1;!function(){try { var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof global?global:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&((e._debugIds|| (e._debugIds={}))[n]="f1cac2d9-4d91-b12e-6fc1-c9475e6c3f32")}catch(e){}}(); 2(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,756390,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r={cancelIdleCallback:function(){return n},requestIdleCallback:function(){return a}};for(var s in r)Object.defineProperty(i,s,{enumerable:!0,get:r[s]});let a="u">typeof self&&self.requestIdleCallback&&self.requestIdleCallback.bind(window)||function(e){let t=Date.now();return self.setTimeout(function(){e({didTimeout:!1,timeRemaining:function(){return Math.max(0,50-(Date.now()-t))}})},1)},n="u">typeof self&&self.cancelIdleCallback&&self.cancelIdleCallback.bind(window)||function(e){return clearTimeout(e)};("function"==typeof i.default||"object"==typeof i.default&&null!==i.default)&&void 0===i.default.__esModule&&(Object.defineProperty(i.default,"__esModule",{value:!0}),Object.assign(i.default,i),t.exports=i.default)},623125,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r={ESCAPE_REGEX:function(){return n},htmlEscapeAttributeString:function(){return u},htmlEscapeJsonString:function(){return l}};for(var s in r)Object.defineProperty(i,s,{enumerable:!0,get:r[s]});let a={"&":"\\u0026",">":"\\u003e","<":"\\u003c","\u2028":"\\u2028","\u2029":"\\u2029"},n=/[&><\u2028\u2029]/g,o={"&":"&",'"':""","'":"'","<":"<",">":">"},c=/[&"'<>]/g;function l(e){return e.replace(n,e=>a[e])}function u(e){return e.replace(c,e=>o[e])}},479901,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0});var r={default:function(){return b},handleClientScriptLoad:function(){return f},initScriptLoader:function(){return g}};for(var s in r)Object.defineProperty(i,s,{enumerable:!0,get:r[s]});let a=e.r(836437),n=e.r(56421),o=e.r(693142),c=a._(e.r(985855)),l=n._(e.r(693185)),u=e.r(927457),h=e.r(350864),d=e.r(756390),p=e.r(623125),m=new Map,_=new Set,y=e=>{let{src:t,id:i,onLoad:r=()=>{},onReady:s=null,dangerouslySetInnerHTML:a,children:n="",strategy:o="afterInteractive",onError:l,stylesheets:u}=e,d=i||t;if(d&&_.has(d))return;if(m.has(t)){_.add(d),m.get(t).then(r,l);return}let p=()=>{s&&s(),_.add(d)},y=document.createElement("script"),f=new Promise((e,t)=>{y.addEventListener("load",function(t){e(),r&&r.call(this,t),p()}),y.addEventListener("error",function(e){t(e)})}).catch(function(e){l&&l(e)});a?(y.innerHTML=a.__html||"",p()):n?(y.textContent="string"==typeof n?n:Array.isArray(n)?n.join(""):"",p()):t&&(y.src=t,m.set(t,f)),(0,h.setAttributesFromProps)(y,e),"worker"===o&&y.setAttribute("type","text/partytown"),y.setAttribute("data-nscript",o),u&&(e=>{if(c.default.preinit)return e.forEach(e=>{c.default.preinit(e,{as:"style"})});if("u">typeof window){let t=document.head;e.forEach(e=>{let i=document.createElement("link");i.type="text/css",i.rel="stylesheet",i.href=e,t.appendChild(i)})}})(u),document.body.appendChild(y)};function f(e){let{strategy:t="afterInteractive"}=e;"lazyOnload"===t?window.addEventListener("load",()=>{(0,d.requestIdleCallback)(()=>y(e))}):y(e)}function g(e){e.forEach(f),[...document.querySelectorAll('[data-nscript="beforeInteractive"]'),...document.querySelectorAll('[data-nscript="beforePageRender"]')].forEach(e=>{let t=e.id||e.getAttribute("src");_.add(t)})}function w(e){let{id:t,src:i="",onLoad:r=()=>{},onReady:s=null,strategy:a="afterInteractive",onError:n,stylesheets:h,...m}=e,{updateScripts:f,scripts:g,getIsSsr:w,appDir:b,nonce:S}=(0,l.useContext)(u.HeadManagerContext);S=m.nonce||S;let k=(0,l.useRef)(!1);(0,l.useEffect)(()=>{let e=t||i;k.current||(s&&e&&_.has(e)&&s(),k.current=!0)},[s,t,i]);let C=(0,l.useRef)(!1);if((0,l.useEffect)(()=>{if(!C.current){if("afterInteractive"===a)y(e);else"lazyOnload"===a&&("complete"===document.readyState?(0,d.requestIdleCallback)(()=>y(e)):window.addEventListener("load",()=>{(0,d.requestIdleCallback)(()=>y(e))}));C.current=!0}},[e,a]),("beforeInteractive"===a||"worker"===a)&&(f?(g[a]=(g[a]||[]).concat([{id:t,src:i,onLoad:r,onReady:s,onError:n,...m,nonce:S}]),f(g)):w&&w()?_.add(t||i):w&&!w()&&y({...e,nonce:S}
2)),b){if(h&&h.forEach(e=>{c.default.preinit(e,{as:"style"})}),"beforeInteractive"===a)if(!i)return m.dangerouslySetInnerHTML&&(m.children=m.dangerouslySetInnerHTML.__html,delete m.dangerouslySetInnerHTML),(0,o.jsx)("script",{nonce:S,dangerouslySetInnerHTML:{__html:`(self.__next_s=self.__next_s||[]).push(${(0,p.htmlEscapeJsonString)(JSON.stringify([0,{...m,id:t}]))})`}});else return c.default.preload(i,m.integrity?{as:"script",integrity:m.integrity,nonce:S,crossOrigin:m.crossOrigin}:{as:"script",nonce:S,crossOrigin:m.crossOrigin}),(0,o.jsx)("script",{nonce:S,dangerouslySetInnerHTML:{__html:`(self.__next_s=self.__next_s||[]).push(${(0,p.htmlEscapeJsonString)(JSON.stringify([i,{...m,id:t}]))})`}});"afterInteractive"===a&&i&&c.default.preload(i,m.integrity?{as:"script",integrity:m.integrity,nonce:S,crossOrigin:m.crossOrigin}:{as:"script",nonce:S,crossOrigin:m.crossOrigin})}return null}Object.defineProperty(w,"__nextScript",{value:!0});let b=w;("function"==typeof i.default||"object"==typeof i.default&&null!==i.default)&&void 0===i.default.__esModule&&(Object.defineProperty(i.default,"__esModule",{value:!0}),Object.assign(i.default,i),t.exports=i.default)},316055,e=>{"use strict";var t=e.i(507325),i=e.i(133529),r=e.i(779855);let s=(0,t.o)("queue-reset",()=>({mutex:0}));function a(e=1){s.mutex=e}function n(){(0,r.t)(19),i.t.abortAll(),i.r.abort().forEach(e=>i.t.queuedQuerySync.emit(e))}var o=e.i(693185),c=e.i(146218);function l(){a(0),n()}function u(){let e=(0,c.usePathname)(),r=(0,o.useRef)(e);return r.current!==e&&(r.current=e,i.r.reset()),(0,o.useEffect)(()=>(!function(){var e;if(e="next/app","u"<typeof history||(history.nuqs?.version&&"2.10.1"!==history.nuqs.version?(console.error((0,t.l)(409),history.nuqs.version,t.s,e),!0):!!history.nuqs?.adapters?.includes(e)))return;let i=history.replaceState,r=history.pushState;history.replaceState=function(e,t,r){return i.call(history,e,"__nuqs__"===t?"":t,r)},history.pushState=function(e,t,i){return"__nuqs__"!==t&&function(e=n){s.mutex=Math.max(0,s.mutex-1),s.mutex>0||e()}(()=>{queueMicrotask(n)}),r.call(history,e,"__nuqs__"===t?"":t,i)},history.nuqs=history.nuqs??{version:"2.10.1",adapters:[]},history.nuqs.adapters.push("next/app")}(),window.addEventListener("popstate",l),()=>window.removeEventListener("popstate",l)),[]),null}let h=(0,t.n)(function(){let e=(0,c.useRouter)(),i=(0,c.usePathname)(),[s,n]=(0,o.useOptimistic)((0,c.useSearchParams)()??new URLSearchParams);return{searchParams:s,pathname:i,updateUrl:(0,o.useCallback)((i,s)=>{(0,o.startTransition)(()=>{s.shallow||n(i);let o=function(e){let{origin:i,pathname:r,hash:s}=location;return i+r+(0,t.c)(e)+s}(i);(0,r.t)(20,"next/app",o);let c="push"===s.history?history.pushState:history.replaceState;a(0),c.call(history,null,"__nuqs__",o),s.scroll&&window.scrollTo(0,0),s.shallow||e.replace(o,{scroll:!1})})},[]),rateLimitFactor:3,autoResetQueueOnUpdate:!1}});e.s(["NuqsAdapter",0,function({children:e,...t}){return(0,o.createElement)(h,{...t,children:[(0,o.createElement)(o.Suspense,{key:"nuqs-adapter-suspense-navspy",children:(0,o.createElement)(u)}),e]})}],316055)},402124,e=>{"use strict";var t=e.i(693142),i=e.i(875825),r=e.i(693185),s=e.i(378356),a=e.i(553094),n=e.i(470508),o=e.i(288060),c=e.i(777288),l=e.i(567948),u=e.i(688949),h=class extends u.Removable{#e;#t;#i;#r;constructor(e){super(),this.#e=e.client,this.mutationId=e.mutationId,this.#i=e.mutationCache,this.#t=[],this.state=e.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){this.#t.includes(e)||(this.#t.push(e),this.clearGcTimeout(),this.#i.notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){this.#t=this.#t.filter(t=>t!==e),this.scheduleGc(),this.#i.notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){this.#t.length||("pending"===this.state.status?this.scheduleGc():this.#i.remove(this))}continue(){return this.#r?.continue()??("pending"===this.state.status?this.execute(this.state.variables):Promise.resolve())}async execute(e){let t=()=>{this.#s({type:"continue"})},i={client:this.#e,meta:this.options.meta,mutationKey:this.options.mutationKey},r=this.#r=(0,l.createRetryer)({fn:()=>this.options.mutationFn?this.options.mutationFn(e,i):Promise.reject(Error("No mutationFn found")),onFail:(e,t)=>{this.#s({type:"failed",failureCount:e,error:t})},onPause:()=>{this.#s({type:"pause"})},onContinue:t,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#i.canRun(this)}),s="pending"===this.state.status,a=!r.canStart();try{if(s)t();else{this.#s({type:"pending",variables:e,isPaused:a}),this.#i.config.onMutate&&await this.#i.config.onMutate(e,this,i);let t=await this.options.onMutate?.(e,i);t!==this.state.context&&this.#s({type:"pending",context:t,variables:e,isPaused:a})}let n=await r.start();return await this.#i.config.onSuccess?.(n,e,this.state.context,this,i),await this.options.onSuccess?.(n,e,this.state.context,i),await this.#i.config.onSettled?.(n,null,this.state.variables,this.state.context,this,i),await this.options.onSettled?.(n,null,e,this.state.context,i),this.#s({type:"success",data:n}),n}catch(t){try{await this.#i.config.onError?.(t,e,this.state.context,this,i)}catch(e){Promise.reject(e)}try{await this.options.onError?.(t,e,this.state.context,i)}catch(e){Promise.reject(e)}try{await this.#i.config.onSettled?.(void 0,t,this.state.variables,this.state.context,this,i)}catch(e){Promise.reject(e)}try{await this.options.onSettled?.(void 0,t,e,this.state.context,i)}catch(e){Promise.reject(e)}throw this.#s({type:"error",error:t}),t}finally{this.#r===r&&(this.#r=void 0),this.#i.runNext(this)}}#s(e){this.state=(t=>{switch(e.type){case"failed":return{...t,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...t,isPaused:!0};case"continue":return{...t,isPaused:!1};
vendor: 1,406 bytes, line 2
2case"pending":return{...t,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...t,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...t,data:void 0,error:e.error,failureCount:t.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}})(this.state),n.notifyManager.batch(()=>{this.#t.forEach(t=>{t.onMutationUpdate(e)}),this.#i.notify({mutation:this,type:"updated",action:e})})}},d=class extends c.Subscribable{#a;#n;#o;constructor(e={}){super(),this.config=e,this.#a=new Set,this.#n=new Map,this.#o=0}build(e,t,i){let r=new h({client:e,mutationCache:this,mutationId:++this.#o,options:e.defaultMutationOptions(t),state:i});return this.add(r),r}add(e){this.#a.add(e);let t=p(e);if("string"==typeof t){let i=this.#n.get(t);i?i.push(e):this.#n.set(t,[e])}this.notify({type:"added",mutation:e})}remove(e){if(this.#a.delete(e)){let t=p(e);if("string"==typeof t){let i=this.#n.get(t);if(i)if(i.length>1){let t=i.indexOf(e);-1!==t&&i.splice(t,1)}else i[0]===e&&this.#n.delete(t)}}this.notify({type:"removed",mutation:e})}canRun(e){let t=p(e);if("string"!=typeof t)return!0;{let i=this.#n.get(t)?.find(e=>"pending"===e.state.status);return!i||i===e}}runNext(e){let t=p(e);return"string"==typeof t?this.#n.get(t)?.find(t=>
2t!==e&&t.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){n.notifyManager.batch(()=>{this.#a.forEach(e=>{this.notify({type:"removed",mutation:e})}),this.#a.clear(),this.#n.clear()})}getAll(){return Array.from(this.#a)}find(e){let t={exact:!0,...e};return this.getAll().find(e=>(0,s.matchMutation)(t,e))}findAll(e={}){return this.getAll().filter(t=>(0,s.matchMutation)(e,t))}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}resumePausedMutations(){let e=this.getAll().filter(e=>e.state.isPaused);return n.notifyManager.batch(()=>Promise.all(e.map(e=>e.continue().catch(s.noop))))}};function p(e){return e.options.scope?.id}var m=c,_=e.i(840741),y=class extends m.Subscribable{#c;constructor(e={}){super(),this.config=e,this.#c=new Map}build(e,t,i){let r=t.queryKey,a=t.queryHash??(0,s.hashQueryKeyByOptions)(r,t),n=this.get(a);return n||(n=new _.Query({client:e,queryKey:r,queryHash:a,options:e.defaultQueryOptions(t),state:i,defaultOptions:e.getQueryDefaults(r)}),this.add(n)),n}add(e){this.#c.has(e.queryHash)||(this.#c.set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){this.#c.get(e.queryHash)===e&&(e.destroy(),this.#c.delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return this.#c.get(e)}getAll(){return[...this.#c.values()]}find(e){let t={exact:!0,...e};return this.getAll().find(e=>(0,s.matchQuery)(t,e))}findAll(e={}){let t=this.getAll();return Object.keys(e).length>0?t.filter(t=>(0,s.matchQuery)(e,t)):t}notify(e){n.notifyManager.batch(()=>{this.listeners.forEach(t=>{t(e)})})}onFocus(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){n.notifyManager.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},f=class{#l;#i;#u;#h;#d;#p;#m;#_;constructor(e={}){this.#l=e.queryCache||new y,this.#i=e.mutationCache||new d,this.#u=e.defaultOptions||{},this.#h=new Map,this.#d=new Map,this.#p=0}mount(){this.#p++,1===this.#p&&(this.#m=a.focusManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#l.onFocus())}),this.#_=o.onlineManager.subscribe(async e=>{e&&(await this.resumePausedMutations(),this.#l.onOnline())}))}unmount(){this.#p--,0===this.#p&&(this.#m?.(),this.#m=void 0,this.#_?.(),this.#_=void 0)}isFetching(e){return this.#l.findAll({...e,fetchStatus:"fetching"}).length}isMutating(e){return this.#i.findAll({...e,status:"pending"}).length}getQueryData(e){let t=this.defaultQueryOptions({queryKey:e});return this.#l.get(t.queryHash)?.state.data}ensureQueryData(e){let t=this.defaultQueryOptions(e),i=this.#l.build(this,t),r=i.state.data;return void 0===r?this.fetchQuery(e):(e.revalidateIfStale&&i.isStaleByTime((0,s.resolveQueryValue)(t.staleTime,i))&&this.prefetchQuery(t),Promise.resolve(r))}getQueriesData(e){return this.#l.findAll(e).map(({queryKey:e,state:t})=>[e,t.data])}setQueryData(e,t,i){let r=this.defaultQueryOptions({queryKey:e}),a=this.#l.get(r.queryHash)?.state.data,n=(0,s.functionalUpdate)(t,a);if(void 0!==n)return this.#l.build(this,r).setData(n,{...i,manual:!0})}setQueriesData(e,t,i){return n.notifyManager.batch(()=>this.#l.findAll(e).map(({queryKey:e})=>[e,this.setQueryData(e,t,i)]))}getQueryState(e){let t=this.defaultQueryOptions({queryKey:e});return this.#l.get(t.queryHash)?.state}removeQueries(e){let t=this.#l;n.notifyManager.batch(()=>{t.findAll(e).forEach(e=>{t.remove(e)})})}resetQueries(e,t){let i=this.#l;return n.notifyManager.batch(()=>{let r=i.findAll(e),s=new Set(r);return r.forEach(e=>{e.reset()}),this.refetchQueries({type:"active",predicate:e=>s.has(e)},t)})}cancelQueries(e,t={}){let i={revert:!0,...t};return Promise.all(n.notifyManager.batch(()=>this.#l.findAll(e).map(e=>e.cancel(i)))).then(s.noop).catch(s.noop)}invalidateQueries(e,t={}){return n.notifyManager.batch(()=>(this.#l.findAll(e).forEach(e=>{e.invalidate()}),e?.refetchType==="none")?Promise.resolve():this.refetchQueries({...e,type:e?.refetchType??e?.type??"active"},t))}refetchQueries(e,t={}){let i={...t,cancelRefetch:t.cancelRefetch??!0};return Promise.all(n.notifyManager.batch(()=>this.#l.findAll(e).filter(e=>!e.isDisabled()&&!e.isStatic()).map(e=>{let t=e.fetch(void 0,i);return i.throwOnError||(t=t.catch(s.noop)),"paused"===e.state.fetchStatus?Promise.resolve():t}
2))).then(s.noop)}async query(e){let t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);let i=this.#l.build(this,t),r=i.isStaleByTime((0,s.resolveQueryValue)(t.staleTime,i))?await i.fetch(t):i.state.data,a=t.select;return a?a(r):r}fetchQuery(e){let t=this.defaultQueryOptions(e);void 0===t.retry&&(t.retry=!1);let i=this.#l.build(this,t);return i.isStaleByTime((0,s.resolveQueryValue)(t.staleTime,i))?i.fetch(t):Promise.resolve(i.state.data)}prefetchQuery(e){return this.fetchQuery(e).then(s.noop).catch(s.noop)}infiniteQuery(e){return e._type="infinite",this.query(e)}fetchInfiniteQuery(e){return e._type="infinite",this.fetchQuery(e)}prefetchInfiniteQuery(e){return this.fetchInfiniteQuery(e).then(s.noop).catch(s.noop)}ensureInfiniteQueryData(e){return e._type="infinite",this.ensureQueryData(e)}resumePausedMutations(){return o.onlineManager.isOnline()?this.#i.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#l}getMutationCache(){return this.#i}getDefaultOptions(){return this.#u}setDefaultOptions(e){this.#u=e}setQueryDefaults(e,t){this.#h.set((0,s.hashKey)(e),{queryKey:e,defaultOptions:t})}getQueryDefaults(e){let t=[...this.#h.values()],i={};return t.forEach(t=>{(0,s.partialMatchKey)(e,t.queryKey)&&Object.assign(i,t.defaultOptions)}),i}setMutationDefaults(e,t){this.#d.set((0,s.hashKey)(e),{mutationKey:e,defaultOptions:t})}getMutationDefaults(e){let t=[...this.#d.values()],i={};return t.forEach(t=>{(0,s.partialMatchKey)(e,t.mutationKey)&&Object.assign(i,t.defaultOptions)}),i}defaultQueryOptions(e){if(e._defaulted)return e;let t={...this.#u.queries,...this.getQueryDefaults(e.queryKey),...e,_defaulted:!0};return t.queryHash||(t.queryHash=(0,s.hashQueryKeyByOptions)(t.queryKey,t)),void 0===t.refetchOnReconnect&&(t.refetchOnReconnect="always"!==t.networkMode),void 0===t.throwOnError&&(t.throwOnError=!!t.suspense),!t.networkMode&&t.persister&&(t.networkMode="offlineFirst"),t.queryFn===s.skipToken&&(t.enabled=!1),t}defaultMutationOptions(e){return e?._defaulted?e:{...this.#u.mutations,...e?.mutationKey&&this.getMutationDefaults(e.mutationKey),...e,_defaulted:!0}}clear(){this.#l.clear(),this.#i.clear()}},g=e.i(650955);function w(){return new f}e.s(["QueryClientProviderWrapper",0,e=>{let s,a=(0,i.c)(3),{children:n}=e,[o]=(0,r.useState)(w);return a[0]!==n||a[1]!==o?(s=(0,t.jsx)(g.QueryClientProvider,{client:o,children:n}),a[0]=n,a[1]=o,a[2]=s):s=a[2],s}],402124)},591548,e=>{"use strict";var t,i,r=e.i(693142),s=e.i(875825),a=e.i(225727),n=e.i(550832);let o="bootstrap",c=()=>({displayWatermark:!1,projectName:null,cnameDomain:null,emailDomains:["stytch.com"],captchaSettings:{enabled:!1},pkceRequiredForEmailMagicLinks:!1,pkceRequiredForPasswordResets:!1,pkceRequiredForOAuth:!1,pkceRequiredForSso:!1,slugPattern:null,createOrganizationEnabled:!1,passwordConfig:null,runDFPProtectedAuth:!1,rbacPolicy:null,siweRequiredForCryptoWallets:!1,vertical:null});class l{_publicToken;_networkClient;_dataLayer;_bootstrapDataPromise;constructor(e,t,i){this._publicToken=e,this._networkClient=t,this._dataLayer=i,this._bootstrapDataPromise=this._networkClient.fetchSDK({url:`/projects/bootstrap/${this._publicToken}`,method:"GET"}).then(l.mapBootstrapData).then(e=>(this._dataLayer.setItem(o,JSON.stringify(e)),e)).catch(e=>(n.logger.error(e),c()))}static mapBootstrapData(e){let t=null!==e.password_config?{ludsComplexity:e.password_config.luds_complexity,ludsMinimumCount:e.password_config.luds_minimum_count}:null;return{projectName:e.project_name,displayWatermark:!e.disable_sdk_watermark,captchaSettings:e.captcha_settings,cnameDomain:e.cname_domain,emailDomains:e.email_domains,pkceRequiredForEmailMagicLinks:e.pkce_required_for_email_magic_links,pkceRequiredForPasswordResets:e.pkce_required_for_password_resets,pkceRequiredForOAuth:e.pkce_required_for_oauth,pkceRequiredForSso:e.pkce_required_for_sso,slugPattern:e.slug_pattern,createOrganizationEnabled:e.create_organization_enabled,passwordConfig:t,runDFPProtectedAuth:e.dfp_protected_auth_enabled??!1,dfpProtectedAuthMode:e.dfp_protected_auth_mode,rbacPolicy:e.rbac_policy??null,siweRequiredFor
2CryptoWallets:e.siwe_required_for_crypto_wallets,vertical:e.vertical}}getSync(){let e=this._dataLayer.getItem(o);if(null===e)return c();try{return JSON.parse(e)}catch{return c()}}getAsync(){return this._bootstrapDataPromise}}var u=e.i(390150);class h{bootstrapPromise;state;constructor(e){this.bootstrapPromise=e,this.state=e.then(async e=>{let t;return e.captchaSettings.enabled?{configured:!0,captchaClient:await (t=e.captchaSettings.siteKey,(0,u.loadESModule)(`https://www.google.com/recaptcha/enterprise.js?render=${t}`,()=>window.grecaptcha.enterprise)),siteKey:e.captchaSettings.siteKey}:{configured:!1}})}executeRecaptcha=async()=>{let{captchaClient:e,configured:t,siteKey:i}=await this.state;if(t)return await new Promise(t=>e.ready(t)),e.execute(i,{action:"LOGIN"})}}var d=e.i(299159),p=e.i(515047);class m{static inflate(e,t){let i=new e(t);return Object.assign(i,t),Object.setPrototypeOf(i,e.prototype),i}static unmarshall(e){if("name"in e)switch(e.name){case"SDKAPIUnreachableError":return m.inflate(p.SDKAPIUnreachableError,e);case"StytchSDKSchemaError":return m.inflate(p.StytchSDKSchemaError,e);case"StytchAPIUnreachableError":return m.inflate(p.StytchAPIUnreachableError,e);case"StytchAPISchemaError":return m.inflate(p.StytchAPISchemaError,e);case"StytchSDKAPIError":return m.inflate(p.StytchSDKAPIError,e);case"StytchAPIError":return m.inflate(p.StytchAPIError,e);case"TypeError":return m.inflate(TypeError,e);case"SyntaxError":return m.inflate(SyntaxError,e);case"ReferenceError":return m.inflate(ReferenceError,e);case"RangeError":return m.inflate(RangeError,e);case"EvalError":return m.inflate(EvalError,e);case"URIError":return m.inflate(URIError,e)}return m.inflate(Error,e)}}class _{iframeURL;frame;constructor(e){this.iframeURL=e,this.createIframe()}createIframe(){let e=document.querySelector(`[src~="${this.iframeURL}"]`);if(e?n.logger.warn(d.MULTIPLE_STYTCH_CLIENTS_DETECTED_WARNING):((e=document.createElement("iframe")).src=this.iframeURL,e.style.position="absolute",e.style.width="0",e.style.height="0",e.style.border="0",e.role="none",document.body.appendChild(e)),"true"===e.dataset.loaded){this.frame=Promise.resolve(e);return}this.frame=new Promise(t=>{e.addEventListener("load",()=>{e.dataset.loaded="true",t(e)},{once:!0})})}async call(e,t){let i=await this.frame,r=new MessageChannel;return new Promise((s,a)=>{r.port1.onmessage=e=>{let t=e.data;r.port1.close(),t.success?s(t.payload):a(m.unmarshall(t.error))},i.contentWindow?.postMessage({method:e,args:t},this.iframeURL,[r.port2])})}}class y{iframeURL;_frameClient;constructor(e){this.iframeURL=e}get frameClient(){return this._frameClient=this._frameClient??new _(this.iframeURL),this._frameClient}call(e,t){return this.frameClient.call(e,[t])}oneTapStart=e=>this.call("oneTapStart",e);oneTapSubmit=e=>this.call("oneTapSubmit",e);parsedPhoneNumber=e=>this.call("parsedPhoneNumber",e);getExamplePhoneNumber=e=>this.call("getExamplePhoneNumber",e)}for(var f=new Uint8Array(16),g=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,w=[],b=0;b<256;++b)w.push((b+256).toString(16).substr(1));function S(e,t,r){var s=(e=e||{}).random||(e.rng||function(){if(!i&&!(i="u">typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"u">typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(f)})();return s[6]=15&s[6]|64,s[8]=63&s[8]|128,function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=(w[e[t+0]]+w[e[t+1]]+w[e[t+2]]+w[e[t+3]]+"-"+w[e[t+4]]+w[e[t+5]]+"-"+w[e[t+6]]+w[e[t+7]]+"-"+w[e[t+8]]+w[e[t+9]]+"-"+w[e[t+10]]+w[e[t+11]]+w[e[t+12]]+w[e[t+13]]+w[e[t+14]]+w[e[t+15]]).toLowerCase();if(!("string"==typeof i&&g.test(i)))throw TypeError("Stringified UUID is invalid");return i}(s)}let k=e=>{let{__user:t,...i}=e;return i};var C=e.i(464938);let v=class{_networkClient;_subscriptionService;_pkceManager;_dynamicConfig;_config;authenticate;constructor(e,t,i,r,s){this._networkClient=e,this._subscriptionService=t,this._pkceManager=i,this._dynamicConfig=r,this._config=s,this.authenticate=this._subscriptionService.withUpdateSession(async(e,t)=>{let i=await this._pkceManager.getPKPair();i||n.logger.warn("No code verifier found in local storage for OAuth flow.\nConsider using stytch.oauth.$provider.start() to add PKCE to your OAuth flows for added security.\nSee https://stytch.com/docs/oauth#guides_pkce for more information.");let r=await this._networkClient.fetchSDK({url:"/oauth/authenticate",method:"POST",body:{token:e,code_verifier:i?.code_verifier,...t}});return this._pkceManager.clearPKPair(),k(r)})}google={start:this.startOAuthFlow(C.OAuthProviders.Google)};apple={start:this.startOAuthFlow(C.OAuthProviders.Apple)};microsoft={start:this.startOAuthFlow(C.OAuthProviders.Microsoft)};github={start:this.startOAuthFlow(C.OAuthProviders.Github)};gitlab={start:this.startOAuthFlow(C.OAuthProviders.GitLab)};facebook={start:this.startOAuthFlow(C.OAuthProviders.Facebook)};discord={start:this.startOAuthFlow(C.OAuthProviders.Discord)};salesforce={start:this.startOAuthFlow(C.OAuthProviders.Salesforce)};slack={start:this.startOAuthFlow(C.OAuthProviders.Slack)};amazon={start:this.startOAuthFlow(C.OAuthProviders.Amazon)};
2bitbucket={start:this.startOAuthFlow(C.OAuthProviders.Bitbucket)};linkedin={start:this.startOAuthFlow(C.OAuthProviders.LinkedIn)};coinbase={start:this.startOAuthFlow(C.OAuthProviders.Coinbase)};twitch={start:this.startOAuthFlow(C.OAuthProviders.Twitch)};twitter={start:this.startOAuthFlow(C.OAuthProviders.Twitter)};tiktok={start:this.startOAuthFlow(C.OAuthProviders.TikTok)};snapchat={start:this.startOAuthFlow(C.OAuthProviders.Snapchat)};figma={start:this.startOAuthFlow(C.OAuthProviders.Figma)};yahoo={start:this.startOAuthFlow(C.OAuthProviders.Yahoo)};async attach(e){return await this._networkClient.fetchSDK({url:"/oauth/attach",method:"POST",body:{provider:e}})}async getBaseApiUrl(){let{cnameDomain:e}=await this._dynamicConfig;return e?`https://${e}`:this._config.publicToken.includes("public-token-test")?this._config.testAPIURL:this._config.liveAPIURL}startOAuthFlow(e){return async({login_redirect_url:t,signup_redirect_url:i,custom_scopes:r,provider_params:s,oauth_attach_token:a}={})=>{let{cnameDomain:n,pkceRequiredForOAuth:o}=await this._dynamicConfig,c=await this.getBaseApiUrl();this._networkClient.logEvent({name:"start_oauth_flow",details:{provider_type:e,custom_scopes:r,cname_domain:n,pkce:o,provider_params:s}});let l=new URL(`${c}/v1/public/oauth/${e}/start`);if(l.searchParams.set("public_token",this._config.publicToken),o){let e=await this._pkceManager.startPKCETransaction();l.searchParams.set("code_challenge",e.code_challenge)}else this._pkceManager.clearPKPair();if(r&&l.searchParams.set("custom_scopes",r.join(" ")),s)for(let e in s)l.searchParams.set("provider_"+e,s[e]);t&&l.searchParams.set("login_redirect_url",t),i&&l.searchParams.set("signup_redirect_url",i),a&&l.searchParams.set("oauth_attach_token",a),this.navigate(l)}}navigate(e){window.location.href=e.toString()}};class P extends v{_oneTap;constructor(e,t,i,r,s,a){super(e,t,i,r,s),this._oneTap=a}startOneTap=async e=>{let t=await this._oneTap.createOneTapClient();if(!t.success)throw Error(`One Tap could not load: ${t.reason}`);let{client:i}=t,r=this._oneTap.createOnSuccessHandler({signupRedirectUrl:e.signup_redirect_url,loginRedirectUrl:e.login_redirect_url,onSuccess:this._oneTap.redirectOnSuccess});return i.render({style:{position:C.OneTapPositions.floating},onOneTapCancelled:e.onOneTapCancelled,callback:r,cancelOnTapOutside:e.cancel_on_tap_outside})};googleOneTap={start:this.startOneTap}}class A{maxBatchSize;logEventURL;batch;constructor(e){this.maxBatchSize=e.maxBatchSize,this.logEventURL=e.logEventURL,setInterval(this.flush.bind(this),e.intervalDurationMs),this.batch=[]}logEvent(e,t){this.batch.push({telemetry:e,event:t}),this.batch.length>=this.maxBatchSize&&this.flush()}async flush(){if(!this.batch.length)return;let e=this.batch;this.batch=[];try{await fetch(this.logEventURL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}catch{}}}var T=((t={}).RequiredCaptcha="CAPTCHA required",t);class D extends Error{type;constructor(e){super(e),this.type=e}}async function O({method:e,finalURL:t,basicAuthHeader:i,xSDKClientHeader:r,xSDKParentHostHeader:s,body:a,retryCallback:n}){let o={method:e,finalURL:t,basicAuthHeader:i,xSDKClientHeader:r,xSDKParentHostHeader:s,body:a};try{return await E(o)}catch(e){if(e instanceof D)return o=await n(e,o),await E(o);throw e}}async function E({method:e,finalURL:t,basicAuthHeader:i,xSDKClientHeader:r,xSDKParentHostHeader:s,body:a}){let n,o,c={Authorization:i,"Content-Type":"application/json","X-SDK-Client":r};s&&(c["X-SDK-Parent-Host"]=s);let l={method:e,headers:c,body:a&&JSON.stringify(a),credentials:"include"};try{n=await fetch(t,l)}catch(e){if("Failed to fetch"===e.message)throw new p.StytchAPIUnreachableError("Unable to contact our servers.");throw e}if(n.status<=299)try{return(await n.json()).data}catch{throw new p.StytchAPIUnreachableError("Invalid JSON response from our servers.")}if(200!==n.status&&n.headers.get("content-type")?.includes("application/json")){let e;try{e=await n.json()}catch{throw new p.StytchAPIUnreachableError("Invalid or no response from server")}if("body"in e||"params"in e||"query"in e)throw new p.StytchAPISchemaError(e);throw new p.StytchAPIError(e)}try{o=await n.text()}catch{throw new p.StytchAPIUnreachableError("Invalid response from our servers.")}if(o.includes("Captcha required"))throw new D("CAPTCHA required");throw new p.StytchAPIUnreachableError("Invalid response from our servers.")}async function I({method:e,finalURL:t,basicAuthHeader:i,xSDKClientHeader:r,xSDKParentHostHeader:s,body:a}){let n={...a||{},__Authorization:i,"__X-SDK-Client":r};s&&(n["__X-SDK-Parent-Host"]=s);let o=Object.entries(n).map(([e,t])=>{let i=document.createElement("input");return i.type="hidden",i.name=e,i.value=t,i}),c=document.createElement("form");c.method=e,c.action=t,c.append(...o),document.body.appendChild(c),c.submit()}class R{_publicToken;_subscriptionDataLayer;additionalTelemetryDataFn;eventLogger;baseURL;constructor(e,t,i,r,s){this._publicToken=e,this._subscriptionDataLayer=t,this.additionalTelemetryDataFn=s,this.baseURL=i,(e=>e.includes("public-token-test"))(e)&&(this.baseURL=r),this.eventLogger=new A({maxBatchSize:15,intervalDurationMs:800,logEventURL:this.buildSDKUrl("/events")})}updateSessionToken=()=>null;logEvent({name:e,details:t,error:i={}}){this.eventLogger.logEvent(this.createTelemetryBlob(),{public_token:this._publicToken,event_name:e,details:t,error_code:i.error_code,error_description:i.error_description,http_status_code:i.http_status_code})}createTelemetryBlob(){return{event_id:`event-id-${S()}`,app_session_id:`app-session-id-${S()}`,persistent_id:`persistent-id-${S()}`,client_sent_at:new Date().toISOString(),timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,...this.additionalTelemetryDataFn(),app:{identifier:window.location.hostname},sdk:{identifier:"Stytch.js Javascript SDK",version:"@stytch/[email protected]"}}}async fetchSDK({url:e,body:t,method:i}){let r=this._subscriptionDataLayer.readSessionCookie().session_token,s="Basic "+window.btoa(this._publicToken+":"+(r||this._publicToken)),a=window.btoa(JSON.stringify(this.createTelemetryBlob())),n=window.location.origin;return E({basicAuthHeader:s,body:t,finalURL:this.buildSDKUrl(e),method:i,xSDKClientHeader:a,xSDKParentHostHeader:n})}async submitFormSDK({url:e,body:t,method:i}){let r=this._subscriptionDataLayer.readSessionCookie().session_token,s="Basic "+window.btoa(this._publicToken+":"+(r||this._publicToken)),a=window.btoa(JSON.stringify(this.createTelemetryBlob())),n=window.location.origin;return I({basicAuthHeader:s,body:t,finalURL:this.buildSDKUrl(e),method:i,xSDKClientHeader:a,xSDKParentHostHeader:n})}async retriableFetchSDK({url:e,body:t,method:i,retryCallback:r}){let s=this._subscriptionDataLayer.readSessionCookie().session_token,a="Basic "+window.btoa(this._publicToken+":"+(s||this._publicToken)),n=window.btoa(JSON.stringify(this.createTelemetryBlob())),o=window.location.origin;return O({basicAuthHeader:a,body:t,finalURL:this.buildSDKUrl(e),method:i,xSDKClientHeader:n,xSDKParentHostHeader:o,retryCallback:r})}buildSDKUrl(e){return`${this.baseURL}
2/sdk/v1${e}`}}var F=e.i(29404);function U(e){let t=e.toString(16);return 1===t.length&&(t="0"+t),t}class L{_dataLayer;namespace;constructor(e,t){this._dataLayer=e,this.namespace=t}key(){return`PKCE_VERIFIER:${this.namespace}`}async startPKCETransaction(){let e=await L.createProofkeyPair();return this._dataLayer.setItem(this.key(),JSON.stringify(e)),e}getPKPair(){let e=this._dataLayer.getItem(this.key());if(null!==e)try{return JSON.parse(e)}catch{n.logger.warn("Found malformed Proof Key pair in localstorage.");return}}clearPKPair(){return this._dataLayer.removeItem(this.key())}static async createProofkeyPair(){var e;let t=new Uint32Array(16);window.crypto.getRandomValues(t);let i=Array.from(t).map(U).join("");return{code_challenge:(e=await window.crypto.subtle.digest("SHA-256",new TextEncoder().encode(i)),btoa(String.fromCharCode.call(null,...new Uint8Array(e))).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")),code_verifier:i}}}function K(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var r in i)"__proto__"!==r&&(e[r]=i[r])}return e}var M=function e(t,i){function r(e,r,s){if("u">typeof document){"number"==typeof(s=K({},i,s)).expires&&(s.expires=new Date(Date.now()+864e5*s.expires)),s.expires&&(s.expires=s.expires.toUTCString()),e=encodeURIComponent(e).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var n in s)s[n]&&(a+="; "+n,!0!==s[n]&&(a+="="+s[n].split(";")[0]));return document.cookie=e+"="+t.write(r,e)+a}}return Object.create({set:r,get:function(e){if("u">typeof document&&(!arguments.length||e)){for(var i=document.cookie?document.cookie.split("; "):[],r={},s=0;s<i.length;s++){var a=i[s].split("="),n=a.slice(1).join("=");try{var o=decodeURIComponent(a[0]);if(o in r||(r[o]=t.read(n,o)),e===o)break}catch(e){}}return e?r[e]:r}},remove:function(e,t){r(e,"",K({},t,{expires:-1}))},withAttributes:function(t){return e(this.converter,K({},this.attributes,t))},withConverter:function(t){return e(K({},this.converter,t),this.attributes)}},{attributes:{value:Object.freeze(i)},converter:{value:Object.freeze(t)}})}({read:function(e){return'"'===e[0]&&(e=e.slice(1,-1)),e.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(e){return encodeURIComponent(e).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}},{path:"/"}),q=e.i(233027),x=e.i(566337),N=e.i(658915);let B="seen_domains";class j{publicToken;state;_opaqueTokenCookieName=null;_jwtCookieName=null;_cookiePath=null;_domain=null;_cookieAvailableToSubdomains=!1;_istCookieName=null;subscriptions;_localStorage;browserSessionStorage;constructor(e,t){let i;this.publicToken=e,this.state=null,this.subscriptions={},this._localStorage=(0,x.getKeyBoundStorage)(x.safeLocalStorage,e),this.browserSessionStorage=(0,x.getKeyBoundStorage)(x.safeSessionStorage,e),t?.cookieOptions&&(this._opaqueTokenCookieName=t.cookieOptions.opaqueTokenCookieName||null,this._jwtCookieName=t.cookieOptions.jwtCookieName||null,this._cookiePath=t.cookieOptions.path||null,this._domain=t.cookieOptions.domain||null,this._cookieAvailableToSubdomains=t.cookieOptions.availableToSubdomains||!1,this._istCookieName=t.cookieOptions.istCookieName||null);const r=this._localStorage.getItem("");if(!r)return;try{i=JSON.parse(r)}catch{this.syncToLocalStorage();return}this.state=i}get opaqueTokenCookieName(){return this._opaqueTokenCookieName??"stytch_session"}get jwtCookieName(){return this._jwtCookieName??"stytch_session_jwt"}get istCookieName(){return this._istCookieName??"stytch_intermediate_session_token"}readSessionCookie(){return{session_token:M.get(this.opaqueTokenCookieName),session_jwt:M.get(this.jwtCookieName)}}readIntermediateSessionTokenCookie(){return M.get(this.istCookieName)}writeSessionCookie(e){let{state:t,session_token:i,session_jwt:r}=e,s=j.generateCookieOpts({expiresAt:t?.session?.expires_at??"",availableToSubdomains:this._cookieAvailableToSubdomains,path:this._cookiePath,domain:this._domain});s.domain&&this.addSeenDomain(s.domain),M.set(this.opaqueTokenCookieName,i,s),M.set(this.jwtCookieName,r,s);let a=j.generateCookieOpts({expiresAt:t?.session?.expires_at??"",availableToSubdomains:!this._cookieAvailableToSubdomains,path:this._cookiePath,domain:this._domain});a.domain&&this.addSeenDomain(a.domain),(0,q.hasMultipleCookies)(this.jwtCookieName)&&M.remove(this.jwtCookieName,a),(0,q.hasMultipleCookies)(this.opaqueTokenCookieName)&&M.remove(this.opaqueTokenCookieName,a),(0,q.hasMultipleCookies)(this.jwtCookieName)&&n.logger.warn("Could not remove extraneous JWT cookie. This might happen if the cookie has been set using multiple `path` settings, and may produce unwanted behavior."),(0,q.hasMultipleCookies)(this.opaqueTokenCookieName)&&n.logger.warn("Could not remove extraneous opaque token cookie.")}writeIntermediateSessionTokenCookie(e){let t=new Date(Date.now()+6e5),i=j.generateCookieOpts({expiresAt:t.toString(),availableToSubdomains:this._cookieAvailableToSubdomains,path:this._cookiePath,domain:this._domain});M.set(this.istCookieName,e,i)}removeSessionCookie(){this.removeCookies([this.opaqueTokenCookieName,this.jwtCookieName])}removeISTCookie(){this.removeCookies([this.istCookieName])}
vendor: 5,349 bytes, lines 2-3
2removeCookies(e){let t=this.getSeenDomains(),i=[...new Set([this._domain,null,...t])];[!0,!1].forEach(t=>{[this._cookiePath,null].forEach(r=>{i.forEach(i=>{let s=j.generateCookieOpts({expiresAt:new Date(0).toString(),availableToSubdomains:t,path:r,domain:i});e.forEach(e=>{M.remove(e,s)})})})})}syncToLocalStorage(){this._localStorage.setItem("",JSON.stringify(this.state))}getItem(e){return this._localStorage.getItem(e)}setItem(e,t){this._localStorage.setItem(e,t)}removeItem(e){this._localStorage.removeItem(e)}getSeenDomains(){let e=this.getItem(B);if(!e)return[];try{let t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}addSeenDomain(e){if(!e)return;let t=this.getSeenDomains();t.includes(e)||(t.push(e),this.setItem(B,JSON.stringify(t)))}static generateCookieOpts({path:e,domain:t,availableToSubdomains:i,expiresAt:r}){let s={expires:new Date(r),sameSite:"lax"};return e&&(s.path=e),(0,q.isLocalhost)()?s.secure=!1:(i&&(s.domain=t||window.location.host),s.secure=!0),s}}class Q extends j{}let $=Symbol.for("__stytch_DataLayer");Symbol.for("__stytch_b2b_DataLayer");let W=(e,t)=>{Object.values(e).forEach(e=>e(t))},z=(0,N.createDeepEqual)({KEYS_TO_EXCLUDE:["last_accessed_at"]});class J{_publicToken;_datalayer;fromCache=!0;constructor(e,t,{usingCustomApiEndpoint:i}){if(this._publicToken=e,this._datalayer=t,window.addEventListener("storage",this._listen),!i){const{session_token:e}=this._datalayer.readSessionCookie();if(!e)return void this.destroySession()}}_listen=e=>{if(e.key!==(0,x.getPersistentStorageKey)(this._publicToken,""))return;let t=null===e.newValue||"null"===e.newValue?null:JSON.parse(e.newValue);this.updateState(t,!0)};getTokens(){let{session_token:e,session_jwt:t}=this._datalayer.readSessionCookie();return"string"!=typeof e||"string"!=typeof t?null:{session_token:e,session_jwt:t}}getIntermediateSessionToken(){return this._datalayer.readIntermediateSessionTokenCookie()||null}destroyState(){this.updateStateAndTokens({state:null,session_token:null,session_jwt:null,intermediate_session_token:null})}destroySession(){this._datalayer.removeSessionCookie(),this.updateState(null)}_updateStateAndTokensInternal(e,t){let i=this._datalayer.state,r=null===e.state?null:{...this._datalayer.state,...e.state};this._datalayer.state=r;let s=this.getFromCache();if(this.setCacheRefreshed(),s||!z(i,r)){let e;e=null==r||t.fromCache?r:{...r,sessionDurationMinutes:t.sessionDurationMinutes},W(this._datalayer.subscriptions,e)}}updateStateAndTokens(e,t={fromCache:!1}){e.state?("string"==typeof e.session_token?this._datalayer.writeSessionCookie(e):this._datalayer.removeSessionCookie(),this._datalayer.removeISTCookie()):e.intermediate_session_token?("string"==typeof e.intermediate_session_token?this._datalayer.writeIntermediateSessionTokenCookie(e.intermediate_session_token):this._datalayer.removeISTCookie(),this._datalayer.removeSessionCookie()):(this._datalayer.removeSessionCookie(),this._datalayer.removeISTCookie()),this._updateStateAndTokensInternal(e,t),this._datalayer.syncToLocalStorage()}updateState(e,t=!1){let i=this._datalayer.state,r=null===e?null:{...this._datalayer.state,...e};this._datalayer.state=r;let s=this.getFromCache();this.setCacheRefreshed();let a=!z(i,r);(s||a)&&(W(this._datalayer.subscriptions,r),a&&!t&&this._datalayer.syncToLocalStorage())}updateTokens(e){let{session_token:t,session_jwt:i}=e,r={...this._datalayer.readSessionCookie(),session_token:t,session_jwt:i};"string"==typeof t||"string"==typeof i?(this._datalayer.writeSessionCookie(r),this._datalayer.removeISTCookie()):this._datalayer.removeSessionCookie()}subscribeToState(e){var t;let i;return t=this._datalayer.subscriptions,t[i=Math.random().toString(36).slice(-10)]=e,()=>delete t[i]}getState(){return this._datalayer.state}destroy(){window.removeEventListener("storage",this._listen)}syncFromDeviceStorage(){return null}getFromCache(){return this.fromCache}setCacheRefreshed(){this.fromCache=!1}}class H extends J{updateUser=e=>this.updateState({user:e});getUser=()=>this.getState()?.user??null;getSession=()=>this.getState()?.session??null;updateSession=(e,t)=>{let{session:i,user:r,session_jwt:s,session_token:a}=e;a&&s?this.updateStateAndTokens({state:{session:i,user:r},session_jwt:s,session_token:a,intermediate_session_token:null},{fromCache:!1,sessionDurationMinutes:t?.sessionDurationMinutes}):this.updateStateAndTokens({state:{session:i,user:r},session_token:!0,session_jwt:!0,intermediate_session_token:null},{fromCache:!1,sessionDurationMinutes:t?.sessionDurationMinutes})};withUpdateSession=e=>async(...t)=>{let i=await e(...t);if(null!=i){let e=t.find(e=>null!=e&&"string"!=typeof e);this.updateSession(i,{sessionDurationMinutes:e?.session_duration_minutes})}return i}}let V=e=>{try{let t=new URL(e);return`https://${t.hostname}`}catch{}try{let t=new URL(`https://${e}`);return`https://${t.hostname}`}catch{}};var G=e.i(702747);let Y=` 3You can find your public token at https://stytch.com/dashboard/api-keys.`;class X{_subscriptionService;emptyState;constructor(e,t){this._subscriptionService=e,this.emptyState=t}onStateChange=e=>this._subscriptionService.subscribeToState(t=>{e(t??this.emptyState)})}class Z{bootstrapPromise;state;constructor(e,t,i,r,s=()=>Promise.resolve(void 0)){this.bootstrapPromise=r,this.state=r.then(async r=>r.runDFPProtectedAuth?(await (0,u.loadESModule)(`${i}/telemetry.js`,()=>
vendor: 5,097 bytes, line 3
3window.GetTelemetryID),{publicToken:e,dfpBackendURL:t,enabled:!0,mode:r.dfpProtectedAuthMode||"OBSERVATION",loaded:!0,executeRecaptcha:s}):{publicToken:e,dfpBackendURL:t,enabled:!1,loaded:!1,executeRecaptcha:s})}isEnabled=async()=>this.state.then(e=>e.enabled);getTelemetryID=async()=>{let{publicToken:e,enabled:t,dfpBackendURL:i}=await this.state;if(t)return await window.GetTelemetryID(e,`${i}/submit`)};getDFPTelemetryIDAndCaptcha=async()=>{let e,t,{enabled:i,executeRecaptcha:r,mode:s}=await this.state;return i||(t=await r()),"DECISIONING"===s?e=await this.getTelemetryID():"OBSERVATION"===s&&(e=await this.getTelemetryID(),t=await r()),{dfp_telemetry_id:e,captcha_token:t}};retryWithCaptchaAndDFP=async(e,t)=>{let{enabled:i,executeRecaptcha:r}=await this.state;if(e.type===T.RequiredCaptcha&&i)return t.body&&(t.body.dfp_telemetry_id=await this.getTelemetryID(),t.body.captcha_token=await r()),t;throw Error("Unable to query captcha and/or dfp telemetry ID")}}class ee{_networkClient;dfpProtectedAuth;constructor(e,t){this._networkClient=e,this.dfpProtectedAuth=t}searchUser(e){return this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha().then(({dfp_telemetry_id:t,captcha_token:i})=>this._networkClient.fetchSDK({url:"/users/search",method:"POST",body:{email:e,dfp_telemetry_id:t,captcha_token:i}}))}searchMember(e,t){return this._networkClient.fetchSDK({url:"/b2b/organizations/members/search",method:"POST",body:{email_address:e,organization_id:t}})}}class et{_networkClient;_subscriptionService;constructor(e,t){this._networkClient=e,this._subscriptionService=t}get=async()=>{let e=(({request_id:e,status_code:t,...i})=>i)(await this._networkClient.fetchSDK({url:"/users/me",method:"GET"}));return this._subscriptionService.updateUser(e),e};getSync=()=>this._subscriptionService.getUser();getInfo=()=>({user:this.getSync(),fromCache:this._subscriptionService.getFromCache()});update=async e=>{let t=await this._networkClient.fetchSDK({url:"/users/me",body:e,method:"PUT"}),i=(({request_id:e,status_code:t,...i})=>i)(t.__user);return this._subscriptionService.updateUser(i),k(t)};deleteEmail=async e=>{let t=await this._networkClient.fetchSDK({url:`/users/emails/${e}`,method:"DELETE"}),i=(({request_id:e,status_code:t,...i})=>i)(t.__user);return this._subscriptionService.updateUser(i),k(t)};deletePhoneNumber=async e=>{let t=await this._networkClient.fetchSDK({url:`/users/phone_numbers/${e}`,method:"DELETE"}),i=(({request_id:e,status_code:t,...i})=>i)(t.__user);return this._subscriptionService.updateUser(i),k(t)};deleteTOTP=async e=>{let t=await this._networkClient.fetchSDK({url:`/users/totps/${e}`,method:"DELETE"}),i=(({request_id:e,status_code:t,...i})=>i)(t.__user);return this._subscriptionService.updateUser(i),k(t)};deleteCryptoWallet=async e=>{let t=await this._networkClient.fetchSDK({url:`/users/crypto_wallets/${e}`,method:"DELETE"}),i=(({request_id:e,status_code:t,...i})=>i)(t.__user);return this._subscriptionService.updateUser(i),k(t)};deleteOAuthRegistration=async e=>{let t=await this._networkClient.fetchSDK({url:`/users/oauth/${e}`,method:"DELETE"}),i=(({request_id:e,status_code:t,...i})=>i)(t.__user);return this._subscriptionService.updateUser(i),k(t)};deleteWebauthnRegistration=async e=>{let t=await this._networkClient.fetchSDK({url:`/users/webauthn_registrations/${e}`,method:"DELETE"}),i=(({request_id:e,status_code:t,...i})=>i)(t.__user);return this._subscriptionService.updateUser(i),k(t)};deleteBiometricRegistration=async e=>{let t=await this._networkClient.fetchSDK({url:`/users/biometric_registrations/${e}`,method:"DELETE"}),i=(({request_id:e,status_code:t,...i})=>i)(t.__user);return this._subscriptionService.updateUser(i),k(t)};onChange=e=>{let t=this._subscriptionService.getUser();return this._subscriptionService.subscribeToState(i=>{i?.user!==t&&e(t=i?.user??null)})};getConnectedApps=async()=>await this._networkClient.fetchSDK({url:"/users/connected_apps",method:"GET"});revokedConnectedApp=async e=>await this._networkClient.fetchSDK({url:`/users/connected_apps/${e}/revoke`,method:"POST"})}let ei=Promise.resolve({siweRequiredForCryptoWallets:!1});class er{_networkClient;_apiNetworkClient;_subscriptionService;executeRecaptcha;dfpProtectedAuth;_config;authenticate;constructor(e,t,i,r=()=>Promise.resolve(void 0),s,a=ei){this._networkClient=e,this._apiNetworkClient=t,this._subscriptionService=i,this.executeRecaptcha=r,this.dfpProtectedAuth=s,this._config=a,this.authenticate=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();return k(await this._apiNetworkClient.retriableFetchSDK({url:"/crypto_wallets/authenticate",method:"POST",body:{session_duration_minutes:e.session_duration_minutes,crypto_wallet_address:e.crypto_wallet_address,crypto_wallet_type:e.crypto_wallet_type,signature:e.signature,captcha_token:i,dfp_telemetry_id:t},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP}))})}async authenticateStart(e){e.siwe_params;let t=!!this._subscriptionService.getSession(),i=await this.executeRecaptcha(),{siweRequiredFor
vendor: 10,905 bytes, line 3
3CryptoWallets:r}=await this._config,s={crypto_wallet_address:e.crypto_wallet_address,crypto_wallet_type:e.crypto_wallet_type};r&&"ethereum"==e.crypto_wallet_type&&(s.siwe_params={...e.siwe_params,uri:e.siwe_params?.uri||window.location.origin});let a={...s,captcha_token:i};return this._apiNetworkClient.fetchSDK({url:t?"/crypto_wallets/authenticate/start/secondary":"/crypto_wallets/authenticate/start/primary",method:"POST",body:a})}}class es{_networkClient;constructor(e){this._networkClient=e}oauthAuthorizeStart=async e=>this._networkClient.fetchSDK({url:"/idp/oauth/authorize/start",method:"POST",body:e});oauthAuthorizeSubmit=async e=>this._networkClient.fetchSDK({url:"/idp/oauth/authorize/submit",method:"POST",body:e});oauthLogoutStart=async e=>this._networkClient.fetchSDK({url:"/oauth/logout/start",method:"POST",body:e})}class ea{_networkClient;_subscriptionService;dfpProtectedAuth;authenticate;constructor(e,t,i){this._networkClient=e,this._subscriptionService=t,this.dfpProtectedAuth=i,this.authenticate=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();return this._networkClient.retriableFetchSDK({url:"/impersonation/authenticate",body:{...e,dfp_telemetry_id:t,captcha_token:i},method:"POST",retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})})}}let en=Promise.resolve({pkceRequiredForEmailMagicLinks:!1});class eo{_networkClient;_subscriptionService;_pkceManager;_passwordResetPKCEManager;_config;dfpProtectedAuth;email;authenticate;constructor(e,t,i,r,s=en,a){this._networkClient=e,this._subscriptionService=t,this._pkceManager=i,this._passwordResetPKCEManager=r,this._config=s,this.dfpProtectedAuth=a,this.email={loginOrCreate:async(e,t={})=>{let i,{pkceRequiredForEmailMagicLinks:r}=await this._config;r&&(i=await this.getCodeChallenge());let{dfp_telemetry_id:s,captcha_token:a}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha(),n={...t,email:e,code_challenge:i,captcha_token:a,dfp_telemetry_id:s};return this._networkClient.retriableFetchSDK({url:"/magic_links/email/login_or_create",body:n,method:"POST",retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})},send:async(e,t={})=>{let i,{pkceRequiredForEmailMagicLinks:r}=await this._config;r&&(i=await this.getCodeChallenge());let{dfp_telemetry_id:s,captcha_token:a}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha(),n={...t,email:e,code_challenge:i,captcha_token:a,dfp_telemetry_id:s},o=!!this._subscriptionService.getSession();return this._networkClient.retriableFetchSDK({url:o?"/magic_links/email/send/secondary":"/magic_links/email/send/primary",body:n,method:"POST",retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})}},this.authenticate=this._subscriptionService.withUpdateSession(async(e,t)=>{let i=await this._passwordResetPKCEManager.getPKPair(),r=null;if(i?.code_verifier)try{r=await this.handlePKCEForAuthenticate(this._passwordResetPKCEManager,{token:e,...t})}catch(e){if(e.message.includes("pkce"))console.log("Authenticate with passwords pkce namespace failed. Falling back to authenticate with magic_links namespace.");else throw e}return r||(r=await this.handlePKCEForAuthenticate(this._pkceManager,{token:e,...t})),k(r)})}async getCodeChallenge(){let e=await this._pkceManager.getPKPair();return e?e.code_challenge:(e=await this._pkceManager.startPKCETransaction()).code_challenge}async handlePKCEForAuthenticate(e,t){let i=await e.getPKPair(),r={code_verifier:i?.code_verifier,...t},s=await this._networkClient.fetchSDK({url:"/magic_links/authenticate",body:r,method:"POST"});return e.clearPKPair(),s}}class ec{_networkClient;_subscriptionService;executeRecaptcha;dfpProtectedAuth;authenticate;constructor(e,t,i=()=>Promise.resolve(void 0),r){this._networkClient=e,this._subscriptionService=t,this.executeRecaptcha=i,this.dfpProtectedAuth=r,this.authenticate=this._subscriptionService.withUpdateSession(async(e,t,i)=>{let{dfp_telemetry_id:r,captcha_token:s}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha(),a={token:e,method_id:t,dfp_telemetry_id:r,captcha_token:s,...i};return k(await this._networkClient.retriableFetchSDK({url:"/otps/authenticate",body:a,method:"POST",retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP}))})}sms={loginOrCreate:async(e,t)=>{let{dfp_telemetry_id:i,captcha_token:r}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha(),s={...t,phone_number:e,captcha_token:r,dfp_telemetry_id:i};return this._networkClient.retriableFetchSDK({url:"/otps/sms/login_or_create",body:s,method:"POST",retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})},send:async(e,t)=>{let{dfp_telemetry_id:i,captcha_token:r}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha(),s={...t,phone_number:e,captcha_token:r,dfp_telemetry_id:i},a=!!this._subscriptionService.getSession();return this._networkClient.retriableFetchSDK({url:a?"/otps/sms/send/secondary":"/otps/sms/send/primary",body:s,method:"POST",retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})}};whatsapp={loginOrCreate:async(e,t)=>{let{dfp_telemetry_id:i,captcha_token:r}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha(),s={...t,phone_number:e,dfp_telemetry_id:i,captcha_token:r};return this._networkClient.retriableFetchSDK({url:"/otps/whatsapp/login_or_create",body:s,method:"POST",retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})},send:async(e,t)=>{let{dfp_telemetry_id:i,captcha_token:r}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha(),s={...t,phone_number:e,captcha_token:r,dfp_telemetry_id:i},a=!!this._subscriptionService.getSession();return this._networkClient.retriableFetchSDK({url:a?"/otps/whatsapp/send/secondary":"/otps/whatsapp/send/primary",body:s,method:"POST",retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})}};email={loginOrCreate:async(e,t)=>{let{dfp_telemetry_id:i,captcha_token:r}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha(),s={...t,email:e,captcha_token:r,dfp_telemetry_id:i};return this._networkClient.retriableFetchSDK({url:"/otps/email/login_or_create",body:s,method:"POST",retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})},send:async(e,t)=>{let i=await this.executeRecaptcha(),r={...t,email:e,captcha_token:i},s=!!this._subscriptionService.getSession();return this._networkClient.fetchSDK({url:s?"/otps/email/send/secondary":"/otps/email/send/primary",body:r,method:"POST"})}}}let el=Promise.resolve({pkceRequiredForPasswordResets:!1});class eu{_networkClient;_subscriptionService;_pkceManager;_config;dfpProtectedAuth;create;authenticate;resetByEmail;resetByExistingPassword;resetBySession;constructor(e,t,i,r=el,s){this._networkClient=e,this._subscriptionService=t,this._pkceManager=i,this._config=r,this.dfpProtectedAuth=s,this.create=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();return k(await this._networkClient.retriableFetchSDK({url:"/passwords",method:"POST",body:{email:e.email,password:e.password,session_duration_minutes:e.session_duration_minutes,captcha_token:i,dfp_telemetry_id:t},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP}))}),this.authenticate=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();return k(await this._networkClient.retriableFetchSDK({url:"/passwords/authenticate",method:"POST",body:{email:e.email,password:e.password,session_duration_minutes:e.session_duration_minutes,captcha_token:i,dfp_telemetry_id:t},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP}))}),this.resetByEmail=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha(),r=await this._pkceManager.getPKPair(),s=r?.code_verifier,a=await this._networkClient.retriableFetchSDK({url:"/passwords/email/reset",method:"POST",body:{token:e.token,password:e.password,session_duration_minutes:e.session_duration_minutes,captcha_token:i,code_verifier:s,dfp_telemetry_id:t},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP});return this._pkceManager.clearPKPair(),k(a)}),this.resetByExistingPassword=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();return k(await this._networkClient.retriableFetchSDK({url:"/passwords/existing_password/reset",method:"POST",body:{email:e.email,existing_password:e.existing_password,new_password:e.new_password,session_duration_minutes:e.session_duration_minutes,dfp_telemetry_id:t,captcha_token:i},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP}))}),this.resetBySession=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();return this._networkClient.retriableFetchSDK({url:"/passwords/session/reset",method:"POST",body:{password:e.password,session_duration_minutes:e.session_duration_minutes,dfp_telemetry_id:t,captcha_token:i},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})})}async getCodeChallenge(){let{pkceRequiredForPasswordResets:e}=await this._config;if(!e)return;let t=await this._pkceManager.getPKPair();return t?t.code_challenge:(t=await this._pkceManager.startPKCETransaction()).code_challenge}async resetByEmailStart(e){let t=await this.getCodeChallenge(),{dfp_telemetry_id:i,captcha_token:r}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();return this._networkClient.retriableFetchSDK({url:"/passwords/email/reset/start",method:"POST",body:{email:e.email,login_redirect_url:e.login_redirect_url,reset_password_redirect_url:e.reset_password_redirect_url,reset_password_expiration_minutes:e.reset_password_expiration_minutes,reset_password_template_id:e.reset_password_template_id,locale:e.locale,code_challenge:t,captcha_token:r,dfp_telemetry_id:i},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP})}async strengthCheck(e){return this._networkClient.fetchSDK({url:"/passwords/strength_check",method:"POST",body:{email:e.email,password:e.password}})}}class eh{roles;resources;rolesByID;constructor(e,t){this.roles=e,this.resources=t,this.rolesByID={},e.forEach(e=>this.rolesByID[e.role_id]=e)}static fromJSON(e){return new eh(e.roles,e.resources)}mergeWithCustomRoles(e){return new eh([...this.roles,...e],this.resources)}callerIsAuthorized(e,t,i){return!!e.map(e=>this.rolesByID[e]).filter(e=>e).flatMap(e=>e.permissions).filter(e=>e.resource_id===t).find(e=>e.actions.includes(i)||e.actions.includes("*"))}allPermissionsForCaller(e){let t=Object.create(null);return this.resources.forEach(i=>{t[i.resource_id]={},i.actions.forEach(r=>{t[i.resource_id][r]=this.callerIsAuthorized(e,i.resource_id,r)})}),t}}class ed{_subscriptionService;cachedPolicy;
3policyPromise;constructor(e,t,i){this._subscriptionService=i,this.cachedPolicy=e.rbacPolicy?eh.fromJSON(e.rbacPolicy):null,this.policyPromise=t.then(e=>e.rbacPolicy?(this.cachedPolicy=eh.fromJSON(e.rbacPolicy),this.cachedPolicy):(n.logger.error("Unable to retrieve RBAC policy from servers. Assuming caller has no permissions."),new eh([],[])))}allPermissions(){return this.policyPromise.then(e=>e.allPermissionsForCaller(this.roleIds()))}isAuthorizedSync=(e,t)=>!!this.cachedPolicy?.callerIsAuthorized(this.roleIds(),e,t);isAuthorized=(e,t)=>this.policyPromise.then(i=>i.callerIsAuthorized(this.roleIds(),e,t));roleIds(){let e=this._subscriptionService.getUser();return e?e.roles??[]:[]}}class ep{_networkClient;_subscriptionService;authenticate;exchangeAccessToken;attest;constructor(e,t){this._networkClient=e,this._subscriptionService=t,this.authenticate=this._subscriptionService.withUpdateSession(this._authenticate),this.exchangeAccessToken=this._subscriptionService.withUpdateSession(async e=>k(await this._networkClient.fetchSDK({url:"/sessions/exchange_access_token",body:e,method:"POST"}))),this.attest=this._subscriptionService.withUpdateSession(async e=>this._networkClient.fetchSDK({url:"/sessions/attest",body:e,method:"POST"}))}getSync=()=>this._subscriptionService.getSession();getInfo=()=>({session:this.getSync(),fromCache:this._subscriptionService.getFromCache()});onChange=e=>{let t=this._subscriptionService.getSession();return this._subscriptionService.subscribeToState(i=>{i?.session!==t&&e(t=i?.session??null)})};revoke=async e=>{try{let e=await this._networkClient.fetchSDK({url:"/sessions/revoke",method:"POST"});return this._subscriptionService.destroyState(),e}catch(t){throw e?.forceClear?this._subscriptionService.destroyState():p.UNRECOVERABLE_ERROR_TYPES.includes(t.error_type)&&this._subscriptionService.destroyState(),t}};_authenticate=async e=>{let t=this._subscriptionService.getSession(),i=()=>t?.session_id!==this._subscriptionService.getSession()?.session_id;try{let t={session_duration_minutes:e?.session_duration_minutes},r=await this._networkClient.fetchSDK({url:"/sessions/authenticate",body:t,method:"POST"});if(i())return this._authenticate(e);return k(r)}catch(t){if(i())return this._authenticate(e);throw p.UNRECOVERABLE_ERROR_TYPES.includes(t.error_type)&&this._subscriptionService.destroySession(),t}};getTokens(){return this._subscriptionService.getTokens()}updateSession(e){this._subscriptionService.updateTokens(e)}}class em{_networkClient;_subscriptionService;dfpProtectedAuth;authenticate;recover;constructor(e,t,i){this._networkClient=e,this._subscriptionService=t,this.dfpProtectedAuth=i,this.authenticate=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();return k(await this._networkClient.retriableFetchSDK({url:"/totps/authenticate",method:"POST",body:{session_duration_minutes:e.session_duration_minutes,totp_code:e.totp_code,captcha_token:i,dfp_telemetry_id:t},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP}))}),this.recover=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();return k(await this._networkClient.retriableFetchSDK({url:"/totps/recover",method:"POST",body:{session_duration_minutes:e.session_duration_minutes,recovery_code:e.recovery_code,captcha_token:i,dfp_telemetry_id:t},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP}))})}async create(e){let t=await this._networkClient.fetchSDK({url:"/totps",method:"POST",body:{expiration_minutes:e.expiration_minutes}});return this._subscriptionService.updateUser(t.__user),k(t)}async recoveryCodes(){return this._networkClient.fetchSDK({url:"/totps/recovery_codes",method:"POST"})}}function e_(e){let t="==".slice(0,(4-e.length%4)%4),i=atob(e.replace(/-/g,"+").replace(/_/g,"/")+t),r=new ArrayBuffer(i.length),s=new Uint8Array(r);for(let e=0;e<i.length;e++)s[e]=i.charCodeAt(e);return r}function ey(e){let t=new Uint8Array(e),i="";for(let e of t)i+=String.fromCharCode(e);return btoa(i).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}var ef="copy",eg="convert";function ew(e,t,i){if(t===ef)return i;if(t===eg)return e(i);if(t instanceof Array)return i.map(i=>ew(e,t[0],i));if(t instanceof Object){let r={};for(let[s,a]of Object.entries(t)){if(a.derive){let e=a.derive(i);void 0!==e&&(i[s]=e)}if(!(s in i)){if(a.required)throw Error(`Missing key: ${s}`);continue}if(null==i[s]){r[s]=null;continue}
3r[s]=ew(e,a.schema,i[s])}return r}}function eb(e,t){return{required:!0,schema:e,derive:t}}function eS(e){return{required:!0,schema:e}}function ek(e){return{required:!1,schema:e}}var eC={type:eS(ef),id:eS(eg),transports:ek(ef)},ev={appid:ek(ef),appidExclude:ek(ef),credProps:ek(ef)},eP={appid:ek(ef),appidExclude:ek(ef),credProps:ek(ef)},eA={publicKey:eS({rp:eS(ef),user:eS({id:eS(eg),name:eS(ef),displayName:eS(ef)}),challenge:eS(eg),pubKeyCredParams:eS(ef),timeout:ek(ef),excludeCredentials:ek([eC]),authenticatorSelection:ek(ef),attestation:ek(ef),extensions:ek(ev)}),signal:ek(ef)},eT={type:eS(ef),id:eS(ef),rawId:eS(eg),authenticatorAttachment:ek(ef),response:eS({clientDataJSON:eS(eg),attestationObject:eS(eg),transports:eb(ef,e=>{var t;return(null==(t=e.getTransports)?void 0:t.call(e))||[]})}),clientExtensionResults:eb(eP,e=>e.getClientExtensionResults())},eD={mediation:ek(ef),publicKey:eS({challenge:eS(eg),timeout:ek(ef),rpId:ek(ef),allowCredentials:ek([eC]),userVerification:ek(ef),extensions:ek(ev)}),signal:ek(ef)},eO={type:eS(ef),id:eS(ef),rawId:eS(eg),authenticatorAttachment:ek(ef),response:eS({clientDataJSON:eS(eg),authenticatorData:eS(eg),signature:eS(eg),userHandle:eS(eg)}),clientExtensionResults:eb(eP,e=>e.getClientExtensionResults())};async function eE(e){let t=await navigator.credentials.create(ew(e_,eA,e));return ew(ey,eT,t)}async function eI(e){let t=await navigator.credentials.get(ew(e_,eD,e));return ew(ey,eO,t)}class eR{_networkClient;_subscriptionService;dfpProtectedAuth;register;authenticate;constructor(e,t,i){this._networkClient=e,this._subscriptionService=t,this.dfpProtectedAuth=i,this.register=this._subscriptionService.withUpdateSession(async e=>{let t=JSON.parse((await this._networkClient.fetchSDK({url:"/webauthn/register/start",method:"POST",body:{domain:e?.domain??window.location.hostname,authenticator_type:e?.authenticator_type??void 0,return_passkey_credential_options:e?.is_passkey,override_id:e?.override_id,override_name:e?.override_name,override_display_name:e?.override_display_name,user_agent:navigator.userAgent,use_base64_url_encoding:e?.use_base64_url_encoding}})).public_key_credential_creation_options),i=await eE({publicKey:t});return k(await this._networkClient.fetchSDK({url:"/webauthn/register",method:"POST",body:{public_key_credential:JSON.stringify(i),session_duration_minutes:e?.session_duration_minutes}}))}),this.authenticate=this._subscriptionService.withUpdateSession(async e=>{let{dfp_telemetry_id:t,captcha_token:i}=await this.dfpProtectedAuth.getDFPTelemetryIDAndCaptcha();if(e.conditional_mediation){if(!await this.browserSupportsAutofill())return n.logger.error("Browser does not support WebAuthn autofill"),null;if(!e.disable_input_check&&!this.checkEligibleInputs())return null}let r=!!this._subscriptionService.getSession(),s=(await this._networkClient.fetchSDK({url:r?"/webauthn/authenticate/start/secondary":"/webauthn/authenticate/start/primary",method:"POST",body:{domain:e.domain??window.location.hostname,return_passkey_credential_options:e?.is_passkey}})).public_key_credential_request_options,a=new AbortController,o={publicKey:JSON.parse(s),signal:e.signal??a.signal},c={...o,mediation:"conditional"},l=await eI(e.conditional_mediation?c:o);return k(await this._networkClient.retriableFetchSDK({url:"/webauthn/authenticate",method:"POST",body:{public_key_credential:JSON.stringify(l),session_duration_minutes:e.session_duration_minutes,dfp_telemetry_id:t,captcha_token:i},retryCallback:this.dfpProtectedAuth.retryWithCaptchaAndDFP}))})}async update(e){let t="/webauthn/update/"+e.webauthn_registration_id;return await this._networkClient.fetchSDK({url:t,method:"PUT",body:{name:e.name}})}async browserSupportsAutofill(){return await window.PublicKeyCredential?.isConditionalMediationAvailable?.()??!1}checkEligibleInputs=()=>!(document.querySelectorAll("input[autocomplete*='webauthn']").length<1)||(n.logger.error('No <input> with `"webauthn"` in its `autocomplete` attribute was detected'),!1)}class eF{hasWarned=!1;registry=new Map;register(e,t){let i=this.registry.get(e);i&&i!==t&&(this.hasWarned||(n.logger.warn(d.MULTIPLE_STYTCH_CLIENTS_DETECTED_WARNING),this.hasWarned=!0),i.cancelBackgroun
vendor: 1,275 bytes, line 3
3dRefresh()),this.registry.set(e,t)}unregister(e,t){let i=this.registry.get(e);i&&i===t&&this.registry.delete(e)}}class eU{_subscriptionService;_headlessSessionClient;_publicToken;_options;static REFRESH_INTERVAL_MS=18e4;timeout=null;lastAuthenticationSessionDuration;static registry=new eF;register(){eU.registry.register(this._publicToken,this)}unregister(){eU.registry.unregister(this._publicToken,this)}constructor(e,t,i,r){this._subscriptionService=e,this._headlessSessionClient=t,this._publicToken=i,this._options=r,this._subscriptionService.subscribeToState(this._onDataChange)}performBackgroundRefresh(){this._reauthenticateWithBackoff().then(()=>{this.scheduleBackgroundRefresh()}).catch(e=>{n.logger.warn("Session background refresh failed. Signalling to app that user is logged out.",{error:e}),this._subscriptionService.destroySession()})}scheduleBackgroundRefresh(){this.cancelBackgroundRefresh(),this.register(),this.timeout=setTimeout(()=>{this.performBackgroundRefresh()},eU.REFRESH_INTERVAL_MS)}cancelBackgroundRefresh(){null!==this.timeout&&(this.unregister(),clearTimeout(this.timeout),this.timeout=null)}_onDataChange=e=>{null!=e&&e.sessionDurationMinutes&&(this.lastAuthenticationSessionDuration=e.sessionDurationMinutes),e?.session?this.scheduleBackgroun
3dRefresh():this.cancelBackgroundRefresh()};_reauthenticateWithBackoff=async()=>{let e=0;for(;;)try{let e={session_duration_minutes:this._options.keepSessionAlive?this.lastAuthenticationSessionDuration:void 0};return await this._headlessSessionClient.authenticate(e)}catch(t){if(eU.isUnrecoverableError(t))return Promise.reject(t);e++,await new Promise(t=>setTimeout(t,eU.timeoutForAttempt(e)))}};static timeoutForAttempt(e){return e=Math.min(e,7),Math.floor(350*Math.random())-175+2e3*2**e}static isUnrecoverableError(e){return p.UNRECOVERABLE_ERROR_TYPES.includes(e.error_type)}}let eL=(0,e.i(859969).ssrSafeClientFactory)(class{_subscriptionService;_sessionManager;_networkClient;_dataLayer;_stateChangeClient;user;magicLinks;session;otps;oauth;cryptoWallets;totps;webauthn;passwords;impersonation;rbac;idp;onStateChange;parseAuthenticateUrl;authenticateByUrl;constructor(e,t){if("u"<typeof window)throw Error("`new StytchClient()` is not supported in server environments. If using @stytch/react or @stytch/nextjs, use `createStytchClient()` instead.");(e=>{"string"!=typeof e?n.logger.warn(`Public token is malformed. Expected a string, got ${typeof e}.${Y}`):""===e?n.logger.warn(`Public token is malformed. Expected "public-token-...", got an empty string.${Y}`):e.startsWith("public-token-")||n.logger.warn(`Public token is malformed. Expected "public-token-...", got ${e}.${Y}`)})(e);const i=e??"",r=((e,t={})=>{let{cookieOptions:i,keepSessionAlive:r}=t;return{cookieOptions:i,keepSessionAlive:r,endpoints:{testAPIURL:(e=>{let t=e?.customBaseUrl??e?.endpointOptions?.testApiDomain;if(t){let i=V(t);if(i)return i;{let i=e?.customBaseUrl?"customBaseUrl":"testApiDomain";n.logger.warn(`Unable to use custom API domain \`${t}\`. ${i} should be a valid domain.`)}}return e?.endpoints?.testAPIURL??d.TEST_API_URL})(t),liveAPIURL:(e=>{let t=e?.customBaseUrl??e?.endpointOptions?.apiDomain;if(t){let i=V(t);if(i)return i;{let i=e?.customBaseUrl?"customBaseUrl":"apiDomain";n.logger.warn(`Unable to use custom API domain \`${t}\`. ${i} should be a valid domain.`)}}return e?.endpoints?.liveAPIURL??d.LIVE_API_URL})(t),dfpBackendURL:(e=>{let t=e?.dfppaUrl??e?.endpointOptions?.dfppaDomain;if(t){let i=V(t);if(i)return i;{let i=e?.dfppaUrl?"dfppaUrl":"dfppaDomain";n.logger.warn(`Unable to use custom DFPPA domain \`${t}\`. ${i} should be a valid domain.`)}}return e?.endpoints?.dfpBackendURL??d.STYTCH_DFP_BACKEND_URL})(t),dfpCdnURL:(e=>{let t=e?.dfpCdnUrl??e?.endpointOptions?.dfpCdnDomain;if(t){let i=V(t);if(i)return i;{let i=e?.dfpCdnUrl?"dfpCdnUrl":"dfpCdnDomain";n.logger.warn(`Unable to use custom DFP CDN domain \`${t}\`. ${i} should be a valid domain.`)}}return d.STYTCH_DFP_CDN_URL})(t),clientsideServicesIframeURL:t?.endpoints?.clientsideServicesIframeURL??d.CLIENTSIDE_SERVICES_IFRAME_URL}}})(this.constructor.name,t),s=((e,t={})=>{let{customBaseUrl:i,endpointOptions:r}=t;return e.includes("public-token-test")?!!(i||r?.testApiDomain):!!(i||r?.apiDomain)})(i,t);this._dataLayer=((e,t)=>{let i,r=((i=window)[$]||(i[$]={}),i[$]);return r[e]||(r[e]=new Q(e,t)),r[e]})(i,r),this._subscriptionService=new H(i,this._dataLayer,{usingCustomApiEndpoint:s}),this._stateChangeClient=new X(this._subscriptionService,{}),this.onStateChange=(...e)=>this._stateChangeClient.onStateChange(...e);const a=()=>({stytch_user_id:this._dataLayer.state?.user?.user_id,stytch_session_id:this._dataLayer.state?.session?.session_id}),o=new L(this._dataLayer,"passwords"),c=new R(i,this._dataLayer,r.endpoints.liveAPIURL,r.endpoints.testAPIURL,a);this._networkClient=c;const u=new l(i,this._networkClient,this._dataLayer),p=new h(u.getAsync()),m=new Z(i,r.endpoints.dfpBacken
3dURL,r.endpoints.dfpCdnURL,u.getAsync(),p.executeRecaptcha),_=new y(r.endpoints.clientsideServicesIframeURL),f=new F.OneTapProvider(i,_),g=new ee(this._networkClient,m);this.user=new et(this._networkClient,this._subscriptionService),this.session=new ep(this._networkClient,this._subscriptionService),this.magicLinks=new eo(this._networkClient,this._subscriptionService,new L(this._dataLayer,"magic_links"),o,u.getAsync(),m),this.otps=new ec(this._networkClient,this._subscriptionService,p.executeRecaptcha,m),this.oauth=new P(this._networkClient,this._subscriptionService,new L(this._dataLayer,"oauth"),u.getAsync(),{publicToken:i,testAPIURL:r.endpoints.testAPIURL,liveAPIURL:r.endpoints.liveAPIURL},f),this.cryptoWallets=new er(this._networkClient,this._networkClient,this._subscriptionService,p.executeRecaptcha,m,u.getAsync()),this.totps=new em(this._networkClient,this._subscriptionService,m),this.webauthn=new eR(this._networkClient,this._subscriptionService,m),this.passwords=new eu(this._networkClient,this._subscriptionService,o,u.getAsync(),m),this.impersonation=new ea(this._networkClient,this._subscriptionService,m),this.rbac=new ed(u.getSync(),u.getAsync(),this._subscriptionService),this.idp=new es(this._networkClient),this._sessionManager=new eU(this._subscriptionService,this.session,i,{keepSessionAlive:r.keepSessionAlive}),(s||this._dataLayer.readSessionCookie().session_token)&&this._sessionManager.performBackgroundRefresh(),this._networkClient.logEvent({name:"sdk_instance_instantiated",details:{event_callback_registered:!1,error_callback_registered:!1,success_callback_registered:!1}}),u.getAsync().then(e=>{"B2B"===e.vertical&&n.logger.error("This application is using a Stytch client for Consumer projects, but the public token is for a Stytch B2B project. Use a B2B Stytch client instead, or verify that the public token is correct.")});const{authenticateByUrl:w,parseAuthenticateUrl:b}=(e=>{let t=Object.keys(e),i=(e=window.location.href)=>{let i=new URL(e),r=i.searchParams.get("stytch_token_type"),s=i.searchParams.get("token");return s&&r?t.includes(r)?{handled:!0,token:s,tokenType:r}:{handled:!1,token:s,tokenType:r}:null};return{authenticateByUrl:async({clearParams:t,...r},s=window.location.href)=>{let a,n,o,c=t??s===window.location.href,l=i(s);if(null==l)return null;if(!l.handled)return l;let{token:u,tokenType:h}=l,d=e[h];return c&&((n=(a=new URL(window.location.toString())).searchParams).delete("token"),n.delete("stytch_token_type"),o=a,window.history.replaceState(null,document.title,o)),{handled:!0,tokenType:h,data:await d(u,r)}},parseAuthenticateUrl:i}})({magic_links:(e,t)=>this.magicLinks.authenticate(e,t),oauth:(e,t)=>this.oauth.authenticate(e,t),impersonation:e=>this.impersonation.authenticate({impersonation_token:e})});this.authenticateByUrl=w,this.parseAuthenticateUrl=b,(0,G.writeB2CInternals)(this,{bootstrap:u,clientsideServices:_,captcha:p,oneTap:f,searchManager:g,publicToken:i,dataLayer:this._dataLayer,networkClient:this._networkClient})}})("public-token-live-e8a590ee-0e4c-4fd1-8aab-d1a4cc4da322",{cookieOptions:{opaqueTokenCookieName:"stytch_session",jwtCookieName:"stytch_session_jwt",path:"",availableToSubdomains:!1,domain:""}});e.s(["StytchProviderWrapper",0,e=>{let t,i=(0,s.c)(2),{children:n}=e;return i[0]!==n?(t=(0,r.jsx)(a.StytchProvider,{stytch:eL,children:n}),i[0]=n,i[1]=t):t=i[1],t}],591548)},622021,e=>{"use strict";var t=e.i(875825),i=e.i(146218),r=e.i(693185),s=null,a=!1,n=[],o=[],c=async e=>{if(globalThis.formbricks)return{ok:!0,data:void 0};let t=`${e}/js/formbricks.umd.cjs`,i=document.querySelector(`script[src="${t}"]`);i&&i.remove();let r=document.createElement("script");r.type="text/javascript",r.src=t,r.async=!0;let s=new Promise(e=>{let t=setTimeout(()=>{e({ok:!1,error:Error("Formbricks SDK loading timed out")})},1e4);r.onload=()=>{if(clearTimeout(t),globalThis.formbricks)return void e({ok:!0,data:void 0});let i=0,r=setInterval(()=>{globalThis.formbricks?(clearInterval(r),e({ok:!0,data:void 0})):++i>=50&&(clearInterval(r),e({ok:!1,error:Error("Formbricks SDK loaded but not available on globalThis")}))},10)},r.onerror=()=>{clearTimeout(t),e({ok:!1,error:Error("Failed to load Formbricks SDK")})}});return document.head.appendChild(r),s},l=async e=>{if(a)return void console.warn("ð§± Formbricks - Warning: Formbricks is already initializing.");let t=(e=>{let{appUrl:t,environmentId:i,workspaceId:r}=e;if(!t)return console.error("ð§± Formbricks - Error: appUrl is required"),null;if(!r&&!i)return console.error("ð§± Formbricks - Error: workspaceId or environmentId is required"),null;i&&!r&&console.warn("ð§± Formbricks - Warning: environmentId is deprecated and will be removed in a future version. Please use workspaceId instead.");let s=t.endsWith("/")?t.slice(0,-1):t;return r?{appUrl:s,workspaceId:r,...i?{environmentId:i}:{}}:{appUrl:s,environmentId:i}})(e);if(t){a=!0;try{let e=await c(t.appUrl),i=globalThis.formbricks;if(!e.ok||!i)return void console.error("ð§± Formbricks - Error: Failed to load Formbricks SDK");(e=>{let t;if(!(o.length>0&&(t=e,("function"!=typeof t.on||"function"!=typeof t.off)&&(console.warn("ð§± Formbricks - Warning: this Formbricks instance does not support events yet (formbricks.on). Update your self-hosted Formbricks to use event subscriptions."),1))))for(let t of o)t.removed||t.target||(e.on(t.event,t.handler),t.target=e)})(i),await i.setup({...t}),s=i,(()=>{for(;n.length>0;){let e=n.shift();if(!e||!s)break;if("function"!=typeof s[e.method]){console.error(`ð§± Formbricks - Error: Method ${e.method} does not exist on formbricks`);continue}s[e.method](...e.args)}})()}catch(e){s=null,console.error("ð§± Formbricks - Error: setup failed",e)}finally{a=!1}
3}},u=async(e,...t)=>{if(s){if("function"!=typeof s[e])return void console.error(`ð§± Formbricks - Error: Method ${e} does not exist on formbricks`);await s[e](...t)}else console.warn("ð§± Formbricks - Warning: Formbricks not initialized. This method will be queued and executed after initialization."),n.push({method:e,args:t})};let h=null,d=()=>(h||(h=l({environmentId:"cm5y6i7mr000rmb03vutldcwu",appUrl:"https://app.formbricks.com"}).catch(e=>{throw h=null,e})),h);function p(){d().then(m)}function m(){return u("registerRouteChange")}function _(){d()}e.s(["default",0,function(){let e,s,a=(0,t.c)(4),n=(0,i.usePathname)(),o=(0,i.useSearchParams)();return a[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],a[0]=e):e=a[0],(0,r.useEffect)(_,e),a[1]!==n||a[2]!==o?(s=[n,o],a[1]=n,a[2]=o,a[3]=s):s=a[3],(0,r.useEffect)(p,s),null}],622021)}]); 4 5//# debugId=f1cac2d9-4d91-b12e-6fc1-c9475e6c3f32
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.