@wacht/jsx 0.0.1-alpha.60 → 0.0.1-alpha.62
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 +95 -95
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1052 -1035
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
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 Os;function Lu(){return Os||(Os=1,process.env.NODE_ENV!=="production"&&(function(){function t(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}function r(x,v){c||i.startTransition===void 0||(c=!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 S=v();if(!g){var E=v();s(S,E)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),g=!0)}E=d({inst:{value:S,getSnapshot:v}});var k=E[0].inst,j=E[1];return l(function(){k.value=S,k.getSnapshot=v,o(k)&&j({inst:k})},[x,S,v]),u(function(){return o(k)&&j({inst:k}),x(function(){o(k)&&j({inst:k})})},[x]),h(S),S}function o(x){var v=x.getSnapshot;x=x.value;try{var S=v();return!s(x,S)}catch{return!0}}function n(x,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=a,s=typeof Object.is=="function"?Object.is:t,d=i.useState,u=i.useEffect,l=i.useLayoutEffect,h=i.useDebugValue,c=!1,g=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;Ln.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Ln}var As;function Mu(){return As||(As=1,process.env.NODE_ENV==="production"?yo.exports=Au():yo.exports=Lu()),yo.exports}var ji=Mu();const jl=0,_l=1,kl=2,Ls=3;var Ms=Object.prototype.hasOwnProperty;function _i(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--&&_i(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Ms.call(t,o)&&++n&&!Ms.call(r,o)||!(o in r)||!_i(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const yt=new WeakMap,Tt=()=>{},Qe=Tt(),ki=Object,Se=t=>t===Qe,pt=t=>typeof t=="function",Gt=(t,r)=>({...t,...r}),Cl=t=>pt(t.then),Mn={},bo={},Ji="undefined",xo=typeof window!=Ji,Ci=typeof document!=Ji,Du=xo&&"Deno"in window,Fu=()=>xo&&typeof window.requestAnimationFrame!=Ji,Bt=(t,r)=>{const o=yt.get(t);return[()=>!Se(r)&&t.get(r)||Mn,n=>{if(!Se(r)){const i=t.get(r);r in bo||(bo[r]=i),o[5](r,Gt(i,n),i||Mn)}},o[6],()=>!Se(r)&&r in bo?bo[r]:!Se(r)&&t.get(r)||Mn]};let Si=!0;const Nu=()=>Si,[$i,zi]=xo&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Tt,Tt],Uu=()=>{const t=Ci&&document.visibilityState;return Se(t)||t!=="hidden"},Bu=t=>(Ci&&document.addEventListener("visibilitychange",t),$i("focus",t),()=>{Ci&&document.removeEventListener("visibilitychange",t),zi("focus",t)}),Wu=t=>{const r=()=>{Si=!0,t()},o=()=>{Si=!1};return $i("online",r),$i("offline",o),()=>{zi("online",r),zi("offline",o)}},Vu={isOnline:Nu,isVisible:Uu},Gu={initFocus:Bu,initReconnect:Wu},Ds=!a.useId,Dr=!xo||Du,Hu=t=>Fu()?window.requestAnimationFrame(t):setTimeout(t,1),Xo=Dr?a.useEffect:a.useLayoutEffect,Dn=typeof navigator<"u"&&navigator.connection,Fs=!Dr&&Dn&&(["slow-2g","2g"].includes(Dn.effectiveType)||Dn.saveData),wo=new WeakMap,qu=t=>ki.prototype.toString.call(t),Fn=(t,r)=>t===`[object ${r}]`;let Yu=0;const Ei=t=>{const r=typeof t,o=qu(t),n=Fn(o,"Date"),i=Fn(o,"RegExp"),s=Fn(o,"Object");let d,u;if(ki(t)===t&&!n&&!i){if(d=wo.get(t),d)return d;if(d=++Yu+"~",wo.set(t,d),Array.isArray(t)){for(d="@",u=0;u<t.length;u++)d+=Ei(t[u])+",";wo.set(t,d)}if(s){d="#";const l=ki.keys(t).sort();for(;!Se(u=l.pop());)Se(t[u])||(d+=u+":"+Ei(t[u])+",");wo.set(t,d)}}else d=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return d},fo=t=>{if(pt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Ei(t):"",[t,r]};let Qu=0;const Pi=()=>++Qu;async function Sl(...t){const[r,o,n,i]=t,s=Gt({populateCache:!0,throwOnError:!0},typeof i=="boolean"?{revalidate:i}:i||{});let d=s.populateCache;const u=s.rollbackOnError;let l=s.optimisticData;const h=m=>typeof u=="function"?u(m):u!==!1,c=s.throwOnError;if(pt(o)){const m=o,x=[],v=r.keys();for(const S of v)!/^\$(inf|sub)\$/.test(S)&&m(r.get(S)._k)&&x.push(S);return Promise.all(x.map(g))}return g(o);async function g(m){const[x]=fo(m);if(!x)return;const[v,S]=Bt(r,x),[E,k,j,z]=yt.get(r),b=()=>{const T=E[x];return(pt(s.revalidate)?s.revalidate(v().data,m):s.revalidate!==!1)&&(delete j[x],delete z[x],T&&T[0])?T[0](kl).then(()=>v().data):v().data};if(t.length<3)return b();let w=n,_,f=!1;const C=Pi();k[x]=[C,0];const y=!Se(l),$=v(),I=$.data,O=$._c,R=Se(O)?I:O;if(y&&(l=pt(l)?l(R,I):l,S({data:l,_c:R})),pt(w))try{w=w(R)}catch(T){_=T,f=!0}if(w&&Cl(w))if(w=await w.catch(T=>{_=T,f=!0}),C!==k[x][0]){if(f)throw _;return w}else f&&y&&h(_)&&(d=!0,S({data:R,_c:Qe}));if(d&&!f)if(pt(d)){const T=d(w,R);S({data:T,error:Qe,_c:Qe})}else S({data:w,error:Qe,_c:Qe});if(k[x][1]=Pi(),Promise.resolve(b()).then(()=>{S({_c:Qe})}),f){if(c)throw _;return}return w}}const Ns=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},Ku=(t,r)=>{if(!yt.has(t)){const o=Gt(Gu,r),n=Object.create(null),i=Sl.bind(Qe,t);let s=Tt;const d=Object.create(null),u=(c,g)=>{const m=d[c]||[];return d[c]=m,m.push(g),()=>m.splice(m.indexOf(g),1)},l=(c,g,m)=>{t.set(c,g);const x=d[c];if(x)for(const v of x)v(g,m)},h=()=>{if(!yt.has(t)&&(yt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),i,l,u]),!Dr)){const c=o.initFocus(setTimeout.bind(Qe,Ns.bind(Qe,n,jl))),g=o.initReconnect(setTimeout.bind(Qe,Ns.bind(Qe,n,_l)));s=()=>{c&&c(),g&&g(),yt.delete(t)}}};return h(),[t,i,h,s]}return[t,yt.get(t)[4]]},Zu=(t,r,o,n,i)=>{const s=o.errorRetryCount,d=i.retryCount,u=~~((Math.random()+.5)*(1<<(d<8?d:8)))*o.errorRetryInterval;!Se(s)&&d>s||setTimeout(n,u,i)},Ju=_i,[Xi,so]=Ku(new Map),Xu=Gt({onLoadingSlow:Tt,onSuccess:Tt,onError:Tt,onErrorRetry:Zu,onDiscarded:Tt,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Fs?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Fs?5e3:3e3,compare:Ju,isPaused:()=>!1,cache:Xi,mutate:so,fallback:{}},Vu),ep=(t,r)=>{const o=Gt(t,r);if(r){const{use:n,fallback:i}=t,{use:s,fallback:d}=r;n&&s&&(o.use=n.concat(s)),i&&d&&(o.fallback=Gt(i,d))}return o},tp=a.createContext({}),$l="$inf$",zl=xo&&window.__SWR_DEVTOOLS_USE__,rp=zl?window.__SWR_DEVTOOLS_USE__:[],op=()=>{zl&&(window.__SWR_DEVTOOLS_REACT__=a)},El=t=>pt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],Pl=()=>{const t=a.useContext(tp);return a.useMemo(()=>Gt(Xu,t),[t])},np=t=>(r,o,n)=>t(r,o&&((...s)=>{const[d]=fo(r),[,,,u]=yt.get(Xi);if(d.startsWith($l))return o(...s);const l=u[d];return Se(l)?o(...s):(delete u[d],l)}),n),ip=rp.concat(np),sp=t=>function(...o){const n=Pl(),[i,s,d]=El(o),u=ep(n,d);let l=t;const{use:h}=u,c=(h||[]).concat(ip);for(let g=c.length;g--;)l=c[g](l);return l(i,s||u.fetcher||null,u)},ap=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const i=n.indexOf(o);i>=0&&(n[i]=n[n.length-1],n.pop())}},cp=(t,r)=>(...o)=>{const[n,i,s]=El(o),d=(s.use||[]).concat(r);return t(n,i,{...s,use:d})};op();const Nn=a.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}}),Un={dedupe:!0},Us=Promise.resolve(Qe),lp=(t,r,o)=>{const{cache:n,compare:i,suspense:s,fallbackData:d,revalidateOnMount:u,revalidateIfStale:l,refreshInterval:h,refreshWhenHidden:c,refreshWhenOffline:g,keepPreviousData:m,strictServerPrefetchWarning:x}=o,[v,S,E,k]=yt.get(n),[j,z]=fo(t),b=a.useRef(!1),w=a.useRef(!1),_=a.useRef(j),f=a.useRef(r),C=a.useRef(o),y=()=>C.current,$=()=>y().isVisible()&&y().isOnline(),[I,O,R,T]=Bt(n,j),F=a.useRef({}).current,D=Se(d)?Se(o.fallback)?Qe:o.fallback[j]:d,M=(Q,q)=>{for(const K in F){const ue=K;if(ue==="data"){if(!i(Q[ue],q[ue])&&(!Se(Q[ue])||!i(we,q[ue])))return!1}else if(q[ue]!==Q[ue])return!1}return!0},L=a.useMemo(()=>{const Q=!j||!r?!1:Se(u)?y().isPaused()||s?!1:l!==!1:u,q=V=>{const be=Gt(V);return delete be._k,Q?{isValidating:!0,isLoading:!0,...be}:be},K=I(),ue=T(),xe=q(K),Y=K===ue?xe:q(ue);let he=xe;return[()=>{const V=q(I());return M(V,he)?(he.data=V.data,he.isLoading=V.isLoading,he.isValidating=V.isValidating,he.error=V.error,he):(he=V,V)},()=>Y]},[n,j]),A=ji.useSyncExternalStore(a.useCallback(Q=>R(j,(q,K)=>{M(K,q)||Q()}),[n,j]),L[0],L[1]),P=!b.current,N=v[j]&&v[j].length>0,W=A.data,H=Se(W)?D&&Cl(D)?Nn(D):D:W,oe=A.error,Z=a.useRef(H),we=m?Se(W)?Se(Z.current)?H:Z.current:W:H,pe=j&&Se(H),ee=!Dr&&ji.useSyncExternalStore(()=>Tt,()=>!1,()=>!0);x&&ee&&!s&&pe&&console.warn(`Missing pre-initiated data for serialized key "${j}" during server-side rendering. Data fethcing should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);const me=N&&!Se(oe)?!1:P&&!Se(u)?u:y().isPaused()?!1:s?Se(H)?!1:l:Se(H)||l,re=!!(j&&r&&P&&me),Pe=Se(A.isValidating)?re:A.isValidating,te=Se(A.isLoading)?re:A.isLoading,ae=a.useCallback(async Q=>{const q=f.current;if(!j||!q||w.current||y().isPaused())return!1;let K,ue,xe=!0;const Y=Q||{},he=!E[j]||!Y.dedupe,V=()=>Ds?!w.current&&j===_.current&&b.current:j===_.current,be={isValidating:!1,isLoading:!1},Ze=()=>{O(be)},lt=()=>{const ce=E[j];ce&&ce[1]===ue&&delete E[j]},G={isValidating:!0};Se(I().data)&&(G.isLoading=!0);try{if(he&&(O(G),o.loadingTimeout&&Se(I().data)&&setTimeout(()=>{xe&&V()&&y().onLoadingSlow(j,o)},o.loadingTimeout),E[j]=[q(z),Pi()]),[K,ue]=E[j],K=await K,he&&setTimeout(lt,o.dedupingInterval),!E[j]||E[j][1]!==ue)return he&&V()&&y().onDiscarded(j),!1;be.error=Qe;const ce=S[j];if(!Se(ce)&&(ue<=ce[0]||ue<=ce[1]||ce[1]===0))return Ze(),he&&V()&&y().onDiscarded(j),!1;const De=I().data;be.data=i(De,K)?De:K,he&&V()&&y().onSuccess(K,j,o)}catch(ce){lt();const De=y(),{shouldRetryOnError:Xe}=De;De.isPaused()||(be.error=ce,he&&V()&&(De.onError(ce,j,De),(Xe===!0||pt(Xe)&&Xe(ce))&&(!y().revalidateOnFocus||!y().revalidateOnReconnect||$())&&De.onErrorRetry(ce,j,De,rt=>{const Je=v[j];Je&&Je[0]&&Je[0](Ls,rt)},{retryCount:(Y.retryCount||0)+1,dedupe:!0})))}return xe=!1,Ze(),!0},[j,n]),ye=a.useCallback((...Q)=>Sl(n,_.current,...Q),[]);if(Xo(()=>{f.current=r,C.current=o,Se(W)||(Z.current=W)}),Xo(()=>{if(!j)return;const Q=ae.bind(Qe,Un);let q=0;y().revalidateOnFocus&&(q=Date.now()+y().focusThrottleInterval);const ue=ap(j,v,(xe,Y={})=>{if(xe==jl){const he=Date.now();y().revalidateOnFocus&&he>q&&$()&&(q=he+y().focusThrottleInterval,Q())}else if(xe==_l)y().revalidateOnReconnect&&$()&&Q();else{if(xe==kl)return ae();if(xe==Ls)return ae(Y)}});return w.current=!1,_.current=j,b.current=!0,O({_k:z}),me&&(E[j]||(Se(H)||Dr?Q():Hu(Q))),()=>{w.current=!0,ue()}},[j]),Xo(()=>{let Q;function q(){const ue=pt(h)?h(I().data):h;ue&&Q!==-1&&(Q=setTimeout(K,ue))}function K(){!I().error&&(c||y().isVisible())&&(g||y().isOnline())?ae(Un).then(q):q()}return q(),()=>{Q&&(clearTimeout(Q),Q=-1)}},[h,c,g,j]),a.useDebugValue(we),s){if(!Ds&&Dr&&pe)throw new Error("Fallback data is required when using Suspense in SSR.");pe&&(f.current=r,C.current=o,w.current=!1);const Q=k[j],q=!Se(Q)&&pe?ye(Q):Us;if(Nn(q),!Se(oe)&&pe)throw oe;const K=pe?ae(Un):Us;!Se(we)&&pe&&(K.status="fulfilled",K.value=!0),Nn(K)}return{mutate:ye,get data(){return F.data=!0,we},get error(){return F.error=!0,oe},get isValidating(){return F.isValidating=!0,Pe},get isLoading(){return F.isLoading=!0,te}}},We=sp(lp),nt=()=>{const{adapter:t,deployment:r}=je(),o=t.useNavigate(),n=(l,h)=>{o?o(l,h):window.location.href=l},i=l=>{if(l)return l;const c=new URLSearchParams(window.location.search).get("redirect_uri");return c||window.location.href};return{navigate:n,navigateToSignIn:l=>{if(!r)return;const h=i(l),c=new URLSearchParams;c.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&c.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${c.toString()}`,{replace:!0})},navigateToAccountSelection:l=>{if(!r)return;const h=i(l),c=new URLSearchParams;c.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&c.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${c.toString()}`,{replace:!0})},navigateToSignUp:l=>{if(!r)return;const h=i(l),c=new URLSearchParams;c.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&c.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${c.toString()}`,{replace:!0})}}};async function dp(t){const r=await t("/session",{method:"GET"});return(await U(r)).data}async function up(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return U(o)}async function pp(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return U(n)}async function hp(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return U(o)}async function fp(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return U(o)}async function gp(t,r){const o=await t(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"});return U(o)}const Ri=new Map,ao=new Map;function bt(){Ri.clear(),ao.clear()}async function mp(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return U(o)}function Be(){const{client:t,loading:r}=Ve(),{deployment:o}=je(),{navigate:n}=nt(),{cache:i}=Pl(),{data:s,error:d,mutate:u,isLoading:l}=We(r?null:"/session",()=>dp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=a.useCallback(async()=>{await u(void 0,{revalidate:!0})},[u]),c=a.useCallback(async(g="default")=>{if(!s)throw new Error("no session");const m=Ri.get(g);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";ao.get(g)||ao.set(g,mp(t,g));const x=await ao.get(g);return ao.delete(g),Ri.set(g,x.data),x.data.token},[t,s==null?void 0:s.active_signin]);return r||!s||l?{loading:!0,error:d,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,exchangeTicket:null,signOut:null,getToken:null,refetch:h}:{loading:l,error:d,session:s,switchSignIn:async g=>{await up(t,g),bt(),await so("/me/organization-memberships",void 0,{revalidate:!1}),await so("/me/workspace-memberships",void 0,{revalidate:!1}),await u(void 0,{revalidate:!0}),await so("/me/organization-memberships"),await so("/me/workspace-memberships")},signOut:async g=>{await pp(t,g);const m=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:scope-unread"],x=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(i instanceof Map){const v=Array.from(i.keys());for(const S of v){let E=!1;(m.includes(S)||typeof S=="string"&&x.some(k=>S.startsWith(k)))&&(E=!0),E&&i.delete(S)}}bt(),await u(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(g&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!g&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async g=>{await hp(t,g),bt(),await u(void 0,{revalidate:!0})},switchWorkspace:async g=>{await fp(t,g),bt(),await u(void 0,{revalidate:!0})},exchangeTicket:async g=>{await gp(t,g),bt(),await u(void 0,{revalidate:!0})},getToken:c,refetch:h}}const jt=()=>{const{organizationMemberships:t,refetch:r,loading:o}=Mt(),{client:n}=Ve(),{refetch:i}=Be(),s=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/roles`,{method:"GET"}))).data,[n]),d=a.useCallback(async(L,A)=>{const P=new URLSearchParams;return A&&(P.set("page",A.page.toString()),P.set("limit",A.limit.toString()),A.search&&P.set("search",A.search)),(await U(await n(`/organizations/${L.id}/members?${P.toString()}`,{method:"GET"}))).data},[n]),u=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/invitations`,{method:"GET"}))).data,[n]),l=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/domains`,{method:"GET"}))).data,[n]),h=a.useCallback(async(L,A)=>{await n(`/organizations/${L.id}/members/${A.id}/remove`,{method:"POST"})},[n]),c=a.useCallback(async L=>{const A=new FormData;A.append("name",L.name),L.image&&A.append("image",L.image),L.description&&A.append("description",L.description);const P=await U(await n("/organizations",{method:"POST",body:A}));return bt(),await r(),await i(),P},[i,r,n]),g=a.useCallback(async(L,A)=>{const P=Object.entries(A).reduce((W,[H,oe])=>(oe!=null&&(Array.isArray(oe)?oe.forEach(Z=>W.append(H,Z)):W.append(H,oe)),W),new FormData),N=await U(await n(`/organizations/${L.id}/update`,{method:"POST",body:P}));return await r(),N},[r,n]),m=a.useCallback(async(L,A)=>{await n(`/organizations/${L.id}/roles/${A.id}/remove`,{method:"POST"})},[n]),x=a.useCallback(async(L,A)=>{const P=new FormData;return P.append("domain",A.fqdn),await U(await n(`/organizations/${L.id}/domains`,{method:"POST",body:P}))},[n]),v=a.useCallback(async(L,A)=>await U(await n(`/organizations/${L.id}/domains/${A.id}/verify`,{method:"POST"})),[n]),S=a.useCallback(async(L,A)=>await U(await n(`/organizations/${L.id}/domains/${A.id}/delete`,{method:"POST"})),[n]),E=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/enterprise-connections`,{method:"GET"}))).data,[n]),k=a.useCallback(async(L,A)=>{const P=new FormData;return P.append("protocol",A.protocol),A.domain_id&&P.append("domain_id",A.domain_id),A.idp_entity_id&&P.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&P.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&P.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&P.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&P.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&P.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&P.append("oidc_scopes",A.oidc_scopes),A.jit_enabled!==void 0&&P.append("jit_enabled",String(A.jit_enabled)),A.attribute_mapping&&P.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await U(await n(`/organizations/${L.id}/enterprise-connections`,{method:"POST",body:P}))).data},[n]),j=a.useCallback(async(L,A,P)=>{const N=new FormData;return P.domain_id&&N.append("domain_id",P.domain_id),P.idp_entity_id&&N.append("idp_entity_id",P.idp_entity_id),P.idp_sso_url&&N.append("idp_sso_url",P.idp_sso_url),P.idp_certificate&&N.append("idp_certificate",P.idp_certificate),P.oidc_client_id&&N.append("oidc_client_id",P.oidc_client_id),P.oidc_client_secret&&N.append("oidc_client_secret",P.oidc_client_secret),P.oidc_issuer_url&&N.append("oidc_issuer_url",P.oidc_issuer_url),P.oidc_scopes&&N.append("oidc_scopes",P.oidc_scopes),P.attribute_mapping&&N.append("attribute_mapping",JSON.stringify(P.attribute_mapping)),(await U(await n(`/organizations/${L.id}/enterprise-connections/${A}/update`,{method:"POST",body:N}))).data},[n]),z=a.useCallback(async(L,A)=>{await n(`/organizations/${L.id}/enterprise-connections/${A}/delete`,{method:"POST"})},[n]),b=a.useCallback(async(L,A)=>{const P=new FormData;return P.append("protocol",A.protocol),A.idp_entity_id&&P.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&P.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&P.append("idp_certificate",A.idp_certificate),A.oidc_issuer_url&&P.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_client_id&&P.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&P.append("oidc_client_secret",A.oidc_client_secret),(await U(await n(`/organizations/${L.id}/enterprise-connections/test`,{method:"POST",body:P}))).data},[n]),w=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/enterprise-connections/${A}/test`,{method:"POST"}))).data,[n]),_=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/enterprise-connections/${A}/scim/token`,{method:"POST"}))).data,[n]),f=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/enterprise-connections/${A}/scim/token`,{method:"GET"}))).data,[n]),C=a.useCallback(async(L,A)=>{await n(`/organizations/${L.id}/enterprise-connections/${A}/scim/token/revoke`,{method:"POST"})},[n]),y=a.useCallback(async(L,A)=>{const P=new FormData;return P.append("name",A.name),A.permissions&&A.permissions.forEach((W,H)=>{P.append(`permissions[${H}]`,W)}),await U(await n(`/organizations/${L.id}/roles`,{method:"POST",body:P}))},[n]),$=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/leave`,{method:"POST"}))).data,[n]),I=a.useCallback(async L=>{const A=await U(await n(`/organizations/${L.id}/delete`,{method:"POST"}));return bt(),await r(),await i(),A.data},[n,r,i]),O=a.useCallback(async(L,A,P)=>(await U(await n(`/organizations/${L.id}/members/${A.id}/roles/${P.id}/add`,{method:"POST"}))).data,[n]),R=a.useCallback(async(L,A,P)=>(await U(await n(`/organizations/${L.id}/members/${A.id}/roles/${P.id}/remove`,{method:"POST"}))).data,[n]),T=a.useCallback(async(L,A)=>{var W,H;const P=new FormData;return P.append("email",A.email),P.append("role_id",A.organizationRole.id),(W=A.workspace)!=null&&W.id&&P.append("workspace_id",A.workspace.id),(H=A.workspaceRole)!=null&&H.id&&P.append("workspace_role_id",A.workspaceRole.id),(await U(await n(`/organizations/${L.id}/invitations`,{method:"POST",body:P}))).data},[n]),F=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/invitations/${A.id}/discard`,{method:"POST"}))).data,[n]),D=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/invitations/${A.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:a.useMemo(()=>t==null?void 0:t.map(L=>L.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:$,getOrganizationRoles:s,getOrganizationMembers:d,removeOrganizationMember:h,createOrganization:c,getOrganizationInvitations:u,getOrganizationDomains:l,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:S,addRoleToOrganizationMember:O,removeRoleFromOrganizationMember:R,inviteOrganizationMember:T,discardOrganizationInvitation:F,resendOrganizationInvitation:D,updateOrganization:g,addRole:y,removeOrganizationRoles:m,deleteOrganization:I,getEnterpriseConnections:E,createEnterpriseConnection:k,updateEnterpriseConnection:j,deleteEnterpriseConnection:z,testEnterpriseConnectionConfig:b,testEnterpriseConnection:w,generateSCIMToken:_,getSCIMToken:f,revokeSCIMToken:C}},Cr=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:i,leaveOrganization:s,removeOrganizationMember:d,getOrganizationInvitations:u,getOrganizationDomains:l,removeOrganizationDomain:h,addOrganizationDomain:c,verifyOrganizationDomain:g,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:S,resendOrganizationInvitation:E,updateOrganization:k,removeOrganizationRoles:j,getEnterpriseConnections:z,createEnterpriseConnection:b,updateEnterpriseConnection:w,deleteEnterpriseConnection:_,testEnterpriseConnectionConfig:f,testEnterpriseConnection:C,generateSCIMToken:y,getSCIMToken:$,revokeSCIMToken:I}=jt(),{session:O,error:R,loading:T}=Be(),{organizationMemberships:F}=Mt(),D=a.useMemo(()=>(F==null?void 0:F.find(V=>{var be;return V.id===((be=O==null?void 0:O.active_signin)==null?void 0:be.active_organization_membership_id)}))||null,[F,O]),M=a.useMemo(()=>(D==null?void 0:D.organization)||null,[D]),L=a.useCallback(async V=>M?await k(M,V):[],[M,k]),A=a.useCallback(async()=>M?await n(M):[],[M,n]),P=a.useCallback(async()=>M?await i(M):[],[M,i]),N=a.useCallback(async V=>M?await d(M,V):[],[M,d]),W=a.useCallback(async V=>M?await j(M,V):void 0,[M,j]),H=a.useCallback(async()=>M?await l(M):[],[M,l]),oe=a.useCallback(async V=>M?await c(M,V):void 0,[M,c]),Z=a.useCallback(async V=>M?await g(M,V):void 0,[M,g]),we=a.useCallback(async V=>M?await h(M,V):void 0,[M,h]),pe=a.useCallback(async(V,be)=>M?await m(M,V,be):void 0,[M,m]),ee=a.useCallback(async(V,be)=>M?await x(M,V,be):void 0,[M,x]),me=a.useCallback(async V=>M?await v(M,V):void 0,[M,v]),re=a.useCallback(async V=>M?await S(M,V):void 0,[M,S]),Pe=a.useCallback(async V=>M?await E(M,V):void 0,[M,E]),te=a.useCallback(async()=>{M&&await s(M)},[M,s]),ae=a.useCallback(async()=>M?await u(M):[],[M,u]),ye=a.useCallback(async()=>M?await z(M):[],[M,z]),ge=a.useCallback(async V=>{if(M)return await b(M,V)},[M,b]),Q=a.useCallback(async(V,be)=>{if(M)return await w(M,V,be)},[M,w]),q=a.useCallback(async V=>{M&&await _(M,V)},[M,_]),K=a.useCallback(async V=>M?await f(M,V):null,[M,f]),ue=a.useCallback(async V=>M?await C(M,V):null,[M,C]),xe=a.useCallback(async V=>{if(M)return await y(M,V)},[M,y]),Y=a.useCallback(async V=>{if(M)return await $(M,V)},[M,$]),he=a.useCallback(async V=>{M&&await I(M,V)},[M,I]);return T||t?{activeOrganization:null,activeMembership:null,loading:!0,error:R||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:M,activeMembership:D,loading:!1,refetch:o,getRoles:P,updateOrganization:L,getMembers:A,getDomains:H,addDomain:oe,verifyDomain:Z,removeDomain:we,getInvitations:ae,removeMember:N,leave:te,removeRole:W,addMemberRole:pe,removeMemberRole:ee,inviteMember:me,discardInvitation:re,resendInvitation:Pe,getEnterpriseConnections:ye,createEnterpriseConnection:ge,updateEnterpriseConnection:Q,deleteEnterpriseConnection:q,testEnterpriseConnectionConfig:K,testEnterpriseConnection:ue,generateSCIMToken:xe,getSCIMToken:Y,revokeSCIMToken:he,error:null}};async function xp(t){return(await U(await t("/me/organization-memberships"))).data}const Mt=()=>{const{client:t,loading:r}=Ve(),{data:o,isLoading:n,error:i,mutate:s}=We(r?null:"/me/organization-memberships",()=>xp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),d=a.useCallback(async()=>{await s()},[s]);return{organizationMemberships:o,loading:r||n,error:i,refetch:d}};async function vp(t){return(await U(await t("/me/workspace-memberships"))).data}async function yp(t,r,o){return(await U(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const vn=()=>{const{client:t,loading:r}=Ve(),{deployment:o}=je(),{data:n,isLoading:i,error:s,mutate:d}=We(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>vp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),u=a.useCallback(async()=>{await d(void 0,{revalidate:!0})},[d]);return{workspaceMemberships:n,loading:r||i,error:s,refetch:u}},Yt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=vn(),{client:i}=Ve(),s=a.useMemo(()=>t==null?void 0:t.map(w=>({...w.workspace,organization:w.organization,eligibility_restriction:w.eligibility_restriction})),[t]),d=a.useCallback(async(w,_,f,C)=>{const y=new FormData;y.append("name",_),f&&y.append("image",f),C&&y.append("description",C),y.append("organization_id",w);const $=await U(await i("/workspaces",{method:"POST",body:y}));return bt(),await r(),$.data},[i,r]),u=a.useCallback(async(w,_)=>{const f=await yp(i,w,_);return await r(),f},[i,r]),l=a.useCallback(async(w,_)=>{const f=new FormData;_.name&&f.append("name",_.name),_.description&&f.append("description",_.description),_.image&&f.append("image",_.image),_.enforce_2fa!==void 0&&f.append("enforce_2fa",String(_.enforce_2fa)),_.enable_ip_restriction!==void 0&&f.append("enable_ip_restriction",String(_.enable_ip_restriction)),_.whitelisted_ips&&_.whitelisted_ips.forEach(y=>f.append("whitelisted_ips",y));const C=await U(await i(`/workspaces/${w.id}/update`,{method:"POST",body:f}));return await r(),C.data},[i,r]),h=a.useCallback(async w=>{const _=await U(await i(`/workspaces/${w.id}/delete`,{method:"POST"}));return bt(),await r(),_.data},[i,r]),c=a.useCallback(async(w,_)=>{const f=new URLSearchParams;return _&&(f.set("page",_.page.toString()),f.set("limit",_.limit.toString()),_.search&&f.set("search",_.search)),(await U(await i(`/workspaces/${w.id}/members?${f.toString()}`,{method:"GET"}))).data},[i]),g=a.useCallback(async w=>(await U(await i(`/workspaces/${w.id}/roles`,{method:"GET"}))).data,[i]),m=a.useCallback(async(w,_,f)=>{const C=new FormData;return C.append("name",_),f.forEach($=>C.append("permissions",$)),(await U(await i(`/workspaces/${w.id}/roles`,{method:"POST",body:C}))).data},[i]),x=a.useCallback(async(w,_)=>(await U(await i(`/workspaces/${w.id}/roles/${_.id}/delete`,{method:"POST"}))).data,[i]),v=a.useCallback(async(w,_)=>{const f=await U(await i(`/workspaces/${w.id}/members/${_}/remove`,{method:"POST"}));return await r(),f.data},[i,r]),S=a.useCallback(async(w,_,f)=>(await U(await i(`/workspaces/${w.id}/members/${_}/roles/${f}/add`,{method:"POST"}))).data,[i]),E=a.useCallback(async(w,_,f)=>(await U(await i(`/workspaces/${w.id}/members/${_}/roles/${f}/remove`,{method:"POST"}))).data,[i]),k=a.useCallback(async w=>(await U(await i(`/organizations/${w.organization.id}/invitations?workspace_id=${w.id}`,{method:"GET"}))).data,[i]),j=a.useCallback(async(w,_,f)=>{const C=new FormData;return C.append("email",_),C.append("workspace_id",w.id),f&&C.append("workspace_role_id",f),(await U(await i(`/organizations/${w.organization.id}/invitations`,{method:"POST",body:C}))).data},[i]),z=a.useCallback(async(w,_)=>(await U(await i(`/organizations/${w.organization.id}/invitations/${_}/discard`,{method:"POST"}))).data,[i]),b=a.useCallback(async(w,_)=>(await U(await i(`/organizations/${w.organization.id}/invitations/${_}/resend`,{method:"POST"}))).data,[i]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:u,createWorkspace:d,updateWorkspace:l,deleteWorkspace:h,getWorkspaceMembers:c,getWorkspaceRoles:g,createWorkspaceRole:m,deleteWorkspaceRole:x,removeWorkspaceMember:v,addWorkspaceMemberRole:S,removeWorkspaceMemberRole:E,getWorkspaceInvitations:k,createWorkspaceInvitation:j,discardWorkspaceInvitation:z,resendWorkspaceInvitation:b}},Dt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:i,updateWorkspace:s,deleteWorkspace:d,getWorkspaceMembers:u,getWorkspaceRoles:l,createWorkspaceRole:h,deleteWorkspaceRole:c,removeWorkspaceMember:g,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x,getWorkspaceInvitations:v,createWorkspaceInvitation:S,discardWorkspaceInvitation:E,resendWorkspaceInvitation:k}=Yt(),{workspaceMemberships:j}=vn(),{session:z,loading:b,error:w}=Be(),_=a.useMemo(()=>(j==null?void 0:j.find(Z=>{var we;return Z.id===((we=z==null?void 0:z.active_signin)==null?void 0:we.active_workspace_membership_id)}))||null,[j,z]),f=a.useMemo(()=>(_==null?void 0:_.workspace)||null,[_]),C=a.useCallback(async()=>{var Z;if(!(!f||!((Z=z==null?void 0:z.active_signin)!=null&&Z.user_id)))return await i(f.id,z.active_signin.user_id)},[f,i,z]),y=a.useCallback(async Z=>{if(f)return await s(f,Z)},[f,s]),$=a.useCallback(async()=>{if(f)return await d(f)},[f,d]),I=a.useCallback(async Z=>f?await u(f,Z):{data:[],meta:{total:0,page:1,limit:10}},[f,u]),O=a.useCallback(async()=>f?await l(f):[],[f,l]),R=a.useCallback(async(Z,we)=>{if(f)return await h(f,Z,we)},[f,h]),T=a.useCallback(async Z=>{if(f)return await c(f,Z)},[f,c]),F=a.useCallback(async Z=>{if(f)return await g(f,Z)},[f,g]),D=a.useCallback(async(Z,we)=>{if(f)return await m(f,Z,we)},[f,m]),M=a.useCallback(async(Z,we)=>{if(f)return await x(f,Z,we)},[f,x]),L=a.useMemo(()=>(n==null?void 0:n.find(Z=>Z.id===(f==null?void 0:f.id)))||null,[n,f]),A=a.useCallback(async()=>L?await v(L):[],[L,v]),P=a.useCallback(async(Z,we)=>{if(L)return await S(L,Z,we)},[L,S]),N=a.useCallback(async Z=>{if(L)return await E(L,Z)},[L,E]),W=a.useCallback(async Z=>{if(L)return await k(L,Z)},[L,k]),H=r||b,oe=o||w;return H?{activeWorkspace:null,activeMembership:null,loading:!0,error:oe,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:_,loading:!1,error:oe,refetch:t,leave:C,updateWorkspace:y,deleteWorkspace:$,getMembers:I,getRoles:O,createRole:R,deleteRole:T,inviteMember:P,removeMember:F,addMemberRole:D,removeMemberRole:M,getInvitations:A,discardInvitation:N,resendInvitation:W}};function Bn(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Wn(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),i=new Uint8Array(n.length);for(let s=0;s<n.length;s++)i[s]=n.charCodeAt(s);return i.buffer}const bp=async t=>(await U(await t("/me"))).data,wp=async t=>(await U(await t("/me/signins"))).data;function Qt(){const{client:t,loading:r}=Ve(),{data:o,error:n,isLoading:i,mutate:s}=We(r?null:"/user",()=>bp(t)),d=async L=>{const A=new FormData;for(const[N,W]of Object.entries(L))W!=null&&W!==""&&A.append(N,String(W));const P=await U(await t("/me",{method:"POST",body:A}));return s(),P},u=async()=>await U(await t("/me/email-addresses",{method:"GET"})),l=async L=>await U(await t(`/me/email-addresses/${L}`,{method:"GET"})),h=async L=>{const A=new FormData;return A.append("email",L),await U(await t("/me/email-addresses",{method:"POST",body:A}))},c=async L=>await U(await t(`/me/email-addresses/${L}/delete`,{method:"POST"})),g=async L=>await U(await t(`/me/email-addresses/${L}/prepare-verification`,{method:"POST"})),m=async(L,A)=>await U(await t(`/me/email-addresses/${L}/attempt-verification?code=${A}`,{method:"POST"})),x=async(L,A)=>{const P=new FormData;return P.append("phone_number",L),P.append("country_code",A),await U(await t("/me/phone-numbers",{method:"POST",body:P}))},v=async L=>await U(await t(`/me/phone-numbers/${L}/delete`,{method:"POST"})),S=async L=>await U(await t(`/me/phone-numbers/${L}/prepare-verification`,{method:"POST"})),E=async(L,A)=>{const P=new FormData;return P.append("code",A),await U(await t(`/me/phone-numbers/${L}/attempt-verification`,{method:"POST",body:P}))},k=async L=>{const A=await U(await t(`/me/phone-numbers/${L}/make-primary`,{method:"POST"}));return s(),A},j=async L=>await U(await t(`/me/email-addresses/${L}/make-primary`,{method:"POST"})),z=async()=>(await U(await t("/me/authenticator",{method:"POST"}))).data,b=async(L,A)=>{const P=new FormData;return P.append("authenticator_id",L),A.forEach(W=>{P.append("codes",W)}),await U(await t("/me/authenticator/attempt-verification",{method:"POST",body:P}))},w=async L=>await U(await t(`/me/authenticator/${L}/delete`,{method:"POST"})),_=async()=>(await U(await t("/me/backup-codes",{method:"POST"}))).data,f=async L=>{const A=new FormData;return A.append("file",L),await U(await t("/me/profile-picture",{method:"POST",body:A}))},C=async()=>(await U(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,y=async(L,A)=>{const P=new FormData;return P.append("current_password",L),P.append("new_password",A),await U(await t("/me/update-password",{method:"POST",body:P}))},$=async L=>{const A=new FormData;A.append("current_password",L);const P=await U(await t("/me/remove-password",{method:"POST",body:A}));return s(),P},I=async L=>{const A=new FormData;return A.append("password",L),await U(await t("/me/account/delete",{method:"POST",body:A}))},O=async L=>await U(await t(`/me/social-connections/${L}/disconnect`,{method:"POST"})),R=async({provider:L,redirectUri:A})=>{var W;const P=new URLSearchParams({provider:L});A&&P.append("redirect_uri",A);const N=await U(await t(`/me/init-sso-connection?${P.toString()}`,{method:"POST"}));return"data"in N&&((W=N.data)!=null&&W.oauth_url)&&window.open(N.data.oauth_url,"_blank"),N},T=async()=>await U(await t("/me/passkeys",{method:"GET"})),F=async L=>{var we,pe;const A=await U(await t("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in A))return A;const P=A.data.options.publicKey,N={challenge:Wn(P.challenge),rp:P.rp,user:{id:Wn(P.user.id),name:P.user.name,displayName:P.user.displayName},pubKeyCredParams:P.pubKeyCredParams,timeout:P.timeout,attestation:P.attestation,authenticatorSelection:P.authenticatorSelection,excludeCredentials:(we=P.excludeCredentials)==null?void 0:we.map(ee=>({type:ee.type,id:Wn(ee.id),transports:ee.transports}))},W=await navigator.credentials.create({publicKey:N});if(!W)throw new Error("Failed to create credential");const H=W.response,oe={id:W.id,rawId:Bn(W.rawId),type:W.type,response:{clientDataJSON:Bn(H.clientDataJSON),attestationObject:Bn(H.attestationObject),transports:((pe=H.getTransports)==null?void 0:pe.call(H))||[]}};return await U(await t(`/me/passkeys/register/finish?name=${encodeURIComponent(L||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oe)}))},D=async L=>await U(await t(`/me/passkeys/${L}/delete`,{method:"POST"})),M=async(L,A)=>await U(await t(`/me/passkeys/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:A})}));return{user:{...o,refetch:s},loading:r||i,error:n||null,updateProfile:d,getEmailAddresses:u,getEmailAddress:l,createEmailAddress:h,deleteEmailAddress:c,prepareEmailVerification:g,attemptEmailVerification:m,makeEmailPrimary:j,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:S,attemptPhoneVerification:E,makePhonePrimary:k,setupAuthenticator:z,verifyAuthenticator:b,deleteAuthenticator:w,generateBackupCodes:_,regenerateBackupCodes:C,updateProfilePicture:f,disconnectSocialConnection:O,connectSocialAccount:R,updatePassword:y,removePassword:$,deleteAccount:I,getPasskeys:T,registerPasskey:F,deletePasskey:D,renamePasskey:M}}function Rl(){const{client:t,loading:r}=Ve(),{data:o,error:n,isLoading:i,mutate:s}=We(r?null:"/me/signins",()=>wp(t));return{signins:o,error:n||null,removeSignin:async u=>await U(await t(`/me/signins/${u}/signout`,{method:"POST"})),refetch:s,loading:i||r}}function jp(){const{session:t,loading:r}=Be(),{loading:o,organizationMemberships:n}=Mt(),{loading:i,workspaceMemberships:s}=vn();if(r||o||i)return{loading:!0,orgMembership:null,workspaceMembership:null};const d=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(l=>{var h;return l.id===((h=t.active_signin)==null?void 0:h.active_organization_membership_id)}),[t]),u=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(l=>{var h;return l.id===((h=t.active_signin)==null?void 0:h.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:d,workspaceMembership:u}}function Il(){const{client:t,loading:r}=Ve(),[o,n]=a.useState(!1),i=async s=>{n(!0);try{const d=new FormData;for(const[h,c]of Object.entries(s))c&&d.append(h,c);const u=await t("/waitlist/join",{method:"POST",body:d});return await U(u)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:i}}function Tl(){const{client:t,loading:r}=Ve(),[o,n]=a.useState(!1),[i,s]=a.useState(null),[d,u]=a.useState(null),[l,h]=a.useState(null),[c,g]=a.useState(!1),[m,x]=a.useState(null);a.useEffect(()=>{if(c||r)return;const S=new URLSearchParams(window.location.search),E=S.get("code"),k=S.get("state"),j=S.get("error"),z=S.get("error_description");if(!E&&!j){g(!0);const b=new Error("No OAuth callback data found.");s(b);return}if(g(!0),n(!0),j){const b=z||j,w=new Error(`OAuth Error: ${b}`);s(w),n(!1);return}if(E&&k)v(E,k);else{const b=new Error("Missing required OAuth parameters");s(b),n(!1)}},[c,r]);const v=async(S,E)=>{try{let k,j;try{const w=E.split(".");if(w.length!==2)throw new Error("Invalid OAuth state format - missing signature");const _=w[0].replace(/-/g,"+").replace(/_/g,"/"),f=_.length%4?"=".repeat(4-_.length%4):"",y=atob(_+f).split("|")[0];if(y==="sign_in")k="/auth/oauth2/callback",j="GET";else if(y==="connect_social")k="/me/sso-connection-callback",j="POST";else throw new Error(`Unknown OAuth action: ${y}`)}catch(w){const _=w instanceof Error?w:new Error("Failed to parse OAuth state");s(new Error(`Invalid OAuth callback: ${_.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const z=await t(`${k}?code=${encodeURIComponent(S)}&state=${encodeURIComponent(E)}`,{method:j}),b=await U(z);if("data"in b){const w=b.data.session,_=b.data.redirect_uri||null;if(u(w),h(_),w.signin_attempts&&w.signin_attempts.length>0){const f=w.signin_attempts.at(-1);f&&x(f)}}else{const w=new Error("SSO callback failed");s(w)}}catch(k){const j=k instanceof Error?k:new Error("Unknown error occurred");s(j)}finally{n(!1)}};return{loading:o,error:i,session:d,redirectUri:l,processed:c,signinAttempt:m}}function Ol(){const{client:t,loading:r}=Ve(),[o,n]=a.useState(!1),[i,s]=a.useState(null);return{loading:r||o,verifyMagicLink:async u=>{if(!u.token||!u.attempt)throw new Error("Invalid magic link parameters");n(!0),s(null);try{const l=new URL("/auth/verify-magic-link",window.location.origin);l.searchParams.set("token",u.token),l.searchParams.set("attempt",u.attempt),u.redirectUri&&l.searchParams.set("redirect_uri",u.redirectUri);const h=await t(l.pathname+l.search,{method:"GET"}),c=await U(h);return n(!1),s(!0),c}catch(l){throw n(!1),s(!1),l}},success:i}}function Al(){const[t,r]=a.useState({});return a.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 Ll(){const{client:t,loading:r}=Ve();return{loading:r,forgotPassword:async s=>{const d=new FormData;d.append("email",s);const u=await t("/auth/forgot-password",{method:"POST",body:d});return await U(u)},verifyOtp:async(s,d)=>{const u=new FormData;u.append("email",s),u.append("otp",d);const l=await t("/auth/forgot-password",{method:"POST",body:u});return await U(l)},resetPassword:async(s,d)=>{const u=new FormData;u.append("token",s),u.append("password",d);const l=await t("/auth/reset-password",{method:"POST",body:u});return await U(l)}}}const _p=()=>{},kp=_p(),Ii=Object,Bs=t=>t===kp,Cp=t=>typeof t=="function",jo=new WeakMap,Sp=t=>Ii.prototype.toString.call(t),Vn=(t,r)=>t===`[object ${r}]`;let $p=0;const Ti=t=>{const r=typeof t,o=Sp(t),n=Vn(o,"Date"),i=Vn(o,"RegExp"),s=Vn(o,"Object");let d,u;if(Ii(t)===t&&!n&&!i){if(d=jo.get(t),d)return d;if(d=++$p+"~",jo.set(t,d),Array.isArray(t)){for(d="@",u=0;u<t.length;u++)d+=Ti(t[u])+",";jo.set(t,d)}if(s){d="#";const l=Ii.keys(t).sort();for(;!Bs(u=l.pop());)Bs(t[u])||(d+=u+":"+Ti(t[u])+",");jo.set(t,d)}}else d=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return d},zp=t=>{if(Cp(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Ti(t):"",[t,r]},Ep=t=>zp(t?t(0,null):null)[0],Gn=Promise.resolve(),Pp=t=>(r,o,n)=>{const i=a.useRef(!1),{cache:s,initialSize:d=1,revalidateAll:u=!1,persistSize:l=!1,revalidateFirstPage:h=!0,revalidateOnMount:c=!1,parallel:g=!1}=n,[,,,m]=yt.get(Xi);let x;try{x=Ep(r),x&&(x=$l+x)}catch{}const[v,S,E]=Bt(s,x),k=a.useCallback(()=>Se(v()._l)?d:v()._l,[s,x,d]);ji.useSyncExternalStore(a.useCallback(C=>x?E(x,()=>{C()}):()=>{},[s,x]),k,k);const j=a.useCallback(()=>{const C=v()._l;return Se(C)?d:C},[x,d]),z=a.useRef(j());Xo(()=>{if(!i.current){i.current=!0;return}x&&S({_l:l?z.current:j()})},[x,s]);const b=c&&!i.current,w=t(x,async C=>{const y=v()._i,$=v()._r;S({_r:Qe});const I=[],O=j(),[R]=Bt(s,C),T=R().data,F=[];let D=null;for(let M=0;M<O;++M){const[L,A]=fo(r(M,g?null:D));if(!L)break;const[P,N]=Bt(s,L);let W=P().data;const H=u||y||Se(W)||h&&!M&&!Se(T)||b||T&&!Se(T[M])&&!n.compare(T[M],W);if(o&&(typeof $=="function"?$(W,A):H)){const oe=async()=>{if(!(L in m))W=await o(A);else{const we=m[L];delete m[L],W=await we}N({data:W,_k:A}),I[M]=W};g?F.push(oe):await oe()}else I[M]=W;g||(D=W)}return g&&await Promise.all(F.map(M=>M())),S({_i:Qe}),I},n),_=a.useCallback(function(C,y){const $=typeof y=="boolean"?{revalidate:y}:y||{},I=$.revalidate!==!1;return x?(I&&(Se(C)?S({_i:!0,_r:$.revalidate}):S({_i:!1,_r:$.revalidate})),arguments.length?w.mutate(C,{...$,revalidate:I}):w.mutate()):Gn},[x,s]),f=a.useCallback(C=>{if(!x)return Gn;const[,y]=Bt(s,x);let $;if(pt(C)?$=C(j()):typeof C=="number"&&($=C),typeof $!="number")return Gn;y({_l:$}),z.current=$;const I=[],[O]=Bt(s,x);let R=null;for(let T=0;T<$;++T){const[F]=fo(r(T,R)),[D]=Bt(s,F),M=F?D().data:Qe;if(Se(M))return _(O().data);I.push(M),R=M}return _(I)},[x,s,_,j]);return{size:j(),setSize:f,mutate:_,get data(){return w.data},get error(){return w.error},get isValidating(){return w.isValidating},get isLoading(){return w.isLoading}}},Rp=cp(We,Pp);function Ml({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:i,onError:s,reconnectDelay:d=1e3,maxReconnectAttempts:u=5}={}){const{session:l,loading:h}=Be(),{deployment:c,loading:g}=je(),[m,x]=a.useState(!1),[v,S]=a.useState(null),E=a.useRef(null),k=a.useRef(null),j=a.useRef(0),z=a.useRef(null),b=a.useRef(i),w=a.useRef(s),_=a.useRef(r),f=a.useRef(o),C=a.useRef(n),y=a.useRef(d),$=a.useRef(u);b.current=i,w.current=s,_.current=r,f.current=o,C.current=n,y.current=d,$.current=u;const I=a.useCallback(()=>{k.current&&(clearTimeout(k.current),k.current=null),z.current&&(clearInterval(z.current),z.current=null),E.current&&(E.current.close(),E.current=null)},[]),O=a.useCallback(async()=>{var L;if(!t||h||g||!l||!c)return;I();const F=new URL(c.backend_host),D=F.protocol==="https:"?"wss:":"ws:",M=new URL("/realtime/notifications",`${D}//${F.host}`);if(c.mode==="staging"){const A=localStorage.getItem("__dev_session__");A&&M.searchParams.set("__dev_session__",A)}_.current&&_.current.length>0&&_.current.forEach(A=>M.searchParams.append("channels",A)),f.current&&f.current.length>0&&f.current.forEach(A=>M.searchParams.append("organization_ids",A.toString())),C.current&&C.current.length>0&&C.current.forEach(A=>M.searchParams.append("workspace_ids",A.toString()));try{const A=new WebSocket(M.toString());E.current=A,A.onopen=()=>{x(!0),S(null),j.current=0,z.current=setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send("ping")},3e4)},A.onmessage=P=>{var N,W;try{const H=JSON.parse(P.data);if(H.type==="notification"&&H.data)(N=b.current)==null||N.call(b,H.data);else if(H.type==="error"){const oe=H.error||"Unknown error occurred";S(oe),(W=w.current)==null||W.call(w,oe)}else H.type}catch{}},A.onerror=()=>{var P;S("Connection error occurred"),(P=w.current)==null||P.call(w,"Connection error occurred")},A.onclose=P=>{var N;if(x(!1),z.current&&(clearInterval(z.current),z.current=null),t&&P.code!==1e3&&j.current<$.current){j.current++;const W=y.current*Math.pow(2,j.current-1);k.current=setTimeout(()=>{O()},W)}else j.current>=$.current&&(S("Max reconnection attempts reached"),(N=w.current)==null||N.call(w,"Max reconnection attempts reached"))}}catch{S("Failed to connect"),(L=w.current)==null||L.call(w,"Failed to connect")}},[t,h,g,l,c,I]);a.useEffect(()=>(O(),()=>{I()}),[O,I]),a.useEffect(()=>{E.current&&E.current.readyState===WebSocket.OPEN&&O()},[r,o,n,O]);const R=a.useCallback(()=>{I(),x(!1)},[I]),T=a.useCallback(()=>{j.current=0,O()},[O]);return{isConnected:m,connectionError:v,disconnect:R,reconnect:T}}function yn(t){if(!t)return"";const r=new URLSearchParams;t.limit&&r.append("limit",t.limit.toString()),t.cursor&&r.append("cursor",t.cursor),t.scope&&r.append("scope",t.scope),t.is_read!==void 0&&r.append("is_read",t.is_read.toString()),t.is_archived!==void 0&&r.append("is_archived",t.is_archived.toString()),t.is_starred!==void 0&&r.append("is_starred",t.is_starred.toString()),t.severity&&r.append("severity",t.severity);const o=r.toString();return o?"?"+o:""}async function Ip(t,r){const o=`/notifications${yn(r)}`,n=await t(o,{method:"GET"});return(await U(n)).data}async function Tp(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return U(o)}async function Op(t,r){const o=await t(`/notifications/${r}/unread`,{method:"POST"});return U(o)}async function Ap(t,r){const o=await t(`/notifications/mark-all-read${yn(r)}`,{method:"POST"});return U(o)}async function Lp(t,r){const o=await t(`/notifications/archive-all-read${yn(r)}`,{method:"POST"});return U(o)}async function Mp(t,r){const o=await t(`/notifications/${r}/archive`,{method:"POST"});return U(o)}async function Dp(t,r){const o=await t(`/notifications/${r}/star`,{method:"POST"});return U(o)}function Dl(t){var w;const{client:r,loading:o}=Ve(),{data:n,error:i,mutate:s,isLoading:d,size:u,setSize:l,isValidating:h}=Rp((_,f)=>{var I;if(o||_>0&&(!f||!f.has_more))return null;const C=_===0||(I=f==null?void 0:f.notifications[f.notifications.length-1])==null?void 0:I.id,{onNotification:y,...$}=t||{};return["wacht-notifications",{...$,cursor:C}]},([,_])=>Ip(r,_),{refreshInterval:6e4,revalidateOnFocus:!0,revalidateFirstPage:!0}),c=a.useMemo(()=>n?n.flatMap(_=>_.notifications):[],[n]),g=n?(w=n[n.length-1])==null?void 0:w.has_more:!1;Ml({enabled:!o&&!!n,onNotification:a.useCallback(_=>{s(async f=>{var I;if(!f||f.length===0||f.some(O=>O.notifications.some(R=>R.id===_.id.toString())))return f;(I=t==null?void 0:t.onNotification)==null||I.call(t,_);const y=f[0];return[{...y,notifications:[{id:_.id.toString(),user_id:_.user_id.toString(),deployment_id:_.deployment_id.toString(),title:_.title,body:_.body,severity:_.severity,ctas:_.ctas,is_read:!1,is_archived:!1,created_at:_.created_at,updated_at:_.created_at},...y.notifications]},...f.slice(1)]},!1)},[s,t]),onError:a.useCallback(()=>{},[])});const m=a.useCallback(async _=>{o||(await s(async f=>f&&f.map(C=>({...C,notifications:C.notifications.map(y=>y.id===_?{...y,is_read:!0}:y)})),!1),await Tp(r,_),await s())},[r,o,s]),x=a.useCallback(async _=>{o||(await s(async f=>f&&f.map(C=>({...C,notifications:C.notifications.map(y=>y.id===_?{...y,is_read:!1}:y)})),!1),await Op(r,_),await s())},[r,o,s]),v=a.useCallback(async()=>{o||(await s(async _=>_&&_.map(f=>({...f,notifications:f.notifications.map(C=>({...C,is_read:!0}))})),!1),await Ap(r,t),await s())},[r,t,s,o]),S=a.useCallback(async()=>{o||(await s(async _=>_&&_.map(f=>({...f,notifications:f.notifications.filter(C=>!C.is_read)})),!1),await Lp(r,t),await s())},[r,t,o,s]),E=a.useCallback(async _=>{o||(await s(async f=>f&&f.map(C=>({...C,notifications:(t==null?void 0:t.is_archived)!==void 0?C.notifications.filter(y=>y.id!==_):C.notifications.map(y=>y.id===_?{...y,is_archived:!y.is_archived}:y)})),!1),await Mp(r,_),await s())},[r,o,s,t==null?void 0:t.is_archived]),k=a.useCallback(async _=>{o||(await s(async f=>f&&f.map(C=>({...C,notifications:C.notifications.map(y=>y.id===_?{...y,is_starred:!y.is_starred}:y)})),!1),await Dp(r,_),await s())},[r,o,s]),j=a.useCallback(async()=>{h||!g||await l(u+1)},[h,g,l,u]),z=a.useCallback(async()=>{await s()},[s]),b=o||d||u>0&&n&&typeof n[u-1]>"u";return!n||b?{loading:!0,notifications:c,hasMore:g,markAsRead:void 0,markAllAsRead:void 0,archiveAllRead:void 0,archiveNotification:void 0,starNotification:void 0,markAsUnread:void 0,error:i,refetch:z,loadMore:j}:{loading:!1,error:i,notifications:c,hasMore:g,markAsRead:m,markAllAsRead:v,archiveAllRead:S,archiveNotification:E,starNotification:k,markAsUnread:x,refetch:z,loadMore:j}}async function Fp(t,r){const o=`/notifications/scope-unread${yn(r)}`,n=await t(o,{method:"GET"});return(await U(n)).data}function Fl(t){const{client:r,loading:o}=Ve(),{data:n,error:i,mutate:s}=We(o?null:["wacht-notifications-unread",t],([,u])=>Fp(r,u),{refreshInterval:3e4,revalidateOnFocus:!0}),d=async()=>{await s()};return!n||o?{loading:!0,count:0,error:i,refetch:d}:{loading:!1,count:n.count,error:i,refetch:d}}const _o={DISCONNECTED:"disconnected",CONNECTED:"connected",ERROR:"error"},qe={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},tr={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Np(t){switch(t){case tr.IDLE:return qe.IDLE;case tr.STARTING:return qe.STARTING;case tr.RUNNING:return qe.RUNNING;case tr.WAITING_FOR_INPUT:return qe.WAITING_FOR_INPUT;case tr.COMPLETED:return qe.COMPLETED;case tr.FAILED:case tr.CANCELLED:return qe.FAILED;default:return qe.IDLE}}function Up(t){return t===qe.STARTING||t===qe.RUNNING||t===qe.WAITING_FOR_INPUT}function Bp({contextId:t,agentName:r,platformAdapter:o}){const{deployment:n}=je(),{client:i}=Ve(),[s,d]=a.useState([]),[u,l]=a.useState([]),[h,c]=a.useState(null),[g,m]=a.useState(null),[x,v]=a.useState(null),[S,E]=a.useState(!1),[k,j]=a.useState(!1),[z,b]=a.useState(qe.IDLE),[w,_]=a.useState({status:_o.DISCONNECTED}),[f,C]=a.useState(!0),[y,$]=a.useState(!1),I=a.useRef(null),O=a.useRef(null),R=a.useRef(null),T=a.useRef(new Set),F=a.useCallback(te=>{var K;const{id:ae,content:ye}=te,ge=te.message_type||((K=te.metadata)==null?void 0:K.message_type)||(ye==null?void 0:ye.type);let Q="assistant";ge==="user_message"&&(Q="user");const q={...te,role:Q,metadata:{...te.metadata||{},message_type:ge}};if(ge==="system_decision"||ge==="action_execution_result"||ge==="context_results"){if(c(null),m(null),v(null),T.current.has(ae))return;T.current.add(ae),d(ue=>[...ue,q]);return}if(ge==="user_message"){if(c(null),m(null),v(null),T.current.has(ae))return;T.current.add(ae),console.log(T.current,ae),d(ue=>[...ue,q]);return}if(ge==="assistant_acknowledgment"){if(c(null),m(null),v(null),T.current.has(ae))return;T.current.add(ae),d(ue=>[...ue,q]),te.further_action_required||(j(!1),b(qe.IDLE),O.current=null);return}if(ge==="agent_response"){if(T.current.has(ae))return;T.current.add(ae),d(ue=>[...ue,q]),j(!1),b(qe.IDLE),O.current=null;return}if(ge==="user_input_request"){if(T.current.has(ae))return;T.current.add(ae),b(qe.WAITING_FOR_INPUT),d(ue=>[...ue,q]);return}if(ge==="execution_status"){const ue=Np(ye.status);b(ue),j(Up(ue));return}},[]),D=a.useCallback((te,ae)=>{var ye;(ye=o==null?void 0:o.onPlatformEvent)==null||ye.call(o,te,ae)},[o]),M=a.useRef(F),L=a.useRef(D),A=a.useRef(i),P=a.useRef(n);a.useEffect(()=>{M.current=F,L.current=D,A.current=i,P.current=n});const N=a.useRef(null),W=a.useRef(null),H=a.useRef(0),oe=10,Z=a.useCallback(async te=>{if(t)try{const ae=new URLSearchParams({limit:"100"});te&&(ae.append("before_id",te),$(!0));const ye=await i(`/api/agent/contexts/${t}/messages?${ae}`,{method:"GET"}),ge=await U(ye);if(ge.data){const Q=[...ge.data.data].sort((q,K)=>{const ue=new Date(q.timestamp).getTime(),xe=new Date(K.timestamp).getTime();return ue-xe});Q.length>0&&(I.current=Q[0].id),Q.forEach(q=>{T.current.add(q.id)}),d(q=>te?[...Q,...q]:Q),C(ge.data.has_more||!1),$(!1)}}catch(ae){console.error("Failed to fetch messages:",ae),$(!1)}},[t,i]);a.useEffect(()=>{const te=P.current;if(!te||!t)return;const ae=()=>{N.current&&(N.current.close(),N.current=null);const ye=te.backend_host.replace(/\/$/,""),ge=new URL(`${ye}/realtime/agent/stream`);if(ge.searchParams.append("context_id",t),te.mode==="staging"){const q=localStorage.getItem("__dev_session__");q&&ge.searchParams.append("__dev_session__",q)}console.log("SSE: Connecting to",ge.toString());const Q=new EventSource(ge.toString(),{withCredentials:te.mode!=="staging"});N.current=Q,Q.onopen=()=>{console.log("SSE: Connected successfully"),E(!0),_({status:_o.CONNECTED}),H.current>0&&setTimeout(()=>{i(`/api/agent/contexts/${t}/messages?limit=100`,{method:"GET"}).then(async q=>{const K=await U(q);if(K.data){const ue=[...K.data.data].sort((xe,Y)=>new Date(xe.timestamp).getTime()-new Date(Y.timestamp).getTime());d(ue)}}).catch(q=>console.error("Failed to refetch messages:",q))},100),H.current=0},Q.onerror=q=>{if(console.error("SSE error:",q),E(!1),_({status:_o.ERROR}),Q.close(),N.current=null,H.current<oe){const K=Math.min(1e3*Math.pow(2,H.current),3e4);console.log(`SSE: Reconnecting in ${K}ms (attempt ${H.current+1}/${oe})`),W.current=setTimeout(()=>{H.current++,ae()},K)}else console.error("SSE: Max reconnection attempts reached"),_({status:_o.DISCONNECTED})},Q.addEventListener("conversation_message",q=>{try{console.log("SSE received conversation_message:",q.data);const K=JSON.parse(q.data);K.ConversationMessage&&M.current(K.ConversationMessage)}catch(K){console.error("Failed to parse conversation event:",K)}}),Q.addEventListener("platform_event",q=>{try{console.log("SSE received platform_event:",q.data);const K=JSON.parse(q.data);K.PlatformEvent&&L.current(K.PlatformEvent[0],K.PlatformEvent[1])}catch(K){console.error("Failed to parse platform event:",K)}}),Q.addEventListener("user_input_request",q=>{try{console.log("SSE received user_input_request:",q.data);const K=JSON.parse(q.data);K.UserInputRequest&&F({id:`input-${Date.now()}`,content:K.UserInputRequest,metadata:{message_type:"user_input_request"}})}catch(K){console.error("Failed to parse user input request:",K)}})};return ae(),()=>{console.log("SSE: Cleanup running, closing connection for context:",t),W.current&&(clearTimeout(W.current),W.current=null),N.current&&(N.current.close(),N.current=null),E(!1)}},[t]);const we=a.useCallback(async(te,ae,ye)=>{if(!(!t||!n)){c(te),ae&&ae.length>0&&m(ae),ye&&ye.length>0&&v(ye);try{const ge=new FormData;ge.append("agent_name",r),ge.append("message",te),ye&&ye.length>0&&ye.forEach(q=>{ge.append("files",q)}),(await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ge})).ok?(j(!0),b(qe.RUNNING)):(c(null),m(null),v(null))}catch(ge){console.error("Failed to send message:",ge),c(null),m(null),v(null)}}},[t,r,n,i,Z]),pe=a.useCallback(async te=>{if(!(!t||z!==qe.WAITING_FOR_INPUT))try{const ae=new FormData;ae.append("agent_name",r),ae.append("user_input",te),await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ae}),b(qe.RUNNING)}catch(ae){console.error("Failed to submit user input:",ae)}},[t,r,z,i]);a.useEffect(()=>{t&&R.current!==t&&(R.current=t,Z())},[t]);const ee=a.useCallback(async()=>{if(!(y||!f||!I.current)){$(!0);try{await Z(I.current)}finally{$(!1)}}},[y,f,Z]),me=a.useCallback(()=>{d([]),l([]),c(null),m(null),v(null)},[]),re=a.useCallback(()=>{},[]),Pe=a.useCallback(async()=>{if(!(!t||!k))try{const te=new FormData;te.append("agent_name",r),te.append("cancel","true"),await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:te}),j(!1),b(qe.IDLE)}catch(te){console.error("Failed to cancel execution:",te)}},[t,k,r,i]);return{messages:s,quickQuestions:u,pendingMessage:h,pendingImages:g,pendingFiles:x,connectionState:w,isConnected:S,isExecuting:k,executionStatus:z,isWaitingForInput:z===qe.WAITING_FOR_INPUT,hasMoreMessages:f,isLoadingMore:y,sendMessage:we,submitUserInput:pe,clearMessages:me,loadMoreMessages:ee,cancelExecution:Pe,connect:re,disconnect:()=>{N.current&&(N.current.close(),N.current=null,E(!1))}}}function Wp(t){const{client:r}=Ve(),o=a.useCallback(async()=>{if(!t)return[];const l=await r(`/api/agent/integrations?agent_name=${t}`,{method:"GET"});return(await U(l)).data},[r,t]),{data:n,error:i,mutate:s}=We(t?`wacht-agent-integrations:${t}`:null,o,{revalidateOnFocus:!1}),d=a.useCallback(async l=>{const h=`/api/agent/integrations/${l}/consent-url`,c=await r(h,{method:"POST"});return(await U(c)).data},[r]),u=a.useCallback(async l=>{await r(`/api/agent/integrations/${l}/remove`,{method:"POST"}),await s(h=>h&&h.filter(c=>c.id!==l))},[r,s]);return{integrations:n||[],loading:!n&&!i,error:i,generateConsentURL:d,removeIntegration:u,refetch:async()=>{await s()}}}function Vp(t){const{client:r}=Ve(),[o,n]=a.useState(!t),[i,s]=a.useState(!!t),[d,u]=a.useState(null),l=a.useRef(!1),h=a.useRef(!1),[c,g]=a.useState(null),m=o,x=a.useCallback(async()=>{const w=await r("/api/agent/session",{method:"GET"});if(!w.ok)throw w.status===401||w.status===403?new Error("NO_SESSION"):new Error("Failed to fetch session");return(await U(w)).data},[r]),{data:v,error:S,isLoading:E,mutate:k}=We(m?"wacht-agent-session":null,x,{revalidateOnFocus:!1});a.useEffect(()=>{if(!t||l.current||h.current)return;(async()=>{h.current=!0,s(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"GET"})).ok?(l.current=!0,n(!0)):u(new Error("Failed to exchange ticket"))}catch(_){u(_ instanceof Error?_:new Error("Failed to exchange ticket"))}finally{s(!1),h.current=!1}})()},[t,r]),a.useEffect(()=>{!c&&(v!=null&&v.agents)&&v.agents.length>0&&g(v.agents[0])},[v,c]),a.useEffect(()=>{v!=null&&v.agents&&c&&!v.agents.some(_=>_.id===c.id)&&v.agents.length>0&&g(v.agents[0])},[v,c]);const j=!S||S.message!=="NO_SESSION",z=d||(S&&S.message!=="NO_SESSION"?S:null);return{hasSession:j,sessionLoading:i||m&&E,sessionError:z,sessionId:(v==null?void 0:v.session_id)||null,contextGroup:(v==null?void 0:v.context_group)||null,agents:(v==null?void 0:v.agents)||[],activeAgent:c,setActiveAgent:g,ticketExchanged:o,ticketLoading:i,refetch:async()=>{await k()}}}function Gp(t={}){const{client:r}=Ve(),{limit:o=20,offset:n=0,status:i,search:s,enabled:d=!0}=t,u=a.useCallback(async()=>{const v=new URLSearchParams({limit:String(o),offset:String(n)});i&&v.append("status",i),s&&v.append("search",s);const S=await r(`/api/agent/contexts?${v.toString()}`,{method:"GET"});return(await U(S)).data},[r,o,n,i,s]),{data:l,error:h,mutate:c}=We(d?`wacht-agent-contexts:${o}:${n}:${i}:${s}`:null,u,{revalidateOnFocus:!1}),g=a.useCallback(async v=>{const S=new FormData;S.append("title",v.title),v.system_instructions&&S.append("system_instructions",v.system_instructions);const E=await r("/api/agent/contexts",{method:"POST",body:S}),k=await U(E);return await c(j=>j&&{...j,data:[k.data,...j.data]}),k.data},[r,c]),m=a.useCallback(async v=>{await r(`/api/agent/contexts/${v}/delete`,{method:"POST"}),await c(S=>S&&{...S,data:S.data.filter(E=>E.id!==v)})},[r,c]),x=a.useCallback(async(v,S)=>{const E=new FormData;if(S.title&&E.append("title",S.title),!(await r(`/api/agent/contexts/${v}/update`,{method:"POST",body:E})).ok)throw new Error("Failed to update context");await c(j=>j&&{...j,data:j.data.map(z=>z.id===v?{...z,...S}:z)})},[r,c]);return{contexts:(l==null?void 0:l.data)||[],loading:!l&&!h,error:h,hasMore:(l==null?void 0:l.has_more)||!1,createContext:g,deleteContext:m,updateContext:x,refetch:async()=>{await c()}}}const Nl=()=>{const{client:t}=Ve(),[r,o]=a.useState(!1),[n,i]=a.useState(null),[s,d]=a.useState(null),u=a.useCallback(async h=>{o(!0),i(null),d(null);try{const c=new FormData;c.append("token",h);const g=await t("/organizations/invitations/accept",{method:"POST",body:c}),x=(await U(g)).data;return d(x),x.error_code&&i(x.message||"Failed to accept invitation"),x}catch(c){const g=c.message||"Failed to accept invitation";i(g);const m={error_code:"NETWORK_ERROR",message:g};return d(m),m}finally{o(!1)}},[t]),l=a.useCallback(()=>{i(null),d(null)},[]);return{acceptInvitation:u,invitationData:s,loading:r,error:n,reset:l}},Hp=({children:t})=>{const{loading:r}=je();return r?null:e.jsx(e.Fragment,{children:t})},qp=({children:t})=>{const{loading:r}=je();return r?e.jsx(e.Fragment,{children:t}):null};var it=function(){return it=Object.assign||function(r){for(var o,n=1,i=arguments.length;n<i;n++){o=arguments[n];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])}return r},it.apply(this,arguments)};function vr(t,r,o){if(o||arguments.length===2)for(var n=0,i=r.length,s;n<i;n++)(s||!(n in r))&&(s||(s=Array.prototype.slice.call(r,0,n)),s[n]=r[n]);return t.concat(s||Array.prototype.slice.call(r))}function Yp(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var Qp=/^((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|fetchpriority|fetchPriority|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|popover|popoverTarget|popoverTargetAction|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)-.*))$/,Kp=Yp(function(t){return Qp.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ne="-ms-",po="-moz-",Te="-webkit-",Ul="comm",bn="rule",es="decl",Zp="@import",Jp="@namespace",Bl="@keyframes",Xp="@layer",Wl=Math.abs,ts=String.fromCharCode,Oi=Object.assign;function eh(t,r){return Ye(t,0)^45?(((r<<2^Ye(t,0))<<2^Ye(t,1))<<2^Ye(t,2))<<2^Ye(t,3):0}function Vl(t){return t.trim()}function It(t,r){return(t=r.exec(t))?t[0]:t}function Ce(t,r,o){return t.replace(r,o)}function en(t,r,o){return t.indexOf(r,o)}function Ye(t,r){return t.charCodeAt(r)|0}function yr(t,r,o){return t.slice(r,o)}function ut(t){return t.length}function Gl(t){return t.length}function co(t,r){return r.push(t),t}function th(t,r){return t.map(r).join("")}function Ws(t,r){return t.filter(function(o){return!It(o,r)})}var wn=1,Fr=1,Hl=0,dt=0,Ge=0,Vr="";function jn(t,r,o,n,i,s,d,u){return{value:t,root:r,parent:o,type:n,props:i,children:s,line:wn,column:Fr,length:d,return:"",siblings:u}}function Ut(t,r){return Oi(jn("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function Sr(t){for(;t.root;)t=Ut(t.root,{children:[t]});co(t,t.siblings)}function rh(){return Ge}function oh(){return Ge=dt>0?Ye(Vr,--dt):0,Fr--,Ge===10&&(Fr=1,wn--),Ge}function ft(){return Ge=dt<Hl?Ye(Vr,dt++):0,Fr++,Ge===10&&(Fr=1,wn++),Ge}function Wt(){return Ye(Vr,dt)}function tn(){return dt}function _n(t,r){return yr(Vr,t,r)}function go(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 nh(t){return wn=Fr=1,Hl=ut(Vr=t),dt=0,[]}function ih(t){return Vr="",t}function Hn(t){return Vl(_n(dt-1,Ai(t===91?t+2:t===40?t+1:t)))}function sh(t){for(;(Ge=Wt())&&Ge<33;)ft();return go(t)>2||go(Ge)>3?"":" "}function ah(t,r){for(;--r&&ft()&&!(Ge<48||Ge>102||Ge>57&&Ge<65||Ge>70&&Ge<97););return _n(t,tn()+(r<6&&Wt()==32&&ft()==32))}function Ai(t){for(;ft();)switch(Ge){case t:return dt;case 34:case 39:t!==34&&t!==39&&Ai(Ge);break;case 40:t===41&&Ai(t);break;case 92:ft();break}return dt}function ch(t,r){for(;ft()&&t+Ge!==57;)if(t+Ge===84&&Wt()===47)break;return"/*"+_n(r,dt-1)+"*"+ts(t===47?t:ft())}function lh(t){for(;!go(Wt());)ft();return _n(t,dt)}function dh(t){return ih(rn("",null,null,null,[""],t=nh(t),0,[0],t))}function rn(t,r,o,n,i,s,d,u,l){for(var h=0,c=0,g=d,m=0,x=0,v=0,S=1,E=1,k=1,j=0,z="",b=i,w=s,_=n,f=z;E;)switch(v=j,j=ft()){case 40:if(v!=108&&Ye(f,g-1)==58){en(f+=Ce(Hn(j),"&","&\f"),"&\f",Wl(h?u[h-1]:0))!=-1&&(k=-1);break}case 34:case 39:case 91:f+=Hn(j);break;case 9:case 10:case 13:case 32:f+=sh(v);break;case 92:f+=ah(tn()-1,7);continue;case 47:switch(Wt()){case 42:case 47:co(uh(ch(ft(),tn()),r,o,l),l),(go(v||1)==5||go(Wt()||1)==5)&&ut(f)&&yr(f,-1,void 0)!==" "&&(f+=" ");break;default:f+="/"}break;case 123*S:u[h++]=ut(f)*k;case 125*S:case 59:case 0:switch(j){case 0:case 125:E=0;case 59+c:k==-1&&(f=Ce(f,/\f/g,"")),x>0&&(ut(f)-g||S===0&&v===47)&&co(x>32?Gs(f+";",n,o,g-1,l):Gs(Ce(f," ","")+";",n,o,g-2,l),l);break;case 59:f+=";";default:if(co(_=Vs(f,r,o,h,c,i,u,z,b=[],w=[],g,s),s),j===123)if(c===0)rn(f,r,_,_,b,s,g,u,w);else{switch(m){case 99:if(Ye(f,3)===110)break;case 108:if(Ye(f,2)===97)break;default:c=0;case 100:case 109:case 115:}c?rn(t,_,_,n&&co(Vs(t,_,_,0,0,i,u,z,i,b=[],g,w),w),i,w,g,u,n?b:w):rn(f,_,_,_,[""],w,0,u,w)}}h=c=x=0,S=k=1,z=f="",g=d;break;case 58:g=1+ut(f),x=v;default:if(S<1){if(j==123)--S;else if(j==125&&S++==0&&oh()==125)continue}switch(f+=ts(j),j*S){case 38:k=c>0?1:(f+="\f",-1);break;case 44:u[h++]=(ut(f)-1)*k,k=1;break;case 64:Wt()===45&&(f+=Hn(ft())),m=Wt(),c=g=ut(z=f+=lh(tn())),j++;break;case 45:v===45&&ut(f)==2&&(S=0)}}return s}function Vs(t,r,o,n,i,s,d,u,l,h,c,g){for(var m=i-1,x=i===0?s:[""],v=Gl(x),S=0,E=0,k=0;S<n;++S)for(var j=0,z=yr(t,m+1,m=Wl(E=d[S])),b=t;j<v;++j)(b=Vl(E>0?x[j]+" "+z:Ce(z,/&\f/g,x[j])))&&(l[k++]=b);return jn(t,r,o,i===0?bn:u,l,h,c,g)}function uh(t,r,o,n){return jn(t,r,o,Ul,ts(rh()),yr(t,2,-2),0,n)}function Gs(t,r,o,n,i){return jn(t,r,o,es,yr(t,0,n),yr(t,n+1,-1),n,i)}function ql(t,r,o){switch(eh(t,r)){case 5103:return Te+"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 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return Te+t+t;case 4855:return Te+t.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+t;case 4789:return po+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Te+t+po+t+Ne+t+t;case 5936:switch(Ye(t,r+11)){case 114:return Te+t+Ne+Ce(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Te+t+Ne+Ce(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Te+t+Ne+Ce(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return Te+t+Ne+t+t;case 6165:return Te+t+Ne+"flex-"+t+t;case 5187:return Te+t+Ce(t,/(\w+).+(:[^]+)/,Te+"box-$1$2"+Ne+"flex-$1$2")+t;case 5443:return Te+t+Ne+"flex-item-"+Ce(t,/flex-|-self/g,"")+(It(t,/flex-|baseline/)?"":Ne+"grid-row-"+Ce(t,/flex-|-self/g,""))+t;case 4675:return Te+t+Ne+"flex-line-pack"+Ce(t,/align-content|flex-|-self/g,"")+t;case 5548:return Te+t+Ne+Ce(t,"shrink","negative")+t;case 5292:return Te+t+Ne+Ce(t,"basis","preferred-size")+t;case 6060:return Te+"box-"+Ce(t,"-grow","")+Te+t+Ne+Ce(t,"grow","positive")+t;case 4554:return Te+Ce(t,/([^-])(transform)/g,"$1"+Te+"$2")+t;case 6187:return Ce(Ce(Ce(t,/(zoom-|grab)/,Te+"$1"),/(image-set)/,Te+"$1"),t,"")+t;case 5495:case 3959:return Ce(t,/(image-set\([^]*)/,Te+"$1$`$1");case 4968:return Ce(Ce(t,/(.+:)(flex-)?(.*)/,Te+"box-pack:$3"+Ne+"flex-pack:$3"),/space-between/,"justify")+Te+t+t;case 4200:if(!It(t,/flex-|baseline/))return Ne+"grid-column-align"+yr(t,r)+t;break;case 2592:case 3360:return Ne+Ce(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,i){return r=i,It(n.props,/grid-\w+-end/)})?~en(t+(o=o[r].value),"span",0)?t:Ne+Ce(t,"-start","")+t+Ne+"grid-row-span:"+(~en(o,"span",0)?It(o,/\d+/):+It(o,/\d+/)-+It(t,/\d+/))+";":Ne+Ce(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return It(n.props,/grid-\w+-start/)})?t:Ne+Ce(Ce(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return Ce(t,/(.+)-inline(.+)/,Te+"$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(ut(t)-1-r>6)switch(Ye(t,r+1)){case 109:if(Ye(t,r+4)!==45)break;case 102:return Ce(t,/(.+:)(.+)-([^]+)/,"$1"+Te+"$2-$3$1"+po+(Ye(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~en(t,"stretch",0)?ql(Ce(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return Ce(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,i,s,d,u,l,h){return Ne+i+":"+s+h+(d?Ne+i+"-span:"+(u?l:+l-+s)+h:"")+t});case 4949:if(Ye(t,r+6)===121)return Ce(t,":",":"+Te)+t;break;case 6444:switch(Ye(t,Ye(t,14)===45?18:11)){case 120:return Ce(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Te+(Ye(t,14)===45?"inline-":"")+"box$3$1"+Te+"$2$3$1"+Ne+"$2box$3")+t;case 100:return Ce(t,":",":"+Ne)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Ce(t,"scroll-","scroll-snap-")+t}return t}function ln(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function ph(t,r,o,n){switch(t.type){case Xp:if(t.children.length)break;case Zp:case Jp:case es:return t.return=t.return||t.value;case Ul:return"";case Bl:return t.return=t.value+"{"+ln(t.children,n)+"}";case bn:if(!ut(t.value=t.props.join(",")))return""}return ut(o=ln(t.children,n))?t.return=t.value+"{"+o+"}":""}function hh(t){var r=Gl(t);return function(o,n,i,s){for(var d="",u=0;u<r;u++)d+=t[u](o,n,i,s)||"";return d}}function fh(t){return function(r){r.root||(r=r.return)&&t(r)}}function gh(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case es:t.return=ql(t.value,t.length,o);return;case Bl:return ln([Ut(t,{value:Ce(t.value,"@","@"+Te)})],n);case bn:if(t.length)return th(o=t.props,function(i){switch(It(i,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Sr(Ut(t,{props:[Ce(i,/:(read-\w+)/,":"+po+"$1")]})),Sr(Ut(t,{props:[i]})),Oi(t,{props:Ws(o,n)});break;case"::placeholder":Sr(Ut(t,{props:[Ce(i,/:(plac\w+)/,":"+Te+"input-$1")]})),Sr(Ut(t,{props:[Ce(i,/:(plac\w+)/,":"+po+"$1")]})),Sr(Ut(t,{props:[Ce(i,/:(plac\w+)/,Ne+"input-$1")]})),Sr(Ut(t,{props:[i]})),Oi(t,{props:Ws(o,n)});break}return""})}}var mh={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,scale: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},br=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Yl="active",Ql="data-styled-version",kn="6.3.8",rs=`/*!sc*/
|
|
18
|
+
*/var Os;function Lu(){return Os||(Os=1,process.env.NODE_ENV!=="production"&&(function(){function t(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}function r(x,v){c||i.startTransition===void 0||(c=!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 S=v();if(!g){var E=v();s(S,E)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),g=!0)}E=d({inst:{value:S,getSnapshot:v}});var k=E[0].inst,j=E[1];return l(function(){k.value=S,k.getSnapshot=v,o(k)&&j({inst:k})},[x,S,v]),u(function(){return o(k)&&j({inst:k}),x(function(){o(k)&&j({inst:k})})},[x]),h(S),S}function o(x){var v=x.getSnapshot;x=x.value;try{var S=v();return!s(x,S)}catch{return!0}}function n(x,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var i=a,s=typeof Object.is=="function"?Object.is:t,d=i.useState,u=i.useEffect,l=i.useLayoutEffect,h=i.useDebugValue,c=!1,g=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;Ln.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())})()),Ln}var As;function Mu(){return As||(As=1,process.env.NODE_ENV==="production"?yo.exports=Au():yo.exports=Lu()),yo.exports}var ji=Mu();const jl=0,_l=1,kl=2,Ls=3;var Ms=Object.prototype.hasOwnProperty;function _i(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--&&_i(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Ms.call(t,o)&&++n&&!Ms.call(r,o)||!(o in r)||!_i(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const wt=new WeakMap,At=()=>{},Qe=At(),ki=Object,Se=t=>t===Qe,ft=t=>typeof t=="function",Ht=(t,r)=>({...t,...r}),Cl=t=>ft(t.then),Mn={},bo={},Ji="undefined",xo=typeof window!=Ji,Ci=typeof document!=Ji,Du=xo&&"Deno"in window,Fu=()=>xo&&typeof window.requestAnimationFrame!=Ji,Wt=(t,r)=>{const o=wt.get(t);return[()=>!Se(r)&&t.get(r)||Mn,n=>{if(!Se(r)){const i=t.get(r);r in bo||(bo[r]=i),o[5](r,Ht(i,n),i||Mn)}},o[6],()=>!Se(r)&&r in bo?bo[r]:!Se(r)&&t.get(r)||Mn]};let Si=!0;const Nu=()=>Si,[$i,zi]=xo&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[At,At],Uu=()=>{const t=Ci&&document.visibilityState;return Se(t)||t!=="hidden"},Bu=t=>(Ci&&document.addEventListener("visibilitychange",t),$i("focus",t),()=>{Ci&&document.removeEventListener("visibilitychange",t),zi("focus",t)}),Wu=t=>{const r=()=>{Si=!0,t()},o=()=>{Si=!1};return $i("online",r),$i("offline",o),()=>{zi("online",r),zi("offline",o)}},Vu={isOnline:Nu,isVisible:Uu},Gu={initFocus:Bu,initReconnect:Wu},Ds=!a.useId,Dr=!xo||Du,Hu=t=>Fu()?window.requestAnimationFrame(t):setTimeout(t,1),Xo=Dr?a.useEffect:a.useLayoutEffect,Dn=typeof navigator<"u"&&navigator.connection,Fs=!Dr&&Dn&&(["slow-2g","2g"].includes(Dn.effectiveType)||Dn.saveData),wo=new WeakMap,qu=t=>ki.prototype.toString.call(t),Fn=(t,r)=>t===`[object ${r}]`;let Yu=0;const Ei=t=>{const r=typeof t,o=qu(t),n=Fn(o,"Date"),i=Fn(o,"RegExp"),s=Fn(o,"Object");let d,u;if(ki(t)===t&&!n&&!i){if(d=wo.get(t),d)return d;if(d=++Yu+"~",wo.set(t,d),Array.isArray(t)){for(d="@",u=0;u<t.length;u++)d+=Ei(t[u])+",";wo.set(t,d)}if(s){d="#";const l=ki.keys(t).sort();for(;!Se(u=l.pop());)Se(t[u])||(d+=u+":"+Ei(t[u])+",");wo.set(t,d)}}else d=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return d},fo=t=>{if(ft(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Ei(t):"",[t,r]};let Qu=0;const Pi=()=>++Qu;async function Sl(...t){const[r,o,n,i]=t,s=Ht({populateCache:!0,throwOnError:!0},typeof i=="boolean"?{revalidate:i}:i||{});let d=s.populateCache;const u=s.rollbackOnError;let l=s.optimisticData;const h=m=>typeof u=="function"?u(m):u!==!1,c=s.throwOnError;if(ft(o)){const m=o,x=[],v=r.keys();for(const S of v)!/^\$(inf|sub)\$/.test(S)&&m(r.get(S)._k)&&x.push(S);return Promise.all(x.map(g))}return g(o);async function g(m){const[x]=fo(m);if(!x)return;const[v,S]=Wt(r,x),[E,k,j,z]=wt.get(r),b=()=>{const T=E[x];return(ft(s.revalidate)?s.revalidate(v().data,m):s.revalidate!==!1)&&(delete j[x],delete z[x],T&&T[0])?T[0](kl).then(()=>v().data):v().data};if(t.length<3)return b();let w=n,_,f=!1;const C=Pi();k[x]=[C,0];const y=!Se(l),$=v(),I=$.data,O=$._c,R=Se(O)?I:O;if(y&&(l=ft(l)?l(R,I):l,S({data:l,_c:R})),ft(w))try{w=w(R)}catch(T){_=T,f=!0}if(w&&Cl(w))if(w=await w.catch(T=>{_=T,f=!0}),C!==k[x][0]){if(f)throw _;return w}else f&&y&&h(_)&&(d=!0,S({data:R,_c:Qe}));if(d&&!f)if(ft(d)){const T=d(w,R);S({data:T,error:Qe,_c:Qe})}else S({data:w,error:Qe,_c:Qe});if(k[x][1]=Pi(),Promise.resolve(b()).then(()=>{S({_c:Qe})}),f){if(c)throw _;return}return w}}const Ns=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},Ku=(t,r)=>{if(!wt.has(t)){const o=Ht(Gu,r),n=Object.create(null),i=Sl.bind(Qe,t);let s=At;const d=Object.create(null),u=(c,g)=>{const m=d[c]||[];return d[c]=m,m.push(g),()=>m.splice(m.indexOf(g),1)},l=(c,g,m)=>{t.set(c,g);const x=d[c];if(x)for(const v of x)v(g,m)},h=()=>{if(!wt.has(t)&&(wt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),i,l,u]),!Dr)){const c=o.initFocus(setTimeout.bind(Qe,Ns.bind(Qe,n,jl))),g=o.initReconnect(setTimeout.bind(Qe,Ns.bind(Qe,n,_l)));s=()=>{c&&c(),g&&g(),wt.delete(t)}}};return h(),[t,i,h,s]}return[t,wt.get(t)[4]]},Zu=(t,r,o,n,i)=>{const s=o.errorRetryCount,d=i.retryCount,u=~~((Math.random()+.5)*(1<<(d<8?d:8)))*o.errorRetryInterval;!Se(s)&&d>s||setTimeout(n,u,i)},Ju=_i,[Xi,so]=Ku(new Map),Xu=Ht({onLoadingSlow:At,onSuccess:At,onError:At,onErrorRetry:Zu,onDiscarded:At,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Fs?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Fs?5e3:3e3,compare:Ju,isPaused:()=>!1,cache:Xi,mutate:so,fallback:{}},Vu),ep=(t,r)=>{const o=Ht(t,r);if(r){const{use:n,fallback:i}=t,{use:s,fallback:d}=r;n&&s&&(o.use=n.concat(s)),i&&d&&(o.fallback=Ht(i,d))}return o},tp=a.createContext({}),$l="$inf$",zl=xo&&window.__SWR_DEVTOOLS_USE__,rp=zl?window.__SWR_DEVTOOLS_USE__:[],op=()=>{zl&&(window.__SWR_DEVTOOLS_REACT__=a)},El=t=>ft(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],Pl=()=>{const t=a.useContext(tp);return a.useMemo(()=>Ht(Xu,t),[t])},np=t=>(r,o,n)=>t(r,o&&((...s)=>{const[d]=fo(r),[,,,u]=wt.get(Xi);if(d.startsWith($l))return o(...s);const l=u[d];return Se(l)?o(...s):(delete u[d],l)}),n),ip=rp.concat(np),sp=t=>function(...o){const n=Pl(),[i,s,d]=El(o),u=ep(n,d);let l=t;const{use:h}=u,c=(h||[]).concat(ip);for(let g=c.length;g--;)l=c[g](l);return l(i,s||u.fetcher||null,u)},ap=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const i=n.indexOf(o);i>=0&&(n[i]=n[n.length-1],n.pop())}},cp=(t,r)=>(...o)=>{const[n,i,s]=El(o),d=(s.use||[]).concat(r);return t(n,i,{...s,use:d})};op();const Nn=a.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}}),Un={dedupe:!0},Us=Promise.resolve(Qe),lp=(t,r,o)=>{const{cache:n,compare:i,suspense:s,fallbackData:d,revalidateOnMount:u,revalidateIfStale:l,refreshInterval:h,refreshWhenHidden:c,refreshWhenOffline:g,keepPreviousData:m,strictServerPrefetchWarning:x}=o,[v,S,E,k]=wt.get(n),[j,z]=fo(t),b=a.useRef(!1),w=a.useRef(!1),_=a.useRef(j),f=a.useRef(r),C=a.useRef(o),y=()=>C.current,$=()=>y().isVisible()&&y().isOnline(),[I,O,R,T]=Wt(n,j),F=a.useRef({}).current,D=Se(d)?Se(o.fallback)?Qe:o.fallback[j]:d,M=(Q,q)=>{for(const K in F){const ue=K;if(ue==="data"){if(!i(Q[ue],q[ue])&&(!Se(Q[ue])||!i(we,q[ue])))return!1}else if(q[ue]!==Q[ue])return!1}return!0},L=a.useMemo(()=>{const Q=!j||!r?!1:Se(u)?y().isPaused()||s?!1:l!==!1:u,q=V=>{const be=Ht(V);return delete be._k,Q?{isValidating:!0,isLoading:!0,...be}:be},K=I(),ue=T(),xe=q(K),Y=K===ue?xe:q(ue);let he=xe;return[()=>{const V=q(I());return M(V,he)?(he.data=V.data,he.isLoading=V.isLoading,he.isValidating=V.isValidating,he.error=V.error,he):(he=V,V)},()=>Y]},[n,j]),A=ji.useSyncExternalStore(a.useCallback(Q=>R(j,(q,K)=>{M(K,q)||Q()}),[n,j]),L[0],L[1]),P=!b.current,N=v[j]&&v[j].length>0,W=A.data,H=Se(W)?D&&Cl(D)?Nn(D):D:W,oe=A.error,Z=a.useRef(H),we=m?Se(W)?Se(Z.current)?H:Z.current:W:H,pe=j&&Se(H),ee=!Dr&&ji.useSyncExternalStore(()=>At,()=>!1,()=>!0);x&&ee&&!s&&pe&&console.warn(`Missing pre-initiated data for serialized key "${j}" during server-side rendering. Data fethcing should be initiated on the server and provided to SWR via fallback data. You can set "strictServerPrefetchWarning: false" to disable this warning.`);const me=N&&!Se(oe)?!1:P&&!Se(u)?u:y().isPaused()?!1:s?Se(H)?!1:l:Se(H)||l,re=!!(j&&r&&P&&me),Re=Se(A.isValidating)?re:A.isValidating,te=Se(A.isLoading)?re:A.isLoading,ae=a.useCallback(async Q=>{const q=f.current;if(!j||!q||w.current||y().isPaused())return!1;let K,ue,xe=!0;const Y=Q||{},he=!E[j]||!Y.dedupe,V=()=>Ds?!w.current&&j===_.current&&b.current:j===_.current,be={isValidating:!1,isLoading:!1},Je=()=>{O(be)},dt=()=>{const ce=E[j];ce&&ce[1]===ue&&delete E[j]},G={isValidating:!0};Se(I().data)&&(G.isLoading=!0);try{if(he&&(O(G),o.loadingTimeout&&Se(I().data)&&setTimeout(()=>{xe&&V()&&y().onLoadingSlow(j,o)},o.loadingTimeout),E[j]=[q(z),Pi()]),[K,ue]=E[j],K=await K,he&&setTimeout(dt,o.dedupingInterval),!E[j]||E[j][1]!==ue)return he&&V()&&y().onDiscarded(j),!1;be.error=Qe;const ce=S[j];if(!Se(ce)&&(ue<=ce[0]||ue<=ce[1]||ce[1]===0))return Je(),he&&V()&&y().onDiscarded(j),!1;const De=I().data;be.data=i(De,K)?De:K,he&&V()&&y().onSuccess(K,j,o)}catch(ce){dt();const De=y(),{shouldRetryOnError:et}=De;De.isPaused()||(be.error=ce,he&&V()&&(De.onError(ce,j,De),(et===!0||ft(et)&&et(ce))&&(!y().revalidateOnFocus||!y().revalidateOnReconnect||$())&&De.onErrorRetry(ce,j,De,ot=>{const Xe=v[j];Xe&&Xe[0]&&Xe[0](Ls,ot)},{retryCount:(Y.retryCount||0)+1,dedupe:!0})))}return xe=!1,Je(),!0},[j,n]),ye=a.useCallback((...Q)=>Sl(n,_.current,...Q),[]);if(Xo(()=>{f.current=r,C.current=o,Se(W)||(Z.current=W)}),Xo(()=>{if(!j)return;const Q=ae.bind(Qe,Un);let q=0;y().revalidateOnFocus&&(q=Date.now()+y().focusThrottleInterval);const ue=ap(j,v,(xe,Y={})=>{if(xe==jl){const he=Date.now();y().revalidateOnFocus&&he>q&&$()&&(q=he+y().focusThrottleInterval,Q())}else if(xe==_l)y().revalidateOnReconnect&&$()&&Q();else{if(xe==kl)return ae();if(xe==Ls)return ae(Y)}});return w.current=!1,_.current=j,b.current=!0,O({_k:z}),me&&(E[j]||(Se(H)||Dr?Q():Hu(Q))),()=>{w.current=!0,ue()}},[j]),Xo(()=>{let Q;function q(){const ue=ft(h)?h(I().data):h;ue&&Q!==-1&&(Q=setTimeout(K,ue))}function K(){!I().error&&(c||y().isVisible())&&(g||y().isOnline())?ae(Un).then(q):q()}return q(),()=>{Q&&(clearTimeout(Q),Q=-1)}},[h,c,g,j]),a.useDebugValue(we),s){if(!Ds&&Dr&&pe)throw new Error("Fallback data is required when using Suspense in SSR.");pe&&(f.current=r,C.current=o,w.current=!1);const Q=k[j],q=!Se(Q)&&pe?ye(Q):Us;if(Nn(q),!Se(oe)&&pe)throw oe;const K=pe?ae(Un):Us;!Se(we)&&pe&&(K.status="fulfilled",K.value=!0),Nn(K)}return{mutate:ye,get data(){return F.data=!0,we},get error(){return F.error=!0,oe},get isValidating(){return F.isValidating=!0,Re},get isLoading(){return F.isLoading=!0,te}}},We=sp(lp),it=()=>{const{adapter:t,deployment:r}=je(),o=t.useNavigate(),n=(l,h)=>{o?o(l,h):window.location.href=l},i=l=>{if(l)return l;const c=new URLSearchParams(window.location.search).get("redirect_uri");return c||window.location.href};return{navigate:n,navigateToSignIn:l=>{if(!r)return;const h=i(l),c=new URLSearchParams;c.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&c.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${c.toString()}`,{replace:!0})},navigateToAccountSelection:l=>{if(!r)return;const h=i(l),c=new URLSearchParams;c.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&c.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${c.toString()}`,{replace:!0})},navigateToSignUp:l=>{if(!r)return;const h=i(l),c=new URLSearchParams;c.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&c.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${c.toString()}`,{replace:!0})}}};async function dp(t){const r=await t("/session",{method:"GET"});return(await U(r)).data}async function up(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return U(o)}async function pp(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return U(n)}async function hp(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return U(o)}async function fp(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return U(o)}async function gp(t,r){const o=await t(`/session/ticket/exchange?ticket=${encodeURIComponent(r)}`,{method:"GET"});return U(o)}const Ri=new Map,ao=new Map;function jt(){Ri.clear(),ao.clear()}async function mp(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return U(o)}function Be(){const{client:t,loading:r}=Ve(),{deployment:o}=je(),{navigate:n}=it(),{cache:i}=Pl(),{data:s,error:d,mutate:u,isLoading:l}=We(r?null:"/session",()=>dp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=a.useCallback(async()=>{await u(void 0,{revalidate:!0})},[u]),c=a.useCallback(async(g="default")=>{if(!s)throw new Error("no session");const m=Ri.get(g);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";ao.get(g)||ao.set(g,mp(t,g));const x=await ao.get(g);return ao.delete(g),Ri.set(g,x.data),x.data.token},[t,s==null?void 0:s.active_signin]);return r||!s||l?{loading:!0,error:d,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,exchangeTicket:null,signOut:null,getToken:null,refetch:h}:{loading:l,error:d,session:s,switchSignIn:async g=>{await up(t,g),jt(),await so("/me/organization-memberships",void 0,{revalidate:!1}),await so("/me/workspace-memberships",void 0,{revalidate:!1}),await u(void 0,{revalidate:!0}),await so("/me/organization-memberships"),await so("/me/workspace-memberships")},signOut:async g=>{await pp(t,g);const m=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:scope-unread"],x=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(i instanceof Map){const v=Array.from(i.keys());for(const S of v){let E=!1;(m.includes(S)||typeof S=="string"&&x.some(k=>S.startsWith(k)))&&(E=!0),E&&i.delete(S)}}jt(),await u(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(g&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!g&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async g=>{await hp(t,g),jt(),await u(void 0,{revalidate:!0})},switchWorkspace:async g=>{await fp(t,g),jt(),await u(void 0,{revalidate:!0})},exchangeTicket:async g=>{await gp(t,g),jt(),await u(void 0,{revalidate:!0})},getToken:c,refetch:h}}const kt=()=>{const{organizationMemberships:t,refetch:r,loading:o}=Ft(),{client:n}=Ve(),{refetch:i}=Be(),s=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/roles`,{method:"GET"}))).data,[n]),d=a.useCallback(async(L,A)=>{const P=new URLSearchParams;return A&&(P.set("page",A.page.toString()),P.set("limit",A.limit.toString()),A.search&&P.set("search",A.search)),(await U(await n(`/organizations/${L.id}/members?${P.toString()}`,{method:"GET"}))).data},[n]),u=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/invitations`,{method:"GET"}))).data,[n]),l=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/domains`,{method:"GET"}))).data,[n]),h=a.useCallback(async(L,A)=>{await n(`/organizations/${L.id}/members/${A.id}/remove`,{method:"POST"})},[n]),c=a.useCallback(async L=>{const A=new FormData;A.append("name",L.name),L.image&&A.append("image",L.image),L.description&&A.append("description",L.description);const P=await U(await n("/organizations",{method:"POST",body:A}));return jt(),await r(),await i(),P},[i,r,n]),g=a.useCallback(async(L,A)=>{const P=Object.entries(A).reduce((W,[H,oe])=>(oe!=null&&(Array.isArray(oe)?oe.forEach(Z=>W.append(H,Z)):W.append(H,oe)),W),new FormData),N=await U(await n(`/organizations/${L.id}/update`,{method:"POST",body:P}));return await r(),N},[r,n]),m=a.useCallback(async(L,A)=>{await n(`/organizations/${L.id}/roles/${A.id}/remove`,{method:"POST"})},[n]),x=a.useCallback(async(L,A)=>{const P=new FormData;return P.append("domain",A.fqdn),await U(await n(`/organizations/${L.id}/domains`,{method:"POST",body:P}))},[n]),v=a.useCallback(async(L,A)=>await U(await n(`/organizations/${L.id}/domains/${A.id}/verify`,{method:"POST"})),[n]),S=a.useCallback(async(L,A)=>await U(await n(`/organizations/${L.id}/domains/${A.id}/delete`,{method:"POST"})),[n]),E=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/enterprise-connections`,{method:"GET"}))).data,[n]),k=a.useCallback(async(L,A)=>{const P=new FormData;return P.append("protocol",A.protocol),A.domain_id&&P.append("domain_id",A.domain_id),A.idp_entity_id&&P.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&P.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&P.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&P.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&P.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&P.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&P.append("oidc_scopes",A.oidc_scopes),A.jit_enabled!==void 0&&P.append("jit_enabled",String(A.jit_enabled)),A.attribute_mapping&&P.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await U(await n(`/organizations/${L.id}/enterprise-connections`,{method:"POST",body:P}))).data},[n]),j=a.useCallback(async(L,A,P)=>{const N=new FormData;return P.domain_id&&N.append("domain_id",P.domain_id),P.idp_entity_id&&N.append("idp_entity_id",P.idp_entity_id),P.idp_sso_url&&N.append("idp_sso_url",P.idp_sso_url),P.idp_certificate&&N.append("idp_certificate",P.idp_certificate),P.oidc_client_id&&N.append("oidc_client_id",P.oidc_client_id),P.oidc_client_secret&&N.append("oidc_client_secret",P.oidc_client_secret),P.oidc_issuer_url&&N.append("oidc_issuer_url",P.oidc_issuer_url),P.oidc_scopes&&N.append("oidc_scopes",P.oidc_scopes),P.attribute_mapping&&N.append("attribute_mapping",JSON.stringify(P.attribute_mapping)),(await U(await n(`/organizations/${L.id}/enterprise-connections/${A}/update`,{method:"POST",body:N}))).data},[n]),z=a.useCallback(async(L,A)=>{await n(`/organizations/${L.id}/enterprise-connections/${A}/delete`,{method:"POST"})},[n]),b=a.useCallback(async(L,A)=>{const P=new FormData;return P.append("protocol",A.protocol),A.idp_entity_id&&P.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&P.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&P.append("idp_certificate",A.idp_certificate),A.oidc_issuer_url&&P.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_client_id&&P.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&P.append("oidc_client_secret",A.oidc_client_secret),(await U(await n(`/organizations/${L.id}/enterprise-connections/test`,{method:"POST",body:P}))).data},[n]),w=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/enterprise-connections/${A}/test`,{method:"POST"}))).data,[n]),_=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/enterprise-connections/${A}/scim/token`,{method:"POST"}))).data,[n]),f=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/enterprise-connections/${A}/scim/token`,{method:"GET"}))).data,[n]),C=a.useCallback(async(L,A)=>{await n(`/organizations/${L.id}/enterprise-connections/${A}/scim/token/revoke`,{method:"POST"})},[n]),y=a.useCallback(async(L,A)=>{const P=new FormData;return P.append("name",A.name),A.permissions&&A.permissions.forEach((W,H)=>{P.append(`permissions[${H}]`,W)}),await U(await n(`/organizations/${L.id}/roles`,{method:"POST",body:P}))},[n]),$=a.useCallback(async L=>(await U(await n(`/organizations/${L.id}/leave`,{method:"POST"}))).data,[n]),I=a.useCallback(async L=>{const A=await U(await n(`/organizations/${L.id}/delete`,{method:"POST"}));return jt(),await r(),await i(),A.data},[n,r,i]),O=a.useCallback(async(L,A,P)=>(await U(await n(`/organizations/${L.id}/members/${A.id}/roles/${P.id}/add`,{method:"POST"}))).data,[n]),R=a.useCallback(async(L,A,P)=>(await U(await n(`/organizations/${L.id}/members/${A.id}/roles/${P.id}/remove`,{method:"POST"}))).data,[n]),T=a.useCallback(async(L,A)=>{var W,H;const P=new FormData;return P.append("email",A.email),P.append("role_id",A.organizationRole.id),(W=A.workspace)!=null&&W.id&&P.append("workspace_id",A.workspace.id),(H=A.workspaceRole)!=null&&H.id&&P.append("workspace_role_id",A.workspaceRole.id),(await U(await n(`/organizations/${L.id}/invitations`,{method:"POST",body:P}))).data},[n]),F=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/invitations/${A.id}/discard`,{method:"POST"}))).data,[n]),D=a.useCallback(async(L,A)=>(await U(await n(`/organizations/${L.id}/invitations/${A.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:a.useMemo(()=>t==null?void 0:t.map(L=>L.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:$,getOrganizationRoles:s,getOrganizationMembers:d,removeOrganizationMember:h,createOrganization:c,getOrganizationInvitations:u,getOrganizationDomains:l,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:S,addRoleToOrganizationMember:O,removeRoleFromOrganizationMember:R,inviteOrganizationMember:T,discardOrganizationInvitation:F,resendOrganizationInvitation:D,updateOrganization:g,addRole:y,removeOrganizationRoles:m,deleteOrganization:I,getEnterpriseConnections:E,createEnterpriseConnection:k,updateEnterpriseConnection:j,deleteEnterpriseConnection:z,testEnterpriseConnectionConfig:b,testEnterpriseConnection:w,generateSCIMToken:_,getSCIMToken:f,revokeSCIMToken:C}},Cr=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:i,leaveOrganization:s,removeOrganizationMember:d,getOrganizationInvitations:u,getOrganizationDomains:l,removeOrganizationDomain:h,addOrganizationDomain:c,verifyOrganizationDomain:g,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:S,resendOrganizationInvitation:E,updateOrganization:k,removeOrganizationRoles:j,getEnterpriseConnections:z,createEnterpriseConnection:b,updateEnterpriseConnection:w,deleteEnterpriseConnection:_,testEnterpriseConnectionConfig:f,testEnterpriseConnection:C,generateSCIMToken:y,getSCIMToken:$,revokeSCIMToken:I}=kt(),{session:O,error:R,loading:T}=Be(),{organizationMemberships:F}=Ft(),D=a.useMemo(()=>(F==null?void 0:F.find(V=>{var be;return V.id===((be=O==null?void 0:O.active_signin)==null?void 0:be.active_organization_membership_id)}))||null,[F,O]),M=a.useMemo(()=>(D==null?void 0:D.organization)||null,[D]),L=a.useCallback(async V=>M?await k(M,V):[],[M,k]),A=a.useCallback(async()=>M?await n(M):[],[M,n]),P=a.useCallback(async()=>M?await i(M):[],[M,i]),N=a.useCallback(async V=>M?await d(M,V):[],[M,d]),W=a.useCallback(async V=>M?await j(M,V):void 0,[M,j]),H=a.useCallback(async()=>M?await l(M):[],[M,l]),oe=a.useCallback(async V=>M?await c(M,V):void 0,[M,c]),Z=a.useCallback(async V=>M?await g(M,V):void 0,[M,g]),we=a.useCallback(async V=>M?await h(M,V):void 0,[M,h]),pe=a.useCallback(async(V,be)=>M?await m(M,V,be):void 0,[M,m]),ee=a.useCallback(async(V,be)=>M?await x(M,V,be):void 0,[M,x]),me=a.useCallback(async V=>M?await v(M,V):void 0,[M,v]),re=a.useCallback(async V=>M?await S(M,V):void 0,[M,S]),Re=a.useCallback(async V=>M?await E(M,V):void 0,[M,E]),te=a.useCallback(async()=>{M&&await s(M)},[M,s]),ae=a.useCallback(async()=>M?await u(M):[],[M,u]),ye=a.useCallback(async()=>M?await z(M):[],[M,z]),ge=a.useCallback(async V=>{if(M)return await b(M,V)},[M,b]),Q=a.useCallback(async(V,be)=>{if(M)return await w(M,V,be)},[M,w]),q=a.useCallback(async V=>{M&&await _(M,V)},[M,_]),K=a.useCallback(async V=>M?await f(M,V):null,[M,f]),ue=a.useCallback(async V=>M?await C(M,V):null,[M,C]),xe=a.useCallback(async V=>{if(M)return await y(M,V)},[M,y]),Y=a.useCallback(async V=>{if(M)return await $(M,V)},[M,$]),he=a.useCallback(async V=>{M&&await I(M,V)},[M,I]);return T||t?{activeOrganization:null,activeMembership:null,loading:!0,error:R||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:M,activeMembership:D,loading:!1,refetch:o,getRoles:P,updateOrganization:L,getMembers:A,getDomains:H,addDomain:oe,verifyDomain:Z,removeDomain:we,getInvitations:ae,removeMember:N,leave:te,removeRole:W,addMemberRole:pe,removeMemberRole:ee,inviteMember:me,discardInvitation:re,resendInvitation:Re,getEnterpriseConnections:ye,createEnterpriseConnection:ge,updateEnterpriseConnection:Q,deleteEnterpriseConnection:q,testEnterpriseConnectionConfig:K,testEnterpriseConnection:ue,generateSCIMToken:xe,getSCIMToken:Y,revokeSCIMToken:he,error:null}};async function xp(t){return(await U(await t("/me/organization-memberships"))).data}const Ft=()=>{const{client:t,loading:r}=Ve(),{data:o,isLoading:n,error:i,mutate:s}=We(r?null:"/me/organization-memberships",()=>xp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),d=a.useCallback(async()=>{await s()},[s]);return{organizationMemberships:o,loading:r||n,error:i,refetch:d}};async function vp(t){return(await U(await t("/me/workspace-memberships"))).data}async function yp(t,r,o){return(await U(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const vn=()=>{const{client:t,loading:r}=Ve(),{deployment:o}=je(),{data:n,isLoading:i,error:s,mutate:d}=We(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>vp(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),u=a.useCallback(async()=>{await d(void 0,{revalidate:!0})},[d]);return{workspaceMemberships:n,loading:r||i,error:s,refetch:u}},Qt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=vn(),{client:i}=Ve(),s=a.useMemo(()=>t==null?void 0:t.map(w=>({...w.workspace,organization:w.organization,eligibility_restriction:w.eligibility_restriction})),[t]),d=a.useCallback(async(w,_,f,C)=>{const y=new FormData;y.append("name",_),f&&y.append("image",f),C&&y.append("description",C),y.append("organization_id",w);const $=await U(await i("/workspaces",{method:"POST",body:y}));return jt(),await r(),$.data},[i,r]),u=a.useCallback(async(w,_)=>{const f=await yp(i,w,_);return await r(),f},[i,r]),l=a.useCallback(async(w,_)=>{const f=new FormData;_.name&&f.append("name",_.name),_.description&&f.append("description",_.description),_.image&&f.append("image",_.image),_.enforce_2fa!==void 0&&f.append("enforce_2fa",String(_.enforce_2fa)),_.enable_ip_restriction!==void 0&&f.append("enable_ip_restriction",String(_.enable_ip_restriction)),_.whitelisted_ips&&_.whitelisted_ips.forEach(y=>f.append("whitelisted_ips",y));const C=await U(await i(`/workspaces/${w.id}/update`,{method:"POST",body:f}));return await r(),C.data},[i,r]),h=a.useCallback(async w=>{const _=await U(await i(`/workspaces/${w.id}/delete`,{method:"POST"}));return jt(),await r(),_.data},[i,r]),c=a.useCallback(async(w,_)=>{const f=new URLSearchParams;return _&&(f.set("page",_.page.toString()),f.set("limit",_.limit.toString()),_.search&&f.set("search",_.search)),(await U(await i(`/workspaces/${w.id}/members?${f.toString()}`,{method:"GET"}))).data},[i]),g=a.useCallback(async w=>(await U(await i(`/workspaces/${w.id}/roles`,{method:"GET"}))).data,[i]),m=a.useCallback(async(w,_,f)=>{const C=new FormData;return C.append("name",_),f.forEach($=>C.append("permissions",$)),(await U(await i(`/workspaces/${w.id}/roles`,{method:"POST",body:C}))).data},[i]),x=a.useCallback(async(w,_)=>(await U(await i(`/workspaces/${w.id}/roles/${_.id}/delete`,{method:"POST"}))).data,[i]),v=a.useCallback(async(w,_)=>{const f=await U(await i(`/workspaces/${w.id}/members/${_}/remove`,{method:"POST"}));return await r(),f.data},[i,r]),S=a.useCallback(async(w,_,f)=>(await U(await i(`/workspaces/${w.id}/members/${_}/roles/${f}/add`,{method:"POST"}))).data,[i]),E=a.useCallback(async(w,_,f)=>(await U(await i(`/workspaces/${w.id}/members/${_}/roles/${f}/remove`,{method:"POST"}))).data,[i]),k=a.useCallback(async w=>(await U(await i(`/organizations/${w.organization.id}/invitations?workspace_id=${w.id}`,{method:"GET"}))).data,[i]),j=a.useCallback(async(w,_,f)=>{const C=new FormData;return C.append("email",_),C.append("workspace_id",w.id),f&&C.append("workspace_role_id",f),(await U(await i(`/organizations/${w.organization.id}/invitations`,{method:"POST",body:C}))).data},[i]),z=a.useCallback(async(w,_)=>(await U(await i(`/organizations/${w.organization.id}/invitations/${_}/discard`,{method:"POST"}))).data,[i]),b=a.useCallback(async(w,_)=>(await U(await i(`/organizations/${w.organization.id}/invitations/${_}/resend`,{method:"POST"}))).data,[i]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:u,createWorkspace:d,updateWorkspace:l,deleteWorkspace:h,getWorkspaceMembers:c,getWorkspaceRoles:g,createWorkspaceRole:m,deleteWorkspaceRole:x,removeWorkspaceMember:v,addWorkspaceMemberRole:S,removeWorkspaceMemberRole:E,getWorkspaceInvitations:k,createWorkspaceInvitation:j,discardWorkspaceInvitation:z,resendWorkspaceInvitation:b}},Nt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:i,updateWorkspace:s,deleteWorkspace:d,getWorkspaceMembers:u,getWorkspaceRoles:l,createWorkspaceRole:h,deleteWorkspaceRole:c,removeWorkspaceMember:g,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x,getWorkspaceInvitations:v,createWorkspaceInvitation:S,discardWorkspaceInvitation:E,resendWorkspaceInvitation:k}=Qt(),{workspaceMemberships:j}=vn(),{session:z,loading:b,error:w}=Be(),_=a.useMemo(()=>(j==null?void 0:j.find(Z=>{var we;return Z.id===((we=z==null?void 0:z.active_signin)==null?void 0:we.active_workspace_membership_id)}))||null,[j,z]),f=a.useMemo(()=>(_==null?void 0:_.workspace)||null,[_]),C=a.useCallback(async()=>{var Z;if(!(!f||!((Z=z==null?void 0:z.active_signin)!=null&&Z.user_id)))return await i(f.id,z.active_signin.user_id)},[f,i,z]),y=a.useCallback(async Z=>{if(f)return await s(f,Z)},[f,s]),$=a.useCallback(async()=>{if(f)return await d(f)},[f,d]),I=a.useCallback(async Z=>f?await u(f,Z):{data:[],meta:{total:0,page:1,limit:10}},[f,u]),O=a.useCallback(async()=>f?await l(f):[],[f,l]),R=a.useCallback(async(Z,we)=>{if(f)return await h(f,Z,we)},[f,h]),T=a.useCallback(async Z=>{if(f)return await c(f,Z)},[f,c]),F=a.useCallback(async Z=>{if(f)return await g(f,Z)},[f,g]),D=a.useCallback(async(Z,we)=>{if(f)return await m(f,Z,we)},[f,m]),M=a.useCallback(async(Z,we)=>{if(f)return await x(f,Z,we)},[f,x]),L=a.useMemo(()=>(n==null?void 0:n.find(Z=>Z.id===(f==null?void 0:f.id)))||null,[n,f]),A=a.useCallback(async()=>L?await v(L):[],[L,v]),P=a.useCallback(async(Z,we)=>{if(L)return await S(L,Z,we)},[L,S]),N=a.useCallback(async Z=>{if(L)return await E(L,Z)},[L,E]),W=a.useCallback(async Z=>{if(L)return await k(L,Z)},[L,k]),H=r||b,oe=o||w;return H?{activeWorkspace:null,activeMembership:null,loading:!0,error:oe,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:_,loading:!1,error:oe,refetch:t,leave:C,updateWorkspace:y,deleteWorkspace:$,getMembers:I,getRoles:O,createRole:R,deleteRole:T,inviteMember:P,removeMember:F,addMemberRole:D,removeMemberRole:M,getInvitations:A,discardInvitation:N,resendInvitation:W}};function Bn(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Wn(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),i=new Uint8Array(n.length);for(let s=0;s<n.length;s++)i[s]=n.charCodeAt(s);return i.buffer}const bp=async t=>(await U(await t("/me"))).data,wp=async t=>(await U(await t("/me/signins"))).data;function Kt(){const{client:t,loading:r}=Ve(),{data:o,error:n,isLoading:i,mutate:s}=We(r?null:"/user",()=>bp(t)),d=async L=>{const A=new FormData;for(const[N,W]of Object.entries(L))W!=null&&W!==""&&A.append(N,String(W));const P=await U(await t("/me",{method:"POST",body:A}));return s(),P},u=async()=>await U(await t("/me/email-addresses",{method:"GET"})),l=async L=>await U(await t(`/me/email-addresses/${L}`,{method:"GET"})),h=async L=>{const A=new FormData;return A.append("email",L),await U(await t("/me/email-addresses",{method:"POST",body:A}))},c=async L=>await U(await t(`/me/email-addresses/${L}/delete`,{method:"POST"})),g=async L=>await U(await t(`/me/email-addresses/${L}/prepare-verification`,{method:"POST"})),m=async(L,A)=>await U(await t(`/me/email-addresses/${L}/attempt-verification?code=${A}`,{method:"POST"})),x=async(L,A)=>{const P=new FormData;return P.append("phone_number",L),P.append("country_code",A),await U(await t("/me/phone-numbers",{method:"POST",body:P}))},v=async L=>await U(await t(`/me/phone-numbers/${L}/delete`,{method:"POST"})),S=async L=>await U(await t(`/me/phone-numbers/${L}/prepare-verification`,{method:"POST"})),E=async(L,A)=>{const P=new FormData;return P.append("code",A),await U(await t(`/me/phone-numbers/${L}/attempt-verification`,{method:"POST",body:P}))},k=async L=>{const A=await U(await t(`/me/phone-numbers/${L}/make-primary`,{method:"POST"}));return s(),A},j=async L=>await U(await t(`/me/email-addresses/${L}/make-primary`,{method:"POST"})),z=async()=>(await U(await t("/me/authenticator",{method:"POST"}))).data,b=async(L,A)=>{const P=new FormData;return P.append("authenticator_id",L),A.forEach(W=>{P.append("codes",W)}),await U(await t("/me/authenticator/attempt-verification",{method:"POST",body:P}))},w=async L=>await U(await t(`/me/authenticator/${L}/delete`,{method:"POST"})),_=async()=>(await U(await t("/me/backup-codes",{method:"POST"}))).data,f=async L=>{const A=new FormData;return A.append("file",L),await U(await t("/me/profile-picture",{method:"POST",body:A}))},C=async()=>(await U(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,y=async(L,A)=>{const P=new FormData;return P.append("current_password",L),P.append("new_password",A),await U(await t("/me/update-password",{method:"POST",body:P}))},$=async L=>{const A=new FormData;A.append("current_password",L);const P=await U(await t("/me/remove-password",{method:"POST",body:A}));return s(),P},I=async L=>{const A=new FormData;return A.append("password",L),await U(await t("/me/account/delete",{method:"POST",body:A}))},O=async L=>await U(await t(`/me/social-connections/${L}/disconnect`,{method:"POST"})),R=async({provider:L,redirectUri:A})=>{var W;const P=new URLSearchParams({provider:L});A&&P.append("redirect_uri",A);const N=await U(await t(`/me/init-sso-connection?${P.toString()}`,{method:"POST"}));return"data"in N&&((W=N.data)!=null&&W.oauth_url)&&window.open(N.data.oauth_url,"_blank"),N},T=async()=>await U(await t("/me/passkeys",{method:"GET"})),F=async L=>{var we,pe;const A=await U(await t("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in A))return A;const P=A.data.options.publicKey,N={challenge:Wn(P.challenge),rp:P.rp,user:{id:Wn(P.user.id),name:P.user.name,displayName:P.user.displayName},pubKeyCredParams:P.pubKeyCredParams,timeout:P.timeout,attestation:P.attestation,authenticatorSelection:P.authenticatorSelection,excludeCredentials:(we=P.excludeCredentials)==null?void 0:we.map(ee=>({type:ee.type,id:Wn(ee.id),transports:ee.transports}))},W=await navigator.credentials.create({publicKey:N});if(!W)throw new Error("Failed to create credential");const H=W.response,oe={id:W.id,rawId:Bn(W.rawId),type:W.type,response:{clientDataJSON:Bn(H.clientDataJSON),attestationObject:Bn(H.attestationObject),transports:((pe=H.getTransports)==null?void 0:pe.call(H))||[]}};return await U(await t(`/me/passkeys/register/finish?name=${encodeURIComponent(L||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(oe)}))},D=async L=>await U(await t(`/me/passkeys/${L}/delete`,{method:"POST"})),M=async(L,A)=>await U(await t(`/me/passkeys/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:A})}));return{user:{...o,refetch:s},loading:r||i,error:n||null,updateProfile:d,getEmailAddresses:u,getEmailAddress:l,createEmailAddress:h,deleteEmailAddress:c,prepareEmailVerification:g,attemptEmailVerification:m,makeEmailPrimary:j,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:S,attemptPhoneVerification:E,makePhonePrimary:k,setupAuthenticator:z,verifyAuthenticator:b,deleteAuthenticator:w,generateBackupCodes:_,regenerateBackupCodes:C,updateProfilePicture:f,disconnectSocialConnection:O,connectSocialAccount:R,updatePassword:y,removePassword:$,deleteAccount:I,getPasskeys:T,registerPasskey:F,deletePasskey:D,renamePasskey:M}}function Rl(){const{client:t,loading:r}=Ve(),{data:o,error:n,isLoading:i,mutate:s}=We(r?null:"/me/signins",()=>wp(t));return{signins:o,error:n||null,removeSignin:async u=>await U(await t(`/me/signins/${u}/signout`,{method:"POST"})),refetch:s,loading:i||r}}function jp(){const{session:t,loading:r}=Be(),{loading:o,organizationMemberships:n}=Ft(),{loading:i,workspaceMemberships:s}=vn();if(r||o||i)return{loading:!0,orgMembership:null,workspaceMembership:null};const d=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(l=>{var h;return l.id===((h=t.active_signin)==null?void 0:h.active_organization_membership_id)}),[t]),u=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(l=>{var h;return l.id===((h=t.active_signin)==null?void 0:h.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:d,workspaceMembership:u}}function Il(){const{client:t,loading:r}=Ve(),[o,n]=a.useState(!1),i=async s=>{n(!0);try{const d=new FormData;for(const[h,c]of Object.entries(s))c&&d.append(h,c);const u=await t("/waitlist/join",{method:"POST",body:d});return await U(u)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:i}}function Tl(){const{client:t,loading:r}=Ve(),[o,n]=a.useState(!1),[i,s]=a.useState(null),[d,u]=a.useState(null),[l,h]=a.useState(null),[c,g]=a.useState(!1),[m,x]=a.useState(null);a.useEffect(()=>{if(c||r)return;const S=new URLSearchParams(window.location.search),E=S.get("code"),k=S.get("state"),j=S.get("error"),z=S.get("error_description");if(!E&&!j){g(!0);const b=new Error("No OAuth callback data found.");s(b);return}if(g(!0),n(!0),j){const b=z||j,w=new Error(`OAuth Error: ${b}`);s(w),n(!1);return}if(E&&k)v(E,k);else{const b=new Error("Missing required OAuth parameters");s(b),n(!1)}},[c,r]);const v=async(S,E)=>{try{let k,j;try{const w=E.split(".");if(w.length!==2)throw new Error("Invalid OAuth state format - missing signature");const _=w[0].replace(/-/g,"+").replace(/_/g,"/"),f=_.length%4?"=".repeat(4-_.length%4):"",y=atob(_+f).split("|")[0];if(y==="sign_in")k="/auth/oauth2/callback",j="GET";else if(y==="connect_social")k="/me/sso-connection-callback",j="POST";else throw new Error(`Unknown OAuth action: ${y}`)}catch(w){const _=w instanceof Error?w:new Error("Failed to parse OAuth state");s(new Error(`Invalid OAuth callback: ${_.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const z=await t(`${k}?code=${encodeURIComponent(S)}&state=${encodeURIComponent(E)}`,{method:j}),b=await U(z);if("data"in b){const w=b.data.session,_=b.data.redirect_uri||null;if(u(w),h(_),w.signin_attempts&&w.signin_attempts.length>0){const f=w.signin_attempts.at(-1);f&&x(f)}}else{const w=new Error("SSO callback failed");s(w)}}catch(k){const j=k instanceof Error?k:new Error("Unknown error occurred");s(j)}finally{n(!1)}};return{loading:o,error:i,session:d,redirectUri:l,processed:c,signinAttempt:m}}function Ol(){const{client:t,loading:r}=Ve(),[o,n]=a.useState(!1),[i,s]=a.useState(null);return{loading:r||o,verifyMagicLink:async u=>{if(!u.token||!u.attempt)throw new Error("Invalid magic link parameters");n(!0),s(null);try{const l=new URL("/auth/verify-magic-link",window.location.origin);l.searchParams.set("token",u.token),l.searchParams.set("attempt",u.attempt),u.redirectUri&&l.searchParams.set("redirect_uri",u.redirectUri);const h=await t(l.pathname+l.search,{method:"GET"}),c=await U(h);return n(!1),s(!0),c}catch(l){throw n(!1),s(!1),l}},success:i}}function Al(){const[t,r]=a.useState({});return a.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 Ll(){const{client:t,loading:r}=Ve();return{loading:r,forgotPassword:async s=>{const d=new FormData;d.append("email",s);const u=await t("/auth/forgot-password",{method:"POST",body:d});return await U(u)},verifyOtp:async(s,d)=>{const u=new FormData;u.append("email",s),u.append("otp",d);const l=await t("/auth/forgot-password",{method:"POST",body:u});return await U(l)},resetPassword:async(s,d)=>{const u=new FormData;u.append("token",s),u.append("password",d);const l=await t("/auth/reset-password",{method:"POST",body:u});return await U(l)}}}const _p=()=>{},kp=_p(),Ii=Object,Bs=t=>t===kp,Cp=t=>typeof t=="function",jo=new WeakMap,Sp=t=>Ii.prototype.toString.call(t),Vn=(t,r)=>t===`[object ${r}]`;let $p=0;const Ti=t=>{const r=typeof t,o=Sp(t),n=Vn(o,"Date"),i=Vn(o,"RegExp"),s=Vn(o,"Object");let d,u;if(Ii(t)===t&&!n&&!i){if(d=jo.get(t),d)return d;if(d=++$p+"~",jo.set(t,d),Array.isArray(t)){for(d="@",u=0;u<t.length;u++)d+=Ti(t[u])+",";jo.set(t,d)}if(s){d="#";const l=Ii.keys(t).sort();for(;!Bs(u=l.pop());)Bs(t[u])||(d+=u+":"+Ti(t[u])+",");jo.set(t,d)}}else d=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return d},zp=t=>{if(Cp(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Ti(t):"",[t,r]},Ep=t=>zp(t?t(0,null):null)[0],Gn=Promise.resolve(),Pp=t=>(r,o,n)=>{const i=a.useRef(!1),{cache:s,initialSize:d=1,revalidateAll:u=!1,persistSize:l=!1,revalidateFirstPage:h=!0,revalidateOnMount:c=!1,parallel:g=!1}=n,[,,,m]=wt.get(Xi);let x;try{x=Ep(r),x&&(x=$l+x)}catch{}const[v,S,E]=Wt(s,x),k=a.useCallback(()=>Se(v()._l)?d:v()._l,[s,x,d]);ji.useSyncExternalStore(a.useCallback(C=>x?E(x,()=>{C()}):()=>{},[s,x]),k,k);const j=a.useCallback(()=>{const C=v()._l;return Se(C)?d:C},[x,d]),z=a.useRef(j());Xo(()=>{if(!i.current){i.current=!0;return}x&&S({_l:l?z.current:j()})},[x,s]);const b=c&&!i.current,w=t(x,async C=>{const y=v()._i,$=v()._r;S({_r:Qe});const I=[],O=j(),[R]=Wt(s,C),T=R().data,F=[];let D=null;for(let M=0;M<O;++M){const[L,A]=fo(r(M,g?null:D));if(!L)break;const[P,N]=Wt(s,L);let W=P().data;const H=u||y||Se(W)||h&&!M&&!Se(T)||b||T&&!Se(T[M])&&!n.compare(T[M],W);if(o&&(typeof $=="function"?$(W,A):H)){const oe=async()=>{if(!(L in m))W=await o(A);else{const we=m[L];delete m[L],W=await we}N({data:W,_k:A}),I[M]=W};g?F.push(oe):await oe()}else I[M]=W;g||(D=W)}return g&&await Promise.all(F.map(M=>M())),S({_i:Qe}),I},n),_=a.useCallback(function(C,y){const $=typeof y=="boolean"?{revalidate:y}:y||{},I=$.revalidate!==!1;return x?(I&&(Se(C)?S({_i:!0,_r:$.revalidate}):S({_i:!1,_r:$.revalidate})),arguments.length?w.mutate(C,{...$,revalidate:I}):w.mutate()):Gn},[x,s]),f=a.useCallback(C=>{if(!x)return Gn;const[,y]=Wt(s,x);let $;if(ft(C)?$=C(j()):typeof C=="number"&&($=C),typeof $!="number")return Gn;y({_l:$}),z.current=$;const I=[],[O]=Wt(s,x);let R=null;for(let T=0;T<$;++T){const[F]=fo(r(T,R)),[D]=Wt(s,F),M=F?D().data:Qe;if(Se(M))return _(O().data);I.push(M),R=M}return _(I)},[x,s,_,j]);return{size:j(),setSize:f,mutate:_,get data(){return w.data},get error(){return w.error},get isValidating(){return w.isValidating},get isLoading(){return w.isLoading}}},Rp=cp(We,Pp);function Ml({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:i,onError:s,reconnectDelay:d=1e3,maxReconnectAttempts:u=5}={}){const{session:l,loading:h}=Be(),{deployment:c,loading:g}=je(),[m,x]=a.useState(!1),[v,S]=a.useState(null),E=a.useRef(null),k=a.useRef(null),j=a.useRef(0),z=a.useRef(null),b=a.useRef(i),w=a.useRef(s),_=a.useRef(r),f=a.useRef(o),C=a.useRef(n),y=a.useRef(d),$=a.useRef(u);b.current=i,w.current=s,_.current=r,f.current=o,C.current=n,y.current=d,$.current=u;const I=a.useCallback(()=>{k.current&&(clearTimeout(k.current),k.current=null),z.current&&(clearInterval(z.current),z.current=null),E.current&&(E.current.close(),E.current=null)},[]),O=a.useCallback(async()=>{var L;if(!t||h||g||!l||!c)return;I();const F=new URL(c.backend_host),D=F.protocol==="https:"?"wss:":"ws:",M=new URL("/realtime/notifications",`${D}//${F.host}`);if(c.mode==="staging"){const A=localStorage.getItem("__dev_session__");A&&M.searchParams.set("__dev_session__",A)}_.current&&_.current.length>0&&_.current.forEach(A=>M.searchParams.append("channels",A)),f.current&&f.current.length>0&&f.current.forEach(A=>M.searchParams.append("organization_ids",A.toString())),C.current&&C.current.length>0&&C.current.forEach(A=>M.searchParams.append("workspace_ids",A.toString()));try{const A=new WebSocket(M.toString());E.current=A,A.onopen=()=>{x(!0),S(null),j.current=0,z.current=setInterval(()=>{A.readyState===WebSocket.OPEN&&A.send("ping")},3e4)},A.onmessage=P=>{var N,W;try{const H=JSON.parse(P.data);if(H.type==="notification"&&H.data)(N=b.current)==null||N.call(b,H.data);else if(H.type==="error"){const oe=H.error||"Unknown error occurred";S(oe),(W=w.current)==null||W.call(w,oe)}else H.type}catch{}},A.onerror=()=>{var P;S("Connection error occurred"),(P=w.current)==null||P.call(w,"Connection error occurred")},A.onclose=P=>{var N;if(x(!1),z.current&&(clearInterval(z.current),z.current=null),t&&P.code!==1e3&&j.current<$.current){j.current++;const W=y.current*Math.pow(2,j.current-1);k.current=setTimeout(()=>{O()},W)}else j.current>=$.current&&(S("Max reconnection attempts reached"),(N=w.current)==null||N.call(w,"Max reconnection attempts reached"))}}catch{S("Failed to connect"),(L=w.current)==null||L.call(w,"Failed to connect")}},[t,h,g,l,c,I]);a.useEffect(()=>(O(),()=>{I()}),[O,I]),a.useEffect(()=>{E.current&&E.current.readyState===WebSocket.OPEN&&O()},[r,o,n,O]);const R=a.useCallback(()=>{I(),x(!1)},[I]),T=a.useCallback(()=>{j.current=0,O()},[O]);return{isConnected:m,connectionError:v,disconnect:R,reconnect:T}}function yn(t){if(!t)return"";const r=new URLSearchParams;t.limit&&r.append("limit",t.limit.toString()),t.cursor&&r.append("cursor",t.cursor),t.scope&&r.append("scope",t.scope),t.is_read!==void 0&&r.append("is_read",t.is_read.toString()),t.is_archived!==void 0&&r.append("is_archived",t.is_archived.toString()),t.is_starred!==void 0&&r.append("is_starred",t.is_starred.toString()),t.severity&&r.append("severity",t.severity);const o=r.toString();return o?"?"+o:""}async function Ip(t,r){const o=`/notifications${yn(r)}`,n=await t(o,{method:"GET"});return(await U(n)).data}async function Tp(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return U(o)}async function Op(t,r){const o=await t(`/notifications/${r}/unread`,{method:"POST"});return U(o)}async function Ap(t,r){const o=await t(`/notifications/mark-all-read${yn(r)}`,{method:"POST"});return U(o)}async function Lp(t,r){const o=await t(`/notifications/archive-all-read${yn(r)}`,{method:"POST"});return U(o)}async function Mp(t,r){const o=await t(`/notifications/${r}/archive`,{method:"POST"});return U(o)}async function Dp(t,r){const o=await t(`/notifications/${r}/star`,{method:"POST"});return U(o)}function Dl(t){var w;const{client:r,loading:o}=Ve(),{data:n,error:i,mutate:s,isLoading:d,size:u,setSize:l,isValidating:h}=Rp((_,f)=>{var I;if(o||_>0&&(!f||!f.has_more))return null;const C=_===0||(I=f==null?void 0:f.notifications[f.notifications.length-1])==null?void 0:I.id,{onNotification:y,...$}=t||{};return["wacht-notifications",{...$,cursor:C}]},([,_])=>Ip(r,_),{refreshInterval:6e4,revalidateOnFocus:!0,revalidateFirstPage:!0}),c=a.useMemo(()=>n?n.flatMap(_=>_.notifications):[],[n]),g=n?(w=n[n.length-1])==null?void 0:w.has_more:!1;Ml({enabled:!o&&!!n,onNotification:a.useCallback(_=>{s(async f=>{var I;if(!f||f.length===0||f.some(O=>O.notifications.some(R=>R.id===_.id.toString())))return f;(I=t==null?void 0:t.onNotification)==null||I.call(t,_);const y=f[0];return[{...y,notifications:[{id:_.id.toString(),user_id:_.user_id.toString(),deployment_id:_.deployment_id.toString(),title:_.title,body:_.body,severity:_.severity,ctas:_.ctas,is_read:!1,is_archived:!1,created_at:_.created_at,updated_at:_.created_at},...y.notifications]},...f.slice(1)]},!1)},[s,t]),onError:a.useCallback(()=>{},[])});const m=a.useCallback(async _=>{o||(await s(async f=>f&&f.map(C=>({...C,notifications:C.notifications.map(y=>y.id===_?{...y,is_read:!0}:y)})),!1),await Tp(r,_),await s())},[r,o,s]),x=a.useCallback(async _=>{o||(await s(async f=>f&&f.map(C=>({...C,notifications:C.notifications.map(y=>y.id===_?{...y,is_read:!1}:y)})),!1),await Op(r,_),await s())},[r,o,s]),v=a.useCallback(async()=>{o||(await s(async _=>_&&_.map(f=>({...f,notifications:f.notifications.map(C=>({...C,is_read:!0}))})),!1),await Ap(r,t),await s())},[r,t,s,o]),S=a.useCallback(async()=>{o||(await s(async _=>_&&_.map(f=>({...f,notifications:f.notifications.filter(C=>!C.is_read)})),!1),await Lp(r,t),await s())},[r,t,o,s]),E=a.useCallback(async _=>{o||(await s(async f=>f&&f.map(C=>({...C,notifications:(t==null?void 0:t.is_archived)!==void 0?C.notifications.filter(y=>y.id!==_):C.notifications.map(y=>y.id===_?{...y,is_archived:!y.is_archived}:y)})),!1),await Mp(r,_),await s())},[r,o,s,t==null?void 0:t.is_archived]),k=a.useCallback(async _=>{o||(await s(async f=>f&&f.map(C=>({...C,notifications:C.notifications.map(y=>y.id===_?{...y,is_starred:!y.is_starred}:y)})),!1),await Dp(r,_),await s())},[r,o,s]),j=a.useCallback(async()=>{h||!g||await l(u+1)},[h,g,l,u]),z=a.useCallback(async()=>{await s()},[s]),b=o||d||u>0&&n&&typeof n[u-1]>"u";return!n||b?{loading:!0,notifications:c,hasMore:g,markAsRead:void 0,markAllAsRead:void 0,archiveAllRead:void 0,archiveNotification:void 0,starNotification:void 0,markAsUnread:void 0,error:i,refetch:z,loadMore:j}:{loading:!1,error:i,notifications:c,hasMore:g,markAsRead:m,markAllAsRead:v,archiveAllRead:S,archiveNotification:E,starNotification:k,markAsUnread:x,refetch:z,loadMore:j}}async function Fp(t,r){const o=`/notifications/scope-unread${yn(r)}`,n=await t(o,{method:"GET"});return(await U(n)).data}function Fl(t){const{client:r,loading:o}=Ve(),{data:n,error:i,mutate:s}=We(o?null:["wacht-notifications-unread",t],([,u])=>Fp(r,u),{refreshInterval:3e4,revalidateOnFocus:!0}),d=async()=>{await s()};return!n||o?{loading:!0,count:0,error:i,refetch:d}:{loading:!1,count:n.count,error:i,refetch:d}}const _o={DISCONNECTED:"disconnected",CONNECTED:"connected",ERROR:"error"},qe={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},tr={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Np(t){switch(t){case tr.IDLE:return qe.IDLE;case tr.STARTING:return qe.STARTING;case tr.RUNNING:return qe.RUNNING;case tr.WAITING_FOR_INPUT:return qe.WAITING_FOR_INPUT;case tr.COMPLETED:return qe.COMPLETED;case tr.FAILED:case tr.CANCELLED:return qe.FAILED;default:return qe.IDLE}}function Up(t){return t===qe.STARTING||t===qe.RUNNING||t===qe.WAITING_FOR_INPUT}function Bp({contextId:t,agentName:r,platformAdapter:o}){const{deployment:n}=je(),{client:i}=Ve(),[s,d]=a.useState([]),[u,l]=a.useState([]),[h,c]=a.useState(null),[g,m]=a.useState(null),[x,v]=a.useState(null),[S,E]=a.useState(!1),[k,j]=a.useState(!1),[z,b]=a.useState(qe.IDLE),[w,_]=a.useState({status:_o.DISCONNECTED}),[f,C]=a.useState(!0),[y,$]=a.useState(!1),I=a.useRef(null),O=a.useRef(null),R=a.useRef(null),T=a.useRef(new Set),F=a.useCallback(te=>{var K;const{id:ae,content:ye}=te,ge=te.message_type||((K=te.metadata)==null?void 0:K.message_type)||(ye==null?void 0:ye.type);let Q="assistant";ge==="user_message"&&(Q="user");const q={...te,role:Q,metadata:{...te.metadata||{},message_type:ge}};if(ge==="system_decision"||ge==="action_execution_result"||ge==="context_results"){if(c(null),m(null),v(null),T.current.has(ae))return;T.current.add(ae),d(ue=>[...ue,q]);return}if(ge==="user_message"){if(c(null),m(null),v(null),T.current.has(ae))return;T.current.add(ae),console.log(T.current,ae),d(ue=>[...ue,q]);return}if(ge==="assistant_acknowledgment"){if(c(null),m(null),v(null),T.current.has(ae))return;T.current.add(ae),d(ue=>[...ue,q]),te.further_action_required||(j(!1),b(qe.IDLE),O.current=null);return}if(ge==="agent_response"){if(T.current.has(ae))return;T.current.add(ae),d(ue=>[...ue,q]),j(!1),b(qe.IDLE),O.current=null;return}if(ge==="user_input_request"){if(T.current.has(ae))return;T.current.add(ae),b(qe.WAITING_FOR_INPUT),d(ue=>[...ue,q]);return}if(ge==="execution_status"){const ue=Np(ye.status);b(ue),j(Up(ue));return}},[]),D=a.useCallback((te,ae)=>{var ye;(ye=o==null?void 0:o.onPlatformEvent)==null||ye.call(o,te,ae)},[o]),M=a.useRef(F),L=a.useRef(D),A=a.useRef(i),P=a.useRef(n);a.useEffect(()=>{M.current=F,L.current=D,A.current=i,P.current=n});const N=a.useRef(null),W=a.useRef(null),H=a.useRef(0),oe=10,Z=a.useCallback(async te=>{if(t)try{const ae=new URLSearchParams({limit:"100"});te&&(ae.append("before_id",te),$(!0));const ye=await i(`/api/agent/contexts/${t}/messages?${ae}`,{method:"GET"}),ge=await U(ye);if(ge.data){const Q=[...ge.data.data].sort((q,K)=>{const ue=new Date(q.timestamp).getTime(),xe=new Date(K.timestamp).getTime();return ue-xe});Q.length>0&&(I.current=Q[0].id),Q.forEach(q=>{T.current.add(q.id)}),d(q=>te?[...Q,...q]:Q),C(ge.data.has_more||!1),$(!1)}}catch(ae){console.error("Failed to fetch messages:",ae),$(!1)}},[t,i]);a.useEffect(()=>{const te=P.current;if(!te||!t)return;const ae=()=>{N.current&&(N.current.close(),N.current=null);const ye=te.backend_host.replace(/\/$/,""),ge=new URL(`${ye}/realtime/agent/stream`);if(ge.searchParams.append("context_id",t),te.mode==="staging"){const q=localStorage.getItem("__dev_session__");q&&ge.searchParams.append("__dev_session__",q)}console.log("SSE: Connecting to",ge.toString());const Q=new EventSource(ge.toString(),{withCredentials:te.mode!=="staging"});N.current=Q,Q.onopen=()=>{console.log("SSE: Connected successfully"),E(!0),_({status:_o.CONNECTED}),H.current>0&&setTimeout(()=>{i(`/api/agent/contexts/${t}/messages?limit=100`,{method:"GET"}).then(async q=>{const K=await U(q);if(K.data){const ue=[...K.data.data].sort((xe,Y)=>new Date(xe.timestamp).getTime()-new Date(Y.timestamp).getTime());d(ue)}}).catch(q=>console.error("Failed to refetch messages:",q))},100),H.current=0},Q.onerror=q=>{if(console.error("SSE error:",q),E(!1),_({status:_o.ERROR}),Q.close(),N.current=null,H.current<oe){const K=Math.min(1e3*Math.pow(2,H.current),3e4);console.log(`SSE: Reconnecting in ${K}ms (attempt ${H.current+1}/${oe})`),W.current=setTimeout(()=>{H.current++,ae()},K)}else console.error("SSE: Max reconnection attempts reached"),_({status:_o.DISCONNECTED})},Q.addEventListener("conversation_message",q=>{try{console.log("SSE received conversation_message:",q.data);const K=JSON.parse(q.data);K.ConversationMessage&&M.current(K.ConversationMessage)}catch(K){console.error("Failed to parse conversation event:",K)}}),Q.addEventListener("platform_event",q=>{try{console.log("SSE received platform_event:",q.data);const K=JSON.parse(q.data);K.PlatformEvent&&L.current(K.PlatformEvent[0],K.PlatformEvent[1])}catch(K){console.error("Failed to parse platform event:",K)}}),Q.addEventListener("user_input_request",q=>{try{console.log("SSE received user_input_request:",q.data);const K=JSON.parse(q.data);K.UserInputRequest&&F({id:`input-${Date.now()}`,content:K.UserInputRequest,metadata:{message_type:"user_input_request"}})}catch(K){console.error("Failed to parse user input request:",K)}})};return ae(),()=>{console.log("SSE: Cleanup running, closing connection for context:",t),W.current&&(clearTimeout(W.current),W.current=null),N.current&&(N.current.close(),N.current=null),E(!1)}},[t]);const we=a.useCallback(async(te,ae,ye)=>{if(!(!t||!n)){c(te),ae&&ae.length>0&&m(ae),ye&&ye.length>0&&v(ye);try{const ge=new FormData;ge.append("agent_name",r),ge.append("message",te),ye&&ye.length>0&&ye.forEach(q=>{ge.append("files",q)}),(await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ge})).ok?(j(!0),b(qe.RUNNING)):(c(null),m(null),v(null))}catch(ge){console.error("Failed to send message:",ge),c(null),m(null),v(null)}}},[t,r,n,i,Z]),pe=a.useCallback(async te=>{if(!(!t||z!==qe.WAITING_FOR_INPUT))try{const ae=new FormData;ae.append("agent_name",r),ae.append("user_input",te),await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ae}),b(qe.RUNNING)}catch(ae){console.error("Failed to submit user input:",ae)}},[t,r,z,i]);a.useEffect(()=>{t&&R.current!==t&&(R.current=t,Z())},[t]);const ee=a.useCallback(async()=>{if(!(y||!f||!I.current)){$(!0);try{await Z(I.current)}finally{$(!1)}}},[y,f,Z]),me=a.useCallback(()=>{d([]),l([]),c(null),m(null),v(null)},[]),re=a.useCallback(()=>{},[]),Re=a.useCallback(async()=>{if(!(!t||!k))try{const te=new FormData;te.append("agent_name",r),te.append("cancel","true"),await i(`/api/agent/contexts/${t}/execute`,{method:"POST",body:te}),j(!1),b(qe.IDLE)}catch(te){console.error("Failed to cancel execution:",te)}},[t,k,r,i]);return{messages:s,quickQuestions:u,pendingMessage:h,pendingImages:g,pendingFiles:x,connectionState:w,isConnected:S,isExecuting:k,executionStatus:z,isWaitingForInput:z===qe.WAITING_FOR_INPUT,hasMoreMessages:f,isLoadingMore:y,sendMessage:we,submitUserInput:pe,clearMessages:me,loadMoreMessages:ee,cancelExecution:Re,connect:re,disconnect:()=>{N.current&&(N.current.close(),N.current=null,E(!1))}}}function Wp(t){const{client:r}=Ve(),o=a.useCallback(async()=>{if(!t)return[];const l=await r(`/api/agent/integrations?agent_name=${t}`,{method:"GET"});return(await U(l)).data},[r,t]),{data:n,error:i,mutate:s}=We(t?`wacht-agent-integrations:${t}`:null,o,{revalidateOnFocus:!1}),d=a.useCallback(async l=>{const h=`/api/agent/integrations/${l}/consent-url`,c=await r(h,{method:"POST"});return(await U(c)).data},[r]),u=a.useCallback(async l=>{await r(`/api/agent/integrations/${l}/remove`,{method:"POST"}),await s(h=>h&&h.filter(c=>c.id!==l))},[r,s]);return{integrations:n||[],loading:!n&&!i,error:i,generateConsentURL:d,removeIntegration:u,refetch:async()=>{await s()}}}function Vp(t){const{client:r}=Ve(),[o,n]=a.useState(!t),[i,s]=a.useState(!!t),[d,u]=a.useState(null),l=a.useRef(!1),h=a.useRef(!1),[c,g]=a.useState(null),m=o,x=a.useCallback(async()=>{const w=await r("/api/agent/session",{method:"GET"});if(!w.ok)throw w.status===401||w.status===403?new Error("NO_SESSION"):new Error("Failed to fetch session");return(await U(w)).data},[r]),{data:v,error:S,isLoading:E,mutate:k}=We(m?"wacht-agent-session":null,x,{revalidateOnFocus:!1});a.useEffect(()=>{if(!t||l.current||h.current)return;(async()=>{h.current=!0,s(!0);try{(await r(`/session/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"GET"})).ok?(l.current=!0,n(!0)):u(new Error("Failed to exchange ticket"))}catch(_){u(_ instanceof Error?_:new Error("Failed to exchange ticket"))}finally{s(!1),h.current=!1}})()},[t,r]),a.useEffect(()=>{!c&&(v!=null&&v.agents)&&v.agents.length>0&&g(v.agents[0])},[v,c]),a.useEffect(()=>{v!=null&&v.agents&&c&&!v.agents.some(_=>_.id===c.id)&&v.agents.length>0&&g(v.agents[0])},[v,c]);const j=!S||S.message!=="NO_SESSION",z=d||(S&&S.message!=="NO_SESSION"?S:null);return{hasSession:j,sessionLoading:i||m&&E,sessionError:z,sessionId:(v==null?void 0:v.session_id)||null,contextGroup:(v==null?void 0:v.context_group)||null,agents:(v==null?void 0:v.agents)||[],activeAgent:c,setActiveAgent:g,ticketExchanged:o,ticketLoading:i,refetch:async()=>{await k()}}}function Gp(t={}){const{client:r}=Ve(),{limit:o=20,offset:n=0,status:i,search:s,enabled:d=!0}=t,u=a.useCallback(async()=>{const v=new URLSearchParams({limit:String(o),offset:String(n)});i&&v.append("status",i),s&&v.append("search",s);const S=await r(`/api/agent/contexts?${v.toString()}`,{method:"GET"});return(await U(S)).data},[r,o,n,i,s]),{data:l,error:h,mutate:c}=We(d?`wacht-agent-contexts:${o}:${n}:${i}:${s}`:null,u,{revalidateOnFocus:!1}),g=a.useCallback(async v=>{const S=new FormData;S.append("title",v.title),v.system_instructions&&S.append("system_instructions",v.system_instructions);const E=await r("/api/agent/contexts",{method:"POST",body:S}),k=await U(E);return await c(j=>j&&{...j,data:[k.data,...j.data]}),k.data},[r,c]),m=a.useCallback(async v=>{await r(`/api/agent/contexts/${v}/delete`,{method:"POST"}),await c(S=>S&&{...S,data:S.data.filter(E=>E.id!==v)})},[r,c]),x=a.useCallback(async(v,S)=>{const E=new FormData;if(S.title&&E.append("title",S.title),!(await r(`/api/agent/contexts/${v}/update`,{method:"POST",body:E})).ok)throw new Error("Failed to update context");await c(j=>j&&{...j,data:j.data.map(z=>z.id===v?{...z,...S}:z)})},[r,c]);return{contexts:(l==null?void 0:l.data)||[],loading:!l&&!h,error:h,hasMore:(l==null?void 0:l.has_more)||!1,createContext:g,deleteContext:m,updateContext:x,refetch:async()=>{await c()}}}const Nl=()=>{const{client:t}=Ve(),[r,o]=a.useState(!1),[n,i]=a.useState(null),[s,d]=a.useState(null),u=a.useCallback(async h=>{o(!0),i(null),d(null);try{const c=new FormData;c.append("token",h);const g=await t("/organizations/invitations/accept",{method:"POST",body:c}),x=(await U(g)).data;return d(x),x.error_code&&i(x.message||"Failed to accept invitation"),x}catch(c){const g=c.message||"Failed to accept invitation";i(g);const m={error_code:"NETWORK_ERROR",message:g};return d(m),m}finally{o(!1)}},[t]),l=a.useCallback(()=>{i(null),d(null)},[]);return{acceptInvitation:u,invitationData:s,loading:r,error:n,reset:l}},Hp=({children:t})=>{const{loading:r}=je();return r?null:e.jsx(e.Fragment,{children:t})},qp=({children:t})=>{const{loading:r}=je();return r?e.jsx(e.Fragment,{children:t}):null};var st=function(){return st=Object.assign||function(r){for(var o,n=1,i=arguments.length;n<i;n++){o=arguments[n];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])}return r},st.apply(this,arguments)};function vr(t,r,o){if(o||arguments.length===2)for(var n=0,i=r.length,s;n<i;n++)(s||!(n in r))&&(s||(s=Array.prototype.slice.call(r,0,n)),s[n]=r[n]);return t.concat(s||Array.prototype.slice.call(r))}function Yp(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var Qp=/^((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|fetchpriority|fetchPriority|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|popover|popoverTarget|popoverTargetAction|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)-.*))$/,Kp=Yp(function(t){return Qp.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ne="-ms-",po="-moz-",Te="-webkit-",Ul="comm",bn="rule",es="decl",Zp="@import",Jp="@namespace",Bl="@keyframes",Xp="@layer",Wl=Math.abs,ts=String.fromCharCode,Oi=Object.assign;function eh(t,r){return Ye(t,0)^45?(((r<<2^Ye(t,0))<<2^Ye(t,1))<<2^Ye(t,2))<<2^Ye(t,3):0}function Vl(t){return t.trim()}function Ot(t,r){return(t=r.exec(t))?t[0]:t}function Ce(t,r,o){return t.replace(r,o)}function en(t,r,o){return t.indexOf(r,o)}function Ye(t,r){return t.charCodeAt(r)|0}function yr(t,r,o){return t.slice(r,o)}function ht(t){return t.length}function Gl(t){return t.length}function co(t,r){return r.push(t),t}function th(t,r){return t.map(r).join("")}function Ws(t,r){return t.filter(function(o){return!Ot(o,r)})}var wn=1,Fr=1,Hl=0,pt=0,Ge=0,Vr="";function jn(t,r,o,n,i,s,d,u){return{value:t,root:r,parent:o,type:n,props:i,children:s,line:wn,column:Fr,length:d,return:"",siblings:u}}function Bt(t,r){return Oi(jn("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function Sr(t){for(;t.root;)t=Bt(t.root,{children:[t]});co(t,t.siblings)}function rh(){return Ge}function oh(){return Ge=pt>0?Ye(Vr,--pt):0,Fr--,Ge===10&&(Fr=1,wn--),Ge}function mt(){return Ge=pt<Hl?Ye(Vr,pt++):0,Fr++,Ge===10&&(Fr=1,wn++),Ge}function Vt(){return Ye(Vr,pt)}function tn(){return pt}function _n(t,r){return yr(Vr,t,r)}function go(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 nh(t){return wn=Fr=1,Hl=ht(Vr=t),pt=0,[]}function ih(t){return Vr="",t}function Hn(t){return Vl(_n(pt-1,Ai(t===91?t+2:t===40?t+1:t)))}function sh(t){for(;(Ge=Vt())&&Ge<33;)mt();return go(t)>2||go(Ge)>3?"":" "}function ah(t,r){for(;--r&&mt()&&!(Ge<48||Ge>102||Ge>57&&Ge<65||Ge>70&&Ge<97););return _n(t,tn()+(r<6&&Vt()==32&&mt()==32))}function Ai(t){for(;mt();)switch(Ge){case t:return pt;case 34:case 39:t!==34&&t!==39&&Ai(Ge);break;case 40:t===41&&Ai(t);break;case 92:mt();break}return pt}function ch(t,r){for(;mt()&&t+Ge!==57;)if(t+Ge===84&&Vt()===47)break;return"/*"+_n(r,pt-1)+"*"+ts(t===47?t:mt())}function lh(t){for(;!go(Vt());)mt();return _n(t,pt)}function dh(t){return ih(rn("",null,null,null,[""],t=nh(t),0,[0],t))}function rn(t,r,o,n,i,s,d,u,l){for(var h=0,c=0,g=d,m=0,x=0,v=0,S=1,E=1,k=1,j=0,z="",b=i,w=s,_=n,f=z;E;)switch(v=j,j=mt()){case 40:if(v!=108&&Ye(f,g-1)==58){en(f+=Ce(Hn(j),"&","&\f"),"&\f",Wl(h?u[h-1]:0))!=-1&&(k=-1);break}case 34:case 39:case 91:f+=Hn(j);break;case 9:case 10:case 13:case 32:f+=sh(v);break;case 92:f+=ah(tn()-1,7);continue;case 47:switch(Vt()){case 42:case 47:co(uh(ch(mt(),tn()),r,o,l),l),(go(v||1)==5||go(Vt()||1)==5)&&ht(f)&&yr(f,-1,void 0)!==" "&&(f+=" ");break;default:f+="/"}break;case 123*S:u[h++]=ht(f)*k;case 125*S:case 59:case 0:switch(j){case 0:case 125:E=0;case 59+c:k==-1&&(f=Ce(f,/\f/g,"")),x>0&&(ht(f)-g||S===0&&v===47)&&co(x>32?Gs(f+";",n,o,g-1,l):Gs(Ce(f," ","")+";",n,o,g-2,l),l);break;case 59:f+=";";default:if(co(_=Vs(f,r,o,h,c,i,u,z,b=[],w=[],g,s),s),j===123)if(c===0)rn(f,r,_,_,b,s,g,u,w);else{switch(m){case 99:if(Ye(f,3)===110)break;case 108:if(Ye(f,2)===97)break;default:c=0;case 100:case 109:case 115:}c?rn(t,_,_,n&&co(Vs(t,_,_,0,0,i,u,z,i,b=[],g,w),w),i,w,g,u,n?b:w):rn(f,_,_,_,[""],w,0,u,w)}}h=c=x=0,S=k=1,z=f="",g=d;break;case 58:g=1+ht(f),x=v;default:if(S<1){if(j==123)--S;else if(j==125&&S++==0&&oh()==125)continue}switch(f+=ts(j),j*S){case 38:k=c>0?1:(f+="\f",-1);break;case 44:u[h++]=(ht(f)-1)*k,k=1;break;case 64:Vt()===45&&(f+=Hn(mt())),m=Vt(),c=g=ht(z=f+=lh(tn())),j++;break;case 45:v===45&&ht(f)==2&&(S=0)}}return s}function Vs(t,r,o,n,i,s,d,u,l,h,c,g){for(var m=i-1,x=i===0?s:[""],v=Gl(x),S=0,E=0,k=0;S<n;++S)for(var j=0,z=yr(t,m+1,m=Wl(E=d[S])),b=t;j<v;++j)(b=Vl(E>0?x[j]+" "+z:Ce(z,/&\f/g,x[j])))&&(l[k++]=b);return jn(t,r,o,i===0?bn:u,l,h,c,g)}function uh(t,r,o,n){return jn(t,r,o,Ul,ts(rh()),yr(t,2,-2),0,n)}function Gs(t,r,o,n,i){return jn(t,r,o,es,yr(t,0,n),yr(t,n+1,-1),n,i)}function ql(t,r,o){switch(eh(t,r)){case 5103:return Te+"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 4215:case 6389:case 5109:case 5365:case 5621:case 3829:case 6391:case 5879:case 5623:case 6135:case 4599:return Te+t+t;case 4855:return Te+t.replace("add","source-over").replace("substract","source-out").replace("intersect","source-in").replace("exclude","xor")+t;case 4789:return po+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Te+t+po+t+Ne+t+t;case 5936:switch(Ye(t,r+11)){case 114:return Te+t+Ne+Ce(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Te+t+Ne+Ce(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Te+t+Ne+Ce(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return Te+t+Ne+t+t;case 6165:return Te+t+Ne+"flex-"+t+t;case 5187:return Te+t+Ce(t,/(\w+).+(:[^]+)/,Te+"box-$1$2"+Ne+"flex-$1$2")+t;case 5443:return Te+t+Ne+"flex-item-"+Ce(t,/flex-|-self/g,"")+(Ot(t,/flex-|baseline/)?"":Ne+"grid-row-"+Ce(t,/flex-|-self/g,""))+t;case 4675:return Te+t+Ne+"flex-line-pack"+Ce(t,/align-content|flex-|-self/g,"")+t;case 5548:return Te+t+Ne+Ce(t,"shrink","negative")+t;case 5292:return Te+t+Ne+Ce(t,"basis","preferred-size")+t;case 6060:return Te+"box-"+Ce(t,"-grow","")+Te+t+Ne+Ce(t,"grow","positive")+t;case 4554:return Te+Ce(t,/([^-])(transform)/g,"$1"+Te+"$2")+t;case 6187:return Ce(Ce(Ce(t,/(zoom-|grab)/,Te+"$1"),/(image-set)/,Te+"$1"),t,"")+t;case 5495:case 3959:return Ce(t,/(image-set\([^]*)/,Te+"$1$`$1");case 4968:return Ce(Ce(t,/(.+:)(flex-)?(.*)/,Te+"box-pack:$3"+Ne+"flex-pack:$3"),/space-between/,"justify")+Te+t+t;case 4200:if(!Ot(t,/flex-|baseline/))return Ne+"grid-column-align"+yr(t,r)+t;break;case 2592:case 3360:return Ne+Ce(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,i){return r=i,Ot(n.props,/grid-\w+-end/)})?~en(t+(o=o[r].value),"span",0)?t:Ne+Ce(t,"-start","")+t+Ne+"grid-row-span:"+(~en(o,"span",0)?Ot(o,/\d+/):+Ot(o,/\d+/)-+Ot(t,/\d+/))+";":Ne+Ce(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return Ot(n.props,/grid-\w+-start/)})?t:Ne+Ce(Ce(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return Ce(t,/(.+)-inline(.+)/,Te+"$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(ht(t)-1-r>6)switch(Ye(t,r+1)){case 109:if(Ye(t,r+4)!==45)break;case 102:return Ce(t,/(.+:)(.+)-([^]+)/,"$1"+Te+"$2-$3$1"+po+(Ye(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~en(t,"stretch",0)?ql(Ce(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return Ce(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,i,s,d,u,l,h){return Ne+i+":"+s+h+(d?Ne+i+"-span:"+(u?l:+l-+s)+h:"")+t});case 4949:if(Ye(t,r+6)===121)return Ce(t,":",":"+Te)+t;break;case 6444:switch(Ye(t,Ye(t,14)===45?18:11)){case 120:return Ce(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Te+(Ye(t,14)===45?"inline-":"")+"box$3$1"+Te+"$2$3$1"+Ne+"$2box$3")+t;case 100:return Ce(t,":",":"+Ne)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return Ce(t,"scroll-","scroll-snap-")+t}return t}function ln(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function ph(t,r,o,n){switch(t.type){case Xp:if(t.children.length)break;case Zp:case Jp:case es:return t.return=t.return||t.value;case Ul:return"";case Bl:return t.return=t.value+"{"+ln(t.children,n)+"}";case bn:if(!ht(t.value=t.props.join(",")))return""}return ht(o=ln(t.children,n))?t.return=t.value+"{"+o+"}":""}function hh(t){var r=Gl(t);return function(o,n,i,s){for(var d="",u=0;u<r;u++)d+=t[u](o,n,i,s)||"";return d}}function fh(t){return function(r){r.root||(r=r.return)&&t(r)}}function gh(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case es:t.return=ql(t.value,t.length,o);return;case Bl:return ln([Bt(t,{value:Ce(t.value,"@","@"+Te)})],n);case bn:if(t.length)return th(o=t.props,function(i){switch(Ot(i,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":Sr(Bt(t,{props:[Ce(i,/:(read-\w+)/,":"+po+"$1")]})),Sr(Bt(t,{props:[i]})),Oi(t,{props:Ws(o,n)});break;case"::placeholder":Sr(Bt(t,{props:[Ce(i,/:(plac\w+)/,":"+Te+"input-$1")]})),Sr(Bt(t,{props:[Ce(i,/:(plac\w+)/,":"+po+"$1")]})),Sr(Bt(t,{props:[Ce(i,/:(plac\w+)/,Ne+"input-$1")]})),Sr(Bt(t,{props:[i]})),Oi(t,{props:Ws(o,n)});break}return""})}}var mh={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,scale: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},br=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Yl="active",Ql="data-styled-version",kn="6.3.8",rs=`/*!sc*/
|
|
19
19
|
`,dn=typeof window<"u"&&typeof document<"u",wr=a.createContext===void 0,xh=!!(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"),Hs=/invalid hook call/i,ko=new Set,vh=function(t,r){if(process.env.NODE_ENV!=="production"){if(wr)return;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.
|
|
@@ -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 Ih(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],i=1,s=t.length;i<s;i+=1)n.push(t[i]);return n.forEach(function(d){o=o.replace(/%[a-z]/,d)}),o}function Gr(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(Ih.apply(void 0,vr([Rh[t]],r,!1)).trim())}var Th=(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,i=n.length,s=i;r>=s;)if((s<<=1)<0)throw Gr(16,"".concat(r));this.groupSizes=new Uint32Array(s),this.groupSizes.set(n),this.length=s;for(var d=i;d<s;d++)this.groupSizes[d]=0}for(var u=this.indexOfGroup(r+1),l=(d=0,o.length);d<l;d++)this.tag.insertRule(u,o[d])&&(this.groupSizes[r]++,u++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),i=n+o;this.groupSizes[r]=0;for(var s=n;s<i;s++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],i=this.indexOfGroup(r),s=i+n,d=i;d<s;d++)o+="".concat(this.tag.getRule(d)).concat(rs);return o},t})(),Oh=1<<30,on=new Map,un=new Map,nn=1,lo=function(t){if(on.has(t))return on.get(t);for(;un.has(nn);)nn++;var r=nn++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Oh))throw Gr(16,"".concat(r));return on.set(t,r),un.set(r,t),r},Ah=function(t,r){nn=r+1,on.set(t,r),un.set(r,t)},Lh="style[".concat(br,"][").concat(Ql,'="').concat(kn,'"]'),Mh=new RegExp("^".concat(br,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Dh=function(t,r,o){for(var n,i=o.split(","),s=0,d=i.length;s<d;s++)(n=i[s])&&t.registerName(r,n)},Fh=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(rs),i=[],s=0,d=n.length;s<d;s++){var u=n[s].trim();if(u){var l=u.match(Mh);if(l){var h=0|parseInt(l[1],10),c=l[2];h!==0&&(Ah(c,h),Dh(t,c,l[3]),t.getTag().insertRules(h,i)),i.length=0}else i.push(u)}}},Js=function(t){for(var r=document.querySelectorAll(Lh),o=0,n=r.length;o<n;o++){var i=r[o];i&&i.getAttribute(br)!==Yl&&(Fh(t,i),i.parentNode&&i.parentNode.removeChild(i))}};function Nh(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var od=function(t){var r=document.head,o=t||r,n=document.createElement("style"),i=(function(u){var l=Array.from(u.querySelectorAll("style[".concat(br,"]")));return l[l.length-1]})(o),s=i!==void 0?i.nextSibling:null;n.setAttribute(br,Yl),n.setAttribute(Ql,kn);var d=Nh();return d&&n.setAttribute("nonce",d),o.insertBefore(n,s),n},Uh=(function(){function t(r){this.element=od(r),this.element.appendChild(document.createTextNode("")),this.sheet=(function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,i=0,s=n.length;i<s;i++){var d=n[i];if(d.ownerNode===o)return d}throw Gr(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})(),Bh=(function(){function t(r){this.element=od(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})(),Wh=(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})(),Xs=dn,Vh={isServer:!dn,useCSSOMInjection:!xh},nd=(function(){function t(r,o,n){r===void 0&&(r=Nr),o===void 0&&(o={});var i=this;this.options=it(it({},Vh),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&dn&&Xs&&(Xs=!1,Js(this)),ns(this,function(){return(function(s){for(var d=s.getTag(),u=d.length,l="",h=function(g){var m=(function(k){return un.get(k)})(g);if(m===void 0)return"continue";var x=s.names.get(m),v=d.getGroup(g);if(x===void 0||!x.size||v.length===0)return"continue";var S="".concat(br,".g").concat(g,'[id="').concat(m,'"]'),E="";x!==void 0&&x.forEach(function(k){k.length>0&&(E+="".concat(k,","))}),l+="".concat(v).concat(S,'{content:"').concat(E,'"}').concat(rs)},c=0;c<u;c++)h(c);return l})(i)})}return t.registerId=function(r){return lo(r)},t.prototype.rehydrate=function(){!this.server&&dn&&Js(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(it(it({},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,i=o.target;return o.isServer?new Wh(i):n?new Uh(i):new Bh(i)})(this.options),new Th(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(lo(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(lo(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(lo(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t})(),Gh=/&/g,Ar=47;function ea(t){if(t.indexOf("}")===-1)return!1;for(var r=t.length,o=0,n=0,i=!1,s=0;s<r;s++){var d=t.charCodeAt(s);if(n!==0||i||d!==Ar||t.charCodeAt(s+1)!==42)if(i)d===42&&t.charCodeAt(s+1)===Ar&&(i=!1,s++);else if(d!==34&&d!==39||s!==0&&t.charCodeAt(s-1)===92){if(n===0){if(d===123)o++;else if(d===125&&--o<0)return!0}}else n===0?n=d:n===d&&(n=0);else i=!0,s++}return o!==0||n!==0}function id(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=id(o.children,r)),o})}function Hh(t){var r,o,n,i=Nr,s=i.options,d=s===void 0?Nr:s,u=i.plugins,l=u===void 0?Cn:u,h=function(m,x,v){return v.startsWith(o)&&v.endsWith(o)&&v.replaceAll(o,"").length>0?".".concat(r):m},c=l.slice();c.push(function(m){m.type===bn&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(Gh,o).replace(n,h))}),d.prefix&&c.push(gh),c.push(ph);var g=function(m,x,v,S){x===void 0&&(x=""),v===void 0&&(v=""),S===void 0&&(S="&"),r=S,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var E=(function(z){if(!ea(z))return z;for(var b=z.length,w="",_=0,f=0,C=0,y=!1,$=0;$<b;$++){var I=z.charCodeAt($);if(C!==0||y||I!==Ar||z.charCodeAt($+1)!==42)if(y)I===42&&z.charCodeAt($+1)===Ar&&(y=!1,$++);else if(I!==34&&I!==39||$!==0&&z.charCodeAt($-1)===92){if(C===0)if(I===123)f++;else if(I===125){if(--f<0){for(var O=$+1;O<b;){var R=z.charCodeAt(O);if(R===59||R===10)break;O++}O<b&&z.charCodeAt(O)===59&&O++,f=0,$=O-1,_=O;continue}f===0&&(w+=z.substring(_,$+1),_=$+1)}else I===59&&f===0&&(w+=z.substring(_,$+1),_=$+1)}else C===0?C=I:C===I&&(C=0);else y=!0,$++}if(_<b){var T=z.substring(_);ea(T)||(w+=T)}return w})((function(z){if(z.indexOf("//")===-1)return z;for(var b=z.length,w=[],_=0,f=0,C=0,y=0;f<b;){var $=z.charCodeAt(f);if($!==34&&$!==39||f!==0&&z.charCodeAt(f-1)===92)if(C===0)if($===40&&f>=3&&(32|z.charCodeAt(f-1))==108&&(32|z.charCodeAt(f-2))==114&&(32|z.charCodeAt(f-3))==117)y=1,f++;else if(y>0)$===41?y--:$===40&&y++,f++;else if($===Ar&&f+1<b&&z.charCodeAt(f+1)===Ar){for(f>_&&w.push(z.substring(_,f));f<b&&z.charCodeAt(f)!==10;)f++;_=f}else f++;else f++;else C===0?C=$:C===$&&(C=0),f++}return _===0?z:(_<b&&w.push(z.substring(_)),w.join(""))})(m)),k=dh(v||x?"".concat(v," ").concat(x," { ").concat(E," }"):E);d.namespace&&(k=id(k,d.namespace));var j=[];return ln(k,hh(c.concat(fh(function(z){return j.push(z)})))),j};return g.hash=l.length?l.reduce(function(m,x){return x.name||Gr(15),pr(m,x.name)},5381).toString():"",g}var qh=new nd,Ni=Hh(),Ui={shouldForwardProp:void 0,styleSheet:qh,stylis:Ni},sd=wr?{Provider:function(t){return t.children},Consumer:function(t){return(0,t.children)(Ui)}}:a.createContext(Ui);sd.Consumer;wr||a.createContext(void 0);function ta(){return wr?Ui:a.useContext(sd)}var Bi=(function(){function t(r,o){var n=this;this.inject=function(i,s){s===void 0&&(s=Ni);var d=n.name+s.hash;i.hasNameForId(n.id,d)||i.insertRules(n.id,d,s(n.rules,d,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,ns(this,function(){throw Gr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=Ni),this.name+r.hash},t})();function Yh(t,r){return r==null||typeof r=="boolean"||r===""?"":typeof r!="number"||r===0||t in mh||t.startsWith("--")?String(r).trim():"".concat(r,"px")}var Qh=function(t){return t>="A"&&t<="Z"};function ra(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;Qh(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var ad=function(t){return t==null||t===!1||t===""},cd=function(t){var r=[];for(var o in t){var n=t[o];t.hasOwnProperty(o)&&!ad(n)&&(Array.isArray(n)&&n.isCss||Ur(n)?r.push("".concat(ra(o),":"),n,";"):Br(n)?r.push.apply(r,vr(vr(["".concat(o," {")],cd(n),!1),["}"],!1)):r.push("".concat(ra(o),": ").concat(Yh(o,n),";")))}return r};function gr(t,r,o,n){if(ad(t))return[];if(os(t))return[".".concat(t.styledComponentId)];if(Ur(t)){if(!Ur(s=t)||s.prototype&&s.prototype.isReactComponent||!r)return[t];var i=t(r);return process.env.NODE_ENV==="production"||typeof i!="object"||Array.isArray(i)||i instanceof Bi||Br(i)||i===null||console.error("".concat(Jl(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.")),gr(i,r,o,n)}var s;return t instanceof Bi?o?(t.inject(o,n),[t.getName(n)]):[t]:Br(t)?cd(t):Array.isArray(t)?Array.prototype.concat.apply(Cn,t.map(function(d){return gr(d,r,o,n)})):[t.toString()]}function Kh(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(Ur(o)&&!os(o))return!1}return!0}var Zh=Kl(kn),Jh=(function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&Kh(r),this.componentId=o,this.baseHash=pr(Zh,o),this.baseStyle=n,nd.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var i=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n).className:"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))i=fr(i,this.staticRulesId);else{var s=Di(gr(this.rules,r,o,n)),d=Mi(pr(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,d)){var u=n(s,".".concat(d),void 0,this.componentId);o.insertRules(this.componentId,d,u)}i=fr(i,d),this.staticRulesId=d}else{for(var l=pr(this.baseHash,n.hash),h="",c=0;c<this.rules.length;c++){var g=this.rules[c];if(typeof g=="string")h+=g,process.env.NODE_ENV!=="production"&&(l=pr(l,g));else if(g){var m=Di(gr(g,r,o,n));l=pr(l,m+c),h+=m}}if(h){var x=Mi(l>>>0);if(!o.hasNameForId(this.componentId,x)){var v=n(h,".".concat(x),void 0,this.componentId);o.insertRules(this.componentId,x,v)}i=fr(i,x)}}return{className:i,css:typeof window>"u"?o.getTag().getGroup(lo(this.componentId)):""}},t})(),ld=wr?{Provider:function(t){return t.children},Consumer:function(t){return(0,t.children)(void 0)}}:a.createContext(void 0);ld.Consumer;var Qn={},oa=new Set;function Xh(t,r,o){var n=os(t),i=t,s=!Yn(t),d=r.attrs,u=d===void 0?Cn:d,l=r.componentId,h=l===void 0?(function(b,w){var _=typeof b!="string"?"sc":qs(b);Qn[_]=(Qn[_]||0)+1;var f="".concat(_,"-").concat(Zl(kn+_+Qn[_]));return w?"".concat(w,"-").concat(f):f})(r.displayName,r.parentComponentId):l,c=r.displayName,g=c===void 0?(function(b){return Yn(b)?"styled.".concat(b):"Styled(".concat(Jl(b),")")})(t):c,m=r.displayName&&r.componentId?"".concat(qs(r.displayName),"-").concat(r.componentId):r.componentId||h,x=n&&i.attrs?i.attrs.concat(u).filter(Boolean):u,v=r.shouldForwardProp;if(n&&i.shouldForwardProp){var S=i.shouldForwardProp;if(r.shouldForwardProp){var E=r.shouldForwardProp;v=function(b,w){return S(b,w)&&E(b,w)}}else v=S}var k=new Jh(o,m,n?i.componentStyle:void 0);function j(b,w){return(function(_,f,C){var y=_.attrs,$=_.componentStyle,I=_.defaultProps,O=_.foldedComponentIds,R=_.styledComponentId,T=_.target,F=wr?void 0:a.useContext(ld),D=ta(),M=_.shouldForwardProp||D.shouldForwardProp;process.env.NODE_ENV!=="production"&&a.useDebugValue&&a.useDebugValue(R);var L=yh(f,F,I)||Nr,A=(function(ee,me,re){for(var Pe,te=it(it({},me),{className:void 0,theme:re}),ae=0;ae<ee.length;ae+=1){var ye=Ur(Pe=ee[ae])?Pe(te):Pe;for(var ge in ye)ge==="className"?te.className=fr(te.className,ye[ge]):ge==="style"?te.style=it(it({},te.style),ye[ge]):te[ge]=ye[ge]}return"className"in me&&typeof me.className=="string"&&(te.className=fr(te.className,me.className)),te})(y,f,L),P=A.as||T,N={};for(var W in A)A[W]===void 0||W[0]==="$"||W==="as"||W==="theme"&&A.theme===L||(W==="forwardedAs"?N.as=A.forwardedAs:M&&!M(W,P)||(N[W]=A[W],M||process.env.NODE_ENV!=="development"||Kp(W)||oa.has(W)||!Li.has(P)||(oa.add(W),console.warn('styled-components: it looks like an unknown prop "'.concat(W,'" 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 H=(function(ee,me){var re=ta(),Pe=ee.generateAndInjectStyles(me,re.styleSheet,re.stylis);return process.env.NODE_ENV!=="production"&&a.useDebugValue&&a.useDebugValue(Pe.className),Pe})($,A),oe=H.className,Z=H.css;process.env.NODE_ENV!=="production"&&_.warnTooManyClasses&&_.warnTooManyClasses(oe);var we=fr(O,R);oe&&(we+=" "+oe),A.className&&(we+=" "+A.className),N[Yn(P)&&!Li.has(P)?"class":"className"]=we,C&&(N.ref=C);var pe=a.createElement(P,N);return wr&&Z?a.createElement(a.Fragment,null,a.createElement("style",{precedence:"styled-components",href:"sc-".concat(R,"-").concat(oe),children:Z}),pe):pe})(z,b,w)}j.displayName=g;var z=a.forwardRef(j);return z.attrs=x,z.componentStyle=k,z.displayName=g,z.shouldForwardProp=v,z.foldedComponentIds=n?fr(i.foldedComponentIds,i.styledComponentId):"",z.styledComponentId=m,z.target=n?i.target:t,Object.defineProperty(z,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(b){this._foldedDefaultProps=n?(function(w){for(var _=[],f=1;f<arguments.length;f++)_[f-1]=arguments[f];for(var C=0,y=_;C<y.length;C++)Fi(w,y[C],!0);return w})({},i.defaultProps,b):b}}),process.env.NODE_ENV!=="production"&&(vh(g,m),z.warnTooManyClasses=(function(b,w){var _={},f=!1;return function(C){if(!f&&(_[C]=!0,Object.keys(_).length>=200)){var y=w?' with the id of "'.concat(w,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(b).concat(y,`.
|
|
64
|
+
`,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function Ih(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],i=1,s=t.length;i<s;i+=1)n.push(t[i]);return n.forEach(function(d){o=o.replace(/%[a-z]/,d)}),o}function Gr(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(Ih.apply(void 0,vr([Rh[t]],r,!1)).trim())}var Th=(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,i=n.length,s=i;r>=s;)if((s<<=1)<0)throw Gr(16,"".concat(r));this.groupSizes=new Uint32Array(s),this.groupSizes.set(n),this.length=s;for(var d=i;d<s;d++)this.groupSizes[d]=0}for(var u=this.indexOfGroup(r+1),l=(d=0,o.length);d<l;d++)this.tag.insertRule(u,o[d])&&(this.groupSizes[r]++,u++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),i=n+o;this.groupSizes[r]=0;for(var s=n;s<i;s++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],i=this.indexOfGroup(r),s=i+n,d=i;d<s;d++)o+="".concat(this.tag.getRule(d)).concat(rs);return o},t})(),Oh=1<<30,on=new Map,un=new Map,nn=1,lo=function(t){if(on.has(t))return on.get(t);for(;un.has(nn);)nn++;var r=nn++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Oh))throw Gr(16,"".concat(r));return on.set(t,r),un.set(r,t),r},Ah=function(t,r){nn=r+1,on.set(t,r),un.set(r,t)},Lh="style[".concat(br,"][").concat(Ql,'="').concat(kn,'"]'),Mh=new RegExp("^".concat(br,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Dh=function(t,r,o){for(var n,i=o.split(","),s=0,d=i.length;s<d;s++)(n=i[s])&&t.registerName(r,n)},Fh=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(rs),i=[],s=0,d=n.length;s<d;s++){var u=n[s].trim();if(u){var l=u.match(Mh);if(l){var h=0|parseInt(l[1],10),c=l[2];h!==0&&(Ah(c,h),Dh(t,c,l[3]),t.getTag().insertRules(h,i)),i.length=0}else i.push(u)}}},Js=function(t){for(var r=document.querySelectorAll(Lh),o=0,n=r.length;o<n;o++){var i=r[o];i&&i.getAttribute(br)!==Yl&&(Fh(t,i),i.parentNode&&i.parentNode.removeChild(i))}};function Nh(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var od=function(t){var r=document.head,o=t||r,n=document.createElement("style"),i=(function(u){var l=Array.from(u.querySelectorAll("style[".concat(br,"]")));return l[l.length-1]})(o),s=i!==void 0?i.nextSibling:null;n.setAttribute(br,Yl),n.setAttribute(Ql,kn);var d=Nh();return d&&n.setAttribute("nonce",d),o.insertBefore(n,s),n},Uh=(function(){function t(r){this.element=od(r),this.element.appendChild(document.createTextNode("")),this.sheet=(function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,i=0,s=n.length;i<s;i++){var d=n[i];if(d.ownerNode===o)return d}throw Gr(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})(),Bh=(function(){function t(r){this.element=od(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})(),Wh=(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})(),Xs=dn,Vh={isServer:!dn,useCSSOMInjection:!xh},nd=(function(){function t(r,o,n){r===void 0&&(r=Nr),o===void 0&&(o={});var i=this;this.options=st(st({},Vh),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&dn&&Xs&&(Xs=!1,Js(this)),ns(this,function(){return(function(s){for(var d=s.getTag(),u=d.length,l="",h=function(g){var m=(function(k){return un.get(k)})(g);if(m===void 0)return"continue";var x=s.names.get(m),v=d.getGroup(g);if(x===void 0||!x.size||v.length===0)return"continue";var S="".concat(br,".g").concat(g,'[id="').concat(m,'"]'),E="";x!==void 0&&x.forEach(function(k){k.length>0&&(E+="".concat(k,","))}),l+="".concat(v).concat(S,'{content:"').concat(E,'"}').concat(rs)},c=0;c<u;c++)h(c);return l})(i)})}return t.registerId=function(r){return lo(r)},t.prototype.rehydrate=function(){!this.server&&dn&&Js(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(st(st({},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,i=o.target;return o.isServer?new Wh(i):n?new Uh(i):new Bh(i)})(this.options),new Th(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(lo(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(lo(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(lo(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t})(),Gh=/&/g,Ar=47;function ea(t){if(t.indexOf("}")===-1)return!1;for(var r=t.length,o=0,n=0,i=!1,s=0;s<r;s++){var d=t.charCodeAt(s);if(n!==0||i||d!==Ar||t.charCodeAt(s+1)!==42)if(i)d===42&&t.charCodeAt(s+1)===Ar&&(i=!1,s++);else if(d!==34&&d!==39||s!==0&&t.charCodeAt(s-1)===92){if(n===0){if(d===123)o++;else if(d===125&&--o<0)return!0}}else n===0?n=d:n===d&&(n=0);else i=!0,s++}return o!==0||n!==0}function id(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=id(o.children,r)),o})}function Hh(t){var r,o,n,i=Nr,s=i.options,d=s===void 0?Nr:s,u=i.plugins,l=u===void 0?Cn:u,h=function(m,x,v){return v.startsWith(o)&&v.endsWith(o)&&v.replaceAll(o,"").length>0?".".concat(r):m},c=l.slice();c.push(function(m){m.type===bn&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(Gh,o).replace(n,h))}),d.prefix&&c.push(gh),c.push(ph);var g=function(m,x,v,S){x===void 0&&(x=""),v===void 0&&(v=""),S===void 0&&(S="&"),r=S,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var E=(function(z){if(!ea(z))return z;for(var b=z.length,w="",_=0,f=0,C=0,y=!1,$=0;$<b;$++){var I=z.charCodeAt($);if(C!==0||y||I!==Ar||z.charCodeAt($+1)!==42)if(y)I===42&&z.charCodeAt($+1)===Ar&&(y=!1,$++);else if(I!==34&&I!==39||$!==0&&z.charCodeAt($-1)===92){if(C===0)if(I===123)f++;else if(I===125){if(--f<0){for(var O=$+1;O<b;){var R=z.charCodeAt(O);if(R===59||R===10)break;O++}O<b&&z.charCodeAt(O)===59&&O++,f=0,$=O-1,_=O;continue}f===0&&(w+=z.substring(_,$+1),_=$+1)}else I===59&&f===0&&(w+=z.substring(_,$+1),_=$+1)}else C===0?C=I:C===I&&(C=0);else y=!0,$++}if(_<b){var T=z.substring(_);ea(T)||(w+=T)}return w})((function(z){if(z.indexOf("//")===-1)return z;for(var b=z.length,w=[],_=0,f=0,C=0,y=0;f<b;){var $=z.charCodeAt(f);if($!==34&&$!==39||f!==0&&z.charCodeAt(f-1)===92)if(C===0)if($===40&&f>=3&&(32|z.charCodeAt(f-1))==108&&(32|z.charCodeAt(f-2))==114&&(32|z.charCodeAt(f-3))==117)y=1,f++;else if(y>0)$===41?y--:$===40&&y++,f++;else if($===Ar&&f+1<b&&z.charCodeAt(f+1)===Ar){for(f>_&&w.push(z.substring(_,f));f<b&&z.charCodeAt(f)!==10;)f++;_=f}else f++;else f++;else C===0?C=$:C===$&&(C=0),f++}return _===0?z:(_<b&&w.push(z.substring(_)),w.join(""))})(m)),k=dh(v||x?"".concat(v," ").concat(x," { ").concat(E," }"):E);d.namespace&&(k=id(k,d.namespace));var j=[];return ln(k,hh(c.concat(fh(function(z){return j.push(z)})))),j};return g.hash=l.length?l.reduce(function(m,x){return x.name||Gr(15),pr(m,x.name)},5381).toString():"",g}var qh=new nd,Ni=Hh(),Ui={shouldForwardProp:void 0,styleSheet:qh,stylis:Ni},sd=wr?{Provider:function(t){return t.children},Consumer:function(t){return(0,t.children)(Ui)}}:a.createContext(Ui);sd.Consumer;wr||a.createContext(void 0);function ta(){return wr?Ui:a.useContext(sd)}var Bi=(function(){function t(r,o){var n=this;this.inject=function(i,s){s===void 0&&(s=Ni);var d=n.name+s.hash;i.hasNameForId(n.id,d)||i.insertRules(n.id,d,s(n.rules,d,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,ns(this,function(){throw Gr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=Ni),this.name+r.hash},t})();function Yh(t,r){return r==null||typeof r=="boolean"||r===""?"":typeof r!="number"||r===0||t in mh||t.startsWith("--")?String(r).trim():"".concat(r,"px")}var Qh=function(t){return t>="A"&&t<="Z"};function ra(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;Qh(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var ad=function(t){return t==null||t===!1||t===""},cd=function(t){var r=[];for(var o in t){var n=t[o];t.hasOwnProperty(o)&&!ad(n)&&(Array.isArray(n)&&n.isCss||Ur(n)?r.push("".concat(ra(o),":"),n,";"):Br(n)?r.push.apply(r,vr(vr(["".concat(o," {")],cd(n),!1),["}"],!1)):r.push("".concat(ra(o),": ").concat(Yh(o,n),";")))}return r};function gr(t,r,o,n){if(ad(t))return[];if(os(t))return[".".concat(t.styledComponentId)];if(Ur(t)){if(!Ur(s=t)||s.prototype&&s.prototype.isReactComponent||!r)return[t];var i=t(r);return process.env.NODE_ENV==="production"||typeof i!="object"||Array.isArray(i)||i instanceof Bi||Br(i)||i===null||console.error("".concat(Jl(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.")),gr(i,r,o,n)}var s;return t instanceof Bi?o?(t.inject(o,n),[t.getName(n)]):[t]:Br(t)?cd(t):Array.isArray(t)?Array.prototype.concat.apply(Cn,t.map(function(d){return gr(d,r,o,n)})):[t.toString()]}function Kh(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(Ur(o)&&!os(o))return!1}return!0}var Zh=Kl(kn),Jh=(function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&Kh(r),this.componentId=o,this.baseHash=pr(Zh,o),this.baseStyle=n,nd.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var i=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n).className:"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))i=fr(i,this.staticRulesId);else{var s=Di(gr(this.rules,r,o,n)),d=Mi(pr(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,d)){var u=n(s,".".concat(d),void 0,this.componentId);o.insertRules(this.componentId,d,u)}i=fr(i,d),this.staticRulesId=d}else{for(var l=pr(this.baseHash,n.hash),h="",c=0;c<this.rules.length;c++){var g=this.rules[c];if(typeof g=="string")h+=g,process.env.NODE_ENV!=="production"&&(l=pr(l,g));else if(g){var m=Di(gr(g,r,o,n));l=pr(l,m+c),h+=m}}if(h){var x=Mi(l>>>0);if(!o.hasNameForId(this.componentId,x)){var v=n(h,".".concat(x),void 0,this.componentId);o.insertRules(this.componentId,x,v)}i=fr(i,x)}}return{className:i,css:typeof window>"u"?o.getTag().getGroup(lo(this.componentId)):""}},t})(),ld=wr?{Provider:function(t){return t.children},Consumer:function(t){return(0,t.children)(void 0)}}:a.createContext(void 0);ld.Consumer;var Qn={},oa=new Set;function Xh(t,r,o){var n=os(t),i=t,s=!Yn(t),d=r.attrs,u=d===void 0?Cn:d,l=r.componentId,h=l===void 0?(function(b,w){var _=typeof b!="string"?"sc":qs(b);Qn[_]=(Qn[_]||0)+1;var f="".concat(_,"-").concat(Zl(kn+_+Qn[_]));return w?"".concat(w,"-").concat(f):f})(r.displayName,r.parentComponentId):l,c=r.displayName,g=c===void 0?(function(b){return Yn(b)?"styled.".concat(b):"Styled(".concat(Jl(b),")")})(t):c,m=r.displayName&&r.componentId?"".concat(qs(r.displayName),"-").concat(r.componentId):r.componentId||h,x=n&&i.attrs?i.attrs.concat(u).filter(Boolean):u,v=r.shouldForwardProp;if(n&&i.shouldForwardProp){var S=i.shouldForwardProp;if(r.shouldForwardProp){var E=r.shouldForwardProp;v=function(b,w){return S(b,w)&&E(b,w)}}else v=S}var k=new Jh(o,m,n?i.componentStyle:void 0);function j(b,w){return(function(_,f,C){var y=_.attrs,$=_.componentStyle,I=_.defaultProps,O=_.foldedComponentIds,R=_.styledComponentId,T=_.target,F=wr?void 0:a.useContext(ld),D=ta(),M=_.shouldForwardProp||D.shouldForwardProp;process.env.NODE_ENV!=="production"&&a.useDebugValue&&a.useDebugValue(R);var L=yh(f,F,I)||Nr,A=(function(ee,me,re){for(var Re,te=st(st({},me),{className:void 0,theme:re}),ae=0;ae<ee.length;ae+=1){var ye=Ur(Re=ee[ae])?Re(te):Re;for(var ge in ye)ge==="className"?te.className=fr(te.className,ye[ge]):ge==="style"?te.style=st(st({},te.style),ye[ge]):te[ge]=ye[ge]}return"className"in me&&typeof me.className=="string"&&(te.className=fr(te.className,me.className)),te})(y,f,L),P=A.as||T,N={};for(var W in A)A[W]===void 0||W[0]==="$"||W==="as"||W==="theme"&&A.theme===L||(W==="forwardedAs"?N.as=A.forwardedAs:M&&!M(W,P)||(N[W]=A[W],M||process.env.NODE_ENV!=="development"||Kp(W)||oa.has(W)||!Li.has(P)||(oa.add(W),console.warn('styled-components: it looks like an unknown prop "'.concat(W,'" 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 H=(function(ee,me){var re=ta(),Re=ee.generateAndInjectStyles(me,re.styleSheet,re.stylis);return process.env.NODE_ENV!=="production"&&a.useDebugValue&&a.useDebugValue(Re.className),Re})($,A),oe=H.className,Z=H.css;process.env.NODE_ENV!=="production"&&_.warnTooManyClasses&&_.warnTooManyClasses(oe);var we=fr(O,R);oe&&(we+=" "+oe),A.className&&(we+=" "+A.className),N[Yn(P)&&!Li.has(P)?"class":"className"]=we,C&&(N.ref=C);var pe=a.createElement(P,N);return wr&&Z?a.createElement(a.Fragment,null,a.createElement("style",{precedence:"styled-components",href:"sc-".concat(R,"-").concat(oe),children:Z}),pe):pe})(z,b,w)}j.displayName=g;var z=a.forwardRef(j);return z.attrs=x,z.componentStyle=k,z.displayName=g,z.shouldForwardProp=v,z.foldedComponentIds=n?fr(i.foldedComponentIds,i.styledComponentId):"",z.styledComponentId=m,z.target=n?i.target:t,Object.defineProperty(z,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(b){this._foldedDefaultProps=n?(function(w){for(var _=[],f=1;f<arguments.length;f++)_[f-1]=arguments[f];for(var C=0,y=_;C<y.length;C++)Fi(w,y[C],!0);return w})({},i.defaultProps,b):b}}),process.env.NODE_ENV!=="production"&&(vh(g,m),z.warnTooManyClasses=(function(b,w){var _={},f=!1;return function(C){if(!f&&(_[C]=!0,Object.keys(_).length>=200)){var y=w?' with the id of "'.concat(w,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(b).concat(y,`.
|
|
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 />`),f=!0,_={}}}})(g,m)),ns(z,function(){return".".concat(z.styledComponentId)}),s&&rd(z,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),z}function na(t,r){for(var o=[t[0]],n=0,i=r.length;n<i;n+=1)o.push(r[n],t[n+1]);return o}var ia=function(t){return Object.assign(t,{isCss:!0})};function
|
|
73
|
+
<Component />`),f=!0,_={}}}})(g,m)),ns(z,function(){return".".concat(z.styledComponentId)}),s&&rd(z,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),z}function na(t,r){for(var o=[t[0]],n=0,i=r.length;n<i;n+=1)o.push(r[n],t[n+1]);return o}var ia=function(t){return Object.assign(t,{isCss:!0})};function Gt(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(Ur(t)||Br(t))return ia(gr(na(Cn,vr([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?gr(n):ia(gr(na(n,r)))}function Wi(t,r,o){if(o===void 0&&(o=Nr),!r)throw Gr(1,r);var n=function(i){for(var s=[],d=1;d<arguments.length;d++)s[d-1]=arguments[d];return t(r,o,Gt.apply(void 0,vr([i],s,!1)))};return n.attrs=function(i){return Wi(t,r,st(st({},o),{attrs:Array.prototype.concat(o.attrs,i).filter(Boolean)}))},n.withConfig=function(i){return Wi(t,r,st(st({},o),i))},n}var dd=function(t){return Wi(Xh,t)},p=dd;Li.forEach(function(t){p[t]=dd(t)});function yt(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=Di(Gt.apply(void 0,vr([t],r,!1))),i=Zl(n);return new Bi(i,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 Co="__sc-".concat(br,"__");process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[Co]||(window[Co]=0),window[Co]===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
|
|
|
@@ -134,12 +134,12 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
134
134
|
*
|
|
135
135
|
* This source code is licensed under the ISC license.
|
|
136
136
|
* See the LICENSE file in the root directory of this source tree.
|
|
137
|
-
*/const gf=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],
|
|
137
|
+
*/const gf=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],rt=ke("Check",gf);/**
|
|
138
138
|
* @license lucide-react v0.474.0 - ISC
|
|
139
139
|
*
|
|
140
140
|
* This source code is licensed under the ISC license.
|
|
141
141
|
* See the LICENSE file in the root directory of this source tree.
|
|
142
|
-
*/const mf=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],
|
|
142
|
+
*/const mf=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],qt=ke("ChevronDown",mf);/**
|
|
143
143
|
* @license lucide-react v0.474.0 - ISC
|
|
144
144
|
*
|
|
145
145
|
* This source code is licensed under the ISC license.
|
|
@@ -224,12 +224,12 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
224
224
|
*
|
|
225
225
|
* This source code is licensed under the ISC license.
|
|
226
226
|
* See the LICENSE file in the root directory of this source tree.
|
|
227
|
-
*/const Df=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],
|
|
227
|
+
*/const Df=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Mt=ke("LoaderCircle",Df);/**
|
|
228
228
|
* @license lucide-react v0.474.0 - ISC
|
|
229
229
|
*
|
|
230
230
|
* This source code is licensed under the ISC license.
|
|
231
231
|
* See the LICENSE file in the root directory of this source tree.
|
|
232
|
-
*/const Ff=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],
|
|
232
|
+
*/const Ff=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],Lt=ke("LogOut",Ff);/**
|
|
233
233
|
* @license lucide-react v0.474.0 - ISC
|
|
234
234
|
*
|
|
235
235
|
* This source code is licensed under the ISC license.
|
|
@@ -244,7 +244,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
244
244
|
*
|
|
245
245
|
* This source code is licensed under the ISC license.
|
|
246
246
|
* See the LICENSE file in the root directory of this source tree.
|
|
247
|
-
*/const Wf=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],
|
|
247
|
+
*/const Wf=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],gt=ke("Plus",Wf);/**
|
|
248
248
|
* @license lucide-react v0.474.0 - ISC
|
|
249
249
|
*
|
|
250
250
|
* This source code is licensed under the ISC license.
|
|
@@ -269,7 +269,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
269
269
|
*
|
|
270
270
|
* This source code is licensed under the ISC license.
|
|
271
271
|
* See the LICENSE file in the root directory of this source tree.
|
|
272
|
-
*/const Kf=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],
|
|
272
|
+
*/const Kf=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],xt=ke("Shield",Kf);/**
|
|
273
273
|
* @license lucide-react v0.474.0 - ISC
|
|
274
274
|
*
|
|
275
275
|
* This source code is licensed under the ISC license.
|
|
@@ -279,12 +279,12 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
279
279
|
*
|
|
280
280
|
* This source code is licensed under the ISC license.
|
|
281
281
|
* See the LICENSE file in the root directory of this source tree.
|
|
282
|
-
*/const Xf=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],
|
|
282
|
+
*/const Xf=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],Ct=ke("Trash2",Xf);/**
|
|
283
283
|
* @license lucide-react v0.474.0 - ISC
|
|
284
284
|
*
|
|
285
285
|
* This source code is licensed under the ISC license.
|
|
286
286
|
* See the LICENSE file in the root directory of this source tree.
|
|
287
|
-
*/const eg=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],
|
|
287
|
+
*/const eg=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Yt=ke("TriangleAlert",eg);/**
|
|
288
288
|
* @license lucide-react v0.474.0 - ISC
|
|
289
289
|
*
|
|
290
290
|
* This source code is licensed under the ISC license.
|
|
@@ -299,7 +299,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
299
299
|
*
|
|
300
300
|
* This source code is licensed under the ISC license.
|
|
301
301
|
* See the LICENSE file in the root directory of this source tree.
|
|
302
|
-
*/const og=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],
|
|
302
|
+
*/const og=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Dt=ke("X",og),le=p.div`
|
|
303
303
|
/* Colors - Light Mode */
|
|
304
304
|
--color-background: #ffffff;
|
|
305
305
|
--color-foreground: #111827;
|
|
@@ -512,7 +512,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
512
512
|
font-size: var(--font-xs);
|
|
513
513
|
display: block;
|
|
514
514
|
text-align: center;
|
|
515
|
-
`;function
|
|
515
|
+
`;function Zt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:i=!1}){const[s,d]=a.useState(new Array(t).fill("")),[u,l]=a.useState(60),[h,c]=a.useState(!1),g=a.useRef([]),m=a.useCallback(()=>{const k=setInterval(()=>{l(j=>j<=1?(c(!0),clearInterval(k),0):j-1)},1e3);return k},[]);a.useEffect(()=>{const k=m();return()=>clearInterval(k)},[m]);const x=async()=>{var k;!h||i||!o||(await o(),c(!1),l(60),d(new Array(t).fill("")),(k=g.current[0])==null||k.focus(),m())},v=(k,j)=>{var _;if(i)return;const z=k.value,b=[...s];b[j]=z.replace(/[^0-9]/g,""),d(b);const w=b.join("");w.length===t&&r(w),z&&j<t-1&&((_=g.current[j+1])==null||_.focus())},S=(k,j)=>{var z;i||k.key==="Backspace"&&!s[j]&&j>0&&((z=g.current[j-1])==null||z.focus())},E=(k,j)=>{var f,C,y;if(i)return;k.preventDefault();const b=k.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(b.length===0)return;const w=[...s];for(let $=0;$<b.length&&j+$<t;$++)w[j+$]=b[$];if(j===0&&b.length===t)for(let $=0;$<t;$++)w[$]=b[$];d(w);const _=w.join("");if(_.length===t)r(_),(f=g.current[t-1])==null||f.focus();else{const $=w.findIndex((I,O)=>O>=j&&!I);if($!==-1)(C=g.current[$])==null||C.focus();else{const I=w.map((O,R)=>O?R:-1).filter(O=>O!==-1).pop();I!==void 0&&I<t-1&&((y=g.current[I+1])==null||y.focus())}}};return e.jsxs(ng,{children:[e.jsx(ig,{children:s.map((k,j)=>e.jsx(sg,{type:"text",maxLength:1,value:k,onChange:z=>v(z.target,j),onKeyDown:z=>S(z,j),onPaste:z=>E(z,j),ref:z=>{g.current[j]=z},disabled:i,autoFocus:j===0},j))}),n&&e.jsx(ag,{children:n}),o&&e.jsx("div",{children:h?e.jsx(cg,{type:"button",onClick:x,disabled:i,children:"Didn't receive a code? Resend"}):e.jsxs(lg,{children:["Resend code in ",u,"s"]})})]})}const xd=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"})]}),vd=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"})]}),yd=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"})}),dg=()=>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"})}),bd=()=>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"})}),wd=()=>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"})]}),ug=()=>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"})}),jd=()=>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"}})]}),Jn={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(vd,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(xd,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(yd,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(dg,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(bd,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(wd,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(ug,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(jd,{})}},pg=p.div`
|
|
516
516
|
display: flex;
|
|
517
517
|
flex-direction: column;
|
|
518
518
|
gap: var(--space-xs);
|
|
@@ -537,11 +537,11 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
537
537
|
font-weight: 400;
|
|
538
538
|
height: 34px;
|
|
539
539
|
|
|
540
|
-
${t=>t.$totalProviders<=6?
|
|
540
|
+
${t=>t.$totalProviders<=6?Gt`
|
|
541
541
|
flex: 1 1 0;
|
|
542
|
-
`:
|
|
542
|
+
`:Gt`
|
|
543
543
|
flex: 0 0 calc((100% - (var(--space-xs) * 5)) / 6);
|
|
544
|
-
${t.$isWide&&
|
|
544
|
+
${t.$isWide&&Gt`
|
|
545
545
|
flex: 0 0 calc((100% - (var(--space-xs) * 3)) / 4);
|
|
546
546
|
`}
|
|
547
547
|
`}
|
|
@@ -556,7 +556,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
556
556
|
height: 16px;
|
|
557
557
|
flex-shrink: 0;
|
|
558
558
|
}
|
|
559
|
-
`,as=({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,i=o();return e.jsx(pg,{children:i.map((s,d)=>e.jsx(hg,{children:s.map((u,l)=>{const h=u.provider;return e.jsxs(fg,{onClick:()=>r(u),type:"button",$isWide:i.length>1&&d<i.length-1,$totalProviders:n,children:[Jn[h].icon,n<3&&e.jsx("span",{children:n===1?Jn[h].fullLabel:Jn[h].shortLabel})]},`${u.provider}-${l}`)})},`row-${d}`))})},
|
|
559
|
+
`,as=({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,i=o();return e.jsx(pg,{children:i.map((s,d)=>e.jsx(hg,{children:s.map((u,l)=>{const h=u.provider;return e.jsxs(fg,{onClick:()=>r(u),type:"button",$isWide:i.length>1&&d<i.length-1,$totalProviders:n,children:[Jn[h].icon,n<3&&e.jsx("span",{children:n===1?Jn[h].fullLabel:Jn[h].shortLabel})]},`${u.provider}-${l}`)})},`row-${d}`))})},vt=({to:t,replace:r,children:o,...n})=>{const{navigate:i}=it(),s=a.useCallback(d=>{d.preventDefault(),i(t,{replace:r})},[t,r,i]);return e.jsx("a",{href:t,onClick:s,...n,children:o})},gg={sm:"36rem"},X=p.input`
|
|
560
560
|
padding: var(--space-sm) var(--space-md);
|
|
561
561
|
width: 100%;
|
|
562
562
|
height: 36px;
|
|
@@ -740,14 +740,14 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
740
740
|
width: auto;
|
|
741
741
|
height: auto;
|
|
742
742
|
object-fit: contain;
|
|
743
|
-
`;function Me(){var i;const{deployment:t}=je(),[r,o]=a.useState(!1),n=(i=t==null?void 0:t.ui_settings)==null?void 0:i.logo_image_url;return!n||r?null:e.jsx(kg,{children:e.jsx(Cg,{children:e.jsx(Sg,{src:n,alt:"Logo",onError:()=>o(!0)})})})}const $g=
|
|
743
|
+
`;function Me(){var i;const{deployment:t}=je(),[r,o]=a.useState(!1),n=(i=t==null?void 0:t.ui_settings)==null?void 0:i.logo_image_url;return!n||r?null:e.jsx(kg,{children:e.jsx(Cg,{children:e.jsx(Sg,{src:n,alt:"Logo",onError:()=>o(!0)})})})}const $g=yt`
|
|
744
744
|
from {
|
|
745
745
|
transform: rotate(0deg);
|
|
746
746
|
}
|
|
747
747
|
to {
|
|
748
748
|
transform: rotate(360deg);
|
|
749
749
|
}
|
|
750
|
-
`,
|
|
750
|
+
`,St={sm:"36rem"},So=p.div`
|
|
751
751
|
max-width: 380px;
|
|
752
752
|
width: 380px;
|
|
753
753
|
padding: var(--space-3xl);
|
|
@@ -755,7 +755,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
755
755
|
border-radius: var(--radius-lg);
|
|
756
756
|
box-shadow: 0 4px 12px var(--color-shadow);
|
|
757
757
|
|
|
758
|
-
@media (max-width: ${
|
|
758
|
+
@media (max-width: ${St.sm}) {
|
|
759
759
|
max-width: 100%;
|
|
760
760
|
padding: var(--space-lg);
|
|
761
761
|
border-radius: 0;
|
|
@@ -775,7 +775,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
775
775
|
margin-bottom: var(--space-2xl);
|
|
776
776
|
position: relative;
|
|
777
777
|
|
|
778
|
-
@media (max-width: ${
|
|
778
|
+
@media (max-width: ${St.sm}) {
|
|
779
779
|
margin-bottom: var(--space-md);
|
|
780
780
|
}
|
|
781
781
|
`,ei=p.h1`
|
|
@@ -785,7 +785,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
785
785
|
margin-bottom: var(--space-xs);
|
|
786
786
|
margin-top: 0;
|
|
787
787
|
|
|
788
|
-
@media (max-width: ${
|
|
788
|
+
@media (max-width: ${St.sm}) {
|
|
789
789
|
font-size: var(--font-md);
|
|
790
790
|
}
|
|
791
791
|
`,ca=p.p`
|
|
@@ -793,7 +793,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
793
793
|
font-size: var(--font-xs);
|
|
794
794
|
margin: 0;
|
|
795
795
|
|
|
796
|
-
@media (max-width: ${
|
|
796
|
+
@media (max-width: ${St.sm}) {
|
|
797
797
|
font-size: var(--font-2xs);
|
|
798
798
|
}
|
|
799
799
|
`,zg=p.div`
|
|
@@ -811,7 +811,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
811
811
|
background: var(--color-divider);
|
|
812
812
|
}
|
|
813
813
|
|
|
814
|
-
@media (max-width: ${
|
|
814
|
+
@media (max-width: ${St.sm}) {
|
|
815
815
|
margin: var(--space-md) 0;
|
|
816
816
|
}
|
|
817
817
|
`,Eg=p.span`
|
|
@@ -825,7 +825,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
825
825
|
flex-direction: column;
|
|
826
826
|
gap: var(--space-lg);
|
|
827
827
|
|
|
828
|
-
@media (max-width: ${
|
|
828
|
+
@media (max-width: ${St.sm}) {
|
|
829
829
|
gap: 1rem;
|
|
830
830
|
}
|
|
831
831
|
`,Pg=p.div`
|
|
@@ -833,7 +833,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
833
833
|
grid-template-columns: ${t=>t.$isBothEnabled?"1fr 1fr":"1fr"};
|
|
834
834
|
gap: var(--space-sm);
|
|
835
835
|
|
|
836
|
-
@media (max-width: ${
|
|
836
|
+
@media (max-width: ${St.sm}) {
|
|
837
837
|
grid-template-columns: 1fr;
|
|
838
838
|
gap: 0.5rem;
|
|
839
839
|
}
|
|
@@ -847,7 +847,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
847
847
|
font-weight: 400;
|
|
848
848
|
color: var(--color-foreground);
|
|
849
849
|
|
|
850
|
-
@media (max-width: ${
|
|
850
|
+
@media (max-width: ${St.sm}) {
|
|
851
851
|
font-size: 0.75rem;
|
|
852
852
|
}
|
|
853
853
|
`,Rg=p.div`
|
|
@@ -879,7 +879,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
879
879
|
cursor: not-allowed;
|
|
880
880
|
}
|
|
881
881
|
|
|
882
|
-
@media (max-width: ${
|
|
882
|
+
@media (max-width: ${St.sm}) {
|
|
883
883
|
padding: 0.5rem 0.875rem;
|
|
884
884
|
font-size: 0.8125rem;
|
|
885
885
|
}
|
|
@@ -889,7 +889,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
889
889
|
font-size: var(--font-xs);
|
|
890
890
|
color: var(--color-secondary-text);
|
|
891
891
|
|
|
892
|
-
@media (max-width: ${
|
|
892
|
+
@media (max-width: ${St.sm}) {
|
|
893
893
|
margin-top: 1rem;
|
|
894
894
|
font-size: 0.75rem;
|
|
895
895
|
}
|
|
@@ -925,7 +925,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
925
925
|
`,Er=p.span`
|
|
926
926
|
color: var(--color-danger);
|
|
927
927
|
margin-left: 2px;
|
|
928
|
-
`;function Mg(){var H,oe,Z,we,pe,ee,me,re,Pe,te,ae,ye,ge,Q,q,K,ue;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=wl(),{signIn:i}=Mr("oauth"),{deployment:s}=je(),{navigate:d}=nt(),{session:u,refetch:l,loading:h}=Be(),[c,g]=a.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=a.useState({}),[v,S]=a.useState(!1),[E,k]=a.useState(void 0),[j,z]=a.useState(null),[b,w]=a.useState(null),[_,f]=a.useState(!1),C=((H=s==null?void 0:s.restrictions)==null?void 0:H.sign_up_mode)==="restricted",y=((oe=s==null?void 0:s.restrictions)==null?void 0:oe.sign_up_mode)==="waitlist",$=((we=(Z=s==null?void 0:s.auth_settings)==null?void 0:Z.multi_session_support)==null?void 0:we.enabled)??!1;a.useEffect(()=>{var xe;if(!h&&(u!=null&&u.active_signin)&&!$&&!_){f(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");Y||(Y=((xe=s==null?void 0:s.ui_settings)==null?void 0:xe.after_signin_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y&&d(Y)}},[u,h,$,s,d,_]),a.useEffect(()=>{var he;if(!s)return;const Y=new URLSearchParams(window.location.search).get("invite_token");if(y&&!Y){f(!0);const V=((he=s.ui_settings)==null?void 0:he.waitlist_page_url)||`https://${s.frontend_host}/waitlist`;d(V);return}Y&&!j&&r&&(w(Y),r.validateDeploymentInvitation(Y).then(V=>{z(V),V.valid&&g(be=>({...be,first_name:V.first_name||be.first_name,last_name:V.last_name||be.last_name,email:V.email||be.email}))}).catch(V=>{console.error("Failed to validate invitation:",V)}))},[s,y,d,j,r]);const[I,O]=a.useState(!1),[R,T]=a.useState(""),F=xe=>{let{name:Y,value:he}=xe.target;Y==="phone_number"?he=he.replace(/[^0-9-]/g,""):Y==="email"&&(he=he.toLowerCase()),g(V=>({...V,[Y]:he})),x(V=>({...V,[Y]:""}))},D=()=>{g({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),O(!1),T(""),n()},M=async xe=>{if(xe.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",P),console.log("Form data:",c),t||v)return;const Y={},he=/^[a-zA-Z]{3,30}$/,V=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,be=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Ze=/^\d{7,15}$/,lt=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(P!=null&&P.first_name.enabled&&(P!=null&&P.first_name.required&&!c.first_name?Y.first_name="First name is required":c.first_name&&!he.test(c.first_name)&&(Y.first_name="Invalid name")),P!=null&&P.last_name.enabled&&(P!=null&&P.last_name.required&&!c.last_name?Y.last_name="Last name is required":c.last_name&&!he.test(c.last_name)&&(Y.last_name="Invalid last name")),P!=null&&P.username.enabled&&(P!=null&&P.username.required&&!c.username?Y.username="Username is required":c.username&&!V.test(c.username)&&(Y.username="Username must be 3-20 characters")),P!=null&&P.email_address.enabled&&(P!=null&&P.email_address.required&&!c.email?Y.email="Email address is required":c.email&&!be.test(c.email)&&(Y.email="Invalid email address")),P!=null&&P.phone_number.enabled&&(P!=null&&P.phone_number.required&&!c.phone_number?Y.phone_number="Phone number is required":c.phone_number&&!Ze.test(c.phone_number)&&(Y.phone_number="Phone number must contain 7-15 digits")),P!=null&&P.password.enabled&&(c.password?lt.test(c.password)||(Y.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):Y.password="Password is required"),x(Y),Object.keys(Y).length>0){console.log("Signup validation failed. Errors:",Y);return}console.log("Signup validation passed"),S(!0);try{const G={...c};c.phone_number&&E&&(G.phone_country_code=E),b&&(G.invite_token=b),console.log("Submitting signup data:",G),console.log("Phone number:",G.phone_number),console.log("Phone country code:",G.phone_country_code),await r.create(G)}catch(G){x({submit:G.message})}finally{S(!1)}},L=async xe=>{if(!(t||v)){S(!0);try{const he=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:V}=await i.create({provider:xe.provider,redirectUri:he});V&&typeof V=="object"&&"oauth_url"in V&&(window.location.href=V.oauth_url)}catch(Y){x({submit:Y.message})}finally{S(!1)}}},A=(s==null?void 0:s.social_connections.filter(xe=>xe.enabled))||[],P=s==null?void 0:s.auth_settings,N=!!((pe=P==null?void 0:P.first_name)!=null&&pe.enabled&&((ee=P==null?void 0:P.last_name)!=null&&ee.enabled)),W=async xe=>{var he;if(xe.preventDefault(),t||v)return;S(!0);const Y={};if(!R){Y.otp="OTP code is required",x(Y),S(!1);return}x(Y);try{const V=await r.completeVerification(R);"data"in V&&((he=V.data)!=null&&he.active_signin)&&await l()}catch(V){console.error("Verification failed:",V)}finally{S(!1)}};return a.useEffect(()=>{var xe;if(o){if(o.completed){let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((xe=s==null?void 0:s.ui_settings)==null?void 0:xe.after_signup_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y){let he;try{he=new URL(Y)}catch{he=new URL(Y,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&he.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),d(he.toString())}return}if(!I){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}O(!0)}}},[o,r,I,s,u,d]),h?e.jsx(le,{children:e.jsxs(So,{children:[e.jsx(Me,{}),e.jsx(aa,{children:e.jsx(At,{size:32})})]})}):_?e.jsx(le,{children:e.jsxs(So,{children:[e.jsx(Me,{}),e.jsx(aa,{children:e.jsx(At,{size:32})})]})}):C?e.jsx(le,{children:e.jsxs(So,{children:[e.jsx(Me,{}),e.jsx(Xn,{children:e.jsx(ei,{children:"Sign up Restricted!"})}),e.jsx(Ig,{children:e.jsx(Tg,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Og,{children:e.jsxs(Ag,{children:["Need assistance?"," ",e.jsx(Lg,{href:(me=s==null?void 0:s.ui_settings)!=null&&me.sign_in_page_url?`${s.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(le,{children:e.jsx(So,{children:I?e.jsxs(e.Fragment,{children:[e.jsxs(Xn,{children:[e.jsxs(ei,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ca,{children:(o==null?void 0:o.current_step)==="verify_email"?`${c.email} to continue to ${(re=s==null?void 0:s.ui_settings)==null?void 0:re.app_name}`:`${c.phone_number} to continue to ${(Pe=s==null?void 0:s.ui_settings)==null?void 0:Pe.app_name}`})]}),e.jsxs(la,{style:{gap:"15px"},onSubmit:W,noValidate:!0,children:[e.jsx(Kt,{onComplete:async xe=>{T(xe)},onResend:async()=>{const xe=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:xe})},error:m.otp,isSubmitting:v}),e.jsx(da,{type:"submit",disabled:v||t||!R,children:v?"Verifying...":`Continue to ${(te=s==null?void 0:s.ui_settings)==null?void 0:te.app_name}`})]}),e.jsxs(ua,{children:["Having trouble?"," ",e.jsx(ti,{children:e.jsx(mt,{to:s.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(ti,{onClick:()=>{D()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{}),e.jsxs(Xn,{children:[e.jsx(ei,{children:"Create your account"}),e.jsx(ca,{children:j!=null&&j.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),A.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(as,{connections:A,callback:L}),e.jsx(zg,{children:e.jsx(Eg,{children:"or"})})]}),e.jsxs(la,{onSubmit:M,noValidate:!0,children:[(((ae=P==null?void 0:P.first_name)==null?void 0:ae.enabled)||((ye=P==null?void 0:P.last_name)==null?void 0:ye.enabled))&&e.jsxs(Pg,{$isBothEnabled:N,children:[((ge=P==null?void 0:P.first_name)==null?void 0:ge.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"first_name",children:["First name",((Q=P==null?void 0:P.first_name)==null?void 0:Q.required)&&e.jsx(Er,{children:"*"})]}),e.jsx(X,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:c.first_name,onChange:F,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(rr,{children:m.first_name})]}),((q=P==null?void 0:P.last_name)==null?void 0:q.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"last_name",children:["Last name",((K=P==null?void 0:P.last_name)==null?void 0:K.required)&&e.jsx(Er,{children:"*"})]}),e.jsx(X,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:c.last_name,onChange:F,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(rr,{children:m.last_name})]})]}),(P==null?void 0:P.username.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"username",children:["Username",P.username.required&&e.jsx(Er,{children:"*"})]}),e.jsx(X,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:c.username,onChange:F,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(rr,{children:m.username})]}),(P==null?void 0:P.email_address.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"email",children:["Email address",P.email_address.required&&e.jsx(Er,{children:"*"})]}),e.jsx(X,{type:"email",id:"email",name:"email",maxLength:320,value:c.email,onChange:F,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(j==null?void 0:j.valid)&&!!(j!=null&&j.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(rr,{children:m.email})]}),(P==null?void 0:P.phone_number.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"phone_number",children:["Phone number",P.phone_number.required&&e.jsx(Er,{children:"*"})]}),e.jsx(vo,{value:c.phone_number,onChange:F,error:m.phone_number,countryCode:E,setCountryCode:k}),m.phone_number&&e.jsx(rr,{children:m.phone_number})]}),(P==null?void 0:P.password.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"password",children:["Password",P.password.required&&e.jsx(Er,{children:"*"})]}),e.jsx(Rg,{children:e.jsx(X,{type:"password",id:"password",name:"password",value:c.password,onChange:F,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(rr,{children:m.password})]}),m.submit&&e.jsx(rr,{children:m.submit}),e.jsx(da,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(ua,{children:["Already have an account?"," ",e.jsx(ti,{children:e.jsx(mt,{to:`${(ue=s.ui_settings)==null?void 0:ue.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const _d=a.createContext(void 0),kd=()=>{const t=a.useContext(_d);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Dg=p.div`
|
|
928
|
+
`;function Mg(){var H,oe,Z,we,pe,ee,me,re,Re,te,ae,ye,ge,Q,q,K,ue;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=wl(),{signIn:i}=Mr("oauth"),{deployment:s}=je(),{navigate:d}=it(),{session:u,refetch:l,loading:h}=Be(),[c,g]=a.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=a.useState({}),[v,S]=a.useState(!1),[E,k]=a.useState(void 0),[j,z]=a.useState(null),[b,w]=a.useState(null),[_,f]=a.useState(!1),C=((H=s==null?void 0:s.restrictions)==null?void 0:H.sign_up_mode)==="restricted",y=((oe=s==null?void 0:s.restrictions)==null?void 0:oe.sign_up_mode)==="waitlist",$=((we=(Z=s==null?void 0:s.auth_settings)==null?void 0:Z.multi_session_support)==null?void 0:we.enabled)??!1;a.useEffect(()=>{var xe;if(!h&&(u!=null&&u.active_signin)&&!$&&!_){f(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");Y||(Y=((xe=s==null?void 0:s.ui_settings)==null?void 0:xe.after_signin_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y&&d(Y)}},[u,h,$,s,d,_]),a.useEffect(()=>{var he;if(!s)return;const Y=new URLSearchParams(window.location.search).get("invite_token");if(y&&!Y){f(!0);const V=((he=s.ui_settings)==null?void 0:he.waitlist_page_url)||`https://${s.frontend_host}/waitlist`;d(V);return}Y&&!j&&r&&(w(Y),r.validateDeploymentInvitation(Y).then(V=>{z(V),V.valid&&g(be=>({...be,first_name:V.first_name||be.first_name,last_name:V.last_name||be.last_name,email:V.email||be.email}))}).catch(V=>{console.error("Failed to validate invitation:",V)}))},[s,y,d,j,r]);const[I,O]=a.useState(!1),[R,T]=a.useState(""),F=xe=>{let{name:Y,value:he}=xe.target;Y==="phone_number"?he=he.replace(/[^0-9-]/g,""):Y==="email"&&(he=he.toLowerCase()),g(V=>({...V,[Y]:he})),x(V=>({...V,[Y]:""}))},D=()=>{g({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),O(!1),T(""),n()},M=async xe=>{if(xe.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",P),console.log("Form data:",c),t||v)return;const Y={},he=/^[a-zA-Z]{3,30}$/,V=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,be=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Je=/^\d{7,15}$/,dt=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(P!=null&&P.first_name.enabled&&(P!=null&&P.first_name.required&&!c.first_name?Y.first_name="First name is required":c.first_name&&!he.test(c.first_name)&&(Y.first_name="Invalid name")),P!=null&&P.last_name.enabled&&(P!=null&&P.last_name.required&&!c.last_name?Y.last_name="Last name is required":c.last_name&&!he.test(c.last_name)&&(Y.last_name="Invalid last name")),P!=null&&P.username.enabled&&(P!=null&&P.username.required&&!c.username?Y.username="Username is required":c.username&&!V.test(c.username)&&(Y.username="Username must be 3-20 characters")),P!=null&&P.email_address.enabled&&(P!=null&&P.email_address.required&&!c.email?Y.email="Email address is required":c.email&&!be.test(c.email)&&(Y.email="Invalid email address")),P!=null&&P.phone_number.enabled&&(P!=null&&P.phone_number.required&&!c.phone_number?Y.phone_number="Phone number is required":c.phone_number&&!Je.test(c.phone_number)&&(Y.phone_number="Phone number must contain 7-15 digits")),P!=null&&P.password.enabled&&(c.password?dt.test(c.password)||(Y.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):Y.password="Password is required"),x(Y),Object.keys(Y).length>0){console.log("Signup validation failed. Errors:",Y);return}console.log("Signup validation passed"),S(!0);try{const G={...c};c.phone_number&&E&&(G.phone_country_code=E),b&&(G.invite_token=b),console.log("Submitting signup data:",G),console.log("Phone number:",G.phone_number),console.log("Phone country code:",G.phone_country_code),await r.create(G)}catch(G){x({submit:G.message})}finally{S(!1)}},L=async xe=>{if(!(t||v)){S(!0);try{const he=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:V}=await i.create({provider:xe.provider,redirectUri:he});V&&typeof V=="object"&&"oauth_url"in V&&(window.location.href=V.oauth_url)}catch(Y){x({submit:Y.message})}finally{S(!1)}}},A=(s==null?void 0:s.social_connections.filter(xe=>xe.enabled))||[],P=s==null?void 0:s.auth_settings,N=!!((pe=P==null?void 0:P.first_name)!=null&&pe.enabled&&((ee=P==null?void 0:P.last_name)!=null&&ee.enabled)),W=async xe=>{var he;if(xe.preventDefault(),t||v)return;S(!0);const Y={};if(!R){Y.otp="OTP code is required",x(Y),S(!1);return}x(Y);try{const V=await r.completeVerification(R);"data"in V&&((he=V.data)!=null&&he.active_signin)&&await l()}catch(V){console.error("Verification failed:",V)}finally{S(!1)}};return a.useEffect(()=>{var xe;if(o){if(o.completed){let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((xe=s==null?void 0:s.ui_settings)==null?void 0:xe.after_signup_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y){let he;try{he=new URL(Y)}catch{he=new URL(Y,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&he.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),d(he.toString())}return}if(!I){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}O(!0)}}},[o,r,I,s,u,d]),h?e.jsx(le,{children:e.jsxs(So,{children:[e.jsx(Me,{}),e.jsx(aa,{children:e.jsx(Mt,{size:32})})]})}):_?e.jsx(le,{children:e.jsxs(So,{children:[e.jsx(Me,{}),e.jsx(aa,{children:e.jsx(Mt,{size:32})})]})}):C?e.jsx(le,{children:e.jsxs(So,{children:[e.jsx(Me,{}),e.jsx(Xn,{children:e.jsx(ei,{children:"Sign up Restricted!"})}),e.jsx(Ig,{children:e.jsx(Tg,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Og,{children:e.jsxs(Ag,{children:["Need assistance?"," ",e.jsx(Lg,{href:(me=s==null?void 0:s.ui_settings)!=null&&me.sign_in_page_url?`${s.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(le,{children:e.jsx(So,{children:I?e.jsxs(e.Fragment,{children:[e.jsxs(Xn,{children:[e.jsxs(ei,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ca,{children:(o==null?void 0:o.current_step)==="verify_email"?`${c.email} to continue to ${(re=s==null?void 0:s.ui_settings)==null?void 0:re.app_name}`:`${c.phone_number} to continue to ${(Re=s==null?void 0:s.ui_settings)==null?void 0:Re.app_name}`})]}),e.jsxs(la,{style:{gap:"15px"},onSubmit:W,noValidate:!0,children:[e.jsx(Zt,{onComplete:async xe=>{T(xe)},onResend:async()=>{const xe=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:xe})},error:m.otp,isSubmitting:v}),e.jsx(da,{type:"submit",disabled:v||t||!R,children:v?"Verifying...":`Continue to ${(te=s==null?void 0:s.ui_settings)==null?void 0:te.app_name}`})]}),e.jsxs(ua,{children:["Having trouble?"," ",e.jsx(ti,{children:e.jsx(vt,{to:s.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(ti,{onClick:()=>{D()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Me,{}),e.jsxs(Xn,{children:[e.jsx(ei,{children:"Create your account"}),e.jsx(ca,{children:j!=null&&j.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),A.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(as,{connections:A,callback:L}),e.jsx(zg,{children:e.jsx(Eg,{children:"or"})})]}),e.jsxs(la,{onSubmit:M,noValidate:!0,children:[(((ae=P==null?void 0:P.first_name)==null?void 0:ae.enabled)||((ye=P==null?void 0:P.last_name)==null?void 0:ye.enabled))&&e.jsxs(Pg,{$isBothEnabled:N,children:[((ge=P==null?void 0:P.first_name)==null?void 0:ge.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"first_name",children:["First name",((Q=P==null?void 0:P.first_name)==null?void 0:Q.required)&&e.jsx(Er,{children:"*"})]}),e.jsx(X,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:c.first_name,onChange:F,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(rr,{children:m.first_name})]}),((q=P==null?void 0:P.last_name)==null?void 0:q.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"last_name",children:["Last name",((K=P==null?void 0:P.last_name)==null?void 0:K.required)&&e.jsx(Er,{children:"*"})]}),e.jsx(X,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:c.last_name,onChange:F,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(rr,{children:m.last_name})]})]}),(P==null?void 0:P.username.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"username",children:["Username",P.username.required&&e.jsx(Er,{children:"*"})]}),e.jsx(X,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:c.username,onChange:F,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(rr,{children:m.username})]}),(P==null?void 0:P.email_address.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"email",children:["Email address",P.email_address.required&&e.jsx(Er,{children:"*"})]}),e.jsx(X,{type:"email",id:"email",name:"email",maxLength:320,value:c.email,onChange:F,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(j==null?void 0:j.valid)&&!!(j!=null&&j.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(rr,{children:m.email})]}),(P==null?void 0:P.phone_number.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"phone_number",children:["Phone number",P.phone_number.required&&e.jsx(Er,{children:"*"})]}),e.jsx(vo,{value:c.phone_number,onChange:F,error:m.phone_number,countryCode:E,setCountryCode:k}),m.phone_number&&e.jsx(rr,{children:m.phone_number})]}),(P==null?void 0:P.password.enabled)&&e.jsxs($r,{children:[e.jsxs(zr,{htmlFor:"password",children:["Password",P.password.required&&e.jsx(Er,{children:"*"})]}),e.jsx(Rg,{children:e.jsx(X,{type:"password",id:"password",name:"password",value:c.password,onChange:F,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(rr,{children:m.password})]}),m.submit&&e.jsx(rr,{children:m.submit}),e.jsx(da,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(ua,{children:["Already have an account?"," ",e.jsx(ti,{children:e.jsx(vt,{to:`${(ue=s.ui_settings)==null?void 0:ue.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const _d=a.createContext(void 0),kd=()=>{const t=a.useContext(_d);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Dg=p.div`
|
|
929
929
|
position: fixed;
|
|
930
930
|
inset: 0;
|
|
931
931
|
background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
|
|
@@ -976,7 +976,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
976
976
|
gap: 8px;
|
|
977
977
|
padding: 16px;
|
|
978
978
|
border-top: 1px solid var(--color-border);
|
|
979
|
-
`,Gg=({isOpen:t,onClose:r,children:o})=>{const[n,i]=a.useState(!1);return a.useEffect(()=>{i(!0);const s=d=>{d.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[t,r]),!t||!n?null:xn.createPortal(e.jsx(le,{children:e.jsx(_d.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},Hg=({children:t})=>{const{onClose:r}=kd(),o=a.useRef(null),n=i=>{o.current&&!o.current.contains(i.target)&&(r==null||r())};return e.jsx(Dg,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},qg=({children:t,style:r,className:o})=>e.jsx(Fg,{style:r,className:o,children:t}),Yg=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=kd();return e.jsxs(Ng,{children:[typeof t=="string"?e.jsx(Ug,{children:t}):t,r&&e.jsx(Bg,{onClick:o,children:e.jsx(
|
|
979
|
+
`,Gg=({isOpen:t,onClose:r,children:o})=>{const[n,i]=a.useState(!1);return a.useEffect(()=>{i(!0);const s=d=>{d.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[t,r]),!t||!n?null:xn.createPortal(e.jsx(le,{children:e.jsx(_d.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},Hg=({children:t})=>{const{onClose:r}=kd(),o=a.useRef(null),n=i=>{o.current&&!o.current.contains(i.target)&&(r==null||r())};return e.jsx(Dg,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},qg=({children:t,style:r,className:o})=>e.jsx(Fg,{style:r,className:o,children:t}),Yg=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=kd();return e.jsxs(Ng,{children:[typeof t=="string"?e.jsx(Ug,{children:t}):t,r&&e.jsx(Bg,{onClick:o,children:e.jsx(Dt,{size:18})})]})},Qg=({children:t,style:r,className:o})=>e.jsx(Wg,{style:r,className:o,children:t}),Kg=({children:t})=>e.jsx(Vg,{children:t}),Ee=Object.assign(Gg,{Overlay:Hg,Content:qg,Header:Yg,Body:Qg,Footer:Kg}),Zg=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:i=!0})=>e.jsx(Ee,{isOpen:t,onClose:r,children:e.jsx(Ee.Overlay,{children:e.jsxs(Ee.Content,{children:[o&&e.jsx(Ee.Header,{showCloseButton:i,children:o}),e.jsx(Ee.Body,{children:n})]})})}),Jg=({trigger:t,renderDialog:r})=>{const[o,n]=a.useState(!1),i=()=>n(!0),s=()=>n(!1);return e.jsxs(e.Fragment,{children:[t({onClick:i}),r({isOpen:o,onClose:s})]})},Xg=p.div`
|
|
980
980
|
position: fixed;
|
|
981
981
|
background: var(--color-background);
|
|
982
982
|
border-radius: 8px;
|
|
@@ -988,7 +988,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
988
988
|
display: grid;
|
|
989
989
|
`,em=p.div`
|
|
990
990
|
width: fit-content;
|
|
991
|
-
`,Cd=a.createContext(void 0),Sd=()=>{const t=a.useContext(Cd);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},
|
|
991
|
+
`,Cd=a.createContext(void 0),Sd=()=>{const t=a.useContext(Cd);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},at=({children:t,open:r,openChange:o,style:n})=>{const i=a.useRef(null),[s,d]=a.useState(!1);return a.useEffect(()=>{const u=l=>{i.current&&!i.current.contains(l.target)&&d(!1)};return s&&document.addEventListener("mousedown",u),()=>{document.removeEventListener("mousedown",u)}},[s,o]),a.useEffect(()=>{o==null||o(s)},[s]),a.useEffect(()=>{d(!!r)},[r]),e.jsx(Cd.Provider,{value:{open:s,openChange:u=>d(u)},children:e.jsx(em,{style:n,ref:i,children:t})})},ct=({children:t,style:r})=>{const{open:o}=Sd(),[n,i]=a.useState({top:0,left:0}),[s,d]=a.useState(!1),u=a.useRef(null);return a.useEffect(()=>{o&&u.current?(d(!1),requestAnimationFrame(()=>{var c,g;const l=(c=u.current)==null?void 0:c.parentElement;if(!l)return;const h=l.querySelector("[data-dropdown-trigger]")||l.firstElementChild;if(h&&h!==u.current){const m=h.getBoundingClientRect(),x=(g=u.current)==null?void 0:g.getBoundingClientRect(),v=window.innerWidth,S=window.innerHeight;let E=m.bottom+4,k=m.right-((x==null?void 0:x.width)||200);k<8&&(k=m.left),k+((x==null?void 0:x.width)||200)>v-8&&(k=v-((x==null?void 0:x.width)||200)-8),x&&E+x.height>S-8&&(E=m.top-(x.height+4)),i({top:E,left:k}),d(!0)}})):d(!1)},[o]),o?e.jsx(Xg,{ref:u,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:s?"visible":"hidden",opacity:s?1:0,transition:s?"opacity 0.15s ease-in-out":"none"},children:t}):null},lt=({children:t})=>{const{openChange:r,open:o}=Sd(),n=a.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Oe=p.button`
|
|
992
992
|
width: 100%;
|
|
993
993
|
padding: 8px 12px;
|
|
994
994
|
background: none;
|
|
@@ -1009,7 +1009,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1009
1009
|
height: 1px;
|
|
1010
1010
|
background-color: var(--color-border);
|
|
1011
1011
|
width: 100%;
|
|
1012
|
-
`,
|
|
1012
|
+
`,_t=p.form`
|
|
1013
1013
|
display: flex;
|
|
1014
1014
|
flex-direction: column;
|
|
1015
1015
|
gap: var(--space-md);
|
|
@@ -1022,7 +1022,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1022
1022
|
text-align: left;
|
|
1023
1023
|
font-weight: 400;
|
|
1024
1024
|
color: var(--color-foreground);
|
|
1025
|
-
`,tm=
|
|
1025
|
+
`,tm=yt`
|
|
1026
1026
|
0% {
|
|
1027
1027
|
transform: rotate(0deg);
|
|
1028
1028
|
}
|
|
@@ -1073,7 +1073,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1073
1073
|
left: ${t=>t.checked?"20px":"2px"};
|
|
1074
1074
|
transition: left 0.2s ease;
|
|
1075
1075
|
}
|
|
1076
|
-
`,jr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(nm,{children:[e.jsx(im,{type:"checkbox",checked:t,onChange:o}),e.jsx(sm,{checked:t})]})},uo=(t=!1)=>{const[r,o]=a.useState(t),n=a.useCallback(()=>{o(!0)},[]),i=a.useCallback(()=>{o(!1)},[]),s=a.useCallback(()=>{o(d=>!d)},[]);return{isOpen:r,open:n,close:i,toggle:s}},
|
|
1076
|
+
`,jr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(nm,{children:[e.jsx(im,{type:"checkbox",checked:t,onChange:o}),e.jsx(sm,{checked:t})]})},uo=(t=!1)=>{const[r,o]=a.useState(t),n=a.useCallback(()=>{o(!0)},[]),i=a.useCallback(()=>{o(!1)},[]),s=a.useCallback(()=>{o(d=>!d)},[]);return{isOpen:r,open:n,close:i,toggle:s}},Ut=({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(qf,{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"}})]}),B=p.button`
|
|
1077
1077
|
width: ${t=>t.$fullWidth?"100%":"auto"};
|
|
1078
1078
|
padding: ${t=>t.$size==="sm"?"4px 12px":t.$size==="lg"?"12px 24px":"var(--space-sm) var(--space-md)"};
|
|
1079
1079
|
border: 1px solid transparent;
|
|
@@ -1101,7 +1101,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1101
1101
|
cursor: not-allowed;
|
|
1102
1102
|
}
|
|
1103
1103
|
|
|
1104
|
-
${t=>t.$outline&&
|
|
1104
|
+
${t=>t.$outline&&Gt`
|
|
1105
1105
|
background-color: transparent;
|
|
1106
1106
|
color: var(--color-foreground);
|
|
1107
1107
|
border: 1px solid var(--color-border);
|
|
@@ -1112,7 +1112,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1112
1112
|
}
|
|
1113
1113
|
`}
|
|
1114
1114
|
|
|
1115
|
-
${t=>t.$destructive&&
|
|
1115
|
+
${t=>t.$destructive&&Gt`
|
|
1116
1116
|
background-color: var(--color-error-background);
|
|
1117
1117
|
color: var(--color-error);
|
|
1118
1118
|
border-color: var(--color-error-border);
|
|
@@ -1214,7 +1214,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1214
1214
|
text-transform: uppercase;
|
|
1215
1215
|
color: var(--color-muted);
|
|
1216
1216
|
background: var(--color-background-hover);
|
|
1217
|
-
`,zn=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:i=!1,searchable:s=!1,width:d,name:u,id:l,groupsEnabled:h=!1,className:c})=>{const[g,m]=a.useState(!1),[x,v]=a.useState(""),S=a.useRef(null),E=a.useRef(null),k=h&&"options"in t[0],z=(k?t.flatMap(f=>f.options):t).find(f=>f.value===r),b=x?k?t.map(f=>({...f,options:f.options.filter(C=>C.label.toLowerCase().includes(x.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(x.toLowerCase())):t,w=(f,C=!1)=>{C||(o(f),m(!1),v(""))},_=()=>{i||m(!g)};return a.useEffect(()=>{g&&s&&E.current&&setTimeout(()=>{var f;(f=E.current)==null||f.focus()},10)},[g,s]),a.useEffect(()=>{const f=C=>{S.current&&!S.current.contains(C.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs($d,{ref:S,style:{width:d},className:c,children:[e.jsxs(zd,{type:"button",onClick:_,disabled:i,"aria-haspopup":"listbox","aria-expanded":g,id:l,children:[z?z.label:e.jsx(Rd,{children:n}),g?e.jsx(hd,{size:16}):e.jsx(
|
|
1217
|
+
`,zn=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:i=!1,searchable:s=!1,width:d,name:u,id:l,groupsEnabled:h=!1,className:c})=>{const[g,m]=a.useState(!1),[x,v]=a.useState(""),S=a.useRef(null),E=a.useRef(null),k=h&&"options"in t[0],z=(k?t.flatMap(f=>f.options):t).find(f=>f.value===r),b=x?k?t.map(f=>({...f,options:f.options.filter(C=>C.label.toLowerCase().includes(x.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(x.toLowerCase())):t,w=(f,C=!1)=>{C||(o(f),m(!1),v(""))},_=()=>{i||m(!g)};return a.useEffect(()=>{g&&s&&E.current&&setTimeout(()=>{var f;(f=E.current)==null||f.focus()},10)},[g,s]),a.useEffect(()=>{const f=C=>{S.current&&!S.current.contains(C.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs($d,{ref:S,style:{width:d},className:c,children:[e.jsxs(zd,{type:"button",onClick:_,disabled:i,"aria-haspopup":"listbox","aria-expanded":g,id:l,children:[z?z.label:e.jsx(Rd,{children:n}),g?e.jsx(hd,{size:16}):e.jsx(qt,{size:16})]}),e.jsxs(Ed,{isOpen:g,role:"listbox",children:[s&&e.jsx(Pd,{ref:E,type:"text",placeholder:"Search...",value:x,onChange:f=>v(f.target.value),onClick:f=>f.stopPropagation()}),k?b.map((f,C)=>e.jsxs(a.Fragment,{children:[e.jsx(Id,{children:f.label}),f.options.length===0?e.jsx(gn,{children:"No options available"}):f.options.map(y=>e.jsxs(fn,{isSelected:y.value===r,disabled:y.disabled,onClick:()=>w(y.value,y.disabled),role:"option","aria-selected":y.value===r,children:[y.label,y.value===r&&e.jsx(rt,{size:16})]},y.value))]},`group-${C}`)):e.jsx(e.Fragment,{children:b.length===0?e.jsx(gn,{children:"No options available"}):b.map(f=>e.jsxs(fn,{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(rt,{size:16})]},f.value))})]}),u&&e.jsx("input",{type:"hidden",name:u,value:r||""})]})},Td=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:i=!1,searchable:s=!1,width:d,name:u,id:l,groupsEnabled:h=!1,className:c})=>{const[g,m]=a.useState(!1),[x,v]=a.useState(""),S=a.useRef(null),E=a.useRef(null),k=h&&"options"in t[0],z=(k?t.flatMap(f=>f.options):t).filter(f=>r.includes(f.value)),b=x?k?t.map(f=>({...f,options:f.options.filter(C=>C.label.toLowerCase().includes(x.toLowerCase()))})).filter(f=>f.options.length>0):t.filter(f=>f.label.toLowerCase().includes(x.toLowerCase())):t,w=(f,C=!1)=>{C||(r.includes(f)?o(r.filter(y=>y!==f)):o([...r,f]))},_=()=>{i||m(!g)};return a.useEffect(()=>{g&&s&&E.current&&setTimeout(()=>{var f;(f=E.current)==null||f.focus()},10)},[g,s]),a.useEffect(()=>{const f=C=>{S.current&&!S.current.contains(C.target)&&(m(!1),v(""))};return document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[]),e.jsxs($d,{ref:S,style:{width:d},className:c,children:[e.jsxs(zd,{type:"button",onClick:_,disabled:i,"aria-haspopup":"listbox","aria-expanded":g,id:l,children:[z.length>0?z.map(f=>f.label).join(", "):e.jsx(Rd,{children:n}),g?e.jsx(hd,{size:16}):e.jsx(qt,{size:16})]}),e.jsxs(Ed,{isOpen:g,role:"listbox",children:[s&&e.jsx(Pd,{ref:E,type:"text",placeholder:"Search...",value:x,onChange:f=>v(f.target.value),onClick:f=>f.stopPropagation()}),k?b.map((f,C)=>e.jsxs(a.Fragment,{children:[e.jsx(Id,{children:f.label}),f.options.length===0?e.jsx(gn,{children:"No options available"}):f.options.map(y=>e.jsxs(fn,{isSelected:r.includes(y.value),disabled:y.disabled,onClick:()=>w(y.value,y.disabled),role:"option","aria-selected":r.includes(y.value),children:[y.label,r.includes(y.value)&&e.jsx(rt,{size:16})]},y.value))]},`group-${C}`)):e.jsx(e.Fragment,{children:b.length===0?e.jsx(gn,{children:"No options available"}):b.map(f=>e.jsxs(fn,{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(rt,{size:16})]},f.value))})]}),u&&e.jsx("input",{type:"hidden",name:u,value:r.join(",")})]})},Od=a.createContext(void 0);function Ad(){const t=a.useContext(Od);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function am({children:t}){const{deployment:r}=je(),[o,n]=a.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[i,s]=a.useState(""),[d,u]=a.useState(!1),[l,h]=a.useState(!1),[c,g]=a.useState(!1),[m,x]=a.useState("identifier"),v=(r==null?void 0:r.social_connections.filter(E=>E.enabled))||[],S=r==null?void 0:r.auth_settings;return e.jsx(Od.Provider,{value:{email:i,showOtherOptions:d,showForgotPassword:l,otpSent:c,setFirstFactor:n,setEmail:s,setShowOtherOptions:u,setShowForgotPassword:h,setOtpSent:g,enabledSocialsProviders:v,authSettings:S,firstFactor:o,signInStep:m,setSignInStep:x},children:t})}const eo=p.button`
|
|
1218
1218
|
width: 100%;
|
|
1219
1219
|
padding: var(--space-sm) var(--space-md);
|
|
1220
1220
|
background: var(--color-input-background);
|
|
@@ -1301,7 +1301,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1301
1301
|
&:hover {
|
|
1302
1302
|
text-decoration: underline;
|
|
1303
1303
|
}
|
|
1304
|
-
`;function pm({onBack:t}){const{deployment:r}=je(),{navigate:o}=
|
|
1304
|
+
`;function pm({onBack:t}){const{deployment:r}=je(),{navigate:o}=it(),[n,i]=a.useState("start"),[s,d]=a.useState(""),[u,l]=a.useState(""),[h,c]=a.useState(""),[g,m]=a.useState(""),[x,v]=a.useState(""),{forgotPassword:S,verifyOtp:E,resetPassword:k}=Ll(),[j,z]=a.useState(!1),[b,w]=a.useState(null),_=async $=>{if($.preventDefault(),!!s){z(!0),w(null);try{await S(s),i("otp")}catch(I){w(I)}finally{z(!1)}}},f=async $=>{if($.preventDefault(),u.length===6){z(!0),w(null);try{const I=await E(s,u);I.data&&(c(I.data.token),i("reset"))}catch(I){w(I)}finally{z(!1)}}},C=async $=>{var I,O;if($.preventDefault(),g===x&&!(g.length<8)){z(!0),w(null);try{const R=await k(h,g);if(R.data){const T=R.data,F=T.signin_attempts&&T.signin_attempts.length>0?T.signin_attempts[T.signin_attempts.length-1]:null;if(F&&!F.completed){const D=(I=r==null?void 0:r.ui_settings)==null?void 0:I.sign_in_page_url;if(D){const M=new URL(D,window.location.origin);M.searchParams.set("signin_attempt_id",F.id),o(M.toString())}else t()}else{const D=((O=r==null?void 0:r.ui_settings)==null?void 0:O.after_signin_redirect_url)||"/";o(D)}}}catch(R){w(R)}finally{z(!1)}}},y=()=>e.jsxs(e.Fragment,{children:[e.jsx(Me,{}),e.jsx($o,{children:e.jsx(zo,{children:"Forgot Password"})}),e.jsx(lm,{onClick:()=>i("email"),disabled:j,children:"Reset your password"}),e.jsx(dm,{children:e.jsx(um,{children:"Or, sign in with another method"})}),e.jsx(Ld,{}),e.jsxs(Eo,{children:[e.jsxs(to,{children:["Unable to reset password? ",e.jsx(ro,{href:"/contact",children:"Get help"})]}),e.jsx(to,{style:{marginTop:"var(--space-sm)"},children:e.jsx(ro,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(le,{children:e.jsxs(cm,{children:[n==="start"&&y(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Me,{}),e.jsxs($o,{children:[e.jsx(zo,{children:"Forgot Password"}),e.jsx(ri,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(_t,{onSubmit:_,noValidate:!0,children:[e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"email",children:"Email Address"}),e.jsx(X,{type:"email",id:"email",value:s,onChange:$=>d($.target.value),placeholder:"Enter your email",required:!0})]}),b&&e.jsx(oi,{children:b.message}),e.jsx(B,{type:"submit",$fullWidth:!0,$size:"sm",disabled:j,style:{marginTop:"var(--space-md)"},children:j?"Sending...":"Send Code"})]}),e.jsx(Eo,{children:e.jsx(to,{style:{marginTop:"var(--space-sm)"},children:e.jsx(ro,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Me,{}),e.jsxs($o,{children:[e.jsx(zo,{children:"Enter Verification Code"}),e.jsxs(ri,{children:["We've sent a 6-digit code to ",s,". Please enter it below."]})]}),e.jsxs(_t,{onSubmit:f,noValidate:!0,children:[e.jsx(Zt,{onComplete:$=>l($),isSubmitting:j,error:b==null?void 0:b.message,onResend:async()=>{await S(s)}}),b&&e.jsx(oi,{children:b.message}),e.jsx(B,{type:"submit",$fullWidth:!0,$size:"sm",disabled:j||u.length!==6,style:{marginTop:"var(--space-md)"},children:j?"Verifying...":"Verify"})]}),e.jsx(Eo,{children:e.jsx(to,{style:{marginTop:"var(--space-sm)"},children:e.jsx(ro,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Me,{}),e.jsxs($o,{children:[e.jsx(zo,{children:"Reset Password"}),e.jsx(ri,{children:"Create a new password for your account."})]}),e.jsxs(_t,{onSubmit:C,noValidate:!0,children:[e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"password",children:"New Password"}),e.jsx(X,{type:"password",id:"password",value:g,onChange:$=>m($.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(X,{type:"password",id:"confirmPassword",value:x,onChange:$=>v($.target.value),placeholder:"Confirm new password",required:!0})]}),b&&e.jsx(oi,{children:b.message}),e.jsx(B,{type:"submit",$fullWidth:!0,$size:"sm",disabled:j,style:{marginTop:"var(--space-md)"},children:j?"Resetting...":"Reset Password"})]}),e.jsx(Eo,{children:e.jsx(to,{style:{marginTop:"var(--space-sm)"},children:e.jsx(ro,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const hm=p.div`
|
|
1305
1305
|
max-width: 360px;
|
|
1306
1306
|
width: 360px;
|
|
1307
1307
|
padding: var(--space-2xl);
|
|
@@ -1472,14 +1472,14 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1472
1472
|
}
|
|
1473
1473
|
`,Dm=p(X)`
|
|
1474
1474
|
padding: var(--space-sm) var(--space-md);
|
|
1475
|
-
`;function Dd({onVerify:t,onBack:r,loading:o}){const[n,i]=a.useState(""),[s,d]=a.useState(""),u=h=>{if(h.preventDefault(),n.length!==4){d("Please enter the last 4 digits of your phone number");return}t(n)},l=h=>{const c=h.target.value.replace(/\D/g,"").slice(0,4);i(c),d("")};return e.jsx(le,{children:e.jsxs(Pm,{children:[e.jsx(Me,{}),e.jsxs(Rm,{children:[e.jsx(Im,{children:"Verify Phone"}),e.jsx(Tm,{children:"Enter the last 4 digits of your phone number."})]}),e.jsxs(
|
|
1475
|
+
`;function Dd({onVerify:t,onBack:r,loading:o}){const[n,i]=a.useState(""),[s,d]=a.useState(""),u=h=>{if(h.preventDefault(),n.length!==4){d("Please enter the last 4 digits of your phone number");return}t(n)},l=h=>{const c=h.target.value.replace(/\D/g,"").slice(0,4);i(c),d("")};return e.jsx(le,{children:e.jsxs(Pm,{children:[e.jsx(Me,{}),e.jsxs(Rm,{children:[e.jsx(Im,{children:"Verify Phone"}),e.jsx(Tm,{children:"Enter the last 4 digits of your phone number."})]}),e.jsxs(_t,{onSubmit:u,noValidate:!0,children:[e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(Dm,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:l,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!s,autoFocus:!0}),s&&e.jsx(Om,{children:s})]}),e.jsx(Am,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(Lm,{children:e.jsx(Mm,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const Fm=()=>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"})}),Nm=()=>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"})]}),Um=()=>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"})}),ni=p.div`
|
|
1476
1476
|
max-width: 380px;
|
|
1477
1477
|
width: 380px;
|
|
1478
1478
|
padding: var(--space-2xl);
|
|
1479
1479
|
background: var(--color-background);
|
|
1480
1480
|
border-radius: var(--radius-lg);
|
|
1481
1481
|
box-shadow: 0 4px 12px var(--color-shadow);
|
|
1482
|
-
`,Bm=
|
|
1482
|
+
`,Bm=yt`
|
|
1483
1483
|
from {
|
|
1484
1484
|
transform: rotate(0deg);
|
|
1485
1485
|
}
|
|
@@ -1533,7 +1533,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1533
1533
|
}
|
|
1534
1534
|
`,Gm=p(X)`
|
|
1535
1535
|
padding: var(--space-sm) var(--space-md);
|
|
1536
|
-
`;function Fd({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:i}=je(),[s,d]=a.useState(""),[u,l]=a.useState({}),[h,c]=a.useState(!1),[g,m]=a.useState(null),[x,v]=a.useState(!0),[S,E]=a.useState(!1),[k,j]=a.useState(""),[z,b]=a.useState(!1),{navigate:w}=
|
|
1536
|
+
`;function Fd({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:i}=je(),[s,d]=a.useState(""),[u,l]=a.useState({}),[h,c]=a.useState(!1),[g,m]=a.useState(null),[x,v]=a.useState(!0),[S,E]=a.useState(!1),[k,j]=a.useState(""),[z,b]=a.useState(!1),{navigate:w}=it(),_=(r==null?void 0:r.available_2fa_methods)||[],f=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(Fm,{}),available:_.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(Nm,{}),available:_.includes("phone_otp"),phoneNumber:k},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Um,{}),available:_.includes("backup_code")}].filter(O=>O.available),C=async O=>{m(O),v(!1),O==="phone_otp"&&E(!0)},y=async O=>{var R,T;if(r){c(!0);try{const F=await n({strategy:"phone_otp",lastDigits:O});F&&"data"in F&&((R=F.data)!=null&&R.otp_sent)?((T=F.data)!=null&&T.masked_phone&&j(F.data.masked_phone),E(!1)):l({phone:"Phone number verification failed"})}catch(F){l({phone:F.message})}finally{c(!1)}}},$=async(O,R)=>{if(O.preventDefault(),h)return;const T=R||s,F={};if(T?g==="authenticator"&&T.length!==6?F.code="Authentication code must be 6 digits":g==="phone_otp"&&T.length!==6&&(F.code="SMS code must be 6 digits"):F.code="Verification code is required",l(F),!(Object.keys(F).length>0)){c(!0);try{await o(T)}catch(D){l({submit:D.message})}finally{c(!1)}}},I=O=>{let R=O.target.value;g!=="backup_code"&&(R=R.replace(/\D/g,"").slice(0,6)),d(R),l(T=>({...T,code:""}))};return a.useEffect(()=>{var O;if(r.completed){b(!0);let R=new URLSearchParams(window.location.search).get("redirect_uri");if(R||(R=((O=i==null?void 0:i.ui_settings)==null?void 0:O.after_signin_redirect_url)||null),!R&&(i!=null&&i.frontend_host)&&(R=`https://${i.frontend_host}`),R){let T;try{T=new URL(R)}catch{T=new URL(R,window.location.origin)}(i==null?void 0:i.mode)==="staging"&&T.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),w(T.toString())}return}},[r,i]),z?e.jsx(le,{children:e.jsxs(ni,{children:[e.jsx(Me,{}),e.jsx(Wm,{children:e.jsx(Mt,{size:32})})]})}):x?f.length===0?e.jsx(le,{children:e.jsxs(ni,{children:[e.jsx(Me,{}),e.jsxs(fa,{children:[e.jsx(ga,{children:"Set Up Two-Factor Authentication"}),e.jsx(ma,{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(va,{children:[t&&e.jsx("div",{children:e.jsx(oo,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(oo,{children:e.jsx(vt,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(Md,{methods:f,onSelectMethod:C,onBack:t}):S&&g==="phone_otp"?e.jsx(Dd,{onVerify:y,onBack:()=>{E(!1),v(!0),m(null)},loading:h}):e.jsx(le,{children:e.jsxs(ni,{children:[e.jsx(Me,{}),e.jsxs(fa,{children:[e.jsx(ga,{children:"Two-factor authentication"}),e.jsxs(ma,{children:[g==="authenticator"&&"Enter the 6-digit code from your authenticator app",g==="phone_otp"&&`Enter the 6-digit code sent to your phone ${k}`,g==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(_t,{onSubmit:$,noValidate:!0,children:[g==="backup_code"?e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"code",children:"Backup code"}),e.jsx(Gm,{type:"text",id:"code",name:"code",value:s,onChange:I,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!u.code,autoFocus:!0}),u.code&&e.jsx(xa,{children:u.code})]}):e.jsx(Zt,{onComplete:async O=>{if(d(O),g!=="backup_code"){const R=new Event("submit",{bubbles:!0,cancelable:!0});await $(R,O)}},onResend:g==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:k.slice(-4)})}catch(O){l({submit:O.message})}}:void 0,error:u.code,isSubmitting:h}),e.jsxs("div",{children:[u.submit&&e.jsx(xa,{children:u.submit}),e.jsx(Vm,{type:"submit",disabled:h||!s,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(va,{children:[e.jsx(oo,{onClick:()=>{v(!0),m(null),d(""),l({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(oo,{children:e.jsx(vt,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(oo,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const ii=p.div`
|
|
1537
1537
|
max-width: 380px;
|
|
1538
1538
|
width: 380px;
|
|
1539
1539
|
padding: var(--space-3xl);
|
|
@@ -1598,7 +1598,7 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1598
1598
|
transform: rotate(360deg);
|
|
1599
1599
|
}
|
|
1600
1600
|
}
|
|
1601
|
-
`;function Nd({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:i}){var L,A,P,N,W,H,oe,Z,we;const{deployment:s}=je(),{navigate:d}=
|
|
1601
|
+
`;function Nd({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:i}){var L,A,P,N,W,H,oe,Z,we;const{deployment:s}=je(),{navigate:d}=it(),[u,l]=a.useState({}),[h,c]=a.useState({}),[g,m]=a.useState("US"),[x,v]=a.useState(!1),[S,E]=a.useState(!1),[k,j]=a.useState(null),[z,b]=a.useState(!1),w=k,_=S,f=async pe=>{var ee;E(!0),j(null);try{if(await o(pe)){b(!0);let re=new URLSearchParams(window.location.search).get("redirect_uri");if(re||(re=((ee=s==null?void 0:s.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!re&&(s!=null&&s.frontend_host)&&(re=`https://${s.frontend_host}`),re){let Re;try{Re=new URL(re)}catch{Re=new URL(re,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&Re.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),d(Re.toString())}}}catch(me){const re=me;throw j(re),re}finally{E(!1)}},C=async pe=>{var ee;E(!0),j(null);try{if(await n(pe)){b(!0);let re=new URLSearchParams(window.location.search).get("redirect_uri");if(re||(re=((ee=s==null?void 0:s.ui_settings)==null?void 0:ee.after_signin_redirect_url)||null),!re&&(s!=null&&s.frontend_host)&&(re=`https://${s.frontend_host}`),re){let Re;try{Re=new URL(re)}catch{Re=new URL(re,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&Re.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),d(Re.toString())}}return!0}catch(me){return j(me),!1}finally{E(!1)}};if(z||!t)return e.jsx(le,{children:e.jsxs(ii,{children:[e.jsx(Me,{}),e.jsx(Ym,{children:e.jsx(Mt,{size:32})})]})});const y=t.missing_fields||[],$="Complete Your Profile",I="Please provide the following information to continue",O=s==null?void 0:s.auth_settings,R=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,T=pe=>{const{name:ee,value:me}=pe.target;l(re=>({...re,[ee]:me})),h[ee]&&c(re=>({...re,[ee]:""}))},F=()=>{const pe={};return y.forEach(ee=>{var Re,te,ae,ye,ge;const me=u[ee];let re=!1;switch(ee){case"first_name":re=((Re=O==null?void 0:O.first_name)==null?void 0:Re.enabled)||!1;break;case"last_name":re=((te=O==null?void 0:O.last_name)==null?void 0:te.enabled)||!1;break;case"username":re=((ae=O==null?void 0:O.username)==null?void 0:ae.enabled)||!1;break;case"phone_number":re=((ye=O==null?void 0:O.phone_number)==null?void 0:ye.enabled)||!1;break;case"email_address":re=((ge=O==null?void 0:O.email_address)==null?void 0:ge.enabled)||!1;break;default:re=!0}if(re&&(!me||me.trim()==="")){const Q=ee.replace("_"," ").replace(/\b\w/g,q=>q.toUpperCase());pe[ee]=`${Q} is required`}}),u.username&&y.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(u.username)||(pe.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),u.phone_number&&y.includes("phone_number")&&(/^\d{7,15}$/.test(u.phone_number)||(pe.phone_number="Phone number must contain 7-15 digits")),u.email&&y.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(u.email)||(pe.email_address="Please enter a valid email address")),c(pe),Object.keys(pe).length===0},D=async pe=>{if(pe.preventDefault(),!F())return;const ee={...u};u.phone_number&&g&&(ee.phone_country_code=g),await f(ee)},M=pe=>{const ee=pe.target.value;l(me=>({...me,phone_number:ee})),h.phone_number&&c(me=>({...me,phone_number:""}))};if(R){const pe=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",ee=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",me=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(le,{children:e.jsxs(ii,{children:[e.jsx(Me,{}),e.jsxs(ya,{children:[e.jsx(ba,{children:pe}),e.jsx(wa,{children:ee})]}),e.jsxs(_t,{onSubmit:re=>re.preventDefault(),noValidate:!0,children:[e.jsx(Zt,{onComplete:C,onResend:async()=>{await i({strategy:me})},error:w==null?void 0:w.message,isSubmitting:_}),w&&e.jsx(or,{style:{marginBottom:"var(--space-md)"},children:w.message})]}),e.jsxs(ja,{children:[e.jsx("div",{children:e.jsx(Po,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Po,{children:e.jsx(vt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(le,{children:e.jsxs(ii,{children:[e.jsx(Me,{}),e.jsxs(ya,{children:[e.jsx(ba,{children:$}),e.jsx(wa,{children:I})]}),e.jsxs(_t,{onSubmit:D,noValidate:!0,children:[(y.includes("first_name")||y.includes("last_name"))&&(((L=O==null?void 0:O.first_name)==null?void 0:L.enabled)||((A=O==null?void 0:O.last_name)==null?void 0:A.enabled))&&e.jsxs(Hm,{$isBothEnabled:!!((P=O==null?void 0:O.first_name)!=null&&P.enabled&&((N=O==null?void 0:O.last_name)!=null&&N.enabled)&&y.includes("first_name")&&y.includes("last_name")),children:[y.includes("first_name")&&((W=O==null?void 0:O.first_name)==null?void 0:W.enabled)&&e.jsxs(ie,{children:[e.jsxs(J,{htmlFor:"first_name",children:["First name ",O.first_name.required&&"*"]}),e.jsx(X,{type:"text",id:"first_name",name:"first_name",value:u.first_name||"",onChange:T,placeholder:"Enter your first name","aria-invalid":!!h.first_name,disabled:_,autoComplete:"given-name"}),h.first_name&&e.jsx(or,{children:h.first_name})]}),y.includes("last_name")&&((H=O==null?void 0:O.last_name)==null?void 0:H.enabled)&&e.jsxs(ie,{children:[e.jsxs(J,{htmlFor:"last_name",children:["Last name ",O.last_name.required&&"*"]}),e.jsx(X,{type:"text",id:"last_name",name:"last_name",value:u.last_name||"",onChange:T,placeholder:"Enter your last name","aria-invalid":!!h.last_name,disabled:_,autoComplete:"family-name"}),h.last_name&&e.jsx(or,{children:h.last_name})]})]}),y.includes("username")&&((oe=O==null?void 0:O.username)==null?void 0:oe.enabled)&&e.jsxs(ie,{children:[e.jsxs(J,{htmlFor:"username",children:["Username ",O.username.required&&"*"]}),e.jsx(X,{type:"text",id:"username",name:"username",value:u.username||"",onChange:T,placeholder:"Choose a username","aria-invalid":!!h.username,disabled:_,autoComplete:"username"}),h.username&&e.jsx(or,{children:h.username})]}),y.includes("phone_number")&&((Z=O==null?void 0:O.phone_number)==null?void 0:Z.enabled)&&e.jsxs(ie,{children:[e.jsxs(J,{htmlFor:"phone_number",children:["Phone number ",O.phone_number.required&&"*"]}),e.jsx(vo,{value:u.phone_number||"",onChange:M,error:h.phone_number,countryCode:g,setCountryCode:m}),h.phone_number&&e.jsx(or,{children:h.phone_number})]}),y.includes("email_address")&&((we=O==null?void 0:O.email_address)==null?void 0:we.enabled)&&e.jsxs(ie,{children:[e.jsxs(J,{htmlFor:"email",children:["Email address ",O.email_address.required&&"*"]}),e.jsx(X,{type:"email",id:"email",name:"email",value:u.email||"",onChange:T,placeholder:"Enter your email address","aria-invalid":!!h.email_address,disabled:_,autoComplete:"email"}),h.email_address&&e.jsx(or,{children:h.email_address})]}),w&&e.jsx(or,{style:{marginBottom:"var(--space-md)"},children:w.message}),e.jsx(qm,{type:"submit",disabled:_,children:_?"Completing...":"Continue"})]}),e.jsxs(ja,{children:[r&&e.jsx("div",{children:e.jsx(Po,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Po,{children:e.jsx(vt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const Qm=p.div`
|
|
1602
1602
|
text-align: center;
|
|
1603
1603
|
margin-bottom: var(--space-2xl);
|
|
1604
1604
|
`,Km=p.div`
|
|
@@ -1631,17 +1631,17 @@ See https://styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-sev
|
|
|
1631
1631
|
flex-direction: column;
|
|
1632
1632
|
gap: var(--space-sm);
|
|
1633
1633
|
margin-top: var(--space-xl);
|
|
1634
|
-
`,ex=
|
|
1634
|
+
`,ex=yt`
|
|
1635
1635
|
from { transform: rotate(0deg); }
|
|
1636
1636
|
to { transform: rotate(360deg); }
|
|
1637
|
-
`,tx=p(
|
|
1637
|
+
`,tx=p(Mt)`
|
|
1638
1638
|
animation: ${ex} 1s linear infinite;
|
|
1639
1639
|
`,rx=p.p`
|
|
1640
1640
|
font-size: var(--font-xs);
|
|
1641
1641
|
color: var(--color-error);
|
|
1642
1642
|
text-align: center;
|
|
1643
1643
|
margin: var(--space-sm) 0 0;
|
|
1644
|
-
`;function Ud({onComplete:t,onSkip:r}){var c;const[o,n]=a.useState(!1),[i,s]=a.useState(null),{registerPasskey:d}=
|
|
1644
|
+
`;function Ud({onComplete:t,onSkip:r}){var c;const[o,n]=a.useState(!1),[i,s]=a.useState(null),{registerPasskey:d}=Kt(),{deployment:u}=je(),l=async()=>{n(!0),s(null);try{await d(),t==null||t()}catch(g){s(g instanceof Error?g.message:"Failed to register passkey")}finally{n(!1)}},h=((c=u==null?void 0:u.ui_settings)==null?void 0:c.app_name)||"this app";return e.jsxs(e.Fragment,{children:[e.jsxs(Qm,{children:[e.jsx(Km,{children:e.jsx(Gi,{})}),e.jsx(Zm,{children:"Add a Passkey"}),e.jsxs(Jm,{children:["Sign in faster and more securely with a passkey. Use your fingerprint, face, or screen lock to access ",h,"."]})]}),e.jsxs(Xm,{children:[e.jsx(B,{$fullWidth:!0,$size:"sm",onClick:l,disabled:o,children:o?e.jsxs(e.Fragment,{children:[e.jsx(tx,{size:16}),"Registering..."]}):e.jsxs(e.Fragment,{children:[e.jsx(Gi,{size:16}),"Add Passkey"]})}),e.jsx(B,{$fullWidth:!0,$size:"sm",$outline:!0,onClick:r,children:"Maybe Later"})]}),i&&e.jsx(rx,{children:i})]})}const Bd=yt`
|
|
1645
1645
|
from {
|
|
1646
1646
|
transform: rotate(0deg);
|
|
1647
1647
|
}
|
|
@@ -1710,7 +1710,7 @@ margin: 0;
|
|
|
1710
1710
|
margin-top: var(--space-2xs);
|
|
1711
1711
|
`,$a=p(B).withConfig({shouldForwardProp:t=>!["$fullWidth","$size"].includes(t)})`
|
|
1712
1712
|
margin-top: var(--space-md);
|
|
1713
|
-
`,sx=p(
|
|
1713
|
+
`,sx=p(Mt)`
|
|
1714
1714
|
animation: ${Bd} 1s linear infinite;
|
|
1715
1715
|
`,ax=p.button`
|
|
1716
1716
|
display: flex;
|
|
@@ -1782,7 +1782,7 @@ cursor: pointer;
|
|
|
1782
1782
|
&:hover {
|
|
1783
1783
|
color: var(--color-primary-hover);
|
|
1784
1784
|
}
|
|
1785
|
-
`;function px(){return e.jsx(am,{children:e.jsx(hx,{})})}function hx(){var q,K,ue,xe,Y,he,V,be,Ze,lt,G,ce,De,Xe,rt,Je;const{deployment:t}=je(),{navigate:r}=nt(),{session:o,loading:n,refetch:i,exchangeTicket:s}=Be(),d=((K=(q=t==null?void 0:t.auth_settings)==null?void 0:q.multi_session_support)==null?void 0:K.enabled)??!1,{setEmail:u,otpSent:l,setOtpSent:h,showForgotPassword:c,setShowForgotPassword:g,showOtherOptions:m,setShowOtherOptions:x,enabledSocialsProviders:v,firstFactor:S,signInStep:E,setSignInStep:k}=Ad(),{loading:j,signIn:z,signinAttempt:b,discardSignInAttempt:w,setSignInAttempt:_}=Mr("generic"),{signIn:f}=Mr("oauth"),{signIn:C}=Mr("passkey"),[y,$]=a.useState({email:"",username:"",password:"",phone:""}),[I,O]=a.useState({}),[R,T]=a.useState(!1),[F,D]=a.useState(""),[M,L]=a.useState("US"),[A,P]=a.useState(!1),[N,W]=a.useState(null),[H,oe]=a.useState(!1),[Z,we]=a.useState(null);a.useEffect(()=>{const de=new URLSearchParams(window.location.search),ne=de.get("error"),ve=de.get("error_description");if(ne==="access_denied"&&ve){W(ve),de.delete("error"),de.delete("error_description");const _e=de.toString()?`${window.location.pathname}?${de.toString()}`:window.location.pathname;window.history.replaceState({},"",_e)}},[]),a.useEffect(()=>{var de,ne,ve,_e;if(!n&&(o!=null&&o.active_signin)&&!d&&!A&&!H){let fe=new URLSearchParams(window.location.search).get("redirect_uri");fe||(fe=((de=t==null?void 0:t.ui_settings)==null?void 0:de.after_signin_redirect_url)||null),!fe&&(t!=null&&t.frontend_host)&&(fe=`https://${t.frontend_host}`);const Re=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.passkey;(Re==null?void 0:Re.enabled)&&(Re==null?void 0:Re.prompt_registration_on_auth)&&!((_e=(ve=o.active_signin)==null?void 0:ve.user)!=null&&_e.has_passkeys)?(we(fe),oe(!0)):fe&&(P(!0),r(fe))}},[o,n,d,t,r,A]);const pe=de=>{let{name:ne,value:ve}=de.target;ne==="phone"?ve=ve.replace(/[^0-9]/g,""):ne==="email"&&(u(ve),ve=ve.toLowerCase()),$(_e=>({..._e,[ne]:ve})),O(_e=>({..._e,[ne]:""}))},ee=()=>{$({email:"",username:"",password:"",phone:""}),O({}),L("US"),k("identifier")},me=async de=>{if(!de){O({email:"Email address is required"});return}T(!0),O({});try{const ne=await z.identify(de);if(ne.strategy==="sso"&&ne.connection_id){const _e=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,fe=await z.initEnterpriseSso(ne.connection_id,_e);if(fe&&fe.sso_url){P(!0),window.location.href=fe.sso_url;return}}else if(ne.strategy==="social"&&ne.provider){const ve=v.find(_e=>_e.provider===ne.provider);if(ve){const fe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Re}=await f.create({provider:ve.provider,redirectUri:fe});if(Re&&typeof Re=="object"&&"oauth_url"in Re){P(!0),window.location.href=Re.oauth_url;return}}else k("password")}else k("password")}catch(ne){O({submit:ne.message})}finally{A||T(!1)}},re=async de=>{if(de.preventDefault(),j||R)return;w();const ne={};if(E==="identifier"&&S==="email_password"){if(!y.email){O({email:"Email address is required"});return}await me(y.email);return}if(S==="email_password"?(y.email||(ne.email="Email address is required"),y.password||(ne.password="Password is required")):S==="username_password"?(y.username||(ne.username="Username is required"),y.password||(ne.password="Password is required")):S==="email_otp"||S==="email_magic_link"?y.email||(ne.email="Email address is required"):S==="phone_otp"&&(y.phone?/^\d{7,15}$/.test(y.phone)||(ne.phone="Phone number must contain 7-15 digits"):ne.phone="Phone number is required"),O(ne),Object.keys(ne).length>0)return;let ve="";switch(S){case"email_password":ve="plain_email";break;case"username_password":ve="plain_username";break;case"email_otp":ve="email_otp";break;case"email_magic_link":ve="magic_link";break;case"phone_otp":ve="phone_otp";break}T(!0);try{const _e={...y,strategy:ve};S==="phone_otp"&&M&&(_e.phone_country_code=M),await z.create(_e)}catch(_e){O({submit:_e.message}),T(!1)}},Pe=async de=>{if(de.preventDefault(),j||R)return;const ne={};if(!F){ne.otp="OTP code is required",O(ne);return}T(!0),O({});try{await z.completeVerification(F),h(!1),D("")}catch(ve){O({otp:ve.message||"Verification failed"})}finally{T(!1)}},te=async de=>{if(!(j||R)){T(!0);try{const ve=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:_e}=await f.create({provider:de.provider,redirectUri:ve});_e&&typeof _e=="object"&&"oauth_url"in _e&&(window.location.href=_e.oauth_url)}catch(ne){O({submit:ne.message})}finally{T(!1)}}},ae=async()=>{var de;if(!(j||R)){T(!0),O({});try{const ne=await C.create();if("data"in ne&&ne.data){await i();let ve=new URLSearchParams(window.location.search).get("redirect_uri");ve||(ve=((de=t==null?void 0:t.ui_settings)==null?void 0:de.after_signin_redirect_url)||null),!ve&&(t!=null&&t.frontend_host)&&(ve=`https://${t.frontend_host}`),P(!0),ve&&r(ve)}}catch(ne){O({submit:ne.message||"Passkey sign-in failed"})}finally{T(!1)}}},ye=a.useRef(!1);if(a.useEffect(()=>{if(n)return;const de=new URLSearchParams(window.location.search),ne=de.get("ticket");if(ne&&!ye.current&&!j){ye.current=!0,de.delete("ticket");const _e=de.toString()?`${window.location.pathname}?${de.toString()}`:window.location.pathname;window.history.replaceState({},"",_e),(async()=>{try{T(!0),await s(ne)}catch(Re){O({submit:Re.message||"Failed to exchange ticket"}),ye.current=!1}finally{T(!1)}})();return}const ve=de.get("signin_attempt_id");if(ve&&(o!=null&&o.signin_attempts)&&!b){const _e=o.signin_attempts.find(fe=>fe.id===ve);if(_e){_(_e),de.delete("signin_attempt_id");const fe=de.toString()?`${window.location.pathname}?${de.toString()} `:window.location.pathname;window.history.replaceState({},"",fe)}}},[o,n,b,_,j]),a.useEffect(()=>{var _e;if(!b)return;if(b.completed){P(!0);let fe=new URLSearchParams(window.location.search).get("redirect_uri");if(fe||(fe=((_e=t==null?void 0:t.ui_settings)==null?void 0:_e.after_signin_redirect_url)||null),!fe&&(t!=null&&t.frontend_host)&&(fe=`https://${t.frontend_host}`),fe){let Re;try{Re=new URL(fe)}catch{Re=new URL(fe,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Re.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(Re.toString())}return}if(!z||l)return;const ne={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[b.current_step];if(!ne)return;(async()=>{try{await z.prepareVerification({strategy:ne}),h(!0)}catch(fe){console.error("Failed to prepare verification:",fe),O({submit:"Failed to send verification. Please try again."})}finally{T(!1)}})()},[b,z,l,h,r,t]),a.useEffect(()=>{},[]),m)return e.jsx(vm,{onBack:()=>x(!1)});if(c)return e.jsx(pm,{onBack:()=>g(!1)});if((b==null?void 0:b.current_step)==="verify_second_factor")return e.jsx(Fd,{attempt:b,completeVerification:z.completeVerification,prepareVerification:z.prepareVerification,onBack:()=>{w(),ee(),h(!1)}});if((b==null?void 0:b.current_step)==="complete_profile")return e.jsx(Nd,{attempt:b,completeProfile:z.completeProfile,completeVerification:z.completeVerification,prepareVerification:z.prepareVerification,onBack:()=>{w(),ee(),h(!1)}});if(H){const de=()=>{oe(!1),Z&&(P(!0),r(Z))},ne=()=>{oe(!1),Z&&(P(!0),r(Z))};return e.jsx(le,{children:e.jsxs(Ro,{children:[e.jsx(Me,{}),e.jsx(Ud,{onComplete:de,onSkip:ne})]})})}if(n)return e.jsx(le,{children:e.jsxs(Ro,{children:[e.jsx(Me,{}),e.jsx(_a,{children:e.jsx(At,{size:32})})]})});if(A)return e.jsx(le,{children:e.jsxs(Ro,{children:[e.jsx(Me,{}),e.jsx(_a,{children:e.jsx(At,{size:32})})]})});const Q=(b==null?void 0:b.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(b.current_step)&&l;return e.jsx(le,{children:e.jsxs(Ro,{children:[e.jsx(Me,{}),Q?e.jsx(e.Fragment,{children:e.jsxs(ka,{children:[e.jsx(Ca,{children:S==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Sa,{children:S==="email_magic_link"?`If ${y.email} exists in our records, you will receive a magic link. Click the link to sign in.`:S==="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(ka,{children:[e.jsx(Ca,{children:"Sign in to your account"}),e.jsxs(Sa,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),N&&e.jsxs(cx,{children:[e.jsx(lx,{children:"Access Denied"}),e.jsx(dx,{children:N}),e.jsx(ux,{onClick:()=>W(null),children:"Try again"})]}),Q?S==="email_magic_link"?e.jsxs(si,{children:["Having trouble?"," ",e.jsx(nr,{children:e.jsx(mt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(nr,{onClick:()=>{h(!1),w(),ee()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(wt,{style:{gap:"15px"},onSubmit:Pe,noValidate:!0,children:[e.jsx(Kt,{onComplete:async de=>{if(D(de),de&&de.length===6){T(!0),O({});try{await z.completeVerification(de),h(!1)}catch(ne){O({otp:ne.message||"Verification failed"})}finally{T(!1)}}},onResend:async()=>{const de=S==="email_otp"?"email_otp":"phone_otp";await z.prepareVerification({strategy:de})},error:I.otp,isSubmitting:R}),e.jsx($a,{type:"submit",$fullWidth:!0,$size:"sm",disabled:R||j||!F,style:{margin:0},children:R?"Verifying...":`Continue to ${(Je=t==null?void 0:t.ui_settings)==null?void 0:Je.app_name}`})]}),e.jsxs(si,{children:["Having trouble?"," ",e.jsx(nr,{children:e.jsx(mt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(nr,{onClick:()=>{h(!1),w(),ee()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[v.length>0&&e.jsx(e.Fragment,{children:e.jsx(as,{connections:v,callback:te})}),((xe=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.passkey)==null?void 0:xe.enabled)&&e.jsxs(ax,{type:"button",onClick:ae,disabled:R,children:[e.jsx(Gi,{size:16}),"Sign in with Passkey"]}),(v.length>0||((he=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.passkey)==null?void 0:he.enabled))&&e.jsx(ox,{children:e.jsx(nx,{children:"or"})}),e.jsxs(wt,{onSubmit:re,noValidate:!0,children:[(S==="email_password"||S==="email_otp"||S==="email_magic_link")&&((be=(V=t==null?void 0:t.auth_settings)==null?void 0:V.email_address)==null?void 0:be.enabled)&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"email",children:"Email address"}),e.jsx(X,{type:"email",id:"email",name:"email",value:y.email,onChange:pe,placeholder:"Enter your email address","aria-invalid":!!I.email}),I.email&&e.jsx(no,{children:I.email})]}),S==="username_password"&&((lt=(Ze=t==null?void 0:t.auth_settings)==null?void 0:Ze.username)==null?void 0:lt.enabled)&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"username",children:"Username"}),e.jsx(X,{type:"text",id:"username",name:"username",value:y.username,onChange:pe,placeholder:"Enter your username","aria-invalid":!!I.username}),I.username&&e.jsx(no,{children:I.username})]}),S==="phone_otp"&&((ce=(G=t==null?void 0:t.auth_settings)==null?void 0:G.phone_number)==null?void 0:ce.enabled)&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"phone",children:"Phone number"}),e.jsx(vo,{value:y.phone,onChange:pe,error:I.phone,countryCode:M,setCountryCode:L}),I.phone&&e.jsx(no,{children:I.phone})]}),E==="password"&&(S==="email_password"||S==="username_password")&&((Xe=(De=t==null?void 0:t.auth_settings)==null?void 0:De.password)==null?void 0:Xe.enabled)&&e.jsxs(ie,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(J,{htmlFor:"password",children:"Password"}),e.jsx(nr,{style:{fontSize:"12px"},onClick:()=>g(!0),children:"Forgot password?"})]}),e.jsx(ix,{children:e.jsx(X,{type:"password",id:"password",name:"password",value:y.password,onChange:pe,placeholder:"Enter your password","aria-invalid":!!I.password})}),I.password&&e.jsx(no,{children:I.password})]}),e.jsxs("div",{children:[I.submit&&e.jsx(no,{children:I.submit}),e.jsx($a,{type:"submit",$fullWidth:!0,$size:"sm",disabled:R||j,children:R?e.jsx(sx,{size:16}):E==="identifier"?"Continue":"Sign in"})]}),e.jsx(nr,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>x(!0),children:"Use other methods"})]}),e.jsxs(si,{children:["Don't have an account?"," ",e.jsx(nr,{children:e.jsx(mt,{to:`${(rt=t.ui_settings)==null?void 0:rt.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const za=p.div`
|
|
1785
|
+
`;function px(){return e.jsx(am,{children:e.jsx(hx,{})})}function hx(){var q,K,ue,xe,Y,he,V,be,Je,dt,G,ce,De,et,ot,Xe;const{deployment:t}=je(),{navigate:r}=it(),{session:o,loading:n,refetch:i,exchangeTicket:s}=Be(),d=((K=(q=t==null?void 0:t.auth_settings)==null?void 0:q.multi_session_support)==null?void 0:K.enabled)??!1,{setEmail:u,otpSent:l,setOtpSent:h,showForgotPassword:c,setShowForgotPassword:g,showOtherOptions:m,setShowOtherOptions:x,enabledSocialsProviders:v,firstFactor:S,signInStep:E,setSignInStep:k}=Ad(),{loading:j,signIn:z,signinAttempt:b,discardSignInAttempt:w,setSignInAttempt:_}=Mr("generic"),{signIn:f}=Mr("oauth"),{signIn:C}=Mr("passkey"),[y,$]=a.useState({email:"",username:"",password:"",phone:""}),[I,O]=a.useState({}),[R,T]=a.useState(!1),[F,D]=a.useState(""),[M,L]=a.useState("US"),[A,P]=a.useState(!1),[N,W]=a.useState(null),[H,oe]=a.useState(!1),[Z,we]=a.useState(null);a.useEffect(()=>{const de=new URLSearchParams(window.location.search),ne=de.get("error"),ve=de.get("error_description");if(ne==="access_denied"&&ve){W(ve),de.delete("error"),de.delete("error_description");const _e=de.toString()?`${window.location.pathname}?${de.toString()}`:window.location.pathname;window.history.replaceState({},"",_e)}},[]),a.useEffect(()=>{var de,ne,ve,_e;if(!n&&(o!=null&&o.active_signin)&&!d&&!A&&!H){let fe=new URLSearchParams(window.location.search).get("redirect_uri");fe||(fe=((de=t==null?void 0:t.ui_settings)==null?void 0:de.after_signin_redirect_url)||null),!fe&&(t!=null&&t.frontend_host)&&(fe=`https://${t.frontend_host}`);const ze=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.passkey;(ze==null?void 0:ze.enabled)&&(ze==null?void 0:ze.prompt_registration_on_auth)&&!((_e=(ve=o.active_signin)==null?void 0:ve.user)!=null&&_e.has_passkeys)?(we(fe),oe(!0)):fe&&(P(!0),r(fe))}},[o,n,d,t,r,A]);const pe=de=>{let{name:ne,value:ve}=de.target;ne==="phone"?ve=ve.replace(/[^0-9]/g,""):ne==="email"&&(u(ve),ve=ve.toLowerCase()),$(_e=>({..._e,[ne]:ve})),O(_e=>({..._e,[ne]:""}))},ee=()=>{$({email:"",username:"",password:"",phone:""}),O({}),L("US"),k("identifier")},me=async de=>{if(!de){O({email:"Email address is required"});return}T(!0),O({});try{const ne=await z.identify(de);if(ne.strategy==="sso"&&ne.connection_id){const _e=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,fe=await z.initEnterpriseSso(ne.connection_id,_e);if(fe&&fe.sso_url){P(!0),window.location.href=fe.sso_url;return}}else if(ne.strategy==="social"&&ne.provider){const ve=v.find(_e=>_e.provider===ne.provider);if(ve){const fe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:ze}=await f.create({provider:ve.provider,redirectUri:fe});if(ze&&typeof ze=="object"&&"oauth_url"in ze){P(!0),window.location.href=ze.oauth_url;return}}else k("password")}else k("password")}catch(ne){O({submit:ne.message})}finally{A||T(!1)}},re=async de=>{if(de.preventDefault(),j||R)return;w();const ne={};if(E==="identifier"&&S==="email_password"){if(!y.email){O({email:"Email address is required"});return}await me(y.email);return}if(S==="email_password"?(y.email||(ne.email="Email address is required"),y.password||(ne.password="Password is required")):S==="username_password"?(y.username||(ne.username="Username is required"),y.password||(ne.password="Password is required")):S==="email_otp"||S==="email_magic_link"?y.email||(ne.email="Email address is required"):S==="phone_otp"&&(y.phone?/^\d{7,15}$/.test(y.phone)||(ne.phone="Phone number must contain 7-15 digits"):ne.phone="Phone number is required"),O(ne),Object.keys(ne).length>0)return;let ve="";switch(S){case"email_password":ve="plain_email";break;case"username_password":ve="plain_username";break;case"email_otp":ve="email_otp";break;case"email_magic_link":ve="magic_link";break;case"phone_otp":ve="phone_otp";break}T(!0);try{const _e={...y,strategy:ve};S==="phone_otp"&&M&&(_e.phone_country_code=M),await z.create(_e)}catch(_e){O({submit:_e.message}),T(!1)}},Re=async de=>{if(de.preventDefault(),j||R)return;const ne={};if(!F){ne.otp="OTP code is required",O(ne);return}T(!0),O({});try{await z.completeVerification(F),h(!1),D("")}catch(ve){O({otp:ve.message||"Verification failed"})}finally{T(!1)}},te=async de=>{if(!(j||R)){T(!0);try{const ve=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:_e}=await f.create({provider:de.provider,redirectUri:ve});_e&&typeof _e=="object"&&"oauth_url"in _e&&(window.location.href=_e.oauth_url)}catch(ne){O({submit:ne.message})}finally{T(!1)}}},ae=async()=>{var de;if(!(j||R)){T(!0),O({});try{const ne=await C.create();if("data"in ne&&ne.data){await i();let ve=new URLSearchParams(window.location.search).get("redirect_uri");ve||(ve=((de=t==null?void 0:t.ui_settings)==null?void 0:de.after_signin_redirect_url)||null),!ve&&(t!=null&&t.frontend_host)&&(ve=`https://${t.frontend_host}`),P(!0),ve&&r(ve)}}catch(ne){O({submit:ne.message||"Passkey sign-in failed"})}finally{T(!1)}}},ye=a.useRef(!1);if(a.useEffect(()=>{if(n)return;const de=new URLSearchParams(window.location.search),ne=de.get("ticket");if(ne&&!ye.current&&!j){ye.current=!0,de.delete("ticket");const _e=de.toString()?`${window.location.pathname}?${de.toString()}`:window.location.pathname;window.history.replaceState({},"",_e),(async()=>{var ze;try{T(!0),await s(ne),P(!0),P(!0);let Ke=new URLSearchParams(window.location.search).get("redirect_uri");if(Ke||(Ke=((ze=t==null?void 0:t.ui_settings)==null?void 0:ze.after_signin_redirect_url)||null),!Ke&&(t!=null&&t.frontend_host)&&(Ke=`https://${t.frontend_host}`),Ke){let ut;try{ut=new URL(Ke)}catch{ut=new URL(Ke,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&ut.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(ut.toString())}return}catch(Ke){O({submit:Ke.message||"Failed to exchange ticket"}),ye.current=!1}finally{T(!1)}})();return}const ve=de.get("signin_attempt_id");if(ve&&(o!=null&&o.signin_attempts)&&!b){const _e=o.signin_attempts.find(fe=>fe.id===ve);if(_e){_(_e),de.delete("signin_attempt_id");const fe=de.toString()?`${window.location.pathname}?${de.toString()} `:window.location.pathname;window.history.replaceState({},"",fe)}}},[o,n,b,_,j]),a.useEffect(()=>{var _e;if(!b)return;if(b.completed){P(!0);let fe=new URLSearchParams(window.location.search).get("redirect_uri");if(fe||(fe=((_e=t==null?void 0:t.ui_settings)==null?void 0:_e.after_signin_redirect_url)||null),!fe&&(t!=null&&t.frontend_host)&&(fe=`https://${t.frontend_host}`),fe){let ze;try{ze=new URL(fe)}catch{ze=new URL(fe,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&ze.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(ze.toString())}return}if(!z||l)return;const ne={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[b.current_step];if(!ne)return;(async()=>{try{await z.prepareVerification({strategy:ne}),h(!0)}catch(fe){console.error("Failed to prepare verification:",fe),O({submit:"Failed to send verification. Please try again."})}finally{T(!1)}})()},[b,z,l,h,r,t]),a.useEffect(()=>{},[]),m)return e.jsx(vm,{onBack:()=>x(!1)});if(c)return e.jsx(pm,{onBack:()=>g(!1)});if((b==null?void 0:b.current_step)==="verify_second_factor")return e.jsx(Fd,{attempt:b,completeVerification:z.completeVerification,prepareVerification:z.prepareVerification,onBack:()=>{w(),ee(),h(!1)}});if((b==null?void 0:b.current_step)==="complete_profile")return e.jsx(Nd,{attempt:b,completeProfile:z.completeProfile,completeVerification:z.completeVerification,prepareVerification:z.prepareVerification,onBack:()=>{w(),ee(),h(!1)}});if(H){const de=()=>{oe(!1),Z&&(P(!0),r(Z))},ne=()=>{oe(!1),Z&&(P(!0),r(Z))};return e.jsx(le,{children:e.jsxs(Ro,{children:[e.jsx(Me,{}),e.jsx(Ud,{onComplete:de,onSkip:ne})]})})}if(n)return e.jsx(le,{children:e.jsxs(Ro,{children:[e.jsx(Me,{}),e.jsx(_a,{children:e.jsx(Mt,{size:32})})]})});if(A)return e.jsx(le,{children:e.jsxs(Ro,{children:[e.jsx(Me,{}),e.jsx(_a,{children:e.jsx(Mt,{size:32})})]})});const Q=(b==null?void 0:b.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(b.current_step)&&l;return e.jsx(le,{children:e.jsxs(Ro,{children:[e.jsx(Me,{}),Q?e.jsx(e.Fragment,{children:e.jsxs(ka,{children:[e.jsx(Ca,{children:S==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Sa,{children:S==="email_magic_link"?`If ${y.email} exists in our records, you will receive a magic link. Click the link to sign in.`:S==="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(ka,{children:[e.jsx(Ca,{children:"Sign in to your account"}),e.jsxs(Sa,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),N&&e.jsxs(cx,{children:[e.jsx(lx,{children:"Access Denied"}),e.jsx(dx,{children:N}),e.jsx(ux,{onClick:()=>W(null),children:"Try again"})]}),Q?S==="email_magic_link"?e.jsxs(si,{children:["Having trouble?"," ",e.jsx(nr,{children:e.jsx(vt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(nr,{onClick:()=>{h(!1),w(),ee()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(_t,{style:{gap:"15px"},onSubmit:Re,noValidate:!0,children:[e.jsx(Zt,{onComplete:async de=>{if(D(de),de&&de.length===6){T(!0),O({});try{await z.completeVerification(de),h(!1)}catch(ne){O({otp:ne.message||"Verification failed"})}finally{T(!1)}}},onResend:async()=>{const de=S==="email_otp"?"email_otp":"phone_otp";await z.prepareVerification({strategy:de})},error:I.otp,isSubmitting:R}),e.jsx($a,{type:"submit",$fullWidth:!0,$size:"sm",disabled:R||j||!F,style:{margin:0},children:R?"Verifying...":`Continue to ${(Xe=t==null?void 0:t.ui_settings)==null?void 0:Xe.app_name}`})]}),e.jsxs(si,{children:["Having trouble?"," ",e.jsx(nr,{children:e.jsx(vt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(nr,{onClick:()=>{h(!1),w(),ee()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[v.length>0&&e.jsx(e.Fragment,{children:e.jsx(as,{connections:v,callback:te})}),((xe=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.passkey)==null?void 0:xe.enabled)&&e.jsxs(ax,{type:"button",onClick:ae,disabled:R,children:[e.jsx(Gi,{size:16}),"Sign in with Passkey"]}),(v.length>0||((he=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.passkey)==null?void 0:he.enabled))&&e.jsx(ox,{children:e.jsx(nx,{children:"or"})}),e.jsxs(_t,{onSubmit:re,noValidate:!0,children:[(S==="email_password"||S==="email_otp"||S==="email_magic_link")&&((be=(V=t==null?void 0:t.auth_settings)==null?void 0:V.email_address)==null?void 0:be.enabled)&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"email",children:"Email address"}),e.jsx(X,{type:"email",id:"email",name:"email",value:y.email,onChange:pe,placeholder:"Enter your email address","aria-invalid":!!I.email}),I.email&&e.jsx(no,{children:I.email})]}),S==="username_password"&&((dt=(Je=t==null?void 0:t.auth_settings)==null?void 0:Je.username)==null?void 0:dt.enabled)&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"username",children:"Username"}),e.jsx(X,{type:"text",id:"username",name:"username",value:y.username,onChange:pe,placeholder:"Enter your username","aria-invalid":!!I.username}),I.username&&e.jsx(no,{children:I.username})]}),S==="phone_otp"&&((ce=(G=t==null?void 0:t.auth_settings)==null?void 0:G.phone_number)==null?void 0:ce.enabled)&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"phone",children:"Phone number"}),e.jsx(vo,{value:y.phone,onChange:pe,error:I.phone,countryCode:M,setCountryCode:L}),I.phone&&e.jsx(no,{children:I.phone})]}),E==="password"&&(S==="email_password"||S==="username_password")&&((et=(De=t==null?void 0:t.auth_settings)==null?void 0:De.password)==null?void 0:et.enabled)&&e.jsxs(ie,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(J,{htmlFor:"password",children:"Password"}),e.jsx(nr,{style:{fontSize:"12px"},onClick:()=>g(!0),children:"Forgot password?"})]}),e.jsx(ix,{children:e.jsx(X,{type:"password",id:"password",name:"password",value:y.password,onChange:pe,placeholder:"Enter your password","aria-invalid":!!I.password})}),I.password&&e.jsx(no,{children:I.password})]}),e.jsxs("div",{children:[I.submit&&e.jsx(no,{children:I.submit}),e.jsx($a,{type:"submit",$fullWidth:!0,$size:"sm",disabled:R||j,children:R?e.jsx(sx,{size:16}):E==="identifier"?"Continue":"Sign in"})]}),e.jsx(nr,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>x(!0),children:"Use other methods"})]}),e.jsxs(si,{children:["Don't have an account?"," ",e.jsx(nr,{children:e.jsx(vt,{to:`${(ot=t.ui_settings)==null?void 0:ot.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const za=p.div`
|
|
1786
1786
|
max-width: 380px;
|
|
1787
1787
|
width: 380px;
|
|
1788
1788
|
padding: var(--space-3xl);
|
|
@@ -1861,7 +1861,7 @@ cursor: pointer;
|
|
|
1861
1861
|
color: var(--color-primary);
|
|
1862
1862
|
text-decoration: none;
|
|
1863
1863
|
cursor: pointer;
|
|
1864
|
-
`;function Sx(){var E,k,j,z,b,w,_,f,C,y,$,I;const{deployment:t}=je(),{loading:r,joinWaitlist:o}=Il(),[n,i]=a.useState({first_name:"",last_name:"",email:""}),[s,d]=a.useState(!1),[u,l]=a.useState(!1),[h,c]=a.useState(null),g=O=>{if(h)return h.message},m=t==null?void 0:t.auth_settings,x=!!((E=m==null?void 0:m.first_name)!=null&&E.enabled&&((k=m==null?void 0:m.last_name)!=null&&k.enabled)),v=O=>{const{name:R,value:T}=O.target;i(F=>({...F,[R]:T}))},S=async O=>{if(O.preventDefault(),!!m){l(!0),c(null);try{(await o(n)).data&&d(!0)}catch(R){c(R)}finally{l(!1)}}};return s?e.jsx(le,{children:e.jsx(za,{children:e.jsxs(yx,{children:[e.jsx(bx,{children:e.jsx(
|
|
1864
|
+
`;function Sx(){var E,k,j,z,b,w,_,f,C,y,$,I;const{deployment:t}=je(),{loading:r,joinWaitlist:o}=Il(),[n,i]=a.useState({first_name:"",last_name:"",email:""}),[s,d]=a.useState(!1),[u,l]=a.useState(!1),[h,c]=a.useState(null),g=O=>{if(h)return h.message},m=t==null?void 0:t.auth_settings,x=!!((E=m==null?void 0:m.first_name)!=null&&E.enabled&&((k=m==null?void 0:m.last_name)!=null&&k.enabled)),v=O=>{const{name:R,value:T}=O.target;i(F=>({...F,[R]:T}))},S=async O=>{if(O.preventDefault(),!!m){l(!0),c(null);try{(await o(n)).data&&d(!0)}catch(R){c(R)}finally{l(!1)}}};return s?e.jsx(le,{children:e.jsx(za,{children:e.jsxs(yx,{children:[e.jsx(bx,{children:e.jsx(rt,{size:32})}),e.jsx(wx,{children:"You're on the waitlist!"}),e.jsxs(jx,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(le,{children:e.jsxs(za,{children:[e.jsx(Me,{}),e.jsxs(fx,{children:[e.jsx(gx,{children:"Join the waitlist"}),e.jsx(mx,{children:"Be the first to know when we launch!"})]}),e.jsxs(xx,{onSubmit:S,noValidate:!0,children:[(((j=m==null?void 0:m.first_name)==null?void 0:j.enabled)||((z=m==null?void 0:m.last_name)==null?void 0:z.enabled))&&e.jsxs(vx,{$isBothEnabled:x,children:[((b=m==null?void 0:m.first_name)==null?void 0:b.enabled)&&e.jsxs(ai,{children:[e.jsxs(ci,{htmlFor:"first_name",children:["First name",((w=m==null?void 0:m.first_name)==null?void 0:w.required)&&e.jsx(li,{children:"*"})]}),e.jsx(X,{type:"text",id:"first_name",name:"first_name",required:(_=m==null?void 0:m.first_name)==null?void 0:_.required,minLength:2,maxLength:50,value:n.first_name,onChange:v,placeholder:"First name","aria-invalid":!!g()}),g()&&e.jsx(Io,{children:g()})]}),((f=m==null?void 0:m.last_name)==null?void 0:f.enabled)&&e.jsxs(ai,{children:[e.jsxs(ci,{htmlFor:"last_name",children:["Last name",((C=m==null?void 0:m.last_name)==null?void 0:C.required)&&e.jsx(li,{children:"*"})]}),e.jsx(X,{type:"text",id:"last_name",name:"last_name",required:(y=m==null?void 0:m.last_name)==null?void 0:y.required,minLength:2,maxLength:50,value:n.last_name,onChange:v,placeholder:"Last name","aria-invalid":!!g()}),g()&&e.jsx(Io,{children:g()})]})]}),e.jsxs(ai,{children:[e.jsxs(ci,{htmlFor:"email",children:["Email address",(($=m==null?void 0:m.email_address)==null?void 0:$.required)&&e.jsx(li,{children:"*"})]}),e.jsx(X,{type:"email",id:"email",name:"email",required:(I=m==null?void 0:m.email_address)==null?void 0:I.required,value:n.email,onChange:v,placeholder:"Enter your email address","aria-invalid":!!g()}),g()&&e.jsx(Io,{children:g()})]}),g()&&e.jsx(Io,{children:g()}),e.jsx(B,{type:"submit",$primary:!0,$fullWidth:!0,$size:"sm",disabled:u||r,children:u||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(_x,{children:e.jsxs(kx,{children:["Need assistance? ",e.jsx(Cx,{href:"/contact",children:"Get help"})]})})]})})}const io=p.div`
|
|
1865
1865
|
max-width: 380px;
|
|
1866
1866
|
width: 380px;
|
|
1867
1867
|
padding: var(--space-3xl);
|
|
@@ -1948,7 +1948,7 @@ cursor: pointer;
|
|
|
1948
1948
|
color: var(--color-primary-hover);
|
|
1949
1949
|
text-decoration: underline;
|
|
1950
1950
|
}
|
|
1951
|
-
`;function Rx(){const{deployment:t}=je(),{navigate:r}=
|
|
1951
|
+
`;function Rx(){const{deployment:t}=je(),{navigate:r}=it(),{error:o,session:n,processed:i,signinAttempt:s,redirectUri:d,loading:u}=Tl(),[l,h]=a.useState(!1),[c,g]=a.useState(null),m=()=>{window.location.reload()},x=()=>{var k;const E=((k=t==null?void 0:t.ui_settings)==null?void 0:k.sign_in_page_url)||"/sign-in";r(E)},v=()=>{h(!1),c&&r(c)},S=()=>{h(!1),c&&r(c)};if(a.useEffect(()=>{var E,k,j,z,b;if(!(!i||u||l)){if(s&&!s.completed){const w=(E=t==null?void 0:t.ui_settings)==null?void 0:E.sign_in_page_url;if(w){const _=new URL(w,window.location.origin);_.searchParams.set("signin_attempt_id",s.id),d&&_.searchParams.set("redirect_uri",d),r(_.toString())}return}if(s!=null&&s.completed){const w=d||((k=t==null?void 0:t.ui_settings)==null?void 0:k.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let _;try{_=new URL(w)}catch{_=new URL(w,window.location.origin)}if(_){(t==null?void 0:t.mode)==="staging"&&_.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||"");const f=(j=t==null?void 0:t.auth_settings)==null?void 0:j.passkey;(f==null?void 0:f.enabled)&&(f==null?void 0:f.prompt_registration_on_auth)&&!((b=(z=n==null?void 0:n.active_signin)==null?void 0:z.user)!=null&&b.has_passkeys)?(g(_.toString()),h(!0)):r(_.toString())}}}},[n,i,u,d,t,s,r]),a.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var k;const E=((k=t==null?void 0:t.ui_settings)==null?void 0:k.sign_in_page_url)||(t==null?void 0:t.frontend_host);E&&r(E)},2e3)},[o,t,r]),u&&!i)return e.jsx(le,{children:e.jsxs(io,{children:[e.jsxs(To,{children:[e.jsx(Oo,{children:"Completing sign in"}),e.jsx(Ao,{children:"Please wait while we authenticate you"})]}),e.jsxs(Lo,{children:[e.jsx(Ea,{}),e.jsx(Mo,{children:"Verifying your credentials..."}),e.jsx(Do,{children:"This will only take a moment."})]})]})});if(l)return e.jsx(le,{children:e.jsxs(io,{children:[e.jsx(Me,{}),e.jsx(Ud,{onComplete:v,onSkip:S})]})});if(n&&i&&!o)return e.jsx(le,{children:e.jsxs(io,{children:[e.jsxs(To,{children:[e.jsx(Oo,{children:"Success!"}),e.jsx(Ao,{children:"Authentication completed successfully"})]}),e.jsxs(Lo,{children:[e.jsx(zx,{children:"✓"}),e.jsx(Mo,{children:"Redirecting you now..."}),e.jsx(Do,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const E=o.message.includes("No OAuth callback data found");return e.jsx(le,{children:e.jsxs(io,{children:[e.jsxs(To,{children:[e.jsx(Oo,{children:"Something went wrong"}),e.jsx(Ao,{children:"We couldn't complete your sign in"})]}),e.jsxs(Lo,{children:[e.jsx($x,{children:"✗"}),e.jsx(Mo,{children:"Authentication Failed"}),e.jsx(Do,{children:o.message||"An unexpected error occurred during authentication."}),!E&&e.jsx(B,{onClick:m,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!E&&e.jsx(Ex,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(Px,{onClick:x,children:"Return to sign in"})]})})]})})}return e.jsx(le,{children:e.jsxs(io,{children:[e.jsxs(To,{children:[e.jsx(Oo,{children:"Completing sign in"}),e.jsx(Ao,{children:"Please wait while we authenticate you"})]}),e.jsxs(Lo,{children:[e.jsx(Ea,{}),e.jsx(Mo,{children:"Verifying your credentials..."}),e.jsx(Do,{children:"This will only take a moment."})]})]})})}const Ix=p.div`
|
|
1952
1952
|
max-width: 380px;
|
|
1953
1953
|
width: 380px;
|
|
1954
1954
|
padding: var(--space-3xl);
|
|
@@ -2013,7 +2013,7 @@ cursor: pointer;
|
|
|
2013
2013
|
`,di=p.p`
|
|
2014
2014
|
font-size: var(--font-xs);
|
|
2015
2015
|
color: var(--color-secondary-text);
|
|
2016
|
-
`;function Nx({onSuccess:t,onError:r}={}){const[o,n]=a.useState("loading"),[i,s]=a.useState(""),{token:d,attempt:u,redirectUri:l}=Al(),{verifyMagicLink:h}=Ol(),{navigate:c}=
|
|
2016
|
+
`;function Nx({onSuccess:t,onError:r}={}){const[o,n]=a.useState("loading"),[i,s]=a.useState(""),{token:d,attempt:u,redirectUri:l}=Al(),{verifyMagicLink:h}=Ol(),{navigate:c}=it(),{deployment:g}=je(),m=a.useRef(!1);a.useEffect(()=>{(async()=>{if(!m.current){if(!d||!u){n("error"),s("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"),s("Please wait while we verify your magic link.");try{await h({token:d,attempt:u,redirectUri:l}),n("success"),s("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var E;let S=l;if(S||(S=(E=g==null?void 0:g.ui_settings)==null?void 0:E.after_signin_redirect_url),!S&&(g!=null&&g.frontend_host)&&(S=`https://${g.frontend_host}`),S){const k=new URL(S);(g==null?void 0:g.mode)==="staging"&&k.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),c(k.toString())}},2e3)}catch(S){n("error"),s("The magic link may have expired or already been used. Please try signing in again."),r==null||r(S.message)}}})()},[d,u]);const x=()=>{var v;(v=g==null?void 0:g.ui_settings)!=null&&v.sign_in_page_url&&c(g.ui_settings.sign_in_page_url)};return e.jsx(le,{children:e.jsxs(Ix,{children:[e.jsxs(Tx,{children:[e.jsx(Ox,{children:"Magic Link Verification"}),e.jsx(Ax,{children:"Verifying your magic link"})]}),e.jsxs(Lx,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(Fx,{}),e.jsx(di,{children:i})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(Mx,{children:"✓"}),e.jsx(di,{children:i})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(Dx,{children:"✗"}),e.jsx(di,{children:i}),e.jsx(B,{onClick:x,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function Ux(t){var n,i;return t?((n=t.signin_attempts)==null?void 0:n.find(s=>s.requires_completion&&!s.completed))?!0:!!((i=t.signup_attempts)==null?void 0:i.find(s=>{var d,u;return((d=s.missing_fields)==null?void 0:d.length)>0||((u=s.remaining_steps)==null?void 0:u.length)>0&&!s.completed})):!1}function Bx(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const ir=p.div`
|
|
2017
2017
|
max-width: 380px;
|
|
2018
2018
|
width: 380px;
|
|
2019
2019
|
padding: var(--space-3xl);
|
|
@@ -2113,7 +2113,7 @@ cursor: pointer;
|
|
|
2113
2113
|
&:hover {
|
|
2114
2114
|
color: var(--color-primary-hover);
|
|
2115
2115
|
}
|
|
2116
|
-
`;function qx({token:t,onSuccess:r,onError:o}){var S;const{acceptInvitation:n,invitationData:i,loading:s,error:d}=Nl(),{navigate:u}=
|
|
2116
|
+
`;function qx({token:t,onSuccess:r,onError:o}){var S;const{acceptInvitation:n,invitationData:i,loading:s,error:d}=Nl(),{navigate:u}=it(),{deployment:l}=je(),h=a.useRef(!1),c=()=>{var k;const E=new URLSearchParams(window.location.search);return{token:t||E.get("invite_token")||E.get("token"),redirectUri:E.get("redirect_uri")||((k=l==null?void 0:l.ui_settings)==null?void 0:k.after_signin_redirect_url)||"/"}};a.useEffect(()=>{if(h.current)return;const{token:E}=c();E&&(h.current=!0,n(E))},[n]),a.useEffect(()=>{var E;i&&(i.organization&&!i.requires_signin&&r&&r(i.organization.id,(E=i.workspace)==null?void 0:E.id),i.error_code&&o&&o(i.message||"Failed to accept invitation"))},[i,r,o]);const g=()=>{const{redirectUri:E}=c();u(E)},m=()=>{var f,C;const{token:E}=c(),k=((f=l==null?void 0:l.ui_settings)==null?void 0:f.sign_in_page_url)||"/sign-in",j=((C=l==null?void 0:l.ui_settings)==null?void 0:C.sign_up_page_url)||"/sign-up",z=new URLSearchParams;E&&z.set("invite_token",E),i!=null&&i.invited_email&&z.set("invited_email",i.invited_email);const w=`${window.location.pathname}?token=${E}`;z.set("redirect_uri",w),i!=null&&i.message&&z.set("message",i.message);const _=(i==null?void 0:i.error_code)==="INVITATION_REQUIRES_SIGNUP";u(`${_?j:k}?${z.toString()}`)},x=()=>{const{token:E}=c();E&&(h.current=!1,n(E))},{token:v}=c();if(!v&&!s)return e.jsx(le,{children:e.jsxs(ir,{children:[e.jsxs(sr,{children:[e.jsx(ar,{children:"Invalid Invitation"}),e.jsx(cr,{children:"No invitation token found"})]}),e.jsxs(lr,{children:[e.jsx(ui,{children:"✗"}),e.jsx(dr,{children:"Missing Invitation Token"}),e.jsx(ur,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(B,{onClick:()=>u("/"),$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(s)return e.jsx(le,{children:e.jsxs(ir,{children:[e.jsxs(sr,{children:[e.jsx(ar,{children:"Processing Invitation"}),e.jsx(cr,{children:"Please wait while we verify your invitation"})]}),e.jsxs(lr,{children:[e.jsx(Vx,{}),e.jsx(dr,{children:"Verifying invitation..."}),e.jsx(ur,{children:"This will only take a moment."})]})]})});if(i!=null&&i.organization&&!i.requires_signin)return e.jsx(le,{children:e.jsxs(ir,{children:[e.jsxs(sr,{children:[e.jsx(ar,{children:"Invitation Accepted!"}),e.jsx(cr,{children:"You've successfully joined the organization"})]}),e.jsxs(lr,{children:[e.jsx(Wx,{children:"✓"}),e.jsxs(dr,{children:["Welcome to ",i.organization.name,"!"]}),i.workspace&&e.jsxs(ur,{children:["You've been added to the ",i.workspace.name," workspace."]}),e.jsx(B,{onClick:g,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(i!=null&&i.already_member)return e.jsx(le,{children:e.jsxs(ir,{children:[e.jsxs(sr,{children:[e.jsx(ar,{children:"Already a Member"}),e.jsx(cr,{children:"You're already part of this organization"})]}),e.jsxs(lr,{children:[e.jsx(Pa,{children:"ℹ"}),e.jsxs(dr,{children:["You're already a member of ",((S=i.organization)==null?void 0:S.name)||"this organization"]}),e.jsx(ur,{children:"No action needed - you already have access."}),e.jsx(B,{onClick:g,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(i!=null&&i.requires_signin){const E=i.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(le,{children:e.jsxs(ir,{children:[e.jsxs(sr,{children:[e.jsx(ar,{children:E?"Sign Up Required":"Sign In Required"}),e.jsx(cr,{children:"To accept this invitation"})]}),e.jsxs(lr,{children:[e.jsx(Pa,{children:"ℹ"}),e.jsxs(dr,{children:["This invitation is for ",e.jsx(Ra,{children:i.invited_email})]}),e.jsx(ur,{children:E?"You need to create an account with this email address to accept the invitation.":i.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(B,{onClick:m,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:E?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(i==null?void 0:i.error_code)==="INVITATION_EXPIRED"?e.jsx(le,{children:e.jsxs(ir,{children:[e.jsxs(sr,{children:[e.jsx(ar,{children:"Invitation Expired"}),e.jsx(cr,{children:"This invitation is no longer valid"})]}),e.jsxs(lr,{children:[e.jsx(ui,{children:"⏱"}),e.jsxs(dr,{children:["Invitation for ",e.jsx(Ra,{children:i.invited_email})," has expired"]}),e.jsx(ur,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):d||i!=null&&i.error_code?e.jsx(le,{children:e.jsxs(ir,{children:[e.jsxs(sr,{children:[e.jsx(ar,{children:"Invitation Error"}),e.jsx(cr,{children:"Unable to process invitation"})]}),e.jsxs(lr,{children:[e.jsx(ui,{children:"✗"}),e.jsx(dr,{children:"Something went wrong"}),e.jsx(ur,{children:(i==null?void 0:i.message)||d||"Failed to accept invitation"}),e.jsx(B,{onClick:x,$fullWidth:!0,$size:"sm",style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(Gx,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(Hx,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const cs=a.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),Ze=()=>{const t=a.useContext(cs);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},Yx=p.div`
|
|
2117
2117
|
display: flex;
|
|
2118
2118
|
height: 100%;
|
|
2119
2119
|
min-height: 400px;
|
|
@@ -2318,7 +2318,7 @@ cursor: pointer;
|
|
|
2318
2318
|
color: white;
|
|
2319
2319
|
font-size: 12px;
|
|
2320
2320
|
font-weight: 400;
|
|
2321
|
-
`,En=({onSuccess:t,onCancel:r})=>{const[o,n]=a.useState(""),[i,s]=a.useState(""),[d,u]=a.useState(),[l,h]=a.useState(null),[c,g]=a.useState(!1),m=a.useRef(null),{createOrganization:x}=
|
|
2321
|
+
`,En=({onSuccess:t,onCancel:r})=>{const[o,n]=a.useState(""),[i,s]=a.useState(""),[d,u]=a.useState(),[l,h]=a.useState(null),[c,g]=a.useState(!1),m=a.useRef(null),{createOrganization:x}=kt(),{refetch:v}=Be(),{toast:S}=Ze(),E=f=>{n(f)},k=f=>{if(f.target.files&&f.target.files[0]){const C=f.target.files[0];if(C.size>2*1024*1024){S("File size cannot exceed 2MB","error");return}if(!C.type.startsWith("image/")){S("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),u(C),h(URL.createObjectURL(C))}},j=()=>{var f;(f=m.current)==null||f.click()},z=f=>f.split(" ").map(C=>C[0]).join("").toUpperCase().slice(0,2)||"O";a.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]);const b=f=>f.trim().replace(/[<>\"'&]/g,""),w=f=>f.length>=2&&f.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(f),_=async()=>{const f=b(o),C=b(i);if(!f){S("Please enter an organization name","error");return}if(!w(f)){S("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(C.length>500){S("Description must be less than 500 characters","error");return}g(!0);try{const y=await x({name:f,description:C,image:d});await v(),t==null||t(y)}catch(y){const $=y.message||"Failed to create organization. Please try again.";S($,"error")}finally{g(!1)}};return e.jsx(le,{children:e.jsxs(Yx,{children:[e.jsxs(Qx,{children:[e.jsxs(Wd,{hasImage:!!l,onClick:j,children:[l?e.jsx(Zx,{src:l,alt:"Organization logo"}):e.jsx(Jx,{children:z(o||"O")}),e.jsx(u0,{children:e.jsx(p0,{children:"Upload Logo"})})]}),e.jsx(d0,{type:"file",ref:m,onChange:k,accept:"image/png, image/jpeg, image/gif",disabled:c}),e.jsx(Xx,{children:"Create new organization"}),e.jsx(e0,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(Kx,{children:[e.jsxs(t0,{children:[e.jsx(r0,{children:"Choose your organization name"}),e.jsx(o0,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(n0,{children:[e.jsxs(Ia,{children:[e.jsx(Ta,{children:"Organization name"}),e.jsx(i0,{type:"text",value:o,onChange:f=>E(f.target.value),placeholder:"Acme Inc.",disabled:c})]}),e.jsxs(Ia,{children:[e.jsx(Ta,{children:"Description (optional)"}),e.jsx(s0,{value:i,onChange:f=>s(f.target.value),placeholder:"What does your organization do?",disabled:c})]})]}),e.jsxs(a0,{children:[r?e.jsxs(c0,{onClick:r,disabled:c,children:[e.jsx(ss,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(l0,{onClick:_,disabled:c||!o.trim(),children:c?"Creating...":"Create"})]})]})]})})},Oa=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(le,{children:e.jsx(Ee,{isOpen:t,onClose:r,children:e.jsx(Ee.Overlay,{children:e.jsx(Ee.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(Ee.Body,{style:{padding:0},children:e.jsx(En,{onSuccess:n,onCancel:r})})})})})})},h0=p.div`
|
|
2322
2322
|
text-align: left;
|
|
2323
2323
|
position: fixed;
|
|
2324
2324
|
background: var(--color-background);
|
|
@@ -2468,7 +2468,7 @@ cursor: pointer;
|
|
|
2468
2468
|
outline: none;
|
|
2469
2469
|
border-color: var(--color-primary);
|
|
2470
2470
|
}
|
|
2471
|
-
`,_0=({organization:t})=>{const{getEnterpriseConnections:r,createEnterpriseConnection:o,deleteEnterpriseConnection:n,testEnterpriseConnection:i,generateSCIMToken:s,getSCIMToken:d,revokeSCIMToken:u}=
|
|
2471
|
+
`,_0=({organization:t})=>{const{getEnterpriseConnections:r,createEnterpriseConnection:o,deleteEnterpriseConnection:n,testEnterpriseConnection:i,generateSCIMToken:s,getSCIMToken:d,revokeSCIMToken:u}=kt(),{toast:l}=Ze(),[h,c]=a.useState(!1),[g,m]=a.useState(null),{data:x=[],isLoading:v,mutate:S}=We(t!=null&&t.id?`wacht-org-sso:${t.id}`:null,async()=>await(r==null?void 0:r(t))||[],{refreshInterval:3e4,revalidateOnFocus:!1}),E=async k=>{try{await(n==null?void 0:n(t,k)),S(),l("SSO connection deleted","info")}catch(j){l(j.message||"Failed to delete connection","error")}m(null)};return v?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ie,{})}):h?e.jsx(z0,{organization:t,onClose:()=>c(!1),onCreate:async k=>{try{await(o==null?void 0:o(t,k)),S(),c(!1),l("SSO connection created","info")}catch(j){l(j.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:x.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(xt,{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(B,{onClick:()=>c(!0),style:{width:"auto"},children:[e.jsx(gt,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(x0,{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"})]})}),x.map(k=>e.jsx($0,{connection:k,onDelete:j=>m(j),connectionToDelete:g,onConfirmDelete:E,onCancelDelete:()=>m(null),testConnection:j=>i(t,j),generateSCIMToken:j=>s(t,j),getSCIMToken:j=>d(t,j),revokeSCIMToken:j=>u(t,j),toast:l},k.id))]})})},k0=p.div`
|
|
2472
2472
|
margin-top: 16px;
|
|
2473
2473
|
padding-top: 16px;
|
|
2474
2474
|
border-top: 1px solid var(--color-border);
|
|
@@ -2484,14 +2484,14 @@ cursor: pointer;
|
|
|
2484
2484
|
display: flex;
|
|
2485
2485
|
gap: 8px;
|
|
2486
2486
|
flex-wrap: wrap;
|
|
2487
|
-
`,$0=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:i,testConnection:s,generateSCIMToken:d,getSCIMToken:u,revokeSCIMToken:l,toast:h})=>{var $,I,O,R,T;const[c,g]=a.useState(null),[m,x]=a.useState(!1),[v,S]=a.useState(null),[E,k]=a.useState(null),[j,z]=a.useState(!1),[b,w]=a.useState(null);a.useEffect(()=>{u&&t.id&&u(t.id).then(g).catch(()=>{})},[t.id,u]);const _=async()=>{if(s){z(!0),w(null);try{const F=await s(t.id);w(F)}catch(F){w({success:!1,checks:{},errors:{general:F.message||"Test failed"}})}finally{z(!1)}}},f=async()=>{if(d){x(!0);try{const F=await d(t.id);S(F.token),g({exists:!0,token:F}),h("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(F){h(F.message||"Failed to generate token","error")}finally{x(!1)}}},C=async()=>{if(l){x(!0);try{await l(t.id),g({exists:!1,scim_base_url:c==null?void 0:c.scim_base_url}),S(null),h("SCIM token revoked","info")}catch(F){h(F.message||"Failed to revoke token","error")}finally{x(!1)}}},y=(F,D)=>{navigator.clipboard.writeText(F),k(D),setTimeout(()=>k(null),2e3)};return e.jsxs(v0,{children:[e.jsxs(y0,{children:[e.jsxs(b0,{children:[e.jsx(
|
|
2487
|
+
`,$0=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:i,testConnection:s,generateSCIMToken:d,getSCIMToken:u,revokeSCIMToken:l,toast:h})=>{var $,I,O,R,T;const[c,g]=a.useState(null),[m,x]=a.useState(!1),[v,S]=a.useState(null),[E,k]=a.useState(null),[j,z]=a.useState(!1),[b,w]=a.useState(null);a.useEffect(()=>{u&&t.id&&u(t.id).then(g).catch(()=>{})},[t.id,u]);const _=async()=>{if(s){z(!0),w(null);try{const F=await s(t.id);w(F)}catch(F){w({success:!1,checks:{},errors:{general:F.message||"Test failed"}})}finally{z(!1)}}},f=async()=>{if(d){x(!0);try{const F=await d(t.id);S(F.token),g({exists:!0,token:F}),h("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(F){h(F.message||"Failed to generate token","error")}finally{x(!1)}}},C=async()=>{if(l){x(!0);try{await l(t.id),g({exists:!1,scim_base_url:c==null?void 0:c.scim_base_url}),S(null),h("SCIM token revoked","info")}catch(F){h(F.message||"Failed to revoke token","error")}finally{x(!1)}}},y=(F,D)=>{navigator.clipboard.writeText(F),k(D),setTimeout(()=>k(null),2e3)};return e.jsxs(v0,{children:[e.jsxs(y0,{children:[e.jsxs(b0,{children:[e.jsx(xt,{size:16}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(w0,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(B,{onClick:_,disabled:j,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:j?e.jsx(Ie,{size:14}):"Test"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{$outline:!0,onClick:()=>r(t.id),style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Remove"}),o===t.id&&e.jsx(Wr,{title:"Delete this SSO connection?",onConfirm:()=>n(t.id),onCancel:i})]})]})]}),b&&e.jsxs("div",{style:{marginBottom:"12px",padding:"8px 12px",background:b.success?"var(--color-success-background, rgba(34, 197, 94, 0.1))":"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"6px",fontSize:"12px",color:b.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:[b.success?"✓ Connection is valid":"✗ Connection failed",b.errors&&Object.entries(b.errors).map(([F,D])=>e.jsxs("div",{style:{fontWeight:400,marginTop:"4px"},children:[F.replace(/_/g," "),": ",D]},F))]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 16px",fontSize:"12px",marginBottom:"16px"},children:[t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Entity ID"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_entity_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"SSO URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_sso_url})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Issuer URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.oidc_issuer_url}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Client ID"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_client_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Scopes"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_scopes||"openid profile email"})]}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Created"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:new Date(t.created_at).toLocaleDateString()})]}),e.jsxs(k0,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsxs(C0,{style:{marginBottom:0},children:[e.jsx(xt,{size:14}),"SCIM Provisioning"]}),e.jsx(S0,{children:!(c!=null&&c.exists)||!(($=c==null?void 0:c.token)!=null&&$.enabled)?e.jsx(B,{onClick:f,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"130px"},children:m?e.jsx(Ie,{size:14}):"Generate Token"}):e.jsxs(e.Fragment,{children:[e.jsx(B,{onClick:f,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:m?e.jsx(Ie,{size:14}):"Rotate"}),e.jsx(B,{$outline:!0,onClick:C,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Revoke"})]})})]}),(((I=c==null?void 0:c.token)==null?void 0:I.scim_base_url)||v)&&e.jsx("div",{style:{marginBottom:"8px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Base URL:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)"},children:((O=c==null?void 0:c.token)==null?void 0:O.scim_base_url)||"Loading..."}),((R=c==null?void 0:c.token)==null?void 0:R.scim_base_url)&&e.jsx(ho,{onClick:()=>y(c.token.scim_base_url,"scim-url"),children:E==="scim-url"?e.jsx(rt,{size:12}):e.jsx(mr,{size:12})})]})}),v&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Token:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)",fontFamily:"monospace"},children:v}),e.jsx(ho,{onClick:()=>y(v,"scim-token"),children:E==="scim-token"?e.jsx(rt,{size:12}):e.jsx(mr,{size:12})})]}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginTop:"6px"},children:"⚠️ Copy this token now. It won't be shown again."})]}),(c==null?void 0:c.exists)&&((T=c==null?void 0:c.token)==null?void 0:T.enabled)&&!v&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--color-muted)"},children:["Token: ",e.jsxs("code",{style:{color:"var(--color-foreground)",background:"var(--color-background-alt)",padding:"2px 6px",borderRadius:"4px"},children:[c.token.token_prefix,"..."]}),c.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(c.token.last_used_at).toLocaleDateString()]})]})]})]})},hi=p.h3`
|
|
2488
2488
|
margin: 0 0 12px 0;
|
|
2489
2489
|
font-size: 13px;
|
|
2490
2490
|
font-weight: 600;
|
|
2491
2491
|
color: var(--color-foreground);
|
|
2492
2492
|
text-transform: uppercase;
|
|
2493
2493
|
letter-spacing: 0.5px;
|
|
2494
|
-
`,z0=({onCreate:t,onClose:r,organization:o})=>{const{getOrganizationDomains:n,testEnterpriseConnectionConfig:i}=jt(),{deployment:s}=je(),{toast:d}=Ke(),[u,l]=a.useState(!1),[h,c]=a.useState(null),[g,m]=a.useState("saml"),[x,v]=a.useState(null),[S,E]=a.useState(!1),[k,j]=a.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[z,b]=a.useState(!1),[w,_]=a.useState(null),{data:f=[],isLoading:C}=We("wacht-org-verified-domains-for-sso-screen",async()=>(await(n==null?void 0:n(o))||[]).filter(M=>M.verified),{revalidateOnFocus:!1}),y=D=>{c(D),m(D.protocol),D.protocol==="saml"?j(M=>{var L,A,P;return{...M,idp_entity_id:D.placeholders.entityId||"",idp_sso_url:D.placeholders.ssoUrl||"",attr_first_name:((L=D.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((A=D.attributeMapping)==null?void 0:A.last_name)||"",attr_email:((P=D.attributeMapping)==null?void 0:P.email)||""}}):j(M=>{var L,A,P;return{...M,oidc_issuer_url:D.placeholders.issuerUrl||"",oidc_scopes:D.placeholders.scopes||"openid profile email",attr_first_name:((L=D.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((A=D.attributeMapping)==null?void 0:A.last_name)||"",attr_email:((P=D.attributeMapping)==null?void 0:P.email)||""}})},$=s!=null&&s.backend_host?`${s.backend_host.startsWith("https://")?"":"https://"}${s.backend_host}/auth/sso/oidc/callback`:"",I=s!=null&&s.backend_host?`https://${s.backend_host}/auth/sso/metadata`:"",O=s!=null&&s.backend_host?`https://${s.backend_host}/auth/sso/callback`:"",R=(D,M)=>{navigator.clipboard.writeText(D),v(M),setTimeout(()=>v(null),2e3)},T=async D=>{D.preventDefault();const M=L=>L.includes("{")||L.includes("}");if(g==="saml"){if(!k.idp_entity_id||M(k.idp_entity_id)){d("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!k.idp_sso_url||M(k.idp_sso_url)){d("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!k.idp_certificate){d("Please provide the X.509 Certificate","error");return}}else{if(!k.oidc_issuer_url||M(k.oidc_issuer_url)){d("Please enter a valid Issuer URL (no placeholders)","error");return}if(!k.oidc_client_id||M(k.oidc_client_id)){d("Please enter a valid Client ID (no placeholders)","error");return}if(!k.oidc_client_secret){d("Please enter the Client Secret","error");return}}l(!0);try{const L={};k.attr_first_name&&(L.first_name=k.attr_first_name),k.attr_last_name&&(L.last_name=k.attr_last_name),k.attr_email&&(L.email=k.attr_email);const A=Object.keys(L).length>0;g==="saml"?await t({protocol:"saml",domain_id:k.domain_id||void 0,idp_entity_id:k.idp_entity_id,idp_sso_url:k.idp_sso_url,idp_certificate:k.idp_certificate,jit_enabled:k.jit_enabled,...A&&{attribute_mapping:L}}):await t({protocol:"oidc",domain_id:k.domain_id||void 0,oidc_issuer_url:k.oidc_issuer_url,oidc_client_id:k.oidc_client_id,oidc_client_secret:k.oidc_client_secret,oidc_scopes:k.oidc_scopes,jit_enabled:k.jit_enabled,...A&&{attribute_mapping:L}})}finally{l(!1)}},F=async()=>{b(!0),_(null);const D=A=>A.includes("{")||A.includes("}"),M={},L={};if(g==="saml"?(k.idp_entity_id?D(k.idp_entity_id)?(L.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):L.entity_id_valid=!0:(L.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID is required"),k.idp_sso_url?D(k.idp_sso_url)?(L.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):L.sso_url_valid=!0:(L.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL is required"),k.idp_certificate?L.certificate_provided=!0:(L.certificate_provided=!1,M.certificate_provided="X.509 Certificate is required")):(k.oidc_issuer_url?D(k.oidc_issuer_url)?(L.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):L.issuer_url_valid=!0:(L.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL is required"),k.oidc_client_id?D(k.oidc_client_id)?(L.client_id_valid=!1,M.client_id_valid="Client ID contains placeholder values - please replace with actual values"):L.client_id_valid=!0:(L.client_id_valid=!1,M.client_id_valid="Client ID is required")),Object.keys(M).length>0){_({success:!1,checks:L,errors:M}),b(!1);return}try{const A=g==="saml"?{protocol:"saml",idp_entity_id:k.idp_entity_id,idp_sso_url:k.idp_sso_url,idp_certificate:k.idp_certificate}:{protocol:"oidc",oidc_issuer_url:k.oidc_issuer_url,oidc_client_id:k.oidc_client_id,oidc_client_secret:k.oidc_client_secret},P=await(i==null?void 0:i(o,A));P&&_(P)}catch(A){_({success:!1,checks:{},errors:{general:"Test failed: "+A.message}})}finally{b(!1)}};return e.jsxs("form",{onSubmit:T,autoComplete:"off",children:[h?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:[h.logo?e.jsx(pi,{src:h.logo,alt:h.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(gt,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:h.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:h.protocol})]}),e.jsx("button",{type:"button",onClick:()=>c(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(hi,{children:"SAML Providers"}),e.jsx(Ma,{children:La.filter(D=>D.protocol==="saml").map(D=>e.jsxs(Da,{type:"button",$selected:!1,onClick:()=>y(D),children:[D.logo?e.jsx(pi,{src:D.logo,alt:D.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(gt,{size:18,color:"#666"})}),e.jsx(Fa,{children:D.name})]},D.id))}),e.jsx(hi,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Ma,{children:La.filter(D=>D.protocol==="oidc").map(D=>e.jsxs(Da,{type:"button",$selected:!1,onClick:()=>y(D),children:[D.logo?e.jsx(pi,{src:D.logo,alt:D.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(gt,{size:18,color:"#666"})}),e.jsx(Fa,{children:D.name})]},D.id))})]}),h&&e.jsxs(e.Fragment,{children:[e.jsxs(Aa,{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:g==="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:O}),e.jsx(ho,{onClick:()=>R(O,"acs"),children:x==="acs"?e.jsx(tt,{size:12}):e.jsx(mr,{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:I}),e.jsx(ho,{onClick:()=>R(I,"metadata"),children:x==="metadata"?e.jsx(tt,{size:12}):e.jsx(mr,{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:$}),e.jsx(ho,{onClick:()=>R($,"callback"),children:x==="callback"?e.jsx(tt,{size:12}):e.jsx(mr,{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(hi,{style:{margin:0},children:h?`${h.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[h&&h.docUrl&&e.jsxs("a",{href:h.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(gd,{size:12})," Docs"]}),e.jsx(B,{type:"button",onClick:F,disabled:z||!h,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:z?e.jsx(Ie,{size:16}):"Test Connection"}),e.jsx(B,{type:"submit",disabled:u||f.length===0||!h,style:{width:"auto",padding:"8px 16px"},children:u?e.jsx(Ie,{size:16}):"Create Connection"})]})]}),w&&(()=>{const D={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:w.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${w.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:w.success?"#10b981":"#ef4444"},children:w.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(w.checks).map(([M,L])=>{var A;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:L?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:L?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:D[M]||M.replace(/_/g," ").replace(/\b\w/g,P=>P.toUpperCase())}),((A=w.errors)==null?void 0:A[M])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:w.errors[M]})]})]},M)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!h&&e.jsxs(ie,{children:[e.jsx(J,{children:"Protocol *"}),e.jsxs(Na,{value:g,onChange:D=>m(D.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(ie,{style:{gridColumn:"1 / -1"},children:[e.jsx(J,{children:"Domain *"}),C?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):f.length===0?e.jsx(Aa,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(Na,{value:k.domain_id,onChange:D=>j({...k,domain_id:D.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),f.map(D=>e.jsx("option",{value:D.id,children:D.fqdn},D.id))]})]}),g==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(J,{children:"IdP Entity ID *"}),e.jsx(X,{type:"text",value:k.idp_entity_id,onChange:D=>j({...k,idp_entity_id:D.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"IdP SSO URL *"}),e.jsx(X,{type:"url",value:k.idp_sso_url,onChange:D=>j({...k,idp_sso_url:D.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(ie,{style:{gridColumn:"1 / -1"},children:[e.jsx(J,{children:"X.509 Certificate *"}),e.jsx(j0,{value:k.idp_certificate,onChange:D=>j({...k,idp_certificate:D.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(J,{children:"Issuer URL *"}),e.jsx(X,{type:"url",value:k.oidc_issuer_url,onChange:D=>j({...k,oidc_issuer_url:D.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Client ID *"}),e.jsx(X,{type:"text",value:k.oidc_client_id,onChange:D=>j({...k,oidc_client_id:D.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Client Secret *"}),e.jsx(X,{type:"password",value:k.oidc_client_secret,onChange:D=>j({...k,oidc_client_secret:D.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Scopes"}),e.jsx(X,{type:"text",value:k.oidc_scopes,onChange:D=>j({...k,oidc_scopes:D.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(ie,{style:{gridColumn:"1 / -1"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px"},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.jsx(jr,{checked:k.jit_enabled,onChange:()=>j({...k,jit_enabled:!k.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>E(!S),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:S?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:S?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),S&&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(ie,{children:[e.jsx(J,{children:"First Name Attribute"}),e.jsx(X,{type:"text",value:k.attr_first_name,onChange:D=>j({...k,attr_first_name:D.target.value}),placeholder:g==="saml"?"givenName":"given_name"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Last Name Attribute"}),e.jsx(X,{type:"text",value:k.attr_last_name,onChange:D=>j({...k,attr_last_name:D.target.value}),placeholder:g==="saml"?"surname":"family_name"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Email Attribute"}),e.jsx(X,{type:"text",value:k.attr_email,onChange:D=>j({...k,attr_email:D.target.value}),placeholder:"email"})]})]})]})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end",gap:"12px",marginTop:"24px"},children:[e.jsx(B,{type:"button",onClick:r,style:{background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)",padding:"8px 16px",borderRadius:"6px"},children:"Cancel"}),e.jsx(B,{type:"submit",disabled:u,style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px"},children:u?"Saving...":"Create Connection"})]})]})]})]})]})};xt`
|
|
2494
|
+
`,z0=({onCreate:t,onClose:r,organization:o})=>{const{getOrganizationDomains:n,testEnterpriseConnectionConfig:i}=kt(),{deployment:s}=je(),{toast:d}=Ze(),[u,l]=a.useState(!1),[h,c]=a.useState(null),[g,m]=a.useState("saml"),[x,v]=a.useState(null),[S,E]=a.useState(!1),[k,j]=a.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[z,b]=a.useState(!1),[w,_]=a.useState(null),{data:f=[],isLoading:C}=We("wacht-org-verified-domains-for-sso-screen",async()=>(await(n==null?void 0:n(o))||[]).filter(M=>M.verified),{revalidateOnFocus:!1}),y=D=>{c(D),m(D.protocol),D.protocol==="saml"?j(M=>{var L,A,P;return{...M,idp_entity_id:D.placeholders.entityId||"",idp_sso_url:D.placeholders.ssoUrl||"",attr_first_name:((L=D.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((A=D.attributeMapping)==null?void 0:A.last_name)||"",attr_email:((P=D.attributeMapping)==null?void 0:P.email)||""}}):j(M=>{var L,A,P;return{...M,oidc_issuer_url:D.placeholders.issuerUrl||"",oidc_scopes:D.placeholders.scopes||"openid profile email",attr_first_name:((L=D.attributeMapping)==null?void 0:L.first_name)||"",attr_last_name:((A=D.attributeMapping)==null?void 0:A.last_name)||"",attr_email:((P=D.attributeMapping)==null?void 0:P.email)||""}})},$=s!=null&&s.backend_host?`${s.backend_host.startsWith("https://")?"":"https://"}${s.backend_host}/auth/sso/oidc/callback`:"",I=s!=null&&s.backend_host?`https://${s.backend_host}/auth/sso/metadata`:"",O=s!=null&&s.backend_host?`https://${s.backend_host}/auth/sso/callback`:"",R=(D,M)=>{navigator.clipboard.writeText(D),v(M),setTimeout(()=>v(null),2e3)},T=async D=>{D.preventDefault();const M=L=>L.includes("{")||L.includes("}");if(g==="saml"){if(!k.idp_entity_id||M(k.idp_entity_id)){d("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!k.idp_sso_url||M(k.idp_sso_url)){d("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!k.idp_certificate){d("Please provide the X.509 Certificate","error");return}}else{if(!k.oidc_issuer_url||M(k.oidc_issuer_url)){d("Please enter a valid Issuer URL (no placeholders)","error");return}if(!k.oidc_client_id||M(k.oidc_client_id)){d("Please enter a valid Client ID (no placeholders)","error");return}if(!k.oidc_client_secret){d("Please enter the Client Secret","error");return}}l(!0);try{const L={};k.attr_first_name&&(L.first_name=k.attr_first_name),k.attr_last_name&&(L.last_name=k.attr_last_name),k.attr_email&&(L.email=k.attr_email);const A=Object.keys(L).length>0;g==="saml"?await t({protocol:"saml",domain_id:k.domain_id||void 0,idp_entity_id:k.idp_entity_id,idp_sso_url:k.idp_sso_url,idp_certificate:k.idp_certificate,jit_enabled:k.jit_enabled,...A&&{attribute_mapping:L}}):await t({protocol:"oidc",domain_id:k.domain_id||void 0,oidc_issuer_url:k.oidc_issuer_url,oidc_client_id:k.oidc_client_id,oidc_client_secret:k.oidc_client_secret,oidc_scopes:k.oidc_scopes,jit_enabled:k.jit_enabled,...A&&{attribute_mapping:L}})}finally{l(!1)}},F=async()=>{b(!0),_(null);const D=A=>A.includes("{")||A.includes("}"),M={},L={};if(g==="saml"?(k.idp_entity_id?D(k.idp_entity_id)?(L.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):L.entity_id_valid=!0:(L.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID is required"),k.idp_sso_url?D(k.idp_sso_url)?(L.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):L.sso_url_valid=!0:(L.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL is required"),k.idp_certificate?L.certificate_provided=!0:(L.certificate_provided=!1,M.certificate_provided="X.509 Certificate is required")):(k.oidc_issuer_url?D(k.oidc_issuer_url)?(L.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):L.issuer_url_valid=!0:(L.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL is required"),k.oidc_client_id?D(k.oidc_client_id)?(L.client_id_valid=!1,M.client_id_valid="Client ID contains placeholder values - please replace with actual values"):L.client_id_valid=!0:(L.client_id_valid=!1,M.client_id_valid="Client ID is required")),Object.keys(M).length>0){_({success:!1,checks:L,errors:M}),b(!1);return}try{const A=g==="saml"?{protocol:"saml",idp_entity_id:k.idp_entity_id,idp_sso_url:k.idp_sso_url,idp_certificate:k.idp_certificate}:{protocol:"oidc",oidc_issuer_url:k.oidc_issuer_url,oidc_client_id:k.oidc_client_id,oidc_client_secret:k.oidc_client_secret},P=await(i==null?void 0:i(o,A));P&&_(P)}catch(A){_({success:!1,checks:{},errors:{general:"Test failed: "+A.message}})}finally{b(!1)}};return e.jsxs("form",{onSubmit:T,autoComplete:"off",children:[h?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:[h.logo?e.jsx(pi,{src:h.logo,alt:h.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(xt,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:h.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:h.protocol})]}),e.jsx("button",{type:"button",onClick:()=>c(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(hi,{children:"SAML Providers"}),e.jsx(Ma,{children:La.filter(D=>D.protocol==="saml").map(D=>e.jsxs(Da,{type:"button",$selected:!1,onClick:()=>y(D),children:[D.logo?e.jsx(pi,{src:D.logo,alt:D.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(xt,{size:18,color:"#666"})}),e.jsx(Fa,{children:D.name})]},D.id))}),e.jsx(hi,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Ma,{children:La.filter(D=>D.protocol==="oidc").map(D=>e.jsxs(Da,{type:"button",$selected:!1,onClick:()=>y(D),children:[D.logo?e.jsx(pi,{src:D.logo,alt:D.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(xt,{size:18,color:"#666"})}),e.jsx(Fa,{children:D.name})]},D.id))})]}),h&&e.jsxs(e.Fragment,{children:[e.jsxs(Aa,{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:g==="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:O}),e.jsx(ho,{onClick:()=>R(O,"acs"),children:x==="acs"?e.jsx(rt,{size:12}):e.jsx(mr,{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:I}),e.jsx(ho,{onClick:()=>R(I,"metadata"),children:x==="metadata"?e.jsx(rt,{size:12}):e.jsx(mr,{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:$}),e.jsx(ho,{onClick:()=>R($,"callback"),children:x==="callback"?e.jsx(rt,{size:12}):e.jsx(mr,{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(hi,{style:{margin:0},children:h?`${h.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[h&&h.docUrl&&e.jsxs("a",{href:h.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(gd,{size:12})," Docs"]}),e.jsx(B,{type:"button",onClick:F,disabled:z||!h,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:z?e.jsx(Ie,{size:16}):"Test Connection"}),e.jsx(B,{type:"submit",disabled:u||f.length===0||!h,style:{width:"auto",padding:"8px 16px"},children:u?e.jsx(Ie,{size:16}):"Create Connection"})]})]}),w&&(()=>{const D={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:w.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${w.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:w.success?"#10b981":"#ef4444"},children:w.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(w.checks).map(([M,L])=>{var A;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:L?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:L?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:D[M]||M.replace(/_/g," ").replace(/\b\w/g,P=>P.toUpperCase())}),((A=w.errors)==null?void 0:A[M])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:w.errors[M]})]})]},M)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!h&&e.jsxs(ie,{children:[e.jsx(J,{children:"Protocol *"}),e.jsxs(Na,{value:g,onChange:D=>m(D.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(ie,{style:{gridColumn:"1 / -1"},children:[e.jsx(J,{children:"Domain *"}),C?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):f.length===0?e.jsx(Aa,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(Na,{value:k.domain_id,onChange:D=>j({...k,domain_id:D.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),f.map(D=>e.jsx("option",{value:D.id,children:D.fqdn},D.id))]})]}),g==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(J,{children:"IdP Entity ID *"}),e.jsx(X,{type:"text",value:k.idp_entity_id,onChange:D=>j({...k,idp_entity_id:D.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"IdP SSO URL *"}),e.jsx(X,{type:"url",value:k.idp_sso_url,onChange:D=>j({...k,idp_sso_url:D.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(ie,{style:{gridColumn:"1 / -1"},children:[e.jsx(J,{children:"X.509 Certificate *"}),e.jsx(j0,{value:k.idp_certificate,onChange:D=>j({...k,idp_certificate:D.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(J,{children:"Issuer URL *"}),e.jsx(X,{type:"url",value:k.oidc_issuer_url,onChange:D=>j({...k,oidc_issuer_url:D.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Client ID *"}),e.jsx(X,{type:"text",value:k.oidc_client_id,onChange:D=>j({...k,oidc_client_id:D.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Client Secret *"}),e.jsx(X,{type:"password",value:k.oidc_client_secret,onChange:D=>j({...k,oidc_client_secret:D.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Scopes"}),e.jsx(X,{type:"text",value:k.oidc_scopes,onChange:D=>j({...k,oidc_scopes:D.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(ie,{style:{gridColumn:"1 / -1"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px"},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.jsx(jr,{checked:k.jit_enabled,onChange:()=>j({...k,jit_enabled:!k.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>E(!S),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:S?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:S?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),S&&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(ie,{children:[e.jsx(J,{children:"First Name Attribute"}),e.jsx(X,{type:"text",value:k.attr_first_name,onChange:D=>j({...k,attr_first_name:D.target.value}),placeholder:g==="saml"?"givenName":"given_name"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Last Name Attribute"}),e.jsx(X,{type:"text",value:k.attr_last_name,onChange:D=>j({...k,attr_last_name:D.target.value}),placeholder:g==="saml"?"surname":"family_name"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Email Attribute"}),e.jsx(X,{type:"text",value:k.attr_email,onChange:D=>j({...k,attr_email:D.target.value}),placeholder:"email"})]})]})]})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",display:"flex",justifyContent:"flex-end",gap:"12px",marginTop:"24px"},children:[e.jsx(B,{type:"button",onClick:r,style:{background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)",padding:"8px 16px",borderRadius:"6px"},children:"Cancel"}),e.jsx(B,{type:"submit",disabled:u,style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px"},children:u?"Saving...":"Create Connection"})]})]})]})]})]})};yt`
|
|
2495
2495
|
0% { transform: rotate(0deg); }
|
|
2496
2496
|
100% { transform: rotate(360deg); }
|
|
2497
2497
|
`;const Ua=p.div`
|
|
@@ -2755,12 +2755,12 @@ cursor: pointer;
|
|
|
2755
2755
|
flex-shrink: 0;
|
|
2756
2756
|
display: block;
|
|
2757
2757
|
}
|
|
2758
|
-
`;const A0=({organization:t})=>{var D,M,L,A;const{switchOrganization:r,refetch:o}=Be(),{workspaces:n}=
|
|
2758
|
+
`;const A0=({organization:t})=>{var D,M,L,A;const{switchOrganization:r,refetch:o}=Be(),{workspaces:n}=Qt(),{deployment:i}=je(),{deleteOrganization:s,updateOrganization:d}=kt(),{toast:u}=Ze(),[l,h]=a.useState((t==null?void 0:t.name)||""),[c,g]=a.useState((t==null?void 0:t.description)||""),[m,x]=a.useState((t==null?void 0:t.image_url)||null),v=a.useRef(null),[S,E]=a.useState(!1),[k,j]=a.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[z,b]=a.useState(""),[w,_]=a.useState(!1),[f,C]=a.useState(!1),[y,$]=a.useState(null),I=a.useRef({name:l,description:c,security:k,imageFile:y,isSaving:S});a.useEffect(()=>{I.current={name:l,description:c,security:k,imageFile:y,isSaving:S}},[l,c,k,y,S]);const O=a.useCallback(async()=>{if(!t||I.current.isSaving)return;const P=I.current;try{E(!0),await d(t,{name:P.name,description:P.description,image:P.imageFile,whitelisted_ips:P.security.allowed_ips.split(`
|
|
2759
2759
|
`).filter(N=>N.trim()),enable_ip_restriction:P.security.ip_restrictions,enforce_mfa:P.security.mfa_required,auto_assigned_workspace_id:P.security.default_workspace_id||"0"}),u("Changes saved","info")}catch(N){const W=N.message||"Failed to save changes. Please try again.";u(W,"error")}finally{E(!1)}},[t,d,u]);a.useEffect(()=>{var P;t&&(h(t.name||""),g(t.description||""),x(t.image_url||null),j({allowed_ips:((P=t.whitelisted_ips)==null?void 0:P.join(`
|
|
2760
2760
|
`))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const R=a.useMemo(()=>n.filter(N=>N.organization.id===(t==null?void 0:t.id)),[n,t==null?void 0:t.id]),T=async()=>{if(!(!t||z!==t.name))try{_(!0),await r(""),await s(t),await o(),u("Organization deleted successfully","info")}catch{u("Failed to delete organization","error")}finally{_(!1),b("")}};a.useEffect(()=>()=>{m&&m.startsWith("blob:")&&URL.revokeObjectURL(m)},[m]);const F=async P=>{var N;if((N=P.target.files)!=null&&N[0]){const W=P.target.files[0];if(W.size>2*1024*1024){u("File size cannot exceed 2MB","error");return}if(!W.type.startsWith("image/")){u("Please select a valid image file","error");return}m&&m.startsWith("blob:")&&URL.revokeObjectURL(m),$(W),x(URL.createObjectURL(W));try{E(!0);const H=I.current;await d(t,{name:H.name,description:H.description,image:W,whitelisted_ips:H.security.allowed_ips.split(`
|
|
2761
2761
|
`).filter(oe=>oe.trim()),enable_ip_restriction:H.security.ip_restrictions,enforce_mfa:H.security.mfa_required,auto_assigned_workspace_id:H.security.default_workspace_id||"0"}),u("Logo updated","info")}catch(H){u(H.message||"Failed to update logo","error")}finally{E(!1)}}};return t?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)",paddingBottom:"40px"},children:[e.jsxs(I0,{children:[e.jsx(T0,{children:e.jsxs("div",{style:{width:"90px",height:"90px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:m?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease",boxShadow:"0 2px 8px var(--color-shadow)"},onClick:()=>{var P;return(P=v.current)==null?void 0:P.click()},children:[m?e.jsx("img",{src:m,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"cover"}}):e.jsx(is,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:v,style:{display:"none"},accept:"image/*",onChange:F})]})}),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 4px 0",fontWeight:"400"},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(O0,{style:{marginBottom:"var(--space-sm)"},children:[e.jsx(B,{$size:"sm",onClick:()=>{var P;return(P=v.current)==null?void 0:P.click()},children:m?"Change":"Upload"}),m&&e.jsxs(B,{$outline:!0,$size:"sm",onClick:async()=>{x(null),$(null);try{E(!0);const P=I.current;await d(t,{name:P.name,description:P.description,image:"null",whitelisted_ips:P.security.allowed_ips.split(`
|
|
2762
|
-
`).filter(N=>N.trim()),enable_ip_restriction:P.security.ip_restrictions,enforce_mfa:P.security.mfa_required,auto_assigned_workspace_id:P.security.default_workspace_id||"0"}),u("Logo removed","info")}catch(P){u(P.message||"Failed to remove logo","error")}finally{E(!1)}},children:[e.jsx(
|
|
2763
|
-
10.0.0.0/24`,style:{minHeight:"80px",fontFamily:"monospace"}})]})]}),((L=i==null?void 0:i.b2b_settings)==null?void 0:L.workspaces_enabled)&&R.length>0&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(zn,{options:R.map(P=>({value:P.id,label:P.name})),value:k.default_workspace_id,onChange:P=>{j(N=>({...N,default_workspace_id:P})),setTimeout(()=>O(),0)},placeholder:"Select default workspace"})]})]})]}),((A=i==null?void 0:i.b2b_settings)==null?void 0:A.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),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:f?"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 an organization, there is no going back. Please be certain."})]}),e.jsx(B,{onClick:()=>{f?(C(!1),b("")):C(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:f?"Cancel":"Delete"})]}),f&&e.jsxs("div",{style:{width:"100%",marginTop:"16px"},children:[e.jsxs(ie,{children:[e.jsxs(J,{htmlFor:"confirm_org_name",children:["Type ",e.jsx("strong",{children:t.name})," to confirm"]}),e.jsx(X,{id:"confirm_org_name",type:"text",value:z,onChange:P=>b(P.target.value),placeholder:"Organization name",style:{width:"100%"}})]}),e.jsx(B,{onClick:T,disabled:z!==t.name||w,style:{background:z===t.name?"var(--color-error)":"transparent",color:z===t.name?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:z===t.name?"pointer":"not-allowed",width:"100%"},children:w?e.jsx(Ie,{size:12}):"Delete Forever"})]})]})]})]})]}):e.jsx(Ie,{})}
|
|
2762
|
+
`).filter(N=>N.trim()),enable_ip_restriction:P.security.ip_restrictions,enforce_mfa:P.security.mfa_required,auto_assigned_workspace_id:P.security.default_workspace_id||"0"}),u("Logo removed","info")}catch(P){u(P.message||"Failed to remove logo","error")}finally{E(!1)}},children:[e.jsx(Ct,{size:14,style:{marginRight:"4px"}})," Remove"]})]})]})]}),e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)",textAlign:"inherit"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 4px 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:"20px"},children:[e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"name",children:"Organization Name"}),e.jsx(X,{id:"name",value:l,onChange:P=>h(P.target.value),onBlur:O,placeholder:"Enter organization name",required:!0})]}),e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"description",children:"Description"}),e.jsx(X,{id:"description",as:"textarea",value:c,onChange:P=>g(P.target.value),onBlur:O,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical"}})]}),((D=i==null?void 0:i.b2b_settings)==null?void 0:D.enforce_mfa_per_org_enabled)&&e.jsxs(Ba,{style:{padding:"0"},children:[e.jsxs(Wa,{children:[e.jsx(J,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"Multi-Factor Authentication"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Require all members to set up MFA for added security"})]}),e.jsx(Va,{children:e.jsx(jr,{checked:k.mfa_required,onChange:()=>{const P=!k.mfa_required;j(N=>({...N,mfa_required:P})),setTimeout(()=>O(),0)}})})]}),((M=i==null?void 0:i.b2b_settings)==null?void 0:M.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs(Ba,{style:{padding:"0"},children:[e.jsxs(Wa,{children:[e.jsx(J,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"IP Restrictions"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Only allow access from specific IP addresses"})]}),e.jsx(Va,{children:e.jsx(jr,{checked:k.ip_restrictions,onChange:()=>{const P=!k.ip_restrictions;j(N=>({...N,ip_restrictions:P})),setTimeout(()=>O(),0)}})})]}),k.ip_restrictions&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(X,{id:"allowed_ips",as:"textarea",value:k.allowed_ips,onChange:P=>j(N=>({...N,allowed_ips:P.target.value})),onBlur:O,placeholder:`192.168.1.1
|
|
2763
|
+
10.0.0.0/24`,style:{minHeight:"80px",fontFamily:"monospace"}})]})]}),((L=i==null?void 0:i.b2b_settings)==null?void 0:L.workspaces_enabled)&&R.length>0&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(zn,{options:R.map(P=>({value:P.id,label:P.name})),value:k.default_workspace_id,onChange:P=>{j(N=>({...N,default_workspace_id:P})),setTimeout(()=>O(),0)},placeholder:"Select default workspace"})]})]})]}),((A=i==null?void 0:i.b2b_settings)==null?void 0:A.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),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:f?"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 an organization, there is no going back. Please be certain."})]}),e.jsx(B,{onClick:()=>{f?(C(!1),b("")):C(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:f?"Cancel":"Delete"})]}),f&&e.jsxs("div",{style:{width:"100%",marginTop:"16px"},children:[e.jsxs(ie,{children:[e.jsxs(J,{htmlFor:"confirm_org_name",children:["Type ",e.jsx("strong",{children:t.name})," to confirm"]}),e.jsx(X,{id:"confirm_org_name",type:"text",value:z,onChange:P=>b(P.target.value),placeholder:"Organization name",style:{width:"100%"}})]}),e.jsx(B,{onClick:T,disabled:z!==t.name||w,style:{background:z===t.name?"var(--color-error)":"transparent",color:z===t.name?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:z===t.name?"pointer":"not-allowed",width:"100%"},children:w?e.jsx(Ie,{size:12}):"Delete Forever"})]})]})]})]})]}):e.jsx(Ie,{})},$t=p.table`
|
|
2764
2764
|
width: 100%;
|
|
2765
2765
|
border-collapse: separate;
|
|
2766
2766
|
border-spacing: 0;
|
|
@@ -2769,9 +2769,9 @@ cursor: pointer;
|
|
|
2769
2769
|
border-radius: 8px;
|
|
2770
2770
|
overflow: hidden;
|
|
2771
2771
|
background: var(--color-background);
|
|
2772
|
-
`,
|
|
2772
|
+
`,zt=p.thead`
|
|
2773
2773
|
background-color: var(--color-background-alt);
|
|
2774
|
-
|
|
2774
|
+
`,Et=p.tbody`
|
|
2775
2775
|
background-color: var(--color-background);
|
|
2776
2776
|
|
|
2777
2777
|
tr:last-child td:last-child {
|
|
@@ -2781,7 +2781,7 @@ cursor: pointer;
|
|
|
2781
2781
|
&:not(:last-child) td {
|
|
2782
2782
|
border-bottom: 1px solid var(--color-border);
|
|
2783
2783
|
}
|
|
2784
|
-
`,
|
|
2784
|
+
`,Pe=p.th`
|
|
2785
2785
|
text-align: left;
|
|
2786
2786
|
padding: 8px 16px;
|
|
2787
2787
|
font-weight: 400;
|
|
@@ -2812,7 +2812,7 @@ cursor: pointer;
|
|
|
2812
2812
|
align-items: center;
|
|
2813
2813
|
gap: 12px;
|
|
2814
2814
|
}
|
|
2815
|
-
`;const
|
|
2815
|
+
`;const Pt=p(Fe)`
|
|
2816
2816
|
text-align: right;
|
|
2817
2817
|
width: auto;
|
|
2818
2818
|
white-space: nowrap;
|
|
@@ -2840,7 +2840,7 @@ cursor: pointer;
|
|
|
2840
2840
|
margin: 0;
|
|
2841
2841
|
max-width: 320px;
|
|
2842
2842
|
line-height: 1.5;
|
|
2843
|
-
`,
|
|
2843
|
+
`,bt=({title:t,description:r,action:o})=>e.jsxs(L0,{children:[e.jsx(M0,{children:t}),e.jsx(D0,{children:r}),o&&e.jsx("div",{style:{marginTop:"24px"},children:o})]}),F0=p.div`
|
|
2844
2844
|
position: fixed;
|
|
2845
2845
|
width: 360px;
|
|
2846
2846
|
max-width: calc(100vw - 48px);
|
|
@@ -2889,7 +2889,7 @@ cursor: pointer;
|
|
|
2889
2889
|
color: var(--color-foreground);
|
|
2890
2890
|
background: var(--color-input-background);
|
|
2891
2891
|
}
|
|
2892
|
-
`,Ka=({onClose:t,domain:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(),[d,u]=a.useState(""),[l,h]=a.useState(!1),[c,g]=a.useState(!1),[m,x]=a.useState({top:0,left:0}),{addDomain:v,verifyDomain:S}=Cr(),{toast:E}=
|
|
2892
|
+
`,Ka=({onClose:t,domain:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(),[d,u]=a.useState(""),[l,h]=a.useState(!1),[c,g]=a.useState(!1),[m,x]=a.useState({top:0,left:0}),{addDomain:v,verifyDomain:S}=Cr(),{toast:E}=Ze(),k=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),j=w=>w.trim().toLowerCase().replace(/^https?:\/\//,""),z=async()=>{const w=j(d);if(!w){E("Please enter a domain name","error");return}if(!k(w)){E("Please enter a valid domain name (e.g., example.com)","error");return}if(w.length>253){E("Domain name is too long","error");return}try{const _=await v({fqdn:w});E("Domain added successfully","info"),s(_.data)}catch(_){const f=_.message||"Failed to add domain. Please try again.";E(f,"error")}},b=async()=>{if(!(!i||l)){h(!0);try{await S(i),t==null||t(),E("Domain verified successfully","info")}catch(w){const _=w.message||"Failed to verify domain. Please check DNS records and try again.";E(_,"error")}finally{h(!1)}}};return a.useEffect(()=>{g(!0);const w=setTimeout(()=>{if(!n.current)return;const C=o==null?void 0:o.current,y=360,$=250,I=8;let O=0,R=0;if(!C){const M=n.current.getBoundingClientRect(),L=M.width||y,A=M.height||$;O=Math.max(I,(window.innerHeight-A)/2),R=Math.max(I,(window.innerWidth-L)/2),x({top:O,left:R});return}const T=C.getBoundingClientRect(),F=window.innerHeight-T.bottom,D=T.top;F>=$+I?(O=T.bottom+I,R=T.right-y,R<I&&(R=T.left,R+y>window.innerWidth-I&&(R=(window.innerWidth-y)/2))):D>=$+I?(O=T.top-$-I,R=T.right-y,R<I&&(R=T.left,R+y>window.innerWidth-I&&(R=(window.innerWidth-y)/2))):(O=T.bottom+I,R=T.right-y,R<I&&(R=T.left)),x({top:O,left:R})},10),_=C=>{n.current&&!n.current.contains(C.target)&&(t==null||t())},f=C=>{C.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",f),()=>{clearTimeout(w),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",f)}},[t,o]),a.useEffect(()=>{r&&s(r)},[r]),c?e.jsx(F0,{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:i?e.jsxs(e.Fragment,{children:[e.jsxs(Ga,{children:[e.jsx(Ha,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Qa,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(Dt,{size:16})})]}),e.jsxs(qa,{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(ie,{children:[e.jsx(J,{children:"Record Type"}),e.jsx(X,{value:i==null?void 0:i.verification_dns_record_type,disabled:!0})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Record Name"}),e.jsx(X,{value:i==null?void 0:i.verification_dns_record_name,disabled:!0})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Record Data"}),e.jsx(X,{type:"text",value:i==null?void 0:i.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Ya,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:b,disabled:l,style:{width:"auto"},children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ga,{children:[e.jsx(Ha,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Qa,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(Dt,{size:16})})]}),e.jsx(qa,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(ie,{children:[e.jsx(J,{children:"Enter FQDN"}),e.jsx(X,{type:"text",placeholder:"Enter your domain",value:d,onChange:w=>u(w.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Ya,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:z,disabled:!d||l,style:{width:"auto"},children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Fo=p.span`
|
|
2893
2893
|
background: ${t=>t.$type==="success"?"var(--color-primary-background)":"var(--color-warning-background)"};
|
|
2894
2894
|
color: ${t=>t.$type==="success"?"var(--color-primary)":"var(--color-warning)"};
|
|
2895
2895
|
padding: 4px 8px;
|
|
@@ -2922,7 +2922,7 @@ cursor: pointer;
|
|
|
2922
2922
|
display: flex;
|
|
2923
2923
|
flex-direction: column;
|
|
2924
2924
|
gap: 12px;
|
|
2925
|
-
`,W0=({organization:t})=>{const{getOrganizationDomains:r,removeOrganizationDomain:o}=
|
|
2925
|
+
`,W0=({organization:t})=>{const{getOrganizationDomains:r,removeOrganizationDomain:o}=kt(),[n,i]=a.useState(null),{data:s=[],isLoading:d,mutate:u}=We(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(r==null?void 0:r(t))||[]).map(w=>({...w,verified:w.verified!==void 0?w.verified:!1}))),[l,h]=a.useState(!1),[c,g]=a.useState(null),[m,x]=a.useState(""),[v,S]=a.useState(null),E=a.useRef(null),k=a.useRef({}),j=a.useMemo(()=>{if(!m.trim())return s;const b=m.toLowerCase();return s.filter(w=>w.fqdn.toLowerCase().includes(b))},[s,m]),z=async b=>{await o(t,b),u(),i(null)};return d?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(Pn,{children:[e.jsx(Ut,{value:m,onChange:x,placeholder:"Search domains..."}),e.jsx(B,{$size:"sm",ref:E,onClick:()=>h(!0),children:"Add Domain"}),l&&e.jsx(Ka,{onClose:()=>{h(!1),u()},triggerRef:E})]}),(j==null?void 0:j.length)>0&&e.jsxs(N0,{children:[e.jsx(Af,{size:18,color:"var(--color-primary)",style:{flexShrink:0,marginTop:"2px"}}),e.jsxs(U0,{children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and will be auto-assigned to the default workspace.",". This helps streamline onboarding for your team."]})]}),j!=null&&j.length?e.jsxs(e.Fragment,{children:[e.jsx(Rn,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Domain"}),e.jsx(Pe,{children:"Status"}),e.jsx(Pe,{children:"Date Added"}),e.jsx(Pe,{})]})}),e.jsx(Et,{children:j.map(b=>e.jsxs(He,{children:[e.jsx(Fe,{children:b.fqdn}),e.jsx(Fe,{children:b.verified?e.jsx(Fo,{$type:"success",children:"✓ Verified"}):e.jsxs(Fo,{$type:"warning",children:[e.jsx(Yt,{size:12})," Pending"]})}),e.jsx(Fe,{children:new Date(b.created_at).toLocaleDateString()}),e.jsx(Pt,{children:e.jsx(Za,{domain:b,selectedAction:v,setSelectedAction:S,onVerify:()=>g(b.id),onDelete:()=>i(b.id),actionButtonRefs:k})})]},b.id))})]})}),e.jsx(In,{children:j.map(b=>e.jsxs(B0,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:400,fontSize:"14px",marginBottom:"4px"},children:b.fqdn}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:["Added on ",new Date(b.created_at).toLocaleDateString()]})]}),e.jsx(Za,{domain:b,selectedAction:v,setSelectedAction:S,onVerify:()=>g(b.id),onDelete:()=>i(b.id),actionButtonRefs:k})]}),e.jsx("div",{children:b.verified?e.jsx(Fo,{$type:"success",children:"✓ Verified"}):e.jsxs(Fo,{$type:"warning",children:[e.jsx(Yt,{size:12})," Pending Verification"]})})]},b.id))})]}):e.jsx(bt,{title:m?"No domains match your search":"No domains added",description:m?"Try a different search term.":"Manage your corporate domains to streamline onboarding for your team."}),n&&e.jsx(Wr,{title:"Delete domain?",description:"Are you sure you want to remove this domain? Active users won't be affected but new ones won't auto-join.",onConfirm:()=>{const b=s.find(w=>w.id===n);b&&z(b)},onCancel:()=>i(null)}),c&&e.jsx(Ka,{domain:s.find(b=>b.id===c),onClose:()=>g(null),triggerRef:{current:k.current[c]}})]})},Za=({domain:t,selectedAction:r,setSelectedAction:o,onVerify:n,onDelete:i,actionButtonRefs:s})=>e.jsx("div",{style:{position:"relative"},children:e.jsxs(at,{open:r===t.id,openChange:d=>o(d?t.id:null),children:[e.jsx(lt,{children:e.jsx(ls,{ref:d=>{s.current[t.id]=d},children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Oe,{onClick:()=>{n(),o(null)},children:t.verified?"📋 View DNS Record":"✓ Verify Domain"}),e.jsxs(Oe,{onClick:()=>{navigator.clipboard.writeText(t.fqdn),o(null)},children:[e.jsx(mr,{size:16})," Copy Domain"]}),e.jsxs(Oe,{onClick:()=>{window.open(`https://${t.fqdn}`,"_blank"),o(null)},children:[e.jsx(gd,{size:16})," Visit Domain"]}),e.jsx($n,{}),e.jsxs(Oe,{$destructive:!0,onClick:()=>{i(),o(null)},children:[e.jsx(Ct,{size:16})," Remove Domain"]})]})]})}),V0=p.div`
|
|
2926
2926
|
position: fixed;
|
|
2927
2927
|
width: 360px;
|
|
2928
2928
|
max-width: calc(100vw - 48px);
|
|
@@ -2971,7 +2971,7 @@ cursor: pointer;
|
|
|
2971
2971
|
color: var(--color-foreground);
|
|
2972
2972
|
background: var(--color-input-background);
|
|
2973
2973
|
}
|
|
2974
|
-
`,Vd=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const i=a.useRef(null),[s,d]=a.useState(""),[u,l]=a.useState(null),[h,c]=a.useState(!1),[g,m]=a.useState(!1),[x,v]=a.useState({top:0,left:0}),{inviteMember:S}=Cr(),{toast:E}=
|
|
2974
|
+
`,Vd=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const i=a.useRef(null),[s,d]=a.useState(""),[u,l]=a.useState(null),[h,c]=a.useState(!1),[g,m]=a.useState(!1),[x,v]=a.useState({top:0,left:0}),{inviteMember:S}=Cr(),{toast:E}=Ze(),k=o.map(b=>({value:b.id,label:b.name})),j=b=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b),z=async()=>{const b=s.trim().toLowerCase();if(!(!b||!u)){if(!j(b)){E("Please enter a valid email address","error");return}if(b.length>320){E("Email address is too long","error");return}c(!0);try{await S({email:b,organizationRole:u}),r==null||r()}catch(w){const _=w.message||"Failed to send invitation. Please try again.";E(_,"error")}finally{c(!1)}}};return a.useEffect(()=>{m(!0);const b=setTimeout(()=>{if(!i.current||!(n!=null&&n.current))return;const f=n.current;if(f){const C=f.getBoundingClientRect(),y=360,$=250,I=8;let O=0,R=0;const T=window.innerHeight-C.bottom,F=C.top;T>=$+I?(O=C.bottom+I,R=C.right-y,R<I&&(R=C.left,R+y>window.innerWidth-I&&(R=(window.innerWidth-y)/2))):F>=$+I?(O=C.top-$-I,R=C.right-y,R<I&&(R=C.left,R+y>window.innerWidth-I&&(R=(window.innerWidth-y)/2))):(O=C.bottom+I,R=C.right-y,R<I&&(R=C.left)),v({top:O,left:R})}},10),w=f=>{i.current&&!i.current.contains(f.target)&&(t==null||t())},_=f=>{f.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",_),()=>{clearTimeout(b),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",_)}},[t,n]),g?e.jsxs(V0,{ref:i,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(G0,{children:[e.jsx(H0,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Q0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Dt,{size:16})})]}),e.jsx(q0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(J,{children:"Email Address"}),e.jsx(X,{type:"email",placeholder:"colleague@company.com",value:s,onChange:b=>d(b.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Role"}),e.jsx(zn,{options:k,value:u==null?void 0:u.id,onChange:b=>l(o.find(w=>w.id===b)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Y0,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:z,disabled:!s||!u||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},K0=p.div`
|
|
2975
2975
|
width: 40px;
|
|
2976
2976
|
height: 40px;
|
|
2977
2977
|
border-radius: 50%;
|
|
@@ -2983,7 +2983,7 @@ cursor: pointer;
|
|
|
2983
2983
|
font-weight: 400;
|
|
2984
2984
|
font-size: 14px;
|
|
2985
2985
|
overflow: hidden;
|
|
2986
|
-
`,Z0=({organization:t})=>{const{getOrganizationMembers:r,getOrganizationRoles:o,addRoleToOrganizationMember:n,removeRoleFromOrganizationMember:i,removeOrganizationMember:s}=
|
|
2986
|
+
`,Z0=({organization:t})=>{const{getOrganizationMembers:r,getOrganizationRoles:o,addRoleToOrganizationMember:n,removeRoleFromOrganizationMember:i,removeOrganizationMember:s}=kt(),{session:d}=Be(),{toast:u}=Ze(),[l,h]=a.useState(""),[c,g]=a.useState(1),[m]=a.useState(10),[x,v]=a.useState(!1),S=a.useRef(null),[E,k]=a.useState(l);a.useEffect(()=>{const R=setTimeout(()=>{k(l),g(1)},500);return()=>clearTimeout(R)},[l]);const{data:j,isLoading:z,mutate:b}=We(t?`wacht-api-organizations:${t.id}:members:${c}:${m}:${E}`:null,()=>r==null?void 0:r(t,{page:c,limit:m,search:E})),w=(j==null?void 0:j.data)||[],_=(j==null?void 0:j.meta)||{total:0,limit:10},f=Math.ceil(_.total/(_.limit||10)),{data:C=[],isLoading:y}=We(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o(t))||[]),$=C,I=async(R,T,F)=>{try{F?(await i(t,R,T),u("Role removed successfully","info")):(await n(t,R,T),u("Role added successfully","info")),b()}catch(D){u(D.message||"Failed to update role","error")}},O=async R=>{try{await s(t,R),b(),u("Member removed successfully","info")}catch(T){u(T.message||"Failed to remove member","error")}};return z||y?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(Pn,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Ut,{value:l,onChange:h,placeholder:"Search members..."})}),e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[_.total>0&&e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)"},children:[_.total," member",_.total!==1?"s":""]}),e.jsx(B,{$size:"sm",ref:S,onClick:()=>v(!0),children:"Invite"})]})]}),x&&e.jsx(Vd,{onClose:()=>v(!1),onSuccess:()=>{b(),v(!1)},roles:$,triggerRef:S}),w.length===0?e.jsx(bt,{title:l?"No members match":"No members yet",description:"Members with corporate domains will automatically join."}):e.jsxs(e.Fragment,{children:[e.jsx(Rn,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Member"}),e.jsx(Pe,{children:"Joined"}),e.jsx(Pe,{children:"Roles"})]})}),e.jsx(Et,{children:w.map(R=>e.jsxs(He,{children:[e.jsx(Fe,{children:e.jsx(Ja,{member:R,session:d})}),e.jsx(Fe,{children:new Date(R.created_at).toLocaleDateString()}),e.jsx(Pt,{children:e.jsx(Xa,{member:R,roles:$,onToggle:I,onRemove:O})})]},R.id))})]})}),e.jsx(In,{children:w.map(R=>e.jsx(ds,{children:e.jsxs(us,{children:[e.jsx(Ja,{member:R,session:d,subtitle:`Joined ${new Date(R.created_at).toLocaleDateString()}`}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(Xa,{member:R,roles:$,onToggle:I,onRemove:O})})]})},R.id))})]}),f>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"16px",marginTop:"24px"},children:[e.jsx(B,{onClick:()=>g(R=>Math.max(1,R-1)),disabled:c===1,$size:"sm",children:"Previous"}),e.jsxs("span",{style:{fontSize:"13px"},children:[c," / ",f]}),e.jsx(B,{onClick:()=>g(R=>Math.min(f,R+1)),disabled:c===f,$size:"sm",children:"Next"})]})]})},Ja=({member:t,session:r,subtitle:o})=>{var d,u,l;const n=t.user,i=(n==null?void 0:n.id)===((d=r==null?void 0:r.active_signin)==null?void 0:d.user_id),s=(h="",c="")=>`${h[0]||""}${c[0]||""}`.toUpperCase();return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx(K0,{children:n!=null&&n.profile_picture_url?e.jsx("img",{src:n.profile_picture_url,alt:"Avatar",style:{width:"100%",height:"100%",objectFit:"cover"}}):s(n==null?void 0:n.first_name,n==null?void 0:n.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:"400"},children:n?`${n.first_name||""} ${n.last_name||""}`.trim()||((u=n.primary_email_address)==null?void 0:u.email):"Unknown"}),i&&e.jsx("span",{style:{fontSize:"10px",padding:"1px 4px",background:"var(--color-background-alt)",color:"var(--color-muted)",borderRadius:"3px",fontWeight:"400"},children:"You"})]}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--color-secondary-text)",fontWeight:"400",display:"flex",flexWrap:"wrap",gap:"4px 8px"},children:[e.jsx("span",{children:(l=n==null?void 0:n.primary_email_address)==null?void 0:l.email}),o&&e.jsxs("span",{style:{color:"var(--color-muted)"},children:["• ",o]})]})]})]})},Xa=({member:t,roles:r,onToggle:o,onRemove:n})=>{const i=t.roles||[],s=d=>i.some(u=>u.id===d);return e.jsxs(at,{children:[e.jsx(lt,{children:e.jsxs(B,{$outline:!0,$size:"sm",style:{color:"var(--color-foreground)"},children:[i.length>0?i[0].name:"No role"," ",e.jsx(qt,{size:14,style:{marginLeft:"4px"}})]})}),e.jsxs(ct,{children:[r.map(d=>{const u=s(d.id);return e.jsx(Oe,{onClick:()=>o(t,d,u),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",gap:"12px"},children:[e.jsx("span",{children:d.name}),u&&e.jsx(rt,{size:14,color:"var(--color-success)"})]})},d.id)}),e.jsx($n,{}),e.jsx(Oe,{$destructive:!0,onClick:()=>n(t),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ct,{size:14})," Remove Member"]})})]})]})},J0=({organization:t})=>{const{getOrganizationInvitations:r,getOrganizationRoles:o,discardOrganizationInvitation:n,resendOrganizationInvitation:i}=kt(),{toast:s}=Ze(),[d,u]=a.useState(!1),[l,h]=a.useState(""),c=a.useRef(null),{data:g=[],isLoading:m,mutate:x}=We(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(r==null?void 0:r(t))||[]),{data:v=[],isLoading:S}=We(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o(t))||[]),E=v,k=a.useMemo(()=>{if(!l)return g;const b=l.toLowerCase();return g.filter(w=>w.email.toLowerCase().includes(b))},[g,l]),j=async b=>{try{await n(t,b),x(),s("Invitation cancelled","info")}catch(w){s(w.message||"Failed to cancel invitation","error")}},z=async b=>{try{await i(t,b),s("Invitation resent","info")}catch(w){s(w.message||"Failed to resend invitation","error")}};return m||S?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(Pn,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Ut,{value:l,onChange:h,placeholder:"Search invitations..."})}),e.jsx(B,{$size:"sm",ref:c,onClick:()=>u(!0),children:"Invite"})]}),d&&e.jsx(Vd,{onClose:()=>u(!1),onSuccess:()=>{x(),u(!1)},roles:E,triggerRef:c}),k.length===0?e.jsx(bt,{title:l?"No invitations match":"No pending invitations",description:"Invite members to collaborate."}):e.jsxs(e.Fragment,{children:[e.jsx(Rn,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Email"}),e.jsx(Pe,{children:"Role"}),e.jsx(Pe,{children:"Invited"}),e.jsx(Pe,{})]})}),e.jsx(Et,{children:k.map(b=>{var w;return e.jsxs(He,{children:[e.jsx(Fe,{children:b.email}),e.jsx(Fe,{children:((w=b.initial_organization_role)==null?void 0:w.name)||"No role"}),e.jsx(Fe,{children:new Date(b.created_at).toLocaleDateString()}),e.jsx(Pt,{children:e.jsx(ec,{invitation:b,onResend:z,onCancel:j})})]},b.id)})})]})}),e.jsx(In,{children:k.map(b=>{var w;return e.jsx(ds,{children:e.jsxs(us,{children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"14px",marginBottom:"4px"},children:b.email}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:[((w=b.initial_organization_role)==null?void 0:w.name)||"No role"," • ",new Date(b.created_at).toLocaleDateString()]})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(ec,{invitation:b,onResend:z,onCancel:j})})]})},b.id)})})]})]})},ec=({invitation:t,onResend:r,onCancel:o})=>e.jsxs(at,{children:[e.jsx(lt,{children:e.jsx(ls,{children:"•••"})}),e.jsxs(ct,{children:[e.jsxs(Oe,{onClick:()=>r(t),children:[e.jsx(Sn,{size:16})," Resend"]}),e.jsxs(Oe,{$destructive:!0,onClick:()=>o(t),children:[e.jsx(Ct,{size:16})," Cancel"]})]})]}),X0=p.div`
|
|
2987
2987
|
position: fixed;
|
|
2988
2988
|
width: 400px;
|
|
2989
2989
|
max-width: calc(100vw - 48px);
|
|
@@ -3034,7 +3034,7 @@ cursor: pointer;
|
|
|
3034
3034
|
color: var(--color-foreground);
|
|
3035
3035
|
background: var(--color-input-background);
|
|
3036
3036
|
}
|
|
3037
|
-
`,tc=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var _;const i=a.useRef(null),[s,d]=a.useState((o==null?void 0:o.name)||""),[u,l]=a.useState((o==null?void 0:o.permissions)||[]);Cr();const[h,c]=a.useState(!1),[g,m]=a.useState(!1),[x,v]=a.useState({top:0,left:0}),{deployment:S}=je(),{toast:E}=
|
|
3037
|
+
`,tc=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var _;const i=a.useRef(null),[s,d]=a.useState((o==null?void 0:o.name)||""),[u,l]=a.useState((o==null?void 0:o.permissions)||[]);Cr();const[h,c]=a.useState(!1),[g,m]=a.useState(!1),[x,v]=a.useState({top:0,left:0}),{deployment:S}=je(),{toast:E}=Ze(),k=!!o,j=Array.isArray((_=S==null?void 0:S.b2b_settings)==null?void 0:_.organization_permissions)?S.b2b_settings.organization_permissions.map(f=>({value:f,label:f})):[];a.useEffect(()=>{m(!0);const f=setTimeout(()=>{if(!i.current)return;let I=null;if(n!=null&&n.current)I=n.current;else if(k){const O=document.querySelectorAll("[data-role-dropdown-trigger]");for(let R=0;R<O.length;R++){const T=O[R];if(T.offsetParent!==null){I=T;break}}}else{const O=document.querySelectorAll("button");for(let R=0;R<O.length;R++){const T=O[R];if(T.textContent==="Add role"&&T.offsetParent!==null){I=T;break}}}if(I){const O=I.getBoundingClientRect(),R=400;let T=O.bottom+8,F=O.right-R;F<10&&(F=O.left),T+300>window.innerHeight&&(T=O.top-300-8),v({top:T,left:F})}},10),C=I=>{i.current&&!i.current.contains(I.target)&&(t==null||t())},y=I=>{I.key==="Escape"&&(t==null||t())},$=setTimeout(()=>{document.addEventListener("mousedown",C),document.addEventListener("keydown",y)},100);return()=>{clearTimeout(f),clearTimeout($),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",y)}},[t,k,n]);const z=f=>f.trim().replace(/[<>\"'&]/g,""),b=f=>f.length>=2&&f.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(f),w=async()=>{const f=z(s);if(!f){E("Please enter a role name","error");return}if(!b(f)){E("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(u.length===0){E("Please select at least one permission","error");return}c(!0);try{const C={id:o==null?void 0:o.id,name:f,permissions:u||[]};r==null||r(C)}catch(C){const y=C.message||`Failed to ${k?"update":"create"} role. Please try again.`;E(y,"error")}finally{c(!1)}};return g?e.jsxs(X0,{ref:i,$isInTable:k,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:f=>f.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(e1,{children:[e.jsx(t1,{id:"role-dialog-title",children:k?"Edit Role":"Create New Role"}),e.jsx(n1,{onClick:t,"aria-label":`Close ${k?"edit":"create"} role dialog`,children:e.jsx(Dt,{size:16})})]}),e.jsx(r1,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(J,{children:"Role Name"}),e.jsx(X,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:s,onChange:f=>d(f.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Permissions"}),e.jsx(Td,{options:j,value:u,onChange:l,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(o1,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:w,disabled:!s||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," ",k?"Updating...":"Creating..."]}):k?"Update Role":"Create Role"})]})]}):null},i1=({organization:t})=>{var z;const{getOrganizationRoles:r,removeOrganizationRoles:o}=kt(),{deployment:n}=je(),[i,s]=a.useState({isOpen:!1}),[d,u]=a.useState(null),[l,h]=a.useState(""),[c,g]=a.useState(null),m=a.useRef(null),{data:x=[],isLoading:v,mutate:S}=We(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(r==null?void 0:r(t))||[]),E=a.useMemo(()=>l?x.filter(b=>b.name.toLowerCase().includes(l.toLowerCase())):x,[x,l]),k=async b=>{try{await new Promise(w=>setTimeout(w,500)),u({text:`Role ${b.id?"updated":"created"} successfully`,type:"success"}),s({isOpen:!1}),S()}catch(w){u({text:w.message||"Failed to save role",type:"error"})}finally{setTimeout(()=>u(null),3e3)}},j=async b=>{try{await o(t,b),S(),g(null)}catch{}};return v&&x.length===0?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[d&&e.jsxs("div",{style:{marginBottom:"20px",padding:"12px 16px",background:d.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:d.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px",fontSize:"14px"},children:[d.type==="success"?"✓":e.jsx(Yt,{size:16}),d.text]}),e.jsxs(Pn,{children:[e.jsx(Ut,{placeholder:"Search roles...",onChange:h,value:l}),((z=n==null?void 0:n.b2b_settings)==null?void 0:z.custom_org_role_enabled)&&e.jsx(B,{$size:"sm",ref:m,onClick:()=>s({isOpen:!0}),children:"Add Role"})]}),i.isOpen&&!i.role&&e.jsx(tc,{onClose:()=>s({isOpen:!1}),onSuccess:k,triggerRef:m}),E.length===0?e.jsx(bt,{title:l?"No roles match":"No roles yet",description:"Define custom roles to manage granular permissions."}):e.jsxs(e.Fragment,{children:[e.jsx(Rn,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Role"}),e.jsx(Pe,{children:"Permissions"}),e.jsx(Pe,{})]})}),e.jsx(Et,{children:E.map(b=>e.jsxs(He,{children:[e.jsx(Fe,{children:e.jsx("div",{style:{fontWeight:500},children:b.name})}),e.jsx(Fe,{style:{color:"var(--color-secondary-text)"},children:b.permissions.join(", ")}),e.jsx(Pt,{children:e.jsx(rc,{role:b,onEdit:()=>s({isOpen:!0,role:b}),onDelete:()=>g(b.id)})})]},b.id))})]})}),e.jsx(In,{children:E.map(b=>e.jsx(ds,{children:e.jsxs(us,{children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"14px",marginBottom:"4px"},children:b.name}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)",lineHeight:1.4},children:b.permissions.join(", ")})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(rc,{role:b,onEdit:()=>s({isOpen:!0,role:b}),onDelete:()=>g(b.id)})})]})},b.id))})]}),c&&e.jsx(Wr,{title:"Delete role?",description:"This action cannot be undone. Users with this role might lose access to certain features.",onConfirm:()=>{const b=x.find(w=>w.id===c);b&&j(b)},onCancel:()=>g(null)}),i.isOpen&&i.role&&e.jsx(tc,{role:i.role,onClose:()=>s({isOpen:!1}),onSuccess:k})]})},rc=({role:t,onEdit:r,onDelete:o})=>e.jsxs(at,{children:[e.jsx(lt,{children:e.jsx(ls,{disabled:!t.organization_id,children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Oe,{onClick:r,children:"Edit Role"}),e.jsxs(Oe,{$destructive:!0,onClick:o,children:[e.jsx(Ct,{size:16})," Remove Role"]})]})]}),s1=()=>{const{activeOrganization:t,loading:r}=Cr(),[o,n]=a.useState(null);return a.useEffect(()=>{t?n(t):!r&&!t&&o&&n(null)},[t,r,o]),{activeOrganization:o||t,loading:r}},Gd=()=>{var c,g;const{loading:t,activeOrganization:r}=s1(),{deployment:o}=je(),[n,i]=a.useState("general"),[s,d]=a.useState(null),[u,l]=a.useState("info"),h=a.useCallback((m,x="info")=>{d(m),l(x),setTimeout(()=>d(null),3e3)},[]);return t&&!r?e.jsx(le,{children:e.jsx(fi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ie,{})})}):r?e.jsx(le,{children:e.jsx(Ua,{children:e.jsx(cs.Provider,{value:{screen:null,setScreen:()=>{},toast:h},children:e.jsxs(fi,{children:[e.jsx(E0,{children:e.jsxs(P0,{children:[e.jsx(Pr,{$isActive:n==="general",onClick:()=>i("general"),children:e.jsxs(Rr,{children:[e.jsx(xr,{size:16})," General"]})}),e.jsx(Pr,{$isActive:n==="domains",onClick:()=>i("domains"),children:e.jsxs(Rr,{children:[e.jsx(Tf,{size:16})," Domains"]})}),e.jsx(Pr,{$isActive:n==="members",onClick:()=>i("members"),children:e.jsxs(Rr,{children:[e.jsx(hn,{size:16})," Members"]})}),e.jsx(Pr,{$isActive:n==="invitations",onClick:()=>i("invitations"),children:e.jsxs(Rr,{children:[e.jsx(Sn,{size:16})," Invitations"]})}),((c=o==null?void 0:o.b2b_settings)==null?void 0:c.custom_org_role_enabled)&&e.jsx(Pr,{$isActive:n==="roles",onClick:()=>i("roles"),children:e.jsxs(Rr,{children:[e.jsx(xt,{size:16})," Roles"]})}),((g=o==null?void 0:o.b2b_settings)==null?void 0:g.enterprise_sso_enabled)&&e.jsx(Pr,{$isActive:n==="sso",onClick:()=>i("sso"),children:e.jsxs(Rr,{children:[e.jsx(xt,{size:16})," SSO"]})})]})}),e.jsxs(R0,{children:[n==="general"&&e.jsx(A0,{organization:r}),n==="domains"&&e.jsx(W0,{organization:r}),n==="members"&&e.jsx(Z0,{organization:r}),n==="invitations"&&e.jsx(J0,{organization:r}),n==="roles"&&e.jsx(i1,{organization:r}),n==="sso"&&e.jsx(_0,{organization:r})]}),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:"slideDown 0.3s ease-out",zIndex:100},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u==="error"?e.jsx(Yt,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})}):e.jsx(le,{children:e.jsx(Ua,{children:e.jsx(fi,{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(is,{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(tu,{})]})})})})},oc=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:i,footerContent:s,customContent:d,children:u,showCloseButton:l})=>e.jsx(Ee,{isOpen:t,onClose:r,children:e.jsx(Ee.Overlay,{children:e.jsxs(Ee.Content,{style:{width:"900px",maxWidth:"90vw"},children:[n&&e.jsx(Ee.Header,{showCloseButton:l,children:i||o}),d||u||e.jsx(Gd,{}),s&&e.jsx(Ee.Footer,{children:s})]})})}),a1=p.div`
|
|
3038
3038
|
display: flex;
|
|
3039
3039
|
height: 100%;
|
|
3040
3040
|
min-height: 400px;
|
|
@@ -3341,7 +3341,7 @@ cursor: pointer;
|
|
|
3341
3341
|
align-items: center;
|
|
3342
3342
|
justify-content: center;
|
|
3343
3343
|
color: var(--color-primary);
|
|
3344
|
-
`,ps=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var F;const[i,s]=a.useState(""),[d,u]=a.useState(""),[l,h]=a.useState(),[c,g]=a.useState(null),[m,x]=a.useState(!1),[v,S]=a.useState(!1),[E,k]=a.useState(t),j=a.useRef(null),z=a.useRef(null),{toast:b}=
|
|
3344
|
+
`,ps=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var F;const[i,s]=a.useState(""),[d,u]=a.useState(""),[l,h]=a.useState(),[c,g]=a.useState(null),[m,x]=a.useState(!1),[v,S]=a.useState(!1),[E,k]=a.useState(t),j=a.useRef(null),z=a.useRef(null),{toast:b}=Ze(),{createWorkspace:w}=Qt(),{refetch:_}=Be(),{organizationMemberships:f}=Ft(),C=(F=f==null?void 0:f.find(D=>D.organization.id===E))==null?void 0:F.organization,y=D=>{if(D.target.files&&D.target.files[0]){const M=D.target.files[0];if(M.size>2*1024*1024){b("File size cannot exceed 2MB","error");return}if(!M.type.startsWith("image/")){b("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),h(M),g(URL.createObjectURL(M))}},$=()=>{var D;(D=j.current)==null||D.click()},I=D=>D.split(" ").map(M=>M[0]).join("").toUpperCase().slice(0,2)||"W",O=D=>D.trim().replace(/[<>\"'&]/g,""),R=D=>D.length>=2&&D.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(D),T=async()=>{const D=O(i),M=O(d);if(!D||!E){b("Please enter a workspace name","error");return}if(!R(D)){b("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(M.length>500){b("Description must be less than 500 characters","error");return}x(!0);try{const L=await w(E,D,l,M);await _(),r==null||r(L)}catch(L){const A=L.message||"Failed to create workspace. Please try again.";b(A,"error")}finally{x(!1)}};return a.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]),a.useEffect(()=>{const D=M=>{z.current&&!z.current.contains(M.target)&&S(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]),e.jsx(le,{children:e.jsxs(a1,{children:[e.jsxs(c1,{children:[e.jsxs(Hd,{hasImage:!!c,onClick:$,children:[c?e.jsx(d1,{src:c,alt:"Workspace logo"}):e.jsx(u1,{children:I(i||"W")}),e.jsx(k1,{children:e.jsx(C1,{children:"Upload Logo"})})]}),e.jsx(_1,{type:"file",ref:j,onChange:y,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(p1,{children:"Create new workspace"}),e.jsx(h1,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(l1,{children:[e.jsxs(f1,{children:[e.jsx(g1,{children:"Choose your workspace name"}),e.jsx(m1,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(x1,{children:[e.jsxs(gi,{children:[e.jsx(mi,{children:"Organization"}),e.jsxs(S1,{ref:z,children:[e.jsxs($1,{type:"button",onClick:()=>S(!v),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nc,{children:C!=null&&C.image_url?e.jsx(ic,{src:C.image_url,alt:C.name}):I((C==null?void 0:C.name)||"O").charAt(0)}),e.jsx("span",{children:(C==null?void 0:C.name)||"Select organization"})]}),e.jsx(qt,{size:16,style:{color:"var(--color-secondary-text)"}})]}),v&&e.jsxs(z1,{children:[f==null?void 0:f.map(D=>{var L,A,P;const M=((L=D.eligibility_restriction)==null?void 0:L.type)&&((A=D.eligibility_restriction)==null?void 0:A.type)!=="none";return e.jsxs(qd,{onClick:()=>{M||(k(D.organization.id),S(!1))},disabled:M,style:{opacity:M?.6:1,cursor:M?"not-allowed":"pointer"},title:M?(P=D.eligibility_restriction)==null?void 0:P.message:void 0,children:[e.jsx(nc,{children:D.organization.image_url?e.jsx(ic,{src:D.organization.image_url,alt:D.organization.name}):I(D.organization.name).charAt(0)}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{children:D.organization.name}),M&&e.jsx("span",{style:{fontSize:"10px",color:"var(--color-error)"},children:"Restricted"})]})]},D.organization.id)}),e.jsxs(E1,{onClick:()=>{S(!1),n==null||n()},children:[e.jsx(P1,{children:e.jsx(gt,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(gi,{children:[e.jsx(mi,{children:"Workspace name"}),e.jsx(v1,{type:"text",value:i,onChange:D=>s(D.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(gi,{children:[e.jsx(mi,{children:"Description (optional)"}),e.jsx(y1,{value:d,onChange:D=>u(D.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(b1,{children:[o?e.jsxs(w1,{onClick:o,disabled:m,children:[e.jsx(ss,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(j1,{onClick:T,disabled:m||!i.trim(),children:m?"Creating...":"Create"})]})]})]})})},Hi=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[i,s]=a.useState(!1),[d,u]=a.useState(n),{refetch:l,organizationMemberships:h}=Ft(),c=()=>{o==null||o(),r==null||r()},g=()=>{s(!0)},m=async()=>{await l(),setTimeout(()=>{if(h&&h.length>0){const x=h[h.length-1];u(x.organization.id)}s(!1)},500)};return e.jsx(le,{children:e.jsx(Ee,{isOpen:t,onClose:r,children:e.jsx(Ee.Overlay,{children:e.jsx(Ee.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(Ee.Body,{style:{padding:0},children:i?e.jsx(En,{onSuccess:m,onCancel:()=>s(!1)}):e.jsx(ps,{organizationId:d||n,onSuccess:c,onCancel:r,onCreateOrganization:g})})})})})})};yt`
|
|
3345
3345
|
0% { transform: rotate(0deg); }
|
|
3346
3346
|
100% { transform: rotate(360deg); }
|
|
3347
3347
|
`;const R1=p.div`
|
|
@@ -3605,11 +3605,11 @@ cursor: pointer;
|
|
|
3605
3605
|
flex-shrink: 0;
|
|
3606
3606
|
display: block;
|
|
3607
3607
|
}
|
|
3608
|
-
`;const D1=()=>{var O,R;const{activeWorkspace:t,loading:r,updateWorkspace:o}=
|
|
3608
|
+
`;const D1=()=>{var O,R;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Nt(),{deleteWorkspace:n}=Qt(),{deployment:i}=je(),{toast:s}=Ze(),[d,u]=a.useState((t==null?void 0:t.name)||""),[l,h]=a.useState((t==null?void 0:t.description)||""),[c,g]=a.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m,x]=a.useState((t==null?void 0:t.image_url)||null),[v,S]=a.useState(null),[E,k]=a.useState(!1),[j,z]=a.useState(""),[b,w]=a.useState(!1),[_,f]=a.useState(!1),C=a.useRef(null);a.useEffect(()=>{var T;t&&(u(t.name||""),h(t.description||""),x(t.image_url||null),g({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((T=t.whitelisted_ips)==null?void 0:T.join(`
|
|
3609
3609
|
`))||""}))},[t]);const y=async()=>{if(!(!t||E))try{k(!0),await o({name:d,description:l,image:v,enforce_2fa:c.mfa_required,enable_ip_restriction:c.ip_restrictions,whitelisted_ips:c.allowed_ips.split(`
|
|
3610
3610
|
`).filter(T=>T.trim())}),s("Changes saved","info")}catch(T){s(T.message||"Failed to save changes","error")}finally{k(!1)}},$=async T=>{var F;if((F=T.target.files)!=null&&F[0]){const D=T.target.files[0];if(D.size>2*1024*1024){s("File size cannot exceed 2MB","error");return}S(D),x(URL.createObjectURL(D));try{k(!0),await o({name:d,description:l,image:D,enforce_2fa:c.mfa_required,enable_ip_restriction:c.ip_restrictions,whitelisted_ips:c.allowed_ips.split(`
|
|
3611
3611
|
`).filter(M=>M.trim())}),s("Logo updated","info")}catch(M){s(M.message||"Failed to update logo","error")}finally{k(!1)}}},I=async()=>{if(!(!t||j!==t.name))try{w(!0),await n(t),s("Workspace deleted","info")}catch{s("Failed to delete workspace","error")}finally{w(!1)}};return r&&!t?e.jsx(Ie,{}):t?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)",paddingBottom:"40px"},children:[e.jsxs(L1,{children:[e.jsx(M1,{children:e.jsxs("div",{style:{width:"90px",height:"90px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:m?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease",boxShadow:"0 2px 8px var(--color-shadow)"},onClick:()=>{var T;return(T=C.current)==null?void 0:T.click()},children:[m?e.jsx("img",{src:m,alt:"Logo",style:{width:"100%",height:"100%",objectFit:"cover"}}):e.jsx(is,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:C,style:{display:"none"},accept:"image/*",onChange:$})]})}),e.jsxs("div",{style:{flex:1,textAlign:"inherit"},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 4px 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Customise your workspace identity"})]}),e.jsxs(O1,{style:{marginBottom:"var(--space-sm)"},children:[e.jsx(B,{$size:"sm",onClick:()=>{var T;return(T=C.current)==null?void 0:T.click()},children:m?"Change":"Upload"}),m&&e.jsxs(B,{$outline:!0,$size:"sm",onClick:async()=>{x(null),S(null);try{k(!0),await o({name:d,description:l,image:"null",enforce_2fa:c.mfa_required,enable_ip_restriction:c.ip_restrictions,whitelisted_ips:c.allowed_ips.split(`
|
|
3612
|
-
`).filter(T=>T.trim())}),s("Logo removed","info")}catch(T){s(T.message||"Failed to remove logo","error")}finally{k(!1)}},children:[e.jsx(
|
|
3612
|
+
`).filter(T=>T.trim())}),s("Logo removed","info")}catch(T){s(T.message||"Failed to remove logo","error")}finally{k(!1)}},children:[e.jsx(Ct,{size:14,style:{marginRight:"4px"}})," Remove"]})]})]})]}),e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),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 4px 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic settings for this workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"name",children:"Workspace Name"}),e.jsx(X,{id:"name",value:d,onChange:T=>u(T.target.value),onBlur:y,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"description",children:"Description"}),e.jsx(X,{id:"description",as:"textarea",value:l,onChange:T=>h(T.target.value),onBlur:y,placeholder:"Enter workspace description",style:{minHeight:"80px",resize:"vertical"}})]}),((O=i==null?void 0:i.b2b_settings)==null?void 0:O.enforce_mfa_per_workspace_enabled)&&e.jsxs(ac,{children:[e.jsxs(cc,{children:[e.jsx(J,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"Multi-Factor Authentication"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Require MFA for all workspace members"})]}),e.jsx(lc,{children:e.jsx(jr,{checked:c.mfa_required,onChange:()=>{g(T=>({...T,mfa_required:!T.mfa_required})),setTimeout(()=>y(),0)}})})]}),((R=i==null?void 0:i.b2b_settings)==null?void 0:R.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs(ac,{children:[e.jsxs(cc,{children:[e.jsx(J,{style:{fontSize:"13px",fontWeight:"400",marginBottom:"4px",display:"block"},children:"IP Restrictions"}),e.jsx("p",{style:{fontSize:"12px",color:"var(--color-muted)",margin:0},children:"Limit workspace access to trusted IP addresses"})]}),e.jsx(lc,{children:e.jsx(jr,{checked:c.ip_restrictions,onChange:()=>{g(T=>({...T,ip_restrictions:!T.ip_restrictions})),setTimeout(()=>y(),0)}})})]}),c.ip_restrictions&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(X,{id:"allowed_ips",as:"textarea",value:c.allowed_ips,onChange:T=>g(F=>({...F,allowed_ips:T.target.value})),onBlur:y,placeholder:"One IP per line...",style:{minHeight:"80px",fontFamily:"monospace"}})]})]})]})]}),e.jsx("div",{style:{height:"1px",background:"var(--color-divider)"}}),e.jsxs("div",{style:{padding:"24px",border:"1px solid var(--color-error)",borderRadius:"16px",background:"transparent",textAlign:"inherit"},children:[e.jsx("h3",{style:{color:"var(--color-error)",fontSize:"15px",fontWeight:"400",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{color:"var(--color-secondary-text)",fontSize:"13px",margin:"0 0 20px 0"},children:"Destructive actions for this workspace"}),_?e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px"},children:[e.jsxs(J,{children:["Type ",e.jsx("strong",{children:t.name})," to confirm"]}),e.jsx(X,{value:j,onChange:T=>z(T.target.value),placeholder:"Workspace name"}),e.jsxs("div",{style:{display:"flex",gap:"12px"},children:[e.jsx(B,{$destructive:!0,$size:"sm",onClick:I,disabled:j!==t.name||b,style:{flex:1},children:b?e.jsx(Ie,{size:12}):"Delete Workspace"}),e.jsx(B,{$outline:!0,$size:"sm",onClick:()=>{f(!1),z("")},style:{flex:1},children:"Cancel"})]})]}):e.jsx(B,{$destructive:!0,$size:"sm",onClick:()=>f(!0),children:"Delete Workspace"})]})]}):e.jsx("div",{style:{padding:"24px",color:"var(--color-muted)"},children:"Workspace not found"})},F1=p.div`
|
|
3613
3613
|
position: fixed;
|
|
3614
3614
|
width: 360px;
|
|
3615
3615
|
max-width: calc(100vw - 48px);
|
|
@@ -3658,7 +3658,7 @@ cursor: pointer;
|
|
|
3658
3658
|
color: var(--color-foreground);
|
|
3659
3659
|
background: var(--color-input-background);
|
|
3660
3660
|
}
|
|
3661
|
-
`,G1=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const i=a.useRef(null),[s,d]=a.useState(""),[u,l]=a.useState(null),[h,c]=a.useState(!1),[g,m]=a.useState(!1),[x,v]=a.useState({top:0,left:0}),{toast:S}=
|
|
3661
|
+
`,G1=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const i=a.useRef(null),[s,d]=a.useState(""),[u,l]=a.useState(null),[h,c]=a.useState(!1),[g,m]=a.useState(!1),[x,v]=a.useState({top:0,left:0}),{toast:S}=Ze(),{inviteMember:E}=Nt(),k=o.map(b=>({value:b.id,label:b.name}));a.useEffect(()=>{m(!0);const b=setTimeout(()=>{if(!i.current||!(n!=null&&n.current))return;const C=n.current;if(C){const y=C.getBoundingClientRect(),$=360,I=250,O=8;let R=0,T=0;const F=window.innerHeight-y.bottom,D=y.top;F>=I+O?(R=y.bottom+O,T=y.right-$,T<O&&(T=y.left,T+$>window.innerWidth-O&&(T=(window.innerWidth-$)/2))):D>=I+O?(R=y.top-I-O,T=y.right-$,T<O&&(T=y.left,T+$>window.innerWidth-O&&(T=(window.innerWidth-$)/2))):(R=y.bottom+O,T=y.right-$,T<O&&(T=y.left)),v({top:R,left:T})}},10),w=C=>{i.current&&!i.current.contains(C.target)&&(t==null||t())},_=C=>{C.key==="Escape"&&(t==null||t())},f=setTimeout(()=>{document.addEventListener("mousedown",w),document.addEventListener("keydown",_)},100);return()=>{clearTimeout(b),clearTimeout(f),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",_)}},[t,n]);const j=b=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b),z=async()=>{const b=s.trim().toLowerCase();if(!(!b||!u)){if(!j(b)){S("Please enter a valid email address","error");return}if(b.length>320){S("Email address is too long","error");return}c(!0);try{await E(b,u.id),r==null||r()}catch(w){const _=w.message||"Failed to send invitation. Please try again.";S(_,"error")}finally{c(!1)}}};return g?e.jsxs(F1,{ref:i,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(N1,{children:[e.jsx(U1,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(V1,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Dt,{size:16})})]}),e.jsx(B1,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(J,{children:"Email Address"}),e.jsx(X,{type:"email",placeholder:"colleague@company.com",value:s,onChange:b=>d(b.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Role"}),e.jsx(zn,{options:k,value:u==null?void 0:u.id,onChange:b=>l(o.find(w=>w.id===b)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(W1,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:z,disabled:!s||!u||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},H1=p.div`
|
|
3662
3662
|
width: 40px;
|
|
3663
3663
|
height: 40px;
|
|
3664
3664
|
border-radius: 50%;
|
|
@@ -3670,7 +3670,7 @@ cursor: pointer;
|
|
|
3670
3670
|
font-weight: 400;
|
|
3671
3671
|
font-size: 14px;
|
|
3672
3672
|
overflow: hidden;
|
|
3673
|
-
`,q1=()=>{const{activeWorkspace:t,getMembers:r,getRoles:o,removeMember:n,addMemberRole:i,removeMemberRole:s}=
|
|
3673
|
+
`,q1=()=>{const{activeWorkspace:t,getMembers:r,getRoles:o,removeMember:n,addMemberRole:i,removeMemberRole:s}=Nt(),{session:d}=Be(),{toast:u}=Ze(),[l,h]=a.useState(""),[c,g]=a.useState(1),[m]=a.useState(10),[x,v]=a.useState(""),[S,E]=a.useState(!1),k=a.useRef(null);a.useEffect(()=>{const R=setTimeout(()=>{v(l),g(1)},500);return()=>clearTimeout(R)},[l]);const{data:j,isLoading:z,mutate:b}=We(t?`wacht - api - workspaces:${t.id}: members:${c}:${m}:${x} `:null,()=>r==null?void 0:r({page:c,limit:m,search:x})),w=(j==null?void 0:j.data)||[],_=(j==null?void 0:j.meta)||{total:0,limit:10},f=Math.ceil(_.total/(_.limit||10)),{data:C=[],isLoading:y}=We(t?`wacht - api - workspaces:${t.id}: roles`:null,()=>o()||[]),$=C,I=async(R,T,F)=>{try{F?(await s(R,T),u("Role removed","info")):(await i(R,T),u("Role added","info")),b()}catch{u("Failed to update role","error")}},O=async R=>{try{await n(R),u("Member removed","info"),b()}catch{u("Failed to remove member","error")}};return z||y?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(hs,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Ut,{value:l,onChange:h,placeholder:"Search members..."})}),e.jsxs("div",{style:{display:"flex",gap:"12px",alignItems:"center"},children:[_.total>0&&e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)"},children:[_.total," member",_.total!==1?"s":""]}),e.jsx(B,{$size:"sm",ref:k,onClick:()=>E(!0),children:"Invite"})]})]}),S&&e.jsx(G1,{onClose:()=>E(!1),onSuccess:()=>{b(),E(!1)},roles:$,triggerRef:k}),w.length===0?e.jsx(bt,{title:l?"No members match":"No members yet",description:"Members added to the organization can be invited here."}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Member"}),e.jsx(Pe,{children:"Joined"}),e.jsx(Pe,{children:"Role"})]})}),e.jsx(Et,{children:w.map(R=>e.jsxs(He,{children:[e.jsx(Fe,{children:e.jsx(dc,{member:R,session:d})}),e.jsx(Fe,{children:new Date(R.created_at).toLocaleDateString()}),e.jsx(Pt,{children:e.jsx(uc,{member:R,roles:$,onToggle:(T,F)=>I(R.id,T,F),onRemove:()=>O(R.id)})})]},R.id))})]})}),e.jsx(gs,{children:w.map(R=>e.jsx(ms,{children:e.jsxs(xs,{children:[e.jsx(dc,{member:R,session:d,subtitle:`Joined ${new Date(R.created_at).toLocaleDateString()}`}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(uc,{member:R,roles:$,onToggle:(T,F)=>I(R.id,T,F),onRemove:()=>O(R.id)})})]})},R.id))})]}),f>1&&e.jsxs("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",gap:"16px",marginTop:"24px"},children:[e.jsx(B,{onClick:()=>g(R=>Math.max(1,R-1)),disabled:c===1,$size:"sm",children:"Previous"}),e.jsxs("span",{style:{fontSize:"13px"},children:[c," / ",f]}),e.jsx(B,{onClick:()=>g(R=>Math.min(f,R+1)),disabled:c===f,$size:"sm",children:"Next"})]})]})},dc=({member:t,session:r,subtitle:o})=>{var d,u,l;const n=t.public_user_data||t.user,i=(n==null?void 0:n.id)===((d=r==null?void 0:r.active_signin)==null?void 0:d.user_id),s=(h="",c="")=>`${h[0]||""}${c[0]||""} `.toUpperCase();return e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx(H1,{children:n!=null&&n.profile_picture_url?e.jsx("img",{src:n.profile_picture_url,alt:"Avatar",style:{width:"100%",height:"100%",objectFit:"cover"}}):s(n==null?void 0:n.first_name,n==null?void 0:n.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:"400"},children:n?`${n.first_name||""} ${n.last_name||""} `.trim()||((u=n.primary_email_address)==null?void 0:u.email):"Unknown"}),i&&e.jsx("span",{style:{fontSize:"10px",padding:"1px 4px",background:"var(--color-background-alt)",color:"var(--color-muted)",borderRadius:"3px",fontWeight:"400"},children:"You"})]}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--color-secondary-text)",fontWeight:"400",display:"flex",flexWrap:"wrap",gap:"4px 8px"},children:[e.jsx("span",{children:(l=n==null?void 0:n.primary_email_address)==null?void 0:l.email}),o&&e.jsxs("span",{style:{color:"var(--color-muted)"},children:["• ",o]})]})]})]})},uc=({member:t,roles:r,onToggle:o,onRemove:n})=>{const i=t.roles||[],s=d=>i.some(u=>u.id===d);return e.jsxs(at,{children:[e.jsx(lt,{children:e.jsxs(B,{$outline:!0,$size:"sm",style:{color:"var(--color-foreground)"},children:[i.length>0?i[0].name:"No role"," ",e.jsx(qt,{size:14,style:{marginLeft:"4px"}})]})}),e.jsxs(ct,{children:[r.map(d=>{const u=s(d.id);return e.jsx(Oe,{onClick:()=>o(d.id,u),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%",gap:"12px"},children:[e.jsx("span",{children:d.name}),u&&e.jsx(rt,{size:14,color:"var(--color-success)"})]})},d.id)}),e.jsx($n,{}),e.jsx(Oe,{$destructive:!0,onClick:n,children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ct,{size:14})," Remove Member"]})})]})]})},Y1=p.div`
|
|
3674
3674
|
position: fixed;
|
|
3675
3675
|
width: 360px;
|
|
3676
3676
|
max-width: calc(100vw - 48px);
|
|
@@ -3719,7 +3719,7 @@ cursor: pointer;
|
|
|
3719
3719
|
color: var(--color-foreground);
|
|
3720
3720
|
background: var(--color-input-background);
|
|
3721
3721
|
}
|
|
3722
|
-
`,ev=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:i})=>{const s=a.useRef(null),[d,u]=a.useState(""),[l,h]=a.useState(o[0]||null),[c,g]=a.useState(!1),[m,x]=a.useState(!1),[v,S]=a.useState({top:0,left:0}),{toast:E}=
|
|
3722
|
+
`,ev=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:i})=>{const s=a.useRef(null),[d,u]=a.useState(""),[l,h]=a.useState(o[0]||null),[c,g]=a.useState(!1),[m,x]=a.useState(!1),[v,S]=a.useState({top:0,left:0}),{toast:E}=Ze(),k=o.map(b=>({value:b.id,label:b.name})),j=b=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(b),z=async()=>{const b=d.trim().toLowerCase();if(!(!b||!l)){if(!j(b)){E("Please enter a valid email address","error");return}if(b.length>320){E("Email address is too long","error");return}g(!0);try{await n({email:b,role_id:l.id}),r()}catch(w){const _=w.message||"Failed to send invitation. Please try again.";E(_,"error")}finally{g(!1)}}};return a.useEffect(()=>{x(!0);const b=setTimeout(()=>{if(!s.current||!(i!=null&&i.current))return;const f=i.current;if(f){const C=f.getBoundingClientRect(),y=360,$=250,I=8;let O=0,R=0;const T=window.innerHeight-C.bottom,F=C.top;T>=$+I?(O=C.bottom+I,R=C.right-y,R<I&&(R=C.left,R+y>window.innerWidth-I&&(R=(window.innerWidth-y)/2))):F>=$+I?(O=C.top-$-I,R=C.right-y,R<I&&(R=C.left,R+y>window.innerWidth-I&&(R=(window.innerWidth-y)/2))):(O=C.bottom+I,R=C.right-y,R<I&&(R=C.left)),S({top:O,left:R})}},10),w=f=>{s.current&&!s.current.contains(f.target)&&(t==null||t())},_=f=>{f.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",_),()=>{clearTimeout(b),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",_)}},[t,i]),m?e.jsxs(Y1,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Q1,{children:[e.jsx(K1,{id:"invite-member-title",children:"Invite Member"}),e.jsx(X1,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Dt,{size:16})})]}),e.jsx(Z1,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(J,{children:"Email Address"}),e.jsx(X,{type:"email",placeholder:"colleague@company.com",value:d,onChange:b=>u(b.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Role"}),e.jsx(zn,{options:k,value:l==null?void 0:l.id,onChange:b=>h(o.find(w=>w.id===b)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(J1,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:z,disabled:!d||!l||c,style:{width:"auto"},children:c?e.jsx(Ie,{size:16}):"Send Invitation"})]})]}):null},tv=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,inviteMember:i,discardInvitation:s,resendInvitation:d}=Nt(),{toast:u}=Ze(),[l,h]=a.useState(!0),[c,g]=a.useState(!0),[m,x]=a.useState(""),[v,S]=a.useState([]),[E,k]=a.useState([]),[j,z]=a.useState(!1),b=a.useRef(null),w=async()=>{if(t){h(!0),g(!0);try{const[y,$]=await Promise.all([o(),n()]);k(y),S($)}catch{}finally{h(!1),g(!1)}}};a.useEffect(()=>{w()},[t==null?void 0:t.id]);const _=async y=>{try{await s(y),w(),u("Invitation cancelled","info")}catch{u("Failed to cancel invitation","error")}},f=async y=>{try{await d(y),w(),u("Invitation resent","info")}catch{u("Failed to resend invitation","error")}},C=a.useMemo(()=>{if(!m)return v;const y=m.toLowerCase();return v.filter($=>{var I;return(I=$.email)==null?void 0:I.toLowerCase().includes(y)})},[v,m]);return r||l||c?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(hs,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Ut,{value:m,onChange:x,placeholder:"Search invitations..."})}),e.jsx(B,{$size:"sm",ref:b,onClick:()=>z(!0),children:"Invite"})]}),j&&e.jsx(ev,{onClose:()=>z(!1),onSuccess:()=>{w(),z(!1),u("Invitation sent","info")},roles:E,createInvitation:y=>i(y.email,y.role_id),triggerRef:b}),C.length===0?e.jsx(bt,{title:m?"No invitations match":"No pending invitations",description:"Invite members to your workspace."}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Email"}),e.jsx(Pe,{children:"Role"}),e.jsx(Pe,{children:"Invited"}),e.jsx(Pe,{})]})}),e.jsx(Et,{children:C.map(y=>{var $,I;return e.jsxs(He,{children:[e.jsx(Fe,{children:y.email}),e.jsx(Fe,{children:(($=y.initial_workspace_role)==null?void 0:$.name)||((I=y.initial_organization_role)==null?void 0:I.name)||"No role"}),e.jsx(Fe,{children:new Date(y.created_at).toLocaleDateString()}),e.jsx(Pt,{children:e.jsx(pc,{onResend:()=>f(y.id),onCancel:()=>_(y.id)})})]},y.id)})})]})}),e.jsx(gs,{children:C.map(y=>{var $;return e.jsx(ms,{children:e.jsxs(xs,{children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"14px",marginBottom:"4px"},children:y.email}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:[(($=y.initial_workspace_role)==null?void 0:$.name)||"No role"," • ",new Date(y.created_at).toLocaleDateString()]})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(pc,{onResend:()=>f(y.id),onCancel:()=>_(y.id)})})]})},y.id)})})]})]})},pc=({onResend:t,onCancel:r})=>e.jsxs(at,{children:[e.jsx(lt,{children:e.jsx(Yd,{children:"•••"})}),e.jsxs(ct,{children:[e.jsxs(Oe,{onClick:t,children:[e.jsx(md,{size:16})," Resend"]}),e.jsxs(Oe,{$destructive:!0,onClick:r,children:[e.jsx(Ct,{size:16})," Cancel"]})]})]}),rv=p.div`
|
|
3723
3723
|
position: fixed;
|
|
3724
3724
|
width: 400px;
|
|
3725
3725
|
max-width: calc(100vw - 48px);
|
|
@@ -3770,7 +3770,7 @@ cursor: pointer;
|
|
|
3770
3770
|
color: var(--color-foreground);
|
|
3771
3771
|
background: var(--color-input-background);
|
|
3772
3772
|
}
|
|
3773
|
-
`,hc=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var f,C;const i=a.useRef(null),[s,d]=a.useState((o==null?void 0:o.name)||""),[u,l]=a.useState((o==null?void 0:o.permissions)||[]),[h,c]=a.useState(!1),[g,m]=a.useState(!1),[x,v]=a.useState({top:0,left:0}),{deployment:S}=je(),{toast:E}=
|
|
3773
|
+
`,hc=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var f,C;const i=a.useRef(null),[s,d]=a.useState((o==null?void 0:o.name)||""),[u,l]=a.useState((o==null?void 0:o.permissions)||[]),[h,c]=a.useState(!1),[g,m]=a.useState(!1),[x,v]=a.useState({top:0,left:0}),{deployment:S}=je(),{toast:E}=Ze(),k=!!o,j=((f=S==null?void 0:S.b2b_settings)==null?void 0:f.workspace_permissions)||((C=S==null?void 0:S.b2b_settings)==null?void 0:C.organization_permissions)||[],z=Array.isArray(j)?j.map(y=>({value:y,label:y})):[];a.useEffect(()=>{m(!0);const y=setTimeout(()=>{if(!i.current)return;let R=null;if(n!=null&&n.current&&(R=n.current),n!=null&&n.current&&(R=n.current),R){const T=R.getBoundingClientRect(),F=400;let D=T.bottom+8,M=T.right-F;M<10&&(M=T.left),D+300>window.innerHeight&&(D=T.top-300-8),v({top:D,left:M})}else v({top:window.innerHeight/2-200,left:window.innerWidth/2-200})},10),$=R=>{i.current&&!i.current.contains(R.target)&&(t==null||t())},I=R=>{R.key==="Escape"&&(t==null||t())},O=setTimeout(()=>{document.addEventListener("mousedown",$),document.addEventListener("keydown",I)},100);return()=>{clearTimeout(y),clearTimeout(O),document.removeEventListener("mousedown",$),document.removeEventListener("keydown",I)}},[t,k,n]);const b=y=>y.trim().replace(/[<>\"'&]/g,""),w=y=>y.length>=2&&y.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(y),_=async()=>{const y=b(s);if(!y){E("Please enter a role name","error");return}if(!w(y)){E("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(u.length===0){E("Please select at least one permission","error");return}c(!0);try{const $={id:o==null?void 0:o.id,name:y,permissions:u||[]};r==null||r($)}catch($){const I=$.message||`Failed to ${k?"update":"create"} role. Please try again.`;E(I,"error")}finally{c(!1)}};return g?e.jsxs(rv,{ref:i,$isInTable:k,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(ov,{children:[e.jsx(nv,{id:"role-dialog-title",children:k?"Edit Role":"Create New Role"}),e.jsx(av,{onClick:t,"aria-label":`Close ${k?"edit":"create"} role dialog`,children:e.jsx(Dt,{size:16})})]}),e.jsx(iv,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(J,{children:"Role Name"}),e.jsx(X,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:s,onChange:y=>d(y.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(ie,{children:[e.jsx(J,{children:"Permissions"}),e.jsx(Td,{options:z,value:u,onChange:l,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(sv,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(B,{onClick:_,disabled:!s||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ie,{size:14})," ",k?"Updating...":"Creating..."]}):k?"Update Role":"Create Role"})]})]}):null},cv=()=>{var f;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:i}=Nt(),{deployment:s}=je(),{toast:d}=Ze(),[u,l]=a.useState(""),[h,c]=a.useState({isOpen:!1}),[g,m]=a.useState(null),[x,v]=a.useState(null),S=a.useRef(null),E=a.useRef(new Map),{data:k=[],isLoading:j,mutate:z}=We(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),b=a.useMemo(()=>u?k.filter(C=>C.name.toLowerCase().includes(u.toLowerCase())):k,[k,u]),w=async C=>{try{await n(C.name,C.permissions||[]),d("Role saved successfully","info"),c({isOpen:!1}),z()}catch{d("Failed to save role","error")}},_=async C=>{try{await i(C),d("Role deleted","info"),m(null),z()}catch{d("Failed to delete role","error")}};return r||j?e.jsx(Ie,{}):e.jsxs(e.Fragment,{children:[e.jsxs(hs,{children:[e.jsx("div",{style:{flex:1},children:e.jsx(Ut,{placeholder:"Search roles...",onChange:l,value:u})}),((f=s==null?void 0:s.b2b_settings)==null?void 0:f.custom_workspace_role_enabled)&&e.jsx(B,{$size:"sm",ref:S,onClick:()=>c({isOpen:!0,triggerElement:S.current}),children:"Add Role"})]}),h.isOpen&&!h.role&&e.jsx(hc,{triggerRef:{current:h.triggerElement||null},onClose:()=>c({isOpen:!1}),onSuccess:w}),b.length===0?e.jsx(bt,{title:u?"No roles match":"No roles yet",description:"Create workspace-specific roles to manage access."}):e.jsxs(e.Fragment,{children:[e.jsx(fs,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Role"}),e.jsx(Pe,{children:"Permissions"}),e.jsx(Pe,{})]})}),e.jsx(Et,{children:b.map(C=>{var y;return e.jsxs(He,{children:[e.jsx(Fe,{children:e.jsx("div",{style:{fontWeight:500},children:C.name})}),e.jsx(Fe,{style:{color:"var(--color-secondary-text)"},children:(y=C.permissions)==null?void 0:y.join(", ")}),e.jsx(Pt,{children:e.jsx(fc,{role:C,onEdit:$=>c({isOpen:!0,role:C,triggerElement:$}),onDelete:()=>m(C.id),open:x===C.id,onOpenChange:$=>v($?C.id:null),dropdownButtonRefs:E})})]},C.id)})})]})}),e.jsx(gs,{children:b.map(C=>{var y;return e.jsx(ms,{children:e.jsxs(xs,{children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:600,fontSize:"14px",marginBottom:"4px"},children:C.name}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:(y=C.permissions)==null?void 0:y.join(", ")})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsx(fc,{role:C,onEdit:$=>c({isOpen:!0,role:C,triggerElement:$}),onDelete:()=>m(C.id),open:x===C.id,onOpenChange:$=>v($?C.id:null),dropdownButtonRefs:E})})]})},C.id)})})]}),g&&e.jsx(Wr,{title:"Delete role?",description:"Are you sure? This will remove the role from all workspace members.",onConfirm:()=>{const C=k.find(y=>y.id===g);C&&_(C)},onCancel:()=>m(null)}),h.isOpen&&h.role&&e.jsx(hc,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>c({isOpen:!1}),onSuccess:w})]})},fc=({role:t,onEdit:r,onDelete:o,open:n,onOpenChange:i,dropdownButtonRefs:s})=>e.jsxs(at,{open:n,openChange:i,children:[e.jsx(lt,{children:e.jsx(Yd,{ref:d=>{d&&s.current.set(t.id,d)},disabled:!t.workspace_id,children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Oe,{onClick:()=>r(s.current.get(t.id)),children:"Edit Role"}),e.jsxs(Oe,{$destructive:!0,onClick:o,children:[e.jsx(Ct,{size:16})," Remove Role"]})]})]}),Qd=()=>{var c;const{activeWorkspace:t,loading:r}=Nt(),{deployment:o}=je(),[n,i]=a.useState("general"),[s,d]=a.useState(null),[u,l]=a.useState("info"),h=a.useCallback((g,m="info")=>{d(g),l(m),setTimeout(()=>d(null),3e3)},[]);return r&&!t?e.jsx(le,{children:e.jsx(sc,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ie,{})})}):t?e.jsx(le,{children:e.jsx(R1,{children:e.jsx(cs.Provider,{value:{screen:null,setScreen:()=>{},toast:h},children:e.jsxs(sc,{children:[e.jsx(I1,{children:e.jsxs(T1,{children:[e.jsx(No,{$isActive:n==="general",onClick:()=>i("general"),children:e.jsxs(Uo,{children:[e.jsx(xr,{size:16})," General"]})}),e.jsx(No,{$isActive:n==="members",onClick:()=>i("members"),children:e.jsxs(Uo,{children:[e.jsx(hn,{size:16})," Members"]})}),e.jsx(No,{$isActive:n==="invitations",onClick:()=>i("invitations"),children:e.jsxs(Uo,{children:[e.jsx(md,{size:16})," Invitations"]})}),((c=o==null?void 0:o.b2b_settings)==null?void 0:c.custom_workspace_role_enabled)&&e.jsx(No,{$isActive:n==="roles",onClick:()=>i("roles"),children:e.jsxs(Uo,{children:[e.jsx(xt,{size:16})," Roles"]})})]})}),e.jsxs(A1,{children:[n==="general"&&e.jsx(D1,{}),n==="members"&&e.jsx(q1,{}),n==="invitations"&&e.jsx(tv,{}),n==="roles"&&e.jsx(cv,{})]}),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:"slideDown 0.3s ease-out",zIndex:100},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u==="error"?e.jsx(Yt,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})})}):null},qi=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:i,footerContent:s,customContent:d,children:u,showCloseButton:l})=>e.jsx(Ee,{isOpen:t,onClose:r,children:e.jsx(Ee.Overlay,{children:e.jsxs(Ee.Content,{style:{width:"900px",maxWidth:"90vw"},children:[n&&e.jsx(Ee.Header,{showCloseButton:l,children:i||o}),d||u||e.jsx(Qd,{}),s&&e.jsx(Ee.Footer,{children:s})]})})}),vs=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:i=8})=>{const[s,d]=a.useState();return a.useEffect(()=>{if(!r||!t.current){d(void 0);return}const u=()=>{if(!t.current)return;const l=t.current.getBoundingClientRect(),h=window.innerWidth,c=window.innerHeight,g=c-l.bottom,m=l.top;let x={};g>=m?(x.top=l.bottom+i,x.maxHeight=Math.min(n,g-i*2)):(x.bottom=c-l.top+i,x.maxHeight=Math.min(n,m-i*2));const v=h-l.left,S=l.right;v>=S?x.left=Math.max(i,Math.min(h-o-i,l.left)):x.left=Math.max(i,Math.min(h-o-i,l.right-o)),d(x)};return u(),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),()=>{window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0)}},[r,o,n,i]),s},Kd=["organization:admin"],Zd=["organization:admin","organization:manage"],Jd=["workspace:admin"],Xd=["workspace:admin","workspace:manage"];function ys(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(i=>r.includes(i))}):!1}function eu(t){return ys(t,Zd)}function lv(t){return ys(t,Kd)}function bs(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(i=>r.includes(i))}):!1}function Yi(t){return bs(t,Xd)}function dv(t){return bs(t,Jd)}const gc=p.div`
|
|
3774
3774
|
position: relative;
|
|
3775
3775
|
display: inline-block;
|
|
3776
3776
|
width: 100%;
|
|
@@ -3883,7 +3883,7 @@ cursor: pointer;
|
|
|
3883
3883
|
`,Ir=p.div`
|
|
3884
3884
|
height: 1px;
|
|
3885
3885
|
background: var(--color-border);
|
|
3886
|
-
`,
|
|
3886
|
+
`,Rt=p.div`
|
|
3887
3887
|
display: flex;
|
|
3888
3888
|
align-items: center;
|
|
3889
3889
|
gap: 8px;
|
|
@@ -3905,13 +3905,13 @@ cursor: pointer;
|
|
|
3905
3905
|
width: 100%;
|
|
3906
3906
|
height: 100%;
|
|
3907
3907
|
object-fit: cover;
|
|
3908
|
-
`,
|
|
3908
|
+
`,It=p.div`
|
|
3909
3909
|
display: flex;
|
|
3910
3910
|
flex-direction: column;
|
|
3911
3911
|
gap: 2px;
|
|
3912
3912
|
overflow: hidden;
|
|
3913
3913
|
flex: 1;
|
|
3914
|
-
`,
|
|
3914
|
+
`,Tt=p.span`
|
|
3915
3915
|
font-weight: 400;
|
|
3916
3916
|
font-size: 13px;
|
|
3917
3917
|
overflow: hidden;
|
|
@@ -4121,7 +4121,7 @@ cursor: pointer;
|
|
|
4121
4121
|
height: 16px;
|
|
4122
4122
|
background: var(--color-border);
|
|
4123
4123
|
border-radius: 2px;
|
|
4124
|
-
`,tu=({showPersonal:t=!0})=>{var te,ae,ye,ge,Q,q,K,ue,xe,Y,he,V,be,Ze,lt;const[r,o]=a.useState(!1),[n,i]=a.useState(!1),[s,d]=a.useState(new Set),u=a.useRef(null),l=a.useRef(null),h=vs({triggerRef:u,isOpen:r,minWidth:300}),c=uo(!1),g=uo(!1),m=uo(!1),x=uo(!1),[v,S]=a.useState(null),[E,k]=a.useState(!1),[j,z]=a.useState(null),{organizationMemberships:b,loading:w,refetch:_}=Mt(),{activeOrganization:f,activeMembership:C,leave:y}=Cr(),{activeWorkspace:$,activeMembership:I,leave:O}=Dt(),{workspaces:R,loading:T}=Yt(),{session:F,switchOrganization:D,switchWorkspace:M}=Be(),{deployment:L}=je(),{toast:A}=Ke(),P=L==null?void 0:L.b2b_settings.organizations_enabled,N=L==null?void 0:L.b2b_settings.workspaces_enabled,W=L==null?void 0:L.b2b_settings.allow_users_to_create_orgs,H=!C,oe=a.useMemo(()=>{var ce,De;if(H)return{name:"Personal account",image_url:(De=(ce=F==null?void 0:F.active_signin)==null?void 0:ce.user)==null?void 0:De.profile_picture_url,isPersonal:!0};let G=(f==null?void 0:f.name)||"";return N&&$&&(G=`${f==null?void 0:f.name} / ${$.name}`),{name:G,image_url:f==null?void 0:f.image_url,isPersonal:!1}},[H,f,$,F,N]);a.useEffect(()=>{if(!r)return;let G=null;const ce=setTimeout(()=>{const De=Xe=>{var Je,de;const rt=Xe.target;(Je=u.current)!=null&&Je.contains(rt)||(de=l.current)!=null&&de.contains(rt)||(o(!1),z(null))};document.addEventListener("mousedown",De),G=()=>{document.removeEventListener("mousedown",De)}},50);return()=>{clearTimeout(ce),G==null||G()}},[r]),a.useEffect(()=>{if(j){const G=setTimeout(()=>{z(null)},5e3);return()=>clearTimeout(G)}},[j]);const Z=()=>{_()};if(!P)return null;const we=G=>{i(!0),D(G).finally(()=>{i(!1)})},pe=G=>{i(!0),M(G).finally(()=>{i(!1)})},ee=G=>{const ce=new Set(s);ce.has(G)?ce.delete(G):ce.add(G),d(ce)},me=G=>G.split(" ").map(ce=>ce[0]).join("").toUpperCase().slice(0,2);return!!!F||w||N&&T?e.jsx(le,{children:e.jsxs(gc,{children:[e.jsxs(bv,{children:[e.jsxs(mc,{children:[e.jsx(wv,{}),e.jsx(jv,{})]}),e.jsx(_v,{})]}),P&&W&&e.jsx(Oa,{isOpen:c.isOpen,onClose:c.close,onCreated:Z}),e.jsx(oc,{isOpen:g.isOpen,onClose:g.close}),e.jsx(qi,{isOpen:x.isOpen,onClose:x.close}),e.jsx(Hi,{isOpen:m.isOpen,onClose:()=>{m.close(),S(null)},organizationId:v||void 0})]})}):e.jsx(le,{children:e.jsxs(gc,{children:[e.jsxs(uv,{ref:u,onClick:()=>{o(!r),r||z(null)},disabled:n,children:[e.jsxs(mc,{children:[e.jsx(pv,{children:oe.image_url?e.jsx(hv,{src:oe.image_url,alt:oe.name}):oe.isPersonal?e.jsx(pn,{size:12}):me(oe.name)}),e.jsx(fv,{children:oe.name})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(((te=C==null?void 0:C.eligibility_restriction)==null?void 0:te.type)&&((ae=C==null?void 0:C.eligibility_restriction)==null?void 0:ae.type)!=="none"||((ye=I==null?void 0:I.eligibility_restriction)==null?void 0:ye.type)&&((ge=I==null?void 0:I.eligibility_restriction)==null?void 0:ge.type)!=="none")&&e.jsx("div",{title:((Q=I==null?void 0:I.eligibility_restriction)==null?void 0:Q.message)||((q=C==null?void 0:C.eligibility_restriction)==null?void 0:q.message),style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),e.jsx(wf,{size:16})]})]}),typeof window<"u"&&xn.createPortal(e.jsx(le,{children:e.jsx(gv,{ref:l,$isOpen:r,$position:h,children:w||T?e.jsxs(yv,{children:[e.jsxs(Ho,{children:[e.jsx(qo,{}),e.jsxs(Yo,{children:[e.jsx(Qo,{width:"120px"}),e.jsx(jc,{width:"80px"})]})]}),e.jsx(Ir,{}),e.jsxs(Ho,{children:[e.jsx(qo,{}),e.jsx(Yo,{children:e.jsx(Qo,{width:"100px"})})]}),e.jsx(Ir,{}),e.jsxs(Ho,{children:[e.jsx(qo,{}),e.jsxs(Yo,{children:[e.jsx(Qo,{width:"140px"}),e.jsx(jc,{width:"60px"})]})]}),e.jsx(Ir,{}),e.jsxs(Ho,{children:[e.jsx(qo,{}),e.jsx(Yo,{children:e.jsx(Qo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(an,{as:"button",$isActive:H,onClick:G=>{G.stopPropagation(),H||we()},disabled:n||H,children:[H&&e.jsx(Vo,{}),e.jsxs(Et,{children:[e.jsx(mv,{children:(ue=(K=F==null?void 0:F.active_signin)==null?void 0:K.user)!=null&&ue.profile_picture_url?e.jsx(xv,{src:F.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(pn,{size:12})}),e.jsx(Pt,{children:e.jsx(Rt,{children:"Personal account"})})]}),!H&&e.jsx(Bo,{className:"hover-arrow",size:14})]}),!H&&f&&e.jsx(Ir,{})]}),!H&&f&&e.jsxs(an,{$isActive:!0,onClick:()=>{N&&ee(f.id)},style:{...n?{pointerEvents:"none",opacity:.7}:{},...((xe=C==null?void 0:C.eligibility_restriction)==null?void 0:xe.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{}},title:(Y=C==null?void 0:C.eligibility_restriction)==null?void 0:Y.message,children:[e.jsx(Vo,{}),e.jsxs(Et,{children:[N&&e.jsx(Ht,{size:12,style:{marginRight:"4px",transform:s.has(f.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(xc,{children:f.image_url?e.jsx(vc,{src:f.image_url,alt:f.name}):me(f.name)}),e.jsx(Pt,{children:e.jsx(Rt,{children:f.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((he=C==null?void 0:C.eligibility_restriction)==null?void 0:he.type)&&((V=C==null?void 0:C.eligibility_restriction)==null?void 0:V.type)!=="none"&&e.jsx("div",{title:(be=C==null?void 0:C.eligibility_restriction)==null?void 0:be.message,style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),((Ze=C==null?void 0:C.eligibility_restriction)==null?void 0:Ze.type)==="none"&&eu(C)&&e.jsx(cn,{onClick:G=>{G.stopPropagation(),g.open()},title:"Manage organization",children:e.jsx(xr,{size:12})}),e.jsx(xi,{onClick:async G=>{G.stopPropagation(),k(!0),z(null);try{await y(),await _(),setTimeout(()=>{k(!1)},500)}catch(ce){z(ce instanceof Error?ce.message:"Failed to leave organization"),k(!1)}},disabled:E,title:"Leave organization",children:e.jsx(Ot,{size:12})})]})]}),f&&N&&s.has(f.id)&&e.jsxs(e.Fragment,{children:[R==null?void 0:R.filter(G=>G.organization.id===f.id).map(G=>{var De,Xe,rt,Je,de,ne,ve,_e,fe,Re,Nt,Jt;const ce=($==null?void 0:$.id)===G.id;return e.jsxs(Go,{as:ce?void 0:"button",$isActive:ce,onClick:ce?void 0:()=>pe(G.id),...ce?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},style:{...((De=G.eligibility_restriction)==null?void 0:De.type)!=="none"||((Xe=C==null?void 0:C.eligibility_restriction)==null?void 0:Xe.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{},...ce&&n?{pointerEvents:"none",opacity:.7}:{}},title:((rt=G.eligibility_restriction)==null?void 0:rt.message)||((Je=C==null?void 0:C.eligibility_restriction)==null?void 0:Je.message),children:[ce&&e.jsx(Vo,{}),e.jsxs(Et,{children:[e.jsx(bc,{children:G.image_url?e.jsx("img",{src:G.image_url,alt:G.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):me(G.name).charAt(0)}),e.jsx(Pt,{children:e.jsx(Rt,{children:G.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(((de=G.eligibility_restriction)==null?void 0:de.type)&&((ne=G.eligibility_restriction)==null?void 0:ne.type)!=="none"||((ve=C==null?void 0:C.eligibility_restriction)==null?void 0:ve.type)&&((_e=C==null?void 0:C.eligibility_restriction)==null?void 0:_e.type)!=="none")&&e.jsx("div",{title:((fe=G.eligibility_restriction)==null?void 0:fe.message)||((Re=C==null?void 0:C.eligibility_restriction)==null?void 0:Re.message),style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),ce?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((Nt=I==null?void 0:I.eligibility_restriction)==null?void 0:Nt.type)==="none"&&((Jt=C==null?void 0:C.eligibility_restriction)==null?void 0:Jt.type)==="none"&&Yi(I)&&e.jsx(cn,{onClick:ot=>{ot.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(xr,{size:12})}),e.jsx(xi,{onClick:async ot=>{ot.stopPropagation();try{O&&await O()}catch(Xt){const er=Xt.message||"Failed to leave workspace. Please try again.";A(er,"error")}},title:"Leave workspace",children:e.jsx(Ot,{size:12})})]}):e.jsx(Bo,{className:"hover-arrow",size:14})]})]},G.id)}),((lt=C==null?void 0:C.eligibility_restriction)==null?void 0:lt.type)==="none"&&e.jsx(Go,{as:"button",onClick:()=>{S(f.id),m.open()},disabled:n,children:e.jsxs(Et,{children:[e.jsx(Wo,{style:{width:"14px",height:"14px"},children:e.jsx(ht,{size:12})}),e.jsx(Pt,{children:e.jsx(Rt,{children:"Create workspace"})})]})})]}),(E||j)&&e.jsxs(e.Fragment,{children:[E&&e.jsxs(wc,{children:[e.jsx(vv,{}),"Leaving organization..."]}),j&&e.jsxs(wc,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),j]})]}),e.jsx(Ir,{}),b&&b.length>0&&e.jsx(e.Fragment,{children:b.filter(G=>G.organization.id!==(f==null?void 0:f.id)).map(G=>{var rt,Je,de,ne,ve,_e;const ce=G.organization,De=(R==null?void 0:R.filter(fe=>fe.organization.id===ce.id))||[],Xe=s.has(ce.id);return e.jsxs(a.Fragment,{children:[e.jsxs(an,{as:"button",$isActive:!1,onClick:()=>{N?ee(ce.id):we(ce.id)},disabled:n,style:((rt=G.eligibility_restriction)==null?void 0:rt.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:void 0,title:(Je=G.eligibility_restriction)==null?void 0:Je.message,children:[e.jsxs(Et,{children:[N&&e.jsx(Ht,{size:12,style:{marginRight:"4px",transform:Xe?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(xc,{children:ce.image_url?e.jsx(vc,{src:ce.image_url,alt:ce.name}):me(ce.name)}),e.jsx(Pt,{children:e.jsx(Rt,{children:ce.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((de=G.eligibility_restriction)==null?void 0:de.type)&&((ne=G.eligibility_restriction)==null?void 0:ne.type)!=="none"&&e.jsx("div",{title:(ve=G.eligibility_restriction)==null?void 0:ve.message,style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),e.jsx(Bo,{className:"hover-arrow",size:14})]})]}),N&&Xe&&e.jsxs(e.Fragment,{children:[De.map(fe=>{var Nt,Jt,ot,Xt,er,qr,Yr,Qr,Kr,Zr;const Re=($==null?void 0:$.id)===fe.id;return e.jsxs(Go,{as:Re?void 0:"button",$isActive:Re,onClick:Re?void 0:()=>pe(fe.id),...Re?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},style:{...((Nt=fe.eligibility_restriction)==null?void 0:Nt.type)!=="none"||((Jt=G.eligibility_restriction)==null?void 0:Jt.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{},...Re&&n?{pointerEvents:"none",opacity:.7}:{}},title:((ot=fe.eligibility_restriction)==null?void 0:ot.message)||((Xt=G.eligibility_restriction)==null?void 0:Xt.message),children:[Re&&e.jsx(Vo,{}),e.jsxs(Et,{children:[e.jsx(bc,{children:fe.image_url?e.jsx("img",{src:fe.image_url,alt:fe.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):me(fe.name).charAt(0)}),e.jsx(Pt,{children:e.jsx(Rt,{children:fe.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(((er=fe.eligibility_restriction)==null?void 0:er.type)&&((qr=fe.eligibility_restriction)==null?void 0:qr.type)!=="none"||((Yr=G.eligibility_restriction)==null?void 0:Yr.type)&&((Qr=G.eligibility_restriction)==null?void 0:Qr.type)!=="none")&&e.jsx("div",{title:((Kr=fe.eligibility_restriction)==null?void 0:Kr.message)||((Zr=G.eligibility_restriction)==null?void 0:Zr.message),style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),Re?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Yi(I)&&e.jsx(cn,{onClick:se=>{se.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(xr,{size:12})}),e.jsx(xi,{onClick:async se=>{se.stopPropagation();try{O&&await O()}catch(Ae){const Le=Ae.message||"Failed to leave workspace. Please try again.";A(Le,"error")}},title:"Leave workspace",children:e.jsx(Ot,{size:12})})]}):e.jsx(Bo,{className:"hover-arrow",size:16})]})]},fe.id)}),((_e=G.eligibility_restriction)==null?void 0:_e.type)==="none"&&e.jsx(Go,{as:"button",onClick:()=>{S(ce.id),m.open()},disabled:n,children:e.jsxs(Et,{children:[e.jsx(Wo,{style:{width:"14px",height:"14px"},children:e.jsx(ht,{size:10})}),e.jsx(Pt,{children:e.jsx(Rt,{children:"Create workspace"})})]})})]}),e.jsx(Ir,{})]},ce.id)})}),N&&e.jsx(yc,{onClick:()=>{var G,ce;f&&(!((G=C==null?void 0:C.eligibility_restriction)!=null&&G.type)||((ce=C==null?void 0:C.eligibility_restriction)==null?void 0:ce.type)==="none")?S(f.id):S(null),m.open()},disabled:n,children:e.jsxs(Et,{children:[e.jsx(Wo,{children:e.jsx(ht,{size:12})}),e.jsx(Pt,{children:e.jsx(Rt,{children:"Create workspace"})})]})}),!N&&W&&e.jsx(yc,{onClick:()=>{c.open()},disabled:n,children:e.jsxs(Et,{children:[e.jsx(Wo,{children:e.jsx(ht,{size:12})}),e.jsx(Pt,{children:e.jsx(Rt,{children:"Create organization"})})]})})]})})}),document.body),P&&W&&e.jsx(Oa,{isOpen:c.isOpen,onClose:c.close,onCreated:Z}),e.jsx(oc,{isOpen:g.isOpen,onClose:g.close}),e.jsx(qi,{isOpen:x.isOpen,onClose:x.close}),e.jsx(Hi,{isOpen:m.isOpen,onClose:()=>{m.close(),S(null)},organizationId:v||void 0})]})})},ru=a.createContext(void 0),Zt=()=>{const t=a.useContext(ru);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},kv=xt`
|
|
4124
|
+
`,tu=({showPersonal:t=!0})=>{var te,ae,ye,ge,Q,q,K,ue,xe,Y,he,V,be,Je,dt;const[r,o]=a.useState(!1),[n,i]=a.useState(!1),[s,d]=a.useState(new Set),u=a.useRef(null),l=a.useRef(null),h=vs({triggerRef:u,isOpen:r,minWidth:300}),c=uo(!1),g=uo(!1),m=uo(!1),x=uo(!1),[v,S]=a.useState(null),[E,k]=a.useState(!1),[j,z]=a.useState(null),{organizationMemberships:b,loading:w,refetch:_}=Ft(),{activeOrganization:f,activeMembership:C,leave:y}=Cr(),{activeWorkspace:$,activeMembership:I,leave:O}=Nt(),{workspaces:R,loading:T}=Qt(),{session:F,switchOrganization:D,switchWorkspace:M}=Be(),{deployment:L}=je(),{toast:A}=Ze(),P=L==null?void 0:L.b2b_settings.organizations_enabled,N=L==null?void 0:L.b2b_settings.workspaces_enabled,W=L==null?void 0:L.b2b_settings.allow_users_to_create_orgs,H=!C,oe=a.useMemo(()=>{var ce,De;if(H)return{name:"Personal account",image_url:(De=(ce=F==null?void 0:F.active_signin)==null?void 0:ce.user)==null?void 0:De.profile_picture_url,isPersonal:!0};let G=(f==null?void 0:f.name)||"";return N&&$&&(G=`${f==null?void 0:f.name} / ${$.name}`),{name:G,image_url:f==null?void 0:f.image_url,isPersonal:!1}},[H,f,$,F,N]);a.useEffect(()=>{if(!r)return;let G=null;const ce=setTimeout(()=>{const De=et=>{var Xe,de;const ot=et.target;(Xe=u.current)!=null&&Xe.contains(ot)||(de=l.current)!=null&&de.contains(ot)||(o(!1),z(null))};document.addEventListener("mousedown",De),G=()=>{document.removeEventListener("mousedown",De)}},50);return()=>{clearTimeout(ce),G==null||G()}},[r]),a.useEffect(()=>{if(j){const G=setTimeout(()=>{z(null)},5e3);return()=>clearTimeout(G)}},[j]);const Z=()=>{_()};if(!P)return null;const we=G=>{i(!0),D(G).finally(()=>{i(!1)})},pe=G=>{i(!0),M(G).finally(()=>{i(!1)})},ee=G=>{const ce=new Set(s);ce.has(G)?ce.delete(G):ce.add(G),d(ce)},me=G=>G.split(" ").map(ce=>ce[0]).join("").toUpperCase().slice(0,2);return!!!F||w||N&&T?e.jsx(le,{children:e.jsxs(gc,{children:[e.jsxs(bv,{children:[e.jsxs(mc,{children:[e.jsx(wv,{}),e.jsx(jv,{})]}),e.jsx(_v,{})]}),P&&W&&e.jsx(Oa,{isOpen:c.isOpen,onClose:c.close,onCreated:Z}),e.jsx(oc,{isOpen:g.isOpen,onClose:g.close}),e.jsx(qi,{isOpen:x.isOpen,onClose:x.close}),e.jsx(Hi,{isOpen:m.isOpen,onClose:()=>{m.close(),S(null)},organizationId:v||void 0})]})}):e.jsx(le,{children:e.jsxs(gc,{children:[e.jsxs(uv,{ref:u,onClick:()=>{o(!r),r||z(null)},disabled:n,children:[e.jsxs(mc,{children:[e.jsx(pv,{children:oe.image_url?e.jsx(hv,{src:oe.image_url,alt:oe.name}):oe.isPersonal?e.jsx(pn,{size:12}):me(oe.name)}),e.jsx(fv,{children:oe.name})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[(((te=C==null?void 0:C.eligibility_restriction)==null?void 0:te.type)&&((ae=C==null?void 0:C.eligibility_restriction)==null?void 0:ae.type)!=="none"||((ye=I==null?void 0:I.eligibility_restriction)==null?void 0:ye.type)&&((ge=I==null?void 0:I.eligibility_restriction)==null?void 0:ge.type)!=="none")&&e.jsx("div",{title:((Q=I==null?void 0:I.eligibility_restriction)==null?void 0:Q.message)||((q=C==null?void 0:C.eligibility_restriction)==null?void 0:q.message),style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),e.jsx(wf,{size:16})]})]}),typeof window<"u"&&xn.createPortal(e.jsx(le,{children:e.jsx(gv,{ref:l,$isOpen:r,$position:h,children:w||T?e.jsxs(yv,{children:[e.jsxs(Ho,{children:[e.jsx(qo,{}),e.jsxs(Yo,{children:[e.jsx(Qo,{width:"120px"}),e.jsx(jc,{width:"80px"})]})]}),e.jsx(Ir,{}),e.jsxs(Ho,{children:[e.jsx(qo,{}),e.jsx(Yo,{children:e.jsx(Qo,{width:"100px"})})]}),e.jsx(Ir,{}),e.jsxs(Ho,{children:[e.jsx(qo,{}),e.jsxs(Yo,{children:[e.jsx(Qo,{width:"140px"}),e.jsx(jc,{width:"60px"})]})]}),e.jsx(Ir,{}),e.jsxs(Ho,{children:[e.jsx(qo,{}),e.jsx(Yo,{children:e.jsx(Qo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(an,{as:"button",$isActive:H,onClick:G=>{G.stopPropagation(),H||we()},disabled:n||H,children:[H&&e.jsx(Vo,{}),e.jsxs(Rt,{children:[e.jsx(mv,{children:(ue=(K=F==null?void 0:F.active_signin)==null?void 0:K.user)!=null&&ue.profile_picture_url?e.jsx(xv,{src:F.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(pn,{size:12})}),e.jsx(It,{children:e.jsx(Tt,{children:"Personal account"})})]}),!H&&e.jsx(Bo,{className:"hover-arrow",size:14})]}),!H&&f&&e.jsx(Ir,{})]}),!H&&f&&e.jsxs(an,{$isActive:!0,onClick:()=>{N&&ee(f.id)},style:{...n?{pointerEvents:"none",opacity:.7}:{},...((xe=C==null?void 0:C.eligibility_restriction)==null?void 0:xe.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{}},title:(Y=C==null?void 0:C.eligibility_restriction)==null?void 0:Y.message,children:[e.jsx(Vo,{}),e.jsxs(Rt,{children:[N&&e.jsx(qt,{size:12,style:{marginRight:"4px",transform:s.has(f.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(xc,{children:f.image_url?e.jsx(vc,{src:f.image_url,alt:f.name}):me(f.name)}),e.jsx(It,{children:e.jsx(Tt,{children:f.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((he=C==null?void 0:C.eligibility_restriction)==null?void 0:he.type)&&((V=C==null?void 0:C.eligibility_restriction)==null?void 0:V.type)!=="none"&&e.jsx("div",{title:(be=C==null?void 0:C.eligibility_restriction)==null?void 0:be.message,style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),((Je=C==null?void 0:C.eligibility_restriction)==null?void 0:Je.type)==="none"&&eu(C)&&e.jsx(cn,{onClick:G=>{G.stopPropagation(),g.open()},title:"Manage organization",children:e.jsx(xr,{size:12})}),e.jsx(xi,{onClick:async G=>{G.stopPropagation(),k(!0),z(null);try{await y(),await _(),setTimeout(()=>{k(!1)},500)}catch(ce){z(ce instanceof Error?ce.message:"Failed to leave organization"),k(!1)}},disabled:E,title:"Leave organization",children:e.jsx(Lt,{size:12})})]})]}),f&&N&&s.has(f.id)&&e.jsxs(e.Fragment,{children:[R==null?void 0:R.filter(G=>G.organization.id===f.id).map(G=>{var De,et,ot,Xe,de,ne,ve,_e,fe,ze,Ke,ut;const ce=($==null?void 0:$.id)===G.id;return e.jsxs(Go,{as:ce?void 0:"button",$isActive:ce,onClick:ce?void 0:()=>pe(G.id),...ce?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},style:{...((De=G.eligibility_restriction)==null?void 0:De.type)!=="none"||((et=C==null?void 0:C.eligibility_restriction)==null?void 0:et.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{},...ce&&n?{pointerEvents:"none",opacity:.7}:{}},title:((ot=G.eligibility_restriction)==null?void 0:ot.message)||((Xe=C==null?void 0:C.eligibility_restriction)==null?void 0:Xe.message),children:[ce&&e.jsx(Vo,{}),e.jsxs(Rt,{children:[e.jsx(bc,{children:G.image_url?e.jsx("img",{src:G.image_url,alt:G.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):me(G.name).charAt(0)}),e.jsx(It,{children:e.jsx(Tt,{children:G.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(((de=G.eligibility_restriction)==null?void 0:de.type)&&((ne=G.eligibility_restriction)==null?void 0:ne.type)!=="none"||((ve=C==null?void 0:C.eligibility_restriction)==null?void 0:ve.type)&&((_e=C==null?void 0:C.eligibility_restriction)==null?void 0:_e.type)!=="none")&&e.jsx("div",{title:((fe=G.eligibility_restriction)==null?void 0:fe.message)||((ze=C==null?void 0:C.eligibility_restriction)==null?void 0:ze.message),style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),ce?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((Ke=I==null?void 0:I.eligibility_restriction)==null?void 0:Ke.type)==="none"&&((ut=C==null?void 0:C.eligibility_restriction)==null?void 0:ut.type)==="none"&&Yi(I)&&e.jsx(cn,{onClick:nt=>{nt.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(xr,{size:12})}),e.jsx(xi,{onClick:async nt=>{nt.stopPropagation();try{O&&await O()}catch(Xt){const er=Xt.message||"Failed to leave workspace. Please try again.";A(er,"error")}},title:"Leave workspace",children:e.jsx(Lt,{size:12})})]}):e.jsx(Bo,{className:"hover-arrow",size:14})]})]},G.id)}),((dt=C==null?void 0:C.eligibility_restriction)==null?void 0:dt.type)==="none"&&e.jsx(Go,{as:"button",onClick:()=>{S(f.id),m.open()},disabled:n,children:e.jsxs(Rt,{children:[e.jsx(Wo,{style:{width:"14px",height:"14px"},children:e.jsx(gt,{size:12})}),e.jsx(It,{children:e.jsx(Tt,{children:"Create workspace"})})]})})]}),(E||j)&&e.jsxs(e.Fragment,{children:[E&&e.jsxs(wc,{children:[e.jsx(vv,{}),"Leaving organization..."]}),j&&e.jsxs(wc,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),j]})]}),e.jsx(Ir,{}),b&&b.length>0&&e.jsx(e.Fragment,{children:b.filter(G=>G.organization.id!==(f==null?void 0:f.id)).map(G=>{var ot,Xe,de,ne,ve,_e;const ce=G.organization,De=(R==null?void 0:R.filter(fe=>fe.organization.id===ce.id))||[],et=s.has(ce.id);return e.jsxs(a.Fragment,{children:[e.jsxs(an,{as:"button",$isActive:!1,onClick:()=>{N?ee(ce.id):we(ce.id)},disabled:n,style:((ot=G.eligibility_restriction)==null?void 0:ot.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:void 0,title:(Xe=G.eligibility_restriction)==null?void 0:Xe.message,children:[e.jsxs(Rt,{children:[N&&e.jsx(qt,{size:12,style:{marginRight:"4px",transform:et?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(xc,{children:ce.image_url?e.jsx(vc,{src:ce.image_url,alt:ce.name}):me(ce.name)}),e.jsx(It,{children:e.jsx(Tt,{children:ce.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[((de=G.eligibility_restriction)==null?void 0:de.type)&&((ne=G.eligibility_restriction)==null?void 0:ne.type)!=="none"&&e.jsx("div",{title:(ve=G.eligibility_restriction)==null?void 0:ve.message,style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),e.jsx(Bo,{className:"hover-arrow",size:14})]})]}),N&&et&&e.jsxs(e.Fragment,{children:[De.map(fe=>{var Ke,ut,nt,Xt,er,qr,Yr,Qr,Kr,Zr;const ze=($==null?void 0:$.id)===fe.id;return e.jsxs(Go,{as:ze?void 0:"button",$isActive:ze,onClick:ze?void 0:()=>pe(fe.id),...ze?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},style:{...((Ke=fe.eligibility_restriction)==null?void 0:Ke.type)!=="none"||((ut=G.eligibility_restriction)==null?void 0:ut.type)!=="none"?{opacity:.6,cursor:"not-allowed"}:{},...ze&&n?{pointerEvents:"none",opacity:.7}:{}},title:((nt=fe.eligibility_restriction)==null?void 0:nt.message)||((Xt=G.eligibility_restriction)==null?void 0:Xt.message),children:[ze&&e.jsx(Vo,{}),e.jsxs(Rt,{children:[e.jsx(bc,{children:fe.image_url?e.jsx("img",{src:fe.image_url,alt:fe.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):me(fe.name).charAt(0)}),e.jsx(It,{children:e.jsx(Tt,{children:fe.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[(((er=fe.eligibility_restriction)==null?void 0:er.type)&&((qr=fe.eligibility_restriction)==null?void 0:qr.type)!=="none"||((Yr=G.eligibility_restriction)==null?void 0:Yr.type)&&((Qr=G.eligibility_restriction)==null?void 0:Qr.type)!=="none")&&e.jsx("div",{title:((Kr=fe.eligibility_restriction)==null?void 0:Kr.message)||((Zr=G.eligibility_restriction)==null?void 0:Zr.message),style:{display:"flex",alignItems:"center"},children:e.jsx(hr,{size:14,color:"var(--color-error)"})}),ze?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Yi(I)&&e.jsx(cn,{onClick:se=>{se.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(xr,{size:12})}),e.jsx(xi,{onClick:async se=>{se.stopPropagation();try{O&&await O()}catch(Ae){const Le=Ae.message||"Failed to leave workspace. Please try again.";A(Le,"error")}},title:"Leave workspace",children:e.jsx(Lt,{size:12})})]}):e.jsx(Bo,{className:"hover-arrow",size:16})]})]},fe.id)}),((_e=G.eligibility_restriction)==null?void 0:_e.type)==="none"&&e.jsx(Go,{as:"button",onClick:()=>{S(ce.id),m.open()},disabled:n,children:e.jsxs(Rt,{children:[e.jsx(Wo,{style:{width:"14px",height:"14px"},children:e.jsx(gt,{size:10})}),e.jsx(It,{children:e.jsx(Tt,{children:"Create workspace"})})]})})]}),e.jsx(Ir,{})]},ce.id)})}),N&&e.jsx(yc,{onClick:()=>{var G,ce;f&&(!((G=C==null?void 0:C.eligibility_restriction)!=null&&G.type)||((ce=C==null?void 0:C.eligibility_restriction)==null?void 0:ce.type)==="none")?S(f.id):S(null),m.open()},disabled:n,children:e.jsxs(Rt,{children:[e.jsx(Wo,{children:e.jsx(gt,{size:12})}),e.jsx(It,{children:e.jsx(Tt,{children:"Create workspace"})})]})}),!N&&W&&e.jsx(yc,{onClick:()=>{c.open()},disabled:n,children:e.jsxs(Rt,{children:[e.jsx(Wo,{children:e.jsx(gt,{size:12})}),e.jsx(It,{children:e.jsx(Tt,{children:"Create organization"})})]})})]})})}),document.body),P&&W&&e.jsx(Oa,{isOpen:c.isOpen,onClose:c.close,onCreated:Z}),e.jsx(oc,{isOpen:g.isOpen,onClose:g.close}),e.jsx(qi,{isOpen:x.isOpen,onClose:x.close}),e.jsx(Hi,{isOpen:m.isOpen,onClose:()=>{m.close(),S(null)},organizationId:v||void 0})]})})},ru=a.createContext(void 0),Jt=()=>{const t=a.useContext(ru);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},kv=yt`
|
|
4125
4125
|
0% { transform: rotate(0deg); }
|
|
4126
4126
|
100% { transform: rotate(360deg); }
|
|
4127
4127
|
`,Cv=p.div`
|
|
@@ -4393,7 +4393,7 @@ cursor: pointer;
|
|
|
4393
4393
|
@media (max-width: 768px) {
|
|
4394
4394
|
justify-content: center;
|
|
4395
4395
|
}
|
|
4396
|
-
`,Mv=t=>{const[r,o]=a.useState(!1);return a.useEffect(()=>{const n=window.matchMedia(t);n.matches!==r&&o(n.matches);const i=()=>o(n.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[t]),r},Dv=()=>{var L,A;const{deployment:t}=je(),{refetch:r}=Be(),{user:o,updateProfile:n,updateProfilePicture:i,deleteAccount:s}=
|
|
4396
|
+
`,Mv=t=>{const[r,o]=a.useState(!1);return a.useEffect(()=>{const n=window.matchMedia(t);n.matches!==r&&o(n.matches);const i=()=>o(n.matches);return n.addEventListener("change",i),()=>n.removeEventListener("change",i)},[t]),r},Dv=()=>{var L,A;const{deployment:t}=je(),{refetch:r}=Be(),{user:o,updateProfile:n,updateProfilePicture:i,deleteAccount:s}=Kt(),{toast:d}=Jt(),[u,l]=a.useState(""),[h,c]=a.useState(""),[g,m]=a.useState(""),[x,v]=a.useState(!1),[S,E]=a.useState(!1),[k,j]=a.useState(!1),[z,b]=a.useState(""),[w,_]=a.useState((o==null?void 0:o.profile_picture_url)||null),f=a.useRef(null);a.useEffect(()=>{o&&!x&&(l(o.first_name||""),c(o.last_name||""),m(o.username||""),_(o.profile_picture_url||null),v(!0))},[o,x]);const C=a.useCallback(async()=>{if(o)try{const P={};u!==o.first_name&&(P.first_name=u),h!==o.last_name&&(P.last_name=h),g!==o.username&&(P.username=g),Object.keys(P).length>0&&await n(P)}catch(P){d(P.message||"Failed to save profile changes","error")}},[o,n,u,h,g,d]),y=P=>{l(P.target.value)},$=P=>{c(P.target.value)},I=P=>{m(P.target.value)},O=()=>{C()},R=()=>{C()},T=()=>{C()},F=P=>{var N;if((N=P.target.files)!=null&&N[0]){const W=P.target.files[0];_(URL.createObjectURL(W)),setTimeout(async()=>{try{await i(W),o.refetch(),d("Profile picture updated successfully","info")}catch(H){d(H.message||"Failed to update profile picture","error"),_((o==null?void 0:o.profile_picture_url)||null)}},100)}},D=()=>{f.current&&f.current.click()};if(!o)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ie,{})});const M=async()=>{if(!(!o||z!=="delete this account")){j(!0);try{await s(""),d("Account deleted successfully","info"),await r()}catch(P){d(P.message||"Failed to delete account","error")}finally{j(!1),b(""),E(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs(Ev,{children:[e.jsx(Pv,{children:e.jsxs("div",{style:{width:"90px",height:"90px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:w?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease",margin:"0 auto"},onClick:D,onMouseEnter:P=>{P.currentTarget.style.borderColor="var(--color-primary)",P.currentTarget.style.transform="scale(1.02)"},onMouseLeave:P=>{P.currentTarget.style.borderColor="var(--color-border)",P.currentTarget.style.transform="scale(1)"},children:[w?e.jsx("img",{src:w,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(pn,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:f,style:{display:"none"},accept:"image/*",onChange:F})]})}),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(Lv,{style:{marginBottom:"var(--space-sm)"},children:[e.jsx(B,{$size:"sm",onClick:()=>{var P;return(P=f.current)==null?void 0:P.click()},children:w?"Change":"Upload"}),e.jsxs(B,{$size:"sm",$outline:!0,onClick:async()=>{_(null),f.current&&(f.current.value="");try{await n({remove_profile_picture:!0}),await o.refetch(),d("Profile picture removed successfully","info")}catch(P){d(P.message||"Failed to remove profile picture","error"),_((o==null?void 0:o.profile_picture_url)||null)}},children:[e.jsx(Ct,{size:14,style:{marginRight:"4px"}}),"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(Ov,{children:[e.jsxs(ie,{style:{flex:1},children:[e.jsx(J,{htmlFor:"firstName",children:"First Name"}),e.jsx(X,{id:"firstName",type:"text",value:u,onChange:y,onBlur:O,placeholder:"Enter your first name",required:!0})]}),e.jsxs(ie,{style:{flex:1},children:[e.jsx(J,{htmlFor:"lastName",children:"Last Name"}),e.jsx(X,{id:"lastName",type:"text",value:h,onChange:$,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((A=(L=t==null?void 0:t.auth_settings)==null?void 0:L.username)==null?void 0:A.enabled)&&e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"username",children:"Username"}),e.jsx(X,{id:"username",type:"text",value:g,onChange:I,onBlur:T,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:S?"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(B,{onClick:()=>{S?(E(!1),b("")):E(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:S?"Cancel":"Delete"})]}),S&&e.jsxs("div",{style:{width:"100%",marginTop:"16px"},children:[e.jsxs(ie,{children:[e.jsx(J,{htmlFor:"confirm_username",children:'Type "delete this account" to confirm'}),e.jsx(X,{id:"confirm_username",type:"text",value:z,onChange:P=>b(P.target.value),placeholder:"delete this account",style:{width:"100%"}})]}),e.jsx(B,{onClick:M,disabled:z!=="delete this account"||k,style:{background:z==="delete this account"?"var(--color-error)":"transparent",color:z==="delete this account"?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:z==="delete this account"?"pointer":"not-allowed",opacity:z==="delete this account"?1:.6,marginTop:"12px",width:"100%"},children:k?e.jsx(Ie,{size:12}):"Delete Forever"})]})]})]})]})})},Fv=p.div`
|
|
4397
4397
|
position: fixed;
|
|
4398
4398
|
background: var(--color-background);
|
|
4399
4399
|
border-radius: var(--radius-md);
|
|
@@ -4432,7 +4432,7 @@ cursor: pointer;
|
|
|
4432
4432
|
justify-content: center;
|
|
4433
4433
|
color: var(--color-muted);
|
|
4434
4434
|
flex-shrink: 0;
|
|
4435
|
-
`,$c=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:i,triggerRef:s})=>{const d=a.useRef(null),[u,l]=a.useState(!1),[h,c]=a.useState({top:0,left:0}),{toast:g}=
|
|
4435
|
+
`,$c=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:i,triggerRef:s})=>{const d=a.useRef(null),[u,l]=a.useState(!1),[h,c]=a.useState({top:0,left:0}),{toast:g}=Jt();a.useEffect(()=>{l(!0);const _=setTimeout(()=>{if(!d.current||!(s!=null&&s.current))return;const y=s.current;if(y){const $=y.getBoundingClientRect(),I=380,O=300,R=8;let T=0,F=0;const D=window.innerHeight-$.bottom,M=$.top;D>=O+R?(T=$.bottom+R,F=$.right-I,F<R&&(F=$.left,F+I>window.innerWidth-R&&(F=(window.innerWidth-I)/2))):M>=O+R?(T=$.top-O-R,F=$.right-I,F<R&&(F=$.left,F+I>window.innerWidth-R&&(F=(window.innerWidth-I)/2))):(T=$.bottom+R,F=$.right-I,F<R&&(F=$.left)),c({top:T,left:F})}},10),f=y=>{d.current&&!d.current.contains(y.target)&&t()},C=y=>{y.key==="Escape"&&t()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",C),()=>{clearTimeout(_),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",C)}},[t,s]);const[m,x]=a.useState(i?"otp":"email"),[v,S]=a.useState(i||""),[E,k]=a.useState(""),[j,z]=a.useState(!1),b=async()=>{if(!(!v||j)){z(!0);try{await r(v),x("otp")}catch(_){const f=_.message||"Failed to add email address. Please try again.";g(f,"error")}finally{z(!1)}}},w=async()=>{z(!0);try{await o(E),t()}catch(_){const f=_.message||"Failed to verify email. Please check the code and try again.";g(f,"error")}finally{z(!1)}};return u?e.jsx(Fv,{ref:d,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx(Sc,{children:"Add email address"}),e.jsx(ie,{children:e.jsxs(Nv,{children:[e.jsx(Uv,{children:e.jsx(Sn,{size:16})}),e.jsx(X,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:_=>S(_.target.value),style:{flex:1}})]})}),e.jsxs(Cc,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(B,{onClick:b,disabled:!v||j,style:{width:"auto",padding:"0 var(--space-md)"},children:j?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Sc,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",v]}),e.jsx(Zt,{onComplete:async _=>k(_),onResend:n,isSubmitting:j}),e.jsxs(Cc,{children:[e.jsx(B,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(B,{onClick:w,disabled:E.length<6||j,style:{width:"auto",padding:"0 var(--space-md)"},children:j?"Verifying...":"Verify"})]})]})}):null},Bv=()=>{var _,f,C,y;const{deployment:t}=je(),{toast:r}=Jt(),[o,n]=a.useState(null),[i,s]=a.useState(""),[d,u]=a.useState(!1),[l,h]=a.useState(null),[c,g]=a.useState(""),m=a.useRef(null),x=a.useRef({}),{user:v,createEmailAddress:S,deleteEmailAddress:E,prepareEmailVerification:k,attemptEmailVerification:j,makeEmailPrimary:z}=Kt();if(!((f=(_=t==null?void 0:t.auth_settings)==null?void 0:_.email_address)!=null&&f.enabled))return null;const b=async $=>{try{if($===(v==null?void 0:v.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await E($),v.refetch(),r("Email address deleted successfully","info")}catch(I){r(I.message||"Failed to delete email address. Please try again.","error")}},w=a.useMemo(()=>v!=null&&v.user_email_addresses?c.trim()?v.user_email_addresses.filter($=>$.email.toLowerCase().includes(c.toLowerCase())):v.user_email_addresses:[],[v==null?void 0:v.user_email_addresses,c]);return e.jsxs(e.Fragment,{children:[e.jsxs(ou,{children:[e.jsx("div",{style:{flex:1,minWidth:"200px"},children:e.jsx(Ut,{value:c,onChange:g,placeholder:"Search Email"})}),e.jsxs("div",{style:{position:"relative",flexShrink:0},children:[e.jsx(B,{ref:m,onClick:()=>u(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px",width:"100%"},children:"Add Email"}),d&&e.jsx($c,{triggerRef:m,onClose:()=>u(!1),onAddEmail:async $=>{const I=await S($);s(I.data.id),await k(I.data.id),v.refetch()},onPrepareVerification:async()=>{await k(i),v.refetch()},onAttemptVerification:async $=>{await j(i,$),v.refetch(),u(!1),s(""),r("Email added and verified successfully!","info")}})]})]}),w!=null&&w.length?e.jsxs(e.Fragment,{children:[e.jsx(ws,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Email Address"}),e.jsx(Pe,{children:"Status"}),e.jsx(Pe,{})]})}),e.jsx(Et,{children:w.map($=>e.jsxs(He,{children:[e.jsx(Fe,{children:$.email}),e.jsx(Fe,{children:$.id===(v==null?void 0:v.primary_email_address_id)?"Primary":$.verified?"Verified":"Not Verified"}),e.jsx(Pt,{children:$.id!==(v==null?void 0:v.primary_email_address_id)||!$.verified?e.jsxs(at,{open:o===$.id,openChange:I=>n(I?$.id:null),children:[e.jsx(lt,{children:e.jsx(_r,{ref:I=>{I&&(x.current[$.id]=I)},children:e.jsx(mo,{size:16})})}),e.jsxs(ct,{children:[$.id!==(v==null?void 0:v.primary_email_address_id)&&$.verified&&e.jsx(Oe,{onClick:async()=>{try{await z($.id),v.refetch(),n(null),r("Primary email updated successfully","info")}catch(I){r(I.message||"Failed to update primary email","error")}},children:"Make primary"}),!$.verified&&e.jsx(Oe,{onClick:async()=>{n(null),await k($.id),h($.id)},children:"Verify email"}),$.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Oe,{$destructive:!0,onClick:()=>{b($.id),n(null)},children:"Remove"})]})]}):null})]},$.id))})]})}),e.jsx(js,{children:w.map(($,I)=>e.jsxs("div",{children:[e.jsx(Tn,{children:e.jsxs(On,{children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:$.email}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",background:"var(--color-input-background)",padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--color-border)"},children:$.id===(v==null?void 0:v.primary_email_address_id)?"Primary":$.verified?"Verified":"Not Verified"}),e.jsx("div",{style:{marginLeft:"auto"},children:($.id!==(v==null?void 0:v.primary_email_address_id)||!$.verified)&&e.jsxs(at,{open:o===$.id,openChange:O=>n(O?$.id:null),children:[e.jsx(lt,{children:e.jsx(_r,{ref:O=>{O&&(x.current[$.id]=O)},children:e.jsx(mo,{size:16})})}),e.jsxs(ct,{children:[$.id!==(v==null?void 0:v.primary_email_address_id)&&$.verified&&e.jsx(Oe,{onClick:async()=>{try{await z($.id),v.refetch(),n(null),r("Primary email updated successfully","info")}catch(O){r(O.message||"Failed to update primary email","error")}},children:"Make primary"}),!$.verified&&e.jsx(Oe,{onClick:async()=>{n(null),await k($.id),h($.id)},children:"Verify email"}),$.id!==(v==null?void 0:v.primary_email_address_id)&&e.jsx(Oe,{$destructive:!0,onClick:()=>{b($.id),n(null)},children:"Remove"})]})]})})]})}),I<w.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},$.id))})]}):e.jsx(bt,{title:c?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),l&&e.jsx($c,{existingEmail:(y=(C=v==null?void 0:v.user_email_addresses)==null?void 0:C.find($=>$.id===l))==null?void 0:y.email,triggerRef:{current:x.current[l]},onClose:()=>h(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await k(l),v.refetch()},onAttemptVerification:async $=>{await j(l,$),v.refetch(),h(null),r("Email verified successfully!","info")}})]})},Wv=p.div`
|
|
4436
4436
|
position: fixed;
|
|
4437
4437
|
background: var(--color-background);
|
|
4438
4438
|
border-radius: var(--radius-md);
|
|
@@ -4456,7 +4456,7 @@ cursor: pointer;
|
|
|
4456
4456
|
font-weight: 400;
|
|
4457
4457
|
color: var(--color-foreground);
|
|
4458
4458
|
margin-bottom: 12px;
|
|
4459
|
-
`,Pc=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:i,triggerRef:s})=>{var C;const d=a.useRef(null),[u,l]=a.useState(!1),[h,c]=a.useState({top:0,left:0}),{toast:g}=
|
|
4459
|
+
`,Pc=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:i,triggerRef:s})=>{var C;const d=a.useRef(null),[u,l]=a.useState(!1),[h,c]=a.useState({top:0,left:0}),{toast:g}=Jt();a.useEffect(()=>{l(!0);const y=setTimeout(()=>{if(!d.current||!(s!=null&&s.current))return;const O=s.current;if(O){const R=O.getBoundingClientRect(),T=380,F=300,D=8;let M=0,L=0;const A=window.innerHeight-R.bottom,P=R.top;A>=F+D?(M=R.bottom+D,L=R.right-T,L<D&&(L=R.left,L+T>window.innerWidth-D&&(L=(window.innerWidth-T)/2))):P>=F+D?(M=R.top-F-D,L=R.right-T,L<D&&(L=R.left,L+T>window.innerWidth-D&&(L=(window.innerWidth-T)/2))):(M=R.bottom+D,L=R.right-T,L<D&&(L=R.left)),c({top:M,left:L})}},10),$=O=>{d.current&&!d.current.contains(O.target)&&t()},I=O=>{O.key==="Escape"&&t()};return document.addEventListener("mousedown",$),document.addEventListener("keydown",I),()=>{clearTimeout(y),document.removeEventListener("mousedown",$),document.removeEventListener("keydown",I)}},[t,s]);const[m,x]=a.useState(n?"otp":"phone"),[v,S]=a.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[E,k]=a.useState((C=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:C.pop()),[j,z]=a.useState(""),[b,w]=a.useState(!1),_=async()=>{if(!(!v||b)){w(!0);try{await r(v,E||""),x("otp")}catch(y){const $=y.message||"Failed to add phone number. Please try again.";g($,"error")}finally{w(!1)}}},f=async()=>{w(!0);try{await o(j),t()}catch(y){const $=y.message||"Failed to verify phone. Please check the code and try again.";g($,"error")}finally{w(!1)}};return u?e.jsx(Wv,{ref:d,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(Ec,{children:"Add phone number"}),e.jsx(ie,{children:e.jsx(vo,{value:v,onChange:y=>S(y.target.value),error:"",countryCode:E,setCountryCode:k})}),e.jsxs(zc,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(B,{onClick:_,disabled:!v||b,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ec,{children:"Verify phone number"}),e.jsx(ie,{children:e.jsx(Zt,{onComplete:y=>z(y),onResend:async()=>i()})}),e.jsxs(zc,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(B,{onClick:f,disabled:j.length!==6||b,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},Vv=()=>{var w,_,f,C;const{deployment:t}=je(),[r,o]=a.useState(null),[n,i]=a.useState(""),[s,d]=a.useState(!1),[u,l]=a.useState(null),[h,c]=a.useState(""),g=a.useRef(null),m=a.useRef({}),{user:x,createPhoneNumber:v,deletePhoneNumber:S,preparePhoneVerification:E,attemptPhoneVerification:k,makePhonePrimary:j}=Kt();if(!((_=(w=t==null?void 0:t.auth_settings)==null?void 0:w.phone_number)!=null&&_.enabled))return null;const z=y=>{const $=sn.find(I=>I.dialCode===y);return($==null?void 0:$.flag)||"🌍"},b=a.useMemo(()=>x!=null&&x.user_phone_numbers?h.trim()?x.user_phone_numbers.filter(y=>y.phone_number.toLowerCase().includes(h.toLowerCase())):x.user_phone_numbers:[],[x==null?void 0:x.user_phone_numbers,h]);return e.jsxs(e.Fragment,{children:[e.jsxs(ou,{children:[e.jsx("div",{style:{flex:1,minWidth:"200px"},children:e.jsx(Ut,{value:h,onChange:c,placeholder:"Search Phone"})}),e.jsxs("div",{style:{position:"relative",flexShrink:0},children:[e.jsx(B,{ref:g,onClick:()=>d(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px",width:"100%"},children:"Add Phone"}),s&&e.jsx(Pc,{triggerRef:g,onClose:()=>d(!1),onAddPhone:async(y,$)=>{const I=await v(y,$);i(I.data.id),await E(I.data.id)},onPrepareVerification:async()=>{await E(n),x.refetch()},onAttemptVerification:async y=>{await k(n,y),x.refetch(),d(!1)}}),u&&e.jsx(Pc,{existingPhone:(C=(f=x==null?void 0:x.user_phone_numbers)==null?void 0:f.find(y=>y.id===u))==null?void 0:C.phone_number,triggerRef:{current:m.current[u]},onClose:()=>l(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await E(u),x.refetch()},onAttemptVerification:async y=>{await k(u,y),x.refetch(),l(null)}})]})]}),b!=null&&b.length?e.jsxs(e.Fragment,{children:[e.jsx(ws,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Phone Number"}),e.jsx(Pe,{children:"Status"}),e.jsx(Pe,{})]})}),e.jsx(Et,{children:b.map(y=>e.jsxs(He,{children:[e.jsx(Fe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:z(y.country_code)}),e.jsx("span",{children:y.country_code}),e.jsx("span",{children:y.phone_number})]})}),e.jsx(Fe,{children:y.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":y.verified?"Verified":"Not Verified"}),e.jsx(Pt,{children:e.jsxs(at,{open:r===y.id,openChange:$=>o($?y.id:null),children:[e.jsx(lt,{children:e.jsx(_r,{ref:$=>{$&&(m.current[y.id]=$)},children:e.jsx(mo,{size:16})})}),e.jsxs(ct,{children:[y.id!==(x==null?void 0:x.primary_phone_number_id)&&y.verified&&e.jsx(Oe,{onClick:async()=>{await j(y.id),x.refetch(),o(null)},children:"Make primary"}),!y.verified&&e.jsx(Oe,{onClick:async()=>{o(null),await E(y.id),l(y.id)},children:"Verify phone"}),e.jsx(Oe,{$destructive:!0,onClick:()=>{S(y.id),o(null)},children:"Remove"})]})]})})]},y.id))})]})}),e.jsx(js,{children:b.map((y,$)=>e.jsxs("div",{children:[e.jsx(Tn,{children:e.jsxs(On,{children:[e.jsx("span",{style:{fontSize:"18px"},children:z(y.country_code)}),e.jsxs("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:[y.country_code," ",y.phone_number]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",background:"var(--color-input-background)",padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--color-border)"},children:y.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":y.verified?"Verified":"Not Verified"}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsxs(at,{open:r===y.id,openChange:I=>o(I?y.id:null),children:[e.jsx(lt,{children:e.jsx(_r,{ref:I=>{I&&(m.current[y.id]=I)},children:e.jsx(mo,{size:16})})}),e.jsxs(ct,{children:[y.id!==(x==null?void 0:x.primary_phone_number_id)&&y.verified&&e.jsx(Oe,{onClick:async()=>{await j(y.id),x.refetch(),o(null)},children:"Make primary"}),!y.verified&&e.jsx(Oe,{onClick:async()=>{o(null),await E(y.id),l(y.id)},children:"Verify phone"}),e.jsx(Oe,{$destructive:!0,onClick:()=>{S(y.id),o(null)},children:"Remove"})]})]})})]})}),$<b.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},y.id))})]}):e.jsx(bt,{title:h?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},Gv=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"})]}),Hv=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=Kt(),{deployment:n}=je(),i={google_oauth:{icon:e.jsx(vd,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Gv,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(xd,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(wd,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(bd,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(jd,{}),label:"Discord"},x_oauth:{icon:e.jsx(yd,{}),label:"X"}},s=(n==null?void 0:n.social_connections.filter(d=>d.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((d,u)=>{var c;const l=((c=t==null?void 0:t.social_connections)==null?void 0:c.filter(g=>g.provider===d.provider))||[],h=i[d.provider];return h?e.jsxs("div",{children:[e.jsxs(Tn,{children:[e.jsxs(On,{children:[e.jsx(Qi,{children:h.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:h.label}),l.map(g=>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:g.email_address}),e.jsx(_r,{onClick:async()=>{await r(g.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(Dt,{size:14})})]},g.id))]}),e.jsx(Av,{children:l.length>0?e.jsx(B,{onClick:()=>{o({provider:d.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(B,{onClick:()=>{o({provider:d.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})})]}),u<s.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},d.provider):null})})]})};var qv=Object.defineProperty,mn=Object.getOwnPropertySymbols,nu=Object.prototype.hasOwnProperty,iu=Object.prototype.propertyIsEnumerable,Rc=(t,r,o)=>r in t?qv(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,Ki=(t,r)=>{for(var o in r||(r={}))nu.call(r,o)&&Rc(t,o,r[o]);if(mn)for(var o of mn(r))iu.call(r,o)&&Rc(t,o,r[o]);return t},Zi=(t,r)=>{var o={};for(var n in t)nu.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&mn)for(var n of mn(t))r.indexOf(n)<0&&iu.call(t,n)&&(o[n]=t[n]);return o};/**
|
|
4460
4460
|
* @license QR Code generator library (TypeScript)
|
|
4461
4461
|
* Copyright (c) Project Nayuki.
|
|
4462
4462
|
* SPDX-License-Identifier: MIT
|
|
@@ -4572,7 +4572,7 @@ cursor: pointer;
|
|
|
4572
4572
|
color: var(--color-warning-text, var(--color-foreground));
|
|
4573
4573
|
margin: 0;
|
|
4574
4574
|
line-height: 1.5;
|
|
4575
|
-
`,d2=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(!1),[d,u]=a.useState({top:0,left:0}),[l,h]=a.useState(""),[c,g]=a.useState(!1),{toast:m}=
|
|
4575
|
+
`,d2=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(!1),[d,u]=a.useState({top:0,left:0}),[l,h]=a.useState(""),[c,g]=a.useState(!1),{toast:m}=Jt();a.useEffect(()=>{s(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const k=o.current;if(k){const j=k.getBoundingClientRect(),z=400,b=300,w=8;let _=0,f=0;const C=window.innerHeight-j.bottom,y=j.top;C>=b+w?(_=j.bottom+w,f=j.right-z,f<w&&(f=j.left,f+z>window.innerWidth-w&&(f=(window.innerWidth-z)/2))):y>=b+w?(_=j.top-b-w,f=j.right-z,f<w&&(f=j.left,f+z>window.innerWidth-w&&(f=(window.innerWidth-z)/2))):(_=j.bottom+w,f=j.right-z,f<w&&(f=j.left)),u({top:_,left:f})}},10),S=k=>{n.current&&!n.current.contains(k.target)&&t()},E=k=>{k.key==="Escape"&&t()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",E),()=>{clearTimeout(v),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",E)}},[t,o]);const x=async()=>{if(!(!l||c)){g(!0);try{await r(l),t()}catch(v){const S=v.message||"Failed to remove password. Please try again.";m(S,"error")}finally{g(!1)}}};return i?e.jsxs(i2,{ref:n,style:{top:`${d.top}px`,left:`${d.left}px`,visibility:d.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(a2,{children:[e.jsx(Yt,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(c2,{children:e.jsx(l2,{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(ie,{children:[e.jsx(J,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(X,{id:"current-password",type:"password",placeholder:"Enter current password",value:l,onChange:v=>h(v.target.value),autoFocus:!0})]}),e.jsxs(s2,{children:[e.jsx(B,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(B,{onClick:x,disabled:!l||c,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:c?"Removing...":"Remove Password"})]})]}):null},u2=p.div`
|
|
4576
4576
|
position: fixed;
|
|
4577
4577
|
background: var(--color-background);
|
|
4578
4578
|
border-radius: var(--radius-md);
|
|
@@ -4615,7 +4615,7 @@ cursor: pointer;
|
|
|
4615
4615
|
font-weight: 400;
|
|
4616
4616
|
color: var(--color-foreground);
|
|
4617
4617
|
margin-bottom: 8px;
|
|
4618
|
-
`,p2=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const i=a.useRef(null),[s,d]=a.useState("qr"),[u,l]=a.useState(""),[h,c]=a.useState(""),[g,m]=a.useState(["",""]),[x,v]=a.useState(!1),[S,E]=a.useState(!1),[k,j]=a.useState({top:0,left:0}),{toast:z}=
|
|
4618
|
+
`,p2=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const i=a.useRef(null),[s,d]=a.useState("qr"),[u,l]=a.useState(""),[h,c]=a.useState(""),[g,m]=a.useState(["",""]),[x,v]=a.useState(!1),[S,E]=a.useState(!1),[k,j]=a.useState({top:0,left:0}),{toast:z}=Jt();a.useEffect(()=>{E(!0);const w=setTimeout(()=>{if(!i.current||!(n!=null&&n.current))return;const C=n.current;if(C){const y=C.getBoundingClientRect(),$=380,I=400,O=8;let R=0,T=0;const F=window.innerHeight-y.bottom,D=y.top;F>=I+O?(R=y.bottom+O,T=y.right-$,T<O&&(T=y.left,T+$>window.innerWidth-O&&(T=(window.innerWidth-$)/2))):D>=I+O?(R=y.top-I-O,T=y.right-$,T<O&&(T=y.left,T+$>window.innerWidth-O&&(T=(window.innerWidth-$)/2))):(R=y.bottom+O,T=y.right-$,T<O&&(T=y.left)),j({top:R,left:T})}},10),_=C=>{i.current&&!i.current.contains(C.target)&&t()},f=C=>{C.key==="Escape"&&t()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",f),()=>{clearTimeout(w),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",f)}},[t,n]),a.useEffect(()=>{(async()=>{v(!0);try{const _=await r();l(_.otp_url||""),c(_.totp_secret||"")}catch(_){const f=_.message||"Failed to setup two-factor authentication. Please try again.";z(f,"error")}finally{v(!1)}})()},[]);const b=async()=>{if(!g.some(w=>w.length!==6)){v(!0);try{await o(g),t()}catch(w){const _=w.message||"Failed to verify codes. Please check your authenticator app and try again.";z(_,"error")}finally{v(!1)}}};return S?e.jsx(u2,{ref:i,style:{top:`${k.top}px`,left:`${k.left}px`,visibility:k.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:s==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(Ac,{children:"Setup Two-Factor Authentication"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:x?e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)"},children:"Loading..."}):u?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(_s,{value:u,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(Oc,{children:e.jsx(bi,{$primary:!0,onClick:()=>d("verify"),disabled:x||!u,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ac,{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(X,{id:"totp-code-1",type:"text",placeholder:"000000",value:g[0],onChange:w=>{const _=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([_,g[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(X,{id:"totp-code-2",type:"text",placeholder:"000000",value:g[1],onChange:w=>{const _=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([g[0],_])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(Oc,{children:[e.jsx(bi,{onClick:()=>d("qr"),children:"Back"}),e.jsx(bi,{$primary:!0,onClick:b,disabled:x||g.some(w=>w.length!==6),children:x?"Verifying...":"Verify"})]})]})}):null},h2=p.div`
|
|
4619
4619
|
position: fixed;
|
|
4620
4620
|
background: var(--color-background);
|
|
4621
4621
|
border-radius: var(--radius-md);
|
|
@@ -4733,9 +4733,9 @@ cursor: pointer;
|
|
|
4733
4733
|
color: var(--color-error);
|
|
4734
4734
|
font-size: 12px;
|
|
4735
4735
|
margin-top: 4px;
|
|
4736
|
-
`,C2=({onClose:t,onAddPasskey:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(!1),[d,u]=a.useState({top:0,left:0}),[l,h]=a.useState(""),[c,g]=a.useState(!1),[m,x]=a.useState("");a.useEffect(()=>{s(!0);const S=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const j=o.current;if(j){const z=j.getBoundingClientRect(),b=320,w=180,_=8;let f=0,C=0;const y=window.innerHeight-z.bottom,$=z.top;y>=w+_?(f=z.bottom+_,C=z.right-b,C<_&&(C=z.left,C+b>window.innerWidth-_&&(C=(window.innerWidth-b)/2))):$>=w+_?(f=z.top-w-_,C=z.right-b,C<_&&(C=z.left,C+b>window.innerWidth-_&&(C=(window.innerWidth-b)/2))):(f=z.bottom+_,C=z.right-b,C<_&&(C=z.left)),u({top:f,left:C})}},10),E=j=>{n.current&&!n.current.contains(j.target)&&t()},k=j=>{j.key==="Escape"&&t()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",k),()=>{clearTimeout(S),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",k)}},[t,o]);const v=async()=>{if(!c){g(!0),x("");try{await r(l.trim()),t()}catch(S){x(S.message||"Failed to register passkey"),g(!1)}}};return i?e.jsxs(b2,{ref:n,style:{top:`${d.top}px`,left:`${d.left}px`,visibility:d.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),children:[e.jsx(j2,{children:"Add Passkey"}),e.jsx(_2,{children:e.jsx(X,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:l,onChange:S=>h(S.target.value),autoFocus:!0})}),m&&e.jsx(k2,{children:m}),e.jsxs(w2,{children:[e.jsx(Mc,{onClick:t,children:"Cancel"}),e.jsx(Mc,{$primary:!0,onClick:v,disabled:c,children:c?"Registering...":"Continue"})]})]}):null},S2=()=>{var Xt,er,qr,Yr,Qr,Kr,Zr;const{deployment:t}=je(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:i,verifyAuthenticator:s,deleteAuthenticator:d,generateBackupCodes:u,regenerateBackupCodes:l,updateProfile:h,getPasskeys:c,registerPasskey:g,deletePasskey:m}=
|
|
4736
|
+
`,C2=({onClose:t,onAddPasskey:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(!1),[d,u]=a.useState({top:0,left:0}),[l,h]=a.useState(""),[c,g]=a.useState(!1),[m,x]=a.useState("");a.useEffect(()=>{s(!0);const S=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const j=o.current;if(j){const z=j.getBoundingClientRect(),b=320,w=180,_=8;let f=0,C=0;const y=window.innerHeight-z.bottom,$=z.top;y>=w+_?(f=z.bottom+_,C=z.right-b,C<_&&(C=z.left,C+b>window.innerWidth-_&&(C=(window.innerWidth-b)/2))):$>=w+_?(f=z.top-w-_,C=z.right-b,C<_&&(C=z.left,C+b>window.innerWidth-_&&(C=(window.innerWidth-b)/2))):(f=z.bottom+_,C=z.right-b,C<_&&(C=z.left)),u({top:f,left:C})}},10),E=j=>{n.current&&!n.current.contains(j.target)&&t()},k=j=>{j.key==="Escape"&&t()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",k),()=>{clearTimeout(S),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",k)}},[t,o]);const v=async()=>{if(!c){g(!0),x("");try{await r(l.trim()),t()}catch(S){x(S.message||"Failed to register passkey"),g(!1)}}};return i?e.jsxs(b2,{ref:n,style:{top:`${d.top}px`,left:`${d.left}px`,visibility:d.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),children:[e.jsx(j2,{children:"Add Passkey"}),e.jsx(_2,{children:e.jsx(X,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:l,onChange:S=>h(S.target.value),autoFocus:!0})}),m&&e.jsx(k2,{children:m}),e.jsxs(w2,{children:[e.jsx(Mc,{onClick:t,children:"Cancel"}),e.jsx(Mc,{$primary:!0,onClick:v,disabled:c,children:c?"Registering...":"Continue"})]})]}):null},S2=()=>{var Xt,er,qr,Yr,Qr,Kr,Zr;const{deployment:t}=je(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:i,verifyAuthenticator:s,deleteAuthenticator:d,generateBackupCodes:u,regenerateBackupCodes:l,updateProfile:h,getPasskeys:c,registerPasskey:g,deletePasskey:m}=Kt(),{toast:x}=Jt(),[v,S]=a.useState((r==null?void 0:r.second_factor_policy)||"none"),[E,k]=a.useState(!1),j=async se=>{try{await h({second_factor_policy:se}),S(se),x("2FA requirement updated successfully","info")}catch(Ae){x(Ae.message||"Failed to update 2FA requirement","error")}},[z,b]=a.useState(!1),[w,_]=a.useState(!1),[f,C]=a.useState(!1),[y,$]=a.useState(!1),I=a.useRef(null),O=a.useRef(null),R=a.useRef(null),T=a.useRef(null),[F,D]=a.useState([]),[M,L]=a.useState(!1),[A,P]=a.useState(!1),[N,W]=a.useState(!1),[H,oe]=a.useState(!1),[Z,we]=a.useState(null),pe=a.useRef(null),[ee,me]=a.useState("table"),[re,Re]=a.useState(""),[te,ae]=a.useState(""),[ye,ge]=a.useState(""),[Q,q]=a.useState(["",""]),[K,ue]=a.useState([]),[xe,Y]=a.useState(!1),[he,V]=a.useState(!1),[be]=a.useState(!1),[Je,dt]=a.useState(!1),G=(Xt=t==null?void 0:t.auth_settings)==null?void 0:Xt.auth_factors_enabled,ce=(qr=(er=t==null?void 0:t.auth_settings)==null?void 0:er.password)==null?void 0:qr.enabled;if(!(G!=null&&G.authenticator)&&!(G!=null&&G.backup_code)&&!ce)return null;const De=async(se,Ae)=>{await o(se,Ae),await r.refetch(),x("Password updated successfully","info")},et=async se=>{await n(se),await r.refetch(),x("Password removed successfully","info")},ot=()=>{var Cs,Ss,$s,zs,Es,Ps;if(!r)return!1;const se=(Cs=r.user_email_addresses)==null?void 0:Cs.some(Jr=>Jr.verified),Ae=(Ss=r.user_phone_numbers)==null?void 0:Ss.some(Jr=>Jr.verified),Le=r.social_connections&&r.social_connections.length>0,tt=t==null?void 0:t.auth_settings;return(tt==null?void 0:tt.first_factor)==="email_otp"&&se||(($s=tt==null?void 0:tt.magic_link)==null?void 0:$s.enabled)&&se||((zs=tt==null?void 0:tt.passkey)==null?void 0:zs.enabled)||((Es=tt==null?void 0:tt.auth_factors_enabled)==null?void 0:Es.phone_otp)&&Ae||Le&&((Ps=t==null?void 0:t.social_connections)==null?void 0:Ps.some(Jr=>Jr.enabled))},Xe=async()=>{if(Q.some(se=>se.length!==6)){x("Please enter both 6-digit verification codes","error");return}try{if(V(!0),await s(ye,Q),await r.refetch(),G!=null&&G.backup_code){const se=await u();ue(se),await r.refetch(),me("backup")}else me("success")}catch(se){x(se.message||"Invalid verification codes","error")}finally{V(!1)}},de=()=>{me("table"),Re(""),ae(""),ge(""),q(["",""]),ue([]),x("Two-factor authentication setup completed successfully!","info")},ne=async()=>{var se;if((se=r==null?void 0:r.user_authenticator)!=null&&se.id)try{dt(!0),await d(r.user_authenticator.id),await r.refetch(),k(!1),x("Two-factor authentication removed successfully","info")}catch(Ae){x(Ae.message||"Failed to remove authenticator","error")}finally{dt(!1)}},ve=async()=>{if(!xe)try{Y(!0);const se=await l();ue(se),await r.refetch(),$(!0),x("New backup codes generated","info")}catch(se){x(se.message||"Failed to generate backup codes","error")}finally{Y(!1)}},_e=()=>{const se=K.join(`
|
|
4737
4737
|
`);navigator.clipboard.writeText(se).then(()=>{x("Backup codes copied to clipboard","info")}).catch(()=>{x("Failed to copy backup codes","error")})},fe=()=>{const se=K.join(`
|
|
4738
|
-
`),Ae=new Blob([se],{type:"text/plain"}),Le=URL.createObjectURL(Ae),et=document.createElement("a");et.href=Le,et.download="wacht-backup-codes.txt",et.click(),URL.revokeObjectURL(Le),x("Backup codes downloaded","info")},Re=async()=>{var se,Ae;if((Ae=(se=t==null?void 0:t.auth_settings)==null?void 0:se.passkey)!=null&&Ae.enabled)try{L(!0);const Le=await c();D(Le.data||[])}catch(Le){console.error("Failed to load passkeys:",Le)}finally{L(!1)}},Nt=async se=>{try{P(!0),await g(se||void 0),await Re(),x("Passkey registered successfully!","info")}catch(Ae){throw x(Ae.message||"Failed to register passkey","error"),Ae}finally{P(!1)}},Jt=async se=>{try{await m(se),await Re(),x("Passkey removed","info")}catch(Ae){x(Ae.message||"Failed to remove passkey","error")}};a.useEffect(()=>{Re()},[(Qr=(Yr=t==null?void 0:t.auth_settings)==null?void 0:Yr.passkey)==null?void 0:Qr.enabled]);const ot=[];return ce&&ot.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"]}),(Zr=(Kr=t==null?void 0:t.auth_settings)==null?void 0:Kr.passkey)!=null&&Zr.enabled&&ot.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:F.length>0?`${F.length} registered`:"",actions:F.length>0?["manage","add"]:["add"]}),G!=null&&G.authenticator&&ot.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&&ot.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&&ot.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:v==="enforced"?"Enforced":"Optional",actions:["toggle"]}),ee!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(kc,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gt,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[ee==="qr"&&"Setup Two-Factor Authentication",ee==="verify"&&"Verify Your Authenticator",ee==="backup"&&"Save Your Backup Codes",ee==="success"&&"Setup Complete!"]})]}),e.jsx(B,{onClick:()=>me("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:[ee==="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:be?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:`${kv} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):re?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(_s,{value:re,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:te||"Loading..."})]}),e.jsx(B,{onClick:()=>me("verify"),disabled:!re||!te,style:{padding:"10px 20px",background:!re||!te?"var(--color-border)":"var(--color-primary)",color:!re||!te?"var(--color-secondary-text)":"white",border:`1px solid ${!re||!te?"var(--color-border)":"var(--color-primary)"}`,cursor:!re||!te?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),ee==="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(X,{type:"text",placeholder:"000000",value:Q[0],onChange:se=>{const Ae=se.target.value.replace(/[^0-9]/g,"").substring(0,6);q([Ae,Q[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(X,{type:"text",placeholder:"000000",value:Q[1],onChange:se=>{const Ae=se.target.value.replace(/[^0-9]/g,"").substring(0,6);q([Q[0],Ae])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(B,{onClick:()=>me("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(B,{onClick:Je,disabled:he||Q.some(se=>se.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:he?"Verifying...":"Verify & Continue"})]})]}),ee==="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(qt,{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:K.map((se,Ae)=>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(se),children:se},Ae))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(B,{onClick:_e,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(B,{onClick:fe,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(fd,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(B,{onClick:de,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),ee==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(tt,{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(B,{onClick:de,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(kc,{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"})})}),ot.length?e.jsx("div",{children:ot.map((se,Ae)=>e.jsxs("div",{children:[e.jsxs(Rv,{children:[e.jsxs(Iv,{children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:se.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:se.description})]}),e.jsx(Tv,{children:e.jsxs("div",{style:{position:"relative"},children:[se.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(B,{ref:O,onClick:()=>_(!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"}),w&&e.jsx(Tc,{triggerRef:O,onClose:()=>_(!1),onChangePassword:De})]}),rt()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:R,onClick:()=>C(!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"}),f&&e.jsx(d2,{triggerRef:R,onClose:()=>C(!1),onRemovePassword:Xe})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:O,onClick:()=>_(!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"}),w&&e.jsx(Tc,{triggerRef:O,onClose:()=>_(!1),onChangePassword:De,isSetup:!0})]})}),se.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:I,onClick:()=>b(!0),disabled:be,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:be?"Setting up...":"Setup"}),z&&e.jsx(p2,{triggerRef:I,onClose:()=>b(!1),onSetupTOTP:async()=>{const Le=await i();return ge(Le.id),Le},onVerifyTOTP:async Le=>{await s(ye,Le),await r.refetch(),x("Two-factor authentication enabled successfully!","info")}})]})}),se.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{onClick:()=>k(!0),disabled:Ze,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:Ze?"not-allowed":"pointer",opacity:Ze?.6:1},children:Ze?"Removing...":"Remove"}),E&&e.jsx(Wr,{title:"Remove MFA and reset policy to default?",onConfirm:ne,onCancel:()=>k(!1)})]}),se.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:T,onClick:ve,disabled:xe,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:xe?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),y&&e.jsx(y2,{triggerRef:T,codes:K,onClose:()=>$(!1),onCopy:_e,onDownload:fe})]})}),se.id==="second_factor_policy"&&e.jsx(jr,{checked:v==="enforced",onChange:Le=>{j(Le?"enforced":"none")}}),se.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(B,{onClick:()=>W(!N),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",color:"var(--color-foreground)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"110px",height:"36px"},children:[N?"Hide":"Manage"," (",F.length,")",e.jsx(Ht,{size:14,style:{transform:N?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:pe,onClick:()=>oe(!0),disabled:A,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:A?"not-allowed":"pointer",opacity:A?.7:1,whiteSpace:"nowrap",minWidth:"80px",width:"auto",height:"36px"},children:A?"Adding...":"Add"}),H&&e.jsx(C2,{triggerRef:pe,onClose:()=>oe(!1),onAddPasskey:Nt})]})]})]})})]}),se.id==="passkey"&&N&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:M?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx(Ie,{})}):F.length===0?e.jsx("div",{style:{textAlign:"center",padding:"16px",color:"var(--color-secondary-text)",fontSize:"13px"},children:"No passkeys registered yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:F.map(Le=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:"var(--color-foreground)"},children:Le.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[Le.device_type==="platform"?"This device":"Security key",Le.last_used_at&&` • Last used ${new Date(Le.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{onClick:()=>we(Le.id),style:{padding:"4px 10px",fontSize:"12px",background:"transparent",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",color:"var(--color-error)",cursor:"pointer",flexShrink:0,width:"auto"},children:"Remove"}),Z===Le.id&&e.jsx(Wr,{title:`Remove "${Le.name||"Unnamed Passkey"}"?`,onConfirm:()=>{Jt(Le.id),we(null)},onCancel:()=>we(null)})]})]},Le.id))})}),Ae<ot.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},se.id))}):e.jsx(vt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},$2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 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)"}})]}),z2=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"})]}),E2=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})]}),P2=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)"})]}),R2=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)"})]}),I2=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)"})]}),T2=()=>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:"?"})]}),Dc=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx($2,{...o}):r.includes("firefox")?e.jsx(z2,{...o}):r.includes("safari")?e.jsx(E2,{...o}):r.includes("edge")?e.jsx(P2,{...o}):r.includes("opera")?e.jsx(R2,{...o}):r.includes("brave")?e.jsx(I2,{...o}):e.jsx(T2,{})},O2=()=>{const[t,r]=a.useState(null),{signins:o,removeSignin:n,refetch:i,loading:s}=Rl(),{refetch:d}=Be(),{toast:u}=Zt(),l=Mv("(max-width: 600px)"),h=o,c=async m=>{try{await n(m),await Promise.all([i(),d()]),r(null),u("Session ended successfully","info")}catch(x){u(x.message||"Failed to end session. Please try again.","error")}},g=m=>{if(!m||m.trim()==="")return"Unknown";const x=new Date(m);if(isNaN(x.getTime()))return"Unknown";const S=Math.floor((new Date().getTime()-x.getTime())/(1e3*60));return S<1?"Just now":S<60?`${S}m ago`:S<1440?`${Math.floor(S/60)}h ago`:x.toLocaleDateString()};return s?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Ie,{})}):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:h&&h.length>0?e.jsxs(e.Fragment,{children:[!l&&e.jsx(ws,{children:e.jsxs(Ct,{children:[e.jsx(St,{children:e.jsxs(He,{children:[e.jsx(Ee,{children:"Browser & Device"}),e.jsx(Ee,{children:"Location"}),e.jsx(Ee,{children:"Last Active"}),e.jsx(Ee,{})]})}),e.jsx($t,{children:h.map(m=>e.jsxs(He,{children:[e.jsx(Fe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Qi,{children:e.jsx(Dc,{browser:m.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:m.browser||"Unknown Browser"}),m.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:m.device})]})]})}),e.jsx(Fe,{children:e.jsxs("div",{children:[e.jsx("div",{children:m.city&&m.country?`${m.city}, ${m.country}`:"Unknown location"}),m.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:m.ip_address})]})}),e.jsx(Fe,{children:g(m.last_active_at)}),e.jsx(zt,{children:e.jsxs(st,{open:t===m.id,openChange:x=>r(x?m.id:null),children:[e.jsx(ct,{children:e.jsx(_r,{children:"•••"})}),e.jsx(at,{children:e.jsx(Oe,{onClick:()=>c(m.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ot,{size:14}),"End Session"]})})})]})})]},m.id))})]})}),l&&e.jsx(js,{children:h.map((m,x)=>e.jsxs("div",{children:[e.jsx(Tn,{children:e.jsxs(On,{children:[e.jsx(Qi,{children:e.jsx(Dc,{browser:m.browser||"Unknown"})}),e.jsxs("div",{style:{marginLeft:"12px",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:[m.browser||"Unknown"," ",m.device?`on ${m.device}`:""]}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:[m.city&&m.country?`${m.city}, ${m.country}`:"Unknown location"," • ",g(m.last_active_at)]})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsxs(st,{open:t===m.id,openChange:v=>r(v?m.id:null),children:[e.jsx(ct,{children:e.jsx(_r,{children:"•••"})}),e.jsx(at,{children:e.jsx(Oe,{onClick:()=>c(m.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ot,{size:14}),"End Session"]})})})]})})]})}),x<h.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},m.id))})]}):e.jsx(vt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},gu=()=>{var v,S,E,k,j,z,b;const{loading:t}=Qt(),{deployment:r}=je(),[o,n]=a.useState("profile"),[i,s]=a.useState(null),[d,u]=a.useState("info"),l=a.useCallback((w,_="info")=>{s(w),u(_),setTimeout(()=>s(null),3e3)},[s]);if(t)return e.jsx(le,{children:e.jsx(_c,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ie,{})})});const h=r==null?void 0:r.auth_settings,c=(v=h==null?void 0:h.email_address)==null?void 0:v.enabled,g=(S=h==null?void 0:h.phone_number)==null?void 0:S.enabled,m=((E=r==null?void 0:r.social_connections)==null?void 0:E.some(w=>w.enabled))||!1,x=((k=h==null?void 0:h.password)==null?void 0:k.enabled)||((j=h==null?void 0:h.auth_factors_enabled)==null?void 0:j.authenticator)||((z=h==null?void 0:h.auth_factors_enabled)==null?void 0:z.phone_otp)||((b=h==null?void 0:h.auth_factors_enabled)==null?void 0:b.backup_code);return e.jsx(le,{children:e.jsx(Cv,{children:e.jsx(ru.Provider,{value:{screen:null,setScreen:()=>{},toast:l},children:e.jsxs(_c,{children:[e.jsx(Sv,{children:e.jsxs($v,{children:[e.jsx(Tr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(Or,{children:[e.jsx(pn,{size:16}),"Profile"]})}),c&&e.jsx(Tr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(Or,{children:[e.jsx(Sn,{size:16}),"Email"]})}),g&&e.jsx(Tr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(Or,{children:[e.jsx(Bf,{size:16}),"Phone"]})}),m&&e.jsx(Tr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(Or,{children:[e.jsx(Mf,{size:16}),"Connections"]})}),x&&e.jsx(Tr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(Or,{children:[e.jsx(gt,{size:16}),"Security"]})}),e.jsx(Tr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(Or,{children:[e.jsx(nf,{size:16}),"Sessions"]})})]})}),e.jsxs(zv,{children:[o==="profile"&&e.jsx(Dv,{}),o==="email"&&c&&e.jsx(Bv,{}),o==="phone"&&g&&e.jsx(Vv,{}),o==="social"&&m&&e.jsx(Hv,{}),o==="security"&&x&&e.jsx(S2,{}),o==="sessions"&&e.jsx(O2,{})]}),i&&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:[d==="error"?e.jsx(qt,{size:16,color:"var(--color-error)"}):e.jsx(tt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:i})]})})]})})})})},mu=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:i,footerContent:s,customContent:d,children:u,showCloseButton:l})=>e.jsx(ze,{isOpen:t,onClose:r,children:e.jsx(ze.Overlay,{children:e.jsxs(ze.Content,{style:{width:"900px",maxWidth:"90vw"},children:[n&&e.jsx(ze.Header,{showCloseButton:l,children:i||o}),d||u||e.jsx(gu,{}),s&&e.jsx(ze.Footer,{children:s})]})})}),A2=p.div`
|
|
4738
|
+
`),Ae=new Blob([se],{type:"text/plain"}),Le=URL.createObjectURL(Ae),tt=document.createElement("a");tt.href=Le,tt.download="wacht-backup-codes.txt",tt.click(),URL.revokeObjectURL(Le),x("Backup codes downloaded","info")},ze=async()=>{var se,Ae;if((Ae=(se=t==null?void 0:t.auth_settings)==null?void 0:se.passkey)!=null&&Ae.enabled)try{L(!0);const Le=await c();D(Le.data||[])}catch(Le){console.error("Failed to load passkeys:",Le)}finally{L(!1)}},Ke=async se=>{try{P(!0),await g(se||void 0),await ze(),x("Passkey registered successfully!","info")}catch(Ae){throw x(Ae.message||"Failed to register passkey","error"),Ae}finally{P(!1)}},ut=async se=>{try{await m(se),await ze(),x("Passkey removed","info")}catch(Ae){x(Ae.message||"Failed to remove passkey","error")}};a.useEffect(()=>{ze()},[(Qr=(Yr=t==null?void 0:t.auth_settings)==null?void 0:Yr.passkey)==null?void 0:Qr.enabled]);const nt=[];return ce&&nt.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"]}),(Zr=(Kr=t==null?void 0:t.auth_settings)==null?void 0:Kr.passkey)!=null&&Zr.enabled&&nt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:F.length>0?`${F.length} registered`:"",actions:F.length>0?["manage","add"]:["add"]}),G!=null&&G.authenticator&&nt.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&&nt.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&&nt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:v==="enforced"?"Enforced":"Optional",actions:["toggle"]}),ee!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(kc,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(xt,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[ee==="qr"&&"Setup Two-Factor Authentication",ee==="verify"&&"Verify Your Authenticator",ee==="backup"&&"Save Your Backup Codes",ee==="success"&&"Setup Complete!"]})]}),e.jsx(B,{onClick:()=>me("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:[ee==="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:be?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:`${kv} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):re?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(_s,{value:re,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:te||"Loading..."})]}),e.jsx(B,{onClick:()=>me("verify"),disabled:!re||!te,style:{padding:"10px 20px",background:!re||!te?"var(--color-border)":"var(--color-primary)",color:!re||!te?"var(--color-secondary-text)":"white",border:`1px solid ${!re||!te?"var(--color-border)":"var(--color-primary)"}`,cursor:!re||!te?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),ee==="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(X,{type:"text",placeholder:"000000",value:Q[0],onChange:se=>{const Ae=se.target.value.replace(/[^0-9]/g,"").substring(0,6);q([Ae,Q[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(X,{type:"text",placeholder:"000000",value:Q[1],onChange:se=>{const Ae=se.target.value.replace(/[^0-9]/g,"").substring(0,6);q([Q[0],Ae])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(B,{onClick:()=>me("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(B,{onClick:Xe,disabled:he||Q.some(se=>se.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:he?"Verifying...":"Verify & Continue"})]})]}),ee==="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(Yt,{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:K.map((se,Ae)=>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(se),children:se},Ae))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(B,{onClick:_e,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(B,{onClick:fe,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(fd,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(B,{onClick:de,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),ee==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(rt,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(B,{onClick:de,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(kc,{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"})})}),nt.length?e.jsx("div",{children:nt.map((se,Ae)=>e.jsxs("div",{children:[e.jsxs(Rv,{children:[e.jsxs(Iv,{children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:se.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:se.description})]}),e.jsx(Tv,{children:e.jsxs("div",{style:{position:"relative"},children:[se.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(B,{ref:O,onClick:()=>_(!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"}),w&&e.jsx(Tc,{triggerRef:O,onClose:()=>_(!1),onChangePassword:De})]}),ot()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:R,onClick:()=>C(!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"}),f&&e.jsx(d2,{triggerRef:R,onClose:()=>C(!1),onRemovePassword:et})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:O,onClick:()=>_(!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"}),w&&e.jsx(Tc,{triggerRef:O,onClose:()=>_(!1),onChangePassword:De,isSetup:!0})]})}),se.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:I,onClick:()=>b(!0),disabled:be,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:be?"Setting up...":"Setup"}),z&&e.jsx(p2,{triggerRef:I,onClose:()=>b(!1),onSetupTOTP:async()=>{const Le=await i();return ge(Le.id),Le},onVerifyTOTP:async Le=>{await s(ye,Le),await r.refetch(),x("Two-factor authentication enabled successfully!","info")}})]})}),se.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{onClick:()=>k(!0),disabled:Je,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:Je?"not-allowed":"pointer",opacity:Je?.6:1},children:Je?"Removing...":"Remove"}),E&&e.jsx(Wr,{title:"Remove MFA and reset policy to default?",onConfirm:ne,onCancel:()=>k(!1)})]}),se.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:T,onClick:ve,disabled:xe,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:xe?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),y&&e.jsx(y2,{triggerRef:T,codes:K,onClose:()=>$(!1),onCopy:_e,onDownload:fe})]})}),se.id==="second_factor_policy"&&e.jsx(jr,{checked:v==="enforced",onChange:Le=>{j(Le?"enforced":"none")}}),se.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(B,{onClick:()=>W(!N),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",color:"var(--color-foreground)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"110px",height:"36px"},children:[N?"Hide":"Manage"," (",F.length,")",e.jsx(qt,{size:14,style:{transform:N?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{ref:pe,onClick:()=>oe(!0),disabled:A,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:A?"not-allowed":"pointer",opacity:A?.7:1,whiteSpace:"nowrap",minWidth:"80px",width:"auto",height:"36px"},children:A?"Adding...":"Add"}),H&&e.jsx(C2,{triggerRef:pe,onClose:()=>oe(!1),onAddPasskey:Ke})]})]})]})})]}),se.id==="passkey"&&N&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:M?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx(Ie,{})}):F.length===0?e.jsx("div",{style:{textAlign:"center",padding:"16px",color:"var(--color-secondary-text)",fontSize:"13px"},children:"No passkeys registered yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:F.map(Le=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:"var(--color-foreground)"},children:Le.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[Le.device_type==="platform"?"This device":"Security key",Le.last_used_at&&` • Last used ${new Date(Le.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(B,{onClick:()=>we(Le.id),style:{padding:"4px 10px",fontSize:"12px",background:"transparent",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",color:"var(--color-error)",cursor:"pointer",flexShrink:0,width:"auto"},children:"Remove"}),Z===Le.id&&e.jsx(Wr,{title:`Remove "${Le.name||"Unnamed Passkey"}"?`,onConfirm:()=>{ut(Le.id),we(null)},onCancel:()=>we(null)})]})]},Le.id))})}),Ae<nt.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},se.id))}):e.jsx(bt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},$2=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 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)"}})]}),z2=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"})]}),E2=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})]}),P2=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)"})]}),R2=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)"})]}),I2=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)"})]}),T2=()=>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:"?"})]}),Dc=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx($2,{...o}):r.includes("firefox")?e.jsx(z2,{...o}):r.includes("safari")?e.jsx(E2,{...o}):r.includes("edge")?e.jsx(P2,{...o}):r.includes("opera")?e.jsx(R2,{...o}):r.includes("brave")?e.jsx(I2,{...o}):e.jsx(T2,{})},O2=()=>{const[t,r]=a.useState(null),{signins:o,removeSignin:n,refetch:i,loading:s}=Rl(),{refetch:d}=Be(),{toast:u}=Jt(),l=Mv("(max-width: 600px)"),h=o,c=async m=>{try{await n(m),await Promise.all([i(),d()]),r(null),u("Session ended successfully","info")}catch(x){u(x.message||"Failed to end session. Please try again.","error")}},g=m=>{if(!m||m.trim()==="")return"Unknown";const x=new Date(m);if(isNaN(x.getTime()))return"Unknown";const S=Math.floor((new Date().getTime()-x.getTime())/(1e3*60));return S<1?"Just now":S<60?`${S}m ago`:S<1440?`${Math.floor(S/60)}h ago`:x.toLocaleDateString()};return s?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Ie,{})}):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:h&&h.length>0?e.jsxs(e.Fragment,{children:[!l&&e.jsx(ws,{children:e.jsxs($t,{children:[e.jsx(zt,{children:e.jsxs(He,{children:[e.jsx(Pe,{children:"Browser & Device"}),e.jsx(Pe,{children:"Location"}),e.jsx(Pe,{children:"Last Active"}),e.jsx(Pe,{})]})}),e.jsx(Et,{children:h.map(m=>e.jsxs(He,{children:[e.jsx(Fe,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Qi,{children:e.jsx(Dc,{browser:m.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:m.browser||"Unknown Browser"}),m.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:m.device})]})]})}),e.jsx(Fe,{children:e.jsxs("div",{children:[e.jsx("div",{children:m.city&&m.country?`${m.city}, ${m.country}`:"Unknown location"}),m.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:m.ip_address})]})}),e.jsx(Fe,{children:g(m.last_active_at)}),e.jsx(Pt,{children:e.jsxs(at,{open:t===m.id,openChange:x=>r(x?m.id:null),children:[e.jsx(lt,{children:e.jsx(_r,{children:"•••"})}),e.jsx(ct,{children:e.jsx(Oe,{onClick:()=>c(m.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Lt,{size:14}),"End Session"]})})})]})})]},m.id))})]})}),l&&e.jsx(js,{children:h.map((m,x)=>e.jsxs("div",{children:[e.jsx(Tn,{children:e.jsxs(On,{children:[e.jsx(Qi,{children:e.jsx(Dc,{browser:m.browser||"Unknown"})}),e.jsxs("div",{style:{marginLeft:"12px",display:"flex",flexDirection:"column"},children:[e.jsxs("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:[m.browser||"Unknown"," ",m.device?`on ${m.device}`:""]}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:[m.city&&m.country?`${m.city}, ${m.country}`:"Unknown location"," • ",g(m.last_active_at)]})]}),e.jsx("div",{style:{marginLeft:"auto"},children:e.jsxs(at,{open:t===m.id,openChange:v=>r(v?m.id:null),children:[e.jsx(lt,{children:e.jsx(_r,{children:"•••"})}),e.jsx(ct,{children:e.jsx(Oe,{onClick:()=>c(m.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Lt,{size:14}),"End Session"]})})})]})})]})}),x<h.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},m.id))})]}):e.jsx(bt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},gu=()=>{var v,S,E,k,j,z,b;const{loading:t}=Kt(),{deployment:r}=je(),[o,n]=a.useState("profile"),[i,s]=a.useState(null),[d,u]=a.useState("info"),l=a.useCallback((w,_="info")=>{s(w),u(_),setTimeout(()=>s(null),3e3)},[s]);if(t)return e.jsx(le,{children:e.jsx(_c,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ie,{})})});const h=r==null?void 0:r.auth_settings,c=(v=h==null?void 0:h.email_address)==null?void 0:v.enabled,g=(S=h==null?void 0:h.phone_number)==null?void 0:S.enabled,m=((E=r==null?void 0:r.social_connections)==null?void 0:E.some(w=>w.enabled))||!1,x=((k=h==null?void 0:h.password)==null?void 0:k.enabled)||((j=h==null?void 0:h.auth_factors_enabled)==null?void 0:j.authenticator)||((z=h==null?void 0:h.auth_factors_enabled)==null?void 0:z.phone_otp)||((b=h==null?void 0:h.auth_factors_enabled)==null?void 0:b.backup_code);return e.jsx(le,{children:e.jsx(Cv,{children:e.jsx(ru.Provider,{value:{screen:null,setScreen:()=>{},toast:l},children:e.jsxs(_c,{children:[e.jsx(Sv,{children:e.jsxs($v,{children:[e.jsx(Tr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(Or,{children:[e.jsx(pn,{size:16}),"Profile"]})}),c&&e.jsx(Tr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(Or,{children:[e.jsx(Sn,{size:16}),"Email"]})}),g&&e.jsx(Tr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(Or,{children:[e.jsx(Bf,{size:16}),"Phone"]})}),m&&e.jsx(Tr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(Or,{children:[e.jsx(Mf,{size:16}),"Connections"]})}),x&&e.jsx(Tr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(Or,{children:[e.jsx(xt,{size:16}),"Security"]})}),e.jsx(Tr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(Or,{children:[e.jsx(nf,{size:16}),"Sessions"]})})]})}),e.jsxs(zv,{children:[o==="profile"&&e.jsx(Dv,{}),o==="email"&&c&&e.jsx(Bv,{}),o==="phone"&&g&&e.jsx(Vv,{}),o==="social"&&m&&e.jsx(Hv,{}),o==="security"&&x&&e.jsx(S2,{}),o==="sessions"&&e.jsx(O2,{})]}),i&&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:[d==="error"?e.jsx(Yt,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:i})]})})]})})})})},mu=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:i,footerContent:s,customContent:d,children:u,showCloseButton:l})=>e.jsx(Ee,{isOpen:t,onClose:r,children:e.jsx(Ee.Overlay,{children:e.jsxs(Ee.Content,{style:{width:"900px",maxWidth:"90vw"},children:[n&&e.jsx(Ee.Header,{showCloseButton:l,children:i||o}),d||u||e.jsx(gu,{}),s&&e.jsx(Ee.Footer,{children:s})]})})}),A2=p.div`
|
|
4739
4739
|
position: relative;
|
|
4740
4740
|
`,L2=p.button`
|
|
4741
4741
|
display: flex;
|
|
@@ -4874,7 +4874,7 @@ cursor: pointer;
|
|
|
4874
4874
|
width: 14px;
|
|
4875
4875
|
height: 14px;
|
|
4876
4876
|
}
|
|
4877
|
-
`,ks=({showName:t=!0})=>{var _,f,C,y;const[r,o]=a.useState(!1),n=a.useRef(null),i=a.useRef(null),s=vs({triggerRef:n,isOpen:r,minWidth:380}),d=uo(!1),{session:u,signOut:l,switchSignIn:h,refetch:c}=Be(),{navigateToSignIn:g}=
|
|
4877
|
+
`,ks=({showName:t=!0})=>{var _,f,C,y;const[r,o]=a.useState(!1),n=a.useRef(null),i=a.useRef(null),s=vs({triggerRef:n,isOpen:r,minWidth:380}),d=uo(!1),{session:u,signOut:l,switchSignIn:h,refetch:c}=Be(),{navigateToSignIn:g}=it(),{deployment:m}=je(),x=(_=u==null?void 0:u.active_signin)==null?void 0:_.user,v=((C=(f=m==null?void 0:m.auth_settings)==null?void 0:f.multi_session_support)==null?void 0:C.enabled)??!1,S=(((y=u==null?void 0:u.signins)==null?void 0:y.length)??0)>1;a.useEffect(()=>{if(!r)return;const $=setTimeout(()=>{const I=O=>{var T,F;const R=O.target;(T=n.current)!=null&&T.contains(R)||(F=i.current)!=null&&F.contains(R)||o(!1)};return document.addEventListener("mousedown",I),()=>{document.removeEventListener("mousedown",I)}},50);return()=>{clearTimeout($)}},[r]);const E=()=>{o(!r)},k=$=>$.split(" ").map(I=>I[0]).join("").toUpperCase(),j=async $=>{try{await l($),await c(),o(!1)}catch{}},z=async()=>{try{await l(),await c(),o(!1)}catch{}},b=async $=>{try{await h($),await c(),o(!1)}catch{}},w=()=>{d.open(),o(!1)};return e.jsx(le,{children:e.jsxs(A2,{children:[e.jsxs(L2,{ref:n,onClick:E,children:[e.jsx(wi,{children:e.jsx(xu,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):k(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(M2,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&xn.createPortal(e.jsx(le,{children:e.jsx(D2,{ref:i,$position:s,$isOpen:r,$maxHeight:s==null?void 0:s.maxHeight,children:e.jsxs("div",{children:[v?(()=>{const $=[...(u==null?void 0:u.signins)||[]].sort((I,O)=>{const R=I.user.id===(x==null?void 0:x.id),T=O.user.id===(x==null?void 0:x.id);return R&&!T?-1:!R&&T?1:0});return $.map(({user:I,id:O},R)=>{const T=I.id===(x==null?void 0:x.id),F=!T;return e.jsxs(a.Fragment,{children:[e.jsxs(Uc,{$isClickable:F,onClick:F?()=>b(O):void 0,children:[e.jsxs(Bc,{children:[e.jsx(wi,{children:e.jsx(Gc,{children:I.has_profile_picture?e.jsx("img",{src:I.profile_picture_url,alt:I.first_name}):k(`${(I==null?void 0:I.first_name)||""} ${(I==null?void 0:I.last_name)||""}`)})}),e.jsxs(Wc,{children:[e.jsx(Vc,{children:e.jsx(Fc,{children:`${(I==null?void 0:I.first_name)||""} ${(I==null?void 0:I.last_name)||""}`})}),e.jsx(Nc,{children:I.primary_email_address.email})]})]}),T&&e.jsxs(Hc,{children:[e.jsxs(Zo,{onClick:w,children:[e.jsx(xr,{}),"Manage account"]}),e.jsxs(Zo,{$destructive:!0,onClick:()=>j(O),children:[e.jsx(Lt,{}),"Sign out"]})]})]}),R===0&&$.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},I.id)})})():x&&e.jsxs(Uc,{$isClickable:!1,children:[e.jsxs(Bc,{children:[e.jsx(wi,{children:e.jsx(Gc,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):k(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(Wc,{children:[e.jsx(Vc,{children:e.jsx(Fc,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(Nc,{children:x.primary_email_address.email})]})]}),e.jsxs(Hc,{children:[e.jsxs(Zo,{onClick:w,children:[e.jsx(xr,{}),"Manage account"]}),e.jsxs(Zo,{$destructive:!0,onClick:()=>{var $;return j((($=u==null?void 0:u.active_signin)==null?void 0:$.id)||"")},children:[e.jsx(Lt,{}),"Sign out"]})]})]}),v&&e.jsxs(e.Fragment,{children:[e.jsx(qc,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(Yc,{onClick:()=>g(),children:[e.jsx(gt,{}),"Add new account"]})}),S&&e.jsx(qc,{children:e.jsxs(Yc,{onClick:z,children:[e.jsx(Lt,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(mu,{isOpen:d.isOpen,onClose:d.close})]})})},F2=p.div`
|
|
4878
4878
|
padding: 12px 16px;
|
|
4879
4879
|
background: ${t=>t.$unread?"var(--color-background-hover)":"transparent"};
|
|
4880
4880
|
transition: background-color 0.2s ease;
|
|
@@ -5153,7 +5153,7 @@ cursor: pointer;
|
|
|
5153
5153
|
`,bu=a.forwardRef(({position:t,scope:r,onAction:o,className:n},i)=>e.jsx(ry,{ref:i,$position:t,className:n,children:e.jsx(yu,{scope:r,onAction:o,fullWidth:!0,maxHeight:t!=null&&t.maxHeight?`${t.maxHeight}px`:"100%"})})),oy=p.div`
|
|
5154
5154
|
position: relative;
|
|
5155
5155
|
display: inline-flex;
|
|
5156
|
-
`,ny=
|
|
5156
|
+
`,ny=yt`
|
|
5157
5157
|
0% { transform: rotate(0); }
|
|
5158
5158
|
10% { transform: rotate(15deg); }
|
|
5159
5159
|
20% { transform: rotate(-15deg); }
|
|
@@ -5181,7 +5181,7 @@ cursor: pointer;
|
|
|
5181
5181
|
}
|
|
5182
5182
|
|
|
5183
5183
|
&:hover svg {
|
|
5184
|
-
animation: ${t=>t.$hasUnread?
|
|
5184
|
+
animation: ${t=>t.$hasUnread?Gt`${ny} 2s ease`:"none"};
|
|
5185
5185
|
}
|
|
5186
5186
|
|
|
5187
5187
|
&:focus {
|
|
@@ -5216,14 +5216,14 @@ cursor: pointer;
|
|
|
5216
5216
|
display: flex;
|
|
5217
5217
|
align-items: center;
|
|
5218
5218
|
gap: 8px;
|
|
5219
|
-
`,cy=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(ay,{children:[r&&e.jsx(wu,{}),e.jsx(ks,{showName:t})]}),ly=({children:t})=>{var n;const{session:r,loading:o}=Be();return o||!((n=r.signins)!=null&&n.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},dy=({children:t})=>{var n;const{loading:r,session:o}=Be();return r||(n=o.signins)!=null&&n.length?null:e.jsx(e.Fragment,{children:t})},ju=
|
|
5219
|
+
`,cy=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(ay,{children:[r&&e.jsx(wu,{}),e.jsx(ks,{showName:t})]}),ly=({children:t})=>{var n;const{session:r,loading:o}=Be();return o||!((n=r.signins)!=null&&n.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},dy=({children:t})=>{var n;const{loading:r,session:o}=Be();return r||(n=o.signins)!=null&&n.length&&o.active_signin?null:e.jsx(e.Fragment,{children:t})},ju=yt`
|
|
5220
5220
|
0% {
|
|
5221
5221
|
background-position: -1000px 0;
|
|
5222
5222
|
}
|
|
5223
5223
|
100% {
|
|
5224
5224
|
background-position: 1000px 0;
|
|
5225
5225
|
}
|
|
5226
|
-
`,uy=
|
|
5226
|
+
`,uy=yt`
|
|
5227
5227
|
from {
|
|
5228
5228
|
transform: rotate(0deg);
|
|
5229
5229
|
}
|
|
@@ -5445,7 +5445,7 @@ cursor: pointer;
|
|
|
5445
5445
|
&:hover {
|
|
5446
5446
|
color: var(--color-primary-hover);
|
|
5447
5447
|
}
|
|
5448
|
-
`,ky=({onAccountSelect:t,showAddAccount:r=!0})=>{var b,w,_,f,C;const{session:o,loading:n,switchSignIn:i,signOut:s}=Be(),{deployment:d}=je(),{navigateToSignIn:u,navigate:l}=
|
|
5448
|
+
`,ky=({onAccountSelect:t,showAddAccount:r=!0})=>{var b,w,_,f,C;const{session:o,loading:n,switchSignIn:i,signOut:s}=Be(),{deployment:d}=je(),{navigateToSignIn:u,navigate:l}=it(),[h,c]=a.useState(null),[g,m]=a.useState(null),x=o==null?void 0:o.active_signin,v=(o==null?void 0:o.signins)||[],S=((w=(b=d==null?void 0:d.auth_settings)==null?void 0:b.multi_session_support)==null?void 0:w.enabled)??!1;a.useEffect(()=>{n||v.length||u()},[n,v,u]);const E=y=>y.split(" ").map($=>$[0]).join("").toUpperCase().slice(0,2),k=async y=>{var $;if(!(y===(x==null?void 0:x.id)||g)){m(y);try{if(await i(y),t)t(y),m(null);else{let I=new URLSearchParams(window.location.search).get("redirect_uri");if(I||(I=($=d.ui_settings)==null?void 0:$.after_signin_redirect_url),I){let O;try{O=new URL(I)}catch{O=new URL(I,window.location.origin)}(d==null?void 0:d.mode)==="staging"&&O.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),l(O.toString())}else m(null)}}catch(I){console.error("Failed to switch account:",I),m(null)}}},j=async(y,$)=>{y.stopPropagation(),c($);try{await s($)}catch(I){console.error("Failed to sign out:",I)}finally{c(null)}},z=()=>{var $;let y=new URLSearchParams(window.location.search).get("redirect_uri");y||(y=($=d.ui_settings)==null?void 0:$.after_signin_redirect_url),u(y)};return n?e.jsx(le,{children:e.jsxs(el,{children:[e.jsx(Me,{}),e.jsxs(rl,{children:[e.jsx(ol,{children:"Choose an account"}),e.jsxs(nl,{children:["to continue to ",((_=d==null?void 0:d.ui_settings)==null?void 0:_.app_name)||"App"]})]}),e.jsx(tl,{children:[1,2].map(y=>e.jsxs(yy,{children:[e.jsx(by,{}),e.jsxs(wy,{children:[e.jsx(il,{}),e.jsx(il,{$width:"small"})]})]},y))})]})}):v.length?e.jsx(le,{children:e.jsxs(el,{children:[e.jsx(Me,{}),e.jsxs(rl,{children:[e.jsx(ol,{children:"Choose an account"}),e.jsxs(nl,{children:["to continue to ",(f=d==null?void 0:d.ui_settings)==null?void 0:f.app_name]})]}),e.jsxs(tl,{children:[v.map(({user:y,id:$})=>{var T,F,D,M,L;if(!y)return null;const I=$===(x==null?void 0:x.id),O=g===$,R=`${y.first_name||""} ${y.last_name||""}`.trim();return e.jsxs(py,{$isActive:I,$isSwitching:O,onClick:()=>k($),children:[e.jsx(hy,{children:y.has_profile_picture?e.jsx("img",{src:y.profile_picture_url,alt:R}):E(R||((T=y.primary_email_address)==null?void 0:T.email)||((F=y.primary_phone_number)==null?void 0:F.phone_number)||y.username||"U")}),e.jsxs(fy,{children:[e.jsx(gy,{children:R||((D=y.primary_email_address)==null?void 0:D.email)||((M=y.primary_phone_number)==null?void 0:M.phone_number)||y.username||"User"}),e.jsx(my,{children:((L=y.primary_email_address)==null?void 0:L.email)||y.username})]}),!O&&e.jsxs(xy,{onClick:A=>j(A,$),$isLoading:h===$,disabled:h===$,children:[h===$?e.jsx(Mt,{size:12}):e.jsx(Lt,{size:12}),h===$?"Signing out...":"Sign out"]})]},$)}),r&&S&&e.jsxs(vy,{onClick:z,children:[e.jsx(gt,{}),"Add another account"]})]}),e.jsxs(jy,{children:["Don't have an account?"," ",e.jsx(_y,{children:e.jsx(vt,{to:`${(C=d.ui_settings)==null?void 0:C.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},Cy=()=>{const{navigateToSignIn:t}=it();return a.useEffect(()=>{t()},[t]),null},Sy=()=>{const{navigateToSignUp:t}=it();return a.useEffect(()=>{t()},[t]),null},$y=p.div`
|
|
5449
5449
|
width: 100%;
|
|
5450
5450
|
max-width: 1000px;
|
|
5451
5451
|
height: 600px;
|
|
@@ -5710,7 +5710,7 @@ cursor: pointer;
|
|
|
5710
5710
|
margin: 0 auto;
|
|
5711
5711
|
padding: 6px 16px;
|
|
5712
5712
|
font-size: 13px;
|
|
5713
|
-
`,Fy=()=>{var I,O;const{organizationMemberships:t,refetch:r,loading:o}=
|
|
5713
|
+
`,Fy=()=>{var I,O;const{organizationMemberships:t,refetch:r,loading:o}=Ft(),{workspaces:n}=Qt(),{switchOrganization:i,switchWorkspace:s}=Be(),{deployment:d}=je(),[u,l]=a.useState(null),[h,c]=a.useState("orgList"),[g,m]=a.useState(null),x=(d==null?void 0:d.b2b_settings.workspaces_enabled)??!1,v=(d==null?void 0:d.b2b_settings.allow_users_to_create_orgs)??!1,S=a.useRef(!1);a.useEffect(()=>{if(!(S.current||!t)){if(S.current=!0,t.length===0){c("createOrg");return}if(!x){c("orgList");return}if(!n||n.length===0){const R=t.find(T=>{var F,D;return!((F=T.eligibility_restriction)!=null&&F.type)||((D=T.eligibility_restriction)==null?void 0:D.type)==="none"});if(R){m(R.organization.id),c("createWorkspace");return}}c("orgList")}},[t,n,x]),console.log("view mode",h,x);const E=R=>R.split(" ").map(T=>T[0]).join("").toUpperCase().slice(0,2),k=async R=>{if(x){m(R.id),c("workspaceList");return}l(R.id);try{await i(R.id)}finally{l(null)}},j=async R=>{l(R.id);try{await s(R.id)}finally{l(null)}},z=async R=>{var F;await r();const T=((F=R==null?void 0:R.data)==null?void 0:F.organization)||(R==null?void 0:R.organization)||R;if(!x){c("orgList");return}T!=null&&T.id?(m(T.id),c("createWorkspace")):c("orgList")},b=()=>{},w=async()=>{m(null),c("orgList")},_=(I=t==null?void 0:t.find(R=>R.organization.id===g))==null?void 0:I.organization,f=g?n==null?void 0:n.filter(R=>R.organization.id===g):[];if(o)return null;if(h==="createOrg")return e.jsx(Ee.Body,{style:{padding:0},children:e.jsx(En,{onSuccess:z,onCancel:()=>c("orgList")})});if(h==="createWorkspace"&&g)return e.jsx(Ee.Body,{style:{padding:0},children:e.jsx(ps,{organizationId:g,onSuccess:b,onCancel:()=>c("workspaceList"),onCreateOrganization:()=>c("createOrg")})});const C=h==="workspaceList",y=C?"Select a workspace":"Select an organization",$=C?`Choose a workspace in ${(_==null?void 0:_.name)||""}`:`to continue to ${((O=d==null?void 0:d.ui_settings)==null?void 0:O.app_name)||"App"}`;return e.jsxs($y,{children:[e.jsxs(zy,{children:[e.jsxs(Ey,{children:[e.jsx(Me,{}),e.jsxs(Ay,{children:[e.jsx(Ly,{children:y}),e.jsx(My,{children:$})]})]}),e.jsx(ks,{showName:!0})]}),e.jsxs(Py,{children:[e.jsxs(Ry,{children:[e.jsxs(Iy,{children:[e.jsx(Ty,{children:C?"Workspaces":"Your organizations"}),C&&e.jsxs(Oy,{onClick:w,children:[e.jsx(ss,{}),"Go back"]})]}),e.jsx(Dy,{children:C?e.jsx(e.Fragment,{children:f&&f.length>0?f.map(R=>{var F,D,M;const T=((F=R.eligibility_restriction)==null?void 0:F.type)!=="none"&&((D=R.eligibility_restriction)==null?void 0:D.type)!==void 0;return e.jsxs(sl,{onClick:()=>!T&&j(R),disabled:u===R.id||T,style:{opacity:T?.6:1},children:[T&&e.jsx(al,{className:"warning-popover",children:(M=R.eligibility_restriction)==null?void 0:M.message}),e.jsx(cl,{children:R.image_url?e.jsx(ll,{src:R.image_url,alt:R.name}):E(R.name).charAt(0)}),e.jsxs(dl,{children:[e.jsx(ul,{children:R.name}),e.jsxs(pl,{children:[e.jsx(hn,{}),"Workspace"]})]}),e.jsxs(hl,{children:[T&&e.jsx(hr,{size:16,style:{color:"var(--color-error)"}}),e.jsx(Vi,{})]})]},R.id)}):e.jsxs(fl,{children:[e.jsx(gl,{children:"No workspaces yet"}),e.jsxs(ml,{children:["Create your first workspace for"," ",(_==null?void 0:_.name)||"this organization"]}),e.jsxs(xl,{onClick:()=>c("createWorkspace"),children:[e.jsx(gt,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(R=>{var W,H,oe;const T=R.organization,F=n==null?void 0:n.filter(Z=>Z.organization.id===T.id),D=(F==null?void 0:F.length)||0,M=T.member_count,L=R.roles[0].name,A=R.roles.length-1,P=A>0?`${L.charAt(0).toUpperCase()+L.slice(1)} +${A}`:L.charAt(0).toUpperCase()+L.slice(1),N=((W=R.eligibility_restriction)==null?void 0:W.type)!=="none"&&((H=R.eligibility_restriction)==null?void 0:H.type)!==void 0;return e.jsxs(sl,{onClick:()=>!N&&k(T),disabled:u===T.id||N,style:{opacity:N?.6:1},children:[N&&e.jsx(al,{className:"warning-popover",children:(oe=R.eligibility_restriction)==null?void 0:oe.message}),e.jsx(cl,{children:T.image_url?e.jsx(ll,{src:T.image_url,alt:T.name}):E(T.name)}),e.jsxs(dl,{children:[e.jsx(ul,{children:T.name}),e.jsx(pl,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(hn,{}),D," workspace",D!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(uf,{}),P," • ",M," member",M!==1?"s":""]})})]}),e.jsxs(hl,{children:[N&&e.jsx(hr,{size:16,style:{color:"var(--color-error)"}}),e.jsx(Vi,{})]})]},T.id)}):e.jsxs(fl,{children:[e.jsx(gl,{children:"No organizations yet"}),e.jsx(ml,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(xl,{onClick:()=>c("createOrg"),children:[e.jsx(gt,{}),"Create organization"]})]})})]}),!C&&t&&t.length>0&&v&&e.jsxs(B,{$outline:!0,style:{marginTop:x?"8px":"var(--space-md)"},onClick:()=>c("createOrg"),disabled:u!==null,children:[e.jsx(gt,{size:12}),"Create new organization"]})]})]})},Ny=p(Ee.Content)`
|
|
5714
5714
|
padding: 0;
|
|
5715
5715
|
width: 90vw;
|
|
5716
5716
|
max-width: 1000px;
|
|
@@ -5719,5 +5719,5 @@ cursor: pointer;
|
|
|
5719
5719
|
max-width: 95vw;
|
|
5720
5720
|
width: 95vw;
|
|
5721
5721
|
}
|
|
5722
|
-
`,Uy=({children:t})=>{var S,E,k,j;const{loading:r,session:o}=Be(),{activeOrganization:n}=Cr(),{activeWorkspace:i,loading:s}=
|
|
5722
|
+
`,Uy=({children:t})=>{var S,E,k,j;const{loading:r,session:o}=Be(),{activeOrganization:n}=Cr(),{activeWorkspace:i,loading:s}=Nt(),{workspaces:d}=Qt(),{deployment:u}=je(),{organizationMemberships:l}=Ft(),h=(u==null?void 0:u.b2b_settings.workspaces_enabled)??!1,c=l==null?void 0:l.find(z=>z.organization.id===(n==null?void 0:n.id)),g=d==null?void 0:d.find(z=>{var b;return z.id===((b=o==null?void 0:o.active_signin)==null?void 0:b.active_workspace_membership_id)}),m=((S=c==null?void 0:c.eligibility_restriction)==null?void 0:S.type)!=="none"&&((E=c==null?void 0:c.eligibility_restriction)==null?void 0:E.type)!==void 0,x=((k=g==null?void 0:g.eligibility_restriction)==null?void 0:k.type)!=="none"&&((j=g==null?void 0:g.eligibility_restriction)==null?void 0:j.type)!==void 0;return r||h&&s?null:(m||x||!n?!1:h?i?d==null?void 0:d.some(b=>b.id===i.id&&b.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(le,{children:e.jsx(Ee,{isOpen:!0,children:e.jsx(Ee.Overlay,{children:e.jsx(Ny,{children:e.jsx(Fy,{})})})})})},By=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(i=>r.startsWith(i))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(i=>r.startsWith(i))},Wy=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=qx;exports.AuthFormImage=Me;exports.CreateOrganizationForm=En;exports.CreateWorkspaceDialog=Hi;exports.CreateWorkspaceForm=ps;exports.DeploymentInitialized=Hp;exports.DeploymentInitializing=qp;exports.DeploymentProvider=_u;exports.Dialog=Ee;exports.DialogTrigger=Jg;exports.Dropdown=at;exports.DropdownDivider=$n;exports.DropdownItem=Oe;exports.DropdownItems=ct;exports.DropdownTrigger=lt;exports.Form=_t;exports.FormGroup=ie;exports.Input=X;exports.Label=J;exports.MagicLinkVerification=Nx;exports.ManageAccount=gu;exports.ManageAccountDialog=mu;exports.ManageOrganization=Gd;exports.ManageWorkspace=Qd;exports.ManageWorkspaceDialog=qi;exports.NavigateToSignIn=Cy;exports.NavigateToSignUp=Sy;exports.NavigationLink=vt;exports.NotificationBell=wu;exports.NotificationItem=vu;exports.NotificationPanel=yu;exports.NotificationPopover=bu;exports.OAuthProvider=yl;exports.ORG_ADMIN_PERMISSIONS=Kd;exports.ORG_MANAGEMENT_PERMISSIONS=Zd;exports.OTPInput=Zt;exports.OrganizationSwitcher=tu;exports.PhoneNumberInput=vo;exports.PhoneVerification=Dd;exports.ProfileCompletion=Nd;exports.RequireActiveTenancy=Uy;exports.SSOCallback=Rx;exports.SignInForm=px;exports.SignUpForm=Mg;exports.SignedIn=ly;exports.SignedInAccounts=ky;exports.SignedOut=dy;exports.SimpleDialog=Zg;exports.Spinner=Ie;exports.Switch=jr;exports.TwoFactorMethodSelector=Md;exports.TwoFactorVerification=Fd;exports.UserButton=ks;exports.UserControls=cy;exports.WORKSPACE_ADMIN_PERMISSIONS=Jd;exports.WORKSPACE_MANAGEMENT_PERMISSIONS=Xd;exports.WaitlistForm=Sx;exports.canManageOrganization=eu;exports.canManageWorkspace=Yi;exports.clearTokenCache=jt;exports.hasIncompleteProfile=Ux;exports.hasOrgPermission=ys;exports.hasWorkspacePermission=bs;exports.isExternalUrl=By;exports.isOrgAdmin=lv;exports.isSafeUrl=Wy;exports.isWorkspaceAdmin=dv;exports.redirectToProfileCompletion=Bx;exports.useActiveOrganization=Cr;exports.useActiveTenancy=jp;exports.useActiveWorkspace=Nt;exports.useAgentContext=Bp;exports.useAgentContexts=Gp;exports.useAgentIntegrations=Wp;exports.useAgentSession=Vp;exports.useClient=Ve;exports.useDeployment=je;exports.useForgotPassword=Ll;exports.useInvitation=Nl;exports.useMagicLinkParams=Al;exports.useMagicLinkVerification=Ol;exports.useNavigation=it;exports.useNotificationStream=Ml;exports.useNotifications=Dl;exports.useOrganizationList=kt;exports.useOrganizationMemberships=Ft;exports.useSSOCallback=Tl;exports.useScopeUnread=Fl;exports.useSession=Be;exports.useSignIn=bl;exports.useSignInWithStrategy=Mr;exports.useSignUp=wl;exports.useUser=Kt;exports.useUserSignins=Rl;exports.useWaitlist=Il;exports.useWorkspaceList=Qt;exports.useWorkspaceMemberships=vn;Object.keys(Rs).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Rs[t]})});
|
|
5723
5723
|
//# sourceMappingURL=index.cjs.js.map
|