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

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,f]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function l(){if(c.current)return;c.current=!0,a(!0);const[u,g,v]=r.split("_");if(!v)throw new Error("Invalid public key");let x=atob(v),w=g==="test",$=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){$=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",$??"");const z=new URL(window.location.href);z.searchParams.delete("__dev_session__"),window.history.replaceState({},"",z.toString())}else $=localStorage.getItem("__dev_session__");let S={};const k=new URLSearchParams;w?k.append("__dev_session__",$??""):S={credentials:"include"};const P=await fetch(`${x}/deployment${w?"?":""}${k.toString()}`,S);if(!P.ok){a(!1);return}const E=await P.json();E.data.backend_host=x,n&&(E.data.ui_settings={...E.data.ui_settings,...n}),f(E.data),w&&P.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",P.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 f=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&f.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(f,{...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 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={};/**
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,g){return u===g&&(u!==0||1/u===1/g)||u!==u&&g!==g}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,s=t.useEffect,a=t.useLayoutEffect,p=t.useDebugValue;function f(u,g){var v=g(),x=n({inst:{value:v,getSnapshot:g}}),w=x[0].inst,$=x[1];return a(function(){w.value=v,w.getSnapshot=g,c(w)&&$({inst:w})},[u,v,g]),s(function(){return c(w)&&$({inst:w}),u(function(){c(w)&&$({inst:w})})},[u]),p(v),v}function c(u){var g=u.getSnapshot;u=u.value;try{var v=g();return!o(u,v)}catch{return!0}}function h(u,g){return g()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:f;return ln.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,ln}var dn={};/**
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={};/**
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 w=x();if(!u){var $=x();a(w,$)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}$=p({inst:{value:w,getSnapshot:x}});var S=$[0].inst,k=$[1];return c(function(){S.value=w,S.getSnapshot=x,o(S)&&k({inst:S})},[v,w,x]),f(function(){return o(S)&&k({inst:S}),v(function(){o(S)&&k({inst:S})})},[v]),h(w),w}function o(v){var x=v.getSnapshot;v=v.value;try{var w=x();return!a(v,w)}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,f=s.useEffect,c=s.useLayoutEffect,h=s.useDebugValue,l=!1,u=!1,g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;dn.useSyncExternalStore=s.useSyncExternalStore!==void 0?s.useSyncExternalStore:g,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,f;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="@",f=0;f<t.length;f++)p+=rs(t[f])+",";Xr.set(t,p)}if(a){p="#";const c=Qn.keys(t).sort();for(;!Se(f=c.pop());)Se(t[f])||(p+=f+":"+rs(t[f])+",");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 f=a.rollbackOnError;let c=a.optimisticData;const h=g=>typeof f=="function"?f(g):f!==!1,l=a.throwOnError;if(lt(o)){const g=o,v=[],x=r.keys();for(const w of x)!/^\$(inf|sub)\$/.test(w)&&g(r.get(w)._k)&&v.push(w);return Promise.all(v.map(u))}return u(o);async function u(g){const[v]=ws(g);if(!v)return;const[x,w]=lc(r,v),[$,S,k,P]=jt.get(r),E=()=>{const I=$[v];return(lt(a.revalidate)?a.revalidate(x().data,g):a.revalidate!==!1)&&(delete k[v],delete P[v],I&&I[0])?I[0](ic).then(()=>x().data):x().data};if(t.length<3)return E();let z=n,y,m=!1;const b=os();S[v]=[b,0];const _=!Se(c),j=x(),T=j.data,R=j._c,C=Se(R)?T:R;if(_&&(c=lt(c)?c(C,T):c,w({data:c,_c:C})),lt(z))try{z=z(C)}catch(I){y=I,m=!0}if(z&&cc(z))if(z=await z.catch(I=>{y=I,m=!0}),b!==S[v][0]){if(m)throw y;return z}else m&&_&&h(y)&&(p=!0,w({data:C,_c:qe}));if(p&&!m)if(lt(p)){const I=p(z,C);w({data:I,error:qe,_c:qe})}else w({data:z,error:qe,_c:qe});if(S[v][1]=os(),Promise.resolve(E()).then(()=>{w({_c:qe})}),m){if(l)throw y;return}return z}}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),f=(l,u)=>{const g=p[l]||[];return p[l]=g,g.push(u),()=>g.splice(g.indexOf(u),1)},c=(l,u,g)=>{t.set(l,u);const v=p[l];if(v)for(const x of v)x(u,g)},h=()=>{if(!jt.has(t)&&(jt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),s,c,f]),!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,f=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!Se(a)&&p>a||setTimeout(n,f,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),[,,,f]=jt.get(uc);if(p.startsWith(Wd))return o(...a);const c=f[p];return Se(c)?o(...a):(delete f[p],c)}),n),Yd=Vd.concat(qd),Zd=t=>function(...o){const n=hc(),[s,a,p]=Hd(o),f=Bd(n,p);let c=t;const{use:h}=f,l=(h||[]).concat(Yd);for(let u=l.length;u--;)c=l[u](c);return c(s,a||f.fetcher||null,f)},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:f,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:g}=o,[v,x,w,$]=jt.get(n),[S,k]=ws(t),P=i.useRef(!1),E=i.useRef(!1),z=i.useRef(S),y=i.useRef(r),m=i.useRef(o),b=()=>m.current,_=()=>b().isVisible()&&b().isOnline(),[j,T,R,C]=lc(n,S),I=i.useRef({}).current,M=Se(p)?Se(o.fallback)?qe:o.fallback[S]:p,F=(ue,U)=>{for(const pe in I){const K=pe;if(K==="data"){if(!s(ue[K],U[K])&&(!Se(ue[K])||!s(re,U[K])))return!1}else if(U[K]!==ue[K])return!1}return!0},L=i.useMemo(()=>{const ue=!S||!r?!1:Se(f)?b().isPaused()||a?!1:c!==!1:f,U=fe=>{const W=It(fe);return delete W._k,ue?{isValidating:!0,isLoading:!0,...W}:W},pe=j(),K=C(),H=U(pe),se=pe===K?H:U(K);let me=H;return[()=>{const fe=U(j());return F(fe,me)?(me.data=fe.data,me.isLoading=fe.isLoading,me.isValidating=fe.isValidating,me.error=fe.error,me):(me=fe,fe)},()=>se]},[n,S]),B=kd.useSyncExternalStore(i.useCallback(ue=>R(S,(U,pe)=>{F(pe,U)||ue()}),[n,S]),L[0],L[1]),O=!P.current,A=v[S]&&v[S].length>0,X=B.data,te=Se(X)?M&&cc(M)?gn(M):M:X,V=B.error,q=i.useRef(te),re=g?Se(X)?Se(q.current)?te:q.current:X:te,ne=A&&!Se(V)?!1:O&&!Se(f)?f:b().isPaused()?!1:a?Se(te)?!1:c:Se(te)||c,J=!!(S&&r&&O&&ne),oe=Se(B.isValidating)?J:B.isValidating,de=Se(B.isLoading)?J:B.isLoading,Z=i.useCallback(async ue=>{const U=y.current;if(!S||!U||E.current||b().isPaused())return!1;let pe,K,H=!0;const se=ue||{},me=!w[S]||!se.dedupe,fe=()=>qs?!E.current&&S===z.current&&P.current:S===z.current,W={isValidating:!1,isLoading:!1},N=()=>{T(W)},D=()=>{const ie=w[S];ie&&ie[1]===K&&delete w[S]},Y={isValidating:!0};Se(j().data)&&(Y.isLoading=!0);try{if(me&&(T(Y),o.loadingTimeout&&Se(j().data)&&setTimeout(()=>{H&&fe()&&b().onLoadingSlow(S,o)},o.loadingTimeout),w[S]=[U(k),os()]),[pe,K]=w[S],pe=await pe,me&&setTimeout(D,o.dedupingInterval),!w[S]||w[S][1]!==K)return me&&fe()&&b().onDiscarded(S),!1;W.error=qe;const ie=x[S];if(!Se(ie)&&(K<=ie[0]||K<=ie[1]||ie[1]===0))return N(),me&&fe()&&b().onDiscarded(S),!1;const ee=j().data;W.data=s(ee,pe)?ee:pe,me&&fe()&&b().onSuccess(pe,S,o)}catch(ie){D();const ee=b(),{shouldRetryOnError:_e}=ee;ee.isPaused()||(W.error=ie,me&&fe()&&(ee.onError(ie,S,ee),(_e===!0||lt(_e)&&_e(ie))&&(!b().revalidateOnFocus||!b().revalidateOnReconnect||_())&&ee.onErrorRetry(ie,S,ee,be=>{const ze=v[S];ze&&ze[0]&&ze[0](Gs,be)},{retryCount:(se.retryCount||0)+1,dedupe:!0})))}return H=!1,N(),!0},[S,n]),ae=i.useCallback((...ue)=>dc(n,z.current,...ue),[]);if(pn(()=>{y.current=r,m.current=o,Se(X)||(q.current=X)}),pn(()=>{if(!S)return;const ue=Z.bind(qe,mn);let U=0;b().revalidateOnFocus&&(U=Date.now()+b().focusThrottleInterval);const K=Kd(S,v,(H,se={})=>{if(H==sc){const me=Date.now();b().revalidateOnFocus&&me>U&&_()&&(U=me+b().focusThrottleInterval,ue())}else if(H==ac)b().revalidateOnReconnect&&_()&&ue();else{if(H==ic)return Z();if(H==Gs)return Z(se)}});return E.current=!1,z.current=S,P.current=!0,T({_k:k}),ne&&(w[S]||(Se(te)||Fr?ue():Td(ue))),()=>{E.current=!0,K()}},[S]),pn(()=>{let ue;function U(){const K=lt(h)?h(j().data):h;K&&ue!==-1&&(ue=setTimeout(pe,K))}function pe(){!j().error&&(l||b().isVisible())&&(u||b().isOnline())?Z(mn).then(U):U()}return U(),()=>{ue&&(clearTimeout(ue),ue=-1)}},[h,l,u,S]),i.useDebugValue(re),a&&Se(te)&&S){if(!qs&&Fr)throw new Error("Fallback data is required when using Suspense in SSR.");y.current=r,m.current=o,E.current=!1;const ue=$[S];if(!Se(ue)){const U=ae(ue);gn(U)}if(Se(V)){const U=Z(mn);Se(re)||(U.status="fulfilled",U.value=!0),gn(U)}else throw V}return{mutate:ae,get data(){return I.data=!0,re},get error(){return I.error=!0,V},get isValidating(){return I.isValidating=!0,oe},get isLoading(){return I.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(g=>g&&{...g,data:[u.data,...g.data]}),u.data},[r,t,a]),f=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:f,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:f}){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:g,loading:v,error:x,createSession:w,deleteSession:$,refetch:S}=fc(o);i.useEffect(()=>{if(s&&g.length>0){const y=g.find(m=>m.id===s);y&&h(y)}},[s,g]);const k=i.useCallback(y=>{h(y),u(!1)},[]),P=i.useCallback(async y=>{try{const m=y||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,b=await w({title:m});return h(b),a==null||a(b),b}catch(m){const b=m instanceof Error?m.message:"Failed to create session";throw f==null||f(b),m}},[w,a,f]),E=i.useCallback(async y=>{try{await $(y),(c==null?void 0:c.id)===y&&h(null),p==null||p(y)}catch(m){const b=m instanceof Error?m.message:"Failed to delete session";throw f==null||f(b),m}},[$,c,p,f]),z={agentName:r,token:o,platformAdapter:n,sessions:g,selectedSession:c,loadingSessions:v,sessionError:x,selectSession:k,createSession:P,deleteSession:E,refreshSessions:S,showHistory:l,setShowHistory:u,onSessionCreated:a,onSessionDeleted:p,onError:f};return e.jsx(gc.Provider,{value:z,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 f,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=(f=p.data)==null?void 0:f.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 f,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=(f=p.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function ru(t,r){return async({phone:o})=>{var p,f;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&&((f=(p=a.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function ou(t,r){return async({email:o})=>{var p,f;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&&((f=(p=a.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(a.data.signin_attempts.at(-1)||null),a}}function nu(t,r){return async({email:o})=>{var p,f;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&&((f=(p=a.data)==null?void 0:p.signin_attempts)!=null&&f.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:f})=>{var u,g;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),f&&c.append("token",f);const h=await t("/auth/signin",{method:"POST",body:c}),l=await G(h);return"data"in l&&((g=(u=l.data)==null?void 0:u.signin_attempts)!=null&&g.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}),f=await G(p);if("data"in f&&((h=(c=f.data)==null?void 0:c.signin_attempts)!=null&&h.length)){const l=f.data.signin_attempts.at(-1);return n(l||null),f.data}else throw new Error("Verification failed")},prepareVerification:async s=>{var f;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((f=o==null?void 0:o.id)==null?void 0:f.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}),f=await G(p);if("data"in f&&f.data){const h=(c=f.data.signin_attempts)==null?void 0:c.find(l=>l.id===o.id);return h&&n(h),f.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 f=await t(`/auth/sso/login?${p.toString()}`,{method:"POST"});return(await G(f)).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 f,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=(f=p.data)==null?void 0:f.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 f,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=(f=p.data)==null?void 0:f.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:f,isLoading:c}=Fe(r?null:"/session",()=>cu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=i.useCallback(async()=>{await f(void 0,{revalidate:!0})},[f]),l=i.useCallback(async(u="default")=>{if(!a)throw new Error("no session");const g=ns.get(u);if(g&&g.expires>Date.now())return(g==null?void 0:g.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 f(void 0,{revalidate:!0}),await Or("/me/organization-memberships"),await Or("/me/workspace-memberships")},signOut:async u=>{await du(t,u);const g=["/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 w of x){let $=!1;(g.includes(w)||typeof w=="string"&&v.some(S=>w.startsWith(S)))&&($=!0),$&&s.delete(w)}}_t(),await f(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 f(void 0,{revalidate:!0})},switchWorkspace:async u=>{await pu(t,u),_t(),await f(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 B=>(await G(await n(`/organizations/${B.id}/roles`,{method:"GET"}))).data,[n]),p=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/members`,{method:"GET"}))).data,[n]),f=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/domains`,{method:"GET"}))).data,[n]),h=i.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/members/${O.id}/remove`,{method:"POST"})},[n]),l=i.useCallback(async B=>{const O=new FormData;O.append("name",B.name),B.image&&O.append("image",B.image),B.description&&O.append("description",B.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(B,O)=>{const A=Object.entries(O).reduce((te,[V,q])=>(q&&te.append(V,q),te),new FormData),X=await G(await n(`/organizations/${B.id}/update`,{method:"POST",body:A}));return await r(),X},[r,n]),g=i.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/roles/${O.id}/remove`,{method:"POST"})},[n]),v=i.useCallback(async(B,O)=>{const A=new FormData;return A.append("domain",O.fqdn),await G(await n(`/organizations/${B.id}/domains`,{method:"POST",body:A}))},[n]),x=i.useCallback(async(B,O)=>await G(await n(`/organizations/${B.id}/domains/${O.id}/verify`,{method:"POST"})),[n]),w=i.useCallback(async(B,O)=>await G(await n(`/organizations/${B.id}/domains/${O.id}/delete`,{method:"POST"})),[n]),$=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/enterprise-connections`,{method:"GET"}))).data,[n]),S=i.useCallback(async(B,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/${B.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),k=i.useCallback(async(B,O,A)=>{const X=new FormData;return A.domain_id&&X.append("domain_id",A.domain_id),A.idp_entity_id&&X.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&X.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&X.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&X.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&X.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&X.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&X.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&X.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/update`,{method:"POST",body:X}))).data},[n]),P=i.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/enterprise-connections/${O}/delete`,{method:"POST"})},[n]),E=i.useCallback(async(B,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/${B.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),z=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/test`,{method:"POST"}))).data,[n]),y=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/scim/token`,{method:"POST"}))).data,[n]),m=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/enterprise-connections/${O}/scim/token`,{method:"GET"}))).data,[n]),b=i.useCallback(async(B,O)=>{await n(`/organizations/${B.id}/enterprise-connections/${O}/scim/token/revoke`,{method:"POST"})},[n]),_=i.useCallback(async(B,O)=>{const A=new FormData;return A.append("name",O.name),O.permissions&&O.permissions.forEach((te,V)=>{A.append(`permissions[${V}]`,te)}),await G(await n(`/organizations/${B.id}/roles`,{method:"POST",body:A}))},[n]),j=i.useCallback(async B=>(await G(await n(`/organizations/${B.id}/leave`,{method:"POST"}))).data,[n]),T=i.useCallback(async B=>{const O=await G(await n(`/organizations/${B.id}/delete`,{method:"POST"}));return _t(),await r(),await s(),O.data},[n,r,s]),R=i.useCallback(async(B,O,A)=>(await G(await n(`/organizations/${B.id}/members/${O.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),C=i.useCallback(async(B,O,A)=>(await G(await n(`/organizations/${B.id}/members/${O.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),I=i.useCallback(async(B,O)=>{var te,V;const A=new FormData;return A.append("email",O.email),A.append("role_id",O.organizationRole.id),(te=O.workspace)!=null&&te.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/${B.id}/invitations`,{method:"POST",body:A}))).data},[n]),M=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/invitations/${O.id}/discard`,{method:"POST"}))).data,[n]),F=i.useCallback(async(B,O)=>(await G(await n(`/organizations/${B.id}/invitations/${O.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(B=>B.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:j,getOrganizationRoles:a,getOrganizationMembers:p,removeOrganizationMember:h,createOrganization:l,getOrganizationInvitations:f,getOrganizationDomains:c,addOrganizationDomain:v,verifyOrganizationDomain:x,removeOrganizationDomain:w,addRoleToOrganizationMember:R,removeRoleFromOrganizationMember:C,inviteOrganizationMember:I,discardOrganizationInvitation:M,resendOrganizationInvitation:F,updateOrganization:u,addRole:_,removeOrganizationRoles:g,deleteOrganization:T,getEnterpriseConnections:$,createEnterpriseConnection:S,updateEnterpriseConnection:k,deleteEnterpriseConnection:P,testEnterpriseConnectionConfig:E,testEnterpriseConnection:z,generateSCIMToken:y,getSCIMToken:m,revokeSCIMToken:b}},Ze=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:s,leaveOrganization:a,removeOrganizationMember:p,getOrganizationInvitations:f,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:l,verifyOrganizationDomain:u,addRoleToOrganizationMember:g,removeRoleFromOrganizationMember:v,inviteOrganizationMember:x,discardOrganizationInvitation:w,resendOrganizationInvitation:$,updateOrganization:S,removeOrganizationRoles:k,getEnterpriseConnections:P,createEnterpriseConnection:E,updateEnterpriseConnection:z,deleteEnterpriseConnection:y,testEnterpriseConnectionConfig:m,testEnterpriseConnection:b,generateSCIMToken:_,getSCIMToken:j,revokeSCIMToken:T}=Yo(),{session:R,error:C,loading:I}=Ue(),{organizationMemberships:M}=Ct(),F=i.useMemo(()=>(M==null?void 0:M.find(D=>{var Y;return D.id===((Y=R==null?void 0:R.active_signin)==null?void 0:Y.active_organization_membership_id)}))||null,[M,R]),L=i.useMemo(()=>(F==null?void 0:F.organization)||null,[F]),B=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]),X=i.useCallback(async D=>L?await p(L,D):[],[L,p]),te=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]),re=i.useCallback(async D=>L?await u(L,D):void 0,[L,u]),ne=i.useCallback(async D=>L?await h(L,D):void 0,[L,h]),J=i.useCallback(async(D,Y)=>L?await g(L,D,Y):void 0,[L,g]),oe=i.useCallback(async(D,Y)=>L?await v(L,D,Y):void 0,[L,v]),de=i.useCallback(async D=>L?await x(L,D):void 0,[L,x]),Z=i.useCallback(async D=>L?await w(L,D):void 0,[L,w]),ae=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 f(L):[],[L,f]),U=i.useCallback(async()=>L?await P(L):[],[L,P]),pe=i.useCallback(async D=>{if(L)return await E(L,D)},[L,E]),K=i.useCallback(async(D,Y)=>{if(L)return await z(L,D,Y)},[L,z]),H=i.useCallback(async D=>{L&&await y(L,D)},[L,y]),se=i.useCallback(async D=>L?await m(L,D):null,[L,m]),me=i.useCallback(async D=>L?await b(L,D):null,[L,b]),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 T(L,D)},[L,T]);return I||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:F,loading:!1,refetch:o,getRoles:A,updateOrganization:B,getMembers:O,getDomains:V,addDomain:q,verifyDomain:re,removeDomain:ne,getInvitations:ue,removeMember:X,leave:xe,removeRole:te,addMemberRole:J,removeMemberRole:oe,inviteMember:de,discardInvitation:Z,resendInvitation:ae,getEnterpriseConnections:U,createEnterpriseConnection:pe,updateEnterpriseConnection:K,deleteEnterpriseConnection:H,testEnterpriseConnectionConfig:se,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}),f=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]);return{workspaceMemberships:n,loading:r||s,error:a,refetch:f}},Pt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Zo(),{client:s}=Be(),a=i.useMemo(()=>t==null?void 0:t.map(y=>({...y.workspace,organization:y.organization,eligibility_restriction:y.eligibility_restriction})),[t]),p=i.useCallback(async(y,m,b,_)=>{const j=new FormData;j.append("name",m),b&&j.append("image",b),_&&j.append("description",_),j.append("organization_id",y);const T=await G(await s("/workspaces",{method:"POST",body:j}));return _t(),await r(),T.data},[s,r]),f=i.useCallback(async(y,m)=>{const b=await mu(s,y,m);return await r(),b},[s,r]),c=i.useCallback(async(y,m)=>{const b=new FormData;m.name&&b.append("name",m.name),m.description&&b.append("description",m.description),m.image&&b.append("image",m.image),m.enforce_2fa!==void 0&&b.append("enforce_2fa",String(m.enforce_2fa)),m.enable_ip_restriction!==void 0&&b.append("enable_ip_restriction",String(m.enable_ip_restriction)),m.whitelisted_ips&&m.whitelisted_ips.forEach(j=>b.append("whitelisted_ips",j));const _=await G(await s(`/workspaces/${y.id}/update`,{method:"POST",body:b}));return await r(),_.data},[s,r]),h=i.useCallback(async y=>{const m=await G(await s(`/workspaces/${y.id}/delete`,{method:"POST"}));return _t(),await r(),m.data},[s,r]),l=i.useCallback(async y=>(await G(await s(`/workspaces/${y.id}/members`,{method:"GET"}))).data,[s]),u=i.useCallback(async y=>(await G(await s(`/workspaces/${y.id}/roles`,{method:"GET"}))).data,[s]),g=i.useCallback(async(y,m,b)=>{const _=new FormData;return _.append("name",m),b.forEach(T=>_.append("permissions",T)),(await G(await s(`/workspaces/${y.id}/roles`,{method:"POST",body:_}))).data},[s]),v=i.useCallback(async(y,m)=>(await G(await s(`/workspaces/${y.id}/roles/${m.id}/delete`,{method:"POST"}))).data,[s]),x=i.useCallback(async(y,m,b)=>{const _=new FormData;return _.append("email",m),b&&_.append("role_id",b),(await G(await s(`/workspaces/${y.id}/members`,{method:"POST",body:_}))).data},[s]),w=i.useCallback(async(y,m)=>{const b=await G(await s(`/workspaces/${y.id}/members/${m}/remove`,{method:"POST"}));return await r(),b.data},[s,r]),$=i.useCallback(async(y,m,b)=>(await G(await s(`/workspaces/${y.id}/members/${m}/roles/${b}/add`,{method:"POST"}))).data,[s]),S=i.useCallback(async(y,m,b)=>(await G(await s(`/workspaces/${y.id}/members/${m}/roles/${b}/remove`,{method:"POST"}))).data,[s]),k=i.useCallback(async y=>(await G(await s(`/organizations/${y.organization.id}/invitations`,{method:"GET"}))).data.filter(b=>String(b.workspace_id)===String(y.id)),[s]),P=i.useCallback(async(y,m,b)=>{const _=new FormData;return _.append("email",m),_.append("workspace_id",y.id),_.append("workspace_role_id",b),(await G(await s(`/organizations/${y.organization.id}/invitations`,{method:"POST",body:_}))).data},[s]),E=i.useCallback(async(y,m)=>(await G(await s(`/organizations/${y.organization.id}/invitations/${m}/discard`,{method:"POST"}))).data,[s]),z=i.useCallback(async(y,m)=>(await G(await s(`/organizations/${y.organization.id}/invitations/${m}/resend`,{method:"POST"}))).data,[s]);return{workspaces:a||[],loading:o,error:n,refetch:r,leaveWorkspace:f,createWorkspace:p,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:l,getWorkspaceRoles:u,createWorkspaceRole:g,deleteWorkspaceRole:v,inviteWorkspaceMember:x,removeWorkspaceMember:w,addWorkspaceMemberRole:$,removeWorkspaceMemberRole:S,getWorkspaceInvitations:k,createWorkspaceInvitation:P,discardWorkspaceInvitation:E,resendWorkspaceInvitation:z}},Rt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:s,updateWorkspace:a,deleteWorkspace:p,getWorkspaceMembers:f,getWorkspaceRoles:c,createWorkspaceRole:h,deleteWorkspaceRole:l,inviteWorkspaceMember:u,removeWorkspaceMember:g,addWorkspaceMemberRole:v,removeWorkspaceMemberRole:x,getWorkspaceInvitations:w,createWorkspaceInvitation:$,discardWorkspaceInvitation:S,resendWorkspaceInvitation:k}=Pt(),{workspaceMemberships:P}=Zo(),{session:E,loading:z,error:y}=Ue(),m=i.useMemo(()=>(P==null?void 0:P.find(J=>{var oe;return J.id===((oe=E==null?void 0:E.active_signin)==null?void 0:oe.active_workspace_membership_id)}))||null,[P,E]),b=i.useMemo(()=>(m==null?void 0:m.workspace)||null,[m]),_=i.useCallback(async()=>{var J;if(!(!b||!((J=E==null?void 0:E.active_signin)!=null&&J.user_id)))return await s(b.id,E.active_signin.user_id)},[b,s,E]),j=i.useCallback(async J=>{if(b)return await a(b,J)},[b,a]),T=i.useCallback(async()=>{if(b)return await p(b)},[b,p]),R=i.useCallback(async()=>b?await f(b):[],[b,f]),C=i.useCallback(async()=>b?await c(b):[],[b,c]),I=i.useCallback(async(J,oe)=>{if(b)return await h(b,J,oe)},[b,h]),M=i.useCallback(async J=>{if(b)return await l(b,J)},[b,l]),F=i.useCallback(async(J,oe)=>{if(b)return await u(b,J,oe)},[b,u]),L=i.useCallback(async J=>{if(b)return await g(b,J)},[b,g]),B=i.useCallback(async(J,oe)=>{if(b)return await v(b,J,oe)},[b,v]),O=i.useCallback(async(J,oe)=>{if(b)return await x(b,J,oe)},[b,x]),A=i.useMemo(()=>(n==null?void 0:n.find(J=>J.id===(b==null?void 0:b.id)))||null,[n,b]),X=i.useCallback(async()=>A?await w(A):[],[A,w]),te=i.useCallback(async(J,oe)=>{if(A)return await $(A,J,oe)},[A,$]),V=i.useCallback(async J=>{if(A)return await S(A,J)},[A,S]),q=i.useCallback(async J=>{if(A)return await k(A,J)},[A,k]),re=r||z,ne=o||y;return re?{activeWorkspace:null,activeMembership:null,loading:!0,error:ne,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,createInvitation:null,discardInvitation:null,resendInvitation:null}:{activeWorkspace:b,activeMembership:m,loading:!1,error:ne,refetch:t,leave:_,updateWorkspace:j,deleteWorkspace:T,getMembers:R,getRoles:C,createRole:I,deleteRole:M,inviteMember:F,removeMember:L,addMemberRole:B,removeMemberRole:O,getInvitations:X,createInvitation:te,discardInvitation:V,resendInvitation:q}},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 I=>{const M=new FormData;for(const[L,B]of Object.entries(I))B!=null&&B!==""&&M.append(L,String(B));const F=await G(await t("/me",{method:"POST",body:M}));return a(),F},f=async()=>await G(await t("/me/email-addresses",{method:"GET"})),c=async I=>await G(await t(`/me/email-addresses/${I}`,{method:"GET"})),h=async I=>{const M=new FormData;return M.append("email",I),await G(await t("/me/email-addresses",{method:"POST",body:M}))},l=async I=>await G(await t(`/me/email-addresses/${I}/delete`,{method:"POST"})),u=async I=>await G(await t(`/me/email-addresses/${I}/prepare-verification`,{method:"POST"})),g=async(I,M)=>await G(await t(`/me/email-addresses/${I}/attempt-verification?code=${M}`,{method:"POST"})),v=async(I,M)=>{const F=new FormData;return F.append("phone_number",I),F.append("country_code",M),await G(await t("/me/phone-numbers",{method:"POST",body:F}))},x=async I=>await G(await t(`/me/phone-numbers/${I}/delete`,{method:"POST"})),w=async I=>await G(await t(`/me/phone-numbers/${I}/prepare-verification`,{method:"POST"})),$=async(I,M)=>{const F=new FormData;return F.append("code",M),await G(await t(`/me/phone-numbers/${I}/attempt-verification`,{method:"POST",body:F}))},S=async I=>{const M=await G(await t(`/me/phone-numbers/${I}/make-primary`,{method:"POST"}));return a(),M},k=async I=>await G(await t(`/me/email-addresses/${I}/make-primary`,{method:"POST"})),P=async()=>(await G(await t("/me/authenticator",{method:"POST"}))).data,E=async(I,M)=>{const F=new FormData;return F.append("authenticator_id",I),M.forEach(B=>{F.append("codes",B)}),await G(await t("/me/authenticator/attempt-verification",{method:"POST",body:F}))},z=async I=>await G(await t(`/me/authenticator/${I}/delete`,{method:"POST"})),y=async()=>(await G(await t("/me/backup-codes",{method:"POST"}))).data,m=async I=>{const M=new FormData;return M.append("file",I),await G(await t("/me/profile-picture",{method:"POST",body:M}))},b=async()=>(await G(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,_=async(I,M)=>{const F=new FormData;return F.append("current_password",I),F.append("new_password",M),await G(await t("/me/update-password",{method:"POST",body:F}))},j=async I=>{const M=new FormData;M.append("current_password",I);const F=await G(await t("/me/remove-password",{method:"POST",body:M}));return a(),F},T=async I=>{const M=new FormData;return M.append("password",I),await G(await t("/me/account/delete",{method:"POST",body:M}))},R=async I=>await G(await t(`/me/social-connections/${I}/disconnect`,{method:"POST"})),C=async({provider:I,redirectUri:M})=>{var B;const F=new URLSearchParams({provider:I});M&&F.append("redirect_uri",M);const L=await G(await t(`/me/init-sso-connection?${F.toString()}`,{method:"POST"}));return"data"in L&&((B=L.data)!=null&&B.oauth_url)&&window.open(L.data.oauth_url,"_blank"),L};return{user:{...o,refetch:a},loading:r||s,error:n||null,updateProfile:p,getEmailAddresses:f,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:l,prepareEmailVerification:u,attemptEmailVerification:g,makeEmailPrimary:k,createPhoneNumber:v,deletePhoneNumber:x,preparePhoneVerification:w,attemptPhoneVerification:$,makePhonePrimary:S,setupAuthenticator:P,verifyAuthenticator:E,deleteAuthenticator:z,generateBackupCodes:y,regenerateBackupCodes:b,updateProfilePicture:m,disconnectSocialConnection:R,connectSocialAccount:C,updatePassword:_,removePassword:j,deleteAccount:T}}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 f=>await G(await t(`/me/signins/${f}/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]),f=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:f}}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 f=await t("/waitlist/join",{method:"POST",body:p});return await G(f)}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,f]=i.useState(null),[c,h]=i.useState(null),[l,u]=i.useState(!1),[g,v]=i.useState(null);i.useEffect(()=>{if(l||r)return;const w=new URLSearchParams(window.location.search),$=w.get("code"),S=w.get("state"),k=w.get("error"),P=w.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=P||k,z=new Error(`OAuth Error: ${E}`);a(z),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(w,$)=>{try{let S,k;try{const z=$.split(".");if(z.length!==2)throw new Error("Invalid OAuth state format - missing signature");const y=z[0].replace(/-/g,"+").replace(/_/g,"/"),m=y.length%4?"=".repeat(4-y.length%4):"",_=atob(y+m).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(z){const y=z instanceof Error?z:new Error("Failed to parse OAuth state");a(new Error(`Invalid OAuth callback: ${y.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const P=await t(`${S}?code=${encodeURIComponent(w)}&state=${encodeURIComponent($)}`,{method:k}),E=await G(P);if("data"in E){const z=E.data.session,y=E.data.redirect_uri||null;if(f(z),h(y),z.signin_attempts&&z.signin_attempts.length>0){const m=z.signin_attempts.at(-1);m&&v(m)}}else{const z=new Error("SSO callback failed");a(z)}}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:g}}function jc(){const{client:t,loading:r}=Be(),[o,n]=i.useState(!1),[s,a]=i.useState(null);return{loading:r||o,verifyMagicLink:async f=>{if(!f.token||!f.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",f.token),c.searchParams.set("attempt",f.attempt),f.redirectUri&&c.searchParams.set("redirect_uri",f.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 f=await t("/auth/forgot-password",{method:"POST",body:p});return await G(f)},verifyOtp:async(a,p)=>{const f=new FormData;f.append("email",a),f.append("otp",p);const c=await t("/auth/forgot-password",{method:"POST",body:f});return await G(c)},resetPassword:async(a,p)=>{const f=new FormData;f.append("token",a),f.append("password",p);const c=await t("/auth/reset-password",{method:"POST",body:f});return await G(c)}}}function Cc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:s,onError:a,reconnectDelay:p=1e3,maxReconnectAttempts:f=5}={}){const{session:c,loading:h}=Ue(),{deployment:l,loading:u}=ve(),[g,v]=i.useState(!1),[x,w]=i.useState(null),$=i.useRef(null),S=i.useRef(null),k=i.useRef(0),P=i.useRef(null),E=i.useRef(s),z=i.useRef(a),y=i.useRef(r),m=i.useRef(o),b=i.useRef(n),_=i.useRef(p),j=i.useRef(f);E.current=s,z.current=a,y.current=r,m.current=o,b.current=n,_.current=p,j.current=f;const T=i.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null),P.current&&(clearInterval(P.current),P.current=null),$.current&&($.current.close(),$.current=null)},[]),R=i.useCallback(async()=>{var B;if(!t||h||u||!c||!l)return;T();const M=new URL(l.backend_host),F=M.protocol==="https:"?"wss:":"ws:",L=new URL("/realtime/notifications",`${F}//${M.host}`);if(l.mode==="staging"){const O=localStorage.getItem("__dev_session__");O&&L.searchParams.set("__dev_session__",O)}y.current&&y.current.length>0&&y.current.forEach(O=>L.searchParams.append("channels",O)),m.current&&m.current.length>0&&m.current.forEach(O=>L.searchParams.append("organization_ids",O.toString())),b.current&&b.current.length>0&&b.current.forEach(O=>L.searchParams.append("workspace_ids",O.toString()));try{const O=new WebSocket(L.toString());$.current=O,O.onopen=()=>{v(!0),w(null),k.current=0,P.current=setInterval(()=>{O.readyState===WebSocket.OPEN&&O.send("ping")},3e4)},O.onmessage=A=>{var X,te;try{const V=JSON.parse(A.data);if(V.type==="notification"&&V.data)(X=E.current)==null||X.call(E,V.data);else if(V.type==="error"){const q=V.error||"Unknown error occurred";w(q),(te=z.current)==null||te.call(z,q)}else V.type}catch{}},O.onerror=()=>{var A;w("Connection error occurred"),(A=z.current)==null||A.call(z,"Connection error occurred")},O.onclose=A=>{var X;if(v(!1),P.current&&(clearInterval(P.current),P.current=null),t&&A.code!==1e3&&k.current<j.current){k.current++;const te=_.current*Math.pow(2,k.current-1);S.current=setTimeout(()=>{R()},te)}else k.current>=j.current&&(w("Max reconnection attempts reached"),(X=z.current)==null||X.call(z,"Max reconnection attempts reached"))}}catch{w("Failed to connect"),(B=z.current)==null||B.call(z,"Failed to connect")}},[t,h,u,c,l,T]);i.useEffect(()=>(R(),()=>{T()}),[R,T]),i.useEffect(()=>{$.current&&$.current.readyState===WebSocket.OPEN&&R()},[r,o,n,R]);const C=i.useCallback(()=>{T(),v(!1)},[T]),I=i.useCallback(()=>{k.current=0,R()},[R]);return{isConnected:g,connectionError:x,disconnect:C,reconnect:I}}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 g=>!g||g.notifications.some(x=>x.id===u.id.toString())?g:{...g,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},...g.notifications],unread_count:g.unread_count+1,total:g.total+1},!1)},[a]),onError:i.useCallback(()=>{},[])});const f=i.useCallback(async u=>{o||(await a(async g=>g&&{...g,notifications:g.notifications.map(v=>v.id===u?{...v,is_read:!0}:v),unread_count:Math.max(0,g.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(g=>({...g,is_read:!0})),unread_count:0},!1),await _u(r),await a())},[r,a]),h=i.useCallback(async u=>{o||(await a(async g=>{if(!g)return g;const v=g.notifications.find(x=>x.id===u);return{...g,notifications:g.notifications.filter(x=>x.id!==u),unread_count:v&&!v.is_read?Math.max(0,g.unread_count-1):g.unread_count,total:Math.max(0,g.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:f,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(),[f,c]=i.useState([]),[h,l]=i.useState(null),[u,g]=i.useState(null),[v,x]=i.useState(!1),[w,$]=i.useState(!1),[S,k]=i.useState(Le.IDLE),[P,E]=i.useState({status:wt.DISCONNECTED}),[z,y]=i.useState(!0),[m,b]=i.useState(!1),_=i.useRef(null),j=i.useRef(null),T=i.useCallback(V=>{var q,re;switch(V.message_type){case"session_connected":if(x(!0),E({status:wt.CONNECTED}),(q=V.data)!=null&&q.execution_status){const J=V.data.execution_status,oe=Ks(J);k(oe),$(Qs(oe))}break;case"conversation_message":R(V.data);break;case"user_input_request":C(V.data);break;case"platform_event":I(V.data);break;case"platform_function":M(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 ne=(re=V.data)==null?void 0:re.status;if(ne){const J=Ks(ne);k(J),$(Qs(J))}break}},[h]),R=i.useCallback(V=>{var oe,de,Z,ae,xe,ue,U,pe;const{id:q,message_type:re,content:ne}=V,J=K=>f.some(H=>H.id===K);if(re==="system_decision"||re==="action_execution_result"||re==="assistant_task_breakdown"||re==="assistant_validation"||re==="assistant_action_planning"||re==="context_results"){l(null),g(null);let K="";if(re==="system_decision"){const H=ne==null?void 0:ne.step,se=ne==null?void 0:ne.reasoning;if(H==="gathercontext")se&&se.length>0?K=se.length>60?`${se.substring(0,60)}...`:se:K="Gathering context...";else if(H==="executeaction")K="Executing action";else if(H==="deliverresponse")K="Preparing response";else if(H==="taskplanning")K="Planning approach";else if(H==="validateprogress")K="Validating progress";else if(H==="acknowledge")K="Processing request";else if(H==="finishplanning")K="Finalizing plan";else if(H==="executetasks")K="Executing tasks";else if(H==="requestuserinput")K="Waiting for input";else if(H==="complete")K="Completed";else if(H==="examinetool")K="Examining tool";else if(H==="examineworkflow")K="Examining workflow";else{const me=(ne==null?void 0:ne.confidence)||.5;me>.8?K="Analyzing":me>.6?K="Thinking":K="Reasoning"}}else if(re==="action_execution_result")((oe=ne.task_execution)==null?void 0:oe.status)==="completed"?K="Task execution completed":(de=ne.task_execution)!=null&&de.approach?K=ne.task_execution.approach:K="Executing task";else if(re==="assistant_task_breakdown")(Z=ne.task_breakdown)!=null&&Z.total_tasks?K=`Identified ${ne.task_breakdown.total_tasks} tasks`:K="Planning tasks";else if(re==="assistant_validation")K="Validated results";else if(re==="assistant_action_planning")(ae=ne.task_execution)!=null&&ae.total_tasks?K=`Planned ${ne.task_execution.total_tasks} tasks`:(ue=(xe=ne.task_execution)==null?void 0:xe.tasks)!=null&&ue.length?K=`Planned ${ne.task_execution.tasks.length} tasks`:K="Planning actions";else if(re==="context_results"){const H=ne.query,se=ne.result_count||0;H&&H!=="General context gathering"?K=`${H}: Found ${se} results`:K=`Found ${se} results`}K&&!J(q)&&c(H=>[...H,{id:q,role:"system",content:K,timestamp:new Date,metadata:{type:"log",messageType:re}}]);return}if(re==="user_message")J(q)||(l(null),g(null),c(K=>[...K,{id:q,role:"user",content:ne.message,images:ne.images,timestamp:new Date}]));else if(re==="agent_response")J(q)||(l(null),g(null),$(!1),k(Le.IDLE),j.current=null,c(K=>[...K,{id:q,role:"assistant",content:ne.response,timestamp:new Date,isStreaming:!1}]));else if(re==="assistant_acknowledgment")J(q)||(l(null),g(null),c(K=>[...K,{id:q,role:"assistant",content:ne.acknowledgment_message,timestamp:new Date}]));else if(re==="assistant_ideation"||re==="assistant_action_planning"||re==="action_execution_result"||re==="assistant_validation"||re==="assistant_context_gathering"||re==="assistant_task_breakdown"){let K="";if(ne.reasoning_summary)K=ne.reasoning_summary;else if((U=ne.task_execution)!=null&&U.approach)K=ne.task_execution.approach;else if(ne.strategic_synthesis)K=ne.strategic_synthesis;else if((pe=ne.task_breakdown)!=null&&pe.total_tasks)K=`Breaking down into ${ne.task_breakdown.total_tasks} tasks...`;else if(ne.acknowledgment_message)K=ne.acknowledgment_message;else return;c(H=>[...H,{id:q,role:"assistant",content:K,timestamp:new Date}])}else if(re==="user_input_request"){const K={question:ne.question,context:ne.context,input_type:ne.input_type,options:ne.options||ne.suggestions,default_value:ne.default_value,placeholder:ne.placeholder};k("waiting_for_input"),c(H=>[...H,{id:q,role:"system",content:K.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:K}}])}},[]),C=i.useCallback(async V=>{k("waiting_for_input");const q=`input-request-${Date.now()}`;c(re=>[...re,{id:q,role:"system",content:V.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:V}}])},[]),I=i.useCallback(V=>{const{event_label:q,event_data:re}=V;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(q,re)},[n]),M=i.useCallback(async V=>{const{function_name:q,function_data:re}=V,{parameters:ne,execution_id:J}=re;if(!(n!=null&&n.onPlatformFunction)){Xe.send({message_type:{platform_function_result:[J,{error:"No platform function handler registered"}]},data:{}});return}try{const oe=await n.onPlatformFunction(q,ne,J),de={message_type:{platform_function_result:[J,oe]},data:{}};Xe.send(de)}catch(oe){Xe.send({message_type:{platform_function_result:[J,{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(T),[T]),i.useEffect(()=>{v&&t&&r&&s&&Xe.send({message_type:{session_connect:[t,r]},data:{}})},[v,t,r,s]);const F=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),g(q||null),$(!0),k(Le.STARTING),Xe.send({message_type:{message_input:V},data:q?{images:q}:{}}))},[v]),B=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 re=new URLSearchParams({token:o,limit:"50"});V&&(re.append("before_id",V),b(!0));const J=await(await p(`/api/agent/contexts/${t}/messages?${re}`,{method:"GET"})).json();if(J.status===200&&J.data){const oe=J.data;if(Array.isArray(oe.data)){const de=oe.data.filter(Z=>{var ue;let ae=Z.content;if(typeof Z.content=="string")try{ae=JSON.parse(Z.content)}catch{ae={message:Z.content}}const xe=((ue=Z.metadata)==null?void 0:ue.message_type)||(ae==null?void 0:ae.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(Z=>{var K,H,se,me,fe,W,N;let ae="",xe,ue,U=Z.content;if(typeof Z.content=="string")try{U=JSON.parse(Z.content)}catch{U=Z.content}const pe=((K=Z.metadata)==null?void 0:K.message_type)||(U==null?void 0:U.message_type);if(pe==="user_message"?(ae=(U==null?void 0:U.message)||"",xe=(U==null?void 0:U.images)||void 0):pe==="agent_response"?ae=(U==null?void 0:U.response)||"":pe==="assistant_acknowledgment"?ae=(U==null?void 0:U.acknowledgment_message)||"":pe==="user_input_request"&&(ae=(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 Y=U==null?void 0:U.step,ie=U==null?void 0:U.reasoning;if(Y==="gathercontext")ie&&ie.length>0?D=ie.length>60?`${ie.substring(0,60)}...`:ie:D="Gathering context...";else if(Y==="executeaction")D="Executing action";else if(Y==="deliverresponse")D="Preparing response";else if(Y==="taskplanning")D="Planning approach";else if(Y==="validateprogress")D="Validating progress";else if(Y==="acknowledge")D="Processing request";else if(Y==="finishplanning")D="Finalizing plan";else if(Y==="executetasks")D="Executing tasks";else if(Y==="requestuserinput")D="Waiting for input";else if(Y==="complete")D="Completed";else if(Y==="examinetool")D="Examining tool";else if(Y==="examineworkflow")D="Examining workflow";else{const ee=(U==null?void 0:U.confidence)||.5;ee>.8?D="Analyzing":ee>.6?D="Thinking":D="Reasoning"}}else if(pe==="action_execution_result")((H=U==null?void 0:U.task_execution)==null?void 0:H.status)==="completed"?D="Task execution completed":(se=U==null?void 0:U.task_execution)!=null&&se.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 Y=U==null?void 0:U.query,ie=(U==null?void 0:U.result_count)||0;Y&&Y!=="General context gathering"?D=`${Y}: Found ${ie} results`:D=`Found ${ie} results`}ae=D,ue={type:"log",messageType:pe}}return{id:Z.id,role:pe==="user_message"?"user":pe==="user_input_request"?"system":"assistant",content:ae,images:xe,timestamp:new Date(Z.timestamp||Z.created_at||Date.now()),metadata:ue}}).filter(Z=>Z.content||Z.metadata||Z.images).sort((Z,ae)=>{const xe=BigInt(Z.id),ue=BigInt(ae.id);return xe<ue?-1:xe>ue?1:0});de.length>0&&(_.current=de[0].id),V?(c(Z=>[...de,...Z]),y(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)),b(!1)}}}catch(re){console.error("Failed to fetch messages:",re),b(!1)}},[o,t,p]);i.useEffect(()=>{t&&o&&A()},[t,o]);const X=i.useCallback(async()=>{if(!(m||!z||!_.current)){b(!0);try{await A(_.current)}finally{b(!1)}}},[m,z,A]),te=i.useCallback(()=>{!v||!w||(Xe.send({message_type:{cancel_execution:null},data:{}}),$(!1),k("idle"))},[v,w]);return{messages:f,pendingMessage:h,pendingImages:u,connectionState:P,isConnected:v,isExecuting:w,executionStatus:S,isWaitingForInput:S==="waiting_for_input",hasMoreMessages:z,isLoadingMore:m,sendMessage:L,submitUserInput:O,clearMessages:B,loadMoreMessages:X,cancelExecution:te,connect:F,disconnect:()=>Xe.disconnect()}}const $c=()=>{const{client:t}=Be(),[r,o]=i.useState(!1),[n,s]=i.useState(null),[a,p]=i.useState(null),f=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 g={error_code:"NETWORK_ERROR",message:u};return p(g),g}finally{o(!1)}},[t]),c=i.useCallback(()=>{s(null),p(null)},[]);return{acceptInvitation:f,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,f){return{value:t,root:r,parent:o,type:n,props:s,children:a,line:Qo,column:wr,length:p,return:"",siblings:f}}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,f,c){for(var h=0,l=0,u=p,g=0,v=0,x=0,w=1,$=1,S=1,k=0,P="",E=s,z=a,y=n,m=P;$;)switch(x=k,k=rt()){case 40:if(x!=108&&We(m,u-1)==58){Io(m+=ye(xn(k),"&","&\f"),"&\f",Pc(h?f[h-1]:0))!=-1&&(S=-1);break}case 34:case 39:case 91:m+=xn(k);break;case 9:case 10:case 13:case 32:m+=Fu(x);break;case 92:m+=Bu(Po()-1,7);continue;case 47:switch(Kt()){case 42:case 47:Lr(Gu(Uu(rt(),Po()),r,o,c),c);break;default:m+="/"}break;case 123*w:f[h++]=ct(m)*S;case 125*w:case 59:case 0:switch(k){case 0:case 125:$=0;case 59+l:S==-1&&(m=ye(m,/\f/g,"")),v>0&&ct(m)-u&&Lr(v>32?ea(m+";",n,o,u-1,c):ea(ye(m," ","")+";",n,o,u-2,c),c);break;case 59:m+=";";default:if(Lr(y=Js(m,r,o,h,l,s,f,P,E=[],z=[],u,a),a),k===123)if(l===0)Ro(m,r,y,y,E,a,u,f,z);else switch(g===99&&We(m,3)===110?100:g){case 100:case 108:case 109:case 115:Ro(t,y,y,n&&Lr(Js(t,y,y,0,0,s,f,P,s,E=[],u,z),z),s,z,u,f,n?E:z);break;default:Ro(m,y,y,y,[""],z,0,f,z)}}h=l=v=0,w=S=1,P=m="",u=p;break;case 58:u=1+ct(m),v=x;default:if(w<1){if(k==123)--w;else if(k==125&&w++==0&&Lu()==125)continue}switch(m+=_s(k),k*w){case 38:S=l>0?1:(m+="\f",-1);break;case 44:f[h++]=(ct(m)-1)*S,S=1;break;case 64:Kt()===45&&(m+=xn(rt())),g=Kt(),l=u=ct(P=m+=Wu(Po())),k++;break;case 45:x===45&&ct(m)==2&&(w=0)}}return a}function Js(t,r,o,n,s,a,p,f,c,h,l,u){for(var g=s-1,v=s===0?a:[""],x=Tc(v),w=0,$=0,S=0;w<n;++w)for(var k=0,P=yr(t,g+1,g=Pc($=p[w])),E=t;k<x;++k)(E=Rc($>0?v[k]+" "+P:ye(P,/&\f/g,v[k])))&&(c[S++]=E);return Xo(t,r,o,s===0?Ko:f,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,f,c,h){return Ie+s+":"+a+h+(p?Ie+s+"-span:"+(f?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="",f=0;f<r;f++)p+=t[f](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*/
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
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.
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 f=[],c=1;c<arguments.length;c++)f[c-1]=arguments[c];ta.test(p)?(a=!1,Jr.delete(n)):s.apply(void 0,tr([p],f,!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),f=0;f<s.length;++f){var c=s[f];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,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.
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 f=this.indexOfGroup(r+1),c=(p=0,o.length);p<c;p++)this.tag.insertRule(f,o[p])&&(this.groupSizes[r]++,f++)},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 f=n[a].trim();if(f){var c=f.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(f)}}},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(f){var c=Array.from(f.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(),f=p.length,c="",h=function(u){var g=function(S){return Fo.get(S)}(u);if(g===void 0)return"continue";var v=a.names.get(g),x=p.getGroup(u);if(v===void 0||!v.size||x.length===0)return"continue";var w="".concat(rr,".g").concat(u,'[id="').concat(g,'"]'),$="";v!==void 0&&v.forEach(function(S){S.length>0&&($+="".concat(S,","))}),c+="".concat(x).concat(w,'{content:"').concat($,'"}').concat(ks)},l=0;l<f;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,f=s.plugins,c=f===void 0?tn:f,h=function(g,v,x){return x.startsWith(o)&&x.endsWith(o)&&x.replaceAll(o,"").length>0?".".concat(r):g},l=c.slice();l.push(function(g){g.type===Ko&&g.value.includes("&")&&(g.props[0]=g.props[0].replace(Cp,o).replace(n,h))}),p.prefix&&l.push(Zu),l.push(Hu);var u=function(g,v,x,w){v===void 0&&(v=""),x===void 0&&(x=""),w===void 0&&(w="&"),r=w,o=v,n=new RegExp("\\".concat(o,"\\b"),"g");var $=g.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(P){return k.push(P)})))),k};return u.hash=c.length?c.reduce(function(g,v){return v.name||zr(15),qt(g,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 f=n(a,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,f)}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 g=us(Qt(u,r,o,n));c=qt(c,g+l),h+=g}}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,f=p===void 0?tn:p,c=r.componentId,h=c===void 0?function(E,z){var y=typeof E!="string"?"sc":ra(E);yn[y]=(yn[y]||0)+1;var m="".concat(y,"-").concat(Fc(en+y+yn[y]));return z?"".concat(z,"-").concat(m):m}(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,g=r.displayName&&r.componentId?"".concat(ra(r.displayName),"-").concat(r.componentId):r.componentId||h,v=n&&s.attrs?s.attrs.concat(f).filter(Boolean):f,x=r.shouldForwardProp;if(n&&s.shouldForwardProp){var w=s.shouldForwardProp;if(r.shouldForwardProp){var $=r.shouldForwardProp;x=function(E,z){return w(E,z)&&$(E,z)}}else x=w}var S=new Rp(o,g,n?s.componentStyle:void 0);function k(E,z){return function(y,m,b){var _=y.attrs,j=y.componentStyle,T=y.defaultProps,R=y.foldedComponentIds,C=y.styledComponentId,I=y.target,M=i.useContext(Xc),F=la(),L=y.shouldForwardProp||F.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(C);var B=Ju(m,M,T)||jr,O=function(re,ne,J){for(var oe,de=Ye(Ye({},ne),{className:void 0,theme:J}),Z=0;Z<re.length;Z+=1){var ae=_r(oe=re[Z])?oe(de):oe;for(var xe in ae)de[xe]=xe==="className"?Zt(de[xe],ae[xe]):xe==="style"?Ye(Ye({},de[xe]),ae[xe]):ae[xe]}return ne.className&&(de.className=Zt(de.className,ne.className)),de}(_,m,B),A=O.as||I,X={};for(var te in O)O[te]===void 0||te[0]==="$"||te==="as"||te==="theme"&&O.theme===B||(te==="forwardedAs"?X.as=O.forwardedAs:L&&!L(te,A)||(X[te]=O[te],L||process.env.NODE_ENV!=="development"||Pu(te)||ua.has(te)||!ls.has(A)||(ua.add(te),console.warn('styled-components: it looks like an unknown prop "'.concat(te,'" 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(re,ne){var J=la(),oe=re.generateAndInjectStyles(ne,J.styleSheet,J.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(oe),oe}(j,O);process.env.NODE_ENV!=="production"&&y.warnTooManyClasses&&y.warnTooManyClasses(V);var q=Zt(R,C);return V&&(q+=" "+V),O.className&&(q+=" "+O.className),X[bn(A)&&!ls.has(A)?"class":"className"]=q,b&&(X.ref=b),i.createElement(A,X)}(P,E,z)}k.displayName=u;var P=i.forwardRef(k);return P.attrs=v,P.componentStyle=S,P.displayName=u,P.shouldForwardProp=x,P.foldedComponentIds=n?Zt(s.foldedComponentIds,s.styledComponentId):"",P.styledComponentId=g,P.target=n?s.target:t,Object.defineProperty(P,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(E){this._foldedDefaultProps=n?function(z){for(var y=[],m=1;m<arguments.length;m++)y[m-1]=arguments[m];for(var b=0,_=y;b<_.length;b++)ps(z,_[b],!0);return z}({},s.defaultProps,E):E}}),process.env.NODE_ENV!=="production"&&(Xu(u,g),P.warnTooManyClasses=function(E,z){var y={},m=!1;return function(b){if(!m&&(y[b]=!0,Object.keys(y).length>=200)){var _=z?' with the id of "'.concat(z,'"'):"";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 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(_,`.
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,7 +70,7 @@ Example:
70
70
  },
71
71
  }))\`width: 100%;\`
72
72
 
73
- <Component />`),m=!0,y={}}}}(u,g)),Ss(P,function(){return".".concat(P.styledComponentId)}),a&&Gc(P,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),P}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(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.
74
74
  Perhaps you're looking to import 'styled-components/native'?
75
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.
76
76
 
@@ -89,7 +89,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
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,...f},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),...f},[...p.map(([h,l])=>i.createElement(h,l)),...Array.isArray(a)?a:[a]]));/**
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]]));/**
93
93
  * @license lucide-react v0.474.0 - ISC
94
94
  *
95
95
  * This source code is licensed under the ISC license.
@@ -507,7 +507,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
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("")),[f,c]=i.useState(60),[h,l]=i.useState(!1),u=i.useRef([]),g=i.useCallback(()=>{const S=setInterval(()=>{c(k=>k<=1?(l(!0),clearInterval(S),0):k-1)},1e3);return S},[]);i.useEffect(()=>{const S=g();return()=>clearInterval(S)},[g]);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(),g())},x=(S,k)=>{var y;if(s)return;const P=S.value,E=[...a];E[k]=P.replace(/[^0-9]/g,""),p(E);const z=E.join("");z.length===t&&r(z),P&&k<t-1&&((y=u.current[k+1])==null||y.focus())},w=(S,k)=>{var P;s||S.key==="Backspace"&&!a[k]&&k>0&&((P=u.current[k-1])==null||P.focus())},$=(S,k)=>{var m,b,_;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 z=[...a];for(let j=0;j<E.length&&k+j<t;j++)z[k+j]=E[j];if(k===0&&E.length===t)for(let j=0;j<t;j++)z[j]=E[j];p(z);const y=z.join("");if(y.length===t)r(y),(m=u.current[t-1])==null||m.focus();else{const j=z.findIndex((T,R)=>R>=k&&!T);if(j!==-1)(b=u.current[j])==null||b.focus();else{const T=z.map((R,C)=>R?C:-1).filter(R=>R!==-1).pop();T!==void 0&&T<t-1&&((_=u.current[T+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:P=>x(P.target,k),onKeyDown:P=>w(P,k),onPaste:P=>$(P,k),ref:P=>{u.current[k]=P},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 ",f,"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(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`
511
511
  display: flex;
512
512
  flex-direction: column;
513
513
  gap: var(--space-xs);
@@ -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((f,c)=>{const h=f.provider;return e.jsxs(qh,{onClick:()=>r(f),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})]},`${f.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"},le=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(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`
555
555
  padding: var(--space-sm) var(--space-md);
556
556
  width: 100%;
557
557
  height: 36px;
@@ -711,9 +711,9 @@ 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(le)`
714
+ `,rf=d(ce)`
715
715
  flex: 1;
716
- `,qr=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:s})=>{const[a,p]=i.useState(!1),[f,c]=i.useState(Oo.find(x=>x.code===n)||Oo[0]),h=i.useRef(null),[l,u]=i.useState(""),g=i.useRef(null);i.useEffect(()=>{function x(w){h.current&&!h.current.contains(w.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(f.dialCode)},[f,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:f.flag}),e.jsx("span",{children:f.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:w=>{var $;w.stopPropagation(),w.preventDefault(),c(x),p(!1),($=g.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:g,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(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`
717
717
  display: flex;
718
718
  justify-content: center;
719
719
  margin-bottom: var(--space-lg);
@@ -921,7 +921,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
921
921
  `,pr=d.span`
922
922
  color: var(--color-danger);
923
923
  margin-left: 2px;
924
- `;function xf(){var V,q,re,ne,J,oe,de,Z,ae,xe,ue,U,pe,K,H,se,me;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=vc(),{signIn:s}=Br("oauth"),{deployment:a}=ve(),{navigate:p}=Ge(),{session:f,refetch:c,loading:h}=Ue(),[l,u]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[g,v]=i.useState({}),[x,w]=i.useState(!1),[$,S]=i.useState(void 0),[k,P]=i.useState(null),[E,z]=i.useState(null),[y,m]=i.useState(!1),b=((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=((ne=(re=a==null?void 0:a.auth_settings)==null?void 0:re.multi_session_support)==null?void 0:ne.enabled)??!1;i.useEffect(()=>{var fe;if(!h&&(f!=null&&f.active_signin)&&!j&&!y){m(!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)}},[f,h,j,a,p,y]),i.useEffect(()=>{var N;if(!a)return;const W=new URLSearchParams(window.location.search).get("invite_token");if(_&&!W){m(!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&&(z(W),r.validateDeploymentInvitation(W).then(D=>{P(D),D.valid&&u(Y=>({...Y,first_name:D.first_name||Y.first_name,last_name:D.last_name||Y.last_name,email:D.email||Y.email}))}).catch(D=>{console.error("Failed to validate invitation:",D)}))},[a,_,p,k,r]);const[T,R]=i.useState(!1),[C,I]=i.useState(""),M=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]:""}))},F=()=>{u({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),v({}),R(!1),I(""),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}$/,Y=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,ie=/^\d{7,15}$/,ee=/^(?=.*[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&&!Y.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&&!ie.test(l.phone_number)&&(W.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(l.password?ee.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"),w(!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{w(!1)}},B=async fe=>{if(!(t||x)){w(!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{w(!1)}}},O=(a==null?void 0:a.social_connections.filter(fe=>fe.enabled))||[],A=a==null?void 0:a.auth_settings,X=!!((J=A==null?void 0:A.first_name)!=null&&J.enabled&&((oe=A==null?void 0:A.last_name)!=null&&oe.enabled)),te=async fe=>{var N;if(fe.preventDefault(),t||x)return;w(!0);const W={};if(!C){W.otp="OTP code is required",v(W),w(!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{w(!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(!T){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,T,a,f,p]),h?e.jsx(ge,{children:e.jsxs(oo,{children:[e.jsx(Pe,{}),e.jsx(ga,{children:e.jsx(kt,{size:32})})]})}):y?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(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:T?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 ${(Z=a==null?void 0:a.ui_settings)==null?void 0:Z.app_name}`:`${l.phone_number} to continue to ${(ae=a==null?void 0:a.ui_settings)==null?void 0:ae.app_name}`})]}),e.jsxs(xa,{style:{gap:"15px"},onSubmit:te,noValidate:!0,children:[e.jsx(Tt,{onComplete:async fe=>{I(fe)},onResend:async()=>{const fe=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:fe})},error:g.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:()=>{F()},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:B}),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:X,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",((K=A==null?void 0:A.first_name)==null?void 0:K.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:M,placeholder:"First name","aria-invalid":!!g.first_name,pattern:"^[a-zA-Z]{3,30}$"}),g.first_name&&e.jsx(At,{children:g.first_name})]}),((H=A==null?void 0:A.last_name)==null?void 0:H.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"last_name",children:["Last name",((se=A==null?void 0:A.last_name)==null?void 0:se.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:M,placeholder:"Last name","aria-invalid":!!g.last_name,pattern:"^[a-zA-Z]{3,30}$"}),g.last_name&&e.jsx(At,{children:g.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(le,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:M,placeholder:"Choose a username","aria-invalid":!!g.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),g.username&&e.jsx(At,{children:g.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(le,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:M,placeholder:"Enter your email address","aria-invalid":!!g.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,}$"}),g.email&&e.jsx(At,{children:g.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:M,error:g.phone_number,countryCode:$,setCountryCode:S}),g.phone_number&&e.jsx(At,{children:g.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(le,{type:"password",id:"password",name:"password",value:l.password,onChange:M,placeholder:"Enter your password","aria-invalid":!!g.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),g.password&&e.jsx(At,{children:g.password})]}),g.submit&&e.jsx(At,{children:g.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 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`
925
925
  position: fixed;
926
926
  inset: 0;
927
927
  background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
@@ -983,7 +983,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
983
983
  display: grid;
984
984
  `,Mf=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 f=c=>{s.current&&!s.current.contains(c.target)&&p(!1)};return a&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[a,o]),i.useEffect(()=>{o==null||o(a)},[a]),i.useEffect(()=>{p(!!r)},[r]),e.jsx(ul.Provider,{value:{open:a,openChange:f=>p(f)},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),f=i.useRef(null);return i.useEffect(()=>{o&&f.current?(p(!1),requestAnimationFrame(()=>{var l,u;const c=(l=f.current)==null?void 0:l.parentElement;if(!c)return;const h=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(h&&h!==f.current){const g=h.getBoundingClientRect(),v=(u=f.current)==null?void 0:u.getBoundingClientRect(),x=window.innerWidth,w=window.innerHeight;let $=g.bottom+4,S=g.right-200;S<8&&(S=g.left),S+200>x-8&&(S=x-208),v&&$+v.height>w-8&&($=g.top-(v.height+4)),s({top:$,left:S}),p(!0)}})):p(!1)},[o]),o?e.jsx(Tf,{ref:f,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(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`
987
987
  width: 100%;
988
988
  padding: 8px 12px;
989
989
  background: none;
@@ -1009,7 +1009,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1009
1009
  display: flex;
1010
1010
  flex-direction: column;
1011
1011
  gap: var(--space-xs);
1012
- `,ce=d.label`
1012
+ `,ie=d.label`
1013
1013
  font-size: var(--font-xs);
1014
1014
  text-align: left;
1015
1015
  font-weight: 400;
@@ -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"}})]}),Q=d.button`
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`
1069
1069
  width: 100%;
1070
1070
  padding: var(--space-sm) var(--space-md);
1071
1071
  border: 1px solid transparent;
@@ -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:f,id:c,groupsEnabled:h=!1,className:l})=>{const[u,g]=i.useState(!1),[v,x]=i.useState(""),w=i.useRef(null),$=i.useRef(null),S=h&&"options"in t[0],P=(S?t.flatMap(m=>m.options):t).find(m=>m.value===r),E=v?S?t.map(m=>({...m,options:m.options.filter(b=>b.label.toLowerCase().includes(v.toLowerCase()))})).filter(m=>m.options.length>0):t.filter(m=>m.label.toLowerCase().includes(v.toLowerCase())):t,z=(m,b=!1)=>{b||(o(m),g(!1),x(""))},y=()=>{s||g(!u)};return i.useEffect(()=>{u&&a&&$.current&&setTimeout(()=>{var m;(m=$.current)==null||m.focus()},10)},[u,a]),i.useEffect(()=>{const m=b=>{w.current&&!w.current.contains(b.target)&&(g(!1),x(""))};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),e.jsxs(hl,{ref:w,style:{width:p},className:l,children:[e.jsxs(fl,{type:"button",onClick:y,disabled:s,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[P?P.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:m=>x(m.target.value),onClick:m=>m.stopPropagation()}),S?E.map((m,b)=>e.jsxs(i.Fragment,{children:[e.jsx(vl,{children:m.label}),m.options.length===0?e.jsx(Vo,{children:"No options available"}):m.options.map(_=>e.jsxs(Wo,{isSelected:_.value===r,disabled:_.disabled,onClick:()=>z(_.value,_.disabled),role:"option","aria-selected":_.value===r,children:[_.label,_.value===r&&e.jsx(Ve,{size:16})]},_.value))]},`group-${b}`)):e.jsx(e.Fragment,{children:E.length===0?e.jsx(Vo,{children:"No options available"}):E.map(m=>e.jsxs(Wo,{isSelected:m.value===r,disabled:m.disabled,onClick:()=>z(m.value,m.disabled),role:"option","aria-selected":m.value===r,children:[m.label,m.value===r&&e.jsx(Ve,{size:16})]},m.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r||""})]})},bl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:s=!1,searchable:a=!1,width:p,name:f,id:c,groupsEnabled:h=!1,className:l})=>{const[u,g]=i.useState(!1),[v,x]=i.useState(""),w=i.useRef(null),$=i.useRef(null),S=h&&"options"in t[0],P=(S?t.flatMap(m=>m.options):t).filter(m=>r.includes(m.value)),E=v?S?t.map(m=>({...m,options:m.options.filter(b=>b.label.toLowerCase().includes(v.toLowerCase()))})).filter(m=>m.options.length>0):t.filter(m=>m.label.toLowerCase().includes(v.toLowerCase())):t,z=(m,b=!1)=>{b||(r.includes(m)?o(r.filter(_=>_!==m)):o([...r,m]))},y=()=>{s||g(!u)};return i.useEffect(()=>{u&&a&&$.current&&setTimeout(()=>{var m;(m=$.current)==null||m.focus()},10)},[u,a]),i.useEffect(()=>{const m=b=>{w.current&&!w.current.contains(b.target)&&(g(!1),x(""))};return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]),e.jsxs(hl,{ref:w,style:{width:p},className:l,children:[e.jsxs(fl,{type:"button",onClick:y,disabled:s,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[P.length>0?P.map(m=>m.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:m=>x(m.target.value),onClick:m=>m.stopPropagation()}),S?E.map((m,b)=>e.jsxs(i.Fragment,{children:[e.jsx(vl,{children:m.label}),m.options.length===0?e.jsx(Vo,{children:"No options available"}):m.options.map(_=>e.jsxs(Wo,{isSelected:r.includes(_.value),disabled:_.disabled,onClick:()=>z(_.value,_.disabled),role:"option","aria-selected":r.includes(_.value),children:[_.label,r.includes(_.value)&&e.jsx(Ve,{size:16})]},_.value))]},`group-${b}`)):e.jsx(e.Fragment,{children:E.length===0?e.jsx(Vo,{children:"No options available"}):E.map(m=>e.jsxs(Wo,{isSelected:r.includes(m.value),disabled:m.disabled,onClick:()=>z(m.value,m.disabled),role:"option","aria-selected":r.includes(m.value),children:[m.label,r.includes(m.value)&&e.jsx(Ve,{size:16})]},m.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,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,f]=i.useState(!1),[c,h]=i.useState(!1),[l,u]=i.useState(!1),[g,v]=i.useState("identifier"),x=(r==null?void 0:r.social_connections.filter($=>$.enabled))||[],w=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:f,setShowForgotPassword:h,setOtpSent:u,enabledSocialsProviders:x,authSettings:w,firstFactor:o,signInStep:g,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),[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`
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,f]=i.useState(!1),c=t==null?void 0:t.auth_settings,h=(t==null?void 0:t.social_connections.filter(g=>g.enabled))||[],l=async g=>{if(!p){f(!0);try{const{data:v}=await r.create({provider:g.provider});v&&typeof v=="object"&&"oauth_url"in v&&(window.location.href=v.oauth_url)}catch{}finally{f(!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: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`
1234
1234
  max-width: 380px;
1235
1235
  width: 380px;
1236
1236
  padding: var(--space-3xl);
@@ -1253,7 +1253,7 @@ 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(Q)`
1256
+ `,Wf=d(X)`
1257
1257
  width: 100%;
1258
1258
  margin-bottom: var(--space-lg);
1259
1259
  `,Vf=d.div`
@@ -1294,7 +1294,7 @@ 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(""),[f,c]=i.useState(""),[h,l]=i.useState(""),[u,g]=i.useState(""),[v,x]=i.useState(""),{forgotPassword:w,verifyOtp:$,resetPassword:S}=kc(),[k,P]=i.useState(!1),[E,z]=i.useState(null),y=async j=>{if(j.preventDefault(),!!a){P(!0),z(null);try{await w(a),s("otp")}catch(T){z(T)}finally{P(!1)}}},m=async j=>{if(j.preventDefault(),f.length===6){P(!0),z(null);try{const T=await $(a,f);T.data&&(l(T.data.token),s("reset"))}catch(T){z(T)}finally{P(!1)}}},b=async j=>{var T,R;if(j.preventDefault(),u===v&&!(u.length<8)){P(!0),z(null);try{const C=await S(h,u);if(C.data){const I=C.data,M=I.signin_attempts&&I.signin_attempts.length>0?I.signin_attempts[I.signin_attempts.length-1]:null;if(M&&!M.completed){const F=(T=r==null?void 0:r.ui_settings)==null?void 0:T.sign_in_page_url;if(F){const L=new URL(F,window.location.origin);L.searchParams.set("signin_attempt_id",M.id),o(L.toString())}else t()}else{const F=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";o(F)}}}catch(C){z(C)}finally{P(!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:y,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"email",children:"Email Address"}),e.jsx(le,{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(Q,{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:m,noValidate:!0,children:[e.jsx(Tt,{onComplete:j=>c(j),isSubmitting:k,error:E==null?void 0:E.message,onResend:async()=>{await w(a)}}),E&&e.jsx(En,{children:E.message}),e.jsx(Q,{type:"submit",disabled:k||f.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:b,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"password",children:"New Password"}),e.jsx(le,{type:"password",id:"password",value:u,onChange:j=>g(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(le,{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(Q,{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 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`
1298
1298
  max-width: 360px;
1299
1299
  width: 360px;
1300
1300
  padding: var(--space-2xl);
@@ -1436,7 +1436,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[ro]+=1);/**
1436
1436
  color: var(--color-error);
1437
1437
  margin: 0;
1438
1438
  margin-top: var(--space-2xs);
1439
- `,gg=d(Q)`
1439
+ `,gg=d(X)`
1440
1440
  margin-top: var(--space-sm);
1441
1441
  width: 100%;
1442
1442
  `,mg=d.div`
@@ -1454,9 +1454,9 @@ 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(le)`
1457
+ `,vg=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(""),f=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:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{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(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`
1460
1460
  max-width: 380px;
1461
1461
  width: 380px;
1462
1462
  padding: var(--space-3xl);
@@ -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(Q)`
1501
+ `,kg=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(le)`
1518
+ `,Cg=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(""),[f,c]=i.useState({}),[h,l]=i.useState(!1),[u,g]=i.useState(null),[v,x]=i.useState(!0),[w,$]=i.useState(!1),[S,k]=i.useState(""),[P,E]=i.useState(!1),{navigate:z}=Ge(),y=(r==null?void 0:r.available_2fa_methods)||[],m=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(bg,{}),available:y.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(yg,{}),available:y.includes("phone_otp"),phoneNumber:S},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(wg,{}),available:y.includes("backup_code")}].filter(R=>R.available),b=async R=>{g(R),x(!1),R==="phone_otp"&&$(!0)},_=async R=>{var C,I;if(r){l(!0);try{const M=await n({strategy:"phone_otp",lastDigits:R});M&&"data"in M&&((C=M.data)!=null&&C.otp_sent)?((I=M.data)!=null&&I.masked_phone&&k(M.data.masked_phone),$(!1)):c({phone:"Phone number verification failed"})}catch(M){c({phone:M.message})}finally{l(!1)}}},j=async(R,C)=>{if(R.preventDefault(),h)return;const I=C||a,M={};if(I?u==="authenticator"&&I.length!==6?M.code="Authentication code must be 6 digits":u==="phone_otp"&&I.length!==6&&(M.code="SMS code must be 6 digits"):M.code="Verification code is required",c(M),!(Object.keys(M).length>0)){l(!0);try{await o(I)}catch(F){c({submit:F.message})}finally{l(!1)}}},T=R=>{let C=R.target.value;u!=="backup_code"&&(C=C.replace(/\D/g,"").slice(0,6)),p(C),c(I=>({...I,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 I;try{I=new URL(C)}catch{I=new URL(C,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&I.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),z(I.toString())}return}},[r,s]),P?e.jsx(ge,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsx(_g,{children:e.jsx(kt,{size:32})})]})}):v?m.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:m,onSelectMethod:b,onBack:t}):w&&u==="phone_otp"?e.jsx(kl,{onVerify:_,onBack:()=>{$(!1),x(!0),g(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(ce,{htmlFor:"code",children:"Backup code"}),e.jsx(Cg,{type:"text",id:"code",name:"code",value:a,onChange:T,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!f.code,autoFocus:!0}),f.code&&e.jsx(Ca,{children:f.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:f.code,isSubmitting:h}),e.jsxs("div",{children:[f.submit&&e.jsx(Ca,{children:f.submit}),e.jsx(kg,{type:"submit",disabled:h||!a,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(Sa,{children:[e.jsx(Tr,{onClick:()=>{x(!0),g(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),[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`
1521
1521
  max-width: 380px;
1522
1522
  width: 380px;
1523
1523
  padding: var(--space-3xl);
@@ -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(Q)`
1549
+ `,zg=d(X)`
1550
1550
  margin-top: var(--space-sm);
1551
1551
  `,Ia=d.div`
1552
1552
  margin-top: var(--space-lg);
@@ -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 B,O,A,X,te,V,q,re,ne;const{deployment:a}=ve(),{navigate:p}=Ge(),[f,c]=i.useState({}),[h,l]=i.useState({}),[u,g]=i.useState("US"),[v,x]=i.useState(!1),[w,$]=i.useState(!1),[S,k]=i.useState(null),[P,E]=i.useState(!1),z=S,y=w,m=async J=>{var oe;$(!0),k(null);try{if(await o(J)){E(!0);let Z=new URLSearchParams(window.location.search).get("redirect_uri");if(Z||(Z=((oe=a==null?void 0:a.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Z&&(a!=null&&a.frontend_host)&&(Z=`https://${a.frontend_host}`),Z){let ae;try{ae=new URL(Z)}catch{ae=new URL(Z,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&ae.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(ae.toString())}}}catch(de){const Z=de;throw k(Z),Z}finally{$(!1)}},b=async J=>{var oe;$(!0),k(null);try{if(await n(J)){E(!0);let Z=new URLSearchParams(window.location.search).get("redirect_uri");if(Z||(Z=((oe=a==null?void 0:a.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Z&&(a!=null&&a.frontend_host)&&(Z=`https://${a.frontend_host}`),Z){let ae;try{ae=new URL(Z)}catch{ae=new URL(Z,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&ae.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(ae.toString())}}return!0}catch(de){return k(de),!1}finally{$(!1)}};if(P||!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",T="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,I=J=>{const{name:oe,value:de}=J.target;c(Z=>({...Z,[oe]:de})),h[oe]&&l(Z=>({...Z,[oe]:""}))},M=()=>{const J={};return _.forEach(oe=>{var ae,xe,ue,U,pe;const de=f[oe];let Z=!1;switch(oe){case"first_name":Z=((ae=R==null?void 0:R.first_name)==null?void 0:ae.enabled)||!1;break;case"last_name":Z=((xe=R==null?void 0:R.last_name)==null?void 0:xe.enabled)||!1;break;case"username":Z=((ue=R==null?void 0:R.username)==null?void 0:ue.enabled)||!1;break;case"phone_number":Z=((U=R==null?void 0:R.phone_number)==null?void 0:U.enabled)||!1;break;case"email_address":Z=((pe=R==null?void 0:R.email_address)==null?void 0:pe.enabled)||!1;break;default:Z=!0}if(Z&&(!de||de.trim()==="")){const K=oe.replace("_"," ").replace(/\b\w/g,H=>H.toUpperCase());J[oe]=`${K} is required`}}),f.username&&_.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(f.username)||(J.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),f.phone_number&&_.includes("phone_number")&&(/^\d{7,15}$/.test(f.phone_number)||(J.phone_number="Phone number must contain 7-15 digits")),f.email&&_.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(f.email)||(J.email_address="Please enter a valid email address")),l(J),Object.keys(J).length===0},F=async J=>{if(J.preventDefault(),!M())return;const oe={...f};f.phone_number&&u&&(oe.phone_country_code=u),await m(oe)},L=J=>{const oe=J.target.value;c(de=>({...de,phone_number:oe})),h.phone_number&&l(de=>({...de,phone_number:""}))};if(C){const J=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:J}),e.jsx(Ea,{children:oe})]}),e.jsxs(dt,{onSubmit:Z=>Z.preventDefault(),noValidate:!0,children:[e.jsx(Tt,{onComplete:b,onResend:async()=>{await s({strategy:de})},error:z==null?void 0:z.message,isSubmitting:y}),z&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:z.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:T})]}),e.jsxs(dt,{onSubmit:F,noValidate:!0,children:[(_.includes("first_name")||_.includes("last_name"))&&(((B=R==null?void 0:R.first_name)==null?void 0:B.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&&((X=R==null?void 0:R.last_name)!=null&&X.enabled)&&_.includes("first_name")&&_.includes("last_name")),children:[_.includes("first_name")&&((te=R==null?void 0:R.first_name)==null?void 0:te.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",value:f.first_name||"",onChange:I,placeholder:"Enter your first name","aria-invalid":!!h.first_name,disabled:y,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(ce,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",value:f.last_name||"",onChange:I,placeholder:"Enter your last name","aria-invalid":!!h.last_name,disabled:y,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(ce,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),e.jsx(le,{type:"text",id:"username",name:"username",value:f.username||"",onChange:I,placeholder:"Choose a username","aria-invalid":!!h.username,disabled:y,autoComplete:"username"}),h.username&&e.jsx(Lt,{children:h.username})]}),_.includes("phone_number")&&((re=R==null?void 0:R.phone_number)==null?void 0:re.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),e.jsx(qr,{value:f.phone_number||"",onChange:L,error:h.phone_number,countryCode:u,setCountryCode:g}),h.phone_number&&e.jsx(Lt,{children:h.phone_number})]}),_.includes("email_address")&&((ne=R==null?void 0:R.email_address)==null?void 0:ne.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),e.jsx(le,{type:"email",id:"email",name:"email",value:f.email||"",onChange:I,placeholder:"Enter your email address","aria-invalid":!!h.email_address,disabled:y,autoComplete:"email"}),h.email_address&&e.jsx(Lt,{children:h.email_address})]}),z&&e.jsx(Lt,{style:{marginBottom:"var(--space-md)"},children:z.message}),e.jsx(zg,{type:"submit",disabled:y,children:y?"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"),[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`
1586
1586
  from {
1587
1587
  transform: rotate(0deg);
1588
1588
  }
@@ -1649,7 +1649,7 @@ position: relative;
1649
1649
  color: var(--color-error);
1650
1650
  margin: 0;
1651
1651
  margin-top: var(--space-2xs);
1652
- `,Oa=d(Q)`
1652
+ `,Oa=d(X)`
1653
1653
  margin-top: var(--space-lg);
1654
1654
  `,Tn=d.div`
1655
1655
  margin-top: var(--space-lg);
@@ -1691,7 +1691,7 @@ 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,Z,ae,xe,ue,U,pe,K,H,se,me,fe;const{deployment:t}=ve(),{navigate:r}=Ge(),{session:o,loading:n}=Ue(),s=((Z=(de=t==null?void 0:t.auth_settings)==null?void 0:de.multi_session_support)==null?void 0:Z.enabled)??!1,{setEmail:a,otpSent:p,setOtpSent:f,showForgotPassword:c,setShowForgotPassword:h,showOtherOptions:l,setShowOtherOptions:u,enabledSocialsProviders:g,firstFactor:v,signInStep:x,setSignInStep:w}=wl(),{loading:$,signIn:S,signinAttempt:k,discardSignInAttempt:P,setSignInAttempt:E}=Br("generic"),{signIn:z}=Br("oauth"),[y,m]=i.useState({email:"",username:"",password:"",phone:""}),[b,_]=i.useState({}),[j,T]=i.useState(!1),[R,C]=i.useState(""),[I,M]=i.useState("US"),[F,L]=i.useState(!1),[B,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 Y=W.toString()?`${window.location.pathname}?${W.toString()}`:window.location.pathname;window.history.replaceState({},"",Y)}},[]),i.useEffect(()=>{var W;if(!n&&(o!=null&&o.active_signin)&&!s&&!F){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,F]);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()),m(Y=>({...Y,[N]:D})),_(Y=>({...Y,[N]:""}))},X=()=>{m({email:"",username:"",password:"",phone:""}),_({}),M("US"),w("identifier")},te=async W=>{if(!W){_({email:"Email address is required"});return}T(!0),_({});try{const N=await S.identify(W);if(N.strategy==="sso"&&N.connection_id){const Y=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,ie=await S.initEnterpriseSso(N.connection_id,Y);if(ie&&ie.sso_url){L(!0),window.location.href=ie.sso_url;return}}else if(N.strategy==="social"&&N.provider){const D=g.find(Y=>Y.provider===N.provider);if(D){const ie=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:ee}=await z.create({provider:D.provider,redirectUri:ie});if(ee&&typeof ee=="object"&&"oauth_url"in ee){L(!0),window.location.href=ee.oauth_url;return}}else w("password")}else w("password")}catch(N){_({submit:N.message})}finally{F||T(!1)}},V=async W=>{if(W.preventDefault(),$||j)return;P();const N={};if(x==="identifier"&&v==="email_password"){if(!y.email){_({email:"Email address is required"});return}await te(y.email);return}if(v==="email_password"?(y.email||(N.email="Email address is required"),y.password||(N.password="Password is required")):v==="username_password"?(y.username||(N.username="Username is required"),y.password||(N.password="Password is required")):v==="email_otp"||v==="email_magic_link"?y.email||(N.email="Email address is required"):v==="phone_otp"&&(y.phone?/^\d{7,15}$/.test(y.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}T(!0);try{const Y={...y,strategy:D};v==="phone_otp"&&I&&(Y.phone_country_code=I),await S.create(Y)}catch(Y){_({submit:Y.message}),T(!1)}},q=async W=>{if(W.preventDefault(),$||j)return;const N={};if(!R){N.otp="OTP code is required",_(N);return}T(!0),_({});try{await S.completeVerification(R),f(!1),C("")}catch(D){_({otp:D.message||"Verification failed"})}finally{T(!1)}},re=async W=>{if(!($||j)){T(!0);try{const D=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Y}=await z.create({provider:W.provider,redirectUri:D});Y&&typeof Y=="object"&&"oauth_url"in Y&&(window.location.href=Y.oauth_url)}catch(N){_({submit:N.message})}finally{T(!1)}}},ne=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const W=new URLSearchParams(window.location.search),N=W.get("impersonation_token");if(N&&!k&&!$&&!ne.current){ne.current=!0,W.delete("impersonation_token");const Y=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",Y),(async()=>{try{T(!0),await S.create({strategy:"impersonation",token:N})}catch(ee){_({submit:ee.message}),T(!1),ne.current=!1}})();return}const D=W.get("signin_attempt_id");if(D&&(o!=null&&o.signin_attempts)&&!k){const Y=o.signin_attempts.find(ie=>ie.id===D);if(Y){E(Y),W.delete("signin_attempt_id");const ie=W.toString()?`${window.location.pathname}?${W.toString()} `:window.location.pathname;window.history.replaceState({},"",ie)}}},[o,n,k,E,$]),i.useEffect(()=>{var Y;if(!k)return;if(k.completed){L(!0);let ie=new URLSearchParams(window.location.search).get("redirect_uri");if(ie||(ie=((Y=t==null?void 0:t.ui_settings)==null?void 0:Y.after_signin_redirect_url)||null),!ie&&(t!=null&&t.frontend_host)&&(ie=`https://${t.frontend_host}`),ie){let ee;try{ee=new URL(ie)}catch{ee=new URL(ie,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&ee.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(ee.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}),f(!0)}catch(ie){console.error("Failed to prepare verification:",ie),_({submit:"Failed to send verification. Please try again."})}finally{T(!1)}})()},[k,S,p,f,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:()=>{P(),X(),f(!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:()=>{P(),X(),f(!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(F)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 ${y.email} exists in our records, you will receive a magic link. Click the link to sign in.`:v==="phone_otp"?`If ${y.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${y.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","!"]})]}),B&&e.jsxs(Tg,{children:[e.jsx(Mg,{children:"Access Denied"}),e.jsx(Og,{children:B}),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:()=>{f(!1),P(),X()},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){T(!0),_({});try{await S.completeVerification(W),f(!1)}catch(N){_({otp:N.message||"Verification failed"})}finally{T(!1)}}},onResend:async()=>{const W=v==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:W})},error:b.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:()=>{f(!1),P(),X()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Es,{connections:g,callback:re}),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=(ae=t==null?void 0:t.auth_settings)==null?void 0:ae.email_address)==null?void 0:xe.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"email",children:"Email address"}),e.jsx(le,{type:"email",id:"email",name:"email",value:y.email,onChange:A,placeholder:"Enter your email address","aria-invalid":!!b.email}),b.email&&e.jsx(Mr,{children:b.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(ce,{htmlFor:"username",children:"Username"}),e.jsx(le,{type:"text",id:"username",name:"username",value:y.username,onChange:A,placeholder:"Enter your username","aria-invalid":!!b.username}),b.username&&e.jsx(Mr,{children:b.username})]}),v==="phone_otp"&&((K=(pe=t==null?void 0:t.auth_settings)==null?void 0:pe.phone_number)==null?void 0:K.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"phone",children:"Phone number"}),e.jsx(qr,{value:y.phone,onChange:A,error:b.phone,countryCode:I,setCountryCode:M}),b.phone&&e.jsx(Mr,{children:b.phone})]}),x==="password"&&(v==="email_password"||v==="username_password")&&((se=(H=t==null?void 0:t.auth_settings)==null?void 0:H.password)==null?void 0:se.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ce,{htmlFor:"password",children:"Password"}),e.jsx(Dt,{style:{fontSize:"12px"},onClick:()=>h(!0),children:"Forgot password?"})]}),e.jsx(Rg,{children:e.jsx(le,{type:"password",id:"password",name:"password",value:y.password,onChange:A,placeholder:"Enter your password","aria-invalid":!!b.password})}),b.password&&e.jsx(Mr,{children:b.password})]}),e.jsxs("div",{children:[b.submit&&e.jsx(Mr,{children:b.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 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`
1695
1695
  max-width: 380px;
1696
1696
  width: 380px;
1697
1697
  padding: var(--space-3xl);
@@ -1792,7 +1792,7 @@ cursor: pointer;
1792
1792
  color: var(--color-primary);
1793
1793
  text-decoration: none;
1794
1794
  cursor: pointer;
1795
- `;function Xg(){var $,S,k,P,E,z,y,m,b,_,j,T;const{deployment:t}=ve(),{loading:r,joinWaitlist:o}=yc(),[n,s]=i.useState({first_name:"",last_name:"",email:""}),[a,p]=i.useState(!1),[f,c]=i.useState(!1),[h,l]=i.useState(null),u=R=>{if(h)return h.message},g=t==null?void 0:t.auth_settings,v=!!(($=g==null?void 0:g.first_name)!=null&&$.enabled&&((S=g==null?void 0:g.last_name)!=null&&S.enabled)),x=R=>{const{name:C,value:I}=R.target;s(M=>({...M,[C]:I}))},w=async R=>{if(R.preventDefault(),!!g){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:w,noValidate:!0,children:[(((k=g==null?void 0:g.first_name)==null?void 0:k.enabled)||((P=g==null?void 0:g.last_name)==null?void 0:P.enabled))&&e.jsxs(Wg,{$isBothEnabled:v,children:[((E=g==null?void 0:g.first_name)==null?void 0:E.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"first_name",children:["First name",((z=g==null?void 0:g.first_name)==null?void 0:z.required)&&e.jsx(An,{children:"*"})]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",required:(y=g==null?void 0:g.first_name)==null?void 0:y.required,minLength:2,maxLength:50,value:n.first_name,onChange:x,placeholder:"First name","aria-invalid":!!u()}),u()&&e.jsx(co,{children:u()})]}),((m=g==null?void 0:g.last_name)==null?void 0:m.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"last_name",children:["Last name",((b=g==null?void 0:g.last_name)==null?void 0:b.required)&&e.jsx(An,{children:"*"})]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",required:(_=g==null?void 0:g.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=g==null?void 0:g.email_address)==null?void 0:j.required)&&e.jsx(An,{children:"*"})]}),e.jsx(le,{type:"email",id:"email",name:"email",required:(T=g==null?void 0:g.email_address)==null?void 0:T.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:f||r,children:f||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 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`
1796
1796
  max-width: 380px;
1797
1797
  width: 380px;
1798
1798
  padding: var(--space-3xl);
@@ -1879,7 +1879,7 @@ 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:f}=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||f)){if(a&&!a.completed){const g=(l=t==null?void 0:t.ui_settings)==null?void 0:l.sign_in_page_url;if(g){const v=new URL(g,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 g=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(g)}catch{v=new URL(g,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,f,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]),f&&!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(Q,{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 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`
1883
1883
  max-width: 380px;
1884
1884
  width: 380px;
1885
1885
  padding: var(--space-3xl);
@@ -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:f,redirectUri:c}=_c(),{verifyMagicLink:h}=jc(),{navigate:l}=Ge(),{deployment:u}=ve(),g=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!g.current){if(!p||!f){n("error"),a("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}g.current=!0,n("loading"),a("Please wait while we verify your magic link.");try{await h({token:p,attempt:f,redirectUri:c}),n("success"),a("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var $;let w=c;if(w||(w=($=u==null?void 0:u.ui_settings)==null?void 0:$.after_signin_redirect_url),!w&&(u!=null&&u.frontend_host)&&(w=`https://${u.frontend_host}`),w){const S=new URL(w);(u==null?void 0:u.mode)==="staging"&&S.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),l(S.toString())}},2e3)}catch(w){n("error"),a("The magic link may have expired or already been used. Please try signing in again."),r==null||r(w.message)}}})()},[p,f]);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(Q,{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,f;return((p=a.missing_fields)==null?void 0:p.length)>0||((f=a.remaining_steps)==null?void 0:f.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 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`
1948
1948
  max-width: 380px;
1949
1949
  width: 380px;
1950
1950
  padding: var(--space-3xl);
@@ -2044,7 +2044,7 @@ cursor: pointer;
2044
2044
  &:hover {
2045
2045
  color: var(--color-primary-hover);
2046
2046
  }
2047
- `;function bm({token:t,onSuccess:r,onError:o}){var w;const{acceptInvitation:n,invitationData:s,loading:a,error:p}=$c(),{navigate:f}=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();f($)},g=()=>{var m,b;const{token:$}=l(),S=((m=c==null?void 0:c.ui_settings)==null?void 0:m.sign_in_page_url)||"/sign-in",k=((b=c==null?void 0:c.ui_settings)==null?void 0:b.sign_up_page_url)||"/sign-up",P=new URLSearchParams;$&&P.set("invite_token",$),s!=null&&s.invited_email&&P.set("invited_email",s.invited_email);const z=`${window.location.pathname}?token=${$}`;P.set("redirect_uri",z),s!=null&&s.message&&P.set("message",s.message);const y=(s==null?void 0:s.error_code)==="INVITATION_REQUIRES_SIGNUP";f(`${y?k:S}?${P.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(Q,{onClick:()=>f("/"),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(Q,{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 ",((w=s.organization)==null?void 0:w.name)||"this organization"]}),e.jsx(Gt,{children:"No action needed - you already have access."}),e.jsx(Q,{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(Q,{onClick:g,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(Q,{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:g,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 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`
2048
2048
  display: flex;
2049
2049
  height: 100%;
2050
2050
  min-height: 400px;
@@ -2233,7 +2233,7 @@ cursor: pointer;
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,f]=i.useState(),[c,h]=i.useState(null),[l,u]=i.useState(!1),g=i.useRef(null),{createOrganization:v}=Yo(),{toast:x}=He(),w=y=>{n(y)},$=y=>{if(y.target.files&&y.target.files[0]){const m=y.target.files[0];if(m.size>2*1024*1024){x("File size cannot exceed 2MB","error");return}if(!m.type.startsWith("image/")){x("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),f(m),h(URL.createObjectURL(m))}},S=()=>{var y;(y=g.current)==null||y.click()},k=y=>y.split(" ").map(m=>m[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const P=y=>y.trim().replace(/[<>\"'&]/g,""),E=y=>y.length>=2&&y.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(y),z=async()=>{const y=P(o),m=P(s);if(!y){x("Please enter an organization name","error");return}if(!E(y)){x("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(m.length>500){x("Description must be less than 500 characters","error");return}u(!0);try{const b=await v({name:y,description:m,image:p});t==null||t(b)}catch(b){const _=b.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:g,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:y=>w(y.target.value),placeholder:"Acme Inc.",disabled:l})]}),e.jsxs(Fa,{children:[e.jsx(Ba,{children:"Description (optional)"}),e.jsx(Rm,{value:s,onChange:y=>a(y.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:z,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: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`
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,f]=i.useState(""),[c,h]=i.useState(!1),[l,u]=i.useState(!1),[g,v]=i.useState({top:0,left:0}),{addDomain:x,verifyDomain:w}=Ze(),{toast:$}=He(),S=z=>/^[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(z),k=z=>z.trim().toLowerCase().replace(/^https?:\/\//,""),P=async()=>{const z=k(p);if(!z){$("Please enter a domain name","error");return}if(!S(z)){$("Please enter a valid domain name (e.g., example.com)","error");return}if(z.length>253){$("Domain name is too long","error");return}try{const y=await x({fqdn:z});$("Domain added successfully","info"),a(y.data)}catch(y){const m=y.message||"Failed to add domain. Please try again.";$(m,"error")}},E=async()=>{if(!(!s||c)){h(!0);try{await w(s),t==null||t(),$("Domain verified successfully","info")}catch(z){const y=z.message||"Failed to verify domain. Please check DNS records and try again.";$(y,"error")}finally{h(!1)}}};return i.useEffect(()=>{u(!0);const z=setTimeout(()=>{if(!n.current)return;const b=o==null?void 0:o.current,_=360,j=250,T=8;let R=0,C=0;if(!b){const L=n.current.getBoundingClientRect(),B=L.width||_,O=L.height||j;R=Math.max(T,(window.innerHeight-O)/2),C=Math.max(T,(window.innerWidth-B)/2),v({top:R,left:C});return}const I=b.getBoundingClientRect(),M=window.innerHeight-I.bottom,F=I.top;M>=j+T?(R=I.bottom+T,C=I.right-_,C<T&&(C=I.left,C+_>window.innerWidth-T&&(C=(window.innerWidth-_)/2))):F>=j+T?(R=I.top-j-T,C=I.right-_,C<T&&(C=I.left,C+_>window.innerWidth-T&&(C=(window.innerWidth-_)/2))):(R=I.bottom+T,C=I.right-_,C<T&&(C=I.left)),v({top:R,left:C})},10),y=b=>{n.current&&!n.current.contains(b.target)&&(t==null||t())},m=b=>{b.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",y),document.addEventListener("keydown",m),()=>{clearTimeout(z),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",m)}},[t,o]),i.useEffect(()=>{r&&a(r)},[r]),l?e.jsx(Fm,{ref:n,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:z=>z.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(ce,{children:"Record Type"}),e.jsx(le,{value:s==null?void 0:s.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Record Name"}),e.jsx(le,{value:s==null?void 0:s.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Record Data"}),e.jsx(le,{type:"text",value:s==null?void 0:s.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Ga,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{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(ce,{children:"Enter FQDN"}),e.jsx(le,{type:"text",placeholder:"Enter your domain",value:p,onChange:z=>f(z.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Ga,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:P,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,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`
2286
2286
  position: fixed;
2287
2287
  width: 360px;
2288
2288
  max-width: calc(100vw - 48px);
@@ -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(""),[f,c]=i.useState(null),[h,l]=i.useState(!1),[u,g]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{inviteMember:w}=Ze(),{toast:$}=He(),S=o.map(E=>({value:E.id,label:E.name})),k=E=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E),P=async()=>{const E=a.trim().toLowerCase();if(!(!E||!f)){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 w({email:E,organizationRole:f}),r==null||r()}catch(z){const y=z.message||"Failed to send invitation. Please try again.";$(y,"error")}finally{l(!1)}}};return i.useEffect(()=>{g(!0);const E=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const m=n.current;if(m){const b=m.getBoundingClientRect(),_=360,j=250,T=8;let R=0,C=0;const I=window.innerHeight-b.bottom,M=b.top;I>=j+T?(R=b.bottom+T,C=b.right-_,C<T&&(C=b.left,C+_>window.innerWidth-T&&(C=(window.innerWidth-_)/2))):M>=j+T?(R=b.top-j-T,C=b.right-_,C<T&&(C=b.left,C+_>window.innerWidth-T&&(C=(window.innerWidth-_)/2))):(R=b.bottom+T,C=b.right-_,C<T&&(C=b.left)),x({top:R,left:C})}},10),z=m=>{s.current&&!s.current.contains(m.target)&&(t==null||t())},y=m=>{m.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",z),document.addEventListener("keydown",y),()=>{clearTimeout(E),document.removeEventListener("mousedown",z),document.removeEventListener("keydown",y)}},[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(ce,{children:"Email Address"}),e.jsx(le,{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(ce,{children:"Role"}),e.jsx(Is,{options:S,value:f==null?void 0:f.id,onChange:E=>c(o.find(z=>z.id===E)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Gm,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:P,disabled:!a||!f||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),[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`
2335
2335
  position: fixed;
2336
2336
  width: 400px;
2337
2337
  max-width: calc(100vw - 48px);
@@ -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 y;const s=i.useRef(null),[a,p]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]);Ze();const[h,l]=i.useState(!1),[u,g]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{deployment:w}=ve(),{toast:$}=He(),S=!!o,k=Array.isArray((y=w==null?void 0:w.b2b_settings)==null?void 0:y.organization_permissions)?w.b2b_settings.organization_permissions.map(m=>({value:m,label:m})):[];i.useEffect(()=>{g(!0);const m=setTimeout(()=>{if(!s.current)return;let T=null;if(n!=null&&n.current)T=n.current;else if(S){const R=document.querySelectorAll("[data-role-dropdown-trigger]");for(let C=0;C<R.length;C++){const I=R[C];if(I.offsetParent!==null){T=I;break}}}else{const R=document.querySelectorAll("button");for(let C=0;C<R.length;C++){const I=R[C];if(I.textContent==="Add role"&&I.offsetParent!==null){T=I;break}}}if(T){const R=T.getBoundingClientRect(),C=400;let I=R.bottom+8,M=R.right-C;M<10&&(M=R.left),I+300>window.innerHeight&&(I=R.top-300-8),x({top:I,left:M})}},10),b=T=>{s.current&&!s.current.contains(T.target)&&(t==null||t())},_=T=>{T.key==="Escape"&&(t==null||t())},j=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",_)},100);return()=>{clearTimeout(m),clearTimeout(j),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",_)}},[t,S,n]);const P=m=>m.trim().replace(/[<>\"'&]/g,""),E=m=>m.length>=2&&m.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(m),z=async()=>{const m=P(a);if(!m){$("Please enter a role name","error");return}if(!E(m)){$("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(f.length===0){$("Please select at least one permission","error");return}l(!0);try{const b={id:o==null?void 0:o.id,name:m,permissions:f||[]};r==null||r(b)}catch(b){const _=b.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:m=>m.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(ce,{children:"Role Name"}),e.jsx(le,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:a,onChange:m=>p(m.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Permissions"}),e.jsx(bl,{options:k,value:f,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Qm,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:z,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),[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`
2386
2386
  width: 100%;
2387
2387
  border-collapse: separate;
2388
2388
  border-spacing: 0;
@@ -2483,7 +2483,7 @@ cursor: pointer;
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 f=(p=n.current.parentElement)==null?void 0:p.getBoundingClientRect();f&&a({top:f.bottom+8,left:f.right-320})}},[]),i.useEffect(()=>{const p=f=>{n.current&&!n.current.contains(f.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(Q,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(Q,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},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(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`
2487
2487
  display: flex;
2488
2488
  align-items: center;
2489
2489
  flex-wrap: wrap;
@@ -2611,7 +2611,7 @@ cursor: pointer;
2611
2611
  outline: none;
2612
2612
  border-color: var(--color-primary);
2613
2613
  }
2614
- `,lx=()=>{var P;const{deployment:t}=ve(),{activeOrganization:r,loading:o,getEnterpriseConnections:n,createEnterpriseConnection:s,deleteEnterpriseConnection:a,testEnterpriseConnection:p,generateSCIMToken:f,getSCIMToken:c,revokeSCIMToken:h}=Ze(),{toast:l}=He(),[u,g]=i.useState(!1),[v,x]=i.useState(null),{data:w=[],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(z){l(z.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,{})}):(P=t==null?void 0:t.b2b_settings)!=null&&P.enterprise_sso_enabled?u?e.jsx(gx,{onClose:()=>g(!1),onCreate:async E=>{try{await(s==null?void 0:s(E)),S(),g(!1),l("SSO connection created","info")}catch(z){l(z.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:w.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(Q,{onClick:()=>g(!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"})]})}),w.map(E=>e.jsx(fx,{connection:E,onDelete:z=>x(z),connectionToDelete:v,onConfirmDelete:k,onCancelDelete:()=>x(null),testConnection:p||null,generateSCIMToken:f,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=()=>{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`
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:f,revokeSCIMToken:c,toast:h})=>{var j,T;const[l,u]=i.useState(null),[g,v]=i.useState(!1),[x,w]=i.useState(null),[$,S]=i.useState(null),[k,P]=i.useState(!1),[E,z]=i.useState(null);i.useEffect(()=>{f&&t.id&&f(t.id).then(u).catch(()=>{})},[t.id,f]);const y=async()=>{if(a){P(!0),z(null);try{const R=await a(t.id);z(R)}catch(R){z({success:!1,checks:{},errors:{general:R.message||"Test failed"}})}finally{P(!1)}}},m=async()=>{if(p){v(!0);try{const R=await p(t.id);w(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)}}},b=async()=>{if(c){v(!0);try{await c(t.id),u({exists:!1,scim_base_url:l==null?void 0:l.scim_base_url}),w(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(Q,{$outline:!0,onClick:y,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,I=>I.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)||!((T=l==null?void 0:l.token)!=null&&T.enabled)?e.jsxs(Q,{onClick:m,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[g?e.jsx(Ee,{size:12}):e.jsx(Ke,{size:14}),"Generate SCIM Token"]}):e.jsxs(e.Fragment,{children:[e.jsx(Q,{$outline:!0,onClick:m,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:"Rotate Token"}),e.jsx(Q,{$outline:!0,onClick:b,disabled:g,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,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`
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,f]=i.useState(null),[c,h]=i.useState("saml"),[l,u]=i.useState(null),[g,v]=i.useState(!1),[x,w]=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,P]=i.useState(null),{data:E=[],isLoading:z}=Fe("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(I=>I.verified),{revalidateOnFocus:!1}),y=C=>{f(C),h(C.protocol),C.protocol==="saml"?w(I=>{var M,F,L;return{...I,idp_entity_id:C.placeholders.entityId||"",idp_sso_url:C.placeholders.ssoUrl||"",attr_first_name:((M=C.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((F=C.attributeMapping)==null?void 0:F.last_name)||"",attr_email:((L=C.attributeMapping)==null?void 0:L.email)||""}}):w(I=>{var M,F,L;return{...I,oidc_issuer_url:C.placeholders.issuerUrl||"",oidc_scopes:C.placeholders.scopes||"openid profile email",attr_first_name:((M=C.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((F=C.attributeMapping)==null?void 0:F.last_name)||"",attr_email:((L=C.attributeMapping)==null?void 0:L.email)||""}})},m=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",b=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,I)=>{navigator.clipboard.writeText(C),u(I),setTimeout(()=>u(null),2e3)},T=async C=>{C.preventDefault(),a(!0);try{const I={};x.attr_first_name&&(I.first_name=x.attr_first_name),x.attr_last_name&&(I.last_name=x.attr_last_name),x.attr_email&&(I.email=x.attr_email);const M=Object.keys(I).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,...M&&{attribute_mapping:I}}):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,...M&&{attribute_mapping:I}})}finally{a(!1)}},R=async()=>{S(!0),P(null);const C=F=>F.includes("{")||F.includes("}"),I={},M={};if(c==="saml"?(x.idp_entity_id?C(x.idp_entity_id)?(M.entity_id_valid=!1,I.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):M.entity_id_valid=!0:(M.entity_id_valid=!1,I.entity_id_valid="IdP Entity ID is required"),x.idp_sso_url?C(x.idp_sso_url)?(M.sso_url_valid=!1,I.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):M.sso_url_valid=!0:(M.sso_url_valid=!1,I.sso_url_valid="IdP SSO URL is required"),x.idp_certificate?M.certificate_provided=!0:(M.certificate_provided=!1,I.certificate_provided="X.509 Certificate is required")):(x.oidc_issuer_url?C(x.oidc_issuer_url)?(M.issuer_url_valid=!1,I.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):M.issuer_url_valid=!0:(M.issuer_url_valid=!1,I.issuer_url_valid="Issuer URL is required"),x.oidc_client_id?C(x.oidc_client_id)?(M.client_id_valid=!1,I.client_id_valid="Client ID contains placeholder values - please replace with actual values"):M.client_id_valid=!0:(M.client_id_valid=!1,I.client_id_valid="Client ID is required")),Object.keys(I).length>0){P({success:!1,checks:M,errors:I}),S(!1);return}try{const F=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(F));L&&P(L)}catch(F){P({success:!1,checks:{},errors:{general:"Test failed: "+F.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:T,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:()=>f(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:()=>y(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:()=>y(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:b}),e.jsx(br,{onClick:()=>j(b,"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:m}),e.jsx(br,{onClick:()=>j(m,"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(Q,{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(Q,{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(([I,M])=>{var F;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:M?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:M?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:C[I]||I.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((F=k.errors)==null?void 0:F[I])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:k.errors[I]})]})]},I)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!p&&e.jsxs(he,{children:[e.jsx(ce,{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(ce,{children:"Domain *"}),z?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=>w({...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(ce,{children:"IdP Entity ID *"}),e.jsx(le,{type:"text",value:x.idp_entity_id,onChange:C=>w({...x,idp_entity_id:C.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"IdP SSO URL *"}),e.jsx(le,{type:"url",value:x.idp_sso_url,onChange:C=>w({...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(ce,{children:"X.509 Certificate *"}),e.jsx(cx,{value:x.idp_certificate,onChange:C=>w({...x,idp_certificate:C.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Issuer URL *"}),e.jsx(le,{type:"url",value:x.oidc_issuer_url,onChange:C=>w({...x,oidc_issuer_url:C.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Client ID *"}),e.jsx(le,{type:"text",value:x.oidc_client_id,onChange:C=>w({...x,oidc_client_id:C.target.value}),placeholder:"your-client-id",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Client Secret *"}),e.jsx(le,{type:"password",value:x.oidc_client_secret,onChange:C=>w({...x,oidc_client_secret:C.target.value}),placeholder:"your-client-secret",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Scopes"}),e.jsx(le,{type:"text",value:x.oidc_scopes,onChange:C=>w({...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=>w({...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(!g),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:g?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:g?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),g&&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(ce,{children:"First Name Attribute"}),e.jsx(le,{type:"text",value:x.attr_first_name,onChange:C=>w({...x,attr_first_name:C.target.value}),placeholder:c==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Last Name Attribute"}),e.jsx(le,{type:"text",value:x.attr_last_name,onChange:C=>w({...x,attr_last_name:C.target.value}),placeholder:c==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Email Attribute"}),e.jsx(le,{type:"text",value:x.attr_email,onChange:C=>w({...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,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`
2647
2647
  * {
2648
2648
  box-sizing: border-box;
2649
2649
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -2745,9 +2745,9 @@ cursor: pointer;
2745
2745
  flex-wrap: wrap;
2746
2746
  gap: 12px;
2747
2747
  margin-bottom: 24px;
2748
- `,bx=()=>{var M,F,L,B;const{activeOrganization:t,loading:r}=Ze(),{switchOrganization:o,refetch:n}=Ue(),{workspaces:s}=Pt(),{deployment:a}=ve(),{deleteOrganization:p,updateOrganization:f}=Yo(),{toast:c}=He(),[h,l]=i.useState((t==null?void 0:t.name)||""),[u,g]=i.useState((t==null?void 0:t.description)||""),[v,x]=i.useState((t==null?void 0:t.image_url)||null),w=i.useRef(null),[$,S]=i.useState(!1),[k,P]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[E,z]=i.useState(""),[y,m]=i.useState(!1),[b,_]=i.useState(!1),j=i.useCallback(async()=>{if(!(!t||$))try{S(!0),await f(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,f,c]);i.useEffect(()=>{var O;t&&(l(t.name||""),g(t.description||""),x(t.image_url||null),P({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 T=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{m(!0),await o(""),await p(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{m(!1),z("")}};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 X=O.target.files[0];if(X.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!X.type.startsWith("image/")){c("Please select a valid image file","error");return}v&&URL.revokeObjectURL(v),x(URL.createObjectURL(X)),setTimeout(()=>j(),100)}},I=()=>{w.current&&w.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:v?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:I,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:w,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(Q,{onClick:()=>{var O;return(O=w.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(Q,{onClick:()=>{x(null),w.current&&(w.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(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(ce,{htmlFor:"name",children:"Organization Name"}),e.jsx(le,{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(ce,{htmlFor:"description",children:"Description"}),e.jsx(le,{id:"description",as:"textarea",value:u,onChange:O=>g(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"})]}),((M=a==null?void 0:a.b2b_settings)==null?void 0:M.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{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:()=>{P(O=>({...O,mfa_required:!O.mfa_required})),setTimeout(()=>j(),100)}})]}),((F=a==null?void 0:a.b2b_settings)==null?void 0:F.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(ce,{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:()=>{P(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(ce,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(le,{id:"allowed_ips",as:"textarea",value:k.allowed_ips,onChange:O=>P(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)&&T.length>0&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Is,{options:T.map(O=>({value:O.id,label:O.name})),value:k.default_workspace_id,onChange:O=>{P(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"})]})]})]}),((B=a==null?void 0:a.b2b_settings)==null?void 0:B.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:b?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this organization, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{b?(_(!1),z("")):_(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:b?"Cancel":"Delete"})]}),b&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(le,{id:"confirm_name",type:"text",value:E,onChange:O=>z(O.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Q,{onClick:R,disabled:E!==(t==null?void 0:t.name)||y,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:y?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)||""),[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`
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:f=[],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=f,[u,g]=i.useState(!1),[v,x]=i.useState(null),[w,$]=i.useState(""),[S,k]=i.useState(null),P=i.useRef(null),E=i.useRef({}),z=i.useMemo(()=>{let b=l;if(w.trim()!==""){const _=w.toLowerCase();b=b.filter(j=>j.fqdn.toLowerCase().includes(_))}return b},[l,w]),y=async b=>{await n(b),h()},m=async b=>{x(b)};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:w,onChange:$,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(Q,{ref:P,onClick:()=>g(!u),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),u&&e.jsx(qa,{onClose:()=>{g(!1),h()},triggerRef:P})]})]}),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","."]}),z!=null&&z.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:z.map(b=>e.jsxs(Ne,{children:[e.jsx(Me,{children:b.fqdn}),e.jsx(Me,{children:b.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(b.created_at).toLocaleDateString()}),e.jsx(mt,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(nt,{style:{marginLeft:"auto"},open:S===b.id,openChange:_=>k(_?b.id:null),children:[e.jsx(at,{children:e.jsx(Rs,{ref:_=>{E.current[b.id]=_},children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{m(b.id),k(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:b.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Te,{onClick:()=>{k(null),navigator.clipboard.writeText(b.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://${b.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(b.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===b.id&&e.jsx(Yr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>y(b),onCancel:()=>p(null)}),v===b.id&&e.jsx(qa,{domain:b,onClose:()=>x(null),triggerRef:{current:E.current[b.id]}})]})})]},b.id))})]}):e.jsx(it,{title:w!=="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((_,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`
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:f}=Ue(),{toast:c}=He(),[h,l]=i.useState(""),[u,g]=i.useState(!1),v=i.useRef(null),{data:x=[],isLoading:w,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())||[]),P=S,E=i.useMemo(()=>h?x.filter(j=>{var F;const T=j.user;if(!T)return!1;const R=T.first_name||"",C=T.last_name||"",I=((F=T.primary_email_address)==null?void 0:F.email)||"";return`${R} ${C}`.trim().toLowerCase().includes(h.toLowerCase())||I.toLowerCase().includes(h.toLowerCase())}):x,[x,h]),z=async(j,T,R)=>{try{R?(await a(j,T),c("Role removed successfully","info")):(await s(j,T),c("Role added successfully","info")),$()}catch(C){const I=C.message||"Failed to update role. Please try again.";c(I,"error")}},y=(j="",T="")=>`${j[0]||""}${T[0]||""}`.toUpperCase(),m=(j,T)=>{var R;return((R=j.roles)==null?void 0:R.some(C=>C.id===T))||!1},b=async j=>{try{await p(j),$(),c("Member removed successfully","info")}catch(T){const R=T.message||"Failed to remove member. Please try again.";c(R,"error")}},_=()=>{g(!1),$(),c("Invitation sent successfully","info")};return r||w||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(Q,{ref:v,onClick:()=>g(!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:()=>g(!1),onSuccess:_,roles:P,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 I,M;const T=j.roles||[],R=j.user,C=(R==null?void 0:R.id)===((I=f==null?void 0:f.active_signin)==null?void 0:I.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"}}):y(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 F=`${R.first_name||""} ${R.last_name||""}`.trim();return F||((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:(M=R==null?void 0:R.primary_email_address)==null?void 0:M.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(Q,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:T.length>0?T[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[P.map(F=>{const L=m(j,F.id);return e.jsx(Te,{onClick:()=>z(j,F,L),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:F.name}),L&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},F.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>b(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(),[f,c]=i.useState(!1),[h,l]=i.useState(""),u=i.useRef(null),{data:g=[],isLoading:v,mutate:x}=Fe(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:w=[],isLoading:$}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),S=w,k=i.useMemo(()=>h?g.filter(y=>y.email.toLowerCase().includes(h.toLowerCase())):g,[g,h]),P=()=>{p("Invitation sent successfully","info"),x(),c(!1)},E=async y=>{try{await s(y),x(),p("Invitation cancelled successfully","info")}catch(m){const b=m.message||"Failed to cancel invitation. Please try again.";p(b,"error")}},z=async y=>{try{await a(y),p("Invitation resent successfully","info")}catch(m){const b=m.message||"Failed to resend invitation. Please try again.";p(b,"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(Q,{ref:u,onClick:()=>c(!f),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"})]}),f&&e.jsx($l,{onClose:()=>c(!1),onSuccess:P,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(y=>{var m;return e.jsxs(Ne,{children:[e.jsx(Me,{children:y.email}),e.jsx(Me,{children:((m=y.initial_organization_role)==null?void 0:m.name)||"No role"}),e.jsx(Me,{children:new Date(y.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:()=>z(y),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(y),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"})]})})]})]})})})]},y.id)})})]})]})},kx=()=>{var y;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=Ze(),{deployment:s}=ve(),[a,p]=i.useState({isOpen:!1}),[f,c]=i.useState(null),[h,l]=i.useState(null),[u,g]=i.useState(""),[v,x]=i.useState(null),w=i.useRef(null),{data:$=[],isLoading:S,mutate:k}=Fe(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),P=i.useMemo(()=>u?$.filter(m=>m.name.toLowerCase().includes(u.toLowerCase())):$,[$,u]),E=async m=>{try{m.id?(await new Promise(b=>setTimeout(b,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(b=>setTimeout(b,1e3)),c({text:"Role created successfully",type:"success"})),p({isOpen:!1}),k()}catch(b){const _=(b==null?void 0:b.message)||(m.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");m.id?c({text:_,type:"error"}):c({text:_,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},z=async m=>{try{await n(m),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:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(ut,{size:16}),f.text]}),e.jsxs(Rl,{children:[e.jsx(St,{placeholder:"Search roles",onChange:g,value:u}),((y=s==null?void 0:s.b2b_settings)==null?void 0:y.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(Q,{ref:w,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:w})]})]}),P.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:P.map(m=>{var b;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:m.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:m.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===m.id,openChange:_=>l(_?m.id:null),children:[e.jsx(at,{children:e.jsx(Rs,{disabled:!m.organization_id,"data-role-dropdown-trigger":m.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{l(null),p({isOpen:!0,role:m})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{l(null),x(m.id)},children:"Remove Role"})]})]}),v===m.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>z(m),onCancel:()=>x(null)}),a.isOpen&&((b=a.role)==null?void 0:b.id)===m.id&&e.jsx(Ya,{role:a.role,onClose:()=>{p({isOpen:!1}),l(null)},onSuccess:E})]})})]},m.id)})})]})]})},Tl=()=>{const{loading:t,activeOrganization:r}=Ze(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[p,f]=i.useState("info"),c=i.useCallback((h,l="info")=>{a(h),f(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:f,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||f||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),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`
2800
2800
  display: flex;
2801
2801
  height: 100%;
2802
2802
  min-height: 400px;
@@ -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 I;const[s,a]=i.useState(""),[p,f]=i.useState(""),[c,h]=i.useState(),[l,u]=i.useState(null),[g,v]=i.useState(!1),[x,w]=i.useState(!1),[$,S]=i.useState(t),k=i.useRef(null),P=i.useRef(null),{toast:E}=He(),{createWorkspace:z}=Pt(),{organizationMemberships:y}=Ct(),m=(I=y==null?void 0:y.find(M=>M.organization.id===$))==null?void 0:I.organization,b=M=>{if(M.target.files&&M.target.files[0]){const F=M.target.files[0];if(F.size>2*1024*1024){E("File size cannot exceed 2MB","error");return}if(!F.type.startsWith("image/")){E("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),h(F),u(URL.createObjectURL(F))}},_=()=>{var M;(M=k.current)==null||M.click()},j=M=>M.split(" ").map(F=>F[0]).join("").toUpperCase().slice(0,2)||"W",T=M=>M.trim().replace(/[<>\"'&]/g,""),R=M=>M.length>=2&&M.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(M),C=async()=>{const M=T(s),F=T(p);if(!M||!$){E("Please enter a workspace name","error");return}if(!R(M)){E("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(F.length>500){E("Description must be less than 500 characters","error");return}v(!0);try{const L=await z($,M,c,F);r==null||r(L)}catch(L){const B=L.message||"Failed to create workspace. Please try again.";E(B,"error")}finally{v(!1)}};return i.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]),i.useEffect(()=>{const M=F=>{P.current&&!P.current.contains(F.target)&&w(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]),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:b,accept:"image/png, image/jpeg, image/gif",disabled:g}),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:P,children:[e.jsxs(Hx,{type:"button",onClick:()=>w(!x),disabled:g,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(oi,{children:m!=null&&m.image_url?e.jsx(ni,{src:m.image_url,alt:m.name}):j((m==null?void 0:m.name)||"O").charAt(0)}),e.jsx("span",{children:(m==null?void 0:m.name)||"Select organization"})]}),e.jsx(or,{size:16,style:{color:"var(--color-secondary-text)"}})]}),x&&e.jsxs(qx,{children:[y==null?void 0:y.map(M=>e.jsxs(Ol,{onClick:()=>{S(M.organization.id),w(!1)},children:[e.jsx(oi,{children:M.organization.image_url?e.jsx(ni,{src:M.organization.image_url,alt:M.organization.name}):j(M.organization.name).charAt(0)}),e.jsx("span",{children:M.organization.name})]},M.organization.id)),e.jsxs(Yx,{onClick:()=>{w(!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:M=>a(M.target.value),placeholder:"Workspace Name",disabled:g})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Description (optional)"}),e.jsx(Dx,{value:p,onChange:M=>f(M.target.value),placeholder:"What is this workspace for?",disabled:g})]})]}),e.jsxs(Nx,{children:[o?e.jsxs(Fx,{onClick:o,disabled:g,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Bx,{onClick:C,disabled:g||!s.trim(),children:g?"Creating...":"Create"})]})]})]})})},Al=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[s,a]=i.useState(!1),[p,f]=i.useState(n),{refetch:c,organizationMemberships:h}=Ct(),l=()=>{o==null||o(),r==null||r()},u=()=>{a(!0)},g=async()=>{await c(),setTimeout(()=>{if(h&&h.length>0){const v=h[h.length-1];f(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:g,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,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`
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,f]=i.useState(""),[c,h]=i.useState(null),[l,u]=i.useState(!1),[g,v]=i.useState(!1),[x,w]=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 b=s.current;if(b){const _=b.getBoundingClientRect(),j=360,T=250,R=8;let C=0,I=0;const M=window.innerHeight-_.bottom,F=_.top;M>=T+R?(C=_.bottom+R,I=_.right-j,I<R&&(I=_.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):F>=T+R?(C=_.top-T-R,I=_.right-j,I<R&&(I=_.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(C=_.bottom+R,I=_.right-j,I<R&&(I=_.left)),w({top:C,left:I})}},10),z=b=>{a.current&&!a.current.contains(b.target)&&(t==null||t())},y=b=>{b.key==="Escape"&&(t==null||t())},m=setTimeout(()=>{document.addEventListener("mousedown",z),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(E),clearTimeout(m),document.removeEventListener("mousedown",z),document.removeEventListener("keydown",y)}},[t,s]);const k=E=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(E),P=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(z){const y=z.message||"Failed to send invitation. Please try again.";$(y,"error")}finally{u(!1)}}};return g?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(ce,{children:"Email Address"}),e.jsx(le,{type:"email",placeholder:"colleague@company.com",value:p,onChange:E=>f(E.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Role"}),e.jsx(Is,{options:S,value:c==null?void 0:c.id,onChange:E=>h(o.find(z=>z.id===E)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(e0,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:P,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,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`
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)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]),[h,l]=i.useState(!1),{deployment:u}=ve(),[g,v]=i.useState(!1),[x,w]=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(z=>({value:z,label:z}));i.useEffect(()=>{v(!0);const z=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const _=n.current;if(_){const j=_.getBoundingClientRect(),T=360,R=250,C=8;let I=0,M=0;const F=window.innerHeight-j.bottom,L=j.top;F>=R+C?(I=j.bottom+C,M=j.right-T,M<C&&(M=j.left,M+T>window.innerWidth-C&&(M=(window.innerWidth-T)/2))):L>=R+C?(I=j.top-R-C,M=j.right-T,M<C&&(M=j.left,M+T>window.innerWidth-C&&(M=(window.innerWidth-T)/2))):(I=j.bottom+C,M=j.right-T,M<C&&(M=j.left)),w({top:I,left:M})}},10),y=_=>{s.current&&!s.current.contains(_.target)&&(t==null||t())},m=_=>{_.key==="Escape"&&(t==null||t())},b=setTimeout(()=>{document.addEventListener("mousedown",y),document.addEventListener("keydown",m)},100);return()=>{clearTimeout(z),clearTimeout(b),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",m)}},[t,n]);const P=async()=>{if(a.trim()){l(!0);try{const z={id:o==null?void 0:o.id,name:a.trim(),permissions:f};r==null||r(z)}catch(z){const y=z.message||"Failed to save role. Please try again.";$(y,"error")}finally{l(!1)}}};return g?e.jsxs(o0,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:z=>z.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(ce,{children:"Role Name"}),e.jsx(le,{type:"text",value:a,onChange:z=>p(z.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Permissions"}),e.jsx(bl,{options:k,value:f,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(i0,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Q,{onClick:P,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 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`
3189
3189
  * {
3190
3190
  box-sizing: border-box;
3191
3191
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -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,createInvitation:s,discardInvitation:a,resendInvitation:p}=Rt(),{toast:f}=He(),[c,h]=i.useState(!0),[l,u]=i.useState(!0),[g,v]=i.useState(""),[x,w]=i.useState([]),[$,S]=i.useState([]),[k,P]=i.useState(!1),E=i.useRef(null);i.useEffect(()=>{if(!t)return;(async()=>{h(!0),u(!0);try{const[j,T]=await Promise.all([o(),n()]);S(j),w(T)}catch{}finally{h(!1),u(!1)}})()},[t==null?void 0:t.id]);const z=async _=>{try{await a(_.id);const j=await n();w(j)}catch{}},y=async _=>{try{await p(_.id);const j=await n();w(j),f("Invitation resent successfully","info")}catch{}},m=async()=>{P(!1);const _=await n();w(_),f("Invitation sent successfully","info")},b=i.useMemo(()=>g?x.filter(_=>(_.email||"").toLowerCase().includes(g.toLowerCase())):x,[x,g]);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:g,onChange:v,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(Q,{ref:E,onClick:()=>P(!k),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),k&&e.jsx(r0,{onClose:()=>P(!1),onSuccess:m,roles:$,createInvitation:s,triggerRef:E})]})]}),e.jsx("div",{children:b.length===0?e.jsx(it,{title:g?"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:b.map(_=>{var j,T;return e.jsxs(Ne,{children:[e.jsx(Me,{children:_.email}),e.jsx(Me,{children:((j=_.initial_workspace_role)==null?void 0:j.name)||((T=_.initial_organization_role)==null?void 0:T.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:()=>y(_),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:()=>z(_),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:f}=Ue(),{toast:c}=He(),[h,l]=i.useState(""),{data:u=[],isLoading:g,mutate:v}=Fe(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:x=[],isLoading:w}=Fe(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),$=x,S=i.useMemo(()=>h?u.filter(y=>{var R;const m=y.public_user_data;if(!m)return!1;const b=m.first_name||"",_=m.last_name||"",j=((R=m.primary_email_address)==null?void 0:R.email)||"";return`${b} ${_}`.trim().toLowerCase().includes(h.toLowerCase())||j.toLowerCase().includes(h.toLowerCase())}):u,[u,h]),k=async y=>{try{await s(y),c("Member removed successfully","info"),v()}catch{c("Failed to remove member","error")}},P=async(y,m,b)=>{try{b?(await p(y,m),c("Role removed successfully","info")):(await a(y,m),c("Role added successfully","info")),v()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},E=(y="",m="")=>`${y[0]||""}${m[0]||""}`.toUpperCase(),z=(y,m)=>{var b;return((b=y.roles)==null?void 0:b.some(_=>_.id===m))||!1};return r||g||w?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(y=>{var j,T;const m=y.public_user_data,b=y.roles||[],_=(m==null?void 0:m.id)===((j=f==null?void 0:f.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:m&&m.profile_picture_url?e.jsx("img",{src:m.profile_picture_url,alt:`${m.first_name||""} ${m.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):E(m==null?void 0:m.first_name,m==null?void 0:m.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(!m)return"Unknown User";const R=`${m.first_name||""} ${m.last_name||""}`.trim();return R||((C=m.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:(T=m==null?void 0:m.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Me,{children:new Date(y.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(Q,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:b.length>0?b[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[$.map(R=>{const C=z(y,R.id);return e.jsx(Te,{onClick:()=>P(y.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(y.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"})]})})]})]})})]},y.id)})})]})]})},m0=()=>{var X,te;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Rt(),{deleteWorkspace:n}=Pt(),{deployment:s}=ve(),{toast:a}=He(),[p,f]=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:""}),[g,v]=i.useState(null),[x,w]=i.useState((t==null?void 0:t.image_url)||null),[$,S]=i.useState(!1),[k,P]=i.useState(!1),[E,z]=i.useState(""),[y,m]=i.useState(!1),[b,_]=i.useState(!1),j=i.useRef(null),T=i.useRef(null);if(i.useEffect(()=>{var V;t&&(f(t.name||""),h(t.description||""),w(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 re=V.target.files[0];v(re),w(URL.createObjectURL(re)),setTimeout(()=>I(),100)}},C=()=>{j.current&&j.current.click()},I=i.useCallback(async()=>{if(!(!t||k))try{P(!0);const V={};g&&(V.image=g,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,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(`
3326
3326
  `);l.allowed_ips!==q&&(V.whitelisted_ips=l.allowed_ips.split(`
3327
- `).map(re=>re.trim()).filter(re=>re!=="")),Object.keys(V).length>0&&(await o(V),S(!0),setTimeout(()=>S(!1),3e3))}catch{a("Failed to auto-save workspace","error")}finally{P(!1)}},[t,o,p,c,g,l,k]),M=i.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{I()},1e3)},[I]),F=V=>{f(V.target.value),M()},L=V=>{h(V.target.value),M()},B=()=>{T.current&&clearTimeout(T.current),I()},O=()=>{T.current&&clearTimeout(T.current),I()},A=async()=>{if(!(!t||E!==t.name))try{m(!0),await n(t),a("Workspace deleted successfully","info")}catch(V){a(V.message||"Failed to delete workspace","error")}finally{m(!1),z(""),_(!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(Q,{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(Q,{onClick:()=>{w(null),v(null),j.current&&(j.current.value=""),setTimeout(()=>I(),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(ce,{htmlFor:"name",children:"Workspace Name"}),e.jsx(le,{id:"name",type:"text",value:p,onChange:F,onBlur:B,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"description",children:"Description"}),e.jsx(le,{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"})]}),((X=s==null?void 0:s.b2b_settings)==null?void 0:X.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{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(()=>I(),100)}})]}),((te=s==null?void 0:s.b2b_settings)==null?void 0:te.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(ce,{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(()=>I(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),l.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(le,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:V=>u(q=>({...q,allowed_ips:V.target.value})),onBlur:I,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:b?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(Q,{onClick:()=>{b?(_(!1),z("")):_(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:b?"Cancel":"Delete"})]}),b&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(le,{id:"confirm_workspace_name",type:"text",value:E,onChange:V=>z(V.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Q,{onClick:A,disabled:E!==(t==null?void 0:t.name)||y,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:y?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{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:`
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 m;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:s}=Rt(),{toast:a}=He(),{deployment:p}=ve(),[f,c]=i.useState(""),[h,l]=i.useState({isOpen:!1}),[u,g]=i.useState(null),[v,x]=i.useState(null),w=i.useRef(null),$=i.useRef(new Map),{data:S=[],isLoading:k,mutate:P}=Fe(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),E=i.useMemo(()=>f?S.filter(b=>b.name.toLowerCase().includes(f.toLowerCase())):S,[S,f]),z=async b=>{try{await n(b.name,b.permissions||[]),a("Role created successfully","info"),l({isOpen:!1}),P()}catch{a("Failed to save role","error"),a("Failed to create role","error")}},y=async b=>{try{await s(b),a("Role deleted successfully","info"),x(null),P()}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:f}),e.jsxs("div",{style:{position:"relative"},children:[((m=p==null?void 0:p.b2b_settings)==null?void 0:m.custom_workspace_role_enabled)&&e.jsx(Q,{ref:w,onClick:()=>l({isOpen:!0,triggerElement:w.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),h.isOpen&&!h.role&&e.jsx(si,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:z})]})]}),E.length===0?e.jsx(it,{title:f?"No roles match your search":"No roles available",description:f?"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(b=>{var _;return e.jsxs(Ne,{children:[e.jsx(Me,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:b.name})}),e.jsx(Me,{style:{color:"var(--color-secondary-text)"},children:b.permissions&&b.permissions.length>0?b.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===b.id,openChange:j=>g(j?b.id:null),children:[e.jsx(at,{children:e.jsx(Ll,{ref:j=>{j&&$.current.set(b.id,j)},disabled:!b.workspace_id,"data-role-dropdown-trigger":b.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{g(null);const j=$.current.get(b.id);l({isOpen:!0,role:b,triggerElement:j||null})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{g(null),x(b.id)},children:"Remove Role"})]})]}),v===b.id&&e.jsx(Yr,{title:"Are you sure you want to delete this role?",onConfirm:()=>y(b),onCancel:()=>x(null)}),h.isOpen&&((_=h.role)==null?void 0:_.id)===b.id&&e.jsx(si,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>{l({isOpen:!1}),g(null)},onSuccess:z})]})})]},b.id)})})]})})]})},Dl=()=>{const{activeWorkspace:t,loading:r}=Rt(),[o,n]=i.useState("general"),[s,a]=i.useState(null),[p,f]=i.useState("info"),c=i.useCallback((h,l="info")=>{a(h),f(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:f,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||f||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 f=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),h=window.innerWidth,l=window.innerHeight,u=h-c.left,g=c.right,v=l-c.bottom,x=c.top;let w={};u>=o?w.left=c.left:g>=o?w.left=c.right-o:w.left=Math.max(s,Math.min(h-o-s,c.left)),v>=150?(w.top=c.bottom+s,w.maxHeight=Math.min(n,v-s*2)):x>=150?(w.bottom=l-c.top+s,w.maxHeight=Math.min(n,x-s*2)):(w.top=c.bottom+s,w.maxHeight=Math.max(100,v-s*2)),p(w)};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!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),[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`
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,K;const[r,o]=i.useState(!1),[n,s]=i.useState(!1),[a,p]=i.useState(new Set),f=i.useRef(null),c=i.useRef(null),h=Fl({triggerRef:f,isOpen:r,minWidth:300}),l=Dr(!1),u=Dr(!1),g=Dr(!1),v=Dr(!1),[x,w]=i.useState(null),[$,S]=i.useState(!1),[k,P]=i.useState(null),{organizationMemberships:E,loading:z,refetch:y}=Ct(),{activeOrganization:m,activeMembership:b,leave:_}=Ze(),{activeWorkspace:j,activeMembership:T,leave:R}=Rt(),{workspaces:C,loading:I}=Pt(),{session:M,loading:F,switchOrganization:L,switchWorkspace:B}=Ue(),{deployment:O}=ve(),{toast:A}=He(),X=O==null?void 0:O.b2b_settings.organizations_enabled,te=O==null?void 0:O.b2b_settings.workspaces_enabled,V=O==null?void 0:O.b2b_settings.allow_users_to_create_orgs,q=!((ue=M==null?void 0:M.active_signin)!=null&&ue.active_organization_membership_id),re=i.useMemo(()=>{var se,me;if(q)return{name:"Personal account",image_url:(me=(se=M==null?void 0:M.active_signin)==null?void 0:se.user)==null?void 0:me.profile_picture_url,isPersonal:!0};let H=(m==null?void 0:m.name)||"";return te&&j&&(H=`${m==null?void 0:m.name} / ${j.name}`),{name:H,image_url:m==null?void 0:m.image_url,isPersonal:!1}},[q,m,j,M,te]);i.useEffect(()=>{if(!r)return;let H=null;const se=setTimeout(()=>{const me=fe=>{var N,D;const W=fe.target;(N=f.current)!=null&&N.contains(W)||(D=c.current)!=null&&D.contains(W)||(o(!1),P(null))};document.addEventListener("mousedown",me),H=()=>{document.removeEventListener("mousedown",me)}},50);return()=>{clearTimeout(se),H==null||H()}},[r]),i.useEffect(()=>{if(k){const H=setTimeout(()=>{P(null)},5e3);return()=>clearTimeout(H)}},[k]);const ne=()=>{y()};if(!X)return null;const J=H=>{s(!0),L(H).finally(()=>{s(!1)})},oe=H=>{s(!0),B(H).finally(()=>{s(!1)})},de=H=>{const se=new Set(a);se.has(H)?se.delete(H):se.add(H),p(se)},Z=H=>H.split(" ").map(se=>se[0]).join("").toUpperCase().slice(0,2),ae=!!((U=M==null?void 0:M.active_signin)!=null&&U.active_organization_membership_id);return z||F||!E&&ae?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:f,onClick:()=>{o(!r),r||P(null)},disabled:n,children:[e.jsxs(ci,{children:[e.jsx(w0,{children:re.image_url?e.jsx(j0,{src:re.image_url,alt:re.name}):re.isPersonal?e.jsx(Bo,{size:12}):Z(re.name)}),e.jsx(_0,{children:re.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:z||I?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:H=>{H.stopPropagation(),q||J()},disabled:n||q,children:[q&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(C0,{children:(K=(pe=M==null?void 0:M.active_signin)==null?void 0:pe.user)!=null&&K.profile_picture_url?e.jsx(S0,{src:M.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&&m&&e.jsx(gr,{})]}),!q&&m&&e.jsxs(Ao,{$isActive:!0,onClick:()=>{te&&de(m.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(wo,{}),e.jsxs(xt,{children:[te&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:a.has(m.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(li,{children:m.image_url?e.jsx(di,{src:m.image_url,alt:m.name}):Z(m.name)}),e.jsx(vt,{children:e.jsx(bt,{children:m.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Gl(b)&&e.jsx(Lo,{onClick:H=>{H.stopPropagation(),u.open()},title:"Manage organization",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async H=>{H.stopPropagation(),S(!0),P(null);try{await _(),await y(),setTimeout(()=>{S(!1)},500)}catch(se){P(se instanceof Error?se.message:"Failed to leave organization"),S(!1)}},disabled:$,title:"Leave organization",children:e.jsx(Et,{size:12})})]})]}),m&&te&&a.has(m.id)&&e.jsxs(e.Fragment,{children:[C==null?void 0:C.filter(H=>H.organization.id===m.id).map(H=>{const se=(j==null?void 0:j.id)===H.id;return e.jsxs(jo,{as:se?void 0:"button",$isActive:se,onClick:se?void 0:()=>oe(H.id),...se?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[se&&e.jsx(wo,{}),e.jsxs(xt,{children:[e.jsx(pi,{children:H.image_url?e.jsx("img",{src:H.image_url,alt:H.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Z(H.name).charAt(0)}),e.jsx(vt,{children:e.jsx(bt,{children:H.name})})]}),se?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[xs(T)&&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})]},H.id)}),e.jsx(jo,{as:"button",onClick:()=>{w(m.id),g.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(H=>H.organization.id!==(m==null?void 0:m.id)).map(H=>{const se=H.organization,me=(C==null?void 0:C.filter(W=>W.organization.id===se.id))||[],fe=a.has(se.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:!1,onClick:()=>{te?de(se.id):J(se.id)},disabled:n,children:[e.jsxs(xt,{children:[te&&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:se.image_url?e.jsx(di,{src:se.image_url,alt:se.name}):Z(se.name)}),e.jsx(vt,{children:e.jsx(bt,{children:se.name})})]}),e.jsx(bo,{className:"hover-arrow",size:14})]}),te&&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"}}):Z(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(T)&&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(Y){const ie=Y.message||"Failed to leave workspace. Please try again.";A(ie,"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:()=>{w(se.id),g.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,{})]},se.id)})}),te?m&&e.jsx(ui,{onClick:()=>{w(m.id),g.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),X&&V&&e.jsx(Nm,{isOpen:l.isOpen,onClose:l.close,onCreated:ne}),e.jsx(Cx,{isOpen:u.isOpen,onClose:u.close}),e.jsx(Nl,{isOpen:v.isOpen,onClose:v.close}),x&&e.jsx(Al,{isOpen:g.isOpen,onClose:()=>{g.close(),w(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
+ `,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};/**
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 g=[];for(let x=0;x<this.size;x++)g.push(!1);for(let x=0;x<this.size;x++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(l);if(this.drawCodewords(v),u==-1){let x=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const $=this.getPenaltyScore();$<x&&(u=w,x=$),this.applyMask(w)}}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,g=-1,v=!0){if(!(je.MIN_VERSION<=l&&l<=u&&u<=je.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let x,w;for(x=l;;x++){const P=je.getNumDataCodewords(x,h)*8,E=p.getTotalBits(c,x);if(E<=P){w=E;break}if(x>=u)throw new RangeError("Data too long")}for(const P of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])v&&w<=je.getNumDataCodewords(x,P)*8&&(h=P);let $=[];for(const P of c){o(P.mode.modeBits,4,$),o(P.numChars,P.mode.numCharCountBits(x),$);for(const E of P.getData())$.push(E)}s($.length==w);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 P=236;$.length<S;P^=253)o(P,8,$);let k=[];for(;k.length*8<$.length;)k.push(0);return $.forEach((P,E)=>k[E>>>3]|=P<<7-(E&7)),new je(x,h,k,g)}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 g=0;g<10;g++)l=l<<1^(l>>>9)*1335;const u=(h<<10|l)^21522;s(u>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(u,g));this.setFunctionModule(8,7,n(u,6)),this.setFunctionModule(8,8,n(u,7)),this.setFunctionModule(7,8,n(u,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(u,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(u,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(u,g));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),g=this.size-11+l%3,v=Math.floor(l/3);this.setFunctionModule(g,v,u),this.setFunctionModule(v,g,u)}}drawFinderPattern(c,h){for(let l=-4;l<=4;l++)for(let u=-4;u<=4;u++){const g=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,g!=2&&g!=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],g=je.ECC_CODEWORDS_PER_BLOCK[l.ordinal][h],v=Math.floor(je.getNumRawDataModules(h)/8),x=u-v%u,w=Math.floor(v/u);let $=[];const S=je.reedSolomonComputeDivisor(g);for(let P=0,E=0;P<u;P++){let z=c.slice(E,E+w-g+(P<x?0:1));E+=z.length;const y=je.reedSolomonComputeRemainder(z,S);P<x&&z.push(0),$.push(z.concat(y))}let k=[];for(let P=0;P<$[0].length;P++)$.forEach((E,z)=>{(P!=w-g||z>=x)&&k.push(E[P])});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 g=0;g<2;g++){const v=l-g,w=(l+1&2)==0?this.size-1-u:u;!this.isFunction[w][v]&&h<c.length*8&&(this.modules[w][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 g=0;g<this.size;g++){let v=!1,x=0,w=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[g][$]==v?(x++,x==5?c+=je.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,w),v||(c+=this.finderPenaltyCountPatterns(w)*je.PENALTY_N3),v=this.modules[g][$],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,w)*je.PENALTY_N3}for(let g=0;g<this.size;g++){let v=!1,x=0,w=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[$][g]==v?(x++,x==5?c+=je.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,w),v||(c+=this.finderPenaltyCountPatterns(w)*je.PENALTY_N3),v=this.modules[$][g],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,w)*je.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let v=0;v<this.size-1;v++){const x=this.modules[g][v];x==this.modules[g][v+1]&&x==this.modules[g+1][v]&&x==this.modules[g+1][v+1]&&(c+=je.PENALTY_N2)}let h=0;for(const g of this.modules)h=g.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 g=0;g<h.length;g++)h[g]=je.reedSolomonMultiply(h[g],l),g+1<h.length&&(h[g]^=h[g+1]);l=je.reedSolomonMultiply(l,2)}return h}static reedSolomonComputeRemainder(c,h){let l=h.map(u=>0);for(const u of c){const g=u^l.shift();l.push(0),h.forEach((v,x)=>l[x]^=je.reedSolomonMultiply(v,g))}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(f,c,h){if(c<0||c>31||f>>>c)throw new RangeError("Value out of range");for(let l=c-1;l>=0;l--)h.push(f>>>l&1)}function n(f,c){return(f>>>c&1)!=0}function s(f){if(!f)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 g=u.mode.numCharCountBits(h);if(u.numChars>=1<<g)return 1/0;l+=4+g+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 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;/**
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,f){if(!p&&a!==null){o.push(`M${a+r} ${s+r}h${f-a}v1H${a+r}z`),a=null;return}if(f===n.length-1){if(!p)return;a===null?o.push(`M${f+r},${s+r} h1v1H${f+r}z`):o.push(`M${a+r},${s+r} h${f+1-a}v1H${a+r}z`);return}p&&a===null&&(a=f)})}),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,f=(n.width||a)*p,c=(n.height||a)*p,h=n.x==null?t.length/2-f/2:n.x*p,l=n.y==null?t.length/2-c/2:n.y*p,u=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let x=Math.floor(h),w=Math.floor(l),$=Math.ceil(f+h-x),S=Math.ceil(c+l-w);g={x,y:w,w:$,h:S}}const v=n.crossOrigin;return{x:h,y:l,h:c,w:f,excavation:g,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:f}){let c=i.useMemo(()=>{const x=(Array.isArray(t)?t:[t]).reduce((w,$)=>(w.push(...vr.QrSegment.makeSegments($)),w),[]);return vr.QrCode.encodeSegments(x,M0[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:h,margin:l,numCells:u,calculatedImageSettings:g}=i.useMemo(()=>{let v=c.getModules();const x=N0(n,s),w=v.length+x*2,$=D0(v,p,x,a);return{cells:v,margin:x,numCells:w,calculatedImageSettings:$}},[c,p,a,n,s]);return{qrcode:c,margin:l,cells:h,numCells:u,calculatedImageSettings:g}}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:f=Ql,fgColor:c=Xl,includeMargin:h=Jl,minVersion:l=ed,boostLevel:u,marginSize:g,imageSettings:v}=n,w=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:$}=w,S=bs(w,["style"]),k=v==null?void 0:v.src,P=i.useRef(null),E=i.useRef(null),z=i.useCallback(I=>{P.current=I,typeof o=="function"?o(I):o&&(o.current=I)},[o]),[y,m]=i.useState(!1),{margin:b,cells:_,numCells:j,calculatedImageSettings:T}=od({value:s,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:g,imageSettings:v,size:a});i.useEffect(()=>{if(P.current!=null){const I=P.current,M=I.getContext("2d");if(!M)return;let F=_;const L=E.current,B=T!=null&&L!==null&&L.complete&&L.naturalHeight!==0&&L.naturalWidth!==0;B&&T.excavation!=null&&(F=rd(_,T.excavation));const O=window.devicePixelRatio||1;I.height=I.width=a*O;const A=a/j*O;M.scale(A,A),M.fillStyle=f,M.fillRect(0,0,j,j),M.fillStyle=c,F0?M.fill(new Path2D(td(F,b))):_.forEach(function(X,te){X.forEach(function(V,q){V&&M.fillRect(q+b,te+b,1,1)})}),T&&(M.globalAlpha=T.opacity),B&&M.drawImage(L,T.x+b,T.y+b,T.w,T.h)}}),i.useEffect(()=>{m(!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:()=>{m(!0)},ref:E,crossOrigin:T==null?void 0:T.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",vs({style:R,height:a,width:a,ref:z,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:f=Ql,fgColor:c=Xl,includeMargin:h=Jl,minVersion:l=ed,boostLevel:u,title:g,marginSize:v,imageSettings:x}=n,w=bs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:$,cells:S,numCells:k,calculatedImageSettings:P}=od({value:s,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:v,imageSettings:x,size:a});let E=S,z=null;x!=null&&P!=null&&(P.excavation!=null&&(E=rd(S,P.excavation)),z=i.createElement("image",{href:x.src,height:P.h,width:P.w,x:P.x+$,y:P.y+$,preserveAspectRatio:"none",opacity:P.opacity,crossOrigin:P.crossOrigin}));const y=td(E,$);return i.createElement("svg",vs({height:a,width:a,viewBox:`0 0 ${k} ${k}`,ref:o,role:"img"},w),!!g&&i.createElement("title",null,g),i.createElement("path",{fill:f,d:`M0,0 h${k}v${k}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:y,shapeRendering:"crispEdges"}),z)});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},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`
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),[f,c]=i.useState(!1),[h,l]=i.useState({top:0,left:0}),{toast:u}=Mt();i.useEffect(()=>{c(!0);const y=setTimeout(()=>{if(!p.current||!(a!=null&&a.current))return;const _=a.current;if(_){const j=_.getBoundingClientRect(),T=380,R=300,C=8;let I=0,M=0;const F=window.innerHeight-j.bottom,L=j.top;F>=R+C?(I=j.bottom+C,M=j.right-T,M<C&&(M=j.left,M+T>window.innerWidth-C&&(M=(window.innerWidth-T)/2))):L>=R+C?(I=j.top-R-C,M=j.right-T,M<C&&(M=j.left,M+T>window.innerWidth-C&&(M=(window.innerWidth-T)/2))):(I=j.bottom+C,M=j.right-T,M<C&&(M=j.left)),l({top:I,left:M})}},10),m=_=>{p.current&&!p.current.contains(_.target)&&t()},b=_=>{_.key==="Escape"&&t()};return document.addEventListener("mousedown",m),document.addEventListener("keydown",b),()=>{clearTimeout(y),document.removeEventListener("mousedown",m),document.removeEventListener("keydown",b)}},[t,a]);const[g,v]=i.useState(s?"otp":"email"),[x,w]=i.useState(s||""),[$,S]=i.useState(""),[k,P]=i.useState(!1),E=async()=>{if(!(!x||k)){P(!0);try{await r(x),v("otp")}catch(y){const m=y.message||"Failed to add email address. Please try again.";u(m,"error")}finally{P(!1)}}},z=async()=>{P(!0);try{await o($),t()}catch(y){const m=y.message||"Failed to verify email. Please check the code and try again.";u(m,"error")}finally{P(!1)}};return f?e.jsx(U0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),children:g==="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(le,{id:"email-input",type:"email",placeholder:"Email address",value:x,onChange:y=>w(y.target.value),style:{flex:1}})]})}),e.jsxs(mi,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{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 y=>S(y),onResend:n,isSubmitting:k}),e.jsxs(mi,{children:[e.jsx(Q,{$outline:!0,onClick:()=>v("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(Q,{onClick:z,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 _=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`
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 b;const p=i.useRef(null),[f,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(),I=380,M=300,F=8;let L=0,B=0;const O=window.innerHeight-C.bottom,A=C.top;O>=M+F?(L=C.bottom+F,B=C.right-I,B<F&&(B=C.left,B+I>window.innerWidth-F&&(B=(window.innerWidth-I)/2))):A>=M+F?(L=C.top-M-F,B=C.right-I,B<F&&(B=C.left,B+I>window.innerWidth-F&&(B=(window.innerWidth-I)/2))):(L=C.bottom+F,B=C.right-I,B<F&&(B=C.left)),l({top:L,left:B})}},10),j=R=>{p.current&&!p.current.contains(R.target)&&t()},T=R=>{R.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",T),()=>{clearTimeout(_),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",T)}},[t,a]);const[g,v]=i.useState(n?"otp":"phone"),[x,w]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[$,S]=i.useState((b=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:b.pop()),[k,P]=i.useState(""),[E,z]=i.useState(!1),y=async()=>{if(!(!x||E)){z(!0);try{await r(x,$||""),v("otp")}catch(_){const j=_.message||"Failed to add phone number. Please try again.";u(j,"error")}finally{z(!1)}}},m=async()=>{z(!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{z(!1)}};return f?e.jsx(G0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:g==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(yi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(qr,{value:x,onChange:_=>w(_.target.value),error:"",countryCode:$,setCountryCode:S})}),e.jsxs(bi,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:y,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:_=>P(_),onResend:async()=>s()})}),e.jsxs(bi,{children:[e.jsx(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{onClick:m,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 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`
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"),[f,c]=i.useState(""),[h,l]=i.useState(""),[u,g]=i.useState(["",""]),[v,x]=i.useState(!1),[w,$]=i.useState(!1),[S,k]=i.useState({top:0,left:0}),{toast:P}=Mt();i.useEffect(()=>{$(!0);const z=setTimeout(()=>{if(!s.current||!(n!=null&&n.current))return;const b=n.current;if(b){const _=b.getBoundingClientRect(),j=380,T=400,R=8;let C=0,I=0;const M=window.innerHeight-_.bottom,F=_.top;M>=T+R?(C=_.bottom+R,I=_.right-j,I<R&&(I=_.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):F>=T+R?(C=_.top-T-R,I=_.right-j,I<R&&(I=_.left,I+j>window.innerWidth-R&&(I=(window.innerWidth-j)/2))):(C=_.bottom+R,I=_.right-j,I<R&&(I=_.left)),k({top:C,left:I})}},10),y=b=>{s.current&&!s.current.contains(b.target)&&t()},m=b=>{b.key==="Escape"&&t()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",m),()=>{clearTimeout(z),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",m)}},[t,n]),i.useEffect(()=>{(async()=>{x(!0);try{const y=await r();c(y.otp_url||""),l(y.totp_secret||"")}catch(y){const m=y.message||"Failed to setup two-factor authentication. Please try again.";P(m,"error")}finally{x(!1)}})()},[]);const E=async()=>{if(!u.some(z=>z.length!==6)){x(!0);try{await o(u),t()}catch(z){const y=z.message||"Failed to verify codes. Please check your authenticator app and try again.";P(y,"error")}finally{x(!1)}}};return w?e.jsx(H0,{ref:s,style:{top:`${S.top}px`,left:`${S.left}px`,visibility:S.top>0?"visible":"hidden"},onClick:z=>z.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..."}):f?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Ls,{value:f,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||!f,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(le,{id:"totp-code-1",type:"text",placeholder:"000000",value:u[0],onChange:z=>{const y=z.target.value.replace(/[^0-9]/g,"").substring(0,6);g([y,u[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(le,{id:"totp-code-2",type:"text",placeholder:"000000",value:u[1],onChange:z=>{const y=z.target.value.replace(/[^0-9]/g,"").substring(0,6);g([u[0],y])},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(z=>z.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(["",""]),[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`
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),[f,c]=i.useState({top:0,left:0}),[h,l]=i.useState(""),[u,g]=i.useState(""),[v,x]=i.useState(""),[w,$]=i.useState(!1),[S,k]=i.useState(!1),[P,E]=i.useState(!1),[z,y]=i.useState(!1),[m,b]=i.useState({});i.useEffect(()=>{p(!0);const j=setTimeout(()=>{if(!s.current||!(o!=null&&o.current))return;const C=o.current;if(C){const I=C.getBoundingClientRect(),M=380,F=350,L=8;let B=0,O=0;const A=window.innerHeight-I.bottom,X=I.top;A>=F+L?(B=I.bottom+L,O=I.right-M,O<L&&(O=I.left,O+M>window.innerWidth-L&&(O=(window.innerWidth-M)/2))):X>=F+L?(B=I.top-F-L,O=I.right-M,O<L&&(O=I.left,O+M>window.innerWidth-L&&(O=(window.innerWidth-M)/2))):(B=I.bottom+L,O=I.right-M,O<L&&(O=I.left)),c({top:B,left:O})}},10),T=C=>{s.current&&!s.current.contains(C.target)&&t()},R=C=>{C.key==="Escape"&&t()};return document.addEventListener("mousedown",T),document.addEventListener("keydown",R),()=>{clearTimeout(j),document.removeEventListener("mousedown",T),document.removeEventListener("keydown",R)}},[t,o]);const _=async()=>{if(z)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){b(j);return}y(!0);try{await r(n?"":h,u),t()}catch(T){b({form:T.message||"Failed to update password"})}finally{y(!1)}};return a?e.jsxs(Y0,{ref:s,style:{top:`${f.top}px`,left:`${f.left}px`,visibility:f.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(ce,{children:"Current Password"}),e.jsxs(qn,{children:[e.jsx(le,{type:w?"text":"password",placeholder:"Enter your current password",value:h,onChange:j=>l(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>$(!w),"aria-label":w?"Hide current password":"Show current password",children:w?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),m.currentPassword&&e.jsx(zo,{children:m.currentPassword})]}),e.jsxs(Hn,{children:[e.jsx(ce,{children:n?"Password":"New Password"}),e.jsxs(qn,{children:[e.jsx(le,{type:S?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:u,onChange:j=>g(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})})]}),m.newPassword&&e.jsx(zo,{children:m.newPassword})]}),e.jsxs(Hn,{children:[e.jsx(ce,{children:"Confirm New Password"}),e.jsxs(qn,{children:[e.jsx(le,{type:P?"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(!P),"aria-label":P?"Hide confirm password":"Show confirm password",children:P?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),m.confirmPassword&&e.jsx(zo,{children:m.confirmPassword})]}),m.form&&e.jsx(zo,{children:m.form}),e.jsxs(Z0,{children:[e.jsx(ki,{onClick:t,children:"Cancel"}),e.jsx(ki,{$primary:!0,onClick:_,disabled:z,children:z?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(""),[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`
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,f]=i.useState({top:0,left:0}),[c,h]=i.useState(""),[l,u]=i.useState(!1),{toast:g}=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(),P=400,E=300,z=8;let y=0,m=0;const b=window.innerHeight-k.bottom,_=k.top;b>=E+z?(y=k.bottom+z,m=k.right-P,m<z&&(m=k.left,m+P>window.innerWidth-z&&(m=(window.innerWidth-P)/2))):_>=E+z?(y=k.top-E-z,m=k.right-P,m<z&&(m=k.left,m+P>window.innerWidth-z&&(m=(window.innerWidth-P)/2))):(y=k.bottom+z,m=k.right-P,m<z&&(m=k.left)),f({top:y,left:m})}},10),w=S=>{n.current&&!n.current.contains(S.target)&&t()},$=S=>{S.key==="Escape"&&t()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",$),()=>{clearTimeout(x),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",$)}},[t,o]);const v=async()=>{if(!(!c||l)){u(!0);try{await r(c),t()}catch(x){const w=x.message||"Failed to remove password. Please try again.";g(w,"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(ce,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(le,{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(Q,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Q,{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 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`
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,f]=i.useState(!1),[c,h]=i.useState({top:0,left:0});return i.useEffect(()=>{f(!0);const l=setTimeout(()=>{if(!a.current||!(s!=null&&s.current))return;const v=s.current;if(v){const x=v.getBoundingClientRect(),w=380,$=300,S=8;let k=0,P=0;const E=window.innerHeight-x.bottom,z=x.top;E>=$+S?(k=x.bottom+S,P=x.right-w,P<S&&(P=x.left,P+w>window.innerWidth-S&&(P=(window.innerWidth-w)/2))):z>=$+S?(k=x.top-$-S,P=x.right-w,P<S&&(P=x.left,P+w>window.innerWidth-S&&(P=(window.innerWidth-w)/2))):(k=x.bottom+S,P=x.right-w,P<S&&(P=x.left)),h({top:k,left:P})}},10),u=v=>{a.current&&!a.current.contains(v.target)&&r()},g=v=>{v.key==="Escape"&&r()};return document.addEventListener("mousedown",u),document.addEventListener("keydown",g),()=>{clearTimeout(l),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",g)}},[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 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`
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:f}=Mt(),c=o,h=async u=>{try{await n(u),await Promise.all([s(),p()]),r(null),f("Session ended successfully","info")}catch(g){f(g.message||"Failed to end session. Please try again.","error")}},l=u=>{if(!u||u.trim()==="")return"Unknown";const g=new Date(u);if(isNaN(g.getTime()))return"Unknown";const x=Math.floor((new Date().getTime()-g.getTime())/(1e3*60));return x<1?"Just now":x<60?`${x}m ago`:x<1440?`${Math.floor(x/60)}h ago`:g.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:g=>r(g?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 y,m,b,_;const{deployment:t}=ve(),{toast:r}=Mt(),[o,n]=i.useState(null),[s,a]=i.useState(""),[p,f]=i.useState(!1),[c,h]=i.useState(null),[l,u]=i.useState(""),g=i.useRef(null),v=i.useRef({}),{user:x,createEmailAddress:w,deleteEmailAddress:$,prepareEmailVerification:S,attemptEmailVerification:k,makeEmailPrimary:P}=sr();if(!((m=(y=t==null?void 0:t.auth_settings)==null?void 0:y.email_address)!=null&&m.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(T){r(T.message||"Failed to delete email address. Please try again.","error")}},z=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(Q,{ref:g,onClick:()=>f(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),p&&e.jsx(vi,{triggerRef:g,onClose:()=>f(!1),onAddEmail:async j=>{const T=await w(j);a(T.data.id),await S(T.data.id),x.refetch()},onPrepareVerification:async()=>{await S(s),x.refetch()},onAttemptVerification:async j=>{await k(s,j),x.refetch(),f(!1),a(""),r("Email added and verified successfully!","info")}})]})]}),z!=null&&z.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:z.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:T=>n(T?j.id:null),children:[e.jsx(at,{children:e.jsx(cn,{ref:T=>{T&&(v.current[j.id]=T)},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 P(j.id),x.refetch(),n(null),r("Primary email updated successfully","info")}catch(T){r(T.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:(_=(b=x==null?void 0:x.user_email_addresses)==null?void 0:b.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 z,y,m,b;const{deployment:t}=ve(),[r,o]=i.useState(null),[n,s]=i.useState(""),[a,p]=i.useState(!1),[f,c]=i.useState(null),[h,l]=i.useState(""),u=i.useRef(null),g=i.useRef({}),{user:v,createPhoneNumber:x,deletePhoneNumber:w,preparePhoneVerification:$,attemptPhoneVerification:S,makePhonePrimary:k}=sr();if(!((y=(z=t==null?void 0:t.auth_settings)==null?void 0:z.phone_number)!=null&&y.enabled))return null;const P=_=>{const j=Oo.find(T=>T.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(Q,{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 T=await x(_,j);s(T.data.id),await $(T.data.id)},onPrepareVerification:async()=>{await $(n),v.refetch()},onAttemptVerification:async _=>{await S(n,_),v.refetch(),p(!1)}}),f&&e.jsx(wi,{existingPhone:(b=(m=v==null?void 0:v.user_phone_numbers)==null?void 0:m.find(_=>_.id===f))==null?void 0:b.phone_number,triggerRef:{current:g.current[f]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await $(f),v.refetch()},onAttemptVerification:async _=>{await S(f,_),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:P(_.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&&(g.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 w(_.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 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`
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,f)=>{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(Q,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(Q,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<a.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},ad=()=>{var x,w,$,S,k,P,E;const{loading:t}=sr(),{deployment:r}=ve(),[o,n]=i.useState("profile"),[s,a]=i.useState(null),[p,f]=i.useState("info"),c=i.useCallback((z,y="info")=>{a(z),f(y),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=(w=h==null?void 0:h.phone_number)==null?void 0:w.enabled,g=(($=r==null?void 0:r.social_connections)==null?void 0:$.some(z=>z.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)||((P=h==null?void 0:h.auth_factors_enabled)==null?void 0:P.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"]})}),g&&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"&&g&&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,Y,ie;const{deployment:t}=ve(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:s,verifyAuthenticator:a,deleteAuthenticator:p,generateBackupCodes:f,regenerateBackupCodes:c,updateProfile:h}=sr(),{toast:l}=Mt(),[u,g]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[v,x]=i.useState(!1),w=async ee=>{try{await h({second_factor_policy:ee}),g(ee),l("2FA requirement updated successfully","info")}catch(_e){l(_e.message||"Failed to update 2FA requirement","error")}},[$,S]=i.useState(!1),[k,P]=i.useState(!1),[E,z]=i.useState(!1),[y,m]=i.useState(!1),b=i.useRef(null),_=i.useRef(null),j=i.useRef(null),T=i.useRef(null),[R,C]=i.useState("table"),[I,M]=i.useState(""),[F,L]=i.useState(""),[B,O]=i.useState(""),[A,X]=i.useState(["",""]),[te,V]=i.useState([]),[q,re]=i.useState(!1),[ne,J]=i.useState(!1),[oe]=i.useState(!1),[de,Z]=i.useState(!1),ae=(D=t==null?void 0:t.auth_settings)==null?void 0:D.auth_factors_enabled,xe=(ie=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.password)==null?void 0:ie.enabled;if(!(ae!=null&&ae.authenticator)&&!(ae!=null&&ae.backup_code)&&!xe)return null;const ue=async(ee,_e)=>{await o(ee,_e),await r.refetch(),l("Password updated successfully","info")},U=async ee=>{await n(ee),await r.refetch(),l("Password removed successfully","info")},pe=()=>{var Re,ir,cr,Zr,Ns,Fs;if(!r)return!1;const ee=(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"&&ee||((cr=ze==null?void 0:ze.magic_link)==null?void 0:cr.enabled)&&ee||((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))},K=async()=>{if(A.some(ee=>ee.length!==6)){l("Please enter both 6-digit verification codes","error");return}try{if(J(!0),await a(B,A),await r.refetch(),ae!=null&&ae.backup_code){const ee=await f();V(ee),await r.refetch(),C("backup")}else C("success")}catch(ee){l(ee.message||"Invalid verification codes","error")}finally{J(!1)}},H=()=>{C("table"),M(""),L(""),O(""),X(["",""]),V([]),l("Two-factor authentication setup completed successfully!","info")},se=async()=>{var ee;if((ee=r==null?void 0:r.user_authenticator)!=null&&ee.id)try{Z(!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{Z(!1)}},me=async()=>{if(!q)try{re(!0);const ee=await c();V(ee),await r.refetch(),m(!0),l("New backup codes generated","info")}catch(ee){l(ee.message||"Failed to generate backup codes","error")}finally{re(!1)}},fe=()=>{const ee=te.join(`
4129
- `);navigator.clipboard.writeText(ee).then(()=>{l("Backup codes copied to clipboard","info")}).catch(()=>{l("Failed to copy backup codes","error")})},W=()=>{const ee=te.join(`
4130
- `),_e=new Blob([ee],{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"]}),ae!=null&&ae.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(Q,{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..."})]})}):I?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Ls,{value:I,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:F||"Loading..."})]}),e.jsx(Q,{onClick:()=>C("verify"),disabled:!I||!F,style:{padding:"10px 20px",background:!I||!F?"var(--color-border)":"var(--color-primary)",color:!I||!F?"var(--color-secondary-text)":"white",border:`1px solid ${!I||!F?"var(--color-border)":"var(--color-primary)"}`,cursor:!I||!F?"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(le,{type:"text",placeholder:"000000",value:A[0],onChange:ee=>{const _e=ee.target.value.replace(/[^0-9]/g,"").substring(0,6);X([_e,A[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(le,{type:"text",placeholder:"000000",value:A[1],onChange:ee=>{const _e=ee.target.value.replace(/[^0-9]/g,"").substring(0,6);X([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(Q,{onClick:()=>C("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(Q,{onClick:K,disabled:ne||A.some(ee=>ee.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:ne?"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:te.map((ee,_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(ee),children:ee},_e))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(Q,{onClick:fe,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(Q,{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(Q,{onClick:H,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(Q,{onClick:H,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((ee,_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:ee.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:ee.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:ee.status==="Enabled"||ee.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:ee.status==="Enabled"||ee.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:ee.status}),e.jsxs("div",{style:{position:"relative"},children:[ee.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:_,onClick:()=>P(!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:()=>P(!1),onChangePassword:ue})]}),pe()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:j,onClick:()=>z(!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:()=>z(!1),onRemovePassword:U})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:_,onClick:()=>P(!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:()=>P(!1),onChangePassword:ue,isSetup:!0})]})}),ee.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:b,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:b,onClose:()=>S(!1),onSetupTOTP:async()=>{const be=await s();return O(be.id),be},onVerifyTOTP:async be=>{await a(B,be),await r.refetch(),l("Two-factor authentication enabled successfully!","info")}})]})}),ee.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{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:se,onCancel:()=>x(!1)})]}),ee.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Q,{ref:T,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"}),y&&e.jsx(lv,{triggerRef:T,codes:te,onClose:()=>m(!1),onCopy:fe,onDownload:W})]})}),ee.id==="second_factor_policy"&&e.jsx(Cr,{checked:u==="enforced",onChange:be=>{w(be?"enforced":"none")}})]})]})]}),_e<N.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},ee.id))}):e.jsx(it,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},$v=()=>{var L,B;const{deployment:t}=ve(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:s}=sr(),{toast:a}=Mt(),[p,f]=i.useState(""),[c,h]=i.useState(""),[l,u]=i.useState(""),[g,v]=i.useState(!1),[x,w]=i.useState(!1),[$,S]=i.useState(!1),[k,P]=i.useState(""),[E,z]=i.useState((r==null?void 0:r.profile_picture_url)||null),y=i.useRef(null);i.useEffect(()=>{r&&!g&&(f(r.first_name||""),h(r.last_name||""),u(r.username||""),z(r.profile_picture_url||null),v(!0))},[r,g]);const m=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]),b=O=>{f(O.target.value)},_=O=>{h(O.target.value)},j=O=>{u(O.target.value)},T=()=>{m()},R=()=>{m()},C=()=>{m()},I=O=>{var A;if((A=O.target.files)!=null&&A[0]){const X=O.target.files[0];z(URL.createObjectURL(X)),setTimeout(async()=>{try{await n(X),r.refetch(),a("Profile picture updated successfully","info")}catch(te){a(te.message||"Failed to update profile picture","error"),z((r==null?void 0:r.profile_picture_url)||null)}},100)}},M=()=>{y.current&&y.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const F=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),P(""),w(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:E?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,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:y,style:{display:"none"},accept:"image/*",onChange:I})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Q,{onClick:()=>{var 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(rn,{size:14}),E?"Change":"Upload"]}),e.jsxs(Q,{onClick:async()=>{z(null),y.current&&(y.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"),z((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(ce,{htmlFor:"firstName",children:"First Name"}),e.jsx(le,{id:"firstName",type:"text",value:p,onChange:b,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ce,{htmlFor:"lastName",children:"Last Name"}),e.jsx(le,{id:"lastName",type:"text",value:c,onChange:_,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((B=(L=t==null?void 0:t.auth_settings)==null?void 0:L.username)==null?void 0:B.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"username",children:"Username"}),e.jsx(le,{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(Q,{onClick:()=>{x?(w(!1),P("")):w(!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(ce,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(le,{id:"confirm_username",type:"text",value:k,onChange:O=>P(O.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(Q,{onClick:F,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:f,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||f||e.jsx(ad,{}),a&&e.jsx(ke.Footer,{children:a})]})})}),Ev=d.div`
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(`
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`
4131
4131
  position: relative;
4132
4132
  `,Iv=d.button`
4133
4133
  display: flex;
@@ -4266,7 +4266,7 @@ cursor: pointer;
4266
4266
  width: 14px;
4267
4267
  height: 14px;
4268
4268
  }
4269
- `,Ds=({showName:t=!0})=>{var y,m,b,_;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:f,signOut:c,switchSignIn:h,refetch:l}=Ue(),{navigateToSignIn:u}=Ge(),{deployment:g}=ve(),v=(y=f==null?void 0:f.active_signin)==null?void 0:y.user,x=((b=(m=g==null?void 0:g.auth_settings)==null?void 0:m.multi_session_support)==null?void 0:b.enabled)??!1,w=(((_=f==null?void 0:f.signins)==null?void 0:_.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const T=R=>{var I,M;const C=R.target;(I=n.current)!=null&&I.contains(C)||(M=s.current)!=null&&M.contains(C)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(j)}},[r]);const $=()=>{o(!r)},S=j=>j.split(" ").map(T=>T[0]).join("").toUpperCase(),k=async j=>{try{await c(j),await l(),o(!1)}catch{}},P=async()=>{try{await c(),await l(),o(!1)}catch{}},E=async j=>{try{await h(j),await l(),o(!1)}catch{}},z=()=>{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=[...(f==null?void 0:f.signins)||[]].sort((T,R)=>{const C=T.user.id===(v==null?void 0:v.id),I=R.user.id===(v==null?void 0:v.id);return C&&!I?-1:!C&&I?1:0});return j.map(({user:T,id:R},C)=>{const I=T.id===(v==null?void 0:v.id),M=!I;return e.jsxs(i.Fragment,{children:[e.jsxs(Ii,{$isClickable:M,onClick:M?()=>E(R):void 0,children:[e.jsxs(Pi,{children:[e.jsx(Yn,{children:e.jsx(Mi,{children:T.has_profile_picture?e.jsx("img",{src:T.profile_picture_url,alt:T.first_name}):S(`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`)})}),e.jsxs(Ri,{children:[e.jsx(Ti,{children:e.jsx($i,{children:`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`})}),e.jsx(Ei,{children:T.primary_email_address.email})]})]}),I&&e.jsxs(Oi,{children:[e.jsxs($o,{onClick:z,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"}})]},T.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:z,children:[e.jsx(er,{}),"Manage account"]}),e.jsxs($o,{$destructive:!0,onClick:()=>{var j;return k(((j=f==null?void 0:f.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"]})}),w&&e.jsx(Ai,{children:e.jsxs(Li,{onClick:P,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,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`
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),g=Math.floor(u/24);return g>7?p.toLocaleDateString():g>0?`${g}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 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`
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 f=!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"}),f&&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
+ `,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`
4490
4490
  position: relative;
4491
4491
  `,o1=d.div`
4492
4492
  width: 40px;
@@ -4549,7 +4549,7 @@ 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),[f,c]=i.useState(),h=i.useRef(null),l=i.useRef(null),u={channels:o,organization_ids:n,workspace_ids:s,limit:20},{unreadCount:g,notifications:v,loading:x,markAsRead:w,markAllAsRead:$,deleteNotification:S}=Sc(u);return i.useEffect(()=>{if(!a)return;const k=setTimeout(()=>{const P=E=>{var y,m;const z=E.target;(y=h.current)!=null&&y.contains(z)||(m=l.current)!=null&&m.contains(z)||p(!1)};return document.addEventListener("mousedown",P),()=>{document.removeEventListener("mousedown",P)}},50);return()=>{clearTimeout(k)}},[a]),i.useEffect(()=>{if(a&&h.current){const k=h.current.getBoundingClientRect(),P=400,E=600,z=window.innerWidth,y=window.innerHeight,m=z-k.left,b=y-k.bottom,_=k.top;let j,T;m>=P?j=k.left:T=z-k.right;let R,C;b>=E+8?R=k.bottom+8:_>=E+8?C=y-k.top+8:R=k.bottom+8,c({top:R,bottom:C,left:j,right:T})}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&&g>0&&e.jsx(s1,{children:g>9?"9+":g})]})}),typeof window<"u"&&a&&Wr.createPortal(e.jsx(ge,{children:e.jsx(dd,{ref:l,position:f,notifications:v,loading:x,onMarkAsRead:w,onMarkAllAsRead:$,onDelete:S})}),document.body)]})})}const a1=d.div`
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`
4553
4553
  display: flex;
4554
4554
  align-items: center;
4555
4555
  gap: 8px;
@@ -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,z,y,m,b;const{session:o,loading:n,switchSignIn:s,signOut:a}=Ue(),{deployment:p}=ve(),{navigateToSignIn:f,navigate:c}=Ge(),[h,l]=i.useState(null),[u,g]=i.useState(null),v=o==null?void 0:o.active_signin,x=(o==null?void 0:o.signins)||[],w=((z=(E=p==null?void 0:p.auth_settings)==null?void 0:E.multi_session_support)==null?void 0:z.enabled)??!1;i.useEffect(()=>{n||x.length||f()},[n,x,f]);const $=_=>_.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),S=async _=>{var j;if(!(_===(v==null?void 0:v.id)||u)){g(_);try{if(await s(_),t)t(_),g(null);else{let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),T){let R;try{R=new URL(T)}catch{R=new URL(T,window.location.origin)}(p==null?void 0:p.mode)==="staging"&&R.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(R.toString())}else g(null)}}catch(T){console.error("Failed to switch account:",T),g(null)}}},k=async(_,j)=>{_.stopPropagation(),l(j);try{await a(j)}catch(T){console.error("Failed to sign out:",T)}finally{l(null)}},P=()=>{var j;let _=new URLSearchParams(window.location.search).get("redirect_uri");_||(_=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),f(_)};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 ",((y=p==null?void 0:p.ui_settings)==null?void 0:y.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 ",(m=p==null?void 0:p.ui_settings)==null?void 0:m.app_name]})]}),e.jsxs(Ni,{children:[x.map(({user:_,id:j})=>{var I,M,F,L,B;if(!_)return null;const T=j===(v==null?void 0:v.id),R=u===j,C=`${_.first_name||""} ${_.last_name||""}`.trim();return e.jsxs(u1,{$isActive:T,$isSwitching:R,onClick:()=>S(j),children:[e.jsx(p1,{children:_.has_profile_picture?e.jsx("img",{src:_.profile_picture_url,alt:C}):$(C||((I=_.primary_email_address)==null?void 0:I.email)||((M=_.primary_phone_number)==null?void 0:M.phone_number)||_.username||"U")}),e.jsxs(h1,{children:[e.jsx(f1,{children:C||((F=_.primary_email_address)==null?void 0:F.email)||((L=_.primary_phone_number)==null?void 0:L.phone_number)||_.username||"User"}),e.jsx(g1,{children:((B=_.primary_email_address)==null?void 0:B.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&&w&&e.jsxs(x1,{onClick:P,children:[e.jsx(Ke,{}),"Add another account"]})]}),e.jsxs(w1,{children:["Don't have an account?"," ",e.jsx(j1,{children:e.jsx(ot,{to:`${(b=p.ui_settings)==null?void 0:b.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 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`
4786
4786
  width: 100%;
4787
4787
  height: 500px;
4788
4788
  background: var(--color-background);
@@ -4985,15 +4985,15 @@ cursor: pointer;
4985
4985
  color: var(--color-secondary-text);
4986
4986
  margin-bottom: 16px;
4987
4987
  line-height: 1.5;
4988
- `,tc=d(Q)`
4988
+ `,tc=d(X)`
4989
4989
  width: auto;
4990
4990
  margin: 0 auto;
4991
4991
  padding: 6px 16px;
4992
4992
  font-size: 13px;
4993
- `,L1=()=>{var T,R;const{organizationMemberships:t,refetch:r,loading:o}=Ct(),{workspaces:n}=Pt(),{switchOrganization:s,switchWorkspace:a}=Ue(),{deployment:p}=ve(),[f,c]=i.useState(null),[h,l]=i.useState("orgList"),[u,g]=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,w=i.useRef(!1);i.useEffect(()=>{if(!(w.current||!t)){if(w.current=!0,t.length===0){l("createOrg");return}if(!v){l("orgList");return}if(!n||n.length===0){t[0]&&g(t[0].organization.id),l("createWorkspace");return}l("orgList")}},[t,n,v]),console.log("view mode",h,v);const $=C=>C.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),S=async C=>{if(v){g(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)}},P=async C=>{await r(),v&&C&&(g(C.id),l("createWorkspace"))},E=()=>{},z=async()=>{g(null),l("orgList")},y=(T=t==null?void 0:t.find(C=>C.organization.id===u))==null?void 0:T.organization,m=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:P,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 b=h==="workspaceList",_=b?"Select a workspace":"Select an organization",j=b?`Choose a workspace in ${(y==null?void 0:y.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:b?"Workspaces":"Your organizations"}),b&&e.jsxs(R1,{onClick:z,children:[e.jsx(Gr,{}),"Go back"]})]}),e.jsx(A1,{children:b?e.jsx(e.Fragment,{children:m&&m.length>0?m.map(C=>{var M,F,L;const I=((M=C.eligibility_restriction)==null?void 0:M.type)!=="none"&&((F=C.eligibility_restriction)==null?void 0:F.type)!==void 0;return e.jsxs(Vi,{onClick:()=>!I&&k(C),disabled:f===C.id||I,style:{opacity:I?.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,{})}),I&&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"," ",(y==null?void 0:y.name)||"this organization"]}),e.jsxs(tc,{onClick:()=>l("createWorkspace"),children:[e.jsx(Ke,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(C=>{var te,V,q;const I=C.organization,M=n==null?void 0:n.filter(re=>re.organization.id===I.id),F=(M==null?void 0:M.length)||0,L=I.member_count,B=C.roles[0].name,O=C.roles.length-1,A=O>0?`${B.charAt(0).toUpperCase()+B.slice(1)} +${O}`:B.charAt(0).toUpperCase()+B.slice(1),X=((te=C.eligibility_restriction)==null?void 0:te.type)!=="none"&&((V=C.eligibility_restriction)==null?void 0:V.type)!==void 0;return e.jsxs(Vi,{onClick:()=>!X&&S(I),disabled:f===I.id||X,style:{opacity:X?.7:1},children:[e.jsx(Gi,{children:I.image_url?e.jsx(Hi,{src:I.image_url,alt:I.name}):$(I.name)}),e.jsxs(qi,{children:[e.jsx(Yi,{children:I.name}),e.jsx(Zi,{children:v?e.jsxs(e.Fragment,{children:[e.jsx(Uo,{}),F," workspace",F!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(Gp,{}),A," • ",L," member",L!==1?"s":""]})})]}),e.jsx(Ki,{children:e.jsx(ms,{})}),X&&e.jsxs(Qi,{children:[e.jsx(ut,{size:14}),(q=C.eligibility_restriction)==null?void 0:q.message]})]},I.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"]})]})})]}),b&&m&&m.length>0&&e.jsxs(Q,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createWorkspace"),disabled:f!==null,children:[e.jsx(Ke,{size:12}),"Create new workspace"]}),!b&&t&&t.length>0&&x&&e.jsxs(Q,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createOrg"),disabled:f!==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),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)`
4994
4994
  padding: 0;
4995
4995
  max-width: 90vw;
4996
- `,N1=({children:t})=>{var w,$,S,k;const{loading:r,session:o}=Ue(),{activeOrganization:n}=Ze(),{activeWorkspace:s,loading:a}=Rt(),{workspaces:p}=Pt(),{deployment:f}=ve(),{organizationMemberships:c}=Ct(),h=(f==null?void 0:f.b2b_settings.workspaces_enabled)??!1,l=c==null?void 0:c.find(P=>P.organization.id===(n==null?void 0:n.id)),u=p==null?void 0:p.find(P=>{var E;return P.id===((E=o==null?void 0:o.active_signin)==null?void 0:E.active_workspace_membership_id)}),g=((w=l==null?void 0:l.eligibility_restriction)==null?void 0:w.type)!=="none"&&(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!==void 0,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:(g||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,$,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`
4997
4997
  display: flex;
4998
4998
  gap: 8px;
4999
4999
  flex-wrap: wrap;
@@ -5021,7 +5021,7 @@ cursor: pointer;
5021
5021
  border-radius: 8px;
5022
5022
  font-size: 10px;
5023
5023
  font-weight: 400;
5024
- `,W1={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function V1({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=s=>{if(t.includes(s)){const p=t.filter(f=>f!==s);p.length===0?o(["user"]):o(p)}else o([...t,s])};return e.jsx(F1,{children:Object.entries(W1).map(([s,a])=>{const p=(r==null?void 0:r[s])||0,f=t.includes(s);return e.jsxs(B1,{$active:f,onClick:()=>n(s),children:[a,p>0&&e.jsx(U1,{children:p})]},s)})})}const rc=d.div`
5024
+ `,W1={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function V1({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=s=>{if(t.includes(s)){const p=t.filter(g=>g!==s);p.length===0?o(["user"]):o(p)}else o([...t,s])};return e.jsx(F1,{children:Object.entries(W1).map(([s,a])=>{const p=(r==null?void 0:r[s])||0,g=t.includes(s);return e.jsxs(B1,{$active:g,onClick:()=>n(s),children:[a,p>0&&e.jsx(U1,{children:p})]},s)})})}const rc=d.div`
5025
5025
  display: flex;
5026
5026
  flex-direction: column;
5027
5027
  width: 100%;
@@ -5097,7 +5097,7 @@ cursor: pointer;
5097
5097
  font-size: 11px;
5098
5098
  color: ${t=>t.$status==="Connecting..."?"var(--color-warning)":t.$status==="Connection error"||t.$status==="Disconnected"?"var(--color-error)":t.$status==="Waiting for your input..."?"var(--color-info)":t.$status==="Working..."?"var(--color-primary)":t.$status==="Ready"?"var(--color-success)":"var(--color-secondary-text)"};
5099
5099
  font-weight: 400;
5100
- `,eb=d.div`
5100
+ `,e2=d.div`
5101
5101
  font-size: 10px;
5102
5102
  padding: 2px 6px;
5103
5103
  border-radius: 9999px;
@@ -5116,7 +5116,7 @@ cursor: pointer;
5116
5116
  background-color: var(--color-error-background);
5117
5117
  color: var(--color-error-text);
5118
5118
  `;default:return"display: none;"}}}
5119
- `,tb=d.div`
5119
+ `,t2=d.div`
5120
5120
  flex: 1;
5121
5121
  overflow-y: auto;
5122
5122
  overflow-x: hidden;
@@ -5167,7 +5167,7 @@ cursor: pointer;
5167
5167
  margin-right: auto;
5168
5168
  font-weight: 400;
5169
5169
  `}
5170
- `,rb=d.span`
5170
+ `,r2=d.span`
5171
5171
  display: inline-flex;
5172
5172
  gap: 2px;
5173
5173
  margin-left: 8px;
@@ -5191,7 +5191,7 @@ cursor: pointer;
5191
5191
  opacity: 1;
5192
5192
  }
5193
5193
  }
5194
- `,ob=d(hd)`
5194
+ `,o2=d(hd)`
5195
5195
  opacity: 0.7;
5196
5196
  position: relative;
5197
5197
  display: inline-block;
@@ -5216,7 +5216,7 @@ cursor: pointer;
5216
5216
  transform: rotate(360deg);
5217
5217
  }
5218
5218
  }
5219
- `,nb=d.div`
5219
+ `,n2=d.div`
5220
5220
  display: flex;
5221
5221
  justify-content: flex-start;
5222
5222
  align-items: center;
@@ -5274,7 +5274,7 @@ cursor: pointer;
5274
5274
  margin: 0;
5275
5275
  font-size: 13px;
5276
5276
  }
5277
- `,sb=d.div`
5277
+ `,s2=d.div`
5278
5278
  background: var(--color-primary-background);
5279
5279
  border: 1px solid var(--color-primary-border);
5280
5280
  border-radius: 8px;
@@ -5372,12 +5372,12 @@ cursor: pointer;
5372
5372
  flex-direction: row;
5373
5373
  gap: 20px;
5374
5374
  }
5375
- `,ab=d.form`
5375
+ `,a2=d.form`
5376
5376
  padding: 20px;
5377
5377
  background: var(--color-background);
5378
5378
  border-top: 1px solid var(--color-border);
5379
5379
  flex-shrink: 0;
5380
- `,ib=d.div`
5380
+ `,i2=d.div`
5381
5381
  position: relative;
5382
5382
  display: flex;
5383
5383
  align-items: flex-end;
@@ -5386,13 +5386,13 @@ cursor: pointer;
5386
5386
  border-radius: 12px;
5387
5387
  padding: 8px 8px 8px 20px;
5388
5388
  min-height: 56px;
5389
- `,cb=d.div`
5389
+ `,c2=d.div`
5390
5390
  flex: 1;
5391
5391
  display: flex;
5392
5392
  flex-direction: column;
5393
5393
  gap: 8px;
5394
5394
  padding-right: 12px;
5395
- `,lb=d.textarea`
5395
+ `,l2=d.textarea`
5396
5396
  width: 100%;
5397
5397
  padding: 0;
5398
5398
  border: none;
@@ -5414,11 +5414,11 @@ cursor: pointer;
5414
5414
  color: var(--color-text-disabled);
5415
5415
  cursor: not-allowed;
5416
5416
  }
5417
- `,db=d.div`
5417
+ `,d2=d.div`
5418
5418
  display: flex;
5419
5419
  gap: 8px;
5420
5420
  margin-top: 4px;
5421
- `,ub=d.div`
5421
+ `,u2=d.div`
5422
5422
  display: flex;
5423
5423
  gap: 8px;
5424
5424
  padding: 8px 20px;
@@ -5426,7 +5426,7 @@ cursor: pointer;
5426
5426
  background: var(--color-background);
5427
5427
  overflow-x: auto;
5428
5428
  max-height: 120px;
5429
- `,pb=d.div`
5429
+ `,p2=d.div`
5430
5430
  position: relative;
5431
5431
  width: 80px;
5432
5432
  height: 80px;
@@ -5440,7 +5440,7 @@ cursor: pointer;
5440
5440
  height: 100%;
5441
5441
  object-fit: cover;
5442
5442
  }
5443
- `,hb=d.button`
5443
+ `,h2=d.button`
5444
5444
  position: absolute;
5445
5445
  top: 4px;
5446
5446
  right: 4px;
@@ -5458,9 +5458,9 @@ cursor: pointer;
5458
5458
  &:hover {
5459
5459
  background: rgba(0, 0, 0, 0.9);
5460
5460
  }
5461
- `,fb=d.input`
5461
+ `,f2=d.input`
5462
5462
  display: none;
5463
- `,gb=d.button`
5463
+ `,g2=d.button`
5464
5464
  padding: 4px 10px;
5465
5465
  border: 1px solid var(--color-border);
5466
5466
  border-radius: 8px;
@@ -5485,7 +5485,7 @@ cursor: pointer;
5485
5485
  border-color: var(--color-border);
5486
5486
  cursor: not-allowed;
5487
5487
  }
5488
- `,mb=d.button`
5488
+ `,m2=d.button`
5489
5489
  align-self: flex-end;
5490
5490
  padding: 6px;
5491
5491
  border: none;
@@ -5510,7 +5510,7 @@ cursor: pointer;
5510
5510
  color: var(--color-text-disabled);
5511
5511
  cursor: not-allowed;
5512
5512
  }
5513
- `,xb=d.div`
5513
+ `,x2=d.div`
5514
5514
  display: ${t=>t.$isOpen?"flex":"none"};
5515
5515
  position: fixed;
5516
5516
  top: 0;
@@ -5535,7 +5535,7 @@ cursor: pointer;
5535
5535
  backdrop-filter: blur(10px);
5536
5536
  }
5537
5537
  }
5538
- `,vb=d.div`
5538
+ `,v2=d.div`
5539
5539
  position: relative;
5540
5540
  width: 100%;
5541
5541
  height: 100%;
@@ -5591,7 +5591,7 @@ cursor: pointer;
5591
5591
  `,Eo=d(fd)`
5592
5592
  width: 32px;
5593
5593
  padding: 0;
5594
- `,bb=d.img`
5594
+ `,b2=d.img`
5595
5595
  max-width: calc(100% - 20px);
5596
5596
  max-height: calc(100% - 20px);
5597
5597
  width: auto;
@@ -5602,7 +5602,7 @@ cursor: pointer;
5602
5602
  transition: ${t=>t.$isDragging?"none":"transform 0.2s ease"};
5603
5603
  user-select: none;
5604
5604
  -webkit-user-drag: none;
5605
- `,yb=d.div`
5605
+ `,y2=d.div`
5606
5606
  position: absolute;
5607
5607
  bottom: 20px;
5608
5608
  left: 50%;
@@ -5610,7 +5610,7 @@ cursor: pointer;
5610
5610
  display: flex;
5611
5611
  gap: 8px;
5612
5612
  align-items: center;
5613
- `,wb=d.div`
5613
+ `,w2=d.div`
5614
5614
  display: flex;
5615
5615
  gap: 4px;
5616
5616
  align-items: center;
@@ -5620,14 +5620,14 @@ cursor: pointer;
5620
5620
  border-radius: 12px;
5621
5621
  padding: 4px;
5622
5622
  box-shadow: 0 10px 25px -5px var(--color-shadow);
5623
- `,jb=d.span`
5623
+ `,j2=d.span`
5624
5624
  min-width: 60px;
5625
5625
  text-align: center;
5626
5626
  font-size: 12px;
5627
5627
  font-weight: 400;
5628
5628
  color: var(--color-foreground);
5629
5629
  padding: 0 8px;
5630
- `,_b=d.div`
5630
+ `,_2=d.div`
5631
5631
  height: 125px;
5632
5632
  width: auto;
5633
5633
  min-width: 125px;
@@ -5675,18 +5675,18 @@ cursor: pointer;
5675
5675
  &:hover .expand-icon {
5676
5676
  opacity: 1;
5677
5677
  }
5678
- `,kb=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:s,onClose:a,onDownload:p,onZoom:f,onReset:c,onWheel:h,onMouseDown:l,onMouseMove:u,onMouseUp:g})=>{const[v,x]=i.useState(!1),w=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()},P=E=>{E.preventDefault()};return document.addEventListener("wheel",S,{passive:!1}),document.addEventListener("gesturestart",k,{passive:!1}),document.addEventListener("gesturechange",P,{passive:!1}),()=>{document.body.style.overflow=$,document.removeEventListener("wheel",S),document.removeEventListener("gesturestart",k),document.removeEventListener("gesturechange",P)}}},[t]),!v||!t||!r?null:Wr.createPortal(e.jsx(ge,{children:e.jsx(xb,{ref:w,$isOpen:!0,onClick:$=>{$.target===$.currentTarget&&a()},children:e.jsxs(vb,{onClick:$=>$.stopPropagation(),onWheel:$=>{$.preventDefault(),$.stopPropagation(),h($)},onMouseMove:u,onMouseUp:g,onMouseLeave:g,children:[e.jsx(bb,{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(yb,{children:[e.jsxs(wb,{children:[e.jsx(Eo,{$variant:"ghost",onClick:()=>f(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(Ah,{size:14})}),e.jsxs(jb,{children:[Math.round(o*100),"%"]}),e.jsx(Eo,{$variant:"ghost",onClick:()=>f(.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(),f=a==null?void 0:a.id;if(!f)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,g]=i.useState(""),[v,x]=i.useState(!1),[w,$]=i.useState(null),[S,k]=i.useState([]),[P,E]=i.useState([]),[z,y]=i.useState(null),[m,b]=i.useState(1),[_,j]=i.useState(!1),[T,R]=i.useState({x:0,y:0}),[C,I]=i.useState({x:0,y:0}),M=i.useRef(null),F=i.useRef(null),{messages:L,pendingMessage:B,pendingImages:O,connectionState:A,isConnected:X,isExecuting:te,executionStatus:V,isWaitingForInput:q,sendMessage:re,submitUserInput:ne,cancelExecution:J}=zc({contextId:f,agentName:o,token:n,platformAdapter:s,autoConnect:c});i.useEffect(()=>{var N;(N=M.current)==null||N.scrollIntoView({behavior:"smooth"})},[L]),i.useEffect(()=>{var N;if(q){const D=L.slice().reverse().find(Y=>{var ie;return((ie=Y.metadata)==null?void 0:ie.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(),!!X)if(q&&w){let D=u.trim();w.input_type==="multiselect"&&(D=S.join(",")),D&&(ne(D),g(""),k([]))}else!te&&u.trim()&&(re(u,P.length>0?P:void 0),g(""),E([]))},de=N=>{const D=N.target.files;D&&(Array.from(D).forEach(Y=>{if(Y.type.startsWith("image/")){const ie=new FileReader;ie.onload=ee=>{var _e;if((_e=ee.target)!=null&&_e.result){const ze=ee.target.result.split(",")[1];E(Ae=>[...Ae,{mime_type:Y.type,data:ze}])}},ie.readAsDataURL(Y)}}),F.current&&(F.current.value=""))},Z=N=>{E(D=>D.filter((Y,ie)=>ie!==N))},ae=N=>{y(N),b(1),R({x:0,y:0})},xe=()=>{y(null),b(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=>{b(D=>{const Y=D+N;return Math.min(Math.max(Y,.5),3)})},pe=N=>{N.preventDefault(),N.stopPropagation();const D=N.deltaY>0?-.1:.1;U(D)},K=N=>{m>1&&(j(!0),I({x:N.clientX-T.x,y:N.clientY-T.y}))},H=N=>{_&&m>1&&R({x:N.clientX-C.x,y:N.clientY-C.y})},se=()=>{j(!1)},me=()=>A.status===wt.CONNECTING?"Connecting...":A.status===wt.ERROR?"Connection error":A.status===wt.DISCONNECTED||!X?"Disconnected":q?"Waiting for your input...":te?"Working...":"Ready",fe=()=>{if(!q||!w)return"Ask anything";switch(w.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},W=()=>!q||!w?!1:["select","multiselect","boolean","date"].includes(w.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(eb,{$status:V,children:V.replace("_"," ")})]}),e.jsx(tb,{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 Y,ie,ee,_e;if(((Y=N.metadata)==null?void 0:Y.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&&(w==null?void 0:w.input_type)===be.input_type;return e.jsx(Zn,{$isUser:!1,children:e.jsxs(sb,{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=>g(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=>g(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=>g(Re.target.value),disabled:!Ae}),e.jsx("span",{children:"No"})]})]}),be.input_type==="date"&&e.jsx("input",{type:"date",value:Ae?u:"",onChange:Re=>g(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(((ie=N.metadata)==null?void 0:ie.type)==="log"){const be=L[D-1],ze=L[D+1],Ae=((ee=be==null?void 0:be.metadata)==null?void 0:ee.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(nb,{$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(_b,{onClick:()=>ae(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(rb,{})]})},N.id)}),B&&e.jsx(Zn,{$isUser:!0,children:e.jsxs(ob,{$isUser:!0,children:[e.jsx("div",{children:B}),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:M})]})}),P.length>0&&e.jsx(ub,{children:P.map((N,D)=>e.jsxs(pb,{children:[e.jsx("img",{src:N.data?`data:${N.mime_type};base64,${N.data}`:"#",alt:`Upload ${D+1}`}),e.jsx(hb,{type:"button",onClick:()=>Z(D),children:e.jsx(et,{size:12})})]},D))}),e.jsx(ab,{onSubmit:oe,children:e.jsxs(ib,{children:[e.jsxs(cb,{children:[e.jsx(lb,{value:u,onChange:N=>g(N.target.value),onKeyDown:N=>{N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),oe(N))},placeholder:fe(),disabled:!X||te&&!q||W(),rows:1}),e.jsx(db,{children:e.jsxs(gb,{type:"button",disabled:!X||te,onClick:()=>{var N;return(N=F.current)==null?void 0:N.click()},children:[e.jsx(vh,{size:16}),"Attach"]})}),e.jsx(fb,{ref:F,type:"file",accept:"image/*",multiple:!0,onChange:de})]}),e.jsx(mb,{type:te?"button":"submit",disabled:!X||!q&&!te&&!u.trim(),onClick:te?J:void 0,onMouseEnter:()=>x(!0),onMouseLeave:()=>x(!1),style:{background:te&&v?"var(--color-error)":void 0},children:te?v?e.jsx(et,{size:14}):e.jsx(kt,{size:14,className:"animate-spin"}):e.jsx($s,{size:14})})]})})]}),e.jsx(kb,{isOpen:!!z,imageUrl:z,zoomLevel:m,dragPosition:T,isDragging:_,onClose:xe,onDownload:()=>z&&ue(z),onZoom:U,onReset:()=>{b(1),R({x:0,y:0})},onWheel:pe,onMouseDown:K,onMouseMove:H,onMouseUp:se})]})}const Cb=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[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`
5679
5679
  height: 100%;
5680
5680
  display: flex;
5681
5681
  flex-direction: column;
5682
5682
  background: var(--color-background);
5683
- `,Sb=d.div`
5683
+ `,S2=d.div`
5684
5684
  display: flex;
5685
5685
  align-items: center;
5686
5686
  gap: var(--space-md);
5687
5687
  padding: var(--space-lg);
5688
5688
  border-bottom: 1px solid var(--color-border);
5689
- `,zb=d.button`
5689
+ `,z2=d.button`
5690
5690
  display: flex;
5691
5691
  align-items: center;
5692
5692
  justify-content: center;
@@ -5702,16 +5702,16 @@ cursor: pointer;
5702
5702
  &:hover {
5703
5703
  background: var(--color-background-hover);
5704
5704
  }
5705
- `,$b=d.h1`
5705
+ `,$2=d.h1`
5706
5706
  flex: 1;
5707
5707
  margin: 0;
5708
5708
  font-size: var(--font-lg);
5709
5709
  font-weight: 400;
5710
5710
  color: var(--color-foreground);
5711
- `,Eb=d.div`
5711
+ `,E2=d.div`
5712
5712
  padding: var(--space-lg);
5713
5713
  border-bottom: 1px solid var(--color-border);
5714
- `,Ib=d.input`
5714
+ `,I2=d.input`
5715
5715
  width: 100%;
5716
5716
  padding: var(--space-sm) var(--space-md);
5717
5717
  background: var(--color-background-subtle);
@@ -5730,20 +5730,20 @@ cursor: pointer;
5730
5730
  border-color: var(--color-primary);
5731
5731
  background: var(--color-background);
5732
5732
  }
5733
- `,Pb=d.div`
5733
+ `,P2=d.div`
5734
5734
  flex: 1;
5735
5735
  overflow-y: auto;
5736
5736
  padding: var(--space-lg);
5737
- `,Rb=d.div`
5737
+ `,R2=d.div`
5738
5738
  margin-bottom: var(--space-xl);
5739
- `,Tb=d.h3`
5739
+ `,T2=d.h3`
5740
5740
  font-size: var(--font-xs);
5741
5741
  font-weight: 400;
5742
5742
  color: var(--color-muted);
5743
5743
  margin: 0 0 var(--space-sm) 0;
5744
5744
  text-transform: uppercase;
5745
5745
  letter-spacing: 0.05em;
5746
- `,Mb=d.div`
5746
+ `,M2=d.div`
5747
5747
  display: flex;
5748
5748
  align-items: center;
5749
5749
  gap: var(--space-md);
@@ -5759,7 +5759,7 @@ cursor: pointer;
5759
5759
  background: var(--color-surface-hover, var(--color-background-hover));
5760
5760
  border-color: var(--color-border-hover, var(--color-border));
5761
5761
  }
5762
- `,Ob=d.div`
5762
+ `,O2=d.div`
5763
5763
  width: 36px;
5764
5764
  height: 36px;
5765
5765
  display: flex;
@@ -5768,10 +5768,10 @@ cursor: pointer;
5768
5768
  background: var(--color-background-subtle);
5769
5769
  border-radius: var(--radius-md);
5770
5770
  color: var(--color-secondary-text);
5771
- `,Ab=d.div`
5771
+ `,A2=d.div`
5772
5772
  flex: 1;
5773
5773
  min-width: 0;
5774
- `,Lb=d.div`
5774
+ `,L2=d.div`
5775
5775
  font-size: var(--font-sm);
5776
5776
  font-weight: 400;
5777
5777
  color: var(--color-foreground);
@@ -5779,13 +5779,13 @@ cursor: pointer;
5779
5779
  white-space: nowrap;
5780
5780
  overflow: hidden;
5781
5781
  text-overflow: ellipsis;
5782
- `,Db=d.div`
5782
+ `,D2=d.div`
5783
5783
  font-size: var(--font-2xs);
5784
5784
  color: var(--color-secondary-text);
5785
5785
  display: flex;
5786
5786
  align-items: center;
5787
5787
  gap: var(--space-xs);
5788
- `,Nb=d.span`
5788
+ `,N2=d.span`
5789
5789
  display: inline-block;
5790
5790
  padding: 2px 6px;
5791
5791
  border-radius: var(--radius-sm);
@@ -5793,7 +5793,7 @@ cursor: pointer;
5793
5793
  font-weight: 400;
5794
5794
  background: ${t=>{switch(t.$status){case"running":return"var(--color-success-bg)";case"waiting_for_input":return"var(--color-warning-bg)";case"failed":return"var(--color-error-bg)";default:return"var(--color-background-subtle)"}}};
5795
5795
  color: ${t=>{switch(t.$status){case"running":return"var(--color-success)";case"waiting_for_input":return"var(--color-warning)";case"failed":return"var(--color-error)";default:return"var(--color-secondary-text)"}}};
5796
- `,Fb=d.button`
5796
+ `,F2=d.button`
5797
5797
  display: flex;
5798
5798
  align-items: center;
5799
5799
  justify-content: center;
@@ -5810,7 +5810,7 @@ cursor: pointer;
5810
5810
  background: var(--color-error-bg);
5811
5811
  color: var(--color-error);
5812
5812
  }
5813
- `,Bb=d.div`
5813
+ `,B2=d.div`
5814
5814
  display: flex;
5815
5815
  flex-direction: column;
5816
5816
  align-items: center;
@@ -5826,11 +5826,11 @@ cursor: pointer;
5826
5826
  margin-bottom: var(--space-md);
5827
5827
  opacity: 0.5;
5828
5828
  }
5829
- `,Ub=d.div`
5829
+ `,U2=d.div`
5830
5830
  display: flex;
5831
5831
  flex-direction: column;
5832
5832
  gap: var(--space-sm);
5833
- `,Wb=d.div`
5833
+ `,W2=d.div`
5834
5834
  display: flex;
5835
5835
  align-items: center;
5836
5836
  gap: var(--space-md);
@@ -5849,33 +5849,33 @@ cursor: pointer;
5849
5849
  opacity: 0.5;
5850
5850
  }
5851
5851
  }
5852
- `,Vb=d.div`
5852
+ `,V2=d.div`
5853
5853
  width: 36px;
5854
5854
  height: 36px;
5855
5855
  background: var(--color-border);
5856
5856
  border-radius: var(--radius-md);
5857
- `,Gb=d.div`
5857
+ `,G2=d.div`
5858
5858
  flex: 1;
5859
5859
  display: flex;
5860
5860
  flex-direction: column;
5861
5861
  gap: var(--space-xs);
5862
- `,Hb=d.div`
5862
+ `,H2=d.div`
5863
5863
  height: 14px;
5864
5864
  width: 60%;
5865
5865
  background: var(--color-border);
5866
5866
  border-radius: var(--radius-sm);
5867
- `,qb=d.div`
5867
+ `,q2=d.div`
5868
5868
  height: 12px;
5869
5869
  width: 30%;
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:f}=qo(),c=n.filter(v=>v.title.toLowerCase().includes(r.toLowerCase())),h=v=>{const x={},w=new Date,$=new Date(w.getFullYear(),w.getMonth(),w.getDate()),S=new Date($);S.setDate(S.getDate()-1);const k=new Date($);return k.setDate(k.getDate()-7),v.forEach(P=>{const E=new Date(P.last_activity_at);let z;E>=$?z="Today":E>=S?z="Yesterday":E>=k?z="This Week":z="Older",x[z]||(x[z]=[]),x[z].push(P)}),x},l=async(v,x)=>{if(v.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await p(x)}catch(w){console.error("Failed to delete session:",w)}},u=v=>new Date(v).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),g=h(c);return e.jsx(ge,{style:{height:"100%",width:"100%"},children:e.jsxs(Cb,{children:[e.jsxs(Sb,{children:[t&&e.jsx(zb,{onClick:()=>f(!1),children:e.jsx(Gr,{size:20})}),e.jsx($b,{children:"Conversation History"})]}),e.jsx(Eb,{children:e.jsx(Ib,{type:"text",placeholder:"Search conversations...",value:r,onChange:v=>o(v.target.value)})}),e.jsx(Pb,{children:s?e.jsx(Ub,{children:[1,2,3,4,5].map(v=>e.jsxs(Wb,{children:[e.jsx(Vb,{}),e.jsxs(Gb,{children:[e.jsx(Hb,{}),e.jsx(qb,{})]})]},v))}):c.length===0?e.jsxs(Bb,{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(g).map(([v,x])=>e.jsxs(Rb,{children:[e.jsx(Tb,{children:v}),x.map(w=>e.jsxs(Mb,{onClick:()=>a(w),children:[e.jsx(Ob,{children:e.jsx(fa,{size:18})}),e.jsxs(Ab,{children:[e.jsx(Lb,{children:w.title}),e.jsxs(Db,{children:[e.jsx("span",{children:u(w.last_activity_at)}),w.status!=="idle"&&e.jsx(Nb,{$status:w.status,children:w.status.replace("_"," ")})]})]}),e.jsx(Fb,{onClick:$=>l($,w.id),children:e.jsx(nn,{size:16})})]},w.id))]},v))})]})})}const Yb=d.div`
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`
5874
5874
  height: 100%;
5875
5875
  display: flex;
5876
5876
  flex-direction: column;
5877
5877
  background: var(--color-background);
5878
- `,Zb=d.div`
5878
+ `,Z2=d.div`
5879
5879
  height: 100%;
5880
5880
  display: flex;
5881
5881
  flex-direction: column;
@@ -5883,7 +5883,7 @@ cursor: pointer;
5883
5883
  justify-content: center;
5884
5884
  padding: var(--space-2xl);
5885
5885
  overflow: auto;
5886
- `,Kb=d.div`
5886
+ `,K2=d.div`
5887
5887
  width: 56px;
5888
5888
  height: 56px;
5889
5889
  margin-bottom: var(--space-lg);
@@ -5894,18 +5894,18 @@ cursor: pointer;
5894
5894
  color: var(--color-secondary-text);
5895
5895
  opacity: 0.6;
5896
5896
  }
5897
- `,Qb=d.h2`
5897
+ `,Q2=d.h2`
5898
5898
  font-size: var(--font-lg);
5899
5899
  font-weight: 400;
5900
5900
  color: var(--color-foreground);
5901
5901
  margin: 0 0 var(--space-sm) 0;
5902
5902
  text-align: center;
5903
- `,Xb=d.p`
5903
+ `,X2=d.p`
5904
5904
  font-size: var(--font-sm);
5905
5905
  color: var(--color-secondary-text);
5906
5906
  margin: 0 0 var(--space-xl) 0;
5907
5907
  text-align: center;
5908
- `,Jb=d.button`
5908
+ `,J2=d.button`
5909
5909
  background: var(--color-primary);
5910
5910
  color: white;
5911
5911
  border: none;
@@ -5943,7 +5943,7 @@ cursor: pointer;
5943
5943
  opacity: 0.6;
5944
5944
  }
5945
5945
  }
5946
- `,e2=d.span`
5946
+ `,eb=d.span`
5947
5947
  &::after {
5948
5948
  content: ".";
5949
5949
  animation: dots 1.5s steps(3, end) infinite;
@@ -5962,7 +5962,7 @@ cursor: pointer;
5962
5962
  content: "...";
5963
5963
  }
5964
5964
  }
5965
- `,t2=d.div`
5965
+ `,tb=d.div`
5966
5966
  width: 100%;
5967
5967
  padding: var(--space-md);
5968
5968
  background: var(--color-surface, var(--color-background));
@@ -5977,7 +5977,7 @@ cursor: pointer;
5977
5977
  background: var(--color-surface-hover, var(--color-background-hover));
5978
5978
  border-color: var(--color-border-hover, var(--color-border));
5979
5979
  }
5980
- `,r2=d.div`
5980
+ `,rb=d.div`
5981
5981
  font-size: var(--font-sm);
5982
5982
  font-weight: 400;
5983
5983
  color: var(--color-foreground);
@@ -5985,34 +5985,34 @@ cursor: pointer;
5985
5985
  white-space: nowrap;
5986
5986
  overflow: hidden;
5987
5987
  text-overflow: ellipsis;
5988
- `,o2=d.div`
5988
+ `,ob=d.div`
5989
5989
  font-size: var(--font-2xs);
5990
5990
  color: var(--color-secondary-text);
5991
5991
  display: flex;
5992
5992
  align-items: center;
5993
5993
  gap: var(--space-xs);
5994
- `,n2=d.div`
5994
+ `,nb=d.div`
5995
5995
  flex: 1;
5996
5996
  min-width: 0;
5997
- `,s2=d.div`
5997
+ `,sb=d.div`
5998
5998
  width: 100%;
5999
5999
  max-width: 320px;
6000
6000
  margin-top: var(--space-2xl);
6001
6001
  padding-top: var(--space-2xl);
6002
6002
  border-top: 1px solid var(--color-border);
6003
- `,a2=d.div`
6003
+ `,ab=d.div`
6004
6004
  display: flex;
6005
6005
  justify-content: space-between;
6006
6006
  align-items: center;
6007
6007
  margin-bottom: var(--space-md);
6008
- `,i2=d.h3`
6008
+ `,ib=d.h3`
6009
6009
  font-size: var(--font-xs);
6010
6010
  font-weight: 400;
6011
6011
  color: var(--color-muted);
6012
6012
  margin: 0;
6013
6013
  text-transform: uppercase;
6014
6014
  letter-spacing: 0.05em;
6015
- `,c2=d.button`
6015
+ `,cb=d.button`
6016
6016
  background: transparent;
6017
6017
  border: none;
6018
6018
  color: var(--color-primary);
@@ -6024,9 +6024,9 @@ cursor: pointer;
6024
6024
  &:hover {
6025
6025
  opacity: 0.8;
6026
6026
  }
6027
- `,l2=d.div`
6027
+ `,lb=d.div`
6028
6028
  display: flex;
6029
6029
  flex-direction: column;
6030
6030
  gap: var(--space-xs);
6031
- `;function d2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:s,selectSession:a,createSession:p,setShowHistory:f}=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),w=Math.floor(x/60),$=Math.floor(w/24);return $>0?`${$}d ago`:w>0?`${w}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(Yb,{children:e.jsxs(Zb,{children:[e.jsx(Kb,{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(Qb,{children:"Hi there! 👋"}),e.jsx(Xb,{children:"How can I help you today?"}),e.jsx(Jb,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(e2,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(s2,{children:[e.jsxs(a2,{children:[e.jsx(i2,{children:"Recent Chats"}),e.jsx(c2,{onClick:()=>f(!0),children:"View All →"})]}),e.jsx(l2,{children:o.slice(0,2).map(l=>e.jsx(t2,{onClick:()=>a(l),children:e.jsxs(n2,{children:[e.jsx(r2,{children:l.title}),e.jsxs(o2,{children:[e.jsx("span",{children:h(l.last_activity_at)}),l.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},l.id))})]})]})})})}const u2=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))},p2=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=d2;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=le;exports.Label=ce;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=u2;exports.isOrgAdmin=v0;exports.isSafeUrl=p2;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),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]})});
6032
6032
  //# sourceMappingURL=index.cjs.js.map