@wacht/jsx 0.0.1-alpha.35 → 0.0.1-alpha.36
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 +69 -69
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +1494 -1494
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";var cd=Object.defineProperty;var ld=(t,r,o)=>r in t?cd(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var tt=(t,r,o)=>ld(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),Wr=require("react-dom"),Ls=require("@wacht/types"),Ja=a.createContext(void 0);function dd({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[i,s]=a.useState(!0),[
|
|
2
|
+
"use strict";var cd=Object.defineProperty;var ld=(t,r,o)=>r in t?cd(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o;var tt=(t,r,o)=>ld(t,typeof r!="symbol"?r+"":r,o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),a=require("react"),Wr=require("react-dom"),Ls=require("@wacht/types"),Ja=a.createContext(void 0);function dd({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[i,s]=a.useState(!0),[p,f]=a.useState(null),c=a.useRef(!1);a.useEffect(()=>{async function l(){if(c.current)return;c.current=!0,s(!0);const[u,g,x]=r.split("_");if(!x)throw new Error("Invalid public key");let m=atob(x),y=g==="test",$=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){$=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",$??"");const k=new URL(window.location.href);k.searchParams.delete("__dev_session__"),window.history.replaceState({},"",k.toString())}else $=localStorage.getItem("__dev_session__");let S={};const b=new URLSearchParams;y?b.append("__dev_session__",$??""):S={credentials:"include"};const z=await fetch(`${m}/deployment${y?"?":""}${b.toString()}`,S);if(!z.ok){s(!1);return}const j=await z.json();j.data.backend_host=m,n&&(j.data.ui_settings={...j.data.ui_settings,...n}),f(j.data),y&&z.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",z.headers.get("x-development-session")??""),s(!1)}l()},[r]);const h=a.useMemo(()=>({loading:i,deployment:p,adapter:o}),[i,p,o]);return e.jsx(Ja.Provider,{value:h,children:t})}function me(){const t=a.useContext(Ja);if(t===void 0)throw new Error("useDeployment must be used within a DeploymentProvider");if(!t.loading&&!t.deployment)throw new Error("Deployment is not loaded");return t}function Fe(){const{deployment:t,loading:r}=me();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,i)=>{const s=ud(t),p=new Headers(s.headers);i!=null&&i.headers&&new Headers(i.headers).forEach((l,u)=>{p.set(u,l)});const f=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&f.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(f,{...s,...i,headers:p});return t.mode==="staging"&&c.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",c.headers.get("x-development-session")??""),c},loading:r}}function ud(t){return t.mode==="staging"?{}:{credentials:"include"}}var Kr={exports:{}},ln={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* use-sync-external-store-shim.production.js
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var As;function pd(){if(As)return ln;As=1;var t=a;function r(
|
|
10
|
+
*/var As;function pd(){if(As)return ln;As=1;var t=a;function r(u,g){return u===g&&(u!==0||1/u===1/g)||u!==u&&g!==g}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,i=t.useEffect,s=t.useLayoutEffect,p=t.useDebugValue;function f(u,g){var x=g(),m=n({inst:{value:x,getSnapshot:g}}),y=m[0].inst,$=m[1];return s(function(){y.value=x,y.getSnapshot=g,c(y)&&$({inst:y})},[u,x,g]),i(function(){return c(y)&&$({inst:y}),u(function(){c(y)&&$({inst:y})})},[u]),p(x),x}function c(u){var g=u.getSnapshot;u=u.value;try{var x=g();return!o(u,x)}catch{return!0}}function h(u,g){return g()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:f;return ln.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,ln}var dn={};/**
|
|
11
11
|
* @license React
|
|
12
12
|
* use-sync-external-store-shim.development.js
|
|
13
13
|
*
|
|
@@ -15,12 +15,12 @@
|
|
|
15
15
|
*
|
|
16
16
|
* This source code is licensed under the MIT license found in the
|
|
17
17
|
* LICENSE file in the root directory of this source tree.
|
|
18
|
-
*/var Ds;function hd(){return Ds||(Ds=1,process.env.NODE_ENV!=="production"&&function(){function t(x,m){return x===m&&(x!==0||1/x===1/m)||x!==x&&m!==m}function r(x,m){l||i.startTransition===void 0||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var y=m();if(!p){var $=m();s(y,$)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),p=!0)}$=u({inst:{value:y,getSnapshot:m}});var S=$[0].inst,b=$[1];return c(function(){S.value=y,S.getSnapshot=m,o(S)&&b({inst:S})},[x,y,m]),f(function(){return o(S)&&b({inst:S}),x(function(){o(S)&&b({inst:S})})},[x]),h(y),y}function o(x){var m=x.getSnapshot;x=x.value;try{var y=m();return!s(x,y)}catch{return!0}}function n(x,m){return m()}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,u=i.useState,f=i.useEffect,c=i.useLayoutEffect,h=i.useDebugValue,l=!1,p=!1,g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;dn.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:g,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),dn}var Fs;function fd(){return Fs||(Fs=1,process.env.NODE_ENV==="production"?Kr.exports=pd():Kr.exports=hd()),Kr.exports}var gd=fd();const ec=0,tc=1,rc=2,Ns=3;var Bs=Object.prototype.hasOwnProperty;function Qn(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--&&Qn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Bs.call(t,o)&&++n&&!Bs.call(r,o)||!(o in r)||!Qn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const vt=new WeakMap,$t=()=>{},He=$t(),Kn=Object,Ce=t=>t===He,lt=t=>typeof t=="function",Pt=(t,r)=>({...t,...r}),oc=t=>lt(t.then),un={},Xr={},bs="undefined",Vr=typeof window!=bs,Xn=typeof document!=bs,md=Vr&&"Deno"in window,xd=()=>Vr&&typeof window.requestAnimationFrame!=bs,nc=(t,r)=>{const o=vt.get(t);return[()=>!Ce(r)&&t.get(r)||un,n=>{if(!Ce(r)){const i=t.get(r);r in Xr||(Xr[r]=i),o[5](r,Pt(i,n),i||un)}},o[6],()=>!Ce(r)&&r in Xr?Xr[r]:!Ce(r)&&t.get(r)||un]};let Jn=!0;const vd=()=>Jn,[es,ts]=Vr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$t,$t],bd=()=>{const t=Xn&&document.visibilityState;return Ce(t)||t!=="hidden"},yd=t=>(Xn&&document.addEventListener("visibilitychange",t),es("focus",t),()=>{Xn&&document.removeEventListener("visibilitychange",t),ts("focus",t)}),wd=t=>{const r=()=>{Jn=!0,t()},o=()=>{Jn=!1};return es("online",r),es("offline",o),()=>{ts("online",r),ts("offline",o)}},jd={isOnline:vd,isVisible:bd},_d={initFocus:yd,initReconnect:wd},Us=!a.useId,Nr=!Vr||md,kd=t=>xd()?window.requestAnimationFrame(t):setTimeout(t,1),pn=Nr?a.useEffect:a.useLayoutEffect,hn=typeof navigator<"u"&&navigator.connection,Ws=!Nr&&hn&&(["slow-2g","2g"].includes(hn.effectiveType)||hn.saveData),Jr=new WeakMap,Cd=t=>Kn.prototype.toString.call(t),fn=(t,r)=>t===`[object ${r}]`;let Sd=0;const rs=t=>{const r=typeof t,o=Cd(t),n=fn(o,"Date"),i=fn(o,"RegExp"),s=fn(o,"Object");let u,f;if(Kn(t)===t&&!n&&!i){if(u=Jr.get(t),u)return u;if(u=++Sd+"~",Jr.set(t,u),Array.isArray(t)){for(u="@",f=0;f<t.length;f++)u+=rs(t[f])+",";Jr.set(t,u)}if(s){u="#";const c=Kn.keys(t).sort();for(;!Ce(f=c.pop());)Ce(t[f])||(u+=f+":"+rs(t[f])+",");Jr.set(t,u)}}else u=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return u},ys=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?rs(t):"",[t,r]};let zd=0;const os=()=>++zd;async function sc(...t){const[r,o,n,i]=t,s=Pt({populateCache:!0,throwOnError:!0},typeof i=="boolean"?{revalidate:i}:i||{});let u=s.populateCache;const f=s.rollbackOnError;let c=s.optimisticData;const h=g=>typeof f=="function"?f(g):f!==!1,l=s.throwOnError;if(lt(o)){const g=o,x=[],m=r.keys();for(const y of m)!/^\$(inf|sub)\$/.test(y)&&g(r.get(y)._k)&&x.push(y);return Promise.all(x.map(p))}return p(o);async function p(g){const[x]=ys(g);if(!x)return;const[m,y]=nc(r,x),[$,S,b,z]=vt.get(r),j=()=>{const I=$[x];return(lt(s.revalidate)?s.revalidate(m().data,g):s.revalidate!==!1)&&(delete b[x],delete z[x],I&&I[0])?I[0](rc).then(()=>m().data):m().data};if(t.length<3)return j();let k=n,_,v=!1;const P=os();S[x]=[P,0];const C=!Ce(c),E=m(),T=E.data,R=E._c,w=Ce(R)?T:R;if(C&&(c=lt(c)?c(w,T):c,y({data:c,_c:w})),lt(k))try{k=k(w)}catch(I){_=I,v=!0}if(k&&oc(k))if(k=await k.catch(I=>{_=I,v=!0}),P!==S[x][0]){if(v)throw _;return k}else v&&C&&h(_)&&(u=!0,y({data:w,_c:He}));if(u&&!v)if(lt(u)){const I=u(k,w);y({data:I,error:He,_c:He})}else y({data:k,error:He,_c:He});if(S[x][1]=os(),Promise.resolve(j()).then(()=>{y({_c:He})}),v){if(l)throw _;return}return k}}const Vs=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},$d=(t,r)=>{if(!vt.has(t)){const o=Pt(_d,r),n=Object.create(null),i=sc.bind(He,t);let s=$t;const u=Object.create(null),f=(l,p)=>{const g=u[l]||[];return u[l]=g,g.push(p),()=>g.splice(g.indexOf(p),1)},c=(l,p,g)=>{t.set(l,p);const x=u[l];if(x)for(const m of x)m(p,g)},h=()=>{if(!vt.has(t)&&(vt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),i,c,f]),!Nr)){const l=o.initFocus(setTimeout.bind(He,Vs.bind(He,n,ec))),p=o.initReconnect(setTimeout.bind(He,Vs.bind(He,n,tc)));s=()=>{l&&l(),p&&p(),vt.delete(t)}}};return h(),[t,i,h,s]}return[t,vt.get(t)[4]]},Ed=(t,r,o,n,i)=>{const s=o.errorRetryCount,u=i.retryCount,f=~~((Math.random()+.5)*(1<<(u<8?u:8)))*o.errorRetryInterval;!Ce(s)&&u>s||setTimeout(n,f,i)},Id=Qn,[ic,Pd]=$d(new Map),Rd=Pt({onLoadingSlow:$t,onSuccess:$t,onError:$t,onErrorRetry:Ed,onDiscarded:$t,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ws?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ws?5e3:3e3,compare:Id,isPaused:()=>!1,cache:ic,mutate:Pd,fallback:{}},jd),Td=(t,r)=>{const o=Pt(t,r);if(r){const{use:n,fallback:i}=t,{use:s,fallback:u}=r;n&&s&&(o.use=n.concat(s)),i&&u&&(o.fallback=Pt(i,u))}return o},Md=a.createContext({}),Od="$inf$",ac=Vr&&window.__SWR_DEVTOOLS_USE__,Ld=ac?window.__SWR_DEVTOOLS_USE__:[],Ad=()=>{ac&&(window.__SWR_DEVTOOLS_REACT__=a)},Dd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],cc=()=>Pt(Rd,a.useContext(Md)),Fd=t=>(r,o,n)=>t(r,o&&((...s)=>{const[u]=ys(r),[,,,f]=vt.get(ic);if(u.startsWith(Od))return o(...s);const c=f[u];return Ce(c)?o(...s):(delete f[u],c)}),n),Nd=Ld.concat(Fd),Bd=t=>function(...o){const n=cc(),[i,s,u]=Dd(o),f=Td(n,u);let c=t;const{use:h}=f,l=(h||[]).concat(Nd);for(let p=l.length;p--;)c=l[p](c);return c(i,s||f.fetcher||null,f)},Ud=(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())}};Ad();const gn=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}}),mn={dedupe:!0},Wd=(t,r,o)=>{const{cache:n,compare:i,suspense:s,fallbackData:u,revalidateOnMount:f,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:l,refreshWhenOffline:p,keepPreviousData:g}=o,[x,m,y,$]=vt.get(n),[S,b]=ys(t),z=a.useRef(!1),j=a.useRef(!1),k=a.useRef(S),_=a.useRef(r),v=a.useRef(o),P=()=>v.current,C=()=>P().isVisible()&&P().isOnline(),[E,T,R,w]=nc(n,S),I=a.useRef({}).current,M=Ce(u)?Ce(o.fallback)?He:o.fallback[S]:u,L=(q,B)=>{for(const ie in I){const H=ie;if(H==="data"){if(!i(q[H],B[H])&&(!Ce(q[H])||!i(oe,B[H])))return!1}else if(B[H]!==q[H])return!1}return!0},U=a.useMemo(()=>{const q=!S||!r?!1:Ce(f)?P().isPaused()||s?!1:c!==!1:f,B=ge=>{const V=Pt(ge);return delete V._k,q?{isValidating:!0,isLoading:!0,...V}:V},ie=E(),H=w(),se=B(ie),we=ie===H?se:B(H);let xe=se;return[()=>{const ge=B(E());return L(ge,xe)?(xe.data=ge.data,xe.isLoading=ge.isLoading,xe.isValidating=ge.isValidating,xe.error=ge.error,xe):(xe=ge,ge)},()=>we]},[n,S]),F=gd.useSyncExternalStore(a.useCallback(q=>R(S,(B,ie)=>{L(ie,B)||q()}),[n,S]),U[0],U[1]),O=!z.current,A=x[S]&&x[S].length>0,Q=F.data,ee=Ce(Q)?M&&oc(M)?gn(M):M:Q,W=F.error,K=a.useRef(ee),oe=g?Ce(Q)?Ce(K.current)?ee:K.current:Q:ee,te=A&&!Ce(W)?!1:O&&!Ce(f)?f:P().isPaused()?!1:s?Ce(ee)?!1:c:Ce(ee)||c,de=!!(S&&r&&O&&te),ne=Ce(F.isValidating)?de:F.isValidating,ue=Ce(F.isLoading)?de:F.isLoading,X=a.useCallback(async q=>{const B=_.current;if(!S||!B||j.current||P().isPaused())return!1;let ie,H,se=!0;const we=q||{},xe=!y[S]||!we.dedupe,ge=()=>Us?!j.current&&S===k.current&&z.current:S===k.current,V={isValidating:!1,isLoading:!1},D=()=>{T(V)},N=()=>{const pe=y[S];pe&&pe[1]===H&&delete y[S]},re={isValidating:!0};Ce(E().data)&&(re.isLoading=!0);try{if(xe&&(T(re),o.loadingTimeout&&Ce(E().data)&&setTimeout(()=>{se&&ge()&&P().onLoadingSlow(S,o)},o.loadingTimeout),y[S]=[B(b),os()]),[ie,H]=y[S],ie=await ie,xe&&setTimeout(N,o.dedupingInterval),!y[S]||y[S][1]!==H)return xe&&ge()&&P().onDiscarded(S),!1;V.error=He;const pe=m[S];if(!Ce(pe)&&(H<=pe[0]||H<=pe[1]||pe[1]===0))return D(),xe&&ge()&&P().onDiscarded(S),!1;const J=E().data;V.data=i(J,ie)?J:ie,xe&&ge()&&P().onSuccess(ie,S,o)}catch(pe){N();const J=P(),{shouldRetryOnError:_e}=J;J.isPaused()||(V.error=pe,xe&&ge()&&(J.onError(pe,S,J),(_e===!0||lt(_e)&&_e(pe))&&(!P().revalidateOnFocus||!P().revalidateOnReconnect||C())&&J.onErrorRetry(pe,S,J,ve=>{const Se=x[S];Se&&Se[0]&&Se[0](Ns,ve)},{retryCount:(we.retryCount||0)+1,dedupe:!0})))}return se=!1,D(),!0},[S,n]),ae=a.useCallback((...q)=>sc(n,k.current,...q),[]);if(pn(()=>{_.current=r,v.current=o,Ce(Q)||(K.current=Q)}),pn(()=>{if(!S)return;const q=X.bind(He,mn);let B=0;P().revalidateOnFocus&&(B=Date.now()+P().focusThrottleInterval);const H=Ud(S,x,(se,we={})=>{if(se==ec){const xe=Date.now();P().revalidateOnFocus&&xe>B&&C()&&(B=xe+P().focusThrottleInterval,q())}else if(se==tc)P().revalidateOnReconnect&&C()&&q();else{if(se==rc)return X();if(se==Ns)return X(we)}});return j.current=!1,k.current=S,z.current=!0,T({_k:b}),te&&(y[S]||(Ce(ee)||Nr?q():kd(q))),()=>{j.current=!0,H()}},[S]),pn(()=>{let q;function B(){const H=lt(h)?h(E().data):h;H&&q!==-1&&(q=setTimeout(ie,H))}function ie(){!E().error&&(l||P().isVisible())&&(p||P().isOnline())?X(mn).then(B):B()}return B(),()=>{q&&(clearTimeout(q),q=-1)}},[h,l,p,S]),a.useDebugValue(oe),s&&Ce(ee)&&S){if(!Us&&Nr)throw new Error("Fallback data is required when using Suspense in SSR.");_.current=r,v.current=o,j.current=!1;const q=$[S];if(!Ce(q)){const B=ae(q);gn(B)}if(Ce(W)){const B=X(mn);Ce(oe)||(B.status="fulfilled",B.value=!0),gn(B)}else throw W}return{mutate:ae,get data(){return I.data=!0,oe},get error(){return I.error=!0,W},get isValidating(){return I.isValidating=!0,ne},get isLoading(){return I.isLoading=!0,ue}}},Ne=Bd(Wd);async function G(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}return{data:(await t.json()).data}}function lc(t){const{client:r}=Fe(),o=a.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await G(c)).data},[r,t]),{data:n,error:i,mutate:s}=Ne(t?`wacht-agent-sessions:${t}`:null,o,{revalidateOnFocus:!1}),u=a.useCallback(async c=>{const h=new FormData;h.append("title",c.title),c.system_instructions&&h.append("system_instructions",c.system_instructions);const l=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:h}),p=await G(l);return await s(g=>g&&{...g,data:[p.data,...g.data]}),p.data},[r,t,s]),f=a.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await s(h=>h&&{...h,data:h.data.filter(l=>l.id!==c)})},[r,t,s]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!i,error:i,createSession:u,deleteSession:f,refetch:async()=>{await s()}}}const dc=a.createContext(void 0);function Yo(){const t=a.useContext(dc);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Vd({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:i,onSessionCreated:s,onSessionDeleted:u,onError:f}){const[c,h]=a.useState(i?{id:i,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[l,p]=a.useState(!1),{sessions:g,loading:x,error:m,createSession:y,deleteSession:$,refetch:S}=lc(o);a.useEffect(()=>{if(i&&g.length>0){const _=g.find(v=>v.id===i);_&&h(_)}},[i,g]);const b=a.useCallback(_=>{h(_),p(!1)},[]),z=a.useCallback(async _=>{try{const v=_||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,P=await y({title:v});return h(P),s==null||s(P),P}catch(v){const P=v instanceof Error?v.message:"Failed to create session";throw f==null||f(P),v}},[y,s,f]),j=a.useCallback(async _=>{try{await $(_),(c==null?void 0:c.id)===_&&h(null),u==null||u(_)}catch(v){const P=v instanceof Error?v.message:"Failed to delete session";throw f==null||f(P),v}},[$,c,u,f]),k={agentName:r,token:o,platformAdapter:n,sessions:g,selectedSession:c,loadingSessions:x,sessionError:m,selectSession:b,createSession:z,deleteSession:j,refreshSessions:S,showHistory:l,setShowHistory:p,onSessionCreated:s,onSessionDeleted:u,onError:f};return e.jsx(dc.Provider,{value:k,children:t})}var uc=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(uc||{});function Gd(t,r){const o={username:Hd(t,r),email:qd(t,r),phone:Yd(t,r),email_otp:Zd(t,r),magic_link:Qd(t,r),oauth:Kd(t),generic:Xd(t,r)};return function(i){return o[i]}}function Hd(t,r){return async({username:o,password:n})=>{var f,c;const i=new FormData;i.append("strategy","plain_username"),i.append("username",o),i.append("password",n);const s=await t("/auth/signin",{method:"POST",body:i}),u=await G(s);return"data"in u&&((c=(f=u.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(u.data.signin_attempts.at(-1)||null),u}}function qd(t,r){return async({email:o,password:n})=>{var f,c;const i=new FormData;i.append("strategy","plain_email"),i.append("email",o),i.append("password",n);const s=await t("/auth/signin",{method:"POST",body:i}),u=await G(s);return"data"in u&&((c=(f=u.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(u.data.signin_attempts.at(-1)||null),u}}function Yd(t,r){return async({phone:o})=>{var u,f;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const i=await t("/auth/signin",{method:"POST",body:n}),s=await G(i);return"data"in s&&((f=(u=s.data)==null?void 0:u.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Zd(t,r){return async({email:o})=>{var u,f;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const i=await t("/auth/signin",{method:"POST",body:n}),s=await G(i);return"data"in s&&((f=(u=s.data)==null?void 0:u.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Qd(t,r){return async({email:o})=>{var u,f;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const i=await t("/auth/signin",{method:"POST",body:n}),s=await G(i);return"data"in s&&((f=(u=s.data)==null?void 0:u.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Kd(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const i=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),s=await G(i);return"data"in s&&s.data.oauth_url&&(window.location.href=s.data.oauth_url),s}}function Xd(t,r){return async({email:o,username:n,password:i,phone:s,strategy:u,token:f})=>{var p,g;const c=new FormData;u&&c.append("strategy",u),o&&c.append("email",o),n&&c.append("username",n),i&&c.append("password",i),s&&c.append("phone",s),f&&c.append("token",f);const h=await t("/auth/signin",{method:"POST",body:c}),l=await G(h);return"data"in l&&((g=(p=l.data)==null?void 0:p.signin_attempts)!=null&&g.length)&&r(l.data.signin_attempts.at(-1)||null),l}}function pc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Gd(t,n),completeVerification:async i=>{var c,h;const s=new FormData;s.append("verification_code",i);const u=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:s}),f=await G(u);if("data"in f&&((h=(c=f.data)==null?void 0:c.signin_attempts)!=null&&h.length)){const l=f.data.signin_attempts.at(-1);return n(l||null),f.data}else throw new Error("Verification failed")},prepareVerification:async i=>{var f;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((f=o==null?void 0:o.id)==null?void 0:f.toString())||""),s.searchParams.set("strategy",i.strategy),s.searchParams.set("identifier_type","signin"),i.strategy==="phone_otp"&&i.lastDigits?s.searchParams.set("last_digits",i.lastDigits):(i.strategy==="email_otp"&&i.redirectUri||i.strategy==="magic_link"&&i.redirectUri)&&s.searchParams.set("redirect_uri",i.redirectUri);const u=await t(s.pathname+s.search,{method:"POST"});return G(u)},completeProfile:async i=>{var c;if(!o)throw new Error("No signin attempt found");const s=new FormData;for(const[h,l]of Object.entries(i))l&&s.append(h,l);const u=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:s}),f=await G(u);if("data"in f&&f.data){const h=(c=f.data.signin_attempts)==null?void 0:c.find(l=>l.id===o.id);return h&&n(h),f.data}else throw new Error("Profile completion failed")},identify:async i=>{const s=new FormData;s.append("identifier",i);const u=await t("/auth/identify",{method:"POST",body:s});return(await G(u)).data},initEnterpriseSso:async(i,s)=>{const u=new URLSearchParams({connection_id:i});s&&u.append("redirect_uri",s);const f=await t(`/auth/sso/login?${u.toString()}`,{method:"POST"});return(await G(f)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function Br(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:i,setSignInAttempt:s}=pc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:i,setSignInAttempt:s};const u=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:u,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:i,setSignInAttempt:s}}function Jd(t,r,o){return{create:async n=>{var f,c,h;const i=new FormData;for(const[l,p]of Object.entries(n))i.append(l,p);const s=await t("/auth/signup",{method:"POST",body:i}),u=await G(s);return"data"in u&&((c=(f=u.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(((h=u.data.signup_attempts)==null?void 0:h.at(-1))||null),u},prepareVerification:async n=>{var u;const i=new URL("/auth/prepare-verification",window.location.origin);i.searchParams.set("attempt_identifier",((u=r==null?void 0:r.id)==null?void 0:u.toString())||""),i.searchParams.set("strategy",n.strategy),i.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?i.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&i.searchParams.set("redirect_uri",n.redirectUri);const s=await t(i.pathname+i.search,{method:"POST"});return G(s)},completeVerification:async n=>{var f,c;const i=new FormData;i.append("verification_code",n);const s=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:i}),u=await G(s);return"data"in u&&((c=(f=u.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(u.data.signup_attempts.at(-1)||null),u},validateDeploymentInvitation:async n=>{try{const i=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),s=await G(i);return"data"in s&&s.data?s.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(i){return{valid:!1,message:i.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function hc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:Jd(t,o,n)}}const Ge=()=>{const{adapter:t,deployment:r}=me(),o=t.useNavigate(),n=(c,h)=>{o?o(c,h):window.location.href=c},i=c=>{if(c)return c;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const h=i(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const h=i(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const h=i(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function eu(t){const r=await t("/session",{method:"GET"});return(await G(r)).data}async function tu(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return G(o)}async function ru(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return G(n)}async function ou(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return G(o)}async function nu(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return G(o)}const ns=new Map,Lr=new Map;function Et(){ns.clear(),Lr.clear()}async function su(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return G(o)}function Be(){const{client:t,loading:r}=Fe(),{deployment:o}=me(),{navigate:n}=Ge(),{cache:i}=cc(),{data:s,error:u,mutate:f,isLoading:c}=Ne(r?null:"/session",()=>eu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=a.useCallback(async()=>{await f(void 0,{revalidate:!0})},[f]),l=a.useCallback(async(p="default")=>{if(!s)throw new Error("no session");const g=ns.get(p);if(g&&g.expires>Date.now())return(g==null?void 0:g.token)||"";Lr.get(p)||Lr.set(p,su(t,p));const x=await Lr.get(p);return Lr.delete(p),ns.set(p,x.data),x.data.token},[t,s==null?void 0:s.active_signin]);return r||!s||c?{loading:!0,error:u,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:h}:{loading:c,error:u,session:s,switchSignIn:async p=>{await tu(t,p),await f(void 0,{revalidate:!0})},signOut:async p=>{await ru(t,p);const g=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],x=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(i instanceof Map){const m=Array.from(i.keys());for(const y of m){let $=!1;(g.includes(y)||typeof y=="string"&&x.some(S=>y.startsWith(S)))&&($=!0),$&&i.delete(y)}}Et(),await f(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(p&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!p&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async p=>{await ou(t,p),Et(),await f(void 0,{revalidate:!0})},switchWorkspace:async p=>{await nu(t,p),Et(),await f(void 0,{revalidate:!0})},getToken:l,refetch:h}}const Zo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=yt(),{client:n}=Fe(),{refetch:i}=Be(),s=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/roles`,{method:"GET"}))).data,[n]),u=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/members`,{method:"GET"}))).data,[n]),f=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/invitations`,{method:"GET"}))).data,[n]),c=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/domains`,{method:"GET"}))).data,[n]),h=a.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/members/${O.id}/remove`,{method:"POST"}),await r()},[r,n]),l=a.useCallback(async F=>{const O=new FormData;O.append("name",F.name),F.image&&O.append("image",F.image),F.description&&O.append("description",F.description);const A=await G(await n("/organizations",{method:"POST",body:O}));return Et(),await r(),await i(),A},[i,r,n]),p=a.useCallback(async(F,O)=>{const A=Object.entries(O).reduce((ee,[W,K])=>(K&&ee.append(W,K),ee),new FormData),Q=await G(await n(`/organizations/${F.id}/update`,{method:"POST",body:A}));return await r(),Q},[r,n]),g=a.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/roles/${O.id}/remove`,{method:"POST"})},[n]),x=a.useCallback(async(F,O)=>{const A=new FormData;return A.append("domain",O.fqdn),await G(await n(`/organizations/${F.id}/domains`,{method:"POST",body:A}))},[n]),m=a.useCallback(async(F,O)=>await G(await n(`/organizations/${F.id}/domains/${O.id}/verify`,{method:"POST"})),[n]),y=a.useCallback(async(F,O)=>await G(await n(`/organizations/${F.id}/domains/${O.id}/delete`,{method:"POST"})),[n]),$=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/enterprise-connections`,{method:"GET"}))).data,[n]),S=a.useCallback(async(F,O)=>{const A=new FormData;return A.append("protocol",O.protocol),O.domain_id&&A.append("domain_id",O.domain_id),O.idp_entity_id&&A.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&A.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&A.append("idp_certificate",O.idp_certificate),O.oidc_client_id&&A.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&A.append("oidc_client_secret",O.oidc_client_secret),O.oidc_issuer_url&&A.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_scopes&&A.append("oidc_scopes",O.oidc_scopes),O.jit_enabled!==void 0&&A.append("jit_enabled",String(O.jit_enabled)),O.attribute_mapping&&A.append("attribute_mapping",JSON.stringify(O.attribute_mapping)),(await G(await n(`/organizations/${F.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),b=a.useCallback(async(F,O,A)=>{const Q=new FormData;return A.domain_id&&Q.append("domain_id",A.domain_id),A.idp_entity_id&&Q.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&Q.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&Q.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&Q.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&Q.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&Q.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&Q.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&Q.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/update`,{method:"POST",body:Q}))).data},[n]),z=a.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/enterprise-connections/${O}/delete`,{method:"POST"})},[n]),j=a.useCallback(async(F,O)=>{const A=new FormData;return A.append("protocol",O.protocol),O.idp_entity_id&&A.append("idp_entity_id",O.idp_entity_id),O.idp_sso_url&&A.append("idp_sso_url",O.idp_sso_url),O.idp_certificate&&A.append("idp_certificate",O.idp_certificate),O.oidc_issuer_url&&A.append("oidc_issuer_url",O.oidc_issuer_url),O.oidc_client_id&&A.append("oidc_client_id",O.oidc_client_id),O.oidc_client_secret&&A.append("oidc_client_secret",O.oidc_client_secret),(await G(await n(`/organizations/${F.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),k=a.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/test`,{method:"POST"}))).data,[n]),_=a.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/scim/token`,{method:"POST"}))).data,[n]),v=a.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${O}/scim/token`,{method:"GET"}))).data,[n]),P=a.useCallback(async(F,O)=>{await n(`/organizations/${F.id}/enterprise-connections/${O}/scim/token/revoke`,{method:"POST"})},[n]),C=a.useCallback(async(F,O)=>{const A=new FormData;return A.append("name",O.name),O.permissions&&O.permissions.forEach((ee,W)=>{A.append(`permissions[${W}]`,ee)}),await G(await n(`/organizations/${F.id}/roles`,{method:"POST",body:A}))},[n]),E=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/leave`,{method:"POST"}))).data,[n]),T=a.useCallback(async F=>{const O=await G(await n(`/organizations/${F.id}/delete`,{method:"POST"}));return Et(),await r(),await i(),O.data},[n,r,i]),R=a.useCallback(async(F,O,A)=>(await G(await n(`/organizations/${F.id}/members/${O.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),w=a.useCallback(async(F,O,A)=>(await G(await n(`/organizations/${F.id}/members/${O.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),I=a.useCallback(async(F,O)=>{var ee,W;const A=new FormData;return A.append("email",O.email),A.append("role_id",O.organizationRole.id),(ee=O.workspace)!=null&&ee.id&&A.append("workspace_id",O.workspace.id),(W=O.workspaceRole)!=null&&W.id&&A.append("workspace_role_id",O.workspaceRole.id),(await G(await n(`/organizations/${F.id}/invitations`,{method:"POST",body:A}))).data},[n]),M=a.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/invitations/${O.id}/remove`,{method:"POST"}))).data,[n]),L=a.useCallback(async(F,O)=>(await G(await n(`/organizations/${F.id}/invitations/${O.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:a.useMemo(()=>t==null?void 0:t.map(F=>F.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:E,getOrganizationRoles:s,getOrganizationMembers:u,removeOrganizationMember:h,createOrganization:l,getOrganizationInvitations:f,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:m,removeOrganizationDomain:y,addRoleToOrganizationMember:R,removeRoleFromOrganizationMember:w,inviteOrganizationMember:I,discardOrganizationInvitation:M,resendOrganizationInvitation:L,updateOrganization:p,addRole:C,removeOrganizationRoles:g,deleteOrganization:T,getEnterpriseConnections:$,createEnterpriseConnection:S,updateEnterpriseConnection:b,deleteEnterpriseConnection:z,testEnterpriseConnectionConfig:j,testEnterpriseConnection:k,generateSCIMToken:_,getSCIMToken:v,revokeSCIMToken:P}},Ye=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:i,leaveOrganization:s,removeOrganizationMember:u,getOrganizationInvitations:f,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:l,verifyOrganizationDomain:p,addRoleToOrganizationMember:g,removeRoleFromOrganizationMember:x,inviteOrganizationMember:m,discardOrganizationInvitation:y,resendOrganizationInvitation:$,updateOrganization:S,removeOrganizationRoles:b,getEnterpriseConnections:z,createEnterpriseConnection:j,updateEnterpriseConnection:k,deleteEnterpriseConnection:_,testEnterpriseConnectionConfig:v,testEnterpriseConnection:P,generateSCIMToken:C,getSCIMToken:E,revokeSCIMToken:T}=Zo(),{session:R,error:w,loading:I}=Be(),{organizationMemberships:M}=yt(),L=a.useMemo(()=>{var D;return((D=M==null?void 0:M.find(N=>{var re;return N.id===((re=R==null?void 0:R.active_signin)==null?void 0:re.active_organization_membership_id)}))==null?void 0:D.organization)||null},[M,R]),U=a.useCallback(async D=>L?await S(L,D):[],[L,S]),F=a.useCallback(async()=>L?await n(L):[],[L,n]),O=a.useCallback(async()=>L?await i(L):[],[L,i]),A=a.useCallback(async D=>L?await u(L,D):[],[L,u]),Q=a.useCallback(async D=>L?await b(L,D):void 0,[L,b]),ee=a.useCallback(async()=>L?await c(L):[],[L,c]),W=a.useCallback(async D=>L?await l(L,D):void 0,[L,l]),K=a.useCallback(async D=>L?await p(L,D):void 0,[L,p]),oe=a.useCallback(async D=>L?await h(L,D):void 0,[L,h]),te=a.useCallback(async(D,N)=>L?await g(L,D,N):void 0,[L,g]),de=a.useCallback(async(D,N)=>L?await x(L,D,N):void 0,[L,x]),ne=a.useCallback(async D=>L?await m(L,D):void 0,[L,m]),ue=a.useCallback(async D=>L?await y(L,D):void 0,[L,y]),X=a.useCallback(async D=>L?await $(L,D):void 0,[L,$]),ae=a.useCallback(async()=>{L&&await s(L)},[L,s]),Z=a.useCallback(async()=>L?await f(L):[],[L,f]),q=a.useCallback(async()=>L?await z(L):[],[L,z]),B=a.useCallback(async D=>{if(L)return await j(L,D)},[L,j]),ie=a.useCallback(async(D,N)=>{if(L)return await k(L,D,N)},[L,k]),H=a.useCallback(async D=>{L&&await _(L,D)},[L,_]),se=a.useCallback(async D=>L?await v(L,D):null,[L,v]),we=a.useCallback(async D=>L?await P(L,D):null,[L,P]),xe=a.useCallback(async D=>{if(L)return await C(L,D)},[L,C]),ge=a.useCallback(async D=>{if(L)return await E(L,D)},[L,E]),V=a.useCallback(async D=>{L&&await T(L,D)},[L,T]);return I||t?{activeOrganization:null,loading:!0,error:w||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null,getEnterpriseConnections:null,createEnterpriseConnection:null,updateEnterpriseConnection:null,deleteEnterpriseConnection:null,generateSCIMToken:null,getSCIMToken:null,revokeSCIMToken:null}:{activeOrganization:L,loading:!1,refetch:o,getRoles:O,updateOrganization:U,getMembers:F,getDomains:ee,addDomain:W,verifyDomain:K,removeDomain:oe,getInvitations:Z,removeMember:A,leave:ae,removeRole:Q,addMemberRole:te,removeMemberRole:de,inviteMember:ne,discardInvitation:ue,resendInvitation:X,getEnterpriseConnections:q,createEnterpriseConnection:B,updateEnterpriseConnection:ie,deleteEnterpriseConnection:H,testEnterpriseConnectionConfig:se,testEnterpriseConnection:we,generateSCIMToken:xe,getSCIMToken:ge,revokeSCIMToken:V,error:null}};async function iu(t){return(await G(await t("/me/organization-memberships"))).data}const yt=()=>{const{client:t,loading:r}=Fe(),{data:o,isLoading:n,error:i,mutate:s}=Ne(r?null:"/me/organization-memberships",()=>iu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),u=a.useCallback(async()=>{await s(void 0,{revalidate:!0})},[s]);return{organizationMemberships:o,loading:r||n,error:i,refetch:u}};async function au(t){return(await G(await t("/me/workspace-memberships"))).data}async function cu(t,r,o){return(await G(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Qo=()=>{const{client:t,loading:r}=Fe(),{deployment:o}=me(),{data:n,isLoading:i,error:s,mutate:u}=Ne(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>au(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=a.useCallback(async()=>{await u(void 0,{revalidate:!0})},[u]);return{workspaceMemberships:n,loading:r||i,error:s,refetch:f}},wt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Qo(),{client:i}=Fe(),s=a.useMemo(()=>t==null?void 0:t.map(b=>({...b.workspace,organization:b.organization,eligibility_restriction:b.eligibility_restriction})),[t]),u=a.useCallback(async(b,z,j,k)=>{const _=new FormData;_.append("name",z),j&&_.append("image",j),k&&_.append("description",k),_.append("organization_id",b);const v=await G(await i("/workspaces",{method:"POST",body:_}));return Et(),await r(),v.data},[i,r]),f=a.useCallback(async(b,z)=>{const j=await cu(i,b,z);return await r(),j},[i,r]),c=a.useCallback(async(b,z)=>{const j=new FormData;z.name&&j.append("name",z.name),z.description&&j.append("description",z.description),z.image&&j.append("image",z.image),z.enforce_2fa!==void 0&&j.append("enforce_2fa",String(z.enforce_2fa)),z.enable_ip_restriction!==void 0&&j.append("enable_ip_restriction",String(z.enable_ip_restriction)),z.whitelisted_ips&&z.whitelisted_ips.forEach(_=>j.append("whitelisted_ips",_));const k=await G(await i(`/workspaces/${b.id}/update`,{method:"POST",body:j}));return await r(),k.data},[i,r]),h=a.useCallback(async b=>{const z=await G(await i(`/workspaces/${b.id}/delete`,{method:"POST"}));return Et(),await r(),z.data},[i,r]),l=a.useCallback(async b=>(await G(await i(`/workspaces/${b.id}/members`,{method:"GET"}))).data,[i]),p=a.useCallback(async b=>(await G(await i(`/workspaces/${b.id}/roles`,{method:"GET"}))).data,[i]),g=a.useCallback(async(b,z,j)=>(await G(await i(`/workspaces/${b.id}/roles`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z,permissions:j})}))).data,[i]),x=a.useCallback(async(b,z)=>(await G(await i(`/workspaces/${b.id}/roles/${z.id}/delete`,{method:"POST"}))).data,[i]),m=a.useCallback(async(b,z,j)=>(await G(await i(`/workspaces/${b.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:z,role_id:j})}))).data,[i]),y=a.useCallback(async(b,z)=>{const j=await G(await i(`/workspaces/${b.id}/members/${z}/remove`,{method:"POST"}));return await r(),j.data},[i,r]),$=a.useCallback(async(b,z,j)=>(await G(await i(`/workspaces/${b.id}/members/${z}/roles/${j}/add`,{method:"POST"}))).data,[i]),S=a.useCallback(async(b,z,j)=>(await G(await i(`/workspaces/${b.id}/members/${z}/roles/${j}/remove`,{method:"POST"}))).data,[i]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:f,createWorkspace:u,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:l,getWorkspaceRoles:p,createWorkspaceRole:g,deleteWorkspaceRole:x,inviteWorkspaceMember:m,removeWorkspaceMember:y,addWorkspaceMemberRole:$,removeWorkspaceMemberRole:S}},Rt=()=>{const{refetch:t,loading:r,error:o,leaveWorkspace:n,updateWorkspace:i,deleteWorkspace:s,getWorkspaceMembers:u,getWorkspaceRoles:f,createWorkspaceRole:c,deleteWorkspaceRole:h,inviteWorkspaceMember:l,removeWorkspaceMember:p,addWorkspaceMemberRole:g,removeWorkspaceMemberRole:x}=wt(),{workspaceMemberships:m}=Qo(),{session:y,loading:$,error:S}=Be(),b=a.useMemo(()=>{var L;return((L=m==null?void 0:m.find(U=>{var F;return U.id===((F=y==null?void 0:y.active_signin)==null?void 0:F.active_workspace_membership_id)}))==null?void 0:L.workspace)||null},[m,y]),z=a.useCallback(async()=>{var L;if(!(!b||!((L=y==null?void 0:y.active_signin)!=null&&L.user_id)))return await n(b.id,y.active_signin.user_id)},[b,n,y]),j=a.useCallback(async L=>{if(b)return await i(b,L)},[b,i]),k=a.useCallback(async()=>{if(b)return await s(b)},[b,s]),_=a.useCallback(async()=>b?await u(b):[],[b,u]),v=a.useCallback(async()=>b?await f(b):[],[b,f]),P=a.useCallback(async(L,U)=>{if(b)return await c(b,L,U)},[b,c]),C=a.useCallback(async L=>{if(b)return await h(b,L)},[b,h]),E=a.useCallback(async(L,U)=>{if(b)return await l(b,L,U)},[b,l]),T=a.useCallback(async L=>{if(b)return await p(b,L)},[b,p]),R=a.useCallback(async(L,U)=>{if(b)return await g(b,L,U)},[b,g]),w=a.useCallback(async(L,U)=>{if(b)return await x(b,L,U)},[b,x]),I=r||$,M=o||S;return I?{activeWorkspace:null,loading:!0,error:M,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null}:{activeWorkspace:b,loading:!1,error:M,refetch:t,leave:z,updateWorkspace:j,deleteWorkspace:k,getMembers:_,getRoles:v,createRole:P,deleteRole:C,inviteMember:E,removeMember:T,addMemberRole:R,removeMemberRole:w}},lu=async t=>(await G(await t("/me"))).data,du=async t=>(await G(await t("/me/signins"))).data;function sr(){const{client:t,loading:r}=Fe(),{data:o,error:n,isLoading:i,mutate:s}=Ne(r?null:"/user",()=>lu(t)),u=async I=>{const M=new FormData;for(const[U,F]of Object.entries(I))F!=null&&F!==""&&M.append(U,String(F));const L=await G(await t("/me",{method:"POST",body:M}));return s(),L},f=async()=>await G(await t("/me/email-addresses",{method:"GET"})),c=async I=>await G(await t(`/me/email-addresses/${I}`,{method:"GET"})),h=async I=>{const M=new FormData;return M.append("email",I),await G(await t("/me/email-addresses",{method:"POST",body:M}))},l=async I=>await G(await t(`/me/email-addresses/${I}/delete`,{method:"POST"})),p=async I=>await G(await t(`/me/email-addresses/${I}/prepare-verification`,{method:"POST"})),g=async(I,M)=>await G(await t(`/me/email-addresses/${I}/attempt-verification?code=${M}`,{method:"POST"})),x=async(I,M)=>{const L=new FormData;return L.append("phone_number",I),L.append("country_code",M),await G(await t("/me/phone-numbers",{method:"POST",body:L}))},m=async I=>await G(await t(`/me/phone-numbers/${I}/delete`,{method:"POST"})),y=async I=>await G(await t(`/me/phone-numbers/${I}/prepare-verification`,{method:"POST"})),$=async(I,M)=>{const L=new FormData;return L.append("code",M),await G(await t(`/me/phone-numbers/${I}/attempt-verification`,{method:"POST",body:L}))},S=async I=>{const M=await G(await t(`/me/phone-numbers/${I}/make-primary`,{method:"POST"}));return s(),M},b=async I=>await G(await t(`/me/email-addresses/${I}/make-primary`,{method:"POST"})),z=async()=>(await G(await t("/me/authenticator",{method:"POST"}))).data,j=async(I,M)=>{const L=new FormData;return L.append("authenticator_id",I),M.forEach(F=>{L.append("codes",F)}),await G(await t("/me/authenticator/attempt-verification",{method:"POST",body:L}))},k=async I=>await G(await t(`/me/authenticator/${I}/delete`,{method:"POST"})),_=async()=>(await G(await t("/me/backup-codes",{method:"POST"}))).data,v=async I=>{const M=new FormData;return M.append("file",I),await G(await t("/me/profile-picture",{method:"POST",body:M}))},P=async()=>(await G(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,C=async(I,M)=>{const L=new FormData;return L.append("current_password",I),L.append("new_password",M),await G(await t("/me/update-password",{method:"POST",body:L}))},E=async I=>{const M=new FormData;M.append("current_password",I);const L=await G(await t("/me/remove-password",{method:"POST",body:M}));return s(),L},T=async I=>{const M=new FormData;return M.append("password",I),await G(await t("/me/account/delete",{method:"POST",body:M}))},R=async I=>await G(await t(`/me/social-connections/${I}/disconnect`,{method:"POST"})),w=async({provider:I,redirectUri:M})=>{var F;const L=new URLSearchParams({provider:I});M&&L.append("redirect_uri",M);const U=await G(await t(`/me/init-sso-connection?${L.toString()}`,{method:"POST"}));return"data"in U&&((F=U.data)!=null&&F.oauth_url)&&window.open(U.data.oauth_url,"_blank"),U};return{user:{...o,refetch:s},loading:r||i,error:n||null,updateProfile:u,getEmailAddresses:f,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:l,prepareEmailVerification:p,attemptEmailVerification:g,makeEmailPrimary:b,createPhoneNumber:x,deletePhoneNumber:m,preparePhoneVerification:y,attemptPhoneVerification:$,makePhonePrimary:S,setupAuthenticator:z,verifyAuthenticator:j,deleteAuthenticator:k,generateBackupCodes:_,regenerateBackupCodes:P,updateProfilePicture:v,disconnectSocialConnection:R,connectSocialAccount:w,updatePassword:C,removePassword:E,deleteAccount:T}}function fc(){const{client:t,loading:r}=Fe(),{data:o,error:n,isLoading:i,mutate:s}=Ne(r?null:"/me/signins",()=>du(t));return{signins:o,error:n||null,removeSignin:async f=>await G(await t(`/me/signins/${f}/signout`,{method:"POST"})),refetch:s,loading:i||r}}function uu(){const{session:t,loading:r}=Be(),{loading:o,organizationMemberships:n}=yt(),{loading:i,workspaceMemberships:s}=Qo();if(r||o||i)return{loading:!0,orgMembership:null,workspaceMembership:null};const u=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_organization_membership_id)}),[t]),f=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:u,workspaceMembership:f}}function gc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(!1),i=async s=>{n(!0);try{const u=new FormData;for(const[h,l]of Object.entries(s))l&&u.append(h,l);const f=await t("/waitlist/join",{method:"POST",body:u});return await G(f)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:i}}function mc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(!1),[i,s]=a.useState(null),[u,f]=a.useState(null),[c,h]=a.useState(null),[l,p]=a.useState(!1),[g,x]=a.useState(null);a.useEffect(()=>{if(l||r)return;const y=new URLSearchParams(window.location.search),$=y.get("code"),S=y.get("state"),b=y.get("error"),z=y.get("error_description");if(!$&&!b){p(!0);const j=new Error("No OAuth callback data found.");s(j);return}if(p(!0),n(!0),b){const j=z||b,k=new Error(`OAuth Error: ${j}`);s(k),n(!1);return}if($&&S)m($,S);else{const j=new Error("Missing required OAuth parameters");s(j),n(!1)}},[l,r]);const m=async(y,$)=>{try{let S,b;try{const k=$.split(".");if(k.length!==2)throw new Error("Invalid OAuth state format - missing signature");const _=k[0].replace(/-/g,"+").replace(/_/g,"/"),v=_.length%4?"=".repeat(4-_.length%4):"",C=atob(_+v).split("|")[0];if(C==="sign_in")S="/auth/oauth2/callback",b="GET";else if(C==="connect_social")S="/me/sso-connection-callback",b="POST";else throw new Error(`Unknown OAuth action: ${C}`)}catch(k){const _=k instanceof Error?k: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(`${S}?code=${encodeURIComponent(y)}&state=${encodeURIComponent($)}`,{method:b}),j=await G(z);if("data"in j){const k=j.data.session,_=j.data.redirect_uri||null;if(f(k),h(_),k.signin_attempts&&k.signin_attempts.length>0){const v=k.signin_attempts.at(-1);v&&x(v)}}else{const k=new Error("SSO callback failed");s(k)}}catch(S){const b=S instanceof Error?S:new Error("Unknown error occurred");s(b)}finally{n(!1)}};return{loading:o,error:i,session:u,redirectUri:c,processed:l,signinAttempt:g}}function xc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(!1),[i,s]=a.useState(null);return{loading:r||o,verifyMagicLink:async f=>{if(!f.token||!f.attempt)throw new Error("Invalid magic link parameters");n(!0),s(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",f.token),c.searchParams.set("attempt",f.attempt),f.redirectUri&&c.searchParams.set("redirect_uri",f.redirectUri);const h=await t(c.pathname+c.search,{method:"GET"}),l=await G(h);return n(!1),s(!0),l}catch(c){throw n(!1),s(!1),c}},success:i}}function vc(){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 bc(){const{client:t,loading:r}=Fe();return{loading:r,forgotPassword:async s=>{const u=new FormData;u.append("email",s);const f=await t("/auth/forgot-password",{method:"POST",body:u});return await G(f)},verifyOtp:async(s,u)=>{const f=new FormData;f.append("email",s),f.append("otp",u);const c=await t("/auth/forgot-password",{method:"POST",body:f});return await G(c)},resetPassword:async(s,u)=>{const f=new FormData;f.append("token",s),f.append("password",u);const c=await t("/auth/reset-password",{method:"POST",body:f});return await G(c)}}}function yc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:i,onError:s,reconnectDelay:u=1e3,maxReconnectAttempts:f=5}={}){const{session:c,loading:h}=Be(),{deployment:l,loading:p}=me(),[g,x]=a.useState(!1),[m,y]=a.useState(null),$=a.useRef(null),S=a.useRef(null),b=a.useRef(0),z=a.useRef(null),j=a.useRef(i),k=a.useRef(s),_=a.useRef(r),v=a.useRef(o),P=a.useRef(n),C=a.useRef(u),E=a.useRef(f);j.current=i,k.current=s,_.current=r,v.current=o,P.current=n,C.current=u,E.current=f;const T=a.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null),z.current&&(clearInterval(z.current),z.current=null),$.current&&($.current.close(),$.current=null)},[]),R=a.useCallback(async()=>{var F;if(!t||h||p||!c||!l)return;T();const M=new URL(l.backend_host),L=M.protocol==="https:"?"wss:":"ws:",U=new URL("/realtime/notifications",`${L}//${M.host}`);if(l.mode==="staging"){const O=localStorage.getItem("__dev_session__");O&&U.searchParams.set("__dev_session__",O)}_.current&&_.current.length>0&&_.current.forEach(O=>U.searchParams.append("channels",O)),v.current&&v.current.length>0&&v.current.forEach(O=>U.searchParams.append("organization_ids",O.toString())),P.current&&P.current.length>0&&P.current.forEach(O=>U.searchParams.append("workspace_ids",O.toString()));try{const O=new WebSocket(U.toString());$.current=O,O.onopen=()=>{x(!0),y(null),b.current=0,z.current=setInterval(()=>{O.readyState===WebSocket.OPEN&&O.send("ping")},3e4)},O.onmessage=A=>{var Q,ee;try{const W=JSON.parse(A.data);if(W.type==="notification"&&W.data)(Q=j.current)==null||Q.call(j,W.data);else if(W.type==="error"){const K=W.error||"Unknown error occurred";y(K),(ee=k.current)==null||ee.call(k,K)}else W.type}catch{}},O.onerror=()=>{var A;y("Connection error occurred"),(A=k.current)==null||A.call(k,"Connection error occurred")},O.onclose=A=>{var Q;if(x(!1),z.current&&(clearInterval(z.current),z.current=null),t&&A.code!==1e3&&b.current<E.current){b.current++;const ee=C.current*Math.pow(2,b.current-1);S.current=setTimeout(()=>{R()},ee)}else b.current>=E.current&&(y("Max reconnection attempts reached"),(Q=k.current)==null||Q.call(k,"Max reconnection attempts reached"))}}catch{y("Failed to connect"),(F=k.current)==null||F.call(k,"Failed to connect")}},[t,h,p,c,l,T]);a.useEffect(()=>(R(),()=>{T()}),[R,T]),a.useEffect(()=>{$.current&&$.current.readyState===WebSocket.OPEN&&R()},[r,o,n,R]);const w=a.useCallback(()=>{T(),x(!1)},[T]),I=a.useCallback(()=>{b.current=0,R()},[R]);return{isConnected:g,connectionError:m,disconnect:w,reconnect:I}}async function pu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(u=>o.append("channels",u)),r.organization_ids&&r.organization_ids.forEach(u=>o.append("organization_ids",u.toString())),r.workspace_ids&&r.workspace_ids.forEach(u=>o.append("workspace_ids",u.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,i=await t(n,{method:"GET"});return(await G(i)).data}async function hu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}async function fu(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return G(o)}async function gu(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return G(r)}async function mu(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return G(o)}function wc(t){const{client:r,loading:o}=Fe(),{data:n,error:i,mutate:s,isLoading:u}=Ne(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>pu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});yc({enabled:!o&&!!n,onNotification:a.useCallback(p=>{s(async g=>!g||g.notifications.some(m=>m.id===p.id.toString())?g:{...g,notifications:[{id:p.id.toString(),user_id:p.user_id.toString(),deployment_id:p.deployment_id.toString(),title:p.title,body:p.body,severity:p.severity,action_url:p.action_url,action_label:p.action_label,is_read:!1,is_archived:!1,created_at:p.created_at,updated_at:p.created_at},...g.notifications],unread_count:g.unread_count+1,total:g.total+1},!1)},[s]),onError:a.useCallback(()=>{},[])});const f=a.useCallback(async p=>{o||(await s(async g=>g&&{...g,notifications:g.notifications.map(x=>x.id===p?{...x,is_read:!0}:x),unread_count:Math.max(0,g.unread_count-1)},!1),await fu(r,p),await s())},[r,o,s]),c=a.useCallback(async()=>{o||(await s(async p=>p&&{...p,notifications:p.notifications.map(g=>({...g,is_read:!0})),unread_count:0},!1),await gu(r),await s())},[r,s]),h=a.useCallback(async p=>{o||(await s(async g=>{if(!g)return g;const x=g.notifications.find(m=>m.id===p);return{...g,notifications:g.notifications.filter(m=>m.id!==p),unread_count:x&&!x.is_read?Math.max(0,g.unread_count-1):g.unread_count,total:Math.max(0,g.total-1)}},!1),await mu(r,p),await s())},[r,o,s]),l=a.useCallback(async()=>{await s()},[s]);return!n||o||u?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:i,refetch:l}:{loading:!1,error:i,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:f,markAllAsRead:c,deleteNotification:h,refetch:l}}async function xu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}function vu(){const{client:t,loading:r}=Fe(),{data:o,error:n,mutate:i}=Ne(r?null:"wacht-notifications:channel-counts",()=>xu(t),{refreshInterval:3e4,revalidateOnFocus:!0}),s=async()=>{await i()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:s}:{loading:!1,counts:o,error:n,refetch:s}}const Yt=class Yt{constructor(){tt(this,"ws",null);tt(this,"messageHandlers",new Set);tt(this,"connectionStateHandlers",new Set);tt(this,"reconnectTimer",null);tt(this,"reconnectAttempts",0);tt(this,"url",null);tt(this,"isIntentionalDisconnect",!1);tt(this,"sessionMessages",{});tt(this,"currentSessionKey",null)}static getInstance(){return Yt.instance||(Yt.instance=new Yt),Yt.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};tt(Yt,"instance");let ss=Yt;const Ke=ss.getInstance(),xt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Ae={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Ot={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Gs(t){switch(t){case Ot.IDLE:return Ae.IDLE;case Ot.STARTING:return Ae.STARTING;case Ot.RUNNING:return Ae.RUNNING;case Ot.WAITING_FOR_INPUT:return Ae.WAITING_FOR_INPUT;case Ot.COMPLETED:return Ae.COMPLETED;case Ot.FAILED:case Ot.CANCELLED:return Ae.FAILED;default:return Ae.IDLE}}function Hs(t){return t===Ae.STARTING||t===Ae.RUNNING||t===Ae.WAITING_FOR_INPUT}function jc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:i=!0}){const{deployment:s}=me(),{client:u}=Fe(),[f,c]=a.useState([]),[h,l]=a.useState(null),[p,g]=a.useState(null),[x,m]=a.useState(!1),[y,$]=a.useState(!1),[S,b]=a.useState(Ae.IDLE),[z,j]=a.useState({status:xt.DISCONNECTED}),[k,_]=a.useState(!0),[v,P]=a.useState(!1),C=a.useRef(null),E=a.useRef(null),T=a.useCallback(W=>{var K,oe;switch(W.message_type){case"session_connected":if(m(!0),j({status:xt.CONNECTED}),(K=W.data)!=null&&K.execution_status){const de=W.data.execution_status,ne=Gs(de);b(ne),$(Hs(ne))}break;case"conversation_message":R(W.data);break;case"user_input_request":w(W.data);break;case"platform_event":I(W.data);break;case"platform_function":M(W.data);break;case"execution_complete":$(!1),b(Ae.IDLE),E.current=null;break;case"execution_error":$(!1),b(Ae.FAILED),E.current=null;break;case"execution_cancelled":$(!1),b(Ae.IDLE),E.current=null;break;case"execution_status":const te=(oe=W.data)==null?void 0:oe.status;if(te){const de=Gs(te);b(de),$(Hs(de))}break}},[h]),R=a.useCallback(W=>{var ne,ue,X,ae,Z,q,B,ie;const{id:K,message_type:oe,content:te}=W,de=H=>f.some(se=>se.id===H);if(oe==="system_decision"||oe==="action_execution_result"||oe==="assistant_task_breakdown"||oe==="assistant_validation"||oe==="assistant_action_planning"||oe==="context_results"){l(null),g(null);let H="";if(oe==="system_decision"){const se=te==null?void 0:te.step,we=te==null?void 0:te.reasoning;if(se==="gathercontext")we&&we.length>0?H=we.length>60?`${we.substring(0,60)}...`:we:H="Gathering context...";else if(se==="executeaction")H="Executing action";else if(se==="deliverresponse")H="Preparing response";else if(se==="taskplanning")H="Planning approach";else if(se==="validateprogress")H="Validating progress";else if(se==="acknowledge")H="Processing request";else if(se==="finishplanning")H="Finalizing plan";else if(se==="executetasks")H="Executing tasks";else if(se==="requestuserinput")H="Waiting for input";else if(se==="complete")H="Completed";else if(se==="examinetool")H="Examining tool";else if(se==="examineworkflow")H="Examining workflow";else{const xe=(te==null?void 0:te.confidence)||.5;xe>.8?H="Analyzing":xe>.6?H="Thinking":H="Reasoning"}}else if(oe==="action_execution_result")((ne=te.task_execution)==null?void 0:ne.status)==="completed"?H="Task execution completed":(ue=te.task_execution)!=null&&ue.approach?H=te.task_execution.approach:H="Executing task";else if(oe==="assistant_task_breakdown")(X=te.task_breakdown)!=null&&X.total_tasks?H=`Identified ${te.task_breakdown.total_tasks} tasks`:H="Planning tasks";else if(oe==="assistant_validation")H="Validated results";else if(oe==="assistant_action_planning")(ae=te.task_execution)!=null&&ae.total_tasks?H=`Planned ${te.task_execution.total_tasks} tasks`:(q=(Z=te.task_execution)==null?void 0:Z.tasks)!=null&&q.length?H=`Planned ${te.task_execution.tasks.length} tasks`:H="Planning actions";else if(oe==="context_results"){const se=te.query,we=te.result_count||0;se&&se!=="General context gathering"?H=`${se}: Found ${we} results`:H=`Found ${we} results`}H&&!de(K)&&c(se=>[...se,{id:K,role:"system",content:H,timestamp:new Date,metadata:{type:"log",messageType:oe}}]);return}if(oe==="user_message")de(K)||(l(null),g(null),c(H=>[...H,{id:K,role:"user",content:te.message,images:te.images,timestamp:new Date}]));else if(oe==="agent_response")de(K)||(l(null),g(null),$(!1),b(Ae.IDLE),E.current=null,c(H=>[...H,{id:K,role:"assistant",content:te.response,timestamp:new Date,isStreaming:!1}]));else if(oe==="assistant_acknowledgment")de(K)||(l(null),g(null),c(H=>[...H,{id:K,role:"assistant",content:te.acknowledgment_message,timestamp:new Date}]));else if(oe==="assistant_ideation"||oe==="assistant_action_planning"||oe==="action_execution_result"||oe==="assistant_validation"||oe==="assistant_context_gathering"||oe==="assistant_task_breakdown"){let H="";if(te.reasoning_summary)H=te.reasoning_summary;else if((B=te.task_execution)!=null&&B.approach)H=te.task_execution.approach;else if(te.strategic_synthesis)H=te.strategic_synthesis;else if((ie=te.task_breakdown)!=null&&ie.total_tasks)H=`Breaking down into ${te.task_breakdown.total_tasks} tasks...`;else if(te.acknowledgment_message)H=te.acknowledgment_message;else return;c(se=>[...se,{id:K,role:"assistant",content:H,timestamp:new Date}])}else if(oe==="user_input_request"){const H={question:te.question,context:te.context,input_type:te.input_type,options:te.options||te.suggestions,default_value:te.default_value,placeholder:te.placeholder};b("waiting_for_input"),c(se=>[...se,{id:K,role:"system",content:H.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:H}}])}},[]),w=a.useCallback(async W=>{b("waiting_for_input");const K=`input-request-${Date.now()}`;c(oe=>[...oe,{id:K,role:"system",content:W.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:W}}])},[]),I=a.useCallback(W=>{const{event_label:K,event_data:oe}=W;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(K,oe)},[n]),M=a.useCallback(async W=>{const{function_name:K,function_data:oe}=W,{parameters:te,execution_id:de}=oe;if(!(n!=null&&n.onPlatformFunction)){Ke.send({message_type:{platform_function_result:[de,{error:"No platform function handler registered"}]},data:{}});return}try{const ne=await n.onPlatformFunction(K,te,de),ue={message_type:{platform_function_result:[de,ne]},data:{}};Ke.send(ue)}catch(ne){Ke.send({message_type:{platform_function_result:[de,{error:ne instanceof Error?ne.message:"Function execution failed",stack:ne instanceof Error?ne.stack:void 0}]},data:{}})}},[n]);a.useEffect(()=>{if(!s)return;const K=`wss://${s==null?void 0:s.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;j({status:xt.CONNECTING}),Ke.connect(K)},[s,o]),a.useEffect(()=>Ke.onConnectionStateChange(K=>{j({status:K.isConnected?xt.CONNECTED:K.error?xt.ERROR:xt.DISCONNECTED}),m(K.isConnected)}),[]),a.useEffect(()=>Ke.onMessage(T),[T]),a.useEffect(()=>{x&&t&&r&&i&&Ke.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,i]);const L=a.useCallback(async()=>(x&&t&&r&&Ke.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),U=a.useCallback((W,K)=>{x&&(l(W),g(K||null),$(!0),b(Ae.STARTING),Ke.send({message_type:{message_input:W},data:K?{images:K}:{}}))},[x]),F=a.useCallback(()=>{c([]),E.current=null},[]),O=a.useCallback(W=>{!x||S!==Ae.WAITING_FOR_INPUT||(Ke.send({message_type:{user_input_response:W},data:{}}),b(Ae.RUNNING))},[x,S]),A=a.useCallback(async W=>{var K;if(!(!o||!t))try{const oe=new URLSearchParams({token:o,limit:"50"});W&&(oe.append("before_id",W),P(!0));const de=await(await u(`/api/agent/contexts/${t}/messages?${oe}`,{method:"GET"})).json();if(de.status===200&&de.data){const ne=de.data;if(Array.isArray(ne.data)){const ue=ne.data.filter(X=>{var q;let ae=X.content;if(typeof X.content=="string")try{ae=JSON.parse(X.content)}catch{ae={message:X.content}}const Z=((q=X.metadata)==null?void 0:q.message_type)||(ae==null?void 0:ae.message_type);return Z==="user_message"||Z==="agent_response"||Z==="assistant_acknowledgment"||Z==="user_input_request"||Z==="system_decision"||Z==="action_execution_result"||Z==="assistant_task_breakdown"||Z==="assistant_validation"||Z==="assistant_action_planning"||Z==="context_results"}).map(X=>{var H,se,we,xe,ge,V,D;let ae="",Z,q,B=X.content;if(typeof X.content=="string")try{B=JSON.parse(X.content)}catch{B=X.content}const ie=((H=X.metadata)==null?void 0:H.message_type)||(B==null?void 0:B.message_type);if(ie==="user_message"?(ae=(B==null?void 0:B.message)||"",Z=(B==null?void 0:B.images)||void 0):ie==="agent_response"?ae=(B==null?void 0:B.response)||"":ie==="assistant_acknowledgment"?ae=(B==null?void 0:B.acknowledgment_message)||"":ie==="user_input_request"&&(ae=(B==null?void 0:B.question)||"",q={type:"user_input_request",userInputRequest:{question:(B==null?void 0:B.question)||"",context:(B==null?void 0:B.context)||"",input_type:(B==null?void 0:B.input_type)||"text",options:(B==null?void 0:B.options)||(B==null?void 0:B.suggestions)||[],default_value:(B==null?void 0:B.default_value)||"",placeholder:(B==null?void 0:B.placeholder)||""}}),ie==="system_decision"||ie==="action_execution_result"||ie==="assistant_task_breakdown"||ie==="assistant_validation"||ie==="assistant_action_planning"||ie==="context_results"){let N="";if(ie==="system_decision"){const re=B==null?void 0:B.step,pe=B==null?void 0:B.reasoning;if(re==="gathercontext")pe&&pe.length>0?N=pe.length>60?`${pe.substring(0,60)}...`:pe:N="Gathering context...";else if(re==="executeaction")N="Executing action";else if(re==="deliverresponse")N="Preparing response";else if(re==="taskplanning")N="Planning approach";else if(re==="validateprogress")N="Validating progress";else if(re==="acknowledge")N="Processing request";else if(re==="finishplanning")N="Finalizing plan";else if(re==="executetasks")N="Executing tasks";else if(re==="requestuserinput")N="Waiting for input";else if(re==="complete")N="Completed";else if(re==="examinetool")N="Examining tool";else if(re==="examineworkflow")N="Examining workflow";else{const J=(B==null?void 0:B.confidence)||.5;J>.8?N="Analyzing":J>.6?N="Thinking":N="Reasoning"}}else if(ie==="action_execution_result")((se=B==null?void 0:B.task_execution)==null?void 0:se.status)==="completed"?N="Task execution completed":(we=B==null?void 0:B.task_execution)!=null&&we.approach?N=B.task_execution.approach:N="Executing task";else if(ie==="assistant_task_breakdown")(xe=B==null?void 0:B.task_breakdown)!=null&&xe.total_tasks?N=`Identified ${B.task_breakdown.total_tasks} tasks`:N="Planning tasks";else if(ie==="assistant_validation")N="Validated results";else if(ie==="assistant_action_planning")(ge=B==null?void 0:B.task_execution)!=null&&ge.total_tasks?N=`Planned ${B.task_execution.total_tasks} tasks`:(D=(V=B==null?void 0:B.task_execution)==null?void 0:V.tasks)!=null&&D.length?N=`Planned ${B.task_execution.tasks.length} tasks`:N="Planning actions";else if(ie==="context_results"){const re=B==null?void 0:B.query,pe=(B==null?void 0:B.result_count)||0;re&&re!=="General context gathering"?N=`${re}: Found ${pe} results`:N=`Found ${pe} results`}ae=N,q={type:"log",messageType:ie}}return{id:X.id,role:ie==="user_message"?"user":ie==="user_input_request"?"system":"assistant",content:ae,images:Z,timestamp:new Date(X.timestamp||X.created_at||Date.now()),metadata:q}}).filter(X=>X.content||X.metadata||X.images).sort((X,ae)=>{const Z=BigInt(X.id),q=BigInt(ae.id);return Z<q?-1:Z>q?1:0});ue.length>0&&(C.current=ue[0].id),W?(c(X=>[...ue,...X]),_(ue.length>=50)):(c(ue),ue.length>0&&((K=ue[ue.length-1].metadata)==null?void 0:K.type)==="user_input_request"&&b(Ae.WAITING_FOR_INPUT)),P(!1)}}}catch(oe){console.error("Failed to fetch messages:",oe),P(!1)}},[o,t,u]);a.useEffect(()=>{t&&o&&A()},[t,o]);const Q=a.useCallback(async()=>{if(!(v||!k||!C.current)){P(!0);try{await A(C.current)}finally{P(!1)}}},[v,k,A]),ee=a.useCallback(()=>{!x||!y||(Ke.send({message_type:{cancel_execution:null},data:{}}),$(!1),b("idle"))},[x,y]);return{messages:f,pendingMessage:h,pendingImages:p,connectionState:z,isConnected:x,isExecuting:y,executionStatus:S,isWaitingForInput:S==="waiting_for_input",hasMoreMessages:k,isLoadingMore:v,sendMessage:U,submitUserInput:O,clearMessages:F,loadMoreMessages:Q,cancelExecution:ee,connect:L,disconnect:()=>Ke.disconnect()}}const _c=()=>{const{client:t}=Fe(),[r,o]=a.useState(!1),[n,i]=a.useState(null),[s,u]=a.useState(null),f=a.useCallback(async h=>{o(!0),i(null),u(null);try{const l=await t("/organizations/invitations/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:h})}),g=(await G(l)).data;return u(g),g.error_code&&i(g.message||"Failed to accept invitation"),g}catch(l){const p=l.message||"Failed to accept invitation";i(p);const g={error_code:"NETWORK_ERROR",message:p};return u(g),g}finally{o(!1)}},[t]),c=a.useCallback(()=>{i(null),u(null)},[]);return{acceptInvitation:f,invitationData:s,loading:r,error:n,reset:c}},bu=({children:t})=>{const{loading:r}=me();return r?null:e.jsx(e.Fragment,{children:t})},yu=({children:t})=>{const{loading:r}=me();return r?e.jsx(e.Fragment,{children:t}):null};var qe=function(){return qe=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},qe.apply(this,arguments)};function tr(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 wu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var ju=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,_u=wu(function(t){return ju.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ie="-ms-",Fr="-moz-",ze="-webkit-",kc="comm",Ko="rule",ws="decl",ku="@import",Cc="@keyframes",Cu="@layer",Sc=Math.abs,js=String.fromCharCode,is=Object.assign;function Su(t,r){return Ue(t,0)^45?(((r<<2^Ue(t,0))<<2^Ue(t,1))<<2^Ue(t,2))<<2^Ue(t,3):0}function zc(t){return t.trim()}function mt(t,r){return(t=r.exec(t))?t[0]:t}function be(t,r,o){return t.replace(r,o)}function Po(t,r,o){return t.indexOf(r,o)}function Ue(t,r){return t.charCodeAt(r)|0}function yr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function $c(t){return t.length}function Ar(t,r){return r.push(t),t}function zu(t,r){return t.map(r).join("")}function qs(t,r){return t.filter(function(o){return!mt(o,r)})}var Xo=1,wr=1,Ec=0,Xe=0,De=0,Sr="";function Jo(t,r,o,n,i,s,u,f){return{value:t,root:r,parent:o,type:n,props:i,children:s,line:Xo,column:wr,length:u,return:"",siblings:f}}function zt(t,r){return is(Jo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function lr(t){for(;t.root;)t=zt(t.root,{children:[t]});Ar(t,t.siblings)}function $u(){return De}function Eu(){return De=Xe>0?Ue(Sr,--Xe):0,wr--,De===10&&(wr=1,Xo--),De}function rt(){return De=Xe<Ec?Ue(Sr,Xe++):0,wr++,De===10&&(wr=1,Xo++),De}function Qt(){return Ue(Sr,Xe)}function Ro(){return Xe}function en(t,r){return yr(Sr,t,r)}function as(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 Iu(t){return Xo=wr=1,Ec=ct(Sr=t),Xe=0,[]}function Pu(t){return Sr="",t}function xn(t){return zc(en(Xe-1,cs(t===91?t+2:t===40?t+1:t)))}function Ru(t){for(;(De=Qt())&&De<33;)rt();return as(t)>2||as(De)>3?"":" "}function Tu(t,r){for(;--r&&rt()&&!(De<48||De>102||De>57&&De<65||De>70&&De<97););return en(t,Ro()+(r<6&&Qt()==32&&rt()==32))}function cs(t){for(;rt();)switch(De){case t:return Xe;case 34:case 39:t!==34&&t!==39&&cs(De);break;case 40:t===41&&cs(t);break;case 92:rt();break}return Xe}function Mu(t,r){for(;rt()&&t+De!==57;)if(t+De===84&&Qt()===47)break;return"/*"+en(r,Xe-1)+"*"+js(t===47?t:rt())}function Ou(t){for(;!as(Qt());)rt();return en(t,Xe)}function Lu(t){return Pu(To("",null,null,null,[""],t=Iu(t),0,[0],t))}function To(t,r,o,n,i,s,u,f,c){for(var h=0,l=0,p=u,g=0,x=0,m=0,y=1,$=1,S=1,b=0,z="",j=i,k=s,_=n,v=z;$;)switch(m=b,b=rt()){case 40:if(m!=108&&Ue(v,p-1)==58){Po(v+=be(xn(b),"&","&\f"),"&\f",Sc(h?f[h-1]:0))!=-1&&(S=-1);break}case 34:case 39:case 91:v+=xn(b);break;case 9:case 10:case 13:case 32:v+=Ru(m);break;case 92:v+=Tu(Ro()-1,7);continue;case 47:switch(Qt()){case 42:case 47:Ar(Au(Mu(rt(),Ro()),r,o,c),c);break;default:v+="/"}break;case 123*y:f[h++]=ct(v)*S;case 125*y:case 59:case 0:switch(b){case 0:case 125:$=0;case 59+l:S==-1&&(v=be(v,/\f/g,"")),x>0&&ct(v)-p&&Ar(x>32?Zs(v+";",n,o,p-1,c):Zs(be(v," ","")+";",n,o,p-2,c),c);break;case 59:v+=";";default:if(Ar(_=Ys(v,r,o,h,l,i,f,z,j=[],k=[],p,s),s),b===123)if(l===0)To(v,r,_,_,j,s,p,f,k);else switch(g===99&&Ue(v,3)===110?100:g){case 100:case 108:case 109:case 115:To(t,_,_,n&&Ar(Ys(t,_,_,0,0,i,f,z,i,j=[],p,k),k),i,k,p,f,n?j:k);break;default:To(v,_,_,_,[""],k,0,f,k)}}h=l=x=0,y=S=1,z=v="",p=u;break;case 58:p=1+ct(v),x=m;default:if(y<1){if(b==123)--y;else if(b==125&&y++==0&&Eu()==125)continue}switch(v+=js(b),b*y){case 38:S=l>0?1:(v+="\f",-1);break;case 44:f[h++]=(ct(v)-1)*S,S=1;break;case 64:Qt()===45&&(v+=xn(rt())),g=Qt(),l=p=ct(z=v+=Ou(Ro())),b++;break;case 45:m===45&&ct(v)==2&&(y=0)}}return s}function Ys(t,r,o,n,i,s,u,f,c,h,l,p){for(var g=i-1,x=i===0?s:[""],m=$c(x),y=0,$=0,S=0;y<n;++y)for(var b=0,z=yr(t,g+1,g=Sc($=u[y])),j=t;b<m;++b)(j=zc($>0?x[b]+" "+z:be(z,/&\f/g,x[b])))&&(c[S++]=j);return Jo(t,r,o,i===0?Ko:f,c,h,l,p)}function Au(t,r,o,n){return Jo(t,r,o,kc,js($u()),yr(t,2,-2),0,n)}function Zs(t,r,o,n,i){return Jo(t,r,o,ws,yr(t,0,n),yr(t,n+1,-1),n,i)}function Ic(t,r,o){switch(Su(t,r)){case 5103:return ze+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return ze+t+t;case 4789:return Fr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return ze+t+Fr+t+Ie+t+t;case 5936:switch(Ue(t,r+11)){case 114:return ze+t+Ie+be(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return ze+t+Ie+be(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return ze+t+Ie+be(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return ze+t+Ie+t+t;case 6165:return ze+t+Ie+"flex-"+t+t;case 5187:return ze+t+be(t,/(\w+).+(:[^]+)/,ze+"box-$1$2"+Ie+"flex-$1$2")+t;case 5443:return ze+t+Ie+"flex-item-"+be(t,/flex-|-self/g,"")+(mt(t,/flex-|baseline/)?"":Ie+"grid-row-"+be(t,/flex-|-self/g,""))+t;case 4675:return ze+t+Ie+"flex-line-pack"+be(t,/align-content|flex-|-self/g,"")+t;case 5548:return ze+t+Ie+be(t,"shrink","negative")+t;case 5292:return ze+t+Ie+be(t,"basis","preferred-size")+t;case 6060:return ze+"box-"+be(t,"-grow","")+ze+t+Ie+be(t,"grow","positive")+t;case 4554:return ze+be(t,/([^-])(transform)/g,"$1"+ze+"$2")+t;case 6187:return be(be(be(t,/(zoom-|grab)/,ze+"$1"),/(image-set)/,ze+"$1"),t,"")+t;case 5495:case 3959:return be(t,/(image-set\([^]*)/,ze+"$1$`$1");case 4968:return be(be(t,/(.+:)(flex-)?(.*)/,ze+"box-pack:$3"+Ie+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+ze+t+t;case 4200:if(!mt(t,/flex-|baseline/))return Ie+"grid-column-align"+yr(t,r)+t;break;case 2592:case 3360:return Ie+be(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,i){return r=i,mt(n.props,/grid-\w+-end/)})?~Po(t+(o=o[r].value),"span",0)?t:Ie+be(t,"-start","")+t+Ie+"grid-row-span:"+(~Po(o,"span",0)?mt(o,/\d+/):+mt(o,/\d+/)-+mt(t,/\d+/))+";":Ie+be(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return mt(n.props,/grid-\w+-start/)})?t:Ie+be(be(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return be(t,/(.+)-inline(.+)/,ze+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ct(t)-1-r>6)switch(Ue(t,r+1)){case 109:if(Ue(t,r+4)!==45)break;case 102:return be(t,/(.+:)(.+)-([^]+)/,"$1"+ze+"$2-$3$1"+Fr+(Ue(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~Po(t,"stretch",0)?Ic(be(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return be(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,i,s,u,f,c,h){return Ie+i+":"+s+h+(u?Ie+i+"-span:"+(f?c:+c-+s)+h:"")+t});case 4949:if(Ue(t,r+6)===121)return be(t,":",":"+ze)+t;break;case 6444:switch(Ue(t,Ue(t,14)===45?18:11)){case 120:return be(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+ze+(Ue(t,14)===45?"inline-":"")+"box$3$1"+ze+"$2$3$1"+Ie+"$2box$3")+t;case 100:return be(t,":",":"+Ie)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return be(t,"scroll-","scroll-snap-")+t}return t}function Fo(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Du(t,r,o,n){switch(t.type){case Cu:if(t.children.length)break;case ku:case ws:return t.return=t.return||t.value;case kc:return"";case Cc:return t.return=t.value+"{"+Fo(t.children,n)+"}";case Ko:if(!ct(t.value=t.props.join(",")))return""}return ct(o=Fo(t.children,n))?t.return=t.value+"{"+o+"}":""}function Fu(t){var r=$c(t);return function(o,n,i,s){for(var u="",f=0;f<r;f++)u+=t[f](o,n,i,s)||"";return u}}function Nu(t){return function(r){r.root||(r=r.return)&&t(r)}}function Bu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case ws:t.return=Ic(t.value,t.length,o);return;case Cc:return Fo([zt(t,{value:be(t.value,"@","@"+ze)})],n);case Ko:if(t.length)return zu(o=t.props,function(i){switch(mt(i,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":lr(zt(t,{props:[be(i,/:(read-\w+)/,":"+Fr+"$1")]})),lr(zt(t,{props:[i]})),is(t,{props:qs(o,n)});break;case"::placeholder":lr(zt(t,{props:[be(i,/:(plac\w+)/,":"+ze+"input-$1")]})),lr(zt(t,{props:[be(i,/:(plac\w+)/,":"+Fr+"$1")]})),lr(zt(t,{props:[be(i,/:(plac\w+)/,Ie+"input-$1")]})),lr(zt(t,{props:[i]})),is(t,{props:qs(o,n)});break}return""})}}var Uu={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},rr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Pc="active",Rc="data-styled-version",tn="6.1.19",_s=`/*!sc*/
|
|
18
|
+
*/var Ds;function hd(){return Ds||(Ds=1,process.env.NODE_ENV!=="production"&&function(){function t(x,m){return x===m&&(x!==0||1/x===1/m)||x!==x&&m!==m}function r(x,m){l||i.startTransition===void 0||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var y=m();if(!u){var $=m();s(y,$)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}$=p({inst:{value:y,getSnapshot:m}});var S=$[0].inst,b=$[1];return c(function(){S.value=y,S.getSnapshot=m,o(S)&&b({inst:S})},[x,y,m]),f(function(){return o(S)&&b({inst:S}),x(function(){o(S)&&b({inst:S})})},[x]),h(y),y}function o(x){var m=x.getSnapshot;x=x.value;try{var y=m();return!s(x,y)}catch{return!0}}function n(x,m){return m()}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,p=i.useState,f=i.useEffect,c=i.useLayoutEffect,h=i.useDebugValue,l=!1,u=!1,g=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;dn.useSyncExternalStore=i.useSyncExternalStore!==void 0?i.useSyncExternalStore:g,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),dn}var Fs;function fd(){return Fs||(Fs=1,process.env.NODE_ENV==="production"?Kr.exports=pd():Kr.exports=hd()),Kr.exports}var gd=fd();const ec=0,tc=1,rc=2,Ns=3;var Bs=Object.prototype.hasOwnProperty;function Qn(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--&&Qn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Bs.call(t,o)&&++n&&!Bs.call(r,o)||!(o in r)||!Qn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const vt=new WeakMap,$t=()=>{},He=$t(),Kn=Object,Ce=t=>t===He,lt=t=>typeof t=="function",Pt=(t,r)=>({...t,...r}),oc=t=>lt(t.then),un={},Xr={},bs="undefined",Vr=typeof window!=bs,Xn=typeof document!=bs,md=Vr&&"Deno"in window,xd=()=>Vr&&typeof window.requestAnimationFrame!=bs,nc=(t,r)=>{const o=vt.get(t);return[()=>!Ce(r)&&t.get(r)||un,n=>{if(!Ce(r)){const i=t.get(r);r in Xr||(Xr[r]=i),o[5](r,Pt(i,n),i||un)}},o[6],()=>!Ce(r)&&r in Xr?Xr[r]:!Ce(r)&&t.get(r)||un]};let Jn=!0;const vd=()=>Jn,[es,ts]=Vr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$t,$t],bd=()=>{const t=Xn&&document.visibilityState;return Ce(t)||t!=="hidden"},yd=t=>(Xn&&document.addEventListener("visibilitychange",t),es("focus",t),()=>{Xn&&document.removeEventListener("visibilitychange",t),ts("focus",t)}),wd=t=>{const r=()=>{Jn=!0,t()},o=()=>{Jn=!1};return es("online",r),es("offline",o),()=>{ts("online",r),ts("offline",o)}},jd={isOnline:vd,isVisible:bd},_d={initFocus:yd,initReconnect:wd},Us=!a.useId,Nr=!Vr||md,kd=t=>xd()?window.requestAnimationFrame(t):setTimeout(t,1),pn=Nr?a.useEffect:a.useLayoutEffect,hn=typeof navigator<"u"&&navigator.connection,Ws=!Nr&&hn&&(["slow-2g","2g"].includes(hn.effectiveType)||hn.saveData),Jr=new WeakMap,Cd=t=>Kn.prototype.toString.call(t),fn=(t,r)=>t===`[object ${r}]`;let Sd=0;const rs=t=>{const r=typeof t,o=Cd(t),n=fn(o,"Date"),i=fn(o,"RegExp"),s=fn(o,"Object");let p,f;if(Kn(t)===t&&!n&&!i){if(p=Jr.get(t),p)return p;if(p=++Sd+"~",Jr.set(t,p),Array.isArray(t)){for(p="@",f=0;f<t.length;f++)p+=rs(t[f])+",";Jr.set(t,p)}if(s){p="#";const c=Kn.keys(t).sort();for(;!Ce(f=c.pop());)Ce(t[f])||(p+=f+":"+rs(t[f])+",");Jr.set(t,p)}}else p=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return p},ys=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?rs(t):"",[t,r]};let zd=0;const os=()=>++zd;async function sc(...t){const[r,o,n,i]=t,s=Pt({populateCache:!0,throwOnError:!0},typeof i=="boolean"?{revalidate:i}:i||{});let p=s.populateCache;const f=s.rollbackOnError;let c=s.optimisticData;const h=g=>typeof f=="function"?f(g):f!==!1,l=s.throwOnError;if(lt(o)){const g=o,x=[],m=r.keys();for(const y of m)!/^\$(inf|sub)\$/.test(y)&&g(r.get(y)._k)&&x.push(y);return Promise.all(x.map(u))}return u(o);async function u(g){const[x]=ys(g);if(!x)return;const[m,y]=nc(r,x),[$,S,b,z]=vt.get(r),j=()=>{const I=$[x];return(lt(s.revalidate)?s.revalidate(m().data,g):s.revalidate!==!1)&&(delete b[x],delete z[x],I&&I[0])?I[0](rc).then(()=>m().data):m().data};if(t.length<3)return j();let k=n,_,v=!1;const P=os();S[x]=[P,0];const C=!Ce(c),E=m(),T=E.data,R=E._c,w=Ce(R)?T:R;if(C&&(c=lt(c)?c(w,T):c,y({data:c,_c:w})),lt(k))try{k=k(w)}catch(I){_=I,v=!0}if(k&&oc(k))if(k=await k.catch(I=>{_=I,v=!0}),P!==S[x][0]){if(v)throw _;return k}else v&&C&&h(_)&&(p=!0,y({data:w,_c:He}));if(p&&!v)if(lt(p)){const I=p(k,w);y({data:I,error:He,_c:He})}else y({data:k,error:He,_c:He});if(S[x][1]=os(),Promise.resolve(j()).then(()=>{y({_c:He})}),v){if(l)throw _;return}return k}}const Vs=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},$d=(t,r)=>{if(!vt.has(t)){const o=Pt(_d,r),n=Object.create(null),i=sc.bind(He,t);let s=$t;const p=Object.create(null),f=(l,u)=>{const g=p[l]||[];return p[l]=g,g.push(u),()=>g.splice(g.indexOf(u),1)},c=(l,u,g)=>{t.set(l,u);const x=p[l];if(x)for(const m of x)m(u,g)},h=()=>{if(!vt.has(t)&&(vt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),i,c,f]),!Nr)){const l=o.initFocus(setTimeout.bind(He,Vs.bind(He,n,ec))),u=o.initReconnect(setTimeout.bind(He,Vs.bind(He,n,tc)));s=()=>{l&&l(),u&&u(),vt.delete(t)}}};return h(),[t,i,h,s]}return[t,vt.get(t)[4]]},Ed=(t,r,o,n,i)=>{const s=o.errorRetryCount,p=i.retryCount,f=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!Ce(s)&&p>s||setTimeout(n,f,i)},Id=Qn,[ic,Pd]=$d(new Map),Rd=Pt({onLoadingSlow:$t,onSuccess:$t,onError:$t,onErrorRetry:Ed,onDiscarded:$t,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:Ws?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:Ws?5e3:3e3,compare:Id,isPaused:()=>!1,cache:ic,mutate:Pd,fallback:{}},jd),Td=(t,r)=>{const o=Pt(t,r);if(r){const{use:n,fallback:i}=t,{use:s,fallback:p}=r;n&&s&&(o.use=n.concat(s)),i&&p&&(o.fallback=Pt(i,p))}return o},Md=a.createContext({}),Od="$inf$",ac=Vr&&window.__SWR_DEVTOOLS_USE__,Ld=ac?window.__SWR_DEVTOOLS_USE__:[],Ad=()=>{ac&&(window.__SWR_DEVTOOLS_REACT__=a)},Dd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],cc=()=>Pt(Rd,a.useContext(Md)),Fd=t=>(r,o,n)=>t(r,o&&((...s)=>{const[p]=ys(r),[,,,f]=vt.get(ic);if(p.startsWith(Od))return o(...s);const c=f[p];return Ce(c)?o(...s):(delete f[p],c)}),n),Nd=Ld.concat(Fd),Bd=t=>function(...o){const n=cc(),[i,s,p]=Dd(o),f=Td(n,p);let c=t;const{use:h}=f,l=(h||[]).concat(Nd);for(let u=l.length;u--;)c=l[u](c);return c(i,s||f.fetcher||null,f)},Ud=(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())}};Ad();const gn=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}}),mn={dedupe:!0},Wd=(t,r,o)=>{const{cache:n,compare:i,suspense:s,fallbackData:p,revalidateOnMount:f,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:g}=o,[x,m,y,$]=vt.get(n),[S,b]=ys(t),z=a.useRef(!1),j=a.useRef(!1),k=a.useRef(S),_=a.useRef(r),v=a.useRef(o),P=()=>v.current,C=()=>P().isVisible()&&P().isOnline(),[E,T,R,w]=nc(n,S),I=a.useRef({}).current,M=Ce(p)?Ce(o.fallback)?He:o.fallback[S]:p,O=(q,B)=>{for(const ie in I){const H=ie;if(H==="data"){if(!i(q[H],B[H])&&(!Ce(q[H])||!i(oe,B[H])))return!1}else if(B[H]!==q[H])return!1}return!0},U=a.useMemo(()=>{const q=!S||!r?!1:Ce(f)?P().isPaused()||s?!1:c!==!1:f,B=ge=>{const V=Pt(ge);return delete V._k,q?{isValidating:!0,isLoading:!0,...V}:V},ie=E(),H=w(),se=B(ie),we=ie===H?se:B(H);let xe=se;return[()=>{const ge=B(E());return O(ge,xe)?(xe.data=ge.data,xe.isLoading=ge.isLoading,xe.isValidating=ge.isValidating,xe.error=ge.error,xe):(xe=ge,ge)},()=>we]},[n,S]),F=gd.useSyncExternalStore(a.useCallback(q=>R(S,(B,ie)=>{O(ie,B)||q()}),[n,S]),U[0],U[1]),L=!z.current,A=x[S]&&x[S].length>0,Q=F.data,ee=Ce(Q)?M&&oc(M)?gn(M):M:Q,W=F.error,K=a.useRef(ee),oe=g?Ce(Q)?Ce(K.current)?ee:K.current:Q:ee,te=A&&!Ce(W)?!1:L&&!Ce(f)?f:P().isPaused()?!1:s?Ce(ee)?!1:c:Ce(ee)||c,de=!!(S&&r&&L&&te),ne=Ce(F.isValidating)?de:F.isValidating,ue=Ce(F.isLoading)?de:F.isLoading,X=a.useCallback(async q=>{const B=_.current;if(!S||!B||j.current||P().isPaused())return!1;let ie,H,se=!0;const we=q||{},xe=!y[S]||!we.dedupe,ge=()=>Us?!j.current&&S===k.current&&z.current:S===k.current,V={isValidating:!1,isLoading:!1},D=()=>{T(V)},N=()=>{const pe=y[S];pe&&pe[1]===H&&delete y[S]},re={isValidating:!0};Ce(E().data)&&(re.isLoading=!0);try{if(xe&&(T(re),o.loadingTimeout&&Ce(E().data)&&setTimeout(()=>{se&&ge()&&P().onLoadingSlow(S,o)},o.loadingTimeout),y[S]=[B(b),os()]),[ie,H]=y[S],ie=await ie,xe&&setTimeout(N,o.dedupingInterval),!y[S]||y[S][1]!==H)return xe&&ge()&&P().onDiscarded(S),!1;V.error=He;const pe=m[S];if(!Ce(pe)&&(H<=pe[0]||H<=pe[1]||pe[1]===0))return D(),xe&&ge()&&P().onDiscarded(S),!1;const J=E().data;V.data=i(J,ie)?J:ie,xe&&ge()&&P().onSuccess(ie,S,o)}catch(pe){N();const J=P(),{shouldRetryOnError:_e}=J;J.isPaused()||(V.error=pe,xe&&ge()&&(J.onError(pe,S,J),(_e===!0||lt(_e)&&_e(pe))&&(!P().revalidateOnFocus||!P().revalidateOnReconnect||C())&&J.onErrorRetry(pe,S,J,ve=>{const Se=x[S];Se&&Se[0]&&Se[0](Ns,ve)},{retryCount:(we.retryCount||0)+1,dedupe:!0})))}return se=!1,D(),!0},[S,n]),ae=a.useCallback((...q)=>sc(n,k.current,...q),[]);if(pn(()=>{_.current=r,v.current=o,Ce(Q)||(K.current=Q)}),pn(()=>{if(!S)return;const q=X.bind(He,mn);let B=0;P().revalidateOnFocus&&(B=Date.now()+P().focusThrottleInterval);const H=Ud(S,x,(se,we={})=>{if(se==ec){const xe=Date.now();P().revalidateOnFocus&&xe>B&&C()&&(B=xe+P().focusThrottleInterval,q())}else if(se==tc)P().revalidateOnReconnect&&C()&&q();else{if(se==rc)return X();if(se==Ns)return X(we)}});return j.current=!1,k.current=S,z.current=!0,T({_k:b}),te&&(y[S]||(Ce(ee)||Nr?q():kd(q))),()=>{j.current=!0,H()}},[S]),pn(()=>{let q;function B(){const H=lt(h)?h(E().data):h;H&&q!==-1&&(q=setTimeout(ie,H))}function ie(){!E().error&&(l||P().isVisible())&&(u||P().isOnline())?X(mn).then(B):B()}return B(),()=>{q&&(clearTimeout(q),q=-1)}},[h,l,u,S]),a.useDebugValue(oe),s&&Ce(ee)&&S){if(!Us&&Nr)throw new Error("Fallback data is required when using Suspense in SSR.");_.current=r,v.current=o,j.current=!1;const q=$[S];if(!Ce(q)){const B=ae(q);gn(B)}if(Ce(W)){const B=X(mn);Ce(oe)||(B.status="fulfilled",B.value=!0),gn(B)}else throw W}return{mutate:ae,get data(){return I.data=!0,oe},get error(){return I.error=!0,W},get isValidating(){return I.isValidating=!0,ne},get isLoading(){return I.isLoading=!0,ue}}},Ne=Bd(Wd);async function G(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}return{data:(await t.json()).data}}function lc(t){const{client:r}=Fe(),o=a.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await G(c)).data},[r,t]),{data:n,error:i,mutate:s}=Ne(t?`wacht-agent-sessions:${t}`:null,o,{revalidateOnFocus:!1}),p=a.useCallback(async c=>{const h=new FormData;h.append("title",c.title),c.system_instructions&&h.append("system_instructions",c.system_instructions);const l=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:h}),u=await G(l);return await s(g=>g&&{...g,data:[u.data,...g.data]}),u.data},[r,t,s]),f=a.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await s(h=>h&&{...h,data:h.data.filter(l=>l.id!==c)})},[r,t,s]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!i,error:i,createSession:p,deleteSession:f,refetch:async()=>{await s()}}}const dc=a.createContext(void 0);function Yo(){const t=a.useContext(dc);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Vd({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:i,onSessionCreated:s,onSessionDeleted:p,onError:f}){const[c,h]=a.useState(i?{id:i,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[l,u]=a.useState(!1),{sessions:g,loading:x,error:m,createSession:y,deleteSession:$,refetch:S}=lc(o);a.useEffect(()=>{if(i&&g.length>0){const _=g.find(v=>v.id===i);_&&h(_)}},[i,g]);const b=a.useCallback(_=>{h(_),u(!1)},[]),z=a.useCallback(async _=>{try{const v=_||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,P=await y({title:v});return h(P),s==null||s(P),P}catch(v){const P=v instanceof Error?v.message:"Failed to create session";throw f==null||f(P),v}},[y,s,f]),j=a.useCallback(async _=>{try{await $(_),(c==null?void 0:c.id)===_&&h(null),p==null||p(_)}catch(v){const P=v instanceof Error?v.message:"Failed to delete session";throw f==null||f(P),v}},[$,c,p,f]),k={agentName:r,token:o,platformAdapter:n,sessions:g,selectedSession:c,loadingSessions:x,sessionError:m,selectSession:b,createSession:z,deleteSession:j,refreshSessions:S,showHistory:l,setShowHistory:u,onSessionCreated:s,onSessionDeleted:p,onError:f};return e.jsx(dc.Provider,{value:k,children:t})}var uc=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(uc||{});function Gd(t,r){const o={username:Hd(t,r),email:qd(t,r),phone:Yd(t,r),email_otp:Zd(t,r),magic_link:Qd(t,r),oauth:Kd(t),generic:Xd(t,r)};return function(i){return o[i]}}function Hd(t,r){return async({username:o,password:n})=>{var f,c;const i=new FormData;i.append("strategy","plain_username"),i.append("username",o),i.append("password",n);const s=await t("/auth/signin",{method:"POST",body:i}),p=await G(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function qd(t,r){return async({email:o,password:n})=>{var f,c;const i=new FormData;i.append("strategy","plain_email"),i.append("email",o),i.append("password",n);const s=await t("/auth/signin",{method:"POST",body:i}),p=await G(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function Yd(t,r){return async({phone:o})=>{var p,f;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const i=await t("/auth/signin",{method:"POST",body:n}),s=await G(i);return"data"in s&&((f=(p=s.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Zd(t,r){return async({email:o})=>{var p,f;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const i=await t("/auth/signin",{method:"POST",body:n}),s=await G(i);return"data"in s&&((f=(p=s.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Qd(t,r){return async({email:o})=>{var p,f;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const i=await t("/auth/signin",{method:"POST",body:n}),s=await G(i);return"data"in s&&((f=(p=s.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Kd(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const i=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),s=await G(i);return"data"in s&&s.data.oauth_url&&(window.location.href=s.data.oauth_url),s}}function Xd(t,r){return async({email:o,username:n,password:i,phone:s,strategy:p,token:f})=>{var u,g;const c=new FormData;p&&c.append("strategy",p),o&&c.append("email",o),n&&c.append("username",n),i&&c.append("password",i),s&&c.append("phone",s),f&&c.append("token",f);const h=await t("/auth/signin",{method:"POST",body:c}),l=await G(h);return"data"in l&&((g=(u=l.data)==null?void 0:u.signin_attempts)!=null&&g.length)&&r(l.data.signin_attempts.at(-1)||null),l}}function pc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Gd(t,n),completeVerification:async i=>{var c,h;const s=new FormData;s.append("verification_code",i);const p=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:s}),f=await G(p);if("data"in f&&((h=(c=f.data)==null?void 0:c.signin_attempts)!=null&&h.length)){const l=f.data.signin_attempts.at(-1);return n(l||null),f.data}else throw new Error("Verification failed")},prepareVerification:async i=>{var f;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((f=o==null?void 0:o.id)==null?void 0:f.toString())||""),s.searchParams.set("strategy",i.strategy),s.searchParams.set("identifier_type","signin"),i.strategy==="phone_otp"&&i.lastDigits?s.searchParams.set("last_digits",i.lastDigits):(i.strategy==="email_otp"&&i.redirectUri||i.strategy==="magic_link"&&i.redirectUri)&&s.searchParams.set("redirect_uri",i.redirectUri);const p=await t(s.pathname+s.search,{method:"POST"});return G(p)},completeProfile:async i=>{var c;if(!o)throw new Error("No signin attempt found");const s=new FormData;for(const[h,l]of Object.entries(i))l&&s.append(h,l);const p=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:s}),f=await G(p);if("data"in f&&f.data){const h=(c=f.data.signin_attempts)==null?void 0:c.find(l=>l.id===o.id);return h&&n(h),f.data}else throw new Error("Profile completion failed")},identify:async i=>{const s=new FormData;s.append("identifier",i);const p=await t("/auth/identify",{method:"POST",body:s});return(await G(p)).data},initEnterpriseSso:async(i,s)=>{const p=new URLSearchParams({connection_id:i});s&&p.append("redirect_uri",s);const f=await t(`/auth/sso/login?${p.toString()}`,{method:"POST"});return(await G(f)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function Br(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:i,setSignInAttempt:s}=pc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:i,setSignInAttempt:s};const p=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:p,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:i,setSignInAttempt:s}}function Jd(t,r,o){return{create:async n=>{var f,c,h;const i=new FormData;for(const[l,u]of Object.entries(n))i.append(l,u);const s=await t("/auth/signup",{method:"POST",body:i}),p=await G(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(((h=p.data.signup_attempts)==null?void 0:h.at(-1))||null),p},prepareVerification:async n=>{var p;const i=new URL("/auth/prepare-verification",window.location.origin);i.searchParams.set("attempt_identifier",((p=r==null?void 0:r.id)==null?void 0:p.toString())||""),i.searchParams.set("strategy",n.strategy),i.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?i.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&i.searchParams.set("redirect_uri",n.redirectUri);const s=await t(i.pathname+i.search,{method:"POST"});return G(s)},completeVerification:async n=>{var f,c;const i=new FormData;i.append("verification_code",n);const s=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:i}),p=await G(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(p.data.signup_attempts.at(-1)||null),p},validateDeploymentInvitation:async n=>{try{const i=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),s=await G(i);return"data"in s&&s.data?s.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(i){return{valid:!1,message:i.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function hc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:Jd(t,o,n)}}const Ge=()=>{const{adapter:t,deployment:r}=me(),o=t.useNavigate(),n=(c,h)=>{o?o(c,h):window.location.href=c},i=c=>{if(c)return c;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const h=i(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const h=i(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const h=i(c),l=new URLSearchParams;l.set("redirect_uri",h),(r==null?void 0:r.mode)==="staging"&&l.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function eu(t){const r=await t("/session",{method:"GET"});return(await G(r)).data}async function tu(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return G(o)}async function ru(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return G(n)}async function ou(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return G(o)}async function nu(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return G(o)}const ns=new Map,Lr=new Map;function Et(){ns.clear(),Lr.clear()}async function su(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return G(o)}function Be(){const{client:t,loading:r}=Fe(),{deployment:o}=me(),{navigate:n}=Ge(),{cache:i}=cc(),{data:s,error:p,mutate:f,isLoading:c}=Ne(r?null:"/session",()=>eu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),h=a.useCallback(async()=>{await f(void 0,{revalidate:!0})},[f]),l=a.useCallback(async(u="default")=>{if(!s)throw new Error("no session");const g=ns.get(u);if(g&&g.expires>Date.now())return(g==null?void 0:g.token)||"";Lr.get(u)||Lr.set(u,su(t,u));const x=await Lr.get(u);return Lr.delete(u),ns.set(u,x.data),x.data.token},[t,s==null?void 0:s.active_signin]);return r||!s||c?{loading:!0,error:p,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:h}:{loading:c,error:p,session:s,switchSignIn:async u=>{await tu(t,u),await f(void 0,{revalidate:!0})},signOut:async u=>{await ru(t,u);const g=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],x=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(i instanceof Map){const m=Array.from(i.keys());for(const y of m){let $=!1;(g.includes(y)||typeof y=="string"&&x.some(S=>y.startsWith(S)))&&($=!0),$&&i.delete(y)}}Et(),await f(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(u&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!u&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async u=>{await ou(t,u),Et(),await f(void 0,{revalidate:!0})},switchWorkspace:async u=>{await nu(t,u),Et(),await f(void 0,{revalidate:!0})},getToken:l,refetch:h}}const Zo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=yt(),{client:n}=Fe(),{refetch:i}=Be(),s=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/roles`,{method:"GET"}))).data,[n]),p=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/members`,{method:"GET"}))).data,[n]),f=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/invitations`,{method:"GET"}))).data,[n]),c=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/domains`,{method:"GET"}))).data,[n]),h=a.useCallback(async(F,L)=>{await n(`/organizations/${F.id}/members/${L.id}/remove`,{method:"POST"}),await r()},[r,n]),l=a.useCallback(async F=>{const L=new FormData;L.append("name",F.name),F.image&&L.append("image",F.image),F.description&&L.append("description",F.description);const A=await G(await n("/organizations",{method:"POST",body:L}));return Et(),await r(),await i(),A},[i,r,n]),u=a.useCallback(async(F,L)=>{const A=Object.entries(L).reduce((ee,[W,K])=>(K&&ee.append(W,K),ee),new FormData),Q=await G(await n(`/organizations/${F.id}/update`,{method:"POST",body:A}));return await r(),Q},[r,n]),g=a.useCallback(async(F,L)=>{await n(`/organizations/${F.id}/roles/${L.id}/remove`,{method:"POST"})},[n]),x=a.useCallback(async(F,L)=>{const A=new FormData;return A.append("domain",L.fqdn),await G(await n(`/organizations/${F.id}/domains`,{method:"POST",body:A}))},[n]),m=a.useCallback(async(F,L)=>await G(await n(`/organizations/${F.id}/domains/${L.id}/verify`,{method:"POST"})),[n]),y=a.useCallback(async(F,L)=>await G(await n(`/organizations/${F.id}/domains/${L.id}/delete`,{method:"POST"})),[n]),$=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/enterprise-connections`,{method:"GET"}))).data,[n]),S=a.useCallback(async(F,L)=>{const A=new FormData;return A.append("protocol",L.protocol),L.domain_id&&A.append("domain_id",L.domain_id),L.idp_entity_id&&A.append("idp_entity_id",L.idp_entity_id),L.idp_sso_url&&A.append("idp_sso_url",L.idp_sso_url),L.idp_certificate&&A.append("idp_certificate",L.idp_certificate),L.oidc_client_id&&A.append("oidc_client_id",L.oidc_client_id),L.oidc_client_secret&&A.append("oidc_client_secret",L.oidc_client_secret),L.oidc_issuer_url&&A.append("oidc_issuer_url",L.oidc_issuer_url),L.oidc_scopes&&A.append("oidc_scopes",L.oidc_scopes),L.jit_enabled!==void 0&&A.append("jit_enabled",String(L.jit_enabled)),L.attribute_mapping&&A.append("attribute_mapping",JSON.stringify(L.attribute_mapping)),(await G(await n(`/organizations/${F.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),b=a.useCallback(async(F,L,A)=>{const Q=new FormData;return A.domain_id&&Q.append("domain_id",A.domain_id),A.idp_entity_id&&Q.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&Q.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&Q.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&Q.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&Q.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&Q.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&Q.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&Q.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await G(await n(`/organizations/${F.id}/enterprise-connections/${L}/update`,{method:"POST",body:Q}))).data},[n]),z=a.useCallback(async(F,L)=>{await n(`/organizations/${F.id}/enterprise-connections/${L}/delete`,{method:"POST"})},[n]),j=a.useCallback(async(F,L)=>{const A=new FormData;return A.append("protocol",L.protocol),L.idp_entity_id&&A.append("idp_entity_id",L.idp_entity_id),L.idp_sso_url&&A.append("idp_sso_url",L.idp_sso_url),L.idp_certificate&&A.append("idp_certificate",L.idp_certificate),L.oidc_issuer_url&&A.append("oidc_issuer_url",L.oidc_issuer_url),L.oidc_client_id&&A.append("oidc_client_id",L.oidc_client_id),L.oidc_client_secret&&A.append("oidc_client_secret",L.oidc_client_secret),(await G(await n(`/organizations/${F.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),k=a.useCallback(async(F,L)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${L}/test`,{method:"POST"}))).data,[n]),_=a.useCallback(async(F,L)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${L}/scim/token`,{method:"POST"}))).data,[n]),v=a.useCallback(async(F,L)=>(await G(await n(`/organizations/${F.id}/enterprise-connections/${L}/scim/token`,{method:"GET"}))).data,[n]),P=a.useCallback(async(F,L)=>{await n(`/organizations/${F.id}/enterprise-connections/${L}/scim/token/revoke`,{method:"POST"})},[n]),C=a.useCallback(async(F,L)=>{const A=new FormData;return A.append("name",L.name),L.permissions&&L.permissions.forEach((ee,W)=>{A.append(`permissions[${W}]`,ee)}),await G(await n(`/organizations/${F.id}/roles`,{method:"POST",body:A}))},[n]),E=a.useCallback(async F=>(await G(await n(`/organizations/${F.id}/leave`,{method:"POST"}))).data,[n]),T=a.useCallback(async F=>{const L=await G(await n(`/organizations/${F.id}/delete`,{method:"POST"}));return Et(),await r(),await i(),L.data},[n,r,i]),R=a.useCallback(async(F,L,A)=>(await G(await n(`/organizations/${F.id}/members/${L.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),w=a.useCallback(async(F,L,A)=>(await G(await n(`/organizations/${F.id}/members/${L.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),I=a.useCallback(async(F,L)=>{var ee,W;const A=new FormData;return A.append("email",L.email),A.append("role_id",L.organizationRole.id),(ee=L.workspace)!=null&&ee.id&&A.append("workspace_id",L.workspace.id),(W=L.workspaceRole)!=null&&W.id&&A.append("workspace_role_id",L.workspaceRole.id),(await G(await n(`/organizations/${F.id}/invitations`,{method:"POST",body:A}))).data},[n]),M=a.useCallback(async(F,L)=>(await G(await n(`/organizations/${F.id}/invitations/${L.id}/remove`,{method:"POST"}))).data,[n]),O=a.useCallback(async(F,L)=>(await G(await n(`/organizations/${F.id}/invitations/${L.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:a.useMemo(()=>t==null?void 0:t.map(F=>F.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:E,getOrganizationRoles:s,getOrganizationMembers:p,removeOrganizationMember:h,createOrganization:l,getOrganizationInvitations:f,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:m,removeOrganizationDomain:y,addRoleToOrganizationMember:R,removeRoleFromOrganizationMember:w,inviteOrganizationMember:I,discardOrganizationInvitation:M,resendOrganizationInvitation:O,updateOrganization:u,addRole:C,removeOrganizationRoles:g,deleteOrganization:T,getEnterpriseConnections:$,createEnterpriseConnection:S,updateEnterpriseConnection:b,deleteEnterpriseConnection:z,testEnterpriseConnectionConfig:j,testEnterpriseConnection:k,generateSCIMToken:_,getSCIMToken:v,revokeSCIMToken:P}},Ye=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:i,leaveOrganization:s,removeOrganizationMember:p,getOrganizationInvitations:f,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:l,verifyOrganizationDomain:u,addRoleToOrganizationMember:g,removeRoleFromOrganizationMember:x,inviteOrganizationMember:m,discardOrganizationInvitation:y,resendOrganizationInvitation:$,updateOrganization:S,removeOrganizationRoles:b,getEnterpriseConnections:z,createEnterpriseConnection:j,updateEnterpriseConnection:k,deleteEnterpriseConnection:_,testEnterpriseConnectionConfig:v,testEnterpriseConnection:P,generateSCIMToken:C,getSCIMToken:E,revokeSCIMToken:T}=Zo(),{session:R,error:w,loading:I}=Be(),{organizationMemberships:M}=yt(),O=a.useMemo(()=>{var D;return((D=M==null?void 0:M.find(N=>{var re;return N.id===((re=R==null?void 0:R.active_signin)==null?void 0:re.active_organization_membership_id)}))==null?void 0:D.organization)||null},[M,R]),U=a.useCallback(async D=>O?await S(O,D):[],[O,S]),F=a.useCallback(async()=>O?await n(O):[],[O,n]),L=a.useCallback(async()=>O?await i(O):[],[O,i]),A=a.useCallback(async D=>O?await p(O,D):[],[O,p]),Q=a.useCallback(async D=>O?await b(O,D):void 0,[O,b]),ee=a.useCallback(async()=>O?await c(O):[],[O,c]),W=a.useCallback(async D=>O?await l(O,D):void 0,[O,l]),K=a.useCallback(async D=>O?await u(O,D):void 0,[O,u]),oe=a.useCallback(async D=>O?await h(O,D):void 0,[O,h]),te=a.useCallback(async(D,N)=>O?await g(O,D,N):void 0,[O,g]),de=a.useCallback(async(D,N)=>O?await x(O,D,N):void 0,[O,x]),ne=a.useCallback(async D=>O?await m(O,D):void 0,[O,m]),ue=a.useCallback(async D=>O?await y(O,D):void 0,[O,y]),X=a.useCallback(async D=>O?await $(O,D):void 0,[O,$]),ae=a.useCallback(async()=>{O&&await s(O)},[O,s]),Z=a.useCallback(async()=>O?await f(O):[],[O,f]),q=a.useCallback(async()=>O?await z(O):[],[O,z]),B=a.useCallback(async D=>{if(O)return await j(O,D)},[O,j]),ie=a.useCallback(async(D,N)=>{if(O)return await k(O,D,N)},[O,k]),H=a.useCallback(async D=>{O&&await _(O,D)},[O,_]),se=a.useCallback(async D=>O?await v(O,D):null,[O,v]),we=a.useCallback(async D=>O?await P(O,D):null,[O,P]),xe=a.useCallback(async D=>{if(O)return await C(O,D)},[O,C]),ge=a.useCallback(async D=>{if(O)return await E(O,D)},[O,E]),V=a.useCallback(async D=>{O&&await T(O,D)},[O,T]);return I||t?{activeOrganization:null,loading:!0,error:w||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:O,loading:!1,refetch:o,getRoles:L,updateOrganization:U,getMembers:F,getDomains:ee,addDomain:W,verifyDomain:K,removeDomain:oe,getInvitations:Z,removeMember:A,leave:ae,removeRole:Q,addMemberRole:te,removeMemberRole:de,inviteMember:ne,discardInvitation:ue,resendInvitation:X,getEnterpriseConnections:q,createEnterpriseConnection:B,updateEnterpriseConnection:ie,deleteEnterpriseConnection:H,testEnterpriseConnectionConfig:se,testEnterpriseConnection:we,generateSCIMToken:xe,getSCIMToken:ge,revokeSCIMToken:V,error:null}};async function iu(t){return(await G(await t("/me/organization-memberships"))).data}const yt=()=>{const{client:t,loading:r}=Fe(),{data:o,isLoading:n,error:i,mutate:s}=Ne(r?null:"/me/organization-memberships",()=>iu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),p=a.useCallback(async()=>{await s(void 0,{revalidate:!0})},[s]);return{organizationMemberships:o,loading:r||n,error:i,refetch:p}};async function au(t){return(await G(await t("/me/workspace-memberships"))).data}async function cu(t,r,o){return(await G(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Qo=()=>{const{client:t,loading:r}=Fe(),{deployment:o}=me(),{data:n,isLoading:i,error:s,mutate:p}=Ne(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>au(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=a.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]);return{workspaceMemberships:n,loading:r||i,error:s,refetch:f}},wt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Qo(),{client:i}=Fe(),s=a.useMemo(()=>t==null?void 0:t.map(b=>({...b.workspace,organization:b.organization,eligibility_restriction:b.eligibility_restriction})),[t]),p=a.useCallback(async(b,z,j,k)=>{const _=new FormData;_.append("name",z),j&&_.append("image",j),k&&_.append("description",k),_.append("organization_id",b);const v=await G(await i("/workspaces",{method:"POST",body:_}));return Et(),await r(),v.data},[i,r]),f=a.useCallback(async(b,z)=>{const j=await cu(i,b,z);return await r(),j},[i,r]),c=a.useCallback(async(b,z)=>{const j=new FormData;z.name&&j.append("name",z.name),z.description&&j.append("description",z.description),z.image&&j.append("image",z.image),z.enforce_2fa!==void 0&&j.append("enforce_2fa",String(z.enforce_2fa)),z.enable_ip_restriction!==void 0&&j.append("enable_ip_restriction",String(z.enable_ip_restriction)),z.whitelisted_ips&&z.whitelisted_ips.forEach(_=>j.append("whitelisted_ips",_));const k=await G(await i(`/workspaces/${b.id}/update`,{method:"POST",body:j}));return await r(),k.data},[i,r]),h=a.useCallback(async b=>{const z=await G(await i(`/workspaces/${b.id}/delete`,{method:"POST"}));return Et(),await r(),z.data},[i,r]),l=a.useCallback(async b=>(await G(await i(`/workspaces/${b.id}/members`,{method:"GET"}))).data,[i]),u=a.useCallback(async b=>(await G(await i(`/workspaces/${b.id}/roles`,{method:"GET"}))).data,[i]),g=a.useCallback(async(b,z,j)=>(await G(await i(`/workspaces/${b.id}/roles`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z,permissions:j})}))).data,[i]),x=a.useCallback(async(b,z)=>(await G(await i(`/workspaces/${b.id}/roles/${z.id}/delete`,{method:"POST"}))).data,[i]),m=a.useCallback(async(b,z,j)=>(await G(await i(`/workspaces/${b.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:z,role_id:j})}))).data,[i]),y=a.useCallback(async(b,z)=>{const j=await G(await i(`/workspaces/${b.id}/members/${z}/remove`,{method:"POST"}));return await r(),j.data},[i,r]),$=a.useCallback(async(b,z,j)=>(await G(await i(`/workspaces/${b.id}/members/${z}/roles/${j}/add`,{method:"POST"}))).data,[i]),S=a.useCallback(async(b,z,j)=>(await G(await i(`/workspaces/${b.id}/members/${z}/roles/${j}/remove`,{method:"POST"}))).data,[i]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:f,createWorkspace:p,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:l,getWorkspaceRoles:u,createWorkspaceRole:g,deleteWorkspaceRole:x,inviteWorkspaceMember:m,removeWorkspaceMember:y,addWorkspaceMemberRole:$,removeWorkspaceMemberRole:S}},Rt=()=>{const{refetch:t,loading:r,error:o,leaveWorkspace:n,updateWorkspace:i,deleteWorkspace:s,getWorkspaceMembers:p,getWorkspaceRoles:f,createWorkspaceRole:c,deleteWorkspaceRole:h,inviteWorkspaceMember:l,removeWorkspaceMember:u,addWorkspaceMemberRole:g,removeWorkspaceMemberRole:x}=wt(),{workspaceMemberships:m}=Qo(),{session:y,loading:$,error:S}=Be(),b=a.useMemo(()=>{var O;return((O=m==null?void 0:m.find(U=>{var F;return U.id===((F=y==null?void 0:y.active_signin)==null?void 0:F.active_workspace_membership_id)}))==null?void 0:O.workspace)||null},[m,y]),z=a.useCallback(async()=>{var O;if(!(!b||!((O=y==null?void 0:y.active_signin)!=null&&O.user_id)))return await n(b.id,y.active_signin.user_id)},[b,n,y]),j=a.useCallback(async O=>{if(b)return await i(b,O)},[b,i]),k=a.useCallback(async()=>{if(b)return await s(b)},[b,s]),_=a.useCallback(async()=>b?await p(b):[],[b,p]),v=a.useCallback(async()=>b?await f(b):[],[b,f]),P=a.useCallback(async(O,U)=>{if(b)return await c(b,O,U)},[b,c]),C=a.useCallback(async O=>{if(b)return await h(b,O)},[b,h]),E=a.useCallback(async(O,U)=>{if(b)return await l(b,O,U)},[b,l]),T=a.useCallback(async O=>{if(b)return await u(b,O)},[b,u]),R=a.useCallback(async(O,U)=>{if(b)return await g(b,O,U)},[b,g]),w=a.useCallback(async(O,U)=>{if(b)return await x(b,O,U)},[b,x]),I=r||$,M=o||S;return I?{activeWorkspace:null,loading:!0,error:M,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null}:{activeWorkspace:b,loading:!1,error:M,refetch:t,leave:z,updateWorkspace:j,deleteWorkspace:k,getMembers:_,getRoles:v,createRole:P,deleteRole:C,inviteMember:E,removeMember:T,addMemberRole:R,removeMemberRole:w}},lu=async t=>(await G(await t("/me"))).data,du=async t=>(await G(await t("/me/signins"))).data;function sr(){const{client:t,loading:r}=Fe(),{data:o,error:n,isLoading:i,mutate:s}=Ne(r?null:"/user",()=>lu(t)),p=async I=>{const M=new FormData;for(const[U,F]of Object.entries(I))F!=null&&F!==""&&M.append(U,String(F));const O=await G(await t("/me",{method:"POST",body:M}));return s(),O},f=async()=>await G(await t("/me/email-addresses",{method:"GET"})),c=async I=>await G(await t(`/me/email-addresses/${I}`,{method:"GET"})),h=async I=>{const M=new FormData;return M.append("email",I),await G(await t("/me/email-addresses",{method:"POST",body:M}))},l=async I=>await G(await t(`/me/email-addresses/${I}/delete`,{method:"POST"})),u=async I=>await G(await t(`/me/email-addresses/${I}/prepare-verification`,{method:"POST"})),g=async(I,M)=>await G(await t(`/me/email-addresses/${I}/attempt-verification?code=${M}`,{method:"POST"})),x=async(I,M)=>{const O=new FormData;return O.append("phone_number",I),O.append("country_code",M),await G(await t("/me/phone-numbers",{method:"POST",body:O}))},m=async I=>await G(await t(`/me/phone-numbers/${I}/delete`,{method:"POST"})),y=async I=>await G(await t(`/me/phone-numbers/${I}/prepare-verification`,{method:"POST"})),$=async(I,M)=>{const O=new FormData;return O.append("code",M),await G(await t(`/me/phone-numbers/${I}/attempt-verification`,{method:"POST",body:O}))},S=async I=>{const M=await G(await t(`/me/phone-numbers/${I}/make-primary`,{method:"POST"}));return s(),M},b=async I=>await G(await t(`/me/email-addresses/${I}/make-primary`,{method:"POST"})),z=async()=>(await G(await t("/me/authenticator",{method:"POST"}))).data,j=async(I,M)=>{const O=new FormData;return O.append("authenticator_id",I),M.forEach(F=>{O.append("codes",F)}),await G(await t("/me/authenticator/attempt-verification",{method:"POST",body:O}))},k=async I=>await G(await t(`/me/authenticator/${I}/delete`,{method:"POST"})),_=async()=>(await G(await t("/me/backup-codes",{method:"POST"}))).data,v=async I=>{const M=new FormData;return M.append("file",I),await G(await t("/me/profile-picture",{method:"POST",body:M}))},P=async()=>(await G(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,C=async(I,M)=>{const O=new FormData;return O.append("current_password",I),O.append("new_password",M),await G(await t("/me/update-password",{method:"POST",body:O}))},E=async I=>{const M=new FormData;M.append("current_password",I);const O=await G(await t("/me/remove-password",{method:"POST",body:M}));return s(),O},T=async I=>{const M=new FormData;return M.append("password",I),await G(await t("/me/account/delete",{method:"POST",body:M}))},R=async I=>await G(await t(`/me/social-connections/${I}/disconnect`,{method:"POST"})),w=async({provider:I,redirectUri:M})=>{var F;const O=new URLSearchParams({provider:I});M&&O.append("redirect_uri",M);const U=await G(await t(`/me/init-sso-connection?${O.toString()}`,{method:"POST"}));return"data"in U&&((F=U.data)!=null&&F.oauth_url)&&window.open(U.data.oauth_url,"_blank"),U};return{user:{...o,refetch:s},loading:r||i,error:n||null,updateProfile:p,getEmailAddresses:f,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:l,prepareEmailVerification:u,attemptEmailVerification:g,makeEmailPrimary:b,createPhoneNumber:x,deletePhoneNumber:m,preparePhoneVerification:y,attemptPhoneVerification:$,makePhonePrimary:S,setupAuthenticator:z,verifyAuthenticator:j,deleteAuthenticator:k,generateBackupCodes:_,regenerateBackupCodes:P,updateProfilePicture:v,disconnectSocialConnection:R,connectSocialAccount:w,updatePassword:C,removePassword:E,deleteAccount:T}}function fc(){const{client:t,loading:r}=Fe(),{data:o,error:n,isLoading:i,mutate:s}=Ne(r?null:"/me/signins",()=>du(t));return{signins:o,error:n||null,removeSignin:async f=>await G(await t(`/me/signins/${f}/signout`,{method:"POST"})),refetch:s,loading:i||r}}function uu(){const{session:t,loading:r}=Be(),{loading:o,organizationMemberships:n}=yt(),{loading:i,workspaceMemberships:s}=Qo();if(r||o||i)return{loading:!0,orgMembership:null,workspaceMembership:null};const p=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_organization_membership_id)}),[t]),f=a.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:p,workspaceMembership:f}}function gc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(!1),i=async s=>{n(!0);try{const p=new FormData;for(const[h,l]of Object.entries(s))l&&p.append(h,l);const f=await t("/waitlist/join",{method:"POST",body:p});return await G(f)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:i}}function mc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(!1),[i,s]=a.useState(null),[p,f]=a.useState(null),[c,h]=a.useState(null),[l,u]=a.useState(!1),[g,x]=a.useState(null);a.useEffect(()=>{if(l||r)return;const y=new URLSearchParams(window.location.search),$=y.get("code"),S=y.get("state"),b=y.get("error"),z=y.get("error_description");if(!$&&!b){u(!0);const j=new Error("No OAuth callback data found.");s(j);return}if(u(!0),n(!0),b){const j=z||b,k=new Error(`OAuth Error: ${j}`);s(k),n(!1);return}if($&&S)m($,S);else{const j=new Error("Missing required OAuth parameters");s(j),n(!1)}},[l,r]);const m=async(y,$)=>{try{let S,b;try{const k=$.split(".");if(k.length!==2)throw new Error("Invalid OAuth state format - missing signature");const _=k[0].replace(/-/g,"+").replace(/_/g,"/"),v=_.length%4?"=".repeat(4-_.length%4):"",C=atob(_+v).split("|")[0];if(C==="sign_in")S="/auth/oauth2/callback",b="GET";else if(C==="connect_social")S="/me/sso-connection-callback",b="POST";else throw new Error(`Unknown OAuth action: ${C}`)}catch(k){const _=k instanceof Error?k: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(`${S}?code=${encodeURIComponent(y)}&state=${encodeURIComponent($)}`,{method:b}),j=await G(z);if("data"in j){const k=j.data.session,_=j.data.redirect_uri||null;if(f(k),h(_),k.signin_attempts&&k.signin_attempts.length>0){const v=k.signin_attempts.at(-1);v&&x(v)}}else{const k=new Error("SSO callback failed");s(k)}}catch(S){const b=S instanceof Error?S:new Error("Unknown error occurred");s(b)}finally{n(!1)}};return{loading:o,error:i,session:p,redirectUri:c,processed:l,signinAttempt:g}}function xc(){const{client:t,loading:r}=Fe(),[o,n]=a.useState(!1),[i,s]=a.useState(null);return{loading:r||o,verifyMagicLink:async f=>{if(!f.token||!f.attempt)throw new Error("Invalid magic link parameters");n(!0),s(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",f.token),c.searchParams.set("attempt",f.attempt),f.redirectUri&&c.searchParams.set("redirect_uri",f.redirectUri);const h=await t(c.pathname+c.search,{method:"GET"}),l=await G(h);return n(!1),s(!0),l}catch(c){throw n(!1),s(!1),c}},success:i}}function vc(){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 bc(){const{client:t,loading:r}=Fe();return{loading:r,forgotPassword:async s=>{const p=new FormData;p.append("email",s);const f=await t("/auth/forgot-password",{method:"POST",body:p});return await G(f)},verifyOtp:async(s,p)=>{const f=new FormData;f.append("email",s),f.append("otp",p);const c=await t("/auth/forgot-password",{method:"POST",body:f});return await G(c)},resetPassword:async(s,p)=>{const f=new FormData;f.append("token",s),f.append("password",p);const c=await t("/auth/reset-password",{method:"POST",body:f});return await G(c)}}}function yc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:i,onError:s,reconnectDelay:p=1e3,maxReconnectAttempts:f=5}={}){const{session:c,loading:h}=Be(),{deployment:l,loading:u}=me(),[g,x]=a.useState(!1),[m,y]=a.useState(null),$=a.useRef(null),S=a.useRef(null),b=a.useRef(0),z=a.useRef(null),j=a.useRef(i),k=a.useRef(s),_=a.useRef(r),v=a.useRef(o),P=a.useRef(n),C=a.useRef(p),E=a.useRef(f);j.current=i,k.current=s,_.current=r,v.current=o,P.current=n,C.current=p,E.current=f;const T=a.useCallback(()=>{S.current&&(clearTimeout(S.current),S.current=null),z.current&&(clearInterval(z.current),z.current=null),$.current&&($.current.close(),$.current=null)},[]),R=a.useCallback(async()=>{var F;if(!t||h||u||!c||!l)return;T();const M=new URL(l.backend_host),O=M.protocol==="https:"?"wss:":"ws:",U=new URL("/realtime/notifications",`${O}//${M.host}`);if(l.mode==="staging"){const L=localStorage.getItem("__dev_session__");L&&U.searchParams.set("__dev_session__",L)}_.current&&_.current.length>0&&_.current.forEach(L=>U.searchParams.append("channels",L)),v.current&&v.current.length>0&&v.current.forEach(L=>U.searchParams.append("organization_ids",L.toString())),P.current&&P.current.length>0&&P.current.forEach(L=>U.searchParams.append("workspace_ids",L.toString()));try{const L=new WebSocket(U.toString());$.current=L,L.onopen=()=>{x(!0),y(null),b.current=0,z.current=setInterval(()=>{L.readyState===WebSocket.OPEN&&L.send("ping")},3e4)},L.onmessage=A=>{var Q,ee;try{const W=JSON.parse(A.data);if(W.type==="notification"&&W.data)(Q=j.current)==null||Q.call(j,W.data);else if(W.type==="error"){const K=W.error||"Unknown error occurred";y(K),(ee=k.current)==null||ee.call(k,K)}else W.type}catch{}},L.onerror=()=>{var A;y("Connection error occurred"),(A=k.current)==null||A.call(k,"Connection error occurred")},L.onclose=A=>{var Q;if(x(!1),z.current&&(clearInterval(z.current),z.current=null),t&&A.code!==1e3&&b.current<E.current){b.current++;const ee=C.current*Math.pow(2,b.current-1);S.current=setTimeout(()=>{R()},ee)}else b.current>=E.current&&(y("Max reconnection attempts reached"),(Q=k.current)==null||Q.call(k,"Max reconnection attempts reached"))}}catch{y("Failed to connect"),(F=k.current)==null||F.call(k,"Failed to connect")}},[t,h,u,c,l,T]);a.useEffect(()=>(R(),()=>{T()}),[R,T]),a.useEffect(()=>{$.current&&$.current.readyState===WebSocket.OPEN&&R()},[r,o,n,R]);const w=a.useCallback(()=>{T(),x(!1)},[T]),I=a.useCallback(()=>{b.current=0,R()},[R]);return{isConnected:g,connectionError:m,disconnect:w,reconnect:I}}async function pu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(p=>o.append("channels",p)),r.organization_ids&&r.organization_ids.forEach(p=>o.append("organization_ids",p.toString())),r.workspace_ids&&r.workspace_ids.forEach(p=>o.append("workspace_ids",p.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,i=await t(n,{method:"GET"});return(await G(i)).data}async function hu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}async function fu(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return G(o)}async function gu(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return G(r)}async function mu(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return G(o)}function wc(t){const{client:r,loading:o}=Fe(),{data:n,error:i,mutate:s,isLoading:p}=Ne(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>pu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});yc({enabled:!o&&!!n,onNotification:a.useCallback(u=>{s(async g=>!g||g.notifications.some(m=>m.id===u.id.toString())?g:{...g,notifications:[{id:u.id.toString(),user_id:u.user_id.toString(),deployment_id:u.deployment_id.toString(),title:u.title,body:u.body,severity:u.severity,action_url:u.action_url,action_label:u.action_label,is_read:!1,is_archived:!1,created_at:u.created_at,updated_at:u.created_at},...g.notifications],unread_count:g.unread_count+1,total:g.total+1},!1)},[s]),onError:a.useCallback(()=>{},[])});const f=a.useCallback(async u=>{o||(await s(async g=>g&&{...g,notifications:g.notifications.map(x=>x.id===u?{...x,is_read:!0}:x),unread_count:Math.max(0,g.unread_count-1)},!1),await fu(r,u),await s())},[r,o,s]),c=a.useCallback(async()=>{o||(await s(async u=>u&&{...u,notifications:u.notifications.map(g=>({...g,is_read:!0})),unread_count:0},!1),await gu(r),await s())},[r,s]),h=a.useCallback(async u=>{o||(await s(async g=>{if(!g)return g;const x=g.notifications.find(m=>m.id===u);return{...g,notifications:g.notifications.filter(m=>m.id!==u),unread_count:x&&!x.is_read?Math.max(0,g.unread_count-1):g.unread_count,total:Math.max(0,g.total-1)}},!1),await mu(r,u),await s())},[r,o,s]),l=a.useCallback(async()=>{await s()},[s]);return!n||o||p?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:i,refetch:l}:{loading:!1,error:i,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:f,markAllAsRead:c,deleteNotification:h,refetch:l}}async function xu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await G(r)).data}function vu(){const{client:t,loading:r}=Fe(),{data:o,error:n,mutate:i}=Ne(r?null:"wacht-notifications:channel-counts",()=>xu(t),{refreshInterval:3e4,revalidateOnFocus:!0}),s=async()=>{await i()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:s}:{loading:!1,counts:o,error:n,refetch:s}}const Yt=class Yt{constructor(){tt(this,"ws",null);tt(this,"messageHandlers",new Set);tt(this,"connectionStateHandlers",new Set);tt(this,"reconnectTimer",null);tt(this,"reconnectAttempts",0);tt(this,"url",null);tt(this,"isIntentionalDisconnect",!1);tt(this,"sessionMessages",{});tt(this,"currentSessionKey",null)}static getInstance(){return Yt.instance||(Yt.instance=new Yt),Yt.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};tt(Yt,"instance");let ss=Yt;const Ke=ss.getInstance(),xt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Ae={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Ot={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Gs(t){switch(t){case Ot.IDLE:return Ae.IDLE;case Ot.STARTING:return Ae.STARTING;case Ot.RUNNING:return Ae.RUNNING;case Ot.WAITING_FOR_INPUT:return Ae.WAITING_FOR_INPUT;case Ot.COMPLETED:return Ae.COMPLETED;case Ot.FAILED:case Ot.CANCELLED:return Ae.FAILED;default:return Ae.IDLE}}function Hs(t){return t===Ae.STARTING||t===Ae.RUNNING||t===Ae.WAITING_FOR_INPUT}function jc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:i=!0}){const{deployment:s}=me(),{client:p}=Fe(),[f,c]=a.useState([]),[h,l]=a.useState(null),[u,g]=a.useState(null),[x,m]=a.useState(!1),[y,$]=a.useState(!1),[S,b]=a.useState(Ae.IDLE),[z,j]=a.useState({status:xt.DISCONNECTED}),[k,_]=a.useState(!0),[v,P]=a.useState(!1),C=a.useRef(null),E=a.useRef(null),T=a.useCallback(W=>{var K,oe;switch(W.message_type){case"session_connected":if(m(!0),j({status:xt.CONNECTED}),(K=W.data)!=null&&K.execution_status){const de=W.data.execution_status,ne=Gs(de);b(ne),$(Hs(ne))}break;case"conversation_message":R(W.data);break;case"user_input_request":w(W.data);break;case"platform_event":I(W.data);break;case"platform_function":M(W.data);break;case"execution_complete":$(!1),b(Ae.IDLE),E.current=null;break;case"execution_error":$(!1),b(Ae.FAILED),E.current=null;break;case"execution_cancelled":$(!1),b(Ae.IDLE),E.current=null;break;case"execution_status":const te=(oe=W.data)==null?void 0:oe.status;if(te){const de=Gs(te);b(de),$(Hs(de))}break}},[h]),R=a.useCallback(W=>{var ne,ue,X,ae,Z,q,B,ie;const{id:K,message_type:oe,content:te}=W,de=H=>f.some(se=>se.id===H);if(oe==="system_decision"||oe==="action_execution_result"||oe==="assistant_task_breakdown"||oe==="assistant_validation"||oe==="assistant_action_planning"||oe==="context_results"){l(null),g(null);let H="";if(oe==="system_decision"){const se=te==null?void 0:te.step,we=te==null?void 0:te.reasoning;if(se==="gathercontext")we&&we.length>0?H=we.length>60?`${we.substring(0,60)}...`:we:H="Gathering context...";else if(se==="executeaction")H="Executing action";else if(se==="deliverresponse")H="Preparing response";else if(se==="taskplanning")H="Planning approach";else if(se==="validateprogress")H="Validating progress";else if(se==="acknowledge")H="Processing request";else if(se==="finishplanning")H="Finalizing plan";else if(se==="executetasks")H="Executing tasks";else if(se==="requestuserinput")H="Waiting for input";else if(se==="complete")H="Completed";else if(se==="examinetool")H="Examining tool";else if(se==="examineworkflow")H="Examining workflow";else{const xe=(te==null?void 0:te.confidence)||.5;xe>.8?H="Analyzing":xe>.6?H="Thinking":H="Reasoning"}}else if(oe==="action_execution_result")((ne=te.task_execution)==null?void 0:ne.status)==="completed"?H="Task execution completed":(ue=te.task_execution)!=null&&ue.approach?H=te.task_execution.approach:H="Executing task";else if(oe==="assistant_task_breakdown")(X=te.task_breakdown)!=null&&X.total_tasks?H=`Identified ${te.task_breakdown.total_tasks} tasks`:H="Planning tasks";else if(oe==="assistant_validation")H="Validated results";else if(oe==="assistant_action_planning")(ae=te.task_execution)!=null&&ae.total_tasks?H=`Planned ${te.task_execution.total_tasks} tasks`:(q=(Z=te.task_execution)==null?void 0:Z.tasks)!=null&&q.length?H=`Planned ${te.task_execution.tasks.length} tasks`:H="Planning actions";else if(oe==="context_results"){const se=te.query,we=te.result_count||0;se&&se!=="General context gathering"?H=`${se}: Found ${we} results`:H=`Found ${we} results`}H&&!de(K)&&c(se=>[...se,{id:K,role:"system",content:H,timestamp:new Date,metadata:{type:"log",messageType:oe}}]);return}if(oe==="user_message")de(K)||(l(null),g(null),c(H=>[...H,{id:K,role:"user",content:te.message,images:te.images,timestamp:new Date}]));else if(oe==="agent_response")de(K)||(l(null),g(null),$(!1),b(Ae.IDLE),E.current=null,c(H=>[...H,{id:K,role:"assistant",content:te.response,timestamp:new Date,isStreaming:!1}]));else if(oe==="assistant_acknowledgment")de(K)||(l(null),g(null),c(H=>[...H,{id:K,role:"assistant",content:te.acknowledgment_message,timestamp:new Date}]));else if(oe==="assistant_ideation"||oe==="assistant_action_planning"||oe==="action_execution_result"||oe==="assistant_validation"||oe==="assistant_context_gathering"||oe==="assistant_task_breakdown"){let H="";if(te.reasoning_summary)H=te.reasoning_summary;else if((B=te.task_execution)!=null&&B.approach)H=te.task_execution.approach;else if(te.strategic_synthesis)H=te.strategic_synthesis;else if((ie=te.task_breakdown)!=null&&ie.total_tasks)H=`Breaking down into ${te.task_breakdown.total_tasks} tasks...`;else if(te.acknowledgment_message)H=te.acknowledgment_message;else return;c(se=>[...se,{id:K,role:"assistant",content:H,timestamp:new Date}])}else if(oe==="user_input_request"){const H={question:te.question,context:te.context,input_type:te.input_type,options:te.options||te.suggestions,default_value:te.default_value,placeholder:te.placeholder};b("waiting_for_input"),c(se=>[...se,{id:K,role:"system",content:H.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:H}}])}},[]),w=a.useCallback(async W=>{b("waiting_for_input");const K=`input-request-${Date.now()}`;c(oe=>[...oe,{id:K,role:"system",content:W.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:W}}])},[]),I=a.useCallback(W=>{const{event_label:K,event_data:oe}=W;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(K,oe)},[n]),M=a.useCallback(async W=>{const{function_name:K,function_data:oe}=W,{parameters:te,execution_id:de}=oe;if(!(n!=null&&n.onPlatformFunction)){Ke.send({message_type:{platform_function_result:[de,{error:"No platform function handler registered"}]},data:{}});return}try{const ne=await n.onPlatformFunction(K,te,de),ue={message_type:{platform_function_result:[de,ne]},data:{}};Ke.send(ue)}catch(ne){Ke.send({message_type:{platform_function_result:[de,{error:ne instanceof Error?ne.message:"Function execution failed",stack:ne instanceof Error?ne.stack:void 0}]},data:{}})}},[n]);a.useEffect(()=>{if(!s)return;const K=`wss://${s==null?void 0:s.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;j({status:xt.CONNECTING}),Ke.connect(K)},[s,o]),a.useEffect(()=>Ke.onConnectionStateChange(K=>{j({status:K.isConnected?xt.CONNECTED:K.error?xt.ERROR:xt.DISCONNECTED}),m(K.isConnected)}),[]),a.useEffect(()=>Ke.onMessage(T),[T]),a.useEffect(()=>{x&&t&&r&&i&&Ke.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,i]);const O=a.useCallback(async()=>(x&&t&&r&&Ke.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),U=a.useCallback((W,K)=>{x&&(l(W),g(K||null),$(!0),b(Ae.STARTING),Ke.send({message_type:{message_input:W},data:K?{images:K}:{}}))},[x]),F=a.useCallback(()=>{c([]),E.current=null},[]),L=a.useCallback(W=>{!x||S!==Ae.WAITING_FOR_INPUT||(Ke.send({message_type:{user_input_response:W},data:{}}),b(Ae.RUNNING))},[x,S]),A=a.useCallback(async W=>{var K;if(!(!o||!t))try{const oe=new URLSearchParams({token:o,limit:"50"});W&&(oe.append("before_id",W),P(!0));const de=await(await p(`/api/agent/contexts/${t}/messages?${oe}`,{method:"GET"})).json();if(de.status===200&&de.data){const ne=de.data;if(Array.isArray(ne.data)){const ue=ne.data.filter(X=>{var q;let ae=X.content;if(typeof X.content=="string")try{ae=JSON.parse(X.content)}catch{ae={message:X.content}}const Z=((q=X.metadata)==null?void 0:q.message_type)||(ae==null?void 0:ae.message_type);return Z==="user_message"||Z==="agent_response"||Z==="assistant_acknowledgment"||Z==="user_input_request"||Z==="system_decision"||Z==="action_execution_result"||Z==="assistant_task_breakdown"||Z==="assistant_validation"||Z==="assistant_action_planning"||Z==="context_results"}).map(X=>{var H,se,we,xe,ge,V,D;let ae="",Z,q,B=X.content;if(typeof X.content=="string")try{B=JSON.parse(X.content)}catch{B=X.content}const ie=((H=X.metadata)==null?void 0:H.message_type)||(B==null?void 0:B.message_type);if(ie==="user_message"?(ae=(B==null?void 0:B.message)||"",Z=(B==null?void 0:B.images)||void 0):ie==="agent_response"?ae=(B==null?void 0:B.response)||"":ie==="assistant_acknowledgment"?ae=(B==null?void 0:B.acknowledgment_message)||"":ie==="user_input_request"&&(ae=(B==null?void 0:B.question)||"",q={type:"user_input_request",userInputRequest:{question:(B==null?void 0:B.question)||"",context:(B==null?void 0:B.context)||"",input_type:(B==null?void 0:B.input_type)||"text",options:(B==null?void 0:B.options)||(B==null?void 0:B.suggestions)||[],default_value:(B==null?void 0:B.default_value)||"",placeholder:(B==null?void 0:B.placeholder)||""}}),ie==="system_decision"||ie==="action_execution_result"||ie==="assistant_task_breakdown"||ie==="assistant_validation"||ie==="assistant_action_planning"||ie==="context_results"){let N="";if(ie==="system_decision"){const re=B==null?void 0:B.step,pe=B==null?void 0:B.reasoning;if(re==="gathercontext")pe&&pe.length>0?N=pe.length>60?`${pe.substring(0,60)}...`:pe:N="Gathering context...";else if(re==="executeaction")N="Executing action";else if(re==="deliverresponse")N="Preparing response";else if(re==="taskplanning")N="Planning approach";else if(re==="validateprogress")N="Validating progress";else if(re==="acknowledge")N="Processing request";else if(re==="finishplanning")N="Finalizing plan";else if(re==="executetasks")N="Executing tasks";else if(re==="requestuserinput")N="Waiting for input";else if(re==="complete")N="Completed";else if(re==="examinetool")N="Examining tool";else if(re==="examineworkflow")N="Examining workflow";else{const J=(B==null?void 0:B.confidence)||.5;J>.8?N="Analyzing":J>.6?N="Thinking":N="Reasoning"}}else if(ie==="action_execution_result")((se=B==null?void 0:B.task_execution)==null?void 0:se.status)==="completed"?N="Task execution completed":(we=B==null?void 0:B.task_execution)!=null&&we.approach?N=B.task_execution.approach:N="Executing task";else if(ie==="assistant_task_breakdown")(xe=B==null?void 0:B.task_breakdown)!=null&&xe.total_tasks?N=`Identified ${B.task_breakdown.total_tasks} tasks`:N="Planning tasks";else if(ie==="assistant_validation")N="Validated results";else if(ie==="assistant_action_planning")(ge=B==null?void 0:B.task_execution)!=null&&ge.total_tasks?N=`Planned ${B.task_execution.total_tasks} tasks`:(D=(V=B==null?void 0:B.task_execution)==null?void 0:V.tasks)!=null&&D.length?N=`Planned ${B.task_execution.tasks.length} tasks`:N="Planning actions";else if(ie==="context_results"){const re=B==null?void 0:B.query,pe=(B==null?void 0:B.result_count)||0;re&&re!=="General context gathering"?N=`${re}: Found ${pe} results`:N=`Found ${pe} results`}ae=N,q={type:"log",messageType:ie}}return{id:X.id,role:ie==="user_message"?"user":ie==="user_input_request"?"system":"assistant",content:ae,images:Z,timestamp:new Date(X.timestamp||X.created_at||Date.now()),metadata:q}}).filter(X=>X.content||X.metadata||X.images).sort((X,ae)=>{const Z=BigInt(X.id),q=BigInt(ae.id);return Z<q?-1:Z>q?1:0});ue.length>0&&(C.current=ue[0].id),W?(c(X=>[...ue,...X]),_(ue.length>=50)):(c(ue),ue.length>0&&((K=ue[ue.length-1].metadata)==null?void 0:K.type)==="user_input_request"&&b(Ae.WAITING_FOR_INPUT)),P(!1)}}}catch(oe){console.error("Failed to fetch messages:",oe),P(!1)}},[o,t,p]);a.useEffect(()=>{t&&o&&A()},[t,o]);const Q=a.useCallback(async()=>{if(!(v||!k||!C.current)){P(!0);try{await A(C.current)}finally{P(!1)}}},[v,k,A]),ee=a.useCallback(()=>{!x||!y||(Ke.send({message_type:{cancel_execution:null},data:{}}),$(!1),b("idle"))},[x,y]);return{messages:f,pendingMessage:h,pendingImages:u,connectionState:z,isConnected:x,isExecuting:y,executionStatus:S,isWaitingForInput:S==="waiting_for_input",hasMoreMessages:k,isLoadingMore:v,sendMessage:U,submitUserInput:L,clearMessages:F,loadMoreMessages:Q,cancelExecution:ee,connect:O,disconnect:()=>Ke.disconnect()}}const _c=()=>{const{client:t}=Fe(),[r,o]=a.useState(!1),[n,i]=a.useState(null),[s,p]=a.useState(null),f=a.useCallback(async h=>{o(!0),i(null),p(null);try{const l=await t("/organizations/invitations/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:h})}),g=(await G(l)).data;return p(g),g.error_code&&i(g.message||"Failed to accept invitation"),g}catch(l){const u=l.message||"Failed to accept invitation";i(u);const g={error_code:"NETWORK_ERROR",message:u};return p(g),g}finally{o(!1)}},[t]),c=a.useCallback(()=>{i(null),p(null)},[]);return{acceptInvitation:f,invitationData:s,loading:r,error:n,reset:c}},bu=({children:t})=>{const{loading:r}=me();return r?null:e.jsx(e.Fragment,{children:t})},yu=({children:t})=>{const{loading:r}=me();return r?e.jsx(e.Fragment,{children:t}):null};var qe=function(){return qe=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},qe.apply(this,arguments)};function tr(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 wu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var ju=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,_u=wu(function(t){return ju.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ie="-ms-",Fr="-moz-",ze="-webkit-",kc="comm",Ko="rule",ws="decl",ku="@import",Cc="@keyframes",Cu="@layer",Sc=Math.abs,js=String.fromCharCode,is=Object.assign;function Su(t,r){return Ue(t,0)^45?(((r<<2^Ue(t,0))<<2^Ue(t,1))<<2^Ue(t,2))<<2^Ue(t,3):0}function zc(t){return t.trim()}function mt(t,r){return(t=r.exec(t))?t[0]:t}function be(t,r,o){return t.replace(r,o)}function Po(t,r,o){return t.indexOf(r,o)}function Ue(t,r){return t.charCodeAt(r)|0}function yr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function $c(t){return t.length}function Ar(t,r){return r.push(t),t}function zu(t,r){return t.map(r).join("")}function qs(t,r){return t.filter(function(o){return!mt(o,r)})}var Xo=1,wr=1,Ec=0,Xe=0,De=0,Sr="";function Jo(t,r,o,n,i,s,p,f){return{value:t,root:r,parent:o,type:n,props:i,children:s,line:Xo,column:wr,length:p,return:"",siblings:f}}function zt(t,r){return is(Jo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function lr(t){for(;t.root;)t=zt(t.root,{children:[t]});Ar(t,t.siblings)}function $u(){return De}function Eu(){return De=Xe>0?Ue(Sr,--Xe):0,wr--,De===10&&(wr=1,Xo--),De}function rt(){return De=Xe<Ec?Ue(Sr,Xe++):0,wr++,De===10&&(wr=1,Xo++),De}function Qt(){return Ue(Sr,Xe)}function Ro(){return Xe}function en(t,r){return yr(Sr,t,r)}function as(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 Iu(t){return Xo=wr=1,Ec=ct(Sr=t),Xe=0,[]}function Pu(t){return Sr="",t}function xn(t){return zc(en(Xe-1,cs(t===91?t+2:t===40?t+1:t)))}function Ru(t){for(;(De=Qt())&&De<33;)rt();return as(t)>2||as(De)>3?"":" "}function Tu(t,r){for(;--r&&rt()&&!(De<48||De>102||De>57&&De<65||De>70&&De<97););return en(t,Ro()+(r<6&&Qt()==32&&rt()==32))}function cs(t){for(;rt();)switch(De){case t:return Xe;case 34:case 39:t!==34&&t!==39&&cs(De);break;case 40:t===41&&cs(t);break;case 92:rt();break}return Xe}function Mu(t,r){for(;rt()&&t+De!==57;)if(t+De===84&&Qt()===47)break;return"/*"+en(r,Xe-1)+"*"+js(t===47?t:rt())}function Ou(t){for(;!as(Qt());)rt();return en(t,Xe)}function Lu(t){return Pu(To("",null,null,null,[""],t=Iu(t),0,[0],t))}function To(t,r,o,n,i,s,p,f,c){for(var h=0,l=0,u=p,g=0,x=0,m=0,y=1,$=1,S=1,b=0,z="",j=i,k=s,_=n,v=z;$;)switch(m=b,b=rt()){case 40:if(m!=108&&Ue(v,u-1)==58){Po(v+=be(xn(b),"&","&\f"),"&\f",Sc(h?f[h-1]:0))!=-1&&(S=-1);break}case 34:case 39:case 91:v+=xn(b);break;case 9:case 10:case 13:case 32:v+=Ru(m);break;case 92:v+=Tu(Ro()-1,7);continue;case 47:switch(Qt()){case 42:case 47:Ar(Au(Mu(rt(),Ro()),r,o,c),c);break;default:v+="/"}break;case 123*y:f[h++]=ct(v)*S;case 125*y:case 59:case 0:switch(b){case 0:case 125:$=0;case 59+l:S==-1&&(v=be(v,/\f/g,"")),x>0&&ct(v)-u&&Ar(x>32?Zs(v+";",n,o,u-1,c):Zs(be(v," ","")+";",n,o,u-2,c),c);break;case 59:v+=";";default:if(Ar(_=Ys(v,r,o,h,l,i,f,z,j=[],k=[],u,s),s),b===123)if(l===0)To(v,r,_,_,j,s,u,f,k);else switch(g===99&&Ue(v,3)===110?100:g){case 100:case 108:case 109:case 115:To(t,_,_,n&&Ar(Ys(t,_,_,0,0,i,f,z,i,j=[],u,k),k),i,k,u,f,n?j:k);break;default:To(v,_,_,_,[""],k,0,f,k)}}h=l=x=0,y=S=1,z=v="",u=p;break;case 58:u=1+ct(v),x=m;default:if(y<1){if(b==123)--y;else if(b==125&&y++==0&&Eu()==125)continue}switch(v+=js(b),b*y){case 38:S=l>0?1:(v+="\f",-1);break;case 44:f[h++]=(ct(v)-1)*S,S=1;break;case 64:Qt()===45&&(v+=xn(rt())),g=Qt(),l=u=ct(z=v+=Ou(Ro())),b++;break;case 45:m===45&&ct(v)==2&&(y=0)}}return s}function Ys(t,r,o,n,i,s,p,f,c,h,l,u){for(var g=i-1,x=i===0?s:[""],m=$c(x),y=0,$=0,S=0;y<n;++y)for(var b=0,z=yr(t,g+1,g=Sc($=p[y])),j=t;b<m;++b)(j=zc($>0?x[b]+" "+z:be(z,/&\f/g,x[b])))&&(c[S++]=j);return Jo(t,r,o,i===0?Ko:f,c,h,l,u)}function Au(t,r,o,n){return Jo(t,r,o,kc,js($u()),yr(t,2,-2),0,n)}function Zs(t,r,o,n,i){return Jo(t,r,o,ws,yr(t,0,n),yr(t,n+1,-1),n,i)}function Ic(t,r,o){switch(Su(t,r)){case 5103:return ze+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return ze+t+t;case 4789:return Fr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return ze+t+Fr+t+Ie+t+t;case 5936:switch(Ue(t,r+11)){case 114:return ze+t+Ie+be(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return ze+t+Ie+be(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return ze+t+Ie+be(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return ze+t+Ie+t+t;case 6165:return ze+t+Ie+"flex-"+t+t;case 5187:return ze+t+be(t,/(\w+).+(:[^]+)/,ze+"box-$1$2"+Ie+"flex-$1$2")+t;case 5443:return ze+t+Ie+"flex-item-"+be(t,/flex-|-self/g,"")+(mt(t,/flex-|baseline/)?"":Ie+"grid-row-"+be(t,/flex-|-self/g,""))+t;case 4675:return ze+t+Ie+"flex-line-pack"+be(t,/align-content|flex-|-self/g,"")+t;case 5548:return ze+t+Ie+be(t,"shrink","negative")+t;case 5292:return ze+t+Ie+be(t,"basis","preferred-size")+t;case 6060:return ze+"box-"+be(t,"-grow","")+ze+t+Ie+be(t,"grow","positive")+t;case 4554:return ze+be(t,/([^-])(transform)/g,"$1"+ze+"$2")+t;case 6187:return be(be(be(t,/(zoom-|grab)/,ze+"$1"),/(image-set)/,ze+"$1"),t,"")+t;case 5495:case 3959:return be(t,/(image-set\([^]*)/,ze+"$1$`$1");case 4968:return be(be(t,/(.+:)(flex-)?(.*)/,ze+"box-pack:$3"+Ie+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+ze+t+t;case 4200:if(!mt(t,/flex-|baseline/))return Ie+"grid-column-align"+yr(t,r)+t;break;case 2592:case 3360:return Ie+be(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,i){return r=i,mt(n.props,/grid-\w+-end/)})?~Po(t+(o=o[r].value),"span",0)?t:Ie+be(t,"-start","")+t+Ie+"grid-row-span:"+(~Po(o,"span",0)?mt(o,/\d+/):+mt(o,/\d+/)-+mt(t,/\d+/))+";":Ie+be(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return mt(n.props,/grid-\w+-start/)})?t:Ie+be(be(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return be(t,/(.+)-inline(.+)/,ze+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ct(t)-1-r>6)switch(Ue(t,r+1)){case 109:if(Ue(t,r+4)!==45)break;case 102:return be(t,/(.+:)(.+)-([^]+)/,"$1"+ze+"$2-$3$1"+Fr+(Ue(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~Po(t,"stretch",0)?Ic(be(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return be(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,i,s,p,f,c,h){return Ie+i+":"+s+h+(p?Ie+i+"-span:"+(f?c:+c-+s)+h:"")+t});case 4949:if(Ue(t,r+6)===121)return be(t,":",":"+ze)+t;break;case 6444:switch(Ue(t,Ue(t,14)===45?18:11)){case 120:return be(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+ze+(Ue(t,14)===45?"inline-":"")+"box$3$1"+ze+"$2$3$1"+Ie+"$2box$3")+t;case 100:return be(t,":",":"+Ie)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return be(t,"scroll-","scroll-snap-")+t}return t}function Fo(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Du(t,r,o,n){switch(t.type){case Cu:if(t.children.length)break;case ku:case ws:return t.return=t.return||t.value;case kc:return"";case Cc:return t.return=t.value+"{"+Fo(t.children,n)+"}";case Ko:if(!ct(t.value=t.props.join(",")))return""}return ct(o=Fo(t.children,n))?t.return=t.value+"{"+o+"}":""}function Fu(t){var r=$c(t);return function(o,n,i,s){for(var p="",f=0;f<r;f++)p+=t[f](o,n,i,s)||"";return p}}function Nu(t){return function(r){r.root||(r=r.return)&&t(r)}}function Bu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case ws:t.return=Ic(t.value,t.length,o);return;case Cc:return Fo([zt(t,{value:be(t.value,"@","@"+ze)})],n);case Ko:if(t.length)return zu(o=t.props,function(i){switch(mt(i,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":lr(zt(t,{props:[be(i,/:(read-\w+)/,":"+Fr+"$1")]})),lr(zt(t,{props:[i]})),is(t,{props:qs(o,n)});break;case"::placeholder":lr(zt(t,{props:[be(i,/:(plac\w+)/,":"+ze+"input-$1")]})),lr(zt(t,{props:[be(i,/:(plac\w+)/,":"+Fr+"$1")]})),lr(zt(t,{props:[be(i,/:(plac\w+)/,Ie+"input-$1")]})),lr(zt(t,{props:[i]})),is(t,{props:qs(o,n)});break}return""})}}var Uu={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},rr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Pc="active",Rc="data-styled-version",tn="6.1.19",_s=`/*!sc*/
|
|
19
19
|
`,No=typeof window<"u"&&typeof document<"u",Wu=!!(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"),Qs=/invalid hook call/i,eo=new Set,Vu=function(t,r){if(process.env.NODE_ENV!=="production"){var o=r?' with the id of "'.concat(r,'"'):"",n="The component ".concat(t).concat(o,` has been created dynamically.
|
|
20
20
|
`)+`You may see this warning because you've called styled inside another component.
|
|
21
21
|
To resolve this only create new StyledComponents outside of any render method and function component.
|
|
22
22
|
See https://styled-components.com/docs/basics#define-styled-components-outside-of-the-render-method for more info.
|
|
23
|
-
`,i=console.error;try{var s=!0;console.error=function(
|
|
23
|
+
`,i=console.error;try{var s=!0;console.error=function(p){for(var f=[],c=1;c<arguments.length;c++)f[c-1]=arguments[c];Qs.test(p)?(s=!1,eo.delete(n)):i.apply(void 0,tr([p],f,!1))},a.useRef(),s&&!eo.has(n)&&(console.warn(n),eo.add(n))}catch(p){Qs.test(p.message)&&eo.delete(n)}finally{console.error=i}}},rn=Object.freeze([]),jr=Object.freeze({});function Gu(t,r,o){return o===void 0&&(o=jr),t.theme!==o.theme&&t.theme||r||o.theme}var ls=new Set(["a","abbr","address","area","article","aside","audio","b","base","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","data","datalist","dd","del","details","dfn","dialog","div","dl","dt","em","embed","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","html","i","iframe","img","input","ins","kbd","keygen","label","legend","li","link","main","map","mark","menu","menuitem","meta","meter","nav","noscript","object","ol","optgroup","option","output","p","param","picture","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","tr","track","u","ul","use","var","video","wbr","circle","clipPath","defs","ellipse","foreignObject","g","image","line","linearGradient","marker","mask","path","pattern","polygon","polyline","radialGradient","rect","stop","svg","text","tspan"]),Hu=/[!"#$%&'()*+,./:;<=>?@[\\\]^`{|}~-]+/g,qu=/(^-|-$)/g;function Ks(t){return t.replace(Hu,"-").replace(qu,"")}var Yu=/(a)(d)/gi,to=52,Xs=function(t){return String.fromCharCode(t+(t>25?39:97))};function ds(t){var r,o="";for(r=Math.abs(t);r>to;r=r/to|0)o=Xs(r%to)+o;return(Xs(r%to)+o).replace(Yu,"$1-$2")}var vn,Tc=5381,qt=function(t,r){for(var o=r.length;o;)t=33*t^r.charCodeAt(--o);return t},Mc=function(t){return qt(Tc,t)};function Oc(t){return ds(Mc(t)>>>0)}function Lc(t){return process.env.NODE_ENV!=="production"&&typeof t=="string"&&t||t.displayName||t.name||"Component"}function bn(t){return typeof t=="string"&&(process.env.NODE_ENV==="production"||t.charAt(0)===t.charAt(0).toLowerCase())}var Ac=typeof Symbol=="function"&&Symbol.for,Dc=Ac?Symbol.for("react.memo"):60115,Zu=Ac?Symbol.for("react.forward_ref"):60112,Qu={childContextTypes:!0,contextType:!0,contextTypes:!0,defaultProps:!0,displayName:!0,getDefaultProps:!0,getDerivedStateFromError:!0,getDerivedStateFromProps:!0,mixins:!0,propTypes:!0,type:!0},Ku={name:!0,length:!0,prototype:!0,caller:!0,callee:!0,arguments:!0,arity:!0},Fc={$$typeof:!0,compare:!0,defaultProps:!0,displayName:!0,propTypes:!0,type:!0},Xu=((vn={})[Zu]={$$typeof:!0,render:!0,defaultProps:!0,displayName:!0,propTypes:!0},vn[Dc]=Fc,vn);function Js(t){return("type"in(r=t)&&r.type.$$typeof)===Dc?Fc:"$$typeof"in t?Xu[t.$$typeof]:Qu;var r}var Ju=Object.defineProperty,ep=Object.getOwnPropertyNames,ei=Object.getOwnPropertySymbols,tp=Object.getOwnPropertyDescriptor,rp=Object.getPrototypeOf,ti=Object.prototype;function Nc(t,r,o){if(typeof r!="string"){if(ti){var n=rp(r);n&&n!==ti&&Nc(t,n,o)}var i=ep(r);ei&&(i=i.concat(ei(r)));for(var s=Js(t),p=Js(r),f=0;f<i.length;++f){var c=i[f];if(!(c in Ku||o&&o[c]||p&&c in p||s&&c in s)){var h=tp(r,c);try{Ju(t,c,h)}catch{}}}}return t}function _r(t){return typeof t=="function"}function ks(t){return typeof t=="object"&&"styledComponentId"in t}function Zt(t,r){return t&&r?"".concat(t," ").concat(r):t||r||""}function us(t,r){if(t.length===0)return"";for(var o=t[0],n=1;n<t.length;n++)o+=t[n];return o}function kr(t){return t!==null&&typeof t=="object"&&t.constructor.name===Object.name&&!("props"in t&&t.$$typeof)}function ps(t,r,o){if(o===void 0&&(o=!1),!o&&!kr(t)&&!Array.isArray(t))return r;if(Array.isArray(r))for(var n=0;n<r.length;n++)t[n]=ps(t[n],r[n]);else if(kr(r))for(var n in r)t[n]=ps(t[n],r[n]);return t}function Cs(t,r){Object.defineProperty(t,"toString",{value:r})}var op=process.env.NODE_ENV!=="production"?{1:`Cannot create styled-component for component: %s.
|
|
24
24
|
|
|
25
25
|
`,2:`Can't collect styles once you've consumed a \`ServerStyleSheet\`'s styles! \`ServerStyleSheet\` is a one off instance for each server-side render cycle.
|
|
26
26
|
|
|
@@ -61,7 +61,7 @@ as for instance in your render method then you may be running into this limitati
|
|
|
61
61
|
|
|
62
62
|
`,17:`CSSStyleSheet could not be found on HTMLStyleElement.
|
|
63
63
|
Has styled-components' style tag been unmounted or altered by another script?
|
|
64
|
-
`,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function np(){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(u){o=o.replace(/%[a-z]/,u)}),o}function zr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(np.apply(void 0,tr([op[t]],r,!1)).trim())}var sp=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 zr(16,"".concat(r));this.groupSizes=new Uint32Array(s),this.groupSizes.set(n),this.length=s;for(var u=i;u<s;u++)this.groupSizes[u]=0}for(var f=this.indexOfGroup(r+1),c=(u=0,o.length);u<c;u++)this.tag.insertRule(f,o[u])&&(this.groupSizes[r]++,f++)},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,u=i;u<s;u++)o+="".concat(this.tag.getRule(u)).concat(_s);return o},t}(),ip=1<<30,Mo=new Map,Bo=new Map,Oo=1,ro=function(t){if(Mo.has(t))return Mo.get(t);for(;Bo.has(Oo);)Oo++;var r=Oo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>ip))throw zr(16,"".concat(r));return Mo.set(t,r),Bo.set(r,t),r},ap=function(t,r){Oo=r+1,Mo.set(t,r),Bo.set(r,t)},cp="style[".concat(rr,"][").concat(Rc,'="').concat(tn,'"]'),lp=new RegExp("^".concat(rr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),dp=function(t,r,o){for(var n,i=o.split(","),s=0,u=i.length;s<u;s++)(n=i[s])&&t.registerName(r,n)},up=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(_s),i=[],s=0,u=n.length;s<u;s++){var f=n[s].trim();if(f){var c=f.match(lp);if(c){var h=0|parseInt(c[1],10),l=c[2];h!==0&&(ap(l,h),dp(t,l,c[3]),t.getTag().insertRules(h,i)),i.length=0}else i.push(f)}}},ri=function(t){for(var r=document.querySelectorAll(cp),o=0,n=r.length;o<n;o++){var i=r[o];i&&i.getAttribute(rr)!==Pc&&(up(t,i),i.parentNode&&i.parentNode.removeChild(i))}};function pp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var Bc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),i=function(f){var c=Array.from(f.querySelectorAll("style[".concat(rr,"]")));return c[c.length-1]}(o),s=i!==void 0?i.nextSibling:null;n.setAttribute(rr,Pc),n.setAttribute(Rc,tn);var u=pp();return u&&n.setAttribute("nonce",u),o.insertBefore(n,s),n},hp=function(){function t(r){this.element=Bc(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 u=n[i];if(u.ownerNode===o)return u}throw zr(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),fp=function(){function t(r){this.element=Bc(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}(),gp=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}(),oi=No,mp={isServer:!No,useCSSOMInjection:!Wu},Uc=function(){function t(r,o,n){r===void 0&&(r=jr),o===void 0&&(o={});var i=this;this.options=qe(qe({},mp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&No&&oi&&(oi=!1,ri(this)),Cs(this,function(){return function(s){for(var u=s.getTag(),f=u.length,c="",h=function(p){var g=function(S){return Bo.get(S)}(p);if(g===void 0)return"continue";var x=s.names.get(g),m=u.getGroup(p);if(x===void 0||!x.size||m.length===0)return"continue";var y="".concat(rr,".g").concat(p,'[id="').concat(g,'"]'),$="";x!==void 0&&x.forEach(function(S){S.length>0&&($+="".concat(S,","))}),c+="".concat(m).concat(y,'{content:"').concat($,'"}').concat(_s)},l=0;l<f;l++)h(l);return c}(i)})}return t.registerId=function(r){return ro(r)},t.prototype.rehydrate=function(){!this.server&&No&&ri(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(qe(qe({},this.options),r),this.gs,o&&this.names||void 0)},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=function(o){var n=o.useCSSOMInjection,i=o.target;return o.isServer?new gp(i):n?new hp(i):new fp(i)}(this.options),new sp(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(ro(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(ro(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(ro(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),xp=/&/g,vp=/^\s*\/\/.*$/gm;function Wc(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=Wc(o.children,r)),o})}function bp(t){var r,o,n,i=jr,s=i.options,u=s===void 0?jr:s,f=i.plugins,c=f===void 0?rn:f,h=function(g,x,m){return m.startsWith(o)&&m.endsWith(o)&&m.replaceAll(o,"").length>0?".".concat(r):g},l=c.slice();l.push(function(g){g.type===Ko&&g.value.includes("&")&&(g.props[0]=g.props[0].replace(xp,o).replace(n,h))}),u.prefix&&l.push(Bu),l.push(Du);var p=function(g,x,m,y){x===void 0&&(x=""),m===void 0&&(m=""),y===void 0&&(y="&"),r=y,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var $=g.replace(vp,""),S=Lu(m||x?"".concat(m," ").concat(x," { ").concat($," }"):$);u.namespace&&(S=Wc(S,u.namespace));var b=[];return Fo(S,Fu(l.concat(Nu(function(z){return b.push(z)})))),b};return p.hash=c.length?c.reduce(function(g,x){return x.name||zr(15),qt(g,x.name)},Tc).toString():"",p}var yp=new Uc,hs=bp(),Vc=a.createContext({shouldForwardProp:void 0,styleSheet:yp,stylis:hs});Vc.Consumer;a.createContext(void 0);function ni(){return a.useContext(Vc)}var fs=function(){function t(r,o){var n=this;this.inject=function(i,s){s===void 0&&(s=hs);var u=n.name+s.hash;i.hasNameForId(n.id,u)||i.insertRules(n.id,u,s(n.rules,u,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,Cs(this,function(){throw zr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=hs),this.name+r.hash},t}(),wp=function(t){return t>="A"&&t<="Z"};function si(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;wp(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Gc=function(t){return t==null||t===!1||t===""},Hc=function(t){var r,o,n=[];for(var i in t){var s=t[i];t.hasOwnProperty(i)&&!Gc(s)&&(Array.isArray(s)&&s.isCss||_r(s)?n.push("".concat(si(i),":"),s,";"):kr(s)?n.push.apply(n,tr(tr(["".concat(i," {")],Hc(s),!1),["}"],!1)):n.push("".concat(si(i),": ").concat((r=i,(o=s)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Uu||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Kt(t,r,o,n){if(Gc(t))return[];if(ks(t))return[".".concat(t.styledComponentId)];if(_r(t)){if(!_r(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 fs||kr(i)||i===null||console.error("".concat(Lc(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Kt(i,r,o,n)}var s;return t instanceof fs?o?(t.inject(o,n),[t.getName(n)]):[t]:kr(t)?Hc(t):Array.isArray(t)?Array.prototype.concat.apply(rn,t.map(function(u){return Kt(u,r,o,n)})):[t.toString()]}function jp(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(_r(o)&&!ks(o))return!1}return!0}var _p=Mc(tn),kp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&jp(r),this.componentId=o,this.baseHash=qt(_p,o),this.baseStyle=n,Uc.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var i=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))i=Zt(i,this.staticRulesId);else{var s=us(Kt(this.rules,r,o,n)),u=ds(qt(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,u)){var f=n(s,".".concat(u),void 0,this.componentId);o.insertRules(this.componentId,u,f)}i=Zt(i,u),this.staticRulesId=u}else{for(var c=qt(this.baseHash,n.hash),h="",l=0;l<this.rules.length;l++){var p=this.rules[l];if(typeof p=="string")h+=p,process.env.NODE_ENV!=="production"&&(c=qt(c,p));else if(p){var g=us(Kt(p,r,o,n));c=qt(c,g+l),h+=g}}if(h){var x=ds(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(h,".".concat(x),void 0,this.componentId)),i=Zt(i,x)}}return i},t}(),qc=a.createContext(void 0);qc.Consumer;var yn={},ii=new Set;function Cp(t,r,o){var n=ks(t),i=t,s=!bn(t),u=r.attrs,f=u===void 0?rn:u,c=r.componentId,h=c===void 0?function(j,k){var _=typeof j!="string"?"sc":Ks(j);yn[_]=(yn[_]||0)+1;var v="".concat(_,"-").concat(Oc(tn+_+yn[_]));return k?"".concat(k,"-").concat(v):v}(r.displayName,r.parentComponentId):c,l=r.displayName,p=l===void 0?function(j){return bn(j)?"styled.".concat(j):"Styled(".concat(Lc(j),")")}(t):l,g=r.displayName&&r.componentId?"".concat(Ks(r.displayName),"-").concat(r.componentId):r.componentId||h,x=n&&i.attrs?i.attrs.concat(f).filter(Boolean):f,m=r.shouldForwardProp;if(n&&i.shouldForwardProp){var y=i.shouldForwardProp;if(r.shouldForwardProp){var $=r.shouldForwardProp;m=function(j,k){return y(j,k)&&$(j,k)}}else m=y}var S=new kp(o,g,n?i.componentStyle:void 0);function b(j,k){return function(_,v,P){var C=_.attrs,E=_.componentStyle,T=_.defaultProps,R=_.foldedComponentIds,w=_.styledComponentId,I=_.target,M=a.useContext(qc),L=ni(),U=_.shouldForwardProp||L.shouldForwardProp;process.env.NODE_ENV!=="production"&&a.useDebugValue(w);var F=Gu(v,M,T)||jr,O=function(oe,te,de){for(var ne,ue=qe(qe({},te),{className:void 0,theme:de}),X=0;X<oe.length;X+=1){var ae=_r(ne=oe[X])?ne(ue):ne;for(var Z in ae)ue[Z]=Z==="className"?Zt(ue[Z],ae[Z]):Z==="style"?qe(qe({},ue[Z]),ae[Z]):ae[Z]}return te.className&&(ue.className=Zt(ue.className,te.className)),ue}(C,v,F),A=O.as||I,Q={};for(var ee in O)O[ee]===void 0||ee[0]==="$"||ee==="as"||ee==="theme"&&O.theme===F||(ee==="forwardedAs"?Q.as=O.forwardedAs:U&&!U(ee,A)||(Q[ee]=O[ee],U||process.env.NODE_ENV!=="development"||_u(ee)||ii.has(ee)||!ls.has(A)||(ii.add(ee),console.warn('styled-components: it looks like an unknown prop "'.concat(ee,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var W=function(oe,te){var de=ni(),ne=oe.generateAndInjectStyles(te,de.styleSheet,de.stylis);return process.env.NODE_ENV!=="production"&&a.useDebugValue(ne),ne}(E,O);process.env.NODE_ENV!=="production"&&_.warnTooManyClasses&&_.warnTooManyClasses(W);var K=Zt(R,w);return W&&(K+=" "+W),O.className&&(K+=" "+O.className),Q[bn(A)&&!ls.has(A)?"class":"className"]=K,P&&(Q.ref=P),a.createElement(A,Q)}(z,j,k)}b.displayName=p;var z=a.forwardRef(b);return z.attrs=x,z.componentStyle=S,z.displayName=p,z.shouldForwardProp=m,z.foldedComponentIds=n?Zt(i.foldedComponentIds,i.styledComponentId):"",z.styledComponentId=g,z.target=n?i.target:t,Object.defineProperty(z,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(j){this._foldedDefaultProps=n?function(k){for(var _=[],v=1;v<arguments.length;v++)_[v-1]=arguments[v];for(var P=0,C=_;P<C.length;P++)ps(k,C[P],!0);return k}({},i.defaultProps,j):j}}),process.env.NODE_ENV!=="production"&&(Vu(p,g),z.warnTooManyClasses=function(j,k){var _={},v=!1;return function(P){if(!v&&(_[P]=!0,Object.keys(_).length>=200)){var C=k?' with the id of "'.concat(k,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(j).concat(C,`.
|
|
64
|
+
`,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function np(){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(p){o=o.replace(/%[a-z]/,p)}),o}function zr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(np.apply(void 0,tr([op[t]],r,!1)).trim())}var sp=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 zr(16,"".concat(r));this.groupSizes=new Uint32Array(s),this.groupSizes.set(n),this.length=s;for(var p=i;p<s;p++)this.groupSizes[p]=0}for(var f=this.indexOfGroup(r+1),c=(p=0,o.length);p<c;p++)this.tag.insertRule(f,o[p])&&(this.groupSizes[r]++,f++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),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,p=i;p<s;p++)o+="".concat(this.tag.getRule(p)).concat(_s);return o},t}(),ip=1<<30,Mo=new Map,Bo=new Map,Oo=1,ro=function(t){if(Mo.has(t))return Mo.get(t);for(;Bo.has(Oo);)Oo++;var r=Oo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>ip))throw zr(16,"".concat(r));return Mo.set(t,r),Bo.set(r,t),r},ap=function(t,r){Oo=r+1,Mo.set(t,r),Bo.set(r,t)},cp="style[".concat(rr,"][").concat(Rc,'="').concat(tn,'"]'),lp=new RegExp("^".concat(rr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),dp=function(t,r,o){for(var n,i=o.split(","),s=0,p=i.length;s<p;s++)(n=i[s])&&t.registerName(r,n)},up=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(_s),i=[],s=0,p=n.length;s<p;s++){var f=n[s].trim();if(f){var c=f.match(lp);if(c){var h=0|parseInt(c[1],10),l=c[2];h!==0&&(ap(l,h),dp(t,l,c[3]),t.getTag().insertRules(h,i)),i.length=0}else i.push(f)}}},ri=function(t){for(var r=document.querySelectorAll(cp),o=0,n=r.length;o<n;o++){var i=r[o];i&&i.getAttribute(rr)!==Pc&&(up(t,i),i.parentNode&&i.parentNode.removeChild(i))}};function pp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var Bc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),i=function(f){var c=Array.from(f.querySelectorAll("style[".concat(rr,"]")));return c[c.length-1]}(o),s=i!==void 0?i.nextSibling:null;n.setAttribute(rr,Pc),n.setAttribute(Rc,tn);var p=pp();return p&&n.setAttribute("nonce",p),o.insertBefore(n,s),n},hp=function(){function t(r){this.element=Bc(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 p=n[i];if(p.ownerNode===o)return p}throw zr(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),fp=function(){function t(r){this.element=Bc(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}(),gp=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}(),oi=No,mp={isServer:!No,useCSSOMInjection:!Wu},Uc=function(){function t(r,o,n){r===void 0&&(r=jr),o===void 0&&(o={});var i=this;this.options=qe(qe({},mp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&No&&oi&&(oi=!1,ri(this)),Cs(this,function(){return function(s){for(var p=s.getTag(),f=p.length,c="",h=function(u){var g=function(S){return Bo.get(S)}(u);if(g===void 0)return"continue";var x=s.names.get(g),m=p.getGroup(u);if(x===void 0||!x.size||m.length===0)return"continue";var y="".concat(rr,".g").concat(u,'[id="').concat(g,'"]'),$="";x!==void 0&&x.forEach(function(S){S.length>0&&($+="".concat(S,","))}),c+="".concat(m).concat(y,'{content:"').concat($,'"}').concat(_s)},l=0;l<f;l++)h(l);return c}(i)})}return t.registerId=function(r){return ro(r)},t.prototype.rehydrate=function(){!this.server&&No&&ri(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(qe(qe({},this.options),r),this.gs,o&&this.names||void 0)},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=function(o){var n=o.useCSSOMInjection,i=o.target;return o.isServer?new gp(i):n?new hp(i):new fp(i)}(this.options),new sp(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(ro(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(ro(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(ro(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),xp=/&/g,vp=/^\s*\/\/.*$/gm;function Wc(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=Wc(o.children,r)),o})}function bp(t){var r,o,n,i=jr,s=i.options,p=s===void 0?jr:s,f=i.plugins,c=f===void 0?rn:f,h=function(g,x,m){return m.startsWith(o)&&m.endsWith(o)&&m.replaceAll(o,"").length>0?".".concat(r):g},l=c.slice();l.push(function(g){g.type===Ko&&g.value.includes("&")&&(g.props[0]=g.props[0].replace(xp,o).replace(n,h))}),p.prefix&&l.push(Bu),l.push(Du);var u=function(g,x,m,y){x===void 0&&(x=""),m===void 0&&(m=""),y===void 0&&(y="&"),r=y,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var $=g.replace(vp,""),S=Lu(m||x?"".concat(m," ").concat(x," { ").concat($," }"):$);p.namespace&&(S=Wc(S,p.namespace));var b=[];return Fo(S,Fu(l.concat(Nu(function(z){return b.push(z)})))),b};return u.hash=c.length?c.reduce(function(g,x){return x.name||zr(15),qt(g,x.name)},Tc).toString():"",u}var yp=new Uc,hs=bp(),Vc=a.createContext({shouldForwardProp:void 0,styleSheet:yp,stylis:hs});Vc.Consumer;a.createContext(void 0);function ni(){return a.useContext(Vc)}var fs=function(){function t(r,o){var n=this;this.inject=function(i,s){s===void 0&&(s=hs);var p=n.name+s.hash;i.hasNameForId(n.id,p)||i.insertRules(n.id,p,s(n.rules,p,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,Cs(this,function(){throw zr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=hs),this.name+r.hash},t}(),wp=function(t){return t>="A"&&t<="Z"};function si(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;wp(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Gc=function(t){return t==null||t===!1||t===""},Hc=function(t){var r,o,n=[];for(var i in t){var s=t[i];t.hasOwnProperty(i)&&!Gc(s)&&(Array.isArray(s)&&s.isCss||_r(s)?n.push("".concat(si(i),":"),s,";"):kr(s)?n.push.apply(n,tr(tr(["".concat(i," {")],Hc(s),!1),["}"],!1)):n.push("".concat(si(i),": ").concat((r=i,(o=s)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Uu||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Kt(t,r,o,n){if(Gc(t))return[];if(ks(t))return[".".concat(t.styledComponentId)];if(_r(t)){if(!_r(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 fs||kr(i)||i===null||console.error("".concat(Lc(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Kt(i,r,o,n)}var s;return t instanceof fs?o?(t.inject(o,n),[t.getName(n)]):[t]:kr(t)?Hc(t):Array.isArray(t)?Array.prototype.concat.apply(rn,t.map(function(p){return Kt(p,r,o,n)})):[t.toString()]}function jp(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(_r(o)&&!ks(o))return!1}return!0}var _p=Mc(tn),kp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&jp(r),this.componentId=o,this.baseHash=qt(_p,o),this.baseStyle=n,Uc.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var i=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))i=Zt(i,this.staticRulesId);else{var s=us(Kt(this.rules,r,o,n)),p=ds(qt(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,p)){var f=n(s,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,f)}i=Zt(i,p),this.staticRulesId=p}else{for(var c=qt(this.baseHash,n.hash),h="",l=0;l<this.rules.length;l++){var u=this.rules[l];if(typeof u=="string")h+=u,process.env.NODE_ENV!=="production"&&(c=qt(c,u));else if(u){var g=us(Kt(u,r,o,n));c=qt(c,g+l),h+=g}}if(h){var x=ds(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(h,".".concat(x),void 0,this.componentId)),i=Zt(i,x)}}return i},t}(),qc=a.createContext(void 0);qc.Consumer;var yn={},ii=new Set;function Cp(t,r,o){var n=ks(t),i=t,s=!bn(t),p=r.attrs,f=p===void 0?rn:p,c=r.componentId,h=c===void 0?function(j,k){var _=typeof j!="string"?"sc":Ks(j);yn[_]=(yn[_]||0)+1;var v="".concat(_,"-").concat(Oc(tn+_+yn[_]));return k?"".concat(k,"-").concat(v):v}(r.displayName,r.parentComponentId):c,l=r.displayName,u=l===void 0?function(j){return bn(j)?"styled.".concat(j):"Styled(".concat(Lc(j),")")}(t):l,g=r.displayName&&r.componentId?"".concat(Ks(r.displayName),"-").concat(r.componentId):r.componentId||h,x=n&&i.attrs?i.attrs.concat(f).filter(Boolean):f,m=r.shouldForwardProp;if(n&&i.shouldForwardProp){var y=i.shouldForwardProp;if(r.shouldForwardProp){var $=r.shouldForwardProp;m=function(j,k){return y(j,k)&&$(j,k)}}else m=y}var S=new kp(o,g,n?i.componentStyle:void 0);function b(j,k){return function(_,v,P){var C=_.attrs,E=_.componentStyle,T=_.defaultProps,R=_.foldedComponentIds,w=_.styledComponentId,I=_.target,M=a.useContext(qc),O=ni(),U=_.shouldForwardProp||O.shouldForwardProp;process.env.NODE_ENV!=="production"&&a.useDebugValue(w);var F=Gu(v,M,T)||jr,L=function(oe,te,de){for(var ne,ue=qe(qe({},te),{className:void 0,theme:de}),X=0;X<oe.length;X+=1){var ae=_r(ne=oe[X])?ne(ue):ne;for(var Z in ae)ue[Z]=Z==="className"?Zt(ue[Z],ae[Z]):Z==="style"?qe(qe({},ue[Z]),ae[Z]):ae[Z]}return te.className&&(ue.className=Zt(ue.className,te.className)),ue}(C,v,F),A=L.as||I,Q={};for(var ee in L)L[ee]===void 0||ee[0]==="$"||ee==="as"||ee==="theme"&&L.theme===F||(ee==="forwardedAs"?Q.as=L.forwardedAs:U&&!U(ee,A)||(Q[ee]=L[ee],U||process.env.NODE_ENV!=="development"||_u(ee)||ii.has(ee)||!ls.has(A)||(ii.add(ee),console.warn('styled-components: it looks like an unknown prop "'.concat(ee,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var W=function(oe,te){var de=ni(),ne=oe.generateAndInjectStyles(te,de.styleSheet,de.stylis);return process.env.NODE_ENV!=="production"&&a.useDebugValue(ne),ne}(E,L);process.env.NODE_ENV!=="production"&&_.warnTooManyClasses&&_.warnTooManyClasses(W);var K=Zt(R,w);return W&&(K+=" "+W),L.className&&(K+=" "+L.className),Q[bn(A)&&!ls.has(A)?"class":"className"]=K,P&&(Q.ref=P),a.createElement(A,Q)}(z,j,k)}b.displayName=u;var z=a.forwardRef(b);return z.attrs=x,z.componentStyle=S,z.displayName=u,z.shouldForwardProp=m,z.foldedComponentIds=n?Zt(i.foldedComponentIds,i.styledComponentId):"",z.styledComponentId=g,z.target=n?i.target:t,Object.defineProperty(z,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(j){this._foldedDefaultProps=n?function(k){for(var _=[],v=1;v<arguments.length;v++)_[v-1]=arguments[v];for(var P=0,C=_;P<C.length;P++)ps(k,C[P],!0);return k}({},i.defaultProps,j):j}}),process.env.NODE_ENV!=="production"&&(Vu(u,g),z.warnTooManyClasses=function(j,k){var _={},v=!1;return function(P){if(!v&&(_[P]=!0,Object.keys(_).length>=200)){var C=k?' with the id of "'.concat(k,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(j).concat(C,`.
|
|
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 />`),v=!0,_={}}}}(
|
|
73
|
+
<Component />`),v=!0,_={}}}}(u,g)),Cs(z,function(){return".".concat(z.styledComponentId)}),s&&Nc(z,t,{attrs:!0,componentStyle:!0,displayName:!0,foldedComponentIds:!0,shouldForwardProp:!0,styledComponentId:!0,target:!0}),z}function ai(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 ci=function(t){return Object.assign(t,{isCss:!0})};function Xt(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];if(_r(t)||kr(t))return ci(Kt(ai(rn,tr([t],r,!0))));var n=t;return r.length===0&&n.length===1&&typeof n[0]=="string"?Kt(n):ci(Kt(ai(n,r)))}function gs(t,r,o){if(o===void 0&&(o=jr),!r)throw zr(1,r);var n=function(i){for(var s=[],p=1;p<arguments.length;p++)s[p-1]=arguments[p];return t(r,o,Xt.apply(void 0,tr([i],s,!1)))};return n.attrs=function(i){return gs(t,r,qe(qe({},o),{attrs:Array.prototype.concat(o.attrs,i).filter(Boolean)}))},n.withConfig=function(i){return gs(t,r,qe(qe({},o),i))},n}var Yc=function(t){return gs(Cp,t)},d=Yc;ls.forEach(function(t){d[t]=Yc(t)});function ir(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];process.env.NODE_ENV!=="production"&&typeof navigator<"u"&&navigator.product==="ReactNative"&&console.warn("`keyframes` cannot be used on ReactNative, only on the web. To do animation in ReactNative please use Animated.");var n=us(Xt.apply(void 0,tr([t],r,!1))),i=Oc(n);return new fs(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 oo="__sc-".concat(rr,"__");process.env.NODE_ENV!=="production"&&process.env.NODE_ENV!=="test"&&typeof window<"u"&&(window[oo]||(window[oo]=0),window[oo]===1&&console.warn(`It looks like there are several instances of 'styled-components' initialized in this application. This may cause dynamic styles to not render properly, errors during the rehydration process, a missing theme prop, and makes your application bigger without good reason.
|
|
76
76
|
|
|
@@ -89,7 +89,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
89
89
|
*
|
|
90
90
|
* This source code is licensed under the ISC license.
|
|
91
91
|
* See the LICENSE file in the root directory of this source tree.
|
|
92
|
-
*/const $p=a.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:i="",children:s,iconNode:
|
|
92
|
+
*/const $p=a.forwardRef(({color:t="currentColor",size:r=24,strokeWidth:o=2,absoluteStrokeWidth:n,className:i="",children:s,iconNode:p,...f},c)=>a.createElement("svg",{ref:c,...zp,width:r,height:r,stroke:t,strokeWidth:n?Number(o)*24/Number(r):o,className:Zc("lucide",i),...f},[...p.map(([h,l])=>a.createElement(h,l)),...Array.isArray(s)?s:[s]]));/**
|
|
93
93
|
* @license lucide-react v0.474.0 - ISC
|
|
94
94
|
*
|
|
95
95
|
* This source code is licensed under the ISC license.
|
|
@@ -507,7 +507,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
507
507
|
font-size: var(--font-xs);
|
|
508
508
|
display: block;
|
|
509
509
|
text-align: center;
|
|
510
|
-
`;function Tt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:i=!1}){const[s,
|
|
510
|
+
`;function Tt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:i=!1}){const[s,p]=a.useState(new Array(t).fill("")),[f,c]=a.useState(60),[h,l]=a.useState(!1),u=a.useRef([]),g=a.useCallback(()=>{const S=setInterval(()=>{c(b=>b<=1?(l(!0),clearInterval(S),0):b-1)},1e3);return S},[]);a.useEffect(()=>{const S=g();return()=>clearInterval(S)},[g]);const x=async()=>{var S;!h||i||!o||(await o(),l(!1),c(60),p(new Array(t).fill("")),(S=u.current[0])==null||S.focus(),g())},m=(S,b)=>{var _;if(i)return;const z=S.value,j=[...s];j[b]=z.replace(/[^0-9]/g,""),p(j);const k=j.join("");k.length===t&&r(k),z&&b<t-1&&((_=u.current[b+1])==null||_.focus())},y=(S,b)=>{var z;i||S.key==="Backspace"&&!s[b]&&b>0&&((z=u.current[b-1])==null||z.focus())},$=(S,b)=>{var v,P,C;if(i)return;S.preventDefault();const j=S.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if(j.length===0)return;const k=[...s];for(let E=0;E<j.length&&b+E<t;E++)k[b+E]=j[E];if(b===0&&j.length===t)for(let E=0;E<t;E++)k[E]=j[E];p(k);const _=k.join("");if(_.length===t)r(_),(v=u.current[t-1])==null||v.focus();else{const E=k.findIndex((T,R)=>R>=b&&!T);if(E!==-1)(P=u.current[E])==null||P.focus();else{const T=k.map((R,w)=>R?w:-1).filter(R=>R!==-1).pop();T!==void 0&&T<t-1&&((C=u.current[T+1])==null||C.focus())}}};return e.jsxs(Eh,{children:[e.jsx(Ih,{children:s.map((S,b)=>e.jsx(Ph,{type:"text",maxLength:1,value:S,onChange:z=>m(z.target,b),onKeyDown:z=>y(z,b),onPaste:z=>$(z,b),ref:z=>{u.current[b]=z},disabled:i,autoFocus:b===0},b))}),n&&e.jsx(Rh,{children:n}),o&&e.jsx("div",{children:h?e.jsx(Th,{type:"button",onClick:x,disabled:i,children:"Didn't receive a code? Resend"}):e.jsxs(Mh,{children:["Resend code in ",f,"s"]})})]})}const Xc=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"})]}),Jc=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"})]}),el=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"})]}),tl=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"})}),Oh=()=>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"})}),rl=()=>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"})}),ol=()=>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"})]}),Lh=()=>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"})}),nl=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),e.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),kn={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(el,{})},microsoft_oauth:{shortLabel:"Microsoft",fullLabel:"Continue with Microsoft",icon:e.jsx(Jc,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(Xc,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(tl,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(Oh,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(rl,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(ol,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(Lh,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(nl,{})}},Ah=d.div`
|
|
511
511
|
display: flex;
|
|
512
512
|
flex-direction: column;
|
|
513
513
|
gap: var(--space-xs);
|
|
@@ -551,7 +551,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
551
551
|
height: 16px;
|
|
552
552
|
flex-shrink: 0;
|
|
553
553
|
}
|
|
554
|
-
`,zs=({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(Ah,{children:i.map((s,
|
|
554
|
+
`,zs=({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(Ah,{children:i.map((s,p)=>e.jsx(Dh,{children:s.map((f,c)=>{const h=f.provider;return e.jsxs(Fh,{onClick:()=>r(f),type:"button",$isWide:i.length>1&&p<i.length-1,$totalProviders:n,children:[kn[h].icon,n<3&&e.jsx("span",{children:n===1?kn[h].fullLabel:kn[h].shortLabel})]},`${f.provider}-${c}`)})},`row-${p}`))})},ot=({to:t,replace:r,children:o,...n})=>{const{navigate:i}=Ge(),s=a.useCallback(p=>{p.preventDefault(),i(t,{replace:r})},[t,r,i]);return e.jsx("a",{href:t,onClick:s,...n,children:o})},Nh={sm:"36rem"},le=d.input`
|
|
555
555
|
padding: var(--space-sm) var(--space-md);
|
|
556
556
|
width: 100%;
|
|
557
557
|
height: 36px;
|
|
@@ -713,7 +713,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
713
713
|
}
|
|
714
714
|
`,Yh=d(le)`
|
|
715
715
|
flex: 1;
|
|
716
|
-
`,Yr=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:i})=>{const[s,
|
|
716
|
+
`,Yr=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:i})=>{const[s,p]=a.useState(!1),[f,c]=a.useState(Lo.find(m=>m.code===n)||Lo[0]),h=a.useRef(null),[l,u]=a.useState(""),g=a.useRef(null);a.useEffect(()=>{function m(y){h.current&&!h.current.contains(y.target)&&p(!1)}return document.addEventListener("mousedown",m),()=>{document.removeEventListener("mousedown",m)}},[]);const x=Lo.filter(m=>m.name.toLowerCase().includes(l.toLowerCase())||m.dialCode.includes(l));return a.useEffect(()=>{i(f.dialCode)},[f,i]),e.jsxs(Bh,{children:[e.jsxs(Uh,{ref:h,children:[e.jsxs(Wh,{type:"button",onClick:()=>p(m=>!m),children:[e.jsx("span",{children:f.flag}),e.jsx("span",{children:f.dialCode})]}),e.jsxs(Vh,{$isOpen:s,children:[e.jsx(Gh,{type:"text",placeholder:"Search country...",value:l,onChange:m=>u(m.target.value),onClick:m=>m.stopPropagation()}),e.jsx(Hh,{children:x.map(m=>e.jsxs(qh,{onClick:y=>{var $;y.stopPropagation(),y.preventDefault(),c(m),p(!1),($=g.current)==null||$.focus()},children:[e.jsx("span",{children:m.flag}),e.jsx("span",{children:m.name}),e.jsx("span",{className:"country-code",children:m.dialCode})]},m.code))})]})]}),e.jsx(Yh,{style:{height:"100%"},type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:g,value:t,onChange:r,placeholder:"Phone number","aria-invalid":!!o,pattern:"^\\d{7,15}$"})]})},Zh=d.div`
|
|
717
717
|
display: flex;
|
|
718
718
|
justify-content: center;
|
|
719
719
|
margin-bottom: var(--space-lg);
|
|
@@ -921,7 +921,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
921
921
|
`,pr=d.span`
|
|
922
922
|
color: var(--color-danger);
|
|
923
923
|
margin-left: 2px;
|
|
924
|
-
`;function lf(){var W,K,oe,te,de,ne,ue,X,ae,Z,q,B,ie,H,se,we,xe;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=hc(),{signIn:i}=Br("oauth"),{deployment:s}=me(),{navigate:u}=Ge(),{session:f,refetch:c,loading:h}=Be(),[l,p]=a.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[g,x]=a.useState({}),[m,y]=a.useState(!1),[$,S]=a.useState(void 0),[b,z]=a.useState(null),[j,k]=a.useState(null),[_,v]=a.useState(!1),P=((W=s==null?void 0:s.restrictions)==null?void 0:W.sign_up_mode)==="restricted",C=((K=s==null?void 0:s.restrictions)==null?void 0:K.sign_up_mode)==="waitlist",E=((te=(oe=s==null?void 0:s.auth_settings)==null?void 0:oe.multi_session_support)==null?void 0:te.enabled)??!1;a.useEffect(()=>{var ge;if(!h&&(f!=null&&f.active_signin)&&!E&&!_){v(!0);let V=new URLSearchParams(window.location.search).get("redirect_uri");V||(V=((ge=s==null?void 0:s.ui_settings)==null?void 0:ge.after_signin_redirect_url)||null),!V&&(s!=null&&s.frontend_host)&&(V=`https://${s.frontend_host}`),!V&&(s!=null&&s.frontend_host)&&(V=`https://${s.frontend_host}`),V&&u(V)}},[f,h,E,s,u,_]),a.useEffect(()=>{var D;if(!s)return;const V=new URLSearchParams(window.location.search).get("invite_token");if(C&&!V){v(!0);const N=((D=s.ui_settings)==null?void 0:D.waitlist_page_url)||`https://${s.frontend_host}/waitlist`;u(N);return}V&&!b&&r&&(k(V),r.validateDeploymentInvitation(V).then(N=>{z(N),N.valid&&p(re=>({...re,first_name:N.first_name||re.first_name,last_name:N.last_name||re.last_name,email:N.email||re.email}))}).catch(N=>{console.error("Failed to validate invitation:",N)}))},[s,C,u,b,r]);const[T,R]=a.useState(!1),[w,I]=a.useState(""),M=ge=>{let{name:V,value:D}=ge.target;V==="phone_number"?D=D.replace(/[^0-9-]/g,""):V==="email"&&(D=D.toLowerCase()),p(N=>({...N,[V]:D})),x(N=>({...N,[V]:""}))},L=()=>{p({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),R(!1),I(""),n()},U=async ge=>{if(ge.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",l),t||m)return;const V={},D=/^[a-zA-Z]{3,30}$/,N=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,re=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,pe=/^\d{7,15}$/,J=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!l.first_name?V.first_name="First name is required":l.first_name&&!D.test(l.first_name)&&(V.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!l.last_name?V.last_name="Last name is required":l.last_name&&!D.test(l.last_name)&&(V.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!l.username?V.username="Username is required":l.username&&!N.test(l.username)&&(V.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!l.email?V.email="Email address is required":l.email&&!re.test(l.email)&&(V.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!l.phone_number?V.phone_number="Phone number is required":l.phone_number&&!pe.test(l.phone_number)&&(V.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(l.password?J.test(l.password)||(V.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):V.password="Password is required"),x(V),Object.keys(V).length>0){console.log("Signup validation failed. Errors:",V);return}console.log("Signup validation passed"),y(!0);try{const _e={...l};l.phone_number&&$&&(_e.phone_country_code=$),j&&(_e.invite_token=j),console.log("Submitting signup data:",_e),console.log("Phone number:",_e.phone_number),console.log("Phone country code:",_e.phone_country_code),await r.create(_e)}catch(_e){x({submit:_e.message})}finally{y(!1)}},F=async ge=>{if(!(t||m)){y(!0);try{const D=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:N}=await i.create({provider:ge.provider,redirectUri:D});N&&typeof N=="object"&&"oauth_url"in N&&(window.location.href=N.oauth_url)}catch(V){x({submit:V.message})}finally{y(!1)}}},O=(s==null?void 0:s.social_connections.filter(ge=>ge.enabled))||[],A=s==null?void 0:s.auth_settings,Q=!!((de=A==null?void 0:A.first_name)!=null&&de.enabled&&((ne=A==null?void 0:A.last_name)!=null&&ne.enabled)),ee=async ge=>{var D;if(ge.preventDefault(),t||m)return;y(!0);const V={};if(!w){V.otp="OTP code is required",x(V),y(!1);return}x(V);try{const N=await r.completeVerification(w);"data"in N&&((D=N.data)!=null&&D.active_signin)&&await c()}catch(N){console.error("Verification failed:",N)}finally{y(!1)}};return a.useEffect(()=>{var ge;if(o){if(o.completed){let V=new URLSearchParams(window.location.search).get("redirect_uri");if(V||(V=((ge=s==null?void 0:s.ui_settings)==null?void 0:ge.after_signup_redirect_url)||null),!V&&(s!=null&&s.frontend_host)&&(V=`https://${s.frontend_host}`),V){const D=new URL(V);(s==null?void 0:s.mode)==="staging"&&D.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),u(D.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[o,r,T,s,f,u]),h?e.jsx(fe,{children:e.jsxs(no,{children:[e.jsx(Pe,{}),e.jsx(di,{children:e.jsx(bt,{size:32})})]})}):_?e.jsx(fe,{children:e.jsxs(no,{children:[e.jsx(Pe,{}),e.jsx(di,{children:e.jsx(bt,{size:32})})]})}):P?e.jsx(fe,{children:e.jsxs(no,{children:[e.jsx(Pe,{}),e.jsx(Cn,{children:e.jsx(Sn,{children:"Sign up Restricted!"})}),e.jsx(of,{children:e.jsx(nf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(sf,{children:e.jsxs(af,{children:["Need assistance?"," ",e.jsx(cf,{href:(ue=s==null?void 0:s.ui_settings)!=null&&ue.sign_in_page_url?`${s.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(fe,{children:e.jsx(no,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(Cn,{children:[e.jsxs(Sn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ui,{children:(o==null?void 0:o.current_step)==="verify_email"?`${l.email} to continue to ${(X=s==null?void 0:s.ui_settings)==null?void 0:X.app_name}`:`${l.phone_number} to continue to ${(ae=s==null?void 0:s.ui_settings)==null?void 0:ae.app_name}`})]}),e.jsxs(pi,{style:{gap:"15px"},onSubmit:ee,noValidate:!0,children:[e.jsx(Tt,{onComplete:async ge=>{I(ge)},onResend:async()=>{const ge=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:ge})},error:g.otp,isSubmitting:m}),e.jsx(hi,{type:"submit",disabled:m||t||!w,children:m?"Verifying...":`Continue to ${(Z=s==null?void 0:s.ui_settings)==null?void 0:Z.app_name}`})]}),e.jsxs(fi,{children:["Having trouble?"," ",e.jsx(zn,{children:e.jsx(ot,{to:s.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(zn,{onClick:()=>{L()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(Cn,{children:[e.jsx(Sn,{children:"Create your account"}),e.jsx(ui,{children:b!=null&&b.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),O.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(zs,{connections:O,callback:F}),e.jsx(Jh,{children:e.jsx(ef,{children:"or"})})]}),e.jsxs(pi,{onSubmit:U,noValidate:!0,children:[(((q=A==null?void 0:A.first_name)==null?void 0:q.enabled)||((B=A==null?void 0:A.last_name)==null?void 0:B.enabled))&&e.jsxs(tf,{$isBothEnabled:Q,children:[((ie=A==null?void 0:A.first_name)==null?void 0:ie.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"first_name",children:["First name",((H=A==null?void 0:A.first_name)==null?void 0:H.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:M,placeholder:"First name","aria-invalid":!!g.first_name,pattern:"^[a-zA-Z]{3,30}$"}),g.first_name&&e.jsx(Lt,{children:g.first_name})]}),((se=A==null?void 0:A.last_name)==null?void 0:se.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"last_name",children:["Last name",((we=A==null?void 0:A.last_name)==null?void 0:we.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:M,placeholder:"Last name","aria-invalid":!!g.last_name,pattern:"^[a-zA-Z]{3,30}$"}),g.last_name&&e.jsx(Lt,{children:g.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:M,placeholder:"Choose a username","aria-invalid":!!g.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),g.username&&e.jsx(Lt,{children:g.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:M,placeholder:"Enter your email address","aria-invalid":!!g.email,required:!0,readOnly:(b==null?void 0:b.valid)&&!!(b!=null&&b.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),g.email&&e.jsx(Lt,{children:g.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(pr,{children:"*"})]}),e.jsx(Yr,{value:l.phone_number,onChange:M,error:g.phone_number,countryCode:$,setCountryCode:S}),g.phone_number&&e.jsx(Lt,{children:g.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(pr,{children:"*"})]}),e.jsx(rf,{children:e.jsx(le,{type:"password",id:"password",name:"password",value:l.password,onChange:M,placeholder:"Enter your password","aria-invalid":!!g.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),g.password&&e.jsx(Lt,{children:g.password})]}),g.submit&&e.jsx(Lt,{children:g.submit}),e.jsx(hi,{type:"submit",disabled:m||t,children:m?"Creating account...":"Continue"})]}),e.jsxs(fi,{children:["Already have an account?"," ",e.jsx(zn,{children:e.jsx(ot,{to:`${(xe=s.ui_settings)==null?void 0:xe.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const sl=a.createContext(void 0),il=()=>{const t=a.useContext(sl);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},df=d.div`
|
|
924
|
+
`;function lf(){var W,K,oe,te,de,ne,ue,X,ae,Z,q,B,ie,H,se,we,xe;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=hc(),{signIn:i}=Br("oauth"),{deployment:s}=me(),{navigate:p}=Ge(),{session:f,refetch:c,loading:h}=Be(),[l,u]=a.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[g,x]=a.useState({}),[m,y]=a.useState(!1),[$,S]=a.useState(void 0),[b,z]=a.useState(null),[j,k]=a.useState(null),[_,v]=a.useState(!1),P=((W=s==null?void 0:s.restrictions)==null?void 0:W.sign_up_mode)==="restricted",C=((K=s==null?void 0:s.restrictions)==null?void 0:K.sign_up_mode)==="waitlist",E=((te=(oe=s==null?void 0:s.auth_settings)==null?void 0:oe.multi_session_support)==null?void 0:te.enabled)??!1;a.useEffect(()=>{var ge;if(!h&&(f!=null&&f.active_signin)&&!E&&!_){v(!0);let V=new URLSearchParams(window.location.search).get("redirect_uri");V||(V=((ge=s==null?void 0:s.ui_settings)==null?void 0:ge.after_signin_redirect_url)||null),!V&&(s!=null&&s.frontend_host)&&(V=`https://${s.frontend_host}`),!V&&(s!=null&&s.frontend_host)&&(V=`https://${s.frontend_host}`),V&&p(V)}},[f,h,E,s,p,_]),a.useEffect(()=>{var D;if(!s)return;const V=new URLSearchParams(window.location.search).get("invite_token");if(C&&!V){v(!0);const N=((D=s.ui_settings)==null?void 0:D.waitlist_page_url)||`https://${s.frontend_host}/waitlist`;p(N);return}V&&!b&&r&&(k(V),r.validateDeploymentInvitation(V).then(N=>{z(N),N.valid&&u(re=>({...re,first_name:N.first_name||re.first_name,last_name:N.last_name||re.last_name,email:N.email||re.email}))}).catch(N=>{console.error("Failed to validate invitation:",N)}))},[s,C,p,b,r]);const[T,R]=a.useState(!1),[w,I]=a.useState(""),M=ge=>{let{name:V,value:D}=ge.target;V==="phone_number"?D=D.replace(/[^0-9-]/g,""):V==="email"&&(D=D.toLowerCase()),u(N=>({...N,[V]:D})),x(N=>({...N,[V]:""}))},O=()=>{u({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),R(!1),I(""),n()},U=async ge=>{if(ge.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",l),t||m)return;const V={},D=/^[a-zA-Z]{3,30}$/,N=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,re=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,pe=/^\d{7,15}$/,J=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!l.first_name?V.first_name="First name is required":l.first_name&&!D.test(l.first_name)&&(V.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!l.last_name?V.last_name="Last name is required":l.last_name&&!D.test(l.last_name)&&(V.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!l.username?V.username="Username is required":l.username&&!N.test(l.username)&&(V.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!l.email?V.email="Email address is required":l.email&&!re.test(l.email)&&(V.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!l.phone_number?V.phone_number="Phone number is required":l.phone_number&&!pe.test(l.phone_number)&&(V.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(l.password?J.test(l.password)||(V.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):V.password="Password is required"),x(V),Object.keys(V).length>0){console.log("Signup validation failed. Errors:",V);return}console.log("Signup validation passed"),y(!0);try{const _e={...l};l.phone_number&&$&&(_e.phone_country_code=$),j&&(_e.invite_token=j),console.log("Submitting signup data:",_e),console.log("Phone number:",_e.phone_number),console.log("Phone country code:",_e.phone_country_code),await r.create(_e)}catch(_e){x({submit:_e.message})}finally{y(!1)}},F=async ge=>{if(!(t||m)){y(!0);try{const D=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:N}=await i.create({provider:ge.provider,redirectUri:D});N&&typeof N=="object"&&"oauth_url"in N&&(window.location.href=N.oauth_url)}catch(V){x({submit:V.message})}finally{y(!1)}}},L=(s==null?void 0:s.social_connections.filter(ge=>ge.enabled))||[],A=s==null?void 0:s.auth_settings,Q=!!((de=A==null?void 0:A.first_name)!=null&&de.enabled&&((ne=A==null?void 0:A.last_name)!=null&&ne.enabled)),ee=async ge=>{var D;if(ge.preventDefault(),t||m)return;y(!0);const V={};if(!w){V.otp="OTP code is required",x(V),y(!1);return}x(V);try{const N=await r.completeVerification(w);"data"in N&&((D=N.data)!=null&&D.active_signin)&&await c()}catch(N){console.error("Verification failed:",N)}finally{y(!1)}};return a.useEffect(()=>{var ge;if(o){if(o.completed){let V=new URLSearchParams(window.location.search).get("redirect_uri");if(V||(V=((ge=s==null?void 0:s.ui_settings)==null?void 0:ge.after_signup_redirect_url)||null),!V&&(s!=null&&s.frontend_host)&&(V=`https://${s.frontend_host}`),V){const D=new URL(V);(s==null?void 0:s.mode)==="staging"&&D.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(D.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}R(!0)}}},[o,r,T,s,f,p]),h?e.jsx(fe,{children:e.jsxs(no,{children:[e.jsx(Pe,{}),e.jsx(di,{children:e.jsx(bt,{size:32})})]})}):_?e.jsx(fe,{children:e.jsxs(no,{children:[e.jsx(Pe,{}),e.jsx(di,{children:e.jsx(bt,{size:32})})]})}):P?e.jsx(fe,{children:e.jsxs(no,{children:[e.jsx(Pe,{}),e.jsx(Cn,{children:e.jsx(Sn,{children:"Sign up Restricted!"})}),e.jsx(of,{children:e.jsx(nf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(sf,{children:e.jsxs(af,{children:["Need assistance?"," ",e.jsx(cf,{href:(ue=s==null?void 0:s.ui_settings)!=null&&ue.sign_in_page_url?`${s.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(fe,{children:e.jsx(no,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(Cn,{children:[e.jsxs(Sn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ui,{children:(o==null?void 0:o.current_step)==="verify_email"?`${l.email} to continue to ${(X=s==null?void 0:s.ui_settings)==null?void 0:X.app_name}`:`${l.phone_number} to continue to ${(ae=s==null?void 0:s.ui_settings)==null?void 0:ae.app_name}`})]}),e.jsxs(pi,{style:{gap:"15px"},onSubmit:ee,noValidate:!0,children:[e.jsx(Tt,{onComplete:async ge=>{I(ge)},onResend:async()=>{const ge=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:ge})},error:g.otp,isSubmitting:m}),e.jsx(hi,{type:"submit",disabled:m||t||!w,children:m?"Verifying...":`Continue to ${(Z=s==null?void 0:s.ui_settings)==null?void 0:Z.app_name}`})]}),e.jsxs(fi,{children:["Having trouble?"," ",e.jsx(zn,{children:e.jsx(ot,{to:s.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(zn,{onClick:()=>{O()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(Cn,{children:[e.jsx(Sn,{children:"Create your account"}),e.jsx(ui,{children:b!=null&&b.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),L.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(zs,{connections:L,callback:F}),e.jsx(Jh,{children:e.jsx(ef,{children:"or"})})]}),e.jsxs(pi,{onSubmit:U,noValidate:!0,children:[(((q=A==null?void 0:A.first_name)==null?void 0:q.enabled)||((B=A==null?void 0:A.last_name)==null?void 0:B.enabled))&&e.jsxs(tf,{$isBothEnabled:Q,children:[((ie=A==null?void 0:A.first_name)==null?void 0:ie.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"first_name",children:["First name",((H=A==null?void 0:A.first_name)==null?void 0:H.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:M,placeholder:"First name","aria-invalid":!!g.first_name,pattern:"^[a-zA-Z]{3,30}$"}),g.first_name&&e.jsx(Lt,{children:g.first_name})]}),((se=A==null?void 0:A.last_name)==null?void 0:se.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"last_name",children:["Last name",((we=A==null?void 0:A.last_name)==null?void 0:we.required)&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:M,placeholder:"Last name","aria-invalid":!!g.last_name,pattern:"^[a-zA-Z]{3,30}$"}),g.last_name&&e.jsx(Lt,{children:g.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:M,placeholder:"Choose a username","aria-invalid":!!g.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),g.username&&e.jsx(Lt,{children:g.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(pr,{children:"*"})]}),e.jsx(le,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:M,placeholder:"Enter your email address","aria-invalid":!!g.email,required:!0,readOnly:(b==null?void 0:b.valid)&&!!(b!=null&&b.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),g.email&&e.jsx(Lt,{children:g.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(pr,{children:"*"})]}),e.jsx(Yr,{value:l.phone_number,onChange:M,error:g.phone_number,countryCode:$,setCountryCode:S}),g.phone_number&&e.jsx(Lt,{children:g.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(dr,{children:[e.jsxs(ur,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(pr,{children:"*"})]}),e.jsx(rf,{children:e.jsx(le,{type:"password",id:"password",name:"password",value:l.password,onChange:M,placeholder:"Enter your password","aria-invalid":!!g.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),g.password&&e.jsx(Lt,{children:g.password})]}),g.submit&&e.jsx(Lt,{children:g.submit}),e.jsx(hi,{type:"submit",disabled:m||t,children:m?"Creating account...":"Continue"})]}),e.jsxs(fi,{children:["Already have an account?"," ",e.jsx(zn,{children:e.jsx(ot,{to:`${(xe=s.ui_settings)==null?void 0:xe.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const sl=a.createContext(void 0),il=()=>{const t=a.useContext(sl);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},df=d.div`
|
|
925
925
|
position: fixed;
|
|
926
926
|
inset: 0;
|
|
927
927
|
background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
|
|
@@ -971,7 +971,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
971
971
|
gap: 8px;
|
|
972
972
|
padding: 16px;
|
|
973
973
|
border-top: 1px solid var(--color-border);
|
|
974
|
-
`,xf=({isOpen:t,onClose:r,children:o})=>{const[n,i]=a.useState(!1);return a.useEffect(()=>{i(!0);const s=
|
|
974
|
+
`,xf=({isOpen:t,onClose:r,children:o})=>{const[n,i]=a.useState(!1);return a.useEffect(()=>{i(!0);const s=p=>{p.key==="Escape"&&t&&(r==null||r())};return document.addEventListener("keydown",s),()=>{document.removeEventListener("keydown",s)}},[t,r]),!t||!n?null:Wr.createPortal(e.jsx(fe,{children:e.jsx(sl.Provider,{value:{isOpen:t,onClose:r},children:o})}),document.body)},vf=({children:t})=>{const{onClose:r}=il(),o=a.useRef(null),n=i=>{o.current&&!o.current.contains(i.target)&&(r==null||r())};return e.jsx(df,{onClick:n,children:e.jsx("div",{ref:o,children:t})})},bf=({children:t,style:r})=>e.jsx(uf,{style:r,children:t}),yf=({children:t,showCloseButton:r=!0})=>{const{onClose:o}=il();return e.jsxs(pf,{children:[typeof t=="string"?e.jsx(hf,{children:t}):t,r&&e.jsx(ff,{onClick:o,children:e.jsx(Je,{size:18})})]})},wf=({children:t,style:r})=>e.jsx(gf,{style:r,children:t}),jf=({children:t})=>e.jsx(mf,{children:t}),ke=Object.assign(xf,{Overlay:vf,Content:bf,Header:yf,Body:wf,Footer:jf}),_f=({isOpen:t,onClose:r,title:o,children:n,showCloseButton:i=!0})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{children:[o&&e.jsx(ke.Header,{showCloseButton:i,children:o}),e.jsx(ke.Body,{children:n})]})})}),kf=({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})]})},Cf=d.div`
|
|
975
975
|
position: fixed;
|
|
976
976
|
background: var(--color-background);
|
|
977
977
|
border-radius: 8px;
|
|
@@ -983,7 +983,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
983
983
|
display: grid;
|
|
984
984
|
`,Sf=d.div`
|
|
985
985
|
width: fit-content;
|
|
986
|
-
`,al=a.createContext(void 0),cl=()=>{const t=a.useContext(al);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},nt=({children:t,open:r,openChange:o,style:n})=>{const i=a.useRef(null),[s,
|
|
986
|
+
`,al=a.createContext(void 0),cl=()=>{const t=a.useContext(al);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},nt=({children:t,open:r,openChange:o,style:n})=>{const i=a.useRef(null),[s,p]=a.useState(!1);return a.useEffect(()=>{const f=c=>{i.current&&!i.current.contains(c.target)&&p(!1)};return s&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[s,o]),a.useEffect(()=>{o==null||o(s)},[s]),a.useEffect(()=>{p(!!r)},[r]),e.jsx(al.Provider,{value:{open:s,openChange:f=>p(f)},children:e.jsx(Sf,{style:n,ref:i,children:t})})},st=({children:t,style:r})=>{const{open:o}=cl(),[n,i]=a.useState({top:0,left:0}),[s,p]=a.useState(!1),f=a.useRef(null);return a.useEffect(()=>{o&&f.current?(p(!1),requestAnimationFrame(()=>{var l,u;const c=(l=f.current)==null?void 0:l.parentElement;if(!c)return;const h=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(h&&h!==f.current){const g=h.getBoundingClientRect(),x=(u=f.current)==null?void 0:u.getBoundingClientRect(),m=window.innerWidth,y=window.innerHeight;let $=g.bottom+4,S=g.right-200;S<8&&(S=g.left),S+200>m-8&&(S=m-208),x&&$+x.height>y-8&&($=g.top-(x.height+4)),i({top:$,left:S}),p(!0)}})):p(!1)},[o]),o?e.jsx(Cf,{ref:f,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},it=({children:t})=>{const{openChange:r,open:o}=cl(),n=a.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Te=d.button`
|
|
987
987
|
width: 100%;
|
|
988
988
|
padding: 8px 12px;
|
|
989
989
|
background: none;
|
|
@@ -1065,7 +1065,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
1065
1065
|
left: ${t=>t.checked?"20px":"2px"};
|
|
1066
1066
|
transition: left 0.2s ease;
|
|
1067
1067
|
}
|
|
1068
|
-
`,Cr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(If,{children:[e.jsx(Pf,{type:"checkbox",checked:t,onChange:o}),e.jsx(Rf,{checked:t})]})},Dr=(t=!1)=>{const[r,o]=a.useState(t),n=a.useCallback(()=>{o(!0)},[]),i=a.useCallback(()=>{o(!1)},[]),s=a.useCallback(()=>{o(
|
|
1068
|
+
`,Cr=({checked:t,onChange:r})=>{const o=n=>{r(n.target.checked)};return e.jsxs(If,{children:[e.jsx(Pf,{type:"checkbox",checked:t,onChange:o}),e.jsx(Rf,{checked:t})]})},Dr=(t=!1)=>{const[r,o]=a.useState(t),n=a.useCallback(()=>{o(!0)},[]),i=a.useCallback(()=>{o(!1)},[]),s=a.useCallback(()=>{o(p=>!p)},[]);return{isOpen:r,open:n,close:i,toggle:s}},jt=({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(gh,{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"}})]}),Y=d.button`
|
|
1069
1069
|
width: 100%;
|
|
1070
1070
|
padding: var(--space-sm) var(--space-md);
|
|
1071
1071
|
border: 1px solid transparent;
|
|
@@ -1207,7 +1207,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
1207
1207
|
text-transform: uppercase;
|
|
1208
1208
|
color: var(--color-muted);
|
|
1209
1209
|
background: var(--color-background-hover);
|
|
1210
|
-
`,$s=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:i=!1,searchable:s=!1,width:
|
|
1210
|
+
`,$s=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:i=!1,searchable:s=!1,width:p,name:f,id:c,groupsEnabled:h=!1,className:l})=>{const[u,g]=a.useState(!1),[x,m]=a.useState(""),y=a.useRef(null),$=a.useRef(null),S=h&&"options"in t[0],z=(S?t.flatMap(v=>v.options):t).find(v=>v.value===r),j=x?S?t.map(v=>({...v,options:v.options.filter(P=>P.label.toLowerCase().includes(x.toLowerCase()))})).filter(v=>v.options.length>0):t.filter(v=>v.label.toLowerCase().includes(x.toLowerCase())):t,k=(v,P=!1)=>{P||(o(v),g(!1),m(""))},_=()=>{i||g(!u)};return a.useEffect(()=>{u&&s&&$.current&&setTimeout(()=>{var v;(v=$.current)==null||v.focus()},10)},[u,s]),a.useEffect(()=>{const v=P=>{y.current&&!y.current.contains(P.target)&&(g(!1),m(""))};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),e.jsxs(ll,{ref:y,style:{width:p},className:l,children:[e.jsxs(dl,{type:"button",onClick:_,disabled:i,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[z?z.label:e.jsx(hl,{children:n}),u?e.jsx(Qc,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(ul,{isOpen:u,role:"listbox",children:[s&&e.jsx(pl,{ref:$,type:"text",placeholder:"Search...",value:x,onChange:v=>m(v.target.value),onClick:v=>v.stopPropagation()}),S?j.map((v,P)=>e.jsxs(a.Fragment,{children:[e.jsx(fl,{children:v.label}),v.options.length===0?e.jsx(Go,{children:"No options available"}):v.options.map(C=>e.jsxs(Vo,{isSelected:C.value===r,disabled:C.disabled,onClick:()=>k(C.value,C.disabled),role:"option","aria-selected":C.value===r,children:[C.label,C.value===r&&e.jsx(Ve,{size:16})]},C.value))]},`group-${P}`)):e.jsx(e.Fragment,{children:j.length===0?e.jsx(Go,{children:"No options available"}):j.map(v=>e.jsxs(Vo,{isSelected:v.value===r,disabled:v.disabled,onClick:()=>k(v.value,v.disabled),role:"option","aria-selected":v.value===r,children:[v.label,v.value===r&&e.jsx(Ve,{size:16})]},v.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r||""})]})},gl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:i=!1,searchable:s=!1,width:p,name:f,id:c,groupsEnabled:h=!1,className:l})=>{const[u,g]=a.useState(!1),[x,m]=a.useState(""),y=a.useRef(null),$=a.useRef(null),S=h&&"options"in t[0],z=(S?t.flatMap(v=>v.options):t).filter(v=>r.includes(v.value)),j=x?S?t.map(v=>({...v,options:v.options.filter(P=>P.label.toLowerCase().includes(x.toLowerCase()))})).filter(v=>v.options.length>0):t.filter(v=>v.label.toLowerCase().includes(x.toLowerCase())):t,k=(v,P=!1)=>{P||(r.includes(v)?o(r.filter(C=>C!==v)):o([...r,v]))},_=()=>{i||g(!u)};return a.useEffect(()=>{u&&s&&$.current&&setTimeout(()=>{var v;(v=$.current)==null||v.focus()},10)},[u,s]),a.useEffect(()=>{const v=P=>{y.current&&!y.current.contains(P.target)&&(g(!1),m(""))};return document.addEventListener("mousedown",v),()=>{document.removeEventListener("mousedown",v)}},[]),e.jsxs(ll,{ref:y,style:{width:p},className:l,children:[e.jsxs(dl,{type:"button",onClick:_,disabled:i,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[z.length>0?z.map(v=>v.label).join(", "):e.jsx(hl,{children:n}),u?e.jsx(Qc,{size:16}):e.jsx(or,{size:16})]}),e.jsxs(ul,{isOpen:u,role:"listbox",children:[s&&e.jsx(pl,{ref:$,type:"text",placeholder:"Search...",value:x,onChange:v=>m(v.target.value),onClick:v=>v.stopPropagation()}),S?j.map((v,P)=>e.jsxs(a.Fragment,{children:[e.jsx(fl,{children:v.label}),v.options.length===0?e.jsx(Go,{children:"No options available"}):v.options.map(C=>e.jsxs(Vo,{isSelected:r.includes(C.value),disabled:C.disabled,onClick:()=>k(C.value,C.disabled),role:"option","aria-selected":r.includes(C.value),children:[C.label,r.includes(C.value)&&e.jsx(Ve,{size:16})]},C.value))]},`group-${P}`)):e.jsx(e.Fragment,{children:j.length===0?e.jsx(Go,{children:"No options available"}):j.map(v=>e.jsxs(Vo,{isSelected:r.includes(v.value),disabled:v.disabled,onClick:()=>k(v.value,v.disabled),role:"option","aria-selected":r.includes(v.value),children:[v.label,r.includes(v.value)&&e.jsx(Ve,{size:16})]},v.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r.join(",")})]})},ml=a.createContext(void 0);function xl(){const t=a.useContext(ml);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function Tf({children:t}){const{deployment:r}=me(),[o,n]=a.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[i,s]=a.useState(""),[p,f]=a.useState(!1),[c,h]=a.useState(!1),[l,u]=a.useState(!1),[g,x]=a.useState("identifier"),m=(r==null?void 0:r.social_connections.filter($=>$.enabled))||[],y=r==null?void 0:r.auth_settings;return e.jsx(ml.Provider,{value:{email:i,showOtherOptions:p,showForgotPassword:c,otpSent:l,setFirstFactor:n,setEmail:s,setShowOtherOptions:f,setShowForgotPassword:h,setOtpSent:u,enabledSocialsProviders:m,authSettings:y,firstFactor:o,signInStep:g,setSignInStep:x},children:t})}const Pr=d.button`
|
|
1211
1211
|
width: 100%;
|
|
1212
1212
|
padding: var(--space-sm) var(--space-md);
|
|
1213
1213
|
background: var(--color-input-background);
|
|
@@ -1230,7 +1230,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
1230
1230
|
opacity: 0.7;
|
|
1231
1231
|
cursor: not-allowed;
|
|
1232
1232
|
}
|
|
1233
|
-
`;function vl(){const{deployment:t}=me(),{signIn:r}=Br("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:i,setShowForgotPassword:s}=xl(),[
|
|
1233
|
+
`;function vl(){const{deployment:t}=me(),{signIn:r}=Br("oauth"),{setFirstFactor:o,firstFactor:n,setShowOtherOptions:i,setShowForgotPassword:s}=xl(),[p,f]=a.useState(!1),c=t==null?void 0:t.auth_settings,h=(t==null?void 0:t.social_connections.filter(g=>g.enabled))||[],l=async g=>{if(!p){f(!0);try{const{data:x}=await r.create({provider:g.provider});x&&typeof x=="object"&&"oauth_url"in x&&(window.location.href=x.oauth_url)}catch{}finally{f(!1)}}},u=()=>{s(!1),i(!1)};return e.jsxs(e.Fragment,{children:[h.length>0&&e.jsx(zs,{connections:h,callback:l}),e.jsxs("div",{children:[n!=="email_magic_link"&&(c==null?void 0:c.auth_factors_enabled.email_magic_link)&&e.jsx(Pr,{onClick:()=>{o("email_magic_link"),u()},children:"Get a magic link on your email"}),n!=="email_password"&&(c==null?void 0:c.auth_factors_enabled.email_password)&&e.jsx(Pr,{onClick:()=>{o("email_password"),u()},children:"Sign in with email and password"}),n!=="email_otp"&&(c==null?void 0:c.auth_factors_enabled.email_otp)&&e.jsx(Pr,{onClick:()=>{o("email_otp"),u()},children:"Sign in with email and OTP"}),n!=="phone_otp"&&(c==null?void 0:c.auth_factors_enabled.phone_otp)&&e.jsx(Pr,{onClick:()=>{o("phone_otp"),u()},children:"Sign in with phone number"}),n!=="username_password"&&(c==null?void 0:c.auth_factors_enabled.username_password)&&e.jsx(Pr,{onClick:()=>{o("username_password"),u()},children:"Sign in with username and password"})]})]})}const Mf=d.div`
|
|
1234
1234
|
max-width: 380px;
|
|
1235
1235
|
width: 380px;
|
|
1236
1236
|
padding: var(--space-3xl);
|
|
@@ -1294,7 +1294,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
1294
1294
|
&:hover {
|
|
1295
1295
|
text-decoration: underline;
|
|
1296
1296
|
}
|
|
1297
|
-
`;function Df({onBack:t}){const{deployment:r}=me(),{navigate:o}=Ge(),[n,i]=a.useState("start"),[s,
|
|
1297
|
+
`;function Df({onBack:t}){const{deployment:r}=me(),{navigate:o}=Ge(),[n,i]=a.useState("start"),[s,p]=a.useState(""),[f,c]=a.useState(""),[h,l]=a.useState(""),[u,g]=a.useState(""),[x,m]=a.useState(""),{forgotPassword:y,verifyOtp:$,resetPassword:S}=bc(),[b,z]=a.useState(!1),[j,k]=a.useState(null),_=async E=>{if(E.preventDefault(),!!s){z(!0),k(null);try{await y(s),i("otp")}catch(T){k(T)}finally{z(!1)}}},v=async E=>{if(E.preventDefault(),f.length===6){z(!0),k(null);try{const T=await $(s,f);T.data&&(l(T.data.token),i("reset"))}catch(T){k(T)}finally{z(!1)}}},P=async E=>{var T,R;if(E.preventDefault(),u===x&&!(u.length<8)){z(!0),k(null);try{const w=await S(h,u);if(w.data){const I=w.data,M=I.signin_attempts&&I.signin_attempts.length>0?I.signin_attempts[I.signin_attempts.length-1]:null;if(M&&!M.completed){const O=(T=r==null?void 0:r.ui_settings)==null?void 0:T.sign_in_page_url;if(O){const U=new URL(O,window.location.origin);U.searchParams.set("signin_attempt_id",M.id),o(U.toString())}else t()}else{const O=((R=r==null?void 0:r.ui_settings)==null?void 0:R.after_signin_redirect_url)||"/";o(O)}}}catch(w){k(w)}finally{z(!1)}}},C=()=>e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsx(so,{children:e.jsx(io,{children:"Forgot Password"})}),e.jsx(Of,{onClick:()=>i("email"),disabled:b,children:"Reset your password"}),e.jsx(Lf,{children:e.jsx(Af,{children:"Or, sign in with another method"})}),e.jsx(vl,{}),e.jsxs(ao,{children:[e.jsxs(Rr,{children:["Unable to reset password? ",e.jsx(Tr,{href:"/contact",children:"Get help"})]}),e.jsx(Rr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(fe,{children:e.jsxs(Mf,{children:[n==="start"&&C(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(so,{children:[e.jsx(io,{children:"Forgot Password"}),e.jsx($n,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(dt,{onSubmit:_,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"email",children:"Email Address"}),e.jsx(le,{type:"email",id:"email",value:s,onChange:E=>p(E.target.value),placeholder:"Enter your email",required:!0})]}),j&&e.jsx(En,{children:j.message}),e.jsx(Y,{type:"submit",disabled:b,style:{width:"100%",marginTop:"var(--space-md)"},children:b?"Sending...":"Send Code"})]}),e.jsx(ao,{children:e.jsx(Rr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(so,{children:[e.jsx(io,{children:"Enter Verification Code"}),e.jsxs($n,{children:["We've sent a 6-digit code to ",s,". Please enter it below."]})]}),e.jsxs(dt,{onSubmit:v,noValidate:!0,children:[e.jsx(Tt,{onComplete:E=>c(E),isSubmitting:b,error:j==null?void 0:j.message,onResend:async()=>{await y(s)}}),j&&e.jsx(En,{children:j.message}),e.jsx(Y,{type:"submit",disabled:b||f.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:b?"Verifying...":"Verify"})]}),e.jsx(ao,{children:e.jsx(Rr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Pe,{}),e.jsxs(so,{children:[e.jsx(io,{children:"Reset Password"}),e.jsx($n,{children:"Create a new password for your account."})]}),e.jsxs(dt,{onSubmit:P,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"password",children:"New Password"}),e.jsx(le,{type:"password",id:"password",value:u,onChange:E=>g(E.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(le,{type:"password",id:"confirmPassword",value:x,onChange:E=>m(E.target.value),placeholder:"Confirm new password",required:!0})]}),j&&e.jsx(En,{children:j.message}),e.jsx(Y,{type:"submit",disabled:b,style:{width:"100%",marginTop:"var(--space-md)"},children:b?"Resetting...":"Reset Password"})]}),e.jsx(ao,{children:e.jsx(Rr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Tr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const Ff=d.div`
|
|
1298
1298
|
max-width: 360px;
|
|
1299
1299
|
width: 360px;
|
|
1300
1300
|
padding: var(--space-2xl);
|
|
@@ -1456,7 +1456,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
1456
1456
|
}
|
|
1457
1457
|
`,dg=d(le)`
|
|
1458
1458
|
padding: var(--space-sm) var(--space-md);
|
|
1459
|
-
`;function yl({onVerify:t,onBack:r,loading:o}){const[n,i]=a.useState(""),[s,
|
|
1459
|
+
`;function yl({onVerify:t,onBack:r,loading:o}){const[n,i]=a.useState(""),[s,p]=a.useState(""),f=h=>{if(h.preventDefault(),n.length!==4){p("Please enter the last 4 digits of your phone number");return}t(n)},c=h=>{const l=h.target.value.replace(/\D/g,"").slice(0,4);i(l),p("")};return e.jsx(fe,{children:e.jsxs(rg,{children:[e.jsx(Pe,{}),e.jsxs(og,{children:[e.jsx(ng,{children:"Verify your phone number"}),e.jsx(sg,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(dt,{onSubmit:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(dg,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!s,autoFocus:!0}),s&&e.jsx(ig,{children:s})]}),e.jsx(ag,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(cg,{children:e.jsx(lg,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const ug=()=>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"})}),pg=()=>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"})]}),hg=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),In=d.div`
|
|
1460
1460
|
max-width: 380px;
|
|
1461
1461
|
width: 380px;
|
|
1462
1462
|
padding: var(--space-3xl);
|
|
@@ -1517,7 +1517,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
1517
1517
|
}
|
|
1518
1518
|
`,xg=d(le)`
|
|
1519
1519
|
padding: var(--space-sm) var(--space-md);
|
|
1520
|
-
`;function wl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:i}=me(),[s,
|
|
1520
|
+
`;function wl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:i}=me(),[s,p]=a.useState(""),[f,c]=a.useState({}),[h,l]=a.useState(!1),[u,g]=a.useState(null),[x,m]=a.useState(!0),[y,$]=a.useState(!1),[S,b]=a.useState(""),[z,j]=a.useState(!1),{navigate:k}=Ge(),_=(r==null?void 0:r.available_2fa_methods)||[],v=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(ug,{}),available:_.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(pg,{}),available:_.includes("phone_otp"),phoneNumber:S},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(hg,{}),available:_.includes("backup_code")}].filter(R=>R.available),P=async R=>{g(R),m(!1),R==="phone_otp"&&$(!0)},C=async R=>{var w,I;if(r){l(!0);try{const M=await n({strategy:"phone_otp",lastDigits:R});M&&"data"in M&&((w=M.data)!=null&&w.otp_sent)?((I=M.data)!=null&&I.masked_phone&&b(M.data.masked_phone),$(!1)):c({phone:"Phone number verification failed"})}catch(M){c({phone:M.message})}finally{l(!1)}}},E=async(R,w)=>{if(R.preventDefault(),h)return;const I=w||s,M={};if(I?u==="authenticator"&&I.length!==6?M.code="Authentication code must be 6 digits":u==="phone_otp"&&I.length!==6&&(M.code="SMS code must be 6 digits"):M.code="Verification code is required",c(M),!(Object.keys(M).length>0)){l(!0);try{await o(I)}catch(O){c({submit:O.message})}finally{l(!1)}}},T=R=>{let w=R.target.value;u!=="backup_code"&&(w=w.replace(/\D/g,"").slice(0,6)),p(w),c(I=>({...I,code:""}))};return a.useEffect(()=>{var R;if(r.completed){j(!0);let w=new URLSearchParams(window.location.search).get("redirect_uri");if(w||(w=((R=i==null?void 0:i.ui_settings)==null?void 0:R.after_signin_redirect_url)||null),!w&&(i!=null&&i.frontend_host)&&(w=`https://${i.frontend_host}`),w){const I=new URL(w);(i==null?void 0:i.mode)==="staging"&&I.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),k(I.toString())}return}},[r,i]),z?e.jsx(fe,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsx(gg,{children:e.jsx(bt,{size:32})})]})}):x?v.length===0?e.jsx(fe,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(xi,{children:[e.jsx(vi,{children:"Set Up Two-Factor Authentication"}),e.jsx(bi,{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(wi,{children:[t&&e.jsx("div",{children:e.jsx(Mr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Mr,{children:e.jsx(ot,{to:(i==null?void 0:i.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(bl,{methods:v,onSelectMethod:P,onBack:t}):y&&u==="phone_otp"?e.jsx(yl,{onVerify:C,onBack:()=>{$(!1),m(!0),g(null)},loading:h}):e.jsx(fe,{children:e.jsxs(In,{children:[e.jsx(Pe,{}),e.jsxs(xi,{children:[e.jsx(vi,{children:"Two-factor authentication"}),e.jsxs(bi,{children:[u==="authenticator"&&"Enter the 6-digit code from your authenticator app",u==="phone_otp"&&`Enter the 6-digit code sent to your phone ${S}`,u==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(dt,{onSubmit:E,noValidate:!0,children:[u==="backup_code"?e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"code",children:"Backup code"}),e.jsx(xg,{type:"text",id:"code",name:"code",value:s,onChange:T,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!f.code,autoFocus:!0}),f.code&&e.jsx(yi,{children:f.code})]}):e.jsx(Tt,{onComplete:async R=>{if(p(R),u!=="backup_code"){const w=new Event("submit",{bubbles:!0,cancelable:!0});await E(w,R)}},onResend:u==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:S.slice(-4)})}catch(R){c({submit:R.message})}}:void 0,error:f.code,isSubmitting:h}),e.jsxs("div",{children:[f.submit&&e.jsx(yi,{children:f.submit}),e.jsx(mg,{type:"submit",disabled:h||!s,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(wi,{children:[e.jsx(Mr,{onClick:()=>{m(!0),g(null),p(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Mr,{children:e.jsx(ot,{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(Mr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const Pn=d.div`
|
|
1521
1521
|
max-width: 380px;
|
|
1522
1522
|
width: 380px;
|
|
1523
1523
|
padding: var(--space-3xl);
|
|
@@ -1582,7 +1582,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[oo]+=1);/**
|
|
|
1582
1582
|
transform: rotate(360deg);
|
|
1583
1583
|
}
|
|
1584
1584
|
}
|
|
1585
|
-
`;function jl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:i}){var F,
|
|
1585
|
+
`;function jl({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:i}){var F,L,A,Q,ee,W,K,oe,te;const{deployment:s}=me(),{navigate:p}=Ge(),[f,c]=a.useState({}),[h,l]=a.useState({}),[u,g]=a.useState("US"),[x,m]=a.useState(!1),[y,$]=a.useState(!1),[S,b]=a.useState(null),[z,j]=a.useState(!1),k=S,_=y,v=async de=>{var ne;$(!0),b(null);try{if(await o(de)){j(!0);let X=new URLSearchParams(window.location.search).get("redirect_uri");if(X||(X=((ne=s==null?void 0:s.ui_settings)==null?void 0:ne.after_signin_redirect_url)||null),!X&&(s!=null&&s.frontend_host)&&(X=`https://${s.frontend_host}`),X){const ae=new URL(X);(s==null?void 0:s.mode)==="staging"&&ae.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(ae.toString())}}}catch(ue){const X=ue;throw b(X),X}finally{$(!1)}},P=async de=>{var ne;$(!0),b(null);try{if(await n(de)){j(!0);let X=new URLSearchParams(window.location.search).get("redirect_uri");if(X||(X=((ne=s==null?void 0:s.ui_settings)==null?void 0:ne.after_signin_redirect_url)||null),!X&&(s!=null&&s.frontend_host)&&(X=`https://${s.frontend_host}`),X){const ae=new URL(X);(s==null?void 0:s.mode)==="staging"&&ae.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(ae.toString())}}return!0}catch(ue){return b(ue),!1}finally{$(!1)}};if(z||!t)return e.jsx(fe,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsx(yg,{children:e.jsx(bt,{size:32})})]})});const C=t.missing_fields||[],E="Complete Your Profile",T="Please provide the following information to continue",R=s==null?void 0:s.auth_settings,w=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,I=de=>{const{name:ne,value:ue}=de.target;c(X=>({...X,[ne]:ue})),h[ne]&&l(X=>({...X,[ne]:""}))},M=()=>{const de={};return C.forEach(ne=>{var ae,Z,q,B,ie;const ue=f[ne];let X=!1;switch(ne){case"first_name":X=((ae=R==null?void 0:R.first_name)==null?void 0:ae.enabled)||!1;break;case"last_name":X=((Z=R==null?void 0:R.last_name)==null?void 0:Z.enabled)||!1;break;case"username":X=((q=R==null?void 0:R.username)==null?void 0:q.enabled)||!1;break;case"phone_number":X=((B=R==null?void 0:R.phone_number)==null?void 0:B.enabled)||!1;break;case"email_address":X=((ie=R==null?void 0:R.email_address)==null?void 0:ie.enabled)||!1;break;default:X=!0}if(X&&(!ue||ue.trim()==="")){const H=ne.replace("_"," ").replace(/\b\w/g,se=>se.toUpperCase());de[ne]=`${H} is required`}}),f.username&&C.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(f.username)||(de.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),f.phone_number&&C.includes("phone_number")&&(/^\d{7,15}$/.test(f.phone_number)||(de.phone_number="Phone number must contain 7-15 digits")),f.email&&C.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(f.email)||(de.email_address="Please enter a valid email address")),l(de),Object.keys(de).length===0},O=async de=>{if(de.preventDefault(),!M())return;const ne={...f};f.phone_number&&u&&(ne.phone_country_code=u),await v(ne)},U=de=>{const ne=de.target.value;c(ue=>({...ue,phone_number:ne})),h.phone_number&&l(ue=>({...ue,phone_number:""}))};if(w){const de=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",ne=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",ue=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(fe,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(ji,{children:[e.jsx(_i,{children:de}),e.jsx(ki,{children:ne})]}),e.jsxs(dt,{onSubmit:X=>X.preventDefault(),noValidate:!0,children:[e.jsx(Tt,{onComplete:P,onResend:async()=>{await i({strategy:ue})},error:k==null?void 0:k.message,isSubmitting:_}),k&&e.jsx(At,{style:{marginBottom:"var(--space-md)"},children:k.message})]}),e.jsxs(Ci,{children:[e.jsx("div",{children:e.jsx(co,{onClick:()=>m(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(co,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(fe,{children:e.jsxs(Pn,{children:[e.jsx(Pe,{}),e.jsxs(ji,{children:[e.jsx(_i,{children:E}),e.jsx(ki,{children:T})]}),e.jsxs(dt,{onSubmit:O,noValidate:!0,children:[(C.includes("first_name")||C.includes("last_name"))&&(((F=R==null?void 0:R.first_name)==null?void 0:F.enabled)||((L=R==null?void 0:R.last_name)==null?void 0:L.enabled))&&e.jsxs(vg,{$isBothEnabled:!!((A=R==null?void 0:R.first_name)!=null&&A.enabled&&((Q=R==null?void 0:R.last_name)!=null&&Q.enabled)&&C.includes("first_name")&&C.includes("last_name")),children:[C.includes("first_name")&&((ee=R==null?void 0:R.first_name)==null?void 0:ee.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"first_name",children:["First name ",R.first_name.required&&"*"]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",value:f.first_name||"",onChange:I,placeholder:"Enter your first name","aria-invalid":!!h.first_name,disabled:_,autoComplete:"given-name"}),h.first_name&&e.jsx(At,{children:h.first_name})]}),C.includes("last_name")&&((W=R==null?void 0:R.last_name)==null?void 0:W.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"last_name",children:["Last name ",R.last_name.required&&"*"]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",value:f.last_name||"",onChange:I,placeholder:"Enter your last name","aria-invalid":!!h.last_name,disabled:_,autoComplete:"family-name"}),h.last_name&&e.jsx(At,{children:h.last_name})]})]}),C.includes("username")&&((K=R==null?void 0:R.username)==null?void 0:K.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"username",children:["Username ",R.username.required&&"*"]}),e.jsx(le,{type:"text",id:"username",name:"username",value:f.username||"",onChange:I,placeholder:"Choose a username","aria-invalid":!!h.username,disabled:_,autoComplete:"username"}),h.username&&e.jsx(At,{children:h.username})]}),C.includes("phone_number")&&((oe=R==null?void 0:R.phone_number)==null?void 0:oe.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"phone_number",children:["Phone number ",R.phone_number.required&&"*"]}),e.jsx(Yr,{value:f.phone_number||"",onChange:U,error:h.phone_number,countryCode:u,setCountryCode:g}),h.phone_number&&e.jsx(At,{children:h.phone_number})]}),C.includes("email_address")&&((te=R==null?void 0:R.email_address)==null?void 0:te.enabled)&&e.jsxs(he,{children:[e.jsxs(ce,{htmlFor:"email",children:["Email address ",R.email_address.required&&"*"]}),e.jsx(le,{type:"email",id:"email",name:"email",value:f.email||"",onChange:I,placeholder:"Enter your email address","aria-invalid":!!h.email_address,disabled:_,autoComplete:"email"}),h.email_address&&e.jsx(At,{children:h.email_address})]}),k&&e.jsx(At,{style:{marginBottom:"var(--space-md)"},children:k.message}),e.jsx(bg,{type:"submit",disabled:_,children:_?"Completing...":"Continue"})]}),e.jsxs(Ci,{children:[r&&e.jsx("div",{children:e.jsx(co,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(co,{children:e.jsx(ot,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const wg=ir`
|
|
1586
1586
|
from {
|
|
1587
1587
|
transform: rotate(0deg);
|
|
1588
1588
|
}
|
|
@@ -1691,7 +1691,7 @@ cursor: pointer;
|
|
|
1691
1691
|
&:hover {
|
|
1692
1692
|
color: var(--color-primary-hover);
|
|
1693
1693
|
}
|
|
1694
|
-
`;function Eg(){return e.jsx(Tf,{children:e.jsx(Ig,{})})}function Ig(){var ue,X,ae,Z,q,B,ie,H,se,we,xe,ge;const{deployment:t}=me(),{navigate:r}=Ge(),{session:o,loading:n}=Be(),i=((X=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.multi_session_support)==null?void 0:X.enabled)??!1,{setEmail:s,otpSent:u,setOtpSent:f,showForgotPassword:c,setShowForgotPassword:h,showOtherOptions:l,setShowOtherOptions:p,enabledSocialsProviders:g,firstFactor:x,signInStep:m,setSignInStep:y}=xl(),{loading:$,signIn:S,signinAttempt:b,discardSignInAttempt:z,setSignInAttempt:j}=Br("generic"),{signIn:k}=Br("oauth"),[_,v]=a.useState({email:"",username:"",password:"",phone:""}),[P,C]=a.useState({}),[E,T]=a.useState(!1),[R,w]=a.useState(""),[I,M]=a.useState("US"),[L,U]=a.useState(!1),[F,O]=a.useState(null);a.useEffect(()=>{const V=new URLSearchParams(window.location.search),D=V.get("error"),N=V.get("error_description");if(D==="access_denied"&&N){O(N),V.delete("error"),V.delete("error_description");const re=V.toString()?`${window.location.pathname}?${V.toString()}`:window.location.pathname;window.history.replaceState({},"",re)}},[]),a.useEffect(()=>{var V;if(!n&&(o!=null&&o.active_signin)&&!i&&!L){U(!0);let D=new URLSearchParams(window.location.search).get("redirect_uri");D||(D=((V=t==null?void 0:t.ui_settings)==null?void 0:V.after_signin_redirect_url)||null),!D&&(t!=null&&t.frontend_host)&&(D=`https://${t.frontend_host}`),D&&r(D)}},[o,n,i,t,r,L]);const A=V=>{let{name:D,value:N}=V.target;D==="phone"?N=N.replace(/[^0-9]/g,""):D==="email"&&(s(N),N=N.toLowerCase()),v(re=>({...re,[D]:N})),C(re=>({...re,[D]:""}))},Q=()=>{v({email:"",username:"",password:"",phone:""}),C({}),M("US"),y("identifier")},ee=async V=>{if(!V){C({email:"Email address is required"});return}T(!0),C({});try{const D=await S.identify(V);if(D.strategy==="sso"&&D.connection_id){const re=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,pe=await S.initEnterpriseSso(D.connection_id,re);if(pe&&pe.sso_url){U(!0),window.location.href=pe.sso_url;return}}else if(D.strategy==="social"&&D.provider){const N=g.find(re=>re.provider===D.provider);if(N){const pe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:J}=await k.create({provider:N.provider,redirectUri:pe});if(J&&typeof J=="object"&&"oauth_url"in J){U(!0),window.location.href=J.oauth_url;return}}else y("password")}else y("password")}catch(D){C({submit:D.message})}finally{L||T(!1)}},W=async V=>{if(V.preventDefault(),$||E)return;z();const D={};if(m==="identifier"&&x==="email_password"){if(!_.email){C({email:"Email address is required"});return}await ee(_.email);return}if(x==="email_password"?(_.email||(D.email="Email address is required"),_.password||(D.password="Password is required")):x==="username_password"?(_.username||(D.username="Username is required"),_.password||(D.password="Password is required")):x==="email_otp"||x==="email_magic_link"?_.email||(D.email="Email address is required"):x==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(D.phone="Phone number must contain 7-15 digits"):D.phone="Phone number is required"),C(D),Object.keys(D).length>0)return;let N="";switch(x){case"email_password":N="plain_email";break;case"username_password":N="plain_username";break;case"email_otp":N="email_otp";break;case"email_magic_link":N="magic_link";break;case"phone_otp":N="phone_otp";break}T(!0);try{const re={..._,strategy:N};x==="phone_otp"&&I&&(re.phone_country_code=I),await S.create(re)}catch(re){C({submit:re.message}),T(!1)}},K=async V=>{if(V.preventDefault(),$||E)return;const D={};if(!R){D.otp="OTP code is required",C(D);return}T(!0),C({});try{await S.completeVerification(R),f(!1),w("")}catch(N){C({otp:N.message||"Verification failed"})}finally{T(!1)}},oe=async V=>{if(!($||E)){T(!0);try{const N=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:re}=await k.create({provider:V.provider,redirectUri:N});re&&typeof re=="object"&&"oauth_url"in re&&(window.location.href=re.oauth_url)}catch(D){C({submit:D.message})}finally{T(!1)}}},te=a.useRef(!1);if(a.useEffect(()=>{if(n)return;const V=new URLSearchParams(window.location.search),D=V.get("impersonation_token");if(D&&!b&&!$&&!te.current){te.current=!0,V.delete("impersonation_token");const re=V.toString()?`${window.location.pathname}?${V.toString()} `:window.location.pathname;window.history.replaceState({},"",re),(async()=>{try{T(!0),await S.create({strategy:"impersonation",token:D})}catch(J){C({submit:J.message}),T(!1),te.current=!1}})();return}const N=V.get("signin_attempt_id");if(N&&(o!=null&&o.signin_attempts)&&!b){const re=o.signin_attempts.find(pe=>pe.id===N);if(re){j(re),V.delete("signin_attempt_id");const pe=V.toString()?`${window.location.pathname}?${V.toString()} `:window.location.pathname;window.history.replaceState({},"",pe)}}},[o,n,b,j,$]),a.useEffect(()=>{var re;if(!b)return;if(b.completed){U(!0);let pe=new URLSearchParams(window.location.search).get("redirect_uri");if(pe||(pe=((re=t==null?void 0:t.ui_settings)==null?void 0:re.after_signin_redirect_url)||null),!pe&&(t!=null&&t.frontend_host)&&(pe=`https://${t.frontend_host}`),pe){const J=new URL(pe);(t==null?void 0:t.mode)==="staging"&&J.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(J.toString())}return}if(!S||u)return;const D={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(!D)return;(async()=>{try{await S.prepareVerification({strategy:D}),f(!0)}catch(pe){console.error("Failed to prepare verification:",pe),C({submit:"Failed to send verification. Please try again."})}finally{T(!1)}})()},[b,S,u,f,r,t]),a.useEffect(()=>{},[]),l)return e.jsx(Vf,{onBack:()=>p(!1)});if(c)return e.jsx(Df,{onBack:()=>h(!1)});if((b==null?void 0:b.current_step)==="verify_second_factor")return e.jsx(wl,{attempt:b,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),Q(),f(!1)}});if((b==null?void 0:b.current_step)==="complete_profile")return e.jsx(jl,{attempt:b,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),Q(),f(!1)}});if(n)return e.jsx(fe,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Si,{children:e.jsx(bt,{size:32})})]})});if(L)return e.jsx(fe,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Si,{children:e.jsx(bt,{size:32})})]})});const ne=(b==null?void 0:b.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(b.current_step)&&u;return e.jsx(fe,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),ne?e.jsx(e.Fragment,{children:e.jsxs(zi,{children:[e.jsx($i,{children:x==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Ei,{children:x==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:x==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(zi,{children:[e.jsx($i,{children:"Sign in to your account"}),e.jsxs(Ei,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),F&&e.jsxs(Cg,{children:[e.jsx(Sg,{children:"Access Denied"}),e.jsx(zg,{children:F}),e.jsx($g,{onClick:()=>O(null),children:"Try again"})]}),ne?x==="email_magic_link"?e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{f(!1),z(),Q()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:K,noValidate:!0,children:[e.jsx(Tt,{onComplete:async V=>{if(w(V),V&&V.length===6){T(!0),C({});try{await S.completeVerification(V),f(!1)}catch(D){C({otp:D.message||"Verification failed"})}finally{T(!1)}}},onResend:async()=>{const V=x==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:V})},error:P.otp,isSubmitting:E}),e.jsx(Ii,{type:"submit",disabled:E||$||!R,style:{margin:0},children:E?"Verifying...":`Continue to ${(ge=t==null?void 0:t.ui_settings)==null?void 0:ge.app_name}`})]}),e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{f(!1),z(),Q()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(zs,{connections:g,callback:oe}),e.jsx(jg,{children:e.jsx(_g,{children:"or"})})]}),e.jsxs(dt,{onSubmit:W,noValidate:!0,children:[(x==="email_password"||x==="email_otp"||x==="email_magic_link")&&((Z=(ae=t==null?void 0:t.auth_settings)==null?void 0:ae.email_address)==null?void 0:Z.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"email",children:"Email address"}),e.jsx(le,{type:"email",id:"email",name:"email",value:_.email,onChange:A,placeholder:"Enter your email address","aria-invalid":!!P.email}),P.email&&e.jsx(Or,{children:P.email})]}),x==="username_password"&&((B=(q=t==null?void 0:t.auth_settings)==null?void 0:q.username)==null?void 0:B.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"username",children:"Username"}),e.jsx(le,{type:"text",id:"username",name:"username",value:_.username,onChange:A,placeholder:"Enter your username","aria-invalid":!!P.username}),P.username&&e.jsx(Or,{children:P.username})]}),x==="phone_otp"&&((H=(ie=t==null?void 0:t.auth_settings)==null?void 0:ie.phone_number)==null?void 0:H.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"phone",children:"Phone number"}),e.jsx(Yr,{value:_.phone,onChange:A,error:P.phone,countryCode:I,setCountryCode:M}),P.phone&&e.jsx(Or,{children:P.phone})]}),m==="password"&&(x==="email_password"||x==="username_password")&&((we=(se=t==null?void 0:t.auth_settings)==null?void 0:se.password)==null?void 0:we.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ce,{htmlFor:"password",children:"Password"}),e.jsx(Dt,{style:{fontSize:"12px"},onClick:()=>h(!0),children:"Forgot password?"})]}),e.jsx(kg,{children:e.jsx(le,{type:"password",id:"password",name:"password",value:_.password,onChange:A,placeholder:"Enter your password","aria-invalid":!!P.password})}),P.password&&e.jsx(Or,{children:P.password})]}),e.jsxs("div",{children:[P.submit&&e.jsx(Or,{children:P.submit}),e.jsx(Ii,{type:"submit",disabled:E||$,children:E?e.jsxs(e.Fragment,{children:[e.jsx(bt,{size:16,style:{animation:"spin 1s linear infinite",marginRight:"8px"}}),m==="identifier"?"Checking...":"Signing in..."]}):m==="identifier"?"Continue":"Sign in"})]}),e.jsx(Dt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>p(!0),children:"Use other methods"})]}),e.jsxs(Tn,{children:["Don't have an account?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:`${(xe=t.ui_settings)==null?void 0:xe.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Pi=d.div`
|
|
1694
|
+
`;function Eg(){return e.jsx(Tf,{children:e.jsx(Ig,{})})}function Ig(){var ue,X,ae,Z,q,B,ie,H,se,we,xe,ge;const{deployment:t}=me(),{navigate:r}=Ge(),{session:o,loading:n}=Be(),i=((X=(ue=t==null?void 0:t.auth_settings)==null?void 0:ue.multi_session_support)==null?void 0:X.enabled)??!1,{setEmail:s,otpSent:p,setOtpSent:f,showForgotPassword:c,setShowForgotPassword:h,showOtherOptions:l,setShowOtherOptions:u,enabledSocialsProviders:g,firstFactor:x,signInStep:m,setSignInStep:y}=xl(),{loading:$,signIn:S,signinAttempt:b,discardSignInAttempt:z,setSignInAttempt:j}=Br("generic"),{signIn:k}=Br("oauth"),[_,v]=a.useState({email:"",username:"",password:"",phone:""}),[P,C]=a.useState({}),[E,T]=a.useState(!1),[R,w]=a.useState(""),[I,M]=a.useState("US"),[O,U]=a.useState(!1),[F,L]=a.useState(null);a.useEffect(()=>{const V=new URLSearchParams(window.location.search),D=V.get("error"),N=V.get("error_description");if(D==="access_denied"&&N){L(N),V.delete("error"),V.delete("error_description");const re=V.toString()?`${window.location.pathname}?${V.toString()}`:window.location.pathname;window.history.replaceState({},"",re)}},[]),a.useEffect(()=>{var V;if(!n&&(o!=null&&o.active_signin)&&!i&&!O){U(!0);let D=new URLSearchParams(window.location.search).get("redirect_uri");D||(D=((V=t==null?void 0:t.ui_settings)==null?void 0:V.after_signin_redirect_url)||null),!D&&(t!=null&&t.frontend_host)&&(D=`https://${t.frontend_host}`),D&&r(D)}},[o,n,i,t,r,O]);const A=V=>{let{name:D,value:N}=V.target;D==="phone"?N=N.replace(/[^0-9]/g,""):D==="email"&&(s(N),N=N.toLowerCase()),v(re=>({...re,[D]:N})),C(re=>({...re,[D]:""}))},Q=()=>{v({email:"",username:"",password:"",phone:""}),C({}),M("US"),y("identifier")},ee=async V=>{if(!V){C({email:"Email address is required"});return}T(!0),C({});try{const D=await S.identify(V);if(D.strategy==="sso"&&D.connection_id){const re=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,pe=await S.initEnterpriseSso(D.connection_id,re);if(pe&&pe.sso_url){U(!0),window.location.href=pe.sso_url;return}}else if(D.strategy==="social"&&D.provider){const N=g.find(re=>re.provider===D.provider);if(N){const pe=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:J}=await k.create({provider:N.provider,redirectUri:pe});if(J&&typeof J=="object"&&"oauth_url"in J){U(!0),window.location.href=J.oauth_url;return}}else y("password")}else y("password")}catch(D){C({submit:D.message})}finally{O||T(!1)}},W=async V=>{if(V.preventDefault(),$||E)return;z();const D={};if(m==="identifier"&&x==="email_password"){if(!_.email){C({email:"Email address is required"});return}await ee(_.email);return}if(x==="email_password"?(_.email||(D.email="Email address is required"),_.password||(D.password="Password is required")):x==="username_password"?(_.username||(D.username="Username is required"),_.password||(D.password="Password is required")):x==="email_otp"||x==="email_magic_link"?_.email||(D.email="Email address is required"):x==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(D.phone="Phone number must contain 7-15 digits"):D.phone="Phone number is required"),C(D),Object.keys(D).length>0)return;let N="";switch(x){case"email_password":N="plain_email";break;case"username_password":N="plain_username";break;case"email_otp":N="email_otp";break;case"email_magic_link":N="magic_link";break;case"phone_otp":N="phone_otp";break}T(!0);try{const re={..._,strategy:N};x==="phone_otp"&&I&&(re.phone_country_code=I),await S.create(re)}catch(re){C({submit:re.message}),T(!1)}},K=async V=>{if(V.preventDefault(),$||E)return;const D={};if(!R){D.otp="OTP code is required",C(D);return}T(!0),C({});try{await S.completeVerification(R),f(!1),w("")}catch(N){C({otp:N.message||"Verification failed"})}finally{T(!1)}},oe=async V=>{if(!($||E)){T(!0);try{const N=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:re}=await k.create({provider:V.provider,redirectUri:N});re&&typeof re=="object"&&"oauth_url"in re&&(window.location.href=re.oauth_url)}catch(D){C({submit:D.message})}finally{T(!1)}}},te=a.useRef(!1);if(a.useEffect(()=>{if(n)return;const V=new URLSearchParams(window.location.search),D=V.get("impersonation_token");if(D&&!b&&!$&&!te.current){te.current=!0,V.delete("impersonation_token");const re=V.toString()?`${window.location.pathname}?${V.toString()} `:window.location.pathname;window.history.replaceState({},"",re),(async()=>{try{T(!0),await S.create({strategy:"impersonation",token:D})}catch(J){C({submit:J.message}),T(!1),te.current=!1}})();return}const N=V.get("signin_attempt_id");if(N&&(o!=null&&o.signin_attempts)&&!b){const re=o.signin_attempts.find(pe=>pe.id===N);if(re){j(re),V.delete("signin_attempt_id");const pe=V.toString()?`${window.location.pathname}?${V.toString()} `:window.location.pathname;window.history.replaceState({},"",pe)}}},[o,n,b,j,$]),a.useEffect(()=>{var re;if(!b)return;if(b.completed){U(!0);let pe=new URLSearchParams(window.location.search).get("redirect_uri");if(pe||(pe=((re=t==null?void 0:t.ui_settings)==null?void 0:re.after_signin_redirect_url)||null),!pe&&(t!=null&&t.frontend_host)&&(pe=`https://${t.frontend_host}`),pe){const J=new URL(pe);(t==null?void 0:t.mode)==="staging"&&J.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(J.toString())}return}if(!S||p)return;const D={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(!D)return;(async()=>{try{await S.prepareVerification({strategy:D}),f(!0)}catch(pe){console.error("Failed to prepare verification:",pe),C({submit:"Failed to send verification. Please try again."})}finally{T(!1)}})()},[b,S,p,f,r,t]),a.useEffect(()=>{},[]),l)return e.jsx(Vf,{onBack:()=>u(!1)});if(c)return e.jsx(Df,{onBack:()=>h(!1)});if((b==null?void 0:b.current_step)==="verify_second_factor")return e.jsx(wl,{attempt:b,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),Q(),f(!1)}});if((b==null?void 0:b.current_step)==="complete_profile")return e.jsx(jl,{attempt:b,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{z(),Q(),f(!1)}});if(n)return e.jsx(fe,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Si,{children:e.jsx(bt,{size:32})})]})});if(O)return e.jsx(fe,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),e.jsx(Si,{children:e.jsx(bt,{size:32})})]})});const ne=(b==null?void 0:b.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(b.current_step)&&p;return e.jsx(fe,{children:e.jsxs(Rn,{children:[e.jsx(Pe,{}),ne?e.jsx(e.Fragment,{children:e.jsxs(zi,{children:[e.jsx($i,{children:x==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Ei,{children:x==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:x==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(zi,{children:[e.jsx($i,{children:"Sign in to your account"}),e.jsxs(Ei,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),F&&e.jsxs(Cg,{children:[e.jsx(Sg,{children:"Access Denied"}),e.jsx(zg,{children:F}),e.jsx($g,{onClick:()=>L(null),children:"Try again"})]}),ne?x==="email_magic_link"?e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{f(!1),z(),Q()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:K,noValidate:!0,children:[e.jsx(Tt,{onComplete:async V=>{if(w(V),V&&V.length===6){T(!0),C({});try{await S.completeVerification(V),f(!1)}catch(D){C({otp:D.message||"Verification failed"})}finally{T(!1)}}},onResend:async()=>{const V=x==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:V})},error:P.otp,isSubmitting:E}),e.jsx(Ii,{type:"submit",disabled:E||$||!R,style:{margin:0},children:E?"Verifying...":`Continue to ${(ge=t==null?void 0:t.ui_settings)==null?void 0:ge.app_name}`})]}),e.jsxs(Tn,{children:["Having trouble?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Dt,{onClick:()=>{f(!1),z(),Q()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[g.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(zs,{connections:g,callback:oe}),e.jsx(jg,{children:e.jsx(_g,{children:"or"})})]}),e.jsxs(dt,{onSubmit:W,noValidate:!0,children:[(x==="email_password"||x==="email_otp"||x==="email_magic_link")&&((Z=(ae=t==null?void 0:t.auth_settings)==null?void 0:ae.email_address)==null?void 0:Z.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"email",children:"Email address"}),e.jsx(le,{type:"email",id:"email",name:"email",value:_.email,onChange:A,placeholder:"Enter your email address","aria-invalid":!!P.email}),P.email&&e.jsx(Or,{children:P.email})]}),x==="username_password"&&((B=(q=t==null?void 0:t.auth_settings)==null?void 0:q.username)==null?void 0:B.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"username",children:"Username"}),e.jsx(le,{type:"text",id:"username",name:"username",value:_.username,onChange:A,placeholder:"Enter your username","aria-invalid":!!P.username}),P.username&&e.jsx(Or,{children:P.username})]}),x==="phone_otp"&&((H=(ie=t==null?void 0:t.auth_settings)==null?void 0:ie.phone_number)==null?void 0:H.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"phone",children:"Phone number"}),e.jsx(Yr,{value:_.phone,onChange:A,error:P.phone,countryCode:I,setCountryCode:M}),P.phone&&e.jsx(Or,{children:P.phone})]}),m==="password"&&(x==="email_password"||x==="username_password")&&((we=(se=t==null?void 0:t.auth_settings)==null?void 0:se.password)==null?void 0:we.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ce,{htmlFor:"password",children:"Password"}),e.jsx(Dt,{style:{fontSize:"12px"},onClick:()=>h(!0),children:"Forgot password?"})]}),e.jsx(kg,{children:e.jsx(le,{type:"password",id:"password",name:"password",value:_.password,onChange:A,placeholder:"Enter your password","aria-invalid":!!P.password})}),P.password&&e.jsx(Or,{children:P.password})]}),e.jsxs("div",{children:[P.submit&&e.jsx(Or,{children:P.submit}),e.jsx(Ii,{type:"submit",disabled:E||$,children:E?e.jsxs(e.Fragment,{children:[e.jsx(bt,{size:16,style:{animation:"spin 1s linear infinite",marginRight:"8px"}}),m==="identifier"?"Checking...":"Signing in..."]}):m==="identifier"?"Continue":"Sign in"})]}),e.jsx(Dt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>u(!0),children:"Use other methods"})]}),e.jsxs(Tn,{children:["Don't have an account?"," ",e.jsx(Dt,{children:e.jsx(ot,{to:`${(xe=t.ui_settings)==null?void 0:xe.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Pi=d.div`
|
|
1695
1695
|
max-width: 380px;
|
|
1696
1696
|
width: 380px;
|
|
1697
1697
|
padding: var(--space-3xl);
|
|
@@ -1792,7 +1792,7 @@ cursor: pointer;
|
|
|
1792
1792
|
color: var(--color-primary);
|
|
1793
1793
|
text-decoration: none;
|
|
1794
1794
|
cursor: pointer;
|
|
1795
|
-
`;function Vg(){var $,S,b,z,j,k,_,v,P,C,E,T;const{deployment:t}=me(),{loading:r,joinWaitlist:o}=gc(),[n,i]=a.useState({first_name:"",last_name:"",email:""}),[s,
|
|
1795
|
+
`;function Vg(){var $,S,b,z,j,k,_,v,P,C,E,T;const{deployment:t}=me(),{loading:r,joinWaitlist:o}=gc(),[n,i]=a.useState({first_name:"",last_name:"",email:""}),[s,p]=a.useState(!1),[f,c]=a.useState(!1),[h,l]=a.useState(null),u=R=>{if(h)return h.message},g=t==null?void 0:t.auth_settings,x=!!(($=g==null?void 0:g.first_name)!=null&&$.enabled&&((S=g==null?void 0:g.last_name)!=null&&S.enabled)),m=R=>{const{name:w,value:I}=R.target;i(M=>({...M,[w]:I}))},y=async R=>{if(R.preventDefault(),!!g){c(!0),l(null);try{(await o(n)).data&&p(!0)}catch(w){l(w)}finally{c(!1)}}};return s?e.jsx(fe,{children:e.jsx(Pi,{children:e.jsxs(Ag,{children:[e.jsx(Dg,{children:e.jsx(Ve,{size:32})}),e.jsx(Fg,{children:"You're on the waitlist!"}),e.jsxs(Ng,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(fe,{children:e.jsxs(Pi,{children:[e.jsx(Pe,{}),e.jsxs(Pg,{children:[e.jsx(Rg,{children:"Join the waitlist"}),e.jsx(Tg,{children:"Be the first to know when we launch!"})]}),e.jsxs(Mg,{onSubmit:y,noValidate:!0,children:[(((b=g==null?void 0:g.first_name)==null?void 0:b.enabled)||((z=g==null?void 0:g.last_name)==null?void 0:z.enabled))&&e.jsxs(Og,{$isBothEnabled:x,children:[((j=g==null?void 0:g.first_name)==null?void 0:j.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"first_name",children:["First name",((k=g==null?void 0:g.first_name)==null?void 0:k.required)&&e.jsx(Ln,{children:"*"})]}),e.jsx(le,{type:"text",id:"first_name",name:"first_name",required:(_=g==null?void 0:g.first_name)==null?void 0:_.required,minLength:2,maxLength:50,value:n.first_name,onChange:m,placeholder:"First name","aria-invalid":!!u()}),u()&&e.jsx(lo,{children:u()})]}),((v=g==null?void 0:g.last_name)==null?void 0:v.enabled)&&e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"last_name",children:["Last name",((P=g==null?void 0:g.last_name)==null?void 0:P.required)&&e.jsx(Ln,{children:"*"})]}),e.jsx(le,{type:"text",id:"last_name",name:"last_name",required:(C=g==null?void 0:g.last_name)==null?void 0:C.required,minLength:2,maxLength:50,value:n.last_name,onChange:m,placeholder:"Last name","aria-invalid":!!u()}),u()&&e.jsx(lo,{children:u()})]})]}),e.jsxs(Mn,{children:[e.jsxs(On,{htmlFor:"email",children:["Email address",((E=g==null?void 0:g.email_address)==null?void 0:E.required)&&e.jsx(Ln,{children:"*"})]}),e.jsx(le,{type:"email",id:"email",name:"email",required:(T=g==null?void 0:g.email_address)==null?void 0:T.required,value:n.email,onChange:m,placeholder:"Enter your email address","aria-invalid":!!u()}),u()&&e.jsx(lo,{children:u()})]}),u()&&e.jsx(lo,{children:u()}),e.jsx(Lg,{type:"submit",$primary:!0,disabled:f||r,children:f||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(Bg,{children:e.jsxs(Ug,{children:["Need assistance? ",e.jsx(Wg,{href:"/contact",children:"Get help"})]})})]})})}const uo=d.div`
|
|
1796
1796
|
max-width: 380px;
|
|
1797
1797
|
width: 380px;
|
|
1798
1798
|
padding: var(--space-3xl);
|
|
@@ -1879,7 +1879,7 @@ cursor: pointer;
|
|
|
1879
1879
|
color: var(--color-primary-hover);
|
|
1880
1880
|
text-decoration: underline;
|
|
1881
1881
|
}
|
|
1882
|
-
`;function Zg(){const{deployment:t}=me(),{navigate:r}=Ge(),{error:o,session:n,processed:i,signinAttempt:s,redirectUri:
|
|
1882
|
+
`;function Zg(){const{deployment:t}=me(),{navigate:r}=Ge(),{error:o,session:n,processed:i,signinAttempt:s,redirectUri:p,loading:f}=mc(),c=()=>{window.location.reload()},h=()=>{var u;const l=((u=t==null?void 0:t.ui_settings)==null?void 0:u.sign_in_page_url)||"/sign-in";r(l)};if(a.useEffect(()=>{var l,u;if(!(!i||f)){if(s&&!s.completed){const g=(l=t==null?void 0:t.ui_settings)==null?void 0:l.sign_in_page_url;if(g){const x=new URL(g,window.location.origin);x.searchParams.set("signin_attempt_id",s.id),p&&x.searchParams.set("redirect_uri",p),r(x.toString())}return}if(s!=null&&s.completed){const g=new URL(p||((u=t==null?void 0:t.ui_settings)==null?void 0:u.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"");g&&((t==null?void 0:t.mode)==="staging"&&g.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(g.toString()))}}},[n,i,f,p,t,s,r]),a.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var u;const l=((u=t==null?void 0:t.ui_settings)==null?void 0:u.sign_in_page_url)||(t==null?void 0:t.frontend_host);l&&r(l)},2e3)},[o,t,r]),f&&!i)return e.jsx(fe,{children:e.jsxs(uo,{children:[e.jsxs(po,{children:[e.jsx(ho,{children:"Completing sign in"}),e.jsx(fo,{children:"Please wait while we authenticate you"})]}),e.jsxs(go,{children:[e.jsx(Ri,{}),e.jsx(mo,{children:"Verifying your credentials..."}),e.jsx(xo,{children:"This will only take a moment."})]})]})});if(n&&i&&!o)return e.jsx(fe,{children:e.jsxs(uo,{children:[e.jsxs(po,{children:[e.jsx(ho,{children:"Success!"}),e.jsx(fo,{children:"Authentication completed successfully"})]}),e.jsxs(go,{children:[e.jsx(Hg,{children:"✓"}),e.jsx(mo,{children:"Redirecting you now..."}),e.jsx(xo,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const l=o.message.includes("No OAuth callback data found");return e.jsx(fe,{children:e.jsxs(uo,{children:[e.jsxs(po,{children:[e.jsx(ho,{children:"Something went wrong"}),e.jsx(fo,{children:"We couldn't complete your sign in"})]}),e.jsxs(go,{children:[e.jsx(Gg,{children:"✗"}),e.jsx(mo,{children:"Authentication Failed"}),e.jsx(xo,{children:o.message||"An unexpected error occurred during authentication."}),!l&&e.jsx(Y,{onClick:c,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!l&&e.jsx(qg,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(Yg,{onClick:h,children:"Return to sign in"})]})})]})})}return e.jsx(fe,{children:e.jsxs(uo,{children:[e.jsxs(po,{children:[e.jsx(ho,{children:"Completing sign in"}),e.jsx(fo,{children:"Please wait while we authenticate you"})]}),e.jsxs(go,{children:[e.jsx(Ri,{}),e.jsx(mo,{children:"Verifying your credentials..."}),e.jsx(xo,{children:"This will only take a moment."})]})]})})}const Qg=d.div`
|
|
1883
1883
|
max-width: 380px;
|
|
1884
1884
|
width: 380px;
|
|
1885
1885
|
padding: var(--space-3xl);
|
|
@@ -1944,7 +1944,7 @@ cursor: pointer;
|
|
|
1944
1944
|
`,An=d.p`
|
|
1945
1945
|
font-size: var(--font-xs);
|
|
1946
1946
|
color: var(--color-secondary-text);
|
|
1947
|
-
`;function nm({onSuccess:t,onError:r}={}){const[o,n]=a.useState("loading"),[i,s]=a.useState(""),{token:
|
|
1947
|
+
`;function nm({onSuccess:t,onError:r}={}){const[o,n]=a.useState("loading"),[i,s]=a.useState(""),{token:p,attempt:f,redirectUri:c}=vc(),{verifyMagicLink:h}=xc(),{navigate:l}=Ge(),{deployment:u}=me(),g=a.useRef(!1);a.useEffect(()=>{(async()=>{if(!g.current){if(!p||!f){n("error"),s("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}g.current=!0,n("loading"),s("Please wait while we verify your magic link.");try{await h({token:p,attempt:f,redirectUri:c}),n("success"),s("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var $;let y=c;if(y||(y=($=u==null?void 0:u.ui_settings)==null?void 0:$.after_signin_redirect_url),!y&&(u!=null&&u.frontend_host)&&(y=`https://${u.frontend_host}`),y){const S=new URL(y);(u==null?void 0:u.mode)==="staging"&&S.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),l(S.toString())}},2e3)}catch(y){n("error"),s("The magic link may have expired or already been used. Please try signing in again."),r==null||r(y.message)}}})()},[p,f]);const x=()=>{var m;(m=u==null?void 0:u.ui_settings)!=null&&m.sign_in_page_url&&l(u.ui_settings.sign_in_page_url)};return e.jsx(fe,{children:e.jsxs(Qg,{children:[e.jsxs(Kg,{children:[e.jsx(Xg,{children:"Magic Link Verification"}),e.jsx(Jg,{children:"Verifying your magic link"})]}),e.jsxs(em,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(om,{}),e.jsx(An,{children:i})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(tm,{children:"✓"}),e.jsx(An,{children:i})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(rm,{children:"✗"}),e.jsx(An,{children:i}),e.jsx(Y,{onClick:x,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function sm(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 p,f;return((p=s.missing_fields)==null?void 0:p.length)>0||((f=s.remaining_steps)==null?void 0:f.length)>0&&!s.completed})):!1}function im(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Ft=d.div`
|
|
1948
1948
|
max-width: 380px;
|
|
1949
1949
|
width: 380px;
|
|
1950
1950
|
padding: var(--space-3xl);
|
|
@@ -2044,7 +2044,7 @@ cursor: pointer;
|
|
|
2044
2044
|
&:hover {
|
|
2045
2045
|
color: var(--color-primary-hover);
|
|
2046
2046
|
}
|
|
2047
|
-
`;function um({token:t,onSuccess:r,onError:o}){var y;const{acceptInvitation:n,invitationData:i,loading:s,error:
|
|
2047
|
+
`;function um({token:t,onSuccess:r,onError:o}){var y;const{acceptInvitation:n,invitationData:i,loading:s,error:p}=_c(),{navigate:f}=Ge(),{deployment:c}=me(),h=a.useRef(!1),l=()=>{var S;const $=new URLSearchParams(window.location.search);return{token:t||$.get("invite_token")||$.get("token"),redirectUri:$.get("redirect_uri")||((S=c==null?void 0:c.ui_settings)==null?void 0:S.after_signin_redirect_url)||"/"}};a.useEffect(()=>{if(h.current)return;const{token:$}=l();$&&(h.current=!0,n($))},[n]),a.useEffect(()=>{var $;i&&(i.organization&&!i.requires_signin&&r&&r(i.organization.id,($=i.workspace)==null?void 0:$.id),i.error_code&&o&&o(i.message||"Failed to accept invitation"))},[i,r,o]);const u=()=>{const{redirectUri:$}=l();f($)},g=()=>{var _,v;const{token:$,redirectUri:S}=l(),b=((_=c==null?void 0:c.ui_settings)==null?void 0:_.sign_in_page_url)||"/sign-in",z=((v=c==null?void 0:c.ui_settings)==null?void 0:v.sign_up_page_url)||"/sign-up",j=new URLSearchParams;$&&j.set("invite_token",$),i!=null&&i.invited_email&&j.set("invited_email",i.invited_email),j.set("redirect_uri",S),i!=null&&i.message&&j.set("message",i.message);const k=(i==null?void 0:i.error_code)==="INVITATION_REQUIRES_SIGNUP";f(`${k?z:b}?${j.toString()}`)},x=()=>{const{token:$}=l();$&&(h.current=!1,n($))},{token:m}=l();if(!m&&!s)return e.jsx(fe,{children:e.jsxs(Ft,{children:[e.jsxs(Nt,{children:[e.jsx(Bt,{children:"Invalid Invitation"}),e.jsx(Ut,{children:"No invitation token found"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Missing Invitation Token"}),e.jsx(Gt,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(Y,{onClick:()=>f("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(s)return e.jsx(fe,{children:e.jsxs(Ft,{children:[e.jsxs(Nt,{children:[e.jsx(Bt,{children:"Processing Invitation"}),e.jsx(Ut,{children:"Please wait while we verify your invitation"})]}),e.jsxs(Wt,{children:[e.jsx(cm,{}),e.jsx(Vt,{children:"Verifying invitation..."}),e.jsx(Gt,{children:"This will only take a moment."})]})]})});if(i!=null&&i.organization&&!i.requires_signin)return e.jsx(fe,{children:e.jsxs(Ft,{children:[e.jsxs(Nt,{children:[e.jsx(Bt,{children:"Invitation Accepted!"}),e.jsx(Ut,{children:"You've successfully joined the organization"})]}),e.jsxs(Wt,{children:[e.jsx(am,{children:"✓"}),e.jsxs(Vt,{children:["Welcome to ",i.organization.name,"!"]}),i.workspace&&e.jsxs(Gt,{children:["You've been added to the ",i.workspace.name," workspace."]}),e.jsx(Y,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(i!=null&&i.already_member)return e.jsx(fe,{children:e.jsxs(Ft,{children:[e.jsxs(Nt,{children:[e.jsx(Bt,{children:"Already a Member"}),e.jsx(Ut,{children:"You're already part of this organization"})]}),e.jsxs(Wt,{children:[e.jsx(Ti,{children:"ℹ"}),e.jsxs(Vt,{children:["You're already a member of ",((y=i.organization)==null?void 0:y.name)||"this organization"]}),e.jsx(Gt,{children:"No action needed - you already have access."}),e.jsx(Y,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(i!=null&&i.requires_signin){const $=i.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(fe,{children:e.jsxs(Ft,{children:[e.jsxs(Nt,{children:[e.jsx(Bt,{children:$?"Sign Up Required":"Sign In Required"}),e.jsx(Ut,{children:"To accept this invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Ti,{children:"ℹ"}),e.jsxs(Vt,{children:["This invitation is for ",e.jsx(Mi,{children:i.invited_email})]}),e.jsx(Gt,{children:$?"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(Y,{onClick:g,style:{marginTop:"var(--space-lg)"},children:$?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(i==null?void 0:i.error_code)==="INVITATION_EXPIRED"?e.jsx(fe,{children:e.jsxs(Ft,{children:[e.jsxs(Nt,{children:[e.jsx(Bt,{children:"Invitation Expired"}),e.jsx(Ut,{children:"This invitation is no longer valid"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"⏱"}),e.jsxs(Vt,{children:["Invitation for ",e.jsx(Mi,{children:i.invited_email})," has expired"]}),e.jsx(Gt,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):p||i!=null&&i.error_code?e.jsx(fe,{children:e.jsxs(Ft,{children:[e.jsxs(Nt,{children:[e.jsx(Bt,{children:"Invitation Error"}),e.jsx(Ut,{children:"Unable to process invitation"})]}),e.jsxs(Wt,{children:[e.jsx(Dn,{children:"✗"}),e.jsx(Vt,{children:"Something went wrong"}),e.jsx(Gt,{children:(i==null?void 0:i.message)||p||"Failed to accept invitation"}),e.jsx(Y,{onClick:x,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(lm,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx(dm,{onClick:g,children:"Sign in manually"})]})})]})]})}):null}const _l=a.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),et=()=>{const t=a.useContext(_l);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},pm=d.div`
|
|
2048
2048
|
display: flex;
|
|
2049
2049
|
height: 100%;
|
|
2050
2050
|
min-height: 400px;
|
|
@@ -2233,7 +2233,7 @@ cursor: pointer;
|
|
|
2233
2233
|
color: white;
|
|
2234
2234
|
font-size: 12px;
|
|
2235
2235
|
font-weight: 400;
|
|
2236
|
-
`,an=({onSuccess:t,onCancel:r})=>{const[o,n]=a.useState(""),[i,s]=a.useState(""),[
|
|
2236
|
+
`,an=({onSuccess:t,onCancel:r})=>{const[o,n]=a.useState(""),[i,s]=a.useState(""),[p,f]=a.useState(),[c,h]=a.useState(null),[l,u]=a.useState(!1),g=a.useRef(null),{createOrganization:x}=Zo(),{toast:m}=et(),y=_=>{n(_)},$=_=>{if(_.target.files&&_.target.files[0]){const v=_.target.files[0];if(v.size>2*1024*1024){m("File size cannot exceed 2MB","error");return}if(!v.type.startsWith("image/")){m("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),f(v),h(URL.createObjectURL(v))}},S=()=>{var _;(_=g.current)==null||_.click()},b=_=>_.split(" ").map(v=>v[0]).join("").toUpperCase().slice(0,2)||"O";a.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const z=_=>_.trim().replace(/[<>\"'&]/g,""),j=_=>_.length>=2&&_.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(_),k=async()=>{const _=z(o),v=z(i);if(!_){m("Please enter an organization name","error");return}if(!j(_)){m("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(v.length>500){m("Description must be less than 500 characters","error");return}u(!0);try{const P=await x({name:_,description:v,image:p});t==null||t(P)}catch(P){const C=P.message||"Failed to create organization. Please try again.";m(C,"error")}finally{u(!1)}};return e.jsx(fe,{children:e.jsxs(pm,{children:[e.jsxs(hm,{children:[e.jsxs(kl,{hasImage:!!c,onClick:S,children:[c?e.jsx(gm,{src:c,alt:"Organization logo"}):e.jsx(mm,{children:b(o||"O")}),e.jsx(Em,{children:e.jsx(Im,{children:"Upload Logo"})})]}),e.jsx($m,{type:"file",ref:g,onChange:$,accept:"image/png, image/jpeg, image/gif",disabled:l}),e.jsx(xm,{children:"Create new organization"}),e.jsx(vm,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(fm,{children:[e.jsxs(bm,{children:[e.jsx(ym,{children:"Choose your organization name"}),e.jsx(wm,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(jm,{children:[e.jsxs(Oi,{children:[e.jsx(Li,{children:"Organization name"}),e.jsx(_m,{type:"text",value:o,onChange:_=>y(_.target.value),placeholder:"Acme Inc.",disabled:l})]}),e.jsxs(Oi,{children:[e.jsx(Li,{children:"Description (optional)"}),e.jsx(km,{value:i,onChange:_=>s(_.target.value),placeholder:"What does your organization do?",disabled:l})]})]}),e.jsxs(Cm,{children:[r?e.jsxs(Sm,{onClick:r,disabled:l,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(zm,{onClick:k,disabled:l||!o.trim(),children:l?"Creating...":"Create"})]})]})]})})},Pm=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(fe,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:n,onCancel:r})})})})})})},Rm=d.div`
|
|
2237
2237
|
position: fixed;
|
|
2238
2238
|
width: 360px;
|
|
2239
2239
|
max-width: calc(100vw - 48px);
|
|
@@ -2282,7 +2282,7 @@ cursor: pointer;
|
|
|
2282
2282
|
color: var(--color-foreground);
|
|
2283
2283
|
background: var(--color-input-background);
|
|
2284
2284
|
}
|
|
2285
|
-
`,Ui=({onClose:t,domain:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(),[
|
|
2285
|
+
`,Ui=({onClose:t,domain:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(),[p,f]=a.useState(""),[c,h]=a.useState(!1),[l,u]=a.useState(!1),[g,x]=a.useState({top:0,left:0}),{addDomain:m,verifyDomain:y}=Ye(),{toast:$}=et(),S=k=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(k),b=k=>k.trim().toLowerCase().replace(/^https?:\/\//,""),z=async()=>{const k=b(p);if(!k){$("Please enter a domain name","error");return}if(!S(k)){$("Please enter a valid domain name (e.g., example.com)","error");return}if(k.length>253){$("Domain name is too long","error");return}try{const _=await m({fqdn:k});$("Domain added successfully","info"),s(_.data)}catch(_){const v=_.message||"Failed to add domain. Please try again.";$(v,"error")}},j=async()=>{if(!(!i||c)){h(!0);try{await y(i),t==null||t(),$("Domain verified successfully","info")}catch(k){const _=k.message||"Failed to verify domain. Please check DNS records and try again.";$(_,"error")}finally{h(!1)}}};return a.useEffect(()=>{u(!0);const k=setTimeout(()=>{if(!n.current)return;const P=o==null?void 0:o.current,C=360,E=250,T=8;let R=0,w=0;if(!P){const U=n.current.getBoundingClientRect(),F=U.width||C,L=U.height||E;R=Math.max(T,(window.innerHeight-L)/2),w=Math.max(T,(window.innerWidth-F)/2),x({top:R,left:w});return}const I=P.getBoundingClientRect(),M=window.innerHeight-I.bottom,O=I.top;M>=E+T?(R=I.bottom+T,w=I.right-C,w<T&&(w=I.left,w+C>window.innerWidth-T&&(w=(window.innerWidth-C)/2))):O>=E+T?(R=I.top-E-T,w=I.right-C,w<T&&(w=I.left,w+C>window.innerWidth-T&&(w=(window.innerWidth-C)/2))):(R=I.bottom+T,w=I.right-C,w<T&&(w=I.left)),x({top:R,left:w})},10),_=P=>{n.current&&!n.current.contains(P.target)&&(t==null||t())},v=P=>{P.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",_),document.addEventListener("keydown",v),()=>{clearTimeout(k),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",v)}},[t,o]),a.useEffect(()=>{r&&s(r)},[r]),l?e.jsx(Rm,{ref:n,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:i?e.jsxs(e.Fragment,{children:[e.jsxs(Ai,{children:[e.jsx(Di,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Bi,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(Je,{size:16})})]}),e.jsxs(Fi,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0,textAlign:"left"},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Record Type"}),e.jsx(le,{value:i==null?void 0:i.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Record Name"}),e.jsx(le,{value:i==null?void 0:i.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Record Data"}),e.jsx(le,{type:"text",value:i==null?void 0:i.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Ni,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Y,{onClick:j,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ai,{children:[e.jsx(Di,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Bi,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(Je,{size:16})})]}),e.jsx(Fi,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ce,{children:"Enter FQDN"}),e.jsx(le,{type:"text",placeholder:"Enter your domain",value:p,onChange:k=>f(k.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Ni,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Y,{onClick:z,disabled:!p||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Tm=d.div`
|
|
2286
2286
|
position: fixed;
|
|
2287
2287
|
width: 360px;
|
|
2288
2288
|
max-width: calc(100vw - 48px);
|
|
@@ -2331,7 +2331,7 @@ cursor: pointer;
|
|
|
2331
2331
|
color: var(--color-foreground);
|
|
2332
2332
|
background: var(--color-input-background);
|
|
2333
2333
|
}
|
|
2334
|
-
`,Cl=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const i=a.useRef(null),[s,
|
|
2334
|
+
`,Cl=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const i=a.useRef(null),[s,p]=a.useState(""),[f,c]=a.useState(null),[h,l]=a.useState(!1),[u,g]=a.useState(!1),[x,m]=a.useState({top:0,left:0}),{inviteMember:y}=Ye(),{toast:$}=et(),S=o.map(j=>({value:j.id,label:j.name})),b=j=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j),z=async()=>{const j=s.trim().toLowerCase();if(!(!j||!f)){if(!b(j)){$("Please enter a valid email address","error");return}if(j.length>320){$("Email address is too long","error");return}l(!0);try{await y({email:j,organizationRole:f}),r==null||r()}catch(k){const _=k.message||"Failed to send invitation. Please try again.";$(_,"error")}finally{l(!1)}}};return a.useEffect(()=>{g(!0);const j=setTimeout(()=>{if(!i.current||!(n!=null&&n.current))return;const v=n.current;if(v){const P=v.getBoundingClientRect(),C=360,E=250,T=8;let R=0,w=0;const I=window.innerHeight-P.bottom,M=P.top;I>=E+T?(R=P.bottom+T,w=P.right-C,w<T&&(w=P.left,w+C>window.innerWidth-T&&(w=(window.innerWidth-C)/2))):M>=E+T?(R=P.top-E-T,w=P.right-C,w<T&&(w=P.left,w+C>window.innerWidth-T&&(w=(window.innerWidth-C)/2))):(R=P.bottom+T,w=P.right-C,w<T&&(w=P.left)),m({top:R,left:w})}},10),k=v=>{i.current&&!i.current.contains(v.target)&&(t==null||t())},_=v=>{v.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",_),()=>{clearTimeout(j),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",_)}},[t,n]),u?e.jsxs(Tm,{ref:i,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Mm,{children:[e.jsx(Om,{id:"invite-member-title",children:"Invite Member"}),e.jsx(Dm,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Je,{size:16})})]}),e.jsx(Lm,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Email Address"}),e.jsx(le,{type:"email",placeholder:"colleague@company.com",value:s,onChange:j=>p(j.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Role"}),e.jsx($s,{options:S,value:f==null?void 0:f.id,onChange:j=>c(o.find(k=>k.id===j)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(Am,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Y,{onClick:z,disabled:!s||!f||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},Fm=d.div`
|
|
2335
2335
|
position: fixed;
|
|
2336
2336
|
width: 400px;
|
|
2337
2337
|
max-width: calc(100vw - 48px);
|
|
@@ -2382,7 +2382,7 @@ cursor: pointer;
|
|
|
2382
2382
|
color: var(--color-foreground);
|
|
2383
2383
|
background: var(--color-input-background);
|
|
2384
2384
|
}
|
|
2385
|
-
`,Wi=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var _;const i=a.useRef(null),[s,
|
|
2385
|
+
`,Wi=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var _;const i=a.useRef(null),[s,p]=a.useState((o==null?void 0:o.name)||""),[f,c]=a.useState((o==null?void 0:o.permissions)||[]);Ye();const[h,l]=a.useState(!1),[u,g]=a.useState(!1),[x,m]=a.useState({top:0,left:0}),{deployment:y}=me(),{toast:$}=et(),S=!!o,b=Array.isArray((_=y==null?void 0:y.b2b_settings)==null?void 0:_.organization_permissions)?y.b2b_settings.organization_permissions.map(v=>({value:v,label:v})):[];a.useEffect(()=>{g(!0);const v=setTimeout(()=>{if(!i.current)return;let T=null;if(n!=null&&n.current)T=n.current;else if(S){const R=document.querySelectorAll("[data-role-dropdown-trigger]");for(let w=0;w<R.length;w++){const I=R[w];if(I.offsetParent!==null){T=I;break}}}else{const R=document.querySelectorAll("button");for(let w=0;w<R.length;w++){const I=R[w];if(I.textContent==="Add role"&&I.offsetParent!==null){T=I;break}}}if(T){const R=T.getBoundingClientRect(),w=400;let I=R.bottom+8,M=R.right-w;M<10&&(M=R.left),I+300>window.innerHeight&&(I=R.top-300-8),m({top:I,left:M})}},10),P=T=>{i.current&&!i.current.contains(T.target)&&(t==null||t())},C=T=>{T.key==="Escape"&&(t==null||t())},E=setTimeout(()=>{document.addEventListener("mousedown",P),document.addEventListener("keydown",C)},100);return()=>{clearTimeout(v),clearTimeout(E),document.removeEventListener("mousedown",P),document.removeEventListener("keydown",C)}},[t,S,n]);const z=v=>v.trim().replace(/[<>\"'&]/g,""),j=v=>v.length>=2&&v.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(v),k=async()=>{const v=z(s);if(!v){$("Please enter a role name","error");return}if(!j(v)){$("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(f.length===0){$("Please select at least one permission","error");return}l(!0);try{const P={id:o==null?void 0:o.id,name:v,permissions:f||[]};r==null||r(P)}catch(P){const C=P.message||`Failed to ${S?"update":"create"} role. Please try again.`;$(C,"error")}finally{l(!1)}};return u?e.jsxs(Fm,{ref:i,$isInTable:S,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(Nm,{children:[e.jsx(Bm,{id:"role-dialog-title",children:S?"Edit Role":"Create New Role"}),e.jsx(Vm,{onClick:t,"aria-label":`Close ${S?"edit":"create"} role dialog`,children:e.jsx(Je,{size:16})})]}),e.jsx(Um,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Role Name"}),e.jsx(le,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:s,onChange:v=>p(v.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Permissions"}),e.jsx(gl,{options:b,value:f,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Wm,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Y,{onClick:k,disabled:!s||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," ",S?"Updating...":"Creating..."]}):S?"Update Role":"Create Role"})]})]}):null},_t=d.table`
|
|
2386
2386
|
width: 100%;
|
|
2387
2387
|
border-collapse: separate;
|
|
2388
2388
|
border-spacing: 0;
|
|
@@ -2483,7 +2483,7 @@ cursor: pointer;
|
|
|
2483
2483
|
display: flex;
|
|
2484
2484
|
gap: 8px;
|
|
2485
2485
|
justify-content: flex-end;
|
|
2486
|
-
`,Zr=({title:t,onConfirm:r,onCancel:o})=>{const n=a.useRef(null),[i,s]=a.useState({top:0,left:0});return a.useEffect(()=>{var
|
|
2486
|
+
`,Zr=({title:t,onConfirm:r,onCancel:o})=>{const n=a.useRef(null),[i,s]=a.useState({top:0,left:0});return a.useEffect(()=>{var p;if(n.current){const f=(p=n.current.parentElement)==null?void 0:p.getBoundingClientRect();f&&s({top:f.bottom+8,left:f.right-320})}},[]),a.useEffect(()=>{const p=f=>{n.current&&!n.current.contains(f.target)&&o()};return document.addEventListener("mousedown",p),()=>{document.removeEventListener("mousedown",p)}},[o]),e.jsxs(Ym,{ref:n,style:{top:`${i.top}px`,left:`${i.left}px`},children:[e.jsx(Zm,{children:t}),e.jsxs(Qm,{children:[e.jsx(Y,{onClick:o,style:{fontSize:"14px",padding:"6px 16px",background:"transparent",border:"1px solid var(--color-border)",color:"var(--color-foreground)"},children:"Cancel"}),e.jsx(Y,{onClick:r,style:{fontSize:"14px",padding:"6px 16px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white"},children:"Confirm"})]})]})},Km=d.div`
|
|
2487
2487
|
display: flex;
|
|
2488
2488
|
align-items: center;
|
|
2489
2489
|
flex-wrap: wrap;
|
|
@@ -2611,7 +2611,7 @@ cursor: pointer;
|
|
|
2611
2611
|
outline: none;
|
|
2612
2612
|
border-color: var(--color-primary);
|
|
2613
2613
|
}
|
|
2614
|
-
`,tx=()=>{var z;const{deployment:t}=me(),{activeOrganization:r,loading:o,getEnterpriseConnections:n,createEnterpriseConnection:i,deleteEnterpriseConnection:s,testEnterpriseConnection:
|
|
2614
|
+
`,tx=()=>{var z;const{deployment:t}=me(),{activeOrganization:r,loading:o,getEnterpriseConnections:n,createEnterpriseConnection:i,deleteEnterpriseConnection:s,testEnterpriseConnection:p,generateSCIMToken:f,getSCIMToken:c,revokeSCIMToken:h}=Ye(),{toast:l}=et(),[u,g]=a.useState(!1),[x,m]=a.useState(null),{data:y=[],isLoading:$,mutate:S}=Ne(r!=null&&r.id?`wacht-org-sso:${r.id}`:null,async()=>await(n==null?void 0:n())||[],{refreshInterval:3e4,revalidateOnFocus:!1}),b=async j=>{try{await(s==null?void 0:s(j)),S(),l("SSO connection deleted","info")}catch(k){l(k.message||"Failed to delete connection","error")}m(null)};return o||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):(z=t==null?void 0:t.b2b_settings)!=null&&z.enterprise_sso_enabled?u?e.jsx(ax,{onClose:()=>g(!1),onCreate:async j=>{try{await(i==null?void 0:i(j)),S(),g(!1),l("SSO connection created","info")}catch(k){l(k.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:y.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(Qe,{size:56,strokeWidth:1,style:{color:"var(--color-primary)",marginBottom:"20px",opacity:.7}}),e.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:500,color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:"var(--color-muted)",maxWidth:"360px",lineHeight:"1.6"},children:"Set up SAML or OIDC single sign-on to allow members to sign in with your identity provider."}),e.jsxs(Y,{onClick:()=>g(!0),style:{width:"auto"},children:[e.jsx(Ze,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Km,{children:e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"16px",color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"var(--color-muted)"},children:"Configure SAML or OIDC SSO for your organization"})]})}),y.map(j=>e.jsx(ix,{connection:j,onDelete:k=>m(k),connectionToDelete:x,onConfirmDelete:b,onCancelDelete:()=>m(null),testConnection:p||null,generateSCIMToken:f,getSCIMToken:c,revokeSCIMToken:h,toast:l},j.id))]})}):e.jsxs(zl,{children:[e.jsxs($l,{children:[e.jsx(Qe,{size:18}),"Enterprise SSO"]}),e.jsx(Ht,{children:e.jsx("span",{style:{color:"var(--color-foreground-muted)"},children:"Enterprise SSO is not enabled for this deployment. Contact your administrator to enable this feature."})})]})},rx=d.div`
|
|
2615
2615
|
margin-top: 16px;
|
|
2616
2616
|
padding-top: 16px;
|
|
2617
2617
|
border-top: 1px solid var(--color-border);
|
|
@@ -2636,14 +2636,14 @@ cursor: pointer;
|
|
|
2636
2636
|
display: flex;
|
|
2637
2637
|
gap: 8px;
|
|
2638
2638
|
flex-wrap: wrap;
|
|
2639
|
-
`,ix=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:i,testConnection:s,generateSCIMToken:
|
|
2639
|
+
`,ix=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:i,testConnection:s,generateSCIMToken:p,getSCIMToken:f,revokeSCIMToken:c,toast:h})=>{var E,T;const[l,u]=a.useState(null),[g,x]=a.useState(!1),[m,y]=a.useState(null),[$,S]=a.useState(null),[b,z]=a.useState(!1),[j,k]=a.useState(null);a.useEffect(()=>{f&&t.id&&f(t.id).then(u).catch(()=>{})},[t.id,f]);const _=async()=>{if(s){z(!0),k(null);try{const R=await s(t.id);k(R)}catch(R){k({success:!1,checks:{},errors:{general:R.message||"Test failed"}})}finally{z(!1)}}},v=async()=>{if(p){x(!0);try{const R=await p(t.id);y(R.token),u({exists:!0,token:R,scim_base_url:R.scim_base_url}),h("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(R){h(R.message||"Failed to generate token","error")}finally{x(!1)}}},P=async()=>{if(c){x(!0);try{await c(t.id),u({exists:!1,scim_base_url:l==null?void 0:l.scim_base_url}),y(null),h("SCIM token revoked","info")}catch(R){h(R.message||"Failed to revoke token","error")}finally{x(!1)}}},C=(R,w)=>{navigator.clipboard.writeText(R),S(w),setTimeout(()=>S(null),2e3)};return e.jsxs(zl,{children:[e.jsxs(Xm,{children:[e.jsxs($l,{children:[e.jsx(Qe,{size:18}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(Jm,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(br,{onClick:()=>r(t.id),style:{color:"var(--color-error)"},children:e.jsx(qr,{size:16})}),o===t.id&&e.jsx(Zr,{title:"Delete this SSO connection?",onConfirm:()=>n(t.id),onCancel:i})]})]}),t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(Ht,{children:[e.jsx("strong",{children:"Entity ID:"})," ",t.idp_entity_id]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"SSO URL:"})," ",t.idp_sso_url]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Ht,{children:[e.jsx("strong",{children:"Issuer URL:"})," ",t.oidc_issuer_url]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Client ID:"})," ",t.oidc_client_id]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Scopes:"})," ",t.oidc_scopes||"openid profile email"]})]}),e.jsxs(Ht,{children:[e.jsx("strong",{children:"Created:"})," ",new Date(t.created_at).toLocaleDateString()]}),e.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[e.jsxs(Y,{$outline:!0,onClick:_,disabled:b,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[b?e.jsx(Ee,{size:12}):e.jsx(Qe,{size:14}),b?"Testing...":"Test Connection"]}),j&&e.jsx("span",{style:{fontSize:"12px",color:j.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:j.success?"✓ Connection valid":"✗ Connection failed"})]}),j&&!j.success&&j.errors&&e.jsx("div",{style:{marginTop:"8px",padding:"8px 12px",background:"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"4px",fontSize:"12px"},children:Object.entries(j.errors).map(([R,w])=>e.jsxs("div",{style:{color:"var(--color-error)",marginBottom:"4px"},children:[e.jsxs("strong",{children:[R.replace(/_/g," ").replace(/\b\w/g,I=>I.toUpperCase()),":"]})," ",w]},R))})]}),e.jsxs(rx,{children:[e.jsxs(ox,{children:[e.jsx(Qe,{size:14}),"SCIM Provisioning"]}),(l==null?void 0:l.scim_base_url)&&e.jsxs("div",{style:{marginBottom:"12px"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"4px"},children:"SCIM Base URL:"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all"},children:l.scim_base_url}),e.jsx(br,{onClick:()=>C(l.scim_base_url,"scim-url"),children:$==="scim-url"?e.jsx(Ve,{size:14}):e.jsx(Jt,{size:14})})]})]}),m&&e.jsxs(nx,{children:[e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginBottom:"8px"},children:"⚠️ Copy this token now. It won't be shown again."}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px"},children:[e.jsx("span",{style:{flex:1},children:m}),e.jsx(br,{onClick:()=>C(m,"scim-token"),children:$==="scim-token"?e.jsx(Ve,{size:14}):e.jsx(Jt,{size:14})})]})]}),(l==null?void 0:l.exists)&&((E=l==null?void 0:l.token)==null?void 0:E.enabled)&&!m&&e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:["Token: ",e.jsxs("code",{children:[l.token.token_prefix,"..."]}),l.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(l.token.last_used_at).toLocaleDateString()]})]}),e.jsx(sx,{children:!(l!=null&&l.exists)||!((T=l==null?void 0:l.token)!=null&&T.enabled)?e.jsxs(Y,{onClick:v,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:[g?e.jsx(Ee,{size:12}):e.jsx(Ze,{size:14}),"Generate SCIM Token"]}):e.jsxs(e.Fragment,{children:[e.jsx(Y,{$outline:!0,onClick:v,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px"},children:"Rotate Token"}),e.jsx(Y,{$outline:!0,onClick:P,disabled:g,style:{width:"auto",fontSize:"12px",padding:"6px 12px",color:"var(--color-error)"},children:"Revoke Token"})]})})]})]})},Nn=d.h3`
|
|
2640
2640
|
margin: 0 0 12px 0;
|
|
2641
2641
|
font-size: 13px;
|
|
2642
2642
|
font-weight: 600;
|
|
2643
2643
|
color: var(--color-foreground);
|
|
2644
2644
|
text-transform: uppercase;
|
|
2645
2645
|
letter-spacing: 0.5px;
|
|
2646
|
-
`,ax=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=Ye(),{deployment:n}=me(),[i,s]=a.useState(!1),[u,f]=a.useState(null),[c,h]=a.useState("saml"),[l,p]=a.useState(null),[g,x]=a.useState(!1),[m,y]=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:""}),[$,S]=a.useState(!1),[b,z]=a.useState(null),{data:j=[],isLoading:k}=Ne("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(I=>I.verified),{revalidateOnFocus:!1}),_=w=>{f(w),h(w.protocol),w.protocol==="saml"?y(I=>{var M,L,U;return{...I,idp_entity_id:w.placeholders.entityId||"",idp_sso_url:w.placeholders.ssoUrl||"",attr_first_name:((M=w.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((L=w.attributeMapping)==null?void 0:L.last_name)||"",attr_email:((U=w.attributeMapping)==null?void 0:U.email)||""}}):y(I=>{var M,L,U;return{...I,oidc_issuer_url:w.placeholders.issuerUrl||"",oidc_scopes:w.placeholders.scopes||"openid profile email",attr_first_name:((M=w.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((L=w.attributeMapping)==null?void 0:L.last_name)||"",attr_email:((U=w.attributeMapping)==null?void 0:U.email)||""}})},v=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",P=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",C=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",E=(w,I)=>{navigator.clipboard.writeText(w),p(I),setTimeout(()=>p(null),2e3)},T=async w=>{w.preventDefault(),s(!0);try{const I={};m.attr_first_name&&(I.first_name=m.attr_first_name),m.attr_last_name&&(I.last_name=m.attr_last_name),m.attr_email&&(I.email=m.attr_email);const M=Object.keys(I).length>0;c==="saml"?await t({protocol:"saml",domain_id:m.domain_id||void 0,idp_entity_id:m.idp_entity_id,idp_sso_url:m.idp_sso_url,idp_certificate:m.idp_certificate,jit_enabled:m.jit_enabled,...M&&{attribute_mapping:I}}):await t({protocol:"oidc",domain_id:m.domain_id||void 0,oidc_issuer_url:m.oidc_issuer_url,oidc_client_id:m.oidc_client_id,oidc_client_secret:m.oidc_client_secret,oidc_scopes:m.oidc_scopes,jit_enabled:m.jit_enabled,...M&&{attribute_mapping:I}})}finally{s(!1)}},R=async()=>{S(!0),z(null);const w=L=>L.includes("{")||L.includes("}"),I={},M={};if(c==="saml"?(m.idp_entity_id?w(m.idp_entity_id)?(M.entity_id_valid=!1,I.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):M.entity_id_valid=!0:(M.entity_id_valid=!1,I.entity_id_valid="IdP Entity ID is required"),m.idp_sso_url?w(m.idp_sso_url)?(M.sso_url_valid=!1,I.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):M.sso_url_valid=!0:(M.sso_url_valid=!1,I.sso_url_valid="IdP SSO URL is required"),m.idp_certificate?M.certificate_provided=!0:(M.certificate_provided=!1,I.certificate_provided="X.509 Certificate is required")):(m.oidc_issuer_url?w(m.oidc_issuer_url)?(M.issuer_url_valid=!1,I.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):M.issuer_url_valid=!0:(M.issuer_url_valid=!1,I.issuer_url_valid="Issuer URL is required"),m.oidc_client_id?w(m.oidc_client_id)?(M.client_id_valid=!1,I.client_id_valid="Client ID contains placeholder values - please replace with actual values"):M.client_id_valid=!0:(M.client_id_valid=!1,I.client_id_valid="Client ID is required")),Object.keys(I).length>0){z({success:!1,checks:M,errors:I}),S(!1);return}try{const L=c==="saml"?{protocol:"saml",idp_entity_id:m.idp_entity_id,idp_sso_url:m.idp_sso_url,idp_certificate:m.idp_certificate}:{protocol:"oidc",oidc_issuer_url:m.oidc_issuer_url,oidc_client_id:m.oidc_client_id,oidc_client_secret:m.oidc_client_secret},U=await(o==null?void 0:o(L));U&&z(U)}catch(L){z({success:!1,checks:{},errors:{general:"Test failed: "+L.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:T,children:[u?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:[u.logo?e.jsx(Fn,{src:u.logo,alt:u.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:u.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:u.protocol})]}),e.jsx("button",{type:"button",onClick:()=>f(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Nn,{children:"SAML Providers"}),e.jsx(Hi,{children:Gi.filter(w=>w.protocol==="saml").map(w=>e.jsxs(qi,{type:"button",$selected:!1,onClick:()=>_(w),children:[w.logo?e.jsx(Fn,{src:w.logo,alt:w.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Yi,{children:w.name})]},w.id))}),e.jsx(Nn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Hi,{children:Gi.filter(w=>w.protocol==="oidc").map(w=>e.jsxs(qi,{type:"button",$selected:!1,onClick:()=>_(w),children:[w.logo?e.jsx(Fn,{src:w.logo,alt:w.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Yi,{children:w.name})]},w.id))})]}),u&&e.jsxs(e.Fragment,{children:[e.jsxs(Vi,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:C}),e.jsx(br,{onClick:()=>E(C,"acs"),children:l==="acs"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:P}),e.jsx(br,{onClick:()=>E(P,"metadata"),children:l==="metadata"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:v}),e.jsx(br,{onClick:()=>E(v,"callback"),children:l==="callback"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Nn,{style:{margin:0},children:u?`${u.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[u&&u.docUrl&&e.jsxs("a",{href:u.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Ss,{size:12})," Docs"]}),e.jsx(Y,{type:"button",onClick:R,disabled:$||!u,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:$?e.jsx(Ee,{size:16}):"Test Connection"}),e.jsx(Y,{type:"submit",disabled:i||j.length===0||!u,style:{width:"auto",padding:"8px 16px"},children:i?e.jsx(Ee,{size:16}):"Create Connection"})]})]}),b&&(()=>{const w={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:b.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${b.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:b.success?"#10b981":"#ef4444"},children:b.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(b.checks).map(([I,M])=>{var L;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:M?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:M?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:w[I]||I.replace(/_/g," ").replace(/\b\w/g,U=>U.toUpperCase())}),((L=b.errors)==null?void 0:L[I])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:b.errors[I]})]})]},I)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!u&&e.jsxs(he,{children:[e.jsx(ce,{children:"Protocol *"}),e.jsxs(Zi,{value:c,onChange:w=>h(w.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ce,{children:"Domain *"}),k?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):j.length===0?e.jsx(Vi,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(Zi,{value:m.domain_id,onChange:w=>y({...m,domain_id:w.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),j.map(w=>e.jsx("option",{value:w.id,children:w.fqdn},w.id))]})]}),c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ce,{children:"IdP Entity ID *"}),e.jsx(le,{type:"text",value:m.idp_entity_id,onChange:w=>y({...m,idp_entity_id:w.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"IdP SSO URL *"}),e.jsx(le,{type:"url",value:m.idp_sso_url,onChange:w=>y({...m,idp_sso_url:w.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ce,{children:"X.509 Certificate *"}),e.jsx(ex,{value:m.idp_certificate,onChange:w=>y({...m,idp_certificate:w.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Issuer URL *"}),e.jsx(le,{type:"url",value:m.oidc_issuer_url,onChange:w=>y({...m,oidc_issuer_url:w.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Client ID *"}),e.jsx(le,{type:"text",value:m.oidc_client_id,onChange:w=>y({...m,oidc_client_id:w.target.value}),placeholder:"your-client-id",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Client Secret *"}),e.jsx(le,{type:"password",value:m.oidc_client_secret,onChange:w=>y({...m,oidc_client_secret:w.target.value}),placeholder:"your-client-secret",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Scopes"}),e.jsx(le,{type:"text",value:m.oidc_scopes,onChange:w=>y({...m,oidc_scopes:w.target.value}),placeholder:"openid profile email"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:m.jit_enabled,onChange:w=>y({...m,jit_enabled:w.target.checked}),style:{width:"16px",height:"16px"}}),e.jsx("span",{style:{fontWeight:500,color:"var(--color-foreground)"},children:"Enable JIT Provisioning"})]}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px",marginLeft:"24px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px"},children:[e.jsxs("div",{onClick:()=>x(!g),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:g?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:g?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),g&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"First Name Attribute"}),e.jsx(le,{type:"text",value:m.attr_first_name,onChange:w=>y({...m,attr_first_name:w.target.value}),placeholder:c==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Last Name Attribute"}),e.jsx(le,{type:"text",value:m.attr_last_name,onChange:w=>y({...m,attr_last_name:w.target.value}),placeholder:c==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Email Attribute"}),e.jsx(le,{type:"text",value:m.attr_email,onChange:w=>y({...m,attr_email:w.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},Qi=d.div`
|
|
2646
|
+
`,ax=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=Ye(),{deployment:n}=me(),[i,s]=a.useState(!1),[p,f]=a.useState(null),[c,h]=a.useState("saml"),[l,u]=a.useState(null),[g,x]=a.useState(!1),[m,y]=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:""}),[$,S]=a.useState(!1),[b,z]=a.useState(null),{data:j=[],isLoading:k}=Ne("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(I=>I.verified),{revalidateOnFocus:!1}),_=w=>{f(w),h(w.protocol),w.protocol==="saml"?y(I=>{var M,O,U;return{...I,idp_entity_id:w.placeholders.entityId||"",idp_sso_url:w.placeholders.ssoUrl||"",attr_first_name:((M=w.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((O=w.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((U=w.attributeMapping)==null?void 0:U.email)||""}}):y(I=>{var M,O,U;return{...I,oidc_issuer_url:w.placeholders.issuerUrl||"",oidc_scopes:w.placeholders.scopes||"openid profile email",attr_first_name:((M=w.attributeMapping)==null?void 0:M.first_name)||"",attr_last_name:((O=w.attributeMapping)==null?void 0:O.last_name)||"",attr_email:((U=w.attributeMapping)==null?void 0:U.email)||""}})},v=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",P=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",C=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",E=(w,I)=>{navigator.clipboard.writeText(w),u(I),setTimeout(()=>u(null),2e3)},T=async w=>{w.preventDefault(),s(!0);try{const I={};m.attr_first_name&&(I.first_name=m.attr_first_name),m.attr_last_name&&(I.last_name=m.attr_last_name),m.attr_email&&(I.email=m.attr_email);const M=Object.keys(I).length>0;c==="saml"?await t({protocol:"saml",domain_id:m.domain_id||void 0,idp_entity_id:m.idp_entity_id,idp_sso_url:m.idp_sso_url,idp_certificate:m.idp_certificate,jit_enabled:m.jit_enabled,...M&&{attribute_mapping:I}}):await t({protocol:"oidc",domain_id:m.domain_id||void 0,oidc_issuer_url:m.oidc_issuer_url,oidc_client_id:m.oidc_client_id,oidc_client_secret:m.oidc_client_secret,oidc_scopes:m.oidc_scopes,jit_enabled:m.jit_enabled,...M&&{attribute_mapping:I}})}finally{s(!1)}},R=async()=>{S(!0),z(null);const w=O=>O.includes("{")||O.includes("}"),I={},M={};if(c==="saml"?(m.idp_entity_id?w(m.idp_entity_id)?(M.entity_id_valid=!1,I.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):M.entity_id_valid=!0:(M.entity_id_valid=!1,I.entity_id_valid="IdP Entity ID is required"),m.idp_sso_url?w(m.idp_sso_url)?(M.sso_url_valid=!1,I.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):M.sso_url_valid=!0:(M.sso_url_valid=!1,I.sso_url_valid="IdP SSO URL is required"),m.idp_certificate?M.certificate_provided=!0:(M.certificate_provided=!1,I.certificate_provided="X.509 Certificate is required")):(m.oidc_issuer_url?w(m.oidc_issuer_url)?(M.issuer_url_valid=!1,I.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):M.issuer_url_valid=!0:(M.issuer_url_valid=!1,I.issuer_url_valid="Issuer URL is required"),m.oidc_client_id?w(m.oidc_client_id)?(M.client_id_valid=!1,I.client_id_valid="Client ID contains placeholder values - please replace with actual values"):M.client_id_valid=!0:(M.client_id_valid=!1,I.client_id_valid="Client ID is required")),Object.keys(I).length>0){z({success:!1,checks:M,errors:I}),S(!1);return}try{const O=c==="saml"?{protocol:"saml",idp_entity_id:m.idp_entity_id,idp_sso_url:m.idp_sso_url,idp_certificate:m.idp_certificate}:{protocol:"oidc",oidc_issuer_url:m.oidc_issuer_url,oidc_client_id:m.oidc_client_id,oidc_client_secret:m.oidc_client_secret},U=await(o==null?void 0:o(O));U&&z(U)}catch(O){z({success:!1,checks:{},errors:{general:"Test failed: "+O.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:T,children:[p?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[p.logo?e.jsx(Fn,{src:p.logo,alt:p.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:p.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:p.protocol})]}),e.jsx("button",{type:"button",onClick:()=>f(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Nn,{children:"SAML Providers"}),e.jsx(Hi,{children:Gi.filter(w=>w.protocol==="saml").map(w=>e.jsxs(qi,{type:"button",$selected:!1,onClick:()=>_(w),children:[w.logo?e.jsx(Fn,{src:w.logo,alt:w.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Yi,{children:w.name})]},w.id))}),e.jsx(Nn,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(Hi,{children:Gi.filter(w=>w.protocol==="oidc").map(w=>e.jsxs(qi,{type:"button",$selected:!1,onClick:()=>_(w),children:[w.logo?e.jsx(Fn,{src:w.logo,alt:w.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(Qe,{size:18,color:"#666"})}),e.jsx(Yi,{children:w.name})]},w.id))})]}),p&&e.jsxs(e.Fragment,{children:[e.jsxs(Vi,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:C}),e.jsx(br,{onClick:()=>E(C,"acs"),children:l==="acs"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:P}),e.jsx(br,{onClick:()=>E(P,"metadata"),children:l==="metadata"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:v}),e.jsx(br,{onClick:()=>E(v,"callback"),children:l==="callback"?e.jsx(Ve,{size:12}):e.jsx(Jt,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Nn,{style:{margin:0},children:p?`${p.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[p&&p.docUrl&&e.jsxs("a",{href:p.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Ss,{size:12})," Docs"]}),e.jsx(Y,{type:"button",onClick:R,disabled:$||!p,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:$?e.jsx(Ee,{size:16}):"Test Connection"}),e.jsx(Y,{type:"submit",disabled:i||j.length===0||!p,style:{width:"auto",padding:"8px 16px"},children:i?e.jsx(Ee,{size:16}):"Create Connection"})]})]}),b&&(()=>{const w={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:b.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${b.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:b.success?"#10b981":"#ef4444"},children:b.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(b.checks).map(([I,M])=>{var O;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:M?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:M?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:w[I]||I.replace(/_/g," ").replace(/\b\w/g,U=>U.toUpperCase())}),((O=b.errors)==null?void 0:O[I])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:b.errors[I]})]})]},I)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!p&&e.jsxs(he,{children:[e.jsx(ce,{children:"Protocol *"}),e.jsxs(Zi,{value:c,onChange:w=>h(w.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ce,{children:"Domain *"}),k?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):j.length===0?e.jsx(Vi,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(Zi,{value:m.domain_id,onChange:w=>y({...m,domain_id:w.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),j.map(w=>e.jsx("option",{value:w.id,children:w.fqdn},w.id))]})]}),c==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ce,{children:"IdP Entity ID *"}),e.jsx(le,{type:"text",value:m.idp_entity_id,onChange:w=>y({...m,idp_entity_id:w.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"IdP SSO URL *"}),e.jsx(le,{type:"url",value:m.idp_sso_url,onChange:w=>y({...m,idp_sso_url:w.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsx(ce,{children:"X.509 Certificate *"}),e.jsx(ex,{value:m.idp_certificate,onChange:w=>y({...m,idp_certificate:w.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Issuer URL *"}),e.jsx(le,{type:"url",value:m.oidc_issuer_url,onChange:w=>y({...m,oidc_issuer_url:w.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Client ID *"}),e.jsx(le,{type:"text",value:m.oidc_client_id,onChange:w=>y({...m,oidc_client_id:w.target.value}),placeholder:"your-client-id",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Client Secret *"}),e.jsx(le,{type:"password",value:m.oidc_client_secret,onChange:w=>y({...m,oidc_client_secret:w.target.value}),placeholder:"your-client-secret",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Scopes"}),e.jsx(le,{type:"text",value:m.oidc_scopes,onChange:w=>y({...m,oidc_scopes:w.target.value}),placeholder:"openid profile email"})]})]}),e.jsxs(he,{style:{gridColumn:"1 / -1"},children:[e.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer"},children:[e.jsx("input",{type:"checkbox",checked:m.jit_enabled,onChange:w=>y({...m,jit_enabled:w.target.checked}),style:{width:"16px",height:"16px"}}),e.jsx("span",{style:{fontWeight:500,color:"var(--color-foreground)"},children:"Enable JIT Provisioning"})]}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px",marginLeft:"24px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px"},children:[e.jsxs("div",{onClick:()=>x(!g),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:g?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:g?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),g&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"First Name Attribute"}),e.jsx(le,{type:"text",value:m.attr_first_name,onChange:w=>y({...m,attr_first_name:w.target.value}),placeholder:c==="saml"?"givenName":"given_name"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Last Name Attribute"}),e.jsx(le,{type:"text",value:m.attr_last_name,onChange:w=>y({...m,attr_last_name:w.target.value}),placeholder:c==="saml"?"surname":"family_name"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Email Attribute"}),e.jsx(le,{type:"text",value:m.attr_email,onChange:w=>y({...m,attr_email:w.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},Qi=d.div`
|
|
2647
2647
|
* {
|
|
2648
2648
|
box-sizing: border-box;
|
|
2649
2649
|
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
@@ -2745,9 +2745,9 @@ cursor: pointer;
|
|
|
2745
2745
|
flex-wrap: wrap;
|
|
2746
2746
|
gap: 12px;
|
|
2747
2747
|
margin-bottom: 24px;
|
|
2748
|
-
`,ux=()=>{var M,
|
|
2749
|
-
`))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const T=a.useMemo(()=>i.filter(A=>A.organization.id===(t==null?void 0:t.id)),[i,t==null?void 0:t.id]),R=async()=>{if(!(!t||j!==t.name))try{v(!0),await o(""),await
|
|
2750
|
-
10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((U=s==null?void 0:s.b2b_settings)==null?void 0:U.workspaces_enabled)&&T.length>0&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx($s,{options:T.map(
|
|
2748
|
+
`,ux=()=>{var M,O,U,F;const{activeOrganization:t,loading:r}=Ye(),{switchOrganization:o,refetch:n}=Be(),{workspaces:i}=wt(),{deployment:s}=me(),{deleteOrganization:p,updateOrganization:f}=Zo(),{toast:c}=et(),[h,l]=a.useState((t==null?void 0:t.name)||""),[u,g]=a.useState((t==null?void 0:t.description)||""),[x,m]=a.useState((t==null?void 0:t.image_url)||null),y=a.useRef(null),[$,S]=a.useState(!1),[b,z]=a.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[j,k]=a.useState(""),[_,v]=a.useState(!1),[P,C]=a.useState(!1),E=a.useCallback(async()=>{if(!(!t||$))try{S(!0),await f(t,{name:h,description:u}),c("Changes saved","info")}catch(L){const A=L.message||"Failed to save changes. Please try again.";c(A,"error")}finally{S(!1)}},[t,h,u,x,b,f,c]);a.useEffect(()=>{var L;t&&(l(t.name||""),g(t.description||""),m(t.image_url||null),z({allowed_ips:((L=t.whitelisted_ips)==null?void 0:L.join(`
|
|
2749
|
+
`))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const T=a.useMemo(()=>i.filter(A=>A.organization.id===(t==null?void 0:t.id)),[i,t==null?void 0:t.id]),R=async()=>{if(!(!t||j!==t.name))try{v(!0),await o(""),await p(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{v(!1),k("")}};if(a.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const w=L=>{var A;if((A=L.target.files)!=null&&A[0]){const Q=L.target.files[0];if(Q.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!Q.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&URL.revokeObjectURL(x),m(URL.createObjectURL(Q)),setTimeout(()=>E(),100)}},I=()=>{y.current&&y.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:I,onMouseEnter:L=>{L.currentTarget.style.borderColor="var(--color-primary)",L.currentTarget.style.transform="scale(1.02)"},onMouseLeave:L=>{L.currentTarget.style.borderColor="var(--color-border)",L.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:w,"aria-label":"Upload organization logo"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your organization"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Y,{onClick:()=>{var L;return(L=y.current)==null?void 0:L.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Ur,{size:14}),x?"Change":"Upload"]}),e.jsxs(Y,{onClick:()=>{m(null),y.current&&(y.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(qr,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your organization"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"name",children:"Organization Name"}),e.jsx(le,{id:"name",type:"text",value:h,onChange:L=>l(L.target.value),onBlur:E,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"description",children:"Description"}),e.jsx(le,{id:"description",as:"textarea",value:u,onChange:L=>g(L.target.value),onBlur:E,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),((M=s==null?void 0:s.b2b_settings)==null?void 0:M.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(Cr,{checked:b.mfa_required,onChange:()=>{z(L=>({...L,mfa_required:!L.mfa_required})),setTimeout(()=>E(),100)}})]}),((O=s==null?void 0:s.b2b_settings)==null?void 0:O.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(Cr,{checked:b.ip_restrictions,onChange:()=>{z(L=>({...L,ip_restrictions:!L.ip_restrictions})),setTimeout(()=>E(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),b.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(le,{id:"allowed_ips",as:"textarea",value:b.allowed_ips,onChange:L=>z(A=>({...A,allowed_ips:L.target.value})),onBlur:E,placeholder:`192.168.1.1
|
|
2750
|
+
10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((U=s==null?void 0:s.b2b_settings)==null?void 0:U.workspaces_enabled)&&T.length>0&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx($s,{options:T.map(L=>({value:L.id,label:L.name})),value:b.default_workspace_id,onChange:L=>{z(A=>({...A,default_workspace_id:L})),setTimeout(()=>E(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((F=s==null?void 0:s.b2b_settings)==null?void 0:F.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:P?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this organization, there is no going back. Please be certain."})]}),e.jsx(Y,{onClick:()=>{P?(C(!1),k("")):C(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:P?"Cancel":"Delete"})]}),P&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(le,{id:"confirm_name",type:"text",value:j,onChange:L=>k(L.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Y,{onClick:R,disabled:j!==(t==null?void 0:t.name)||_,style:{background:j===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:j===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:j===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:j===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:_?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})]})})},Ki=d.span`
|
|
2751
2751
|
background: var(--color-primary-background);
|
|
2752
2752
|
color: var(--color-primary);
|
|
2753
2753
|
padding: 4px 8px;
|
|
@@ -2784,7 +2784,7 @@ cursor: pointer;
|
|
|
2784
2784
|
opacity: 0.5;
|
|
2785
2785
|
cursor: not-allowed;
|
|
2786
2786
|
}
|
|
2787
|
-
`,px=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=Ye(),i=a.useRef(null),[s,
|
|
2787
|
+
`,px=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=Ye(),i=a.useRef(null),[s,p]=a.useState(null),{data:f=[],isLoading:c,mutate:h}=Ne(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((C,E)=>({...C,verified:C.verified!==void 0?C.verified:E%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),l=f,[u,g]=a.useState(!1),[x,m]=a.useState(null),[y,$]=a.useState(""),[S,b]=a.useState(null),z=a.useRef(null),j=a.useRef({}),k=a.useMemo(()=>{let P=l;if(y.trim()!==""){const C=y.toLowerCase();P=P.filter(E=>E.fqdn.toLowerCase().includes(C))}return P},[l,y]),_=async P=>{await n(P),h()},v=async P=>{m(P)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(El,{children:[e.jsx(jt,{value:y,onChange:$,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(Y,{ref:z,onClick:()=>g(!u),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),u&&e.jsx(Ui,{onClose:()=>{g(!1),h()},triggerRef:z})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),k!=null&&k.length?e.jsxs(_t,{ref:i,children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Domain"}),e.jsx($e,{children:"Status"}),e.jsx($e,{children:"Date Added"}),e.jsx($e,{})]})}),e.jsx(Ct,{children:k.map(P=>e.jsxs(We,{children:[e.jsx(Le,{children:P.fqdn}),e.jsx(Le,{children:P.verified?e.jsx(Ki,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(Ki,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(ut,{size:9})," Pending Verification"]})}),e.jsx(Le,{children:new Date(P.created_at).toLocaleDateString()}),e.jsx(St,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(nt,{style:{marginLeft:"auto"},open:S===P.id,openChange:C=>b(C?P.id:null),children:[e.jsx(it,{children:e.jsx(Es,{ref:C=>{j.current[P.id]=C},children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{v(P.id),b(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:P.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Te,{onClick:()=>{b(null),navigator.clipboard.writeText(P.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jt,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Te,{onClick:()=>{window.open(`https://${P.fqdn}`,"_blank"),b(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ss,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>{b(null),p(P.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(qr,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),s===P.id&&e.jsx(Zr,{title:"Are you sure you want to delete this domain?",onConfirm:()=>_(P),onCancel:()=>p(null)}),x===P.id&&e.jsx(Ui,{domain:P,onClose:()=>m(null),triggerRef:{current:j.current[P.id]}})]})})]},P.id))})]}):e.jsx(at,{title:y!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},hx=d.div`
|
|
2788
2788
|
width: 40px;
|
|
2789
2789
|
height: 40px;
|
|
2790
2790
|
border-radius: 50%;
|
|
@@ -2796,7 +2796,7 @@ cursor: pointer;
|
|
|
2796
2796
|
font-weight: 400;
|
|
2797
2797
|
font-size: 14px;
|
|
2798
2798
|
overflow: hidden;
|
|
2799
|
-
`,fx=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:i,removeMemberRole:s,removeMember:u}=Ye(),{session:f}=Be(),{toast:c}=et(),[h,l]=a.useState(""),[p,g]=a.useState(!1),x=a.useRef(null),{data:m=[],isLoading:y,mutate:$}=Ne(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:S=[],isLoading:b}=Ne(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),z=S,j=a.useMemo(()=>h?m.filter(C=>{var M;const E=C.user;if(!E)return!1;const T=E.first_name||"",R=E.last_name||"",w=((M=E.primary_email_address)==null?void 0:M.email)||"";return`${T} ${R}`.trim().toLowerCase().includes(h.toLowerCase())||w.toLowerCase().includes(h.toLowerCase())}):m,[m,h]),k=async(C,E,T)=>{try{T?(await s(C,E),c("Role removed successfully","info")):(await i(C,E),c("Role added successfully","info")),$()}catch(R){const w=R.message||"Failed to update role. Please try again.";c(w,"error")}},_=(C="",E="")=>`${C[0]||""}${E[0]||""}`.toUpperCase(),v=(C,E)=>{var T;return((T=C.roles)==null?void 0:T.some(R=>R.id===E))||!1},P=()=>{g(!1),$(),c("Invitation sent successfully","info")};return r||y||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(jt,{value:h,onChange:l,placeholder:"Search members..."})}),e.jsx(Y,{ref:x,onClick:()=>g(!p),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),p&&e.jsx(Cl,{onClose:()=>g(!1),onSuccess:P,roles:z,triggerRef:x}),j.length===0?e.jsx(at,{title:h?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Member"}),e.jsx($e,{children:"Joined"}),e.jsx($e,{children:"Roles"})]})}),e.jsx(Ct,{children:j.map(C=>{var w,I;const E=C.roles||[],T=C.user,R=(T==null?void 0:T.id)===((w=f==null?void 0:f.active_signin)==null?void 0:w.user_id);return e.jsxs(We,{children:[e.jsx(Sl,{children:e.jsxs("div",{children:[e.jsx(hx,{children:T!=null&&T.profile_picture_url?e.jsx("img",{src:T.profile_picture_url,alt:`${T.first_name||""} ${T.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):_(T==null?void 0:T.first_name,T==null?void 0:T.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var L;if(!T)return"Unknown User";const M=`${T.first_name||""} ${T.last_name||""}`.trim();return M||((L=T.primary_email_address)==null?void 0:L.email)||"Unknown User"})()}),R&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(I=T==null?void 0:T.primary_email_address)==null?void 0:I.email})]})]})}),e.jsx(Le,{children:new Date(C.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(St,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsxs(Y,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:E.length>0?E[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[z.map(M=>{const L=v(C,M.id);return e.jsx(Te,{onClick:()=>k(C,M,L),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:M.name}),L&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},M.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>u(C),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(qr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},C.id)})})]})]})},gx=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:i,resendInvitation:s}=Ye(),{toast:u}=et(),[f,c]=a.useState(!1),[h,l]=a.useState(""),p=a.useRef(null),{data:g=[],isLoading:x,mutate:m}=Ne(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:y=[],isLoading:$}=Ne(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),S=y,b=a.useMemo(()=>h?g.filter(_=>_.email.toLowerCase().includes(h.toLowerCase())):g,[g,h]),z=()=>{u("Invitation sent successfully","info"),m(),c(!1)},j=async _=>{try{await i(_),m(),u("Invitation cancelled successfully","info")}catch(v){const P=v.message||"Failed to cancel invitation. Please try again.";u(P,"error")}},k=async _=>{try{await s(_),u("Invitation resent successfully","info")}catch(v){const P=v.message||"Failed to resend invitation. Please try again.";u(P,"error")}};return r||x||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(jt,{value:h,onChange:l,placeholder:"Search invitations..."})}),e.jsx(Y,{ref:p,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx(Cl,{onClose:()=>c(!1),onSuccess:z,roles:S,triggerRef:p}),b.length===0?e.jsx(at,{title:h?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Email"}),e.jsx($e,{children:"Role"}),e.jsx($e,{children:"Invited"}),e.jsx($e,{})]})}),e.jsx(Ct,{children:b.map(_=>{var v;return e.jsxs(We,{children:[e.jsx(Le,{children:_.email}),e.jsx(Le,{children:((v=_.initial_organization_role)==null?void 0:v.name)||"No role"}),e.jsx(Le,{children:new Date(_.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(St,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsx(Es,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>k(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>j(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(qr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},_.id)})})]})]})},mx=()=>{var _;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=Ye(),{deployment:i}=me(),[s,u]=a.useState({isOpen:!1}),[f,c]=a.useState(null),[h,l]=a.useState(null),[p,g]=a.useState(""),[x,m]=a.useState(null),y=a.useRef(null),{data:$=[],isLoading:S,mutate:b}=Ne(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),z=a.useMemo(()=>p?$.filter(v=>v.name.toLowerCase().includes(p.toLowerCase())):$,[$,p]),j=async v=>{try{v.id?(await new Promise(P=>setTimeout(P,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(P=>setTimeout(P,1e3)),c({text:"Role created successfully",type:"success"})),u({isOpen:!1}),b()}catch(P){const C=(P==null?void 0:P.message)||(v.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");v.id?c({text:C,type:"error"}):c({text:C,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},k=async v=>{try{await n(v),b()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(ut,{size:16}),f.text]}),e.jsxs(El,{children:[e.jsx(jt,{placeholder:"Search roles",onChange:g,value:p}),((_=i==null?void 0:i.b2b_settings)==null?void 0:_.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(Y,{ref:y,onClick:()=>u({isOpen:!s.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),s.isOpen&&!s.role&&e.jsx(Wi,{role:s.role,onClose:()=>u({isOpen:!1}),onSuccess:j,triggerRef:y})]})]}),z.length===0?e.jsx(at,{title:p?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Role"}),e.jsx($e,{children:"Permissions"}),e.jsx($e,{})]})}),e.jsx(Ct,{children:z.map(v=>{var P;return e.jsxs(We,{children:[e.jsx(Le,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:v.name})}),e.jsx(Le,{style:{color:"var(--color-secondary-text)"},children:v.permissions.join(", ")}),e.jsx(St,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:h===v.id,openChange:C=>l(C?v.id:null),children:[e.jsx(it,{children:e.jsx(Es,{disabled:!v.organization_id,"data-role-dropdown-trigger":v.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{l(null),u({isOpen:!0,role:v})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{l(null),m(v.id)},children:"Remove Role"})]})]}),x===v.id&&e.jsx(Zr,{title:"Are you sure you want to delete this role?",onConfirm:()=>k(v),onCancel:()=>m(null)}),s.isOpen&&((P=s.role)==null?void 0:P.id)===v.id&&e.jsx(Wi,{role:s.role,onClose:()=>{u({isOpen:!1}),l(null)},onSuccess:j})]})})]},v.id)})})]})]})},Il=()=>{const{loading:t,activeOrganization:r}=Ye(),[o,n]=a.useState("general"),[i,s]=a.useState(null),[u,f]=a.useState("info"),c=a.useCallback((h,l="info")=>{s(h),f(l),setTimeout(()=>s(null),3e3)},[s]);return t?e.jsx(Bn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):r?e.jsx(Qi,{children:e.jsx(_l.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Bn,{children:[e.jsx(cx,{children:e.jsxs(lx,{children:[e.jsx(hr,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(fr,{children:[e.jsx(er,{size:16}),"General"]})}),e.jsx(hr,{$isActive:o==="domains",onClick:()=>n("domains"),children:e.jsxs(fr,{children:[e.jsx(eh,{size:16}),"Domains"]})}),e.jsx(hr,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(fr,{children:[e.jsx(Wo,{size:16}),"Members"]})}),e.jsx(hr,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(fr,{children:[e.jsx(Hr,{size:16}),"Invitations"]})}),e.jsx(hr,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"Roles"]})}),e.jsx(hr,{$isActive:o==="sso",onClick:()=>n("sso"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"SSO"]})})]})}),e.jsxs(dx,{children:[o==="general"&&e.jsx(ux,{}),o==="domains"&&e.jsx(px,{}),o==="members"&&e.jsx(fx,{}),o==="invitations"&&e.jsx(gx,{}),o==="roles"&&e.jsx(mx,{}),o==="sso"&&e.jsx(tx,{})]}),i&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[u==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:i})]})})]})})}):e.jsx(Qi,{children:e.jsx(Bn,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(Ur,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(Dl,{})]})})})},xx=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:i,footerContent:s,customContent:u,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:i||o}),u||f||e.jsx(Il,{}),s&&e.jsx(ke.Footer,{children:s})]})})}),vx=d.div`
|
|
2799
|
+
`,fx=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:i,removeMemberRole:s,removeMember:p}=Ye(),{session:f}=Be(),{toast:c}=et(),[h,l]=a.useState(""),[u,g]=a.useState(!1),x=a.useRef(null),{data:m=[],isLoading:y,mutate:$}=Ne(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:S=[],isLoading:b}=Ne(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),z=S,j=a.useMemo(()=>h?m.filter(C=>{var M;const E=C.user;if(!E)return!1;const T=E.first_name||"",R=E.last_name||"",w=((M=E.primary_email_address)==null?void 0:M.email)||"";return`${T} ${R}`.trim().toLowerCase().includes(h.toLowerCase())||w.toLowerCase().includes(h.toLowerCase())}):m,[m,h]),k=async(C,E,T)=>{try{T?(await s(C,E),c("Role removed successfully","info")):(await i(C,E),c("Role added successfully","info")),$()}catch(R){const w=R.message||"Failed to update role. Please try again.";c(w,"error")}},_=(C="",E="")=>`${C[0]||""}${E[0]||""}`.toUpperCase(),v=(C,E)=>{var T;return((T=C.roles)==null?void 0:T.some(R=>R.id===E))||!1},P=()=>{g(!1),$(),c("Invitation sent successfully","info")};return r||y||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(jt,{value:h,onChange:l,placeholder:"Search members..."})}),e.jsx(Y,{ref:x,onClick:()=>g(!u),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),u&&e.jsx(Cl,{onClose:()=>g(!1),onSuccess:P,roles:z,triggerRef:x}),j.length===0?e.jsx(at,{title:h?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Member"}),e.jsx($e,{children:"Joined"}),e.jsx($e,{children:"Roles"})]})}),e.jsx(Ct,{children:j.map(C=>{var w,I;const E=C.roles||[],T=C.user,R=(T==null?void 0:T.id)===((w=f==null?void 0:f.active_signin)==null?void 0:w.user_id);return e.jsxs(We,{children:[e.jsx(Sl,{children:e.jsxs("div",{children:[e.jsx(hx,{children:T!=null&&T.profile_picture_url?e.jsx("img",{src:T.profile_picture_url,alt:`${T.first_name||""} ${T.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):_(T==null?void 0:T.first_name,T==null?void 0:T.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var O;if(!T)return"Unknown User";const M=`${T.first_name||""} ${T.last_name||""}`.trim();return M||((O=T.primary_email_address)==null?void 0:O.email)||"Unknown User"})()}),R&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(I=T==null?void 0:T.primary_email_address)==null?void 0:I.email})]})]})}),e.jsx(Le,{children:new Date(C.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(St,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsxs(Y,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:E.length>0?E[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[z.map(M=>{const O=v(C,M.id);return e.jsx(Te,{onClick:()=>k(C,M,O),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:M.name}),O&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},M.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>p(C),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(qr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},C.id)})})]})]})},gx=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:i,resendInvitation:s}=Ye(),{toast:p}=et(),[f,c]=a.useState(!1),[h,l]=a.useState(""),u=a.useRef(null),{data:g=[],isLoading:x,mutate:m}=Ne(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:y=[],isLoading:$}=Ne(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),S=y,b=a.useMemo(()=>h?g.filter(_=>_.email.toLowerCase().includes(h.toLowerCase())):g,[g,h]),z=()=>{p("Invitation sent successfully","info"),m(),c(!1)},j=async _=>{try{await i(_),m(),p("Invitation cancelled successfully","info")}catch(v){const P=v.message||"Failed to cancel invitation. Please try again.";p(P,"error")}},k=async _=>{try{await s(_),p("Invitation resent successfully","info")}catch(v){const P=v.message||"Failed to resend invitation. Please try again.";p(P,"error")}};return r||x||$?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(jt,{value:h,onChange:l,placeholder:"Search invitations..."})}),e.jsx(Y,{ref:u,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx(Cl,{onClose:()=>c(!1),onSuccess:z,roles:S,triggerRef:u}),b.length===0?e.jsx(at,{title:h?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Email"}),e.jsx($e,{children:"Role"}),e.jsx($e,{children:"Invited"}),e.jsx($e,{})]})}),e.jsx(Ct,{children:b.map(_=>{var v;return e.jsxs(We,{children:[e.jsx(Le,{children:_.email}),e.jsx(Le,{children:((v=_.initial_organization_role)==null?void 0:v.name)||"No role"}),e.jsx(Le,{children:new Date(_.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(St,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsx(Es,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>k(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>j(_),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(qr,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},_.id)})})]})]})},mx=()=>{var _;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=Ye(),{deployment:i}=me(),[s,p]=a.useState({isOpen:!1}),[f,c]=a.useState(null),[h,l]=a.useState(null),[u,g]=a.useState(""),[x,m]=a.useState(null),y=a.useRef(null),{data:$=[],isLoading:S,mutate:b}=Ne(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),z=a.useMemo(()=>u?$.filter(v=>v.name.toLowerCase().includes(u.toLowerCase())):$,[$,u]),j=async v=>{try{v.id?(await new Promise(P=>setTimeout(P,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(P=>setTimeout(P,1e3)),c({text:"Role created successfully",type:"success"})),p({isOpen:!1}),b()}catch(P){const C=(P==null?void 0:P.message)||(v.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");v.id?c({text:C,type:"error"}):c({text:C,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},k=async v=>{try{await n(v),b()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(ut,{size:16}),f.text]}),e.jsxs(El,{children:[e.jsx(jt,{placeholder:"Search roles",onChange:g,value:u}),((_=i==null?void 0:i.b2b_settings)==null?void 0:_.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(Y,{ref:y,onClick:()=>p({isOpen:!s.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),s.isOpen&&!s.role&&e.jsx(Wi,{role:s.role,onClose:()=>p({isOpen:!1}),onSuccess:j,triggerRef:y})]})]}),z.length===0?e.jsx(at,{title:u?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Role"}),e.jsx($e,{children:"Permissions"}),e.jsx($e,{})]})}),e.jsx(Ct,{children:z.map(v=>{var P;return e.jsxs(We,{children:[e.jsx(Le,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:v.name})}),e.jsx(Le,{style:{color:"var(--color-secondary-text)"},children:v.permissions.join(", ")}),e.jsx(St,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:h===v.id,openChange:C=>l(C?v.id:null),children:[e.jsx(it,{children:e.jsx(Es,{disabled:!v.organization_id,"data-role-dropdown-trigger":v.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{l(null),p({isOpen:!0,role:v})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{l(null),m(v.id)},children:"Remove Role"})]})]}),x===v.id&&e.jsx(Zr,{title:"Are you sure you want to delete this role?",onConfirm:()=>k(v),onCancel:()=>m(null)}),s.isOpen&&((P=s.role)==null?void 0:P.id)===v.id&&e.jsx(Wi,{role:s.role,onClose:()=>{p({isOpen:!1}),l(null)},onSuccess:j})]})})]},v.id)})})]})]})},Il=()=>{const{loading:t,activeOrganization:r}=Ye(),[o,n]=a.useState("general"),[i,s]=a.useState(null),[p,f]=a.useState("info"),c=a.useCallback((h,l="info")=>{s(h),f(l),setTimeout(()=>s(null),3e3)},[s]);return t?e.jsx(Bn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):r?e.jsx(Qi,{children:e.jsx(_l.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Bn,{children:[e.jsx(cx,{children:e.jsxs(lx,{children:[e.jsx(hr,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(fr,{children:[e.jsx(er,{size:16}),"General"]})}),e.jsx(hr,{$isActive:o==="domains",onClick:()=>n("domains"),children:e.jsxs(fr,{children:[e.jsx(eh,{size:16}),"Domains"]})}),e.jsx(hr,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(fr,{children:[e.jsx(Wo,{size:16}),"Members"]})}),e.jsx(hr,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(fr,{children:[e.jsx(Hr,{size:16}),"Invitations"]})}),e.jsx(hr,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"Roles"]})}),e.jsx(hr,{$isActive:o==="sso",onClick:()=>n("sso"),children:e.jsxs(fr,{children:[e.jsx(Qe,{size:16}),"SSO"]})})]})}),e.jsxs(dx,{children:[o==="general"&&e.jsx(ux,{}),o==="domains"&&e.jsx(px,{}),o==="members"&&e.jsx(fx,{}),o==="invitations"&&e.jsx(gx,{}),o==="roles"&&e.jsx(mx,{}),o==="sso"&&e.jsx(tx,{})]}),i&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:i})]})})]})})}):e.jsx(Qi,{children:e.jsx(Bn,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(Ur,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(Dl,{})]})})})},xx=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:i,footerContent:s,customContent:p,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:i||o}),p||f||e.jsx(Il,{}),s&&e.jsx(ke.Footer,{children:s})]})})}),vx=d.div`
|
|
2800
2800
|
display: flex;
|
|
2801
2801
|
height: 100%;
|
|
2802
2802
|
min-height: 400px;
|
|
@@ -3087,7 +3087,7 @@ cursor: pointer;
|
|
|
3087
3087
|
align-items: center;
|
|
3088
3088
|
justify-content: center;
|
|
3089
3089
|
color: var(--color-primary);
|
|
3090
|
-
`,Is=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var I;const[i,s]=a.useState(""),[
|
|
3090
|
+
`,Is=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var I;const[i,s]=a.useState(""),[p,f]=a.useState(""),[c,h]=a.useState(),[l,u]=a.useState(null),[g,x]=a.useState(!1),[m,y]=a.useState(!1),[$,S]=a.useState(t),b=a.useRef(null),z=a.useRef(null),{toast:j}=et(),{createWorkspace:k}=wt(),{organizationMemberships:_}=yt(),v=(I=_==null?void 0:_.find(M=>M.organization.id===$))==null?void 0:I.organization,P=M=>{if(M.target.files&&M.target.files[0]){const O=M.target.files[0];if(O.size>2*1024*1024){j("File size cannot exceed 2MB","error");return}if(!O.type.startsWith("image/")){j("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),h(O),u(URL.createObjectURL(O))}},C=()=>{var M;(M=b.current)==null||M.click()},E=M=>M.split(" ").map(O=>O[0]).join("").toUpperCase().slice(0,2)||"W",T=M=>M.trim().replace(/[<>\"'&]/g,""),R=M=>M.length>=2&&M.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(M),w=async()=>{const M=T(i),O=T(p);if(!M||!$){j("Please enter a workspace name","error");return}if(!R(M)){j("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(O.length>500){j("Description must be less than 500 characters","error");return}x(!0);try{const U=await k($,M,c,O);r==null||r(U)}catch(U){const F=U.message||"Failed to create workspace. Please try again.";j(F,"error")}finally{x(!1)}};return a.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]),a.useEffect(()=>{const M=O=>{z.current&&!z.current.contains(O.target)&&y(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]),e.jsx(fe,{children:e.jsxs(vx,{children:[e.jsxs(bx,{children:[e.jsxs(Pl,{hasImage:!!l,onClick:C,children:[l?e.jsx(wx,{src:l,alt:"Workspace logo"}):e.jsx(jx,{children:E(i||"W")}),e.jsx(Ox,{children:e.jsx(Lx,{children:"Upload Logo"})})]}),e.jsx(Mx,{type:"file",ref:b,onChange:P,accept:"image/png, image/jpeg, image/gif",disabled:g}),e.jsx(_x,{children:"Create new workspace"}),e.jsx(kx,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(yx,{children:[e.jsxs(Cx,{children:[e.jsx(Sx,{children:"Choose your workspace name"}),e.jsx(zx,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs($x,{children:[e.jsxs(Un,{children:[e.jsx(Wn,{children:"Organization"}),e.jsxs(Ax,{ref:z,children:[e.jsxs(Dx,{type:"button",onClick:()=>y(!m),disabled:g,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Xi,{children:v!=null&&v.image_url?e.jsx(Ji,{src:v.image_url,alt:v.name}):E((v==null?void 0:v.name)||"O").charAt(0)}),e.jsx("span",{children:(v==null?void 0:v.name)||"Select organization"})]}),e.jsx(or,{size:16,style:{color:"var(--color-secondary-text)"}})]}),m&&e.jsxs(Fx,{children:[_==null?void 0:_.map(M=>e.jsxs(Rl,{onClick:()=>{S(M.organization.id),y(!1)},children:[e.jsx(Xi,{children:M.organization.image_url?e.jsx(Ji,{src:M.organization.image_url,alt:M.organization.name}):E(M.organization.name).charAt(0)}),e.jsx("span",{children:M.organization.name})]},M.organization.id)),e.jsxs(Nx,{onClick:()=>{y(!1),n==null||n()},children:[e.jsx(Bx,{children:e.jsx(Ze,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Workspace name"}),e.jsx(Ex,{type:"text",value:i,onChange:M=>s(M.target.value),placeholder:"Workspace Name",disabled:g})]}),e.jsxs(Un,{children:[e.jsx(Wn,{children:"Description (optional)"}),e.jsx(Ix,{value:p,onChange:M=>f(M.target.value),placeholder:"What is this workspace for?",disabled:g})]})]}),e.jsxs(Px,{children:[o?e.jsxs(Rx,{onClick:o,disabled:g,children:[e.jsx(Gr,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Tx,{onClick:w,disabled:g||!i.trim(),children:g?"Creating...":"Create"})]})]})]})})},Tl=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[i,s]=a.useState(!1),[p,f]=a.useState(n),{refetch:c,organizationMemberships:h}=yt(),l=()=>{o==null||o(),r==null||r()},u=()=>{s(!0)},g=async()=>{await c(),setTimeout(()=>{if(h&&h.length>0){const x=h[h.length-1];f(x.organization.id)}s(!1)},500)};return e.jsx(fe,{children:e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsx(ke.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(ke.Body,{style:{padding:0},children:i?e.jsx(an,{onSuccess:g,onCancel:()=>s(!1)}):e.jsx(Is,{organizationId:p||n,onSuccess:l,onCancel:r,onCreateOrganization:u})})})})})})},Ux=d.div`
|
|
3091
3091
|
position: fixed;
|
|
3092
3092
|
width: 360px;
|
|
3093
3093
|
max-width: calc(100vw - 48px);
|
|
@@ -3136,7 +3136,7 @@ cursor: pointer;
|
|
|
3136
3136
|
color: var(--color-foreground);
|
|
3137
3137
|
background: var(--color-input-background);
|
|
3138
3138
|
}
|
|
3139
|
-
`,Yx=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:i})=>{const s=a.useRef(null),[
|
|
3139
|
+
`,Yx=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:i})=>{const s=a.useRef(null),[p,f]=a.useState(""),[c,h]=a.useState(null),[l,u]=a.useState(!1),[g,x]=a.useState(!1),[m,y]=a.useState({top:0,left:0}),{toast:$}=et(),S=o.map(j=>({value:j.id,label:j.name}));a.useEffect(()=>{x(!0);const j=setTimeout(()=>{if(!s.current||!(i!=null&&i.current))return;const P=i.current;if(P){const C=P.getBoundingClientRect(),E=360,T=250,R=8;let w=0,I=0;const M=window.innerHeight-C.bottom,O=C.top;M>=T+R?(w=C.bottom+R,I=C.right-E,I<R&&(I=C.left,I+E>window.innerWidth-R&&(I=(window.innerWidth-E)/2))):O>=T+R?(w=C.top-T-R,I=C.right-E,I<R&&(I=C.left,I+E>window.innerWidth-R&&(I=(window.innerWidth-E)/2))):(w=C.bottom+R,I=C.right-E,I<R&&(I=C.left)),y({top:w,left:I})}},10),k=P=>{s.current&&!s.current.contains(P.target)&&(t==null||t())},_=P=>{P.key==="Escape"&&(t==null||t())},v=setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",_)},100);return()=>{clearTimeout(j),clearTimeout(v),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",_)}},[t,i]);const b=j=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(j),z=async()=>{const j=p.trim().toLowerCase();if(!(!j||!c)){if(!b(j)){$("Please enter a valid email address","error");return}if(j.length>320){$("Email address is too long","error");return}u(!0);try{await n(j,c.id),r==null||r()}catch(k){const _=k.message||"Failed to send invitation. Please try again.";$(_,"error")}finally{u(!1)}}};return g?e.jsxs(Ux,{ref:s,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(Wx,{children:[e.jsx(Vx,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(qx,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Je,{size:16})})]}),e.jsx(Gx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Email Address"}),e.jsx(le,{type:"email",placeholder:"colleague@company.com",value:p,onChange:j=>f(j.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Role"}),e.jsx($s,{options:S,value:c==null?void 0:c.id,onChange:j=>h(o.find(k=>k.id===j)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(Hx,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Y,{onClick:z,disabled:!p||!c||l,style:{width:"auto"},children:l?e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},Zx=d.div`
|
|
3140
3140
|
position: fixed;
|
|
3141
3141
|
width: 360px;
|
|
3142
3142
|
max-width: calc(100vw - 48px);
|
|
@@ -3185,7 +3185,7 @@ cursor: pointer;
|
|
|
3185
3185
|
color: var(--color-foreground);
|
|
3186
3186
|
background: var(--color-input-background);
|
|
3187
3187
|
}
|
|
3188
|
-
`,ea=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var j;const i=a.useRef(null),[s,
|
|
3188
|
+
`,ea=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var j;const i=a.useRef(null),[s,p]=a.useState((o==null?void 0:o.name)||""),[f,c]=a.useState((o==null?void 0:o.permissions)||[]),[h,l]=a.useState(!1),{deployment:u}=me(),[g,x]=a.useState(!1),[m,y]=a.useState({top:0,left:0}),{toast:$}=et(),S=!!o,b=(((j=u==null?void 0:u.b2b_settings)==null?void 0:j.workspace_permissions)||[]).map(k=>({value:k,label:k}));a.useEffect(()=>{x(!0);const k=setTimeout(()=>{if(!i.current||!(n!=null&&n.current))return;const C=n.current;if(C){const E=C.getBoundingClientRect(),T=360,R=250,w=8;let I=0,M=0;const O=window.innerHeight-E.bottom,U=E.top;O>=R+w?(I=E.bottom+w,M=E.right-T,M<w&&(M=E.left,M+T>window.innerWidth-w&&(M=(window.innerWidth-T)/2))):U>=R+w?(I=E.top-R-w,M=E.right-T,M<w&&(M=E.left,M+T>window.innerWidth-w&&(M=(window.innerWidth-T)/2))):(I=E.bottom+w,M=E.right-T,M<w&&(M=E.left)),y({top:I,left:M})}},10),_=C=>{i.current&&!i.current.contains(C.target)&&(t==null||t())},v=C=>{C.key==="Escape"&&(t==null||t())},P=setTimeout(()=>{document.addEventListener("mousedown",_),document.addEventListener("keydown",v)},100);return()=>{clearTimeout(k),clearTimeout(P),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",v)}},[t,n]);const z=async()=>{if(s.trim()){l(!0);try{const k={id:o==null?void 0:o.id,name:s.trim(),permissions:f};r==null||r(k)}catch(k){const _=k.message||"Failed to save role. Please try again.";$(_,"error")}finally{l(!1)}}};return g?e.jsxs(Zx,{ref:i,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),children:[e.jsxs(Qx,{children:[e.jsx(Kx,{children:S?"Edit Role":"Add Role"}),e.jsx(e0,{onClick:t,children:e.jsx(Je,{size:16})})]}),e.jsx(Xx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ce,{children:"Role Name"}),e.jsx(le,{type:"text",value:s,onChange:k=>p(k.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{children:"Permissions"}),e.jsx(gl,{options:b,value:f,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(Jx,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(Y,{onClick:z,disabled:!s.trim()||h,style:{width:"auto"},children:h?"Saving...":S?"Update":"Create"})]})]}):null},Er=a.createContext(void 0),Mt=()=>{const t=a.useContext(Er);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},t0=d.div`
|
|
3189
3189
|
* {
|
|
3190
3190
|
box-sizing: border-box;
|
|
3191
3191
|
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
@@ -3351,10 +3351,10 @@ cursor: pointer;
|
|
|
3351
3351
|
opacity: 0.5;
|
|
3352
3352
|
cursor: not-allowed;
|
|
3353
3353
|
}
|
|
3354
|
-
`,p0=()=>{const{activeWorkspace:t,loading:r,getRoles:o}=Rt(),{workspaces:n}=wt(),{client:i}=Fe(),s=n==null?void 0:n.find(R=>R.id===(t==null?void 0:t.id)),[
|
|
3355
|
-
`))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const R=W=>{var K;if((K=W.target.files)!=null&&K[0]){const oe=W.target.files[0];x(oe),y(URL.createObjectURL(oe)),setTimeout(()=>I(),100)}},w=()=>{E.current&&E.current.click()},I=a.useCallback(async()=>{if(!(!t||b))try{z(!0);const W={};g&&(W.image=g,x(null)),
|
|
3354
|
+
`,p0=()=>{const{activeWorkspace:t,loading:r,getRoles:o}=Rt(),{workspaces:n}=wt(),{client:i}=Fe(),s=n==null?void 0:n.find(R=>R.id===(t==null?void 0:t.id)),[p,f]=a.useState(!0),[c,h]=a.useState(!0),[l,u]=a.useState(""),[g,x]=a.useState(""),[m,y]=a.useState([]),[$,S]=a.useState([]),[b,z]=a.useState(!1),j=a.useRef(null),k=a.useCallback(async()=>{if(!t||!s)return[];try{return(await G(await i(`/organizations/${s.organization.id}/invitations`,{method:"GET"}))).data.filter(I=>I.workspace_id===t.id)}catch{return[]}},[i,t,s]),_=a.useCallback(async(R,w)=>{if(!t||!s)return;const M=(await G(await i(`/organizations/${s.organization.id}/roles`,{method:"GET"}))).data,O=M.find(F=>!F.organization_id)||M[0];return(await G(await i(`/organizations/${s.organization.id}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:R,role_id:O==null?void 0:O.id,workspace_id:t.id,workspace_role_id:w})}))).data},[i,t,s]),v=a.useCallback(async R=>!t||!s?void 0:(await G(await i(`/organizations/${s.organization.id}/invitations/${R}/remove`,{method:"POST"}))).data,[i,t,s]);a.useEffect(()=>{if(!t)return;(async()=>{f(!0),h(!0);try{const[w,I]=await Promise.all([o(),k()]);S(w),y(I)}catch{}finally{f(!1),h(!1)}})()},[t==null?void 0:t.id]);const P=async R=>{try{await v(R.id);const w=await k();y(w)}catch{}},C=async R=>{var w;try{await v(R.id),await _(R.email,R.workspace_role_id||((w=R.initial_workspace_role)==null?void 0:w.id)||R.role_id);const I=await k();y(I),x("Invitation resent successfully"),setTimeout(()=>x(""),3e3)}catch{}},E=async()=>{z(!1);const R=await k();y(R),x("Invitation sent successfully"),setTimeout(()=>x(""),3e3)},T=a.useMemo(()=>l?m.filter(R=>(R.email||"").toLowerCase().includes(l.toLowerCase())):m,[m,l]);return r||p||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[g&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 16px",background:"var(--color-success-background)",color:"var(--color-success)",borderRadius:"6px",fontSize:"14px"},children:["✓ ",g]}),e.jsxs(Ps,{children:[e.jsx(jt,{value:l,onChange:u,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(Y,{ref:j,onClick:()=>z(!b),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),b&&e.jsx(Yx,{onClose:()=>z(!1),onSuccess:E,roles:$,createInvitation:_,triggerRef:j})]})]}),e.jsx("div",{children:T.length===0?e.jsx(at,{title:l?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsx("div",{style:{borderTop:"1px solid var(--color-border)"},children:T.map(R=>{var w,I,M;return e.jsxs(s0,{children:[e.jsx(i0,{children:e.jsxs(c0,{children:[e.jsx(l0,{children:R.email}),e.jsx(d0,{children:((w=R.initial_workspace_role)==null?void 0:w.name)||((I=R.initial_organization_role)==null?void 0:I.name)||((M=R.role)==null?void 0:M.name)})]})}),e.jsx(u0,{children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsx(Ml,{children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>C(R),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Hr,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Te,{$destructive:!0,onClick:()=>P(R),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})]},R.id)})})})]})},h0=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:i,addMemberRole:s,removeMemberRole:p}=Rt(),{session:f}=Be(),{toast:c}=a.useContext(Er)||{},[h,l]=a.useState(""),{data:u=[],isLoading:g,mutate:x}=Ne(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:m=[],isLoading:y}=Ne(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),$=m,S=a.useMemo(()=>h?u.filter(_=>{var R;const v=_.public_user_data;if(!v)return!1;const P=v.first_name||"",C=v.last_name||"",E=((R=v.primary_email_address)==null?void 0:R.email)||"";return`${P} ${C}`.trim().toLowerCase().includes(h.toLowerCase())||E.toLowerCase().includes(h.toLowerCase())}):u,[u,h]),b=async _=>{try{await i(_),c==null||c("Member removed successfully","info"),x()}catch{c==null||c("Failed to remove member","error")}},z=async(_,v,P)=>{try{P?(await p(_,v),c==null||c("Role removed successfully","info")):(await s(_,v),c==null||c("Role added successfully","info")),x()}catch{c==null||c("Failed to toggle role","error"),c==null||c("Failed to update role","error")}},j=(_="",v="")=>`${_[0]||""}${v[0]||""}`.toUpperCase(),k=(_,v)=>{var P;return((P=_.roles)==null?void 0:P.some(C=>C.id===v))||!1};return r||g||y?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Ps,{children:e.jsx(jt,{value:h,onChange:l,placeholder:"Search members..."})}),S.length===0?e.jsx(at,{title:h?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Member"}),e.jsx($e,{children:"Joined"}),e.jsx($e,{children:"Role"})]})}),e.jsx(Ct,{children:S.map(_=>{var E,T;const v=_.public_user_data,P=_.roles||[],C=(v==null?void 0:v.id)===((E=f==null?void 0:f.active_signin)==null?void 0:E.user_id);return e.jsxs(We,{children:[e.jsx(Sl,{children:e.jsxs("div",{children:[e.jsx(a0,{children:v&&v.profile_picture_url?e.jsx("img",{src:v.profile_picture_url,alt:`${v.first_name||""} ${v.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):j(v==null?void 0:v.first_name,v==null?void 0:v.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var w;if(!v)return"Unknown User";const R=`${v.first_name||""} ${v.last_name||""}`.trim();return R||((w=v.primary_email_address)==null?void 0:w.email)||"Unknown User"})()}),C&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(T=v==null?void 0:v.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(Le,{children:new Date(_.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(St,{children:e.jsxs(nt,{children:[e.jsx(it,{children:e.jsxs(Y,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:P.length>0?P[0].name:"No role"}),e.jsx(or,{size:14})]})}),e.jsxs(st,{children:[$.map(R=>{const w=k(_,R.id);return e.jsx(Te,{onClick:()=>z(_.id,R.id,w),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:R.name}),w&&e.jsx(Ve,{size:16,color:"var(--color-success)"})]})},R.id)}),e.jsx(sn,{}),e.jsx(Te,{$destructive:!0,onClick:()=>b(_.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(nn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},_.id)})})]})]})},f0=()=>{var Q,ee;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Rt(),{deleteWorkspace:n}=wt(),{deployment:i}=me(),{toast:s}=a.useContext(Er)||{},[p,f]=a.useState((t==null?void 0:t.name)||""),[c,h]=a.useState((t==null?void 0:t.description)||""),[l,u]=a.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[g,x]=a.useState(null),[m,y]=a.useState((t==null?void 0:t.image_url)||null),[$,S]=a.useState(!1),[b,z]=a.useState(!1),[j,k]=a.useState(""),[_,v]=a.useState(!1),[P,C]=a.useState(!1),E=a.useRef(null),T=a.useRef(null);if(a.useEffect(()=>{var W;t&&(f(t.name||""),h(t.description||""),y(t.image_url||null),u({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((W=t.whitelisted_ips)==null?void 0:W.join(`
|
|
3355
|
+
`))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const R=W=>{var K;if((K=W.target.files)!=null&&K[0]){const oe=W.target.files[0];x(oe),y(URL.createObjectURL(oe)),setTimeout(()=>I(),100)}},w=()=>{E.current&&E.current.click()},I=a.useCallback(async()=>{if(!(!t||b))try{z(!0);const W={};g&&(W.image=g,x(null)),p!==t.name&&(W.name=p),c!==t.description&&(W.description=c),l.mfa_required!==t.enforce_2fa&&(W.enforce_2fa=l.mfa_required),l.ip_restrictions!==t.enable_ip_restriction&&(W.enable_ip_restriction=l.ip_restrictions);const K=(t.whitelisted_ips||[]).join(`
|
|
3356
3356
|
`);l.allowed_ips!==K&&(W.whitelisted_ips=l.allowed_ips.split(`
|
|
3357
|
-
`).map(oe=>oe.trim()).filter(oe=>oe!=="")),Object.keys(W).length>0&&(await o(W),S(!0),setTimeout(()=>S(!1),3e3))}catch{s==null||s("Failed to auto-save workspace","error")}finally{z(!1)}},[t,o,
|
|
3357
|
+
`).map(oe=>oe.trim()).filter(oe=>oe!=="")),Object.keys(W).length>0&&(await o(W),S(!0),setTimeout(()=>S(!1),3e3))}catch{s==null||s("Failed to auto-save workspace","error")}finally{z(!1)}},[t,o,p,c,g,l,b]),M=a.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{I()},1e3)},[I]),O=W=>{f(W.target.value),M()},U=W=>{h(W.target.value),M()},F=()=>{T.current&&clearTimeout(T.current),I()},L=()=>{T.current&&clearTimeout(T.current),I()},A=async()=>{if(!(!t||j!==t.name))try{v(!0),await n(t),s==null||s("Workspace deleted successfully","info")}catch(W){s==null||s(W.message||"Failed to delete workspace","error")}finally{v(!1),k(""),C(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:m?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:w,onMouseEnter:W=>{W.currentTarget.style.borderColor="var(--color-primary)",W.currentTarget.style.transform="scale(1.02)"},onMouseLeave:W=>{W.currentTarget.style.borderColor="var(--color-border)",W.currentTarget.style.transform="scale(1)"},children:[m?e.jsx("img",{src:m,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Ur,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:E,style:{display:"none"},accept:"image/*",onChange:R})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Y,{onClick:()=>{var W;return(W=E.current)==null?void 0:W.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Ur,{size:14}),m?"Change":"Upload"]}),e.jsxs(Y,{onClick:()=>{y(null),x(null),E.current&&(E.current.value=""),setTimeout(()=>I(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(nn,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"name",children:"Workspace Name"}),e.jsx(le,{id:"name",type:"text",value:p,onChange:O,onBlur:F,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"description",children:"Description"}),e.jsx(le,{id:"description",as:"textarea",value:c,onChange:U,onBlur:L,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]}),((Q=i==null?void 0:i.b2b_settings)==null?void 0:Q.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(Cr,{checked:l.mfa_required,onChange:()=>{u(W=>({...W,mfa_required:!W.mfa_required})),setTimeout(()=>I(),100)}})]}),((ee=i==null?void 0:i.b2b_settings)==null?void 0:ee.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ce,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(Cr,{checked:l.ip_restrictions,onChange:()=>{u(W=>({...W,ip_restrictions:!W.ip_restrictions})),setTimeout(()=>I(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),l.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(le,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:W=>u(K=>({...K,allowed_ips:W.target.value})),onBlur:I,placeholder:`192.168.1.1
|
|
3358
3358
|
10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:P?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(Y,{onClick:()=>{P?(C(!1),k("")):C(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:P?"Cancel":"Delete"})]}),P&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(le,{id:"confirm_workspace_name",type:"text",value:j,onChange:W=>k(W.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(Y,{onClick:A,disabled:j!==(t==null?void 0:t.name)||_,style:{background:j===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:j===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:j===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:j===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:_?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]}),$&&e.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"var(--color-success-background)",color:"var(--color-success)",padding:"var(--space-sm) var(--space-lg)",borderRadius:"var(--radius-lg)",boxShadow:"0 4px 12px var(--color-shadow)",display:"flex",alignItems:"center",gap:"var(--space-xs)",fontSize:"var(--font-xs)",fontWeight:500,zIndex:1e3,animation:"slideUp 0.3s ease-out"},children:"✓ Changes saved automatically"}),e.jsx("style",{children:`
|
|
3359
3359
|
@keyframes slideUp {
|
|
3360
3360
|
from {
|
|
@@ -3366,7 +3366,7 @@ cursor: pointer;
|
|
|
3366
3366
|
transform: translateX(-50%) translateY(0);
|
|
3367
3367
|
}
|
|
3368
3368
|
}
|
|
3369
|
-
`})]})},g0=()=>{var v;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:i}=Rt(),{toast:s}=a.useContext(Er)||{},{deployment:
|
|
3369
|
+
`})]})},g0=()=>{var v;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:i}=Rt(),{toast:s}=a.useContext(Er)||{},{deployment:p}=me(),[f,c]=a.useState(""),[h,l]=a.useState({isOpen:!1}),[u,g]=a.useState(null),[x,m]=a.useState(null),y=a.useRef(null),$=a.useRef(new Map),{data:S=[],isLoading:b,mutate:z}=Ne(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),j=a.useMemo(()=>f?S.filter(P=>P.name.toLowerCase().includes(f.toLowerCase())):S,[S,f]),k=async P=>{try{await n(P.name,P.permissions||[]),s==null||s("Role created successfully","info"),l({isOpen:!1}),z()}catch{s==null||s("Failed to save role","error"),s==null||s("Failed to create role","error")}},_=async P=>{try{await i(P),s==null||s("Role deleted successfully","info"),m(null),z()}catch{s==null||s("Failed to delete role","error"),s==null||s("Failed to delete role","error")}};return r||b?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Ps,{children:[e.jsx(jt,{placeholder:"Search roles",onChange:c,value:f}),e.jsxs("div",{style:{position:"relative"},children:[((v=p==null?void 0:p.b2b_settings)==null?void 0:v.custom_workspace_role_enabled)&&e.jsx(Y,{ref:y,onClick:()=>l({isOpen:!0,triggerElement:y.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),h.isOpen&&!h.role&&e.jsx(ea,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:k})]})]}),j.length===0?e.jsx(at,{title:f?"No roles match your search":"No roles available",description:f?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Role"}),e.jsx($e,{children:"Permissions"}),e.jsx($e,{})]})}),e.jsx(Ct,{children:j.map(P=>{var C;return e.jsxs(We,{children:[e.jsx(Le,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:P.name})}),e.jsx(Le,{style:{color:"var(--color-secondary-text)"},children:P.permissions&&P.permissions.length>0?P.permissions.join(", "):""}),e.jsx(St,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(nt,{open:u===P.id,openChange:E=>g(E?P.id:null),children:[e.jsx(it,{children:e.jsx(Ml,{ref:E=>{E&&$.current.set(P.id,E)},disabled:!P.workspace_id,"data-role-dropdown-trigger":P.id,children:"•••"})}),e.jsxs(st,{children:[e.jsx(Te,{onClick:()=>{g(null);const E=$.current.get(P.id);l({isOpen:!0,role:P,triggerElement:E||null})},children:"Edit Role"}),e.jsx(Te,{$destructive:!0,onClick:()=>{g(null),m(P.id)},children:"Remove Role"})]})]}),x===P.id&&e.jsx(Zr,{title:"Are you sure you want to delete this role?",onConfirm:()=>_(P),onCancel:()=>m(null)}),h.isOpen&&((C=h.role)==null?void 0:C.id)===P.id&&e.jsx(ea,{role:h.role,triggerRef:{current:h.triggerElement||null},onClose:()=>{l({isOpen:!1}),g(null)},onSuccess:k})]})})]},P.id)})})]})})]})},Ol=()=>{const{activeWorkspace:t,loading:r}=Rt(),[o,n]=a.useState("general"),[i,s]=a.useState(null),[p,f]=a.useState("info"),c=a.useCallback((h,l="info")=>{s(h),f(l),setTimeout(()=>s(null),3e3)},[]);return r?e.jsx(ta,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})}):t?e.jsx(Er.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(t0,{children:e.jsxs(ta,{children:[e.jsx(r0,{children:e.jsxs(o0,{children:[e.jsx(vo,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(bo,{children:[e.jsx(er,{size:16}),"General"]})}),e.jsx(vo,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(bo,{children:[e.jsx(Wo,{size:16}),"Members"]})}),e.jsx(vo,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(bo,{children:[e.jsx(Kc,{size:16}),"Invitations"]})}),e.jsx(vo,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(bo,{children:[e.jsx(Qe,{size:16}),"Roles"]})})]})}),e.jsxs(n0,{children:[o==="general"&&e.jsx(f0,{}),o==="members"&&e.jsx(h0,{}),o==="invitations"&&e.jsx(p0,{}),o==="roles"&&e.jsx(g0,{})]}),i&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:i})]})})]})})}):null},Ll=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:i,footerContent:s,customContent:p,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:i||o}),p||f||e.jsx(Ol,{}),s&&e.jsx(ke.Footer,{children:s})]})})}),Al=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:i=8})=>{const[s,p]=a.useState();return a.useEffect(()=>{if(!r||!t.current){p(void 0);return}const f=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),h=window.innerWidth,l=window.innerHeight,u=h-c.left,g=c.right,x=l-c.bottom,m=c.top;let y={};u>=o?y.left=c.left:g>=o?y.left=c.right-o:y.left=Math.max(i,Math.min(h-o-i,c.left)),x>=150?(y.top=c.bottom+i,y.maxHeight=Math.min(n,x-i*2)):m>=150?(y.bottom=l-c.top+i,y.maxHeight=Math.min(n,m-i*2)):(y.top=c.bottom+i,y.maxHeight=Math.max(100,x-i*2)),p(y)};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[r,o,n,i]),s},ra=d.div`
|
|
3370
3370
|
position: relative;
|
|
3371
3371
|
display: inline-block;
|
|
3372
3372
|
width: 100%;
|
|
@@ -3717,15 +3717,15 @@ cursor: pointer;
|
|
|
3717
3717
|
height: 16px;
|
|
3718
3718
|
background: var(--color-border);
|
|
3719
3719
|
border-radius: 2px;
|
|
3720
|
-
`,Dl=({showPersonal:t=!0})=>{var ue,X,ae;const[r,o]=a.useState(!1),[n,i]=a.useState(!1),[s,
|
|
3720
|
+
`,Dl=({showPersonal:t=!0})=>{var ue,X,ae;const[r,o]=a.useState(!1),[n,i]=a.useState(!1),[s,p]=a.useState(new Set),f=a.useRef(null),c=a.useRef(null),h=Al({triggerRef:f,isOpen:r,minWidth:300}),l=Dr(!1),u=Dr(!1),g=Dr(!1),x=Dr(!1),[m,y]=a.useState(null),[$,S]=a.useState(!1),[b,z]=a.useState(null),{organizationMemberships:j,loading:k,refetch:_}=yt(),{activeOrganization:v,leave:P}=Ye(),{activeWorkspace:C,leave:E}=Rt(),{workspaces:T,loading:R}=wt(),{session:w,loading:I,switchOrganization:M,switchWorkspace:O}=Be(),{deployment:U}=me(),{toast:F}=et(),L=U==null?void 0:U.b2b_settings.organizations_enabled,A=U==null?void 0:U.b2b_settings.workspaces_enabled,Q=U==null?void 0:U.b2b_settings.allow_users_to_create_orgs,ee=!((ue=w==null?void 0:w.active_signin)!=null&&ue.active_organization_membership_id),W=a.useMemo(()=>{var q,B;if(ee)return{name:"Personal account",image_url:(B=(q=w==null?void 0:w.active_signin)==null?void 0:q.user)==null?void 0:B.profile_picture_url,isPersonal:!0};let Z=(v==null?void 0:v.name)||"";return A&&C&&(Z=`${v==null?void 0:v.name} / ${C.name}`),{name:Z,image_url:v==null?void 0:v.image_url,isPersonal:!1}},[ee,v,C,w,A]);a.useEffect(()=>{if(!r)return;let Z=null;const q=setTimeout(()=>{const B=ie=>{var se,we;const H=ie.target;(se=f.current)!=null&&se.contains(H)||(we=c.current)!=null&&we.contains(H)||(o(!1),z(null))};document.addEventListener("mousedown",B),Z=()=>{document.removeEventListener("mousedown",B)}},50);return()=>{clearTimeout(q),Z==null||Z()}},[r]),a.useEffect(()=>{if(b){const Z=setTimeout(()=>{z(null)},5e3);return()=>clearTimeout(Z)}},[b]);const K=()=>{_()};if(!L)return null;const oe=Z=>{i(!0),M(Z).finally(()=>{i(!1)})},te=Z=>{i(!0),O(Z).finally(()=>{i(!1)})},de=Z=>{const q=new Set(s);q.has(Z)?q.delete(Z):q.add(Z),p(q)},ne=Z=>Z.split(" ").map(q=>q[0]).join("").toUpperCase().slice(0,2);return k||I?e.jsx(fe,{children:e.jsx(ra,{children:e.jsxs(C0,{children:[e.jsxs(oa,{children:[e.jsx(S0,{}),e.jsx(z0,{})]}),e.jsx($0,{})]})})}):e.jsx(fe,{children:e.jsxs(ra,{children:[e.jsxs(m0,{ref:f,onClick:()=>{o(!r),r||z(null)},disabled:n,children:[e.jsxs(oa,{children:[e.jsx(x0,{children:W.image_url?e.jsx(v0,{src:W.image_url,alt:W.name}):W.isPersonal?e.jsx(Uo,{size:12}):ne(W.name)}),e.jsx(b0,{children:W.name})]}),e.jsx(Gp,{size:16})]}),typeof window<"u"&&Wr.createPortal(e.jsx(fe,{children:e.jsx(y0,{ref:c,$isOpen:r,$position:h,children:k||R?e.jsxs(k0,{children:[e.jsxs(ko,{children:[e.jsx(Co,{}),e.jsxs(So,{children:[e.jsx(zo,{width:"120px"}),e.jsx(la,{width:"80px"})]})]}),e.jsx(gr,{}),e.jsxs(ko,{children:[e.jsx(Co,{}),e.jsx(So,{children:e.jsx(zo,{width:"100px"})})]}),e.jsx(gr,{}),e.jsxs(ko,{children:[e.jsx(Co,{}),e.jsxs(So,{children:[e.jsx(zo,{width:"140px"}),e.jsx(la,{width:"60px"})]})]}),e.jsx(gr,{}),e.jsxs(ko,{children:[e.jsx(Co,{}),e.jsx(So,{children:e.jsx(zo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:ee,onClick:Z=>{Z.stopPropagation(),ee||oe()},disabled:n||ee,children:[ee&&e.jsx(jo,{}),e.jsxs(ht,{children:[e.jsx(w0,{children:(ae=(X=w==null?void 0:w.active_signin)==null?void 0:X.user)!=null&&ae.profile_picture_url?e.jsx(j0,{src:w.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Uo,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Personal account"})})]}),!ee&&e.jsx(yo,{className:"hover-arrow",size:14})]}),!ee&&v&&e.jsx(gr,{})]}),!ee&&v&&e.jsxs(Ao,{$isActive:!0,onClick:()=>{A&&de(v.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(jo,{}),e.jsxs(ht,{children:[A&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:s.has(v.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(na,{children:v.image_url?e.jsx(sa,{src:v.image_url,alt:v.name}):ne(v.name)}),e.jsx(ft,{children:e.jsx(gt,{children:v.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Do,{onClick:Z=>{Z.stopPropagation(),u.open()},title:"Manage organization",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async Z=>{Z.stopPropagation(),S(!0),z(null);try{await P(),await _(),setTimeout(()=>{S(!1)},500)}catch(q){z(q instanceof Error?q.message:"Failed to leave organization"),S(!1)}},disabled:$,title:"Leave organization",children:e.jsx(It,{size:12})})]})]}),v&&A&&s.has(v.id)&&e.jsxs(e.Fragment,{children:[T==null?void 0:T.filter(Z=>Z.organization.id===v.id).map(Z=>{const q=(C==null?void 0:C.id)===Z.id;return e.jsxs(_o,{as:q?void 0:"button",$isActive:q,onClick:q?void 0:()=>te(Z.id),...q?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[q&&e.jsx(jo,{}),e.jsxs(ht,{children:[e.jsx(aa,{children:Z.image_url?e.jsx("img",{src:Z.image_url,alt:Z.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):ne(Z.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:Z.name})})]}),q?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Do,{onClick:B=>{B.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async B=>{B.stopPropagation();try{E&&await E()}catch(ie){const H=ie.message||"Failed to leave workspace. Please try again.";F(H,"error")}},title:"Leave workspace",children:e.jsx(It,{size:12})})]}):e.jsx(yo,{className:"hover-arrow",size:14})]},Z.id)}),e.jsx(_o,{as:"button",onClick:()=>{y(v.id),g.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(wo,{style:{width:"14px",height:"14px"},children:e.jsx(Ze,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),($||b)&&e.jsxs(e.Fragment,{children:[$&&e.jsxs(ca,{children:[e.jsx(_0,{}),"Leaving organization..."]}),b&&e.jsxs(ca,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),b]})]}),e.jsx(gr,{}),j&&j.length>0&&e.jsx(e.Fragment,{children:j.filter(Z=>Z.organization.id!==(v==null?void 0:v.id)).map(Z=>{const q=Z.organization,B=(T==null?void 0:T.filter(H=>H.organization.id===q.id))||[],ie=s.has(q.id);return e.jsxs(a.Fragment,{children:[e.jsxs(Ao,{as:"button",$isActive:!1,onClick:()=>{A?de(q.id):oe(q.id)},disabled:n,children:[e.jsxs(ht,{children:[A&&e.jsx(or,{size:12,style:{marginRight:"4px",transform:ie?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(na,{children:q.image_url?e.jsx(sa,{src:q.image_url,alt:q.name}):ne(q.name)}),e.jsx(ft,{children:e.jsx(gt,{children:q.name})})]}),e.jsx(yo,{className:"hover-arrow",size:14})]}),A&&ie&&e.jsxs(e.Fragment,{children:[B.map(H=>{const se=(C==null?void 0:C.id)===H.id;return e.jsxs(_o,{as:se?void 0:"button",$isActive:se,onClick:se?void 0:()=>te(H.id),...se?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[se&&e.jsx(jo,{}),e.jsxs(ht,{children:[e.jsx(aa,{children:H.image_url?e.jsx("img",{src:H.image_url,alt:H.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):ne(H.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:H.name})})]}),se?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Do,{onClick:we=>{we.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(er,{size:12})}),e.jsx(Vn,{onClick:async we=>{we.stopPropagation();try{E&&await E()}catch(xe){const ge=xe.message||"Failed to leave workspace. Please try again.";F(ge,"error")}},title:"Leave workspace",children:e.jsx(It,{size:12})})]}):e.jsx(yo,{className:"hover-arrow",size:16})]},H.id)}),e.jsx(_o,{as:"button",onClick:()=>{y(q.id),g.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(wo,{style:{width:"14px",height:"14px"},children:e.jsx(Ze,{size:10})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),e.jsx(gr,{})]},q.id)})}),A?v&&e.jsx(ia,{onClick:()=>{y(v.id),g.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(wo,{children:e.jsx(Ze,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})}):Q&&e.jsx(ia,{onClick:()=>{l.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(wo,{children:e.jsx(Ze,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create organization"})})]})})]})})}),document.body),L&&Q&&e.jsx(Pm,{isOpen:l.isOpen,onClose:l.close,onCreated:K}),e.jsx(xx,{isOpen:u.isOpen,onClose:u.close}),e.jsx(Ll,{isOpen:x.isOpen,onClose:x.close}),m&&e.jsx(Tl,{isOpen:g.isOpen,onClose:()=>{g.close(),y(null)},organizationId:m})]})})};var E0=Object.defineProperty,Ho=Object.getOwnPropertySymbols,Fl=Object.prototype.hasOwnProperty,Nl=Object.prototype.propertyIsEnumerable,da=(t,r,o)=>r in t?E0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,xs=(t,r)=>{for(var o in r||(r={}))Fl.call(r,o)&&da(t,o,r[o]);if(Ho)for(var o of Ho(r))Nl.call(r,o)&&da(t,o,r[o]);return t},vs=(t,r)=>{var o={};for(var n in t)Fl.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Ho)for(var n of Ho(t))r.indexOf(n)<0&&Nl.call(t,n)&&(o[n]=t[n]);return o};/**
|
|
3721
3721
|
* @license QR Code generator library (TypeScript)
|
|
3722
3722
|
* Copyright (c) Project Nayuki.
|
|
3723
3723
|
* SPDX-License-Identifier: MIT
|
|
3724
|
-
*/var nr;(t=>{const r=class je{constructor(c,h,l,p){if(this.version=c,this.errorCorrectionLevel=h,this.modules=[],this.isFunction=[],c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version value out of range");if(p<-1||p>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let g=[];for(let m=0;m<this.size;m++)g.push(!1);for(let m=0;m<this.size;m++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(l);if(this.drawCodewords(x),p==-1){let m=1e9;for(let y=0;y<8;y++){this.applyMask(y),this.drawFormatBits(y);const $=this.getPenaltyScore();$<m&&(p=y,m=$),this.applyMask(y)}}i(0<=p&&p<=7),this.mask=p,this.applyMask(p),this.drawFormatBits(p),this.isFunction=[]}static encodeText(c,h){const l=t.QrSegment.makeSegments(c);return je.encodeSegments(l,h)}static encodeBinary(c,h){const l=t.QrSegment.makeBytes(c);return je.encodeSegments([l],h)}static encodeSegments(c,h,l=1,p=40,g=-1,x=!0){if(!(je.MIN_VERSION<=l&&l<=p&&p<=je.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let m,y;for(m=l;;m++){const z=je.getNumDataCodewords(m,h)*8,j=u.getTotalBits(c,m);if(j<=z){y=j;break}if(m>=p)throw new RangeError("Data too long")}for(const z of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])x&&y<=je.getNumDataCodewords(m,z)*8&&(h=z);let $=[];for(const z of c){o(z.mode.modeBits,4,$),o(z.numChars,z.mode.numCharCountBits(m),$);for(const j of z.getData())$.push(j)}i($.length==y);const S=je.getNumDataCodewords(m,h)*8;i($.length<=S),o(0,Math.min(4,S-$.length),$),o(0,(8-$.length%8)%8,$),i($.length%8==0);for(let z=236;$.length<S;z^=253)o(z,8,$);let b=[];for(;b.length*8<$.length;)b.push(0);return $.forEach((z,j)=>b[j>>>3]|=z<<7-(j&7)),new je(m,h,b,g)}getModule(c,h){return 0<=c&&c<this.size&&0<=h&&h<this.size&&this.modules[h][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),h=c.length;for(let l=0;l<h;l++)for(let p=0;p<h;p++)l==0&&p==0||l==0&&p==h-1||l==h-1&&p==0||this.drawAlignmentPattern(c[l],c[p]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const h=this.errorCorrectionLevel.formatBits<<3|c;let l=h;for(let g=0;g<10;g++)l=l<<1^(l>>>9)*1335;const p=(h<<10|l)^21522;i(p>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(p,g));this.setFunctionModule(8,7,n(p,6)),this.setFunctionModule(8,8,n(p,7)),this.setFunctionModule(7,8,n(p,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(p,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(p,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(p,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let l=0;l<12;l++)c=c<<1^(c>>>11)*7973;const h=this.version<<12|c;i(h>>>18==0);for(let l=0;l<18;l++){const p=n(h,l),g=this.size-11+l%3,x=Math.floor(l/3);this.setFunctionModule(g,x,p),this.setFunctionModule(x,g,p)}}drawFinderPattern(c,h){for(let l=-4;l<=4;l++)for(let p=-4;p<=4;p++){const g=Math.max(Math.abs(p),Math.abs(l)),x=c+p,m=h+l;0<=x&&x<this.size&&0<=m&&m<this.size&&this.setFunctionModule(x,m,g!=2&&g!=4)}}drawAlignmentPattern(c,h){for(let l=-2;l<=2;l++)for(let p=-2;p<=2;p++)this.setFunctionModule(c+p,h+l,Math.max(Math.abs(p),Math.abs(l))!=1)}setFunctionModule(c,h,l){this.modules[h][c]=l,this.isFunction[h][c]=!0}addEccAndInterleave(c){const h=this.version,l=this.errorCorrectionLevel;if(c.length!=je.getNumDataCodewords(h,l))throw new RangeError("Invalid argument");const p=je.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][h],g=je.ECC_CODEWORDS_PER_BLOCK[l.ordinal][h],x=Math.floor(je.getNumRawDataModules(h)/8),m=p-x%p,y=Math.floor(x/p);let $=[];const S=je.reedSolomonComputeDivisor(g);for(let z=0,j=0;z<p;z++){let k=c.slice(j,j+y-g+(z<m?0:1));j+=k.length;const _=je.reedSolomonComputeRemainder(k,S);z<m&&k.push(0),$.push(k.concat(_))}let b=[];for(let z=0;z<$[0].length;z++)$.forEach((j,k)=>{(z!=y-g||k>=m)&&b.push(j[z])});return i(b.length==x),b}drawCodewords(c){if(c.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let h=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let p=0;p<this.size;p++)for(let g=0;g<2;g++){const x=l-g,y=(l+1&2)==0?this.size-1-p:p;!this.isFunction[y][x]&&h<c.length*8&&(this.modules[y][x]=n(c[h>>>3],7-(h&7)),h++)}}i(h==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let h=0;h<this.size;h++)for(let l=0;l<this.size;l++){let p;switch(c){case 0:p=(l+h)%2==0;break;case 1:p=h%2==0;break;case 2:p=l%3==0;break;case 3:p=(l+h)%3==0;break;case 4:p=(Math.floor(l/3)+Math.floor(h/2))%2==0;break;case 5:p=l*h%2+l*h%3==0;break;case 6:p=(l*h%2+l*h%3)%2==0;break;case 7:p=((l+h)%2+l*h%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[h][l]&&p&&(this.modules[h][l]=!this.modules[h][l])}}getPenaltyScore(){let c=0;for(let g=0;g<this.size;g++){let x=!1,m=0,y=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[g][$]==x?(m++,m==5?c+=je.PENALTY_N1:m>5&&c++):(this.finderPenaltyAddHistory(m,y),x||(c+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[g][$],m=1);c+=this.finderPenaltyTerminateAndCount(x,m,y)*je.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,m=0,y=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[$][g]==x?(m++,m==5?c+=je.PENALTY_N1:m>5&&c++):(this.finderPenaltyAddHistory(m,y),x||(c+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[$][g],m=1);c+=this.finderPenaltyTerminateAndCount(x,m,y)*je.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const m=this.modules[g][x];m==this.modules[g][x+1]&&m==this.modules[g+1][x]&&m==this.modules[g+1][x+1]&&(c+=je.PENALTY_N2)}let h=0;for(const g of this.modules)h=g.reduce((x,m)=>x+(m?1:0),h);const l=this.size*this.size,p=Math.ceil(Math.abs(h*20-l*10)/l)-1;return i(0<=p&&p<=9),c+=p*je.PENALTY_N4,i(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,h=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let l=[6];for(let p=this.size-7;l.length<c;p-=h)l.splice(1,0,p);return l}}static getNumRawDataModules(c){if(c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version number out of range");let h=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;h-=(25*l-10)*l-55,c>=7&&(h-=36)}return i(208<=h&&h<=29648),h}static getNumDataCodewords(c,h){return Math.floor(je.getNumRawDataModules(c)/8)-je.ECC_CODEWORDS_PER_BLOCK[h.ordinal][c]*je.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let h=[];for(let p=0;p<c-1;p++)h.push(0);h.push(1);let l=1;for(let p=0;p<c;p++){for(let g=0;g<h.length;g++)h[g]=je.reedSolomonMultiply(h[g],l),g+1<h.length&&(h[g]^=h[g+1]);l=je.reedSolomonMultiply(l,2)}return h}static reedSolomonComputeRemainder(c,h){let l=h.map(p=>0);for(const p of c){const g=p^l.shift();l.push(0),h.forEach((x,m)=>l[m]^=je.reedSolomonMultiply(x,g))}return l}static reedSolomonMultiply(c,h){if(c>>>8||h>>>8)throw new RangeError("Byte out of range");let l=0;for(let p=7;p>=0;p--)l=l<<1^(l>>>7)*285,l^=(h>>>p&1)*c;return i(l>>>8==0),l}finderPenaltyCountPatterns(c){const h=c[1];i(h<=this.size*3);const l=h>0&&c[2]==h&&c[3]==h*3&&c[4]==h&&c[5]==h;return(l&&c[0]>=h*4&&c[6]>=h?1:0)+(l&&c[6]>=h*4&&c[0]>=h?1:0)}finderPenaltyTerminateAndCount(c,h,l){return c&&(this.finderPenaltyAddHistory(h,l),h=0),h+=this.size,this.finderPenaltyAddHistory(h,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(c,h){h[0]==0&&(c+=this.size),h.pop(),h.unshift(c)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function o(f,c,h){if(c<0||c>31||f>>>c)throw new RangeError("Value out of range");for(let l=c-1;l>=0;l--)h.push(f>>>l&1)}function n(f,c){return(f>>>c&1)!=0}function i(f){if(!f)throw new Error("Assertion error")}const s=class Me{constructor(c,h,l){if(this.mode=c,this.numChars=h,this.bitData=l,h<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let h=[];for(const l of c)o(l,8,h);return new Me(Me.Mode.BYTE,c.length,h)}static makeNumeric(c){if(!Me.isNumeric(c))throw new RangeError("String contains non-numeric characters");let h=[];for(let l=0;l<c.length;){const p=Math.min(c.length-l,3);o(parseInt(c.substring(l,l+p),10),p*3+1,h),l+=p}return new Me(Me.Mode.NUMERIC,c.length,h)}static makeAlphanumeric(c){if(!Me.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let h=[],l;for(l=0;l+2<=c.length;l+=2){let p=Me.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;p+=Me.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),o(p,11,h)}return l<c.length&&o(Me.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,h),new Me(Me.Mode.ALPHANUMERIC,c.length,h)}static makeSegments(c){return c==""?[]:Me.isNumeric(c)?[Me.makeNumeric(c)]:Me.isAlphanumeric(c)?[Me.makeAlphanumeric(c)]:[Me.makeBytes(Me.toUtf8ByteArray(c))]}static makeEci(c){let h=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,h);else if(c<16384)o(2,2,h),o(c,14,h);else if(c<1e6)o(6,3,h),o(c,21,h);else throw new RangeError("ECI assignment value out of range");return new Me(Me.Mode.ECI,0,h)}static isNumeric(c){return Me.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Me.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,h){let l=0;for(const p of c){const g=p.mode.numCharCountBits(h);if(p.numChars>=1<<g)return 1/0;l+=4+g+p.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let h=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?h.push(c.charCodeAt(l)):(h.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return h}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let u=s;t.QrSegment=s})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(i,s){this.ordinal=i,this.formatBits=s}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(i,s){this.modeBits=i,this.numBitsCharCount=s}numCharCountBits(i){return this.numBitsCharCount[Math.floor((i+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(nr||(nr={}));var vr=nr;/**
|
|
3724
|
+
*/var nr;(t=>{const r=class je{constructor(c,h,l,u){if(this.version=c,this.errorCorrectionLevel=h,this.modules=[],this.isFunction=[],c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version value out of range");if(u<-1||u>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let g=[];for(let m=0;m<this.size;m++)g.push(!1);for(let m=0;m<this.size;m++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const x=this.addEccAndInterleave(l);if(this.drawCodewords(x),u==-1){let m=1e9;for(let y=0;y<8;y++){this.applyMask(y),this.drawFormatBits(y);const $=this.getPenaltyScore();$<m&&(u=y,m=$),this.applyMask(y)}}i(0<=u&&u<=7),this.mask=u,this.applyMask(u),this.drawFormatBits(u),this.isFunction=[]}static encodeText(c,h){const l=t.QrSegment.makeSegments(c);return je.encodeSegments(l,h)}static encodeBinary(c,h){const l=t.QrSegment.makeBytes(c);return je.encodeSegments([l],h)}static encodeSegments(c,h,l=1,u=40,g=-1,x=!0){if(!(je.MIN_VERSION<=l&&l<=u&&u<=je.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let m,y;for(m=l;;m++){const z=je.getNumDataCodewords(m,h)*8,j=p.getTotalBits(c,m);if(j<=z){y=j;break}if(m>=u)throw new RangeError("Data too long")}for(const z of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])x&&y<=je.getNumDataCodewords(m,z)*8&&(h=z);let $=[];for(const z of c){o(z.mode.modeBits,4,$),o(z.numChars,z.mode.numCharCountBits(m),$);for(const j of z.getData())$.push(j)}i($.length==y);const S=je.getNumDataCodewords(m,h)*8;i($.length<=S),o(0,Math.min(4,S-$.length),$),o(0,(8-$.length%8)%8,$),i($.length%8==0);for(let z=236;$.length<S;z^=253)o(z,8,$);let b=[];for(;b.length*8<$.length;)b.push(0);return $.forEach((z,j)=>b[j>>>3]|=z<<7-(j&7)),new je(m,h,b,g)}getModule(c,h){return 0<=c&&c<this.size&&0<=h&&h<this.size&&this.modules[h][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),h=c.length;for(let l=0;l<h;l++)for(let u=0;u<h;u++)l==0&&u==0||l==0&&u==h-1||l==h-1&&u==0||this.drawAlignmentPattern(c[l],c[u]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const h=this.errorCorrectionLevel.formatBits<<3|c;let l=h;for(let g=0;g<10;g++)l=l<<1^(l>>>9)*1335;const u=(h<<10|l)^21522;i(u>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,n(u,g));this.setFunctionModule(8,7,n(u,6)),this.setFunctionModule(8,8,n(u,7)),this.setFunctionModule(7,8,n(u,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,n(u,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,n(u,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,n(u,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let l=0;l<12;l++)c=c<<1^(c>>>11)*7973;const h=this.version<<12|c;i(h>>>18==0);for(let l=0;l<18;l++){const u=n(h,l),g=this.size-11+l%3,x=Math.floor(l/3);this.setFunctionModule(g,x,u),this.setFunctionModule(x,g,u)}}drawFinderPattern(c,h){for(let l=-4;l<=4;l++)for(let u=-4;u<=4;u++){const g=Math.max(Math.abs(u),Math.abs(l)),x=c+u,m=h+l;0<=x&&x<this.size&&0<=m&&m<this.size&&this.setFunctionModule(x,m,g!=2&&g!=4)}}drawAlignmentPattern(c,h){for(let l=-2;l<=2;l++)for(let u=-2;u<=2;u++)this.setFunctionModule(c+u,h+l,Math.max(Math.abs(u),Math.abs(l))!=1)}setFunctionModule(c,h,l){this.modules[h][c]=l,this.isFunction[h][c]=!0}addEccAndInterleave(c){const h=this.version,l=this.errorCorrectionLevel;if(c.length!=je.getNumDataCodewords(h,l))throw new RangeError("Invalid argument");const u=je.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][h],g=je.ECC_CODEWORDS_PER_BLOCK[l.ordinal][h],x=Math.floor(je.getNumRawDataModules(h)/8),m=u-x%u,y=Math.floor(x/u);let $=[];const S=je.reedSolomonComputeDivisor(g);for(let z=0,j=0;z<u;z++){let k=c.slice(j,j+y-g+(z<m?0:1));j+=k.length;const _=je.reedSolomonComputeRemainder(k,S);z<m&&k.push(0),$.push(k.concat(_))}let b=[];for(let z=0;z<$[0].length;z++)$.forEach((j,k)=>{(z!=y-g||k>=m)&&b.push(j[z])});return i(b.length==x),b}drawCodewords(c){if(c.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let h=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let u=0;u<this.size;u++)for(let g=0;g<2;g++){const x=l-g,y=(l+1&2)==0?this.size-1-u:u;!this.isFunction[y][x]&&h<c.length*8&&(this.modules[y][x]=n(c[h>>>3],7-(h&7)),h++)}}i(h==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let h=0;h<this.size;h++)for(let l=0;l<this.size;l++){let u;switch(c){case 0:u=(l+h)%2==0;break;case 1:u=h%2==0;break;case 2:u=l%3==0;break;case 3:u=(l+h)%3==0;break;case 4:u=(Math.floor(l/3)+Math.floor(h/2))%2==0;break;case 5:u=l*h%2+l*h%3==0;break;case 6:u=(l*h%2+l*h%3)%2==0;break;case 7:u=((l+h)%2+l*h%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[h][l]&&u&&(this.modules[h][l]=!this.modules[h][l])}}getPenaltyScore(){let c=0;for(let g=0;g<this.size;g++){let x=!1,m=0,y=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[g][$]==x?(m++,m==5?c+=je.PENALTY_N1:m>5&&c++):(this.finderPenaltyAddHistory(m,y),x||(c+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[g][$],m=1);c+=this.finderPenaltyTerminateAndCount(x,m,y)*je.PENALTY_N3}for(let g=0;g<this.size;g++){let x=!1,m=0,y=[0,0,0,0,0,0,0];for(let $=0;$<this.size;$++)this.modules[$][g]==x?(m++,m==5?c+=je.PENALTY_N1:m>5&&c++):(this.finderPenaltyAddHistory(m,y),x||(c+=this.finderPenaltyCountPatterns(y)*je.PENALTY_N3),x=this.modules[$][g],m=1);c+=this.finderPenaltyTerminateAndCount(x,m,y)*je.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let x=0;x<this.size-1;x++){const m=this.modules[g][x];m==this.modules[g][x+1]&&m==this.modules[g+1][x]&&m==this.modules[g+1][x+1]&&(c+=je.PENALTY_N2)}let h=0;for(const g of this.modules)h=g.reduce((x,m)=>x+(m?1:0),h);const l=this.size*this.size,u=Math.ceil(Math.abs(h*20-l*10)/l)-1;return i(0<=u&&u<=9),c+=u*je.PENALTY_N4,i(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,h=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let l=[6];for(let u=this.size-7;l.length<c;u-=h)l.splice(1,0,u);return l}}static getNumRawDataModules(c){if(c<je.MIN_VERSION||c>je.MAX_VERSION)throw new RangeError("Version number out of range");let h=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;h-=(25*l-10)*l-55,c>=7&&(h-=36)}return i(208<=h&&h<=29648),h}static getNumDataCodewords(c,h){return Math.floor(je.getNumRawDataModules(c)/8)-je.ECC_CODEWORDS_PER_BLOCK[h.ordinal][c]*je.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let h=[];for(let u=0;u<c-1;u++)h.push(0);h.push(1);let l=1;for(let u=0;u<c;u++){for(let g=0;g<h.length;g++)h[g]=je.reedSolomonMultiply(h[g],l),g+1<h.length&&(h[g]^=h[g+1]);l=je.reedSolomonMultiply(l,2)}return h}static reedSolomonComputeRemainder(c,h){let l=h.map(u=>0);for(const u of c){const g=u^l.shift();l.push(0),h.forEach((x,m)=>l[m]^=je.reedSolomonMultiply(x,g))}return l}static reedSolomonMultiply(c,h){if(c>>>8||h>>>8)throw new RangeError("Byte out of range");let l=0;for(let u=7;u>=0;u--)l=l<<1^(l>>>7)*285,l^=(h>>>u&1)*c;return i(l>>>8==0),l}finderPenaltyCountPatterns(c){const h=c[1];i(h<=this.size*3);const l=h>0&&c[2]==h&&c[3]==h*3&&c[4]==h&&c[5]==h;return(l&&c[0]>=h*4&&c[6]>=h?1:0)+(l&&c[6]>=h*4&&c[0]>=h?1:0)}finderPenaltyTerminateAndCount(c,h,l){return c&&(this.finderPenaltyAddHistory(h,l),h=0),h+=this.size,this.finderPenaltyAddHistory(h,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(c,h){h[0]==0&&(c+=this.size),h.pop(),h.unshift(c)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function o(f,c,h){if(c<0||c>31||f>>>c)throw new RangeError("Value out of range");for(let l=c-1;l>=0;l--)h.push(f>>>l&1)}function n(f,c){return(f>>>c&1)!=0}function i(f){if(!f)throw new Error("Assertion error")}const s=class Me{constructor(c,h,l){if(this.mode=c,this.numChars=h,this.bitData=l,h<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let h=[];for(const l of c)o(l,8,h);return new Me(Me.Mode.BYTE,c.length,h)}static makeNumeric(c){if(!Me.isNumeric(c))throw new RangeError("String contains non-numeric characters");let h=[];for(let l=0;l<c.length;){const u=Math.min(c.length-l,3);o(parseInt(c.substring(l,l+u),10),u*3+1,h),l+=u}return new Me(Me.Mode.NUMERIC,c.length,h)}static makeAlphanumeric(c){if(!Me.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let h=[],l;for(l=0;l+2<=c.length;l+=2){let u=Me.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;u+=Me.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),o(u,11,h)}return l<c.length&&o(Me.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,h),new Me(Me.Mode.ALPHANUMERIC,c.length,h)}static makeSegments(c){return c==""?[]:Me.isNumeric(c)?[Me.makeNumeric(c)]:Me.isAlphanumeric(c)?[Me.makeAlphanumeric(c)]:[Me.makeBytes(Me.toUtf8ByteArray(c))]}static makeEci(c){let h=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,h);else if(c<16384)o(2,2,h),o(c,14,h);else if(c<1e6)o(6,3,h),o(c,21,h);else throw new RangeError("ECI assignment value out of range");return new Me(Me.Mode.ECI,0,h)}static isNumeric(c){return Me.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Me.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,h){let l=0;for(const u of c){const g=u.mode.numCharCountBits(h);if(u.numChars>=1<<g)return 1/0;l+=4+g+u.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let h=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?h.push(c.charCodeAt(l)):(h.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return h}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let p=s;t.QrSegment=s})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(i,s){this.ordinal=i,this.formatBits=s}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(nr||(nr={}));(t=>{(r=>{const o=class{constructor(i,s){this.modeBits=i,this.numBitsCharCount=s}numCharCountBits(i){return this.numBitsCharCount[Math.floor((i+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(nr||(nr={}));var vr=nr;/**
|
|
3725
3725
|
* @license qrcode.react
|
|
3726
3726
|
* Copyright (c) Paul O'Shannessy
|
|
3727
3727
|
* SPDX-License-Identifier: ISC
|
|
3728
|
-
*/var I0={L:vr.QrCode.Ecc.LOW,M:vr.QrCode.Ecc.MEDIUM,Q:vr.QrCode.Ecc.QUARTILE,H:vr.QrCode.Ecc.HIGH},Bl=128,Ul="L",Wl="#FFFFFF",Vl="#000000",Gl=!1,Hl=1,P0=4,R0=0,T0=.1;function ql(t,r=0){const o=[];return t.forEach(function(n,i){let s=null;n.forEach(function(
|
|
3728
|
+
*/var I0={L:vr.QrCode.Ecc.LOW,M:vr.QrCode.Ecc.MEDIUM,Q:vr.QrCode.Ecc.QUARTILE,H:vr.QrCode.Ecc.HIGH},Bl=128,Ul="L",Wl="#FFFFFF",Vl="#000000",Gl=!1,Hl=1,P0=4,R0=0,T0=.1;function ql(t,r=0){const o=[];return t.forEach(function(n,i){let s=null;n.forEach(function(p,f){if(!p&&s!==null){o.push(`M${s+r} ${i+r}h${f-s}v1H${s+r}z`),s=null;return}if(f===n.length-1){if(!p)return;s===null?o.push(`M${f+r},${i+r} h1v1H${f+r}z`):o.push(`M${s+r},${i+r} h${f+1-s}v1H${s+r}z`);return}p&&s===null&&(s=f)})}),o.join("")}function Yl(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((i,s)=>s<r.x||s>=r.x+r.w?i:!1))}function M0(t,r,o,n){if(n==null)return null;const i=t.length+o*2,s=Math.floor(r*T0),p=i/r,f=(n.width||s)*p,c=(n.height||s)*p,h=n.x==null?t.length/2-f/2:n.x*p,l=n.y==null?t.length/2-c/2:n.y*p,u=n.opacity==null?1:n.opacity;let g=null;if(n.excavate){let m=Math.floor(h),y=Math.floor(l),$=Math.ceil(f+h-m),S=Math.ceil(c+l-y);g={x:m,y,w:$,h:S}}const x=n.crossOrigin;return{x:h,y:l,h:c,w:f,excavation:g,opacity:u,crossOrigin:x}}function O0(t,r){return r!=null?Math.max(Math.floor(r),0):t?P0:R0}function Zl({value:t,level:r,minVersion:o,includeMargin:n,marginSize:i,imageSettings:s,size:p,boostLevel:f}){let c=a.useMemo(()=>{const m=(Array.isArray(t)?t:[t]).reduce((y,$)=>(y.push(...vr.QrSegment.makeSegments($)),y),[]);return vr.QrCode.encodeSegments(m,I0[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:h,margin:l,numCells:u,calculatedImageSettings:g}=a.useMemo(()=>{let x=c.getModules();const m=O0(n,i),y=x.length+m*2,$=M0(x,p,m,s);return{cells:x,margin:m,numCells:y,calculatedImageSettings:$}},[c,p,s,n,i]);return{qrcode:c,margin:l,cells:h,numCells:u,calculatedImageSettings:g}}var L0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),A0=a.forwardRef(function(r,o){const n=r,{value:i,size:s=Bl,level:p=Ul,bgColor:f=Wl,fgColor:c=Vl,includeMargin:h=Gl,minVersion:l=Hl,boostLevel:u,marginSize:g,imageSettings:x}=n,y=vs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:$}=y,S=vs(y,["style"]),b=x==null?void 0:x.src,z=a.useRef(null),j=a.useRef(null),k=a.useCallback(I=>{z.current=I,typeof o=="function"?o(I):o&&(o.current=I)},[o]),[_,v]=a.useState(!1),{margin:P,cells:C,numCells:E,calculatedImageSettings:T}=Zl({value:i,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:g,imageSettings:x,size:s});a.useEffect(()=>{if(z.current!=null){const I=z.current,M=I.getContext("2d");if(!M)return;let O=C;const U=j.current,F=T!=null&&U!==null&&U.complete&&U.naturalHeight!==0&&U.naturalWidth!==0;F&&T.excavation!=null&&(O=Yl(C,T.excavation));const L=window.devicePixelRatio||1;I.height=I.width=s*L;const A=s/E*L;M.scale(A,A),M.fillStyle=f,M.fillRect(0,0,E,E),M.fillStyle=c,L0?M.fill(new Path2D(ql(O,P))):C.forEach(function(Q,ee){Q.forEach(function(W,K){W&&M.fillRect(K+P,ee+P,1,1)})}),T&&(M.globalAlpha=T.opacity),F&&M.drawImage(U,T.x+P,T.y+P,T.w,T.h)}}),a.useEffect(()=>{v(!1)},[b]);const R=xs({height:s,width:s},$);let w=null;return b!=null&&(w=a.createElement("img",{src:b,key:b,style:{display:"none"},onLoad:()=>{v(!0)},ref:j,crossOrigin:T==null?void 0:T.crossOrigin})),a.createElement(a.Fragment,null,a.createElement("canvas",xs({style:R,height:s,width:s,ref:k,role:"img"},S)),w)});A0.displayName="QRCodeCanvas";var Rs=a.forwardRef(function(r,o){const n=r,{value:i,size:s=Bl,level:p=Ul,bgColor:f=Wl,fgColor:c=Vl,includeMargin:h=Gl,minVersion:l=Hl,boostLevel:u,title:g,marginSize:x,imageSettings:m}=n,y=vs(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:$,cells:S,numCells:b,calculatedImageSettings:z}=Zl({value:i,level:p,minVersion:l,boostLevel:u,includeMargin:h,marginSize:x,imageSettings:m,size:s});let j=S,k=null;m!=null&&z!=null&&(z.excavation!=null&&(j=Yl(S,z.excavation)),k=a.createElement("image",{href:m.src,height:z.h,width:z.w,x:z.x+$,y:z.y+$,preserveAspectRatio:"none",opacity:z.opacity,crossOrigin:z.crossOrigin}));const _=ql(j,$);return a.createElement("svg",xs({height:s,width:s,viewBox:`0 0 ${b} ${b}`,ref:o,role:"img"},y),!!g&&a.createElement("title",null,g),a.createElement("path",{fill:f,d:`M0,0 h${b}v${b}H0z`,shapeRendering:"crispEdges"}),a.createElement("path",{fill:c,d:_,shapeRendering:"crispEdges"}),k)});Rs.displayName="QRCodeSVG";const D0=d.div`
|
|
3729
3729
|
position: fixed;
|
|
3730
3730
|
background: var(--color-background);
|
|
3731
3731
|
border-radius: var(--radius-md);
|
|
@@ -3764,7 +3764,7 @@ cursor: pointer;
|
|
|
3764
3764
|
justify-content: center;
|
|
3765
3765
|
color: var(--color-muted);
|
|
3766
3766
|
flex-shrink: 0;
|
|
3767
|
-
`,ha=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:i,triggerRef:s})=>{const
|
|
3767
|
+
`,ha=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:i,triggerRef:s})=>{const p=a.useRef(null),[f,c]=a.useState(!1),[h,l]=a.useState({top:0,left:0}),{toast:u}=Mt();a.useEffect(()=>{c(!0);const _=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const C=s.current;if(C){const E=C.getBoundingClientRect(),T=380,R=300,w=8;let I=0,M=0;const O=window.innerHeight-E.bottom,U=E.top;O>=R+w?(I=E.bottom+w,M=E.right-T,M<w&&(M=E.left,M+T>window.innerWidth-w&&(M=(window.innerWidth-T)/2))):U>=R+w?(I=E.top-R-w,M=E.right-T,M<w&&(M=E.left,M+T>window.innerWidth-w&&(M=(window.innerWidth-T)/2))):(I=E.bottom+w,M=E.right-T,M<w&&(M=E.left)),l({top:I,left:M})}},10),v=C=>{p.current&&!p.current.contains(C.target)&&t()},P=C=>{C.key==="Escape"&&t()};return document.addEventListener("mousedown",v),document.addEventListener("keydown",P),()=>{clearTimeout(_),document.removeEventListener("mousedown",v),document.removeEventListener("keydown",P)}},[t,s]);const[g,x]=a.useState(i?"otp":"email"),[m,y]=a.useState(i||""),[$,S]=a.useState(""),[b,z]=a.useState(!1),j=async()=>{if(!(!m||b)){z(!0);try{await r(m),x("otp")}catch(_){const v=_.message||"Failed to add email address. Please try again.";u(v,"error")}finally{z(!1)}}},k=async()=>{z(!0);try{await o($),t()}catch(_){const v=_.message||"Failed to verify email. Please check the code and try again.";u(v,"error")}finally{z(!1)}};return f?e.jsx(D0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),children:g==="email"?e.jsxs(e.Fragment,{children:[e.jsx(pa,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(F0,{children:[e.jsx(N0,{children:e.jsx(Hr,{size:16})}),e.jsx(le,{id:"email-input",type:"email",placeholder:"Email address",value:m,onChange:_=>y(_.target.value),style:{flex:1}})]})}),e.jsxs(ua,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Y,{onClick:j,disabled:!m||b,style:{width:"auto",padding:"0 var(--space-md)"},children:b?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(pa,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",m]}),e.jsx(Tt,{onComplete:async _=>S(_),onResend:n,isSubmitting:b}),e.jsxs(ua,{children:[e.jsx(Y,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(Y,{onClick:k,disabled:$.length<6||b,style:{width:"auto",padding:"0 var(--space-md)"},children:b?"Verifying...":"Verify"})]})]})}):null},B0=d.div`
|
|
3768
3768
|
position: fixed;
|
|
3769
3769
|
background: var(--color-background);
|
|
3770
3770
|
border-radius: var(--radius-md);
|
|
@@ -3788,7 +3788,7 @@ cursor: pointer;
|
|
|
3788
3788
|
font-weight: 400;
|
|
3789
3789
|
color: var(--color-foreground);
|
|
3790
3790
|
margin-bottom: 12px;
|
|
3791
|
-
`,ma=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:i,triggerRef:s})=>{var P;const
|
|
3791
|
+
`,ma=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:i,triggerRef:s})=>{var P;const p=a.useRef(null),[f,c]=a.useState(!1),[h,l]=a.useState({top:0,left:0}),{toast:u}=Mt();a.useEffect(()=>{c(!0);const C=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const R=s.current;if(R){const w=R.getBoundingClientRect(),I=380,M=300,O=8;let U=0,F=0;const L=window.innerHeight-w.bottom,A=w.top;L>=M+O?(U=w.bottom+O,F=w.right-I,F<O&&(F=w.left,F+I>window.innerWidth-O&&(F=(window.innerWidth-I)/2))):A>=M+O?(U=w.top-M-O,F=w.right-I,F<O&&(F=w.left,F+I>window.innerWidth-O&&(F=(window.innerWidth-I)/2))):(U=w.bottom+O,F=w.right-I,F<O&&(F=w.left)),l({top:U,left:F})}},10),E=R=>{p.current&&!p.current.contains(R.target)&&t()},T=R=>{R.key==="Escape"&&t()};return document.addEventListener("mousedown",E),document.addEventListener("keydown",T),()=>{clearTimeout(C),document.removeEventListener("mousedown",E),document.removeEventListener("keydown",T)}},[t,s]);const[g,x]=a.useState(n?"otp":"phone"),[m,y]=a.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[$,S]=a.useState((P=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:P.pop()),[b,z]=a.useState(""),[j,k]=a.useState(!1),_=async()=>{if(!(!m||j)){k(!0);try{await r(m,$||""),x("otp")}catch(C){const E=C.message||"Failed to add phone number. Please try again.";u(E,"error")}finally{k(!1)}}},v=async()=>{k(!0);try{await o(b),t()}catch(C){const E=C.message||"Failed to verify phone. Please check the code and try again.";u(E,"error")}finally{k(!1)}};return f?e.jsx(B0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:C=>C.stopPropagation(),children:g==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(ga,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(Yr,{value:m,onChange:C=>y(C.target.value),error:"",countryCode:$,setCountryCode:S})}),e.jsxs(fa,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Y,{onClick:_,disabled:!m||j,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ga,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(Tt,{onComplete:C=>z(C),onResend:async()=>i()})}),e.jsxs(fa,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Y,{onClick:v,disabled:b.length!==6||j,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},U0=d.div`
|
|
3792
3792
|
position: fixed;
|
|
3793
3793
|
background: var(--color-background);
|
|
3794
3794
|
border-radius: var(--radius-md);
|
|
@@ -3831,7 +3831,7 @@ cursor: pointer;
|
|
|
3831
3831
|
font-weight: 400;
|
|
3832
3832
|
color: var(--color-foreground);
|
|
3833
3833
|
margin-bottom: 8px;
|
|
3834
|
-
`,W0=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const i=a.useRef(null),[s,
|
|
3834
|
+
`,W0=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const i=a.useRef(null),[s,p]=a.useState("qr"),[f,c]=a.useState(""),[h,l]=a.useState(""),[u,g]=a.useState(["",""]),[x,m]=a.useState(!1),[y,$]=a.useState(!1),[S,b]=a.useState({top:0,left:0}),{toast:z}=Mt();a.useEffect(()=>{$(!0);const k=setTimeout(()=>{if(!i.current||!(n!=null&&n.current))return;const P=n.current;if(P){const C=P.getBoundingClientRect(),E=380,T=400,R=8;let w=0,I=0;const M=window.innerHeight-C.bottom,O=C.top;M>=T+R?(w=C.bottom+R,I=C.right-E,I<R&&(I=C.left,I+E>window.innerWidth-R&&(I=(window.innerWidth-E)/2))):O>=T+R?(w=C.top-T-R,I=C.right-E,I<R&&(I=C.left,I+E>window.innerWidth-R&&(I=(window.innerWidth-E)/2))):(w=C.bottom+R,I=C.right-E,I<R&&(I=C.left)),b({top:w,left:I})}},10),_=P=>{i.current&&!i.current.contains(P.target)&&t()},v=P=>{P.key==="Escape"&&t()};return document.addEventListener("mousedown",_),document.addEventListener("keydown",v),()=>{clearTimeout(k),document.removeEventListener("mousedown",_),document.removeEventListener("keydown",v)}},[t,n]),a.useEffect(()=>{(async()=>{m(!0);try{const _=await r();c(_.otp_url||""),l(_.totp_secret||"")}catch(_){const v=_.message||"Failed to setup two-factor authentication. Please try again.";z(v,"error")}finally{m(!1)}})()},[]);const j=async()=>{if(!u.some(k=>k.length!==6)){m(!0);try{await o(u),t()}catch(k){const _=k.message||"Failed to verify codes. Please check your authenticator app and try again.";z(_,"error")}finally{m(!1)}}};return y?e.jsx(U0,{ref:i,style:{top:`${S.top}px`,left:`${S.left}px`,visibility:S.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),children:s==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(va,{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..."}):f?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Rs,{value:f,size:150,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)",color:"var(--color-error)"},children:"QR Code Not Available"})}),h&&e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",marginBottom:"16px",fontSize:"12px"},children:[e.jsx("div",{style:{color:"var(--color-secondary-text)",marginBottom:"4px"},children:"Or enter manually:"}),e.jsx("code",{style:{fontFamily:"monospace",wordBreak:"break-all",color:"var(--color-secondary-text)"},children:h})]}),e.jsx(xa,{children:e.jsx(Gn,{$primary:!0,onClick:()=>p("verify"),disabled:x||!f,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(va,{children:"Verify Your Authenticator"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Enter two consecutive codes from your authenticator app"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:[e.jsx(le,{id:"totp-code-1",type:"text",placeholder:"000000",value:u[0],onChange:k=>{const _=k.target.value.replace(/[^0-9]/g,"").substring(0,6);g([_,u[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(le,{id:"totp-code-2",type:"text",placeholder:"000000",value:u[1],onChange:k=>{const _=k.target.value.replace(/[^0-9]/g,"").substring(0,6);g([u[0],_])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(xa,{children:[e.jsx(Gn,{onClick:()=>p("qr"),children:"Back"}),e.jsx(Gn,{$primary:!0,onClick:j,disabled:x||u.some(k=>k.length!==6),children:x?"Verifying...":"Verify"})]})]})}):null},V0=d.div`
|
|
3835
3835
|
position: fixed;
|
|
3836
3836
|
background: var(--color-background);
|
|
3837
3837
|
border-radius: var(--radius-md);
|
|
@@ -3901,7 +3901,7 @@ cursor: pointer;
|
|
|
3901
3901
|
color: var(--color-error);
|
|
3902
3902
|
font-size: 12px;
|
|
3903
3903
|
margin-top: 4px;
|
|
3904
|
-
`,ya=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const i=a.useRef(null),[s,
|
|
3904
|
+
`,ya=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const i=a.useRef(null),[s,p]=a.useState(!1),[f,c]=a.useState({top:0,left:0}),[h,l]=a.useState(""),[u,g]=a.useState(""),[x,m]=a.useState(""),[y,$]=a.useState(!1),[S,b]=a.useState(!1),[z,j]=a.useState(!1),[k,_]=a.useState(!1),[v,P]=a.useState({});a.useEffect(()=>{p(!0);const E=setTimeout(()=>{if(!i.current||!(o!=null&&o.current))return;const w=o.current;if(w){const I=w.getBoundingClientRect(),M=380,O=350,U=8;let F=0,L=0;const A=window.innerHeight-I.bottom,Q=I.top;A>=O+U?(F=I.bottom+U,L=I.right-M,L<U&&(L=I.left,L+M>window.innerWidth-U&&(L=(window.innerWidth-M)/2))):Q>=O+U?(F=I.top-O-U,L=I.right-M,L<U&&(L=I.left,L+M>window.innerWidth-U&&(L=(window.innerWidth-M)/2))):(F=I.bottom+U,L=I.right-M,L<U&&(L=I.left)),c({top:F,left:L})}},10),T=w=>{i.current&&!i.current.contains(w.target)&&t()},R=w=>{w.key==="Escape"&&t()};return document.addEventListener("mousedown",T),document.addEventListener("keydown",R),()=>{clearTimeout(E),document.removeEventListener("mousedown",T),document.removeEventListener("keydown",R)}},[t,o]);const C=async()=>{if(k)return;const E={};if(!n&&!h&&(E.currentPassword="Current password is required"),u?u.length<8&&(E.newPassword="Password must be at least 8 characters"):E.newPassword="New password is required",u!==x&&(E.confirmPassword="Passwords do not match"),Object.keys(E).length>0){P(E);return}_(!0);try{await r(n?"":h,u),t()}catch(T){P({form:T.message||"Failed to update password"})}finally{_(!1)}};return s?e.jsxs(V0,{ref:i,style:{top:`${f.top}px`,left:`${f.left}px`,visibility:f.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:[e.jsx(H0,{children:n?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&e.jsxs(Hn,{children:[e.jsx(ce,{children:"Current Password"}),e.jsxs(qn,{children:[e.jsx(le,{type:y?"text":"password",placeholder:"Enter your current password",value:h,onChange:E=>l(E.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>$(!y),"aria-label":y?"Hide current password":"Show current password",children:y?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),v.currentPassword&&e.jsx($o,{children:v.currentPassword})]}),e.jsxs(Hn,{children:[e.jsx(ce,{children:n?"Password":"New Password"}),e.jsxs(qn,{children:[e.jsx(le,{type:S?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:u,onChange:E=>g(E.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>b(!S),"aria-label":S?"Hide new password":"Show new password",children:S?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),v.newPassword&&e.jsx($o,{children:v.newPassword})]}),e.jsxs(Hn,{children:[e.jsx(ce,{children:"Confirm New Password"}),e.jsxs(qn,{children:[e.jsx(le,{type:z?"text":"password",placeholder:"Confirm your new password",value:x,onChange:E=>m(E.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>j(!z),"aria-label":z?"Hide confirm password":"Show confirm password",children:z?e.jsx(jn,{size:16}):e.jsx(_n,{size:16})})]}),v.confirmPassword&&e.jsx($o,{children:v.confirmPassword})]}),v.form&&e.jsx($o,{children:v.form}),e.jsxs(G0,{children:[e.jsx(ba,{onClick:t,children:"Cancel"}),e.jsx(ba,{$primary:!0,onClick:C,disabled:k,children:k?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},q0=d.div`
|
|
3905
3905
|
position: fixed;
|
|
3906
3906
|
background: var(--color-background);
|
|
3907
3907
|
border-radius: var(--radius-md);
|
|
@@ -3939,7 +3939,7 @@ cursor: pointer;
|
|
|
3939
3939
|
color: var(--color-warning-text, var(--color-foreground));
|
|
3940
3940
|
margin: 0;
|
|
3941
3941
|
line-height: 1.5;
|
|
3942
|
-
`,X0=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(!1),[
|
|
3942
|
+
`,X0=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=a.useRef(null),[i,s]=a.useState(!1),[p,f]=a.useState({top:0,left:0}),[c,h]=a.useState(""),[l,u]=a.useState(!1),{toast:g}=Mt();a.useEffect(()=>{s(!0);const m=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const S=o.current;if(S){const b=S.getBoundingClientRect(),z=400,j=300,k=8;let _=0,v=0;const P=window.innerHeight-b.bottom,C=b.top;P>=j+k?(_=b.bottom+k,v=b.right-z,v<k&&(v=b.left,v+z>window.innerWidth-k&&(v=(window.innerWidth-z)/2))):C>=j+k?(_=b.top-j-k,v=b.right-z,v<k&&(v=b.left,v+z>window.innerWidth-k&&(v=(window.innerWidth-z)/2))):(_=b.bottom+k,v=b.right-z,v<k&&(v=b.left)),f({top:_,left:v})}},10),y=S=>{n.current&&!n.current.contains(S.target)&&t()},$=S=>{S.key==="Escape"&&t()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",$),()=>{clearTimeout(m),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",$)}},[t,o]);const x=async()=>{if(!(!c||l)){u(!0);try{await r(c),t()}catch(m){const y=m.message||"Failed to remove password. Please try again.";g(y,"error")}finally{u(!1)}}};return i?e.jsxs(q0,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:m=>m.stopPropagation(),children:[e.jsxs(Z0,{children:[e.jsx(ut,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(Q0,{children:e.jsx(K0,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(le,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:m=>h(m.target.value),autoFocus:!0})]}),e.jsxs(Y0,{children:[e.jsx(Y,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(Y,{onClick:x,disabled:!c||l,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:l?"Removing...":"Remove Password"})]})]}):null},J0=d.div`
|
|
3943
3943
|
position: fixed;
|
|
3944
3944
|
background: var(--color-background);
|
|
3945
3945
|
border-radius: var(--radius-md);
|
|
@@ -4005,7 +4005,7 @@ cursor: pointer;
|
|
|
4005
4005
|
background: var(--color-input-background-hover);
|
|
4006
4006
|
border-color: var(--color-primary);
|
|
4007
4007
|
}
|
|
4008
|
-
`,sv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:i})=>{const s=a.useRef(null),[u,f]=a.useState(!1),[c,h]=a.useState({top:0,left:0});return a.useEffect(()=>{f(!0);const l=setTimeout(()=>{if(!s.current||!(i!=null&&i.current))return;const x=i.current;if(x){const m=x.getBoundingClientRect(),y=380,$=300,S=8;let b=0,z=0;const j=window.innerHeight-m.bottom,k=m.top;j>=$+S?(b=m.bottom+S,z=m.right-y,z<S&&(z=m.left,z+y>window.innerWidth-S&&(z=(window.innerWidth-y)/2))):k>=$+S?(b=m.top-$-S,z=m.right-y,z<S&&(z=m.left,z+y>window.innerWidth-S&&(z=(window.innerWidth-y)/2))):(b=m.bottom+S,z=m.right-y,z<S&&(z=m.left)),h({top:b,left:z})}},10),p=x=>{s.current&&!s.current.contains(x.target)&&r()},g=x=>{x.key==="Escape"&&r()};return document.addEventListener("mousedown",p),document.addEventListener("keydown",g),()=>{clearTimeout(l),document.removeEventListener("mousedown",p),document.removeEventListener("keydown",g)}},[r,i]),u?e.jsxs(J0,{ref:s,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:l=>l.stopPropagation(),children:[e.jsxs(ev,{children:[e.jsx(tv,{children:"Backup Codes"}),e.jsxs(rv,{children:[e.jsxs(wa,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Jt,{size:14}),"Copy"]}),e.jsxs(wa,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(on,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(ov,{children:t.map((l,p)=>e.jsx(nv,{onClick:()=>{navigator.clipboard.writeText(l)},title:"Click to copy",children:l},p))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},iv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:48,height:48,...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),av=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"})]}),cv=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})]}),lv=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)"})]}),dv=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)"})]}),uv=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)"})]}),pv=ir`
|
|
4008
|
+
`,sv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:i})=>{const s=a.useRef(null),[p,f]=a.useState(!1),[c,h]=a.useState({top:0,left:0});return a.useEffect(()=>{f(!0);const l=setTimeout(()=>{if(!s.current||!(i!=null&&i.current))return;const x=i.current;if(x){const m=x.getBoundingClientRect(),y=380,$=300,S=8;let b=0,z=0;const j=window.innerHeight-m.bottom,k=m.top;j>=$+S?(b=m.bottom+S,z=m.right-y,z<S&&(z=m.left,z+y>window.innerWidth-S&&(z=(window.innerWidth-y)/2))):k>=$+S?(b=m.top-$-S,z=m.right-y,z<S&&(z=m.left,z+y>window.innerWidth-S&&(z=(window.innerWidth-y)/2))):(b=m.bottom+S,z=m.right-y,z<S&&(z=m.left)),h({top:b,left:z})}},10),u=x=>{s.current&&!s.current.contains(x.target)&&r()},g=x=>{x.key==="Escape"&&r()};return document.addEventListener("mousedown",u),document.addEventListener("keydown",g),()=>{clearTimeout(l),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",g)}},[r,i]),p?e.jsxs(J0,{ref:s,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:l=>l.stopPropagation(),children:[e.jsxs(ev,{children:[e.jsx(tv,{children:"Backup Codes"}),e.jsxs(rv,{children:[e.jsxs(wa,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(Jt,{size:14}),"Copy"]}),e.jsxs(wa,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(on,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(ov,{children:t.map((l,u)=>e.jsx(nv,{onClick:()=>{navigator.clipboard.writeText(l)},title:"Click to copy",children:l},u))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},iv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:48,height:48,...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),av=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"})]}),cv=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})]}),lv=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)"})]}),dv=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)"})]}),uv=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)"})]}),pv=ir`
|
|
4009
4009
|
0% { transform: rotate(0deg); }
|
|
4010
4010
|
100% { transform: rotate(360deg); }
|
|
4011
4011
|
`,hv=d.div`
|
|
@@ -4140,7 +4140,7 @@ cursor: pointer;
|
|
|
4140
4140
|
flex-wrap: wrap;
|
|
4141
4141
|
gap: 12px;
|
|
4142
4142
|
margin-bottom: 0;
|
|
4143
|
-
`,xv=()=>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:"?"})]}),vv=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(iv,{...o}):r.includes("firefox")?e.jsx(av,{...o}):r.includes("safari")?e.jsx(cv,{...o}):r.includes("edge")?e.jsx(lv,{...o}):r.includes("opera")?e.jsx(dv,{...o}):r.includes("brave")?e.jsx(uv,{...o}):e.jsx(xv,{})},bv=()=>{const[t,r]=a.useState(null),{signins:o,removeSignin:n,refetch:i,loading:s}=fc(),{refetch:
|
|
4143
|
+
`,xv=()=>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:"?"})]}),vv=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx(iv,{...o}):r.includes("firefox")?e.jsx(av,{...o}):r.includes("safari")?e.jsx(cv,{...o}):r.includes("edge")?e.jsx(lv,{...o}):r.includes("opera")?e.jsx(dv,{...o}):r.includes("brave")?e.jsx(uv,{...o}):e.jsx(xv,{})},bv=()=>{const[t,r]=a.useState(null),{signins:o,removeSignin:n,refetch:i,loading:s}=fc(),{refetch:p}=Be(),{toast:f}=Mt(),c=o,h=async u=>{try{await n(u),await Promise.all([i(),p()]),r(null),f("Session ended successfully","info")}catch(g){f(g.message||"Failed to end session. Please try again.","error")}},l=u=>{if(!u||u.trim()==="")return"Unknown";const g=new Date(u);if(isNaN(g.getTime()))return"Unknown";const m=Math.floor((new Date().getTime()-g.getTime())/(1e3*60));return m<1?"Just now":m<60?`${m}m ago`:m<1440?`${Math.floor(m/60)}h ago`:g.toLocaleDateString()};return s?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx(Ee,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:c&&c.length>0?e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Browser & Device"}),e.jsx($e,{children:"Location"}),e.jsx($e,{children:"Last Active"}),e.jsx($e,{})]})}),e.jsx(Ct,{children:c.map(u=>e.jsxs(We,{children:[e.jsx(Le,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ql,{children:e.jsx(vv,{browser:u.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:u.browser||"Unknown Browser"}),u.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.device})]})]})}),e.jsx(Le,{children:e.jsxs("div",{children:[e.jsx("div",{children:u.city&&u.country?`${u.city}, ${u.country}`:"Unknown location"}),u.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.ip_address})]})}),e.jsx(Le,{children:l(u.last_active_at)}),e.jsx(St,{children:e.jsxs(nt,{open:t===u.id,openChange:g=>r(g?u.id:null),children:[e.jsx(it,{children:e.jsx(cn,{children:"•••"})}),e.jsx(st,{children:e.jsx(Te,{onClick:()=>h(u.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(It,{size:14}),"End Session"]})})})]})})]},u.id))})]}):e.jsx(at,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},yv=()=>{var _,v,P,C;const{deployment:t}=me(),{toast:r}=Mt(),[o,n]=a.useState(null),[i,s]=a.useState(""),[p,f]=a.useState(!1),[c,h]=a.useState(null),[l,u]=a.useState(""),g=a.useRef(null),x=a.useRef({}),{user:m,createEmailAddress:y,deleteEmailAddress:$,prepareEmailVerification:S,attemptEmailVerification:b,makeEmailPrimary:z}=sr();if(!((v=(_=t==null?void 0:t.auth_settings)==null?void 0:_.email_address)!=null&&v.enabled))return null;const j=async E=>{try{if(E===(m==null?void 0:m.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await $(E),m.refetch(),r("Email address deleted successfully","info")}catch(T){r(T.message||"Failed to delete email address. Please try again.","error")}},k=a.useMemo(()=>m!=null&&m.user_email_addresses?l.trim()?m.user_email_addresses.filter(E=>E.email.toLowerCase().includes(l.toLowerCase())):m.user_email_addresses:[],[m==null?void 0:m.user_email_addresses,l]);return e.jsxs(e.Fragment,{children:[e.jsxs(qo,{style:{marginBottom:"20px"},children:[e.jsx(jt,{value:l,onChange:u,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:g,onClick:()=>f(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),p&&e.jsx(ha,{triggerRef:g,onClose:()=>f(!1),onAddEmail:async E=>{const T=await y(E);s(T.data.id),await S(T.data.id),m.refetch()},onPrepareVerification:async()=>{await S(i),m.refetch()},onAttemptVerification:async E=>{await b(i,E),m.refetch(),f(!1),s(""),r("Email added and verified successfully!","info")}})]})]}),k!=null&&k.length?e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Email Address"}),e.jsx($e,{children:"Status"}),e.jsx($e,{})]})}),e.jsx(Ct,{children:k.map(E=>e.jsxs(We,{children:[e.jsx(Le,{children:E.email}),e.jsx(Le,{children:E.id===(m==null?void 0:m.primary_email_address_id)?"Primary":E.verified?"Verified":"Not Verified"}),e.jsx(St,{children:E.id!==(m==null?void 0:m.primary_email_address_id)||!E.verified?e.jsxs(nt,{open:o===E.id,openChange:T=>n(T?E.id:null),children:[e.jsx(it,{children:e.jsx(cn,{ref:T=>{T&&(x.current[E.id]=T)},children:"•••"})}),e.jsxs(st,{children:[E.id!==(m==null?void 0:m.primary_email_address_id)&&E.verified&&e.jsx(Te,{onClick:async()=>{try{await z(E.id),m.refetch(),n(null),r("Primary email updated successfully","info")}catch(T){r(T.message||"Failed to update primary email","error")}},children:"Make primary"}),!E.verified&&e.jsx(Te,{onClick:async()=>{n(null),await S(E.id),h(E.id)},children:"Verify email"}),E.id!==(m==null?void 0:m.primary_email_address_id)&&e.jsx(Te,{$destructive:!0,onClick:()=>{j(E.id),n(null)},children:"Remove"})]})]}):null})]},E.id))})]}):e.jsx(at,{title:l?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(ha,{existingEmail:(C=(P=m==null?void 0:m.user_email_addresses)==null?void 0:P.find(E=>E.id===c))==null?void 0:C.email,triggerRef:{current:x.current[c]},onClose:()=>h(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await S(c),m.refetch()},onAttemptVerification:async E=>{await b(c,E),m.refetch(),h(null),r("Email verified successfully!","info")}})]})},wv=()=>{var k,_,v,P;const{deployment:t}=me(),[r,o]=a.useState(null),[n,i]=a.useState(""),[s,p]=a.useState(!1),[f,c]=a.useState(null),[h,l]=a.useState(""),u=a.useRef(null),g=a.useRef({}),{user:x,createPhoneNumber:m,deletePhoneNumber:y,preparePhoneVerification:$,attemptPhoneVerification:S,makePhonePrimary:b}=sr();if(!((_=(k=t==null?void 0:t.auth_settings)==null?void 0:k.phone_number)!=null&&_.enabled))return null;const z=C=>{const E=Lo.find(T=>T.dialCode===C);return(E==null?void 0:E.flag)||"🌍"},j=a.useMemo(()=>x!=null&&x.user_phone_numbers?h.trim()?x.user_phone_numbers.filter(C=>C.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(qo,{style:{marginBottom:"20px"},children:[e.jsx(jt,{value:h,onChange:l,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:u,onClick:()=>p(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),s&&e.jsx(ma,{triggerRef:u,onClose:()=>p(!1),onAddPhone:async(C,E)=>{const T=await m(C,E);i(T.data.id),await $(T.data.id)},onPrepareVerification:async()=>{await $(n),x.refetch()},onAttemptVerification:async C=>{await S(n,C),x.refetch(),p(!1)}}),f&&e.jsx(ma,{existingPhone:(P=(v=x==null?void 0:x.user_phone_numbers)==null?void 0:v.find(C=>C.id===f))==null?void 0:P.phone_number,triggerRef:{current:g.current[f]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await $(f),x.refetch()},onAttemptVerification:async C=>{await S(f,C),x.refetch(),c(null)}})]})]}),j!=null&&j.length?e.jsxs(_t,{children:[e.jsx(kt,{children:e.jsxs(We,{children:[e.jsx($e,{children:"Phone Number"}),e.jsx($e,{children:"Status"}),e.jsx($e,{})]})}),e.jsx(Ct,{children:j.map(C=>e.jsxs(We,{children:[e.jsx(Le,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:z(C.country_code)}),e.jsx("span",{children:C.country_code}),e.jsx("span",{children:C.phone_number})]})}),e.jsx(Le,{children:C.id===(x==null?void 0:x.primary_phone_number_id)?"Primary":C.verified?"Verified":"Not Verified"}),e.jsx(St,{children:e.jsxs(nt,{open:r===C.id,openChange:E=>o(E?C.id:null),children:[e.jsx(it,{children:e.jsx(cn,{ref:E=>{E&&(g.current[C.id]=E)},children:"•••"})}),e.jsxs(st,{children:[C.id!==(x==null?void 0:x.primary_phone_number_id)&&C.verified&&e.jsx(Te,{onClick:async()=>{await b(C.id),o(null),x.refetch()},children:"Make primary"}),!C.verified&&e.jsx(Te,{onClick:async()=>{await $(C.id),c(C.id),o(null)},children:"Verify phone"}),e.jsx(Te,{$destructive:!0,onClick:async()=>{await y(C.id),o(null),x.refetch()},children:"Remove"})]})]})})]},C.id))})]}):e.jsx(at,{title:h?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},Ql=d.div`
|
|
4144
4144
|
width: 20px;
|
|
4145
4145
|
height: 20px;
|
|
4146
4146
|
flex-shrink: 0;
|
|
@@ -4155,9 +4155,9 @@ cursor: pointer;
|
|
|
4155
4155
|
flex-shrink: 0;
|
|
4156
4156
|
display: block;
|
|
4157
4157
|
}
|
|
4158
|
-
`,jv=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=sr(),{deployment:n}=me(),i={google_oauth:{icon:e.jsx(el,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Jc,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(Xc,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(ol,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(rl,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(nl,{}),label:"Discord"},x_oauth:{icon:e.jsx(tl,{}),label:"X"}},s=(n==null?void 0:n.social_connections.filter(
|
|
4158
|
+
`,jv=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=sr(),{deployment:n}=me(),i={google_oauth:{icon:e.jsx(el,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Jc,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(Xc,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(ol,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(rl,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(nl,{}),label:"Discord"},x_oauth:{icon:e.jsx(tl,{}),label:"X"}},s=(n==null?void 0:n.social_connections.filter(p=>p.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((p,f)=>{var l;const c=((l=t==null?void 0:t.social_connections)==null?void 0:l.filter(u=>u.provider===p.provider))||[],h=i[p.provider];return h?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(Ql,{children:h.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:h.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(u=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:u.email_address}),e.jsx(cn,{onClick:async()=>{await r(u.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(Je,{size:14})})]},u.id)),c.length>0?e.jsx(Y,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(Y,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<s.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},Kl=()=>{var m,y,$,S,b,z,j;const{loading:t}=sr(),{deployment:r}=me(),[o,n]=a.useState("profile"),[i,s]=a.useState(null),[p,f]=a.useState("info"),c=a.useCallback((k,_="info")=>{s(k),f(_),setTimeout(()=>s(null),3e3)},[s]);if(t)return e.jsx(fe,{children:e.jsx(ja,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Ee,{})})});const h=r==null?void 0:r.auth_settings,l=(m=h==null?void 0:h.email_address)==null?void 0:m.enabled,u=(y=h==null?void 0:h.phone_number)==null?void 0:y.enabled,g=(($=r==null?void 0:r.social_connections)==null?void 0:$.some(k=>k.enabled))||!1,x=((S=h==null?void 0:h.password)==null?void 0:S.enabled)||((b=h==null?void 0:h.auth_factors_enabled)==null?void 0:b.authenticator)||((z=h==null?void 0:h.auth_factors_enabled)==null?void 0:z.phone_otp)||((j=h==null?void 0:h.auth_factors_enabled)==null?void 0:j.backup_code);return e.jsx(fe,{children:e.jsx(hv,{children:e.jsx(Er.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(ja,{children:[e.jsx(fv,{children:e.jsxs(gv,{children:[e.jsx(mr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(xr,{children:[e.jsx(Uo,{size:16}),"Profile"]})}),l&&e.jsx(mr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(xr,{children:[e.jsx(Hr,{size:16}),"Email"]})}),u&&e.jsx(mr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(xr,{children:[e.jsx(ph,{size:16}),"Phone"]})}),g&&e.jsx(mr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(xr,{children:[e.jsx(rh,{size:16}),"Connections"]})}),x&&e.jsx(mr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(xr,{children:[e.jsx(Qe,{size:16}),"Security"]})}),e.jsx(mr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(xr,{children:[e.jsx(Ip,{size:16}),"Sessions"]})})]})}),e.jsxs(mv,{children:[o==="profile"&&e.jsx(kv,{}),o==="email"&&l&&e.jsx(yv,{}),o==="phone"&&u&&e.jsx(wv,{}),o==="social"&&g&&e.jsx(jv,{}),o==="security"&&x&&e.jsx(_v,{}),o==="sessions"&&e.jsx(bv,{})]}),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:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(Ve,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:i})]})})]})})})})},_v=()=>{var N,re,pe;const{deployment:t}=me(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:i,verifyAuthenticator:s,deleteAuthenticator:p,generateBackupCodes:f,regenerateBackupCodes:c,updateProfile:h}=sr(),{toast:l}=Mt(),[u,g]=a.useState((r==null?void 0:r.second_factor_policy)||"none"),[x,m]=a.useState(!1),y=async J=>{try{await h({second_factor_policy:J}),g(J),l("2FA requirement updated successfully","info")}catch(_e){l(_e.message||"Failed to update 2FA requirement","error")}},[$,S]=a.useState(!1),[b,z]=a.useState(!1),[j,k]=a.useState(!1),[_,v]=a.useState(!1),P=a.useRef(null),C=a.useRef(null),E=a.useRef(null),T=a.useRef(null),[R,w]=a.useState("table"),[I,M]=a.useState(""),[O,U]=a.useState(""),[F,L]=a.useState(""),[A,Q]=a.useState(["",""]),[ee,W]=a.useState([]),[K,oe]=a.useState(!1),[te,de]=a.useState(!1),[ne]=a.useState(!1),[ue,X]=a.useState(!1),ae=(N=t==null?void 0:t.auth_settings)==null?void 0:N.auth_factors_enabled,Z=(pe=(re=t==null?void 0:t.auth_settings)==null?void 0:re.password)==null?void 0:pe.enabled;if(!(ae!=null&&ae.authenticator)&&!(ae!=null&&ae.backup_code)&&!Z)return null;const q=async(J,_e)=>{await o(J,_e),await r.refetch(),l("Password updated successfully","info")},B=async J=>{await n(J),await r.refetch(),l("Password removed successfully","info")},ie=()=>{var Re,ar,cr,Qr,Ms,Os;if(!r)return!1;const J=(Re=r.user_email_addresses)==null?void 0:Re.some(Ir=>Ir.verified),_e=(ar=r.user_phone_numbers)==null?void 0:ar.some(Ir=>Ir.verified),ve=r.social_connections&&r.social_connections.length>0,Se=t==null?void 0:t.auth_settings;return(Se==null?void 0:Se.first_factor)==="email_otp"&&J||((cr=Se==null?void 0:Se.magic_link)==null?void 0:cr.enabled)&&J||((Qr=Se==null?void 0:Se.passkey)==null?void 0:Qr.enabled)||((Ms=Se==null?void 0:Se.auth_factors_enabled)==null?void 0:Ms.phone_otp)&&_e||ve&&((Os=t==null?void 0:t.social_connections)==null?void 0:Os.some(Ir=>Ir.enabled))},H=async()=>{if(A.some(J=>J.length!==6)){l("Please enter both 6-digit verification codes","error");return}try{if(de(!0),await s(F,A),await r.refetch(),ae!=null&&ae.backup_code){const J=await f();W(J),await r.refetch(),w("backup")}else w("success")}catch(J){l(J.message||"Invalid verification codes","error")}finally{de(!1)}},se=()=>{w("table"),M(""),U(""),L(""),Q(["",""]),W([]),l("Two-factor authentication setup completed successfully!","info")},we=async()=>{var J;if((J=r==null?void 0:r.user_authenticator)!=null&&J.id)try{X(!0),await p(r.user_authenticator.id),await r.refetch(),m(!1),l("Two-factor authentication removed successfully","info")}catch(_e){l(_e.message||"Failed to remove authenticator","error")}finally{X(!1)}},xe=async()=>{if(!K)try{oe(!0);const J=await c();W(J),await r.refetch(),v(!0),l("New backup codes generated","info")}catch(J){l(J.message||"Failed to generate backup codes","error")}finally{oe(!1)}},ge=()=>{const J=ee.join(`
|
|
4159
4159
|
`);navigator.clipboard.writeText(J).then(()=>{l("Backup codes copied to clipboard","info")}).catch(()=>{l("Failed to copy backup codes","error")})},V=()=>{const J=ee.join(`
|
|
4160
|
-
`),_e=new Blob([J],{type:"text/plain"}),ve=URL.createObjectURL(_e),Se=document.createElement("a");Se.href=ve,Se.download="wacht-backup-codes.txt",Se.click(),URL.revokeObjectURL(ve),l("Backup codes downloaded","info")},D=[];return Z&&D.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),ae!=null&&ae.authenticator&&D.push({id:"authenticator",name:"Two-Factor Authentication",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&D.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),(r!=null&&r.user_authenticator||r!=null&&r.backup_codes_generated||r.second_factor_policy==="enforced"||r.primary_phone_number_id)&&D.push({id:"second_factor_policy",name:"Second Factor Policy",description:"Require a second factor for all sign-ins",status:p==="enforced"?"Enforced":"Optional",actions:["toggle"]}),R!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(qo,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Qe,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[R==="qr"&&"Setup Two-Factor Authentication",R==="verify"&&"Verify Your Authenticator",R==="backup"&&"Save Your Backup Codes",R==="success"&&"Setup Complete!"]})]}),e.jsx(Y,{onClick:()=>w("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[R==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:ne?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:`${pv} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):I?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Rs,{value:I,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:L||"Loading..."})]}),e.jsx(Y,{onClick:()=>w("verify"),disabled:!I||!L,style:{padding:"10px 20px",background:!I||!L?"var(--color-border)":"var(--color-primary)",color:!I||!L?"var(--color-secondary-text)":"white",border:`1px solid ${!I||!L?"var(--color-border)":"var(--color-primary)"}`,cursor:!I||!L?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),R==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(le,{type:"text",placeholder:"000000",value:A[0],onChange:J=>{const _e=J.target.value.replace(/[^0-9]/g,"").substring(0,6);Q([_e,A[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(le,{type:"text",placeholder:"000000",value:A[1],onChange:J=>{const _e=J.target.value.replace(/[^0-9]/g,"").substring(0,6);Q([A[0],_e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(Y,{onClick:()=>w("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(Y,{onClick:H,disabled:te||A.some(J=>J.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:te?"Verifying...":"Verify & Continue"})]})]}),R==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ut,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:ee.map((J,_e)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(J),children:J},_e))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(Y,{onClick:ge,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(Y,{onClick:V,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(on,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(Y,{onClick:se,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),R==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(Ve,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(Y,{onClick:se,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(qo,{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"})})}),D.length?e.jsx("div",{children:D.map((J,_e)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:J.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:J.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:J.status==="Enabled"||J.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:J.status==="Enabled"||J.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:J.status}),e.jsxs("div",{style:{position:"relative"},children:[J.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(Y,{ref:C,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),b&&e.jsx(ya,{triggerRef:C,onClose:()=>z(!1),onChangePassword:q})]}),ie()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:E,onClick:()=>k(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),j&&e.jsx(X0,{triggerRef:E,onClose:()=>k(!1),onRemovePassword:B})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:C,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),b&&e.jsx(ya,{triggerRef:C,onClose:()=>z(!1),onChangePassword:q,isSetup:!0})]})}),J.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:P,onClick:()=>S(!0),disabled:ne,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:ne?"Setting up...":"Setup"}),$&&e.jsx(W0,{triggerRef:P,onClose:()=>S(!1),onSetupTOTP:async()=>{const ve=await i();return O(ve.id),ve},onVerifyTOTP:async ve=>{await s(F,ve),await r.refetch(),l("Two-factor authentication enabled successfully!","info")}})]})}),J.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{onClick:()=>m(!0),disabled:ue,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:ue?"not-allowed":"pointer",opacity:ue?.6:1},children:ue?"Removing...":"Remove"}),x&&e.jsx(Zr,{title:"Remove MFA and reset policy to default?",onConfirm:we,onCancel:()=>m(!1)})]}),J.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:T,onClick:xe,disabled:K,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:K?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),_&&e.jsx(sv,{triggerRef:T,codes:ee,onClose:()=>v(!1),onCopy:ge,onDownload:V})]})}),J.id==="second_factor_policy"&&e.jsx(Cr,{checked:p==="enforced",onChange:ve=>{y(ve?"enforced":"none")}})]})]})]}),_e<D.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},J.id))}):e.jsx(at,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},kv=()=>{var U,F;const{deployment:t}=me(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:i}=sr(),{toast:s}=Mt(),[u,f]=a.useState(""),[c,h]=a.useState(""),[l,p]=a.useState(""),[g,x]=a.useState(!1),[m,y]=a.useState(!1),[$,S]=a.useState(!1),[b,z]=a.useState(""),[j,k]=a.useState((r==null?void 0:r.profile_picture_url)||null),_=a.useRef(null);a.useEffect(()=>{r&&!g&&(f(r.first_name||""),h(r.last_name||""),p(r.username||""),k(r.profile_picture_url||null),x(!0))},[r,g]);const v=a.useCallback(async()=>{if(r)try{const O={};u!==r.first_name&&(O.first_name=u),c!==r.last_name&&(O.last_name=c),l!==r.username&&(O.username=l),Object.keys(O).length>0&&await o(O)}catch(O){s(O.message||"Failed to save profile changes","error")}},[r,o,u,c,l,s]),P=O=>{f(O.target.value)},C=O=>{h(O.target.value)},E=O=>{p(O.target.value)},T=()=>{v()},R=()=>{v()},w=()=>{v()},I=O=>{var A;if((A=O.target.files)!=null&&A[0]){const Q=O.target.files[0];k(URL.createObjectURL(Q)),setTimeout(async()=>{try{await n(Q),r.refetch(),s("Profile picture updated successfully","info")}catch(ee){s(ee.message||"Failed to update profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},100)}},M=()=>{_.current&&_.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const L=async()=>{if(!(!r||b!==r.username)){S(!0);try{await i(""),s("Account deleted successfully","info")}catch(O){s(O.message||"Failed to delete account","error")}finally{S(!1),z(""),y(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:j?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,onMouseEnter:O=>{O.currentTarget.style.borderColor="var(--color-primary)",O.currentTarget.style.transform="scale(1.02)"},onMouseLeave:O=>{O.currentTarget.style.borderColor="var(--color-border)",O.currentTarget.style.transform="scale(1)"},children:[j?e.jsx("img",{src:j,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Uo,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:_,style:{display:"none"},accept:"image/*",onChange:I})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Y,{onClick:()=>{var O;return(O=_.current)==null?void 0:O.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(on,{size:14}),j?"Change":"Upload"]}),e.jsxs(Y,{onClick:async()=>{k(null),_.current&&(_.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),s("Profile picture removed successfully","info")}catch(O){s(O.message||"Failed to remove profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ut,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ce,{htmlFor:"firstName",children:"First Name"}),e.jsx(le,{id:"firstName",type:"text",value:u,onChange:P,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ce,{htmlFor:"lastName",children:"Last Name"}),e.jsx(le,{id:"lastName",type:"text",value:c,onChange:C,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((F=(U=t==null?void 0:t.auth_settings)==null?void 0:U.username)==null?void 0:F.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"username",children:"Username"}),e.jsx(le,{id:"username",type:"text",value:l,onChange:E,onBlur:w,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:m?"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(Y,{onClick:()=>{m?(y(!1),z("")):y(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:m?"Cancel":"Delete"})]}),m&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(le,{id:"confirm_username",type:"text",value:b,onChange:O=>z(O.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(Y,{onClick:L,disabled:b!==(r==null?void 0:r.username)||$,style:{background:b===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:b===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:b===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:b===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:$?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})})},Xl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:i,footerContent:s,customContent:u,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:i||o}),u||f||e.jsx(Kl,{}),s&&e.jsx(ke.Footer,{children:s})]})})}),Cv=d.div`
|
|
4160
|
+
`),_e=new Blob([J],{type:"text/plain"}),ve=URL.createObjectURL(_e),Se=document.createElement("a");Se.href=ve,Se.download="wacht-backup-codes.txt",Se.click(),URL.revokeObjectURL(ve),l("Backup codes downloaded","info")},D=[];return Z&&D.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),ae!=null&&ae.authenticator&&D.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&&D.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&&D.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:u==="enforced"?"Enforced":"Optional",actions:["toggle"]}),R!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(qo,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Qe,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[R==="qr"&&"Setup Two-Factor Authentication",R==="verify"&&"Verify Your Authenticator",R==="backup"&&"Save Your Backup Codes",R==="success"&&"Setup Complete!"]})]}),e.jsx(Y,{onClick:()=>w("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[R==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:ne?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:`${pv} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):I?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Rs,{value:I,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:O||"Loading..."})]}),e.jsx(Y,{onClick:()=>w("verify"),disabled:!I||!O,style:{padding:"10px 20px",background:!I||!O?"var(--color-border)":"var(--color-primary)",color:!I||!O?"var(--color-secondary-text)":"white",border:`1px solid ${!I||!O?"var(--color-border)":"var(--color-primary)"}`,cursor:!I||!O?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),R==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(le,{type:"text",placeholder:"000000",value:A[0],onChange:J=>{const _e=J.target.value.replace(/[^0-9]/g,"").substring(0,6);Q([_e,A[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(le,{type:"text",placeholder:"000000",value:A[1],onChange:J=>{const _e=J.target.value.replace(/[^0-9]/g,"").substring(0,6);Q([A[0],_e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(Y,{onClick:()=>w("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(Y,{onClick:H,disabled:te||A.some(J=>J.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:te?"Verifying...":"Verify & Continue"})]})]}),R==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ut,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:ee.map((J,_e)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(J),children:J},_e))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(Y,{onClick:ge,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(Y,{onClick:V,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(on,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(Y,{onClick:se,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),R==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(Ve,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(Y,{onClick:se,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(qo,{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"})})}),D.length?e.jsx("div",{children:D.map((J,_e)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:J.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:J.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:J.status==="Enabled"||J.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:J.status==="Enabled"||J.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:J.status}),e.jsxs("div",{style:{position:"relative"},children:[J.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(Y,{ref:C,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),b&&e.jsx(ya,{triggerRef:C,onClose:()=>z(!1),onChangePassword:q})]}),ie()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:E,onClick:()=>k(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),j&&e.jsx(X0,{triggerRef:E,onClose:()=>k(!1),onRemovePassword:B})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:C,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),b&&e.jsx(ya,{triggerRef:C,onClose:()=>z(!1),onChangePassword:q,isSetup:!0})]})}),J.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:P,onClick:()=>S(!0),disabled:ne,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:ne?"Setting up...":"Setup"}),$&&e.jsx(W0,{triggerRef:P,onClose:()=>S(!1),onSetupTOTP:async()=>{const ve=await i();return L(ve.id),ve},onVerifyTOTP:async ve=>{await s(F,ve),await r.refetch(),l("Two-factor authentication enabled successfully!","info")}})]})}),J.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{onClick:()=>m(!0),disabled:ue,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:ue?"not-allowed":"pointer",opacity:ue?.6:1},children:ue?"Removing...":"Remove"}),x&&e.jsx(Zr,{title:"Remove MFA and reset policy to default?",onConfirm:we,onCancel:()=>m(!1)})]}),J.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(Y,{ref:T,onClick:xe,disabled:K,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:K?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),_&&e.jsx(sv,{triggerRef:T,codes:ee,onClose:()=>v(!1),onCopy:ge,onDownload:V})]})}),J.id==="second_factor_policy"&&e.jsx(Cr,{checked:u==="enforced",onChange:ve=>{y(ve?"enforced":"none")}})]})]})]}),_e<D.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},J.id))}):e.jsx(at,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},kv=()=>{var U,F;const{deployment:t}=me(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:i}=sr(),{toast:s}=Mt(),[p,f]=a.useState(""),[c,h]=a.useState(""),[l,u]=a.useState(""),[g,x]=a.useState(!1),[m,y]=a.useState(!1),[$,S]=a.useState(!1),[b,z]=a.useState(""),[j,k]=a.useState((r==null?void 0:r.profile_picture_url)||null),_=a.useRef(null);a.useEffect(()=>{r&&!g&&(f(r.first_name||""),h(r.last_name||""),u(r.username||""),k(r.profile_picture_url||null),x(!0))},[r,g]);const v=a.useCallback(async()=>{if(r)try{const L={};p!==r.first_name&&(L.first_name=p),c!==r.last_name&&(L.last_name=c),l!==r.username&&(L.username=l),Object.keys(L).length>0&&await o(L)}catch(L){s(L.message||"Failed to save profile changes","error")}},[r,o,p,c,l,s]),P=L=>{f(L.target.value)},C=L=>{h(L.target.value)},E=L=>{u(L.target.value)},T=()=>{v()},R=()=>{v()},w=()=>{v()},I=L=>{var A;if((A=L.target.files)!=null&&A[0]){const Q=L.target.files[0];k(URL.createObjectURL(Q)),setTimeout(async()=>{try{await n(Q),r.refetch(),s("Profile picture updated successfully","info")}catch(ee){s(ee.message||"Failed to update profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},100)}},M=()=>{_.current&&_.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Ee,{})});const O=async()=>{if(!(!r||b!==r.username)){S(!0);try{await i(""),s("Account deleted successfully","info")}catch(L){s(L.message||"Failed to delete account","error")}finally{S(!1),z(""),y(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:j?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,onMouseEnter:L=>{L.currentTarget.style.borderColor="var(--color-primary)",L.currentTarget.style.transform="scale(1.02)"},onMouseLeave:L=>{L.currentTarget.style.borderColor="var(--color-border)",L.currentTarget.style.transform="scale(1)"},children:[j?e.jsx("img",{src:j,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Uo,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:_,style:{display:"none"},accept:"image/*",onChange:I})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(Y,{onClick:()=>{var L;return(L=_.current)==null?void 0:L.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(on,{size:14}),j?"Change":"Upload"]}),e.jsxs(Y,{onClick:async()=>{k(null),_.current&&(_.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),s("Profile picture removed successfully","info")}catch(L){s(L.message||"Failed to remove profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ut,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ce,{htmlFor:"firstName",children:"First Name"}),e.jsx(le,{id:"firstName",type:"text",value:p,onChange:P,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ce,{htmlFor:"lastName",children:"Last Name"}),e.jsx(le,{id:"lastName",type:"text",value:c,onChange:C,onBlur:R,placeholder:"Enter your last name",required:!0})]})]}),((F=(U=t==null?void 0:t.auth_settings)==null?void 0:U.username)==null?void 0:F.enabled)&&e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"username",children:"Username"}),e.jsx(le,{id:"username",type:"text",value:l,onChange:E,onBlur:w,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:m?"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(Y,{onClick:()=>{m?(y(!1),z("")):y(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:m?"Cancel":"Delete"})]}),m&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ce,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(le,{id:"confirm_username",type:"text",value:b,onChange:L=>z(L.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(Y,{onClick:O,disabled:b!==(r==null?void 0:r.username)||$,style:{background:b===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:b===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:b===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:b===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:$?e.jsx(Ee,{size:12}):"Delete Forever"})]})]})]})]})})},Xl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:i,footerContent:s,customContent:p,children:f,showCloseButton:c})=>e.jsx(ke,{isOpen:t,onClose:r,children:e.jsx(ke.Overlay,{children:e.jsxs(ke.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(ke.Header,{showCloseButton:c,children:i||o}),p||f||e.jsx(Kl,{}),s&&e.jsx(ke.Footer,{children:s})]})})}),Cv=d.div`
|
|
4161
4161
|
position: relative;
|
|
4162
4162
|
`,Sv=d.button`
|
|
4163
4163
|
display: flex;
|
|
@@ -4296,7 +4296,7 @@ cursor: pointer;
|
|
|
4296
4296
|
width: 14px;
|
|
4297
4297
|
height: 14px;
|
|
4298
4298
|
}
|
|
4299
|
-
`,Ts=({showName:t=!0})=>{var _,v,P,C;const[r,o]=a.useState(!1),n=a.useRef(null),i=a.useRef(null),s=Al({triggerRef:n,isOpen:r,minWidth:380}),
|
|
4299
|
+
`,Ts=({showName:t=!0})=>{var _,v,P,C;const[r,o]=a.useState(!1),n=a.useRef(null),i=a.useRef(null),s=Al({triggerRef:n,isOpen:r,minWidth:380}),p=Dr(!1),{session:f,signOut:c,switchSignIn:h,refetch:l}=Be(),{navigateToSignIn:u}=Ge(),{deployment:g}=me(),x=(_=f==null?void 0:f.active_signin)==null?void 0:_.user,m=((P=(v=g==null?void 0:g.auth_settings)==null?void 0:v.multi_session_support)==null?void 0:P.enabled)??!1,y=(((C=f==null?void 0:f.signins)==null?void 0:C.length)??0)>1;a.useEffect(()=>{if(!r)return;const E=setTimeout(()=>{const T=R=>{var I,M;const w=R.target;(I=n.current)!=null&&I.contains(w)||(M=i.current)!=null&&M.contains(w)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(E)}},[r]);const $=()=>{o(!r)},S=E=>E.split(" ").map(T=>T[0]).join("").toUpperCase(),b=async E=>{try{await c(E),await l(),o(!1)}catch{}},z=async()=>{try{await c(),await l(),o(!1)}catch{}},j=async E=>{try{await h(E),await l(),o(!1)}catch{}},k=()=>{p.open(),o(!1)};return e.jsx(fe,{children:e.jsxs(Cv,{children:[e.jsxs(Sv,{ref:n,onClick:$,children:[e.jsx(Yn,{children:e.jsx(Jl,{children:x!=null&&x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):S(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),t&&e.jsx(zv,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})]}),typeof window<"u"&&r&&Wr.createPortal(e.jsx(fe,{children:e.jsx($v,{ref:i,$position:s,$isOpen:r,$maxHeight:s==null?void 0:s.maxHeight,children:e.jsxs("div",{children:[m?(()=>{const E=[...(f==null?void 0:f.signins)||[]].sort((T,R)=>{const w=T.user.id===(x==null?void 0:x.id),I=R.user.id===(x==null?void 0:x.id);return w&&!I?-1:!w&&I?1:0});return E.map(({user:T,id:R},w)=>{const I=T.id===(x==null?void 0:x.id),M=!I;return e.jsxs(a.Fragment,{children:[e.jsxs(Ca,{$isClickable:M,onClick:M?()=>j(R):void 0,children:[e.jsxs(Sa,{children:[e.jsx(Yn,{children:e.jsx(Ea,{children:T.has_profile_picture?e.jsx("img",{src:T.profile_picture_url,alt:T.first_name}):S(`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`)})}),e.jsxs(za,{children:[e.jsx($a,{children:e.jsx(_a,{children:`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`})}),e.jsx(ka,{children:T.primary_email_address.email})]})]}),I&&e.jsxs(Ia,{children:[e.jsxs(Eo,{onClick:k,children:[e.jsx(er,{}),"Manage account"]}),e.jsxs(Eo,{$destructive:!0,onClick:()=>b(R),children:[e.jsx(It,{}),"Sign out"]})]})]}),w===0&&E.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},T.id)})})():x&&e.jsxs(Ca,{$isClickable:!1,children:[e.jsxs(Sa,{children:[e.jsx(Yn,{children:e.jsx(Ea,{children:x.has_profile_picture?e.jsx("img",{src:x.profile_picture_url,alt:x.first_name}):S(`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`)})}),e.jsxs(za,{children:[e.jsx($a,{children:e.jsx(_a,{children:`${(x==null?void 0:x.first_name)||""} ${(x==null?void 0:x.last_name)||""}`})}),e.jsx(ka,{children:x.primary_email_address.email})]})]}),e.jsxs(Ia,{children:[e.jsxs(Eo,{onClick:k,children:[e.jsx(er,{}),"Manage account"]}),e.jsxs(Eo,{$destructive:!0,onClick:()=>{var E;return b(((E=f==null?void 0:f.active_signin)==null?void 0:E.id)||"")},children:[e.jsx(It,{}),"Sign out"]})]})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx(Pa,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(Ra,{onClick:()=>u(),children:[e.jsx(Ze,{}),"Add new account"]})}),y&&e.jsx(Pa,{children:e.jsxs(Ra,{onClick:z,children:[e.jsx(It,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(Xl,{isOpen:p.isOpen,onClose:p.close})]})})},Ev=d.div`
|
|
4300
4300
|
padding: var(--space-md) var(--space-lg);
|
|
4301
4301
|
background: ${t=>t.$unread?"var(--color-background-hover)":"transparent"};
|
|
4302
4302
|
transition: all 0.2s ease;
|
|
@@ -4405,7 +4405,7 @@ cursor: pointer;
|
|
|
4405
4405
|
width: 12px;
|
|
4406
4406
|
height: 12px;
|
|
4407
4407
|
}
|
|
4408
|
-
`;function ed({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},i=s=>{const
|
|
4408
|
+
`;function ed({notification:t,onMarkAsRead:r,onDelete:o}){const n=()=>{t.is_read||r(t.id)},i=s=>{const p=new Date(s),c=new Date().getTime()-p.getTime(),h=Math.floor(c/1e3),l=Math.floor(h/60),u=Math.floor(l/60),g=Math.floor(u/24);return g>7?p.toLocaleDateString():g>0?`${g}d ago`:u>0?`${u}h ago`:l>0?`${l}m ago`:"Just now"};return e.jsxs(Ev,{$unread:!t.is_read,onClick:n,children:[e.jsxs(Iv,{children:[e.jsxs(Pv,{children:[e.jsx(Tv,{$severity:t.severity}),e.jsx(Rv,{children:t.title})]}),e.jsx(Dv,{onClick:s=>{s.stopPropagation(),o(t.id)},"aria-label":"Delete notification",children:e.jsx(Je,{})})]}),e.jsx(Mv,{children:t.body}),e.jsxs(Ov,{children:[e.jsx(Lv,{children:i(t.created_at)}),t.action_url&&e.jsx(Av,{children:e.jsxs(Fv,{href:t.action_url,target:"_blank",rel:"noopener noreferrer",onClick:s=>s.stopPropagation(),children:[t.action_label||"View",e.jsx(Ss,{})]})})]})]})}const Nv=d.div`
|
|
4409
4409
|
position: fixed;
|
|
4410
4410
|
${t=>{var r;return((r=t.$position)==null?void 0:r.top)!==void 0?`top: ${t.$position.top}px;`:""}}
|
|
4411
4411
|
${t=>{var r;return((r=t.$position)==null?void 0:r.bottom)!==void 0?`bottom: ${t.$position.bottom}px;`:""}}
|
|
@@ -4516,7 +4516,7 @@ cursor: pointer;
|
|
|
4516
4516
|
color: var(--color-primary-hover);
|
|
4517
4517
|
text-decoration: underline;
|
|
4518
4518
|
}
|
|
4519
|
-
`,td=a.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:i,onDelete:s},
|
|
4519
|
+
`,td=a.forwardRef(({position:t,notifications:r,loading:o,onMarkAsRead:n,onMarkAllAsRead:i,onDelete:s},p)=>{const f=!o&&r.some(c=>!c.is_read);return console.log("loadings",o),e.jsxs(Nv,{ref:p,$position:t,children:[e.jsxs(Bv,{children:[e.jsx(Uv,{children:"Notifications"}),f&&e.jsx(Wv,{onClick:i,children:"Mark all as read"})]}),e.jsx(Vv,{children:o?e.jsx(Gv,{children:e.jsx(Ee,{})}):r.length===0?e.jsxs(Hv,{children:[e.jsx(qv,{children:e.jsx(Rp,{})}),e.jsx(Yv,{children:"No notifications"}),e.jsx(Zv,{children:"You're all caught up!"})]}):r.map(c=>e.jsx(ed,{notification:c,onMarkAsRead:n,onDelete:s},c.id))}),!o&&r.length>0&&e.jsx(Qv,{children:e.jsx(Kv,{href:"/notifications",children:"View all notifications"})})]})}),Xv=d.div`
|
|
4520
4520
|
position: relative;
|
|
4521
4521
|
`,Jv=d.div`
|
|
4522
4522
|
width: 40px;
|
|
@@ -4579,11 +4579,11 @@ cursor: pointer;
|
|
|
4579
4579
|
justify-content: center;
|
|
4580
4580
|
border: 2px solid var(--color-background);
|
|
4581
4581
|
box-shadow: 0 1px 3px var(--color-shadow);
|
|
4582
|
-
`;function rd({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:i}){const[s,
|
|
4582
|
+
`;function rd({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:i}){const[s,p]=a.useState(!1),[f,c]=a.useState(),h=a.useRef(null),l=a.useRef(null),u={channels:o,organization_ids:n,workspace_ids:i,limit:20},{unreadCount:g,notifications:x,loading:m,markAsRead:y,markAllAsRead:$,deleteNotification:S}=wc(u);return a.useEffect(()=>{if(!s)return;const b=setTimeout(()=>{const z=j=>{var _,v;const k=j.target;(_=h.current)!=null&&_.contains(k)||(v=l.current)!=null&&v.contains(k)||p(!1)};return document.addEventListener("mousedown",z),()=>{document.removeEventListener("mousedown",z)}},50);return()=>{clearTimeout(b)}},[s]),a.useEffect(()=>{if(s&&h.current){const b=h.current.getBoundingClientRect(),z=400,j=600,k=window.innerWidth,_=window.innerHeight,v=k-b.left,P=_-b.bottom,C=b.top;let E,T;v>=z?E=b.left:T=k-b.right;let R,w;P>=j+8?R=b.bottom+8:C>=j+8?w=_-b.top+8:R=b.bottom+8,c({top:R,bottom:w,left:E,right:T})}else c(void 0)},[s]),e.jsx(fe,{children:e.jsxs(Xv,{ref:h,className:t,children:[e.jsx(Jv,{children:e.jsxs(e1,{onClick:()=>p(!s),children:[e.jsx(Mp,{size:16}),r&&g>0&&e.jsx(t1,{children:g>9?"9+":g})]})}),typeof window<"u"&&s&&Wr.createPortal(e.jsx(fe,{children:e.jsx(td,{ref:l,position:f,notifications:x,loading:m,onMarkAsRead:y,onMarkAllAsRead:$,onDelete:S})}),document.body)]})})}const r1=d.div`
|
|
4583
4583
|
display: flex;
|
|
4584
4584
|
align-items: center;
|
|
4585
4585
|
gap: 8px;
|
|
4586
|
-
`,o1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(r1,{children:[r&&e.jsx(rd,{}),e.jsx(Ts,{showName:t})]}),n1=({children:t})=>{var s;const{session:r,loading:o}=Be(),{deployment:n}=me(),{navigateToAccountSelection:i}=Ge();return a.useEffect(()=>{var
|
|
4586
|
+
`,o1=({showName:t=!0,showNotifications:r=!0})=>e.jsxs(r1,{children:[r&&e.jsx(rd,{}),e.jsx(Ts,{showName:t})]}),n1=({children:t})=>{var s;const{session:r,loading:o}=Be(),{deployment:n}=me(),{navigateToAccountSelection:i}=Ge();return a.useEffect(()=>{var p;o||(p=r==null?void 0:r.signins)!=null&&p.length&&!r.active_signin&&i()},[o,r,n,i]),o||!((s=r.signins)!=null&&s.length)||!r.active_signin?null:e.jsx(e.Fragment,{children:t})},s1=({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})},od=ir`
|
|
4587
4587
|
0% {
|
|
4588
4588
|
background-position: -1000px 0;
|
|
4589
4589
|
}
|
|
@@ -4812,7 +4812,7 @@ cursor: pointer;
|
|
|
4812
4812
|
&:hover {
|
|
4813
4813
|
color: var(--color-primary-hover);
|
|
4814
4814
|
}
|
|
4815
|
-
`,b1=({onAccountSelect:t,showAddAccount:r=!0})=>{var j,k,_,v,P;const{session:o,loading:n,switchSignIn:i,signOut:s}=Be(),{deployment:
|
|
4815
|
+
`,b1=({onAccountSelect:t,showAddAccount:r=!0})=>{var j,k,_,v,P;const{session:o,loading:n,switchSignIn:i,signOut:s}=Be(),{deployment:p}=me(),{navigateToSignIn:f,navigate:c}=Ge(),[h,l]=a.useState(null),[u,g]=a.useState(null),x=o==null?void 0:o.active_signin,m=(o==null?void 0:o.signins)||[],y=((k=(j=p==null?void 0:p.auth_settings)==null?void 0:j.multi_session_support)==null?void 0:k.enabled)??!1;a.useEffect(()=>{n||m.length||f()},[n,m,f]);const $=C=>C.split(" ").map(E=>E[0]).join("").toUpperCase().slice(0,2),S=async C=>{var E;if(!(C===(x==null?void 0:x.id)||u)){g(C);try{if(await i(C),t)t(C),g(null);else{let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=(E=p.ui_settings)==null?void 0:E.after_signin_redirect_url),T){const R=new URL(T);(p==null?void 0:p.mode)==="staging"&&R.searchParams.set("dev_session",localStorage.getItem("__dev_session__")??""),c(R.toString())}else g(null)}}catch(T){console.error("Failed to switch account:",T),g(null)}}},b=async(C,E)=>{C.stopPropagation(),l(E);try{await s(E)}catch(T){console.error("Failed to sign out:",T)}finally{l(null)}},z=()=>{var E;let C=new URLSearchParams(window.location.search).get("redirect_uri");C||(C=(E=p.ui_settings)==null?void 0:E.after_signin_redirect_url),f(C)};return n?e.jsx(fe,{children:e.jsxs(Ta,{children:[e.jsx(Pe,{}),e.jsxs(Oa,{children:[e.jsx(La,{children:"Choose an account"}),e.jsxs(Aa,{children:["to continue to ",((_=p==null?void 0:p.ui_settings)==null?void 0:_.app_name)||"App"]})]}),e.jsx(Ma,{children:[1,2].map(C=>e.jsxs(f1,{children:[e.jsx(g1,{}),e.jsxs(m1,{children:[e.jsx(Da,{}),e.jsx(Da,{$width:"small"})]})]},C))})]})}):m.length?e.jsx(fe,{children:e.jsxs(Ta,{children:[e.jsx(Pe,{}),e.jsxs(Oa,{children:[e.jsx(La,{children:"Choose an account"}),e.jsxs(Aa,{children:["to continue to ",(v=p==null?void 0:p.ui_settings)==null?void 0:v.app_name]})]}),e.jsxs(Ma,{children:[m.map(({user:C,id:E})=>{var I,M,O,U,F;if(!C)return null;const T=E===(x==null?void 0:x.id),R=u===E,w=`${C.first_name||""} ${C.last_name||""}`.trim();return e.jsxs(a1,{$isActive:T,$isSwitching:R,onClick:()=>S(E),children:[e.jsx(c1,{children:C.has_profile_picture?e.jsx("img",{src:C.profile_picture_url,alt:w}):$(w||((I=C.primary_email_address)==null?void 0:I.email)||((M=C.primary_phone_number)==null?void 0:M.phone_number)||C.username||"U")}),e.jsxs(l1,{children:[e.jsx(d1,{children:w||((O=C.primary_email_address)==null?void 0:O.email)||((U=C.primary_phone_number)==null?void 0:U.phone_number)||C.username||"User"}),e.jsx(u1,{children:((F=C.primary_email_address)==null?void 0:F.email)||C.username})]}),!R&&e.jsxs(p1,{onClick:L=>b(L,E),$isLoading:h===E,disabled:h===E,children:[h===E?e.jsx(bt,{size:12}):e.jsx(It,{size:12}),h===E?"Signing out...":"Sign out"]})]},E)}),r&&y&&e.jsxs(h1,{onClick:z,children:[e.jsx(Ze,{}),"Add another account"]})]}),e.jsxs(x1,{children:["Don't have an account?"," ",e.jsx(v1,{children:e.jsx(ot,{to:`${(P=p.ui_settings)==null?void 0:P.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},y1=()=>{const{navigateToSignIn:t}=Ge();return a.useEffect(()=>{t()},[t]),null},w1=()=>{const{navigateToSignUp:t}=Ge();return a.useEffect(()=>{t()},[t]),null},j1=d.div`
|
|
4816
4816
|
width: 100%;
|
|
4817
4817
|
height: 500px;
|
|
4818
4818
|
background: var(--color-background);
|
|
@@ -5020,10 +5020,10 @@ cursor: pointer;
|
|
|
5020
5020
|
margin: 0 auto;
|
|
5021
5021
|
padding: 6px 16px;
|
|
5022
5022
|
font-size: 13px;
|
|
5023
|
-
`,T1=()=>{var T,R;const{organizationMemberships:t,refetch:r,loading:o}=yt(),{workspaces:n}=wt(),{switchOrganization:i,switchWorkspace:s}=Be(),{deployment:
|
|
5023
|
+
`,T1=()=>{var T,R;const{organizationMemberships:t,refetch:r,loading:o}=yt(),{workspaces:n}=wt(),{switchOrganization:i,switchWorkspace:s}=Be(),{deployment:p}=me(),[f,c]=a.useState(null),[h,l]=a.useState("orgList"),[u,g]=a.useState(null),x=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,m=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,y=a.useRef(!1);a.useEffect(()=>{if(!(y.current||!t)){if(y.current=!0,t.length===0){l("createOrg");return}if(!x){l("orgList");return}if(!n||n.length===0){t[0]&&g(t[0].organization.id),l("createWorkspace");return}l("orgList")}},[t,n,x]),console.log("view mode",h,x);const $=w=>w.split(" ").map(I=>I[0]).join("").toUpperCase().slice(0,2),S=async w=>{if(x){g(w.id),l("workspaceList");return}c(w.id);try{await i(w.id)}finally{c(null)}},b=async w=>{c(w.id);try{await s(w.id)}finally{c(null)}},z=async w=>{await r(),x&&w&&(g(w.id),l("createWorkspace"))},j=()=>{},k=async()=>{g(null),l("orgList")},_=(T=t==null?void 0:t.find(w=>w.organization.id===u))==null?void 0:T.organization,v=u?n==null?void 0:n.filter(w=>w.organization.id===u):[];if(o)return null;if(h==="createOrg")return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(an,{onSuccess:z,onCancel:()=>l("orgList")})});if(h==="createWorkspace"&&u)return e.jsx(ke.Body,{style:{padding:0},children:e.jsx(Is,{organizationId:u,onSuccess:j,onCancel:()=>l("workspaceList"),onCreateOrganization:()=>l("createOrg")})});const P=h==="workspaceList",C=P?"Select a workspace":"Select an organization",E=P?`Choose a workspace in ${(_==null?void 0:_.name)||""}`:`to continue to ${((R=p==null?void 0:p.ui_settings)==null?void 0:R.app_name)||"App"}`;return e.jsxs(j1,{children:[e.jsxs(_1,{children:[e.jsxs("div",{children:[e.jsx(Pe,{}),e.jsxs(E1,{children:[e.jsx(I1,{children:C}),e.jsx(P1,{children:E})]})]}),e.jsx(Ts,{showName:!0})]}),e.jsxs(k1,{children:[e.jsxs(C1,{children:[e.jsxs(S1,{children:[e.jsx(z1,{children:P?"Workspaces":"Your organizations"}),P&&e.jsxs($1,{onClick:k,children:[e.jsx(Gr,{}),"Go back"]})]}),e.jsx(R1,{children:P?e.jsx(e.Fragment,{children:v&&v.length>0?v.map(w=>{var M,O,U;const I=((M=w.eligibility_restriction)==null?void 0:M.type)!=="none"&&((O=w.eligibility_restriction)==null?void 0:O.type)!==void 0;return e.jsxs(Fa,{onClick:()=>!I&&b(w),disabled:f===w.id||I,style:{opacity:I?.7:1},children:[e.jsx(Na,{children:w.image_url?e.jsx(Ba,{src:w.image_url,alt:w.name}):$(w.name).charAt(0)}),e.jsxs(Ua,{children:[e.jsx(Wa,{children:w.name}),e.jsxs(Va,{children:[e.jsx(Wo,{}),"Workspace"]})]}),e.jsx(Ga,{children:e.jsx(ms,{})}),I&&e.jsxs(Ha,{children:[e.jsx(ut,{size:14}),(U=w.eligibility_restriction)==null?void 0:U.message]})]},w.id)}):e.jsxs(qa,{children:[e.jsx(Ya,{children:"No workspaces yet"}),e.jsxs(Za,{children:["Create your first workspace for"," ",(_==null?void 0:_.name)||"this organization"]}),e.jsxs(Qa,{onClick:()=>l("createWorkspace"),children:[e.jsx(Ze,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(w=>{var ee,W,K;const I=w.organization,M=n==null?void 0:n.filter(oe=>oe.organization.id===I.id),O=(M==null?void 0:M.length)||0,U=I.member_count,F=w.roles[0].name,L=w.roles.length-1,A=L>0?`${F.charAt(0).toUpperCase()+F.slice(1)} +${L}`:F.charAt(0).toUpperCase()+F.slice(1),Q=((ee=w.eligibility_restriction)==null?void 0:ee.type)!=="none"&&((W=w.eligibility_restriction)==null?void 0:W.type)!==void 0;return e.jsxs(Fa,{onClick:()=>!Q&&S(I),disabled:f===I.id||Q,style:{opacity:Q?.7:1},children:[e.jsx(Na,{children:I.image_url?e.jsx(Ba,{src:I.image_url,alt:I.name}):$(I.name)}),e.jsxs(Ua,{children:[e.jsx(Wa,{children:I.name}),e.jsx(Va,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),O," workspace",O!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(Ap,{}),A," • ",U," member",U!==1?"s":""]})})]}),e.jsx(Ga,{children:e.jsx(ms,{})}),Q&&e.jsxs(Ha,{children:[e.jsx(ut,{size:14}),(K=w.eligibility_restriction)==null?void 0:K.message]})]},I.id)}):e.jsxs(qa,{children:[e.jsx(Ya,{children:"No organizations yet"}),e.jsx(Za,{children:m?"Create your first organization to get started":"You don't have access to any organizations yet"}),m&&e.jsxs(Qa,{onClick:()=>l("createOrg"),children:[e.jsx(Ze,{}),"Create organization"]})]})})]}),P&&v&&v.length>0&&e.jsxs(Y,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createWorkspace"),disabled:f!==null,children:[e.jsx(Ze,{size:12}),"Create new workspace"]}),!P&&t&&t.length>0&&m&&e.jsxs(Y,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createOrg"),disabled:f!==null,children:[e.jsx(Ze,{size:12}),"Create new organization"]})]})]})},M1=d(ke.Content)`
|
|
5024
5024
|
padding: 0;
|
|
5025
5025
|
max-width: 90vw;
|
|
5026
|
-
`,O1=({children:t})=>{var y,$,S,b;const{loading:r,session:o}=Be(),{activeOrganization:n}=Ye(),{activeWorkspace:i,loading:s}=Rt(),{workspaces:
|
|
5026
|
+
`,O1=({children:t})=>{var y,$,S,b;const{loading:r,session:o}=Be(),{activeOrganization:n}=Ye(),{activeWorkspace:i,loading:s}=Rt(),{workspaces:p}=wt(),{deployment:f}=me(),{organizationMemberships:c}=yt(),h=(f==null?void 0:f.b2b_settings.workspaces_enabled)??!1,l=c==null?void 0:c.find(z=>z.organization.id===(n==null?void 0:n.id)),u=p==null?void 0:p.find(z=>{var j;return z.id===((j=o==null?void 0:o.active_signin)==null?void 0:j.active_workspace_membership_id)}),g=((y=l==null?void 0:l.eligibility_restriction)==null?void 0:y.type)!=="none"&&(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!==void 0,x=((S=u==null?void 0:u.eligibility_restriction)==null?void 0:S.type)!=="none"&&((b=u==null?void 0:u.eligibility_restriction)==null?void 0:b.type)!==void 0;return r||h&&s?null:(g||x||!n?!1:h?i?p==null?void 0:p.some(j=>j.id===i.id&&j.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(fe,{children:e.jsx(ke,{isOpen:!0,children:e.jsx(ke.Overlay,{children:e.jsx(M1,{style:{width:"850px"},children:e.jsx(T1,{})})})})})},L1=d.div`
|
|
5027
5027
|
display: flex;
|
|
5028
5028
|
gap: 8px;
|
|
5029
5029
|
flex-wrap: wrap;
|
|
@@ -5051,7 +5051,7 @@ cursor: pointer;
|
|
|
5051
5051
|
border-radius: 8px;
|
|
5052
5052
|
font-size: 10px;
|
|
5053
5053
|
font-weight: 400;
|
|
5054
|
-
`,F1={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function N1({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=i=>{if(t.includes(i)){const
|
|
5054
|
+
`,F1={user:"Personal",organization:"Organization",workspace:"Workspace",current:"Current Context"};function N1({selectedChannels:t,channelCounts:r,onChannelsChange:o}){const n=i=>{if(t.includes(i)){const p=t.filter(f=>f!==i);p.length===0?o(["user"]):o(p)}else o([...t,i])};return e.jsx(L1,{children:Object.entries(F1).map(([i,s])=>{const p=(r==null?void 0:r[i])||0,f=t.includes(i);return e.jsxs(A1,{$active:f,onClick:()=>n(i),children:[s,p>0&&e.jsx(D1,{children:p})]},i)})})}const Ka=d.div`
|
|
5055
5055
|
display: flex;
|
|
5056
5056
|
flex-direction: column;
|
|
5057
5057
|
width: 100%;
|
|
@@ -5705,7 +5705,7 @@ cursor: pointer;
|
|
|
5705
5705
|
&:hover .expand-icon {
|
|
5706
5706
|
opacity: 1;
|
|
5707
5707
|
}
|
|
5708
|
-
`,yb=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:i,onClose:s,onDownload:u,onZoom:f,onReset:c,onWheel:h,onMouseDown:l,onMouseMove:p,onMouseUp:g})=>{const[x,m]=a.useState(!1),y=a.useRef(null);return a.useEffect(()=>(m(!0),()=>m(!1)),[]),a.useEffect(()=>{if(t){const $=document.body.style.overflow;document.body.style.overflow="hidden";const S=j=>{(j.ctrlKey||j.metaKey)&&j.preventDefault()},b=j=>{j.preventDefault()},z=j=>{j.preventDefault()};return document.addEventListener("wheel",S,{passive:!1}),document.addEventListener("gesturestart",b,{passive:!1}),document.addEventListener("gesturechange",z,{passive:!1}),()=>{document.body.style.overflow=$,document.removeEventListener("wheel",S),document.removeEventListener("gesturestart",b),document.removeEventListener("gesturechange",z)}}},[t]),!x||!t||!r?null:Wr.createPortal(e.jsx(fe,{children:e.jsx(hb,{ref:y,$isOpen:!0,onClick:$=>{$.target===$.currentTarget&&s()},children:e.jsxs(fb,{onClick:$=>$.stopPropagation(),onWheel:$=>{$.preventDefault(),$.stopPropagation(),h($)},onMouseMove:p,onMouseUp:g,onMouseLeave:g,children:[e.jsx(gb,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:i,onMouseDown:l,draggable:!1}),e.jsx(Io,{$variant:"ghost",onClick:s,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(Je,{size:14})}),e.jsxs(mb,{children:[e.jsxs(xb,{children:[e.jsx(Io,{$variant:"ghost",onClick:()=>f(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx($h,{size:14})}),e.jsxs(vb,{children:[Math.round(o*100),"%"]}),e.jsx(Io,{$variant:"ghost",onClick:()=>f(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Sh,{size:14})}),e.jsx(Io,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(ah,{size:14})})]}),e.jsxs(sd,{$variant:"primary",onClick:u,title:"Download image",children:[e.jsx(on,{size:14}),"Download"]})]})]})})}),document.body)};function id({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:i,selectedSession:s,selectSession:u}=Yo(),f=s==null?void 0:s.id;if(!f)return e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsx(Ka,{children:e.jsxs(Xa,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,h=!0,l="Start a conversation by typing a message below",[p,g]=a.useState(""),[x,m]=a.useState(!1),[y,$]=a.useState(null),[S,b]=a.useState([]),[z,j]=a.useState([]),[k,_]=a.useState(null),[v,P]=a.useState(1),[C,E]=a.useState(!1),[T,R]=a.useState({x:0,y:0}),[w,I]=a.useState({x:0,y:0}),M=a.useRef(null),L=a.useRef(null),{messages:U,pendingMessage:F,pendingImages:O,connectionState:A,isConnected:Q,isExecuting:ee,executionStatus:W,isWaitingForInput:K,sendMessage:oe,submitUserInput:te,cancelExecution:de}=jc({contextId:f,agentName:o,token:n,platformAdapter:i,autoConnect:c});a.useEffect(()=>{var D;(D=M.current)==null||D.scrollIntoView({behavior:"smooth"})},[U]),a.useEffect(()=>{var D;if(K){const N=U.slice().reverse().find(re=>{var pe;return((pe=re.metadata)==null?void 0:pe.type)==="user_input_request"});(D=N==null?void 0:N.metadata)!=null&&D.userInputRequest&&$(N.metadata.userInputRequest)}else $(null),b([])},[K,U]);const ne=D=>{if(D.preventDefault(),!!Q)if(K&&y){let N=p.trim();y.input_type==="multiselect"&&(N=S.join(",")),N&&(te(N),g(""),b([]))}else!ee&&p.trim()&&(oe(p,z.length>0?z:void 0),g(""),j([]))},ue=D=>{const N=D.target.files;N&&(Array.from(N).forEach(re=>{if(re.type.startsWith("image/")){const pe=new FileReader;pe.onload=J=>{var _e;if((_e=J.target)!=null&&_e.result){const Se=J.target.result.split(",")[1];j(Oe=>[...Oe,{mime_type:re.type,data:Se}])}},pe.readAsDataURL(re)}}),L.current&&(L.current.value=""))},X=D=>{j(N=>N.filter((re,pe)=>pe!==D))},ae=D=>{_(D),P(1),R({x:0,y:0})},Z=()=>{_(null),P(1),R({x:0,y:0}),E(!1)},q=D=>{const N=document.createElement("a");N.href=D,N.download=`image-${Date.now()}.png`,document.body.appendChild(N),N.click(),document.body.removeChild(N)},B=D=>{P(N=>{const re=N+D;return Math.min(Math.max(re,.5),3)})},ie=D=>{D.preventDefault(),D.stopPropagation();const N=D.deltaY>0?-.1:.1;B(N)},H=D=>{v>1&&(E(!0),I({x:D.clientX-T.x,y:D.clientY-T.y}))},se=D=>{C&&v>1&&R({x:D.clientX-w.x,y:D.clientY-w.y})},we=()=>{E(!1)},xe=()=>A.status===xt.CONNECTING?"Connecting...":A.status===xt.ERROR?"Connection error":A.status===xt.DISCONNECTED||!Q?"Disconnected":K?"Waiting for your input...":ee?"Working...":"Ready",ge=()=>{if(!K||!y)return"Ask anything";switch(y.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},V=()=>!K||!y?!1:["select","multiselect","boolean","date"].includes(y.input_type||"");return e.jsxs(fe,{style:{height:"100%",width:"100%"},children:[e.jsxs(Ka,{children:[e.jsxs(B1,{children:[e.jsxs(U1,{children:[t&&e.jsx(W1,{onClick:()=>{r?r():u(null)},children:e.jsx(Gr,{size:20})}),e.jsxs(V1,{children:[e.jsx(G1,{children:e.jsx(wn,{size:20})}),e.jsxs(H1,{children:[e.jsx(Y1,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(q1,{$status:xe()}),e.jsx(Z1,{$status:xe(),children:xe()})]})]})]})]}),W!==Ae.IDLE&&e.jsx(Q1,{$status:W,children:W.replace("_"," ")})]}),e.jsx(K1,{children:U.length===0&&h?e.jsxs(Xa,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:l})]}):e.jsxs(e.Fragment,{children:[U.map((D,N)=>{var re,pe,J,_e;if(((re=D.metadata)==null?void 0:re.type)==="user_input_request"&&D.metadata.userInputRequest){const ve=D.metadata.userInputRequest,Se=!ve.input_type||ve.input_type==="text"||ve.input_type==="number",Oe=K&&(y==null?void 0:y.input_type)===ve.input_type;return e.jsx(Zn,{$isUser:!1,children:e.jsxs(tb,{children:[e.jsx("div",{className:"question",children:ve.question}),ve.context&&ve.context.trim()&&e.jsx("div",{className:"context",children:ve.context}),!Se&&e.jsxs("div",{className:"controls",children:[ve.input_type==="select"&&ve.options&&e.jsxs("select",{value:Oe?p:"",onChange:Re=>g(Re.target.value),disabled:!Oe,children:[e.jsx("option",{value:"",children:"Choose an option..."}),ve.options.map(Re=>e.jsx("option",{value:Re,children:Re},Re))]}),ve.input_type==="multiselect"&&ve.options&&e.jsx("div",{className:"checkbox-group",children:ve.options.map(Re=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Oe&&S.includes(Re),onChange:ar=>{ar.target.checked?b([...S,Re]):b(S.filter(cr=>cr!==Re))},disabled:!Oe}),e.jsx("span",{children:Re})]},Re))}),ve.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Oe&&p==="true",onChange:Re=>g(Re.target.value),disabled:!Oe}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Oe&&p==="false",onChange:Re=>g(Re.target.value),disabled:!Oe}),e.jsx("span",{children:"No"})]})]}),ve.input_type==="date"&&e.jsx("input",{type:"date",value:Oe?p:"",onChange:Re=>g(Re.target.value),disabled:!Oe})]}),e.jsx("div",{className:"instruction",children:Oe?Se?"Type your response below":ve.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},D.id)}if(((pe=D.metadata)==null?void 0:pe.type)==="log"){const ve=U[N-1],Se=U[N+1],Oe=((J=ve==null?void 0:ve.metadata)==null?void 0:J.type)==="log",Re=((_e=Se==null?void 0:Se.metadata)==null?void 0:_e.type)==="log",ar=Oe||Re,cr=!Oe&&Re,Qr=Oe&&!Re;return e.jsx(eb,{$isGrouped:ar,$isFirstInGroup:cr,$isLastInGroup:Qr,children:e.jsx("div",{className:"log-content",children:D.content})},D.id)}return!D.content&&(!D.images||D.images.length===0)?null:e.jsx(Zn,{$isUser:D.role==="user",children:e.jsxs(nd,{$isUser:D.role==="user",children:[e.jsx("div",{children:D.content}),D.images&&D.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:D.images.map((ve,Se)=>{const Oe=ve.url||`data:${ve.mime_type};base64,${ve.data}`;return e.jsxs(bb,{onClick:()=>ae(Oe),title:"Click to preview",children:[e.jsx("img",{src:Oe,alt:`Image ${Se+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(Zp,{size:14})})]},Se)})}),D.isStreaming&&e.jsx(X1,{})]})},D.id)}),F&&e.jsx(Zn,{$isUser:!0,children:e.jsxs(J1,{$isUser:!0,children:[e.jsx("div",{children:F}),O&&O.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:O.map((D,N)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:D.data?`data:${D.mime_type};base64,${D.data}`:"#",alt:`Image ${N+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},N))})]})}),e.jsx("div",{ref:M})]})}),z.length>0&&e.jsx(ab,{children:z.map((D,N)=>e.jsxs(cb,{children:[e.jsx("img",{src:D.data?`data:${D.mime_type};base64,${D.data}`:"#",alt:`Upload ${N+1}`}),e.jsx(lb,{type:"button",onClick:()=>X(N),children:e.jsx(Je,{size:12})})]},N))}),e.jsx(rb,{onSubmit:ne,children:e.jsxs(ob,{children:[e.jsxs(nb,{children:[e.jsx(sb,{value:p,onChange:D=>g(D.target.value),onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),ne(D))},placeholder:ge(),disabled:!Q||ee&&!K||V(),rows:1}),e.jsx(ib,{children:e.jsxs(ub,{type:"button",disabled:!Q||ee,onClick:()=>{var D;return(D=L.current)==null?void 0:D.click()},children:[e.jsx(dh,{size:16}),"Attach"]})}),e.jsx(db,{ref:L,type:"file",accept:"image/*",multiple:!0,onChange:ue})]}),e.jsx(pb,{type:ee?"button":"submit",disabled:!Q||!K&&!ee&&!p.trim(),onClick:ee?de:void 0,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{background:ee&&x?"var(--color-error)":void 0},children:ee?x?e.jsx(Je,{size:14}):e.jsx(bt,{size:14,className:"animate-spin"}):e.jsx(Kc,{size:14})})]})})]}),e.jsx(yb,{isOpen:!!k,imageUrl:k,zoomLevel:v,dragPosition:T,isDragging:C,onClose:Z,onDownload:()=>k&&q(k),onZoom:B,onReset:()=>{P(1),R({x:0,y:0})},onWheel:ie,onMouseDown:H,onMouseMove:se,onMouseUp:we})]})}const wb=d.div`
|
|
5708
|
+
`,yb=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:i,onClose:s,onDownload:p,onZoom:f,onReset:c,onWheel:h,onMouseDown:l,onMouseMove:u,onMouseUp:g})=>{const[x,m]=a.useState(!1),y=a.useRef(null);return a.useEffect(()=>(m(!0),()=>m(!1)),[]),a.useEffect(()=>{if(t){const $=document.body.style.overflow;document.body.style.overflow="hidden";const S=j=>{(j.ctrlKey||j.metaKey)&&j.preventDefault()},b=j=>{j.preventDefault()},z=j=>{j.preventDefault()};return document.addEventListener("wheel",S,{passive:!1}),document.addEventListener("gesturestart",b,{passive:!1}),document.addEventListener("gesturechange",z,{passive:!1}),()=>{document.body.style.overflow=$,document.removeEventListener("wheel",S),document.removeEventListener("gesturestart",b),document.removeEventListener("gesturechange",z)}}},[t]),!x||!t||!r?null:Wr.createPortal(e.jsx(fe,{children:e.jsx(hb,{ref:y,$isOpen:!0,onClick:$=>{$.target===$.currentTarget&&s()},children:e.jsxs(fb,{onClick:$=>$.stopPropagation(),onWheel:$=>{$.preventDefault(),$.stopPropagation(),h($)},onMouseMove:u,onMouseUp:g,onMouseLeave:g,children:[e.jsx(gb,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:i,onMouseDown:l,draggable:!1}),e.jsx(Io,{$variant:"ghost",onClick:s,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(Je,{size:14})}),e.jsxs(mb,{children:[e.jsxs(xb,{children:[e.jsx(Io,{$variant:"ghost",onClick:()=>f(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx($h,{size:14})}),e.jsxs(vb,{children:[Math.round(o*100),"%"]}),e.jsx(Io,{$variant:"ghost",onClick:()=>f(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Sh,{size:14})}),e.jsx(Io,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(ah,{size:14})})]}),e.jsxs(sd,{$variant:"primary",onClick:p,title:"Download image",children:[e.jsx(on,{size:14}),"Download"]})]})]})})}),document.body)};function id({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:i,selectedSession:s,selectSession:p}=Yo(),f=s==null?void 0:s.id;if(!f)return e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsx(Ka,{children:e.jsxs(Xa,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,h=!0,l="Start a conversation by typing a message below",[u,g]=a.useState(""),[x,m]=a.useState(!1),[y,$]=a.useState(null),[S,b]=a.useState([]),[z,j]=a.useState([]),[k,_]=a.useState(null),[v,P]=a.useState(1),[C,E]=a.useState(!1),[T,R]=a.useState({x:0,y:0}),[w,I]=a.useState({x:0,y:0}),M=a.useRef(null),O=a.useRef(null),{messages:U,pendingMessage:F,pendingImages:L,connectionState:A,isConnected:Q,isExecuting:ee,executionStatus:W,isWaitingForInput:K,sendMessage:oe,submitUserInput:te,cancelExecution:de}=jc({contextId:f,agentName:o,token:n,platformAdapter:i,autoConnect:c});a.useEffect(()=>{var D;(D=M.current)==null||D.scrollIntoView({behavior:"smooth"})},[U]),a.useEffect(()=>{var D;if(K){const N=U.slice().reverse().find(re=>{var pe;return((pe=re.metadata)==null?void 0:pe.type)==="user_input_request"});(D=N==null?void 0:N.metadata)!=null&&D.userInputRequest&&$(N.metadata.userInputRequest)}else $(null),b([])},[K,U]);const ne=D=>{if(D.preventDefault(),!!Q)if(K&&y){let N=u.trim();y.input_type==="multiselect"&&(N=S.join(",")),N&&(te(N),g(""),b([]))}else!ee&&u.trim()&&(oe(u,z.length>0?z:void 0),g(""),j([]))},ue=D=>{const N=D.target.files;N&&(Array.from(N).forEach(re=>{if(re.type.startsWith("image/")){const pe=new FileReader;pe.onload=J=>{var _e;if((_e=J.target)!=null&&_e.result){const Se=J.target.result.split(",")[1];j(Oe=>[...Oe,{mime_type:re.type,data:Se}])}},pe.readAsDataURL(re)}}),O.current&&(O.current.value=""))},X=D=>{j(N=>N.filter((re,pe)=>pe!==D))},ae=D=>{_(D),P(1),R({x:0,y:0})},Z=()=>{_(null),P(1),R({x:0,y:0}),E(!1)},q=D=>{const N=document.createElement("a");N.href=D,N.download=`image-${Date.now()}.png`,document.body.appendChild(N),N.click(),document.body.removeChild(N)},B=D=>{P(N=>{const re=N+D;return Math.min(Math.max(re,.5),3)})},ie=D=>{D.preventDefault(),D.stopPropagation();const N=D.deltaY>0?-.1:.1;B(N)},H=D=>{v>1&&(E(!0),I({x:D.clientX-T.x,y:D.clientY-T.y}))},se=D=>{C&&v>1&&R({x:D.clientX-w.x,y:D.clientY-w.y})},we=()=>{E(!1)},xe=()=>A.status===xt.CONNECTING?"Connecting...":A.status===xt.ERROR?"Connection error":A.status===xt.DISCONNECTED||!Q?"Disconnected":K?"Waiting for your input...":ee?"Working...":"Ready",ge=()=>{if(!K||!y)return"Ask anything";switch(y.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},V=()=>!K||!y?!1:["select","multiselect","boolean","date"].includes(y.input_type||"");return e.jsxs(fe,{style:{height:"100%",width:"100%"},children:[e.jsxs(Ka,{children:[e.jsxs(B1,{children:[e.jsxs(U1,{children:[t&&e.jsx(W1,{onClick:()=>{r?r():p(null)},children:e.jsx(Gr,{size:20})}),e.jsxs(V1,{children:[e.jsx(G1,{children:e.jsx(wn,{size:20})}),e.jsxs(H1,{children:[e.jsx(Y1,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(q1,{$status:xe()}),e.jsx(Z1,{$status:xe(),children:xe()})]})]})]})]}),W!==Ae.IDLE&&e.jsx(Q1,{$status:W,children:W.replace("_"," ")})]}),e.jsx(K1,{children:U.length===0&&h?e.jsxs(Xa,{children:[e.jsx(wn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:l})]}):e.jsxs(e.Fragment,{children:[U.map((D,N)=>{var re,pe,J,_e;if(((re=D.metadata)==null?void 0:re.type)==="user_input_request"&&D.metadata.userInputRequest){const ve=D.metadata.userInputRequest,Se=!ve.input_type||ve.input_type==="text"||ve.input_type==="number",Oe=K&&(y==null?void 0:y.input_type)===ve.input_type;return e.jsx(Zn,{$isUser:!1,children:e.jsxs(tb,{children:[e.jsx("div",{className:"question",children:ve.question}),ve.context&&ve.context.trim()&&e.jsx("div",{className:"context",children:ve.context}),!Se&&e.jsxs("div",{className:"controls",children:[ve.input_type==="select"&&ve.options&&e.jsxs("select",{value:Oe?u:"",onChange:Re=>g(Re.target.value),disabled:!Oe,children:[e.jsx("option",{value:"",children:"Choose an option..."}),ve.options.map(Re=>e.jsx("option",{value:Re,children:Re},Re))]}),ve.input_type==="multiselect"&&ve.options&&e.jsx("div",{className:"checkbox-group",children:ve.options.map(Re=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Oe&&S.includes(Re),onChange:ar=>{ar.target.checked?b([...S,Re]):b(S.filter(cr=>cr!==Re))},disabled:!Oe}),e.jsx("span",{children:Re})]},Re))}),ve.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Oe&&u==="true",onChange:Re=>g(Re.target.value),disabled:!Oe}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Oe&&u==="false",onChange:Re=>g(Re.target.value),disabled:!Oe}),e.jsx("span",{children:"No"})]})]}),ve.input_type==="date"&&e.jsx("input",{type:"date",value:Oe?u:"",onChange:Re=>g(Re.target.value),disabled:!Oe})]}),e.jsx("div",{className:"instruction",children:Oe?Se?"Type your response below":ve.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},D.id)}if(((pe=D.metadata)==null?void 0:pe.type)==="log"){const ve=U[N-1],Se=U[N+1],Oe=((J=ve==null?void 0:ve.metadata)==null?void 0:J.type)==="log",Re=((_e=Se==null?void 0:Se.metadata)==null?void 0:_e.type)==="log",ar=Oe||Re,cr=!Oe&&Re,Qr=Oe&&!Re;return e.jsx(eb,{$isGrouped:ar,$isFirstInGroup:cr,$isLastInGroup:Qr,children:e.jsx("div",{className:"log-content",children:D.content})},D.id)}return!D.content&&(!D.images||D.images.length===0)?null:e.jsx(Zn,{$isUser:D.role==="user",children:e.jsxs(nd,{$isUser:D.role==="user",children:[e.jsx("div",{children:D.content}),D.images&&D.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:D.images.map((ve,Se)=>{const Oe=ve.url||`data:${ve.mime_type};base64,${ve.data}`;return e.jsxs(bb,{onClick:()=>ae(Oe),title:"Click to preview",children:[e.jsx("img",{src:Oe,alt:`Image ${Se+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(Zp,{size:14})})]},Se)})}),D.isStreaming&&e.jsx(X1,{})]})},D.id)}),F&&e.jsx(Zn,{$isUser:!0,children:e.jsxs(J1,{$isUser:!0,children:[e.jsx("div",{children:F}),L&&L.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:L.map((D,N)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:D.data?`data:${D.mime_type};base64,${D.data}`:"#",alt:`Image ${N+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},N))})]})}),e.jsx("div",{ref:M})]})}),z.length>0&&e.jsx(ab,{children:z.map((D,N)=>e.jsxs(cb,{children:[e.jsx("img",{src:D.data?`data:${D.mime_type};base64,${D.data}`:"#",alt:`Upload ${N+1}`}),e.jsx(lb,{type:"button",onClick:()=>X(N),children:e.jsx(Je,{size:12})})]},N))}),e.jsx(rb,{onSubmit:ne,children:e.jsxs(ob,{children:[e.jsxs(nb,{children:[e.jsx(sb,{value:u,onChange:D=>g(D.target.value),onKeyDown:D=>{D.key==="Enter"&&!D.shiftKey&&(D.preventDefault(),ne(D))},placeholder:ge(),disabled:!Q||ee&&!K||V(),rows:1}),e.jsx(ib,{children:e.jsxs(ub,{type:"button",disabled:!Q||ee,onClick:()=>{var D;return(D=O.current)==null?void 0:D.click()},children:[e.jsx(dh,{size:16}),"Attach"]})}),e.jsx(db,{ref:O,type:"file",accept:"image/*",multiple:!0,onChange:ue})]}),e.jsx(pb,{type:ee?"button":"submit",disabled:!Q||!K&&!ee&&!u.trim(),onClick:ee?de:void 0,onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),style:{background:ee&&x?"var(--color-error)":void 0},children:ee?x?e.jsx(Je,{size:14}):e.jsx(bt,{size:14,className:"animate-spin"}):e.jsx(Kc,{size:14})})]})})]}),e.jsx(yb,{isOpen:!!k,imageUrl:k,zoomLevel:v,dragPosition:T,isDragging:C,onClose:Z,onDownload:()=>k&&q(k),onZoom:B,onReset:()=>{P(1),R({x:0,y:0})},onWheel:ie,onMouseDown:H,onMouseMove:se,onMouseUp:we})]})}const wb=d.div`
|
|
5709
5709
|
height: 100%;
|
|
5710
5710
|
display: flex;
|
|
5711
5711
|
flex-direction: column;
|
|
@@ -5900,7 +5900,7 @@ cursor: pointer;
|
|
|
5900
5900
|
background: var(--color-border);
|
|
5901
5901
|
border-radius: var(--radius-sm);
|
|
5902
5902
|
opacity: 0.6;
|
|
5903
|
-
`;function ad({showBackButton:t=!1}){const[r,o]=a.useState(""),{sessions:n,loadingSessions:i,selectSession:s,deleteSession:
|
|
5903
|
+
`;function ad({showBackButton:t=!1}){const[r,o]=a.useState(""),{sessions:n,loadingSessions:i,selectSession:s,deleteSession:p,setShowHistory:f}=Yo(),c=n.filter(x=>x.title.toLowerCase().includes(r.toLowerCase())),h=x=>{const m={},y=new Date,$=new Date(y.getFullYear(),y.getMonth(),y.getDate()),S=new Date($);S.setDate(S.getDate()-1);const b=new Date($);return b.setDate(b.getDate()-7),x.forEach(z=>{const j=new Date(z.last_activity_at);let k;j>=$?k="Today":j>=S?k="Yesterday":j>=b?k="This Week":k="Older",m[k]||(m[k]=[]),m[k].push(z)}),m},l=async(x,m)=>{if(x.stopPropagation(),confirm("Are you sure you want to delete this conversation?"))try{await p(m)}catch(y){console.error("Failed to delete session:",y)}},u=x=>new Date(x).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}),g=h(c);return e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsxs(wb,{children:[e.jsxs(jb,{children:[t&&e.jsx(_b,{onClick:()=>f(!1),children:e.jsx(Gr,{size:20})}),e.jsx(kb,{children:"Conversation History"})]}),e.jsx(Cb,{children:e.jsx(Sb,{type:"text",placeholder:"Search conversations...",value:r,onChange:x=>o(x.target.value)})}),e.jsx(zb,{children:i?e.jsx(Db,{children:[1,2,3,4,5].map(x=>e.jsxs(Fb,{children:[e.jsx(Nb,{}),e.jsxs(Bb,{children:[e.jsx(Ub,{}),e.jsx(Wb,{})]})]},x))}):c.length===0?e.jsxs(Ab,{children:[e.jsx(li,{}),e.jsx("div",{children:"No conversations found"}),r&&e.jsx("div",{style:{fontSize:"var(--font-xs)",marginTop:"var(--space-sm)"},children:"Try a different search term"})]}):Object.entries(g).map(([x,m])=>e.jsxs($b,{children:[e.jsx(Eb,{children:x}),m.map(y=>e.jsxs(Ib,{onClick:()=>s(y),children:[e.jsx(Pb,{children:e.jsx(li,{size:18})}),e.jsxs(Rb,{children:[e.jsx(Tb,{children:y.title}),e.jsxs(Mb,{children:[e.jsx("span",{children:u(y.last_activity_at)}),y.status!=="idle"&&e.jsx(Ob,{$status:y.status,children:y.status.replace("_"," ")})]})]}),e.jsx(Lb,{onClick:$=>l($,y.id),children:e.jsx(nn,{size:16})})]},y.id))]},x))})]})})}const Vb=d.div`
|
|
5904
5904
|
height: 100%;
|
|
5905
5905
|
display: flex;
|
|
5906
5906
|
flex-direction: column;
|
|
@@ -6058,5 +6058,5 @@ cursor: pointer;
|
|
|
6058
6058
|
display: flex;
|
|
6059
6059
|
flex-direction: column;
|
|
6060
6060
|
gap: var(--space-xs);
|
|
6061
|
-
`;function i2(){const[t,r]=a.useState(!1),{sessions:o,selectedSession:n,showHistory:i,selectSession:s,createSession:
|
|
6061
|
+
`;function i2(){const[t,r]=a.useState(!1),{sessions:o,selectedSession:n,showHistory:i,selectSession:s,createSession:p,setShowHistory:f}=Yo(),c=async()=>{try{r(!0),await p()}finally{r(!1)}},h=l=>{try{const u=new Date(l),x=new Date().getTime()-u.getTime(),m=Math.floor(x/6e4),y=Math.floor(m/60),$=Math.floor(y/24);return $>0?`${$}d ago`:y>0?`${y}h ago`:m>0?`${m}m ago`:"Just now"}catch{return""}};return i?e.jsx(ad,{showBackButton:!0}):n?e.jsx(id,{showBackButton:!0}):e.jsx(fe,{style:{height:"100%",width:"100%"},children:e.jsx(Vb,{children:e.jsxs(Gb,{children:[e.jsx(Hb,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(qb,{children:"Hi there! 👋"}),e.jsx(Yb,{children:"How can I help you today?"}),e.jsx(Zb,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(Qb,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(t2,{children:[e.jsxs(r2,{children:[e.jsx(o2,{children:"Recent Chats"}),e.jsx(n2,{onClick:()=>f(!0),children:"View All →"})]}),e.jsx(s2,{children:o.slice(0,2).map(l=>e.jsx(Kb,{onClick:()=>s(l),children:e.jsxs(e2,{children:[e.jsx(Xb,{children:l.title}),e.jsxs(Jb,{children:[e.jsx("span",{children:h(l.last_activity_at)}),l.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},l.id))})]})]})})})}const a2=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))},c2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=um;exports.AgentConversation=id;exports.AgentConversationHistory=ad;exports.AgentConversationHub=i2;exports.AgentConversationProvider=Vd;exports.AuthFormImage=Pe;exports.ChannelSelector=N1;exports.CreateOrganizationForm=an;exports.CreateWorkspaceDialog=Tl;exports.CreateWorkspaceForm=Is;exports.DeploymentInitialized=bu;exports.DeploymentInitializing=yu;exports.DeploymentProvider=dd;exports.Dialog=ke;exports.DialogTrigger=kf;exports.Dropdown=nt;exports.DropdownDivider=sn;exports.DropdownItem=Te;exports.DropdownItems=st;exports.DropdownTrigger=it;exports.Form=dt;exports.FormGroup=he;exports.Input=le;exports.Label=ce;exports.MagicLinkVerification=nm;exports.ManageAccount=Kl;exports.ManageAccountDialog=Xl;exports.ManageOrganization=Il;exports.ManageWorkspace=Ol;exports.ManageWorkspaceDialog=Ll;exports.NavigateToSignIn=y1;exports.NavigateToSignUp=w1;exports.NavigationLink=ot;exports.NotificationBell=rd;exports.NotificationItem=ed;exports.NotificationPopover=td;exports.OAuthProvider=uc;exports.OTPInput=Tt;exports.OrganizationSwitcher=Dl;exports.PhoneNumberInput=Yr;exports.PhoneVerification=yl;exports.ProfileCompletion=jl;exports.RequireActiveTenancy=O1;exports.SSOCallback=Zg;exports.SignInForm=Eg;exports.SignUpForm=lf;exports.SignedIn=n1;exports.SignedInAccounts=b1;exports.SignedOut=s1;exports.SimpleDialog=_f;exports.Spinner=Ee;exports.Switch=Cr;exports.TwoFactorMethodSelector=bl;exports.TwoFactorVerification=wl;exports.UserButton=Ts;exports.UserControls=o1;exports.WaitlistForm=Vg;exports.clearTokenCache=Et;exports.fetchChannelCounts=hu;exports.hasIncompleteProfile=sm;exports.isExternalUrl=a2;exports.isSafeUrl=c2;exports.redirectToProfileCompletion=im;exports.useActiveOrganization=Ye;exports.useActiveTenancy=uu;exports.useActiveWorkspace=Rt;exports.useAgentConversation=jc;exports.useAgentConversationContext=Yo;exports.useChannelCounts=vu;exports.useClient=Fe;exports.useConversationSessions=lc;exports.useDeployment=me;exports.useForgotPassword=bc;exports.useInvitation=_c;exports.useMagicLinkParams=vc;exports.useMagicLinkVerification=xc;exports.useNavigation=Ge;exports.useNotificationStream=yc;exports.useNotifications=wc;exports.useOrganizationList=Zo;exports.useOrganizationMemberships=yt;exports.useSSOCallback=mc;exports.useSession=Be;exports.useSignIn=pc;exports.useSignInWithStrategy=Br;exports.useSignUp=hc;exports.useUser=sr;exports.useUserSignins=fc;exports.useWaitlist=gc;exports.useWorkspaceList=wt;exports.useWorkspaceMemberships=Qo;Object.keys(Ls).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Ls[t]})});
|
|
6062
6062
|
//# sourceMappingURL=index.cjs.js.map
|