UNPKG

@clerk/clerk-js

Version:
3 lines • 268 kB
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var i=t();for(var n in i)("object"==typeof exports?exports:e)[n]=i[n]}}(globalThis,()=>(()=>{var e={753:function(e,t,i){"use strict";i.d(t,{O1:()=>l,Yt:()=>n,bf:()=>u,cD:()=>a,cc:()=>s,ci:()=>h,gR:()=>p,hz:()=>d,im:()=>c,v_:()=>r,w9:()=>o});let n=["redirect_url","after_sign_in_url","after_sign_up_url","sign_in_force_redirect_url","sign_in_fallback_redirect_url","sign_up_force_redirect_url","sign_up_fallback_redirect_url"],r="__clerk_modal_state",a="__clerk_synced",s="suffixed_cookies",o="__clerk_satellite_url",l={FORM_IDENTIFIER_NOT_FOUND:"form_identifier_not_found",FORM_PASSWORD_INCORRECT:"form_password_incorrect",FORM_PASSWORD_PWNED:"form_password_pwned",INVALID_STRATEGY_FOR_USER:"strategy_for_user_invalid",NOT_ALLOWED_TO_SIGN_UP:"not_allowed_to_sign_up",OAUTH_ACCESS_DENIED:"oauth_access_denied",OAUTH_EMAIL_DOMAIN_RESERVED_BY_SAML:"oauth_email_domain_reserved_by_saml",NOT_ALLOWED_ACCESS:"not_allowed_access",SAML_USER_ATTRIBUTE_MISSING:"saml_user_attribute_missing",USER_LOCKED:"user_locked",EXTERNAL_ACCOUNT_NOT_FOUND:"external_account_not_found",SIGN_UP_MODE_RESTRICTED:"sign_up_mode_restricted",SIGN_UP_MODE_RESTRICTED_WAITLIST:"sign_up_restricted_waitlist",ENTERPRISE_SSO_USER_ATTRIBUTE_MISSING:"enterprise_sso_user_attribute_missing",ENTERPRISE_SSO_EMAIL_ADDRESS_DOMAIN_MISMATCH:"enterprise_sso_email_address_domain_mismatch",ENTERPRISE_SSO_HOSTED_DOMAIN_MISMATCH:"enterprise_sso_hosted_domain_mismatch",SAML_EMAIL_ADDRESS_DOMAIN_MISMATCH:"saml_email_address_domain_mismatch",INVITATION_ACCOUNT_NOT_EXISTS:"invitation_account_not_exists",ORGANIZATION_MEMBERSHIP_QUOTA_EXCEEDED_FOR_SSO:"organization_membership_quota_exceeded_for_sso",CAPTCHA_INVALID:"captcha_invalid",FRAUD_DEVICE_BLOCKED:"device_blocked",FRAUD_ACTION_BLOCKED:"action_blocked",SIGNUP_RATE_LIMIT_EXCEEDED:"signup_rate_limit_exceeded"},c=["email_address","phone_number","username"],u=["email_address","phone_number","username","first_name","last_name"],d=350,h={PUBLIC:"public",RESTRICTED:"restricted",WAITLIST:"waitlist"},p="2025-04-10"},4152:function(e,t,i){"use strict";i.d(t,{$C:()=>P,C:()=>p,Dg:()=>s,FI:()=>A,G6:()=>c,HE:()=>u,O7:()=>h,PQ:()=>U,RE:()=>O,Rz:()=>m,WC:()=>g,Ws:()=>y,Xp:()=>a,_5:()=>S,an:()=>r,cT:()=>v,ep:()=>_,k2:()=>l,lb:()=>f,qO:()=>b,qW:()=>k,rn:()=>d,sY:()=>C,xZ:()=>w,yI:()=>o});let n="ClerkJS:";function r(e,t){throw Error(`${n} Network error at "${e}" - ${t}. Please try again.`)}function a(){throw Error(`${n} Something went wrong initializing Clerk.`)}function s(e=""){throw Error(`${n} Something went wrong initializing Clerk in development mode.${e&&` ${e}`}`)}function o(e){throw Error(`${n} Missing path option. The ${e} component was mounted with path routing so you need to specify the path where the component is mounted on e.g. path="/sign-in".`)}function l(e){throw Error(`${n} You must wrap your application in a <${e}> component.`)}function c(){throw Error(`${n} Clerk is undefined`)}function u(){throw Error(`${n} The target element is empty. Provide a valid DOM element.`)}function d(){throw Error(`${n} Missing FAPI client in resources.`)}function h(e){throw Error(`${n} Something went wrong initializing Clerk during the ${e} flow. Please contact support.`)}function p(e){throw Error(`${n} You need to start a ${e} flow by calling ${e}.create() first.`)}function m(e,t){throw Error(`${n} Strategy "${t}" is not a valid strategy for ${e}.`)}function f(e){throw Error(`${n} You need to start a ${e} flow by calling ${e}.create({ identifier: 'your web3 wallet address' }) first`)}function _(){throw Error(`${n} You need to start a SignIn flow by calling SignIn.create({ strategy: 'passkey' }) first`)}function g(e=""){throw Error(`${n} Missing '${e}' option`)}function y(e,t){throw Error(`${n} Response: ${e||0} not supported yet. For more information contact us at ${t}`)}function b(){throw Error(`${n} Missing dev browser jwt. Please contact support.`)}function w(){throw Error(`${n} Missing domain and proxyUrl. A satellite application needs to specify a domain or a proxyUrl.`)}function v(){throw Error(`${n} The signInUrl needs to be on a different origin than your satellite application.`)}function S(){throw Error(`${n} The signInUrl needs to have a absolute url format.`)}function k(){throw Error(`${n} Missing signInUrl. A satellite application needs to specify the signInUrl for development instances.`)}function C(){throw Error(`${n} Invalid redirect_url. A valid http or https url should be used for the redirection.`)}function A(e){throw Error(`${n} Unable to retrieve a third party script${e?` ${e}`:""}.`)}function U(e){throw Error(`${n} Invalid routing strategy, path cannot be used in tandem with ${e}.`)}function O(e){throw Error(`${n} Calling ${e}.reload is not currently supported. Please contact support.`)}function P(e){throw Error(`${n} Missing publicKey. When calling 'navigator.credentials.${e}()' it is required to pass a publicKey object.`)}},5:function(e,t,i){"use strict";i.d(t,{Y:()=>a,U:()=>r});var n=i(6225);i(4310);let r={TokenUpdate:"token:update",UserSignOut:"user:signOut",EnvironmentUpdate:"environment:update",SessionTokenResolved:"session:tokenResolved"},a=(0,n.n)()},4843:function(e,t,i){"use strict";i.d(t,{C9:()=>o,iL:()=>a,_G:()=>s,QE:()=>l});var n=i(750),r=i(3139);class a{getPlans=async e=>{let{for:t,...i}=e||{},a={...i,payer_type:"organization"===t?"org":"user"};return await r.i._fetch({path:"/commerce/plans",method:"GET",search:(0,n.C)(a)}).then(e=>{let{data:t,total_count:i}=e;return{total_count:i,data:t.map(e=>new r.Cs(e))}})};getPlan=async e=>{let t=await r.i._fetch({path:`/commerce/plans/${e.id}`,method:"GET"});return new r.Cs(t)};getSubscription=async e=>await r.i._fetch({path:e.orgId?`/organizations/${e.orgId}/commerce/subscription`:"/me/commerce/subscription",method:"GET"}).then(e=>new r.gU(e?.response));getSubscriptions=async e=>{let{orgId:t,...i}=e;return await r.i._fetch({path:t?`/organizations/${t}/commerce/subscriptions`:"/me/commerce/subscriptions",method:"GET",search:(0,n.C)(i)}).then(e=>{let{data:t,total_count:i}=e?.response;return{total_count:i,data:t.map(e=>new r.oq(e))}})};getStatements=async e=>{let{orgId:t,...i}=e;return await r.i._fetch({path:t?`/organizations/${t}/commerce/statements`:"/me/commerce/statements",method:"GET",search:(0,n.C)(i)}).then(e=>{let{data:t,total_count:i}=e?.response;return{total_count:i,data:t.map(e=>new r.j3(e))}})};getStatement=async e=>{let t=(await r.i._fetch({path:e.orgId?`/organizations/${e.orgId}/commerce/statements/${e.id}`:`/me/commerce/statements/${e.id}`,method:"GET"}))?.response;return new r.j3(t)};getPaymentAttempts=async e=>{let{orgId:t,...i}=e;return await r.i._fetch({path:t?`/organizations/${t}/commerce/payment_attempts`:"/me/commerce/payment_attempts",method:"GET",search:(0,n.C)(i)}).then(e=>{let{data:t,total_count:i}=e;return{total_count:i,data:t.map(e=>new r.Pm(e))}})};getPaymentAttempt=async e=>{let t=await r.i._fetch({path:e.orgId?`/organizations/${e.orgId}/commerce/payment_attempts/${e.id}`:`/me/commerce/payment_attempts/${e.id}`,method:"GET"});return new r.Pm(t)};startCheckout=async e=>{let{orgId:t,...i}=e,n=(await r.i._fetch({path:t?`/organizations/${t}/commerce/checkouts`:"/me/commerce/checkouts",method:"POST",body:i}))?.response;return new r.Dl(n,t)}}let s=async e=>{let{orgId:t,...i}=e,n=(await r.i._fetch({path:t?`/organizations/${t}/commerce/payment_sources/initialize`:"/me/commerce/payment_sources/initialize",method:"POST",body:i}))?.response;return new r.zv(n)},o=async e=>{let{orgId:t,...i}=e,n=(await r.i._fetch({path:t?`/organizations/${t}/commerce/payment_sources`:"/me/commerce/payment_sources",method:"POST",body:i}))?.response;return new r.wg(n)},l=async e=>{let{orgId:t,...i}=e;return await r.i._fetch({path:t?`/organizations/${t}/commerce/payment_sources`:"/me/commerce/payment_sources",method:"GET",search:(0,n.C)(i)}).then(e=>{let{data:t,total_count:i}=e?.response;return{total_count:i,data:t.map(e=>new r.wg(e))}})}},104:function(e,t,i){"use strict";i.d(t,{T:()=>a});var n=i(6630),r=i(3139);class a extends r.i{claimedAt=null;reverification=!1;singleSessionMode=!1;preferredChannels=null;constructor(e=null){super(),this.fromJSON(e)}fromJSON(e){return e&&(this.claimedAt=this.withDefault(e.claimed_at?(0,n.V)(e.claimed_at):null,this.claimedAt),this.reverification=this.withDefault(e.reverification,this.reverification),this.singleSessionMode=this.withDefault(e.single_session_mode,this.singleSessionMode),this.preferredChannels=this.withDefault(e.preferred_channels,this.preferredChannels)),this}__internal_toSnapshot(){return{claimed_at:this.claimedAt?this.claimedAt.getTime():null,id:this.id??"",object:"auth_config",reverification:this.reverification,single_session_mode:this.singleSessionMode}}}},8069:function(e,t,i){"use strict";i.d(t,{i:()=>c});var n=i(2708),r=i(1402),a=i(4152),s=i(7976),o=i(3139);class l{client;CaptchaChallengeImpl;static instance;inflightException=null;captchaRetryCount=0;MAX_RETRY_ATTEMPTS=3;static getInstance(){return l.instance||(l.instance=new l(o.KU,s.E)),l.instance}constructor(e,t){this.client=e,this.CaptchaChallengeImpl=t}async execute(e,t){if(this.captchaAttemptsExceeded())throw new o.w$("Security verification failed. Please try again by refreshing the page, clearing your browser cookies, or using a different web browser.",{code:"captcha_client_attempts_exceeded"});try{return this.inflightException&&await this.inflightException,await t()}catch(n){let i;if(!(0,o.kD)(n)||n.errors[0]?.code!=="requires_captcha")throw n;if(this.inflightException)return await this.inflightException,await t();this.inflightException=new Promise(e=>i=e);try{let t=await this.managedChallenge(e);t?.captchaError!=="modal_component_not_ready"&&(await this.client.getOrCreateInstance().__internal_sendCaptchaToken(t),this.captchaRetryCount=0)}catch(e){throw this.captchaRetryCount++,e}finally{i(),this.inflightException=null}return await t()}}managedChallenge(e){return new this.CaptchaChallengeImpl(e).managedInModal({action:"verify"})}captchaAttemptsExceeded=()=>this.captchaRetryCount>=this.MAX_RETRY_ATTEMPTS}class c{static clerk;id;pathRoot="";static get fapiClient(){return c.clerk.getFapiClient()}async reload(e){let{rotatingTokenNonce:t}=e||{};return this._baseGet({forceUpdateClient:!0,rotatingTokenNonce:t})}isNew(){return!this.id}static async _fetch(e,t={}){return l.getInstance().execute(this.clerk,()=>this._baseFetch(e,t))}static async _baseFetch(e,t={}){let i;c.fapiClient||(0,a.rn)();let{fetchMaxTries:s}=t;try{i=await c.fapiClient.request(e,{fetchMaxTries:s})}catch(e){if(this.shouldRethrowOfflineNetworkErrors())throw new o.w$(e?.message||e,{code:"network_error"});if(!(0,n.af)())return console.warn(e),null;throw e}let{payload:l,status:u,statusText:d,headers:h}=i;if(h){let e=h.get("x-country");this.clerk.__internal_setCountry(e?e.toLowerCase():null)}if(("GET"!==e.method||t.forceUpdateClient)&&this._updateClient(l),u>=200&&u<=299)return l;if(u>=400){let e=l?.errors,t=e?.[0]?.long_message,i=e?.[0]?.code;401===u&&"requires_captcha"!==i&&await c.clerk.handleUnauthenticated(),function(e,t){if(!t||!t[0])return;let i=t[0],n=i.long_message;if("origin_invalid"===i.code&&(0,r.mA)(c.clerk.publishableKey)){let i=c.clerk.frontendApi.replace("clerk.","");throw new o.gO(`Clerk: Production Keys are only allowed for domain "${i}". API Error: ${n}`,{data:t,status:e})}}(u,e);let n={data:e,status:u};if(429===u&&h){let e=h.get("retry-after");if(e){let t=parseInt(e,10);isNaN(t)||(n.retryAfter=t)}}throw new o.gO(t||d,n)}return null}static _updateClient(e){if(!e)return;let t=e.client||e.meta?.client;t&&c.clerk&&c.clerk.updateClient(o.KU.getOrCreateInstance().fromJSON(t))}path(e){let t=this.pathRoot;if(this.isNew())return t;let i=t.replace(/[^/]$/,"$&/")+encodeURIComponent(this.id);return e?i.replace(/[^/]$/,"$&/")+encodeURIComponent(e):i}withDefault(e,t){return e??t}async _baseGet(e={}){let t=await c._fetch({method:"GET",path:this.path(),rotatingTokenNonce:e.rotatingTokenNonce},e);return this.fromJSON(t?.response||t)}async _baseMutate(e){let{action:t,body:i,method:n,path:r}=e,a=await c._fetch({method:n,path:r||this.path(t),body:i});return this.fromJSON(a?.response||a)}async _baseMutateBypass(e){let{action:t,body:i,method:n,path:r}=e,a=await c._baseFetch({method:n,path:r||this.path(t),body:i});return this.fromJSON(a?.response||a)}async _basePost(e={}){return this._baseMutate({...e,method:"POST"})}async _basePostBypass(e={}){return this._baseMutateBypass({...e,method:"POST"})}async _basePut(e={}){return this._baseMutate({...e,method:"PUT"})}async _basePatch(e={}){return this._baseMutate({...e,method:"PATCH"})}async _baseDelete(e={}){await this._baseMutate({...e,method:"DELETE"})}static shouldRethrowOfflineNetworkErrors(){let e=c.clerk?.__internal_getOption?.("experimental");return e?.rethrowOfflineNetworkErrors||!1}}},9401:function(e,t,i){"use strict";i.d(t,{K:()=>s});var n=i(6630),r=i(7292),a=i(3139);class s extends a.i{static instance;pathRoot="/client";sessions=[];signUp=new a.Mo;signIn=new a.cL;lastActiveSessionId=null;captchaBypass=!1;cookieExpiresAt=null;createdAt=null;updatedAt=null;static getOrCreateInstance(e=null){return s.instance||(s.instance=new s(e)),s.instance}static clearInstance(){s.instance=null}static isClientResource(e){return!!e&&e instanceof s}constructor(e=null){super(),this.fromJSON(e)}get signUpAttempt(){return this.signUp}get signInAttempt(){return this.signIn}get activeSessions(){return this.sessions.filter(e=>"active"===e.status)}get signedInSessions(){return this.sessions.filter(e=>"active"===e.status||"pending"===e.status)}create(){return this._basePut()}fetch({fetchMaxTries:e}={}){return this._baseGet({fetchMaxTries:e})}async destroy(){return this._baseDelete({path:"/client"}).then(()=>{r.O.clear(),this.id="",this.sessions=[],this.signUp=new a.Mo(null),this.signIn=new a.cL(null),this.lastActiveSessionId=null,this.cookieExpiresAt=null,this.createdAt=null,this.updatedAt=null})}removeSessions(){return this._baseDelete({path:this.path()+"/sessions"}).then(e=>(r.O.clear(),e))}clearCache(){return this.sessions.forEach(e=>e.clearCache())}isEligibleForTouch(){return!!this.cookieExpiresAt&&this.cookieExpiresAt.getTime()-Date.now()<=6912e5}buildTouchUrl({redirectUrl:e}){return a.i.fapiClient.buildUrl({method:"GET",path:"/client/touch",pathPrefix:"v1",search:{redirect_url:e.toString()}}).toString()}__internal_sendCaptchaToken(e){return this._basePostBypass({body:e,path:this.path()+"/verify"})}fromJSON(e){return e&&(this.id=e.id,this.sessions=(e.sessions||[]).map(e=>new a.z_(e)),this.signUp=new a.Mo(e.sign_up),this.signIn=new a.cL(e.sign_in),this.lastActiveSessionId=e.last_active_session_id,this.captchaBypass=e.captcha_bypass||!1,this.cookieExpiresAt=e.cookie_expires_at?(0,n.V)(e.cookie_expires_at):null,this.createdAt=(0,n.V)(e.created_at||void 0),this.updatedAt=(0,n.V)(e.updated_at||void 0)),this}__internal_toSnapshot(){return{object:"client",id:this.id||"",sessions:this.sessions.map(e=>e.__internal_toSnapshot()),sign_up:this.signUp.__internal_toSnapshot(),sign_in:this.signIn.__internal_toSnapshot(),last_active_session_id:this.lastActiveSessionId,captcha_bypass:this.captchaBypass,cookie_expires_at:this.cookieExpiresAt?this.cookieExpiresAt.getTime():null,created_at:this.createdAt?.getTime()??null,updated_at:this.updatedAt?.getTime()??null}}path(){return this.pathRoot}}},4498:function(e,t,i){"use strict";i.d(t,{l:()=>r});var n=i(3139);class r extends n.i{afterCreateOrganizationUrl="";afterJoinWaitlistUrl="";afterLeaveOrganizationUrl="";afterSignInUrl="";afterSignOutAllUrl="";afterSignOutOneUrl="";afterSignOutUrl="";afterSignUpUrl="";afterSwitchSessionUrl="";applicationName="";backendHost="";branded=!1;captchaHeartbeat=!1;captchaHeartbeatIntervalMs;captchaOauthBypass=["oauth_google","oauth_microsoft","oauth_apple"];captchaProvider="turnstile";captchaPublicKey=null;captchaPublicKeyInvisible=null;captchaWidgetType=null;clerkJSVersion;createOrganizationUrl="";experimental__forceOauthFirst;faviconImageUrl="";googleOneTapClientId;homeUrl="";id="";instanceEnvironmentType="";logoImageUrl="";organizationProfileUrl="";preferredSignInStrategy="password";privacyPolicyUrl="";showDevModeWarning=!1;signInUrl="";signUpUrl="";supportEmail="";termsUrl="";theme={};userProfileUrl="";waitlistUrl="";constructor(e=null){super(),this.fromJSON(e)}fromJSON(e){return e&&(this.afterCreateOrganizationUrl=this.withDefault(e.after_create_organization_url,this.afterCreateOrganizationUrl),this.afterJoinWaitlistUrl=this.withDefault(e.after_join_waitlist_url,this.afterJoinWaitlistUrl),this.afterLeaveOrganizationUrl=this.withDefault(e.after_leave_organization_url,this.afterLeaveOrganizationUrl),this.afterSignInUrl=this.withDefault(e.after_sign_in_url,this.afterSignInUrl),this.afterSignOutAllUrl=this.withDefault(e.after_sign_out_all_url,this.afterSignOutAllUrl),this.afterSignOutOneUrl=this.withDefault(e.after_sign_out_one_url,this.afterSignOutOneUrl),this.afterSignUpUrl=this.withDefault(e.after_sign_up_url,this.afterSignUpUrl),this.afterSwitchSessionUrl=this.withDefault(e.after_switch_session_url,this.afterSwitchSessionUrl),this.applicationName=this.withDefault(e.application_name,this.applicationName),this.branded=this.withDefault(e.branded,this.branded),this.captchaHeartbeat=this.withDefault(e.captcha_heartbeat,this.captchaHeartbeat),this.captchaHeartbeatIntervalMs=this.withDefault(e.captcha_heartbeat_interval_ms,this.captchaHeartbeatIntervalMs),this.captchaOauthBypass=this.withDefault(e.captcha_oauth_bypass,this.captchaOauthBypass),this.captchaProvider=this.withDefault(e.captcha_provider,this.captchaProvider),this.captchaPublicKey=this.withDefault(e.captcha_public_key,this.captchaPublicKey),this.captchaPublicKeyInvisible=this.withDefault(e.captcha_public_key_invisible,this.captchaPublicKeyInvisible),this.captchaWidgetType=this.withDefault(e.captcha_widget_type,this.captchaWidgetType),this.clerkJSVersion=this.withDefault(e.clerk_js_version,this.clerkJSVersion),this.createOrganizationUrl=this.withDefault(e.create_organization_url,this.createOrganizationUrl),this.faviconImageUrl=this.withDefault(e.favicon_image_url,this.faviconImageUrl),this.googleOneTapClientId=this.withDefault(e.google_one_tap_client_id,this.googleOneTapClientId),this.homeUrl=this.withDefault(e.home_url,this.homeUrl),this.id=this.withDefault(e.id,this.id),this.instanceEnvironmentType=this.withDefault(e.instance_environment_type,this.instanceEnvironmentType),this.logoImageUrl=this.withDefault(e.logo_image_url,this.logoImageUrl),this.organizationProfileUrl=this.withDefault(e.organization_profile_url,this.organizationProfileUrl),this.preferredSignInStrategy=this.withDefault(e.preferred_sign_in_strategy,this.preferredSignInStrategy),this.privacyPolicyUrl=this.withDefault(e.privacy_policy_url,this.privacyPolicyUrl),this.showDevModeWarning=this.withDefault(e.show_devmode_warning,this.showDevModeWarning),this.signInUrl=this.withDefault(e.sign_in_url,this.signInUrl),this.signUpUrl=this.withDefault(e.sign_up_url,this.signUpUrl),this.supportEmail=this.withDefault(e.support_email,this.supportEmail),this.termsUrl=this.withDefault(e.terms_url,this.termsUrl),this.theme=this.withDefault(e.theme,this.theme),this.userProfileUrl=this.withDefault(e.user_profile_url,this.userProfileUrl),this.waitlistUrl=this.withDefault(e.waitlist_url,this.waitlistUrl)),this}__internal_toSnapshot(){return{object:"display_config",after_create_organization_url:this.afterCreateOrganizationUrl,after_join_waitlist_url:this.afterJoinWaitlistUrl,after_leave_organization_url:this.afterLeaveOrganizationUrl,after_sign_in_url:this.afterSignInUrl,after_sign_out_all_url:this.afterSignOutAllUrl,after_sign_out_one_url:this.afterSignOutOneUrl,after_sign_up_url:this.afterSignUpUrl,after_switch_session_url:this.afterSwitchSessionUrl,application_name:this.applicationName,branded:this.branded,captcha_heartbeat_interval_ms:this.captchaHeartbeatIntervalMs,captcha_heartbeat:this.captchaHeartbeat,captcha_oauth_bypass:this.captchaOauthBypass,captcha_provider:this.captchaProvider,captcha_public_key_invisible:this.captchaPublicKeyInvisible,captcha_public_key:this.captchaPublicKey,captcha_widget_type:this.captchaWidgetType,clerk_js_version:this.clerkJSVersion,create_organization_url:this.createOrganizationUrl,favicon_image_url:this.faviconImageUrl,google_one_tap_client_id:this.googleOneTapClientId,home_url:this.homeUrl,id:this.id,instance_environment_type:this.instanceEnvironmentType,logo_image_url:this.logoImageUrl,organization_profile_url:this.organizationProfileUrl,preferred_sign_in_strategy:this.preferredSignInStrategy,privacy_policy_url:this.privacyPolicyUrl,show_devmode_warning:this.showDevModeWarning,sign_in_url:this.signInUrl,sign_up_url:this.signUpUrl,support_email:this.supportEmail,terms_url:this.termsUrl,theme:this.theme,user_profile_url:this.userProfileUrl,waitlist_url:this.waitlistUrl}}}},2986:function(e,t,i){"use strict";i.d(t,{b:()=>a});var n=i(6111),r=i(3139);class a extends r.i{id;emailAddress="";matchesSsoConnection=!1;linkedTo=[];verification;constructor(e,t){super(),this.pathRoot=t,this.fromJSON(e)}create(){return this._basePost({body:{email_address:this.emailAddress}})}prepareVerification=e=>this._basePost({action:"prepare_verification",body:{...e}});attemptVerification=e=>{let{code:t}=e||{};return this._basePost({action:"attempt_verification",body:{code:t}})};createEmailLinkFlow=()=>{let{run:e,stop:t}=(0,n.W)();return{startEmailLinkFlow:async({redirectUrl:i})=>(await this.prepareVerification({strategy:"email_link",redirectUrl:i}),new Promise((i,n)=>{e(()=>this.reload().then(e=>{"verified"===e.verification.status&&(t(),i(e))}).catch(e=>{t(),n(e)}))})),cancelEmailLinkFlow:t}};createEnterpriseSSOLinkFlow=()=>{let{run:e,stop:t}=(0,n.W)();return{startEnterpriseSSOLinkFlow:async({redirectUrl:i})=>{if(!(await this.prepareVerification({strategy:"enterprise_sso",redirectUrl:i})).verification.externalVerificationRedirectURL)throw Error("Unexpected: External verification redirect URL is missing");return new Promise((i,n)=>{e(()=>this.reload().then(e=>{"verified"===e.verification.status&&(t(),i(e))}).catch(e=>{t(),n(e)}))})},cancelEnterpriseSSOLinkFlow:t}};destroy=()=>this._baseDelete();toString=()=>this.emailAddress;fromJSON(e){return e&&(this.id=e.id,this.emailAddress=e.email_address,this.verification=new r.GX(e.verification),this.matchesSsoConnection=e.matches_sso_connection,this.linkedTo=(e.linked_to||[]).map(e=>new r.YN(e))),this}__internal_toSnapshot(){return{object:"email_address",id:this.id,email_address:this.emailAddress,verification:this.verification.__internal_toSnapshot(),linked_to:this.linkedTo.map(e=>e.__internal_toSnapshot()),matches_sso_connection:this.matchesSsoConnection}}}},9357:function(e,t,i){"use strict";i.d(t,{q:()=>o});var n=i(5),r=i(3139);class a extends r.i{enabled=!1;constructor(e=null){super(),this.fromJSON(e)}fromJSON(e){return e&&(this.enabled=this.withDefault(e.enabled,!1)),this}__internal_toSnapshot(){return{enabled:this.enabled}}}class s extends r.i{actions={adminDelete:!1};domains={enabled:!1,enrollmentModes:[],defaultRole:null};enabled=!1;maxAllowedMemberships=1;forceOrganizationSelection;constructor(e=null){super(),this.fromJSON(e)}fromJSON(e){return e&&(e.actions&&(this.actions.adminDelete=this.withDefault(e.actions.admin_delete,this.actions.adminDelete)),e.domains&&(this.domains.enabled=this.withDefault(e.domains.enabled,this.domains.enabled),this.domains.enrollmentModes=this.withDefault(e.domains.enrollment_modes,this.domains.enrollmentModes),this.domains.defaultRole=this.withDefault(e.domains.default_role,this.domains.defaultRole)),this.enabled=this.withDefault(e.enabled,this.enabled),this.maxAllowedMemberships=this.withDefault(e.max_allowed_memberships,this.maxAllowedMemberships),this.forceOrganizationSelection=this.withDefault(e.force_organization_selection,this.forceOrganizationSelection)),this}__internal_toSnapshot(){return{actions:{admin_delete:this.actions.adminDelete},domains:{enabled:this.domains.enabled,enrollment_modes:this.domains.enrollmentModes,default_role:this.domains.defaultRole},enabled:this.enabled,max_allowed_memberships:this.maxAllowedMemberships}}}class o extends r.i{static instance;authConfig=new r.Tg;displayConfig=new r.lR;maintenanceMode=!1;pathRoot="/environment";userSettings=new r.PG;organizationSettings=new s;commerceSettings=new r.mM;apiKeysSettings=new a;static getInstance(){return o.instance||(o.instance=new o),o.instance}constructor(e=null){super(),this.fromJSON(e)}fromJSON(e){return e&&(this.authConfig=new r.Tg(e.auth_config),this.displayConfig=new r.lR(e.display_config),this.maintenanceMode=this.withDefault(e.maintenance_mode,this.maintenanceMode),this.organizationSettings=new s(e.organization_settings),this.userSettings=new r.PG(e.user_settings),this.commerceSettings=new r.mM(e.commerce_settings),this.apiKeysSettings=new a(e.api_keys_settings)),this}fetch({touch:e,fetchMaxTries:t}={touch:!1}){return(e?this._basePatch({}):this._baseGet({fetchMaxTries:t})).then(e=>(n.Y.emit(n.U.EnvironmentUpdate,null),e))}isDevelopmentOrStaging=()=>!this.isProduction();isProduction=()=>"production"===this.displayConfig.instanceEnvironmentType;isSingleSession=()=>this.authConfig.singleSessionMode;onWindowLocationHost=()=>this.displayConfig.backendHost===window.location.host;__internal_toSnapshot(){return{object:"environment",auth_config:this.authConfig.__internal_toSnapshot(),display_config:this.displayConfig.__internal_toSnapshot(),id:this.id??"",maintenance_mode:this.maintenanceMode,organization_settings:this.organizationSettings.__internal_toSnapshot(),user_settings:this.userSettings.__internal_toSnapshot(),commerce_settings:this.commerceSettings.__internal_toSnapshot(),api_keys_settings:this.apiKeysSettings.__internal_toSnapshot()}}}},3767:function(e,t,i){"use strict";i.d(t,{N:()=>n.N,ZC:()=>n.ZC,gO:()=>n.gO,kD:()=>n.kD,sZ:()=>n.sZ,uX:()=>n.uX,w$:()=>n.w$});var n=i(3531)},6516:function(e,t,i){"use strict";i.d(t,{z:()=>s});var n=i(5027),r=i(8069),a=i(9596);class s extends r.i{id;identificationId;provider;providerUserId="";emailAddress="";approvedScopes="";firstName="";lastName="";imageUrl="";username="";phoneNumber="";publicMetadata={};label="";verification=null;constructor(e,t){super(),this.pathRoot=t,this.fromJSON(e)}reauthorize=e=>{let{additionalScopes:t,redirectUrl:i}=e||{};return this._basePatch({action:"reauthorize",body:{additional_scope:t,redirect_url:i}})};destroy=()=>this._baseDelete();fromJSON(e){return e&&(this.id=e.id,this.identificationId=e.identification_id,this.providerUserId=e.provider_user_id,this.approvedScopes=e.approved_scopes,this.imageUrl=e.image_url,this.emailAddress=e.email_address,this.firstName=e.first_name,this.lastName=e.last_name,this.provider=(e.provider||"").replace("oauth_",""),this.username=e.username,this.phoneNumber=e.phone_number,this.publicMetadata=e.public_metadata,this.label=e.label,e.verification&&(this.verification=new a.GX(e.verification))),this}__internal_toSnapshot(){return{object:"external_account",id:this.id,identification_id:this.identificationId,provider:this.provider,provider_user_id:this.providerUserId,email_address:this.emailAddress,approved_scopes:this.approvedScopes,first_name:this.firstName,last_name:this.lastName,image_url:this.imageUrl,username:this.username,phone_number:this.phoneNumber,public_metadata:this.publicMetadata,label:this.label,verification:this.verification?.__internal_toSnapshot()||null}}providerSlug(){return this.provider}providerTitle(){return[(0,n.MI)(this.providerSlug()),"Account"].join(" ")}accountIdentifier(){return this.username||this.emailAddress||this.label}}},1956:function(e,t,i){"use strict";i.d(t,{Y:()=>r});var n=i(8069);class r extends n.i{id;type;constructor(e){super(),this.fromJSON(e)}fromJSON(e){return e&&(this.id=e.id,this.type=e.type),this}__internal_toSnapshot(){return{object:"identification_link",id:this.id,type:this.type}}}},6890:function(e,t,i){"use strict";i.d(t,{E:()=>r});var n=i(3139);class r extends n.i{id;name=null;publicUrl=null;static async create(e,t={}){let i,a=t;return"string"==typeof t.file?(a=t.file,i=new Headers({"Content-Type":"application/octet-stream"})):t.file&&(a=new FormData).append("file",t.file),new r((await n.i._fetch({path:e,method:"POST",body:a,headers:i}))?.response)}static async delete(e){return new r((await n.i._fetch({path:e,method:"DELETE"}))?.response)}constructor(e){super(),this.fromJSON(e)}fromJSON(e){return e&&(this.id=e.id,this.name=e.name,this.publicUrl=e.public_url),this}}},9210:function(e,t,i){"use strict";i.d(t,{B:()=>r});var n=i(3139);class r extends n.i{id;phoneNumber="";reservedForSecondFactor=!1;defaultSecondFactor=!1;linkedTo=[];verification;backupCodes;constructor(e,t){super(),this.pathRoot=t,this.fromJSON(e)}create=()=>this._basePost({body:{phone_number:this.phoneNumber}});prepareVerification=()=>this._basePost({action:"prepare_verification",body:{strategy:"phone_code"}});attemptVerification=e=>{let{code:t}=e||{};return this._basePost({action:"attempt_verification",body:{code:t}})};setReservedForSecondFactor=e=>{let{reserved:t}=e||{};return this._basePatch({body:{reserved_for_second_factor:t}})};makeDefaultSecondFactor=()=>this._basePatch({body:{default_second_factor:!0}});destroy=()=>this._baseDelete();toString=()=>{let e=this.phoneNumber.match(/^(\d{3})(\d{3})(\d{4})$/);return e?"("+e[1]+") "+e[2]+"-"+e[3]:this.phoneNumber};fromJSON(e){return e&&(this.id=e.id,this.phoneNumber=e.phone_number,this.reservedForSecondFactor=e.reserved_for_second_factor,this.defaultSecondFactor=e.default_second_factor,this.verification=new n.GX(e.verification),this.linkedTo=(e.linked_to||[]).map(e=>new n.YN(e)),this.backupCodes=e.backup_codes),this}__internal_toSnapshot(){return{object:"phone_number",id:this.id||"",phone_number:this.phoneNumber,reserved_for_second_factor:this.reservedForSecondFactor,default_second_factor:this.defaultSecondFactor,verification:this.verification.__internal_toSnapshot(),linked_to:this.linkedTo.map(e=>e.__internal_toSnapshot()),backup_codes:this.backupCodes}}}},2724:function(e,t,i){"use strict";i.d(t,{g:()=>s});var n=i(6630),r=i(8069),a=i(9596);class s extends r.i{id;provider="saml_custom";providerUserId=null;active=!1;emailAddress="";firstName="";lastName="";verification=null;samlConnection=null;constructor(e,t){super(),this.pathRoot=t,this.fromJSON(e)}fromJSON(e){return e&&(this.id=e.id,this.provider=e.provider,this.providerUserId=e.provider_user_id,this.active=e.active,this.emailAddress=e.email_address,this.firstName=e.first_name,this.lastName=e.last_name,e.verification&&(this.verification=new a.GX(e.verification)),e.saml_connection&&(this.samlConnection=new o(e.saml_connection))),this}__internal_toSnapshot(){return{object:"saml_account",id:this.id,provider:this.provider,provider_user_id:this.providerUserId,active:this.active,email_address:this.emailAddress,first_name:this.firstName,last_name:this.lastName,verification:this.verification?.__internal_toSnapshot()||null,saml_connection:this.samlConnection?.__internal_toSnapshot()}}}class o extends r.i{id;name;domain;active;provider;syncUserAttributes;allowSubdomains;allowIdpInitiated;disableAdditionalIdentifications;createdAt;updatedAt;constructor(e){super(),this.fromJSON(e)}fromJSON(e){return e&&(this.id=e.id,this.name=e.name,this.domain=e.domain,this.active=e.active,this.provider=e.provider,this.syncUserAttributes=e.sync_user_attributes,this.allowSubdomains=e.allow_subdomains,this.allowIdpInitiated=e.allow_idp_initiated,this.disableAdditionalIdentifications=e.disable_additional_identifications,this.createdAt=(0,n.V)(e.created_at),this.updatedAt=(0,n.V)(e.updated_at)),this}__internal_toSnapshot(){return{object:"saml_account_connection",id:this.id,name:this.name,domain:this.domain,active:this.active,provider:this.provider,sync_user_attributes:this.syncUserAttributes,allow_subdomains:this.allowSubdomains,allow_idp_initiated:this.allowIdpInitiated,disable_additional_identifications:this.disableAdditionalIdentifications,created_at:this.createdAt.getTime(),updated_at:this.updatedAt.getTime()}}}},7045:function(e,t,i){"use strict";i.d(t,{z:()=>f});var n=i(1353);i(4310);var r=i(3531),a=i(153),s=i(2208),o=i(6630),l=i(3367),c=i(4152),u=i(5),d=i(7292),h=i(3139),p=i(5027);class m extends h.i{status;level;session;supportedFirstFactors=[];supportedSecondFactors=[];firstFactorVerification=new h.GX(null);secondFactorVerification=new h.GX(null);constructor(e=null){super(),this.fromJSON(e)}fromJSON(e){return e&&(this.id=e.id,this.status=e.status,this.session=new h.z_(e.session),this.level=e.level,this.supportedFirstFactors=(0,p.aw)(e.supported_first_factors),this.supportedSecondFactors=(0,p.aw)(e.supported_second_factors),this.firstFactorVerification=new h.GX(e.first_factor_verification),this.secondFactorVerification=new h.GX(e.second_factor_verification)),this}}class f extends h.i{pathRoot="/client/sessions";id;status;lastActiveAt;lastActiveToken;lastActiveOrganizationId;actor;user;publicUserData;factorVerificationAge=null;tasks=null;expireAt;abandonAt;createdAt;updatedAt;static isSessionResource(e){return!!e&&e instanceof f}constructor(e){super(),this.fromJSON(e),this.#e(this.lastActiveToken)}end=()=>(d.O.clear(),this._basePost({action:"end"}));remove=()=>(d.O.clear(),this._basePost({action:"remove"}));touch=()=>this._basePost({action:"touch",body:{active_organization_id:this.lastActiveOrganizationId}}).then(e=>(e.lastActiveToken&&u.Y.emit(u.U.TokenUpdate,{token:e.lastActiveToken}),e));clearCache=()=>d.O.clear();getToken=async e=>(0,a.X)(()=>this._getToken(e),{factor:1.55,initialDelay:3e3,maxDelayBetweenRetries:5e4,jitter:!1,shouldRetry:(e,t)=>!(0,r.ix)(e)&&t<=8});checkAuthorization=e=>{let t=(this.user?.organizationMemberships||[]).find(e=>e.organization.id===this.lastActiveOrganizationId);return(0,n.QL)({userId:this.user?.id,factorVerificationAge:this.factorVerificationAge,orgId:t?.id,orgRole:t?.role,orgPermissions:t?.permissions,features:this.lastActiveToken?.jwt?.claims.fea||"",plans:this.lastActiveToken?.jwt?.claims.pla||""})(e)};#e=e=>{e&&d.O.set({tokenId:this.#t(),tokenResolver:Promise.resolve(e)})};#t(e,t){let i=void 0===t?this.lastActiveOrganizationId:t;return[this.id,e,i,this.updatedAt.getTime()].filter(Boolean).join("-")}startVerification=async({level:e})=>new m((await h.i._fetch({method:"POST",path:`/client/sessions/${this.id}/verify`,body:{level:e}}))?.response);prepareFirstFactorVerification=async e=>{let t;switch(e.strategy){case"email_code":t={emailAddressId:e.emailAddressId};break;case"phone_code":t={phoneNumberId:e.phoneNumberId,default:e.default};break;case"passkey":t={};break;default:(0,c.Rz)("Session.prepareFirstFactorVerification",e.strategy)}return new m((await h.i._fetch({method:"POST",path:`/client/sessions/${this.id}/verify/prepare_first_factor`,body:{...t,strategy:e.strategy}}))?.response)};attemptFirstFactorVerification=async e=>{let t;return t="passkey"===e.strategy?{publicKeyCredential:JSON.stringify((0,l.zQ)(e.publicKeyCredential))}:{...e},new m((await h.i._fetch({method:"POST",path:`/client/sessions/${this.id}/verify/attempt_first_factor`,body:{...t,strategy:e.strategy}}))?.response)};verifyWithPasskey=async()=>{let{nonce:e=null}=(await this.prepareFirstFactorVerification({strategy:"passkey"})).firstFactorVerification,t=f.clerk.__internal_isWebAuthnSupported||s.iW,i=f.clerk.__internal_getPublicCredentials||l.t1;if(!t())throw new r.RK("Passkeys are not supported",{code:"passkey_not_supported"});let n=e?(0,l.N7)(JSON.parse(e)):null;n||(0,c.$C)("get");let{publicKeyCredential:a,error:o}=await i({publicKeyOptions:n,conditionalUI:!1});if(!a)throw o;return this.attemptFirstFactorVerification({strategy:"passkey",publicKeyCredential:a})};prepareSecondFactorVerification=async e=>new m((await h.i._fetch({method:"POST",path:`/client/sessions/${this.id}/verify/prepare_second_factor`,body:e}))?.response);attemptSecondFactorVerification=async e=>new m((await h.i._fetch({method:"POST",path:`/client/sessions/${this.id}/verify/attempt_second_factor`,body:e}))?.response);fromJSON(e){return e&&(this.id=e.id,this.status=e.status,this.expireAt=(0,o.V)(e.expire_at),this.abandonAt=(0,o.V)(e.abandon_at),this.factorVerificationAge=e.factor_verification_age,this.lastActiveAt=(0,o.V)(e.last_active_at||void 0),this.lastActiveOrganizationId=e.last_active_organization_id,this.actor=e.actor||null,this.createdAt=(0,o.V)(e.created_at),this.updatedAt=(0,o.V)(e.updated_at),this.user=new h.n5(e.user),this.tasks=e.tasks||null,e.public_user_data&&(this.publicUserData=new h.VO(e.public_user_data)),this.lastActiveToken=e.last_active_token?new h.WU(e.last_active_token):null),this}__internal_toSnapshot(){return{object:"session",id:this.id,status:this.status,expire_at:this.expireAt.getTime(),abandon_at:this.abandonAt.getTime(),factor_verification_age:this.factorVerificationAge,last_active_at:this.lastActiveAt.getTime(),last_active_organization_id:this.lastActiveOrganizationId,actor:this.actor,tasks:this.tasks,user:this.user?.__internal_toSnapshot()||null,public_user_data:this.publicUserData.__internal_toSnapshot(),last_active_token:this.lastActiveToken?.__internal_toSnapshot()||null,created_at:this.createdAt.getTime(),updated_at:this.updatedAt.getTime()}}async _getToken(e){if(!this.user)return null;let{leewayInSeconds:t,template:i,skipCache:n=!1}=e||{},r=void 0===e?.organizationId?this.lastActiveOrganizationId:e?.organizationId;if(!i&&Number(t)>=60)throw Error("Leeway can not exceed the token lifespan (60 seconds)");let a=this.#t(i,r),s=n?void 0:d.O.get({tokenId:a},t),o=!i&&r===this.lastActiveOrganizationId;if(s){let e=await s.tokenResolver;return o&&u.Y.emit(u.U.TokenUpdate,{token:e}),e.getRawString()||null}let l=i?`${this.path()}/tokens/${i}`:`${this.path()}/tokens`,c=h.WU.create(l,i?{}:{organizationId:r});return d.O.set({tokenId:a,tokenResolver:c}),c.then(e=>(o&&(u.Y.emit(u.U.TokenUpdate,{token:e}),e.jwt&&(this.lastActiveToken=e,u.Y.emit(u.U.SessionTokenResolved,null))),e.getRawString()||null))}get currentTask(){let[e]=this.tasks??[];return e}}},8076:function(e,t,i){"use strict";i.d(t,{A:()=>a});var n=i(6630),r=i(3139);class a extends r.i{pathRoot="";id;status;abandonAt;expireAt;lastActiveAt;latestActivity;actor;constructor(e,t){super(),this.pathRoot=t,this.fromJSON(e)}static retrieve(){let e=r.i.clerk.session?.id;return this.clerk.getFapiClient().request({method:"GET",path:"/me/sessions/active",sessionId:e}).then(e=>e.payload.map(e=>new a(e,"/me/sessions"))).catch(()=>[])}revoke(){return this._basePost({action:"revoke",body:{}})}fromJSON(e){let t;return e?(this.id=e.id,this.status=e.status,this.expireAt=(0,n.V)(e.expire_at),this.abandonAt=(0,n.V)(e.abandon_at),this.lastActiveAt=(0,n.V)(e.last_active_at||void 0),this.latestActivity={id:(t=e.latest_activity??{}).id,deviceType:t.device_type,browserName:t.browser_name,browserVersion:t.browser_version,country:t.country,city:t.city,isMobile:t.is_mobile,ipAddress:t.ip_address},this.actor=e.actor,this):this}}},3898:function(e,t,i){"use strict";i.d(t,{c:()=>p});var n=i(3531),r=i(6111),a=i(5027),s=i(2208),o=i(3344),l=i(3837),c=i(3367),u=i(33),d=i(4152),h=i(3139);class p extends h.i{pathRoot="/client/sign_ins";id;status=null;supportedIdentifiers=[];supportedFirstFactors=[];supportedSecondFactors=null;firstFactorVerification=new h.GX(null);secondFactorVerification=new h.GX(null);identifier=null;createdSessionId=null;userData=new h.mt(null);constructor(e=null){super(),this.fromJSON(e)}create=e=>this._basePost({path:this.pathRoot,body:e});resetPassword=e=>this._basePost({body:e,action:"reset_password"});prepareFirstFactor=e=>{let t;switch(e.strategy){case"passkey":t={};break;case"email_link":t={emailAddressId:e.emailAddressId,redirectUrl:e.redirectUrl};break;case"email_code":case"reset_password_email_code":t={emailAddressId:e.emailAddressId};break;case"phone_code":t={phoneNumberId:e.phoneNumberId,default:e.default,channel:e.channel};break;case"web3_metamask_signature":case"web3_coinbase_wallet_signature":case"web3_okx_wallet_signature":t={web3WalletId:e.web3WalletId};break;case"reset_password_phone_code":t={phoneNumberId:e.phoneNumberId};break;case"saml":t={redirectUrl:e.redirectUrl,actionCompleteRedirectUrl:e.actionCompleteRedirectUrl};break;case"enterprise_sso":t={redirectUrl:e.redirectUrl,actionCompleteRedirectUrl:e.actionCompleteRedirectUrl,oidcPrompt:e.oidcPrompt};break;default:(0,d.Rz)("SignIn.prepareFirstFactor",e.strategy)}return this._basePost({body:{...t,strategy:e.strategy},action:"prepare_first_factor"})};attemptFirstFactor=e=>{let t;return t="passkey"===e.strategy?{publicKeyCredential:JSON.stringify((0,c.zQ)(e.publicKeyCredential))}:{...e},this._basePost({body:{...t,strategy:e.strategy},action:"attempt_first_factor"})};createEmailLinkFlow=()=>{let{run:e,stop:t}=(0,r.W)();return{startEmailLinkFlow:async({emailAddressId:i,redirectUrl:n})=>(this.id||(0,d.C)("SignIn"),await this.prepareFirstFactor({strategy:"email_link",emailAddressId:i,redirectUrl:n}),new Promise((i,n)=>{e(()=>this.reload().then(e=>{let n=e.firstFactorVerification.status;("verified"===n||"expired"===n)&&(t(),i(e))}).catch(e=>{t(),n(e)}))})),cancelEmailLinkFlow:t}};prepareSecondFactor=e=>this._basePost({body:e,action:"prepare_second_factor"});attemptSecondFactor=e=>this._basePost({body:e,action:"attempt_second_factor"});authenticateWithRedirectOrPopup=async(e,t)=>{let{strategy:i,redirectUrl:n,redirectUrlComplete:r,identifier:a,oidcPrompt:s,continueSignIn:l}=e||{},c=p.clerk.buildUrlWithAuth(n),u=p.clerk.__internal_hasAfterAuthFlows?(0,o.KV)({base:c,search:`?redirect_url=${r}`}).toString():r;this.id&&l||await this.create({strategy:i,identifier:a,redirectUrl:c,actionCompleteRedirectUrl:u}),("saml"===i||"enterprise_sso"===i)&&await this.prepareFirstFactor({strategy:i,redirectUrl:p.clerk.buildUrlWithAuth(n),actionCompleteRedirectUrl:u,oidcPrompt:s});let{status:h,externalVerificationRedirectURL:m}=this.firstFactorVerification;"unverified"===h&&m?t(m):(0,d.Ws)(h,p.fapiClient.buildEmailAddress("support"))};authenticateWithRedirect=async e=>this.authenticateWithRedirectOrPopup(e,o.T7);authenticateWithPopup=async e=>{let{popup:t}=e||{};return t||(0,d.WC)("popup"),(0,l.G)(p.clerk,"signIn",this.authenticateWithRedirectOrPopup,e,e=>{t.location.href=e.toString()})};authenticateWithWeb3=async e=>{let t,{identifier:i,generateSignature:n,strategy:r="web3_metamask_signature"}=e||{},a=r.replace("web3_","").replace("_signature","");"function"!=typeof n&&(0,d.WC)("generateSignature"),await this.create({identifier:i});let s=this.supportedFirstFactors?.find(e=>e.strategy===r);s||(0,d.lb)("SignIn"),await this.prepareFirstFactor(s);let{message:o}=this.firstFactorVerification;o||(0,d.lb)("SignIn");try{t=await n({identifier:i,nonce:o,provider:a})}catch(e){if("coinbase_wallet"===a&&4001===e.code)t=await n({identifier:i,nonce:o,provider:a});else throw e}return this.attemptFirstFactor({signature:t,strategy:r})};authenticateWithMetamask=async()=>{let e=await (0,o.M8)();return this.authenticateWithWeb3({identifier:e,generateSignature:o.wO,strategy:"web3_metamask_signature"})};authenticateWithCoinbaseWallet=async()=>{let e=await (0,o.$0)();return this.authenticateWithWeb3({identifier:e,generateSignature:o.dR,strategy:"web3_coinbase_wallet_signature"})};authenticateWithOKXWallet=async()=>{let e=await (0,o.ZE)();return this.authenticateWithWeb3({identifier:e,generateSignature:o.C3,strategy:"web3_okx_wallet_signature"})};authenticateWithPasskey=async e=>{let{flow:t}=e||{},i=p.clerk.__internal_isWebAuthnSupported||s.iW,r=p.clerk.__internal_getPublicCredentials||c.t1,a=p.clerk.__internal_isWebAuthnAutofillSupported||s.h_;if(!i())throw new n.RK("Passkeys are not supported",{code:"passkey_not_supported"});if("autofill"===t||"discoverable"===t)await this.create({strategy:"passkey"});else{let e=this.supportedFirstFactors.find(e=>"passkey"===e.strategy);e||(0,d.ep)(),await this.prepareFirstFactor(e)}let{nonce:o}=this.firstFactorVerification,l=o?(0,c.N7)(JSON.parse(o)):null;l||(0,d.$C)("get");let u=!1;"autofill"===t&&(u=await a());let{publicKeyCredential:h,error:m}=await r({publicKeyOptions:l,conditionalUI:u});if(!h)throw m;return this.attemptFirstFactor({publicKeyCredential:h,strategy:"passkey"})};validatePassword=(e,t)=>{if(p.clerk.__unstable__environment?.userSettings.passwordSettings)return(0,u.z)({...p.clerk.__unstable__environment?.userSettings.passwordSettings,validatePassword:!0})(e,t)};fromJSON(e){return e&&(this.id=e.id,this.status=e.status,this.supportedIdentifiers=e.supported_identifiers,this.identifier=e.identifier,this.supportedFirstFactors=(0,a.aw)(e.supported_first_factors),this.supportedSecondFactors=(0,a.aw)(e.supported_second_factors),this.firstFactorVerification=new h.GX(e.first_factor_verification),this.secondFactorVerification=new h.GX(e.second_factor_verification),this.createdSessionId=e.created_session_id,this.userData=new h.mt(e.user_data)),this}__internal_toSnapshot(){return{object:"sign_in",id:this.id||"",status:this.status||null,supported_identifiers:this.supportedIdentifiers,supported_first_factors:(0,a.zb)(this.supportedFirstFactors),supported_second_factors:(0,a.zb)(this.supportedSecondFactors),first_factor_verification:this.firstFactorVerification.__internal_toSnapshot(),second_factor_verification:this.secondFactorVerification.__internal_toSnapshot(),identifier:this.identifier,created_session_id:this.createdSessionId,user_data:this.userData.__internal_toSnapshot()}}}},240:function(e,t,i){"use strict";i.d(t,{M:()=>h});var n=i(3531),r=i(6111),a=i(3344),s=i(3837),o=i(7976),l=i(33),c=i(6310),u=i(4152),d=i(3139);class h extends d.i{pathRoot="/client/sign_ups";id;status=null;requiredFields=[];optionalFields=[];missingFields=[];unverifiedFields=[];verifications=new d.EJ(null);username=null;firstName=null;lastName=null;emailAddress=null;phoneNumber=null;web3wallet=null;externalAccount;hasPassword=!1;unsafeMetadata={};createdSessionId=null;createdUserId=null;abandonAt=null;legalAcceptedAt=null;constructor(e=null){super(),this.fromJSON(e)}create=async e=>{let t=e;if(!this.clientBypass()&&!this.shouldBypassCaptchaForAttempt(t)){let e=new o.E(h.clerk),i=await e.managedOrInvisible({action:"signup"});if(!i)throw new d.w$("",{code:"captcha_unavailable"});t={...t,...i}}return t.transfer&&this.shouldBypassCaptchaForAttempt(t)&&(t.strategy=h.clerk.client?.signIn.firstFactorVerification.strategy),this._basePost({path:this.pathRoot,body:(0,c.q)(t)})};prepareVerification=e=>this._basePost({body:e,action:"prepare_verification"});attemptVerification=e=>this._basePost({body:e,action:"attempt_verification"});prepareEmailAddressVerification=e=>this.prepareVerification(e||{strategy:"email_code"});attemptEmailAddressVerification=e=>this.attemptVerification({...e,strategy:"email_code"});createEmailLinkFlow=()=>{let{run:e,stop:t}=(0,r.W)();return{startEmailLinkFlow:async({redirectUrl:i})=>(this.id||(0,u.C)("SignUp"),await this.prepareEmailAddressVerification({strategy:"email_link",redirectUrl:i}),new Promise((i,n)=>{e(()=>this.reload().then(e=>{let n=e.verifications.emailAddress.status;("verified"===n||"expired"===n)&&(t(),i(e))}).catch(e=>{t(),n(e)}))})),cancelEmailLinkFlow:t}};preparePhoneNumberVerification=e=>this.prepareVerification(e||{strategy:"phone_code"});attemptPhoneNumberVerification=e=>this.attemptVerification({...e,strategy:"phone_code"});prepareWeb3WalletVerification=e=>this.prepareVerification({strategy:"web3_metamask_signature",...e});attemptWeb3WalletVerification=async e=>{let{signature:t,strategy:i="web3_metamask_signature"}=e;return this.attemptVerification({signature:t,strategy:i})};authenticateWithWeb3=async e=>{let t,{generateSignature:i,identifier:n,unsafeMetadata:r,strategy:a="web3_metamask_signature",legalAccepted:s}=e||{},o=a.replace("web3_","").replace("_signature","");"function"!=typeof i&&(0,u.WC)("generateSignature");let l=n||this.web3wallet;await this.create({web3Wallet:l,unsafeMetadata:r,legalAccepted:s}),await this.prepareWeb3WalletVerification({strategy:a});let{message:c}=this.verifications.web3Wallet;c||(0,u.lb)("SignUp");try{t=await i({identifier:n,nonce:c,provider:o})}catch(e){if("coinbase_wallet"===o&&4001===e.code)t=await i({identifier:n,nonce:c,provider:o});else throw e}return this.attemptWeb3WalletVerification({signature:t,strategy:a})};authenticateWithMetamask=async e=>{let t=await (0,a.M8)();return this.authenticateWithWeb3({identifier:t,generateSignature:a.wO,unsafeMetadata:e?.unsafeMetadata,strategy:"web3_metamask_signature",legalAccepted:e?.legalAccepted})};authenticateWithCoinbaseWallet=async e=>{let t=await (0,a.$0)();return this.authenticateWithWeb3({identifier:t,generateSignature:a.dR,unsafeMetadata:e?.unsafeMetadata,strategy:"web3_coinbase_wallet_signature",legalAccepted:e?.legalAccepted})};authenticateWithOKXWallet=async e=>{let t=await (0,a.ZE)();return this.authenticateWithWeb3({identifier:t,generateSignature:a.C3,unsafeMetadata:e?.unsafeMetadata,strategy:"web3_okx_wallet_signature",legalAccepted:e?.legalAccepted})};authenticateWithRedirectOrPopup=async(e,t)=>{let{redirectUrl:i,redirectUrlComplete:r,strategy:a,continueSignUp:s=!1,unsafeMetadata:o,emailAddress:l,legalAccepted:c,oidcPrompt:d}=e,p=h.clerk.buildUrlWithAuth(i),m=h.clerk.__internal_hasAfterAuthFlows?p:r,f=()=>{let e={strategy:a,redirectUrl:p,actionCompleteRedirectUrl:m,unsafeMetadata:o,emailAddress:l,legalAccepted:c,oidcPrompt:d};return s&&this.id?this.update(e):this.create(e)},{verifications:_}=await f().catch(async e=>{if((0,n.kD)(e)&&(0,n.pG)(e))return await h.clerk.__unstable__environment.reload(),f();throw e}),{externalAccount:g}=_,{status:y,externalVerificationRedirectURL:b}=g;"unverified"===y&&b?t(b):(0,u.Ws)(y,h.fapiClient.buildEmailAddress("support"))};authenticateWithRedirect=async e=>this.authenticateWithRedirectOrPopup(e,a.T7);authenticateWithPopup=async e=>{let{popup:t}=e||{};return t||(0,u.WC)("popup"),(0,s.G)(h.clerk,"signUp",this.authenticateWithRedirectOrPopup,e,e=>{t.location.href=e instanceof URL?e.toString():e})};update=e=>this._basePatch(