@wacht/jsx 0.0.1-alpha.17 → 0.0.1-alpha.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- "use strict";var Zl=Object.defineProperty;var Kl=(t,r,o)=>r in t?Zl(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var Xe=(t,r,o)=>Kl(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),Ve=require("@wacht/types"),Nr=require("react-dom"),Bi=i.createContext(void 0);function Ql({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[a,s]=i.useState(!0),[p,g]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function d(){if(c.current)return;c.current=!0,s(!0);const[l,m,x]=r.split("_");if(!x)throw new Error("Invalid public key");let v=atob(x),w=m==="test",C=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){C=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",C??"");const k=new URL(window.location.href);k.searchParams.delete("__dev_session__"),window.history.replaceState({},"",k.toString())}else C=localStorage.getItem("__dev_session__");let $={};const y=new URLSearchParams;w?y.append("__dev_session__",C??""):$={credentials:"include"};const z=await fetch(`${v}/deployment${w?"?":""}${y.toString()}`,$);if(!z.ok){s(!1);return}const _=await z.json();_.data.backend_host=v,n&&(_.data.ui_settings={..._.data.ui_settings,...n}),g(_.data),w&&z.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",z.headers.get("x-development-session")??""),s(!1)}d()},[r]);const h=i.useMemo(()=>({loading:a,deployment:p,adapter:o}),[a,p,o]);return e.jsx(Bi.Provider,{value:h,children:t})}function ve(){const t=i.useContext(Bi);if(t===void 0)throw new Error("useDeployment must be used within a DeploymentProvider");if(!t.loading&&!t.deployment)throw new Error("Deployment is not loaded");return t}function De(){const{deployment:t,loading:r}=ve();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,a)=>{const s=Xl(t),p=new Headers(s.headers);a!=null&&a.headers&&new Headers(a.headers).forEach((d,l)=>{p.set(l,d)});const g=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&g.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(g,{...s,...a,headers:p});return t.mode==="staging"&&c.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",c.headers.get("x-development-session")??""),c},loading:r}}function Xl(t){return t.mode==="staging"?{}:{credentials:"include"}}var Gr={exports:{}},an={};/**
2
+ "use strict";var Zl=Object.defineProperty;var Kl=(t,r,o)=>r in t?Zl(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var Xe=(t,r,o)=>Kl(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),Ve=require("@wacht/types"),Fr=require("react-dom"),Bi=i.createContext(void 0);function Ql({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[a,s]=i.useState(!0),[h,g]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function l(){if(c.current)return;c.current=!0,s(!0);const[d,m,x]=r.split("_");if(!x)throw new Error("Invalid public key");let v=atob(x),w=m==="test",$=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){$=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",$??"");const S=new URL(window.location.href);S.searchParams.delete("__dev_session__"),window.history.replaceState({},"",S.toString())}else $=localStorage.getItem("__dev_session__");let z={};const y=new URLSearchParams;w?y.append("__dev_session__",$??""):z={credentials:"include"};const C=await fetch(`${v}/deployment${w?"?":""}${y.toString()}`,z);if(!C.ok){s(!1);return}const k=await C.json();k.data.backend_host=v,n&&(k.data.ui_settings={...k.data.ui_settings,...n}),g(k.data),w&&C.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",C.headers.get("x-development-session")??""),s(!1)}l()},[r]);const p=i.useMemo(()=>({loading:a,deployment:h,adapter:o}),[a,h,o]);return e.jsx(Bi.Provider,{value:p,children:t})}function xe(){const t=i.useContext(Bi);if(t===void 0)throw new Error("useDeployment must be used within a DeploymentProvider");if(!t.loading&&!t.deployment)throw new Error("Deployment is not loaded");return t}function De(){const{deployment:t,loading:r}=xe();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,a)=>{const s=Xl(t),h=new Headers(s.headers);a!=null&&a.headers&&new Headers(a.headers).forEach((l,d)=>{h.set(d,l)});const g=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&g.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(g,{...s,...a,headers:h});return t.mode==="staging"&&c.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",c.headers.get("x-development-session")??""),c},loading:r}}function Xl(t){return t.mode==="staging"?{}:{credentials:"include"}}var Hr={exports:{}},an={};/**
3
3
  * @license React
4
4
  * use-sync-external-store-shim.production.js
5
5
  *
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * This source code is licensed under the MIT license found in the
9
9
  * LICENSE file in the root directory of this source tree.
10
- */var Pa;function Jl(){if(Pa)return an;Pa=1;var t=i;function r(l,m){return l===m&&(l!==0||1/l===1/m)||l!==l&&m!==m}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,a=t.useEffect,s=t.useLayoutEffect,p=t.useDebugValue;function g(l,m){var x=m(),v=n({inst:{value:x,getSnapshot:m}}),w=v[0].inst,C=v[1];return s(function(){w.value=x,w.getSnapshot=m,c(w)&&C({inst:w})},[l,x,m]),a(function(){return c(w)&&C({inst:w}),l(function(){c(w)&&C({inst:w})})},[l]),p(x),x}function c(l){var m=l.getSnapshot;l=l.value;try{var x=m();return!o(l,x)}catch{return!0}}function h(l,m){return m()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:g;return an.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:d,an}var sn={};/**
10
+ */var Pa;function Jl(){if(Pa)return an;Pa=1;var t=i;function r(d,m){return d===m&&(d!==0||1/d===1/m)||d!==d&&m!==m}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,a=t.useEffect,s=t.useLayoutEffect,h=t.useDebugValue;function g(d,m){var x=m(),v=n({inst:{value:x,getSnapshot:m}}),w=v[0].inst,$=v[1];return s(function(){w.value=x,w.getSnapshot=m,c(w)&&$({inst:w})},[d,x,m]),a(function(){return c(w)&&$({inst:w}),d(function(){c(w)&&$({inst:w})})},[d]),h(x),x}function c(d){var m=d.getSnapshot;d=d.value;try{var x=m();return!o(d,x)}catch{return!0}}function p(d,m){return m()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:g;return an.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,an}var sn={};/**
11
11
  * @license React
12
12
  * use-sync-external-store-shim.development.js
13
13
  *
@@ -15,12 +15,12 @@
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var Ra;function ed(){return Ra||(Ra=1,process.env.NODE_ENV!=="production"&&function(){function t(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}function r(x,v){d||a.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var w=v();if(!l){var C=v();s(w,C)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}C=p({inst:{value:w,getSnapshot:v}});var $=C[0].inst,y=C[1];return c(function(){$.value=w,$.getSnapshot=v,o($)&&y({inst:$})},[x,w,v]),g(function(){return o($)&&y({inst:$}),x(function(){o($)&&y({inst:$})})},[x]),h(w),w}function o(x){var v=x.getSnapshot;x=x.value;try{var w=v();return!s(x,w)}catch{return!0}}function n(x,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=i,s=typeof Object.is=="function"?Object.is:t,p=a.useState,g=a.useEffect,c=a.useLayoutEffect,h=a.useDebugValue,d=!1,l=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;sn.useSyncExternalStore=a.useSyncExternalStore!==void 0?a.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),sn}var Ia;function td(){return Ia||(Ia=1,process.env.NODE_ENV==="production"?Gr.exports=Jl():Gr.exports=ed()),Gr.exports}var rd=td();const Ui=0,Wi=1,Vi=2,Ta=3;var Oa=Object.prototype.hasOwnProperty;function Gn(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&Gn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Oa.call(t,o)&&++n&&!Oa.call(r,o)||!(o in r)||!Gn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const vt=new WeakMap,$t=()=>{},Ge=$t(),Hn=Object,je=t=>t===Ge,lt=t=>typeof t=="function",Et=(t,r)=>({...t,...r}),Gi=t=>lt(t.then),cn={},Hr={},fa="undefined",Fr=typeof window!=fa,qn=typeof document!=fa,od=Fr&&"Deno"in window,nd=()=>Fr&&typeof window.requestAnimationFrame!=fa,Hi=(t,r)=>{const o=vt.get(t);return[()=>!je(r)&&t.get(r)||cn,n=>{if(!je(r)){const a=t.get(r);r in Hr||(Hr[r]=a),o[5](r,Et(a,n),a||cn)}},o[6],()=>!je(r)&&r in Hr?Hr[r]:!je(r)&&t.get(r)||cn]};let Yn=!0;const ad=()=>Yn,[Zn,Kn]=Fr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$t,$t],sd=()=>{const t=qn&&document.visibilityState;return je(t)||t!=="hidden"},id=t=>(qn&&document.addEventListener("visibilitychange",t),Zn("focus",t),()=>{qn&&document.removeEventListener("visibilitychange",t),Kn("focus",t)}),cd=t=>{const r=()=>{Yn=!0,t()},o=()=>{Yn=!1};return Zn("online",r),Zn("offline",o),()=>{Kn("online",r),Kn("offline",o)}},ld={isOnline:ad,isVisible:sd},dd={initFocus:id,initReconnect:cd},Ma=!i.useId,Lr=!Fr||od,ud=t=>nd()?window.requestAnimationFrame(t):setTimeout(t,1),ln=Lr?i.useEffect:i.useLayoutEffect,dn=typeof navigator<"u"&&navigator.connection,La=!Lr&&dn&&(["slow-2g","2g"].includes(dn.effectiveType)||dn.saveData),qr=new WeakMap,pd=t=>Hn.prototype.toString.call(t),un=(t,r)=>t===`[object ${r}]`;let hd=0;const Qn=t=>{const r=typeof t,o=pd(t),n=un(o,"Date"),a=un(o,"RegExp"),s=un(o,"Object");let p,g;if(Hn(t)===t&&!n&&!a){if(p=qr.get(t),p)return p;if(p=++hd+"~",qr.set(t,p),Array.isArray(t)){for(p="@",g=0;g<t.length;g++)p+=Qn(t[g])+",";qr.set(t,p)}if(s){p="#";const c=Hn.keys(t).sort();for(;!je(g=c.pop());)je(t[g])||(p+=g+":"+Qn(t[g])+",");qr.set(t,p)}}else p=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return p},ga=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Qn(t):"",[t,r]};let fd=0;const Xn=()=>++fd;async function qi(...t){const[r,o,n,a]=t,s=Et({populateCache:!0,throwOnError:!0},typeof a=="boolean"?{revalidate:a}:a||{});let p=s.populateCache;const g=s.rollbackOnError;let c=s.optimisticData;const h=m=>typeof g=="function"?g(m):g!==!1,d=s.throwOnError;if(lt(o)){const m=o,x=[],v=r.keys();for(const w of v)!/^\$(inf|sub)\$/.test(w)&&m(r.get(w)._k)&&x.push(w);return Promise.all(x.map(l))}return l(o);async function l(m){const[x]=ga(m);if(!x)return;const[v,w]=Hi(r,x),[C,$,y,z]=vt.get(r),_=()=>{const P=C[x];return(lt(s.revalidate)?s.revalidate(v().data,m):s.revalidate!==!1)&&(delete y[x],delete z[x],P&&P[0])?P[0](Vi).then(()=>v().data):v().data};if(t.length<3)return _();let k=n,b,f=!1;const I=Xn();$[x]=[I,0];const j=!je(c),S=v(),R=S.data,E=S._c,T=je(E)?R:E;if(j&&(c=lt(c)?c(T,R):c,w({data:c,_c:T})),lt(k))try{k=k(T)}catch(P){b=P,f=!0}if(k&&Gi(k))if(k=await k.catch(P=>{b=P,f=!0}),I!==$[x][0]){if(f)throw b;return k}else f&&j&&h(b)&&(p=!0,w({data:T,_c:Ge}));if(p&&!f)if(lt(p)){const P=p(k,T);w({data:P,error:Ge,_c:Ge})}else w({data:k,error:Ge,_c:Ge});if($[x][1]=Xn(),Promise.resolve(_()).then(()=>{w({_c:Ge})}),f){if(d)throw b;return}return k}}const Aa=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},gd=(t,r)=>{if(!vt.has(t)){const o=Et(dd,r),n=Object.create(null),a=qi.bind(Ge,t);let s=$t;const p=Object.create(null),g=(d,l)=>{const m=p[d]||[];return p[d]=m,m.push(l),()=>m.splice(m.indexOf(l),1)},c=(d,l,m)=>{t.set(d,l);const x=p[d];if(x)for(const v of x)v(l,m)},h=()=>{if(!vt.has(t)&&(vt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),a,c,g]),!Lr)){const d=o.initFocus(setTimeout.bind(Ge,Aa.bind(Ge,n,Ui))),l=o.initReconnect(setTimeout.bind(Ge,Aa.bind(Ge,n,Wi)));s=()=>{d&&d(),l&&l(),vt.delete(t)}}};return h(),[t,a,h,s]}return[t,vt.get(t)[4]]},md=(t,r,o,n,a)=>{const s=o.errorRetryCount,p=a.retryCount,g=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!je(s)&&p>s||setTimeout(n,g,a)},xd=Gn,[Yi,vd]=gd(new Map),bd=Et({onLoadingSlow:$t,onSuccess:$t,onError:$t,onErrorRetry:md,onDiscarded:$t,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:La?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:La?5e3:3e3,compare:xd,isPaused:()=>!1,cache:Yi,mutate:vd,fallback:{}},ld),yd=(t,r)=>{const o=Et(t,r);if(r){const{use:n,fallback:a}=t,{use:s,fallback:p}=r;n&&s&&(o.use=n.concat(s)),a&&p&&(o.fallback=Et(a,p))}return o},wd=i.createContext({}),jd="$inf$",Zi=Fr&&window.__SWR_DEVTOOLS_USE__,kd=Zi?window.__SWR_DEVTOOLS_USE__:[],_d=()=>{Zi&&(window.__SWR_DEVTOOLS_REACT__=i)},Cd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],Sd=()=>Et(bd,i.useContext(wd)),$d=t=>(r,o,n)=>t(r,o&&((...s)=>{const[p]=ga(r),[,,,g]=vt.get(Yi);if(p.startsWith(jd))return o(...s);const c=g[p];return je(c)?o(...s):(delete g[p],c)}),n),zd=kd.concat($d),Ed=t=>function(...o){const n=Sd(),[a,s,p]=Cd(o),g=yd(n,p);let c=t;const{use:h}=g,d=(h||[]).concat(zd);for(let l=d.length;l--;)c=d[l](c);return c(a,s||g.fetcher||null,g)},Pd=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const a=n.indexOf(o);a>=0&&(n[a]=n[n.length-1],n.pop())}};_d();const pn=i.use||(t=>{switch(t.status){case"pending":throw t;case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t.status="pending",t.then(r=>{t.status="fulfilled",t.value=r},r=>{t.status="rejected",t.reason=r}),t}}),hn={dedupe:!0},Rd=(t,r,o)=>{const{cache:n,compare:a,suspense:s,fallbackData:p,revalidateOnMount:g,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:d,refreshWhenOffline:l,keepPreviousData:m}=o,[x,v,w,C]=vt.get(n),[$,y]=ga(t),z=i.useRef(!1),_=i.useRef(!1),k=i.useRef($),b=i.useRef(r),f=i.useRef(o),I=()=>f.current,j=()=>I().isVisible()&&I().isOnline(),[S,R,E,T]=Hi(n,$),P=i.useRef({}).current,O=je(p)?je(o.fallback)?Ge:o.fallback[$]:p,D=(H,A)=>{for(const B in P){const L=B;if(L==="data"){if(!a(H[L],A[L])&&(!je(H[L])||!a(Z,A[L])))return!1}else if(A[L]!==H[L])return!1}return!0},M=i.useMemo(()=>{const H=!$||!r?!1:je(g)?I().isPaused()||s?!1:c!==!1:g,A=Se=>{const Ne=Et(Se);return delete Ne._k,H?{isValidating:!0,isLoading:!0,...Ne}:Ne},B=S(),L=T(),W=A(B),ee=B===L?W:A(L);let pe=W;return[()=>{const Se=A(S());return D(Se,pe)?(pe.data=Se.data,pe.isLoading=Se.isLoading,pe.isValidating=Se.isValidating,pe.error=Se.error,pe):(pe=Se,Se)},()=>ee]},[n,$]),N=rd.useSyncExternalStore(i.useCallback(H=>E($,(A,B)=>{D(B,A)||H()}),[n,$]),M[0],M[1]),F=!z.current,J=x[$]&&x[$].length>0,ie=N.data,re=je(ie)?O&&Gi(O)?pn(O):O:ie,X=N.error,U=i.useRef(re),Z=m?je(ie)?je(U.current)?re:U.current:ie:re,Q=J&&!je(X)?!1:F&&!je(g)?g:I().isPaused()?!1:s?je(re)?!1:c:je(re)||c,ae=!!($&&r&&F&&Q),oe=je(N.isValidating)?ae:N.isValidating,ce=je(N.isLoading)?ae:N.isLoading,Y=i.useCallback(async H=>{const A=b.current;if(!$||!A||_.current||I().isPaused())return!1;let B,L,W=!0;const ee=H||{},pe=!w[$]||!ee.dedupe,Se=()=>Ma?!_.current&&$===k.current&&z.current:$===k.current,Ne={isValidating:!1,isLoading:!1},G=()=>{R(Ne)},ne=()=>{const be=w[$];be&&be[1]===L&&delete w[$]},ye={isValidating:!0};je(S().data)&&(ye.isLoading=!0);try{if(pe&&(R(ye),o.loadingTimeout&&je(S().data)&&setTimeout(()=>{W&&Se()&&I().onLoadingSlow($,o)},o.loadingTimeout),w[$]=[A(y),Xn()]),[B,L]=w[$],B=await B,pe&&setTimeout(ne,o.dedupingInterval),!w[$]||w[$][1]!==L)return pe&&Se()&&I().onDiscarded($),!1;Ne.error=Ge;const be=v[$];if(!je(be)&&(L<=be[0]||L<=be[1]||be[1]===0))return G(),pe&&Se()&&I().onDiscarded($),!1;const te=S().data;Ne.data=a(te,B)?te:B,pe&&Se()&&I().onSuccess(B,$,o)}catch(be){ne();const te=I(),{shouldRetryOnError:$e}=te;te.isPaused()||(Ne.error=be,pe&&Se()&&(te.onError(be,$,te),($e===!0||lt($e)&&$e(be))&&(!I().revalidateOnFocus||!I().revalidateOnReconnect||j())&&te.onErrorRetry(be,$,te,fe=>{const ke=x[$];ke&&ke[0]&&ke[0](Ta,fe)},{retryCount:(ee.retryCount||0)+1,dedupe:!0})))}return W=!1,G(),!0},[$,n]),se=i.useCallback((...H)=>qi(n,k.current,...H),[]);if(ln(()=>{b.current=r,f.current=o,je(ie)||(U.current=ie)}),ln(()=>{if(!$)return;const H=Y.bind(Ge,hn);let A=0;I().revalidateOnFocus&&(A=Date.now()+I().focusThrottleInterval);const L=Pd($,x,(W,ee={})=>{if(W==Ui){const pe=Date.now();I().revalidateOnFocus&&pe>A&&j()&&(A=pe+I().focusThrottleInterval,H())}else if(W==Wi)I().revalidateOnReconnect&&j()&&H();else{if(W==Vi)return Y();if(W==Ta)return Y(ee)}});return _.current=!1,k.current=$,z.current=!0,R({_k:y}),Q&&(w[$]||(je(re)||Lr?H():ud(H))),()=>{_.current=!0,L()}},[$]),ln(()=>{let H;function A(){const L=lt(h)?h(S().data):h;L&&H!==-1&&(H=setTimeout(B,L))}function B(){!S().error&&(d||I().isVisible())&&(l||I().isOnline())?Y(hn).then(A):A()}return A(),()=>{H&&(clearTimeout(H),H=-1)}},[h,d,l,$]),i.useDebugValue(Z),s&&je(re)&&$){if(!Ma&&Lr)throw new Error("Fallback data is required when using Suspense in SSR.");b.current=r,f.current=o,_.current=!1;const H=C[$];if(!je(H)){const A=se(H);pn(A)}if(je(X)){const A=Y(hn);je(Z)||(A.status="fulfilled",A.value=!0),pn(A)}else throw X}return{mutate:se,get data(){return P.data=!0,Z},get error(){return P.error=!0,X},get isValidating(){return P.isValidating=!0,oe},get isLoading(){return P.isLoading=!0,ce}}},We=Ed(Rd);async function V(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}const r=await t.json();return{data:r.data,errors:r.errors}}function Ki(t){const{client:r}=De(),o=i.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await V(c)).data},[r,t]),{data:n,error:a,mutate:s}=We(t?`sessions-${t}`:null,o,{revalidateOnFocus:!1}),p=i.useCallback(async c=>{const h=new FormData;h.append("title",c.title),c.system_instructions&&h.append("system_instructions",c.system_instructions);const d=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:h}),l=await V(d);return await s(m=>m&&{...m,data:[l.data,...m.data]}),l.data},[r,t,s]),g=i.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await s(h=>h&&{...h,data:h.data.filter(d=>d.id!==c)})},[r,t,s]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!a,error:a,createSession:p,deleteSession:g,refetch:async()=>{await s()}}}const Qi=i.createContext(void 0);function Uo(){const t=i.useContext(Qi);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Id({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:a,onSessionCreated:s,onSessionDeleted:p,onError:g}){const[c,h]=i.useState(a?{id:a,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[d,l]=i.useState(!1),{sessions:m,loading:x,error:v,createSession:w,deleteSession:C,refetch:$}=Ki(o);i.useEffect(()=>{if(a&&m.length>0){const b=m.find(f=>f.id===a);b&&h(b)}},[a,m]);const y=i.useCallback(b=>{h(b),l(!1)},[]),z=i.useCallback(async b=>{try{const f=b||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,I=await w({title:f});return h(I),s==null||s(I),I}catch(f){const I=f instanceof Error?f.message:"Failed to create session";throw g==null||g(I),f}},[w,s,g]),_=i.useCallback(async b=>{try{await C(b),(c==null?void 0:c.id)===b&&h(null),p==null||p(b)}catch(f){const I=f instanceof Error?f.message:"Failed to delete session";throw g==null||g(I),f}},[C,c,p,g]),k={agentName:r,token:o,platformAdapter:n,sessions:m,selectedSession:c,loadingSessions:x,sessionError:v,selectSession:y,createSession:z,deleteSession:_,refreshSessions:$,showHistory:d,setShowHistory:l,onSessionCreated:s,onSessionDeleted:p,onError:g};return e.jsx(Qi.Provider,{value:k,children:t})}var Xi=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(Xi||{});function Td(t,r,o){const n={username:Od(t,r,o),email:Md(t,r,o),phone:Ld(t,r,o),email_otp:Ad(t,r,o),magic_link:Dd(t,r,o),oauth:Nd(t,o),generic:Fd(t,r,o)};return function(s){return n[s]}}function Od(t,r,o){return async({username:n,password:a})=>{var c,h;const s=new FormData;s.append("strategy","plain_username"),s.append("username",n),s.append("password",a);const p=await t("/auth/signin",{method:"POST",body:s}),g=await V(p);return"data"in g&&((h=(c=g.data)==null?void 0:c.signin_attempts)!=null&&h.length)?(r(g.data.signin_attempts.at(-1)||null),o(null)):o(g),g}}function Md(t,r,o){return async({email:n,password:a})=>{var c,h;const s=new FormData;s.append("strategy","plain_email"),s.append("email",n),s.append("password",a);const p=await t("/auth/signin",{method:"POST",body:s}),g=await V(p);return"data"in g&&((h=(c=g.data)==null?void 0:c.signin_attempts)!=null&&h.length)?(r(g.data.signin_attempts.at(-1)||null),o(null)):o(g),g}}function Ld(t,r,o){return async({phone:n})=>{var g,c;const a=new FormData;a.append("strategy","phone_otp"),a.append("phone",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await V(s);return"data"in p&&((c=(g=p.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(p.data.signin_attempts.at(-1)||null),o(null)):o(p),p}}function Ad(t,r,o){return async({email:n})=>{var g,c;const a=new FormData;a.append("strategy","email_otp"),a.append("email",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await V(s);return"data"in p&&((c=(g=p.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(p.data.signin_attempts.at(-1)||null),o(null)):o(p),p}}function Dd(t,r,o){return async({email:n})=>{var g,c;const a=new FormData;a.append("strategy","magic_link"),a.append("email",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await V(s);return"data"in p&&((c=(g=p.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(p.data.signin_attempts.at(-1)||null),o(null)):o(p),p}}function Nd(t,r){return async({provider:o,redirectUri:n})=>{const a=new URLSearchParams({provider:o});n&&a.append("redirect_uri",n);const s=await t(`/auth/oauth2/init?${a.toString()}`,{method:"POST"}),p=await V(s);return"data"in p?(r(null),p.data.oauth_url&&(window.location.href=p.data.oauth_url)):r(p),p}}function Fd(t,r,o){return async({email:n,username:a,password:s,phone:p,strategy:g,token:c})=>{var m,x;const h=new FormData;g&&h.append("strategy",g),n&&h.append("email",n),a&&h.append("username",a),s&&h.append("password",s),p&&h.append("phone",p),c&&h.append("token",c);const d=await t("/auth/signin",{method:"POST",body:h}),l=await V(d);return"data"in l&&((x=(m=l.data)==null?void 0:m.signin_attempts)!=null&&x.length)?(r(l.data.signin_attempts.at(-1)||null),o(null)):o(l),l}}function Ji(){const{client:t,loading:r}=De(),[o,n]=i.useState(null),[a,s]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null),s(null)},setSignInAttempt:n,error:null}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Td(t,n,s),completeVerification:async p=>{var d,l,m,x;const g=new FormData;g.append("verification_code",p);const c=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:g}),h=await V(c);if("data"in h&&((l=(d=h.data)==null?void 0:d.signin_attempts)!=null&&l.length)){const v=h.data.signin_attempts.at(-1);return n(v||null),s(null),h.data}else throw"errors"in h?(s(h),new Error(((x=(m=h.errors)==null?void 0:m[0])==null?void 0:x.message)||"Verification failed")):new Error("Verification failed")},prepareVerification:async p=>{var h;const g=new URL("/auth/prepare-verification",window.location.origin);g.searchParams.set("attempt_identifier",((h=o==null?void 0:o.id)==null?void 0:h.toString())||""),g.searchParams.set("strategy",p.strategy),g.searchParams.set("identifier_type","signin"),p.strategy==="phone_otp"&&p.lastDigits?g.searchParams.set("last_digits",p.lastDigits):(p.strategy==="email_otp"&&p.redirectUri||p.strategy==="magic_link"&&p.redirectUri)&&g.searchParams.set("redirect_uri",p.redirectUri);const c=await t(g.pathname+g.search,{method:"POST"});return V(c)},completeProfile:async p=>{var d;if(!o)throw new Error("No signin attempt found");const g=new FormData;for(const[l,m]of Object.entries(p))m&&g.append(l,m);const c=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:g}),h=await V(c);if("data"in h&&h.data){const l=(d=h.data.signin_attempts)==null?void 0:d.find(m=>m.id===o.id);return l&&n(l),s(null),h.data}else throw new Error("Profile completion failed")}},discardSignInAttempt:()=>{n(null),s(null)},setSignInAttempt:n,error:a}}function Ar(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:a,setSignInAttempt:s,error:p}=Ji();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:a,setSignInAttempt:s,error:null};const g=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:g,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile},discardSignInAttempt:a,setSignInAttempt:s,error:p}}function Bd(t,r,o,n){return{create:async a=>{var c,h,d;const s=new FormData;for(const[l,m]of Object.entries(a))s.append(l,m);const p=await t("/auth/signup",{method:"POST",body:s}),g=await V(p);return"data"in g&&((h=(c=g.data)==null?void 0:c.signup_attempts)!=null&&h.length)?(o(((d=g.data.signup_attempts)==null?void 0:d.at(-1))||null),n(null)):n(g),g},prepareVerification:async a=>{var g;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((g=r==null?void 0:r.id)==null?void 0:g.toString())||""),s.searchParams.set("strategy",a.strategy),s.searchParams.set("identifier_type","signup"),a.strategy==="phone_otp"&&a.lastDigits?s.searchParams.set("last_digits",a.lastDigits):a.strategy==="email_otp"&&a.redirectUri&&s.searchParams.set("redirect_uri",a.redirectUri);const p=await t(s.pathname+s.search,{method:"POST"});return V(p)},completeVerification:async a=>{var c,h,d,l;const s=new FormData;s.append("verification_code",a);const p=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),g=await V(p);if("data"in g&&((h=(c=g.data)==null?void 0:c.signup_attempts)!=null&&h.length))o(g.data.signup_attempts.at(-1)||null),n(null);else if("errors"in g)throw n(g),new Error(((l=(d=g.errors)==null?void 0:d[0])==null?void 0:l.message)||"Verification failed");return g},validateDeploymentInvitation:async a=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(a)}`,{method:"GET"}),p=await V(s);return"data"in p&&p.data?p.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(s){return{valid:!1,message:s.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function ec(){const{client:t,loading:r}=De(),[o,n]=i.useState(null),[a,s]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null),s(null)},errors:null}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null),s(null)},signUp:Bd(t,o,n,s),errors:a}}const He=()=>{const{adapter:t,deployment:r}=ve(),o=t.useNavigate(),n=(p,g)=>{o?o(p,g):window.location.href=p};return{navigate:n,navigateToSignIn:p=>{if(!r)return;const g=p||window.location.href,c=new URLSearchParams;c.set("redirect_uri",g),(r==null?void 0:r.mode)==="staging"&&c.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${c.toString()}`,{replace:!0})},navigateToSignUp:p=>{if(!r)return;const g=p||window.location.href,c=new URLSearchParams;c.set("redirect_uri",g),(r==null?void 0:r.mode)==="staging"&&c.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${c.toString()}`,{replace:!0})}}};async function Ud(t){const r=await t("/session",{method:"GET"});return(await V(r)).data}async function Wd(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return V(o)}async function Vd(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return V(n)}async function Gd(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return V(o)}async function Hd(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return V(o)}const Jn=new Map,Ir=new Map;function Qt(){Jn.clear(),Ir.clear()}async function qd(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return V(o)}function Fe(){const{client:t,loading:r}=De(),{deployment:o}=ve(),{navigate:n}=He(),{data:a,error:s,mutate:p,isLoading:g}=We(r?null:"/session",()=>Ud(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),c=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]),h=i.useCallback(async(l="default")=>{var v;if(!a)throw new Error("no session");const m=Jn.get(l);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";Ir.get(l)||Ir.set(l,qd(t,l));const x=await Ir.get(l);if(Ir.delete(l),(v=x.errors)!=null&&v.length)throw new Error(x.errors[0].message);return Jn.set(l,x.data),x.data.token},[t,a==null?void 0:a.active_signin]),d=i.useCallback(()=>{if(!o)return;const l=o.ui_settings.sign_in_page_url,m=window.location.href,x=new URL(l);if(x.searchParams.set("redirect_uri",m),o.mode==="staging"){const v=localStorage.getItem("__dev_session__");v&&x.searchParams.set("dev_session",v)}n(x.toString())},[o,n]);return r||!a||g?{loading:!0,error:s,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,addNewAccount:null,refetch:c}:{loading:g,error:s,session:a,switchSignIn:async l=>{await Wd(t,l),await p(void 0,{revalidate:!0})},signOut:async l=>{await Vd(t,l),await p(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(l&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!l&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async l=>{await Gd(t,l),Qt(),await p(void 0,{revalidate:!0})},switchWorkspace:async l=>{await Hd(t,l),Qt(),await p(void 0,{revalidate:!0})},getToken:h,addNewAccount:d,refetch:c}}const Wo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=bt(),{client:n}=De(),{refetch:a}=Fe(),s=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/roles`,{method:"GET"}))).data,[n]),p=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/members`,{method:"GET"}))).data,[n]),g=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/domains`,{method:"GET"}))).data,[n]),h=i.useCallback(async(j,S)=>{await n(`/organizations/${j.id}/members/${S.id}/remove`,{method:"POST"}),await r()},[r,n]),d=i.useCallback(async j=>{const S=new FormData;S.append("name",j.name),j.image&&S.append("image",j.image),j.description&&S.append("description",j.description);const R=await V(await n("/organizations",{method:"POST",body:S}));return Qt(),await r(),await a(),R},[a,r,n]),l=i.useCallback(async(j,S)=>{const R=Object.entries(S).reduce((T,[P,O])=>(O&&T.append(P,O),T),new FormData),E=await V(await n(`/organizations/${j.id}/update`,{method:"POST",body:R}));return await r(),E},[r,n]),m=i.useCallback(async(j,S)=>{await n(`/organizations/${j.id}/roles/${S.id}/remove`,{method:"POST"})},[n]),x=i.useCallback(async(j,S)=>{const R=new FormData;return R.append("domain",S.fqdn),await V(await n(`/organizations/${j.id}/domains`,{method:"POST",body:R}))},[n]),v=i.useCallback(async(j,S)=>await V(await n(`/organizations/${j.id}/domains/${S.id}/verify`,{method:"POST"})),[n]),w=i.useCallback(async(j,S)=>await V(await n(`/organizations/${j.id}/domains/${S.id}/remove`,{method:"POST"})),[n]),C=i.useCallback(async(j,S)=>{const R=new FormData;return R.append("name",S.name),S.permissions&&S.permissions.forEach((T,P)=>{R.append(`permissions[${P}]`,T)}),await V(await n(`/organizations/${j.id}/roles`,{method:"POST",body:R}))},[n]),$=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/leave`,{method:"POST"}))).data,[n]),y=i.useCallback(async j=>{const S=await V(await n(`/organizations/${j.id}/delete`,{method:"POST"}));return Qt(),await r(),await a(),S.data},[n,r,a]),z=i.useCallback(async(j,S,R)=>(await V(await n(`/organizations/${j.id}/members/${S.id}/roles/${R.id}/add`,{method:"POST"}))).data,[n]),_=i.useCallback(async(j,S,R)=>(await V(await n(`/organizations/${j.id}/members/${S.id}/roles/${R.id}/remove`,{method:"POST"}))).data,[n]),k=i.useCallback(async(j,S)=>{var T,P;const R=new FormData;return R.append("email",S.email),R.append("role_id",S.organizationRole.id),(T=S.workspace)!=null&&T.id&&R.append("workspace_id",S.workspace.id),(P=S.workspaceRole)!=null&&P.id&&R.append("workspace_role_id",S.workspaceRole.id),(await V(await n(`/organizations/${j.id}/invitations`,{method:"POST",body:R}))).data},[n]),b=i.useCallback(async(j,S)=>(await V(await n(`/organizations/${j.id}/invitations/${S.id}/remove`,{method:"POST"}))).data,[n]),f=i.useCallback(async(j,S)=>(await V(await n(`/organizations/${j.id}/invitations/${S.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(j=>j.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:$,getOrganizationRoles:s,getOrganizationMembers:p,removeOrganizationMember:h,createOrganization:d,getOrganizationInvitations:g,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:w,addRoleToOrganizationMember:z,removeRoleFromOrganizationMember:_,inviteOrganizationMember:k,discardOrganizationInvitation:b,resendOrganizationInvitation:f,updateOrganization:l,addRole:C,removeOrganizationRoles:m,deleteOrganization:y}},Qe=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:a,leaveOrganization:s,removeOrganizationMember:p,getOrganizationInvitations:g,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:d,verifyOrganizationDomain:l,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:w,resendOrganizationInvitation:C,updateOrganization:$,removeOrganizationRoles:y}=Wo(),{session:z,error:_,loading:k}=Fe(),{organizationMemberships:b}=bt(),f=i.useMemo(()=>{var U;return((U=b==null?void 0:b.find(Z=>{var Q;return Z.id===((Q=z==null?void 0:z.active_signin)==null?void 0:Q.active_organization_membership_id)}))==null?void 0:U.organization)||null},[b,z]),I=i.useCallback(async U=>f?await $(f,U):[],[f,$]),j=i.useCallback(async()=>f?await n(f):[],[f,n]),S=i.useCallback(async()=>f?await a(f):[],[f,a]),R=i.useCallback(async U=>f?await p(f,U):[],[f,p]),E=i.useCallback(async U=>f?await y(f,U):void 0,[f,y]),T=i.useCallback(async()=>f?await c(f):[],[f,c]),P=i.useCallback(async U=>f?await d(f,U):void 0,[f,d]),O=i.useCallback(async U=>f?await l(f,U):void 0,[f,l]),D=i.useCallback(async U=>f?await h(f,U):void 0,[f,h]),M=i.useCallback(async(U,Z)=>f?await m(f,U,Z):void 0,[f,m]),N=i.useCallback(async(U,Z)=>f?await x(f,U,Z):void 0,[f,x]),F=i.useCallback(async U=>f?await v(f,U):void 0,[f,v]),J=i.useCallback(async U=>f?await w(f,U):void 0,[f,w]),ie=i.useCallback(async U=>f?await C(f,U):void 0,[f,C]),re=i.useCallback(async()=>{f&&await s(f)},[f,s]),X=i.useCallback(async()=>f?await g(f):[],[f,g]);return k||t?{activeOrganization:null,loading:!0,error:_||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null}:{activeOrganization:f,loading:!1,refetch:o,getRoles:S,updateOrganization:I,getMembers:j,getDomains:T,addDomain:P,verifyDomain:O,removeDomain:D,getInvitations:X,removeMember:R,leave:re,removeRole:E,addMemberRole:M,removeMemberRole:N,inviteMember:F,discardInvitation:J,resendInvitation:ie,error:null}};async function Yd(t){return(await V(await t("/me/organization-memberships"))).data}const bt=()=>{const{client:t,loading:r}=De(),{data:o,isLoading:n,error:a,mutate:s}=We(r?null:"/me/organization-memberships",()=>Yd(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),p=i.useCallback(async()=>{await s(void 0,{revalidate:!0})},[s]);return{organizationMemberships:o,loading:r||n,error:a,refetch:p}};async function Zd(t){return(await V(await t("/me/workspace-memberships"))).data}async function Kd(t,r,o){return(await V(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Vo=()=>{const{client:t,loading:r}=De(),{deployment:o}=ve(),{data:n,isLoading:a,error:s,mutate:p}=We(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>Zd(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),g=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]);return{workspaceMemberships:n,loading:r||a,error:s,refetch:g}},yt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Vo(),{client:a}=De(),s=i.useMemo(()=>t==null?void 0:t.map(y=>({...y.workspace,organization:y.organization,eligibility_restriction:y.eligibility_restriction})),[t]),p=i.useCallback(async(y,z,_,k)=>{const b=new FormData;b.append("name",z),_&&b.append("image",_),k&&b.append("description",k),b.append("organization_id",y);const f=await a("/workspaces",{method:"POST",body:b});return Qt(),await r(),f},[a,r]),g=i.useCallback(async(y,z)=>{const _=await Kd(a,y,z);return await r(),_},[a,r]),c=i.useCallback(async(y,z)=>{const _=new FormData;z.name&&_.append("name",z.name),z.description&&_.append("description",z.description),z.image&&_.append("image",z.image);const k=await V(await a(`/workspaces/${y.id}/update`,{method:"POST",body:_}));return await r(),k.data},[a,r]),h=i.useCallback(async y=>{const z=await V(await a(`/workspaces/${y.id}/delete`,{method:"POST"}));return Qt(),await r(),z.data},[a,r]),d=i.useCallback(async y=>(await V(await a(`/workspaces/${y.id}/members`,{method:"GET"}))).data,[a]),l=i.useCallback(async y=>(await V(await a(`/workspaces/${y.id}/roles`,{method:"GET"}))).data,[a]),m=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/roles`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z,permissions:_})}))).data,[a]),x=i.useCallback(async(y,z)=>(await V(await a(`/workspaces/${y.id}/roles/${z.id}/delete`,{method:"POST"}))).data,[a]),v=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:z,role_id:_})}))).data,[a]),w=i.useCallback(async(y,z)=>{const _=await V(await a(`/workspaces/${y.id}/members/${z}/remove`,{method:"POST"}));return await r(),_.data},[a,r]),C=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/members/${z}/roles/${_}`,{method:"POST"}))).data,[a]),$=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/members/${z}/roles/${_}/remove`,{method:"POST"}))).data,[a]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:g,createWorkspace:p,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:d,getWorkspaceRoles:l,createWorkspaceRole:m,deleteWorkspaceRole:x,inviteWorkspaceMember:v,removeWorkspaceMember:w,addWorkspaceMemberRole:C,removeWorkspaceMemberRole:$}},Pt=()=>{const{refetch:t,loading:r,error:o,leaveWorkspace:n,updateWorkspace:a,deleteWorkspace:s,getWorkspaceMembers:p,getWorkspaceRoles:g,createWorkspaceRole:c,deleteWorkspaceRole:h,inviteWorkspaceMember:d,removeWorkspaceMember:l,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x}=yt(),{workspaceMemberships:v}=Vo(),{session:w,loading:C,error:$}=Fe(),y=i.useMemo(()=>{var D;return((D=v==null?void 0:v.find(M=>{var N;return M.id===((N=w==null?void 0:w.active_signin)==null?void 0:N.active_workspace_membership_id)}))==null?void 0:D.workspace)||null},[v,w]),z=i.useCallback(async()=>{var D;if(!(!y||!((D=w==null?void 0:w.active_signin)!=null&&D.user_id)))return await n(y.id,w.active_signin.user_id)},[y,n,w]),_=i.useCallback(async D=>{if(y)return await a(y,D)},[y,a]),k=i.useCallback(async()=>{if(y)return await s(y)},[y,s]),b=i.useCallback(async()=>y?await p(y):[],[y,p]),f=i.useCallback(async()=>y?await g(y):[],[y,g]),I=i.useCallback(async(D,M)=>{if(y)return await c(y,D,M)},[y,c]),j=i.useCallback(async D=>{if(y)return await h(y,D)},[y,h]),S=i.useCallback(async(D,M)=>{if(y)return await d(y,D,M)},[y,d]),R=i.useCallback(async D=>{if(y)return await l(y,D)},[y,l]),E=i.useCallback(async(D,M)=>{if(y)return await m(y,D,M)},[y,m]),T=i.useCallback(async(D,M)=>{if(y)return await x(y,D,M)},[y,x]),P=r||C,O=o||$;return P?{activeWorkspace:null,loading:!0,error:O,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null}:{activeWorkspace:y,loading:!1,error:O,refetch:t,leave:z,updateWorkspace:_,deleteWorkspace:k,getMembers:b,getRoles:f,createRole:I,deleteRole:j,inviteMember:S,removeMember:R,addMemberRole:E,removeMemberRole:T}},Qd=async t=>(await V(await t("/me"))).data,Xd=async t=>(await V(await t("/me/signins"))).data;function rr(){const{client:t,loading:r}=De(),{data:o,error:n,isLoading:a,mutate:s}=We(r?null:"/user",()=>Qd(t)),p=async P=>{const O=new FormData;for(const[M,N]of Object.entries(P))N!=null&&N!==""&&O.append(M,String(N));const D=await V(await t("/me",{method:"POST",body:O}));return s(),D},g=async()=>await V(await t("/me/email-addresses",{method:"GET"})),c=async P=>await V(await t(`/me/email-addresses/${P}`,{method:"GET"})),h=async P=>{const O=new FormData;return O.append("email",P),await V(await t("/me/email-addresses",{method:"POST",body:O}))},d=async P=>await V(await t(`/me/email-addresses/${P}/delete`,{method:"POST"})),l=async P=>await V(await t(`/me/email-addresses/${P}/prepare-verification`,{method:"POST"})),m=async(P,O)=>await V(await t(`/me/email-addresses/${P}/attempt-verification?code=${O}`,{method:"POST"})),x=async(P,O)=>{const D=new FormData;return D.append("phone_number",P),D.append("country_code",O),await V(await t("/me/phone-numbers",{method:"POST",body:D}))},v=async P=>await V(await t(`/me/phone-numbers/${P}/delete`,{method:"POST"})),w=async P=>await V(await t(`/me/phone-numbers/${P}/prepare-verification`,{method:"POST"})),C=async(P,O)=>{const D=new FormData;return D.append("code",O),await V(await t(`/me/phone-numbers/${P}/attempt-verification`,{method:"POST",body:D}))},$=async P=>{const O=await V(await t(`/me/phone-numbers/${P}/make-primary`,{method:"POST"}));return s(),O},y=async P=>await V(await t(`/me/email-addresses/${P}/make-primary`,{method:"POST"})),z=async()=>(await V(await t("/me/authenticator",{method:"POST"}))).data,_=async(P,O)=>{const D=new FormData;return D.append("authenticator_id",P),O.forEach(N=>{D.append("codes",N)}),await V(await t("/me/authenticator/attempt-verification",{method:"POST",body:D}))},k=async P=>await V(await t(`/me/authenticator/${P}/delete`,{method:"POST"})),b=async()=>(await V(await t("/me/backup-codes",{method:"POST"}))).data,f=async P=>{const O=new FormData;return O.append("file",P),await V(await t("/me/profile-picture",{method:"POST",body:O}))},I=async()=>(await V(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,j=async(P,O)=>{const D=new FormData;return D.append("current_password",P),D.append("new_password",O),await V(await t("/me/update-password",{method:"POST",body:D}))},S=async P=>{const O=new FormData;O.append("current_password",P);const D=await V(await t("/me/remove-password",{method:"POST",body:O}));return s(),D},R=async P=>{const O=new FormData;return O.append("password",P),await V(await t("/me/account/delete",{method:"POST",body:O}))},E=async P=>await V(await t(`/me/social-connections/${P}/disconnect`,{method:"POST"})),T=async({provider:P,redirectUri:O})=>{var N;const D=new URLSearchParams({provider:P});O&&D.append("redirect_uri",O);const M=await V(await t(`/me/init-sso-connection?${D.toString()}`,{method:"POST"}));return"data"in M&&((N=M.data)!=null&&N.oauth_url)&&window.open(M.data.oauth_url,"_blank"),M};return{user:{...o,refetch:s},loading:r||a,error:n||null,updateProfile:p,getEmailAddresses:g,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:d,prepareEmailVerification:l,attemptEmailVerification:m,makeEmailPrimary:y,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:w,attemptPhoneVerification:C,makePhonePrimary:$,setupAuthenticator:z,verifyAuthenticator:_,deleteAuthenticator:k,generateBackupCodes:b,regenerateBackupCodes:I,updateProfilePicture:f,disconnectSocialConnection:E,connectSocialAccount:T,updatePassword:j,removePassword:S,deleteAccount:R}}function tc(){const{client:t,loading:r}=De(),{data:o,error:n,isLoading:a,mutate:s}=We(r?null:"/me/signins",()=>Xd(t));return{signins:o,error:n||null,removeSignin:async g=>await V(await t(`/me/signins/${g}/signout`,{method:"POST"})),refetch:s,loading:a||r}}function Jd(){const{session:t,loading:r}=Fe(),{loading:o,organizationMemberships:n}=bt(),{loading:a,workspaceMemberships:s}=Vo();if(r||o||a)return{loading:!0,orgMembership:null,workspaceMembership:null};const p=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_organization_membership_id)}),[t]),g=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:p,workspaceMembership:g}}function rc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),p=async g=>{n(!0),s(null);try{const c=new FormData;for(const[l,m]of Object.entries(g))m&&c.append(l,m);const h=await t("/waitlist/join",{method:"POST",body:c}),d=await V(h);return s(d.errors?d:null),d}catch(c){const h={data:null,errors:[{message:c instanceof Error?c.message:"Failed to join waitlist",code:Ve.ErrorCode.Unknown}]};return s(h),h}finally{n(!1)}};return r?{loading:!0,error:null,joinWaitlist:null}:{loading:o,error:a,joinWaitlist:p}}function oc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[p,g]=i.useState(null),[c,h]=i.useState(null),[d,l]=i.useState(!1),[m,x]=i.useState(null);i.useEffect(()=>{if(d||r)return;const w=new URLSearchParams(window.location.search),C=w.get("code"),$=w.get("state"),y=w.get("error"),z=w.get("error_description");if(!C&&!y){l(!0);const _=new Error("No OAuth callback data found.");s(_);return}if(l(!0),n(!0),y){const _=z||y,k=new Error(`OAuth Error: ${_}`);s(k),n(!1);return}if(C&&$)v(C,$);else{const _=new Error("Missing required OAuth parameters");s(_),n(!1)}},[d,r]);const v=async(w,C)=>{try{let $,y;try{const k=C.split(".");if(k.length!==2)throw new Error("Invalid OAuth state format - missing signature");const b=k[0].replace(/-/g,"+").replace(/_/g,"/"),f=b.length%4?"=".repeat(4-b.length%4):"",j=atob(b+f).split("|")[0];if(j==="sign_in")$="/auth/oauth2/callback",y="GET";else if(j==="connect_social")$="/me/sso-connection-callback",y="POST";else throw new Error(`Unknown OAuth action: ${j}`)}catch(k){const b=k instanceof Error?k:new Error("Failed to parse OAuth state");s(new Error(`Invalid OAuth callback: ${b.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const z=await t(`${$}?code=${encodeURIComponent(w)}&state=${encodeURIComponent(C)}`,{method:y}),_=await V(z);if("data"in _){const k=_.data.session,b=_.data.redirect_uri||null;if(g(k),h(b),k.signin_attempts&&k.signin_attempts.length>0){const f=k.signin_attempts.at(-1);f&&x(f)}}else{const k=new Error("SSO callback failed");s(k)}}catch($){const y=$ instanceof Error?$:new Error("Unknown error occurred");s(y)}finally{n(!1)}};return{loading:o,error:a,session:p,redirectUri:c,processed:d,signinAttempt:m}}function nc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[p,g]=i.useState(null);return{loading:r||o,verifyMagicLink:async h=>{if(!h.token||!h.attempt){const d=new Error("Invalid magic link parameters");return s(d),{data:void 0,errors:[{message:d.message,code:Ve.ErrorCode.BadRequestBody}]}}n(!0),s(null),g(null);try{const d=new URL("/auth/verify-magic-link",window.location.origin);d.searchParams.set("token",h.token),d.searchParams.set("attempt",h.attempt),h.redirectUri&&d.searchParams.set("redirect_uri",h.redirectUri);const l=await t(d.pathname+d.search,{method:"GET"}),m=await V(l);if(n(!1),"errors"in m&&m.errors){const x=new Error(m.errors[0].message);s(x),g(!1)}else g(!0);return m}catch(d){n(!1);const l=d instanceof Error?d:new Error("Magic link verification failed");return s(l),g(!1),{data:void 0,errors:[{message:l.message,code:Ve.ErrorCode.Internal}]}}},error:a,success:p}}function ac(){const[t,r]=i.useState({});return i.useEffect(()=>{const o=new URLSearchParams(window.location.search);r({token:o.get("token")||void 0,attempt:o.get("attempt")||void 0,redirectUri:o.get("redirect_uri")||void 0})},[]),t}function sc(){const{client:t,loading:r}=De(),[o,n]=i.useState(null);return{error:o,loading:r,forgotPassword:async g=>{n(null);const c=new FormData;c.append("email",g);const h=await t("/auth/forgot-password",{method:"POST",body:c}),d=await V(h);return"errors"in d&&d.errors&&n(new Error(d.errors[0].message)),d},verifyOtp:async(g,c)=>{n(null);const h=new FormData;h.append("email",g),h.append("otp",c);const d=await t("/auth/forgot-password",{method:"POST",body:h}),l=await V(d);return"errors"in l&&l.errors&&n(new Error(l.errors[0].message)),l},resetPassword:async(g,c)=>{n(null);const h=new FormData;h.append("token",g),h.append("password",c);const d=await t("/auth/reset-password",{method:"POST",body:h}),l=await V(d);return"errors"in l&&l.errors&&n(new Error(l.errors[0].message)),l}}}function ic({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:a,onError:s,reconnectDelay:p=1e3,maxReconnectAttempts:g=5}={}){const{session:c,loading:h}=Fe(),{deployment:d,loading:l}=ve(),[m,x]=i.useState(!1),[v,w]=i.useState(null),C=i.useRef(null),$=i.useRef(null),y=i.useRef(0),z=i.useRef(null),_=i.useRef(a),k=i.useRef(s),b=i.useRef(r),f=i.useRef(o),I=i.useRef(n),j=i.useRef(p),S=i.useRef(g);_.current=a,k.current=s,b.current=r,f.current=o,I.current=n,j.current=p,S.current=g;const R=i.useCallback(()=>{$.current&&(clearTimeout($.current),$.current=null),z.current&&(clearInterval(z.current),z.current=null),C.current&&(C.current.close(),C.current=null)},[]),E=i.useCallback(async()=>{var N;if(!t||h||l||!c||!d)return;R();const O=new URL(d.backend_host),D=O.protocol==="https:"?"wss:":"ws:",M=new URL("/realtime/notifications",`${D}//${O.host}`);if(d.mode==="staging"){const F=localStorage.getItem("__dev_session__");F&&M.searchParams.set("__dev_session__",F)}b.current&&b.current.length>0&&b.current.forEach(F=>M.searchParams.append("channels",F)),f.current&&f.current.length>0&&f.current.forEach(F=>M.searchParams.append("organization_ids",F.toString())),I.current&&I.current.length>0&&I.current.forEach(F=>M.searchParams.append("workspace_ids",F.toString()));try{const F=new WebSocket(M.toString());C.current=F,F.onopen=()=>{x(!0),w(null),y.current=0,z.current=setInterval(()=>{F.readyState===WebSocket.OPEN&&F.send("ping")},3e4)},F.onmessage=J=>{var ie,re;try{const X=JSON.parse(J.data);if(X.type==="notification"&&X.data)(ie=_.current)==null||ie.call(_,X.data);else if(X.type==="error"){const U=X.error||"Unknown error occurred";w(U),(re=k.current)==null||re.call(k,U)}else X.type}catch{}},F.onerror=()=>{var J;w("Connection error occurred"),(J=k.current)==null||J.call(k,"Connection error occurred")},F.onclose=J=>{var ie;if(x(!1),z.current&&(clearInterval(z.current),z.current=null),t&&J.code!==1e3&&y.current<S.current){y.current++;const re=j.current*Math.pow(2,y.current-1);$.current=setTimeout(()=>{E()},re)}else y.current>=S.current&&(w("Max reconnection attempts reached"),(ie=k.current)==null||ie.call(k,"Max reconnection attempts reached"))}}catch{w("Failed to connect"),(N=k.current)==null||N.call(k,"Failed to connect")}},[t,h,l,c,d,R]);i.useEffect(()=>(E(),()=>{R()}),[E,R]),i.useEffect(()=>{C.current&&C.current.readyState===WebSocket.OPEN&&E()},[r,o,n,E]);const T=i.useCallback(()=>{R(),x(!1)},[R]),P=i.useCallback(()=>{y.current=0,E()},[E]);return{isConnected:m,connectionError:v,disconnect:T,reconnect:P}}async function eu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(p=>o.append("channels",p)),r.organization_ids&&r.organization_ids.forEach(p=>o.append("organization_ids",p.toString())),r.workspace_ids&&r.workspace_ids.forEach(p=>o.append("workspace_ids",p.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,a=await t(n,{method:"GET"});return(await V(a)).data}async function tu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await V(r)).data}async function ru(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return V(o)}async function ou(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return V(r)}async function nu(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return V(o)}function cc(t){const{client:r,loading:o}=De(),{data:n,error:a,mutate:s,isLoading:p}=We(o?null:["notifications",JSON.stringify(t)],()=>eu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});ic({enabled:!o&&!!n,onNotification:i.useCallback(l=>{s(async m=>!m||m.notifications.some(v=>v.id===l.id.toString())?m:{...m,notifications:[{id:l.id.toString(),user_id:l.user_id.toString(),deployment_id:l.deployment_id.toString(),title:l.title,body:l.body,severity:l.severity,action_url:l.action_url,action_label:l.action_label,is_read:!1,is_archived:!1,created_at:l.created_at,updated_at:l.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[s]),onError:i.useCallback(()=>{},[])});const g=i.useCallback(async l=>{o||(await s(async m=>m&&{...m,notifications:m.notifications.map(x=>x.id===l?{...x,is_read:!0}:x),unread_count:Math.max(0,m.unread_count-1)},!1),await ru(r,l),await s())},[r,o,s]),c=i.useCallback(async()=>{o||(await s(async l=>l&&{...l,notifications:l.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await ou(r),await s())},[r,s]),h=i.useCallback(async l=>{o||(await s(async m=>{if(!m)return m;const x=m.notifications.find(v=>v.id===l);return{...m,notifications:m.notifications.filter(v=>v.id!==l),unread_count:x&&!x.is_read?Math.max(0,m.unread_count-1):m.unread_count,total:Math.max(0,m.total-1)}},!1),await nu(r,l),await s())},[r,o,s]),d=i.useCallback(async()=>{await s()},[s]);return!n||o||p?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:a,refetch:d}:{loading:!1,error:a,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:g,markAllAsRead:c,deleteNotification:h,refetch:d}}async function au(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await V(r)).data}function su(){const{client:t,loading:r}=De(),{data:o,error:n,mutate:a}=We(r?null:["notifications","channel-counts"],()=>au(t),{refreshInterval:3e4,revalidateOnFocus:!0}),s=async()=>{await a()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:s}:{loading:!1,counts:o,error:n,refetch:s}}const Gt=class Gt{constructor(){Xe(this,"ws",null);Xe(this,"messageHandlers",new Set);Xe(this,"connectionStateHandlers",new Set);Xe(this,"reconnectTimer",null);Xe(this,"reconnectAttempts",0);Xe(this,"url",null);Xe(this,"isIntentionalDisconnect",!1);Xe(this,"sessionMessages",{});Xe(this,"currentSessionKey",null)}static getInstance(){return Gt.instance||(Gt.instance=new Gt),Gt.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};Xe(Gt,"instance");let ea=Gt;const Ye=ea.getInstance(),xt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Me={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Tt={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Da(t){switch(t){case Tt.IDLE:return Me.IDLE;case Tt.STARTING:return Me.STARTING;case Tt.RUNNING:return Me.RUNNING;case Tt.WAITING_FOR_INPUT:return Me.WAITING_FOR_INPUT;case Tt.COMPLETED:return Me.COMPLETED;case Tt.FAILED:case Tt.CANCELLED:return Me.FAILED;default:return Me.IDLE}}function Na(t){return t===Me.STARTING||t===Me.RUNNING||t===Me.WAITING_FOR_INPUT}function lc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:a=!0}){const{deployment:s}=ve(),{client:p}=De(),[g,c]=i.useState([]),[h,d]=i.useState(null),[l,m]=i.useState(null),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState(Me.IDLE),[z,_]=i.useState({status:xt.DISCONNECTED}),[k,b]=i.useState(!0),[f,I]=i.useState(!1),j=i.useRef(null),S=i.useRef(null),R=i.useCallback(X=>{var U,Z;switch(X.message_type){case"session_connected":if(v(!0),_({status:xt.CONNECTED}),(U=X.data)!=null&&U.execution_status){const ae=X.data.execution_status,oe=Da(ae);y(oe),C(Na(oe))}break;case"conversation_message":E(X.data);break;case"user_input_request":T(X.data);break;case"platform_event":P(X.data);break;case"platform_function":O(X.data);break;case"execution_complete":C(!1),y(Me.IDLE),S.current=null;break;case"execution_error":C(!1),y(Me.FAILED),S.current=null;break;case"execution_cancelled":C(!1),y(Me.IDLE),S.current=null;break;case"execution_status":const Q=(Z=X.data)==null?void 0:Z.status;if(Q){const ae=Da(Q);y(ae),C(Na(ae))}break}},[h]),E=i.useCallback(X=>{var oe,ce,Y,se,q,H,A,B;const{id:U,message_type:Z,content:Q}=X,ae=L=>g.some(W=>W.id===L);if(Z==="system_decision"||Z==="action_execution_result"||Z==="assistant_task_breakdown"||Z==="assistant_validation"||Z==="assistant_action_planning"||Z==="context_results"){d(null),m(null);let L="";if(Z==="system_decision"){const W=Q==null?void 0:Q.step,ee=Q==null?void 0:Q.reasoning;if(W==="gathercontext")ee&&ee.length>0?L=ee.length>60?`${ee.substring(0,60)}...`:ee:L="Gathering context...";else if(W==="executeaction")L="Executing action";else if(W==="deliverresponse")L="Preparing response";else if(W==="taskplanning")L="Planning approach";else if(W==="validateprogress")L="Validating progress";else if(W==="acknowledge")L="Processing request";else if(W==="finishplanning")L="Finalizing plan";else if(W==="executetasks")L="Executing tasks";else if(W==="requestuserinput")L="Waiting for input";else if(W==="complete")L="Completed";else if(W==="examinetool")L="Examining tool";else if(W==="examineworkflow")L="Examining workflow";else{const pe=(Q==null?void 0:Q.confidence)||.5;pe>.8?L="Analyzing":pe>.6?L="Thinking":L="Reasoning"}}else if(Z==="action_execution_result")((oe=Q.task_execution)==null?void 0:oe.status)==="completed"?L="Task execution completed":(ce=Q.task_execution)!=null&&ce.approach?L=Q.task_execution.approach:L="Executing task";else if(Z==="assistant_task_breakdown")(Y=Q.task_breakdown)!=null&&Y.total_tasks?L=`Identified ${Q.task_breakdown.total_tasks} tasks`:L="Planning tasks";else if(Z==="assistant_validation")L="Validated results";else if(Z==="assistant_action_planning")(se=Q.task_execution)!=null&&se.total_tasks?L=`Planned ${Q.task_execution.total_tasks} tasks`:(H=(q=Q.task_execution)==null?void 0:q.tasks)!=null&&H.length?L=`Planned ${Q.task_execution.tasks.length} tasks`:L="Planning actions";else if(Z==="context_results"){const W=Q.query,ee=Q.result_count||0;W&&W!=="General context gathering"?L=`${W}: Found ${ee} results`:L=`Found ${ee} results`}L&&!ae(U)&&c(W=>[...W,{id:U,role:"system",content:L,timestamp:new Date,metadata:{type:"log",messageType:Z}}]);return}if(Z==="user_message")ae(U)||(d(null),m(null),c(L=>[...L,{id:U,role:"user",content:Q.message,images:Q.images,timestamp:new Date}]));else if(Z==="agent_response")ae(U)||(d(null),m(null),C(!1),y(Me.IDLE),S.current=null,c(L=>[...L,{id:U,role:"assistant",content:Q.response,timestamp:new Date,isStreaming:!1}]));else if(Z==="assistant_acknowledgment")ae(U)||(d(null),m(null),c(L=>[...L,{id:U,role:"assistant",content:Q.acknowledgment_message,timestamp:new Date}]));else if(Z==="assistant_ideation"||Z==="assistant_action_planning"||Z==="action_execution_result"||Z==="assistant_validation"||Z==="assistant_context_gathering"||Z==="assistant_task_breakdown"){let L="";if(Q.reasoning_summary)L=Q.reasoning_summary;else if((A=Q.task_execution)!=null&&A.approach)L=Q.task_execution.approach;else if(Q.strategic_synthesis)L=Q.strategic_synthesis;else if((B=Q.task_breakdown)!=null&&B.total_tasks)L=`Breaking down into ${Q.task_breakdown.total_tasks} tasks...`;else if(Q.acknowledgment_message)L=Q.acknowledgment_message;else return;c(W=>[...W,{id:U,role:"assistant",content:L,timestamp:new Date}])}else if(Z==="user_input_request"){const L={question:Q.question,context:Q.context,input_type:Q.input_type,options:Q.options||Q.suggestions,default_value:Q.default_value,placeholder:Q.placeholder};y("waiting_for_input"),c(W=>[...W,{id:U,role:"system",content:L.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:L}}])}},[]),T=i.useCallback(async X=>{y("waiting_for_input");const U=`input-request-${Date.now()}`;c(Z=>[...Z,{id:U,role:"system",content:X.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:X}}])},[]),P=i.useCallback(X=>{const{event_label:U,event_data:Z}=X;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(U,Z)},[n]),O=i.useCallback(async X=>{const{function_name:U,function_data:Z}=X,{parameters:Q,execution_id:ae}=Z;if(!(n!=null&&n.onPlatformFunction)){Ye.send({message_type:{platform_function_result:[ae,{error:"No platform function handler registered"}]},data:{}});return}try{const oe=await n.onPlatformFunction(U,Q,ae),ce={message_type:{platform_function_result:[ae,oe]},data:{}};Ye.send(ce)}catch(oe){Ye.send({message_type:{platform_function_result:[ae,{error:oe instanceof Error?oe.message:"Function execution failed",stack:oe instanceof Error?oe.stack:void 0}]},data:{}})}},[n]);i.useEffect(()=>{if(!s)return;const U=`wss://${s==null?void 0:s.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;_({status:xt.CONNECTING}),Ye.connect(U)},[s,o]),i.useEffect(()=>Ye.onConnectionStateChange(U=>{_({status:U.isConnected?xt.CONNECTED:U.error?xt.ERROR:xt.DISCONNECTED}),v(U.isConnected)}),[]),i.useEffect(()=>Ye.onMessage(R),[R]),i.useEffect(()=>{x&&t&&r&&a&&Ye.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,a]);const D=i.useCallback(async()=>(x&&t&&r&&Ye.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),M=i.useCallback((X,U)=>{x&&(d(X),m(U||null),C(!0),y(Me.STARTING),Ye.send({message_type:{message_input:X},data:U?{images:U}:{}}))},[x]),N=i.useCallback(()=>{c([]),S.current=null},[]),F=i.useCallback(X=>{!x||$!==Me.WAITING_FOR_INPUT||(Ye.send({message_type:{user_input_response:X},data:{}}),y(Me.RUNNING))},[x,$]),J=i.useCallback(async X=>{var U;if(!(!o||!t))try{const Z=new URLSearchParams({token:o,limit:"50"});X&&(Z.append("before_id",X),I(!0));const ae=await(await p(`/api/agent/contexts/${t}/messages?${Z}`,{method:"GET"})).json();if(ae.status===200&&ae.data){const oe=ae.data;if(Array.isArray(oe.data)){const ce=oe.data.filter(Y=>{var H;let se=Y.content;if(typeof Y.content=="string")try{se=JSON.parse(Y.content)}catch{se={message:Y.content}}const q=((H=Y.metadata)==null?void 0:H.message_type)||(se==null?void 0:se.message_type);return q==="user_message"||q==="agent_response"||q==="assistant_acknowledgment"||q==="user_input_request"||q==="system_decision"||q==="action_execution_result"||q==="assistant_task_breakdown"||q==="assistant_validation"||q==="assistant_action_planning"||q==="context_results"}).map(Y=>{var L,W,ee,pe,Se,Ne,G;let se="",q,H,A=Y.content;if(typeof Y.content=="string")try{A=JSON.parse(Y.content)}catch{A=Y.content}const B=((L=Y.metadata)==null?void 0:L.message_type)||(A==null?void 0:A.message_type);if(B==="user_message"?(se=(A==null?void 0:A.message)||"",q=(A==null?void 0:A.images)||void 0):B==="agent_response"?se=(A==null?void 0:A.response)||"":B==="assistant_acknowledgment"?se=(A==null?void 0:A.acknowledgment_message)||"":B==="user_input_request"&&(se=(A==null?void 0:A.question)||"",H={type:"user_input_request",userInputRequest:{question:(A==null?void 0:A.question)||"",context:(A==null?void 0:A.context)||"",input_type:(A==null?void 0:A.input_type)||"text",options:(A==null?void 0:A.options)||(A==null?void 0:A.suggestions)||[],default_value:(A==null?void 0:A.default_value)||"",placeholder:(A==null?void 0:A.placeholder)||""}}),B==="system_decision"||B==="action_execution_result"||B==="assistant_task_breakdown"||B==="assistant_validation"||B==="assistant_action_planning"||B==="context_results"){let ne="";if(B==="system_decision"){const ye=A==null?void 0:A.step,be=A==null?void 0:A.reasoning;if(ye==="gathercontext")be&&be.length>0?ne=be.length>60?`${be.substring(0,60)}...`:be:ne="Gathering context...";else if(ye==="executeaction")ne="Executing action";else if(ye==="deliverresponse")ne="Preparing response";else if(ye==="taskplanning")ne="Planning approach";else if(ye==="validateprogress")ne="Validating progress";else if(ye==="acknowledge")ne="Processing request";else if(ye==="finishplanning")ne="Finalizing plan";else if(ye==="executetasks")ne="Executing tasks";else if(ye==="requestuserinput")ne="Waiting for input";else if(ye==="complete")ne="Completed";else if(ye==="examinetool")ne="Examining tool";else if(ye==="examineworkflow")ne="Examining workflow";else{const te=(A==null?void 0:A.confidence)||.5;te>.8?ne="Analyzing":te>.6?ne="Thinking":ne="Reasoning"}}else if(B==="action_execution_result")((W=A==null?void 0:A.task_execution)==null?void 0:W.status)==="completed"?ne="Task execution completed":(ee=A==null?void 0:A.task_execution)!=null&&ee.approach?ne=A.task_execution.approach:ne="Executing task";else if(B==="assistant_task_breakdown")(pe=A==null?void 0:A.task_breakdown)!=null&&pe.total_tasks?ne=`Identified ${A.task_breakdown.total_tasks} tasks`:ne="Planning tasks";else if(B==="assistant_validation")ne="Validated results";else if(B==="assistant_action_planning")(Se=A==null?void 0:A.task_execution)!=null&&Se.total_tasks?ne=`Planned ${A.task_execution.total_tasks} tasks`:(G=(Ne=A==null?void 0:A.task_execution)==null?void 0:Ne.tasks)!=null&&G.length?ne=`Planned ${A.task_execution.tasks.length} tasks`:ne="Planning actions";else if(B==="context_results"){const ye=A==null?void 0:A.query,be=(A==null?void 0:A.result_count)||0;ye&&ye!=="General context gathering"?ne=`${ye}: Found ${be} results`:ne=`Found ${be} results`}se=ne,H={type:"log",messageType:B}}return{id:Y.id,role:B==="user_message"?"user":B==="user_input_request"?"system":"assistant",content:se,images:q,timestamp:new Date(Y.timestamp||Y.created_at||Date.now()),metadata:H}}).filter(Y=>Y.content||Y.metadata||Y.images).sort((Y,se)=>{const q=BigInt(Y.id),H=BigInt(se.id);return q<H?-1:q>H?1:0});ce.length>0&&(j.current=ce[0].id),X?(c(Y=>[...ce,...Y]),b(ce.length>=50)):(c(ce),ce.length>0&&((U=ce[ce.length-1].metadata)==null?void 0:U.type)==="user_input_request"&&y(Me.WAITING_FOR_INPUT)),I(!1)}}}catch(Z){console.error("Failed to fetch messages:",Z),I(!1)}},[o,t,p]);i.useEffect(()=>{t&&o&&J()},[t,o]);const ie=i.useCallback(async()=>{if(!(f||!k||!j.current)){I(!0);try{await J(j.current)}finally{I(!1)}}},[f,k,J]),re=i.useCallback(()=>{!x||!w||(Ye.send({message_type:{cancel_execution:null},data:{}}),C(!1),y("idle"))},[x,w]);return{messages:g,pendingMessage:h,pendingImages:l,connectionState:z,isConnected:x,isExecuting:w,executionStatus:$,isWaitingForInput:$==="waiting_for_input",hasMoreMessages:k,isLoadingMore:f,sendMessage:M,submitUserInput:F,clearMessages:N,loadMoreMessages:ie,cancelExecution:re,connect:D,disconnect:()=>Ye.disconnect()}}const dc=()=>{const{client:t}=De(),[r,o]=i.useState(!1),[n,a]=i.useState(null),[s,p]=i.useState(null),g=i.useCallback(async h=>{o(!0),a(null),p(null);try{const d=await t("/organizations/invitations/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:h})}),m=(await V(d)).data;return p(m),m.error_code&&a(m.message||"Failed to accept invitation"),m}catch(d){const l=d.message||"Failed to accept invitation";a(l);const m={error_code:"NETWORK_ERROR",message:l};return p(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{a(null),p(null)},[]);return{acceptInvitation:g,invitationData:s,loading:r,error:n,reset:c}},iu=({children:t})=>{const{loading:r}=ve();return r?null:e.jsx(e.Fragment,{children:t})},cu=({children:t})=>{const{loading:r}=ve();return r?e.jsx(e.Fragment,{children:t}):null};var qe=function(){return qe=Object.assign||function(r){for(var o,n=1,a=arguments.length;n<a;n++){o=arguments[n];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])}return r},qe.apply(this,arguments)};function Xt(t,r,o){if(o||arguments.length===2)for(var n=0,a=r.length,s;n<a;n++)(s||!(n in r))&&(s||(s=Array.prototype.slice.call(r,0,n)),s[n]=r[n]);return t.concat(s||Array.prototype.slice.call(r))}function lu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var du=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,uu=lu(function(t){return du.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),ze="-ms-",Mr="-moz-",_e="-webkit-",uc="comm",Go="rule",ma="decl",pu="@import",pc="@keyframes",hu="@layer",hc=Math.abs,xa=String.fromCharCode,ta=Object.assign;function fu(t,r){return Be(t,0)^45?(((r<<2^Be(t,0))<<2^Be(t,1))<<2^Be(t,2))<<2^Be(t,3):0}function fc(t){return t.trim()}function mt(t,r){return(t=r.exec(t))?t[0]:t}function ge(t,r,o){return t.replace(r,o)}function _o(t,r,o){return t.indexOf(r,o)}function Be(t,r){return t.charCodeAt(r)|0}function hr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function gc(t){return t.length}function Tr(t,r){return r.push(t),t}function gu(t,r){return t.map(r).join("")}function Fa(t,r){return t.filter(function(o){return!mt(o,r)})}var Ho=1,fr=1,mc=0,Ze=0,Le=0,br="";function qo(t,r,o,n,a,s,p,g){return{value:t,root:r,parent:o,type:n,props:a,children:s,line:Ho,column:fr,length:p,return:"",siblings:g}}function St(t,r){return ta(qo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function ar(t){for(;t.root;)t=St(t.root,{children:[t]});Tr(t,t.siblings)}function mu(){return Le}function xu(){return Le=Ze>0?Be(br,--Ze):0,fr--,Le===10&&(fr=1,Ho--),Le}function et(){return Le=Ze<mc?Be(br,Ze++):0,fr++,Le===10&&(fr=1,Ho++),Le}function qt(){return Be(br,Ze)}function Co(){return Ze}function Yo(t,r){return hr(br,t,r)}function ra(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function vu(t){return Ho=fr=1,mc=ct(br=t),Ze=0,[]}function bu(t){return br="",t}function fn(t){return fc(Yo(Ze-1,oa(t===91?t+2:t===40?t+1:t)))}function yu(t){for(;(Le=qt())&&Le<33;)et();return ra(t)>2||ra(Le)>3?"":" "}function wu(t,r){for(;--r&&et()&&!(Le<48||Le>102||Le>57&&Le<65||Le>70&&Le<97););return Yo(t,Co()+(r<6&&qt()==32&&et()==32))}function oa(t){for(;et();)switch(Le){case t:return Ze;case 34:case 39:t!==34&&t!==39&&oa(Le);break;case 40:t===41&&oa(t);break;case 92:et();break}return Ze}function ju(t,r){for(;et()&&t+Le!==57;)if(t+Le===84&&qt()===47)break;return"/*"+Yo(r,Ze-1)+"*"+xa(t===47?t:et())}function ku(t){for(;!ra(qt());)et();return Yo(t,Ze)}function _u(t){return bu(So("",null,null,null,[""],t=vu(t),0,[0],t))}function So(t,r,o,n,a,s,p,g,c){for(var h=0,d=0,l=p,m=0,x=0,v=0,w=1,C=1,$=1,y=0,z="",_=a,k=s,b=n,f=z;C;)switch(v=y,y=et()){case 40:if(v!=108&&Be(f,l-1)==58){_o(f+=ge(fn(y),"&","&\f"),"&\f",hc(h?g[h-1]:0))!=-1&&($=-1);break}case 34:case 39:case 91:f+=fn(y);break;case 9:case 10:case 13:case 32:f+=yu(v);break;case 92:f+=wu(Co()-1,7);continue;case 47:switch(qt()){case 42:case 47:Tr(Cu(ju(et(),Co()),r,o,c),c);break;default:f+="/"}break;case 123*w:g[h++]=ct(f)*$;case 125*w:case 59:case 0:switch(y){case 0:case 125:C=0;case 59+d:$==-1&&(f=ge(f,/\f/g,"")),x>0&&ct(f)-l&&Tr(x>32?Ua(f+";",n,o,l-1,c):Ua(ge(f," ","")+";",n,o,l-2,c),c);break;case 59:f+=";";default:if(Tr(b=Ba(f,r,o,h,d,a,g,z,_=[],k=[],l,s),s),y===123)if(d===0)So(f,r,b,b,_,s,l,g,k);else switch(m===99&&Be(f,3)===110?100:m){case 100:case 108:case 109:case 115:So(t,b,b,n&&Tr(Ba(t,b,b,0,0,a,g,z,a,_=[],l,k),k),a,k,l,g,n?_:k);break;default:So(f,b,b,b,[""],k,0,g,k)}}h=d=x=0,w=$=1,z=f="",l=p;break;case 58:l=1+ct(f),x=v;default:if(w<1){if(y==123)--w;else if(y==125&&w++==0&&xu()==125)continue}switch(f+=xa(y),y*w){case 38:$=d>0?1:(f+="\f",-1);break;case 44:g[h++]=(ct(f)-1)*$,$=1;break;case 64:qt()===45&&(f+=fn(et())),m=qt(),d=l=ct(z=f+=ku(Co())),y++;break;case 45:v===45&&ct(f)==2&&(w=0)}}return s}function Ba(t,r,o,n,a,s,p,g,c,h,d,l){for(var m=a-1,x=a===0?s:[""],v=gc(x),w=0,C=0,$=0;w<n;++w)for(var y=0,z=hr(t,m+1,m=hc(C=p[w])),_=t;y<v;++y)(_=fc(C>0?x[y]+" "+z:ge(z,/&\f/g,x[y])))&&(c[$++]=_);return qo(t,r,o,a===0?Go:g,c,h,d,l)}function Cu(t,r,o,n){return qo(t,r,o,uc,xa(mu()),hr(t,2,-2),0,n)}function Ua(t,r,o,n,a){return qo(t,r,o,ma,hr(t,0,n),hr(t,n+1,-1),n,a)}function xc(t,r,o){switch(fu(t,r)){case 5103:return _e+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return _e+t+t;case 4789:return Mr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return _e+t+Mr+t+ze+t+t;case 5936:switch(Be(t,r+11)){case 114:return _e+t+ze+ge(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return _e+t+ze+ge(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return _e+t+ze+ge(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return _e+t+ze+t+t;case 6165:return _e+t+ze+"flex-"+t+t;case 5187:return _e+t+ge(t,/(\w+).+(:[^]+)/,_e+"box-$1$2"+ze+"flex-$1$2")+t;case 5443:return _e+t+ze+"flex-item-"+ge(t,/flex-|-self/g,"")+(mt(t,/flex-|baseline/)?"":ze+"grid-row-"+ge(t,/flex-|-self/g,""))+t;case 4675:return _e+t+ze+"flex-line-pack"+ge(t,/align-content|flex-|-self/g,"")+t;case 5548:return _e+t+ze+ge(t,"shrink","negative")+t;case 5292:return _e+t+ze+ge(t,"basis","preferred-size")+t;case 6060:return _e+"box-"+ge(t,"-grow","")+_e+t+ze+ge(t,"grow","positive")+t;case 4554:return _e+ge(t,/([^-])(transform)/g,"$1"+_e+"$2")+t;case 6187:return ge(ge(ge(t,/(zoom-|grab)/,_e+"$1"),/(image-set)/,_e+"$1"),t,"")+t;case 5495:case 3959:return ge(t,/(image-set\([^]*)/,_e+"$1$`$1");case 4968:return ge(ge(t,/(.+:)(flex-)?(.*)/,_e+"box-pack:$3"+ze+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+_e+t+t;case 4200:if(!mt(t,/flex-|baseline/))return ze+"grid-column-align"+hr(t,r)+t;break;case 2592:case 3360:return ze+ge(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,a){return r=a,mt(n.props,/grid-\w+-end/)})?~_o(t+(o=o[r].value),"span",0)?t:ze+ge(t,"-start","")+t+ze+"grid-row-span:"+(~_o(o,"span",0)?mt(o,/\d+/):+mt(o,/\d+/)-+mt(t,/\d+/))+";":ze+ge(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return mt(n.props,/grid-\w+-start/)})?t:ze+ge(ge(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ge(t,/(.+)-inline(.+)/,_e+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ct(t)-1-r>6)switch(Be(t,r+1)){case 109:if(Be(t,r+4)!==45)break;case 102:return ge(t,/(.+:)(.+)-([^]+)/,"$1"+_e+"$2-$3$1"+Mr+(Be(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~_o(t,"stretch",0)?xc(ge(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ge(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,a,s,p,g,c,h){return ze+a+":"+s+h+(p?ze+a+"-span:"+(g?c:+c-+s)+h:"")+t});case 4949:if(Be(t,r+6)===121)return ge(t,":",":"+_e)+t;break;case 6444:switch(Be(t,Be(t,14)===45?18:11)){case 120:return ge(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+_e+(Be(t,14)===45?"inline-":"")+"box$3$1"+_e+"$2$3$1"+ze+"$2box$3")+t;case 100:return ge(t,":",":"+ze)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ge(t,"scroll-","scroll-snap-")+t}return t}function Io(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Su(t,r,o,n){switch(t.type){case hu:if(t.children.length)break;case pu:case ma:return t.return=t.return||t.value;case uc:return"";case pc:return t.return=t.value+"{"+Io(t.children,n)+"}";case Go:if(!ct(t.value=t.props.join(",")))return""}return ct(o=Io(t.children,n))?t.return=t.value+"{"+o+"}":""}function $u(t){var r=gc(t);return function(o,n,a,s){for(var p="",g=0;g<r;g++)p+=t[g](o,n,a,s)||"";return p}}function zu(t){return function(r){r.root||(r=r.return)&&t(r)}}function Eu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case ma:t.return=xc(t.value,t.length,o);return;case pc:return Io([St(t,{value:ge(t.value,"@","@"+_e)})],n);case Go:if(t.length)return gu(o=t.props,function(a){switch(mt(a,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":ar(St(t,{props:[ge(a,/:(read-\w+)/,":"+Mr+"$1")]})),ar(St(t,{props:[a]})),ta(t,{props:Fa(o,n)});break;case"::placeholder":ar(St(t,{props:[ge(a,/:(plac\w+)/,":"+_e+"input-$1")]})),ar(St(t,{props:[ge(a,/:(plac\w+)/,":"+Mr+"$1")]})),ar(St(t,{props:[ge(a,/:(plac\w+)/,ze+"input-$1")]})),ar(St(t,{props:[a]})),ta(t,{props:Fa(o,n)});break}return""})}}var Pu={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Jt=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",vc="active",bc="data-styled-version",Zo="6.1.19",va=`/*!sc*/
19
- `,To=typeof window<"u"&&typeof document<"u",Ru=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==""?process.env.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&process.env.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.SC_DISABLE_SPEEDY!==void 0&&process.env.SC_DISABLE_SPEEDY!==""?process.env.SC_DISABLE_SPEEDY!=="false"&&process.env.SC_DISABLE_SPEEDY:process.env.NODE_ENV!=="production"),Wa=/invalid hook call/i,Yr=new Set,Iu=function(t,r){if(process.env.NODE_ENV!=="production"){var o=r?' with the id of "'.concat(r,'"'):"",n="The component ".concat(t).concat(o,` has been created dynamically.
18
+ */var Ra;function ed(){return Ra||(Ra=1,process.env.NODE_ENV!=="production"&&function(){function t(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}function r(x,v){l||a.startTransition===void 0||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var w=v();if(!d){var $=v();s(w,$)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),d=!0)}$=h({inst:{value:w,getSnapshot:v}});var z=$[0].inst,y=$[1];return c(function(){z.value=w,z.getSnapshot=v,o(z)&&y({inst:z})},[x,w,v]),g(function(){return o(z)&&y({inst:z}),x(function(){o(z)&&y({inst:z})})},[x]),p(w),w}function o(x){var v=x.getSnapshot;x=x.value;try{var w=v();return!s(x,w)}catch{return!0}}function n(x,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=i,s=typeof Object.is=="function"?Object.is:t,h=a.useState,g=a.useEffect,c=a.useLayoutEffect,p=a.useDebugValue,l=!1,d=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;sn.useSyncExternalStore=a.useSyncExternalStore!==void 0?a.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),sn}var Ia;function td(){return Ia||(Ia=1,process.env.NODE_ENV==="production"?Hr.exports=Jl():Hr.exports=ed()),Hr.exports}var rd=td();const Ui=0,Wi=1,Vi=2,Ta=3;var Oa=Object.prototype.hasOwnProperty;function Gn(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&Gn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Oa.call(t,o)&&++n&&!Oa.call(r,o)||!(o in r)||!Gn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const vt=new WeakMap,$t=()=>{},Ge=$t(),Hn=Object,je=t=>t===Ge,lt=t=>typeof t=="function",Et=(t,r)=>({...t,...r}),Gi=t=>lt(t.then),cn={},qr={},fa="undefined",Br=typeof window!=fa,qn=typeof document!=fa,od=Br&&"Deno"in window,nd=()=>Br&&typeof window.requestAnimationFrame!=fa,Hi=(t,r)=>{const o=vt.get(t);return[()=>!je(r)&&t.get(r)||cn,n=>{if(!je(r)){const a=t.get(r);r in qr||(qr[r]=a),o[5](r,Et(a,n),a||cn)}},o[6],()=>!je(r)&&r in qr?qr[r]:!je(r)&&t.get(r)||cn]};let Yn=!0;const ad=()=>Yn,[Zn,Kn]=Br&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$t,$t],sd=()=>{const t=qn&&document.visibilityState;return je(t)||t!=="hidden"},id=t=>(qn&&document.addEventListener("visibilitychange",t),Zn("focus",t),()=>{qn&&document.removeEventListener("visibilitychange",t),Kn("focus",t)}),cd=t=>{const r=()=>{Yn=!0,t()},o=()=>{Yn=!1};return Zn("online",r),Zn("offline",o),()=>{Kn("online",r),Kn("offline",o)}},ld={isOnline:ad,isVisible:sd},dd={initFocus:id,initReconnect:cd},Ma=!i.useId,Ar=!Br||od,ud=t=>nd()?window.requestAnimationFrame(t):setTimeout(t,1),ln=Ar?i.useEffect:i.useLayoutEffect,dn=typeof navigator<"u"&&navigator.connection,La=!Ar&&dn&&(["slow-2g","2g"].includes(dn.effectiveType)||dn.saveData),Yr=new WeakMap,pd=t=>Hn.prototype.toString.call(t),un=(t,r)=>t===`[object ${r}]`;let hd=0;const Qn=t=>{const r=typeof t,o=pd(t),n=un(o,"Date"),a=un(o,"RegExp"),s=un(o,"Object");let h,g;if(Hn(t)===t&&!n&&!a){if(h=Yr.get(t),h)return h;if(h=++hd+"~",Yr.set(t,h),Array.isArray(t)){for(h="@",g=0;g<t.length;g++)h+=Qn(t[g])+",";Yr.set(t,h)}if(s){h="#";const c=Hn.keys(t).sort();for(;!je(g=c.pop());)je(t[g])||(h+=g+":"+Qn(t[g])+",");Yr.set(t,h)}}else h=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return h},ga=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Qn(t):"",[t,r]};let fd=0;const Xn=()=>++fd;async function qi(...t){const[r,o,n,a]=t,s=Et({populateCache:!0,throwOnError:!0},typeof a=="boolean"?{revalidate:a}:a||{});let h=s.populateCache;const g=s.rollbackOnError;let c=s.optimisticData;const p=m=>typeof g=="function"?g(m):g!==!1,l=s.throwOnError;if(lt(o)){const m=o,x=[],v=r.keys();for(const w of v)!/^\$(inf|sub)\$/.test(w)&&m(r.get(w)._k)&&x.push(w);return Promise.all(x.map(d))}return d(o);async function d(m){const[x]=ga(m);if(!x)return;const[v,w]=Hi(r,x),[$,z,y,C]=vt.get(r),k=()=>{const R=$[x];return(lt(s.revalidate)?s.revalidate(v().data,m):s.revalidate!==!1)&&(delete y[x],delete C[x],R&&R[0])?R[0](Vi).then(()=>v().data):v().data};if(t.length<3)return k();let S=n,b,f=!1;const E=Xn();z[x]=[E,0];const j=!je(c),_=v(),I=_.data,P=_._c,T=je(P)?I:P;if(j&&(c=lt(c)?c(T,I):c,w({data:c,_c:T})),lt(S))try{S=S(T)}catch(R){b=R,f=!0}if(S&&Gi(S))if(S=await S.catch(R=>{b=R,f=!0}),E!==z[x][0]){if(f)throw b;return S}else f&&j&&p(b)&&(h=!0,w({data:T,_c:Ge}));if(h&&!f)if(lt(h)){const R=h(S,T);w({data:R,error:Ge,_c:Ge})}else w({data:S,error:Ge,_c:Ge});if(z[x][1]=Xn(),Promise.resolve(k()).then(()=>{w({_c:Ge})}),f){if(l)throw b;return}return S}}const Aa=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},gd=(t,r)=>{if(!vt.has(t)){const o=Et(dd,r),n=Object.create(null),a=qi.bind(Ge,t);let s=$t;const h=Object.create(null),g=(l,d)=>{const m=h[l]||[];return h[l]=m,m.push(d),()=>m.splice(m.indexOf(d),1)},c=(l,d,m)=>{t.set(l,d);const x=h[l];if(x)for(const v of x)v(d,m)},p=()=>{if(!vt.has(t)&&(vt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),a,c,g]),!Ar)){const l=o.initFocus(setTimeout.bind(Ge,Aa.bind(Ge,n,Ui))),d=o.initReconnect(setTimeout.bind(Ge,Aa.bind(Ge,n,Wi)));s=()=>{l&&l(),d&&d(),vt.delete(t)}}};return p(),[t,a,p,s]}return[t,vt.get(t)[4]]},md=(t,r,o,n,a)=>{const s=o.errorRetryCount,h=a.retryCount,g=~~((Math.random()+.5)*(1<<(h<8?h:8)))*o.errorRetryInterval;!je(s)&&h>s||setTimeout(n,g,a)},xd=Gn,[Yi,vd]=gd(new Map),bd=Et({onLoadingSlow:$t,onSuccess:$t,onError:$t,onErrorRetry:md,onDiscarded:$t,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:La?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:La?5e3:3e3,compare:xd,isPaused:()=>!1,cache:Yi,mutate:vd,fallback:{}},ld),yd=(t,r)=>{const o=Et(t,r);if(r){const{use:n,fallback:a}=t,{use:s,fallback:h}=r;n&&s&&(o.use=n.concat(s)),a&&h&&(o.fallback=Et(a,h))}return o},wd=i.createContext({}),jd="$inf$",Zi=Br&&window.__SWR_DEVTOOLS_USE__,kd=Zi?window.__SWR_DEVTOOLS_USE__:[],_d=()=>{Zi&&(window.__SWR_DEVTOOLS_REACT__=i)},Cd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],Sd=()=>Et(bd,i.useContext(wd)),$d=t=>(r,o,n)=>t(r,o&&((...s)=>{const[h]=ga(r),[,,,g]=vt.get(Yi);if(h.startsWith(jd))return o(...s);const c=g[h];return je(c)?o(...s):(delete g[h],c)}),n),zd=kd.concat($d),Ed=t=>function(...o){const n=Sd(),[a,s,h]=Cd(o),g=yd(n,h);let c=t;const{use:p}=g,l=(p||[]).concat(zd);for(let d=l.length;d--;)c=l[d](c);return c(a,s||g.fetcher||null,g)},Pd=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const a=n.indexOf(o);a>=0&&(n[a]=n[n.length-1],n.pop())}};_d();const pn=i.use||(t=>{switch(t.status){case"pending":throw t;case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t.status="pending",t.then(r=>{t.status="fulfilled",t.value=r},r=>{t.status="rejected",t.reason=r}),t}}),hn={dedupe:!0},Rd=(t,r,o)=>{const{cache:n,compare:a,suspense:s,fallbackData:h,revalidateOnMount:g,revalidateIfStale:c,refreshInterval:p,refreshWhenHidden:l,refreshWhenOffline:d,keepPreviousData:m}=o,[x,v,w,$]=vt.get(n),[z,y]=ga(t),C=i.useRef(!1),k=i.useRef(!1),S=i.useRef(z),b=i.useRef(r),f=i.useRef(o),E=()=>f.current,j=()=>E().isVisible()&&E().isOnline(),[_,I,P,T]=Hi(n,z),R=i.useRef({}).current,O=je(h)?je(o.fallback)?Ge:o.fallback[z]:h,D=(q,A)=>{for(const B in R){const L=B;if(L==="data"){if(!a(q[L],A[L])&&(!je(q[L])||!a(G,A[L])))return!1}else if(A[L]!==q[L])return!1}return!0},M=i.useMemo(()=>{const q=!z||!r?!1:je(g)?E().isPaused()||s?!1:c!==!1:g,A=Se=>{const Ne=Et(Se);return delete Ne._k,q?{isValidating:!0,isLoading:!0,...Ne}:Ne},B=_(),L=T(),W=A(B),te=B===L?W:A(L);let pe=W;return[()=>{const Se=A(_());return D(Se,pe)?(pe.data=Se.data,pe.isLoading=Se.isLoading,pe.isValidating=Se.isValidating,pe.error=Se.error,pe):(pe=Se,Se)},()=>te]},[n,z]),Y=rd.useSyncExternalStore(i.useCallback(q=>P(z,(A,B)=>{D(B,A)||q()}),[n,z]),M[0],M[1]),N=!C.current,J=x[z]&&x[z].length>0,ae=Y.data,ee=je(ae)?O&&Gi(O)?pn(O):O:ae,F=Y.error,U=i.useRef(ee),G=m?je(ae)?je(U.current)?ee:U.current:ae:ee,X=J&&!je(F)?!1:N&&!je(g)?g:E().isPaused()?!1:s?je(ee)?!1:c:je(ee)||c,se=!!(z&&r&&N&&X),oe=je(Y.isValidating)?se:Y.isValidating,ce=je(Y.isLoading)?se:Y.isLoading,K=i.useCallback(async q=>{const A=b.current;if(!z||!A||k.current||E().isPaused())return!1;let B,L,W=!0;const te=q||{},pe=!w[z]||!te.dedupe,Se=()=>Ma?!k.current&&z===S.current&&C.current:z===S.current,Ne={isValidating:!1,isLoading:!1},H=()=>{I(Ne)},ne=()=>{const be=w[z];be&&be[1]===L&&delete w[z]},ye={isValidating:!0};je(_().data)&&(ye.isLoading=!0);try{if(pe&&(I(ye),o.loadingTimeout&&je(_().data)&&setTimeout(()=>{W&&Se()&&E().onLoadingSlow(z,o)},o.loadingTimeout),w[z]=[A(y),Xn()]),[B,L]=w[z],B=await B,pe&&setTimeout(ne,o.dedupingInterval),!w[z]||w[z][1]!==L)return pe&&Se()&&E().onDiscarded(z),!1;Ne.error=Ge;const be=v[z];if(!je(be)&&(L<=be[0]||L<=be[1]||be[1]===0))return H(),pe&&Se()&&E().onDiscarded(z),!1;const re=_().data;Ne.data=a(re,B)?re:B,pe&&Se()&&E().onSuccess(B,z,o)}catch(be){ne();const re=E(),{shouldRetryOnError:$e}=re;re.isPaused()||(Ne.error=be,pe&&Se()&&(re.onError(be,z,re),($e===!0||lt($e)&&$e(be))&&(!E().revalidateOnFocus||!E().revalidateOnReconnect||j())&&re.onErrorRetry(be,z,re,fe=>{const ke=x[z];ke&&ke[0]&&ke[0](Ta,fe)},{retryCount:(te.retryCount||0)+1,dedupe:!0})))}return W=!1,H(),!0},[z,n]),ie=i.useCallback((...q)=>qi(n,S.current,...q),[]);if(ln(()=>{b.current=r,f.current=o,je(ae)||(U.current=ae)}),ln(()=>{if(!z)return;const q=K.bind(Ge,hn);let A=0;E().revalidateOnFocus&&(A=Date.now()+E().focusThrottleInterval);const L=Pd(z,x,(W,te={})=>{if(W==Ui){const pe=Date.now();E().revalidateOnFocus&&pe>A&&j()&&(A=pe+E().focusThrottleInterval,q())}else if(W==Wi)E().revalidateOnReconnect&&j()&&q();else{if(W==Vi)return K();if(W==Ta)return K(te)}});return k.current=!1,S.current=z,C.current=!0,I({_k:y}),X&&(w[z]||(je(ee)||Ar?q():ud(q))),()=>{k.current=!0,L()}},[z]),ln(()=>{let q;function A(){const L=lt(p)?p(_().data):p;L&&q!==-1&&(q=setTimeout(B,L))}function B(){!_().error&&(l||E().isVisible())&&(d||E().isOnline())?K(hn).then(A):A()}return A(),()=>{q&&(clearTimeout(q),q=-1)}},[p,l,d,z]),i.useDebugValue(G),s&&je(ee)&&z){if(!Ma&&Ar)throw new Error("Fallback data is required when using Suspense in SSR.");b.current=r,f.current=o,k.current=!1;const q=$[z];if(!je(q)){const A=ie(q);pn(A)}if(je(F)){const A=K(hn);je(G)||(A.status="fulfilled",A.value=!0),pn(A)}else throw F}return{mutate:ie,get data(){return R.data=!0,G},get error(){return R.error=!0,F},get isValidating(){return R.isValidating=!0,oe},get isLoading(){return R.isLoading=!0,ce}}},We=Ed(Rd);async function V(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}const r=await t.json();return{data:r.data,errors:r.errors}}function Ki(t){const{client:r}=De(),o=i.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await V(c)).data},[r,t]),{data:n,error:a,mutate:s}=We(t?`sessions-${t}`:null,o,{revalidateOnFocus:!1}),h=i.useCallback(async c=>{const p=new FormData;p.append("title",c.title),c.system_instructions&&p.append("system_instructions",c.system_instructions);const l=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:p}),d=await V(l);return await s(m=>m&&{...m,data:[d.data,...m.data]}),d.data},[r,t,s]),g=i.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await s(p=>p&&{...p,data:p.data.filter(l=>l.id!==c)})},[r,t,s]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!a,error:a,createSession:h,deleteSession:g,refetch:async()=>{await s()}}}const Qi=i.createContext(void 0);function Uo(){const t=i.useContext(Qi);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Id({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:a,onSessionCreated:s,onSessionDeleted:h,onError:g}){const[c,p]=i.useState(a?{id:a,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[l,d]=i.useState(!1),{sessions:m,loading:x,error:v,createSession:w,deleteSession:$,refetch:z}=Ki(o);i.useEffect(()=>{if(a&&m.length>0){const b=m.find(f=>f.id===a);b&&p(b)}},[a,m]);const y=i.useCallback(b=>{p(b),d(!1)},[]),C=i.useCallback(async b=>{try{const f=b||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,E=await w({title:f});return p(E),s==null||s(E),E}catch(f){const E=f instanceof Error?f.message:"Failed to create session";throw g==null||g(E),f}},[w,s,g]),k=i.useCallback(async b=>{try{await $(b),(c==null?void 0:c.id)===b&&p(null),h==null||h(b)}catch(f){const E=f instanceof Error?f.message:"Failed to delete session";throw g==null||g(E),f}},[$,c,h,g]),S={agentName:r,token:o,platformAdapter:n,sessions:m,selectedSession:c,loadingSessions:x,sessionError:v,selectSession:y,createSession:C,deleteSession:k,refreshSessions:z,showHistory:l,setShowHistory:d,onSessionCreated:s,onSessionDeleted:h,onError:g};return e.jsx(Qi.Provider,{value:S,children:t})}var Xi=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(Xi||{});function Td(t,r,o){const n={username:Od(t,r,o),email:Md(t,r,o),phone:Ld(t,r,o),email_otp:Ad(t,r,o),magic_link:Dd(t,r,o),oauth:Nd(t,o),generic:Fd(t,r,o)};return function(s){return n[s]}}function Od(t,r,o){return async({username:n,password:a})=>{var c,p;const s=new FormData;s.append("strategy","plain_username"),s.append("username",n),s.append("password",a);const h=await t("/auth/signin",{method:"POST",body:s}),g=await V(h);return"data"in g&&((p=(c=g.data)==null?void 0:c.signin_attempts)!=null&&p.length)?(r(g.data.signin_attempts.at(-1)||null),o(null)):o(g),g}}function Md(t,r,o){return async({email:n,password:a})=>{var c,p;const s=new FormData;s.append("strategy","plain_email"),s.append("email",n),s.append("password",a);const h=await t("/auth/signin",{method:"POST",body:s}),g=await V(h);return"data"in g&&((p=(c=g.data)==null?void 0:c.signin_attempts)!=null&&p.length)?(r(g.data.signin_attempts.at(-1)||null),o(null)):o(g),g}}function Ld(t,r,o){return async({phone:n})=>{var g,c;const a=new FormData;a.append("strategy","phone_otp"),a.append("phone",n);const s=await t("/auth/signin",{method:"POST",body:a}),h=await V(s);return"data"in h&&((c=(g=h.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(h.data.signin_attempts.at(-1)||null),o(null)):o(h),h}}function Ad(t,r,o){return async({email:n})=>{var g,c;const a=new FormData;a.append("strategy","email_otp"),a.append("email",n);const s=await t("/auth/signin",{method:"POST",body:a}),h=await V(s);return"data"in h&&((c=(g=h.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(h.data.signin_attempts.at(-1)||null),o(null)):o(h),h}}function Dd(t,r,o){return async({email:n})=>{var g,c;const a=new FormData;a.append("strategy","magic_link"),a.append("email",n);const s=await t("/auth/signin",{method:"POST",body:a}),h=await V(s);return"data"in h&&((c=(g=h.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(h.data.signin_attempts.at(-1)||null),o(null)):o(h),h}}function Nd(t,r){return async({provider:o,redirectUri:n})=>{const a=new URLSearchParams({provider:o});n&&a.append("redirect_uri",n);const s=await t(`/auth/oauth2/init?${a.toString()}`,{method:"POST"}),h=await V(s);return"data"in h?(r(null),h.data.oauth_url&&(window.location.href=h.data.oauth_url)):r(h),h}}function Fd(t,r,o){return async({email:n,username:a,password:s,phone:h,strategy:g,token:c})=>{var m,x;const p=new FormData;g&&p.append("strategy",g),n&&p.append("email",n),a&&p.append("username",a),s&&p.append("password",s),h&&p.append("phone",h),c&&p.append("token",c);const l=await t("/auth/signin",{method:"POST",body:p}),d=await V(l);return"data"in d&&((x=(m=d.data)==null?void 0:m.signin_attempts)!=null&&x.length)?(r(d.data.signin_attempts.at(-1)||null),o(null)):o(d),d}}function Ji(){const{client:t,loading:r}=De(),[o,n]=i.useState(null),[a,s]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null),s(null)},setSignInAttempt:n,error:null}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Td(t,n,s),completeVerification:async h=>{var l,d,m,x;const g=new FormData;g.append("verification_code",h);const c=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:g}),p=await V(c);if("data"in p&&((d=(l=p.data)==null?void 0:l.signin_attempts)!=null&&d.length)){const v=p.data.signin_attempts.at(-1);return n(v||null),s(null),p.data}else throw"errors"in p?(s(p),new Error(((x=(m=p.errors)==null?void 0:m[0])==null?void 0:x.message)||"Verification failed")):new Error("Verification failed")},prepareVerification:async h=>{var p;const g=new URL("/auth/prepare-verification",window.location.origin);g.searchParams.set("attempt_identifier",((p=o==null?void 0:o.id)==null?void 0:p.toString())||""),g.searchParams.set("strategy",h.strategy),g.searchParams.set("identifier_type","signin"),h.strategy==="phone_otp"&&h.lastDigits?g.searchParams.set("last_digits",h.lastDigits):(h.strategy==="email_otp"&&h.redirectUri||h.strategy==="magic_link"&&h.redirectUri)&&g.searchParams.set("redirect_uri",h.redirectUri);const c=await t(g.pathname+g.search,{method:"POST"});return V(c)},completeProfile:async h=>{var l;if(!o)throw new Error("No signin attempt found");const g=new FormData;for(const[d,m]of Object.entries(h))m&&g.append(d,m);const c=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:g}),p=await V(c);if("data"in p&&p.data){const d=(l=p.data.signin_attempts)==null?void 0:l.find(m=>m.id===o.id);return d&&n(d),s(null),p.data}else throw new Error("Profile completion failed")}},discardSignInAttempt:()=>{n(null),s(null)},setSignInAttempt:n,error:a}}function Dr(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:a,setSignInAttempt:s,error:h}=Ji();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:a,setSignInAttempt:s,error:null};const g=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:g,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile},discardSignInAttempt:a,setSignInAttempt:s,error:h}}function Bd(t,r,o,n){return{create:async a=>{var c,p,l;const s=new FormData;for(const[d,m]of Object.entries(a))s.append(d,m);const h=await t("/auth/signup",{method:"POST",body:s}),g=await V(h);return"data"in g&&((p=(c=g.data)==null?void 0:c.signup_attempts)!=null&&p.length)?(o(((l=g.data.signup_attempts)==null?void 0:l.at(-1))||null),n(null)):n(g),g},prepareVerification:async a=>{var g;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((g=r==null?void 0:r.id)==null?void 0:g.toString())||""),s.searchParams.set("strategy",a.strategy),s.searchParams.set("identifier_type","signup"),a.strategy==="phone_otp"&&a.lastDigits?s.searchParams.set("last_digits",a.lastDigits):a.strategy==="email_otp"&&a.redirectUri&&s.searchParams.set("redirect_uri",a.redirectUri);const h=await t(s.pathname+s.search,{method:"POST"});return V(h)},completeVerification:async a=>{var c,p,l,d;const s=new FormData;s.append("verification_code",a);const h=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),g=await V(h);if("data"in g&&((p=(c=g.data)==null?void 0:c.signup_attempts)!=null&&p.length))o(g.data.signup_attempts.at(-1)||null),n(null);else if("errors"in g)throw n(g),new Error(((d=(l=g.errors)==null?void 0:l[0])==null?void 0:d.message)||"Verification failed");return g},validateDeploymentInvitation:async a=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(a)}`,{method:"GET"}),h=await V(s);return"data"in h&&h.data?h.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(s){return{valid:!1,message:s.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function ec(){const{client:t,loading:r}=De(),[o,n]=i.useState(null),[a,s]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null),s(null)},errors:null}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null),s(null)},signUp:Bd(t,o,n,s),errors:a}}const He=()=>{const{adapter:t,deployment:r}=xe(),o=t.useNavigate(),n=(g,c)=>{o?o(g,c):window.location.href=g};return{navigate:n,navigateToSignIn:g=>{if(!r)return;const c=g||window.location.href,p=new URLSearchParams;p.set("redirect_uri",c),(r==null?void 0:r.mode)==="staging"&&p.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${p.toString()}`,{replace:!0})},navigateToAccountSelection:g=>{if(!r)return;const c=g||window.location.href,p=new URLSearchParams;p.set("redirect_uri",c),(r==null?void 0:r.mode)==="staging"&&p.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.frontend_host}?${p.toString()}`,{replace:!0})},navigateToSignUp:g=>{if(!r)return;const c=g||window.location.href,p=new URLSearchParams;p.set("redirect_uri",c),(r==null?void 0:r.mode)==="staging"&&p.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${p.toString()}`,{replace:!0})}}};async function Ud(t){const r=await t("/session",{method:"GET"});return(await V(r)).data}async function Wd(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return V(o)}async function Vd(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return V(n)}async function Gd(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return V(o)}async function Hd(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return V(o)}const Jn=new Map,Tr=new Map;function Qt(){Jn.clear(),Tr.clear()}async function qd(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return V(o)}function Fe(){const{client:t,loading:r}=De(),{deployment:o}=xe(),{navigate:n}=He(),{data:a,error:s,mutate:h,isLoading:g}=We(r?null:"/session",()=>Ud(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),c=i.useCallback(async()=>{await h(void 0,{revalidate:!0})},[h]),p=i.useCallback(async(d="default")=>{var v;if(!a)throw new Error("no session");const m=Jn.get(d);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";Tr.get(d)||Tr.set(d,qd(t,d));const x=await Tr.get(d);if(Tr.delete(d),(v=x.errors)!=null&&v.length)throw new Error(x.errors[0].message);return Jn.set(d,x.data),x.data.token},[t,a==null?void 0:a.active_signin]),l=i.useCallback(()=>{if(!o)return;const d=o.ui_settings.sign_in_page_url,m=window.location.href,x=new URL(d);if(x.searchParams.set("redirect_uri",m),o.mode==="staging"){const v=localStorage.getItem("__dev_session__");v&&x.searchParams.set("dev_session",v)}n(x.toString())},[o,n]);return r||!a||g?{loading:!0,error:s,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,addNewAccount:null,refetch:c}:{loading:g,error:s,session:a,switchSignIn:async d=>{await Wd(t,d),await h(void 0,{revalidate:!0})},signOut:async d=>{await Vd(t,d),await h(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(d&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!d&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async d=>{await Gd(t,d),Qt(),await h(void 0,{revalidate:!0})},switchWorkspace:async d=>{await Hd(t,d),Qt(),await h(void 0,{revalidate:!0})},getToken:p,addNewAccount:l,refetch:c}}const Wo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=bt(),{client:n}=De(),{refetch:a}=Fe(),s=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/roles`,{method:"GET"}))).data,[n]),h=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/members`,{method:"GET"}))).data,[n]),g=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/domains`,{method:"GET"}))).data,[n]),p=i.useCallback(async(j,_)=>{await n(`/organizations/${j.id}/members/${_.id}/remove`,{method:"POST"}),await r()},[r,n]),l=i.useCallback(async j=>{const _=new FormData;_.append("name",j.name),j.image&&_.append("image",j.image),j.description&&_.append("description",j.description);const I=await V(await n("/organizations",{method:"POST",body:_}));return Qt(),await r(),await a(),I},[a,r,n]),d=i.useCallback(async(j,_)=>{const I=Object.entries(_).reduce((T,[R,O])=>(O&&T.append(R,O),T),new FormData),P=await V(await n(`/organizations/${j.id}/update`,{method:"POST",body:I}));return await r(),P},[r,n]),m=i.useCallback(async(j,_)=>{await n(`/organizations/${j.id}/roles/${_.id}/remove`,{method:"POST"})},[n]),x=i.useCallback(async(j,_)=>{const I=new FormData;return I.append("domain",_.fqdn),await V(await n(`/organizations/${j.id}/domains`,{method:"POST",body:I}))},[n]),v=i.useCallback(async(j,_)=>await V(await n(`/organizations/${j.id}/domains/${_.id}/verify`,{method:"POST"})),[n]),w=i.useCallback(async(j,_)=>await V(await n(`/organizations/${j.id}/domains/${_.id}/remove`,{method:"POST"})),[n]),$=i.useCallback(async(j,_)=>{const I=new FormData;return I.append("name",_.name),_.permissions&&_.permissions.forEach((T,R)=>{I.append(`permissions[${R}]`,T)}),await V(await n(`/organizations/${j.id}/roles`,{method:"POST",body:I}))},[n]),z=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/leave`,{method:"POST"}))).data,[n]),y=i.useCallback(async j=>{const _=await V(await n(`/organizations/${j.id}/delete`,{method:"POST"}));return Qt(),await r(),await a(),_.data},[n,r,a]),C=i.useCallback(async(j,_,I)=>(await V(await n(`/organizations/${j.id}/members/${_.id}/roles/${I.id}/add`,{method:"POST"}))).data,[n]),k=i.useCallback(async(j,_,I)=>(await V(await n(`/organizations/${j.id}/members/${_.id}/roles/${I.id}/remove`,{method:"POST"}))).data,[n]),S=i.useCallback(async(j,_)=>{var T,R;const I=new FormData;return I.append("email",_.email),I.append("role_id",_.organizationRole.id),(T=_.workspace)!=null&&T.id&&I.append("workspace_id",_.workspace.id),(R=_.workspaceRole)!=null&&R.id&&I.append("workspace_role_id",_.workspaceRole.id),(await V(await n(`/organizations/${j.id}/invitations`,{method:"POST",body:I}))).data},[n]),b=i.useCallback(async(j,_)=>(await V(await n(`/organizations/${j.id}/invitations/${_.id}/remove`,{method:"POST"}))).data,[n]),f=i.useCallback(async(j,_)=>(await V(await n(`/organizations/${j.id}/invitations/${_.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(j=>j.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:z,getOrganizationRoles:s,getOrganizationMembers:h,removeOrganizationMember:p,createOrganization:l,getOrganizationInvitations:g,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:w,addRoleToOrganizationMember:C,removeRoleFromOrganizationMember:k,inviteOrganizationMember:S,discardOrganizationInvitation:b,resendOrganizationInvitation:f,updateOrganization:d,addRole:$,removeOrganizationRoles:m,deleteOrganization:y}},Qe=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:a,leaveOrganization:s,removeOrganizationMember:h,getOrganizationInvitations:g,getOrganizationDomains:c,removeOrganizationDomain:p,addOrganizationDomain:l,verifyOrganizationDomain:d,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:w,resendOrganizationInvitation:$,updateOrganization:z,removeOrganizationRoles:y}=Wo(),{session:C,error:k,loading:S}=Fe(),{organizationMemberships:b}=bt(),f=i.useMemo(()=>{var U;return((U=b==null?void 0:b.find(G=>{var X;return G.id===((X=C==null?void 0:C.active_signin)==null?void 0:X.active_organization_membership_id)}))==null?void 0:U.organization)||null},[b,C]),E=i.useCallback(async U=>f?await z(f,U):[],[f,z]),j=i.useCallback(async()=>f?await n(f):[],[f,n]),_=i.useCallback(async()=>f?await a(f):[],[f,a]),I=i.useCallback(async U=>f?await h(f,U):[],[f,h]),P=i.useCallback(async U=>f?await y(f,U):void 0,[f,y]),T=i.useCallback(async()=>f?await c(f):[],[f,c]),R=i.useCallback(async U=>f?await l(f,U):void 0,[f,l]),O=i.useCallback(async U=>f?await d(f,U):void 0,[f,d]),D=i.useCallback(async U=>f?await p(f,U):void 0,[f,p]),M=i.useCallback(async(U,G)=>f?await m(f,U,G):void 0,[f,m]),Y=i.useCallback(async(U,G)=>f?await x(f,U,G):void 0,[f,x]),N=i.useCallback(async U=>f?await v(f,U):void 0,[f,v]),J=i.useCallback(async U=>f?await w(f,U):void 0,[f,w]),ae=i.useCallback(async U=>f?await $(f,U):void 0,[f,$]),ee=i.useCallback(async()=>{f&&await s(f)},[f,s]),F=i.useCallback(async()=>f?await g(f):[],[f,g]);return S||t?{activeOrganization:null,loading:!0,error:k||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null}:{activeOrganization:f,loading:!1,refetch:o,getRoles:_,updateOrganization:E,getMembers:j,getDomains:T,addDomain:R,verifyDomain:O,removeDomain:D,getInvitations:F,removeMember:I,leave:ee,removeRole:P,addMemberRole:M,removeMemberRole:Y,inviteMember:N,discardInvitation:J,resendInvitation:ae,error:null}};async function Yd(t){return(await V(await t("/me/organization-memberships"))).data}const bt=()=>{const{client:t,loading:r}=De(),{data:o,isLoading:n,error:a,mutate:s}=We(r?null:"/me/organization-memberships",()=>Yd(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=i.useCallback(async()=>{await s(void 0,{revalidate:!0})},[s]);return{organizationMemberships:o,loading:r||n,error:a,refetch:h}};async function Zd(t){return(await V(await t("/me/workspace-memberships"))).data}async function Kd(t,r,o){return(await V(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Vo=()=>{const{client:t,loading:r}=De(),{deployment:o}=xe(),{data:n,isLoading:a,error:s,mutate:h}=We(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>Zd(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),g=i.useCallback(async()=>{await h(void 0,{revalidate:!0})},[h]);return{workspaceMemberships:n,loading:r||a,error:s,refetch:g}},yt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Vo(),{client:a}=De(),s=i.useMemo(()=>t==null?void 0:t.map(y=>({...y.workspace,organization:y.organization,eligibility_restriction:y.eligibility_restriction})),[t]),h=i.useCallback(async(y,C,k,S)=>{const b=new FormData;b.append("name",C),k&&b.append("image",k),S&&b.append("description",S),b.append("organization_id",y);const f=await V(await a("/workspaces",{method:"POST",body:b}));return Qt(),await r(),f.data},[a,r]),g=i.useCallback(async(y,C)=>{const k=await Kd(a,y,C);return await r(),k},[a,r]),c=i.useCallback(async(y,C)=>{const k=new FormData;C.name&&k.append("name",C.name),C.description&&k.append("description",C.description),C.image&&k.append("image",C.image),C.enforce_2fa!==void 0&&k.append("enforce_2fa",String(C.enforce_2fa)),C.enable_ip_restriction!==void 0&&k.append("enable_ip_restriction",String(C.enable_ip_restriction)),C.whitelisted_ips&&C.whitelisted_ips.forEach(b=>k.append("whitelisted_ips",b));const S=await V(await a(`/workspaces/${y.id}/update`,{method:"POST",body:k}));return await r(),S.data},[a,r]),p=i.useCallback(async y=>{const C=await V(await a(`/workspaces/${y.id}/delete`,{method:"POST"}));return Qt(),await r(),C.data},[a,r]),l=i.useCallback(async y=>(await V(await a(`/workspaces/${y.id}/members`,{method:"GET"}))).data,[a]),d=i.useCallback(async y=>(await V(await a(`/workspaces/${y.id}/roles`,{method:"GET"}))).data,[a]),m=i.useCallback(async(y,C,k)=>(await V(await a(`/workspaces/${y.id}/roles`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:C,permissions:k})}))).data,[a]),x=i.useCallback(async(y,C)=>(await V(await a(`/workspaces/${y.id}/roles/${C.id}/delete`,{method:"POST"}))).data,[a]),v=i.useCallback(async(y,C,k)=>(await V(await a(`/workspaces/${y.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:C,role_id:k})}))).data,[a]),w=i.useCallback(async(y,C)=>{const k=await V(await a(`/workspaces/${y.id}/members/${C}/remove`,{method:"POST"}));return await r(),k.data},[a,r]),$=i.useCallback(async(y,C,k)=>(await V(await a(`/workspaces/${y.id}/members/${C}/roles/${k}/add`,{method:"POST"}))).data,[a]),z=i.useCallback(async(y,C,k)=>(await V(await a(`/workspaces/${y.id}/members/${C}/roles/${k}/remove`,{method:"POST"}))).data,[a]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:g,createWorkspace:h,updateWorkspace:c,deleteWorkspace:p,getWorkspaceMembers:l,getWorkspaceRoles:d,createWorkspaceRole:m,deleteWorkspaceRole:x,inviteWorkspaceMember:v,removeWorkspaceMember:w,addWorkspaceMemberRole:$,removeWorkspaceMemberRole:z}},Pt=()=>{const{refetch:t,loading:r,error:o,leaveWorkspace:n,updateWorkspace:a,deleteWorkspace:s,getWorkspaceMembers:h,getWorkspaceRoles:g,createWorkspaceRole:c,deleteWorkspaceRole:p,inviteWorkspaceMember:l,removeWorkspaceMember:d,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x}=yt(),{workspaceMemberships:v}=Vo(),{session:w,loading:$,error:z}=Fe(),y=i.useMemo(()=>{var D;return((D=v==null?void 0:v.find(M=>{var Y;return M.id===((Y=w==null?void 0:w.active_signin)==null?void 0:Y.active_workspace_membership_id)}))==null?void 0:D.workspace)||null},[v,w]),C=i.useCallback(async()=>{var D;if(!(!y||!((D=w==null?void 0:w.active_signin)!=null&&D.user_id)))return await n(y.id,w.active_signin.user_id)},[y,n,w]),k=i.useCallback(async D=>{if(y)return await a(y,D)},[y,a]),S=i.useCallback(async()=>{if(y)return await s(y)},[y,s]),b=i.useCallback(async()=>y?await h(y):[],[y,h]),f=i.useCallback(async()=>y?await g(y):[],[y,g]),E=i.useCallback(async(D,M)=>{if(y)return await c(y,D,M)},[y,c]),j=i.useCallback(async D=>{if(y)return await p(y,D)},[y,p]),_=i.useCallback(async(D,M)=>{if(y)return await l(y,D,M)},[y,l]),I=i.useCallback(async D=>{if(y)return await d(y,D)},[y,d]),P=i.useCallback(async(D,M)=>{if(y)return await m(y,D,M)},[y,m]),T=i.useCallback(async(D,M)=>{if(y)return await x(y,D,M)},[y,x]),R=r||$,O=o||z;return R?{activeWorkspace:null,loading:!0,error:O,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null}:{activeWorkspace:y,loading:!1,error:O,refetch:t,leave:C,updateWorkspace:k,deleteWorkspace:S,getMembers:b,getRoles:f,createRole:E,deleteRole:j,inviteMember:_,removeMember:I,addMemberRole:P,removeMemberRole:T}},Qd=async t=>(await V(await t("/me"))).data,Xd=async t=>(await V(await t("/me/signins"))).data;function rr(){const{client:t,loading:r}=De(),{data:o,error:n,isLoading:a,mutate:s}=We(r?null:"/user",()=>Qd(t)),h=async R=>{const O=new FormData;for(const[M,Y]of Object.entries(R))Y!=null&&Y!==""&&O.append(M,String(Y));const D=await V(await t("/me",{method:"POST",body:O}));return s(),D},g=async()=>await V(await t("/me/email-addresses",{method:"GET"})),c=async R=>await V(await t(`/me/email-addresses/${R}`,{method:"GET"})),p=async R=>{const O=new FormData;return O.append("email",R),await V(await t("/me/email-addresses",{method:"POST",body:O}))},l=async R=>await V(await t(`/me/email-addresses/${R}/delete`,{method:"POST"})),d=async R=>await V(await t(`/me/email-addresses/${R}/prepare-verification`,{method:"POST"})),m=async(R,O)=>await V(await t(`/me/email-addresses/${R}/attempt-verification?code=${O}`,{method:"POST"})),x=async(R,O)=>{const D=new FormData;return D.append("phone_number",R),D.append("country_code",O),await V(await t("/me/phone-numbers",{method:"POST",body:D}))},v=async R=>await V(await t(`/me/phone-numbers/${R}/delete`,{method:"POST"})),w=async R=>await V(await t(`/me/phone-numbers/${R}/prepare-verification`,{method:"POST"})),$=async(R,O)=>{const D=new FormData;return D.append("code",O),await V(await t(`/me/phone-numbers/${R}/attempt-verification`,{method:"POST",body:D}))},z=async R=>{const O=await V(await t(`/me/phone-numbers/${R}/make-primary`,{method:"POST"}));return s(),O},y=async R=>await V(await t(`/me/email-addresses/${R}/make-primary`,{method:"POST"})),C=async()=>(await V(await t("/me/authenticator",{method:"POST"}))).data,k=async(R,O)=>{const D=new FormData;return D.append("authenticator_id",R),O.forEach(Y=>{D.append("codes",Y)}),await V(await t("/me/authenticator/attempt-verification",{method:"POST",body:D}))},S=async R=>await V(await t(`/me/authenticator/${R}/delete`,{method:"POST"})),b=async()=>(await V(await t("/me/backup-codes",{method:"POST"}))).data,f=async R=>{const O=new FormData;return O.append("file",R),await V(await t("/me/profile-picture",{method:"POST",body:O}))},E=async()=>(await V(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,j=async(R,O)=>{const D=new FormData;return D.append("current_password",R),D.append("new_password",O),await V(await t("/me/update-password",{method:"POST",body:D}))},_=async R=>{const O=new FormData;O.append("current_password",R);const D=await V(await t("/me/remove-password",{method:"POST",body:O}));return s(),D},I=async R=>{const O=new FormData;return O.append("password",R),await V(await t("/me/account/delete",{method:"POST",body:O}))},P=async R=>await V(await t(`/me/social-connections/${R}/disconnect`,{method:"POST"})),T=async({provider:R,redirectUri:O})=>{var Y;const D=new URLSearchParams({provider:R});O&&D.append("redirect_uri",O);const M=await V(await t(`/me/init-sso-connection?${D.toString()}`,{method:"POST"}));return"data"in M&&((Y=M.data)!=null&&Y.oauth_url)&&window.open(M.data.oauth_url,"_blank"),M};return{user:{...o,refetch:s},loading:r||a,error:n||null,updateProfile:h,getEmailAddresses:g,getEmailAddress:c,createEmailAddress:p,deleteEmailAddress:l,prepareEmailVerification:d,attemptEmailVerification:m,makeEmailPrimary:y,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:w,attemptPhoneVerification:$,makePhonePrimary:z,setupAuthenticator:C,verifyAuthenticator:k,deleteAuthenticator:S,generateBackupCodes:b,regenerateBackupCodes:E,updateProfilePicture:f,disconnectSocialConnection:P,connectSocialAccount:T,updatePassword:j,removePassword:_,deleteAccount:I}}function tc(){const{client:t,loading:r}=De(),{data:o,error:n,isLoading:a,mutate:s}=We(r?null:"/me/signins",()=>Xd(t));return{signins:o,error:n||null,removeSignin:async g=>await V(await t(`/me/signins/${g}/signout`,{method:"POST"})),refetch:s,loading:a||r}}function Jd(){const{session:t,loading:r}=Fe(),{loading:o,organizationMemberships:n}=bt(),{loading:a,workspaceMemberships:s}=Vo();if(r||o||a)return{loading:!0,orgMembership:null,workspaceMembership:null};const h=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var p;return c.id===((p=t.active_signin)==null?void 0:p.active_organization_membership_id)}),[t]),g=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(c=>{var p;return c.id===((p=t.active_signin)==null?void 0:p.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:h,workspaceMembership:g}}function rc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),h=async g=>{n(!0),s(null);try{const c=new FormData;for(const[d,m]of Object.entries(g))m&&c.append(d,m);const p=await t("/waitlist/join",{method:"POST",body:c}),l=await V(p);return s(l.errors?l:null),l}catch(c){const p={data:null,errors:[{message:c instanceof Error?c.message:"Failed to join waitlist",code:Ve.ErrorCode.Unknown}]};return s(p),p}finally{n(!1)}};return r?{loading:!0,error:null,joinWaitlist:null}:{loading:o,error:a,joinWaitlist:h}}function oc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[h,g]=i.useState(null),[c,p]=i.useState(null),[l,d]=i.useState(!1),[m,x]=i.useState(null);i.useEffect(()=>{if(l||r)return;const w=new URLSearchParams(window.location.search),$=w.get("code"),z=w.get("state"),y=w.get("error"),C=w.get("error_description");if(!$&&!y){d(!0);const k=new Error("No OAuth callback data found.");s(k);return}if(d(!0),n(!0),y){const k=C||y,S=new Error(`OAuth Error: ${k}`);s(S),n(!1);return}if($&&z)v($,z);else{const k=new Error("Missing required OAuth parameters");s(k),n(!1)}},[l,r]);const v=async(w,$)=>{try{let z,y;try{const S=$.split(".");if(S.length!==2)throw new Error("Invalid OAuth state format - missing signature");const b=S[0].replace(/-/g,"+").replace(/_/g,"/"),f=b.length%4?"=".repeat(4-b.length%4):"",j=atob(b+f).split("|")[0];if(j==="sign_in")z="/auth/oauth2/callback",y="GET";else if(j==="connect_social")z="/me/sso-connection-callback",y="POST";else throw new Error(`Unknown OAuth action: ${j}`)}catch(S){const b=S instanceof Error?S:new Error("Failed to parse OAuth state");s(new Error(`Invalid OAuth callback: ${b.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const C=await t(`${z}?code=${encodeURIComponent(w)}&state=${encodeURIComponent($)}`,{method:y}),k=await V(C);if("data"in k){const S=k.data.session,b=k.data.redirect_uri||null;if(g(S),p(b),S.signin_attempts&&S.signin_attempts.length>0){const f=S.signin_attempts.at(-1);f&&x(f)}}else{const S=new Error("SSO callback failed");s(S)}}catch(z){const y=z instanceof Error?z:new Error("Unknown error occurred");s(y)}finally{n(!1)}};return{loading:o,error:a,session:h,redirectUri:c,processed:l,signinAttempt:m}}function nc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[h,g]=i.useState(null);return{loading:r||o,verifyMagicLink:async p=>{if(!p.token||!p.attempt){const l=new Error("Invalid magic link parameters");return s(l),{data:void 0,errors:[{message:l.message,code:Ve.ErrorCode.BadRequestBody}]}}n(!0),s(null),g(null);try{const l=new URL("/auth/verify-magic-link",window.location.origin);l.searchParams.set("token",p.token),l.searchParams.set("attempt",p.attempt),p.redirectUri&&l.searchParams.set("redirect_uri",p.redirectUri);const d=await t(l.pathname+l.search,{method:"GET"}),m=await V(d);if(n(!1),"errors"in m&&m.errors){const x=new Error(m.errors[0].message);s(x),g(!1)}else g(!0);return m}catch(l){n(!1);const d=l instanceof Error?l:new Error("Magic link verification failed");return s(d),g(!1),{data:void 0,errors:[{message:d.message,code:Ve.ErrorCode.Internal}]}}},error:a,success:h}}function ac(){const[t,r]=i.useState({});return i.useEffect(()=>{const o=new URLSearchParams(window.location.search);r({token:o.get("token")||void 0,attempt:o.get("attempt")||void 0,redirectUri:o.get("redirect_uri")||void 0})},[]),t}function sc(){const{client:t,loading:r}=De(),[o,n]=i.useState(null);return{error:o,loading:r,forgotPassword:async g=>{n(null);const c=new FormData;c.append("email",g);const p=await t("/auth/forgot-password",{method:"POST",body:c}),l=await V(p);return"errors"in l&&l.errors&&n(new Error(l.errors[0].message)),l},verifyOtp:async(g,c)=>{n(null);const p=new FormData;p.append("email",g),p.append("otp",c);const l=await t("/auth/forgot-password",{method:"POST",body:p}),d=await V(l);return"errors"in d&&d.errors&&n(new Error(d.errors[0].message)),d},resetPassword:async(g,c)=>{n(null);const p=new FormData;p.append("token",g),p.append("password",c);const l=await t("/auth/reset-password",{method:"POST",body:p}),d=await V(l);return"errors"in d&&d.errors&&n(new Error(d.errors[0].message)),d}}}function ic({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:a,onError:s,reconnectDelay:h=1e3,maxReconnectAttempts:g=5}={}){const{session:c,loading:p}=Fe(),{deployment:l,loading:d}=xe(),[m,x]=i.useState(!1),[v,w]=i.useState(null),$=i.useRef(null),z=i.useRef(null),y=i.useRef(0),C=i.useRef(null),k=i.useRef(a),S=i.useRef(s),b=i.useRef(r),f=i.useRef(o),E=i.useRef(n),j=i.useRef(h),_=i.useRef(g);k.current=a,S.current=s,b.current=r,f.current=o,E.current=n,j.current=h,_.current=g;const I=i.useCallback(()=>{z.current&&(clearTimeout(z.current),z.current=null),C.current&&(clearInterval(C.current),C.current=null),$.current&&($.current.close(),$.current=null)},[]),P=i.useCallback(async()=>{var Y;if(!t||p||d||!c||!l)return;I();const O=new URL(l.backend_host),D=O.protocol==="https:"?"wss:":"ws:",M=new URL("/realtime/notifications",`${D}//${O.host}`);if(l.mode==="staging"){const N=localStorage.getItem("__dev_session__");N&&M.searchParams.set("__dev_session__",N)}b.current&&b.current.length>0&&b.current.forEach(N=>M.searchParams.append("channels",N)),f.current&&f.current.length>0&&f.current.forEach(N=>M.searchParams.append("organization_ids",N.toString())),E.current&&E.current.length>0&&E.current.forEach(N=>M.searchParams.append("workspace_ids",N.toString()));try{const N=new WebSocket(M.toString());$.current=N,N.onopen=()=>{x(!0),w(null),y.current=0,C.current=setInterval(()=>{N.readyState===WebSocket.OPEN&&N.send("ping")},3e4)},N.onmessage=J=>{var ae,ee;try{const F=JSON.parse(J.data);if(F.type==="notification"&&F.data)(ae=k.current)==null||ae.call(k,F.data);else if(F.type==="error"){const U=F.error||"Unknown error occurred";w(U),(ee=S.current)==null||ee.call(S,U)}else F.type}catch{}},N.onerror=()=>{var J;w("Connection error occurred"),(J=S.current)==null||J.call(S,"Connection error occurred")},N.onclose=J=>{var ae;if(x(!1),C.current&&(clearInterval(C.current),C.current=null),t&&J.code!==1e3&&y.current<_.current){y.current++;const ee=j.current*Math.pow(2,y.current-1);z.current=setTimeout(()=>{P()},ee)}else y.current>=_.current&&(w("Max reconnection attempts reached"),(ae=S.current)==null||ae.call(S,"Max reconnection attempts reached"))}}catch{w("Failed to connect"),(Y=S.current)==null||Y.call(S,"Failed to connect")}},[t,p,d,c,l,I]);i.useEffect(()=>(P(),()=>{I()}),[P,I]),i.useEffect(()=>{$.current&&$.current.readyState===WebSocket.OPEN&&P()},[r,o,n,P]);const T=i.useCallback(()=>{I(),x(!1)},[I]),R=i.useCallback(()=>{y.current=0,P()},[P]);return{isConnected:m,connectionError:v,disconnect:T,reconnect:R}}async function eu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(h=>o.append("channels",h)),r.organization_ids&&r.organization_ids.forEach(h=>o.append("organization_ids",h.toString())),r.workspace_ids&&r.workspace_ids.forEach(h=>o.append("workspace_ids",h.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,a=await t(n,{method:"GET"});return(await V(a)).data}async function tu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await V(r)).data}async function ru(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return V(o)}async function ou(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return V(r)}async function nu(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return V(o)}function cc(t){const{client:r,loading:o}=De(),{data:n,error:a,mutate:s,isLoading:h}=We(o?null:["notifications",JSON.stringify(t)],()=>eu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});ic({enabled:!o&&!!n,onNotification:i.useCallback(d=>{s(async m=>!m||m.notifications.some(v=>v.id===d.id.toString())?m:{...m,notifications:[{id:d.id.toString(),user_id:d.user_id.toString(),deployment_id:d.deployment_id.toString(),title:d.title,body:d.body,severity:d.severity,action_url:d.action_url,action_label:d.action_label,is_read:!1,is_archived:!1,created_at:d.created_at,updated_at:d.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[s]),onError:i.useCallback(()=>{},[])});const g=i.useCallback(async d=>{o||(await s(async m=>m&&{...m,notifications:m.notifications.map(x=>x.id===d?{...x,is_read:!0}:x),unread_count:Math.max(0,m.unread_count-1)},!1),await ru(r,d),await s())},[r,o,s]),c=i.useCallback(async()=>{o||(await s(async d=>d&&{...d,notifications:d.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await ou(r),await s())},[r,s]),p=i.useCallback(async d=>{o||(await s(async m=>{if(!m)return m;const x=m.notifications.find(v=>v.id===d);return{...m,notifications:m.notifications.filter(v=>v.id!==d),unread_count:x&&!x.is_read?Math.max(0,m.unread_count-1):m.unread_count,total:Math.max(0,m.total-1)}},!1),await nu(r,d),await s())},[r,o,s]),l=i.useCallback(async()=>{await s()},[s]);return!n||o||h?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:a,refetch:l}:{loading:!1,error:a,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:g,markAllAsRead:c,deleteNotification:p,refetch:l}}async function au(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await V(r)).data}function su(){const{client:t,loading:r}=De(),{data:o,error:n,mutate:a}=We(r?null:["notifications","channel-counts"],()=>au(t),{refreshInterval:3e4,revalidateOnFocus:!0}),s=async()=>{await a()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:s}:{loading:!1,counts:o,error:n,refetch:s}}const Gt=class Gt{constructor(){Xe(this,"ws",null);Xe(this,"messageHandlers",new Set);Xe(this,"connectionStateHandlers",new Set);Xe(this,"reconnectTimer",null);Xe(this,"reconnectAttempts",0);Xe(this,"url",null);Xe(this,"isIntentionalDisconnect",!1);Xe(this,"sessionMessages",{});Xe(this,"currentSessionKey",null)}static getInstance(){return Gt.instance||(Gt.instance=new Gt),Gt.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};Xe(Gt,"instance");let ea=Gt;const Ye=ea.getInstance(),xt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Me={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Tt={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Da(t){switch(t){case Tt.IDLE:return Me.IDLE;case Tt.STARTING:return Me.STARTING;case Tt.RUNNING:return Me.RUNNING;case Tt.WAITING_FOR_INPUT:return Me.WAITING_FOR_INPUT;case Tt.COMPLETED:return Me.COMPLETED;case Tt.FAILED:case Tt.CANCELLED:return Me.FAILED;default:return Me.IDLE}}function Na(t){return t===Me.STARTING||t===Me.RUNNING||t===Me.WAITING_FOR_INPUT}function lc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:a=!0}){const{deployment:s}=xe(),{client:h}=De(),[g,c]=i.useState([]),[p,l]=i.useState(null),[d,m]=i.useState(null),[x,v]=i.useState(!1),[w,$]=i.useState(!1),[z,y]=i.useState(Me.IDLE),[C,k]=i.useState({status:xt.DISCONNECTED}),[S,b]=i.useState(!0),[f,E]=i.useState(!1),j=i.useRef(null),_=i.useRef(null),I=i.useCallback(F=>{var U,G;switch(F.message_type){case"session_connected":if(v(!0),k({status:xt.CONNECTED}),(U=F.data)!=null&&U.execution_status){const se=F.data.execution_status,oe=Da(se);y(oe),$(Na(oe))}break;case"conversation_message":P(F.data);break;case"user_input_request":T(F.data);break;case"platform_event":R(F.data);break;case"platform_function":O(F.data);break;case"execution_complete":$(!1),y(Me.IDLE),_.current=null;break;case"execution_error":$(!1),y(Me.FAILED),_.current=null;break;case"execution_cancelled":$(!1),y(Me.IDLE),_.current=null;break;case"execution_status":const X=(G=F.data)==null?void 0:G.status;if(X){const se=Da(X);y(se),$(Na(se))}break}},[p]),P=i.useCallback(F=>{var oe,ce,K,ie,Z,q,A,B;const{id:U,message_type:G,content:X}=F,se=L=>g.some(W=>W.id===L);if(G==="system_decision"||G==="action_execution_result"||G==="assistant_task_breakdown"||G==="assistant_validation"||G==="assistant_action_planning"||G==="context_results"){l(null),m(null);let L="";if(G==="system_decision"){const W=X==null?void 0:X.step,te=X==null?void 0:X.reasoning;if(W==="gathercontext")te&&te.length>0?L=te.length>60?`${te.substring(0,60)}...`:te:L="Gathering context...";else if(W==="executeaction")L="Executing action";else if(W==="deliverresponse")L="Preparing response";else if(W==="taskplanning")L="Planning approach";else if(W==="validateprogress")L="Validating progress";else if(W==="acknowledge")L="Processing request";else if(W==="finishplanning")L="Finalizing plan";else if(W==="executetasks")L="Executing tasks";else if(W==="requestuserinput")L="Waiting for input";else if(W==="complete")L="Completed";else if(W==="examinetool")L="Examining tool";else if(W==="examineworkflow")L="Examining workflow";else{const pe=(X==null?void 0:X.confidence)||.5;pe>.8?L="Analyzing":pe>.6?L="Thinking":L="Reasoning"}}else if(G==="action_execution_result")((oe=X.task_execution)==null?void 0:oe.status)==="completed"?L="Task execution completed":(ce=X.task_execution)!=null&&ce.approach?L=X.task_execution.approach:L="Executing task";else if(G==="assistant_task_breakdown")(K=X.task_breakdown)!=null&&K.total_tasks?L=`Identified ${X.task_breakdown.total_tasks} tasks`:L="Planning tasks";else if(G==="assistant_validation")L="Validated results";else if(G==="assistant_action_planning")(ie=X.task_execution)!=null&&ie.total_tasks?L=`Planned ${X.task_execution.total_tasks} tasks`:(q=(Z=X.task_execution)==null?void 0:Z.tasks)!=null&&q.length?L=`Planned ${X.task_execution.tasks.length} tasks`:L="Planning actions";else if(G==="context_results"){const W=X.query,te=X.result_count||0;W&&W!=="General context gathering"?L=`${W}: Found ${te} results`:L=`Found ${te} results`}L&&!se(U)&&c(W=>[...W,{id:U,role:"system",content:L,timestamp:new Date,metadata:{type:"log",messageType:G}}]);return}if(G==="user_message")se(U)||(l(null),m(null),c(L=>[...L,{id:U,role:"user",content:X.message,images:X.images,timestamp:new Date}]));else if(G==="agent_response")se(U)||(l(null),m(null),$(!1),y(Me.IDLE),_.current=null,c(L=>[...L,{id:U,role:"assistant",content:X.response,timestamp:new Date,isStreaming:!1}]));else if(G==="assistant_acknowledgment")se(U)||(l(null),m(null),c(L=>[...L,{id:U,role:"assistant",content:X.acknowledgment_message,timestamp:new Date}]));else if(G==="assistant_ideation"||G==="assistant_action_planning"||G==="action_execution_result"||G==="assistant_validation"||G==="assistant_context_gathering"||G==="assistant_task_breakdown"){let L="";if(X.reasoning_summary)L=X.reasoning_summary;else if((A=X.task_execution)!=null&&A.approach)L=X.task_execution.approach;else if(X.strategic_synthesis)L=X.strategic_synthesis;else if((B=X.task_breakdown)!=null&&B.total_tasks)L=`Breaking down into ${X.task_breakdown.total_tasks} tasks...`;else if(X.acknowledgment_message)L=X.acknowledgment_message;else return;c(W=>[...W,{id:U,role:"assistant",content:L,timestamp:new Date}])}else if(G==="user_input_request"){const L={question:X.question,context:X.context,input_type:X.input_type,options:X.options||X.suggestions,default_value:X.default_value,placeholder:X.placeholder};y("waiting_for_input"),c(W=>[...W,{id:U,role:"system",content:L.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:L}}])}},[]),T=i.useCallback(async F=>{y("waiting_for_input");const U=`input-request-${Date.now()}`;c(G=>[...G,{id:U,role:"system",content:F.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:F}}])},[]),R=i.useCallback(F=>{const{event_label:U,event_data:G}=F;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(U,G)},[n]),O=i.useCallback(async F=>{const{function_name:U,function_data:G}=F,{parameters:X,execution_id:se}=G;if(!(n!=null&&n.onPlatformFunction)){Ye.send({message_type:{platform_function_result:[se,{error:"No platform function handler registered"}]},data:{}});return}try{const oe=await n.onPlatformFunction(U,X,se),ce={message_type:{platform_function_result:[se,oe]},data:{}};Ye.send(ce)}catch(oe){Ye.send({message_type:{platform_function_result:[se,{error:oe instanceof Error?oe.message:"Function execution failed",stack:oe instanceof Error?oe.stack:void 0}]},data:{}})}},[n]);i.useEffect(()=>{if(!s)return;const U=`wss://${s==null?void 0:s.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;k({status:xt.CONNECTING}),Ye.connect(U)},[s,o]),i.useEffect(()=>Ye.onConnectionStateChange(U=>{k({status:U.isConnected?xt.CONNECTED:U.error?xt.ERROR:xt.DISCONNECTED}),v(U.isConnected)}),[]),i.useEffect(()=>Ye.onMessage(I),[I]),i.useEffect(()=>{x&&t&&r&&a&&Ye.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,a]);const D=i.useCallback(async()=>(x&&t&&r&&Ye.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),M=i.useCallback((F,U)=>{x&&(l(F),m(U||null),$(!0),y(Me.STARTING),Ye.send({message_type:{message_input:F},data:U?{images:U}:{}}))},[x]),Y=i.useCallback(()=>{c([]),_.current=null},[]),N=i.useCallback(F=>{!x||z!==Me.WAITING_FOR_INPUT||(Ye.send({message_type:{user_input_response:F},data:{}}),y(Me.RUNNING))},[x,z]),J=i.useCallback(async F=>{var U;if(!(!o||!t))try{const G=new URLSearchParams({token:o,limit:"50"});F&&(G.append("before_id",F),E(!0));const se=await(await h(`/api/agent/contexts/${t}/messages?${G}`,{method:"GET"})).json();if(se.status===200&&se.data){const oe=se.data;if(Array.isArray(oe.data)){const ce=oe.data.filter(K=>{var q;let ie=K.content;if(typeof K.content=="string")try{ie=JSON.parse(K.content)}catch{ie={message:K.content}}const Z=((q=K.metadata)==null?void 0:q.message_type)||(ie==null?void 0:ie.message_type);return Z==="user_message"||Z==="agent_response"||Z==="assistant_acknowledgment"||Z==="user_input_request"||Z==="system_decision"||Z==="action_execution_result"||Z==="assistant_task_breakdown"||Z==="assistant_validation"||Z==="assistant_action_planning"||Z==="context_results"}).map(K=>{var L,W,te,pe,Se,Ne,H;let ie="",Z,q,A=K.content;if(typeof K.content=="string")try{A=JSON.parse(K.content)}catch{A=K.content}const B=((L=K.metadata)==null?void 0:L.message_type)||(A==null?void 0:A.message_type);if(B==="user_message"?(ie=(A==null?void 0:A.message)||"",Z=(A==null?void 0:A.images)||void 0):B==="agent_response"?ie=(A==null?void 0:A.response)||"":B==="assistant_acknowledgment"?ie=(A==null?void 0:A.acknowledgment_message)||"":B==="user_input_request"&&(ie=(A==null?void 0:A.question)||"",q={type:"user_input_request",userInputRequest:{question:(A==null?void 0:A.question)||"",context:(A==null?void 0:A.context)||"",input_type:(A==null?void 0:A.input_type)||"text",options:(A==null?void 0:A.options)||(A==null?void 0:A.suggestions)||[],default_value:(A==null?void 0:A.default_value)||"",placeholder:(A==null?void 0:A.placeholder)||""}}),B==="system_decision"||B==="action_execution_result"||B==="assistant_task_breakdown"||B==="assistant_validation"||B==="assistant_action_planning"||B==="context_results"){let ne="";if(B==="system_decision"){const ye=A==null?void 0:A.step,be=A==null?void 0:A.reasoning;if(ye==="gathercontext")be&&be.length>0?ne=be.length>60?`${be.substring(0,60)}...`:be:ne="Gathering context...";else if(ye==="executeaction")ne="Executing action";else if(ye==="deliverresponse")ne="Preparing response";else if(ye==="taskplanning")ne="Planning approach";else if(ye==="validateprogress")ne="Validating progress";else if(ye==="acknowledge")ne="Processing request";else if(ye==="finishplanning")ne="Finalizing plan";else if(ye==="executetasks")ne="Executing tasks";else if(ye==="requestuserinput")ne="Waiting for input";else if(ye==="complete")ne="Completed";else if(ye==="examinetool")ne="Examining tool";else if(ye==="examineworkflow")ne="Examining workflow";else{const re=(A==null?void 0:A.confidence)||.5;re>.8?ne="Analyzing":re>.6?ne="Thinking":ne="Reasoning"}}else if(B==="action_execution_result")((W=A==null?void 0:A.task_execution)==null?void 0:W.status)==="completed"?ne="Task execution completed":(te=A==null?void 0:A.task_execution)!=null&&te.approach?ne=A.task_execution.approach:ne="Executing task";else if(B==="assistant_task_breakdown")(pe=A==null?void 0:A.task_breakdown)!=null&&pe.total_tasks?ne=`Identified ${A.task_breakdown.total_tasks} tasks`:ne="Planning tasks";else if(B==="assistant_validation")ne="Validated results";else if(B==="assistant_action_planning")(Se=A==null?void 0:A.task_execution)!=null&&Se.total_tasks?ne=`Planned ${A.task_execution.total_tasks} tasks`:(H=(Ne=A==null?void 0:A.task_execution)==null?void 0:Ne.tasks)!=null&&H.length?ne=`Planned ${A.task_execution.tasks.length} tasks`:ne="Planning actions";else if(B==="context_results"){const ye=A==null?void 0:A.query,be=(A==null?void 0:A.result_count)||0;ye&&ye!=="General context gathering"?ne=`${ye}: Found ${be} results`:ne=`Found ${be} results`}ie=ne,q={type:"log",messageType:B}}return{id:K.id,role:B==="user_message"?"user":B==="user_input_request"?"system":"assistant",content:ie,images:Z,timestamp:new Date(K.timestamp||K.created_at||Date.now()),metadata:q}}).filter(K=>K.content||K.metadata||K.images).sort((K,ie)=>{const Z=BigInt(K.id),q=BigInt(ie.id);return Z<q?-1:Z>q?1:0});ce.length>0&&(j.current=ce[0].id),F?(c(K=>[...ce,...K]),b(ce.length>=50)):(c(ce),ce.length>0&&((U=ce[ce.length-1].metadata)==null?void 0:U.type)==="user_input_request"&&y(Me.WAITING_FOR_INPUT)),E(!1)}}}catch(G){console.error("Failed to fetch messages:",G),E(!1)}},[o,t,h]);i.useEffect(()=>{t&&o&&J()},[t,o]);const ae=i.useCallback(async()=>{if(!(f||!S||!j.current)){E(!0);try{await J(j.current)}finally{E(!1)}}},[f,S,J]),ee=i.useCallback(()=>{!x||!w||(Ye.send({message_type:{cancel_execution:null},data:{}}),$(!1),y("idle"))},[x,w]);return{messages:g,pendingMessage:p,pendingImages:d,connectionState:C,isConnected:x,isExecuting:w,executionStatus:z,isWaitingForInput:z==="waiting_for_input",hasMoreMessages:S,isLoadingMore:f,sendMessage:M,submitUserInput:N,clearMessages:Y,loadMoreMessages:ae,cancelExecution:ee,connect:D,disconnect:()=>Ye.disconnect()}}const dc=()=>{const{client:t}=De(),[r,o]=i.useState(!1),[n,a]=i.useState(null),[s,h]=i.useState(null),g=i.useCallback(async p=>{o(!0),a(null),h(null);try{const l=await t("/organizations/invitations/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:p})}),m=(await V(l)).data;return h(m),m.error_code&&a(m.message||"Failed to accept invitation"),m}catch(l){const d=l.message||"Failed to accept invitation";a(d);const m={error_code:"NETWORK_ERROR",message:d};return h(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{a(null),h(null)},[]);return{acceptInvitation:g,invitationData:s,loading:r,error:n,reset:c}},iu=({children:t})=>{const{loading:r}=xe();return r?null:e.jsx(e.Fragment,{children:t})},cu=({children:t})=>{const{loading:r}=xe();return r?e.jsx(e.Fragment,{children:t}):null};var qe=function(){return qe=Object.assign||function(r){for(var o,n=1,a=arguments.length;n<a;n++){o=arguments[n];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])}return r},qe.apply(this,arguments)};function Xt(t,r,o){if(o||arguments.length===2)for(var n=0,a=r.length,s;n<a;n++)(s||!(n in r))&&(s||(s=Array.prototype.slice.call(r,0,n)),s[n]=r[n]);return t.concat(s||Array.prototype.slice.call(r))}function lu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var du=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,uu=lu(function(t){return du.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),ze="-ms-",Lr="-moz-",_e="-webkit-",uc="comm",Go="rule",ma="decl",pu="@import",pc="@keyframes",hu="@layer",hc=Math.abs,xa=String.fromCharCode,ta=Object.assign;function fu(t,r){return Be(t,0)^45?(((r<<2^Be(t,0))<<2^Be(t,1))<<2^Be(t,2))<<2^Be(t,3):0}function fc(t){return t.trim()}function mt(t,r){return(t=r.exec(t))?t[0]:t}function ge(t,r,o){return t.replace(r,o)}function Co(t,r,o){return t.indexOf(r,o)}function Be(t,r){return t.charCodeAt(r)|0}function hr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function gc(t){return t.length}function Or(t,r){return r.push(t),t}function gu(t,r){return t.map(r).join("")}function Fa(t,r){return t.filter(function(o){return!mt(o,r)})}var Ho=1,fr=1,mc=0,Ze=0,Le=0,yr="";function qo(t,r,o,n,a,s,h,g){return{value:t,root:r,parent:o,type:n,props:a,children:s,line:Ho,column:fr,length:h,return:"",siblings:g}}function St(t,r){return ta(qo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function ar(t){for(;t.root;)t=St(t.root,{children:[t]});Or(t,t.siblings)}function mu(){return Le}function xu(){return Le=Ze>0?Be(yr,--Ze):0,fr--,Le===10&&(fr=1,Ho--),Le}function et(){return Le=Ze<mc?Be(yr,Ze++):0,fr++,Le===10&&(fr=1,Ho++),Le}function qt(){return Be(yr,Ze)}function So(){return Ze}function Yo(t,r){return hr(yr,t,r)}function ra(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function vu(t){return Ho=fr=1,mc=ct(yr=t),Ze=0,[]}function bu(t){return yr="",t}function fn(t){return fc(Yo(Ze-1,oa(t===91?t+2:t===40?t+1:t)))}function yu(t){for(;(Le=qt())&&Le<33;)et();return ra(t)>2||ra(Le)>3?"":" "}function wu(t,r){for(;--r&&et()&&!(Le<48||Le>102||Le>57&&Le<65||Le>70&&Le<97););return Yo(t,So()+(r<6&&qt()==32&&et()==32))}function oa(t){for(;et();)switch(Le){case t:return Ze;case 34:case 39:t!==34&&t!==39&&oa(Le);break;case 40:t===41&&oa(t);break;case 92:et();break}return Ze}function ju(t,r){for(;et()&&t+Le!==57;)if(t+Le===84&&qt()===47)break;return"/*"+Yo(r,Ze-1)+"*"+xa(t===47?t:et())}function ku(t){for(;!ra(qt());)et();return Yo(t,Ze)}function _u(t){return bu($o("",null,null,null,[""],t=vu(t),0,[0],t))}function $o(t,r,o,n,a,s,h,g,c){for(var p=0,l=0,d=h,m=0,x=0,v=0,w=1,$=1,z=1,y=0,C="",k=a,S=s,b=n,f=C;$;)switch(v=y,y=et()){case 40:if(v!=108&&Be(f,d-1)==58){Co(f+=ge(fn(y),"&","&\f"),"&\f",hc(p?g[p-1]:0))!=-1&&(z=-1);break}case 34:case 39:case 91:f+=fn(y);break;case 9:case 10:case 13:case 32:f+=yu(v);break;case 92:f+=wu(So()-1,7);continue;case 47:switch(qt()){case 42:case 47:Or(Cu(ju(et(),So()),r,o,c),c);break;default:f+="/"}break;case 123*w:g[p++]=ct(f)*z;case 125*w:case 59:case 0:switch(y){case 0:case 125:$=0;case 59+l:z==-1&&(f=ge(f,/\f/g,"")),x>0&&ct(f)-d&&Or(x>32?Ua(f+";",n,o,d-1,c):Ua(ge(f," ","")+";",n,o,d-2,c),c);break;case 59:f+=";";default:if(Or(b=Ba(f,r,o,p,l,a,g,C,k=[],S=[],d,s),s),y===123)if(l===0)$o(f,r,b,b,k,s,d,g,S);else switch(m===99&&Be(f,3)===110?100:m){case 100:case 108:case 109:case 115:$o(t,b,b,n&&Or(Ba(t,b,b,0,0,a,g,C,a,k=[],d,S),S),a,S,d,g,n?k:S);break;default:$o(f,b,b,b,[""],S,0,g,S)}}p=l=x=0,w=z=1,C=f="",d=h;break;case 58:d=1+ct(f),x=v;default:if(w<1){if(y==123)--w;else if(y==125&&w++==0&&xu()==125)continue}switch(f+=xa(y),y*w){case 38:z=l>0?1:(f+="\f",-1);break;case 44:g[p++]=(ct(f)-1)*z,z=1;break;case 64:qt()===45&&(f+=fn(et())),m=qt(),l=d=ct(C=f+=ku(So())),y++;break;case 45:v===45&&ct(f)==2&&(w=0)}}return s}function Ba(t,r,o,n,a,s,h,g,c,p,l,d){for(var m=a-1,x=a===0?s:[""],v=gc(x),w=0,$=0,z=0;w<n;++w)for(var y=0,C=hr(t,m+1,m=hc($=h[w])),k=t;y<v;++y)(k=fc($>0?x[y]+" "+C:ge(C,/&\f/g,x[y])))&&(c[z++]=k);return qo(t,r,o,a===0?Go:g,c,p,l,d)}function Cu(t,r,o,n){return qo(t,r,o,uc,xa(mu()),hr(t,2,-2),0,n)}function Ua(t,r,o,n,a){return qo(t,r,o,ma,hr(t,0,n),hr(t,n+1,-1),n,a)}function xc(t,r,o){switch(fu(t,r)){case 5103:return _e+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return _e+t+t;case 4789:return Lr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return _e+t+Lr+t+ze+t+t;case 5936:switch(Be(t,r+11)){case 114:return _e+t+ze+ge(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return _e+t+ze+ge(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return _e+t+ze+ge(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return _e+t+ze+t+t;case 6165:return _e+t+ze+"flex-"+t+t;case 5187:return _e+t+ge(t,/(\w+).+(:[^]+)/,_e+"box-$1$2"+ze+"flex-$1$2")+t;case 5443:return _e+t+ze+"flex-item-"+ge(t,/flex-|-self/g,"")+(mt(t,/flex-|baseline/)?"":ze+"grid-row-"+ge(t,/flex-|-self/g,""))+t;case 4675:return _e+t+ze+"flex-line-pack"+ge(t,/align-content|flex-|-self/g,"")+t;case 5548:return _e+t+ze+ge(t,"shrink","negative")+t;case 5292:return _e+t+ze+ge(t,"basis","preferred-size")+t;case 6060:return _e+"box-"+ge(t,"-grow","")+_e+t+ze+ge(t,"grow","positive")+t;case 4554:return _e+ge(t,/([^-])(transform)/g,"$1"+_e+"$2")+t;case 6187:return ge(ge(ge(t,/(zoom-|grab)/,_e+"$1"),/(image-set)/,_e+"$1"),t,"")+t;case 5495:case 3959:return ge(t,/(image-set\([^]*)/,_e+"$1$`$1");case 4968:return ge(ge(t,/(.+:)(flex-)?(.*)/,_e+"box-pack:$3"+ze+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+_e+t+t;case 4200:if(!mt(t,/flex-|baseline/))return ze+"grid-column-align"+hr(t,r)+t;break;case 2592:case 3360:return ze+ge(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,a){return r=a,mt(n.props,/grid-\w+-end/)})?~Co(t+(o=o[r].value),"span",0)?t:ze+ge(t,"-start","")+t+ze+"grid-row-span:"+(~Co(o,"span",0)?mt(o,/\d+/):+mt(o,/\d+/)-+mt(t,/\d+/))+";":ze+ge(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return mt(n.props,/grid-\w+-start/)})?t:ze+ge(ge(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ge(t,/(.+)-inline(.+)/,_e+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ct(t)-1-r>6)switch(Be(t,r+1)){case 109:if(Be(t,r+4)!==45)break;case 102:return ge(t,/(.+:)(.+)-([^]+)/,"$1"+_e+"$2-$3$1"+Lr+(Be(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~Co(t,"stretch",0)?xc(ge(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ge(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,a,s,h,g,c,p){return ze+a+":"+s+p+(h?ze+a+"-span:"+(g?c:+c-+s)+p:"")+t});case 4949:if(Be(t,r+6)===121)return ge(t,":",":"+_e)+t;break;case 6444:switch(Be(t,Be(t,14)===45?18:11)){case 120:return ge(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+_e+(Be(t,14)===45?"inline-":"")+"box$3$1"+_e+"$2$3$1"+ze+"$2box$3")+t;case 100:return ge(t,":",":"+ze)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ge(t,"scroll-","scroll-snap-")+t}return t}function To(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Su(t,r,o,n){switch(t.type){case hu:if(t.children.length)break;case pu:case ma:return t.return=t.return||t.value;case uc:return"";case pc:return t.return=t.value+"{"+To(t.children,n)+"}";case Go:if(!ct(t.value=t.props.join(",")))return""}return ct(o=To(t.children,n))?t.return=t.value+"{"+o+"}":""}function $u(t){var r=gc(t);return function(o,n,a,s){for(var h="",g=0;g<r;g++)h+=t[g](o,n,a,s)||"";return h}}function zu(t){return function(r){r.root||(r=r.return)&&t(r)}}function Eu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case ma:t.return=xc(t.value,t.length,o);return;case pc:return To([St(t,{value:ge(t.value,"@","@"+_e)})],n);case Go:if(t.length)return gu(o=t.props,function(a){switch(mt(a,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":ar(St(t,{props:[ge(a,/:(read-\w+)/,":"+Lr+"$1")]})),ar(St(t,{props:[a]})),ta(t,{props:Fa(o,n)});break;case"::placeholder":ar(St(t,{props:[ge(a,/:(plac\w+)/,":"+_e+"input-$1")]})),ar(St(t,{props:[ge(a,/:(plac\w+)/,":"+Lr+"$1")]})),ar(St(t,{props:[ge(a,/:(plac\w+)/,ze+"input-$1")]})),ar(St(t,{props:[a]})),ta(t,{props:Fa(o,n)});break}return""})}}var Pu={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Jt=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",vc="active",bc="data-styled-version",Zo="6.1.19",va=`/*!sc*/
19
+ `,Oo=typeof window<"u"&&typeof document<"u",Ru=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==""?process.env.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&process.env.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.SC_DISABLE_SPEEDY!==void 0&&process.env.SC_DISABLE_SPEEDY!==""?process.env.SC_DISABLE_SPEEDY!=="false"&&process.env.SC_DISABLE_SPEEDY:process.env.NODE_ENV!=="production"),Wa=/invalid hook call/i,Zr=new Set,Iu=function(t,r){if(process.env.NODE_ENV!=="production"){var o=r?' with the id of "'.concat(r,'"'):"",n="The component ".concat(t).concat(o,` has been created dynamically.
20
20
  `)+`You may see this warning because you've called styled inside another component.
21
21
  To resolve this only create new StyledComponents outside of any render method and function component.
22
22
  See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
23
- `,a=console.error;try{var s=!0;console.error=function(p){for(var g=[],c=1;c<arguments.length;c++)g[c-1]=arguments[c];Wa.test(p)?(s=!1,Yr.delete(n)):a.apply(void 0,Xt([p],g,!1))},i.useRef(),s&&!Yr.has(n)&&(console.warn(n),Yr.add(n))}catch(p){Wa.test(p.message)&&Yr.delete(n)}finally{console.error=a}}},Ko=Object.freeze([]),gr=Object.freeze({});function Tu(t,r,o){return o===void 0&&(o=gr),t.theme!==o.theme&&t.theme||r||o.theme}var na=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),Ou=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Mu=/(^-|-$)/g;function Va(t){return t.replace(Ou,"-").replace(Mu,"")}var Lu=/(a)(d)/gi,Zr=52,Ga=function(t){return String.fromCharCode(t+(t>25?39:97))};function aa(t){var r,o="";for(r=Math.abs(t);r>Zr;r=r/Zr|0)o=Ga(r%Zr)+o;return(Ga(r%Zr)+o).replace(Lu,"$1-$2")}var gn,yc=5381,Vt=function(t,r){for(var o=r.length;o;)t=33*t^r.charCodeAt(--o);return t},wc=function(t){return Vt(yc,t)};function jc(t){return aa(wc(t)>>>0)}function kc(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function mn(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var _c=typeof Symbol=="function"&&Symbol.for,Cc=_c?Symbol.for("react.memo"):60115,Au=_c?Symbol.for("react.forward_ref"):60112,Du={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Nu={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Sc={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Fu=((gn={})[Au]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},gn[Cc]=Sc,gn);function Ha(t){return("type"in(r=t)&&r.type.$$typeof)===Cc?Sc:"$$typeof"in t?Fu[t.$$typeof]:Du;var r}var Bu=Object.defineProperty,Uu=Object.getOwnPropertyNames,qa=Object.getOwnPropertySymbols,Wu=Object.getOwnPropertyDescriptor,Vu=Object.getPrototypeOf,Ya=Object.prototype;function $c(t,r,o){if(typeof r!="string"){if(Ya){var n=Vu(r);n&&n!==Ya&&$c(t,n,o)}var a=Uu(r);qa&&(a=a.concat(qa(r)));for(var s=Ha(t),p=Ha(r),g=0;g<a.length;++g){var c=a[g];if(!(c in Nu||o&&o[c]||p&&c in p||s&&c in s)){var h=Wu(r,c);try{Bu(t,c,h)}catch{}}}}return t}function mr(t){return typeof t=="function"}function ba(t){return typeof t=="object"&&"styledComponentId"in t}function Ht(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function sa(t,r){if(t.length===0)return"";for(var o=t[0],n=1;n<t.length;n++)o+=t[n];return o}function xr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function ia(t,r,o){if(o===void 0&&(o=!1),!o&&!xr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var n=0;n<r.length;n++)t[n]=ia(t[n],r[n]);else if(xr(r))for(var n in r)t[n]=ia(t[n],r[n]);return t}function ya(t,r){Object.defineProperty(t,"toString",{value:r})}var Gu=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
23
+ `,a=console.error;try{var s=!0;console.error=function(h){for(var g=[],c=1;c<arguments.length;c++)g[c-1]=arguments[c];Wa.test(h)?(s=!1,Zr.delete(n)):a.apply(void 0,Xt([h],g,!1))},i.useRef(),s&&!Zr.has(n)&&(console.warn(n),Zr.add(n))}catch(h){Wa.test(h.message)&&Zr.delete(n)}finally{console.error=a}}},Ko=Object.freeze([]),gr=Object.freeze({});function Tu(t,r,o){return o===void 0&&(o=gr),t.theme!==o.theme&&t.theme||r||o.theme}var na=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),Ou=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Mu=/(^-|-$)/g;function Va(t){return t.replace(Ou,"-").replace(Mu,"")}var Lu=/(a)(d)/gi,Kr=52,Ga=function(t){return String.fromCharCode(t+(t>25?39:97))};function aa(t){var r,o="";for(r=Math.abs(t);r>Kr;r=r/Kr|0)o=Ga(r%Kr)+o;return(Ga(r%Kr)+o).replace(Lu,"$1-$2")}var gn,yc=5381,Vt=function(t,r){for(var o=r.length;o;)t=33*t^r.charCodeAt(--o);return t},wc=function(t){return Vt(yc,t)};function jc(t){return aa(wc(t)>>>0)}function kc(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function mn(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var _c=typeof Symbol=="function"&&Symbol.for,Cc=_c?Symbol.for("react.memo"):60115,Au=_c?Symbol.for("react.forward_ref"):60112,Du={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Nu={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Sc={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Fu=((gn={})[Au]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},gn[Cc]=Sc,gn);function Ha(t){return("type"in(r=t)&&r.type.$$typeof)===Cc?Sc:"$$typeof"in t?Fu[t.$$typeof]:Du;var r}var Bu=Object.defineProperty,Uu=Object.getOwnPropertyNames,qa=Object.getOwnPropertySymbols,Wu=Object.getOwnPropertyDescriptor,Vu=Object.getPrototypeOf,Ya=Object.prototype;function $c(t,r,o){if(typeof r!="string"){if(Ya){var n=Vu(r);n&&n!==Ya&&$c(t,n,o)}var a=Uu(r);qa&&(a=a.concat(qa(r)));for(var s=Ha(t),h=Ha(r),g=0;g<a.length;++g){var c=a[g];if(!(c in Nu||o&&o[c]||h&&c in h||s&&c in s)){var p=Wu(r,c);try{Bu(t,c,p)}catch{}}}}return t}function mr(t){return typeof t=="function"}function ba(t){return typeof t=="object"&&"styledComponentId"in t}function Ht(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function sa(t,r){if(t.length===0)return"";for(var o=t[0],n=1;n<t.length;n++)o+=t[n];return o}function xr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function ia(t,r,o){if(o===void 0&&(o=!1),!o&&!xr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var n=0;n<r.length;n++)t[n]=ia(t[n],r[n]);else if(xr(r))for(var n in r)t[n]=ia(t[n],r[n]);return t}function ya(t,r){Object.defineProperty(t,"toString",{value:r})}var Gu=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
24
24
 
25
25
  `,2:`Can't collect styles once you've consumed a \`ServerStyleSheet\`'s styles! \`ServerStyleSheet\` is a one off instance for each server-side render cycle.
26
26
 
@@ -61,7 +61,7 @@ as for instance in your render method then you may be running into this limitati
61
61
 
62
62
  `,17:`CSSStyleSheet could not be found on HTMLStyleElement.
63
63
  Has styled-components' style tag been unmounted or altered by another script?
64
- `,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function Hu(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],a=1,s=t.length;a<s;a+=1)n.push(t[a]);return n.forEach(function(p){o=o.replace(/%[a-z]/,p)}),o}function yr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(Hu.apply(void 0,Xt([Gu[t]],r,!1)).trim())}var qu=function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r}return t.prototype.indexOfGroup=function(r){for(var o=0,n=0;n<r;n++)o+=this.groupSizes[n];return o},t.prototype.insertRules=function(r,o){if(r>=this.groupSizes.length){for(var n=this.groupSizes,a=n.length,s=a;r>=s;)if((s<<=1)<0)throw yr(16,"".concat(r));this.groupSizes=new Uint32Array(s),this.groupSizes.set(n),this.length=s;for(var p=a;p<s;p++)this.groupSizes[p]=0}for(var g=this.indexOfGroup(r+1),c=(p=0,o.length);p<c;p++)this.tag.insertRule(g,o[p])&&(this.groupSizes[r]++,g++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),a=n+o;this.groupSizes[r]=0;for(var s=n;s<a;s++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],a=this.indexOfGroup(r),s=a+n,p=a;p<s;p++)o+="".concat(this.tag.getRule(p)).concat(va);return o},t}(),Yu=1<<30,$o=new Map,Oo=new Map,zo=1,Kr=function(t){if($o.has(t))return $o.get(t);for(;Oo.has(zo);)zo++;var r=zo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Yu))throw yr(16,"".concat(r));return $o.set(t,r),Oo.set(r,t),r},Zu=function(t,r){zo=r+1,$o.set(t,r),Oo.set(r,t)},Ku="style[".concat(Jt,"][").concat(bc,'="').concat(Zo,'"]'),Qu=new RegExp("^".concat(Jt,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Xu=function(t,r,o){for(var n,a=o.split(","),s=0,p=a.length;s<p;s++)(n=a[s])&&t.registerName(r,n)},Ju=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(va),a=[],s=0,p=n.length;s<p;s++){var g=n[s].trim();if(g){var c=g.match(Qu);if(c){var h=0|parseInt(c[1],10),d=c[2];h!==0&&(Zu(d,h),Xu(t,d,c[3]),t.getTag().insertRules(h,a)),a.length=0}else a.push(g)}}},Za=function(t){for(var r=document.querySelectorAll(Ku),o=0,n=r.length;o<n;o++){var a=r[o];a&&a.getAttribute(Jt)!==vc&&(Ju(t,a),a.parentNode&&a.parentNode.removeChild(a))}};function ep(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var zc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),a=function(g){var c=Array.from(g.querySelectorAll("style[".concat(Jt,"]")));return c[c.length-1]}(o),s=a!==void 0?a.nextSibling:null;n.setAttribute(Jt,vc),n.setAttribute(bc,Zo);var p=ep();return p&&n.setAttribute("nonce",p),o.insertBefore(n,s),n},tp=function(){function t(r){this.element=zc(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,a=0,s=n.length;a<s;a++){var p=n[a];if(p.ownerNode===o)return p}throw yr(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),rp=function(){function t(r){this.element=zc(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,o){if(r<=this.length&&r>=0){var n=document.createTextNode(o);return this.element.insertBefore(n,this.nodes[r]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(r){this.element.removeChild(this.nodes[r]),this.length--},t.prototype.getRule=function(r){return r<this.length?this.nodes[r].textContent:""},t}(),op=function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,o){return r<=this.length&&(this.rules.splice(r,0,o),this.length++,!0)},t.prototype.deleteRule=function(r){this.rules.splice(r,1),this.length--},t.prototype.getRule=function(r){return r<this.length?this.rules[r]:""},t}(),Ka=To,np={isServer:!To,useCSSOMInjection:!Ru},Ec=function(){function t(r,o,n){r===void 0&&(r=gr),o===void 0&&(o={});var a=this;this.options=qe(qe({},np),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&To&&Ka&&(Ka=!1,Za(this)),ya(this,function(){return function(s){for(var p=s.getTag(),g=p.length,c="",h=function(l){var m=function($){return Oo.get($)}(l);if(m===void 0)return"continue";var x=s.names.get(m),v=p.getGroup(l);if(x===void 0||!x.size||v.length===0)return"continue";var w="".concat(Jt,".g").concat(l,'[id="').concat(m,'"]'),C="";x!==void 0&&x.forEach(function($){$.length>0&&(C+="".concat($,","))}),c+="".concat(v).concat(w,'{content:"').concat(C,'"}').concat(va)},d=0;d<g;d++)h(d);return c}(a)})}return t.registerId=function(r){return Kr(r)},t.prototype.rehydrate=function(){!this.server&&To&&Za(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(qe(qe({},this.options),r),this.gs,o&&this.names||void 0)},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=function(o){var n=o.useCSSOMInjection,a=o.target;return o.isServer?new op(a):n?new tp(a):new rp(a)}(this.options),new qu(r)));var r},t.prototype.hasNameForId=function(r,o){return this.names.has(r)&&this.names.get(r).has(o)},t.prototype.registerName=function(r,o){if(Kr(r),this.names.has(r))this.names.get(r).add(o);else{var n=new Set;n.add(o),this.names.set(r,n)}},t.prototype.insertRules=function(r,o,n){this.registerName(r,o),this.getTag().insertRules(Kr(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(Kr(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),ap=/&/g,sp=/^\s*\/\/.*$/gm;function Pc(t,r){return t.map(function(o){return o.type==="rule"&&(o.value="".concat(r," ").concat(o.value),o.value=o.value.replaceAll(",",",".concat(r," ")),o.props=o.props.map(function(n){return"".concat(r," ").concat(n)})),Array.isArray(o.children)&&o.type!=="@keyframes"&&(o.children=Pc(o.children,r)),o})}function ip(t){var r,o,n,a=gr,s=a.options,p=s===void 0?gr:s,g=a.plugins,c=g===void 0?Ko:g,h=function(m,x,v){return v.startsWith(o)&&v.endsWith(o)&&v.replaceAll(o,"").length>0?".".concat(r):m},d=c.slice();d.push(function(m){m.type===Go&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(ap,o).replace(n,h))}),p.prefix&&d.push(Eu),d.push(Su);var l=function(m,x,v,w){x===void 0&&(x=""),v===void 0&&(v=""),w===void 0&&(w="&"),r=w,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var C=m.replace(sp,""),$=_u(v||x?"".concat(v," ").concat(x," { ").concat(C," }"):C);p.namespace&&($=Pc($,p.namespace));var y=[];return Io($,$u(d.concat(zu(function(z){return y.push(z)})))),y};return l.hash=c.length?c.reduce(function(m,x){return x.name||yr(15),Vt(m,x.name)},yc).toString():"",l}var cp=new Ec,ca=ip(),Rc=i.createContext({shouldForwardProp:void 0,styleSheet:cp,stylis:ca});Rc.Consumer;i.createContext(void 0);function Qa(){return i.useContext(Rc)}var la=function(){function t(r,o){var n=this;this.inject=function(a,s){s===void 0&&(s=ca);var p=n.name+s.hash;a.hasNameForId(n.id,p)||a.insertRules(n.id,p,s(n.rules,p,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,ya(this,function(){throw yr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=ca),this.name+r.hash},t}(),lp=function(t){return t>="A"&&t<="Z"};function Xa(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;lp(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Ic=function(t){return t==null||t===!1||t===""},Tc=function(t){var r,o,n=[];for(var a in t){var s=t[a];t.hasOwnProperty(a)&&!Ic(s)&&(Array.isArray(s)&&s.isCss||mr(s)?n.push("".concat(Xa(a),":"),s,";"):xr(s)?n.push.apply(n,Xt(Xt(["".concat(a," {")],Tc(s),!1),["}"],!1)):n.push("".concat(Xa(a),": ").concat((r=a,(o=s)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Pu||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Yt(t,r,o,n){if(Ic(t))return[];if(ba(t))return[".".concat(t.styledComponentId)];if(mr(t)){if(!mr(s=t)||s.prototype&&s.prototype.isReactComponent||!r)return[t];var a=t(r);return process.env.NODE_ENV==="production"||typeof a!="object"||Array.isArray(a)||a instanceof la||xr(a)||a===null||console.error("".concat(kc(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Yt(a,r,o,n)}var s;return t instanceof la?o?(t.inject(o,n),[t.getName(n)]):[t]:xr(t)?Tc(t):Array.isArray(t)?Array.prototype.concat.apply(Ko,t.map(function(p){return Yt(p,r,o,n)})):[t.toString()]}function dp(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(mr(o)&&!ba(o))return!1}return!0}var up=wc(Zo),pp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&dp(r),this.componentId=o,this.baseHash=Vt(up,o),this.baseStyle=n,Ec.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var a=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))a=Ht(a,this.staticRulesId);else{var s=sa(Yt(this.rules,r,o,n)),p=aa(Vt(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,p)){var g=n(s,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,g)}a=Ht(a,p),this.staticRulesId=p}else{for(var c=Vt(this.baseHash,n.hash),h="",d=0;d<this.rules.length;d++){var l=this.rules[d];if(typeof l=="string")h+=l,process.env.NODE_ENV!=="production"&&(c=Vt(c,l));else if(l){var m=sa(Yt(l,r,o,n));c=Vt(c,m+d),h+=m}}if(h){var x=aa(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(h,".".concat(x),void 0,this.componentId)),a=Ht(a,x)}}return a},t}(),Oc=i.createContext(void 0);Oc.Consumer;var xn={},Ja=new Set;function hp(t,r,o){var n=ba(t),a=t,s=!mn(t),p=r.attrs,g=p===void 0?Ko:p,c=r.componentId,h=c===void 0?function(_,k){var b=typeof _!="string"?"sc":Va(_);xn[b]=(xn[b]||0)+1;var f="".concat(b,"-").concat(jc(Zo+b+xn[b]));return k?"".concat(k,"-").concat(f):f}(r.displayName,r.parentComponentId):c,d=r.displayName,l=d===void 0?function(_){return mn(_)?"styled.".concat(_):"Styled(".concat(kc(_),")")}(t):d,m=r.displayName&&r.componentId?"".concat(Va(r.displayName),"-").concat(r.componentId):r.componentId||h,x=n&&a.attrs?a.attrs.concat(g).filter(Boolean):g,v=r.shouldForwardProp;if(n&&a.shouldForwardProp){var w=a.shouldForwardProp;if(r.shouldForwardProp){var C=r.shouldForwardProp;v=function(_,k){return w(_,k)&&C(_,k)}}else v=w}var $=new pp(o,m,n?a.componentStyle:void 0);function y(_,k){return function(b,f,I){var j=b.attrs,S=b.componentStyle,R=b.defaultProps,E=b.foldedComponentIds,T=b.styledComponentId,P=b.target,O=i.useContext(Oc),D=Qa(),M=b.shouldForwardProp||D.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(T);var N=Tu(f,O,R)||gr,F=function(Z,Q,ae){for(var oe,ce=qe(qe({},Q),{className:void 0,theme:ae}),Y=0;Y<Z.length;Y+=1){var se=mr(oe=Z[Y])?oe(ce):oe;for(var q in se)ce[q]=q==="className"?Ht(ce[q],se[q]):q==="style"?qe(qe({},ce[q]),se[q]):se[q]}return Q.className&&(ce.className=Ht(ce.className,Q.className)),ce}(j,f,N),J=F.as||P,ie={};for(var re in F)F[re]===void 0||re[0]==="$"||re==="as"||re==="theme"&&F.theme===N||(re==="forwardedAs"?ie.as=F.forwardedAs:M&&!M(re,J)||(ie[re]=F[re],M||process.env.NODE_ENV!=="development"||uu(re)||Ja.has(re)||!na.has(J)||(Ja.add(re),console.warn('styled-components: it looks like an unknown prop "'.concat(re,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var X=function(Z,Q){var ae=Qa(),oe=Z.generateAndInjectStyles(Q,ae.styleSheet,ae.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(oe),oe}(S,F);process.env.NODE_ENV!=="production"&&b.warnTooManyClasses&&b.warnTooManyClasses(X);var U=Ht(E,T);return X&&(U+=" "+X),F.className&&(U+=" "+F.className),ie[mn(J)&&!na.has(J)?"class":"className"]=U,I&&(ie.ref=I),i.createElement(J,ie)}(z,_,k)}y.displayName=l;var z=i.forwardRef(y);return z.attrs=x,z.componentStyle=$,z.displayName=l,z.shouldForwardProp=v,z.foldedComponentIds=n?Ht(a.foldedComponentIds,a.styledComponentId):"",z.styledComponentId=m,z.target=n?a.target:t,Object.defineProperty(z,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(_){this._foldedDefaultProps=n?function(k){for(var b=[],f=1;f<arguments.length;f++)b[f-1]=arguments[f];for(var I=0,j=b;I<j.length;I++)ia(k,j[I],!0);return k}({},a.defaultProps,_):_}}),process.env.NODE_ENV!=="production"&&(Iu(l,m),z.warnTooManyClasses=function(_,k){var b={},f=!1;return function(I){if(!f&&(b[I]=!0,Object.keys(b).length>=200)){var j=k?' with the id of "'.concat(k,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(_).concat(j,`.
64
+ `,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function Hu(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],a=1,s=t.length;a<s;a+=1)n.push(t[a]);return n.forEach(function(h){o=o.replace(/%[a-z]/,h)}),o}function wr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(Hu.apply(void 0,Xt([Gu[t]],r,!1)).trim())}var qu=function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r}return t.prototype.indexOfGroup=function(r){for(var o=0,n=0;n<r;n++)o+=this.groupSizes[n];return o},t.prototype.insertRules=function(r,o){if(r>=this.groupSizes.length){for(var n=this.groupSizes,a=n.length,s=a;r>=s;)if((s<<=1)<0)throw wr(16,"".concat(r));this.groupSizes=new Uint32Array(s),this.groupSizes.set(n),this.length=s;for(var h=a;h<s;h++)this.groupSizes[h]=0}for(var g=this.indexOfGroup(r+1),c=(h=0,o.length);h<c;h++)this.tag.insertRule(g,o[h])&&(this.groupSizes[r]++,g++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),a=n+o;this.groupSizes[r]=0;for(var s=n;s<a;s++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],a=this.indexOfGroup(r),s=a+n,h=a;h<s;h++)o+="".concat(this.tag.getRule(h)).concat(va);return o},t}(),Yu=1<<30,zo=new Map,Mo=new Map,Eo=1,Qr=function(t){if(zo.has(t))return zo.get(t);for(;Mo.has(Eo);)Eo++;var r=Eo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Yu))throw wr(16,"".concat(r));return zo.set(t,r),Mo.set(r,t),r},Zu=function(t,r){Eo=r+1,zo.set(t,r),Mo.set(r,t)},Ku="style[".concat(Jt,"][").concat(bc,'="').concat(Zo,'"]'),Qu=new RegExp("^".concat(Jt,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Xu=function(t,r,o){for(var n,a=o.split(","),s=0,h=a.length;s<h;s++)(n=a[s])&&t.registerName(r,n)},Ju=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(va),a=[],s=0,h=n.length;s<h;s++){var g=n[s].trim();if(g){var c=g.match(Qu);if(c){var p=0|parseInt(c[1],10),l=c[2];p!==0&&(Zu(l,p),Xu(t,l,c[3]),t.getTag().insertRules(p,a)),a.length=0}else a.push(g)}}},Za=function(t){for(var r=document.querySelectorAll(Ku),o=0,n=r.length;o<n;o++){var a=r[o];a&&a.getAttribute(Jt)!==vc&&(Ju(t,a),a.parentNode&&a.parentNode.removeChild(a))}};function ep(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var zc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),a=function(g){var c=Array.from(g.querySelectorAll("style[".concat(Jt,"]")));return c[c.length-1]}(o),s=a!==void 0?a.nextSibling:null;n.setAttribute(Jt,vc),n.setAttribute(bc,Zo);var h=ep();return h&&n.setAttribute("nonce",h),o.insertBefore(n,s),n},tp=function(){function t(r){this.element=zc(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,a=0,s=n.length;a<s;a++){var h=n[a];if(h.ownerNode===o)return h}throw wr(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),rp=function(){function t(r){this.element=zc(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,o){if(r<=this.length&&r>=0){var n=document.createTextNode(o);return this.element.insertBefore(n,this.nodes[r]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(r){this.element.removeChild(this.nodes[r]),this.length--},t.prototype.getRule=function(r){return r<this.length?this.nodes[r].textContent:""},t}(),op=function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,o){return r<=this.length&&(this.rules.splice(r,0,o),this.length++,!0)},t.prototype.deleteRule=function(r){this.rules.splice(r,1),this.length--},t.prototype.getRule=function(r){return r<this.length?this.rules[r]:""},t}(),Ka=Oo,np={isServer:!Oo,useCSSOMInjection:!Ru},Ec=function(){function t(r,o,n){r===void 0&&(r=gr),o===void 0&&(o={});var a=this;this.options=qe(qe({},np),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&Oo&&Ka&&(Ka=!1,Za(this)),ya(this,function(){return function(s){for(var h=s.getTag(),g=h.length,c="",p=function(d){var m=function(z){return Mo.get(z)}(d);if(m===void 0)return"continue";var x=s.names.get(m),v=h.getGroup(d);if(x===void 0||!x.size||v.length===0)return"continue";var w="".concat(Jt,".g").concat(d,'[id="').concat(m,'"]'),$="";x!==void 0&&x.forEach(function(z){z.length>0&&($+="".concat(z,","))}),c+="".concat(v).concat(w,'{content:"').concat($,'"}').concat(va)},l=0;l<g;l++)p(l);return c}(a)})}return t.registerId=function(r){return Qr(r)},t.prototype.rehydrate=function(){!this.server&&Oo&&Za(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(qe(qe({},this.options),r),this.gs,o&&this.names||void 0)},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=function(o){var n=o.useCSSOMInjection,a=o.target;return o.isServer?new op(a):n?new tp(a):new rp(a)}(this.options),new qu(r)));var r},t.prototype.hasNameForId=function(r,o){return this.names.has(r)&&this.names.get(r).has(o)},t.prototype.registerName=function(r,o){if(Qr(r),this.names.has(r))this.names.get(r).add(o);else{var n=new Set;n.add(o),this.names.set(r,n)}},t.prototype.insertRules=function(r,o,n){this.registerName(r,o),this.getTag().insertRules(Qr(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(Qr(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),ap=/&/g,sp=/^\s*\/\/.*$/gm;function Pc(t,r){return t.map(function(o){return o.type==="rule"&&(o.value="".concat(r," ").concat(o.value),o.value=o.value.replaceAll(",",",".concat(r," ")),o.props=o.props.map(function(n){return"".concat(r," ").concat(n)})),Array.isArray(o.children)&&o.type!=="@keyframes"&&(o.children=Pc(o.children,r)),o})}function ip(t){var r,o,n,a=gr,s=a.options,h=s===void 0?gr:s,g=a.plugins,c=g===void 0?Ko:g,p=function(m,x,v){return v.startsWith(o)&&v.endsWith(o)&&v.replaceAll(o,"").length>0?".".concat(r):m},l=c.slice();l.push(function(m){m.type===Go&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(ap,o).replace(n,p))}),h.prefix&&l.push(Eu),l.push(Su);var d=function(m,x,v,w){x===void 0&&(x=""),v===void 0&&(v=""),w===void 0&&(w="&"),r=w,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var $=m.replace(sp,""),z=_u(v||x?"".concat(v," ").concat(x," { ").concat($," }"):$);h.namespace&&(z=Pc(z,h.namespace));var y=[];return To(z,$u(l.concat(zu(function(C){return y.push(C)})))),y};return d.hash=c.length?c.reduce(function(m,x){return x.name||wr(15),Vt(m,x.name)},yc).toString():"",d}var cp=new Ec,ca=ip(),Rc=i.createContext({shouldForwardProp:void 0,styleSheet:cp,stylis:ca});Rc.Consumer;i.createContext(void 0);function Qa(){return i.useContext(Rc)}var la=function(){function t(r,o){var n=this;this.inject=function(a,s){s===void 0&&(s=ca);var h=n.name+s.hash;a.hasNameForId(n.id,h)||a.insertRules(n.id,h,s(n.rules,h,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,ya(this,function(){throw wr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=ca),this.name+r.hash},t}(),lp=function(t){return t>="A"&&t<="Z"};function Xa(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;lp(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Ic=function(t){return t==null||t===!1||t===""},Tc=function(t){var r,o,n=[];for(var a in t){var s=t[a];t.hasOwnProperty(a)&&!Ic(s)&&(Array.isArray(s)&&s.isCss||mr(s)?n.push("".concat(Xa(a),":"),s,";"):xr(s)?n.push.apply(n,Xt(Xt(["".concat(a," {")],Tc(s),!1),["}"],!1)):n.push("".concat(Xa(a),": ").concat((r=a,(o=s)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Pu||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Yt(t,r,o,n){if(Ic(t))return[];if(ba(t))return[".".concat(t.styledComponentId)];if(mr(t)){if(!mr(s=t)||s.prototype&&s.prototype.isReactComponent||!r)return[t];var a=t(r);return process.env.NODE_ENV==="production"||typeof a!="object"||Array.isArray(a)||a instanceof la||xr(a)||a===null||console.error("".concat(kc(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Yt(a,r,o,n)}var s;return t instanceof la?o?(t.inject(o,n),[t.getName(n)]):[t]:xr(t)?Tc(t):Array.isArray(t)?Array.prototype.concat.apply(Ko,t.map(function(h){return Yt(h,r,o,n)})):[t.toString()]}function dp(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(mr(o)&&!ba(o))return!1}return!0}var up=wc(Zo),pp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&dp(r),this.componentId=o,this.baseHash=Vt(up,o),this.baseStyle=n,Ec.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var a=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))a=Ht(a,this.staticRulesId);else{var s=sa(Yt(this.rules,r,o,n)),h=aa(Vt(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,h)){var g=n(s,".".concat(h),void 0,this.componentId);o.insertRules(this.componentId,h,g)}a=Ht(a,h),this.staticRulesId=h}else{for(var c=Vt(this.baseHash,n.hash),p="",l=0;l<this.rules.length;l++){var d=this.rules[l];if(typeof d=="string")p+=d,process.env.NODE_ENV!=="production"&&(c=Vt(c,d));else if(d){var m=sa(Yt(d,r,o,n));c=Vt(c,m+l),p+=m}}if(p){var x=aa(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(p,".".concat(x),void 0,this.componentId)),a=Ht(a,x)}}return a},t}(),Oc=i.createContext(void 0);Oc.Consumer;var xn={},Ja=new Set;function hp(t,r,o){var n=ba(t),a=t,s=!mn(t),h=r.attrs,g=h===void 0?Ko:h,c=r.componentId,p=c===void 0?function(k,S){var b=typeof k!="string"?"sc":Va(k);xn[b]=(xn[b]||0)+1;var f="".concat(b,"-").concat(jc(Zo+b+xn[b]));return S?"".concat(S,"-").concat(f):f}(r.displayName,r.parentComponentId):c,l=r.displayName,d=l===void 0?function(k){return mn(k)?"styled.".concat(k):"Styled(".concat(kc(k),")")}(t):l,m=r.displayName&&r.componentId?"".concat(Va(r.displayName),"-").concat(r.componentId):r.componentId||p,x=n&&a.attrs?a.attrs.concat(g).filter(Boolean):g,v=r.shouldForwardProp;if(n&&a.shouldForwardProp){var w=a.shouldForwardProp;if(r.shouldForwardProp){var $=r.shouldForwardProp;v=function(k,S){return w(k,S)&&$(k,S)}}else v=w}var z=new pp(o,m,n?a.componentStyle:void 0);function y(k,S){return function(b,f,E){var j=b.attrs,_=b.componentStyle,I=b.defaultProps,P=b.foldedComponentIds,T=b.styledComponentId,R=b.target,O=i.useContext(Oc),D=Qa(),M=b.shouldForwardProp||D.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(T);var Y=Tu(f,O,I)||gr,N=function(G,X,se){for(var oe,ce=qe(qe({},X),{className:void 0,theme:se}),K=0;K<G.length;K+=1){var ie=mr(oe=G[K])?oe(ce):oe;for(var Z in ie)ce[Z]=Z==="className"?Ht(ce[Z],ie[Z]):Z==="style"?qe(qe({},ce[Z]),ie[Z]):ie[Z]}return X.className&&(ce.className=Ht(ce.className,X.className)),ce}(j,f,Y),J=N.as||R,ae={};for(var ee in N)N[ee]===void 0||ee[0]==="$"||ee==="as"||ee==="theme"&&N.theme===Y||(ee==="forwardedAs"?ae.as=N.forwardedAs:M&&!M(ee,J)||(ae[ee]=N[ee],M||process.env.NODE_ENV!=="development"||uu(ee)||Ja.has(ee)||!na.has(J)||(Ja.add(ee),console.warn('styled-components: it looks like an unknown prop "'.concat(ee,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var F=function(G,X){var se=Qa(),oe=G.generateAndInjectStyles(X,se.styleSheet,se.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(oe),oe}(_,N);process.env.NODE_ENV!=="production"&&b.warnTooManyClasses&&b.warnTooManyClasses(F);var U=Ht(P,T);return F&&(U+=" "+F),N.className&&(U+=" "+N.className),ae[mn(J)&&!na.has(J)?"class":"className"]=U,E&&(ae.ref=E),i.createElement(J,ae)}(C,k,S)}y.displayName=d;var C=i.forwardRef(y);return C.attrs=x,C.componentStyle=z,C.displayName=d,C.shouldForwardProp=v,C.foldedComponentIds=n?Ht(a.foldedComponentIds,a.styledComponentId):"",C.styledComponentId=m,C.target=n?a.target:t,Object.defineProperty(C,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(k){this._foldedDefaultProps=n?function(S){for(var b=[],f=1;f<arguments.length;f++)b[f-1]=arguments[f];for(var E=0,j=b;E<j.length;E++)ia(S,j[E],!0);return S}({},a.defaultProps,k):k}}),process.env.NODE_ENV!=="production"&&(Iu(d,m),C.warnTooManyClasses=function(k,S){var b={},f=!1;return function(E){if(!f&&(b[E]=!0,Object.keys(b).length>=200)){var j=S?' with the id of "'.concat(S,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(k).concat(j,`.
65
65
  `)+`Consider using the attrs method, together with a style object for frequently changed styles.
66
66
  Example:
67
67
  const Component = styled.div.attrs(props => ({
@@ -70,11 +70,11 @@ Example:
70
70
  },
71
71
  }))\`width: 100%;\`
72
72
 
73
- <Component />`),f=!0,b={}}}}(l,m)),ya(z,function(){return".".concat(z.styledComponentId)}),s&&$c(z,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),z}function es(t,r){for(var o=[t[0]],n=0,a=r.length;n<a;n+=1)o.push(r[n],t[n+1]);return o}var ts=function(t){return Object.assign(t,{isCss:!0})};function Zt(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(mr(t)||xr(t))return ts(Yt(es(Ko,Xt([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?Yt(n):ts(Yt(es(n,r)))}function da(t,r,o){if(o===void 0&&(o=gr),!r)throw yr(1,r);var n=function(a){for(var s=[],p=1;p<arguments.length;p++)s[p-1]=arguments[p];return t(r,o,Zt.apply(void 0,Xt([a],s,!1)))};return n.attrs=function(a){return da(t,r,qe(qe({},o),{attrs:Array.prototype.concat(o.attrs,a).filter(Boolean)}))},n.withConfig=function(a){return da(t,r,qe(qe({},o),a))},n}var Mc=function(t){return da(hp,t)},u=Mc;na.forEach(function(t){u[t]=Mc(t)});function wr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var n=sa(Zt.apply(void 0,Xt([t],r,!1))),a=jc(n);return new la(a,n)}process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn(`It looks like you've imported 'styled-components' on React Native.
73
+ <Component />`),f=!0,b={}}}}(d,m)),ya(C,function(){return".".concat(C.styledComponentId)}),s&&$c(C,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),C}function es(t,r){for(var o=[t[0]],n=0,a=r.length;n<a;n+=1)o.push(r[n],t[n+1]);return o}var ts=function(t){return Object.assign(t,{isCss:!0})};function Zt(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(mr(t)||xr(t))return ts(Yt(es(Ko,Xt([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?Yt(n):ts(Yt(es(n,r)))}function da(t,r,o){if(o===void 0&&(o=gr),!r)throw wr(1,r);var n=function(a){for(var s=[],h=1;h<arguments.length;h++)s[h-1]=arguments[h];return t(r,o,Zt.apply(void 0,Xt([a],s,!1)))};return n.attrs=function(a){return da(t,r,qe(qe({},o),{attrs:Array.prototype.concat(o.attrs,a).filter(Boolean)}))},n.withConfig=function(a){return da(t,r,qe(qe({},o),a))},n}var Mc=function(t){return da(hp,t)},u=Mc;na.forEach(function(t){u[t]=Mc(t)});function jr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var n=sa(Zt.apply(void 0,Xt([t],r,!1))),a=jc(n);return new la(a,n)}process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn(`It looks like you've imported 'styled-components' on React Native.
74
74
  Perhaps you're looking to import 'styled-components/native'?
75
- Read more about this at https://www.styled-components.com/docs/basics#react-native`);var Qr="__sc-".concat(Jt,"__");process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[Qr]||(window[Qr]=0),window[Qr]===1&&console.warn(`It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.
75
+ Read more about this at https://www.styled-components.com/docs/basics#react-native`);var Xr="__sc-".concat(Jt,"__");process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[Xr]||(window[Xr]=0),window[Xr]===1&&console.warn(`It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.
76
76
 
77
- See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
77
+ See https://s-c.sh/2BAXzed for more info.`),window[Xr]+=1);const le=u.div`
78
78
  /* Colors - Light Mode */
79
79
  --color-background: #ffffff;
80
80
  --color-foreground: #111827;
@@ -287,7 +287,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
287
287
  font-size: var(--font-xs);
288
288
  display: block;
289
289
  text-align: center;
290
- `;function Rt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:a=!1}){const[s,p]=i.useState(new Array(t).fill("")),[g,c]=i.useState(60),[h,d]=i.useState(!1),l=i.useRef([]),m=i.useCallback(()=>{const $=setInterval(()=>{c(y=>y<=1?(d(!0),clearInterval($),0):y-1)},1e3);return $},[]);i.useEffect(()=>{const $=m();return()=>clearInterval($)},[m]);const x=async()=>{var $;!h||a||!o||(await o(),d(!1),c(60),p(new Array(t).fill("")),($=l.current[0])==null||$.focus(),m())},v=($,y)=>{var b;if(a)return;const z=$.value,_=[...s];_[y]=z.replace(/[^0-9]/g,""),p(_);const k=_.join("");k.length===t&&r(k),z&&y<t-1&&((b=l.current[y+1])==null||b.focus())},w=($,y)=>{var z;a||$.key==="Backspace"&&!s[y]&&y>0&&((z=l.current[y-1])==null||z.focus())},C=($,y)=>{var f,I,j;if(a)return;$.preventDefault();const _=$.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(_.length===0)return;const k=[...s];for(let S=0;S<_.length&&y+S<t;S++)k[y+S]=_[S];if(y===0&&_.length===t)for(let S=0;S<t;S++)k[S]=_[S];p(k);const b=k.join("");if(b.length===t)r(b),(f=l.current[t-1])==null||f.focus();else{const S=k.findIndex((R,E)=>E>=y&&!R);if(S!==-1)(I=l.current[S])==null||I.focus();else{const R=k.map((E,T)=>E?T:-1).filter(E=>E!==-1).pop();R!==void 0&&R<t-1&&((j=l.current[R+1])==null||j.focus())}}};return e.jsxs(fp,{children:[e.jsx(gp,{children:s.map(($,y)=>e.jsx(mp,{type:"text",maxLength:1,value:$,onChange:z=>v(z.target,y),onKeyDown:z=>w(z,y),onPaste:z=>C(z,y),ref:z=>{l.current[y]=z},disabled:a,autoFocus:y===0},y))}),n&&e.jsx(xp,{children:n}),o&&e.jsx("div",{children:h?e.jsx(vp,{type:"button",onClick:x,disabled:a,children:"Didn't receive a code? Resend"}):e.jsxs(bp,{children:["Resend code in ",g,"s"]})})]})}const Lc=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...t,children:[e.jsx("title",{id:"githubIconTitle",children:"GitHub"}),e.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),Ac=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),e.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),e.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),Dc=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),e.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),e.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),e.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),Nc=t=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...t,children:e.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),yp=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Fc=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:e.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),Bc=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),wp=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Uc=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),e.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),vn={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(Dc,{})},microsoft_oauth:{shortLabel:"Microsoft",fullLabel:"Continue with Microsoft",icon:e.jsx(Ac,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(Lc,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(Nc,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(yp,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(Fc,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(Bc,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(wp,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(Uc,{})}},jp=u.div`
290
+ `;function Rt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:a=!1}){const[s,h]=i.useState(new Array(t).fill("")),[g,c]=i.useState(60),[p,l]=i.useState(!1),d=i.useRef([]),m=i.useCallback(()=>{const z=setInterval(()=>{c(y=>y<=1?(l(!0),clearInterval(z),0):y-1)},1e3);return z},[]);i.useEffect(()=>{const z=m();return()=>clearInterval(z)},[m]);const x=async()=>{var z;!p||a||!o||(await o(),l(!1),c(60),h(new Array(t).fill("")),(z=d.current[0])==null||z.focus(),m())},v=(z,y)=>{var b;if(a)return;const C=z.value,k=[...s];k[y]=C.replace(/[^0-9]/g,""),h(k);const S=k.join("");S.length===t&&r(S),C&&y<t-1&&((b=d.current[y+1])==null||b.focus())},w=(z,y)=>{var C;a||z.key==="Backspace"&&!s[y]&&y>0&&((C=d.current[y-1])==null||C.focus())},$=(z,y)=>{var f,E,j;if(a)return;z.preventDefault();const k=z.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(k.length===0)return;const S=[...s];for(let _=0;_<k.length&&y+_<t;_++)S[y+_]=k[_];if(y===0&&k.length===t)for(let _=0;_<t;_++)S[_]=k[_];h(S);const b=S.join("");if(b.length===t)r(b),(f=d.current[t-1])==null||f.focus();else{const _=S.findIndex((I,P)=>P>=y&&!I);if(_!==-1)(E=d.current[_])==null||E.focus();else{const I=S.map((P,T)=>P?T:-1).filter(P=>P!==-1).pop();I!==void 0&&I<t-1&&((j=d.current[I+1])==null||j.focus())}}};return e.jsxs(fp,{children:[e.jsx(gp,{children:s.map((z,y)=>e.jsx(mp,{type:"text",maxLength:1,value:z,onChange:C=>v(C.target,y),onKeyDown:C=>w(C,y),onPaste:C=>$(C,y),ref:C=>{d.current[y]=C},disabled:a,autoFocus:y===0},y))}),n&&e.jsx(xp,{children:n}),o&&e.jsx("div",{children:p?e.jsx(vp,{type:"button",onClick:x,disabled:a,children:"Didn't receive a code? Resend"}):e.jsxs(bp,{children:["Resend code in ",g,"s"]})})]})}const Lc=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...t,children:[e.jsx("title",{id:"githubIconTitle",children:"GitHub"}),e.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),Ac=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),e.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),e.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),Dc=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),e.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),e.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),e.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),Nc=t=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...t,children:e.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),yp=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),Fc=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:e.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),Bc=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),wp=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),Uc=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),e.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),vn={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(Dc,{})},microsoft_oauth:{shortLabel:"Microsoft",fullLabel:"Continue with Microsoft",icon:e.jsx(Ac,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(Lc,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(Nc,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(yp,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(Fc,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(Bc,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(wp,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(Uc,{})}},jp=u.div`
291
291
  display: flex;
292
292
  flex-direction: column;
293
293
  gap: var(--space-xs);
@@ -331,7 +331,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
331
331
  height: 16px;
332
332
  flex-shrink: 0;
333
333
  }
334
- `,wa=({connections:t,callback:r})=>{const o=()=>t.length<=6?[t]:t.length<=12?[t.slice(0,4),t.slice(4)]:[t.slice(0,4),t.slice(4,8),t.slice(8)],n=t.length,a=o();return e.jsx(jp,{children:a.map((s,p)=>e.jsx(kp,{children:s.map((g,c)=>{const h=g.provider;return e.jsxs(_p,{onClick:()=>r(g),type:"button",$isWide:a.length>1&&p<a.length-1,$totalProviders:n,children:[vn[h].icon,n<3&&e.jsx("span",{children:n===1?vn[h].fullLabel:vn[h].shortLabel})]},`${g.provider}-${c}`)})},`row-${p}`))})},tt=({to:t,replace:r,children:o,...n})=>{const{navigate:a}=He(),s=i.useCallback(p=>{p.preventDefault(),a(t,{replace:r})},[t,r,a]);return e.jsx("a",{href:t,onClick:s,...n,children:o})},Cp={sm:"36rem"},de=u.input`
334
+ `,wa=({connections:t,callback:r})=>{const o=()=>t.length<=6?[t]:t.length<=12?[t.slice(0,4),t.slice(4)]:[t.slice(0,4),t.slice(4,8),t.slice(8)],n=t.length,a=o();return e.jsx(jp,{children:a.map((s,h)=>e.jsx(kp,{children:s.map((g,c)=>{const p=g.provider;return e.jsxs(_p,{onClick:()=>r(g),type:"button",$isWide:a.length>1&&h<a.length-1,$totalProviders:n,children:[vn[p].icon,n<3&&e.jsx("span",{children:n===1?vn[p].fullLabel:vn[p].shortLabel})]},`${g.provider}-${c}`)})},`row-${h}`))})},tt=({to:t,replace:r,children:o,...n})=>{const{navigate:a}=He(),s=i.useCallback(h=>{h.preventDefault(),a(t,{replace:r})},[t,r,a]);return e.jsx("a",{href:t,onClick:s,...n,children:o})},Cp={sm:"36rem"},de=u.input`
335
335
  padding: var(--space-sm) var(--space-md);
336
336
  width: 100%;
337
337
  height: 36px;
@@ -376,12 +376,12 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
376
376
  font-size: var(--font-2xs);
377
377
  padding: var(--space-xs) var(--space-sm);
378
378
  }
379
- `,Eo=[{name:"Afghanistan",code:"AF",dialCode:"+93",flag:"🇦🇫"},{name:"Albania",code:"AL",dialCode:"+355",flag:"🇦🇱"},{name:"Algeria",code:"DZ",dialCode:"+213",flag:"🇩🇿"},{name:"American Samoa",code:"AS",dialCode:"+1684",flag:"🇺🇸"},{name:"Andorra",code:"AD",dialCode:"+376",flag:"🇦🇩"},{name:"Angola",code:"AO",dialCode:"+244",flag:"🇦🇴"},{name:"Anguilla",code:"AI",dialCode:"+1264",flag:"🇦🇮"},{name:"Antarctica",code:"AQ",dialCode:"+672",flag:"🇦🇶"},{name:"Antigua and Barbuda",code:"AG",dialCode:"+1268",flag:"🇦🇬"},{name:"Argentina",code:"AR",dialCode:"+54",flag:"🇦🇷"},{name:"Armenia",code:"AM",dialCode:"+374",flag:"🇦🇲"},{name:"Aruba",code:"AW",dialCode:"+297",flag:"🇦🇼"},{name:"Australia",code:"AU",dialCode:"+61",flag:"🇦🇺"},{name:"Austria",code:"AT",dialCode:"+43",flag:"🇦🇹"},{name:"Azerbaijan",code:"AZ",dialCode:"+994",flag:"🇦🇿"},{name:"Bahamas",code:"BS",dialCode:"+1242",flag:"🇧🇸"},{name:"Bahrain",code:"BH",dialCode:"+973",flag:"🇧🇭"},{name:"Bangladesh",code:"BD",dialCode:"+880",flag:"🇧🇩"},{name:"Barbados",code:"BB",dialCode:"+1246",flag:"🇧🇧"},{name:"Belarus",code:"BY",dialCode:"+375",flag:"🇧🇾"},{name:"Belgium",code:"BE",dialCode:"+32",flag:"🇧🇪"},{name:"Belize",code:"BZ",dialCode:"+501",flag:"🇧🇿"},{name:"Benin",code:"BJ",dialCode:"+229",flag:"🇧🇯"},{name:"Bermuda",code:"BM",dialCode:"+1441",flag:"🇧🇲"},{name:"Bhutan",code:"BT",dialCode:"+975",flag:"🇧🇹"},{name:"Bolivia",code:"BO",dialCode:"+591",flag:"🇧🇴"},{name:"Bosnia and Herzegovina",code:"BA",dialCode:"+387",flag:"🇧🇦"},{name:"Botswana",code:"BW",dialCode:"+267",flag:"🇧🇼"},{name:"Brazil",code:"BR",dialCode:"+55",flag:"🇧🇷"},{name:"British Indian Ocean Territory",code:"IO",dialCode:"+246",flag:"🇮🇴"},{name:"British Virgin Islands",code:"VG",dialCode:"+1284",flag:"🇻🇬"},{name:"Brunei",code:"BN",dialCode:"+673",flag:"🇧🇳"},{name:"Bulgaria",code:"BG",dialCode:"+359",flag:"🇧🇬"},{name:"Burkina Faso",code:"BF",dialCode:"+226",flag:"🇧🇫"},{name:"Burundi",code:"BI",dialCode:"+257",flag:"🇧🇮"},{name:"Cambodia",code:"KH",dialCode:"+855",flag:"🇰🇭"},{name:"Cameroon",code:"CM",dialCode:"+237",flag:"🇨🇲"},{name:"Canada",code:"CA",dialCode:"+1",flag:"🇨🇦"},{name:"Cape Verde",code:"CV",dialCode:"+238",flag:"🇨🇻"},{name:"Cayman Islands",code:"KY",dialCode:"+1345",flag:"🇰🇾"},{name:"Central African Republic",code:"CF",dialCode:"+236",flag:"🇨🇫"},{name:"Chad",code:"TD",dialCode:"+235",flag:"🇹🇩"},{name:"Chile",code:"CL",dialCode:"+56",flag:"🇨🇱"},{name:"China",code:"CN",dialCode:"+86",flag:"🇨🇳"},{name:"Christmas Island",code:"CX",dialCode:"+61",flag:"🇨🇽"},{name:"Cocos Islands",code:"CC",dialCode:"+61",flag:"🇨🇨"},{name:"Colombia",code:"CO",dialCode:"+57",flag:"🇨🇴"},{name:"Comoros",code:"KM",dialCode:"+269",flag:"🇰🇲"},{name:"Cook Islands",code:"CK",dialCode:"+682",flag:"🇨🇰"},{name:"Costa Rica",code:"CR",dialCode:"+506",flag:"🇨🇷"},{name:"Croatia",code:"HR",dialCode:"+385",flag:"🇭🇷"},{name:"Cuba",code:"CU",dialCode:"+53",flag:"🇨🇺"},{name:"Curacao",code:"CW",dialCode:"+599",flag:"🇨🇼"},{name:"Cyprus",code:"CY",dialCode:"+357",flag:"🇨🇾"},{name:"Czech Republic",code:"CZ",dialCode:"+420",flag:"🇨🇿"},{name:"Democratic Republic of the Congo",code:"CD",dialCode:"+243",flag:"🇨🇩"},{name:"Denmark",code:"DK",dialCode:"+45",flag:"🇩🇰"},{name:"Djibouti",code:"DJ",dialCode:"+253",flag:"🇩🇯"},{name:"Dominica",code:"DM",dialCode:"+1767",flag:"🇩🇲"},{name:"Dominican Republic",code:"DO",dialCode:"+1849",flag:"🇩🇴"},{name:"East Timor",code:"TL",dialCode:"+670",flag:"🇹🇱"},{name:"Ecuador",code:"EC",dialCode:"+593",flag:"🇪🇨"},{name:"Egypt",code:"EG",dialCode:"+20",flag:"🇪🇬"},{name:"El Salvador",code:"SV",dialCode:"+503",flag:"🇸🇻"},{name:"Equatorial Guinea",code:"GQ",dialCode:"+240",flag:"🇬🇶"},{name:"Eritrea",code:"ER",dialCode:"+291",flag:"🇪🇷"},{name:"Estonia",code:"EE",dialCode:"+372",flag:"🇪🇪"},{name:"Ethiopia",code:"ET",dialCode:"+251",flag:"🇪🇹"},{name:"Falkland Islands",code:"FK",dialCode:"+500",flag:"🇫🇰"},{name:"Faroe Islands",code:"FO",dialCode:"+298",flag:"🇫🇴"},{name:"Fiji",code:"FJ",dialCode:"+679",flag:"🇫🇯"},{name:"Finland",code:"FI",dialCode:"+358",flag:"🇫🇮"},{name:"France",code:"FR",dialCode:"+33",flag:"🇫🇷"},{name:"French Polynesia",code:"PF",dialCode:"+689",flag:"🇵🇫"},{name:"Gabon",code:"GA",dialCode:"+241",flag:"🇬🇦"},{name:"Gambia",code:"GM",dialCode:"+220",flag:"🇬🇲"},{name:"Georgia",code:"GE",dialCode:"+995",flag:"🇬🇪"},{name:"Germany",code:"DE",dialCode:"+49",flag:"🇩🇪"},{name:"Ghana",code:"GH",dialCode:"+233",flag:"🇬🇭"},{name:"Gibraltar",code:"GI",dialCode:"+350",flag:"🇬🇮"},{name:"Greece",code:"GR",dialCode:"+30",flag:"🇬🇷"},{name:"Greenland",code:"GL",dialCode:"+299",flag:"🇬🇱"},{name:"Grenada",code:"GD",dialCode:"+1473",flag:"🇬🇩"},{name:"Guam",code:"GU",dialCode:"+1671",flag:"🇬🇺"},{name:"Guatemala",code:"GT",dialCode:"+502",flag:"🇬🇹"},{name:"Guernsey",code:"GG",dialCode:"+44",flag:"🇬🇬"},{name:"Guinea",code:"GN",dialCode:"+224",flag:"🇬🇳"},{name:"Guinea-Bissau",code:"GW",dialCode:"+245",flag:"🇬🇼"},{name:"Guyana",code:"GY",dialCode:"+592",flag:"🇬🇾"},{name:"Haiti",code:"HT",dialCode:"+509",flag:"🇭🇹"},{name:"Honduras",code:"HN",dialCode:"+504",flag:"🇭🇳"},{name:"Hong Kong",code:"HK",dialCode:"+852",flag:"🇭🇰"},{name:"Hungary",code:"HU",dialCode:"+36",flag:"🇭🇺"},{name:"Iceland",code:"IS",dialCode:"+354",flag:"🇮🇸"},{name:"India",code:"IN",dialCode:"+91",flag:"🇮🇳"},{name:"Indonesia",code:"ID",dialCode:"+62",flag:"🇮🇩"},{name:"Iran",code:"IR",dialCode:"+98",flag:"🇮🇷"},{name:"Iraq",code:"IQ",dialCode:"+964",flag:"🇮🇶"},{name:"Ireland",code:"IE",dialCode:"+353",flag:"🇮🇪"},{name:"Isle of Man",code:"IM",dialCode:"+44",flag:"🇮🇲"},{name:"Israel",code:"IL",dialCode:"+972",flag:"🇮🇱"},{name:"Italy",code:"IT",dialCode:"+39",flag:"🇮🇹"},{name:"Ivory Coast",code:"CI",dialCode:"+225",flag:"🇨🇮"},{name:"Jamaica",code:"JM",dialCode:"+1876",flag:"🇯🇲"},{name:"Japan",code:"JP",dialCode:"+81",flag:"🇯🇵"},{name:"Jersey",code:"JE",dialCode:"+44",flag:"🇬🇬"},{name:"Jordan",code:"JO",dialCode:"+962",flag:"🇯🇴"},{name:"Kazakhstan",code:"KZ",dialCode:"+7",flag:"🇰🇿"},{name:"Kenya",code:"KE",dialCode:"+254",flag:"🇰🇪"},{name:"Kiribati",code:"KI",dialCode:"+686",flag:"🇰🇮"},{name:"Kosovo",code:"XK",dialCode:"+383",flag:"🇽🇰"},{name:"Kuwait",code:"KW",dialCode:"+965",flag:"🇰🇼"},{name:"Kyrgyzstan",code:"KG",dialCode:"+996",flag:"🇰🇬"},{name:"Laos",code:"LA",dialCode:"+856",flag:"🇱🇦"},{name:"Latvia",code:"LV",dialCode:"+371",flag:"🇱🇻"},{name:"Lebanon",code:"LB",dialCode:"+961",flag:"🇱🇧"},{name:"Lesotho",code:"LS",dialCode:"+266",flag:"🇱🇸"},{name:"Liberia",code:"LR",dialCode:"+231",flag:"🇱🇷"},{name:"Libya",code:"LY",dialCode:"+218",flag:"🇱🇾"},{name:"Liechtenstein",code:"LI",dialCode:"+423",flag:"🇱🇮"},{name:"Lithuania",code:"LT",dialCode:"+370",flag:"🇱🇹"},{name:"Luxembourg",code:"LU",dialCode:"+352",flag:"🇱🇺"},{name:"Macau",code:"MO",dialCode:"+853",flag:"🇲🇴"},{name:"Macedonia",code:"MK",dialCode:"+389",flag:"🇲🇰"},{name:"Madagascar",code:"MG",dialCode:"+261",flag:"🇲🇬"},{name:"Malawi",code:"MW",dialCode:"+265",flag:"🇲🇼"},{name:"Malaysia",code:"MY",dialCode:"+60",flag:"🇲🇾"},{name:"Maldives",code:"MV",dialCode:"+960",flag:"🇲🇻"},{name:"Mali",code:"ML",dialCode:"+223",flag:"🇲🇱"},{name:"Malta",code:"MT",dialCode:"+356",flag:"🇲🇹"},{name:"Marshall Islands",code:"MH",dialCode:"+692",flag:"🇲🇭"},{name:"Mauritania",code:"MR",dialCode:"+222",flag:"🇲🇷"},{name:"Mauritius",code:"MU",dialCode:"+230",flag:"🇲🇺"},{name:"Mayotte",code:"YT",dialCode:"+262",flag:"🇾🇹"},{name:"Mexico",code:"MX",dialCode:"+52",flag:"🇲🇽"},{name:"Micronesia",code:"FM",dialCode:"+691",flag:"🇫🇲"},{name:"Moldova",code:"MD",dialCode:"+373",flag:"🇲🇩"},{name:"Monaco",code:"MC",dialCode:"+377",flag:"🇲🇨"},{name:"Mongolia",code:"MN",dialCode:"+976",flag:"🇲🇳"},{name:"Montenegro",code:"ME",dialCode:"+382",flag:"🇲🇪"},{name:"Montserrat",code:"MS",dialCode:"+1664",flag:"🇲🇸"},{name:"Morocco",code:"MA",dialCode:"+212",flag:"🇲🇦"},{name:"Mozambique",code:"MZ",dialCode:"+258",flag:"🇲🇿"},{name:"Myanmar",code:"MM",dialCode:"+95",flag:"🇲🇲"},{name:"Namibia",code:"NA",dialCode:"+264",flag:"🇳🇦"},{name:"Nauru",code:"NR",dialCode:"+674",flag:"🇳🇷"},{name:"Nepal",code:"NP",dialCode:"+977",flag:"🇳🇵"},{name:"Netherlands",code:"NL",dialCode:"+31",flag:"🇳🇱"},{name:"Netherlands Antilles",code:"AN",dialCode:"+599",flag:"🇳🇱"},{name:"New Caledonia",code:"NC",dialCode:"+687",flag:"🇳🇨"},{name:"New Zealand",code:"NZ",dialCode:"+64",flag:"🇳🇿"},{name:"Nicaragua",code:"NI",dialCode:"+505",flag:"🇳🇮"},{name:"Niger",code:"NE",dialCode:"+227",flag:"🇳🇪"},{name:"Nigeria",code:"NG",dialCode:"+234",flag:"🇳🇬"},{name:"Niue",code:"NU",dialCode:"+683",flag:"🇳🇺"},{name:"North Korea",code:"KP",dialCode:"+850",flag:"🇰🇵"},{name:"Northern Mariana Islands",code:"MP",dialCode:"+1670",flag:"🇲🇵"},{name:"Norway",code:"NO",dialCode:"+47",flag:"🇳🇴"},{name:"Oman",code:"OM",dialCode:"+968",flag:"🇴🇲"},{name:"Pakistan",code:"PK",dialCode:"+92",flag:"🇵🇰"},{name:"Palau",code:"PW",dialCode:"+680",flag:"🇵🇼"},{name:"Palestine",code:"PS",dialCode:"+970",flag:"🇵🇸"},{name:"Panama",code:"PA",dialCode:"+507",flag:"🇵🇦"},{name:"Papua New Guinea",code:"PG",dialCode:"+675",flag:"🇵🇬"},{name:"Paraguay",code:"PY",dialCode:"+595",flag:"🇵🇾"},{name:"Peru",code:"PE",dialCode:"+51",flag:"🇵🇪"},{name:"Philippines",code:"PH",dialCode:"+63",flag:"🇵🇭"},{name:"Pitcairn",code:"PN",dialCode:"+64",flag:"🇵🇳"},{name:"Poland",code:"PL",dialCode:"+48",flag:"🇵🇱"},{name:"Portugal",code:"PT",dialCode:"+351",flag:"🇵🇹"},{name:"Puerto Rico",code:"PR",dialCode:"+1939",flag:"🇵🇷"},{name:"Qatar",code:"QA",dialCode:"+974",flag:"🇶🇦"},{name:"Republic of the Congo",code:"CG",dialCode:"+242",flag:"🇨🇬"},{name:"Reunion",code:"RE",dialCode:"+262",flag:"🇷🇪"},{name:"Romania",code:"RO",dialCode:"+40",flag:"🇷🇴"},{name:"Russia",code:"RU",dialCode:"+7",flag:"🇷🇺"},{name:"Rwanda",code:"RW",dialCode:"+250",flag:"🇷🇼"},{name:"Saint Barthelemy",code:"BL",dialCode:"+590",flag:"🇧🇱"},{name:"Saint Helena",code:"SH",dialCode:"+290",flag:"🇸🇭"},{name:"Saint Kitts and Nevis",code:"KN",dialCode:"+1869",flag:"🇰🇳"},{name:"Saint Lucia",code:"LC",dialCode:"+1758",flag:"🇱🇨"},{name:"Saint Martin",code:"MF",dialCode:"+590",flag:"🇲🇫"},{name:"Saint Pierre and Miquelon",code:"PM",dialCode:"+508",flag:"🇵🇲"},{name:"Saint Vincent and the Grenadines",code:"VC",dialCode:"+1784",flag:"🇻🇨"},{name:"Samoa",code:"WS",dialCode:"+685",flag:"🇼🇸"},{name:"San Marino",code:"SM",dialCode:"+378",flag:"🇸🇲"},{name:"Sao Tome and Principe",code:"ST",dialCode:"+239",flag:"🇸🇹"},{name:"Saudi Arabia",code:"SA",dialCode:"+966",flag:"🇸🇦"},{name:"Senegal",code:"SN",dialCode:"+221",flag:"🇸🇳"},{name:"Serbia",code:"RS",dialCode:"+381",flag:"🇷🇸"},{name:"Seychelles",code:"SC",dialCode:"+248",flag:"🇸🇨"},{name:"Sierra Leone",code:"SL",dialCode:"+232",flag:"🇸🇱"},{name:"Singapore",code:"SG",dialCode:"+65",flag:"🇸🇬"},{name:"Sint Maarten",code:"SX",dialCode:"+1721",flag:"🇸🇽"},{name:"Slovakia",code:"SK",dialCode:"+421",flag:"🇸🇰"},{name:"Slovenia",code:"SI",dialCode:"+386",flag:"🇸🇮"},{name:"Solomon Islands",code:"SB",dialCode:"+677",flag:"🇸🇧"},{name:"Somalia",code:"SO",dialCode:"+252",flag:"🇸🇴"},{name:"South Africa",code:"ZA",dialCode:"+27",flag:"🇿🇦"},{name:"South Korea",code:"KR",dialCode:"+82",flag:"🇰🇷"},{name:"South Sudan",code:"SS",dialCode:"+211",flag:"🇸🇸"},{name:"Spain",code:"ES",dialCode:"+34",flag:"🇪🇸"},{name:"Sri Lanka",code:"LK",dialCode:"+94",flag:"🇱🇰"},{name:"Sudan",code:"SD",dialCode:"+249",flag:"🇸🇩"},{name:"Suriname",code:"SR",dialCode:"+597",flag:"🇸🇷"},{name:"Svalbard and Jan Mayen",code:"SJ",dialCode:"+47",flag:"🇸🇯"},{name:"Swaziland",code:"SZ",dialCode:"+268",flag:"🇸🇿"},{name:"Sweden",code:"SE",dialCode:"+46",flag:"🇸🇪"},{name:"Switzerland",code:"CH",dialCode:"+41",flag:"🇨🇭"},{name:"Syria",code:"SY",dialCode:"+963",flag:"🇸🇾"},{name:"Taiwan",code:"TW",dialCode:"+886",flag:"🇹🇼"},{name:"Tajikistan",code:"TJ",dialCode:"+992",flag:"🇹🇯"},{name:"Tanzania",code:"TZ",dialCode:"+255",flag:"🇹🇿"},{name:"Thailand",code:"TH",dialCode:"+66",flag:"🇹🇭"},{name:"Togo",code:"TG",dialCode:"+228",flag:"🇹🇬"},{name:"Tokelau",code:"TK",dialCode:"+690",flag:"🇹🇰"},{name:"Tonga",code:"TO",dialCode:"+676",flag:"🇹🇴"},{name:"Trinidad and Tobago",code:"TT",dialCode:"+1868",flag:"🇹🇹"},{name:"Tunisia",code:"TN",dialCode:"+216",flag:"🇹🇳"},{name:"Turkey",code:"TR",dialCode:"+90",flag:"🇹🇷"},{name:"Turkmenistan",code:"TM",dialCode:"+993",flag:"🇹🇲"},{name:"Turks and Caicos Islands",code:"TC",dialCode:"+1649",flag:"🇹🇨"},{name:"Tuvalu",code:"TV",dialCode:"+688",flag:"🇹🇻"},{name:"U.S. Virgin Islands",code:"VI",dialCode:"+1340",flag:"🇻🇮"},{name:"Uganda",code:"UG",dialCode:"+256",flag:"🇺🇬"},{name:"Ukraine",code:"UA",dialCode:"+380",flag:"🇺🇦"},{name:"United Arab Emirates",code:"AE",dialCode:"+971",flag:"🇦🇪"},{name:"United Kingdom",code:"GB",dialCode:"+44",flag:"🇬🇧"},{name:"United States",code:"US",dialCode:"+1",flag:"🇺🇸"},{name:"Uruguay",code:"UY",dialCode:"+598",flag:"🇺🇾"},{name:"Uzbekistan",code:"UZ",dialCode:"+998",flag:"🇺🇿"},{name:"Vanuatu",code:"VU",dialCode:"+678",flag:"🇻🇺"},{name:"Vatican",code:"VA",dialCode:"+379",flag:"🇻🇦"},{name:"Venezuela",code:"VE",dialCode:"+58",flag:"🇻🇪"},{name:"Vietnam",code:"VN",dialCode:"+84",flag:"🇻🇳"},{name:"Wallis and Futuna",code:"WF",dialCode:"+681",flag:"🇼🇫"},{name:"Western Sahara",code:"EH",dialCode:"+212",flag:"🇪🇭"},{name:"Yemen",code:"YE",dialCode:"+967",flag:"🇾🇪"},{name:"Zambia",code:"ZM",dialCode:"+260",flag:"🇿🇲"},{name:"Zimbabwe",code:"ZW",dialCode:"+263",flag:"🇿🇼"}],jr={sm:"36rem"},Sp=u.div`
379
+ `,Po=[{name:"Afghanistan",code:"AF",dialCode:"+93",flag:"🇦🇫"},{name:"Albania",code:"AL",dialCode:"+355",flag:"🇦🇱"},{name:"Algeria",code:"DZ",dialCode:"+213",flag:"🇩🇿"},{name:"American Samoa",code:"AS",dialCode:"+1684",flag:"🇺🇸"},{name:"Andorra",code:"AD",dialCode:"+376",flag:"🇦🇩"},{name:"Angola",code:"AO",dialCode:"+244",flag:"🇦🇴"},{name:"Anguilla",code:"AI",dialCode:"+1264",flag:"🇦🇮"},{name:"Antarctica",code:"AQ",dialCode:"+672",flag:"🇦🇶"},{name:"Antigua and Barbuda",code:"AG",dialCode:"+1268",flag:"🇦🇬"},{name:"Argentina",code:"AR",dialCode:"+54",flag:"🇦🇷"},{name:"Armenia",code:"AM",dialCode:"+374",flag:"🇦🇲"},{name:"Aruba",code:"AW",dialCode:"+297",flag:"🇦🇼"},{name:"Australia",code:"AU",dialCode:"+61",flag:"🇦🇺"},{name:"Austria",code:"AT",dialCode:"+43",flag:"🇦🇹"},{name:"Azerbaijan",code:"AZ",dialCode:"+994",flag:"🇦🇿"},{name:"Bahamas",code:"BS",dialCode:"+1242",flag:"🇧🇸"},{name:"Bahrain",code:"BH",dialCode:"+973",flag:"🇧🇭"},{name:"Bangladesh",code:"BD",dialCode:"+880",flag:"🇧🇩"},{name:"Barbados",code:"BB",dialCode:"+1246",flag:"🇧🇧"},{name:"Belarus",code:"BY",dialCode:"+375",flag:"🇧🇾"},{name:"Belgium",code:"BE",dialCode:"+32",flag:"🇧🇪"},{name:"Belize",code:"BZ",dialCode:"+501",flag:"🇧🇿"},{name:"Benin",code:"BJ",dialCode:"+229",flag:"🇧🇯"},{name:"Bermuda",code:"BM",dialCode:"+1441",flag:"🇧🇲"},{name:"Bhutan",code:"BT",dialCode:"+975",flag:"🇧🇹"},{name:"Bolivia",code:"BO",dialCode:"+591",flag:"🇧🇴"},{name:"Bosnia and Herzegovina",code:"BA",dialCode:"+387",flag:"🇧🇦"},{name:"Botswana",code:"BW",dialCode:"+267",flag:"🇧🇼"},{name:"Brazil",code:"BR",dialCode:"+55",flag:"🇧🇷"},{name:"British Indian Ocean Territory",code:"IO",dialCode:"+246",flag:"🇮🇴"},{name:"British Virgin Islands",code:"VG",dialCode:"+1284",flag:"🇻🇬"},{name:"Brunei",code:"BN",dialCode:"+673",flag:"🇧🇳"},{name:"Bulgaria",code:"BG",dialCode:"+359",flag:"🇧🇬"},{name:"Burkina Faso",code:"BF",dialCode:"+226",flag:"🇧🇫"},{name:"Burundi",code:"BI",dialCode:"+257",flag:"🇧🇮"},{name:"Cambodia",code:"KH",dialCode:"+855",flag:"🇰🇭"},{name:"Cameroon",code:"CM",dialCode:"+237",flag:"🇨🇲"},{name:"Canada",code:"CA",dialCode:"+1",flag:"🇨🇦"},{name:"Cape Verde",code:"CV",dialCode:"+238",flag:"🇨🇻"},{name:"Cayman Islands",code:"KY",dialCode:"+1345",flag:"🇰🇾"},{name:"Central African Republic",code:"CF",dialCode:"+236",flag:"🇨🇫"},{name:"Chad",code:"TD",dialCode:"+235",flag:"🇹🇩"},{name:"Chile",code:"CL",dialCode:"+56",flag:"🇨🇱"},{name:"China",code:"CN",dialCode:"+86",flag:"🇨🇳"},{name:"Christmas Island",code:"CX",dialCode:"+61",flag:"🇨🇽"},{name:"Cocos Islands",code:"CC",dialCode:"+61",flag:"🇨🇨"},{name:"Colombia",code:"CO",dialCode:"+57",flag:"🇨🇴"},{name:"Comoros",code:"KM",dialCode:"+269",flag:"🇰🇲"},{name:"Cook Islands",code:"CK",dialCode:"+682",flag:"🇨🇰"},{name:"Costa Rica",code:"CR",dialCode:"+506",flag:"🇨🇷"},{name:"Croatia",code:"HR",dialCode:"+385",flag:"🇭🇷"},{name:"Cuba",code:"CU",dialCode:"+53",flag:"🇨🇺"},{name:"Curacao",code:"CW",dialCode:"+599",flag:"🇨🇼"},{name:"Cyprus",code:"CY",dialCode:"+357",flag:"🇨🇾"},{name:"Czech Republic",code:"CZ",dialCode:"+420",flag:"🇨🇿"},{name:"Democratic Republic of the Congo",code:"CD",dialCode:"+243",flag:"🇨🇩"},{name:"Denmark",code:"DK",dialCode:"+45",flag:"🇩🇰"},{name:"Djibouti",code:"DJ",dialCode:"+253",flag:"🇩🇯"},{name:"Dominica",code:"DM",dialCode:"+1767",flag:"🇩🇲"},{name:"Dominican Republic",code:"DO",dialCode:"+1849",flag:"🇩🇴"},{name:"East Timor",code:"TL",dialCode:"+670",flag:"🇹🇱"},{name:"Ecuador",code:"EC",dialCode:"+593",flag:"🇪🇨"},{name:"Egypt",code:"EG",dialCode:"+20",flag:"🇪🇬"},{name:"El Salvador",code:"SV",dialCode:"+503",flag:"🇸🇻"},{name:"Equatorial Guinea",code:"GQ",dialCode:"+240",flag:"🇬🇶"},{name:"Eritrea",code:"ER",dialCode:"+291",flag:"🇪🇷"},{name:"Estonia",code:"EE",dialCode:"+372",flag:"🇪🇪"},{name:"Ethiopia",code:"ET",dialCode:"+251",flag:"🇪🇹"},{name:"Falkland Islands",code:"FK",dialCode:"+500",flag:"🇫🇰"},{name:"Faroe Islands",code:"FO",dialCode:"+298",flag:"🇫🇴"},{name:"Fiji",code:"FJ",dialCode:"+679",flag:"🇫🇯"},{name:"Finland",code:"FI",dialCode:"+358",flag:"🇫🇮"},{name:"France",code:"FR",dialCode:"+33",flag:"🇫🇷"},{name:"French Polynesia",code:"PF",dialCode:"+689",flag:"🇵🇫"},{name:"Gabon",code:"GA",dialCode:"+241",flag:"🇬🇦"},{name:"Gambia",code:"GM",dialCode:"+220",flag:"🇬🇲"},{name:"Georgia",code:"GE",dialCode:"+995",flag:"🇬🇪"},{name:"Germany",code:"DE",dialCode:"+49",flag:"🇩🇪"},{name:"Ghana",code:"GH",dialCode:"+233",flag:"🇬🇭"},{name:"Gibraltar",code:"GI",dialCode:"+350",flag:"🇬🇮"},{name:"Greece",code:"GR",dialCode:"+30",flag:"🇬🇷"},{name:"Greenland",code:"GL",dialCode:"+299",flag:"🇬🇱"},{name:"Grenada",code:"GD",dialCode:"+1473",flag:"🇬🇩"},{name:"Guam",code:"GU",dialCode:"+1671",flag:"🇬🇺"},{name:"Guatemala",code:"GT",dialCode:"+502",flag:"🇬🇹"},{name:"Guernsey",code:"GG",dialCode:"+44",flag:"🇬🇬"},{name:"Guinea",code:"GN",dialCode:"+224",flag:"🇬🇳"},{name:"Guinea-Bissau",code:"GW",dialCode:"+245",flag:"🇬🇼"},{name:"Guyana",code:"GY",dialCode:"+592",flag:"🇬🇾"},{name:"Haiti",code:"HT",dialCode:"+509",flag:"🇭🇹"},{name:"Honduras",code:"HN",dialCode:"+504",flag:"🇭🇳"},{name:"Hong Kong",code:"HK",dialCode:"+852",flag:"🇭🇰"},{name:"Hungary",code:"HU",dialCode:"+36",flag:"🇭🇺"},{name:"Iceland",code:"IS",dialCode:"+354",flag:"🇮🇸"},{name:"India",code:"IN",dialCode:"+91",flag:"🇮🇳"},{name:"Indonesia",code:"ID",dialCode:"+62",flag:"🇮🇩"},{name:"Iran",code:"IR",dialCode:"+98",flag:"🇮🇷"},{name:"Iraq",code:"IQ",dialCode:"+964",flag:"🇮🇶"},{name:"Ireland",code:"IE",dialCode:"+353",flag:"🇮🇪"},{name:"Isle of Man",code:"IM",dialCode:"+44",flag:"🇮🇲"},{name:"Israel",code:"IL",dialCode:"+972",flag:"🇮🇱"},{name:"Italy",code:"IT",dialCode:"+39",flag:"🇮🇹"},{name:"Ivory Coast",code:"CI",dialCode:"+225",flag:"🇨🇮"},{name:"Jamaica",code:"JM",dialCode:"+1876",flag:"🇯🇲"},{name:"Japan",code:"JP",dialCode:"+81",flag:"🇯🇵"},{name:"Jersey",code:"JE",dialCode:"+44",flag:"🇬🇬"},{name:"Jordan",code:"JO",dialCode:"+962",flag:"🇯🇴"},{name:"Kazakhstan",code:"KZ",dialCode:"+7",flag:"🇰🇿"},{name:"Kenya",code:"KE",dialCode:"+254",flag:"🇰🇪"},{name:"Kiribati",code:"KI",dialCode:"+686",flag:"🇰🇮"},{name:"Kosovo",code:"XK",dialCode:"+383",flag:"🇽🇰"},{name:"Kuwait",code:"KW",dialCode:"+965",flag:"🇰🇼"},{name:"Kyrgyzstan",code:"KG",dialCode:"+996",flag:"🇰🇬"},{name:"Laos",code:"LA",dialCode:"+856",flag:"🇱🇦"},{name:"Latvia",code:"LV",dialCode:"+371",flag:"🇱🇻"},{name:"Lebanon",code:"LB",dialCode:"+961",flag:"🇱🇧"},{name:"Lesotho",code:"LS",dialCode:"+266",flag:"🇱🇸"},{name:"Liberia",code:"LR",dialCode:"+231",flag:"🇱🇷"},{name:"Libya",code:"LY",dialCode:"+218",flag:"🇱🇾"},{name:"Liechtenstein",code:"LI",dialCode:"+423",flag:"🇱🇮"},{name:"Lithuania",code:"LT",dialCode:"+370",flag:"🇱🇹"},{name:"Luxembourg",code:"LU",dialCode:"+352",flag:"🇱🇺"},{name:"Macau",code:"MO",dialCode:"+853",flag:"🇲🇴"},{name:"Macedonia",code:"MK",dialCode:"+389",flag:"🇲🇰"},{name:"Madagascar",code:"MG",dialCode:"+261",flag:"🇲🇬"},{name:"Malawi",code:"MW",dialCode:"+265",flag:"🇲🇼"},{name:"Malaysia",code:"MY",dialCode:"+60",flag:"🇲🇾"},{name:"Maldives",code:"MV",dialCode:"+960",flag:"🇲🇻"},{name:"Mali",code:"ML",dialCode:"+223",flag:"🇲🇱"},{name:"Malta",code:"MT",dialCode:"+356",flag:"🇲🇹"},{name:"Marshall Islands",code:"MH",dialCode:"+692",flag:"🇲🇭"},{name:"Mauritania",code:"MR",dialCode:"+222",flag:"🇲🇷"},{name:"Mauritius",code:"MU",dialCode:"+230",flag:"🇲🇺"},{name:"Mayotte",code:"YT",dialCode:"+262",flag:"🇾🇹"},{name:"Mexico",code:"MX",dialCode:"+52",flag:"🇲🇽"},{name:"Micronesia",code:"FM",dialCode:"+691",flag:"🇫🇲"},{name:"Moldova",code:"MD",dialCode:"+373",flag:"🇲🇩"},{name:"Monaco",code:"MC",dialCode:"+377",flag:"🇲🇨"},{name:"Mongolia",code:"MN",dialCode:"+976",flag:"🇲🇳"},{name:"Montenegro",code:"ME",dialCode:"+382",flag:"🇲🇪"},{name:"Montserrat",code:"MS",dialCode:"+1664",flag:"🇲🇸"},{name:"Morocco",code:"MA",dialCode:"+212",flag:"🇲🇦"},{name:"Mozambique",code:"MZ",dialCode:"+258",flag:"🇲🇿"},{name:"Myanmar",code:"MM",dialCode:"+95",flag:"🇲🇲"},{name:"Namibia",code:"NA",dialCode:"+264",flag:"🇳🇦"},{name:"Nauru",code:"NR",dialCode:"+674",flag:"🇳🇷"},{name:"Nepal",code:"NP",dialCode:"+977",flag:"🇳🇵"},{name:"Netherlands",code:"NL",dialCode:"+31",flag:"🇳🇱"},{name:"Netherlands Antilles",code:"AN",dialCode:"+599",flag:"🇳🇱"},{name:"New Caledonia",code:"NC",dialCode:"+687",flag:"🇳🇨"},{name:"New Zealand",code:"NZ",dialCode:"+64",flag:"🇳🇿"},{name:"Nicaragua",code:"NI",dialCode:"+505",flag:"🇳🇮"},{name:"Niger",code:"NE",dialCode:"+227",flag:"🇳🇪"},{name:"Nigeria",code:"NG",dialCode:"+234",flag:"🇳🇬"},{name:"Niue",code:"NU",dialCode:"+683",flag:"🇳🇺"},{name:"North Korea",code:"KP",dialCode:"+850",flag:"🇰🇵"},{name:"Northern Mariana Islands",code:"MP",dialCode:"+1670",flag:"🇲🇵"},{name:"Norway",code:"NO",dialCode:"+47",flag:"🇳🇴"},{name:"Oman",code:"OM",dialCode:"+968",flag:"🇴🇲"},{name:"Pakistan",code:"PK",dialCode:"+92",flag:"🇵🇰"},{name:"Palau",code:"PW",dialCode:"+680",flag:"🇵🇼"},{name:"Palestine",code:"PS",dialCode:"+970",flag:"🇵🇸"},{name:"Panama",code:"PA",dialCode:"+507",flag:"🇵🇦"},{name:"Papua New Guinea",code:"PG",dialCode:"+675",flag:"🇵🇬"},{name:"Paraguay",code:"PY",dialCode:"+595",flag:"🇵🇾"},{name:"Peru",code:"PE",dialCode:"+51",flag:"🇵🇪"},{name:"Philippines",code:"PH",dialCode:"+63",flag:"🇵🇭"},{name:"Pitcairn",code:"PN",dialCode:"+64",flag:"🇵🇳"},{name:"Poland",code:"PL",dialCode:"+48",flag:"🇵🇱"},{name:"Portugal",code:"PT",dialCode:"+351",flag:"🇵🇹"},{name:"Puerto Rico",code:"PR",dialCode:"+1939",flag:"🇵🇷"},{name:"Qatar",code:"QA",dialCode:"+974",flag:"🇶🇦"},{name:"Republic of the Congo",code:"CG",dialCode:"+242",flag:"🇨🇬"},{name:"Reunion",code:"RE",dialCode:"+262",flag:"🇷🇪"},{name:"Romania",code:"RO",dialCode:"+40",flag:"🇷🇴"},{name:"Russia",code:"RU",dialCode:"+7",flag:"🇷🇺"},{name:"Rwanda",code:"RW",dialCode:"+250",flag:"🇷🇼"},{name:"Saint Barthelemy",code:"BL",dialCode:"+590",flag:"🇧🇱"},{name:"Saint Helena",code:"SH",dialCode:"+290",flag:"🇸🇭"},{name:"Saint Kitts and Nevis",code:"KN",dialCode:"+1869",flag:"🇰🇳"},{name:"Saint Lucia",code:"LC",dialCode:"+1758",flag:"🇱🇨"},{name:"Saint Martin",code:"MF",dialCode:"+590",flag:"🇲🇫"},{name:"Saint Pierre and Miquelon",code:"PM",dialCode:"+508",flag:"🇵🇲"},{name:"Saint Vincent and the Grenadines",code:"VC",dialCode:"+1784",flag:"🇻🇨"},{name:"Samoa",code:"WS",dialCode:"+685",flag:"🇼🇸"},{name:"San Marino",code:"SM",dialCode:"+378",flag:"🇸🇲"},{name:"Sao Tome and Principe",code:"ST",dialCode:"+239",flag:"🇸🇹"},{name:"Saudi Arabia",code:"SA",dialCode:"+966",flag:"🇸🇦"},{name:"Senegal",code:"SN",dialCode:"+221",flag:"🇸🇳"},{name:"Serbia",code:"RS",dialCode:"+381",flag:"🇷🇸"},{name:"Seychelles",code:"SC",dialCode:"+248",flag:"🇸🇨"},{name:"Sierra Leone",code:"SL",dialCode:"+232",flag:"🇸🇱"},{name:"Singapore",code:"SG",dialCode:"+65",flag:"🇸🇬"},{name:"Sint Maarten",code:"SX",dialCode:"+1721",flag:"🇸🇽"},{name:"Slovakia",code:"SK",dialCode:"+421",flag:"🇸🇰"},{name:"Slovenia",code:"SI",dialCode:"+386",flag:"🇸🇮"},{name:"Solomon Islands",code:"SB",dialCode:"+677",flag:"🇸🇧"},{name:"Somalia",code:"SO",dialCode:"+252",flag:"🇸🇴"},{name:"South Africa",code:"ZA",dialCode:"+27",flag:"🇿🇦"},{name:"South Korea",code:"KR",dialCode:"+82",flag:"🇰🇷"},{name:"South Sudan",code:"SS",dialCode:"+211",flag:"🇸🇸"},{name:"Spain",code:"ES",dialCode:"+34",flag:"🇪🇸"},{name:"Sri Lanka",code:"LK",dialCode:"+94",flag:"🇱🇰"},{name:"Sudan",code:"SD",dialCode:"+249",flag:"🇸🇩"},{name:"Suriname",code:"SR",dialCode:"+597",flag:"🇸🇷"},{name:"Svalbard and Jan Mayen",code:"SJ",dialCode:"+47",flag:"🇸🇯"},{name:"Swaziland",code:"SZ",dialCode:"+268",flag:"🇸🇿"},{name:"Sweden",code:"SE",dialCode:"+46",flag:"🇸🇪"},{name:"Switzerland",code:"CH",dialCode:"+41",flag:"🇨🇭"},{name:"Syria",code:"SY",dialCode:"+963",flag:"🇸🇾"},{name:"Taiwan",code:"TW",dialCode:"+886",flag:"🇹🇼"},{name:"Tajikistan",code:"TJ",dialCode:"+992",flag:"🇹🇯"},{name:"Tanzania",code:"TZ",dialCode:"+255",flag:"🇹🇿"},{name:"Thailand",code:"TH",dialCode:"+66",flag:"🇹🇭"},{name:"Togo",code:"TG",dialCode:"+228",flag:"🇹🇬"},{name:"Tokelau",code:"TK",dialCode:"+690",flag:"🇹🇰"},{name:"Tonga",code:"TO",dialCode:"+676",flag:"🇹🇴"},{name:"Trinidad and Tobago",code:"TT",dialCode:"+1868",flag:"🇹🇹"},{name:"Tunisia",code:"TN",dialCode:"+216",flag:"🇹🇳"},{name:"Turkey",code:"TR",dialCode:"+90",flag:"🇹🇷"},{name:"Turkmenistan",code:"TM",dialCode:"+993",flag:"🇹🇲"},{name:"Turks and Caicos Islands",code:"TC",dialCode:"+1649",flag:"🇹🇨"},{name:"Tuvalu",code:"TV",dialCode:"+688",flag:"🇹🇻"},{name:"U.S. Virgin Islands",code:"VI",dialCode:"+1340",flag:"🇻🇮"},{name:"Uganda",code:"UG",dialCode:"+256",flag:"🇺🇬"},{name:"Ukraine",code:"UA",dialCode:"+380",flag:"🇺🇦"},{name:"United Arab Emirates",code:"AE",dialCode:"+971",flag:"🇦🇪"},{name:"United Kingdom",code:"GB",dialCode:"+44",flag:"🇬🇧"},{name:"United States",code:"US",dialCode:"+1",flag:"🇺🇸"},{name:"Uruguay",code:"UY",dialCode:"+598",flag:"🇺🇾"},{name:"Uzbekistan",code:"UZ",dialCode:"+998",flag:"🇺🇿"},{name:"Vanuatu",code:"VU",dialCode:"+678",flag:"🇻🇺"},{name:"Vatican",code:"VA",dialCode:"+379",flag:"🇻🇦"},{name:"Venezuela",code:"VE",dialCode:"+58",flag:"🇻🇪"},{name:"Vietnam",code:"VN",dialCode:"+84",flag:"🇻🇳"},{name:"Wallis and Futuna",code:"WF",dialCode:"+681",flag:"🇼🇫"},{name:"Western Sahara",code:"EH",dialCode:"+212",flag:"🇪🇭"},{name:"Yemen",code:"YE",dialCode:"+967",flag:"🇾🇪"},{name:"Zambia",code:"ZM",dialCode:"+260",flag:"🇿🇲"},{name:"Zimbabwe",code:"ZW",dialCode:"+263",flag:"🇿🇼"}],kr={sm:"36rem"},Sp=u.div`
380
380
  display: flex;
381
381
  gap: var(--space-xs);
382
382
  width: 100%;
383
383
 
384
- @media (max-width: ${jr.sm}) {
384
+ @media (max-width: ${kr.sm}) {
385
385
  gap: 0.375rem;
386
386
  }
387
387
  `,$p=u.div`
@@ -411,7 +411,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
411
411
  background: var(--color-background);
412
412
  }
413
413
 
414
- @media (max-width: ${jr.sm}) {
414
+ @media (max-width: ${kr.sm}) {
415
415
  padding: 0.375rem 0.625rem;
416
416
  font-size: 0.8125rem;
417
417
  }
@@ -431,7 +431,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
431
431
  z-index: 1000;
432
432
  display: ${t=>t.$isOpen?"block":"none"};
433
433
 
434
- @media (max-width: ${jr.sm}) {
434
+ @media (max-width: ${kr.sm}) {
435
435
  width: 15rem;
436
436
  max-height: 15rem;
437
437
  }
@@ -453,7 +453,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
453
453
  color: var(--color-secondary-text);
454
454
  }
455
455
 
456
- @media (max-width: ${jr.sm}) {
456
+ @media (max-width: ${kr.sm}) {
457
457
  padding: 0.375rem 0.625rem;
458
458
  font-size: 0.8125rem;
459
459
  }
@@ -461,7 +461,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
461
461
  max-height: 15.625rem;
462
462
  overflow-y: auto;
463
463
 
464
- @media (max-width: ${jr.sm}) {
464
+ @media (max-width: ${kr.sm}) {
465
465
  max-height: 12.5rem;
466
466
  }
467
467
  `,Ip=u.button`
@@ -486,14 +486,14 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
486
486
  margin-left: auto;
487
487
  }
488
488
 
489
- @media (max-width: ${jr.sm}) {
489
+ @media (max-width: ${kr.sm}) {
490
490
  padding: 0.375rem 0.625rem;
491
491
  font-size: 0.8125rem;
492
492
  gap: 0.375rem;
493
493
  }
494
494
  `,Tp=u(de)`
495
495
  flex: 1;
496
- `,Br=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:a})=>{const[s,p]=i.useState(!1),[g,c]=i.useState(Eo.find(v=>v.code===n)||Eo[0]),h=i.useRef(null),[d,l]=i.useState(""),m=i.useRef(null);i.useEffect(()=>{function v(w){h.current&&!h.current.contains(w.target)&&p(!1)}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]);const x=Eo.filter(v=>v.name.toLowerCase().includes(d.toLowerCase())||v.dialCode.includes(d));return i.useEffect(()=>{a(g.dialCode)},[g,a]),e.jsxs(Sp,{children:[e.jsxs($p,{ref:h,children:[e.jsxs(zp,{type:"button",onClick:()=>p(v=>!v),children:[e.jsx("span",{children:g.flag}),e.jsx("span",{children:g.dialCode})]}),e.jsxs(Ep,{$isOpen:s,children:[e.jsx(Pp,{type:"text",placeholder:"Search country...",value:d,onChange:v=>l(v.target.value),onClick:v=>v.stopPropagation()}),e.jsx(Rp,{children:x.map(v=>e.jsxs(Ip,{onClick:w=>{var C;w.stopPropagation(),w.preventDefault(),c(v),p(!1),(C=m.current)==null||C.focus()},children:[e.jsx("span",{children:v.flag}),e.jsx("span",{children:v.name}),e.jsx("span",{className:"country-code",children:v.dialCode})]},v.code))})]})]}),e.jsx(Tp,{style:{height:"100%"},type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:m,value:t,onChange:r,placeholder:"Phone number","aria-invalid":!!o,pattern:"^\\d{7,15}$"})]})},rs=u.div`
496
+ `,Ur=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:a})=>{const[s,h]=i.useState(!1),[g,c]=i.useState(Po.find(v=>v.code===n)||Po[0]),p=i.useRef(null),[l,d]=i.useState(""),m=i.useRef(null);i.useEffect(()=>{function v(w){p.current&&!p.current.contains(w.target)&&h(!1)}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]);const x=Po.filter(v=>v.name.toLowerCase().includes(l.toLowerCase())||v.dialCode.includes(l));return i.useEffect(()=>{a(g.dialCode)},[g,a]),e.jsxs(Sp,{children:[e.jsxs($p,{ref:p,children:[e.jsxs(zp,{type:"button",onClick:()=>h(v=>!v),children:[e.jsx("span",{children:g.flag}),e.jsx("span",{children:g.dialCode})]}),e.jsxs(Ep,{$isOpen:s,children:[e.jsx(Pp,{type:"text",placeholder:"Search country...",value:l,onChange:v=>d(v.target.value),onClick:v=>v.stopPropagation()}),e.jsx(Rp,{children:x.map(v=>e.jsxs(Ip,{onClick:w=>{var $;w.stopPropagation(),w.preventDefault(),c(v),h(!1),($=m.current)==null||$.focus()},children:[e.jsx("span",{children:v.flag}),e.jsx("span",{children:v.name}),e.jsx("span",{className:"country-code",children:v.dialCode})]},v.code))})]})]}),e.jsx(Tp,{style:{height:"100%"},type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:m,value:t,onChange:r,placeholder:"Phone number","aria-invalid":!!o,pattern:"^\\d{7,15}$"})]})},rs=u.div`
497
497
  display: flex;
498
498
  justify-content: center;
499
499
  margin-bottom: var(--space-sm);
@@ -503,7 +503,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
503
503
  width: auto;
504
504
  height: auto;
505
505
  object-fit: contain;
506
- `;function Ae(){var o;const{deployment:t}=ve(),r=(o=t==null?void 0:t.ui_settings)==null?void 0:o.logo_image_url;return r?e.jsx(rs,{children:e.jsx(Op,{src:r,alt:"Logo",onError:n=>{n.currentTarget.style.display="none"}})}):e.jsx(rs,{})}const pt={sm:"36rem"},os=u.div`
506
+ `;function Ae(){var o;const{deployment:t}=xe(),r=(o=t==null?void 0:t.ui_settings)==null?void 0:o.logo_image_url;return r?e.jsx(rs,{children:e.jsx(Op,{src:r,alt:"Logo",onError:n=>{n.currentTarget.style.display="none"}})}):e.jsx(rs,{})}const pt={sm:"36rem"},os=u.div`
507
507
  max-width: 380px;
508
508
  width: 380px;
509
509
  padding: var(--space-3xl);
@@ -671,7 +671,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
671
671
  `,cr=u.span`
672
672
  color: var(--color-danger);
673
673
  margin-left: 2px;
674
- `;function Vp(){var J,ie,re,X,U,Z,Q,ae,oe,ce,Y,se,q,H,A;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n,errors:a}=ec(),{signIn:s}=Ar("oauth"),{deployment:p}=ve(),{navigate:g}=He(),{session:c,refetch:h}=Fe(),[d,l]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=i.useState({}),[v,w]=i.useState(!1),[C,$]=i.useState(void 0),[y,z]=i.useState(null),[_,k]=i.useState(null),b=((J=p==null?void 0:p.restrictions)==null?void 0:J.sign_up_mode)==="restricted",f=((ie=p==null?void 0:p.restrictions)==null?void 0:ie.sign_up_mode)==="waitlist";i.useEffect(()=>{var W;if(!p)return;if(f){const ee=((W=p.ui_settings)==null?void 0:W.waitlist_page_url)||`${p.frontend_host}/waitlist`||"/waitlist";g(ee);return}const L=new URLSearchParams(window.location.search).get("invite_token");L&&!y&&r&&(k(L),r.validateDeploymentInvitation(L).then(ee=>{z(ee),ee.valid&&l(pe=>({...pe,first_name:ee.first_name||pe.first_name,last_name:ee.last_name||pe.last_name,email:ee.email||pe.email}))}).catch(ee=>{console.error("Failed to validate invitation:",ee)}))},[p,f,g,y,r]);const[I,j]=i.useState(!1),[S,R]=i.useState(""),E=B=>{let{name:L,value:W}=B.target;L==="phone_number"?W=W.replace(/[^0-9-]/g,""):L==="email"&&(W=W.toLowerCase()),l(ee=>({...ee,[L]:W})),x(ee=>({...ee,[L]:""}))},T=()=>{l({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),j(!1),R(""),n()},P=async B=>{if(B.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",M),console.log("Form data:",d),t||v)return;const L={},W=/^[a-zA-Z]{3,30}$/,ee=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,pe=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Se=/^\d{7,15}$/,Ne=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(M!=null&&M.first_name.enabled&&(M!=null&&M.first_name.required&&!d.first_name?L.first_name="First name is required":d.first_name&&!W.test(d.first_name)&&(L.first_name="Invalid name")),M!=null&&M.last_name.enabled&&(M!=null&&M.last_name.required&&!d.last_name?L.last_name="Last name is required":d.last_name&&!W.test(d.last_name)&&(L.last_name="Invalid last name")),M!=null&&M.username.enabled&&(M!=null&&M.username.required&&!d.username?L.username="Username is required":d.username&&!ee.test(d.username)&&(L.username="Username must be 3-20 characters")),M!=null&&M.email_address.enabled&&(M!=null&&M.email_address.required&&!d.email?L.email="Email address is required":d.email&&!pe.test(d.email)&&(L.email="Invalid email address")),M!=null&&M.phone_number.enabled&&(M!=null&&M.phone_number.required&&!d.phone_number?L.phone_number="Phone number is required":d.phone_number&&!Se.test(d.phone_number)&&(L.phone_number="Phone number must contain 7-15 digits")),M!=null&&M.password.enabled&&(d.password?Ne.test(d.password)||(L.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):L.password="Password is required"),x(L),Object.keys(L).length>0){console.log("Signup validation failed. Errors:",L);return}console.log("Signup validation passed"),w(!0);try{const G={...d};d.phone_number&&C&&(G.phone_country_code=C),_&&(G.invite_token=_),console.log("Submitting signup data:",G),console.log("Phone number:",G.phone_number),console.log("Phone country code:",G.phone_country_code),await r.create(G)}catch(G){x({submit:G.message})}finally{w(!1)}},O=async B=>{if(!(t||v)){w(!0);try{const W=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:ee}=await s.create({provider:B.provider,redirectUri:W});ee&&typeof ee=="object"&&"oauth_url"in ee&&(window.location.href=ee.oauth_url)}catch(L){x({submit:L.message})}finally{w(!1)}}},D=(p==null?void 0:p.social_connections.filter(B=>B.enabled))||[],M=p==null?void 0:p.auth_settings,N=!!((re=M==null?void 0:M.first_name)!=null&&re.enabled&&((X=M==null?void 0:M.last_name)!=null&&X.enabled)),F=async B=>{var W;if(B.preventDefault(),t||v)return;w(!0);const L={};if(!S){L.otp="OTP code is required",x(L),w(!1);return}x(L);try{const ee=await r.completeVerification(S);"data"in ee&&((W=ee.data)!=null&&W.active_signin)&&await h()}catch(ee){console.error("Verification failed:",ee)}finally{w(!1)}};return i.useEffect(()=>{var B;if(o){if(o.completed){let L=new URLSearchParams(window.location.search).get("redirect_uri");if(L||(L=((B=p==null?void 0:p.ui_settings)==null?void 0:B.after_signup_redirect_url)||null),!L&&(p!=null&&p.frontend_host)&&(L=`https://${p.frontend_host}`),L){const W=new URL(L);(p==null?void 0:p.mode)==="staging"&&W.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),g(W.toString())}return}if(!I){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}j(!0)}}},[o,r,I,p,c,g]),i.useEffect(()=>{const B={};if(a!=null&&a.errors&&Array.isArray(a==null?void 0:a.errors))for(const L of a.errors)L.code==="USERNAME_EXISTS"&&(B.username=L.message),L.code==="EMAIL_EXISTS"&&(B.email=L.message),L.code==="PHONE_NUMBER_EXISTS"&&(B.phone_number=L.message),L.code==="INVALID_CREDENTIALS"&&(B.password=L.message),["COUNTRY_RESTRICTED","EMAIL_NOT_ALLOWED","EMAIL_BLOCKED","DISPOSABLE_EMAIL_BLOCKED","VOIP_NUMBER_BLOCKED","BANNED_KEYWORD"].includes(L.code)&&(B.submit=L.message);x(B)},[a]),b?e.jsx(le,{children:e.jsxs(os,{children:[e.jsx(Ae,{}),e.jsx(bn,{children:e.jsx(yn,{children:"Sign up Restricted!"})}),e.jsx(Np,{children:e.jsx(Fp,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Bp,{children:e.jsxs(Up,{children:["Need assistance?"," ",e.jsx(Wp,{href:(U=p==null?void 0:p.ui_settings)!=null&&U.sign_in_page_url?`${p.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(le,{children:e.jsx(os,{children:I?e.jsxs(e.Fragment,{children:[e.jsxs(bn,{children:[e.jsxs(yn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ns,{children:(o==null?void 0:o.current_step)==="verify_email"?`${d.email} to continue to ${(Z=p==null?void 0:p.ui_settings)==null?void 0:Z.app_name}`:`${d.phone_number} to continue to ${(Q=p==null?void 0:p.ui_settings)==null?void 0:Q.app_name}`})]}),e.jsxs(as,{style:{gap:"15px"},onSubmit:F,noValidate:!0,children:[e.jsx(Rt,{onComplete:async B=>{R(B)},onResend:async()=>{const B=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:B})},error:m.otp,isSubmitting:v}),e.jsx(ss,{type:"submit",disabled:v||t||!S,children:v?"Verifying...":`Continue to ${(ae=p==null?void 0:p.ui_settings)==null?void 0:ae.app_name}`})]}),e.jsxs(is,{children:["Having trouble?"," ",e.jsx(wn,{children:e.jsx(tt,{to:p.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(wn,{onClick:()=>{T()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{}),e.jsxs(bn,{children:[e.jsx(yn,{children:"Create your account"}),e.jsx(ns,{children:y!=null&&y.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),D.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wa,{connections:D,callback:O}),e.jsx(Mp,{children:e.jsx(Lp,{children:"or"})})]}),e.jsxs(as,{onSubmit:P,noValidate:!0,children:[(((oe=M==null?void 0:M.first_name)==null?void 0:oe.enabled)||((ce=M==null?void 0:M.last_name)==null?void 0:ce.enabled))&&e.jsxs(Ap,{$isBothEnabled:N,children:[((Y=M==null?void 0:M.first_name)==null?void 0:Y.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"first_name",children:["First name",((se=M==null?void 0:M.first_name)==null?void 0:se.required)&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:d.first_name,onChange:E,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Ot,{children:m.first_name})]}),((q=M==null?void 0:M.last_name)==null?void 0:q.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"last_name",children:["Last name",((H=M==null?void 0:M.last_name)==null?void 0:H.required)&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:d.last_name,onChange:E,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Ot,{children:m.last_name})]})]}),(M==null?void 0:M.username.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"username",children:["Username",M.username.required&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:d.username,onChange:E,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Ot,{children:m.username})]}),(M==null?void 0:M.email_address.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"email",children:["Email address",M.email_address.required&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"email",id:"email",name:"email",maxLength:320,value:d.email,onChange:E,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(y==null?void 0:y.valid)&&!!(y!=null&&y.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Ot,{children:m.email})]}),(M==null?void 0:M.phone_number.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"phone_number",children:["Phone number",M.phone_number.required&&e.jsx(cr,{children:"*"})]}),e.jsx(Br,{value:d.phone_number,onChange:E,error:m.phone_number,countryCode:C,setCountryCode:$}),m.phone_number&&e.jsx(Ot,{children:m.phone_number})]}),(M==null?void 0:M.password.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"password",children:["Password",M.password.required&&e.jsx(cr,{children:"*"})]}),e.jsx(Dp,{children:e.jsx(de,{type:"password",id:"password",name:"password",value:d.password,onChange:E,placeholder:"Enter your password","aria-invalid":!!m.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),m.password&&e.jsx(Ot,{children:m.password})]}),m.submit&&e.jsx(Ot,{children:m.submit}),e.jsx(ss,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(is,{children:["Already have an account?"," ",e.jsx(wn,{children:e.jsx(tt,{to:`${(A=p.ui_settings)==null?void 0:A.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}/**
674
+ `;function Vp(){var J,ae,ee,F,U,G,X,se,oe,ce,K,ie,Z,q,A;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n,errors:a}=ec(),{signIn:s}=Dr("oauth"),{deployment:h}=xe(),{navigate:g}=He(),{session:c,refetch:p}=Fe(),[l,d]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=i.useState({}),[v,w]=i.useState(!1),[$,z]=i.useState(void 0),[y,C]=i.useState(null),[k,S]=i.useState(null),b=((J=h==null?void 0:h.restrictions)==null?void 0:J.sign_up_mode)==="restricted",f=((ae=h==null?void 0:h.restrictions)==null?void 0:ae.sign_up_mode)==="waitlist";i.useEffect(()=>{var W;if(!h)return;if(f){const te=((W=h.ui_settings)==null?void 0:W.waitlist_page_url)||`${h.frontend_host}/waitlist`||"/waitlist";g(te);return}const L=new URLSearchParams(window.location.search).get("invite_token");L&&!y&&r&&(S(L),r.validateDeploymentInvitation(L).then(te=>{C(te),te.valid&&d(pe=>({...pe,first_name:te.first_name||pe.first_name,last_name:te.last_name||pe.last_name,email:te.email||pe.email}))}).catch(te=>{console.error("Failed to validate invitation:",te)}))},[h,f,g,y,r]);const[E,j]=i.useState(!1),[_,I]=i.useState(""),P=B=>{let{name:L,value:W}=B.target;L==="phone_number"?W=W.replace(/[^0-9-]/g,""):L==="email"&&(W=W.toLowerCase()),d(te=>({...te,[L]:W})),x(te=>({...te,[L]:""}))},T=()=>{d({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),j(!1),I(""),n()},R=async B=>{if(B.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",M),console.log("Form data:",l),t||v)return;const L={},W=/^[a-zA-Z]{3,30}$/,te=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,pe=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Se=/^\d{7,15}$/,Ne=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(M!=null&&M.first_name.enabled&&(M!=null&&M.first_name.required&&!l.first_name?L.first_name="First name is required":l.first_name&&!W.test(l.first_name)&&(L.first_name="Invalid name")),M!=null&&M.last_name.enabled&&(M!=null&&M.last_name.required&&!l.last_name?L.last_name="Last name is required":l.last_name&&!W.test(l.last_name)&&(L.last_name="Invalid last name")),M!=null&&M.username.enabled&&(M!=null&&M.username.required&&!l.username?L.username="Username is required":l.username&&!te.test(l.username)&&(L.username="Username must be 3-20 characters")),M!=null&&M.email_address.enabled&&(M!=null&&M.email_address.required&&!l.email?L.email="Email address is required":l.email&&!pe.test(l.email)&&(L.email="Invalid email address")),M!=null&&M.phone_number.enabled&&(M!=null&&M.phone_number.required&&!l.phone_number?L.phone_number="Phone number is required":l.phone_number&&!Se.test(l.phone_number)&&(L.phone_number="Phone number must contain 7-15 digits")),M!=null&&M.password.enabled&&(l.password?Ne.test(l.password)||(L.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):L.password="Password is required"),x(L),Object.keys(L).length>0){console.log("Signup validation failed. Errors:",L);return}console.log("Signup validation passed"),w(!0);try{const H={...l};l.phone_number&&$&&(H.phone_country_code=$),k&&(H.invite_token=k),console.log("Submitting signup data:",H),console.log("Phone number:",H.phone_number),console.log("Phone country code:",H.phone_country_code),await r.create(H)}catch(H){x({submit:H.message})}finally{w(!1)}},O=async B=>{if(!(t||v)){w(!0);try{const W=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:te}=await s.create({provider:B.provider,redirectUri:W});te&&typeof te=="object"&&"oauth_url"in te&&(window.location.href=te.oauth_url)}catch(L){x({submit:L.message})}finally{w(!1)}}},D=(h==null?void 0:h.social_connections.filter(B=>B.enabled))||[],M=h==null?void 0:h.auth_settings,Y=!!((ee=M==null?void 0:M.first_name)!=null&&ee.enabled&&((F=M==null?void 0:M.last_name)!=null&&F.enabled)),N=async B=>{var W;if(B.preventDefault(),t||v)return;w(!0);const L={};if(!_){L.otp="OTP code is required",x(L),w(!1);return}x(L);try{const te=await r.completeVerification(_);"data"in te&&((W=te.data)!=null&&W.active_signin)&&await p()}catch(te){console.error("Verification failed:",te)}finally{w(!1)}};return i.useEffect(()=>{var B;if(o){if(o.completed){let L=new URLSearchParams(window.location.search).get("redirect_uri");if(L||(L=((B=h==null?void 0:h.ui_settings)==null?void 0:B.after_signup_redirect_url)||null),!L&&(h!=null&&h.frontend_host)&&(L=`https://${h.frontend_host}`),L){const W=new URL(L);(h==null?void 0:h.mode)==="staging"&&W.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),g(W.toString())}return}if(!E){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}j(!0)}}},[o,r,E,h,c,g]),i.useEffect(()=>{const B={};if(a!=null&&a.errors&&Array.isArray(a==null?void 0:a.errors))for(const L of a.errors)L.code==="USERNAME_EXISTS"&&(B.username=L.message),L.code==="EMAIL_EXISTS"&&(B.email=L.message),L.code==="PHONE_NUMBER_EXISTS"&&(B.phone_number=L.message),L.code==="INVALID_CREDENTIALS"&&(B.password=L.message),["COUNTRY_RESTRICTED","EMAIL_NOT_ALLOWED","EMAIL_BLOCKED","DISPOSABLE_EMAIL_BLOCKED","VOIP_NUMBER_BLOCKED","BANNED_KEYWORD"].includes(L.code)&&(B.submit=L.message);x(B)},[a]),b?e.jsx(le,{children:e.jsxs(os,{children:[e.jsx(Ae,{}),e.jsx(bn,{children:e.jsx(yn,{children:"Sign up Restricted!"})}),e.jsx(Np,{children:e.jsx(Fp,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Bp,{children:e.jsxs(Up,{children:["Need assistance?"," ",e.jsx(Wp,{href:(U=h==null?void 0:h.ui_settings)!=null&&U.sign_in_page_url?`${h.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(le,{children:e.jsx(os,{children:E?e.jsxs(e.Fragment,{children:[e.jsxs(bn,{children:[e.jsxs(yn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ns,{children:(o==null?void 0:o.current_step)==="verify_email"?`${l.email} to continue to ${(G=h==null?void 0:h.ui_settings)==null?void 0:G.app_name}`:`${l.phone_number} to continue to ${(X=h==null?void 0:h.ui_settings)==null?void 0:X.app_name}`})]}),e.jsxs(as,{style:{gap:"15px"},onSubmit:N,noValidate:!0,children:[e.jsx(Rt,{onComplete:async B=>{I(B)},onResend:async()=>{const B=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:B})},error:m.otp,isSubmitting:v}),e.jsx(ss,{type:"submit",disabled:v||t||!_,children:v?"Verifying...":`Continue to ${(se=h==null?void 0:h.ui_settings)==null?void 0:se.app_name}`})]}),e.jsxs(is,{children:["Having trouble?"," ",e.jsx(wn,{children:e.jsx(tt,{to:h.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(wn,{onClick:()=>{T()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{}),e.jsxs(bn,{children:[e.jsx(yn,{children:"Create your account"}),e.jsx(ns,{children:y!=null&&y.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),D.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wa,{connections:D,callback:O}),e.jsx(Mp,{children:e.jsx(Lp,{children:"or"})})]}),e.jsxs(as,{onSubmit:R,noValidate:!0,children:[(((oe=M==null?void 0:M.first_name)==null?void 0:oe.enabled)||((ce=M==null?void 0:M.last_name)==null?void 0:ce.enabled))&&e.jsxs(Ap,{$isBothEnabled:Y,children:[((K=M==null?void 0:M.first_name)==null?void 0:K.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"first_name",children:["First name",((ie=M==null?void 0:M.first_name)==null?void 0:ie.required)&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:P,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Ot,{children:m.first_name})]}),((Z=M==null?void 0:M.last_name)==null?void 0:Z.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"last_name",children:["Last name",((q=M==null?void 0:M.last_name)==null?void 0:q.required)&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:P,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Ot,{children:m.last_name})]})]}),(M==null?void 0:M.username.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"username",children:["Username",M.username.required&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:P,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Ot,{children:m.username})]}),(M==null?void 0:M.email_address.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"email",children:["Email address",M.email_address.required&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:P,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(y==null?void 0:y.valid)&&!!(y!=null&&y.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Ot,{children:m.email})]}),(M==null?void 0:M.phone_number.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"phone_number",children:["Phone number",M.phone_number.required&&e.jsx(cr,{children:"*"})]}),e.jsx(Ur,{value:l.phone_number,onChange:P,error:m.phone_number,countryCode:$,setCountryCode:z}),m.phone_number&&e.jsx(Ot,{children:m.phone_number})]}),(M==null?void 0:M.password.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"password",children:["Password",M.password.required&&e.jsx(cr,{children:"*"})]}),e.jsx(Dp,{children:e.jsx(de,{type:"password",id:"password",name:"password",value:l.password,onChange:P,placeholder:"Enter your password","aria-invalid":!!m.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),m.password&&e.jsx(Ot,{children:m.password})]}),m.submit&&e.jsx(Ot,{children:m.submit}),e.jsx(ss,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(is,{children:["Already have an account?"," ",e.jsx(wn,{children:e.jsx(tt,{to:`${(A=h.ui_settings)==null?void 0:A.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}/**
675
675
  * @license lucide-react v0.474.0 - ISC
676
676
  *
677
677
  * This source code is licensed under the ISC license.
@@ -686,7 +686,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
686
686
  *
687
687
  * This source code is licensed under the ISC license.
688
688
  * See the LICENSE file in the root directory of this source tree.
689
- */const qp=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:a="",children:s,iconNode:p,...g},c)=>i.createElement("svg",{ref:c,...Hp,width:r,height:r,stroke:t,strokeWidth:n?Number(o)*24/Number(r):o,className:Wc("lucide",a),...g},[...p.map(([h,d])=>i.createElement(h,d)),...Array.isArray(s)?s:[s]]));/**
689
+ */const qp=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:a="",children:s,iconNode:h,...g},c)=>i.createElement("svg",{ref:c,...Hp,width:r,height:r,stroke:t,strokeWidth:n?Number(o)*24/Number(r):o,className:Wc("lucide",a),...g},[...h.map(([p,l])=>i.createElement(p,l)),...Array.isArray(s)?s:[s]]));/**
690
690
  * @license lucide-react v0.474.0 - ISC
691
691
  *
692
692
  * This source code is licensed under the ISC license.
@@ -721,7 +721,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
721
721
  *
722
722
  * This source code is licensed under the ISC license.
723
723
  * See the LICENSE file in the root directory of this source tree.
724
- */const oh=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Dr=me("Building",oh);/**
724
+ */const oh=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Nr=me("Building",oh);/**
725
725
  * @license lucide-react v0.474.0 - ISC
726
726
  *
727
727
  * This source code is licensed under the ISC license.
@@ -736,7 +736,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
736
736
  *
737
737
  * This source code is licensed under the ISC license.
738
738
  * See the LICENSE file in the root directory of this source tree.
739
- */const sh=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ur=me("ChevronLeft",sh);/**
739
+ */const sh=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Wr=me("ChevronLeft",sh);/**
740
740
  * @license lucide-react v0.474.0 - ISC
741
741
  *
742
742
  * This source code is licensed under the ISC license.
@@ -806,7 +806,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
806
806
  *
807
807
  * This source code is licensed under the ISC license.
808
808
  * See the LICENSE file in the root directory of this source tree.
809
- */const _h=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],Wr=me("Mail",_h);/**
809
+ */const _h=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],Vr=me("Mail",_h);/**
810
810
  * @license lucide-react v0.474.0 - ISC
811
811
  *
812
812
  * This source code is licensed under the ISC license.
@@ -871,12 +871,12 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
871
871
  *
872
872
  * This source code is licensed under the ISC license.
873
873
  * See the LICENSE file in the root directory of this source tree.
874
- */const Bh=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Mo=me("User",Bh);/**
874
+ */const Bh=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Lo=me("User",Bh);/**
875
875
  * @license lucide-react v0.474.0 - ISC
876
876
  *
877
877
  * This source code is licensed under the ISC license.
878
878
  * See the LICENSE file in the root directory of this source tree.
879
- */const Uh=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Lo=me("Users",Uh);/**
879
+ */const Uh=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Ao=me("Users",Uh);/**
880
880
  * @license lucide-react v0.474.0 - ISC
881
881
  *
882
882
  * This source code is licensed under the ISC license.
@@ -941,7 +941,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
941
941
  gap: 8px;
942
942
  padding: 16px;
943
943
  border-top: 1px solid var(--color-border);
944
- `,tf=({isOpen:t,onClose:r,children:o})=>{const[n,a]=i.useState(!1);return i.useEffect(()=>{a(!0);const s=p=>{p.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[t,r]),!t||!n?null:Nr.createPortal(e.jsx(le,{children:e.jsx(Yc.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},rf=({children:t})=>{const{onClose:r}=Zc(),o=i.useRef(null),n=a=>{o.current&&!o.current.contains(a.target)&&(r==null||r())};return e.jsx(Yh,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},of=({children:t,style:r})=>e.jsx(Zh,{style:r,children:t}),nf=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=Zc();return e.jsxs(Kh,{children:[typeof t=="string"?e.jsx(Qh,{children:t}):t,r&&e.jsx(Xh,{onClick:o,children:e.jsx(Ke,{size:18})})]})},af=({children:t,style:r})=>e.jsx(Jh,{style:r,children:t}),sf=({children:t})=>e.jsx(ef,{children:t}),we=Object.assign(tf,{Overlay:rf,Content:of,Header:nf,Body:af,Footer:sf}),cf=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:a=!0})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{children:[o&&e.jsx(we.Header,{showCloseButton:a,children:o}),e.jsx(we.Body,{children:n})]})})}),lf=({trigger:t,renderDialog:r})=>{const[o,n]=i.useState(!1),a=()=>n(!0),s=()=>n(!1);return e.jsxs(e.Fragment,{children:[t({onClick:a}),r({isOpen:o,onClose:s})]})},df=u.div`
944
+ `,tf=({isOpen:t,onClose:r,children:o})=>{const[n,a]=i.useState(!1);return i.useEffect(()=>{a(!0);const s=h=>{h.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[t,r]),!t||!n?null:Fr.createPortal(e.jsx(le,{children:e.jsx(Yc.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},rf=({children:t})=>{const{onClose:r}=Zc(),o=i.useRef(null),n=a=>{o.current&&!o.current.contains(a.target)&&(r==null||r())};return e.jsx(Yh,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},of=({children:t,style:r})=>e.jsx(Zh,{style:r,children:t}),nf=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=Zc();return e.jsxs(Kh,{children:[typeof t=="string"?e.jsx(Qh,{children:t}):t,r&&e.jsx(Xh,{onClick:o,children:e.jsx(Ke,{size:18})})]})},af=({children:t,style:r})=>e.jsx(Jh,{style:r,children:t}),sf=({children:t})=>e.jsx(ef,{children:t}),we=Object.assign(tf,{Overlay:rf,Content:of,Header:nf,Body:af,Footer:sf}),cf=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:a=!0})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{children:[o&&e.jsx(we.Header,{showCloseButton:a,children:o}),e.jsx(we.Body,{children:n})]})})}),lf=({trigger:t,renderDialog:r})=>{const[o,n]=i.useState(!1),a=()=>n(!0),s=()=>n(!1);return e.jsxs(e.Fragment,{children:[t({onClick:a}),r({isOpen:o,onClose:s})]})},df=u.div`
945
945
  position: fixed;
946
946
  background: var(--color-background);
947
947
  border-radius: 8px;
@@ -953,7 +953,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
953
953
  display: grid;
954
954
  `,uf=u.div`
955
955
  width: fit-content;
956
- `,Kc=i.createContext(void 0),Qc=()=>{const t=i.useContext(Kc);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},ot=({children:t,open:r,openChange:o,style:n})=>{const a=i.useRef(null),[s,p]=i.useState(!1);return i.useEffect(()=>{const g=c=>{a.current&&!a.current.contains(c.target)&&p(!1)};return s&&document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[s,o]),i.useEffect(()=>{o==null||o(s)},[s]),i.useEffect(()=>{p(!!r)},[r]),e.jsx(Kc.Provider,{value:{open:s,openChange:g=>p(g)},children:e.jsx(uf,{style:n,ref:a,children:t})})},nt=({children:t,style:r})=>{const{open:o}=Qc(),[n,a]=i.useState({top:0,left:0}),[s,p]=i.useState(!1),g=i.useRef(null);return i.useEffect(()=>{o&&g.current?(p(!1),requestAnimationFrame(()=>{var d,l;const c=(d=g.current)==null?void 0:d.parentElement;if(!c)return;const h=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(h&&h!==g.current){const m=h.getBoundingClientRect(),x=(l=g.current)==null?void 0:l.getBoundingClientRect(),v=window.innerWidth,w=window.innerHeight;let C=m.bottom+4,$=m.right-200;$<8&&($=m.left),$+200>v-8&&($=v-208),x&&C+x.height>w-8&&(C=m.top-(x.height+4)),a({top:C,left:$}),p(!0)}})):p(!1)},[o]),o?e.jsx(df,{ref:g,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:s?"visible":"hidden",opacity:s?1:0,transition:s?"opacity 0.15s ease-in-out":"none"},children:t}):null},at=({children:t})=>{const{openChange:r,open:o}=Qc(),n=i.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Pe=u.button`
956
+ `,Kc=i.createContext(void 0),Qc=()=>{const t=i.useContext(Kc);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},ot=({children:t,open:r,openChange:o,style:n})=>{const a=i.useRef(null),[s,h]=i.useState(!1);return i.useEffect(()=>{const g=c=>{a.current&&!a.current.contains(c.target)&&h(!1)};return s&&document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[s,o]),i.useEffect(()=>{o==null||o(s)},[s]),i.useEffect(()=>{h(!!r)},[r]),e.jsx(Kc.Provider,{value:{open:s,openChange:g=>h(g)},children:e.jsx(uf,{style:n,ref:a,children:t})})},nt=({children:t,style:r})=>{const{open:o}=Qc(),[n,a]=i.useState({top:0,left:0}),[s,h]=i.useState(!1),g=i.useRef(null);return i.useEffect(()=>{o&&g.current?(h(!1),requestAnimationFrame(()=>{var l,d;const c=(l=g.current)==null?void 0:l.parentElement;if(!c)return;const p=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(p&&p!==g.current){const m=p.getBoundingClientRect(),x=(d=g.current)==null?void 0:d.getBoundingClientRect(),v=window.innerWidth,w=window.innerHeight;let $=m.bottom+4,z=m.right-200;z<8&&(z=m.left),z+200>v-8&&(z=v-208),x&&$+x.height>w-8&&($=m.top-(x.height+4)),a({top:$,left:z}),h(!0)}})):h(!1)},[o]),o?e.jsx(df,{ref:g,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:s?"visible":"hidden",opacity:s?1:0,transition:s?"opacity 0.15s ease-in-out":"none"},children:t}):null},at=({children:t})=>{const{openChange:r,open:o}=Qc(),n=i.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Pe=u.button`
957
957
  width: 100%;
958
958
  padding: 8px 12px;
959
959
  background: none;
@@ -984,7 +984,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
984
984
  text-align: left;
985
985
  font-weight: 400;
986
986
  color: var(--color-foreground);
987
- `,pf=wr`
987
+ `,pf=jr`
988
988
  0% {
989
989
  transform: rotate(0deg);
990
990
  }
@@ -1035,7 +1035,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1035
1035
  left: ${t=>t.checked?"20px":"2px"};
1036
1036
  transition: left 0.2s ease;
1037
1037
  }
1038
- `,Ao=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(gf,{children:[e.jsx(mf,{type:"checkbox",checked:t,onChange:o}),e.jsx(xf,{checked:t})]})},Or=(t=!1)=>{const[r,o]=i.useState(t),n=i.useCallback(()=>{o(!0)},[]),a=i.useCallback(()=>{o(!1)},[]),s=i.useCallback(()=>{o(p=>!p)},[]);return{isOpen:r,open:n,close:a,toggle:s}},wt=({onChange:t,placeholder:r,value:o})=>e.jsxs("div",{style:{display:"flex",flexGrow:1,alignItems:"center",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"8px 12px",backgroundColor:"var(--color-input-background)",minWidth:"250px"},children:[e.jsx(Oh,{size:16,color:"var(--color-secondary-text)",style:{marginRight:"8px"}}),e.jsx("input",{type:"text",placeholder:r,value:o,onChange:n=>t(n.target.value),style:{border:"none",outline:"none",width:"100%",fontSize:"14px",color:"var(--color-text)",backgroundColor:"transparent"}})]}),K=u.button`
1038
+ `,br=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(gf,{children:[e.jsx(mf,{type:"checkbox",checked:t,onChange:o}),e.jsx(xf,{checked:t})]})},Mr=(t=!1)=>{const[r,o]=i.useState(t),n=i.useCallback(()=>{o(!0)},[]),a=i.useCallback(()=>{o(!1)},[]),s=i.useCallback(()=>{o(h=>!h)},[]);return{isOpen:r,open:n,close:a,toggle:s}},wt=({onChange:t,placeholder:r,value:o})=>e.jsxs("div",{style:{display:"flex",flexGrow:1,alignItems:"center",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"8px 12px",backgroundColor:"var(--color-input-background)",minWidth:"250px"},children:[e.jsx(Oh,{size:16,color:"var(--color-secondary-text)",style:{marginRight:"8px"}}),e.jsx("input",{type:"text",placeholder:r,value:o,onChange:n=>t(n.target.value),style:{border:"none",outline:"none",width:"100%",fontSize:"14px",color:"var(--color-text)",backgroundColor:"transparent"}})]}),Q=u.button`
1039
1039
  width: 100%;
1040
1040
  padding: var(--space-sm) var(--space-md);
1041
1041
  border: 1px solid transparent;
@@ -1177,7 +1177,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1177
1177
  text-transform: uppercase;
1178
1178
  color: var(--color-muted);
1179
1179
  background: var(--color-background-hover);
1180
- `,ja=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:a=!1,searchable:s=!1,width:p,name:g,id:c,groupsEnabled:h=!1,className:d})=>{const[l,m]=i.useState(!1),[x,v]=i.useState(""),w=i.useRef(null),C=i.useRef(null),$=h&&"options"in t[0],z=($?t.flatMap(f=>f.options):t).find(f=>f.value===r),_=x?$?t.map(f=>({...f,options:f.options.filter(I=>I.label.toLowerCase().includes(x.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(x.toLowerCase())):t,k=(f,I=!1)=>{I||(o(f),m(!1),v(""))},b=()=>{a||m(!l)};return i.useEffect(()=>{l&&s&&C.current&&setTimeout(()=>{var f;(f=C.current)==null||f.focus()},10)},[l,s]),i.useEffect(()=>{const f=I=>{w.current&&!w.current.contains(I.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs(Xc,{ref:w,style:{width:p},className:d,children:[e.jsxs(Jc,{type:"button",onClick:b,disabled:a,"aria-haspopup":"listbox","aria-expanded":l,id:c,children:[z?z.label:e.jsx(rl,{children:n}),l?e.jsx(Vc,{size:16}):e.jsx(er,{size:16})]}),e.jsxs(el,{isOpen:l,role:"listbox",children:[s&&e.jsx(tl,{ref:C,type:"text",placeholder:"Search...",value:x,onChange:f=>v(f.target.value),onClick:f=>f.stopPropagation()}),$?_.map((f,I)=>e.jsxs(i.Fragment,{children:[e.jsx(ol,{children:f.label}),f.options.length===0?e.jsx(No,{children:"No options available"}):f.options.map(j=>e.jsxs(Do,{isSelected:j.value===r,disabled:j.disabled,onClick:()=>k(j.value,j.disabled),role:"option","aria-selected":j.value===r,children:[j.label,j.value===r&&e.jsx(rt,{size:16})]},j.value))]},`group-${I}`)):e.jsx(e.Fragment,{children:_.length===0?e.jsx(No,{children:"No options available"}):_.map(f=>e.jsxs(Do,{isSelected:f.value===r,disabled:f.disabled,onClick:()=>k(f.value,f.disabled),role:"option","aria-selected":f.value===r,children:[f.label,f.value===r&&e.jsx(rt,{size:16})]},f.value))})]}),g&&e.jsx("input",{type:"hidden",name:g,value:r||""})]})},nl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:a=!1,searchable:s=!1,width:p,name:g,id:c,groupsEnabled:h=!1,className:d})=>{const[l,m]=i.useState(!1),[x,v]=i.useState(""),w=i.useRef(null),C=i.useRef(null),$=h&&"options"in t[0],z=($?t.flatMap(f=>f.options):t).filter(f=>r.includes(f.value)),_=x?$?t.map(f=>({...f,options:f.options.filter(I=>I.label.toLowerCase().includes(x.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(x.toLowerCase())):t,k=(f,I=!1)=>{I||(r.includes(f)?o(r.filter(j=>j!==f)):o([...r,f]))},b=()=>{a||m(!l)};return i.useEffect(()=>{l&&s&&C.current&&setTimeout(()=>{var f;(f=C.current)==null||f.focus()},10)},[l,s]),i.useEffect(()=>{const f=I=>{w.current&&!w.current.contains(I.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs(Xc,{ref:w,style:{width:p},className:d,children:[e.jsxs(Jc,{type:"button",onClick:b,disabled:a,"aria-haspopup":"listbox","aria-expanded":l,id:c,children:[z.length>0?z.map(f=>f.label).join(", "):e.jsx(rl,{children:n}),l?e.jsx(Vc,{size:16}):e.jsx(er,{size:16})]}),e.jsxs(el,{isOpen:l,role:"listbox",children:[s&&e.jsx(tl,{ref:C,type:"text",placeholder:"Search...",value:x,onChange:f=>v(f.target.value),onClick:f=>f.stopPropagation()}),$?_.map((f,I)=>e.jsxs(i.Fragment,{children:[e.jsx(ol,{children:f.label}),f.options.length===0?e.jsx(No,{children:"No options available"}):f.options.map(j=>e.jsxs(Do,{isSelected:r.includes(j.value),disabled:j.disabled,onClick:()=>k(j.value,j.disabled),role:"option","aria-selected":r.includes(j.value),children:[j.label,r.includes(j.value)&&e.jsx(rt,{size:16})]},j.value))]},`group-${I}`)):e.jsx(e.Fragment,{children:_.length===0?e.jsx(No,{children:"No options available"}):_.map(f=>e.jsxs(Do,{isSelected:r.includes(f.value),disabled:f.disabled,onClick:()=>k(f.value,f.disabled),role:"option","aria-selected":r.includes(f.value),children:[f.label,r.includes(f.value)&&e.jsx(rt,{size:16})]},f.value))})]}),g&&e.jsx("input",{type:"hidden",name:g,value:r.join(",")})]})},al=i.createContext(void 0);function sl(){const t=i.useContext(al);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function vf({children:t}){const{deployment:r}=ve(),[o,n]=i.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[a,s]=i.useState(""),[p,g]=i.useState(!1),[c,h]=i.useState(!1),[d,l]=i.useState(!1),m=(r==null?void 0:r.social_connections.filter(v=>v.enabled))||[],x=r==null?void 0:r.auth_settings;return e.jsx(al.Provider,{value:{email:a,showOtherOptions:p,showForgotPassword:c,otpSent:d,setFirstFactor:n,setEmail:s,setShowOtherOptions:g,setShowForgotPassword:h,setOtpSent:l,enabledSocialsProviders:m,authSettings:x,firstFactor:o},children:t})}const Cr=u.button`
1180
+ `,ja=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:a=!1,searchable:s=!1,width:h,name:g,id:c,groupsEnabled:p=!1,className:l})=>{const[d,m]=i.useState(!1),[x,v]=i.useState(""),w=i.useRef(null),$=i.useRef(null),z=p&&"options"in t[0],C=(z?t.flatMap(f=>f.options):t).find(f=>f.value===r),k=x?z?t.map(f=>({...f,options:f.options.filter(E=>E.label.toLowerCase().includes(x.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(x.toLowerCase())):t,S=(f,E=!1)=>{E||(o(f),m(!1),v(""))},b=()=>{a||m(!d)};return i.useEffect(()=>{d&&s&&$.current&&setTimeout(()=>{var f;(f=$.current)==null||f.focus()},10)},[d,s]),i.useEffect(()=>{const f=E=>{w.current&&!w.current.contains(E.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs(Xc,{ref:w,style:{width:h},className:l,children:[e.jsxs(Jc,{type:"button",onClick:b,disabled:a,"aria-haspopup":"listbox","aria-expanded":d,id:c,children:[C?C.label:e.jsx(rl,{children:n}),d?e.jsx(Vc,{size:16}):e.jsx(er,{size:16})]}),e.jsxs(el,{isOpen:d,role:"listbox",children:[s&&e.jsx(tl,{ref:$,type:"text",placeholder:"Search...",value:x,onChange:f=>v(f.target.value),onClick:f=>f.stopPropagation()}),z?k.map((f,E)=>e.jsxs(i.Fragment,{children:[e.jsx(ol,{children:f.label}),f.options.length===0?e.jsx(No,{children:"No options available"}):f.options.map(j=>e.jsxs(Do,{isSelected:j.value===r,disabled:j.disabled,onClick:()=>S(j.value,j.disabled),role:"option","aria-selected":j.value===r,children:[j.label,j.value===r&&e.jsx(rt,{size:16})]},j.value))]},`group-${E}`)):e.jsx(e.Fragment,{children:k.length===0?e.jsx(No,{children:"No options available"}):k.map(f=>e.jsxs(Do,{isSelected:f.value===r,disabled:f.disabled,onClick:()=>S(f.value,f.disabled),role:"option","aria-selected":f.value===r,children:[f.label,f.value===r&&e.jsx(rt,{size:16})]},f.value))})]}),g&&e.jsx("input",{type:"hidden",name:g,value:r||""})]})},nl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:a=!1,searchable:s=!1,width:h,name:g,id:c,groupsEnabled:p=!1,className:l})=>{const[d,m]=i.useState(!1),[x,v]=i.useState(""),w=i.useRef(null),$=i.useRef(null),z=p&&"options"in t[0],C=(z?t.flatMap(f=>f.options):t).filter(f=>r.includes(f.value)),k=x?z?t.map(f=>({...f,options:f.options.filter(E=>E.label.toLowerCase().includes(x.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(x.toLowerCase())):t,S=(f,E=!1)=>{E||(r.includes(f)?o(r.filter(j=>j!==f)):o([...r,f]))},b=()=>{a||m(!d)};return i.useEffect(()=>{d&&s&&$.current&&setTimeout(()=>{var f;(f=$.current)==null||f.focus()},10)},[d,s]),i.useEffect(()=>{const f=E=>{w.current&&!w.current.contains(E.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs(Xc,{ref:w,style:{width:h},className:l,children:[e.jsxs(Jc,{type:"button",onClick:b,disabled:a,"aria-haspopup":"listbox","aria-expanded":d,id:c,children:[C.length>0?C.map(f=>f.label).join(", "):e.jsx(rl,{children:n}),d?e.jsx(Vc,{size:16}):e.jsx(er,{size:16})]}),e.jsxs(el,{isOpen:d,role:"listbox",children:[s&&e.jsx(tl,{ref:$,type:"text",placeholder:"Search...",value:x,onChange:f=>v(f.target.value),onClick:f=>f.stopPropagation()}),z?k.map((f,E)=>e.jsxs(i.Fragment,{children:[e.jsx(ol,{children:f.label}),f.options.length===0?e.jsx(No,{children:"No options available"}):f.options.map(j=>e.jsxs(Do,{isSelected:r.includes(j.value),disabled:j.disabled,onClick:()=>S(j.value,j.disabled),role:"option","aria-selected":r.includes(j.value),children:[j.label,r.includes(j.value)&&e.jsx(rt,{size:16})]},j.value))]},`group-${E}`)):e.jsx(e.Fragment,{children:k.length===0?e.jsx(No,{children:"No options available"}):k.map(f=>e.jsxs(Do,{isSelected:r.includes(f.value),disabled:f.disabled,onClick:()=>S(f.value,f.disabled),role:"option","aria-selected":r.includes(f.value),children:[f.label,r.includes(f.value)&&e.jsx(rt,{size:16})]},f.value))})]}),g&&e.jsx("input",{type:"hidden",name:g,value:r.join(",")})]})},al=i.createContext(void 0);function sl(){const t=i.useContext(al);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function vf({children:t}){const{deployment:r}=xe(),[o,n]=i.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[a,s]=i.useState(""),[h,g]=i.useState(!1),[c,p]=i.useState(!1),[l,d]=i.useState(!1),m=(r==null?void 0:r.social_connections.filter(v=>v.enabled))||[],x=r==null?void 0:r.auth_settings;return e.jsx(al.Provider,{value:{email:a,showOtherOptions:h,showForgotPassword:c,otpSent:l,setFirstFactor:n,setEmail:s,setShowOtherOptions:g,setShowForgotPassword:p,setOtpSent:d,enabledSocialsProviders:m,authSettings:x,firstFactor:o},children:t})}const Sr=u.button`
1181
1181
  width: 100%;
1182
1182
  padding: var(--space-sm) var(--space-md);
1183
1183
  background: var(--color-input-background);
@@ -1200,17 +1200,17 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1200
1200
  opacity: 0.7;
1201
1201
  cursor: not-allowed;
1202
1202
  }
1203
- `;function il(){const{deployment:t}=ve(),{signIn:r}=Ar("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:a,setShowForgotPassword:s}=sl(),[p,g]=i.useState(!1),c=t==null?void 0:t.auth_settings,h=(t==null?void 0:t.social_connections.filter(m=>m.enabled))||[],d=async m=>{if(!p){g(!0);try{const{data:x}=await r.create({provider:m.provider});x&&typeof x=="object"&&"oauth_url"in x&&(window.location.href=x.oauth_url)}catch{}finally{g(!1)}}},l=()=>{s(!1),a(!1)};return e.jsxs(e.Fragment,{children:[h.length>0&&e.jsx(wa,{connections:h,callback:d}),e.jsxs("div",{children:[n!=="email_magic_link"&&(c==null?void 0:c.auth_factors_enabled.email_magic_link)&&e.jsx(Cr,{onClick:()=>{o("email_magic_link"),l()},children:"Get a magic link on your email"}),n!=="email_password"&&(c==null?void 0:c.auth_factors_enabled.email_password)&&e.jsx(Cr,{onClick:()=>{o("email_password"),l()},children:"Sign in with email and password"}),n!=="email_otp"&&(c==null?void 0:c.auth_factors_enabled.email_otp)&&e.jsx(Cr,{onClick:()=>{o("email_otp"),l()},children:"Sign in with email and OTP"}),n!=="phone_otp"&&(c==null?void 0:c.auth_factors_enabled.phone_otp)&&e.jsx(Cr,{onClick:()=>{o("phone_otp"),l()},children:"Sign in with phone number"}),n!=="username_password"&&(c==null?void 0:c.auth_factors_enabled.username_password)&&e.jsx(Cr,{onClick:()=>{o("username_password"),l()},children:"Sign in with username and password"})]})]})}const bf=u.div`
1203
+ `;function il(){const{deployment:t}=xe(),{signIn:r}=Dr("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:a,setShowForgotPassword:s}=sl(),[h,g]=i.useState(!1),c=t==null?void 0:t.auth_settings,p=(t==null?void 0:t.social_connections.filter(m=>m.enabled))||[],l=async m=>{if(!h){g(!0);try{const{data:x}=await r.create({provider:m.provider});x&&typeof x=="object"&&"oauth_url"in x&&(window.location.href=x.oauth_url)}catch{}finally{g(!1)}}},d=()=>{s(!1),a(!1)};return e.jsxs(e.Fragment,{children:[p.length>0&&e.jsx(wa,{connections:p,callback:l}),e.jsxs("div",{children:[n!=="email_magic_link"&&(c==null?void 0:c.auth_factors_enabled.email_magic_link)&&e.jsx(Sr,{onClick:()=>{o("email_magic_link"),d()},children:"Get a magic link on your email"}),n!=="email_password"&&(c==null?void 0:c.auth_factors_enabled.email_password)&&e.jsx(Sr,{onClick:()=>{o("email_password"),d()},children:"Sign in with email and password"}),n!=="email_otp"&&(c==null?void 0:c.auth_factors_enabled.email_otp)&&e.jsx(Sr,{onClick:()=>{o("email_otp"),d()},children:"Sign in with email and OTP"}),n!=="phone_otp"&&(c==null?void 0:c.auth_factors_enabled.phone_otp)&&e.jsx(Sr,{onClick:()=>{o("phone_otp"),d()},children:"Sign in with phone number"}),n!=="username_password"&&(c==null?void 0:c.auth_factors_enabled.username_password)&&e.jsx(Sr,{onClick:()=>{o("username_password"),d()},children:"Sign in with username and password"})]})]})}const bf=u.div`
1204
1204
  max-width: 380px;
1205
1205
  width: 380px;
1206
1206
  padding: var(--space-3xl);
1207
1207
  background: var(--color-background);
1208
1208
  border-radius: var(--radius-lg);
1209
1209
  box-shadow: 0 4px 12px var(--color-shadow);
1210
- `,Xr=u.div`
1210
+ `,Jr=u.div`
1211
1211
  text-align: center;
1212
1212
  margin-bottom: var(--space-lg);
1213
- `,Jr=u.h1`
1213
+ `,eo=u.h1`
1214
1214
  font-size: var(--font-lg);
1215
1215
  color: var(--color-foreground);
1216
1216
  margin: 0 0 var(--space-xs) 0;
@@ -1223,7 +1223,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1223
1223
  color: var(--color-error);
1224
1224
  margin: 0;
1225
1225
  margin-top: var(--space-2xs);
1226
- `,yf=u(K)`
1226
+ `,yf=u(Q)`
1227
1227
  width: 100%;
1228
1228
  margin-bottom: var(--space-lg);
1229
1229
  `,wf=u.div`
@@ -1250,21 +1250,21 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1250
1250
  }
1251
1251
  `,jf=u.span`
1252
1252
  white-space: nowrap;
1253
- `,eo=u.div`
1253
+ `,to=u.div`
1254
1254
  text-align: center;
1255
1255
  margin-top: var(--space-lg);
1256
- `,Sr=u.p`
1256
+ `,$r=u.p`
1257
1257
  font-size: var(--font-sm);
1258
1258
  color: var(--color-muted);
1259
1259
  margin: 0;
1260
- `,$r=u.a`
1260
+ `,zr=u.a`
1261
1261
  color: var(--color-primary);
1262
1262
  text-decoration: none;
1263
1263
 
1264
1264
  &:hover {
1265
1265
  text-decoration: underline;
1266
1266
  }
1267
- `;function kf({onBack:t}){const{deployment:r}=ve(),{navigate:o}=He(),[n,a]=i.useState("start"),[s,p]=i.useState(""),[g,c]=i.useState(""),[h,d]=i.useState(""),[l,m]=i.useState(""),[x,v]=i.useState(""),{forgotPassword:w,verifyOtp:C,resetPassword:$,error:y}=sc(),[z,_]=i.useState(!1),k=async j=>{if(j.preventDefault(),!s)return;_(!0);const S=await w(s);_(!1),S.errors||a("otp")},b=async j=>{if(j.preventDefault(),g.length!==6)return;_(!0);const S=await C(s,g);_(!1),!S.errors&&S.data&&(d(S.data.token),a("reset"))},f=async j=>{var R,E;if(j.preventDefault(),l!==x||l.length<8||l.length<8)return;_(!0);const S=await $(h,l);if(_(!1),!S.errors&&S.data){const T=S.data,P=T.signin_attempts&&T.signin_attempts.length>0?T.signin_attempts[T.signin_attempts.length-1]:null;if(P&&!P.completed){const O=(R=r==null?void 0:r.ui_settings)==null?void 0:R.sign_in_page_url;if(O){const D=new URL(O,window.location.origin);D.searchParams.set("signin_attempt_id",P.id),o(D.toString())}else t()}else{const O=((E=r==null?void 0:r.ui_settings)==null?void 0:E.after_signin_redirect_url)||"/";o(O)}}},I=()=>e.jsxs(e.Fragment,{children:[e.jsx(Ae,{}),e.jsx(Xr,{children:e.jsx(Jr,{children:"Forgot Password"})}),e.jsx(yf,{onClick:()=>a("email"),disabled:z,children:"Reset your password"}),e.jsx(wf,{children:e.jsx(jf,{children:"Or, sign in with another method"})}),e.jsx(il,{}),e.jsxs(eo,{children:[e.jsxs(Sr,{children:["Unable to reset password? ",e.jsx($r,{href:"/contact",children:"Get help"})]}),e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(le,{children:e.jsxs(bf,{children:[n==="start"&&I(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsxs(Xr,{children:[e.jsx(Jr,{children:"Forgot Password"}),e.jsx(Cn,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(dt,{onSubmit:k,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"email",children:"Email Address"}),e.jsx(de,{type:"email",id:"email",value:s,onChange:j=>p(j.target.value),placeholder:"Enter your email",required:!0})]}),y&&e.jsx(Sn,{children:y.message}),e.jsx(K,{type:"submit",disabled:z,style:{width:"100%",marginTop:"var(--space-md)"},children:z?"Sending...":"Send Code"})]}),e.jsx(eo,{children:e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsxs(Xr,{children:[e.jsx(Jr,{children:"Enter Verification Code"}),e.jsxs(Cn,{children:["We've sent a 6-digit code to ",s,". Please enter it below."]})]}),e.jsxs(dt,{onSubmit:b,noValidate:!0,children:[e.jsx(Rt,{onComplete:j=>c(j),isSubmitting:z,error:y==null?void 0:y.message,onResend:async()=>{await w(s)}}),y&&e.jsx(Sn,{children:y.message}),e.jsx(K,{type:"submit",disabled:z||g.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:z?"Verifying...":"Verify"})]}),e.jsx(eo,{children:e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsxs(Xr,{children:[e.jsx(Jr,{children:"Reset Password"}),e.jsx(Cn,{children:"Create a new password for your account."})]}),e.jsxs(dt,{onSubmit:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"password",children:"New Password"}),e.jsx(de,{type:"password",id:"password",value:l,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(de,{type:"password",id:"confirmPassword",value:x,onChange:j=>v(j.target.value),placeholder:"Confirm new password",required:!0})]}),y&&e.jsx(Sn,{children:y.message}),e.jsx(K,{type:"submit",disabled:z,style:{width:"100%",marginTop:"var(--space-md)"},children:z?"Resetting...":"Reset Password"})]}),e.jsx(eo,{children:e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const _f=u.div`
1267
+ `;function kf({onBack:t}){const{deployment:r}=xe(),{navigate:o}=He(),[n,a]=i.useState("start"),[s,h]=i.useState(""),[g,c]=i.useState(""),[p,l]=i.useState(""),[d,m]=i.useState(""),[x,v]=i.useState(""),{forgotPassword:w,verifyOtp:$,resetPassword:z,error:y}=sc(),[C,k]=i.useState(!1),S=async j=>{if(j.preventDefault(),!s)return;k(!0);const _=await w(s);k(!1),_.errors||a("otp")},b=async j=>{if(j.preventDefault(),g.length!==6)return;k(!0);const _=await $(s,g);k(!1),!_.errors&&_.data&&(l(_.data.token),a("reset"))},f=async j=>{var I,P;if(j.preventDefault(),d!==x||d.length<8||d.length<8)return;k(!0);const _=await z(p,d);if(k(!1),!_.errors&&_.data){const T=_.data,R=T.signin_attempts&&T.signin_attempts.length>0?T.signin_attempts[T.signin_attempts.length-1]:null;if(R&&!R.completed){const O=(I=r==null?void 0:r.ui_settings)==null?void 0:I.sign_in_page_url;if(O){const D=new URL(O,window.location.origin);D.searchParams.set("signin_attempt_id",R.id),o(D.toString())}else t()}else{const O=((P=r==null?void 0:r.ui_settings)==null?void 0:P.after_signin_redirect_url)||"/";o(O)}}},E=()=>e.jsxs(e.Fragment,{children:[e.jsx(Ae,{}),e.jsx(Jr,{children:e.jsx(eo,{children:"Forgot Password"})}),e.jsx(yf,{onClick:()=>a("email"),disabled:C,children:"Reset your password"}),e.jsx(wf,{children:e.jsx(jf,{children:"Or, sign in with another method"})}),e.jsx(il,{}),e.jsxs(to,{children:[e.jsxs($r,{children:["Unable to reset password? ",e.jsx(zr,{href:"/contact",children:"Get help"})]}),e.jsx($r,{style:{marginTop:"var(--space-sm)"},children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(le,{children:e.jsxs(bf,{children:[n==="start"&&E(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsxs(Jr,{children:[e.jsx(eo,{children:"Forgot Password"}),e.jsx(Cn,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(dt,{onSubmit:S,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"email",children:"Email Address"}),e.jsx(de,{type:"email",id:"email",value:s,onChange:j=>h(j.target.value),placeholder:"Enter your email",required:!0})]}),y&&e.jsx(Sn,{children:y.message}),e.jsx(Q,{type:"submit",disabled:C,style:{width:"100%",marginTop:"var(--space-md)"},children:C?"Sending...":"Send Code"})]}),e.jsx(to,{children:e.jsx($r,{style:{marginTop:"var(--space-sm)"},children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsxs(Jr,{children:[e.jsx(eo,{children:"Enter Verification Code"}),e.jsxs(Cn,{children:["We've sent a 6-digit code to ",s,". Please enter it below."]})]}),e.jsxs(dt,{onSubmit:b,noValidate:!0,children:[e.jsx(Rt,{onComplete:j=>c(j),isSubmitting:C,error:y==null?void 0:y.message,onResend:async()=>{await w(s)}}),y&&e.jsx(Sn,{children:y.message}),e.jsx(Q,{type:"submit",disabled:C||g.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:C?"Verifying...":"Verify"})]}),e.jsx(to,{children:e.jsx($r,{style:{marginTop:"var(--space-sm)"},children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsxs(Jr,{children:[e.jsx(eo,{children:"Reset Password"}),e.jsx(Cn,{children:"Create a new password for your account."})]}),e.jsxs(dt,{onSubmit:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"password",children:"New Password"}),e.jsx(de,{type:"password",id:"password",value:d,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(de,{type:"password",id:"confirmPassword",value:x,onChange:j=>v(j.target.value),placeholder:"Confirm new password",required:!0})]}),y&&e.jsx(Sn,{children:y.message}),e.jsx(Q,{type:"submit",disabled:C,style:{width:"100%",marginTop:"var(--space-md)"},children:C?"Resetting...":"Reset Password"})]}),e.jsx(to,{children:e.jsx($r,{style:{marginTop:"var(--space-sm)"},children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const _f=u.div`
1268
1268
  max-width: 360px;
1269
1269
  width: 360px;
1270
1270
  padding: var(--space-2xl);
@@ -1406,7 +1406,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1406
1406
  color: var(--color-error);
1407
1407
  margin: 0;
1408
1408
  margin-top: var(--space-2xs);
1409
- `,Hf=u(K)`
1409
+ `,Hf=u(Q)`
1410
1410
  margin-top: var(--space-sm);
1411
1411
  width: 100%;
1412
1412
  `,qf=u.div`
@@ -1426,14 +1426,14 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1426
1426
  }
1427
1427
  `,Zf=u(de)`
1428
1428
  padding: var(--space-sm) var(--space-md);
1429
- `;function ll({onVerify:t,onBack:r,loading:o}){const[n,a]=i.useState(""),[s,p]=i.useState(""),g=h=>{if(h.preventDefault(),n.length!==4){p("Please enter the last 4 digits of your phone number");return}t(n)},c=h=>{const d=h.target.value.replace(/\D/g,"").slice(0,4);a(d),p("")};return e.jsx(le,{children:e.jsxs(Bf,{children:[e.jsx(Ae,{}),e.jsxs(Uf,{children:[e.jsx(Wf,{children:"Verify your phone number"}),e.jsx(Vf,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(dt,{onSubmit:g,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(Zf,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!s,autoFocus:!0}),s&&e.jsx(Gf,{children:s})]}),e.jsx(Hf,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(qf,{children:e.jsx(Yf,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const Kf=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),Qf=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),Xf=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),$n=u.div`
1429
+ `;function ll({onVerify:t,onBack:r,loading:o}){const[n,a]=i.useState(""),[s,h]=i.useState(""),g=p=>{if(p.preventDefault(),n.length!==4){h("Please enter the last 4 digits of your phone number");return}t(n)},c=p=>{const l=p.target.value.replace(/\D/g,"").slice(0,4);a(l),h("")};return e.jsx(le,{children:e.jsxs(Bf,{children:[e.jsx(Ae,{}),e.jsxs(Uf,{children:[e.jsx(Wf,{children:"Verify your phone number"}),e.jsx(Vf,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(dt,{onSubmit:g,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(Zf,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!s,autoFocus:!0}),s&&e.jsx(Gf,{children:s})]}),e.jsx(Hf,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(qf,{children:e.jsx(Yf,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const Kf=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),Qf=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),Xf=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),$n=u.div`
1430
1430
  max-width: 380px;
1431
1431
  width: 380px;
1432
1432
  padding: var(--space-3xl);
1433
1433
  background: var(--color-background);
1434
1434
  border-radius: var(--radius-lg);
1435
1435
  box-shadow: 0 4px 12px var(--color-shadow);
1436
- `,Jf=wr`
1436
+ `,Jf=jr`
1437
1437
  from {
1438
1438
  transform: rotate(0deg);
1439
1439
  }
@@ -1468,14 +1468,14 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1468
1468
  color: var(--color-error);
1469
1469
  margin: 0;
1470
1470
  margin-top: var(--space-2xs);
1471
- `,tg=u(K)`
1471
+ `,tg=u(Q)`
1472
1472
  margin-top: var(--space-sm);
1473
1473
  `,gs=u.div`
1474
1474
  margin-top: var(--space-lg);
1475
1475
  text-align: center;
1476
1476
  font-size: var(--font-xs);
1477
1477
  color: var(--color-secondary-text);
1478
- `,zr=u.span`
1478
+ `,Er=u.span`
1479
1479
  color: var(--color-primary);
1480
1480
  text-decoration: none;
1481
1481
  font-weight: 400;
@@ -1487,7 +1487,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1487
1487
  }
1488
1488
  `,rg=u(de)`
1489
1489
  padding: var(--space-sm) var(--space-md);
1490
- `;function dl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:a}=ve(),[s,p]=i.useState(""),[g,c]=i.useState({}),[h,d]=i.useState(!1),[l,m]=i.useState(null),[x,v]=i.useState(!0),[w,C]=i.useState(!1),[$,y]=i.useState(""),[z,_]=i.useState(!1),{navigate:k}=He(),b=(r==null?void 0:r.available_2fa_methods)||[],f=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(Kf,{}),available:b.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(Qf,{}),available:b.includes("phone_otp"),phoneNumber:$},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Xf,{}),available:b.includes("backup_code")}].filter(E=>E.available),I=async E=>{m(E),v(!1),E==="phone_otp"&&C(!0)},j=async E=>{var T,P;if(r){d(!0);try{const O=await n({strategy:"phone_otp",lastDigits:E});O&&"data"in O&&((T=O.data)!=null&&T.otp_sent)?((P=O.data)!=null&&P.masked_phone&&y(O.data.masked_phone),C(!1)):c({phone:"Phone number verification failed"})}catch(O){c({phone:O.message})}finally{d(!1)}}},S=async E=>{if(E.preventDefault(),h)return;const T={};if(s?l==="authenticator"&&s.length!==6?T.code="Authentication code must be 6 digits":l==="phone_otp"&&s.length!==6&&(T.code="SMS code must be 6 digits"):T.code="Verification code is required",c(T),!(Object.keys(T).length>0)){d(!0);try{await o(s)}catch(P){c({submit:P.message})}finally{d(!1)}}},R=E=>{const T=E.target.value.replace(/\D/g,"").slice(0,6);p(T),c(P=>({...P,code:""}))};return i.useEffect(()=>{var E;if(r.completed){_(!0);let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=((E=a==null?void 0:a.ui_settings)==null?void 0:E.after_signin_redirect_url)||null),!T&&(a!=null&&a.frontend_host)&&(T=`https://${a.frontend_host}`),T){const P=new URL(T);(a==null?void 0:a.mode)==="staging"&&P.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),k(P.toString())}return}},[r,a]),z?e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsx(eg,{children:e.jsx(vr,{size:32})})]})}):x?f.length===0?e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsxs(us,{children:[e.jsx(ps,{children:"Set Up Two-Factor Authentication"}),e.jsx(hs,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),e.jsxs(gs,{children:[t&&e.jsx("div",{children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(zr,{children:e.jsx(tt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(cl,{methods:f,onSelectMethod:I,onBack:t}):w&&l==="phone_otp"?e.jsx(ll,{onVerify:j,onBack:()=>{C(!1),v(!0),m(null)},loading:h}):e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsxs(us,{children:[e.jsx(ps,{children:"Two-factor authentication"}),e.jsxs(hs,{children:[l==="authenticator"&&"Enter the 6-digit code from your authenticator app",l==="phone_otp"&&`Enter the 6-digit code sent to your phone ${$}`,l==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(dt,{onSubmit:S,noValidate:!0,children:[l==="backup_code"?e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"code",children:"Backup code"}),e.jsx(rg,{type:"text",id:"code",name:"code",value:s,onChange:R,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!g.code,autoFocus:!0}),g.code&&e.jsx(fs,{children:g.code})]}):e.jsx(Rt,{onComplete:async E=>{if(p(E),l!=="backup_code"){const T=new Event("submit",{bubbles:!0,cancelable:!0});await S(T)}},onResend:l==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:$.slice(-4)})}catch(E){c({submit:E.message})}}:void 0,error:g.code,isSubmitting:h}),e.jsxs("div",{children:[g.submit&&e.jsx(fs,{children:g.submit}),e.jsx(tg,{type:"submit",disabled:h||!s,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(gs,{children:[e.jsx(zr,{onClick:()=>{v(!0),m(null),p(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(zr,{children:e.jsx(tt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const zn=u.div`
1490
+ `;function dl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:a}=xe(),[s,h]=i.useState(""),[g,c]=i.useState({}),[p,l]=i.useState(!1),[d,m]=i.useState(null),[x,v]=i.useState(!0),[w,$]=i.useState(!1),[z,y]=i.useState(""),[C,k]=i.useState(!1),{navigate:S}=He(),b=(r==null?void 0:r.available_2fa_methods)||[],f=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(Kf,{}),available:b.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(Qf,{}),available:b.includes("phone_otp"),phoneNumber:z},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Xf,{}),available:b.includes("backup_code")}].filter(P=>P.available),E=async P=>{m(P),v(!1),P==="phone_otp"&&$(!0)},j=async P=>{var T,R;if(r){l(!0);try{const O=await n({strategy:"phone_otp",lastDigits:P});O&&"data"in O&&((T=O.data)!=null&&T.otp_sent)?((R=O.data)!=null&&R.masked_phone&&y(O.data.masked_phone),$(!1)):c({phone:"Phone number verification failed"})}catch(O){c({phone:O.message})}finally{l(!1)}}},_=async P=>{if(P.preventDefault(),p)return;const T={};if(s?d==="authenticator"&&s.length!==6?T.code="Authentication code must be 6 digits":d==="phone_otp"&&s.length!==6&&(T.code="SMS code must be 6 digits"):T.code="Verification code is required",c(T),!(Object.keys(T).length>0)){l(!0);try{await o(s)}catch(R){c({submit:R.message})}finally{l(!1)}}},I=P=>{const T=P.target.value.replace(/\D/g,"").slice(0,6);h(T),c(R=>({...R,code:""}))};return i.useEffect(()=>{var P;if(r.completed){k(!0);let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=((P=a==null?void 0:a.ui_settings)==null?void 0:P.after_signin_redirect_url)||null),!T&&(a!=null&&a.frontend_host)&&(T=`https://${a.frontend_host}`),T){const R=new URL(T);(a==null?void 0:a.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),S(R.toString())}return}},[r,a]),C?e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsx(eg,{children:e.jsx(vr,{size:32})})]})}):x?f.length===0?e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsxs(us,{children:[e.jsx(ps,{children:"Set Up Two-Factor Authentication"}),e.jsx(hs,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),e.jsxs(gs,{children:[t&&e.jsx("div",{children:e.jsx(Er,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Er,{children:e.jsx(tt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(cl,{methods:f,onSelectMethod:E,onBack:t}):w&&d==="phone_otp"?e.jsx(ll,{onVerify:j,onBack:()=>{$(!1),v(!0),m(null)},loading:p}):e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsxs(us,{children:[e.jsx(ps,{children:"Two-factor authentication"}),e.jsxs(hs,{children:[d==="authenticator"&&"Enter the 6-digit code from your authenticator app",d==="phone_otp"&&`Enter the 6-digit code sent to your phone ${z}`,d==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(dt,{onSubmit:_,noValidate:!0,children:[d==="backup_code"?e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"code",children:"Backup code"}),e.jsx(rg,{type:"text",id:"code",name:"code",value:s,onChange:I,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!g.code,autoFocus:!0}),g.code&&e.jsx(fs,{children:g.code})]}):e.jsx(Rt,{onComplete:async P=>{if(h(P),d!=="backup_code"){const T=new Event("submit",{bubbles:!0,cancelable:!0});await _(T)}},onResend:d==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:z.slice(-4)})}catch(P){c({submit:P.message})}}:void 0,error:g.code,isSubmitting:p}),e.jsxs("div",{children:[g.submit&&e.jsx(fs,{children:g.submit}),e.jsx(tg,{type:"submit",disabled:p||!s,children:p?"Verifying...":"Verify"})]})]}),e.jsxs(gs,{children:[e.jsx(Er,{onClick:()=>{v(!0),m(null),h(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Er,{children:e.jsx(tt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Er,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const zn=u.div`
1491
1491
  max-width: 380px;
1492
1492
  width: 380px;
1493
1493
  padding: var(--space-3xl);
@@ -1516,14 +1516,14 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1516
1516
  color: var(--color-error);
1517
1517
  margin: 0;
1518
1518
  margin-top: var(--space-2xs);
1519
- `,ng=u(K)`
1519
+ `,ng=u(Q)`
1520
1520
  margin-top: var(--space-sm);
1521
1521
  `,bs=u.div`
1522
1522
  margin-top: var(--space-lg);
1523
1523
  text-align: center;
1524
1524
  font-size: var(--font-xs);
1525
1525
  color: var(--color-secondary-text);
1526
- `,to=u.span`
1526
+ `,ro=u.span`
1527
1527
  color: var(--color-primary);
1528
1528
  text-decoration: none;
1529
1529
  font-weight: 400;
@@ -1552,7 +1552,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1552
1552
  transform: rotate(360deg);
1553
1553
  }
1554
1554
  }
1555
- `;function ul({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:a}){var N,F,J,ie,re,X,U,Z,Q;const{deployment:s}=ve(),{navigate:p}=He(),[g,c]=i.useState({}),[h,d]=i.useState({}),[l,m]=i.useState("US"),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState(null),[z,_]=i.useState(!1),k=$,b=w,f=async ae=>{var oe;C(!0),y(null);try{if(await o(ae)){_(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((oe=s==null?void 0:s.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y){const se=new URL(Y);(s==null?void 0:s.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(se.toString())}}}catch(ce){const Y=ce;throw y(Y),Y}finally{C(!1)}},I=async ae=>{var oe;C(!0),y(null);try{if(await n(ae)){_(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((oe=s==null?void 0:s.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y){const se=new URL(Y);(s==null?void 0:s.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(se.toString())}}return!0}catch(ce){return y(ce),!1}finally{C(!1)}};if(z||!t)return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsx(ag,{children:e.jsx(vr,{size:32})})]})});const j=t.missing_fields||[],S="Complete Your Profile",R="Please provide the following information to continue",E=s==null?void 0:s.auth_settings,T=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,P=ae=>{const{name:oe,value:ce}=ae.target;c(Y=>({...Y,[oe]:ce})),h[oe]&&d(Y=>({...Y,[oe]:""}))},O=()=>{const ae={};return j.forEach(oe=>{var se,q,H,A,B;const ce=g[oe];let Y=!1;switch(oe){case"first_name":Y=((se=E==null?void 0:E.first_name)==null?void 0:se.enabled)||!1;break;case"last_name":Y=((q=E==null?void 0:E.last_name)==null?void 0:q.enabled)||!1;break;case"username":Y=((H=E==null?void 0:E.username)==null?void 0:H.enabled)||!1;break;case"phone_number":Y=((A=E==null?void 0:E.phone_number)==null?void 0:A.enabled)||!1;break;case"email_address":Y=((B=E==null?void 0:E.email_address)==null?void 0:B.enabled)||!1;break;default:Y=!0}if(Y&&(!ce||ce.trim()==="")){const L=oe.replace("_"," ").replace(/\b\w/g,W=>W.toUpperCase());ae[oe]=`${L} is required`}}),g.username&&j.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(g.username)||(ae.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),g.phone_number&&j.includes("phone_number")&&(/^\d{7,15}$/.test(g.phone_number)||(ae.phone_number="Phone number must contain 7-15 digits")),g.email&&j.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(g.email)||(ae.email_address="Please enter a valid email address")),d(ae),Object.keys(ae).length===0},D=async ae=>{if(ae.preventDefault(),!O())return;const oe={...g};g.phone_number&&l&&(oe.phone_country_code=l),await f(oe)},M=ae=>{const oe=ae.target.value;c(ce=>({...ce,phone_number:oe})),h.phone_number&&d(ce=>({...ce,phone_number:""}))};if(T){const ae=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",oe=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",ce=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsxs(ms,{children:[e.jsx(xs,{children:ae}),e.jsx(vs,{children:oe})]}),e.jsxs(dt,{onSubmit:Y=>Y.preventDefault(),noValidate:!0,children:[e.jsx(Rt,{onComplete:I,onResend:async()=>{await a({strategy:ce})},error:k==null?void 0:k.message,isSubmitting:b}),k&&e.jsx(Mt,{style:{marginBottom:"var(--space-md)"},children:k.message})]}),e.jsxs(bs,{children:[e.jsx("div",{children:e.jsx(to,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(to,{children:e.jsx(tt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsxs(ms,{children:[e.jsx(xs,{children:S}),e.jsx(vs,{children:R})]}),e.jsxs(dt,{onSubmit:D,noValidate:!0,children:[(j.includes("first_name")||j.includes("last_name"))&&(((N=E==null?void 0:E.first_name)==null?void 0:N.enabled)||((F=E==null?void 0:E.last_name)==null?void 0:F.enabled))&&e.jsxs(og,{$isBothEnabled:!!((J=E==null?void 0:E.first_name)!=null&&J.enabled&&((ie=E==null?void 0:E.last_name)!=null&&ie.enabled)&&j.includes("first_name")&&j.includes("last_name")),children:[j.includes("first_name")&&((re=E==null?void 0:E.first_name)==null?void 0:re.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"first_name",children:["First name ",E.first_name.required&&"*"]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",value:g.first_name||"",onChange:P,placeholder:"Enter your first name","aria-invalid":!!h.first_name,disabled:b,autoComplete:"given-name"}),h.first_name&&e.jsx(Mt,{children:h.first_name})]}),j.includes("last_name")&&((X=E==null?void 0:E.last_name)==null?void 0:X.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"last_name",children:["Last name ",E.last_name.required&&"*"]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",value:g.last_name||"",onChange:P,placeholder:"Enter your last name","aria-invalid":!!h.last_name,disabled:b,autoComplete:"family-name"}),h.last_name&&e.jsx(Mt,{children:h.last_name})]})]}),j.includes("username")&&((U=E==null?void 0:E.username)==null?void 0:U.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"username",children:["Username ",E.username.required&&"*"]}),e.jsx(de,{type:"text",id:"username",name:"username",value:g.username||"",onChange:P,placeholder:"Choose a username","aria-invalid":!!h.username,disabled:b,autoComplete:"username"}),h.username&&e.jsx(Mt,{children:h.username})]}),j.includes("phone_number")&&((Z=E==null?void 0:E.phone_number)==null?void 0:Z.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"phone_number",children:["Phone number ",E.phone_number.required&&"*"]}),e.jsx(Br,{value:g.phone_number||"",onChange:M,error:h.phone_number,countryCode:l,setCountryCode:m}),h.phone_number&&e.jsx(Mt,{children:h.phone_number})]}),j.includes("email_address")&&((Q=E==null?void 0:E.email_address)==null?void 0:Q.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"email",children:["Email address ",E.email_address.required&&"*"]}),e.jsx(de,{type:"email",id:"email",name:"email",value:g.email||"",onChange:P,placeholder:"Enter your email address","aria-invalid":!!h.email_address,disabled:b,autoComplete:"email"}),h.email_address&&e.jsx(Mt,{children:h.email_address})]}),k&&e.jsx(Mt,{style:{marginBottom:"var(--space-md)"},children:k.message}),e.jsx(ng,{type:"submit",disabled:b,children:b?"Completing...":"Continue"})]}),e.jsxs(bs,{children:[r&&e.jsx("div",{children:e.jsx(to,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(to,{children:e.jsx(tt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const sg=new Set([Ve.ErrorCode.InvalidCredentials,Ve.ErrorCode.UserNotFound,Ve.ErrorCode.UserAlreadySignedIn,Ve.ErrorCode.Internal,Ve.ErrorCode.UserDisabled,Ve.ErrorCode.CountryRestricted,Ve.ErrorCode.EmailNotAllowed,Ve.ErrorCode.EmailBlocked,Ve.ErrorCode.DisposableEmailBlocked,Ve.ErrorCode.VoipNumberBlocked,Ve.ErrorCode.BannedKeyword]),ig=wr`
1555
+ `;function ul({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:a}){var Y,N,J,ae,ee,F,U,G,X;const{deployment:s}=xe(),{navigate:h}=He(),[g,c]=i.useState({}),[p,l]=i.useState({}),[d,m]=i.useState("US"),[x,v]=i.useState(!1),[w,$]=i.useState(!1),[z,y]=i.useState(null),[C,k]=i.useState(!1),S=z,b=w,f=async se=>{var oe;$(!0),y(null);try{if(await o(se)){k(!0);let K=new URLSearchParams(window.location.search).get("redirect_uri");if(K||(K=((oe=s==null?void 0:s.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!K&&(s!=null&&s.frontend_host)&&(K=`https://${s.frontend_host}`),K){const ie=new URL(K);(s==null?void 0:s.mode)==="staging"&&ie.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(ie.toString())}}}catch(ce){const K=ce;throw y(K),K}finally{$(!1)}},E=async se=>{var oe;$(!0),y(null);try{if(await n(se)){k(!0);let K=new URLSearchParams(window.location.search).get("redirect_uri");if(K||(K=((oe=s==null?void 0:s.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!K&&(s!=null&&s.frontend_host)&&(K=`https://${s.frontend_host}`),K){const ie=new URL(K);(s==null?void 0:s.mode)==="staging"&&ie.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),h(ie.toString())}}return!0}catch(ce){return y(ce),!1}finally{$(!1)}};if(C||!t)return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsx(ag,{children:e.jsx(vr,{size:32})})]})});const j=t.missing_fields||[],_="Complete Your Profile",I="Please provide the following information to continue",P=s==null?void 0:s.auth_settings,T=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,R=se=>{const{name:oe,value:ce}=se.target;c(K=>({...K,[oe]:ce})),p[oe]&&l(K=>({...K,[oe]:""}))},O=()=>{const se={};return j.forEach(oe=>{var ie,Z,q,A,B;const ce=g[oe];let K=!1;switch(oe){case"first_name":K=((ie=P==null?void 0:P.first_name)==null?void 0:ie.enabled)||!1;break;case"last_name":K=((Z=P==null?void 0:P.last_name)==null?void 0:Z.enabled)||!1;break;case"username":K=((q=P==null?void 0:P.username)==null?void 0:q.enabled)||!1;break;case"phone_number":K=((A=P==null?void 0:P.phone_number)==null?void 0:A.enabled)||!1;break;case"email_address":K=((B=P==null?void 0:P.email_address)==null?void 0:B.enabled)||!1;break;default:K=!0}if(K&&(!ce||ce.trim()==="")){const L=oe.replace("_"," ").replace(/\b\w/g,W=>W.toUpperCase());se[oe]=`${L} is required`}}),g.username&&j.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(g.username)||(se.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),g.phone_number&&j.includes("phone_number")&&(/^\d{7,15}$/.test(g.phone_number)||(se.phone_number="Phone number must contain 7-15 digits")),g.email&&j.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(g.email)||(se.email_address="Please enter a valid email address")),l(se),Object.keys(se).length===0},D=async se=>{if(se.preventDefault(),!O())return;const oe={...g};g.phone_number&&d&&(oe.phone_country_code=d),await f(oe)},M=se=>{const oe=se.target.value;c(ce=>({...ce,phone_number:oe})),p.phone_number&&l(ce=>({...ce,phone_number:""}))};if(T){const se=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",oe=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",ce=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsxs(ms,{children:[e.jsx(xs,{children:se}),e.jsx(vs,{children:oe})]}),e.jsxs(dt,{onSubmit:K=>K.preventDefault(),noValidate:!0,children:[e.jsx(Rt,{onComplete:E,onResend:async()=>{await a({strategy:ce})},error:S==null?void 0:S.message,isSubmitting:b}),S&&e.jsx(Mt,{style:{marginBottom:"var(--space-md)"},children:S.message})]}),e.jsxs(bs,{children:[e.jsx("div",{children:e.jsx(ro,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(ro,{children:e.jsx(tt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsxs(ms,{children:[e.jsx(xs,{children:_}),e.jsx(vs,{children:I})]}),e.jsxs(dt,{onSubmit:D,noValidate:!0,children:[(j.includes("first_name")||j.includes("last_name"))&&(((Y=P==null?void 0:P.first_name)==null?void 0:Y.enabled)||((N=P==null?void 0:P.last_name)==null?void 0:N.enabled))&&e.jsxs(og,{$isBothEnabled:!!((J=P==null?void 0:P.first_name)!=null&&J.enabled&&((ae=P==null?void 0:P.last_name)!=null&&ae.enabled)&&j.includes("first_name")&&j.includes("last_name")),children:[j.includes("first_name")&&((ee=P==null?void 0:P.first_name)==null?void 0:ee.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"first_name",children:["First name ",P.first_name.required&&"*"]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",value:g.first_name||"",onChange:R,placeholder:"Enter your first name","aria-invalid":!!p.first_name,disabled:b,autoComplete:"given-name"}),p.first_name&&e.jsx(Mt,{children:p.first_name})]}),j.includes("last_name")&&((F=P==null?void 0:P.last_name)==null?void 0:F.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"last_name",children:["Last name ",P.last_name.required&&"*"]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",value:g.last_name||"",onChange:R,placeholder:"Enter your last name","aria-invalid":!!p.last_name,disabled:b,autoComplete:"family-name"}),p.last_name&&e.jsx(Mt,{children:p.last_name})]})]}),j.includes("username")&&((U=P==null?void 0:P.username)==null?void 0:U.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"username",children:["Username ",P.username.required&&"*"]}),e.jsx(de,{type:"text",id:"username",name:"username",value:g.username||"",onChange:R,placeholder:"Choose a username","aria-invalid":!!p.username,disabled:b,autoComplete:"username"}),p.username&&e.jsx(Mt,{children:p.username})]}),j.includes("phone_number")&&((G=P==null?void 0:P.phone_number)==null?void 0:G.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"phone_number",children:["Phone number ",P.phone_number.required&&"*"]}),e.jsx(Ur,{value:g.phone_number||"",onChange:M,error:p.phone_number,countryCode:d,setCountryCode:m}),p.phone_number&&e.jsx(Mt,{children:p.phone_number})]}),j.includes("email_address")&&((X=P==null?void 0:P.email_address)==null?void 0:X.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"email",children:["Email address ",P.email_address.required&&"*"]}),e.jsx(de,{type:"email",id:"email",name:"email",value:g.email||"",onChange:R,placeholder:"Enter your email address","aria-invalid":!!p.email_address,disabled:b,autoComplete:"email"}),p.email_address&&e.jsx(Mt,{children:p.email_address})]}),S&&e.jsx(Mt,{style:{marginBottom:"var(--space-md)"},children:S.message}),e.jsx(ng,{type:"submit",disabled:b,children:b?"Completing...":"Continue"})]}),e.jsxs(bs,{children:[r&&e.jsx("div",{children:e.jsx(ro,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(ro,{children:e.jsx(tt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const sg=new Set([Ve.ErrorCode.InvalidCredentials,Ve.ErrorCode.UserNotFound,Ve.ErrorCode.UserAlreadySignedIn,Ve.ErrorCode.Internal,Ve.ErrorCode.UserDisabled,Ve.ErrorCode.CountryRestricted,Ve.ErrorCode.EmailNotAllowed,Ve.ErrorCode.EmailBlocked,Ve.ErrorCode.DisposableEmailBlocked,Ve.ErrorCode.VoipNumberBlocked,Ve.ErrorCode.BannedKeyword]),ig=jr`
1556
1556
  from {
1557
1557
  transform: rotate(0deg);
1558
1558
  }
@@ -1614,12 +1614,12 @@ position: relative;
1614
1614
  letter-spacing: 0.05em;
1615
1615
  `,dg=u.div`
1616
1616
  position: relative;
1617
- `,Er=u.p`
1617
+ `,Pr=u.p`
1618
1618
  font-size: var(--font-2xs);
1619
1619
  color: var(--color-error);
1620
1620
  margin: 0;
1621
1621
  margin-top: var(--space-2xs);
1622
- `,_s=u(K)`
1622
+ `,_s=u(Q)`
1623
1623
  margin-top: var(--space-lg);
1624
1624
  `,Pn=u.div`
1625
1625
  margin-top: var(--space-lg);
@@ -1636,7 +1636,7 @@ cursor: pointer;
1636
1636
  &:hover {
1637
1637
  color: var(--color-primary-hover);
1638
1638
  }
1639
- `;function ug(){return e.jsx(vf,{children:e.jsx(pg,{})})}function pg(){var U,Z,Q,ae,oe,ce,Y,se,q,H;const{deployment:t}=ve(),{navigate:r}=He(),{session:o,loading:n}=Fe(),{setEmail:a,otpSent:s,setOtpSent:p,showForgotPassword:g,setShowForgotPassword:c,showOtherOptions:h,setShowOtherOptions:d,enabledSocialsProviders:l,firstFactor:m}=sl(),{loading:x,signIn:v,signinAttempt:w,discardSignInAttempt:C,error:$,setSignInAttempt:y}=Ar("generic"),{signIn:z}=Ar("oauth"),[_,k]=i.useState({email:"",username:"",password:"",phone:""}),[b,f]=i.useState({}),[I,j]=i.useState(!1),[S,R]=i.useState(""),[E,T]=i.useState("US"),[P,O]=i.useState(!1),D=A=>{let{name:B,value:L}=A.target;B==="phone"?L=L.replace(/[^0-9]/g,""):B==="email"&&(a(L),L=L.toLowerCase()),k(W=>({...W,[B]:L})),f(W=>({...W,[B]:""}))},M=()=>{k({email:"",username:"",password:"",phone:""}),f({}),T("US")},N=async A=>{if(A.preventDefault(),x||I)return;C();const B={};if(m==="email_password"?(_.email||(B.email="Email address is required"),_.password||(B.password="Password is required")):m==="username_password"?(_.username||(B.username="Username is required"),_.password||(B.password="Password is required")):m==="email_otp"||m==="email_magic_link"?_.email||(B.email="Email address is required"):m==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(B.phone="Phone number must contain 7-15 digits"):B.phone="Phone number is required"),f(B),Object.keys(B).length>0)return;let L="";switch(m){case"email_password":L="plain_email";break;case"username_password":L="plain_username";break;case"email_otp":L="email_otp";break;case"email_magic_link":L="magic_link";break;case"phone_otp":L="phone_otp";break}j(!0);try{const W={..._,strategy:L};m==="phone_otp"&&E&&(W.phone_country_code=E),await v.create(W)}catch(W){f({submit:W.message}),j(!1)}},F=async A=>{if(A.preventDefault(),x||I)return;const B={};if(!S){B.otp="OTP code is required",f(B);return}j(!0),f({});try{await v.completeVerification(S),p(!1),R("")}catch(L){f({otp:L.message||"Verification failed"})}finally{j(!1)}},J=async A=>{if(!(x||I)){j(!0);try{const L=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:W}=await z.create({provider:A.provider,redirectUri:L});W&&typeof W=="object"&&"oauth_url"in W&&(window.location.href=W.oauth_url)}catch(B){f({submit:B.message})}finally{j(!1)}}},ie=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const A=new URLSearchParams(window.location.search),B=A.get("impersonation_token");if(B&&!w&&!x&&!ie.current){ie.current=!0,A.delete("impersonation_token");const W=A.toString()?`${window.location.pathname}?${A.toString()} `:window.location.pathname;window.history.replaceState({},"",W),(async()=>{try{j(!0),await v.create({strategy:"impersonation",token:B})}catch(pe){f({submit:pe.message}),j(!1),ie.current=!1}})();return}const L=A.get("signin_attempt_id");if(L&&(o!=null&&o.signin_attempts)&&!w){const W=o.signin_attempts.find(ee=>ee.id===L);if(W){y(W),A.delete("signin_attempt_id");const ee=A.toString()?`${window.location.pathname}?${A.toString()} `:window.location.pathname;window.history.replaceState({},"",ee)}}},[o,n,w,y,x]),i.useEffect(()=>{var W;if(!w)return;if(w.completed){O(!0);let ee=new URLSearchParams(window.location.search).get("redirect_uri");if(ee||(ee=((W=t==null?void 0:t.ui_settings)==null?void 0:W.after_signin_redirect_url)||null),!ee&&(t!=null&&t.frontend_host)&&(ee=`https://${t.frontend_host}`),ee){const pe=new URL(ee);(t==null?void 0:t.mode)==="staging"&&pe.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(pe.toString())}return}if(!v||s)return;const B={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[w.current_step];if(!B)return;(async()=>{try{await v.prepareVerification({strategy:B}),p(!0)}catch(ee){console.error("Failed to prepare verification:",ee),f({submit:"Failed to send verification. Please try again."})}finally{j(!1)}})()},[w,v,s,p,r,t]),i.useEffect(()=>{const A={};if($!=null&&$.errors&&Array.isArray($==null?void 0:$.errors))for(const B of $.errors)sg.has(B.code)&&(A.submit=B.message);f(A)},[$]),h)return e.jsx(Ef,{onBack:()=>d(!1)});if(g)return e.jsx(kf,{onBack:()=>c(!1)});if((w==null?void 0:w.current_step)==="verify_second_factor")return e.jsx(dl,{attempt:w,completeVerification:v.completeVerification,prepareVerification:v.prepareVerification,onBack:()=>{C(),M(),p(!1)}});if((w==null?void 0:w.current_step)==="complete_profile")return e.jsx(ul,{attempt:w,completeProfile:v.completeProfile,completeVerification:v.completeVerification,prepareVerification:v.prepareVerification,onBack:()=>{C(),M(),p(!1)}});if(n)return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),e.jsx(ys,{children:e.jsx(vr,{size:32})})]})});if(P)return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),e.jsx(ys,{children:e.jsx(vr,{size:32})})]})});const X=(w==null?void 0:w.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(w.current_step)&&s;return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),X?e.jsx(e.Fragment,{children:e.jsxs(ws,{children:[e.jsx(js,{children:m==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(ks,{children:m==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:m==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(ws,{children:[e.jsx(js,{children:"Sign in to your account"}),e.jsxs(ks,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),X?m==="email_magic_link"?e.jsxs(Pn,{children:["Having trouble?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Lt,{onClick:()=>{p(!1),C(),M()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:F,noValidate:!0,children:[e.jsx(Rt,{onComplete:async A=>{if(R(A),A&&A.length===6){j(!0),f({});try{await v.completeVerification(A),p(!1)}catch(B){f({otp:B.message||"Verification failed"})}finally{j(!1)}}},onResend:async()=>{const A=m==="email_otp"?"email_otp":"phone_otp";await v.prepareVerification({strategy:A})},error:b.otp,isSubmitting:I}),e.jsx(_s,{type:"submit",disabled:I||x||!S,style:{margin:0},children:I?"Verifying...":`Continue to ${(H=t==null?void 0:t.ui_settings)==null?void 0:H.app_name}`})]}),e.jsxs(Pn,{children:["Having trouble?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Lt,{onClick:()=>{p(!1),C(),M()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wa,{connections:l,callback:J}),e.jsx(cg,{children:e.jsx(lg,{children:"or"})})]}),e.jsxs(dt,{onSubmit:N,noValidate:!0,children:[(m==="email_password"||m==="email_otp"||m==="email_magic_link")&&((Z=(U=t==null?void 0:t.auth_settings)==null?void 0:U.email_address)==null?void 0:Z.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"email",children:"Email address"}),e.jsx(de,{type:"email",id:"email",name:"email",value:_.email,onChange:D,placeholder:"Enter your email address","aria-invalid":!!b.email}),b.email&&e.jsx(Er,{children:b.email})]}),m==="username_password"&&((ae=(Q=t==null?void 0:t.auth_settings)==null?void 0:Q.username)==null?void 0:ae.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"username",children:"Username"}),e.jsx(de,{type:"text",id:"username",name:"username",value:_.username,onChange:D,placeholder:"Enter your username","aria-invalid":!!b.username}),b.username&&e.jsx(Er,{children:b.username})]}),m==="phone_otp"&&((ce=(oe=t==null?void 0:t.auth_settings)==null?void 0:oe.phone_number)==null?void 0:ce.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"phone",children:"Phone number"}),e.jsx(Br,{value:_.phone,onChange:D,error:b.phone,countryCode:E,setCountryCode:T}),b.phone&&e.jsx(Er,{children:b.phone})]}),(m==="email_password"||m==="username_password")&&((se=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.password)==null?void 0:se.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ue,{htmlFor:"password",children:"Password"}),e.jsx(Lt,{style:{fontSize:"12px"},onClick:()=>c(!0),children:"Forgot password?"})]}),e.jsx(dg,{children:e.jsx(de,{type:"password",id:"password",name:"password",value:_.password,onChange:D,placeholder:"Enter your password","aria-invalid":!!b.password})}),b.password&&e.jsx(Er,{children:b.password})]}),e.jsxs("div",{children:[b.submit&&e.jsx(Er,{children:b.submit}),e.jsx(_s,{type:"submit",disabled:I||x,children:I?"Signing in...":"Sign in"})]}),e.jsx(Lt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>d(!0),children:"Use other methods"})]}),e.jsxs(Pn,{children:["Don't have an account?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:`${(q=t.ui_settings)==null?void 0:q.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Cs=u.div`
1639
+ `;function ug(){return e.jsx(vf,{children:e.jsx(pg,{})})}function pg(){var U,G,X,se,oe,ce,K,ie,Z,q;const{deployment:t}=xe(),{navigate:r}=He(),{session:o,loading:n}=Fe(),{setEmail:a,otpSent:s,setOtpSent:h,showForgotPassword:g,setShowForgotPassword:c,showOtherOptions:p,setShowOtherOptions:l,enabledSocialsProviders:d,firstFactor:m}=sl(),{loading:x,signIn:v,signinAttempt:w,discardSignInAttempt:$,error:z,setSignInAttempt:y}=Dr("generic"),{signIn:C}=Dr("oauth"),[k,S]=i.useState({email:"",username:"",password:"",phone:""}),[b,f]=i.useState({}),[E,j]=i.useState(!1),[_,I]=i.useState(""),[P,T]=i.useState("US"),[R,O]=i.useState(!1),D=A=>{let{name:B,value:L}=A.target;B==="phone"?L=L.replace(/[^0-9]/g,""):B==="email"&&(a(L),L=L.toLowerCase()),S(W=>({...W,[B]:L})),f(W=>({...W,[B]:""}))},M=()=>{S({email:"",username:"",password:"",phone:""}),f({}),T("US")},Y=async A=>{if(A.preventDefault(),x||E)return;$();const B={};if(m==="email_password"?(k.email||(B.email="Email address is required"),k.password||(B.password="Password is required")):m==="username_password"?(k.username||(B.username="Username is required"),k.password||(B.password="Password is required")):m==="email_otp"||m==="email_magic_link"?k.email||(B.email="Email address is required"):m==="phone_otp"&&(k.phone?/^\d{7,15}$/.test(k.phone)||(B.phone="Phone number must contain 7-15 digits"):B.phone="Phone number is required"),f(B),Object.keys(B).length>0)return;let L="";switch(m){case"email_password":L="plain_email";break;case"username_password":L="plain_username";break;case"email_otp":L="email_otp";break;case"email_magic_link":L="magic_link";break;case"phone_otp":L="phone_otp";break}j(!0);try{const W={...k,strategy:L};m==="phone_otp"&&P&&(W.phone_country_code=P),await v.create(W)}catch(W){f({submit:W.message}),j(!1)}},N=async A=>{if(A.preventDefault(),x||E)return;const B={};if(!_){B.otp="OTP code is required",f(B);return}j(!0),f({});try{await v.completeVerification(_),h(!1),I("")}catch(L){f({otp:L.message||"Verification failed"})}finally{j(!1)}},J=async A=>{if(!(x||E)){j(!0);try{const L=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:W}=await C.create({provider:A.provider,redirectUri:L});W&&typeof W=="object"&&"oauth_url"in W&&(window.location.href=W.oauth_url)}catch(B){f({submit:B.message})}finally{j(!1)}}},ae=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const A=new URLSearchParams(window.location.search),B=A.get("impersonation_token");if(B&&!w&&!x&&!ae.current){ae.current=!0,A.delete("impersonation_token");const W=A.toString()?`${window.location.pathname}?${A.toString()} `:window.location.pathname;window.history.replaceState({},"",W),(async()=>{try{j(!0),await v.create({strategy:"impersonation",token:B})}catch(pe){f({submit:pe.message}),j(!1),ae.current=!1}})();return}const L=A.get("signin_attempt_id");if(L&&(o!=null&&o.signin_attempts)&&!w){const W=o.signin_attempts.find(te=>te.id===L);if(W){y(W),A.delete("signin_attempt_id");const te=A.toString()?`${window.location.pathname}?${A.toString()} `:window.location.pathname;window.history.replaceState({},"",te)}}},[o,n,w,y,x]),i.useEffect(()=>{var W;if(!w)return;if(w.completed){O(!0);let te=new URLSearchParams(window.location.search).get("redirect_uri");if(te||(te=((W=t==null?void 0:t.ui_settings)==null?void 0:W.after_signin_redirect_url)||null),!te&&(t!=null&&t.frontend_host)&&(te=`https://${t.frontend_host}`),te){const pe=new URL(te);(t==null?void 0:t.mode)==="staging"&&pe.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(pe.toString())}return}if(!v||s)return;const B={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[w.current_step];if(!B)return;(async()=>{try{await v.prepareVerification({strategy:B}),h(!0)}catch(te){console.error("Failed to prepare verification:",te),f({submit:"Failed to send verification. Please try again."})}finally{j(!1)}})()},[w,v,s,h,r,t]),i.useEffect(()=>{const A={};if(z!=null&&z.errors&&Array.isArray(z==null?void 0:z.errors))for(const B of z.errors)sg.has(B.code)&&(A.submit=B.message);f(A)},[z]),p)return e.jsx(Ef,{onBack:()=>l(!1)});if(g)return e.jsx(kf,{onBack:()=>c(!1)});if((w==null?void 0:w.current_step)==="verify_second_factor")return e.jsx(dl,{attempt:w,completeVerification:v.completeVerification,prepareVerification:v.prepareVerification,onBack:()=>{$(),M(),h(!1)}});if((w==null?void 0:w.current_step)==="complete_profile")return e.jsx(ul,{attempt:w,completeProfile:v.completeProfile,completeVerification:v.completeVerification,prepareVerification:v.prepareVerification,onBack:()=>{$(),M(),h(!1)}});if(n)return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),e.jsx(ys,{children:e.jsx(vr,{size:32})})]})});if(R)return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),e.jsx(ys,{children:e.jsx(vr,{size:32})})]})});const F=(w==null?void 0:w.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(w.current_step)&&s;return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),F?e.jsx(e.Fragment,{children:e.jsxs(ws,{children:[e.jsx(js,{children:m==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(ks,{children:m==="email_magic_link"?`If ${k.email} exists in our records, you will receive a magic link. Click the link to sign in.`:m==="phone_otp"?`If ${k.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${k.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(ws,{children:[e.jsx(js,{children:"Sign in to your account"}),e.jsxs(ks,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),F?m==="email_magic_link"?e.jsxs(Pn,{children:["Having trouble?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Lt,{onClick:()=>{h(!1),$(),M()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:N,noValidate:!0,children:[e.jsx(Rt,{onComplete:async A=>{if(I(A),A&&A.length===6){j(!0),f({});try{await v.completeVerification(A),h(!1)}catch(B){f({otp:B.message||"Verification failed"})}finally{j(!1)}}},onResend:async()=>{const A=m==="email_otp"?"email_otp":"phone_otp";await v.prepareVerification({strategy:A})},error:b.otp,isSubmitting:E}),e.jsx(_s,{type:"submit",disabled:E||x||!_,style:{margin:0},children:E?"Verifying...":`Continue to ${(q=t==null?void 0:t.ui_settings)==null?void 0:q.app_name}`})]}),e.jsxs(Pn,{children:["Having trouble?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Lt,{onClick:()=>{h(!1),$(),M()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[d.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wa,{connections:d,callback:J}),e.jsx(cg,{children:e.jsx(lg,{children:"or"})})]}),e.jsxs(dt,{onSubmit:Y,noValidate:!0,children:[(m==="email_password"||m==="email_otp"||m==="email_magic_link")&&((G=(U=t==null?void 0:t.auth_settings)==null?void 0:U.email_address)==null?void 0:G.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"email",children:"Email address"}),e.jsx(de,{type:"email",id:"email",name:"email",value:k.email,onChange:D,placeholder:"Enter your email address","aria-invalid":!!b.email}),b.email&&e.jsx(Pr,{children:b.email})]}),m==="username_password"&&((se=(X=t==null?void 0:t.auth_settings)==null?void 0:X.username)==null?void 0:se.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"username",children:"Username"}),e.jsx(de,{type:"text",id:"username",name:"username",value:k.username,onChange:D,placeholder:"Enter your username","aria-invalid":!!b.username}),b.username&&e.jsx(Pr,{children:b.username})]}),m==="phone_otp"&&((ce=(oe=t==null?void 0:t.auth_settings)==null?void 0:oe.phone_number)==null?void 0:ce.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"phone",children:"Phone number"}),e.jsx(Ur,{value:k.phone,onChange:D,error:b.phone,countryCode:P,setCountryCode:T}),b.phone&&e.jsx(Pr,{children:b.phone})]}),(m==="email_password"||m==="username_password")&&((ie=(K=t==null?void 0:t.auth_settings)==null?void 0:K.password)==null?void 0:ie.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ue,{htmlFor:"password",children:"Password"}),e.jsx(Lt,{style:{fontSize:"12px"},onClick:()=>c(!0),children:"Forgot password?"})]}),e.jsx(dg,{children:e.jsx(de,{type:"password",id:"password",name:"password",value:k.password,onChange:D,placeholder:"Enter your password","aria-invalid":!!b.password})}),b.password&&e.jsx(Pr,{children:b.password})]}),e.jsxs("div",{children:[b.submit&&e.jsx(Pr,{children:b.submit}),e.jsx(_s,{type:"submit",disabled:E||x,children:E?"Signing in...":"Sign in"})]}),e.jsx(Lt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>l(!0),children:"Use other methods"})]}),e.jsxs(Pn,{children:["Don't have an account?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:`${(Z=t.ui_settings)==null?void 0:Z.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Cs=u.div`
1640
1640
  max-width: 380px;
1641
1641
  width: 380px;
1642
1642
  padding: var(--space-3xl);
@@ -1698,7 +1698,7 @@ cursor: pointer;
1698
1698
  opacity: 0.7;
1699
1699
  cursor: not-allowed;
1700
1700
  }
1701
- `,ro=u.div`
1701
+ `,oo=u.div`
1702
1702
  color: var(--color-error);
1703
1703
  font-size: var(--font-2xs);
1704
1704
  margin-top: var(--space-2xs);
@@ -1737,28 +1737,28 @@ cursor: pointer;
1737
1737
  color: var(--color-primary);
1738
1738
  text-decoration: none;
1739
1739
  cursor: pointer;
1740
- `;function Sg(){var w,C,$,y,z,_,k,b,f,I,j,S;const{deployment:t}=ve(),{loading:r,error:o,joinWaitlist:n}=rc(),[a,s]=i.useState({first_name:"",last_name:"",email:""}),[p,g]=i.useState(!1),[c,h]=i.useState(!1),d=R=>{var E;if(o!=null&&o.errors)if(R){const T=o.errors.find(P=>{var O;return(O=P.code)==null?void 0:O.toLowerCase().includes(R.toLowerCase())});if(T)return T.message}else return(E=o==null?void 0:o.errors[0])==null?void 0:E.message},l=t==null?void 0:t.auth_settings,m=!!((w=l==null?void 0:l.first_name)!=null&&w.enabled&&((C=l==null?void 0:l.last_name)!=null&&C.enabled)),x=R=>{const{name:E,value:T}=R.target;s(P=>({...P,[E]:T}))},v=async R=>{if(R.preventDefault(),!!l){h(!0);try{(await n(a)).data&&g(!0)}catch{}finally{h(!1)}}};return p?e.jsx(le,{children:e.jsx(Cs,{children:e.jsxs(bg,{children:[e.jsx(yg,{children:e.jsx(rt,{size:32})}),e.jsx(wg,{children:"You're on the waitlist!"}),e.jsxs(jg,{children:["Thanks for your interest! We'll notify you at ",a.email," ","when we're ready for you to join."]})]})})}):e.jsx(le,{children:e.jsxs(Cs,{children:[e.jsx(Ae,{}),e.jsxs(hg,{children:[e.jsx(fg,{children:"Join the waitlist"}),e.jsx(gg,{children:"Be the first to know when we launch!"})]}),e.jsxs(mg,{onSubmit:v,noValidate:!0,children:[((($=l==null?void 0:l.first_name)==null?void 0:$.enabled)||((y=l==null?void 0:l.last_name)==null?void 0:y.enabled))&&e.jsxs(xg,{$isBothEnabled:m,children:[((z=l==null?void 0:l.first_name)==null?void 0:z.enabled)&&e.jsxs(Rn,{children:[e.jsxs(In,{htmlFor:"first_name",children:["First name",((_=l==null?void 0:l.first_name)==null?void 0:_.required)&&e.jsx(Tn,{children:"*"})]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",required:(k=l==null?void 0:l.first_name)==null?void 0:k.required,minLength:2,maxLength:50,value:a.first_name,onChange:x,placeholder:"First name","aria-invalid":!!d("first_name")}),d("first_name")&&e.jsx(ro,{children:d("first_name")})]}),((b=l==null?void 0:l.last_name)==null?void 0:b.enabled)&&e.jsxs(Rn,{children:[e.jsxs(In,{htmlFor:"last_name",children:["Last name",((f=l==null?void 0:l.last_name)==null?void 0:f.required)&&e.jsx(Tn,{children:"*"})]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",required:(I=l==null?void 0:l.last_name)==null?void 0:I.required,minLength:2,maxLength:50,value:a.last_name,onChange:x,placeholder:"Last name","aria-invalid":!!d("last_name")}),d("last_name")&&e.jsx(ro,{children:d("last_name")})]})]}),e.jsxs(Rn,{children:[e.jsxs(In,{htmlFor:"email",children:["Email address",((j=l==null?void 0:l.email_address)==null?void 0:j.required)&&e.jsx(Tn,{children:"*"})]}),e.jsx(de,{type:"email",id:"email",name:"email",required:(S=l==null?void 0:l.email_address)==null?void 0:S.required,value:a.email,onChange:x,placeholder:"Enter your email address","aria-invalid":!!d("email")}),d("email")&&e.jsx(ro,{children:d("email")})]}),d()&&e.jsx(ro,{children:d()}),e.jsx(vg,{type:"submit",$primary:!0,disabled:c||r,children:c||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(kg,{children:e.jsxs(_g,{children:["Need assistance? ",e.jsx(Cg,{href:"/contact",children:"Get help"})]})})]})})}const oo=u.div`
1740
+ `;function Sg(){var w,$,z,y,C,k,S,b,f,E,j,_;const{deployment:t}=xe(),{loading:r,error:o,joinWaitlist:n}=rc(),[a,s]=i.useState({first_name:"",last_name:"",email:""}),[h,g]=i.useState(!1),[c,p]=i.useState(!1),l=I=>{var P;if(o!=null&&o.errors)if(I){const T=o.errors.find(R=>{var O;return(O=R.code)==null?void 0:O.toLowerCase().includes(I.toLowerCase())});if(T)return T.message}else return(P=o==null?void 0:o.errors[0])==null?void 0:P.message},d=t==null?void 0:t.auth_settings,m=!!((w=d==null?void 0:d.first_name)!=null&&w.enabled&&(($=d==null?void 0:d.last_name)!=null&&$.enabled)),x=I=>{const{name:P,value:T}=I.target;s(R=>({...R,[P]:T}))},v=async I=>{if(I.preventDefault(),!!d){p(!0);try{(await n(a)).data&&g(!0)}catch{}finally{p(!1)}}};return h?e.jsx(le,{children:e.jsx(Cs,{children:e.jsxs(bg,{children:[e.jsx(yg,{children:e.jsx(rt,{size:32})}),e.jsx(wg,{children:"You're on the waitlist!"}),e.jsxs(jg,{children:["Thanks for your interest! We'll notify you at ",a.email," ","when we're ready for you to join."]})]})})}):e.jsx(le,{children:e.jsxs(Cs,{children:[e.jsx(Ae,{}),e.jsxs(hg,{children:[e.jsx(fg,{children:"Join the waitlist"}),e.jsx(gg,{children:"Be the first to know when we launch!"})]}),e.jsxs(mg,{onSubmit:v,noValidate:!0,children:[(((z=d==null?void 0:d.first_name)==null?void 0:z.enabled)||((y=d==null?void 0:d.last_name)==null?void 0:y.enabled))&&e.jsxs(xg,{$isBothEnabled:m,children:[((C=d==null?void 0:d.first_name)==null?void 0:C.enabled)&&e.jsxs(Rn,{children:[e.jsxs(In,{htmlFor:"first_name",children:["First name",((k=d==null?void 0:d.first_name)==null?void 0:k.required)&&e.jsx(Tn,{children:"*"})]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",required:(S=d==null?void 0:d.first_name)==null?void 0:S.required,minLength:2,maxLength:50,value:a.first_name,onChange:x,placeholder:"First name","aria-invalid":!!l("first_name")}),l("first_name")&&e.jsx(oo,{children:l("first_name")})]}),((b=d==null?void 0:d.last_name)==null?void 0:b.enabled)&&e.jsxs(Rn,{children:[e.jsxs(In,{htmlFor:"last_name",children:["Last name",((f=d==null?void 0:d.last_name)==null?void 0:f.required)&&e.jsx(Tn,{children:"*"})]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",required:(E=d==null?void 0:d.last_name)==null?void 0:E.required,minLength:2,maxLength:50,value:a.last_name,onChange:x,placeholder:"Last name","aria-invalid":!!l("last_name")}),l("last_name")&&e.jsx(oo,{children:l("last_name")})]})]}),e.jsxs(Rn,{children:[e.jsxs(In,{htmlFor:"email",children:["Email address",((j=d==null?void 0:d.email_address)==null?void 0:j.required)&&e.jsx(Tn,{children:"*"})]}),e.jsx(de,{type:"email",id:"email",name:"email",required:(_=d==null?void 0:d.email_address)==null?void 0:_.required,value:a.email,onChange:x,placeholder:"Enter your email address","aria-invalid":!!l("email")}),l("email")&&e.jsx(oo,{children:l("email")})]}),l()&&e.jsx(oo,{children:l()}),e.jsx(vg,{type:"submit",$primary:!0,disabled:c||r,children:c||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(kg,{children:e.jsxs(_g,{children:["Need assistance? ",e.jsx(Cg,{href:"/contact",children:"Get help"})]})})]})})}const no=u.div`
1741
1741
  max-width: 380px;
1742
1742
  width: 380px;
1743
1743
  padding: var(--space-3xl);
1744
1744
  background: var(--color-background);
1745
1745
  border-radius: var(--radius-lg);
1746
1746
  box-shadow: 0 4px 12px var(--color-shadow);
1747
- `,no=u.div`
1747
+ `,ao=u.div`
1748
1748
  text-align: center;
1749
1749
  margin-bottom: var(--space-lg);
1750
1750
  position: relative;
1751
- `,ao=u.h1`
1751
+ `,so=u.h1`
1752
1752
  font-size: var(--font-lg);
1753
1753
  font-weight: 400;
1754
1754
  color: var(--color-foreground);
1755
1755
  margin-bottom: var(--space-xs);
1756
1756
  margin-top: 0;
1757
- `,so=u.p`
1757
+ `,io=u.p`
1758
1758
  color: var(--color-secondary-text);
1759
1759
  font-size: var(--font-xs);
1760
1760
  margin: 0;
1761
- `,io=u.div`
1761
+ `,co=u.div`
1762
1762
  padding-top: var(--space-xl);
1763
1763
  text-align: center;
1764
1764
  `,$g=u.div`
@@ -1800,11 +1800,11 @@ cursor: pointer;
1800
1800
  margin: 0 auto var(--space-lg) auto;
1801
1801
  color: var(--color-success);
1802
1802
  font-size: var(--font-xl);
1803
- `,co=u.p`
1803
+ `,lo=u.p`
1804
1804
  font-size: var(--font-sm);
1805
1805
  color: var(--color-foreground);
1806
1806
  margin-bottom: var(--space-xs);
1807
- `,lo=u.p`
1807
+ `,uo=u.p`
1808
1808
  font-size: var(--font-xs);
1809
1809
  color: var(--color-secondary-text);
1810
1810
  margin-bottom: var(--space-lg);
@@ -1824,7 +1824,7 @@ cursor: pointer;
1824
1824
  color: var(--color-primary-hover);
1825
1825
  text-decoration: underline;
1826
1826
  }
1827
- `;function Rg(){const{deployment:t}=ve(),{navigate:r}=He(),{error:o,session:n,processed:a,signinAttempt:s,redirectUri:p,loading:g}=oc(),c=()=>{window.location.reload()},h=()=>{var l;const d=((l=t==null?void 0:t.ui_settings)==null?void 0:l.sign_in_page_url)||"/sign-in";r(d)};if(i.useEffect(()=>{var d,l;if(!(!a||g)){if(s&&!s.completed){const m=(d=t==null?void 0:t.ui_settings)==null?void 0:d.sign_in_page_url;if(m){const x=new URL(m,window.location.origin);x.searchParams.set("signin_attempt_id",s.id),p&&x.searchParams.set("redirect_uri",p),r(x.toString())}return}if(s!=null&&s.completed){const m=new URL(p||((l=t==null?void 0:t.ui_settings)==null?void 0:l.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"");m&&((t==null?void 0:t.mode)==="staging"&&m.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(m.toString()))}}},[n,a,g,p,t,s,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var l;const d=((l=t==null?void 0:t.ui_settings)==null?void 0:l.sign_in_page_url)||(t==null?void 0:t.frontend_host);d&&r(d)},2e3)},[o,t,r]),g&&!a)return e.jsx(le,{children:e.jsxs(oo,{children:[e.jsxs(no,{children:[e.jsx(ao,{children:"Completing sign in"}),e.jsx(so,{children:"Please wait while we authenticate you"})]}),e.jsxs(io,{children:[e.jsx(Ss,{}),e.jsx(co,{children:"Verifying your credentials..."}),e.jsx(lo,{children:"This will only take a moment."})]})]})});if(n&&a&&!o)return e.jsx(le,{children:e.jsxs(oo,{children:[e.jsxs(no,{children:[e.jsx(ao,{children:"Success!"}),e.jsx(so,{children:"Authentication completed successfully"})]}),e.jsxs(io,{children:[e.jsx(zg,{children:"✓"}),e.jsx(co,{children:"Redirecting you now..."}),e.jsx(lo,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const d=o.message.includes("No OAuth callback data found");return e.jsx(le,{children:e.jsxs(oo,{children:[e.jsxs(no,{children:[e.jsx(ao,{children:"Something went wrong"}),e.jsx(so,{children:"We couldn't complete your sign in"})]}),e.jsxs(io,{children:[e.jsx($g,{children:"✗"}),e.jsx(co,{children:"Authentication Failed"}),e.jsx(lo,{children:o.message||"An unexpected error occurred during authentication."}),!d&&e.jsx(K,{onClick:c,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!d&&e.jsx(Eg,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(Pg,{onClick:h,children:"Return to sign in"})]})})]})})}return e.jsx(le,{children:e.jsxs(oo,{children:[e.jsxs(no,{children:[e.jsx(ao,{children:"Completing sign in"}),e.jsx(so,{children:"Please wait while we authenticate you"})]}),e.jsxs(io,{children:[e.jsx(Ss,{}),e.jsx(co,{children:"Verifying your credentials..."}),e.jsx(lo,{children:"This will only take a moment."})]})]})})}const Ig=u.div`
1827
+ `;function Rg(){const{deployment:t}=xe(),{navigate:r}=He(),{error:o,session:n,processed:a,signinAttempt:s,redirectUri:h,loading:g}=oc(),c=()=>{window.location.reload()},p=()=>{var d;const l=((d=t==null?void 0:t.ui_settings)==null?void 0:d.sign_in_page_url)||"/sign-in";r(l)};if(i.useEffect(()=>{var l,d;if(!(!a||g)){if(s&&!s.completed){const m=(l=t==null?void 0:t.ui_settings)==null?void 0:l.sign_in_page_url;if(m){const x=new URL(m,window.location.origin);x.searchParams.set("signin_attempt_id",s.id),h&&x.searchParams.set("redirect_uri",h),r(x.toString())}return}if(s!=null&&s.completed){const m=new URL(h||((d=t==null?void 0:t.ui_settings)==null?void 0:d.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"");m&&((t==null?void 0:t.mode)==="staging"&&m.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(m.toString()))}}},[n,a,g,h,t,s,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var d;const l=((d=t==null?void 0:t.ui_settings)==null?void 0:d.sign_in_page_url)||(t==null?void 0:t.frontend_host);l&&r(l)},2e3)},[o,t,r]),g&&!a)return e.jsx(le,{children:e.jsxs(no,{children:[e.jsxs(ao,{children:[e.jsx(so,{children:"Completing sign in"}),e.jsx(io,{children:"Please wait while we authenticate you"})]}),e.jsxs(co,{children:[e.jsx(Ss,{}),e.jsx(lo,{children:"Verifying your credentials..."}),e.jsx(uo,{children:"This will only take a moment."})]})]})});if(n&&a&&!o)return e.jsx(le,{children:e.jsxs(no,{children:[e.jsxs(ao,{children:[e.jsx(so,{children:"Success!"}),e.jsx(io,{children:"Authentication completed successfully"})]}),e.jsxs(co,{children:[e.jsx(zg,{children:"✓"}),e.jsx(lo,{children:"Redirecting you now..."}),e.jsx(uo,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const l=o.message.includes("No OAuth callback data found");return e.jsx(le,{children:e.jsxs(no,{children:[e.jsxs(ao,{children:[e.jsx(so,{children:"Something went wrong"}),e.jsx(io,{children:"We couldn't complete your sign in"})]}),e.jsxs(co,{children:[e.jsx($g,{children:"✗"}),e.jsx(lo,{children:"Authentication Failed"}),e.jsx(uo,{children:o.message||"An unexpected error occurred during authentication."}),!l&&e.jsx(Q,{onClick:c,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!l&&e.jsx(Eg,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(Pg,{onClick:p,children:"Return to sign in"})]})})]})})}return e.jsx(le,{children:e.jsxs(no,{children:[e.jsxs(ao,{children:[e.jsx(so,{children:"Completing sign in"}),e.jsx(io,{children:"Please wait while we authenticate you"})]}),e.jsxs(co,{children:[e.jsx(Ss,{}),e.jsx(lo,{children:"Verifying your credentials..."}),e.jsx(uo,{children:"This will only take a moment."})]})]})})}const Ig=u.div`
1828
1828
  max-width: 380px;
1829
1829
  width: 380px;
1830
1830
  padding: var(--space-3xl);
@@ -1889,7 +1889,7 @@ cursor: pointer;
1889
1889
  `,On=u.p`
1890
1890
  font-size: var(--font-xs);
1891
1891
  color: var(--color-secondary-text);
1892
- `;function Fg({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[a,s]=i.useState(""),{token:p,attempt:g,redirectUri:c}=ac(),{verifyMagicLink:h,error:d,success:l}=nc(),{navigate:m}=He(),{deployment:x}=ve(),v=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!v.current){if(!p||!g){n("error"),s("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}v.current=!0,n("loading"),s("Please wait while we verify your magic link."),await h({token:p,attempt:g,redirectUri:c})}})()},[p,g]),i.useEffect(()=>{l?(n("success"),s("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var $;let C=c;if(C||(C=($=x==null?void 0:x.ui_settings)==null?void 0:$.after_signin_redirect_url),!C&&(x!=null&&x.frontend_host)&&(C=`https://${x.frontend_host}`),C){const y=new URL(C);(x==null?void 0:x.mode)==="staging"&&y.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),m(y.toString())}},2e3)):d&&(n("error"),s("The magic link may have expired or already been used. Please try signing in again."),r==null||r(d.message))},[l,d,m,x,c,t,r]);const w=()=>{var C;(C=x==null?void 0:x.ui_settings)!=null&&C.sign_in_page_url&&m(x.ui_settings.sign_in_page_url)};return e.jsx(le,{children:e.jsxs(Ig,{children:[e.jsxs(Tg,{children:[e.jsx(Og,{children:"Magic Link Verification"}),e.jsx(Mg,{children:"Verifying your magic link"})]}),e.jsxs(Lg,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(Ng,{}),e.jsx(On,{children:a})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(Ag,{children:"✓"}),e.jsx(On,{children:a})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(Dg,{children:"✗"}),e.jsx(On,{children:a}),e.jsx(K,{onClick:w,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function Bg(t){var n,a;return t?((n=t.signin_attempts)==null?void 0:n.find(s=>s.requires_completion&&!s.completed))?!0:!!((a=t.signup_attempts)==null?void 0:a.find(s=>{var p,g;return((p=s.missing_fields)==null?void 0:p.length)>0||((g=s.remaining_steps)==null?void 0:g.length)>0&&!s.completed})):!1}function Ug(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const At=u.div`
1892
+ `;function Fg({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[a,s]=i.useState(""),{token:h,attempt:g,redirectUri:c}=ac(),{verifyMagicLink:p,error:l,success:d}=nc(),{navigate:m}=He(),{deployment:x}=xe(),v=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!v.current){if(!h||!g){n("error"),s("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}v.current=!0,n("loading"),s("Please wait while we verify your magic link."),await p({token:h,attempt:g,redirectUri:c})}})()},[h,g]),i.useEffect(()=>{d?(n("success"),s("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var z;let $=c;if($||($=(z=x==null?void 0:x.ui_settings)==null?void 0:z.after_signin_redirect_url),!$&&(x!=null&&x.frontend_host)&&($=`https://${x.frontend_host}`),$){const y=new URL($);(x==null?void 0:x.mode)==="staging"&&y.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),m(y.toString())}},2e3)):l&&(n("error"),s("The magic link may have expired or already been used. Please try signing in again."),r==null||r(l.message))},[d,l,m,x,c,t,r]);const w=()=>{var $;($=x==null?void 0:x.ui_settings)!=null&&$.sign_in_page_url&&m(x.ui_settings.sign_in_page_url)};return e.jsx(le,{children:e.jsxs(Ig,{children:[e.jsxs(Tg,{children:[e.jsx(Og,{children:"Magic Link Verification"}),e.jsx(Mg,{children:"Verifying your magic link"})]}),e.jsxs(Lg,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(Ng,{}),e.jsx(On,{children:a})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(Ag,{children:"✓"}),e.jsx(On,{children:a})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(Dg,{children:"✗"}),e.jsx(On,{children:a}),e.jsx(Q,{onClick:w,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function Bg(t){var n,a;return t?((n=t.signin_attempts)==null?void 0:n.find(s=>s.requires_completion&&!s.completed))?!0:!!((a=t.signup_attempts)==null?void 0:a.find(s=>{var h,g;return((h=s.missing_fields)==null?void 0:h.length)>0||((g=s.remaining_steps)==null?void 0:g.length)>0&&!s.completed})):!1}function Ug(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const At=u.div`
1893
1893
  max-width: 380px;
1894
1894
  width: 380px;
1895
1895
  padding: var(--space-3xl);
@@ -1989,7 +1989,7 @@ cursor: pointer;
1989
1989
  &:hover {
1990
1990
  color: var(--color-primary-hover);
1991
1991
  }
1992
- `;function qg({token:t,onSuccess:r,onError:o}){var w;const{acceptInvitation:n,invitationData:a,loading:s,error:p}=dc(),{navigate:g}=He(),{deployment:c}=ve(),h=i.useRef(!1),d=()=>{var $;const C=new URLSearchParams(window.location.search);return{token:t||C.get("invite_token")||C.get("token"),redirectUri:C.get("redirect_uri")||(($=c==null?void 0:c.ui_settings)==null?void 0:$.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(h.current)return;const{token:C}=d();C&&(h.current=!0,n(C))},[n]),i.useEffect(()=>{var C;a&&(a.organization&&!a.requires_signin&&r&&r(a.organization.id,(C=a.workspace)==null?void 0:C.id),a.error_code&&o&&o(a.message||"Failed to accept invitation"))},[a,r,o]);const l=()=>{const{redirectUri:C}=d();g(C)},m=()=>{var b,f;const{token:C,redirectUri:$}=d(),y=((b=c==null?void 0:c.ui_settings)==null?void 0:b.sign_in_page_url)||"/sign-in",z=((f=c==null?void 0:c.ui_settings)==null?void 0:f.sign_up_page_url)||"/sign-up",_=new URLSearchParams;C&&_.set("invite_token",C),a!=null&&a.invited_email&&_.set("invited_email",a.invited_email),_.set("redirect_uri",$),a!=null&&a.message&&_.set("message",a.message);const k=(a==null?void 0:a.error_code)==="INVITATION_REQUIRES_SIGNUP";g(`${k?z:y}?${_.toString()}`)},x=()=>{const{token:C}=d();C&&(h.current=!1,n(C))},{token:v}=d();if(!v&&!s)return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Invalid Invitation"}),e.jsx(Ft,{children:"No invitation token found"})]}),e.jsxs(Bt,{children:[e.jsx(Mn,{children:"✗"}),e.jsx(Ut,{children:"Missing Invitation Token"}),e.jsx(Wt,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(K,{onClick:()=>g("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(s)return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Processing Invitation"}),e.jsx(Ft,{children:"Please wait while we verify your invitation"})]}),e.jsxs(Bt,{children:[e.jsx(Vg,{}),e.jsx(Ut,{children:"Verifying invitation..."}),e.jsx(Wt,{children:"This will only take a moment."})]})]})});if(a!=null&&a.organization&&!a.requires_signin)return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Invitation Accepted!"}),e.jsx(Ft,{children:"You've successfully joined the organization"})]}),e.jsxs(Bt,{children:[e.jsx(Wg,{children:"✓"}),e.jsxs(Ut,{children:["Welcome to ",a.organization.name,"!"]}),a.workspace&&e.jsxs(Wt,{children:["You've been added to the ",a.workspace.name," workspace."]}),e.jsx(K,{onClick:l,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(a!=null&&a.already_member)return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Already a Member"}),e.jsx(Ft,{children:"You're already part of this organization"})]}),e.jsxs(Bt,{children:[e.jsx($s,{children:"ℹ"}),e.jsxs(Ut,{children:["You're already a member of ",((w=a.organization)==null?void 0:w.name)||"this organization"]}),e.jsx(Wt,{children:"No action needed - you already have access."}),e.jsx(K,{onClick:l,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(a!=null&&a.requires_signin){const C=a.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:C?"Sign Up Required":"Sign In Required"}),e.jsx(Ft,{children:"To accept this invitation"})]}),e.jsxs(Bt,{children:[e.jsx($s,{children:"ℹ"}),e.jsxs(Ut,{children:["This invitation is for ",e.jsx(zs,{children:a.invited_email})]}),e.jsx(Wt,{children:C?"You need to create an account with this email address to accept the invitation.":a.error_code==="INVITATION_EMAIL_MISMATCH"?"You're currently signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."}),e.jsx(K,{onClick:m,style:{marginTop:"var(--space-lg)"},children:C?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(a==null?void 0:a.error_code)==="INVITATION_EXPIRED"?e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Invitation Expired"}),e.jsx(Ft,{children:"This invitation is no longer valid"})]}),e.jsxs(Bt,{children:[e.jsx(Mn,{children:"⏱"}),e.jsxs(Ut,{children:["Invitation for ",e.jsx(zs,{children:a.invited_email})," has expired"]}),e.jsx(Wt,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):p||a!=null&&a.error_code?e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Invitation Error"}),e.jsx(Ft,{children:"Unable to process invitation"})]}),e.jsxs(Bt,{children:[e.jsx(Mn,{children:"✗"}),e.jsx(Ut,{children:"Something went wrong"}),e.jsx(Wt,{children:(a==null?void 0:a.message)||p||"Failed to accept invitation"}),e.jsx(K,{onClick:x,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(Gg,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(Hg,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const pl=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),st=()=>{const t=i.useContext(pl);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},Yg=u.div`
1992
+ `;function qg({token:t,onSuccess:r,onError:o}){var w;const{acceptInvitation:n,invitationData:a,loading:s,error:h}=dc(),{navigate:g}=He(),{deployment:c}=xe(),p=i.useRef(!1),l=()=>{var z;const $=new URLSearchParams(window.location.search);return{token:t||$.get("invite_token")||$.get("token"),redirectUri:$.get("redirect_uri")||((z=c==null?void 0:c.ui_settings)==null?void 0:z.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(p.current)return;const{token:$}=l();$&&(p.current=!0,n($))},[n]),i.useEffect(()=>{var $;a&&(a.organization&&!a.requires_signin&&r&&r(a.organization.id,($=a.workspace)==null?void 0:$.id),a.error_code&&o&&o(a.message||"Failed to accept invitation"))},[a,r,o]);const d=()=>{const{redirectUri:$}=l();g($)},m=()=>{var b,f;const{token:$,redirectUri:z}=l(),y=((b=c==null?void 0:c.ui_settings)==null?void 0:b.sign_in_page_url)||"/sign-in",C=((f=c==null?void 0:c.ui_settings)==null?void 0:f.sign_up_page_url)||"/sign-up",k=new URLSearchParams;$&&k.set("invite_token",$),a!=null&&a.invited_email&&k.set("invited_email",a.invited_email),k.set("redirect_uri",z),a!=null&&a.message&&k.set("message",a.message);const S=(a==null?void 0:a.error_code)==="INVITATION_REQUIRES_SIGNUP";g(`${S?C:y}?${k.toString()}`)},x=()=>{const{token:$}=l();$&&(p.current=!1,n($))},{token:v}=l();if(!v&&!s)return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Invalid Invitation"}),e.jsx(Ft,{children:"No invitation token found"})]}),e.jsxs(Bt,{children:[e.jsx(Mn,{children:"✗"}),e.jsx(Ut,{children:"Missing Invitation Token"}),e.jsx(Wt,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(Q,{onClick:()=>g("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(s)return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Processing Invitation"}),e.jsx(Ft,{children:"Please wait while we verify your invitation"})]}),e.jsxs(Bt,{children:[e.jsx(Vg,{}),e.jsx(Ut,{children:"Verifying invitation..."}),e.jsx(Wt,{children:"This will only take a moment."})]})]})});if(a!=null&&a.organization&&!a.requires_signin)return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Invitation Accepted!"}),e.jsx(Ft,{children:"You've successfully joined the organization"})]}),e.jsxs(Bt,{children:[e.jsx(Wg,{children:"✓"}),e.jsxs(Ut,{children:["Welcome to ",a.organization.name,"!"]}),a.workspace&&e.jsxs(Wt,{children:["You've been added to the ",a.workspace.name," workspace."]}),e.jsx(Q,{onClick:d,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(a!=null&&a.already_member)return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Already a Member"}),e.jsx(Ft,{children:"You're already part of this organization"})]}),e.jsxs(Bt,{children:[e.jsx($s,{children:"ℹ"}),e.jsxs(Ut,{children:["You're already a member of ",((w=a.organization)==null?void 0:w.name)||"this organization"]}),e.jsx(Wt,{children:"No action needed - you already have access."}),e.jsx(Q,{onClick:d,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(a!=null&&a.requires_signin){const $=a.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:$?"Sign Up Required":"Sign In Required"}),e.jsx(Ft,{children:"To accept this invitation"})]}),e.jsxs(Bt,{children:[e.jsx($s,{children:"ℹ"}),e.jsxs(Ut,{children:["This invitation is for ",e.jsx(zs,{children:a.invited_email})]}),e.jsx(Wt,{children:$?"You need to create an account with this email address to accept the invitation.":a.error_code==="INVITATION_EMAIL_MISMATCH"?"You're currently signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."}),e.jsx(Q,{onClick:m,style:{marginTop:"var(--space-lg)"},children:$?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(a==null?void 0:a.error_code)==="INVITATION_EXPIRED"?e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Invitation Expired"}),e.jsx(Ft,{children:"This invitation is no longer valid"})]}),e.jsxs(Bt,{children:[e.jsx(Mn,{children:"⏱"}),e.jsxs(Ut,{children:["Invitation for ",e.jsx(zs,{children:a.invited_email})," has expired"]}),e.jsx(Wt,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):h||a!=null&&a.error_code?e.jsx(le,{children:e.jsxs(At,{children:[e.jsxs(Dt,{children:[e.jsx(Nt,{children:"Invitation Error"}),e.jsx(Ft,{children:"Unable to process invitation"})]}),e.jsxs(Bt,{children:[e.jsx(Mn,{children:"✗"}),e.jsx(Ut,{children:"Something went wrong"}),e.jsx(Wt,{children:(a==null?void 0:a.message)||h||"Failed to accept invitation"}),e.jsx(Q,{onClick:x,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(Gg,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(Hg,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const pl=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),st=()=>{const t=i.useContext(pl);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},Yg=u.div`
1993
1993
  display: flex;
1994
1994
  height: 100%;
1995
1995
  min-height: 400px;
@@ -2178,7 +2178,7 @@ cursor: pointer;
2178
2178
  color: white;
2179
2179
  font-size: 12px;
2180
2180
  font-weight: 400;
2181
- `,rn=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[a,s]=i.useState(""),[p,g]=i.useState(),[c,h]=i.useState(null),[d,l]=i.useState(!1),m=i.useRef(null),{createOrganization:x}=Wo(),{toast:v}=st(),w=b=>{n(b)},C=b=>{if(b.target.files&&b.target.files[0]){const f=b.target.files[0];if(f.size>2*1024*1024){v("File size cannot exceed 2MB","error");return}if(!f.type.startsWith("image/")){v("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),g(f),h(URL.createObjectURL(f))}},$=()=>{var b;(b=m.current)==null||b.click()},y=b=>b.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const z=b=>b.trim().replace(/[<>\"'&]/g,""),_=b=>b.length>=2&&b.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(b),k=async()=>{const b=z(o),f=z(a);if(!b){v("Please enter an organization name","error");return}if(!_(b)){v("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(f.length>500){v("Description must be less than 500 characters","error");return}l(!0);try{const I=await x({name:b,description:f,image:p});t==null||t(I)}catch(I){const j=I.message||"Failed to create organization. Please try again.";v(j,"error")}finally{l(!1)}};return e.jsx(le,{children:e.jsxs(Yg,{children:[e.jsxs(Zg,{children:[e.jsxs(hl,{hasImage:!!c,onClick:$,children:[c?e.jsx(Qg,{src:c,alt:"Organization logo"}):e.jsx(Xg,{children:y(o||"O")}),e.jsx(um,{children:e.jsx(pm,{children:"Upload Logo"})})]}),e.jsx(dm,{type:"file",ref:m,onChange:C,accept:"image/png, image/jpeg, image/gif",disabled:d}),e.jsx(Jg,{children:"Create new organization"}),e.jsx(em,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(Kg,{children:[e.jsxs(tm,{children:[e.jsx(rm,{children:"Choose your organization name"}),e.jsx(om,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(nm,{children:[e.jsxs(Es,{children:[e.jsx(Ps,{children:"Organization name"}),e.jsx(am,{type:"text",value:o,onChange:b=>w(b.target.value),placeholder:"Acme Inc.",disabled:d})]}),e.jsxs(Es,{children:[e.jsx(Ps,{children:"Description (optional)"}),e.jsx(sm,{value:a,onChange:b=>s(b.target.value),placeholder:"What does your organization do?",disabled:d})]})]}),e.jsxs(im,{children:[r?e.jsxs(cm,{onClick:r,disabled:d,children:[e.jsx(Ur,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(lm,{onClick:k,disabled:d||!o.trim(),children:d?"Creating...":"Create"})]})]})]})})},hm=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(le,{children:e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsx(we.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(we.Body,{style:{padding:0},children:e.jsx(rn,{onSuccess:n,onCancel:r})})})})})})},fm=u.div`
2181
+ `,rn=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[a,s]=i.useState(""),[h,g]=i.useState(),[c,p]=i.useState(null),[l,d]=i.useState(!1),m=i.useRef(null),{createOrganization:x}=Wo(),{toast:v}=st(),w=b=>{n(b)},$=b=>{if(b.target.files&&b.target.files[0]){const f=b.target.files[0];if(f.size>2*1024*1024){v("File size cannot exceed 2MB","error");return}if(!f.type.startsWith("image/")){v("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),g(f),p(URL.createObjectURL(f))}},z=()=>{var b;(b=m.current)==null||b.click()},y=b=>b.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const C=b=>b.trim().replace(/[<>\"'&]/g,""),k=b=>b.length>=2&&b.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(b),S=async()=>{const b=C(o),f=C(a);if(!b){v("Please enter an organization name","error");return}if(!k(b)){v("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(f.length>500){v("Description must be less than 500 characters","error");return}d(!0);try{const E=await x({name:b,description:f,image:h});t==null||t(E)}catch(E){const j=E.message||"Failed to create organization. Please try again.";v(j,"error")}finally{d(!1)}};return e.jsx(le,{children:e.jsxs(Yg,{children:[e.jsxs(Zg,{children:[e.jsxs(hl,{hasImage:!!c,onClick:z,children:[c?e.jsx(Qg,{src:c,alt:"Organization logo"}):e.jsx(Xg,{children:y(o||"O")}),e.jsx(um,{children:e.jsx(pm,{children:"Upload Logo"})})]}),e.jsx(dm,{type:"file",ref:m,onChange:$,accept:"image/png, image/jpeg, image/gif",disabled:l}),e.jsx(Jg,{children:"Create new organization"}),e.jsx(em,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(Kg,{children:[e.jsxs(tm,{children:[e.jsx(rm,{children:"Choose your organization name"}),e.jsx(om,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(nm,{children:[e.jsxs(Es,{children:[e.jsx(Ps,{children:"Organization name"}),e.jsx(am,{type:"text",value:o,onChange:b=>w(b.target.value),placeholder:"Acme Inc.",disabled:l})]}),e.jsxs(Es,{children:[e.jsx(Ps,{children:"Description (optional)"}),e.jsx(sm,{value:a,onChange:b=>s(b.target.value),placeholder:"What does your organization do?",disabled:l})]})]}),e.jsxs(im,{children:[r?e.jsxs(cm,{onClick:r,disabled:l,children:[e.jsx(Wr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(lm,{onClick:S,disabled:l||!o.trim(),children:l?"Creating...":"Create"})]})]})]})})},hm=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(le,{children:e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsx(we.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(we.Body,{style:{padding:0},children:e.jsx(rn,{onSuccess:n,onCancel:r})})})})})})},fm=u.div`
2182
2182
  position: fixed;
2183
2183
  width: 360px;
2184
2184
  max-width: calc(100vw - 48px);
@@ -2227,7 +2227,7 @@ cursor: pointer;
2227
2227
  color: var(--color-foreground);
2228
2228
  background: var(--color-input-background);
2229
2229
  }
2230
- `,Ls=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(),[p,g]=i.useState(""),[c,h]=i.useState(!1),[d,l]=i.useState(!1),[m,x]=i.useState({top:0,left:0}),{addDomain:v,verifyDomain:w}=Qe(),{toast:C}=st(),$=k=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(k),y=k=>k.trim().toLowerCase().replace(/^https?:\/\//,""),z=async()=>{var b,f;const k=y(p);if(!k){C("Please enter a domain name","error");return}if(!$(k)){C("Please enter a valid domain name (e.g., example.com)","error");return}if(k.length>253){C("Domain name is too long","error");return}try{const I=await v({fqdn:k});if((b=I==null?void 0:I.errors)!=null&&b.length){const j=((f=I.errors[0])==null?void 0:f.message)||I.errors[0]||"Failed to add domain";C(typeof j=="string"?j:"Failed to add domain","error");return}C("Domain added successfully","info"),s(I.data)}catch(I){const j=I.message||"Failed to add domain. Please try again.";C(j,"error")}},_=async()=>{if(!(!a||c)){h(!0);try{await w(a),t==null||t(),C("Domain verified successfully","info")}catch(k){const b=k.message||"Failed to verify domain. Please check DNS records and try again.";C(b,"error")}finally{h(!1)}}};return i.useEffect(()=>{l(!0);const k=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const I=o.current;if(I){const j=I.getBoundingClientRect(),S=360,R=250,E=8;let T=0,P=0;const O=window.innerHeight-j.bottom,D=j.top;O>=R+E?(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):D>=R+E?(T=j.top-R-E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left)),x({top:T,left:P})}},10),b=I=>{n.current&&!n.current.contains(I.target)&&(t==null||t())},f=I=>{I.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(k),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,o]),i.useEffect(()=>{r&&s(r)},[r]),d?e.jsx(fm,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:a?e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{children:[e.jsx(Is,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Ms,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(Ke,{size:16})})]}),e.jsxs(Ts,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Record Type"}),e.jsx(de,{value:a==null?void 0:a.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Record Name"}),e.jsx(de,{value:a==null?void 0:a.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Record Data"}),e.jsx(de,{type:"text",value:a==null?void 0:a.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Os,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:_,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{children:[e.jsx(Is,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Ms,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(Ts,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ue,{children:"Enter FQDN"}),e.jsx(de,{type:"text",placeholder:"Enter your domain",value:p,onChange:k=>g(k.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Os,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!p||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Adding..."]}):"Continue"})]})]})}):null},gm=u.div`
2230
+ `,Ls=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(),[h,g]=i.useState(""),[c,p]=i.useState(!1),[l,d]=i.useState(!1),[m,x]=i.useState({top:0,left:0}),{addDomain:v,verifyDomain:w}=Qe(),{toast:$}=st(),z=S=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(S),y=S=>S.trim().toLowerCase().replace(/^https?:\/\//,""),C=async()=>{var b,f;const S=y(h);if(!S){$("Please enter a domain name","error");return}if(!z(S)){$("Please enter a valid domain name (e.g., example.com)","error");return}if(S.length>253){$("Domain name is too long","error");return}try{const E=await v({fqdn:S});if((b=E==null?void 0:E.errors)!=null&&b.length){const j=((f=E.errors[0])==null?void 0:f.message)||E.errors[0]||"Failed to add domain";$(typeof j=="string"?j:"Failed to add domain","error");return}$("Domain added successfully","info"),s(E.data)}catch(E){const j=E.message||"Failed to add domain. Please try again.";$(j,"error")}},k=async()=>{if(!(!a||c)){p(!0);try{await w(a),t==null||t(),$("Domain verified successfully","info")}catch(S){const b=S.message||"Failed to verify domain. Please check DNS records and try again.";$(b,"error")}finally{p(!1)}}};return i.useEffect(()=>{d(!0);const S=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const E=o.current;if(E){const j=E.getBoundingClientRect(),_=360,I=250,P=8;let T=0,R=0;const O=window.innerHeight-j.bottom,D=j.top;O>=I+P?(T=j.bottom+P,R=j.right-_,R<P&&(R=j.left,R+_>window.innerWidth-P&&(R=(window.innerWidth-_)/2))):D>=I+P?(T=j.top-I-P,R=j.right-_,R<P&&(R=j.left,R+_>window.innerWidth-P&&(R=(window.innerWidth-_)/2))):(T=j.bottom+P,R=j.right-_,R<P&&(R=j.left)),x({top:T,left:R})}},10),b=E=>{n.current&&!n.current.contains(E.target)&&(t==null||t())},f=E=>{E.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(S),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,o]),i.useEffect(()=>{r&&s(r)},[r]),l?e.jsx(fm,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:a?e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{children:[e.jsx(Is,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Ms,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(Ke,{size:16})})]}),e.jsxs(Ts,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Record Type"}),e.jsx(de,{value:a==null?void 0:a.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Record Name"}),e.jsx(de,{value:a==null?void 0:a.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Record Data"}),e.jsx(de,{type:"text",value:a==null?void 0:a.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Os,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:k,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{children:[e.jsx(Is,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Ms,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(Ts,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ue,{children:"Enter FQDN"}),e.jsx(de,{type:"text",placeholder:"Enter your domain",value:h,onChange:S=>g(S.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Os,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:C,disabled:!h||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Adding..."]}):"Continue"})]})]})}):null},gm=u.div`
2231
2231
  position: fixed;
2232
2232
  width: 360px;
2233
2233
  max-width: calc(100vw - 48px);
@@ -2276,7 +2276,7 @@ cursor: pointer;
2276
2276
  color: var(--color-foreground);
2277
2277
  background: var(--color-input-background);
2278
2278
  }
2279
- `,fl=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const a=i.useRef(null),[s,p]=i.useState(""),[g,c]=i.useState(null),[h,d]=i.useState(!1),[l,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{inviteMember:w}=Qe(),{toast:C}=st(),$=o.map(_=>({value:_.id,label:_.name})),y=_=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_),z=async()=>{const _=s.trim().toLowerCase();if(!(!_||!g)){if(!y(_)){C("Please enter a valid email address","error");return}if(_.length>320){C("Email address is too long","error");return}d(!0);try{await w({email:_,organizationRole:g}),r==null||r()}catch(k){const b=k.message||"Failed to send invitation. Please try again.";C(b,"error")}finally{d(!1)}}};return i.useEffect(()=>{m(!0);const _=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const f=n.current;if(f){const I=f.getBoundingClientRect(),j=360,S=250,R=8;let E=0,T=0;const P=window.innerHeight-I.bottom,O=I.top;P>=S+R?(E=I.bottom+R,T=I.right-j,T<R&&(T=I.left,T+j>window.innerWidth-R&&(T=(window.innerWidth-j)/2))):O>=S+R?(E=I.top-S-R,T=I.right-j,T<R&&(T=I.left,T+j>window.innerWidth-R&&(T=(window.innerWidth-j)/2))):(E=I.bottom+R,T=I.right-j,T<R&&(T=I.left)),v({top:E,left:T})}},10),k=f=>{a.current&&!a.current.contains(f.target)&&(t==null||t())},b=f=>{f.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",b),()=>{clearTimeout(_),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",b)}},[t,n]),l?e.jsxs(gm,{ref:a,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(mm,{children:[e.jsx(xm,{id:"invite-member-title",children:"Invite Member"}),e.jsx(ym,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(vm,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Email Address"}),e.jsx(de,{type:"email",placeholder:"colleague@company.com",value:s,onChange:_=>p(_.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Role"}),e.jsx(ja,{options:$,value:g==null?void 0:g.id,onChange:_=>c(o.find(k=>k.id===_)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(bm,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!s||!g||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},wm=u.div`
2279
+ `,fl=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const a=i.useRef(null),[s,h]=i.useState(""),[g,c]=i.useState(null),[p,l]=i.useState(!1),[d,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{inviteMember:w}=Qe(),{toast:$}=st(),z=o.map(k=>({value:k.id,label:k.name})),y=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),C=async()=>{const k=s.trim().toLowerCase();if(!(!k||!g)){if(!y(k)){$("Please enter a valid email address","error");return}if(k.length>320){$("Email address is too long","error");return}l(!0);try{await w({email:k,organizationRole:g}),r==null||r()}catch(S){const b=S.message||"Failed to send invitation. Please try again.";$(b,"error")}finally{l(!1)}}};return i.useEffect(()=>{m(!0);const k=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const f=n.current;if(f){const E=f.getBoundingClientRect(),j=360,_=250,I=8;let P=0,T=0;const R=window.innerHeight-E.bottom,O=E.top;R>=_+I?(P=E.bottom+I,T=E.right-j,T<I&&(T=E.left,T+j>window.innerWidth-I&&(T=(window.innerWidth-j)/2))):O>=_+I?(P=E.top-_-I,T=E.right-j,T<I&&(T=E.left,T+j>window.innerWidth-I&&(T=(window.innerWidth-j)/2))):(P=E.bottom+I,T=E.right-j,T<I&&(T=E.left)),v({top:P,left:T})}},10),S=f=>{a.current&&!a.current.contains(f.target)&&(t==null||t())},b=f=>{f.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",S),document.addEventListener("keydown",b),()=>{clearTimeout(k),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",b)}},[t,n]),d?e.jsxs(gm,{ref:a,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(mm,{children:[e.jsx(xm,{id:"invite-member-title",children:"Invite Member"}),e.jsx(ym,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(vm,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Email Address"}),e.jsx(de,{type:"email",placeholder:"colleague@company.com",value:s,onChange:k=>h(k.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Role"}),e.jsx(ja,{options:z,value:g==null?void 0:g.id,onChange:k=>c(o.find(S=>S.id===k)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(bm,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:C,disabled:!s||!g||p,style:{width:"auto"},children:p?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},wm=u.div`
2280
2280
  position: fixed;
2281
2281
  width: 400px;
2282
2282
  max-width: calc(100vw - 48px);
@@ -2327,7 +2327,7 @@ cursor: pointer;
2327
2327
  color: var(--color-foreground);
2328
2328
  background: var(--color-input-background);
2329
2329
  }
2330
- `,As=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var b;const a=i.useRef(null),[s,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]);Qe();const[h,d]=i.useState(!1),[l,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{deployment:w}=ve(),{toast:C}=st(),$=!!o,y=Array.isArray((b=w==null?void 0:w.b2b_settings)==null?void 0:b.organization_permissions)?w.b2b_settings.organization_permissions.map(f=>({value:f,label:f})):[];i.useEffect(()=>{m(!0);const f=setTimeout(()=>{if(!a.current)return;let R=null;if(n!=null&&n.current)R=n.current;else if($){const E=document.querySelectorAll("[data-role-dropdown-trigger]");for(let T=0;T<E.length;T++){const P=E[T];if(P.offsetParent!==null){R=P;break}}}else{const E=document.querySelectorAll("button");for(let T=0;T<E.length;T++){const P=E[T];if(P.textContent==="Add role"&&P.offsetParent!==null){R=P;break}}}if(R){const E=R.getBoundingClientRect(),T=400;let P=E.bottom+8,O=E.right-T;O<10&&(O=E.left),P+300>window.innerHeight&&(P=E.top-300-8),v({top:P,left:O})}},10),I=R=>{a.current&&!a.current.contains(R.target)&&(t==null||t())},j=R=>{R.key==="Escape"&&(t==null||t())},S=setTimeout(()=>{document.addEventListener("mousedown",I),document.addEventListener("keydown",j)},100);return()=>{clearTimeout(f),clearTimeout(S),document.removeEventListener("mousedown",I),document.removeEventListener("keydown",j)}},[t,$,n]);const z=f=>f.trim().replace(/[<>\"'&]/g,""),_=f=>f.length>=2&&f.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(f),k=async()=>{const f=z(s);if(!f){C("Please enter a role name","error");return}if(!_(f)){C("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(g.length===0){C("Please select at least one permission","error");return}d(!0);try{const I={id:o==null?void 0:o.id,name:f,permissions:g||[]};r==null||r(I)}catch(I){const j=I.message||`Failed to ${$?"update":"create"} role. Please try again.`;C(j,"error")}finally{d(!1)}};return l?e.jsxs(wm,{ref:a,$isInTable:$,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:f=>f.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(jm,{children:[e.jsx(km,{id:"role-dialog-title",children:$?"Edit Role":"Create New Role"}),e.jsx(Sm,{onClick:t,"aria-label":`Close ${$?"edit":"create"} role dialog`,children:e.jsx(Ke,{size:16})})]}),e.jsx(_m,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Role Name"}),e.jsx(de,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:s,onChange:f=>p(f.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Permissions"}),e.jsx(nl,{options:y,value:g,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Cm,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:k,disabled:!s||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," ",$?"Updating...":"Creating..."]}):$?"Update Role":"Create Role"})]})]}):null},jt=u.table`
2330
+ `,As=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var b;const a=i.useRef(null),[s,h]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]);Qe();const[p,l]=i.useState(!1),[d,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{deployment:w}=xe(),{toast:$}=st(),z=!!o,y=Array.isArray((b=w==null?void 0:w.b2b_settings)==null?void 0:b.organization_permissions)?w.b2b_settings.organization_permissions.map(f=>({value:f,label:f})):[];i.useEffect(()=>{m(!0);const f=setTimeout(()=>{if(!a.current)return;let I=null;if(n!=null&&n.current)I=n.current;else if(z){const P=document.querySelectorAll("[data-role-dropdown-trigger]");for(let T=0;T<P.length;T++){const R=P[T];if(R.offsetParent!==null){I=R;break}}}else{const P=document.querySelectorAll("button");for(let T=0;T<P.length;T++){const R=P[T];if(R.textContent==="Add role"&&R.offsetParent!==null){I=R;break}}}if(I){const P=I.getBoundingClientRect(),T=400;let R=P.bottom+8,O=P.right-T;O<10&&(O=P.left),R+300>window.innerHeight&&(R=P.top-300-8),v({top:R,left:O})}},10),E=I=>{a.current&&!a.current.contains(I.target)&&(t==null||t())},j=I=>{I.key==="Escape"&&(t==null||t())},_=setTimeout(()=>{document.addEventListener("mousedown",E),document.addEventListener("keydown",j)},100);return()=>{clearTimeout(f),clearTimeout(_),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",j)}},[t,z,n]);const C=f=>f.trim().replace(/[<>\"'&]/g,""),k=f=>f.length>=2&&f.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(f),S=async()=>{const f=C(s);if(!f){$("Please enter a role name","error");return}if(!k(f)){$("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(g.length===0){$("Please select at least one permission","error");return}l(!0);try{const E={id:o==null?void 0:o.id,name:f,permissions:g||[]};r==null||r(E)}catch(E){const j=E.message||`Failed to ${z?"update":"create"} role. Please try again.`;$(j,"error")}finally{l(!1)}};return d?e.jsxs(wm,{ref:a,$isInTable:z,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:f=>f.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(jm,{children:[e.jsx(km,{id:"role-dialog-title",children:z?"Edit Role":"Create New Role"}),e.jsx(Sm,{onClick:t,"aria-label":`Close ${z?"edit":"create"} role dialog`,children:e.jsx(Ke,{size:16})})]}),e.jsx(_m,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Role Name"}),e.jsx(de,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:s,onChange:f=>h(f.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Permissions"}),e.jsx(nl,{options:y,value:g,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Cm,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:S,disabled:!s||p,style:{width:"auto"},children:p?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," ",z?"Updating...":"Creating..."]}):z?"Update Role":"Create Role"})]})]}):null},jt=u.table`
2331
2331
  width: 100%;
2332
2332
  border-collapse: separate;
2333
2333
  border-spacing: 0;
@@ -2428,7 +2428,7 @@ cursor: pointer;
2428
2428
  display: flex;
2429
2429
  gap: 8px;
2430
2430
  justify-content: flex-end;
2431
- `,on=({title:t,onConfirm:r,onCancel:o})=>{const n=i.useRef(null),[a,s]=i.useState({top:0,left:0});return i.useEffect(()=>{var p;if(n.current){const g=(p=n.current.parentElement)==null?void 0:p.getBoundingClientRect();g&&s({top:g.bottom+8,left:g.right-320})}},[]),i.useEffect(()=>{const p=g=>{n.current&&!n.current.contains(g.target)&&o()};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[o]),e.jsxs(Pm,{ref:n,style:{top:`${a.top}px`,left:`${a.left}px`},children:[e.jsx(Rm,{children:t}),e.jsxs(Im,{children:[e.jsx(K,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(K,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},Ds=u.div`
2431
+ `,on=({title:t,onConfirm:r,onCancel:o})=>{const n=i.useRef(null),[a,s]=i.useState({top:0,left:0});return i.useEffect(()=>{var h;if(n.current){const g=(h=n.current.parentElement)==null?void 0:h.getBoundingClientRect();g&&s({top:g.bottom+8,left:g.right-320})}},[]),i.useEffect(()=>{const h=g=>{n.current&&!n.current.contains(g.target)&&o()};return document.addEventListener("mousedown",h),()=>{document.removeEventListener("mousedown",h)}},[o]),e.jsxs(Pm,{ref:n,style:{top:`${a.top}px`,left:`${a.left}px`},children:[e.jsx(Rm,{children:t}),e.jsxs(Im,{children:[e.jsx(Q,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(Q,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},Ds=u.div`
2432
2432
  * {
2433
2433
  box-sizing: border-box;
2434
2434
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -2483,7 +2483,7 @@ cursor: pointer;
2483
2483
  &::-webkit-scrollbar {
2484
2484
  display: none;
2485
2485
  }
2486
- `,Pr=u.button`
2486
+ `,Rr=u.button`
2487
2487
  padding: 12px 12px;
2488
2488
  border: none;
2489
2489
  background: none;
@@ -2511,7 +2511,7 @@ cursor: pointer;
2511
2511
  opacity: ${t=>t.$isActive?1:0};
2512
2512
  transition: opacity 0.15s ease;
2513
2513
  }
2514
- `,Rr=u.span`
2514
+ `,Ir=u.span`
2515
2515
  display: inline-flex;
2516
2516
  align-items: center;
2517
2517
  gap: 6px;
@@ -2530,9 +2530,9 @@ cursor: pointer;
2530
2530
  flex-wrap: wrap;
2531
2531
  gap: 12px;
2532
2532
  margin-bottom: 24px;
2533
- `,Lm=()=>{var O,D,M;const{activeOrganization:t,loading:r}=Qe(),{switchOrganization:o,refetch:n}=Fe(),{workspaces:a}=yt(),{deployment:s}=ve(),{deleteOrganization:p,updateOrganization:g}=Wo(),{toast:c}=st(),[h,d]=i.useState((t==null?void 0:t.name)||""),[l,m]=i.useState((t==null?void 0:t.description)||""),[x,v]=i.useState((t==null?void 0:t.image_url)||null),w=i.useRef(null),[C,$]=i.useState(!1),[y,z]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[_,k]=i.useState(""),[b,f]=i.useState(!1),[I,j]=i.useState(!1),S=i.useCallback(async()=>{if(!(!t||C))try{$(!0),await g(t,{name:h,description:l}),c("Changes saved","info")}catch(N){const F=N.message||"Failed to save changes. Please try again.";c(F,"error")}finally{$(!1)}},[t,h,l,x,y,g,c]);i.useEffect(()=>{var N;t&&(d(t.name||""),m(t.description||""),v(t.image_url||null),z({allowed_ips:((N=t.whitelisted_ips)==null?void 0:N.join(`
2534
- `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const R=i.useMemo(()=>a.filter(F=>F.organization.id===(t==null?void 0:t.id)),[a,t==null?void 0:t.id]),E=async()=>{if(!(!t||_!==t.name))try{f(!0),await o(""),await p(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{f(!1),k("")}};if(i.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const T=N=>{var F;if((F=N.target.files)!=null&&F[0]){const J=N.target.files[0];if(J.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!J.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&URL.revokeObjectURL(x),v(URL.createObjectURL(J)),setTimeout(()=>S(),100)}},P=()=>{w.current&&w.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:P,onMouseEnter:N=>{N.currentTarget.style.borderColor="var(--color-primary)",N.currentTarget.style.transform="scale(1.02)"},onMouseLeave:N=>{N.currentTarget.style.borderColor="var(--color-border)",N.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Dr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:w,style:{display:"none"},accept:"image/*",onChange:T,"aria-label":"Upload organization logo"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your organization"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(K,{onClick:()=>{var N;return(N=w.current)==null?void 0:N.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Dr,{size:14}),x?"Change":"Upload"]}),e.jsxs(K,{onClick:()=>{v(null),w.current&&(w.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(en,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your organization"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"name",children:"Organization Name"}),e.jsx(de,{id:"name",type:"text",value:h,onChange:N=>d(N.target.value),onBlur:S,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"description",children:"Description"}),e.jsx(de,{id:"description",as:"textarea",value:l,onChange:N=>m(N.target.value),onBlur:S,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(Ao,{checked:y.mfa_required,onChange:()=>{z(N=>({...N,mfa_required:!N.mfa_required})),setTimeout(()=>S(),100)}})]}),((O=s==null?void 0:s.b2b_settings)==null?void 0:O.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(Ao,{checked:y.ip_restrictions,onChange:()=>{z(N=>({...N,ip_restrictions:!N.ip_restrictions})),setTimeout(()=>S(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),y.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(de,{id:"allowed_ips",as:"textarea",value:y.allowed_ips,onChange:N=>z(F=>({...F,allowed_ips:N.target.value})),onBlur:S,placeholder:`192.168.1.1
2535
- 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((D=s==null?void 0:s.b2b_settings)==null?void 0:D.workspaces_enabled)&&R.length>0&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(ja,{options:R.map(N=>({value:N.id,label:N.name})),value:y.default_workspace_id,onChange:N=>{z(F=>({...F,default_workspace_id:N})),setTimeout(()=>S(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((M=s==null?void 0:s.b2b_settings)==null?void 0:M.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:I?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this organization, there is no going back. Please be certain."})]}),e.jsx(K,{onClick:()=>{I?(j(!1),k("")):j(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:I?"Cancel":"Delete"})]}),I&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(de,{id:"confirm_name",type:"text",value:_,onChange:N=>k(N.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(K,{onClick:E,disabled:_!==(t==null?void 0:t.name)||b,style:{background:_===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:_===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:_===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:_===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:b?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})]})})},Ns=u.span`
2533
+ `,Lm=()=>{var O,D,M,Y;const{activeOrganization:t,loading:r}=Qe(),{switchOrganization:o,refetch:n}=Fe(),{workspaces:a}=yt(),{deployment:s}=xe(),{deleteOrganization:h,updateOrganization:g}=Wo(),{toast:c}=st(),[p,l]=i.useState((t==null?void 0:t.name)||""),[d,m]=i.useState((t==null?void 0:t.description)||""),[x,v]=i.useState((t==null?void 0:t.image_url)||null),w=i.useRef(null),[$,z]=i.useState(!1),[y,C]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[k,S]=i.useState(""),[b,f]=i.useState(!1),[E,j]=i.useState(!1),_=i.useCallback(async()=>{if(!(!t||$))try{z(!0),await g(t,{name:p,description:d}),c("Changes saved","info")}catch(N){const J=N.message||"Failed to save changes. Please try again.";c(J,"error")}finally{z(!1)}},[t,p,d,x,y,g,c]);i.useEffect(()=>{var N;t&&(l(t.name||""),m(t.description||""),v(t.image_url||null),C({allowed_ips:((N=t.whitelisted_ips)==null?void 0:N.join(`
2534
+ `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const I=i.useMemo(()=>a.filter(J=>J.organization.id===(t==null?void 0:t.id)),[a,t==null?void 0:t.id]),P=async()=>{if(!(!t||k!==t.name))try{f(!0),await o(""),await h(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{f(!1),S("")}};if(i.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const T=N=>{var J;if((J=N.target.files)!=null&&J[0]){const ae=N.target.files[0];if(ae.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!ae.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&URL.revokeObjectURL(x),v(URL.createObjectURL(ae)),setTimeout(()=>_(),100)}},R=()=>{w.current&&w.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:R,onMouseEnter:N=>{N.currentTarget.style.borderColor="var(--color-primary)",N.currentTarget.style.transform="scale(1.02)"},onMouseLeave:N=>{N.currentTarget.style.borderColor="var(--color-border)",N.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Nr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:w,style:{display:"none"},accept:"image/*",onChange:T,"aria-label":"Upload organization logo"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your organization"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var N;return(N=w.current)==null?void 0:N.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Nr,{size:14}),x?"Change":"Upload"]}),e.jsxs(Q,{onClick:()=>{v(null),w.current&&(w.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(en,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your organization"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"name",children:"Organization Name"}),e.jsx(de,{id:"name",type:"text",value:p,onChange:N=>l(N.target.value),onBlur:_,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"description",children:"Description"}),e.jsx(de,{id:"description",as:"textarea",value:d,onChange:N=>m(N.target.value),onBlur:_,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),((O=s==null?void 0:s.b2b_settings)==null?void 0:O.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(br,{checked:y.mfa_required,onChange:()=>{C(N=>({...N,mfa_required:!N.mfa_required})),setTimeout(()=>_(),100)}})]}),((D=s==null?void 0:s.b2b_settings)==null?void 0:D.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(br,{checked:y.ip_restrictions,onChange:()=>{C(N=>({...N,ip_restrictions:!N.ip_restrictions})),setTimeout(()=>_(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),y.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(de,{id:"allowed_ips",as:"textarea",value:y.allowed_ips,onChange:N=>C(J=>({...J,allowed_ips:N.target.value})),onBlur:_,placeholder:`192.168.1.1
2535
+ 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((M=s==null?void 0:s.b2b_settings)==null?void 0:M.workspaces_enabled)&&I.length>0&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(ja,{options:I.map(N=>({value:N.id,label:N.name})),value:y.default_workspace_id,onChange:N=>{C(J=>({...J,default_workspace_id:N})),setTimeout(()=>_(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((Y=s==null?void 0:s.b2b_settings)==null?void 0:Y.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:E?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this organization, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{E?(j(!1),S("")):j(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:E?"Cancel":"Delete"})]}),E&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(de,{id:"confirm_name",type:"text",value:k,onChange:N=>S(N.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Q,{onClick:P,disabled:k!==(t==null?void 0:t.name)||b,style:{background:k===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:k===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:k===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:k===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:b?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})]})})},Ns=u.span`
2536
2536
  background: var(--color-primary-background);
2537
2537
  color: var(--color-primary);
2538
2538
  padding: 4px 8px;
@@ -2569,7 +2569,7 @@ cursor: pointer;
2569
2569
  opacity: 0.5;
2570
2570
  cursor: not-allowed;
2571
2571
  }
2572
- `,Am=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=Qe(),a=i.useRef(null),[s,p]=i.useState(null),{data:g=[],isLoading:c,mutate:h}=We(t!=null&&t.id?`/domains/${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((I,j)=>({...I,verified:I.verified!==void 0?I.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),d=g,[l,m]=i.useState(!1),[x,v]=i.useState(null),[w,C]=i.useState(""),[$,y]=i.useState(null),z=i.useRef(null),_=i.useMemo(()=>{let f=d;if(w.trim()!==""){const I=w.toLowerCase();f=f.filter(j=>j.fqdn.toLowerCase().includes(I))}return f},[d,w]),k=async f=>{await n(f),h()},b=async f=>{v(f)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(ml,{children:[e.jsx(wt,{value:w,onChange:C,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(K,{ref:z,onClick:()=>m(!l),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),l&&e.jsx(Ls,{onClose:()=>{m(!1),h()},triggerRef:z})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),_!=null&&_.length?e.jsxs(jt,{ref:a,children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Domain"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{children:"Date Added"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:_.map(f=>e.jsxs(Ue,{children:[e.jsx(Oe,{children:f.fqdn}),e.jsx(Oe,{children:f.verified?e.jsx(Ns,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(Ns,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(ut,{size:9})," Pending Verification"]})}),e.jsx(Oe,{children:new Date(f.created_at).toLocaleDateString()}),e.jsx(Ct,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(ot,{style:{marginLeft:"auto"},open:$===f.id,openChange:I=>y(I?f.id:null),children:[e.jsx(at,{children:e.jsx(ka,{children:"•••"})}),e.jsxs(nt,{children:[!f.verified&&e.jsx(Pe,{onClick:()=>{b(f.id),y(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:"✓ Verify Domain"})}),e.jsx(Pe,{onClick:()=>{y(null),navigator.clipboard.writeText(f.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Gc,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Pe,{onClick:()=>{window.open(`https://${f.fqdn}`,"_blank"),y(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hc,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(tn,{}),e.jsx(Pe,{$destructive:!0,onClick:()=>{y(null),p(f.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(en,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),s===f.id&&e.jsx(on,{title:"Are you sure you want to delete this domain?",onConfirm:()=>k(f),onCancel:()=>p(null)}),x===f.id&&e.jsx(Ls,{domain:f,onClose:()=>v(null)})]})})]},f.id))})]}):e.jsx(it,{title:w!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},Dm=u.div`
2572
+ `,Am=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=Qe(),a=i.useRef(null),[s,h]=i.useState(null),{data:g=[],isLoading:c,mutate:p}=We(t!=null&&t.id?`/domains/${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((E,j)=>({...E,verified:E.verified!==void 0?E.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),l=g,[d,m]=i.useState(!1),[x,v]=i.useState(null),[w,$]=i.useState(""),[z,y]=i.useState(null),C=i.useRef(null),k=i.useMemo(()=>{let f=l;if(w.trim()!==""){const E=w.toLowerCase();f=f.filter(j=>j.fqdn.toLowerCase().includes(E))}return f},[l,w]),S=async f=>{await n(f),p()},b=async f=>{v(f)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(ml,{children:[e.jsx(wt,{value:w,onChange:$,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(Q,{ref:C,onClick:()=>m(!d),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),d&&e.jsx(Ls,{onClose:()=>{m(!1),p()},triggerRef:C})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),k!=null&&k.length?e.jsxs(jt,{ref:a,children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Domain"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{children:"Date Added"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:k.map(f=>e.jsxs(Ue,{children:[e.jsx(Oe,{children:f.fqdn}),e.jsx(Oe,{children:f.verified?e.jsx(Ns,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(Ns,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(ut,{size:9})," Pending Verification"]})}),e.jsx(Oe,{children:new Date(f.created_at).toLocaleDateString()}),e.jsx(Ct,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(ot,{style:{marginLeft:"auto"},open:z===f.id,openChange:E=>y(E?f.id:null),children:[e.jsx(at,{children:e.jsx(ka,{children:"•••"})}),e.jsxs(nt,{children:[!f.verified&&e.jsx(Pe,{onClick:()=>{b(f.id),y(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:"✓ Verify Domain"})}),e.jsx(Pe,{onClick:()=>{y(null),navigator.clipboard.writeText(f.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Gc,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Pe,{onClick:()=>{window.open(`https://${f.fqdn}`,"_blank"),y(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hc,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(tn,{}),e.jsx(Pe,{$destructive:!0,onClick:()=>{y(null),h(f.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(en,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),s===f.id&&e.jsx(on,{title:"Are you sure you want to delete this domain?",onConfirm:()=>S(f),onCancel:()=>h(null)}),x===f.id&&e.jsx(Ls,{domain:f,onClose:()=>v(null)})]})})]},f.id))})]}):e.jsx(it,{title:w!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},Dm=u.div`
2573
2573
  width: 40px;
2574
2574
  height: 40px;
2575
2575
  border-radius: 50%;
@@ -2581,7 +2581,7 @@ cursor: pointer;
2581
2581
  font-weight: 400;
2582
2582
  font-size: 14px;
2583
2583
  overflow: hidden;
2584
- `,Nm=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:a,removeMemberRole:s,removeMember:p}=Qe(),{session:g}=Fe(),{toast:c}=st(),[h,d]=i.useState(""),[l,m]=i.useState(!1),x=i.useRef(null),{data:v=[],isLoading:w,mutate:C}=We(t?`/api/organizations/${t.id}/members`:null,()=>(o==null?void 0:o())||[]),{data:$=[],isLoading:y}=We(t?`/api/organizations/${t.id}/roles`:null,()=>(n==null?void 0:n())||[]),z=$,_=i.useMemo(()=>h?v.filter(j=>{var O;const S=j.user;if(!S)return!1;const R=S.first_name||"",E=S.last_name||"",T=((O=S.primary_email_address)==null?void 0:O.email)||"";return`${R} ${E}`.trim().toLowerCase().includes(h.toLowerCase())||T.toLowerCase().includes(h.toLowerCase())}):v,[v,h]),k=async(j,S,R)=>{try{R?(await s(j,S),c("Role removed successfully","info")):(await a(j,S),c("Role added successfully","info")),C()}catch(E){const T=E.message||"Failed to update role. Please try again.";c(T,"error")}},b=(j="",S="")=>`${j[0]||""}${S[0]||""}`.toUpperCase(),f=(j,S)=>{var R;return((R=j.roles)==null?void 0:R.some(E=>E.id===S))||!1},I=()=>{m(!1),C(),c("Invitation sent successfully","info")};return r||w||y?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(wt,{value:h,onChange:d,placeholder:"Search members..."})}),e.jsx(K,{ref:x,onClick:()=>m(!l),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),l&&e.jsx(fl,{onClose:()=>m(!1),onSuccess:I,roles:z,triggerRef:x}),_.length===0?e.jsx(it,{title:h?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Roles"})]})}),e.jsx(_t,{children:_.map(j=>{var T,P;const S=j.roles||[],R=j.user,E=(R==null?void 0:R.id)===((T=g==null?void 0:g.active_signin)==null?void 0:T.user_id);return e.jsxs(Ue,{children:[e.jsx(gl,{children:e.jsxs("div",{children:[e.jsx(Dm,{children:R!=null&&R.profile_picture_url?e.jsx("img",{src:R.profile_picture_url,alt:`${R.first_name||""} ${R.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):b(R==null?void 0:R.first_name,R==null?void 0:R.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var D;if(!R)return"Unknown User";const O=`${R.first_name||""} ${R.last_name||""}`.trim();return O||((D=R.primary_email_address)==null?void 0:D.email)||"Unknown User"})()}),E&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(P=R==null?void 0:R.primary_email_address)==null?void 0:P.email})]})]})}),e.jsx(Oe,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(Ct,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsxs(K,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:S.length>0?S[0].name:"No role"}),e.jsx(er,{size:14})]})}),e.jsxs(nt,{children:[z.map(O=>{const D=f(j,O.id);return e.jsx(Pe,{onClick:()=>k(j,O,D),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:O.name}),D&&e.jsx(rt,{size:16,color:"var(--color-success)"})]})},O.id)}),e.jsx(tn,{}),e.jsx(Pe,{$destructive:!0,onClick:()=>p(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(en,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},Fm=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:a,resendInvitation:s}=Qe(),{toast:p}=st(),[g,c]=i.useState(!1),[h,d]=i.useState(""),l=i.useRef(null),{data:m=[],isLoading:x,mutate:v}=We(t?`/api/organizations/${t.id}/invitations`:null,()=>(o==null?void 0:o())||[]),{data:w=[],isLoading:C}=We(t?`/api/organizations/${t.id}/roles`:null,()=>(n==null?void 0:n())||[]),$=w,y=i.useMemo(()=>h?m.filter(b=>b.email.toLowerCase().includes(h.toLowerCase())):m,[m,h]),z=()=>{p("Invitation sent successfully","info"),v(),c(!1)},_=async b=>{try{await a(b),v(),p("Invitation cancelled successfully","info")}catch(f){const I=f.message||"Failed to cancel invitation. Please try again.";p(I,"error")}},k=async b=>{try{await s(b),p("Invitation resent successfully","info")}catch(f){const I=f.message||"Failed to resend invitation. Please try again.";p(I,"error")}};return r||x||C?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(wt,{value:h,onChange:d,placeholder:"Search invitations..."})}),e.jsx(K,{ref:l,onClick:()=>c(!g),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),g&&e.jsx(fl,{onClose:()=>c(!1),onSuccess:z,roles:$,triggerRef:l}),y.length===0?e.jsx(it,{title:h?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:y.map(b=>{var f;return e.jsxs(Ue,{children:[e.jsx(Oe,{children:b.email}),e.jsx(Oe,{children:((f=b.initial_organization_role)==null?void 0:f.name)||"No role"}),e.jsx(Oe,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(Ct,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsx(ka,{children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>k(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Wr,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Pe,{$destructive:!0,onClick:()=>_(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(en,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},b.id)})})]})]})},Bm=()=>{const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=Qe(),[a,s]=i.useState({isOpen:!1}),[p,g]=i.useState(null),[c,h]=i.useState(null),[d,l]=i.useState(""),[m,x]=i.useState(null),v=i.useRef(null),{data:w=[],isLoading:C,mutate:$}=We(t?`/api/organizations/${t.id}/roles`:null,()=>(o==null?void 0:o())||[]),y=i.useMemo(()=>d?w.filter(k=>k.name.toLowerCase().includes(d.toLowerCase())):w,[w,d]),z=async k=>{try{k.id?(await new Promise(b=>setTimeout(b,1e3)),g({text:"Role updated successfully",type:"success"})):(await new Promise(b=>setTimeout(b,1e3)),g({text:"Role created successfully",type:"success"})),s({isOpen:!1}),$()}catch(b){const f=(b==null?void 0:b.message)||(k.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");k.id?g({text:f,type:"error"}):g({text:f,type:"error"})}finally{setTimeout(()=>g(null),3e3)}},_=async k=>{try{await n(k),$()}catch{}finally{setTimeout(()=>g(null),3e3)}};return r||C?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[p&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:p.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:p.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[p.type==="success"?"✓":e.jsx(ut,{size:16}),p.text]}),e.jsxs(ml,{children:[e.jsx(wt,{placeholder:"Search roles",onChange:l,value:d}),e.jsxs("div",{children:[e.jsx(K,{ref:v,onClick:()=>s({isOpen:!a.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),a.isOpen&&!a.role&&e.jsx(As,{role:a.role,onClose:()=>s({isOpen:!1}),onSuccess:z,triggerRef:v})]})]}),y.length===0?e.jsx(it,{title:d?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:y.map(k=>{var b;return e.jsxs(Ue,{children:[e.jsx(Oe,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:k.name})}),e.jsx(Oe,{style:{color:"var(--color-secondary-text)"},children:k.permissions.join(", ")}),e.jsx(Ct,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ot,{open:c===k.id,openChange:f=>h(f?k.id:null),children:[e.jsx(at,{children:e.jsx(ka,{disabled:!k.organization_id,"data-role-dropdown-trigger":k.id,children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>{h(null),s({isOpen:!0,role:k})},children:"Edit Role"}),e.jsx(Pe,{$destructive:!0,onClick:()=>{h(null),x(k.id)},children:"Remove Role"})]})]}),m===k.id&&e.jsx(on,{title:"Are you sure you want to delete this role?",onConfirm:()=>_(k),onCancel:()=>x(null)}),a.isOpen&&((b=a.role)==null?void 0:b.id)===k.id&&e.jsx(As,{role:a.role,onClose:()=>{s({isOpen:!1}),h(null)},onSuccess:z})]})})]},k.id)})})]})]})},xl=()=>{const{loading:t,activeOrganization:r}=Qe(),[o,n]=i.useState("general"),[a,s]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((h,d="info")=>{s(h),g(d),setTimeout(()=>s(null),3e3)},[s]);return t?e.jsx(Ln,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):r?e.jsx(Ds,{children:e.jsx(pl.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Ln,{children:[e.jsx(Tm,{children:e.jsxs(Om,{children:[e.jsx(Pr,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(Rr,{children:[e.jsx(Kt,{size:16}),"General"]})}),e.jsx(Pr,{$isActive:o==="domains",onClick:()=>n("domains"),children:e.jsxs(Rr,{children:[e.jsx(bh,{size:16}),"Domains"]})}),e.jsx(Pr,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(Rr,{children:[e.jsx(Lo,{size:16}),"Members"]})}),e.jsx(Pr,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(Rr,{children:[e.jsx(Wr,{size:16}),"Invitations"]})}),e.jsx(Pr,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(Rr,{children:[e.jsx(Xo,{size:16}),"Roles"]})})]})}),e.jsxs(Mm,{children:[o==="general"&&e.jsx(Lm,{}),o==="domains"&&e.jsx(Am,{}),o==="members"&&e.jsx(Nm,{}),o==="invitations"&&e.jsx(Fm,{}),o==="roles"&&e.jsx(Bm,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):e.jsx(Ds,{children:e.jsx(Ln,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(Dr,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(Cl,{})]})})})},Um=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:g,showCloseButton:c})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(we.Header,{showCloseButton:c,children:a||o}),p||g||e.jsx(xl,{}),s&&e.jsx(we.Footer,{children:s})]})})}),Wm=u.div`
2584
+ `,Nm=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:a,removeMemberRole:s,removeMember:h}=Qe(),{session:g}=Fe(),{toast:c}=st(),[p,l]=i.useState(""),[d,m]=i.useState(!1),x=i.useRef(null),{data:v=[],isLoading:w,mutate:$}=We(t?`/api/organizations/${t.id}/members`:null,()=>(o==null?void 0:o())||[]),{data:z=[],isLoading:y}=We(t?`/api/organizations/${t.id}/roles`:null,()=>(n==null?void 0:n())||[]),C=z,k=i.useMemo(()=>p?v.filter(j=>{var O;const _=j.user;if(!_)return!1;const I=_.first_name||"",P=_.last_name||"",T=((O=_.primary_email_address)==null?void 0:O.email)||"";return`${I} ${P}`.trim().toLowerCase().includes(p.toLowerCase())||T.toLowerCase().includes(p.toLowerCase())}):v,[v,p]),S=async(j,_,I)=>{try{I?(await s(j,_),c("Role removed successfully","info")):(await a(j,_),c("Role added successfully","info")),$()}catch(P){const T=P.message||"Failed to update role. Please try again.";c(T,"error")}},b=(j="",_="")=>`${j[0]||""}${_[0]||""}`.toUpperCase(),f=(j,_)=>{var I;return((I=j.roles)==null?void 0:I.some(P=>P.id===_))||!1},E=()=>{m(!1),$(),c("Invitation sent successfully","info")};return r||w||y?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(wt,{value:p,onChange:l,placeholder:"Search members..."})}),e.jsx(Q,{ref:x,onClick:()=>m(!d),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),d&&e.jsx(fl,{onClose:()=>m(!1),onSuccess:E,roles:C,triggerRef:x}),k.length===0?e.jsx(it,{title:p?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Roles"})]})}),e.jsx(_t,{children:k.map(j=>{var T,R;const _=j.roles||[],I=j.user,P=(I==null?void 0:I.id)===((T=g==null?void 0:g.active_signin)==null?void 0:T.user_id);return e.jsxs(Ue,{children:[e.jsx(gl,{children:e.jsxs("div",{children:[e.jsx(Dm,{children:I!=null&&I.profile_picture_url?e.jsx("img",{src:I.profile_picture_url,alt:`${I.first_name||""} ${I.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):b(I==null?void 0:I.first_name,I==null?void 0:I.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var D;if(!I)return"Unknown User";const O=`${I.first_name||""} ${I.last_name||""}`.trim();return O||((D=I.primary_email_address)==null?void 0:D.email)||"Unknown User"})()}),P&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(R=I==null?void 0:I.primary_email_address)==null?void 0:R.email})]})]})}),e.jsx(Oe,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(Ct,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsxs(Q,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:_.length>0?_[0].name:"No role"}),e.jsx(er,{size:14})]})}),e.jsxs(nt,{children:[C.map(O=>{const D=f(j,O.id);return e.jsx(Pe,{onClick:()=>S(j,O,D),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:O.name}),D&&e.jsx(rt,{size:16,color:"var(--color-success)"})]})},O.id)}),e.jsx(tn,{}),e.jsx(Pe,{$destructive:!0,onClick:()=>h(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(en,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},Fm=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:a,resendInvitation:s}=Qe(),{toast:h}=st(),[g,c]=i.useState(!1),[p,l]=i.useState(""),d=i.useRef(null),{data:m=[],isLoading:x,mutate:v}=We(t?`/api/organizations/${t.id}/invitations`:null,()=>(o==null?void 0:o())||[]),{data:w=[],isLoading:$}=We(t?`/api/organizations/${t.id}/roles`:null,()=>(n==null?void 0:n())||[]),z=w,y=i.useMemo(()=>p?m.filter(b=>b.email.toLowerCase().includes(p.toLowerCase())):m,[m,p]),C=()=>{h("Invitation sent successfully","info"),v(),c(!1)},k=async b=>{try{await a(b),v(),h("Invitation cancelled successfully","info")}catch(f){const E=f.message||"Failed to cancel invitation. Please try again.";h(E,"error")}},S=async b=>{try{await s(b),h("Invitation resent successfully","info")}catch(f){const E=f.message||"Failed to resend invitation. Please try again.";h(E,"error")}};return r||x||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(wt,{value:p,onChange:l,placeholder:"Search invitations..."})}),e.jsx(Q,{ref:d,onClick:()=>c(!g),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),g&&e.jsx(fl,{onClose:()=>c(!1),onSuccess:C,roles:z,triggerRef:d}),y.length===0?e.jsx(it,{title:p?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:y.map(b=>{var f;return e.jsxs(Ue,{children:[e.jsx(Oe,{children:b.email}),e.jsx(Oe,{children:((f=b.initial_organization_role)==null?void 0:f.name)||"No role"}),e.jsx(Oe,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(Ct,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsx(ka,{children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>S(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Vr,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Pe,{$destructive:!0,onClick:()=>k(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(en,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},b.id)})})]})]})},Bm=()=>{var b;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=Qe(),{deployment:a}=xe(),[s,h]=i.useState({isOpen:!1}),[g,c]=i.useState(null),[p,l]=i.useState(null),[d,m]=i.useState(""),[x,v]=i.useState(null),w=i.useRef(null),{data:$=[],isLoading:z,mutate:y}=We(t?`/api/organizations/${t.id}/roles`:null,()=>(o==null?void 0:o())||[]),C=i.useMemo(()=>d?$.filter(f=>f.name.toLowerCase().includes(d.toLowerCase())):$,[$,d]),k=async f=>{try{f.id?(await new Promise(E=>setTimeout(E,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(E=>setTimeout(E,1e3)),c({text:"Role created successfully",type:"success"})),h({isOpen:!1}),y()}catch(E){const j=(E==null?void 0:E.message)||(f.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");f.id?c({text:j,type:"error"}):c({text:j,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},S=async f=>{try{await n(f),y()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||z?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[g&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:g.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:g.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[g.type==="success"?"✓":e.jsx(ut,{size:16}),g.text]}),e.jsxs(ml,{children:[e.jsx(wt,{placeholder:"Search roles",onChange:m,value:d}),((b=a==null?void 0:a.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(Q,{ref:w,onClick:()=>h({isOpen:!s.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),s.isOpen&&!s.role&&e.jsx(As,{role:s.role,onClose:()=>h({isOpen:!1}),onSuccess:k,triggerRef:w})]})]}),C.length===0?e.jsx(it,{title:d?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:C.map(f=>{var E;return e.jsxs(Ue,{children:[e.jsx(Oe,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:f.name})}),e.jsx(Oe,{style:{color:"var(--color-secondary-text)"},children:f.permissions.join(", ")}),e.jsx(Ct,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ot,{open:p===f.id,openChange:j=>l(j?f.id:null),children:[e.jsx(at,{children:e.jsx(ka,{disabled:!f.organization_id,"data-role-dropdown-trigger":f.id,children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>{l(null),h({isOpen:!0,role:f})},children:"Edit Role"}),e.jsx(Pe,{$destructive:!0,onClick:()=>{l(null),v(f.id)},children:"Remove Role"})]})]}),x===f.id&&e.jsx(on,{title:"Are you sure you want to delete this role?",onConfirm:()=>S(f),onCancel:()=>v(null)}),s.isOpen&&((E=s.role)==null?void 0:E.id)===f.id&&e.jsx(As,{role:s.role,onClose:()=>{h({isOpen:!1}),l(null)},onSuccess:k})]})})]},f.id)})})]})]})},xl=()=>{const{loading:t,activeOrganization:r}=Qe(),[o,n]=i.useState("general"),[a,s]=i.useState(null),[h,g]=i.useState("info"),c=i.useCallback((p,l="info")=>{s(p),g(l),setTimeout(()=>s(null),3e3)},[s]);return t?e.jsx(Ln,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):r?e.jsx(Ds,{children:e.jsx(pl.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Ln,{children:[e.jsx(Tm,{children:e.jsxs(Om,{children:[e.jsx(Rr,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(Ir,{children:[e.jsx(Kt,{size:16}),"General"]})}),e.jsx(Rr,{$isActive:o==="domains",onClick:()=>n("domains"),children:e.jsxs(Ir,{children:[e.jsx(bh,{size:16}),"Domains"]})}),e.jsx(Rr,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(Ir,{children:[e.jsx(Ao,{size:16}),"Members"]})}),e.jsx(Rr,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(Ir,{children:[e.jsx(Vr,{size:16}),"Invitations"]})}),e.jsx(Rr,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(Ir,{children:[e.jsx(Xo,{size:16}),"Roles"]})})]})}),e.jsxs(Mm,{children:[o==="general"&&e.jsx(Lm,{}),o==="domains"&&e.jsx(Am,{}),o==="members"&&e.jsx(Nm,{}),o==="invitations"&&e.jsx(Fm,{}),o==="roles"&&e.jsx(Bm,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):e.jsx(Ds,{children:e.jsx(Ln,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(Nr,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(Cl,{})]})})})},Um=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:h,children:g,showCloseButton:c})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(we.Header,{showCloseButton:c,children:a||o}),h||g||e.jsx(xl,{}),s&&e.jsx(we.Footer,{children:s})]})})}),Wm=u.div`
2585
2585
  display: flex;
2586
2586
  height: 100%;
2587
2587
  min-height: 400px;
@@ -2872,7 +2872,7 @@ cursor: pointer;
2872
2872
  align-items: center;
2873
2873
  justify-content: center;
2874
2874
  color: var(--color-primary);
2875
- `,_a=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var P;const[a,s]=i.useState(""),[p,g]=i.useState(""),[c,h]=i.useState(),[d,l]=i.useState(null),[m,x]=i.useState(!1),[v,w]=i.useState(!1),[C,$]=i.useState(t),y=i.useRef(null),z=i.useRef(null),{toast:_}=st(),{createWorkspace:k}=yt(),{organizationMemberships:b}=bt(),f=(P=b==null?void 0:b.find(O=>O.organization.id===C))==null?void 0:P.organization,I=O=>{if(O.target.files&&O.target.files[0]){const D=O.target.files[0];if(D.size>2*1024*1024){_("File size cannot exceed 2MB","error");return}if(!D.type.startsWith("image/")){_("Please select a valid image file","error");return}d&&URL.revokeObjectURL(d),h(D),l(URL.createObjectURL(D))}},j=()=>{var O;(O=y.current)==null||O.click()},S=O=>O.split(" ").map(D=>D[0]).join("").toUpperCase().slice(0,2)||"W",R=O=>O.trim().replace(/[<>\"'&]/g,""),E=O=>O.length>=2&&O.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(O),T=async()=>{const O=R(a),D=R(p);if(!O||!C){_("Please enter a workspace name","error");return}if(!E(O)){_("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(D.length>500){_("Description must be less than 500 characters","error");return}x(!0);try{const M=await k(C,O,c,D);r==null||r(M)}catch(M){const N=M.message||"Failed to create workspace. Please try again.";_(N,"error")}finally{x(!1)}};return i.useEffect(()=>()=>{d&&URL.revokeObjectURL(d)},[d]),i.useEffect(()=>{const O=D=>{z.current&&!z.current.contains(D.target)&&w(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]),e.jsx(le,{children:e.jsxs(Wm,{children:[e.jsxs(Vm,{children:[e.jsxs(vl,{hasImage:!!d,onClick:j,children:[d?e.jsx(Hm,{src:d,alt:"Workspace logo"}):e.jsx(qm,{children:S(a||"W")}),e.jsx(sx,{children:e.jsx(ix,{children:"Upload Logo"})})]}),e.jsx(ax,{type:"file",ref:y,onChange:I,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(Ym,{children:"Create new workspace"}),e.jsx(Zm,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(Gm,{children:[e.jsxs(Km,{children:[e.jsx(Qm,{children:"Choose your workspace name"}),e.jsx(Xm,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(Jm,{children:[e.jsxs(An,{children:[e.jsx(Dn,{children:"Organization"}),e.jsxs(cx,{ref:z,children:[e.jsxs(lx,{type:"button",onClick:()=>w(!v),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Fs,{children:f!=null&&f.image_url?e.jsx(Bs,{src:f.image_url,alt:f.name}):S((f==null?void 0:f.name)||"O").charAt(0)}),e.jsx("span",{children:(f==null?void 0:f.name)||"Select organization"})]}),e.jsx(er,{size:16,style:{color:"var(--color-secondary-text)"}})]}),v&&e.jsxs(dx,{children:[b==null?void 0:b.map(O=>e.jsxs(bl,{onClick:()=>{$(O.organization.id),w(!1)},children:[e.jsx(Fs,{children:O.organization.image_url?e.jsx(Bs,{src:O.organization.image_url,alt:O.organization.name}):S(O.organization.name).charAt(0)}),e.jsx("span",{children:O.organization.name})]},O.organization.id)),e.jsxs(ux,{onClick:()=>{w(!1),n==null||n()},children:[e.jsx(px,{children:e.jsx(Je,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(An,{children:[e.jsx(Dn,{children:"Workspace name"}),e.jsx(ex,{type:"text",value:a,onChange:O=>s(O.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(An,{children:[e.jsx(Dn,{children:"Description (optional)"}),e.jsx(tx,{value:p,onChange:O=>g(O.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(rx,{children:[o?e.jsxs(ox,{onClick:o,disabled:m,children:[e.jsx(Ur,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(nx,{onClick:T,disabled:m||!a.trim(),children:m?"Creating...":"Create"})]})]})]})})},yl=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[a,s]=i.useState(!1),[p,g]=i.useState(n),{refetch:c,organizationMemberships:h}=bt(),d=()=>{o==null||o(),r==null||r()},l=()=>{s(!0)},m=async()=>{await c(),setTimeout(()=>{if(h&&h.length>0){const x=h[h.length-1];g(x.organization.id)}s(!1)},500)};return e.jsx(le,{children:e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsx(we.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(we.Body,{style:{padding:0},children:a?e.jsx(rn,{onSuccess:m,onCancel:()=>s(!1)}):e.jsx(_a,{organizationId:p||n,onSuccess:d,onCancel:r,onCreateOrganization:l})})})})})})},hx=u.div`
2875
+ `,_a=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var R;const[a,s]=i.useState(""),[h,g]=i.useState(""),[c,p]=i.useState(),[l,d]=i.useState(null),[m,x]=i.useState(!1),[v,w]=i.useState(!1),[$,z]=i.useState(t),y=i.useRef(null),C=i.useRef(null),{toast:k}=st(),{createWorkspace:S}=yt(),{organizationMemberships:b}=bt(),f=(R=b==null?void 0:b.find(O=>O.organization.id===$))==null?void 0:R.organization,E=O=>{if(O.target.files&&O.target.files[0]){const D=O.target.files[0];if(D.size>2*1024*1024){k("File size cannot exceed 2MB","error");return}if(!D.type.startsWith("image/")){k("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),p(D),d(URL.createObjectURL(D))}},j=()=>{var O;(O=y.current)==null||O.click()},_=O=>O.split(" ").map(D=>D[0]).join("").toUpperCase().slice(0,2)||"W",I=O=>O.trim().replace(/[<>\"'&]/g,""),P=O=>O.length>=2&&O.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(O),T=async()=>{const O=I(a),D=I(h);if(!O||!$){k("Please enter a workspace name","error");return}if(!P(O)){k("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(D.length>500){k("Description must be less than 500 characters","error");return}x(!0);try{const M=await S($,O,c,D);r==null||r(M)}catch(M){const Y=M.message||"Failed to create workspace. Please try again.";k(Y,"error")}finally{x(!1)}};return i.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]),i.useEffect(()=>{const O=D=>{C.current&&!C.current.contains(D.target)&&w(!1)};return document.addEventListener("mousedown",O),()=>document.removeEventListener("mousedown",O)},[]),e.jsx(le,{children:e.jsxs(Wm,{children:[e.jsxs(Vm,{children:[e.jsxs(vl,{hasImage:!!l,onClick:j,children:[l?e.jsx(Hm,{src:l,alt:"Workspace logo"}):e.jsx(qm,{children:_(a||"W")}),e.jsx(sx,{children:e.jsx(ix,{children:"Upload Logo"})})]}),e.jsx(ax,{type:"file",ref:y,onChange:E,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(Ym,{children:"Create new workspace"}),e.jsx(Zm,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(Gm,{children:[e.jsxs(Km,{children:[e.jsx(Qm,{children:"Choose your workspace name"}),e.jsx(Xm,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(Jm,{children:[e.jsxs(An,{children:[e.jsx(Dn,{children:"Organization"}),e.jsxs(cx,{ref:C,children:[e.jsxs(lx,{type:"button",onClick:()=>w(!v),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Fs,{children:f!=null&&f.image_url?e.jsx(Bs,{src:f.image_url,alt:f.name}):_((f==null?void 0:f.name)||"O").charAt(0)}),e.jsx("span",{children:(f==null?void 0:f.name)||"Select organization"})]}),e.jsx(er,{size:16,style:{color:"var(--color-secondary-text)"}})]}),v&&e.jsxs(dx,{children:[b==null?void 0:b.map(O=>e.jsxs(bl,{onClick:()=>{z(O.organization.id),w(!1)},children:[e.jsx(Fs,{children:O.organization.image_url?e.jsx(Bs,{src:O.organization.image_url,alt:O.organization.name}):_(O.organization.name).charAt(0)}),e.jsx("span",{children:O.organization.name})]},O.organization.id)),e.jsxs(ux,{onClick:()=>{w(!1),n==null||n()},children:[e.jsx(px,{children:e.jsx(Je,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(An,{children:[e.jsx(Dn,{children:"Workspace name"}),e.jsx(ex,{type:"text",value:a,onChange:O=>s(O.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(An,{children:[e.jsx(Dn,{children:"Description (optional)"}),e.jsx(tx,{value:h,onChange:O=>g(O.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(rx,{children:[o?e.jsxs(ox,{onClick:o,disabled:m,children:[e.jsx(Wr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(nx,{onClick:T,disabled:m||!a.trim(),children:m?"Creating...":"Create"})]})]})]})})},yl=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[a,s]=i.useState(!1),[h,g]=i.useState(n),{refetch:c,organizationMemberships:p}=bt(),l=()=>{o==null||o(),r==null||r()},d=()=>{s(!0)},m=async()=>{await c(),setTimeout(()=>{if(p&&p.length>0){const x=p[p.length-1];g(x.organization.id)}s(!1)},500)};return e.jsx(le,{children:e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsx(we.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(we.Body,{style:{padding:0},children:a?e.jsx(rn,{onSuccess:m,onCancel:()=>s(!1)}):e.jsx(_a,{organizationId:h||n,onSuccess:l,onCancel:r,onCreateOrganization:d})})})})})})},hx=u.div`
2876
2876
  position: fixed;
2877
2877
  width: 360px;
2878
2878
  max-width: calc(100vw - 48px);
@@ -2921,7 +2921,7 @@ cursor: pointer;
2921
2921
  color: var(--color-foreground);
2922
2922
  background: var(--color-input-background);
2923
2923
  }
2924
- `,bx=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:a})=>{const s=i.useRef(null),[p,g]=i.useState(""),[c,h]=i.useState(null),[d,l]=i.useState(!1),[m,x]=i.useState(!1),[v,w]=i.useState({top:0,left:0}),{toast:C}=st(),$=o.map(_=>({value:_.id,label:_.name}));i.useEffect(()=>{x(!0);const _=setTimeout(()=>{if(!s.current||!(a!=null&&a.current))return;const I=a.current;if(I){const j=I.getBoundingClientRect(),S=360,R=250,E=8;let T=0,P=0;const O=window.innerHeight-j.bottom,D=j.top;O>=R+E?(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):D>=R+E?(T=j.top-R-E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left)),w({top:T,left:P})}},10),k=I=>{s.current&&!s.current.contains(I.target)&&(t==null||t())},b=I=>{I.key==="Escape"&&(t==null||t())},f=setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",b)},100);return()=>{clearTimeout(_),clearTimeout(f),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",b)}},[t,a]);const y=_=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_),z=async()=>{const _=p.trim().toLowerCase();if(!(!_||!c)){if(!y(_)){C("Please enter a valid email address","error");return}if(_.length>320){C("Email address is too long","error");return}l(!0);try{await n(_,c.id),r==null||r()}catch(k){const b=k.message||"Failed to send invitation. Please try again.";C(b,"error")}finally{l(!1)}}};return m?e.jsxs(hx,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(fx,{children:[e.jsx(gx,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(vx,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(mx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Email Address"}),e.jsx(de,{type:"email",placeholder:"colleague@company.com",value:p,onChange:_=>g(_.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Role"}),e.jsx(ja,{options:$,value:c==null?void 0:c.id,onChange:_=>h(o.find(k=>k.id===_)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(xx,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!p||!c||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},yx=u.div`
2924
+ `,bx=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:a})=>{const s=i.useRef(null),[h,g]=i.useState(""),[c,p]=i.useState(null),[l,d]=i.useState(!1),[m,x]=i.useState(!1),[v,w]=i.useState({top:0,left:0}),{toast:$}=st(),z=o.map(k=>({value:k.id,label:k.name}));i.useEffect(()=>{x(!0);const k=setTimeout(()=>{if(!s.current||!(a!=null&&a.current))return;const E=a.current;if(E){const j=E.getBoundingClientRect(),_=360,I=250,P=8;let T=0,R=0;const O=window.innerHeight-j.bottom,D=j.top;O>=I+P?(T=j.bottom+P,R=j.right-_,R<P&&(R=j.left,R+_>window.innerWidth-P&&(R=(window.innerWidth-_)/2))):D>=I+P?(T=j.top-I-P,R=j.right-_,R<P&&(R=j.left,R+_>window.innerWidth-P&&(R=(window.innerWidth-_)/2))):(T=j.bottom+P,R=j.right-_,R<P&&(R=j.left)),w({top:T,left:R})}},10),S=E=>{s.current&&!s.current.contains(E.target)&&(t==null||t())},b=E=>{E.key==="Escape"&&(t==null||t())},f=setTimeout(()=>{document.addEventListener("mousedown",S),document.addEventListener("keydown",b)},100);return()=>{clearTimeout(k),clearTimeout(f),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",b)}},[t,a]);const y=k=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(k),C=async()=>{const k=h.trim().toLowerCase();if(!(!k||!c)){if(!y(k)){$("Please enter a valid email address","error");return}if(k.length>320){$("Email address is too long","error");return}d(!0);try{await n(k,c.id),r==null||r()}catch(S){const b=S.message||"Failed to send invitation. Please try again.";$(b,"error")}finally{d(!1)}}};return m?e.jsxs(hx,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(fx,{children:[e.jsx(gx,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(vx,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(mx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Email Address"}),e.jsx(de,{type:"email",placeholder:"colleague@company.com",value:h,onChange:k=>g(k.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Role"}),e.jsx(ja,{options:z,value:c==null?void 0:c.id,onChange:k=>p(o.find(S=>S.id===k)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(xx,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:C,disabled:!h||!c||l,style:{width:"auto"},children:l?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},yx=u.div`
2925
2925
  position: fixed;
2926
2926
  width: 360px;
2927
2927
  max-width: calc(100vw - 48px);
@@ -2970,7 +2970,7 @@ cursor: pointer;
2970
2970
  color: var(--color-foreground);
2971
2971
  background: var(--color-input-background);
2972
2972
  }
2973
- `,Us=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var _;const a=i.useRef(null),[s,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]),[h,d]=i.useState(!1),{deployment:l}=ve(),[m,x]=i.useState(!1),[v,w]=i.useState({top:0,left:0}),{toast:C}=st(),$=!!o,y=(((_=l==null?void 0:l.b2b_settings)==null?void 0:_.workspace_permissions)||[]).map(k=>({value:k,label:k}));i.useEffect(()=>{x(!0);const k=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const j=n.current;if(j){const S=j.getBoundingClientRect(),R=360,E=250,T=8;let P=0,O=0;const D=window.innerHeight-S.bottom,M=S.top;D>=E+T?(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):M>=E+T?(P=S.top-E-T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left)),w({top:P,left:O})}},10),b=j=>{a.current&&!a.current.contains(j.target)&&(t==null||t())},f=j=>{j.key==="Escape"&&(t==null||t())},I=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",f)},100);return()=>{clearTimeout(k),clearTimeout(I),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,n]);const z=async()=>{if(s.trim()){d(!0);try{const k={id:o==null?void 0:o.id,name:s.trim(),permissions:g};r==null||r(k)}catch(k){const b=k.message||"Failed to save role. Please try again.";C(b,"error")}finally{d(!1)}}};return m?e.jsxs(yx,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),children:[e.jsxs(wx,{children:[e.jsx(jx,{children:$?"Edit Role":"Add Role"}),e.jsx(Cx,{onClick:t,children:e.jsx(Ke,{size:16})})]}),e.jsx(kx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Role Name"}),e.jsx(de,{type:"text",value:s,onChange:k=>p(k.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Permissions"}),e.jsx(nl,{options:y,value:g,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(_x,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!s.trim()||h,style:{width:"auto"},children:h?"Saving...":$?"Update":"Create"})]})]}):null},kr=i.createContext(void 0),It=()=>{const t=i.useContext(kr);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},Sx=u.div`
2973
+ `,Us=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var k;const a=i.useRef(null),[s,h]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]),[p,l]=i.useState(!1),{deployment:d}=xe(),[m,x]=i.useState(!1),[v,w]=i.useState({top:0,left:0}),{toast:$}=st(),z=!!o,y=(((k=d==null?void 0:d.b2b_settings)==null?void 0:k.workspace_permissions)||[]).map(S=>({value:S,label:S}));i.useEffect(()=>{x(!0);const S=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const j=n.current;if(j){const _=j.getBoundingClientRect(),I=360,P=250,T=8;let R=0,O=0;const D=window.innerHeight-_.bottom,M=_.top;D>=P+T?(R=_.bottom+T,O=_.right-I,O<T&&(O=_.left,O+I>window.innerWidth-T&&(O=(window.innerWidth-I)/2))):M>=P+T?(R=_.top-P-T,O=_.right-I,O<T&&(O=_.left,O+I>window.innerWidth-T&&(O=(window.innerWidth-I)/2))):(R=_.bottom+T,O=_.right-I,O<T&&(O=_.left)),w({top:R,left:O})}},10),b=j=>{a.current&&!a.current.contains(j.target)&&(t==null||t())},f=j=>{j.key==="Escape"&&(t==null||t())},E=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",f)},100);return()=>{clearTimeout(S),clearTimeout(E),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,n]);const C=async()=>{if(s.trim()){l(!0);try{const S={id:o==null?void 0:o.id,name:s.trim(),permissions:g};r==null||r(S)}catch(S){const b=S.message||"Failed to save role. Please try again.";$(b,"error")}finally{l(!1)}}};return m?e.jsxs(yx,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),children:[e.jsxs(wx,{children:[e.jsx(jx,{children:z?"Edit Role":"Add Role"}),e.jsx(Cx,{onClick:t,children:e.jsx(Ke,{size:16})})]}),e.jsx(kx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Role Name"}),e.jsx(de,{type:"text",value:s,onChange:S=>h(S.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Permissions"}),e.jsx(nl,{options:y,value:g,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(_x,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:C,disabled:!s.trim()||p,style:{width:"auto"},children:p?"Saving...":z?"Update":"Create"})]})]}):null},_r=i.createContext(void 0),It=()=>{const t=i.useContext(_r);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},Sx=u.div`
2974
2974
  * {
2975
2975
  box-sizing: border-box;
2976
2976
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -3025,7 +3025,7 @@ cursor: pointer;
3025
3025
  &::-webkit-scrollbar {
3026
3026
  display: none;
3027
3027
  }
3028
- `,uo=u.button`
3028
+ `,po=u.button`
3029
3029
  padding: 12px 12px;
3030
3030
  border: none;
3031
3031
  background: none;
@@ -3053,7 +3053,7 @@ cursor: pointer;
3053
3053
  opacity: ${t=>t.$isActive?1:0};
3054
3054
  transition: opacity 0.15s ease;
3055
3055
  }
3056
- `,po=u.span`
3056
+ `,ho=u.span`
3057
3057
  display: inline-flex;
3058
3058
  align-items: center;
3059
3059
  gap: 6px;
@@ -3136,7 +3136,11 @@ cursor: pointer;
3136
3136
  opacity: 0.5;
3137
3137
  cursor: not-allowed;
3138
3138
  }
3139
- `,Ax=()=>{const{activeWorkspace:t,loading:r,getRoles:o}=Pt(),{workspaces:n}=yt(),{client:a}=De(),s=n==null?void 0:n.find(E=>E.id===(t==null?void 0:t.id)),[p,g]=i.useState(!0),[c,h]=i.useState(!0),[d,l]=i.useState(""),[m,x]=i.useState(""),[v,w]=i.useState([]),[C,$]=i.useState([]),[y,z]=i.useState(!1),_=i.useRef(null),k=i.useCallback(async()=>{if(!t||!s)return[];try{return(await V(await a(`/organizations/${s.organization.id}/invitations`,{method:"GET"}))).data.filter(P=>P.workspace_id===t.id)}catch{return[]}},[a,t,s]),b=i.useCallback(async(E,T)=>{if(!t||!s)return;const O=(await V(await a(`/organizations/${s.organization.id}/roles`,{method:"GET"}))).data,D=O.find(N=>!N.organization_id)||O[0];return(await V(await a(`/organizations/${s.organization.id}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:E,role_id:D==null?void 0:D.id,workspace_id:t.id,workspace_role_id:T})}))).data},[a,t,s]),f=i.useCallback(async E=>!t||!s?void 0:(await V(await a(`/organizations/${s.organization.id}/invitations/${E}/remove`,{method:"POST"}))).data,[a,t,s]);i.useEffect(()=>{if(!t)return;(async()=>{g(!0),h(!0);try{const[T,P]=await Promise.all([o(),k()]);$(T),w(P)}catch{}finally{g(!1),h(!1)}})()},[t==null?void 0:t.id]);const I=async E=>{try{await f(E.id);const T=await k();w(T)}catch{}},j=async E=>{var T;try{await f(E.id),await b(E.email,E.workspace_role_id||((T=E.initial_workspace_role)==null?void 0:T.id)||E.role_id);const P=await k();w(P),x("Invitation resent successfully"),setTimeout(()=>x(""),3e3)}catch{}},S=async()=>{z(!1);const E=await k();w(E),x("Invitation sent successfully"),setTimeout(()=>x(""),3e3)},R=i.useMemo(()=>d?v.filter(E=>(E.email||"").toLowerCase().includes(d.toLowerCase())):v,[v,d]);return r||p||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[m&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 16px",background:"var(--color-success-background)",color:"var(--color-success)",borderRadius:"6px",fontSize:"14px"},children:["✓ ",m]}),e.jsxs(Ca,{children:[e.jsx(wt,{value:d,onChange:l,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(K,{ref:_,onClick:()=>z(!y),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),y&&e.jsx(bx,{onClose:()=>z(!1),onSuccess:S,roles:C,createInvitation:b,triggerRef:_})]})]}),e.jsx("div",{children:R.length===0?e.jsx(it,{title:d?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsx("div",{style:{borderTop:"1px solid var(--color-border)"},children:R.map(E=>{var T,P,O;return e.jsxs(Px,{children:[e.jsx(Rx,{children:e.jsxs(Tx,{children:[e.jsx(Ox,{children:E.email}),e.jsx(Mx,{children:((T=E.initial_workspace_role)==null?void 0:T.name)||((P=E.initial_organization_role)==null?void 0:P.name)||((O=E.role)==null?void 0:O.name)})]})}),e.jsx(Lx,{children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsx(wl,{children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>j(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Wr,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Pe,{$destructive:!0,onClick:()=>I(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jo,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})]},E.id)})})})]})},Dx=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:a,addMemberRole:s,removeMemberRole:p}=Pt(),{session:g}=Fe(),{toast:c}=i.useContext(kr)||{},[h,d]=i.useState(""),{data:l=[],isLoading:m,mutate:x}=We(t?`/api/workspaces/${t.id}/members`:null,()=>o()||[]),{data:v=[],isLoading:w}=We(t?`/api/workspaces/${t.id}/roles`:null,()=>n()||[]),C=v,$=i.useMemo(()=>h?l.filter(b=>{var E;const f=b.public_user_data;if(!f)return!1;const I=f.first_name||"",j=f.last_name||"",S=((E=f.primary_email_address)==null?void 0:E.email)||"";return`${I} ${j}`.trim().toLowerCase().includes(h.toLowerCase())||S.toLowerCase().includes(h.toLowerCase())}):l,[l,h]),y=async b=>{try{await a(b),c==null||c("Member removed successfully","info"),x()}catch{c==null||c("Failed to remove member","error")}},z=async(b,f,I)=>{try{I?(await p(b,f),c==null||c("Role removed successfully","info")):(await s(b,f),c==null||c("Role added successfully","info")),x()}catch{c==null||c("Failed to toggle role","error"),c==null||c("Failed to update role","error")}},_=(b="",f="")=>`${b[0]||""}${f[0]||""}`.toUpperCase(),k=(b,f)=>{var I;return((I=b.roles)==null?void 0:I.some(j=>j.id===f))||!1};return r||m||w?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Ca,{children:e.jsx(wt,{value:h,onChange:d,placeholder:"Search members..."})}),$.length===0?e.jsx(it,{title:h?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Role"})]})}),e.jsx(_t,{children:$.map(b=>{var S,R;const f=b.public_user_data,I=b.roles||[],j=(f==null?void 0:f.id)===((S=g==null?void 0:g.active_signin)==null?void 0:S.user_id);return e.jsxs(Ue,{children:[e.jsx(gl,{children:e.jsxs("div",{children:[e.jsx(Ix,{children:f&&f.profile_picture_url?e.jsx("img",{src:f.profile_picture_url,alt:`${f.first_name||""} ${f.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):_(f==null?void 0:f.first_name,f==null?void 0:f.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var T;if(!f)return"Unknown User";const E=`${f.first_name||""} ${f.last_name||""}`.trim();return E||((T=f.primary_email_address)==null?void 0:T.email)||"Unknown User"})()}),j&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(R=f==null?void 0:f.primary_email_address)==null?void 0:R.email})]})]})}),e.jsx(Oe,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(Ct,{children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsxs(K,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:I.length>0?I[0].name:"No role"}),e.jsx(er,{size:14})]})}),e.jsxs(nt,{children:[C.map(E=>{const T=k(b,E.id);return e.jsx(Pe,{onClick:()=>z(b.id,E.id,T),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:E.name}),T&&e.jsx(rt,{size:16,color:"var(--color-success)"})]})},E.id)}),e.jsx(tn,{}),e.jsx(Pe,{$destructive:!0,onClick:()=>y(b.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jo,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},b.id)})})]})]})},Nx=()=>{const{activeWorkspace:t,loading:r,updateWorkspace:o}=Pt(),{deleteWorkspace:n}=yt(),{toast:a}=i.useContext(kr)||{},[s,p]=i.useState((t==null?void 0:t.name)||""),[g,c]=i.useState((t==null?void 0:t.description)||""),[h,d]=i.useState(null),[l,m]=i.useState((t==null?void 0:t.image_url)||null),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState(""),[z,_]=i.useState(!1),[k,b]=i.useState(!1),f=i.useRef(null),I=i.useRef(null);if(i.useEffect(()=>{t&&(p(t.name||""),c(t.description||""),m(t.image_url||null))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const j=N=>{var F;if((F=N.target.files)!=null&&F[0]){const J=N.target.files[0];d(J),m(URL.createObjectURL(J)),setTimeout(()=>R(),100)}},S=()=>{f.current&&f.current.click()},R=i.useCallback(async()=>{if(!(!t||w))try{C(!0);const N={};h&&(N.image=h,d(null)),s!==t.name&&(N.name=s),g!==t.description&&(N.description=g),Object.keys(N).length>0&&(await o(N),v(!0),setTimeout(()=>v(!1),3e3))}catch{a==null||a("Failed to auto-save workspace","error")}finally{C(!1)}},[t,o,s,g,h,w]),E=i.useCallback(()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{R()},1e3)},[R]),T=N=>{p(N.target.value),E()},P=N=>{c(N.target.value),E()},O=()=>{I.current&&clearTimeout(I.current),R()},D=()=>{I.current&&clearTimeout(I.current),R()},M=async()=>{if(!(!t||$!==t.name))try{_(!0),await n(t),a==null||a("Workspace deleted successfully","info")}catch(N){a==null||a(N.message||"Failed to delete workspace","error")}finally{_(!1),y(""),b(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:l?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:S,onMouseEnter:N=>{N.currentTarget.style.borderColor="var(--color-primary)",N.currentTarget.style.transform="scale(1.02)"},onMouseLeave:N=>{N.currentTarget.style.borderColor="var(--color-border)",N.currentTarget.style.transform="scale(1)"},children:[l?e.jsx("img",{src:l,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Dr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:f,style:{display:"none"},accept:"image/*",onChange:j})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(K,{onClick:()=>{var N;return(N=f.current)==null?void 0:N.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Dr,{size:14}),l?"Change":"Upload"]}),e.jsxs(K,{onClick:()=>{m(null),d(null),f.current&&(f.current.value=""),setTimeout(()=>R(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jo,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"name",children:"Workspace Name"}),e.jsx(de,{id:"name",type:"text",value:s,onChange:T,onBlur:O,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"description",children:"Description"}),e.jsx(de,{id:"description",as:"textarea",value:g,onChange:P,onBlur:D,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:k?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(K,{onClick:()=>{k?(b(!1),y("")):b(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:k?"Cancel":"Delete"})]}),k&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(de,{id:"confirm_workspace_name",type:"text",value:$,onChange:N=>y(N.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(K,{onClick:M,disabled:$!==(t==null?void 0:t.name)||z,style:{background:$===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:$===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:$===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:$===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:z?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]}),x&&e.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"var(--color-success-background)",color:"var(--color-success)",padding:"var(--space-sm) var(--space-lg)",borderRadius:"var(--radius-lg)",boxShadow:"0 4px 12px var(--color-shadow)",display:"flex",alignItems:"center",gap:"var(--space-xs)",fontSize:"var(--font-xs)",fontWeight:500,zIndex:1e3,animation:"slideUp 0.3s ease-out"},children:"✓ Changes saved automatically"}),e.jsx("style",{children:`
3139
+ `,Ax=()=>{const{activeWorkspace:t,loading:r,getRoles:o}=Pt(),{workspaces:n}=yt(),{client:a}=De(),s=n==null?void 0:n.find(P=>P.id===(t==null?void 0:t.id)),[h,g]=i.useState(!0),[c,p]=i.useState(!0),[l,d]=i.useState(""),[m,x]=i.useState(""),[v,w]=i.useState([]),[$,z]=i.useState([]),[y,C]=i.useState(!1),k=i.useRef(null),S=i.useCallback(async()=>{if(!t||!s)return[];try{return(await V(await a(`/organizations/${s.organization.id}/invitations`,{method:"GET"}))).data.filter(R=>R.workspace_id===t.id)}catch{return[]}},[a,t,s]),b=i.useCallback(async(P,T)=>{if(!t||!s)return;const O=(await V(await a(`/organizations/${s.organization.id}/roles`,{method:"GET"}))).data,D=O.find(Y=>!Y.organization_id)||O[0];return(await V(await a(`/organizations/${s.organization.id}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:P,role_id:D==null?void 0:D.id,workspace_id:t.id,workspace_role_id:T})}))).data},[a,t,s]),f=i.useCallback(async P=>!t||!s?void 0:(await V(await a(`/organizations/${s.organization.id}/invitations/${P}/remove`,{method:"POST"}))).data,[a,t,s]);i.useEffect(()=>{if(!t)return;(async()=>{g(!0),p(!0);try{const[T,R]=await Promise.all([o(),S()]);z(T),w(R)}catch{}finally{g(!1),p(!1)}})()},[t==null?void 0:t.id]);const E=async P=>{try{await f(P.id);const T=await S();w(T)}catch{}},j=async P=>{var T;try{await f(P.id),await b(P.email,P.workspace_role_id||((T=P.initial_workspace_role)==null?void 0:T.id)||P.role_id);const R=await S();w(R),x("Invitation resent successfully"),setTimeout(()=>x(""),3e3)}catch{}},_=async()=>{C(!1);const P=await S();w(P),x("Invitation sent successfully"),setTimeout(()=>x(""),3e3)},I=i.useMemo(()=>l?v.filter(P=>(P.email||"").toLowerCase().includes(l.toLowerCase())):v,[v,l]);return r||h||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[m&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 16px",background:"var(--color-success-background)",color:"var(--color-success)",borderRadius:"6px",fontSize:"14px"},children:["✓ ",m]}),e.jsxs(Ca,{children:[e.jsx(wt,{value:l,onChange:d,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(Q,{ref:k,onClick:()=>C(!y),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),y&&e.jsx(bx,{onClose:()=>C(!1),onSuccess:_,roles:$,createInvitation:b,triggerRef:k})]})]}),e.jsx("div",{children:I.length===0?e.jsx(it,{title:l?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsx("div",{style:{borderTop:"1px solid var(--color-border)"},children:I.map(P=>{var T,R,O;return e.jsxs(Px,{children:[e.jsx(Rx,{children:e.jsxs(Tx,{children:[e.jsx(Ox,{children:P.email}),e.jsx(Mx,{children:((T=P.initial_workspace_role)==null?void 0:T.name)||((R=P.initial_organization_role)==null?void 0:R.name)||((O=P.role)==null?void 0:O.name)})]})}),e.jsx(Lx,{children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsx(wl,{children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>j(P),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Vr,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Pe,{$destructive:!0,onClick:()=>E(P),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jo,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})]},P.id)})})})]})},Dx=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:a,addMemberRole:s,removeMemberRole:h}=Pt(),{session:g}=Fe(),{toast:c}=i.useContext(_r)||{},[p,l]=i.useState(""),{data:d=[],isLoading:m,mutate:x}=We(t?`/api/workspaces/${t.id}/members`:null,()=>o()||[]),{data:v=[],isLoading:w}=We(t?`/api/workspaces/${t.id}/roles`:null,()=>n()||[]),$=v,z=i.useMemo(()=>p?d.filter(b=>{var P;const f=b.public_user_data;if(!f)return!1;const E=f.first_name||"",j=f.last_name||"",_=((P=f.primary_email_address)==null?void 0:P.email)||"";return`${E} ${j}`.trim().toLowerCase().includes(p.toLowerCase())||_.toLowerCase().includes(p.toLowerCase())}):d,[d,p]),y=async b=>{try{await a(b),c==null||c("Member removed successfully","info"),x()}catch{c==null||c("Failed to remove member","error")}},C=async(b,f,E)=>{try{E?(await h(b,f),c==null||c("Role removed successfully","info")):(await s(b,f),c==null||c("Role added successfully","info")),x()}catch{c==null||c("Failed to toggle role","error"),c==null||c("Failed to update role","error")}},k=(b="",f="")=>`${b[0]||""}${f[0]||""}`.toUpperCase(),S=(b,f)=>{var E;return((E=b.roles)==null?void 0:E.some(j=>j.id===f))||!1};return r||m||w?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Ca,{children:e.jsx(wt,{value:p,onChange:l,placeholder:"Search members..."})}),z.length===0?e.jsx(it,{title:p?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Role"})]})}),e.jsx(_t,{children:z.map(b=>{var _,I;const f=b.public_user_data,E=b.roles||[],j=(f==null?void 0:f.id)===((_=g==null?void 0:g.active_signin)==null?void 0:_.user_id);return e.jsxs(Ue,{children:[e.jsx(gl,{children:e.jsxs("div",{children:[e.jsx(Ix,{children:f&&f.profile_picture_url?e.jsx("img",{src:f.profile_picture_url,alt:`${f.first_name||""} ${f.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):k(f==null?void 0:f.first_name,f==null?void 0:f.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var T;if(!f)return"Unknown User";const P=`${f.first_name||""} ${f.last_name||""}`.trim();return P||((T=f.primary_email_address)==null?void 0:T.email)||"Unknown User"})()}),j&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(I=f==null?void 0:f.primary_email_address)==null?void 0:I.email})]})]})}),e.jsx(Oe,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(Ct,{children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsxs(Q,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:E.length>0?E[0].name:"No role"}),e.jsx(er,{size:14})]})}),e.jsxs(nt,{children:[$.map(P=>{const T=S(b,P.id);return e.jsx(Pe,{onClick:()=>C(b.id,P.id,T),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:P.name}),T&&e.jsx(rt,{size:16,color:"var(--color-success)"})]})},P.id)}),e.jsx(tn,{}),e.jsx(Pe,{$destructive:!0,onClick:()=>y(b.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jo,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},b.id)})})]})]})},Nx=()=>{var ae,ee;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Pt(),{deleteWorkspace:n}=yt(),{deployment:a}=xe(),{toast:s}=i.useContext(_r)||{},[h,g]=i.useState((t==null?void 0:t.name)||""),[c,p]=i.useState((t==null?void 0:t.description)||""),[l,d]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m,x]=i.useState(null),[v,w]=i.useState((t==null?void 0:t.image_url)||null),[$,z]=i.useState(!1),[y,C]=i.useState(!1),[k,S]=i.useState(""),[b,f]=i.useState(!1),[E,j]=i.useState(!1),_=i.useRef(null),I=i.useRef(null);if(i.useEffect(()=>{var F;t&&(g(t.name||""),p(t.description||""),w(t.image_url||null),d({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((F=t.whitelisted_ips)==null?void 0:F.join(`
3140
+ `))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const P=F=>{var U;if((U=F.target.files)!=null&&U[0]){const G=F.target.files[0];x(G),w(URL.createObjectURL(G)),setTimeout(()=>R(),100)}},T=()=>{_.current&&_.current.click()},R=i.useCallback(async()=>{if(!(!t||y))try{C(!0);const F={};m&&(F.image=m,x(null)),h!==t.name&&(F.name=h),c!==t.description&&(F.description=c),l.mfa_required!==t.enforce_2fa&&(F.enforce_2fa=l.mfa_required),l.ip_restrictions!==t.enable_ip_restriction&&(F.enable_ip_restriction=l.ip_restrictions);const U=(t.whitelisted_ips||[]).join(`
3141
+ `);l.allowed_ips!==U&&(F.whitelisted_ips=l.allowed_ips.split(`
3142
+ `).map(G=>G.trim()).filter(G=>G!=="")),Object.keys(F).length>0&&(await o(F),z(!0),setTimeout(()=>z(!1),3e3))}catch{s==null||s("Failed to auto-save workspace","error")}finally{C(!1)}},[t,o,h,c,m,l,y]),O=i.useCallback(()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{R()},1e3)},[R]),D=F=>{g(F.target.value),O()},M=F=>{p(F.target.value),O()},Y=()=>{I.current&&clearTimeout(I.current),R()},N=()=>{I.current&&clearTimeout(I.current),R()},J=async()=>{if(!(!t||k!==t.name))try{f(!0),await n(t),s==null||s("Workspace deleted successfully","info")}catch(F){s==null||s(F.message||"Failed to delete workspace","error")}finally{f(!1),S(""),j(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:v?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:T,onMouseEnter:F=>{F.currentTarget.style.borderColor="var(--color-primary)",F.currentTarget.style.transform="scale(1.02)"},onMouseLeave:F=>{F.currentTarget.style.borderColor="var(--color-border)",F.currentTarget.style.transform="scale(1)"},children:[v?e.jsx("img",{src:v,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Nr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:_,style:{display:"none"},accept:"image/*",onChange:P})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var F;return(F=_.current)==null?void 0:F.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Nr,{size:14}),v?"Change":"Upload"]}),e.jsxs(Q,{onClick:()=>{w(null),x(null),_.current&&(_.current.value=""),setTimeout(()=>R(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jo,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"name",children:"Workspace Name"}),e.jsx(de,{id:"name",type:"text",value:h,onChange:D,onBlur:Y,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"description",children:"Description"}),e.jsx(de,{id:"description",as:"textarea",value:c,onChange:M,onBlur:N,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]}),((ae=a==null?void 0:a.b2b_settings)==null?void 0:ae.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(br,{checked:l.mfa_required,onChange:()=>{d(F=>({...F,mfa_required:!F.mfa_required})),setTimeout(()=>R(),100)}})]}),((ee=a==null?void 0:a.b2b_settings)==null?void 0:ee.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(br,{checked:l.ip_restrictions,onChange:()=>{d(F=>({...F,ip_restrictions:!F.ip_restrictions})),setTimeout(()=>R(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),l.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(de,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:F=>d(U=>({...U,allowed_ips:F.target.value})),onBlur:R,placeholder:`192.168.1.1
3143
+ 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:E?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{E?(j(!1),S("")):j(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:E?"Cancel":"Delete"})]}),E&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(de,{id:"confirm_workspace_name",type:"text",value:k,onChange:F=>S(F.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Q,{onClick:J,disabled:k!==(t==null?void 0:t.name)||b,style:{background:k===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:k===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:k===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:k===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:b?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]}),$&&e.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"var(--color-success-background)",color:"var(--color-success)",padding:"var(--space-sm) var(--space-lg)",borderRadius:"var(--radius-lg)",boxShadow:"0 4px 12px var(--color-shadow)",display:"flex",alignItems:"center",gap:"var(--space-xs)",fontSize:"var(--font-xs)",fontWeight:500,zIndex:1e3,animation:"slideUp 0.3s ease-out"},children:"✓ Changes saved automatically"}),e.jsx("style",{children:`
3140
3144
  @keyframes slideUp {
3141
3145
  from {
3142
3146
  opacity: 0;
@@ -3147,7 +3151,7 @@ cursor: pointer;
3147
3151
  transform: translateX(-50%) translateY(0);
3148
3152
  }
3149
3153
  }
3150
- `})]})},Fx=()=>{const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:a}=Pt(),{toast:s}=i.useContext(kr)||{},[p,g]=i.useState(""),[c,h]=i.useState({isOpen:!1}),[d,l]=i.useState(null),[m,x]=i.useState(null),v=i.useRef(null),w=i.useRef(new Map),{data:C=[],isLoading:$,mutate:y}=We(t?`/api/workspaces/${t.id}/roles`:null,()=>o()||[]),z=i.useMemo(()=>p?C.filter(b=>b.name.toLowerCase().includes(p.toLowerCase())):C,[C,p]),_=async b=>{try{await n(b.name,b.permissions||[]),s==null||s("Role created successfully","info"),h({isOpen:!1}),y()}catch{s==null||s("Failed to save role","error"),s==null||s("Failed to create role","error")}},k=async b=>{try{await a(b),s==null||s("Role deleted successfully","info"),x(null),y()}catch{s==null||s("Failed to delete role","error"),s==null||s("Failed to delete role","error")}};return r||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ca,{children:[e.jsx(wt,{placeholder:"Search roles",onChange:g,value:p}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:v,onClick:()=>h({isOpen:!0,triggerElement:v.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),c.isOpen&&!c.role&&e.jsx(Us,{role:c.role,triggerRef:{current:c.triggerElement||null},onClose:()=>h({isOpen:!1}),onSuccess:_})]})]}),z.length===0?e.jsx(it,{title:p?"No roles match your search":"No roles available",description:p?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:z.map(b=>{var f;return e.jsxs(Ue,{children:[e.jsx(Oe,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:b.name})}),e.jsx(Oe,{style:{color:"var(--color-secondary-text)"},children:b.permissions&&b.permissions.length>0?b.permissions.join(", "):""}),e.jsx(Ct,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ot,{open:d===b.id,openChange:I=>l(I?b.id:null),children:[e.jsx(at,{children:e.jsx(wl,{ref:I=>{I&&w.current.set(b.id,I)},disabled:!b.workspace_id,"data-role-dropdown-trigger":b.id,children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>{l(null);const I=w.current.get(b.id);h({isOpen:!0,role:b,triggerElement:I||null})},children:"Edit Role"}),e.jsx(Pe,{$destructive:!0,onClick:()=>{l(null),x(b.id)},children:"Remove Role"})]})]}),m===b.id&&e.jsx(on,{title:"Are you sure you want to delete this role?",onConfirm:()=>k(b),onCancel:()=>x(null)}),c.isOpen&&((f=c.role)==null?void 0:f.id)===b.id&&e.jsx(Us,{role:c.role,triggerRef:{current:c.triggerElement||null},onClose:()=>{h({isOpen:!1}),l(null)},onSuccess:_})]})})]},b.id)})})]})})]})},jl=()=>{const{activeWorkspace:t,loading:r}=Pt(),[o,n]=i.useState("general"),[a,s]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((h,d="info")=>{s(h),g(d),setTimeout(()=>s(null),3e3)},[]);return r?e.jsx(Ws,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):t?e.jsx(kr.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(Sx,{children:e.jsxs(Ws,{children:[e.jsx($x,{children:e.jsxs(zx,{children:[e.jsx(uo,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(po,{children:[e.jsx(Kt,{size:16}),"General"]})}),e.jsx(uo,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(po,{children:[e.jsx(Lo,{size:16}),"Members"]})}),e.jsx(uo,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(po,{children:[e.jsx(qc,{size:16}),"Invitations"]})}),e.jsx(uo,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(po,{children:[e.jsx(Xo,{size:16}),"Roles"]})})]})}),e.jsxs(Ex,{children:[o==="general"&&e.jsx(Nx,{}),o==="members"&&e.jsx(Dx,{}),o==="invitations"&&e.jsx(Ax,{}),o==="roles"&&e.jsx(Fx,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):null},kl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:g,showCloseButton:c})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(we.Header,{showCloseButton:c,children:a||o}),p||g||e.jsx(jl,{}),s&&e.jsx(we.Footer,{children:s})]})})}),_l=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:a=8})=>{const[s,p]=i.useState();return i.useEffect(()=>{if(!r||!t.current){p(void 0);return}const g=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),h=window.innerWidth,d=window.innerHeight,l=h-c.left,m=c.right,x=d-c.bottom,v=c.top;let w={};l>=o?w.left=c.left:m>=o?w.left=c.right-o:w.left=Math.max(a,Math.min(h-o-a,c.left)),x>=150?(w.top=c.bottom+a,w.maxHeight=Math.min(n,x-a*2)):v>=150?(w.bottom=d-c.top+a,w.maxHeight=Math.min(n,v-a*2)):(w.top=c.bottom+a,w.maxHeight=Math.max(100,x-a*2)),p(w)};return g(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[r,o,n,a]),s},Vs=u.div`
3154
+ `})]})},Fx=()=>{var f;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:a}=Pt(),{toast:s}=i.useContext(_r)||{},{deployment:h}=xe(),[g,c]=i.useState(""),[p,l]=i.useState({isOpen:!1}),[d,m]=i.useState(null),[x,v]=i.useState(null),w=i.useRef(null),$=i.useRef(new Map),{data:z=[],isLoading:y,mutate:C}=We(t?`/api/workspaces/${t.id}/roles`:null,()=>o()||[]),k=i.useMemo(()=>g?z.filter(E=>E.name.toLowerCase().includes(g.toLowerCase())):z,[z,g]),S=async E=>{try{await n(E.name,E.permissions||[]),s==null||s("Role created successfully","info"),l({isOpen:!1}),C()}catch{s==null||s("Failed to save role","error"),s==null||s("Failed to create role","error")}},b=async E=>{try{await a(E),s==null||s("Role deleted successfully","info"),v(null),C()}catch{s==null||s("Failed to delete role","error"),s==null||s("Failed to delete role","error")}};return r||y?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ca,{children:[e.jsx(wt,{placeholder:"Search roles",onChange:c,value:g}),e.jsxs("div",{style:{position:"relative"},children:[((f=h==null?void 0:h.b2b_settings)==null?void 0:f.custom_workspace_role_enabled)&&e.jsx(Q,{ref:w,onClick:()=>l({isOpen:!0,triggerElement:w.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),p.isOpen&&!p.role&&e.jsx(Us,{role:p.role,triggerRef:{current:p.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:S})]})]}),k.length===0?e.jsx(it,{title:g?"No roles match your search":"No roles available",description:g?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:k.map(E=>{var j;return e.jsxs(Ue,{children:[e.jsx(Oe,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:E.name})}),e.jsx(Oe,{style:{color:"var(--color-secondary-text)"},children:E.permissions&&E.permissions.length>0?E.permissions.join(", "):""}),e.jsx(Ct,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(ot,{open:d===E.id,openChange:_=>m(_?E.id:null),children:[e.jsx(at,{children:e.jsx(wl,{ref:_=>{_&&$.current.set(E.id,_)},disabled:!E.workspace_id,"data-role-dropdown-trigger":E.id,children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>{m(null);const _=$.current.get(E.id);l({isOpen:!0,role:E,triggerElement:_||null})},children:"Edit Role"}),e.jsx(Pe,{$destructive:!0,onClick:()=>{m(null),v(E.id)},children:"Remove Role"})]})]}),x===E.id&&e.jsx(on,{title:"Are you sure you want to delete this role?",onConfirm:()=>b(E),onCancel:()=>v(null)}),p.isOpen&&((j=p.role)==null?void 0:j.id)===E.id&&e.jsx(Us,{role:p.role,triggerRef:{current:p.triggerElement||null},onClose:()=>{l({isOpen:!1}),m(null)},onSuccess:S})]})})]},E.id)})})]})})]})},jl=()=>{const{activeWorkspace:t,loading:r}=Pt(),[o,n]=i.useState("general"),[a,s]=i.useState(null),[h,g]=i.useState("info"),c=i.useCallback((p,l="info")=>{s(p),g(l),setTimeout(()=>s(null),3e3)},[]);return r?e.jsx(Ws,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})}):t?e.jsx(_r.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(Sx,{children:e.jsxs(Ws,{children:[e.jsx($x,{children:e.jsxs(zx,{children:[e.jsx(po,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(ho,{children:[e.jsx(Kt,{size:16}),"General"]})}),e.jsx(po,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(ho,{children:[e.jsx(Ao,{size:16}),"Members"]})}),e.jsx(po,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(ho,{children:[e.jsx(qc,{size:16}),"Invitations"]})}),e.jsx(po,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(ho,{children:[e.jsx(Xo,{size:16}),"Roles"]})})]})}),e.jsxs(Ex,{children:[o==="general"&&e.jsx(Nx,{}),o==="members"&&e.jsx(Dx,{}),o==="invitations"&&e.jsx(Ax,{}),o==="roles"&&e.jsx(Fx,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):null},kl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:h,children:g,showCloseButton:c})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(we.Header,{showCloseButton:c,children:a||o}),h||g||e.jsx(jl,{}),s&&e.jsx(we.Footer,{children:s})]})})}),_l=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:a=8})=>{const[s,h]=i.useState();return i.useEffect(()=>{if(!r||!t.current){h(void 0);return}const g=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),p=window.innerWidth,l=window.innerHeight,d=p-c.left,m=c.right,x=l-c.bottom,v=c.top;let w={};d>=o?w.left=c.left:m>=o?w.left=c.right-o:w.left=Math.max(a,Math.min(p-o-a,c.left)),x>=150?(w.top=c.bottom+a,w.maxHeight=Math.min(n,x-a*2)):v>=150?(w.bottom=l-c.top+a,w.maxHeight=Math.min(n,v-a*2)):(w.top=c.bottom+a,w.maxHeight=Math.max(100,x-a*2)),h(w)};return g(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[r,o,n,a]),s},Vs=u.div`
3151
3155
  position: relative;
3152
3156
  display: inline-block;
3153
3157
  width: 100%;
@@ -3226,7 +3230,7 @@ cursor: pointer;
3226
3230
  opacity 0.15s ease,
3227
3231
  transform 0.15s ease,
3228
3232
  visibility 0s linear ${t=>t.$isOpen?"0s":"0.15s"};
3229
- `,Po=u.div`
3233
+ `,Ro=u.div`
3230
3234
  display: flex;
3231
3235
  align-items: center;
3232
3236
  justify-content: space-between;
@@ -3253,7 +3257,7 @@ cursor: pointer;
3253
3257
  cursor: not-allowed;
3254
3258
  opacity: 0.7;
3255
3259
  }
3256
- `,ho=u(ua)`
3260
+ `,fo=u(ua)`
3257
3261
  opacity: 0;
3258
3262
  transition: opacity 0.1s ease;
3259
3263
  color: var(--color-secondary-text);
@@ -3295,7 +3299,7 @@ cursor: pointer;
3295
3299
  text-overflow: ellipsis;
3296
3300
  white-space: nowrap;
3297
3301
  color: var(--color-foreground);
3298
- `,Ro=u.button`
3302
+ `,Io=u.button`
3299
3303
  padding: 3px;
3300
3304
  border-radius: 4px;
3301
3305
  border: 1px solid var(--color-border);
@@ -3313,7 +3317,7 @@ cursor: pointer;
3313
3317
  background: var(--color-background-hover);
3314
3318
  color: var(--color-foreground);
3315
3319
  }
3316
- `,Nn=u(Ro)`
3320
+ `,Nn=u(Io)`
3317
3321
  &:hover:not(:disabled) {
3318
3322
  background: var(--color-error-background);
3319
3323
  color: var(--color-error);
@@ -3347,7 +3351,7 @@ cursor: pointer;
3347
3351
  cursor: not-allowed;
3348
3352
  opacity: 0.7;
3349
3353
  }
3350
- `,fo=u.div`
3354
+ `,go=u.div`
3351
3355
  width: 20px;
3352
3356
  height: 20px;
3353
3357
  border-radius: 50%;
@@ -3357,7 +3361,7 @@ cursor: pointer;
3357
3361
  justify-content: center;
3358
3362
  color: var(--color-secondary-text);
3359
3363
  background: var(--color-background-hover);
3360
- `,go=u.div`
3364
+ `,mo=u.div`
3361
3365
  width: 8px;
3362
3366
  height: 8px;
3363
3367
  border-radius: 50%;
@@ -3380,7 +3384,7 @@ cursor: pointer;
3380
3384
  width: 100%;
3381
3385
  height: 100%;
3382
3386
  object-fit: cover;
3383
- `,mo=u(Po)`
3387
+ `,xo=u(Ro)`
3384
3388
  padding-left: 40px;
3385
3389
  font-size: 11px;
3386
3390
  `,Zs=u.div`
@@ -3422,7 +3426,7 @@ cursor: pointer;
3422
3426
  }
3423
3427
  `,Zx=u.div`
3424
3428
  padding: 8px 0;
3425
- `,xo=u.div`
3429
+ `,vo=u.div`
3426
3430
  display: flex;
3427
3431
  align-items: center;
3428
3432
  gap: 6px;
@@ -3440,17 +3444,17 @@ cursor: pointer;
3440
3444
  opacity: 0.5;
3441
3445
  }
3442
3446
  }
3443
- `,vo=u.div`
3447
+ `,bo=u.div`
3444
3448
  width: 18px;
3445
3449
  height: 18px;
3446
3450
  border-radius: 50%;
3447
3451
  background: var(--color-border);
3448
- `,bo=u.div`
3452
+ `,yo=u.div`
3449
3453
  flex: 1;
3450
3454
  display: flex;
3451
3455
  flex-direction: column;
3452
3456
  gap: 4px;
3453
- `,yo=u.div`
3457
+ `,wo=u.div`
3454
3458
  height: 12px;
3455
3459
  background: var(--color-border);
3456
3460
  border-radius: 4px;
@@ -3498,15 +3502,15 @@ cursor: pointer;
3498
3502
  height: 16px;
3499
3503
  background: var(--color-border);
3500
3504
  border-radius: 2px;
3501
- `,Cl=({showPersonal:t=!0})=>{var ce,Y,se;const[r,o]=i.useState(!1),[n,a]=i.useState(!1),[s,p]=i.useState(new Set),g=i.useRef(null),c=i.useRef(null),h=_l({triggerRef:g,isOpen:r,minWidth:300}),d=Or(!1),l=Or(!1),m=Or(!1),x=Or(!1),[v,w]=i.useState(null),[C,$]=i.useState(!1),[y,z]=i.useState(null),{organizationMemberships:_,loading:k,refetch:b}=bt(),{activeOrganization:f,leave:I}=Qe(),{activeWorkspace:j,leave:S}=Pt(),{workspaces:R,loading:E}=yt(),{session:T,loading:P,switchOrganization:O,switchWorkspace:D}=Fe(),{deployment:M}=ve(),{toast:N}=st(),F=M==null?void 0:M.b2b_settings.organizations_enabled,J=M==null?void 0:M.b2b_settings.workspaces_enabled,ie=M==null?void 0:M.b2b_settings.allow_users_to_create_orgs,re=!((ce=T==null?void 0:T.active_signin)!=null&&ce.active_organization_membership_id),X=i.useMemo(()=>{var H,A;if(re)return{name:"Personal account",image_url:(A=(H=T==null?void 0:T.active_signin)==null?void 0:H.user)==null?void 0:A.profile_picture_url,isPersonal:!0};let q=(f==null?void 0:f.name)||"";return J&&j&&(q=`${f==null?void 0:f.name} / ${j.name}`),{name:q,image_url:f==null?void 0:f.image_url,isPersonal:!1}},[re,f,j,T,J]);i.useEffect(()=>{if(!r)return;let q=null;const H=setTimeout(()=>{const A=B=>{var W,ee;const L=B.target;(W=g.current)!=null&&W.contains(L)||(ee=c.current)!=null&&ee.contains(L)||(o(!1),z(null))};document.addEventListener("mousedown",A),q=()=>{document.removeEventListener("mousedown",A)}},50);return()=>{clearTimeout(H),q==null||q()}},[r]),i.useEffect(()=>{if(y){const q=setTimeout(()=>{z(null)},5e3);return()=>clearTimeout(q)}},[y]);const U=()=>{b()};if(!F)return null;const Z=q=>{a(!0),O(q).finally(()=>{a(!1)})},Q=q=>{a(!0),D(q).finally(()=>{a(!1)})},ae=q=>{const H=new Set(s);H.has(q)?H.delete(q):H.add(q),p(H)},oe=q=>q.split(" ").map(H=>H[0]).join("").toUpperCase().slice(0,2);return k||P?e.jsx(le,{children:e.jsx(Vs,{children:e.jsxs(Kx,{children:[e.jsxs(Gs,{children:[e.jsx(Qx,{}),e.jsx(Xx,{})]}),e.jsx(Jx,{})]})})}):e.jsx(le,{children:e.jsxs(Vs,{children:[e.jsxs(Bx,{ref:g,onClick:()=>{o(!r),r||z(null)},disabled:n,children:[e.jsxs(Gs,{children:[e.jsx(Ux,{children:X.image_url?e.jsx(Wx,{src:X.image_url,alt:X.name}):X.isPersonal?e.jsx(Mo,{size:12}):oe(X.name)}),e.jsx(Vx,{children:X.name})]}),e.jsx(dh,{size:16})]}),typeof window<"u"&&Nr.createPortal(e.jsx(le,{children:e.jsx(Gx,{ref:c,$isOpen:r,$position:h,children:k||E?e.jsxs(Zx,{children:[e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsxs(bo,{children:[e.jsx(yo,{width:"120px"}),e.jsx(Qs,{width:"80px"})]})]}),e.jsx(lr,{}),e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsx(bo,{children:e.jsx(yo,{width:"100px"})})]}),e.jsx(lr,{}),e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsxs(bo,{children:[e.jsx(yo,{width:"140px"}),e.jsx(Qs,{width:"60px"})]})]}),e.jsx(lr,{}),e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsx(bo,{children:e.jsx(yo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Po,{as:"button",$isActive:re,onClick:q=>{q.stopPropagation(),re||Z()},disabled:n||re,children:[re&&e.jsx(go,{}),e.jsxs(ht,{children:[e.jsx(Hx,{children:(se=(Y=T==null?void 0:T.active_signin)==null?void 0:Y.user)!=null&&se.profile_picture_url?e.jsx(qx,{src:T.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Mo,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Personal account"})})]}),!re&&e.jsx(ho,{className:"hover-arrow",size:14})]}),!re&&f&&e.jsx(lr,{})]}),!re&&f&&e.jsxs(Po,{$isActive:!0,onClick:()=>{J&&ae(f.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(go,{}),e.jsxs(ht,{children:[J&&e.jsx(er,{size:12,style:{marginRight:"4px",transform:s.has(f.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Hs,{children:f.image_url?e.jsx(qs,{src:f.image_url,alt:f.name}):oe(f.name)}),e.jsx(ft,{children:e.jsx(gt,{children:f.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ro,{onClick:q=>{q.stopPropagation(),l.open()},title:"Manage organization",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async q=>{q.stopPropagation(),$(!0),z(null);try{await I(),await b(),setTimeout(()=>{$(!1)},500)}catch(H){z(H instanceof Error?H.message:"Failed to leave organization"),$(!1)}},disabled:C,title:"Leave organization",children:e.jsx(zt,{size:12})})]})]}),f&&J&&s.has(f.id)&&e.jsxs(e.Fragment,{children:[R==null?void 0:R.filter(q=>q.organization.id===f.id).map(q=>{const H=(j==null?void 0:j.id)===q.id;return e.jsxs(mo,{as:H?void 0:"button",$isActive:H,onClick:H?void 0:()=>Q(q.id),...H?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[H&&e.jsx(go,{}),e.jsxs(ht,{children:[e.jsx(Zs,{children:q.image_url?e.jsx("img",{src:q.image_url,alt:q.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):oe(q.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:q.name})})]}),H?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ro,{onClick:A=>{A.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async A=>{A.stopPropagation();try{S&&await S()}catch(B){const L=B.message||"Failed to leave workspace. Please try again.";N(L,"error")}},title:"Leave workspace",children:e.jsx(zt,{size:12})})]}):e.jsx(ho,{className:"hover-arrow",size:14})]},q.id)}),e.jsx(mo,{as:"button",onClick:()=>{w(f.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{style:{width:"14px",height:"14px"},children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),(C||y)&&e.jsxs(e.Fragment,{children:[C&&e.jsxs(Ks,{children:[e.jsx(Yx,{}),"Leaving organization..."]}),y&&e.jsxs(Ks,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),y]})]}),e.jsx(lr,{}),_&&_.length>0&&e.jsx(e.Fragment,{children:_.filter(q=>q.organization.id!==(f==null?void 0:f.id)).map(q=>{const H=q.organization,A=(R==null?void 0:R.filter(L=>L.organization.id===H.id))||[],B=s.has(H.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Po,{as:"button",$isActive:!1,onClick:()=>{J?ae(H.id):Z(H.id)},disabled:n,children:[e.jsxs(ht,{children:[J&&e.jsx(er,{size:12,style:{marginRight:"4px",transform:B?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Hs,{children:H.image_url?e.jsx(qs,{src:H.image_url,alt:H.name}):oe(H.name)}),e.jsx(ft,{children:e.jsx(gt,{children:H.name})})]}),e.jsx(ho,{className:"hover-arrow",size:14})]}),J&&B&&e.jsxs(e.Fragment,{children:[A.map(L=>{const W=(j==null?void 0:j.id)===L.id;return e.jsxs(mo,{as:W?void 0:"button",$isActive:W,onClick:W?void 0:()=>Q(L.id),...W?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[W&&e.jsx(go,{}),e.jsxs(ht,{children:[e.jsx(Zs,{children:L.image_url?e.jsx("img",{src:L.image_url,alt:L.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):oe(L.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:L.name})})]}),W?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ro,{onClick:ee=>{ee.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async ee=>{ee.stopPropagation();try{S&&await S()}catch(pe){const Se=pe.message||"Failed to leave workspace. Please try again.";N(Se,"error")}},title:"Leave workspace",children:e.jsx(zt,{size:12})})]}):e.jsx(ho,{className:"hover-arrow",size:16})]},L.id)}),e.jsx(mo,{as:"button",onClick:()=>{w(H.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{style:{width:"14px",height:"14px"},children:e.jsx(Je,{size:10})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),e.jsx(lr,{})]},H.id)})}),J?f&&e.jsx(Ys,{onClick:()=>{w(f.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})}):ie&&e.jsx(Ys,{onClick:()=>{d.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create organization"})})]})})]})})}),document.body),F&&ie&&e.jsx(hm,{isOpen:d.isOpen,onClose:d.close,onCreated:U}),e.jsx(Um,{isOpen:l.isOpen,onClose:l.close}),e.jsx(kl,{isOpen:x.isOpen,onClose:x.close}),v&&e.jsx(yl,{isOpen:m.isOpen,onClose:()=>{m.close(),w(null)},organizationId:v})]})})};var e0=Object.defineProperty,Fo=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,$l=Object.prototype.propertyIsEnumerable,Xs=(t,r,o)=>r in t?e0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,pa=(t,r)=>{for(var o in r||(r={}))Sl.call(r,o)&&Xs(t,o,r[o]);if(Fo)for(var o of Fo(r))$l.call(r,o)&&Xs(t,o,r[o]);return t},ha=(t,r)=>{var o={};for(var n in t)Sl.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Fo)for(var n of Fo(t))r.indexOf(n)<0&&$l.call(t,n)&&(o[n]=t[n]);return o};/**
3505
+ `,Cl=({showPersonal:t=!0})=>{var ce,K,ie;const[r,o]=i.useState(!1),[n,a]=i.useState(!1),[s,h]=i.useState(new Set),g=i.useRef(null),c=i.useRef(null),p=_l({triggerRef:g,isOpen:r,minWidth:300}),l=Mr(!1),d=Mr(!1),m=Mr(!1),x=Mr(!1),[v,w]=i.useState(null),[$,z]=i.useState(!1),[y,C]=i.useState(null),{organizationMemberships:k,loading:S,refetch:b}=bt(),{activeOrganization:f,leave:E}=Qe(),{activeWorkspace:j,leave:_}=Pt(),{workspaces:I,loading:P}=yt(),{session:T,loading:R,switchOrganization:O,switchWorkspace:D}=Fe(),{deployment:M}=xe(),{toast:Y}=st(),N=M==null?void 0:M.b2b_settings.organizations_enabled,J=M==null?void 0:M.b2b_settings.workspaces_enabled,ae=M==null?void 0:M.b2b_settings.allow_users_to_create_orgs,ee=!((ce=T==null?void 0:T.active_signin)!=null&&ce.active_organization_membership_id),F=i.useMemo(()=>{var q,A;if(ee)return{name:"Personal account",image_url:(A=(q=T==null?void 0:T.active_signin)==null?void 0:q.user)==null?void 0:A.profile_picture_url,isPersonal:!0};let Z=(f==null?void 0:f.name)||"";return J&&j&&(Z=`${f==null?void 0:f.name} / ${j.name}`),{name:Z,image_url:f==null?void 0:f.image_url,isPersonal:!1}},[ee,f,j,T,J]);i.useEffect(()=>{if(!r)return;let Z=null;const q=setTimeout(()=>{const A=B=>{var W,te;const L=B.target;(W=g.current)!=null&&W.contains(L)||(te=c.current)!=null&&te.contains(L)||(o(!1),C(null))};document.addEventListener("mousedown",A),Z=()=>{document.removeEventListener("mousedown",A)}},50);return()=>{clearTimeout(q),Z==null||Z()}},[r]),i.useEffect(()=>{if(y){const Z=setTimeout(()=>{C(null)},5e3);return()=>clearTimeout(Z)}},[y]);const U=()=>{b()};if(!N)return null;const G=Z=>{a(!0),O(Z).finally(()=>{a(!1)})},X=Z=>{a(!0),D(Z).finally(()=>{a(!1)})},se=Z=>{const q=new Set(s);q.has(Z)?q.delete(Z):q.add(Z),h(q)},oe=Z=>Z.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2);return S||R?e.jsx(le,{children:e.jsx(Vs,{children:e.jsxs(Kx,{children:[e.jsxs(Gs,{children:[e.jsx(Qx,{}),e.jsx(Xx,{})]}),e.jsx(Jx,{})]})})}):e.jsx(le,{children:e.jsxs(Vs,{children:[e.jsxs(Bx,{ref:g,onClick:()=>{o(!r),r||C(null)},disabled:n,children:[e.jsxs(Gs,{children:[e.jsx(Ux,{children:F.image_url?e.jsx(Wx,{src:F.image_url,alt:F.name}):F.isPersonal?e.jsx(Lo,{size:12}):oe(F.name)}),e.jsx(Vx,{children:F.name})]}),e.jsx(dh,{size:16})]}),typeof window<"u"&&Fr.createPortal(e.jsx(le,{children:e.jsx(Gx,{ref:c,$isOpen:r,$position:p,children:S||P?e.jsxs(Zx,{children:[e.jsxs(vo,{children:[e.jsx(bo,{}),e.jsxs(yo,{children:[e.jsx(wo,{width:"120px"}),e.jsx(Qs,{width:"80px"})]})]}),e.jsx(lr,{}),e.jsxs(vo,{children:[e.jsx(bo,{}),e.jsx(yo,{children:e.jsx(wo,{width:"100px"})})]}),e.jsx(lr,{}),e.jsxs(vo,{children:[e.jsx(bo,{}),e.jsxs(yo,{children:[e.jsx(wo,{width:"140px"}),e.jsx(Qs,{width:"60px"})]})]}),e.jsx(lr,{}),e.jsxs(vo,{children:[e.jsx(bo,{}),e.jsx(yo,{children:e.jsx(wo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Ro,{as:"button",$isActive:ee,onClick:Z=>{Z.stopPropagation(),ee||G()},disabled:n||ee,children:[ee&&e.jsx(mo,{}),e.jsxs(ht,{children:[e.jsx(Hx,{children:(ie=(K=T==null?void 0:T.active_signin)==null?void 0:K.user)!=null&&ie.profile_picture_url?e.jsx(qx,{src:T.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Lo,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Personal account"})})]}),!ee&&e.jsx(fo,{className:"hover-arrow",size:14})]}),!ee&&f&&e.jsx(lr,{})]}),!ee&&f&&e.jsxs(Ro,{$isActive:!0,onClick:()=>{J&&se(f.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(mo,{}),e.jsxs(ht,{children:[J&&e.jsx(er,{size:12,style:{marginRight:"4px",transform:s.has(f.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Hs,{children:f.image_url?e.jsx(qs,{src:f.image_url,alt:f.name}):oe(f.name)}),e.jsx(ft,{children:e.jsx(gt,{children:f.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Io,{onClick:Z=>{Z.stopPropagation(),d.open()},title:"Manage organization",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async Z=>{Z.stopPropagation(),z(!0),C(null);try{await E(),await b(),setTimeout(()=>{z(!1)},500)}catch(q){C(q instanceof Error?q.message:"Failed to leave organization"),z(!1)}},disabled:$,title:"Leave organization",children:e.jsx(zt,{size:12})})]})]}),f&&J&&s.has(f.id)&&e.jsxs(e.Fragment,{children:[I==null?void 0:I.filter(Z=>Z.organization.id===f.id).map(Z=>{const q=(j==null?void 0:j.id)===Z.id;return e.jsxs(xo,{as:q?void 0:"button",$isActive:q,onClick:q?void 0:()=>X(Z.id),...q?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[q&&e.jsx(mo,{}),e.jsxs(ht,{children:[e.jsx(Zs,{children:Z.image_url?e.jsx("img",{src:Z.image_url,alt:Z.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):oe(Z.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:Z.name})})]}),q?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Io,{onClick:A=>{A.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async A=>{A.stopPropagation();try{_&&await _()}catch(B){const L=B.message||"Failed to leave workspace. Please try again.";Y(L,"error")}},title:"Leave workspace",children:e.jsx(zt,{size:12})})]}):e.jsx(fo,{className:"hover-arrow",size:14})]},Z.id)}),e.jsx(xo,{as:"button",onClick:()=>{w(f.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(go,{style:{width:"14px",height:"14px"},children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),($||y)&&e.jsxs(e.Fragment,{children:[$&&e.jsxs(Ks,{children:[e.jsx(Yx,{}),"Leaving organization..."]}),y&&e.jsxs(Ks,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),y]})]}),e.jsx(lr,{}),k&&k.length>0&&e.jsx(e.Fragment,{children:k.filter(Z=>Z.organization.id!==(f==null?void 0:f.id)).map(Z=>{const q=Z.organization,A=(I==null?void 0:I.filter(L=>L.organization.id===q.id))||[],B=s.has(q.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Ro,{as:"button",$isActive:!1,onClick:()=>{J?se(q.id):G(q.id)},disabled:n,children:[e.jsxs(ht,{children:[J&&e.jsx(er,{size:12,style:{marginRight:"4px",transform:B?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Hs,{children:q.image_url?e.jsx(qs,{src:q.image_url,alt:q.name}):oe(q.name)}),e.jsx(ft,{children:e.jsx(gt,{children:q.name})})]}),e.jsx(fo,{className:"hover-arrow",size:14})]}),J&&B&&e.jsxs(e.Fragment,{children:[A.map(L=>{const W=(j==null?void 0:j.id)===L.id;return e.jsxs(xo,{as:W?void 0:"button",$isActive:W,onClick:W?void 0:()=>X(L.id),...W?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[W&&e.jsx(mo,{}),e.jsxs(ht,{children:[e.jsx(Zs,{children:L.image_url?e.jsx("img",{src:L.image_url,alt:L.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):oe(L.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:L.name})})]}),W?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Io,{onClick:te=>{te.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async te=>{te.stopPropagation();try{_&&await _()}catch(pe){const Se=pe.message||"Failed to leave workspace. Please try again.";Y(Se,"error")}},title:"Leave workspace",children:e.jsx(zt,{size:12})})]}):e.jsx(fo,{className:"hover-arrow",size:16})]},L.id)}),e.jsx(xo,{as:"button",onClick:()=>{w(q.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(go,{style:{width:"14px",height:"14px"},children:e.jsx(Je,{size:10})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),e.jsx(lr,{})]},q.id)})}),J?f&&e.jsx(Ys,{onClick:()=>{w(f.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(go,{children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})}):ae&&e.jsx(Ys,{onClick:()=>{l.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(go,{children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create organization"})})]})})]})})}),document.body),N&&ae&&e.jsx(hm,{isOpen:l.isOpen,onClose:l.close,onCreated:U}),e.jsx(Um,{isOpen:d.isOpen,onClose:d.close}),e.jsx(kl,{isOpen:x.isOpen,onClose:x.close}),v&&e.jsx(yl,{isOpen:m.isOpen,onClose:()=>{m.close(),w(null)},organizationId:v})]})})};var e0=Object.defineProperty,Fo=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,$l=Object.prototype.propertyIsEnumerable,Xs=(t,r,o)=>r in t?e0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,pa=(t,r)=>{for(var o in r||(r={}))Sl.call(r,o)&&Xs(t,o,r[o]);if(Fo)for(var o of Fo(r))$l.call(r,o)&&Xs(t,o,r[o]);return t},ha=(t,r)=>{var o={};for(var n in t)Sl.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Fo)for(var n of Fo(t))r.indexOf(n)<0&&$l.call(t,n)&&(o[n]=t[n]);return o};/**
3502
3506
  * @license QR Code generator library (TypeScript)
3503
3507
  * Copyright (c) Project Nayuki.
3504
3508
  * SPDX-License-Identifier: MIT
3505
- */var tr;(t=>{const r=class xe{constructor(c,h,d,l){if(this.version=c,this.errorCorrectionLevel=h,this.modules=[],this.isFunction=[],c<xe.MIN_VERSION||c>xe.MAX_VERSION)throw new RangeError("Version value out of range");if(l<-1||l>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let m=[];for(let v=0;v<this.size;v++)m.push(!1);for(let v=0;v<this.size;v++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(d);if(this.drawCodewords(x),l==-1){let v=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const C=this.getPenaltyScore();C<v&&(l=w,v=C),this.applyMask(w)}}a(0<=l&&l<=7),this.mask=l,this.applyMask(l),this.drawFormatBits(l),this.isFunction=[]}static encodeText(c,h){const d=t.QrSegment.makeSegments(c);return xe.encodeSegments(d,h)}static encodeBinary(c,h){const d=t.QrSegment.makeBytes(c);return xe.encodeSegments([d],h)}static encodeSegments(c,h,d=1,l=40,m=-1,x=!0){if(!(xe.MIN_VERSION<=d&&d<=l&&l<=xe.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let v,w;for(v=d;;v++){const z=xe.getNumDataCodewords(v,h)*8,_=p.getTotalBits(c,v);if(_<=z){w=_;break}if(v>=l)throw new RangeError("Data too long")}for(const z of[xe.Ecc.MEDIUM,xe.Ecc.QUARTILE,xe.Ecc.HIGH])x&&w<=xe.getNumDataCodewords(v,z)*8&&(h=z);let C=[];for(const z of c){o(z.mode.modeBits,4,C),o(z.numChars,z.mode.numCharCountBits(v),C);for(const _ of z.getData())C.push(_)}a(C.length==w);const $=xe.getNumDataCodewords(v,h)*8;a(C.length<=$),o(0,Math.min(4,$-C.length),C),o(0,(8-C.length%8)%8,C),a(C.length%8==0);for(let z=236;C.length<$;z^=253)o(z,8,C);let y=[];for(;y.length*8<C.length;)y.push(0);return C.forEach((z,_)=>y[_>>>3]|=z<<7-(_&7)),new xe(v,h,y,m)}getModule(c,h){return 0<=c&&c<this.size&&0<=h&&h<this.size&&this.modules[h][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let d=0;d<this.size;d++)this.setFunctionModule(6,d,d%2==0),this.setFunctionModule(d,6,d%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),h=c.length;for(let d=0;d<h;d++)for(let l=0;l<h;l++)d==0&&l==0||d==0&&l==h-1||d==h-1&&l==0||this.drawAlignmentPattern(c[d],c[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const h=this.errorCorrectionLevel.formatBits<<3|c;let d=h;for(let m=0;m<10;m++)d=d<<1^(d>>>9)*1335;const l=(h<<10|d)^21522;a(l>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,n(l,m));this.setFunctionModule(8,7,n(l,6)),this.setFunctionModule(8,8,n(l,7)),this.setFunctionModule(7,8,n(l,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,n(l,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,n(l,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,n(l,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let d=0;d<12;d++)c=c<<1^(c>>>11)*7973;const h=this.version<<12|c;a(h>>>18==0);for(let d=0;d<18;d++){const l=n(h,d),m=this.size-11+d%3,x=Math.floor(d/3);this.setFunctionModule(m,x,l),this.setFunctionModule(x,m,l)}}drawFinderPattern(c,h){for(let d=-4;d<=4;d++)for(let l=-4;l<=4;l++){const m=Math.max(Math.abs(l),Math.abs(d)),x=c+l,v=h+d;0<=x&&x<this.size&&0<=v&&v<this.size&&this.setFunctionModule(x,v,m!=2&&m!=4)}}drawAlignmentPattern(c,h){for(let d=-2;d<=2;d++)for(let l=-2;l<=2;l++)this.setFunctionModule(c+l,h+d,Math.max(Math.abs(l),Math.abs(d))!=1)}setFunctionModule(c,h,d){this.modules[h][c]=d,this.isFunction[h][c]=!0}addEccAndInterleave(c){const h=this.version,d=this.errorCorrectionLevel;if(c.length!=xe.getNumDataCodewords(h,d))throw new RangeError("Invalid argument");const l=xe.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][h],m=xe.ECC_CODEWORDS_PER_BLOCK[d.ordinal][h],x=Math.floor(xe.getNumRawDataModules(h)/8),v=l-x%l,w=Math.floor(x/l);let C=[];const $=xe.reedSolomonComputeDivisor(m);for(let z=0,_=0;z<l;z++){let k=c.slice(_,_+w-m+(z<v?0:1));_+=k.length;const b=xe.reedSolomonComputeRemainder(k,$);z<v&&k.push(0),C.push(k.concat(b))}let y=[];for(let z=0;z<C[0].length;z++)C.forEach((_,k)=>{(z!=w-m||k>=v)&&y.push(_[z])});return a(y.length==x),y}drawCodewords(c){if(c.length!=Math.floor(xe.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let h=0;for(let d=this.size-1;d>=1;d-=2){d==6&&(d=5);for(let l=0;l<this.size;l++)for(let m=0;m<2;m++){const x=d-m,w=(d+1&2)==0?this.size-1-l:l;!this.isFunction[w][x]&&h<c.length*8&&(this.modules[w][x]=n(c[h>>>3],7-(h&7)),h++)}}a(h==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let h=0;h<this.size;h++)for(let d=0;d<this.size;d++){let l;switch(c){case 0:l=(d+h)%2==0;break;case 1:l=h%2==0;break;case 2:l=d%3==0;break;case 3:l=(d+h)%3==0;break;case 4:l=(Math.floor(d/3)+Math.floor(h/2))%2==0;break;case 5:l=d*h%2+d*h%3==0;break;case 6:l=(d*h%2+d*h%3)%2==0;break;case 7:l=((d+h)%2+d*h%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[h][d]&&l&&(this.modules[h][d]=!this.modules[h][d])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let x=!1,v=0,w=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[m][C]==x?(v++,v==5?c+=xe.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,w),x||(c+=this.finderPenaltyCountPatterns(w)*xe.PENALTY_N3),x=this.modules[m][C],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,w)*xe.PENALTY_N3}for(let m=0;m<this.size;m++){let x=!1,v=0,w=[0,0,0,0,0,0,0];for(let C=0;C<this.size;C++)this.modules[C][m]==x?(v++,v==5?c+=xe.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,w),x||(c+=this.finderPenaltyCountPatterns(w)*xe.PENALTY_N3),x=this.modules[C][m],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,w)*xe.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let x=0;x<this.size-1;x++){const v=this.modules[m][x];v==this.modules[m][x+1]&&v==this.modules[m+1][x]&&v==this.modules[m+1][x+1]&&(c+=xe.PENALTY_N2)}let h=0;for(const m of this.modules)h=m.reduce((x,v)=>x+(v?1:0),h);const d=this.size*this.size,l=Math.ceil(Math.abs(h*20-d*10)/d)-1;return a(0<=l&&l<=9),c+=l*xe.PENALTY_N4,a(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,h=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let d=[6];for(let l=this.size-7;d.length<c;l-=h)d.splice(1,0,l);return d}}static getNumRawDataModules(c){if(c<xe.MIN_VERSION||c>xe.MAX_VERSION)throw new RangeError("Version number out of range");let h=(16*c+128)*c+64;if(c>=2){const d=Math.floor(c/7)+2;h-=(25*d-10)*d-55,c>=7&&(h-=36)}return a(208<=h&&h<=29648),h}static getNumDataCodewords(c,h){return Math.floor(xe.getNumRawDataModules(c)/8)-xe.ECC_CODEWORDS_PER_BLOCK[h.ordinal][c]*xe.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let h=[];for(let l=0;l<c-1;l++)h.push(0);h.push(1);let d=1;for(let l=0;l<c;l++){for(let m=0;m<h.length;m++)h[m]=xe.reedSolomonMultiply(h[m],d),m+1<h.length&&(h[m]^=h[m+1]);d=xe.reedSolomonMultiply(d,2)}return h}static reedSolomonComputeRemainder(c,h){let d=h.map(l=>0);for(const l of c){const m=l^d.shift();d.push(0),h.forEach((x,v)=>d[v]^=xe.reedSolomonMultiply(x,m))}return d}static reedSolomonMultiply(c,h){if(c>>>8||h>>>8)throw new RangeError("Byte out of range");let d=0;for(let l=7;l>=0;l--)d=d<<1^(d>>>7)*285,d^=(h>>>l&1)*c;return a(d>>>8==0),d}finderPenaltyCountPatterns(c){const h=c[1];a(h<=this.size*3);const d=h>0&&c[2]==h&&c[3]==h*3&&c[4]==h&&c[5]==h;return(d&&c[0]>=h*4&&c[6]>=h?1:0)+(d&&c[6]>=h*4&&c[0]>=h?1:0)}finderPenaltyTerminateAndCount(c,h,d){return c&&(this.finderPenaltyAddHistory(h,d),h=0),h+=this.size,this.finderPenaltyAddHistory(h,d),this.finderPenaltyCountPatterns(d)}finderPenaltyAddHistory(c,h){h[0]==0&&(c+=this.size),h.pop(),h.unshift(c)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function o(g,c,h){if(c<0||c>31||g>>>c)throw new RangeError("Value out of range");for(let d=c-1;d>=0;d--)h.push(g>>>d&1)}function n(g,c){return(g>>>c&1)!=0}function a(g){if(!g)throw new Error("Assertion error")}const s=class Ie{constructor(c,h,d){if(this.mode=c,this.numChars=h,this.bitData=d,h<0)throw new RangeError("Invalid argument");this.bitData=d.slice()}static makeBytes(c){let h=[];for(const d of c)o(d,8,h);return new Ie(Ie.Mode.BYTE,c.length,h)}static makeNumeric(c){if(!Ie.isNumeric(c))throw new RangeError("String contains non-numeric characters");let h=[];for(let d=0;d<c.length;){const l=Math.min(c.length-d,3);o(parseInt(c.substring(d,d+l),10),l*3+1,h),d+=l}return new Ie(Ie.Mode.NUMERIC,c.length,h)}static makeAlphanumeric(c){if(!Ie.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let h=[],d;for(d=0;d+2<=c.length;d+=2){let l=Ie.ALPHANUMERIC_CHARSET.indexOf(c.charAt(d))*45;l+=Ie.ALPHANUMERIC_CHARSET.indexOf(c.charAt(d+1)),o(l,11,h)}return d<c.length&&o(Ie.ALPHANUMERIC_CHARSET.indexOf(c.charAt(d)),6,h),new Ie(Ie.Mode.ALPHANUMERIC,c.length,h)}static makeSegments(c){return c==""?[]:Ie.isNumeric(c)?[Ie.makeNumeric(c)]:Ie.isAlphanumeric(c)?[Ie.makeAlphanumeric(c)]:[Ie.makeBytes(Ie.toUtf8ByteArray(c))]}static makeEci(c){let h=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,h);else if(c<16384)o(2,2,h),o(c,14,h);else if(c<1e6)o(6,3,h),o(c,21,h);else throw new RangeError("ECI assignment value out of range");return new Ie(Ie.Mode.ECI,0,h)}static isNumeric(c){return Ie.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Ie.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,h){let d=0;for(const l of c){const m=l.mode.numCharCountBits(h);if(l.numChars>=1<<m)return 1/0;d+=4+m+l.bitData.length}return d}static toUtf8ByteArray(c){c=encodeURI(c);let h=[];for(let d=0;d<c.length;d++)c.charAt(d)!="%"?h.push(c.charCodeAt(d)):(h.push(parseInt(c.substring(d+1,d+3),16)),d+=2);return h}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let p=s;t.QrSegment=s})(tr||(tr={}));(t=>{(r=>{const o=class{constructor(a,s){this.ordinal=a,this.formatBits=s}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(tr||(tr={}));(t=>{(r=>{const o=class{constructor(a,s){this.modeBits=a,this.numBitsCharCount=s}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(tr||(tr={}));var pr=tr;/**
3509
+ */var tr;(t=>{const r=class ve{constructor(c,p,l,d){if(this.version=c,this.errorCorrectionLevel=p,this.modules=[],this.isFunction=[],c<ve.MIN_VERSION||c>ve.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let m=[];for(let v=0;v<this.size;v++)m.push(!1);for(let v=0;v<this.size;v++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(l);if(this.drawCodewords(x),d==-1){let v=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const $=this.getPenaltyScore();$<v&&(d=w,v=$),this.applyMask(w)}}a(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(c,p){const l=t.QrSegment.makeSegments(c);return ve.encodeSegments(l,p)}static encodeBinary(c,p){const l=t.QrSegment.makeBytes(c);return ve.encodeSegments([l],p)}static encodeSegments(c,p,l=1,d=40,m=-1,x=!0){if(!(ve.MIN_VERSION<=l&&l<=d&&d<=ve.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let v,w;for(v=l;;v++){const C=ve.getNumDataCodewords(v,p)*8,k=h.getTotalBits(c,v);if(k<=C){w=k;break}if(v>=d)throw new RangeError("Data too long")}for(const C of[ve.Ecc.MEDIUM,ve.Ecc.QUARTILE,ve.Ecc.HIGH])x&&w<=ve.getNumDataCodewords(v,C)*8&&(p=C);let $=[];for(const C of c){o(C.mode.modeBits,4,$),o(C.numChars,C.mode.numCharCountBits(v),$);for(const k of C.getData())$.push(k)}a($.length==w);const z=ve.getNumDataCodewords(v,p)*8;a($.length<=z),o(0,Math.min(4,z-$.length),$),o(0,(8-$.length%8)%8,$),a($.length%8==0);for(let C=236;$.length<z;C^=253)o(C,8,$);let y=[];for(;y.length*8<$.length;)y.push(0);return $.forEach((C,k)=>y[k>>>3]|=C<<7-(k&7)),new ve(v,p,y,m)}getModule(c,p){return 0<=c&&c<this.size&&0<=p&&p<this.size&&this.modules[p][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),p=c.length;for(let l=0;l<p;l++)for(let d=0;d<p;d++)l==0&&d==0||l==0&&d==p-1||l==p-1&&d==0||this.drawAlignmentPattern(c[l],c[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const p=this.errorCorrectionLevel.formatBits<<3|c;let l=p;for(let m=0;m<10;m++)l=l<<1^(l>>>9)*1335;const d=(p<<10|l)^21522;a(d>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,n(d,m));this.setFunctionModule(8,7,n(d,6)),this.setFunctionModule(8,8,n(d,7)),this.setFunctionModule(7,8,n(d,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,n(d,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,n(d,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,n(d,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let l=0;l<12;l++)c=c<<1^(c>>>11)*7973;const p=this.version<<12|c;a(p>>>18==0);for(let l=0;l<18;l++){const d=n(p,l),m=this.size-11+l%3,x=Math.floor(l/3);this.setFunctionModule(m,x,d),this.setFunctionModule(x,m,d)}}drawFinderPattern(c,p){for(let l=-4;l<=4;l++)for(let d=-4;d<=4;d++){const m=Math.max(Math.abs(d),Math.abs(l)),x=c+d,v=p+l;0<=x&&x<this.size&&0<=v&&v<this.size&&this.setFunctionModule(x,v,m!=2&&m!=4)}}drawAlignmentPattern(c,p){for(let l=-2;l<=2;l++)for(let d=-2;d<=2;d++)this.setFunctionModule(c+d,p+l,Math.max(Math.abs(d),Math.abs(l))!=1)}setFunctionModule(c,p,l){this.modules[p][c]=l,this.isFunction[p][c]=!0}addEccAndInterleave(c){const p=this.version,l=this.errorCorrectionLevel;if(c.length!=ve.getNumDataCodewords(p,l))throw new RangeError("Invalid argument");const d=ve.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][p],m=ve.ECC_CODEWORDS_PER_BLOCK[l.ordinal][p],x=Math.floor(ve.getNumRawDataModules(p)/8),v=d-x%d,w=Math.floor(x/d);let $=[];const z=ve.reedSolomonComputeDivisor(m);for(let C=0,k=0;C<d;C++){let S=c.slice(k,k+w-m+(C<v?0:1));k+=S.length;const b=ve.reedSolomonComputeRemainder(S,z);C<v&&S.push(0),$.push(S.concat(b))}let y=[];for(let C=0;C<$[0].length;C++)$.forEach((k,S)=>{(C!=w-m||S>=v)&&y.push(k[C])});return a(y.length==x),y}drawCodewords(c){if(c.length!=Math.floor(ve.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let p=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let d=0;d<this.size;d++)for(let m=0;m<2;m++){const x=l-m,w=(l+1&2)==0?this.size-1-d:d;!this.isFunction[w][x]&&p<c.length*8&&(this.modules[w][x]=n(c[p>>>3],7-(p&7)),p++)}}a(p==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let p=0;p<this.size;p++)for(let l=0;l<this.size;l++){let d;switch(c){case 0:d=(l+p)%2==0;break;case 1:d=p%2==0;break;case 2:d=l%3==0;break;case 3:d=(l+p)%3==0;break;case 4:d=(Math.floor(l/3)+Math.floor(p/2))%2==0;break;case 5:d=l*p%2+l*p%3==0;break;case 6:d=(l*p%2+l*p%3)%2==0;break;case 7:d=((l+p)%2+l*p%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[p][l]&&d&&(this.modules[p][l]=!this.modules[p][l])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let x=!1,v=0,w=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[m][$]==x?(v++,v==5?c+=ve.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,w),x||(c+=this.finderPenaltyCountPatterns(w)*ve.PENALTY_N3),x=this.modules[m][$],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,w)*ve.PENALTY_N3}for(let m=0;m<this.size;m++){let x=!1,v=0,w=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[$][m]==x?(v++,v==5?c+=ve.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,w),x||(c+=this.finderPenaltyCountPatterns(w)*ve.PENALTY_N3),x=this.modules[$][m],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,w)*ve.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let x=0;x<this.size-1;x++){const v=this.modules[m][x];v==this.modules[m][x+1]&&v==this.modules[m+1][x]&&v==this.modules[m+1][x+1]&&(c+=ve.PENALTY_N2)}let p=0;for(const m of this.modules)p=m.reduce((x,v)=>x+(v?1:0),p);const l=this.size*this.size,d=Math.ceil(Math.abs(p*20-l*10)/l)-1;return a(0<=d&&d<=9),c+=d*ve.PENALTY_N4,a(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,p=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let l=[6];for(let d=this.size-7;l.length<c;d-=p)l.splice(1,0,d);return l}}static getNumRawDataModules(c){if(c<ve.MIN_VERSION||c>ve.MAX_VERSION)throw new RangeError("Version number out of range");let p=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;p-=(25*l-10)*l-55,c>=7&&(p-=36)}return a(208<=p&&p<=29648),p}static getNumDataCodewords(c,p){return Math.floor(ve.getNumRawDataModules(c)/8)-ve.ECC_CODEWORDS_PER_BLOCK[p.ordinal][c]*ve.NUM_ERROR_CORRECTION_BLOCKS[p.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let p=[];for(let d=0;d<c-1;d++)p.push(0);p.push(1);let l=1;for(let d=0;d<c;d++){for(let m=0;m<p.length;m++)p[m]=ve.reedSolomonMultiply(p[m],l),m+1<p.length&&(p[m]^=p[m+1]);l=ve.reedSolomonMultiply(l,2)}return p}static reedSolomonComputeRemainder(c,p){let l=p.map(d=>0);for(const d of c){const m=d^l.shift();l.push(0),p.forEach((x,v)=>l[v]^=ve.reedSolomonMultiply(x,m))}return l}static reedSolomonMultiply(c,p){if(c>>>8||p>>>8)throw new RangeError("Byte out of range");let l=0;for(let d=7;d>=0;d--)l=l<<1^(l>>>7)*285,l^=(p>>>d&1)*c;return a(l>>>8==0),l}finderPenaltyCountPatterns(c){const p=c[1];a(p<=this.size*3);const l=p>0&&c[2]==p&&c[3]==p*3&&c[4]==p&&c[5]==p;return(l&&c[0]>=p*4&&c[6]>=p?1:0)+(l&&c[6]>=p*4&&c[0]>=p?1:0)}finderPenaltyTerminateAndCount(c,p,l){return c&&(this.finderPenaltyAddHistory(p,l),p=0),p+=this.size,this.finderPenaltyAddHistory(p,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(c,p){p[0]==0&&(c+=this.size),p.pop(),p.unshift(c)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function o(g,c,p){if(c<0||c>31||g>>>c)throw new RangeError("Value out of range");for(let l=c-1;l>=0;l--)p.push(g>>>l&1)}function n(g,c){return(g>>>c&1)!=0}function a(g){if(!g)throw new Error("Assertion error")}const s=class Ie{constructor(c,p,l){if(this.mode=c,this.numChars=p,this.bitData=l,p<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let p=[];for(const l of c)o(l,8,p);return new Ie(Ie.Mode.BYTE,c.length,p)}static makeNumeric(c){if(!Ie.isNumeric(c))throw new RangeError("String contains non-numeric characters");let p=[];for(let l=0;l<c.length;){const d=Math.min(c.length-l,3);o(parseInt(c.substring(l,l+d),10),d*3+1,p),l+=d}return new Ie(Ie.Mode.NUMERIC,c.length,p)}static makeAlphanumeric(c){if(!Ie.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let p=[],l;for(l=0;l+2<=c.length;l+=2){let d=Ie.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;d+=Ie.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),o(d,11,p)}return l<c.length&&o(Ie.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,p),new Ie(Ie.Mode.ALPHANUMERIC,c.length,p)}static makeSegments(c){return c==""?[]:Ie.isNumeric(c)?[Ie.makeNumeric(c)]:Ie.isAlphanumeric(c)?[Ie.makeAlphanumeric(c)]:[Ie.makeBytes(Ie.toUtf8ByteArray(c))]}static makeEci(c){let p=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,p);else if(c<16384)o(2,2,p),o(c,14,p);else if(c<1e6)o(6,3,p),o(c,21,p);else throw new RangeError("ECI assignment value out of range");return new Ie(Ie.Mode.ECI,0,p)}static isNumeric(c){return Ie.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Ie.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,p){let l=0;for(const d of c){const m=d.mode.numCharCountBits(p);if(d.numChars>=1<<m)return 1/0;l+=4+m+d.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let p=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?p.push(c.charCodeAt(l)):(p.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return p}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let h=s;t.QrSegment=s})(tr||(tr={}));(t=>{(r=>{const o=class{constructor(a,s){this.ordinal=a,this.formatBits=s}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(tr||(tr={}));(t=>{(r=>{const o=class{constructor(a,s){this.modeBits=a,this.numBitsCharCount=s}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(tr||(tr={}));var pr=tr;/**
3506
3510
  * @license qrcode.react
3507
3511
  * Copyright (c) Paul O'Shannessy
3508
3512
  * SPDX-License-Identifier: ISC
3509
- */var t0={L:pr.QrCode.Ecc.LOW,M:pr.QrCode.Ecc.MEDIUM,Q:pr.QrCode.Ecc.QUARTILE,H:pr.QrCode.Ecc.HIGH},zl=128,El="L",Pl="#FFFFFF",Rl="#000000",Il=!1,Tl=1,r0=4,o0=0,n0=.1;function Ol(t,r=0){const o=[];return t.forEach(function(n,a){let s=null;n.forEach(function(p,g){if(!p&&s!==null){o.push(`M${s+r} ${a+r}h${g-s}v1H${s+r}z`),s=null;return}if(g===n.length-1){if(!p)return;s===null?o.push(`M${g+r},${a+r} h1v1H${g+r}z`):o.push(`M${s+r},${a+r} h${g+1-s}v1H${s+r}z`);return}p&&s===null&&(s=g)})}),o.join("")}function Ml(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((a,s)=>s<r.x||s>=r.x+r.w?a:!1))}function a0(t,r,o,n){if(n==null)return null;const a=t.length+o*2,s=Math.floor(r*n0),p=a/r,g=(n.width||s)*p,c=(n.height||s)*p,h=n.x==null?t.length/2-g/2:n.x*p,d=n.y==null?t.length/2-c/2:n.y*p,l=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let v=Math.floor(h),w=Math.floor(d),C=Math.ceil(g+h-v),$=Math.ceil(c+d-w);m={x:v,y:w,w:C,h:$}}const x=n.crossOrigin;return{x:h,y:d,h:c,w:g,excavation:m,opacity:l,crossOrigin:x}}function s0(t,r){return r!=null?Math.max(Math.floor(r),0):t?r0:o0}function Ll({value:t,level:r,minVersion:o,includeMargin:n,marginSize:a,imageSettings:s,size:p,boostLevel:g}){let c=i.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((w,C)=>(w.push(...pr.QrSegment.makeSegments(C)),w),[]);return pr.QrCode.encodeSegments(v,t0[r],o,void 0,void 0,g)},[t,r,o,g]);const{cells:h,margin:d,numCells:l,calculatedImageSettings:m}=i.useMemo(()=>{let x=c.getModules();const v=s0(n,a),w=x.length+v*2,C=a0(x,p,v,s);return{cells:x,margin:v,numCells:w,calculatedImageSettings:C}},[c,p,s,n,a]);return{qrcode:c,margin:d,cells:h,numCells:l,calculatedImageSettings:m}}var i0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),c0=i.forwardRef(function(r,o){const n=r,{value:a,size:s=zl,level:p=El,bgColor:g=Pl,fgColor:c=Rl,includeMargin:h=Il,minVersion:d=Tl,boostLevel:l,marginSize:m,imageSettings:x}=n,w=ha(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:C}=w,$=ha(w,["style"]),y=x==null?void 0:x.src,z=i.useRef(null),_=i.useRef(null),k=i.useCallback(P=>{z.current=P,typeof o=="function"?o(P):o&&(o.current=P)},[o]),[b,f]=i.useState(!1),{margin:I,cells:j,numCells:S,calculatedImageSettings:R}=Ll({value:a,level:p,minVersion:d,boostLevel:l,includeMargin:h,marginSize:m,imageSettings:x,size:s});i.useEffect(()=>{if(z.current!=null){const P=z.current,O=P.getContext("2d");if(!O)return;let D=j;const M=_.current,N=R!=null&&M!==null&&M.complete&&M.naturalHeight!==0&&M.naturalWidth!==0;N&&R.excavation!=null&&(D=Ml(j,R.excavation));const F=window.devicePixelRatio||1;P.height=P.width=s*F;const J=s/S*F;O.scale(J,J),O.fillStyle=g,O.fillRect(0,0,S,S),O.fillStyle=c,i0?O.fill(new Path2D(Ol(D,I))):j.forEach(function(ie,re){ie.forEach(function(X,U){X&&O.fillRect(U+I,re+I,1,1)})}),R&&(O.globalAlpha=R.opacity),N&&O.drawImage(M,R.x+I,R.y+I,R.w,R.h)}}),i.useEffect(()=>{f(!1)},[y]);const E=pa({height:s,width:s},C);let T=null;return y!=null&&(T=i.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{f(!0)},ref:_,crossOrigin:R==null?void 0:R.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",pa({style:E,height:s,width:s,ref:k,role:"img"},$)),T)});c0.displayName="QRCodeCanvas";var Sa=i.forwardRef(function(r,o){const n=r,{value:a,size:s=zl,level:p=El,bgColor:g=Pl,fgColor:c=Rl,includeMargin:h=Il,minVersion:d=Tl,boostLevel:l,title:m,marginSize:x,imageSettings:v}=n,w=ha(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:C,cells:$,numCells:y,calculatedImageSettings:z}=Ll({value:a,level:p,minVersion:d,boostLevel:l,includeMargin:h,marginSize:x,imageSettings:v,size:s});let _=$,k=null;v!=null&&z!=null&&(z.excavation!=null&&(_=Ml($,z.excavation)),k=i.createElement("image",{href:v.src,height:z.h,width:z.w,x:z.x+C,y:z.y+C,preserveAspectRatio:"none",opacity:z.opacity,crossOrigin:z.crossOrigin}));const b=Ol(_,C);return i.createElement("svg",pa({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:o,role:"img"},w),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:g,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:b,shapeRendering:"crispEdges"}),k)});Sa.displayName="QRCodeSVG";const l0=u.div`
3513
+ */var t0={L:pr.QrCode.Ecc.LOW,M:pr.QrCode.Ecc.MEDIUM,Q:pr.QrCode.Ecc.QUARTILE,H:pr.QrCode.Ecc.HIGH},zl=128,El="L",Pl="#FFFFFF",Rl="#000000",Il=!1,Tl=1,r0=4,o0=0,n0=.1;function Ol(t,r=0){const o=[];return t.forEach(function(n,a){let s=null;n.forEach(function(h,g){if(!h&&s!==null){o.push(`M${s+r} ${a+r}h${g-s}v1H${s+r}z`),s=null;return}if(g===n.length-1){if(!h)return;s===null?o.push(`M${g+r},${a+r} h1v1H${g+r}z`):o.push(`M${s+r},${a+r} h${g+1-s}v1H${s+r}z`);return}h&&s===null&&(s=g)})}),o.join("")}function Ml(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((a,s)=>s<r.x||s>=r.x+r.w?a:!1))}function a0(t,r,o,n){if(n==null)return null;const a=t.length+o*2,s=Math.floor(r*n0),h=a/r,g=(n.width||s)*h,c=(n.height||s)*h,p=n.x==null?t.length/2-g/2:n.x*h,l=n.y==null?t.length/2-c/2:n.y*h,d=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let v=Math.floor(p),w=Math.floor(l),$=Math.ceil(g+p-v),z=Math.ceil(c+l-w);m={x:v,y:w,w:$,h:z}}const x=n.crossOrigin;return{x:p,y:l,h:c,w:g,excavation:m,opacity:d,crossOrigin:x}}function s0(t,r){return r!=null?Math.max(Math.floor(r),0):t?r0:o0}function Ll({value:t,level:r,minVersion:o,includeMargin:n,marginSize:a,imageSettings:s,size:h,boostLevel:g}){let c=i.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((w,$)=>(w.push(...pr.QrSegment.makeSegments($)),w),[]);return pr.QrCode.encodeSegments(v,t0[r],o,void 0,void 0,g)},[t,r,o,g]);const{cells:p,margin:l,numCells:d,calculatedImageSettings:m}=i.useMemo(()=>{let x=c.getModules();const v=s0(n,a),w=x.length+v*2,$=a0(x,h,v,s);return{cells:x,margin:v,numCells:w,calculatedImageSettings:$}},[c,h,s,n,a]);return{qrcode:c,margin:l,cells:p,numCells:d,calculatedImageSettings:m}}var i0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),c0=i.forwardRef(function(r,o){const n=r,{value:a,size:s=zl,level:h=El,bgColor:g=Pl,fgColor:c=Rl,includeMargin:p=Il,minVersion:l=Tl,boostLevel:d,marginSize:m,imageSettings:x}=n,w=ha(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:$}=w,z=ha(w,["style"]),y=x==null?void 0:x.src,C=i.useRef(null),k=i.useRef(null),S=i.useCallback(R=>{C.current=R,typeof o=="function"?o(R):o&&(o.current=R)},[o]),[b,f]=i.useState(!1),{margin:E,cells:j,numCells:_,calculatedImageSettings:I}=Ll({value:a,level:h,minVersion:l,boostLevel:d,includeMargin:p,marginSize:m,imageSettings:x,size:s});i.useEffect(()=>{if(C.current!=null){const R=C.current,O=R.getContext("2d");if(!O)return;let D=j;const M=k.current,Y=I!=null&&M!==null&&M.complete&&M.naturalHeight!==0&&M.naturalWidth!==0;Y&&I.excavation!=null&&(D=Ml(j,I.excavation));const N=window.devicePixelRatio||1;R.height=R.width=s*N;const J=s/_*N;O.scale(J,J),O.fillStyle=g,O.fillRect(0,0,_,_),O.fillStyle=c,i0?O.fill(new Path2D(Ol(D,E))):j.forEach(function(ae,ee){ae.forEach(function(F,U){F&&O.fillRect(U+E,ee+E,1,1)})}),I&&(O.globalAlpha=I.opacity),Y&&O.drawImage(M,I.x+E,I.y+E,I.w,I.h)}}),i.useEffect(()=>{f(!1)},[y]);const P=pa({height:s,width:s},$);let T=null;return y!=null&&(T=i.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{f(!0)},ref:k,crossOrigin:I==null?void 0:I.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",pa({style:P,height:s,width:s,ref:S,role:"img"},z)),T)});c0.displayName="QRCodeCanvas";var Sa=i.forwardRef(function(r,o){const n=r,{value:a,size:s=zl,level:h=El,bgColor:g=Pl,fgColor:c=Rl,includeMargin:p=Il,minVersion:l=Tl,boostLevel:d,title:m,marginSize:x,imageSettings:v}=n,w=ha(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:$,cells:z,numCells:y,calculatedImageSettings:C}=Ll({value:a,level:h,minVersion:l,boostLevel:d,includeMargin:p,marginSize:x,imageSettings:v,size:s});let k=z,S=null;v!=null&&C!=null&&(C.excavation!=null&&(k=Ml(z,C.excavation)),S=i.createElement("image",{href:v.src,height:C.h,width:C.w,x:C.x+$,y:C.y+$,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const b=Ol(k,$);return i.createElement("svg",pa({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:o,role:"img"},w),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:g,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:b,shapeRendering:"crispEdges"}),S)});Sa.displayName="QRCodeSVG";const l0=u.div`
3510
3514
  position: fixed;
3511
3515
  background: var(--color-background);
3512
3516
  border-radius: var(--radius-md);
@@ -3545,7 +3549,7 @@ cursor: pointer;
3545
3549
  justify-content: center;
3546
3550
  color: var(--color-muted);
3547
3551
  flex-shrink: 0;
3548
- `,ti=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:a,triggerRef:s})=>{const p=i.useRef(null),[g,c]=i.useState(!1),[h,d]=i.useState({top:0,left:0}),{toast:l}=It();i.useEffect(()=>{c(!0);const b=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const j=s.current;if(j){const S=j.getBoundingClientRect(),R=380,E=300,T=8;let P=0,O=0;const D=window.innerHeight-S.bottom,M=S.top;D>=E+T?(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):M>=E+T?(P=S.top-E-T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left)),d({top:P,left:O})}},10),f=j=>{p.current&&!p.current.contains(j.target)&&t()},I=j=>{j.key==="Escape"&&t()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",I),()=>{clearTimeout(b),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",I)}},[t,s]);const[m,x]=i.useState(a?"otp":"email"),[v,w]=i.useState(a||""),[C,$]=i.useState(""),[y,z]=i.useState(!1),_=async()=>{if(!(!v||y)){z(!0);try{await r(v),x("otp")}catch(b){const f=b.message||"Failed to add email address. Please try again.";l(f,"error")}finally{z(!1)}}},k=async()=>{z(!0);try{await o(C),t()}catch(b){const f=b.message||"Failed to verify email. Please check the code and try again.";l(f,"error")}finally{z(!1)}};return g?e.jsx(l0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx(ei,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(d0,{children:[e.jsx(u0,{children:e.jsx(Wr,{size:16})}),e.jsx(de,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:b=>w(b.target.value),style:{flex:1}})]})}),e.jsxs(Js,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:_,disabled:!v||y,style:{width:"auto",padding:"0 var(--space-md)"},children:y?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ei,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",v]}),e.jsx(Rt,{onComplete:async b=>$(b),onResend:n,isSubmitting:y}),e.jsxs(Js,{children:[e.jsx(K,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(K,{onClick:k,disabled:C.length<6||y,style:{width:"auto",padding:"0 var(--space-md)"},children:y?"Verifying...":"Verify"})]})]})}):null},p0=u.div`
3552
+ `,ti=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:a,triggerRef:s})=>{const h=i.useRef(null),[g,c]=i.useState(!1),[p,l]=i.useState({top:0,left:0}),{toast:d}=It();i.useEffect(()=>{c(!0);const b=setTimeout(()=>{if(!h.current||!(s!=null&&s.current))return;const j=s.current;if(j){const _=j.getBoundingClientRect(),I=380,P=300,T=8;let R=0,O=0;const D=window.innerHeight-_.bottom,M=_.top;D>=P+T?(R=_.bottom+T,O=_.right-I,O<T&&(O=_.left,O+I>window.innerWidth-T&&(O=(window.innerWidth-I)/2))):M>=P+T?(R=_.top-P-T,O=_.right-I,O<T&&(O=_.left,O+I>window.innerWidth-T&&(O=(window.innerWidth-I)/2))):(R=_.bottom+T,O=_.right-I,O<T&&(O=_.left)),l({top:R,left:O})}},10),f=j=>{h.current&&!h.current.contains(j.target)&&t()},E=j=>{j.key==="Escape"&&t()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",E),()=>{clearTimeout(b),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",E)}},[t,s]);const[m,x]=i.useState(a?"otp":"email"),[v,w]=i.useState(a||""),[$,z]=i.useState(""),[y,C]=i.useState(!1),k=async()=>{if(!(!v||y)){C(!0);try{await r(v),x("otp")}catch(b){const f=b.message||"Failed to add email address. Please try again.";d(f,"error")}finally{C(!1)}}},S=async()=>{C(!0);try{await o($),t()}catch(b){const f=b.message||"Failed to verify email. Please check the code and try again.";d(f,"error")}finally{C(!1)}};return g?e.jsx(l0,{ref:h,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx(ei,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(d0,{children:[e.jsx(u0,{children:e.jsx(Vr,{size:16})}),e.jsx(de,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:b=>w(b.target.value),style:{flex:1}})]})}),e.jsxs(Js,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:k,disabled:!v||y,style:{width:"auto",padding:"0 var(--space-md)"},children:y?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ei,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",v]}),e.jsx(Rt,{onComplete:async b=>z(b),onResend:n,isSubmitting:y}),e.jsxs(Js,{children:[e.jsx(Q,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(Q,{onClick:S,disabled:$.length<6||y,style:{width:"auto",padding:"0 var(--space-md)"},children:y?"Verifying...":"Verify"})]})]})}):null},p0=u.div`
3549
3553
  position: fixed;
3550
3554
  background: var(--color-background);
3551
3555
  border-radius: var(--radius-md);
@@ -3569,7 +3573,7 @@ cursor: pointer;
3569
3573
  font-weight: 400;
3570
3574
  color: var(--color-foreground);
3571
3575
  margin-bottom: 12px;
3572
- `,ni=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:a,triggerRef:s})=>{var I;const p=i.useRef(null),[g,c]=i.useState(!1),[h,d]=i.useState({top:0,left:0}),{toast:l}=It();i.useEffect(()=>{c(!0);const j=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const E=s.current;if(E){const T=E.getBoundingClientRect(),P=380,O=300,D=8;let M=0,N=0;const F=window.innerHeight-T.bottom,J=T.top;F>=O+D?(M=T.bottom+D,N=T.right-P,N<D&&(N=T.left,N+P>window.innerWidth-D&&(N=(window.innerWidth-P)/2))):J>=O+D?(M=T.top-O-D,N=T.right-P,N<D&&(N=T.left,N+P>window.innerWidth-D&&(N=(window.innerWidth-P)/2))):(M=T.bottom+D,N=T.right-P,N<D&&(N=T.left)),d({top:M,left:N})}},10),S=E=>{p.current&&!p.current.contains(E.target)&&t()},R=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",R),()=>{clearTimeout(j),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",R)}},[t,s]);const[m,x]=i.useState(n?"otp":"phone"),[v,w]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[C,$]=i.useState((I=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:I.pop()),[y,z]=i.useState(""),[_,k]=i.useState(!1),b=async()=>{if(!(!v||_)){k(!0);try{await r(v,C||""),x("otp")}catch(j){const S=j.message||"Failed to add phone number. Please try again.";l(S,"error")}finally{k(!1)}}},f=async()=>{k(!0);try{await o(y),t()}catch(j){const S=j.message||"Failed to verify phone. Please check the code and try again.";l(S,"error")}finally{k(!1)}};return g?e.jsx(p0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(oi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(Br,{value:v,onChange:j=>w(j.target.value),error:"",countryCode:C,setCountryCode:$})}),e.jsxs(ri,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:b,disabled:!v||_,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(Rt,{onComplete:j=>z(j),onResend:async()=>a()})}),e.jsxs(ri,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:f,disabled:y.length!==6||_,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},h0=u.div`
3576
+ `,ni=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:a,triggerRef:s})=>{var E;const h=i.useRef(null),[g,c]=i.useState(!1),[p,l]=i.useState({top:0,left:0}),{toast:d}=It();i.useEffect(()=>{c(!0);const j=setTimeout(()=>{if(!h.current||!(s!=null&&s.current))return;const P=s.current;if(P){const T=P.getBoundingClientRect(),R=380,O=300,D=8;let M=0,Y=0;const N=window.innerHeight-T.bottom,J=T.top;N>=O+D?(M=T.bottom+D,Y=T.right-R,Y<D&&(Y=T.left,Y+R>window.innerWidth-D&&(Y=(window.innerWidth-R)/2))):J>=O+D?(M=T.top-O-D,Y=T.right-R,Y<D&&(Y=T.left,Y+R>window.innerWidth-D&&(Y=(window.innerWidth-R)/2))):(M=T.bottom+D,Y=T.right-R,Y<D&&(Y=T.left)),l({top:M,left:Y})}},10),_=P=>{h.current&&!h.current.contains(P.target)&&t()},I=P=>{P.key==="Escape"&&t()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",I),()=>{clearTimeout(j),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",I)}},[t,s]);const[m,x]=i.useState(n?"otp":"phone"),[v,w]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[$,z]=i.useState((E=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:E.pop()),[y,C]=i.useState(""),[k,S]=i.useState(!1),b=async()=>{if(!(!v||k)){S(!0);try{await r(v,$||""),x("otp")}catch(j){const _=j.message||"Failed to add phone number. Please try again.";d(_,"error")}finally{S(!1)}}},f=async()=>{S(!0);try{await o(y),t()}catch(j){const _=j.message||"Failed to verify phone. Please check the code and try again.";d(_,"error")}finally{S(!1)}};return g?e.jsx(p0,{ref:h,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(oi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(Ur,{value:v,onChange:j=>w(j.target.value),error:"",countryCode:$,setCountryCode:z})}),e.jsxs(ri,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:b,disabled:!v||k,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(Rt,{onComplete:j=>C(j),onResend:async()=>a()})}),e.jsxs(ri,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:f,disabled:y.length!==6||k,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},h0=u.div`
3573
3577
  position: fixed;
3574
3578
  background: var(--color-background);
3575
3579
  border-radius: var(--radius-md);
@@ -3612,7 +3616,7 @@ cursor: pointer;
3612
3616
  font-weight: 400;
3613
3617
  color: var(--color-foreground);
3614
3618
  margin-bottom: 8px;
3615
- `,f0=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const a=i.useRef(null),[s,p]=i.useState("qr"),[g,c]=i.useState(""),[h,d]=i.useState(""),[l,m]=i.useState(["",""]),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState({top:0,left:0}),{toast:z}=It();i.useEffect(()=>{C(!0);const k=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const I=n.current;if(I){const j=I.getBoundingClientRect(),S=380,R=400,E=8;let T=0,P=0;const O=window.innerHeight-j.bottom,D=j.top;O>=R+E?(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):D>=R+E?(T=j.top-R-E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left)),y({top:T,left:P})}},10),b=I=>{a.current&&!a.current.contains(I.target)&&t()},f=I=>{I.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(k),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,n]),i.useEffect(()=>{(async()=>{v(!0);try{const b=await r();c(b.otp_url||""),d(b.totp_secret||"")}catch(b){const f=b.message||"Failed to setup two-factor authentication. Please try again.";z(f,"error")}finally{v(!1)}})()},[]);const _=async()=>{if(!l.some(k=>k.length!==6)){v(!0);try{await o(l),t()}catch(k){const b=k.message||"Failed to verify codes. Please check your authenticator app and try again.";z(b,"error")}finally{v(!1)}}};return w?e.jsx(h0,{ref:a,style:{top:`${$.top}px`,left:`${$.left}px`,visibility:$.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),children:s==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(si,{children:"Setup Two-Factor Authentication"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:x?e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)"},children:"Loading..."}):g?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Sa,{value:g,size:150,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)",color:"var(--color-error)"},children:"QR Code Not Available"})}),h&&e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",marginBottom:"16px",fontSize:"12px"},children:[e.jsx("div",{style:{color:"var(--color-secondary-text)",marginBottom:"4px"},children:"Or enter manually:"}),e.jsx("code",{style:{fontFamily:"monospace",wordBreak:"break-all",color:"var(--color-secondary-text)"},children:h})]}),e.jsx(ai,{children:e.jsx(Fn,{$primary:!0,onClick:()=>p("verify"),disabled:x||!g,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(si,{children:"Verify Your Authenticator"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Enter two consecutive codes from your authenticator app"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:[e.jsx(de,{id:"totp-code-1",type:"text",placeholder:"000000",value:l[0],onChange:k=>{const b=k.target.value.replace(/[^0-9]/g,"").substring(0,6);m([b,l[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(de,{id:"totp-code-2",type:"text",placeholder:"000000",value:l[1],onChange:k=>{const b=k.target.value.replace(/[^0-9]/g,"").substring(0,6);m([l[0],b])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(ai,{children:[e.jsx(Fn,{onClick:()=>p("qr"),children:"Back"}),e.jsx(Fn,{$primary:!0,onClick:_,disabled:x||l.some(k=>k.length!==6),children:x?"Verifying...":"Verify"})]})]})}):null},g0=u.div`
3619
+ `,f0=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const a=i.useRef(null),[s,h]=i.useState("qr"),[g,c]=i.useState(""),[p,l]=i.useState(""),[d,m]=i.useState(["",""]),[x,v]=i.useState(!1),[w,$]=i.useState(!1),[z,y]=i.useState({top:0,left:0}),{toast:C}=It();i.useEffect(()=>{$(!0);const S=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const E=n.current;if(E){const j=E.getBoundingClientRect(),_=380,I=400,P=8;let T=0,R=0;const O=window.innerHeight-j.bottom,D=j.top;O>=I+P?(T=j.bottom+P,R=j.right-_,R<P&&(R=j.left,R+_>window.innerWidth-P&&(R=(window.innerWidth-_)/2))):D>=I+P?(T=j.top-I-P,R=j.right-_,R<P&&(R=j.left,R+_>window.innerWidth-P&&(R=(window.innerWidth-_)/2))):(T=j.bottom+P,R=j.right-_,R<P&&(R=j.left)),y({top:T,left:R})}},10),b=E=>{a.current&&!a.current.contains(E.target)&&t()},f=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(S),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,n]),i.useEffect(()=>{(async()=>{v(!0);try{const b=await r();c(b.otp_url||""),l(b.totp_secret||"")}catch(b){const f=b.message||"Failed to setup two-factor authentication. Please try again.";C(f,"error")}finally{v(!1)}})()},[]);const k=async()=>{if(!d.some(S=>S.length!==6)){v(!0);try{await o(d),t()}catch(S){const b=S.message||"Failed to verify codes. Please check your authenticator app and try again.";C(b,"error")}finally{v(!1)}}};return w?e.jsx(h0,{ref:a,style:{top:`${z.top}px`,left:`${z.left}px`,visibility:z.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),children:s==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(si,{children:"Setup Two-Factor Authentication"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:x?e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)"},children:"Loading..."}):g?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Sa,{value:g,size:150,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)",color:"var(--color-error)"},children:"QR Code Not Available"})}),p&&e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",marginBottom:"16px",fontSize:"12px"},children:[e.jsx("div",{style:{color:"var(--color-secondary-text)",marginBottom:"4px"},children:"Or enter manually:"}),e.jsx("code",{style:{fontFamily:"monospace",wordBreak:"break-all",color:"var(--color-secondary-text)"},children:p})]}),e.jsx(ai,{children:e.jsx(Fn,{$primary:!0,onClick:()=>h("verify"),disabled:x||!g,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(si,{children:"Verify Your Authenticator"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Enter two consecutive codes from your authenticator app"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:[e.jsx(de,{id:"totp-code-1",type:"text",placeholder:"000000",value:d[0],onChange:S=>{const b=S.target.value.replace(/[^0-9]/g,"").substring(0,6);m([b,d[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(de,{id:"totp-code-2",type:"text",placeholder:"000000",value:d[1],onChange:S=>{const b=S.target.value.replace(/[^0-9]/g,"").substring(0,6);m([d[0],b])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(ai,{children:[e.jsx(Fn,{onClick:()=>h("qr"),children:"Back"}),e.jsx(Fn,{$primary:!0,onClick:k,disabled:x||d.some(S=>S.length!==6),children:x?"Verifying...":"Verify"})]})]})}):null},g0=u.div`
3616
3620
  position: fixed;
3617
3621
  background: var(--color-background);
3618
3622
  border-radius: var(--radius-md);
@@ -3678,11 +3682,11 @@ cursor: pointer;
3678
3682
  color: var(--color-foreground);
3679
3683
  }
3680
3684
  }
3681
- `,wo=u.div`
3685
+ `,jo=u.div`
3682
3686
  color: var(--color-error);
3683
3687
  font-size: 12px;
3684
3688
  margin-top: 4px;
3685
- `,ci=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const a=i.useRef(null),[s,p]=i.useState(!1),[g,c]=i.useState({top:0,left:0}),[h,d]=i.useState(""),[l,m]=i.useState(""),[x,v]=i.useState(""),[w,C]=i.useState(!1),[$,y]=i.useState(!1),[z,_]=i.useState(!1),[k,b]=i.useState(!1),[f,I]=i.useState({});i.useEffect(()=>{p(!0);const S=setTimeout(()=>{if(!a.current||!(o!=null&&o.current))return;const T=o.current;if(T){const P=T.getBoundingClientRect(),O=380,D=350,M=8;let N=0,F=0;const J=window.innerHeight-P.bottom,ie=P.top;J>=D+M?(N=P.bottom+M,F=P.right-O,F<M&&(F=P.left,F+O>window.innerWidth-M&&(F=(window.innerWidth-O)/2))):ie>=D+M?(N=P.top-D-M,F=P.right-O,F<M&&(F=P.left,F+O>window.innerWidth-M&&(F=(window.innerWidth-O)/2))):(N=P.bottom+M,F=P.right-O,F<M&&(F=P.left)),c({top:N,left:F})}},10),R=T=>{a.current&&!a.current.contains(T.target)&&t()},E=T=>{T.key==="Escape"&&t()};return document.addEventListener("mousedown",R),document.addEventListener("keydown",E),()=>{clearTimeout(S),document.removeEventListener("mousedown",R),document.removeEventListener("keydown",E)}},[t,o]);const j=async()=>{if(k)return;const S={};if(!n&&!h&&(S.currentPassword="Current password is required"),l?l.length<8&&(S.newPassword="Password must be at least 8 characters"):S.newPassword="New password is required",l!==x&&(S.confirmPassword="Passwords do not match"),Object.keys(S).length>0){I(S);return}b(!0);try{await r(n?"":h,l),t()}catch(R){I({form:R.message||"Failed to update password"})}finally{b(!1)}};return s?e.jsxs(g0,{ref:a,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),children:[e.jsx(x0,{children:n?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&e.jsxs(Bn,{children:[e.jsx(ue,{children:"Current Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:w?"text":"password",placeholder:"Enter your current password",value:h,onChange:S=>d(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>C(!w),"aria-label":w?"Hide current password":"Show current password",children:w?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.currentPassword&&e.jsx(wo,{children:f.currentPassword})]}),e.jsxs(Bn,{children:[e.jsx(ue,{children:n?"Password":"New Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:$?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:l,onChange:S=>m(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>y(!$),"aria-label":$?"Hide new password":"Show new password",children:$?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.newPassword&&e.jsx(wo,{children:f.newPassword})]}),e.jsxs(Bn,{children:[e.jsx(ue,{children:"Confirm New Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:z?"text":"password",placeholder:"Confirm your new password",value:x,onChange:S=>v(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>_(!z),"aria-label":z?"Hide confirm password":"Show confirm password",children:z?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.confirmPassword&&e.jsx(wo,{children:f.confirmPassword})]}),f.form&&e.jsx(wo,{children:f.form}),e.jsxs(m0,{children:[e.jsx(ii,{onClick:t,children:"Cancel"}),e.jsx(ii,{$primary:!0,onClick:j,disabled:k,children:k?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},v0=u.div`
3689
+ `,ci=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const a=i.useRef(null),[s,h]=i.useState(!1),[g,c]=i.useState({top:0,left:0}),[p,l]=i.useState(""),[d,m]=i.useState(""),[x,v]=i.useState(""),[w,$]=i.useState(!1),[z,y]=i.useState(!1),[C,k]=i.useState(!1),[S,b]=i.useState(!1),[f,E]=i.useState({});i.useEffect(()=>{h(!0);const _=setTimeout(()=>{if(!a.current||!(o!=null&&o.current))return;const T=o.current;if(T){const R=T.getBoundingClientRect(),O=380,D=350,M=8;let Y=0,N=0;const J=window.innerHeight-R.bottom,ae=R.top;J>=D+M?(Y=R.bottom+M,N=R.right-O,N<M&&(N=R.left,N+O>window.innerWidth-M&&(N=(window.innerWidth-O)/2))):ae>=D+M?(Y=R.top-D-M,N=R.right-O,N<M&&(N=R.left,N+O>window.innerWidth-M&&(N=(window.innerWidth-O)/2))):(Y=R.bottom+M,N=R.right-O,N<M&&(N=R.left)),c({top:Y,left:N})}},10),I=T=>{a.current&&!a.current.contains(T.target)&&t()},P=T=>{T.key==="Escape"&&t()};return document.addEventListener("mousedown",I),document.addEventListener("keydown",P),()=>{clearTimeout(_),document.removeEventListener("mousedown",I),document.removeEventListener("keydown",P)}},[t,o]);const j=async()=>{if(S)return;const _={};if(!n&&!p&&(_.currentPassword="Current password is required"),d?d.length<8&&(_.newPassword="Password must be at least 8 characters"):_.newPassword="New password is required",d!==x&&(_.confirmPassword="Passwords do not match"),Object.keys(_).length>0){E(_);return}b(!0);try{await r(n?"":p,d),t()}catch(I){E({form:I.message||"Failed to update password"})}finally{b(!1)}};return s?e.jsxs(g0,{ref:a,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:[e.jsx(x0,{children:n?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&e.jsxs(Bn,{children:[e.jsx(ue,{children:"Current Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:w?"text":"password",placeholder:"Enter your current password",value:p,onChange:_=>l(_.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>$(!w),"aria-label":w?"Hide current password":"Show current password",children:w?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.currentPassword&&e.jsx(jo,{children:f.currentPassword})]}),e.jsxs(Bn,{children:[e.jsx(ue,{children:n?"Password":"New Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:z?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:d,onChange:_=>m(_.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>y(!z),"aria-label":z?"Hide new password":"Show new password",children:z?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.newPassword&&e.jsx(jo,{children:f.newPassword})]}),e.jsxs(Bn,{children:[e.jsx(ue,{children:"Confirm New Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:C?"text":"password",placeholder:"Confirm your new password",value:x,onChange:_=>v(_.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>k(!C),"aria-label":C?"Hide confirm password":"Show confirm password",children:C?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.confirmPassword&&e.jsx(jo,{children:f.confirmPassword})]}),f.form&&e.jsx(jo,{children:f.form}),e.jsxs(m0,{children:[e.jsx(ii,{onClick:t,children:"Cancel"}),e.jsx(ii,{$primary:!0,onClick:j,disabled:S,children:S?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},v0=u.div`
3686
3690
  position: fixed;
3687
3691
  background: var(--color-background);
3688
3692
  border-radius: var(--radius-md);
@@ -3720,7 +3724,7 @@ cursor: pointer;
3720
3724
  color: var(--color-warning-text, var(--color-foreground));
3721
3725
  margin: 0;
3722
3726
  line-height: 1.5;
3723
- `,k0=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(!1),[p,g]=i.useState({top:0,left:0}),[c,h]=i.useState(""),[d,l]=i.useState(!1),{toast:m}=It();i.useEffect(()=>{s(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const $=o.current;if($){const y=$.getBoundingClientRect(),z=400,_=300,k=8;let b=0,f=0;const I=window.innerHeight-y.bottom,j=y.top;I>=_+k?(b=y.bottom+k,f=y.right-z,f<k&&(f=y.left,f+z>window.innerWidth-k&&(f=(window.innerWidth-z)/2))):j>=_+k?(b=y.top-_-k,f=y.right-z,f<k&&(f=y.left,f+z>window.innerWidth-k&&(f=(window.innerWidth-z)/2))):(b=y.bottom+k,f=y.right-z,f<k&&(f=y.left)),g({top:b,left:f})}},10),w=$=>{n.current&&!n.current.contains($.target)&&t()},C=$=>{$.key==="Escape"&&t()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",C),()=>{clearTimeout(v),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",C)}},[t,o]);const x=async()=>{if(!(!c||d)){l(!0);try{await r(c),t()}catch(v){const w=v.message||"Failed to remove password. Please try again.";m(w,"error")}finally{l(!1)}}};return a?e.jsxs(v0,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(y0,{children:[e.jsx(ut,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(w0,{children:e.jsx(j0,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(de,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:v=>h(v.target.value),autoFocus:!0})]}),e.jsxs(b0,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:x,disabled:!c||d,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:d?"Removing...":"Remove Password"})]})]}):null},_0=u.div`
3727
+ `,k0=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(!1),[h,g]=i.useState({top:0,left:0}),[c,p]=i.useState(""),[l,d]=i.useState(!1),{toast:m}=It();i.useEffect(()=>{s(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const z=o.current;if(z){const y=z.getBoundingClientRect(),C=400,k=300,S=8;let b=0,f=0;const E=window.innerHeight-y.bottom,j=y.top;E>=k+S?(b=y.bottom+S,f=y.right-C,f<S&&(f=y.left,f+C>window.innerWidth-S&&(f=(window.innerWidth-C)/2))):j>=k+S?(b=y.top-k-S,f=y.right-C,f<S&&(f=y.left,f+C>window.innerWidth-S&&(f=(window.innerWidth-C)/2))):(b=y.bottom+S,f=y.right-C,f<S&&(f=y.left)),g({top:b,left:f})}},10),w=z=>{n.current&&!n.current.contains(z.target)&&t()},$=z=>{z.key==="Escape"&&t()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",$),()=>{clearTimeout(v),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",$)}},[t,o]);const x=async()=>{if(!(!c||l)){d(!0);try{await r(c),t()}catch(v){const w=v.message||"Failed to remove password. Please try again.";m(w,"error")}finally{d(!1)}}};return a?e.jsxs(v0,{ref:n,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(y0,{children:[e.jsx(ut,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(w0,{children:e.jsx(j0,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(de,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:v=>p(v.target.value),autoFocus:!0})]}),e.jsxs(b0,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:x,disabled:!c||l,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:l?"Removing...":"Remove Password"})]})]}):null},_0=u.div`
3724
3728
  position: fixed;
3725
3729
  background: var(--color-background);
3726
3730
  border-radius: var(--radius-md);
@@ -3786,7 +3790,7 @@ cursor: pointer;
3786
3790
  background: var(--color-input-background-hover);
3787
3791
  border-color: var(--color-primary);
3788
3792
  }
3789
- `,P0=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:a})=>{const s=i.useRef(null),[p,g]=i.useState(!1),[c,h]=i.useState({top:0,left:0});return i.useEffect(()=>{g(!0);const d=setTimeout(()=>{if(!s.current||!(a!=null&&a.current))return;const x=a.current;if(x){const v=x.getBoundingClientRect(),w=380,C=300,$=8;let y=0,z=0;const _=window.innerHeight-v.bottom,k=v.top;_>=C+$?(y=v.bottom+$,z=v.right-w,z<$&&(z=v.left,z+w>window.innerWidth-$&&(z=(window.innerWidth-w)/2))):k>=C+$?(y=v.top-C-$,z=v.right-w,z<$&&(z=v.left,z+w>window.innerWidth-$&&(z=(window.innerWidth-w)/2))):(y=v.bottom+$,z=v.right-w,z<$&&(z=v.left)),h({top:y,left:z})}},10),l=x=>{s.current&&!s.current.contains(x.target)&&r()},m=x=>{x.key==="Escape"&&r()};return document.addEventListener("mousedown",l),document.addEventListener("keydown",m),()=>{clearTimeout(d),document.removeEventListener("mousedown",l),document.removeEventListener("keydown",m)}},[r,a]),p?e.jsxs(_0,{ref:s,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:d=>d.stopPropagation(),children:[e.jsxs(C0,{children:[e.jsx(S0,{children:"Backup Codes"}),e.jsxs($0,{children:[e.jsxs(li,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Gc,{size:14}),"Copy"]}),e.jsxs(li,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Qo,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(z0,{children:t.map((d,l)=>e.jsx(E0,{onClick:()=>{navigator.clipboard.writeText(d)},title:"Click to copy",children:d},l))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},R0=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:48,height:48,...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),I0=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),T0=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),O0=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),M0=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),L0=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),A0=wr`
3793
+ `,P0=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:a})=>{const s=i.useRef(null),[h,g]=i.useState(!1),[c,p]=i.useState({top:0,left:0});return i.useEffect(()=>{g(!0);const l=setTimeout(()=>{if(!s.current||!(a!=null&&a.current))return;const x=a.current;if(x){const v=x.getBoundingClientRect(),w=380,$=300,z=8;let y=0,C=0;const k=window.innerHeight-v.bottom,S=v.top;k>=$+z?(y=v.bottom+z,C=v.right-w,C<z&&(C=v.left,C+w>window.innerWidth-z&&(C=(window.innerWidth-w)/2))):S>=$+z?(y=v.top-$-z,C=v.right-w,C<z&&(C=v.left,C+w>window.innerWidth-z&&(C=(window.innerWidth-w)/2))):(y=v.bottom+z,C=v.right-w,C<z&&(C=v.left)),p({top:y,left:C})}},10),d=x=>{s.current&&!s.current.contains(x.target)&&r()},m=x=>{x.key==="Escape"&&r()};return document.addEventListener("mousedown",d),document.addEventListener("keydown",m),()=>{clearTimeout(l),document.removeEventListener("mousedown",d),document.removeEventListener("keydown",m)}},[r,a]),h?e.jsxs(_0,{ref:s,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:l=>l.stopPropagation(),children:[e.jsxs(C0,{children:[e.jsx(S0,{children:"Backup Codes"}),e.jsxs($0,{children:[e.jsxs(li,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Gc,{size:14}),"Copy"]}),e.jsxs(li,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Qo,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(z0,{children:t.map((l,d)=>e.jsx(E0,{onClick:()=>{navigator.clipboard.writeText(l)},title:"Click to copy",children:l},d))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},R0=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:48,height:48,...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),I0=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),T0=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),O0=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),M0=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),L0=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),A0=jr`
3790
3794
  0% { transform: rotate(0deg); }
3791
3795
  100% { transform: rotate(360deg); }
3792
3796
  `,D0=u.div`
@@ -3921,7 +3925,7 @@ cursor: pointer;
3921
3925
  flex-wrap: wrap;
3922
3926
  gap: 12px;
3923
3927
  margin-bottom: 0;
3924
- `,U0=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),W0=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(R0,{...o}):r.includes("firefox")?e.jsx(I0,{...o}):r.includes("safari")?e.jsx(T0,{...o}):r.includes("edge")?e.jsx(O0,{...o}):r.includes("opera")?e.jsx(M0,{...o}):r.includes("brave")?e.jsx(L0,{...o}):e.jsx(U0,{})},V0=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:a,loading:s}=tc(),{refetch:p}=Fe(),{toast:g}=It(),c=o,h=async l=>{try{await n(l),await Promise.all([a(),p()]),r(null),g("Session ended successfully","info")}catch(m){g(m.message||"Failed to end session. Please try again.","error")}},d=l=>{if(!l||l.trim()==="")return"Unknown";const m=new Date(l);if(isNaN(m.getTime()))return"Unknown";const v=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return v<1?"Just now":v<60?`${v}m ago`:v<1440?`${Math.floor(v/60)}h ago`:m.toLocaleDateString()};return s?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:c&&c.length>0?e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Browser & Device"}),e.jsx(Ce,{children:"Location"}),e.jsx(Ce,{children:"Last Active"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:c.map(l=>e.jsxs(Ue,{children:[e.jsx(Oe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Al,{children:e.jsx(W0,{browser:l.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:l.browser||"Unknown Browser"}),l.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:l.device})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{children:[e.jsx("div",{children:l.city&&l.country?`${l.city}, ${l.country}`:"Unknown location"}),l.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:l.ip_address})]})}),e.jsx(Oe,{children:d(l.last_active_at)}),e.jsx(Ct,{children:e.jsxs(ot,{open:t===l.id,openChange:m=>r(m?l.id:null),children:[e.jsx(at,{children:e.jsx(nn,{children:"•••"})}),e.jsx(nt,{children:e.jsx(Pe,{onClick:()=>h(l.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(zt,{size:14}),"End Session"]})})})]})})]},l.id))})]}):e.jsx(it,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},G0=()=>{var b,f,I,j;const{deployment:t}=ve(),{toast:r}=It(),[o,n]=i.useState(null),[a,s]=i.useState(""),[p,g]=i.useState(!1),[c,h]=i.useState(null),[d,l]=i.useState(""),m=i.useRef(null),x=i.useRef({}),{user:v,createEmailAddress:w,deleteEmailAddress:C,prepareEmailVerification:$,attemptEmailVerification:y,makeEmailPrimary:z}=rr();if(!((f=(b=t==null?void 0:t.auth_settings)==null?void 0:b.email_address)!=null&&f.enabled))return null;const _=async S=>{try{if(S===(v==null?void 0:v.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await C(S),v.refetch(),r("Email address deleted successfully","info")}catch(R){r(R.message||"Failed to delete email address. Please try again.","error")}},k=i.useMemo(()=>v!=null&&v.user_email_addresses?d.trim()?v.user_email_addresses.filter(S=>S.email.toLowerCase().includes(d.toLowerCase())):v.user_email_addresses:[],[v==null?void 0:v.user_email_addresses,d]);return e.jsxs(e.Fragment,{children:[e.jsxs(Bo,{style:{marginBottom:"20px"},children:[e.jsx(wt,{value:d,onChange:l,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:m,onClick:()=>g(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),p&&e.jsx(ti,{triggerRef:m,onClose:()=>g(!1),onAddEmail:async S=>{const R=await w(S);s(R.data.id),await $(R.data.id),v.refetch()},onPrepareVerification:async()=>{await $(a),v.refetch()},onAttemptVerification:async S=>{await y(a,S),v.refetch(),g(!1),s(""),r("Email added and verified successfully!","info")}})]})]}),k!=null&&k.length?e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Email Address"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:k.map(S=>e.jsxs(Ue,{children:[e.jsx(Oe,{children:S.email}),e.jsx(Oe,{children:S.id===(v==null?void 0:v.primary_email_address_id)?"Primary":S.verified?"Verified":"Not Verified"}),e.jsx(Ct,{children:S.id!==(v==null?void 0:v.primary_email_address_id)||!S.verified?e.jsxs(ot,{open:o===S.id,openChange:R=>n(R?S.id:null),children:[e.jsx(at,{children:e.jsx(nn,{ref:R=>{R&&(x.current[S.id]=R)},children:"•••"})}),e.jsxs(nt,{children:[S.id!==(v==null?void 0:v.primary_email_address_id)&&S.verified&&e.jsx(Pe,{onClick:async()=>{try{await z(S.id),v.refetch(),n(null),r("Primary email updated successfully","info")}catch(R){r(R.message||"Failed to update primary email","error")}},children:"Make primary"}),!S.verified&&e.jsx(Pe,{onClick:async()=>{n(null),await $(S.id),h(S.id)},children:"Verify email"}),S.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Pe,{$destructive:!0,onClick:()=>{_(S.id),n(null)},children:"Remove"})]})]}):null})]},S.id))})]}):e.jsx(it,{title:d?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(ti,{existingEmail:(j=(I=v==null?void 0:v.user_email_addresses)==null?void 0:I.find(S=>S.id===c))==null?void 0:j.email,triggerRef:{current:x.current[c]},onClose:()=>h(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await $(c),v.refetch()},onAttemptVerification:async S=>{await y(c,S),v.refetch(),h(null),r("Email verified successfully!","info")}})]})},H0=()=>{var k,b,f,I;const{deployment:t}=ve(),[r,o]=i.useState(null),[n,a]=i.useState(""),[s,p]=i.useState(!1),[g,c]=i.useState(null),[h,d]=i.useState(""),l=i.useRef(null),m=i.useRef({}),{user:x,createPhoneNumber:v,deletePhoneNumber:w,preparePhoneVerification:C,attemptPhoneVerification:$,makePhonePrimary:y}=rr();if(!((b=(k=t==null?void 0:t.auth_settings)==null?void 0:k.phone_number)!=null&&b.enabled))return null;const z=j=>{const S=Eo.find(R=>R.dialCode===j);return(S==null?void 0:S.flag)||"🌍"},_=i.useMemo(()=>x!=null&&x.user_phone_numbers?h.trim()?x.user_phone_numbers.filter(j=>j.phone_number.toLowerCase().includes(h.toLowerCase())):x.user_phone_numbers:[],[x==null?void 0:x.user_phone_numbers,h]);return e.jsxs(e.Fragment,{children:[e.jsxs(Bo,{style:{marginBottom:"20px"},children:[e.jsx(wt,{value:h,onChange:d,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:l,onClick:()=>p(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),s&&e.jsx(ni,{triggerRef:l,onClose:()=>p(!1),onAddPhone:async(j,S)=>{const R=await v(j,S);a(R.data.id),await C(R.data.id)},onPrepareVerification:async()=>{await C(n),x.refetch()},onAttemptVerification:async j=>{await $(n,j),x.refetch(),p(!1)}}),g&&e.jsx(ni,{existingPhone:(I=(f=x==null?void 0:x.user_phone_numbers)==null?void 0:f.find(j=>j.id===g))==null?void 0:I.phone_number,triggerRef:{current:m.current[g]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await C(g),x.refetch()},onAttemptVerification:async j=>{await $(g,j),x.refetch(),c(null)}})]})]}),_!=null&&_.length?e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Phone Number"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:_.map(j=>e.jsxs(Ue,{children:[e.jsx(Oe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:z(j.country_code)}),e.jsx("span",{children:j.country_code}),e.jsx("span",{children:j.phone_number})]})}),e.jsx(Oe,{children:j.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx(Ct,{children:e.jsxs(ot,{open:r===j.id,openChange:S=>o(S?j.id:null),children:[e.jsx(at,{children:e.jsx(nn,{ref:S=>{S&&(m.current[j.id]=S)},children:"•••"})}),e.jsxs(nt,{children:[j.id!==(x==null?void 0:x.primary_phone_number_id)&&j.verified&&e.jsx(Pe,{onClick:async()=>{await y(j.id),o(null),x.refetch()},children:"Make primary"}),!j.verified&&e.jsx(Pe,{onClick:async()=>{await C(j.id),c(j.id),o(null)},children:"Verify phone"}),e.jsx(Pe,{$destructive:!0,onClick:async()=>{await w(j.id),o(null),x.refetch()},children:"Remove"})]})]})})]},j.id))})]}):e.jsx(it,{title:h?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},Al=u.div`
3928
+ `,U0=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),W0=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(R0,{...o}):r.includes("firefox")?e.jsx(I0,{...o}):r.includes("safari")?e.jsx(T0,{...o}):r.includes("edge")?e.jsx(O0,{...o}):r.includes("opera")?e.jsx(M0,{...o}):r.includes("brave")?e.jsx(L0,{...o}):e.jsx(U0,{})},V0=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:a,loading:s}=tc(),{refetch:h}=Fe(),{toast:g}=It(),c=o,p=async d=>{try{await n(d),await Promise.all([a(),h()]),r(null),g("Session ended successfully","info")}catch(m){g(m.message||"Failed to end session. Please try again.","error")}},l=d=>{if(!d||d.trim()==="")return"Unknown";const m=new Date(d);if(isNaN(m.getTime()))return"Unknown";const v=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return v<1?"Just now":v<60?`${v}m ago`:v<1440?`${Math.floor(v/60)}h ago`:m.toLocaleDateString()};return s?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:c&&c.length>0?e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Browser & Device"}),e.jsx(Ce,{children:"Location"}),e.jsx(Ce,{children:"Last Active"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:c.map(d=>e.jsxs(Ue,{children:[e.jsx(Oe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Al,{children:e.jsx(W0,{browser:d.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:d.browser||"Unknown Browser"}),d.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:d.device})]})]})}),e.jsx(Oe,{children:e.jsxs("div",{children:[e.jsx("div",{children:d.city&&d.country?`${d.city}, ${d.country}`:"Unknown location"}),d.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:d.ip_address})]})}),e.jsx(Oe,{children:l(d.last_active_at)}),e.jsx(Ct,{children:e.jsxs(ot,{open:t===d.id,openChange:m=>r(m?d.id:null),children:[e.jsx(at,{children:e.jsx(nn,{children:"•••"})}),e.jsx(nt,{children:e.jsx(Pe,{onClick:()=>p(d.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(zt,{size:14}),"End Session"]})})})]})})]},d.id))})]}):e.jsx(it,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},G0=()=>{var b,f,E,j;const{deployment:t}=xe(),{toast:r}=It(),[o,n]=i.useState(null),[a,s]=i.useState(""),[h,g]=i.useState(!1),[c,p]=i.useState(null),[l,d]=i.useState(""),m=i.useRef(null),x=i.useRef({}),{user:v,createEmailAddress:w,deleteEmailAddress:$,prepareEmailVerification:z,attemptEmailVerification:y,makeEmailPrimary:C}=rr();if(!((f=(b=t==null?void 0:t.auth_settings)==null?void 0:b.email_address)!=null&&f.enabled))return null;const k=async _=>{try{if(_===(v==null?void 0:v.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await $(_),v.refetch(),r("Email address deleted successfully","info")}catch(I){r(I.message||"Failed to delete email address. Please try again.","error")}},S=i.useMemo(()=>v!=null&&v.user_email_addresses?l.trim()?v.user_email_addresses.filter(_=>_.email.toLowerCase().includes(l.toLowerCase())):v.user_email_addresses:[],[v==null?void 0:v.user_email_addresses,l]);return e.jsxs(e.Fragment,{children:[e.jsxs(Bo,{style:{marginBottom:"20px"},children:[e.jsx(wt,{value:l,onChange:d,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:m,onClick:()=>g(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),h&&e.jsx(ti,{triggerRef:m,onClose:()=>g(!1),onAddEmail:async _=>{const I=await w(_);s(I.data.id),await z(I.data.id),v.refetch()},onPrepareVerification:async()=>{await z(a),v.refetch()},onAttemptVerification:async _=>{await y(a,_),v.refetch(),g(!1),s(""),r("Email added and verified successfully!","info")}})]})]}),S!=null&&S.length?e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Email Address"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:S.map(_=>e.jsxs(Ue,{children:[e.jsx(Oe,{children:_.email}),e.jsx(Oe,{children:_.id===(v==null?void 0:v.primary_email_address_id)?"Primary":_.verified?"Verified":"Not Verified"}),e.jsx(Ct,{children:_.id!==(v==null?void 0:v.primary_email_address_id)||!_.verified?e.jsxs(ot,{open:o===_.id,openChange:I=>n(I?_.id:null),children:[e.jsx(at,{children:e.jsx(nn,{ref:I=>{I&&(x.current[_.id]=I)},children:"•••"})}),e.jsxs(nt,{children:[_.id!==(v==null?void 0:v.primary_email_address_id)&&_.verified&&e.jsx(Pe,{onClick:async()=>{try{await C(_.id),v.refetch(),n(null),r("Primary email updated successfully","info")}catch(I){r(I.message||"Failed to update primary email","error")}},children:"Make primary"}),!_.verified&&e.jsx(Pe,{onClick:async()=>{n(null),await z(_.id),p(_.id)},children:"Verify email"}),_.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Pe,{$destructive:!0,onClick:()=>{k(_.id),n(null)},children:"Remove"})]})]}):null})]},_.id))})]}):e.jsx(it,{title:l?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(ti,{existingEmail:(j=(E=v==null?void 0:v.user_email_addresses)==null?void 0:E.find(_=>_.id===c))==null?void 0:j.email,triggerRef:{current:x.current[c]},onClose:()=>p(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await z(c),v.refetch()},onAttemptVerification:async _=>{await y(c,_),v.refetch(),p(null),r("Email verified successfully!","info")}})]})},H0=()=>{var S,b,f,E;const{deployment:t}=xe(),[r,o]=i.useState(null),[n,a]=i.useState(""),[s,h]=i.useState(!1),[g,c]=i.useState(null),[p,l]=i.useState(""),d=i.useRef(null),m=i.useRef({}),{user:x,createPhoneNumber:v,deletePhoneNumber:w,preparePhoneVerification:$,attemptPhoneVerification:z,makePhonePrimary:y}=rr();if(!((b=(S=t==null?void 0:t.auth_settings)==null?void 0:S.phone_number)!=null&&b.enabled))return null;const C=j=>{const _=Po.find(I=>I.dialCode===j);return(_==null?void 0:_.flag)||"🌍"},k=i.useMemo(()=>x!=null&&x.user_phone_numbers?p.trim()?x.user_phone_numbers.filter(j=>j.phone_number.toLowerCase().includes(p.toLowerCase())):x.user_phone_numbers:[],[x==null?void 0:x.user_phone_numbers,p]);return e.jsxs(e.Fragment,{children:[e.jsxs(Bo,{style:{marginBottom:"20px"},children:[e.jsx(wt,{value:p,onChange:l,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:d,onClick:()=>h(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),s&&e.jsx(ni,{triggerRef:d,onClose:()=>h(!1),onAddPhone:async(j,_)=>{const I=await v(j,_);a(I.data.id),await $(I.data.id)},onPrepareVerification:async()=>{await $(n),x.refetch()},onAttemptVerification:async j=>{await z(n,j),x.refetch(),h(!1)}}),g&&e.jsx(ni,{existingPhone:(E=(f=x==null?void 0:x.user_phone_numbers)==null?void 0:f.find(j=>j.id===g))==null?void 0:E.phone_number,triggerRef:{current:m.current[g]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await $(g),x.refetch()},onAttemptVerification:async j=>{await z(g,j),x.refetch(),c(null)}})]})]}),k!=null&&k.length?e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Phone Number"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(_t,{children:k.map(j=>e.jsxs(Ue,{children:[e.jsx(Oe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:C(j.country_code)}),e.jsx("span",{children:j.country_code}),e.jsx("span",{children:j.phone_number})]})}),e.jsx(Oe,{children:j.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx(Ct,{children:e.jsxs(ot,{open:r===j.id,openChange:_=>o(_?j.id:null),children:[e.jsx(at,{children:e.jsx(nn,{ref:_=>{_&&(m.current[j.id]=_)},children:"•••"})}),e.jsxs(nt,{children:[j.id!==(x==null?void 0:x.primary_phone_number_id)&&j.verified&&e.jsx(Pe,{onClick:async()=>{await y(j.id),o(null),x.refetch()},children:"Make primary"}),!j.verified&&e.jsx(Pe,{onClick:async()=>{await $(j.id),c(j.id),o(null)},children:"Verify phone"}),e.jsx(Pe,{$destructive:!0,onClick:async()=>{await w(j.id),o(null),x.refetch()},children:"Remove"})]})]})})]},j.id))})]}):e.jsx(it,{title:p?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},Al=u.div`
3925
3929
  width: 20px;
3926
3930
  height: 20px;
3927
3931
  flex-shrink: 0;
@@ -3936,9 +3940,9 @@ cursor: pointer;
3936
3940
  flex-shrink: 0;
3937
3941
  display: block;
3938
3942
  }
3939
- `,q0=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=rr(),{deployment:n}=ve(),a={google_oauth:{icon:e.jsx(Dc,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Ac,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(Lc,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(Bc,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(Fc,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(Uc,{}),label:"Discord"},x_oauth:{icon:e.jsx(Nc,{}),label:"X"}},s=(n==null?void 0:n.social_connections.filter(p=>p.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((p,g)=>{var d;const c=((d=t==null?void 0:t.social_connections)==null?void 0:d.filter(l=>l.provider===p.provider))||[],h=a[p.provider];return h?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(Al,{children:h.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:h.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(l=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:l.email_address}),e.jsx(nn,{onClick:async()=>{await r(l.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(Ke,{size:14})})]},l.id)),c.length>0?e.jsx(K,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(K,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),g<s.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},Dl=()=>{var v,w,C,$,y,z,_;const{loading:t}=rr(),{deployment:r}=ve(),[o,n]=i.useState("profile"),[a,s]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((k,b="info")=>{s(k),g(b),setTimeout(()=>s(null),3e3)},[s]);if(t)return e.jsx(le,{children:e.jsx(di,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})})});const h=r==null?void 0:r.auth_settings,d=(v=h==null?void 0:h.email_address)==null?void 0:v.enabled,l=(w=h==null?void 0:h.phone_number)==null?void 0:w.enabled,m=((C=r==null?void 0:r.social_connections)==null?void 0:C.some(k=>k.enabled))||!1,x=(($=h==null?void 0:h.password)==null?void 0:$.enabled)||((y=h==null?void 0:h.auth_factors_enabled)==null?void 0:y.authenticator)||((z=h==null?void 0:h.auth_factors_enabled)==null?void 0:z.phone_otp)||((_=h==null?void 0:h.auth_factors_enabled)==null?void 0:_.backup_code);return e.jsx(le,{children:e.jsx(D0,{children:e.jsx(kr.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(di,{children:[e.jsx(N0,{children:e.jsxs(F0,{children:[e.jsx(dr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(ur,{children:[e.jsx(Mo,{size:16}),"Profile"]})}),d&&e.jsx(dr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(ur,{children:[e.jsx(Wr,{size:16}),"Email"]})}),l&&e.jsx(dr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(ur,{children:[e.jsx(Rh,{size:16}),"Phone"]})}),m&&e.jsx(dr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(ur,{children:[e.jsx(wh,{size:16}),"Connections"]})}),x&&e.jsx(dr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(ur,{children:[e.jsx(Xo,{size:16}),"Security"]})}),e.jsx(dr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(ur,{children:[e.jsx(Zp,{size:16}),"Sessions"]})})]})}),e.jsxs(B0,{children:[o==="profile"&&e.jsx(Z0,{}),o==="email"&&d&&e.jsx(G0,{}),o==="phone"&&l&&e.jsx(H0,{}),o==="social"&&m&&e.jsx(q0,{}),o==="security"&&x&&e.jsx(Y0,{}),o==="sessions"&&e.jsx(V0,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})})})},Y0=()=>{var ne,ye,be;const{deployment:t}=ve(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:a,verifyAuthenticator:s,deleteAuthenticator:p,generateBackupCodes:g,regenerateBackupCodes:c,updateProfile:h}=rr(),{toast:d}=It(),[l,m]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[x,v]=i.useState(!1),w=async te=>{try{await h({second_factor_policy:te}),m(te),d("Second factor policy updated successfully","info")}catch($e){d($e.message||"Failed to update second factor policy","error")}},[C,$]=i.useState(!1),[y,z]=i.useState(!1),[_,k]=i.useState(!1),[b,f]=i.useState(!1),I=i.useRef(null),j=i.useRef(null),S=i.useRef(null),R=i.useRef(null),[E,T]=i.useState("table"),[P,O]=i.useState(""),[D,M]=i.useState(""),[N,F]=i.useState(""),[J,ie]=i.useState(["",""]),[re,X]=i.useState([]),[U,Z]=i.useState(!1),[Q,ae]=i.useState(!1),[oe]=i.useState(!1),[ce,Y]=i.useState(!1),se=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.auth_factors_enabled,q=(be=(ye=t==null?void 0:t.auth_settings)==null?void 0:ye.password)==null?void 0:be.enabled;if(!(se!=null&&se.authenticator)&&!(se!=null&&se.backup_code)&&!q)return null;const H=async(te,$e)=>{await o(te,$e),await r.refetch(),d("Password updated successfully","info")},A=async te=>{await n(te),await r.refetch(),d("Password removed successfully","info")},B=()=>{var Ee,or,nr,Vr,za,Ea;if(!r)return!1;const te=(Ee=r.user_email_addresses)==null?void 0:Ee.some(_r=>_r.verified),$e=(or=r.user_phone_numbers)==null?void 0:or.some(_r=>_r.verified),fe=r.social_connections&&r.social_connections.length>0,ke=t==null?void 0:t.auth_settings;return(ke==null?void 0:ke.first_factor)==="email_otp"&&te||((nr=ke==null?void 0:ke.magic_link)==null?void 0:nr.enabled)&&te||((Vr=ke==null?void 0:ke.passkey)==null?void 0:Vr.enabled)||((za=ke==null?void 0:ke.auth_factors_enabled)==null?void 0:za.phone_otp)&&$e||fe&&((Ea=t==null?void 0:t.social_connections)==null?void 0:Ea.some(_r=>_r.enabled))},L=async()=>{if(J.some(te=>te.length!==6)){d("Please enter both 6-digit verification codes","error");return}try{if(ae(!0),await s(N,J),await r.refetch(),se!=null&&se.backup_code){const te=await g();X(te),await r.refetch(),T("backup")}else T("success")}catch(te){d(te.message||"Invalid verification codes","error")}finally{ae(!1)}},W=()=>{T("table"),O(""),M(""),F(""),ie(["",""]),X([]),d("Two-factor authentication setup completed successfully!","info")},ee=async()=>{var te;if((te=r==null?void 0:r.user_authenticator)!=null&&te.id)try{Y(!0),await p(r.user_authenticator.id),await r.refetch(),v(!1),d("Two-factor authentication removed successfully","info")}catch($e){d($e.message||"Failed to remove authenticator","error")}finally{Y(!1)}},pe=async()=>{if(!U)try{Z(!0);const te=await c();X(te),await r.refetch(),f(!0),d("New backup codes generated","info")}catch(te){d(te.message||"Failed to generate backup codes","error")}finally{Z(!1)}},Se=()=>{const te=re.join(`
3940
- `);navigator.clipboard.writeText(te).then(()=>{d("Backup codes copied to clipboard","info")}).catch(()=>{d("Failed to copy backup codes","error")})},Ne=()=>{const te=re.join(`
3941
- `),$e=new Blob([te],{type:"text/plain"}),fe=URL.createObjectURL($e),ke=document.createElement("a");ke.href=fe,ke.download="wacht-backup-codes.txt",ke.click(),URL.revokeObjectURL(fe),d("Backup codes downloaded","info")},G=[];return q&&G.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),se!=null&&se.authenticator&&G.push({id:"authenticator",name:"Two-Factor Authentication",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&G.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),(r!=null&&r.user_authenticator||r!=null&&r.backup_codes_generated||r.second_factor_policy==="enforced"||r.primary_phone_number_id)&&G.push({id:"second_factor_policy",name:"Second Factor Policy",description:"Require a second factor for all sign-ins",status:l==="enforced"?"Enforced":"Optional",actions:["toggle"]}),E!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Bo,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Xo,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[E==="qr"&&"Setup Two-Factor Authentication",E==="verify"&&"Verify Your Authenticator",E==="backup"&&"Save Your Backup Codes",E==="success"&&"Setup Complete!"]})]}),e.jsx(K,{onClick:()=>T("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[E==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:oe?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${A0} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):P?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Sa,{value:P,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:D||"Loading..."})]}),e.jsx(K,{onClick:()=>T("verify"),disabled:!P||!D,style:{padding:"10px 20px",background:!P||!D?"var(--color-border)":"var(--color-primary)",color:!P||!D?"var(--color-secondary-text)":"white",border:`1px solid ${!P||!D?"var(--color-border)":"var(--color-primary)"}`,cursor:!P||!D?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),E==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(de,{type:"text",placeholder:"000000",value:J[0],onChange:te=>{const $e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);ie([$e,J[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(de,{type:"text",placeholder:"000000",value:J[1],onChange:te=>{const $e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);ie([J[0],$e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(K,{onClick:()=>T("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(K,{onClick:L,disabled:Q||J.some(te=>te.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:Q?"Verifying...":"Verify & Continue"})]})]}),E==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ut,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:re.map((te,$e)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(te),children:te},$e))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(K,{onClick:Se,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(K,{onClick:Ne,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(Qo,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(K,{onClick:W,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),E==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(rt,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(K,{onClick:W,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bo,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),G.length?e.jsx("div",{children:G.map((te,$e)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:te.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:te.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:te.status==="Enabled"||te.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:te.status==="Enabled"||te.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:te.status}),e.jsxs("div",{style:{position:"relative"},children:[te.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:j,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),y&&e.jsx(ci,{triggerRef:j,onClose:()=>z(!1),onChangePassword:H})]}),B()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:S,onClick:()=>k(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),_&&e.jsx(k0,{triggerRef:S,onClose:()=>k(!1),onRemovePassword:A})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:j,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),y&&e.jsx(ci,{triggerRef:j,onClose:()=>z(!1),onChangePassword:H,isSetup:!0})]})}),te.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:I,onClick:()=>$(!0),disabled:oe,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:oe?"Setting up...":"Setup"}),C&&e.jsx(f0,{triggerRef:I,onClose:()=>$(!1),onSetupTOTP:async()=>{const fe=await a();return F(fe.id),fe},onVerifyTOTP:async fe=>{await s(N,fe),await r.refetch(),d("Two-factor authentication enabled successfully!","info")}})]})}),te.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{onClick:()=>v(!0),disabled:ce,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:ce?"not-allowed":"pointer",opacity:ce?.6:1},children:ce?"Removing...":"Remove"}),x&&e.jsx(on,{title:"Remove MFA and reset policy to default?",onConfirm:ee,onCancel:()=>v(!1)})]}),te.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:R,onClick:pe,disabled:U,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:U?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),b&&e.jsx(P0,{triggerRef:R,codes:re,onClose:()=>f(!1),onCopy:Se,onDownload:Ne})]})}),te.id==="second_factor_policy"&&e.jsx(Ao,{checked:l==="enforced",onChange:fe=>{w(fe?"enforced":"none")}})]})]})]}),$e<G.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},te.id))}):e.jsx(it,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},Z0=()=>{var M,N;const{deployment:t}=ve(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:a}=rr(),{toast:s}=It(),[p,g]=i.useState(""),[c,h]=i.useState(""),[d,l]=i.useState(""),[m,x]=i.useState(!1),[v,w]=i.useState(!1),[C,$]=i.useState(!1),[y,z]=i.useState(""),[_,k]=i.useState((r==null?void 0:r.profile_picture_url)||null),b=i.useRef(null);i.useEffect(()=>{r&&!m&&(g(r.first_name||""),h(r.last_name||""),l(r.username||""),k(r.profile_picture_url||null),x(!0))},[r,m]);const f=i.useCallback(async()=>{if(r)try{const F={};p!==r.first_name&&(F.first_name=p),c!==r.last_name&&(F.last_name=c),d!==r.username&&(F.username=d),Object.keys(F).length>0&&await o(F)}catch(F){s(F.message||"Failed to save profile changes","error")}},[r,o,p,c,d,s]),I=F=>{g(F.target.value)},j=F=>{h(F.target.value)},S=F=>{l(F.target.value)},R=()=>{f()},E=()=>{f()},T=()=>{f()},P=F=>{var J;if((J=F.target.files)!=null&&J[0]){const ie=F.target.files[0];k(URL.createObjectURL(ie)),setTimeout(async()=>{try{await n(ie),r.refetch(),s("Profile picture updated successfully","info")}catch(re){s(re.message||"Failed to update profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},100)}},O=()=>{b.current&&b.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const D=async()=>{if(!(!r||y!==r.username)){$(!0);try{await a(""),s("Account deleted successfully","info")}catch(F){s(F.message||"Failed to delete account","error")}finally{$(!1),z(""),w(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:_?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:O,onMouseEnter:F=>{F.currentTarget.style.borderColor="var(--color-primary)",F.currentTarget.style.transform="scale(1.02)"},onMouseLeave:F=>{F.currentTarget.style.borderColor="var(--color-border)",F.currentTarget.style.transform="scale(1)"},children:[_?e.jsx("img",{src:_,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Mo,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:b,style:{display:"none"},accept:"image/*",onChange:P})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(K,{onClick:()=>{var F;return(F=b.current)==null?void 0:F.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Qo,{size:14}),_?"Change":"Upload"]}),e.jsxs(K,{onClick:async()=>{k(null),b.current&&(b.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),s("Profile picture removed successfully","info")}catch(F){s(F.message||"Failed to remove profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ut,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ue,{htmlFor:"firstName",children:"First Name"}),e.jsx(de,{id:"firstName",type:"text",value:p,onChange:I,onBlur:R,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ue,{htmlFor:"lastName",children:"Last Name"}),e.jsx(de,{id:"lastName",type:"text",value:c,onChange:j,onBlur:E,placeholder:"Enter your last name",required:!0})]})]}),((N=(M=t==null?void 0:t.auth_settings)==null?void 0:M.username)==null?void 0:N.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"username",children:"Username"}),e.jsx(de,{id:"username",type:"text",value:d,onChange:S,onBlur:T,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:v?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(K,{onClick:()=>{v?(w(!1),z("")):w(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:v?"Cancel":"Delete"})]}),v&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(de,{id:"confirm_username",type:"text",value:y,onChange:F=>z(F.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(K,{onClick:D,disabled:y!==(r==null?void 0:r.username)||C,style:{background:y===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:y===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:y===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:y===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:C?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})})},Nl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:g,showCloseButton:c})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(we.Header,{showCloseButton:c,children:a||o}),p||g||e.jsx(Dl,{}),s&&e.jsx(we.Footer,{children:s})]})})}),K0=u.div`
3943
+ `,q0=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=rr(),{deployment:n}=xe(),a={google_oauth:{icon:e.jsx(Dc,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Ac,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(Lc,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(Bc,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(Fc,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(Uc,{}),label:"Discord"},x_oauth:{icon:e.jsx(Nc,{}),label:"X"}},s=(n==null?void 0:n.social_connections.filter(h=>h.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((h,g)=>{var l;const c=((l=t==null?void 0:t.social_connections)==null?void 0:l.filter(d=>d.provider===h.provider))||[],p=a[h.provider];return p?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(Al,{children:p.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:p.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(d=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:d.email_address}),e.jsx(nn,{onClick:async()=>{await r(d.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(Ke,{size:14})})]},d.id)),c.length>0?e.jsx(Q,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(Q,{onClick:()=>{o({provider:h.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),g<s.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},h.provider):null})})]})},Dl=()=>{var v,w,$,z,y,C,k;const{loading:t}=rr(),{deployment:r}=xe(),[o,n]=i.useState("profile"),[a,s]=i.useState(null),[h,g]=i.useState("info"),c=i.useCallback((S,b="info")=>{s(S),g(b),setTimeout(()=>s(null),3e3)},[s]);if(t)return e.jsx(le,{children:e.jsx(di,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})})});const p=r==null?void 0:r.auth_settings,l=(v=p==null?void 0:p.email_address)==null?void 0:v.enabled,d=(w=p==null?void 0:p.phone_number)==null?void 0:w.enabled,m=(($=r==null?void 0:r.social_connections)==null?void 0:$.some(S=>S.enabled))||!1,x=((z=p==null?void 0:p.password)==null?void 0:z.enabled)||((y=p==null?void 0:p.auth_factors_enabled)==null?void 0:y.authenticator)||((C=p==null?void 0:p.auth_factors_enabled)==null?void 0:C.phone_otp)||((k=p==null?void 0:p.auth_factors_enabled)==null?void 0:k.backup_code);return e.jsx(le,{children:e.jsx(D0,{children:e.jsx(_r.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(di,{children:[e.jsx(N0,{children:e.jsxs(F0,{children:[e.jsx(dr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(ur,{children:[e.jsx(Lo,{size:16}),"Profile"]})}),l&&e.jsx(dr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(ur,{children:[e.jsx(Vr,{size:16}),"Email"]})}),d&&e.jsx(dr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(ur,{children:[e.jsx(Rh,{size:16}),"Phone"]})}),m&&e.jsx(dr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(ur,{children:[e.jsx(wh,{size:16}),"Connections"]})}),x&&e.jsx(dr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(ur,{children:[e.jsx(Xo,{size:16}),"Security"]})}),e.jsx(dr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(ur,{children:[e.jsx(Zp,{size:16}),"Sessions"]})})]})}),e.jsxs(B0,{children:[o==="profile"&&e.jsx(Z0,{}),o==="email"&&l&&e.jsx(G0,{}),o==="phone"&&d&&e.jsx(H0,{}),o==="social"&&m&&e.jsx(q0,{}),o==="security"&&x&&e.jsx(Y0,{}),o==="sessions"&&e.jsx(V0,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[h==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})})})},Y0=()=>{var ne,ye,be;const{deployment:t}=xe(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:a,verifyAuthenticator:s,deleteAuthenticator:h,generateBackupCodes:g,regenerateBackupCodes:c,updateProfile:p}=rr(),{toast:l}=It(),[d,m]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[x,v]=i.useState(!1),w=async re=>{try{await p({second_factor_policy:re}),m(re),l("Second factor policy updated successfully","info")}catch($e){l($e.message||"Failed to update second factor policy","error")}},[$,z]=i.useState(!1),[y,C]=i.useState(!1),[k,S]=i.useState(!1),[b,f]=i.useState(!1),E=i.useRef(null),j=i.useRef(null),_=i.useRef(null),I=i.useRef(null),[P,T]=i.useState("table"),[R,O]=i.useState(""),[D,M]=i.useState(""),[Y,N]=i.useState(""),[J,ae]=i.useState(["",""]),[ee,F]=i.useState([]),[U,G]=i.useState(!1),[X,se]=i.useState(!1),[oe]=i.useState(!1),[ce,K]=i.useState(!1),ie=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.auth_factors_enabled,Z=(be=(ye=t==null?void 0:t.auth_settings)==null?void 0:ye.password)==null?void 0:be.enabled;if(!(ie!=null&&ie.authenticator)&&!(ie!=null&&ie.backup_code)&&!Z)return null;const q=async(re,$e)=>{await o(re,$e),await r.refetch(),l("Password updated successfully","info")},A=async re=>{await n(re),await r.refetch(),l("Password removed successfully","info")},B=()=>{var Ee,or,nr,Gr,za,Ea;if(!r)return!1;const re=(Ee=r.user_email_addresses)==null?void 0:Ee.some(Cr=>Cr.verified),$e=(or=r.user_phone_numbers)==null?void 0:or.some(Cr=>Cr.verified),fe=r.social_connections&&r.social_connections.length>0,ke=t==null?void 0:t.auth_settings;return(ke==null?void 0:ke.first_factor)==="email_otp"&&re||((nr=ke==null?void 0:ke.magic_link)==null?void 0:nr.enabled)&&re||((Gr=ke==null?void 0:ke.passkey)==null?void 0:Gr.enabled)||((za=ke==null?void 0:ke.auth_factors_enabled)==null?void 0:za.phone_otp)&&$e||fe&&((Ea=t==null?void 0:t.social_connections)==null?void 0:Ea.some(Cr=>Cr.enabled))},L=async()=>{if(J.some(re=>re.length!==6)){l("Please enter both 6-digit verification codes","error");return}try{if(se(!0),await s(Y,J),await r.refetch(),ie!=null&&ie.backup_code){const re=await g();F(re),await r.refetch(),T("backup")}else T("success")}catch(re){l(re.message||"Invalid verification codes","error")}finally{se(!1)}},W=()=>{T("table"),O(""),M(""),N(""),ae(["",""]),F([]),l("Two-factor authentication setup completed successfully!","info")},te=async()=>{var re;if((re=r==null?void 0:r.user_authenticator)!=null&&re.id)try{K(!0),await h(r.user_authenticator.id),await r.refetch(),v(!1),l("Two-factor authentication removed successfully","info")}catch($e){l($e.message||"Failed to remove authenticator","error")}finally{K(!1)}},pe=async()=>{if(!U)try{G(!0);const re=await c();F(re),await r.refetch(),f(!0),l("New backup codes generated","info")}catch(re){l(re.message||"Failed to generate backup codes","error")}finally{G(!1)}},Se=()=>{const re=ee.join(`
3944
+ `);navigator.clipboard.writeText(re).then(()=>{l("Backup codes copied to clipboard","info")}).catch(()=>{l("Failed to copy backup codes","error")})},Ne=()=>{const re=ee.join(`
3945
+ `),$e=new Blob([re],{type:"text/plain"}),fe=URL.createObjectURL($e),ke=document.createElement("a");ke.href=fe,ke.download="wacht-backup-codes.txt",ke.click(),URL.revokeObjectURL(fe),l("Backup codes downloaded","info")},H=[];return Z&&H.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),ie!=null&&ie.authenticator&&H.push({id:"authenticator",name:"Two-Factor Authentication",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&H.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),(r!=null&&r.user_authenticator||r!=null&&r.backup_codes_generated||r.second_factor_policy==="enforced"||r.primary_phone_number_id)&&H.push({id:"second_factor_policy",name:"Second Factor Policy",description:"Require a second factor for all sign-ins",status:d==="enforced"?"Enforced":"Optional",actions:["toggle"]}),P!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Bo,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Xo,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[P==="qr"&&"Setup Two-Factor Authentication",P==="verify"&&"Verify Your Authenticator",P==="backup"&&"Save Your Backup Codes",P==="success"&&"Setup Complete!"]})]}),e.jsx(Q,{onClick:()=>T("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[P==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:oe?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${A0} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):R?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Sa,{value:R,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:D||"Loading..."})]}),e.jsx(Q,{onClick:()=>T("verify"),disabled:!R||!D,style:{padding:"10px 20px",background:!R||!D?"var(--color-border)":"var(--color-primary)",color:!R||!D?"var(--color-secondary-text)":"white",border:`1px solid ${!R||!D?"var(--color-border)":"var(--color-primary)"}`,cursor:!R||!D?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),P==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(de,{type:"text",placeholder:"000000",value:J[0],onChange:re=>{const $e=re.target.value.replace(/[^0-9]/g,"").substring(0,6);ae([$e,J[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(de,{type:"text",placeholder:"000000",value:J[1],onChange:re=>{const $e=re.target.value.replace(/[^0-9]/g,"").substring(0,6);ae([J[0],$e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(Q,{onClick:()=>T("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(Q,{onClick:L,disabled:X||J.some(re=>re.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:X?"Verifying...":"Verify & Continue"})]})]}),P==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ut,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:ee.map((re,$e)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(re),children:re},$e))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(Q,{onClick:Se,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(Q,{onClick:Ne,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(Qo,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(Q,{onClick:W,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),P==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(rt,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(Q,{onClick:W,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bo,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),H.length?e.jsx("div",{children:H.map((re,$e)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:re.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:re.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:re.status==="Enabled"||re.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:re.status==="Enabled"||re.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:re.status}),e.jsxs("div",{style:{position:"relative"},children:[re.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:j,onClick:()=>C(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),y&&e.jsx(ci,{triggerRef:j,onClose:()=>C(!1),onChangePassword:q})]}),B()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:_,onClick:()=>S(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),k&&e.jsx(k0,{triggerRef:_,onClose:()=>S(!1),onRemovePassword:A})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:j,onClick:()=>C(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),y&&e.jsx(ci,{triggerRef:j,onClose:()=>C(!1),onChangePassword:q,isSetup:!0})]})}),re.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:E,onClick:()=>z(!0),disabled:oe,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:oe?"Setting up...":"Setup"}),$&&e.jsx(f0,{triggerRef:E,onClose:()=>z(!1),onSetupTOTP:async()=>{const fe=await a();return N(fe.id),fe},onVerifyTOTP:async fe=>{await s(Y,fe),await r.refetch(),l("Two-factor authentication enabled successfully!","info")}})]})}),re.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{onClick:()=>v(!0),disabled:ce,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:ce?"not-allowed":"pointer",opacity:ce?.6:1},children:ce?"Removing...":"Remove"}),x&&e.jsx(on,{title:"Remove MFA and reset policy to default?",onConfirm:te,onCancel:()=>v(!1)})]}),re.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:I,onClick:pe,disabled:U,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:U?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),b&&e.jsx(P0,{triggerRef:I,codes:ee,onClose:()=>f(!1),onCopy:Se,onDownload:Ne})]})}),re.id==="second_factor_policy"&&e.jsx(br,{checked:d==="enforced",onChange:fe=>{w(fe?"enforced":"none")}})]})]})]}),$e<H.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},re.id))}):e.jsx(it,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},Z0=()=>{var M,Y;const{deployment:t}=xe(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:a}=rr(),{toast:s}=It(),[h,g]=i.useState(""),[c,p]=i.useState(""),[l,d]=i.useState(""),[m,x]=i.useState(!1),[v,w]=i.useState(!1),[$,z]=i.useState(!1),[y,C]=i.useState(""),[k,S]=i.useState((r==null?void 0:r.profile_picture_url)||null),b=i.useRef(null);i.useEffect(()=>{r&&!m&&(g(r.first_name||""),p(r.last_name||""),d(r.username||""),S(r.profile_picture_url||null),x(!0))},[r,m]);const f=i.useCallback(async()=>{if(r)try{const N={};h!==r.first_name&&(N.first_name=h),c!==r.last_name&&(N.last_name=c),l!==r.username&&(N.username=l),Object.keys(N).length>0&&await o(N)}catch(N){s(N.message||"Failed to save profile changes","error")}},[r,o,h,c,l,s]),E=N=>{g(N.target.value)},j=N=>{p(N.target.value)},_=N=>{d(N.target.value)},I=()=>{f()},P=()=>{f()},T=()=>{f()},R=N=>{var J;if((J=N.target.files)!=null&&J[0]){const ae=N.target.files[0];S(URL.createObjectURL(ae)),setTimeout(async()=>{try{await n(ae),r.refetch(),s("Profile picture updated successfully","info")}catch(ee){s(ee.message||"Failed to update profile picture","error"),S((r==null?void 0:r.profile_picture_url)||null)}},100)}},O=()=>{b.current&&b.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const D=async()=>{if(!(!r||y!==r.username)){z(!0);try{await a(""),s("Account deleted successfully","info")}catch(N){s(N.message||"Failed to delete account","error")}finally{z(!1),C(""),w(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:k?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:O,onMouseEnter:N=>{N.currentTarget.style.borderColor="var(--color-primary)",N.currentTarget.style.transform="scale(1.02)"},onMouseLeave:N=>{N.currentTarget.style.borderColor="var(--color-border)",N.currentTarget.style.transform="scale(1)"},children:[k?e.jsx("img",{src:k,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Lo,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:b,style:{display:"none"},accept:"image/*",onChange:R})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var N;return(N=b.current)==null?void 0:N.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Qo,{size:14}),k?"Change":"Upload"]}),e.jsxs(Q,{onClick:async()=>{S(null),b.current&&(b.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),s("Profile picture removed successfully","info")}catch(N){s(N.message||"Failed to remove profile picture","error"),S((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ut,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ue,{htmlFor:"firstName",children:"First Name"}),e.jsx(de,{id:"firstName",type:"text",value:h,onChange:E,onBlur:I,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ue,{htmlFor:"lastName",children:"Last Name"}),e.jsx(de,{id:"lastName",type:"text",value:c,onChange:j,onBlur:P,placeholder:"Enter your last name",required:!0})]})]}),((Y=(M=t==null?void 0:t.auth_settings)==null?void 0:M.username)==null?void 0:Y.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"username",children:"Username"}),e.jsx(de,{id:"username",type:"text",value:l,onChange:_,onBlur:T,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:v?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{v?(w(!1),C("")):w(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:v?"Cancel":"Delete"})]}),v&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(de,{id:"confirm_username",type:"text",value:y,onChange:N=>C(N.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(Q,{onClick:D,disabled:y!==(r==null?void 0:r.username)||$,style:{background:y===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:y===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:y===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:y===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:$?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})})},Nl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:h,children:g,showCloseButton:c})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(we.Header,{showCloseButton:c,children:a||o}),h||g||e.jsx(Dl,{}),s&&e.jsx(we.Footer,{children:s})]})})}),K0=u.div`
3942
3946
  position: relative;
3943
3947
  `,Q0=u.button`
3944
3948
  display: flex;
@@ -4029,7 +4033,7 @@ cursor: pointer;
4029
4033
  display: flex;
4030
4034
  margin-top: 12px;
4031
4035
  gap: 8px;
4032
- `,jo=u.button`
4036
+ `,ko=u.button`
4033
4037
  display: flex;
4034
4038
  align-items: center;
4035
4039
  justify-content: center;
@@ -4077,7 +4081,7 @@ cursor: pointer;
4077
4081
  width: 14px;
4078
4082
  height: 14px;
4079
4083
  }
4080
- `,$a=({showName:t=!0})=>{var b,f,I,j;const[r,o]=i.useState(!1),n=i.useRef(null),a=i.useRef(null),s=_l({triggerRef:n,isOpen:r,minWidth:380}),p=Or(!1),{session:g,signOut:c,switchSignIn:h,addNewAccount:d,refetch:l}=Fe(),{deployment:m}=ve(),x=(b=g==null?void 0:g.active_signin)==null?void 0:b.user,v=((I=(f=m==null?void 0:m.auth_settings)==null?void 0:f.multi_session_support)==null?void 0:I.enabled)??!1,w=(((j=g==null?void 0:g.signins)==null?void 0:j.length)??0)>1;i.useEffect(()=>{if(!r)return;const S=setTimeout(()=>{const R=E=>{var P,O;const T=E.target;(P=n.current)!=null&&P.contains(T)||(O=a.current)!=null&&O.contains(T)||o(!1)};return document.addEventListener("mousedown",R),()=>{document.removeEventListener("mousedown",R)}},50);return()=>{clearTimeout(S)}},[r]);const C=()=>{o(!r)},$=S=>S.split(" ").map(R=>R[0]).join("").toUpperCase(),y=async S=>{try{await c(S),await l(),o(!1)}catch{}},z=async()=>{try{await c(),await l(),o(!1)}catch{}},_=async S=>{try{await h(S),await l(),o(!1)}catch{}},k=()=>{p.open(),o(!1)};return e.jsx(le,{children:e.jsxs(K0,{children:[e.jsxs(Q0,{ref:n,onClick:C,children:[e.jsx(Wn,{children:e.jsx(Fl,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(X0,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&Nr.createPortal(e.jsx(le,{children:e.jsx(J0,{ref:a,$position:s,$isOpen:r,$maxHeight:s==null?void 0:s.maxHeight,children:e.jsxs("div",{children:[v?(()=>{const S=[...(g==null?void 0:g.signins)||[]].sort((R,E)=>{const T=R.user.id===(x==null?void 0:x.id),P=E.user.id===(x==null?void 0:x.id);return T&&!P?-1:!T&&P?1:0});return S.map(({user:R,id:E},T)=>{const P=R.id===(x==null?void 0:x.id),O=!P;return e.jsxs(i.Fragment,{children:[e.jsxs(hi,{$isClickable:O,onClick:O?()=>_(E):void 0,children:[e.jsxs(fi,{children:[e.jsx(Wn,{children:e.jsx(xi,{children:R.has_profile_picture?e.jsx("img",{src:R.profile_picture_url,alt:R.first_name}):$(`${(R==null?void 0:R.first_name)||""} ${(R==null?void 0:R.last_name)||""}`)})}),e.jsxs(gi,{children:[e.jsx(mi,{children:e.jsx(ui,{children:`${(R==null?void 0:R.first_name)||""} ${(R==null?void 0:R.last_name)||""}`})}),e.jsx(pi,{children:R.primary_email_address.email})]})]}),P&&e.jsxs(vi,{children:[e.jsxs(jo,{onClick:k,children:[e.jsx(Kt,{}),"Manage account"]}),e.jsxs(jo,{$destructive:!0,onClick:()=>y(E),children:[e.jsx(zt,{}),"Sign out"]})]})]}),T===0&&S.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},R.id)})})():x&&e.jsxs(hi,{$isClickable:!1,children:[e.jsxs(fi,{children:[e.jsx(Wn,{children:e.jsx(xi,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):$(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(gi,{children:[e.jsx(mi,{children:e.jsx(ui,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(pi,{children:x.primary_email_address.email})]})]}),e.jsxs(vi,{children:[e.jsxs(jo,{onClick:k,children:[e.jsx(Kt,{}),"Manage account"]}),e.jsxs(jo,{$destructive:!0,onClick:()=>{var S;return y(((S=g==null?void 0:g.active_signin)==null?void 0:S.id)||"")},children:[e.jsx(zt,{}),"Sign out"]})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(bi,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(yi,{onClick:d,children:[e.jsx(Je,{}),"Add new account"]})}),w&&e.jsx(bi,{children:e.jsxs(yi,{onClick:z,children:[e.jsx(zt,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(Nl,{isOpen:p.isOpen,onClose:p.close})]})})},e1=u.div`
4084
+ `,$a=({showName:t=!0})=>{var b,f,E,j;const[r,o]=i.useState(!1),n=i.useRef(null),a=i.useRef(null),s=_l({triggerRef:n,isOpen:r,minWidth:380}),h=Mr(!1),{session:g,signOut:c,switchSignIn:p,addNewAccount:l,refetch:d}=Fe(),{deployment:m}=xe(),x=(b=g==null?void 0:g.active_signin)==null?void 0:b.user,v=((E=(f=m==null?void 0:m.auth_settings)==null?void 0:f.multi_session_support)==null?void 0:E.enabled)??!1,w=(((j=g==null?void 0:g.signins)==null?void 0:j.length)??0)>1;i.useEffect(()=>{if(!r)return;const _=setTimeout(()=>{const I=P=>{var R,O;const T=P.target;(R=n.current)!=null&&R.contains(T)||(O=a.current)!=null&&O.contains(T)||o(!1)};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},50);return()=>{clearTimeout(_)}},[r]);const $=()=>{o(!r)},z=_=>_.split(" ").map(I=>I[0]).join("").toUpperCase(),y=async _=>{try{await c(_),await d(),o(!1)}catch{}},C=async()=>{try{await c(),await d(),o(!1)}catch{}},k=async _=>{try{await p(_),await d(),o(!1)}catch{}},S=()=>{h.open(),o(!1)};return e.jsx(le,{children:e.jsxs(K0,{children:[e.jsxs(Q0,{ref:n,onClick:$,children:[e.jsx(Wn,{children:e.jsx(Fl,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):z(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(X0,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&Fr.createPortal(e.jsx(le,{children:e.jsx(J0,{ref:a,$position:s,$isOpen:r,$maxHeight:s==null?void 0:s.maxHeight,children:e.jsxs("div",{children:[v?(()=>{const _=[...(g==null?void 0:g.signins)||[]].sort((I,P)=>{const T=I.user.id===(x==null?void 0:x.id),R=P.user.id===(x==null?void 0:x.id);return T&&!R?-1:!T&&R?1:0});return _.map(({user:I,id:P},T)=>{const R=I.id===(x==null?void 0:x.id),O=!R;return e.jsxs(i.Fragment,{children:[e.jsxs(hi,{$isClickable:O,onClick:O?()=>k(P):void 0,children:[e.jsxs(fi,{children:[e.jsx(Wn,{children:e.jsx(xi,{children:I.has_profile_picture?e.jsx("img",{src:I.profile_picture_url,alt:I.first_name}):z(`${(I==null?void 0:I.first_name)||""} ${(I==null?void 0:I.last_name)||""}`)})}),e.jsxs(gi,{children:[e.jsx(mi,{children:e.jsx(ui,{children:`${(I==null?void 0:I.first_name)||""} ${(I==null?void 0:I.last_name)||""}`})}),e.jsx(pi,{children:I.primary_email_address.email})]})]}),R&&e.jsxs(vi,{children:[e.jsxs(ko,{onClick:S,children:[e.jsx(Kt,{}),"Manage account"]}),e.jsxs(ko,{$destructive:!0,onClick:()=>y(P),children:[e.jsx(zt,{}),"Sign out"]})]})]}),T===0&&_.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},I.id)})})():x&&e.jsxs(hi,{$isClickable:!1,children:[e.jsxs(fi,{children:[e.jsx(Wn,{children:e.jsx(xi,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):z(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(gi,{children:[e.jsx(mi,{children:e.jsx(ui,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(pi,{children:x.primary_email_address.email})]})]}),e.jsxs(vi,{children:[e.jsxs(ko,{onClick:S,children:[e.jsx(Kt,{}),"Manage account"]}),e.jsxs(ko,{$destructive:!0,onClick:()=>{var _;return y(((_=g==null?void 0:g.active_signin)==null?void 0:_.id)||"")},children:[e.jsx(zt,{}),"Sign out"]})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(bi,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(yi,{onClick:l,children:[e.jsx(Je,{}),"Add new account"]})}),w&&e.jsx(bi,{children:e.jsxs(yi,{onClick:C,children:[e.jsx(zt,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(Nl,{isOpen:h.isOpen,onClose:h.close})]})})},e1=u.div`
4081
4085
  padding: var(--space-md) var(--space-lg);
4082
4086
  background: ${t=>t.$unread?"var(--color-background-hover)":"transparent"};
4083
4087
  transition: all 0.2s ease;
@@ -4186,7 +4190,7 @@ cursor: pointer;
4186
4190
  width: 12px;
4187
4191
  height: 12px;
4188
4192
  }
4189
- `;function Bl({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},a=s=>{const p=new Date(s),c=new Date().getTime()-p.getTime(),h=Math.floor(c/1e3),d=Math.floor(h/60),l=Math.floor(d/60),m=Math.floor(l/24);return m>7?p.toLocaleDateString():m>0?`${m}d ago`:l>0?`${l}h ago`:d>0?`${d}m ago`:"Just now"};return e.jsxs(e1,{$unread:!t.is_read,onClick:n,children:[e.jsxs(t1,{children:[e.jsxs(r1,{children:[e.jsx(n1,{$severity:t.severity}),e.jsx(o1,{children:t.title})]}),e.jsx(l1,{onClick:s=>{s.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(Ke,{})})]}),e.jsx(a1,{children:t.body}),e.jsxs(s1,{children:[e.jsx(i1,{children:a(t.created_at)}),t.action_url&&e.jsx(c1,{children:e.jsxs(d1,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),children:[t.action_label||"View",e.jsx(Hc,{})]})})]})]})}const u1=u.div`
4193
+ `;function Bl({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},a=s=>{const h=new Date(s),c=new Date().getTime()-h.getTime(),p=Math.floor(c/1e3),l=Math.floor(p/60),d=Math.floor(l/60),m=Math.floor(d/24);return m>7?h.toLocaleDateString():m>0?`${m}d ago`:d>0?`${d}h ago`:l>0?`${l}m ago`:"Just now"};return e.jsxs(e1,{$unread:!t.is_read,onClick:n,children:[e.jsxs(t1,{children:[e.jsxs(r1,{children:[e.jsx(n1,{$severity:t.severity}),e.jsx(o1,{children:t.title})]}),e.jsx(l1,{onClick:s=>{s.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(Ke,{})})]}),e.jsx(a1,{children:t.body}),e.jsxs(s1,{children:[e.jsx(i1,{children:a(t.created_at)}),t.action_url&&e.jsx(c1,{children:e.jsxs(d1,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),children:[t.action_label||"View",e.jsx(Hc,{})]})})]})]})}const u1=u.div`
4190
4194
  position: fixed;
4191
4195
  ${t=>{var r;return((r=t.$position)==null?void 0:r.top)!==void 0?`top: ${t.$position.top}px;`:""}}
4192
4196
  ${t=>{var r;return((r=t.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${t.$position.bottom}px;`:""}}
@@ -4297,7 +4301,7 @@ cursor: pointer;
4297
4301
  color: var(--color-primary-hover);
4298
4302
  text-decoration: underline;
4299
4303
  }
4300
- `,Ul=i.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:a,onDelete:s},p)=>{const g=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(u1,{ref:p,$position:t,children:[e.jsxs(p1,{children:[e.jsx(h1,{children:"Notifications"}),g&&e.jsx(f1,{onClick:a,children:"Mark all as read"})]}),e.jsx(g1,{children:o?e.jsx(m1,{children:e.jsx(Re,{})}):r.length===0?e.jsxs(x1,{children:[e.jsx(v1,{children:e.jsx(Qp,{})}),e.jsx(b1,{children:"No notifications"}),e.jsx(y1,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(Bl,{notification:c,onMarkAsRead:n,onDelete:s},c.id))}),!o&&r.length>0&&e.jsx(w1,{children:e.jsx(j1,{href:"/notifications",children:"View all notifications"})})]})}),k1=u.div`
4304
+ `,Ul=i.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:a,onDelete:s},h)=>{const g=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(u1,{ref:h,$position:t,children:[e.jsxs(p1,{children:[e.jsx(h1,{children:"Notifications"}),g&&e.jsx(f1,{onClick:a,children:"Mark all as read"})]}),e.jsx(g1,{children:o?e.jsx(m1,{children:e.jsx(Re,{})}):r.length===0?e.jsxs(x1,{children:[e.jsx(v1,{children:e.jsx(Qp,{})}),e.jsx(b1,{children:"No notifications"}),e.jsx(y1,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(Bl,{notification:c,onMarkAsRead:n,onDelete:s},c.id))}),!o&&r.length>0&&e.jsx(w1,{children:e.jsx(j1,{href:"/notifications",children:"View all notifications"})})]})}),k1=u.div`
4301
4305
  position: relative;
4302
4306
  `,_1=u.div`
4303
4307
  width: 40px;
@@ -4360,18 +4364,18 @@ cursor: pointer;
4360
4364
  justify-content: center;
4361
4365
  border: 2px solid var(--color-background);
4362
4366
  box-shadow: 0 1px 3px var(--color-shadow);
4363
- `;function Wl({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:a}){const[s,p]=i.useState(!1),[g,c]=i.useState(),h=i.useRef(null),d=i.useRef(null),l={channels:o,organization_ids:n,workspace_ids:a,limit:20},{unreadCount:m,notifications:x,loading:v,markAsRead:w,markAllAsRead:C,deleteNotification:$}=cc(l);return i.useEffect(()=>{if(!s)return;const y=setTimeout(()=>{const z=_=>{var b,f;const k=_.target;(b=h.current)!=null&&b.contains(k)||(f=d.current)!=null&&f.contains(k)||p(!1)};return document.addEventListener("mousedown",z),()=>{document.removeEventListener("mousedown",z)}},50);return()=>{clearTimeout(y)}},[s]),i.useEffect(()=>{if(s&&h.current){const y=h.current.getBoundingClientRect(),z=400,_=600,k=window.innerWidth,b=window.innerHeight,f=k-y.left,I=b-y.bottom,j=y.top;let S,R;f>=z?S=y.left:R=k-y.right;let E,T;I>=_+8?E=y.bottom+8:j>=_+8?T=b-y.top+8:E=y.bottom+8,c({top:E,bottom:T,left:S,right:R})}else c(void 0)},[s]),e.jsx(le,{children:e.jsxs(k1,{ref:h,className:t,children:[e.jsx(_1,{children:e.jsxs(C1,{onClick:()=>p(!s),children:[e.jsx(Jp,{size:16}),r&&m>0&&e.jsx(S1,{children:m>9?"9+":m})]})}),typeof window<"u"&&s&&Nr.createPortal(e.jsx(le,{children:e.jsx(Ul,{ref:d,position:g,notifications:x,loading:v,onMarkAsRead:w,onMarkAllAsRead:C,onDelete:$})}),document.body)]})})}const $1=u.div`
4367
+ `;function Wl({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:a}){const[s,h]=i.useState(!1),[g,c]=i.useState(),p=i.useRef(null),l=i.useRef(null),d={channels:o,organization_ids:n,workspace_ids:a,limit:20},{unreadCount:m,notifications:x,loading:v,markAsRead:w,markAllAsRead:$,deleteNotification:z}=cc(d);return i.useEffect(()=>{if(!s)return;const y=setTimeout(()=>{const C=k=>{var b,f;const S=k.target;(b=p.current)!=null&&b.contains(S)||(f=l.current)!=null&&f.contains(S)||h(!1)};return document.addEventListener("mousedown",C),()=>{document.removeEventListener("mousedown",C)}},50);return()=>{clearTimeout(y)}},[s]),i.useEffect(()=>{if(s&&p.current){const y=p.current.getBoundingClientRect(),C=400,k=600,S=window.innerWidth,b=window.innerHeight,f=S-y.left,E=b-y.bottom,j=y.top;let _,I;f>=C?_=y.left:I=S-y.right;let P,T;E>=k+8?P=y.bottom+8:j>=k+8?T=b-y.top+8:P=y.bottom+8,c({top:P,bottom:T,left:_,right:I})}else c(void 0)},[s]),e.jsx(le,{children:e.jsxs(k1,{ref:p,className:t,children:[e.jsx(_1,{children:e.jsxs(C1,{onClick:()=>h(!s),children:[e.jsx(Jp,{size:16}),r&&m>0&&e.jsx(S1,{children:m>9?"9+":m})]})}),typeof window<"u"&&s&&Fr.createPortal(e.jsx(le,{children:e.jsx(Ul,{ref:l,position:g,notifications:x,loading:v,onMarkAsRead:w,onMarkAllAsRead:$,onDelete:z})}),document.body)]})})}const $1=u.div`
4364
4368
  display: flex;
4365
4369
  align-items: center;
4366
4370
  gap: 8px;
4367
- `,z1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs($1,{children:[r&&e.jsx(Wl,{}),e.jsx($a,{showName:t})]}),E1=({children:t})=>{var s;const{session:r,loading:o}=Fe(),{deployment:n}=ve(),{navigate:a}=He();return i.useEffect(()=>{var p;if(!o&&(p=r==null?void 0:r.signins)!=null&&p.length&&!r.active_signin){let g=window.location.href,c=new URL(g);c.searchParams.set("redirect_uri",g),a(c.toString())}},[o,r,n,a]),o||!((s=r.signins)!=null&&s.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},P1=({children:t})=>{var n;const{loading:r,session:o}=Fe();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},Vl=wr`
4371
+ `,z1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs($1,{children:[r&&e.jsx(Wl,{}),e.jsx($a,{showName:t})]}),E1=({children:t})=>{var s;const{session:r,loading:o}=Fe(),{deployment:n}=xe(),{navigateToAccountSelection:a}=He();return i.useEffect(()=>{var h;o||(h=r==null?void 0:r.signins)!=null&&h.length&&!r.active_signin&&a()},[o,r,n,a]),o||!((s=r.signins)!=null&&s.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},P1=({children:t})=>{var n;const{loading:r,session:o}=Fe();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},Vl=jr`
4368
4372
  0% {
4369
4373
  background-position: -1000px 0;
4370
4374
  }
4371
4375
  100% {
4372
4376
  background-position: 1000px 0;
4373
4377
  }
4374
- `,R1=wr`
4378
+ `,R1=jr`
4375
4379
  from {
4376
4380
  transform: rotate(0deg);
4377
4381
  }
@@ -4593,7 +4597,7 @@ cursor: pointer;
4593
4597
  &:hover {
4594
4598
  color: var(--color-primary-hover);
4595
4599
  }
4596
- `,V1=({onAccountSelect:t,showAddAccount:r=!0})=>{var z,_,k;const{session:o,loading:n,switchSignIn:a,addNewAccount:s,signOut:p}=Fe(),{deployment:g}=ve(),{navigate:c}=He(),[h,d]=i.useState(null),[l,m]=i.useState(null),x=o==null?void 0:o.active_signin,v=(o==null?void 0:o.signins)||[];i.useEffect(()=>{var b;if(!n&&!v.length){const f=(b=g==null?void 0:g.ui_settings)==null?void 0:b.sign_in_page_url;f&&c(`${f}${window.location.search}`)}},[n,v,g,c]);const w=b=>b.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),C=async b=>{var f;if(!(b===(x==null?void 0:x.id)||l)){m(b);try{if(await a(b),t)t(b),m(null);else{let I=new URLSearchParams(window.location.search).get("redirect_uri");if(I||(I=(f=g.ui_settings)==null?void 0:f.after_signin_redirect_url),I){const j=new URL(I);(g==null?void 0:g.mode)==="staging"&&j.searchParams.set("dev_session",localStorage.getItem("__dev_session__")??""),c(j.toString())}else m(null)}}catch(I){console.error("Failed to switch account:",I),m(null)}}},$=async(b,f)=>{b.stopPropagation(),d(f);try{await p(f)}catch(I){console.error("Failed to sign out:",I)}finally{d(null)}},y=()=>{var b;if(s)s();else{const f=(b=g==null?void 0:g.ui_settings)==null?void 0:b.sign_in_page_url;f&&c(`${f}${window.location.search}`)}};return n?e.jsx(le,{children:e.jsxs(wi,{children:[e.jsx(Ae,{}),e.jsxs(ki,{children:[e.jsx(_i,{children:"Choose an account"}),e.jsxs(Ci,{children:["to continue to ",((z=g==null?void 0:g.ui_settings)==null?void 0:z.app_name)||"App"]})]}),e.jsx(ji,{children:[1,2].map(b=>e.jsxs(N1,{children:[e.jsx(F1,{}),e.jsxs(B1,{children:[e.jsx(Si,{}),e.jsx(Si,{$width:"small"})]})]},b))})]})}):v.length?e.jsx(le,{children:e.jsxs(wi,{children:[e.jsx(Ae,{}),e.jsxs(ki,{children:[e.jsx(_i,{children:"Choose an account"}),e.jsxs(Ci,{children:["to continue to ",(_=g==null?void 0:g.ui_settings)==null?void 0:_.app_name]})]}),e.jsxs(ji,{children:[v.map(({user:b,id:f})=>{var R,E,T,P,O;if(!b)return null;const I=f===(x==null?void 0:x.id),j=l===f,S=`${b.first_name||""} ${b.last_name||""}`.trim();return e.jsxs(I1,{$isActive:I,$isSwitching:j,onClick:()=>C(f),children:[e.jsx(T1,{children:b.has_profile_picture?e.jsx("img",{src:b.profile_picture_url,alt:S}):w(S||((R=b.primary_email_address)==null?void 0:R.email)||((E=b.primary_phone_number)==null?void 0:E.phone_number)||b.username||"U")}),e.jsxs(O1,{children:[e.jsx(M1,{children:S||((T=b.primary_email_address)==null?void 0:T.email)||((P=b.primary_phone_number)==null?void 0:P.phone_number)||b.username||"User"}),e.jsx(L1,{children:((O=b.primary_email_address)==null?void 0:O.email)||b.username})]}),!j&&e.jsxs(A1,{onClick:D=>$(D,f),$isLoading:h===f,disabled:h===f,children:[h===f?e.jsx(vr,{size:12}):e.jsx(zt,{size:12}),h===f?"Signing out...":"Sign out"]})]},f)}),r&&e.jsxs(D1,{onClick:y,children:[e.jsx(Je,{}),"Add another account"]})]}),e.jsxs(U1,{children:["Don't have an account?"," ",e.jsx(W1,{children:e.jsx(tt,{to:`${(k=g.ui_settings)==null?void 0:k.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},G1=()=>{const{navigateToSignIn:t}=He();return i.useEffect(()=>{t()},[t]),null},H1=()=>{const{navigateToSignUp:t}=He();return i.useEffect(()=>{t()},[t]),null},q1=u.div`
4600
+ `,V1=({onAccountSelect:t,showAddAccount:r=!0})=>{var C,k,S;const{session:o,loading:n,switchSignIn:a,addNewAccount:s,signOut:h}=Fe(),{deployment:g}=xe(),{navigate:c}=He(),[p,l]=i.useState(null),[d,m]=i.useState(null),x=o==null?void 0:o.active_signin,v=(o==null?void 0:o.signins)||[];i.useEffect(()=>{var b;if(!n&&!v.length){const f=(b=g==null?void 0:g.ui_settings)==null?void 0:b.sign_in_page_url;f&&c(`${f}${window.location.search}`)}},[n,v,g,c]);const w=b=>b.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2),$=async b=>{var f;if(!(b===(x==null?void 0:x.id)||d)){m(b);try{if(await a(b),t)t(b),m(null);else{let E=new URLSearchParams(window.location.search).get("redirect_uri");if(E||(E=(f=g.ui_settings)==null?void 0:f.after_signin_redirect_url),E){const j=new URL(E);(g==null?void 0:g.mode)==="staging"&&j.searchParams.set("dev_session",localStorage.getItem("__dev_session__")??""),c(j.toString())}else m(null)}}catch(E){console.error("Failed to switch account:",E),m(null)}}},z=async(b,f)=>{b.stopPropagation(),l(f);try{await h(f)}catch(E){console.error("Failed to sign out:",E)}finally{l(null)}},y=()=>{var b;if(s)s();else{const f=(b=g==null?void 0:g.ui_settings)==null?void 0:b.sign_in_page_url;f&&c(`${f}${window.location.search}`)}};return n?e.jsx(le,{children:e.jsxs(wi,{children:[e.jsx(Ae,{}),e.jsxs(ki,{children:[e.jsx(_i,{children:"Choose an account"}),e.jsxs(Ci,{children:["to continue to ",((C=g==null?void 0:g.ui_settings)==null?void 0:C.app_name)||"App"]})]}),e.jsx(ji,{children:[1,2].map(b=>e.jsxs(N1,{children:[e.jsx(F1,{}),e.jsxs(B1,{children:[e.jsx(Si,{}),e.jsx(Si,{$width:"small"})]})]},b))})]})}):v.length?e.jsx(le,{children:e.jsxs(wi,{children:[e.jsx(Ae,{}),e.jsxs(ki,{children:[e.jsx(_i,{children:"Choose an account"}),e.jsxs(Ci,{children:["to continue to ",(k=g==null?void 0:g.ui_settings)==null?void 0:k.app_name]})]}),e.jsxs(ji,{children:[v.map(({user:b,id:f})=>{var I,P,T,R,O;if(!b)return null;const E=f===(x==null?void 0:x.id),j=d===f,_=`${b.first_name||""} ${b.last_name||""}`.trim();return e.jsxs(I1,{$isActive:E,$isSwitching:j,onClick:()=>$(f),children:[e.jsx(T1,{children:b.has_profile_picture?e.jsx("img",{src:b.profile_picture_url,alt:_}):w(_||((I=b.primary_email_address)==null?void 0:I.email)||((P=b.primary_phone_number)==null?void 0:P.phone_number)||b.username||"U")}),e.jsxs(O1,{children:[e.jsx(M1,{children:_||((T=b.primary_email_address)==null?void 0:T.email)||((R=b.primary_phone_number)==null?void 0:R.phone_number)||b.username||"User"}),e.jsx(L1,{children:((O=b.primary_email_address)==null?void 0:O.email)||b.username})]}),!j&&e.jsxs(A1,{onClick:D=>z(D,f),$isLoading:p===f,disabled:p===f,children:[p===f?e.jsx(vr,{size:12}):e.jsx(zt,{size:12}),p===f?"Signing out...":"Sign out"]})]},f)}),r&&e.jsxs(D1,{onClick:y,children:[e.jsx(Je,{}),"Add another account"]})]}),e.jsxs(U1,{children:["Don't have an account?"," ",e.jsx(W1,{children:e.jsx(tt,{to:`${(S=g.ui_settings)==null?void 0:S.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},G1=()=>{const{navigateToSignIn:t}=He();return i.useEffect(()=>{t()},[t]),null},H1=()=>{const{navigateToSignUp:t}=He();return i.useEffect(()=>{t()},[t]),null},q1=u.div`
4597
4601
  width: 100%;
4598
4602
  height: 500px;
4599
4603
  background: var(--color-background);
@@ -4796,15 +4800,15 @@ cursor: pointer;
4796
4800
  color: var(--color-secondary-text);
4797
4801
  margin-bottom: 16px;
4798
4802
  line-height: 1.5;
4799
- `,Di=u(K)`
4803
+ `,Di=u(Q)`
4800
4804
  width: auto;
4801
4805
  margin: 0 auto;
4802
4806
  padding: 6px 16px;
4803
4807
  font-size: 13px;
4804
- `,nv=()=>{var R,E;const{organizationMemberships:t,refetch:r,loading:o}=bt(),{workspaces:n}=yt(),{switchOrganization:a,switchWorkspace:s}=Fe(),{deployment:p}=ve(),[g,c]=i.useState(null),[h,d]=i.useState("orgList"),[l,m]=i.useState(null),x=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,v=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,w=i.useRef(!1);i.useEffect(()=>{if(!(w.current||!t)){if(w.current=!0,t.length===0){d("createOrg");return}if(!x){d("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),d("createWorkspace");return}d("orgList")}},[t,n,x]),console.log("view mode",h,x);const C=T=>T.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),$=async T=>{if(x){m(T.id),d("workspaceList");return}c(T.id);try{await a(T.id)}finally{c(null)}},y=async T=>{c(T.id);try{await s(T.id)}finally{c(null)}},z=async T=>{await r(),x&&T&&(m(T.id),d("createWorkspace"))},_=()=>{},k=async()=>{m(null),d("orgList")},b=(R=t==null?void 0:t.find(T=>T.organization.id===l))==null?void 0:R.organization,f=l?n==null?void 0:n.filter(T=>T.organization.id===l):[];if(o)return null;if(h==="createOrg")return e.jsx(we.Body,{style:{padding:0},children:e.jsx(rn,{onSuccess:z,onCancel:()=>d("orgList")})});if(h==="createWorkspace"&&l)return e.jsx(we.Body,{style:{padding:0},children:e.jsx(_a,{organizationId:l,onSuccess:_,onCancel:()=>d("workspaceList"),onCreateOrganization:()=>d("createOrg")})});const I=h==="workspaceList",j=I?"Select a workspace":"Select an organization",S=I?`Choose a workspace in ${(b==null?void 0:b.name)||""}`:`to continue to ${((E=p==null?void 0:p.ui_settings)==null?void 0:E.app_name)||"App"}`;return e.jsxs(q1,{children:[e.jsxs(Y1,{children:[e.jsxs("div",{children:[e.jsx(Ae,{}),e.jsxs(ev,{children:[e.jsx(tv,{children:j}),e.jsx(rv,{children:S})]})]}),e.jsx($a,{showName:!0})]}),e.jsxs(Z1,{children:[e.jsxs(K1,{children:[e.jsxs(Q1,{children:[e.jsx(X1,{children:I?"Workspaces":"Your organizations"}),I&&e.jsxs(J1,{onClick:k,children:[e.jsx(Ur,{}),"Go back"]})]}),e.jsx(ov,{children:I?e.jsx(e.Fragment,{children:f&&f.length>0?f.map(T=>{var O,D,M;const P=((O=T.eligibility_restriction)==null?void 0:O.type)!=="none"&&((D=T.eligibility_restriction)==null?void 0:D.type)!==void 0;return e.jsxs($i,{onClick:()=>!P&&y(T),disabled:g===T.id||P,style:{opacity:P?.7:1},children:[e.jsx(zi,{children:T.image_url?e.jsx(Ei,{src:T.image_url,alt:T.name}):C(T.name).charAt(0)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:T.name}),e.jsxs(Ii,{children:[e.jsx(Lo,{}),"Workspace"]})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),P&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(M=T.eligibility_restriction)==null?void 0:M.message]})]},T.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No workspaces yet"}),e.jsxs(Ai,{children:["Create your first workspace for"," ",(b==null?void 0:b.name)||"this organization"]}),e.jsxs(Di,{onClick:()=>d("createWorkspace"),children:[e.jsx(Je,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(T=>{var re,X,U;const P=T.organization,O=n==null?void 0:n.filter(Z=>Z.organization.id===P.id),D=(O==null?void 0:O.length)||0,M=P.member_count,N=T.roles[0].name,F=T.roles.length-1,J=F>0?`${N.charAt(0).toUpperCase()+N.slice(1)} +${F}`:N.charAt(0).toUpperCase()+N.slice(1),ie=((re=T.eligibility_restriction)==null?void 0:re.type)!=="none"&&((X=T.eligibility_restriction)==null?void 0:X.type)!==void 0;return e.jsxs($i,{onClick:()=>!ie&&$(P),disabled:g===P.id||ie,style:{opacity:ie?.7:1},children:[e.jsx(zi,{children:P.image_url?e.jsx(Ei,{src:P.image_url,alt:P.name}):C(P.name)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:P.name}),e.jsx(Ii,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Lo,{}),D," workspace",D!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(rh,{}),J," • ",M," member",M!==1?"s":""]})})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),ie&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(U=T.eligibility_restriction)==null?void 0:U.message]})]},P.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No organizations yet"}),e.jsx(Ai,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Di,{onClick:()=>d("createOrg"),children:[e.jsx(Je,{}),"Create organization"]})]})})]}),I&&f&&f.length>0&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createWorkspace"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new workspace"]}),!I&&t&&t.length>0&&v&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createOrg"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new organization"]})]})]})},av=u(we.Content)`
4808
+ `,nv=()=>{var I,P;const{organizationMemberships:t,refetch:r,loading:o}=bt(),{workspaces:n}=yt(),{switchOrganization:a,switchWorkspace:s}=Fe(),{deployment:h}=xe(),[g,c]=i.useState(null),[p,l]=i.useState("orgList"),[d,m]=i.useState(null),x=(h==null?void 0:h.b2b_settings.workspaces_enabled)??!1,v=(h==null?void 0:h.b2b_settings.allow_users_to_create_orgs)??!1,w=i.useRef(!1);i.useEffect(()=>{if(!(w.current||!t)){if(w.current=!0,t.length===0){l("createOrg");return}if(!x){l("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),l("createWorkspace");return}l("orgList")}},[t,n,x]),console.log("view mode",p,x);const $=T=>T.split(" ").map(R=>R[0]).join("").toUpperCase().slice(0,2),z=async T=>{if(x){m(T.id),l("workspaceList");return}c(T.id);try{await a(T.id)}finally{c(null)}},y=async T=>{c(T.id);try{await s(T.id)}finally{c(null)}},C=async T=>{await r(),x&&T&&(m(T.id),l("createWorkspace"))},k=()=>{},S=async()=>{m(null),l("orgList")},b=(I=t==null?void 0:t.find(T=>T.organization.id===d))==null?void 0:I.organization,f=d?n==null?void 0:n.filter(T=>T.organization.id===d):[];if(o)return null;if(p==="createOrg")return e.jsx(we.Body,{style:{padding:0},children:e.jsx(rn,{onSuccess:C,onCancel:()=>l("orgList")})});if(p==="createWorkspace"&&d)return e.jsx(we.Body,{style:{padding:0},children:e.jsx(_a,{organizationId:d,onSuccess:k,onCancel:()=>l("workspaceList"),onCreateOrganization:()=>l("createOrg")})});const E=p==="workspaceList",j=E?"Select a workspace":"Select an organization",_=E?`Choose a workspace in ${(b==null?void 0:b.name)||""}`:`to continue to ${((P=h==null?void 0:h.ui_settings)==null?void 0:P.app_name)||"App"}`;return e.jsxs(q1,{children:[e.jsxs(Y1,{children:[e.jsxs("div",{children:[e.jsx(Ae,{}),e.jsxs(ev,{children:[e.jsx(tv,{children:j}),e.jsx(rv,{children:_})]})]}),e.jsx($a,{showName:!0})]}),e.jsxs(Z1,{children:[e.jsxs(K1,{children:[e.jsxs(Q1,{children:[e.jsx(X1,{children:E?"Workspaces":"Your organizations"}),E&&e.jsxs(J1,{onClick:S,children:[e.jsx(Wr,{}),"Go back"]})]}),e.jsx(ov,{children:E?e.jsx(e.Fragment,{children:f&&f.length>0?f.map(T=>{var O,D,M;const R=((O=T.eligibility_restriction)==null?void 0:O.type)!=="none"&&((D=T.eligibility_restriction)==null?void 0:D.type)!==void 0;return e.jsxs($i,{onClick:()=>!R&&y(T),disabled:g===T.id||R,style:{opacity:R?.7:1},children:[e.jsx(zi,{children:T.image_url?e.jsx(Ei,{src:T.image_url,alt:T.name}):$(T.name).charAt(0)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:T.name}),e.jsxs(Ii,{children:[e.jsx(Ao,{}),"Workspace"]})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),R&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(M=T.eligibility_restriction)==null?void 0:M.message]})]},T.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No workspaces yet"}),e.jsxs(Ai,{children:["Create your first workspace for"," ",(b==null?void 0:b.name)||"this organization"]}),e.jsxs(Di,{onClick:()=>l("createWorkspace"),children:[e.jsx(Je,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(T=>{var ee,F,U;const R=T.organization,O=n==null?void 0:n.filter(G=>G.organization.id===R.id),D=(O==null?void 0:O.length)||0,M=R.member_count,Y=T.roles[0].name,N=T.roles.length-1,J=N>0?`${Y.charAt(0).toUpperCase()+Y.slice(1)} +${N}`:Y.charAt(0).toUpperCase()+Y.slice(1),ae=((ee=T.eligibility_restriction)==null?void 0:ee.type)!=="none"&&((F=T.eligibility_restriction)==null?void 0:F.type)!==void 0;return e.jsxs($i,{onClick:()=>!ae&&z(R),disabled:g===R.id||ae,style:{opacity:ae?.7:1},children:[e.jsx(zi,{children:R.image_url?e.jsx(Ei,{src:R.image_url,alt:R.name}):$(R.name)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:R.name}),e.jsx(Ii,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Ao,{}),D," workspace",D!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(rh,{}),J," • ",M," member",M!==1?"s":""]})})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),ae&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(U=T.eligibility_restriction)==null?void 0:U.message]})]},R.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No organizations yet"}),e.jsx(Ai,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Di,{onClick:()=>l("createOrg"),children:[e.jsx(Je,{}),"Create organization"]})]})})]}),E&&f&&f.length>0&&e.jsxs(Q,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createWorkspace"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new workspace"]}),!E&&t&&t.length>0&&v&&e.jsxs(Q,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createOrg"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new organization"]})]})]})},av=u(we.Content)`
4805
4809
  padding: 0;
4806
4810
  max-width: 90vw;
4807
- `,sv=({children:t})=>{var w,C,$,y;const{loading:r,session:o}=Fe(),{activeOrganization:n}=Qe(),{activeWorkspace:a,loading:s}=Pt(),{workspaces:p}=yt(),{deployment:g}=ve(),{organizationMemberships:c}=bt(),h=(g==null?void 0:g.b2b_settings.workspaces_enabled)??!1,d=c==null?void 0:c.find(z=>z.organization.id===(n==null?void 0:n.id)),l=p==null?void 0:p.find(z=>{var _;return z.id===((_=o==null?void 0:o.active_signin)==null?void 0:_.active_workspace_membership_id)}),m=((w=d==null?void 0:d.eligibility_restriction)==null?void 0:w.type)!=="none"&&((C=d==null?void 0:d.eligibility_restriction)==null?void 0:C.type)!==void 0,x=(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!=="none"&&((y=l==null?void 0:l.eligibility_restriction)==null?void 0:y.type)!==void 0;return r||h&&s?null:(m||x||!n?!1:h?a?p==null?void 0:p.some(_=>_.id===a.id&&_.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(le,{children:e.jsx(we,{isOpen:!0,children:e.jsx(we.Overlay,{children:e.jsx(av,{style:{width:"850px"},children:e.jsx(nv,{})})})})})},iv=u.div`
4811
+ `,sv=({children:t})=>{var w,$,z,y;const{loading:r,session:o}=Fe(),{activeOrganization:n}=Qe(),{activeWorkspace:a,loading:s}=Pt(),{workspaces:h}=yt(),{deployment:g}=xe(),{organizationMemberships:c}=bt(),p=(g==null?void 0:g.b2b_settings.workspaces_enabled)??!1,l=c==null?void 0:c.find(C=>C.organization.id===(n==null?void 0:n.id)),d=h==null?void 0:h.find(C=>{var k;return C.id===((k=o==null?void 0:o.active_signin)==null?void 0:k.active_workspace_membership_id)}),m=((w=l==null?void 0:l.eligibility_restriction)==null?void 0:w.type)!=="none"&&(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!==void 0,x=((z=d==null?void 0:d.eligibility_restriction)==null?void 0:z.type)!=="none"&&((y=d==null?void 0:d.eligibility_restriction)==null?void 0:y.type)!==void 0;return r||p&&s?null:(m||x||!n?!1:p?a?h==null?void 0:h.some(k=>k.id===a.id&&k.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(le,{children:e.jsx(we,{isOpen:!0,children:e.jsx(we.Overlay,{children:e.jsx(av,{style:{width:"850px"},children:e.jsx(nv,{})})})})})},iv=u.div`
4808
4812
  display: flex;
4809
4813
  gap: 8px;
4810
4814
  flex-wrap: wrap;
@@ -4832,7 +4836,7 @@ cursor: pointer;
4832
4836
  border-radius: 8px;
4833
4837
  font-size: 10px;
4834
4838
  font-weight: 400;
4835
- `,dv={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function uv({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=a=>{if(t.includes(a)){const p=t.filter(g=>g!==a);p.length===0?o(["user"]):o(p)}else o([...t,a])};return e.jsx(iv,{children:Object.entries(dv).map(([a,s])=>{const p=(r==null?void 0:r[a])||0,g=t.includes(a);return e.jsxs(cv,{$active:g,onClick:()=>n(a),children:[s,p>0&&e.jsx(lv,{children:p})]},a)})})}const Ni=u.div`
4839
+ `,dv={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function uv({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=a=>{if(t.includes(a)){const h=t.filter(g=>g!==a);h.length===0?o(["user"]):o(h)}else o([...t,a])};return e.jsx(iv,{children:Object.entries(dv).map(([a,s])=>{const h=(r==null?void 0:r[a])||0,g=t.includes(a);return e.jsxs(cv,{$active:g,onClick:()=>n(a),children:[s,h>0&&e.jsx(lv,{children:h})]},a)})})}const Ni=u.div`
4836
4840
  display: flex;
4837
4841
  flex-direction: column;
4838
4842
  width: 100%;
@@ -5399,7 +5403,7 @@ cursor: pointer;
5399
5403
  &:active:not(:disabled) {
5400
5404
  transform: scale(0.98);
5401
5405
  }
5402
- `,ko=u(Hl)`
5406
+ `,_o=u(Hl)`
5403
5407
  width: 32px;
5404
5408
  padding: 0;
5405
5409
  `,Fv=u.img`
@@ -5486,7 +5490,7 @@ cursor: pointer;
5486
5490
  &:hover .expand-icon {
5487
5491
  opacity: 1;
5488
5492
  }
5489
- `,Gv=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:a,onClose:s,onDownload:p,onZoom:g,onReset:c,onWheel:h,onMouseDown:d,onMouseMove:l,onMouseUp:m})=>{const[x,v]=i.useState(!1),w=i.useRef(null);return i.useEffect(()=>(v(!0),()=>v(!1)),[]),i.useEffect(()=>{if(t){const C=document.body.style.overflow;document.body.style.overflow="hidden";const $=_=>{(_.ctrlKey||_.metaKey)&&_.preventDefault()},y=_=>{_.preventDefault()},z=_=>{_.preventDefault()};return document.addEventListener("wheel",$,{passive:!1}),document.addEventListener("gesturestart",y,{passive:!1}),document.addEventListener("gesturechange",z,{passive:!1}),()=>{document.body.style.overflow=C,document.removeEventListener("wheel",$),document.removeEventListener("gesturestart",y),document.removeEventListener("gesturechange",z)}}},[t]),!x||!t||!r?null:Nr.createPortal(e.jsx(le,{children:e.jsx(Dv,{ref:w,$isOpen:!0,onClick:C=>{C.target===C.currentTarget&&s()},children:e.jsxs(Nv,{onClick:C=>C.stopPropagation(),onWheel:C=>{C.preventDefault(),C.stopPropagation(),h(C)},onMouseMove:l,onMouseUp:m,onMouseLeave:m,children:[e.jsx(Fv,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:a,onMouseDown:d,draggable:!1}),e.jsx(ko,{$variant:"ghost",onClick:s,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(Ke,{size:14})}),e.jsxs(Bv,{children:[e.jsxs(Uv,{children:[e.jsx(ko,{$variant:"ghost",onClick:()=>g(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(qh,{size:14})}),e.jsxs(Wv,{children:[Math.round(o*100),"%"]}),e.jsx(ko,{$variant:"ghost",onClick:()=>g(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Gh,{size:14})}),e.jsx(ko,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(Sh,{size:14})})]}),e.jsxs(Hl,{$variant:"primary",onClick:p,title:"Download image",children:[e.jsx(Qo,{size:14}),"Download"]})]})]})})}),document.body)};function ql({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:a,selectedSession:s,selectSession:p}=Uo(),g=s==null?void 0:s.id;if(!g)return e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsx(Ni,{children:e.jsxs(Fi,{children:[e.jsx(jn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,h=!0,d="Start a conversation by typing a message below",[l,m]=i.useState(""),[x,v]=i.useState(!1),[w,C]=i.useState(null),[$,y]=i.useState([]),[z,_]=i.useState([]),[k,b]=i.useState(null),[f,I]=i.useState(1),[j,S]=i.useState(!1),[R,E]=i.useState({x:0,y:0}),[T,P]=i.useState({x:0,y:0}),O=i.useRef(null),D=i.useRef(null),{messages:M,pendingMessage:N,pendingImages:F,connectionState:J,isConnected:ie,isExecuting:re,executionStatus:X,isWaitingForInput:U,sendMessage:Z,submitUserInput:Q,cancelExecution:ae}=lc({contextId:g,agentName:o,token:n,platformAdapter:a,autoConnect:c});i.useEffect(()=>{var G;(G=O.current)==null||G.scrollIntoView({behavior:"smooth"})},[M]),i.useEffect(()=>{var G;if(U){const ne=M.slice().reverse().find(ye=>{var be;return((be=ye.metadata)==null?void 0:be.type)==="user_input_request"});(G=ne==null?void 0:ne.metadata)!=null&&G.userInputRequest&&C(ne.metadata.userInputRequest)}else C(null),y([])},[U,M]);const oe=G=>{if(G.preventDefault(),!!ie)if(U&&w){let ne=l.trim();w.input_type==="multiselect"&&(ne=$.join(",")),ne&&(Q(ne),m(""),y([]))}else!re&&l.trim()&&(Z(l,z.length>0?z:void 0),m(""),_([]))},ce=G=>{const ne=G.target.files;ne&&(Array.from(ne).forEach(ye=>{if(ye.type.startsWith("image/")){const be=new FileReader;be.onload=te=>{var $e;if(($e=te.target)!=null&&$e.result){const ke=te.target.result.split(",")[1];_(Te=>[...Te,{mime_type:ye.type,data:ke}])}},be.readAsDataURL(ye)}}),D.current&&(D.current.value=""))},Y=G=>{_(ne=>ne.filter((ye,be)=>be!==G))},se=G=>{b(G),I(1),E({x:0,y:0})},q=()=>{b(null),I(1),E({x:0,y:0}),S(!1)},H=G=>{const ne=document.createElement("a");ne.href=G,ne.download=`image-${Date.now()}.png`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne)},A=G=>{I(ne=>{const ye=ne+G;return Math.min(Math.max(ye,.5),3)})},B=G=>{G.preventDefault(),G.stopPropagation();const ne=G.deltaY>0?-.1:.1;A(ne)},L=G=>{f>1&&(S(!0),P({x:G.clientX-R.x,y:G.clientY-R.y}))},W=G=>{j&&f>1&&E({x:G.clientX-T.x,y:G.clientY-T.y})},ee=()=>{S(!1)},pe=()=>J.status===xt.CONNECTING?"Connecting...":J.status===xt.ERROR?"Connection error":J.status===xt.DISCONNECTED||!ie?"Disconnected":U?"Waiting for your input...":re?"Working...":"Ready",Se=()=>{if(!U||!w)return"Ask anything";switch(w.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},Ne=()=>!U||!w?!1:["select","multiselect","boolean","date"].includes(w.input_type||"");return e.jsxs(le,{style:{height:"100%",width:"100%"},children:[e.jsxs(Ni,{children:[e.jsxs(pv,{children:[e.jsxs(hv,{children:[t&&e.jsx(fv,{onClick:()=>{r?r():p(null)},children:e.jsx(Ur,{size:20})}),e.jsxs(gv,{children:[e.jsx(mv,{children:e.jsx(jn,{size:20})}),e.jsxs(xv,{children:[e.jsx(bv,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(vv,{$status:pe()}),e.jsx(yv,{$status:pe(),children:pe()})]})]})]})]}),X!==Me.IDLE&&e.jsx(wv,{$status:X,children:X.replace("_"," ")})]}),e.jsx(jv,{children:M.length===0&&h?e.jsxs(Fi,{children:[e.jsx(jn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:d})]}):e.jsxs(e.Fragment,{children:[M.map((G,ne)=>{var ye,be,te,$e;if(((ye=G.metadata)==null?void 0:ye.type)==="user_input_request"&&G.metadata.userInputRequest){const fe=G.metadata.userInputRequest,ke=!fe.input_type||fe.input_type==="text"||fe.input_type==="number",Te=U&&(w==null?void 0:w.input_type)===fe.input_type;return e.jsx(Vn,{$isUser:!1,children:e.jsxs(Sv,{children:[e.jsx("div",{className:"question",children:fe.question}),fe.context&&fe.context.trim()&&e.jsx("div",{className:"context",children:fe.context}),!ke&&e.jsxs("div",{className:"controls",children:[fe.input_type==="select"&&fe.options&&e.jsxs("select",{value:Te?l:"",onChange:Ee=>m(Ee.target.value),disabled:!Te,children:[e.jsx("option",{value:"",children:"Choose an option..."}),fe.options.map(Ee=>e.jsx("option",{value:Ee,children:Ee},Ee))]}),fe.input_type==="multiselect"&&fe.options&&e.jsx("div",{className:"checkbox-group",children:fe.options.map(Ee=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Te&&$.includes(Ee),onChange:or=>{or.target.checked?y([...$,Ee]):y($.filter(nr=>nr!==Ee))},disabled:!Te}),e.jsx("span",{children:Ee})]},Ee))}),fe.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Te&&l==="true",onChange:Ee=>m(Ee.target.value),disabled:!Te}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Te&&l==="false",onChange:Ee=>m(Ee.target.value),disabled:!Te}),e.jsx("span",{children:"No"})]})]}),fe.input_type==="date"&&e.jsx("input",{type:"date",value:Te?l:"",onChange:Ee=>m(Ee.target.value),disabled:!Te})]}),e.jsx("div",{className:"instruction",children:Te?ke?"Type your response below":fe.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},G.id)}if(((be=G.metadata)==null?void 0:be.type)==="log"){const fe=M[ne-1],ke=M[ne+1],Te=((te=fe==null?void 0:fe.metadata)==null?void 0:te.type)==="log",Ee=(($e=ke==null?void 0:ke.metadata)==null?void 0:$e.type)==="log",or=Te||Ee,nr=!Te&&Ee,Vr=Te&&!Ee;return e.jsx(Cv,{$isGrouped:or,$isFirstInGroup:nr,$isLastInGroup:Vr,children:e.jsx("div",{className:"log-content",children:G.content})},G.id)}return!G.content&&(!G.images||G.images.length===0)?null:e.jsx(Vn,{$isUser:G.role==="user",children:e.jsxs(Gl,{$isUser:G.role==="user",children:[e.jsx("div",{children:G.content}),G.images&&G.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:G.images.map((fe,ke)=>{const Te=fe.url||`data:${fe.mime_type};base64,${fe.data}`;return e.jsxs(Vv,{onClick:()=>se(Te),title:"Click to preview",children:[e.jsx("img",{src:Te,alt:`Image ${ke+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(fh,{size:14})})]},ke)})}),G.isStreaming&&e.jsx(kv,{})]})},G.id)}),N&&e.jsx(Vn,{$isUser:!0,children:e.jsxs(_v,{$isUser:!0,children:[e.jsx("div",{children:N}),F&&F.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:F.map((G,ne)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:G.data?`data:${G.mime_type};base64,${G.data}`:"#",alt:`Image ${ne+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},ne))})]})}),e.jsx("div",{ref:O})]})}),z.length>0&&e.jsx(Iv,{children:z.map((G,ne)=>e.jsxs(Tv,{children:[e.jsx("img",{src:G.data?`data:${G.mime_type};base64,${G.data}`:"#",alt:`Upload ${ne+1}`}),e.jsx(Ov,{type:"button",onClick:()=>Y(ne),children:e.jsx(Ke,{size:12})})]},ne))}),e.jsx($v,{onSubmit:oe,children:e.jsxs(zv,{children:[e.jsxs(Ev,{children:[e.jsx(Pv,{value:l,onChange:G=>m(G.target.value),onKeyDown:G=>{G.key==="Enter"&&!G.shiftKey&&(G.preventDefault(),oe(G))},placeholder:Se(),disabled:!ie||re&&!U||Ne(),rows:1}),e.jsx(Rv,{children:e.jsxs(Lv,{type:"button",disabled:!ie||re,onClick:()=>{var G;return(G=D.current)==null?void 0:G.click()},children:[e.jsx(Eh,{size:16}),"Attach"]})}),e.jsx(Mv,{ref:D,type:"file",accept:"image/*",multiple:!0,onChange:ce})]}),e.jsx(Av,{type:re?"button":"submit",disabled:!ie||!U&&!re&&!l.trim(),onClick:re?ae:void 0,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{background:re&&x?"var(--color-error)":void 0},children:re?x?e.jsx(Ke,{size:14}):e.jsx(vr,{size:14,className:"animate-spin"}):e.jsx(qc,{size:14})})]})})]}),e.jsx(Gv,{isOpen:!!k,imageUrl:k,zoomLevel:f,dragPosition:R,isDragging:j,onClose:q,onDownload:()=>k&&H(k),onZoom:A,onReset:()=>{I(1),E({x:0,y:0})},onWheel:B,onMouseDown:L,onMouseMove:W,onMouseUp:ee})]})}const Hv=u.div`
5493
+ `,Gv=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:a,onClose:s,onDownload:h,onZoom:g,onReset:c,onWheel:p,onMouseDown:l,onMouseMove:d,onMouseUp:m})=>{const[x,v]=i.useState(!1),w=i.useRef(null);return i.useEffect(()=>(v(!0),()=>v(!1)),[]),i.useEffect(()=>{if(t){const $=document.body.style.overflow;document.body.style.overflow="hidden";const z=k=>{(k.ctrlKey||k.metaKey)&&k.preventDefault()},y=k=>{k.preventDefault()},C=k=>{k.preventDefault()};return document.addEventListener("wheel",z,{passive:!1}),document.addEventListener("gesturestart",y,{passive:!1}),document.addEventListener("gesturechange",C,{passive:!1}),()=>{document.body.style.overflow=$,document.removeEventListener("wheel",z),document.removeEventListener("gesturestart",y),document.removeEventListener("gesturechange",C)}}},[t]),!x||!t||!r?null:Fr.createPortal(e.jsx(le,{children:e.jsx(Dv,{ref:w,$isOpen:!0,onClick:$=>{$.target===$.currentTarget&&s()},children:e.jsxs(Nv,{onClick:$=>$.stopPropagation(),onWheel:$=>{$.preventDefault(),$.stopPropagation(),p($)},onMouseMove:d,onMouseUp:m,onMouseLeave:m,children:[e.jsx(Fv,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:a,onMouseDown:l,draggable:!1}),e.jsx(_o,{$variant:"ghost",onClick:s,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(Ke,{size:14})}),e.jsxs(Bv,{children:[e.jsxs(Uv,{children:[e.jsx(_o,{$variant:"ghost",onClick:()=>g(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(qh,{size:14})}),e.jsxs(Wv,{children:[Math.round(o*100),"%"]}),e.jsx(_o,{$variant:"ghost",onClick:()=>g(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Gh,{size:14})}),e.jsx(_o,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(Sh,{size:14})})]}),e.jsxs(Hl,{$variant:"primary",onClick:h,title:"Download image",children:[e.jsx(Qo,{size:14}),"Download"]})]})]})})}),document.body)};function ql({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:a,selectedSession:s,selectSession:h}=Uo(),g=s==null?void 0:s.id;if(!g)return e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsx(Ni,{children:e.jsxs(Fi,{children:[e.jsx(jn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,p=!0,l="Start a conversation by typing a message below",[d,m]=i.useState(""),[x,v]=i.useState(!1),[w,$]=i.useState(null),[z,y]=i.useState([]),[C,k]=i.useState([]),[S,b]=i.useState(null),[f,E]=i.useState(1),[j,_]=i.useState(!1),[I,P]=i.useState({x:0,y:0}),[T,R]=i.useState({x:0,y:0}),O=i.useRef(null),D=i.useRef(null),{messages:M,pendingMessage:Y,pendingImages:N,connectionState:J,isConnected:ae,isExecuting:ee,executionStatus:F,isWaitingForInput:U,sendMessage:G,submitUserInput:X,cancelExecution:se}=lc({contextId:g,agentName:o,token:n,platformAdapter:a,autoConnect:c});i.useEffect(()=>{var H;(H=O.current)==null||H.scrollIntoView({behavior:"smooth"})},[M]),i.useEffect(()=>{var H;if(U){const ne=M.slice().reverse().find(ye=>{var be;return((be=ye.metadata)==null?void 0:be.type)==="user_input_request"});(H=ne==null?void 0:ne.metadata)!=null&&H.userInputRequest&&$(ne.metadata.userInputRequest)}else $(null),y([])},[U,M]);const oe=H=>{if(H.preventDefault(),!!ae)if(U&&w){let ne=d.trim();w.input_type==="multiselect"&&(ne=z.join(",")),ne&&(X(ne),m(""),y([]))}else!ee&&d.trim()&&(G(d,C.length>0?C:void 0),m(""),k([]))},ce=H=>{const ne=H.target.files;ne&&(Array.from(ne).forEach(ye=>{if(ye.type.startsWith("image/")){const be=new FileReader;be.onload=re=>{var $e;if(($e=re.target)!=null&&$e.result){const ke=re.target.result.split(",")[1];k(Te=>[...Te,{mime_type:ye.type,data:ke}])}},be.readAsDataURL(ye)}}),D.current&&(D.current.value=""))},K=H=>{k(ne=>ne.filter((ye,be)=>be!==H))},ie=H=>{b(H),E(1),P({x:0,y:0})},Z=()=>{b(null),E(1),P({x:0,y:0}),_(!1)},q=H=>{const ne=document.createElement("a");ne.href=H,ne.download=`image-${Date.now()}.png`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne)},A=H=>{E(ne=>{const ye=ne+H;return Math.min(Math.max(ye,.5),3)})},B=H=>{H.preventDefault(),H.stopPropagation();const ne=H.deltaY>0?-.1:.1;A(ne)},L=H=>{f>1&&(_(!0),R({x:H.clientX-I.x,y:H.clientY-I.y}))},W=H=>{j&&f>1&&P({x:H.clientX-T.x,y:H.clientY-T.y})},te=()=>{_(!1)},pe=()=>J.status===xt.CONNECTING?"Connecting...":J.status===xt.ERROR?"Connection error":J.status===xt.DISCONNECTED||!ae?"Disconnected":U?"Waiting for your input...":ee?"Working...":"Ready",Se=()=>{if(!U||!w)return"Ask anything";switch(w.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},Ne=()=>!U||!w?!1:["select","multiselect","boolean","date"].includes(w.input_type||"");return e.jsxs(le,{style:{height:"100%",width:"100%"},children:[e.jsxs(Ni,{children:[e.jsxs(pv,{children:[e.jsxs(hv,{children:[t&&e.jsx(fv,{onClick:()=>{r?r():h(null)},children:e.jsx(Wr,{size:20})}),e.jsxs(gv,{children:[e.jsx(mv,{children:e.jsx(jn,{size:20})}),e.jsxs(xv,{children:[e.jsx(bv,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(vv,{$status:pe()}),e.jsx(yv,{$status:pe(),children:pe()})]})]})]})]}),F!==Me.IDLE&&e.jsx(wv,{$status:F,children:F.replace("_"," ")})]}),e.jsx(jv,{children:M.length===0&&p?e.jsxs(Fi,{children:[e.jsx(jn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:l})]}):e.jsxs(e.Fragment,{children:[M.map((H,ne)=>{var ye,be,re,$e;if(((ye=H.metadata)==null?void 0:ye.type)==="user_input_request"&&H.metadata.userInputRequest){const fe=H.metadata.userInputRequest,ke=!fe.input_type||fe.input_type==="text"||fe.input_type==="number",Te=U&&(w==null?void 0:w.input_type)===fe.input_type;return e.jsx(Vn,{$isUser:!1,children:e.jsxs(Sv,{children:[e.jsx("div",{className:"question",children:fe.question}),fe.context&&fe.context.trim()&&e.jsx("div",{className:"context",children:fe.context}),!ke&&e.jsxs("div",{className:"controls",children:[fe.input_type==="select"&&fe.options&&e.jsxs("select",{value:Te?d:"",onChange:Ee=>m(Ee.target.value),disabled:!Te,children:[e.jsx("option",{value:"",children:"Choose an option..."}),fe.options.map(Ee=>e.jsx("option",{value:Ee,children:Ee},Ee))]}),fe.input_type==="multiselect"&&fe.options&&e.jsx("div",{className:"checkbox-group",children:fe.options.map(Ee=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Te&&z.includes(Ee),onChange:or=>{or.target.checked?y([...z,Ee]):y(z.filter(nr=>nr!==Ee))},disabled:!Te}),e.jsx("span",{children:Ee})]},Ee))}),fe.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Te&&d==="true",onChange:Ee=>m(Ee.target.value),disabled:!Te}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Te&&d==="false",onChange:Ee=>m(Ee.target.value),disabled:!Te}),e.jsx("span",{children:"No"})]})]}),fe.input_type==="date"&&e.jsx("input",{type:"date",value:Te?d:"",onChange:Ee=>m(Ee.target.value),disabled:!Te})]}),e.jsx("div",{className:"instruction",children:Te?ke?"Type your response below":fe.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},H.id)}if(((be=H.metadata)==null?void 0:be.type)==="log"){const fe=M[ne-1],ke=M[ne+1],Te=((re=fe==null?void 0:fe.metadata)==null?void 0:re.type)==="log",Ee=(($e=ke==null?void 0:ke.metadata)==null?void 0:$e.type)==="log",or=Te||Ee,nr=!Te&&Ee,Gr=Te&&!Ee;return e.jsx(Cv,{$isGrouped:or,$isFirstInGroup:nr,$isLastInGroup:Gr,children:e.jsx("div",{className:"log-content",children:H.content})},H.id)}return!H.content&&(!H.images||H.images.length===0)?null:e.jsx(Vn,{$isUser:H.role==="user",children:e.jsxs(Gl,{$isUser:H.role==="user",children:[e.jsx("div",{children:H.content}),H.images&&H.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:H.images.map((fe,ke)=>{const Te=fe.url||`data:${fe.mime_type};base64,${fe.data}`;return e.jsxs(Vv,{onClick:()=>ie(Te),title:"Click to preview",children:[e.jsx("img",{src:Te,alt:`Image ${ke+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(fh,{size:14})})]},ke)})}),H.isStreaming&&e.jsx(kv,{})]})},H.id)}),Y&&e.jsx(Vn,{$isUser:!0,children:e.jsxs(_v,{$isUser:!0,children:[e.jsx("div",{children:Y}),N&&N.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:N.map((H,ne)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:H.data?`data:${H.mime_type};base64,${H.data}`:"#",alt:`Image ${ne+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},ne))})]})}),e.jsx("div",{ref:O})]})}),C.length>0&&e.jsx(Iv,{children:C.map((H,ne)=>e.jsxs(Tv,{children:[e.jsx("img",{src:H.data?`data:${H.mime_type};base64,${H.data}`:"#",alt:`Upload ${ne+1}`}),e.jsx(Ov,{type:"button",onClick:()=>K(ne),children:e.jsx(Ke,{size:12})})]},ne))}),e.jsx($v,{onSubmit:oe,children:e.jsxs(zv,{children:[e.jsxs(Ev,{children:[e.jsx(Pv,{value:d,onChange:H=>m(H.target.value),onKeyDown:H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),oe(H))},placeholder:Se(),disabled:!ae||ee&&!U||Ne(),rows:1}),e.jsx(Rv,{children:e.jsxs(Lv,{type:"button",disabled:!ae||ee,onClick:()=>{var H;return(H=D.current)==null?void 0:H.click()},children:[e.jsx(Eh,{size:16}),"Attach"]})}),e.jsx(Mv,{ref:D,type:"file",accept:"image/*",multiple:!0,onChange:ce})]}),e.jsx(Av,{type:ee?"button":"submit",disabled:!ae||!U&&!ee&&!d.trim(),onClick:ee?se:void 0,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{background:ee&&x?"var(--color-error)":void 0},children:ee?x?e.jsx(Ke,{size:14}):e.jsx(vr,{size:14,className:"animate-spin"}):e.jsx(qc,{size:14})})]})})]}),e.jsx(Gv,{isOpen:!!S,imageUrl:S,zoomLevel:f,dragPosition:I,isDragging:j,onClose:Z,onDownload:()=>S&&q(S),onZoom:A,onReset:()=>{E(1),P({x:0,y:0})},onWheel:B,onMouseDown:L,onMouseMove:W,onMouseUp:te})]})}const Hv=u.div`
5490
5494
  height: 100%;
5491
5495
  display: flex;
5492
5496
  flex-direction: column;
@@ -5681,7 +5685,7 @@ cursor: pointer;
5681
5685
  background: var(--color-border);
5682
5686
  border-radius: var(--radius-sm);
5683
5687
  opacity: 0.6;
5684
- `;function Yl({showBackButton:t=!1}){const[r,o]=i.useState(""),{sessions:n,loadingSessions:a,selectSession:s,deleteSession:p,setShowHistory:g}=Uo(),c=n.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())),h=x=>{const v={},w=new Date,C=new Date(w.getFullYear(),w.getMonth(),w.getDate()),$=new Date(C);$.setDate($.getDate()-1);const y=new Date(C);return y.setDate(y.getDate()-7),x.forEach(z=>{const _=new Date(z.last_activity_at);let k;_>=C?k="Today":_>=$?k="Yesterday":_>=y?k="This Week":k="Older",v[k]||(v[k]=[]),v[k].push(z)}),v},d=async(x,v)=>{if(x.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await p(v)}catch(w){console.error("Failed to delete session:",w)}},l=x=>new Date(x).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m=h(c);return e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsxs(Hv,{children:[e.jsxs(qv,{children:[t&&e.jsx(Yv,{onClick:()=>g(!1),children:e.jsx(Ur,{size:20})}),e.jsx(Zv,{children:"Conversation History"})]}),e.jsx(Kv,{children:e.jsx(Qv,{type:"text",placeholder:"Search conversations...",value:r,onChange:x=>o(x.target.value)})}),e.jsx(Xv,{children:a?e.jsx(l2,{children:[1,2,3,4,5].map(x=>e.jsxs(d2,{children:[e.jsx(u2,{}),e.jsxs(p2,{children:[e.jsx(h2,{}),e.jsx(f2,{})]})]},x))}):c.length===0?e.jsxs(c2,{children:[e.jsx(cs,{}),e.jsx("div",{children:"No conversations found"}),r&&e.jsx("div",{style:{fontSize:"var(--font-xs)",marginTop:"var(--space-sm)"},children:"Try a different search term"})]}):Object.entries(m).map(([x,v])=>e.jsxs(Jv,{children:[e.jsx(e2,{children:x}),v.map(w=>e.jsxs(t2,{onClick:()=>s(w),children:[e.jsx(r2,{children:e.jsx(cs,{size:18})}),e.jsxs(o2,{children:[e.jsx(n2,{children:w.title}),e.jsxs(a2,{children:[e.jsx("span",{children:l(w.last_activity_at)}),w.status!=="idle"&&e.jsx(s2,{$status:w.status,children:w.status.replace("_"," ")})]})]}),e.jsx(i2,{onClick:C=>d(C,w.id),children:e.jsx(Jo,{size:16})})]},w.id))]},x))})]})})}const g2=u.div`
5688
+ `;function Yl({showBackButton:t=!1}){const[r,o]=i.useState(""),{sessions:n,loadingSessions:a,selectSession:s,deleteSession:h,setShowHistory:g}=Uo(),c=n.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())),p=x=>{const v={},w=new Date,$=new Date(w.getFullYear(),w.getMonth(),w.getDate()),z=new Date($);z.setDate(z.getDate()-1);const y=new Date($);return y.setDate(y.getDate()-7),x.forEach(C=>{const k=new Date(C.last_activity_at);let S;k>=$?S="Today":k>=z?S="Yesterday":k>=y?S="This Week":S="Older",v[S]||(v[S]=[]),v[S].push(C)}),v},l=async(x,v)=>{if(x.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await h(v)}catch(w){console.error("Failed to delete session:",w)}},d=x=>new Date(x).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m=p(c);return e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsxs(Hv,{children:[e.jsxs(qv,{children:[t&&e.jsx(Yv,{onClick:()=>g(!1),children:e.jsx(Wr,{size:20})}),e.jsx(Zv,{children:"Conversation History"})]}),e.jsx(Kv,{children:e.jsx(Qv,{type:"text",placeholder:"Search conversations...",value:r,onChange:x=>o(x.target.value)})}),e.jsx(Xv,{children:a?e.jsx(l2,{children:[1,2,3,4,5].map(x=>e.jsxs(d2,{children:[e.jsx(u2,{}),e.jsxs(p2,{children:[e.jsx(h2,{}),e.jsx(f2,{})]})]},x))}):c.length===0?e.jsxs(c2,{children:[e.jsx(cs,{}),e.jsx("div",{children:"No conversations found"}),r&&e.jsx("div",{style:{fontSize:"var(--font-xs)",marginTop:"var(--space-sm)"},children:"Try a different search term"})]}):Object.entries(m).map(([x,v])=>e.jsxs(Jv,{children:[e.jsx(e2,{children:x}),v.map(w=>e.jsxs(t2,{onClick:()=>s(w),children:[e.jsx(r2,{children:e.jsx(cs,{size:18})}),e.jsxs(o2,{children:[e.jsx(n2,{children:w.title}),e.jsxs(a2,{children:[e.jsx("span",{children:d(w.last_activity_at)}),w.status!=="idle"&&e.jsx(s2,{$status:w.status,children:w.status.replace("_"," ")})]})]}),e.jsx(i2,{onClick:$=>l($,w.id),children:e.jsx(Jo,{size:16})})]},w.id))]},x))})]})})}const g2=u.div`
5685
5689
  height: 100%;
5686
5690
  display: flex;
5687
5691
  flex-direction: column;
@@ -5839,5 +5843,5 @@ cursor: pointer;
5839
5843
  display: flex;
5840
5844
  flex-direction: column;
5841
5845
  gap: var(--space-xs);
5842
- `;function R2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:a,selectSession:s,createSession:p,setShowHistory:g}=Uo(),c=async()=>{try{r(!0),await p()}finally{r(!1)}},h=d=>{try{const l=new Date(d),x=new Date().getTime()-l.getTime(),v=Math.floor(x/6e4),w=Math.floor(v/60),C=Math.floor(w/24);return C>0?`${C}d ago`:w>0?`${w}h ago`:v>0?`${v}m ago`:"Just now"}catch{return""}};return a?e.jsx(Yl,{showBackButton:!0}):n?e.jsx(ql,{showBackButton:!0}):e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsx(g2,{children:e.jsxs(m2,{children:[e.jsx(x2,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(v2,{children:"Hi there! 👋"}),e.jsx(b2,{children:"How can I help you today?"}),e.jsx(y2,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(w2,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(S2,{children:[e.jsxs($2,{children:[e.jsx(z2,{children:"Recent Chats"}),e.jsx(E2,{onClick:()=>g(!0),children:"View All →"})]}),e.jsx(P2,{children:o.slice(0,2).map(d=>e.jsx(j2,{onClick:()=>s(d),children:e.jsxs(C2,{children:[e.jsx(k2,{children:d.title}),e.jsxs(_2,{children:[e.jsx("span",{children:h(d.last_activity_at)}),d.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},d.id))})]})]})})})}const I2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(a=>r.startsWith(a))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(a=>r.startsWith(a))},T2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=qg;exports.AgentConversation=ql;exports.AgentConversationHistory=Yl;exports.AgentConversationHub=R2;exports.AgentConversationProvider=Id;exports.AuthFormImage=Ae;exports.ChannelSelector=uv;exports.CreateOrganizationForm=rn;exports.CreateWorkspaceDialog=yl;exports.CreateWorkspaceForm=_a;exports.DeploymentInitialized=iu;exports.DeploymentInitializing=cu;exports.DeploymentProvider=Ql;exports.Dialog=we;exports.DialogTrigger=lf;exports.Dropdown=ot;exports.DropdownDivider=tn;exports.DropdownItem=Pe;exports.DropdownItems=nt;exports.DropdownTrigger=at;exports.Form=dt;exports.FormGroup=he;exports.Input=de;exports.Label=ue;exports.MagicLinkVerification=Fg;exports.ManageAccount=Dl;exports.ManageAccountDialog=Nl;exports.ManageOrganization=xl;exports.ManageWorkspace=jl;exports.ManageWorkspaceDialog=kl;exports.NavigateToSignIn=G1;exports.NavigateToSignUp=H1;exports.NavigationLink=tt;exports.NotificationBell=Wl;exports.NotificationItem=Bl;exports.NotificationPopover=Ul;exports.OAuthProvider=Xi;exports.OTPInput=Rt;exports.OrganizationSwitcher=Cl;exports.PhoneNumberInput=Br;exports.PhoneVerification=ll;exports.ProfileCompletion=ul;exports.RequireActiveTenancy=sv;exports.SSOCallback=Rg;exports.SignInForm=ug;exports.SignUpForm=Vp;exports.SignedIn=E1;exports.SignedInAccounts=V1;exports.SignedOut=P1;exports.SimpleDialog=cf;exports.Spinner=Re;exports.Switch=Ao;exports.TwoFactorMethodSelector=cl;exports.TwoFactorVerification=dl;exports.UserButton=$a;exports.UserControls=z1;exports.WaitlistForm=Sg;exports.clearTokenCache=Qt;exports.fetchChannelCounts=tu;exports.hasIncompleteProfile=Bg;exports.isExternalUrl=I2;exports.isSafeUrl=T2;exports.redirectToProfileCompletion=Ug;exports.useActiveOrganization=Qe;exports.useActiveTenancy=Jd;exports.useActiveWorkspace=Pt;exports.useAgentConversation=lc;exports.useAgentConversationContext=Uo;exports.useChannelCounts=su;exports.useClient=De;exports.useConversationSessions=Ki;exports.useDeployment=ve;exports.useForgotPassword=sc;exports.useInvitation=dc;exports.useMagicLinkParams=ac;exports.useMagicLinkVerification=nc;exports.useNavigation=He;exports.useNotificationStream=ic;exports.useNotifications=cc;exports.useOrganizationList=Wo;exports.useOrganizationMemberships=bt;exports.useSSOCallback=oc;exports.useSession=Fe;exports.useSignIn=Ji;exports.useSignInWithStrategy=Ar;exports.useSignUp=ec;exports.useUser=rr;exports.useUserSignins=tc;exports.useWaitlist=rc;exports.useWorkspaceList=yt;exports.useWorkspaceMemberships=Vo;Object.keys(Ve).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Ve[t]})});
5846
+ `;function R2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:a,selectSession:s,createSession:h,setShowHistory:g}=Uo(),c=async()=>{try{r(!0),await h()}finally{r(!1)}},p=l=>{try{const d=new Date(l),x=new Date().getTime()-d.getTime(),v=Math.floor(x/6e4),w=Math.floor(v/60),$=Math.floor(w/24);return $>0?`${$}d ago`:w>0?`${w}h ago`:v>0?`${v}m ago`:"Just now"}catch{return""}};return a?e.jsx(Yl,{showBackButton:!0}):n?e.jsx(ql,{showBackButton:!0}):e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsx(g2,{children:e.jsxs(m2,{children:[e.jsx(x2,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(v2,{children:"Hi there! 👋"}),e.jsx(b2,{children:"How can I help you today?"}),e.jsx(y2,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(w2,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(S2,{children:[e.jsxs($2,{children:[e.jsx(z2,{children:"Recent Chats"}),e.jsx(E2,{onClick:()=>g(!0),children:"View All →"})]}),e.jsx(P2,{children:o.slice(0,2).map(l=>e.jsx(j2,{onClick:()=>s(l),children:e.jsxs(C2,{children:[e.jsx(k2,{children:l.title}),e.jsxs(_2,{children:[e.jsx("span",{children:p(l.last_activity_at)}),l.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},l.id))})]})]})})})}const I2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(a=>r.startsWith(a))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(a=>r.startsWith(a))},T2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=qg;exports.AgentConversation=ql;exports.AgentConversationHistory=Yl;exports.AgentConversationHub=R2;exports.AgentConversationProvider=Id;exports.AuthFormImage=Ae;exports.ChannelSelector=uv;exports.CreateOrganizationForm=rn;exports.CreateWorkspaceDialog=yl;exports.CreateWorkspaceForm=_a;exports.DeploymentInitialized=iu;exports.DeploymentInitializing=cu;exports.DeploymentProvider=Ql;exports.Dialog=we;exports.DialogTrigger=lf;exports.Dropdown=ot;exports.DropdownDivider=tn;exports.DropdownItem=Pe;exports.DropdownItems=nt;exports.DropdownTrigger=at;exports.Form=dt;exports.FormGroup=he;exports.Input=de;exports.Label=ue;exports.MagicLinkVerification=Fg;exports.ManageAccount=Dl;exports.ManageAccountDialog=Nl;exports.ManageOrganization=xl;exports.ManageWorkspace=jl;exports.ManageWorkspaceDialog=kl;exports.NavigateToSignIn=G1;exports.NavigateToSignUp=H1;exports.NavigationLink=tt;exports.NotificationBell=Wl;exports.NotificationItem=Bl;exports.NotificationPopover=Ul;exports.OAuthProvider=Xi;exports.OTPInput=Rt;exports.OrganizationSwitcher=Cl;exports.PhoneNumberInput=Ur;exports.PhoneVerification=ll;exports.ProfileCompletion=ul;exports.RequireActiveTenancy=sv;exports.SSOCallback=Rg;exports.SignInForm=ug;exports.SignUpForm=Vp;exports.SignedIn=E1;exports.SignedInAccounts=V1;exports.SignedOut=P1;exports.SimpleDialog=cf;exports.Spinner=Re;exports.Switch=br;exports.TwoFactorMethodSelector=cl;exports.TwoFactorVerification=dl;exports.UserButton=$a;exports.UserControls=z1;exports.WaitlistForm=Sg;exports.clearTokenCache=Qt;exports.fetchChannelCounts=tu;exports.hasIncompleteProfile=Bg;exports.isExternalUrl=I2;exports.isSafeUrl=T2;exports.redirectToProfileCompletion=Ug;exports.useActiveOrganization=Qe;exports.useActiveTenancy=Jd;exports.useActiveWorkspace=Pt;exports.useAgentConversation=lc;exports.useAgentConversationContext=Uo;exports.useChannelCounts=su;exports.useClient=De;exports.useConversationSessions=Ki;exports.useDeployment=xe;exports.useForgotPassword=sc;exports.useInvitation=dc;exports.useMagicLinkParams=ac;exports.useMagicLinkVerification=nc;exports.useNavigation=He;exports.useNotificationStream=ic;exports.useNotifications=cc;exports.useOrganizationList=Wo;exports.useOrganizationMemberships=bt;exports.useSSOCallback=oc;exports.useSession=Fe;exports.useSignIn=Ji;exports.useSignInWithStrategy=Dr;exports.useSignUp=ec;exports.useUser=rr;exports.useUserSignins=tc;exports.useWaitlist=rc;exports.useWorkspaceList=yt;exports.useWorkspaceMemberships=Vo;Object.keys(Ve).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Ve[t]})});
5843
5847
  //# sourceMappingURL=index.cjs.js.map