@crossmint/client-sdk-react-ui 1.19.10 → 1.19.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/{chunk-V663SZLR.cjs → chunk-4NAIVYZA.cjs} +1 -1
- package/dist/{chunk-OUHJCKNS.cjs → chunk-52TPOYZX.cjs} +1 -1
- package/dist/chunk-6JL2Z7HQ.js +1 -0
- package/dist/{chunk-C4OBVGU2.js → chunk-6LCKIE2N.js} +1 -1
- package/dist/{chunk-MWBXDGMH.cjs → chunk-ACQ5A3N3.cjs} +1 -1
- package/dist/{chunk-QOAJW7AL.js → chunk-CE67LUEG.js} +1 -1
- package/dist/{chunk-ORB3KG3Y.js → chunk-CX2TFMWD.js} +1 -1
- package/dist/{chunk-UO3X37VU.cjs → chunk-DX6N75BJ.cjs} +1 -1
- package/dist/{chunk-XD2PPF3S.cjs → chunk-E3FSY4S6.cjs} +1 -1
- package/dist/{chunk-RBVM6I2M.js → chunk-IG2QFOPZ.js} +1 -1
- package/dist/chunk-ISBULNSO.js +6 -0
- package/dist/{chunk-KGKNJ5IE.cjs → chunk-JAE37BIK.cjs} +1 -1
- package/dist/{chunk-3U4DUXCZ.cjs → chunk-L7JAEZCV.cjs} +1 -1
- package/dist/{chunk-ZPOFU55O.cjs → chunk-M2UL6C5E.cjs} +1 -1
- package/dist/chunk-MPAPLYZ5.cjs +6 -0
- package/dist/{chunk-JOMJPVZA.js → chunk-N65GIM5A.js} +1 -1
- package/dist/{chunk-KKNYY377.js → chunk-OG3C54GN.js} +1 -1
- package/dist/{chunk-4LVYOALZ.js → chunk-OR3NPL3T.js} +1 -1
- package/dist/{chunk-RJ7DUWCV.cjs → chunk-QCUCNKQF.cjs} +1 -1
- package/dist/{chunk-X5NSB3JN.js → chunk-QFBTVRV3.js} +1 -1
- package/dist/{chunk-CUGB72S5.js → chunk-SVRYTBGZ.js} +1 -1
- package/dist/{chunk-BHSFIQN7.js → chunk-UZBA2TKS.js} +1 -1
- package/dist/{chunk-SSJC2ISE.cjs → chunk-W25BBGJL.cjs} +1 -1
- package/dist/{chunk-2XE54HE2.cjs → chunk-XNPRYDMW.cjs} +1 -1
- package/dist/components/CrossmintNFTCollectionView.cjs +1 -1
- package/dist/components/CrossmintNFTCollectionView.js +1 -1
- package/dist/components/CrossmintNFTDetail.cjs +1 -1
- package/dist/components/CrossmintNFTDetail.js +1 -1
- package/dist/components/auth/AuthForm.cjs +1 -1
- package/dist/components/auth/AuthForm.js +1 -1
- package/dist/components/auth/AuthFormBackButton.cjs +1 -1
- package/dist/components/auth/AuthFormBackButton.js +1 -1
- package/dist/components/auth/AuthFormDialog.cjs +1 -1
- package/dist/components/auth/AuthFormDialog.js +1 -1
- package/dist/components/auth/EmbeddedAuthForm.cjs +1 -1
- package/dist/components/auth/EmbeddedAuthForm.js +1 -1
- package/dist/components/auth/PasskeyPrompt.cjs +1 -1
- package/dist/components/auth/PasskeyPrompt.js +1 -1
- package/dist/components/auth/methods/email/EmailAuthFlow.cjs +1 -1
- package/dist/components/auth/methods/email/EmailAuthFlow.js +1 -1
- package/dist/components/auth/methods/email/EmailOTPInput.cjs +1 -1
- package/dist/components/auth/methods/email/EmailOTPInput.js +1 -1
- package/dist/components/auth/methods/email/EmailSignIn.cjs +1 -1
- package/dist/components/auth/methods/email/EmailSignIn.js +1 -1
- package/dist/components/auth/methods/farcaster/FarcasterSignIn.cjs +1 -1
- package/dist/components/auth/methods/farcaster/FarcasterSignIn.js +1 -1
- package/dist/components/auth/methods/google/ContinueWithGoogle.cjs +1 -1
- package/dist/components/auth/methods/google/ContinueWithGoogle.js +1 -1
- package/dist/components/auth/methods/google/GoogleSignIn.cjs +1 -1
- package/dist/components/auth/methods/google/GoogleSignIn.js +1 -1
- package/dist/components/auth/methods/twitter/TwitterSignIn.cjs +1 -1
- package/dist/components/auth/methods/twitter/TwitterSignIn.js +1 -1
- package/dist/components/auth/methods/web3/Web3AuthFlow.cjs +1 -1
- package/dist/components/auth/methods/web3/Web3AuthFlow.js +1 -1
- package/dist/components/auth/methods/web3/Web3AuthFlowButton.cjs +1 -1
- package/dist/components/auth/methods/web3/Web3AuthFlowButton.js +1 -1
- package/dist/components/auth/methods/web3/Web3Connectors.cjs +1 -1
- package/dist/components/auth/methods/web3/Web3Connectors.js +1 -1
- package/dist/components/common/Divider.cjs +1 -1
- package/dist/components/common/Divider.js +1 -1
- package/dist/components/embed/v3/CrossmintEmbeddedCheckoutV3.cjs +1 -1
- package/dist/components/embed/v3/CrossmintEmbeddedCheckoutV3.js +1 -1
- package/dist/components/embed/v3/EmbeddedCheckoutV3IFrame.cjs +1 -1
- package/dist/components/embed/v3/EmbeddedCheckoutV3IFrame.js +1 -1
- package/dist/components/embed/v3/index.cjs +1 -1
- package/dist/components/embed/v3/index.js +1 -1
- package/dist/components/hosted/CrossmintPayButton_DEPRECATED.cjs +1 -1
- package/dist/components/hosted/CrossmintPayButton_DEPRECATED.js +1 -1
- package/dist/components/hosted/index.cjs +1 -1
- package/dist/components/hosted/index.js +1 -1
- package/dist/components/hosted/v3/CrossmintHostedCheckoutV3.cjs +1 -1
- package/dist/components/hosted/v3/CrossmintHostedCheckoutV3.js +1 -1
- package/dist/components/hosted/v3/index.cjs +1 -1
- package/dist/components/hosted/v3/index.js +1 -1
- package/dist/components/index.cjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/consts/version.cjs +1 -1
- package/dist/consts/version.js +1 -1
- package/dist/hooks/index.cjs +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/useAuth.cjs +1 -1
- package/dist/hooks/useAuth.js +1 -1
- package/dist/hooks/useCrossmintAuth.cjs +1 -1
- package/dist/hooks/useCrossmintAuth.js +1 -1
- package/dist/hooks/useCrossmintCheckout.cjs +1 -1
- package/dist/hooks/useCrossmintCheckout.js +1 -1
- package/dist/hooks/useOAuthWindowListener.cjs +1 -1
- package/dist/hooks/useOAuthWindowListener.js +1 -1
- package/dist/hooks/useSignerInvisibleIFrame.d.cts +137 -39
- package/dist/hooks/useSignerInvisibleIFrame.d.ts +137 -39
- package/dist/hooks/useWallet.cjs +1 -1
- package/dist/hooks/useWallet.js +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/providers/CrossmintAuthProvider.cjs +1 -1
- package/dist/providers/CrossmintAuthProvider.js +1 -1
- package/dist/providers/CrossmintWalletProvider.cjs +1 -1
- package/dist/providers/CrossmintWalletProvider.js +1 -1
- package/dist/providers/auth/AuthFormProvider.cjs +1 -1
- package/dist/providers/auth/AuthFormProvider.js +1 -1
- package/dist/providers/auth/web3/DynamicWeb3WalletConnect.cjs +1 -1
- package/dist/providers/auth/web3/DynamicWeb3WalletConnect.js +1 -1
- package/dist/providers/index.cjs +1 -1
- package/dist/providers/index.js +1 -1
- package/dist/providers/signers/CrossmintSignerProvider.cjs +1 -1
- package/dist/providers/signers/CrossmintSignerProvider.js +1 -1
- package/dist/utils/createCrossmintApiClient.cjs +1 -1
- package/dist/utils/createCrossmintApiClient.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-CJLEWP72.js +0 -1
- package/dist/chunk-F5H6BPF2.cjs +0 -6
- package/dist/chunk-YOCCNJIU.js +0 -6
package/dist/chunk-F5H6BPF2.cjs
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkAHO6ZTD2cjs = require('./chunk-AHO6ZTD2.cjs');var _chunkBR77Q3PKcjs = require('./chunk-BR77Q3PK.cjs');var _chunkPZ3KXKJDcjs = require('./chunk-PZ3KXKJD.cjs');var _chunkAHD64NAJcjs = require('./chunk-AHD64NAJ.cjs');var _chunk3U4DUXCZcjs = require('./chunk-3U4DUXCZ.cjs');var _chunkHLGNSXEQcjs = require('./chunk-HLGNSXEQ.cjs');var _chunkWMBBIP2Ccjs = require('./chunk-WMBBIP2C.cjs');var _chunkHG5ML6KXcjs = require('./chunk-HG5ML6KX.cjs');var _chunk2BOQSASOcjs = require('./chunk-2BOQSASO.cjs');var _chunkZ2FGFHRQcjs = require('./chunk-Z2FGFHRQ.cjs');var _chunkWABJHG6Bcjs = require('./chunk-WABJHG6B.cjs');var _chunkFASRTACDcjs = require('./chunk-FASRTACD.cjs');var _chunkLYUOGA56cjs = require('./chunk-LYUOGA56.cjs');var _chunkGARYGAY7cjs = require('./chunk-GARYGAY7.cjs');var _chunkJNLQRLICcjs = require('./chunk-JNLQRLIC.cjs');var _chunkE65EGG73cjs = require('./chunk-E65EGG73.cjs');var _chunkTM7WDKYRcjs = require('./chunk-TM7WDKYR.cjs');var _chunkZBQCXWMDcjs = require('./chunk-ZBQCXWMD.cjs');var _chunkTXOVDTYKcjs = require('./chunk-TXOVDTYK.cjs');var _chunkNRN4WNQLcjs = require('./chunk-NRN4WNQL.cjs');var _chunkYXF74MVIcjs = require('./chunk-YXF74MVI.cjs');var _chunkI4GMMHQRcjs = require('./chunk-I4GMMHQR.cjs');var _chunkSRQAQHYKcjs = require('./chunk-SRQAQHYK.cjs');var _chunkGPQZG7HCcjs = require('./chunk-GPQZG7HC.cjs');var _chunkCDSQUWS7cjs = require('./chunk-CDSQUWS7.cjs');var _chunk74NYCN24cjs = require('./chunk-74NYCN24.cjs');var _chunk2WSEHVNPcjs = require('./chunk-2WSEHVNP.cjs');var _react = require('react');var _walletssdk = require('@crossmint/wallets-sdk');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var _reactdom = require('react-dom');var _jsxruntime = require('react/jsx-runtime');var St=_react.createContext.call(void 0, {status:"not-loaded",getOrCreateWallet:()=>Promise.resolve({startedCreation:!1}),createPasskeySigner:()=>Promise.resolve(null),clearWallet:()=>{}});function le({children:r,showPasskeyHelpers:e=!0,appearance:o,experimental_enableRecoveryKeys:t=!1,experimental_signersURL:s=void 0}){let[i,n]=_react.useState.call(void 0, {status:"not-loaded"}),l={walletState:i,setWalletState:n,showPasskeyHelpers:e,appearance:o,experimental_enableRecoveryKeys:t};return t?_jsxruntime.jsx.call(void 0, _chunkJNLQRLICcjs.a,{children:_jsxruntime.jsx.call(void 0, ne,{walletState:i,setWalletState:n,appearance:o,signersURL:s,children:_jsxruntime.jsx.call(void 0, re,_chunk2WSEHVNPcjs.b.call(void 0, _chunk2WSEHVNPcjs.a.call(void 0, {},l),{children:r}))})}):_jsxruntime.jsx.call(void 0, re,_chunk2WSEHVNPcjs.b.call(void 0, _chunk2WSEHVNPcjs.a.call(void 0, {},l),{children:r}))}function re({children:r,showPasskeyHelpers:e=!0,appearance:o,walletState:t,setWalletState:s,experimental_enableRecoveryKeys:i}){let{crossmint:n}=_chunkGPQZG7HCcjs.b.call(void 0, "CrossmintWalletProvider must be used within CrossmintProvider"),{experimental_getOrCreateWalletWithRecoveryKey:l}=se({enabled:i!=null?i:!1}),c=_react.useMemo.call(void 0, ()=>_walletssdk.CrossmintWallets.from({apiKey:n.apiKey,jwt:n==null?void 0:n.jwt}),[n.apiKey,n.jwt]),[f,m]=_react.useState.call(void 0, {open:!1}),y=x=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){var p,A;if(t.status=="in-progress")return{startedCreation:!1,reason:"Wallet is already loading."};if(n.jwt==null)return{startedCreation:!1,reason:'Jwt not set in "CrossmintProvider".'};try{s({status:"in-progress"});let S={onWalletCreationStart:a("create-wallet"),onWalletCreationFail:a("create-wallet-error"),onTransactionStart:a("transaction"),onTransactionFail:a("transaction-error")};switch(x.type){case"evm-smart-wallet":{let W={adminSigner:(p=x.args.adminSigner)!=null?p:{type:"evm-passkey"},linkedUser:x.args.linkedUser},P=yield c.getOrCreateWallet("evm-smart-wallet",W,{experimental_callbacks:((A=W.adminSigner)==null?void 0:A.type)==="evm-passkey"?S:void 0});s({status:"loaded",wallet:P,type:"evm-smart-wallet"});break}case"solana-smart-wallet":{let W=yield c.getOrCreateWallet("solana-smart-wallet",x.args);s({status:"loaded",wallet:W,type:"solana-smart-wallet"});break}}}catch(S){console.error("There was an error creating a wallet ",S),s(_chunkLYUOGA56cjs.a.call(void 0, S))}return{startedCreation:!0}}),a=x=>()=>new Promise(p=>{if(!e){p();return}m({type:x,open:!0,primaryActionOnClick:()=>{m({open:!1}),p()},secondaryActionOnClick:()=>{m({open:!1}),p()}})}),w=()=>{s({status:"not-loaded"})},h=(x,p)=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){return p!=null&&(yield a(p)()),yield _chunkFASRTACDcjs.a.call(void 0, x)}),d=_react.useMemo.call(void 0, ()=>_chunk2WSEHVNPcjs.b.call(void 0, _chunk2WSEHVNPcjs.a.call(void 0, {},t),{getOrCreateWallet:y,createPasskeySigner:h,clearWallet:w,experimental_getOrCreateWalletWithRecoveryKey:l}),[t,l]);return _jsxruntime.jsxs.call(void 0, St.Provider,{value:d,children:[r,f.open?_reactdom.createPortal.call(void 0, _jsxruntime.jsx.call(void 0, _chunk3U4DUXCZcjs.a,{state:f,appearance:o}),document.body):null]})}function ae(){let r=_react.useContext.call(void 0, St);if(!r)throw new Error("useWallet must be used within CrossmintAuthProvider or CrossmintWalletProvider");return r}var _clientsdkauth = require('@crossmint/client-sdk-auth');var _commonsdkauth = require('@crossmint/common-sdk-auth');var _reactvisuallyhidden = require('@radix-ui/react-visually-hidden');function _(){let r=_react.useContext.call(void 0, st);if(!r)throw new Error("useCrossmintAuth must be used within a CrossmintAuthProvider");return r}var me={google:"",twitter:""},ue=_react.createContext.call(void 0, void 0),v= exports.h =()=>{let r=_react.useContext.call(void 0, ue);if(!r)throw new Error("useAuthForm must be used within an AuthFormProvider");return r},ce= exports.i =({setDialogOpen:r,preFetchOAuthUrls:e,initialState:o,children:t})=>{let{crossmintAuth:s}=_(),[i,n]=_react.useState.call(void 0, "initial"),[l,c]=_react.useState.call(void 0, null),[f,m]=_react.useState.call(void 0, me),[y,a]=_react.useState.call(void 0, !0),{loginMethods:w,baseUrl:h,appearance:d,termsOfServiceText:x,authModalTitle:p,defaultEmail:A}=o,S=_react.useCallback.call(void 0, ()=>_chunk2WSEHVNPcjs.d.call(void 0, void 0,null,function*(){a(!0);try{let b=w.filter(E=>E in me).map(E=>_chunk2WSEHVNPcjs.d.call(void 0, void 0,null,function*(){let U=yield s==null?void 0:s.getOAuthUrl(E);return{[E]:U}})),u=Object.assign({},...yield Promise.all(b));m(u)}catch(g){c(g instanceof _commonsdkauth.CrossmintAuthenticationError?g.message:"Unable to load oauth providers. Please try again later.")}finally{a(!1)}}),[w,s]);_react.useEffect.call(void 0, ()=>{e&&S()},[S,e]);let P={step:i,error:l,baseUrl:h,appearance:d,termsOfServiceText:x,authModalTitle:p,loginMethods:w,defaultEmail:A,oauthUrlMap:f,isLoadingOauthUrlMap:y,setDialogOpen:(g,b)=>{r==null||r(g,b),g||setTimeout(()=>n("initial"),250)},setError:c,setStep:n};return _jsxruntime.jsx.call(void 0, ue.Provider,{value:P,children:t})};var _color = require('color'); var _color2 = _interopRequireDefault(_color);var Y=i=>{var n=i,{className:r,iconColor:e,ringColor:o,onClick:t}=n,s=_chunk2WSEHVNPcjs.c.call(void 0, n,["className","iconColor","ringColor","onClick"]);let{setError:l}=v();return _jsxruntime.jsx.call(void 0, "button",_chunk2WSEHVNPcjs.b.call(void 0, _chunk2WSEHVNPcjs.a.call(void 0, {className:_chunkWABJHG6Bcjs.a.call(void 0, "absolute left-4 top-4 min-[480px]:!left-6 min-[480px]:!top-6 rounded-full opacity-70 ring-offset-background text-cm-text-primary transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-cm-accent focus:ring-offset-2 disabled:pointer-events-none",r),onClick:c=>{l(null),t==null||t(c)}},s),{children:_jsxruntime.jsx.call(void 0, _chunkTM7WDKYRcjs.a,{className:"w-6 h-6",style:{color:e}})}))};var Je=6;function fe({otpEmailData:r,setOtpEmailData:e}){var x,p,A,S,W,P,g,b,u,E,U,V,T,M,K,J,j,O,z,ot;let{crossmintAuth:o}=_(),{appearance:t,setDialogOpen:s,setStep:i,setError:n}=v(),[l,c]=_react.useState.call(void 0, ""),[f,m]=_react.useState.call(void 0, !1),[y,a]=_react.useState.call(void 0, !1),w=()=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){var I,Ct;a(!0);try{let vt=yield o==null?void 0:o.confirmEmailOtp((I=r==null?void 0:r.email)!=null?I:"",(Ct=r==null?void 0:r.emailId)!=null?Ct:"",l);yield o==null?void 0:o.handleRefreshAuthMaterial(vt),s(!1,!0),i("initial")}catch(vt){console.error("Error confirming email OTP",vt),n("Invalid code. Please try again."),m(!0)}finally{a(!1)}}),h=()=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){var I;try{yield o==null?void 0:o.sendEmailOtp((I=r==null?void 0:r.email)!=null?I:"")}catch(Ct){n("Failed to resend code. Please try again.")}});return _jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, Y,{onClick:()=>{i("initial"),e(null)},iconColor:(x=t==null?void 0:t.colors)==null?void 0:x.textPrimary,ringColor:(p=t==null?void 0:t.colors)==null?void 0:p.accent}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-center justify-start w-full",children:[_jsxruntime.jsx.call(void 0, "div",{className:"relative left-3",children:_jsxruntime.jsx.call(void 0, _chunkI4GMMHQRcjs.a,{customAccentColor:(A=t==null?void 0:t.colors)==null?void 0:A.accent,customButtonBackgroundColor:(S=t==null?void 0:t.colors)==null?void 0:S.buttonBackground,customBackgroundColor:(W=t==null?void 0:t.colors)==null?void 0:W.background})}),_jsxruntime.jsx.call(void 0, "p",{className:"text-base font-normal mt-4 mb-1 text-center text-cm-text-primary",style:{color:(P=t==null?void 0:t.colors)==null?void 0:P.textPrimary},children:"Check your email"}),_jsxruntime.jsxs.call(void 0, "p",{className:"text-center text-cm-text-secondary px-4",style:{color:(g=t==null?void 0:t.colors)==null?void 0:g.textSecondary},children:["A temporary login code has been sent to"," ",r!=null&&r.email?r.email:"your email address"]}),_jsxruntime.jsx.call(void 0, "div",{className:"py-8",children:_jsxruntime.jsx.call(void 0, _chunkHG5ML6KXcjs.a,{maxLength:Je,value:l,onChange:I=>{c(I),m(!1),n(null)},onComplete:w,disabled:y,customStyles:{accent:(u=(b=t==null?void 0:t.colors)==null?void 0:b.accent)!=null?u:"#04AA6D",danger:(U=(E=t==null?void 0:t.colors)==null?void 0:E.danger)!=null?U:"#f44336",border:(T=(V=t==null?void 0:t.colors)==null?void 0:V.border)!=null?T:"#E5E7EB",textPrimary:(K=(M=t==null?void 0:t.colors)==null?void 0:M.textPrimary)!=null?K:"#909ca3",buttonBackground:(j=(J=t==null?void 0:t.colors)==null?void 0:J.buttonBackground)!=null?j:"#eff6ff",inputBackground:(z=(O=t==null?void 0:t.colors)==null?void 0:O.inputBackground)!=null?z:"#FFFFFF",borderRadius:t==null?void 0:t.borderRadius},children:_jsxruntime.jsxs.call(void 0, _chunkHG5ML6KXcjs.b,{children:[_jsxruntime.jsx.call(void 0, _chunkHG5ML6KXcjs.c,{index:0,hasError:f}),_jsxruntime.jsx.call(void 0, _chunkHG5ML6KXcjs.c,{index:1,hasError:f}),_jsxruntime.jsx.call(void 0, _chunkHG5ML6KXcjs.c,{index:2,hasError:f}),_jsxruntime.jsx.call(void 0, _chunkHG5ML6KXcjs.c,{index:3,hasError:f}),_jsxruntime.jsx.call(void 0, _chunkHG5ML6KXcjs.c,{index:4,hasError:f}),_jsxruntime.jsx.call(void 0, _chunkHG5ML6KXcjs.c,{index:5,hasError:f})]})})}),_jsxruntime.jsx.call(void 0, "div",{className:"text-xs leading-tight text-cm-text-secondary text-center",children:_jsxruntime.jsxs.call(void 0, "span",{style:{color:(ot=t==null?void 0:t.colors)==null?void 0:ot.textSecondary},children:["Can't find the email? Check spam folder.",`
|
|
2
|
-
`,"Some emails may take several minutes to arrive."]})}),_jsxruntime.jsx.call(void 0, _chunkHLGNSXEQcjs.a,{initialSeconds:60,appearance:t,countdownText:I=>`Re-send code in ${I}s`,countdownCompleteText:"Re-send code",handleOnClick:h})]})]})}var _clientsdkwindow = require('@crossmint/client-sdk-window');var _zod = require('zod');var Z=r=>{let{crossmintAuth:e}=_(),{oauthUrlMap:o,setError:t}=v(),[s,i]=_react.useState.call(void 0, !1),n=_react.useRef.call(void 0, null);return _react.useEffect.call(void 0, ()=>(n.current==null&&(n.current=new (0, _clientsdkwindow.ChildWindow)(window.opener||window.parent,"*",{incomingEvents:eo})),()=>{n.current!=null&&n.current.off("authMaterialFromPopupCallback")}),[]),{createPopupAndSetupListeners:c=>_chunk2WSEHVNPcjs.d.call(void 0, void 0,null,function*(){if(n.current==null)throw new Error("Child window not initialized");i(!0),t(null);let f=new URL(o[r]);if(c!=null){let h=Array.from(f.searchParams.entries());f.search="",c&&f.searchParams.append("provider_login_hint",c),h.forEach(([d,x])=>{f.searchParams.append(d,x)})}let m=yield _clientsdkwindow.PopupWindow.init(f.toString(),{awaitToLoad:!1,crossOrigin:!0,width:400,height:700}),y=h=>_chunk2WSEHVNPcjs.d.call(void 0, void 0,null,function*(){var d;yield e==null?void 0:e.handleRefreshAuthMaterial(h.oneTimeSecret),(d=n.current)==null||d.off("authMaterialFromPopupCallback"),m.window.close(),i(!1)}),a=h=>{var d;t(h.error),(d=n.current)==null||d.off("errorFromPopupCallback"),m.window.close(),i(!1)};n.current.on("authMaterialFromPopupCallback",y),n.current.on("errorFromPopupCallback",a);let w=setInterval(()=>{var h;m.window.closed&&(clearInterval(w),i(!1),(h=n.current)==null||h.off("authMaterialFromPopupCallback"))},2500)}),isLoading:s}},eo={authMaterialFromPopupCallback:_zod.z.object({oneTimeSecret:_zod.z.string()}),errorFromPopupCallback:_zod.z.object({error:_zod.z.string()})};function ge({emailInput:r,appearance:e}){var s,i,n,l;let{createPopupAndSetupListeners:o,isLoading:t}=Z("google");return _jsxruntime.jsxs.call(void 0, "button",{type:"button",className:_chunkWABJHG6Bcjs.a.call(void 0, "flex items-center gap-2 justify-center h-[32px] px-2.5 border border-cm-border rounded-xl bg-cm-background-primary","hover:bg-cm-hover focus:bg-cm-hover outline-none",t?"cursor-not-allowed hover:bg-cm-muted-primary":""),onClick:t?void 0:()=>o(r.trim().toLowerCase()),style:{backgroundColor:(s=e==null?void 0:e.colors)==null?void 0:s.buttonBackground,borderRadius:e==null?void 0:e.borderRadius},children:[_jsxruntime.jsx.call(void 0, _chunkE65EGG73cjs.a,{className:"max-h-[18px] max-w-[18px] h-[18px] w-[18px]"}),t?_jsxruntime.jsx.call(void 0, _chunkZ2FGFHRQcjs.a,{style:{color:(i=e==null?void 0:e.colors)==null?void 0:i.textSecondary,fill:(n=e==null?void 0:e.colors)==null?void 0:n.textPrimary,width:"18px",height:"18px"}}):_jsxruntime.jsx.call(void 0, "span",{className:"text-cm-accent",style:{color:(l=e==null?void 0:e.colors)==null?void 0:l.accent},children:"Continue"})]})}function pe({setOtpEmailData:r}){var h,d,x,p,A,S,W,P,g,b,u,E,U,V;let{crossmintAuth:e}=_(),{appearance:o,defaultEmail:t,setStep:s,setError:i}=v(),[n,l]=_react.useState.call(void 0, t!=null?t:""),[c,f]=_react.useState.call(void 0, ""),[m,y]=_react.useState.call(void 0, !1),a=n.toLowerCase().includes("@gmail.com")&&!n.toLowerCase().includes("+")&&_commonsdkauth.isEmailValid.call(void 0, n)&&!m;function w(T){return _chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){T.preventDefault(),y(!0);try{let M=n.trim().toLowerCase(),K=yield e==null?void 0:e.sendEmailOtp(M);r({email:M,emailId:K.emailId}),s("otp")}catch(M){y(!1),i("Failed to send email. Please try again or contact support.")}})}return _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment,{children:_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-start justify-start w-full rounded-lg",children:_jsxruntime.jsxs.call(void 0, "div",{className:"w-full",children:[_jsxruntime.jsx.call(void 0, "label",{className:"text-cm-text-primary block mb-[5px]",style:{color:(h=o==null?void 0:o.colors)==null?void 0:h.textPrimary},children:"Email"}),_jsxruntime.jsxs.call(void 0, "form",{role:"form",className:"relative",onSubmit:T=>{if(a){T.preventDefault();return}_commonsdkauth.isEmailValid.call(void 0, n)?w(T):T.preventDefault()},noValidate:!0,children:[_jsxruntime.jsx.call(void 0, "label",{htmlFor:"emailInput",className:"sr-only",children:"Email"}),_jsxruntime.jsx.call(void 0, "input",{className:_chunkWABJHG6Bcjs.a.call(void 0, "flex-grow text-cm-text-primary text-left pl-[16px] h-[58px] w-full border border-cm-border rounded-xl bg-cm-background-primary placeholder:text-md","transition-none duration-200 ease-in-out","focus:outline-none focus-ring-custom","placeholder:[color:var(--placeholder-color)]",c?"border-red-500":"",a?"pr-[132px]":"pr-[80px]"),style:{color:(d=o==null?void 0:o.colors)==null?void 0:d.textPrimary,borderRadius:o==null?void 0:o.borderRadius,borderColor:c?(x=o==null?void 0:o.colors)==null?void 0:x.danger:(p=o==null?void 0:o.colors)==null?void 0:p.border,backgroundColor:(A=o==null?void 0:o.colors)==null?void 0:A.inputBackground,"--placeholder-color":(W=(S=o==null?void 0:o.colors)==null?void 0:S.textSecondary)!=null?W:"#67797F","--focus-ring-color":new (0, _color2.default)((g=(P=o==null?void 0:o.colors)==null?void 0:P.accent)!=null?g:"#04AA6D").alpha(.18).toString()},type:"email",placeholder:"your@email.com",value:n,onChange:T=>{l(T.target.value),f(""),i(null)},readOnly:m,"aria-describedby":"emailError"}),_jsxruntime.jsxs.call(void 0, "div",{className:"absolute inset-y-0 right-0 flex items-center pr-4",children:[c&&_jsxruntime.jsx.call(void 0, _chunkNRN4WNQLcjs.a,{customColor:(b=o==null?void 0:o.colors)==null?void 0:b.danger}),m&&_jsxruntime.jsx.call(void 0, _chunkZ2FGFHRQcjs.a,{style:{color:(u=o==null?void 0:o.colors)==null?void 0:u.textSecondary,fill:(E=o==null?void 0:o.colors)==null?void 0:E.textPrimary}}),a?_jsxruntime.jsx.call(void 0, ge,{emailInput:n,appearance:o}):!c&&!m?_jsxruntime.jsx.call(void 0, "button",{type:"submit",className:_chunkWABJHG6Bcjs.a.call(void 0, "font-medium text-cm-accent text-nowrap bg-cm-background-primary",_commonsdkauth.isEmailValid.call(void 0, n)?"cursor-pointer":"!cursor-not-allowed opacity-60"),style:{color:(U=o==null?void 0:o.colors)==null?void 0:U.accent,backgroundColor:(V=o==null?void 0:o.colors)==null?void 0:V.inputBackground},disabled:!_commonsdkauth.isEmailValid.call(void 0, n)||m,children:"Submit"}):null]})]}),c&&_jsxruntime.jsx.call(void 0, "p",{className:"text-xs text-red-500 mb-2 pt-2",children:c})]})})})}function he(){let{step:r}=v(),[e,o]=_react.useState.call(void 0, null);return r==="otp"?_jsxruntime.jsx.call(void 0, fe,{otpEmailData:e,setOtpEmailData:o}):r==="initial"?_jsxruntime.jsx.call(void 0, pe,{setOtpEmailData:o}):null}function we({appearance:r,text:e}){var t,s,i;let{step:o}=v();return o!=="initial"?null:_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-center justify-center w-full pt-2 pb-3",children:[_jsxruntime.jsx.call(void 0, "span",{className:"w-full h-[1px] bg-cm-border",style:{backgroundColor:(t=r==null?void 0:r.colors)==null?void 0:t.border}}),e!=null?_jsxruntime.jsx.call(void 0, "p",{className:"flex-none px-2 text-sm text-cm-text-primary",style:{color:(s=r==null?void 0:r.colors)==null?void 0:s.textSecondary},children:e}):null,_jsxruntime.jsx.call(void 0, "span",{className:"w-full h-[1px] bg-cm-border",style:{backgroundColor:(i=r==null?void 0:r.colors)==null?void 0:i.border}})]})}function be(e){var r=_chunk2WSEHVNPcjs.c.call(void 0, e,[]);var c,f,m,y;let{step:o,appearance:t,isLoadingOauthUrlMap:s}=v(),{createPopupAndSetupListeners:i,isLoading:n}=Z("google"),l=s||n;return o!=="initial"?null:_jsxruntime.jsxs.call(void 0, "button",_chunk2WSEHVNPcjs.b.call(void 0, _chunk2WSEHVNPcjs.a.call(void 0, {className:_chunkWABJHG6Bcjs.a.call(void 0, "relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none",l?"cursor-not-allowed hover:bg-cm-muted-primary":""),style:{borderRadius:t==null?void 0:t.borderRadius,backgroundColor:(c=t==null?void 0:t.colors)==null?void 0:c.buttonBackground},onClick:l?void 0:()=>i()},r),{children:[_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkE65EGG73cjs.a,{className:"max-h-[25px] max-w-[25px] h-[25px] w-[25px] absolute left-[18px]"}),l?_jsxruntime.jsx.call(void 0, _chunkZ2FGFHRQcjs.a,{style:{color:(f=t==null?void 0:t.colors)==null?void 0:f.textSecondary,fill:(m=t==null?void 0:t.colors)==null?void 0:m.textPrimary}}):_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",style:{margin:"0px 32px",color:(y=t==null?void 0:t.colors)==null?void 0:y.textPrimary},children:"Sign in with Google"})]}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Sign in with Google"})]}))}var _authkit = require('@farcaster/auth-kit');function Ce(){var s,i;let{step:r,appearance:e,setStep:o,setError:t}=v();return r==="initial"?_jsxruntime.jsx.call(void 0, "div",{children:_jsxruntime.jsxs.call(void 0, "button",{className:_chunkWABJHG6Bcjs.a.call(void 0, "relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none"),style:{borderRadius:e==null?void 0:e.borderRadius,backgroundColor:(s=e==null?void 0:e.colors)==null?void 0:s.buttonBackground},onClick:()=>{o("qrCode"),t(null)},children:[_jsxruntime.jsx.call(void 0, _chunkSRQAQHYKcjs.a,{className:"max-h-[25px] max-w-[25px] h-[25px] w-[25px] absolute left-[18px]"}),_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",style:{margin:"0px 32px",color:(i=e==null?void 0:e.colors)==null?void 0:i.textPrimary},children:"Sign in with Farcaster"}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Sign in with Farcaster"})]})}):r==="qrCode"?_jsxruntime.jsx.call(void 0, fo,{}):null}function fo(){var h,d,x,p,A,S,W,P,g;let{crossmintAuth:r}=_(),{appearance:e,setStep:o,setDialogOpen:t,setError:s}=v(),[i,n]=_react.useState.call(void 0, null),l=_react.useMemo.call(void 0, ()=>({onSuccess:b=>{n(b)}}),[]),{signIn:c,url:f,connect:m,signOut:y,isConnected:a}=_authkit.useSignIn.call(void 0, l),w=b=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){s(null);try{let u=yield r==null?void 0:r.signInWithFarcaster(b);yield r==null?void 0:r.handleRefreshAuthMaterial(u),t(!1),o("initial")}catch(u){console.error("Error during Farcaster sign-in:",u),s("Failed to sign in with Farcaster")}});return _react.useEffect.call(void 0, ()=>{i!=null&&w(i)},[i]),_react.useEffect.call(void 0, ()=>{a&&c()},[a]),_react.useEffect.call(void 0, ()=>{m()},[]),_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, Y,{onClick:()=>{y(),o("initial")},iconColor:(h=e==null?void 0:e.colors)==null?void 0:h.textPrimary,ringColor:(d=e==null?void 0:e.colors)==null?void 0:d.accent}),_jsxruntime.jsxs.call(void 0, "div",{className:"flex flex-col items-center gap-4",children:[_jsxruntime.jsxs.call(void 0, "div",{className:"text-center",children:[_jsxruntime.jsx.call(void 0, "h3",{className:"text-lg font-semibold text-cm-text-primary mb-2",style:{color:(x=e==null?void 0:e.colors)==null?void 0:x.textPrimary},children:"Sign in with Farcaster"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-base font-normal text-cm-text-secondary",style:{color:(p=e==null?void 0:e.colors)==null?void 0:p.textSecondary},children:"Scan with your phone's camera to continue."})]}),_jsxruntime.jsx.call(void 0, "div",{className:"bg-white aspect-square rounded-lg p-4",style:{backgroundColor:(A=e==null?void 0:e.colors)==null?void 0:A.inputBackground,borderRadius:e==null?void 0:e.borderRadius},children:f!=null?_jsxruntime.jsx.call(void 0, _authkit.QRCode,{uri:f,size:280}):_jsxruntime.jsx.call(void 0, "div",{className:"min-h-[246px] flex items-center justify-center",children:_jsxruntime.jsx.call(void 0, _chunkZ2FGFHRQcjs.a,{style:{color:(S=e==null?void 0:e.colors)==null?void 0:S.textSecondary,fill:(W=e==null?void 0:e.colors)==null?void 0:W.textPrimary}})})}),f?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, "p",{className:"text-base text-center font-normal text-cm-text-secondary",style:{color:(P=e==null?void 0:e.colors)==null?void 0:P.textSecondary},children:"Alternatively, click on this link to open Warpcast."}),_jsxruntime.jsx.call(void 0, "a",{href:f,rel:"noopener noreferrer",target:"_blank",className:"text-base font-normal text-cm-link",style:{color:(g=e==null?void 0:e.colors)==null?void 0:g.textLink},children:"Open Warpcast"})]}):null]})]})}function Se(e){var r=_chunk2WSEHVNPcjs.c.call(void 0, e,[]);var c,f,m,y;let{step:o,appearance:t,isLoadingOauthUrlMap:s}=v(),{createPopupAndSetupListeners:i,isLoading:n}=Z("twitter"),l=s||n;return o!=="initial"?null:_jsxruntime.jsxs.call(void 0, "button",_chunk2WSEHVNPcjs.b.call(void 0, _chunk2WSEHVNPcjs.a.call(void 0, {className:_chunkWABJHG6Bcjs.a.call(void 0, "relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none",l?"cursor-not-allowed hover:bg-cm-muted-primary":""),style:{borderRadius:t==null?void 0:t.borderRadius,backgroundColor:(c=t==null?void 0:t.colors)==null?void 0:c.buttonBackground},onClick:l?void 0:()=>i()},r),{children:[_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, _chunkZBQCXWMDcjs.a,{className:"max-h-[25px] max-w-[25px] h-[25px] w-[25px] absolute left-[18px]"}),l?_jsxruntime.jsx.call(void 0, _chunkZ2FGFHRQcjs.a,{style:{color:(f=t==null?void 0:t.colors)==null?void 0:f.textSecondary,fill:(m=t==null?void 0:t.colors)==null?void 0:m.textPrimary}}):_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",style:{margin:"0px 32px",color:(y=t==null?void 0:t.colors)==null?void 0:y.textPrimary},children:"Sign in with X"})]}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Sign in with X"})]}))}function Pe(){var s,i,n,l,c;let{step:r,appearance:e,setStep:o,setError:t}=v();return r!=="initial"?null:_jsxruntime.jsxs.call(void 0, "button",{className:_chunkWABJHG6Bcjs.a.call(void 0, "relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none"),style:{borderRadius:e==null?void 0:e.borderRadius,borderColor:(s=e==null?void 0:e.colors)==null?void 0:s.border,backgroundColor:(i=e==null?void 0:e.colors)==null?void 0:i.buttonBackground},onClick:()=>{o("web3"),t(null)},children:[_jsxruntime.jsx.call(void 0, _chunkTXOVDTYKcjs.a,{className:"h-[21px] w-[21px] absolute left-[20px]",style:{color:(n=e==null?void 0:e.colors)==null?void 0:n.textPrimary}}),_jsxruntime.jsx.call(void 0, "span",{className:"font-medium",style:{margin:"0px 32px",color:(l=e==null?void 0:e.colors)==null?void 0:l.textPrimary},children:"Continue with a wallet"}),_jsxruntime.jsx.call(void 0, _chunkYXF74MVIcjs.a,{className:"h-[21px] w-[21px] absolute right-[20px]",style:{color:(c=e==null?void 0:e.colors)==null?void 0:c.textSecondary}}),_jsxruntime.jsx.call(void 0, "span",{className:"sr-only",children:"Continue with a wallet"})]})}var _sdkreactcore = require('@dynamic-labs/sdk-react-core');function Ae(){var t,s;let{appearance:r,step:e,setStep:o}=v();return e==="web3"?_jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment,{children:[_jsxruntime.jsx.call(void 0, Y,{onClick:()=>o("initial"),iconColor:(t=r==null?void 0:r.colors)==null?void 0:t.textPrimary,ringColor:(s=r==null?void 0:r.colors)==null?void 0:s.accent}),_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col items-center",children:_jsxruntime.jsx.call(void 0, "div",{className:"flex flex-col gap-[10px] w-full",children:_jsxruntime.jsx.call(void 0, "div",{className:"widget-container",children:_jsxruntime.jsx.call(void 0, _sdkreactcore.DynamicEmbeddedWidget,{background:"none"})})})})]}):null}function ke(){let{step:r}=v();return r.startsWith("web3")?_jsxruntime.jsx.call(void 0, Ae,{}):r==="initial"?_jsxruntime.jsx.call(void 0, Pe,{}):null}function Ee({className:r}){var c,f,m,y,a,w,h,d,x,p,A,S,W;let{step:e,appearance:o,loginMethods:t,baseUrl:s,error:i,termsOfServiceText:n,authModalTitle:l}=v();return _jsxruntime.jsxs.call(void 0, "div",{className:_chunkWABJHG6Bcjs.a.call(void 0, "relative pt-10 pb-[30px] px-6 !min-[480px]:px-10 flex flex-col gap-[10px] antialiased animate-none",r),children:[i!=null?_jsxruntime.jsxs.call(void 0, "div",{className:"flex items-start justify-start w-full rounded-lg p-2 mt-4 bg-cm-danger-muted",style:{backgroundColor:new (0, _color2.default)((f=(c=o==null?void 0:o.colors)==null?void 0:c.danger)!=null?f:"#f44336").alpha(.12).toString()},children:[_jsxruntime.jsx.call(void 0, "div",{className:"min-w-[20px]",children:_jsxruntime.jsx.call(void 0, _chunkNRN4WNQLcjs.a,{customColor:(y=(m=o==null?void 0:o.colors)==null?void 0:m.danger)!=null?y:"#f44336"})}),_jsxruntime.jsx.call(void 0, "p",{className:"ml-2 text-sm",style:{color:(w=(a=o==null?void 0:o.colors)==null?void 0:a.danger)!=null?w:"#f44336"},children:i})]}):null,e==="initial"?_jsxruntime.jsxs.call(void 0, "div",{children:[_jsxruntime.jsx.call(void 0, "h1",{className:"text-2xl font-bold text-cm-text-primary",style:{color:(h=o==null?void 0:o.colors)==null?void 0:h.textPrimary},children:l!=null?l:"Sign in to Crossmint"}),_jsxruntime.jsx.call(void 0, "p",{className:"text-base font-normal mb-3 text-cm-text-secondary",style:{color:(d=o==null?void 0:o.colors)==null?void 0:d.textSecondary},children:"Access using one of the options below."})]}):null,t.includes("google")?_jsxruntime.jsx.call(void 0, be,{}):null,t.includes("farcaster")?_jsxruntime.jsx.call(void 0, _chunkBR77Q3PKcjs.a,{baseUrl:s,children:_jsxruntime.jsx.call(void 0, Ce,{})}):null,t.includes("twitter")?_jsxruntime.jsx.call(void 0, Se,{}):null,t.some(P=>P.startsWith("web3"))?_jsxruntime.jsx.call(void 0, ke,{}):null,t.includes("email")?_jsxruntime.jsxs.call(void 0, "div",{children:[t.length>1?_jsxruntime.jsx.call(void 0, we,{appearance:o,text:"OR"}):null,_jsxruntime.jsx.call(void 0, he,{})]}):null,e==="initial"&&n!=null?_jsxruntime.jsxs.call(void 0, "div",{className:"text-sm text-center text-cm-text-secondary mt-2",style:{color:(x=o==null?void 0:o.colors)==null?void 0:x.textSecondary},children:[_jsxruntime.jsx.call(void 0, "style",{children:`
|
|
3
|
-
p a {
|
|
4
|
-
color: ${(A=(p=o==null?void 0:o.colors)==null?void 0:p.textLink)!=null?A:"#1A74E9"};
|
|
5
|
-
}
|
|
6
|
-
`}),n]}):null,e==="initial"||e==="otp"?_jsxruntime.jsx.call(void 0, _chunk2BOQSASOcjs.a,{className:"mt-1.5 md:mt-4 justify-center",color:(W=(S=o==null?void 0:o.colors)==null?void 0:S.textSecondary)!=null?W:"#67797F"}):null]})}function Ft({open:r}){var t,s,i;let{appearance:e,setDialogOpen:o}=v();return _react.useEffect.call(void 0, ()=>{document.body.style.overflow=r?"hidden":""},[r]),_jsxruntime.jsx.call(void 0, _chunkWMBBIP2Ccjs.a,{modal:!1,open:r,onOpenChange:o,children:_jsxruntime.jsxs.call(void 0, _chunkWMBBIP2Ccjs.e,{onInteractOutside:n=>n.preventDefault(),onOpenAutoFocus:n=>n.preventDefault(),closeButtonColor:(t=e==null?void 0:e.colors)==null?void 0:t.textPrimary,closeButtonRingColor:(s=e==null?void 0:e.colors)==null?void 0:s.accent,className:"!p-0 !min-[480px]:p-0",style:{borderRadius:e==null?void 0:e.borderRadius,backgroundColor:(i=e==null?void 0:e.colors)==null?void 0:i.background},children:[_jsxruntime.jsx.call(void 0, _reactvisuallyhidden.VisuallyHidden,{asChild:!0,children:_jsxruntime.jsx.call(void 0, _chunkWMBBIP2Ccjs.h,{children:"Crossmint Auth"})}),_jsxruntime.jsx.call(void 0, _reactvisuallyhidden.VisuallyHidden,{asChild:!0,children:_jsxruntime.jsx.call(void 0, _chunkWMBBIP2Ccjs.i,{children:"Sign in via Crossmint"})}),_jsxruntime.jsx.call(void 0, Ee,{className:"max-w-[448px]"})]})})}var _ethereum = require('@dynamic-labs/ethereum');var _solana = require('@dynamic-labs/solana');function Ie({children:r,apiKeyEnvironment:e,enabled:o}){var c,f;let{crossmintAuth:t}=_(),{appearance:s,loginMethods:i}=v(),n=o?[_ethereum.EthereumWalletConnectors,_solana.SolanaWalletConnectors]:void 0;i.includes("web3:evm-only")?n=[_ethereum.EthereumWalletConnectors]:i.includes("web3:solana-only")&&(n=[_solana.SolanaWalletConnectors]);let l=`.powered-by-dynamic { display: none !important; } .wallet-list__scroll-container { padding: 0px !important; } .wallet-list__search-container { padding-left: 0px !important; padding-right: 0px !important; } .dynamic-footer { display: none !important; } h1 { color: ${(c=s==null?void 0:s.colors)==null?void 0:c.textPrimary} !important; } * { color: ${(f=s==null?void 0:s.colors)==null?void 0:f.textSecondary} !important; }`;return _jsxruntime.jsx.call(void 0, _chunkAHD64NAJcjs.a,{apiKeyEnvironment:e,settings:{walletConnectors:n,cssOverrides:l,events:{onWalletRemoved(){console.log("[CryptoWalletConnectionHandler] onWalletRemoved")},onAuthFlowCancel(){console.log("[CryptoWalletConnectionHandler] onAuthFlowCancel")},onAuthFlowClose(){console.log("[CryptoWalletConnectionHandler] onAuthFlowClose")},onAuthFailure(m,y){console.error("[CryptoWalletConnectionHandler] onAuthFailure",m,y)},onAuthSuccess(m){console.log("[CryptoWalletConnectionHandler] onAuthSuccess",m)}},handlers:{handleConnectedWallet:m=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){var h;console.log("[CryptoWalletConnectionHandler] handleConnectedWallet",m);let y=m.address;if(!y)return console.error("[CryptoWalletConnectionHandler] handleConnectedWallet: address is missing"),!1;let w=(yield _chunkPZ3KXKJDcjs.b.call(void 0, m))==="solana"?"solana":"evm";try{let d=yield t==null?void 0:t.signInWithSmartWallet(y,w),x=yield(h=m.connector)==null?void 0:h.proveOwnership(y,d.challenge),p=x;if(w==="solana"){let W=Buffer.from(x,"base64");p=_bs582.default.encode(W)}let S=(yield t==null?void 0:t.authenticateSmartWallet(y,w,p)).oneTimeSecret;yield t==null?void 0:t.handleRefreshAuthMaterial(S)}catch(d){console.error("[CryptoWalletConnectionHandler] Error authenticating wallet:",d)}return!0})}},children:r},`${e}-${i.join(",")}`)}var To={crossmintAuth:void 0,login:()=>{},logout:()=>{},jwt:void 0,user:void 0,status:"initializing",getUser:()=>{}},st= exports.A =_react.createContext.call(void 0, To),Io={createOnLogin:"off",type:"evm-smart-wallet",experimental_enableRecoveryKeys:!1,experimental_signersURL:void 0};function ui({embeddedWallets:r=Io,children:e,appearance:o,termsOfServiceText:t,prefetchOAuthUrls:s=!0,authModalTitle:i,onLoginSuccess:n,loginMethods:l=["email","google"],refreshRoute:c,logoutRoute:f}){var j;let[m,y]=_react.useState.call(void 0, void 0),{crossmint:a,setJwt:w}=_chunkGPQZG7HCcjs.b.call(void 0, "CrossmintAuthProvider must be used within CrossmintProvider"),h=_react.useRef.call(void 0, null),d=_react.useMemo.call(void 0, ()=>(h.current||(h.current=_clientsdkauth.CrossmintAuth.from(a,{callbacks:{onLogout:()=>{w(void 0),y(void 0)},onTokenRefresh:O=>{w(O.jwt),y(O.user)}},refreshRoute:c,logoutRoute:f})),h.current),[]),x=_commonsdkbase.validateApiKeyAndGetCrossmintBaseUrl.call(void 0, a.apiKey),[p,A]=_react.useState.call(void 0, !1),[S,W]=_react.useState.call(void 0, !1),[P,g]=_react.useState.call(void 0, void 0),[b,u]=_react.useState.call(void 0, !1),E=l.some(O=>O.startsWith("web3")),U=_react.useCallback.call(void 0, ()=>{n==null||n()},[n]);_react.useEffect.call(void 0, ()=>{if(a.jwt==null){let O=_clientsdkauth.getCookie.call(void 0, _commonsdkauth.SESSION_PREFIX);w(O)}W(!0)},[a.jwt,w]),_react.useEffect.call(void 0, ()=>{a.jwt!=null&&p&&(A(!1),U())},[a.jwt,p,U]);let V=_react.useCallback.call(void 0, O=>{if(a.jwt!=null){console.log("User already logged in");return}O!=null&&typeof O=="string"&&g(O),A(!0)},[a.jwt]),T=_react.useCallback.call(void 0, ()=>{d.logout()},[d]),M=_react.useCallback.call(void 0, ()=>!S||E&&!b?"initializing":a.jwt!=null?"logged-in":p?"in-progress":"logged-out",[S,a.jwt,p,b,E]),K=_react.useCallback.call(void 0, ()=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){if(a.jwt==null){console.log("User not logged in");return}let O=yield d.getUser();y(O)}),[a.jwt,d]),J=_react.useMemo.call(void 0, ()=>({crossmintAuth:d,login:V,logout:T,jwt:a.jwt,user:m,status:M(),getUser:K}),[d,V,T,a.jwt,m,M,K]);return _jsxruntime.jsx.call(void 0, _chunkJNLQRLICcjs.a,{children:_jsxruntime.jsx.call(void 0, st.Provider,{value:J,children:_jsxruntime.jsx.call(void 0, le,{showPasskeyHelpers:r.showPasskeyHelpers,appearance:o,experimental_enableRecoveryKeys:(j=r.experimental_enableRecoveryKeys)!=null?j:!1,children:_jsxruntime.jsx.call(void 0, ce,{setDialogOpen:(O,z)=>{A(O),z&&U()},preFetchOAuthUrls:M()==="logged-out"&&s,initialState:{appearance:o,loginMethods:l,termsOfServiceText:t,authModalTitle:i,embeddedWallets:r,baseUrl:x,defaultEmail:P},children:_jsxruntime.jsxs.call(void 0, Ie,{enabled:E,apiKeyEnvironment:a.apiKey.includes("production")?"production":"staging",children:[_jsxruntime.jsx.call(void 0, No,{embeddedWallets:r,accessToken:a.jwt,setIsDynamicSdkLoaded:u,isWeb3Enabled:E}),e,_jsxruntime.jsx.call(void 0, Ft,{open:p})]})})},a.jwt)})})}function No({embeddedWallets:r,accessToken:e,setIsDynamicSdkLoaded:o,isWeb3Enabled:t}){let{getOrCreateWallet:s,clearWallet:i,status:n}=ae(),{sdkHasLoaded:l,getAdminSigner:c,cleanup:f,isDynamicWalletConnected:m}=_chunkCDSQUWS7cjs.a.call(void 0, t,o,e),{createOnLogin:y,adminSigner:a,linkedUser:w}=r,h=y==="all-users"&&n==="not-loaded"&&e!=null&&l,d=_react.useCallback.call(void 0, ()=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){var S,W;if(!h)return;let p=a,A=r.type;if(m&&(p=(S=yield c())!=null?S:p,A=(W=_chunkGARYGAY7cjs.a.call(void 0, p==null?void 0:p.type))!=null?W:A),!m&&r.type==null){console.error("[CrossmintAuthProvider] \u26A0\uFE0F embeddedWallets.type is required when no external wallet is connected");return}s({type:A,args:{adminSigner:p,linkedUser:w}})}),[h,s,w,a,r.type,c]),x=_react.useCallback.call(void 0, ()=>{e==null&&n==="loaded"&&i(),f()},[n,e,i,f]);return _react.useEffect.call(void 0, ()=>{d(),x()},[d,x]),null}function Ci(){let r=_react.useContext.call(void 0, st);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}var Le={timeoutMs:1e4,intervalMs:5e3},Ue= exports.a =_react.createContext.call(void 0, null);function ne({children:r,setWalletState:e,appearance:o,signersURL:t}){let{crossmint:{apiKey:s,jwt:i}}=_chunkGPQZG7HCcjs.b.call(void 0, ),n=_react.useMemo.call(void 0, ()=>_walletssdk.CrossmintWallets.from({apiKey:s,jwt:i}),[s,i]),l=_chunk74NYCN24cjs.a.call(void 0, t),[c,f]=_react.useState.call(void 0, ""),[m,y]=_react.useState.call(void 0, "initial"),[a,w]=_react.useState.call(void 0, !1),h=_react.useRef.call(void 0, null),d=_react.useRef.call(void 0, null),x=P=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){try{e({status:"in-progress"}),f(P.email);let g=_commonsdkbase.environmentToCrossmintBaseURL.call(void 0, s.startsWith("ck_development_")?"development":"staging"),E=(yield(yield fetch(`${g}/api/unstable/wallets/ncs/doesnt-matter/public-key`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`,"x-api-key":s},body:JSON.stringify({authId:`email:${P.email}`,signingAlgorithm:"EDDSA_ED25519"})})).json()).publicKey,U=Uint8Array.from(atob(E),K=>K.charCodeAt(0)),V=_bs582.default.encode(U),T=yield W(V),M=_chunk2WSEHVNPcjs.b.call(void 0, _chunk2WSEHVNPcjs.a.call(void 0, {},T),{sendTransaction:K=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){return new Promise((J,j)=>{let O=()=>{w(!1),y("initial")},z=()=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){O();try{let I=yield T.sendTransaction(K);J(I)}catch(I){j(I)}}),ot=I=>{O(),j(I)};h.current=z,d.current=ot,p().then(z).catch(ot)})})});e({status:"loaded",wallet:M,type:"solana-smart-wallet"})}catch(g){throw console.error("There was an error creating a wallet ",g),e(_chunkLYUOGA56cjs.a.call(void 0, g)),g}});function p(){return _chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){if(!l.current||i==null)throw new Error("[handleGetRecoverySigner] IFrame window not initialized or JWT not set");return new Promise((P,g)=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){var b;try{let u=yield(b=l.current)==null?void 0:b.sendAction({event:"request:get-public-key",responseEvent:"response:get-public-key",data:{authData:{jwt:i,apiKey:s},data:{chainLayer:"solana"}}});if((u==null?void 0:u.status)==="success")return console.log("Signer already exists, skipping OTP flow"),P();h.current=()=>P(),d.current=E=>g(E),y("initial"),w(!0)}catch(u){console.error("Error getting recovery signer",u),g(u)}}))})}let A=P=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){var g,b;if(!l.current||i==null)throw new Error("[handleSendEmailOTP] IFrame window not initialized or JWT not set");try{console.log("Creating Recovery Key");let u=yield(g=l.current)==null?void 0:g.sendAction({event:"request:create-signer",responseEvent:"response:create-signer",data:{authData:{jwt:i,apiKey:s},data:{chainLayer:"solana",authId:`email:${P}`}}});if(u.status==="error")throw new Error(u.error);if(u.status==="success"&&u.address!=null){console.log("Signer already exists, skipping OTP flow"),y("initial"),w(!1);return}console.log("Proceeding to OTP flow"),y("otp"),w(!0)}catch(u){throw console.error("Error in email submission:",u),(b=d.current)==null||b.call(d,u),u}}),S=P=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){var g,b;if(!l.current||i==null)throw new Error("[handleOTPSubmit] IFrame window not initialized or JWT not set");try{let u=yield l.current.sendAction({event:"request:send-otp",responseEvent:"response:send-otp",data:{authData:{jwt:i,apiKey:s},data:{encryptedOtp:P,chainLayer:"solana"}}});if(u.status==="error")throw new Error(u.error);y("initial"),w(!1),(g=h.current)==null||g.call(h)}catch(u){throw console.error("Error in OTP submission:",u),(b=d.current)==null||b.call(d,u),u}});function W(P){return _chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){if(i==null)throw new Error("[getOrCreateSolanaWalletWithSigner] JWT not set!");try{return yield n.getOrCreateWallet("solana-smart-wallet",{adminSigner:{type:"solana-keypair",address:P,signer:{signMessage:g=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){if(l.current==null)throw new Error("IFrame window not initialized");let b=yield l.current.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:s},data:{keyType:"ed25519",bytes:_bs582.default.encode(g),encoding:"base58"}},options:Le});if(b.status==="error")throw new Error(b.error);if(b.signature==null)throw new Error("Failed to sign message");return _bs582.default.decode(b.signature)}),signTransaction:g=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){var E;console.log("Signing transaction...",g);let b=g.message.serialize(),u=yield(E=l.current)==null?void 0:E.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:s},data:{keyType:"ed25519",bytes:_bs582.default.encode(b),encoding:"base58"}},options:Le});if((u==null?void 0:u.status)==="error")throw new Error(u.error);if((u==null?void 0:u.signature)==null)throw new Error("Failed to sign transaction");return g.addSignature(new (0, _web3js.PublicKey)(P),_bs582.default.decode(u.signature)),g})}}})}catch(g){throw console.error("Error creating wallet with signer:",g),e(_chunkLYUOGA56cjs.a.call(void 0, g)),g}})}return _react.useEffect.call(void 0, ()=>{document.body.style.overflow=a?"hidden":""},[a]),_jsxruntime.jsxs.call(void 0, Ue.Provider,{value:{experimental_getOrCreateWalletWithRecoveryKey:x},children:[_jsxruntime.jsx.call(void 0, _chunkAHO6ZTD2cjs.a,{email:c,open:a,setOpen:w,step:m,onSubmitOTP:S,onResendOTPCode:A,onSubmitEmail:A,appearance:o}),r]})}function se({enabled:r=!0}={}){let e=_react.useContext.call(void 0, Ue);if(!r)return{experimental_getOrCreateWalletWithRecoveryKey:()=>_chunk2WSEHVNPcjs.d.call(void 0, this,null,function*(){yield Promise.reject(new Error("useCrossmintSigner is disabled, please set 'experimental_enableRecoveryKeys' to true"))})};if(e===null)throw new Error("useCrossmintSigner must be used within a CrossmintSignerProvider");return e}exports.a = Ue; exports.b = ne; exports.c = se; exports.d = St; exports.e = le; exports.f = ae; exports.g = _; exports.h = v; exports.i = ce; exports.j = Y; exports.k = Je; exports.l = fe; exports.m = Z; exports.n = ge; exports.o = pe; exports.p = he; exports.q = we; exports.r = be; exports.s = Ce; exports.t = Se; exports.u = Pe; exports.v = Ae; exports.w = ke; exports.x = Ee; exports.y = Ft; exports.z = Ie; exports.A = st; exports.B = ui; exports.C = Ci;
|
package/dist/chunk-YOCCNJIU.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import{a as jt}from"./chunk-P7UQAP6A.js";import{a as Jt}from"./chunk-JSNUJJQJ.js";import{b as te}from"./chunk-4KDASQO6.js";import{a as Zt}from"./chunk-LD3MRJ3F.js";import{a as Bt}from"./chunk-JOMJPVZA.js";import{a as Kt}from"./chunk-EMXNIC4M.js";import{a as Lt,e as Ut,h as Mt,i as Dt}from"./chunk-UDQUVZUQ.js";import{a as Vt,b as Ht,c as $}from"./chunk-VHNBXIOC.js";import{a as Rt}from"./chunk-2VBA64WU.js";import{a as G}from"./chunk-TNCETEEL.js";import{a as T}from"./chunk-NBJIJZGO.js";import{a as _t}from"./chunk-BFHQZOV3.js";import{a as nt}from"./chunk-C22ZEFQD.js";import{a as ee}from"./chunk-ZZYJ6XM2.js";import{a as ft}from"./chunk-RZG2PAKA.js";import{a as pt}from"./chunk-WW6GUXHG.js";import{a as qt}from"./chunk-SFDQPSSP.js";import{a as Xt}from"./chunk-JPJKOERH.js";import{a as Yt}from"./chunk-VWL76U5G.js";import{a as gt}from"./chunk-UAFW3OWA.js";import{a as Qt}from"./chunk-VLDE23JX.js";import{a as Gt}from"./chunk-C3JRTLQP.js";import{a as $t}from"./chunk-E4TBJMOO.js";import{b as Y}from"./chunk-ROJ6HFVK.js";import{a as oe}from"./chunk-WQVJJ44F.js";import{a as zt}from"./chunk-AITWNSJU.js";import{a as B,b as _,c as Q,d as C}from"./chunk-PXDN3KFO.js";import{createContext as Mo,useContext as Do,useRef as Le,useState as Nt,useEffect as Bo,useMemo as _o}from"react";import{CrossmintWallets as Ko}from"@crossmint/wallets-sdk";import{PublicKey as Vo}from"@solana/web3.js";import dt from"bs58";import{environmentToCrossmintBaseURL as Ho}from"@crossmint/common-sdk-base";import{useContext as Ve}from"react";import{createContext as De,useMemo as re,useState as le}from"react";import{createPortal as Be}from"react-dom";import{CrossmintWallets as _e}from"@crossmint/wallets-sdk";import{jsx as st,jsxs as Ke}from"react/jsx-runtime";var Pt=De({status:"not-loaded",getOrCreateWallet:()=>Promise.resolve({startedCreation:!1}),createPasskeySigner:()=>Promise.resolve(null),clearWallet:()=>{}});function ae({children:r,showPasskeyHelpers:e=!0,appearance:o,experimental_enableRecoveryKeys:t=!1,experimental_signersURL:s=void 0}){let[i,n]=le({status:"not-loaded"}),l={walletState:i,setWalletState:n,showPasskeyHelpers:e,appearance:o,experimental_enableRecoveryKeys:t};return t?st(ft,{children:st(se,{walletState:i,setWalletState:n,appearance:o,signersURL:s,children:st(ne,_(B({},l),{children:r}))})}):st(ne,_(B({},l),{children:r}))}function ne({children:r,showPasskeyHelpers:e=!0,appearance:o,walletState:t,setWalletState:s,experimental_enableRecoveryKeys:i}){let{crossmint:n}=Y("CrossmintWalletProvider must be used within CrossmintProvider"),{experimental_getOrCreateWalletWithRecoveryKey:l}=ie({enabled:i!=null?i:!1}),c=re(()=>_e.from({apiKey:n.apiKey,jwt:n==null?void 0:n.jwt}),[n.apiKey,n.jwt]),[f,m]=le({open:!1}),y=x=>C(this,null,function*(){var p,A;if(t.status=="in-progress")return{startedCreation:!1,reason:"Wallet is already loading."};if(n.jwt==null)return{startedCreation:!1,reason:'Jwt not set in "CrossmintProvider".'};try{s({status:"in-progress"});let S={onWalletCreationStart:a("create-wallet"),onWalletCreationFail:a("create-wallet-error"),onTransactionStart:a("transaction"),onTransactionFail:a("transaction-error")};switch(x.type){case"evm-smart-wallet":{let W={adminSigner:(p=x.args.adminSigner)!=null?p:{type:"evm-passkey"},linkedUser:x.args.linkedUser},P=yield c.getOrCreateWallet("evm-smart-wallet",W,{experimental_callbacks:((A=W.adminSigner)==null?void 0:A.type)==="evm-passkey"?S:void 0});s({status:"loaded",wallet:P,type:"evm-smart-wallet"});break}case"solana-smart-wallet":{let W=yield c.getOrCreateWallet("solana-smart-wallet",x.args);s({status:"loaded",wallet:W,type:"solana-smart-wallet"});break}}}catch(S){console.error("There was an error creating a wallet ",S),s(nt(S))}return{startedCreation:!0}}),a=x=>()=>new Promise(p=>{if(!e){p();return}m({type:x,open:!0,primaryActionOnClick:()=>{m({open:!1}),p()},secondaryActionOnClick:()=>{m({open:!1}),p()}})}),w=()=>{s({status:"not-loaded"})},h=(x,p)=>C(this,null,function*(){return p!=null&&(yield a(p)()),yield _t(x)}),d=re(()=>_(B({},t),{getOrCreateWallet:y,createPasskeySigner:h,clearWallet:w,experimental_getOrCreateWalletWithRecoveryKey:l}),[t,l]);return Ke(Pt.Provider,{value:d,children:[r,f.open?Be(st(Bt,{state:f,appearance:o}),document.body):null]})}function me(){let r=Ve(Pt);if(!r)throw new Error("useWallet must be used within CrossmintAuthProvider or CrossmintWalletProvider");return r}import{useContext as Uo}from"react";import{createContext as Wo,useEffect as It,useMemo as Re,useRef as ko,useState as ct,useCallback as J}from"react";import{CrossmintAuth as Eo,getCookie as Oo}from"@crossmint/client-sdk-auth";import{validateApiKeyAndGetCrossmintBaseUrl as Fo}from"@crossmint/common-sdk-base";import{SESSION_PREFIX as To}from"@crossmint/common-sdk-auth";import{VisuallyHidden as Fe}from"@radix-ui/react-visually-hidden";import{createContext as Ge,useCallback as je,useContext as ze,useEffect as qe,useState as yt}from"react";import{CrossmintAuthenticationError as $e}from"@crossmint/common-sdk-auth";import{useContext as He}from"react";function K(){let r=He(it);if(!r)throw new Error("useCrossmintAuth must be used within a CrossmintAuthProvider");return r}import{jsx as Je}from"react/jsx-runtime";var ue={google:"",twitter:""},ce=Ge(void 0),v=()=>{let r=ze(ce);if(!r)throw new Error("useAuthForm must be used within an AuthFormProvider");return r},de=({setDialogOpen:r,preFetchOAuthUrls:e,initialState:o,children:t})=>{let{crossmintAuth:s}=K(),[i,n]=yt("initial"),[l,c]=yt(null),[f,m]=yt(ue),[y,a]=yt(!0),{loginMethods:w,baseUrl:h,appearance:d,termsOfServiceText:x,authModalTitle:p,defaultEmail:A}=o,S=je(()=>C(void 0,null,function*(){a(!0);try{let b=w.filter(O=>O in ue).map(O=>C(void 0,null,function*(){let M=yield s==null?void 0:s.getOAuthUrl(O);return{[O]:M}})),u=Object.assign({},...yield Promise.all(b));m(u)}catch(g){c(g instanceof $e?g.message:"Unable to load oauth providers. Please try again later.")}finally{a(!1)}}),[w,s]);qe(()=>{e&&S()},[S,e]);let P={step:i,error:l,baseUrl:h,appearance:d,termsOfServiceText:x,authModalTitle:p,loginMethods:w,defaultEmail:A,oauthUrlMap:f,isLoadingOauthUrlMap:y,setDialogOpen:(g,b)=>{r==null||r(g,b),g||setTimeout(()=>n("initial"),250)},setError:c,setStep:n};return Je(ce.Provider,{value:P,children:t})};import Co from"color";import{useState as io}from"react";import{useState as At}from"react";import{jsx as fe}from"react/jsx-runtime";var Z=i=>{var n=i,{className:r,iconColor:e,ringColor:o,onClick:t}=n,s=Q(n,["className","iconColor","ringColor","onClick"]);let{setError:l}=v();return fe("button",_(B({className:T("absolute left-4 top-4 min-[480px]:!left-6 min-[480px]:!top-6 rounded-full opacity-70 ring-offset-background text-cm-text-primary transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-cm-accent focus:ring-offset-2 disabled:pointer-events-none",r),onClick:c=>{l(null),t==null||t(c)}},s),{children:fe(qt,{className:"w-6 h-6",style:{color:e}})}))};import{jsx as R,jsxs as lt}from"react/jsx-runtime";var Xe=6;function ge({otpEmailData:r,setOtpEmailData:e}){var x,p,A,S,W,P,g,b,u,O,M,H,I,D,V,X,z,F,q,rt;let{crossmintAuth:o}=K(),{appearance:t,setDialogOpen:s,setStep:i,setError:n}=v(),[l,c]=At(""),[f,m]=At(!1),[y,a]=At(!1),w=()=>C(this,null,function*(){var N,vt;a(!0);try{let St=yield o==null?void 0:o.confirmEmailOtp((N=r==null?void 0:r.email)!=null?N:"",(vt=r==null?void 0:r.emailId)!=null?vt:"",l);yield o==null?void 0:o.handleRefreshAuthMaterial(St),s(!1,!0),i("initial")}catch(St){console.error("Error confirming email OTP",St),n("Invalid code. Please try again."),m(!0)}finally{a(!1)}}),h=()=>C(this,null,function*(){var N;try{yield o==null?void 0:o.sendEmailOtp((N=r==null?void 0:r.email)!=null?N:"")}catch(vt){n("Failed to resend code. Please try again.")}});return lt("div",{children:[R(Z,{onClick:()=>{i("initial"),e(null)},iconColor:(x=t==null?void 0:t.colors)==null?void 0:x.textPrimary,ringColor:(p=t==null?void 0:t.colors)==null?void 0:p.accent}),lt("div",{className:"flex flex-col items-center justify-start w-full",children:[R("div",{className:"relative left-3",children:R(Gt,{customAccentColor:(A=t==null?void 0:t.colors)==null?void 0:A.accent,customButtonBackgroundColor:(S=t==null?void 0:t.colors)==null?void 0:S.buttonBackground,customBackgroundColor:(W=t==null?void 0:t.colors)==null?void 0:W.background})}),R("p",{className:"text-base font-normal mt-4 mb-1 text-center text-cm-text-primary",style:{color:(P=t==null?void 0:t.colors)==null?void 0:P.textPrimary},children:"Check your email"}),lt("p",{className:"text-center text-cm-text-secondary px-4",style:{color:(g=t==null?void 0:t.colors)==null?void 0:g.textSecondary},children:["A temporary login code has been sent to"," ",r!=null&&r.email?r.email:"your email address"]}),R("div",{className:"py-8",children:R(Vt,{maxLength:Xe,value:l,onChange:N=>{c(N),m(!1),n(null)},onComplete:w,disabled:y,customStyles:{accent:(u=(b=t==null?void 0:t.colors)==null?void 0:b.accent)!=null?u:"#04AA6D",danger:(M=(O=t==null?void 0:t.colors)==null?void 0:O.danger)!=null?M:"#f44336",border:(I=(H=t==null?void 0:t.colors)==null?void 0:H.border)!=null?I:"#E5E7EB",textPrimary:(V=(D=t==null?void 0:t.colors)==null?void 0:D.textPrimary)!=null?V:"#909ca3",buttonBackground:(z=(X=t==null?void 0:t.colors)==null?void 0:X.buttonBackground)!=null?z:"#eff6ff",inputBackground:(q=(F=t==null?void 0:t.colors)==null?void 0:F.inputBackground)!=null?q:"#FFFFFF",borderRadius:t==null?void 0:t.borderRadius},children:lt(Ht,{children:[R($,{index:0,hasError:f}),R($,{index:1,hasError:f}),R($,{index:2,hasError:f}),R($,{index:3,hasError:f}),R($,{index:4,hasError:f}),R($,{index:5,hasError:f})]})})}),R("div",{className:"text-xs leading-tight text-cm-text-secondary text-center",children:lt("span",{style:{color:(rt=t==null?void 0:t.colors)==null?void 0:rt.textSecondary},children:["Can't find the email? Check spam folder.",`
|
|
2
|
-
`,"Some emails may take several minutes to arrive."]})}),R(Kt,{initialSeconds:60,appearance:t,countdownText:N=>`Re-send code in ${N}s`,countdownCompleteText:"Re-send code",handleOnClick:h})]})]})}import{useState as kt}from"react";import no from"color";import{isEmailValid as wt}from"@crossmint/common-sdk-auth";import{ChildWindow as Qe,PopupWindow as Ye}from"@crossmint/client-sdk-window";import{useEffect as Ze,useRef as to,useState as eo}from"react";import{z as ht}from"zod";var tt=r=>{let{crossmintAuth:e}=K(),{oauthUrlMap:o,setError:t}=v(),[s,i]=eo(!1),n=to(null);return Ze(()=>(n.current==null&&(n.current=new Qe(window.opener||window.parent,"*",{incomingEvents:oo})),()=>{n.current!=null&&n.current.off("authMaterialFromPopupCallback")}),[]),{createPopupAndSetupListeners:c=>C(void 0,null,function*(){if(n.current==null)throw new Error("Child window not initialized");i(!0),t(null);let f=new URL(o[r]);if(c!=null){let h=Array.from(f.searchParams.entries());f.search="",c&&f.searchParams.append("provider_login_hint",c),h.forEach(([d,x])=>{f.searchParams.append(d,x)})}let m=yield Ye.init(f.toString(),{awaitToLoad:!1,crossOrigin:!0,width:400,height:700}),y=h=>C(void 0,null,function*(){var d;yield e==null?void 0:e.handleRefreshAuthMaterial(h.oneTimeSecret),(d=n.current)==null||d.off("authMaterialFromPopupCallback"),m.window.close(),i(!1)}),a=h=>{var d;t(h.error),(d=n.current)==null||d.off("errorFromPopupCallback"),m.window.close(),i(!1)};n.current.on("authMaterialFromPopupCallback",y),n.current.on("errorFromPopupCallback",a);let w=setInterval(()=>{var h;m.window.closed&&(clearInterval(w),i(!1),(h=n.current)==null||h.off("authMaterialFromPopupCallback"))},2500)}),isLoading:s}},oo={authMaterialFromPopupCallback:ht.object({oneTimeSecret:ht.string()}),errorFromPopupCallback:ht.object({error:ht.string()})};import{jsx as Wt,jsxs as ro}from"react/jsx-runtime";function pe({emailInput:r,appearance:e}){var s,i,n,l;let{createPopupAndSetupListeners:o,isLoading:t}=tt("google");return ro("button",{type:"button",className:T("flex items-center gap-2 justify-center h-[32px] px-2.5 border border-cm-border rounded-xl bg-cm-background-primary","hover:bg-cm-hover focus:bg-cm-hover outline-none",t?"cursor-not-allowed hover:bg-cm-muted-primary":""),onClick:t?void 0:()=>o(r.trim().toLowerCase()),style:{backgroundColor:(s=e==null?void 0:e.colors)==null?void 0:s.buttonBackground,borderRadius:e==null?void 0:e.borderRadius},children:[Wt(pt,{className:"max-h-[18px] max-w-[18px] h-[18px] w-[18px]"}),t?Wt(G,{style:{color:(i=e==null?void 0:e.colors)==null?void 0:i.textSecondary,fill:(n=e==null?void 0:e.colors)==null?void 0:n.textPrimary,width:"18px",height:"18px"}}):Wt("span",{className:"text-cm-accent",style:{color:(l=e==null?void 0:e.colors)==null?void 0:l.accent},children:"Continue"})]})}import{Fragment as so,jsx as j,jsxs as Et}from"react/jsx-runtime";function ye({setOtpEmailData:r}){var h,d,x,p,A,S,W,P,g,b,u,O,M,H;let{crossmintAuth:e}=K(),{appearance:o,defaultEmail:t,setStep:s,setError:i}=v(),[n,l]=kt(t!=null?t:""),[c,f]=kt(""),[m,y]=kt(!1),a=n.toLowerCase().includes("@gmail.com")&&!n.toLowerCase().includes("+")&&wt(n)&&!m;function w(I){return C(this,null,function*(){I.preventDefault(),y(!0);try{let D=n.trim().toLowerCase(),V=yield e==null?void 0:e.sendEmailOtp(D);r({email:D,emailId:V.emailId}),s("otp")}catch(D){y(!1),i("Failed to send email. Please try again or contact support.")}})}return j(so,{children:j("div",{className:"flex flex-col items-start justify-start w-full rounded-lg",children:Et("div",{className:"w-full",children:[j("label",{className:"text-cm-text-primary block mb-[5px]",style:{color:(h=o==null?void 0:o.colors)==null?void 0:h.textPrimary},children:"Email"}),Et("form",{role:"form",className:"relative",onSubmit:I=>{if(a){I.preventDefault();return}wt(n)?w(I):I.preventDefault()},noValidate:!0,children:[j("label",{htmlFor:"emailInput",className:"sr-only",children:"Email"}),j("input",{className:T("flex-grow text-cm-text-primary text-left pl-[16px] h-[58px] w-full border border-cm-border rounded-xl bg-cm-background-primary placeholder:text-md","transition-none duration-200 ease-in-out","focus:outline-none focus-ring-custom","placeholder:[color:var(--placeholder-color)]",c?"border-red-500":"",a?"pr-[132px]":"pr-[80px]"),style:{color:(d=o==null?void 0:o.colors)==null?void 0:d.textPrimary,borderRadius:o==null?void 0:o.borderRadius,borderColor:c?(x=o==null?void 0:o.colors)==null?void 0:x.danger:(p=o==null?void 0:o.colors)==null?void 0:p.border,backgroundColor:(A=o==null?void 0:o.colors)==null?void 0:A.inputBackground,"--placeholder-color":(W=(S=o==null?void 0:o.colors)==null?void 0:S.textSecondary)!=null?W:"#67797F","--focus-ring-color":new no((g=(P=o==null?void 0:o.colors)==null?void 0:P.accent)!=null?g:"#04AA6D").alpha(.18).toString()},type:"email",placeholder:"your@email.com",value:n,onChange:I=>{l(I.target.value),f(""),i(null)},readOnly:m,"aria-describedby":"emailError"}),Et("div",{className:"absolute inset-y-0 right-0 flex items-center pr-4",children:[c&&j(gt,{customColor:(b=o==null?void 0:o.colors)==null?void 0:b.danger}),m&&j(G,{style:{color:(u=o==null?void 0:o.colors)==null?void 0:u.textSecondary,fill:(O=o==null?void 0:o.colors)==null?void 0:O.textPrimary}}),a?j(pe,{emailInput:n,appearance:o}):!c&&!m?j("button",{type:"submit",className:T("font-medium text-cm-accent text-nowrap bg-cm-background-primary",wt(n)?"cursor-pointer":"!cursor-not-allowed opacity-60"),style:{color:(M=o==null?void 0:o.colors)==null?void 0:M.accent,backgroundColor:(H=o==null?void 0:o.colors)==null?void 0:H.inputBackground},disabled:!wt(n)||m,children:"Submit"}):null]})]}),c&&j("p",{className:"text-xs text-red-500 mb-2 pt-2",children:c})]})})})}import{jsx as he}from"react/jsx-runtime";function we(){let{step:r}=v(),[e,o]=io(null);return r==="otp"?he(ge,{otpEmailData:e,setOtpEmailData:o}):r==="initial"?he(ye,{setOtpEmailData:o}):null}import{jsx as Ot,jsxs as lo}from"react/jsx-runtime";function xe({appearance:r,text:e}){var t,s,i;let{step:o}=v();return o!=="initial"?null:lo("div",{className:"flex items-center justify-center w-full pt-2 pb-3",children:[Ot("span",{className:"w-full h-[1px] bg-cm-border",style:{backgroundColor:(t=r==null?void 0:r.colors)==null?void 0:t.border}}),e!=null?Ot("p",{className:"flex-none px-2 text-sm text-cm-text-primary",style:{color:(s=r==null?void 0:r.colors)==null?void 0:s.textSecondary},children:e}):null,Ot("span",{className:"w-full h-[1px] bg-cm-border",style:{backgroundColor:(i=r==null?void 0:r.colors)==null?void 0:i.border}})]})}import{Fragment as ao,jsx as xt,jsxs as be}from"react/jsx-runtime";function Ce(e){var r=Q(e,[]);var c,f,m,y;let{step:o,appearance:t,isLoadingOauthUrlMap:s}=v(),{createPopupAndSetupListeners:i,isLoading:n}=tt("google"),l=s||n;return o!=="initial"?null:be("button",_(B({className:T("relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none",l?"cursor-not-allowed hover:bg-cm-muted-primary":""),style:{borderRadius:t==null?void 0:t.borderRadius,backgroundColor:(c=t==null?void 0:t.colors)==null?void 0:c.buttonBackground},onClick:l?void 0:()=>i()},r),{children:[be(ao,{children:[xt(pt,{className:"max-h-[25px] max-w-[25px] h-[25px] w-[25px] absolute left-[18px]"}),l?xt(G,{style:{color:(f=t==null?void 0:t.colors)==null?void 0:f.textSecondary,fill:(m=t==null?void 0:t.colors)==null?void 0:m.textPrimary}}):xt("span",{className:"font-medium",style:{margin:"0px 32px",color:(y=t==null?void 0:t.colors)==null?void 0:y.textPrimary},children:"Sign in with Google"})]}),xt("span",{className:"sr-only",children:"Sign in with Google"})]}))}import{useEffect as Ft,useMemo as mo,useState as uo}from"react";import{useSignIn as co,QRCode as fo}from"@farcaster/auth-kit";import{Fragment as po,jsx as L,jsxs as at}from"react/jsx-runtime";function ve(){var s,i;let{step:r,appearance:e,setStep:o,setError:t}=v();return r==="initial"?L("div",{children:at("button",{className:T("relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none"),style:{borderRadius:e==null?void 0:e.borderRadius,backgroundColor:(s=e==null?void 0:e.colors)==null?void 0:s.buttonBackground},onClick:()=>{o("qrCode"),t(null)},children:[L($t,{className:"max-h-[25px] max-w-[25px] h-[25px] w-[25px] absolute left-[18px]"}),L("span",{className:"font-medium",style:{margin:"0px 32px",color:(i=e==null?void 0:e.colors)==null?void 0:i.textPrimary},children:"Sign in with Farcaster"}),L("span",{className:"sr-only",children:"Sign in with Farcaster"})]})}):r==="qrCode"?L(go,{}):null}function go(){var h,d,x,p,A,S,W,P,g;let{crossmintAuth:r}=K(),{appearance:e,setStep:o,setDialogOpen:t,setError:s}=v(),[i,n]=uo(null),l=mo(()=>({onSuccess:b=>{n(b)}}),[]),{signIn:c,url:f,connect:m,signOut:y,isConnected:a}=co(l),w=b=>C(this,null,function*(){s(null);try{let u=yield r==null?void 0:r.signInWithFarcaster(b);yield r==null?void 0:r.handleRefreshAuthMaterial(u),t(!1),o("initial")}catch(u){console.error("Error during Farcaster sign-in:",u),s("Failed to sign in with Farcaster")}});return Ft(()=>{i!=null&&w(i)},[i]),Ft(()=>{a&&c()},[a]),Ft(()=>{m()},[]),at("div",{children:[L(Z,{onClick:()=>{y(),o("initial")},iconColor:(h=e==null?void 0:e.colors)==null?void 0:h.textPrimary,ringColor:(d=e==null?void 0:e.colors)==null?void 0:d.accent}),at("div",{className:"flex flex-col items-center gap-4",children:[at("div",{className:"text-center",children:[L("h3",{className:"text-lg font-semibold text-cm-text-primary mb-2",style:{color:(x=e==null?void 0:e.colors)==null?void 0:x.textPrimary},children:"Sign in with Farcaster"}),L("p",{className:"text-base font-normal text-cm-text-secondary",style:{color:(p=e==null?void 0:e.colors)==null?void 0:p.textSecondary},children:"Scan with your phone's camera to continue."})]}),L("div",{className:"bg-white aspect-square rounded-lg p-4",style:{backgroundColor:(A=e==null?void 0:e.colors)==null?void 0:A.inputBackground,borderRadius:e==null?void 0:e.borderRadius},children:f!=null?L(fo,{uri:f,size:280}):L("div",{className:"min-h-[246px] flex items-center justify-center",children:L(G,{style:{color:(S=e==null?void 0:e.colors)==null?void 0:S.textSecondary,fill:(W=e==null?void 0:e.colors)==null?void 0:W.textPrimary}})})}),f?at(po,{children:[L("p",{className:"text-base text-center font-normal text-cm-text-secondary",style:{color:(P=e==null?void 0:e.colors)==null?void 0:P.textSecondary},children:"Alternatively, click on this link to open Warpcast."}),L("a",{href:f,rel:"noopener noreferrer",target:"_blank",className:"text-base font-normal text-cm-link",style:{color:(g=e==null?void 0:e.colors)==null?void 0:g.textLink},children:"Open Warpcast"})]}):null]})]})}import{Fragment as yo,jsx as bt,jsxs as Se}from"react/jsx-runtime";function Pe(e){var r=Q(e,[]);var c,f,m,y;let{step:o,appearance:t,isLoadingOauthUrlMap:s}=v(),{createPopupAndSetupListeners:i,isLoading:n}=tt("twitter"),l=s||n;return o!=="initial"?null:Se("button",_(B({className:T("relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none",l?"cursor-not-allowed hover:bg-cm-muted-primary":""),style:{borderRadius:t==null?void 0:t.borderRadius,backgroundColor:(c=t==null?void 0:t.colors)==null?void 0:c.buttonBackground},onClick:l?void 0:()=>i()},r),{children:[Se(yo,{children:[bt(Xt,{className:"max-h-[25px] max-w-[25px] h-[25px] w-[25px] absolute left-[18px]"}),l?bt(G,{style:{color:(f=t==null?void 0:t.colors)==null?void 0:f.textSecondary,fill:(m=t==null?void 0:t.colors)==null?void 0:m.textPrimary}}):bt("span",{className:"font-medium",style:{margin:"0px 32px",color:(y=t==null?void 0:t.colors)==null?void 0:y.textPrimary},children:"Sign in with X"})]}),bt("span",{className:"sr-only",children:"Sign in with X"})]}))}import{jsx as Ct,jsxs as ho}from"react/jsx-runtime";function Ae(){var s,i,n,l,c;let{step:r,appearance:e,setStep:o,setError:t}=v();return r!=="initial"?null:ho("button",{className:T("relative flex text-base p-4 bg-cm-muted-primary text-cm-text-primary items-center w-full rounded-xl justify-center","transition-colors duration-200 ease-in-out","hover:bg-cm-hover focus:bg-cm-hover outline-none"),style:{borderRadius:e==null?void 0:e.borderRadius,borderColor:(s=e==null?void 0:e.colors)==null?void 0:s.border,backgroundColor:(i=e==null?void 0:e.colors)==null?void 0:i.buttonBackground},onClick:()=>{o("web3"),t(null)},children:[Ct(Yt,{className:"h-[21px] w-[21px] absolute left-[20px]",style:{color:(n=e==null?void 0:e.colors)==null?void 0:n.textPrimary}}),Ct("span",{className:"font-medium",style:{margin:"0px 32px",color:(l=e==null?void 0:e.colors)==null?void 0:l.textPrimary},children:"Continue with a wallet"}),Ct(Qt,{className:"h-[21px] w-[21px] absolute right-[20px]",style:{color:(c=e==null?void 0:e.colors)==null?void 0:c.textSecondary}}),Ct("span",{className:"sr-only",children:"Continue with a wallet"})]})}import{DynamicEmbeddedWidget as wo}from"@dynamic-labs/sdk-react-core";import{Fragment as xo,jsx as mt,jsxs as bo}from"react/jsx-runtime";function We(){var t,s;let{appearance:r,step:e,setStep:o}=v();return e==="web3"?bo(xo,{children:[mt(Z,{onClick:()=>o("initial"),iconColor:(t=r==null?void 0:r.colors)==null?void 0:t.textPrimary,ringColor:(s=r==null?void 0:r.colors)==null?void 0:s.accent}),mt("div",{className:"flex flex-col items-center",children:mt("div",{className:"flex flex-col gap-[10px] w-full",children:mt("div",{className:"widget-container",children:mt(wo,{background:"none"})})})})]}):null}import{jsx as ke}from"react/jsx-runtime";function Ee(){let{step:r}=v();return r.startsWith("web3")?ke(We,{}):r==="initial"?ke(Ae,{}):null}import{jsx as U,jsxs as ut}from"react/jsx-runtime";function Oe({className:r}){var c,f,m,y,a,w,h,d,x,p,A,S,W;let{step:e,appearance:o,loginMethods:t,baseUrl:s,error:i,termsOfServiceText:n,authModalTitle:l}=v();return ut("div",{className:T("relative pt-10 pb-[30px] px-6 !min-[480px]:px-10 flex flex-col gap-[10px] antialiased animate-none",r),children:[i!=null?ut("div",{className:"flex items-start justify-start w-full rounded-lg p-2 mt-4 bg-cm-danger-muted",style:{backgroundColor:new Co((f=(c=o==null?void 0:o.colors)==null?void 0:c.danger)!=null?f:"#f44336").alpha(.12).toString()},children:[U("div",{className:"min-w-[20px]",children:U(gt,{customColor:(y=(m=o==null?void 0:o.colors)==null?void 0:m.danger)!=null?y:"#f44336"})}),U("p",{className:"ml-2 text-sm",style:{color:(w=(a=o==null?void 0:o.colors)==null?void 0:a.danger)!=null?w:"#f44336"},children:i})]}):null,e==="initial"?ut("div",{children:[U("h1",{className:"text-2xl font-bold text-cm-text-primary",style:{color:(h=o==null?void 0:o.colors)==null?void 0:h.textPrimary},children:l!=null?l:"Sign in to Crossmint"}),U("p",{className:"text-base font-normal mb-3 text-cm-text-secondary",style:{color:(d=o==null?void 0:o.colors)==null?void 0:d.textSecondary},children:"Access using one of the options below."})]}):null,t.includes("google")?U(Ce,{}):null,t.includes("farcaster")?U(Jt,{baseUrl:s,children:U(ve,{})}):null,t.includes("twitter")?U(Pe,{}):null,t.some(P=>P.startsWith("web3"))?U(Ee,{}):null,t.includes("email")?ut("div",{children:[t.length>1?U(xe,{appearance:o,text:"OR"}):null,U(we,{})]}):null,e==="initial"&&n!=null?ut("div",{className:"text-sm text-center text-cm-text-secondary mt-2",style:{color:(x=o==null?void 0:o.colors)==null?void 0:x.textSecondary},children:[U("style",{children:`
|
|
3
|
-
p a {
|
|
4
|
-
color: ${(A=(p=o==null?void 0:o.colors)==null?void 0:p.textLink)!=null?A:"#1A74E9"};
|
|
5
|
-
}
|
|
6
|
-
`}),n]}):null,e==="initial"||e==="otp"?U(Rt,{className:"mt-1.5 md:mt-4 justify-center",color:(W=(S=o==null?void 0:o.colors)==null?void 0:S.textSecondary)!=null?W:"#67797F"}):null]})}import{useEffect as vo}from"react";import{jsx as et,jsxs as So}from"react/jsx-runtime";function Tt({open:r}){var t,s,i;let{appearance:e,setDialogOpen:o}=v();return vo(()=>{document.body.style.overflow=r?"hidden":""},[r]),et(Lt,{modal:!1,open:r,onOpenChange:o,children:So(Ut,{onInteractOutside:n=>n.preventDefault(),onOpenAutoFocus:n=>n.preventDefault(),closeButtonColor:(t=e==null?void 0:e.colors)==null?void 0:t.textPrimary,closeButtonRingColor:(s=e==null?void 0:e.colors)==null?void 0:s.accent,className:"!p-0 !min-[480px]:p-0",style:{borderRadius:e==null?void 0:e.borderRadius,backgroundColor:(i=e==null?void 0:e.colors)==null?void 0:i.background},children:[et(Fe,{asChild:!0,children:et(Mt,{children:"Crossmint Auth"})}),et(Fe,{asChild:!0,children:et(Dt,{children:"Sign in via Crossmint"})}),et(Oe,{className:"max-w-[448px]"})]})})}import Po from"bs58";import{EthereumWalletConnectors as Te}from"@dynamic-labs/ethereum";import{SolanaWalletConnectors as Ie}from"@dynamic-labs/solana";import{jsx as Ao}from"react/jsx-runtime";function Ne({children:r,apiKeyEnvironment:e,enabled:o}){var c,f;let{crossmintAuth:t}=K(),{appearance:s,loginMethods:i}=v(),n=o?[Te,Ie]:void 0;i.includes("web3:evm-only")?n=[Te]:i.includes("web3:solana-only")&&(n=[Ie]);let l=`.powered-by-dynamic { display: none !important; } .wallet-list__scroll-container { padding: 0px !important; } .wallet-list__search-container { padding-left: 0px !important; padding-right: 0px !important; } .dynamic-footer { display: none !important; } h1 { color: ${(c=s==null?void 0:s.colors)==null?void 0:c.textPrimary} !important; } * { color: ${(f=s==null?void 0:s.colors)==null?void 0:f.textSecondary} !important; }`;return Ao(Zt,{apiKeyEnvironment:e,settings:{walletConnectors:n,cssOverrides:l,events:{onWalletRemoved(){console.log("[CryptoWalletConnectionHandler] onWalletRemoved")},onAuthFlowCancel(){console.log("[CryptoWalletConnectionHandler] onAuthFlowCancel")},onAuthFlowClose(){console.log("[CryptoWalletConnectionHandler] onAuthFlowClose")},onAuthFailure(m,y){console.error("[CryptoWalletConnectionHandler] onAuthFailure",m,y)},onAuthSuccess(m){console.log("[CryptoWalletConnectionHandler] onAuthSuccess",m)}},handlers:{handleConnectedWallet:m=>C(this,null,function*(){var h;console.log("[CryptoWalletConnectionHandler] handleConnectedWallet",m);let y=m.address;if(!y)return console.error("[CryptoWalletConnectionHandler] handleConnectedWallet: address is missing"),!1;let w=(yield te(m))==="solana"?"solana":"evm";try{let d=yield t==null?void 0:t.signInWithSmartWallet(y,w),x=yield(h=m.connector)==null?void 0:h.proveOwnership(y,d.challenge),p=x;if(w==="solana"){let W=Buffer.from(x,"base64");p=Po.encode(W)}let S=(yield t==null?void 0:t.authenticateSmartWallet(y,w,p)).oneTimeSecret;yield t==null?void 0:t.handleRefreshAuthMaterial(S)}catch(d){console.error("[CryptoWalletConnectionHandler] Error authenticating wallet:",d)}return!0})}},children:r},`${e}-${i.join(",")}`)}import{jsx as ot,jsxs as Lo}from"react/jsx-runtime";var Io={crossmintAuth:void 0,login:()=>{},logout:()=>{},jwt:void 0,user:void 0,status:"initializing",getUser:()=>{}},it=Wo(Io),No={createOnLogin:"off",type:"evm-smart-wallet",experimental_enableRecoveryKeys:!1,experimental_signersURL:void 0};function ci({embeddedWallets:r=No,children:e,appearance:o,termsOfServiceText:t,prefetchOAuthUrls:s=!0,authModalTitle:i,onLoginSuccess:n,loginMethods:l=["email","google"],refreshRoute:c,logoutRoute:f}){var z;let[m,y]=ct(void 0),{crossmint:a,setJwt:w}=Y("CrossmintAuthProvider must be used within CrossmintProvider"),h=ko(null),d=Re(()=>(h.current||(h.current=Eo.from(a,{callbacks:{onLogout:()=>{w(void 0),y(void 0)},onTokenRefresh:F=>{w(F.jwt),y(F.user)}},refreshRoute:c,logoutRoute:f})),h.current),[]),x=Fo(a.apiKey),[p,A]=ct(!1),[S,W]=ct(!1),[P,g]=ct(void 0),[b,u]=ct(!1),O=l.some(F=>F.startsWith("web3")),M=J(()=>{n==null||n()},[n]);It(()=>{if(a.jwt==null){let F=Oo(To);w(F)}W(!0)},[a.jwt,w]),It(()=>{a.jwt!=null&&p&&(A(!1),M())},[a.jwt,p,M]);let H=J(F=>{if(a.jwt!=null){console.log("User already logged in");return}F!=null&&typeof F=="string"&&g(F),A(!0)},[a.jwt]),I=J(()=>{d.logout()},[d]),D=J(()=>!S||O&&!b?"initializing":a.jwt!=null?"logged-in":p?"in-progress":"logged-out",[S,a.jwt,p,b,O]),V=J(()=>C(this,null,function*(){if(a.jwt==null){console.log("User not logged in");return}let F=yield d.getUser();y(F)}),[a.jwt,d]),X=Re(()=>({crossmintAuth:d,login:H,logout:I,jwt:a.jwt,user:m,status:D(),getUser:V}),[d,H,I,a.jwt,m,D,V]);return ot(ft,{children:ot(it.Provider,{value:X,children:ot(ae,{showPasskeyHelpers:r.showPasskeyHelpers,appearance:o,experimental_enableRecoveryKeys:(z=r.experimental_enableRecoveryKeys)!=null?z:!1,children:ot(de,{setDialogOpen:(F,q)=>{A(F),q&&M()},preFetchOAuthUrls:D()==="logged-out"&&s,initialState:{appearance:o,loginMethods:l,termsOfServiceText:t,authModalTitle:i,embeddedWallets:r,baseUrl:x,defaultEmail:P},children:Lo(Ne,{enabled:O,apiKeyEnvironment:a.apiKey.includes("production")?"production":"staging",children:[ot(Ro,{embeddedWallets:r,accessToken:a.jwt,setIsDynamicSdkLoaded:u,isWeb3Enabled:O}),e,ot(Tt,{open:p})]})})},a.jwt)})})}function Ro({embeddedWallets:r,accessToken:e,setIsDynamicSdkLoaded:o,isWeb3Enabled:t}){let{getOrCreateWallet:s,clearWallet:i,status:n}=me(),{sdkHasLoaded:l,getAdminSigner:c,cleanup:f,isDynamicWalletConnected:m}=oe(t,o,e),{createOnLogin:y,adminSigner:a,linkedUser:w}=r,h=y==="all-users"&&n==="not-loaded"&&e!=null&&l,d=J(()=>C(this,null,function*(){var S,W;if(!h)return;let p=a,A=r.type;if(m&&(p=(S=yield c())!=null?S:p,A=(W=ee(p==null?void 0:p.type))!=null?W:A),!m&&r.type==null){console.error("[CrossmintAuthProvider] \u26A0\uFE0F embeddedWallets.type is required when no external wallet is connected");return}s({type:A,args:{adminSigner:p,linkedUser:w}})}),[h,s,w,a,r.type,c]),x=J(()=>{e==null&&n==="loaded"&&i(),f()},[n,e,i,f]);return It(()=>{d(),x()},[d,x]),null}function vi(){let r=Uo(it);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}import{jsx as Go,jsxs as jo}from"react/jsx-runtime";var Ue={timeoutMs:1e4,intervalMs:5e3},Me=Mo(null);function se({children:r,setWalletState:e,appearance:o,signersURL:t}){let{crossmint:{apiKey:s,jwt:i}}=Y(),n=_o(()=>Ko.from({apiKey:s,jwt:i}),[s,i]),l=zt(t),[c,f]=Nt(""),[m,y]=Nt("initial"),[a,w]=Nt(!1),h=Le(null),d=Le(null),x=P=>C(this,null,function*(){try{e({status:"in-progress"}),f(P.email);let g=Ho(s.startsWith("ck_development_")?"development":"staging"),O=(yield(yield fetch(`${g}/api/unstable/wallets/ncs/doesnt-matter/public-key`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i}`,"x-api-key":s},body:JSON.stringify({authId:`email:${P.email}`,signingAlgorithm:"EDDSA_ED25519"})})).json()).publicKey,M=Uint8Array.from(atob(O),V=>V.charCodeAt(0)),H=dt.encode(M),I=yield W(H),D=_(B({},I),{sendTransaction:V=>C(this,null,function*(){return new Promise((X,z)=>{let F=()=>{w(!1),y("initial")},q=()=>C(this,null,function*(){F();try{let N=yield I.sendTransaction(V);X(N)}catch(N){z(N)}}),rt=N=>{F(),z(N)};h.current=q,d.current=rt,p().then(q).catch(rt)})})});e({status:"loaded",wallet:D,type:"solana-smart-wallet"})}catch(g){throw console.error("There was an error creating a wallet ",g),e(nt(g)),g}});function p(){return C(this,null,function*(){if(!l.current||i==null)throw new Error("[handleGetRecoverySigner] IFrame window not initialized or JWT not set");return new Promise((P,g)=>C(this,null,function*(){var b;try{let u=yield(b=l.current)==null?void 0:b.sendAction({event:"request:get-public-key",responseEvent:"response:get-public-key",data:{authData:{jwt:i,apiKey:s},data:{chainLayer:"solana"}}});if((u==null?void 0:u.status)==="success")return console.log("Signer already exists, skipping OTP flow"),P();h.current=()=>P(),d.current=O=>g(O),y("initial"),w(!0)}catch(u){console.error("Error getting recovery signer",u),g(u)}}))})}let A=P=>C(this,null,function*(){var g,b;if(!l.current||i==null)throw new Error("[handleSendEmailOTP] IFrame window not initialized or JWT not set");try{console.log("Creating Recovery Key");let u=yield(g=l.current)==null?void 0:g.sendAction({event:"request:create-signer",responseEvent:"response:create-signer",data:{authData:{jwt:i,apiKey:s},data:{chainLayer:"solana",authId:`email:${P}`}}});if(u.status==="error")throw new Error(u.error);if(u.status==="success"&&u.address!=null){console.log("Signer already exists, skipping OTP flow"),y("initial"),w(!1);return}console.log("Proceeding to OTP flow"),y("otp"),w(!0)}catch(u){throw console.error("Error in email submission:",u),(b=d.current)==null||b.call(d,u),u}}),S=P=>C(this,null,function*(){var g,b;if(!l.current||i==null)throw new Error("[handleOTPSubmit] IFrame window not initialized or JWT not set");try{let u=yield l.current.sendAction({event:"request:send-otp",responseEvent:"response:send-otp",data:{authData:{jwt:i,apiKey:s},data:{encryptedOtp:P,chainLayer:"solana"}}});if(u.status==="error")throw new Error(u.error);y("initial"),w(!1),(g=h.current)==null||g.call(h)}catch(u){throw console.error("Error in OTP submission:",u),(b=d.current)==null||b.call(d,u),u}});function W(P){return C(this,null,function*(){if(i==null)throw new Error("[getOrCreateSolanaWalletWithSigner] JWT not set!");try{return yield n.getOrCreateWallet("solana-smart-wallet",{adminSigner:{type:"solana-keypair",address:P,signer:{signMessage:g=>C(this,null,function*(){if(l.current==null)throw new Error("IFrame window not initialized");let b=yield l.current.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:s},data:{keyType:"ed25519",bytes:dt.encode(g),encoding:"base58"}},options:Ue});if(b.status==="error")throw new Error(b.error);if(b.signature==null)throw new Error("Failed to sign message");return dt.decode(b.signature)}),signTransaction:g=>C(this,null,function*(){var O;console.log("Signing transaction...",g);let b=g.message.serialize(),u=yield(O=l.current)==null?void 0:O.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:s},data:{keyType:"ed25519",bytes:dt.encode(b),encoding:"base58"}},options:Ue});if((u==null?void 0:u.status)==="error")throw new Error(u.error);if((u==null?void 0:u.signature)==null)throw new Error("Failed to sign transaction");return g.addSignature(new Vo(P),dt.decode(u.signature)),g})}}})}catch(g){throw console.error("Error creating wallet with signer:",g),e(nt(g)),g}})}return Bo(()=>{document.body.style.overflow=a?"hidden":""},[a]),jo(Me.Provider,{value:{experimental_getOrCreateWalletWithRecoveryKey:x},children:[Go(jt,{email:c,open:a,setOpen:w,step:m,onSubmitOTP:S,onResendOTPCode:A,onSubmitEmail:A,appearance:o}),r]})}function ie({enabled:r=!0}={}){let e=Do(Me);if(!r)return{experimental_getOrCreateWalletWithRecoveryKey:()=>C(this,null,function*(){yield Promise.reject(new Error("useCrossmintSigner is disabled, please set 'experimental_enableRecoveryKeys' to true"))})};if(e===null)throw new Error("useCrossmintSigner must be used within a CrossmintSignerProvider");return e}export{Me as a,se as b,ie as c,Pt as d,ae as e,me as f,K as g,v as h,de as i,Z as j,Xe as k,ge as l,tt as m,pe as n,ye as o,we as p,xe as q,Ce as r,ve as s,Pe as t,Ae as u,We as v,Ee as w,Oe as x,Tt as y,Ne as z,it as A,ci as B,vi as C};
|