@wacht/jsx 0.0.1-alpha.43 → 0.0.1-alpha.45

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 xd=Object.defineProperty;var vd=(t,r,o)=>r in t?xd(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var tt=(t,r,o)=>vd(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),Wr=require("react-dom"),Bs=require("@wacht/types"),nc=i.createContext(void 0);function bd({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[s,a]=i.useState(!0),[p,g]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function l(){if(c.current)return;c.current=!0,a(!0);const[u,m,v]=r.split("_");if(!v)throw new Error("Invalid public key");let x=atob(v),y=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 w=new URL(window.location.href);w.searchParams.delete("__dev_session__"),window.history.replaceState({},"",w.toString())}else $=localStorage.getItem("__dev_session__");let S={};const k=new URLSearchParams;y?k.append("__dev_session__",$??""):S={credentials:"include"};const I=await fetch(`${x}/deployment${y?"?":""}${k.toString()}`,S);if(!I.ok){a(!1);return}const E=await I.json();E.data.backend_host=x,n&&(E.data.ui_settings={...E.data.ui_settings,...n}),g(E.data),y&&I.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",I.headers.get("x-development-session")??""),a(!1)}l()},[r]);const h=i.useMemo(()=>({loading:s,deployment:p,adapter:o}),[s,p,o]);return e.jsx(nc.Provider,{value:h,children:t})}function ve(){const t=i.useContext(nc);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 Be(){const{deployment:t,loading:r}=ve();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,s)=>{const a=yd(t),p=new Headers(a.headers);s!=null&&s.headers&&new Headers(s.headers).forEach((l,u)=>{p.set(u,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,{...a,...s,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 yd(t){return t.mode==="staging"?{}:{credentials:"include"}}var Kr={exports:{}},ln={};/**
2
+ "use strict";var gd=Object.defineProperty;var md=(t,r,o)=>r in t?gd(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var tt=(t,r,o)=>md(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),Wr=require("react-dom"),Bs=require("@wacht/types"),nc=i.createContext(void 0);function xd({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[s,a]=i.useState(!0),[p,g]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function l(){if(c.current)return;c.current=!0,a(!0);const[u,m,x]=r.split("_");if(!x)throw new Error("Invalid public key");let v=atob(x),y=m==="test",z=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){z=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",z??"");const w=new URL(window.location.href);w.searchParams.delete("__dev_session__"),window.history.replaceState({},"",w.toString())}else z=localStorage.getItem("__dev_session__");let S={};const _=new URLSearchParams;y?_.append("__dev_session__",z??""):S={credentials:"include"};const E=await fetch(`${v}/deployment${y?"?":""}${_.toString()}`,S);if(!E.ok){a(!1);return}const I=await E.json();I.data.backend_host=v,n&&(I.data.ui_settings={...I.data.ui_settings,...n}),g(I.data),y&&E.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",E.headers.get("x-development-session")??""),a(!1)}l()},[r]);const h=i.useMemo(()=>({loading:s,deployment:p,adapter:o}),[s,p,o]);return e.jsx(nc.Provider,{value:h,children:t})}function ve(){const t=i.useContext(nc);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 Be(){const{deployment:t,loading:r}=ve();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,s)=>{const a=vd(t),p=new Headers(a.headers);s!=null&&s.headers&&new Headers(s.headers).forEach((l,u)=>{p.set(u,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,{...a,...s,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 vd(t){return t.mode==="staging"?{}:{credentials:"include"}}var Kr={exports:{}},ln={};/**
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 Us;function wd(){if(Us)return ln;Us=1;var t=i;function r(u,m){return u===m&&(u!==0||1/u===1/m)||u!==u&&m!==m}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,s=t.useEffect,a=t.useLayoutEffect,p=t.useDebugValue;function g(u,m){var v=m(),x=n({inst:{value:v,getSnapshot:m}}),y=x[0].inst,$=x[1];return a(function(){y.value=v,y.getSnapshot=m,c(y)&&$({inst:y})},[u,v,m]),s(function(){return c(y)&&$({inst:y}),u(function(){c(y)&&$({inst:y})})},[u]),p(v),v}function c(u){var m=u.getSnapshot;u=u.value;try{var v=m();return!o(u,v)}catch{return!0}}function h(u,m){return m()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:g;return ln.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,ln}var dn={};/**
10
+ */var Us;function bd(){if(Us)return ln;Us=1;var t=i;function r(u,m){return u===m&&(u!==0||1/u===1/m)||u!==u&&m!==m}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,s=t.useEffect,a=t.useLayoutEffect,p=t.useDebugValue;function g(u,m){var x=m(),v=n({inst:{value:x,getSnapshot:m}}),y=v[0].inst,z=v[1];return a(function(){y.value=x,y.getSnapshot=m,c(y)&&z({inst:y})},[u,x,m]),s(function(){return c(y)&&z({inst:y}),u(function(){c(y)&&z({inst:y})})},[u]),p(x),x}function c(u){var m=u.getSnapshot;u=u.value;try{var x=m();return!o(u,x)}catch{return!0}}function h(u,m){return m()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:g;return ln.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,ln}var dn={};/**
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 Ws;function jd(){return Ws||(Ws=1,process.env.NODE_ENV!=="production"&&function(){function t(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}function r(v,x){l||s.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 y=x();if(!u){var $=x();a(y,$)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}$=p({inst:{value:y,getSnapshot:x}});var S=$[0].inst,k=$[1];return c(function(){S.value=y,S.getSnapshot=x,o(S)&&k({inst:S})},[v,y,x]),g(function(){return o(S)&&k({inst:S}),v(function(){o(S)&&k({inst:S})})},[v]),h(y),y}function o(v){var x=v.getSnapshot;v=v.value;try{var y=x();return!a(v,y)}catch{return!0}}function n(v,x){return x()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var s=i,a=typeof Object.is=="function"?Object.is:t,p=s.useState,g=s.useEffect,c=s.useLayoutEffect,h=s.useDebugValue,l=!1,u=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;dn.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),dn}var Vs;function _d(){return Vs||(Vs=1,process.env.NODE_ENV==="production"?Kr.exports=wd():Kr.exports=jd()),Kr.exports}var kd=_d();const sc=0,ac=1,ic=2,Gs=3;var Hs=Object.prototype.hasOwnProperty;function Kn(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--&&Kn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Hs.call(t,o)&&++n&&!Hs.call(r,o)||!(o in r)||!Kn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const jt=new WeakMap,$t=()=>{},qe=$t(),Qn=Object,Se=t=>t===qe,lt=t=>typeof t=="function",It=(t,r)=>({...t,...r}),cc=t=>lt(t.then),un={},Qr={},ys="undefined",Vr=typeof window!=ys,Xn=typeof document!=ys,Cd=Vr&&"Deno"in window,Sd=()=>Vr&&typeof window.requestAnimationFrame!=ys,lc=(t,r)=>{const o=jt.get(t);return[()=>!Se(r)&&t.get(r)||un,n=>{if(!Se(r)){const s=t.get(r);r in Qr||(Qr[r]=s),o[5](r,It(s,n),s||un)}},o[6],()=>!Se(r)&&r in Qr?Qr[r]:!Se(r)&&t.get(r)||un]};let Jn=!0;const zd=()=>Jn,[es,ts]=Vr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$t,$t],$d=()=>{const t=Xn&&document.visibilityState;return Se(t)||t!=="hidden"},Ed=t=>(Xn&&document.addEventListener("visibilitychange",t),es("focus",t),()=>{Xn&&document.removeEventListener("visibilitychange",t),ts("focus",t)}),Id=t=>{const r=()=>{Jn=!0,t()},o=()=>{Jn=!1};return es("online",r),es("offline",o),()=>{ts("online",r),ts("offline",o)}},Pd={isOnline:zd,isVisible:$d},Rd={initFocus:Ed,initReconnect:Id},qs=!i.useId,Fr=!Vr||Cd,Td=t=>Sd()?window.requestAnimationFrame(t):setTimeout(t,1),pn=Fr?i.useEffect:i.useLayoutEffect,hn=typeof navigator<"u"&&navigator.connection,Ys=!Fr&&hn&&(["slow-2g","2g"].includes(hn.effectiveType)||hn.saveData),Xr=new WeakMap,Md=t=>Qn.prototype.toString.call(t),fn=(t,r)=>t===`[object ${r}]`;let Od=0;const rs=t=>{const r=typeof t,o=Md(t),n=fn(o,"Date"),s=fn(o,"RegExp"),a=fn(o,"Object");let p,g;if(Qn(t)===t&&!n&&!s){if(p=Xr.get(t),p)return p;if(p=++Od+"~",Xr.set(t,p),Array.isArray(t)){for(p="@",g=0;g<t.length;g++)p+=rs(t[g])+",";Xr.set(t,p)}if(a){p="#";const c=Qn.keys(t).sort();for(;!Se(g=c.pop());)Se(t[g])||(p+=g+":"+rs(t[g])+",");Xr.set(t,p)}}else p=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return p},ws=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?rs(t):"",[t,r]};let Ad=0;const os=()=>++Ad;async function dc(...t){const[r,o,n,s]=t,a=It({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let p=a.populateCache;const g=a.rollbackOnError;let c=a.optimisticData;const h=m=>typeof g=="function"?g(m):g!==!1,l=a.throwOnError;if(lt(o)){const m=o,v=[],x=r.keys();for(const y of x)!/^\$(inf|sub)\$/.test(y)&&m(r.get(y)._k)&&v.push(y);return Promise.all(v.map(u))}return u(o);async function u(m){const[v]=ws(m);if(!v)return;const[x,y]=lc(r,v),[$,S,k,I]=jt.get(r),E=()=>{const P=$[v];return(lt(a.revalidate)?a.revalidate(x().data,m):a.revalidate!==!1)&&(delete k[v],delete I[v],P&&P[0])?P[0](ic).then(()=>x().data):x().data};if(t.length<3)return E();let w=n,b,f=!1;const z=os();S[v]=[z,0];const _=!Se(c),j=x(),M=j.data,R=j._c,C=Se(R)?M:R;if(_&&(c=lt(c)?c(C,M):c,y({data:c,_c:C})),lt(w))try{w=w(C)}catch(P){b=P,f=!0}if(w&&cc(w))if(w=await w.catch(P=>{b=P,f=!0}),z!==S[v][0]){if(f)throw b;return w}else f&&_&&h(b)&&(p=!0,y({data:C,_c:qe}));if(p&&!f)if(lt(p)){const P=p(w,C);y({data:P,error:qe,_c:qe})}else y({data:w,error:qe,_c:qe});if(S[v][1]=os(),Promise.resolve(E()).then(()=>{y({_c:qe})}),f){if(l)throw b;return}return w}}const Zs=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},Ld=(t,r)=>{if(!jt.has(t)){const o=It(Rd,r),n=Object.create(null),s=dc.bind(qe,t);let a=$t;const p=Object.create(null),g=(l,u)=>{const m=p[l]||[];return p[l]=m,m.push(u),()=>m.splice(m.indexOf(u),1)},c=(l,u,m)=>{t.set(l,u);const v=p[l];if(v)for(const x of v)x(u,m)},h=()=>{if(!jt.has(t)&&(jt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),s,c,g]),!Fr)){const l=o.initFocus(setTimeout.bind(qe,Zs.bind(qe,n,sc))),u=o.initReconnect(setTimeout.bind(qe,Zs.bind(qe,n,ac)));a=()=>{l&&l(),u&&u(),jt.delete(t)}}};return h(),[t,s,h,a]}return[t,jt.get(t)[4]]},Dd=(t,r,o,n,s)=>{const a=o.errorRetryCount,p=s.retryCount,g=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!Se(a)&&p>a||setTimeout(n,g,s)},Nd=Kn,[uc,Or]=Ld(new Map),Fd=It({onLoadingSlow:$t,onSuccess:$t,onError:$t,onErrorRetry:Dd,onDiscarded:$t,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ys?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ys?5e3:3e3,compare:Nd,isPaused:()=>!1,cache:uc,mutate:Or,fallback:{}},Pd),Bd=(t,r)=>{const o=It(t,r);if(r){const{use:n,fallback:s}=t,{use:a,fallback:p}=r;n&&a&&(o.use=n.concat(a)),s&&p&&(o.fallback=It(s,p))}return o},Ud=i.createContext({}),Wd="$inf$",pc=Vr&&window.__SWR_DEVTOOLS_USE__,Vd=pc?window.__SWR_DEVTOOLS_USE__:[],Gd=()=>{pc&&(window.__SWR_DEVTOOLS_REACT__=i)},Hd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],hc=()=>It(Fd,i.useContext(Ud)),qd=t=>(r,o,n)=>t(r,o&&((...a)=>{const[p]=ws(r),[,,,g]=jt.get(uc);if(p.startsWith(Wd))return o(...a);const c=g[p];return Se(c)?o(...a):(delete g[p],c)}),n),Yd=Vd.concat(qd),Zd=t=>function(...o){const n=hc(),[s,a,p]=Hd(o),g=Bd(n,p);let c=t;const{use:h}=g,l=(h||[]).concat(Yd);for(let u=l.length;u--;)c=l[u](c);return c(s,a||g.fetcher||null,g)},Kd=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const s=n.indexOf(o);s>=0&&(n[s]=n[n.length-1],n.pop())}};Gd();const gn=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}}),mn={dedupe:!0},Qd=(t,r,o)=>{const{cache:n,compare:s,suspense:a,fallbackData:p,revalidateOnMount:g,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:m}=o,[v,x,y,$]=jt.get(n),[S,k]=ws(t),I=i.useRef(!1),E=i.useRef(!1),w=i.useRef(S),b=i.useRef(r),f=i.useRef(o),z=()=>f.current,_=()=>z().isVisible()&&z().isOnline(),[j,M,R,C]=lc(n,S),P=i.useRef({}).current,T=Se(p)?Se(o.fallback)?qe:o.fallback[S]:p,B=(ue,U)=>{for(const pe in P){const Q=pe;if(Q==="data"){if(!s(ue[Q],U[Q])&&(!Se(ue[Q])||!s(H,U[Q])))return!1}else if(U[Q]!==ue[Q])return!1}return!0},L=i.useMemo(()=>{const ue=!S||!r?!1:Se(g)?z().isPaused()||a?!1:c!==!1:g,U=fe=>{const W=It(fe);return delete W._k,ue?{isValidating:!0,isLoading:!0,...W}:W},pe=j(),Q=C(),Y=U(pe),ne=pe===Q?Y:U(Q);let me=Y;return[()=>{const fe=U(j());return B(fe,me)?(me.data=fe.data,me.isLoading=fe.isLoading,me.isValidating=fe.isValidating,me.error=fe.error,me):(me=fe,fe)},()=>ne]},[n,S]),F=kd.useSyncExternalStore(i.useCallback(ue=>R(S,(U,pe)=>{B(pe,U)||ue()}),[n,S]),L[0],L[1]),O=!I.current,A=v[S]&&v[S].length>0,J=F.data,re=Se(J)?T&&cc(T)?gn(T):T:J,V=F.error,q=i.useRef(re),H=m?Se(J)?Se(q.current)?re:q.current:J:re,ee=A&&!Se(V)?!1:O&&!Se(g)?g:z().isPaused()?!1:a?Se(re)?!1:c:Se(re)||c,le=!!(S&&r&&O&&ee),oe=Se(F.isValidating)?le:F.isValidating,de=Se(F.isLoading)?le:F.isLoading,K=i.useCallback(async ue=>{const U=b.current;if(!S||!U||E.current||z().isPaused())return!1;let pe,Q,Y=!0;const ne=ue||{},me=!y[S]||!ne.dedupe,fe=()=>qs?!E.current&&S===w.current&&I.current:S===w.current,W={isValidating:!1,isLoading:!1},N=()=>{M(W)},D=()=>{const ae=y[S];ae&&ae[1]===Q&&delete y[S]},Z={isValidating:!0};Se(j().data)&&(Z.isLoading=!0);try{if(me&&(M(Z),o.loadingTimeout&&Se(j().data)&&setTimeout(()=>{Y&&fe()&&z().onLoadingSlow(S,o)},o.loadingTimeout),y[S]=[U(k),os()]),[pe,Q]=y[S],pe=await pe,me&&setTimeout(D,o.dedupingInterval),!y[S]||y[S][1]!==Q)return me&&fe()&&z().onDiscarded(S),!1;W.error=qe;const ae=x[S];if(!Se(ae)&&(Q<=ae[0]||Q<=ae[1]||ae[1]===0))return N(),me&&fe()&&z().onDiscarded(S),!1;const te=j().data;W.data=s(te,pe)?te:pe,me&&fe()&&z().onSuccess(pe,S,o)}catch(ae){D();const te=z(),{shouldRetryOnError:_e}=te;te.isPaused()||(W.error=ae,me&&fe()&&(te.onError(ae,S,te),(_e===!0||lt(_e)&&_e(ae))&&(!z().revalidateOnFocus||!z().revalidateOnReconnect||_())&&te.onErrorRetry(ae,S,te,be=>{const ze=v[S];ze&&ze[0]&&ze[0](Gs,be)},{retryCount:(ne.retryCount||0)+1,dedupe:!0})))}return Y=!1,N(),!0},[S,n]),se=i.useCallback((...ue)=>dc(n,w.current,...ue),[]);if(pn(()=>{b.current=r,f.current=o,Se(J)||(q.current=J)}),pn(()=>{if(!S)return;const ue=K.bind(qe,mn);let U=0;z().revalidateOnFocus&&(U=Date.now()+z().focusThrottleInterval);const Q=Kd(S,v,(Y,ne={})=>{if(Y==sc){const me=Date.now();z().revalidateOnFocus&&me>U&&_()&&(U=me+z().focusThrottleInterval,ue())}else if(Y==ac)z().revalidateOnReconnect&&_()&&ue();else{if(Y==ic)return K();if(Y==Gs)return K(ne)}});return E.current=!1,w.current=S,I.current=!0,M({_k:k}),ee&&(y[S]||(Se(re)||Fr?ue():Td(ue))),()=>{E.current=!0,Q()}},[S]),pn(()=>{let ue;function U(){const Q=lt(h)?h(j().data):h;Q&&ue!==-1&&(ue=setTimeout(pe,Q))}function pe(){!j().error&&(l||z().isVisible())&&(u||z().isOnline())?K(mn).then(U):U()}return U(),()=>{ue&&(clearTimeout(ue),ue=-1)}},[h,l,u,S]),i.useDebugValue(H),a&&Se(re)&&S){if(!qs&&Fr)throw new Error("Fallback data is required when using Suspense in SSR.");b.current=r,f.current=o,E.current=!1;const ue=$[S];if(!Se(ue)){const U=se(ue);gn(U)}if(Se(V)){const U=K(mn);Se(H)||(U.status="fulfilled",U.value=!0),gn(U)}else throw V}return{mutate:se,get data(){return P.data=!0,H},get error(){return P.error=!0,V},get isValidating(){return P.isValidating=!0,oe},get isLoading(){return P.isLoading=!0,de}}},Fe=Zd(Qd);async function G(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)}return{data:(await t.json()).data}}function fc(t){const{client:r}=Be(),o=i.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await G(c)).data},[r,t]),{data:n,error:s,mutate:a}=Fe(t?`wacht-agent-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 l=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:h}),u=await G(l);return await a(m=>m&&{...m,data:[u.data,...m.data]}),u.data},[r,t,a]),g=i.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await a(h=>h&&{...h,data:h.data.filter(l=>l.id!==c)})},[r,t,a]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!s,error:s,createSession:p,deleteSession:g,refetch:async()=>{await a()}}}const gc=i.createContext(void 0);function qo(){const t=i.useContext(gc);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Xd({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:s,onSessionCreated:a,onSessionDeleted:p,onError:g}){const[c,h]=i.useState(s?{id:s,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[l,u]=i.useState(!1),{sessions:m,loading:v,error:x,createSession:y,deleteSession:$,refetch:S}=fc(o);i.useEffect(()=>{if(s&&m.length>0){const b=m.find(f=>f.id===s);b&&h(b)}},[s,m]);const k=i.useCallback(b=>{h(b),u(!1)},[]),I=i.useCallback(async b=>{try{const f=b||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,z=await y({title:f});return h(z),a==null||a(z),z}catch(f){const z=f instanceof Error?f.message:"Failed to create session";throw g==null||g(z),f}},[y,a,g]),E=i.useCallback(async b=>{try{await $(b),(c==null?void 0:c.id)===b&&h(null),p==null||p(b)}catch(f){const z=f instanceof Error?f.message:"Failed to delete session";throw g==null||g(z),f}},[$,c,p,g]),w={agentName:r,token:o,platformAdapter:n,sessions:m,selectedSession:c,loadingSessions:v,sessionError:x,selectSession:k,createSession:I,deleteSession:E,refreshSessions:S,showHistory:l,setShowHistory:u,onSessionCreated:a,onSessionDeleted:p,onError:g};return e.jsx(gc.Provider,{value:w,children:t})}var mc=(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))(mc||{});function Jd(t,r){const o={username:eu(t,r),email:tu(t,r),phone:ru(t,r),email_otp:ou(t,r),magic_link:nu(t,r),oauth:su(t),generic:au(t,r)};return function(s){return o[s]}}function eu(t,r){return async({username:o,password:n})=>{var g,c;const s=new FormData;s.append("strategy","plain_username"),s.append("username",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),p=await G(a);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),p}}function tu(t,r){return async({email:o,password:n})=>{var g,c;const s=new FormData;s.append("strategy","plain_email"),s.append("email",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),p=await G(a);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),p}}function ru(t,r){return async({phone:o})=>{var p,g;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await G(s);return"data"in a&&((g=(p=a.data)==null?void 0:p.signin_attempts)!=null&&g.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function ou(t,r){return async({email:o})=>{var p,g;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await G(s);return"data"in a&&((g=(p=a.data)==null?void 0:p.signin_attempts)!=null&&g.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function nu(t,r){return async({email:o})=>{var p,g;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await G(s);return"data"in a&&((g=(p=a.data)==null?void 0:p.signin_attempts)!=null&&g.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function su(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const s=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),a=await G(s);return"data"in a&&a.data.oauth_url&&(window.location.href=a.data.oauth_url),a}}function au(t,r){return async({email:o,username:n,password:s,phone:a,strategy:p,token:g})=>{var u,m;const c=new FormData;p&&c.append("strategy",p),o&&c.append("email",o),n&&c.append("username",n),s&&c.append("password",s),a&&c.append("phone",a),g&&c.append("token",g);const h=await t("/auth/signin",{method:"POST",body:c}),l=await G(h);return"data"in l&&((m=(u=l.data)==null?void 0:u.signin_attempts)!=null&&m.length)&&r(l.data.signin_attempts.at(-1)||null),l}}function xc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Jd(t,n),completeVerification:async s=>{var c,h;const a=new FormData;a.append("verification_code",s);const p=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:a}),g=await G(p);if("data"in g&&((h=(c=g.data)==null?void 0:c.signin_attempts)!=null&&h.length)){const l=g.data.signin_attempts.at(-1);return n(l||null),g.data}else throw new Error("Verification failed")},prepareVerification:async s=>{var g;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((g=o==null?void 0:o.id)==null?void 0:g.toString())||""),a.searchParams.set("strategy",s.strategy),a.searchParams.set("identifier_type","signin"),s.strategy==="phone_otp"&&s.lastDigits?a.searchParams.set("last_digits",s.lastDigits):(s.strategy==="email_otp"&&s.redirectUri||s.strategy==="magic_link"&&s.redirectUri)&&a.searchParams.set("redirect_uri",s.redirectUri);const p=await t(a.pathname+a.search,{method:"POST"});return G(p)},completeProfile:async s=>{var c;if(!o)throw new Error("No signin attempt found");const a=new FormData;for(const[h,l]of Object.entries(s))l&&a.append(h,l);const p=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:a}),g=await G(p);if("data"in g&&g.data){const h=(c=g.data.signin_attempts)==null?void 0:c.find(l=>l.id===o.id);return h&&n(h),g.data}else throw new Error("Profile completion failed")},identify:async s=>{const a=new FormData;a.append("identifier",s);const p=await t("/auth/identify",{method:"POST",body:a});return(await G(p)).data},initEnterpriseSso:async(s,a)=>{const p=new URLSearchParams({connection_id:s});a&&p.append("redirect_uri",a);const g=await t(`/auth/sso/login?${p.toString()}`,{method:"POST"});return(await G(g)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function Br(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:s,setSignInAttempt:a}=xc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:s,setSignInAttempt:a};const p=(()=>{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:p,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:s,setSignInAttempt:a}}function iu(t,r,o){return{create:async n=>{var g,c,h;const s=new FormData;for(const[l,u]of Object.entries(n))s.append(l,u);const a=await t("/auth/signup",{method:"POST",body:s}),p=await G(a);return"data"in p&&((c=(g=p.data)==null?void 0:g.signup_attempts)!=null&&c.length)&&o(((h=p.data.signup_attempts)==null?void 0:h.at(-1))||null),p},prepareVerification:async n=>{var p;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((p=r==null?void 0:r.id)==null?void 0:p.toString())||""),s.searchParams.set("strategy",n.strategy),s.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?s.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&s.searchParams.set("redirect_uri",n.redirectUri);const a=await t(s.pathname+s.search,{method:"POST"});return G(a)},completeVerification:async n=>{var g,c;const s=new FormData;s.append("verification_code",n);const a=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),p=await G(a);return"data"in p&&((c=(g=p.data)==null?void 0:g.signup_attempts)!=null&&c.length)&&o(p.data.signup_attempts.at(-1)||null),p},validateDeploymentInvitation:async n=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),a=await G(s);return"data"in a&&a.data?a.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 vc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:iu(t,o,n)}}const Ge=()=>{const{adapter:t,deployment:r}=ve(),o=t.useNavigate(),n=(c,h)=>{o?o(c,h):window.location.href=c},s=c=>{if(c)return c;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function cu(t){const r=await t("/session",{method:"GET"});return(await G(r)).data}async function lu(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return G(o)}async function du(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return G(n)}async function uu(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return G(o)}async function pu(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return G(o)}const ns=new Map,Ar=new Map;function _t(){ns.clear(),Ar.clear()}async function hu(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return G(o)}function Ue(){const{client:t,loading:r}=Be(),{deployment:o}=ve(),{navigate:n}=Ge(),{cache:s}=hc(),{data:a,error:p,mutate:g,isLoading:c}=Fe(r?null:"/session",()=>cu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=i.useCallback(async()=>{await g(void 0,{revalidate:!0})},[g]),l=i.useCallback(async(u="default")=>{if(!a)throw new Error("no session");const m=ns.get(u);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";Ar.get(u)||Ar.set(u,hu(t,u));const v=await Ar.get(u);return Ar.delete(u),ns.set(u,v.data),v.data.token},[t,a==null?void 0:a.active_signin]);return r||!a||c?{loading:!0,error:p,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:h}:{loading:c,error:p,session:a,switchSignIn:async u=>{await lu(t,u),_t(),await Or("/me/organization-memberships",void 0,{revalidate:!1}),await Or("/me/workspace-memberships",void 0,{revalidate:!1}),await g(void 0,{revalidate:!0}),await Or("/me/organization-memberships"),await Or("/me/workspace-memberships")},signOut:async u=>{await du(t,u);const m=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],v=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(s instanceof Map){const x=Array.from(s.keys());for(const y of x){let $=!1;(m.includes(y)||typeof y=="string"&&v.some(S=>y.startsWith(S)))&&($=!0),$&&s.delete(y)}}_t(),await g(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(u&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!u&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async u=>{await uu(t,u),_t(),await g(void 0,{revalidate:!0})},switchWorkspace:async u=>{await pu(t,u),_t(),await g(void 0,{revalidate:!0})},getToken:l,refetch:h}}const Yo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=Ct(),{client:n}=Be(),{refetch:s}=Ue(),a=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/roles`,{method:"GET"}))).data,[n]),p=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/members`,{method:"GET"}))).data,[n]),g=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/domains`,{method:"GET"}))).data,[n]),h=i.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/members/${O.id}/remove`,{method:"POST"})},[n]),l=i.useCallback(async F=>{const O=new FormData;O.append("name",F.name),F.image&&O.append("image",F.image),F.description&&O.append("description",F.description);const A=await G(await n("/organizations",{method:"POST",body:O}));return _t(),await r(),await s(),A},[s,r,n]),u=i.useCallback(async(F,O)=>{const A=Object.entries(O).reduce((re,[V,q])=>(q&&re.append(V,q),re),new FormData),J=await G(await n(`/organizations/${F.id}/update`,{method:"POST",body:A}));return await r(),J},[r,n]),m=i.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/roles/${O.id}/remove`,{method:"POST"})},[n]),v=i.useCallback(async(F,O)=>{const A=new FormData;return A.append("domain",O.fqdn),await G(await n(`/organizations/${F.id}/domains`,{method:"POST",body:A}))},[n]),x=i.useCallback(async(F,O)=>await G(await n(`/organizations/${F.id}/domains/${O.id}/verify`,{method:"POST"})),[n]),y=i.useCallback(async(F,O)=>await G(await n(`/organizations/${F.id}/domains/${O.id}/delete`,{method:"POST"})),[n]),$=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/enterprise-connections`,{method:"GET"}))).data,[n]),S=i.useCallback(async(F,O)=>{const A=new FormData;return A.append("protocol",O.protocol),O.domain_id&&A.append("domain_id",O.domain_id),O.idp_entity_id&&A.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&A.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&A.append("idp_certificate",O.idp_certificate),O.oidc_client_id&&A.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&A.append("oidc_client_secret",O.oidc_client_secret),O.oidc_issuer_url&&A.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_scopes&&A.append("oidc_scopes",O.oidc_scopes),O.jit_enabled!==void 0&&A.append("jit_enabled",String(O.jit_enabled)),O.attribute_mapping&&A.append("attribute_mapping",JSON.stringify(O.attribute_mapping)),(await G(await n(`/organizations/${F.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),k=i.useCallback(async(F,O,A)=>{const J=new FormData;return A.domain_id&&J.append("domain_id",A.domain_id),A.idp_entity_id&&J.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&J.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&J.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&J.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&J.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&J.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&J.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&J.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/update`,{method:"POST",body:J}))).data},[n]),I=i.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/enterprise-connections/${O}/delete`,{method:"POST"})},[n]),E=i.useCallback(async(F,O)=>{const A=new FormData;return A.append("protocol",O.protocol),O.idp_entity_id&&A.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&A.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&A.append("idp_certificate",O.idp_certificate),O.oidc_issuer_url&&A.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_client_id&&A.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&A.append("oidc_client_secret",O.oidc_client_secret),(await G(await n(`/organizations/${F.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),w=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/test`,{method:"POST"}))).data,[n]),b=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/scim/token`,{method:"POST"}))).data,[n]),f=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/scim/token`,{method:"GET"}))).data,[n]),z=i.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/enterprise-connections/${O}/scim/token/revoke`,{method:"POST"})},[n]),_=i.useCallback(async(F,O)=>{const A=new FormData;return A.append("name",O.name),O.permissions&&O.permissions.forEach((re,V)=>{A.append(`permissions[${V}]`,re)}),await G(await n(`/organizations/${F.id}/roles`,{method:"POST",body:A}))},[n]),j=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/leave`,{method:"POST"}))).data,[n]),M=i.useCallback(async F=>{const O=await G(await n(`/organizations/${F.id}/delete`,{method:"POST"}));return _t(),await r(),await s(),O.data},[n,r,s]),R=i.useCallback(async(F,O,A)=>(await G(await n(`/organizations/${F.id}/members/${O.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),C=i.useCallback(async(F,O,A)=>(await G(await n(`/organizations/${F.id}/members/${O.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),P=i.useCallback(async(F,O)=>{var re,V;const A=new FormData;return A.append("email",O.email),A.append("role_id",O.organizationRole.id),(re=O.workspace)!=null&&re.id&&A.append("workspace_id",O.workspace.id),(V=O.workspaceRole)!=null&&V.id&&A.append("workspace_role_id",O.workspaceRole.id),(await G(await n(`/organizations/${F.id}/invitations`,{method:"POST",body:A}))).data},[n]),T=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/invitations/${O.id}/discard`,{method:"POST"}))).data,[n]),B=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/invitations/${O.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(F=>F.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:j,getOrganizationRoles:a,getOrganizationMembers:p,removeOrganizationMember:h,createOrganization:l,getOrganizationInvitations:g,getOrganizationDomains:c,addOrganizationDomain:v,verifyOrganizationDomain:x,removeOrganizationDomain:y,addRoleToOrganizationMember:R,removeRoleFromOrganizationMember:C,inviteOrganizationMember:P,discardOrganizationInvitation:T,resendOrganizationInvitation:B,updateOrganization:u,addRole:_,removeOrganizationRoles:m,deleteOrganization:M,getEnterpriseConnections:$,createEnterpriseConnection:S,updateEnterpriseConnection:k,deleteEnterpriseConnection:I,testEnterpriseConnectionConfig:E,testEnterpriseConnection:w,generateSCIMToken:b,getSCIMToken:f,revokeSCIMToken:z}},Ze=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:s,leaveOrganization:a,removeOrganizationMember:p,getOrganizationInvitations:g,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:l,verifyOrganizationDomain:u,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:v,inviteOrganizationMember:x,discardOrganizationInvitation:y,resendOrganizationInvitation:$,updateOrganization:S,removeOrganizationRoles:k,getEnterpriseConnections:I,createEnterpriseConnection:E,updateEnterpriseConnection:w,deleteEnterpriseConnection:b,testEnterpriseConnectionConfig:f,testEnterpriseConnection:z,generateSCIMToken:_,getSCIMToken:j,revokeSCIMToken:M}=Yo(),{session:R,error:C,loading:P}=Ue(),{organizationMemberships:T}=Ct(),B=i.useMemo(()=>(T==null?void 0:T.find(D=>{var Z;return D.id===((Z=R==null?void 0:R.active_signin)==null?void 0:Z.active_organization_membership_id)}))||null,[T,R]),L=i.useMemo(()=>(B==null?void 0:B.organization)||null,[B]),F=i.useCallback(async D=>L?await S(L,D):[],[L,S]),O=i.useCallback(async()=>L?await n(L):[],[L,n]),A=i.useCallback(async()=>L?await s(L):[],[L,s]),J=i.useCallback(async D=>L?await p(L,D):[],[L,p]),re=i.useCallback(async D=>L?await k(L,D):void 0,[L,k]),V=i.useCallback(async()=>L?await c(L):[],[L,c]),q=i.useCallback(async D=>L?await l(L,D):void 0,[L,l]),H=i.useCallback(async D=>L?await u(L,D):void 0,[L,u]),ee=i.useCallback(async D=>L?await h(L,D):void 0,[L,h]),le=i.useCallback(async(D,Z)=>L?await m(L,D,Z):void 0,[L,m]),oe=i.useCallback(async(D,Z)=>L?await v(L,D,Z):void 0,[L,v]),de=i.useCallback(async D=>L?await x(L,D):void 0,[L,x]),K=i.useCallback(async D=>L?await y(L,D):void 0,[L,y]),se=i.useCallback(async D=>L?await $(L,D):void 0,[L,$]),xe=i.useCallback(async()=>{L&&await a(L)},[L,a]),ue=i.useCallback(async()=>L?await g(L):[],[L,g]),U=i.useCallback(async()=>L?await I(L):[],[L,I]),pe=i.useCallback(async D=>{if(L)return await E(L,D)},[L,E]),Q=i.useCallback(async(D,Z)=>{if(L)return await w(L,D,Z)},[L,w]),Y=i.useCallback(async D=>{L&&await b(L,D)},[L,b]),ne=i.useCallback(async D=>L?await f(L,D):null,[L,f]),me=i.useCallback(async D=>L?await z(L,D):null,[L,z]),fe=i.useCallback(async D=>{if(L)return await _(L,D)},[L,_]),W=i.useCallback(async D=>{if(L)return await j(L,D)},[L,j]),N=i.useCallback(async D=>{L&&await M(L,D)},[L,M]);return P||t?{activeOrganization:null,activeMembership:null,loading:!0,error:C||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,getEnterpriseConnections:null,createEnterpriseConnection:null,updateEnterpriseConnection:null,deleteEnterpriseConnection:null,generateSCIMToken:null,getSCIMToken:null,revokeSCIMToken:null}:{activeOrganization:L,activeMembership:B,loading:!1,refetch:o,getRoles:A,updateOrganization:F,getMembers:O,getDomains:V,addDomain:q,verifyDomain:H,removeDomain:ee,getInvitations:ue,removeMember:J,leave:xe,removeRole:re,addMemberRole:le,removeMemberRole:oe,inviteMember:de,discardInvitation:K,resendInvitation:se,getEnterpriseConnections:U,createEnterpriseConnection:pe,updateEnterpriseConnection:Q,deleteEnterpriseConnection:Y,testEnterpriseConnectionConfig:ne,testEnterpriseConnection:me,generateSCIMToken:fe,getSCIMToken:W,revokeSCIMToken:N,error:null}};async function fu(t){return(await G(await t("/me/organization-memberships"))).data}const Ct=()=>{const{client:t,loading:r}=Be(),{data:o,isLoading:n,error:s,mutate:a}=Fe(r?null:"/me/organization-memberships",()=>fu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),p=i.useCallback(async()=>{await a(void 0,{revalidate:!0})},[a]);return{organizationMemberships:o,loading:r||n,error:s,refetch:p}};async function gu(t){return(await G(await t("/me/workspace-memberships"))).data}async function mu(t,r,o){return(await G(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Zo=()=>{const{client:t,loading:r}=Be(),{deployment:o}=ve(),{data:n,isLoading:s,error:a,mutate:p}=Fe(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>gu(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||s,error:a,refetch:g}},Pt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Zo(),{client:s}=Be(),a=i.useMemo(()=>t==null?void 0:t.map(w=>({...w.workspace,organization:w.organization,eligibility_restriction:w.eligibility_restriction})),[t]),p=i.useCallback(async(w,b,f,z)=>{const _=new FormData;_.append("name",b),f&&_.append("image",f),z&&_.append("description",z),_.append("organization_id",w);const j=await G(await s("/workspaces",{method:"POST",body:_}));return _t(),await r(),j.data},[s,r]),g=i.useCallback(async(w,b)=>{const f=await mu(s,w,b);return await r(),f},[s,r]),c=i.useCallback(async(w,b)=>{const f=new FormData;b.name&&f.append("name",b.name),b.description&&f.append("description",b.description),b.image&&f.append("image",b.image),b.enforce_2fa!==void 0&&f.append("enforce_2fa",String(b.enforce_2fa)),b.enable_ip_restriction!==void 0&&f.append("enable_ip_restriction",String(b.enable_ip_restriction)),b.whitelisted_ips&&b.whitelisted_ips.forEach(_=>f.append("whitelisted_ips",_));const z=await G(await s(`/workspaces/${w.id}/update`,{method:"POST",body:f}));return await r(),z.data},[s,r]),h=i.useCallback(async w=>{const b=await G(await s(`/workspaces/${w.id}/delete`,{method:"POST"}));return _t(),await r(),b.data},[s,r]),l=i.useCallback(async w=>(await G(await s(`/workspaces/${w.id}/members`,{method:"GET"}))).data,[s]),u=i.useCallback(async w=>(await G(await s(`/workspaces/${w.id}/roles`,{method:"GET"}))).data,[s]),m=i.useCallback(async(w,b,f)=>{const z=new FormData;return z.append("name",b),f.forEach(j=>z.append("permissions",j)),(await G(await s(`/workspaces/${w.id}/roles`,{method:"POST",body:z}))).data},[s]),v=i.useCallback(async(w,b)=>(await G(await s(`/workspaces/${w.id}/roles/${b.id}/delete`,{method:"POST"}))).data,[s]),x=i.useCallback(async(w,b)=>{const f=await G(await s(`/workspaces/${w.id}/members/${b}/remove`,{method:"POST"}));return await r(),f.data},[s,r]),y=i.useCallback(async(w,b,f)=>(await G(await s(`/workspaces/${w.id}/members/${b}/roles/${f}/add`,{method:"POST"}))).data,[s]),$=i.useCallback(async(w,b,f)=>(await G(await s(`/workspaces/${w.id}/members/${b}/roles/${f}/remove`,{method:"POST"}))).data,[s]),S=i.useCallback(async w=>(await G(await s(`/organizations/${w.organization.id}/invitations`,{method:"GET"}))).data.filter(f=>String(f.workspace_id)===String(w.id)),[s]),k=i.useCallback(async(w,b,f)=>{const z=new FormData;return z.append("email",b),z.append("workspace_id",w.id),z.append("workspace_role_id",f),(await G(await s(`/organizations/${w.organization.id}/invitations`,{method:"POST",body:z}))).data},[s]),I=i.useCallback(async(w,b)=>(await G(await s(`/organizations/${w.organization.id}/invitations/${b}/discard`,{method:"POST"}))).data,[s]),E=i.useCallback(async(w,b)=>(await G(await s(`/organizations/${w.organization.id}/invitations/${b}/resend`,{method:"POST"}))).data,[s]);return{workspaces:a||[],loading:o,error:n,refetch:r,leaveWorkspace:g,createWorkspace:p,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:l,getWorkspaceRoles:u,createWorkspaceRole:m,deleteWorkspaceRole:v,removeWorkspaceMember:x,addWorkspaceMemberRole:y,removeWorkspaceMemberRole:$,getWorkspaceInvitations:S,createWorkspaceInvitation:k,discardWorkspaceInvitation:I,resendWorkspaceInvitation:E}},Rt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:s,updateWorkspace:a,deleteWorkspace:p,getWorkspaceMembers:g,getWorkspaceRoles:c,createWorkspaceRole:h,deleteWorkspaceRole:l,removeWorkspaceMember:u,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:v,getWorkspaceInvitations:x,createWorkspaceInvitation:y,discardWorkspaceInvitation:$,resendWorkspaceInvitation:S}=Pt(),{workspaceMemberships:k}=Zo(),{session:I,loading:E,error:w}=Ue(),b=i.useMemo(()=>(k==null?void 0:k.find(H=>{var ee;return H.id===((ee=I==null?void 0:I.active_signin)==null?void 0:ee.active_workspace_membership_id)}))||null,[k,I]),f=i.useMemo(()=>(b==null?void 0:b.workspace)||null,[b]),z=i.useCallback(async()=>{var H;if(!(!f||!((H=I==null?void 0:I.active_signin)!=null&&H.user_id)))return await s(f.id,I.active_signin.user_id)},[f,s,I]),_=i.useCallback(async H=>{if(f)return await a(f,H)},[f,a]),j=i.useCallback(async()=>{if(f)return await p(f)},[f,p]),M=i.useCallback(async()=>f?await g(f):[],[f,g]),R=i.useCallback(async()=>f?await c(f):[],[f,c]),C=i.useCallback(async(H,ee)=>{if(f)return await h(f,H,ee)},[f,h]),P=i.useCallback(async H=>{if(f)return await l(f,H)},[f,l]),T=i.useCallback(async H=>{if(f)return await u(f,H)},[f,u]),B=i.useCallback(async(H,ee)=>{if(f)return await m(f,H,ee)},[f,m]),L=i.useCallback(async(H,ee)=>{if(f)return await v(f,H,ee)},[f,v]),F=i.useMemo(()=>(n==null?void 0:n.find(H=>H.id===(f==null?void 0:f.id)))||null,[n,f]),O=i.useCallback(async()=>F?await x(F):[],[F,x]),A=i.useCallback(async(H,ee)=>{if(F)return await y(F,H,ee)},[F,y]),J=i.useCallback(async H=>{if(F)return await $(F,H)},[F,$]),re=i.useCallback(async H=>{if(F)return await S(F,H)},[F,S]),V=r||E,q=o||w;return V?{activeWorkspace:null,activeMembership:null,loading:!0,error:q,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null,getInvitations:null,discardInvitation:null,resendInvitation:null}:{activeWorkspace:f,activeMembership:b,loading:!1,error:q,refetch:t,leave:z,updateWorkspace:_,deleteWorkspace:j,getMembers:M,getRoles:R,createRole:C,deleteRole:P,inviteMember:A,removeMember:T,addMemberRole:B,removeMemberRole:L,getInvitations:O,discardInvitation:J,resendInvitation:re}},xu=async t=>(await G(await t("/me"))).data,vu=async t=>(await G(await t("/me/signins"))).data;function sr(){const{client:t,loading:r}=Be(),{data:o,error:n,isLoading:s,mutate:a}=Fe(r?null:"/user",()=>xu(t)),p=async P=>{const T=new FormData;for(const[L,F]of Object.entries(P))F!=null&&F!==""&&T.append(L,String(F));const B=await G(await t("/me",{method:"POST",body:T}));return a(),B},g=async()=>await G(await t("/me/email-addresses",{method:"GET"})),c=async P=>await G(await t(`/me/email-addresses/${P}`,{method:"GET"})),h=async P=>{const T=new FormData;return T.append("email",P),await G(await t("/me/email-addresses",{method:"POST",body:T}))},l=async P=>await G(await t(`/me/email-addresses/${P}/delete`,{method:"POST"})),u=async P=>await G(await t(`/me/email-addresses/${P}/prepare-verification`,{method:"POST"})),m=async(P,T)=>await G(await t(`/me/email-addresses/${P}/attempt-verification?code=${T}`,{method:"POST"})),v=async(P,T)=>{const B=new FormData;return B.append("phone_number",P),B.append("country_code",T),await G(await t("/me/phone-numbers",{method:"POST",body:B}))},x=async P=>await G(await t(`/me/phone-numbers/${P}/delete`,{method:"POST"})),y=async P=>await G(await t(`/me/phone-numbers/${P}/prepare-verification`,{method:"POST"})),$=async(P,T)=>{const B=new FormData;return B.append("code",T),await G(await t(`/me/phone-numbers/${P}/attempt-verification`,{method:"POST",body:B}))},S=async P=>{const T=await G(await t(`/me/phone-numbers/${P}/make-primary`,{method:"POST"}));return a(),T},k=async P=>await G(await t(`/me/email-addresses/${P}/make-primary`,{method:"POST"})),I=async()=>(await G(await t("/me/authenticator",{method:"POST"}))).data,E=async(P,T)=>{const B=new FormData;return B.append("authenticator_id",P),T.forEach(F=>{B.append("codes",F)}),await G(await t("/me/authenticator/attempt-verification",{method:"POST",body:B}))},w=async P=>await G(await t(`/me/authenticator/${P}/delete`,{method:"POST"})),b=async()=>(await G(await t("/me/backup-codes",{method:"POST"}))).data,f=async P=>{const T=new FormData;return T.append("file",P),await G(await t("/me/profile-picture",{method:"POST",body:T}))},z=async()=>(await G(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,_=async(P,T)=>{const B=new FormData;return B.append("current_password",P),B.append("new_password",T),await G(await t("/me/update-password",{method:"POST",body:B}))},j=async P=>{const T=new FormData;T.append("current_password",P);const B=await G(await t("/me/remove-password",{method:"POST",body:T}));return a(),B},M=async P=>{const T=new FormData;return T.append("password",P),await G(await t("/me/account/delete",{method:"POST",body:T}))},R=async P=>await G(await t(`/me/social-connections/${P}/disconnect`,{method:"POST"})),C=async({provider:P,redirectUri:T})=>{var F;const B=new URLSearchParams({provider:P});T&&B.append("redirect_uri",T);const L=await G(await t(`/me/init-sso-connection?${B.toString()}`,{method:"POST"}));return"data"in L&&((F=L.data)!=null&&F.oauth_url)&&window.open(L.data.oauth_url,"_blank"),L};return{user:{...o,refetch:a},loading:r||s,error:n||null,updateProfile:p,getEmailAddresses:g,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:l,prepareEmailVerification:u,attemptEmailVerification:m,makeEmailPrimary:k,createPhoneNumber:v,deletePhoneNumber:x,preparePhoneVerification:y,attemptPhoneVerification:$,makePhonePrimary:S,setupAuthenticator:I,verifyAuthenticator:E,deleteAuthenticator:w,generateBackupCodes:b,regenerateBackupCodes:z,updateProfilePicture:f,disconnectSocialConnection:R,connectSocialAccount:C,updatePassword:_,removePassword:j,deleteAccount:M}}function bc(){const{client:t,loading:r}=Be(),{data:o,error:n,isLoading:s,mutate:a}=Fe(r?null:"/me/signins",()=>vu(t));return{signins:o,error:n||null,removeSignin:async g=>await G(await t(`/me/signins/${g}/signout`,{method:"POST"})),refetch:a,loading:s||r}}function bu(){const{session:t,loading:r}=Ue(),{loading:o,organizationMemberships:n}=Ct(),{loading:s,workspaceMemberships:a}=Zo();if(r||o||s)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:a==null?void 0:a.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 yc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),s=async a=>{n(!0);try{const p=new FormData;for(const[h,l]of Object.entries(a))l&&p.append(h,l);const g=await t("/waitlist/join",{method:"POST",body:p});return await G(g)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:s}}function wc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),[s,a]=i.useState(null),[p,g]=i.useState(null),[c,h]=i.useState(null),[l,u]=i.useState(!1),[m,v]=i.useState(null);i.useEffect(()=>{if(l||r)return;const y=new URLSearchParams(window.location.search),$=y.get("code"),S=y.get("state"),k=y.get("error"),I=y.get("error_description");if(!$&&!k){u(!0);const E=new Error("No OAuth callback data found.");a(E);return}if(u(!0),n(!0),k){const E=I||k,w=new Error(`OAuth Error: ${E}`);a(w),n(!1);return}if($&&S)x($,S);else{const E=new Error("Missing required OAuth parameters");a(E),n(!1)}},[l,r]);const x=async(y,$)=>{try{let S,k;try{const w=$.split(".");if(w.length!==2)throw new Error("Invalid OAuth state format - missing signature");const b=w[0].replace(/-/g,"+").replace(/_/g,"/"),f=b.length%4?"=".repeat(4-b.length%4):"",_=atob(b+f).split("|")[0];if(_==="sign_in")S="/auth/oauth2/callback",k="GET";else if(_==="connect_social")S="/me/sso-connection-callback",k="POST";else throw new Error(`Unknown OAuth action: ${_}`)}catch(w){const b=w instanceof Error?w:new Error("Failed to parse OAuth state");a(new Error(`Invalid OAuth callback: ${b.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const I=await t(`${S}?code=${encodeURIComponent(y)}&state=${encodeURIComponent($)}`,{method:k}),E=await G(I);if("data"in E){const w=E.data.session,b=E.data.redirect_uri||null;if(g(w),h(b),w.signin_attempts&&w.signin_attempts.length>0){const f=w.signin_attempts.at(-1);f&&v(f)}}else{const w=new Error("SSO callback failed");a(w)}}catch(S){const k=S instanceof Error?S:new Error("Unknown error occurred");a(k)}finally{n(!1)}};return{loading:o,error:s,session:p,redirectUri:c,processed:l,signinAttempt:m}}function jc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),[s,a]=i.useState(null);return{loading:r||o,verifyMagicLink:async g=>{if(!g.token||!g.attempt)throw new Error("Invalid magic link parameters");n(!0),a(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",g.token),c.searchParams.set("attempt",g.attempt),g.redirectUri&&c.searchParams.set("redirect_uri",g.redirectUri);const h=await t(c.pathname+c.search,{method:"GET"}),l=await G(h);return n(!1),a(!0),l}catch(c){throw n(!1),a(!1),c}},success:s}}function _c(){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 kc(){const{client:t,loading:r}=Be();return{loading:r,forgotPassword:async a=>{const p=new FormData;p.append("email",a);const g=await t("/auth/forgot-password",{method:"POST",body:p});return await G(g)},verifyOtp:async(a,p)=>{const g=new FormData;g.append("email",a),g.append("otp",p);const c=await t("/auth/forgot-password",{method:"POST",body:g});return await G(c)},resetPassword:async(a,p)=>{const g=new FormData;g.append("token",a),g.append("password",p);const c=await t("/auth/reset-password",{method:"POST",body:g});return await G(c)}}}function Cc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:s,onError:a,reconnectDelay:p=1e3,maxReconnectAttempts:g=5}={}){const{session:c,loading:h}=Ue(),{deployment:l,loading:u}=ve(),[m,v]=i.useState(!1),[x,y]=i.useState(null),$=i.useRef(null),S=i.useRef(null),k=i.useRef(0),I=i.useRef(null),E=i.useRef(s),w=i.useRef(a),b=i.useRef(r),f=i.useRef(o),z=i.useRef(n),_=i.useRef(p),j=i.useRef(g);E.current=s,w.current=a,b.current=r,f.current=o,z.current=n,_.current=p,j.current=g;const M=i.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null),I.current&&(clearInterval(I.current),I.current=null),$.current&&($.current.close(),$.current=null)},[]),R=i.useCallback(async()=>{var F;if(!t||h||u||!c||!l)return;M();const T=new URL(l.backend_host),B=T.protocol==="https:"?"wss:":"ws:",L=new URL("/realtime/notifications",`${B}//${T.host}`);if(l.mode==="staging"){const O=localStorage.getItem("__dev_session__");O&&L.searchParams.set("__dev_session__",O)}b.current&&b.current.length>0&&b.current.forEach(O=>L.searchParams.append("channels",O)),f.current&&f.current.length>0&&f.current.forEach(O=>L.searchParams.append("organization_ids",O.toString())),z.current&&z.current.length>0&&z.current.forEach(O=>L.searchParams.append("workspace_ids",O.toString()));try{const O=new WebSocket(L.toString());$.current=O,O.onopen=()=>{v(!0),y(null),k.current=0,I.current=setInterval(()=>{O.readyState===WebSocket.OPEN&&O.send("ping")},3e4)},O.onmessage=A=>{var J,re;try{const V=JSON.parse(A.data);if(V.type==="notification"&&V.data)(J=E.current)==null||J.call(E,V.data);else if(V.type==="error"){const q=V.error||"Unknown error occurred";y(q),(re=w.current)==null||re.call(w,q)}else V.type}catch{}},O.onerror=()=>{var A;y("Connection error occurred"),(A=w.current)==null||A.call(w,"Connection error occurred")},O.onclose=A=>{var J;if(v(!1),I.current&&(clearInterval(I.current),I.current=null),t&&A.code!==1e3&&k.current<j.current){k.current++;const re=_.current*Math.pow(2,k.current-1);S.current=setTimeout(()=>{R()},re)}else k.current>=j.current&&(y("Max reconnection attempts reached"),(J=w.current)==null||J.call(w,"Max reconnection attempts reached"))}}catch{y("Failed to connect"),(F=w.current)==null||F.call(w,"Failed to connect")}},[t,h,u,c,l,M]);i.useEffect(()=>(R(),()=>{M()}),[R,M]),i.useEffect(()=>{$.current&&$.current.readyState===WebSocket.OPEN&&R()},[r,o,n,R]);const C=i.useCallback(()=>{M(),v(!1)},[M]),P=i.useCallback(()=>{k.current=0,R()},[R]);return{isConnected:m,connectionError:x,disconnect:C,reconnect:P}}async function yu(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():""}`,s=await t(n,{method:"GET"});return(await G(s)).data}async function wu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}async function ju(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return G(o)}async function _u(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return G(r)}async function ku(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return G(o)}function Sc(t){const{client:r,loading:o}=Be(),{data:n,error:s,mutate:a,isLoading:p}=Fe(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>yu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});Cc({enabled:!o&&!!n,onNotification:i.useCallback(u=>{a(async m=>!m||m.notifications.some(x=>x.id===u.id.toString())?m:{...m,notifications:[{id:u.id.toString(),user_id:u.user_id.toString(),deployment_id:u.deployment_id.toString(),title:u.title,body:u.body,severity:u.severity,action_url:u.action_url,action_label:u.action_label,is_read:!1,is_archived:!1,created_at:u.created_at,updated_at:u.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[a]),onError:i.useCallback(()=>{},[])});const g=i.useCallback(async u=>{o||(await a(async m=>m&&{...m,notifications:m.notifications.map(v=>v.id===u?{...v,is_read:!0}:v),unread_count:Math.max(0,m.unread_count-1)},!1),await ju(r,u),await a())},[r,o,a]),c=i.useCallback(async()=>{o||(await a(async u=>u&&{...u,notifications:u.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await _u(r),await a())},[r,a]),h=i.useCallback(async u=>{o||(await a(async m=>{if(!m)return m;const v=m.notifications.find(x=>x.id===u);return{...m,notifications:m.notifications.filter(x=>x.id!==u),unread_count:v&&!v.is_read?Math.max(0,m.unread_count-1):m.unread_count,total:Math.max(0,m.total-1)}},!1),await ku(r,u),await a())},[r,o,a]),l=i.useCallback(async()=>{await a()},[a]);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:s,refetch:l}:{loading:!1,error:s,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:l}}async function Cu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}function Su(){const{client:t,loading:r}=Be(),{data:o,error:n,mutate:s}=Fe(r?null:"wacht-notifications:channel-counts",()=>Cu(t),{refreshInterval:3e4,revalidateOnFocus:!0}),a=async()=>{await s()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:a}:{loading:!1,counts:o,error:n,refetch:a}}const Yt=class Yt{constructor(){tt(this,"ws",null);tt(this,"messageHandlers",new Set);tt(this,"connectionStateHandlers",new Set);tt(this,"reconnectTimer",null);tt(this,"reconnectAttempts",0);tt(this,"url",null);tt(this,"isIntentionalDisconnect",!1);tt(this,"sessionMessages",{});tt(this,"currentSessionKey",null)}static getInstance(){return Yt.instance||(Yt.instance=new Yt),Yt.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]=[])}};tt(Yt,"instance");let ss=Yt;const Xe=ss.getInstance(),wt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Le={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Ot={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Ks(t){switch(t){case Ot.IDLE:return Le.IDLE;case Ot.STARTING:return Le.STARTING;case Ot.RUNNING:return Le.RUNNING;case Ot.WAITING_FOR_INPUT:return Le.WAITING_FOR_INPUT;case Ot.COMPLETED:return Le.COMPLETED;case Ot.FAILED:case Ot.CANCELLED:return Le.FAILED;default:return Le.IDLE}}function Qs(t){return t===Le.STARTING||t===Le.RUNNING||t===Le.WAITING_FOR_INPUT}function zc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:s=!0}){const{deployment:a}=ve(),{client:p}=Be(),[g,c]=i.useState([]),[h,l]=i.useState(null),[u,m]=i.useState(null),[v,x]=i.useState(!1),[y,$]=i.useState(!1),[S,k]=i.useState(Le.IDLE),[I,E]=i.useState({status:wt.DISCONNECTED}),[w,b]=i.useState(!0),[f,z]=i.useState(!1),_=i.useRef(null),j=i.useRef(null),M=i.useCallback(V=>{var q,H;switch(V.message_type){case"session_connected":if(x(!0),E({status:wt.CONNECTED}),(q=V.data)!=null&&q.execution_status){const le=V.data.execution_status,oe=Ks(le);k(oe),$(Qs(oe))}break;case"conversation_message":R(V.data);break;case"user_input_request":C(V.data);break;case"platform_event":P(V.data);break;case"platform_function":T(V.data);break;case"execution_complete":$(!1),k(Le.IDLE),j.current=null;break;case"execution_error":$(!1),k(Le.FAILED),j.current=null;break;case"execution_cancelled":$(!1),k(Le.IDLE),j.current=null;break;case"execution_status":const ee=(H=V.data)==null?void 0:H.status;if(ee){const le=Ks(ee);k(le),$(Qs(le))}break}},[h]),R=i.useCallback(V=>{var oe,de,K,se,xe,ue,U,pe;const{id:q,message_type:H,content:ee}=V,le=Q=>g.some(Y=>Y.id===Q);if(H==="system_decision"||H==="action_execution_result"||H==="assistant_task_breakdown"||H==="assistant_validation"||H==="assistant_action_planning"||H==="context_results"){l(null),m(null);let Q="";if(H==="system_decision"){const Y=ee==null?void 0:ee.step,ne=ee==null?void 0:ee.reasoning;if(Y==="gathercontext")ne&&ne.length>0?Q=ne.length>60?`${ne.substring(0,60)}...`:ne:Q="Gathering context...";else if(Y==="executeaction")Q="Executing action";else if(Y==="deliverresponse")Q="Preparing response";else if(Y==="taskplanning")Q="Planning approach";else if(Y==="validateprogress")Q="Validating progress";else if(Y==="acknowledge")Q="Processing request";else if(Y==="finishplanning")Q="Finalizing plan";else if(Y==="executetasks")Q="Executing tasks";else if(Y==="requestuserinput")Q="Waiting for input";else if(Y==="complete")Q="Completed";else if(Y==="examinetool")Q="Examining tool";else if(Y==="examineworkflow")Q="Examining workflow";else{const me=(ee==null?void 0:ee.confidence)||.5;me>.8?Q="Analyzing":me>.6?Q="Thinking":Q="Reasoning"}}else if(H==="action_execution_result")((oe=ee.task_execution)==null?void 0:oe.status)==="completed"?Q="Task execution completed":(de=ee.task_execution)!=null&&de.approach?Q=ee.task_execution.approach:Q="Executing task";else if(H==="assistant_task_breakdown")(K=ee.task_breakdown)!=null&&K.total_tasks?Q=`Identified ${ee.task_breakdown.total_tasks} tasks`:Q="Planning tasks";else if(H==="assistant_validation")Q="Validated results";else if(H==="assistant_action_planning")(se=ee.task_execution)!=null&&se.total_tasks?Q=`Planned ${ee.task_execution.total_tasks} tasks`:(ue=(xe=ee.task_execution)==null?void 0:xe.tasks)!=null&&ue.length?Q=`Planned ${ee.task_execution.tasks.length} tasks`:Q="Planning actions";else if(H==="context_results"){const Y=ee.query,ne=ee.result_count||0;Y&&Y!=="General context gathering"?Q=`${Y}: Found ${ne} results`:Q=`Found ${ne} results`}Q&&!le(q)&&c(Y=>[...Y,{id:q,role:"system",content:Q,timestamp:new Date,metadata:{type:"log",messageType:H}}]);return}if(H==="user_message")le(q)||(l(null),m(null),c(Q=>[...Q,{id:q,role:"user",content:ee.message,images:ee.images,timestamp:new Date}]));else if(H==="agent_response")le(q)||(l(null),m(null),$(!1),k(Le.IDLE),j.current=null,c(Q=>[...Q,{id:q,role:"assistant",content:ee.response,timestamp:new Date,isStreaming:!1}]));else if(H==="assistant_acknowledgment")le(q)||(l(null),m(null),c(Q=>[...Q,{id:q,role:"assistant",content:ee.acknowledgment_message,timestamp:new Date}]));else if(H==="assistant_ideation"||H==="assistant_action_planning"||H==="action_execution_result"||H==="assistant_validation"||H==="assistant_context_gathering"||H==="assistant_task_breakdown"){let Q="";if(ee.reasoning_summary)Q=ee.reasoning_summary;else if((U=ee.task_execution)!=null&&U.approach)Q=ee.task_execution.approach;else if(ee.strategic_synthesis)Q=ee.strategic_synthesis;else if((pe=ee.task_breakdown)!=null&&pe.total_tasks)Q=`Breaking down into ${ee.task_breakdown.total_tasks} tasks...`;else if(ee.acknowledgment_message)Q=ee.acknowledgment_message;else return;c(Y=>[...Y,{id:q,role:"assistant",content:Q,timestamp:new Date}])}else if(H==="user_input_request"){const Q={question:ee.question,context:ee.context,input_type:ee.input_type,options:ee.options||ee.suggestions,default_value:ee.default_value,placeholder:ee.placeholder};k("waiting_for_input"),c(Y=>[...Y,{id:q,role:"system",content:Q.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:Q}}])}},[]),C=i.useCallback(async V=>{k("waiting_for_input");const q=`input-request-${Date.now()}`;c(H=>[...H,{id:q,role:"system",content:V.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:V}}])},[]),P=i.useCallback(V=>{const{event_label:q,event_data:H}=V;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(q,H)},[n]),T=i.useCallback(async V=>{const{function_name:q,function_data:H}=V,{parameters:ee,execution_id:le}=H;if(!(n!=null&&n.onPlatformFunction)){Xe.send({message_type:{platform_function_result:[le,{error:"No platform function handler registered"}]},data:{}});return}try{const oe=await n.onPlatformFunction(q,ee,le),de={message_type:{platform_function_result:[le,oe]},data:{}};Xe.send(de)}catch(oe){Xe.send({message_type:{platform_function_result:[le,{error:oe instanceof Error?oe.message:"Function execution failed",stack:oe instanceof Error?oe.stack:void 0}]},data:{}})}},[n]);i.useEffect(()=>{if(!a)return;const q=`wss://${a==null?void 0:a.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;E({status:wt.CONNECTING}),Xe.connect(q)},[a,o]),i.useEffect(()=>Xe.onConnectionStateChange(q=>{E({status:q.isConnected?wt.CONNECTED:q.error?wt.ERROR:wt.DISCONNECTED}),x(q.isConnected)}),[]),i.useEffect(()=>Xe.onMessage(M),[M]),i.useEffect(()=>{v&&t&&r&&s&&Xe.send({message_type:{session_connect:[t,r]},data:{}})},[v,t,r,s]);const B=i.useCallback(async()=>(v&&t&&r&&Xe.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[v,t,r]),L=i.useCallback((V,q)=>{v&&(l(V),m(q||null),$(!0),k(Le.STARTING),Xe.send({message_type:{message_input:V},data:q?{images:q}:{}}))},[v]),F=i.useCallback(()=>{c([]),j.current=null},[]),O=i.useCallback(V=>{!v||S!==Le.WAITING_FOR_INPUT||(Xe.send({message_type:{user_input_response:V},data:{}}),k(Le.RUNNING))},[v,S]),A=i.useCallback(async V=>{var q;if(!(!o||!t))try{const H=new URLSearchParams({token:o,limit:"50"});V&&(H.append("before_id",V),z(!0));const le=await(await p(`/api/agent/contexts/${t}/messages?${H}`,{method:"GET"})).json();if(le.status===200&&le.data){const oe=le.data;if(Array.isArray(oe.data)){const de=oe.data.filter(K=>{var ue;let se=K.content;if(typeof K.content=="string")try{se=JSON.parse(K.content)}catch{se={message:K.content}}const xe=((ue=K.metadata)==null?void 0:ue.message_type)||(se==null?void 0:se.message_type);return xe==="user_message"||xe==="agent_response"||xe==="assistant_acknowledgment"||xe==="user_input_request"||xe==="system_decision"||xe==="action_execution_result"||xe==="assistant_task_breakdown"||xe==="assistant_validation"||xe==="assistant_action_planning"||xe==="context_results"}).map(K=>{var Q,Y,ne,me,fe,W,N;let se="",xe,ue,U=K.content;if(typeof K.content=="string")try{U=JSON.parse(K.content)}catch{U=K.content}const pe=((Q=K.metadata)==null?void 0:Q.message_type)||(U==null?void 0:U.message_type);if(pe==="user_message"?(se=(U==null?void 0:U.message)||"",xe=(U==null?void 0:U.images)||void 0):pe==="agent_response"?se=(U==null?void 0:U.response)||"":pe==="assistant_acknowledgment"?se=(U==null?void 0:U.acknowledgment_message)||"":pe==="user_input_request"&&(se=(U==null?void 0:U.question)||"",ue={type:"user_input_request",userInputRequest:{question:(U==null?void 0:U.question)||"",context:(U==null?void 0:U.context)||"",input_type:(U==null?void 0:U.input_type)||"text",options:(U==null?void 0:U.options)||(U==null?void 0:U.suggestions)||[],default_value:(U==null?void 0:U.default_value)||"",placeholder:(U==null?void 0:U.placeholder)||""}}),pe==="system_decision"||pe==="action_execution_result"||pe==="assistant_task_breakdown"||pe==="assistant_validation"||pe==="assistant_action_planning"||pe==="context_results"){let D="";if(pe==="system_decision"){const Z=U==null?void 0:U.step,ae=U==null?void 0:U.reasoning;if(Z==="gathercontext")ae&&ae.length>0?D=ae.length>60?`${ae.substring(0,60)}...`:ae:D="Gathering context...";else if(Z==="executeaction")D="Executing action";else if(Z==="deliverresponse")D="Preparing response";else if(Z==="taskplanning")D="Planning approach";else if(Z==="validateprogress")D="Validating progress";else if(Z==="acknowledge")D="Processing request";else if(Z==="finishplanning")D="Finalizing plan";else if(Z==="executetasks")D="Executing tasks";else if(Z==="requestuserinput")D="Waiting for input";else if(Z==="complete")D="Completed";else if(Z==="examinetool")D="Examining tool";else if(Z==="examineworkflow")D="Examining workflow";else{const te=(U==null?void 0:U.confidence)||.5;te>.8?D="Analyzing":te>.6?D="Thinking":D="Reasoning"}}else if(pe==="action_execution_result")((Y=U==null?void 0:U.task_execution)==null?void 0:Y.status)==="completed"?D="Task execution completed":(ne=U==null?void 0:U.task_execution)!=null&&ne.approach?D=U.task_execution.approach:D="Executing task";else if(pe==="assistant_task_breakdown")(me=U==null?void 0:U.task_breakdown)!=null&&me.total_tasks?D=`Identified ${U.task_breakdown.total_tasks} tasks`:D="Planning tasks";else if(pe==="assistant_validation")D="Validated results";else if(pe==="assistant_action_planning")(fe=U==null?void 0:U.task_execution)!=null&&fe.total_tasks?D=`Planned ${U.task_execution.total_tasks} tasks`:(N=(W=U==null?void 0:U.task_execution)==null?void 0:W.tasks)!=null&&N.length?D=`Planned ${U.task_execution.tasks.length} tasks`:D="Planning actions";else if(pe==="context_results"){const Z=U==null?void 0:U.query,ae=(U==null?void 0:U.result_count)||0;Z&&Z!=="General context gathering"?D=`${Z}: Found ${ae} results`:D=`Found ${ae} results`}se=D,ue={type:"log",messageType:pe}}return{id:K.id,role:pe==="user_message"?"user":pe==="user_input_request"?"system":"assistant",content:se,images:xe,timestamp:new Date(K.timestamp||K.created_at||Date.now()),metadata:ue}}).filter(K=>K.content||K.metadata||K.images).sort((K,se)=>{const xe=BigInt(K.id),ue=BigInt(se.id);return xe<ue?-1:xe>ue?1:0});de.length>0&&(_.current=de[0].id),V?(c(K=>[...de,...K]),b(de.length>=50)):(c(de),de.length>0&&((q=de[de.length-1].metadata)==null?void 0:q.type)==="user_input_request"&&k(Le.WAITING_FOR_INPUT)),z(!1)}}}catch(H){console.error("Failed to fetch messages:",H),z(!1)}},[o,t,p]);i.useEffect(()=>{t&&o&&A()},[t,o]);const J=i.useCallback(async()=>{if(!(f||!w||!_.current)){z(!0);try{await A(_.current)}finally{z(!1)}}},[f,w,A]),re=i.useCallback(()=>{!v||!y||(Xe.send({message_type:{cancel_execution:null},data:{}}),$(!1),k("idle"))},[v,y]);return{messages:g,pendingMessage:h,pendingImages:u,connectionState:I,isConnected:v,isExecuting:y,executionStatus:S,isWaitingForInput:S==="waiting_for_input",hasMoreMessages:w,isLoadingMore:f,sendMessage:L,submitUserInput:O,clearMessages:F,loadMoreMessages:J,cancelExecution:re,connect:B,disconnect:()=>Xe.disconnect()}}const $c=()=>{const{client:t}=Be(),[r,o]=i.useState(!1),[n,s]=i.useState(null),[a,p]=i.useState(null),g=i.useCallback(async h=>{o(!0),s(null),p(null);try{const l=new FormData;l.append("token",h);const u=await t("/organizations/invitations/accept",{method:"POST",body:l}),v=(await G(u)).data;return p(v),v.error_code&&s(v.message||"Failed to accept invitation"),v}catch(l){const u=l.message||"Failed to accept invitation";s(u);const m={error_code:"NETWORK_ERROR",message:u};return p(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{s(null),p(null)},[]);return{acceptInvitation:g,invitationData:a,loading:r,error:n,reset:c}},zu=({children:t})=>{const{loading:r}=ve();return r?null:e.jsx(e.Fragment,{children:t})},$u=({children:t})=>{const{loading:r}=ve();return r?e.jsx(e.Fragment,{children:t}):null};var Ye=function(){return Ye=Object.assign||function(r){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(r[a]=o[a])}return r},Ye.apply(this,arguments)};function tr(t,r,o){if(o||arguments.length===2)for(var n=0,s=r.length,a;n<s;n++)(a||!(n in r))&&(a||(a=Array.prototype.slice.call(r,0,n)),a[n]=r[n]);return t.concat(a||Array.prototype.slice.call(r))}function Eu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var Iu=/^((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)-.*))$/,Pu=Eu(function(t){return Iu.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ie="-ms-",Nr="-moz-",$e="-webkit-",Ec="comm",Ko="rule",js="decl",Ru="@import",Ic="@keyframes",Tu="@layer",Pc=Math.abs,_s=String.fromCharCode,as=Object.assign;function Mu(t,r){return We(t,0)^45?(((r<<2^We(t,0))<<2^We(t,1))<<2^We(t,2))<<2^We(t,3):0}function Rc(t){return t.trim()}function yt(t,r){return(t=r.exec(t))?t[0]:t}function ye(t,r,o){return t.replace(r,o)}function Io(t,r,o){return t.indexOf(r,o)}function We(t,r){return t.charCodeAt(r)|0}function yr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function Tc(t){return t.length}function Lr(t,r){return r.push(t),t}function Ou(t,r){return t.map(r).join("")}function Xs(t,r){return t.filter(function(o){return!yt(o,r)})}var Qo=1,wr=1,Mc=0,Je=0,De=0,Sr="";function Xo(t,r,o,n,s,a,p,g){return{value:t,root:r,parent:o,type:n,props:s,children:a,line:Qo,column:wr,length:p,return:"",siblings:g}}function zt(t,r){return as(Xo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function lr(t){for(;t.root;)t=zt(t.root,{children:[t]});Lr(t,t.siblings)}function Au(){return De}function Lu(){return De=Je>0?We(Sr,--Je):0,wr--,De===10&&(wr=1,Qo--),De}function rt(){return De=Je<Mc?We(Sr,Je++):0,wr++,De===10&&(wr=1,Qo++),De}function Kt(){return We(Sr,Je)}function Po(){return Je}function Jo(t,r){return yr(Sr,t,r)}function is(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 Du(t){return Qo=wr=1,Mc=ct(Sr=t),Je=0,[]}function Nu(t){return Sr="",t}function xn(t){return Rc(Jo(Je-1,cs(t===91?t+2:t===40?t+1:t)))}function Fu(t){for(;(De=Kt())&&De<33;)rt();return is(t)>2||is(De)>3?"":" "}function Bu(t,r){for(;--r&&rt()&&!(De<48||De>102||De>57&&De<65||De>70&&De<97););return Jo(t,Po()+(r<6&&Kt()==32&&rt()==32))}function cs(t){for(;rt();)switch(De){case t:return Je;case 34:case 39:t!==34&&t!==39&&cs(De);break;case 40:t===41&&cs(t);break;case 92:rt();break}return Je}function Uu(t,r){for(;rt()&&t+De!==57;)if(t+De===84&&Kt()===47)break;return"/*"+Jo(r,Je-1)+"*"+_s(t===47?t:rt())}function Wu(t){for(;!is(Kt());)rt();return Jo(t,Je)}function Vu(t){return Nu(Ro("",null,null,null,[""],t=Du(t),0,[0],t))}function Ro(t,r,o,n,s,a,p,g,c){for(var h=0,l=0,u=p,m=0,v=0,x=0,y=1,$=1,S=1,k=0,I="",E=s,w=a,b=n,f=I;$;)switch(x=k,k=rt()){case 40:if(x!=108&&We(f,u-1)==58){Io(f+=ye(xn(k),"&","&\f"),"&\f",Pc(h?g[h-1]:0))!=-1&&(S=-1);break}case 34:case 39:case 91:f+=xn(k);break;case 9:case 10:case 13:case 32:f+=Fu(x);break;case 92:f+=Bu(Po()-1,7);continue;case 47:switch(Kt()){case 42:case 47:Lr(Gu(Uu(rt(),Po()),r,o,c),c);break;default:f+="/"}break;case 123*y:g[h++]=ct(f)*S;case 125*y:case 59:case 0:switch(k){case 0:case 125:$=0;case 59+l:S==-1&&(f=ye(f,/\f/g,"")),v>0&&ct(f)-u&&Lr(v>32?ea(f+";",n,o,u-1,c):ea(ye(f," ","")+";",n,o,u-2,c),c);break;case 59:f+=";";default:if(Lr(b=Js(f,r,o,h,l,s,g,I,E=[],w=[],u,a),a),k===123)if(l===0)Ro(f,r,b,b,E,a,u,g,w);else switch(m===99&&We(f,3)===110?100:m){case 100:case 108:case 109:case 115:Ro(t,b,b,n&&Lr(Js(t,b,b,0,0,s,g,I,s,E=[],u,w),w),s,w,u,g,n?E:w);break;default:Ro(f,b,b,b,[""],w,0,g,w)}}h=l=v=0,y=S=1,I=f="",u=p;break;case 58:u=1+ct(f),v=x;default:if(y<1){if(k==123)--y;else if(k==125&&y++==0&&Lu()==125)continue}switch(f+=_s(k),k*y){case 38:S=l>0?1:(f+="\f",-1);break;case 44:g[h++]=(ct(f)-1)*S,S=1;break;case 64:Kt()===45&&(f+=xn(rt())),m=Kt(),l=u=ct(I=f+=Wu(Po())),k++;break;case 45:x===45&&ct(f)==2&&(y=0)}}return a}function Js(t,r,o,n,s,a,p,g,c,h,l,u){for(var m=s-1,v=s===0?a:[""],x=Tc(v),y=0,$=0,S=0;y<n;++y)for(var k=0,I=yr(t,m+1,m=Pc($=p[y])),E=t;k<x;++k)(E=Rc($>0?v[k]+" "+I:ye(I,/&\f/g,v[k])))&&(c[S++]=E);return Xo(t,r,o,s===0?Ko:g,c,h,l,u)}function Gu(t,r,o,n){return Xo(t,r,o,Ec,_s(Au()),yr(t,2,-2),0,n)}function ea(t,r,o,n,s){return Xo(t,r,o,js,yr(t,0,n),yr(t,n+1,-1),n,s)}function Oc(t,r,o){switch(Mu(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 Nr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return $e+t+Nr+t+Ie+t+t;case 5936:switch(We(t,r+11)){case 114:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return $e+t+Ie+t+t;case 6165:return $e+t+Ie+"flex-"+t+t;case 5187:return $e+t+ye(t,/(\w+).+(:[^]+)/,$e+"box-$1$2"+Ie+"flex-$1$2")+t;case 5443:return $e+t+Ie+"flex-item-"+ye(t,/flex-|-self/g,"")+(yt(t,/flex-|baseline/)?"":Ie+"grid-row-"+ye(t,/flex-|-self/g,""))+t;case 4675:return $e+t+Ie+"flex-line-pack"+ye(t,/align-content|flex-|-self/g,"")+t;case 5548:return $e+t+Ie+ye(t,"shrink","negative")+t;case 5292:return $e+t+Ie+ye(t,"basis","preferred-size")+t;case 6060:return $e+"box-"+ye(t,"-grow","")+$e+t+Ie+ye(t,"grow","positive")+t;case 4554:return $e+ye(t,/([^-])(transform)/g,"$1"+$e+"$2")+t;case 6187:return ye(ye(ye(t,/(zoom-|grab)/,$e+"$1"),/(image-set)/,$e+"$1"),t,"")+t;case 5495:case 3959:return ye(t,/(image-set\([^]*)/,$e+"$1$`$1");case 4968:return ye(ye(t,/(.+:)(flex-)?(.*)/,$e+"box-pack:$3"+Ie+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+$e+t+t;case 4200:if(!yt(t,/flex-|baseline/))return Ie+"grid-column-align"+yr(t,r)+t;break;case 2592:case 3360:return Ie+ye(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,s){return r=s,yt(n.props,/grid-\w+-end/)})?~Io(t+(o=o[r].value),"span",0)?t:Ie+ye(t,"-start","")+t+Ie+"grid-row-span:"+(~Io(o,"span",0)?yt(o,/\d+/):+yt(o,/\d+/)-+yt(t,/\d+/))+";":Ie+ye(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return yt(n.props,/grid-\w+-start/)})?t:Ie+ye(ye(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ye(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(We(t,r+1)){case 109:if(We(t,r+4)!==45)break;case 102:return ye(t,/(.+:)(.+)-([^]+)/,"$1"+$e+"$2-$3$1"+Nr+(We(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~Io(t,"stretch",0)?Oc(ye(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ye(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,a,p,g,c,h){return Ie+s+":"+a+h+(p?Ie+s+"-span:"+(g?c:+c-+a)+h:"")+t});case 4949:if(We(t,r+6)===121)return ye(t,":",":"+$e)+t;break;case 6444:switch(We(t,We(t,14)===45?18:11)){case 120:return ye(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+$e+(We(t,14)===45?"inline-":"")+"box$3$1"+$e+"$2$3$1"+Ie+"$2box$3")+t;case 100:return ye(t,":",":"+Ie)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ye(t,"scroll-","scroll-snap-")+t}return t}function Do(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Hu(t,r,o,n){switch(t.type){case Tu:if(t.children.length)break;case Ru:case js:return t.return=t.return||t.value;case Ec:return"";case Ic:return t.return=t.value+"{"+Do(t.children,n)+"}";case Ko:if(!ct(t.value=t.props.join(",")))return""}return ct(o=Do(t.children,n))?t.return=t.value+"{"+o+"}":""}function qu(t){var r=Tc(t);return function(o,n,s,a){for(var p="",g=0;g<r;g++)p+=t[g](o,n,s,a)||"";return p}}function Yu(t){return function(r){r.root||(r=r.return)&&t(r)}}function Zu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case js:t.return=Oc(t.value,t.length,o);return;case Ic:return Do([zt(t,{value:ye(t.value,"@","@"+$e)})],n);case Ko:if(t.length)return Ou(o=t.props,function(s){switch(yt(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":lr(zt(t,{props:[ye(s,/:(read-\w+)/,":"+Nr+"$1")]})),lr(zt(t,{props:[s]})),as(t,{props:Xs(o,n)});break;case"::placeholder":lr(zt(t,{props:[ye(s,/:(plac\w+)/,":"+$e+"input-$1")]})),lr(zt(t,{props:[ye(s,/:(plac\w+)/,":"+Nr+"$1")]})),lr(zt(t,{props:[ye(s,/:(plac\w+)/,Ie+"input-$1")]})),lr(zt(t,{props:[s]})),as(t,{props:Xs(o,n)});break}return""})}}var Ku={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},rr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Ac="active",Lc="data-styled-version",en="6.1.19",ks=`/*!sc*/
19
- `,No=typeof window<"u"&&typeof document<"u",Qu=!!(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"),ta=/invalid hook call/i,Jr=new Set,Xu=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 Ws;function yd(){return Ws||(Ws=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||s.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 y=v();if(!u){var z=v();a(y,z)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}z=p({inst:{value:y,getSnapshot:v}});var S=z[0].inst,_=z[1];return c(function(){S.value=y,S.getSnapshot=v,o(S)&&_({inst:S})},[x,y,v]),g(function(){return o(S)&&_({inst:S}),x(function(){o(S)&&_({inst:S})})},[x]),h(y),y}function o(x){var v=x.getSnapshot;x=x.value;try{var y=v();return!a(x,y)}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 s=i,a=typeof Object.is=="function"?Object.is:t,p=s.useState,g=s.useEffect,c=s.useLayoutEffect,h=s.useDebugValue,l=!1,u=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;dn.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),dn}var Vs;function wd(){return Vs||(Vs=1,process.env.NODE_ENV==="production"?Kr.exports=bd():Kr.exports=yd()),Kr.exports}var jd=wd();const sc=0,ac=1,ic=2,Gs=3;var Hs=Object.prototype.hasOwnProperty;function Kn(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--&&Kn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Hs.call(t,o)&&++n&&!Hs.call(r,o)||!(o in r)||!Kn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const jt=new WeakMap,$t=()=>{},qe=$t(),Qn=Object,Se=t=>t===qe,lt=t=>typeof t=="function",It=(t,r)=>({...t,...r}),cc=t=>lt(t.then),un={},Qr={},ys="undefined",Vr=typeof window!=ys,Xn=typeof document!=ys,_d=Vr&&"Deno"in window,kd=()=>Vr&&typeof window.requestAnimationFrame!=ys,lc=(t,r)=>{const o=jt.get(t);return[()=>!Se(r)&&t.get(r)||un,n=>{if(!Se(r)){const s=t.get(r);r in Qr||(Qr[r]=s),o[5](r,It(s,n),s||un)}},o[6],()=>!Se(r)&&r in Qr?Qr[r]:!Se(r)&&t.get(r)||un]};let Jn=!0;const Cd=()=>Jn,[es,ts]=Vr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$t,$t],Sd=()=>{const t=Xn&&document.visibilityState;return Se(t)||t!=="hidden"},zd=t=>(Xn&&document.addEventListener("visibilitychange",t),es("focus",t),()=>{Xn&&document.removeEventListener("visibilitychange",t),ts("focus",t)}),$d=t=>{const r=()=>{Jn=!0,t()},o=()=>{Jn=!1};return es("online",r),es("offline",o),()=>{ts("online",r),ts("offline",o)}},Ed={isOnline:Cd,isVisible:Sd},Id={initFocus:zd,initReconnect:$d},qs=!i.useId,Fr=!Vr||_d,Pd=t=>kd()?window.requestAnimationFrame(t):setTimeout(t,1),pn=Fr?i.useEffect:i.useLayoutEffect,hn=typeof navigator<"u"&&navigator.connection,Ys=!Fr&&hn&&(["slow-2g","2g"].includes(hn.effectiveType)||hn.saveData),Xr=new WeakMap,Rd=t=>Qn.prototype.toString.call(t),fn=(t,r)=>t===`[object ${r}]`;let Td=0;const rs=t=>{const r=typeof t,o=Rd(t),n=fn(o,"Date"),s=fn(o,"RegExp"),a=fn(o,"Object");let p,g;if(Qn(t)===t&&!n&&!s){if(p=Xr.get(t),p)return p;if(p=++Td+"~",Xr.set(t,p),Array.isArray(t)){for(p="@",g=0;g<t.length;g++)p+=rs(t[g])+",";Xr.set(t,p)}if(a){p="#";const c=Qn.keys(t).sort();for(;!Se(g=c.pop());)Se(t[g])||(p+=g+":"+rs(t[g])+",");Xr.set(t,p)}}else p=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return p},ws=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?rs(t):"",[t,r]};let Md=0;const os=()=>++Md;async function dc(...t){const[r,o,n,s]=t,a=It({populateCache:!0,throwOnError:!0},typeof s=="boolean"?{revalidate:s}:s||{});let p=a.populateCache;const g=a.rollbackOnError;let c=a.optimisticData;const h=m=>typeof g=="function"?g(m):g!==!1,l=a.throwOnError;if(lt(o)){const m=o,x=[],v=r.keys();for(const y of v)!/^\$(inf|sub)\$/.test(y)&&m(r.get(y)._k)&&x.push(y);return Promise.all(x.map(u))}return u(o);async function u(m){const[x]=ws(m);if(!x)return;const[v,y]=lc(r,x),[z,S,_,E]=jt.get(r),I=()=>{const P=z[x];return(lt(a.revalidate)?a.revalidate(v().data,m):a.revalidate!==!1)&&(delete _[x],delete E[x],P&&P[0])?P[0](ic).then(()=>v().data):v().data};if(t.length<3)return I();let w=n,b,f=!1;const $=os();S[x]=[$,0];const k=!Se(c),j=v(),M=j.data,R=j._c,C=Se(R)?M:R;if(k&&(c=lt(c)?c(C,M):c,y({data:c,_c:C})),lt(w))try{w=w(C)}catch(P){b=P,f=!0}if(w&&cc(w))if(w=await w.catch(P=>{b=P,f=!0}),$!==S[x][0]){if(f)throw b;return w}else f&&k&&h(b)&&(p=!0,y({data:C,_c:qe}));if(p&&!f)if(lt(p)){const P=p(w,C);y({data:P,error:qe,_c:qe})}else y({data:w,error:qe,_c:qe});if(S[x][1]=os(),Promise.resolve(I()).then(()=>{y({_c:qe})}),f){if(l)throw b;return}return w}}const Zs=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},Od=(t,r)=>{if(!jt.has(t)){const o=It(Id,r),n=Object.create(null),s=dc.bind(qe,t);let a=$t;const p=Object.create(null),g=(l,u)=>{const m=p[l]||[];return p[l]=m,m.push(u),()=>m.splice(m.indexOf(u),1)},c=(l,u,m)=>{t.set(l,u);const x=p[l];if(x)for(const v of x)v(u,m)},h=()=>{if(!jt.has(t)&&(jt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),s,c,g]),!Fr)){const l=o.initFocus(setTimeout.bind(qe,Zs.bind(qe,n,sc))),u=o.initReconnect(setTimeout.bind(qe,Zs.bind(qe,n,ac)));a=()=>{l&&l(),u&&u(),jt.delete(t)}}};return h(),[t,s,h,a]}return[t,jt.get(t)[4]]},Ad=(t,r,o,n,s)=>{const a=o.errorRetryCount,p=s.retryCount,g=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!Se(a)&&p>a||setTimeout(n,g,s)},Ld=Kn,[uc,Or]=Od(new Map),Dd=It({onLoadingSlow:$t,onSuccess:$t,onError:$t,onErrorRetry:Ad,onDiscarded:$t,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ys?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ys?5e3:3e3,compare:Ld,isPaused:()=>!1,cache:uc,mutate:Or,fallback:{}},Ed),Nd=(t,r)=>{const o=It(t,r);if(r){const{use:n,fallback:s}=t,{use:a,fallback:p}=r;n&&a&&(o.use=n.concat(a)),s&&p&&(o.fallback=It(s,p))}return o},Fd=i.createContext({}),Bd="$inf$",pc=Vr&&window.__SWR_DEVTOOLS_USE__,Ud=pc?window.__SWR_DEVTOOLS_USE__:[],Wd=()=>{pc&&(window.__SWR_DEVTOOLS_REACT__=i)},Vd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],hc=()=>It(Dd,i.useContext(Fd)),Gd=t=>(r,o,n)=>t(r,o&&((...a)=>{const[p]=ws(r),[,,,g]=jt.get(uc);if(p.startsWith(Bd))return o(...a);const c=g[p];return Se(c)?o(...a):(delete g[p],c)}),n),Hd=Ud.concat(Gd),qd=t=>function(...o){const n=hc(),[s,a,p]=Vd(o),g=Nd(n,p);let c=t;const{use:h}=g,l=(h||[]).concat(Hd);for(let u=l.length;u--;)c=l[u](c);return c(s,a||g.fetcher||null,g)},Yd=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const s=n.indexOf(o);s>=0&&(n[s]=n[n.length-1],n.pop())}};Wd();const gn=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}}),mn={dedupe:!0},Zd=(t,r,o)=>{const{cache:n,compare:s,suspense:a,fallbackData:p,revalidateOnMount:g,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:m}=o,[x,v,y,z]=jt.get(n),[S,_]=ws(t),E=i.useRef(!1),I=i.useRef(!1),w=i.useRef(S),b=i.useRef(r),f=i.useRef(o),$=()=>f.current,k=()=>$().isVisible()&&$().isOnline(),[j,M,R,C]=lc(n,S),P=i.useRef({}).current,T=Se(p)?Se(o.fallback)?qe:o.fallback[S]:p,B=(ue,U)=>{for(const pe in P){const Q=pe;if(Q==="data"){if(!s(ue[Q],U[Q])&&(!Se(ue[Q])||!s(H,U[Q])))return!1}else if(U[Q]!==ue[Q])return!1}return!0},L=i.useMemo(()=>{const ue=!S||!r?!1:Se(g)?$().isPaused()||a?!1:c!==!1:g,U=fe=>{const W=It(fe);return delete W._k,ue?{isValidating:!0,isLoading:!0,...W}:W},pe=j(),Q=C(),Y=U(pe),ne=pe===Q?Y:U(Q);let me=Y;return[()=>{const fe=U(j());return B(fe,me)?(me.data=fe.data,me.isLoading=fe.isLoading,me.isValidating=fe.isValidating,me.error=fe.error,me):(me=fe,fe)},()=>ne]},[n,S]),F=jd.useSyncExternalStore(i.useCallback(ue=>R(S,(U,pe)=>{B(pe,U)||ue()}),[n,S]),L[0],L[1]),O=!E.current,A=x[S]&&x[S].length>0,J=F.data,re=Se(J)?T&&cc(T)?gn(T):T:J,V=F.error,q=i.useRef(re),H=m?Se(J)?Se(q.current)?re:q.current:J:re,ee=A&&!Se(V)?!1:O&&!Se(g)?g:$().isPaused()?!1:a?Se(re)?!1:c:Se(re)||c,le=!!(S&&r&&O&&ee),oe=Se(F.isValidating)?le:F.isValidating,de=Se(F.isLoading)?le:F.isLoading,K=i.useCallback(async ue=>{const U=b.current;if(!S||!U||I.current||$().isPaused())return!1;let pe,Q,Y=!0;const ne=ue||{},me=!y[S]||!ne.dedupe,fe=()=>qs?!I.current&&S===w.current&&E.current:S===w.current,W={isValidating:!1,isLoading:!1},N=()=>{M(W)},D=()=>{const ae=y[S];ae&&ae[1]===Q&&delete y[S]},Z={isValidating:!0};Se(j().data)&&(Z.isLoading=!0);try{if(me&&(M(Z),o.loadingTimeout&&Se(j().data)&&setTimeout(()=>{Y&&fe()&&$().onLoadingSlow(S,o)},o.loadingTimeout),y[S]=[U(_),os()]),[pe,Q]=y[S],pe=await pe,me&&setTimeout(D,o.dedupingInterval),!y[S]||y[S][1]!==Q)return me&&fe()&&$().onDiscarded(S),!1;W.error=qe;const ae=v[S];if(!Se(ae)&&(Q<=ae[0]||Q<=ae[1]||ae[1]===0))return N(),me&&fe()&&$().onDiscarded(S),!1;const te=j().data;W.data=s(te,pe)?te:pe,me&&fe()&&$().onSuccess(pe,S,o)}catch(ae){D();const te=$(),{shouldRetryOnError:_e}=te;te.isPaused()||(W.error=ae,me&&fe()&&(te.onError(ae,S,te),(_e===!0||lt(_e)&&_e(ae))&&(!$().revalidateOnFocus||!$().revalidateOnReconnect||k())&&te.onErrorRetry(ae,S,te,be=>{const ze=x[S];ze&&ze[0]&&ze[0](Gs,be)},{retryCount:(ne.retryCount||0)+1,dedupe:!0})))}return Y=!1,N(),!0},[S,n]),se=i.useCallback((...ue)=>dc(n,w.current,...ue),[]);if(pn(()=>{b.current=r,f.current=o,Se(J)||(q.current=J)}),pn(()=>{if(!S)return;const ue=K.bind(qe,mn);let U=0;$().revalidateOnFocus&&(U=Date.now()+$().focusThrottleInterval);const Q=Yd(S,x,(Y,ne={})=>{if(Y==sc){const me=Date.now();$().revalidateOnFocus&&me>U&&k()&&(U=me+$().focusThrottleInterval,ue())}else if(Y==ac)$().revalidateOnReconnect&&k()&&ue();else{if(Y==ic)return K();if(Y==Gs)return K(ne)}});return I.current=!1,w.current=S,E.current=!0,M({_k:_}),ee&&(y[S]||(Se(re)||Fr?ue():Pd(ue))),()=>{I.current=!0,Q()}},[S]),pn(()=>{let ue;function U(){const Q=lt(h)?h(j().data):h;Q&&ue!==-1&&(ue=setTimeout(pe,Q))}function pe(){!j().error&&(l||$().isVisible())&&(u||$().isOnline())?K(mn).then(U):U()}return U(),()=>{ue&&(clearTimeout(ue),ue=-1)}},[h,l,u,S]),i.useDebugValue(H),a&&Se(re)&&S){if(!qs&&Fr)throw new Error("Fallback data is required when using Suspense in SSR.");b.current=r,f.current=o,I.current=!1;const ue=z[S];if(!Se(ue)){const U=se(ue);gn(U)}if(Se(V)){const U=K(mn);Se(H)||(U.status="fulfilled",U.value=!0),gn(U)}else throw V}return{mutate:se,get data(){return P.data=!0,H},get error(){return P.error=!0,V},get isValidating(){return P.isValidating=!0,oe},get isLoading(){return P.isLoading=!0,de}}},Fe=qd(Zd);async function G(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)}return{data:(await t.json()).data}}function fc(t){const{client:r}=Be(),o=i.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await G(c)).data},[r,t]),{data:n,error:s,mutate:a}=Fe(t?`wacht-agent-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 l=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:h}),u=await G(l);return await a(m=>m&&{...m,data:[u.data,...m.data]}),u.data},[r,t,a]),g=i.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await a(h=>h&&{...h,data:h.data.filter(l=>l.id!==c)})},[r,t,a]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!s,error:s,createSession:p,deleteSession:g,refetch:async()=>{await a()}}}const gc=i.createContext(void 0);function qo(){const t=i.useContext(gc);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Kd({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:s,onSessionCreated:a,onSessionDeleted:p,onError:g}){const[c,h]=i.useState(s?{id:s,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[l,u]=i.useState(!1),{sessions:m,loading:x,error:v,createSession:y,deleteSession:z,refetch:S}=fc(o);i.useEffect(()=>{if(s&&m.length>0){const b=m.find(f=>f.id===s);b&&h(b)}},[s,m]);const _=i.useCallback(b=>{h(b),u(!1)},[]),E=i.useCallback(async b=>{try{const f=b||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,$=await y({title:f});return h($),a==null||a($),$}catch(f){const $=f instanceof Error?f.message:"Failed to create session";throw g==null||g($),f}},[y,a,g]),I=i.useCallback(async b=>{try{await z(b),(c==null?void 0:c.id)===b&&h(null),p==null||p(b)}catch(f){const $=f instanceof Error?f.message:"Failed to delete session";throw g==null||g($),f}},[z,c,p,g]),w={agentName:r,token:o,platformAdapter:n,sessions:m,selectedSession:c,loadingSessions:x,sessionError:v,selectSession:_,createSession:E,deleteSession:I,refreshSessions:S,showHistory:l,setShowHistory:u,onSessionCreated:a,onSessionDeleted:p,onError:g};return e.jsx(gc.Provider,{value:w,children:t})}var mc=(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))(mc||{});function Qd(t,r){const o={username:Xd(t,r),email:Jd(t,r),phone:eu(t,r),email_otp:tu(t,r),magic_link:ru(t,r),oauth:ou(t),generic:nu(t,r)};return function(s){return o[s]}}function Xd(t,r){return async({username:o,password:n})=>{var g,c;const s=new FormData;s.append("strategy","plain_username"),s.append("username",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),p=await G(a);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),p}}function Jd(t,r){return async({email:o,password:n})=>{var g,c;const s=new FormData;s.append("strategy","plain_email"),s.append("email",o),s.append("password",n);const a=await t("/auth/signin",{method:"POST",body:s}),p=await G(a);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),p}}function eu(t,r){return async({phone:o})=>{var p,g;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await G(s);return"data"in a&&((g=(p=a.data)==null?void 0:p.signin_attempts)!=null&&g.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function tu(t,r){return async({email:o})=>{var p,g;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await G(s);return"data"in a&&((g=(p=a.data)==null?void 0:p.signin_attempts)!=null&&g.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function ru(t,r){return async({email:o})=>{var p,g;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const s=await t("/auth/signin",{method:"POST",body:n}),a=await G(s);return"data"in a&&((g=(p=a.data)==null?void 0:p.signin_attempts)!=null&&g.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function ou(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const s=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),a=await G(s);return"data"in a&&a.data.oauth_url&&(window.location.href=a.data.oauth_url),a}}function nu(t,r){return async({email:o,username:n,password:s,phone:a,strategy:p,token:g})=>{var u,m;const c=new FormData;p&&c.append("strategy",p),o&&c.append("email",o),n&&c.append("username",n),s&&c.append("password",s),a&&c.append("phone",a),g&&c.append("token",g);const h=await t("/auth/signin",{method:"POST",body:c}),l=await G(h);return"data"in l&&((m=(u=l.data)==null?void 0:u.signin_attempts)!=null&&m.length)&&r(l.data.signin_attempts.at(-1)||null),l}}function xc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Qd(t,n),completeVerification:async s=>{var c,h;const a=new FormData;a.append("verification_code",s);const p=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:a}),g=await G(p);if("data"in g&&((h=(c=g.data)==null?void 0:c.signin_attempts)!=null&&h.length)){const l=g.data.signin_attempts.at(-1);return n(l||null),g.data}else throw new Error("Verification failed")},prepareVerification:async s=>{var g;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((g=o==null?void 0:o.id)==null?void 0:g.toString())||""),a.searchParams.set("strategy",s.strategy),a.searchParams.set("identifier_type","signin"),s.strategy==="phone_otp"&&s.lastDigits?a.searchParams.set("last_digits",s.lastDigits):(s.strategy==="email_otp"&&s.redirectUri||s.strategy==="magic_link"&&s.redirectUri)&&a.searchParams.set("redirect_uri",s.redirectUri);const p=await t(a.pathname+a.search,{method:"POST"});return G(p)},completeProfile:async s=>{var c;if(!o)throw new Error("No signin attempt found");const a=new FormData;for(const[h,l]of Object.entries(s))l&&a.append(h,l);const p=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:a}),g=await G(p);if("data"in g&&g.data){const h=(c=g.data.signin_attempts)==null?void 0:c.find(l=>l.id===o.id);return h&&n(h),g.data}else throw new Error("Profile completion failed")},identify:async s=>{const a=new FormData;a.append("identifier",s);const p=await t("/auth/identify",{method:"POST",body:a});return(await G(p)).data},initEnterpriseSso:async(s,a)=>{const p=new URLSearchParams({connection_id:s});a&&p.append("redirect_uri",a);const g=await t(`/auth/sso/login?${p.toString()}`,{method:"POST"});return(await G(g)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function Br(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:s,setSignInAttempt:a}=xc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:s,setSignInAttempt:a};const p=(()=>{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:p,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:s,setSignInAttempt:a}}function su(t,r,o){return{create:async n=>{var g,c,h;const s=new FormData;for(const[l,u]of Object.entries(n))s.append(l,u);const a=await t("/auth/signup",{method:"POST",body:s}),p=await G(a);return"data"in p&&((c=(g=p.data)==null?void 0:g.signup_attempts)!=null&&c.length)&&o(((h=p.data.signup_attempts)==null?void 0:h.at(-1))||null),p},prepareVerification:async n=>{var p;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((p=r==null?void 0:r.id)==null?void 0:p.toString())||""),s.searchParams.set("strategy",n.strategy),s.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?s.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&s.searchParams.set("redirect_uri",n.redirectUri);const a=await t(s.pathname+s.search,{method:"POST"});return G(a)},completeVerification:async n=>{var g,c;const s=new FormData;s.append("verification_code",n);const a=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),p=await G(a);return"data"in p&&((c=(g=p.data)==null?void 0:g.signup_attempts)!=null&&c.length)&&o(p.data.signup_attempts.at(-1)||null),p},validateDeploymentInvitation:async n=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),a=await G(s);return"data"in a&&a.data?a.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 vc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:su(t,o,n)}}const Ge=()=>{const{adapter:t,deployment:r}=ve(),o=t.useNavigate(),n=(c,h)=>{o?o(c,h):window.location.href=c},s=c=>{if(c)return c;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const h=s(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function au(t){const r=await t("/session",{method:"GET"});return(await G(r)).data}async function iu(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return G(o)}async function cu(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return G(n)}async function lu(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return G(o)}async function du(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return G(o)}const ns=new Map,Ar=new Map;function _t(){ns.clear(),Ar.clear()}async function uu(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return G(o)}function Ue(){const{client:t,loading:r}=Be(),{deployment:o}=ve(),{navigate:n}=Ge(),{cache:s}=hc(),{data:a,error:p,mutate:g,isLoading:c}=Fe(r?null:"/session",()=>au(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=i.useCallback(async()=>{await g(void 0,{revalidate:!0})},[g]),l=i.useCallback(async(u="default")=>{if(!a)throw new Error("no session");const m=ns.get(u);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";Ar.get(u)||Ar.set(u,uu(t,u));const x=await Ar.get(u);return Ar.delete(u),ns.set(u,x.data),x.data.token},[t,a==null?void 0:a.active_signin]);return r||!a||c?{loading:!0,error:p,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:h}:{loading:c,error:p,session:a,switchSignIn:async u=>{await iu(t,u),_t(),await Or("/me/organization-memberships",void 0,{revalidate:!1}),await Or("/me/workspace-memberships",void 0,{revalidate:!1}),await g(void 0,{revalidate:!0}),await Or("/me/organization-memberships"),await Or("/me/workspace-memberships")},signOut:async u=>{await cu(t,u);const m=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],x=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(s instanceof Map){const v=Array.from(s.keys());for(const y of v){let z=!1;(m.includes(y)||typeof y=="string"&&x.some(S=>y.startsWith(S)))&&(z=!0),z&&s.delete(y)}}_t(),await g(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(u&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!u&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async u=>{await lu(t,u),_t(),await g(void 0,{revalidate:!0})},switchWorkspace:async u=>{await du(t,u),_t(),await g(void 0,{revalidate:!0})},getToken:l,refetch:h}}const Yo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=Ct(),{client:n}=Be(),{refetch:s}=Ue(),a=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/roles`,{method:"GET"}))).data,[n]),p=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/members`,{method:"GET"}))).data,[n]),g=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/domains`,{method:"GET"}))).data,[n]),h=i.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/members/${O.id}/remove`,{method:"POST"})},[n]),l=i.useCallback(async F=>{const O=new FormData;O.append("name",F.name),F.image&&O.append("image",F.image),F.description&&O.append("description",F.description);const A=await G(await n("/organizations",{method:"POST",body:O}));return _t(),await r(),await s(),A},[s,r,n]),u=i.useCallback(async(F,O)=>{const A=Object.entries(O).reduce((re,[V,q])=>(q&&re.append(V,q),re),new FormData),J=await G(await n(`/organizations/${F.id}/update`,{method:"POST",body:A}));return await r(),J},[r,n]),m=i.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/roles/${O.id}/remove`,{method:"POST"})},[n]),x=i.useCallback(async(F,O)=>{const A=new FormData;return A.append("domain",O.fqdn),await G(await n(`/organizations/${F.id}/domains`,{method:"POST",body:A}))},[n]),v=i.useCallback(async(F,O)=>await G(await n(`/organizations/${F.id}/domains/${O.id}/verify`,{method:"POST"})),[n]),y=i.useCallback(async(F,O)=>await G(await n(`/organizations/${F.id}/domains/${O.id}/delete`,{method:"POST"})),[n]),z=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/enterprise-connections`,{method:"GET"}))).data,[n]),S=i.useCallback(async(F,O)=>{const A=new FormData;return A.append("protocol",O.protocol),O.domain_id&&A.append("domain_id",O.domain_id),O.idp_entity_id&&A.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&A.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&A.append("idp_certificate",O.idp_certificate),O.oidc_client_id&&A.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&A.append("oidc_client_secret",O.oidc_client_secret),O.oidc_issuer_url&&A.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_scopes&&A.append("oidc_scopes",O.oidc_scopes),O.jit_enabled!==void 0&&A.append("jit_enabled",String(O.jit_enabled)),O.attribute_mapping&&A.append("attribute_mapping",JSON.stringify(O.attribute_mapping)),(await G(await n(`/organizations/${F.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),_=i.useCallback(async(F,O,A)=>{const J=new FormData;return A.domain_id&&J.append("domain_id",A.domain_id),A.idp_entity_id&&J.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&J.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&J.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&J.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&J.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&J.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&J.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&J.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/update`,{method:"POST",body:J}))).data},[n]),E=i.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/enterprise-connections/${O}/delete`,{method:"POST"})},[n]),I=i.useCallback(async(F,O)=>{const A=new FormData;return A.append("protocol",O.protocol),O.idp_entity_id&&A.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&A.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&A.append("idp_certificate",O.idp_certificate),O.oidc_issuer_url&&A.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_client_id&&A.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&A.append("oidc_client_secret",O.oidc_client_secret),(await G(await n(`/organizations/${F.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),w=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/test`,{method:"POST"}))).data,[n]),b=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/scim/token`,{method:"POST"}))).data,[n]),f=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/scim/token`,{method:"GET"}))).data,[n]),$=i.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/enterprise-connections/${O}/scim/token/revoke`,{method:"POST"})},[n]),k=i.useCallback(async(F,O)=>{const A=new FormData;return A.append("name",O.name),O.permissions&&O.permissions.forEach((re,V)=>{A.append(`permissions[${V}]`,re)}),await G(await n(`/organizations/${F.id}/roles`,{method:"POST",body:A}))},[n]),j=i.useCallback(async F=>(await G(await n(`/organizations/${F.id}/leave`,{method:"POST"}))).data,[n]),M=i.useCallback(async F=>{const O=await G(await n(`/organizations/${F.id}/delete`,{method:"POST"}));return _t(),await r(),await s(),O.data},[n,r,s]),R=i.useCallback(async(F,O,A)=>(await G(await n(`/organizations/${F.id}/members/${O.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),C=i.useCallback(async(F,O,A)=>(await G(await n(`/organizations/${F.id}/members/${O.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),P=i.useCallback(async(F,O)=>{var re,V;const A=new FormData;return A.append("email",O.email),A.append("role_id",O.organizationRole.id),(re=O.workspace)!=null&&re.id&&A.append("workspace_id",O.workspace.id),(V=O.workspaceRole)!=null&&V.id&&A.append("workspace_role_id",O.workspaceRole.id),(await G(await n(`/organizations/${F.id}/invitations`,{method:"POST",body:A}))).data},[n]),T=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/invitations/${O.id}/discard`,{method:"POST"}))).data,[n]),B=i.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/invitations/${O.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(F=>F.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:j,getOrganizationRoles:a,getOrganizationMembers:p,removeOrganizationMember:h,createOrganization:l,getOrganizationInvitations:g,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:y,addRoleToOrganizationMember:R,removeRoleFromOrganizationMember:C,inviteOrganizationMember:P,discardOrganizationInvitation:T,resendOrganizationInvitation:B,updateOrganization:u,addRole:k,removeOrganizationRoles:m,deleteOrganization:M,getEnterpriseConnections:z,createEnterpriseConnection:S,updateEnterpriseConnection:_,deleteEnterpriseConnection:E,testEnterpriseConnectionConfig:I,testEnterpriseConnection:w,generateSCIMToken:b,getSCIMToken:f,revokeSCIMToken:$}},Ze=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:s,leaveOrganization:a,removeOrganizationMember:p,getOrganizationInvitations:g,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:l,verifyOrganizationDomain:u,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:y,resendOrganizationInvitation:z,updateOrganization:S,removeOrganizationRoles:_,getEnterpriseConnections:E,createEnterpriseConnection:I,updateEnterpriseConnection:w,deleteEnterpriseConnection:b,testEnterpriseConnectionConfig:f,testEnterpriseConnection:$,generateSCIMToken:k,getSCIMToken:j,revokeSCIMToken:M}=Yo(),{session:R,error:C,loading:P}=Ue(),{organizationMemberships:T}=Ct(),B=i.useMemo(()=>(T==null?void 0:T.find(D=>{var Z;return D.id===((Z=R==null?void 0:R.active_signin)==null?void 0:Z.active_organization_membership_id)}))||null,[T,R]),L=i.useMemo(()=>(B==null?void 0:B.organization)||null,[B]),F=i.useCallback(async D=>L?await S(L,D):[],[L,S]),O=i.useCallback(async()=>L?await n(L):[],[L,n]),A=i.useCallback(async()=>L?await s(L):[],[L,s]),J=i.useCallback(async D=>L?await p(L,D):[],[L,p]),re=i.useCallback(async D=>L?await _(L,D):void 0,[L,_]),V=i.useCallback(async()=>L?await c(L):[],[L,c]),q=i.useCallback(async D=>L?await l(L,D):void 0,[L,l]),H=i.useCallback(async D=>L?await u(L,D):void 0,[L,u]),ee=i.useCallback(async D=>L?await h(L,D):void 0,[L,h]),le=i.useCallback(async(D,Z)=>L?await m(L,D,Z):void 0,[L,m]),oe=i.useCallback(async(D,Z)=>L?await x(L,D,Z):void 0,[L,x]),de=i.useCallback(async D=>L?await v(L,D):void 0,[L,v]),K=i.useCallback(async D=>L?await y(L,D):void 0,[L,y]),se=i.useCallback(async D=>L?await z(L,D):void 0,[L,z]),xe=i.useCallback(async()=>{L&&await a(L)},[L,a]),ue=i.useCallback(async()=>L?await g(L):[],[L,g]),U=i.useCallback(async()=>L?await E(L):[],[L,E]),pe=i.useCallback(async D=>{if(L)return await I(L,D)},[L,I]),Q=i.useCallback(async(D,Z)=>{if(L)return await w(L,D,Z)},[L,w]),Y=i.useCallback(async D=>{L&&await b(L,D)},[L,b]),ne=i.useCallback(async D=>L?await f(L,D):null,[L,f]),me=i.useCallback(async D=>L?await $(L,D):null,[L,$]),fe=i.useCallback(async D=>{if(L)return await k(L,D)},[L,k]),W=i.useCallback(async D=>{if(L)return await j(L,D)},[L,j]),N=i.useCallback(async D=>{L&&await M(L,D)},[L,M]);return P||t?{activeOrganization:null,activeMembership:null,loading:!0,error:C||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,getEnterpriseConnections:null,createEnterpriseConnection:null,updateEnterpriseConnection:null,deleteEnterpriseConnection:null,generateSCIMToken:null,getSCIMToken:null,revokeSCIMToken:null}:{activeOrganization:L,activeMembership:B,loading:!1,refetch:o,getRoles:A,updateOrganization:F,getMembers:O,getDomains:V,addDomain:q,verifyDomain:H,removeDomain:ee,getInvitations:ue,removeMember:J,leave:xe,removeRole:re,addMemberRole:le,removeMemberRole:oe,inviteMember:de,discardInvitation:K,resendInvitation:se,getEnterpriseConnections:U,createEnterpriseConnection:pe,updateEnterpriseConnection:Q,deleteEnterpriseConnection:Y,testEnterpriseConnectionConfig:ne,testEnterpriseConnection:me,generateSCIMToken:fe,getSCIMToken:W,revokeSCIMToken:N,error:null}};async function pu(t){return(await G(await t("/me/organization-memberships"))).data}const Ct=()=>{const{client:t,loading:r}=Be(),{data:o,isLoading:n,error:s,mutate:a}=Fe(r?null:"/me/organization-memberships",()=>pu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),p=i.useCallback(async()=>{await a(void 0,{revalidate:!0})},[a]);return{organizationMemberships:o,loading:r||n,error:s,refetch:p}};async function hu(t){return(await G(await t("/me/workspace-memberships"))).data}async function fu(t,r,o){return(await G(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Zo=()=>{const{client:t,loading:r}=Be(),{deployment:o}=ve(),{data:n,isLoading:s,error:a,mutate:p}=Fe(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>hu(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||s,error:a,refetch:g}},Pt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Zo(),{client:s}=Be(),a=i.useMemo(()=>t==null?void 0:t.map(w=>({...w.workspace,organization:w.organization,eligibility_restriction:w.eligibility_restriction})),[t]),p=i.useCallback(async(w,b,f,$)=>{const k=new FormData;k.append("name",b),f&&k.append("image",f),$&&k.append("description",$),k.append("organization_id",w);const j=await G(await s("/workspaces",{method:"POST",body:k}));return _t(),await r(),j.data},[s,r]),g=i.useCallback(async(w,b)=>{const f=await fu(s,w,b);return await r(),f},[s,r]),c=i.useCallback(async(w,b)=>{const f=new FormData;b.name&&f.append("name",b.name),b.description&&f.append("description",b.description),b.image&&f.append("image",b.image),b.enforce_2fa!==void 0&&f.append("enforce_2fa",String(b.enforce_2fa)),b.enable_ip_restriction!==void 0&&f.append("enable_ip_restriction",String(b.enable_ip_restriction)),b.whitelisted_ips&&b.whitelisted_ips.forEach(k=>f.append("whitelisted_ips",k));const $=await G(await s(`/workspaces/${w.id}/update`,{method:"POST",body:f}));return await r(),$.data},[s,r]),h=i.useCallback(async w=>{const b=await G(await s(`/workspaces/${w.id}/delete`,{method:"POST"}));return _t(),await r(),b.data},[s,r]),l=i.useCallback(async w=>(await G(await s(`/workspaces/${w.id}/members`,{method:"GET"}))).data,[s]),u=i.useCallback(async w=>(await G(await s(`/workspaces/${w.id}/roles`,{method:"GET"}))).data,[s]),m=i.useCallback(async(w,b,f)=>{const $=new FormData;return $.append("name",b),f.forEach(j=>$.append("permissions",j)),(await G(await s(`/workspaces/${w.id}/roles`,{method:"POST",body:$}))).data},[s]),x=i.useCallback(async(w,b)=>(await G(await s(`/workspaces/${w.id}/roles/${b.id}/delete`,{method:"POST"}))).data,[s]),v=i.useCallback(async(w,b)=>{const f=await G(await s(`/workspaces/${w.id}/members/${b}/remove`,{method:"POST"}));return await r(),f.data},[s,r]),y=i.useCallback(async(w,b,f)=>(await G(await s(`/workspaces/${w.id}/members/${b}/roles/${f}/add`,{method:"POST"}))).data,[s]),z=i.useCallback(async(w,b,f)=>(await G(await s(`/workspaces/${w.id}/members/${b}/roles/${f}/remove`,{method:"POST"}))).data,[s]),S=i.useCallback(async w=>(await G(await s(`/organizations/${w.organization.id}/invitations`,{method:"GET"}))).data.filter(f=>String(f.workspace_id)===String(w.id)),[s]),_=i.useCallback(async(w,b,f)=>{const $=new FormData;return $.append("email",b),$.append("workspace_id",w.id),f&&$.append("workspace_role_id",f),(await G(await s(`/organizations/${w.organization.id}/invitations`,{method:"POST",body:$}))).data},[s]),E=i.useCallback(async(w,b)=>(await G(await s(`/organizations/${w.organization.id}/invitations/${b}/discard`,{method:"POST"}))).data,[s]),I=i.useCallback(async(w,b)=>(await G(await s(`/organizations/${w.organization.id}/invitations/${b}/resend`,{method:"POST"}))).data,[s]);return{workspaces:a||[],loading:o,error:n,refetch:r,leaveWorkspace:g,createWorkspace:p,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:l,getWorkspaceRoles:u,createWorkspaceRole:m,deleteWorkspaceRole:x,removeWorkspaceMember:v,addWorkspaceMemberRole:y,removeWorkspaceMemberRole:z,getWorkspaceInvitations:S,createWorkspaceInvitation:_,discardWorkspaceInvitation:E,resendWorkspaceInvitation:I}},Rt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:s,updateWorkspace:a,deleteWorkspace:p,getWorkspaceMembers:g,getWorkspaceRoles:c,createWorkspaceRole:h,deleteWorkspaceRole:l,removeWorkspaceMember:u,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x,getWorkspaceInvitations:v,createWorkspaceInvitation:y,discardWorkspaceInvitation:z,resendWorkspaceInvitation:S}=Pt(),{workspaceMemberships:_}=Zo(),{session:E,loading:I,error:w}=Ue(),b=i.useMemo(()=>(_==null?void 0:_.find(H=>{var ee;return H.id===((ee=E==null?void 0:E.active_signin)==null?void 0:ee.active_workspace_membership_id)}))||null,[_,E]),f=i.useMemo(()=>(b==null?void 0:b.workspace)||null,[b]),$=i.useCallback(async()=>{var H;if(!(!f||!((H=E==null?void 0:E.active_signin)!=null&&H.user_id)))return await s(f.id,E.active_signin.user_id)},[f,s,E]),k=i.useCallback(async H=>{if(f)return await a(f,H)},[f,a]),j=i.useCallback(async()=>{if(f)return await p(f)},[f,p]),M=i.useCallback(async()=>f?await g(f):[],[f,g]),R=i.useCallback(async()=>f?await c(f):[],[f,c]),C=i.useCallback(async(H,ee)=>{if(f)return await h(f,H,ee)},[f,h]),P=i.useCallback(async H=>{if(f)return await l(f,H)},[f,l]),T=i.useCallback(async H=>{if(f)return await u(f,H)},[f,u]),B=i.useCallback(async(H,ee)=>{if(f)return await m(f,H,ee)},[f,m]),L=i.useCallback(async(H,ee)=>{if(f)return await x(f,H,ee)},[f,x]),F=i.useMemo(()=>(n==null?void 0:n.find(H=>H.id===(f==null?void 0:f.id)))||null,[n,f]),O=i.useCallback(async()=>F?await v(F):[],[F,v]),A=i.useCallback(async(H,ee)=>{if(F)return await y(F,H,ee)},[F,y]),J=i.useCallback(async H=>{if(F)return await z(F,H)},[F,z]),re=i.useCallback(async H=>{if(F)return await S(F,H)},[F,S]),V=r||I,q=o||w;return V?{activeWorkspace:null,activeMembership:null,loading:!0,error:q,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null,getInvitations:null,discardInvitation:null,resendInvitation:null}:{activeWorkspace:f,activeMembership:b,loading:!1,error:q,refetch:t,leave:$,updateWorkspace:k,deleteWorkspace:j,getMembers:M,getRoles:R,createRole:C,deleteRole:P,inviteMember:A,removeMember:T,addMemberRole:B,removeMemberRole:L,getInvitations:O,discardInvitation:J,resendInvitation:re}},gu=async t=>(await G(await t("/me"))).data,mu=async t=>(await G(await t("/me/signins"))).data;function nr(){const{client:t,loading:r}=Be(),{data:o,error:n,isLoading:s,mutate:a}=Fe(r?null:"/user",()=>gu(t)),p=async P=>{const T=new FormData;for(const[L,F]of Object.entries(P))F!=null&&F!==""&&T.append(L,String(F));const B=await G(await t("/me",{method:"POST",body:T}));return a(),B},g=async()=>await G(await t("/me/email-addresses",{method:"GET"})),c=async P=>await G(await t(`/me/email-addresses/${P}`,{method:"GET"})),h=async P=>{const T=new FormData;return T.append("email",P),await G(await t("/me/email-addresses",{method:"POST",body:T}))},l=async P=>await G(await t(`/me/email-addresses/${P}/delete`,{method:"POST"})),u=async P=>await G(await t(`/me/email-addresses/${P}/prepare-verification`,{method:"POST"})),m=async(P,T)=>await G(await t(`/me/email-addresses/${P}/attempt-verification?code=${T}`,{method:"POST"})),x=async(P,T)=>{const B=new FormData;return B.append("phone_number",P),B.append("country_code",T),await G(await t("/me/phone-numbers",{method:"POST",body:B}))},v=async P=>await G(await t(`/me/phone-numbers/${P}/delete`,{method:"POST"})),y=async P=>await G(await t(`/me/phone-numbers/${P}/prepare-verification`,{method:"POST"})),z=async(P,T)=>{const B=new FormData;return B.append("code",T),await G(await t(`/me/phone-numbers/${P}/attempt-verification`,{method:"POST",body:B}))},S=async P=>{const T=await G(await t(`/me/phone-numbers/${P}/make-primary`,{method:"POST"}));return a(),T},_=async P=>await G(await t(`/me/email-addresses/${P}/make-primary`,{method:"POST"})),E=async()=>(await G(await t("/me/authenticator",{method:"POST"}))).data,I=async(P,T)=>{const B=new FormData;return B.append("authenticator_id",P),T.forEach(F=>{B.append("codes",F)}),await G(await t("/me/authenticator/attempt-verification",{method:"POST",body:B}))},w=async P=>await G(await t(`/me/authenticator/${P}/delete`,{method:"POST"})),b=async()=>(await G(await t("/me/backup-codes",{method:"POST"}))).data,f=async P=>{const T=new FormData;return T.append("file",P),await G(await t("/me/profile-picture",{method:"POST",body:T}))},$=async()=>(await G(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,k=async(P,T)=>{const B=new FormData;return B.append("current_password",P),B.append("new_password",T),await G(await t("/me/update-password",{method:"POST",body:B}))},j=async P=>{const T=new FormData;T.append("current_password",P);const B=await G(await t("/me/remove-password",{method:"POST",body:T}));return a(),B},M=async P=>{const T=new FormData;return T.append("password",P),await G(await t("/me/account/delete",{method:"POST",body:T}))},R=async P=>await G(await t(`/me/social-connections/${P}/disconnect`,{method:"POST"})),C=async({provider:P,redirectUri:T})=>{var F;const B=new URLSearchParams({provider:P});T&&B.append("redirect_uri",T);const L=await G(await t(`/me/init-sso-connection?${B.toString()}`,{method:"POST"}));return"data"in L&&((F=L.data)!=null&&F.oauth_url)&&window.open(L.data.oauth_url,"_blank"),L};return{user:{...o,refetch:a},loading:r||s,error:n||null,updateProfile:p,getEmailAddresses:g,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:l,prepareEmailVerification:u,attemptEmailVerification:m,makeEmailPrimary:_,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:y,attemptPhoneVerification:z,makePhonePrimary:S,setupAuthenticator:E,verifyAuthenticator:I,deleteAuthenticator:w,generateBackupCodes:b,regenerateBackupCodes:$,updateProfilePicture:f,disconnectSocialConnection:R,connectSocialAccount:C,updatePassword:k,removePassword:j,deleteAccount:M}}function bc(){const{client:t,loading:r}=Be(),{data:o,error:n,isLoading:s,mutate:a}=Fe(r?null:"/me/signins",()=>mu(t));return{signins:o,error:n||null,removeSignin:async g=>await G(await t(`/me/signins/${g}/signout`,{method:"POST"})),refetch:a,loading:s||r}}function xu(){const{session:t,loading:r}=Ue(),{loading:o,organizationMemberships:n}=Ct(),{loading:s,workspaceMemberships:a}=Zo();if(r||o||s)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:a==null?void 0:a.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 yc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),s=async a=>{n(!0);try{const p=new FormData;for(const[h,l]of Object.entries(a))l&&p.append(h,l);const g=await t("/waitlist/join",{method:"POST",body:p});return await G(g)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:s}}function wc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),[s,a]=i.useState(null),[p,g]=i.useState(null),[c,h]=i.useState(null),[l,u]=i.useState(!1),[m,x]=i.useState(null);i.useEffect(()=>{if(l||r)return;const y=new URLSearchParams(window.location.search),z=y.get("code"),S=y.get("state"),_=y.get("error"),E=y.get("error_description");if(!z&&!_){u(!0);const I=new Error("No OAuth callback data found.");a(I);return}if(u(!0),n(!0),_){const I=E||_,w=new Error(`OAuth Error: ${I}`);a(w),n(!1);return}if(z&&S)v(z,S);else{const I=new Error("Missing required OAuth parameters");a(I),n(!1)}},[l,r]);const v=async(y,z)=>{try{let S,_;try{const w=z.split(".");if(w.length!==2)throw new Error("Invalid OAuth state format - missing signature");const b=w[0].replace(/-/g,"+").replace(/_/g,"/"),f=b.length%4?"=".repeat(4-b.length%4):"",k=atob(b+f).split("|")[0];if(k==="sign_in")S="/auth/oauth2/callback",_="GET";else if(k==="connect_social")S="/me/sso-connection-callback",_="POST";else throw new Error(`Unknown OAuth action: ${k}`)}catch(w){const b=w instanceof Error?w:new Error("Failed to parse OAuth state");a(new Error(`Invalid OAuth callback: ${b.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const E=await t(`${S}?code=${encodeURIComponent(y)}&state=${encodeURIComponent(z)}`,{method:_}),I=await G(E);if("data"in I){const w=I.data.session,b=I.data.redirect_uri||null;if(g(w),h(b),w.signin_attempts&&w.signin_attempts.length>0){const f=w.signin_attempts.at(-1);f&&x(f)}}else{const w=new Error("SSO callback failed");a(w)}}catch(S){const _=S instanceof Error?S:new Error("Unknown error occurred");a(_)}finally{n(!1)}};return{loading:o,error:s,session:p,redirectUri:c,processed:l,signinAttempt:m}}function jc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),[s,a]=i.useState(null);return{loading:r||o,verifyMagicLink:async g=>{if(!g.token||!g.attempt)throw new Error("Invalid magic link parameters");n(!0),a(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",g.token),c.searchParams.set("attempt",g.attempt),g.redirectUri&&c.searchParams.set("redirect_uri",g.redirectUri);const h=await t(c.pathname+c.search,{method:"GET"}),l=await G(h);return n(!1),a(!0),l}catch(c){throw n(!1),a(!1),c}},success:s}}function _c(){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 kc(){const{client:t,loading:r}=Be();return{loading:r,forgotPassword:async a=>{const p=new FormData;p.append("email",a);const g=await t("/auth/forgot-password",{method:"POST",body:p});return await G(g)},verifyOtp:async(a,p)=>{const g=new FormData;g.append("email",a),g.append("otp",p);const c=await t("/auth/forgot-password",{method:"POST",body:g});return await G(c)},resetPassword:async(a,p)=>{const g=new FormData;g.append("token",a),g.append("password",p);const c=await t("/auth/reset-password",{method:"POST",body:g});return await G(c)}}}function Cc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:s,onError:a,reconnectDelay:p=1e3,maxReconnectAttempts:g=5}={}){const{session:c,loading:h}=Ue(),{deployment:l,loading:u}=ve(),[m,x]=i.useState(!1),[v,y]=i.useState(null),z=i.useRef(null),S=i.useRef(null),_=i.useRef(0),E=i.useRef(null),I=i.useRef(s),w=i.useRef(a),b=i.useRef(r),f=i.useRef(o),$=i.useRef(n),k=i.useRef(p),j=i.useRef(g);I.current=s,w.current=a,b.current=r,f.current=o,$.current=n,k.current=p,j.current=g;const M=i.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null),E.current&&(clearInterval(E.current),E.current=null),z.current&&(z.current.close(),z.current=null)},[]),R=i.useCallback(async()=>{var F;if(!t||h||u||!c||!l)return;M();const T=new URL(l.backend_host),B=T.protocol==="https:"?"wss:":"ws:",L=new URL("/realtime/notifications",`${B}//${T.host}`);if(l.mode==="staging"){const O=localStorage.getItem("__dev_session__");O&&L.searchParams.set("__dev_session__",O)}b.current&&b.current.length>0&&b.current.forEach(O=>L.searchParams.append("channels",O)),f.current&&f.current.length>0&&f.current.forEach(O=>L.searchParams.append("organization_ids",O.toString())),$.current&&$.current.length>0&&$.current.forEach(O=>L.searchParams.append("workspace_ids",O.toString()));try{const O=new WebSocket(L.toString());z.current=O,O.onopen=()=>{x(!0),y(null),_.current=0,E.current=setInterval(()=>{O.readyState===WebSocket.OPEN&&O.send("ping")},3e4)},O.onmessage=A=>{var J,re;try{const V=JSON.parse(A.data);if(V.type==="notification"&&V.data)(J=I.current)==null||J.call(I,V.data);else if(V.type==="error"){const q=V.error||"Unknown error occurred";y(q),(re=w.current)==null||re.call(w,q)}else V.type}catch{}},O.onerror=()=>{var A;y("Connection error occurred"),(A=w.current)==null||A.call(w,"Connection error occurred")},O.onclose=A=>{var J;if(x(!1),E.current&&(clearInterval(E.current),E.current=null),t&&A.code!==1e3&&_.current<j.current){_.current++;const re=k.current*Math.pow(2,_.current-1);S.current=setTimeout(()=>{R()},re)}else _.current>=j.current&&(y("Max reconnection attempts reached"),(J=w.current)==null||J.call(w,"Max reconnection attempts reached"))}}catch{y("Failed to connect"),(F=w.current)==null||F.call(w,"Failed to connect")}},[t,h,u,c,l,M]);i.useEffect(()=>(R(),()=>{M()}),[R,M]),i.useEffect(()=>{z.current&&z.current.readyState===WebSocket.OPEN&&R()},[r,o,n,R]);const C=i.useCallback(()=>{M(),x(!1)},[M]),P=i.useCallback(()=>{_.current=0,R()},[R]);return{isConnected:m,connectionError:v,disconnect:C,reconnect:P}}async function vu(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():""}`,s=await t(n,{method:"GET"});return(await G(s)).data}async function bu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}async function yu(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return G(o)}async function wu(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return G(r)}async function ju(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return G(o)}function Sc(t){const{client:r,loading:o}=Be(),{data:n,error:s,mutate:a,isLoading:p}=Fe(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>vu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});Cc({enabled:!o&&!!n,onNotification:i.useCallback(u=>{a(async m=>!m||m.notifications.some(v=>v.id===u.id.toString())?m:{...m,notifications:[{id:u.id.toString(),user_id:u.user_id.toString(),deployment_id:u.deployment_id.toString(),title:u.title,body:u.body,severity:u.severity,action_url:u.action_url,action_label:u.action_label,is_read:!1,is_archived:!1,created_at:u.created_at,updated_at:u.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[a]),onError:i.useCallback(()=>{},[])});const g=i.useCallback(async u=>{o||(await a(async m=>m&&{...m,notifications:m.notifications.map(x=>x.id===u?{...x,is_read:!0}:x),unread_count:Math.max(0,m.unread_count-1)},!1),await yu(r,u),await a())},[r,o,a]),c=i.useCallback(async()=>{o||(await a(async u=>u&&{...u,notifications:u.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await wu(r),await a())},[r,a]),h=i.useCallback(async u=>{o||(await a(async m=>{if(!m)return m;const x=m.notifications.find(v=>v.id===u);return{...m,notifications:m.notifications.filter(v=>v.id!==u),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 ju(r,u),await a())},[r,o,a]),l=i.useCallback(async()=>{await a()},[a]);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:s,refetch:l}:{loading:!1,error:s,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:l}}async function _u(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}function ku(){const{client:t,loading:r}=Be(),{data:o,error:n,mutate:s}=Fe(r?null:"wacht-notifications:channel-counts",()=>_u(t),{refreshInterval:3e4,revalidateOnFocus:!0}),a=async()=>{await s()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:a}:{loading:!1,counts:o,error:n,refetch:a}}const qt=class qt{constructor(){tt(this,"ws",null);tt(this,"messageHandlers",new Set);tt(this,"connectionStateHandlers",new Set);tt(this,"reconnectTimer",null);tt(this,"reconnectAttempts",0);tt(this,"url",null);tt(this,"isIntentionalDisconnect",!1);tt(this,"sessionMessages",{});tt(this,"currentSessionKey",null)}static getInstance(){return qt.instance||(qt.instance=new qt),qt.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]=[])}};tt(qt,"instance");let ss=qt;const Qe=ss.getInstance(),wt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Le={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Ot={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Ks(t){switch(t){case Ot.IDLE:return Le.IDLE;case Ot.STARTING:return Le.STARTING;case Ot.RUNNING:return Le.RUNNING;case Ot.WAITING_FOR_INPUT:return Le.WAITING_FOR_INPUT;case Ot.COMPLETED:return Le.COMPLETED;case Ot.FAILED:case Ot.CANCELLED:return Le.FAILED;default:return Le.IDLE}}function Qs(t){return t===Le.STARTING||t===Le.RUNNING||t===Le.WAITING_FOR_INPUT}function zc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:s=!0}){const{deployment:a}=ve(),{client:p}=Be(),[g,c]=i.useState([]),[h,l]=i.useState(null),[u,m]=i.useState(null),[x,v]=i.useState(!1),[y,z]=i.useState(!1),[S,_]=i.useState(Le.IDLE),[E,I]=i.useState({status:wt.DISCONNECTED}),[w,b]=i.useState(!0),[f,$]=i.useState(!1),k=i.useRef(null),j=i.useRef(null),M=i.useCallback(V=>{var q,H;switch(V.message_type){case"session_connected":if(v(!0),I({status:wt.CONNECTED}),(q=V.data)!=null&&q.execution_status){const le=V.data.execution_status,oe=Ks(le);_(oe),z(Qs(oe))}break;case"conversation_message":R(V.data);break;case"user_input_request":C(V.data);break;case"platform_event":P(V.data);break;case"platform_function":T(V.data);break;case"execution_complete":z(!1),_(Le.IDLE),j.current=null;break;case"execution_error":z(!1),_(Le.FAILED),j.current=null;break;case"execution_cancelled":z(!1),_(Le.IDLE),j.current=null;break;case"execution_status":const ee=(H=V.data)==null?void 0:H.status;if(ee){const le=Ks(ee);_(le),z(Qs(le))}break}},[h]),R=i.useCallback(V=>{var oe,de,K,se,xe,ue,U,pe;const{id:q,message_type:H,content:ee}=V,le=Q=>g.some(Y=>Y.id===Q);if(H==="system_decision"||H==="action_execution_result"||H==="assistant_task_breakdown"||H==="assistant_validation"||H==="assistant_action_planning"||H==="context_results"){l(null),m(null);let Q="";if(H==="system_decision"){const Y=ee==null?void 0:ee.step,ne=ee==null?void 0:ee.reasoning;if(Y==="gathercontext")ne&&ne.length>0?Q=ne.length>60?`${ne.substring(0,60)}...`:ne:Q="Gathering context...";else if(Y==="executeaction")Q="Executing action";else if(Y==="deliverresponse")Q="Preparing response";else if(Y==="taskplanning")Q="Planning approach";else if(Y==="validateprogress")Q="Validating progress";else if(Y==="acknowledge")Q="Processing request";else if(Y==="finishplanning")Q="Finalizing plan";else if(Y==="executetasks")Q="Executing tasks";else if(Y==="requestuserinput")Q="Waiting for input";else if(Y==="complete")Q="Completed";else if(Y==="examinetool")Q="Examining tool";else if(Y==="examineworkflow")Q="Examining workflow";else{const me=(ee==null?void 0:ee.confidence)||.5;me>.8?Q="Analyzing":me>.6?Q="Thinking":Q="Reasoning"}}else if(H==="action_execution_result")((oe=ee.task_execution)==null?void 0:oe.status)==="completed"?Q="Task execution completed":(de=ee.task_execution)!=null&&de.approach?Q=ee.task_execution.approach:Q="Executing task";else if(H==="assistant_task_breakdown")(K=ee.task_breakdown)!=null&&K.total_tasks?Q=`Identified ${ee.task_breakdown.total_tasks} tasks`:Q="Planning tasks";else if(H==="assistant_validation")Q="Validated results";else if(H==="assistant_action_planning")(se=ee.task_execution)!=null&&se.total_tasks?Q=`Planned ${ee.task_execution.total_tasks} tasks`:(ue=(xe=ee.task_execution)==null?void 0:xe.tasks)!=null&&ue.length?Q=`Planned ${ee.task_execution.tasks.length} tasks`:Q="Planning actions";else if(H==="context_results"){const Y=ee.query,ne=ee.result_count||0;Y&&Y!=="General context gathering"?Q=`${Y}: Found ${ne} results`:Q=`Found ${ne} results`}Q&&!le(q)&&c(Y=>[...Y,{id:q,role:"system",content:Q,timestamp:new Date,metadata:{type:"log",messageType:H}}]);return}if(H==="user_message")le(q)||(l(null),m(null),c(Q=>[...Q,{id:q,role:"user",content:ee.message,images:ee.images,timestamp:new Date}]));else if(H==="agent_response")le(q)||(l(null),m(null),z(!1),_(Le.IDLE),j.current=null,c(Q=>[...Q,{id:q,role:"assistant",content:ee.response,timestamp:new Date,isStreaming:!1}]));else if(H==="assistant_acknowledgment")le(q)||(l(null),m(null),c(Q=>[...Q,{id:q,role:"assistant",content:ee.acknowledgment_message,timestamp:new Date}]));else if(H==="assistant_ideation"||H==="assistant_action_planning"||H==="action_execution_result"||H==="assistant_validation"||H==="assistant_context_gathering"||H==="assistant_task_breakdown"){let Q="";if(ee.reasoning_summary)Q=ee.reasoning_summary;else if((U=ee.task_execution)!=null&&U.approach)Q=ee.task_execution.approach;else if(ee.strategic_synthesis)Q=ee.strategic_synthesis;else if((pe=ee.task_breakdown)!=null&&pe.total_tasks)Q=`Breaking down into ${ee.task_breakdown.total_tasks} tasks...`;else if(ee.acknowledgment_message)Q=ee.acknowledgment_message;else return;c(Y=>[...Y,{id:q,role:"assistant",content:Q,timestamp:new Date}])}else if(H==="user_input_request"){const Q={question:ee.question,context:ee.context,input_type:ee.input_type,options:ee.options||ee.suggestions,default_value:ee.default_value,placeholder:ee.placeholder};_("waiting_for_input"),c(Y=>[...Y,{id:q,role:"system",content:Q.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:Q}}])}},[]),C=i.useCallback(async V=>{_("waiting_for_input");const q=`input-request-${Date.now()}`;c(H=>[...H,{id:q,role:"system",content:V.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:V}}])},[]),P=i.useCallback(V=>{const{event_label:q,event_data:H}=V;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(q,H)},[n]),T=i.useCallback(async V=>{const{function_name:q,function_data:H}=V,{parameters:ee,execution_id:le}=H;if(!(n!=null&&n.onPlatformFunction)){Qe.send({message_type:{platform_function_result:[le,{error:"No platform function handler registered"}]},data:{}});return}try{const oe=await n.onPlatformFunction(q,ee,le),de={message_type:{platform_function_result:[le,oe]},data:{}};Qe.send(de)}catch(oe){Qe.send({message_type:{platform_function_result:[le,{error:oe instanceof Error?oe.message:"Function execution failed",stack:oe instanceof Error?oe.stack:void 0}]},data:{}})}},[n]);i.useEffect(()=>{if(!a)return;const q=`wss://${a==null?void 0:a.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;I({status:wt.CONNECTING}),Qe.connect(q)},[a,o]),i.useEffect(()=>Qe.onConnectionStateChange(q=>{I({status:q.isConnected?wt.CONNECTED:q.error?wt.ERROR:wt.DISCONNECTED}),v(q.isConnected)}),[]),i.useEffect(()=>Qe.onMessage(M),[M]),i.useEffect(()=>{x&&t&&r&&s&&Qe.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,s]);const B=i.useCallback(async()=>(x&&t&&r&&Qe.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),L=i.useCallback((V,q)=>{x&&(l(V),m(q||null),z(!0),_(Le.STARTING),Qe.send({message_type:{message_input:V},data:q?{images:q}:{}}))},[x]),F=i.useCallback(()=>{c([]),j.current=null},[]),O=i.useCallback(V=>{!x||S!==Le.WAITING_FOR_INPUT||(Qe.send({message_type:{user_input_response:V},data:{}}),_(Le.RUNNING))},[x,S]),A=i.useCallback(async V=>{var q;if(!(!o||!t))try{const H=new URLSearchParams({token:o,limit:"50"});V&&(H.append("before_id",V),$(!0));const le=await(await p(`/api/agent/contexts/${t}/messages?${H}`,{method:"GET"})).json();if(le.status===200&&le.data){const oe=le.data;if(Array.isArray(oe.data)){const de=oe.data.filter(K=>{var ue;let se=K.content;if(typeof K.content=="string")try{se=JSON.parse(K.content)}catch{se={message:K.content}}const xe=((ue=K.metadata)==null?void 0:ue.message_type)||(se==null?void 0:se.message_type);return xe==="user_message"||xe==="agent_response"||xe==="assistant_acknowledgment"||xe==="user_input_request"||xe==="system_decision"||xe==="action_execution_result"||xe==="assistant_task_breakdown"||xe==="assistant_validation"||xe==="assistant_action_planning"||xe==="context_results"}).map(K=>{var Q,Y,ne,me,fe,W,N;let se="",xe,ue,U=K.content;if(typeof K.content=="string")try{U=JSON.parse(K.content)}catch{U=K.content}const pe=((Q=K.metadata)==null?void 0:Q.message_type)||(U==null?void 0:U.message_type);if(pe==="user_message"?(se=(U==null?void 0:U.message)||"",xe=(U==null?void 0:U.images)||void 0):pe==="agent_response"?se=(U==null?void 0:U.response)||"":pe==="assistant_acknowledgment"?se=(U==null?void 0:U.acknowledgment_message)||"":pe==="user_input_request"&&(se=(U==null?void 0:U.question)||"",ue={type:"user_input_request",userInputRequest:{question:(U==null?void 0:U.question)||"",context:(U==null?void 0:U.context)||"",input_type:(U==null?void 0:U.input_type)||"text",options:(U==null?void 0:U.options)||(U==null?void 0:U.suggestions)||[],default_value:(U==null?void 0:U.default_value)||"",placeholder:(U==null?void 0:U.placeholder)||""}}),pe==="system_decision"||pe==="action_execution_result"||pe==="assistant_task_breakdown"||pe==="assistant_validation"||pe==="assistant_action_planning"||pe==="context_results"){let D="";if(pe==="system_decision"){const Z=U==null?void 0:U.step,ae=U==null?void 0:U.reasoning;if(Z==="gathercontext")ae&&ae.length>0?D=ae.length>60?`${ae.substring(0,60)}...`:ae:D="Gathering context...";else if(Z==="executeaction")D="Executing action";else if(Z==="deliverresponse")D="Preparing response";else if(Z==="taskplanning")D="Planning approach";else if(Z==="validateprogress")D="Validating progress";else if(Z==="acknowledge")D="Processing request";else if(Z==="finishplanning")D="Finalizing plan";else if(Z==="executetasks")D="Executing tasks";else if(Z==="requestuserinput")D="Waiting for input";else if(Z==="complete")D="Completed";else if(Z==="examinetool")D="Examining tool";else if(Z==="examineworkflow")D="Examining workflow";else{const te=(U==null?void 0:U.confidence)||.5;te>.8?D="Analyzing":te>.6?D="Thinking":D="Reasoning"}}else if(pe==="action_execution_result")((Y=U==null?void 0:U.task_execution)==null?void 0:Y.status)==="completed"?D="Task execution completed":(ne=U==null?void 0:U.task_execution)!=null&&ne.approach?D=U.task_execution.approach:D="Executing task";else if(pe==="assistant_task_breakdown")(me=U==null?void 0:U.task_breakdown)!=null&&me.total_tasks?D=`Identified ${U.task_breakdown.total_tasks} tasks`:D="Planning tasks";else if(pe==="assistant_validation")D="Validated results";else if(pe==="assistant_action_planning")(fe=U==null?void 0:U.task_execution)!=null&&fe.total_tasks?D=`Planned ${U.task_execution.total_tasks} tasks`:(N=(W=U==null?void 0:U.task_execution)==null?void 0:W.tasks)!=null&&N.length?D=`Planned ${U.task_execution.tasks.length} tasks`:D="Planning actions";else if(pe==="context_results"){const Z=U==null?void 0:U.query,ae=(U==null?void 0:U.result_count)||0;Z&&Z!=="General context gathering"?D=`${Z}: Found ${ae} results`:D=`Found ${ae} results`}se=D,ue={type:"log",messageType:pe}}return{id:K.id,role:pe==="user_message"?"user":pe==="user_input_request"?"system":"assistant",content:se,images:xe,timestamp:new Date(K.timestamp||K.created_at||Date.now()),metadata:ue}}).filter(K=>K.content||K.metadata||K.images).sort((K,se)=>{const xe=BigInt(K.id),ue=BigInt(se.id);return xe<ue?-1:xe>ue?1:0});de.length>0&&(k.current=de[0].id),V?(c(K=>[...de,...K]),b(de.length>=50)):(c(de),de.length>0&&((q=de[de.length-1].metadata)==null?void 0:q.type)==="user_input_request"&&_(Le.WAITING_FOR_INPUT)),$(!1)}}}catch(H){console.error("Failed to fetch messages:",H),$(!1)}},[o,t,p]);i.useEffect(()=>{t&&o&&A()},[t,o]);const J=i.useCallback(async()=>{if(!(f||!w||!k.current)){$(!0);try{await A(k.current)}finally{$(!1)}}},[f,w,A]),re=i.useCallback(()=>{!x||!y||(Qe.send({message_type:{cancel_execution:null},data:{}}),z(!1),_("idle"))},[x,y]);return{messages:g,pendingMessage:h,pendingImages:u,connectionState:E,isConnected:x,isExecuting:y,executionStatus:S,isWaitingForInput:S==="waiting_for_input",hasMoreMessages:w,isLoadingMore:f,sendMessage:L,submitUserInput:O,clearMessages:F,loadMoreMessages:J,cancelExecution:re,connect:B,disconnect:()=>Qe.disconnect()}}const $c=()=>{const{client:t}=Be(),[r,o]=i.useState(!1),[n,s]=i.useState(null),[a,p]=i.useState(null),g=i.useCallback(async h=>{o(!0),s(null),p(null);try{const l=new FormData;l.append("token",h);const u=await t("/organizations/invitations/accept",{method:"POST",body:l}),x=(await G(u)).data;return p(x),x.error_code&&s(x.message||"Failed to accept invitation"),x}catch(l){const u=l.message||"Failed to accept invitation";s(u);const m={error_code:"NETWORK_ERROR",message:u};return p(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{s(null),p(null)},[]);return{acceptInvitation:g,invitationData:a,loading:r,error:n,reset:c}},Cu=({children:t})=>{const{loading:r}=ve();return r?null:e.jsx(e.Fragment,{children:t})},Su=({children:t})=>{const{loading:r}=ve();return r?e.jsx(e.Fragment,{children:t}):null};var Ye=function(){return Ye=Object.assign||function(r){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var a in o)Object.prototype.hasOwnProperty.call(o,a)&&(r[a]=o[a])}return r},Ye.apply(this,arguments)};function er(t,r,o){if(o||arguments.length===2)for(var n=0,s=r.length,a;n<s;n++)(a||!(n in r))&&(a||(a=Array.prototype.slice.call(r,0,n)),a[n]=r[n]);return t.concat(a||Array.prototype.slice.call(r))}function zu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var $u=/^((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)-.*))$/,Eu=zu(function(t){return $u.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ie="-ms-",Nr="-moz-",$e="-webkit-",Ec="comm",Ko="rule",js="decl",Iu="@import",Ic="@keyframes",Pu="@layer",Pc=Math.abs,_s=String.fromCharCode,as=Object.assign;function Ru(t,r){return We(t,0)^45?(((r<<2^We(t,0))<<2^We(t,1))<<2^We(t,2))<<2^We(t,3):0}function Rc(t){return t.trim()}function yt(t,r){return(t=r.exec(t))?t[0]:t}function ye(t,r,o){return t.replace(r,o)}function Io(t,r,o){return t.indexOf(r,o)}function We(t,r){return t.charCodeAt(r)|0}function yr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function Tc(t){return t.length}function Lr(t,r){return r.push(t),t}function Tu(t,r){return t.map(r).join("")}function Xs(t,r){return t.filter(function(o){return!yt(o,r)})}var Qo=1,wr=1,Mc=0,Je=0,De=0,Sr="";function Xo(t,r,o,n,s,a,p,g){return{value:t,root:r,parent:o,type:n,props:s,children:a,line:Qo,column:wr,length:p,return:"",siblings:g}}function zt(t,r){return as(Xo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function cr(t){for(;t.root;)t=zt(t.root,{children:[t]});Lr(t,t.siblings)}function Mu(){return De}function Ou(){return De=Je>0?We(Sr,--Je):0,wr--,De===10&&(wr=1,Qo--),De}function rt(){return De=Je<Mc?We(Sr,Je++):0,wr++,De===10&&(wr=1,Qo++),De}function Zt(){return We(Sr,Je)}function Po(){return Je}function Jo(t,r){return yr(Sr,t,r)}function is(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 Au(t){return Qo=wr=1,Mc=ct(Sr=t),Je=0,[]}function Lu(t){return Sr="",t}function xn(t){return Rc(Jo(Je-1,cs(t===91?t+2:t===40?t+1:t)))}function Du(t){for(;(De=Zt())&&De<33;)rt();return is(t)>2||is(De)>3?"":" "}function Nu(t,r){for(;--r&&rt()&&!(De<48||De>102||De>57&&De<65||De>70&&De<97););return Jo(t,Po()+(r<6&&Zt()==32&&rt()==32))}function cs(t){for(;rt();)switch(De){case t:return Je;case 34:case 39:t!==34&&t!==39&&cs(De);break;case 40:t===41&&cs(t);break;case 92:rt();break}return Je}function Fu(t,r){for(;rt()&&t+De!==57;)if(t+De===84&&Zt()===47)break;return"/*"+Jo(r,Je-1)+"*"+_s(t===47?t:rt())}function Bu(t){for(;!is(Zt());)rt();return Jo(t,Je)}function Uu(t){return Lu(Ro("",null,null,null,[""],t=Au(t),0,[0],t))}function Ro(t,r,o,n,s,a,p,g,c){for(var h=0,l=0,u=p,m=0,x=0,v=0,y=1,z=1,S=1,_=0,E="",I=s,w=a,b=n,f=E;z;)switch(v=_,_=rt()){case 40:if(v!=108&&We(f,u-1)==58){Io(f+=ye(xn(_),"&","&\f"),"&\f",Pc(h?g[h-1]:0))!=-1&&(S=-1);break}case 34:case 39:case 91:f+=xn(_);break;case 9:case 10:case 13:case 32:f+=Du(v);break;case 92:f+=Nu(Po()-1,7);continue;case 47:switch(Zt()){case 42:case 47:Lr(Wu(Fu(rt(),Po()),r,o,c),c);break;default:f+="/"}break;case 123*y:g[h++]=ct(f)*S;case 125*y:case 59:case 0:switch(_){case 0:case 125:z=0;case 59+l:S==-1&&(f=ye(f,/\f/g,"")),x>0&&ct(f)-u&&Lr(x>32?ea(f+";",n,o,u-1,c):ea(ye(f," ","")+";",n,o,u-2,c),c);break;case 59:f+=";";default:if(Lr(b=Js(f,r,o,h,l,s,g,E,I=[],w=[],u,a),a),_===123)if(l===0)Ro(f,r,b,b,I,a,u,g,w);else switch(m===99&&We(f,3)===110?100:m){case 100:case 108:case 109:case 115:Ro(t,b,b,n&&Lr(Js(t,b,b,0,0,s,g,E,s,I=[],u,w),w),s,w,u,g,n?I:w);break;default:Ro(f,b,b,b,[""],w,0,g,w)}}h=l=x=0,y=S=1,E=f="",u=p;break;case 58:u=1+ct(f),x=v;default:if(y<1){if(_==123)--y;else if(_==125&&y++==0&&Ou()==125)continue}switch(f+=_s(_),_*y){case 38:S=l>0?1:(f+="\f",-1);break;case 44:g[h++]=(ct(f)-1)*S,S=1;break;case 64:Zt()===45&&(f+=xn(rt())),m=Zt(),l=u=ct(E=f+=Bu(Po())),_++;break;case 45:v===45&&ct(f)==2&&(y=0)}}return a}function Js(t,r,o,n,s,a,p,g,c,h,l,u){for(var m=s-1,x=s===0?a:[""],v=Tc(x),y=0,z=0,S=0;y<n;++y)for(var _=0,E=yr(t,m+1,m=Pc(z=p[y])),I=t;_<v;++_)(I=Rc(z>0?x[_]+" "+E:ye(E,/&\f/g,x[_])))&&(c[S++]=I);return Xo(t,r,o,s===0?Ko:g,c,h,l,u)}function Wu(t,r,o,n){return Xo(t,r,o,Ec,_s(Mu()),yr(t,2,-2),0,n)}function ea(t,r,o,n,s){return Xo(t,r,o,js,yr(t,0,n),yr(t,n+1,-1),n,s)}function Oc(t,r,o){switch(Ru(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 Nr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return $e+t+Nr+t+Ie+t+t;case 5936:switch(We(t,r+11)){case 114:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return $e+t+Ie+ye(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return $e+t+Ie+t+t;case 6165:return $e+t+Ie+"flex-"+t+t;case 5187:return $e+t+ye(t,/(\w+).+(:[^]+)/,$e+"box-$1$2"+Ie+"flex-$1$2")+t;case 5443:return $e+t+Ie+"flex-item-"+ye(t,/flex-|-self/g,"")+(yt(t,/flex-|baseline/)?"":Ie+"grid-row-"+ye(t,/flex-|-self/g,""))+t;case 4675:return $e+t+Ie+"flex-line-pack"+ye(t,/align-content|flex-|-self/g,"")+t;case 5548:return $e+t+Ie+ye(t,"shrink","negative")+t;case 5292:return $e+t+Ie+ye(t,"basis","preferred-size")+t;case 6060:return $e+"box-"+ye(t,"-grow","")+$e+t+Ie+ye(t,"grow","positive")+t;case 4554:return $e+ye(t,/([^-])(transform)/g,"$1"+$e+"$2")+t;case 6187:return ye(ye(ye(t,/(zoom-|grab)/,$e+"$1"),/(image-set)/,$e+"$1"),t,"")+t;case 5495:case 3959:return ye(t,/(image-set\([^]*)/,$e+"$1$`$1");case 4968:return ye(ye(t,/(.+:)(flex-)?(.*)/,$e+"box-pack:$3"+Ie+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+$e+t+t;case 4200:if(!yt(t,/flex-|baseline/))return Ie+"grid-column-align"+yr(t,r)+t;break;case 2592:case 3360:return Ie+ye(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,s){return r=s,yt(n.props,/grid-\w+-end/)})?~Io(t+(o=o[r].value),"span",0)?t:Ie+ye(t,"-start","")+t+Ie+"grid-row-span:"+(~Io(o,"span",0)?yt(o,/\d+/):+yt(o,/\d+/)-+yt(t,/\d+/))+";":Ie+ye(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return yt(n.props,/grid-\w+-start/)})?t:Ie+ye(ye(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ye(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(We(t,r+1)){case 109:if(We(t,r+4)!==45)break;case 102:return ye(t,/(.+:)(.+)-([^]+)/,"$1"+$e+"$2-$3$1"+Nr+(We(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~Io(t,"stretch",0)?Oc(ye(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ye(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,s,a,p,g,c,h){return Ie+s+":"+a+h+(p?Ie+s+"-span:"+(g?c:+c-+a)+h:"")+t});case 4949:if(We(t,r+6)===121)return ye(t,":",":"+$e)+t;break;case 6444:switch(We(t,We(t,14)===45?18:11)){case 120:return ye(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+$e+(We(t,14)===45?"inline-":"")+"box$3$1"+$e+"$2$3$1"+Ie+"$2box$3")+t;case 100:return ye(t,":",":"+Ie)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ye(t,"scroll-","scroll-snap-")+t}return t}function Do(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Vu(t,r,o,n){switch(t.type){case Pu:if(t.children.length)break;case Iu:case js:return t.return=t.return||t.value;case Ec:return"";case Ic:return t.return=t.value+"{"+Do(t.children,n)+"}";case Ko:if(!ct(t.value=t.props.join(",")))return""}return ct(o=Do(t.children,n))?t.return=t.value+"{"+o+"}":""}function Gu(t){var r=Tc(t);return function(o,n,s,a){for(var p="",g=0;g<r;g++)p+=t[g](o,n,s,a)||"";return p}}function Hu(t){return function(r){r.root||(r=r.return)&&t(r)}}function qu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case js:t.return=Oc(t.value,t.length,o);return;case Ic:return Do([zt(t,{value:ye(t.value,"@","@"+$e)})],n);case Ko:if(t.length)return Tu(o=t.props,function(s){switch(yt(s,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":cr(zt(t,{props:[ye(s,/:(read-\w+)/,":"+Nr+"$1")]})),cr(zt(t,{props:[s]})),as(t,{props:Xs(o,n)});break;case"::placeholder":cr(zt(t,{props:[ye(s,/:(plac\w+)/,":"+$e+"input-$1")]})),cr(zt(t,{props:[ye(s,/:(plac\w+)/,":"+Nr+"$1")]})),cr(zt(t,{props:[ye(s,/:(plac\w+)/,Ie+"input-$1")]})),cr(zt(t,{props:[s]})),as(t,{props:Xs(o,n)});break}return""})}}var Yu={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},tr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Ac="active",Lc="data-styled-version",en="6.1.19",ks=`/*!sc*/
19
+ `,No=typeof window<"u"&&typeof document<"u",Zu=!!(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"),ta=/invalid hook call/i,Jr=new Set,Ku=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
- `,s=console.error;try{var a=!0;console.error=function(p){for(var g=[],c=1;c<arguments.length;c++)g[c-1]=arguments[c];ta.test(p)?(a=!1,Jr.delete(n)):s.apply(void 0,tr([p],g,!1))},i.useRef(),a&&!Jr.has(n)&&(console.warn(n),Jr.add(n))}catch(p){ta.test(p.message)&&Jr.delete(n)}finally{console.error=s}}},tn=Object.freeze([]),jr=Object.freeze({});function Ju(t,r,o){return o===void 0&&(o=jr),t.theme!==o.theme&&t.theme||r||o.theme}var ls=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"]),ep=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,tp=/(^-|-$)/g;function ra(t){return t.replace(ep,"-").replace(tp,"")}var rp=/(a)(d)/gi,eo=52,oa=function(t){return String.fromCharCode(t+(t>25?39:97))};function ds(t){var r,o="";for(r=Math.abs(t);r>eo;r=r/eo|0)o=oa(r%eo)+o;return(oa(r%eo)+o).replace(rp,"$1-$2")}var vn,Dc=5381,qt=function(t,r){for(var o=r.length;o;)t=33*t^r.charCodeAt(--o);return t},Nc=function(t){return qt(Dc,t)};function Fc(t){return ds(Nc(t)>>>0)}function Bc(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function bn(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var Uc=typeof Symbol=="function"&&Symbol.for,Wc=Uc?Symbol.for("react.memo"):60115,op=Uc?Symbol.for("react.forward_ref"):60112,np={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},sp={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Vc={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},ap=((vn={})[op]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},vn[Wc]=Vc,vn);function na(t){return("type"in(r=t)&&r.type.$$typeof)===Wc?Vc:"$$typeof"in t?ap[t.$$typeof]:np;var r}var ip=Object.defineProperty,cp=Object.getOwnPropertyNames,sa=Object.getOwnPropertySymbols,lp=Object.getOwnPropertyDescriptor,dp=Object.getPrototypeOf,aa=Object.prototype;function Gc(t,r,o){if(typeof r!="string"){if(aa){var n=dp(r);n&&n!==aa&&Gc(t,n,o)}var s=cp(r);sa&&(s=s.concat(sa(r)));for(var a=na(t),p=na(r),g=0;g<s.length;++g){var c=s[g];if(!(c in sp||o&&o[c]||p&&c in p||a&&c in a)){var h=lp(r,c);try{ip(t,c,h)}catch{}}}}return t}function _r(t){return typeof t=="function"}function Cs(t){return typeof t=="object"&&"styledComponentId"in t}function Zt(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function us(t,r){if(t.length===0)return"";for(var o=t[0],n=1;n<t.length;n++)o+=t[n];return o}function kr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function ps(t,r,o){if(o===void 0&&(o=!1),!o&&!kr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var n=0;n<r.length;n++)t[n]=ps(t[n],r[n]);else if(kr(r))for(var n in r)t[n]=ps(t[n],r[n]);return t}function Ss(t,r){Object.defineProperty(t,"toString",{value:r})}var up=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
23
+ `,s=console.error;try{var a=!0;console.error=function(p){for(var g=[],c=1;c<arguments.length;c++)g[c-1]=arguments[c];ta.test(p)?(a=!1,Jr.delete(n)):s.apply(void 0,er([p],g,!1))},i.useRef(),a&&!Jr.has(n)&&(console.warn(n),Jr.add(n))}catch(p){ta.test(p.message)&&Jr.delete(n)}finally{console.error=s}}},tn=Object.freeze([]),jr=Object.freeze({});function Qu(t,r,o){return o===void 0&&(o=jr),t.theme!==o.theme&&t.theme||r||o.theme}var ls=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"]),Xu=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,Ju=/(^-|-$)/g;function ra(t){return t.replace(Xu,"-").replace(Ju,"")}var ep=/(a)(d)/gi,eo=52,oa=function(t){return String.fromCharCode(t+(t>25?39:97))};function ds(t){var r,o="";for(r=Math.abs(t);r>eo;r=r/eo|0)o=oa(r%eo)+o;return(oa(r%eo)+o).replace(ep,"$1-$2")}var vn,Dc=5381,Ht=function(t,r){for(var o=r.length;o;)t=33*t^r.charCodeAt(--o);return t},Nc=function(t){return Ht(Dc,t)};function Fc(t){return ds(Nc(t)>>>0)}function Bc(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function bn(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var Uc=typeof Symbol=="function"&&Symbol.for,Wc=Uc?Symbol.for("react.memo"):60115,tp=Uc?Symbol.for("react.forward_ref"):60112,rp={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},op={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Vc={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},np=((vn={})[tp]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},vn[Wc]=Vc,vn);function na(t){return("type"in(r=t)&&r.type.$$typeof)===Wc?Vc:"$$typeof"in t?np[t.$$typeof]:rp;var r}var sp=Object.defineProperty,ap=Object.getOwnPropertyNames,sa=Object.getOwnPropertySymbols,ip=Object.getOwnPropertyDescriptor,cp=Object.getPrototypeOf,aa=Object.prototype;function Gc(t,r,o){if(typeof r!="string"){if(aa){var n=cp(r);n&&n!==aa&&Gc(t,n,o)}var s=ap(r);sa&&(s=s.concat(sa(r)));for(var a=na(t),p=na(r),g=0;g<s.length;++g){var c=s[g];if(!(c in op||o&&o[c]||p&&c in p||a&&c in a)){var h=ip(r,c);try{sp(t,c,h)}catch{}}}}return t}function _r(t){return typeof t=="function"}function Cs(t){return typeof t=="object"&&"styledComponentId"in t}function Yt(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function us(t,r){if(t.length===0)return"";for(var o=t[0],n=1;n<t.length;n++)o+=t[n];return o}function kr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function ps(t,r,o){if(o===void 0&&(o=!1),!o&&!kr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var n=0;n<r.length;n++)t[n]=ps(t[n],r[n]);else if(kr(r))for(var n in r)t[n]=ps(t[n],r[n]);return t}function Ss(t,r){Object.defineProperty(t,"toString",{value:r})}var lp=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 pp(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],s=1,a=t.length;s<a;s+=1)n.push(t[s]);return n.forEach(function(p){o=o.replace(/%[a-z]/,p)}),o}function zr(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(pp.apply(void 0,tr([up[t]],r,!1)).trim())}var hp=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,s=n.length,a=s;r>=a;)if((a<<=1)<0)throw zr(16,"".concat(r));this.groupSizes=new Uint32Array(a),this.groupSizes.set(n),this.length=a;for(var p=s;p<a;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),s=n+o;this.groupSizes[r]=0;for(var a=n;a<s;a++)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],s=this.indexOfGroup(r),a=s+n,p=s;p<a;p++)o+="".concat(this.tag.getRule(p)).concat(ks);return o},t}(),fp=1<<30,To=new Map,Fo=new Map,Mo=1,to=function(t){if(To.has(t))return To.get(t);for(;Fo.has(Mo);)Mo++;var r=Mo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>fp))throw zr(16,"".concat(r));return To.set(t,r),Fo.set(r,t),r},gp=function(t,r){Mo=r+1,To.set(t,r),Fo.set(r,t)},mp="style[".concat(rr,"][").concat(Lc,'="').concat(en,'"]'),xp=new RegExp("^".concat(rr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),vp=function(t,r,o){for(var n,s=o.split(","),a=0,p=s.length;a<p;a++)(n=s[a])&&t.registerName(r,n)},bp=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(ks),s=[],a=0,p=n.length;a<p;a++){var g=n[a].trim();if(g){var c=g.match(xp);if(c){var h=0|parseInt(c[1],10),l=c[2];h!==0&&(gp(l,h),vp(t,l,c[3]),t.getTag().insertRules(h,s)),s.length=0}else s.push(g)}}},ia=function(t){for(var r=document.querySelectorAll(mp),o=0,n=r.length;o<n;o++){var s=r[o];s&&s.getAttribute(rr)!==Ac&&(bp(t,s),s.parentNode&&s.parentNode.removeChild(s))}};function yp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var Hc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),s=function(g){var c=Array.from(g.querySelectorAll("style[".concat(rr,"]")));return c[c.length-1]}(o),a=s!==void 0?s.nextSibling:null;n.setAttribute(rr,Ac),n.setAttribute(Lc,en);var p=yp();return p&&n.setAttribute("nonce",p),o.insertBefore(n,a),n},wp=function(){function t(r){this.element=Hc(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,s=0,a=n.length;s<a;s++){var p=n[s];if(p.ownerNode===o)return p}throw zr(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}(),jp=function(){function t(r){this.element=Hc(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}(),_p=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}(),ca=No,kp={isServer:!No,useCSSOMInjection:!Qu},qc=function(){function t(r,o,n){r===void 0&&(r=jr),o===void 0&&(o={});var s=this;this.options=Ye(Ye({},kp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&No&&ca&&(ca=!1,ia(this)),Ss(this,function(){return function(a){for(var p=a.getTag(),g=p.length,c="",h=function(u){var m=function(S){return Fo.get(S)}(u);if(m===void 0)return"continue";var v=a.names.get(m),x=p.getGroup(u);if(v===void 0||!v.size||x.length===0)return"continue";var y="".concat(rr,".g").concat(u,'[id="').concat(m,'"]'),$="";v!==void 0&&v.forEach(function(S){S.length>0&&($+="".concat(S,","))}),c+="".concat(x).concat(y,'{content:"').concat($,'"}').concat(ks)},l=0;l<g;l++)h(l);return c}(s)})}return t.registerId=function(r){return to(r)},t.prototype.rehydrate=function(){!this.server&&No&&ia(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(Ye(Ye({},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,s=o.target;return o.isServer?new _p(s):n?new wp(s):new jp(s)}(this.options),new hp(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(to(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(to(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(to(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),Cp=/&/g,Sp=/^\s*\/\/.*$/gm;function Yc(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=Yc(o.children,r)),o})}function zp(t){var r,o,n,s=jr,a=s.options,p=a===void 0?jr:a,g=s.plugins,c=g===void 0?tn:g,h=function(m,v,x){return x.startsWith(o)&&x.endsWith(o)&&x.replaceAll(o,"").length>0?".".concat(r):m},l=c.slice();l.push(function(m){m.type===Ko&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(Cp,o).replace(n,h))}),p.prefix&&l.push(Zu),l.push(Hu);var u=function(m,v,x,y){v===void 0&&(v=""),x===void 0&&(x=""),y===void 0&&(y="&"),r=y,o=v,n=new RegExp("\\".concat(o,"\\b"),"g");var $=m.replace(Sp,""),S=Vu(x||v?"".concat(x," ").concat(v," { ").concat($," }"):$);p.namespace&&(S=Yc(S,p.namespace));var k=[];return Do(S,qu(l.concat(Yu(function(I){return k.push(I)})))),k};return u.hash=c.length?c.reduce(function(m,v){return v.name||zr(15),qt(m,v.name)},Dc).toString():"",u}var $p=new qc,hs=zp(),Zc=i.createContext({shouldForwardProp:void 0,styleSheet:$p,stylis:hs});Zc.Consumer;i.createContext(void 0);function la(){return i.useContext(Zc)}var fs=function(){function t(r,o){var n=this;this.inject=function(s,a){a===void 0&&(a=hs);var p=n.name+a.hash;s.hasNameForId(n.id,p)||s.insertRules(n.id,p,a(n.rules,p,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,Ss(this,function(){throw zr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=hs),this.name+r.hash},t}(),Ep=function(t){return t>="A"&&t<="Z"};function da(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;Ep(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Kc=function(t){return t==null||t===!1||t===""},Qc=function(t){var r,o,n=[];for(var s in t){var a=t[s];t.hasOwnProperty(s)&&!Kc(a)&&(Array.isArray(a)&&a.isCss||_r(a)?n.push("".concat(da(s),":"),a,";"):kr(a)?n.push.apply(n,tr(tr(["".concat(s," {")],Qc(a),!1),["}"],!1)):n.push("".concat(da(s),": ").concat((r=s,(o=a)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Ku||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Qt(t,r,o,n){if(Kc(t))return[];if(Cs(t))return[".".concat(t.styledComponentId)];if(_r(t)){if(!_r(a=t)||a.prototype&&a.prototype.isReactComponent||!r)return[t];var s=t(r);return process.env.NODE_ENV==="production"||typeof s!="object"||Array.isArray(s)||s instanceof fs||kr(s)||s===null||console.error("".concat(Bc(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.")),Qt(s,r,o,n)}var a;return t instanceof fs?o?(t.inject(o,n),[t.getName(n)]):[t]:kr(t)?Qc(t):Array.isArray(t)?Array.prototype.concat.apply(tn,t.map(function(p){return Qt(p,r,o,n)})):[t.toString()]}function Ip(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(_r(o)&&!Cs(o))return!1}return!0}var Pp=Nc(en),Rp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&Ip(r),this.componentId=o,this.baseHash=qt(Pp,o),this.baseStyle=n,qc.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var s=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))s=Zt(s,this.staticRulesId);else{var a=us(Qt(this.rules,r,o,n)),p=ds(qt(this.baseHash,a)>>>0);if(!o.hasNameForId(this.componentId,p)){var g=n(a,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,g)}s=Zt(s,p),this.staticRulesId=p}else{for(var c=qt(this.baseHash,n.hash),h="",l=0;l<this.rules.length;l++){var u=this.rules[l];if(typeof u=="string")h+=u,process.env.NODE_ENV!=="production"&&(c=qt(c,u));else if(u){var m=us(Qt(u,r,o,n));c=qt(c,m+l),h+=m}}if(h){var v=ds(c>>>0);o.hasNameForId(this.componentId,v)||o.insertRules(this.componentId,v,n(h,".".concat(v),void 0,this.componentId)),s=Zt(s,v)}}return s},t}(),Xc=i.createContext(void 0);Xc.Consumer;var yn={},ua=new Set;function Tp(t,r,o){var n=Cs(t),s=t,a=!bn(t),p=r.attrs,g=p===void 0?tn:p,c=r.componentId,h=c===void 0?function(E,w){var b=typeof E!="string"?"sc":ra(E);yn[b]=(yn[b]||0)+1;var f="".concat(b,"-").concat(Fc(en+b+yn[b]));return w?"".concat(w,"-").concat(f):f}(r.displayName,r.parentComponentId):c,l=r.displayName,u=l===void 0?function(E){return bn(E)?"styled.".concat(E):"Styled(".concat(Bc(E),")")}(t):l,m=r.displayName&&r.componentId?"".concat(ra(r.displayName),"-").concat(r.componentId):r.componentId||h,v=n&&s.attrs?s.attrs.concat(g).filter(Boolean):g,x=r.shouldForwardProp;if(n&&s.shouldForwardProp){var y=s.shouldForwardProp;if(r.shouldForwardProp){var $=r.shouldForwardProp;x=function(E,w){return y(E,w)&&$(E,w)}}else x=y}var S=new Rp(o,m,n?s.componentStyle:void 0);function k(E,w){return function(b,f,z){var _=b.attrs,j=b.componentStyle,M=b.defaultProps,R=b.foldedComponentIds,C=b.styledComponentId,P=b.target,T=i.useContext(Xc),B=la(),L=b.shouldForwardProp||B.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(C);var F=Ju(f,T,M)||jr,O=function(H,ee,le){for(var oe,de=Ye(Ye({},ee),{className:void 0,theme:le}),K=0;K<H.length;K+=1){var se=_r(oe=H[K])?oe(de):oe;for(var xe in se)de[xe]=xe==="className"?Zt(de[xe],se[xe]):xe==="style"?Ye(Ye({},de[xe]),se[xe]):se[xe]}return ee.className&&(de.className=Zt(de.className,ee.className)),de}(_,f,F),A=O.as||P,J={};for(var re in O)O[re]===void 0||re[0]==="$"||re==="as"||re==="theme"&&O.theme===F||(re==="forwardedAs"?J.as=O.forwardedAs:L&&!L(re,A)||(J[re]=O[re],L||process.env.NODE_ENV!=="development"||Pu(re)||ua.has(re)||!ls.has(A)||(ua.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 V=function(H,ee){var le=la(),oe=H.generateAndInjectStyles(ee,le.styleSheet,le.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(oe),oe}(j,O);process.env.NODE_ENV!=="production"&&b.warnTooManyClasses&&b.warnTooManyClasses(V);var q=Zt(R,C);return V&&(q+=" "+V),O.className&&(q+=" "+O.className),J[bn(A)&&!ls.has(A)?"class":"className"]=q,z&&(J.ref=z),i.createElement(A,J)}(I,E,w)}k.displayName=u;var I=i.forwardRef(k);return I.attrs=v,I.componentStyle=S,I.displayName=u,I.shouldForwardProp=x,I.foldedComponentIds=n?Zt(s.foldedComponentIds,s.styledComponentId):"",I.styledComponentId=m,I.target=n?s.target:t,Object.defineProperty(I,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(E){this._foldedDefaultProps=n?function(w){for(var b=[],f=1;f<arguments.length;f++)b[f-1]=arguments[f];for(var z=0,_=b;z<_.length;z++)ps(w,_[z],!0);return w}({},s.defaultProps,E):E}}),process.env.NODE_ENV!=="production"&&(Xu(u,m),I.warnTooManyClasses=function(E,w){var b={},f=!1;return function(z){if(!f&&(b[z]=!0,Object.keys(b).length>=200)){var _=w?' with the id of "'.concat(w,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(E).concat(_,`.
64
+ `,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function dp(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],s=1,a=t.length;s<a;s+=1)n.push(t[s]);return n.forEach(function(p){o=o.replace(/%[a-z]/,p)}),o}function zr(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(dp.apply(void 0,er([lp[t]],r,!1)).trim())}var up=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,s=n.length,a=s;r>=a;)if((a<<=1)<0)throw zr(16,"".concat(r));this.groupSizes=new Uint32Array(a),this.groupSizes.set(n),this.length=a;for(var p=s;p<a;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),s=n+o;this.groupSizes[r]=0;for(var a=n;a<s;a++)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],s=this.indexOfGroup(r),a=s+n,p=s;p<a;p++)o+="".concat(this.tag.getRule(p)).concat(ks);return o},t}(),pp=1<<30,To=new Map,Fo=new Map,Mo=1,to=function(t){if(To.has(t))return To.get(t);for(;Fo.has(Mo);)Mo++;var r=Mo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>pp))throw zr(16,"".concat(r));return To.set(t,r),Fo.set(r,t),r},hp=function(t,r){Mo=r+1,To.set(t,r),Fo.set(r,t)},fp="style[".concat(tr,"][").concat(Lc,'="').concat(en,'"]'),gp=new RegExp("^".concat(tr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),mp=function(t,r,o){for(var n,s=o.split(","),a=0,p=s.length;a<p;a++)(n=s[a])&&t.registerName(r,n)},xp=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(ks),s=[],a=0,p=n.length;a<p;a++){var g=n[a].trim();if(g){var c=g.match(gp);if(c){var h=0|parseInt(c[1],10),l=c[2];h!==0&&(hp(l,h),mp(t,l,c[3]),t.getTag().insertRules(h,s)),s.length=0}else s.push(g)}}},ia=function(t){for(var r=document.querySelectorAll(fp),o=0,n=r.length;o<n;o++){var s=r[o];s&&s.getAttribute(tr)!==Ac&&(xp(t,s),s.parentNode&&s.parentNode.removeChild(s))}};function vp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var Hc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),s=function(g){var c=Array.from(g.querySelectorAll("style[".concat(tr,"]")));return c[c.length-1]}(o),a=s!==void 0?s.nextSibling:null;n.setAttribute(tr,Ac),n.setAttribute(Lc,en);var p=vp();return p&&n.setAttribute("nonce",p),o.insertBefore(n,a),n},bp=function(){function t(r){this.element=Hc(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,s=0,a=n.length;s<a;s++){var p=n[s];if(p.ownerNode===o)return p}throw zr(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}(),yp=function(){function t(r){this.element=Hc(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}(),wp=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}(),ca=No,jp={isServer:!No,useCSSOMInjection:!Zu},qc=function(){function t(r,o,n){r===void 0&&(r=jr),o===void 0&&(o={});var s=this;this.options=Ye(Ye({},jp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&No&&ca&&(ca=!1,ia(this)),Ss(this,function(){return function(a){for(var p=a.getTag(),g=p.length,c="",h=function(u){var m=function(S){return Fo.get(S)}(u);if(m===void 0)return"continue";var x=a.names.get(m),v=p.getGroup(u);if(x===void 0||!x.size||v.length===0)return"continue";var y="".concat(tr,".g").concat(u,'[id="').concat(m,'"]'),z="";x!==void 0&&x.forEach(function(S){S.length>0&&(z+="".concat(S,","))}),c+="".concat(v).concat(y,'{content:"').concat(z,'"}').concat(ks)},l=0;l<g;l++)h(l);return c}(s)})}return t.registerId=function(r){return to(r)},t.prototype.rehydrate=function(){!this.server&&No&&ia(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(Ye(Ye({},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,s=o.target;return o.isServer?new wp(s):n?new bp(s):new yp(s)}(this.options),new up(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(to(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(to(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(to(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),_p=/&/g,kp=/^\s*\/\/.*$/gm;function Yc(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=Yc(o.children,r)),o})}function Cp(t){var r,o,n,s=jr,a=s.options,p=a===void 0?jr:a,g=s.plugins,c=g===void 0?tn:g,h=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===Ko&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(_p,o).replace(n,h))}),p.prefix&&l.push(qu),l.push(Vu);var u=function(m,x,v,y){x===void 0&&(x=""),v===void 0&&(v=""),y===void 0&&(y="&"),r=y,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var z=m.replace(kp,""),S=Uu(v||x?"".concat(v," ").concat(x," { ").concat(z," }"):z);p.namespace&&(S=Yc(S,p.namespace));var _=[];return Do(S,Gu(l.concat(Hu(function(E){return _.push(E)})))),_};return u.hash=c.length?c.reduce(function(m,x){return x.name||zr(15),Ht(m,x.name)},Dc).toString():"",u}var Sp=new qc,hs=Cp(),Zc=i.createContext({shouldForwardProp:void 0,styleSheet:Sp,stylis:hs});Zc.Consumer;i.createContext(void 0);function la(){return i.useContext(Zc)}var fs=function(){function t(r,o){var n=this;this.inject=function(s,a){a===void 0&&(a=hs);var p=n.name+a.hash;s.hasNameForId(n.id,p)||s.insertRules(n.id,p,a(n.rules,p,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,Ss(this,function(){throw zr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=hs),this.name+r.hash},t}(),zp=function(t){return t>="A"&&t<="Z"};function da(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;zp(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Kc=function(t){return t==null||t===!1||t===""},Qc=function(t){var r,o,n=[];for(var s in t){var a=t[s];t.hasOwnProperty(s)&&!Kc(a)&&(Array.isArray(a)&&a.isCss||_r(a)?n.push("".concat(da(s),":"),a,";"):kr(a)?n.push.apply(n,er(er(["".concat(s," {")],Qc(a),!1),["}"],!1)):n.push("".concat(da(s),": ").concat((r=s,(o=a)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Yu||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Kt(t,r,o,n){if(Kc(t))return[];if(Cs(t))return[".".concat(t.styledComponentId)];if(_r(t)){if(!_r(a=t)||a.prototype&&a.prototype.isReactComponent||!r)return[t];var s=t(r);return process.env.NODE_ENV==="production"||typeof s!="object"||Array.isArray(s)||s instanceof fs||kr(s)||s===null||console.error("".concat(Bc(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.")),Kt(s,r,o,n)}var a;return t instanceof fs?o?(t.inject(o,n),[t.getName(n)]):[t]:kr(t)?Qc(t):Array.isArray(t)?Array.prototype.concat.apply(tn,t.map(function(p){return Kt(p,r,o,n)})):[t.toString()]}function $p(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(_r(o)&&!Cs(o))return!1}return!0}var Ep=Nc(en),Ip=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&$p(r),this.componentId=o,this.baseHash=Ht(Ep,o),this.baseStyle=n,qc.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var s=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))s=Yt(s,this.staticRulesId);else{var a=us(Kt(this.rules,r,o,n)),p=ds(Ht(this.baseHash,a)>>>0);if(!o.hasNameForId(this.componentId,p)){var g=n(a,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,g)}s=Yt(s,p),this.staticRulesId=p}else{for(var c=Ht(this.baseHash,n.hash),h="",l=0;l<this.rules.length;l++){var u=this.rules[l];if(typeof u=="string")h+=u,process.env.NODE_ENV!=="production"&&(c=Ht(c,u));else if(u){var m=us(Kt(u,r,o,n));c=Ht(c,m+l),h+=m}}if(h){var x=ds(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(h,".".concat(x),void 0,this.componentId)),s=Yt(s,x)}}return s},t}(),Xc=i.createContext(void 0);Xc.Consumer;var yn={},ua=new Set;function Pp(t,r,o){var n=Cs(t),s=t,a=!bn(t),p=r.attrs,g=p===void 0?tn:p,c=r.componentId,h=c===void 0?function(I,w){var b=typeof I!="string"?"sc":ra(I);yn[b]=(yn[b]||0)+1;var f="".concat(b,"-").concat(Fc(en+b+yn[b]));return w?"".concat(w,"-").concat(f):f}(r.displayName,r.parentComponentId):c,l=r.displayName,u=l===void 0?function(I){return bn(I)?"styled.".concat(I):"Styled(".concat(Bc(I),")")}(t):l,m=r.displayName&&r.componentId?"".concat(ra(r.displayName),"-").concat(r.componentId):r.componentId||h,x=n&&s.attrs?s.attrs.concat(g).filter(Boolean):g,v=r.shouldForwardProp;if(n&&s.shouldForwardProp){var y=s.shouldForwardProp;if(r.shouldForwardProp){var z=r.shouldForwardProp;v=function(I,w){return y(I,w)&&z(I,w)}}else v=y}var S=new Ip(o,m,n?s.componentStyle:void 0);function _(I,w){return function(b,f,$){var k=b.attrs,j=b.componentStyle,M=b.defaultProps,R=b.foldedComponentIds,C=b.styledComponentId,P=b.target,T=i.useContext(Xc),B=la(),L=b.shouldForwardProp||B.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(C);var F=Qu(f,T,M)||jr,O=function(H,ee,le){for(var oe,de=Ye(Ye({},ee),{className:void 0,theme:le}),K=0;K<H.length;K+=1){var se=_r(oe=H[K])?oe(de):oe;for(var xe in se)de[xe]=xe==="className"?Yt(de[xe],se[xe]):xe==="style"?Ye(Ye({},de[xe]),se[xe]):se[xe]}return ee.className&&(de.className=Yt(de.className,ee.className)),de}(k,f,F),A=O.as||P,J={};for(var re in O)O[re]===void 0||re[0]==="$"||re==="as"||re==="theme"&&O.theme===F||(re==="forwardedAs"?J.as=O.forwardedAs:L&&!L(re,A)||(J[re]=O[re],L||process.env.NODE_ENV!=="development"||Eu(re)||ua.has(re)||!ls.has(A)||(ua.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 V=function(H,ee){var le=la(),oe=H.generateAndInjectStyles(ee,le.styleSheet,le.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(oe),oe}(j,O);process.env.NODE_ENV!=="production"&&b.warnTooManyClasses&&b.warnTooManyClasses(V);var q=Yt(R,C);return V&&(q+=" "+V),O.className&&(q+=" "+O.className),J[bn(A)&&!ls.has(A)?"class":"className"]=q,$&&(J.ref=$),i.createElement(A,J)}(E,I,w)}_.displayName=u;var E=i.forwardRef(_);return E.attrs=x,E.componentStyle=S,E.displayName=u,E.shouldForwardProp=v,E.foldedComponentIds=n?Yt(s.foldedComponentIds,s.styledComponentId):"",E.styledComponentId=m,E.target=n?s.target:t,Object.defineProperty(E,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(I){this._foldedDefaultProps=n?function(w){for(var b=[],f=1;f<arguments.length;f++)b[f-1]=arguments[f];for(var $=0,k=b;$<k.length;$++)ps(w,k[$],!0);return w}({},s.defaultProps,I):I}}),process.env.NODE_ENV!=="production"&&(Ku(u,m),E.warnTooManyClasses=function(I,w){var b={},f=!1;return function($){if(!f&&(b[$]=!0,Object.keys(b).length>=200)){var k=w?' with the id of "'.concat(w,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(I).concat(k,`.
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,231 +70,231 @@ Example:
70
70
  },
71
71
  }))\`width: 100%;\`
72
72
 
73
- <Component />`),f=!0,b={}}}}(u,m)),Ss(I,function(){return".".concat(I.styledComponentId)}),a&&Gc(I,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),I}function pa(t,r){for(var o=[t[0]],n=0,s=r.length;n<s;n+=1)o.push(r[n],t[n+1]);return o}var ha=function(t){return Object.assign(t,{isCss:!0})};function Xt(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(_r(t)||kr(t))return ha(Qt(pa(tn,tr([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?Qt(n):ha(Qt(pa(n,r)))}function gs(t,r,o){if(o===void 0&&(o=jr),!r)throw zr(1,r);var n=function(s){for(var a=[],p=1;p<arguments.length;p++)a[p-1]=arguments[p];return t(r,o,Xt.apply(void 0,tr([s],a,!1)))};return n.attrs=function(s){return gs(t,r,Ye(Ye({},o),{attrs:Array.prototype.concat(o.attrs,s).filter(Boolean)}))},n.withConfig=function(s){return gs(t,r,Ye(Ye({},o),s))},n}var Jc=function(t){return gs(Tp,t)},d=Jc;ls.forEach(function(t){d[t]=Jc(t)});function ar(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=us(Xt.apply(void 0,tr([t],r,!1))),s=Fc(n);return new fs(s,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={}}}}(u,m)),Ss(E,function(){return".".concat(E.styledComponentId)}),a&&Gc(E,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),E}function pa(t,r){for(var o=[t[0]],n=0,s=r.length;n<s;n+=1)o.push(r[n],t[n+1]);return o}var ha=function(t){return Object.assign(t,{isCss:!0})};function Qt(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(_r(t)||kr(t))return ha(Kt(pa(tn,er([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?Kt(n):ha(Kt(pa(n,r)))}function gs(t,r,o){if(o===void 0&&(o=jr),!r)throw zr(1,r);var n=function(s){for(var a=[],p=1;p<arguments.length;p++)a[p-1]=arguments[p];return t(r,o,Qt.apply(void 0,er([s],a,!1)))};return n.attrs=function(s){return gs(t,r,Ye(Ye({},o),{attrs:Array.prototype.concat(o.attrs,s).filter(Boolean)}))},n.withConfig=function(s){return gs(t,r,Ye(Ye({},o),s))},n}var Jc=function(t){return gs(Pp,t)},d=Jc;ls.forEach(function(t){d[t]=Jc(t)});function sr(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=us(Qt.apply(void 0,er([t],r,!1))),s=Fc(n);return new fs(s,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 ro="__sc-".concat(rr,"__");process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[ro]||(window[ro]=0),window[ro]===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 ro="__sc-".concat(tr,"__");process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[ro]||(window[ro]=0),window[ro]===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
77
  See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
78
78
  * @license lucide-react v0.474.0 - ISC
79
79
  *
80
80
  * This source code is licensed under the ISC license.
81
81
  * See the LICENSE file in the root directory of this source tree.
82
- */const Mp=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),el=(...t)=>t.filter((r,o,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===o).join(" ").trim();/**
82
+ */const Rp=t=>t.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),el=(...t)=>t.filter((r,o,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===o).join(" ").trim();/**
83
83
  * @license lucide-react v0.474.0 - ISC
84
84
  *
85
85
  * This source code is licensed under the ISC license.
86
86
  * See the LICENSE file in the root directory of this source tree.
87
- */var Op={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
87
+ */var Tp={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};/**
88
88
  * @license lucide-react v0.474.0 - ISC
89
89
  *
90
90
  * This source code is licensed under the ISC license.
91
91
  * See the LICENSE file in the root directory of this source tree.
92
- */const Ap=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:p,...g},c)=>i.createElement("svg",{ref:c,...Op,width:r,height:r,stroke:t,strokeWidth:n?Number(o)*24/Number(r):o,className:el("lucide",s),...g},[...p.map(([h,l])=>i.createElement(h,l)),...Array.isArray(a)?a:[a]]));/**
92
+ */const Mp=i.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:p,...g},c)=>i.createElement("svg",{ref:c,...Tp,width:r,height:r,stroke:t,strokeWidth:n?Number(o)*24/Number(r):o,className:el("lucide",s),...g},[...p.map(([h,l])=>i.createElement(h,l)),...Array.isArray(a)?a:[a]]));/**
93
93
  * @license lucide-react v0.474.0 - ISC
94
94
  *
95
95
  * This source code is licensed under the ISC license.
96
96
  * See the LICENSE file in the root directory of this source tree.
97
- */const we=(t,r)=>{const o=i.forwardRef(({className:n,...s},a)=>i.createElement(Ap,{ref:a,iconNode:r,className:el(`lucide-${Mp(t)}`,n),...s}));return o.displayName=`${t}`,o};/**
97
+ */const we=(t,r)=>{const o=i.forwardRef(({className:n,...s},a)=>i.createElement(Mp,{ref:a,iconNode:r,className:el(`lucide-${Rp(t)}`,n),...s}));return o.displayName=`${t}`,o};/**
98
98
  * @license lucide-react v0.474.0 - ISC
99
99
  *
100
100
  * This source code is licensed under the ISC license.
101
101
  * See the LICENSE file in the root directory of this source tree.
102
- */const Lp=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Dp=we("Activity",Lp);/**
102
+ */const Op=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ap=we("Activity",Op);/**
103
103
  * @license lucide-react v0.474.0 - ISC
104
104
  *
105
105
  * This source code is licensed under the ISC license.
106
106
  * See the LICENSE file in the root directory of this source tree.
107
- */const Np=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],Fp=we("BellOff",Np);/**
107
+ */const Lp=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],Dp=we("BellOff",Lp);/**
108
108
  * @license lucide-react v0.474.0 - ISC
109
109
  *
110
110
  * This source code is licensed under the ISC license.
111
111
  * See the LICENSE file in the root directory of this source tree.
112
- */const Bp=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],Up=we("BellRing",Bp);/**
112
+ */const Np=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],Fp=we("BellRing",Np);/**
113
113
  * @license lucide-react v0.474.0 - ISC
114
114
  *
115
115
  * This source code is licensed under the ISC license.
116
116
  * See the LICENSE file in the root directory of this source tree.
117
- */const Wp=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],wn=we("Bot",Wp);/**
117
+ */const Bp=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],wn=we("Bot",Bp);/**
118
118
  * @license lucide-react v0.474.0 - ISC
119
119
  *
120
120
  * This source code is licensed under the ISC license.
121
121
  * See the LICENSE file in the root directory of this source tree.
122
- */const Vp=[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Gp=we("Building2",Vp);/**
122
+ */const Up=[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]],Wp=we("Building2",Up);/**
123
123
  * @license lucide-react v0.474.0 - ISC
124
124
  *
125
125
  * This source code is licensed under the ISC license.
126
126
  * See the LICENSE file in the root directory of this source tree.
127
- */const Hp=[["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"}]],Ur=we("Building",Hp);/**
127
+ */const Vp=[["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"}]],Ur=we("Building",Vp);/**
128
128
  * @license lucide-react v0.474.0 - ISC
129
129
  *
130
130
  * This source code is licensed under the ISC license.
131
131
  * See the LICENSE file in the root directory of this source tree.
132
- */const qp=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ve=we("Check",qp);/**
132
+ */const Gp=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],Ve=we("Check",Gp);/**
133
133
  * @license lucide-react v0.474.0 - ISC
134
134
  *
135
135
  * This source code is licensed under the ISC license.
136
136
  * See the LICENSE file in the root directory of this source tree.
137
- */const Yp=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],or=we("ChevronDown",Yp);/**
137
+ */const Hp=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],rr=we("ChevronDown",Hp);/**
138
138
  * @license lucide-react v0.474.0 - ISC
139
139
  *
140
140
  * This source code is licensed under the ISC license.
141
141
  * See the LICENSE file in the root directory of this source tree.
142
- */const Zp=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Gr=we("ChevronLeft",Zp);/**
142
+ */const qp=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Gr=we("ChevronLeft",qp);/**
143
143
  * @license lucide-react v0.474.0 - ISC
144
144
  *
145
145
  * This source code is licensed under the ISC license.
146
146
  * See the LICENSE file in the root directory of this source tree.
147
- */const Kp=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ms=we("ChevronRight",Kp);/**
147
+ */const Yp=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ms=we("ChevronRight",Yp);/**
148
148
  * @license lucide-react v0.474.0 - ISC
149
149
  *
150
150
  * This source code is licensed under the ISC license.
151
151
  * See the LICENSE file in the root directory of this source tree.
152
- */const Qp=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],tl=we("ChevronUp",Qp);/**
152
+ */const Zp=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],tl=we("ChevronUp",Zp);/**
153
153
  * @license lucide-react v0.474.0 - ISC
154
154
  *
155
155
  * This source code is licensed under the ISC license.
156
156
  * See the LICENSE file in the root directory of this source tree.
157
- */const Xp=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Jp=we("ChevronsUpDown",Xp);/**
157
+ */const Kp=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],Qp=we("ChevronsUpDown",Kp);/**
158
158
  * @license lucide-react v0.474.0 - ISC
159
159
  *
160
160
  * This source code is licensed under the ISC license.
161
161
  * See the LICENSE file in the root directory of this source tree.
162
- */const eh=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Jt=we("Copy",eh);/**
162
+ */const Xp=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Xt=we("Copy",Xp);/**
163
163
  * @license lucide-react v0.474.0 - ISC
164
164
  *
165
165
  * This source code is licensed under the ISC license.
166
166
  * See the LICENSE file in the root directory of this source tree.
167
- */const th=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],rn=we("Download",th);/**
167
+ */const Jp=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],rn=we("Download",Jp);/**
168
168
  * @license lucide-react v0.474.0 - ISC
169
169
  *
170
170
  * This source code is licensed under the ISC license.
171
171
  * See the LICENSE file in the root directory of this source tree.
172
- */const rh=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],oh=we("Expand",rh);/**
172
+ */const eh=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],th=we("Expand",eh);/**
173
173
  * @license lucide-react v0.474.0 - ISC
174
174
  *
175
175
  * This source code is licensed under the ISC license.
176
176
  * See the LICENSE file in the root directory of this source tree.
177
- */const nh=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],zs=we("ExternalLink",nh);/**
177
+ */const rh=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],zs=we("ExternalLink",rh);/**
178
178
  * @license lucide-react v0.474.0 - ISC
179
179
  *
180
180
  * This source code is licensed under the ISC license.
181
181
  * See the LICENSE file in the root directory of this source tree.
182
- */const sh=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],jn=we("EyeOff",sh);/**
182
+ */const oh=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],jn=we("EyeOff",oh);/**
183
183
  * @license lucide-react v0.474.0 - ISC
184
184
  *
185
185
  * This source code is licensed under the ISC license.
186
186
  * See the LICENSE file in the root directory of this source tree.
187
- */const ah=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_n=we("Eye",ah);/**
187
+ */const nh=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_n=we("Eye",nh);/**
188
188
  * @license lucide-react v0.474.0 - ISC
189
189
  *
190
190
  * This source code is licensed under the ISC license.
191
191
  * See the LICENSE file in the root directory of this source tree.
192
- */const ih=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ch=we("Globe",ih);/**
192
+ */const sh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],ah=we("Globe",sh);/**
193
193
  * @license lucide-react v0.474.0 - ISC
194
194
  *
195
195
  * This source code is licensed under the ISC license.
196
196
  * See the LICENSE file in the root directory of this source tree.
197
- */const lh=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],dh=we("Link2",lh);/**
197
+ */const ih=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],ch=we("Link2",ih);/**
198
198
  * @license lucide-react v0.474.0 - ISC
199
199
  *
200
200
  * This source code is licensed under the ISC license.
201
201
  * See the LICENSE file in the root directory of this source tree.
202
- */const uh=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],kt=we("LoaderCircle",uh);/**
202
+ */const lh=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],kt=we("LoaderCircle",lh);/**
203
203
  * @license lucide-react v0.474.0 - ISC
204
204
  *
205
205
  * This source code is licensed under the ISC license.
206
206
  * See the LICENSE file in the root directory of this source tree.
207
- */const ph=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],Et=we("LogOut",ph);/**
207
+ */const dh=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],Et=we("LogOut",dh);/**
208
208
  * @license lucide-react v0.474.0 - ISC
209
209
  *
210
210
  * This source code is licensed under the ISC license.
211
211
  * See the LICENSE file in the root directory of this source tree.
212
- */const hh=[["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"}]],on=we("Mail",hh);/**
212
+ */const uh=[["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"}]],on=we("Mail",uh);/**
213
213
  * @license lucide-react v0.474.0 - ISC
214
214
  *
215
215
  * This source code is licensed under the ISC license.
216
216
  * See the LICENSE file in the root directory of this source tree.
217
- */const fh=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],gh=we("Maximize2",fh);/**
217
+ */const ph=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],hh=we("Maximize2",ph);/**
218
218
  * @license lucide-react v0.474.0 - ISC
219
219
  *
220
220
  * This source code is licensed under the ISC license.
221
221
  * See the LICENSE file in the root directory of this source tree.
222
- */const mh=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],fa=we("MessageCircle",mh);/**
222
+ */const fh=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],fa=we("MessageCircle",fh);/**
223
223
  * @license lucide-react v0.474.0 - ISC
224
224
  *
225
225
  * This source code is licensed under the ISC license.
226
226
  * See the LICENSE file in the root directory of this source tree.
227
- */const xh=[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]],vh=we("Paperclip",xh);/**
227
+ */const gh=[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]],mh=we("Paperclip",gh);/**
228
228
  * @license lucide-react v0.474.0 - ISC
229
229
  *
230
230
  * This source code is licensed under the ISC license.
231
231
  * See the LICENSE file in the root directory of this source tree.
232
- */const bh=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],yh=we("Phone",bh);/**
232
+ */const xh=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],vh=we("Phone",xh);/**
233
233
  * @license lucide-react v0.474.0 - ISC
234
234
  *
235
235
  * This source code is licensed under the ISC license.
236
236
  * See the LICENSE file in the root directory of this source tree.
237
- */const wh=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ke=we("Plus",wh);/**
237
+ */const bh=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Ke=we("Plus",bh);/**
238
238
  * @license lucide-react v0.474.0 - ISC
239
239
  *
240
240
  * This source code is licensed under the ISC license.
241
241
  * See the LICENSE file in the root directory of this source tree.
242
- */const jh=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],_h=we("Search",jh);/**
242
+ */const yh=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],wh=we("Search",yh);/**
243
243
  * @license lucide-react v0.474.0 - ISC
244
244
  *
245
245
  * This source code is licensed under the ISC license.
246
246
  * See the LICENSE file in the root directory of this source tree.
247
- */const kh=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],$s=we("Send",kh);/**
247
+ */const jh=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],$s=we("Send",jh);/**
248
248
  * @license lucide-react v0.474.0 - ISC
249
249
  *
250
250
  * This source code is licensed under the ISC license.
251
251
  * See the LICENSE file in the root directory of this source tree.
252
- */const Ch=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],er=we("Settings",Ch);/**
252
+ */const _h=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Jt=we("Settings",_h);/**
253
253
  * @license lucide-react v0.474.0 - ISC
254
254
  *
255
255
  * This source code is licensed under the ISC license.
256
256
  * See the LICENSE file in the root directory of this source tree.
257
- */const Sh=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Qe=we("Shield",Sh);/**
257
+ */const kh=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Xe=we("Shield",kh);/**
258
258
  * @license lucide-react v0.474.0 - ISC
259
259
  *
260
260
  * This source code is licensed under the ISC license.
261
261
  * See the LICENSE file in the root directory of this source tree.
262
- */const zh=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],nn=we("Trash2",zh);/**
262
+ */const Ch=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],nn=we("Trash2",Ch);/**
263
263
  * @license lucide-react v0.474.0 - ISC
264
264
  *
265
265
  * This source code is licensed under the ISC license.
266
266
  * See the LICENSE file in the root directory of this source tree.
267
- */const $h=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],Hr=we("Trash",$h);/**
267
+ */const Sh=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],Hr=we("Trash",Sh);/**
268
268
  * @license lucide-react v0.474.0 - ISC
269
269
  *
270
270
  * This source code is licensed under the ISC license.
271
271
  * See the LICENSE file in the root directory of this source tree.
272
- */const Eh=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ut=we("TriangleAlert",Eh);/**
272
+ */const zh=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ut=we("TriangleAlert",zh);/**
273
273
  * @license lucide-react v0.474.0 - ISC
274
274
  *
275
275
  * This source code is licensed under the ISC license.
276
276
  * See the LICENSE file in the root directory of this source tree.
277
- */const Ih=[["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"}]],Bo=we("User",Ih);/**
277
+ */const $h=[["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"}]],Bo=we("User",$h);/**
278
278
  * @license lucide-react v0.474.0 - ISC
279
279
  *
280
280
  * This source code is licensed under the ISC license.
281
281
  * See the LICENSE file in the root directory of this source tree.
282
- */const Ph=[["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"}]],Uo=we("Users",Ph);/**
282
+ */const Eh=[["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"}]],Uo=we("Users",Eh);/**
283
283
  * @license lucide-react v0.474.0 - ISC
284
284
  *
285
285
  * This source code is licensed under the ISC license.
286
286
  * See the LICENSE file in the root directory of this source tree.
287
- */const Rh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],et=we("X",Rh);/**
287
+ */const Ih=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],et=we("X",Ih);/**
288
288
  * @license lucide-react v0.474.0 - ISC
289
289
  *
290
290
  * This source code is licensed under the ISC license.
291
291
  * See the LICENSE file in the root directory of this source tree.
292
- */const Th=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Mh=we("ZoomIn",Th);/**
292
+ */const Ph=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Rh=we("ZoomIn",Ph);/**
293
293
  * @license lucide-react v0.474.0 - ISC
294
294
  *
295
295
  * This source code is licensed under the ISC license.
296
296
  * See the LICENSE file in the root directory of this source tree.
297
- */const Oh=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Ah=we("ZoomOut",Oh),ge=d.div`
297
+ */const Th=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Mh=we("ZoomOut",Th),ge=d.div`
298
298
  /* Colors - Light Mode */
299
299
  --color-background: #ffffff;
300
300
  --color-foreground: #111827;
@@ -446,16 +446,16 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
446
446
  background: var(--color-scrollbar-thumb-hover);
447
447
  }
448
448
  }
449
- `,Lh=d.div`
449
+ `,Oh=d.div`
450
450
  width: 100%;
451
451
  display: flex;
452
452
  flex-direction: column;
453
453
  gap: var(--space-xs);
454
- `,Dh=d.div`
454
+ `,Ah=d.div`
455
455
  display: flex;
456
456
  gap: var(--space-xs);
457
457
  justify-content: center;
458
- `,Nh=d.input`
458
+ `,Lh=d.input`
459
459
  width: 40px;
460
460
  height: 40px;
461
461
  border: 1px solid var(--color-border);
@@ -476,13 +476,13 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
476
476
  &::placeholder {
477
477
  color: var(--color-secondary-text);
478
478
  }
479
- `,Fh=d.p`
479
+ `,Dh=d.p`
480
480
  font-size: var(--font-2xs);
481
481
  color: var(--color-error);
482
482
  margin: 0;
483
483
  margin-top: var(--space-2xs);
484
484
  text-align: center;
485
- `,Bh=d.button`
485
+ `,Nh=d.button`
486
486
  background: none;
487
487
  border: none;
488
488
  color: var(--color-primary);
@@ -502,21 +502,21 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
502
502
  color: var(--color-secondary-text);
503
503
  cursor: not-allowed;
504
504
  }
505
- `,Uh=d.span`
505
+ `,Fh=d.span`
506
506
  color: var(--color-secondary-text);
507
507
  font-size: var(--font-xs);
508
508
  display: block;
509
509
  text-align: center;
510
- `;function Tt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:s=!1}){const[a,p]=i.useState(new Array(t).fill("")),[g,c]=i.useState(60),[h,l]=i.useState(!1),u=i.useRef([]),m=i.useCallback(()=>{const S=setInterval(()=>{c(k=>k<=1?(l(!0),clearInterval(S),0):k-1)},1e3);return S},[]);i.useEffect(()=>{const S=m();return()=>clearInterval(S)},[m]);const v=async()=>{var S;!h||s||!o||(await o(),l(!1),c(60),p(new Array(t).fill("")),(S=u.current[0])==null||S.focus(),m())},x=(S,k)=>{var b;if(s)return;const I=S.value,E=[...a];E[k]=I.replace(/[^0-9]/g,""),p(E);const w=E.join("");w.length===t&&r(w),I&&k<t-1&&((b=u.current[k+1])==null||b.focus())},y=(S,k)=>{var I;s||S.key==="Backspace"&&!a[k]&&k>0&&((I=u.current[k-1])==null||I.focus())},$=(S,k)=>{var f,z,_;if(s)return;S.preventDefault();const E=S.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(E.length===0)return;const w=[...a];for(let j=0;j<E.length&&k+j<t;j++)w[k+j]=E[j];if(k===0&&E.length===t)for(let j=0;j<t;j++)w[j]=E[j];p(w);const b=w.join("");if(b.length===t)r(b),(f=u.current[t-1])==null||f.focus();else{const j=w.findIndex((M,R)=>R>=k&&!M);if(j!==-1)(z=u.current[j])==null||z.focus();else{const M=w.map((R,C)=>R?C:-1).filter(R=>R!==-1).pop();M!==void 0&&M<t-1&&((_=u.current[M+1])==null||_.focus())}}};return e.jsxs(Lh,{children:[e.jsx(Dh,{children:a.map((S,k)=>e.jsx(Nh,{type:"text",maxLength:1,value:S,onChange:I=>x(I.target,k),onKeyDown:I=>y(I,k),onPaste:I=>$(I,k),ref:I=>{u.current[k]=I},disabled:s,autoFocus:k===0},k))}),n&&e.jsx(Fh,{children:n}),o&&e.jsx("div",{children:h?e.jsx(Bh,{type:"button",onClick:v,disabled:s,children:"Didn't receive a code? Resend"}):e.jsxs(Uh,{children:["Resend code in ",g,"s"]})})]})}const rl=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"})]}),ol=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"})]}),nl=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"})]}),sl=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"})}),Wh=()=>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"})}),al=()=>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"})}),il=()=>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"})]}),Vh=()=>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"})}),cl=()=>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"}})]}),kn={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(nl,{})},microsoft_oauth:{shortLabel:"Microsoft",fullLabel:"Continue with Microsoft",icon:e.jsx(ol,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(rl,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(sl,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(Wh,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(al,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(il,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(Vh,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(cl,{})}},Gh=d.div`
510
+ `;function Tt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:s=!1}){const[a,p]=i.useState(new Array(t).fill("")),[g,c]=i.useState(60),[h,l]=i.useState(!1),u=i.useRef([]),m=i.useCallback(()=>{const S=setInterval(()=>{c(_=>_<=1?(l(!0),clearInterval(S),0):_-1)},1e3);return S},[]);i.useEffect(()=>{const S=m();return()=>clearInterval(S)},[m]);const x=async()=>{var S;!h||s||!o||(await o(),l(!1),c(60),p(new Array(t).fill("")),(S=u.current[0])==null||S.focus(),m())},v=(S,_)=>{var b;if(s)return;const E=S.value,I=[...a];I[_]=E.replace(/[^0-9]/g,""),p(I);const w=I.join("");w.length===t&&r(w),E&&_<t-1&&((b=u.current[_+1])==null||b.focus())},y=(S,_)=>{var E;s||S.key==="Backspace"&&!a[_]&&_>0&&((E=u.current[_-1])==null||E.focus())},z=(S,_)=>{var f,$,k;if(s)return;S.preventDefault();const I=S.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(I.length===0)return;const w=[...a];for(let j=0;j<I.length&&_+j<t;j++)w[_+j]=I[j];if(_===0&&I.length===t)for(let j=0;j<t;j++)w[j]=I[j];p(w);const b=w.join("");if(b.length===t)r(b),(f=u.current[t-1])==null||f.focus();else{const j=w.findIndex((M,R)=>R>=_&&!M);if(j!==-1)($=u.current[j])==null||$.focus();else{const M=w.map((R,C)=>R?C:-1).filter(R=>R!==-1).pop();M!==void 0&&M<t-1&&((k=u.current[M+1])==null||k.focus())}}};return e.jsxs(Oh,{children:[e.jsx(Ah,{children:a.map((S,_)=>e.jsx(Lh,{type:"text",maxLength:1,value:S,onChange:E=>v(E.target,_),onKeyDown:E=>y(E,_),onPaste:E=>z(E,_),ref:E=>{u.current[_]=E},disabled:s,autoFocus:_===0},_))}),n&&e.jsx(Dh,{children:n}),o&&e.jsx("div",{children:h?e.jsx(Nh,{type:"button",onClick:x,disabled:s,children:"Didn't receive a code? Resend"}):e.jsxs(Fh,{children:["Resend code in ",g,"s"]})})]})}const rl=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"})]}),ol=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"})]}),nl=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"})]}),sl=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"})}),Bh=()=>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"})}),al=()=>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"})}),il=()=>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"})]}),Uh=()=>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"})}),cl=()=>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"}})]}),kn={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(nl,{})},microsoft_oauth:{shortLabel:"Microsoft",fullLabel:"Continue with Microsoft",icon:e.jsx(ol,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(rl,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(sl,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(Bh,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(al,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(il,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(Uh,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(cl,{})}},Wh=d.div`
511
511
  display: flex;
512
512
  flex-direction: column;
513
513
  gap: var(--space-xs);
514
514
  margin-bottom: var(--space-md);
515
- `,Hh=d.div`
515
+ `,Vh=d.div`
516
516
  display: flex;
517
517
  flex-wrap: wrap;
518
518
  gap: var(--space-xs);
519
- `,qh=d.button`
519
+ `,Gh=d.button`
520
520
  display: flex;
521
521
  align-items: center;
522
522
  justify-content: center;
@@ -532,11 +532,11 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
532
532
  font-weight: 400;
533
533
  height: 34px;
534
534
 
535
- ${t=>t.$totalProviders<=6?Xt`
535
+ ${t=>t.$totalProviders<=6?Qt`
536
536
  flex: 1 1 0;
537
- `:Xt`
537
+ `:Qt`
538
538
  flex: 0 0 calc((100% - (var(--space-xs) * 5)) / 6);
539
- ${t.$isWide&&Xt`
539
+ ${t.$isWide&&Qt`
540
540
  flex: 0 0 calc((100% - (var(--space-xs) * 3)) / 4);
541
541
  `}
542
542
  `}
@@ -551,7 +551,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
551
551
  height: 16px;
552
552
  flex-shrink: 0;
553
553
  }
554
- `,Es=({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,s=o();return e.jsx(Gh,{children:s.map((a,p)=>e.jsx(Hh,{children:a.map((g,c)=>{const h=g.provider;return e.jsxs(qh,{onClick:()=>r(g),type:"button",$isWide:s.length>1&&p<s.length-1,$totalProviders:n,children:[kn[h].icon,n<3&&e.jsx("span",{children:n===1?kn[h].fullLabel:kn[h].shortLabel})]},`${g.provider}-${c}`)})},`row-${p}`))})},ot=({to:t,replace:r,children:o,...n})=>{const{navigate:s}=Ge(),a=i.useCallback(p=>{p.preventDefault(),s(t,{replace:r})},[t,r,s]);return e.jsx("a",{href:t,onClick:a,...n,children:o})},Yh={sm:"36rem"},ce=d.input`
554
+ `,Es=({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,s=o();return e.jsx(Wh,{children:s.map((a,p)=>e.jsx(Vh,{children:a.map((g,c)=>{const h=g.provider;return e.jsxs(Gh,{onClick:()=>r(g),type:"button",$isWide:s.length>1&&p<s.length-1,$totalProviders:n,children:[kn[h].icon,n<3&&e.jsx("span",{children:n===1?kn[h].fullLabel:kn[h].shortLabel})]},`${g.provider}-${c}`)})},`row-${p}`))})},ot=({to:t,replace:r,children:o,...n})=>{const{navigate:s}=Ge(),a=i.useCallback(p=>{p.preventDefault(),s(t,{replace:r})},[t,r,s]);return e.jsx("a",{href:t,onClick:a,...n,children:o})},Hh={sm:"36rem"},ce=d.input`
555
555
  padding: var(--space-sm) var(--space-md);
556
556
  width: 100%;
557
557
  height: 36px;
@@ -591,12 +591,12 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
591
591
  color: var(--color-secondary-text);
592
592
  }
593
593
 
594
- @media (max-width: ${Yh.sm}) {
594
+ @media (max-width: ${Hh.sm}) {
595
595
  height: 32px;
596
596
  font-size: var(--font-2xs);
597
597
  padding: var(--space-xs) var(--space-sm);
598
598
  }
599
- `,Oo=[{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:"🇿🇼"}],$r={sm:"36rem"},Zh=d.div`
599
+ `,Oo=[{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:"🇿🇼"}],$r={sm:"36rem"},qh=d.div`
600
600
  display: flex;
601
601
  gap: var(--space-xs);
602
602
  width: 100%;
@@ -604,9 +604,9 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
604
604
  @media (max-width: ${$r.sm}) {
605
605
  gap: 0.375rem;
606
606
  }
607
- `,Kh=d.div`
607
+ `,Yh=d.div`
608
608
  position: relative;
609
- `,Qh=d.button`
609
+ `,Zh=d.button`
610
610
  display: flex;
611
611
  align-items: center;
612
612
  gap: 0.375rem;
@@ -635,7 +635,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
635
635
  padding: 0.375rem 0.625rem;
636
636
  font-size: 0.8125rem;
637
637
  }
638
- `,Xh=d.div`
638
+ `,Kh=d.div`
639
639
  position: absolute;
640
640
  top: calc(100% + 0.25rem);
641
641
  left: 0;
@@ -655,7 +655,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
655
655
  width: 15rem;
656
656
  max-height: 15rem;
657
657
  }
658
- `,Jh=d.input`
658
+ `,Qh=d.input`
659
659
  width: 100%;
660
660
  padding: 0.5rem 0.75rem;
661
661
  border: none;
@@ -677,14 +677,14 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
677
677
  padding: 0.375rem 0.625rem;
678
678
  font-size: 0.8125rem;
679
679
  }
680
- `,ef=d.div`
680
+ `,Xh=d.div`
681
681
  max-height: 15.625rem;
682
682
  overflow-y: auto;
683
683
 
684
684
  @media (max-width: ${$r.sm}) {
685
685
  max-height: 12.5rem;
686
686
  }
687
- `,tf=d.button`
687
+ `,Jh=d.button`
688
688
  display: flex;
689
689
  align-items: center;
690
690
  gap: 0.5rem;
@@ -711,13 +711,13 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
711
711
  font-size: 0.8125rem;
712
712
  gap: 0.375rem;
713
713
  }
714
- `,rf=d(ce)`
714
+ `,ef=d(ce)`
715
715
  flex: 1;
716
- `,qr=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:s})=>{const[a,p]=i.useState(!1),[g,c]=i.useState(Oo.find(x=>x.code===n)||Oo[0]),h=i.useRef(null),[l,u]=i.useState(""),m=i.useRef(null);i.useEffect(()=>{function x(y){h.current&&!h.current.contains(y.target)&&p(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const v=Oo.filter(x=>x.name.toLowerCase().includes(l.toLowerCase())||x.dialCode.includes(l));return i.useEffect(()=>{s(g.dialCode)},[g,s]),e.jsxs(Zh,{children:[e.jsxs(Kh,{ref:h,children:[e.jsxs(Qh,{type:"button",onClick:()=>p(x=>!x),children:[e.jsx("span",{children:g.flag}),e.jsx("span",{children:g.dialCode})]}),e.jsxs(Xh,{$isOpen:a,children:[e.jsx(Jh,{type:"text",placeholder:"Search country...",value:l,onChange:x=>u(x.target.value),onClick:x=>x.stopPropagation()}),e.jsx(ef,{children:v.map(x=>e.jsxs(tf,{onClick:y=>{var $;y.stopPropagation(),y.preventDefault(),c(x),p(!1),($=m.current)==null||$.focus()},children:[e.jsx("span",{children:x.flag}),e.jsx("span",{children:x.name}),e.jsx("span",{className:"country-code",children:x.dialCode})]},x.code))})]})]}),e.jsx(rf,{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}$"})]})},of=d.div`
716
+ `,qr=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:s})=>{const[a,p]=i.useState(!1),[g,c]=i.useState(Oo.find(v=>v.code===n)||Oo[0]),h=i.useRef(null),[l,u]=i.useState(""),m=i.useRef(null);i.useEffect(()=>{function v(y){h.current&&!h.current.contains(y.target)&&p(!1)}return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]);const x=Oo.filter(v=>v.name.toLowerCase().includes(l.toLowerCase())||v.dialCode.includes(l));return i.useEffect(()=>{s(g.dialCode)},[g,s]),e.jsxs(qh,{children:[e.jsxs(Yh,{ref:h,children:[e.jsxs(Zh,{type:"button",onClick:()=>p(v=>!v),children:[e.jsx("span",{children:g.flag}),e.jsx("span",{children:g.dialCode})]}),e.jsxs(Kh,{$isOpen:a,children:[e.jsx(Qh,{type:"text",placeholder:"Search country...",value:l,onChange:v=>u(v.target.value),onClick:v=>v.stopPropagation()}),e.jsx(Xh,{children:x.map(v=>e.jsxs(Jh,{onClick:y=>{var z;y.stopPropagation(),y.preventDefault(),c(v),p(!1),(z=m.current)==null||z.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(ef,{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}$"})]})},tf=d.div`
717
717
  display: flex;
718
718
  justify-content: center;
719
719
  margin-bottom: var(--space-lg);
720
- `,nf=d.div`
720
+ `,rf=d.div`
721
721
  display: flex;
722
722
  align-items: center;
723
723
  justify-content: center;
@@ -730,13 +730,13 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
730
730
  @media (prefers-color-scheme: dark) {
731
731
  background: var(--color-muted-background, rgba(255, 255, 255, 0.08));
732
732
  }
733
- `,sf=d.img`
733
+ `,of=d.img`
734
734
  max-width: 100%;
735
735
  max-height: 100%;
736
736
  width: auto;
737
737
  height: auto;
738
738
  object-fit: contain;
739
- `;function Pe(){var s;const{deployment:t}=ve(),[r,o]=i.useState(!1),n=(s=t==null?void 0:t.ui_settings)==null?void 0:s.logo_image_url;return!n||r?null:e.jsx(of,{children:e.jsx(nf,{children:e.jsx(sf,{src:n,alt:"Logo",onError:()=>o(!0)})})})}const af=ar`
739
+ `;function Pe(){var s;const{deployment:t}=ve(),[r,o]=i.useState(!1),n=(s=t==null?void 0:t.ui_settings)==null?void 0:s.logo_image_url;return!n||r?null:e.jsx(tf,{children:e.jsx(rf,{children:e.jsx(of,{src:n,alt:"Logo",onError:()=>o(!0)})})})}const nf=sr`
740
740
  from {
741
741
  transform: rotate(0deg);
742
742
  }
@@ -763,7 +763,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
763
763
  min-height: 200px;
764
764
 
765
765
  svg {
766
- animation: ${af} 1s linear infinite;
766
+ animation: ${nf} 1s linear infinite;
767
767
  color: var(--color-primary);
768
768
  }
769
769
  `,Cn=d.div`
@@ -792,7 +792,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
792
792
  @media (max-width: ${pt.sm}) {
793
793
  font-size: var(--font-2xs);
794
794
  }
795
- `,cf=d.div`
795
+ `,sf=d.div`
796
796
  position: relative;
797
797
  text-align: center;
798
798
  margin: var(--space-lg) 0;
@@ -810,7 +810,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
810
810
  @media (max-width: ${pt.sm}) {
811
811
  margin: var(--space-md) 0;
812
812
  }
813
- `,lf=d.span`
813
+ `,af=d.span`
814
814
  position: relative;
815
815
  background: var(--color-background);
816
816
  padding: 0 var(--space-sm);
@@ -824,7 +824,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
824
824
  @media (max-width: ${pt.sm}) {
825
825
  gap: 1rem;
826
826
  }
827
- `,df=d.div`
827
+ `,cf=d.div`
828
828
  display: grid;
829
829
  grid-template-columns: ${t=>t.$isBothEnabled?"1fr 1fr":"1fr"};
830
830
  gap: var(--space-sm);
@@ -833,11 +833,11 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
833
833
  grid-template-columns: 1fr;
834
834
  gap: 0.5rem;
835
835
  }
836
- `,dr=d.div`
836
+ `,lr=d.div`
837
837
  display: flex;
838
838
  flex-direction: column;
839
839
  gap: var(--space-xs);
840
- `,ur=d.label`
840
+ `,dr=d.label`
841
841
  font-size: var(--font-xs);
842
842
  text-align: left;
843
843
  font-weight: 400;
@@ -846,7 +846,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
846
846
  @media (max-width: ${pt.sm}) {
847
847
  font-size: 0.75rem;
848
848
  }
849
- `,uf=d.div`
849
+ `,lf=d.div`
850
850
  position: relative;
851
851
  `,At=d.p`
852
852
  font-size: var(--font-2xs);
@@ -898,30 +898,30 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
898
898
  &:hover {
899
899
  color: var(--color-primary-hover);
900
900
  }
901
- `,pf=d.div`
901
+ `,df=d.div`
902
902
  text-align: center;
903
903
  padding: var(--space-xl);
904
904
  margin-bottom: var(--space-lg);
905
- `,hf=d.p`
905
+ `,uf=d.p`
906
906
  font-size: var(--font-size-md);
907
907
  color: var(--color-text-secondary);
908
908
  margin: 0 0 var(--space-sm) 0;
909
909
  line-height: 1.5;
910
- `,ff=d.div`
910
+ `,pf=d.div`
911
911
  text-align: center;
912
912
  margin-top: var(--space-lg);
913
- `,gf=d.p`
913
+ `,hf=d.p`
914
914
  font-size: var(--font-xs);
915
915
  color: var(--color-muted);
916
916
  margin: 0;
917
- `,mf=d.a`
917
+ `,ff=d.a`
918
918
  color: var(--color-primary);
919
919
  text-decoration: none;
920
920
  cursor: pointer;
921
- `,pr=d.span`
921
+ `,ur=d.span`
922
922
  color: var(--color-danger);
923
923
  margin-left: 2px;
924
- `;function xf(){var V,q,H,ee,le,oe,de,K,se,xe,ue,U,pe,Q,Y,ne,me;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=vc(),{signIn:s}=Br("oauth"),{deployment:a}=ve(),{navigate:p}=Ge(),{session:g,refetch:c,loading:h}=Ue(),[l,u]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,v]=i.useState({}),[x,y]=i.useState(!1),[$,S]=i.useState(void 0),[k,I]=i.useState(null),[E,w]=i.useState(null),[b,f]=i.useState(!1),z=((V=a==null?void 0:a.restrictions)==null?void 0:V.sign_up_mode)==="restricted",_=((q=a==null?void 0:a.restrictions)==null?void 0:q.sign_up_mode)==="waitlist",j=((ee=(H=a==null?void 0:a.auth_settings)==null?void 0:H.multi_session_support)==null?void 0:ee.enabled)??!1;i.useEffect(()=>{var fe;if(!h&&(g!=null&&g.active_signin)&&!j&&!b){f(!0);let W=new URLSearchParams(window.location.search).get("redirect_uri");W||(W=((fe=a==null?void 0:a.ui_settings)==null?void 0:fe.after_signin_redirect_url)||null),!W&&(a!=null&&a.frontend_host)&&(W=`https://${a.frontend_host}`),!W&&(a!=null&&a.frontend_host)&&(W=`https://${a.frontend_host}`),W&&p(W)}},[g,h,j,a,p,b]),i.useEffect(()=>{var N;if(!a)return;const W=new URLSearchParams(window.location.search).get("invite_token");if(_&&!W){f(!0);const D=((N=a.ui_settings)==null?void 0:N.waitlist_page_url)||`https://${a.frontend_host}/waitlist`;p(D);return}W&&!k&&r&&(w(W),r.validateDeploymentInvitation(W).then(D=>{I(D),D.valid&&u(Z=>({...Z,first_name:D.first_name||Z.first_name,last_name:D.last_name||Z.last_name,email:D.email||Z.email}))}).catch(D=>{console.error("Failed to validate invitation:",D)}))},[a,_,p,k,r]);const[M,R]=i.useState(!1),[C,P]=i.useState(""),T=fe=>{let{name:W,value:N}=fe.target;W==="phone_number"?N=N.replace(/[^0-9-]/g,""):W==="email"&&(N=N.toLowerCase()),u(D=>({...D,[W]:N})),v(D=>({...D,[W]:""}))},B=()=>{u({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),v({}),R(!1),P(""),n()},L=async fe=>{if(fe.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",l),t||x)return;const W={},N=/^[a-zA-Z]{3,30}$/,D=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,Z=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,ae=/^\d{7,15}$/,te=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!l.first_name?W.first_name="First name is required":l.first_name&&!N.test(l.first_name)&&(W.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!l.last_name?W.last_name="Last name is required":l.last_name&&!N.test(l.last_name)&&(W.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!l.username?W.username="Username is required":l.username&&!D.test(l.username)&&(W.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!l.email?W.email="Email address is required":l.email&&!Z.test(l.email)&&(W.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!l.phone_number?W.phone_number="Phone number is required":l.phone_number&&!ae.test(l.phone_number)&&(W.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(l.password?te.test(l.password)||(W.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):W.password="Password is required"),v(W),Object.keys(W).length>0){console.log("Signup validation failed. Errors:",W);return}console.log("Signup validation passed"),y(!0);try{const _e={...l};l.phone_number&&$&&(_e.phone_country_code=$),E&&(_e.invite_token=E),console.log("Submitting signup data:",_e),console.log("Phone number:",_e.phone_number),console.log("Phone country code:",_e.phone_country_code),await r.create(_e)}catch(_e){v({submit:_e.message})}finally{y(!1)}},F=async fe=>{if(!(t||x)){y(!0);try{const N=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:D}=await s.create({provider:fe.provider,redirectUri:N});D&&typeof D=="object"&&"oauth_url"in D&&(window.location.href=D.oauth_url)}catch(W){v({submit:W.message})}finally{y(!1)}}},O=(a==null?void 0:a.social_connections.filter(fe=>fe.enabled))||[],A=a==null?void 0:a.auth_settings,J=!!((le=A==null?void 0:A.first_name)!=null&&le.enabled&&((oe=A==null?void 0:A.last_name)!=null&&oe.enabled)),re=async fe=>{var N;if(fe.preventDefault(),t||x)return;y(!0);const W={};if(!C){W.otp="OTP code is required",v(W),y(!1);return}v(W);try{const D=await r.completeVerification(C);"data"in D&&((N=D.data)!=null&&N.active_signin)&&await c()}catch(D){console.error("Verification failed:",D)}finally{y(!1)}};return i.useEffect(()=>{var fe;if(o){if(o.completed){let W=new URLSearchParams(window.location.search).get("redirect_uri");if(W||(W=((fe=a==null?void 0:a.ui_settings)==null?void 0:fe.after_signup_redirect_url)||null),!W&&(a!=null&&a.frontend_host)&&(W=`https://${a.frontend_host}`),W){let N;try{N=new URL(W)}catch{N=new URL(W,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&N.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(N.toString())}return}if(!M){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[o,r,M,a,g,p]),h?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(ga,{children:e.jsx(kt,{size:32})})]})}):b?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(ga,{children:e.jsx(kt,{size:32})})]})}):z?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(Cn,{children:e.jsx(Sn,{children:"Sign up Restricted!"})}),e.jsx(pf,{children:e.jsx(hf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(ff,{children:e.jsxs(gf,{children:["Need assistance?"," ",e.jsx(mf,{href:(de=a==null?void 0:a.ui_settings)!=null&&de.sign_in_page_url?`${a.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(ge,{children:e.jsx(oo,{children:M?e.jsxs(e.Fragment,{children:[e.jsxs(Cn,{children:[e.jsxs(Sn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ma,{children:(o==null?void 0:o.current_step)==="verify_email"?`${l.email} to continue to ${(K=a==null?void 0:a.ui_settings)==null?void 0:K.app_name}`:`${l.phone_number} to continue to ${(se=a==null?void 0:a.ui_settings)==null?void 0:se.app_name}`})]}),e.jsxs(xa,{style:{gap:"15px"},onSubmit:re,noValidate:!0,children:[e.jsx(Tt,{onComplete:async fe=>{P(fe)},onResend:async()=>{const fe=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:fe})},error:m.otp,isSubmitting:x}),e.jsx(va,{type:"submit",disabled:x||t||!C,children:x?"Verifying...":`Continue to ${(xe=a==null?void 0:a.ui_settings)==null?void 0:xe.app_name}`})]}),e.jsxs(ba,{children:["Having trouble?"," ",e.jsx(zn,{children:e.jsx(ot,{to:a.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(zn,{onClick:()=>{B()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(Cn,{children:[e.jsx(Sn,{children:"Create your account"}),e.jsx(ma,{children:k!=null&&k.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),O.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Es,{connections:O,callback:F}),e.jsx(cf,{children:e.jsx(lf,{children:"or"})})]}),e.jsxs(xa,{onSubmit:L,noValidate:!0,children:[(((ue=A==null?void 0:A.first_name)==null?void 0:ue.enabled)||((U=A==null?void 0:A.last_name)==null?void 0:U.enabled))&&e.jsxs(df,{$isBothEnabled:J,children:[((pe=A==null?void 0:A.first_name)==null?void 0:pe.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"first_name",children:["First name",((Q=A==null?void 0:A.first_name)==null?void 0:Q.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(ce,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:T,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(At,{children:m.first_name})]}),((Y=A==null?void 0:A.last_name)==null?void 0:Y.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"last_name",children:["Last name",((ne=A==null?void 0:A.last_name)==null?void 0:ne.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(ce,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:T,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(At,{children:m.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(pr,{children:"*"})]}),e.jsx(ce,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:T,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(At,{children:m.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(pr,{children:"*"})]}),e.jsx(ce,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:T,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(k==null?void 0:k.valid)&&!!(k!=null&&k.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(At,{children:m.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(pr,{children:"*"})]}),e.jsx(qr,{value:l.phone_number,onChange:T,error:m.phone_number,countryCode:$,setCountryCode:S}),m.phone_number&&e.jsx(At,{children:m.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(pr,{children:"*"})]}),e.jsx(uf,{children:e.jsx(ce,{type:"password",id:"password",name:"password",value:l.password,onChange:T,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(At,{children:m.password})]}),m.submit&&e.jsx(At,{children:m.submit}),e.jsx(va,{type:"submit",disabled:x||t,children:x?"Creating account...":"Continue"})]}),e.jsxs(ba,{children:["Already have an account?"," ",e.jsx(zn,{children:e.jsx(ot,{to:`${(me=a.ui_settings)==null?void 0:me.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const ll=i.createContext(void 0),dl=()=>{const t=i.useContext(ll);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},vf=d.div`
924
+ `;function gf(){var V,q,H,ee,le,oe,de,K,se,xe,ue,U,pe,Q,Y,ne,me;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=vc(),{signIn:s}=Br("oauth"),{deployment:a}=ve(),{navigate:p}=Ge(),{session:g,refetch:c,loading:h}=Ue(),[l,u]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=i.useState({}),[v,y]=i.useState(!1),[z,S]=i.useState(void 0),[_,E]=i.useState(null),[I,w]=i.useState(null),[b,f]=i.useState(!1),$=((V=a==null?void 0:a.restrictions)==null?void 0:V.sign_up_mode)==="restricted",k=((q=a==null?void 0:a.restrictions)==null?void 0:q.sign_up_mode)==="waitlist",j=((ee=(H=a==null?void 0:a.auth_settings)==null?void 0:H.multi_session_support)==null?void 0:ee.enabled)??!1;i.useEffect(()=>{var fe;if(!h&&(g!=null&&g.active_signin)&&!j&&!b){f(!0);let W=new URLSearchParams(window.location.search).get("redirect_uri");W||(W=((fe=a==null?void 0:a.ui_settings)==null?void 0:fe.after_signin_redirect_url)||null),!W&&(a!=null&&a.frontend_host)&&(W=`https://${a.frontend_host}`),!W&&(a!=null&&a.frontend_host)&&(W=`https://${a.frontend_host}`),W&&p(W)}},[g,h,j,a,p,b]),i.useEffect(()=>{var N;if(!a)return;const W=new URLSearchParams(window.location.search).get("invite_token");if(k&&!W){f(!0);const D=((N=a.ui_settings)==null?void 0:N.waitlist_page_url)||`https://${a.frontend_host}/waitlist`;p(D);return}W&&!_&&r&&(w(W),r.validateDeploymentInvitation(W).then(D=>{E(D),D.valid&&u(Z=>({...Z,first_name:D.first_name||Z.first_name,last_name:D.last_name||Z.last_name,email:D.email||Z.email}))}).catch(D=>{console.error("Failed to validate invitation:",D)}))},[a,k,p,_,r]);const[M,R]=i.useState(!1),[C,P]=i.useState(""),T=fe=>{let{name:W,value:N}=fe.target;W==="phone_number"?N=N.replace(/[^0-9-]/g,""):W==="email"&&(N=N.toLowerCase()),u(D=>({...D,[W]:N})),x(D=>({...D,[W]:""}))},B=()=>{u({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),R(!1),P(""),n()},L=async fe=>{if(fe.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",l),t||v)return;const W={},N=/^[a-zA-Z]{3,30}$/,D=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,Z=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,ae=/^\d{7,15}$/,te=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!l.first_name?W.first_name="First name is required":l.first_name&&!N.test(l.first_name)&&(W.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!l.last_name?W.last_name="Last name is required":l.last_name&&!N.test(l.last_name)&&(W.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!l.username?W.username="Username is required":l.username&&!D.test(l.username)&&(W.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!l.email?W.email="Email address is required":l.email&&!Z.test(l.email)&&(W.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!l.phone_number?W.phone_number="Phone number is required":l.phone_number&&!ae.test(l.phone_number)&&(W.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(l.password?te.test(l.password)||(W.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):W.password="Password is required"),x(W),Object.keys(W).length>0){console.log("Signup validation failed. Errors:",W);return}console.log("Signup validation passed"),y(!0);try{const _e={...l};l.phone_number&&z&&(_e.phone_country_code=z),I&&(_e.invite_token=I),console.log("Submitting signup data:",_e),console.log("Phone number:",_e.phone_number),console.log("Phone country code:",_e.phone_country_code),await r.create(_e)}catch(_e){x({submit:_e.message})}finally{y(!1)}},F=async fe=>{if(!(t||v)){y(!0);try{const N=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:D}=await s.create({provider:fe.provider,redirectUri:N});D&&typeof D=="object"&&"oauth_url"in D&&(window.location.href=D.oauth_url)}catch(W){x({submit:W.message})}finally{y(!1)}}},O=(a==null?void 0:a.social_connections.filter(fe=>fe.enabled))||[],A=a==null?void 0:a.auth_settings,J=!!((le=A==null?void 0:A.first_name)!=null&&le.enabled&&((oe=A==null?void 0:A.last_name)!=null&&oe.enabled)),re=async fe=>{var N;if(fe.preventDefault(),t||v)return;y(!0);const W={};if(!C){W.otp="OTP code is required",x(W),y(!1);return}x(W);try{const D=await r.completeVerification(C);"data"in D&&((N=D.data)!=null&&N.active_signin)&&await c()}catch(D){console.error("Verification failed:",D)}finally{y(!1)}};return i.useEffect(()=>{var fe;if(o){if(o.completed){let W=new URLSearchParams(window.location.search).get("redirect_uri");if(W||(W=((fe=a==null?void 0:a.ui_settings)==null?void 0:fe.after_signup_redirect_url)||null),!W&&(a!=null&&a.frontend_host)&&(W=`https://${a.frontend_host}`),W){let N;try{N=new URL(W)}catch{N=new URL(W,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&N.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(N.toString())}return}if(!M){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[o,r,M,a,g,p]),h?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(ga,{children:e.jsx(kt,{size:32})})]})}):b?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(ga,{children:e.jsx(kt,{size:32})})]})}):$?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(Cn,{children:e.jsx(Sn,{children:"Sign up Restricted!"})}),e.jsx(df,{children:e.jsx(uf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(pf,{children:e.jsxs(hf,{children:["Need assistance?"," ",e.jsx(ff,{href:(de=a==null?void 0:a.ui_settings)!=null&&de.sign_in_page_url?`${a.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(ge,{children:e.jsx(oo,{children:M?e.jsxs(e.Fragment,{children:[e.jsxs(Cn,{children:[e.jsxs(Sn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ma,{children:(o==null?void 0:o.current_step)==="verify_email"?`${l.email} to continue to ${(K=a==null?void 0:a.ui_settings)==null?void 0:K.app_name}`:`${l.phone_number} to continue to ${(se=a==null?void 0:a.ui_settings)==null?void 0:se.app_name}`})]}),e.jsxs(xa,{style:{gap:"15px"},onSubmit:re,noValidate:!0,children:[e.jsx(Tt,{onComplete:async fe=>{P(fe)},onResend:async()=>{const fe=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:fe})},error:m.otp,isSubmitting:v}),e.jsx(va,{type:"submit",disabled:v||t||!C,children:v?"Verifying...":`Continue to ${(xe=a==null?void 0:a.ui_settings)==null?void 0:xe.app_name}`})]}),e.jsxs(ba,{children:["Having trouble?"," ",e.jsx(zn,{children:e.jsx(ot,{to:a.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(zn,{onClick:()=>{B()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(Cn,{children:[e.jsx(Sn,{children:"Create your account"}),e.jsx(ma,{children:_!=null&&_.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),O.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Es,{connections:O,callback:F}),e.jsx(sf,{children:e.jsx(af,{children:"or"})})]}),e.jsxs(xa,{onSubmit:L,noValidate:!0,children:[(((ue=A==null?void 0:A.first_name)==null?void 0:ue.enabled)||((U=A==null?void 0:A.last_name)==null?void 0:U.enabled))&&e.jsxs(cf,{$isBothEnabled:J,children:[((pe=A==null?void 0:A.first_name)==null?void 0:pe.enabled)&&e.jsxs(lr,{children:[e.jsxs(dr,{htmlFor:"first_name",children:["First name",((Q=A==null?void 0:A.first_name)==null?void 0:Q.required)&&e.jsx(ur,{children:"*"})]}),e.jsx(ce,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:T,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(At,{children:m.first_name})]}),((Y=A==null?void 0:A.last_name)==null?void 0:Y.enabled)&&e.jsxs(lr,{children:[e.jsxs(dr,{htmlFor:"last_name",children:["Last name",((ne=A==null?void 0:A.last_name)==null?void 0:ne.required)&&e.jsx(ur,{children:"*"})]}),e.jsx(ce,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:T,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(At,{children:m.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(lr,{children:[e.jsxs(dr,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(ur,{children:"*"})]}),e.jsx(ce,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:T,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(At,{children:m.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(lr,{children:[e.jsxs(dr,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(ur,{children:"*"})]}),e.jsx(ce,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:T,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(_==null?void 0:_.valid)&&!!(_!=null&&_.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(At,{children:m.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(lr,{children:[e.jsxs(dr,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(ur,{children:"*"})]}),e.jsx(qr,{value:l.phone_number,onChange:T,error:m.phone_number,countryCode:z,setCountryCode:S}),m.phone_number&&e.jsx(At,{children:m.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(lr,{children:[e.jsxs(dr,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(ur,{children:"*"})]}),e.jsx(lf,{children:e.jsx(ce,{type:"password",id:"password",name:"password",value:l.password,onChange:T,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(At,{children:m.password})]}),m.submit&&e.jsx(At,{children:m.submit}),e.jsx(va,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(ba,{children:["Already have an account?"," ",e.jsx(zn,{children:e.jsx(ot,{to:`${(me=a.ui_settings)==null?void 0:me.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const ll=i.createContext(void 0),dl=()=>{const t=i.useContext(ll);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},mf=d.div`
925
925
  position: fixed;
926
926
  inset: 0;
927
927
  background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
@@ -929,7 +929,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
929
929
  justify-content: center;
930
930
  align-items: center;
931
931
  z-index: 99999;
932
- `,bf=d.div`
932
+ `,xf=d.div`
933
933
  background-color: var(--color-background);
934
934
  border-radius: 8px;
935
935
  box-shadow: 0 10px 25px -5px var(--color-shadow);
@@ -938,17 +938,17 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
938
938
  overflow-y: auto;
939
939
  position: relative;
940
940
  z-index: 100000;
941
- `,yf=d.div`
941
+ `,vf=d.div`
942
942
  display: flex;
943
943
  align-items: center;
944
944
  justify-content: space-between;
945
945
  padding: var(--space-sm, 12px) var(--space-md, 16px);
946
946
  border-bottom: 1px solid var(--color-border);
947
- `,wf=d.h2`
947
+ `,bf=d.h2`
948
948
  font-size: 16px;
949
949
  color: var(--color-foreground);
950
950
  margin: 0;
951
- `,jf=d.button`
951
+ `,yf=d.button`
952
952
  background: transparent;
953
953
  border: none;
954
954
  cursor: pointer;
@@ -963,15 +963,15 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
963
963
  background-color: var(--color-background-hover);
964
964
  color: var(--color-foreground);
965
965
  }
966
- `,_f=d.div`
966
+ `,wf=d.div`
967
967
  padding: 16px;
968
- `,kf=d.div`
968
+ `,jf=d.div`
969
969
  display: flex;
970
970
  justify-content: flex-end;
971
971
  gap: 8px;
972
972
  padding: 16px;
973
973
  border-top: 1px solid var(--color-border);
974
- `,Cf=({isOpen:t,onClose:r,children:o})=>{const[n,s]=i.useState(!1);return i.useEffect(()=>{s(!0);const a=p=>{p.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[t,r]),!t||!n?null:Wr.createPortal(e.jsx(ge,{children:e.jsx(ll.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},Sf=({children:t})=>{const{onClose:r}=dl(),o=i.useRef(null),n=s=>{o.current&&!o.current.contains(s.target)&&(r==null||r())};return e.jsx(vf,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},zf=({children:t,style:r})=>e.jsx(bf,{style:r,children:t}),$f=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=dl();return e.jsxs(yf,{children:[typeof t=="string"?e.jsx(wf,{children:t}):t,r&&e.jsx(jf,{onClick:o,children:e.jsx(et,{size:18})})]})},Ef=({children:t,style:r})=>e.jsx(_f,{style:r,children:t}),If=({children:t})=>e.jsx(kf,{children:t}),ke=Object.assign(Cf,{Overlay:Sf,Content:zf,Header:$f,Body:Ef,Footer:If}),Pf=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:s=!0})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{children:[o&&e.jsx(ke.Header,{showCloseButton:s,children:o}),e.jsx(ke.Body,{children:n})]})})}),Rf=({trigger:t,renderDialog:r})=>{const[o,n]=i.useState(!1),s=()=>n(!0),a=()=>n(!1);return e.jsxs(e.Fragment,{children:[t({onClick:s}),r({isOpen:o,onClose:a})]})},Tf=d.div`
974
+ `,_f=({isOpen:t,onClose:r,children:o})=>{const[n,s]=i.useState(!1);return i.useEffect(()=>{s(!0);const a=p=>{p.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[t,r]),!t||!n?null:Wr.createPortal(e.jsx(ge,{children:e.jsx(ll.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},kf=({children:t})=>{const{onClose:r}=dl(),o=i.useRef(null),n=s=>{o.current&&!o.current.contains(s.target)&&(r==null||r())};return e.jsx(mf,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},Cf=({children:t,style:r})=>e.jsx(xf,{style:r,children:t}),Sf=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=dl();return e.jsxs(vf,{children:[typeof t=="string"?e.jsx(bf,{children:t}):t,r&&e.jsx(yf,{onClick:o,children:e.jsx(et,{size:18})})]})},zf=({children:t,style:r})=>e.jsx(wf,{style:r,children:t}),$f=({children:t})=>e.jsx(jf,{children:t}),ke=Object.assign(_f,{Overlay:kf,Content:Cf,Header:Sf,Body:zf,Footer:$f}),Ef=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:s=!0})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{children:[o&&e.jsx(ke.Header,{showCloseButton:s,children:o}),e.jsx(ke.Body,{children:n})]})})}),If=({trigger:t,renderDialog:r})=>{const[o,n]=i.useState(!1),s=()=>n(!0),a=()=>n(!1);return e.jsxs(e.Fragment,{children:[t({onClick:s}),r({isOpen:o,onClose:a})]})},Pf=d.div`
975
975
  position: fixed;
976
976
  background: var(--color-background);
977
977
  border-radius: 8px;
@@ -981,9 +981,9 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
981
981
  z-index: 1000;
982
982
  min-width: 140px;
983
983
  display: grid;
984
- `,Mf=d.div`
984
+ `,Rf=d.div`
985
985
  width: fit-content;
986
- `,ul=i.createContext(void 0),pl=()=>{const t=i.useContext(ul);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},nt=({children:t,open:r,openChange:o,style:n})=>{const s=i.useRef(null),[a,p]=i.useState(!1);return i.useEffect(()=>{const g=c=>{s.current&&!s.current.contains(c.target)&&p(!1)};return a&&document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[a,o]),i.useEffect(()=>{o==null||o(a)},[a]),i.useEffect(()=>{p(!!r)},[r]),e.jsx(ul.Provider,{value:{open:a,openChange:g=>p(g)},children:e.jsx(Mf,{style:n,ref:s,children:t})})},st=({children:t,style:r})=>{const{open:o}=pl(),[n,s]=i.useState({top:0,left:0}),[a,p]=i.useState(!1),g=i.useRef(null);return i.useEffect(()=>{o&&g.current?(p(!1),requestAnimationFrame(()=>{var l,u;const c=(l=g.current)==null?void 0:l.parentElement;if(!c)return;const h=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(h&&h!==g.current){const m=h.getBoundingClientRect(),v=(u=g.current)==null?void 0:u.getBoundingClientRect(),x=window.innerWidth,y=window.innerHeight;let $=m.bottom+4,S=m.right-200;S<8&&(S=m.left),S+200>x-8&&(S=x-208),v&&$+v.height>y-8&&($=m.top-(v.height+4)),s({top:$,left:S}),p(!0)}})):p(!1)},[o]),o?e.jsx(Tf,{ref:g,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:a?"visible":"hidden",opacity:a?1:0,transition:a?"opacity 0.15s ease-in-out":"none"},children:t}):null},at=({children:t})=>{const{openChange:r,open:o}=pl(),n=i.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Te=d.button`
986
+ `,ul=i.createContext(void 0),pl=()=>{const t=i.useContext(ul);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},nt=({children:t,open:r,openChange:o,style:n})=>{const s=i.useRef(null),[a,p]=i.useState(!1);return i.useEffect(()=>{const g=c=>{s.current&&!s.current.contains(c.target)&&p(!1)};return a&&document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[a,o]),i.useEffect(()=>{o==null||o(a)},[a]),i.useEffect(()=>{p(!!r)},[r]),e.jsx(ul.Provider,{value:{open:a,openChange:g=>p(g)},children:e.jsx(Rf,{style:n,ref:s,children:t})})},st=({children:t,style:r})=>{const{open:o}=pl(),[n,s]=i.useState({top:0,left:0}),[a,p]=i.useState(!1),g=i.useRef(null);return i.useEffect(()=>{o&&g.current?(p(!1),requestAnimationFrame(()=>{var l,u;const c=(l=g.current)==null?void 0:l.parentElement;if(!c)return;const h=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(h&&h!==g.current){const m=h.getBoundingClientRect(),x=(u=g.current)==null?void 0:u.getBoundingClientRect(),v=window.innerWidth,y=window.innerHeight;let z=m.bottom+4,S=m.right-200;S<8&&(S=m.left),S+200>v-8&&(S=v-208),x&&z+x.height>y-8&&(z=m.top-(x.height+4)),s({top:z,left:S}),p(!0)}})):p(!1)},[o]),o?e.jsx(Pf,{ref:g,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:a?"visible":"hidden",opacity:a?1:0,transition:a?"opacity 0.15s ease-in-out":"none"},children:t}):null},at=({children:t})=>{const{openChange:r,open:o}=pl(),n=i.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Te=d.button`
987
987
  width: 100%;
988
988
  padding: 8px 12px;
989
989
  background: none;
@@ -1014,37 +1014,37 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1014
1014
  text-align: left;
1015
1015
  font-weight: 400;
1016
1016
  color: var(--color-foreground);
1017
- `,Of=ar`
1017
+ `,Tf=sr`
1018
1018
  0% {
1019
1019
  transform: rotate(0deg);
1020
1020
  }
1021
1021
  100% {
1022
1022
  transform: rotate(360deg);
1023
1023
  }
1024
- `,Af=d.div`
1024
+ `,Mf=d.div`
1025
1025
  display: flex;
1026
1026
  justify-content: center;
1027
1027
  align-items: center;
1028
1028
  width: 100%;
1029
1029
  height: ${t=>t.$size?`${t.$size}px`:"100%"};
1030
- `,Lf=d.div`
1030
+ `,Of=d.div`
1031
1031
  width: ${t=>t.$size?`${t.$size}px`:"40px"};
1032
1032
  height: ${t=>t.$size?`${t.$size}px`:"40px"};
1033
1033
  border: 3px solid var(--color-border);
1034
1034
  border-top: 3px solid var(--color-primary);
1035
1035
  border-radius: 50%;
1036
- animation: ${Of} 1s linear infinite;
1037
- `,Ee=({size:t,className:r})=>e.jsx(Af,{className:r,$size:t,children:e.jsx(Lf,{$size:t})}),Df=d.label`
1036
+ animation: ${Tf} 1s linear infinite;
1037
+ `,Ee=({size:t,className:r})=>e.jsx(Mf,{className:r,$size:t,children:e.jsx(Of,{$size:t})}),Af=d.label`
1038
1038
  display: inline-flex;
1039
1039
  align-items: center;
1040
1040
  cursor: pointer;
1041
1041
  position: relative;
1042
- `,Nf=d.input`
1042
+ `,Lf=d.input`
1043
1043
  opacity: 0;
1044
1044
  width: 0;
1045
1045
  height: 0;
1046
1046
  position: absolute;
1047
- `,Ff=d.span`
1047
+ `,Df=d.span`
1048
1048
  position: relative;
1049
1049
  width: 40px;
1050
1050
  height: 24px;
@@ -1065,7 +1065,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1065
1065
  left: ${t=>t.checked?"20px":"2px"};
1066
1066
  transition: left 0.2s ease;
1067
1067
  }
1068
- `,Cr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(Df,{children:[e.jsx(Nf,{type:"checkbox",checked:t,onChange:o}),e.jsx(Ff,{checked:t})]})},Dr=(t=!1)=>{const[r,o]=i.useState(t),n=i.useCallback(()=>{o(!0)},[]),s=i.useCallback(()=>{o(!1)},[]),a=i.useCallback(()=>{o(p=>!p)},[]);return{isOpen:r,open:n,close:s,toggle:a}},St=({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(_h,{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"}})]}),X=d.button`
1068
+ `,Cr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(Af,{children:[e.jsx(Lf,{type:"checkbox",checked:t,onChange:o}),e.jsx(Df,{checked:t})]})},Dr=(t=!1)=>{const[r,o]=i.useState(t),n=i.useCallback(()=>{o(!0)},[]),s=i.useCallback(()=>{o(!1)},[]),a=i.useCallback(()=>{o(p=>!p)},[]);return{isOpen:r,open:n,close:s,toggle:a}},St=({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(wh,{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"}})]}),X=d.button`
1069
1069
  width: 100%;
1070
1070
  padding: var(--space-sm) var(--space-md);
1071
1071
  border: 1px solid transparent;
@@ -1095,7 +1095,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1095
1095
  cursor: not-allowed;
1096
1096
  }
1097
1097
 
1098
- ${t=>t.$outline&&Xt`
1098
+ ${t=>t.$outline&&Qt`
1099
1099
  background-color: var(--color-input-background);
1100
1100
  color: var(--color-foreground);
1101
1101
  border: 1px solid var(--color-border);
@@ -1105,7 +1105,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1105
1105
  }
1106
1106
  `}
1107
1107
 
1108
- ${t=>t.$destructive&&Xt`
1108
+ ${t=>t.$destructive&&Qt`
1109
1109
  background-color: var(--color-error-background);
1110
1110
  color: var(--color-error);
1111
1111
  border-color: var(--color-error-border);
@@ -1207,7 +1207,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1207
1207
  text-transform: uppercase;
1208
1208
  color: var(--color-muted);
1209
1209
  background: var(--color-background-hover);
1210
- `,Is=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:s=!1,searchable:a=!1,width:p,name:g,id:c,groupsEnabled:h=!1,className:l})=>{const[u,m]=i.useState(!1),[v,x]=i.useState(""),y=i.useRef(null),$=i.useRef(null),S=h&&"options"in t[0],I=(S?t.flatMap(f=>f.options):t).find(f=>f.value===r),E=v?S?t.map(f=>({...f,options:f.options.filter(z=>z.label.toLowerCase().includes(v.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(v.toLowerCase())):t,w=(f,z=!1)=>{z||(o(f),m(!1),x(""))},b=()=>{s||m(!u)};return i.useEffect(()=>{u&&a&&$.current&&setTimeout(()=>{var f;(f=$.current)==null||f.focus()},10)},[u,a]),i.useEffect(()=>{const f=z=>{y.current&&!y.current.contains(z.target)&&(m(!1),x(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs(hl,{ref:y,style:{width:p},className:l,children:[e.jsxs(fl,{type:"button",onClick:b,disabled:s,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[I?I.label:e.jsx(xl,{children:n}),u?e.jsx(tl,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(gl,{isOpen:u,role:"listbox",children:[a&&e.jsx(ml,{ref:$,type:"text",placeholder:"Search...",value:v,onChange:f=>x(f.target.value),onClick:f=>f.stopPropagation()}),S?E.map((f,z)=>e.jsxs(i.Fragment,{children:[e.jsx(vl,{children:f.label}),f.options.length===0?e.jsx(Vo,{children:"No options available"}):f.options.map(_=>e.jsxs(Wo,{isSelected:_.value===r,disabled:_.disabled,onClick:()=>w(_.value,_.disabled),role:"option","aria-selected":_.value===r,children:[_.label,_.value===r&&e.jsx(Ve,{size:16})]},_.value))]},`group-${z}`)):e.jsx(e.Fragment,{children:E.length===0?e.jsx(Vo,{children:"No options available"}):E.map(f=>e.jsxs(Wo,{isSelected:f.value===r,disabled:f.disabled,onClick:()=>w(f.value,f.disabled),role:"option","aria-selected":f.value===r,children:[f.label,f.value===r&&e.jsx(Ve,{size:16})]},f.value))})]}),g&&e.jsx("input",{type:"hidden",name:g,value:r||""})]})},bl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:s=!1,searchable:a=!1,width:p,name:g,id:c,groupsEnabled:h=!1,className:l})=>{const[u,m]=i.useState(!1),[v,x]=i.useState(""),y=i.useRef(null),$=i.useRef(null),S=h&&"options"in t[0],I=(S?t.flatMap(f=>f.options):t).filter(f=>r.includes(f.value)),E=v?S?t.map(f=>({...f,options:f.options.filter(z=>z.label.toLowerCase().includes(v.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(v.toLowerCase())):t,w=(f,z=!1)=>{z||(r.includes(f)?o(r.filter(_=>_!==f)):o([...r,f]))},b=()=>{s||m(!u)};return i.useEffect(()=>{u&&a&&$.current&&setTimeout(()=>{var f;(f=$.current)==null||f.focus()},10)},[u,a]),i.useEffect(()=>{const f=z=>{y.current&&!y.current.contains(z.target)&&(m(!1),x(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs(hl,{ref:y,style:{width:p},className:l,children:[e.jsxs(fl,{type:"button",onClick:b,disabled:s,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[I.length>0?I.map(f=>f.label).join(", "):e.jsx(xl,{children:n}),u?e.jsx(tl,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(gl,{isOpen:u,role:"listbox",children:[a&&e.jsx(ml,{ref:$,type:"text",placeholder:"Search...",value:v,onChange:f=>x(f.target.value),onClick:f=>f.stopPropagation()}),S?E.map((f,z)=>e.jsxs(i.Fragment,{children:[e.jsx(vl,{children:f.label}),f.options.length===0?e.jsx(Vo,{children:"No options available"}):f.options.map(_=>e.jsxs(Wo,{isSelected:r.includes(_.value),disabled:_.disabled,onClick:()=>w(_.value,_.disabled),role:"option","aria-selected":r.includes(_.value),children:[_.label,r.includes(_.value)&&e.jsx(Ve,{size:16})]},_.value))]},`group-${z}`)):e.jsx(e.Fragment,{children:E.length===0?e.jsx(Vo,{children:"No options available"}):E.map(f=>e.jsxs(Wo,{isSelected:r.includes(f.value),disabled:f.disabled,onClick:()=>w(f.value,f.disabled),role:"option","aria-selected":r.includes(f.value),children:[f.label,r.includes(f.value)&&e.jsx(Ve,{size:16})]},f.value))})]}),g&&e.jsx("input",{type:"hidden",name:g,value:r.join(",")})]})},yl=i.createContext(void 0);function wl(){const t=i.useContext(yl);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function Bf({children:t}){const{deployment:r}=ve(),[o,n]=i.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[s,a]=i.useState(""),[p,g]=i.useState(!1),[c,h]=i.useState(!1),[l,u]=i.useState(!1),[m,v]=i.useState("identifier"),x=(r==null?void 0:r.social_connections.filter($=>$.enabled))||[],y=r==null?void 0:r.auth_settings;return e.jsx(yl.Provider,{value:{email:s,showOtherOptions:p,showForgotPassword:c,otpSent:l,setFirstFactor:n,setEmail:a,setShowOtherOptions:g,setShowForgotPassword:h,setOtpSent:u,enabledSocialsProviders:x,authSettings:y,firstFactor:o,signInStep:m,setSignInStep:v},children:t})}const Ir=d.button`
1210
+ `,Is=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:s=!1,searchable:a=!1,width:p,name:g,id:c,groupsEnabled:h=!1,className:l})=>{const[u,m]=i.useState(!1),[x,v]=i.useState(""),y=i.useRef(null),z=i.useRef(null),S=h&&"options"in t[0],E=(S?t.flatMap(f=>f.options):t).find(f=>f.value===r),I=x?S?t.map(f=>({...f,options:f.options.filter($=>$.label.toLowerCase().includes(x.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(x.toLowerCase())):t,w=(f,$=!1)=>{$||(o(f),m(!1),v(""))},b=()=>{s||m(!u)};return i.useEffect(()=>{u&&a&&z.current&&setTimeout(()=>{var f;(f=z.current)==null||f.focus()},10)},[u,a]),i.useEffect(()=>{const f=$=>{y.current&&!y.current.contains($.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs(hl,{ref:y,style:{width:p},className:l,children:[e.jsxs(fl,{type:"button",onClick:b,disabled:s,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[E?E.label:e.jsx(xl,{children:n}),u?e.jsx(tl,{size:16}):e.jsx(rr,{size:16})]}),e.jsxs(gl,{isOpen:u,role:"listbox",children:[a&&e.jsx(ml,{ref:z,type:"text",placeholder:"Search...",value:x,onChange:f=>v(f.target.value),onClick:f=>f.stopPropagation()}),S?I.map((f,$)=>e.jsxs(i.Fragment,{children:[e.jsx(vl,{children:f.label}),f.options.length===0?e.jsx(Vo,{children:"No options available"}):f.options.map(k=>e.jsxs(Wo,{isSelected:k.value===r,disabled:k.disabled,onClick:()=>w(k.value,k.disabled),role:"option","aria-selected":k.value===r,children:[k.label,k.value===r&&e.jsx(Ve,{size:16})]},k.value))]},`group-${$}`)):e.jsx(e.Fragment,{children:I.length===0?e.jsx(Vo,{children:"No options available"}):I.map(f=>e.jsxs(Wo,{isSelected:f.value===r,disabled:f.disabled,onClick:()=>w(f.value,f.disabled),role:"option","aria-selected":f.value===r,children:[f.label,f.value===r&&e.jsx(Ve,{size:16})]},f.value))})]}),g&&e.jsx("input",{type:"hidden",name:g,value:r||""})]})},bl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:s=!1,searchable:a=!1,width:p,name:g,id:c,groupsEnabled:h=!1,className:l})=>{const[u,m]=i.useState(!1),[x,v]=i.useState(""),y=i.useRef(null),z=i.useRef(null),S=h&&"options"in t[0],E=(S?t.flatMap(f=>f.options):t).filter(f=>r.includes(f.value)),I=x?S?t.map(f=>({...f,options:f.options.filter($=>$.label.toLowerCase().includes(x.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(x.toLowerCase())):t,w=(f,$=!1)=>{$||(r.includes(f)?o(r.filter(k=>k!==f)):o([...r,f]))},b=()=>{s||m(!u)};return i.useEffect(()=>{u&&a&&z.current&&setTimeout(()=>{var f;(f=z.current)==null||f.focus()},10)},[u,a]),i.useEffect(()=>{const f=$=>{y.current&&!y.current.contains($.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs(hl,{ref:y,style:{width:p},className:l,children:[e.jsxs(fl,{type:"button",onClick:b,disabled:s,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[E.length>0?E.map(f=>f.label).join(", "):e.jsx(xl,{children:n}),u?e.jsx(tl,{size:16}):e.jsx(rr,{size:16})]}),e.jsxs(gl,{isOpen:u,role:"listbox",children:[a&&e.jsx(ml,{ref:z,type:"text",placeholder:"Search...",value:x,onChange:f=>v(f.target.value),onClick:f=>f.stopPropagation()}),S?I.map((f,$)=>e.jsxs(i.Fragment,{children:[e.jsx(vl,{children:f.label}),f.options.length===0?e.jsx(Vo,{children:"No options available"}):f.options.map(k=>e.jsxs(Wo,{isSelected:r.includes(k.value),disabled:k.disabled,onClick:()=>w(k.value,k.disabled),role:"option","aria-selected":r.includes(k.value),children:[k.label,r.includes(k.value)&&e.jsx(Ve,{size:16})]},k.value))]},`group-${$}`)):e.jsx(e.Fragment,{children:I.length===0?e.jsx(Vo,{children:"No options available"}):I.map(f=>e.jsxs(Wo,{isSelected:r.includes(f.value),disabled:f.disabled,onClick:()=>w(f.value,f.disabled),role:"option","aria-selected":r.includes(f.value),children:[f.label,r.includes(f.value)&&e.jsx(Ve,{size:16})]},f.value))})]}),g&&e.jsx("input",{type:"hidden",name:g,value:r.join(",")})]})},yl=i.createContext(void 0);function wl(){const t=i.useContext(yl);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function Nf({children:t}){const{deployment:r}=ve(),[o,n]=i.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[s,a]=i.useState(""),[p,g]=i.useState(!1),[c,h]=i.useState(!1),[l,u]=i.useState(!1),[m,x]=i.useState("identifier"),v=(r==null?void 0:r.social_connections.filter(z=>z.enabled))||[],y=r==null?void 0:r.auth_settings;return e.jsx(yl.Provider,{value:{email:s,showOtherOptions:p,showForgotPassword:c,otpSent:l,setFirstFactor:n,setEmail:a,setShowOtherOptions:g,setShowForgotPassword:h,setOtpSent:u,enabledSocialsProviders:v,authSettings:y,firstFactor:o,signInStep:m,setSignInStep:x},children:t})}const Ir=d.button`
1211
1211
  width: 100%;
1212
1212
  padding: var(--space-sm) var(--space-md);
1213
1213
  background: var(--color-input-background);
@@ -1230,7 +1230,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1230
1230
  opacity: 0.7;
1231
1231
  cursor: not-allowed;
1232
1232
  }
1233
- `;function jl(){const{deployment:t}=ve(),{signIn:r}=Br("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:s,setShowForgotPassword:a}=wl(),[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))||[],l=async m=>{if(!p){g(!0);try{const{data:v}=await r.create({provider:m.provider});v&&typeof v=="object"&&"oauth_url"in v&&(window.location.href=v.oauth_url)}catch{}finally{g(!1)}}},u=()=>{a(!1),s(!1)};return e.jsxs(e.Fragment,{children:[h.length>0&&e.jsx(Es,{connections:h,callback:l}),e.jsxs("div",{children:[n!=="email_magic_link"&&(c==null?void 0:c.auth_factors_enabled.email_magic_link)&&e.jsx(Ir,{onClick:()=>{o("email_magic_link"),u()},children:"Get a magic link on your email"}),n!=="email_password"&&(c==null?void 0:c.auth_factors_enabled.email_password)&&e.jsx(Ir,{onClick:()=>{o("email_password"),u()},children:"Sign in with email and password"}),n!=="email_otp"&&(c==null?void 0:c.auth_factors_enabled.email_otp)&&e.jsx(Ir,{onClick:()=>{o("email_otp"),u()},children:"Sign in with email and OTP"}),n!=="phone_otp"&&(c==null?void 0:c.auth_factors_enabled.phone_otp)&&e.jsx(Ir,{onClick:()=>{o("phone_otp"),u()},children:"Sign in with phone number"}),n!=="username_password"&&(c==null?void 0:c.auth_factors_enabled.username_password)&&e.jsx(Ir,{onClick:()=>{o("username_password"),u()},children:"Sign in with username and password"})]})]})}const Uf=d.div`
1233
+ `;function jl(){const{deployment:t}=ve(),{signIn:r}=Br("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:s,setShowForgotPassword:a}=wl(),[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))||[],l=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)}}},u=()=>{a(!1),s(!1)};return e.jsxs(e.Fragment,{children:[h.length>0&&e.jsx(Es,{connections:h,callback:l}),e.jsxs("div",{children:[n!=="email_magic_link"&&(c==null?void 0:c.auth_factors_enabled.email_magic_link)&&e.jsx(Ir,{onClick:()=>{o("email_magic_link"),u()},children:"Get a magic link on your email"}),n!=="email_password"&&(c==null?void 0:c.auth_factors_enabled.email_password)&&e.jsx(Ir,{onClick:()=>{o("email_password"),u()},children:"Sign in with email and password"}),n!=="email_otp"&&(c==null?void 0:c.auth_factors_enabled.email_otp)&&e.jsx(Ir,{onClick:()=>{o("email_otp"),u()},children:"Sign in with email and OTP"}),n!=="phone_otp"&&(c==null?void 0:c.auth_factors_enabled.phone_otp)&&e.jsx(Ir,{onClick:()=>{o("phone_otp"),u()},children:"Sign in with phone number"}),n!=="username_password"&&(c==null?void 0:c.auth_factors_enabled.username_password)&&e.jsx(Ir,{onClick:()=>{o("username_password"),u()},children:"Sign in with username and password"})]})]})}const Ff=d.div`
1234
1234
  max-width: 380px;
1235
1235
  width: 380px;
1236
1236
  padding: var(--space-3xl);
@@ -1253,10 +1253,10 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1253
1253
  color: var(--color-error);
1254
1254
  margin: 0;
1255
1255
  margin-top: var(--space-2xs);
1256
- `,Wf=d(X)`
1256
+ `,Bf=d(X)`
1257
1257
  width: 100%;
1258
1258
  margin-bottom: var(--space-lg);
1259
- `,Vf=d.div`
1259
+ `,Uf=d.div`
1260
1260
  display: flex;
1261
1261
  align-items: center;
1262
1262
  text-align: center;
@@ -1278,7 +1278,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1278
1278
  &::after {
1279
1279
  margin-left: var(--space-sm);
1280
1280
  }
1281
- `,Gf=d.span`
1281
+ `,Wf=d.span`
1282
1282
  white-space: nowrap;
1283
1283
  `,ao=d.div`
1284
1284
  text-align: center;
@@ -1294,28 +1294,28 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1294
1294
  &:hover {
1295
1295
  text-decoration: underline;
1296
1296
  }
1297
- `;function Hf({onBack:t}){const{deployment:r}=ve(),{navigate:o}=Ge(),[n,s]=i.useState("start"),[a,p]=i.useState(""),[g,c]=i.useState(""),[h,l]=i.useState(""),[u,m]=i.useState(""),[v,x]=i.useState(""),{forgotPassword:y,verifyOtp:$,resetPassword:S}=kc(),[k,I]=i.useState(!1),[E,w]=i.useState(null),b=async j=>{if(j.preventDefault(),!!a){I(!0),w(null);try{await y(a),s("otp")}catch(M){w(M)}finally{I(!1)}}},f=async j=>{if(j.preventDefault(),g.length===6){I(!0),w(null);try{const M=await $(a,g);M.data&&(l(M.data.token),s("reset"))}catch(M){w(M)}finally{I(!1)}}},z=async j=>{var M,R;if(j.preventDefault(),u===v&&!(u.length<8)){I(!0),w(null);try{const C=await S(h,u);if(C.data){const P=C.data,T=P.signin_attempts&&P.signin_attempts.length>0?P.signin_attempts[P.signin_attempts.length-1]:null;if(T&&!T.completed){const B=(M=r==null?void 0:r.ui_settings)==null?void 0:M.sign_in_page_url;if(B){const L=new URL(B,window.location.origin);L.searchParams.set("signin_attempt_id",T.id),o(L.toString())}else t()}else{const B=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";o(B)}}}catch(C){w(C)}finally{I(!1)}}},_=()=>e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsx(no,{children:e.jsx(so,{children:"Forgot Password"})}),e.jsx(Wf,{onClick:()=>s("email"),disabled:k,children:"Reset your password"}),e.jsx(Vf,{children:e.jsx(Gf,{children:"Or, sign in with another method"})}),e.jsx(jl,{}),e.jsxs(ao,{children:[e.jsxs(Pr,{children:["Unable to reset password? ",e.jsx(Rr,{href:"/contact",children:"Get help"})]}),e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(ge,{children:e.jsxs(Uf,{children:[n==="start"&&_(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Forgot Password"}),e.jsx($n,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(dt,{onSubmit:b,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email Address"}),e.jsx(ce,{type:"email",id:"email",value:a,onChange:j=>p(j.target.value),placeholder:"Enter your email",required:!0})]}),E&&e.jsx(En,{children:E.message}),e.jsx(X,{type:"submit",disabled:k,style:{width:"100%",marginTop:"var(--space-md)"},children:k?"Sending...":"Send Code"})]}),e.jsx(ao,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Enter Verification Code"}),e.jsxs($n,{children:["We've sent a 6-digit code to ",a,". Please enter it below."]})]}),e.jsxs(dt,{onSubmit:f,noValidate:!0,children:[e.jsx(Tt,{onComplete:j=>c(j),isSubmitting:k,error:E==null?void 0:E.message,onResend:async()=>{await y(a)}}),E&&e.jsx(En,{children:E.message}),e.jsx(X,{type:"submit",disabled:k||g.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:k?"Verifying...":"Verify"})]}),e.jsx(ao,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Reset Password"}),e.jsx($n,{children:"Create a new password for your account."})]}),e.jsxs(dt,{onSubmit:z,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"password",children:"New Password"}),e.jsx(ce,{type:"password",id:"password",value:u,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(ce,{type:"password",id:"confirmPassword",value:v,onChange:j=>x(j.target.value),placeholder:"Confirm new password",required:!0})]}),E&&e.jsx(En,{children:E.message}),e.jsx(X,{type:"submit",disabled:k,style:{width:"100%",marginTop:"var(--space-md)"},children:k?"Resetting...":"Reset Password"})]}),e.jsx(ao,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const qf=d.div`
1297
+ `;function Vf({onBack:t}){const{deployment:r}=ve(),{navigate:o}=Ge(),[n,s]=i.useState("start"),[a,p]=i.useState(""),[g,c]=i.useState(""),[h,l]=i.useState(""),[u,m]=i.useState(""),[x,v]=i.useState(""),{forgotPassword:y,verifyOtp:z,resetPassword:S}=kc(),[_,E]=i.useState(!1),[I,w]=i.useState(null),b=async j=>{if(j.preventDefault(),!!a){E(!0),w(null);try{await y(a),s("otp")}catch(M){w(M)}finally{E(!1)}}},f=async j=>{if(j.preventDefault(),g.length===6){E(!0),w(null);try{const M=await z(a,g);M.data&&(l(M.data.token),s("reset"))}catch(M){w(M)}finally{E(!1)}}},$=async j=>{var M,R;if(j.preventDefault(),u===x&&!(u.length<8)){E(!0),w(null);try{const C=await S(h,u);if(C.data){const P=C.data,T=P.signin_attempts&&P.signin_attempts.length>0?P.signin_attempts[P.signin_attempts.length-1]:null;if(T&&!T.completed){const B=(M=r==null?void 0:r.ui_settings)==null?void 0:M.sign_in_page_url;if(B){const L=new URL(B,window.location.origin);L.searchParams.set("signin_attempt_id",T.id),o(L.toString())}else t()}else{const B=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";o(B)}}}catch(C){w(C)}finally{E(!1)}}},k=()=>e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsx(no,{children:e.jsx(so,{children:"Forgot Password"})}),e.jsx(Bf,{onClick:()=>s("email"),disabled:_,children:"Reset your password"}),e.jsx(Uf,{children:e.jsx(Wf,{children:"Or, sign in with another method"})}),e.jsx(jl,{}),e.jsxs(ao,{children:[e.jsxs(Pr,{children:["Unable to reset password? ",e.jsx(Rr,{href:"/contact",children:"Get help"})]}),e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(ge,{children:e.jsxs(Ff,{children:[n==="start"&&k(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Forgot Password"}),e.jsx($n,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(dt,{onSubmit:b,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email Address"}),e.jsx(ce,{type:"email",id:"email",value:a,onChange:j=>p(j.target.value),placeholder:"Enter your email",required:!0})]}),I&&e.jsx(En,{children:I.message}),e.jsx(X,{type:"submit",disabled:_,style:{width:"100%",marginTop:"var(--space-md)"},children:_?"Sending...":"Send Code"})]}),e.jsx(ao,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Enter Verification Code"}),e.jsxs($n,{children:["We've sent a 6-digit code to ",a,". Please enter it below."]})]}),e.jsxs(dt,{onSubmit:f,noValidate:!0,children:[e.jsx(Tt,{onComplete:j=>c(j),isSubmitting:_,error:I==null?void 0:I.message,onResend:async()=>{await y(a)}}),I&&e.jsx(En,{children:I.message}),e.jsx(X,{type:"submit",disabled:_||g.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:_?"Verifying...":"Verify"})]}),e.jsx(ao,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(no,{children:[e.jsx(so,{children:"Reset Password"}),e.jsx($n,{children:"Create a new password for your account."})]}),e.jsxs(dt,{onSubmit:$,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"password",children:"New Password"}),e.jsx(ce,{type:"password",id:"password",value:u,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(ce,{type:"password",id:"confirmPassword",value:x,onChange:j=>v(j.target.value),placeholder:"Confirm new password",required:!0})]}),I&&e.jsx(En,{children:I.message}),e.jsx(X,{type:"submit",disabled:_,style:{width:"100%",marginTop:"var(--space-md)"},children:_?"Resetting...":"Reset Password"})]}),e.jsx(ao,{children:e.jsx(Pr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Rr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const Gf=d.div`
1298
1298
  max-width: 360px;
1299
1299
  width: 360px;
1300
1300
  padding: var(--space-2xl);
1301
1301
  background: var(--color-background);
1302
1302
  border-radius: var(--radius-lg);
1303
1303
  box-shadow: 0 4px 12px var(--color-shadow);
1304
- `,Yf=d.div`
1304
+ `,Hf=d.div`
1305
1305
  text-align: center;
1306
1306
  margin-bottom: var(--space-lg);
1307
1307
  position: relative;
1308
- `,Zf=d.h1`
1308
+ `,qf=d.h1`
1309
1309
  font-size: var(--font-lg);
1310
1310
  font-weight: 400;
1311
1311
  color: var(--color-foreground);
1312
1312
  margin-bottom: var(--space-xs);
1313
1313
  margin-top: 0;
1314
- `,Kf=d.p`
1314
+ `,Yf=d.p`
1315
1315
  color: var(--color-secondary-text);
1316
1316
  font-size: var(--font-xs);
1317
1317
  margin: 0;
1318
- `,Qf=d.div`
1318
+ `,Zf=d.div`
1319
1319
  text-align: center;
1320
1320
  margin-top: var(--space-lg);
1321
1321
  `,ya=d.p`
@@ -1324,31 +1324,31 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1324
1324
  `,wa=d.a`
1325
1325
  color: var(--color-primary);
1326
1326
  text-decoration: none;
1327
- `;function Xf({onBack:t}){return e.jsx(ge,{children:e.jsxs(qf,{children:[e.jsx(Pe,{}),e.jsxs(Yf,{children:[e.jsx(Zf,{children:"Supported Options"}),e.jsx(Kf,{children:"Choose one of the following options to continue"})]}),e.jsx(jl,{}),e.jsxs(Qf,{children:[e.jsxs(ya,{children:["Don't have an account? ",e.jsx(wa,{href:"/signup",children:"Sign up"})]}),e.jsx(ya,{style:{marginTop:"var(--space-sm)"},children:e.jsx(wa,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Jf=d.div`
1327
+ `;function Kf({onBack:t}){return e.jsx(ge,{children:e.jsxs(Gf,{children:[e.jsx(Pe,{}),e.jsxs(Hf,{children:[e.jsx(qf,{children:"Supported Options"}),e.jsx(Yf,{children:"Choose one of the following options to continue"})]}),e.jsx(jl,{}),e.jsxs(Zf,{children:[e.jsxs(ya,{children:["Don't have an account? ",e.jsx(wa,{href:"/signup",children:"Sign up"})]}),e.jsx(ya,{style:{marginTop:"var(--space-sm)"},children:e.jsx(wa,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Qf=d.div`
1328
1328
  max-width: 380px;
1329
1329
  width: 380px;
1330
1330
  padding: var(--space-3xl);
1331
1331
  background: var(--color-background);
1332
1332
  border-radius: var(--radius-lg);
1333
1333
  box-shadow: 0 4px 12px var(--color-shadow);
1334
- `,eg=d.div`
1334
+ `,Xf=d.div`
1335
1335
  text-align: center;
1336
1336
  margin-bottom: var(--space-lg);
1337
1337
  position: relative;
1338
- `,tg=d.h1`
1338
+ `,Jf=d.h1`
1339
1339
  font-size: var(--font-lg);
1340
1340
  font-weight: 400;
1341
1341
  color: var(--color-foreground);
1342
1342
  margin-bottom: var(--space-xs);
1343
1343
  margin-top: 0;
1344
- `,rg=d.p`
1344
+ `,eg=d.p`
1345
1345
  color: var(--color-secondary-text);
1346
1346
  font-size: var(--font-xs);
1347
- `,og=d.div`
1347
+ `,tg=d.div`
1348
1348
  display: flex;
1349
1349
  flex-direction: column;
1350
1350
  gap: 0;
1351
- `,ng=d.button`
1351
+ `,rg=d.button`
1352
1352
  display: flex;
1353
1353
  align-items: flex-start;
1354
1354
  gap: var(--space-md);
@@ -1383,25 +1383,25 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1383
1383
  color: var(--color-primary);
1384
1384
  margin-top: 2px;
1385
1385
  }
1386
- `,sg=d.div`
1386
+ `,og=d.div`
1387
1387
  flex: 1;
1388
1388
  display: flex;
1389
1389
  flex-direction: column;
1390
1390
  gap: var(--space-2xs);
1391
- `,ag=d.div`
1391
+ `,ng=d.div`
1392
1392
  font-weight: 400;
1393
1393
  font-size: var(--font-sm);
1394
1394
  color: var(--color-foreground);
1395
- `,ig=d.div`
1395
+ `,sg=d.div`
1396
1396
  font-size: var(--font-xs);
1397
1397
  color: var(--color-secondary-text);
1398
1398
  line-height: 1.4;
1399
- `,cg=d.div`
1399
+ `,ag=d.div`
1400
1400
  margin-top: var(--space-lg);
1401
1401
  text-align: center;
1402
1402
  font-size: var(--font-xs);
1403
1403
  color: var(--color-secondary-text);
1404
- `,lg=d.span`
1404
+ `,ig=d.span`
1405
1405
  color: var(--color-primary);
1406
1406
  text-decoration: none;
1407
1407
  font-weight: 400;
@@ -1411,40 +1411,40 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1411
1411
  &:hover {
1412
1412
  color: var(--color-primary-hover);
1413
1413
  }
1414
- `;function _l({methods:t,onSelectMethod:r,onBack:o}){const n=s=>{r(s)};return e.jsx(ge,{children:e.jsxs(Jf,{children:[e.jsx(Pe,{}),e.jsxs(eg,{children:[e.jsx(tg,{children:"Two-factor authentication"}),e.jsx(rg,{children:"Choose how you'd like to verify your identity"})]}),e.jsx(og,{children:t.map(s=>e.jsxs(ng,{onClick:()=>n(s.id),disabled:!s.available,type:"button",children:[s.icon,e.jsxs(sg,{children:[e.jsx(ag,{children:s.name}),e.jsxs(ig,{children:[s.description,s.phoneNumber&&` ${s.phoneNumber}`]})]})]},s.id))}),o&&e.jsx(cg,{children:e.jsx(lg,{onClick:o,style:{cursor:"pointer"},children:"Back to login"})})]})})}const dg=d.div`
1414
+ `;function _l({methods:t,onSelectMethod:r,onBack:o}){const n=s=>{r(s)};return e.jsx(ge,{children:e.jsxs(Qf,{children:[e.jsx(Pe,{}),e.jsxs(Xf,{children:[e.jsx(Jf,{children:"Two-factor authentication"}),e.jsx(eg,{children:"Choose how you'd like to verify your identity"})]}),e.jsx(tg,{children:t.map(s=>e.jsxs(rg,{onClick:()=>n(s.id),disabled:!s.available,type:"button",children:[s.icon,e.jsxs(og,{children:[e.jsx(ng,{children:s.name}),e.jsxs(sg,{children:[s.description,s.phoneNumber&&` ${s.phoneNumber}`]})]})]},s.id))}),o&&e.jsx(ag,{children:e.jsx(ig,{onClick:o,style:{cursor:"pointer"},children:"Back to login"})})]})})}const cg=d.div`
1415
1415
  max-width: 380px;
1416
1416
  width: 380px;
1417
1417
  padding: var(--space-3xl);
1418
1418
  background: var(--color-background);
1419
1419
  border-radius: var(--radius-lg);
1420
1420
  box-shadow: 0 4px 12px var(--color-shadow);
1421
- `,ug=d.div`
1421
+ `,lg=d.div`
1422
1422
  text-align: center;
1423
1423
  margin-bottom: var(--space-lg);
1424
1424
  position: relative;
1425
- `,pg=d.h1`
1425
+ `,dg=d.h1`
1426
1426
  font-size: var(--font-lg);
1427
1427
  font-weight: 400;
1428
1428
  color: var(--color-foreground);
1429
1429
  margin-bottom: var(--space-xs);
1430
1430
  margin-top: 0;
1431
- `,hg=d.p`
1431
+ `,ug=d.p`
1432
1432
  color: var(--color-secondary-text);
1433
1433
  font-size: var(--font-xs);
1434
- `,fg=d.p`
1434
+ `,pg=d.p`
1435
1435
  font-size: var(--font-2xs);
1436
1436
  color: var(--color-error);
1437
1437
  margin: 0;
1438
1438
  margin-top: var(--space-2xs);
1439
- `,gg=d(X)`
1439
+ `,hg=d(X)`
1440
1440
  margin-top: var(--space-sm);
1441
1441
  width: 100%;
1442
- `,mg=d.div`
1442
+ `,fg=d.div`
1443
1443
  margin-top: var(--space-lg);
1444
1444
  text-align: center;
1445
1445
  font-size: var(--font-xs);
1446
1446
  color: var(--color-secondary-text);
1447
- `,xg=d.span`
1447
+ `,gg=d.span`
1448
1448
  color: var(--color-primary);
1449
1449
  text-decoration: none;
1450
1450
  font-weight: 400;
@@ -1454,30 +1454,30 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1454
1454
  &:hover {
1455
1455
  color: var(--color-primary-hover);
1456
1456
  }
1457
- `,vg=d(ce)`
1457
+ `,mg=d(ce)`
1458
1458
  padding: var(--space-sm) var(--space-md);
1459
- `;function kl({onVerify:t,onBack:r,loading:o}){const[n,s]=i.useState(""),[a,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 l=h.target.value.replace(/\D/g,"").slice(0,4);s(l),p("")};return e.jsx(ge,{children:e.jsxs(dg,{children:[e.jsx(Pe,{}),e.jsxs(ug,{children:[e.jsx(pg,{children:"Verify your phone number"}),e.jsx(hg,{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(ie,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(vg,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!a,autoFocus:!0}),a&&e.jsx(fg,{children:a})]}),e.jsx(gg,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(mg,{children:e.jsx(xg,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const bg=()=>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"})}),yg=()=>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"})]}),wg=()=>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"})}),In=d.div`
1459
+ `;function kl({onVerify:t,onBack:r,loading:o}){const[n,s]=i.useState(""),[a,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 l=h.target.value.replace(/\D/g,"").slice(0,4);s(l),p("")};return e.jsx(ge,{children:e.jsxs(cg,{children:[e.jsx(Pe,{}),e.jsxs(lg,{children:[e.jsx(dg,{children:"Verify your phone number"}),e.jsx(ug,{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(ie,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(mg,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!a,autoFocus:!0}),a&&e.jsx(pg,{children:a})]}),e.jsx(hg,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(fg,{children:e.jsx(gg,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const xg=()=>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"})}),vg=()=>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"})]}),bg=()=>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"})}),In=d.div`
1460
1460
  max-width: 380px;
1461
1461
  width: 380px;
1462
1462
  padding: var(--space-3xl);
1463
1463
  background: var(--color-background);
1464
1464
  border-radius: var(--radius-lg);
1465
1465
  box-shadow: 0 4px 12px var(--color-shadow);
1466
- `,jg=ar`
1466
+ `,yg=sr`
1467
1467
  from {
1468
1468
  transform: rotate(0deg);
1469
1469
  }
1470
1470
  to {
1471
1471
  transform: rotate(360deg);
1472
1472
  }
1473
- `,_g=d.div`
1473
+ `,wg=d.div`
1474
1474
  display: flex;
1475
1475
  justify-content: center;
1476
1476
  align-items: center;
1477
1477
  min-height: 200px;
1478
1478
 
1479
1479
  svg {
1480
- animation: ${jg} 1s linear infinite;
1480
+ animation: ${yg} 1s linear infinite;
1481
1481
  color: var(--color-primary);
1482
1482
  }
1483
1483
  `,ja=d.div`
@@ -1498,7 +1498,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1498
1498
  color: var(--color-error);
1499
1499
  margin: 0;
1500
1500
  margin-top: var(--space-2xs);
1501
- `,kg=d(X)`
1501
+ `,jg=d(X)`
1502
1502
  margin-top: var(--space-sm);
1503
1503
  `,Sa=d.div`
1504
1504
  margin-top: var(--space-lg);
@@ -1515,9 +1515,9 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1515
1515
  &:hover {
1516
1516
  color: var(--color-primary-hover);
1517
1517
  }
1518
- `,Cg=d(ce)`
1518
+ `,_g=d(ce)`
1519
1519
  padding: var(--space-sm) var(--space-md);
1520
- `;function Cl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:s}=ve(),[a,p]=i.useState(""),[g,c]=i.useState({}),[h,l]=i.useState(!1),[u,m]=i.useState(null),[v,x]=i.useState(!0),[y,$]=i.useState(!1),[S,k]=i.useState(""),[I,E]=i.useState(!1),{navigate:w}=Ge(),b=(r==null?void 0:r.available_2fa_methods)||[],f=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(bg,{}),available:b.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(yg,{}),available:b.includes("phone_otp"),phoneNumber:S},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(wg,{}),available:b.includes("backup_code")}].filter(R=>R.available),z=async R=>{m(R),x(!1),R==="phone_otp"&&$(!0)},_=async R=>{var C,P;if(r){l(!0);try{const T=await n({strategy:"phone_otp",lastDigits:R});T&&"data"in T&&((C=T.data)!=null&&C.otp_sent)?((P=T.data)!=null&&P.masked_phone&&k(T.data.masked_phone),$(!1)):c({phone:"Phone number verification failed"})}catch(T){c({phone:T.message})}finally{l(!1)}}},j=async(R,C)=>{if(R.preventDefault(),h)return;const P=C||a,T={};if(P?u==="authenticator"&&P.length!==6?T.code="Authentication code must be 6 digits":u==="phone_otp"&&P.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(P)}catch(B){c({submit:B.message})}finally{l(!1)}}},M=R=>{let C=R.target.value;u!=="backup_code"&&(C=C.replace(/\D/g,"").slice(0,6)),p(C),c(P=>({...P,code:""}))};return i.useEffect(()=>{var R;if(r.completed){E(!0);let C=new URLSearchParams(window.location.search).get("redirect_uri");if(C||(C=((R=s==null?void 0:s.ui_settings)==null?void 0:R.after_signin_redirect_url)||null),!C&&(s!=null&&s.frontend_host)&&(C=`https://${s.frontend_host}`),C){let P;try{P=new URL(C)}catch{P=new URL(C,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&P.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),w(P.toString())}return}},[r,s]),I?e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsx(_g,{children:e.jsx(kt,{size:32})})]})}):v?f.length===0?e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(ja,{children:[e.jsx(_a,{children:"Set Up Two-Factor Authentication"}),e.jsx(ka,{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(Sa,{children:[t&&e.jsx("div",{children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Tr,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(_l,{methods:f,onSelectMethod:z,onBack:t}):y&&u==="phone_otp"?e.jsx(kl,{onVerify:_,onBack:()=>{$(!1),x(!0),m(null)},loading:h}):e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(ja,{children:[e.jsx(_a,{children:"Two-factor authentication"}),e.jsxs(ka,{children:[u==="authenticator"&&"Enter the 6-digit code from your authenticator app",u==="phone_otp"&&`Enter the 6-digit code sent to your phone ${S}`,u==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(dt,{onSubmit:j,noValidate:!0,children:[u==="backup_code"?e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"code",children:"Backup code"}),e.jsx(Cg,{type:"text",id:"code",name:"code",value:a,onChange:M,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!g.code,autoFocus:!0}),g.code&&e.jsx(Ca,{children:g.code})]}):e.jsx(Tt,{onComplete:async R=>{if(p(R),u!=="backup_code"){const C=new Event("submit",{bubbles:!0,cancelable:!0});await j(C,R)}},onResend:u==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:S.slice(-4)})}catch(R){c({submit:R.message})}}:void 0,error:g.code,isSubmitting:h}),e.jsxs("div",{children:[g.submit&&e.jsx(Ca,{children:g.submit}),e.jsx(kg,{type:"submit",disabled:h||!a,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(Sa,{children:[e.jsx(Tr,{onClick:()=>{x(!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(Tr,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Pn=d.div`
1520
+ `;function Cl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:s}=ve(),[a,p]=i.useState(""),[g,c]=i.useState({}),[h,l]=i.useState(!1),[u,m]=i.useState(null),[x,v]=i.useState(!0),[y,z]=i.useState(!1),[S,_]=i.useState(""),[E,I]=i.useState(!1),{navigate:w}=Ge(),b=(r==null?void 0:r.available_2fa_methods)||[],f=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(xg,{}),available:b.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(vg,{}),available:b.includes("phone_otp"),phoneNumber:S},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(bg,{}),available:b.includes("backup_code")}].filter(R=>R.available),$=async R=>{m(R),v(!1),R==="phone_otp"&&z(!0)},k=async R=>{var C,P;if(r){l(!0);try{const T=await n({strategy:"phone_otp",lastDigits:R});T&&"data"in T&&((C=T.data)!=null&&C.otp_sent)?((P=T.data)!=null&&P.masked_phone&&_(T.data.masked_phone),z(!1)):c({phone:"Phone number verification failed"})}catch(T){c({phone:T.message})}finally{l(!1)}}},j=async(R,C)=>{if(R.preventDefault(),h)return;const P=C||a,T={};if(P?u==="authenticator"&&P.length!==6?T.code="Authentication code must be 6 digits":u==="phone_otp"&&P.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(P)}catch(B){c({submit:B.message})}finally{l(!1)}}},M=R=>{let C=R.target.value;u!=="backup_code"&&(C=C.replace(/\D/g,"").slice(0,6)),p(C),c(P=>({...P,code:""}))};return i.useEffect(()=>{var R;if(r.completed){I(!0);let C=new URLSearchParams(window.location.search).get("redirect_uri");if(C||(C=((R=s==null?void 0:s.ui_settings)==null?void 0:R.after_signin_redirect_url)||null),!C&&(s!=null&&s.frontend_host)&&(C=`https://${s.frontend_host}`),C){let P;try{P=new URL(C)}catch{P=new URL(C,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&P.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),w(P.toString())}return}},[r,s]),E?e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsx(wg,{children:e.jsx(kt,{size:32})})]})}):x?f.length===0?e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(ja,{children:[e.jsx(_a,{children:"Set Up Two-Factor Authentication"}),e.jsx(ka,{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(Sa,{children:[t&&e.jsx("div",{children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Tr,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(_l,{methods:f,onSelectMethod:$,onBack:t}):y&&u==="phone_otp"?e.jsx(kl,{onVerify:k,onBack:()=>{z(!1),v(!0),m(null)},loading:h}):e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(ja,{children:[e.jsx(_a,{children:"Two-factor authentication"}),e.jsxs(ka,{children:[u==="authenticator"&&"Enter the 6-digit code from your authenticator app",u==="phone_otp"&&`Enter the 6-digit code sent to your phone ${S}`,u==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(dt,{onSubmit:j,noValidate:!0,children:[u==="backup_code"?e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"code",children:"Backup code"}),e.jsx(_g,{type:"text",id:"code",name:"code",value:a,onChange:M,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!g.code,autoFocus:!0}),g.code&&e.jsx(Ca,{children:g.code})]}):e.jsx(Tt,{onComplete:async R=>{if(p(R),u!=="backup_code"){const C=new Event("submit",{bubbles:!0,cancelable:!0});await j(C,R)}},onResend:u==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:S.slice(-4)})}catch(R){c({submit:R.message})}}:void 0,error:g.code,isSubmitting:h}),e.jsxs("div",{children:[g.submit&&e.jsx(Ca,{children:g.submit}),e.jsx(jg,{type:"submit",disabled:h||!a,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(Sa,{children:[e.jsx(Tr,{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(Tr,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Pn=d.div`
1521
1521
  max-width: 380px;
1522
1522
  width: 380px;
1523
1523
  padding: var(--space-3xl);
@@ -1537,7 +1537,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1537
1537
  `,Ea=d.p`
1538
1538
  color: var(--color-secondary-text);
1539
1539
  font-size: var(--font-xs);
1540
- `,Sg=d.div`
1540
+ `,kg=d.div`
1541
1541
  display: grid;
1542
1542
  grid-template-columns: ${t=>t.$isBothEnabled?"1fr 1fr":"1fr"};
1543
1543
  gap: var(--space-sm);
@@ -1546,7 +1546,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1546
1546
  color: var(--color-error);
1547
1547
  margin: 0;
1548
1548
  margin-top: var(--space-2xs);
1549
- `,zg=d(X)`
1549
+ `,Cg=d(X)`
1550
1550
  margin-top: var(--space-sm);
1551
1551
  `,Ia=d.div`
1552
1552
  margin-top: var(--space-lg);
@@ -1563,7 +1563,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1563
1563
  &:hover {
1564
1564
  color: var(--color-primary-hover);
1565
1565
  }
1566
- `,$g=d.div`
1566
+ `,Sg=d.div`
1567
1567
  display: flex;
1568
1568
  justify-content: center;
1569
1569
  align-items: center;
@@ -1582,7 +1582,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1582
1582
  transform: rotate(360deg);
1583
1583
  }
1584
1584
  }
1585
- `;function Sl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:s}){var F,O,A,J,re,V,q,H,ee;const{deployment:a}=ve(),{navigate:p}=Ge(),[g,c]=i.useState({}),[h,l]=i.useState({}),[u,m]=i.useState("US"),[v,x]=i.useState(!1),[y,$]=i.useState(!1),[S,k]=i.useState(null),[I,E]=i.useState(!1),w=S,b=y,f=async le=>{var oe;$(!0),k(null);try{if(await o(le)){E(!0);let K=new URLSearchParams(window.location.search).get("redirect_uri");if(K||(K=((oe=a==null?void 0:a.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!K&&(a!=null&&a.frontend_host)&&(K=`https://${a.frontend_host}`),K){let se;try{se=new URL(K)}catch{se=new URL(K,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(se.toString())}}}catch(de){const K=de;throw k(K),K}finally{$(!1)}},z=async le=>{var oe;$(!0),k(null);try{if(await n(le)){E(!0);let K=new URLSearchParams(window.location.search).get("redirect_uri");if(K||(K=((oe=a==null?void 0:a.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!K&&(a!=null&&a.frontend_host)&&(K=`https://${a.frontend_host}`),K){let se;try{se=new URL(K)}catch{se=new URL(K,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(se.toString())}}return!0}catch(de){return k(de),!1}finally{$(!1)}};if(I||!t)return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsx($g,{children:e.jsx(kt,{size:32})})]})});const _=t.missing_fields||[],j="Complete Your Profile",M="Please provide the following information to continue",R=a==null?void 0:a.auth_settings,C=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||v,P=le=>{const{name:oe,value:de}=le.target;c(K=>({...K,[oe]:de})),h[oe]&&l(K=>({...K,[oe]:""}))},T=()=>{const le={};return _.forEach(oe=>{var se,xe,ue,U,pe;const de=g[oe];let K=!1;switch(oe){case"first_name":K=((se=R==null?void 0:R.first_name)==null?void 0:se.enabled)||!1;break;case"last_name":K=((xe=R==null?void 0:R.last_name)==null?void 0:xe.enabled)||!1;break;case"username":K=((ue=R==null?void 0:R.username)==null?void 0:ue.enabled)||!1;break;case"phone_number":K=((U=R==null?void 0:R.phone_number)==null?void 0:U.enabled)||!1;break;case"email_address":K=((pe=R==null?void 0:R.email_address)==null?void 0:pe.enabled)||!1;break;default:K=!0}if(K&&(!de||de.trim()==="")){const Q=oe.replace("_"," ").replace(/\b\w/g,Y=>Y.toUpperCase());le[oe]=`${Q} is required`}}),g.username&&_.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(g.username)||(le.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),g.phone_number&&_.includes("phone_number")&&(/^\d{7,15}$/.test(g.phone_number)||(le.phone_number="Phone number must contain 7-15 digits")),g.email&&_.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(g.email)||(le.email_address="Please enter a valid email address")),l(le),Object.keys(le).length===0},B=async le=>{if(le.preventDefault(),!T())return;const oe={...g};g.phone_number&&u&&(oe.phone_country_code=u),await f(oe)},L=le=>{const oe=le.target.value;c(de=>({...de,phone_number:oe})),h.phone_number&&l(de=>({...de,phone_number:""}))};if(C){const le=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",de=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(za,{children:[e.jsx($a,{children:le}),e.jsx(Ea,{children:oe})]}),e.jsxs(dt,{onSubmit:K=>K.preventDefault(),noValidate:!0,children:[e.jsx(Tt,{onComplete:z,onResend:async()=>{await s({strategy:de})},error:w==null?void 0:w.message,isSubmitting:b}),w&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:w.message})]}),e.jsxs(Ia,{children:[e.jsx("div",{children:e.jsx(io,{onClick:()=>x(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(io,{children:e.jsx(ot,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(za,{children:[e.jsx($a,{children:j}),e.jsx(Ea,{children:M})]}),e.jsxs(dt,{onSubmit:B,noValidate:!0,children:[(_.includes("first_name")||_.includes("last_name"))&&(((F=R==null?void 0:R.first_name)==null?void 0:F.enabled)||((O=R==null?void 0:R.last_name)==null?void 0:O.enabled))&&e.jsxs(Sg,{$isBothEnabled:!!((A=R==null?void 0:R.first_name)!=null&&A.enabled&&((J=R==null?void 0:R.last_name)!=null&&J.enabled)&&_.includes("first_name")&&_.includes("last_name")),children:[_.includes("first_name")&&((re=R==null?void 0:R.first_name)==null?void 0:re.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),e.jsx(ce,{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(Lt,{children:h.first_name})]}),_.includes("last_name")&&((V=R==null?void 0:R.last_name)==null?void 0:V.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),e.jsx(ce,{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(Lt,{children:h.last_name})]})]}),_.includes("username")&&((q=R==null?void 0:R.username)==null?void 0:q.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),e.jsx(ce,{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(Lt,{children:h.username})]}),_.includes("phone_number")&&((H=R==null?void 0:R.phone_number)==null?void 0:H.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),e.jsx(qr,{value:g.phone_number||"",onChange:L,error:h.phone_number,countryCode:u,setCountryCode:m}),h.phone_number&&e.jsx(Lt,{children:h.phone_number})]}),_.includes("email_address")&&((ee=R==null?void 0:R.email_address)==null?void 0:ee.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),e.jsx(ce,{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(Lt,{children:h.email_address})]}),w&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:w.message}),e.jsx(zg,{type:"submit",disabled:b,children:b?"Completing...":"Continue"})]}),e.jsxs(Ia,{children:[r&&e.jsx("div",{children:e.jsx(io,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(io,{children:e.jsx(ot,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const Eg=ar`
1585
+ `;function Sl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:s}){var F,O,A,J,re,V,q,H,ee;const{deployment:a}=ve(),{navigate:p}=Ge(),[g,c]=i.useState({}),[h,l]=i.useState({}),[u,m]=i.useState("US"),[x,v]=i.useState(!1),[y,z]=i.useState(!1),[S,_]=i.useState(null),[E,I]=i.useState(!1),w=S,b=y,f=async le=>{var oe;z(!0),_(null);try{if(await o(le)){I(!0);let K=new URLSearchParams(window.location.search).get("redirect_uri");if(K||(K=((oe=a==null?void 0:a.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!K&&(a!=null&&a.frontend_host)&&(K=`https://${a.frontend_host}`),K){let se;try{se=new URL(K)}catch{se=new URL(K,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(se.toString())}}}catch(de){const K=de;throw _(K),K}finally{z(!1)}},$=async le=>{var oe;z(!0),_(null);try{if(await n(le)){I(!0);let K=new URLSearchParams(window.location.search).get("redirect_uri");if(K||(K=((oe=a==null?void 0:a.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!K&&(a!=null&&a.frontend_host)&&(K=`https://${a.frontend_host}`),K){let se;try{se=new URL(K)}catch{se=new URL(K,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(se.toString())}}return!0}catch(de){return _(de),!1}finally{z(!1)}};if(E||!t)return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsx(Sg,{children:e.jsx(kt,{size:32})})]})});const k=t.missing_fields||[],j="Complete Your Profile",M="Please provide the following information to continue",R=a==null?void 0:a.auth_settings,C=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,P=le=>{const{name:oe,value:de}=le.target;c(K=>({...K,[oe]:de})),h[oe]&&l(K=>({...K,[oe]:""}))},T=()=>{const le={};return k.forEach(oe=>{var se,xe,ue,U,pe;const de=g[oe];let K=!1;switch(oe){case"first_name":K=((se=R==null?void 0:R.first_name)==null?void 0:se.enabled)||!1;break;case"last_name":K=((xe=R==null?void 0:R.last_name)==null?void 0:xe.enabled)||!1;break;case"username":K=((ue=R==null?void 0:R.username)==null?void 0:ue.enabled)||!1;break;case"phone_number":K=((U=R==null?void 0:R.phone_number)==null?void 0:U.enabled)||!1;break;case"email_address":K=((pe=R==null?void 0:R.email_address)==null?void 0:pe.enabled)||!1;break;default:K=!0}if(K&&(!de||de.trim()==="")){const Q=oe.replace("_"," ").replace(/\b\w/g,Y=>Y.toUpperCase());le[oe]=`${Q} is required`}}),g.username&&k.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(g.username)||(le.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),g.phone_number&&k.includes("phone_number")&&(/^\d{7,15}$/.test(g.phone_number)||(le.phone_number="Phone number must contain 7-15 digits")),g.email&&k.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(g.email)||(le.email_address="Please enter a valid email address")),l(le),Object.keys(le).length===0},B=async le=>{if(le.preventDefault(),!T())return;const oe={...g};g.phone_number&&u&&(oe.phone_country_code=u),await f(oe)},L=le=>{const oe=le.target.value;c(de=>({...de,phone_number:oe})),h.phone_number&&l(de=>({...de,phone_number:""}))};if(C){const le=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",de=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(za,{children:[e.jsx($a,{children:le}),e.jsx(Ea,{children:oe})]}),e.jsxs(dt,{onSubmit:K=>K.preventDefault(),noValidate:!0,children:[e.jsx(Tt,{onComplete:$,onResend:async()=>{await s({strategy:de})},error:w==null?void 0:w.message,isSubmitting:b}),w&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:w.message})]}),e.jsxs(Ia,{children:[e.jsx("div",{children:e.jsx(io,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(io,{children:e.jsx(ot,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(ge,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(za,{children:[e.jsx($a,{children:j}),e.jsx(Ea,{children:M})]}),e.jsxs(dt,{onSubmit:B,noValidate:!0,children:[(k.includes("first_name")||k.includes("last_name"))&&(((F=R==null?void 0:R.first_name)==null?void 0:F.enabled)||((O=R==null?void 0:R.last_name)==null?void 0:O.enabled))&&e.jsxs(kg,{$isBothEnabled:!!((A=R==null?void 0:R.first_name)!=null&&A.enabled&&((J=R==null?void 0:R.last_name)!=null&&J.enabled)&&k.includes("first_name")&&k.includes("last_name")),children:[k.includes("first_name")&&((re=R==null?void 0:R.first_name)==null?void 0:re.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),e.jsx(ce,{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(Lt,{children:h.first_name})]}),k.includes("last_name")&&((V=R==null?void 0:R.last_name)==null?void 0:V.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),e.jsx(ce,{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(Lt,{children:h.last_name})]})]}),k.includes("username")&&((q=R==null?void 0:R.username)==null?void 0:q.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),e.jsx(ce,{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(Lt,{children:h.username})]}),k.includes("phone_number")&&((H=R==null?void 0:R.phone_number)==null?void 0:H.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),e.jsx(qr,{value:g.phone_number||"",onChange:L,error:h.phone_number,countryCode:u,setCountryCode:m}),h.phone_number&&e.jsx(Lt,{children:h.phone_number})]}),k.includes("email_address")&&((ee=R==null?void 0:R.email_address)==null?void 0:ee.enabled)&&e.jsxs(he,{children:[e.jsxs(ie,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),e.jsx(ce,{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(Lt,{children:h.email_address})]}),w&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:w.message}),e.jsx(Cg,{type:"submit",disabled:b,children:b?"Completing...":"Continue"})]}),e.jsxs(Ia,{children:[r&&e.jsx("div",{children:e.jsx(io,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(io,{children:e.jsx(ot,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const zg=sr`
1586
1586
  from {
1587
1587
  transform: rotate(0deg);
1588
1588
  }
@@ -1603,7 +1603,7 @@ display: flex;
1603
1603
  min-height: 200px;
1604
1604
 
1605
1605
  svg {
1606
- animation: ${Eg} 1s linear infinite;
1606
+ animation: ${zg} 1s linear infinite;
1607
1607
  color: var(--color-primary);
1608
1608
  }
1609
1609
  `,Ra=d.div`
@@ -1619,7 +1619,7 @@ display: flex;
1619
1619
  `,Ma=d.p`
1620
1620
  color: var(--color-secondary-text);
1621
1621
  font-size: var(--font-xs);
1622
- `,Ig=d.div`
1622
+ `,$g=d.div`
1623
1623
  position: relative;
1624
1624
  text-align: center;
1625
1625
  margin: var(--space-2xl) 0;
@@ -1633,7 +1633,7 @@ position: relative;
1633
1633
  height: 1px;
1634
1634
  background: var(--color-border);
1635
1635
  }
1636
- `,Pg=d.span`
1636
+ `,Eg=d.span`
1637
1637
  position: relative;
1638
1638
  background: var(--color-background);
1639
1639
  padding: 0 var(--space-md);
@@ -1642,7 +1642,7 @@ position: relative;
1642
1642
  font-weight: 400;
1643
1643
  text-transform: uppercase;
1644
1644
  letter-spacing: 0.05em;
1645
- `,Rg=d.div`
1645
+ `,Ig=d.div`
1646
1646
  position: relative;
1647
1647
  `,Mr=d.p`
1648
1648
  font-size: var(--font-2xs);
@@ -1666,23 +1666,23 @@ cursor: pointer;
1666
1666
  &:hover {
1667
1667
  color: var(--color-primary-hover);
1668
1668
  }
1669
- `,Tg=d.div`
1669
+ `,Pg=d.div`
1670
1670
  background: var(--color-error-background, rgba(239, 68, 68, 0.1));
1671
1671
  border: 1px solid var(--color-error, #ef4444);
1672
1672
  border-radius: var(--radius-md);
1673
1673
  padding: var(--space-md);
1674
1674
  margin-bottom: var(--space-lg);
1675
1675
  text-align: center;
1676
- `,Mg=d.div`
1676
+ `,Rg=d.div`
1677
1677
  font-weight: 600;
1678
1678
  font-size: var(--font-sm);
1679
1679
  color: var(--color-error, #ef4444);
1680
1680
  margin-bottom: var(--space-xs);
1681
- `,Og=d.div`
1681
+ `,Tg=d.div`
1682
1682
  font-size: var(--font-xs);
1683
1683
  color: var(--color-foreground);
1684
1684
  margin-bottom: var(--space-sm);
1685
- `,Ag=d.span`
1685
+ `,Mg=d.span`
1686
1686
  font-size: var(--font-xs);
1687
1687
  color: var(--color-primary);
1688
1688
  cursor: pointer;
@@ -1691,27 +1691,27 @@ cursor: pointer;
1691
1691
  &:hover {
1692
1692
  color: var(--color-primary-hover);
1693
1693
  }
1694
- `;function Lg(){return e.jsx(Bf,{children:e.jsx(Dg,{})})}function Dg(){var de,K,se,xe,ue,U,pe,Q,Y,ne,me,fe;const{deployment:t}=ve(),{navigate:r}=Ge(),{session:o,loading:n}=Ue(),s=((K=(de=t==null?void 0:t.auth_settings)==null?void 0:de.multi_session_support)==null?void 0:K.enabled)??!1,{setEmail:a,otpSent:p,setOtpSent:g,showForgotPassword:c,setShowForgotPassword:h,showOtherOptions:l,setShowOtherOptions:u,enabledSocialsProviders:m,firstFactor:v,signInStep:x,setSignInStep:y}=wl(),{loading:$,signIn:S,signinAttempt:k,discardSignInAttempt:I,setSignInAttempt:E}=Br("generic"),{signIn:w}=Br("oauth"),[b,f]=i.useState({email:"",username:"",password:"",phone:""}),[z,_]=i.useState({}),[j,M]=i.useState(!1),[R,C]=i.useState(""),[P,T]=i.useState("US"),[B,L]=i.useState(!1),[F,O]=i.useState(null);i.useEffect(()=>{const W=new URLSearchParams(window.location.search),N=W.get("error"),D=W.get("error_description");if(N==="access_denied"&&D){O(D),W.delete("error"),W.delete("error_description");const Z=W.toString()?`${window.location.pathname}?${W.toString()}`:window.location.pathname;window.history.replaceState({},"",Z)}},[]),i.useEffect(()=>{var W;if(!n&&(o!=null&&o.active_signin)&&!s&&!B){L(!0);let N=new URLSearchParams(window.location.search).get("redirect_uri");N||(N=((W=t==null?void 0:t.ui_settings)==null?void 0:W.after_signin_redirect_url)||null),!N&&(t!=null&&t.frontend_host)&&(N=`https://${t.frontend_host}`),N&&r(N)}},[o,n,s,t,r,B]);const A=W=>{let{name:N,value:D}=W.target;N==="phone"?D=D.replace(/[^0-9]/g,""):N==="email"&&(a(D),D=D.toLowerCase()),f(Z=>({...Z,[N]:D})),_(Z=>({...Z,[N]:""}))},J=()=>{f({email:"",username:"",password:"",phone:""}),_({}),T("US"),y("identifier")},re=async W=>{if(!W){_({email:"Email address is required"});return}M(!0),_({});try{const N=await S.identify(W);if(N.strategy==="sso"&&N.connection_id){const Z=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,ae=await S.initEnterpriseSso(N.connection_id,Z);if(ae&&ae.sso_url){L(!0),window.location.href=ae.sso_url;return}}else if(N.strategy==="social"&&N.provider){const D=m.find(Z=>Z.provider===N.provider);if(D){const ae=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:te}=await w.create({provider:D.provider,redirectUri:ae});if(te&&typeof te=="object"&&"oauth_url"in te){L(!0),window.location.href=te.oauth_url;return}}else y("password")}else y("password")}catch(N){_({submit:N.message})}finally{B||M(!1)}},V=async W=>{if(W.preventDefault(),$||j)return;I();const N={};if(x==="identifier"&&v==="email_password"){if(!b.email){_({email:"Email address is required"});return}await re(b.email);return}if(v==="email_password"?(b.email||(N.email="Email address is required"),b.password||(N.password="Password is required")):v==="username_password"?(b.username||(N.username="Username is required"),b.password||(N.password="Password is required")):v==="email_otp"||v==="email_magic_link"?b.email||(N.email="Email address is required"):v==="phone_otp"&&(b.phone?/^\d{7,15}$/.test(b.phone)||(N.phone="Phone number must contain 7-15 digits"):N.phone="Phone number is required"),_(N),Object.keys(N).length>0)return;let D="";switch(v){case"email_password":D="plain_email";break;case"username_password":D="plain_username";break;case"email_otp":D="email_otp";break;case"email_magic_link":D="magic_link";break;case"phone_otp":D="phone_otp";break}M(!0);try{const Z={...b,strategy:D};v==="phone_otp"&&P&&(Z.phone_country_code=P),await S.create(Z)}catch(Z){_({submit:Z.message}),M(!1)}},q=async W=>{if(W.preventDefault(),$||j)return;const N={};if(!R){N.otp="OTP code is required",_(N);return}M(!0),_({});try{await S.completeVerification(R),g(!1),C("")}catch(D){_({otp:D.message||"Verification failed"})}finally{M(!1)}},H=async W=>{if(!($||j)){M(!0);try{const D=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Z}=await w.create({provider:W.provider,redirectUri:D});Z&&typeof Z=="object"&&"oauth_url"in Z&&(window.location.href=Z.oauth_url)}catch(N){_({submit:N.message})}finally{M(!1)}}},ee=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const W=new URLSearchParams(window.location.search),N=W.get("impersonation_token");if(N&&!k&&!$&&!ee.current){ee.current=!0,W.delete("impersonation_token");const Z=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",Z),(async()=>{try{M(!0),await S.create({strategy:"impersonation",token:N})}catch(te){_({submit:te.message}),M(!1),ee.current=!1}})();return}const D=W.get("signin_attempt_id");if(D&&(o!=null&&o.signin_attempts)&&!k){const Z=o.signin_attempts.find(ae=>ae.id===D);if(Z){E(Z),W.delete("signin_attempt_id");const ae=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",ae)}}},[o,n,k,E,$]),i.useEffect(()=>{var Z;if(!k)return;if(k.completed){L(!0);let ae=new URLSearchParams(window.location.search).get("redirect_uri");if(ae||(ae=((Z=t==null?void 0:t.ui_settings)==null?void 0:Z.after_signin_redirect_url)||null),!ae&&(t!=null&&t.frontend_host)&&(ae=`https://${t.frontend_host}`),ae){let te;try{te=new URL(ae)}catch{te=new URL(ae,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&te.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(te.toString())}return}if(!S||p)return;const N={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[k.current_step];if(!N)return;(async()=>{try{await S.prepareVerification({strategy:N}),g(!0)}catch(ae){console.error("Failed to prepare verification:",ae),_({submit:"Failed to send verification. Please try again."})}finally{M(!1)}})()},[k,S,p,g,r,t]),i.useEffect(()=>{},[]),l)return e.jsx(Xf,{onBack:()=>u(!1)});if(c)return e.jsx(Hf,{onBack:()=>h(!1)});if((k==null?void 0:k.current_step)==="verify_second_factor")return e.jsx(Cl,{attempt:k,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{I(),J(),g(!1)}});if((k==null?void 0:k.current_step)==="complete_profile")return e.jsx(Sl,{attempt:k,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{I(),J(),g(!1)}});if(n)return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Pa,{children:e.jsx(kt,{size:32})})]})});if(B)return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Pa,{children:e.jsx(kt,{size:32})})]})});const oe=(k==null?void 0:k.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(k.current_step)&&p;return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),oe?e.jsx(e.Fragment,{children:e.jsxs(Ra,{children:[e.jsx(Ta,{children:v==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Ma,{children:v==="email_magic_link"?`If ${b.email} exists in our records, you will receive a magic link. Click the link to sign in.`:v==="phone_otp"?`If ${b.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${b.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(Ra,{children:[e.jsx(Ta,{children:"Sign in to your account"}),e.jsxs(Ma,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),F&&e.jsxs(Tg,{children:[e.jsx(Mg,{children:"Access Denied"}),e.jsx(Og,{children:F}),e.jsx(Ag,{onClick:()=>O(null),children:"Try again"})]}),oe?v==="email_magic_link"?e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{g(!1),I(),J()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:q,noValidate:!0,children:[e.jsx(Tt,{onComplete:async W=>{if(C(W),W&&W.length===6){M(!0),_({});try{await S.completeVerification(W),g(!1)}catch(N){_({otp:N.message||"Verification failed"})}finally{M(!1)}}},onResend:async()=>{const W=v==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:W})},error:z.otp,isSubmitting:j}),e.jsx(Oa,{type:"submit",disabled:j||$||!R,style:{margin:0},children:j?"Verifying...":`Continue to ${(fe=t==null?void 0:t.ui_settings)==null?void 0:fe.app_name}`})]}),e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{g(!1),I(),J()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[m.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Es,{connections:m,callback:H}),e.jsx(Ig,{children:e.jsx(Pg,{children:"or"})})]}),e.jsxs(dt,{onSubmit:V,noValidate:!0,children:[(v==="email_password"||v==="email_otp"||v==="email_magic_link")&&((xe=(se=t==null?void 0:t.auth_settings)==null?void 0:se.email_address)==null?void 0:xe.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email address"}),e.jsx(ce,{type:"email",id:"email",name:"email",value:b.email,onChange:A,placeholder:"Enter your email address","aria-invalid":!!z.email}),z.email&&e.jsx(Mr,{children:z.email})]}),v==="username_password"&&((U=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.username)==null?void 0:U.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(ce,{type:"text",id:"username",name:"username",value:b.username,onChange:A,placeholder:"Enter your username","aria-invalid":!!z.username}),z.username&&e.jsx(Mr,{children:z.username})]}),v==="phone_otp"&&((Q=(pe=t==null?void 0:t.auth_settings)==null?void 0:pe.phone_number)==null?void 0:Q.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"phone",children:"Phone number"}),e.jsx(qr,{value:b.phone,onChange:A,error:z.phone,countryCode:P,setCountryCode:T}),z.phone&&e.jsx(Mr,{children:z.phone})]}),x==="password"&&(v==="email_password"||v==="username_password")&&((ne=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.password)==null?void 0:ne.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ie,{htmlFor:"password",children:"Password"}),e.jsx(Dt,{style:{fontSize:"12px"},onClick:()=>h(!0),children:"Forgot password?"})]}),e.jsx(Rg,{children:e.jsx(ce,{type:"password",id:"password",name:"password",value:b.password,onChange:A,placeholder:"Enter your password","aria-invalid":!!z.password})}),z.password&&e.jsx(Mr,{children:z.password})]}),e.jsxs("div",{children:[z.submit&&e.jsx(Mr,{children:z.submit}),e.jsx(Oa,{type:"submit",disabled:j||$,children:j?e.jsxs(e.Fragment,{children:[e.jsx(kt,{size:16,style:{animation:"spin 1s linear infinite",marginRight:"8px"}}),x==="identifier"?"Checking...":"Signing in..."]}):x==="identifier"?"Continue":"Sign in"})]}),e.jsx(Dt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>u(!0),children:"Use other methods"})]}),e.jsxs(Tn,{children:["Don't have an account?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:`${(me=t.ui_settings)==null?void 0:me.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Aa=d.div`
1694
+ `;function Og(){return e.jsx(Nf,{children:e.jsx(Ag,{})})}function Ag(){var de,K,se,xe,ue,U,pe,Q,Y,ne,me,fe;const{deployment:t}=ve(),{navigate:r}=Ge(),{session:o,loading:n}=Ue(),s=((K=(de=t==null?void 0:t.auth_settings)==null?void 0:de.multi_session_support)==null?void 0:K.enabled)??!1,{setEmail:a,otpSent:p,setOtpSent:g,showForgotPassword:c,setShowForgotPassword:h,showOtherOptions:l,setShowOtherOptions:u,enabledSocialsProviders:m,firstFactor:x,signInStep:v,setSignInStep:y}=wl(),{loading:z,signIn:S,signinAttempt:_,discardSignInAttempt:E,setSignInAttempt:I}=Br("generic"),{signIn:w}=Br("oauth"),[b,f]=i.useState({email:"",username:"",password:"",phone:""}),[$,k]=i.useState({}),[j,M]=i.useState(!1),[R,C]=i.useState(""),[P,T]=i.useState("US"),[B,L]=i.useState(!1),[F,O]=i.useState(null);i.useEffect(()=>{const W=new URLSearchParams(window.location.search),N=W.get("error"),D=W.get("error_description");if(N==="access_denied"&&D){O(D),W.delete("error"),W.delete("error_description");const Z=W.toString()?`${window.location.pathname}?${W.toString()}`:window.location.pathname;window.history.replaceState({},"",Z)}},[]),i.useEffect(()=>{var W;if(!n&&(o!=null&&o.active_signin)&&!s&&!B){L(!0);let N=new URLSearchParams(window.location.search).get("redirect_uri");N||(N=((W=t==null?void 0:t.ui_settings)==null?void 0:W.after_signin_redirect_url)||null),!N&&(t!=null&&t.frontend_host)&&(N=`https://${t.frontend_host}`),N&&r(N)}},[o,n,s,t,r,B]);const A=W=>{let{name:N,value:D}=W.target;N==="phone"?D=D.replace(/[^0-9]/g,""):N==="email"&&(a(D),D=D.toLowerCase()),f(Z=>({...Z,[N]:D})),k(Z=>({...Z,[N]:""}))},J=()=>{f({email:"",username:"",password:"",phone:""}),k({}),T("US"),y("identifier")},re=async W=>{if(!W){k({email:"Email address is required"});return}M(!0),k({});try{const N=await S.identify(W);if(N.strategy==="sso"&&N.connection_id){const Z=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,ae=await S.initEnterpriseSso(N.connection_id,Z);if(ae&&ae.sso_url){L(!0),window.location.href=ae.sso_url;return}}else if(N.strategy==="social"&&N.provider){const D=m.find(Z=>Z.provider===N.provider);if(D){const ae=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:te}=await w.create({provider:D.provider,redirectUri:ae});if(te&&typeof te=="object"&&"oauth_url"in te){L(!0),window.location.href=te.oauth_url;return}}else y("password")}else y("password")}catch(N){k({submit:N.message})}finally{B||M(!1)}},V=async W=>{if(W.preventDefault(),z||j)return;E();const N={};if(v==="identifier"&&x==="email_password"){if(!b.email){k({email:"Email address is required"});return}await re(b.email);return}if(x==="email_password"?(b.email||(N.email="Email address is required"),b.password||(N.password="Password is required")):x==="username_password"?(b.username||(N.username="Username is required"),b.password||(N.password="Password is required")):x==="email_otp"||x==="email_magic_link"?b.email||(N.email="Email address is required"):x==="phone_otp"&&(b.phone?/^\d{7,15}$/.test(b.phone)||(N.phone="Phone number must contain 7-15 digits"):N.phone="Phone number is required"),k(N),Object.keys(N).length>0)return;let D="";switch(x){case"email_password":D="plain_email";break;case"username_password":D="plain_username";break;case"email_otp":D="email_otp";break;case"email_magic_link":D="magic_link";break;case"phone_otp":D="phone_otp";break}M(!0);try{const Z={...b,strategy:D};x==="phone_otp"&&P&&(Z.phone_country_code=P),await S.create(Z)}catch(Z){k({submit:Z.message}),M(!1)}},q=async W=>{if(W.preventDefault(),z||j)return;const N={};if(!R){N.otp="OTP code is required",k(N);return}M(!0),k({});try{await S.completeVerification(R),g(!1),C("")}catch(D){k({otp:D.message||"Verification failed"})}finally{M(!1)}},H=async W=>{if(!(z||j)){M(!0);try{const D=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Z}=await w.create({provider:W.provider,redirectUri:D});Z&&typeof Z=="object"&&"oauth_url"in Z&&(window.location.href=Z.oauth_url)}catch(N){k({submit:N.message})}finally{M(!1)}}},ee=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const W=new URLSearchParams(window.location.search),N=W.get("impersonation_token");if(N&&!_&&!z&&!ee.current){ee.current=!0,W.delete("impersonation_token");const Z=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",Z),(async()=>{try{M(!0),await S.create({strategy:"impersonation",token:N})}catch(te){k({submit:te.message}),M(!1),ee.current=!1}})();return}const D=W.get("signin_attempt_id");if(D&&(o!=null&&o.signin_attempts)&&!_){const Z=o.signin_attempts.find(ae=>ae.id===D);if(Z){I(Z),W.delete("signin_attempt_id");const ae=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",ae)}}},[o,n,_,I,z]),i.useEffect(()=>{var Z;if(!_)return;if(_.completed){L(!0);let ae=new URLSearchParams(window.location.search).get("redirect_uri");if(ae||(ae=((Z=t==null?void 0:t.ui_settings)==null?void 0:Z.after_signin_redirect_url)||null),!ae&&(t!=null&&t.frontend_host)&&(ae=`https://${t.frontend_host}`),ae){let te;try{te=new URL(ae)}catch{te=new URL(ae,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&te.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(te.toString())}return}if(!S||p)return;const N={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[_.current_step];if(!N)return;(async()=>{try{await S.prepareVerification({strategy:N}),g(!0)}catch(ae){console.error("Failed to prepare verification:",ae),k({submit:"Failed to send verification. Please try again."})}finally{M(!1)}})()},[_,S,p,g,r,t]),i.useEffect(()=>{},[]),l)return e.jsx(Kf,{onBack:()=>u(!1)});if(c)return e.jsx(Vf,{onBack:()=>h(!1)});if((_==null?void 0:_.current_step)==="verify_second_factor")return e.jsx(Cl,{attempt:_,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{E(),J(),g(!1)}});if((_==null?void 0:_.current_step)==="complete_profile")return e.jsx(Sl,{attempt:_,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{E(),J(),g(!1)}});if(n)return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Pa,{children:e.jsx(kt,{size:32})})]})});if(B)return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Pa,{children:e.jsx(kt,{size:32})})]})});const oe=(_==null?void 0:_.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(_.current_step)&&p;return e.jsx(ge,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),oe?e.jsx(e.Fragment,{children:e.jsxs(Ra,{children:[e.jsx(Ta,{children:x==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Ma,{children:x==="email_magic_link"?`If ${b.email} exists in our records, you will receive a magic link. Click the link to sign in.`:x==="phone_otp"?`If ${b.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${b.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(Ra,{children:[e.jsx(Ta,{children:"Sign in to your account"}),e.jsxs(Ma,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),F&&e.jsxs(Pg,{children:[e.jsx(Rg,{children:"Access Denied"}),e.jsx(Tg,{children:F}),e.jsx(Mg,{onClick:()=>O(null),children:"Try again"})]}),oe?x==="email_magic_link"?e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{g(!1),E(),J()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:q,noValidate:!0,children:[e.jsx(Tt,{onComplete:async W=>{if(C(W),W&&W.length===6){M(!0),k({});try{await S.completeVerification(W),g(!1)}catch(N){k({otp:N.message||"Verification failed"})}finally{M(!1)}}},onResend:async()=>{const W=x==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:W})},error:$.otp,isSubmitting:j}),e.jsx(Oa,{type:"submit",disabled:j||z||!R,style:{margin:0},children:j?"Verifying...":`Continue to ${(fe=t==null?void 0:t.ui_settings)==null?void 0:fe.app_name}`})]}),e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{g(!1),E(),J()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[m.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Es,{connections:m,callback:H}),e.jsx($g,{children:e.jsx(Eg,{children:"or"})})]}),e.jsxs(dt,{onSubmit:V,noValidate:!0,children:[(x==="email_password"||x==="email_otp"||x==="email_magic_link")&&((xe=(se=t==null?void 0:t.auth_settings)==null?void 0:se.email_address)==null?void 0:xe.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"email",children:"Email address"}),e.jsx(ce,{type:"email",id:"email",name:"email",value:b.email,onChange:A,placeholder:"Enter your email address","aria-invalid":!!$.email}),$.email&&e.jsx(Mr,{children:$.email})]}),x==="username_password"&&((U=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.username)==null?void 0:U.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(ce,{type:"text",id:"username",name:"username",value:b.username,onChange:A,placeholder:"Enter your username","aria-invalid":!!$.username}),$.username&&e.jsx(Mr,{children:$.username})]}),x==="phone_otp"&&((Q=(pe=t==null?void 0:t.auth_settings)==null?void 0:pe.phone_number)==null?void 0:Q.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"phone",children:"Phone number"}),e.jsx(qr,{value:b.phone,onChange:A,error:$.phone,countryCode:P,setCountryCode:T}),$.phone&&e.jsx(Mr,{children:$.phone})]}),v==="password"&&(x==="email_password"||x==="username_password")&&((ne=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.password)==null?void 0:ne.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ie,{htmlFor:"password",children:"Password"}),e.jsx(Dt,{style:{fontSize:"12px"},onClick:()=>h(!0),children:"Forgot password?"})]}),e.jsx(Ig,{children:e.jsx(ce,{type:"password",id:"password",name:"password",value:b.password,onChange:A,placeholder:"Enter your password","aria-invalid":!!$.password})}),$.password&&e.jsx(Mr,{children:$.password})]}),e.jsxs("div",{children:[$.submit&&e.jsx(Mr,{children:$.submit}),e.jsx(Oa,{type:"submit",disabled:j||z,children:j?e.jsxs(e.Fragment,{children:[e.jsx(kt,{size:16,style:{animation:"spin 1s linear infinite",marginRight:"8px"}}),v==="identifier"?"Checking...":"Signing in..."]}):v==="identifier"?"Continue":"Sign in"})]}),e.jsx(Dt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>u(!0),children:"Use other methods"})]}),e.jsxs(Tn,{children:["Don't have an account?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:`${(me=t.ui_settings)==null?void 0:me.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Aa=d.div`
1695
1695
  max-width: 380px;
1696
1696
  width: 380px;
1697
1697
  padding: var(--space-3xl);
1698
1698
  background: var(--color-background);
1699
1699
  border-radius: var(--radius-lg);
1700
1700
  box-shadow: 0 4px 12px var(--color-shadow);
1701
- `,Ng=d.div`
1701
+ `,Lg=d.div`
1702
1702
  text-align: center;
1703
1703
  margin-bottom: var(--space-lg);
1704
- `,Fg=d.h1`
1704
+ `,Dg=d.h1`
1705
1705
  font-size: var(--font-lg);
1706
1706
  font-weight: 400;
1707
1707
  color: var(--color-foreground);
1708
1708
  margin-bottom: var(--space-xs);
1709
1709
  margin-top: 0;
1710
- `,Bg=d.p`
1710
+ `,Ng=d.p`
1711
1711
  color: var(--color-secondary-text);
1712
1712
  font-size: var(--font-xs);
1713
1713
  margin: 0;
1714
- `,Ug=d.form`
1714
+ `,Fg=d.form`
1715
1715
  display: flex;
1716
1716
  flex-direction: column;
1717
1717
  gap: var(--space-md);
@@ -1719,7 +1719,7 @@ cursor: pointer;
1719
1719
  display: flex;
1720
1720
  flex-direction: column;
1721
1721
  gap: var(--space-xs);
1722
- `,Wg=d.div`
1722
+ `,Bg=d.div`
1723
1723
  display: grid;
1724
1724
  grid-template-columns: ${t=>t.$isBothEnabled?"1fr 1fr":"1fr"};
1725
1725
  gap: var(--space-md);
@@ -1731,7 +1731,7 @@ cursor: pointer;
1731
1731
  `,An=d.span`
1732
1732
  color: var(--color-error);
1733
1733
  margin-left: var(--space-2xs);
1734
- `,Vg=d.button`
1734
+ `,Ug=d.button`
1735
1735
  width: 100%;
1736
1736
  padding: var(--space-sm) var(--space-md);
1737
1737
  border: ${t=>t.$primary?"none":"1px solid var(--color-input-border)"};
@@ -1757,13 +1757,13 @@ cursor: pointer;
1757
1757
  color: var(--color-error);
1758
1758
  font-size: var(--font-2xs);
1759
1759
  margin-top: var(--space-2xs);
1760
- `,Gg=d.div`
1760
+ `,Wg=d.div`
1761
1761
  display: flex;
1762
1762
  flex-direction: column;
1763
1763
  align-items: center;
1764
1764
  gap: var(--space-md);
1765
1765
  text-align: center;
1766
- `,Hg=d.div`
1766
+ `,Vg=d.div`
1767
1767
  width: 48px;
1768
1768
  height: 48px;
1769
1769
  background: var(--color-success);
@@ -1772,27 +1772,27 @@ cursor: pointer;
1772
1772
  align-items: center;
1773
1773
  justify-content: center;
1774
1774
  color: white;
1775
- `,qg=d.h2`
1775
+ `,Gg=d.h2`
1776
1776
  font-size: var(--font-lg);
1777
1777
  color: var(--color-foreground);
1778
1778
  margin: 0;
1779
- `,Yg=d.p`
1779
+ `,Hg=d.p`
1780
1780
  font-size: var(--font-xs);
1781
1781
  color: var(--color-secondary-text);
1782
1782
  margin: 0;
1783
1783
  line-height: 1.5;
1784
- `,Zg=d.div`
1784
+ `,qg=d.div`
1785
1785
  text-align: center;
1786
1786
  margin-top: var(--space-lg);
1787
- `,Kg=d.p`
1787
+ `,Yg=d.p`
1788
1788
  font-size: var(--font-xs);
1789
1789
  color: var(--color-muted);
1790
1790
  margin: 0;
1791
- `,Qg=d.a`
1791
+ `,Zg=d.a`
1792
1792
  color: var(--color-primary);
1793
1793
  text-decoration: none;
1794
1794
  cursor: pointer;
1795
- `;function Xg(){var $,S,k,I,E,w,b,f,z,_,j,M;const{deployment:t}=ve(),{loading:r,joinWaitlist:o}=yc(),[n,s]=i.useState({first_name:"",last_name:"",email:""}),[a,p]=i.useState(!1),[g,c]=i.useState(!1),[h,l]=i.useState(null),u=R=>{if(h)return h.message},m=t==null?void 0:t.auth_settings,v=!!(($=m==null?void 0:m.first_name)!=null&&$.enabled&&((S=m==null?void 0:m.last_name)!=null&&S.enabled)),x=R=>{const{name:C,value:P}=R.target;s(T=>({...T,[C]:P}))},y=async R=>{if(R.preventDefault(),!!m){c(!0),l(null);try{(await o(n)).data&&p(!0)}catch(C){l(C)}finally{c(!1)}}};return a?e.jsx(ge,{children:e.jsx(Aa,{children:e.jsxs(Gg,{children:[e.jsx(Hg,{children:e.jsx(Ve,{size:32})}),e.jsx(qg,{children:"You're on the waitlist!"}),e.jsxs(Yg,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(ge,{children:e.jsxs(Aa,{children:[e.jsx(Pe,{}),e.jsxs(Ng,{children:[e.jsx(Fg,{children:"Join the waitlist"}),e.jsx(Bg,{children:"Be the first to know when we launch!"})]}),e.jsxs(Ug,{onSubmit:y,noValidate:!0,children:[(((k=m==null?void 0:m.first_name)==null?void 0:k.enabled)||((I=m==null?void 0:m.last_name)==null?void 0:I.enabled))&&e.jsxs(Wg,{$isBothEnabled:v,children:[((E=m==null?void 0:m.first_name)==null?void 0:E.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"first_name",children:["First name",((w=m==null?void 0:m.first_name)==null?void 0:w.required)&&e.jsx(An,{children:"*"})]}),e.jsx(ce,{type:"text",id:"first_name",name:"first_name",required:(b=m==null?void 0:m.first_name)==null?void 0:b.required,minLength:2,maxLength:50,value:n.first_name,onChange:x,placeholder:"First name","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]}),((f=m==null?void 0:m.last_name)==null?void 0:f.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"last_name",children:["Last name",((z=m==null?void 0:m.last_name)==null?void 0:z.required)&&e.jsx(An,{children:"*"})]}),e.jsx(ce,{type:"text",id:"last_name",name:"last_name",required:(_=m==null?void 0:m.last_name)==null?void 0:_.required,minLength:2,maxLength:50,value:n.last_name,onChange:x,placeholder:"Last name","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]})]}),e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"email",children:["Email address",((j=m==null?void 0:m.email_address)==null?void 0:j.required)&&e.jsx(An,{children:"*"})]}),e.jsx(ce,{type:"email",id:"email",name:"email",required:(M=m==null?void 0:m.email_address)==null?void 0:M.required,value:n.email,onChange:x,placeholder:"Enter your email address","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]}),u()&&e.jsx(co,{children:u()}),e.jsx(Vg,{type:"submit",$primary:!0,disabled:g||r,children:g||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(Zg,{children:e.jsxs(Kg,{children:["Need assistance? ",e.jsx(Qg,{href:"/contact",children:"Get help"})]})})]})})}const lo=d.div`
1795
+ `;function Kg(){var z,S,_,E,I,w,b,f,$,k,j,M;const{deployment:t}=ve(),{loading:r,joinWaitlist:o}=yc(),[n,s]=i.useState({first_name:"",last_name:"",email:""}),[a,p]=i.useState(!1),[g,c]=i.useState(!1),[h,l]=i.useState(null),u=R=>{if(h)return h.message},m=t==null?void 0:t.auth_settings,x=!!((z=m==null?void 0:m.first_name)!=null&&z.enabled&&((S=m==null?void 0:m.last_name)!=null&&S.enabled)),v=R=>{const{name:C,value:P}=R.target;s(T=>({...T,[C]:P}))},y=async R=>{if(R.preventDefault(),!!m){c(!0),l(null);try{(await o(n)).data&&p(!0)}catch(C){l(C)}finally{c(!1)}}};return a?e.jsx(ge,{children:e.jsx(Aa,{children:e.jsxs(Wg,{children:[e.jsx(Vg,{children:e.jsx(Ve,{size:32})}),e.jsx(Gg,{children:"You're on the waitlist!"}),e.jsxs(Hg,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(ge,{children:e.jsxs(Aa,{children:[e.jsx(Pe,{}),e.jsxs(Lg,{children:[e.jsx(Dg,{children:"Join the waitlist"}),e.jsx(Ng,{children:"Be the first to know when we launch!"})]}),e.jsxs(Fg,{onSubmit:y,noValidate:!0,children:[(((_=m==null?void 0:m.first_name)==null?void 0:_.enabled)||((E=m==null?void 0:m.last_name)==null?void 0:E.enabled))&&e.jsxs(Bg,{$isBothEnabled:x,children:[((I=m==null?void 0:m.first_name)==null?void 0:I.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"first_name",children:["First name",((w=m==null?void 0:m.first_name)==null?void 0:w.required)&&e.jsx(An,{children:"*"})]}),e.jsx(ce,{type:"text",id:"first_name",name:"first_name",required:(b=m==null?void 0:m.first_name)==null?void 0:b.required,minLength:2,maxLength:50,value:n.first_name,onChange:v,placeholder:"First name","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]}),((f=m==null?void 0:m.last_name)==null?void 0:f.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"last_name",children:["Last name",(($=m==null?void 0:m.last_name)==null?void 0:$.required)&&e.jsx(An,{children:"*"})]}),e.jsx(ce,{type:"text",id:"last_name",name:"last_name",required:(k=m==null?void 0:m.last_name)==null?void 0:k.required,minLength:2,maxLength:50,value:n.last_name,onChange:v,placeholder:"Last name","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]})]}),e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"email",children:["Email address",((j=m==null?void 0:m.email_address)==null?void 0:j.required)&&e.jsx(An,{children:"*"})]}),e.jsx(ce,{type:"email",id:"email",name:"email",required:(M=m==null?void 0:m.email_address)==null?void 0:M.required,value:n.email,onChange:v,placeholder:"Enter your email address","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]}),u()&&e.jsx(co,{children:u()}),e.jsx(Ug,{type:"submit",$primary:!0,disabled:g||r,children:g||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(qg,{children:e.jsxs(Yg,{children:["Need assistance? ",e.jsx(Zg,{href:"/contact",children:"Get help"})]})})]})})}const lo=d.div`
1796
1796
  max-width: 380px;
1797
1797
  width: 380px;
1798
1798
  padding: var(--space-3xl);
@@ -1816,7 +1816,7 @@ cursor: pointer;
1816
1816
  `,fo=d.div`
1817
1817
  padding-top: var(--space-xl);
1818
1818
  text-align: center;
1819
- `,Jg=d.div`
1819
+ `,Qg=d.div`
1820
1820
  width: calc(var(--space-3xl) * 2);
1821
1821
  height: calc(var(--space-3xl) * 2);
1822
1822
  border-radius: 50%;
@@ -1844,7 +1844,7 @@ cursor: pointer;
1844
1844
  transform: rotate(360deg);
1845
1845
  }
1846
1846
  }
1847
- `,em=d.div`
1847
+ `,Xg=d.div`
1848
1848
  width: calc(var(--space-3xl) * 2);
1849
1849
  height: calc(var(--space-3xl) * 2);
1850
1850
  border-radius: 50%;
@@ -1863,12 +1863,12 @@ cursor: pointer;
1863
1863
  font-size: var(--font-xs);
1864
1864
  color: var(--color-secondary-text);
1865
1865
  margin-bottom: var(--space-lg);
1866
- `,tm=d.div`
1866
+ `,Jg=d.div`
1867
1867
  margin-top: var(--space-xl);
1868
1868
  text-align: center;
1869
1869
  font-size: var(--font-xs);
1870
1870
  color: var(--color-secondary-text);
1871
- `,rm=d.span`
1871
+ `,em=d.span`
1872
1872
  color: var(--color-primary);
1873
1873
  text-decoration: none;
1874
1874
  font-weight: 400;
@@ -1879,30 +1879,30 @@ cursor: pointer;
1879
1879
  color: var(--color-primary-hover);
1880
1880
  text-decoration: underline;
1881
1881
  }
1882
- `;function om(){const{deployment:t}=ve(),{navigate:r}=Ge(),{error:o,session:n,processed:s,signinAttempt:a,redirectUri:p,loading:g}=wc(),c=()=>{window.location.reload()},h=()=>{var u;const l=((u=t==null?void 0:t.ui_settings)==null?void 0:u.sign_in_page_url)||"/sign-in";r(l)};if(i.useEffect(()=>{var l,u;if(!(!s||g)){if(a&&!a.completed){const m=(l=t==null?void 0:t.ui_settings)==null?void 0:l.sign_in_page_url;if(m){const v=new URL(m,window.location.origin);v.searchParams.set("signin_attempt_id",a.id),p&&v.searchParams.set("redirect_uri",p),r(v.toString())}return}if(a!=null&&a.completed){const m=p||((u=t==null?void 0:t.ui_settings)==null?void 0:u.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let v;try{v=new URL(m)}catch{v=new URL(m,window.location.origin)}v&&((t==null?void 0:t.mode)==="staging"&&v.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(v.toString()))}}},[n,s,g,p,t,a,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var u;const l=((u=t==null?void 0:t.ui_settings)==null?void 0:u.sign_in_page_url)||(t==null?void 0:t.frontend_host);l&&r(l)},2e3)},[o,t,r]),g&&!s)return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Completing sign in"}),e.jsx(ho,{children:"Please wait while we authenticate you"})]}),e.jsxs(fo,{children:[e.jsx(La,{}),e.jsx(go,{children:"Verifying your credentials..."}),e.jsx(mo,{children:"This will only take a moment."})]})]})});if(n&&s&&!o)return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Success!"}),e.jsx(ho,{children:"Authentication completed successfully"})]}),e.jsxs(fo,{children:[e.jsx(em,{children:"✓"}),e.jsx(go,{children:"Redirecting you now..."}),e.jsx(mo,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const l=o.message.includes("No OAuth callback data found");return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Something went wrong"}),e.jsx(ho,{children:"We couldn't complete your sign in"})]}),e.jsxs(fo,{children:[e.jsx(Jg,{children:"✗"}),e.jsx(go,{children:"Authentication Failed"}),e.jsx(mo,{children:o.message||"An unexpected error occurred during authentication."}),!l&&e.jsx(X,{onClick:c,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!l&&e.jsx(tm,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(rm,{onClick:h,children:"Return to sign in"})]})})]})})}return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Completing sign in"}),e.jsx(ho,{children:"Please wait while we authenticate you"})]}),e.jsxs(fo,{children:[e.jsx(La,{}),e.jsx(go,{children:"Verifying your credentials..."}),e.jsx(mo,{children:"This will only take a moment."})]})]})})}const nm=d.div`
1882
+ `;function tm(){const{deployment:t}=ve(),{navigate:r}=Ge(),{error:o,session:n,processed:s,signinAttempt:a,redirectUri:p,loading:g}=wc(),c=()=>{window.location.reload()},h=()=>{var u;const l=((u=t==null?void 0:t.ui_settings)==null?void 0:u.sign_in_page_url)||"/sign-in";r(l)};if(i.useEffect(()=>{var l,u;if(!(!s||g)){if(a&&!a.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",a.id),p&&x.searchParams.set("redirect_uri",p),r(x.toString())}return}if(a!=null&&a.completed){const m=p||((u=t==null?void 0:t.ui_settings)==null?void 0:u.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let x;try{x=new URL(m)}catch{x=new URL(m,window.location.origin)}x&&((t==null?void 0:t.mode)==="staging"&&x.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(x.toString()))}}},[n,s,g,p,t,a,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var u;const l=((u=t==null?void 0:t.ui_settings)==null?void 0:u.sign_in_page_url)||(t==null?void 0:t.frontend_host);l&&r(l)},2e3)},[o,t,r]),g&&!s)return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Completing sign in"}),e.jsx(ho,{children:"Please wait while we authenticate you"})]}),e.jsxs(fo,{children:[e.jsx(La,{}),e.jsx(go,{children:"Verifying your credentials..."}),e.jsx(mo,{children:"This will only take a moment."})]})]})});if(n&&s&&!o)return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Success!"}),e.jsx(ho,{children:"Authentication completed successfully"})]}),e.jsxs(fo,{children:[e.jsx(Xg,{children:"✓"}),e.jsx(go,{children:"Redirecting you now..."}),e.jsx(mo,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const l=o.message.includes("No OAuth callback data found");return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Something went wrong"}),e.jsx(ho,{children:"We couldn't complete your sign in"})]}),e.jsxs(fo,{children:[e.jsx(Qg,{children:"✗"}),e.jsx(go,{children:"Authentication Failed"}),e.jsx(mo,{children:o.message||"An unexpected error occurred during authentication."}),!l&&e.jsx(X,{onClick:c,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!l&&e.jsx(Jg,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(em,{onClick:h,children:"Return to sign in"})]})})]})})}return e.jsx(ge,{children:e.jsxs(lo,{children:[e.jsxs(uo,{children:[e.jsx(po,{children:"Completing sign in"}),e.jsx(ho,{children:"Please wait while we authenticate you"})]}),e.jsxs(fo,{children:[e.jsx(La,{}),e.jsx(go,{children:"Verifying your credentials..."}),e.jsx(mo,{children:"This will only take a moment."})]})]})})}const rm=d.div`
1883
1883
  max-width: 380px;
1884
1884
  width: 380px;
1885
1885
  padding: var(--space-3xl);
1886
1886
  background: var(--color-background);
1887
1887
  border-radius: var(--radius-lg);
1888
1888
  box-shadow: 0 4px 12px var(--color-shadow);
1889
- `,sm=d.div`
1889
+ `,om=d.div`
1890
1890
  text-align: center;
1891
1891
  position: relative;
1892
- `,am=d.h1`
1892
+ `,nm=d.h1`
1893
1893
  font-size: var(--font-lg);
1894
1894
  font-weight: 400;
1895
1895
  color: var(--color-foreground);
1896
1896
  margin-bottom: var(--space-xs);
1897
1897
  margin-top: 0;
1898
- `,im=d.p`
1898
+ `,sm=d.p`
1899
1899
  color: var(--color-secondary-text);
1900
1900
  font-size: var(--font-xs);
1901
1901
  margin: 0;
1902
- `,cm=d.div`
1902
+ `,am=d.div`
1903
1903
  padding-top: var(--space-xl);
1904
1904
  text-align: center;
1905
- `,lm=d.div`
1905
+ `,im=d.div`
1906
1906
  width: calc(var(--space-3xl) * 2);
1907
1907
  height: calc(var(--space-3xl) * 2);
1908
1908
  border-radius: 50%;
@@ -1913,7 +1913,7 @@ cursor: pointer;
1913
1913
  margin: 0 auto var(--space-lg) auto;
1914
1914
  color: var(--color-success);
1915
1915
  font-size: var(--font-xl);
1916
- `,dm=d.div`
1916
+ `,cm=d.div`
1917
1917
  width: calc(var(--space-3xl) * 2);
1918
1918
  height: calc(var(--space-3xl) * 2);
1919
1919
  border-radius: 50%;
@@ -1924,7 +1924,7 @@ cursor: pointer;
1924
1924
  margin: 0 auto var(--space-lg) auto;
1925
1925
  color: var(--color-error);
1926
1926
  font-size: var(--font-xl);
1927
- `,um=d.div`
1927
+ `,lm=d.div`
1928
1928
  width: calc(var(--space-3xl) * 2);
1929
1929
  height: calc(var(--space-3xl) * 2);
1930
1930
  border: 3px solid var(--color-border);
@@ -1944,7 +1944,7 @@ cursor: pointer;
1944
1944
  `,Ln=d.p`
1945
1945
  font-size: var(--font-xs);
1946
1946
  color: var(--color-secondary-text);
1947
- `;function pm({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[s,a]=i.useState(""),{token:p,attempt:g,redirectUri:c}=_c(),{verifyMagicLink:h}=jc(),{navigate:l}=Ge(),{deployment:u}=ve(),m=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!m.current){if(!p||!g){n("error"),a("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}m.current=!0,n("loading"),a("Please wait while we verify your magic link.");try{await h({token:p,attempt:g,redirectUri:c}),n("success"),a("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var $;let y=c;if(y||(y=($=u==null?void 0:u.ui_settings)==null?void 0:$.after_signin_redirect_url),!y&&(u!=null&&u.frontend_host)&&(y=`https://${u.frontend_host}`),y){const S=new URL(y);(u==null?void 0:u.mode)==="staging"&&S.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),l(S.toString())}},2e3)}catch(y){n("error"),a("The magic link may have expired or already been used. Please try signing in again."),r==null||r(y.message)}}})()},[p,g]);const v=()=>{var x;(x=u==null?void 0:u.ui_settings)!=null&&x.sign_in_page_url&&l(u.ui_settings.sign_in_page_url)};return e.jsx(ge,{children:e.jsxs(nm,{children:[e.jsxs(sm,{children:[e.jsx(am,{children:"Magic Link Verification"}),e.jsx(im,{children:"Verifying your magic link"})]}),e.jsxs(cm,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(um,{}),e.jsx(Ln,{children:s})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(lm,{children:"✓"}),e.jsx(Ln,{children:s})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(dm,{children:"✗"}),e.jsx(Ln,{children:s}),e.jsx(X,{onClick:v,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function hm(t){var n,s;return t?((n=t.signin_attempts)==null?void 0:n.find(a=>a.requires_completion&&!a.completed))?!0:!!((s=t.signup_attempts)==null?void 0:s.find(a=>{var p,g;return((p=a.missing_fields)==null?void 0:p.length)>0||((g=a.remaining_steps)==null?void 0:g.length)>0&&!a.completed})):!1}function fm(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Nt=d.div`
1947
+ `;function dm({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[s,a]=i.useState(""),{token:p,attempt:g,redirectUri:c}=_c(),{verifyMagicLink:h}=jc(),{navigate:l}=Ge(),{deployment:u}=ve(),m=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!m.current){if(!p||!g){n("error"),a("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}m.current=!0,n("loading"),a("Please wait while we verify your magic link.");try{await h({token:p,attempt:g,redirectUri:c}),n("success"),a("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var z;let y=c;if(y||(y=(z=u==null?void 0:u.ui_settings)==null?void 0:z.after_signin_redirect_url),!y&&(u!=null&&u.frontend_host)&&(y=`https://${u.frontend_host}`),y){const S=new URL(y);(u==null?void 0:u.mode)==="staging"&&S.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),l(S.toString())}},2e3)}catch(y){n("error"),a("The magic link may have expired or already been used. Please try signing in again."),r==null||r(y.message)}}})()},[p,g]);const x=()=>{var v;(v=u==null?void 0:u.ui_settings)!=null&&v.sign_in_page_url&&l(u.ui_settings.sign_in_page_url)};return e.jsx(ge,{children:e.jsxs(rm,{children:[e.jsxs(om,{children:[e.jsx(nm,{children:"Magic Link Verification"}),e.jsx(sm,{children:"Verifying your magic link"})]}),e.jsxs(am,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(lm,{}),e.jsx(Ln,{children:s})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(im,{children:"✓"}),e.jsx(Ln,{children:s})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(cm,{children:"✗"}),e.jsx(Ln,{children:s}),e.jsx(X,{onClick:x,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function um(t){var n,s;return t?((n=t.signin_attempts)==null?void 0:n.find(a=>a.requires_completion&&!a.completed))?!0:!!((s=t.signup_attempts)==null?void 0:s.find(a=>{var p,g;return((p=a.missing_fields)==null?void 0:p.length)>0||((g=a.remaining_steps)==null?void 0:g.length)>0&&!a.completed})):!1}function pm(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Nt=d.div`
1948
1948
  max-width: 380px;
1949
1949
  width: 380px;
1950
1950
  padding: var(--space-3xl);
@@ -1968,7 +1968,7 @@ cursor: pointer;
1968
1968
  `,Wt=d.div`
1969
1969
  padding-top: var(--space-xl);
1970
1970
  text-align: center;
1971
- `,gm=d.div`
1971
+ `,hm=d.div`
1972
1972
  width: calc(var(--space-3xl) * 2);
1973
1973
  height: calc(var(--space-3xl) * 2);
1974
1974
  border-radius: 50%;
@@ -2001,7 +2001,7 @@ cursor: pointer;
2001
2001
  margin: 0 auto var(--space-lg) auto;
2002
2002
  color: var(--color-info);
2003
2003
  font-size: var(--font-xl);
2004
- `,mm=d.div`
2004
+ `,fm=d.div`
2005
2005
  width: calc(var(--space-3xl) * 2);
2006
2006
  height: calc(var(--space-3xl) * 2);
2007
2007
  border: 3px solid var(--color-border);
@@ -2029,12 +2029,12 @@ cursor: pointer;
2029
2029
  `,Na=d.span`
2030
2030
  color: var(--color-primary);
2031
2031
  font-weight: 400;
2032
- `,xm=d.div`
2032
+ `,gm=d.div`
2033
2033
  margin-top: var(--space-xl);
2034
2034
  text-align: center;
2035
2035
  font-size: var(--font-xs);
2036
2036
  color: var(--color-secondary-text);
2037
- `,vm=d.span`
2037
+ `,mm=d.span`
2038
2038
  color: var(--color-primary);
2039
2039
  text-decoration: none;
2040
2040
  font-weight: 400;
@@ -2044,11 +2044,11 @@ cursor: pointer;
2044
2044
  &:hover {
2045
2045
  color: var(--color-primary-hover);
2046
2046
  }
2047
- `;function bm({token:t,onSuccess:r,onError:o}){var y;const{acceptInvitation:n,invitationData:s,loading:a,error:p}=$c(),{navigate:g}=Ge(),{deployment:c}=ve(),h=i.useRef(!1),l=()=>{var S;const $=new URLSearchParams(window.location.search);return{token:t||$.get("invite_token")||$.get("token"),redirectUri:$.get("redirect_uri")||((S=c==null?void 0:c.ui_settings)==null?void 0:S.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(h.current)return;const{token:$}=l();$&&(h.current=!0,n($))},[n]),i.useEffect(()=>{var $;s&&(s.organization&&!s.requires_signin&&r&&r(s.organization.id,($=s.workspace)==null?void 0:$.id),s.error_code&&o&&o(s.message||"Failed to accept invitation"))},[s,r,o]);const u=()=>{const{redirectUri:$}=l();g($)},m=()=>{var f,z;const{token:$}=l(),S=((f=c==null?void 0:c.ui_settings)==null?void 0:f.sign_in_page_url)||"/sign-in",k=((z=c==null?void 0:c.ui_settings)==null?void 0:z.sign_up_page_url)||"/sign-up",I=new URLSearchParams;$&&I.set("invite_token",$),s!=null&&s.invited_email&&I.set("invited_email",s.invited_email);const w=`${window.location.pathname}?token=${$}`;I.set("redirect_uri",w),s!=null&&s.message&&I.set("message",s.message);const b=(s==null?void 0:s.error_code)==="INVITATION_REQUIRES_SIGNUP";g(`${b?k:S}?${I.toString()}`)},v=()=>{const{token:$}=l();$&&(h.current=!1,n($))},{token:x}=l();if(!x&&!a)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invalid Invitation"}),e.jsx(Ut,{children:"No invitation token found"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Missing Invitation Token"}),e.jsx(Gt,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(X,{onClick:()=>g("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(a)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Processing Invitation"}),e.jsx(Ut,{children:"Please wait while we verify your invitation"})]}),e.jsxs(Wt,{children:[e.jsx(mm,{}),e.jsx(Vt,{children:"Verifying invitation..."}),e.jsx(Gt,{children:"This will only take a moment."})]})]})});if(s!=null&&s.organization&&!s.requires_signin)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Accepted!"}),e.jsx(Ut,{children:"You've successfully joined the organization"})]}),e.jsxs(Wt,{children:[e.jsx(gm,{children:"✓"}),e.jsxs(Vt,{children:["Welcome to ",s.organization.name,"!"]}),s.workspace&&e.jsxs(Gt,{children:["You've been added to the ",s.workspace.name," workspace."]}),e.jsx(X,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.already_member)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Already a Member"}),e.jsx(Ut,{children:"You're already part of this organization"})]}),e.jsxs(Wt,{children:[e.jsx(Da,{children:"ℹ"}),e.jsxs(Vt,{children:["You're already a member of ",((y=s.organization)==null?void 0:y.name)||"this organization"]}),e.jsx(Gt,{children:"No action needed - you already have access."}),e.jsx(X,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.requires_signin){const $=s.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:$?"Sign Up Required":"Sign In Required"}),e.jsx(Ut,{children:"To accept this invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Da,{children:"ℹ"}),e.jsxs(Vt,{children:["This invitation is for ",e.jsx(Na,{children:s.invited_email})]}),e.jsx(Gt,{children:$?"You need to create an account with this email address to accept the invitation.":s.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(X,{onClick:m,style:{marginTop:"var(--space-lg)"},children:$?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(s==null?void 0:s.error_code)==="INVITATION_EXPIRED"?e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Expired"}),e.jsx(Ut,{children:"This invitation is no longer valid"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"⏱"}),e.jsxs(Vt,{children:["Invitation for ",e.jsx(Na,{children:s.invited_email})," has expired"]}),e.jsx(Gt,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):p||s!=null&&s.error_code?e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Error"}),e.jsx(Ut,{children:"Unable to process invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Something went wrong"}),e.jsx(Gt,{children:(s==null?void 0:s.message)||p||"Failed to accept invitation"}),e.jsx(X,{onClick:v,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(xm,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(vm,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const Ps=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),He=()=>{const t=i.useContext(Ps);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},ym=d.div`
2047
+ `;function xm({token:t,onSuccess:r,onError:o}){var y;const{acceptInvitation:n,invitationData:s,loading:a,error:p}=$c(),{navigate:g}=Ge(),{deployment:c}=ve(),h=i.useRef(!1),l=()=>{var S;const z=new URLSearchParams(window.location.search);return{token:t||z.get("invite_token")||z.get("token"),redirectUri:z.get("redirect_uri")||((S=c==null?void 0:c.ui_settings)==null?void 0:S.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(h.current)return;const{token:z}=l();z&&(h.current=!0,n(z))},[n]),i.useEffect(()=>{var z;s&&(s.organization&&!s.requires_signin&&r&&r(s.organization.id,(z=s.workspace)==null?void 0:z.id),s.error_code&&o&&o(s.message||"Failed to accept invitation"))},[s,r,o]);const u=()=>{const{redirectUri:z}=l();g(z)},m=()=>{var f,$;const{token:z}=l(),S=((f=c==null?void 0:c.ui_settings)==null?void 0:f.sign_in_page_url)||"/sign-in",_=(($=c==null?void 0:c.ui_settings)==null?void 0:$.sign_up_page_url)||"/sign-up",E=new URLSearchParams;z&&E.set("invite_token",z),s!=null&&s.invited_email&&E.set("invited_email",s.invited_email);const w=`${window.location.pathname}?token=${z}`;E.set("redirect_uri",w),s!=null&&s.message&&E.set("message",s.message);const b=(s==null?void 0:s.error_code)==="INVITATION_REQUIRES_SIGNUP";g(`${b?_:S}?${E.toString()}`)},x=()=>{const{token:z}=l();z&&(h.current=!1,n(z))},{token:v}=l();if(!v&&!a)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invalid Invitation"}),e.jsx(Ut,{children:"No invitation token found"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Missing Invitation Token"}),e.jsx(Gt,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(X,{onClick:()=>g("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(a)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Processing Invitation"}),e.jsx(Ut,{children:"Please wait while we verify your invitation"})]}),e.jsxs(Wt,{children:[e.jsx(fm,{}),e.jsx(Vt,{children:"Verifying invitation..."}),e.jsx(Gt,{children:"This will only take a moment."})]})]})});if(s!=null&&s.organization&&!s.requires_signin)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Accepted!"}),e.jsx(Ut,{children:"You've successfully joined the organization"})]}),e.jsxs(Wt,{children:[e.jsx(hm,{children:"✓"}),e.jsxs(Vt,{children:["Welcome to ",s.organization.name,"!"]}),s.workspace&&e.jsxs(Gt,{children:["You've been added to the ",s.workspace.name," workspace."]}),e.jsx(X,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.already_member)return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Already a Member"}),e.jsx(Ut,{children:"You're already part of this organization"})]}),e.jsxs(Wt,{children:[e.jsx(Da,{children:"ℹ"}),e.jsxs(Vt,{children:["You're already a member of ",((y=s.organization)==null?void 0:y.name)||"this organization"]}),e.jsx(Gt,{children:"No action needed - you already have access."}),e.jsx(X,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(s!=null&&s.requires_signin){const z=s.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:z?"Sign Up Required":"Sign In Required"}),e.jsx(Ut,{children:"To accept this invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Da,{children:"ℹ"}),e.jsxs(Vt,{children:["This invitation is for ",e.jsx(Na,{children:s.invited_email})]}),e.jsx(Gt,{children:z?"You need to create an account with this email address to accept the invitation.":s.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(X,{onClick:m,style:{marginTop:"var(--space-lg)"},children:z?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(s==null?void 0:s.error_code)==="INVITATION_EXPIRED"?e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Expired"}),e.jsx(Ut,{children:"This invitation is no longer valid"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"⏱"}),e.jsxs(Vt,{children:["Invitation for ",e.jsx(Na,{children:s.invited_email})," has expired"]}),e.jsx(Gt,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):p||s!=null&&s.error_code?e.jsx(ge,{children:e.jsxs(Nt,{children:[e.jsxs(Ft,{children:[e.jsx(Bt,{children:"Invitation Error"}),e.jsx(Ut,{children:"Unable to process invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Something went wrong"}),e.jsx(Gt,{children:(s==null?void 0:s.message)||p||"Failed to accept invitation"}),e.jsx(X,{onClick:x,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(gm,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(mm,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const Ps=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),He=()=>{const t=i.useContext(Ps);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},vm=d.div`
2048
2048
  display: flex;
2049
2049
  height: 100%;
2050
2050
  min-height: 400px;
2051
- `,wm=d.div`
2051
+ `,bm=d.div`
2052
2052
  width: 35%;
2053
2053
  background: var(--color-background-hover);
2054
2054
  padding: 32px;
@@ -2058,7 +2058,7 @@ cursor: pointer;
2058
2058
  justify-content: center;
2059
2059
  text-align: center;
2060
2060
  border-right: 1px solid var(--color-border);
2061
- `,jm=d.div`
2061
+ `,ym=d.div`
2062
2062
  flex: 1;
2063
2063
  padding: 32px;
2064
2064
  display: flex;
@@ -2082,11 +2082,11 @@ cursor: pointer;
2082
2082
  border-color: var(--color-border-hover);
2083
2083
  transform: scale(1.02);
2084
2084
  }
2085
- `,_m=d.img`
2085
+ `,wm=d.img`
2086
2086
  width: 100%;
2087
2087
  height: 100%;
2088
2088
  object-fit: cover;
2089
- `,km=d.div`
2089
+ `,jm=d.div`
2090
2090
  font-size: 32px;
2091
2091
  font-weight: 600;
2092
2092
  color: var(--color-muted);
@@ -2096,28 +2096,28 @@ cursor: pointer;
2096
2096
  display: flex;
2097
2097
  align-items: center;
2098
2098
  justify-content: center;
2099
- `,Cm=d.h2`
2099
+ `,_m=d.h2`
2100
2100
  font-size: 16px;
2101
2101
  font-weight: 400;
2102
2102
  color: var(--color-foreground);
2103
2103
  margin-bottom: 8px;
2104
- `,Sm=d.p`
2104
+ `,km=d.p`
2105
2105
  font-size: 13px;
2106
2106
  color: var(--color-secondary-text);
2107
2107
  line-height: 1.4;
2108
2108
  max-width: 200px;
2109
- `,zm=d.div`
2109
+ `,Cm=d.div`
2110
2110
  margin-bottom: 24px;
2111
- `,$m=d.h3`
2111
+ `,Sm=d.h3`
2112
2112
  font-size: 16px;
2113
2113
  font-weight: 400;
2114
2114
  color: var(--color-foreground);
2115
2115
  margin-bottom: 6px;
2116
- `,Em=d.p`
2116
+ `,zm=d.p`
2117
2117
  font-size: 13px;
2118
2118
  color: var(--color-secondary-text);
2119
2119
  line-height: 1.4;
2120
- `,Im=d.div`
2120
+ `,$m=d.div`
2121
2121
  flex: 1;
2122
2122
  `,Fa=d.div`
2123
2123
  margin-bottom: 20px;
@@ -2127,7 +2127,7 @@ cursor: pointer;
2127
2127
  font-size: 13px;
2128
2128
  font-weight: 400;
2129
2129
  color: var(--color-foreground);
2130
- `,Pm=d.input`
2130
+ `,Em=d.input`
2131
2131
  width: 100%;
2132
2132
  padding: 8px 12px;
2133
2133
  border: 1px solid var(--color-border);
@@ -2147,7 +2147,7 @@ cursor: pointer;
2147
2147
  &::placeholder {
2148
2148
  color: var(--color-muted);
2149
2149
  }
2150
- `,Rm=d.textarea`
2150
+ `,Im=d.textarea`
2151
2151
  width: 100%;
2152
2152
  padding: 8px 12px;
2153
2153
  border: 1px solid var(--color-border);
@@ -2170,13 +2170,13 @@ cursor: pointer;
2170
2170
  &::placeholder {
2171
2171
  color: var(--color-muted);
2172
2172
  }
2173
- `,Tm=d.div`
2173
+ `,Pm=d.div`
2174
2174
  display: flex;
2175
2175
  justify-content: space-between;
2176
2176
  align-items: center;
2177
2177
  margin-top: auto;
2178
2178
  padding-top: 24px;
2179
- `,Mm=d.button`
2179
+ `,Rm=d.button`
2180
2180
  display: flex;
2181
2181
  align-items: center;
2182
2182
  gap: 6px;
@@ -2192,7 +2192,7 @@ cursor: pointer;
2192
2192
  &:hover {
2193
2193
  color: var(--color-foreground);
2194
2194
  }
2195
- `,Om=d.button`
2195
+ `,Tm=d.button`
2196
2196
  padding: 8px 20px;
2197
2197
  border-radius: 6px;
2198
2198
  font-size: 14px;
@@ -2213,9 +2213,9 @@ cursor: pointer;
2213
2213
  opacity: 0.5;
2214
2214
  cursor: not-allowed;
2215
2215
  }
2216
- `,Am=d.input`
2216
+ `,Mm=d.input`
2217
2217
  display: none;
2218
- `,Lm=d.div`
2218
+ `,Om=d.div`
2219
2219
  position: absolute;
2220
2220
  inset: 0;
2221
2221
  background: var(--color-dialog-backdrop);
@@ -2229,11 +2229,11 @@ cursor: pointer;
2229
2229
  ${zl}:hover & {
2230
2230
  opacity: 1;
2231
2231
  }
2232
- `,Dm=d.div`
2232
+ `,Am=d.div`
2233
2233
  color: white;
2234
2234
  font-size: 12px;
2235
2235
  font-weight: 400;
2236
- `,an=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[s,a]=i.useState(""),[p,g]=i.useState(),[c,h]=i.useState(null),[l,u]=i.useState(!1),m=i.useRef(null),{createOrganization:v}=Yo(),{toast:x}=He(),y=b=>{n(b)},$=b=>{if(b.target.files&&b.target.files[0]){const f=b.target.files[0];if(f.size>2*1024*1024){x("File size cannot exceed 2MB","error");return}if(!f.type.startsWith("image/")){x("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),g(f),h(URL.createObjectURL(f))}},S=()=>{var b;(b=m.current)==null||b.click()},k=b=>b.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const I=b=>b.trim().replace(/[<>\"'&]/g,""),E=b=>b.length>=2&&b.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(b),w=async()=>{const b=I(o),f=I(s);if(!b){x("Please enter an organization name","error");return}if(!E(b)){x("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(f.length>500){x("Description must be less than 500 characters","error");return}u(!0);try{const z=await v({name:b,description:f,image:p});t==null||t(z)}catch(z){const _=z.message||"Failed to create organization. Please try again.";x(_,"error")}finally{u(!1)}};return e.jsx(ge,{children:e.jsxs(ym,{children:[e.jsxs(wm,{children:[e.jsxs(zl,{hasImage:!!c,onClick:S,children:[c?e.jsx(_m,{src:c,alt:"Organization logo"}):e.jsx(km,{children:k(o||"O")}),e.jsx(Lm,{children:e.jsx(Dm,{children:"Upload Logo"})})]}),e.jsx(Am,{type:"file",ref:m,onChange:$,accept:"image/png, image/jpeg, image/gif",disabled:l}),e.jsx(Cm,{children:"Create new organization"}),e.jsx(Sm,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(jm,{children:[e.jsxs(zm,{children:[e.jsx($m,{children:"Choose your organization name"}),e.jsx(Em,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(Im,{children:[e.jsxs(Fa,{children:[e.jsx(Ba,{children:"Organization name"}),e.jsx(Pm,{type:"text",value:o,onChange:b=>y(b.target.value),placeholder:"Acme Inc.",disabled:l})]}),e.jsxs(Fa,{children:[e.jsx(Ba,{children:"Description (optional)"}),e.jsx(Rm,{value:s,onChange:b=>a(b.target.value),placeholder:"What does your organization do?",disabled:l})]})]}),e.jsxs(Tm,{children:[r?e.jsxs(Mm,{onClick:r,disabled:l,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Om,{onClick:w,disabled:l||!o.trim(),children:l?"Creating...":"Create"})]})]})]})})},Nm=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(ge,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:n,onCancel:r})})})})})})},Fm=d.div`
2236
+ `,an=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[s,a]=i.useState(""),[p,g]=i.useState(),[c,h]=i.useState(null),[l,u]=i.useState(!1),m=i.useRef(null),{createOrganization:x}=Yo(),{toast:v}=He(),y=b=>{n(b)},z=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))}},S=()=>{var b;(b=m.current)==null||b.click()},_=b=>b.split(" ").map(f=>f[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const E=b=>b.trim().replace(/[<>\"'&]/g,""),I=b=>b.length>=2&&b.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(b),w=async()=>{const b=E(o),f=E(s);if(!b){v("Please enter an organization name","error");return}if(!I(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}u(!0);try{const $=await x({name:b,description:f,image:p});t==null||t($)}catch($){const k=$.message||"Failed to create organization. Please try again.";v(k,"error")}finally{u(!1)}};return e.jsx(ge,{children:e.jsxs(vm,{children:[e.jsxs(bm,{children:[e.jsxs(zl,{hasImage:!!c,onClick:S,children:[c?e.jsx(wm,{src:c,alt:"Organization logo"}):e.jsx(jm,{children:_(o||"O")}),e.jsx(Om,{children:e.jsx(Am,{children:"Upload Logo"})})]}),e.jsx(Mm,{type:"file",ref:m,onChange:z,accept:"image/png, image/jpeg, image/gif",disabled:l}),e.jsx(_m,{children:"Create new organization"}),e.jsx(km,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(ym,{children:[e.jsxs(Cm,{children:[e.jsx(Sm,{children:"Choose your organization name"}),e.jsx(zm,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs($m,{children:[e.jsxs(Fa,{children:[e.jsx(Ba,{children:"Organization name"}),e.jsx(Em,{type:"text",value:o,onChange:b=>y(b.target.value),placeholder:"Acme Inc.",disabled:l})]}),e.jsxs(Fa,{children:[e.jsx(Ba,{children:"Description (optional)"}),e.jsx(Im,{value:s,onChange:b=>a(b.target.value),placeholder:"What does your organization do?",disabled:l})]})]}),e.jsxs(Pm,{children:[r?e.jsxs(Rm,{onClick:r,disabled:l,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Tm,{onClick:w,disabled:l||!o.trim(),children:l?"Creating...":"Create"})]})]})]})})},Lm=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(ge,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:n,onCancel:r})})})})})})},Dm=d.div`
2237
2237
  position: fixed;
2238
2238
  width: 360px;
2239
2239
  max-width: calc(100vw - 48px);
@@ -2282,7 +2282,7 @@ cursor: pointer;
2282
2282
  color: var(--color-foreground);
2283
2283
  background: var(--color-input-background);
2284
2284
  }
2285
- `,qa=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(),[p,g]=i.useState(""),[c,h]=i.useState(!1),[l,u]=i.useState(!1),[m,v]=i.useState({top:0,left:0}),{addDomain:x,verifyDomain:y}=Ze(),{toast:$}=He(),S=w=>/^[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(w),k=w=>w.trim().toLowerCase().replace(/^https?:\/\//,""),I=async()=>{const w=k(p);if(!w){$("Please enter a domain name","error");return}if(!S(w)){$("Please enter a valid domain name (e.g., example.com)","error");return}if(w.length>253){$("Domain name is too long","error");return}try{const b=await x({fqdn:w});$("Domain added successfully","info"),a(b.data)}catch(b){const f=b.message||"Failed to add domain. Please try again.";$(f,"error")}},E=async()=>{if(!(!s||c)){h(!0);try{await y(s),t==null||t(),$("Domain verified successfully","info")}catch(w){const b=w.message||"Failed to verify domain. Please check DNS records and try again.";$(b,"error")}finally{h(!1)}}};return i.useEffect(()=>{u(!0);const w=setTimeout(()=>{if(!n.current)return;const z=o==null?void 0:o.current,_=360,j=250,M=8;let R=0,C=0;if(!z){const L=n.current.getBoundingClientRect(),F=L.width||_,O=L.height||j;R=Math.max(M,(window.innerHeight-O)/2),C=Math.max(M,(window.innerWidth-F)/2),v({top:R,left:C});return}const P=z.getBoundingClientRect(),T=window.innerHeight-P.bottom,B=P.top;T>=j+M?(R=P.bottom+M,C=P.right-_,C<M&&(C=P.left,C+_>window.innerWidth-M&&(C=(window.innerWidth-_)/2))):B>=j+M?(R=P.top-j-M,C=P.right-_,C<M&&(C=P.left,C+_>window.innerWidth-M&&(C=(window.innerWidth-_)/2))):(R=P.bottom+M,C=P.right-_,C<M&&(C=P.left)),v({top:R,left:C})},10),b=z=>{n.current&&!n.current.contains(z.target)&&(t==null||t())},f=z=>{z.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(w),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,o]),i.useEffect(()=>{r&&a(r)},[r]),l?e.jsx(Fm,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(Ua,{children:[e.jsx(Wa,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Ha,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(et,{size:16})})]}),e.jsxs(Va,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0,textAlign:"left"},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(ie,{children:"Record Type"}),e.jsx(ce,{value:s==null?void 0:s.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Name"}),e.jsx(ce,{value:s==null?void 0:s.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Data"}),e.jsx(ce,{type:"text",value:s==null?void 0:s.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Ga,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:E,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ua,{children:[e.jsx(Wa,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Ha,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Va,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ie,{children:"Enter FQDN"}),e.jsx(ce,{type:"text",placeholder:"Enter your domain",value:p,onChange:w=>g(w.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Ga,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:I,disabled:!p||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Bm=d.div`
2285
+ `,qa=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(),[p,g]=i.useState(""),[c,h]=i.useState(!1),[l,u]=i.useState(!1),[m,x]=i.useState({top:0,left:0}),{addDomain:v,verifyDomain:y}=Ze(),{toast:z}=He(),S=w=>/^[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(w),_=w=>w.trim().toLowerCase().replace(/^https?:\/\//,""),E=async()=>{const w=_(p);if(!w){z("Please enter a domain name","error");return}if(!S(w)){z("Please enter a valid domain name (e.g., example.com)","error");return}if(w.length>253){z("Domain name is too long","error");return}try{const b=await v({fqdn:w});z("Domain added successfully","info"),a(b.data)}catch(b){const f=b.message||"Failed to add domain. Please try again.";z(f,"error")}},I=async()=>{if(!(!s||c)){h(!0);try{await y(s),t==null||t(),z("Domain verified successfully","info")}catch(w){const b=w.message||"Failed to verify domain. Please check DNS records and try again.";z(b,"error")}finally{h(!1)}}};return i.useEffect(()=>{u(!0);const w=setTimeout(()=>{if(!n.current)return;const $=o==null?void 0:o.current,k=360,j=250,M=8;let R=0,C=0;if(!$){const L=n.current.getBoundingClientRect(),F=L.width||k,O=L.height||j;R=Math.max(M,(window.innerHeight-O)/2),C=Math.max(M,(window.innerWidth-F)/2),x({top:R,left:C});return}const P=$.getBoundingClientRect(),T=window.innerHeight-P.bottom,B=P.top;T>=j+M?(R=P.bottom+M,C=P.right-k,C<M&&(C=P.left,C+k>window.innerWidth-M&&(C=(window.innerWidth-k)/2))):B>=j+M?(R=P.top-j-M,C=P.right-k,C<M&&(C=P.left,C+k>window.innerWidth-M&&(C=(window.innerWidth-k)/2))):(R=P.bottom+M,C=P.right-k,C<M&&(C=P.left)),x({top:R,left:C})},10),b=$=>{n.current&&!n.current.contains($.target)&&(t==null||t())},f=$=>{$.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(w),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,o]),i.useEffect(()=>{r&&a(r)},[r]),l?e.jsx(Dm,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:s?e.jsxs(e.Fragment,{children:[e.jsxs(Ua,{children:[e.jsx(Wa,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Ha,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(et,{size:16})})]}),e.jsxs(Va,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0,textAlign:"left"},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(ie,{children:"Record Type"}),e.jsx(ce,{value:s==null?void 0:s.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Name"}),e.jsx(ce,{value:s==null?void 0:s.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Record Data"}),e.jsx(ce,{type:"text",value:s==null?void 0:s.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Ga,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:I,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ua,{children:[e.jsx(Wa,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Ha,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Va,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ie,{children:"Enter FQDN"}),e.jsx(ce,{type:"text",placeholder:"Enter your domain",value:p,onChange:w=>g(w.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Ga,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:E,disabled:!p||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Nm=d.div`
2286
2286
  position: fixed;
2287
2287
  width: 360px;
2288
2288
  max-width: calc(100vw - 48px);
@@ -2295,27 +2295,27 @@ cursor: pointer;
2295
2295
  @media (max-width: 600px) {
2296
2296
  width: calc(100vw - 48px);
2297
2297
  }
2298
- `,Um=d.div`
2298
+ `,Fm=d.div`
2299
2299
  display: flex;
2300
2300
  justify-content: space-between;
2301
2301
  align-items: center;
2302
2302
  padding: var(--space-sm) var(--space-md);
2303
2303
  border-bottom: 1px solid var(--color-border);
2304
- `,Wm=d.h3`
2304
+ `,Bm=d.h3`
2305
2305
  margin: 0;
2306
2306
  font-size: var(--font-xs);
2307
2307
  font-weight: 400;
2308
2308
  color: var(--color-foreground);
2309
- `,Vm=d.div`
2309
+ `,Um=d.div`
2310
2310
  padding: var(--space-md);
2311
- `,Gm=d.div`
2311
+ `,Wm=d.div`
2312
2312
  display: flex;
2313
2313
  gap: var(--space-xs);
2314
2314
  justify-content: flex-end;
2315
2315
  padding: var(--space-sm) var(--space-md);
2316
2316
  border-top: 1px solid var(--color-border);
2317
2317
  background: var(--color-background-alt);
2318
- `,Hm=d.button`
2318
+ `,Vm=d.button`
2319
2319
  background: none;
2320
2320
  border: none;
2321
2321
  padding: var(--space-xs);
@@ -2331,7 +2331,7 @@ cursor: pointer;
2331
2331
  color: var(--color-foreground);
2332
2332
  background: var(--color-input-background);
2333
2333
  }
2334
- `,$l=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const s=i.useRef(null),[a,p]=i.useState(""),[g,c]=i.useState(null),[h,l]=i.useState(!1),[u,m]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{inviteMember:y}=Ze(),{toast:$}=He(),S=o.map(E=>({value:E.id,label:E.name})),k=E=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E),I=async()=>{const E=a.trim().toLowerCase();if(!(!E||!g)){if(!k(E)){$("Please enter a valid email address","error");return}if(E.length>320){$("Email address is too long","error");return}l(!0);try{await y({email:E,organizationRole:g}),r==null||r()}catch(w){const b=w.message||"Failed to send invitation. Please try again.";$(b,"error")}finally{l(!1)}}};return i.useEffect(()=>{m(!0);const E=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const f=n.current;if(f){const z=f.getBoundingClientRect(),_=360,j=250,M=8;let R=0,C=0;const P=window.innerHeight-z.bottom,T=z.top;P>=j+M?(R=z.bottom+M,C=z.right-_,C<M&&(C=z.left,C+_>window.innerWidth-M&&(C=(window.innerWidth-_)/2))):T>=j+M?(R=z.top-j-M,C=z.right-_,C<M&&(C=z.left,C+_>window.innerWidth-M&&(C=(window.innerWidth-_)/2))):(R=z.bottom+M,C=z.right-_,C<M&&(C=z.left)),x({top:R,left:C})}},10),w=f=>{s.current&&!s.current.contains(f.target)&&(t==null||t())},b=f=>{f.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",b),()=>{clearTimeout(E),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",b)}},[t,n]),u?e.jsxs(Bm,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Um,{children:[e.jsx(Wm,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Hm,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(et,{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(ie,{children:"Email Address"}),e.jsx(ce,{type:"email",placeholder:"colleague@company.com",value:a,onChange:E=>p(E.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Is,{options:S,value:g==null?void 0:g.id,onChange:E=>c(o.find(w=>w.id===E)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Gm,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:I,disabled:!a||!g||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},qm=d.div`
2334
+ `,$l=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const s=i.useRef(null),[a,p]=i.useState(""),[g,c]=i.useState(null),[h,l]=i.useState(!1),[u,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{inviteMember:y}=Ze(),{toast:z}=He(),S=o.map(I=>({value:I.id,label:I.name})),_=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),E=async()=>{const I=a.trim().toLowerCase();if(!(!I||!g)){if(!_(I)){z("Please enter a valid email address","error");return}if(I.length>320){z("Email address is too long","error");return}l(!0);try{await y({email:I,organizationRole:g}),r==null||r()}catch(w){const b=w.message||"Failed to send invitation. Please try again.";z(b,"error")}finally{l(!1)}}};return i.useEffect(()=>{m(!0);const I=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const f=n.current;if(f){const $=f.getBoundingClientRect(),k=360,j=250,M=8;let R=0,C=0;const P=window.innerHeight-$.bottom,T=$.top;P>=j+M?(R=$.bottom+M,C=$.right-k,C<M&&(C=$.left,C+k>window.innerWidth-M&&(C=(window.innerWidth-k)/2))):T>=j+M?(R=$.top-j-M,C=$.right-k,C<M&&(C=$.left,C+k>window.innerWidth-M&&(C=(window.innerWidth-k)/2))):(R=$.bottom+M,C=$.right-k,C<M&&(C=$.left)),v({top:R,left:C})}},10),w=f=>{s.current&&!s.current.contains(f.target)&&(t==null||t())},b=f=>{f.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",b),()=>{clearTimeout(I),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",b)}},[t,n]),u?e.jsxs(Nm,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:I=>I.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Fm,{children:[e.jsx(Bm,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Vm,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Um,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(ce,{type:"email",placeholder:"colleague@company.com",value:a,onChange:I=>p(I.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Is,{options:S,value:g==null?void 0:g.id,onChange:I=>c(o.find(w=>w.id===I)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Wm,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:E,disabled:!a||!g||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},Gm=d.div`
2335
2335
  position: fixed;
2336
2336
  width: 400px;
2337
2337
  max-width: calc(100vw - 48px);
@@ -2346,27 +2346,27 @@ cursor: pointer;
2346
2346
  @media (max-width: 600px) {
2347
2347
  width: calc(100vw - 48px);
2348
2348
  }
2349
- `,Ym=d.div`
2349
+ `,Hm=d.div`
2350
2350
  display: flex;
2351
2351
  justify-content: space-between;
2352
2352
  align-items: center;
2353
2353
  padding: var(--space-sm) var(--space-md);
2354
2354
  border-bottom: 1px solid var(--color-border);
2355
- `,Zm=d.h3`
2355
+ `,qm=d.h3`
2356
2356
  margin: 0;
2357
2357
  font-size: var(--font-xs);
2358
2358
  font-weight: 400;
2359
2359
  color: var(--color-foreground);
2360
- `,Km=d.div`
2360
+ `,Ym=d.div`
2361
2361
  padding: var(--space-md);
2362
- `,Qm=d.div`
2362
+ `,Zm=d.div`
2363
2363
  display: flex;
2364
2364
  gap: var(--space-xs);
2365
2365
  justify-content: flex-end;
2366
2366
  padding: var(--space-sm) var(--space-md);
2367
2367
  border-top: 1px solid var(--color-border);
2368
2368
  background: var(--color-background-alt);
2369
- `,Xm=d.button`
2369
+ `,Km=d.button`
2370
2370
  background: none;
2371
2371
  border: none;
2372
2372
  padding: var(--space-xs);
@@ -2382,7 +2382,7 @@ cursor: pointer;
2382
2382
  color: var(--color-foreground);
2383
2383
  background: var(--color-input-background);
2384
2384
  }
2385
- `,Ya=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var b;const s=i.useRef(null),[a,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]);Ze();const[h,l]=i.useState(!1),[u,m]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{deployment:y}=ve(),{toast:$}=He(),S=!!o,k=Array.isArray((b=y==null?void 0:y.b2b_settings)==null?void 0:b.organization_permissions)?y.b2b_settings.organization_permissions.map(f=>({value:f,label:f})):[];i.useEffect(()=>{m(!0);const f=setTimeout(()=>{if(!s.current)return;let M=null;if(n!=null&&n.current)M=n.current;else if(S){const R=document.querySelectorAll("[data-role-dropdown-trigger]");for(let C=0;C<R.length;C++){const P=R[C];if(P.offsetParent!==null){M=P;break}}}else{const R=document.querySelectorAll("button");for(let C=0;C<R.length;C++){const P=R[C];if(P.textContent==="Add role"&&P.offsetParent!==null){M=P;break}}}if(M){const R=M.getBoundingClientRect(),C=400;let P=R.bottom+8,T=R.right-C;T<10&&(T=R.left),P+300>window.innerHeight&&(P=R.top-300-8),x({top:P,left:T})}},10),z=M=>{s.current&&!s.current.contains(M.target)&&(t==null||t())},_=M=>{M.key==="Escape"&&(t==null||t())},j=setTimeout(()=>{document.addEventListener("mousedown",z),document.addEventListener("keydown",_)},100);return()=>{clearTimeout(f),clearTimeout(j),document.removeEventListener("mousedown",z),document.removeEventListener("keydown",_)}},[t,S,n]);const I=f=>f.trim().replace(/[<>\"'&]/g,""),E=f=>f.length>=2&&f.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(f),w=async()=>{const f=I(a);if(!f){$("Please enter a role name","error");return}if(!E(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 z={id:o==null?void 0:o.id,name:f,permissions:g||[]};r==null||r(z)}catch(z){const _=z.message||`Failed to ${S?"update":"create"} role. Please try again.`;$(_,"error")}finally{l(!1)}};return u?e.jsxs(qm,{ref:s,$isInTable:S,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:f=>f.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(Ym,{children:[e.jsx(Zm,{id:"role-dialog-title",children:S?"Edit Role":"Create New Role"}),e.jsx(Xm,{onClick:t,"aria-label":`Close ${S?"edit":"create"} role dialog`,children:e.jsx(et,{size:16})})]}),e.jsx(Km,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(ce,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:f=>p(f.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(bl,{options:k,value:g,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Qm,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:w,disabled:!a||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," ",S?"Updating...":"Creating..."]}):S?"Update Role":"Create Role"})]})]}):null},ht=d.table`
2385
+ `,Ya=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var b;const s=i.useRef(null),[a,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]);Ze();const[h,l]=i.useState(!1),[u,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{deployment:y}=ve(),{toast:z}=He(),S=!!o,_=Array.isArray((b=y==null?void 0:y.b2b_settings)==null?void 0:b.organization_permissions)?y.b2b_settings.organization_permissions.map(f=>({value:f,label:f})):[];i.useEffect(()=>{m(!0);const f=setTimeout(()=>{if(!s.current)return;let M=null;if(n!=null&&n.current)M=n.current;else if(S){const R=document.querySelectorAll("[data-role-dropdown-trigger]");for(let C=0;C<R.length;C++){const P=R[C];if(P.offsetParent!==null){M=P;break}}}else{const R=document.querySelectorAll("button");for(let C=0;C<R.length;C++){const P=R[C];if(P.textContent==="Add role"&&P.offsetParent!==null){M=P;break}}}if(M){const R=M.getBoundingClientRect(),C=400;let P=R.bottom+8,T=R.right-C;T<10&&(T=R.left),P+300>window.innerHeight&&(P=R.top-300-8),v({top:P,left:T})}},10),$=M=>{s.current&&!s.current.contains(M.target)&&(t==null||t())},k=M=>{M.key==="Escape"&&(t==null||t())},j=setTimeout(()=>{document.addEventListener("mousedown",$),document.addEventListener("keydown",k)},100);return()=>{clearTimeout(f),clearTimeout(j),document.removeEventListener("mousedown",$),document.removeEventListener("keydown",k)}},[t,S,n]);const E=f=>f.trim().replace(/[<>\"'&]/g,""),I=f=>f.length>=2&&f.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(f),w=async()=>{const f=E(a);if(!f){z("Please enter a role name","error");return}if(!I(f)){z("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(g.length===0){z("Please select at least one permission","error");return}l(!0);try{const $={id:o==null?void 0:o.id,name:f,permissions:g||[]};r==null||r($)}catch($){const k=$.message||`Failed to ${S?"update":"create"} role. Please try again.`;z(k,"error")}finally{l(!1)}};return u?e.jsxs(Gm,{ref:s,$isInTable:S,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(Hm,{children:[e.jsx(qm,{id:"role-dialog-title",children:S?"Edit Role":"Create New Role"}),e.jsx(Km,{onClick:t,"aria-label":`Close ${S?"edit":"create"} role dialog`,children:e.jsx(et,{size:16})})]}),e.jsx(Ym,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(ce,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:f=>p(f.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(bl,{options:_,value:g,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Zm,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:w,disabled:!a||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," ",S?"Updating...":"Creating..."]}):S?"Update Role":"Create Role"})]})]}):null},ht=d.table`
2386
2386
  width: 100%;
2387
2387
  border-collapse: separate;
2388
2388
  border-spacing: 0;
@@ -2440,7 +2440,7 @@ cursor: pointer;
2440
2440
  white-space: nowrap;
2441
2441
  position: relative;
2442
2442
  overflow: visible;
2443
- `,Jm=d.div`
2443
+ `,Qm=d.div`
2444
2444
  display: flex;
2445
2445
  flex-direction: column;
2446
2446
  align-items: center;
@@ -2452,18 +2452,18 @@ cursor: pointer;
2452
2452
  border: 1px dashed var(--color-border);
2453
2453
  height: 100%;
2454
2454
  width: 100%;
2455
- `,ex=d.h3`
2455
+ `,Xm=d.h3`
2456
2456
  font-size: 16px;
2457
2457
  font-weight: 400;
2458
2458
  color: var(--color-foreground);
2459
2459
  margin: 0 0 8px 0;
2460
- `,tx=d.p`
2460
+ `,Jm=d.p`
2461
2461
  font-size: 14px;
2462
2462
  color: var(--color-muted);
2463
2463
  margin: 0;
2464
2464
  max-width: 380px;
2465
2465
  line-height: 1.5;
2466
- `,it=({title:t,description:r,action:o})=>e.jsxs(Jm,{children:[e.jsx(ex,{children:t}),e.jsx(tx,{children:r}),o&&e.jsx("div",{style:{marginTop:"24px"},children:o})]}),rx=d.div`
2466
+ `,it=({title:t,description:r,action:o})=>e.jsxs(Qm,{children:[e.jsx(Xm,{children:t}),e.jsx(Jm,{children:r}),o&&e.jsx("div",{style:{marginTop:"24px"},children:o})]}),ex=d.div`
2467
2467
  text-align: left;
2468
2468
  position: fixed;
2469
2469
  background: var(--color-background);
@@ -2473,34 +2473,34 @@ cursor: pointer;
2473
2473
  padding: 16px;
2474
2474
  width: 320px;
2475
2475
  z-index: 1000;
2476
- `,ox=d.div`
2476
+ `,tx=d.div`
2477
2477
  font-size: 14px;
2478
2478
  font-weight: 400;
2479
2479
  color: var(--color-foreground);
2480
2480
  margin-bottom: 16px;
2481
2481
  line-height: 1.4;
2482
- `,nx=d.div`
2482
+ `,rx=d.div`
2483
2483
  display: flex;
2484
2484
  gap: 8px;
2485
2485
  justify-content: flex-end;
2486
- `,Yr=({title:t,onConfirm:r,onCancel:o})=>{const n=i.useRef(null),[s,a]=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&&a({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(rx,{ref:n,style:{top:`${s.top}px`,left:`${s.left}px`},children:[e.jsx(ox,{children:t}),e.jsxs(nx,{children:[e.jsx(X,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(X,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},sx=d.div`
2486
+ `,Yr=({title:t,onConfirm:r,onCancel:o})=>{const n=i.useRef(null),[s,a]=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&&a({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(ex,{ref:n,style:{top:`${s.top}px`,left:`${s.left}px`},children:[e.jsx(tx,{children:t}),e.jsxs(rx,{children:[e.jsx(X,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(X,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},ox=d.div`
2487
2487
  display: flex;
2488
2488
  align-items: center;
2489
2489
  flex-wrap: wrap;
2490
2490
  gap: 12px;
2491
2491
  margin-bottom: 24px;
2492
- `,Il=d.div`
2492
+ `,nx=d.div`
2493
2493
  background: var(--color-background);
2494
2494
  border: 1px solid var(--color-border);
2495
2495
  border-radius: 8px;
2496
2496
  padding: 20px;
2497
2497
  margin-bottom: 16px;
2498
- `,ax=d.div`
2498
+ `,sx=d.div`
2499
2499
  display: flex;
2500
2500
  justify-content: space-between;
2501
2501
  align-items: flex-start;
2502
2502
  margin-bottom: 16px;
2503
- `,Pl=d.h3`
2503
+ `,ax=d.h3`
2504
2504
  font-size: 16px;
2505
2505
  font-weight: 500;
2506
2506
  color: var(--color-foreground);
@@ -2516,7 +2516,7 @@ cursor: pointer;
2516
2516
  font-size: 12px;
2517
2517
  font-weight: 400;
2518
2518
  text-transform: uppercase;
2519
- `,Ht=d.div`
2519
+ `,pr=d.div`
2520
2520
  font-size: 13px;
2521
2521
  color: var(--color-muted);
2522
2522
  margin-bottom: 8px;
@@ -2611,7 +2611,7 @@ cursor: pointer;
2611
2611
  outline: none;
2612
2612
  border-color: var(--color-primary);
2613
2613
  }
2614
- `,lx=()=>{var I;const{deployment:t}=ve(),{activeOrganization:r,loading:o,getEnterpriseConnections:n,createEnterpriseConnection:s,deleteEnterpriseConnection:a,testEnterpriseConnection:p,generateSCIMToken:g,getSCIMToken:c,revokeSCIMToken:h}=Ze(),{toast:l}=He(),[u,m]=i.useState(!1),[v,x]=i.useState(null),{data:y=[],isLoading:$,mutate:S}=Fe(r!=null&&r.id?`wacht-org-sso:${r.id}`:null,async()=>await(n==null?void 0:n())||[],{refreshInterval:3e4,revalidateOnFocus:!1}),k=async E=>{try{await(a==null?void 0:a(E)),S(),l("SSO connection deleted","info")}catch(w){l(w.message||"Failed to delete connection","error")}x(null)};return o||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):(I=t==null?void 0:t.b2b_settings)!=null&&I.enterprise_sso_enabled?u?e.jsx(gx,{onClose:()=>m(!1),onCreate:async E=>{try{await(s==null?void 0:s(E)),S(),m(!1),l("SSO connection created","info")}catch(w){l(w.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:y.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(Qe,{size:56,strokeWidth:1,style:{color:"var(--color-primary)",marginBottom:"20px",opacity:.7}}),e.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:500,color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:"var(--color-muted)",maxWidth:"360px",lineHeight:"1.6"},children:"Set up SAML or OIDC single sign-on to allow members to sign in with your identity provider."}),e.jsxs(X,{onClick:()=>m(!0),style:{width:"auto"},children:[e.jsx(Ke,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(sx,{children:e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"16px",color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"var(--color-muted)"},children:"Configure SAML or OIDC SSO for your organization"})]})}),y.map(E=>e.jsx(fx,{connection:E,onDelete:w=>x(w),connectionToDelete:v,onConfirmDelete:k,onCancelDelete:()=>x(null),testConnection:p||null,generateSCIMToken:g,getSCIMToken:c,revokeSCIMToken:h,toast:l},E.id))]})}):e.jsxs(Il,{children:[e.jsxs(Pl,{children:[e.jsx(Qe,{size:18}),"Enterprise SSO"]}),e.jsx(Ht,{children:e.jsx("span",{style:{color:"var(--color-foreground-muted)"},children:"Enterprise SSO is not enabled for this deployment. Contact your administrator to enable this feature."})})]})},dx=d.div`
2614
+ `,lx=()=>{const{activeOrganization:t,loading:r,getEnterpriseConnections:o,createEnterpriseConnection:n,deleteEnterpriseConnection:s,testEnterpriseConnection:a,generateSCIMToken:p,getSCIMToken:g,revokeSCIMToken:c}=Ze(),{toast:h}=He(),[l,u]=i.useState(!1),[m,x]=i.useState(null),{data:v=[],isLoading:y,mutate:z}=Fe(t!=null&&t.id?`wacht-org-sso:${t.id}`:null,async()=>await(o==null?void 0:o())||[],{refreshInterval:3e4,revalidateOnFocus:!1}),S=async _=>{try{await(s==null?void 0:s(_)),z(),h("SSO connection deleted","info")}catch(E){h(E.message||"Failed to delete connection","error")}x(null)};return r||y?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):l?e.jsx(gx,{onClose:()=>u(!1),onCreate:async _=>{try{await(n==null?void 0:n(_)),z(),u(!1),h("SSO connection created","info")}catch(E){h(E.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:v.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(Xe,{size:56,strokeWidth:1,style:{color:"var(--color-primary)",marginBottom:"20px",opacity:.7}}),e.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:500,color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:"var(--color-muted)",maxWidth:"360px",lineHeight:"1.6"},children:"Set up SAML or OIDC single sign-on to allow members to sign in with your identity provider."}),e.jsxs(X,{onClick:()=>u(!0),style:{width:"auto"},children:[e.jsx(Ke,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ox,{children:e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"16px",color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"var(--color-muted)"},children:"Configure SAML or OIDC SSO for your organization"})]})}),v.map(_=>e.jsx(fx,{connection:_,onDelete:E=>x(E),connectionToDelete:m,onConfirmDelete:S,onCancelDelete:()=>x(null),testConnection:a||null,generateSCIMToken:p,getSCIMToken:g,revokeSCIMToken:c,toast:h},_.id))]})})},dx=d.div`
2615
2615
  margin-top: 16px;
2616
2616
  padding-top: 16px;
2617
2617
  border-top: 1px solid var(--color-border);
@@ -2636,14 +2636,14 @@ cursor: pointer;
2636
2636
  display: flex;
2637
2637
  gap: 8px;
2638
2638
  flex-wrap: wrap;
2639
- `,fx=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:s,testConnection:a,generateSCIMToken:p,getSCIMToken:g,revokeSCIMToken:c,toast:h})=>{var j,M;const[l,u]=i.useState(null),[m,v]=i.useState(!1),[x,y]=i.useState(null),[$,S]=i.useState(null),[k,I]=i.useState(!1),[E,w]=i.useState(null);i.useEffect(()=>{g&&t.id&&g(t.id).then(u).catch(()=>{})},[t.id,g]);const b=async()=>{if(a){I(!0),w(null);try{const R=await a(t.id);w(R)}catch(R){w({success:!1,checks:{},errors:{general:R.message||"Test failed"}})}finally{I(!1)}}},f=async()=>{if(p){v(!0);try{const R=await p(t.id);y(R.token),u({exists:!0,token:R,scim_base_url:R.scim_base_url}),h("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(R){h(R.message||"Failed to generate token","error")}finally{v(!1)}}},z=async()=>{if(c){v(!0);try{await c(t.id),u({exists:!1,scim_base_url:l==null?void 0:l.scim_base_url}),y(null),h("SCIM token revoked","info")}catch(R){h(R.message||"Failed to revoke token","error")}finally{v(!1)}}},_=(R,C)=>{navigator.clipboard.writeText(R),S(C),setTimeout(()=>S(null),2e3)};return e.jsxs(Il,{children:[e.jsxs(ax,{children:[e.jsxs(Pl,{children:[e.jsx(Qe,{size:18}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(ix,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(br,{onClick:()=>r(t.id),style:{color:"var(--color-error)"},children:e.jsx(Hr,{size:16})}),o===t.id&&e.jsx(Yr,{title:"Delete this SSO connection?",onConfirm:()=>n(t.id),onCancel:s})]})]}),t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(Ht,{children:[e.jsx("strong",{children:"Entity ID:"})," ",t.idp_entity_id]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"SSO URL:"})," ",t.idp_sso_url]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ht,{children:[e.jsx("strong",{children:"Issuer URL:"})," ",t.oidc_issuer_url]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Client ID:"})," ",t.oidc_client_id]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Scopes:"})," ",t.oidc_scopes||"openid profile email"]})]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Created:"})," ",new Date(t.created_at).toLocaleDateString()]}),e.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[e.jsxs(X,{$outline:!0,onClick:b,disabled:k,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[k?e.jsx(Ee,{size:12}):e.jsx(Qe,{size:14}),k?"Testing...":"Test Connection"]}),E&&e.jsx("span",{style:{fontSize:"12px",color:E.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:E.success?"✓ Connection valid":"✗ Connection failed"})]}),E&&!E.success&&E.errors&&e.jsx("div",{style:{marginTop:"8px",padding:"8px 12px",background:"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"4px",fontSize:"12px"},children:Object.entries(E.errors).map(([R,C])=>e.jsxs("div",{style:{color:"var(--color-error)",marginBottom:"4px"},children:[e.jsxs("strong",{children:[R.replace(/_/g," ").replace(/\b\w/g,P=>P.toUpperCase()),":"]})," ",C]},R))})]}),e.jsxs(dx,{children:[e.jsxs(ux,{children:[e.jsx(Qe,{size:14}),"SCIM Provisioning"]}),(l==null?void 0:l.scim_base_url)&&e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"4px"},children:"SCIM Base URL:"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all"},children:l.scim_base_url}),e.jsx(br,{onClick:()=>_(l.scim_base_url,"scim-url"),children:$==="scim-url"?e.jsx(Ve,{size:14}):e.jsx(Jt,{size:14})})]})]}),x&&e.jsxs(px,{children:[e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginBottom:"8px"},children:"⚠️ Copy this token now. It won't be shown again."}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[e.jsx("span",{style:{flex:1},children:x}),e.jsx(br,{onClick:()=>_(x,"scim-token"),children:$==="scim-token"?e.jsx(Ve,{size:14}):e.jsx(Jt,{size:14})})]})]}),(l==null?void 0:l.exists)&&((j=l==null?void 0:l.token)==null?void 0:j.enabled)&&!x&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:["Token: ",e.jsxs("code",{children:[l.token.token_prefix,"..."]}),l.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(l.token.last_used_at).toLocaleDateString()]})]}),e.jsx(hx,{children:!(l!=null&&l.exists)||!((M=l==null?void 0:l.token)!=null&&M.enabled)?e.jsxs(X,{onClick:f,disabled:m,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[m?e.jsx(Ee,{size:12}):e.jsx(Ke,{size:14}),"Generate SCIM Token"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{$outline:!0,onClick:f,disabled:m,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:"Rotate Token"}),e.jsx(X,{$outline:!0,onClick:z,disabled:m,style:{width:"auto",fontSize:"12px",padding:"6px 12px",color:"var(--color-error)"},children:"Revoke Token"})]})})]})]})},Fn=d.h3`
2639
+ `,fx=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:s,testConnection:a,generateSCIMToken:p,getSCIMToken:g,revokeSCIMToken:c,toast:h})=>{var j,M;const[l,u]=i.useState(null),[m,x]=i.useState(!1),[v,y]=i.useState(null),[z,S]=i.useState(null),[_,E]=i.useState(!1),[I,w]=i.useState(null);i.useEffect(()=>{g&&t.id&&g(t.id).then(u).catch(()=>{})},[t.id,g]);const b=async()=>{if(a){E(!0),w(null);try{const R=await a(t.id);w(R)}catch(R){w({success:!1,checks:{},errors:{general:R.message||"Test failed"}})}finally{E(!1)}}},f=async()=>{if(p){x(!0);try{const R=await p(t.id);y(R.token),u({exists:!0,token:R,scim_base_url:R.scim_base_url}),h("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(R){h(R.message||"Failed to generate token","error")}finally{x(!1)}}},$=async()=>{if(c){x(!0);try{await c(t.id),u({exists:!1,scim_base_url:l==null?void 0:l.scim_base_url}),y(null),h("SCIM token revoked","info")}catch(R){h(R.message||"Failed to revoke token","error")}finally{x(!1)}}},k=(R,C)=>{navigator.clipboard.writeText(R),S(C),setTimeout(()=>S(null),2e3)};return e.jsxs(nx,{children:[e.jsxs(sx,{children:[e.jsxs(ax,{children:[e.jsx(Xe,{size:18}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(ix,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(br,{onClick:()=>r(t.id),style:{color:"var(--color-error)"},children:e.jsx(Hr,{size:16})}),o===t.id&&e.jsx(Yr,{title:"Delete this SSO connection?",onConfirm:()=>n(t.id),onCancel:s})]})]}),t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(pr,{children:[e.jsx("strong",{children:"Entity ID:"})," ",t.idp_entity_id]}),e.jsxs(pr,{children:[e.jsx("strong",{children:"SSO URL:"})," ",t.idp_sso_url]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(pr,{children:[e.jsx("strong",{children:"Issuer URL:"})," ",t.oidc_issuer_url]}),e.jsxs(pr,{children:[e.jsx("strong",{children:"Client ID:"})," ",t.oidc_client_id]}),e.jsxs(pr,{children:[e.jsx("strong",{children:"Scopes:"})," ",t.oidc_scopes||"openid profile email"]})]}),e.jsxs(pr,{children:[e.jsx("strong",{children:"Created:"})," ",new Date(t.created_at).toLocaleDateString()]}),e.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[e.jsxs(X,{$outline:!0,onClick:b,disabled:_,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[_?e.jsx(Ee,{size:12}):e.jsx(Xe,{size:14}),_?"Testing...":"Test Connection"]}),I&&e.jsx("span",{style:{fontSize:"12px",color:I.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:I.success?"✓ Connection valid":"✗ Connection failed"})]}),I&&!I.success&&I.errors&&e.jsx("div",{style:{marginTop:"8px",padding:"8px 12px",background:"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"4px",fontSize:"12px"},children:Object.entries(I.errors).map(([R,C])=>e.jsxs("div",{style:{color:"var(--color-error)",marginBottom:"4px"},children:[e.jsxs("strong",{children:[R.replace(/_/g," ").replace(/\b\w/g,P=>P.toUpperCase()),":"]})," ",C]},R))})]}),e.jsxs(dx,{children:[e.jsxs(ux,{children:[e.jsx(Xe,{size:14}),"SCIM Provisioning"]}),(l==null?void 0:l.scim_base_url)&&e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"4px"},children:"SCIM Base URL:"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all"},children:l.scim_base_url}),e.jsx(br,{onClick:()=>k(l.scim_base_url,"scim-url"),children:z==="scim-url"?e.jsx(Ve,{size:14}):e.jsx(Xt,{size:14})})]})]}),v&&e.jsxs(px,{children:[e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginBottom:"8px"},children:"⚠️ Copy this token now. It won't be shown again."}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[e.jsx("span",{style:{flex:1},children:v}),e.jsx(br,{onClick:()=>k(v,"scim-token"),children:z==="scim-token"?e.jsx(Ve,{size:14}):e.jsx(Xt,{size:14})})]})]}),(l==null?void 0:l.exists)&&((j=l==null?void 0:l.token)==null?void 0:j.enabled)&&!v&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:["Token: ",e.jsxs("code",{children:[l.token.token_prefix,"..."]}),l.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(l.token.last_used_at).toLocaleDateString()]})]}),e.jsx(hx,{children:!(l!=null&&l.exists)||!((M=l==null?void 0:l.token)!=null&&M.enabled)?e.jsxs(X,{onClick:f,disabled:m,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[m?e.jsx(Ee,{size:12}):e.jsx(Ke,{size:14}),"Generate SCIM Token"]}):e.jsxs(e.Fragment,{children:[e.jsx(X,{$outline:!0,onClick:f,disabled:m,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:"Rotate Token"}),e.jsx(X,{$outline:!0,onClick:$,disabled:m,style:{width:"auto",fontSize:"12px",padding:"6px 12px",color:"var(--color-error)"},children:"Revoke Token"})]})})]})]})},Fn=d.h3`
2640
2640
  margin: 0 0 12px 0;
2641
2641
  font-size: 13px;
2642
2642
  font-weight: 600;
2643
2643
  color: var(--color-foreground);
2644
2644
  text-transform: uppercase;
2645
2645
  letter-spacing: 0.5px;
2646
- `,gx=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=Ze(),{deployment:n}=ve(),[s,a]=i.useState(!1),[p,g]=i.useState(null),[c,h]=i.useState("saml"),[l,u]=i.useState(null),[m,v]=i.useState(!1),[x,y]=i.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[$,S]=i.useState(!1),[k,I]=i.useState(null),{data:E=[],isLoading:w}=Fe("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(P=>P.verified),{revalidateOnFocus:!1}),b=C=>{g(C),h(C.protocol),C.protocol==="saml"?y(P=>{var T,B,L;return{...P,idp_entity_id:C.placeholders.entityId||"",idp_sso_url:C.placeholders.ssoUrl||"",attr_first_name:((T=C.attributeMapping)==null?void 0:T.first_name)||"",attr_last_name:((B=C.attributeMapping)==null?void 0:B.last_name)||"",attr_email:((L=C.attributeMapping)==null?void 0:L.email)||""}}):y(P=>{var T,B,L;return{...P,oidc_issuer_url:C.placeholders.issuerUrl||"",oidc_scopes:C.placeholders.scopes||"openid profile email",attr_first_name:((T=C.attributeMapping)==null?void 0:T.first_name)||"",attr_last_name:((B=C.attributeMapping)==null?void 0:B.last_name)||"",attr_email:((L=C.attributeMapping)==null?void 0:L.email)||""}})},f=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",z=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",_=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",j=(C,P)=>{navigator.clipboard.writeText(C),u(P),setTimeout(()=>u(null),2e3)},M=async C=>{C.preventDefault(),a(!0);try{const P={};x.attr_first_name&&(P.first_name=x.attr_first_name),x.attr_last_name&&(P.last_name=x.attr_last_name),x.attr_email&&(P.email=x.attr_email);const T=Object.keys(P).length>0;c==="saml"?await t({protocol:"saml",domain_id:x.domain_id||void 0,idp_entity_id:x.idp_entity_id,idp_sso_url:x.idp_sso_url,idp_certificate:x.idp_certificate,jit_enabled:x.jit_enabled,...T&&{attribute_mapping:P}}):await t({protocol:"oidc",domain_id:x.domain_id||void 0,oidc_issuer_url:x.oidc_issuer_url,oidc_client_id:x.oidc_client_id,oidc_client_secret:x.oidc_client_secret,oidc_scopes:x.oidc_scopes,jit_enabled:x.jit_enabled,...T&&{attribute_mapping:P}})}finally{a(!1)}},R=async()=>{S(!0),I(null);const C=B=>B.includes("{")||B.includes("}"),P={},T={};if(c==="saml"?(x.idp_entity_id?C(x.idp_entity_id)?(T.entity_id_valid=!1,P.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):T.entity_id_valid=!0:(T.entity_id_valid=!1,P.entity_id_valid="IdP Entity ID is required"),x.idp_sso_url?C(x.idp_sso_url)?(T.sso_url_valid=!1,P.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):T.sso_url_valid=!0:(T.sso_url_valid=!1,P.sso_url_valid="IdP SSO URL is required"),x.idp_certificate?T.certificate_provided=!0:(T.certificate_provided=!1,P.certificate_provided="X.509 Certificate is required")):(x.oidc_issuer_url?C(x.oidc_issuer_url)?(T.issuer_url_valid=!1,P.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):T.issuer_url_valid=!0:(T.issuer_url_valid=!1,P.issuer_url_valid="Issuer URL is required"),x.oidc_client_id?C(x.oidc_client_id)?(T.client_id_valid=!1,P.client_id_valid="Client ID contains placeholder values - please replace with actual values"):T.client_id_valid=!0:(T.client_id_valid=!1,P.client_id_valid="Client ID is required")),Object.keys(P).length>0){I({success:!1,checks:T,errors:P}),S(!1);return}try{const B=c==="saml"?{protocol:"saml",idp_entity_id:x.idp_entity_id,idp_sso_url:x.idp_sso_url,idp_certificate:x.idp_certificate}:{protocol:"oidc",oidc_issuer_url:x.oidc_issuer_url,oidc_client_id:x.oidc_client_id,oidc_client_secret:x.oidc_client_secret},L=await(o==null?void 0:o(B));L&&I(L)}catch(B){I({success:!1,checks:{},errors:{general:"Test failed: "+B.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:M,children:[p?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[p.logo?e.jsx(Nn,{src:p.logo,alt:p.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:p.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:p.protocol})]}),e.jsx("button",{type:"button",onClick:()=>g(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{children:"SAML Providers"}),e.jsx(Qa,{children:Ka.filter(C=>C.protocol==="saml").map(C=>e.jsxs(Xa,{type:"button",$selected:!1,onClick:()=>b(C),children:[C.logo?e.jsx(Nn,{src:C.logo,alt:C.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Ja,{children:C.name})]},C.id))}),e.jsx(Fn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Qa,{children:Ka.filter(C=>C.protocol==="oidc").map(C=>e.jsxs(Xa,{type:"button",$selected:!1,onClick:()=>b(C),children:[C.logo?e.jsx(Nn,{src:C.logo,alt:C.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Ja,{children:C.name})]},C.id))})]}),p&&e.jsxs(e.Fragment,{children:[e.jsxs(Za,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:_}),e.jsx(br,{onClick:()=>j(_,"acs"),children:l==="acs"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:z}),e.jsx(br,{onClick:()=>j(z,"metadata"),children:l==="metadata"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:f}),e.jsx(br,{onClick:()=>j(f,"callback"),children:l==="callback"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Fn,{style:{margin:0},children:p?`${p.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[p&&p.docUrl&&e.jsxs("a",{href:p.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(zs,{size:12})," Docs"]}),e.jsx(X,{type:"button",onClick:R,disabled:$||!p,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:$?e.jsx(Ee,{size:16}):"Test Connection"}),e.jsx(X,{type:"submit",disabled:s||E.length===0||!p,style:{width:"auto",padding:"8px 16px"},children:s?e.jsx(Ee,{size:16}):"Create Connection"})]})]}),k&&(()=>{const C={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:k.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${k.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:k.success?"#10b981":"#ef4444"},children:k.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(k.checks).map(([P,T])=>{var B;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:T?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:T?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:C[P]||P.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((B=k.errors)==null?void 0:B[P])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:k.errors[P]})]})]},P)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!p&&e.jsxs(he,{children:[e.jsx(ie,{children:"Protocol *"}),e.jsxs(ei,{value:c,onChange:C=>h(C.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"Domain *"}),w?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):E.length===0?e.jsx(Za,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(ei,{value:x.domain_id,onChange:C=>y({...x,domain_id:C.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),E.map(C=>e.jsx("option",{value:C.id,children:C.fqdn},C.id))]})]}),c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"IdP Entity ID *"}),e.jsx(ce,{type:"text",value:x.idp_entity_id,onChange:C=>y({...x,idp_entity_id:C.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"IdP SSO URL *"}),e.jsx(ce,{type:"url",value:x.idp_sso_url,onChange:C=>y({...x,idp_sso_url:C.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"X.509 Certificate *"}),e.jsx(cx,{value:x.idp_certificate,onChange:C=>y({...x,idp_certificate:C.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Issuer URL *"}),e.jsx(ce,{type:"url",value:x.oidc_issuer_url,onChange:C=>y({...x,oidc_issuer_url:C.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client ID *"}),e.jsx(ce,{type:"text",value:x.oidc_client_id,onChange:C=>y({...x,oidc_client_id:C.target.value}),placeholder:"your-client-id",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client Secret *"}),e.jsx(ce,{type:"password",value:x.oidc_client_secret,onChange:C=>y({...x,oidc_client_secret:C.target.value}),placeholder:"your-client-secret",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Scopes"}),e.jsx(ce,{type:"text",value:x.oidc_scopes,onChange:C=>y({...x,oidc_scopes:C.target.value}),placeholder:"openid profile email"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:x.jit_enabled,onChange:C=>y({...x,jit_enabled:C.target.checked}),style:{width:"16px",height:"16px"}}),e.jsx("span",{style:{fontWeight:500,color:"var(--color-foreground)"},children:"Enable JIT Provisioning"})]}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px",marginLeft:"24px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px"},children:[e.jsxs("div",{onClick:()=>v(!m),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:m?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:m?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),m&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"First Name Attribute"}),e.jsx(ce,{type:"text",value:x.attr_first_name,onChange:C=>y({...x,attr_first_name:C.target.value}),placeholder:c==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Last Name Attribute"}),e.jsx(ce,{type:"text",value:x.attr_last_name,onChange:C=>y({...x,attr_last_name:C.target.value}),placeholder:c==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Email Attribute"}),e.jsx(ce,{type:"text",value:x.attr_email,onChange:C=>y({...x,attr_email:C.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},ti=d.div`
2646
+ `,gx=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=Ze(),{deployment:n}=ve(),[s,a]=i.useState(!1),[p,g]=i.useState(null),[c,h]=i.useState("saml"),[l,u]=i.useState(null),[m,x]=i.useState(!1),[v,y]=i.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[z,S]=i.useState(!1),[_,E]=i.useState(null),{data:I=[],isLoading:w}=Fe("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(P=>P.verified),{revalidateOnFocus:!1}),b=C=>{g(C),h(C.protocol),C.protocol==="saml"?y(P=>{var T,B,L;return{...P,idp_entity_id:C.placeholders.entityId||"",idp_sso_url:C.placeholders.ssoUrl||"",attr_first_name:((T=C.attributeMapping)==null?void 0:T.first_name)||"",attr_last_name:((B=C.attributeMapping)==null?void 0:B.last_name)||"",attr_email:((L=C.attributeMapping)==null?void 0:L.email)||""}}):y(P=>{var T,B,L;return{...P,oidc_issuer_url:C.placeholders.issuerUrl||"",oidc_scopes:C.placeholders.scopes||"openid profile email",attr_first_name:((T=C.attributeMapping)==null?void 0:T.first_name)||"",attr_last_name:((B=C.attributeMapping)==null?void 0:B.last_name)||"",attr_email:((L=C.attributeMapping)==null?void 0:L.email)||""}})},f=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",$=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",k=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",j=(C,P)=>{navigator.clipboard.writeText(C),u(P),setTimeout(()=>u(null),2e3)},M=async C=>{C.preventDefault(),a(!0);try{const P={};v.attr_first_name&&(P.first_name=v.attr_first_name),v.attr_last_name&&(P.last_name=v.attr_last_name),v.attr_email&&(P.email=v.attr_email);const T=Object.keys(P).length>0;c==="saml"?await t({protocol:"saml",domain_id:v.domain_id||void 0,idp_entity_id:v.idp_entity_id,idp_sso_url:v.idp_sso_url,idp_certificate:v.idp_certificate,jit_enabled:v.jit_enabled,...T&&{attribute_mapping:P}}):await t({protocol:"oidc",domain_id:v.domain_id||void 0,oidc_issuer_url:v.oidc_issuer_url,oidc_client_id:v.oidc_client_id,oidc_client_secret:v.oidc_client_secret,oidc_scopes:v.oidc_scopes,jit_enabled:v.jit_enabled,...T&&{attribute_mapping:P}})}finally{a(!1)}},R=async()=>{S(!0),E(null);const C=B=>B.includes("{")||B.includes("}"),P={},T={};if(c==="saml"?(v.idp_entity_id?C(v.idp_entity_id)?(T.entity_id_valid=!1,P.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):T.entity_id_valid=!0:(T.entity_id_valid=!1,P.entity_id_valid="IdP Entity ID is required"),v.idp_sso_url?C(v.idp_sso_url)?(T.sso_url_valid=!1,P.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):T.sso_url_valid=!0:(T.sso_url_valid=!1,P.sso_url_valid="IdP SSO URL is required"),v.idp_certificate?T.certificate_provided=!0:(T.certificate_provided=!1,P.certificate_provided="X.509 Certificate is required")):(v.oidc_issuer_url?C(v.oidc_issuer_url)?(T.issuer_url_valid=!1,P.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):T.issuer_url_valid=!0:(T.issuer_url_valid=!1,P.issuer_url_valid="Issuer URL is required"),v.oidc_client_id?C(v.oidc_client_id)?(T.client_id_valid=!1,P.client_id_valid="Client ID contains placeholder values - please replace with actual values"):T.client_id_valid=!0:(T.client_id_valid=!1,P.client_id_valid="Client ID is required")),Object.keys(P).length>0){E({success:!1,checks:T,errors:P}),S(!1);return}try{const B=c==="saml"?{protocol:"saml",idp_entity_id:v.idp_entity_id,idp_sso_url:v.idp_sso_url,idp_certificate:v.idp_certificate}:{protocol:"oidc",oidc_issuer_url:v.oidc_issuer_url,oidc_client_id:v.oidc_client_id,oidc_client_secret:v.oidc_client_secret},L=await(o==null?void 0:o(B));L&&E(L)}catch(B){E({success:!1,checks:{},errors:{general:"Test failed: "+B.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:M,children:[p?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[p.logo?e.jsx(Nn,{src:p.logo,alt:p.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Xe,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:p.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:p.protocol})]}),e.jsx("button",{type:"button",onClick:()=>g(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fn,{children:"SAML Providers"}),e.jsx(Qa,{children:Ka.filter(C=>C.protocol==="saml").map(C=>e.jsxs(Xa,{type:"button",$selected:!1,onClick:()=>b(C),children:[C.logo?e.jsx(Nn,{src:C.logo,alt:C.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Xe,{size:18,color:"#666"})}),e.jsx(Ja,{children:C.name})]},C.id))}),e.jsx(Fn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Qa,{children:Ka.filter(C=>C.protocol==="oidc").map(C=>e.jsxs(Xa,{type:"button",$selected:!1,onClick:()=>b(C),children:[C.logo?e.jsx(Nn,{src:C.logo,alt:C.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Xe,{size:18,color:"#666"})}),e.jsx(Ja,{children:C.name})]},C.id))})]}),p&&e.jsxs(e.Fragment,{children:[e.jsxs(Za,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:k}),e.jsx(br,{onClick:()=>j(k,"acs"),children:l==="acs"?e.jsx(Ve,{size:12}):e.jsx(Xt,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:$}),e.jsx(br,{onClick:()=>j($,"metadata"),children:l==="metadata"?e.jsx(Ve,{size:12}):e.jsx(Xt,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:f}),e.jsx(br,{onClick:()=>j(f,"callback"),children:l==="callback"?e.jsx(Ve,{size:12}):e.jsx(Xt,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Fn,{style:{margin:0},children:p?`${p.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[p&&p.docUrl&&e.jsxs("a",{href:p.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(zs,{size:12})," Docs"]}),e.jsx(X,{type:"button",onClick:R,disabled:z||!p,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:z?e.jsx(Ee,{size:16}):"Test Connection"}),e.jsx(X,{type:"submit",disabled:s||I.length===0||!p,style:{width:"auto",padding:"8px 16px"},children:s?e.jsx(Ee,{size:16}):"Create Connection"})]})]}),_&&(()=>{const C={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:_.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${_.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:_.success?"#10b981":"#ef4444"},children:_.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(_.checks).map(([P,T])=>{var B;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:T?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:T?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:C[P]||P.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((B=_.errors)==null?void 0:B[P])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:_.errors[P]})]})]},P)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!p&&e.jsxs(he,{children:[e.jsx(ie,{children:"Protocol *"}),e.jsxs(ei,{value:c,onChange:C=>h(C.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"Domain *"}),w?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):I.length===0?e.jsx(Za,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(ei,{value:v.domain_id,onChange:C=>y({...v,domain_id:C.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),I.map(C=>e.jsx("option",{value:C.id,children:C.fqdn},C.id))]})]}),c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"IdP Entity ID *"}),e.jsx(ce,{type:"text",value:v.idp_entity_id,onChange:C=>y({...v,idp_entity_id:C.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"IdP SSO URL *"}),e.jsx(ce,{type:"url",value:v.idp_sso_url,onChange:C=>y({...v,idp_sso_url:C.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ie,{children:"X.509 Certificate *"}),e.jsx(cx,{value:v.idp_certificate,onChange:C=>y({...v,idp_certificate:C.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Issuer URL *"}),e.jsx(ce,{type:"url",value:v.oidc_issuer_url,onChange:C=>y({...v,oidc_issuer_url:C.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client ID *"}),e.jsx(ce,{type:"text",value:v.oidc_client_id,onChange:C=>y({...v,oidc_client_id:C.target.value}),placeholder:"your-client-id",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Client Secret *"}),e.jsx(ce,{type:"password",value:v.oidc_client_secret,onChange:C=>y({...v,oidc_client_secret:C.target.value}),placeholder:"your-client-secret",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Scopes"}),e.jsx(ce,{type:"text",value:v.oidc_scopes,onChange:C=>y({...v,oidc_scopes:C.target.value}),placeholder:"openid profile email"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:v.jit_enabled,onChange:C=>y({...v,jit_enabled:C.target.checked}),style:{width:"16px",height:"16px"}}),e.jsx("span",{style:{fontWeight:500,color:"var(--color-foreground)"},children:"Enable JIT Provisioning"})]}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px",marginLeft:"24px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px"},children:[e.jsxs("div",{onClick:()=>x(!m),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:m?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:m?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),m&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"First Name Attribute"}),e.jsx(ce,{type:"text",value:v.attr_first_name,onChange:C=>y({...v,attr_first_name:C.target.value}),placeholder:c==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Last Name Attribute"}),e.jsx(ce,{type:"text",value:v.attr_last_name,onChange:C=>y({...v,attr_last_name:C.target.value}),placeholder:c==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Email Attribute"}),e.jsx(ce,{type:"text",value:v.attr_email,onChange:C=>y({...v,attr_email:C.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},ti=d.div`
2647
2647
  * {
2648
2648
  box-sizing: border-box;
2649
2649
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -2739,15 +2739,15 @@ cursor: pointer;
2739
2739
  @media (max-width: 768px) {
2740
2740
  padding: 20px 20px 0 20px;
2741
2741
  }
2742
- `,Rl=d.div`
2742
+ `,Il=d.div`
2743
2743
  display: flex;
2744
2744
  align-items: center;
2745
2745
  flex-wrap: wrap;
2746
2746
  gap: 12px;
2747
2747
  margin-bottom: 24px;
2748
- `,bx=()=>{var T,B,L,F;const{activeOrganization:t,loading:r}=Ze(),{switchOrganization:o,refetch:n}=Ue(),{workspaces:s}=Pt(),{deployment:a}=ve(),{deleteOrganization:p,updateOrganization:g}=Yo(),{toast:c}=He(),[h,l]=i.useState((t==null?void 0:t.name)||""),[u,m]=i.useState((t==null?void 0:t.description)||""),[v,x]=i.useState((t==null?void 0:t.image_url)||null),y=i.useRef(null),[$,S]=i.useState(!1),[k,I]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[E,w]=i.useState(""),[b,f]=i.useState(!1),[z,_]=i.useState(!1),j=i.useCallback(async()=>{if(!(!t||$))try{S(!0),await g(t,{name:h,description:u}),c("Changes saved","info")}catch(O){const A=O.message||"Failed to save changes. Please try again.";c(A,"error")}finally{S(!1)}},[t,h,u,v,k,g,c]);i.useEffect(()=>{var O;t&&(l(t.name||""),m(t.description||""),x(t.image_url||null),I({allowed_ips:((O=t.whitelisted_ips)==null?void 0:O.join(`
2749
- `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const M=i.useMemo(()=>s.filter(A=>A.organization.id===(t==null?void 0:t.id)),[s,t==null?void 0:t.id]),R=async()=>{if(!(!t||E!==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),w("")}};if(i.useEffect(()=>()=>{v&&URL.revokeObjectURL(v)},[v]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const C=O=>{var A;if((A=O.target.files)!=null&&A[0]){const J=O.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}v&&URL.revokeObjectURL(v),x(URL.createObjectURL(J)),setTimeout(()=>j(),100)}},P=()=>{y.current&&y.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:v?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:P,onMouseEnter:O=>{O.currentTarget.style.borderColor="var(--color-primary)",O.currentTarget.style.transform="scale(1.02)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--color-border)",O.currentTarget.style.transform="scale(1)"},children:[v?e.jsx("img",{src:v,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:C,"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(X,{onClick:()=>{var O;return(O=y.current)==null?void 0:O.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(Ur,{size:14}),v?"Change":"Upload"]}),e.jsxs(X,{onClick:()=>{x(null),y.current&&(y.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(Hr,{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(ie,{htmlFor:"name",children:"Organization Name"}),e.jsx(ce,{id:"name",type:"text",value:h,onChange:O=>l(O.target.value),onBlur:j,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(ce,{id:"description",as:"textarea",value:u,onChange:O=>m(O.target.value),onBlur:j,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"})]}),((T=a==null?void 0:a.b2b_settings)==null?void 0:T.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{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(Cr,{checked:k.mfa_required,onChange:()=>{I(O=>({...O,mfa_required:!O.mfa_required})),setTimeout(()=>j(),100)}})]}),((B=a==null?void 0:a.b2b_settings)==null?void 0:B.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(ie,{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(Cr,{checked:k.ip_restrictions,onChange:()=>{I(O=>({...O,ip_restrictions:!O.ip_restrictions})),setTimeout(()=>j(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),k.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(ce,{id:"allowed_ips",as:"textarea",value:k.allowed_ips,onChange:O=>I(A=>({...A,allowed_ips:O.target.value})),onBlur:j,placeholder:`192.168.1.1
2750
- 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"})]})]}),((L=a==null?void 0:a.b2b_settings)==null?void 0:L.workspaces_enabled)&&M.length>0&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Is,{options:M.map(O=>({value:O.id,label:O.name})),value:k.default_workspace_id,onChange:O=>{I(A=>({...A,default_workspace_id:O})),setTimeout(()=>j(),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"})]})]})]}),((F=a==null?void 0:a.b2b_settings)==null?void 0:F.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:z?"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(X,{onClick:()=>{z?(_(!1),w("")):_(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:z?"Cancel":"Delete"})]}),z&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(ce,{id:"confirm_name",type:"text",value:E,onChange:O=>w(O.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(X,{onClick:R,disabled:E!==(t==null?void 0:t.name)||b,style:{background:E===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:E===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:E===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:E===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:b?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})]})})},ri=d.span`
2748
+ `,bx=()=>{var T,B,L,F;const{activeOrganization:t,loading:r}=Ze(),{switchOrganization:o,refetch:n}=Ue(),{workspaces:s}=Pt(),{deployment:a}=ve(),{deleteOrganization:p,updateOrganization:g}=Yo(),{toast:c}=He(),[h,l]=i.useState((t==null?void 0:t.name)||""),[u,m]=i.useState((t==null?void 0:t.description)||""),[x,v]=i.useState((t==null?void 0:t.image_url)||null),y=i.useRef(null),[z,S]=i.useState(!1),[_,E]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[I,w]=i.useState(""),[b,f]=i.useState(!1),[$,k]=i.useState(!1),j=i.useCallback(async()=>{if(!(!t||z))try{S(!0),await g(t,{name:h,description:u}),c("Changes saved","info")}catch(O){const A=O.message||"Failed to save changes. Please try again.";c(A,"error")}finally{S(!1)}},[t,h,u,x,_,g,c]);i.useEffect(()=>{var O;t&&(l(t.name||""),m(t.description||""),v(t.image_url||null),E({allowed_ips:((O=t.whitelisted_ips)==null?void 0:O.join(`
2749
+ `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const M=i.useMemo(()=>s.filter(A=>A.organization.id===(t==null?void 0:t.id)),[s,t==null?void 0:t.id]),R=async()=>{if(!(!t||I!==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),w("")}};if(i.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const C=O=>{var A;if((A=O.target.files)!=null&&A[0]){const J=O.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(()=>j(),100)}},P=()=>{y.current&&y.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:O=>{O.currentTarget.style.borderColor="var(--color-primary)",O.currentTarget.style.transform="scale(1.02)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--color-border)",O.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(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:C,"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(X,{onClick:()=>{var O;return(O=y.current)==null?void 0:O.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(Ur,{size:14}),x?"Change":"Upload"]}),e.jsxs(X,{onClick:()=>{v(null),y.current&&(y.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(Hr,{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(ie,{htmlFor:"name",children:"Organization Name"}),e.jsx(ce,{id:"name",type:"text",value:h,onChange:O=>l(O.target.value),onBlur:j,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(ce,{id:"description",as:"textarea",value:u,onChange:O=>m(O.target.value),onBlur:j,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"})]}),((T=a==null?void 0:a.b2b_settings)==null?void 0:T.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{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(Cr,{checked:_.mfa_required,onChange:()=>{E(O=>({...O,mfa_required:!O.mfa_required})),setTimeout(()=>j(),100)}})]}),((B=a==null?void 0:a.b2b_settings)==null?void 0:B.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(ie,{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(Cr,{checked:_.ip_restrictions,onChange:()=>{E(O=>({...O,ip_restrictions:!O.ip_restrictions})),setTimeout(()=>j(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),_.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(ce,{id:"allowed_ips",as:"textarea",value:_.allowed_ips,onChange:O=>E(A=>({...A,allowed_ips:O.target.value})),onBlur:j,placeholder:`192.168.1.1
2750
+ 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"})]})]}),((L=a==null?void 0:a.b2b_settings)==null?void 0:L.workspaces_enabled)&&M.length>0&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Is,{options:M.map(O=>({value:O.id,label:O.name})),value:_.default_workspace_id,onChange:O=>{E(A=>({...A,default_workspace_id:O})),setTimeout(()=>j(),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"})]})]})]}),((F=a==null?void 0:a.b2b_settings)==null?void 0:F.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:$?"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(X,{onClick:()=>{$?(k(!1),w("")):k(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:$?"Cancel":"Delete"})]}),$&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(ce,{id:"confirm_name",type:"text",value:I,onChange:O=>w(O.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(X,{onClick:R,disabled:I!==(t==null?void 0:t.name)||b,style:{background:I===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:I===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:I===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:I===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:b?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})]})})},ri=d.span`
2751
2751
  background: var(--color-primary-background);
2752
2752
  color: var(--color-primary);
2753
2753
  padding: 4px 8px;
@@ -2784,7 +2784,7 @@ cursor: pointer;
2784
2784
  opacity: 0.5;
2785
2785
  cursor: not-allowed;
2786
2786
  }
2787
- `,yx=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=Ze(),s=i.useRef(null),[a,p]=i.useState(null),{data:g=[],isLoading:c,mutate:h}=Fe(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((_,j)=>({..._,verified:_.verified!==void 0?_.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),l=g,[u,m]=i.useState(!1),[v,x]=i.useState(null),[y,$]=i.useState(""),[S,k]=i.useState(null),I=i.useRef(null),E=i.useRef({}),w=i.useMemo(()=>{let z=l;if(y.trim()!==""){const _=y.toLowerCase();z=z.filter(j=>j.fqdn.toLowerCase().includes(_))}return z},[l,y]),b=async z=>{await n(z),h()},f=async z=>{x(z)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Rl,{children:[e.jsx(St,{value:y,onChange:$,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(X,{ref:I,onClick:()=>m(!u),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),u&&e.jsx(qa,{onClose:()=>{m(!1),h()},triggerRef:I})]})]}),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","."]}),w!=null&&w.length?e.jsxs(ht,{ref:s,children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Domain"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{children:"Date Added"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:w.map(z=>e.jsxs(Ne,{children:[e.jsx(Me,{children:z.fqdn}),e.jsx(Me,{children:z.verified?e.jsx(ri,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(ri,{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(Me,{children:new Date(z.created_at).toLocaleDateString()}),e.jsx(mt,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(nt,{style:{marginLeft:"auto"},open:S===z.id,openChange:_=>k(_?z.id:null),children:[e.jsx(at,{children:e.jsx(Rs,{ref:_=>{E.current[z.id]=_},children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{f(z.id),k(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:z.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Te,{onClick:()=>{k(null),navigator.clipboard.writeText(z.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jt,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Te,{onClick:()=>{window.open(`https://${z.fqdn}`,"_blank"),k(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(zs,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>{k(null),p(z.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),a===z.id&&e.jsx(Yr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>b(z),onCancel:()=>p(null)}),v===z.id&&e.jsx(qa,{domain:z,onClose:()=>x(null),triggerRef:{current:E.current[z.id]}})]})})]},z.id))})]}):e.jsx(it,{title:y!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},wx=d.div`
2787
+ `,yx=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=Ze(),s=i.useRef(null),[a,p]=i.useState(null),{data:g=[],isLoading:c,mutate:h}=Fe(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((k,j)=>({...k,verified:k.verified!==void 0?k.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),l=g,[u,m]=i.useState(!1),[x,v]=i.useState(null),[y,z]=i.useState(""),[S,_]=i.useState(null),E=i.useRef(null),I=i.useRef({}),w=i.useMemo(()=>{let $=l;if(y.trim()!==""){const k=y.toLowerCase();$=$.filter(j=>j.fqdn.toLowerCase().includes(k))}return $},[l,y]),b=async $=>{await n($),h()},f=async $=>{v($)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Il,{children:[e.jsx(St,{value:y,onChange:z,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(X,{ref:E,onClick:()=>m(!u),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),u&&e.jsx(qa,{onClose:()=>{m(!1),h()},triggerRef:E})]})]}),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","."]}),w!=null&&w.length?e.jsxs(ht,{ref:s,children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Domain"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{children:"Date Added"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:w.map($=>e.jsxs(Ne,{children:[e.jsx(Me,{children:$.fqdn}),e.jsx(Me,{children:$.verified?e.jsx(ri,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(ri,{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(Me,{children:new Date($.created_at).toLocaleDateString()}),e.jsx(mt,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(nt,{style:{marginLeft:"auto"},open:S===$.id,openChange:k=>_(k?$.id:null),children:[e.jsx(at,{children:e.jsx(Rs,{ref:k=>{I.current[$.id]=k},children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{f($.id),_(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:$.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Te,{onClick:()=>{_(null),navigator.clipboard.writeText($.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Xt,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Te,{onClick:()=>{window.open(`https://${$.fqdn}`,"_blank"),_(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(zs,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>{_(null),p($.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),a===$.id&&e.jsx(Yr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>b($),onCancel:()=>p(null)}),x===$.id&&e.jsx(qa,{domain:$,onClose:()=>v(null),triggerRef:{current:I.current[$.id]}})]})})]},$.id))})]}):e.jsx(it,{title:y!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},wx=d.div`
2788
2788
  width: 40px;
2789
2789
  height: 40px;
2790
2790
  border-radius: 50%;
@@ -2796,7 +2796,7 @@ cursor: pointer;
2796
2796
  font-weight: 400;
2797
2797
  font-size: 14px;
2798
2798
  overflow: hidden;
2799
- `,jx=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:s,removeMemberRole:a,removeMember:p}=Ze(),{session:g}=Ue(),{toast:c}=He(),[h,l]=i.useState(""),[u,m]=i.useState(!1),v=i.useRef(null),{data:x=[],isLoading:y,mutate:$}=Fe(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:S=[],isLoading:k}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),I=S,E=i.useMemo(()=>h?x.filter(j=>{var B;const M=j.user;if(!M)return!1;const R=M.first_name||"",C=M.last_name||"",P=((B=M.primary_email_address)==null?void 0:B.email)||"";return`${R} ${C}`.trim().toLowerCase().includes(h.toLowerCase())||P.toLowerCase().includes(h.toLowerCase())}):x,[x,h]),w=async(j,M,R)=>{try{R?(await a(j,M),c("Role removed successfully","info")):(await s(j,M),c("Role added successfully","info")),$()}catch(C){const P=C.message||"Failed to update role. Please try again.";c(P,"error")}},b=(j="",M="")=>`${j[0]||""}${M[0]||""}`.toUpperCase(),f=(j,M)=>{var R;return((R=j.roles)==null?void 0:R.some(C=>C.id===M))||!1},z=async j=>{try{await p(j),$(),c("Member removed successfully","info")}catch(M){const R=M.message||"Failed to remove member. Please try again.";c(R,"error")}},_=()=>{m(!1),$(),c("Invitation sent successfully","info")};return r||y||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):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(St,{value:h,onChange:l,placeholder:"Search members..."})}),e.jsx(X,{ref:v,onClick:()=>m(!u),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"})]}),u&&e.jsx($l,{onClose:()=>m(!1),onSuccess:_,roles:I,triggerRef:v}),E.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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Roles"})]})}),e.jsx(gt,{children:E.map(j=>{var P,T;const M=j.roles||[],R=j.user,C=(R==null?void 0:R.id)===((P=g==null?void 0:g.active_signin)==null?void 0:P.user_id);return e.jsxs(Ne,{children:[e.jsx(El,{children:e.jsxs("div",{children:[e.jsx(wx,{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 L;if(!R)return"Unknown User";const B=`${R.first_name||""} ${R.last_name||""}`.trim();return B||((L=R.primary_email_address)==null?void 0:L.email)||"Unknown User"})()}),C&&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:(T=R==null?void 0:R.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Me,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(X,{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:M.length>0?M[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[I.map(B=>{const L=f(j,B.id);return e.jsx(Te,{onClick:()=>w(j,B,L),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:B.name}),L&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},B.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>z(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},_x=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:s,resendInvitation:a}=Ze(),{toast:p}=He(),[g,c]=i.useState(!1),[h,l]=i.useState(""),u=i.useRef(null),{data:m=[],isLoading:v,mutate:x}=Fe(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:y=[],isLoading:$}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),S=y,k=i.useMemo(()=>h?m.filter(b=>b.email.toLowerCase().includes(h.toLowerCase())):m,[m,h]),I=()=>{p("Invitation sent successfully","info"),x(),c(!1)},E=async b=>{try{await s(b),x(),p("Invitation cancelled successfully","info")}catch(f){const z=f.message||"Failed to cancel invitation. Please try again.";p(z,"error")}},w=async b=>{try{await a(b),p("Invitation resent successfully","info")}catch(f){const z=f.message||"Failed to resend invitation. Please try again.";p(z,"error")}};return r||v||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):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(St,{value:h,onChange:l,placeholder:"Search invitations..."})}),e.jsx(X,{ref:u,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($l,{onClose:()=>c(!1),onSuccess:I,roles:S,triggerRef:u}),k.length===0?e.jsx(it,{title:h?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:k.map(b=>{var f;return e.jsxs(Ne,{children:[e.jsx(Me,{children:b.email}),e.jsx(Me,{children:((f=b.initial_organization_role)==null?void 0:f.name)||"No role"}),e.jsx(Me,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsx(Rs,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>w(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(on,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>E(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},b.id)})})]})]})},kx=()=>{var b;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=Ze(),{deployment:s}=ve(),[a,p]=i.useState({isOpen:!1}),[g,c]=i.useState(null),[h,l]=i.useState(null),[u,m]=i.useState(""),[v,x]=i.useState(null),y=i.useRef(null),{data:$=[],isLoading:S,mutate:k}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),I=i.useMemo(()=>u?$.filter(f=>f.name.toLowerCase().includes(u.toLowerCase())):$,[$,u]),E=async f=>{try{f.id?(await new Promise(z=>setTimeout(z,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(z=>setTimeout(z,1e3)),c({text:"Role created successfully",type:"success"})),p({isOpen:!1}),k()}catch(z){const _=(z==null?void 0:z.message)||(f.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");f.id?c({text:_,type:"error"}):c({text:_,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},w=async f=>{try{await n(f),k()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):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(Rl,{children:[e.jsx(St,{placeholder:"Search roles",onChange:m,value:u}),((b=s==null?void 0:s.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(X,{ref:y,onClick:()=>p({isOpen:!a.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),a.isOpen&&!a.role&&e.jsx(Ya,{role:a.role,onClose:()=>p({isOpen:!1}),onSuccess:E,triggerRef:y})]})]}),I.length===0?e.jsx(it,{title:u?"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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:I.map(f=>{var z;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:f.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:f.permissions.join(", ")}),e.jsx(mt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:h===f.id,openChange:_=>l(_?f.id:null),children:[e.jsx(at,{children:e.jsx(Rs,{disabled:!f.organization_id,"data-role-dropdown-trigger":f.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{l(null),p({isOpen:!0,role:f})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{l(null),x(f.id)},children:"Remove Role"})]})]}),v===f.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>w(f),onCancel:()=>x(null)}),a.isOpen&&((z=a.role)==null?void 0:z.id)===f.id&&e.jsx(Ya,{role:a.role,onClose:()=>{p({isOpen:!1}),l(null)},onSuccess:E})]})})]},f.id)})})]})]})},Tl=()=>{const{loading:t,activeOrganization:r}=Ze(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((h,l="info")=>{a(h),g(l),setTimeout(()=>a(null),3e3)},[a]);return t?e.jsx(Bn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):r?e.jsx(ti,{children:e.jsx(Ps.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Bn,{children:[e.jsx(mx,{children:e.jsxs(xx,{children:[e.jsx(hr,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(fr,{children:[e.jsx(er,{size:16}),"General"]})}),e.jsx(hr,{$isActive:o==="domains",onClick:()=>n("domains"),children:e.jsxs(fr,{children:[e.jsx(ch,{size:16}),"Domains"]})}),e.jsx(hr,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(fr,{children:[e.jsx(Uo,{size:16}),"Members"]})}),e.jsx(hr,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(fr,{children:[e.jsx(on,{size:16}),"Invitations"]})}),e.jsx(hr,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"Roles"]})}),e.jsx(hr,{$isActive:o==="sso",onClick:()=>n("sso"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"SSO"]})})]})}),e.jsxs(vx,{children:[o==="general"&&e.jsx(bx,{}),o==="domains"&&e.jsx(yx,{}),o==="members"&&e.jsx(jx,{}),o==="invitations"&&e.jsx(_x,{}),o==="roles"&&e.jsx(kx,{}),o==="sso"&&e.jsx(lx,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",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",wordBreak:"break-word"},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(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):e.jsx(ti,{children:e.jsx(Bn,{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(Ur,{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(Hl,{})]})})})},Cx=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:p,children:g,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),p||g||e.jsx(Tl,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Sx=d.div`
2799
+ `,jx=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:s,removeMemberRole:a,removeMember:p}=Ze(),{session:g}=Ue(),{toast:c}=He(),[h,l]=i.useState(""),[u,m]=i.useState(!1),x=i.useRef(null),{data:v=[],isLoading:y,mutate:z}=Fe(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:S=[],isLoading:_}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),E=S,I=i.useMemo(()=>h?v.filter(j=>{var B;const M=j.user;if(!M)return!1;const R=M.first_name||"",C=M.last_name||"",P=((B=M.primary_email_address)==null?void 0:B.email)||"";return`${R} ${C}`.trim().toLowerCase().includes(h.toLowerCase())||P.toLowerCase().includes(h.toLowerCase())}):v,[v,h]),w=async(j,M,R)=>{try{R?(await a(j,M),c("Role removed successfully","info")):(await s(j,M),c("Role added successfully","info")),z()}catch(C){const P=C.message||"Failed to update role. Please try again.";c(P,"error")}},b=(j="",M="")=>`${j[0]||""}${M[0]||""}`.toUpperCase(),f=(j,M)=>{var R;return((R=j.roles)==null?void 0:R.some(C=>C.id===M))||!1},$=async j=>{try{await p(j),z(),c("Member removed successfully","info")}catch(M){const R=M.message||"Failed to remove member. Please try again.";c(R,"error")}},k=()=>{m(!1),z(),c("Invitation sent successfully","info")};return r||y||_?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):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(St,{value:h,onChange:l,placeholder:"Search members..."})}),e.jsx(X,{ref:x,onClick:()=>m(!u),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"})]}),u&&e.jsx($l,{onClose:()=>m(!1),onSuccess:k,roles:E,triggerRef:x}),I.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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Roles"})]})}),e.jsx(gt,{children:I.map(j=>{var P,T;const M=j.roles||[],R=j.user,C=(R==null?void 0:R.id)===((P=g==null?void 0:g.active_signin)==null?void 0:P.user_id);return e.jsxs(Ne,{children:[e.jsx(El,{children:e.jsxs("div",{children:[e.jsx(wx,{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 L;if(!R)return"Unknown User";const B=`${R.first_name||""} ${R.last_name||""}`.trim();return B||((L=R.primary_email_address)==null?void 0:L.email)||"Unknown User"})()}),C&&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:(T=R==null?void 0:R.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Me,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(X,{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:M.length>0?M[0].name:"No role"}),e.jsx(rr,{size:14})]})}),e.jsxs(st,{children:[E.map(B=>{const L=f(j,B.id);return e.jsx(Te,{onClick:()=>w(j,B,L),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:B.name}),L&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},B.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>$(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},_x=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:s,resendInvitation:a}=Ze(),{toast:p}=He(),[g,c]=i.useState(!1),[h,l]=i.useState(""),u=i.useRef(null),{data:m=[],isLoading:x,mutate:v}=Fe(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:y=[],isLoading:z}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),S=y,_=i.useMemo(()=>h?m.filter(b=>b.email.toLowerCase().includes(h.toLowerCase())):m,[m,h]),E=()=>{p("Invitation sent successfully","info"),v(),c(!1)},I=async b=>{try{await s(b),v(),p("Invitation cancelled successfully","info")}catch(f){const $=f.message||"Failed to cancel invitation. Please try again.";p($,"error")}},w=async b=>{try{await a(b),p("Invitation resent successfully","info")}catch(f){const $=f.message||"Failed to resend invitation. Please try again.";p($,"error")}};return r||x||z?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):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(St,{value:h,onChange:l,placeholder:"Search invitations..."})}),e.jsx(X,{ref:u,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($l,{onClose:()=>c(!1),onSuccess:E,roles:S,triggerRef:u}),_.length===0?e.jsx(it,{title:h?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:_.map(b=>{var f;return e.jsxs(Ne,{children:[e.jsx(Me,{children:b.email}),e.jsx(Me,{children:((f=b.initial_organization_role)==null?void 0:f.name)||"No role"}),e.jsx(Me,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsx(Rs,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>w(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(on,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>I(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},b.id)})})]})]})},kx=()=>{var b;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=Ze(),{deployment:s}=ve(),[a,p]=i.useState({isOpen:!1}),[g,c]=i.useState(null),[h,l]=i.useState(null),[u,m]=i.useState(""),[x,v]=i.useState(null),y=i.useRef(null),{data:z=[],isLoading:S,mutate:_}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),E=i.useMemo(()=>u?z.filter(f=>f.name.toLowerCase().includes(u.toLowerCase())):z,[z,u]),I=async f=>{try{f.id?(await new Promise($=>setTimeout($,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise($=>setTimeout($,1e3)),c({text:"Role created successfully",type:"success"})),p({isOpen:!1}),_()}catch($){const k=($==null?void 0:$.message)||(f.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");f.id?c({text:k,type:"error"}):c({text:k,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},w=async f=>{try{await n(f),_()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):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(Il,{children:[e.jsx(St,{placeholder:"Search roles",onChange:m,value:u}),((b=s==null?void 0:s.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(X,{ref:y,onClick:()=>p({isOpen:!a.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),a.isOpen&&!a.role&&e.jsx(Ya,{role:a.role,onClose:()=>p({isOpen:!1}),onSuccess:I,triggerRef:y})]})]}),E.length===0?e.jsx(it,{title:u?"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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:E.map(f=>{var $;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:f.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:f.permissions.join(", ")}),e.jsx(mt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:h===f.id,openChange:k=>l(k?f.id:null),children:[e.jsx(at,{children:e.jsx(Rs,{disabled:!f.organization_id,"data-role-dropdown-trigger":f.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{l(null),p({isOpen:!0,role:f})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{l(null),v(f.id)},children:"Remove Role"})]})]}),x===f.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>w(f),onCancel:()=>v(null)}),a.isOpen&&(($=a.role)==null?void 0:$.id)===f.id&&e.jsx(Ya,{role:a.role,onClose:()=>{p({isOpen:!1}),l(null)},onSuccess:I})]})})]},f.id)})})]})]})},Pl=()=>{var l;const{loading:t,activeOrganization:r}=Ze(),{deployment:o}=ve(),[n,s]=i.useState("general"),[a,p]=i.useState(null),[g,c]=i.useState("info"),h=i.useCallback((u,m="info")=>{p(u),c(m),setTimeout(()=>p(null),3e3)},[p]);return t?e.jsx(Bn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):r?e.jsx(ti,{children:e.jsx(Ps.Provider,{value:{screen:null,setScreen:()=>{},toast:h},children:e.jsxs(Bn,{children:[e.jsx(mx,{children:e.jsxs(xx,{children:[e.jsx(hr,{$isActive:n==="general",onClick:()=>s("general"),children:e.jsxs(fr,{children:[e.jsx(Jt,{size:16}),"General"]})}),e.jsx(hr,{$isActive:n==="domains",onClick:()=>s("domains"),children:e.jsxs(fr,{children:[e.jsx(ah,{size:16}),"Domains"]})}),e.jsx(hr,{$isActive:n==="members",onClick:()=>s("members"),children:e.jsxs(fr,{children:[e.jsx(Uo,{size:16}),"Members"]})}),e.jsx(hr,{$isActive:n==="invitations",onClick:()=>s("invitations"),children:e.jsxs(fr,{children:[e.jsx(on,{size:16}),"Invitations"]})}),e.jsx(hr,{$isActive:n==="roles",onClick:()=>s("roles"),children:e.jsxs(fr,{children:[e.jsx(Xe,{size:16}),"Roles"]})}),((l=o==null?void 0:o.b2b_settings)==null?void 0:l.enterprise_sso_enabled)&&e.jsx(hr,{$isActive:n==="sso",onClick:()=>s("sso"),children:e.jsxs(fr,{children:[e.jsx(Xe,{size:16}),"Single Sign-On"]})})]})}),e.jsxs(vx,{children:[n==="general"&&e.jsx(bx,{}),n==="domains"&&e.jsx(yx,{}),n==="members"&&e.jsx(jx,{}),n==="invitations"&&e.jsx(_x,{}),n==="roles"&&e.jsx(kx,{}),n==="sso"&&e.jsx(lx,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",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",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[g==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):e.jsx(ti,{children:e.jsx(Bn,{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(Ur,{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(Vl,{})]})})})},Cx=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:p,children:g,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),p||g||e.jsx(Pl,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Sx=d.div`
2800
2800
  display: flex;
2801
2801
  height: 100%;
2802
2802
  min-height: 400px;
@@ -2815,7 +2815,7 @@ cursor: pointer;
2815
2815
  padding: 32px;
2816
2816
  display: flex;
2817
2817
  flex-direction: column;
2818
- `,Ml=d.div`
2818
+ `,Rl=d.div`
2819
2819
  width: 80px;
2820
2820
  height: 80px;
2821
2821
  border-radius: 16px;
@@ -2978,7 +2978,7 @@ cursor: pointer;
2978
2978
  transition: opacity 0.2s ease;
2979
2979
  cursor: pointer;
2980
2980
 
2981
- ${Ml}:hover & {
2981
+ ${Rl}:hover & {
2982
2982
  opacity: 1;
2983
2983
  }
2984
2984
  `,Vx=d.div`
@@ -3030,7 +3030,7 @@ cursor: pointer;
3030
3030
  z-index: 10;
3031
3031
  max-height: 200px;
3032
3032
  overflow-y: auto;
3033
- `,Ol=d.button`
3033
+ `,Tl=d.button`
3034
3034
  width: 100%;
3035
3035
  padding: 8px 12px;
3036
3036
  border: none;
@@ -3069,7 +3069,7 @@ cursor: pointer;
3069
3069
  width: 100%;
3070
3070
  height: 100%;
3071
3071
  object-fit: cover;
3072
- `,Yx=d(Ol)`
3072
+ `,Yx=d(Tl)`
3073
3073
  border-top: 1px solid var(--color-border);
3074
3074
  color: var(--color-primary);
3075
3075
  font-weight: 400;
@@ -3087,7 +3087,7 @@ cursor: pointer;
3087
3087
  align-items: center;
3088
3088
  justify-content: center;
3089
3089
  color: var(--color-primary);
3090
- `,Ts=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var P;const[s,a]=i.useState(""),[p,g]=i.useState(""),[c,h]=i.useState(),[l,u]=i.useState(null),[m,v]=i.useState(!1),[x,y]=i.useState(!1),[$,S]=i.useState(t),k=i.useRef(null),I=i.useRef(null),{toast:E}=He(),{createWorkspace:w}=Pt(),{organizationMemberships:b}=Ct(),f=(P=b==null?void 0:b.find(T=>T.organization.id===$))==null?void 0:P.organization,z=T=>{if(T.target.files&&T.target.files[0]){const B=T.target.files[0];if(B.size>2*1024*1024){E("File size cannot exceed 2MB","error");return}if(!B.type.startsWith("image/")){E("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),h(B),u(URL.createObjectURL(B))}},_=()=>{var T;(T=k.current)==null||T.click()},j=T=>T.split(" ").map(B=>B[0]).join("").toUpperCase().slice(0,2)||"W",M=T=>T.trim().replace(/[<>\"'&]/g,""),R=T=>T.length>=2&&T.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(T),C=async()=>{const T=M(s),B=M(p);if(!T||!$){E("Please enter a workspace name","error");return}if(!R(T)){E("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(B.length>500){E("Description must be less than 500 characters","error");return}v(!0);try{const L=await w($,T,c,B);r==null||r(L)}catch(L){const F=L.message||"Failed to create workspace. Please try again.";E(F,"error")}finally{v(!1)}};return i.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]),i.useEffect(()=>{const T=B=>{I.current&&!I.current.contains(B.target)&&y(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),e.jsx(ge,{children:e.jsxs(Sx,{children:[e.jsxs(zx,{children:[e.jsxs(Ml,{hasImage:!!l,onClick:_,children:[l?e.jsx(Ex,{src:l,alt:"Workspace logo"}):e.jsx(Ix,{children:j(s||"W")}),e.jsx(Wx,{children:e.jsx(Vx,{children:"Upload Logo"})})]}),e.jsx(Ux,{type:"file",ref:k,onChange:z,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(Px,{children:"Create new workspace"}),e.jsx(Rx,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs($x,{children:[e.jsxs(Tx,{children:[e.jsx(Mx,{children:"Choose your workspace name"}),e.jsx(Ox,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(Ax,{children:[e.jsxs(Un,{children:[e.jsx(Wn,{children:"Organization"}),e.jsxs(Gx,{ref:I,children:[e.jsxs(Hx,{type:"button",onClick:()=>y(!x),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(oi,{children:f!=null&&f.image_url?e.jsx(ni,{src:f.image_url,alt:f.name}):j((f==null?void 0:f.name)||"O").charAt(0)}),e.jsx("span",{children:(f==null?void 0:f.name)||"Select organization"})]}),e.jsx(or,{size:16,style:{color:"var(--color-secondary-text)"}})]}),x&&e.jsxs(qx,{children:[b==null?void 0:b.map(T=>e.jsxs(Ol,{onClick:()=>{S(T.organization.id),y(!1)},children:[e.jsx(oi,{children:T.organization.image_url?e.jsx(ni,{src:T.organization.image_url,alt:T.organization.name}):j(T.organization.name).charAt(0)}),e.jsx("span",{children:T.organization.name})]},T.organization.id)),e.jsxs(Yx,{onClick:()=>{y(!1),n==null||n()},children:[e.jsx(Zx,{children:e.jsx(Ke,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Workspace name"}),e.jsx(Lx,{type:"text",value:s,onChange:T=>a(T.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Description (optional)"}),e.jsx(Dx,{value:p,onChange:T=>g(T.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(Nx,{children:[o?e.jsxs(Fx,{onClick:o,disabled:m,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Bx,{onClick:C,disabled:m||!s.trim(),children:m?"Creating...":"Create"})]})]})]})})},Al=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[s,a]=i.useState(!1),[p,g]=i.useState(n),{refetch:c,organizationMemberships:h}=Ct(),l=()=>{o==null||o(),r==null||r()},u=()=>{a(!0)},m=async()=>{await c(),setTimeout(()=>{if(h&&h.length>0){const v=h[h.length-1];g(v.organization.id)}a(!1)},500)};return e.jsx(ge,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:s?e.jsx(an,{onSuccess:m,onCancel:()=>a(!1)}):e.jsx(Ts,{organizationId:p||n,onSuccess:l,onCancel:r,onCreateOrganization:u})})})})})})},Kx=d.div`
3090
+ `,Ts=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var P;const[s,a]=i.useState(""),[p,g]=i.useState(""),[c,h]=i.useState(),[l,u]=i.useState(null),[m,x]=i.useState(!1),[v,y]=i.useState(!1),[z,S]=i.useState(t),_=i.useRef(null),E=i.useRef(null),{toast:I}=He(),{createWorkspace:w}=Pt(),{organizationMemberships:b}=Ct(),f=(P=b==null?void 0:b.find(T=>T.organization.id===z))==null?void 0:P.organization,$=T=>{if(T.target.files&&T.target.files[0]){const B=T.target.files[0];if(B.size>2*1024*1024){I("File size cannot exceed 2MB","error");return}if(!B.type.startsWith("image/")){I("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),h(B),u(URL.createObjectURL(B))}},k=()=>{var T;(T=_.current)==null||T.click()},j=T=>T.split(" ").map(B=>B[0]).join("").toUpperCase().slice(0,2)||"W",M=T=>T.trim().replace(/[<>\"'&]/g,""),R=T=>T.length>=2&&T.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(T),C=async()=>{const T=M(s),B=M(p);if(!T||!z){I("Please enter a workspace name","error");return}if(!R(T)){I("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(B.length>500){I("Description must be less than 500 characters","error");return}x(!0);try{const L=await w(z,T,c,B);r==null||r(L)}catch(L){const F=L.message||"Failed to create workspace. Please try again.";I(F,"error")}finally{x(!1)}};return i.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]),i.useEffect(()=>{const T=B=>{E.current&&!E.current.contains(B.target)&&y(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]),e.jsx(ge,{children:e.jsxs(Sx,{children:[e.jsxs(zx,{children:[e.jsxs(Rl,{hasImage:!!l,onClick:k,children:[l?e.jsx(Ex,{src:l,alt:"Workspace logo"}):e.jsx(Ix,{children:j(s||"W")}),e.jsx(Wx,{children:e.jsx(Vx,{children:"Upload Logo"})})]}),e.jsx(Ux,{type:"file",ref:_,onChange:$,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(Px,{children:"Create new workspace"}),e.jsx(Rx,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs($x,{children:[e.jsxs(Tx,{children:[e.jsx(Mx,{children:"Choose your workspace name"}),e.jsx(Ox,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(Ax,{children:[e.jsxs(Un,{children:[e.jsx(Wn,{children:"Organization"}),e.jsxs(Gx,{ref:E,children:[e.jsxs(Hx,{type:"button",onClick:()=>y(!v),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(oi,{children:f!=null&&f.image_url?e.jsx(ni,{src:f.image_url,alt:f.name}):j((f==null?void 0:f.name)||"O").charAt(0)}),e.jsx("span",{children:(f==null?void 0:f.name)||"Select organization"})]}),e.jsx(rr,{size:16,style:{color:"var(--color-secondary-text)"}})]}),v&&e.jsxs(qx,{children:[b==null?void 0:b.map(T=>e.jsxs(Tl,{onClick:()=>{S(T.organization.id),y(!1)},children:[e.jsx(oi,{children:T.organization.image_url?e.jsx(ni,{src:T.organization.image_url,alt:T.organization.name}):j(T.organization.name).charAt(0)}),e.jsx("span",{children:T.organization.name})]},T.organization.id)),e.jsxs(Yx,{onClick:()=>{y(!1),n==null||n()},children:[e.jsx(Zx,{children:e.jsx(Ke,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Workspace name"}),e.jsx(Lx,{type:"text",value:s,onChange:T=>a(T.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Description (optional)"}),e.jsx(Dx,{value:p,onChange:T=>g(T.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(Nx,{children:[o?e.jsxs(Fx,{onClick:o,disabled:m,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Bx,{onClick:C,disabled:m||!s.trim(),children:m?"Creating...":"Create"})]})]})]})})},Ml=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[s,a]=i.useState(!1),[p,g]=i.useState(n),{refetch:c,organizationMemberships:h}=Ct(),l=()=>{o==null||o(),r==null||r()},u=()=>{a(!0)},m=async()=>{await c(),setTimeout(()=>{if(h&&h.length>0){const x=h[h.length-1];g(x.organization.id)}a(!1)},500)};return e.jsx(ge,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:s?e.jsx(an,{onSuccess:m,onCancel:()=>a(!1)}):e.jsx(Ts,{organizationId:p||n,onSuccess:l,onCancel:r,onCreateOrganization:u})})})})})})},Kx=d.div`
3091
3091
  position: fixed;
3092
3092
  width: 360px;
3093
3093
  max-width: calc(100vw - 48px);
@@ -3136,7 +3136,7 @@ cursor: pointer;
3136
3136
  color: var(--color-foreground);
3137
3137
  background: var(--color-input-background);
3138
3138
  }
3139
- `,r0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:s})=>{const a=i.useRef(null),[p,g]=i.useState(""),[c,h]=i.useState(null),[l,u]=i.useState(!1),[m,v]=i.useState(!1),[x,y]=i.useState({top:0,left:0}),{toast:$}=He(),S=o.map(E=>({value:E.id,label:E.name}));i.useEffect(()=>{v(!0);const E=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const z=s.current;if(z){const _=z.getBoundingClientRect(),j=360,M=250,R=8;let C=0,P=0;const T=window.innerHeight-_.bottom,B=_.top;T>=M+R?(C=_.bottom+R,P=_.right-j,P<R&&(P=_.left,P+j>window.innerWidth-R&&(P=(window.innerWidth-j)/2))):B>=M+R?(C=_.top-M-R,P=_.right-j,P<R&&(P=_.left,P+j>window.innerWidth-R&&(P=(window.innerWidth-j)/2))):(C=_.bottom+R,P=_.right-j,P<R&&(P=_.left)),y({top:C,left:P})}},10),w=z=>{a.current&&!a.current.contains(z.target)&&(t==null||t())},b=z=>{z.key==="Escape"&&(t==null||t())},f=setTimeout(()=>{document.addEventListener("mousedown",w),document.addEventListener("keydown",b)},100);return()=>{clearTimeout(E),clearTimeout(f),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",b)}},[t,s]);const k=E=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E),I=async()=>{const E=p.trim().toLowerCase();if(!(!E||!c)){if(!k(E)){$("Please enter a valid email address","error");return}if(E.length>320){$("Email address is too long","error");return}u(!0);try{await n(E,c.id),r==null||r()}catch(w){const b=w.message||"Failed to send invitation. Please try again.";$(b,"error")}finally{u(!1)}}};return m?e.jsxs(Kx,{ref:a,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(Qx,{children:[e.jsx(Xx,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(t0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Jx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(ce,{type:"email",placeholder:"colleague@company.com",value:p,onChange:E=>g(E.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Is,{options:S,value:c==null?void 0:c.id,onChange:E=>h(o.find(w=>w.id===E)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(e0,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:I,disabled:!p||!c||l,style:{width:"auto"},children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},o0=d.div`
3139
+ `,r0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:s})=>{const a=i.useRef(null),[p,g]=i.useState(""),[c,h]=i.useState(null),[l,u]=i.useState(!1),[m,x]=i.useState(!1),[v,y]=i.useState({top:0,left:0}),{toast:z}=He(),S=o.map(I=>({value:I.id,label:I.name}));i.useEffect(()=>{x(!0);const I=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const $=s.current;if($){const k=$.getBoundingClientRect(),j=360,M=250,R=8;let C=0,P=0;const T=window.innerHeight-k.bottom,B=k.top;T>=M+R?(C=k.bottom+R,P=k.right-j,P<R&&(P=k.left,P+j>window.innerWidth-R&&(P=(window.innerWidth-j)/2))):B>=M+R?(C=k.top-M-R,P=k.right-j,P<R&&(P=k.left,P+j>window.innerWidth-R&&(P=(window.innerWidth-j)/2))):(C=k.bottom+R,P=k.right-j,P<R&&(P=k.left)),y({top:C,left:P})}},10),w=$=>{a.current&&!a.current.contains($.target)&&(t==null||t())},b=$=>{$.key==="Escape"&&(t==null||t())},f=setTimeout(()=>{document.addEventListener("mousedown",w),document.addEventListener("keydown",b)},100);return()=>{clearTimeout(I),clearTimeout(f),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",b)}},[t,s]);const _=I=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(I),E=async()=>{const I=p.trim().toLowerCase();if(!(!I||!c)){if(!_(I)){z("Please enter a valid email address","error");return}if(I.length>320){z("Email address is too long","error");return}u(!0);try{await n(I,c.id),r==null||r()}catch(w){const b=w.message||"Failed to send invitation. Please try again.";z(b,"error")}finally{u(!1)}}};return m?e.jsxs(Kx,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:I=>I.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(Qx,{children:[e.jsx(Xx,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(t0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(et,{size:16})})]}),e.jsx(Jx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Email Address"}),e.jsx(ce,{type:"email",placeholder:"colleague@company.com",value:p,onChange:I=>g(I.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Role"}),e.jsx(Is,{options:S,value:c==null?void 0:c.id,onChange:I=>h(o.find(w=>w.id===I)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(e0,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:E,disabled:!p||!c||l,style:{width:"auto"},children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},o0=d.div`
3140
3140
  position: fixed;
3141
3141
  width: 360px;
3142
3142
  max-width: calc(100vw - 48px);
@@ -3185,7 +3185,7 @@ cursor: pointer;
3185
3185
  color: var(--color-foreground);
3186
3186
  background: var(--color-input-background);
3187
3187
  }
3188
- `,si=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var E;const s=i.useRef(null),[a,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]),[h,l]=i.useState(!1),{deployment:u}=ve(),[m,v]=i.useState(!1),[x,y]=i.useState({top:0,left:0}),{toast:$}=He(),S=!!o,k=(((E=u==null?void 0:u.b2b_settings)==null?void 0:E.workspace_permissions)||[]).map(w=>({value:w,label:w}));i.useEffect(()=>{v(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const _=n.current;if(_){const j=_.getBoundingClientRect(),M=360,R=250,C=8;let P=0,T=0;const B=window.innerHeight-j.bottom,L=j.top;B>=R+C?(P=j.bottom+C,T=j.right-M,T<C&&(T=j.left,T+M>window.innerWidth-C&&(T=(window.innerWidth-M)/2))):L>=R+C?(P=j.top-R-C,T=j.right-M,T<C&&(T=j.left,T+M>window.innerWidth-C&&(T=(window.innerWidth-M)/2))):(P=j.bottom+C,T=j.right-M,T<C&&(T=j.left)),y({top:P,left:T})}},10),b=_=>{s.current&&!s.current.contains(_.target)&&(t==null||t())},f=_=>{_.key==="Escape"&&(t==null||t())},z=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",f)},100);return()=>{clearTimeout(w),clearTimeout(z),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,n]);const I=async()=>{if(a.trim()){l(!0);try{const w={id:o==null?void 0:o.id,name:a.trim(),permissions:g};r==null||r(w)}catch(w){const b=w.message||"Failed to save role. Please try again.";$(b,"error")}finally{l(!1)}}};return m?e.jsxs(o0,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:[e.jsxs(n0,{children:[e.jsx(s0,{children:S?"Edit Role":"Add Role"}),e.jsx(c0,{onClick:t,children:e.jsx(et,{size:16})})]}),e.jsx(a0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(ce,{type:"text",value:a,onChange:w=>p(w.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(bl,{options:k,value:g,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(i0,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:I,disabled:!a.trim()||h,style:{width:"auto"},children:h?"Saving...":S?"Update":"Create"})]})]}):null},l0=d.div`
3188
+ `,si=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var I;const s=i.useRef(null),[a,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]),[h,l]=i.useState(!1),{deployment:u}=ve(),[m,x]=i.useState(!1),[v,y]=i.useState({top:0,left:0}),{toast:z}=He(),S=!!o,_=(((I=u==null?void 0:u.b2b_settings)==null?void 0:I.workspace_permissions)||[]).map(w=>({value:w,label:w}));i.useEffect(()=>{x(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const k=n.current;if(k){const j=k.getBoundingClientRect(),M=360,R=250,C=8;let P=0,T=0;const B=window.innerHeight-j.bottom,L=j.top;B>=R+C?(P=j.bottom+C,T=j.right-M,T<C&&(T=j.left,T+M>window.innerWidth-C&&(T=(window.innerWidth-M)/2))):L>=R+C?(P=j.top-R-C,T=j.right-M,T<C&&(T=j.left,T+M>window.innerWidth-C&&(T=(window.innerWidth-M)/2))):(P=j.bottom+C,T=j.right-M,T<C&&(T=j.left)),y({top:P,left:T})}},10),b=k=>{s.current&&!s.current.contains(k.target)&&(t==null||t())},f=k=>{k.key==="Escape"&&(t==null||t())},$=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",f)},100);return()=>{clearTimeout(w),clearTimeout($),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,n]);const E=async()=>{if(a.trim()){l(!0);try{const w={id:o==null?void 0:o.id,name:a.trim(),permissions:g};r==null||r(w)}catch(w){const b=w.message||"Failed to save role. Please try again.";z(b,"error")}finally{l(!1)}}};return m?e.jsxs(o0,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:[e.jsxs(n0,{children:[e.jsx(s0,{children:S?"Edit Role":"Add Role"}),e.jsx(c0,{onClick:t,children:e.jsx(et,{size:16})})]}),e.jsx(a0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ie,{children:"Role Name"}),e.jsx(ce,{type:"text",value:a,onChange:w=>p(w.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{children:"Permissions"}),e.jsx(bl,{options:_,value:g,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(i0,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(X,{onClick:E,disabled:!a.trim()||h,style:{width:"auto"},children:h?"Saving...":S?"Update":"Create"})]})]}):null},l0=d.div`
3189
3189
  * {
3190
3190
  box-sizing: border-box;
3191
3191
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -3299,7 +3299,7 @@ cursor: pointer;
3299
3299
  font-weight: 400;
3300
3300
  font-size: 14px;
3301
3301
  overflow: hidden;
3302
- `,Ll=d.button`
3302
+ `,Ol=d.button`
3303
3303
  background: none;
3304
3304
  border: 1px solid var(--color-border);
3305
3305
  padding: 3px;
@@ -3321,11 +3321,11 @@ cursor: pointer;
3321
3321
  opacity: 0.5;
3322
3322
  cursor: not-allowed;
3323
3323
  }
3324
- `,f0=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,inviteMember:s,discardInvitation:a,resendInvitation:p}=Rt(),{toast:g}=He(),[c,h]=i.useState(!0),[l,u]=i.useState(!0),[m,v]=i.useState(""),[x,y]=i.useState([]),[$,S]=i.useState([]),[k,I]=i.useState(!1),E=i.useRef(null);i.useEffect(()=>{if(!t)return;(async()=>{h(!0),u(!0);try{const[j,M]=await Promise.all([o(),n()]);S(j),y(M)}catch{}finally{h(!1),u(!1)}})()},[t==null?void 0:t.id]);const w=async _=>{try{await a(_.id);const j=await n();y(j)}catch{}},b=async _=>{try{await p(_.id);const j=await n();y(j),g("Invitation resent successfully","info")}catch{}},f=async()=>{I(!1);const _=await n();y(_),g("Invitation sent successfully","info")},z=i.useMemo(()=>m?x.filter(_=>(_.email||"").toLowerCase().includes(m.toLowerCase())):x,[x,m]);return r||c||l?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{children:[e.jsx(St,{value:m,onChange:v,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(X,{ref:E,onClick:()=>I(!k),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),k&&e.jsx(r0,{onClose:()=>I(!1),onSuccess:f,roles:$,createInvitation:s,triggerRef:E})]})]}),e.jsx("div",{children:z.length===0?e.jsx(it,{title:m?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:z.map(_=>{var j,M;return e.jsxs(Ne,{children:[e.jsx(Me,{children:_.email}),e.jsx(Me,{children:((j=_.initial_workspace_role)==null?void 0:j.name)||((M=_.initial_organization_role)==null?void 0:M.name)||"No role"}),e.jsx(Me,{children:new Date(_.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsx(Ll,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>b(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx($s,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>w(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},_.id)})})]})})]})},g0=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:s,addMemberRole:a,removeMemberRole:p}=Rt(),{session:g}=Ue(),{toast:c}=He(),[h,l]=i.useState(""),{data:u=[],isLoading:m,mutate:v}=Fe(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:x=[],isLoading:y}=Fe(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),$=x,S=i.useMemo(()=>h?u.filter(b=>{var R;const f=b.public_user_data;if(!f)return!1;const z=f.first_name||"",_=f.last_name||"",j=((R=f.primary_email_address)==null?void 0:R.email)||"";return`${z} ${_}`.trim().toLowerCase().includes(h.toLowerCase())||j.toLowerCase().includes(h.toLowerCase())}):u,[u,h]),k=async b=>{try{await s(b),c("Member removed successfully","info"),v()}catch{c("Failed to remove member","error")}},I=async(b,f,z)=>{try{z?(await p(b,f),c("Role removed successfully","info")):(await a(b,f),c("Role added successfully","info")),v()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},E=(b="",f="")=>`${b[0]||""}${f[0]||""}`.toUpperCase(),w=(b,f)=>{var z;return((z=b.roles)==null?void 0:z.some(_=>_.id===f))||!1};return r||m||y?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Ms,{children:e.jsx(St,{value:h,onChange:l,placeholder:"Search members..."})}),S.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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Role"})]})}),e.jsx(gt,{children:S.map(b=>{var j,M;const f=b.public_user_data,z=b.roles||[],_=(f==null?void 0:f.id)===((j=g==null?void 0:g.active_signin)==null?void 0:j.user_id);return e.jsxs(Ne,{children:[e.jsx(El,{children:e.jsxs("div",{children:[e.jsx(h0,{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"}}):E(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 C;if(!f)return"Unknown User";const R=`${f.first_name||""} ${f.last_name||""}`.trim();return R||((C=f.primary_email_address)==null?void 0:C.email)||"Unknown User"})()}),_&&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:(M=f==null?void 0:f.primary_email_address)==null?void 0:M.email})]})]})}),e.jsx(Me,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(X,{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:z.length>0?z[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[$.map(R=>{const C=w(b,R.id);return e.jsx(Te,{onClick:()=>I(b.id,R.id,C),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:R.name}),C&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},R.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>k(b.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},b.id)})})]})]})},m0=()=>{var J,re;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Rt(),{deleteWorkspace:n}=Pt(),{deployment:s}=ve(),{toast:a}=He(),[p,g]=i.useState((t==null?void 0:t.name)||""),[c,h]=i.useState((t==null?void 0:t.description)||""),[l,u]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m,v]=i.useState(null),[x,y]=i.useState((t==null?void 0:t.image_url)||null),[$,S]=i.useState(!1),[k,I]=i.useState(!1),[E,w]=i.useState(""),[b,f]=i.useState(!1),[z,_]=i.useState(!1),j=i.useRef(null),M=i.useRef(null);if(i.useEffect(()=>{var V;t&&(g(t.name||""),h(t.description||""),y(t.image_url||null),u({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((V=t.whitelisted_ips)==null?void 0:V.join(`
3325
- `))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const R=V=>{var q;if((q=V.target.files)!=null&&q[0]){const H=V.target.files[0];v(H),y(URL.createObjectURL(H)),setTimeout(()=>P(),100)}},C=()=>{j.current&&j.current.click()},P=i.useCallback(async()=>{if(!(!t||k))try{I(!0);const V={};m&&(V.image=m,v(null)),p!==t.name&&(V.name=p),c!==t.description&&(V.description=c),l.mfa_required!==t.enforce_2fa&&(V.enforce_2fa=l.mfa_required),l.ip_restrictions!==t.enable_ip_restriction&&(V.enable_ip_restriction=l.ip_restrictions);const q=(t.whitelisted_ips||[]).join(`
3324
+ `,f0=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,inviteMember:s,discardInvitation:a,resendInvitation:p}=Rt(),{toast:g}=He(),[c,h]=i.useState(!0),[l,u]=i.useState(!0),[m,x]=i.useState(""),[v,y]=i.useState([]),[z,S]=i.useState([]),[_,E]=i.useState(!1),I=i.useRef(null);i.useEffect(()=>{if(!t)return;(async()=>{h(!0),u(!0);try{const[j,M]=await Promise.all([o(),n()]);S(j),y(M)}catch{}finally{h(!1),u(!1)}})()},[t==null?void 0:t.id]);const w=async k=>{try{await a(k.id);const j=await n();y(j)}catch{}},b=async k=>{try{await p(k.id);const j=await n();y(j),g("Invitation resent successfully","info")}catch{}},f=async()=>{E(!1);const k=await n();y(k),g("Invitation sent successfully","info")},$=i.useMemo(()=>m?v.filter(k=>(k.email||"").toLowerCase().includes(m.toLowerCase())):v,[v,m]);return r||c||l?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{children:[e.jsx(St,{value:m,onChange:x,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(X,{ref:I,onClick:()=>E(!_),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),_&&e.jsx(r0,{onClose:()=>E(!1),onSuccess:f,roles:z,createInvitation:s,triggerRef:I})]})]}),e.jsx("div",{children:$.length===0?e.jsx(it,{title:m?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email"}),e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Invited"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:$.map(k=>{var j,M;return e.jsxs(Ne,{children:[e.jsx(Me,{children:k.email}),e.jsx(Me,{children:((j=k.initial_workspace_role)==null?void 0:j.name)||((M=k.initial_organization_role)==null?void 0:M.name)||"No role"}),e.jsx(Me,{children:new Date(k.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsx(Ol,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>b(k),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx($s,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>w(k),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},k.id)})})]})})]})},g0=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:s,addMemberRole:a,removeMemberRole:p}=Rt(),{session:g}=Ue(),{toast:c}=He(),[h,l]=i.useState(""),{data:u=[],isLoading:m,mutate:x}=Fe(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:v=[],isLoading:y}=Fe(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),z=v,S=i.useMemo(()=>h?u.filter(b=>{var R;const f=b.public_user_data;if(!f)return!1;const $=f.first_name||"",k=f.last_name||"",j=((R=f.primary_email_address)==null?void 0:R.email)||"";return`${$} ${k}`.trim().toLowerCase().includes(h.toLowerCase())||j.toLowerCase().includes(h.toLowerCase())}):u,[u,h]),_=async b=>{try{await s(b),c("Member removed successfully","info"),x()}catch{c("Failed to remove member","error")}},E=async(b,f,$)=>{try{$?(await p(b,f),c("Role removed successfully","info")):(await a(b,f),c("Role added successfully","info")),x()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},I=(b="",f="")=>`${b[0]||""}${f[0]||""}`.toUpperCase(),w=(b,f)=>{var $;return(($=b.roles)==null?void 0:$.some(k=>k.id===f))||!1};return r||m||y?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Ms,{children:e.jsx(St,{value:h,onChange:l,placeholder:"Search members..."})}),S.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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Role"})]})}),e.jsx(gt,{children:S.map(b=>{var j,M;const f=b.public_user_data,$=b.roles||[],k=(f==null?void 0:f.id)===((j=g==null?void 0:g.active_signin)==null?void 0:j.user_id);return e.jsxs(Ne,{children:[e.jsx(El,{children:e.jsxs("div",{children:[e.jsx(h0,{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"}}):I(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 C;if(!f)return"Unknown User";const R=`${f.first_name||""} ${f.last_name||""}`.trim();return R||((C=f.primary_email_address)==null?void 0:C.email)||"Unknown User"})()}),k&&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:(M=f==null?void 0:f.primary_email_address)==null?void 0:M.email})]})]})}),e.jsx(Me,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(mt,{children:e.jsxs(nt,{children:[e.jsx(at,{children:e.jsxs(X,{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:$.length>0?$[0].name:"No role"}),e.jsx(rr,{size:14})]})}),e.jsxs(st,{children:[z.map(R=>{const C=w(b,R.id);return e.jsx(Te,{onClick:()=>E(b.id,R.id,C),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:R.name}),C&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},R.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>_(b.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},b.id)})})]})]})},m0=()=>{var J,re;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Rt(),{deleteWorkspace:n}=Pt(),{deployment:s}=ve(),{toast:a}=He(),[p,g]=i.useState((t==null?void 0:t.name)||""),[c,h]=i.useState((t==null?void 0:t.description)||""),[l,u]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m,x]=i.useState(null),[v,y]=i.useState((t==null?void 0:t.image_url)||null),[z,S]=i.useState(!1),[_,E]=i.useState(!1),[I,w]=i.useState(""),[b,f]=i.useState(!1),[$,k]=i.useState(!1),j=i.useRef(null),M=i.useRef(null);if(i.useEffect(()=>{var V;t&&(g(t.name||""),h(t.description||""),y(t.image_url||null),u({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((V=t.whitelisted_ips)==null?void 0:V.join(`
3325
+ `))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const R=V=>{var q;if((q=V.target.files)!=null&&q[0]){const H=V.target.files[0];x(H),y(URL.createObjectURL(H)),setTimeout(()=>P(),100)}},C=()=>{j.current&&j.current.click()},P=i.useCallback(async()=>{if(!(!t||_))try{E(!0);const V={};m&&(V.image=m,x(null)),p!==t.name&&(V.name=p),c!==t.description&&(V.description=c),l.mfa_required!==t.enforce_2fa&&(V.enforce_2fa=l.mfa_required),l.ip_restrictions!==t.enable_ip_restriction&&(V.enable_ip_restriction=l.ip_restrictions);const q=(t.whitelisted_ips||[]).join(`
3326
3326
  `);l.allowed_ips!==q&&(V.whitelisted_ips=l.allowed_ips.split(`
3327
- `).map(H=>H.trim()).filter(H=>H!=="")),Object.keys(V).length>0&&(await o(V),S(!0),setTimeout(()=>S(!1),3e3))}catch{a("Failed to auto-save workspace","error")}finally{I(!1)}},[t,o,p,c,m,l,k]),T=i.useCallback(()=>{M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{P()},1e3)},[P]),B=V=>{g(V.target.value),T()},L=V=>{h(V.target.value),T()},F=()=>{M.current&&clearTimeout(M.current),P()},O=()=>{M.current&&clearTimeout(M.current),P()},A=async()=>{if(!(!t||E!==t.name))try{f(!0),await n(t),a("Workspace deleted successfully","info")}catch(V){a(V.message||"Failed to delete workspace","error")}finally{f(!1),w(""),_(!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:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:C,onMouseEnter:V=>{V.currentTarget.style.borderColor="var(--color-primary)",V.currentTarget.style.transform="scale(1.02)"},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--color-border)",V.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:j,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:"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(X,{onClick:()=>{var V;return(V=j.current)==null?void 0:V.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(Ur,{size:14}),x?"Change":"Upload"]}),e.jsxs(X,{onClick:()=>{y(null),v(null),j.current&&(j.current.value=""),setTimeout(()=>P(),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(nn,{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(ie,{htmlFor:"name",children:"Workspace Name"}),e.jsx(ce,{id:"name",type:"text",value:p,onChange:B,onBlur:F,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(ce,{id:"description",as:"textarea",value:c,onChange:L,onBlur:O,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"})]}),((J=s==null?void 0:s.b2b_settings)==null?void 0:J.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{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(Cr,{checked:l.mfa_required,onChange:()=>{u(V=>({...V,mfa_required:!V.mfa_required})),setTimeout(()=>P(),100)}})]}),((re=s==null?void 0:s.b2b_settings)==null?void 0:re.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(ie,{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(Cr,{checked:l.ip_restrictions,onChange:()=>{u(V=>({...V,ip_restrictions:!V.ip_restrictions})),setTimeout(()=>P(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),l.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(ce,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:V=>u(q=>({...q,allowed_ips:V.target.value})),onBlur:P,placeholder:`192.168.1.1
3328
- 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:z?"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(X,{onClick:()=>{z?(_(!1),w("")):_(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:z?"Cancel":"Delete"})]}),z&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(ce,{id:"confirm_workspace_name",type:"text",value:E,onChange:V=>w(V.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(X,{onClick:A,disabled:E!==(t==null?void 0:t.name)||b,style:{background:E===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:E===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:E===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:E===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:b?e.jsx(Ee,{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:`
3327
+ `).map(H=>H.trim()).filter(H=>H!=="")),Object.keys(V).length>0&&(await o(V),S(!0),setTimeout(()=>S(!1),3e3))}catch{a("Failed to auto-save workspace","error")}finally{E(!1)}},[t,o,p,c,m,l,_]),T=i.useCallback(()=>{M.current&&clearTimeout(M.current),M.current=setTimeout(()=>{P()},1e3)},[P]),B=V=>{g(V.target.value),T()},L=V=>{h(V.target.value),T()},F=()=>{M.current&&clearTimeout(M.current),P()},O=()=>{M.current&&clearTimeout(M.current),P()},A=async()=>{if(!(!t||I!==t.name))try{f(!0),await n(t),a("Workspace deleted successfully","info")}catch(V){a(V.message||"Failed to delete workspace","error")}finally{f(!1),w(""),k(!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:C,onMouseEnter:V=>{V.currentTarget.style.borderColor="var(--color-primary)",V.currentTarget.style.transform="scale(1.02)"},onMouseLeave:V=>{V.currentTarget.style.borderColor="var(--color-border)",V.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(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:j,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:"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(X,{onClick:()=>{var V;return(V=j.current)==null?void 0:V.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(Ur,{size:14}),v?"Change":"Upload"]}),e.jsxs(X,{onClick:()=>{y(null),x(null),j.current&&(j.current.value=""),setTimeout(()=>P(),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(nn,{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(ie,{htmlFor:"name",children:"Workspace Name"}),e.jsx(ce,{id:"name",type:"text",value:p,onChange:B,onBlur:F,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"description",children:"Description"}),e.jsx(ce,{id:"description",as:"textarea",value:c,onChange:L,onBlur:O,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"})]}),((J=s==null?void 0:s.b2b_settings)==null?void 0:J.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ie,{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(Cr,{checked:l.mfa_required,onChange:()=>{u(V=>({...V,mfa_required:!V.mfa_required})),setTimeout(()=>P(),100)}})]}),((re=s==null?void 0:s.b2b_settings)==null?void 0:re.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(ie,{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(Cr,{checked:l.ip_restrictions,onChange:()=>{u(V=>({...V,ip_restrictions:!V.ip_restrictions})),setTimeout(()=>P(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),l.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(ce,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:V=>u(q=>({...q,allowed_ips:V.target.value})),onBlur:P,placeholder:`192.168.1.1
3328
+ 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:$?"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(X,{onClick:()=>{$?(k(!1),w("")):k(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:$?"Cancel":"Delete"})]}),$&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(ce,{id:"confirm_workspace_name",type:"text",value:I,onChange:V=>w(V.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(X,{onClick:A,disabled:I!==(t==null?void 0:t.name)||b,style:{background:I===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:I===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:I===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:I===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:b?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]}),z&&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:`
3329
3329
  @keyframes slideUp {
3330
3330
  from {
3331
3331
  opacity: 0;
@@ -3336,7 +3336,7 @@ cursor: pointer;
3336
3336
  transform: translateX(-50%) translateY(0);
3337
3337
  }
3338
3338
  }
3339
- `})]})},x0=()=>{var f;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:s}=Rt(),{toast:a}=He(),{deployment:p}=ve(),[g,c]=i.useState(""),[h,l]=i.useState({isOpen:!1}),[u,m]=i.useState(null),[v,x]=i.useState(null),y=i.useRef(null),$=i.useRef(new Map),{data:S=[],isLoading:k,mutate:I}=Fe(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),E=i.useMemo(()=>g?S.filter(z=>z.name.toLowerCase().includes(g.toLowerCase())):S,[S,g]),w=async z=>{try{await n(z.name,z.permissions||[]),a("Role created successfully","info"),l({isOpen:!1}),I()}catch{a("Failed to save role","error"),a("Failed to create role","error")}},b=async z=>{try{await s(z),a("Role deleted successfully","info"),x(null),I()}catch{a("Failed to delete role","error"),a("Failed to delete role","error")}};return r||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{children:[e.jsx(St,{placeholder:"Search roles",onChange:c,value:g}),e.jsxs("div",{style:{position:"relative"},children:[((f=p==null?void 0:p.b2b_settings)==null?void 0:f.custom_workspace_role_enabled)&&e.jsx(X,{ref:y,onClick:()=>l({isOpen:!0,triggerElement:y.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),h.isOpen&&!h.role&&e.jsx(si,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:w})]})]}),E.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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:E.map(z=>{var _;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:z.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:z.permissions&&z.permissions.length>0?z.permissions.join(", "):""}),e.jsx(mt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:u===z.id,openChange:j=>m(j?z.id:null),children:[e.jsx(at,{children:e.jsx(Ll,{ref:j=>{j&&$.current.set(z.id,j)},disabled:!z.workspace_id,"data-role-dropdown-trigger":z.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{m(null);const j=$.current.get(z.id);l({isOpen:!0,role:z,triggerElement:j||null})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{m(null),x(z.id)},children:"Remove Role"})]})]}),v===z.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>b(z),onCancel:()=>x(null)}),h.isOpen&&((_=h.role)==null?void 0:_.id)===z.id&&e.jsx(si,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>{l({isOpen:!1}),m(null)},onSuccess:w})]})})]},z.id)})})]})})]})},Dl=()=>{const{activeWorkspace:t,loading:r}=Rt(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((h,l="info")=>{a(h),g(l),setTimeout(()=>a(null),3e3)},[]);return r?e.jsx(ai,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):t?e.jsx(Ps.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(l0,{children:e.jsxs(ai,{children:[e.jsx(d0,{children:e.jsxs(u0,{children:[e.jsx(xo,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(vo,{children:[e.jsx(er,{size:16}),"General"]})}),e.jsx(xo,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(vo,{children:[e.jsx(Uo,{size:16}),"Members"]})}),e.jsx(xo,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(vo,{children:[e.jsx($s,{size:16}),"Invitations"]})}),e.jsx(xo,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(vo,{children:[e.jsx(Qe,{size:16}),"Roles"]})})]})}),e.jsxs(p0,{children:[o==="general"&&e.jsx(m0,{}),o==="members"&&e.jsx(g0,{}),o==="invitations"&&e.jsx(f0,{}),o==="roles"&&e.jsx(x0,{})]}),s&&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(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):null},Nl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:p,children:g,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),p||g||e.jsx(Dl,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Fl=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:s=8})=>{const[a,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,l=window.innerHeight,u=h-c.left,m=c.right,v=l-c.bottom,x=c.top;let y={};u>=o?y.left=c.left:m>=o?y.left=c.right-o:y.left=Math.max(s,Math.min(h-o-s,c.left)),v>=150?(y.top=c.bottom+s,y.maxHeight=Math.min(n,v-s*2)):x>=150?(y.bottom=l-c.top+s,y.maxHeight=Math.min(n,x-s*2)):(y.top=c.bottom+s,y.maxHeight=Math.max(100,v-s*2)),p(y)};return g(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[r,o,n,s]),a},Bl=["organization:admin"],Ul=["organization:admin","organization:manage"],Wl=["workspace:admin"],Vl=["workspace:admin","workspace:manage"];function Os(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function Gl(t){return Os(t,Ul)}function v0(t){return Os(t,Bl)}function As(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function xs(t){return As(t,Vl)}function b0(t){return As(t,Wl)}const ii=d.div`
3339
+ `})]})},x0=()=>{var f;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:s}=Rt(),{toast:a}=He(),{deployment:p}=ve(),[g,c]=i.useState(""),[h,l]=i.useState({isOpen:!1}),[u,m]=i.useState(null),[x,v]=i.useState(null),y=i.useRef(null),z=i.useRef(new Map),{data:S=[],isLoading:_,mutate:E}=Fe(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),I=i.useMemo(()=>g?S.filter($=>$.name.toLowerCase().includes(g.toLowerCase())):S,[S,g]),w=async $=>{try{await n($.name,$.permissions||[]),a("Role created successfully","info"),l({isOpen:!1}),E()}catch{a("Failed to save role","error"),a("Failed to create role","error")}},b=async $=>{try{await s($),a("Role deleted successfully","info"),v(null),E()}catch{a("Failed to delete role","error"),a("Failed to delete role","error")}};return r||_?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ms,{children:[e.jsx(St,{placeholder:"Search roles",onChange:c,value:g}),e.jsxs("div",{style:{position:"relative"},children:[((f=p==null?void 0:p.b2b_settings)==null?void 0:f.custom_workspace_role_enabled)&&e.jsx(X,{ref:y,onClick:()=>l({isOpen:!0,triggerElement:y.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),h.isOpen&&!h.role&&e.jsx(si,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:w})]})]}),I.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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Role"}),e.jsx(Ce,{children:"Permissions"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:I.map($=>{var k;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:$.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:$.permissions&&$.permissions.length>0?$.permissions.join(", "):""}),e.jsx(mt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:u===$.id,openChange:j=>m(j?$.id:null),children:[e.jsx(at,{children:e.jsx(Ol,{ref:j=>{j&&z.current.set($.id,j)},disabled:!$.workspace_id,"data-role-dropdown-trigger":$.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{m(null);const j=z.current.get($.id);l({isOpen:!0,role:$,triggerElement:j||null})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{m(null),v($.id)},children:"Remove Role"})]})]}),x===$.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>b($),onCancel:()=>v(null)}),h.isOpen&&((k=h.role)==null?void 0:k.id)===$.id&&e.jsx(si,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>{l({isOpen:!1}),m(null)},onSuccess:w})]})})]},$.id)})})]})})]})},Al=()=>{const{activeWorkspace:t,loading:r}=Rt(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((h,l="info")=>{a(h),g(l),setTimeout(()=>a(null),3e3)},[]);return r?e.jsx(ai,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):t?e.jsx(Ps.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(l0,{children:e.jsxs(ai,{children:[e.jsx(d0,{children:e.jsxs(u0,{children:[e.jsx(xo,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(vo,{children:[e.jsx(Jt,{size:16}),"General"]})}),e.jsx(xo,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(vo,{children:[e.jsx(Uo,{size:16}),"Members"]})}),e.jsx(xo,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(vo,{children:[e.jsx($s,{size:16}),"Invitations"]})}),e.jsx(xo,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(vo,{children:[e.jsx(Xe,{size:16}),"Roles"]})})]})}),e.jsxs(p0,{children:[o==="general"&&e.jsx(m0,{}),o==="members"&&e.jsx(g0,{}),o==="invitations"&&e.jsx(f0,{}),o==="roles"&&e.jsx(x0,{})]}),s&&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(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):null},Ll=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:p,children:g,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),p||g||e.jsx(Al,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Dl=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:s=8})=>{const[a,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,l=window.innerHeight,u=h-c.left,m=c.right,x=l-c.bottom,v=c.top;let y={};u>=o?y.left=c.left:m>=o?y.left=c.right-o:y.left=Math.max(s,Math.min(h-o-s,c.left)),x>=150?(y.top=c.bottom+s,y.maxHeight=Math.min(n,x-s*2)):v>=150?(y.bottom=l-c.top+s,y.maxHeight=Math.min(n,v-s*2)):(y.top=c.bottom+s,y.maxHeight=Math.max(100,x-s*2)),p(y)};return g(),window.addEventListener("resize",g),window.addEventListener("scroll",g,!0),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0)}},[r,o,n,s]),a},Nl=["organization:admin"],Fl=["organization:admin","organization:manage"],Bl=["workspace:admin"],Ul=["workspace:admin","workspace:manage"];function Os(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function Wl(t){return Os(t,Fl)}function v0(t){return Os(t,Nl)}function As(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(s=>r.includes(s))}):!1}function xs(t){return As(t,Ul)}function b0(t){return As(t,Bl)}const ii=d.div`
3340
3340
  position: relative;
3341
3341
  display: inline-block;
3342
3342
  width: 100%;
@@ -3687,15 +3687,15 @@ cursor: pointer;
3687
3687
  height: 16px;
3688
3688
  background: var(--color-border);
3689
3689
  border-radius: 2px;
3690
- `,Hl=({showPersonal:t=!0})=>{var ue,U,pe,Q;const[r,o]=i.useState(!1),[n,s]=i.useState(!1),[a,p]=i.useState(new Set),g=i.useRef(null),c=i.useRef(null),h=Fl({triggerRef:g,isOpen:r,minWidth:300}),l=Dr(!1),u=Dr(!1),m=Dr(!1),v=Dr(!1),[x,y]=i.useState(null),[$,S]=i.useState(!1),[k,I]=i.useState(null),{organizationMemberships:E,loading:w,refetch:b}=Ct(),{activeOrganization:f,activeMembership:z,leave:_}=Ze(),{activeWorkspace:j,activeMembership:M,leave:R}=Rt(),{workspaces:C,loading:P}=Pt(),{session:T,loading:B,switchOrganization:L,switchWorkspace:F}=Ue(),{deployment:O}=ve(),{toast:A}=He(),J=O==null?void 0:O.b2b_settings.organizations_enabled,re=O==null?void 0:O.b2b_settings.workspaces_enabled,V=O==null?void 0:O.b2b_settings.allow_users_to_create_orgs,q=!((ue=T==null?void 0:T.active_signin)!=null&&ue.active_organization_membership_id),H=i.useMemo(()=>{var ne,me;if(q)return{name:"Personal account",image_url:(me=(ne=T==null?void 0:T.active_signin)==null?void 0:ne.user)==null?void 0:me.profile_picture_url,isPersonal:!0};let Y=(f==null?void 0:f.name)||"";return re&&j&&(Y=`${f==null?void 0:f.name} / ${j.name}`),{name:Y,image_url:f==null?void 0:f.image_url,isPersonal:!1}},[q,f,j,T,re]);i.useEffect(()=>{if(!r)return;let Y=null;const ne=setTimeout(()=>{const me=fe=>{var N,D;const W=fe.target;(N=g.current)!=null&&N.contains(W)||(D=c.current)!=null&&D.contains(W)||(o(!1),I(null))};document.addEventListener("mousedown",me),Y=()=>{document.removeEventListener("mousedown",me)}},50);return()=>{clearTimeout(ne),Y==null||Y()}},[r]),i.useEffect(()=>{if(k){const Y=setTimeout(()=>{I(null)},5e3);return()=>clearTimeout(Y)}},[k]);const ee=()=>{b()};if(!J)return null;const le=Y=>{s(!0),L(Y).finally(()=>{s(!1)})},oe=Y=>{s(!0),F(Y).finally(()=>{s(!1)})},de=Y=>{const ne=new Set(a);ne.has(Y)?ne.delete(Y):ne.add(Y),p(ne)},K=Y=>Y.split(" ").map(ne=>ne[0]).join("").toUpperCase().slice(0,2),se=!!((U=T==null?void 0:T.active_signin)!=null&&U.active_organization_membership_id);return w||B||!E&&se?e.jsx(ge,{children:e.jsx(ii,{children:e.jsxs(E0,{children:[e.jsxs(ci,{children:[e.jsx(I0,{}),e.jsx(P0,{})]}),e.jsx(R0,{})]})})}):e.jsx(ge,{children:e.jsxs(ii,{children:[e.jsxs(y0,{ref:g,onClick:()=>{o(!r),r||I(null)},disabled:n,children:[e.jsxs(ci,{children:[e.jsx(w0,{children:H.image_url?e.jsx(j0,{src:H.image_url,alt:H.name}):H.isPersonal?e.jsx(Bo,{size:12}):K(H.name)}),e.jsx(_0,{children:H.name})]}),e.jsx(Jp,{size:16})]}),typeof window<"u"&&Wr.createPortal(e.jsx(ge,{children:e.jsx(k0,{ref:c,$isOpen:r,$position:h,children:w||P?e.jsxs($0,{children:[e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsxs(Co,{children:[e.jsx(So,{width:"120px"}),e.jsx(fi,{width:"80px"})]})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsx(Co,{children:e.jsx(So,{width:"100px"})})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsxs(Co,{children:[e.jsx(So,{width:"140px"}),e.jsx(fi,{width:"60px"})]})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsx(Co,{children:e.jsx(So,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:q,onClick:Y=>{Y.stopPropagation(),q||le()},disabled:n||q,children:[q&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(C0,{children:(Q=(pe=T==null?void 0:T.active_signin)==null?void 0:pe.user)!=null&&Q.profile_picture_url?e.jsx(S0,{src:T.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Bo,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Personal account"})})]}),!q&&e.jsx(bo,{className:"hover-arrow",size:14})]}),!q&&f&&e.jsx(gr,{})]}),!q&&f&&e.jsxs(Ao,{$isActive:!0,onClick:()=>{re&&de(f.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(wo,{}),e.jsxs(xt,{children:[re&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:a.has(f.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(li,{children:f.image_url?e.jsx(di,{src:f.image_url,alt:f.name}):K(f.name)}),e.jsx(vt,{children:e.jsx(bt,{children:f.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Gl(z)&&e.jsx(Lo,{onClick:Y=>{Y.stopPropagation(),u.open()},title:"Manage organization",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async Y=>{Y.stopPropagation(),S(!0),I(null);try{await _(),await b(),setTimeout(()=>{S(!1)},500)}catch(ne){I(ne instanceof Error?ne.message:"Failed to leave organization"),S(!1)}},disabled:$,title:"Leave organization",children:e.jsx(Et,{size:12})})]})]}),f&&re&&a.has(f.id)&&e.jsxs(e.Fragment,{children:[C==null?void 0:C.filter(Y=>Y.organization.id===f.id).map(Y=>{const ne=(j==null?void 0:j.id)===Y.id;return e.jsxs(jo,{as:ne?void 0:"button",$isActive:ne,onClick:ne?void 0:()=>oe(Y.id),...ne?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[ne&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(pi,{children:Y.image_url?e.jsx("img",{src:Y.image_url,alt:Y.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):K(Y.name).charAt(0)}),e.jsx(vt,{children:e.jsx(bt,{children:Y.name})})]}),ne?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[xs(M)&&e.jsx(Lo,{onClick:me=>{me.stopPropagation(),v.open()},title:"Manage workspace",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async me=>{me.stopPropagation();try{R&&await R()}catch(fe){const W=fe.message||"Failed to leave workspace. Please try again.";A(W,"error")}},title:"Leave workspace",children:e.jsx(Et,{size:12})})]}):e.jsx(bo,{className:"hover-arrow",size:14})]},Y.id)}),e.jsx(jo,{as:"button",onClick:()=>{y(f.id),m.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{style:{width:"14px",height:"14px"},children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})})]}),($||k)&&e.jsxs(e.Fragment,{children:[$&&e.jsxs(hi,{children:[e.jsx(z0,{}),"Leaving organization..."]}),k&&e.jsxs(hi,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),k]})]}),e.jsx(gr,{}),E&&E.length>0&&e.jsx(e.Fragment,{children:E.filter(Y=>Y.organization.id!==(f==null?void 0:f.id)).map(Y=>{const ne=Y.organization,me=(C==null?void 0:C.filter(W=>W.organization.id===ne.id))||[],fe=a.has(ne.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:!1,onClick:()=>{re?de(ne.id):le(ne.id)},disabled:n,children:[e.jsxs(xt,{children:[re&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:fe?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(li,{children:ne.image_url?e.jsx(di,{src:ne.image_url,alt:ne.name}):K(ne.name)}),e.jsx(vt,{children:e.jsx(bt,{children:ne.name})})]}),e.jsx(bo,{className:"hover-arrow",size:14})]}),re&&fe&&e.jsxs(e.Fragment,{children:[me.map(W=>{const N=(j==null?void 0:j.id)===W.id;return e.jsxs(jo,{as:N?void 0:"button",$isActive:N,onClick:N?void 0:()=>oe(W.id),...N?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[N&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(pi,{children:W.image_url?e.jsx("img",{src:W.image_url,alt:W.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):K(W.name).charAt(0)}),e.jsx(vt,{children:e.jsx(bt,{children:W.name})})]}),N?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[xs(M)&&e.jsx(Lo,{onClick:D=>{D.stopPropagation(),v.open()},title:"Manage workspace",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async D=>{D.stopPropagation();try{R&&await R()}catch(Z){const ae=Z.message||"Failed to leave workspace. Please try again.";A(ae,"error")}},title:"Leave workspace",children:e.jsx(Et,{size:12})})]}):e.jsx(bo,{className:"hover-arrow",size:16})]},W.id)}),e.jsx(jo,{as:"button",onClick:()=>{y(ne.id),m.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{style:{width:"14px",height:"14px"},children:e.jsx(Ke,{size:10})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})})]}),e.jsx(gr,{})]},ne.id)})}),re?f&&e.jsx(ui,{onClick:()=>{y(f.id),m.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})}):V&&e.jsx(ui,{onClick:()=>{l.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create organization"})})]})})]})})}),document.body),J&&V&&e.jsx(Nm,{isOpen:l.isOpen,onClose:l.close,onCreated:ee}),e.jsx(Cx,{isOpen:u.isOpen,onClose:u.close}),e.jsx(Nl,{isOpen:v.isOpen,onClose:v.close}),x&&e.jsx(Al,{isOpen:m.isOpen,onClose:()=>{m.close(),y(null)},organizationId:x})]})})};var T0=Object.defineProperty,Go=Object.getOwnPropertySymbols,ql=Object.prototype.hasOwnProperty,Yl=Object.prototype.propertyIsEnumerable,gi=(t,r,o)=>r in t?T0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,vs=(t,r)=>{for(var o in r||(r={}))ql.call(r,o)&&gi(t,o,r[o]);if(Go)for(var o of Go(r))Yl.call(r,o)&&gi(t,o,r[o]);return t},bs=(t,r)=>{var o={};for(var n in t)ql.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Go)for(var n of Go(t))r.indexOf(n)<0&&Yl.call(t,n)&&(o[n]=t[n]);return o};/**
3690
+ `,Vl=({showPersonal:t=!0})=>{var ue,U,pe,Q;const[r,o]=i.useState(!1),[n,s]=i.useState(!1),[a,p]=i.useState(new Set),g=i.useRef(null),c=i.useRef(null),h=Dl({triggerRef:g,isOpen:r,minWidth:300}),l=Dr(!1),u=Dr(!1),m=Dr(!1),x=Dr(!1),[v,y]=i.useState(null),[z,S]=i.useState(!1),[_,E]=i.useState(null),{organizationMemberships:I,loading:w,refetch:b}=Ct(),{activeOrganization:f,activeMembership:$,leave:k}=Ze(),{activeWorkspace:j,activeMembership:M,leave:R}=Rt(),{workspaces:C,loading:P}=Pt(),{session:T,loading:B,switchOrganization:L,switchWorkspace:F}=Ue(),{deployment:O}=ve(),{toast:A}=He(),J=O==null?void 0:O.b2b_settings.organizations_enabled,re=O==null?void 0:O.b2b_settings.workspaces_enabled,V=O==null?void 0:O.b2b_settings.allow_users_to_create_orgs,q=!((ue=T==null?void 0:T.active_signin)!=null&&ue.active_organization_membership_id),H=i.useMemo(()=>{var ne,me;if(q)return{name:"Personal account",image_url:(me=(ne=T==null?void 0:T.active_signin)==null?void 0:ne.user)==null?void 0:me.profile_picture_url,isPersonal:!0};let Y=(f==null?void 0:f.name)||"";return re&&j&&(Y=`${f==null?void 0:f.name} / ${j.name}`),{name:Y,image_url:f==null?void 0:f.image_url,isPersonal:!1}},[q,f,j,T,re]);i.useEffect(()=>{if(!r)return;let Y=null;const ne=setTimeout(()=>{const me=fe=>{var N,D;const W=fe.target;(N=g.current)!=null&&N.contains(W)||(D=c.current)!=null&&D.contains(W)||(o(!1),E(null))};document.addEventListener("mousedown",me),Y=()=>{document.removeEventListener("mousedown",me)}},50);return()=>{clearTimeout(ne),Y==null||Y()}},[r]),i.useEffect(()=>{if(_){const Y=setTimeout(()=>{E(null)},5e3);return()=>clearTimeout(Y)}},[_]);const ee=()=>{b()};if(!J)return null;const le=Y=>{s(!0),L(Y).finally(()=>{s(!1)})},oe=Y=>{s(!0),F(Y).finally(()=>{s(!1)})},de=Y=>{const ne=new Set(a);ne.has(Y)?ne.delete(Y):ne.add(Y),p(ne)},K=Y=>Y.split(" ").map(ne=>ne[0]).join("").toUpperCase().slice(0,2),se=!!((U=T==null?void 0:T.active_signin)!=null&&U.active_organization_membership_id);return w||B||!I&&se?e.jsx(ge,{children:e.jsx(ii,{children:e.jsxs(E0,{children:[e.jsxs(ci,{children:[e.jsx(I0,{}),e.jsx(P0,{})]}),e.jsx(R0,{})]})})}):e.jsx(ge,{children:e.jsxs(ii,{children:[e.jsxs(y0,{ref:g,onClick:()=>{o(!r),r||E(null)},disabled:n,children:[e.jsxs(ci,{children:[e.jsx(w0,{children:H.image_url?e.jsx(j0,{src:H.image_url,alt:H.name}):H.isPersonal?e.jsx(Bo,{size:12}):K(H.name)}),e.jsx(_0,{children:H.name})]}),e.jsx(Qp,{size:16})]}),typeof window<"u"&&Wr.createPortal(e.jsx(ge,{children:e.jsx(k0,{ref:c,$isOpen:r,$position:h,children:w||P?e.jsxs($0,{children:[e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsxs(Co,{children:[e.jsx(So,{width:"120px"}),e.jsx(fi,{width:"80px"})]})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsx(Co,{children:e.jsx(So,{width:"100px"})})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsxs(Co,{children:[e.jsx(So,{width:"140px"}),e.jsx(fi,{width:"60px"})]})]}),e.jsx(gr,{}),e.jsxs(_o,{children:[e.jsx(ko,{}),e.jsx(Co,{children:e.jsx(So,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:q,onClick:Y=>{Y.stopPropagation(),q||le()},disabled:n||q,children:[q&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(C0,{children:(Q=(pe=T==null?void 0:T.active_signin)==null?void 0:pe.user)!=null&&Q.profile_picture_url?e.jsx(S0,{src:T.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Bo,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Personal account"})})]}),!q&&e.jsx(bo,{className:"hover-arrow",size:14})]}),!q&&f&&e.jsx(gr,{})]}),!q&&f&&e.jsxs(Ao,{$isActive:!0,onClick:()=>{re&&de(f.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(wo,{}),e.jsxs(xt,{children:[re&&e.jsx(rr,{size:12,style:{marginRight:"4px",transform:a.has(f.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(li,{children:f.image_url?e.jsx(di,{src:f.image_url,alt:f.name}):K(f.name)}),e.jsx(vt,{children:e.jsx(bt,{children:f.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Wl($)&&e.jsx(Lo,{onClick:Y=>{Y.stopPropagation(),u.open()},title:"Manage organization",children:e.jsx(Jt,{size:12})}),e.jsx(Vn,{onClick:async Y=>{Y.stopPropagation(),S(!0),E(null);try{await k(),await b(),setTimeout(()=>{S(!1)},500)}catch(ne){E(ne instanceof Error?ne.message:"Failed to leave organization"),S(!1)}},disabled:z,title:"Leave organization",children:e.jsx(Et,{size:12})})]})]}),f&&re&&a.has(f.id)&&e.jsxs(e.Fragment,{children:[C==null?void 0:C.filter(Y=>Y.organization.id===f.id).map(Y=>{const ne=(j==null?void 0:j.id)===Y.id;return e.jsxs(jo,{as:ne?void 0:"button",$isActive:ne,onClick:ne?void 0:()=>oe(Y.id),...ne?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[ne&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(pi,{children:Y.image_url?e.jsx("img",{src:Y.image_url,alt:Y.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):K(Y.name).charAt(0)}),e.jsx(vt,{children:e.jsx(bt,{children:Y.name})})]}),ne?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[xs(M)&&e.jsx(Lo,{onClick:me=>{me.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Jt,{size:12})}),e.jsx(Vn,{onClick:async me=>{me.stopPropagation();try{R&&await R()}catch(fe){const W=fe.message||"Failed to leave workspace. Please try again.";A(W,"error")}},title:"Leave workspace",children:e.jsx(Et,{size:12})})]}):e.jsx(bo,{className:"hover-arrow",size:14})]},Y.id)}),e.jsx(jo,{as:"button",onClick:()=>{y(f.id),m.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{style:{width:"14px",height:"14px"},children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})})]}),(z||_)&&e.jsxs(e.Fragment,{children:[z&&e.jsxs(hi,{children:[e.jsx(z0,{}),"Leaving organization..."]}),_&&e.jsxs(hi,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),_]})]}),e.jsx(gr,{}),I&&I.length>0&&e.jsx(e.Fragment,{children:I.filter(Y=>Y.organization.id!==(f==null?void 0:f.id)).map(Y=>{const ne=Y.organization,me=(C==null?void 0:C.filter(W=>W.organization.id===ne.id))||[],fe=a.has(ne.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:!1,onClick:()=>{re?de(ne.id):le(ne.id)},disabled:n,children:[e.jsxs(xt,{children:[re&&e.jsx(rr,{size:12,style:{marginRight:"4px",transform:fe?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(li,{children:ne.image_url?e.jsx(di,{src:ne.image_url,alt:ne.name}):K(ne.name)}),e.jsx(vt,{children:e.jsx(bt,{children:ne.name})})]}),e.jsx(bo,{className:"hover-arrow",size:14})]}),re&&fe&&e.jsxs(e.Fragment,{children:[me.map(W=>{const N=(j==null?void 0:j.id)===W.id;return e.jsxs(jo,{as:N?void 0:"button",$isActive:N,onClick:N?void 0:()=>oe(W.id),...N?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[N&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(pi,{children:W.image_url?e.jsx("img",{src:W.image_url,alt:W.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):K(W.name).charAt(0)}),e.jsx(vt,{children:e.jsx(bt,{children:W.name})})]}),N?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[xs(M)&&e.jsx(Lo,{onClick:D=>{D.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Jt,{size:12})}),e.jsx(Vn,{onClick:async D=>{D.stopPropagation();try{R&&await R()}catch(Z){const ae=Z.message||"Failed to leave workspace. Please try again.";A(ae,"error")}},title:"Leave workspace",children:e.jsx(Et,{size:12})})]}):e.jsx(bo,{className:"hover-arrow",size:16})]},W.id)}),e.jsx(jo,{as:"button",onClick:()=>{y(ne.id),m.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{style:{width:"14px",height:"14px"},children:e.jsx(Ke,{size:10})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})})]}),e.jsx(gr,{})]},ne.id)})}),re?f&&e.jsx(ui,{onClick:()=>{y(f.id),m.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create workspace"})})]})}):V&&e.jsx(ui,{onClick:()=>{l.open()},disabled:n,children:e.jsxs(xt,{children:[e.jsx(yo,{children:e.jsx(Ke,{size:12})}),e.jsx(vt,{children:e.jsx(bt,{children:"Create organization"})})]})})]})})}),document.body),J&&V&&e.jsx(Lm,{isOpen:l.isOpen,onClose:l.close,onCreated:ee}),e.jsx(Cx,{isOpen:u.isOpen,onClose:u.close}),e.jsx(Ll,{isOpen:x.isOpen,onClose:x.close}),v&&e.jsx(Ml,{isOpen:m.isOpen,onClose:()=>{m.close(),y(null)},organizationId:v})]})})};var T0=Object.defineProperty,Go=Object.getOwnPropertySymbols,Gl=Object.prototype.hasOwnProperty,Hl=Object.prototype.propertyIsEnumerable,gi=(t,r,o)=>r in t?T0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,vs=(t,r)=>{for(var o in r||(r={}))Gl.call(r,o)&&gi(t,o,r[o]);if(Go)for(var o of Go(r))Hl.call(r,o)&&gi(t,o,r[o]);return t},bs=(t,r)=>{var o={};for(var n in t)Gl.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Go)for(var n of Go(t))r.indexOf(n)<0&&Hl.call(t,n)&&(o[n]=t[n]);return o};/**
3691
3691
  * @license QR Code generator library (TypeScript)
3692
3692
  * Copyright (c) Project Nayuki.
3693
3693
  * SPDX-License-Identifier: MIT
3694
- */var nr;(t=>{const r=class je{constructor(c,h,l,u){if(this.version=c,this.errorCorrectionLevel=h,this.modules=[],this.isFunction=[],c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version value out of range");if(u<-1||u>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let m=[];for(let x=0;x<this.size;x++)m.push(!1);for(let x=0;x<this.size;x++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(l);if(this.drawCodewords(v),u==-1){let x=1e9;for(let y=0;y<8;y++){this.applyMask(y),this.drawFormatBits(y);const $=this.getPenaltyScore();$<x&&(u=y,x=$),this.applyMask(y)}}s(0<=u&&u<=7),this.mask=u,this.applyMask(u),this.drawFormatBits(u),this.isFunction=[]}static encodeText(c,h){const l=t.QrSegment.makeSegments(c);return je.encodeSegments(l,h)}static encodeBinary(c,h){const l=t.QrSegment.makeBytes(c);return je.encodeSegments([l],h)}static encodeSegments(c,h,l=1,u=40,m=-1,v=!0){if(!(je.MIN_VERSION<=l&&l<=u&&u<=je.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let x,y;for(x=l;;x++){const I=je.getNumDataCodewords(x,h)*8,E=p.getTotalBits(c,x);if(E<=I){y=E;break}if(x>=u)throw new RangeError("Data too long")}for(const I of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])v&&y<=je.getNumDataCodewords(x,I)*8&&(h=I);let $=[];for(const I of c){o(I.mode.modeBits,4,$),o(I.numChars,I.mode.numCharCountBits(x),$);for(const E of I.getData())$.push(E)}s($.length==y);const S=je.getNumDataCodewords(x,h)*8;s($.length<=S),o(0,Math.min(4,S-$.length),$),o(0,(8-$.length%8)%8,$),s($.length%8==0);for(let I=236;$.length<S;I^=253)o(I,8,$);let k=[];for(;k.length*8<$.length;)k.push(0);return $.forEach((I,E)=>k[E>>>3]|=I<<7-(E&7)),new je(x,h,k,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 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(),h=c.length;for(let l=0;l<h;l++)for(let u=0;u<h;u++)l==0&&u==0||l==0&&u==h-1||l==h-1&&u==0||this.drawAlignmentPattern(c[l],c[u]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const h=this.errorCorrectionLevel.formatBits<<3|c;let l=h;for(let m=0;m<10;m++)l=l<<1^(l>>>9)*1335;const u=(h<<10|l)^21522;s(u>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,n(u,m));this.setFunctionModule(8,7,n(u,6)),this.setFunctionModule(8,8,n(u,7)),this.setFunctionModule(7,8,n(u,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,n(u,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,n(u,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,n(u,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 h=this.version<<12|c;s(h>>>18==0);for(let l=0;l<18;l++){const u=n(h,l),m=this.size-11+l%3,v=Math.floor(l/3);this.setFunctionModule(m,v,u),this.setFunctionModule(v,m,u)}}drawFinderPattern(c,h){for(let l=-4;l<=4;l++)for(let u=-4;u<=4;u++){const m=Math.max(Math.abs(u),Math.abs(l)),v=c+u,x=h+l;0<=v&&v<this.size&&0<=x&&x<this.size&&this.setFunctionModule(v,x,m!=2&&m!=4)}}drawAlignmentPattern(c,h){for(let l=-2;l<=2;l++)for(let u=-2;u<=2;u++)this.setFunctionModule(c+u,h+l,Math.max(Math.abs(u),Math.abs(l))!=1)}setFunctionModule(c,h,l){this.modules[h][c]=l,this.isFunction[h][c]=!0}addEccAndInterleave(c){const h=this.version,l=this.errorCorrectionLevel;if(c.length!=je.getNumDataCodewords(h,l))throw new RangeError("Invalid argument");const u=je.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][h],m=je.ECC_CODEWORDS_PER_BLOCK[l.ordinal][h],v=Math.floor(je.getNumRawDataModules(h)/8),x=u-v%u,y=Math.floor(v/u);let $=[];const S=je.reedSolomonComputeDivisor(m);for(let I=0,E=0;I<u;I++){let w=c.slice(E,E+y-m+(I<x?0:1));E+=w.length;const b=je.reedSolomonComputeRemainder(w,S);I<x&&w.push(0),$.push(w.concat(b))}let k=[];for(let I=0;I<$[0].length;I++)$.forEach((E,w)=>{(I!=y-m||w>=x)&&k.push(E[I])});return s(k.length==v),k}drawCodewords(c){if(c.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let h=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let u=0;u<this.size;u++)for(let m=0;m<2;m++){const v=l-m,y=(l+1&2)==0?this.size-1-u:u;!this.isFunction[y][v]&&h<c.length*8&&(this.modules[y][v]=n(c[h>>>3],7-(h&7)),h++)}}s(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 l=0;l<this.size;l++){let u;switch(c){case 0:u=(l+h)%2==0;break;case 1:u=h%2==0;break;case 2:u=l%3==0;break;case 3:u=(l+h)%3==0;break;case 4:u=(Math.floor(l/3)+Math.floor(h/2))%2==0;break;case 5:u=l*h%2+l*h%3==0;break;case 6:u=(l*h%2+l*h%3)%2==0;break;case 7:u=((l+h)%2+l*h%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[h][l]&&u&&(this.modules[h][l]=!this.modules[h][l])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let v=!1,x=0,y=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[m][$]==v?(x++,x==5?c+=je.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,y),v||(c+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),v=this.modules[m][$],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,y)*je.PENALTY_N3}for(let m=0;m<this.size;m++){let v=!1,x=0,y=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[$][m]==v?(x++,x==5?c+=je.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,y),v||(c+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),v=this.modules[$][m],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,y)*je.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let v=0;v<this.size-1;v++){const x=this.modules[m][v];x==this.modules[m][v+1]&&x==this.modules[m+1][v]&&x==this.modules[m+1][v+1]&&(c+=je.PENALTY_N2)}let h=0;for(const m of this.modules)h=m.reduce((v,x)=>v+(x?1:0),h);const l=this.size*this.size,u=Math.ceil(Math.abs(h*20-l*10)/l)-1;return s(0<=u&&u<=9),c+=u*je.PENALTY_N4,s(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 l=[6];for(let u=this.size-7;l.length<c;u-=h)l.splice(1,0,u);return l}}static getNumRawDataModules(c){if(c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version number out of range");let h=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;h-=(25*l-10)*l-55,c>=7&&(h-=36)}return s(208<=h&&h<=29648),h}static getNumDataCodewords(c,h){return Math.floor(je.getNumRawDataModules(c)/8)-je.ECC_CODEWORDS_PER_BLOCK[h.ordinal][c]*je.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 u=0;u<c-1;u++)h.push(0);h.push(1);let l=1;for(let u=0;u<c;u++){for(let m=0;m<h.length;m++)h[m]=je.reedSolomonMultiply(h[m],l),m+1<h.length&&(h[m]^=h[m+1]);l=je.reedSolomonMultiply(l,2)}return h}static reedSolomonComputeRemainder(c,h){let l=h.map(u=>0);for(const u of c){const m=u^l.shift();l.push(0),h.forEach((v,x)=>l[x]^=je.reedSolomonMultiply(v,m))}return l}static reedSolomonMultiply(c,h){if(c>>>8||h>>>8)throw new RangeError("Byte out of range");let l=0;for(let u=7;u>=0;u--)l=l<<1^(l>>>7)*285,l^=(h>>>u&1)*c;return s(l>>>8==0),l}finderPenaltyCountPatterns(c){const h=c[1];s(h<=this.size*3);const l=h>0&&c[2]==h&&c[3]==h*3&&c[4]==h&&c[5]==h;return(l&&c[0]>=h*4&&c[6]>=h?1:0)+(l&&c[6]>=h*4&&c[0]>=h?1:0)}finderPenaltyTerminateAndCount(c,h,l){return c&&(this.finderPenaltyAddHistory(h,l),h=0),h+=this.size,this.finderPenaltyAddHistory(h,l),this.finderPenaltyCountPatterns(l)}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 l=c-1;l>=0;l--)h.push(g>>>l&1)}function n(g,c){return(g>>>c&1)!=0}function s(g){if(!g)throw new Error("Assertion error")}const a=class Oe{constructor(c,h,l){if(this.mode=c,this.numChars=h,this.bitData=l,h<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let h=[];for(const l of c)o(l,8,h);return new Oe(Oe.Mode.BYTE,c.length,h)}static makeNumeric(c){if(!Oe.isNumeric(c))throw new RangeError("String contains non-numeric characters");let h=[];for(let l=0;l<c.length;){const u=Math.min(c.length-l,3);o(parseInt(c.substring(l,l+u),10),u*3+1,h),l+=u}return new Oe(Oe.Mode.NUMERIC,c.length,h)}static makeAlphanumeric(c){if(!Oe.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let h=[],l;for(l=0;l+2<=c.length;l+=2){let u=Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;u+=Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),o(u,11,h)}return l<c.length&&o(Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,h),new Oe(Oe.Mode.ALPHANUMERIC,c.length,h)}static makeSegments(c){return c==""?[]:Oe.isNumeric(c)?[Oe.makeNumeric(c)]:Oe.isAlphanumeric(c)?[Oe.makeAlphanumeric(c)]:[Oe.makeBytes(Oe.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 Oe(Oe.Mode.ECI,0,h)}static isNumeric(c){return Oe.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Oe.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,h){let l=0;for(const u of c){const m=u.mode.numCharCountBits(h);if(u.numChars>=1<<m)return 1/0;l+=4+m+u.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let h=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?h.push(c.charCodeAt(l)):(h.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return h}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let p=a;t.QrSegment=a})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(s,a){this.ordinal=s,this.formatBits=a}};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={}))})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(s,a){this.modeBits=s,this.numBitsCharCount=a}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+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={}))})(nr||(nr={}));var vr=nr;/**
3694
+ */var or;(t=>{const r=class je{constructor(c,h,l,u){if(this.version=c,this.errorCorrectionLevel=h,this.modules=[],this.isFunction=[],c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version value out of range");if(u<-1||u>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),u==-1){let v=1e9;for(let y=0;y<8;y++){this.applyMask(y),this.drawFormatBits(y);const z=this.getPenaltyScore();z<v&&(u=y,v=z),this.applyMask(y)}}s(0<=u&&u<=7),this.mask=u,this.applyMask(u),this.drawFormatBits(u),this.isFunction=[]}static encodeText(c,h){const l=t.QrSegment.makeSegments(c);return je.encodeSegments(l,h)}static encodeBinary(c,h){const l=t.QrSegment.makeBytes(c);return je.encodeSegments([l],h)}static encodeSegments(c,h,l=1,u=40,m=-1,x=!0){if(!(je.MIN_VERSION<=l&&l<=u&&u<=je.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let v,y;for(v=l;;v++){const E=je.getNumDataCodewords(v,h)*8,I=p.getTotalBits(c,v);if(I<=E){y=I;break}if(v>=u)throw new RangeError("Data too long")}for(const E of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])x&&y<=je.getNumDataCodewords(v,E)*8&&(h=E);let z=[];for(const E of c){o(E.mode.modeBits,4,z),o(E.numChars,E.mode.numCharCountBits(v),z);for(const I of E.getData())z.push(I)}s(z.length==y);const S=je.getNumDataCodewords(v,h)*8;s(z.length<=S),o(0,Math.min(4,S-z.length),z),o(0,(8-z.length%8)%8,z),s(z.length%8==0);for(let E=236;z.length<S;E^=253)o(E,8,z);let _=[];for(;_.length*8<z.length;)_.push(0);return z.forEach((E,I)=>_[I>>>3]|=E<<7-(I&7)),new je(v,h,_,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 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(),h=c.length;for(let l=0;l<h;l++)for(let u=0;u<h;u++)l==0&&u==0||l==0&&u==h-1||l==h-1&&u==0||this.drawAlignmentPattern(c[l],c[u]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const h=this.errorCorrectionLevel.formatBits<<3|c;let l=h;for(let m=0;m<10;m++)l=l<<1^(l>>>9)*1335;const u=(h<<10|l)^21522;s(u>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,n(u,m));this.setFunctionModule(8,7,n(u,6)),this.setFunctionModule(8,8,n(u,7)),this.setFunctionModule(7,8,n(u,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,n(u,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,n(u,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,n(u,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 h=this.version<<12|c;s(h>>>18==0);for(let l=0;l<18;l++){const u=n(h,l),m=this.size-11+l%3,x=Math.floor(l/3);this.setFunctionModule(m,x,u),this.setFunctionModule(x,m,u)}}drawFinderPattern(c,h){for(let l=-4;l<=4;l++)for(let u=-4;u<=4;u++){const m=Math.max(Math.abs(u),Math.abs(l)),x=c+u,v=h+l;0<=x&&x<this.size&&0<=v&&v<this.size&&this.setFunctionModule(x,v,m!=2&&m!=4)}}drawAlignmentPattern(c,h){for(let l=-2;l<=2;l++)for(let u=-2;u<=2;u++)this.setFunctionModule(c+u,h+l,Math.max(Math.abs(u),Math.abs(l))!=1)}setFunctionModule(c,h,l){this.modules[h][c]=l,this.isFunction[h][c]=!0}addEccAndInterleave(c){const h=this.version,l=this.errorCorrectionLevel;if(c.length!=je.getNumDataCodewords(h,l))throw new RangeError("Invalid argument");const u=je.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][h],m=je.ECC_CODEWORDS_PER_BLOCK[l.ordinal][h],x=Math.floor(je.getNumRawDataModules(h)/8),v=u-x%u,y=Math.floor(x/u);let z=[];const S=je.reedSolomonComputeDivisor(m);for(let E=0,I=0;E<u;E++){let w=c.slice(I,I+y-m+(E<v?0:1));I+=w.length;const b=je.reedSolomonComputeRemainder(w,S);E<v&&w.push(0),z.push(w.concat(b))}let _=[];for(let E=0;E<z[0].length;E++)z.forEach((I,w)=>{(E!=y-m||w>=v)&&_.push(I[E])});return s(_.length==x),_}drawCodewords(c){if(c.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let h=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let u=0;u<this.size;u++)for(let m=0;m<2;m++){const x=l-m,y=(l+1&2)==0?this.size-1-u:u;!this.isFunction[y][x]&&h<c.length*8&&(this.modules[y][x]=n(c[h>>>3],7-(h&7)),h++)}}s(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 l=0;l<this.size;l++){let u;switch(c){case 0:u=(l+h)%2==0;break;case 1:u=h%2==0;break;case 2:u=l%3==0;break;case 3:u=(l+h)%3==0;break;case 4:u=(Math.floor(l/3)+Math.floor(h/2))%2==0;break;case 5:u=l*h%2+l*h%3==0;break;case 6:u=(l*h%2+l*h%3)%2==0;break;case 7:u=((l+h)%2+l*h%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[h][l]&&u&&(this.modules[h][l]=!this.modules[h][l])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let x=!1,v=0,y=[0,0,0,0,0,0,0];for(let z=0;z<this.size;z++)this.modules[m][z]==x?(v++,v==5?c+=je.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,y),x||(c+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[m][z],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,y)*je.PENALTY_N3}for(let m=0;m<this.size;m++){let x=!1,v=0,y=[0,0,0,0,0,0,0];for(let z=0;z<this.size;z++)this.modules[z][m]==x?(v++,v==5?c+=je.PENALTY_N1:v>5&&c++):(this.finderPenaltyAddHistory(v,y),x||(c+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[z][m],v=1);c+=this.finderPenaltyTerminateAndCount(x,v,y)*je.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+=je.PENALTY_N2)}let h=0;for(const m of this.modules)h=m.reduce((x,v)=>x+(v?1:0),h);const l=this.size*this.size,u=Math.ceil(Math.abs(h*20-l*10)/l)-1;return s(0<=u&&u<=9),c+=u*je.PENALTY_N4,s(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 l=[6];for(let u=this.size-7;l.length<c;u-=h)l.splice(1,0,u);return l}}static getNumRawDataModules(c){if(c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version number out of range");let h=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;h-=(25*l-10)*l-55,c>=7&&(h-=36)}return s(208<=h&&h<=29648),h}static getNumDataCodewords(c,h){return Math.floor(je.getNumRawDataModules(c)/8)-je.ECC_CODEWORDS_PER_BLOCK[h.ordinal][c]*je.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 u=0;u<c-1;u++)h.push(0);h.push(1);let l=1;for(let u=0;u<c;u++){for(let m=0;m<h.length;m++)h[m]=je.reedSolomonMultiply(h[m],l),m+1<h.length&&(h[m]^=h[m+1]);l=je.reedSolomonMultiply(l,2)}return h}static reedSolomonComputeRemainder(c,h){let l=h.map(u=>0);for(const u of c){const m=u^l.shift();l.push(0),h.forEach((x,v)=>l[v]^=je.reedSolomonMultiply(x,m))}return l}static reedSolomonMultiply(c,h){if(c>>>8||h>>>8)throw new RangeError("Byte out of range");let l=0;for(let u=7;u>=0;u--)l=l<<1^(l>>>7)*285,l^=(h>>>u&1)*c;return s(l>>>8==0),l}finderPenaltyCountPatterns(c){const h=c[1];s(h<=this.size*3);const l=h>0&&c[2]==h&&c[3]==h*3&&c[4]==h&&c[5]==h;return(l&&c[0]>=h*4&&c[6]>=h?1:0)+(l&&c[6]>=h*4&&c[0]>=h?1:0)}finderPenaltyTerminateAndCount(c,h,l){return c&&(this.finderPenaltyAddHistory(h,l),h=0),h+=this.size,this.finderPenaltyAddHistory(h,l),this.finderPenaltyCountPatterns(l)}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 l=c-1;l>=0;l--)h.push(g>>>l&1)}function n(g,c){return(g>>>c&1)!=0}function s(g){if(!g)throw new Error("Assertion error")}const a=class Oe{constructor(c,h,l){if(this.mode=c,this.numChars=h,this.bitData=l,h<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let h=[];for(const l of c)o(l,8,h);return new Oe(Oe.Mode.BYTE,c.length,h)}static makeNumeric(c){if(!Oe.isNumeric(c))throw new RangeError("String contains non-numeric characters");let h=[];for(let l=0;l<c.length;){const u=Math.min(c.length-l,3);o(parseInt(c.substring(l,l+u),10),u*3+1,h),l+=u}return new Oe(Oe.Mode.NUMERIC,c.length,h)}static makeAlphanumeric(c){if(!Oe.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let h=[],l;for(l=0;l+2<=c.length;l+=2){let u=Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;u+=Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),o(u,11,h)}return l<c.length&&o(Oe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,h),new Oe(Oe.Mode.ALPHANUMERIC,c.length,h)}static makeSegments(c){return c==""?[]:Oe.isNumeric(c)?[Oe.makeNumeric(c)]:Oe.isAlphanumeric(c)?[Oe.makeAlphanumeric(c)]:[Oe.makeBytes(Oe.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 Oe(Oe.Mode.ECI,0,h)}static isNumeric(c){return Oe.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Oe.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,h){let l=0;for(const u of c){const m=u.mode.numCharCountBits(h);if(u.numChars>=1<<m)return 1/0;l+=4+m+u.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let h=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?h.push(c.charCodeAt(l)):(h.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return h}};a.NUMERIC_REGEX=/^[0-9]*$/,a.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,a.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let p=a;t.QrSegment=a})(or||(or={}));(t=>{(r=>{const o=class{constructor(s,a){this.ordinal=s,this.formatBits=a}};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={}))})(or||(or={}));(t=>{(r=>{const o=class{constructor(s,a){this.modeBits=s,this.numBitsCharCount=a}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+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={}))})(or||(or={}));var vr=or;/**
3695
3695
  * @license qrcode.react
3696
3696
  * Copyright (c) Paul O'Shannessy
3697
3697
  * SPDX-License-Identifier: ISC
3698
- */var M0={L:vr.QrCode.Ecc.LOW,M:vr.QrCode.Ecc.MEDIUM,Q:vr.QrCode.Ecc.QUARTILE,H:vr.QrCode.Ecc.HIGH},Zl=128,Kl="L",Ql="#FFFFFF",Xl="#000000",Jl=!1,ed=1,O0=4,A0=0,L0=.1;function td(t,r=0){const o=[];return t.forEach(function(n,s){let a=null;n.forEach(function(p,g){if(!p&&a!==null){o.push(`M${a+r} ${s+r}h${g-a}v1H${a+r}z`),a=null;return}if(g===n.length-1){if(!p)return;a===null?o.push(`M${g+r},${s+r} h1v1H${g+r}z`):o.push(`M${a+r},${s+r} h${g+1-a}v1H${a+r}z`);return}p&&a===null&&(a=g)})}),o.join("")}function rd(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((s,a)=>a<r.x||a>=r.x+r.w?s:!1))}function D0(t,r,o,n){if(n==null)return null;const s=t.length+o*2,a=Math.floor(r*L0),p=s/r,g=(n.width||a)*p,c=(n.height||a)*p,h=n.x==null?t.length/2-g/2:n.x*p,l=n.y==null?t.length/2-c/2:n.y*p,u=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let x=Math.floor(h),y=Math.floor(l),$=Math.ceil(g+h-x),S=Math.ceil(c+l-y);m={x,y,w:$,h:S}}const v=n.crossOrigin;return{x:h,y:l,h:c,w:g,excavation:m,opacity:u,crossOrigin:v}}function N0(t,r){return r!=null?Math.max(Math.floor(r),0):t?O0:A0}function od({value:t,level:r,minVersion:o,includeMargin:n,marginSize:s,imageSettings:a,size:p,boostLevel:g}){let c=i.useMemo(()=>{const x=(Array.isArray(t)?t:[t]).reduce((y,$)=>(y.push(...vr.QrSegment.makeSegments($)),y),[]);return vr.QrCode.encodeSegments(x,M0[r],o,void 0,void 0,g)},[t,r,o,g]);const{cells:h,margin:l,numCells:u,calculatedImageSettings:m}=i.useMemo(()=>{let v=c.getModules();const x=N0(n,s),y=v.length+x*2,$=D0(v,p,x,a);return{cells:v,margin:x,numCells:y,calculatedImageSettings:$}},[c,p,a,n,s]);return{qrcode:c,margin:l,cells:h,numCells:u,calculatedImageSettings:m}}var F0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),B0=i.forwardRef(function(r,o){const n=r,{value:s,size:a=Zl,level:p=Kl,bgColor:g=Ql,fgColor:c=Xl,includeMargin:h=Jl,minVersion:l=ed,boostLevel:u,marginSize:m,imageSettings:v}=n,y=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:$}=y,S=bs(y,["style"]),k=v==null?void 0:v.src,I=i.useRef(null),E=i.useRef(null),w=i.useCallback(P=>{I.current=P,typeof o=="function"?o(P):o&&(o.current=P)},[o]),[b,f]=i.useState(!1),{margin:z,cells:_,numCells:j,calculatedImageSettings:M}=od({value:s,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:m,imageSettings:v,size:a});i.useEffect(()=>{if(I.current!=null){const P=I.current,T=P.getContext("2d");if(!T)return;let B=_;const L=E.current,F=M!=null&&L!==null&&L.complete&&L.naturalHeight!==0&&L.naturalWidth!==0;F&&M.excavation!=null&&(B=rd(_,M.excavation));const O=window.devicePixelRatio||1;P.height=P.width=a*O;const A=a/j*O;T.scale(A,A),T.fillStyle=g,T.fillRect(0,0,j,j),T.fillStyle=c,F0?T.fill(new Path2D(td(B,z))):_.forEach(function(J,re){J.forEach(function(V,q){V&&T.fillRect(q+z,re+z,1,1)})}),M&&(T.globalAlpha=M.opacity),F&&T.drawImage(L,M.x+z,M.y+z,M.w,M.h)}}),i.useEffect(()=>{f(!1)},[k]);const R=vs({height:a,width:a},$);let C=null;return k!=null&&(C=i.createElement("img",{src:k,key:k,style:{display:"none"},onLoad:()=>{f(!0)},ref:E,crossOrigin:M==null?void 0:M.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",vs({style:R,height:a,width:a,ref:w,role:"img"},S)),C)});B0.displayName="QRCodeCanvas";var Ls=i.forwardRef(function(r,o){const n=r,{value:s,size:a=Zl,level:p=Kl,bgColor:g=Ql,fgColor:c=Xl,includeMargin:h=Jl,minVersion:l=ed,boostLevel:u,title:m,marginSize:v,imageSettings:x}=n,y=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:$,cells:S,numCells:k,calculatedImageSettings:I}=od({value:s,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:v,imageSettings:x,size:a});let E=S,w=null;x!=null&&I!=null&&(I.excavation!=null&&(E=rd(S,I.excavation)),w=i.createElement("image",{href:x.src,height:I.h,width:I.w,x:I.x+$,y:I.y+$,preserveAspectRatio:"none",opacity:I.opacity,crossOrigin:I.crossOrigin}));const b=td(E,$);return i.createElement("svg",vs({height:a,width:a,viewBox:`0 0 ${k} ${k}`,ref:o,role:"img"},y),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:g,d:`M0,0 h${k}v${k}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:b,shapeRendering:"crispEdges"}),w)});Ls.displayName="QRCodeSVG";const nd=i.createContext(void 0),Mt=()=>{const t=i.useContext(nd);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},U0=d.div`
3698
+ */var M0={L:vr.QrCode.Ecc.LOW,M:vr.QrCode.Ecc.MEDIUM,Q:vr.QrCode.Ecc.QUARTILE,H:vr.QrCode.Ecc.HIGH},ql=128,Yl="L",Zl="#FFFFFF",Kl="#000000",Ql=!1,Xl=1,O0=4,A0=0,L0=.1;function Jl(t,r=0){const o=[];return t.forEach(function(n,s){let a=null;n.forEach(function(p,g){if(!p&&a!==null){o.push(`M${a+r} ${s+r}h${g-a}v1H${a+r}z`),a=null;return}if(g===n.length-1){if(!p)return;a===null?o.push(`M${g+r},${s+r} h1v1H${g+r}z`):o.push(`M${a+r},${s+r} h${g+1-a}v1H${a+r}z`);return}p&&a===null&&(a=g)})}),o.join("")}function ed(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((s,a)=>a<r.x||a>=r.x+r.w?s:!1))}function D0(t,r,o,n){if(n==null)return null;const s=t.length+o*2,a=Math.floor(r*L0),p=s/r,g=(n.width||a)*p,c=(n.height||a)*p,h=n.x==null?t.length/2-g/2:n.x*p,l=n.y==null?t.length/2-c/2:n.y*p,u=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let v=Math.floor(h),y=Math.floor(l),z=Math.ceil(g+h-v),S=Math.ceil(c+l-y);m={x:v,y,w:z,h:S}}const x=n.crossOrigin;return{x:h,y:l,h:c,w:g,excavation:m,opacity:u,crossOrigin:x}}function N0(t,r){return r!=null?Math.max(Math.floor(r),0):t?O0:A0}function td({value:t,level:r,minVersion:o,includeMargin:n,marginSize:s,imageSettings:a,size:p,boostLevel:g}){let c=i.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((y,z)=>(y.push(...vr.QrSegment.makeSegments(z)),y),[]);return vr.QrCode.encodeSegments(v,M0[r],o,void 0,void 0,g)},[t,r,o,g]);const{cells:h,margin:l,numCells:u,calculatedImageSettings:m}=i.useMemo(()=>{let x=c.getModules();const v=N0(n,s),y=x.length+v*2,z=D0(x,p,v,a);return{cells:x,margin:v,numCells:y,calculatedImageSettings:z}},[c,p,a,n,s]);return{qrcode:c,margin:l,cells:h,numCells:u,calculatedImageSettings:m}}var F0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),B0=i.forwardRef(function(r,o){const n=r,{value:s,size:a=ql,level:p=Yl,bgColor:g=Zl,fgColor:c=Kl,includeMargin:h=Ql,minVersion:l=Xl,boostLevel:u,marginSize:m,imageSettings:x}=n,y=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:z}=y,S=bs(y,["style"]),_=x==null?void 0:x.src,E=i.useRef(null),I=i.useRef(null),w=i.useCallback(P=>{E.current=P,typeof o=="function"?o(P):o&&(o.current=P)},[o]),[b,f]=i.useState(!1),{margin:$,cells:k,numCells:j,calculatedImageSettings:M}=td({value:s,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:m,imageSettings:x,size:a});i.useEffect(()=>{if(E.current!=null){const P=E.current,T=P.getContext("2d");if(!T)return;let B=k;const L=I.current,F=M!=null&&L!==null&&L.complete&&L.naturalHeight!==0&&L.naturalWidth!==0;F&&M.excavation!=null&&(B=ed(k,M.excavation));const O=window.devicePixelRatio||1;P.height=P.width=a*O;const A=a/j*O;T.scale(A,A),T.fillStyle=g,T.fillRect(0,0,j,j),T.fillStyle=c,F0?T.fill(new Path2D(Jl(B,$))):k.forEach(function(J,re){J.forEach(function(V,q){V&&T.fillRect(q+$,re+$,1,1)})}),M&&(T.globalAlpha=M.opacity),F&&T.drawImage(L,M.x+$,M.y+$,M.w,M.h)}}),i.useEffect(()=>{f(!1)},[_]);const R=vs({height:a,width:a},z);let C=null;return _!=null&&(C=i.createElement("img",{src:_,key:_,style:{display:"none"},onLoad:()=>{f(!0)},ref:I,crossOrigin:M==null?void 0:M.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",vs({style:R,height:a,width:a,ref:w,role:"img"},S)),C)});B0.displayName="QRCodeCanvas";var Ls=i.forwardRef(function(r,o){const n=r,{value:s,size:a=ql,level:p=Yl,bgColor:g=Zl,fgColor:c=Kl,includeMargin:h=Ql,minVersion:l=Xl,boostLevel:u,title:m,marginSize:x,imageSettings:v}=n,y=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:z,cells:S,numCells:_,calculatedImageSettings:E}=td({value:s,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:x,imageSettings:v,size:a});let I=S,w=null;v!=null&&E!=null&&(E.excavation!=null&&(I=ed(S,E.excavation)),w=i.createElement("image",{href:v.src,height:E.h,width:E.w,x:E.x+z,y:E.y+z,preserveAspectRatio:"none",opacity:E.opacity,crossOrigin:E.crossOrigin}));const b=Jl(I,z);return i.createElement("svg",vs({height:a,width:a,viewBox:`0 0 ${_} ${_}`,ref:o,role:"img"},y),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:g,d:`M0,0 h${_}v${_}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:b,shapeRendering:"crispEdges"}),w)});Ls.displayName="QRCodeSVG";const rd=i.createContext(void 0),Mt=()=>{const t=i.useContext(rd);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},U0=d.div`
3699
3699
  position: fixed;
3700
3700
  background: var(--color-background);
3701
3701
  border-radius: var(--radius-md);
@@ -3734,7 +3734,7 @@ cursor: pointer;
3734
3734
  justify-content: center;
3735
3735
  color: var(--color-muted);
3736
3736
  flex-shrink: 0;
3737
- `,vi=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:s,triggerRef:a})=>{const p=i.useRef(null),[g,c]=i.useState(!1),[h,l]=i.useState({top:0,left:0}),{toast:u}=Mt();i.useEffect(()=>{c(!0);const b=setTimeout(()=>{if(!p.current||!(a!=null&&a.current))return;const _=a.current;if(_){const j=_.getBoundingClientRect(),M=380,R=300,C=8;let P=0,T=0;const B=window.innerHeight-j.bottom,L=j.top;B>=R+C?(P=j.bottom+C,T=j.right-M,T<C&&(T=j.left,T+M>window.innerWidth-C&&(T=(window.innerWidth-M)/2))):L>=R+C?(P=j.top-R-C,T=j.right-M,T<C&&(T=j.left,T+M>window.innerWidth-C&&(T=(window.innerWidth-M)/2))):(P=j.bottom+C,T=j.right-M,T<C&&(T=j.left)),l({top:P,left:T})}},10),f=_=>{p.current&&!p.current.contains(_.target)&&t()},z=_=>{_.key==="Escape"&&t()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",z),()=>{clearTimeout(b),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",z)}},[t,a]);const[m,v]=i.useState(s?"otp":"email"),[x,y]=i.useState(s||""),[$,S]=i.useState(""),[k,I]=i.useState(!1),E=async()=>{if(!(!x||k)){I(!0);try{await r(x),v("otp")}catch(b){const f=b.message||"Failed to add email address. Please try again.";u(f,"error")}finally{I(!1)}}},w=async()=>{I(!0);try{await o($),t()}catch(b){const f=b.message||"Failed to verify email. Please check the code and try again.";u(f,"error")}finally{I(!1)}};return g?e.jsx(U0,{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(xi,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(W0,{children:[e.jsx(V0,{children:e.jsx(on,{size:16})}),e.jsx(ce,{id:"email-input",type:"email",placeholder:"Email address",value:x,onChange:b=>y(b.target.value),style:{flex:1}})]})}),e.jsxs(mi,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(X,{onClick:E,disabled:!x||k,style:{width:"auto",padding:"0 var(--space-md)"},children:k?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",x]}),e.jsx(Tt,{onComplete:async b=>S(b),onResend:n,isSubmitting:k}),e.jsxs(mi,{children:[e.jsx(X,{$outline:!0,onClick:()=>v("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(X,{onClick:w,disabled:$.length<6||k,style:{width:"auto",padding:"0 var(--space-md)"},children:k?"Verifying...":"Verify"})]})]})}):null},G0=d.div`
3737
+ `,vi=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:s,triggerRef:a})=>{const p=i.useRef(null),[g,c]=i.useState(!1),[h,l]=i.useState({top:0,left:0}),{toast:u}=Mt();i.useEffect(()=>{c(!0);const b=setTimeout(()=>{if(!p.current||!(a!=null&&a.current))return;const k=a.current;if(k){const j=k.getBoundingClientRect(),M=380,R=300,C=8;let P=0,T=0;const B=window.innerHeight-j.bottom,L=j.top;B>=R+C?(P=j.bottom+C,T=j.right-M,T<C&&(T=j.left,T+M>window.innerWidth-C&&(T=(window.innerWidth-M)/2))):L>=R+C?(P=j.top-R-C,T=j.right-M,T<C&&(T=j.left,T+M>window.innerWidth-C&&(T=(window.innerWidth-M)/2))):(P=j.bottom+C,T=j.right-M,T<C&&(T=j.left)),l({top:P,left:T})}},10),f=k=>{p.current&&!p.current.contains(k.target)&&t()},$=k=>{k.key==="Escape"&&t()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",$),()=>{clearTimeout(b),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",$)}},[t,a]);const[m,x]=i.useState(s?"otp":"email"),[v,y]=i.useState(s||""),[z,S]=i.useState(""),[_,E]=i.useState(!1),I=async()=>{if(!(!v||_)){E(!0);try{await r(v),x("otp")}catch(b){const f=b.message||"Failed to add email address. Please try again.";u(f,"error")}finally{E(!1)}}},w=async()=>{E(!0);try{await o(z),t()}catch(b){const f=b.message||"Failed to verify email. Please check the code and try again.";u(f,"error")}finally{E(!1)}};return g?e.jsx(U0,{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(xi,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(W0,{children:[e.jsx(V0,{children:e.jsx(on,{size:16})}),e.jsx(ce,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:b=>y(b.target.value),style:{flex:1}})]})}),e.jsxs(mi,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(X,{onClick:I,disabled:!v||_,style:{width:"auto",padding:"0 var(--space-md)"},children:_?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(xi,{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(Tt,{onComplete:async b=>S(b),onResend:n,isSubmitting:_}),e.jsxs(mi,{children:[e.jsx(X,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(X,{onClick:w,disabled:z.length<6||_,style:{width:"auto",padding:"0 var(--space-md)"},children:_?"Verifying...":"Verify"})]})]})}):null},G0=d.div`
3738
3738
  position: fixed;
3739
3739
  background: var(--color-background);
3740
3740
  border-radius: var(--radius-md);
@@ -3758,7 +3758,7 @@ cursor: pointer;
3758
3758
  font-weight: 400;
3759
3759
  color: var(--color-foreground);
3760
3760
  margin-bottom: 12px;
3761
- `,wi=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:s,triggerRef:a})=>{var z;const p=i.useRef(null),[g,c]=i.useState(!1),[h,l]=i.useState({top:0,left:0}),{toast:u}=Mt();i.useEffect(()=>{c(!0);const _=setTimeout(()=>{if(!p.current||!(a!=null&&a.current))return;const R=a.current;if(R){const C=R.getBoundingClientRect(),P=380,T=300,B=8;let L=0,F=0;const O=window.innerHeight-C.bottom,A=C.top;O>=T+B?(L=C.bottom+B,F=C.right-P,F<B&&(F=C.left,F+P>window.innerWidth-B&&(F=(window.innerWidth-P)/2))):A>=T+B?(L=C.top-T-B,F=C.right-P,F<B&&(F=C.left,F+P>window.innerWidth-B&&(F=(window.innerWidth-P)/2))):(L=C.bottom+B,F=C.right-P,F<B&&(F=C.left)),l({top:L,left:F})}},10),j=R=>{p.current&&!p.current.contains(R.target)&&t()},M=R=>{R.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",M),()=>{clearTimeout(_),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",M)}},[t,a]);const[m,v]=i.useState(n?"otp":"phone"),[x,y]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[$,S]=i.useState((z=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:z.pop()),[k,I]=i.useState(""),[E,w]=i.useState(!1),b=async()=>{if(!(!x||E)){w(!0);try{await r(x,$||""),v("otp")}catch(_){const j=_.message||"Failed to add phone number. Please try again.";u(j,"error")}finally{w(!1)}}},f=async()=>{w(!0);try{await o(k),t()}catch(_){const j=_.message||"Failed to verify phone. Please check the code and try again.";u(j,"error")}finally{w(!1)}};return g?e.jsx(G0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(qr,{value:x,onChange:_=>y(_.target.value),error:"",countryCode:$,setCountryCode:S})}),e.jsxs(bi,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(X,{onClick:b,disabled:!x||E,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(yi,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(Tt,{onComplete:_=>I(_),onResend:async()=>s()})}),e.jsxs(bi,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(X,{onClick:f,disabled:k.length!==6||E,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},H0=d.div`
3761
+ `,wi=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:s,triggerRef:a})=>{var $;const p=i.useRef(null),[g,c]=i.useState(!1),[h,l]=i.useState({top:0,left:0}),{toast:u}=Mt();i.useEffect(()=>{c(!0);const k=setTimeout(()=>{if(!p.current||!(a!=null&&a.current))return;const R=a.current;if(R){const C=R.getBoundingClientRect(),P=380,T=300,B=8;let L=0,F=0;const O=window.innerHeight-C.bottom,A=C.top;O>=T+B?(L=C.bottom+B,F=C.right-P,F<B&&(F=C.left,F+P>window.innerWidth-B&&(F=(window.innerWidth-P)/2))):A>=T+B?(L=C.top-T-B,F=C.right-P,F<B&&(F=C.left,F+P>window.innerWidth-B&&(F=(window.innerWidth-P)/2))):(L=C.bottom+B,F=C.right-P,F<B&&(F=C.left)),l({top:L,left:F})}},10),j=R=>{p.current&&!p.current.contains(R.target)&&t()},M=R=>{R.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",M),()=>{clearTimeout(k),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",M)}},[t,a]);const[m,x]=i.useState(n?"otp":"phone"),[v,y]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[z,S]=i.useState(($=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:$.pop()),[_,E]=i.useState(""),[I,w]=i.useState(!1),b=async()=>{if(!(!v||I)){w(!0);try{await r(v,z||""),x("otp")}catch(k){const j=k.message||"Failed to add phone number. Please try again.";u(j,"error")}finally{w(!1)}}},f=async()=>{w(!0);try{await o(_),t()}catch(k){const j=k.message||"Failed to verify phone. Please check the code and try again.";u(j,"error")}finally{w(!1)}};return g?e.jsx(G0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(qr,{value:v,onChange:k=>y(k.target.value),error:"",countryCode:z,setCountryCode:S})}),e.jsxs(bi,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(X,{onClick:b,disabled:!v||I,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(yi,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(Tt,{onComplete:k=>E(k),onResend:async()=>s()})}),e.jsxs(bi,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(X,{onClick:f,disabled:_.length!==6||I,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},H0=d.div`
3762
3762
  position: fixed;
3763
3763
  background: var(--color-background);
3764
3764
  border-radius: var(--radius-md);
@@ -3801,7 +3801,7 @@ cursor: pointer;
3801
3801
  font-weight: 400;
3802
3802
  color: var(--color-foreground);
3803
3803
  margin-bottom: 8px;
3804
- `,q0=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const s=i.useRef(null),[a,p]=i.useState("qr"),[g,c]=i.useState(""),[h,l]=i.useState(""),[u,m]=i.useState(["",""]),[v,x]=i.useState(!1),[y,$]=i.useState(!1),[S,k]=i.useState({top:0,left:0}),{toast:I}=Mt();i.useEffect(()=>{$(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const z=n.current;if(z){const _=z.getBoundingClientRect(),j=380,M=400,R=8;let C=0,P=0;const T=window.innerHeight-_.bottom,B=_.top;T>=M+R?(C=_.bottom+R,P=_.right-j,P<R&&(P=_.left,P+j>window.innerWidth-R&&(P=(window.innerWidth-j)/2))):B>=M+R?(C=_.top-M-R,P=_.right-j,P<R&&(P=_.left,P+j>window.innerWidth-R&&(P=(window.innerWidth-j)/2))):(C=_.bottom+R,P=_.right-j,P<R&&(P=_.left)),k({top:C,left:P})}},10),b=z=>{s.current&&!s.current.contains(z.target)&&t()},f=z=>{z.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(w),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,n]),i.useEffect(()=>{(async()=>{x(!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.";I(f,"error")}finally{x(!1)}})()},[]);const E=async()=>{if(!u.some(w=>w.length!==6)){x(!0);try{await o(u),t()}catch(w){const b=w.message||"Failed to verify codes. Please check your authenticator app and try again.";I(b,"error")}finally{x(!1)}}};return y?e.jsx(H0,{ref:s,style:{top:`${S.top}px`,left:`${S.left}px`,visibility:S.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:a==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(_i,{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:v?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(Ls,{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(ji,{children:e.jsx(Gn,{$primary:!0,onClick:()=>p("verify"),disabled:v||!g,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(_i,{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(ce,{id:"totp-code-1",type:"text",placeholder:"000000",value:u[0],onChange:w=>{const b=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([b,u[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(ce,{id:"totp-code-2",type:"text",placeholder:"000000",value:u[1],onChange:w=>{const b=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([u[0],b])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(ji,{children:[e.jsx(Gn,{onClick:()=>p("qr"),children:"Back"}),e.jsx(Gn,{$primary:!0,onClick:E,disabled:v||u.some(w=>w.length!==6),children:v?"Verifying...":"Verify"})]})]})}):null},Y0=d.div`
3804
+ `,q0=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const s=i.useRef(null),[a,p]=i.useState("qr"),[g,c]=i.useState(""),[h,l]=i.useState(""),[u,m]=i.useState(["",""]),[x,v]=i.useState(!1),[y,z]=i.useState(!1),[S,_]=i.useState({top:0,left:0}),{toast:E}=Mt();i.useEffect(()=>{z(!0);const w=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const $=n.current;if($){const k=$.getBoundingClientRect(),j=380,M=400,R=8;let C=0,P=0;const T=window.innerHeight-k.bottom,B=k.top;T>=M+R?(C=k.bottom+R,P=k.right-j,P<R&&(P=k.left,P+j>window.innerWidth-R&&(P=(window.innerWidth-j)/2))):B>=M+R?(C=k.top-M-R,P=k.right-j,P<R&&(P=k.left,P+j>window.innerWidth-R&&(P=(window.innerWidth-j)/2))):(C=k.bottom+R,P=k.right-j,P<R&&(P=k.left)),_({top:C,left:P})}},10),b=$=>{s.current&&!s.current.contains($.target)&&t()},f=$=>{$.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(w),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.";E(f,"error")}finally{v(!1)}})()},[]);const I=async()=>{if(!u.some(w=>w.length!==6)){v(!0);try{await o(u),t()}catch(w){const b=w.message||"Failed to verify codes. Please check your authenticator app and try again.";E(b,"error")}finally{v(!1)}}};return y?e.jsx(H0,{ref:s,style:{top:`${S.top}px`,left:`${S.left}px`,visibility:S.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:a==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(_i,{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(Ls,{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(ji,{children:e.jsx(Gn,{$primary:!0,onClick:()=>p("verify"),disabled:x||!g,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(_i,{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(ce,{id:"totp-code-1",type:"text",placeholder:"000000",value:u[0],onChange:w=>{const b=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([b,u[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(ce,{id:"totp-code-2",type:"text",placeholder:"000000",value:u[1],onChange:w=>{const b=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([u[0],b])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(ji,{children:[e.jsx(Gn,{onClick:()=>p("qr"),children:"Back"}),e.jsx(Gn,{$primary:!0,onClick:I,disabled:x||u.some(w=>w.length!==6),children:x?"Verifying...":"Verify"})]})]})}):null},Y0=d.div`
3805
3805
  position: fixed;
3806
3806
  background: var(--color-background);
3807
3807
  border-radius: var(--radius-md);
@@ -3871,7 +3871,7 @@ cursor: pointer;
3871
3871
  color: var(--color-error);
3872
3872
  font-size: 12px;
3873
3873
  margin-top: 4px;
3874
- `,Ci=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const s=i.useRef(null),[a,p]=i.useState(!1),[g,c]=i.useState({top:0,left:0}),[h,l]=i.useState(""),[u,m]=i.useState(""),[v,x]=i.useState(""),[y,$]=i.useState(!1),[S,k]=i.useState(!1),[I,E]=i.useState(!1),[w,b]=i.useState(!1),[f,z]=i.useState({});i.useEffect(()=>{p(!0);const j=setTimeout(()=>{if(!s.current||!(o!=null&&o.current))return;const C=o.current;if(C){const P=C.getBoundingClientRect(),T=380,B=350,L=8;let F=0,O=0;const A=window.innerHeight-P.bottom,J=P.top;A>=B+L?(F=P.bottom+L,O=P.right-T,O<L&&(O=P.left,O+T>window.innerWidth-L&&(O=(window.innerWidth-T)/2))):J>=B+L?(F=P.top-B-L,O=P.right-T,O<L&&(O=P.left,O+T>window.innerWidth-L&&(O=(window.innerWidth-T)/2))):(F=P.bottom+L,O=P.right-T,O<L&&(O=P.left)),c({top:F,left:O})}},10),M=C=>{s.current&&!s.current.contains(C.target)&&t()},R=C=>{C.key==="Escape"&&t()};return document.addEventListener("mousedown",M),document.addEventListener("keydown",R),()=>{clearTimeout(j),document.removeEventListener("mousedown",M),document.removeEventListener("keydown",R)}},[t,o]);const _=async()=>{if(w)return;const j={};if(!n&&!h&&(j.currentPassword="Current password is required"),u?u.length<8&&(j.newPassword="Password must be at least 8 characters"):j.newPassword="New password is required",u!==v&&(j.confirmPassword="Passwords do not match"),Object.keys(j).length>0){z(j);return}b(!0);try{await r(n?"":h,u),t()}catch(M){z({form:M.message||"Failed to update password"})}finally{b(!1)}};return a?e.jsxs(Y0,{ref:s,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:[e.jsx(K0,{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(Hn,{children:[e.jsx(ie,{children:"Current Password"}),e.jsxs(qn,{children:[e.jsx(ce,{type:y?"text":"password",placeholder:"Enter your current password",value:h,onChange:j=>l(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>$(!y),"aria-label":y?"Hide current password":"Show current password",children:y?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),f.currentPassword&&e.jsx(zo,{children:f.currentPassword})]}),e.jsxs(Hn,{children:[e.jsx(ie,{children:n?"Password":"New Password"}),e.jsxs(qn,{children:[e.jsx(ce,{type:S?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:u,onChange:j=>m(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>k(!S),"aria-label":S?"Hide new password":"Show new password",children:S?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),f.newPassword&&e.jsx(zo,{children:f.newPassword})]}),e.jsxs(Hn,{children:[e.jsx(ie,{children:"Confirm New Password"}),e.jsxs(qn,{children:[e.jsx(ce,{type:I?"text":"password",placeholder:"Confirm your new password",value:v,onChange:j=>x(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>E(!I),"aria-label":I?"Hide confirm password":"Show confirm password",children:I?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),f.confirmPassword&&e.jsx(zo,{children:f.confirmPassword})]}),f.form&&e.jsx(zo,{children:f.form}),e.jsxs(Z0,{children:[e.jsx(ki,{onClick:t,children:"Cancel"}),e.jsx(ki,{$primary:!0,onClick:_,disabled:w,children:w?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},Q0=d.div`
3874
+ `,Ci=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const s=i.useRef(null),[a,p]=i.useState(!1),[g,c]=i.useState({top:0,left:0}),[h,l]=i.useState(""),[u,m]=i.useState(""),[x,v]=i.useState(""),[y,z]=i.useState(!1),[S,_]=i.useState(!1),[E,I]=i.useState(!1),[w,b]=i.useState(!1),[f,$]=i.useState({});i.useEffect(()=>{p(!0);const j=setTimeout(()=>{if(!s.current||!(o!=null&&o.current))return;const C=o.current;if(C){const P=C.getBoundingClientRect(),T=380,B=350,L=8;let F=0,O=0;const A=window.innerHeight-P.bottom,J=P.top;A>=B+L?(F=P.bottom+L,O=P.right-T,O<L&&(O=P.left,O+T>window.innerWidth-L&&(O=(window.innerWidth-T)/2))):J>=B+L?(F=P.top-B-L,O=P.right-T,O<L&&(O=P.left,O+T>window.innerWidth-L&&(O=(window.innerWidth-T)/2))):(F=P.bottom+L,O=P.right-T,O<L&&(O=P.left)),c({top:F,left:O})}},10),M=C=>{s.current&&!s.current.contains(C.target)&&t()},R=C=>{C.key==="Escape"&&t()};return document.addEventListener("mousedown",M),document.addEventListener("keydown",R),()=>{clearTimeout(j),document.removeEventListener("mousedown",M),document.removeEventListener("keydown",R)}},[t,o]);const k=async()=>{if(w)return;const j={};if(!n&&!h&&(j.currentPassword="Current password is required"),u?u.length<8&&(j.newPassword="Password must be at least 8 characters"):j.newPassword="New password is required",u!==x&&(j.confirmPassword="Passwords do not match"),Object.keys(j).length>0){$(j);return}b(!0);try{await r(n?"":h,u),t()}catch(M){$({form:M.message||"Failed to update password"})}finally{b(!1)}};return a?e.jsxs(Y0,{ref:s,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:[e.jsx(K0,{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(Hn,{children:[e.jsx(ie,{children:"Current Password"}),e.jsxs(qn,{children:[e.jsx(ce,{type:y?"text":"password",placeholder:"Enter your current password",value:h,onChange:j=>l(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>z(!y),"aria-label":y?"Hide current password":"Show current password",children:y?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),f.currentPassword&&e.jsx(zo,{children:f.currentPassword})]}),e.jsxs(Hn,{children:[e.jsx(ie,{children:n?"Password":"New Password"}),e.jsxs(qn,{children:[e.jsx(ce,{type:S?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:u,onChange:j=>m(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>_(!S),"aria-label":S?"Hide new password":"Show new password",children:S?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),f.newPassword&&e.jsx(zo,{children:f.newPassword})]}),e.jsxs(Hn,{children:[e.jsx(ie,{children:"Confirm New Password"}),e.jsxs(qn,{children:[e.jsx(ce,{type:E?"text":"password",placeholder:"Confirm your new password",value:x,onChange:j=>v(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>I(!E),"aria-label":E?"Hide confirm password":"Show confirm password",children:E?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),f.confirmPassword&&e.jsx(zo,{children:f.confirmPassword})]}),f.form&&e.jsx(zo,{children:f.form}),e.jsxs(Z0,{children:[e.jsx(ki,{onClick:t,children:"Cancel"}),e.jsx(ki,{$primary:!0,onClick:k,disabled:w,children:w?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},Q0=d.div`
3875
3875
  position: fixed;
3876
3876
  background: var(--color-background);
3877
3877
  border-radius: var(--radius-md);
@@ -3909,7 +3909,7 @@ cursor: pointer;
3909
3909
  color: var(--color-warning-text, var(--color-foreground));
3910
3910
  margin: 0;
3911
3911
  line-height: 1.5;
3912
- `,rv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(!1),[p,g]=i.useState({top:0,left:0}),[c,h]=i.useState(""),[l,u]=i.useState(!1),{toast:m}=Mt();i.useEffect(()=>{a(!0);const x=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const S=o.current;if(S){const k=S.getBoundingClientRect(),I=400,E=300,w=8;let b=0,f=0;const z=window.innerHeight-k.bottom,_=k.top;z>=E+w?(b=k.bottom+w,f=k.right-I,f<w&&(f=k.left,f+I>window.innerWidth-w&&(f=(window.innerWidth-I)/2))):_>=E+w?(b=k.top-E-w,f=k.right-I,f<w&&(f=k.left,f+I>window.innerWidth-w&&(f=(window.innerWidth-I)/2))):(b=k.bottom+w,f=k.right-I,f<w&&(f=k.left)),g({top:b,left:f})}},10),y=S=>{n.current&&!n.current.contains(S.target)&&t()},$=S=>{S.key==="Escape"&&t()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",$),()=>{clearTimeout(x),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",$)}},[t,o]);const v=async()=>{if(!(!c||l)){u(!0);try{await r(c),t()}catch(x){const y=x.message||"Failed to remove password. Please try again.";m(y,"error")}finally{u(!1)}}};return s?e.jsxs(Q0,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:x=>x.stopPropagation(),children:[e.jsxs(J0,{children:[e.jsx(ut,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(ev,{children:e.jsx(tv,{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(ie,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(ce,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:x=>h(x.target.value),autoFocus:!0})]}),e.jsxs(X0,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(X,{onClick:v,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},ov=d.div`
3912
+ `,rv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[s,a]=i.useState(!1),[p,g]=i.useState({top:0,left:0}),[c,h]=i.useState(""),[l,u]=i.useState(!1),{toast:m}=Mt();i.useEffect(()=>{a(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const S=o.current;if(S){const _=S.getBoundingClientRect(),E=400,I=300,w=8;let b=0,f=0;const $=window.innerHeight-_.bottom,k=_.top;$>=I+w?(b=_.bottom+w,f=_.right-E,f<w&&(f=_.left,f+E>window.innerWidth-w&&(f=(window.innerWidth-E)/2))):k>=I+w?(b=_.top-I-w,f=_.right-E,f<w&&(f=_.left,f+E>window.innerWidth-w&&(f=(window.innerWidth-E)/2))):(b=_.bottom+w,f=_.right-E,f<w&&(f=_.left)),g({top:b,left:f})}},10),y=S=>{n.current&&!n.current.contains(S.target)&&t()},z=S=>{S.key==="Escape"&&t()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",z),()=>{clearTimeout(v),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",z)}},[t,o]);const x=async()=>{if(!(!c||l)){u(!0);try{await r(c),t()}catch(v){const y=v.message||"Failed to remove password. Please try again.";m(y,"error")}finally{u(!1)}}};return s?e.jsxs(Q0,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(J0,{children:[e.jsx(ut,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(ev,{children:e.jsx(tv,{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(ie,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(ce,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:v=>h(v.target.value),autoFocus:!0})]}),e.jsxs(X0,{children:[e.jsx(X,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(X,{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},ov=d.div`
3913
3913
  position: fixed;
3914
3914
  background: var(--color-background);
3915
3915
  border-radius: var(--radius-md);
@@ -3975,7 +3975,7 @@ cursor: pointer;
3975
3975
  background: var(--color-input-background-hover);
3976
3976
  border-color: var(--color-primary);
3977
3977
  }
3978
- `,lv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:s})=>{const a=i.useRef(null),[p,g]=i.useState(!1),[c,h]=i.useState({top:0,left:0});return i.useEffect(()=>{g(!0);const l=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const v=s.current;if(v){const x=v.getBoundingClientRect(),y=380,$=300,S=8;let k=0,I=0;const E=window.innerHeight-x.bottom,w=x.top;E>=$+S?(k=x.bottom+S,I=x.right-y,I<S&&(I=x.left,I+y>window.innerWidth-S&&(I=(window.innerWidth-y)/2))):w>=$+S?(k=x.top-$-S,I=x.right-y,I<S&&(I=x.left,I+y>window.innerWidth-S&&(I=(window.innerWidth-y)/2))):(k=x.bottom+S,I=x.right-y,I<S&&(I=x.left)),h({top:k,left:I})}},10),u=v=>{a.current&&!a.current.contains(v.target)&&r()},m=v=>{v.key==="Escape"&&r()};return document.addEventListener("mousedown",u),document.addEventListener("keydown",m),()=>{clearTimeout(l),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",m)}},[r,s]),p?e.jsxs(ov,{ref:a,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:l=>l.stopPropagation(),children:[e.jsxs(nv,{children:[e.jsx(sv,{children:"Backup Codes"}),e.jsxs(av,{children:[e.jsxs(Si,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Jt,{size:14}),"Copy"]}),e.jsxs(Si,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(rn,{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(iv,{children:t.map((l,u)=>e.jsx(cv,{onClick:()=>{navigator.clipboard.writeText(l)},title:"Click to copy",children:l},u))}),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},dv=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)"}})]}),uv=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"})]}),pv=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})]}),hv=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)"})]}),fv=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)"})]}),gv=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)"})]}),mv=ar`
3978
+ `,lv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:s})=>{const a=i.useRef(null),[p,g]=i.useState(!1),[c,h]=i.useState({top:0,left:0});return i.useEffect(()=>{g(!0);const l=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const x=s.current;if(x){const v=x.getBoundingClientRect(),y=380,z=300,S=8;let _=0,E=0;const I=window.innerHeight-v.bottom,w=v.top;I>=z+S?(_=v.bottom+S,E=v.right-y,E<S&&(E=v.left,E+y>window.innerWidth-S&&(E=(window.innerWidth-y)/2))):w>=z+S?(_=v.top-z-S,E=v.right-y,E<S&&(E=v.left,E+y>window.innerWidth-S&&(E=(window.innerWidth-y)/2))):(_=v.bottom+S,E=v.right-y,E<S&&(E=v.left)),h({top:_,left:E})}},10),u=x=>{a.current&&!a.current.contains(x.target)&&r()},m=x=>{x.key==="Escape"&&r()};return document.addEventListener("mousedown",u),document.addEventListener("keydown",m),()=>{clearTimeout(l),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",m)}},[r,s]),p?e.jsxs(ov,{ref:a,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:l=>l.stopPropagation(),children:[e.jsxs(nv,{children:[e.jsx(sv,{children:"Backup Codes"}),e.jsxs(av,{children:[e.jsxs(Si,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Xt,{size:14}),"Copy"]}),e.jsxs(Si,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(rn,{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(iv,{children:t.map((l,u)=>e.jsx(cv,{onClick:()=>{navigator.clipboard.writeText(l)},title:"Click to copy",children:l},u))}),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},dv=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)"}})]}),uv=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"})]}),pv=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})]}),hv=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)"})]}),fv=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)"})]}),gv=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)"})]}),mv=sr`
3979
3979
  0% { transform: rotate(0deg); }
3980
3980
  100% { transform: rotate(360deg); }
3981
3981
  `,xv=d.div`
@@ -4110,7 +4110,7 @@ cursor: pointer;
4110
4110
  flex-wrap: wrap;
4111
4111
  gap: 12px;
4112
4112
  margin-bottom: 0;
4113
- `,wv=()=>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:"?"})]}),jv=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(dv,{...o}):r.includes("firefox")?e.jsx(uv,{...o}):r.includes("safari")?e.jsx(pv,{...o}):r.includes("edge")?e.jsx(hv,{...o}):r.includes("opera")?e.jsx(fv,{...o}):r.includes("brave")?e.jsx(gv,{...o}):e.jsx(wv,{})},_v=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:s,loading:a}=bc(),{refetch:p}=Ue(),{toast:g}=Mt(),c=o,h=async u=>{try{await n(u),await Promise.all([s(),p()]),r(null),g("Session ended successfully","info")}catch(m){g(m.message||"Failed to end session. Please try again.","error")}},l=u=>{if(!u||u.trim()==="")return"Unknown";const m=new Date(u);if(isNaN(m.getTime()))return"Unknown";const x=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return x<1?"Just now":x<60?`${x}m ago`:x<1440?`${Math.floor(x/60)}h ago`:m.toLocaleDateString()};return a?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Ee,{})}):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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Browser & Device"}),e.jsx(Ce,{children:"Location"}),e.jsx(Ce,{children:"Last Active"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:c.map(u=>e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(sd,{children:e.jsx(jv,{browser:u.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:u.browser||"Unknown Browser"}),u.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.device})]})]})}),e.jsx(Me,{children:e.jsxs("div",{children:[e.jsx("div",{children:u.city&&u.country?`${u.city}, ${u.country}`:"Unknown location"}),u.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.ip_address})]})}),e.jsx(Me,{children:l(u.last_active_at)}),e.jsx(mt,{children:e.jsxs(nt,{open:t===u.id,openChange:m=>r(m?u.id:null),children:[e.jsx(at,{children:e.jsx(cn,{children:"•••"})}),e.jsx(st,{children:e.jsx(Te,{onClick:()=>h(u.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Et,{size:14}),"End Session"]})})})]})})]},u.id))})]}):e.jsx(it,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},kv=()=>{var b,f,z,_;const{deployment:t}=ve(),{toast:r}=Mt(),[o,n]=i.useState(null),[s,a]=i.useState(""),[p,g]=i.useState(!1),[c,h]=i.useState(null),[l,u]=i.useState(""),m=i.useRef(null),v=i.useRef({}),{user:x,createEmailAddress:y,deleteEmailAddress:$,prepareEmailVerification:S,attemptEmailVerification:k,makeEmailPrimary:I}=sr();if(!((f=(b=t==null?void 0:t.auth_settings)==null?void 0:b.email_address)!=null&&f.enabled))return null;const E=async j=>{try{if(j===(x==null?void 0:x.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await $(j),x.refetch(),r("Email address deleted successfully","info")}catch(M){r(M.message||"Failed to delete email address. Please try again.","error")}},w=i.useMemo(()=>x!=null&&x.user_email_addresses?l.trim()?x.user_email_addresses.filter(j=>j.email.toLowerCase().includes(l.toLowerCase())):x.user_email_addresses:[],[x==null?void 0:x.user_email_addresses,l]);return e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{style:{marginBottom:"20px"},children:[e.jsx(St,{value:l,onChange:u,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:m,onClick:()=>g(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),p&&e.jsx(vi,{triggerRef:m,onClose:()=>g(!1),onAddEmail:async j=>{const M=await y(j);a(M.data.id),await S(M.data.id),x.refetch()},onPrepareVerification:async()=>{await S(s),x.refetch()},onAttemptVerification:async j=>{await k(s,j),x.refetch(),g(!1),a(""),r("Email added and verified successfully!","info")}})]})]}),w!=null&&w.length?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email Address"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:w.map(j=>e.jsxs(Ne,{children:[e.jsx(Me,{children:j.email}),e.jsx(Me,{children:j.id===(x==null?void 0:x.primary_email_address_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx(mt,{children:j.id!==(x==null?void 0:x.primary_email_address_id)||!j.verified?e.jsxs(nt,{open:o===j.id,openChange:M=>n(M?j.id:null),children:[e.jsx(at,{children:e.jsx(cn,{ref:M=>{M&&(v.current[j.id]=M)},children:"•••"})}),e.jsxs(st,{children:[j.id!==(x==null?void 0:x.primary_email_address_id)&&j.verified&&e.jsx(Te,{onClick:async()=>{try{await I(j.id),x.refetch(),n(null),r("Primary email updated successfully","info")}catch(M){r(M.message||"Failed to update primary email","error")}},children:"Make primary"}),!j.verified&&e.jsx(Te,{onClick:async()=>{n(null),await S(j.id),h(j.id)},children:"Verify email"}),j.id!==(x==null?void 0:x.primary_email_address_id)&&e.jsx(Te,{$destructive:!0,onClick:()=>{E(j.id),n(null)},children:"Remove"})]})]}):null})]},j.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(vi,{existingEmail:(_=(z=x==null?void 0:x.user_email_addresses)==null?void 0:z.find(j=>j.id===c))==null?void 0:_.email,triggerRef:{current:v.current[c]},onClose:()=>h(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await S(c),x.refetch()},onAttemptVerification:async j=>{await k(c,j),x.refetch(),h(null),r("Email verified successfully!","info")}})]})},Cv=()=>{var w,b,f,z;const{deployment:t}=ve(),[r,o]=i.useState(null),[n,s]=i.useState(""),[a,p]=i.useState(!1),[g,c]=i.useState(null),[h,l]=i.useState(""),u=i.useRef(null),m=i.useRef({}),{user:v,createPhoneNumber:x,deletePhoneNumber:y,preparePhoneVerification:$,attemptPhoneVerification:S,makePhonePrimary:k}=sr();if(!((b=(w=t==null?void 0:t.auth_settings)==null?void 0:w.phone_number)!=null&&b.enabled))return null;const I=_=>{const j=Oo.find(M=>M.dialCode===_);return(j==null?void 0:j.flag)||"🌍"},E=i.useMemo(()=>v!=null&&v.user_phone_numbers?h.trim()?v.user_phone_numbers.filter(_=>_.phone_number.toLowerCase().includes(h.toLowerCase())):v.user_phone_numbers:[],[v==null?void 0:v.user_phone_numbers,h]);return e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{style:{marginBottom:"20px"},children:[e.jsx(St,{value:h,onChange:l,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:u,onClick:()=>p(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),a&&e.jsx(wi,{triggerRef:u,onClose:()=>p(!1),onAddPhone:async(_,j)=>{const M=await x(_,j);s(M.data.id),await $(M.data.id)},onPrepareVerification:async()=>{await $(n),v.refetch()},onAttemptVerification:async _=>{await S(n,_),v.refetch(),p(!1)}}),g&&e.jsx(wi,{existingPhone:(z=(f=v==null?void 0:v.user_phone_numbers)==null?void 0:f.find(_=>_.id===g))==null?void 0:z.phone_number,triggerRef:{current:m.current[g]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await $(g),v.refetch()},onAttemptVerification:async _=>{await S(g,_),v.refetch(),c(null)}})]})]}),E!=null&&E.length?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Phone Number"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:E.map(_=>e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:I(_.country_code)}),e.jsx("span",{children:_.country_code}),e.jsx("span",{children:_.phone_number})]})}),e.jsx(Me,{children:_.id===(v==null?void 0:v.primary_phone_number_id)?"Primary":_.verified?"Verified":"Not Verified"}),e.jsx(mt,{children:e.jsxs(nt,{open:r===_.id,openChange:j=>o(j?_.id:null),children:[e.jsx(at,{children:e.jsx(cn,{ref:j=>{j&&(m.current[_.id]=j)},children:"•••"})}),e.jsxs(st,{children:[_.id!==(v==null?void 0:v.primary_phone_number_id)&&_.verified&&e.jsx(Te,{onClick:async()=>{await k(_.id),o(null),v.refetch()},children:"Make primary"}),!_.verified&&e.jsx(Te,{onClick:async()=>{await $(_.id),c(_.id),o(null)},children:"Verify phone"}),e.jsx(Te,{$destructive:!0,onClick:async()=>{await y(_.id),o(null),v.refetch()},children:"Remove"})]})]})})]},_.id))})]}):e.jsx(it,{title:h?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},sd=d.div`
4113
+ `,wv=()=>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:"?"})]}),jv=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(dv,{...o}):r.includes("firefox")?e.jsx(uv,{...o}):r.includes("safari")?e.jsx(pv,{...o}):r.includes("edge")?e.jsx(hv,{...o}):r.includes("opera")?e.jsx(fv,{...o}):r.includes("brave")?e.jsx(gv,{...o}):e.jsx(wv,{})},_v=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:s,loading:a}=bc(),{refetch:p}=Ue(),{toast:g}=Mt(),c=o,h=async u=>{try{await n(u),await Promise.all([s(),p()]),r(null),g("Session ended successfully","info")}catch(m){g(m.message||"Failed to end session. Please try again.","error")}},l=u=>{if(!u||u.trim()==="")return"Unknown";const m=new Date(u);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 a?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Ee,{})}):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(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Browser & Device"}),e.jsx(Ce,{children:"Location"}),e.jsx(Ce,{children:"Last Active"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:c.map(u=>e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(od,{children:e.jsx(jv,{browser:u.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:u.browser||"Unknown Browser"}),u.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.device})]})]})}),e.jsx(Me,{children:e.jsxs("div",{children:[e.jsx("div",{children:u.city&&u.country?`${u.city}, ${u.country}`:"Unknown location"}),u.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.ip_address})]})}),e.jsx(Me,{children:l(u.last_active_at)}),e.jsx(mt,{children:e.jsxs(nt,{open:t===u.id,openChange:m=>r(m?u.id:null),children:[e.jsx(at,{children:e.jsx(cn,{children:"•••"})}),e.jsx(st,{children:e.jsx(Te,{onClick:()=>h(u.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Et,{size:14}),"End Session"]})})})]})})]},u.id))})]}):e.jsx(it,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},kv=()=>{var b,f,$,k;const{deployment:t}=ve(),{toast:r}=Mt(),[o,n]=i.useState(null),[s,a]=i.useState(""),[p,g]=i.useState(!1),[c,h]=i.useState(null),[l,u]=i.useState(""),m=i.useRef(null),x=i.useRef({}),{user:v,createEmailAddress:y,deleteEmailAddress:z,prepareEmailVerification:S,attemptEmailVerification:_,makeEmailPrimary:E}=nr();if(!((f=(b=t==null?void 0:t.auth_settings)==null?void 0:b.email_address)!=null&&f.enabled))return null;const I=async j=>{try{if(j===(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 z(j),v.refetch(),r("Email address deleted successfully","info")}catch(M){r(M.message||"Failed to delete email address. Please try again.","error")}},w=i.useMemo(()=>v!=null&&v.user_email_addresses?l.trim()?v.user_email_addresses.filter(j=>j.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(Ho,{style:{marginBottom:"20px"},children:[e.jsx(St,{value:l,onChange:u,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:m,onClick:()=>g(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),p&&e.jsx(vi,{triggerRef:m,onClose:()=>g(!1),onAddEmail:async j=>{const M=await y(j);a(M.data.id),await S(M.data.id),v.refetch()},onPrepareVerification:async()=>{await S(s),v.refetch()},onAttemptVerification:async j=>{await _(s,j),v.refetch(),g(!1),a(""),r("Email added and verified successfully!","info")}})]})]}),w!=null&&w.length?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Email Address"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:w.map(j=>e.jsxs(Ne,{children:[e.jsx(Me,{children:j.email}),e.jsx(Me,{children:j.id===(v==null?void 0:v.primary_email_address_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx(mt,{children:j.id!==(v==null?void 0:v.primary_email_address_id)||!j.verified?e.jsxs(nt,{open:o===j.id,openChange:M=>n(M?j.id:null),children:[e.jsx(at,{children:e.jsx(cn,{ref:M=>{M&&(x.current[j.id]=M)},children:"•••"})}),e.jsxs(st,{children:[j.id!==(v==null?void 0:v.primary_email_address_id)&&j.verified&&e.jsx(Te,{onClick:async()=>{try{await E(j.id),v.refetch(),n(null),r("Primary email updated successfully","info")}catch(M){r(M.message||"Failed to update primary email","error")}},children:"Make primary"}),!j.verified&&e.jsx(Te,{onClick:async()=>{n(null),await S(j.id),h(j.id)},children:"Verify email"}),j.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Te,{$destructive:!0,onClick:()=>{I(j.id),n(null)},children:"Remove"})]})]}):null})]},j.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(vi,{existingEmail:(k=($=v==null?void 0:v.user_email_addresses)==null?void 0:$.find(j=>j.id===c))==null?void 0:k.email,triggerRef:{current:x.current[c]},onClose:()=>h(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await S(c),v.refetch()},onAttemptVerification:async j=>{await _(c,j),v.refetch(),h(null),r("Email verified successfully!","info")}})]})},Cv=()=>{var w,b,f,$;const{deployment:t}=ve(),[r,o]=i.useState(null),[n,s]=i.useState(""),[a,p]=i.useState(!1),[g,c]=i.useState(null),[h,l]=i.useState(""),u=i.useRef(null),m=i.useRef({}),{user:x,createPhoneNumber:v,deletePhoneNumber:y,preparePhoneVerification:z,attemptPhoneVerification:S,makePhonePrimary:_}=nr();if(!((b=(w=t==null?void 0:t.auth_settings)==null?void 0:w.phone_number)!=null&&b.enabled))return null;const E=k=>{const j=Oo.find(M=>M.dialCode===k);return(j==null?void 0:j.flag)||"🌍"},I=i.useMemo(()=>x!=null&&x.user_phone_numbers?h.trim()?x.user_phone_numbers.filter(k=>k.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(Ho,{style:{marginBottom:"20px"},children:[e.jsx(St,{value:h,onChange:l,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:u,onClick:()=>p(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),a&&e.jsx(wi,{triggerRef:u,onClose:()=>p(!1),onAddPhone:async(k,j)=>{const M=await v(k,j);s(M.data.id),await z(M.data.id)},onPrepareVerification:async()=>{await z(n),x.refetch()},onAttemptVerification:async k=>{await S(n,k),x.refetch(),p(!1)}}),g&&e.jsx(wi,{existingPhone:($=(f=x==null?void 0:x.user_phone_numbers)==null?void 0:f.find(k=>k.id===g))==null?void 0:$.phone_number,triggerRef:{current:m.current[g]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await z(g),x.refetch()},onAttemptVerification:async k=>{await S(g,k),x.refetch(),c(null)}})]})]}),I!=null&&I.length?e.jsxs(ht,{children:[e.jsx(ft,{children:e.jsxs(Ne,{children:[e.jsx(Ce,{children:"Phone Number"}),e.jsx(Ce,{children:"Status"}),e.jsx(Ce,{})]})}),e.jsx(gt,{children:I.map(k=>e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:E(k.country_code)}),e.jsx("span",{children:k.country_code}),e.jsx("span",{children:k.phone_number})]})}),e.jsx(Me,{children:k.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":k.verified?"Verified":"Not Verified"}),e.jsx(mt,{children:e.jsxs(nt,{open:r===k.id,openChange:j=>o(j?k.id:null),children:[e.jsx(at,{children:e.jsx(cn,{ref:j=>{j&&(m.current[k.id]=j)},children:"•••"})}),e.jsxs(st,{children:[k.id!==(x==null?void 0:x.primary_phone_number_id)&&k.verified&&e.jsx(Te,{onClick:async()=>{await _(k.id),o(null),x.refetch()},children:"Make primary"}),!k.verified&&e.jsx(Te,{onClick:async()=>{await z(k.id),c(k.id),o(null)},children:"Verify phone"}),e.jsx(Te,{$destructive:!0,onClick:async()=>{await y(k.id),o(null),x.refetch()},children:"Remove"})]})]})})]},k.id))})]}):e.jsx(it,{title:h?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},od=d.div`
4114
4114
  width: 20px;
4115
4115
  height: 20px;
4116
4116
  flex-shrink: 0;
@@ -4125,9 +4125,9 @@ cursor: pointer;
4125
4125
  flex-shrink: 0;
4126
4126
  display: block;
4127
4127
  }
4128
- `,Sv=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=sr(),{deployment:n}=ve(),s={google_oauth:{icon:e.jsx(nl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(ol,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(rl,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(il,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(al,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(cl,{}),label:"Discord"},x_oauth:{icon:e.jsx(sl,{}),label:"X"}},a=(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:a.map((p,g)=>{var l;const c=((l=t==null?void 0:t.social_connections)==null?void 0:l.filter(u=>u.provider===p.provider))||[],h=s[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(sd,{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(u=>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:u.email_address}),e.jsx(cn,{onClick:async()=>{await r(u.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(et,{size:14})})]},u.id)),c.length>0?e.jsx(X,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(X,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),g<a.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},ad=()=>{var x,y,$,S,k,I,E;const{loading:t}=sr(),{deployment:r}=ve(),[o,n]=i.useState("profile"),[s,a]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((w,b="info")=>{a(w),g(b),setTimeout(()=>a(null),3e3)},[a]);if(t)return e.jsx(ge,{children:e.jsx(zi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})})});const h=r==null?void 0:r.auth_settings,l=(x=h==null?void 0:h.email_address)==null?void 0:x.enabled,u=(y=h==null?void 0:h.phone_number)==null?void 0:y.enabled,m=(($=r==null?void 0:r.social_connections)==null?void 0:$.some(w=>w.enabled))||!1,v=((S=h==null?void 0:h.password)==null?void 0:S.enabled)||((k=h==null?void 0:h.auth_factors_enabled)==null?void 0:k.authenticator)||((I=h==null?void 0:h.auth_factors_enabled)==null?void 0:I.phone_otp)||((E=h==null?void 0:h.auth_factors_enabled)==null?void 0:E.backup_code);return e.jsx(ge,{children:e.jsx(xv,{children:e.jsx(nd.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(zi,{children:[e.jsx(vv,{children:e.jsxs(bv,{children:[e.jsx(mr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(xr,{children:[e.jsx(Bo,{size:16}),"Profile"]})}),l&&e.jsx(mr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(xr,{children:[e.jsx(on,{size:16}),"Email"]})}),u&&e.jsx(mr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(xr,{children:[e.jsx(yh,{size:16}),"Phone"]})}),m&&e.jsx(mr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(xr,{children:[e.jsx(dh,{size:16}),"Connections"]})}),v&&e.jsx(mr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(xr,{children:[e.jsx(Qe,{size:16}),"Security"]})}),e.jsx(mr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(xr,{children:[e.jsx(Dp,{size:16}),"Sessions"]})})]})}),e.jsxs(yv,{children:[o==="profile"&&e.jsx($v,{}),o==="email"&&l&&e.jsx(kv,{}),o==="phone"&&u&&e.jsx(Cv,{}),o==="social"&&m&&e.jsx(Sv,{}),o==="security"&&v&&e.jsx(zv,{}),o==="sessions"&&e.jsx(_v,{})]}),s&&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(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})})},zv=()=>{var D,Z,ae;const{deployment:t}=ve(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:s,verifyAuthenticator:a,deleteAuthenticator:p,generateBackupCodes:g,regenerateBackupCodes:c,updateProfile:h}=sr(),{toast:l}=Mt(),[u,m]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[v,x]=i.useState(!1),y=async te=>{try{await h({second_factor_policy:te}),m(te),l("2FA requirement updated successfully","info")}catch(_e){l(_e.message||"Failed to update 2FA requirement","error")}},[$,S]=i.useState(!1),[k,I]=i.useState(!1),[E,w]=i.useState(!1),[b,f]=i.useState(!1),z=i.useRef(null),_=i.useRef(null),j=i.useRef(null),M=i.useRef(null),[R,C]=i.useState("table"),[P,T]=i.useState(""),[B,L]=i.useState(""),[F,O]=i.useState(""),[A,J]=i.useState(["",""]),[re,V]=i.useState([]),[q,H]=i.useState(!1),[ee,le]=i.useState(!1),[oe]=i.useState(!1),[de,K]=i.useState(!1),se=(D=t==null?void 0:t.auth_settings)==null?void 0:D.auth_factors_enabled,xe=(ae=(Z=t==null?void 0:t.auth_settings)==null?void 0:Z.password)==null?void 0:ae.enabled;if(!(se!=null&&se.authenticator)&&!(se!=null&&se.backup_code)&&!xe)return null;const ue=async(te,_e)=>{await o(te,_e),await r.refetch(),l("Password updated successfully","info")},U=async te=>{await n(te),await r.refetch(),l("Password removed successfully","info")},pe=()=>{var Re,ir,cr,Zr,Ns,Fs;if(!r)return!1;const te=(Re=r.user_email_addresses)==null?void 0:Re.some(Er=>Er.verified),_e=(ir=r.user_phone_numbers)==null?void 0:ir.some(Er=>Er.verified),be=r.social_connections&&r.social_connections.length>0,ze=t==null?void 0:t.auth_settings;return(ze==null?void 0:ze.first_factor)==="email_otp"&&te||((cr=ze==null?void 0:ze.magic_link)==null?void 0:cr.enabled)&&te||((Zr=ze==null?void 0:ze.passkey)==null?void 0:Zr.enabled)||((Ns=ze==null?void 0:ze.auth_factors_enabled)==null?void 0:Ns.phone_otp)&&_e||be&&((Fs=t==null?void 0:t.social_connections)==null?void 0:Fs.some(Er=>Er.enabled))},Q=async()=>{if(A.some(te=>te.length!==6)){l("Please enter both 6-digit verification codes","error");return}try{if(le(!0),await a(F,A),await r.refetch(),se!=null&&se.backup_code){const te=await g();V(te),await r.refetch(),C("backup")}else C("success")}catch(te){l(te.message||"Invalid verification codes","error")}finally{le(!1)}},Y=()=>{C("table"),T(""),L(""),O(""),J(["",""]),V([]),l("Two-factor authentication setup completed successfully!","info")},ne=async()=>{var te;if((te=r==null?void 0:r.user_authenticator)!=null&&te.id)try{K(!0),await p(r.user_authenticator.id),await r.refetch(),x(!1),l("Two-factor authentication removed successfully","info")}catch(_e){l(_e.message||"Failed to remove authenticator","error")}finally{K(!1)}},me=async()=>{if(!q)try{H(!0);const te=await c();V(te),await r.refetch(),f(!0),l("New backup codes generated","info")}catch(te){l(te.message||"Failed to generate backup codes","error")}finally{H(!1)}},fe=()=>{const te=re.join(`
4128
+ `,Sv=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=nr(),{deployment:n}=ve(),s={google_oauth:{icon:e.jsx(nl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(ol,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(rl,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(il,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(al,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(cl,{}),label:"Discord"},x_oauth:{icon:e.jsx(sl,{}),label:"X"}},a=(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:a.map((p,g)=>{var l;const c=((l=t==null?void 0:t.social_connections)==null?void 0:l.filter(u=>u.provider===p.provider))||[],h=s[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(od,{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(u=>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:u.email_address}),e.jsx(cn,{onClick:async()=>{await r(u.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(et,{size:14})})]},u.id)),c.length>0?e.jsx(X,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(X,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),g<a.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},nd=()=>{var v,y,z,S,_,E,I;const{loading:t}=nr(),{deployment:r}=ve(),[o,n]=i.useState("profile"),[s,a]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((w,b="info")=>{a(w),g(b),setTimeout(()=>a(null),3e3)},[a]);if(t)return e.jsx(ge,{children:e.jsx(zi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})})});const h=r==null?void 0:r.auth_settings,l=(v=h==null?void 0:h.email_address)==null?void 0:v.enabled,u=(y=h==null?void 0:h.phone_number)==null?void 0:y.enabled,m=((z=r==null?void 0:r.social_connections)==null?void 0:z.some(w=>w.enabled))||!1,x=((S=h==null?void 0:h.password)==null?void 0:S.enabled)||((_=h==null?void 0:h.auth_factors_enabled)==null?void 0:_.authenticator)||((E=h==null?void 0:h.auth_factors_enabled)==null?void 0:E.phone_otp)||((I=h==null?void 0:h.auth_factors_enabled)==null?void 0:I.backup_code);return e.jsx(ge,{children:e.jsx(xv,{children:e.jsx(rd.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(zi,{children:[e.jsx(vv,{children:e.jsxs(bv,{children:[e.jsx(mr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(xr,{children:[e.jsx(Bo,{size:16}),"Profile"]})}),l&&e.jsx(mr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(xr,{children:[e.jsx(on,{size:16}),"Email"]})}),u&&e.jsx(mr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(xr,{children:[e.jsx(vh,{size:16}),"Phone"]})}),m&&e.jsx(mr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(xr,{children:[e.jsx(ch,{size:16}),"Connections"]})}),x&&e.jsx(mr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(xr,{children:[e.jsx(Xe,{size:16}),"Security"]})}),e.jsx(mr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(xr,{children:[e.jsx(Ap,{size:16}),"Sessions"]})})]})}),e.jsxs(yv,{children:[o==="profile"&&e.jsx($v,{}),o==="email"&&l&&e.jsx(kv,{}),o==="phone"&&u&&e.jsx(Cv,{}),o==="social"&&m&&e.jsx(Sv,{}),o==="security"&&x&&e.jsx(zv,{}),o==="sessions"&&e.jsx(_v,{})]}),s&&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(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})})},zv=()=>{var D,Z,ae;const{deployment:t}=ve(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:s,verifyAuthenticator:a,deleteAuthenticator:p,generateBackupCodes:g,regenerateBackupCodes:c,updateProfile:h}=nr(),{toast:l}=Mt(),[u,m]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[x,v]=i.useState(!1),y=async te=>{try{await h({second_factor_policy:te}),m(te),l("2FA requirement updated successfully","info")}catch(_e){l(_e.message||"Failed to update 2FA requirement","error")}},[z,S]=i.useState(!1),[_,E]=i.useState(!1),[I,w]=i.useState(!1),[b,f]=i.useState(!1),$=i.useRef(null),k=i.useRef(null),j=i.useRef(null),M=i.useRef(null),[R,C]=i.useState("table"),[P,T]=i.useState(""),[B,L]=i.useState(""),[F,O]=i.useState(""),[A,J]=i.useState(["",""]),[re,V]=i.useState([]),[q,H]=i.useState(!1),[ee,le]=i.useState(!1),[oe]=i.useState(!1),[de,K]=i.useState(!1),se=(D=t==null?void 0:t.auth_settings)==null?void 0:D.auth_factors_enabled,xe=(ae=(Z=t==null?void 0:t.auth_settings)==null?void 0:Z.password)==null?void 0:ae.enabled;if(!(se!=null&&se.authenticator)&&!(se!=null&&se.backup_code)&&!xe)return null;const ue=async(te,_e)=>{await o(te,_e),await r.refetch(),l("Password updated successfully","info")},U=async te=>{await n(te),await r.refetch(),l("Password removed successfully","info")},pe=()=>{var Re,ar,ir,Zr,Ns,Fs;if(!r)return!1;const te=(Re=r.user_email_addresses)==null?void 0:Re.some(Er=>Er.verified),_e=(ar=r.user_phone_numbers)==null?void 0:ar.some(Er=>Er.verified),be=r.social_connections&&r.social_connections.length>0,ze=t==null?void 0:t.auth_settings;return(ze==null?void 0:ze.first_factor)==="email_otp"&&te||((ir=ze==null?void 0:ze.magic_link)==null?void 0:ir.enabled)&&te||((Zr=ze==null?void 0:ze.passkey)==null?void 0:Zr.enabled)||((Ns=ze==null?void 0:ze.auth_factors_enabled)==null?void 0:Ns.phone_otp)&&_e||be&&((Fs=t==null?void 0:t.social_connections)==null?void 0:Fs.some(Er=>Er.enabled))},Q=async()=>{if(A.some(te=>te.length!==6)){l("Please enter both 6-digit verification codes","error");return}try{if(le(!0),await a(F,A),await r.refetch(),se!=null&&se.backup_code){const te=await g();V(te),await r.refetch(),C("backup")}else C("success")}catch(te){l(te.message||"Invalid verification codes","error")}finally{le(!1)}},Y=()=>{C("table"),T(""),L(""),O(""),J(["",""]),V([]),l("Two-factor authentication setup completed successfully!","info")},ne=async()=>{var te;if((te=r==null?void 0:r.user_authenticator)!=null&&te.id)try{K(!0),await p(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)}},me=async()=>{if(!q)try{H(!0);const te=await c();V(te),await r.refetch(),f(!0),l("New backup codes generated","info")}catch(te){l(te.message||"Failed to generate backup codes","error")}finally{H(!1)}},fe=()=>{const te=re.join(`
4129
4129
  `);navigator.clipboard.writeText(te).then(()=>{l("Backup codes copied to clipboard","info")}).catch(()=>{l("Failed to copy backup codes","error")})},W=()=>{const te=re.join(`
4130
- `),_e=new Blob([te],{type:"text/plain"}),be=URL.createObjectURL(_e),ze=document.createElement("a");ze.href=be,ze.download="wacht-backup-codes.txt",ze.click(),URL.revokeObjectURL(be),l("Backup codes downloaded","info")},N=[];return xe&&N.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&&N.push({id:"authenticator",name:"Authenticator App",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&&N.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&&N.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:u==="enforced"?"Enforced":"Optional",actions:["toggle"]}),R!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Qe,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[R==="qr"&&"Setup Two-Factor Authentication",R==="verify"&&"Verify Your Authenticator",R==="backup"&&"Save Your Backup Codes",R==="success"&&"Setup Complete!"]})]}),e.jsx(X,{onClick:()=>C("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:[R==="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:`${mv} 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(Ls,{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:B||"Loading..."})]}),e.jsx(X,{onClick:()=>C("verify"),disabled:!P||!B,style:{padding:"10px 20px",background:!P||!B?"var(--color-border)":"var(--color-primary)",color:!P||!B?"var(--color-secondary-text)":"white",border:`1px solid ${!P||!B?"var(--color-border)":"var(--color-primary)"}`,cursor:!P||!B?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),R==="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(ce,{type:"text",placeholder:"000000",value:A[0],onChange:te=>{const _e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);J([_e,A[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(ce,{type:"text",placeholder:"000000",value:A[1],onChange:te=>{const _e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);J([A[0],_e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(X,{onClick:()=>C("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(X,{onClick:Q,disabled:ee||A.some(te=>te.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:ee?"Verifying...":"Verify & Continue"})]})]}),R==="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(X,{onClick:fe,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(X,{onClick:W,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(rn,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(X,{onClick:Y,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),R==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(Ve,{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(X,{onClick:Y,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(Ho,{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"})})}),N.length?e.jsx("div",{children:N.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(X,{ref:_,onClick:()=>I(!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"}),k&&e.jsx(Ci,{triggerRef:_,onClose:()=>I(!1),onChangePassword:ue})]}),pe()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:j,onClick:()=>w(!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&&e.jsx(rv,{triggerRef:j,onClose:()=>w(!1),onRemovePassword:U})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:_,onClick:()=>I(!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"}),k&&e.jsx(Ci,{triggerRef:_,onClose:()=>I(!1),onChangePassword:ue,isSetup:!0})]})}),te.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:z,onClick:()=>S(!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(q0,{triggerRef:z,onClose:()=>S(!1),onSetupTOTP:async()=>{const be=await s();return O(be.id),be},onVerifyTOTP:async be=>{await a(F,be),await r.refetch(),l("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(X,{onClick:()=>x(!0),disabled:de,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:de?"not-allowed":"pointer",opacity:de?.6:1},children:de?"Removing...":"Remove"}),v&&e.jsx(Yr,{title:"Remove MFA and reset policy to default?",onConfirm:ne,onCancel:()=>x(!1)})]}),te.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:M,onClick:me,disabled:q,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:q?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),b&&e.jsx(lv,{triggerRef:M,codes:re,onClose:()=>f(!1),onCopy:fe,onDownload:W})]})}),te.id==="second_factor_policy"&&e.jsx(Cr,{checked:u==="enforced",onChange:be=>{y(be?"enforced":"none")}})]})]})]}),_e<N.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."})]})},$v=()=>{var L,F;const{deployment:t}=ve(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:s}=sr(),{toast:a}=Mt(),[p,g]=i.useState(""),[c,h]=i.useState(""),[l,u]=i.useState(""),[m,v]=i.useState(!1),[x,y]=i.useState(!1),[$,S]=i.useState(!1),[k,I]=i.useState(""),[E,w]=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||""),u(r.username||""),w(r.profile_picture_url||null),v(!0))},[r,m]);const f=i.useCallback(async()=>{if(r)try{const O={};p!==r.first_name&&(O.first_name=p),c!==r.last_name&&(O.last_name=c),l!==r.username&&(O.username=l),Object.keys(O).length>0&&await o(O)}catch(O){a(O.message||"Failed to save profile changes","error")}},[r,o,p,c,l,a]),z=O=>{g(O.target.value)},_=O=>{h(O.target.value)},j=O=>{u(O.target.value)},M=()=>{f()},R=()=>{f()},C=()=>{f()},P=O=>{var A;if((A=O.target.files)!=null&&A[0]){const J=O.target.files[0];w(URL.createObjectURL(J)),setTimeout(async()=>{try{await n(J),r.refetch(),a("Profile picture updated successfully","info")}catch(re){a(re.message||"Failed to update profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},100)}},T=()=>{b.current&&b.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const B=async()=>{if(!(!r||k!==r.username)){S(!0);try{await s(""),a("Account deleted successfully","info")}catch(O){a(O.message||"Failed to delete account","error")}finally{S(!1),I(""),y(!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:E?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:T,onMouseEnter:O=>{O.currentTarget.style.borderColor="var(--color-primary)",O.currentTarget.style.transform="scale(1.02)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--color-border)",O.currentTarget.style.transform="scale(1)"},children:[E?e.jsx("img",{src:E,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Bo,{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(X,{onClick:()=>{var O;return(O=b.current)==null?void 0:O.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(rn,{size:14}),E?"Change":"Upload"]}),e.jsxs(X,{onClick:async()=>{w(null),b.current&&(b.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),a("Profile picture removed successfully","info")}catch(O){a(O.message||"Failed to remove profile picture","error"),w((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(ie,{htmlFor:"firstName",children:"First Name"}),e.jsx(ce,{id:"firstName",type:"text",value:p,onChange:z,onBlur:M,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ce,{id:"lastName",type:"text",value:c,onChange:_,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((F=(L=t==null?void 0:t.auth_settings)==null?void 0:L.username)==null?void 0:F.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(ce,{id:"username",type:"text",value:l,onChange:j,onBlur:C,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:x?"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(X,{onClick:()=>{x?(y(!1),I("")):y(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:x?"Cancel":"Delete"})]}),x&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(ce,{id:"confirm_username",type:"text",value:k,onChange:O=>I(O.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(X,{onClick:B,disabled:k!==(r==null?void 0:r.username)||$,style:{background:k===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:k===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:k===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:k===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:$?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})})},id=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:p,children:g,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),p||g||e.jsx(ad,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Ev=d.div`
4130
+ `),_e=new Blob([te],{type:"text/plain"}),be=URL.createObjectURL(_e),ze=document.createElement("a");ze.href=be,ze.download="wacht-backup-codes.txt",ze.click(),URL.revokeObjectURL(be),l("Backup codes downloaded","info")},N=[];return xe&&N.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&&N.push({id:"authenticator",name:"Authenticator App",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&&N.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&&N.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:u==="enforced"?"Enforced":"Optional",actions:["toggle"]}),R!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Ho,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Xe,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[R==="qr"&&"Setup Two-Factor Authentication",R==="verify"&&"Verify Your Authenticator",R==="backup"&&"Save Your Backup Codes",R==="success"&&"Setup Complete!"]})]}),e.jsx(X,{onClick:()=>C("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:[R==="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:`${mv} 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(Ls,{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:B||"Loading..."})]}),e.jsx(X,{onClick:()=>C("verify"),disabled:!P||!B,style:{padding:"10px 20px",background:!P||!B?"var(--color-border)":"var(--color-primary)",color:!P||!B?"var(--color-secondary-text)":"white",border:`1px solid ${!P||!B?"var(--color-border)":"var(--color-primary)"}`,cursor:!P||!B?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),R==="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(ce,{type:"text",placeholder:"000000",value:A[0],onChange:te=>{const _e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);J([_e,A[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(ce,{type:"text",placeholder:"000000",value:A[1],onChange:te=>{const _e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);J([A[0],_e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(X,{onClick:()=>C("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(X,{onClick:Q,disabled:ee||A.some(te=>te.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:ee?"Verifying...":"Verify & Continue"})]})]}),R==="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(X,{onClick:fe,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(X,{onClick:W,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(rn,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(X,{onClick:Y,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),R==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(Ve,{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(X,{onClick:Y,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(Ho,{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"})})}),N.length?e.jsx("div",{children:N.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(X,{ref:k,onClick:()=>E(!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"}),_&&e.jsx(Ci,{triggerRef:k,onClose:()=>E(!1),onChangePassword:ue})]}),pe()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:j,onClick:()=>w(!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"}),I&&e.jsx(rv,{triggerRef:j,onClose:()=>w(!1),onRemovePassword:U})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:k,onClick:()=>E(!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"}),_&&e.jsx(Ci,{triggerRef:k,onClose:()=>E(!1),onChangePassword:ue,isSetup:!0})]})}),te.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:$,onClick:()=>S(!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"}),z&&e.jsx(q0,{triggerRef:$,onClose:()=>S(!1),onSetupTOTP:async()=>{const be=await s();return O(be.id),be},onVerifyTOTP:async be=>{await a(F,be),await r.refetch(),l("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(X,{onClick:()=>v(!0),disabled:de,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:de?"not-allowed":"pointer",opacity:de?.6:1},children:de?"Removing...":"Remove"}),x&&e.jsx(Yr,{title:"Remove MFA and reset policy to default?",onConfirm:ne,onCancel:()=>v(!1)})]}),te.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(X,{ref:M,onClick:me,disabled:q,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:q?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),b&&e.jsx(lv,{triggerRef:M,codes:re,onClose:()=>f(!1),onCopy:fe,onDownload:W})]})}),te.id==="second_factor_policy"&&e.jsx(Cr,{checked:u==="enforced",onChange:be=>{y(be?"enforced":"none")}})]})]})]}),_e<N.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."})]})},$v=()=>{var L,F;const{deployment:t}=ve(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:s}=nr(),{toast:a}=Mt(),[p,g]=i.useState(""),[c,h]=i.useState(""),[l,u]=i.useState(""),[m,x]=i.useState(!1),[v,y]=i.useState(!1),[z,S]=i.useState(!1),[_,E]=i.useState(""),[I,w]=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||""),u(r.username||""),w(r.profile_picture_url||null),x(!0))},[r,m]);const f=i.useCallback(async()=>{if(r)try{const O={};p!==r.first_name&&(O.first_name=p),c!==r.last_name&&(O.last_name=c),l!==r.username&&(O.username=l),Object.keys(O).length>0&&await o(O)}catch(O){a(O.message||"Failed to save profile changes","error")}},[r,o,p,c,l,a]),$=O=>{g(O.target.value)},k=O=>{h(O.target.value)},j=O=>{u(O.target.value)},M=()=>{f()},R=()=>{f()},C=()=>{f()},P=O=>{var A;if((A=O.target.files)!=null&&A[0]){const J=O.target.files[0];w(URL.createObjectURL(J)),setTimeout(async()=>{try{await n(J),r.refetch(),a("Profile picture updated successfully","info")}catch(re){a(re.message||"Failed to update profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},100)}},T=()=>{b.current&&b.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const B=async()=>{if(!(!r||_!==r.username)){S(!0);try{await s(""),a("Account deleted successfully","info")}catch(O){a(O.message||"Failed to delete account","error")}finally{S(!1),E(""),y(!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:I?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:T,onMouseEnter:O=>{O.currentTarget.style.borderColor="var(--color-primary)",O.currentTarget.style.transform="scale(1.02)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--color-border)",O.currentTarget.style.transform="scale(1)"},children:[I?e.jsx("img",{src:I,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Bo,{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(X,{onClick:()=>{var O;return(O=b.current)==null?void 0:O.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(rn,{size:14}),I?"Change":"Upload"]}),e.jsxs(X,{onClick:async()=>{w(null),b.current&&(b.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),a("Profile picture removed successfully","info")}catch(O){a(O.message||"Failed to remove profile picture","error"),w((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(ie,{htmlFor:"firstName",children:"First Name"}),e.jsx(ce,{id:"firstName",type:"text",value:p,onChange:$,onBlur:M,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ie,{htmlFor:"lastName",children:"Last Name"}),e.jsx(ce,{id:"lastName",type:"text",value:c,onChange:k,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((F=(L=t==null?void 0:t.auth_settings)==null?void 0:L.username)==null?void 0:F.enabled)&&e.jsxs(he,{children:[e.jsx(ie,{htmlFor:"username",children:"Username"}),e.jsx(ce,{id:"username",type:"text",value:l,onChange:j,onBlur:C,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(X,{onClick:()=>{v?(y(!1),E("")):y(!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(ie,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(ce,{id:"confirm_username",type:"text",value:_,onChange:O=>E(O.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(X,{onClick:B,disabled:_!==(r==null?void 0:r.username)||z,style:{background:_===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:_===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:_===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:_===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:z?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})})},sd=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:s,footerContent:a,customContent:p,children:g,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:s||o}),p||g||e.jsx(nd,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Ev=d.div`
4131
4131
  position: relative;
4132
4132
  `,Iv=d.button`
4133
4133
  display: flex;
@@ -4140,7 +4140,7 @@ cursor: pointer;
4140
4140
  transition: background-color 0.2s ease;
4141
4141
  `,Yn=d.div`
4142
4142
  position: relative;
4143
- `,cd=d.div`
4143
+ `,ad=d.div`
4144
4144
  width: 36px;
4145
4145
  height: 36px;
4146
4146
  border-radius: 50%;
@@ -4211,7 +4211,7 @@ cursor: pointer;
4211
4211
  display: flex;
4212
4212
  align-items: center;
4213
4213
  justify-content: space-between;
4214
- `,Mi=d(cd)`
4214
+ `,Mi=d(ad)`
4215
4215
  width: 40px;
4216
4216
  height: 40px;
4217
4217
  `,Oi=d.div`
@@ -4266,7 +4266,7 @@ cursor: pointer;
4266
4266
  width: 14px;
4267
4267
  height: 14px;
4268
4268
  }
4269
- `,Ds=({showName:t=!0})=>{var b,f,z,_;const[r,o]=i.useState(!1),n=i.useRef(null),s=i.useRef(null),a=Fl({triggerRef:n,isOpen:r,minWidth:380}),p=Dr(!1),{session:g,signOut:c,switchSignIn:h,refetch:l}=Ue(),{navigateToSignIn:u}=Ge(),{deployment:m}=ve(),v=(b=g==null?void 0:g.active_signin)==null?void 0:b.user,x=((z=(f=m==null?void 0:m.auth_settings)==null?void 0:f.multi_session_support)==null?void 0:z.enabled)??!1,y=(((_=g==null?void 0:g.signins)==null?void 0:_.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const M=R=>{var P,T;const C=R.target;(P=n.current)!=null&&P.contains(C)||(T=s.current)!=null&&T.contains(C)||o(!1)};return document.addEventListener("mousedown",M),()=>{document.removeEventListener("mousedown",M)}},50);return()=>{clearTimeout(j)}},[r]);const $=()=>{o(!r)},S=j=>j.split(" ").map(M=>M[0]).join("").toUpperCase(),k=async j=>{try{await c(j),await l(),o(!1)}catch{}},I=async()=>{try{await c(),await l(),o(!1)}catch{}},E=async j=>{try{await h(j),await l(),o(!1)}catch{}},w=()=>{p.open(),o(!1)};return e.jsx(ge,{children:e.jsxs(Ev,{children:[e.jsxs(Iv,{ref:n,onClick:$,children:[e.jsx(Yn,{children:e.jsx(cd,{children:v!=null&&v.has_profile_picture?e.jsx("img",{src:v.profile_picture_url,alt:v.first_name}):S(`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`)})}),t&&e.jsx(Pv,{children:`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`})]}),typeof window<"u"&&r&&Wr.createPortal(e.jsx(ge,{children:e.jsx(Rv,{ref:s,$position:a,$isOpen:r,$maxHeight:a==null?void 0:a.maxHeight,children:e.jsxs("div",{children:[x?(()=>{const j=[...(g==null?void 0:g.signins)||[]].sort((M,R)=>{const C=M.user.id===(v==null?void 0:v.id),P=R.user.id===(v==null?void 0:v.id);return C&&!P?-1:!C&&P?1:0});return j.map(({user:M,id:R},C)=>{const P=M.id===(v==null?void 0:v.id),T=!P;return e.jsxs(i.Fragment,{children:[e.jsxs(Ii,{$isClickable:T,onClick:T?()=>E(R):void 0,children:[e.jsxs(Pi,{children:[e.jsx(Yn,{children:e.jsx(Mi,{children:M.has_profile_picture?e.jsx("img",{src:M.profile_picture_url,alt:M.first_name}):S(`${(M==null?void 0:M.first_name)||""} ${(M==null?void 0:M.last_name)||""}`)})}),e.jsxs(Ri,{children:[e.jsx(Ti,{children:e.jsx($i,{children:`${(M==null?void 0:M.first_name)||""} ${(M==null?void 0:M.last_name)||""}`})}),e.jsx(Ei,{children:M.primary_email_address.email})]})]}),P&&e.jsxs(Oi,{children:[e.jsxs($o,{onClick:w,children:[e.jsx(er,{}),"Manage account"]}),e.jsxs($o,{$destructive:!0,onClick:()=>k(R),children:[e.jsx(Et,{}),"Sign out"]})]})]}),C===0&&j.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},M.id)})})():v&&e.jsxs(Ii,{$isClickable:!1,children:[e.jsxs(Pi,{children:[e.jsx(Yn,{children:e.jsx(Mi,{children:v.has_profile_picture?e.jsx("img",{src:v.profile_picture_url,alt:v.first_name}):S(`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`)})}),e.jsxs(Ri,{children:[e.jsx(Ti,{children:e.jsx($i,{children:`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`})}),e.jsx(Ei,{children:v.primary_email_address.email})]})]}),e.jsxs(Oi,{children:[e.jsxs($o,{onClick:w,children:[e.jsx(er,{}),"Manage account"]}),e.jsxs($o,{$destructive:!0,onClick:()=>{var j;return k(((j=g==null?void 0:g.active_signin)==null?void 0:j.id)||"")},children:[e.jsx(Et,{}),"Sign out"]})]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsx(Ai,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(Li,{onClick:()=>u(),children:[e.jsx(Ke,{}),"Add new account"]})}),y&&e.jsx(Ai,{children:e.jsxs(Li,{onClick:I,children:[e.jsx(Et,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(id,{isOpen:p.isOpen,onClose:p.close})]})})},Tv=d.div`
4269
+ `,Ds=({showName:t=!0})=>{var b,f,$,k;const[r,o]=i.useState(!1),n=i.useRef(null),s=i.useRef(null),a=Dl({triggerRef:n,isOpen:r,minWidth:380}),p=Dr(!1),{session:g,signOut:c,switchSignIn:h,refetch:l}=Ue(),{navigateToSignIn:u}=Ge(),{deployment:m}=ve(),x=(b=g==null?void 0:g.active_signin)==null?void 0:b.user,v=(($=(f=m==null?void 0:m.auth_settings)==null?void 0:f.multi_session_support)==null?void 0:$.enabled)??!1,y=(((k=g==null?void 0:g.signins)==null?void 0:k.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const M=R=>{var P,T;const C=R.target;(P=n.current)!=null&&P.contains(C)||(T=s.current)!=null&&T.contains(C)||o(!1)};return document.addEventListener("mousedown",M),()=>{document.removeEventListener("mousedown",M)}},50);return()=>{clearTimeout(j)}},[r]);const z=()=>{o(!r)},S=j=>j.split(" ").map(M=>M[0]).join("").toUpperCase(),_=async j=>{try{await c(j),await l(),o(!1)}catch{}},E=async()=>{try{await c(),await l(),o(!1)}catch{}},I=async j=>{try{await h(j),await l(),o(!1)}catch{}},w=()=>{p.open(),o(!1)};return e.jsx(ge,{children:e.jsxs(Ev,{children:[e.jsxs(Iv,{ref:n,onClick:z,children:[e.jsx(Yn,{children:e.jsx(ad,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):S(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(Pv,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&Wr.createPortal(e.jsx(ge,{children:e.jsx(Rv,{ref:s,$position:a,$isOpen:r,$maxHeight:a==null?void 0:a.maxHeight,children:e.jsxs("div",{children:[v?(()=>{const j=[...(g==null?void 0:g.signins)||[]].sort((M,R)=>{const C=M.user.id===(x==null?void 0:x.id),P=R.user.id===(x==null?void 0:x.id);return C&&!P?-1:!C&&P?1:0});return j.map(({user:M,id:R},C)=>{const P=M.id===(x==null?void 0:x.id),T=!P;return e.jsxs(i.Fragment,{children:[e.jsxs(Ii,{$isClickable:T,onClick:T?()=>I(R):void 0,children:[e.jsxs(Pi,{children:[e.jsx(Yn,{children:e.jsx(Mi,{children:M.has_profile_picture?e.jsx("img",{src:M.profile_picture_url,alt:M.first_name}):S(`${(M==null?void 0:M.first_name)||""} ${(M==null?void 0:M.last_name)||""}`)})}),e.jsxs(Ri,{children:[e.jsx(Ti,{children:e.jsx($i,{children:`${(M==null?void 0:M.first_name)||""} ${(M==null?void 0:M.last_name)||""}`})}),e.jsx(Ei,{children:M.primary_email_address.email})]})]}),P&&e.jsxs(Oi,{children:[e.jsxs($o,{onClick:w,children:[e.jsx(Jt,{}),"Manage account"]}),e.jsxs($o,{$destructive:!0,onClick:()=>_(R),children:[e.jsx(Et,{}),"Sign out"]})]})]}),C===0&&j.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},M.id)})})():x&&e.jsxs(Ii,{$isClickable:!1,children:[e.jsxs(Pi,{children:[e.jsx(Yn,{children:e.jsx(Mi,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):S(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(Ri,{children:[e.jsx(Ti,{children:e.jsx($i,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(Ei,{children:x.primary_email_address.email})]})]}),e.jsxs(Oi,{children:[e.jsxs($o,{onClick:w,children:[e.jsx(Jt,{}),"Manage account"]}),e.jsxs($o,{$destructive:!0,onClick:()=>{var j;return _(((j=g==null?void 0:g.active_signin)==null?void 0:j.id)||"")},children:[e.jsx(Et,{}),"Sign out"]})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(Ai,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(Li,{onClick:()=>u(),children:[e.jsx(Ke,{}),"Add new account"]})}),y&&e.jsx(Ai,{children:e.jsxs(Li,{onClick:E,children:[e.jsx(Et,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(sd,{isOpen:p.isOpen,onClose:p.close})]})})},Tv=d.div`
4270
4270
  padding: var(--space-md) var(--space-lg);
4271
4271
  background: ${t=>t.$unread?"var(--color-background-hover)":"transparent"};
4272
4272
  transition: all 0.2s ease;
@@ -4375,7 +4375,7 @@ cursor: pointer;
4375
4375
  width: 12px;
4376
4376
  height: 12px;
4377
4377
  }
4378
- `;function ld({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},s=a=>{const p=new Date(a),c=new Date().getTime()-p.getTime(),h=Math.floor(c/1e3),l=Math.floor(h/60),u=Math.floor(l/60),m=Math.floor(u/24);return m>7?p.toLocaleDateString():m>0?`${m}d ago`:u>0?`${u}h ago`:l>0?`${l}m ago`:"Just now"};return e.jsxs(Tv,{$unread:!t.is_read,onClick:n,children:[e.jsxs(Mv,{children:[e.jsxs(Ov,{children:[e.jsx(Lv,{$severity:t.severity}),e.jsx(Av,{children:t.title})]}),e.jsx(Uv,{onClick:a=>{a.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(et,{})})]}),e.jsx(Dv,{children:t.body}),e.jsxs(Nv,{children:[e.jsx(Fv,{children:s(t.created_at)}),t.action_url&&e.jsx(Bv,{children:e.jsxs(Wv,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:a=>a.stopPropagation(),children:[t.action_label||"View",e.jsx(zs,{})]})})]})]})}const Vv=d.div`
4378
+ `;function id({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},s=a=>{const p=new Date(a),c=new Date().getTime()-p.getTime(),h=Math.floor(c/1e3),l=Math.floor(h/60),u=Math.floor(l/60),m=Math.floor(u/24);return m>7?p.toLocaleDateString():m>0?`${m}d ago`:u>0?`${u}h ago`:l>0?`${l}m ago`:"Just now"};return e.jsxs(Tv,{$unread:!t.is_read,onClick:n,children:[e.jsxs(Mv,{children:[e.jsxs(Ov,{children:[e.jsx(Lv,{$severity:t.severity}),e.jsx(Av,{children:t.title})]}),e.jsx(Uv,{onClick:a=>{a.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(et,{})})]}),e.jsx(Dv,{children:t.body}),e.jsxs(Nv,{children:[e.jsx(Fv,{children:s(t.created_at)}),t.action_url&&e.jsx(Bv,{children:e.jsxs(Wv,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:a=>a.stopPropagation(),children:[t.action_label||"View",e.jsx(zs,{})]})})]})]})}const Vv=d.div`
4379
4379
  position: fixed;
4380
4380
  ${t=>{var r;return((r=t.$position)==null?void 0:r.top)!==void 0?`top: ${t.$position.top}px;`:""}}
4381
4381
  ${t=>{var r;return((r=t.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${t.$position.bottom}px;`:""}}
@@ -4486,7 +4486,7 @@ cursor: pointer;
4486
4486
  color: var(--color-primary-hover);
4487
4487
  text-decoration: underline;
4488
4488
  }
4489
- `,dd=i.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:s,onDelete:a},p)=>{const g=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(Vv,{ref:p,$position:t,children:[e.jsxs(Gv,{children:[e.jsx(Hv,{children:"Notifications"}),g&&e.jsx(qv,{onClick:s,children:"Mark all as read"})]}),e.jsx(Yv,{children:o?e.jsx(Zv,{children:e.jsx(Ee,{})}):r.length===0?e.jsxs(Kv,{children:[e.jsx(Qv,{children:e.jsx(Fp,{})}),e.jsx(Xv,{children:"No notifications"}),e.jsx(Jv,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(ld,{notification:c,onMarkAsRead:n,onDelete:a},c.id))}),!o&&r.length>0&&e.jsx(e1,{children:e.jsx(t1,{href:"/notifications",children:"View all notifications"})})]})}),r1=d.div`
4489
+ `,cd=i.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:s,onDelete:a},p)=>{const g=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(Vv,{ref:p,$position:t,children:[e.jsxs(Gv,{children:[e.jsx(Hv,{children:"Notifications"}),g&&e.jsx(qv,{onClick:s,children:"Mark all as read"})]}),e.jsx(Yv,{children:o?e.jsx(Zv,{children:e.jsx(Ee,{})}):r.length===0?e.jsxs(Kv,{children:[e.jsx(Qv,{children:e.jsx(Dp,{})}),e.jsx(Xv,{children:"No notifications"}),e.jsx(Jv,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(id,{notification:c,onMarkAsRead:n,onDelete:a},c.id))}),!o&&r.length>0&&e.jsx(e1,{children:e.jsx(t1,{href:"/notifications",children:"View all notifications"})})]})}),r1=d.div`
4490
4490
  position: relative;
4491
4491
  `,o1=d.div`
4492
4492
  width: 40px;
@@ -4549,18 +4549,18 @@ cursor: pointer;
4549
4549
  justify-content: center;
4550
4550
  border: 2px solid var(--color-background);
4551
4551
  box-shadow: 0 1px 3px var(--color-shadow);
4552
- `;function ud({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:s}){const[a,p]=i.useState(!1),[g,c]=i.useState(),h=i.useRef(null),l=i.useRef(null),u={channels:o,organization_ids:n,workspace_ids:s,limit:20},{unreadCount:m,notifications:v,loading:x,markAsRead:y,markAllAsRead:$,deleteNotification:S}=Sc(u);return i.useEffect(()=>{if(!a)return;const k=setTimeout(()=>{const I=E=>{var b,f;const w=E.target;(b=h.current)!=null&&b.contains(w)||(f=l.current)!=null&&f.contains(w)||p(!1)};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},50);return()=>{clearTimeout(k)}},[a]),i.useEffect(()=>{if(a&&h.current){const k=h.current.getBoundingClientRect(),I=400,E=600,w=window.innerWidth,b=window.innerHeight,f=w-k.left,z=b-k.bottom,_=k.top;let j,M;f>=I?j=k.left:M=w-k.right;let R,C;z>=E+8?R=k.bottom+8:_>=E+8?C=b-k.top+8:R=k.bottom+8,c({top:R,bottom:C,left:j,right:M})}else c(void 0)},[a]),e.jsx(ge,{children:e.jsxs(r1,{ref:h,className:t,children:[e.jsx(o1,{children:e.jsxs(n1,{onClick:()=>p(!a),children:[e.jsx(Up,{size:16}),r&&m>0&&e.jsx(s1,{children:m>9?"9+":m})]})}),typeof window<"u"&&a&&Wr.createPortal(e.jsx(ge,{children:e.jsx(dd,{ref:l,position:g,notifications:v,loading:x,onMarkAsRead:y,onMarkAllAsRead:$,onDelete:S})}),document.body)]})})}const a1=d.div`
4552
+ `;function ld({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:s}){const[a,p]=i.useState(!1),[g,c]=i.useState(),h=i.useRef(null),l=i.useRef(null),u={channels:o,organization_ids:n,workspace_ids:s,limit:20},{unreadCount:m,notifications:x,loading:v,markAsRead:y,markAllAsRead:z,deleteNotification:S}=Sc(u);return i.useEffect(()=>{if(!a)return;const _=setTimeout(()=>{const E=I=>{var b,f;const w=I.target;(b=h.current)!=null&&b.contains(w)||(f=l.current)!=null&&f.contains(w)||p(!1)};return document.addEventListener("mousedown",E),()=>{document.removeEventListener("mousedown",E)}},50);return()=>{clearTimeout(_)}},[a]),i.useEffect(()=>{if(a&&h.current){const _=h.current.getBoundingClientRect(),E=400,I=600,w=window.innerWidth,b=window.innerHeight,f=w-_.left,$=b-_.bottom,k=_.top;let j,M;f>=E?j=_.left:M=w-_.right;let R,C;$>=I+8?R=_.bottom+8:k>=I+8?C=b-_.top+8:R=_.bottom+8,c({top:R,bottom:C,left:j,right:M})}else c(void 0)},[a]),e.jsx(ge,{children:e.jsxs(r1,{ref:h,className:t,children:[e.jsx(o1,{children:e.jsxs(n1,{onClick:()=>p(!a),children:[e.jsx(Fp,{size:16}),r&&m>0&&e.jsx(s1,{children:m>9?"9+":m})]})}),typeof window<"u"&&a&&Wr.createPortal(e.jsx(ge,{children:e.jsx(cd,{ref:l,position:g,notifications:x,loading:v,onMarkAsRead:y,onMarkAllAsRead:z,onDelete:S})}),document.body)]})})}const a1=d.div`
4553
4553
  display: flex;
4554
4554
  align-items: center;
4555
4555
  gap: 8px;
4556
- `,i1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(a1,{children:[r&&e.jsx(ud,{}),e.jsx(Ds,{showName:t})]}),c1=({children:t})=>{var a;const{session:r,loading:o}=Ue(),{deployment:n}=ve(),{navigateToAccountSelection:s}=Ge();return i.useEffect(()=>{var p;o||(p=r==null?void 0:r.signins)!=null&&p.length&&!r.active_signin&&s()},[o,r,n,s]),o||!((a=r.signins)!=null&&a.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},l1=({children:t})=>{var n;const{loading:r,session:o}=Ue();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},pd=ar`
4556
+ `,i1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(a1,{children:[r&&e.jsx(ld,{}),e.jsx(Ds,{showName:t})]}),c1=({children:t})=>{var a;const{session:r,loading:o}=Ue(),{deployment:n}=ve(),{navigateToAccountSelection:s}=Ge();return i.useEffect(()=>{var p;o||(p=r==null?void 0:r.signins)!=null&&p.length&&!r.active_signin&&s()},[o,r,n,s]),o||!((a=r.signins)!=null&&a.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},l1=({children:t})=>{var n;const{loading:r,session:o}=Ue();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},dd=sr`
4557
4557
  0% {
4558
4558
  background-position: -1000px 0;
4559
4559
  }
4560
4560
  100% {
4561
4561
  background-position: 1000px 0;
4562
4562
  }
4563
- `,d1=ar`
4563
+ `,d1=sr`
4564
4564
  from {
4565
4565
  transform: rotate(0deg);
4566
4566
  }
@@ -4749,7 +4749,7 @@ cursor: pointer;
4749
4749
  var(--color-background-hover) 100%
4750
4750
  );
4751
4751
  background-size: 1000px 100%;
4752
- animation: ${pd} 2s infinite linear;
4752
+ animation: ${dd} 2s infinite linear;
4753
4753
  `,y1=d.div`
4754
4754
  flex: 1;
4755
4755
  display: flex;
@@ -4766,7 +4766,7 @@ cursor: pointer;
4766
4766
  var(--color-background-hover) 100%
4767
4767
  );
4768
4768
  background-size: 1000px 100%;
4769
- animation: ${pd} 2s infinite linear;
4769
+ animation: ${dd} 2s infinite linear;
4770
4770
  `,w1=d.p`
4771
4771
  margin-top: var(--space-lg);
4772
4772
  text-align: center;
@@ -4782,7 +4782,7 @@ cursor: pointer;
4782
4782
  &:hover {
4783
4783
  color: var(--color-primary-hover);
4784
4784
  }
4785
- `,_1=({onAccountSelect:t,showAddAccount:r=!0})=>{var E,w,b,f,z;const{session:o,loading:n,switchSignIn:s,signOut:a}=Ue(),{deployment:p}=ve(),{navigateToSignIn:g,navigate:c}=Ge(),[h,l]=i.useState(null),[u,m]=i.useState(null),v=o==null?void 0:o.active_signin,x=(o==null?void 0:o.signins)||[],y=((w=(E=p==null?void 0:p.auth_settings)==null?void 0:E.multi_session_support)==null?void 0:w.enabled)??!1;i.useEffect(()=>{n||x.length||g()},[n,x,g]);const $=_=>_.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),S=async _=>{var j;if(!(_===(v==null?void 0:v.id)||u)){m(_);try{if(await s(_),t)t(_),m(null);else{let M=new URLSearchParams(window.location.search).get("redirect_uri");if(M||(M=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),M){let R;try{R=new URL(M)}catch{R=new URL(M,window.location.origin)}(p==null?void 0:p.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(R.toString())}else m(null)}}catch(M){console.error("Failed to switch account:",M),m(null)}}},k=async(_,j)=>{_.stopPropagation(),l(j);try{await a(j)}catch(M){console.error("Failed to sign out:",M)}finally{l(null)}},I=()=>{var j;let _=new URLSearchParams(window.location.search).get("redirect_uri");_||(_=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),g(_)};return n?e.jsx(ge,{children:e.jsxs(Di,{children:[e.jsx(Pe,{}),e.jsxs(Fi,{children:[e.jsx(Bi,{children:"Choose an account"}),e.jsxs(Ui,{children:["to continue to ",((b=p==null?void 0:p.ui_settings)==null?void 0:b.app_name)||"App"]})]}),e.jsx(Ni,{children:[1,2].map(_=>e.jsxs(v1,{children:[e.jsx(b1,{}),e.jsxs(y1,{children:[e.jsx(Wi,{}),e.jsx(Wi,{$width:"small"})]})]},_))})]})}):x.length?e.jsx(ge,{children:e.jsxs(Di,{children:[e.jsx(Pe,{}),e.jsxs(Fi,{children:[e.jsx(Bi,{children:"Choose an account"}),e.jsxs(Ui,{children:["to continue to ",(f=p==null?void 0:p.ui_settings)==null?void 0:f.app_name]})]}),e.jsxs(Ni,{children:[x.map(({user:_,id:j})=>{var P,T,B,L,F;if(!_)return null;const M=j===(v==null?void 0:v.id),R=u===j,C=`${_.first_name||""} ${_.last_name||""}`.trim();return e.jsxs(u1,{$isActive:M,$isSwitching:R,onClick:()=>S(j),children:[e.jsx(p1,{children:_.has_profile_picture?e.jsx("img",{src:_.profile_picture_url,alt:C}):$(C||((P=_.primary_email_address)==null?void 0:P.email)||((T=_.primary_phone_number)==null?void 0:T.phone_number)||_.username||"U")}),e.jsxs(h1,{children:[e.jsx(f1,{children:C||((B=_.primary_email_address)==null?void 0:B.email)||((L=_.primary_phone_number)==null?void 0:L.phone_number)||_.username||"User"}),e.jsx(g1,{children:((F=_.primary_email_address)==null?void 0:F.email)||_.username})]}),!R&&e.jsxs(m1,{onClick:O=>k(O,j),$isLoading:h===j,disabled:h===j,children:[h===j?e.jsx(kt,{size:12}):e.jsx(Et,{size:12}),h===j?"Signing out...":"Sign out"]})]},j)}),r&&y&&e.jsxs(x1,{onClick:I,children:[e.jsx(Ke,{}),"Add another account"]})]}),e.jsxs(w1,{children:["Don't have an account?"," ",e.jsx(j1,{children:e.jsx(ot,{to:`${(z=p.ui_settings)==null?void 0:z.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},k1=()=>{const{navigateToSignIn:t}=Ge();return i.useEffect(()=>{t()},[t]),null},C1=()=>{const{navigateToSignUp:t}=Ge();return i.useEffect(()=>{t()},[t]),null},S1=d.div`
4785
+ `,_1=({onAccountSelect:t,showAddAccount:r=!0})=>{var I,w,b,f,$;const{session:o,loading:n,switchSignIn:s,signOut:a}=Ue(),{deployment:p}=ve(),{navigateToSignIn:g,navigate:c}=Ge(),[h,l]=i.useState(null),[u,m]=i.useState(null),x=o==null?void 0:o.active_signin,v=(o==null?void 0:o.signins)||[],y=((w=(I=p==null?void 0:p.auth_settings)==null?void 0:I.multi_session_support)==null?void 0:w.enabled)??!1;i.useEffect(()=>{n||v.length||g()},[n,v,g]);const z=k=>k.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),S=async k=>{var j;if(!(k===(x==null?void 0:x.id)||u)){m(k);try{if(await s(k),t)t(k),m(null);else{let M=new URLSearchParams(window.location.search).get("redirect_uri");if(M||(M=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),M){let R;try{R=new URL(M)}catch{R=new URL(M,window.location.origin)}(p==null?void 0:p.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(R.toString())}else m(null)}}catch(M){console.error("Failed to switch account:",M),m(null)}}},_=async(k,j)=>{k.stopPropagation(),l(j);try{await a(j)}catch(M){console.error("Failed to sign out:",M)}finally{l(null)}},E=()=>{var j;let k=new URLSearchParams(window.location.search).get("redirect_uri");k||(k=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),g(k)};return n?e.jsx(ge,{children:e.jsxs(Di,{children:[e.jsx(Pe,{}),e.jsxs(Fi,{children:[e.jsx(Bi,{children:"Choose an account"}),e.jsxs(Ui,{children:["to continue to ",((b=p==null?void 0:p.ui_settings)==null?void 0:b.app_name)||"App"]})]}),e.jsx(Ni,{children:[1,2].map(k=>e.jsxs(v1,{children:[e.jsx(b1,{}),e.jsxs(y1,{children:[e.jsx(Wi,{}),e.jsx(Wi,{$width:"small"})]})]},k))})]})}):v.length?e.jsx(ge,{children:e.jsxs(Di,{children:[e.jsx(Pe,{}),e.jsxs(Fi,{children:[e.jsx(Bi,{children:"Choose an account"}),e.jsxs(Ui,{children:["to continue to ",(f=p==null?void 0:p.ui_settings)==null?void 0:f.app_name]})]}),e.jsxs(Ni,{children:[v.map(({user:k,id:j})=>{var P,T,B,L,F;if(!k)return null;const M=j===(x==null?void 0:x.id),R=u===j,C=`${k.first_name||""} ${k.last_name||""}`.trim();return e.jsxs(u1,{$isActive:M,$isSwitching:R,onClick:()=>S(j),children:[e.jsx(p1,{children:k.has_profile_picture?e.jsx("img",{src:k.profile_picture_url,alt:C}):z(C||((P=k.primary_email_address)==null?void 0:P.email)||((T=k.primary_phone_number)==null?void 0:T.phone_number)||k.username||"U")}),e.jsxs(h1,{children:[e.jsx(f1,{children:C||((B=k.primary_email_address)==null?void 0:B.email)||((L=k.primary_phone_number)==null?void 0:L.phone_number)||k.username||"User"}),e.jsx(g1,{children:((F=k.primary_email_address)==null?void 0:F.email)||k.username})]}),!R&&e.jsxs(m1,{onClick:O=>_(O,j),$isLoading:h===j,disabled:h===j,children:[h===j?e.jsx(kt,{size:12}):e.jsx(Et,{size:12}),h===j?"Signing out...":"Sign out"]})]},j)}),r&&y&&e.jsxs(x1,{onClick:E,children:[e.jsx(Ke,{}),"Add another account"]})]}),e.jsxs(w1,{children:["Don't have an account?"," ",e.jsx(j1,{children:e.jsx(ot,{to:`${($=p.ui_settings)==null?void 0:$.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},k1=()=>{const{navigateToSignIn:t}=Ge();return i.useEffect(()=>{t()},[t]),null},C1=()=>{const{navigateToSignUp:t}=Ge();return i.useEffect(()=>{t()},[t]),null},S1=d.div`
4786
4786
  width: 100%;
4787
4787
  height: 500px;
4788
4788
  background: var(--color-background);
@@ -4990,10 +4990,10 @@ cursor: pointer;
4990
4990
  margin: 0 auto;
4991
4991
  padding: 6px 16px;
4992
4992
  font-size: 13px;
4993
- `,L1=()=>{var M,R;const{organizationMemberships:t,refetch:r,loading:o}=Ct(),{workspaces:n}=Pt(),{switchOrganization:s,switchWorkspace:a}=Ue(),{deployment:p}=ve(),[g,c]=i.useState(null),[h,l]=i.useState("orgList"),[u,m]=i.useState(null),v=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,x=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,y=i.useRef(!1);i.useEffect(()=>{if(!(y.current||!t)){if(y.current=!0,t.length===0){l("createOrg");return}if(!v){l("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),l("createWorkspace");return}l("orgList")}},[t,n,v]),console.log("view mode",h,v);const $=C=>C.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),S=async C=>{if(v){m(C.id),l("workspaceList");return}c(C.id);try{await s(C.id)}finally{c(null)}},k=async C=>{c(C.id);try{await a(C.id)}finally{c(null)}},I=async C=>{await r(),v&&C&&(m(C.id),l("createWorkspace"))},E=()=>{},w=async()=>{m(null),l("orgList")},b=(M=t==null?void 0:t.find(C=>C.organization.id===u))==null?void 0:M.organization,f=u?n==null?void 0:n.filter(C=>C.organization.id===u):[];if(o)return null;if(h==="createOrg")return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:I,onCancel:()=>l("orgList")})});if(h==="createWorkspace"&&u)return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(Ts,{organizationId:u,onSuccess:E,onCancel:()=>l("workspaceList"),onCreateOrganization:()=>l("createOrg")})});const z=h==="workspaceList",_=z?"Select a workspace":"Select an organization",j=z?`Choose a workspace in ${(b==null?void 0:b.name)||""}`:`to continue to ${((R=p==null?void 0:p.ui_settings)==null?void 0:R.app_name)||"App"}`;return e.jsxs(S1,{children:[e.jsxs(z1,{children:[e.jsxs("div",{children:[e.jsx(Pe,{}),e.jsxs(T1,{children:[e.jsx(M1,{children:_}),e.jsx(O1,{children:j})]})]}),e.jsx(Ds,{showName:!0})]}),e.jsxs($1,{children:[e.jsxs(E1,{children:[e.jsxs(I1,{children:[e.jsx(P1,{children:z?"Workspaces":"Your organizations"}),z&&e.jsxs(R1,{onClick:w,children:[e.jsx(Gr,{}),"Go back"]})]}),e.jsx(A1,{children:z?e.jsx(e.Fragment,{children:f&&f.length>0?f.map(C=>{var T,B,L;const P=((T=C.eligibility_restriction)==null?void 0:T.type)!=="none"&&((B=C.eligibility_restriction)==null?void 0:B.type)!==void 0;return e.jsxs(Vi,{onClick:()=>!P&&k(C),disabled:g===C.id||P,style:{opacity:P?.7:1},children:[e.jsx(Gi,{children:C.image_url?e.jsx(Hi,{src:C.image_url,alt:C.name}):$(C.name).charAt(0)}),e.jsxs(qi,{children:[e.jsx(Yi,{children:C.name}),e.jsxs(Zi,{children:[e.jsx(Uo,{}),"Workspace"]})]}),e.jsx(Ki,{children:e.jsx(ms,{})}),P&&e.jsxs(Qi,{children:[e.jsx(ut,{size:14}),(L=C.eligibility_restriction)==null?void 0:L.message]})]},C.id)}):e.jsxs(Xi,{children:[e.jsx(Ji,{children:"No workspaces yet"}),e.jsxs(ec,{children:["Create your first workspace for"," ",(b==null?void 0:b.name)||"this organization"]}),e.jsxs(tc,{onClick:()=>l("createWorkspace"),children:[e.jsx(Ke,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(C=>{var re,V,q;const P=C.organization,T=n==null?void 0:n.filter(H=>H.organization.id===P.id),B=(T==null?void 0:T.length)||0,L=P.member_count,F=C.roles[0].name,O=C.roles.length-1,A=O>0?`${F.charAt(0).toUpperCase()+F.slice(1)} +${O}`:F.charAt(0).toUpperCase()+F.slice(1),J=((re=C.eligibility_restriction)==null?void 0:re.type)!=="none"&&((V=C.eligibility_restriction)==null?void 0:V.type)!==void 0;return e.jsxs(Vi,{onClick:()=>!J&&S(P),disabled:g===P.id||J,style:{opacity:J?.7:1},children:[e.jsx(Gi,{children:P.image_url?e.jsx(Hi,{src:P.image_url,alt:P.name}):$(P.name)}),e.jsxs(qi,{children:[e.jsx(Yi,{children:P.name}),e.jsx(Zi,{children:v?e.jsxs(e.Fragment,{children:[e.jsx(Uo,{}),B," workspace",B!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(Gp,{}),A," • ",L," member",L!==1?"s":""]})})]}),e.jsx(Ki,{children:e.jsx(ms,{})}),J&&e.jsxs(Qi,{children:[e.jsx(ut,{size:14}),(q=C.eligibility_restriction)==null?void 0:q.message]})]},P.id)}):e.jsxs(Xi,{children:[e.jsx(Ji,{children:"No organizations yet"}),e.jsx(ec,{children:x?"Create your first organization to get started":"You don't have access to any organizations yet"}),x&&e.jsxs(tc,{onClick:()=>l("createOrg"),children:[e.jsx(Ke,{}),"Create organization"]})]})})]}),z&&f&&f.length>0&&e.jsxs(X,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createWorkspace"),disabled:g!==null,children:[e.jsx(Ke,{size:12}),"Create new workspace"]}),!z&&t&&t.length>0&&x&&e.jsxs(X,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createOrg"),disabled:g!==null,children:[e.jsx(Ke,{size:12}),"Create new organization"]})]})]})},D1=d(ke.Content)`
4993
+ `,L1=()=>{var M,R;const{organizationMemberships:t,refetch:r,loading:o}=Ct(),{workspaces:n}=Pt(),{switchOrganization:s,switchWorkspace:a}=Ue(),{deployment:p}=ve(),[g,c]=i.useState(null),[h,l]=i.useState("orgList"),[u,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,y=i.useRef(!1);i.useEffect(()=>{if(!(y.current||!t)){if(y.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",h,x);const z=C=>C.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),S=async C=>{if(x){m(C.id),l("workspaceList");return}c(C.id);try{await s(C.id)}finally{c(null)}},_=async C=>{c(C.id);try{await a(C.id)}finally{c(null)}},E=async C=>{await r(),x&&C&&(m(C.id),l("createWorkspace"))},I=()=>{},w=async()=>{m(null),l("orgList")},b=(M=t==null?void 0:t.find(C=>C.organization.id===u))==null?void 0:M.organization,f=u?n==null?void 0:n.filter(C=>C.organization.id===u):[];if(o)return null;if(h==="createOrg")return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:E,onCancel:()=>l("orgList")})});if(h==="createWorkspace"&&u)return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(Ts,{organizationId:u,onSuccess:I,onCancel:()=>l("workspaceList"),onCreateOrganization:()=>l("createOrg")})});const $=h==="workspaceList",k=$?"Select a workspace":"Select an organization",j=$?`Choose a workspace in ${(b==null?void 0:b.name)||""}`:`to continue to ${((R=p==null?void 0:p.ui_settings)==null?void 0:R.app_name)||"App"}`;return e.jsxs(S1,{children:[e.jsxs(z1,{children:[e.jsxs("div",{children:[e.jsx(Pe,{}),e.jsxs(T1,{children:[e.jsx(M1,{children:k}),e.jsx(O1,{children:j})]})]}),e.jsx(Ds,{showName:!0})]}),e.jsxs($1,{children:[e.jsxs(E1,{children:[e.jsxs(I1,{children:[e.jsx(P1,{children:$?"Workspaces":"Your organizations"}),$&&e.jsxs(R1,{onClick:w,children:[e.jsx(Gr,{}),"Go back"]})]}),e.jsx(A1,{children:$?e.jsx(e.Fragment,{children:f&&f.length>0?f.map(C=>{var T,B,L;const P=((T=C.eligibility_restriction)==null?void 0:T.type)!=="none"&&((B=C.eligibility_restriction)==null?void 0:B.type)!==void 0;return e.jsxs(Vi,{onClick:()=>!P&&_(C),disabled:g===C.id||P,style:{opacity:P?.7:1},children:[e.jsx(Gi,{children:C.image_url?e.jsx(Hi,{src:C.image_url,alt:C.name}):z(C.name).charAt(0)}),e.jsxs(qi,{children:[e.jsx(Yi,{children:C.name}),e.jsxs(Zi,{children:[e.jsx(Uo,{}),"Workspace"]})]}),e.jsx(Ki,{children:e.jsx(ms,{})}),P&&e.jsxs(Qi,{children:[e.jsx(ut,{size:14}),(L=C.eligibility_restriction)==null?void 0:L.message]})]},C.id)}):e.jsxs(Xi,{children:[e.jsx(Ji,{children:"No workspaces yet"}),e.jsxs(ec,{children:["Create your first workspace for"," ",(b==null?void 0:b.name)||"this organization"]}),e.jsxs(tc,{onClick:()=>l("createWorkspace"),children:[e.jsx(Ke,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(C=>{var re,V,q;const P=C.organization,T=n==null?void 0:n.filter(H=>H.organization.id===P.id),B=(T==null?void 0:T.length)||0,L=P.member_count,F=C.roles[0].name,O=C.roles.length-1,A=O>0?`${F.charAt(0).toUpperCase()+F.slice(1)} +${O}`:F.charAt(0).toUpperCase()+F.slice(1),J=((re=C.eligibility_restriction)==null?void 0:re.type)!=="none"&&((V=C.eligibility_restriction)==null?void 0:V.type)!==void 0;return e.jsxs(Vi,{onClick:()=>!J&&S(P),disabled:g===P.id||J,style:{opacity:J?.7:1},children:[e.jsx(Gi,{children:P.image_url?e.jsx(Hi,{src:P.image_url,alt:P.name}):z(P.name)}),e.jsxs(qi,{children:[e.jsx(Yi,{children:P.name}),e.jsx(Zi,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Uo,{}),B," workspace",B!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(Wp,{}),A," • ",L," member",L!==1?"s":""]})})]}),e.jsx(Ki,{children:e.jsx(ms,{})}),J&&e.jsxs(Qi,{children:[e.jsx(ut,{size:14}),(q=C.eligibility_restriction)==null?void 0:q.message]})]},P.id)}):e.jsxs(Xi,{children:[e.jsx(Ji,{children:"No organizations yet"}),e.jsx(ec,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(tc,{onClick:()=>l("createOrg"),children:[e.jsx(Ke,{}),"Create organization"]})]})})]}),$&&f&&f.length>0&&e.jsxs(X,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createWorkspace"),disabled:g!==null,children:[e.jsx(Ke,{size:12}),"Create new workspace"]}),!$&&t&&t.length>0&&v&&e.jsxs(X,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createOrg"),disabled:g!==null,children:[e.jsx(Ke,{size:12}),"Create new organization"]})]})]})},D1=d(ke.Content)`
4994
4994
  padding: 0;
4995
4995
  max-width: 90vw;
4996
- `,N1=({children:t})=>{var y,$,S,k;const{loading:r,session:o}=Ue(),{activeOrganization:n}=Ze(),{activeWorkspace:s,loading:a}=Rt(),{workspaces:p}=Pt(),{deployment:g}=ve(),{organizationMemberships:c}=Ct(),h=(g==null?void 0:g.b2b_settings.workspaces_enabled)??!1,l=c==null?void 0:c.find(I=>I.organization.id===(n==null?void 0:n.id)),u=p==null?void 0:p.find(I=>{var E;return I.id===((E=o==null?void 0:o.active_signin)==null?void 0:E.active_workspace_membership_id)}),m=((y=l==null?void 0:l.eligibility_restriction)==null?void 0:y.type)!=="none"&&(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!==void 0,v=((S=u==null?void 0:u.eligibility_restriction)==null?void 0:S.type)!=="none"&&((k=u==null?void 0:u.eligibility_restriction)==null?void 0:k.type)!==void 0;return r||h&&a?null:(m||v||!n?!1:h?s?p==null?void 0:p.some(E=>E.id===s.id&&E.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(ge,{children:e.jsx(ke,{isOpen:!0,children:e.jsx(ke.Overlay,{children:e.jsx(D1,{style:{width:"850px"},children:e.jsx(L1,{})})})})})},F1=d.div`
4996
+ `,N1=({children:t})=>{var y,z,S,_;const{loading:r,session:o}=Ue(),{activeOrganization:n}=Ze(),{activeWorkspace:s,loading:a}=Rt(),{workspaces:p}=Pt(),{deployment:g}=ve(),{organizationMemberships:c}=Ct(),h=(g==null?void 0:g.b2b_settings.workspaces_enabled)??!1,l=c==null?void 0:c.find(E=>E.organization.id===(n==null?void 0:n.id)),u=p==null?void 0:p.find(E=>{var I;return E.id===((I=o==null?void 0:o.active_signin)==null?void 0:I.active_workspace_membership_id)}),m=((y=l==null?void 0:l.eligibility_restriction)==null?void 0:y.type)!=="none"&&((z=l==null?void 0:l.eligibility_restriction)==null?void 0:z.type)!==void 0,x=((S=u==null?void 0:u.eligibility_restriction)==null?void 0:S.type)!=="none"&&((_=u==null?void 0:u.eligibility_restriction)==null?void 0:_.type)!==void 0;return r||h&&a?null:(m||x||!n?!1:h?s?p==null?void 0:p.some(I=>I.id===s.id&&I.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(ge,{children:e.jsx(ke,{isOpen:!0,children:e.jsx(ke.Overlay,{children:e.jsx(D1,{style:{width:"850px"},children:e.jsx(L1,{})})})})})},F1=d.div`
4997
4997
  display: flex;
4998
4998
  gap: 8px;
4999
4999
  flex-wrap: wrap;
@@ -5144,7 +5144,7 @@ cursor: pointer;
5144
5144
  `,Zn=d.div`
5145
5145
  display: flex;
5146
5146
  justify-content: ${t=>t.$isUser?"flex-end":"flex-start"};
5147
- `,hd=d.div`
5147
+ `,ud=d.div`
5148
5148
  max-width: 85%;
5149
5149
  padding: 10px 14px;
5150
5150
  border-radius: 12px;
@@ -5191,7 +5191,7 @@ cursor: pointer;
5191
5191
  opacity: 1;
5192
5192
  }
5193
5193
  }
5194
- `,o2=d(hd)`
5194
+ `,o2=d(ud)`
5195
5195
  opacity: 0.7;
5196
5196
  position: relative;
5197
5197
  display: inline-block;
@@ -5548,7 +5548,7 @@ cursor: pointer;
5548
5548
  align-items: center;
5549
5549
  justify-content: center;
5550
5550
  overflow: hidden;
5551
- `,fd=d.button`
5551
+ `,pd=d.button`
5552
5552
  height: 32px;
5553
5553
  padding: 0 12px;
5554
5554
  border-radius: 8px;
@@ -5588,7 +5588,7 @@ cursor: pointer;
5588
5588
  &:active:not(:disabled) {
5589
5589
  transform: scale(0.98);
5590
5590
  }
5591
- `,Eo=d(fd)`
5591
+ `,Eo=d(pd)`
5592
5592
  width: 32px;
5593
5593
  padding: 0;
5594
5594
  `,b2=d.img`
@@ -5675,7 +5675,7 @@ cursor: pointer;
5675
5675
  &:hover .expand-icon {
5676
5676
  opacity: 1;
5677
5677
  }
5678
- `,k2=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:s,onClose:a,onDownload:p,onZoom:g,onReset:c,onWheel:h,onMouseDown:l,onMouseMove:u,onMouseUp:m})=>{const[v,x]=i.useState(!1),y=i.useRef(null);return i.useEffect(()=>(x(!0),()=>x(!1)),[]),i.useEffect(()=>{if(t){const $=document.body.style.overflow;document.body.style.overflow="hidden";const S=E=>{(E.ctrlKey||E.metaKey)&&E.preventDefault()},k=E=>{E.preventDefault()},I=E=>{E.preventDefault()};return document.addEventListener("wheel",S,{passive:!1}),document.addEventListener("gesturestart",k,{passive:!1}),document.addEventListener("gesturechange",I,{passive:!1}),()=>{document.body.style.overflow=$,document.removeEventListener("wheel",S),document.removeEventListener("gesturestart",k),document.removeEventListener("gesturechange",I)}}},[t]),!v||!t||!r?null:Wr.createPortal(e.jsx(ge,{children:e.jsx(x2,{ref:y,$isOpen:!0,onClick:$=>{$.target===$.currentTarget&&a()},children:e.jsxs(v2,{onClick:$=>$.stopPropagation(),onWheel:$=>{$.preventDefault(),$.stopPropagation(),h($)},onMouseMove:u,onMouseUp:m,onMouseLeave:m,children:[e.jsx(b2,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:s,onMouseDown:l,draggable:!1}),e.jsx(Eo,{$variant:"ghost",onClick:a,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(et,{size:14})}),e.jsxs(y2,{children:[e.jsxs(w2,{children:[e.jsx(Eo,{$variant:"ghost",onClick:()=>g(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(Ah,{size:14})}),e.jsxs(j2,{children:[Math.round(o*100),"%"]}),e.jsx(Eo,{$variant:"ghost",onClick:()=>g(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Mh,{size:14})}),e.jsx(Eo,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(gh,{size:14})})]}),e.jsxs(fd,{$variant:"primary",onClick:p,title:"Download image",children:[e.jsx(rn,{size:14}),"Download"]})]})]})})}),document.body)};function gd({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:s,selectedSession:a,selectSession:p}=qo(),g=a==null?void 0:a.id;if(!g)return e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsx(rc,{children:e.jsxs(oc,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,h=!0,l="Start a conversation by typing a message below",[u,m]=i.useState(""),[v,x]=i.useState(!1),[y,$]=i.useState(null),[S,k]=i.useState([]),[I,E]=i.useState([]),[w,b]=i.useState(null),[f,z]=i.useState(1),[_,j]=i.useState(!1),[M,R]=i.useState({x:0,y:0}),[C,P]=i.useState({x:0,y:0}),T=i.useRef(null),B=i.useRef(null),{messages:L,pendingMessage:F,pendingImages:O,connectionState:A,isConnected:J,isExecuting:re,executionStatus:V,isWaitingForInput:q,sendMessage:H,submitUserInput:ee,cancelExecution:le}=zc({contextId:g,agentName:o,token:n,platformAdapter:s,autoConnect:c});i.useEffect(()=>{var N;(N=T.current)==null||N.scrollIntoView({behavior:"smooth"})},[L]),i.useEffect(()=>{var N;if(q){const D=L.slice().reverse().find(Z=>{var ae;return((ae=Z.metadata)==null?void 0:ae.type)==="user_input_request"});(N=D==null?void 0:D.metadata)!=null&&N.userInputRequest&&$(D.metadata.userInputRequest)}else $(null),k([])},[q,L]);const oe=N=>{if(N.preventDefault(),!!J)if(q&&y){let D=u.trim();y.input_type==="multiselect"&&(D=S.join(",")),D&&(ee(D),m(""),k([]))}else!re&&u.trim()&&(H(u,I.length>0?I:void 0),m(""),E([]))},de=N=>{const D=N.target.files;D&&(Array.from(D).forEach(Z=>{if(Z.type.startsWith("image/")){const ae=new FileReader;ae.onload=te=>{var _e;if((_e=te.target)!=null&&_e.result){const ze=te.target.result.split(",")[1];E(Ae=>[...Ae,{mime_type:Z.type,data:ze}])}},ae.readAsDataURL(Z)}}),B.current&&(B.current.value=""))},K=N=>{E(D=>D.filter((Z,ae)=>ae!==N))},se=N=>{b(N),z(1),R({x:0,y:0})},xe=()=>{b(null),z(1),R({x:0,y:0}),j(!1)},ue=N=>{const D=document.createElement("a");D.href=N,D.download=`image-${Date.now()}.png`,document.body.appendChild(D),D.click(),document.body.removeChild(D)},U=N=>{z(D=>{const Z=D+N;return Math.min(Math.max(Z,.5),3)})},pe=N=>{N.preventDefault(),N.stopPropagation();const D=N.deltaY>0?-.1:.1;U(D)},Q=N=>{f>1&&(j(!0),P({x:N.clientX-M.x,y:N.clientY-M.y}))},Y=N=>{_&&f>1&&R({x:N.clientX-C.x,y:N.clientY-C.y})},ne=()=>{j(!1)},me=()=>A.status===wt.CONNECTING?"Connecting...":A.status===wt.ERROR?"Connection error":A.status===wt.DISCONNECTED||!J?"Disconnected":q?"Waiting for your input...":re?"Working...":"Ready",fe=()=>{if(!q||!y)return"Ask anything";switch(y.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..."}},W=()=>!q||!y?!1:["select","multiselect","boolean","date"].includes(y.input_type||"");return e.jsxs(ge,{style:{height:"100%",width:"100%"},children:[e.jsxs(rc,{children:[e.jsxs(G1,{children:[e.jsxs(H1,{children:[t&&e.jsx(q1,{onClick:()=>{r?r():p(null)},children:e.jsx(Gr,{size:20})}),e.jsxs(Y1,{children:[e.jsx(Z1,{children:e.jsx(wn,{size:20})}),e.jsxs(K1,{children:[e.jsx(X1,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Q1,{$status:me()}),e.jsx(J1,{$status:me(),children:me()})]})]})]})]}),V!==Le.IDLE&&e.jsx(e2,{$status:V,children:V.replace("_"," ")})]}),e.jsx(t2,{children:L.length===0&&h?e.jsxs(oc,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:l})]}):e.jsxs(e.Fragment,{children:[L.map((N,D)=>{var Z,ae,te,_e;if(((Z=N.metadata)==null?void 0:Z.type)==="user_input_request"&&N.metadata.userInputRequest){const be=N.metadata.userInputRequest,ze=!be.input_type||be.input_type==="text"||be.input_type==="number",Ae=q&&(y==null?void 0:y.input_type)===be.input_type;return e.jsx(Zn,{$isUser:!1,children:e.jsxs(s2,{children:[e.jsx("div",{className:"question",children:be.question}),be.context&&be.context.trim()&&e.jsx("div",{className:"context",children:be.context}),!ze&&e.jsxs("div",{className:"controls",children:[be.input_type==="select"&&be.options&&e.jsxs("select",{value:Ae?u:"",onChange:Re=>m(Re.target.value),disabled:!Ae,children:[e.jsx("option",{value:"",children:"Choose an option..."}),be.options.map(Re=>e.jsx("option",{value:Re,children:Re},Re))]}),be.input_type==="multiselect"&&be.options&&e.jsx("div",{className:"checkbox-group",children:be.options.map(Re=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Ae&&S.includes(Re),onChange:ir=>{ir.target.checked?k([...S,Re]):k(S.filter(cr=>cr!==Re))},disabled:!Ae}),e.jsx("span",{children:Re})]},Re))}),be.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:Ae&&u==="true",onChange:Re=>m(Re.target.value),disabled:!Ae}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Ae&&u==="false",onChange:Re=>m(Re.target.value),disabled:!Ae}),e.jsx("span",{children:"No"})]})]}),be.input_type==="date"&&e.jsx("input",{type:"date",value:Ae?u:"",onChange:Re=>m(Re.target.value),disabled:!Ae})]}),e.jsx("div",{className:"instruction",children:Ae?ze?"Type your response below":be.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},N.id)}if(((ae=N.metadata)==null?void 0:ae.type)==="log"){const be=L[D-1],ze=L[D+1],Ae=((te=be==null?void 0:be.metadata)==null?void 0:te.type)==="log",Re=((_e=ze==null?void 0:ze.metadata)==null?void 0:_e.type)==="log",ir=Ae||Re,cr=!Ae&&Re,Zr=Ae&&!Re;return e.jsx(n2,{$isGrouped:ir,$isFirstInGroup:cr,$isLastInGroup:Zr,children:e.jsx("div",{className:"log-content",children:N.content})},N.id)}return!N.content&&(!N.images||N.images.length===0)?null:e.jsx(Zn,{$isUser:N.role==="user",children:e.jsxs(hd,{$isUser:N.role==="user",children:[e.jsx("div",{children:N.content}),N.images&&N.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:N.images.map((be,ze)=>{const Ae=be.url||`data:${be.mime_type};base64,${be.data}`;return e.jsxs(_2,{onClick:()=>se(Ae),title:"Click to preview",children:[e.jsx("img",{src:Ae,alt:`Image ${ze+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(oh,{size:14})})]},ze)})}),N.isStreaming&&e.jsx(r2,{})]})},N.id)}),F&&e.jsx(Zn,{$isUser:!0,children:e.jsxs(o2,{$isUser:!0,children:[e.jsx("div",{children:F}),O&&O.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:O.map((N,D)=>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:N.data?`data:${N.mime_type};base64,${N.data}`:"#",alt:`Image ${D+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},D))})]})}),e.jsx("div",{ref:T})]})}),I.length>0&&e.jsx(u2,{children:I.map((N,D)=>e.jsxs(p2,{children:[e.jsx("img",{src:N.data?`data:${N.mime_type};base64,${N.data}`:"#",alt:`Upload ${D+1}`}),e.jsx(h2,{type:"button",onClick:()=>K(D),children:e.jsx(et,{size:12})})]},D))}),e.jsx(a2,{onSubmit:oe,children:e.jsxs(i2,{children:[e.jsxs(c2,{children:[e.jsx(l2,{value:u,onChange:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),oe(N))},placeholder:fe(),disabled:!J||re&&!q||W(),rows:1}),e.jsx(d2,{children:e.jsxs(g2,{type:"button",disabled:!J||re,onClick:()=>{var N;return(N=B.current)==null?void 0:N.click()},children:[e.jsx(vh,{size:16}),"Attach"]})}),e.jsx(f2,{ref:B,type:"file",accept:"image/*",multiple:!0,onChange:de})]}),e.jsx(m2,{type:re?"button":"submit",disabled:!J||!q&&!re&&!u.trim(),onClick:re?le:void 0,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),style:{background:re&&v?"var(--color-error)":void 0},children:re?v?e.jsx(et,{size:14}):e.jsx(kt,{size:14,className:"animate-spin"}):e.jsx($s,{size:14})})]})})]}),e.jsx(k2,{isOpen:!!w,imageUrl:w,zoomLevel:f,dragPosition:M,isDragging:_,onClose:xe,onDownload:()=>w&&ue(w),onZoom:U,onReset:()=>{z(1),R({x:0,y:0})},onWheel:pe,onMouseDown:Q,onMouseMove:Y,onMouseUp:ne})]})}const C2=d.div`
5678
+ `,k2=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:s,onClose:a,onDownload:p,onZoom:g,onReset:c,onWheel:h,onMouseDown:l,onMouseMove:u,onMouseUp:m})=>{const[x,v]=i.useState(!1),y=i.useRef(null);return i.useEffect(()=>(v(!0),()=>v(!1)),[]),i.useEffect(()=>{if(t){const z=document.body.style.overflow;document.body.style.overflow="hidden";const S=I=>{(I.ctrlKey||I.metaKey)&&I.preventDefault()},_=I=>{I.preventDefault()},E=I=>{I.preventDefault()};return document.addEventListener("wheel",S,{passive:!1}),document.addEventListener("gesturestart",_,{passive:!1}),document.addEventListener("gesturechange",E,{passive:!1}),()=>{document.body.style.overflow=z,document.removeEventListener("wheel",S),document.removeEventListener("gesturestart",_),document.removeEventListener("gesturechange",E)}}},[t]),!x||!t||!r?null:Wr.createPortal(e.jsx(ge,{children:e.jsx(x2,{ref:y,$isOpen:!0,onClick:z=>{z.target===z.currentTarget&&a()},children:e.jsxs(v2,{onClick:z=>z.stopPropagation(),onWheel:z=>{z.preventDefault(),z.stopPropagation(),h(z)},onMouseMove:u,onMouseUp:m,onMouseLeave:m,children:[e.jsx(b2,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:s,onMouseDown:l,draggable:!1}),e.jsx(Eo,{$variant:"ghost",onClick:a,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(et,{size:14})}),e.jsxs(y2,{children:[e.jsxs(w2,{children:[e.jsx(Eo,{$variant:"ghost",onClick:()=>g(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(Mh,{size:14})}),e.jsxs(j2,{children:[Math.round(o*100),"%"]}),e.jsx(Eo,{$variant:"ghost",onClick:()=>g(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Rh,{size:14})}),e.jsx(Eo,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(hh,{size:14})})]}),e.jsxs(pd,{$variant:"primary",onClick:p,title:"Download image",children:[e.jsx(rn,{size:14}),"Download"]})]})]})})}),document.body)};function hd({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:s,selectedSession:a,selectSession:p}=qo(),g=a==null?void 0:a.id;if(!g)return e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsx(rc,{children:e.jsxs(oc,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,h=!0,l="Start a conversation by typing a message below",[u,m]=i.useState(""),[x,v]=i.useState(!1),[y,z]=i.useState(null),[S,_]=i.useState([]),[E,I]=i.useState([]),[w,b]=i.useState(null),[f,$]=i.useState(1),[k,j]=i.useState(!1),[M,R]=i.useState({x:0,y:0}),[C,P]=i.useState({x:0,y:0}),T=i.useRef(null),B=i.useRef(null),{messages:L,pendingMessage:F,pendingImages:O,connectionState:A,isConnected:J,isExecuting:re,executionStatus:V,isWaitingForInput:q,sendMessage:H,submitUserInput:ee,cancelExecution:le}=zc({contextId:g,agentName:o,token:n,platformAdapter:s,autoConnect:c});i.useEffect(()=>{var N;(N=T.current)==null||N.scrollIntoView({behavior:"smooth"})},[L]),i.useEffect(()=>{var N;if(q){const D=L.slice().reverse().find(Z=>{var ae;return((ae=Z.metadata)==null?void 0:ae.type)==="user_input_request"});(N=D==null?void 0:D.metadata)!=null&&N.userInputRequest&&z(D.metadata.userInputRequest)}else z(null),_([])},[q,L]);const oe=N=>{if(N.preventDefault(),!!J)if(q&&y){let D=u.trim();y.input_type==="multiselect"&&(D=S.join(",")),D&&(ee(D),m(""),_([]))}else!re&&u.trim()&&(H(u,E.length>0?E:void 0),m(""),I([]))},de=N=>{const D=N.target.files;D&&(Array.from(D).forEach(Z=>{if(Z.type.startsWith("image/")){const ae=new FileReader;ae.onload=te=>{var _e;if((_e=te.target)!=null&&_e.result){const ze=te.target.result.split(",")[1];I(Ae=>[...Ae,{mime_type:Z.type,data:ze}])}},ae.readAsDataURL(Z)}}),B.current&&(B.current.value=""))},K=N=>{I(D=>D.filter((Z,ae)=>ae!==N))},se=N=>{b(N),$(1),R({x:0,y:0})},xe=()=>{b(null),$(1),R({x:0,y:0}),j(!1)},ue=N=>{const D=document.createElement("a");D.href=N,D.download=`image-${Date.now()}.png`,document.body.appendChild(D),D.click(),document.body.removeChild(D)},U=N=>{$(D=>{const Z=D+N;return Math.min(Math.max(Z,.5),3)})},pe=N=>{N.preventDefault(),N.stopPropagation();const D=N.deltaY>0?-.1:.1;U(D)},Q=N=>{f>1&&(j(!0),P({x:N.clientX-M.x,y:N.clientY-M.y}))},Y=N=>{k&&f>1&&R({x:N.clientX-C.x,y:N.clientY-C.y})},ne=()=>{j(!1)},me=()=>A.status===wt.CONNECTING?"Connecting...":A.status===wt.ERROR?"Connection error":A.status===wt.DISCONNECTED||!J?"Disconnected":q?"Waiting for your input...":re?"Working...":"Ready",fe=()=>{if(!q||!y)return"Ask anything";switch(y.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..."}},W=()=>!q||!y?!1:["select","multiselect","boolean","date"].includes(y.input_type||"");return e.jsxs(ge,{style:{height:"100%",width:"100%"},children:[e.jsxs(rc,{children:[e.jsxs(G1,{children:[e.jsxs(H1,{children:[t&&e.jsx(q1,{onClick:()=>{r?r():p(null)},children:e.jsx(Gr,{size:20})}),e.jsxs(Y1,{children:[e.jsx(Z1,{children:e.jsx(wn,{size:20})}),e.jsxs(K1,{children:[e.jsx(X1,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(Q1,{$status:me()}),e.jsx(J1,{$status:me(),children:me()})]})]})]})]}),V!==Le.IDLE&&e.jsx(e2,{$status:V,children:V.replace("_"," ")})]}),e.jsx(t2,{children:L.length===0&&h?e.jsxs(oc,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:l})]}):e.jsxs(e.Fragment,{children:[L.map((N,D)=>{var Z,ae,te,_e;if(((Z=N.metadata)==null?void 0:Z.type)==="user_input_request"&&N.metadata.userInputRequest){const be=N.metadata.userInputRequest,ze=!be.input_type||be.input_type==="text"||be.input_type==="number",Ae=q&&(y==null?void 0:y.input_type)===be.input_type;return e.jsx(Zn,{$isUser:!1,children:e.jsxs(s2,{children:[e.jsx("div",{className:"question",children:be.question}),be.context&&be.context.trim()&&e.jsx("div",{className:"context",children:be.context}),!ze&&e.jsxs("div",{className:"controls",children:[be.input_type==="select"&&be.options&&e.jsxs("select",{value:Ae?u:"",onChange:Re=>m(Re.target.value),disabled:!Ae,children:[e.jsx("option",{value:"",children:"Choose an option..."}),be.options.map(Re=>e.jsx("option",{value:Re,children:Re},Re))]}),be.input_type==="multiselect"&&be.options&&e.jsx("div",{className:"checkbox-group",children:be.options.map(Re=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Ae&&S.includes(Re),onChange:ar=>{ar.target.checked?_([...S,Re]):_(S.filter(ir=>ir!==Re))},disabled:!Ae}),e.jsx("span",{children:Re})]},Re))}),be.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:Ae&&u==="true",onChange:Re=>m(Re.target.value),disabled:!Ae}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Ae&&u==="false",onChange:Re=>m(Re.target.value),disabled:!Ae}),e.jsx("span",{children:"No"})]})]}),be.input_type==="date"&&e.jsx("input",{type:"date",value:Ae?u:"",onChange:Re=>m(Re.target.value),disabled:!Ae})]}),e.jsx("div",{className:"instruction",children:Ae?ze?"Type your response below":be.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},N.id)}if(((ae=N.metadata)==null?void 0:ae.type)==="log"){const be=L[D-1],ze=L[D+1],Ae=((te=be==null?void 0:be.metadata)==null?void 0:te.type)==="log",Re=((_e=ze==null?void 0:ze.metadata)==null?void 0:_e.type)==="log",ar=Ae||Re,ir=!Ae&&Re,Zr=Ae&&!Re;return e.jsx(n2,{$isGrouped:ar,$isFirstInGroup:ir,$isLastInGroup:Zr,children:e.jsx("div",{className:"log-content",children:N.content})},N.id)}return!N.content&&(!N.images||N.images.length===0)?null:e.jsx(Zn,{$isUser:N.role==="user",children:e.jsxs(ud,{$isUser:N.role==="user",children:[e.jsx("div",{children:N.content}),N.images&&N.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:N.images.map((be,ze)=>{const Ae=be.url||`data:${be.mime_type};base64,${be.data}`;return e.jsxs(_2,{onClick:()=>se(Ae),title:"Click to preview",children:[e.jsx("img",{src:Ae,alt:`Image ${ze+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(th,{size:14})})]},ze)})}),N.isStreaming&&e.jsx(r2,{})]})},N.id)}),F&&e.jsx(Zn,{$isUser:!0,children:e.jsxs(o2,{$isUser:!0,children:[e.jsx("div",{children:F}),O&&O.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:O.map((N,D)=>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:N.data?`data:${N.mime_type};base64,${N.data}`:"#",alt:`Image ${D+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},D))})]})}),e.jsx("div",{ref:T})]})}),E.length>0&&e.jsx(u2,{children:E.map((N,D)=>e.jsxs(p2,{children:[e.jsx("img",{src:N.data?`data:${N.mime_type};base64,${N.data}`:"#",alt:`Upload ${D+1}`}),e.jsx(h2,{type:"button",onClick:()=>K(D),children:e.jsx(et,{size:12})})]},D))}),e.jsx(a2,{onSubmit:oe,children:e.jsxs(i2,{children:[e.jsxs(c2,{children:[e.jsx(l2,{value:u,onChange:N=>m(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),oe(N))},placeholder:fe(),disabled:!J||re&&!q||W(),rows:1}),e.jsx(d2,{children:e.jsxs(g2,{type:"button",disabled:!J||re,onClick:()=>{var N;return(N=B.current)==null?void 0:N.click()},children:[e.jsx(mh,{size:16}),"Attach"]})}),e.jsx(f2,{ref:B,type:"file",accept:"image/*",multiple:!0,onChange:de})]}),e.jsx(m2,{type:re?"button":"submit",disabled:!J||!q&&!re&&!u.trim(),onClick:re?le:void 0,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{background:re&&x?"var(--color-error)":void 0},children:re?x?e.jsx(et,{size:14}):e.jsx(kt,{size:14,className:"animate-spin"}):e.jsx($s,{size:14})})]})})]}),e.jsx(k2,{isOpen:!!w,imageUrl:w,zoomLevel:f,dragPosition:M,isDragging:k,onClose:xe,onDownload:()=>w&&ue(w),onZoom:U,onReset:()=>{$(1),R({x:0,y:0})},onWheel:pe,onMouseDown:Q,onMouseMove:Y,onMouseUp:ne})]})}const C2=d.div`
5679
5679
  height: 100%;
5680
5680
  display: flex;
5681
5681
  flex-direction: column;
@@ -5870,7 +5870,7 @@ cursor: pointer;
5870
5870
  background: var(--color-border);
5871
5871
  border-radius: var(--radius-sm);
5872
5872
  opacity: 0.6;
5873
- `;function md({showBackButton:t=!1}){const[r,o]=i.useState(""),{sessions:n,loadingSessions:s,selectSession:a,deleteSession:p,setShowHistory:g}=qo(),c=n.filter(v=>v.title.toLowerCase().includes(r.toLowerCase())),h=v=>{const x={},y=new Date,$=new Date(y.getFullYear(),y.getMonth(),y.getDate()),S=new Date($);S.setDate(S.getDate()-1);const k=new Date($);return k.setDate(k.getDate()-7),v.forEach(I=>{const E=new Date(I.last_activity_at);let w;E>=$?w="Today":E>=S?w="Yesterday":E>=k?w="This Week":w="Older",x[w]||(x[w]=[]),x[w].push(I)}),x},l=async(v,x)=>{if(v.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await p(x)}catch(y){console.error("Failed to delete session:",y)}},u=v=>new Date(v).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m=h(c);return e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsxs(C2,{children:[e.jsxs(S2,{children:[t&&e.jsx(z2,{onClick:()=>g(!1),children:e.jsx(Gr,{size:20})}),e.jsx($2,{children:"Conversation History"})]}),e.jsx(E2,{children:e.jsx(I2,{type:"text",placeholder:"Search conversations...",value:r,onChange:v=>o(v.target.value)})}),e.jsx(P2,{children:s?e.jsx(U2,{children:[1,2,3,4,5].map(v=>e.jsxs(W2,{children:[e.jsx(V2,{}),e.jsxs(G2,{children:[e.jsx(H2,{}),e.jsx(q2,{})]})]},v))}):c.length===0?e.jsxs(B2,{children:[e.jsx(fa,{}),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(([v,x])=>e.jsxs(R2,{children:[e.jsx(T2,{children:v}),x.map(y=>e.jsxs(M2,{onClick:()=>a(y),children:[e.jsx(O2,{children:e.jsx(fa,{size:18})}),e.jsxs(A2,{children:[e.jsx(L2,{children:y.title}),e.jsxs(D2,{children:[e.jsx("span",{children:u(y.last_activity_at)}),y.status!=="idle"&&e.jsx(N2,{$status:y.status,children:y.status.replace("_"," ")})]})]}),e.jsx(F2,{onClick:$=>l($,y.id),children:e.jsx(nn,{size:16})})]},y.id))]},v))})]})})}const Y2=d.div`
5873
+ `;function fd({showBackButton:t=!1}){const[r,o]=i.useState(""),{sessions:n,loadingSessions:s,selectSession:a,deleteSession:p,setShowHistory:g}=qo(),c=n.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())),h=x=>{const v={},y=new Date,z=new Date(y.getFullYear(),y.getMonth(),y.getDate()),S=new Date(z);S.setDate(S.getDate()-1);const _=new Date(z);return _.setDate(_.getDate()-7),x.forEach(E=>{const I=new Date(E.last_activity_at);let w;I>=z?w="Today":I>=S?w="Yesterday":I>=_?w="This Week":w="Older",v[w]||(v[w]=[]),v[w].push(E)}),v},l=async(x,v)=>{if(x.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await p(v)}catch(y){console.error("Failed to delete session:",y)}},u=x=>new Date(x).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),m=h(c);return e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsxs(C2,{children:[e.jsxs(S2,{children:[t&&e.jsx(z2,{onClick:()=>g(!1),children:e.jsx(Gr,{size:20})}),e.jsx($2,{children:"Conversation History"})]}),e.jsx(E2,{children:e.jsx(I2,{type:"text",placeholder:"Search conversations...",value:r,onChange:x=>o(x.target.value)})}),e.jsx(P2,{children:s?e.jsx(U2,{children:[1,2,3,4,5].map(x=>e.jsxs(W2,{children:[e.jsx(V2,{}),e.jsxs(G2,{children:[e.jsx(H2,{}),e.jsx(q2,{})]})]},x))}):c.length===0?e.jsxs(B2,{children:[e.jsx(fa,{}),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(R2,{children:[e.jsx(T2,{children:x}),v.map(y=>e.jsxs(M2,{onClick:()=>a(y),children:[e.jsx(O2,{children:e.jsx(fa,{size:18})}),e.jsxs(A2,{children:[e.jsx(L2,{children:y.title}),e.jsxs(D2,{children:[e.jsx("span",{children:u(y.last_activity_at)}),y.status!=="idle"&&e.jsx(N2,{$status:y.status,children:y.status.replace("_"," ")})]})]}),e.jsx(F2,{onClick:z=>l(z,y.id),children:e.jsx(nn,{size:16})})]},y.id))]},x))})]})})}const Y2=d.div`
5874
5874
  height: 100%;
5875
5875
  display: flex;
5876
5876
  flex-direction: column;
@@ -6028,5 +6028,5 @@ cursor: pointer;
6028
6028
  display: flex;
6029
6029
  flex-direction: column;
6030
6030
  gap: var(--space-xs);
6031
- `;function db(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:s,selectSession:a,createSession:p,setShowHistory:g}=qo(),c=async()=>{try{r(!0),await p()}finally{r(!1)}},h=l=>{try{const u=new Date(l),v=new Date().getTime()-u.getTime(),x=Math.floor(v/6e4),y=Math.floor(x/60),$=Math.floor(y/24);return $>0?`${$}d ago`:y>0?`${y}h ago`:x>0?`${x}m ago`:"Just now"}catch{return""}};return s?e.jsx(md,{showBackButton:!0}):n?e.jsx(gd,{showBackButton:!0}):e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsx(Y2,{children:e.jsxs(Z2,{children:[e.jsx(K2,{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(Q2,{children:"Hi there! 👋"}),e.jsx(X2,{children:"How can I help you today?"}),e.jsx(J2,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(eb,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(sb,{children:[e.jsxs(ab,{children:[e.jsx(ib,{children:"Recent Chats"}),e.jsx(cb,{onClick:()=>g(!0),children:"View All →"})]}),e.jsx(lb,{children:o.slice(0,2).map(l=>e.jsx(tb,{onClick:()=>a(l),children:e.jsxs(nb,{children:[e.jsx(rb,{children:l.title}),e.jsxs(ob,{children:[e.jsx("span",{children:h(l.last_activity_at)}),l.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},l.id))})]})]})})})}const ub=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(s=>r.startsWith(s))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(s=>r.startsWith(s))},pb=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=bm;exports.AgentConversation=gd;exports.AgentConversationHistory=md;exports.AgentConversationHub=db;exports.AgentConversationProvider=Xd;exports.AuthFormImage=Pe;exports.ChannelSelector=V1;exports.CreateOrganizationForm=an;exports.CreateWorkspaceDialog=Al;exports.CreateWorkspaceForm=Ts;exports.DeploymentInitialized=zu;exports.DeploymentInitializing=$u;exports.DeploymentProvider=bd;exports.Dialog=ke;exports.DialogTrigger=Rf;exports.Dropdown=nt;exports.DropdownDivider=sn;exports.DropdownItem=Te;exports.DropdownItems=st;exports.DropdownTrigger=at;exports.Form=dt;exports.FormGroup=he;exports.Input=ce;exports.Label=ie;exports.MagicLinkVerification=pm;exports.ManageAccount=ad;exports.ManageAccountDialog=id;exports.ManageOrganization=Tl;exports.ManageWorkspace=Dl;exports.ManageWorkspaceDialog=Nl;exports.NavigateToSignIn=k1;exports.NavigateToSignUp=C1;exports.NavigationLink=ot;exports.NotificationBell=ud;exports.NotificationItem=ld;exports.NotificationPopover=dd;exports.OAuthProvider=mc;exports.ORG_ADMIN_PERMISSIONS=Bl;exports.ORG_MANAGEMENT_PERMISSIONS=Ul;exports.OTPInput=Tt;exports.OrganizationSwitcher=Hl;exports.PhoneNumberInput=qr;exports.PhoneVerification=kl;exports.ProfileCompletion=Sl;exports.RequireActiveTenancy=N1;exports.SSOCallback=om;exports.SignInForm=Lg;exports.SignUpForm=xf;exports.SignedIn=c1;exports.SignedInAccounts=_1;exports.SignedOut=l1;exports.SimpleDialog=Pf;exports.Spinner=Ee;exports.Switch=Cr;exports.TwoFactorMethodSelector=_l;exports.TwoFactorVerification=Cl;exports.UserButton=Ds;exports.UserControls=i1;exports.WORKSPACE_ADMIN_PERMISSIONS=Wl;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=Vl;exports.WaitlistForm=Xg;exports.canManageOrganization=Gl;exports.canManageWorkspace=xs;exports.clearTokenCache=_t;exports.fetchChannelCounts=wu;exports.hasIncompleteProfile=hm;exports.hasOrgPermission=Os;exports.hasWorkspacePermission=As;exports.isExternalUrl=ub;exports.isOrgAdmin=v0;exports.isSafeUrl=pb;exports.isWorkspaceAdmin=b0;exports.redirectToProfileCompletion=fm;exports.useActiveOrganization=Ze;exports.useActiveTenancy=bu;exports.useActiveWorkspace=Rt;exports.useAgentConversation=zc;exports.useAgentConversationContext=qo;exports.useChannelCounts=Su;exports.useClient=Be;exports.useConversationSessions=fc;exports.useDeployment=ve;exports.useForgotPassword=kc;exports.useInvitation=$c;exports.useMagicLinkParams=_c;exports.useMagicLinkVerification=jc;exports.useNavigation=Ge;exports.useNotificationStream=Cc;exports.useNotifications=Sc;exports.useOrganizationList=Yo;exports.useOrganizationMemberships=Ct;exports.useSSOCallback=wc;exports.useSession=Ue;exports.useSignIn=xc;exports.useSignInWithStrategy=Br;exports.useSignUp=vc;exports.useUser=sr;exports.useUserSignins=bc;exports.useWaitlist=yc;exports.useWorkspaceList=Pt;exports.useWorkspaceMemberships=Zo;Object.keys(Bs).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Bs[t]})});
6031
+ `;function db(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:s,selectSession:a,createSession:p,setShowHistory:g}=qo(),c=async()=>{try{r(!0),await p()}finally{r(!1)}},h=l=>{try{const u=new Date(l),x=new Date().getTime()-u.getTime(),v=Math.floor(x/6e4),y=Math.floor(v/60),z=Math.floor(y/24);return z>0?`${z}d ago`:y>0?`${y}h ago`:v>0?`${v}m ago`:"Just now"}catch{return""}};return s?e.jsx(fd,{showBackButton:!0}):n?e.jsx(hd,{showBackButton:!0}):e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsx(Y2,{children:e.jsxs(Z2,{children:[e.jsx(K2,{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(Q2,{children:"Hi there! 👋"}),e.jsx(X2,{children:"How can I help you today?"}),e.jsx(J2,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(eb,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(sb,{children:[e.jsxs(ab,{children:[e.jsx(ib,{children:"Recent Chats"}),e.jsx(cb,{onClick:()=>g(!0),children:"View All →"})]}),e.jsx(lb,{children:o.slice(0,2).map(l=>e.jsx(tb,{onClick:()=>a(l),children:e.jsxs(nb,{children:[e.jsx(rb,{children:l.title}),e.jsxs(ob,{children:[e.jsx("span",{children:h(l.last_activity_at)}),l.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},l.id))})]})]})})})}const ub=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(s=>r.startsWith(s))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(s=>r.startsWith(s))},pb=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=xm;exports.AgentConversation=hd;exports.AgentConversationHistory=fd;exports.AgentConversationHub=db;exports.AgentConversationProvider=Kd;exports.AuthFormImage=Pe;exports.ChannelSelector=V1;exports.CreateOrganizationForm=an;exports.CreateWorkspaceDialog=Ml;exports.CreateWorkspaceForm=Ts;exports.DeploymentInitialized=Cu;exports.DeploymentInitializing=Su;exports.DeploymentProvider=xd;exports.Dialog=ke;exports.DialogTrigger=If;exports.Dropdown=nt;exports.DropdownDivider=sn;exports.DropdownItem=Te;exports.DropdownItems=st;exports.DropdownTrigger=at;exports.Form=dt;exports.FormGroup=he;exports.Input=ce;exports.Label=ie;exports.MagicLinkVerification=dm;exports.ManageAccount=nd;exports.ManageAccountDialog=sd;exports.ManageOrganization=Pl;exports.ManageWorkspace=Al;exports.ManageWorkspaceDialog=Ll;exports.NavigateToSignIn=k1;exports.NavigateToSignUp=C1;exports.NavigationLink=ot;exports.NotificationBell=ld;exports.NotificationItem=id;exports.NotificationPopover=cd;exports.OAuthProvider=mc;exports.ORG_ADMIN_PERMISSIONS=Nl;exports.ORG_MANAGEMENT_PERMISSIONS=Fl;exports.OTPInput=Tt;exports.OrganizationSwitcher=Vl;exports.PhoneNumberInput=qr;exports.PhoneVerification=kl;exports.ProfileCompletion=Sl;exports.RequireActiveTenancy=N1;exports.SSOCallback=tm;exports.SignInForm=Og;exports.SignUpForm=gf;exports.SignedIn=c1;exports.SignedInAccounts=_1;exports.SignedOut=l1;exports.SimpleDialog=Ef;exports.Spinner=Ee;exports.Switch=Cr;exports.TwoFactorMethodSelector=_l;exports.TwoFactorVerification=Cl;exports.UserButton=Ds;exports.UserControls=i1;exports.WORKSPACE_ADMIN_PERMISSIONS=Bl;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=Ul;exports.WaitlistForm=Kg;exports.canManageOrganization=Wl;exports.canManageWorkspace=xs;exports.clearTokenCache=_t;exports.fetchChannelCounts=bu;exports.hasIncompleteProfile=um;exports.hasOrgPermission=Os;exports.hasWorkspacePermission=As;exports.isExternalUrl=ub;exports.isOrgAdmin=v0;exports.isSafeUrl=pb;exports.isWorkspaceAdmin=b0;exports.redirectToProfileCompletion=pm;exports.useActiveOrganization=Ze;exports.useActiveTenancy=xu;exports.useActiveWorkspace=Rt;exports.useAgentConversation=zc;exports.useAgentConversationContext=qo;exports.useChannelCounts=ku;exports.useClient=Be;exports.useConversationSessions=fc;exports.useDeployment=ve;exports.useForgotPassword=kc;exports.useInvitation=$c;exports.useMagicLinkParams=_c;exports.useMagicLinkVerification=jc;exports.useNavigation=Ge;exports.useNotificationStream=Cc;exports.useNotifications=Sc;exports.useOrganizationList=Yo;exports.useOrganizationMemberships=Ct;exports.useSSOCallback=wc;exports.useSession=Ue;exports.useSignIn=xc;exports.useSignInWithStrategy=Br;exports.useSignUp=vc;exports.useUser=nr;exports.useUserSignins=bc;exports.useWaitlist=yc;exports.useWorkspaceList=Pt;exports.useWorkspaceMemberships=Zo;Object.keys(Bs).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Bs[t]})});
6032
6032
  //# sourceMappingURL=index.cjs.js.map