"use client";
import { CrossCircledIcon } from "@radix-ui/react-icons";
import { useQueryClient } from "@tanstack/react-query";
import { lazy, Suspense } from "react";
import type { ThirdwebClient } from "../../../../../client/client.js";
import { isEcosystemWallet } from "../../../../../wallets/ecosystem/is-ecosystem-wallet.js";
import type { Wallet } from "../../../../../wallets/interfaces/wallet.js";
import type { EcosystemWalletId } from "../../../../../wallets/wallet-types.js";
import { iconSize } from "../../../../core/design-system/index.js";
import { useActiveWallet } from "../../../../core/hooks/wallets/useActiveWallet.js";
import { useActiveWalletChain } from "../../../../core/hooks/wallets/useActiveWalletChain.js";
import { useAdminWallet } from "../../../../core/hooks/wallets/useAdminWallet.js";
import EcosystemWalletConnectUI from "../../../wallets/ecosystem/EcosystemWalletConnectUI.js";
import { LoadingScreen } from "../../../wallets/shared/LoadingScreen.js";
import { Container, Line, ModalHeader } from "../../components/basic.js";
import { Text } from "../../components/text.js";
import type { ConnectLocale } from "../locale/types.js";
const InAppWalletConnectUI = /* @__PURE__ */ lazy(
() => import("../../../wallets/in-app/InAppWalletConnectUI.js"),
);
/**
* @internal
*/
export function LinkProfileScreen(props: {
onBack: () => void;
locale: ConnectLocale;
client: ThirdwebClient;
walletConnect: { projectId?: string } | undefined;
}) {
const adminWallet = useAdminWallet();
const activeWallet = useActiveWallet();
const chain = useActiveWalletChain();
const queryClient = useQueryClient();
const wallet = adminWallet || activeWallet;
if (!wallet) {
return ;
}
if (wallet.id === "inApp") {
return (
}>
{
setTimeout(() => {
queryClient.invalidateQueries({ queryKey: ["profiles"] });
}, 500);
props.onBack();
}}
goBack={props.onBack}
isLinking={true}
meta={{
showThirdwebBranding: false,
title: props.locale.manageWallet.linkProfile,
}}
size="compact"
wallet={wallet as Wallet<"inApp">}
walletConnect={props.walletConnect}
/>
);
}
if (isEcosystemWallet(wallet)) {
return (
}>
{
setTimeout(() => {
queryClient.invalidateQueries({ queryKey: ["profiles"] });
}, 500);
props.onBack();
}}
goBack={props.onBack}
isLinking={true}
meta={{
showThirdwebBranding: false,
title: props.locale.manageWallet.linkProfile,
}}
size="compact"
wallet={wallet as Wallet}
walletConnect={props.walletConnect}
/>
);
}
return (
This wallet does not support account linking
);
}