"use strict";var e=require("react"),t=require("styled-components"),r=require("react/jsx-runtime"),o=require("viem/utils"),n=require("./wallet-connect-BuohfvHK.js"),i=require("./context-rs-ygOK2.js"),l=require("./events-context-Di6--rDg.js"),a=require("./internal-context-CdsQ3LEl.js"),s=require("./privy-context-UTJouJ1x.js"),c=require("./index-Ub4KpwSY.js"),d=require("./get-entropy-details-for-user-D63rM5_a.js"),p=require("zustand");const u=t.styled.div`
  text-align: left;
  flex-grow: 1;
`,x=t.styled.div`
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  flex-grow: 1;
`,y=t.styled.div`
  display: flex;
  flex-direction: column;
  gap: 8px;

  /* for Internet Explorer, Edge */
  -ms-overflow-style: none;

  /* for Firefox */
  scrollbar-width: none;

  /* for Chrome, Safari, and Opera */
  &::-webkit-scrollbar {
    display: none;
  }
`,g=t.styled(y)`
  ${e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0}

  background-repeat: no-repeat;
  background-size:
    100% 32px,
    100% 16px;
  background-attachment: local, scroll;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 3px;
`;let f=t.css`
  && {
    width: 100%;
    font-size: 16px;
    line-height: 24px;
    min-height: 56px;

    /* Tablet and Up */
    @media (min-width: 440px) {
      font-size: 14px;
    }

    display: flex;
    gap: 12px;
    align-items: center;
    color: var(--privy-color-foreground);

    padding: 10px 12px;
    border: 1px solid var(--privy-color-foreground-4) !important;
    border-radius: var(--privy-border-radius-md);
    transition: background-color 200ms ease;

    cursor: pointer;

    &:hover {
      background-color: var(--privy-color-background-2);
    }

    &:disabled {
      cursor: pointer;
      background-color: var(--privy-color-background-2);
    }
  }
`;const h=t.styled.div`
  text-align: center;
  font-size: 14px;
  margin-bottom: 24px;
`,v=t.styled.button.attrs({className:"login-method-button"})`
  ${f}
`;t.styled.a`
  ${f}
`;const b=t.styled.div`
  width: 32px;
  height: 32px;
  border-radius: ${e=>e.$fullSize?"0":"4px"};
  background: ${e=>e.$fullSize?"transparent":"var(--privy-color-background-2)"};
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;

  svg {
    width: ${e=>e.$fullSize?"32px":"18px"};
    height: ${e=>e.$fullSize?"32px":"18px"};
    color: ${e=>e.$fullSize?"inherit":"var(--privy-color-icon-muted)"};
  }
`,m=t.styled.div`
  width: 100%;
  height: 100%;
  min-height: inherit;
  display: flex;
  flex-direction: column;
  ${e=>e.$if?"display: none;":""}
`,w=t.styled.div`
  width: 100%;
  height: 100%;
  padding: ${e=>e.$withPadding?"64px 0px":"0px"};
`,C=t.styled.div`
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
  gap: 12px;
  & h3 {
    font-size: 18px;
    font-style: normal;
    font-weight: 600;
    line-height: 24px;
  }
  & p {
    max-width: 300px;
    font-size: 14px;
    font-style: normal;
    font-weight: 400;
    line-height: 20px;
  }
`;let S=t.styled.span`
  && {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 2;
  }
`,k=t.styled.span`
  position: relative;
  width: 82px;
  height: 82px;
  display: inline-block;
`;const $=t.styled.span`
  && {
    width: 82px;
    height: 82px;
    border-width: 4px;
    border-style: solid;
    border-color: ${e=>e.color??"var(--privy-color-icon-subtle)"};
    border-bottom-color: transparent;
    border-radius: 50%;
    display: inline-block;
    box-sizing: border-box;
    animation: rotation 1.2s linear infinite;
    transition: border-color 800ms;
  }

  @keyframes rotation {
    0% {
      transform: rotate(0deg);
    }
    100% {
      transform: rotate(360deg);
    }
  }

  &&&.success {
    border-color: var(--privy-color-icon-success);
    border-bottom-color: var(--privy-color-icon-success);
  }

  &&&.fail {
    border-color: var(--privy-color-icon-error);
    border-bottom-color: var(--privy-color-icon-error);
  }
`,j=t.styled($)`
  && {
    border-bottom-color: ${e=>e.color??"var(--privy-color-border-default)"};
    border-color: ${e=>e.color??"var(--privy-color-border-default)"};
    animation: none;
    opacity: 0.5;
  }
`;let T=t.styled($)`
  && {
    height: 1rem;
    width: 1rem;
    margin: 2px 0;
    border-width: 1.5px;

    /* Override default Loader to match button transitions */
    transition: border-color 200ms ease;
  }
`;let W=/*#__PURE__*/e.createContext({});let z=e=>`privy:${e}:recent-login-method`,P=e=>`privy:${e}:recent-login-wallet-client`,I=e=>`privy:${e}:recent-login-chain-type`;const E=p.create((()=>({isModalOpen:!1,resolvers:null})));let L=p.create((()=>({})));const M=async()=>{let e,t,r=new Promise(((r,o)=>{e=r,t=o}));return L.setState({}),E.setState({isModalOpen:!0,resolvers:{resolve:e,reject:t}}),await r},q=({address:e,client:t,appId:r})=>{let o=`${t}:${e}`;r&&n.s.put(A(r),o),E.setState({wallet:o})},A=e=>`privy:${e}:active-wallet-connection`;exports.AlignBottom=x,exports.ButtonLoader=e=>/*#__PURE__*/r.jsx(T,{color:e.color||"var(--privy-color-foreground-3)"}),exports.ConnectionLoader=({success:e,fail:t})=>/*#__PURE__*/r.jsxs(k,{children:[/*#__PURE__*/r.jsx(S,{children:/*#__PURE__*/r.jsx(j,{className:e?"success":t?"fail":""})}),/*#__PURE__*/r.jsx(S,{children:/*#__PURE__*/r.jsx($,{className:e?"success":t?"fail":""})})]}),exports.EmptyWalletState=w,exports.Grow=u,exports.Header=C,exports.Hide=m,exports.Loader=$,exports.LoaderFaint=j,exports.LoginMethodButton=v,exports.LoginMethodContainer=y,exports.LoginMethodContainerWithScrollShadows=g,exports.LoginMethodIconWrapper=b,exports.RecentlyUsedAccountProvider=({children:t})=>{let o=i.useAppConfig(),[a,s]=e.useState({});return l.usePrivyEventSubscription("login",{onComplete:({loginAccount:e})=>{e&&"passkey"!==e.type&&"cross_app"!==e.type&&("wallet"!==e.type||"privy"!==e.walletClientType)&&(n.s.put(z(o.id),e.type),"wallet"===e.type?(n.s.put(P(o.id),e.walletClientType),n.s.put(I(o.id),e.chainType),s({accountType:e.type,walletClientType:e.walletClientType,chainType:e.chainType})):(n.s.del(P(o.id)),n.s.del(I(o.id)),s({accountType:e.type})))}}),e.useEffect((()=>{if(!o.id)return;let e=n.s.get(z(o.id)),t=n.s.get(P(o.id)),r=n.s.get(I(o.id));e&&s("wallet"===e?{accountType:e,walletClientType:t,chainType:r}:{accountType:e})}),[o.id]),/*#__PURE__*/r.jsx(W.Provider,{value:a,children:t})},exports.Subtitle=h,exports.close=()=>{let e=E.getState().resolvers;e||console.warn("useActiveWalletStore: Called close while modal was not open"),E.setState({isModalOpen:!1}),e?.resolve({wallet:E.getState().wallet})},exports.enforceDefaultChainAfterConnect=async function(e,t,r){if(!t.shouldEnforceDefaultChainOnConnect)return;let i=Number(e.chainId.replace("eip155:",""));if(!t.chains.find((e=>e.id===i))&&("wallet_connect_v2"!==e.connectorType||"metamask"!==e.walletClientType)){r?.();try{await e.switchChain(t.defaultChain.id),e.chainId=n.formatChainIdToCAIP2(o.toHex(t.defaultChain.id))}catch{n.connectorLogger.warn("Unable to switch to default chain after connect",{chainId:t.defaultChain.id})}}},exports.setActiveWallet=q,exports.updateBalance=(e,t,r)=>{L.setState((o=>({[e]:{...o[e],[t]:r}})))},exports.useActiveWallet=()=>{let t=i.useAppConfig(),{wallets:r}=d.useWallets(),{connectors:o}=a.usePrivyInternal(),l=e.useMemo((()=>o.filter(c.isSolanaWalletConnector).flatMap((e=>e.wallets))),[o]),s=E((e=>e.wallet));e.useEffect((()=>{if(!t.id)return;let e=n.s.get(A(t.id));E.setState({wallet:e})}),[t.id]);let p=e.useMemo((()=>{if(!s)return;let[,e]=s.split(":");return r.find((t=>t.address===e))||l.find((t=>t.address===e))}),[s,r,l]),u=e.useMemo((()=>p?"ethereum"===p.type?p.chainId:"solana":void 0),[p]);return{connect:async e=>{e?.reset&&(n.s.del(A(t.id)),E.setState({wallet:void 0}));let{wallet:o}=await M();if(!o)return{};let[,i]=o.split(":"),a=r.find((e=>e.address===i));if(a)return{wallet:a,network:a.chainId};let s=l.find((e=>e.address===i));return s?{wallet:s,network:"solana"}:{}},setActiveWallet:e.useCallback((e=>{q({address:e.address,client:e.walletClientType,appId:t.id})}),[t.id]),wallet:p,network:u}},exports.useBalance=(e,t)=>L((r=>r[e]?.[t])),exports.useConnectWallet=function(t){let{connectWallet:r}=e.useContext(s.PrivyContext);return l.usePrivyEventSubscription("connectWallet",t),{connectWallet:r}},exports.useElementHeight=t=>{let[r,o]=e.useState("auto");return e.useEffect((()=>{let e=new ResizeObserver((e=>{o(e[0]?.contentRect.height??"auto")}));return t.current&&e.observe(t.current),()=>{t.current&&e.unobserve(t.current)}}),[t.current]),r},exports.useFundWallet=e=>{l.usePrivyEventSubscription("fundWallet",e);let{fundWallet:t}=a.usePrivyInternal();return{fundWallet:({address:e,options:r})=>t(e,r)}},exports.useIsModalOpen=()=>E((e=>e.isModalOpen)),exports.useLogin=function(t){let{login:r}=e.useContext(s.PrivyContext);return l.usePrivyEventSubscription("login",t),{login:r}},exports.useLogout=function(t){let{logout:r}=e.useContext(s.PrivyContext);return l.usePrivyEventSubscription("logout",t),{logout:r}},exports.useRecentlyUsedLogin=()=>e.useContext(W);
//# sourceMappingURL=useActiveWallet-dTc6deka.js.map
