"use client";

import { PrivyProvider } from "@privy-io/react-auth";

import { toSolanaWalletConnectors } from "@privy-io/react-auth/solana";

const solanaConnectors = toSolanaWalletConnectors({
  // By default, shouldAutoConnect is enabled
  shouldAutoConnect: false,
});

export default function MyPrivyProvider({
  children,
}: {
  children: React.ReactNode;
}) {
  return (
    <PrivyProvider
      appId={process.env.NEXT_PUBLIC_PRIVY_APP_ID!}
      config={{
        // Customize Privy's appearance in your app
        appearance: {
          accentColor: "#812f20",
          theme: "light",
          showWalletLoginFirst: false,
          walletChainType: "solana-only",
          // walletList: ["phantom"],
          logo: "https://supabasekong-mco40gw4sc0gs4ks40w4c4g4.dev3vds1.link/storage/v1/object/public/agent-thumbnails/Beactio%20Banner.png",
        },
        loginMethods: ["email", "wallet"],
        fundingMethodConfig: {
          moonpay: {
            useSandbox: true,
          },
        },
        // Create embedded wallets for users who don't have a wallet
        embeddedWallets: {
          createOnLogin: "all-users",
          showWalletUIs: true,
        },
        mfa: {
          noPromptOnMfaRequired: false,
        },
        externalWallets: {
          solana: { connectors: solanaConnectors },
        },
      }}
    >
      {children}
    </PrivyProvider>
  );
}
