@wacht/jsx 0.0.1-alpha.13 → 0.0.1-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -15,7 +15,7 @@
15
15
  *
16
16
  * This source code is licensed under the MIT license found in the
17
17
  * LICENSE file in the root directory of this source tree.
18
- */var Ra;function ed(){return Ra||(Ra=1,process.env.NODE_ENV!=="production"&&function(){function t(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}function r(x,v){d||a.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var w=v();if(!l){var C=v();s(w,C)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}C=p({inst:{value:w,getSnapshot:v}});var $=C[0].inst,y=C[1];return c(function(){$.value=w,$.getSnapshot=v,o($)&&y({inst:$})},[x,w,v]),g(function(){return o($)&&y({inst:$}),x(function(){o($)&&y({inst:$})})},[x]),h(w),w}function o(x){var v=x.getSnapshot;x=x.value;try{var w=v();return!s(x,w)}catch{return!0}}function n(x,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=i,s=typeof Object.is=="function"?Object.is:t,p=a.useState,g=a.useEffect,c=a.useLayoutEffect,h=a.useDebugValue,d=!1,l=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;sn.useSyncExternalStore=a.useSyncExternalStore!==void 0?a.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),sn}var Ia;function td(){return Ia||(Ia=1,process.env.NODE_ENV==="production"?Gr.exports=Jl():Gr.exports=ed()),Gr.exports}var rd=td();const Ui=0,Wi=1,Vi=2,Ta=3;var Oa=Object.prototype.hasOwnProperty;function Gn(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&Gn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Oa.call(t,o)&&++n&&!Oa.call(r,o)||!(o in r)||!Gn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const vt=new WeakMap,$t=()=>{},Ge=$t(),Hn=Object,je=t=>t===Ge,lt=t=>typeof t=="function",Et=(t,r)=>({...t,...r}),Gi=t=>lt(t.then),cn={},Hr={},fa="undefined",Fr=typeof window!=fa,qn=typeof document!=fa,od=Fr&&"Deno"in window,nd=()=>Fr&&typeof window.requestAnimationFrame!=fa,Hi=(t,r)=>{const o=vt.get(t);return[()=>!je(r)&&t.get(r)||cn,n=>{if(!je(r)){const a=t.get(r);r in Hr||(Hr[r]=a),o[5](r,Et(a,n),a||cn)}},o[6],()=>!je(r)&&r in Hr?Hr[r]:!je(r)&&t.get(r)||cn]};let Yn=!0;const ad=()=>Yn,[Zn,Kn]=Fr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$t,$t],sd=()=>{const t=qn&&document.visibilityState;return je(t)||t!=="hidden"},id=t=>(qn&&document.addEventListener("visibilitychange",t),Zn("focus",t),()=>{qn&&document.removeEventListener("visibilitychange",t),Kn("focus",t)}),cd=t=>{const r=()=>{Yn=!0,t()},o=()=>{Yn=!1};return Zn("online",r),Zn("offline",o),()=>{Kn("online",r),Kn("offline",o)}},ld={isOnline:ad,isVisible:sd},dd={initFocus:id,initReconnect:cd},Ma=!i.useId,Lr=!Fr||od,ud=t=>nd()?window.requestAnimationFrame(t):setTimeout(t,1),ln=Lr?i.useEffect:i.useLayoutEffect,dn=typeof navigator<"u"&&navigator.connection,La=!Lr&&dn&&(["slow-2g","2g"].includes(dn.effectiveType)||dn.saveData),qr=new WeakMap,pd=t=>Hn.prototype.toString.call(t),un=(t,r)=>t===`[object ${r}]`;let hd=0;const Qn=t=>{const r=typeof t,o=pd(t),n=un(o,"Date"),a=un(o,"RegExp"),s=un(o,"Object");let p,g;if(Hn(t)===t&&!n&&!a){if(p=qr.get(t),p)return p;if(p=++hd+"~",qr.set(t,p),Array.isArray(t)){for(p="@",g=0;g<t.length;g++)p+=Qn(t[g])+",";qr.set(t,p)}if(s){p="#";const c=Hn.keys(t).sort();for(;!je(g=c.pop());)je(t[g])||(p+=g+":"+Qn(t[g])+",");qr.set(t,p)}}else p=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return p},ga=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Qn(t):"",[t,r]};let fd=0;const Xn=()=>++fd;async function qi(...t){const[r,o,n,a]=t,s=Et({populateCache:!0,throwOnError:!0},typeof a=="boolean"?{revalidate:a}:a||{});let p=s.populateCache;const g=s.rollbackOnError;let c=s.optimisticData;const h=m=>typeof g=="function"?g(m):g!==!1,d=s.throwOnError;if(lt(o)){const m=o,x=[],v=r.keys();for(const w of v)!/^\$(inf|sub)\$/.test(w)&&m(r.get(w)._k)&&x.push(w);return Promise.all(x.map(l))}return l(o);async function l(m){const[x]=ga(m);if(!x)return;const[v,w]=Hi(r,x),[C,$,y,z]=vt.get(r),_=()=>{const P=C[x];return(lt(s.revalidate)?s.revalidate(v().data,m):s.revalidate!==!1)&&(delete y[x],delete z[x],P&&P[0])?P[0](Vi).then(()=>v().data):v().data};if(t.length<3)return _();let k=n,b,f=!1;const I=Xn();$[x]=[I,0];const j=!je(c),S=v(),R=S.data,E=S._c,T=je(E)?R:E;if(j&&(c=lt(c)?c(T,R):c,w({data:c,_c:T})),lt(k))try{k=k(T)}catch(P){b=P,f=!0}if(k&&Gi(k))if(k=await k.catch(P=>{b=P,f=!0}),I!==$[x][0]){if(f)throw b;return k}else f&&j&&h(b)&&(p=!0,w({data:T,_c:Ge}));if(p&&!f)if(lt(p)){const P=p(k,T);w({data:P,error:Ge,_c:Ge})}else w({data:k,error:Ge,_c:Ge});if($[x][1]=Xn(),Promise.resolve(_()).then(()=>{w({_c:Ge})}),f){if(d)throw b;return}return k}}const Aa=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},gd=(t,r)=>{if(!vt.has(t)){const o=Et(dd,r),n=Object.create(null),a=qi.bind(Ge,t);let s=$t;const p=Object.create(null),g=(d,l)=>{const m=p[d]||[];return p[d]=m,m.push(l),()=>m.splice(m.indexOf(l),1)},c=(d,l,m)=>{t.set(d,l);const x=p[d];if(x)for(const v of x)v(l,m)},h=()=>{if(!vt.has(t)&&(vt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),a,c,g]),!Lr)){const d=o.initFocus(setTimeout.bind(Ge,Aa.bind(Ge,n,Ui))),l=o.initReconnect(setTimeout.bind(Ge,Aa.bind(Ge,n,Wi)));s=()=>{d&&d(),l&&l(),vt.delete(t)}}};return h(),[t,a,h,s]}return[t,vt.get(t)[4]]},md=(t,r,o,n,a)=>{const s=o.errorRetryCount,p=a.retryCount,g=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!je(s)&&p>s||setTimeout(n,g,a)},xd=Gn,[Yi,vd]=gd(new Map),bd=Et({onLoadingSlow:$t,onSuccess:$t,onError:$t,onErrorRetry:md,onDiscarded:$t,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:La?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:La?5e3:3e3,compare:xd,isPaused:()=>!1,cache:Yi,mutate:vd,fallback:{}},ld),yd=(t,r)=>{const o=Et(t,r);if(r){const{use:n,fallback:a}=t,{use:s,fallback:p}=r;n&&s&&(o.use=n.concat(s)),a&&p&&(o.fallback=Et(a,p))}return o},wd=i.createContext({}),jd="$inf$",Zi=Fr&&window.__SWR_DEVTOOLS_USE__,kd=Zi?window.__SWR_DEVTOOLS_USE__:[],_d=()=>{Zi&&(window.__SWR_DEVTOOLS_REACT__=i)},Cd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],Sd=()=>Et(bd,i.useContext(wd)),$d=t=>(r,o,n)=>t(r,o&&((...s)=>{const[p]=ga(r),[,,,g]=vt.get(Yi);if(p.startsWith(jd))return o(...s);const c=g[p];return je(c)?o(...s):(delete g[p],c)}),n),zd=kd.concat($d),Ed=t=>function(...o){const n=Sd(),[a,s,p]=Cd(o),g=yd(n,p);let c=t;const{use:h}=g,d=(h||[]).concat(zd);for(let l=d.length;l--;)c=d[l](c);return c(a,s||g.fetcher||null,g)},Pd=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const a=n.indexOf(o);a>=0&&(n[a]=n[n.length-1],n.pop())}};_d();const pn=i.use||(t=>{switch(t.status){case"pending":throw t;case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t.status="pending",t.then(r=>{t.status="fulfilled",t.value=r},r=>{t.status="rejected",t.reason=r}),t}}),hn={dedupe:!0},Rd=(t,r,o)=>{const{cache:n,compare:a,suspense:s,fallbackData:p,revalidateOnMount:g,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:d,refreshWhenOffline:l,keepPreviousData:m}=o,[x,v,w,C]=vt.get(n),[$,y]=ga(t),z=i.useRef(!1),_=i.useRef(!1),k=i.useRef($),b=i.useRef(r),f=i.useRef(o),I=()=>f.current,j=()=>I().isVisible()&&I().isOnline(),[S,R,E,T]=Hi(n,$),P=i.useRef({}).current,O=je(p)?je(o.fallback)?Ge:o.fallback[$]:p,D=(B,A)=>{for(const W in P){const L=W;if(L==="data"){if(!a(B[L],A[L])&&(!je(B[L])||!a(Z,A[L])))return!1}else if(A[L]!==B[L])return!1}return!0},M=i.useMemo(()=>{const B=!$||!r?!1:je(g)?I().isPaused()||s?!1:c!==!1:g,A=Se=>{const Ne=Et(Se);return delete Ne._k,B?{isValidating:!0,isLoading:!0,...Ne}:Ne},W=S(),L=T(),G=A(W),se=W===L?G:A(L);let me=G;return[()=>{const Se=A(S());return D(Se,me)?(me.data=Se.data,me.isLoading=Se.isLoading,me.isValidating=Se.isValidating,me.error=Se.error,me):(me=Se,Se)},()=>se]},[n,$]),N=rd.useSyncExternalStore(i.useCallback(B=>E($,(A,W)=>{D(W,A)||B()}),[n,$]),M[0],M[1]),F=!z.current,ee=x[$]&&x[$].length>0,ce=N.data,J=je(ce)?O&&Gi(O)?pn(O):O:ce,X=N.error,U=i.useRef(J),Z=m?je(ce)?je(U.current)?J:U.current:ce:J,Q=ee&&!je(X)?!1:F&&!je(g)?g:I().isPaused()?!1:s?je(J)?!1:c:je(J)||c,ne=!!($&&r&&F&&Q),re=je(N.isValidating)?ne:N.isValidating,ie=je(N.isLoading)?ne:N.isLoading,Y=i.useCallback(async B=>{const A=b.current;if(!$||!A||_.current||I().isPaused())return!1;let W,L,G=!0;const se=B||{},me=!w[$]||!se.dedupe,Se=()=>Ma?!_.current&&$===k.current&&z.current:$===k.current,Ne={isValidating:!1,isLoading:!1},H=()=>{R(Ne)},oe=()=>{const be=w[$];be&&be[1]===L&&delete w[$]},ye={isValidating:!0};je(S().data)&&(ye.isLoading=!0);try{if(me&&(R(ye),o.loadingTimeout&&je(S().data)&&setTimeout(()=>{G&&Se()&&I().onLoadingSlow($,o)},o.loadingTimeout),w[$]=[A(y),Xn()]),[W,L]=w[$],W=await W,me&&setTimeout(oe,o.dedupingInterval),!w[$]||w[$][1]!==L)return me&&Se()&&I().onDiscarded($),!1;Ne.error=Ge;const be=v[$];if(!je(be)&&(L<=be[0]||L<=be[1]||be[1]===0))return H(),me&&Se()&&I().onDiscarded($),!1;const te=S().data;Ne.data=a(te,W)?te:W,me&&Se()&&I().onSuccess(W,$,o)}catch(be){oe();const te=I(),{shouldRetryOnError:$e}=te;te.isPaused()||(Ne.error=be,me&&Se()&&(te.onError(be,$,te),($e===!0||lt($e)&&$e(be))&&(!I().revalidateOnFocus||!I().revalidateOnReconnect||j())&&te.onErrorRetry(be,$,te,he=>{const ke=x[$];ke&&ke[0]&&ke[0](Ta,he)},{retryCount:(se.retryCount||0)+1,dedupe:!0})))}return G=!1,H(),!0},[$,n]),ae=i.useCallback((...B)=>qi(n,k.current,...B),[]);if(ln(()=>{b.current=r,f.current=o,je(ce)||(U.current=ce)}),ln(()=>{if(!$)return;const B=Y.bind(Ge,hn);let A=0;I().revalidateOnFocus&&(A=Date.now()+I().focusThrottleInterval);const L=Pd($,x,(G,se={})=>{if(G==Ui){const me=Date.now();I().revalidateOnFocus&&me>A&&j()&&(A=me+I().focusThrottleInterval,B())}else if(G==Wi)I().revalidateOnReconnect&&j()&&B();else{if(G==Vi)return Y();if(G==Ta)return Y(se)}});return _.current=!1,k.current=$,z.current=!0,R({_k:y}),Q&&(w[$]||(je(J)||Lr?B():ud(B))),()=>{_.current=!0,L()}},[$]),ln(()=>{let B;function A(){const L=lt(h)?h(S().data):h;L&&B!==-1&&(B=setTimeout(W,L))}function W(){!S().error&&(d||I().isVisible())&&(l||I().isOnline())?Y(hn).then(A):A()}return A(),()=>{B&&(clearTimeout(B),B=-1)}},[h,d,l,$]),i.useDebugValue(Z),s&&je(J)&&$){if(!Ma&&Lr)throw new Error("Fallback data is required when using Suspense in SSR.");b.current=r,f.current=o,_.current=!1;const B=C[$];if(!je(B)){const A=ae(B);pn(A)}if(je(X)){const A=Y(hn);je(Z)||(A.status="fulfilled",A.value=!0),pn(A)}else throw X}return{mutate:ae,get data(){return P.data=!0,Z},get error(){return P.error=!0,X},get isValidating(){return P.isValidating=!0,re},get isLoading(){return P.isLoading=!0,ie}}},We=Ed(Rd);async function V(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}const r=await t.json();return{data:r.data,errors:r.errors}}function Ki(t){const{client:r}=De(),o=i.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await V(c)).data},[r,t]),{data:n,error:a,mutate:s}=We(t?`sessions-${t}`:null,o,{revalidateOnFocus:!1}),p=i.useCallback(async c=>{const h=new FormData;h.append("title",c.title),c.system_instructions&&h.append("system_instructions",c.system_instructions);const d=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:h}),l=await V(d);return await s(m=>m&&{...m,data:[l.data,...m.data]}),l.data},[r,t,s]),g=i.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await s(h=>h&&{...h,data:h.data.filter(d=>d.id!==c)})},[r,t,s]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!a,error:a,createSession:p,deleteSession:g,refetch:async()=>{await s()}}}const Qi=i.createContext(void 0);function Uo(){const t=i.useContext(Qi);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Id({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:a,onSessionCreated:s,onSessionDeleted:p,onError:g}){const[c,h]=i.useState(a?{id:a,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[d,l]=i.useState(!1),{sessions:m,loading:x,error:v,createSession:w,deleteSession:C,refetch:$}=Ki(o);i.useEffect(()=>{if(a&&m.length>0){const b=m.find(f=>f.id===a);b&&h(b)}},[a,m]);const y=i.useCallback(b=>{h(b),l(!1)},[]),z=i.useCallback(async b=>{try{const f=b||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,I=await w({title:f});return h(I),s==null||s(I),I}catch(f){const I=f instanceof Error?f.message:"Failed to create session";throw g==null||g(I),f}},[w,s,g]),_=i.useCallback(async b=>{try{await C(b),(c==null?void 0:c.id)===b&&h(null),p==null||p(b)}catch(f){const I=f instanceof Error?f.message:"Failed to delete session";throw g==null||g(I),f}},[C,c,p,g]),k={agentName:r,token:o,platformAdapter:n,sessions:m,selectedSession:c,loadingSessions:x,sessionError:v,selectSession:y,createSession:z,deleteSession:_,refreshSessions:$,showHistory:d,setShowHistory:l,onSessionCreated:s,onSessionDeleted:p,onError:g};return e.jsx(Qi.Provider,{value:k,children:t})}var Xi=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(Xi||{});function Td(t,r,o){const n={username:Od(t,r,o),email:Md(t,r,o),phone:Ld(t,r,o),email_otp:Ad(t,r,o),magic_link:Dd(t,r,o),oauth:Nd(t,o),generic:Fd(t,r,o)};return function(s){return n[s]}}function Od(t,r,o){return async({username:n,password:a})=>{var c,h;const s=new FormData;s.append("strategy","plain_username"),s.append("username",n),s.append("password",a);const p=await t("/auth/signin",{method:"POST",body:s}),g=await V(p);return"data"in g&&((h=(c=g.data)==null?void 0:c.signin_attempts)!=null&&h.length)?(r(g.data.signin_attempts.at(-1)||null),o(null)):o(g),g}}function Md(t,r,o){return async({email:n,password:a})=>{var c,h;const s=new FormData;s.append("strategy","plain_email"),s.append("email",n),s.append("password",a);const p=await t("/auth/signin",{method:"POST",body:s}),g=await V(p);return"data"in g&&((h=(c=g.data)==null?void 0:c.signin_attempts)!=null&&h.length)?(r(g.data.signin_attempts.at(-1)||null),o(null)):o(g),g}}function Ld(t,r,o){return async({phone:n})=>{var g,c;const a=new FormData;a.append("strategy","phone_otp"),a.append("phone",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await V(s);return"data"in p&&((c=(g=p.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(p.data.signin_attempts.at(-1)||null),o(null)):o(p),p}}function Ad(t,r,o){return async({email:n})=>{var g,c;const a=new FormData;a.append("strategy","email_otp"),a.append("email",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await V(s);return"data"in p&&((c=(g=p.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(p.data.signin_attempts.at(-1)||null),o(null)):o(p),p}}function Dd(t,r,o){return async({email:n})=>{var g,c;const a=new FormData;a.append("strategy","magic_link"),a.append("email",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await V(s);return"data"in p&&((c=(g=p.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(p.data.signin_attempts.at(-1)||null),o(null)):o(p),p}}function Nd(t,r){return async({provider:o,redirectUri:n})=>{const a=new URLSearchParams({provider:o});n&&a.append("redirect_uri",n);const s=await t(`/auth/oauth2/init?${a.toString()}`,{method:"POST"}),p=await V(s);return"data"in p?(r(null),p.data.oauth_url&&(window.location.href=p.data.oauth_url)):r(p),p}}function Fd(t,r,o){return async({email:n,username:a,password:s,phone:p,strategy:g,token:c})=>{var m,x;const h=new FormData;g&&h.append("strategy",g),n&&h.append("email",n),a&&h.append("username",a),s&&h.append("password",s),p&&h.append("phone",p),c&&h.append("token",c);const d=await t("/auth/signin",{method:"POST",body:h}),l=await V(d);return"data"in l&&((x=(m=l.data)==null?void 0:m.signin_attempts)!=null&&x.length)?(r(l.data.signin_attempts.at(-1)||null),o(null)):o(l),l}}function Ji(){const{client:t,loading:r}=De(),[o,n]=i.useState(null),[a,s]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null),s(null)},setSignInAttempt:n,error:null}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Td(t,n,s),completeVerification:async p=>{var d,l,m,x;const g=new FormData;g.append("verification_code",p);const c=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:g}),h=await V(c);if("data"in h&&((l=(d=h.data)==null?void 0:d.signin_attempts)!=null&&l.length)){const v=h.data.signin_attempts.at(-1);return n(v||null),s(null),h.data}else throw"errors"in h?(s(h),new Error(((x=(m=h.errors)==null?void 0:m[0])==null?void 0:x.message)||"Verification failed")):new Error("Verification failed")},prepareVerification:async p=>{var h;const g=new URL("/auth/prepare-verification",window.location.origin);g.searchParams.set("attempt_identifier",((h=o==null?void 0:o.id)==null?void 0:h.toString())||""),g.searchParams.set("strategy",p.strategy),g.searchParams.set("identifier_type","signin"),p.strategy==="phone_otp"&&p.lastDigits?g.searchParams.set("last_digits",p.lastDigits):(p.strategy==="email_otp"&&p.redirectUri||p.strategy==="magic_link"&&p.redirectUri)&&g.searchParams.set("redirect_uri",p.redirectUri);const c=await t(g.pathname+g.search,{method:"POST"});return V(c)},completeProfile:async p=>{var d;if(!o)throw new Error("No signin attempt found");const g=new FormData;for(const[l,m]of Object.entries(p))m&&g.append(l,m);const c=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:g}),h=await V(c);if("data"in h&&h.data){const l=(d=h.data.signin_attempts)==null?void 0:d.find(m=>m.id===o.id);return l&&n(l),s(null),h.data}else throw new Error("Profile completion failed")}},discardSignInAttempt:()=>{n(null),s(null)},setSignInAttempt:n,error:a}}function Ar(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:a,setSignInAttempt:s,error:p}=Ji();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:a,setSignInAttempt:s,error:null};const g=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:g,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile},discardSignInAttempt:a,setSignInAttempt:s,error:p}}function Bd(t,r,o,n){return{create:async a=>{var c,h,d;const s=new FormData;for(const[l,m]of Object.entries(a))s.append(l,m);const p=await t("/auth/signup",{method:"POST",body:s}),g=await V(p);return"data"in g&&((h=(c=g.data)==null?void 0:c.signup_attempts)!=null&&h.length)?(o(((d=g.data.signup_attempts)==null?void 0:d.at(-1))||null),n(null)):n(g),g},prepareVerification:async a=>{var g;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((g=r==null?void 0:r.id)==null?void 0:g.toString())||""),s.searchParams.set("strategy",a.strategy),s.searchParams.set("identifier_type","signup"),a.strategy==="phone_otp"&&a.lastDigits?s.searchParams.set("last_digits",a.lastDigits):a.strategy==="email_otp"&&a.redirectUri&&s.searchParams.set("redirect_uri",a.redirectUri);const p=await t(s.pathname+s.search,{method:"POST"});return V(p)},completeVerification:async a=>{var c,h,d,l;const s=new FormData;s.append("verification_code",a);const p=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),g=await V(p);if("data"in g&&((h=(c=g.data)==null?void 0:c.signup_attempts)!=null&&h.length))o(g.data.signup_attempts.at(-1)||null),n(null);else if("errors"in g)throw n(g),new Error(((l=(d=g.errors)==null?void 0:d[0])==null?void 0:l.message)||"Verification failed");return g},validateDeploymentInvitation:async a=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(a)}`,{method:"GET"}),p=await V(s);return"data"in p&&p.data?p.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(s){return{valid:!1,message:s.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function ec(){const{client:t,loading:r}=De(),[o,n]=i.useState(null),[a,s]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null),s(null)},errors:null}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null),s(null)},signUp:Bd(t,o,n,s),errors:a}}const He=()=>{const{adapter:t,deployment:r}=ve(),o=t.useNavigate(),n=(p,g)=>{o?o(p,g):window.location.href=p};return{navigate:n,navigateToSignIn:p=>{if(!r)return;const g=p||window.location.href,c=new URLSearchParams;c.set("redirect_uri",g),(r==null?void 0:r.mode)==="staging"&&c.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${c.toString()}`,{replace:!0})},navigateToSignUp:p=>{if(!r)return;const g=p||window.location.href,c=new URLSearchParams;c.set("redirect_uri",g),(r==null?void 0:r.mode)==="staging"&&c.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${c.toString()}`,{replace:!0})}}};async function Ud(t){const r=await t("/session",{method:"GET"});return(await V(r)).data}async function Wd(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return V(o)}async function Vd(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return V(n)}async function Gd(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return V(o)}async function Hd(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return V(o)}const Jn=new Map,Ir=new Map;function Qt(){Jn.clear(),Ir.clear()}async function qd(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return V(o)}function Fe(){const{client:t,loading:r}=De(),{deployment:o}=ve(),{navigate:n}=He(),{data:a,error:s,mutate:p,isLoading:g}=We(r?null:"/session",()=>Ud(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),c=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]),h=i.useCallback(async(l="default")=>{var v;if(!a)throw new Error("no session");const m=Jn.get(l);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";Ir.get(l)||Ir.set(l,qd(t,l));const x=await Ir.get(l);if(Ir.delete(l),(v=x.errors)!=null&&v.length)throw new Error(x.errors[0].message);return Jn.set(l,x.data),x.data.token},[t,a==null?void 0:a.active_signin]),d=i.useCallback(()=>{if(!o)return;const l=o.ui_settings.sign_in_page_url,m=window.location.href,x=new URL(l);if(x.searchParams.set("redirect_uri",m),o.mode==="staging"){const v=localStorage.getItem("__dev_session__");v&&x.searchParams.set("dev_session",v)}n(x.toString())},[o,n]);return r||!a||g?{loading:!0,error:s,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,addNewAccount:null,refetch:c}:{loading:g,error:s,session:a,switchSignIn:async l=>{await Wd(t,l),await p(void 0,{revalidate:!0})},signOut:async l=>{await Vd(t,l),await p(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(l&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!l&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async l=>{await Gd(t,l),Qt(),await p(void 0,{revalidate:!0})},switchWorkspace:async l=>{await Hd(t,l),Qt(),await p(void 0,{revalidate:!0})},getToken:h,addNewAccount:d,refetch:c}}const Wo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=bt(),{client:n}=De(),{refetch:a}=Fe(),s=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/roles`,{method:"GET"}))).data,[n]),p=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/members`,{method:"GET"}))).data,[n]),g=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/domains`,{method:"GET"}))).data,[n]),h=i.useCallback(async(j,S)=>{await n(`/organizations/${j.id}/members/${S.id}/remove`,{method:"POST"}),await r()},[r,n]),d=i.useCallback(async j=>{const S=new FormData;S.append("name",j.name),j.image&&S.append("image",j.image),j.description&&S.append("description",j.description);const R=await V(await n("/organizations",{method:"POST",body:S}));return Qt(),await r(),await a(),R},[a,r,n]),l=i.useCallback(async(j,S)=>{const R=Object.entries(S).reduce((T,[P,O])=>(O&&T.append(P,O),T),new FormData),E=await V(await n(`/organizations/${j.id}/update`,{method:"POST",body:R}));return await r(),E},[r,n]),m=i.useCallback(async(j,S)=>{await n(`/organizations/${j.id}/roles/${S.id}/remove`,{method:"POST"})},[n]),x=i.useCallback(async(j,S)=>{const R=new FormData;return R.append("domain",S.fqdn),await V(await n(`/organizations/${j.id}/domains`,{method:"POST",body:R}))},[n]),v=i.useCallback(async(j,S)=>await V(await n(`/organizations/${j.id}/domains/${S.id}/verify`,{method:"POST"})),[n]),w=i.useCallback(async(j,S)=>await V(await n(`/organizations/${j.id}/domains/${S.id}/remove`,{method:"POST"})),[n]),C=i.useCallback(async(j,S)=>{const R=new FormData;return R.append("name",S.name),S.permissions&&S.permissions.forEach((T,P)=>{R.append(`permissions[${P}]`,T)}),await V(await n(`/organizations/${j.id}/roles`,{method:"POST",body:R}))},[n]),$=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/leave`,{method:"POST"}))).data,[n]),y=i.useCallback(async j=>{const S=await V(await n(`/organizations/${j.id}/delete`,{method:"POST"}));return Qt(),await r(),await a(),S.data},[n,r,a]),z=i.useCallback(async(j,S,R)=>(await V(await n(`/organizations/${j.id}/members/${S.id}/roles/${R.id}/add`,{method:"POST"}))).data,[n]),_=i.useCallback(async(j,S,R)=>(await V(await n(`/organizations/${j.id}/members/${S.id}/roles/${R.id}/remove`,{method:"POST"}))).data,[n]),k=i.useCallback(async(j,S)=>{var T,P;const R=new FormData;return R.append("email",S.email),R.append("role_id",S.organizationRole.id),(T=S.workspace)!=null&&T.id&&R.append("workspace_id",S.workspace.id),(P=S.workspaceRole)!=null&&P.id&&R.append("workspace_role_id",S.workspaceRole.id),(await V(await n(`/organizations/${j.id}/invitations`,{method:"POST",body:R}))).data},[n]),b=i.useCallback(async(j,S)=>(await V(await n(`/organizations/${j.id}/invitations/${S.id}/remove`,{method:"POST"}))).data,[n]),f=i.useCallback(async(j,S)=>(await V(await n(`/organizations/${j.id}/invitations/${S.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(j=>j.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:$,getOrganizationRoles:s,getOrganizationMembers:p,removeOrganizationMember:h,createOrganization:d,getOrganizationInvitations:g,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:w,addRoleToOrganizationMember:z,removeRoleFromOrganizationMember:_,inviteOrganizationMember:k,discardOrganizationInvitation:b,resendOrganizationInvitation:f,updateOrganization:l,addRole:C,removeOrganizationRoles:m,deleteOrganization:y}},Qe=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:a,leaveOrganization:s,removeOrganizationMember:p,getOrganizationInvitations:g,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:d,verifyOrganizationDomain:l,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:w,resendOrganizationInvitation:C,updateOrganization:$,removeOrganizationRoles:y}=Wo(),{session:z,error:_,loading:k}=Fe(),{organizationMemberships:b}=bt(),f=i.useMemo(()=>{var U;return((U=b==null?void 0:b.find(Z=>{var Q;return Z.id===((Q=z==null?void 0:z.active_signin)==null?void 0:Q.active_organization_membership_id)}))==null?void 0:U.organization)||null},[b,z]),I=i.useCallback(async U=>f?await $(f,U):[],[f,$]),j=i.useCallback(async()=>f?await n(f):[],[f,n]),S=i.useCallback(async()=>f?await a(f):[],[f,a]),R=i.useCallback(async U=>f?await p(f,U):[],[f,p]),E=i.useCallback(async U=>f?await y(f,U):void 0,[f,y]),T=i.useCallback(async()=>f?await c(f):[],[f,c]),P=i.useCallback(async U=>f?await d(f,U):void 0,[f,d]),O=i.useCallback(async U=>f?await l(f,U):void 0,[f,l]),D=i.useCallback(async U=>f?await h(f,U):void 0,[f,h]),M=i.useCallback(async(U,Z)=>f?await m(f,U,Z):void 0,[f,m]),N=i.useCallback(async(U,Z)=>f?await x(f,U,Z):void 0,[f,x]),F=i.useCallback(async U=>f?await v(f,U):void 0,[f,v]),ee=i.useCallback(async U=>f?await w(f,U):void 0,[f,w]),ce=i.useCallback(async U=>f?await C(f,U):void 0,[f,C]),J=i.useCallback(async()=>{f&&await s(f)},[f,s]),X=i.useCallback(async()=>f?await g(f):[],[f,g]);return k||t?{activeOrganization:null,loading:!0,error:_||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null}:{activeOrganization:f,loading:!1,refetch:o,getRoles:S,updateOrganization:I,getMembers:j,getDomains:T,addDomain:P,verifyDomain:O,removeDomain:D,getInvitations:X,removeMember:R,leave:J,removeRole:E,addMemberRole:M,removeMemberRole:N,inviteMember:F,discardInvitation:ee,resendInvitation:ce,error:null}};async function Yd(t){return(await V(await t("/me/organization-memberships"))).data}const bt=()=>{const{client:t,loading:r}=De(),{data:o,isLoading:n,error:a,mutate:s}=We(r?null:"/me/organization-memberships",()=>Yd(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),p=i.useCallback(async()=>{await s(void 0,{revalidate:!0})},[s]);return{organizationMemberships:o,loading:r||n,error:a,refetch:p}};async function Zd(t){return(await V(await t("/me/workspace-memberships"))).data}async function Kd(t,r,o){return(await V(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Vo=()=>{const{client:t,loading:r}=De(),{deployment:o}=ve(),{data:n,isLoading:a,error:s,mutate:p}=We(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>Zd(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),g=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]);return{workspaceMemberships:n,loading:r||a,error:s,refetch:g}},yt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Vo(),{client:a}=De(),s=i.useMemo(()=>t==null?void 0:t.map(y=>({...y.workspace,organization:y.organization,eligibility_restriction:y.eligibility_restriction})),[t]),p=i.useCallback(async(y,z,_,k)=>{const b=new FormData;b.append("name",z),_&&b.append("image",_),k&&b.append("description",k),b.append("organization_id",y);const f=await a("/workspaces",{method:"POST",body:b});return Qt(),await r(),f},[a,r]),g=i.useCallback(async(y,z)=>{const _=await Kd(a,y,z);return await r(),_},[a,r]),c=i.useCallback(async(y,z)=>{const _=new FormData;z.name&&_.append("name",z.name),z.description&&_.append("description",z.description),z.image&&_.append("image",z.image);const k=await V(await a(`/workspaces/${y.id}/update`,{method:"POST",body:_}));return await r(),k.data},[a,r]),h=i.useCallback(async y=>{const z=await V(await a(`/workspaces/${y.id}/delete`,{method:"POST"}));return Qt(),await r(),z.data},[a,r]),d=i.useCallback(async y=>(await V(await a(`/workspaces/${y.id}/members`,{method:"GET"}))).data,[a]),l=i.useCallback(async y=>(await V(await a(`/workspaces/${y.id}/roles`,{method:"GET"}))).data,[a]),m=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/roles`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z,permissions:_})}))).data,[a]),x=i.useCallback(async(y,z)=>(await V(await a(`/workspaces/${y.id}/roles/${z.id}/delete`,{method:"POST"}))).data,[a]),v=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:z,role_id:_})}))).data,[a]),w=i.useCallback(async(y,z)=>{const _=await V(await a(`/workspaces/${y.id}/members/${z}/remove`,{method:"POST"}));return await r(),_.data},[a,r]),C=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/members/${z}/roles/${_}`,{method:"POST"}))).data,[a]),$=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/members/${z}/roles/${_}/remove`,{method:"POST"}))).data,[a]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:g,createWorkspace:p,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:d,getWorkspaceRoles:l,createWorkspaceRole:m,deleteWorkspaceRole:x,inviteWorkspaceMember:v,removeWorkspaceMember:w,addWorkspaceMemberRole:C,removeWorkspaceMemberRole:$}},Pt=()=>{const{refetch:t,loading:r,error:o,leaveWorkspace:n,updateWorkspace:a,deleteWorkspace:s,getWorkspaceMembers:p,getWorkspaceRoles:g,createWorkspaceRole:c,deleteWorkspaceRole:h,inviteWorkspaceMember:d,removeWorkspaceMember:l,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x}=yt(),{workspaceMemberships:v}=Vo(),{session:w,loading:C,error:$}=Fe(),y=i.useMemo(()=>{var D;return((D=v==null?void 0:v.find(M=>{var N;return M.id===((N=w==null?void 0:w.active_signin)==null?void 0:N.active_workspace_membership_id)}))==null?void 0:D.workspace)||null},[v,w]),z=i.useCallback(async()=>{var D;if(!(!y||!((D=w==null?void 0:w.active_signin)!=null&&D.user_id)))return await n(y.id,w.active_signin.user_id)},[y,n,w]),_=i.useCallback(async D=>{if(y)return await a(y,D)},[y,a]),k=i.useCallback(async()=>{if(y)return await s(y)},[y,s]),b=i.useCallback(async()=>y?await p(y):[],[y,p]),f=i.useCallback(async()=>y?await g(y):[],[y,g]),I=i.useCallback(async(D,M)=>{if(y)return await c(y,D,M)},[y,c]),j=i.useCallback(async D=>{if(y)return await h(y,D)},[y,h]),S=i.useCallback(async(D,M)=>{if(y)return await d(y,D,M)},[y,d]),R=i.useCallback(async D=>{if(y)return await l(y,D)},[y,l]),E=i.useCallback(async(D,M)=>{if(y)return await m(y,D,M)},[y,m]),T=i.useCallback(async(D,M)=>{if(y)return await x(y,D,M)},[y,x]),P=r||C,O=o||$;return P?{activeWorkspace:null,loading:!0,error:O,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null}:{activeWorkspace:y,loading:!1,error:O,refetch:t,leave:z,updateWorkspace:_,deleteWorkspace:k,getMembers:b,getRoles:f,createRole:I,deleteRole:j,inviteMember:S,removeMember:R,addMemberRole:E,removeMemberRole:T}},Qd=async t=>(await V(await t("/me"))).data,Xd=async t=>(await V(await t("/me/signins"))).data;function rr(){const{client:t,loading:r}=De(),{data:o,error:n,isLoading:a,mutate:s}=We(r?null:"/user",()=>Qd(t)),p=async P=>{const O=new FormData;for(const[M,N]of Object.entries(P))N!=null&&N!==""&&O.append(M,String(N));const D=await V(await t("/me",{method:"POST",body:O}));return s(),D},g=async()=>await V(await t("/me/email-addresses",{method:"GET"})),c=async P=>await V(await t(`/me/email-addresses/${P}`,{method:"GET"})),h=async P=>{const O=new FormData;return O.append("email",P),await V(await t("/me/email-addresses",{method:"POST",body:O}))},d=async P=>await V(await t(`/me/email-addresses/${P}/delete`,{method:"POST"})),l=async P=>await V(await t(`/me/email-addresses/${P}/prepare-verification`,{method:"POST"})),m=async(P,O)=>await V(await t(`/me/email-addresses/${P}/attempt-verification?code=${O}`,{method:"POST"})),x=async(P,O)=>{const D=new FormData;return D.append("phone_number",P),D.append("country_code",O),await V(await t("/me/phone-numbers",{method:"POST",body:D}))},v=async P=>await V(await t(`/me/phone-numbers/${P}/delete`,{method:"POST"})),w=async P=>await V(await t(`/me/phone-numbers/${P}/prepare-verification`,{method:"POST"})),C=async(P,O)=>{const D=new FormData;return D.append("code",O),await V(await t(`/me/phone-numbers/${P}/attempt-verification`,{method:"POST",body:D}))},$=async P=>{const O=await V(await t(`/me/phone-numbers/${P}/make-primary`,{method:"POST"}));return s(),O},y=async P=>await V(await t(`/me/email-addresses/${P}/make-primary`,{method:"POST"})),z=async()=>(await V(await t("/me/authenticator",{method:"POST"}))).data,_=async(P,O)=>{const D=new FormData;return D.append("authenticator_id",P),O.forEach(N=>{D.append("codes",N)}),await V(await t("/me/authenticator/attempt-verification",{method:"POST",body:D}))},k=async P=>await V(await t(`/me/authenticator/${P}/delete`,{method:"POST"})),b=async()=>(await V(await t("/me/backup-codes",{method:"POST"}))).data,f=async P=>{const O=new FormData;return O.append("file",P),await V(await t("/me/profile-picture",{method:"POST",body:O}))},I=async()=>(await V(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,j=async(P,O)=>{const D=new FormData;return D.append("current_password",P),D.append("new_password",O),await V(await t("/me/update-password",{method:"POST",body:D}))},S=async P=>{const O=new FormData;O.append("current_password",P);const D=await V(await t("/me/remove-password",{method:"POST",body:O}));return s(),D},R=async P=>{const O=new FormData;return O.append("password",P),await V(await t("/me/account/delete",{method:"POST",body:O}))},E=async P=>await V(await t(`/me/social-connections/${P}/disconnect`,{method:"POST"})),T=async({provider:P,redirectUri:O})=>{var N;const D=new URLSearchParams({provider:P});O&&D.append("redirect_uri",O);const M=await V(await t(`/me/init-sso-connection?${D.toString()}`,{method:"POST"}));return"data"in M&&((N=M.data)!=null&&N.oauth_url)&&window.open(M.data.oauth_url,"_blank"),M};return{user:{...o,refetch:s},loading:r||a,error:n||null,updateProfile:p,getEmailAddresses:g,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:d,prepareEmailVerification:l,attemptEmailVerification:m,makeEmailPrimary:y,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:w,attemptPhoneVerification:C,makePhonePrimary:$,setupAuthenticator:z,verifyAuthenticator:_,deleteAuthenticator:k,generateBackupCodes:b,regenerateBackupCodes:I,updateProfilePicture:f,disconnectSocialConnection:E,connectSocialAccount:T,updatePassword:j,removePassword:S,deleteAccount:R}}function tc(){const{client:t,loading:r}=De(),{data:o,error:n,isLoading:a,mutate:s}=We(r?null:"/me/signins",()=>Xd(t));return{signins:o,error:n||null,removeSignin:async g=>await V(await t(`/me/signins/${g}/signout`,{method:"POST"})),refetch:s,loading:a||r}}function Jd(){const{session:t,loading:r}=Fe(),{loading:o,organizationMemberships:n}=bt(),{loading:a,workspaceMemberships:s}=Vo();if(r||o||a)return{loading:!0,orgMembership:null,workspaceMembership:null};const p=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_organization_membership_id)}),[t]),g=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:p,workspaceMembership:g}}function rc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),p=async g=>{n(!0),s(null);try{const c=new FormData;for(const[l,m]of Object.entries(g))m&&c.append(l,m);const h=await t("/waitlist/join",{method:"POST",body:c}),d=await V(h);return s(d.errors?d:null),d}catch(c){const h={data:null,errors:[{message:c instanceof Error?c.message:"Failed to join waitlist",code:Ve.ErrorCode.Unknown}]};return s(h),h}finally{n(!1)}};return r?{loading:!0,error:null,joinWaitlist:null}:{loading:o,error:a,joinWaitlist:p}}function oc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[p,g]=i.useState(null),[c,h]=i.useState(null),[d,l]=i.useState(!1),[m,x]=i.useState(null);i.useEffect(()=>{if(d||r)return;const w=new URLSearchParams(window.location.search),C=w.get("code"),$=w.get("state"),y=w.get("error"),z=w.get("error_description");if(!C&&!y){l(!0);const _=new Error("No OAuth callback data found.");s(_);return}if(l(!0),n(!0),y){const _=z||y,k=new Error(`OAuth Error: ${_}`);s(k),n(!1);return}if(C&&$)v(C,$);else{const _=new Error("Missing required OAuth parameters");s(_),n(!1)}},[d,r]);const v=async(w,C)=>{try{let $,y;try{const k=C.split(".");if(k.length!==2)throw new Error("Invalid OAuth state format - missing signature");const b=k[0].replace(/-/g,"+").replace(/_/g,"/"),f=b.length%4?"=".repeat(4-b.length%4):"",j=atob(b+f).split("|")[0];if(j==="sign_in")$="/auth/oauth2/callback",y="GET";else if(j==="connect_social")$="/me/sso-connection-callback",y="POST";else throw new Error(`Unknown OAuth action: ${j}`)}catch(k){const b=k instanceof Error?k:new Error("Failed to parse OAuth state");s(new Error(`Invalid OAuth callback: ${b.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const z=await t(`${$}?code=${encodeURIComponent(w)}&state=${encodeURIComponent(C)}`,{method:y}),_=await V(z);if("data"in _){const k=_.data.session,b=_.data.redirect_uri||null;if(g(k),h(b),k.signin_attempts&&k.signin_attempts.length>0){const f=k.signin_attempts.at(-1);f&&x(f)}}else{const k=new Error("SSO callback failed");s(k)}}catch($){const y=$ instanceof Error?$:new Error("Unknown error occurred");s(y)}finally{n(!1)}};return{loading:o,error:a,session:p,redirectUri:c,processed:d,signinAttempt:m}}function nc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[p,g]=i.useState(null);return{loading:r||o,verifyMagicLink:async h=>{if(!h.token||!h.attempt){const d=new Error("Invalid magic link parameters");return s(d),{data:void 0,errors:[{message:d.message,code:Ve.ErrorCode.BadRequestBody}]}}n(!0),s(null),g(null);try{const d=new URL("/auth/verify-magic-link",window.location.origin);d.searchParams.set("token",h.token),d.searchParams.set("attempt",h.attempt),h.redirectUri&&d.searchParams.set("redirect_uri",h.redirectUri);const l=await t(d.pathname+d.search,{method:"GET"}),m=await V(l);if(n(!1),"errors"in m&&m.errors){const x=new Error(m.errors[0].message);s(x),g(!1)}else g(!0);return m}catch(d){n(!1);const l=d instanceof Error?d:new Error("Magic link verification failed");return s(l),g(!1),{data:void 0,errors:[{message:l.message,code:Ve.ErrorCode.Internal}]}}},error:a,success:p}}function ac(){const[t,r]=i.useState({});return i.useEffect(()=>{const o=new URLSearchParams(window.location.search);r({token:o.get("token")||void 0,attempt:o.get("attempt")||void 0,redirectUri:o.get("redirect_uri")||void 0})},[]),t}function sc(){const{client:t,loading:r}=De(),[o,n]=i.useState(null);return{error:o,loading:r,forgotPassword:async g=>{n(null);const c=new FormData;c.append("email",g);const h=await t("/auth/forgot-password",{method:"POST",body:c}),d=await V(h);return"errors"in d&&d.errors&&n(new Error(d.errors[0].message)),d},verifyOtp:async(g,c)=>{n(null);const h=new FormData;h.append("email",g),h.append("otp",c);const d=await t("/auth/forgot-password",{method:"POST",body:h}),l=await V(d);return"errors"in l&&l.errors&&n(new Error(l.errors[0].message)),l},resetPassword:async(g,c)=>{n(null);const h=new FormData;h.append("token",g),h.append("password",c);const d=await t("/auth/reset-password",{method:"POST",body:h}),l=await V(d);return"errors"in l&&l.errors&&n(new Error(l.errors[0].message)),l}}}function ic({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:a,onError:s,reconnectDelay:p=1e3,maxReconnectAttempts:g=5}={}){const{session:c,loading:h}=Fe(),{deployment:d,loading:l}=ve(),[m,x]=i.useState(!1),[v,w]=i.useState(null),C=i.useRef(null),$=i.useRef(null),y=i.useRef(0),z=i.useRef(null),_=i.useRef(a),k=i.useRef(s),b=i.useRef(r),f=i.useRef(o),I=i.useRef(n),j=i.useRef(p),S=i.useRef(g);_.current=a,k.current=s,b.current=r,f.current=o,I.current=n,j.current=p,S.current=g;const R=i.useCallback(()=>{$.current&&(clearTimeout($.current),$.current=null),z.current&&(clearInterval(z.current),z.current=null),C.current&&(C.current.close(),C.current=null)},[]),E=i.useCallback(async()=>{var N;if(!t||h||l||!c||!d)return;R();const O=new URL(d.backend_host),D=O.protocol==="https:"?"wss:":"ws:",M=new URL("/realtime/notifications",`${D}//${O.host}`);if(d.mode==="staging"){const F=localStorage.getItem("__dev_session__");F&&M.searchParams.set("__dev_session__",F)}b.current&&b.current.length>0&&b.current.forEach(F=>M.searchParams.append("channels",F)),f.current&&f.current.length>0&&f.current.forEach(F=>M.searchParams.append("organization_ids",F.toString())),I.current&&I.current.length>0&&I.current.forEach(F=>M.searchParams.append("workspace_ids",F.toString()));try{const F=new WebSocket(M.toString());C.current=F,F.onopen=()=>{x(!0),w(null),y.current=0,z.current=setInterval(()=>{F.readyState===WebSocket.OPEN&&F.send("ping")},3e4)},F.onmessage=ee=>{var ce,J;try{const X=JSON.parse(ee.data);if(X.type==="notification"&&X.data)(ce=_.current)==null||ce.call(_,X.data);else if(X.type==="error"){const U=X.error||"Unknown error occurred";w(U),(J=k.current)==null||J.call(k,U)}else X.type}catch{}},F.onerror=()=>{var ee;w("Connection error occurred"),(ee=k.current)==null||ee.call(k,"Connection error occurred")},F.onclose=ee=>{var ce;if(x(!1),z.current&&(clearInterval(z.current),z.current=null),t&&ee.code!==1e3&&y.current<S.current){y.current++;const J=j.current*Math.pow(2,y.current-1);$.current=setTimeout(()=>{E()},J)}else y.current>=S.current&&(w("Max reconnection attempts reached"),(ce=k.current)==null||ce.call(k,"Max reconnection attempts reached"))}}catch{w("Failed to connect"),(N=k.current)==null||N.call(k,"Failed to connect")}},[t,h,l,c,d,R]);i.useEffect(()=>(E(),()=>{R()}),[E,R]),i.useEffect(()=>{C.current&&C.current.readyState===WebSocket.OPEN&&E()},[r,o,n,E]);const T=i.useCallback(()=>{R(),x(!1)},[R]),P=i.useCallback(()=>{y.current=0,E()},[E]);return{isConnected:m,connectionError:v,disconnect:T,reconnect:P}}async function eu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(p=>o.append("channels",p)),r.organization_ids&&r.organization_ids.forEach(p=>o.append("organization_ids",p.toString())),r.workspace_ids&&r.workspace_ids.forEach(p=>o.append("workspace_ids",p.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,a=await t(n,{method:"GET"});return(await V(a)).data}async function tu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await V(r)).data}async function ru(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return V(o)}async function ou(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return V(r)}async function nu(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return V(o)}function cc(t){const{client:r,loading:o}=De(),{data:n,error:a,mutate:s,isLoading:p}=We(o?null:["notifications",JSON.stringify(t)],()=>eu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});ic({enabled:!o&&!!n,onNotification:i.useCallback(l=>{s(async m=>!m||m.notifications.some(v=>v.id===l.id.toString())?m:{...m,notifications:[{id:l.id.toString(),user_id:l.user_id.toString(),deployment_id:l.deployment_id.toString(),title:l.title,body:l.body,severity:l.severity,action_url:l.action_url,action_label:l.action_label,is_read:!1,is_archived:!1,created_at:l.created_at,updated_at:l.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[s]),onError:i.useCallback(()=>{},[])});const g=i.useCallback(async l=>{o||(await s(async m=>m&&{...m,notifications:m.notifications.map(x=>x.id===l?{...x,is_read:!0}:x),unread_count:Math.max(0,m.unread_count-1)},!1),await ru(r,l),await s())},[r,o,s]),c=i.useCallback(async()=>{o||(await s(async l=>l&&{...l,notifications:l.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await ou(r),await s())},[r,s]),h=i.useCallback(async l=>{o||(await s(async m=>{if(!m)return m;const x=m.notifications.find(v=>v.id===l);return{...m,notifications:m.notifications.filter(v=>v.id!==l),unread_count:x&&!x.is_read?Math.max(0,m.unread_count-1):m.unread_count,total:Math.max(0,m.total-1)}},!1),await nu(r,l),await s())},[r,o,s]),d=i.useCallback(async()=>{await s()},[s]);return!n||o||p?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:a,refetch:d}:{loading:!1,error:a,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:g,markAllAsRead:c,deleteNotification:h,refetch:d}}async function au(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await V(r)).data}function su(){const{client:t,loading:r}=De(),{data:o,error:n,mutate:a}=We(r?null:["notifications","channel-counts"],()=>au(t),{refreshInterval:3e4,revalidateOnFocus:!0}),s=async()=>{await a()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:s}:{loading:!1,counts:o,error:n,refetch:s}}const Gt=class Gt{constructor(){Xe(this,"ws",null);Xe(this,"messageHandlers",new Set);Xe(this,"connectionStateHandlers",new Set);Xe(this,"reconnectTimer",null);Xe(this,"reconnectAttempts",0);Xe(this,"url",null);Xe(this,"isIntentionalDisconnect",!1);Xe(this,"sessionMessages",{});Xe(this,"currentSessionKey",null)}static getInstance(){return Gt.instance||(Gt.instance=new Gt),Gt.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};Xe(Gt,"instance");let ea=Gt;const Ye=ea.getInstance(),xt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Me={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Tt={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Da(t){switch(t){case Tt.IDLE:return Me.IDLE;case Tt.STARTING:return Me.STARTING;case Tt.RUNNING:return Me.RUNNING;case Tt.WAITING_FOR_INPUT:return Me.WAITING_FOR_INPUT;case Tt.COMPLETED:return Me.COMPLETED;case Tt.FAILED:case Tt.CANCELLED:return Me.FAILED;default:return Me.IDLE}}function Na(t){return t===Me.STARTING||t===Me.RUNNING||t===Me.WAITING_FOR_INPUT}function lc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:a=!0}){const{deployment:s}=ve(),{client:p}=De(),[g,c]=i.useState([]),[h,d]=i.useState(null),[l,m]=i.useState(null),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState(Me.IDLE),[z,_]=i.useState({status:xt.DISCONNECTED}),[k,b]=i.useState(!0),[f,I]=i.useState(!1),j=i.useRef(null),S=i.useRef(null),R=i.useCallback(X=>{var U,Z;switch(X.message_type){case"session_connected":if(v(!0),_({status:xt.CONNECTED}),(U=X.data)!=null&&U.execution_status){const ne=X.data.execution_status,re=Da(ne);y(re),C(Na(re))}break;case"conversation_message":E(X.data);break;case"user_input_request":T(X.data);break;case"platform_event":P(X.data);break;case"platform_function":O(X.data);break;case"execution_complete":C(!1),y(Me.IDLE),S.current=null;break;case"execution_error":C(!1),y(Me.FAILED),S.current=null;break;case"execution_cancelled":C(!1),y(Me.IDLE),S.current=null;break;case"execution_status":const Q=(Z=X.data)==null?void 0:Z.status;if(Q){const ne=Da(Q);y(ne),C(Na(ne))}break}},[h]),E=i.useCallback(X=>{var re,ie,Y,ae,q,B,A,W;const{id:U,message_type:Z,content:Q}=X,ne=L=>g.some(G=>G.id===L);if(Z==="system_decision"||Z==="action_execution_result"||Z==="assistant_task_breakdown"||Z==="assistant_validation"||Z==="assistant_action_planning"||Z==="context_results"){d(null),m(null);let L="";if(Z==="system_decision"){const G=Q==null?void 0:Q.step,se=Q==null?void 0:Q.reasoning;if(G==="gathercontext")se&&se.length>0?L=se.length>60?`${se.substring(0,60)}...`:se:L="Gathering context...";else if(G==="executeaction")L="Executing action";else if(G==="deliverresponse")L="Preparing response";else if(G==="taskplanning")L="Planning approach";else if(G==="validateprogress")L="Validating progress";else if(G==="acknowledge")L="Processing request";else if(G==="finishplanning")L="Finalizing plan";else if(G==="executetasks")L="Executing tasks";else if(G==="requestuserinput")L="Waiting for input";else if(G==="complete")L="Completed";else if(G==="examinetool")L="Examining tool";else if(G==="examineworkflow")L="Examining workflow";else{const me=(Q==null?void 0:Q.confidence)||.5;me>.8?L="Analyzing":me>.6?L="Thinking":L="Reasoning"}}else if(Z==="action_execution_result")((re=Q.task_execution)==null?void 0:re.status)==="completed"?L="Task execution completed":(ie=Q.task_execution)!=null&&ie.approach?L=Q.task_execution.approach:L="Executing task";else if(Z==="assistant_task_breakdown")(Y=Q.task_breakdown)!=null&&Y.total_tasks?L=`Identified ${Q.task_breakdown.total_tasks} tasks`:L="Planning tasks";else if(Z==="assistant_validation")L="Validated results";else if(Z==="assistant_action_planning")(ae=Q.task_execution)!=null&&ae.total_tasks?L=`Planned ${Q.task_execution.total_tasks} tasks`:(B=(q=Q.task_execution)==null?void 0:q.tasks)!=null&&B.length?L=`Planned ${Q.task_execution.tasks.length} tasks`:L="Planning actions";else if(Z==="context_results"){const G=Q.query,se=Q.result_count||0;G&&G!=="General context gathering"?L=`${G}: Found ${se} results`:L=`Found ${se} results`}L&&!ne(U)&&c(G=>[...G,{id:U,role:"system",content:L,timestamp:new Date,metadata:{type:"log",messageType:Z}}]);return}if(Z==="user_message")ne(U)||(d(null),m(null),c(L=>[...L,{id:U,role:"user",content:Q.message,images:Q.images,timestamp:new Date}]));else if(Z==="agent_response")ne(U)||(d(null),m(null),C(!1),y(Me.IDLE),S.current=null,c(L=>[...L,{id:U,role:"assistant",content:Q.response,timestamp:new Date,isStreaming:!1}]));else if(Z==="assistant_acknowledgment")ne(U)||(d(null),m(null),c(L=>[...L,{id:U,role:"assistant",content:Q.acknowledgment_message,timestamp:new Date}]));else if(Z==="assistant_ideation"||Z==="assistant_action_planning"||Z==="action_execution_result"||Z==="assistant_validation"||Z==="assistant_context_gathering"||Z==="assistant_task_breakdown"){let L="";if(Q.reasoning_summary)L=Q.reasoning_summary;else if((A=Q.task_execution)!=null&&A.approach)L=Q.task_execution.approach;else if(Q.strategic_synthesis)L=Q.strategic_synthesis;else if((W=Q.task_breakdown)!=null&&W.total_tasks)L=`Breaking down into ${Q.task_breakdown.total_tasks} tasks...`;else if(Q.acknowledgment_message)L=Q.acknowledgment_message;else return;c(G=>[...G,{id:U,role:"assistant",content:L,timestamp:new Date}])}else if(Z==="user_input_request"){const L={question:Q.question,context:Q.context,input_type:Q.input_type,options:Q.options||Q.suggestions,default_value:Q.default_value,placeholder:Q.placeholder};y("waiting_for_input"),c(G=>[...G,{id:U,role:"system",content:L.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:L}}])}},[]),T=i.useCallback(async X=>{y("waiting_for_input");const U=`input-request-${Date.now()}`;c(Z=>[...Z,{id:U,role:"system",content:X.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:X}}])},[]),P=i.useCallback(X=>{const{event_label:U,event_data:Z}=X;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(U,Z)},[n]),O=i.useCallback(async X=>{const{function_name:U,function_data:Z}=X,{parameters:Q,execution_id:ne}=Z;if(!(n!=null&&n.onPlatformFunction)){Ye.send({message_type:{platform_function_result:[ne,{error:"No platform function handler registered"}]},data:{}});return}try{const re=await n.onPlatformFunction(U,Q,ne),ie={message_type:{platform_function_result:[ne,re]},data:{}};Ye.send(ie)}catch(re){Ye.send({message_type:{platform_function_result:[ne,{error:re instanceof Error?re.message:"Function execution failed",stack:re instanceof Error?re.stack:void 0}]},data:{}})}},[n]);i.useEffect(()=>{if(!s)return;const U=`wss://${s==null?void 0:s.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;_({status:xt.CONNECTING}),Ye.connect(U)},[s,o]),i.useEffect(()=>Ye.onConnectionStateChange(U=>{_({status:U.isConnected?xt.CONNECTED:U.error?xt.ERROR:xt.DISCONNECTED}),v(U.isConnected)}),[]),i.useEffect(()=>Ye.onMessage(R),[R]),i.useEffect(()=>{x&&t&&r&&a&&Ye.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,a]);const D=i.useCallback(async()=>(x&&t&&r&&Ye.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),M=i.useCallback((X,U)=>{x&&(d(X),m(U||null),C(!0),y(Me.STARTING),Ye.send({message_type:{message_input:X},data:U?{images:U}:{}}))},[x]),N=i.useCallback(()=>{c([]),S.current=null},[]),F=i.useCallback(X=>{!x||$!==Me.WAITING_FOR_INPUT||(Ye.send({message_type:{user_input_response:X},data:{}}),y(Me.RUNNING))},[x,$]),ee=i.useCallback(async X=>{var U;if(!(!o||!t))try{const Z=new URLSearchParams({token:o,limit:"50"});X&&(Z.append("before_id",X),I(!0));const ne=await(await p(`/api/agent/contexts/${t}/messages?${Z}`,{method:"GET"})).json();if(ne.status===200&&ne.data){const re=ne.data;if(Array.isArray(re.data)){const ie=re.data.filter(Y=>{var B;let ae=Y.content;if(typeof Y.content=="string")try{ae=JSON.parse(Y.content)}catch{ae={message:Y.content}}const q=((B=Y.metadata)==null?void 0:B.message_type)||(ae==null?void 0:ae.message_type);return q==="user_message"||q==="agent_response"||q==="assistant_acknowledgment"||q==="user_input_request"||q==="system_decision"||q==="action_execution_result"||q==="assistant_task_breakdown"||q==="assistant_validation"||q==="assistant_action_planning"||q==="context_results"}).map(Y=>{var L,G,se,me,Se,Ne,H;let ae="",q,B,A=Y.content;if(typeof Y.content=="string")try{A=JSON.parse(Y.content)}catch{A=Y.content}const W=((L=Y.metadata)==null?void 0:L.message_type)||(A==null?void 0:A.message_type);if(W==="user_message"?(ae=(A==null?void 0:A.message)||"",q=(A==null?void 0:A.images)||void 0):W==="agent_response"?ae=(A==null?void 0:A.response)||"":W==="assistant_acknowledgment"?ae=(A==null?void 0:A.acknowledgment_message)||"":W==="user_input_request"&&(ae=(A==null?void 0:A.question)||"",B={type:"user_input_request",userInputRequest:{question:(A==null?void 0:A.question)||"",context:(A==null?void 0:A.context)||"",input_type:(A==null?void 0:A.input_type)||"text",options:(A==null?void 0:A.options)||(A==null?void 0:A.suggestions)||[],default_value:(A==null?void 0:A.default_value)||"",placeholder:(A==null?void 0:A.placeholder)||""}}),W==="system_decision"||W==="action_execution_result"||W==="assistant_task_breakdown"||W==="assistant_validation"||W==="assistant_action_planning"||W==="context_results"){let oe="";if(W==="system_decision"){const ye=A==null?void 0:A.step,be=A==null?void 0:A.reasoning;if(ye==="gathercontext")be&&be.length>0?oe=be.length>60?`${be.substring(0,60)}...`:be:oe="Gathering context...";else if(ye==="executeaction")oe="Executing action";else if(ye==="deliverresponse")oe="Preparing response";else if(ye==="taskplanning")oe="Planning approach";else if(ye==="validateprogress")oe="Validating progress";else if(ye==="acknowledge")oe="Processing request";else if(ye==="finishplanning")oe="Finalizing plan";else if(ye==="executetasks")oe="Executing tasks";else if(ye==="requestuserinput")oe="Waiting for input";else if(ye==="complete")oe="Completed";else if(ye==="examinetool")oe="Examining tool";else if(ye==="examineworkflow")oe="Examining workflow";else{const te=(A==null?void 0:A.confidence)||.5;te>.8?oe="Analyzing":te>.6?oe="Thinking":oe="Reasoning"}}else if(W==="action_execution_result")((G=A==null?void 0:A.task_execution)==null?void 0:G.status)==="completed"?oe="Task execution completed":(se=A==null?void 0:A.task_execution)!=null&&se.approach?oe=A.task_execution.approach:oe="Executing task";else if(W==="assistant_task_breakdown")(me=A==null?void 0:A.task_breakdown)!=null&&me.total_tasks?oe=`Identified ${A.task_breakdown.total_tasks} tasks`:oe="Planning tasks";else if(W==="assistant_validation")oe="Validated results";else if(W==="assistant_action_planning")(Se=A==null?void 0:A.task_execution)!=null&&Se.total_tasks?oe=`Planned ${A.task_execution.total_tasks} tasks`:(H=(Ne=A==null?void 0:A.task_execution)==null?void 0:Ne.tasks)!=null&&H.length?oe=`Planned ${A.task_execution.tasks.length} tasks`:oe="Planning actions";else if(W==="context_results"){const ye=A==null?void 0:A.query,be=(A==null?void 0:A.result_count)||0;ye&&ye!=="General context gathering"?oe=`${ye}: Found ${be} results`:oe=`Found ${be} results`}ae=oe,B={type:"log",messageType:W}}return{id:Y.id,role:W==="user_message"?"user":W==="user_input_request"?"system":"assistant",content:ae,images:q,timestamp:new Date(Y.timestamp||Y.created_at||Date.now()),metadata:B}}).filter(Y=>Y.content||Y.metadata||Y.images).sort((Y,ae)=>{const q=BigInt(Y.id),B=BigInt(ae.id);return q<B?-1:q>B?1:0});ie.length>0&&(j.current=ie[0].id),X?(c(Y=>[...ie,...Y]),b(ie.length>=50)):(c(ie),ie.length>0&&((U=ie[ie.length-1].metadata)==null?void 0:U.type)==="user_input_request"&&y(Me.WAITING_FOR_INPUT)),I(!1)}}}catch(Z){console.error("Failed to fetch messages:",Z),I(!1)}},[o,t,p]);i.useEffect(()=>{t&&o&&ee()},[t,o]);const ce=i.useCallback(async()=>{if(!(f||!k||!j.current)){I(!0);try{await ee(j.current)}finally{I(!1)}}},[f,k,ee]),J=i.useCallback(()=>{!x||!w||(Ye.send({message_type:{cancel_execution:null},data:{}}),C(!1),y("idle"))},[x,w]);return{messages:g,pendingMessage:h,pendingImages:l,connectionState:z,isConnected:x,isExecuting:w,executionStatus:$,isWaitingForInput:$==="waiting_for_input",hasMoreMessages:k,isLoadingMore:f,sendMessage:M,submitUserInput:F,clearMessages:N,loadMoreMessages:ce,cancelExecution:J,connect:D,disconnect:()=>Ye.disconnect()}}const dc=()=>{const{client:t}=De(),[r,o]=i.useState(!1),[n,a]=i.useState(null),[s,p]=i.useState(null),g=i.useCallback(async h=>{o(!0),a(null),p(null);try{const d=await t("/organizations/invitations/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:h})}),m=(await V(d)).data;return p(m),m.error_code&&a(m.message||"Failed to accept invitation"),m}catch(d){const l=d.message||"Failed to accept invitation";a(l);const m={error_code:"NETWORK_ERROR",message:l};return p(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{a(null),p(null)},[]);return{acceptInvitation:g,invitationData:s,loading:r,error:n,reset:c}},iu=({children:t})=>{const{loading:r}=ve();return r?null:e.jsx(e.Fragment,{children:t})},cu=({children:t})=>{const{loading:r}=ve();return r?e.jsx(e.Fragment,{children:t}):null};var qe=function(){return qe=Object.assign||function(r){for(var o,n=1,a=arguments.length;n<a;n++){o=arguments[n];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])}return r},qe.apply(this,arguments)};function Xt(t,r,o){if(o||arguments.length===2)for(var n=0,a=r.length,s;n<a;n++)(s||!(n in r))&&(s||(s=Array.prototype.slice.call(r,0,n)),s[n]=r[n]);return t.concat(s||Array.prototype.slice.call(r))}function lu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var du=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,uu=lu(function(t){return du.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),ze="-ms-",Mr="-moz-",_e="-webkit-",uc="comm",Go="rule",ma="decl",pu="@import",pc="@keyframes",hu="@layer",hc=Math.abs,xa=String.fromCharCode,ta=Object.assign;function fu(t,r){return Be(t,0)^45?(((r<<2^Be(t,0))<<2^Be(t,1))<<2^Be(t,2))<<2^Be(t,3):0}function fc(t){return t.trim()}function mt(t,r){return(t=r.exec(t))?t[0]:t}function fe(t,r,o){return t.replace(r,o)}function _o(t,r,o){return t.indexOf(r,o)}function Be(t,r){return t.charCodeAt(r)|0}function hr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function gc(t){return t.length}function Tr(t,r){return r.push(t),t}function gu(t,r){return t.map(r).join("")}function Fa(t,r){return t.filter(function(o){return!mt(o,r)})}var Ho=1,fr=1,mc=0,Ze=0,Le=0,br="";function qo(t,r,o,n,a,s,p,g){return{value:t,root:r,parent:o,type:n,props:a,children:s,line:Ho,column:fr,length:p,return:"",siblings:g}}function St(t,r){return ta(qo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function ar(t){for(;t.root;)t=St(t.root,{children:[t]});Tr(t,t.siblings)}function mu(){return Le}function xu(){return Le=Ze>0?Be(br,--Ze):0,fr--,Le===10&&(fr=1,Ho--),Le}function et(){return Le=Ze<mc?Be(br,Ze++):0,fr++,Le===10&&(fr=1,Ho++),Le}function qt(){return Be(br,Ze)}function Co(){return Ze}function Yo(t,r){return hr(br,t,r)}function ra(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function vu(t){return Ho=fr=1,mc=ct(br=t),Ze=0,[]}function bu(t){return br="",t}function fn(t){return fc(Yo(Ze-1,oa(t===91?t+2:t===40?t+1:t)))}function yu(t){for(;(Le=qt())&&Le<33;)et();return ra(t)>2||ra(Le)>3?"":" "}function wu(t,r){for(;--r&&et()&&!(Le<48||Le>102||Le>57&&Le<65||Le>70&&Le<97););return Yo(t,Co()+(r<6&&qt()==32&&et()==32))}function oa(t){for(;et();)switch(Le){case t:return Ze;case 34:case 39:t!==34&&t!==39&&oa(Le);break;case 40:t===41&&oa(t);break;case 92:et();break}return Ze}function ju(t,r){for(;et()&&t+Le!==57;)if(t+Le===84&&qt()===47)break;return"/*"+Yo(r,Ze-1)+"*"+xa(t===47?t:et())}function ku(t){for(;!ra(qt());)et();return Yo(t,Ze)}function _u(t){return bu(So("",null,null,null,[""],t=vu(t),0,[0],t))}function So(t,r,o,n,a,s,p,g,c){for(var h=0,d=0,l=p,m=0,x=0,v=0,w=1,C=1,$=1,y=0,z="",_=a,k=s,b=n,f=z;C;)switch(v=y,y=et()){case 40:if(v!=108&&Be(f,l-1)==58){_o(f+=fe(fn(y),"&","&\f"),"&\f",hc(h?g[h-1]:0))!=-1&&($=-1);break}case 34:case 39:case 91:f+=fn(y);break;case 9:case 10:case 13:case 32:f+=yu(v);break;case 92:f+=wu(Co()-1,7);continue;case 47:switch(qt()){case 42:case 47:Tr(Cu(ju(et(),Co()),r,o,c),c);break;default:f+="/"}break;case 123*w:g[h++]=ct(f)*$;case 125*w:case 59:case 0:switch(y){case 0:case 125:C=0;case 59+d:$==-1&&(f=fe(f,/\f/g,"")),x>0&&ct(f)-l&&Tr(x>32?Ua(f+";",n,o,l-1,c):Ua(fe(f," ","")+";",n,o,l-2,c),c);break;case 59:f+=";";default:if(Tr(b=Ba(f,r,o,h,d,a,g,z,_=[],k=[],l,s),s),y===123)if(d===0)So(f,r,b,b,_,s,l,g,k);else switch(m===99&&Be(f,3)===110?100:m){case 100:case 108:case 109:case 115:So(t,b,b,n&&Tr(Ba(t,b,b,0,0,a,g,z,a,_=[],l,k),k),a,k,l,g,n?_:k);break;default:So(f,b,b,b,[""],k,0,g,k)}}h=d=x=0,w=$=1,z=f="",l=p;break;case 58:l=1+ct(f),x=v;default:if(w<1){if(y==123)--w;else if(y==125&&w++==0&&xu()==125)continue}switch(f+=xa(y),y*w){case 38:$=d>0?1:(f+="\f",-1);break;case 44:g[h++]=(ct(f)-1)*$,$=1;break;case 64:qt()===45&&(f+=fn(et())),m=qt(),d=l=ct(z=f+=ku(Co())),y++;break;case 45:v===45&&ct(f)==2&&(w=0)}}return s}function Ba(t,r,o,n,a,s,p,g,c,h,d,l){for(var m=a-1,x=a===0?s:[""],v=gc(x),w=0,C=0,$=0;w<n;++w)for(var y=0,z=hr(t,m+1,m=hc(C=p[w])),_=t;y<v;++y)(_=fc(C>0?x[y]+" "+z:fe(z,/&\f/g,x[y])))&&(c[$++]=_);return qo(t,r,o,a===0?Go:g,c,h,d,l)}function Cu(t,r,o,n){return qo(t,r,o,uc,xa(mu()),hr(t,2,-2),0,n)}function Ua(t,r,o,n,a){return qo(t,r,o,ma,hr(t,0,n),hr(t,n+1,-1),n,a)}function xc(t,r,o){switch(fu(t,r)){case 5103:return _e+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return _e+t+t;case 4789:return Mr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return _e+t+Mr+t+ze+t+t;case 5936:switch(Be(t,r+11)){case 114:return _e+t+ze+fe(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return _e+t+ze+fe(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return _e+t+ze+fe(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return _e+t+ze+t+t;case 6165:return _e+t+ze+"flex-"+t+t;case 5187:return _e+t+fe(t,/(\w+).+(:[^]+)/,_e+"box-$1$2"+ze+"flex-$1$2")+t;case 5443:return _e+t+ze+"flex-item-"+fe(t,/flex-|-self/g,"")+(mt(t,/flex-|baseline/)?"":ze+"grid-row-"+fe(t,/flex-|-self/g,""))+t;case 4675:return _e+t+ze+"flex-line-pack"+fe(t,/align-content|flex-|-self/g,"")+t;case 5548:return _e+t+ze+fe(t,"shrink","negative")+t;case 5292:return _e+t+ze+fe(t,"basis","preferred-size")+t;case 6060:return _e+"box-"+fe(t,"-grow","")+_e+t+ze+fe(t,"grow","positive")+t;case 4554:return _e+fe(t,/([^-])(transform)/g,"$1"+_e+"$2")+t;case 6187:return fe(fe(fe(t,/(zoom-|grab)/,_e+"$1"),/(image-set)/,_e+"$1"),t,"")+t;case 5495:case 3959:return fe(t,/(image-set\([^]*)/,_e+"$1$`$1");case 4968:return fe(fe(t,/(.+:)(flex-)?(.*)/,_e+"box-pack:$3"+ze+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+_e+t+t;case 4200:if(!mt(t,/flex-|baseline/))return ze+"grid-column-align"+hr(t,r)+t;break;case 2592:case 3360:return ze+fe(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,a){return r=a,mt(n.props,/grid-\w+-end/)})?~_o(t+(o=o[r].value),"span",0)?t:ze+fe(t,"-start","")+t+ze+"grid-row-span:"+(~_o(o,"span",0)?mt(o,/\d+/):+mt(o,/\d+/)-+mt(t,/\d+/))+";":ze+fe(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return mt(n.props,/grid-\w+-start/)})?t:ze+fe(fe(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return fe(t,/(.+)-inline(.+)/,_e+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ct(t)-1-r>6)switch(Be(t,r+1)){case 109:if(Be(t,r+4)!==45)break;case 102:return fe(t,/(.+:)(.+)-([^]+)/,"$1"+_e+"$2-$3$1"+Mr+(Be(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~_o(t,"stretch",0)?xc(fe(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return fe(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,a,s,p,g,c,h){return ze+a+":"+s+h+(p?ze+a+"-span:"+(g?c:+c-+s)+h:"")+t});case 4949:if(Be(t,r+6)===121)return fe(t,":",":"+_e)+t;break;case 6444:switch(Be(t,Be(t,14)===45?18:11)){case 120:return fe(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+_e+(Be(t,14)===45?"inline-":"")+"box$3$1"+_e+"$2$3$1"+ze+"$2box$3")+t;case 100:return fe(t,":",":"+ze)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return fe(t,"scroll-","scroll-snap-")+t}return t}function Io(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Su(t,r,o,n){switch(t.type){case hu:if(t.children.length)break;case pu:case ma:return t.return=t.return||t.value;case uc:return"";case pc:return t.return=t.value+"{"+Io(t.children,n)+"}";case Go:if(!ct(t.value=t.props.join(",")))return""}return ct(o=Io(t.children,n))?t.return=t.value+"{"+o+"}":""}function $u(t){var r=gc(t);return function(o,n,a,s){for(var p="",g=0;g<r;g++)p+=t[g](o,n,a,s)||"";return p}}function zu(t){return function(r){r.root||(r=r.return)&&t(r)}}function Eu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case ma:t.return=xc(t.value,t.length,o);return;case pc:return Io([St(t,{value:fe(t.value,"@","@"+_e)})],n);case Go:if(t.length)return gu(o=t.props,function(a){switch(mt(a,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":ar(St(t,{props:[fe(a,/:(read-\w+)/,":"+Mr+"$1")]})),ar(St(t,{props:[a]})),ta(t,{props:Fa(o,n)});break;case"::placeholder":ar(St(t,{props:[fe(a,/:(plac\w+)/,":"+_e+"input-$1")]})),ar(St(t,{props:[fe(a,/:(plac\w+)/,":"+Mr+"$1")]})),ar(St(t,{props:[fe(a,/:(plac\w+)/,ze+"input-$1")]})),ar(St(t,{props:[a]})),ta(t,{props:Fa(o,n)});break}return""})}}var Pu={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Jt=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",vc="active",bc="data-styled-version",Zo="6.1.19",va=`/*!sc*/
18
+ */var Ra;function ed(){return Ra||(Ra=1,process.env.NODE_ENV!=="production"&&function(){function t(x,v){return x===v&&(x!==0||1/x===1/v)||x!==x&&v!==v}function r(x,v){d||a.startTransition===void 0||(d=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var w=v();if(!l){var C=v();s(w,C)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),l=!0)}C=p({inst:{value:w,getSnapshot:v}});var $=C[0].inst,y=C[1];return c(function(){$.value=w,$.getSnapshot=v,o($)&&y({inst:$})},[x,w,v]),g(function(){return o($)&&y({inst:$}),x(function(){o($)&&y({inst:$})})},[x]),h(w),w}function o(x){var v=x.getSnapshot;x=x.value;try{var w=v();return!s(x,w)}catch{return!0}}function n(x,v){return v()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=i,s=typeof Object.is=="function"?Object.is:t,p=a.useState,g=a.useEffect,c=a.useLayoutEffect,h=a.useDebugValue,d=!1,l=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;sn.useSyncExternalStore=a.useSyncExternalStore!==void 0?a.useSyncExternalStore:m,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error())}()),sn}var Ia;function td(){return Ia||(Ia=1,process.env.NODE_ENV==="production"?Gr.exports=Jl():Gr.exports=ed()),Gr.exports}var rd=td();const Ui=0,Wi=1,Vi=2,Ta=3;var Oa=Object.prototype.hasOwnProperty;function Gn(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&Gn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(Oa.call(t,o)&&++n&&!Oa.call(r,o)||!(o in r)||!Gn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const vt=new WeakMap,$t=()=>{},Ge=$t(),Hn=Object,je=t=>t===Ge,lt=t=>typeof t=="function",Et=(t,r)=>({...t,...r}),Gi=t=>lt(t.then),cn={},Hr={},fa="undefined",Fr=typeof window!=fa,qn=typeof document!=fa,od=Fr&&"Deno"in window,nd=()=>Fr&&typeof window.requestAnimationFrame!=fa,Hi=(t,r)=>{const o=vt.get(t);return[()=>!je(r)&&t.get(r)||cn,n=>{if(!je(r)){const a=t.get(r);r in Hr||(Hr[r]=a),o[5](r,Et(a,n),a||cn)}},o[6],()=>!je(r)&&r in Hr?Hr[r]:!je(r)&&t.get(r)||cn]};let Yn=!0;const ad=()=>Yn,[Zn,Kn]=Fr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[$t,$t],sd=()=>{const t=qn&&document.visibilityState;return je(t)||t!=="hidden"},id=t=>(qn&&document.addEventListener("visibilitychange",t),Zn("focus",t),()=>{qn&&document.removeEventListener("visibilitychange",t),Kn("focus",t)}),cd=t=>{const r=()=>{Yn=!0,t()},o=()=>{Yn=!1};return Zn("online",r),Zn("offline",o),()=>{Kn("online",r),Kn("offline",o)}},ld={isOnline:ad,isVisible:sd},dd={initFocus:id,initReconnect:cd},Ma=!i.useId,Lr=!Fr||od,ud=t=>nd()?window.requestAnimationFrame(t):setTimeout(t,1),ln=Lr?i.useEffect:i.useLayoutEffect,dn=typeof navigator<"u"&&navigator.connection,La=!Lr&&dn&&(["slow-2g","2g"].includes(dn.effectiveType)||dn.saveData),qr=new WeakMap,pd=t=>Hn.prototype.toString.call(t),un=(t,r)=>t===`[object ${r}]`;let hd=0;const Qn=t=>{const r=typeof t,o=pd(t),n=un(o,"Date"),a=un(o,"RegExp"),s=un(o,"Object");let p,g;if(Hn(t)===t&&!n&&!a){if(p=qr.get(t),p)return p;if(p=++hd+"~",qr.set(t,p),Array.isArray(t)){for(p="@",g=0;g<t.length;g++)p+=Qn(t[g])+",";qr.set(t,p)}if(s){p="#";const c=Hn.keys(t).sort();for(;!je(g=c.pop());)je(t[g])||(p+=g+":"+Qn(t[g])+",");qr.set(t,p)}}else p=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return p},ga=t=>{if(lt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?Qn(t):"",[t,r]};let fd=0;const Xn=()=>++fd;async function qi(...t){const[r,o,n,a]=t,s=Et({populateCache:!0,throwOnError:!0},typeof a=="boolean"?{revalidate:a}:a||{});let p=s.populateCache;const g=s.rollbackOnError;let c=s.optimisticData;const h=m=>typeof g=="function"?g(m):g!==!1,d=s.throwOnError;if(lt(o)){const m=o,x=[],v=r.keys();for(const w of v)!/^\$(inf|sub)\$/.test(w)&&m(r.get(w)._k)&&x.push(w);return Promise.all(x.map(l))}return l(o);async function l(m){const[x]=ga(m);if(!x)return;const[v,w]=Hi(r,x),[C,$,y,z]=vt.get(r),_=()=>{const P=C[x];return(lt(s.revalidate)?s.revalidate(v().data,m):s.revalidate!==!1)&&(delete y[x],delete z[x],P&&P[0])?P[0](Vi).then(()=>v().data):v().data};if(t.length<3)return _();let k=n,b,f=!1;const I=Xn();$[x]=[I,0];const j=!je(c),S=v(),R=S.data,E=S._c,T=je(E)?R:E;if(j&&(c=lt(c)?c(T,R):c,w({data:c,_c:T})),lt(k))try{k=k(T)}catch(P){b=P,f=!0}if(k&&Gi(k))if(k=await k.catch(P=>{b=P,f=!0}),I!==$[x][0]){if(f)throw b;return k}else f&&j&&h(b)&&(p=!0,w({data:T,_c:Ge}));if(p&&!f)if(lt(p)){const P=p(k,T);w({data:P,error:Ge,_c:Ge})}else w({data:k,error:Ge,_c:Ge});if($[x][1]=Xn(),Promise.resolve(_()).then(()=>{w({_c:Ge})}),f){if(d)throw b;return}return k}}const Aa=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},gd=(t,r)=>{if(!vt.has(t)){const o=Et(dd,r),n=Object.create(null),a=qi.bind(Ge,t);let s=$t;const p=Object.create(null),g=(d,l)=>{const m=p[d]||[];return p[d]=m,m.push(l),()=>m.splice(m.indexOf(l),1)},c=(d,l,m)=>{t.set(d,l);const x=p[d];if(x)for(const v of x)v(l,m)},h=()=>{if(!vt.has(t)&&(vt.set(t,[n,Object.create(null),Object.create(null),Object.create(null),a,c,g]),!Lr)){const d=o.initFocus(setTimeout.bind(Ge,Aa.bind(Ge,n,Ui))),l=o.initReconnect(setTimeout.bind(Ge,Aa.bind(Ge,n,Wi)));s=()=>{d&&d(),l&&l(),vt.delete(t)}}};return h(),[t,a,h,s]}return[t,vt.get(t)[4]]},md=(t,r,o,n,a)=>{const s=o.errorRetryCount,p=a.retryCount,g=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!je(s)&&p>s||setTimeout(n,g,a)},xd=Gn,[Yi,vd]=gd(new Map),bd=Et({onLoadingSlow:$t,onSuccess:$t,onError:$t,onErrorRetry:md,onDiscarded:$t,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:La?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:La?5e3:3e3,compare:xd,isPaused:()=>!1,cache:Yi,mutate:vd,fallback:{}},ld),yd=(t,r)=>{const o=Et(t,r);if(r){const{use:n,fallback:a}=t,{use:s,fallback:p}=r;n&&s&&(o.use=n.concat(s)),a&&p&&(o.fallback=Et(a,p))}return o},wd=i.createContext({}),jd="$inf$",Zi=Fr&&window.__SWR_DEVTOOLS_USE__,kd=Zi?window.__SWR_DEVTOOLS_USE__:[],_d=()=>{Zi&&(window.__SWR_DEVTOOLS_REACT__=i)},Cd=t=>lt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],Sd=()=>Et(bd,i.useContext(wd)),$d=t=>(r,o,n)=>t(r,o&&((...s)=>{const[p]=ga(r),[,,,g]=vt.get(Yi);if(p.startsWith(jd))return o(...s);const c=g[p];return je(c)?o(...s):(delete g[p],c)}),n),zd=kd.concat($d),Ed=t=>function(...o){const n=Sd(),[a,s,p]=Cd(o),g=yd(n,p);let c=t;const{use:h}=g,d=(h||[]).concat(zd);for(let l=d.length;l--;)c=d[l](c);return c(a,s||g.fetcher||null,g)},Pd=(t,r,o)=>{const n=r[t]||(r[t]=[]);return n.push(o),()=>{const a=n.indexOf(o);a>=0&&(n[a]=n[n.length-1],n.pop())}};_d();const pn=i.use||(t=>{switch(t.status){case"pending":throw t;case"fulfilled":return t.value;case"rejected":throw t.reason;default:throw t.status="pending",t.then(r=>{t.status="fulfilled",t.value=r},r=>{t.status="rejected",t.reason=r}),t}}),hn={dedupe:!0},Rd=(t,r,o)=>{const{cache:n,compare:a,suspense:s,fallbackData:p,revalidateOnMount:g,revalidateIfStale:c,refreshInterval:h,refreshWhenHidden:d,refreshWhenOffline:l,keepPreviousData:m}=o,[x,v,w,C]=vt.get(n),[$,y]=ga(t),z=i.useRef(!1),_=i.useRef(!1),k=i.useRef($),b=i.useRef(r),f=i.useRef(o),I=()=>f.current,j=()=>I().isVisible()&&I().isOnline(),[S,R,E,T]=Hi(n,$),P=i.useRef({}).current,O=je(p)?je(o.fallback)?Ge:o.fallback[$]:p,D=(H,A)=>{for(const B in P){const L=B;if(L==="data"){if(!a(H[L],A[L])&&(!je(H[L])||!a(Z,A[L])))return!1}else if(A[L]!==H[L])return!1}return!0},M=i.useMemo(()=>{const H=!$||!r?!1:je(g)?I().isPaused()||s?!1:c!==!1:g,A=Se=>{const Ne=Et(Se);return delete Ne._k,H?{isValidating:!0,isLoading:!0,...Ne}:Ne},B=S(),L=T(),W=A(B),ee=B===L?W:A(L);let pe=W;return[()=>{const Se=A(S());return D(Se,pe)?(pe.data=Se.data,pe.isLoading=Se.isLoading,pe.isValidating=Se.isValidating,pe.error=Se.error,pe):(pe=Se,Se)},()=>ee]},[n,$]),N=rd.useSyncExternalStore(i.useCallback(H=>E($,(A,B)=>{D(B,A)||H()}),[n,$]),M[0],M[1]),F=!z.current,J=x[$]&&x[$].length>0,ie=N.data,re=je(ie)?O&&Gi(O)?pn(O):O:ie,X=N.error,U=i.useRef(re),Z=m?je(ie)?je(U.current)?re:U.current:ie:re,Q=J&&!je(X)?!1:F&&!je(g)?g:I().isPaused()?!1:s?je(re)?!1:c:je(re)||c,ae=!!($&&r&&F&&Q),oe=je(N.isValidating)?ae:N.isValidating,ce=je(N.isLoading)?ae:N.isLoading,Y=i.useCallback(async H=>{const A=b.current;if(!$||!A||_.current||I().isPaused())return!1;let B,L,W=!0;const ee=H||{},pe=!w[$]||!ee.dedupe,Se=()=>Ma?!_.current&&$===k.current&&z.current:$===k.current,Ne={isValidating:!1,isLoading:!1},G=()=>{R(Ne)},ne=()=>{const be=w[$];be&&be[1]===L&&delete w[$]},ye={isValidating:!0};je(S().data)&&(ye.isLoading=!0);try{if(pe&&(R(ye),o.loadingTimeout&&je(S().data)&&setTimeout(()=>{W&&Se()&&I().onLoadingSlow($,o)},o.loadingTimeout),w[$]=[A(y),Xn()]),[B,L]=w[$],B=await B,pe&&setTimeout(ne,o.dedupingInterval),!w[$]||w[$][1]!==L)return pe&&Se()&&I().onDiscarded($),!1;Ne.error=Ge;const be=v[$];if(!je(be)&&(L<=be[0]||L<=be[1]||be[1]===0))return G(),pe&&Se()&&I().onDiscarded($),!1;const te=S().data;Ne.data=a(te,B)?te:B,pe&&Se()&&I().onSuccess(B,$,o)}catch(be){ne();const te=I(),{shouldRetryOnError:$e}=te;te.isPaused()||(Ne.error=be,pe&&Se()&&(te.onError(be,$,te),($e===!0||lt($e)&&$e(be))&&(!I().revalidateOnFocus||!I().revalidateOnReconnect||j())&&te.onErrorRetry(be,$,te,fe=>{const ke=x[$];ke&&ke[0]&&ke[0](Ta,fe)},{retryCount:(ee.retryCount||0)+1,dedupe:!0})))}return W=!1,G(),!0},[$,n]),se=i.useCallback((...H)=>qi(n,k.current,...H),[]);if(ln(()=>{b.current=r,f.current=o,je(ie)||(U.current=ie)}),ln(()=>{if(!$)return;const H=Y.bind(Ge,hn);let A=0;I().revalidateOnFocus&&(A=Date.now()+I().focusThrottleInterval);const L=Pd($,x,(W,ee={})=>{if(W==Ui){const pe=Date.now();I().revalidateOnFocus&&pe>A&&j()&&(A=pe+I().focusThrottleInterval,H())}else if(W==Wi)I().revalidateOnReconnect&&j()&&H();else{if(W==Vi)return Y();if(W==Ta)return Y(ee)}});return _.current=!1,k.current=$,z.current=!0,R({_k:y}),Q&&(w[$]||(je(re)||Lr?H():ud(H))),()=>{_.current=!0,L()}},[$]),ln(()=>{let H;function A(){const L=lt(h)?h(S().data):h;L&&H!==-1&&(H=setTimeout(B,L))}function B(){!S().error&&(d||I().isVisible())&&(l||I().isOnline())?Y(hn).then(A):A()}return A(),()=>{H&&(clearTimeout(H),H=-1)}},[h,d,l,$]),i.useDebugValue(Z),s&&je(re)&&$){if(!Ma&&Lr)throw new Error("Fallback data is required when using Suspense in SSR.");b.current=r,f.current=o,_.current=!1;const H=C[$];if(!je(H)){const A=se(H);pn(A)}if(je(X)){const A=Y(hn);je(Z)||(A.status="fulfilled",A.value=!0),pn(A)}else throw X}return{mutate:se,get data(){return P.data=!0,Z},get error(){return P.error=!0,X},get isValidating(){return P.isValidating=!0,oe},get isLoading(){return P.isLoading=!0,ce}}},We=Ed(Rd);async function V(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}const r=await t.json();return{data:r.data,errors:r.errors}}function Ki(t){const{client:r}=De(),o=i.useCallback(async()=>{const c=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"GET"});return(await V(c)).data},[r,t]),{data:n,error:a,mutate:s}=We(t?`sessions-${t}`:null,o,{revalidateOnFocus:!1}),p=i.useCallback(async c=>{const h=new FormData;h.append("title",c.title),c.system_instructions&&h.append("system_instructions",c.system_instructions);const d=await r(`/api/agent/contexts?token=${encodeURIComponent(t)}`,{method:"POST",body:h}),l=await V(d);return await s(m=>m&&{...m,data:[l.data,...m.data]}),l.data},[r,t,s]),g=i.useCallback(async c=>{await r(`/api/agent/contexts/${c}/delete?token=${encodeURIComponent(t)}`,{method:"POST"}),await s(h=>h&&{...h,data:h.data.filter(d=>d.id!==c)})},[r,t,s]);return{sessions:(n==null?void 0:n.data)||[],loading:!n&&!a,error:a,createSession:p,deleteSession:g,refetch:async()=>{await s()}}}const Qi=i.createContext(void 0);function Uo(){const t=i.useContext(Qi);if(!t)throw new Error("useAgentConversationContext must be used within AgentConversationProvider");return t}function Id({children:t,agentName:r,token:o,platformAdapter:n,defaultSessionId:a,onSessionCreated:s,onSessionDeleted:p,onError:g}){const[c,h]=i.useState(a?{id:a,title:"Conversation",status:"idle",last_activity_at:new Date().toISOString(),created_at:new Date().toISOString()}:null),[d,l]=i.useState(!1),{sessions:m,loading:x,error:v,createSession:w,deleteSession:C,refetch:$}=Ki(o);i.useEffect(()=>{if(a&&m.length>0){const b=m.find(f=>f.id===a);b&&h(b)}},[a,m]);const y=i.useCallback(b=>{h(b),l(!1)},[]),z=i.useCallback(async b=>{try{const f=b||`Chat ${new Date().toLocaleDateString()} ${new Date().toLocaleTimeString()}`,I=await w({title:f});return h(I),s==null||s(I),I}catch(f){const I=f instanceof Error?f.message:"Failed to create session";throw g==null||g(I),f}},[w,s,g]),_=i.useCallback(async b=>{try{await C(b),(c==null?void 0:c.id)===b&&h(null),p==null||p(b)}catch(f){const I=f instanceof Error?f.message:"Failed to delete session";throw g==null||g(I),f}},[C,c,p,g]),k={agentName:r,token:o,platformAdapter:n,sessions:m,selectedSession:c,loadingSessions:x,sessionError:v,selectSession:y,createSession:z,deleteSession:_,refreshSessions:$,showHistory:d,setShowHistory:l,onSessionCreated:s,onSessionDeleted:p,onError:g};return e.jsx(Qi.Provider,{value:k,children:t})}var Xi=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(Xi||{});function Td(t,r,o){const n={username:Od(t,r,o),email:Md(t,r,o),phone:Ld(t,r,o),email_otp:Ad(t,r,o),magic_link:Dd(t,r,o),oauth:Nd(t,o),generic:Fd(t,r,o)};return function(s){return n[s]}}function Od(t,r,o){return async({username:n,password:a})=>{var c,h;const s=new FormData;s.append("strategy","plain_username"),s.append("username",n),s.append("password",a);const p=await t("/auth/signin",{method:"POST",body:s}),g=await V(p);return"data"in g&&((h=(c=g.data)==null?void 0:c.signin_attempts)!=null&&h.length)?(r(g.data.signin_attempts.at(-1)||null),o(null)):o(g),g}}function Md(t,r,o){return async({email:n,password:a})=>{var c,h;const s=new FormData;s.append("strategy","plain_email"),s.append("email",n),s.append("password",a);const p=await t("/auth/signin",{method:"POST",body:s}),g=await V(p);return"data"in g&&((h=(c=g.data)==null?void 0:c.signin_attempts)!=null&&h.length)?(r(g.data.signin_attempts.at(-1)||null),o(null)):o(g),g}}function Ld(t,r,o){return async({phone:n})=>{var g,c;const a=new FormData;a.append("strategy","phone_otp"),a.append("phone",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await V(s);return"data"in p&&((c=(g=p.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(p.data.signin_attempts.at(-1)||null),o(null)):o(p),p}}function Ad(t,r,o){return async({email:n})=>{var g,c;const a=new FormData;a.append("strategy","email_otp"),a.append("email",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await V(s);return"data"in p&&((c=(g=p.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(p.data.signin_attempts.at(-1)||null),o(null)):o(p),p}}function Dd(t,r,o){return async({email:n})=>{var g,c;const a=new FormData;a.append("strategy","magic_link"),a.append("email",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await V(s);return"data"in p&&((c=(g=p.data)==null?void 0:g.signin_attempts)!=null&&c.length)?(r(p.data.signin_attempts.at(-1)||null),o(null)):o(p),p}}function Nd(t,r){return async({provider:o,redirectUri:n})=>{const a=new URLSearchParams({provider:o});n&&a.append("redirect_uri",n);const s=await t(`/auth/oauth2/init?${a.toString()}`,{method:"POST"}),p=await V(s);return"data"in p?(r(null),p.data.oauth_url&&(window.location.href=p.data.oauth_url)):r(p),p}}function Fd(t,r,o){return async({email:n,username:a,password:s,phone:p,strategy:g,token:c})=>{var m,x;const h=new FormData;g&&h.append("strategy",g),n&&h.append("email",n),a&&h.append("username",a),s&&h.append("password",s),p&&h.append("phone",p),c&&h.append("token",c);const d=await t("/auth/signin",{method:"POST",body:h}),l=await V(d);return"data"in l&&((x=(m=l.data)==null?void 0:m.signin_attempts)!=null&&x.length)?(r(l.data.signin_attempts.at(-1)||null),o(null)):o(l),l}}function Ji(){const{client:t,loading:r}=De(),[o,n]=i.useState(null),[a,s]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null),s(null)},setSignInAttempt:n,error:null}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Td(t,n,s),completeVerification:async p=>{var d,l,m,x;const g=new FormData;g.append("verification_code",p);const c=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:g}),h=await V(c);if("data"in h&&((l=(d=h.data)==null?void 0:d.signin_attempts)!=null&&l.length)){const v=h.data.signin_attempts.at(-1);return n(v||null),s(null),h.data}else throw"errors"in h?(s(h),new Error(((x=(m=h.errors)==null?void 0:m[0])==null?void 0:x.message)||"Verification failed")):new Error("Verification failed")},prepareVerification:async p=>{var h;const g=new URL("/auth/prepare-verification",window.location.origin);g.searchParams.set("attempt_identifier",((h=o==null?void 0:o.id)==null?void 0:h.toString())||""),g.searchParams.set("strategy",p.strategy),g.searchParams.set("identifier_type","signin"),p.strategy==="phone_otp"&&p.lastDigits?g.searchParams.set("last_digits",p.lastDigits):(p.strategy==="email_otp"&&p.redirectUri||p.strategy==="magic_link"&&p.redirectUri)&&g.searchParams.set("redirect_uri",p.redirectUri);const c=await t(g.pathname+g.search,{method:"POST"});return V(c)},completeProfile:async p=>{var d;if(!o)throw new Error("No signin attempt found");const g=new FormData;for(const[l,m]of Object.entries(p))m&&g.append(l,m);const c=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:g}),h=await V(c);if("data"in h&&h.data){const l=(d=h.data.signin_attempts)==null?void 0:d.find(m=>m.id===o.id);return l&&n(l),s(null),h.data}else throw new Error("Profile completion failed")}},discardSignInAttempt:()=>{n(null),s(null)},setSignInAttempt:n,error:a}}function Ar(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:a,setSignInAttempt:s,error:p}=Ji();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:a,setSignInAttempt:s,error:null};const g=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:g,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile},discardSignInAttempt:a,setSignInAttempt:s,error:p}}function Bd(t,r,o,n){return{create:async a=>{var c,h,d;const s=new FormData;for(const[l,m]of Object.entries(a))s.append(l,m);const p=await t("/auth/signup",{method:"POST",body:s}),g=await V(p);return"data"in g&&((h=(c=g.data)==null?void 0:c.signup_attempts)!=null&&h.length)?(o(((d=g.data.signup_attempts)==null?void 0:d.at(-1))||null),n(null)):n(g),g},prepareVerification:async a=>{var g;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((g=r==null?void 0:r.id)==null?void 0:g.toString())||""),s.searchParams.set("strategy",a.strategy),s.searchParams.set("identifier_type","signup"),a.strategy==="phone_otp"&&a.lastDigits?s.searchParams.set("last_digits",a.lastDigits):a.strategy==="email_otp"&&a.redirectUri&&s.searchParams.set("redirect_uri",a.redirectUri);const p=await t(s.pathname+s.search,{method:"POST"});return V(p)},completeVerification:async a=>{var c,h,d,l;const s=new FormData;s.append("verification_code",a);const p=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:s}),g=await V(p);if("data"in g&&((h=(c=g.data)==null?void 0:c.signup_attempts)!=null&&h.length))o(g.data.signup_attempts.at(-1)||null),n(null);else if("errors"in g)throw n(g),new Error(((l=(d=g.errors)==null?void 0:d[0])==null?void 0:l.message)||"Verification failed");return g},validateDeploymentInvitation:async a=>{try{const s=await t(`/deployment/invitations/validate?token=${encodeURIComponent(a)}`,{method:"GET"}),p=await V(s);return"data"in p&&p.data?p.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(s){return{valid:!1,message:s.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function ec(){const{client:t,loading:r}=De(),[o,n]=i.useState(null),[a,s]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null),s(null)},errors:null}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null),s(null)},signUp:Bd(t,o,n,s),errors:a}}const He=()=>{const{adapter:t,deployment:r}=ve(),o=t.useNavigate(),n=(p,g)=>{o?o(p,g):window.location.href=p};return{navigate:n,navigateToSignIn:p=>{if(!r)return;const g=p||window.location.href,c=new URLSearchParams;c.set("redirect_uri",g),(r==null?void 0:r.mode)==="staging"&&c.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${c.toString()}`,{replace:!0})},navigateToSignUp:p=>{if(!r)return;const g=p||window.location.href,c=new URLSearchParams;c.set("redirect_uri",g),(r==null?void 0:r.mode)==="staging"&&c.set("dev_session",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${c.toString()}`,{replace:!0})}}};async function Ud(t){const r=await t("/session",{method:"GET"});return(await V(r)).data}async function Wd(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return V(o)}async function Vd(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return V(n)}async function Gd(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return V(o)}async function Hd(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return V(o)}const Jn=new Map,Ir=new Map;function Qt(){Jn.clear(),Ir.clear()}async function qd(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return V(o)}function Fe(){const{client:t,loading:r}=De(),{deployment:o}=ve(),{navigate:n}=He(),{data:a,error:s,mutate:p,isLoading:g}=We(r?null:"/session",()=>Ud(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),c=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]),h=i.useCallback(async(l="default")=>{var v;if(!a)throw new Error("no session");const m=Jn.get(l);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";Ir.get(l)||Ir.set(l,qd(t,l));const x=await Ir.get(l);if(Ir.delete(l),(v=x.errors)!=null&&v.length)throw new Error(x.errors[0].message);return Jn.set(l,x.data),x.data.token},[t,a==null?void 0:a.active_signin]),d=i.useCallback(()=>{if(!o)return;const l=o.ui_settings.sign_in_page_url,m=window.location.href,x=new URL(l);if(x.searchParams.set("redirect_uri",m),o.mode==="staging"){const v=localStorage.getItem("__dev_session__");v&&x.searchParams.set("dev_session",v)}n(x.toString())},[o,n]);return r||!a||g?{loading:!0,error:s,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,addNewAccount:null,refetch:c}:{loading:g,error:s,session:a,switchSignIn:async l=>{await Wd(t,l),await p(void 0,{revalidate:!0})},signOut:async l=>{await Vd(t,l),await p(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(l&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!l&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async l=>{await Gd(t,l),Qt(),await p(void 0,{revalidate:!0})},switchWorkspace:async l=>{await Hd(t,l),Qt(),await p(void 0,{revalidate:!0})},getToken:h,addNewAccount:d,refetch:c}}const Wo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=bt(),{client:n}=De(),{refetch:a}=Fe(),s=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/roles`,{method:"GET"}))).data,[n]),p=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/members`,{method:"GET"}))).data,[n]),g=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/domains`,{method:"GET"}))).data,[n]),h=i.useCallback(async(j,S)=>{await n(`/organizations/${j.id}/members/${S.id}/remove`,{method:"POST"}),await r()},[r,n]),d=i.useCallback(async j=>{const S=new FormData;S.append("name",j.name),j.image&&S.append("image",j.image),j.description&&S.append("description",j.description);const R=await V(await n("/organizations",{method:"POST",body:S}));return Qt(),await r(),await a(),R},[a,r,n]),l=i.useCallback(async(j,S)=>{const R=Object.entries(S).reduce((T,[P,O])=>(O&&T.append(P,O),T),new FormData),E=await V(await n(`/organizations/${j.id}/update`,{method:"POST",body:R}));return await r(),E},[r,n]),m=i.useCallback(async(j,S)=>{await n(`/organizations/${j.id}/roles/${S.id}/remove`,{method:"POST"})},[n]),x=i.useCallback(async(j,S)=>{const R=new FormData;return R.append("domain",S.fqdn),await V(await n(`/organizations/${j.id}/domains`,{method:"POST",body:R}))},[n]),v=i.useCallback(async(j,S)=>await V(await n(`/organizations/${j.id}/domains/${S.id}/verify`,{method:"POST"})),[n]),w=i.useCallback(async(j,S)=>await V(await n(`/organizations/${j.id}/domains/${S.id}/remove`,{method:"POST"})),[n]),C=i.useCallback(async(j,S)=>{const R=new FormData;return R.append("name",S.name),S.permissions&&S.permissions.forEach((T,P)=>{R.append(`permissions[${P}]`,T)}),await V(await n(`/organizations/${j.id}/roles`,{method:"POST",body:R}))},[n]),$=i.useCallback(async j=>(await V(await n(`/organizations/${j.id}/leave`,{method:"POST"}))).data,[n]),y=i.useCallback(async j=>{const S=await V(await n(`/organizations/${j.id}/delete`,{method:"POST"}));return Qt(),await r(),await a(),S.data},[n,r,a]),z=i.useCallback(async(j,S,R)=>(await V(await n(`/organizations/${j.id}/members/${S.id}/roles/${R.id}/add`,{method:"POST"}))).data,[n]),_=i.useCallback(async(j,S,R)=>(await V(await n(`/organizations/${j.id}/members/${S.id}/roles/${R.id}/remove`,{method:"POST"}))).data,[n]),k=i.useCallback(async(j,S)=>{var T,P;const R=new FormData;return R.append("email",S.email),R.append("role_id",S.organizationRole.id),(T=S.workspace)!=null&&T.id&&R.append("workspace_id",S.workspace.id),(P=S.workspaceRole)!=null&&P.id&&R.append("workspace_role_id",S.workspaceRole.id),(await V(await n(`/organizations/${j.id}/invitations`,{method:"POST",body:R}))).data},[n]),b=i.useCallback(async(j,S)=>(await V(await n(`/organizations/${j.id}/invitations/${S.id}/remove`,{method:"POST"}))).data,[n]),f=i.useCallback(async(j,S)=>(await V(await n(`/organizations/${j.id}/invitations/${S.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(j=>j.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:$,getOrganizationRoles:s,getOrganizationMembers:p,removeOrganizationMember:h,createOrganization:d,getOrganizationInvitations:g,getOrganizationDomains:c,addOrganizationDomain:x,verifyOrganizationDomain:v,removeOrganizationDomain:w,addRoleToOrganizationMember:z,removeRoleFromOrganizationMember:_,inviteOrganizationMember:k,discardOrganizationInvitation:b,resendOrganizationInvitation:f,updateOrganization:l,addRole:C,removeOrganizationRoles:m,deleteOrganization:y}},Qe=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:a,leaveOrganization:s,removeOrganizationMember:p,getOrganizationInvitations:g,getOrganizationDomains:c,removeOrganizationDomain:h,addOrganizationDomain:d,verifyOrganizationDomain:l,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:x,inviteOrganizationMember:v,discardOrganizationInvitation:w,resendOrganizationInvitation:C,updateOrganization:$,removeOrganizationRoles:y}=Wo(),{session:z,error:_,loading:k}=Fe(),{organizationMemberships:b}=bt(),f=i.useMemo(()=>{var U;return((U=b==null?void 0:b.find(Z=>{var Q;return Z.id===((Q=z==null?void 0:z.active_signin)==null?void 0:Q.active_organization_membership_id)}))==null?void 0:U.organization)||null},[b,z]),I=i.useCallback(async U=>f?await $(f,U):[],[f,$]),j=i.useCallback(async()=>f?await n(f):[],[f,n]),S=i.useCallback(async()=>f?await a(f):[],[f,a]),R=i.useCallback(async U=>f?await p(f,U):[],[f,p]),E=i.useCallback(async U=>f?await y(f,U):void 0,[f,y]),T=i.useCallback(async()=>f?await c(f):[],[f,c]),P=i.useCallback(async U=>f?await d(f,U):void 0,[f,d]),O=i.useCallback(async U=>f?await l(f,U):void 0,[f,l]),D=i.useCallback(async U=>f?await h(f,U):void 0,[f,h]),M=i.useCallback(async(U,Z)=>f?await m(f,U,Z):void 0,[f,m]),N=i.useCallback(async(U,Z)=>f?await x(f,U,Z):void 0,[f,x]),F=i.useCallback(async U=>f?await v(f,U):void 0,[f,v]),J=i.useCallback(async U=>f?await w(f,U):void 0,[f,w]),ie=i.useCallback(async U=>f?await C(f,U):void 0,[f,C]),re=i.useCallback(async()=>{f&&await s(f)},[f,s]),X=i.useCallback(async()=>f?await g(f):[],[f,g]);return k||t?{activeOrganization:null,loading:!0,error:_||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null}:{activeOrganization:f,loading:!1,refetch:o,getRoles:S,updateOrganization:I,getMembers:j,getDomains:T,addDomain:P,verifyDomain:O,removeDomain:D,getInvitations:X,removeMember:R,leave:re,removeRole:E,addMemberRole:M,removeMemberRole:N,inviteMember:F,discardInvitation:J,resendInvitation:ie,error:null}};async function Yd(t){return(await V(await t("/me/organization-memberships"))).data}const bt=()=>{const{client:t,loading:r}=De(),{data:o,isLoading:n,error:a,mutate:s}=We(r?null:"/me/organization-memberships",()=>Yd(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),p=i.useCallback(async()=>{await s(void 0,{revalidate:!0})},[s]);return{organizationMemberships:o,loading:r||n,error:a,refetch:p}};async function Zd(t){return(await V(await t("/me/workspace-memberships"))).data}async function Kd(t,r,o){return(await V(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Vo=()=>{const{client:t,loading:r}=De(),{deployment:o}=ve(),{data:n,isLoading:a,error:s,mutate:p}=We(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>Zd(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),g=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]);return{workspaceMemberships:n,loading:r||a,error:s,refetch:g}},yt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Vo(),{client:a}=De(),s=i.useMemo(()=>t==null?void 0:t.map(y=>({...y.workspace,organization:y.organization,eligibility_restriction:y.eligibility_restriction})),[t]),p=i.useCallback(async(y,z,_,k)=>{const b=new FormData;b.append("name",z),_&&b.append("image",_),k&&b.append("description",k),b.append("organization_id",y);const f=await a("/workspaces",{method:"POST",body:b});return Qt(),await r(),f},[a,r]),g=i.useCallback(async(y,z)=>{const _=await Kd(a,y,z);return await r(),_},[a,r]),c=i.useCallback(async(y,z)=>{const _=new FormData;z.name&&_.append("name",z.name),z.description&&_.append("description",z.description),z.image&&_.append("image",z.image);const k=await V(await a(`/workspaces/${y.id}/update`,{method:"POST",body:_}));return await r(),k.data},[a,r]),h=i.useCallback(async y=>{const z=await V(await a(`/workspaces/${y.id}/delete`,{method:"POST"}));return Qt(),await r(),z.data},[a,r]),d=i.useCallback(async y=>(await V(await a(`/workspaces/${y.id}/members`,{method:"GET"}))).data,[a]),l=i.useCallback(async y=>(await V(await a(`/workspaces/${y.id}/roles`,{method:"GET"}))).data,[a]),m=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/roles`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:z,permissions:_})}))).data,[a]),x=i.useCallback(async(y,z)=>(await V(await a(`/workspaces/${y.id}/roles/${z.id}/delete`,{method:"POST"}))).data,[a]),v=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/members`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:z,role_id:_})}))).data,[a]),w=i.useCallback(async(y,z)=>{const _=await V(await a(`/workspaces/${y.id}/members/${z}/remove`,{method:"POST"}));return await r(),_.data},[a,r]),C=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/members/${z}/roles/${_}`,{method:"POST"}))).data,[a]),$=i.useCallback(async(y,z,_)=>(await V(await a(`/workspaces/${y.id}/members/${z}/roles/${_}/remove`,{method:"POST"}))).data,[a]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:g,createWorkspace:p,updateWorkspace:c,deleteWorkspace:h,getWorkspaceMembers:d,getWorkspaceRoles:l,createWorkspaceRole:m,deleteWorkspaceRole:x,inviteWorkspaceMember:v,removeWorkspaceMember:w,addWorkspaceMemberRole:C,removeWorkspaceMemberRole:$}},Pt=()=>{const{refetch:t,loading:r,error:o,leaveWorkspace:n,updateWorkspace:a,deleteWorkspace:s,getWorkspaceMembers:p,getWorkspaceRoles:g,createWorkspaceRole:c,deleteWorkspaceRole:h,inviteWorkspaceMember:d,removeWorkspaceMember:l,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:x}=yt(),{workspaceMemberships:v}=Vo(),{session:w,loading:C,error:$}=Fe(),y=i.useMemo(()=>{var D;return((D=v==null?void 0:v.find(M=>{var N;return M.id===((N=w==null?void 0:w.active_signin)==null?void 0:N.active_workspace_membership_id)}))==null?void 0:D.workspace)||null},[v,w]),z=i.useCallback(async()=>{var D;if(!(!y||!((D=w==null?void 0:w.active_signin)!=null&&D.user_id)))return await n(y.id,w.active_signin.user_id)},[y,n,w]),_=i.useCallback(async D=>{if(y)return await a(y,D)},[y,a]),k=i.useCallback(async()=>{if(y)return await s(y)},[y,s]),b=i.useCallback(async()=>y?await p(y):[],[y,p]),f=i.useCallback(async()=>y?await g(y):[],[y,g]),I=i.useCallback(async(D,M)=>{if(y)return await c(y,D,M)},[y,c]),j=i.useCallback(async D=>{if(y)return await h(y,D)},[y,h]),S=i.useCallback(async(D,M)=>{if(y)return await d(y,D,M)},[y,d]),R=i.useCallback(async D=>{if(y)return await l(y,D)},[y,l]),E=i.useCallback(async(D,M)=>{if(y)return await m(y,D,M)},[y,m]),T=i.useCallback(async(D,M)=>{if(y)return await x(y,D,M)},[y,x]),P=r||C,O=o||$;return P?{activeWorkspace:null,loading:!0,error:O,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null}:{activeWorkspace:y,loading:!1,error:O,refetch:t,leave:z,updateWorkspace:_,deleteWorkspace:k,getMembers:b,getRoles:f,createRole:I,deleteRole:j,inviteMember:S,removeMember:R,addMemberRole:E,removeMemberRole:T}},Qd=async t=>(await V(await t("/me"))).data,Xd=async t=>(await V(await t("/me/signins"))).data;function rr(){const{client:t,loading:r}=De(),{data:o,error:n,isLoading:a,mutate:s}=We(r?null:"/user",()=>Qd(t)),p=async P=>{const O=new FormData;for(const[M,N]of Object.entries(P))N!=null&&N!==""&&O.append(M,String(N));const D=await V(await t("/me",{method:"POST",body:O}));return s(),D},g=async()=>await V(await t("/me/email-addresses",{method:"GET"})),c=async P=>await V(await t(`/me/email-addresses/${P}`,{method:"GET"})),h=async P=>{const O=new FormData;return O.append("email",P),await V(await t("/me/email-addresses",{method:"POST",body:O}))},d=async P=>await V(await t(`/me/email-addresses/${P}/delete`,{method:"POST"})),l=async P=>await V(await t(`/me/email-addresses/${P}/prepare-verification`,{method:"POST"})),m=async(P,O)=>await V(await t(`/me/email-addresses/${P}/attempt-verification?code=${O}`,{method:"POST"})),x=async(P,O)=>{const D=new FormData;return D.append("phone_number",P),D.append("country_code",O),await V(await t("/me/phone-numbers",{method:"POST",body:D}))},v=async P=>await V(await t(`/me/phone-numbers/${P}/delete`,{method:"POST"})),w=async P=>await V(await t(`/me/phone-numbers/${P}/prepare-verification`,{method:"POST"})),C=async(P,O)=>{const D=new FormData;return D.append("code",O),await V(await t(`/me/phone-numbers/${P}/attempt-verification`,{method:"POST",body:D}))},$=async P=>{const O=await V(await t(`/me/phone-numbers/${P}/make-primary`,{method:"POST"}));return s(),O},y=async P=>await V(await t(`/me/email-addresses/${P}/make-primary`,{method:"POST"})),z=async()=>(await V(await t("/me/authenticator",{method:"POST"}))).data,_=async(P,O)=>{const D=new FormData;return D.append("authenticator_id",P),O.forEach(N=>{D.append("codes",N)}),await V(await t("/me/authenticator/attempt-verification",{method:"POST",body:D}))},k=async P=>await V(await t(`/me/authenticator/${P}/delete`,{method:"POST"})),b=async()=>(await V(await t("/me/backup-codes",{method:"POST"}))).data,f=async P=>{const O=new FormData;return O.append("file",P),await V(await t("/me/profile-picture",{method:"POST",body:O}))},I=async()=>(await V(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,j=async(P,O)=>{const D=new FormData;return D.append("current_password",P),D.append("new_password",O),await V(await t("/me/update-password",{method:"POST",body:D}))},S=async P=>{const O=new FormData;O.append("current_password",P);const D=await V(await t("/me/remove-password",{method:"POST",body:O}));return s(),D},R=async P=>{const O=new FormData;return O.append("password",P),await V(await t("/me/account/delete",{method:"POST",body:O}))},E=async P=>await V(await t(`/me/social-connections/${P}/disconnect`,{method:"POST"})),T=async({provider:P,redirectUri:O})=>{var N;const D=new URLSearchParams({provider:P});O&&D.append("redirect_uri",O);const M=await V(await t(`/me/init-sso-connection?${D.toString()}`,{method:"POST"}));return"data"in M&&((N=M.data)!=null&&N.oauth_url)&&window.open(M.data.oauth_url,"_blank"),M};return{user:{...o,refetch:s},loading:r||a,error:n||null,updateProfile:p,getEmailAddresses:g,getEmailAddress:c,createEmailAddress:h,deleteEmailAddress:d,prepareEmailVerification:l,attemptEmailVerification:m,makeEmailPrimary:y,createPhoneNumber:x,deletePhoneNumber:v,preparePhoneVerification:w,attemptPhoneVerification:C,makePhonePrimary:$,setupAuthenticator:z,verifyAuthenticator:_,deleteAuthenticator:k,generateBackupCodes:b,regenerateBackupCodes:I,updateProfilePicture:f,disconnectSocialConnection:E,connectSocialAccount:T,updatePassword:j,removePassword:S,deleteAccount:R}}function tc(){const{client:t,loading:r}=De(),{data:o,error:n,isLoading:a,mutate:s}=We(r?null:"/me/signins",()=>Xd(t));return{signins:o,error:n||null,removeSignin:async g=>await V(await t(`/me/signins/${g}/signout`,{method:"POST"})),refetch:s,loading:a||r}}function Jd(){const{session:t,loading:r}=Fe(),{loading:o,organizationMemberships:n}=bt(),{loading:a,workspaceMemberships:s}=Vo();if(r||o||a)return{loading:!0,orgMembership:null,workspaceMembership:null};const p=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:n==null?void 0:n.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_organization_membership_id)}),[t]),g=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(c=>{var h;return c.id===((h=t.active_signin)==null?void 0:h.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:p,workspaceMembership:g}}function rc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),p=async g=>{n(!0),s(null);try{const c=new FormData;for(const[l,m]of Object.entries(g))m&&c.append(l,m);const h=await t("/waitlist/join",{method:"POST",body:c}),d=await V(h);return s(d.errors?d:null),d}catch(c){const h={data:null,errors:[{message:c instanceof Error?c.message:"Failed to join waitlist",code:Ve.ErrorCode.Unknown}]};return s(h),h}finally{n(!1)}};return r?{loading:!0,error:null,joinWaitlist:null}:{loading:o,error:a,joinWaitlist:p}}function oc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[p,g]=i.useState(null),[c,h]=i.useState(null),[d,l]=i.useState(!1),[m,x]=i.useState(null);i.useEffect(()=>{if(d||r)return;const w=new URLSearchParams(window.location.search),C=w.get("code"),$=w.get("state"),y=w.get("error"),z=w.get("error_description");if(!C&&!y){l(!0);const _=new Error("No OAuth callback data found.");s(_);return}if(l(!0),n(!0),y){const _=z||y,k=new Error(`OAuth Error: ${_}`);s(k),n(!1);return}if(C&&$)v(C,$);else{const _=new Error("Missing required OAuth parameters");s(_),n(!1)}},[d,r]);const v=async(w,C)=>{try{let $,y;try{const k=C.split(".");if(k.length!==2)throw new Error("Invalid OAuth state format - missing signature");const b=k[0].replace(/-/g,"+").replace(/_/g,"/"),f=b.length%4?"=".repeat(4-b.length%4):"",j=atob(b+f).split("|")[0];if(j==="sign_in")$="/auth/oauth2/callback",y="GET";else if(j==="connect_social")$="/me/sso-connection-callback",y="POST";else throw new Error(`Unknown OAuth action: ${j}`)}catch(k){const b=k instanceof Error?k:new Error("Failed to parse OAuth state");s(new Error(`Invalid OAuth callback: ${b.message}. The authorization link may be expired or malformed. Please try signing in again.`)),n(!1);return}const z=await t(`${$}?code=${encodeURIComponent(w)}&state=${encodeURIComponent(C)}`,{method:y}),_=await V(z);if("data"in _){const k=_.data.session,b=_.data.redirect_uri||null;if(g(k),h(b),k.signin_attempts&&k.signin_attempts.length>0){const f=k.signin_attempts.at(-1);f&&x(f)}}else{const k=new Error("SSO callback failed");s(k)}}catch($){const y=$ instanceof Error?$:new Error("Unknown error occurred");s(y)}finally{n(!1)}};return{loading:o,error:a,session:p,redirectUri:c,processed:d,signinAttempt:m}}function nc(){const{client:t,loading:r}=De(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[p,g]=i.useState(null);return{loading:r||o,verifyMagicLink:async h=>{if(!h.token||!h.attempt){const d=new Error("Invalid magic link parameters");return s(d),{data:void 0,errors:[{message:d.message,code:Ve.ErrorCode.BadRequestBody}]}}n(!0),s(null),g(null);try{const d=new URL("/auth/verify-magic-link",window.location.origin);d.searchParams.set("token",h.token),d.searchParams.set("attempt",h.attempt),h.redirectUri&&d.searchParams.set("redirect_uri",h.redirectUri);const l=await t(d.pathname+d.search,{method:"GET"}),m=await V(l);if(n(!1),"errors"in m&&m.errors){const x=new Error(m.errors[0].message);s(x),g(!1)}else g(!0);return m}catch(d){n(!1);const l=d instanceof Error?d:new Error("Magic link verification failed");return s(l),g(!1),{data:void 0,errors:[{message:l.message,code:Ve.ErrorCode.Internal}]}}},error:a,success:p}}function ac(){const[t,r]=i.useState({});return i.useEffect(()=>{const o=new URLSearchParams(window.location.search);r({token:o.get("token")||void 0,attempt:o.get("attempt")||void 0,redirectUri:o.get("redirect_uri")||void 0})},[]),t}function sc(){const{client:t,loading:r}=De(),[o,n]=i.useState(null);return{error:o,loading:r,forgotPassword:async g=>{n(null);const c=new FormData;c.append("email",g);const h=await t("/auth/forgot-password",{method:"POST",body:c}),d=await V(h);return"errors"in d&&d.errors&&n(new Error(d.errors[0].message)),d},verifyOtp:async(g,c)=>{n(null);const h=new FormData;h.append("email",g),h.append("otp",c);const d=await t("/auth/forgot-password",{method:"POST",body:h}),l=await V(d);return"errors"in l&&l.errors&&n(new Error(l.errors[0].message)),l},resetPassword:async(g,c)=>{n(null);const h=new FormData;h.append("token",g),h.append("password",c);const d=await t("/auth/reset-password",{method:"POST",body:h}),l=await V(d);return"errors"in l&&l.errors&&n(new Error(l.errors[0].message)),l}}}function ic({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:a,onError:s,reconnectDelay:p=1e3,maxReconnectAttempts:g=5}={}){const{session:c,loading:h}=Fe(),{deployment:d,loading:l}=ve(),[m,x]=i.useState(!1),[v,w]=i.useState(null),C=i.useRef(null),$=i.useRef(null),y=i.useRef(0),z=i.useRef(null),_=i.useRef(a),k=i.useRef(s),b=i.useRef(r),f=i.useRef(o),I=i.useRef(n),j=i.useRef(p),S=i.useRef(g);_.current=a,k.current=s,b.current=r,f.current=o,I.current=n,j.current=p,S.current=g;const R=i.useCallback(()=>{$.current&&(clearTimeout($.current),$.current=null),z.current&&(clearInterval(z.current),z.current=null),C.current&&(C.current.close(),C.current=null)},[]),E=i.useCallback(async()=>{var N;if(!t||h||l||!c||!d)return;R();const O=new URL(d.backend_host),D=O.protocol==="https:"?"wss:":"ws:",M=new URL("/realtime/notifications",`${D}//${O.host}`);if(d.mode==="staging"){const F=localStorage.getItem("__dev_session__");F&&M.searchParams.set("__dev_session__",F)}b.current&&b.current.length>0&&b.current.forEach(F=>M.searchParams.append("channels",F)),f.current&&f.current.length>0&&f.current.forEach(F=>M.searchParams.append("organization_ids",F.toString())),I.current&&I.current.length>0&&I.current.forEach(F=>M.searchParams.append("workspace_ids",F.toString()));try{const F=new WebSocket(M.toString());C.current=F,F.onopen=()=>{x(!0),w(null),y.current=0,z.current=setInterval(()=>{F.readyState===WebSocket.OPEN&&F.send("ping")},3e4)},F.onmessage=J=>{var ie,re;try{const X=JSON.parse(J.data);if(X.type==="notification"&&X.data)(ie=_.current)==null||ie.call(_,X.data);else if(X.type==="error"){const U=X.error||"Unknown error occurred";w(U),(re=k.current)==null||re.call(k,U)}else X.type}catch{}},F.onerror=()=>{var J;w("Connection error occurred"),(J=k.current)==null||J.call(k,"Connection error occurred")},F.onclose=J=>{var ie;if(x(!1),z.current&&(clearInterval(z.current),z.current=null),t&&J.code!==1e3&&y.current<S.current){y.current++;const re=j.current*Math.pow(2,y.current-1);$.current=setTimeout(()=>{E()},re)}else y.current>=S.current&&(w("Max reconnection attempts reached"),(ie=k.current)==null||ie.call(k,"Max reconnection attempts reached"))}}catch{w("Failed to connect"),(N=k.current)==null||N.call(k,"Failed to connect")}},[t,h,l,c,d,R]);i.useEffect(()=>(E(),()=>{R()}),[E,R]),i.useEffect(()=>{C.current&&C.current.readyState===WebSocket.OPEN&&E()},[r,o,n,E]);const T=i.useCallback(()=>{R(),x(!1)},[R]),P=i.useCallback(()=>{y.current=0,E()},[E]);return{isConnected:m,connectionError:v,disconnect:T,reconnect:P}}async function eu(t,r){const o=new URLSearchParams;r&&(r.limit&&o.append("limit",r.limit.toString()),r.offset&&o.append("offset",r.offset.toString()),r.channels&&r.channels.forEach(p=>o.append("channels",p)),r.organization_ids&&r.organization_ids.forEach(p=>o.append("organization_ids",p.toString())),r.workspace_ids&&r.workspace_ids.forEach(p=>o.append("workspace_ids",p.toString())),r.is_read!==void 0&&o.append("is_read",r.is_read.toString()),r.is_archived!==void 0&&o.append("is_archived",r.is_archived.toString()),r.severity&&o.append("severity",r.severity));const n=`/notifications${o.toString()?"?"+o.toString():""}`,a=await t(n,{method:"GET"});return(await V(a)).data}async function tu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await V(r)).data}async function ru(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return V(o)}async function ou(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return V(r)}async function nu(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return V(o)}function cc(t){const{client:r,loading:o}=De(),{data:n,error:a,mutate:s,isLoading:p}=We(o?null:["notifications",JSON.stringify(t)],()=>eu(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});ic({enabled:!o&&!!n,onNotification:i.useCallback(l=>{s(async m=>!m||m.notifications.some(v=>v.id===l.id.toString())?m:{...m,notifications:[{id:l.id.toString(),user_id:l.user_id.toString(),deployment_id:l.deployment_id.toString(),title:l.title,body:l.body,severity:l.severity,action_url:l.action_url,action_label:l.action_label,is_read:!1,is_archived:!1,created_at:l.created_at,updated_at:l.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[s]),onError:i.useCallback(()=>{},[])});const g=i.useCallback(async l=>{o||(await s(async m=>m&&{...m,notifications:m.notifications.map(x=>x.id===l?{...x,is_read:!0}:x),unread_count:Math.max(0,m.unread_count-1)},!1),await ru(r,l),await s())},[r,o,s]),c=i.useCallback(async()=>{o||(await s(async l=>l&&{...l,notifications:l.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await ou(r),await s())},[r,s]),h=i.useCallback(async l=>{o||(await s(async m=>{if(!m)return m;const x=m.notifications.find(v=>v.id===l);return{...m,notifications:m.notifications.filter(v=>v.id!==l),unread_count:x&&!x.is_read?Math.max(0,m.unread_count-1):m.unread_count,total:Math.max(0,m.total-1)}},!1),await nu(r,l),await s())},[r,o,s]),d=i.useCallback(async()=>{await s()},[s]);return!n||o||p?{loading:!0,notifications:void 0,unreadCount:void 0,unreadCounts:void 0,channels:void 0,hasMore:void 0,markAsRead:void 0,markAllAsRead:void 0,deleteNotification:void 0,error:a,refetch:d}:{loading:!1,error:a,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:g,markAllAsRead:c,deleteNotification:h,refetch:d}}async function au(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await V(r)).data}function su(){const{client:t,loading:r}=De(),{data:o,error:n,mutate:a}=We(r?null:["notifications","channel-counts"],()=>au(t),{refreshInterval:3e4,revalidateOnFocus:!0}),s=async()=>{await a()};return!o||r?{loading:!0,counts:void 0,error:n,refetch:s}:{loading:!1,counts:o,error:n,refetch:s}}const Gt=class Gt{constructor(){Xe(this,"ws",null);Xe(this,"messageHandlers",new Set);Xe(this,"connectionStateHandlers",new Set);Xe(this,"reconnectTimer",null);Xe(this,"reconnectAttempts",0);Xe(this,"url",null);Xe(this,"isIntentionalDisconnect",!1);Xe(this,"sessionMessages",{});Xe(this,"currentSessionKey",null)}static getInstance(){return Gt.instance||(Gt.instance=new Gt),Gt.instance}connect(r){var o,n;if(this.url=r,this.isIntentionalDisconnect=!1,((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN&&this.url===r){this.notifyConnectionState({isConnected:!0});return}((n=this.ws)==null?void 0:n.readyState)!==WebSocket.CONNECTING&&this.createConnection()}createConnection(){if(this.url)try{this.ws=new WebSocket(this.url),this.ws.onopen=()=>{this.reconnectAttempts=0,this.notifyConnectionState({isConnected:!0})},this.ws.onmessage=r=>{try{const o=JSON.parse(r.data);this.notifyMessageHandlers(o)}catch{}},this.ws.onerror=()=>{this.notifyConnectionState({isConnected:!1,error:"Connection error"})},this.ws.onclose=()=>{this.ws=null,this.notifyConnectionState({isConnected:!1}),this.isIntentionalDisconnect||this.scheduleReconnect()}}catch(r){this.notifyConnectionState({isConnected:!1,error:r instanceof Error?r.message:"Failed to connect"})}}scheduleReconnect(){this.reconnectAttempts++;const r=Math.min(1e3*Math.pow(2,this.reconnectAttempts-1),3e4),o=Math.random()*.3*r,n=Math.floor(r+o);this.reconnectTimer=setTimeout(()=>{this.createConnection()},n)}disconnect(){this.isIntentionalDisconnect=!0,this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.ws&&(this.ws.close(),this.ws=null)}send(r){var o;if(((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN){const n=JSON.stringify(r);this.ws.send(n)}}onMessage(r){return this.messageHandlers.add(r),()=>{this.messageHandlers.delete(r)}}onConnectionStateChange(r){var o;return this.connectionStateHandlers.add(r),r({isConnected:((o=this.ws)==null?void 0:o.readyState)===WebSocket.OPEN}),()=>{this.connectionStateHandlers.delete(r)}}notifyMessageHandlers(r){this.messageHandlers.forEach(o=>{try{o(r)}catch{}})}notifyConnectionState(r){this.connectionStateHandlers.forEach(o=>{try{o(r)}catch{}})}isConnected(){var r;return((r=this.ws)==null?void 0:r.readyState)===WebSocket.OPEN}setCurrentSession(r){this.currentSessionKey=r,this.sessionMessages[r]||(this.sessionMessages[r]=[])}addMessage(r){this.currentSessionKey&&(this.sessionMessages[this.currentSessionKey]||(this.sessionMessages[this.currentSessionKey]=[]),this.sessionMessages[this.currentSessionKey].push(r))}getSessionMessages(r){return this.sessionMessages[r]||[]}clearSessionMessages(r){this.sessionMessages[r]&&(this.sessionMessages[r]=[])}};Xe(Gt,"instance");let ea=Gt;const Ye=ea.getInstance(),xt={DISCONNECTED:"disconnected",CONNECTING:"connecting",CONNECTED:"connected",ERROR:"error"},Me={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Tt={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Da(t){switch(t){case Tt.IDLE:return Me.IDLE;case Tt.STARTING:return Me.STARTING;case Tt.RUNNING:return Me.RUNNING;case Tt.WAITING_FOR_INPUT:return Me.WAITING_FOR_INPUT;case Tt.COMPLETED:return Me.COMPLETED;case Tt.FAILED:case Tt.CANCELLED:return Me.FAILED;default:return Me.IDLE}}function Na(t){return t===Me.STARTING||t===Me.RUNNING||t===Me.WAITING_FOR_INPUT}function lc({contextId:t,agentName:r,token:o,platformAdapter:n,autoConnect:a=!0}){const{deployment:s}=ve(),{client:p}=De(),[g,c]=i.useState([]),[h,d]=i.useState(null),[l,m]=i.useState(null),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState(Me.IDLE),[z,_]=i.useState({status:xt.DISCONNECTED}),[k,b]=i.useState(!0),[f,I]=i.useState(!1),j=i.useRef(null),S=i.useRef(null),R=i.useCallback(X=>{var U,Z;switch(X.message_type){case"session_connected":if(v(!0),_({status:xt.CONNECTED}),(U=X.data)!=null&&U.execution_status){const ae=X.data.execution_status,oe=Da(ae);y(oe),C(Na(oe))}break;case"conversation_message":E(X.data);break;case"user_input_request":T(X.data);break;case"platform_event":P(X.data);break;case"platform_function":O(X.data);break;case"execution_complete":C(!1),y(Me.IDLE),S.current=null;break;case"execution_error":C(!1),y(Me.FAILED),S.current=null;break;case"execution_cancelled":C(!1),y(Me.IDLE),S.current=null;break;case"execution_status":const Q=(Z=X.data)==null?void 0:Z.status;if(Q){const ae=Da(Q);y(ae),C(Na(ae))}break}},[h]),E=i.useCallback(X=>{var oe,ce,Y,se,q,H,A,B;const{id:U,message_type:Z,content:Q}=X,ae=L=>g.some(W=>W.id===L);if(Z==="system_decision"||Z==="action_execution_result"||Z==="assistant_task_breakdown"||Z==="assistant_validation"||Z==="assistant_action_planning"||Z==="context_results"){d(null),m(null);let L="";if(Z==="system_decision"){const W=Q==null?void 0:Q.step,ee=Q==null?void 0:Q.reasoning;if(W==="gathercontext")ee&&ee.length>0?L=ee.length>60?`${ee.substring(0,60)}...`:ee:L="Gathering context...";else if(W==="executeaction")L="Executing action";else if(W==="deliverresponse")L="Preparing response";else if(W==="taskplanning")L="Planning approach";else if(W==="validateprogress")L="Validating progress";else if(W==="acknowledge")L="Processing request";else if(W==="finishplanning")L="Finalizing plan";else if(W==="executetasks")L="Executing tasks";else if(W==="requestuserinput")L="Waiting for input";else if(W==="complete")L="Completed";else if(W==="examinetool")L="Examining tool";else if(W==="examineworkflow")L="Examining workflow";else{const pe=(Q==null?void 0:Q.confidence)||.5;pe>.8?L="Analyzing":pe>.6?L="Thinking":L="Reasoning"}}else if(Z==="action_execution_result")((oe=Q.task_execution)==null?void 0:oe.status)==="completed"?L="Task execution completed":(ce=Q.task_execution)!=null&&ce.approach?L=Q.task_execution.approach:L="Executing task";else if(Z==="assistant_task_breakdown")(Y=Q.task_breakdown)!=null&&Y.total_tasks?L=`Identified ${Q.task_breakdown.total_tasks} tasks`:L="Planning tasks";else if(Z==="assistant_validation")L="Validated results";else if(Z==="assistant_action_planning")(se=Q.task_execution)!=null&&se.total_tasks?L=`Planned ${Q.task_execution.total_tasks} tasks`:(H=(q=Q.task_execution)==null?void 0:q.tasks)!=null&&H.length?L=`Planned ${Q.task_execution.tasks.length} tasks`:L="Planning actions";else if(Z==="context_results"){const W=Q.query,ee=Q.result_count||0;W&&W!=="General context gathering"?L=`${W}: Found ${ee} results`:L=`Found ${ee} results`}L&&!ae(U)&&c(W=>[...W,{id:U,role:"system",content:L,timestamp:new Date,metadata:{type:"log",messageType:Z}}]);return}if(Z==="user_message")ae(U)||(d(null),m(null),c(L=>[...L,{id:U,role:"user",content:Q.message,images:Q.images,timestamp:new Date}]));else if(Z==="agent_response")ae(U)||(d(null),m(null),C(!1),y(Me.IDLE),S.current=null,c(L=>[...L,{id:U,role:"assistant",content:Q.response,timestamp:new Date,isStreaming:!1}]));else if(Z==="assistant_acknowledgment")ae(U)||(d(null),m(null),c(L=>[...L,{id:U,role:"assistant",content:Q.acknowledgment_message,timestamp:new Date}]));else if(Z==="assistant_ideation"||Z==="assistant_action_planning"||Z==="action_execution_result"||Z==="assistant_validation"||Z==="assistant_context_gathering"||Z==="assistant_task_breakdown"){let L="";if(Q.reasoning_summary)L=Q.reasoning_summary;else if((A=Q.task_execution)!=null&&A.approach)L=Q.task_execution.approach;else if(Q.strategic_synthesis)L=Q.strategic_synthesis;else if((B=Q.task_breakdown)!=null&&B.total_tasks)L=`Breaking down into ${Q.task_breakdown.total_tasks} tasks...`;else if(Q.acknowledgment_message)L=Q.acknowledgment_message;else return;c(W=>[...W,{id:U,role:"assistant",content:L,timestamp:new Date}])}else if(Z==="user_input_request"){const L={question:Q.question,context:Q.context,input_type:Q.input_type,options:Q.options||Q.suggestions,default_value:Q.default_value,placeholder:Q.placeholder};y("waiting_for_input"),c(W=>[...W,{id:U,role:"system",content:L.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:L}}])}},[]),T=i.useCallback(async X=>{y("waiting_for_input");const U=`input-request-${Date.now()}`;c(Z=>[...Z,{id:U,role:"system",content:X.question,timestamp:new Date,metadata:{type:"user_input_request",userInputRequest:X}}])},[]),P=i.useCallback(X=>{const{event_label:U,event_data:Z}=X;n!=null&&n.onPlatformEvent&&n.onPlatformEvent(U,Z)},[n]),O=i.useCallback(async X=>{const{function_name:U,function_data:Z}=X,{parameters:Q,execution_id:ae}=Z;if(!(n!=null&&n.onPlatformFunction)){Ye.send({message_type:{platform_function_result:[ae,{error:"No platform function handler registered"}]},data:{}});return}try{const oe=await n.onPlatformFunction(U,Q,ae),ce={message_type:{platform_function_result:[ae,oe]},data:{}};Ye.send(ce)}catch(oe){Ye.send({message_type:{platform_function_result:[ae,{error:oe instanceof Error?oe.message:"Function execution failed",stack:oe instanceof Error?oe.stack:void 0}]},data:{}})}},[n]);i.useEffect(()=>{if(!s)return;const U=`wss://${s==null?void 0:s.backend_host.replace(/https?:\/\//,"")}/realtime/agent?token=${encodeURIComponent(o)}`;_({status:xt.CONNECTING}),Ye.connect(U)},[s,o]),i.useEffect(()=>Ye.onConnectionStateChange(U=>{_({status:U.isConnected?xt.CONNECTED:U.error?xt.ERROR:xt.DISCONNECTED}),v(U.isConnected)}),[]),i.useEffect(()=>Ye.onMessage(R),[R]),i.useEffect(()=>{x&&t&&r&&a&&Ye.send({message_type:{session_connect:[t,r]},data:{}})},[x,t,r,a]);const D=i.useCallback(async()=>(x&&t&&r&&Ye.send({message_type:{session_connect:[t,r]},data:{}}),()=>{}),[x,t,r]),M=i.useCallback((X,U)=>{x&&(d(X),m(U||null),C(!0),y(Me.STARTING),Ye.send({message_type:{message_input:X},data:U?{images:U}:{}}))},[x]),N=i.useCallback(()=>{c([]),S.current=null},[]),F=i.useCallback(X=>{!x||$!==Me.WAITING_FOR_INPUT||(Ye.send({message_type:{user_input_response:X},data:{}}),y(Me.RUNNING))},[x,$]),J=i.useCallback(async X=>{var U;if(!(!o||!t))try{const Z=new URLSearchParams({token:o,limit:"50"});X&&(Z.append("before_id",X),I(!0));const ae=await(await p(`/api/agent/contexts/${t}/messages?${Z}`,{method:"GET"})).json();if(ae.status===200&&ae.data){const oe=ae.data;if(Array.isArray(oe.data)){const ce=oe.data.filter(Y=>{var H;let se=Y.content;if(typeof Y.content=="string")try{se=JSON.parse(Y.content)}catch{se={message:Y.content}}const q=((H=Y.metadata)==null?void 0:H.message_type)||(se==null?void 0:se.message_type);return q==="user_message"||q==="agent_response"||q==="assistant_acknowledgment"||q==="user_input_request"||q==="system_decision"||q==="action_execution_result"||q==="assistant_task_breakdown"||q==="assistant_validation"||q==="assistant_action_planning"||q==="context_results"}).map(Y=>{var L,W,ee,pe,Se,Ne,G;let se="",q,H,A=Y.content;if(typeof Y.content=="string")try{A=JSON.parse(Y.content)}catch{A=Y.content}const B=((L=Y.metadata)==null?void 0:L.message_type)||(A==null?void 0:A.message_type);if(B==="user_message"?(se=(A==null?void 0:A.message)||"",q=(A==null?void 0:A.images)||void 0):B==="agent_response"?se=(A==null?void 0:A.response)||"":B==="assistant_acknowledgment"?se=(A==null?void 0:A.acknowledgment_message)||"":B==="user_input_request"&&(se=(A==null?void 0:A.question)||"",H={type:"user_input_request",userInputRequest:{question:(A==null?void 0:A.question)||"",context:(A==null?void 0:A.context)||"",input_type:(A==null?void 0:A.input_type)||"text",options:(A==null?void 0:A.options)||(A==null?void 0:A.suggestions)||[],default_value:(A==null?void 0:A.default_value)||"",placeholder:(A==null?void 0:A.placeholder)||""}}),B==="system_decision"||B==="action_execution_result"||B==="assistant_task_breakdown"||B==="assistant_validation"||B==="assistant_action_planning"||B==="context_results"){let ne="";if(B==="system_decision"){const ye=A==null?void 0:A.step,be=A==null?void 0:A.reasoning;if(ye==="gathercontext")be&&be.length>0?ne=be.length>60?`${be.substring(0,60)}...`:be:ne="Gathering context...";else if(ye==="executeaction")ne="Executing action";else if(ye==="deliverresponse")ne="Preparing response";else if(ye==="taskplanning")ne="Planning approach";else if(ye==="validateprogress")ne="Validating progress";else if(ye==="acknowledge")ne="Processing request";else if(ye==="finishplanning")ne="Finalizing plan";else if(ye==="executetasks")ne="Executing tasks";else if(ye==="requestuserinput")ne="Waiting for input";else if(ye==="complete")ne="Completed";else if(ye==="examinetool")ne="Examining tool";else if(ye==="examineworkflow")ne="Examining workflow";else{const te=(A==null?void 0:A.confidence)||.5;te>.8?ne="Analyzing":te>.6?ne="Thinking":ne="Reasoning"}}else if(B==="action_execution_result")((W=A==null?void 0:A.task_execution)==null?void 0:W.status)==="completed"?ne="Task execution completed":(ee=A==null?void 0:A.task_execution)!=null&&ee.approach?ne=A.task_execution.approach:ne="Executing task";else if(B==="assistant_task_breakdown")(pe=A==null?void 0:A.task_breakdown)!=null&&pe.total_tasks?ne=`Identified ${A.task_breakdown.total_tasks} tasks`:ne="Planning tasks";else if(B==="assistant_validation")ne="Validated results";else if(B==="assistant_action_planning")(Se=A==null?void 0:A.task_execution)!=null&&Se.total_tasks?ne=`Planned ${A.task_execution.total_tasks} tasks`:(G=(Ne=A==null?void 0:A.task_execution)==null?void 0:Ne.tasks)!=null&&G.length?ne=`Planned ${A.task_execution.tasks.length} tasks`:ne="Planning actions";else if(B==="context_results"){const ye=A==null?void 0:A.query,be=(A==null?void 0:A.result_count)||0;ye&&ye!=="General context gathering"?ne=`${ye}: Found ${be} results`:ne=`Found ${be} results`}se=ne,H={type:"log",messageType:B}}return{id:Y.id,role:B==="user_message"?"user":B==="user_input_request"?"system":"assistant",content:se,images:q,timestamp:new Date(Y.timestamp||Y.created_at||Date.now()),metadata:H}}).filter(Y=>Y.content||Y.metadata||Y.images).sort((Y,se)=>{const q=BigInt(Y.id),H=BigInt(se.id);return q<H?-1:q>H?1:0});ce.length>0&&(j.current=ce[0].id),X?(c(Y=>[...ce,...Y]),b(ce.length>=50)):(c(ce),ce.length>0&&((U=ce[ce.length-1].metadata)==null?void 0:U.type)==="user_input_request"&&y(Me.WAITING_FOR_INPUT)),I(!1)}}}catch(Z){console.error("Failed to fetch messages:",Z),I(!1)}},[o,t,p]);i.useEffect(()=>{t&&o&&J()},[t,o]);const ie=i.useCallback(async()=>{if(!(f||!k||!j.current)){I(!0);try{await J(j.current)}finally{I(!1)}}},[f,k,J]),re=i.useCallback(()=>{!x||!w||(Ye.send({message_type:{cancel_execution:null},data:{}}),C(!1),y("idle"))},[x,w]);return{messages:g,pendingMessage:h,pendingImages:l,connectionState:z,isConnected:x,isExecuting:w,executionStatus:$,isWaitingForInput:$==="waiting_for_input",hasMoreMessages:k,isLoadingMore:f,sendMessage:M,submitUserInput:F,clearMessages:N,loadMoreMessages:ie,cancelExecution:re,connect:D,disconnect:()=>Ye.disconnect()}}const dc=()=>{const{client:t}=De(),[r,o]=i.useState(!1),[n,a]=i.useState(null),[s,p]=i.useState(null),g=i.useCallback(async h=>{o(!0),a(null),p(null);try{const d=await t("/organizations/invitations/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:h})}),m=(await V(d)).data;return p(m),m.error_code&&a(m.message||"Failed to accept invitation"),m}catch(d){const l=d.message||"Failed to accept invitation";a(l);const m={error_code:"NETWORK_ERROR",message:l};return p(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{a(null),p(null)},[]);return{acceptInvitation:g,invitationData:s,loading:r,error:n,reset:c}},iu=({children:t})=>{const{loading:r}=ve();return r?null:e.jsx(e.Fragment,{children:t})},cu=({children:t})=>{const{loading:r}=ve();return r?e.jsx(e.Fragment,{children:t}):null};var qe=function(){return qe=Object.assign||function(r){for(var o,n=1,a=arguments.length;n<a;n++){o=arguments[n];for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(r[s]=o[s])}return r},qe.apply(this,arguments)};function Xt(t,r,o){if(o||arguments.length===2)for(var n=0,a=r.length,s;n<a;n++)(s||!(n in r))&&(s||(s=Array.prototype.slice.call(r,0,n)),s[n]=r[n]);return t.concat(s||Array.prototype.slice.call(r))}function lu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var du=/^((children|dangerouslySetInnerHTML|key|ref|autoFocus|defaultValue|defaultChecked|innerHTML|suppressContentEditableWarning|suppressHydrationWarning|valueLink|abbr|accept|acceptCharset|accessKey|action|allow|allowUserMedia|allowPaymentRequest|allowFullScreen|allowTransparency|alt|async|autoComplete|autoPlay|capture|cellPadding|cellSpacing|challenge|charSet|checked|cite|classID|className|cols|colSpan|content|contentEditable|contextMenu|controls|controlsList|coords|crossOrigin|data|dateTime|decoding|default|defer|dir|disabled|disablePictureInPicture|disableRemotePlayback|download|draggable|encType|enterKeyHint|form|formAction|formEncType|formMethod|formNoValidate|formTarget|frameBorder|headers|height|hidden|high|href|hrefLang|htmlFor|httpEquiv|id|inputMode|integrity|is|keyParams|keyType|kind|label|lang|list|loading|loop|low|marginHeight|marginWidth|max|maxLength|media|mediaGroup|method|min|minLength|multiple|muted|name|nonce|noValidate|open|optimum|pattern|placeholder|playsInline|poster|preload|profile|radioGroup|readOnly|referrerPolicy|rel|required|reversed|role|rows|rowSpan|sandbox|scope|scoped|scrolling|seamless|selected|shape|size|sizes|slot|span|spellCheck|src|srcDoc|srcLang|srcSet|start|step|style|summary|tabIndex|target|title|translate|type|useMap|value|width|wmode|wrap|about|datatype|inlist|prefix|property|resource|typeof|vocab|autoCapitalize|autoCorrect|autoSave|color|incremental|fallback|inert|itemProp|itemScope|itemType|itemID|itemRef|on|option|results|security|unselectable|accentHeight|accumulate|additive|alignmentBaseline|allowReorder|alphabetic|amplitude|arabicForm|ascent|attributeName|attributeType|autoReverse|azimuth|baseFrequency|baselineShift|baseProfile|bbox|begin|bias|by|calcMode|capHeight|clip|clipPathUnits|clipPath|clipRule|colorInterpolation|colorInterpolationFilters|colorProfile|colorRendering|contentScriptType|contentStyleType|cursor|cx|cy|d|decelerate|descent|diffuseConstant|direction|display|divisor|dominantBaseline|dur|dx|dy|edgeMode|elevation|enableBackground|end|exponent|externalResourcesRequired|fill|fillOpacity|fillRule|filter|filterRes|filterUnits|floodColor|floodOpacity|focusable|fontFamily|fontSize|fontSizeAdjust|fontStretch|fontStyle|fontVariant|fontWeight|format|from|fr|fx|fy|g1|g2|glyphName|glyphOrientationHorizontal|glyphOrientationVertical|glyphRef|gradientTransform|gradientUnits|hanging|horizAdvX|horizOriginX|ideographic|imageRendering|in|in2|intercept|k|k1|k2|k3|k4|kernelMatrix|kernelUnitLength|kerning|keyPoints|keySplines|keyTimes|lengthAdjust|letterSpacing|lightingColor|limitingConeAngle|local|markerEnd|markerMid|markerStart|markerHeight|markerUnits|markerWidth|mask|maskContentUnits|maskUnits|mathematical|mode|numOctaves|offset|opacity|operator|order|orient|orientation|origin|overflow|overlinePosition|overlineThickness|panose1|paintOrder|pathLength|patternContentUnits|patternTransform|patternUnits|pointerEvents|points|pointsAtX|pointsAtY|pointsAtZ|preserveAlpha|preserveAspectRatio|primitiveUnits|r|radius|refX|refY|renderingIntent|repeatCount|repeatDur|requiredExtensions|requiredFeatures|restart|result|rotate|rx|ry|scale|seed|shapeRendering|slope|spacing|specularConstant|specularExponent|speed|spreadMethod|startOffset|stdDeviation|stemh|stemv|stitchTiles|stopColor|stopOpacity|strikethroughPosition|strikethroughThickness|string|stroke|strokeDasharray|strokeDashoffset|strokeLinecap|strokeLinejoin|strokeMiterlimit|strokeOpacity|strokeWidth|surfaceScale|systemLanguage|tableValues|targetX|targetY|textAnchor|textDecoration|textRendering|textLength|to|transform|u1|u2|underlinePosition|underlineThickness|unicode|unicodeBidi|unicodeRange|unitsPerEm|vAlphabetic|vHanging|vIdeographic|vMathematical|values|vectorEffect|version|vertAdvY|vertOriginX|vertOriginY|viewBox|viewTarget|visibility|widths|wordSpacing|writingMode|x|xHeight|x1|x2|xChannelSelector|xlinkActuate|xlinkArcrole|xlinkHref|xlinkRole|xlinkShow|xlinkTitle|xlinkType|xmlBase|xmlns|xmlnsXlink|xmlLang|xmlSpace|y|y1|y2|yChannelSelector|z|zoomAndPan|for|class|autofocus)|(([Dd][Aa][Tt][Aa]|[Aa][Rr][Ii][Aa]|x)-.*))$/,uu=lu(function(t){return du.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),ze="-ms-",Mr="-moz-",_e="-webkit-",uc="comm",Go="rule",ma="decl",pu="@import",pc="@keyframes",hu="@layer",hc=Math.abs,xa=String.fromCharCode,ta=Object.assign;function fu(t,r){return Be(t,0)^45?(((r<<2^Be(t,0))<<2^Be(t,1))<<2^Be(t,2))<<2^Be(t,3):0}function fc(t){return t.trim()}function mt(t,r){return(t=r.exec(t))?t[0]:t}function ge(t,r,o){return t.replace(r,o)}function _o(t,r,o){return t.indexOf(r,o)}function Be(t,r){return t.charCodeAt(r)|0}function hr(t,r,o){return t.slice(r,o)}function ct(t){return t.length}function gc(t){return t.length}function Tr(t,r){return r.push(t),t}function gu(t,r){return t.map(r).join("")}function Fa(t,r){return t.filter(function(o){return!mt(o,r)})}var Ho=1,fr=1,mc=0,Ze=0,Le=0,br="";function qo(t,r,o,n,a,s,p,g){return{value:t,root:r,parent:o,type:n,props:a,children:s,line:Ho,column:fr,length:p,return:"",siblings:g}}function St(t,r){return ta(qo("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function ar(t){for(;t.root;)t=St(t.root,{children:[t]});Tr(t,t.siblings)}function mu(){return Le}function xu(){return Le=Ze>0?Be(br,--Ze):0,fr--,Le===10&&(fr=1,Ho--),Le}function et(){return Le=Ze<mc?Be(br,Ze++):0,fr++,Le===10&&(fr=1,Ho++),Le}function qt(){return Be(br,Ze)}function Co(){return Ze}function Yo(t,r){return hr(br,t,r)}function ra(t){switch(t){case 0:case 9:case 10:case 13:case 32:return 5;case 33:case 43:case 44:case 47:case 62:case 64:case 126:case 59:case 123:case 125:return 4;case 58:return 3;case 34:case 39:case 40:case 91:return 2;case 41:case 93:return 1}return 0}function vu(t){return Ho=fr=1,mc=ct(br=t),Ze=0,[]}function bu(t){return br="",t}function fn(t){return fc(Yo(Ze-1,oa(t===91?t+2:t===40?t+1:t)))}function yu(t){for(;(Le=qt())&&Le<33;)et();return ra(t)>2||ra(Le)>3?"":" "}function wu(t,r){for(;--r&&et()&&!(Le<48||Le>102||Le>57&&Le<65||Le>70&&Le<97););return Yo(t,Co()+(r<6&&qt()==32&&et()==32))}function oa(t){for(;et();)switch(Le){case t:return Ze;case 34:case 39:t!==34&&t!==39&&oa(Le);break;case 40:t===41&&oa(t);break;case 92:et();break}return Ze}function ju(t,r){for(;et()&&t+Le!==57;)if(t+Le===84&&qt()===47)break;return"/*"+Yo(r,Ze-1)+"*"+xa(t===47?t:et())}function ku(t){for(;!ra(qt());)et();return Yo(t,Ze)}function _u(t){return bu(So("",null,null,null,[""],t=vu(t),0,[0],t))}function So(t,r,o,n,a,s,p,g,c){for(var h=0,d=0,l=p,m=0,x=0,v=0,w=1,C=1,$=1,y=0,z="",_=a,k=s,b=n,f=z;C;)switch(v=y,y=et()){case 40:if(v!=108&&Be(f,l-1)==58){_o(f+=ge(fn(y),"&","&\f"),"&\f",hc(h?g[h-1]:0))!=-1&&($=-1);break}case 34:case 39:case 91:f+=fn(y);break;case 9:case 10:case 13:case 32:f+=yu(v);break;case 92:f+=wu(Co()-1,7);continue;case 47:switch(qt()){case 42:case 47:Tr(Cu(ju(et(),Co()),r,o,c),c);break;default:f+="/"}break;case 123*w:g[h++]=ct(f)*$;case 125*w:case 59:case 0:switch(y){case 0:case 125:C=0;case 59+d:$==-1&&(f=ge(f,/\f/g,"")),x>0&&ct(f)-l&&Tr(x>32?Ua(f+";",n,o,l-1,c):Ua(ge(f," ","")+";",n,o,l-2,c),c);break;case 59:f+=";";default:if(Tr(b=Ba(f,r,o,h,d,a,g,z,_=[],k=[],l,s),s),y===123)if(d===0)So(f,r,b,b,_,s,l,g,k);else switch(m===99&&Be(f,3)===110?100:m){case 100:case 108:case 109:case 115:So(t,b,b,n&&Tr(Ba(t,b,b,0,0,a,g,z,a,_=[],l,k),k),a,k,l,g,n?_:k);break;default:So(f,b,b,b,[""],k,0,g,k)}}h=d=x=0,w=$=1,z=f="",l=p;break;case 58:l=1+ct(f),x=v;default:if(w<1){if(y==123)--w;else if(y==125&&w++==0&&xu()==125)continue}switch(f+=xa(y),y*w){case 38:$=d>0?1:(f+="\f",-1);break;case 44:g[h++]=(ct(f)-1)*$,$=1;break;case 64:qt()===45&&(f+=fn(et())),m=qt(),d=l=ct(z=f+=ku(Co())),y++;break;case 45:v===45&&ct(f)==2&&(w=0)}}return s}function Ba(t,r,o,n,a,s,p,g,c,h,d,l){for(var m=a-1,x=a===0?s:[""],v=gc(x),w=0,C=0,$=0;w<n;++w)for(var y=0,z=hr(t,m+1,m=hc(C=p[w])),_=t;y<v;++y)(_=fc(C>0?x[y]+" "+z:ge(z,/&\f/g,x[y])))&&(c[$++]=_);return qo(t,r,o,a===0?Go:g,c,h,d,l)}function Cu(t,r,o,n){return qo(t,r,o,uc,xa(mu()),hr(t,2,-2),0,n)}function Ua(t,r,o,n,a){return qo(t,r,o,ma,hr(t,0,n),hr(t,n+1,-1),n,a)}function xc(t,r,o){switch(fu(t,r)){case 5103:return _e+"print-"+t+t;case 5737:case 4201:case 3177:case 3433:case 1641:case 4457:case 2921:case 5572:case 6356:case 5844:case 3191:case 6645:case 3005:case 6391:case 5879:case 5623:case 6135:case 4599:case 4855:case 4215:case 6389:case 5109:case 5365:case 5621:case 3829:return _e+t+t;case 4789:return Mr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return _e+t+Mr+t+ze+t+t;case 5936:switch(Be(t,r+11)){case 114:return _e+t+ze+ge(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return _e+t+ze+ge(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return _e+t+ze+ge(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return _e+t+ze+t+t;case 6165:return _e+t+ze+"flex-"+t+t;case 5187:return _e+t+ge(t,/(\w+).+(:[^]+)/,_e+"box-$1$2"+ze+"flex-$1$2")+t;case 5443:return _e+t+ze+"flex-item-"+ge(t,/flex-|-self/g,"")+(mt(t,/flex-|baseline/)?"":ze+"grid-row-"+ge(t,/flex-|-self/g,""))+t;case 4675:return _e+t+ze+"flex-line-pack"+ge(t,/align-content|flex-|-self/g,"")+t;case 5548:return _e+t+ze+ge(t,"shrink","negative")+t;case 5292:return _e+t+ze+ge(t,"basis","preferred-size")+t;case 6060:return _e+"box-"+ge(t,"-grow","")+_e+t+ze+ge(t,"grow","positive")+t;case 4554:return _e+ge(t,/([^-])(transform)/g,"$1"+_e+"$2")+t;case 6187:return ge(ge(ge(t,/(zoom-|grab)/,_e+"$1"),/(image-set)/,_e+"$1"),t,"")+t;case 5495:case 3959:return ge(t,/(image-set\([^]*)/,_e+"$1$`$1");case 4968:return ge(ge(t,/(.+:)(flex-)?(.*)/,_e+"box-pack:$3"+ze+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+_e+t+t;case 4200:if(!mt(t,/flex-|baseline/))return ze+"grid-column-align"+hr(t,r)+t;break;case 2592:case 3360:return ze+ge(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,a){return r=a,mt(n.props,/grid-\w+-end/)})?~_o(t+(o=o[r].value),"span",0)?t:ze+ge(t,"-start","")+t+ze+"grid-row-span:"+(~_o(o,"span",0)?mt(o,/\d+/):+mt(o,/\d+/)-+mt(t,/\d+/))+";":ze+ge(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return mt(n.props,/grid-\w+-start/)})?t:ze+ge(ge(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ge(t,/(.+)-inline(.+)/,_e+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ct(t)-1-r>6)switch(Be(t,r+1)){case 109:if(Be(t,r+4)!==45)break;case 102:return ge(t,/(.+:)(.+)-([^]+)/,"$1"+_e+"$2-$3$1"+Mr+(Be(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~_o(t,"stretch",0)?xc(ge(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ge(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,a,s,p,g,c,h){return ze+a+":"+s+h+(p?ze+a+"-span:"+(g?c:+c-+s)+h:"")+t});case 4949:if(Be(t,r+6)===121)return ge(t,":",":"+_e)+t;break;case 6444:switch(Be(t,Be(t,14)===45?18:11)){case 120:return ge(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+_e+(Be(t,14)===45?"inline-":"")+"box$3$1"+_e+"$2$3$1"+ze+"$2box$3")+t;case 100:return ge(t,":",":"+ze)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ge(t,"scroll-","scroll-snap-")+t}return t}function Io(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function Su(t,r,o,n){switch(t.type){case hu:if(t.children.length)break;case pu:case ma:return t.return=t.return||t.value;case uc:return"";case pc:return t.return=t.value+"{"+Io(t.children,n)+"}";case Go:if(!ct(t.value=t.props.join(",")))return""}return ct(o=Io(t.children,n))?t.return=t.value+"{"+o+"}":""}function $u(t){var r=gc(t);return function(o,n,a,s){for(var p="",g=0;g<r;g++)p+=t[g](o,n,a,s)||"";return p}}function zu(t){return function(r){r.root||(r=r.return)&&t(r)}}function Eu(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case ma:t.return=xc(t.value,t.length,o);return;case pc:return Io([St(t,{value:ge(t.value,"@","@"+_e)})],n);case Go:if(t.length)return gu(o=t.props,function(a){switch(mt(a,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":ar(St(t,{props:[ge(a,/:(read-\w+)/,":"+Mr+"$1")]})),ar(St(t,{props:[a]})),ta(t,{props:Fa(o,n)});break;case"::placeholder":ar(St(t,{props:[ge(a,/:(plac\w+)/,":"+_e+"input-$1")]})),ar(St(t,{props:[ge(a,/:(plac\w+)/,":"+Mr+"$1")]})),ar(St(t,{props:[ge(a,/:(plac\w+)/,ze+"input-$1")]})),ar(St(t,{props:[a]})),ta(t,{props:Fa(o,n)});break}return""})}}var Pu={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1},Jt=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",vc="active",bc="data-styled-version",Zo="6.1.19",va=`/*!sc*/
19
19
  `,To=typeof window<"u"&&typeof document<"u",Ru=!!(typeof SC_DISABLE_SPEEDY=="boolean"?SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==void 0&&process.env.REACT_APP_SC_DISABLE_SPEEDY!==""?process.env.REACT_APP_SC_DISABLE_SPEEDY!=="false"&&process.env.REACT_APP_SC_DISABLE_SPEEDY:typeof process<"u"&&process.env!==void 0&&process.env.SC_DISABLE_SPEEDY!==void 0&&process.env.SC_DISABLE_SPEEDY!==""?process.env.SC_DISABLE_SPEEDY!=="false"&&process.env.SC_DISABLE_SPEEDY:process.env.NODE_ENV!=="production"),Wa=/invalid hook call/i,Yr=new Set,Iu=function(t,r){if(process.env.NODE_ENV!=="production"){var o=r?' with the id of "'.concat(r,'"'):"",n="The component ".concat(t).concat(o,` has been created dynamically.
20
20
  `)+`You may see this warning because you've called styled inside another component.
21
21
  To resolve this only create new StyledComponents outside of any render method and function component.
@@ -61,7 +61,7 @@ as for instance in your render method then you may be running into this limitati
61
61
 
62
62
  `,17:`CSSStyleSheet could not be found on HTMLStyleElement.
63
63
  Has styled-components' style tag been unmounted or altered by another script?
64
- `,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function Hu(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],a=1,s=t.length;a<s;a+=1)n.push(t[a]);return n.forEach(function(p){o=o.replace(/%[a-z]/,p)}),o}function yr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(Hu.apply(void 0,Xt([Gu[t]],r,!1)).trim())}var qu=function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r}return t.prototype.indexOfGroup=function(r){for(var o=0,n=0;n<r;n++)o+=this.groupSizes[n];return o},t.prototype.insertRules=function(r,o){if(r>=this.groupSizes.length){for(var n=this.groupSizes,a=n.length,s=a;r>=s;)if((s<<=1)<0)throw yr(16,"".concat(r));this.groupSizes=new Uint32Array(s),this.groupSizes.set(n),this.length=s;for(var p=a;p<s;p++)this.groupSizes[p]=0}for(var g=this.indexOfGroup(r+1),c=(p=0,o.length);p<c;p++)this.tag.insertRule(g,o[p])&&(this.groupSizes[r]++,g++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),a=n+o;this.groupSizes[r]=0;for(var s=n;s<a;s++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],a=this.indexOfGroup(r),s=a+n,p=a;p<s;p++)o+="".concat(this.tag.getRule(p)).concat(va);return o},t}(),Yu=1<<30,$o=new Map,Oo=new Map,zo=1,Kr=function(t){if($o.has(t))return $o.get(t);for(;Oo.has(zo);)zo++;var r=zo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Yu))throw yr(16,"".concat(r));return $o.set(t,r),Oo.set(r,t),r},Zu=function(t,r){zo=r+1,$o.set(t,r),Oo.set(r,t)},Ku="style[".concat(Jt,"][").concat(bc,'="').concat(Zo,'"]'),Qu=new RegExp("^".concat(Jt,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Xu=function(t,r,o){for(var n,a=o.split(","),s=0,p=a.length;s<p;s++)(n=a[s])&&t.registerName(r,n)},Ju=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(va),a=[],s=0,p=n.length;s<p;s++){var g=n[s].trim();if(g){var c=g.match(Qu);if(c){var h=0|parseInt(c[1],10),d=c[2];h!==0&&(Zu(d,h),Xu(t,d,c[3]),t.getTag().insertRules(h,a)),a.length=0}else a.push(g)}}},Za=function(t){for(var r=document.querySelectorAll(Ku),o=0,n=r.length;o<n;o++){var a=r[o];a&&a.getAttribute(Jt)!==vc&&(Ju(t,a),a.parentNode&&a.parentNode.removeChild(a))}};function ep(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var zc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),a=function(g){var c=Array.from(g.querySelectorAll("style[".concat(Jt,"]")));return c[c.length-1]}(o),s=a!==void 0?a.nextSibling:null;n.setAttribute(Jt,vc),n.setAttribute(bc,Zo);var p=ep();return p&&n.setAttribute("nonce",p),o.insertBefore(n,s),n},tp=function(){function t(r){this.element=zc(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,a=0,s=n.length;a<s;a++){var p=n[a];if(p.ownerNode===o)return p}throw yr(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),rp=function(){function t(r){this.element=zc(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,o){if(r<=this.length&&r>=0){var n=document.createTextNode(o);return this.element.insertBefore(n,this.nodes[r]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(r){this.element.removeChild(this.nodes[r]),this.length--},t.prototype.getRule=function(r){return r<this.length?this.nodes[r].textContent:""},t}(),op=function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,o){return r<=this.length&&(this.rules.splice(r,0,o),this.length++,!0)},t.prototype.deleteRule=function(r){this.rules.splice(r,1),this.length--},t.prototype.getRule=function(r){return r<this.length?this.rules[r]:""},t}(),Ka=To,np={isServer:!To,useCSSOMInjection:!Ru},Ec=function(){function t(r,o,n){r===void 0&&(r=gr),o===void 0&&(o={});var a=this;this.options=qe(qe({},np),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&To&&Ka&&(Ka=!1,Za(this)),ya(this,function(){return function(s){for(var p=s.getTag(),g=p.length,c="",h=function(l){var m=function($){return Oo.get($)}(l);if(m===void 0)return"continue";var x=s.names.get(m),v=p.getGroup(l);if(x===void 0||!x.size||v.length===0)return"continue";var w="".concat(Jt,".g").concat(l,'[id="').concat(m,'"]'),C="";x!==void 0&&x.forEach(function($){$.length>0&&(C+="".concat($,","))}),c+="".concat(v).concat(w,'{content:"').concat(C,'"}').concat(va)},d=0;d<g;d++)h(d);return c}(a)})}return t.registerId=function(r){return Kr(r)},t.prototype.rehydrate=function(){!this.server&&To&&Za(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(qe(qe({},this.options),r),this.gs,o&&this.names||void 0)},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=function(o){var n=o.useCSSOMInjection,a=o.target;return o.isServer?new op(a):n?new tp(a):new rp(a)}(this.options),new qu(r)));var r},t.prototype.hasNameForId=function(r,o){return this.names.has(r)&&this.names.get(r).has(o)},t.prototype.registerName=function(r,o){if(Kr(r),this.names.has(r))this.names.get(r).add(o);else{var n=new Set;n.add(o),this.names.set(r,n)}},t.prototype.insertRules=function(r,o,n){this.registerName(r,o),this.getTag().insertRules(Kr(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(Kr(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),ap=/&/g,sp=/^\s*\/\/.*$/gm;function Pc(t,r){return t.map(function(o){return o.type==="rule"&&(o.value="".concat(r," ").concat(o.value),o.value=o.value.replaceAll(",",",".concat(r," ")),o.props=o.props.map(function(n){return"".concat(r," ").concat(n)})),Array.isArray(o.children)&&o.type!=="@keyframes"&&(o.children=Pc(o.children,r)),o})}function ip(t){var r,o,n,a=gr,s=a.options,p=s===void 0?gr:s,g=a.plugins,c=g===void 0?Ko:g,h=function(m,x,v){return v.startsWith(o)&&v.endsWith(o)&&v.replaceAll(o,"").length>0?".".concat(r):m},d=c.slice();d.push(function(m){m.type===Go&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(ap,o).replace(n,h))}),p.prefix&&d.push(Eu),d.push(Su);var l=function(m,x,v,w){x===void 0&&(x=""),v===void 0&&(v=""),w===void 0&&(w="&"),r=w,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var C=m.replace(sp,""),$=_u(v||x?"".concat(v," ").concat(x," { ").concat(C," }"):C);p.namespace&&($=Pc($,p.namespace));var y=[];return Io($,$u(d.concat(zu(function(z){return y.push(z)})))),y};return l.hash=c.length?c.reduce(function(m,x){return x.name||yr(15),Vt(m,x.name)},yc).toString():"",l}var cp=new Ec,ca=ip(),Rc=i.createContext({shouldForwardProp:void 0,styleSheet:cp,stylis:ca});Rc.Consumer;i.createContext(void 0);function Qa(){return i.useContext(Rc)}var la=function(){function t(r,o){var n=this;this.inject=function(a,s){s===void 0&&(s=ca);var p=n.name+s.hash;a.hasNameForId(n.id,p)||a.insertRules(n.id,p,s(n.rules,p,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,ya(this,function(){throw yr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=ca),this.name+r.hash},t}(),lp=function(t){return t>="A"&&t<="Z"};function Xa(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;lp(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Ic=function(t){return t==null||t===!1||t===""},Tc=function(t){var r,o,n=[];for(var a in t){var s=t[a];t.hasOwnProperty(a)&&!Ic(s)&&(Array.isArray(s)&&s.isCss||mr(s)?n.push("".concat(Xa(a),":"),s,";"):xr(s)?n.push.apply(n,Xt(Xt(["".concat(a," {")],Tc(s),!1),["}"],!1)):n.push("".concat(Xa(a),": ").concat((r=a,(o=s)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Pu||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Yt(t,r,o,n){if(Ic(t))return[];if(ba(t))return[".".concat(t.styledComponentId)];if(mr(t)){if(!mr(s=t)||s.prototype&&s.prototype.isReactComponent||!r)return[t];var a=t(r);return process.env.NODE_ENV==="production"||typeof a!="object"||Array.isArray(a)||a instanceof la||xr(a)||a===null||console.error("".concat(kc(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Yt(a,r,o,n)}var s;return t instanceof la?o?(t.inject(o,n),[t.getName(n)]):[t]:xr(t)?Tc(t):Array.isArray(t)?Array.prototype.concat.apply(Ko,t.map(function(p){return Yt(p,r,o,n)})):[t.toString()]}function dp(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(mr(o)&&!ba(o))return!1}return!0}var up=wc(Zo),pp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&dp(r),this.componentId=o,this.baseHash=Vt(up,o),this.baseStyle=n,Ec.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var a=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))a=Ht(a,this.staticRulesId);else{var s=sa(Yt(this.rules,r,o,n)),p=aa(Vt(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,p)){var g=n(s,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,g)}a=Ht(a,p),this.staticRulesId=p}else{for(var c=Vt(this.baseHash,n.hash),h="",d=0;d<this.rules.length;d++){var l=this.rules[d];if(typeof l=="string")h+=l,process.env.NODE_ENV!=="production"&&(c=Vt(c,l));else if(l){var m=sa(Yt(l,r,o,n));c=Vt(c,m+d),h+=m}}if(h){var x=aa(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(h,".".concat(x),void 0,this.componentId)),a=Ht(a,x)}}return a},t}(),Oc=i.createContext(void 0);Oc.Consumer;var xn={},Ja=new Set;function hp(t,r,o){var n=ba(t),a=t,s=!mn(t),p=r.attrs,g=p===void 0?Ko:p,c=r.componentId,h=c===void 0?function(_,k){var b=typeof _!="string"?"sc":Va(_);xn[b]=(xn[b]||0)+1;var f="".concat(b,"-").concat(jc(Zo+b+xn[b]));return k?"".concat(k,"-").concat(f):f}(r.displayName,r.parentComponentId):c,d=r.displayName,l=d===void 0?function(_){return mn(_)?"styled.".concat(_):"Styled(".concat(kc(_),")")}(t):d,m=r.displayName&&r.componentId?"".concat(Va(r.displayName),"-").concat(r.componentId):r.componentId||h,x=n&&a.attrs?a.attrs.concat(g).filter(Boolean):g,v=r.shouldForwardProp;if(n&&a.shouldForwardProp){var w=a.shouldForwardProp;if(r.shouldForwardProp){var C=r.shouldForwardProp;v=function(_,k){return w(_,k)&&C(_,k)}}else v=w}var $=new pp(o,m,n?a.componentStyle:void 0);function y(_,k){return function(b,f,I){var j=b.attrs,S=b.componentStyle,R=b.defaultProps,E=b.foldedComponentIds,T=b.styledComponentId,P=b.target,O=i.useContext(Oc),D=Qa(),M=b.shouldForwardProp||D.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(T);var N=Tu(f,O,R)||gr,F=function(Z,Q,ne){for(var re,ie=qe(qe({},Q),{className:void 0,theme:ne}),Y=0;Y<Z.length;Y+=1){var ae=mr(re=Z[Y])?re(ie):re;for(var q in ae)ie[q]=q==="className"?Ht(ie[q],ae[q]):q==="style"?qe(qe({},ie[q]),ae[q]):ae[q]}return Q.className&&(ie.className=Ht(ie.className,Q.className)),ie}(j,f,N),ee=F.as||P,ce={};for(var J in F)F[J]===void 0||J[0]==="$"||J==="as"||J==="theme"&&F.theme===N||(J==="forwardedAs"?ce.as=F.forwardedAs:M&&!M(J,ee)||(ce[J]=F[J],M||process.env.NODE_ENV!=="development"||uu(J)||Ja.has(J)||!na.has(ee)||(Ja.add(J),console.warn('styled-components: it looks like an unknown prop "'.concat(J,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var X=function(Z,Q){var ne=Qa(),re=Z.generateAndInjectStyles(Q,ne.styleSheet,ne.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(re),re}(S,F);process.env.NODE_ENV!=="production"&&b.warnTooManyClasses&&b.warnTooManyClasses(X);var U=Ht(E,T);return X&&(U+=" "+X),F.className&&(U+=" "+F.className),ce[mn(ee)&&!na.has(ee)?"class":"className"]=U,I&&(ce.ref=I),i.createElement(ee,ce)}(z,_,k)}y.displayName=l;var z=i.forwardRef(y);return z.attrs=x,z.componentStyle=$,z.displayName=l,z.shouldForwardProp=v,z.foldedComponentIds=n?Ht(a.foldedComponentIds,a.styledComponentId):"",z.styledComponentId=m,z.target=n?a.target:t,Object.defineProperty(z,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(_){this._foldedDefaultProps=n?function(k){for(var b=[],f=1;f<arguments.length;f++)b[f-1]=arguments[f];for(var I=0,j=b;I<j.length;I++)ia(k,j[I],!0);return k}({},a.defaultProps,_):_}}),process.env.NODE_ENV!=="production"&&(Iu(l,m),z.warnTooManyClasses=function(_,k){var b={},f=!1;return function(I){if(!f&&(b[I]=!0,Object.keys(b).length>=200)){var j=k?' with the id of "'.concat(k,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(_).concat(j,`.
64
+ `,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function Hu(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];for(var o=t[0],n=[],a=1,s=t.length;a<s;a+=1)n.push(t[a]);return n.forEach(function(p){o=o.replace(/%[a-z]/,p)}),o}function yr(t){for(var r=[],o=1;o<arguments.length;o++)r[o-1]=arguments[o];return process.env.NODE_ENV==="production"?new Error("An error occurred. See https://github.com/styled-components/styled-components/blob/main/packages/styled-components/src/utils/errors.md#".concat(t," for more information.").concat(r.length>0?" Args: ".concat(r.join(", ")):"")):new Error(Hu.apply(void 0,Xt([Gu[t]],r,!1)).trim())}var qu=function(){function t(r){this.groupSizes=new Uint32Array(512),this.length=512,this.tag=r}return t.prototype.indexOfGroup=function(r){for(var o=0,n=0;n<r;n++)o+=this.groupSizes[n];return o},t.prototype.insertRules=function(r,o){if(r>=this.groupSizes.length){for(var n=this.groupSizes,a=n.length,s=a;r>=s;)if((s<<=1)<0)throw yr(16,"".concat(r));this.groupSizes=new Uint32Array(s),this.groupSizes.set(n),this.length=s;for(var p=a;p<s;p++)this.groupSizes[p]=0}for(var g=this.indexOfGroup(r+1),c=(p=0,o.length);p<c;p++)this.tag.insertRule(g,o[p])&&(this.groupSizes[r]++,g++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),a=n+o;this.groupSizes[r]=0;for(var s=n;s<a;s++)this.tag.deleteRule(n)}},t.prototype.getGroup=function(r){var o="";if(r>=this.length||this.groupSizes[r]===0)return o;for(var n=this.groupSizes[r],a=this.indexOfGroup(r),s=a+n,p=a;p<s;p++)o+="".concat(this.tag.getRule(p)).concat(va);return o},t}(),Yu=1<<30,$o=new Map,Oo=new Map,zo=1,Kr=function(t){if($o.has(t))return $o.get(t);for(;Oo.has(zo);)zo++;var r=zo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Yu))throw yr(16,"".concat(r));return $o.set(t,r),Oo.set(r,t),r},Zu=function(t,r){zo=r+1,$o.set(t,r),Oo.set(r,t)},Ku="style[".concat(Jt,"][").concat(bc,'="').concat(Zo,'"]'),Qu=new RegExp("^".concat(Jt,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),Xu=function(t,r,o){for(var n,a=o.split(","),s=0,p=a.length;s<p;s++)(n=a[s])&&t.registerName(r,n)},Ju=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(va),a=[],s=0,p=n.length;s<p;s++){var g=n[s].trim();if(g){var c=g.match(Qu);if(c){var h=0|parseInt(c[1],10),d=c[2];h!==0&&(Zu(d,h),Xu(t,d,c[3]),t.getTag().insertRules(h,a)),a.length=0}else a.push(g)}}},Za=function(t){for(var r=document.querySelectorAll(Ku),o=0,n=r.length;o<n;o++){var a=r[o];a&&a.getAttribute(Jt)!==vc&&(Ju(t,a),a.parentNode&&a.parentNode.removeChild(a))}};function ep(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var zc=function(t){var r=document.head,o=t||r,n=document.createElement("style"),a=function(g){var c=Array.from(g.querySelectorAll("style[".concat(Jt,"]")));return c[c.length-1]}(o),s=a!==void 0?a.nextSibling:null;n.setAttribute(Jt,vc),n.setAttribute(bc,Zo);var p=ep();return p&&n.setAttribute("nonce",p),o.insertBefore(n,s),n},tp=function(){function t(r){this.element=zc(r),this.element.appendChild(document.createTextNode("")),this.sheet=function(o){if(o.sheet)return o.sheet;for(var n=document.styleSheets,a=0,s=n.length;a<s;a++){var p=n[a];if(p.ownerNode===o)return p}throw yr(17)}(this.element),this.length=0}return t.prototype.insertRule=function(r,o){try{return this.sheet.insertRule(o,r),this.length++,!0}catch{return!1}},t.prototype.deleteRule=function(r){this.sheet.deleteRule(r),this.length--},t.prototype.getRule=function(r){var o=this.sheet.cssRules[r];return o&&o.cssText?o.cssText:""},t}(),rp=function(){function t(r){this.element=zc(r),this.nodes=this.element.childNodes,this.length=0}return t.prototype.insertRule=function(r,o){if(r<=this.length&&r>=0){var n=document.createTextNode(o);return this.element.insertBefore(n,this.nodes[r]||null),this.length++,!0}return!1},t.prototype.deleteRule=function(r){this.element.removeChild(this.nodes[r]),this.length--},t.prototype.getRule=function(r){return r<this.length?this.nodes[r].textContent:""},t}(),op=function(){function t(r){this.rules=[],this.length=0}return t.prototype.insertRule=function(r,o){return r<=this.length&&(this.rules.splice(r,0,o),this.length++,!0)},t.prototype.deleteRule=function(r){this.rules.splice(r,1),this.length--},t.prototype.getRule=function(r){return r<this.length?this.rules[r]:""},t}(),Ka=To,np={isServer:!To,useCSSOMInjection:!Ru},Ec=function(){function t(r,o,n){r===void 0&&(r=gr),o===void 0&&(o={});var a=this;this.options=qe(qe({},np),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&To&&Ka&&(Ka=!1,Za(this)),ya(this,function(){return function(s){for(var p=s.getTag(),g=p.length,c="",h=function(l){var m=function($){return Oo.get($)}(l);if(m===void 0)return"continue";var x=s.names.get(m),v=p.getGroup(l);if(x===void 0||!x.size||v.length===0)return"continue";var w="".concat(Jt,".g").concat(l,'[id="').concat(m,'"]'),C="";x!==void 0&&x.forEach(function($){$.length>0&&(C+="".concat($,","))}),c+="".concat(v).concat(w,'{content:"').concat(C,'"}').concat(va)},d=0;d<g;d++)h(d);return c}(a)})}return t.registerId=function(r){return Kr(r)},t.prototype.rehydrate=function(){!this.server&&To&&Za(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(qe(qe({},this.options),r),this.gs,o&&this.names||void 0)},t.prototype.allocateGSInstance=function(r){return this.gs[r]=(this.gs[r]||0)+1},t.prototype.getTag=function(){return this.tag||(this.tag=(r=function(o){var n=o.useCSSOMInjection,a=o.target;return o.isServer?new op(a):n?new tp(a):new rp(a)}(this.options),new qu(r)));var r},t.prototype.hasNameForId=function(r,o){return this.names.has(r)&&this.names.get(r).has(o)},t.prototype.registerName=function(r,o){if(Kr(r),this.names.has(r))this.names.get(r).add(o);else{var n=new Set;n.add(o),this.names.set(r,n)}},t.prototype.insertRules=function(r,o,n){this.registerName(r,o),this.getTag().insertRules(Kr(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(Kr(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),ap=/&/g,sp=/^\s*\/\/.*$/gm;function Pc(t,r){return t.map(function(o){return o.type==="rule"&&(o.value="".concat(r," ").concat(o.value),o.value=o.value.replaceAll(",",",".concat(r," ")),o.props=o.props.map(function(n){return"".concat(r," ").concat(n)})),Array.isArray(o.children)&&o.type!=="@keyframes"&&(o.children=Pc(o.children,r)),o})}function ip(t){var r,o,n,a=gr,s=a.options,p=s===void 0?gr:s,g=a.plugins,c=g===void 0?Ko:g,h=function(m,x,v){return v.startsWith(o)&&v.endsWith(o)&&v.replaceAll(o,"").length>0?".".concat(r):m},d=c.slice();d.push(function(m){m.type===Go&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(ap,o).replace(n,h))}),p.prefix&&d.push(Eu),d.push(Su);var l=function(m,x,v,w){x===void 0&&(x=""),v===void 0&&(v=""),w===void 0&&(w="&"),r=w,o=x,n=new RegExp("\\".concat(o,"\\b"),"g");var C=m.replace(sp,""),$=_u(v||x?"".concat(v," ").concat(x," { ").concat(C," }"):C);p.namespace&&($=Pc($,p.namespace));var y=[];return Io($,$u(d.concat(zu(function(z){return y.push(z)})))),y};return l.hash=c.length?c.reduce(function(m,x){return x.name||yr(15),Vt(m,x.name)},yc).toString():"",l}var cp=new Ec,ca=ip(),Rc=i.createContext({shouldForwardProp:void 0,styleSheet:cp,stylis:ca});Rc.Consumer;i.createContext(void 0);function Qa(){return i.useContext(Rc)}var la=function(){function t(r,o){var n=this;this.inject=function(a,s){s===void 0&&(s=ca);var p=n.name+s.hash;a.hasNameForId(n.id,p)||a.insertRules(n.id,p,s(n.rules,p,"@keyframes"))},this.name=r,this.id="sc-keyframes-".concat(r),this.rules=o,ya(this,function(){throw yr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=ca),this.name+r.hash},t}(),lp=function(t){return t>="A"&&t<="Z"};function Xa(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;lp(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var Ic=function(t){return t==null||t===!1||t===""},Tc=function(t){var r,o,n=[];for(var a in t){var s=t[a];t.hasOwnProperty(a)&&!Ic(s)&&(Array.isArray(s)&&s.isCss||mr(s)?n.push("".concat(Xa(a),":"),s,";"):xr(s)?n.push.apply(n,Xt(Xt(["".concat(a," {")],Tc(s),!1),["}"],!1)):n.push("".concat(Xa(a),": ").concat((r=a,(o=s)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in Pu||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function Yt(t,r,o,n){if(Ic(t))return[];if(ba(t))return[".".concat(t.styledComponentId)];if(mr(t)){if(!mr(s=t)||s.prototype&&s.prototype.isReactComponent||!r)return[t];var a=t(r);return process.env.NODE_ENV==="production"||typeof a!="object"||Array.isArray(a)||a instanceof la||xr(a)||a===null||console.error("".concat(kc(t)," is not a styled component and cannot be referred to via component selector. See https://www.styled-components.com/docs/advanced#referring-to-other-components for more details.")),Yt(a,r,o,n)}var s;return t instanceof la?o?(t.inject(o,n),[t.getName(n)]):[t]:xr(t)?Tc(t):Array.isArray(t)?Array.prototype.concat.apply(Ko,t.map(function(p){return Yt(p,r,o,n)})):[t.toString()]}function dp(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(mr(o)&&!ba(o))return!1}return!0}var up=wc(Zo),pp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&dp(r),this.componentId=o,this.baseHash=Vt(up,o),this.baseStyle=n,Ec.registerId(o)}return t.prototype.generateAndInjectStyles=function(r,o,n){var a=this.baseStyle?this.baseStyle.generateAndInjectStyles(r,o,n):"";if(this.isStatic&&!n.hash)if(this.staticRulesId&&o.hasNameForId(this.componentId,this.staticRulesId))a=Ht(a,this.staticRulesId);else{var s=sa(Yt(this.rules,r,o,n)),p=aa(Vt(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,p)){var g=n(s,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,g)}a=Ht(a,p),this.staticRulesId=p}else{for(var c=Vt(this.baseHash,n.hash),h="",d=0;d<this.rules.length;d++){var l=this.rules[d];if(typeof l=="string")h+=l,process.env.NODE_ENV!=="production"&&(c=Vt(c,l));else if(l){var m=sa(Yt(l,r,o,n));c=Vt(c,m+d),h+=m}}if(h){var x=aa(c>>>0);o.hasNameForId(this.componentId,x)||o.insertRules(this.componentId,x,n(h,".".concat(x),void 0,this.componentId)),a=Ht(a,x)}}return a},t}(),Oc=i.createContext(void 0);Oc.Consumer;var xn={},Ja=new Set;function hp(t,r,o){var n=ba(t),a=t,s=!mn(t),p=r.attrs,g=p===void 0?Ko:p,c=r.componentId,h=c===void 0?function(_,k){var b=typeof _!="string"?"sc":Va(_);xn[b]=(xn[b]||0)+1;var f="".concat(b,"-").concat(jc(Zo+b+xn[b]));return k?"".concat(k,"-").concat(f):f}(r.displayName,r.parentComponentId):c,d=r.displayName,l=d===void 0?function(_){return mn(_)?"styled.".concat(_):"Styled(".concat(kc(_),")")}(t):d,m=r.displayName&&r.componentId?"".concat(Va(r.displayName),"-").concat(r.componentId):r.componentId||h,x=n&&a.attrs?a.attrs.concat(g).filter(Boolean):g,v=r.shouldForwardProp;if(n&&a.shouldForwardProp){var w=a.shouldForwardProp;if(r.shouldForwardProp){var C=r.shouldForwardProp;v=function(_,k){return w(_,k)&&C(_,k)}}else v=w}var $=new pp(o,m,n?a.componentStyle:void 0);function y(_,k){return function(b,f,I){var j=b.attrs,S=b.componentStyle,R=b.defaultProps,E=b.foldedComponentIds,T=b.styledComponentId,P=b.target,O=i.useContext(Oc),D=Qa(),M=b.shouldForwardProp||D.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(T);var N=Tu(f,O,R)||gr,F=function(Z,Q,ae){for(var oe,ce=qe(qe({},Q),{className:void 0,theme:ae}),Y=0;Y<Z.length;Y+=1){var se=mr(oe=Z[Y])?oe(ce):oe;for(var q in se)ce[q]=q==="className"?Ht(ce[q],se[q]):q==="style"?qe(qe({},ce[q]),se[q]):se[q]}return Q.className&&(ce.className=Ht(ce.className,Q.className)),ce}(j,f,N),J=F.as||P,ie={};for(var re in F)F[re]===void 0||re[0]==="$"||re==="as"||re==="theme"&&F.theme===N||(re==="forwardedAs"?ie.as=F.forwardedAs:M&&!M(re,J)||(ie[re]=F[re],M||process.env.NODE_ENV!=="development"||uu(re)||Ja.has(re)||!na.has(J)||(Ja.add(re),console.warn('styled-components: it looks like an unknown prop "'.concat(re,'" is being sent through to the DOM, which will likely trigger a React console error. If you would like automatic filtering of unknown props, you can opt-into that behavior via `<StyleSheetManager shouldForwardProp={...}>` (connect an API like `@emotion/is-prop-valid`) or consider using transient props (`$` prefix for automatic filtering.)')))));var X=function(Z,Q){var ae=Qa(),oe=Z.generateAndInjectStyles(Q,ae.styleSheet,ae.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(oe),oe}(S,F);process.env.NODE_ENV!=="production"&&b.warnTooManyClasses&&b.warnTooManyClasses(X);var U=Ht(E,T);return X&&(U+=" "+X),F.className&&(U+=" "+F.className),ie[mn(J)&&!na.has(J)?"class":"className"]=U,I&&(ie.ref=I),i.createElement(J,ie)}(z,_,k)}y.displayName=l;var z=i.forwardRef(y);return z.attrs=x,z.componentStyle=$,z.displayName=l,z.shouldForwardProp=v,z.foldedComponentIds=n?Ht(a.foldedComponentIds,a.styledComponentId):"",z.styledComponentId=m,z.target=n?a.target:t,Object.defineProperty(z,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function(_){this._foldedDefaultProps=n?function(k){for(var b=[],f=1;f<arguments.length;f++)b[f-1]=arguments[f];for(var I=0,j=b;I<j.length;I++)ia(k,j[I],!0);return k}({},a.defaultProps,_):_}}),process.env.NODE_ENV!=="production"&&(Iu(l,m),z.warnTooManyClasses=function(_,k){var b={},f=!1;return function(I){if(!f&&(b[I]=!0,Object.keys(b).length>=200)){var j=k?' with the id of "'.concat(k,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat(_).concat(j,`.
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 => ({
@@ -671,7 +671,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
671
671
  `,cr=u.span`
672
672
  color: var(--color-danger);
673
673
  margin-left: 2px;
674
- `;function Vp(){var ee,ce,J,X,U,Z,Q,ne,re,ie,Y,ae,q,B,A;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n,errors:a}=ec(),{signIn:s}=Ar("oauth"),{deployment:p}=ve(),{navigate:g}=He(),{session:c,refetch:h}=Fe(),[d,l]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=i.useState({}),[v,w]=i.useState(!1),[C,$]=i.useState(void 0),[y,z]=i.useState(null),[_,k]=i.useState(null),b=((ee=p==null?void 0:p.restrictions)==null?void 0:ee.sign_up_mode)==="restricted",f=((ce=p==null?void 0:p.restrictions)==null?void 0:ce.sign_up_mode)==="waitlist";i.useEffect(()=>{var G;if(!p)return;if(f){const se=((G=p.ui_settings)==null?void 0:G.waitlist_page_url)||`${p.frontend_host}/waitlist`||"/waitlist";g(se);return}const L=new URLSearchParams(window.location.search).get("invite_token");L&&!y&&r&&(k(L),r.validateDeploymentInvitation(L).then(se=>{z(se),se.valid&&l(me=>({...me,first_name:se.first_name||me.first_name,last_name:se.last_name||me.last_name,email:se.email||me.email}))}).catch(se=>{console.error("Failed to validate invitation:",se)}))},[p,f,g,y,r]);const[I,j]=i.useState(!1),[S,R]=i.useState(""),E=W=>{let{name:L,value:G}=W.target;L==="phone_number"?G=G.replace(/[^0-9-]/g,""):L==="email"&&(G=G.toLowerCase()),l(se=>({...se,[L]:G})),x(se=>({...se,[L]:""}))},T=()=>{l({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),j(!1),R(""),n()},P=async W=>{if(W.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",M),console.log("Form data:",d),t||v)return;const L={},G=/^[a-zA-Z]{3,30}$/,se=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,me=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Se=/^\d{7,15}$/,Ne=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(M!=null&&M.first_name.enabled&&(M!=null&&M.first_name.required&&!d.first_name?L.first_name="First name is required":d.first_name&&!G.test(d.first_name)&&(L.first_name="Invalid name")),M!=null&&M.last_name.enabled&&(M!=null&&M.last_name.required&&!d.last_name?L.last_name="Last name is required":d.last_name&&!G.test(d.last_name)&&(L.last_name="Invalid last name")),M!=null&&M.username.enabled&&(M!=null&&M.username.required&&!d.username?L.username="Username is required":d.username&&!se.test(d.username)&&(L.username="Username must be 3-20 characters")),M!=null&&M.email_address.enabled&&(M!=null&&M.email_address.required&&!d.email?L.email="Email address is required":d.email&&!me.test(d.email)&&(L.email="Invalid email address")),M!=null&&M.phone_number.enabled&&(M!=null&&M.phone_number.required&&!d.phone_number?L.phone_number="Phone number is required":d.phone_number&&!Se.test(d.phone_number)&&(L.phone_number="Phone number must contain 7-15 digits")),M!=null&&M.password.enabled&&(d.password?Ne.test(d.password)||(L.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):L.password="Password is required"),x(L),Object.keys(L).length>0){console.log("Signup validation failed. Errors:",L);return}console.log("Signup validation passed"),w(!0);try{const H={...d};d.phone_number&&C&&(H.phone_country_code=C),_&&(H.invite_token=_),console.log("Submitting signup data:",H),console.log("Phone number:",H.phone_number),console.log("Phone country code:",H.phone_country_code),await r.create(H)}catch(H){x({submit:H.message})}finally{w(!1)}},O=async W=>{if(!(t||v)){w(!0);try{const G=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:se}=await s.create({provider:W.provider,redirectUri:G});se&&typeof se=="object"&&"oauth_url"in se&&(window.location.href=se.oauth_url)}catch(L){x({submit:L.message})}finally{w(!1)}}},D=(p==null?void 0:p.social_connections.filter(W=>W.enabled))||[],M=p==null?void 0:p.auth_settings,N=!!((J=M==null?void 0:M.first_name)!=null&&J.enabled&&((X=M==null?void 0:M.last_name)!=null&&X.enabled)),F=async W=>{var G;if(W.preventDefault(),t||v)return;w(!0);const L={};if(!S){L.otp="OTP code is required",x(L),w(!1);return}x(L);try{const se=await r.completeVerification(S);"data"in se&&((G=se.data)!=null&&G.active_signin)&&await h()}catch(se){console.error("Verification failed:",se)}finally{w(!1)}};return i.useEffect(()=>{var W;if(o){if(o.completed){let L=new URLSearchParams(window.location.search).get("redirect_uri");if(L||(L=((W=p==null?void 0:p.ui_settings)==null?void 0:W.after_signup_redirect_url)||null),!L&&(p!=null&&p.frontend_host)&&(L=`https://${p.frontend_host}`),L){const G=new URL(L);(p==null?void 0:p.mode)==="staging"&&G.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),g(G.toString())}return}if(!I){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}j(!0)}}},[o,r,I,p,c,g]),i.useEffect(()=>{const W={};if(a!=null&&a.errors&&Array.isArray(a==null?void 0:a.errors))for(const L of a.errors)L.code==="USERNAME_EXISTS"&&(W.username=L.message),L.code==="EMAIL_EXISTS"&&(W.email=L.message),L.code==="PHONE_NUMBER_EXISTS"&&(W.phone_number=L.message),L.code==="INVALID_CREDENTIALS"&&(W.password=L.message),["COUNTRY_RESTRICTED","EMAIL_NOT_ALLOWED","EMAIL_BLOCKED","DISPOSABLE_EMAIL_BLOCKED","VOIP_NUMBER_BLOCKED","BANNED_KEYWORD"].includes(L.code)&&(W.submit=L.message);x(W)},[a]),b?e.jsx(le,{children:e.jsxs(os,{children:[e.jsx(Ae,{}),e.jsx(bn,{children:e.jsx(yn,{children:"Sign up Restricted!"})}),e.jsx(Np,{children:e.jsx(Fp,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Bp,{children:e.jsxs(Up,{children:["Need assistance?"," ",e.jsx(Wp,{href:(U=p==null?void 0:p.ui_settings)!=null&&U.sign_in_page_url?`${p.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(le,{children:e.jsx(os,{children:I?e.jsxs(e.Fragment,{children:[e.jsxs(bn,{children:[e.jsxs(yn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ns,{children:(o==null?void 0:o.current_step)==="verify_email"?`${d.email} to continue to ${(Z=p==null?void 0:p.ui_settings)==null?void 0:Z.app_name}`:`${d.phone_number} to continue to ${(Q=p==null?void 0:p.ui_settings)==null?void 0:Q.app_name}`})]}),e.jsxs(as,{style:{gap:"15px"},onSubmit:F,noValidate:!0,children:[e.jsx(Rt,{onComplete:async W=>{R(W)},onResend:async()=>{const W=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:W})},error:m.otp,isSubmitting:v}),e.jsx(ss,{type:"submit",disabled:v||t||!S,children:v?"Verifying...":`Continue to ${(ne=p==null?void 0:p.ui_settings)==null?void 0:ne.app_name}`})]}),e.jsxs(is,{children:["Having trouble?"," ",e.jsx(wn,{children:e.jsx(tt,{to:p.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(wn,{onClick:()=>{T()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{}),e.jsxs(bn,{children:[e.jsx(yn,{children:"Create your account"}),e.jsx(ns,{children:y!=null&&y.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),D.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wa,{connections:D,callback:O}),e.jsx(Mp,{children:e.jsx(Lp,{children:"or"})})]}),e.jsxs(as,{onSubmit:P,noValidate:!0,children:[(((re=M==null?void 0:M.first_name)==null?void 0:re.enabled)||((ie=M==null?void 0:M.last_name)==null?void 0:ie.enabled))&&e.jsxs(Ap,{$isBothEnabled:N,children:[((Y=M==null?void 0:M.first_name)==null?void 0:Y.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"first_name",children:["First name",((ae=M==null?void 0:M.first_name)==null?void 0:ae.required)&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:d.first_name,onChange:E,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Ot,{children:m.first_name})]}),((q=M==null?void 0:M.last_name)==null?void 0:q.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"last_name",children:["Last name",((B=M==null?void 0:M.last_name)==null?void 0:B.required)&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:d.last_name,onChange:E,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Ot,{children:m.last_name})]})]}),(M==null?void 0:M.username.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"username",children:["Username",M.username.required&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:d.username,onChange:E,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Ot,{children:m.username})]}),(M==null?void 0:M.email_address.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"email",children:["Email address",M.email_address.required&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"email",id:"email",name:"email",maxLength:320,value:d.email,onChange:E,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(y==null?void 0:y.valid)&&!!(y!=null&&y.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Ot,{children:m.email})]}),(M==null?void 0:M.phone_number.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"phone_number",children:["Phone number",M.phone_number.required&&e.jsx(cr,{children:"*"})]}),e.jsx(Br,{value:d.phone_number,onChange:E,error:m.phone_number,countryCode:C,setCountryCode:$}),m.phone_number&&e.jsx(Ot,{children:m.phone_number})]}),(M==null?void 0:M.password.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"password",children:["Password",M.password.required&&e.jsx(cr,{children:"*"})]}),e.jsx(Dp,{children:e.jsx(de,{type:"password",id:"password",name:"password",value:d.password,onChange:E,placeholder:"Enter your password","aria-invalid":!!m.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),m.password&&e.jsx(Ot,{children:m.password})]}),m.submit&&e.jsx(Ot,{children:m.submit}),e.jsx(ss,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(is,{children:["Already have an account?"," ",e.jsx(wn,{children:e.jsx(tt,{to:`${(A=p.ui_settings)==null?void 0:A.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}/**
674
+ `;function Vp(){var J,ie,re,X,U,Z,Q,ae,oe,ce,Y,se,q,H,A;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n,errors:a}=ec(),{signIn:s}=Ar("oauth"),{deployment:p}=ve(),{navigate:g}=He(),{session:c,refetch:h}=Fe(),[d,l]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,x]=i.useState({}),[v,w]=i.useState(!1),[C,$]=i.useState(void 0),[y,z]=i.useState(null),[_,k]=i.useState(null),b=((J=p==null?void 0:p.restrictions)==null?void 0:J.sign_up_mode)==="restricted",f=((ie=p==null?void 0:p.restrictions)==null?void 0:ie.sign_up_mode)==="waitlist";i.useEffect(()=>{var W;if(!p)return;if(f){const ee=((W=p.ui_settings)==null?void 0:W.waitlist_page_url)||`${p.frontend_host}/waitlist`||"/waitlist";g(ee);return}const L=new URLSearchParams(window.location.search).get("invite_token");L&&!y&&r&&(k(L),r.validateDeploymentInvitation(L).then(ee=>{z(ee),ee.valid&&l(pe=>({...pe,first_name:ee.first_name||pe.first_name,last_name:ee.last_name||pe.last_name,email:ee.email||pe.email}))}).catch(ee=>{console.error("Failed to validate invitation:",ee)}))},[p,f,g,y,r]);const[I,j]=i.useState(!1),[S,R]=i.useState(""),E=B=>{let{name:L,value:W}=B.target;L==="phone_number"?W=W.replace(/[^0-9-]/g,""):L==="email"&&(W=W.toLowerCase()),l(ee=>({...ee,[L]:W})),x(ee=>({...ee,[L]:""}))},T=()=>{l({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),x({}),j(!1),R(""),n()},P=async B=>{if(B.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",M),console.log("Form data:",d),t||v)return;const L={},W=/^[a-zA-Z]{3,30}$/,ee=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,pe=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Se=/^\d{7,15}$/,Ne=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(M!=null&&M.first_name.enabled&&(M!=null&&M.first_name.required&&!d.first_name?L.first_name="First name is required":d.first_name&&!W.test(d.first_name)&&(L.first_name="Invalid name")),M!=null&&M.last_name.enabled&&(M!=null&&M.last_name.required&&!d.last_name?L.last_name="Last name is required":d.last_name&&!W.test(d.last_name)&&(L.last_name="Invalid last name")),M!=null&&M.username.enabled&&(M!=null&&M.username.required&&!d.username?L.username="Username is required":d.username&&!ee.test(d.username)&&(L.username="Username must be 3-20 characters")),M!=null&&M.email_address.enabled&&(M!=null&&M.email_address.required&&!d.email?L.email="Email address is required":d.email&&!pe.test(d.email)&&(L.email="Invalid email address")),M!=null&&M.phone_number.enabled&&(M!=null&&M.phone_number.required&&!d.phone_number?L.phone_number="Phone number is required":d.phone_number&&!Se.test(d.phone_number)&&(L.phone_number="Phone number must contain 7-15 digits")),M!=null&&M.password.enabled&&(d.password?Ne.test(d.password)||(L.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):L.password="Password is required"),x(L),Object.keys(L).length>0){console.log("Signup validation failed. Errors:",L);return}console.log("Signup validation passed"),w(!0);try{const G={...d};d.phone_number&&C&&(G.phone_country_code=C),_&&(G.invite_token=_),console.log("Submitting signup data:",G),console.log("Phone number:",G.phone_number),console.log("Phone country code:",G.phone_country_code),await r.create(G)}catch(G){x({submit:G.message})}finally{w(!1)}},O=async B=>{if(!(t||v)){w(!0);try{const W=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:ee}=await s.create({provider:B.provider,redirectUri:W});ee&&typeof ee=="object"&&"oauth_url"in ee&&(window.location.href=ee.oauth_url)}catch(L){x({submit:L.message})}finally{w(!1)}}},D=(p==null?void 0:p.social_connections.filter(B=>B.enabled))||[],M=p==null?void 0:p.auth_settings,N=!!((re=M==null?void 0:M.first_name)!=null&&re.enabled&&((X=M==null?void 0:M.last_name)!=null&&X.enabled)),F=async B=>{var W;if(B.preventDefault(),t||v)return;w(!0);const L={};if(!S){L.otp="OTP code is required",x(L),w(!1);return}x(L);try{const ee=await r.completeVerification(S);"data"in ee&&((W=ee.data)!=null&&W.active_signin)&&await h()}catch(ee){console.error("Verification failed:",ee)}finally{w(!1)}};return i.useEffect(()=>{var B;if(o){if(o.completed){let L=new URLSearchParams(window.location.search).get("redirect_uri");if(L||(L=((B=p==null?void 0:p.ui_settings)==null?void 0:B.after_signup_redirect_url)||null),!L&&(p!=null&&p.frontend_host)&&(L=`https://${p.frontend_host}`),L){const W=new URL(L);(p==null?void 0:p.mode)==="staging"&&W.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),g(W.toString())}return}if(!I){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}j(!0)}}},[o,r,I,p,c,g]),i.useEffect(()=>{const B={};if(a!=null&&a.errors&&Array.isArray(a==null?void 0:a.errors))for(const L of a.errors)L.code==="USERNAME_EXISTS"&&(B.username=L.message),L.code==="EMAIL_EXISTS"&&(B.email=L.message),L.code==="PHONE_NUMBER_EXISTS"&&(B.phone_number=L.message),L.code==="INVALID_CREDENTIALS"&&(B.password=L.message),["COUNTRY_RESTRICTED","EMAIL_NOT_ALLOWED","EMAIL_BLOCKED","DISPOSABLE_EMAIL_BLOCKED","VOIP_NUMBER_BLOCKED","BANNED_KEYWORD"].includes(L.code)&&(B.submit=L.message);x(B)},[a]),b?e.jsx(le,{children:e.jsxs(os,{children:[e.jsx(Ae,{}),e.jsx(bn,{children:e.jsx(yn,{children:"Sign up Restricted!"})}),e.jsx(Np,{children:e.jsx(Fp,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(Bp,{children:e.jsxs(Up,{children:["Need assistance?"," ",e.jsx(Wp,{href:(U=p==null?void 0:p.ui_settings)!=null&&U.sign_in_page_url?`${p.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(le,{children:e.jsx(os,{children:I?e.jsxs(e.Fragment,{children:[e.jsxs(bn,{children:[e.jsxs(yn,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(ns,{children:(o==null?void 0:o.current_step)==="verify_email"?`${d.email} to continue to ${(Z=p==null?void 0:p.ui_settings)==null?void 0:Z.app_name}`:`${d.phone_number} to continue to ${(Q=p==null?void 0:p.ui_settings)==null?void 0:Q.app_name}`})]}),e.jsxs(as,{style:{gap:"15px"},onSubmit:F,noValidate:!0,children:[e.jsx(Rt,{onComplete:async B=>{R(B)},onResend:async()=>{const B=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:B})},error:m.otp,isSubmitting:v}),e.jsx(ss,{type:"submit",disabled:v||t||!S,children:v?"Verifying...":`Continue to ${(ae=p==null?void 0:p.ui_settings)==null?void 0:ae.app_name}`})]}),e.jsxs(is,{children:["Having trouble?"," ",e.jsx(wn,{children:e.jsx(tt,{to:p.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(wn,{onClick:()=>{T()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ae,{}),e.jsxs(bn,{children:[e.jsx(yn,{children:"Create your account"}),e.jsx(ns,{children:y!=null&&y.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),D.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wa,{connections:D,callback:O}),e.jsx(Mp,{children:e.jsx(Lp,{children:"or"})})]}),e.jsxs(as,{onSubmit:P,noValidate:!0,children:[(((oe=M==null?void 0:M.first_name)==null?void 0:oe.enabled)||((ce=M==null?void 0:M.last_name)==null?void 0:ce.enabled))&&e.jsxs(Ap,{$isBothEnabled:N,children:[((Y=M==null?void 0:M.first_name)==null?void 0:Y.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"first_name",children:["First name",((se=M==null?void 0:M.first_name)==null?void 0:se.required)&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:d.first_name,onChange:E,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Ot,{children:m.first_name})]}),((q=M==null?void 0:M.last_name)==null?void 0:q.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"last_name",children:["Last name",((H=M==null?void 0:M.last_name)==null?void 0:H.required)&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:d.last_name,onChange:E,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Ot,{children:m.last_name})]})]}),(M==null?void 0:M.username.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"username",children:["Username",M.username.required&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:d.username,onChange:E,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Ot,{children:m.username})]}),(M==null?void 0:M.email_address.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"email",children:["Email address",M.email_address.required&&e.jsx(cr,{children:"*"})]}),e.jsx(de,{type:"email",id:"email",name:"email",maxLength:320,value:d.email,onChange:E,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(y==null?void 0:y.valid)&&!!(y!=null&&y.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Ot,{children:m.email})]}),(M==null?void 0:M.phone_number.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"phone_number",children:["Phone number",M.phone_number.required&&e.jsx(cr,{children:"*"})]}),e.jsx(Br,{value:d.phone_number,onChange:E,error:m.phone_number,countryCode:C,setCountryCode:$}),m.phone_number&&e.jsx(Ot,{children:m.phone_number})]}),(M==null?void 0:M.password.enabled)&&e.jsxs(sr,{children:[e.jsxs(ir,{htmlFor:"password",children:["Password",M.password.required&&e.jsx(cr,{children:"*"})]}),e.jsx(Dp,{children:e.jsx(de,{type:"password",id:"password",name:"password",value:d.password,onChange:E,placeholder:"Enter your password","aria-invalid":!!m.password,required:!0,minLength:8,maxLength:128,pattern:"^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[@$!%*?&])[A-Za-z\\d@$!%*?&]{8,125}$"})}),m.password&&e.jsx(Ot,{children:m.password})]}),m.submit&&e.jsx(Ot,{children:m.submit}),e.jsx(ss,{type:"submit",disabled:v||t,children:v?"Creating account...":"Continue"})]}),e.jsxs(is,{children:["Already have an account?"," ",e.jsx(wn,{children:e.jsx(tt,{to:`${(A=p.ui_settings)==null?void 0:A.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}/**
675
675
  * @license lucide-react v0.474.0 - ISC
676
676
  *
677
677
  * This source code is licensed under the ISC license.
@@ -691,207 +691,207 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
691
691
  *
692
692
  * This source code is licensed under the ISC license.
693
693
  * See the LICENSE file in the root directory of this source tree.
694
- */const ge=(t,r)=>{const o=i.forwardRef(({className:n,...a},s)=>i.createElement(qp,{ref:s,iconNode:r,className:Wc(`lucide-${Gp(t)}`,n),...a}));return o.displayName=`${t}`,o};/**
694
+ */const me=(t,r)=>{const o=i.forwardRef(({className:n,...a},s)=>i.createElement(qp,{ref:s,iconNode:r,className:Wc(`lucide-${Gp(t)}`,n),...a}));return o.displayName=`${t}`,o};/**
695
695
  * @license lucide-react v0.474.0 - ISC
696
696
  *
697
697
  * This source code is licensed under the ISC license.
698
698
  * See the LICENSE file in the root directory of this source tree.
699
- */const Yp=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Zp=ge("Activity",Yp);/**
699
+ */const Yp=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Zp=me("Activity",Yp);/**
700
700
  * @license lucide-react v0.474.0 - ISC
701
701
  *
702
702
  * This source code is licensed under the ISC license.
703
703
  * See the LICENSE file in the root directory of this source tree.
704
- */const Kp=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],Qp=ge("BellOff",Kp);/**
704
+ */const Kp=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M17 17H4a1 1 0 0 1-.74-1.673C4.59 13.956 6 12.499 6 8a6 6 0 0 1 .258-1.742",key:"178tsu"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M8.668 3.01A6 6 0 0 1 18 8c0 2.687.77 4.653 1.707 6.05",key:"1hqiys"}]],Qp=me("BellOff",Kp);/**
705
705
  * @license lucide-react v0.474.0 - ISC
706
706
  *
707
707
  * This source code is licensed under the ISC license.
708
708
  * See the LICENSE file in the root directory of this source tree.
709
- */const Xp=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],Jp=ge("BellRing",Xp);/**
709
+ */const Xp=[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]],Jp=me("BellRing",Xp);/**
710
710
  * @license lucide-react v0.474.0 - ISC
711
711
  *
712
712
  * This source code is licensed under the ISC license.
713
713
  * See the LICENSE file in the root directory of this source tree.
714
- */const eh=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],jn=ge("Bot",eh);/**
714
+ */const eh=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],jn=me("Bot",eh);/**
715
715
  * @license lucide-react v0.474.0 - ISC
716
716
  *
717
717
  * This source code is licensed under the ISC license.
718
718
  * See the LICENSE file in the root directory of this source tree.
719
- */const th=[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]],rh=ge("Building2",th);/**
719
+ */const th=[["path",{d:"M6 22V4a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v18Z",key:"1b4qmf"}],["path",{d:"M6 12H4a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h2",key:"i71pzd"}],["path",{d:"M18 9h2a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2h-2",key:"10jefs"}],["path",{d:"M10 6h4",key:"1itunk"}],["path",{d:"M10 10h4",key:"tcdvrf"}],["path",{d:"M10 14h4",key:"kelpxr"}],["path",{d:"M10 18h4",key:"1ulq68"}]],rh=me("Building2",th);/**
720
720
  * @license lucide-react v0.474.0 - ISC
721
721
  *
722
722
  * This source code is licensed under the ISC license.
723
723
  * See the LICENSE file in the root directory of this source tree.
724
- */const oh=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Dr=ge("Building",oh);/**
724
+ */const oh=[["rect",{width:"16",height:"20",x:"4",y:"2",rx:"2",ry:"2",key:"76otgf"}],["path",{d:"M9 22v-4h6v4",key:"r93iot"}],["path",{d:"M8 6h.01",key:"1dz90k"}],["path",{d:"M16 6h.01",key:"1x0f13"}],["path",{d:"M12 6h.01",key:"1vi96p"}],["path",{d:"M12 10h.01",key:"1nrarc"}],["path",{d:"M12 14h.01",key:"1etili"}],["path",{d:"M16 10h.01",key:"1m94wz"}],["path",{d:"M16 14h.01",key:"1gbofw"}],["path",{d:"M8 10h.01",key:"19clt8"}],["path",{d:"M8 14h.01",key:"6423bh"}]],Dr=me("Building",oh);/**
725
725
  * @license lucide-react v0.474.0 - ISC
726
726
  *
727
727
  * This source code is licensed under the ISC license.
728
728
  * See the LICENSE file in the root directory of this source tree.
729
- */const nh=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],rt=ge("Check",nh);/**
729
+ */const nh=[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]],rt=me("Check",nh);/**
730
730
  * @license lucide-react v0.474.0 - ISC
731
731
  *
732
732
  * This source code is licensed under the ISC license.
733
733
  * See the LICENSE file in the root directory of this source tree.
734
- */const ah=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],er=ge("ChevronDown",ah);/**
734
+ */const ah=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],er=me("ChevronDown",ah);/**
735
735
  * @license lucide-react v0.474.0 - ISC
736
736
  *
737
737
  * This source code is licensed under the ISC license.
738
738
  * See the LICENSE file in the root directory of this source tree.
739
- */const sh=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ur=ge("ChevronLeft",sh);/**
739
+ */const sh=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Ur=me("ChevronLeft",sh);/**
740
740
  * @license lucide-react v0.474.0 - ISC
741
741
  *
742
742
  * This source code is licensed under the ISC license.
743
743
  * See the LICENSE file in the root directory of this source tree.
744
- */const ih=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ua=ge("ChevronRight",ih);/**
744
+ */const ih=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ua=me("ChevronRight",ih);/**
745
745
  * @license lucide-react v0.474.0 - ISC
746
746
  *
747
747
  * This source code is licensed under the ISC license.
748
748
  * See the LICENSE file in the root directory of this source tree.
749
- */const ch=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Vc=ge("ChevronUp",ch);/**
749
+ */const ch=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Vc=me("ChevronUp",ch);/**
750
750
  * @license lucide-react v0.474.0 - ISC
751
751
  *
752
752
  * This source code is licensed under the ISC license.
753
753
  * See the LICENSE file in the root directory of this source tree.
754
- */const lh=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],dh=ge("ChevronsUpDown",lh);/**
754
+ */const lh=[["path",{d:"m7 15 5 5 5-5",key:"1hf1tw"}],["path",{d:"m7 9 5-5 5 5",key:"sgt6xg"}]],dh=me("ChevronsUpDown",lh);/**
755
755
  * @license lucide-react v0.474.0 - ISC
756
756
  *
757
757
  * This source code is licensed under the ISC license.
758
758
  * See the LICENSE file in the root directory of this source tree.
759
- */const uh=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Gc=ge("Copy",uh);/**
759
+ */const uh=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Gc=me("Copy",uh);/**
760
760
  * @license lucide-react v0.474.0 - ISC
761
761
  *
762
762
  * This source code is licensed under the ISC license.
763
763
  * See the LICENSE file in the root directory of this source tree.
764
- */const ph=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],Qo=ge("Download",ph);/**
764
+ */const ph=[["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["polyline",{points:"7 10 12 15 17 10",key:"2ggqvy"}],["line",{x1:"12",x2:"12",y1:"15",y2:"3",key:"1vk2je"}]],Qo=me("Download",ph);/**
765
765
  * @license lucide-react v0.474.0 - ISC
766
766
  *
767
767
  * This source code is licensed under the ISC license.
768
768
  * See the LICENSE file in the root directory of this source tree.
769
- */const hh=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],fh=ge("Expand",hh);/**
769
+ */const hh=[["path",{d:"m15 15 6 6",key:"1s409w"}],["path",{d:"m15 9 6-6",key:"ko1vev"}],["path",{d:"M21 16.2V21h-4.8",key:"1hrera"}],["path",{d:"M21 7.8V3h-4.8",key:"ul1q53"}],["path",{d:"M3 16.2V21h4.8",key:"1x04uo"}],["path",{d:"m3 21 6-6",key:"wwnumi"}],["path",{d:"M3 7.8V3h4.8",key:"1ijppm"}],["path",{d:"M9 9 3 3",key:"v551iv"}]],fh=me("Expand",hh);/**
770
770
  * @license lucide-react v0.474.0 - ISC
771
771
  *
772
772
  * This source code is licensed under the ISC license.
773
773
  * See the LICENSE file in the root directory of this source tree.
774
- */const gh=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Hc=ge("ExternalLink",gh);/**
774
+ */const gh=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Hc=me("ExternalLink",gh);/**
775
775
  * @license lucide-react v0.474.0 - ISC
776
776
  *
777
777
  * This source code is licensed under the ISC license.
778
778
  * See the LICENSE file in the root directory of this source tree.
779
- */const mh=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],kn=ge("EyeOff",mh);/**
779
+ */const mh=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],kn=me("EyeOff",mh);/**
780
780
  * @license lucide-react v0.474.0 - ISC
781
781
  *
782
782
  * This source code is licensed under the ISC license.
783
783
  * See the LICENSE file in the root directory of this source tree.
784
- */const xh=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_n=ge("Eye",xh);/**
784
+ */const xh=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],_n=me("Eye",xh);/**
785
785
  * @license lucide-react v0.474.0 - ISC
786
786
  *
787
787
  * This source code is licensed under the ISC license.
788
788
  * See the LICENSE file in the root directory of this source tree.
789
- */const vh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],bh=ge("Globe",vh);/**
789
+ */const vh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],bh=me("Globe",vh);/**
790
790
  * @license lucide-react v0.474.0 - ISC
791
791
  *
792
792
  * This source code is licensed under the ISC license.
793
793
  * See the LICENSE file in the root directory of this source tree.
794
- */const yh=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],wh=ge("Link2",yh);/**
794
+ */const yh=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],wh=me("Link2",yh);/**
795
795
  * @license lucide-react v0.474.0 - ISC
796
796
  *
797
797
  * This source code is licensed under the ISC license.
798
798
  * See the LICENSE file in the root directory of this source tree.
799
- */const jh=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],vr=ge("LoaderCircle",jh);/**
799
+ */const jh=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],vr=me("LoaderCircle",jh);/**
800
800
  * @license lucide-react v0.474.0 - ISC
801
801
  *
802
802
  * This source code is licensed under the ISC license.
803
803
  * See the LICENSE file in the root directory of this source tree.
804
- */const kh=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],zt=ge("LogOut",kh);/**
804
+ */const kh=[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]],zt=me("LogOut",kh);/**
805
805
  * @license lucide-react v0.474.0 - ISC
806
806
  *
807
807
  * This source code is licensed under the ISC license.
808
808
  * See the LICENSE file in the root directory of this source tree.
809
- */const _h=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],Wr=ge("Mail",_h);/**
809
+ */const _h=[["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}]],Wr=me("Mail",_h);/**
810
810
  * @license lucide-react v0.474.0 - ISC
811
811
  *
812
812
  * This source code is licensed under the ISC license.
813
813
  * See the LICENSE file in the root directory of this source tree.
814
- */const Ch=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],Sh=ge("Maximize2",Ch);/**
814
+ */const Ch=[["polyline",{points:"15 3 21 3 21 9",key:"mznyad"}],["polyline",{points:"9 21 3 21 3 15",key:"1avn1i"}],["line",{x1:"21",x2:"14",y1:"3",y2:"10",key:"ota7mn"}],["line",{x1:"3",x2:"10",y1:"21",y2:"14",key:"1atl0r"}]],Sh=me("Maximize2",Ch);/**
815
815
  * @license lucide-react v0.474.0 - ISC
816
816
  *
817
817
  * This source code is licensed under the ISC license.
818
818
  * See the LICENSE file in the root directory of this source tree.
819
- */const $h=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],cs=ge("MessageCircle",$h);/**
819
+ */const $h=[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}]],cs=me("MessageCircle",$h);/**
820
820
  * @license lucide-react v0.474.0 - ISC
821
821
  *
822
822
  * This source code is licensed under the ISC license.
823
823
  * See the LICENSE file in the root directory of this source tree.
824
- */const zh=[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]],Eh=ge("Paperclip",zh);/**
824
+ */const zh=[["path",{d:"M13.234 20.252 21 12.3",key:"1cbrk9"}],["path",{d:"m16 6-8.414 8.586a2 2 0 0 0 0 2.828 2 2 0 0 0 2.828 0l8.414-8.586a4 4 0 0 0 0-5.656 4 4 0 0 0-5.656 0l-8.415 8.585a6 6 0 1 0 8.486 8.486",key:"1pkts6"}]],Eh=me("Paperclip",zh);/**
825
825
  * @license lucide-react v0.474.0 - ISC
826
826
  *
827
827
  * This source code is licensed under the ISC license.
828
828
  * See the LICENSE file in the root directory of this source tree.
829
- */const Ph=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],Rh=ge("Phone",Ph);/**
829
+ */const Ph=[["path",{d:"M22 16.92v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.5 19.5 0 0 1-6-6 19.79 19.79 0 0 1-3.07-8.67A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91a16 16 0 0 0 6 6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7A2 2 0 0 1 22 16.92z",key:"foiqr5"}]],Rh=me("Phone",Ph);/**
830
830
  * @license lucide-react v0.474.0 - ISC
831
831
  *
832
832
  * This source code is licensed under the ISC license.
833
833
  * See the LICENSE file in the root directory of this source tree.
834
- */const Ih=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Je=ge("Plus",Ih);/**
834
+ */const Ih=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]],Je=me("Plus",Ih);/**
835
835
  * @license lucide-react v0.474.0 - ISC
836
836
  *
837
837
  * This source code is licensed under the ISC license.
838
838
  * See the LICENSE file in the root directory of this source tree.
839
- */const Th=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Oh=ge("Search",Th);/**
839
+ */const Th=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["path",{d:"m21 21-4.3-4.3",key:"1qie3q"}]],Oh=me("Search",Th);/**
840
840
  * @license lucide-react v0.474.0 - ISC
841
841
  *
842
842
  * This source code is licensed under the ISC license.
843
843
  * See the LICENSE file in the root directory of this source tree.
844
- */const Mh=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],qc=ge("Send",Mh);/**
844
+ */const Mh=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],qc=me("Send",Mh);/**
845
845
  * @license lucide-react v0.474.0 - ISC
846
846
  *
847
847
  * This source code is licensed under the ISC license.
848
848
  * See the LICENSE file in the root directory of this source tree.
849
- */const Lh=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Kt=ge("Settings",Lh);/**
849
+ */const Lh=[["path",{d:"M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z",key:"1qme2f"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Kt=me("Settings",Lh);/**
850
850
  * @license lucide-react v0.474.0 - ISC
851
851
  *
852
852
  * This source code is licensed under the ISC license.
853
853
  * See the LICENSE file in the root directory of this source tree.
854
- */const Ah=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Xo=ge("Shield",Ah);/**
854
+ */const Ah=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Xo=me("Shield",Ah);/**
855
855
  * @license lucide-react v0.474.0 - ISC
856
856
  *
857
857
  * This source code is licensed under the ISC license.
858
858
  * See the LICENSE file in the root directory of this source tree.
859
- */const Dh=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],Jo=ge("Trash2",Dh);/**
859
+ */const Dh=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]],Jo=me("Trash2",Dh);/**
860
860
  * @license lucide-react v0.474.0 - ISC
861
861
  *
862
862
  * This source code is licensed under the ISC license.
863
863
  * See the LICENSE file in the root directory of this source tree.
864
- */const Nh=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],en=ge("Trash",Nh);/**
864
+ */const Nh=[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]],en=me("Trash",Nh);/**
865
865
  * @license lucide-react v0.474.0 - ISC
866
866
  *
867
867
  * This source code is licensed under the ISC license.
868
868
  * See the LICENSE file in the root directory of this source tree.
869
- */const Fh=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ut=ge("TriangleAlert",Fh);/**
869
+ */const Fh=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],ut=me("TriangleAlert",Fh);/**
870
870
  * @license lucide-react v0.474.0 - ISC
871
871
  *
872
872
  * This source code is licensed under the ISC license.
873
873
  * See the LICENSE file in the root directory of this source tree.
874
- */const Bh=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Mo=ge("User",Bh);/**
874
+ */const Bh=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Mo=me("User",Bh);/**
875
875
  * @license lucide-react v0.474.0 - ISC
876
876
  *
877
877
  * This source code is licensed under the ISC license.
878
878
  * See the LICENSE file in the root directory of this source tree.
879
- */const Uh=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Lo=ge("Users",Uh);/**
879
+ */const Uh=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["path",{d:"M16 3.13a4 4 0 0 1 0 7.75",key:"1da9ce"}]],Lo=me("Users",Uh);/**
880
880
  * @license lucide-react v0.474.0 - ISC
881
881
  *
882
882
  * This source code is licensed under the ISC license.
883
883
  * See the LICENSE file in the root directory of this source tree.
884
- */const Wh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ke=ge("X",Wh);/**
884
+ */const Wh=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Ke=me("X",Wh);/**
885
885
  * @license lucide-react v0.474.0 - ISC
886
886
  *
887
887
  * This source code is licensed under the ISC license.
888
888
  * See the LICENSE file in the root directory of this source tree.
889
- */const Vh=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Gh=ge("ZoomIn",Vh);/**
889
+ */const Vh=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Gh=me("ZoomIn",Vh);/**
890
890
  * @license lucide-react v0.474.0 - ISC
891
891
  *
892
892
  * This source code is licensed under the ISC license.
893
893
  * See the LICENSE file in the root directory of this source tree.
894
- */const Hh=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],qh=ge("ZoomOut",Hh),Yc=i.createContext(void 0),Zc=()=>{const t=i.useContext(Yc);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Yh=u.div`
894
+ */const Hh=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],qh=me("ZoomOut",Hh),Yc=i.createContext(void 0),Zc=()=>{const t=i.useContext(Yc);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},Yh=u.div`
895
895
  position: fixed;
896
896
  inset: 0;
897
897
  background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
@@ -975,7 +975,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
975
975
  display: flex;
976
976
  flex-direction: column;
977
977
  gap: var(--space-md);
978
- `,pe=u.div`
978
+ `,he=u.div`
979
979
  display: flex;
980
980
  flex-direction: column;
981
981
  gap: var(--space-xs);
@@ -1264,7 +1264,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1264
1264
  &:hover {
1265
1265
  text-decoration: underline;
1266
1266
  }
1267
- `;function kf({onBack:t}){const{deployment:r}=ve(),{navigate:o}=He(),[n,a]=i.useState("start"),[s,p]=i.useState(""),[g,c]=i.useState(""),[h,d]=i.useState(""),[l,m]=i.useState(""),[x,v]=i.useState(""),{forgotPassword:w,verifyOtp:C,resetPassword:$,error:y}=sc(),[z,_]=i.useState(!1),k=async j=>{if(j.preventDefault(),!s)return;_(!0);const S=await w(s);_(!1),S.errors||a("otp")},b=async j=>{if(j.preventDefault(),g.length!==6)return;_(!0);const S=await C(s,g);_(!1),!S.errors&&S.data&&(d(S.data.token),a("reset"))},f=async j=>{var R,E;if(j.preventDefault(),l!==x||l.length<8||l.length<8)return;_(!0);const S=await $(h,l);if(_(!1),!S.errors&&S.data){const T=S.data,P=T.signin_attempts&&T.signin_attempts.length>0?T.signin_attempts[T.signin_attempts.length-1]:null;if(P&&!P.completed){const O=(R=r==null?void 0:r.ui_settings)==null?void 0:R.sign_in_page_url;if(O){const D=new URL(O,window.location.origin);D.searchParams.set("signin_attempt_id",P.id),o(D.toString())}else t()}else{const O=((E=r==null?void 0:r.ui_settings)==null?void 0:E.after_signin_redirect_url)||"/";o(O)}}},I=()=>e.jsxs(e.Fragment,{children:[e.jsx(Ae,{}),e.jsx(Xr,{children:e.jsx(Jr,{children:"Forgot Password"})}),e.jsx(yf,{onClick:()=>a("email"),disabled:z,children:"Reset your password"}),e.jsx(wf,{children:e.jsx(jf,{children:"Or, sign in with another method"})}),e.jsx(il,{}),e.jsxs(eo,{children:[e.jsxs(Sr,{children:["Unable to reset password? ",e.jsx($r,{href:"/contact",children:"Get help"})]}),e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(le,{children:e.jsxs(bf,{children:[n==="start"&&I(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsxs(Xr,{children:[e.jsx(Jr,{children:"Forgot Password"}),e.jsx(Cn,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(dt,{onSubmit:k,noValidate:!0,children:[e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"email",children:"Email Address"}),e.jsx(de,{type:"email",id:"email",value:s,onChange:j=>p(j.target.value),placeholder:"Enter your email",required:!0})]}),y&&e.jsx(Sn,{children:y.message}),e.jsx(K,{type:"submit",disabled:z,style:{width:"100%",marginTop:"var(--space-md)"},children:z?"Sending...":"Send Code"})]}),e.jsx(eo,{children:e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsxs(Xr,{children:[e.jsx(Jr,{children:"Enter Verification Code"}),e.jsxs(Cn,{children:["We've sent a 6-digit code to ",s,". Please enter it below."]})]}),e.jsxs(dt,{onSubmit:b,noValidate:!0,children:[e.jsx(Rt,{onComplete:j=>c(j),isSubmitting:z,error:y==null?void 0:y.message,onResend:async()=>{await w(s)}}),y&&e.jsx(Sn,{children:y.message}),e.jsx(K,{type:"submit",disabled:z||g.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:z?"Verifying...":"Verify"})]}),e.jsx(eo,{children:e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsxs(Xr,{children:[e.jsx(Jr,{children:"Reset Password"}),e.jsx(Cn,{children:"Create a new password for your account."})]}),e.jsxs(dt,{onSubmit:f,noValidate:!0,children:[e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"password",children:"New Password"}),e.jsx(de,{type:"password",id:"password",value:l,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(de,{type:"password",id:"confirmPassword",value:x,onChange:j=>v(j.target.value),placeholder:"Confirm new password",required:!0})]}),y&&e.jsx(Sn,{children:y.message}),e.jsx(K,{type:"submit",disabled:z,style:{width:"100%",marginTop:"var(--space-md)"},children:z?"Resetting...":"Reset Password"})]}),e.jsx(eo,{children:e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const _f=u.div`
1267
+ `;function kf({onBack:t}){const{deployment:r}=ve(),{navigate:o}=He(),[n,a]=i.useState("start"),[s,p]=i.useState(""),[g,c]=i.useState(""),[h,d]=i.useState(""),[l,m]=i.useState(""),[x,v]=i.useState(""),{forgotPassword:w,verifyOtp:C,resetPassword:$,error:y}=sc(),[z,_]=i.useState(!1),k=async j=>{if(j.preventDefault(),!s)return;_(!0);const S=await w(s);_(!1),S.errors||a("otp")},b=async j=>{if(j.preventDefault(),g.length!==6)return;_(!0);const S=await C(s,g);_(!1),!S.errors&&S.data&&(d(S.data.token),a("reset"))},f=async j=>{var R,E;if(j.preventDefault(),l!==x||l.length<8||l.length<8)return;_(!0);const S=await $(h,l);if(_(!1),!S.errors&&S.data){const T=S.data,P=T.signin_attempts&&T.signin_attempts.length>0?T.signin_attempts[T.signin_attempts.length-1]:null;if(P&&!P.completed){const O=(R=r==null?void 0:r.ui_settings)==null?void 0:R.sign_in_page_url;if(O){const D=new URL(O,window.location.origin);D.searchParams.set("signin_attempt_id",P.id),o(D.toString())}else t()}else{const O=((E=r==null?void 0:r.ui_settings)==null?void 0:E.after_signin_redirect_url)||"/";o(O)}}},I=()=>e.jsxs(e.Fragment,{children:[e.jsx(Ae,{}),e.jsx(Xr,{children:e.jsx(Jr,{children:"Forgot Password"})}),e.jsx(yf,{onClick:()=>a("email"),disabled:z,children:"Reset your password"}),e.jsx(wf,{children:e.jsx(jf,{children:"Or, sign in with another method"})}),e.jsx(il,{}),e.jsxs(eo,{children:[e.jsxs(Sr,{children:["Unable to reset password? ",e.jsx($r,{href:"/contact",children:"Get help"})]}),e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(le,{children:e.jsxs(bf,{children:[n==="start"&&I(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsxs(Xr,{children:[e.jsx(Jr,{children:"Forgot Password"}),e.jsx(Cn,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(dt,{onSubmit:k,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"email",children:"Email Address"}),e.jsx(de,{type:"email",id:"email",value:s,onChange:j=>p(j.target.value),placeholder:"Enter your email",required:!0})]}),y&&e.jsx(Sn,{children:y.message}),e.jsx(K,{type:"submit",disabled:z,style:{width:"100%",marginTop:"var(--space-md)"},children:z?"Sending...":"Send Code"})]}),e.jsx(eo,{children:e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsxs(Xr,{children:[e.jsx(Jr,{children:"Enter Verification Code"}),e.jsxs(Cn,{children:["We've sent a 6-digit code to ",s,". Please enter it below."]})]}),e.jsxs(dt,{onSubmit:b,noValidate:!0,children:[e.jsx(Rt,{onComplete:j=>c(j),isSubmitting:z,error:y==null?void 0:y.message,onResend:async()=>{await w(s)}}),y&&e.jsx(Sn,{children:y.message}),e.jsx(K,{type:"submit",disabled:z||g.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:z?"Verifying...":"Verify"})]}),e.jsx(eo,{children:e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsxs(Xr,{children:[e.jsx(Jr,{children:"Reset Password"}),e.jsx(Cn,{children:"Create a new password for your account."})]}),e.jsxs(dt,{onSubmit:f,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"password",children:"New Password"}),e.jsx(de,{type:"password",id:"password",value:l,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(de,{type:"password",id:"confirmPassword",value:x,onChange:j=>v(j.target.value),placeholder:"Confirm new password",required:!0})]}),y&&e.jsx(Sn,{children:y.message}),e.jsx(K,{type:"submit",disabled:z,style:{width:"100%",marginTop:"var(--space-md)"},children:z?"Resetting...":"Reset Password"})]}),e.jsx(eo,{children:e.jsx(Sr,{style:{marginTop:"var(--space-sm)"},children:e.jsx($r,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const _f=u.div`
1268
1268
  max-width: 360px;
1269
1269
  width: 360px;
1270
1270
  padding: var(--space-2xl);
@@ -1426,7 +1426,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1426
1426
  }
1427
1427
  `,Zf=u(de)`
1428
1428
  padding: var(--space-sm) var(--space-md);
1429
- `;function ll({onVerify:t,onBack:r,loading:o}){const[n,a]=i.useState(""),[s,p]=i.useState(""),g=h=>{if(h.preventDefault(),n.length!==4){p("Please enter the last 4 digits of your phone number");return}t(n)},c=h=>{const d=h.target.value.replace(/\D/g,"").slice(0,4);a(d),p("")};return e.jsx(le,{children:e.jsxs(Bf,{children:[e.jsx(Ae,{}),e.jsxs(Uf,{children:[e.jsx(Wf,{children:"Verify your phone number"}),e.jsx(Vf,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(dt,{onSubmit:g,noValidate:!0,children:[e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(Zf,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!s,autoFocus:!0}),s&&e.jsx(Gf,{children:s})]}),e.jsx(Hf,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(qf,{children:e.jsx(Yf,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const Kf=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),Qf=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),Xf=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),$n=u.div`
1429
+ `;function ll({onVerify:t,onBack:r,loading:o}){const[n,a]=i.useState(""),[s,p]=i.useState(""),g=h=>{if(h.preventDefault(),n.length!==4){p("Please enter the last 4 digits of your phone number");return}t(n)},c=h=>{const d=h.target.value.replace(/\D/g,"").slice(0,4);a(d),p("")};return e.jsx(le,{children:e.jsxs(Bf,{children:[e.jsx(Ae,{}),e.jsxs(Uf,{children:[e.jsx(Wf,{children:"Verify your phone number"}),e.jsx(Vf,{children:"To send a verification code, please confirm the last 4 digits of your primary phone number"})]}),e.jsxs(dt,{onSubmit:g,noValidate:!0,children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"lastDigits",children:"Last 4 digits"}),e.jsx(Zf,{type:"text",id:"lastDigits",name:"lastDigits",value:n,onChange:c,placeholder:"0000",maxLength:4,autoComplete:"off","aria-invalid":!!s,autoFocus:!0}),s&&e.jsx(Gf,{children:s})]}),e.jsx(Hf,{type:"submit",disabled:o||n.length!==4,children:o?"Verifying...":"Send code"})]}),e.jsx(qf,{children:e.jsx(Yf,{onClick:r,style:{cursor:"pointer"},children:"Choose a different method"})})]})})}const Kf=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"})}),Qf=()=>e.jsxs("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"5",y:"2",width:"14",height:"20",rx:"2",ry:"2"}),e.jsx("path",{d:"M12 18h.01"})]}),Xf=()=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:e.jsx("path",{d:"m21 2-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0 3 3L22 7l-3-3m-3.5 3.5L19 4"})}),$n=u.div`
1430
1430
  max-width: 380px;
1431
1431
  width: 380px;
1432
1432
  padding: var(--space-3xl);
@@ -1487,7 +1487,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1487
1487
  }
1488
1488
  `,rg=u(de)`
1489
1489
  padding: var(--space-sm) var(--space-md);
1490
- `;function dl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:a}=ve(),[s,p]=i.useState(""),[g,c]=i.useState({}),[h,d]=i.useState(!1),[l,m]=i.useState(null),[x,v]=i.useState(!0),[w,C]=i.useState(!1),[$,y]=i.useState(""),[z,_]=i.useState(!1),{navigate:k}=He(),b=(r==null?void 0:r.available_2fa_methods)||[],f=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(Kf,{}),available:b.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(Qf,{}),available:b.includes("phone_otp"),phoneNumber:$},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Xf,{}),available:b.includes("backup_code")}].filter(E=>E.available),I=async E=>{m(E),v(!1),E==="phone_otp"&&C(!0)},j=async E=>{var T,P;if(r){d(!0);try{const O=await n({strategy:"phone_otp",lastDigits:E});O&&"data"in O&&((T=O.data)!=null&&T.otp_sent)?((P=O.data)!=null&&P.masked_phone&&y(O.data.masked_phone),C(!1)):c({phone:"Phone number verification failed"})}catch(O){c({phone:O.message})}finally{d(!1)}}},S=async E=>{if(E.preventDefault(),h)return;const T={};if(s?l==="authenticator"&&s.length!==6?T.code="Authentication code must be 6 digits":l==="phone_otp"&&s.length!==6&&(T.code="SMS code must be 6 digits"):T.code="Verification code is required",c(T),!(Object.keys(T).length>0)){d(!0);try{await o(s)}catch(P){c({submit:P.message})}finally{d(!1)}}},R=E=>{const T=E.target.value.replace(/\D/g,"").slice(0,6);p(T),c(P=>({...P,code:""}))};return i.useEffect(()=>{var E;if(r.completed){_(!0);let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=((E=a==null?void 0:a.ui_settings)==null?void 0:E.after_signin_redirect_url)||null),!T&&(a!=null&&a.frontend_host)&&(T=`https://${a.frontend_host}`),T){const P=new URL(T);(a==null?void 0:a.mode)==="staging"&&P.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),k(P.toString())}return}},[r,a]),z?e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsx(eg,{children:e.jsx(vr,{size:32})})]})}):x?f.length===0?e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsxs(us,{children:[e.jsx(ps,{children:"Set Up Two-Factor Authentication"}),e.jsx(hs,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),e.jsxs(gs,{children:[t&&e.jsx("div",{children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(zr,{children:e.jsx(tt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(cl,{methods:f,onSelectMethod:I,onBack:t}):w&&l==="phone_otp"?e.jsx(ll,{onVerify:j,onBack:()=>{C(!1),v(!0),m(null)},loading:h}):e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsxs(us,{children:[e.jsx(ps,{children:"Two-factor authentication"}),e.jsxs(hs,{children:[l==="authenticator"&&"Enter the 6-digit code from your authenticator app",l==="phone_otp"&&`Enter the 6-digit code sent to your phone ${$}`,l==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(dt,{onSubmit:S,noValidate:!0,children:[l==="backup_code"?e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"code",children:"Backup code"}),e.jsx(rg,{type:"text",id:"code",name:"code",value:s,onChange:R,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!g.code,autoFocus:!0}),g.code&&e.jsx(fs,{children:g.code})]}):e.jsx(Rt,{onComplete:async E=>{if(p(E),l!=="backup_code"){const T=new Event("submit",{bubbles:!0,cancelable:!0});await S(T)}},onResend:l==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:$.slice(-4)})}catch(E){c({submit:E.message})}}:void 0,error:g.code,isSubmitting:h}),e.jsxs("div",{children:[g.submit&&e.jsx(fs,{children:g.submit}),e.jsx(tg,{type:"submit",disabled:h||!s,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(gs,{children:[e.jsx(zr,{onClick:()=>{v(!0),m(null),p(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(zr,{children:e.jsx(tt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const zn=u.div`
1490
+ `;function dl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:a}=ve(),[s,p]=i.useState(""),[g,c]=i.useState({}),[h,d]=i.useState(!1),[l,m]=i.useState(null),[x,v]=i.useState(!0),[w,C]=i.useState(!1),[$,y]=i.useState(""),[z,_]=i.useState(!1),{navigate:k}=He(),b=(r==null?void 0:r.available_2fa_methods)||[],f=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(Kf,{}),available:b.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(Qf,{}),available:b.includes("phone_otp"),phoneNumber:$},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(Xf,{}),available:b.includes("backup_code")}].filter(E=>E.available),I=async E=>{m(E),v(!1),E==="phone_otp"&&C(!0)},j=async E=>{var T,P;if(r){d(!0);try{const O=await n({strategy:"phone_otp",lastDigits:E});O&&"data"in O&&((T=O.data)!=null&&T.otp_sent)?((P=O.data)!=null&&P.masked_phone&&y(O.data.masked_phone),C(!1)):c({phone:"Phone number verification failed"})}catch(O){c({phone:O.message})}finally{d(!1)}}},S=async E=>{if(E.preventDefault(),h)return;const T={};if(s?l==="authenticator"&&s.length!==6?T.code="Authentication code must be 6 digits":l==="phone_otp"&&s.length!==6&&(T.code="SMS code must be 6 digits"):T.code="Verification code is required",c(T),!(Object.keys(T).length>0)){d(!0);try{await o(s)}catch(P){c({submit:P.message})}finally{d(!1)}}},R=E=>{const T=E.target.value.replace(/\D/g,"").slice(0,6);p(T),c(P=>({...P,code:""}))};return i.useEffect(()=>{var E;if(r.completed){_(!0);let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=((E=a==null?void 0:a.ui_settings)==null?void 0:E.after_signin_redirect_url)||null),!T&&(a!=null&&a.frontend_host)&&(T=`https://${a.frontend_host}`),T){const P=new URL(T);(a==null?void 0:a.mode)==="staging"&&P.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),k(P.toString())}return}},[r,a]),z?e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsx(eg,{children:e.jsx(vr,{size:32})})]})}):x?f.length===0?e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsxs(us,{children:[e.jsx(ps,{children:"Set Up Two-Factor Authentication"}),e.jsx(hs,{children:"Your account requires two-factor authentication, but you haven't set up any methods yet. Please contact your administrator to set up 2FA."})]}),e.jsxs(gs,{children:[t&&e.jsx("div",{children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(zr,{children:e.jsx(tt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(cl,{methods:f,onSelectMethod:I,onBack:t}):w&&l==="phone_otp"?e.jsx(ll,{onVerify:j,onBack:()=>{C(!1),v(!0),m(null)},loading:h}):e.jsx(le,{children:e.jsxs($n,{children:[e.jsx(Ae,{}),e.jsxs(us,{children:[e.jsx(ps,{children:"Two-factor authentication"}),e.jsxs(hs,{children:[l==="authenticator"&&"Enter the 6-digit code from your authenticator app",l==="phone_otp"&&`Enter the 6-digit code sent to your phone ${$}`,l==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(dt,{onSubmit:S,noValidate:!0,children:[l==="backup_code"?e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"code",children:"Backup code"}),e.jsx(rg,{type:"text",id:"code",name:"code",value:s,onChange:R,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!g.code,autoFocus:!0}),g.code&&e.jsx(fs,{children:g.code})]}):e.jsx(Rt,{onComplete:async E=>{if(p(E),l!=="backup_code"){const T=new Event("submit",{bubbles:!0,cancelable:!0});await S(T)}},onResend:l==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:$.slice(-4)})}catch(E){c({submit:E.message})}}:void 0,error:g.code,isSubmitting:h}),e.jsxs("div",{children:[g.submit&&e.jsx(fs,{children:g.submit}),e.jsx(tg,{type:"submit",disabled:h||!s,children:h?"Verifying...":"Verify"})]})]}),e.jsxs(gs,{children:[e.jsx(zr,{onClick:()=>{v(!0),m(null),p(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(zr,{children:e.jsx(tt,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]}),t&&e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(zr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const zn=u.div`
1491
1491
  max-width: 380px;
1492
1492
  width: 380px;
1493
1493
  padding: var(--space-3xl);
@@ -1552,91 +1552,91 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
1552
1552
  transform: rotate(360deg);
1553
1553
  }
1554
1554
  }
1555
- `;function ul({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:a}){var N,F,ee,ce,J,X,U,Z,Q;const{deployment:s}=ve(),{navigate:p}=He(),[g,c]=i.useState({}),[h,d]=i.useState({}),[l,m]=i.useState("US"),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState(null),[z,_]=i.useState(!1),k=$,b=w,f=async ne=>{var re;C(!0),y(null);try{if(await o(ne)){_(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((re=s==null?void 0:s.ui_settings)==null?void 0:re.after_signin_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y){const ae=new URL(Y);(s==null?void 0:s.mode)==="staging"&&ae.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(ae.toString())}}}catch(ie){const Y=ie;throw y(Y),Y}finally{C(!1)}},I=async ne=>{var re;C(!0),y(null);try{if(await n(ne)){_(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((re=s==null?void 0:s.ui_settings)==null?void 0:re.after_signin_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y){const ae=new URL(Y);(s==null?void 0:s.mode)==="staging"&&ae.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(ae.toString())}}return!0}catch(ie){return y(ie),!1}finally{C(!1)}};if(z||!t)return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsx(ag,{children:e.jsx(vr,{size:32})})]})});const j=t.missing_fields||[],S="Complete Your Profile",R="Please provide the following information to continue",E=s==null?void 0:s.auth_settings,T=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,P=ne=>{const{name:re,value:ie}=ne.target;c(Y=>({...Y,[re]:ie})),h[re]&&d(Y=>({...Y,[re]:""}))},O=()=>{const ne={};return j.forEach(re=>{var ae,q,B,A,W;const ie=g[re];let Y=!1;switch(re){case"first_name":Y=((ae=E==null?void 0:E.first_name)==null?void 0:ae.enabled)||!1;break;case"last_name":Y=((q=E==null?void 0:E.last_name)==null?void 0:q.enabled)||!1;break;case"username":Y=((B=E==null?void 0:E.username)==null?void 0:B.enabled)||!1;break;case"phone_number":Y=((A=E==null?void 0:E.phone_number)==null?void 0:A.enabled)||!1;break;case"email_address":Y=((W=E==null?void 0:E.email_address)==null?void 0:W.enabled)||!1;break;default:Y=!0}if(Y&&(!ie||ie.trim()==="")){const L=re.replace("_"," ").replace(/\b\w/g,G=>G.toUpperCase());ne[re]=`${L} is required`}}),g.username&&j.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(g.username)||(ne.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),g.phone_number&&j.includes("phone_number")&&(/^\d{7,15}$/.test(g.phone_number)||(ne.phone_number="Phone number must contain 7-15 digits")),g.email&&j.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(g.email)||(ne.email_address="Please enter a valid email address")),d(ne),Object.keys(ne).length===0},D=async ne=>{if(ne.preventDefault(),!O())return;const re={...g};g.phone_number&&l&&(re.phone_country_code=l),await f(re)},M=ne=>{const re=ne.target.value;c(ie=>({...ie,phone_number:re})),h.phone_number&&d(ie=>({...ie,phone_number:""}))};if(T){const ne=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",re=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",ie=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsxs(ms,{children:[e.jsx(xs,{children:ne}),e.jsx(vs,{children:re})]}),e.jsxs(dt,{onSubmit:Y=>Y.preventDefault(),noValidate:!0,children:[e.jsx(Rt,{onComplete:I,onResend:async()=>{await a({strategy:ie})},error:k==null?void 0:k.message,isSubmitting:b}),k&&e.jsx(Mt,{style:{marginBottom:"var(--space-md)"},children:k.message})]}),e.jsxs(bs,{children:[e.jsx("div",{children:e.jsx(to,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(to,{children:e.jsx(tt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsxs(ms,{children:[e.jsx(xs,{children:S}),e.jsx(vs,{children:R})]}),e.jsxs(dt,{onSubmit:D,noValidate:!0,children:[(j.includes("first_name")||j.includes("last_name"))&&(((N=E==null?void 0:E.first_name)==null?void 0:N.enabled)||((F=E==null?void 0:E.last_name)==null?void 0:F.enabled))&&e.jsxs(og,{$isBothEnabled:!!((ee=E==null?void 0:E.first_name)!=null&&ee.enabled&&((ce=E==null?void 0:E.last_name)!=null&&ce.enabled)&&j.includes("first_name")&&j.includes("last_name")),children:[j.includes("first_name")&&((J=E==null?void 0:E.first_name)==null?void 0:J.enabled)&&e.jsxs(pe,{children:[e.jsxs(ue,{htmlFor:"first_name",children:["First name ",E.first_name.required&&"*"]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",value:g.first_name||"",onChange:P,placeholder:"Enter your first name","aria-invalid":!!h.first_name,disabled:b,autoComplete:"given-name"}),h.first_name&&e.jsx(Mt,{children:h.first_name})]}),j.includes("last_name")&&((X=E==null?void 0:E.last_name)==null?void 0:X.enabled)&&e.jsxs(pe,{children:[e.jsxs(ue,{htmlFor:"last_name",children:["Last name ",E.last_name.required&&"*"]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",value:g.last_name||"",onChange:P,placeholder:"Enter your last name","aria-invalid":!!h.last_name,disabled:b,autoComplete:"family-name"}),h.last_name&&e.jsx(Mt,{children:h.last_name})]})]}),j.includes("username")&&((U=E==null?void 0:E.username)==null?void 0:U.enabled)&&e.jsxs(pe,{children:[e.jsxs(ue,{htmlFor:"username",children:["Username ",E.username.required&&"*"]}),e.jsx(de,{type:"text",id:"username",name:"username",value:g.username||"",onChange:P,placeholder:"Choose a username","aria-invalid":!!h.username,disabled:b,autoComplete:"username"}),h.username&&e.jsx(Mt,{children:h.username})]}),j.includes("phone_number")&&((Z=E==null?void 0:E.phone_number)==null?void 0:Z.enabled)&&e.jsxs(pe,{children:[e.jsxs(ue,{htmlFor:"phone_number",children:["Phone number ",E.phone_number.required&&"*"]}),e.jsx(Br,{value:g.phone_number||"",onChange:M,error:h.phone_number,countryCode:l,setCountryCode:m}),h.phone_number&&e.jsx(Mt,{children:h.phone_number})]}),j.includes("email_address")&&((Q=E==null?void 0:E.email_address)==null?void 0:Q.enabled)&&e.jsxs(pe,{children:[e.jsxs(ue,{htmlFor:"email",children:["Email address ",E.email_address.required&&"*"]}),e.jsx(de,{type:"email",id:"email",name:"email",value:g.email||"",onChange:P,placeholder:"Enter your email address","aria-invalid":!!h.email_address,disabled:b,autoComplete:"email"}),h.email_address&&e.jsx(Mt,{children:h.email_address})]}),k&&e.jsx(Mt,{style:{marginBottom:"var(--space-md)"},children:k.message}),e.jsx(ng,{type:"submit",disabled:b,children:b?"Completing...":"Continue"})]}),e.jsxs(bs,{children:[r&&e.jsx("div",{children:e.jsx(to,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(to,{children:e.jsx(tt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const sg=new Set([Ve.ErrorCode.InvalidCredentials,Ve.ErrorCode.UserNotFound,Ve.ErrorCode.UserAlreadySignedIn,Ve.ErrorCode.Internal,Ve.ErrorCode.UserDisabled,Ve.ErrorCode.CountryRestricted,Ve.ErrorCode.EmailNotAllowed,Ve.ErrorCode.EmailBlocked,Ve.ErrorCode.DisposableEmailBlocked,Ve.ErrorCode.VoipNumberBlocked,Ve.ErrorCode.BannedKeyword]),ig=wr`
1555
+ `;function ul({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:a}){var N,F,J,ie,re,X,U,Z,Q;const{deployment:s}=ve(),{navigate:p}=He(),[g,c]=i.useState({}),[h,d]=i.useState({}),[l,m]=i.useState("US"),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState(null),[z,_]=i.useState(!1),k=$,b=w,f=async ae=>{var oe;C(!0),y(null);try{if(await o(ae)){_(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((oe=s==null?void 0:s.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y){const se=new URL(Y);(s==null?void 0:s.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(se.toString())}}}catch(ce){const Y=ce;throw y(Y),Y}finally{C(!1)}},I=async ae=>{var oe;C(!0),y(null);try{if(await n(ae)){_(!0);let Y=new URLSearchParams(window.location.search).get("redirect_uri");if(Y||(Y=((oe=s==null?void 0:s.ui_settings)==null?void 0:oe.after_signin_redirect_url)||null),!Y&&(s!=null&&s.frontend_host)&&(Y=`https://${s.frontend_host}`),Y){const se=new URL(Y);(s==null?void 0:s.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(se.toString())}}return!0}catch(ce){return y(ce),!1}finally{C(!1)}};if(z||!t)return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsx(ag,{children:e.jsx(vr,{size:32})})]})});const j=t.missing_fields||[],S="Complete Your Profile",R="Please provide the following information to continue",E=s==null?void 0:s.auth_settings,T=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||x,P=ae=>{const{name:oe,value:ce}=ae.target;c(Y=>({...Y,[oe]:ce})),h[oe]&&d(Y=>({...Y,[oe]:""}))},O=()=>{const ae={};return j.forEach(oe=>{var se,q,H,A,B;const ce=g[oe];let Y=!1;switch(oe){case"first_name":Y=((se=E==null?void 0:E.first_name)==null?void 0:se.enabled)||!1;break;case"last_name":Y=((q=E==null?void 0:E.last_name)==null?void 0:q.enabled)||!1;break;case"username":Y=((H=E==null?void 0:E.username)==null?void 0:H.enabled)||!1;break;case"phone_number":Y=((A=E==null?void 0:E.phone_number)==null?void 0:A.enabled)||!1;break;case"email_address":Y=((B=E==null?void 0:E.email_address)==null?void 0:B.enabled)||!1;break;default:Y=!0}if(Y&&(!ce||ce.trim()==="")){const L=oe.replace("_"," ").replace(/\b\w/g,W=>W.toUpperCase());ae[oe]=`${L} is required`}}),g.username&&j.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(g.username)||(ae.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),g.phone_number&&j.includes("phone_number")&&(/^\d{7,15}$/.test(g.phone_number)||(ae.phone_number="Phone number must contain 7-15 digits")),g.email&&j.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(g.email)||(ae.email_address="Please enter a valid email address")),d(ae),Object.keys(ae).length===0},D=async ae=>{if(ae.preventDefault(),!O())return;const oe={...g};g.phone_number&&l&&(oe.phone_country_code=l),await f(oe)},M=ae=>{const oe=ae.target.value;c(ce=>({...ce,phone_number:oe})),h.phone_number&&d(ce=>({...ce,phone_number:""}))};if(T){const ae=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",oe=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",ce=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsxs(ms,{children:[e.jsx(xs,{children:ae}),e.jsx(vs,{children:oe})]}),e.jsxs(dt,{onSubmit:Y=>Y.preventDefault(),noValidate:!0,children:[e.jsx(Rt,{onComplete:I,onResend:async()=>{await a({strategy:ce})},error:k==null?void 0:k.message,isSubmitting:b}),k&&e.jsx(Mt,{style:{marginBottom:"var(--space-md)"},children:k.message})]}),e.jsxs(bs,{children:[e.jsx("div",{children:e.jsx(to,{onClick:()=>v(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(to,{children:e.jsx(tt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(le,{children:e.jsxs(zn,{children:[e.jsx(Ae,{}),e.jsxs(ms,{children:[e.jsx(xs,{children:S}),e.jsx(vs,{children:R})]}),e.jsxs(dt,{onSubmit:D,noValidate:!0,children:[(j.includes("first_name")||j.includes("last_name"))&&(((N=E==null?void 0:E.first_name)==null?void 0:N.enabled)||((F=E==null?void 0:E.last_name)==null?void 0:F.enabled))&&e.jsxs(og,{$isBothEnabled:!!((J=E==null?void 0:E.first_name)!=null&&J.enabled&&((ie=E==null?void 0:E.last_name)!=null&&ie.enabled)&&j.includes("first_name")&&j.includes("last_name")),children:[j.includes("first_name")&&((re=E==null?void 0:E.first_name)==null?void 0:re.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"first_name",children:["First name ",E.first_name.required&&"*"]}),e.jsx(de,{type:"text",id:"first_name",name:"first_name",value:g.first_name||"",onChange:P,placeholder:"Enter your first name","aria-invalid":!!h.first_name,disabled:b,autoComplete:"given-name"}),h.first_name&&e.jsx(Mt,{children:h.first_name})]}),j.includes("last_name")&&((X=E==null?void 0:E.last_name)==null?void 0:X.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"last_name",children:["Last name ",E.last_name.required&&"*"]}),e.jsx(de,{type:"text",id:"last_name",name:"last_name",value:g.last_name||"",onChange:P,placeholder:"Enter your last name","aria-invalid":!!h.last_name,disabled:b,autoComplete:"family-name"}),h.last_name&&e.jsx(Mt,{children:h.last_name})]})]}),j.includes("username")&&((U=E==null?void 0:E.username)==null?void 0:U.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"username",children:["Username ",E.username.required&&"*"]}),e.jsx(de,{type:"text",id:"username",name:"username",value:g.username||"",onChange:P,placeholder:"Choose a username","aria-invalid":!!h.username,disabled:b,autoComplete:"username"}),h.username&&e.jsx(Mt,{children:h.username})]}),j.includes("phone_number")&&((Z=E==null?void 0:E.phone_number)==null?void 0:Z.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"phone_number",children:["Phone number ",E.phone_number.required&&"*"]}),e.jsx(Br,{value:g.phone_number||"",onChange:M,error:h.phone_number,countryCode:l,setCountryCode:m}),h.phone_number&&e.jsx(Mt,{children:h.phone_number})]}),j.includes("email_address")&&((Q=E==null?void 0:E.email_address)==null?void 0:Q.enabled)&&e.jsxs(he,{children:[e.jsxs(ue,{htmlFor:"email",children:["Email address ",E.email_address.required&&"*"]}),e.jsx(de,{type:"email",id:"email",name:"email",value:g.email||"",onChange:P,placeholder:"Enter your email address","aria-invalid":!!h.email_address,disabled:b,autoComplete:"email"}),h.email_address&&e.jsx(Mt,{children:h.email_address})]}),k&&e.jsx(Mt,{style:{marginBottom:"var(--space-md)"},children:k.message}),e.jsx(ng,{type:"submit",disabled:b,children:b?"Completing...":"Continue"})]}),e.jsxs(bs,{children:[r&&e.jsx("div",{children:e.jsx(to,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(to,{children:e.jsx(tt,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const sg=new Set([Ve.ErrorCode.InvalidCredentials,Ve.ErrorCode.UserNotFound,Ve.ErrorCode.UserAlreadySignedIn,Ve.ErrorCode.Internal,Ve.ErrorCode.UserDisabled,Ve.ErrorCode.CountryRestricted,Ve.ErrorCode.EmailNotAllowed,Ve.ErrorCode.EmailBlocked,Ve.ErrorCode.DisposableEmailBlocked,Ve.ErrorCode.VoipNumberBlocked,Ve.ErrorCode.BannedKeyword]),ig=wr`
1556
1556
  from {
1557
- transform: rotate(0deg);
1558
- }
1557
+ transform: rotate(0deg);
1558
+ }
1559
1559
  to {
1560
- transform: rotate(360deg);
1561
- }
1560
+ transform: rotate(360deg);
1561
+ }
1562
1562
  `,En=u.div`
1563
- max-width: 380px;
1564
- width: 380px;
1565
- padding: var(--space-3xl);
1566
- background: var(--color-background);
1567
- border-radius: var(--radius-lg);
1568
- box-shadow: 0 4px 12px var(--color-shadow);
1563
+ max - width: 380px;
1564
+ width: 380px;
1565
+ padding: var(--space - 3xl);
1566
+ background: var(--color - background);
1567
+ border - radius: var(--radius - lg);
1568
+ box - shadow: 0 4px 12px var(--color - shadow);
1569
1569
  `,ys=u.div`
1570
- display: flex;
1571
- justify-content: center;
1572
- align-items: center;
1573
- min-height: 200px;
1570
+ display: flex;
1571
+ justify - content: center;
1572
+ align - items: center;
1573
+ min - height: 200px;
1574
1574
 
1575
1575
  svg {
1576
- animation: ${ig} 1s linear infinite;
1577
- color: var(--color-primary);
1578
- }
1576
+ animation: ${ig} 1s linear infinite;
1577
+ color: var(--color - primary);
1578
+ }
1579
1579
  `,ws=u.div`
1580
- text-align: center;
1581
- margin-bottom: var(--space-2xl);
1582
- position: relative;
1580
+ text - align: center;
1581
+ margin - bottom: var(--space - 2xl);
1582
+ position: relative;
1583
1583
  `,js=u.h1`
1584
- font-size: var(--font-lg);
1585
- font-weight: 400;
1586
- color: var(--color-foreground);
1587
- margin-bottom: var(--space-xs);
1588
- margin-top: 0;
1584
+ font - size: var(--font - lg);
1585
+ font - weight: 400;
1586
+ color: var(--color - foreground);
1587
+ margin - bottom: var(--space - xs);
1588
+ margin - top: 0;
1589
1589
  `,ks=u.p`
1590
- color: var(--color-secondary-text);
1591
- font-size: var(--font-xs);
1590
+ color: var(--color - secondary - text);
1591
+ font - size: var(--font - xs);
1592
1592
  `,cg=u.div`
1593
- position: relative;
1594
- text-align: center;
1595
- margin: var(--space-2xl) 0;
1593
+ position: relative;
1594
+ text - align: center;
1595
+ margin: var(--space - 2xl) 0;
1596
1596
 
1597
1597
  &::before {
1598
- content: "";
1599
- position: absolute;
1600
- top: 50%;
1601
- left: 0;
1602
- right: 0;
1603
- height: 1px;
1604
- background: var(--color-border);
1605
- }
1598
+ content: "";
1599
+ position: absolute;
1600
+ top: 50 %;
1601
+ left: 0;
1602
+ right: 0;
1603
+ height: 1px;
1604
+ background: var(--color - border);
1605
+ }
1606
1606
  `,lg=u.span`
1607
- position: relative;
1608
- background: var(--color-background);
1609
- padding: 0 var(--space-md);
1610
- color: var(--color-muted);
1611
- font-size: var(--font-xs);
1612
- font-weight: 400;
1613
- text-transform: uppercase;
1614
- letter-spacing: 0.05em;
1607
+ position: relative;
1608
+ background: var(--color - background);
1609
+ padding: 0 var(--space - md);
1610
+ color: var(--color - muted);
1611
+ font - size: var(--font - xs);
1612
+ font - weight: 400;
1613
+ text - transform: uppercase;
1614
+ letter - spacing: 0.05em;
1615
1615
  `,dg=u.div`
1616
- position: relative;
1616
+ position: relative;
1617
1617
  `,Er=u.p`
1618
- font-size: var(--font-2xs);
1619
- color: var(--color-error);
1620
- margin: 0;
1621
- margin-top: var(--space-2xs);
1618
+ font - size: var(--font - 2xs);
1619
+ color: var(--color - error);
1620
+ margin: 0;
1621
+ margin - top: var(--space - 2xs);
1622
1622
  `,_s=u(K)`
1623
- margin-top: var(--space-lg);
1623
+ margin - top: var(--space - lg);
1624
1624
  `,Pn=u.div`
1625
- margin-top: var(--space-lg);
1626
- text-align: center;
1627
- font-size: var(--font-xs);
1628
- color: var(--color-secondary-text);
1625
+ margin - top: var(--space - lg);
1626
+ text - align: center;
1627
+ font - size: var(--font - xs);
1628
+ color: var(--color - secondary - text);
1629
1629
  `,Lt=u.span`
1630
- color: var(--color-primary);
1631
- text-decoration: none;
1632
- font-weight: 400;
1633
- transition: color 0.2s;
1634
- cursor: pointer;
1630
+ color: var(--color - primary);
1631
+ text - decoration: none;
1632
+ font - weight: 400;
1633
+ transition: color 0.2s;
1634
+ cursor: pointer;
1635
1635
 
1636
1636
  &:hover {
1637
- color: var(--color-primary-hover);
1638
- }
1639
- `;function ug(){return e.jsx(vf,{children:e.jsx(pg,{})})}function pg(){var X,U,Z,Q,ne,re,ie,Y,ae,q;const{deployment:t}=ve(),{navigate:r}=He(),{session:o,loading:n}=Fe(),{setEmail:a,otpSent:s,setOtpSent:p,showForgotPassword:g,setShowForgotPassword:c,showOtherOptions:h,setShowOtherOptions:d,enabledSocialsProviders:l,firstFactor:m}=sl(),{loading:x,signIn:v,signinAttempt:w,discardSignInAttempt:C,error:$,setSignInAttempt:y}=Ar("generic"),{signIn:z}=Ar("oauth"),[_,k]=i.useState({email:"",username:"",password:"",phone:""}),[b,f]=i.useState({}),[I,j]=i.useState(!1),[S,R]=i.useState(""),[E,T]=i.useState("US"),[P,O]=i.useState(!1),D=B=>{let{name:A,value:W}=B.target;A==="phone"?W=W.replace(/[^0-9]/g,""):A==="email"&&(a(W),W=W.toLowerCase()),k(L=>({...L,[A]:W})),f(L=>({...L,[A]:""}))},M=()=>{k({email:"",username:"",password:"",phone:""}),f({}),T("US")},N=async B=>{if(B.preventDefault(),x||I)return;C();const A={};if(m==="email_password"?(_.email||(A.email="Email address is required"),_.password||(A.password="Password is required")):m==="username_password"?(_.username||(A.username="Username is required"),_.password||(A.password="Password is required")):m==="email_otp"||m==="email_magic_link"?_.email||(A.email="Email address is required"):m==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(A.phone="Phone number must contain 7-15 digits"):A.phone="Phone number is required"),f(A),Object.keys(A).length>0)return;let W="";switch(m){case"email_password":W="plain_email";break;case"username_password":W="plain_username";break;case"email_otp":W="email_otp";break;case"email_magic_link":W="magic_link";break;case"phone_otp":W="phone_otp";break}j(!0);try{const L={..._,strategy:W};m==="phone_otp"&&E&&(L.phone_country_code=E),await v.create(L)}catch(L){f({submit:L.message}),j(!1)}},F=async B=>{if(B.preventDefault(),x||I)return;const A={};if(!S){A.otp="OTP code is required",f(A);return}j(!0),f({});try{await v.completeVerification(S),p(!1),R("")}catch(W){f({otp:W.message||"Verification failed"})}finally{j(!1)}},ee=async B=>{if(!(x||I)){j(!0);try{const W=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:L}=await z.create({provider:B.provider,redirectUri:W});L&&typeof L=="object"&&"oauth_url"in L&&(window.location.href=L.oauth_url)}catch(A){f({submit:A.message})}finally{j(!1)}}};if(i.useEffect(()=>{if(n)return;const B=new URLSearchParams(window.location.search),A=B.get("impersonation_token");if(A&&!w&&!x){(async()=>{try{j(!0),await v.create({strategy:"impersonation",token:A}),B.delete("impersonation_token");const G=B.toString()?`${window.location.pathname}?${B.toString()}`:window.location.pathname;window.history.replaceState({},"",G)}catch(G){f({submit:G.message}),j(!1)}})();return}const W=B.get("signin_attempt_id");if(W&&(o!=null&&o.signin_attempts)&&!w){const L=o.signin_attempts.find(G=>G.id===W);if(L){y(L),B.delete("signin_attempt_id");const G=B.toString()?`${window.location.pathname}?${B.toString()}`:window.location.pathname;window.history.replaceState({},"",G)}}},[o,n,w,y,v,x]),i.useEffect(()=>{var L;if(!w)return;if(w.completed){O(!0);let G=new URLSearchParams(window.location.search).get("redirect_uri");if(G||(G=((L=t==null?void 0:t.ui_settings)==null?void 0:L.after_signin_redirect_url)||null),!G&&(t!=null&&t.frontend_host)&&(G=`https://${t.frontend_host}`),G){const se=new URL(G);(t==null?void 0:t.mode)==="staging"&&se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(se.toString())}return}if(!v||s)return;const A={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[w.current_step];if(!A)return;(async()=>{try{await v.prepareVerification({strategy:A}),p(!0)}catch(G){console.error("Failed to prepare verification:",G),f({submit:"Failed to send verification. Please try again."})}finally{j(!1)}})()},[w,v,s,p,r,t]),i.useEffect(()=>{const B={};if($!=null&&$.errors&&Array.isArray($==null?void 0:$.errors))for(const A of $.errors)sg.has(A.code)&&(B.submit=A.message);f(B)},[$]),h)return e.jsx(Ef,{onBack:()=>d(!1)});if(g)return e.jsx(kf,{onBack:()=>c(!1)});if((w==null?void 0:w.current_step)==="verify_second_factor")return e.jsx(dl,{attempt:w,completeVerification:v.completeVerification,prepareVerification:v.prepareVerification,onBack:()=>{C(),M(),p(!1)}});if((w==null?void 0:w.current_step)==="complete_profile")return e.jsx(ul,{attempt:w,completeProfile:v.completeProfile,completeVerification:v.completeVerification,prepareVerification:v.prepareVerification,onBack:()=>{C(),M(),p(!1)}});if(n)return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),e.jsx(ys,{children:e.jsx(vr,{size:32})})]})});if(P)return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),e.jsx(ys,{children:e.jsx(vr,{size:32})})]})});const J=(w==null?void 0:w.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(w.current_step)&&s;return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),J?e.jsx(e.Fragment,{children:e.jsxs(ws,{children:[e.jsx(js,{children:m==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(ks,{children:m==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:m==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(ws,{children:[e.jsx(js,{children:"Sign in to your account"}),e.jsxs(ks,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),J?m==="email_magic_link"?e.jsxs(Pn,{children:["Having trouble?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Lt,{onClick:()=>{p(!1),C(),M()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:F,noValidate:!0,children:[e.jsx(Rt,{onComplete:async B=>{if(R(B),B&&B.length===6){j(!0),f({});try{await v.completeVerification(B),p(!1)}catch(A){f({otp:A.message||"Verification failed"})}finally{j(!1)}}},onResend:async()=>{const B=m==="email_otp"?"email_otp":"phone_otp";await v.prepareVerification({strategy:B})},error:b.otp,isSubmitting:I}),e.jsx(_s,{type:"submit",disabled:I||x||!S,style:{margin:0},children:I?"Verifying...":`Continue to ${(q=t==null?void 0:t.ui_settings)==null?void 0:q.app_name}`})]}),e.jsxs(Pn,{children:["Having trouble?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Lt,{onClick:()=>{p(!1),C(),M()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wa,{connections:l,callback:ee}),e.jsx(cg,{children:e.jsx(lg,{children:"or"})})]}),e.jsxs(dt,{onSubmit:N,noValidate:!0,children:[(m==="email_password"||m==="email_otp"||m==="email_magic_link")&&((U=(X=t==null?void 0:t.auth_settings)==null?void 0:X.email_address)==null?void 0:U.enabled)&&e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"email",children:"Email address"}),e.jsx(de,{type:"email",id:"email",name:"email",value:_.email,onChange:D,placeholder:"Enter your email address","aria-invalid":!!b.email}),b.email&&e.jsx(Er,{children:b.email})]}),m==="username_password"&&((Q=(Z=t==null?void 0:t.auth_settings)==null?void 0:Z.username)==null?void 0:Q.enabled)&&e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"username",children:"Username"}),e.jsx(de,{type:"text",id:"username",name:"username",value:_.username,onChange:D,placeholder:"Enter your username","aria-invalid":!!b.username}),b.username&&e.jsx(Er,{children:b.username})]}),m==="phone_otp"&&((re=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.phone_number)==null?void 0:re.enabled)&&e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"phone",children:"Phone number"}),e.jsx(Br,{value:_.phone,onChange:D,error:b.phone,countryCode:E,setCountryCode:T}),b.phone&&e.jsx(Er,{children:b.phone})]}),(m==="email_password"||m==="username_password")&&((Y=(ie=t==null?void 0:t.auth_settings)==null?void 0:ie.password)==null?void 0:Y.enabled)&&e.jsxs(pe,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ue,{htmlFor:"password",children:"Password"}),e.jsx(Lt,{style:{fontSize:"12px"},onClick:()=>c(!0),children:"Forgot password?"})]}),e.jsx(dg,{children:e.jsx(de,{type:"password",id:"password",name:"password",value:_.password,onChange:D,placeholder:"Enter your password","aria-invalid":!!b.password})}),b.password&&e.jsx(Er,{children:b.password})]}),e.jsxs("div",{children:[b.submit&&e.jsx(Er,{children:b.submit}),e.jsx(_s,{type:"submit",disabled:I||x,children:I?"Signing in...":"Sign in"})]}),e.jsx(Lt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>d(!0),children:"Use other methods"})]}),e.jsxs(Pn,{children:["Don't have an account?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:`${(ae=t.ui_settings)==null?void 0:ae.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Cs=u.div`
1637
+ color: var(--color - primary - hover);
1638
+ }
1639
+ `;function ug(){return e.jsx(vf,{children:e.jsx(pg,{})})}function pg(){var U,Z,Q,ae,oe,ce,Y,se,q,H;const{deployment:t}=ve(),{navigate:r}=He(),{session:o,loading:n}=Fe(),{setEmail:a,otpSent:s,setOtpSent:p,showForgotPassword:g,setShowForgotPassword:c,showOtherOptions:h,setShowOtherOptions:d,enabledSocialsProviders:l,firstFactor:m}=sl(),{loading:x,signIn:v,signinAttempt:w,discardSignInAttempt:C,error:$,setSignInAttempt:y}=Ar("generic"),{signIn:z}=Ar("oauth"),[_,k]=i.useState({email:"",username:"",password:"",phone:""}),[b,f]=i.useState({}),[I,j]=i.useState(!1),[S,R]=i.useState(""),[E,T]=i.useState("US"),[P,O]=i.useState(!1),D=A=>{let{name:B,value:L}=A.target;B==="phone"?L=L.replace(/[^0-9]/g,""):B==="email"&&(a(L),L=L.toLowerCase()),k(W=>({...W,[B]:L})),f(W=>({...W,[B]:""}))},M=()=>{k({email:"",username:"",password:"",phone:""}),f({}),T("US")},N=async A=>{if(A.preventDefault(),x||I)return;C();const B={};if(m==="email_password"?(_.email||(B.email="Email address is required"),_.password||(B.password="Password is required")):m==="username_password"?(_.username||(B.username="Username is required"),_.password||(B.password="Password is required")):m==="email_otp"||m==="email_magic_link"?_.email||(B.email="Email address is required"):m==="phone_otp"&&(_.phone?/^\d{7,15}$/.test(_.phone)||(B.phone="Phone number must contain 7-15 digits"):B.phone="Phone number is required"),f(B),Object.keys(B).length>0)return;let L="";switch(m){case"email_password":L="plain_email";break;case"username_password":L="plain_username";break;case"email_otp":L="email_otp";break;case"email_magic_link":L="magic_link";break;case"phone_otp":L="phone_otp";break}j(!0);try{const W={..._,strategy:L};m==="phone_otp"&&E&&(W.phone_country_code=E),await v.create(W)}catch(W){f({submit:W.message}),j(!1)}},F=async A=>{if(A.preventDefault(),x||I)return;const B={};if(!S){B.otp="OTP code is required",f(B);return}j(!0),f({});try{await v.completeVerification(S),p(!1),R("")}catch(L){f({otp:L.message||"Verification failed"})}finally{j(!1)}},J=async A=>{if(!(x||I)){j(!0);try{const L=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:W}=await z.create({provider:A.provider,redirectUri:L});W&&typeof W=="object"&&"oauth_url"in W&&(window.location.href=W.oauth_url)}catch(B){f({submit:B.message})}finally{j(!1)}}},ie=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const A=new URLSearchParams(window.location.search),B=A.get("impersonation_token");if(B&&!w&&!x&&!ie.current){ie.current=!0,A.delete("impersonation_token");const W=A.toString()?`${window.location.pathname}?${A.toString()} `:window.location.pathname;window.history.replaceState({},"",W),(async()=>{try{j(!0),await v.create({strategy:"impersonation",token:B})}catch(pe){f({submit:pe.message}),j(!1),ie.current=!1}})();return}const L=A.get("signin_attempt_id");if(L&&(o!=null&&o.signin_attempts)&&!w){const W=o.signin_attempts.find(ee=>ee.id===L);if(W){y(W),A.delete("signin_attempt_id");const ee=A.toString()?`${window.location.pathname}?${A.toString()} `:window.location.pathname;window.history.replaceState({},"",ee)}}},[o,n,w,y,x]),i.useEffect(()=>{var W;if(!w)return;if(w.completed){O(!0);let ee=new URLSearchParams(window.location.search).get("redirect_uri");if(ee||(ee=((W=t==null?void 0:t.ui_settings)==null?void 0:W.after_signin_redirect_url)||null),!ee&&(t!=null&&t.frontend_host)&&(ee=`https://${t.frontend_host}`),ee){const pe=new URL(ee);(t==null?void 0:t.mode)==="staging"&&pe.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(pe.toString())}return}if(!v||s)return;const B={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[w.current_step];if(!B)return;(async()=>{try{await v.prepareVerification({strategy:B}),p(!0)}catch(ee){console.error("Failed to prepare verification:",ee),f({submit:"Failed to send verification. Please try again."})}finally{j(!1)}})()},[w,v,s,p,r,t]),i.useEffect(()=>{const A={};if($!=null&&$.errors&&Array.isArray($==null?void 0:$.errors))for(const B of $.errors)sg.has(B.code)&&(A.submit=B.message);f(A)},[$]),h)return e.jsx(Ef,{onBack:()=>d(!1)});if(g)return e.jsx(kf,{onBack:()=>c(!1)});if((w==null?void 0:w.current_step)==="verify_second_factor")return e.jsx(dl,{attempt:w,completeVerification:v.completeVerification,prepareVerification:v.prepareVerification,onBack:()=>{C(),M(),p(!1)}});if((w==null?void 0:w.current_step)==="complete_profile")return e.jsx(ul,{attempt:w,completeProfile:v.completeProfile,completeVerification:v.completeVerification,prepareVerification:v.prepareVerification,onBack:()=>{C(),M(),p(!1)}});if(n)return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),e.jsx(ys,{children:e.jsx(vr,{size:32})})]})});if(P)return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),e.jsx(ys,{children:e.jsx(vr,{size:32})})]})});const X=(w==null?void 0:w.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(w.current_step)&&s;return e.jsx(le,{children:e.jsxs(En,{children:[e.jsx(Ae,{}),X?e.jsx(e.Fragment,{children:e.jsxs(ws,{children:[e.jsx(js,{children:m==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(ks,{children:m==="email_magic_link"?`If ${_.email} exists in our records, you will receive a magic link. Click the link to sign in.`:m==="phone_otp"?`If ${_.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${_.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(ws,{children:[e.jsx(js,{children:"Sign in to your account"}),e.jsxs(ks,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),X?m==="email_magic_link"?e.jsxs(Pn,{children:["Having trouble?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Lt,{onClick:()=>{p(!1),C(),M()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(dt,{style:{gap:"15px"},onSubmit:F,noValidate:!0,children:[e.jsx(Rt,{onComplete:async A=>{if(R(A),A&&A.length===6){j(!0),f({});try{await v.completeVerification(A),p(!1)}catch(B){f({otp:B.message||"Verification failed"})}finally{j(!1)}}},onResend:async()=>{const A=m==="email_otp"?"email_otp":"phone_otp";await v.prepareVerification({strategy:A})},error:b.otp,isSubmitting:I}),e.jsx(_s,{type:"submit",disabled:I||x||!S,style:{margin:0},children:I?"Verifying...":`Continue to ${(H=t==null?void 0:t.ui_settings)==null?void 0:H.app_name}`})]}),e.jsxs(Pn,{children:["Having trouble?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Lt,{onClick:()=>{p(!1),C(),M()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[l.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(wa,{connections:l,callback:J}),e.jsx(cg,{children:e.jsx(lg,{children:"or"})})]}),e.jsxs(dt,{onSubmit:N,noValidate:!0,children:[(m==="email_password"||m==="email_otp"||m==="email_magic_link")&&((Z=(U=t==null?void 0:t.auth_settings)==null?void 0:U.email_address)==null?void 0:Z.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"email",children:"Email address"}),e.jsx(de,{type:"email",id:"email",name:"email",value:_.email,onChange:D,placeholder:"Enter your email address","aria-invalid":!!b.email}),b.email&&e.jsx(Er,{children:b.email})]}),m==="username_password"&&((ae=(Q=t==null?void 0:t.auth_settings)==null?void 0:Q.username)==null?void 0:ae.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"username",children:"Username"}),e.jsx(de,{type:"text",id:"username",name:"username",value:_.username,onChange:D,placeholder:"Enter your username","aria-invalid":!!b.username}),b.username&&e.jsx(Er,{children:b.username})]}),m==="phone_otp"&&((ce=(oe=t==null?void 0:t.auth_settings)==null?void 0:oe.phone_number)==null?void 0:ce.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"phone",children:"Phone number"}),e.jsx(Br,{value:_.phone,onChange:D,error:b.phone,countryCode:E,setCountryCode:T}),b.phone&&e.jsx(Er,{children:b.phone})]}),(m==="email_password"||m==="username_password")&&((se=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.password)==null?void 0:se.enabled)&&e.jsxs(he,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(ue,{htmlFor:"password",children:"Password"}),e.jsx(Lt,{style:{fontSize:"12px"},onClick:()=>c(!0),children:"Forgot password?"})]}),e.jsx(dg,{children:e.jsx(de,{type:"password",id:"password",name:"password",value:_.password,onChange:D,placeholder:"Enter your password","aria-invalid":!!b.password})}),b.password&&e.jsx(Er,{children:b.password})]}),e.jsxs("div",{children:[b.submit&&e.jsx(Er,{children:b.submit}),e.jsx(_s,{type:"submit",disabled:I||x,children:I?"Signing in...":"Sign in"})]}),e.jsx(Lt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>d(!0),children:"Use other methods"})]}),e.jsxs(Pn,{children:["Don't have an account?"," ",e.jsx(Lt,{children:e.jsx(tt,{to:`${(q=t.ui_settings)==null?void 0:q.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Cs=u.div`
1640
1640
  max-width: 380px;
1641
1641
  width: 380px;
1642
1642
  padding: var(--space-3xl);
@@ -2227,7 +2227,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
2227
2227
  color: var(--color-foreground);
2228
2228
  background: var(--color-input-background);
2229
2229
  }
2230
- `,Ls=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(),[p,g]=i.useState(""),[c,h]=i.useState(!1),[d,l]=i.useState(!1),[m,x]=i.useState({top:0,left:0}),{addDomain:v,verifyDomain:w}=Qe(),{toast:C}=st(),$=k=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(k),y=k=>k.trim().toLowerCase().replace(/^https?:\/\//,""),z=async()=>{var b,f;const k=y(p);if(!k){C("Please enter a domain name","error");return}if(!$(k)){C("Please enter a valid domain name (e.g., example.com)","error");return}if(k.length>253){C("Domain name is too long","error");return}try{const I=await v({fqdn:k});if((b=I==null?void 0:I.errors)!=null&&b.length){const j=((f=I.errors[0])==null?void 0:f.message)||I.errors[0]||"Failed to add domain";C(typeof j=="string"?j:"Failed to add domain","error");return}C("Domain added successfully","info"),s(I.data)}catch(I){const j=I.message||"Failed to add domain. Please try again.";C(j,"error")}},_=async()=>{if(!(!a||c)){h(!0);try{await w(a),t==null||t(),C("Domain verified successfully","info")}catch(k){const b=k.message||"Failed to verify domain. Please check DNS records and try again.";C(b,"error")}finally{h(!1)}}};return i.useEffect(()=>{l(!0);const k=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const I=o.current;if(I){const j=I.getBoundingClientRect(),S=360,R=250,E=8;let T=0,P=0;const O=window.innerHeight-j.bottom,D=j.top;O>=R+E?(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):D>=R+E?(T=j.top-R-E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left)),x({top:T,left:P})}},10),b=I=>{n.current&&!n.current.contains(I.target)&&(t==null||t())},f=I=>{I.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(k),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,o]),i.useEffect(()=>{r&&s(r)},[r]),d?e.jsx(fm,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:a?e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{children:[e.jsx(Is,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Ms,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(Ke,{size:16})})]}),e.jsxs(Ts,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(pe,{children:[e.jsx(ue,{children:"Record Type"}),e.jsx(de,{value:a==null?void 0:a.verification_dns_record_type,disabled:!0})]}),e.jsxs(pe,{children:[e.jsx(ue,{children:"Record Name"}),e.jsx(de,{value:a==null?void 0:a.verification_dns_record_name,disabled:!0})]}),e.jsxs(pe,{children:[e.jsx(ue,{children:"Record Data"}),e.jsx(de,{type:"text",value:a==null?void 0:a.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Os,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:_,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{children:[e.jsx(Is,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Ms,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(Ts,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(pe,{children:[e.jsx(ue,{children:"Enter FQDN"}),e.jsx(de,{type:"text",placeholder:"Enter your domain",value:p,onChange:k=>g(k.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Os,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!p||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Adding..."]}):"Continue"})]})]})}):null},gm=u.div`
2230
+ `,Ls=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(),[p,g]=i.useState(""),[c,h]=i.useState(!1),[d,l]=i.useState(!1),[m,x]=i.useState({top:0,left:0}),{addDomain:v,verifyDomain:w}=Qe(),{toast:C}=st(),$=k=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(k),y=k=>k.trim().toLowerCase().replace(/^https?:\/\//,""),z=async()=>{var b,f;const k=y(p);if(!k){C("Please enter a domain name","error");return}if(!$(k)){C("Please enter a valid domain name (e.g., example.com)","error");return}if(k.length>253){C("Domain name is too long","error");return}try{const I=await v({fqdn:k});if((b=I==null?void 0:I.errors)!=null&&b.length){const j=((f=I.errors[0])==null?void 0:f.message)||I.errors[0]||"Failed to add domain";C(typeof j=="string"?j:"Failed to add domain","error");return}C("Domain added successfully","info"),s(I.data)}catch(I){const j=I.message||"Failed to add domain. Please try again.";C(j,"error")}},_=async()=>{if(!(!a||c)){h(!0);try{await w(a),t==null||t(),C("Domain verified successfully","info")}catch(k){const b=k.message||"Failed to verify domain. Please check DNS records and try again.";C(b,"error")}finally{h(!1)}}};return i.useEffect(()=>{l(!0);const k=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const I=o.current;if(I){const j=I.getBoundingClientRect(),S=360,R=250,E=8;let T=0,P=0;const O=window.innerHeight-j.bottom,D=j.top;O>=R+E?(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):D>=R+E?(T=j.top-R-E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left)),x({top:T,left:P})}},10),b=I=>{n.current&&!n.current.contains(I.target)&&(t==null||t())},f=I=>{I.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",f),()=>{clearTimeout(k),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,o]),i.useEffect(()=>{r&&s(r)},[r]),d?e.jsx(fm,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:a?e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{children:[e.jsx(Is,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(Ms,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(Ke,{size:16})})]}),e.jsxs(Ts,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Record Type"}),e.jsx(de,{value:a==null?void 0:a.verification_dns_record_type,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Record Name"}),e.jsx(de,{value:a==null?void 0:a.verification_dns_record_name,disabled:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Record Data"}),e.jsx(de,{type:"text",value:a==null?void 0:a.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(Os,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:_,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(Rs,{children:[e.jsx(Is,{id:"add-domain-title",children:"Add Domain"}),e.jsx(Ms,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(Ts,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(he,{children:[e.jsx(ue,{children:"Enter FQDN"}),e.jsx(de,{type:"text",placeholder:"Enter your domain",value:p,onChange:k=>g(k.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(Os,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!p||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Adding..."]}):"Continue"})]})]})}):null},gm=u.div`
2231
2231
  position: fixed;
2232
2232
  width: 360px;
2233
2233
  max-width: calc(100vw - 48px);
@@ -2276,7 +2276,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
2276
2276
  color: var(--color-foreground);
2277
2277
  background: var(--color-input-background);
2278
2278
  }
2279
- `,fl=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const a=i.useRef(null),[s,p]=i.useState(""),[g,c]=i.useState(null),[h,d]=i.useState(!1),[l,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{inviteMember:w}=Qe(),{toast:C}=st(),$=o.map(_=>({value:_.id,label:_.name})),y=_=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_),z=async()=>{const _=s.trim().toLowerCase();if(!(!_||!g)){if(!y(_)){C("Please enter a valid email address","error");return}if(_.length>320){C("Email address is too long","error");return}d(!0);try{await w({email:_,organizationRole:g}),r==null||r()}catch(k){const b=k.message||"Failed to send invitation. Please try again.";C(b,"error")}finally{d(!1)}}};return i.useEffect(()=>{m(!0);const _=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const f=n.current;if(f){const I=f.getBoundingClientRect(),j=360,S=250,R=8;let E=0,T=0;const P=window.innerHeight-I.bottom,O=I.top;P>=S+R?(E=I.bottom+R,T=I.right-j,T<R&&(T=I.left,T+j>window.innerWidth-R&&(T=(window.innerWidth-j)/2))):O>=S+R?(E=I.top-S-R,T=I.right-j,T<R&&(T=I.left,T+j>window.innerWidth-R&&(T=(window.innerWidth-j)/2))):(E=I.bottom+R,T=I.right-j,T<R&&(T=I.left)),v({top:E,left:T})}},10),k=f=>{a.current&&!a.current.contains(f.target)&&(t==null||t())},b=f=>{f.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",b),()=>{clearTimeout(_),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",b)}},[t,n]),l?e.jsxs(gm,{ref:a,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(mm,{children:[e.jsx(xm,{id:"invite-member-title",children:"Invite Member"}),e.jsx(ym,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(vm,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(pe,{children:[e.jsx(ue,{children:"Email Address"}),e.jsx(de,{type:"email",placeholder:"colleague@company.com",value:s,onChange:_=>p(_.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(pe,{children:[e.jsx(ue,{children:"Role"}),e.jsx(ja,{options:$,value:g==null?void 0:g.id,onChange:_=>c(o.find(k=>k.id===_)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(bm,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!s||!g||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},wm=u.div`
2279
+ `,fl=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const a=i.useRef(null),[s,p]=i.useState(""),[g,c]=i.useState(null),[h,d]=i.useState(!1),[l,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{inviteMember:w}=Qe(),{toast:C}=st(),$=o.map(_=>({value:_.id,label:_.name})),y=_=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_),z=async()=>{const _=s.trim().toLowerCase();if(!(!_||!g)){if(!y(_)){C("Please enter a valid email address","error");return}if(_.length>320){C("Email address is too long","error");return}d(!0);try{await w({email:_,organizationRole:g}),r==null||r()}catch(k){const b=k.message||"Failed to send invitation. Please try again.";C(b,"error")}finally{d(!1)}}};return i.useEffect(()=>{m(!0);const _=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const f=n.current;if(f){const I=f.getBoundingClientRect(),j=360,S=250,R=8;let E=0,T=0;const P=window.innerHeight-I.bottom,O=I.top;P>=S+R?(E=I.bottom+R,T=I.right-j,T<R&&(T=I.left,T+j>window.innerWidth-R&&(T=(window.innerWidth-j)/2))):O>=S+R?(E=I.top-S-R,T=I.right-j,T<R&&(T=I.left,T+j>window.innerWidth-R&&(T=(window.innerWidth-j)/2))):(E=I.bottom+R,T=I.right-j,T<R&&(T=I.left)),v({top:E,left:T})}},10),k=f=>{a.current&&!a.current.contains(f.target)&&(t==null||t())},b=f=>{f.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",k),document.addEventListener("keydown",b),()=>{clearTimeout(_),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",b)}},[t,n]),l?e.jsxs(gm,{ref:a,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(mm,{children:[e.jsx(xm,{id:"invite-member-title",children:"Invite Member"}),e.jsx(ym,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(vm,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Email Address"}),e.jsx(de,{type:"email",placeholder:"colleague@company.com",value:s,onChange:_=>p(_.target.value),autoFocus:!0,"aria-label":"Email address for invitation","aria-describedby":"email-help"})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Role"}),e.jsx(ja,{options:$,value:g==null?void 0:g.id,onChange:_=>c(o.find(k=>k.id===_)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(bm,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!s||!g||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},wm=u.div`
2280
2280
  position: fixed;
2281
2281
  width: 400px;
2282
2282
  max-width: calc(100vw - 48px);
@@ -2327,7 +2327,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
2327
2327
  color: var(--color-foreground);
2328
2328
  background: var(--color-input-background);
2329
2329
  }
2330
- `,As=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var b;const a=i.useRef(null),[s,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]);Qe();const[h,d]=i.useState(!1),[l,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{deployment:w}=ve(),{toast:C}=st(),$=!!o,y=Array.isArray((b=w==null?void 0:w.b2b_settings)==null?void 0:b.organization_permissions)?w.b2b_settings.organization_permissions.map(f=>({value:f,label:f})):[];i.useEffect(()=>{m(!0);const f=setTimeout(()=>{if(!a.current)return;let R=null;if(n!=null&&n.current)R=n.current;else if($){const E=document.querySelectorAll("[data-role-dropdown-trigger]");for(let T=0;T<E.length;T++){const P=E[T];if(P.offsetParent!==null){R=P;break}}}else{const E=document.querySelectorAll("button");for(let T=0;T<E.length;T++){const P=E[T];if(P.textContent==="Add role"&&P.offsetParent!==null){R=P;break}}}if(R){const E=R.getBoundingClientRect(),T=400;let P=E.bottom+8,O=E.right-T;O<10&&(O=E.left),P+300>window.innerHeight&&(P=E.top-300-8),v({top:P,left:O})}},10),I=R=>{a.current&&!a.current.contains(R.target)&&(t==null||t())},j=R=>{R.key==="Escape"&&(t==null||t())},S=setTimeout(()=>{document.addEventListener("mousedown",I),document.addEventListener("keydown",j)},100);return()=>{clearTimeout(f),clearTimeout(S),document.removeEventListener("mousedown",I),document.removeEventListener("keydown",j)}},[t,$,n]);const z=f=>f.trim().replace(/[<>\"'&]/g,""),_=f=>f.length>=2&&f.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(f),k=async()=>{const f=z(s);if(!f){C("Please enter a role name","error");return}if(!_(f)){C("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(g.length===0){C("Please select at least one permission","error");return}d(!0);try{const I={id:o==null?void 0:o.id,name:f,permissions:g||[]};r==null||r(I)}catch(I){const j=I.message||`Failed to ${$?"update":"create"} role. Please try again.`;C(j,"error")}finally{d(!1)}};return l?e.jsxs(wm,{ref:a,$isInTable:$,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:f=>f.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(jm,{children:[e.jsx(km,{id:"role-dialog-title",children:$?"Edit Role":"Create New Role"}),e.jsx(Sm,{onClick:t,"aria-label":`Close ${$?"edit":"create"} role dialog`,children:e.jsx(Ke,{size:16})})]}),e.jsx(_m,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(pe,{children:[e.jsx(ue,{children:"Role Name"}),e.jsx(de,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:s,onChange:f=>p(f.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(pe,{children:[e.jsx(ue,{children:"Permissions"}),e.jsx(nl,{options:y,value:g,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Cm,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:k,disabled:!s||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," ",$?"Updating...":"Creating..."]}):$?"Update Role":"Create Role"})]})]}):null},jt=u.table`
2330
+ `,As=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var b;const a=i.useRef(null),[s,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]);Qe();const[h,d]=i.useState(!1),[l,m]=i.useState(!1),[x,v]=i.useState({top:0,left:0}),{deployment:w}=ve(),{toast:C}=st(),$=!!o,y=Array.isArray((b=w==null?void 0:w.b2b_settings)==null?void 0:b.organization_permissions)?w.b2b_settings.organization_permissions.map(f=>({value:f,label:f})):[];i.useEffect(()=>{m(!0);const f=setTimeout(()=>{if(!a.current)return;let R=null;if(n!=null&&n.current)R=n.current;else if($){const E=document.querySelectorAll("[data-role-dropdown-trigger]");for(let T=0;T<E.length;T++){const P=E[T];if(P.offsetParent!==null){R=P;break}}}else{const E=document.querySelectorAll("button");for(let T=0;T<E.length;T++){const P=E[T];if(P.textContent==="Add role"&&P.offsetParent!==null){R=P;break}}}if(R){const E=R.getBoundingClientRect(),T=400;let P=E.bottom+8,O=E.right-T;O<10&&(O=E.left),P+300>window.innerHeight&&(P=E.top-300-8),v({top:P,left:O})}},10),I=R=>{a.current&&!a.current.contains(R.target)&&(t==null||t())},j=R=>{R.key==="Escape"&&(t==null||t())},S=setTimeout(()=>{document.addEventListener("mousedown",I),document.addEventListener("keydown",j)},100);return()=>{clearTimeout(f),clearTimeout(S),document.removeEventListener("mousedown",I),document.removeEventListener("keydown",j)}},[t,$,n]);const z=f=>f.trim().replace(/[<>\"'&]/g,""),_=f=>f.length>=2&&f.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(f),k=async()=>{const f=z(s);if(!f){C("Please enter a role name","error");return}if(!_(f)){C("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(g.length===0){C("Please select at least one permission","error");return}d(!0);try{const I={id:o==null?void 0:o.id,name:f,permissions:g||[]};r==null||r(I)}catch(I){const j=I.message||`Failed to ${$?"update":"create"} role. Please try again.`;C(j,"error")}finally{d(!1)}};return l?e.jsxs(wm,{ref:a,$isInTable:$,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:f=>f.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(jm,{children:[e.jsx(km,{id:"role-dialog-title",children:$?"Edit Role":"Create New Role"}),e.jsx(Sm,{onClick:t,"aria-label":`Close ${$?"edit":"create"} role dialog`,children:e.jsx(Ke,{size:16})})]}),e.jsx(_m,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Role Name"}),e.jsx(de,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:s,onChange:f=>p(f.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Permissions"}),e.jsx(nl,{options:y,value:g,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(Cm,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:k,disabled:!s||h,style:{width:"auto"},children:h?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," ",$?"Updating...":"Creating..."]}):$?"Update Role":"Create Role"})]})]}):null},jt=u.table`
2331
2331
  width: 100%;
2332
2332
  border-collapse: separate;
2333
2333
  border-spacing: 0;
@@ -2531,8 +2531,8 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
2531
2531
  gap: 12px;
2532
2532
  margin-bottom: 24px;
2533
2533
  `,Lm=()=>{var O,D,M;const{activeOrganization:t,loading:r}=Qe(),{switchOrganization:o,refetch:n}=Fe(),{workspaces:a}=yt(),{deployment:s}=ve(),{deleteOrganization:p,updateOrganization:g}=Wo(),{toast:c}=st(),[h,d]=i.useState((t==null?void 0:t.name)||""),[l,m]=i.useState((t==null?void 0:t.description)||""),[x,v]=i.useState((t==null?void 0:t.image_url)||null),w=i.useRef(null),[C,$]=i.useState(!1),[y,z]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[_,k]=i.useState(""),[b,f]=i.useState(!1),[I,j]=i.useState(!1),S=i.useCallback(async()=>{if(!(!t||C))try{$(!0),await g(t,{name:h,description:l}),c("Changes saved","info")}catch(N){const F=N.message||"Failed to save changes. Please try again.";c(F,"error")}finally{$(!1)}},[t,h,l,x,y,g,c]);i.useEffect(()=>{var N;t&&(d(t.name||""),m(t.description||""),v(t.image_url||null),z({allowed_ips:((N=t.whitelisted_ips)==null?void 0:N.join(`
2534
- `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const R=i.useMemo(()=>a.filter(F=>F.organization.id===(t==null?void 0:t.id)),[a,t==null?void 0:t.id]),E=async()=>{if(!(!t||_!==t.name))try{f(!0),await o(""),await p(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{f(!1),k("")}};if(i.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const T=N=>{var F;if((F=N.target.files)!=null&&F[0]){const ee=N.target.files[0];if(ee.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!ee.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&URL.revokeObjectURL(x),v(URL.createObjectURL(ee)),setTimeout(()=>S(),100)}},P=()=>{w.current&&w.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:P,onMouseEnter:N=>{N.currentTarget.style.borderColor="var(--color-primary)",N.currentTarget.style.transform="scale(1.02)"},onMouseLeave:N=>{N.currentTarget.style.borderColor="var(--color-border)",N.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Dr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:w,style:{display:"none"},accept:"image/*",onChange:T,"aria-label":"Upload organization logo"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your organization"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(K,{onClick:()=>{var N;return(N=w.current)==null?void 0:N.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Dr,{size:14}),x?"Change":"Upload"]}),e.jsxs(K,{onClick:()=>{v(null),w.current&&(w.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(en,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your organization"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"name",children:"Organization Name"}),e.jsx(de,{id:"name",type:"text",value:h,onChange:N=>d(N.target.value),onBlur:S,placeholder:"Enter organization name",required:!0})]}),e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"description",children:"Description"}),e.jsx(de,{id:"description",as:"textarea",value:l,onChange:N=>m(N.target.value),onBlur:S,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(Ao,{checked:y.mfa_required,onChange:()=>{z(N=>({...N,mfa_required:!N.mfa_required})),setTimeout(()=>S(),100)}})]}),((O=s==null?void 0:s.b2b_settings)==null?void 0:O.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(Ao,{checked:y.ip_restrictions,onChange:()=>{z(N=>({...N,ip_restrictions:!N.ip_restrictions})),setTimeout(()=>S(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),y.ip_restrictions&&e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(de,{id:"allowed_ips",as:"textarea",value:y.allowed_ips,onChange:N=>z(F=>({...F,allowed_ips:N.target.value})),onBlur:S,placeholder:`192.168.1.1
2535
- 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((D=s==null?void 0:s.b2b_settings)==null?void 0:D.workspaces_enabled)&&R.length>0&&e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(ja,{options:R.map(N=>({value:N.id,label:N.name})),value:y.default_workspace_id,onChange:N=>{z(F=>({...F,default_workspace_id:N})),setTimeout(()=>S(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((M=s==null?void 0:s.b2b_settings)==null?void 0:M.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:I?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this organization, there is no going back. Please be certain."})]}),e.jsx(K,{onClick:()=>{I?(j(!1),k("")):j(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:I?"Cancel":"Delete"})]}),I&&e.jsxs("div",{children:[e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(de,{id:"confirm_name",type:"text",value:_,onChange:N=>k(N.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(K,{onClick:E,disabled:_!==(t==null?void 0:t.name)||b,style:{background:_===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:_===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:_===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:_===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:b?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})]})})},Ns=u.span`
2534
+ `))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const R=i.useMemo(()=>a.filter(F=>F.organization.id===(t==null?void 0:t.id)),[a,t==null?void 0:t.id]),E=async()=>{if(!(!t||_!==t.name))try{f(!0),await o(""),await p(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{f(!1),k("")}};if(i.useEffect(()=>()=>{x&&URL.revokeObjectURL(x)},[x]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const T=N=>{var F;if((F=N.target.files)!=null&&F[0]){const J=N.target.files[0];if(J.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!J.type.startsWith("image/")){c("Please select a valid image file","error");return}x&&URL.revokeObjectURL(x),v(URL.createObjectURL(J)),setTimeout(()=>S(),100)}},P=()=>{w.current&&w.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:P,onMouseEnter:N=>{N.currentTarget.style.borderColor="var(--color-primary)",N.currentTarget.style.transform="scale(1.02)"},onMouseLeave:N=>{N.currentTarget.style.borderColor="var(--color-border)",N.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Dr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:w,style:{display:"none"},accept:"image/*",onChange:T,"aria-label":"Upload organization logo"})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your organization"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(K,{onClick:()=>{var N;return(N=w.current)==null?void 0:N.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Dr,{size:14}),x?"Change":"Upload"]}),e.jsxs(K,{onClick:()=>{v(null),w.current&&(w.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(en,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Organization Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your organization"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"name",children:"Organization Name"}),e.jsx(de,{id:"name",type:"text",value:h,onChange:N=>d(N.target.value),onBlur:S,placeholder:"Enter organization name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"description",children:"Description"}),e.jsx(de,{id:"description",as:"textarea",value:l,onChange:N=>m(N.target.value),onBlur:S,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"Multi-Factor Authentication"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"mfa-description",children:"Require all members to set up MFA for added security"})]}),e.jsx(Ao,{checked:y.mfa_required,onChange:()=>{z(N=>({...N,mfa_required:!N.mfa_required})),setTimeout(()=>S(),100)}})]}),((O=s==null?void 0:s.b2b_settings)==null?void 0:O.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(ue,{style:{fontSize:"var(--font-xs)",color:"var(--color-foreground)",display:"block",marginBottom:"var(--space-2xs)"},children:"IP Restrictions"}),e.jsx("div",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)"},id:"ip-restrictions-description",children:"Only allow access from specific IP addresses"})]}),e.jsx(Ao,{checked:y.ip_restrictions,onChange:()=>{z(N=>({...N,ip_restrictions:!N.ip_restrictions})),setTimeout(()=>S(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),y.ip_restrictions&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(de,{id:"allowed_ips",as:"textarea",value:y.allowed_ips,onChange:N=>z(F=>({...F,allowed_ips:N.target.value})),onBlur:S,placeholder:`192.168.1.1
2535
+ 10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]}),((D=s==null?void 0:s.b2b_settings)==null?void 0:D.workspaces_enabled)&&R.length>0&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(ja,{options:R.map(N=>({value:N.id,label:N.name})),value:y.default_workspace_id,onChange:N=>{z(F=>({...F,default_workspace_id:N})),setTimeout(()=>S(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((M=s==null?void 0:s.b2b_settings)==null?void 0:M.allow_org_deletion)&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:I?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Organization"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this organization, there is no going back. Please be certain."})]}),e.jsx(K,{onClick:()=>{I?(j(!1),k("")):j(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:I?"Cancel":"Delete"})]}),I&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(de,{id:"confirm_name",type:"text",value:_,onChange:N=>k(N.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(K,{onClick:E,disabled:_!==(t==null?void 0:t.name)||b,style:{background:_===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:_===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:_===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:_===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:b?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})]})})},Ns=u.span`
2536
2536
  background: var(--color-primary-background);
2537
2537
  color: var(--color-primary);
2538
2538
  padding: 4px 8px;
@@ -2921,7 +2921,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
2921
2921
  color: var(--color-foreground);
2922
2922
  background: var(--color-input-background);
2923
2923
  }
2924
- `,bx=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:a})=>{const s=i.useRef(null),[p,g]=i.useState(""),[c,h]=i.useState(null),[d,l]=i.useState(!1),[m,x]=i.useState(!1),[v,w]=i.useState({top:0,left:0}),{toast:C}=st(),$=o.map(_=>({value:_.id,label:_.name}));i.useEffect(()=>{x(!0);const _=setTimeout(()=>{if(!s.current||!(a!=null&&a.current))return;const I=a.current;if(I){const j=I.getBoundingClientRect(),S=360,R=250,E=8;let T=0,P=0;const O=window.innerHeight-j.bottom,D=j.top;O>=R+E?(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):D>=R+E?(T=j.top-R-E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left)),w({top:T,left:P})}},10),k=I=>{s.current&&!s.current.contains(I.target)&&(t==null||t())},b=I=>{I.key==="Escape"&&(t==null||t())},f=setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",b)},100);return()=>{clearTimeout(_),clearTimeout(f),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",b)}},[t,a]);const y=_=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_),z=async()=>{const _=p.trim().toLowerCase();if(!(!_||!c)){if(!y(_)){C("Please enter a valid email address","error");return}if(_.length>320){C("Email address is too long","error");return}l(!0);try{await n(_,c.id),r==null||r()}catch(k){const b=k.message||"Failed to send invitation. Please try again.";C(b,"error")}finally{l(!1)}}};return m?e.jsxs(hx,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(fx,{children:[e.jsx(gx,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(vx,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(mx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(pe,{children:[e.jsx(ue,{children:"Email Address"}),e.jsx(de,{type:"email",placeholder:"colleague@company.com",value:p,onChange:_=>g(_.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(pe,{children:[e.jsx(ue,{children:"Role"}),e.jsx(ja,{options:$,value:c==null?void 0:c.id,onChange:_=>h(o.find(k=>k.id===_)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(xx,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!p||!c||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},yx=u.div`
2924
+ `,bx=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:a})=>{const s=i.useRef(null),[p,g]=i.useState(""),[c,h]=i.useState(null),[d,l]=i.useState(!1),[m,x]=i.useState(!1),[v,w]=i.useState({top:0,left:0}),{toast:C}=st(),$=o.map(_=>({value:_.id,label:_.name}));i.useEffect(()=>{x(!0);const _=setTimeout(()=>{if(!s.current||!(a!=null&&a.current))return;const I=a.current;if(I){const j=I.getBoundingClientRect(),S=360,R=250,E=8;let T=0,P=0;const O=window.innerHeight-j.bottom,D=j.top;O>=R+E?(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):D>=R+E?(T=j.top-R-E,P=j.right-S,P<E&&(P=j.left,P+S>window.innerWidth-E&&(P=(window.innerWidth-S)/2))):(T=j.bottom+E,P=j.right-S,P<E&&(P=j.left)),w({top:T,left:P})}},10),k=I=>{s.current&&!s.current.contains(I.target)&&(t==null||t())},b=I=>{I.key==="Escape"&&(t==null||t())},f=setTimeout(()=>{document.addEventListener("mousedown",k),document.addEventListener("keydown",b)},100);return()=>{clearTimeout(_),clearTimeout(f),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",b)}},[t,a]);const y=_=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(_),z=async()=>{const _=p.trim().toLowerCase();if(!(!_||!c)){if(!y(_)){C("Please enter a valid email address","error");return}if(_.length>320){C("Email address is too long","error");return}l(!0);try{await n(_,c.id),r==null||r()}catch(k){const b=k.message||"Failed to send invitation. Please try again.";C(b,"error")}finally{l(!1)}}};return m?e.jsxs(hx,{ref:s,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:_=>_.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(fx,{children:[e.jsx(gx,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(vx,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Ke,{size:16})})]}),e.jsx(mx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Email Address"}),e.jsx(de,{type:"email",placeholder:"colleague@company.com",value:p,onChange:_=>g(_.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Role"}),e.jsx(ja,{options:$,value:c==null?void 0:c.id,onChange:_=>h(o.find(k=>k.id===_)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(xx,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!p||!c||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx(Re,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},yx=u.div`
2925
2925
  position: fixed;
2926
2926
  width: 360px;
2927
2927
  max-width: calc(100vw - 48px);
@@ -2970,7 +2970,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
2970
2970
  color: var(--color-foreground);
2971
2971
  background: var(--color-input-background);
2972
2972
  }
2973
- `,Us=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var _;const a=i.useRef(null),[s,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]),[h,d]=i.useState(!1),{deployment:l}=ve(),[m,x]=i.useState(!1),[v,w]=i.useState({top:0,left:0}),{toast:C}=st(),$=!!o,y=(((_=l==null?void 0:l.b2b_settings)==null?void 0:_.workspace_permissions)||[]).map(k=>({value:k,label:k}));i.useEffect(()=>{x(!0);const k=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const j=n.current;if(j){const S=j.getBoundingClientRect(),R=360,E=250,T=8;let P=0,O=0;const D=window.innerHeight-S.bottom,M=S.top;D>=E+T?(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):M>=E+T?(P=S.top-E-T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left)),w({top:P,left:O})}},10),b=j=>{a.current&&!a.current.contains(j.target)&&(t==null||t())},f=j=>{j.key==="Escape"&&(t==null||t())},I=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",f)},100);return()=>{clearTimeout(k),clearTimeout(I),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,n]);const z=async()=>{if(s.trim()){d(!0);try{const k={id:o==null?void 0:o.id,name:s.trim(),permissions:g};r==null||r(k)}catch(k){const b=k.message||"Failed to save role. Please try again.";C(b,"error")}finally{d(!1)}}};return m?e.jsxs(yx,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),children:[e.jsxs(wx,{children:[e.jsx(jx,{children:$?"Edit Role":"Add Role"}),e.jsx(Cx,{onClick:t,children:e.jsx(Ke,{size:16})})]}),e.jsx(kx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(pe,{children:[e.jsx(ue,{children:"Role Name"}),e.jsx(de,{type:"text",value:s,onChange:k=>p(k.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(pe,{children:[e.jsx(ue,{children:"Permissions"}),e.jsx(nl,{options:y,value:g,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(_x,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!s.trim()||h,style:{width:"auto"},children:h?"Saving...":$?"Update":"Create"})]})]}):null},kr=i.createContext(void 0),It=()=>{const t=i.useContext(kr);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},Sx=u.div`
2973
+ `,Us=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var _;const a=i.useRef(null),[s,p]=i.useState((o==null?void 0:o.name)||""),[g,c]=i.useState((o==null?void 0:o.permissions)||[]),[h,d]=i.useState(!1),{deployment:l}=ve(),[m,x]=i.useState(!1),[v,w]=i.useState({top:0,left:0}),{toast:C}=st(),$=!!o,y=(((_=l==null?void 0:l.b2b_settings)==null?void 0:_.workspace_permissions)||[]).map(k=>({value:k,label:k}));i.useEffect(()=>{x(!0);const k=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const j=n.current;if(j){const S=j.getBoundingClientRect(),R=360,E=250,T=8;let P=0,O=0;const D=window.innerHeight-S.bottom,M=S.top;D>=E+T?(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):M>=E+T?(P=S.top-E-T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left)),w({top:P,left:O})}},10),b=j=>{a.current&&!a.current.contains(j.target)&&(t==null||t())},f=j=>{j.key==="Escape"&&(t==null||t())},I=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",f)},100);return()=>{clearTimeout(k),clearTimeout(I),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",f)}},[t,n]);const z=async()=>{if(s.trim()){d(!0);try{const k={id:o==null?void 0:o.id,name:s.trim(),permissions:g};r==null||r(k)}catch(k){const b=k.message||"Failed to save role. Please try again.";C(b,"error")}finally{d(!1)}}};return m?e.jsxs(yx,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:k=>k.stopPropagation(),children:[e.jsxs(wx,{children:[e.jsx(jx,{children:$?"Edit Role":"Add Role"}),e.jsx(Cx,{onClick:t,children:e.jsx(Ke,{size:16})})]}),e.jsx(kx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(he,{children:[e.jsx(ue,{children:"Role Name"}),e.jsx(de,{type:"text",value:s,onChange:k=>p(k.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{children:"Permissions"}),e.jsx(nl,{options:y,value:g,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(_x,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(K,{onClick:z,disabled:!s.trim()||h,style:{width:"auto"},children:h?"Saving...":$?"Update":"Create"})]})]}):null},kr=i.createContext(void 0),It=()=>{const t=i.useContext(kr);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},Sx=u.div`
2974
2974
  * {
2975
2975
  box-sizing: border-box;
2976
2976
  font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
@@ -3136,7 +3136,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
3136
3136
  opacity: 0.5;
3137
3137
  cursor: not-allowed;
3138
3138
  }
3139
- `,Ax=()=>{const{activeWorkspace:t,loading:r,getRoles:o}=Pt(),{workspaces:n}=yt(),{client:a}=De(),s=n==null?void 0:n.find(E=>E.id===(t==null?void 0:t.id)),[p,g]=i.useState(!0),[c,h]=i.useState(!0),[d,l]=i.useState(""),[m,x]=i.useState(""),[v,w]=i.useState([]),[C,$]=i.useState([]),[y,z]=i.useState(!1),_=i.useRef(null),k=i.useCallback(async()=>{if(!t||!s)return[];try{return(await V(await a(`/organizations/${s.organization.id}/invitations`,{method:"GET"}))).data.filter(P=>P.workspace_id===t.id)}catch{return[]}},[a,t,s]),b=i.useCallback(async(E,T)=>{if(!t||!s)return;const O=(await V(await a(`/organizations/${s.organization.id}/roles`,{method:"GET"}))).data,D=O.find(N=>!N.organization_id)||O[0];return(await V(await a(`/organizations/${s.organization.id}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:E,role_id:D==null?void 0:D.id,workspace_id:t.id,workspace_role_id:T})}))).data},[a,t,s]),f=i.useCallback(async E=>!t||!s?void 0:(await V(await a(`/organizations/${s.organization.id}/invitations/${E}/remove`,{method:"POST"}))).data,[a,t,s]);i.useEffect(()=>{if(!t)return;(async()=>{g(!0),h(!0);try{const[T,P]=await Promise.all([o(),k()]);$(T),w(P)}catch{}finally{g(!1),h(!1)}})()},[t==null?void 0:t.id]);const I=async E=>{try{await f(E.id);const T=await k();w(T)}catch{}},j=async E=>{var T;try{await f(E.id),await b(E.email,E.workspace_role_id||((T=E.initial_workspace_role)==null?void 0:T.id)||E.role_id);const P=await k();w(P),x("Invitation resent successfully"),setTimeout(()=>x(""),3e3)}catch{}},S=async()=>{z(!1);const E=await k();w(E),x("Invitation sent successfully"),setTimeout(()=>x(""),3e3)},R=i.useMemo(()=>d?v.filter(E=>(E.email||"").toLowerCase().includes(d.toLowerCase())):v,[v,d]);return r||p||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[m&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 16px",background:"var(--color-success-background)",color:"var(--color-success)",borderRadius:"6px",fontSize:"14px"},children:["✓ ",m]}),e.jsxs(Ca,{children:[e.jsx(wt,{value:d,onChange:l,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(K,{ref:_,onClick:()=>z(!y),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),y&&e.jsx(bx,{onClose:()=>z(!1),onSuccess:S,roles:C,createInvitation:b,triggerRef:_})]})]}),e.jsx("div",{children:R.length===0?e.jsx(it,{title:d?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsx("div",{style:{borderTop:"1px solid var(--color-border)"},children:R.map(E=>{var T,P,O;return e.jsxs(Px,{children:[e.jsx(Rx,{children:e.jsxs(Tx,{children:[e.jsx(Ox,{children:E.email}),e.jsx(Mx,{children:((T=E.initial_workspace_role)==null?void 0:T.name)||((P=E.initial_organization_role)==null?void 0:P.name)||((O=E.role)==null?void 0:O.name)})]})}),e.jsx(Lx,{children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsx(wl,{children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>j(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Wr,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Pe,{$destructive:!0,onClick:()=>I(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jo,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})]},E.id)})})})]})},Dx=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:a,addMemberRole:s,removeMemberRole:p}=Pt(),{session:g}=Fe(),{toast:c}=i.useContext(kr)||{},[h,d]=i.useState(""),{data:l=[],isLoading:m,mutate:x}=We(t?`/api/workspaces/${t.id}/members`:null,()=>o()||[]),{data:v=[],isLoading:w}=We(t?`/api/workspaces/${t.id}/roles`:null,()=>n()||[]),C=v,$=i.useMemo(()=>h?l.filter(b=>{var E;const f=b.public_user_data;if(!f)return!1;const I=f.first_name||"",j=f.last_name||"",S=((E=f.primary_email_address)==null?void 0:E.email)||"";return`${I} ${j}`.trim().toLowerCase().includes(h.toLowerCase())||S.toLowerCase().includes(h.toLowerCase())}):l,[l,h]),y=async b=>{try{await a(b),c==null||c("Member removed successfully","info"),x()}catch{c==null||c("Failed to remove member","error")}},z=async(b,f,I)=>{try{I?(await p(b,f),c==null||c("Role removed successfully","info")):(await s(b,f),c==null||c("Role added successfully","info")),x()}catch{c==null||c("Failed to toggle role","error"),c==null||c("Failed to update role","error")}},_=(b="",f="")=>`${b[0]||""}${f[0]||""}`.toUpperCase(),k=(b,f)=>{var I;return((I=b.roles)==null?void 0:I.some(j=>j.id===f))||!1};return r||m||w?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Ca,{children:e.jsx(wt,{value:h,onChange:d,placeholder:"Search members..."})}),$.length===0?e.jsx(it,{title:h?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Role"})]})}),e.jsx(_t,{children:$.map(b=>{var S,R;const f=b.public_user_data,I=b.roles||[],j=(f==null?void 0:f.id)===((S=g==null?void 0:g.active_signin)==null?void 0:S.user_id);return e.jsxs(Ue,{children:[e.jsx(gl,{children:e.jsxs("div",{children:[e.jsx(Ix,{children:f&&f.profile_picture_url?e.jsx("img",{src:f.profile_picture_url,alt:`${f.first_name||""} ${f.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):_(f==null?void 0:f.first_name,f==null?void 0:f.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var T;if(!f)return"Unknown User";const E=`${f.first_name||""} ${f.last_name||""}`.trim();return E||((T=f.primary_email_address)==null?void 0:T.email)||"Unknown User"})()}),j&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(R=f==null?void 0:f.primary_email_address)==null?void 0:R.email})]})]})}),e.jsx(Oe,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(Ct,{children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsxs(K,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:I.length>0?I[0].name:"No role"}),e.jsx(er,{size:14})]})}),e.jsxs(nt,{children:[C.map(E=>{const T=k(b,E.id);return e.jsx(Pe,{onClick:()=>z(b.id,E.id,T),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:E.name}),T&&e.jsx(rt,{size:16,color:"var(--color-success)"})]})},E.id)}),e.jsx(tn,{}),e.jsx(Pe,{$destructive:!0,onClick:()=>y(b.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jo,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},b.id)})})]})]})},Nx=()=>{const{activeWorkspace:t,loading:r,updateWorkspace:o}=Pt(),{deleteWorkspace:n}=yt(),{toast:a}=i.useContext(kr)||{},[s,p]=i.useState((t==null?void 0:t.name)||""),[g,c]=i.useState((t==null?void 0:t.description)||""),[h,d]=i.useState(null),[l,m]=i.useState((t==null?void 0:t.image_url)||null),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState(""),[z,_]=i.useState(!1),[k,b]=i.useState(!1),f=i.useRef(null),I=i.useRef(null);if(i.useEffect(()=>{t&&(p(t.name||""),c(t.description||""),m(t.image_url||null))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const j=N=>{var F;if((F=N.target.files)!=null&&F[0]){const ee=N.target.files[0];d(ee),m(URL.createObjectURL(ee)),setTimeout(()=>R(),100)}},S=()=>{f.current&&f.current.click()},R=i.useCallback(async()=>{if(!(!t||w))try{C(!0);const N={};h&&(N.image=h,d(null)),s!==t.name&&(N.name=s),g!==t.description&&(N.description=g),Object.keys(N).length>0&&(await o(N),v(!0),setTimeout(()=>v(!1),3e3))}catch{a==null||a("Failed to auto-save workspace","error")}finally{C(!1)}},[t,o,s,g,h,w]),E=i.useCallback(()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{R()},1e3)},[R]),T=N=>{p(N.target.value),E()},P=N=>{c(N.target.value),E()},O=()=>{I.current&&clearTimeout(I.current),R()},D=()=>{I.current&&clearTimeout(I.current),R()},M=async()=>{if(!(!t||$!==t.name))try{_(!0),await n(t),a==null||a("Workspace deleted successfully","info")}catch(N){a==null||a(N.message||"Failed to delete workspace","error")}finally{_(!1),y(""),b(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:l?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:S,onMouseEnter:N=>{N.currentTarget.style.borderColor="var(--color-primary)",N.currentTarget.style.transform="scale(1.02)"},onMouseLeave:N=>{N.currentTarget.style.borderColor="var(--color-border)",N.currentTarget.style.transform="scale(1)"},children:[l?e.jsx("img",{src:l,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Dr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:f,style:{display:"none"},accept:"image/*",onChange:j})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(K,{onClick:()=>{var N;return(N=f.current)==null?void 0:N.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Dr,{size:14}),l?"Change":"Upload"]}),e.jsxs(K,{onClick:()=>{m(null),d(null),f.current&&(f.current.value=""),setTimeout(()=>R(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jo,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"name",children:"Workspace Name"}),e.jsx(de,{id:"name",type:"text",value:s,onChange:T,onBlur:O,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"description",children:"Description"}),e.jsx(de,{id:"description",as:"textarea",value:g,onChange:P,onBlur:D,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:k?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(K,{onClick:()=>{k?(b(!1),y("")):b(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:k?"Cancel":"Delete"})]}),k&&e.jsxs("div",{children:[e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(de,{id:"confirm_workspace_name",type:"text",value:$,onChange:N=>y(N.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(K,{onClick:M,disabled:$!==(t==null?void 0:t.name)||z,style:{background:$===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:$===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:$===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:$===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:z?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]}),x&&e.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"var(--color-success-background)",color:"var(--color-success)",padding:"var(--space-sm) var(--space-lg)",borderRadius:"var(--radius-lg)",boxShadow:"0 4px 12px var(--color-shadow)",display:"flex",alignItems:"center",gap:"var(--space-xs)",fontSize:"var(--font-xs)",fontWeight:500,zIndex:1e3,animation:"slideUp 0.3s ease-out"},children:"✓ Changes saved automatically"}),e.jsx("style",{children:`
3139
+ `,Ax=()=>{const{activeWorkspace:t,loading:r,getRoles:o}=Pt(),{workspaces:n}=yt(),{client:a}=De(),s=n==null?void 0:n.find(E=>E.id===(t==null?void 0:t.id)),[p,g]=i.useState(!0),[c,h]=i.useState(!0),[d,l]=i.useState(""),[m,x]=i.useState(""),[v,w]=i.useState([]),[C,$]=i.useState([]),[y,z]=i.useState(!1),_=i.useRef(null),k=i.useCallback(async()=>{if(!t||!s)return[];try{return(await V(await a(`/organizations/${s.organization.id}/invitations`,{method:"GET"}))).data.filter(P=>P.workspace_id===t.id)}catch{return[]}},[a,t,s]),b=i.useCallback(async(E,T)=>{if(!t||!s)return;const O=(await V(await a(`/organizations/${s.organization.id}/roles`,{method:"GET"}))).data,D=O.find(N=>!N.organization_id)||O[0];return(await V(await a(`/organizations/${s.organization.id}/invitations`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:E,role_id:D==null?void 0:D.id,workspace_id:t.id,workspace_role_id:T})}))).data},[a,t,s]),f=i.useCallback(async E=>!t||!s?void 0:(await V(await a(`/organizations/${s.organization.id}/invitations/${E}/remove`,{method:"POST"}))).data,[a,t,s]);i.useEffect(()=>{if(!t)return;(async()=>{g(!0),h(!0);try{const[T,P]=await Promise.all([o(),k()]);$(T),w(P)}catch{}finally{g(!1),h(!1)}})()},[t==null?void 0:t.id]);const I=async E=>{try{await f(E.id);const T=await k();w(T)}catch{}},j=async E=>{var T;try{await f(E.id),await b(E.email,E.workspace_role_id||((T=E.initial_workspace_role)==null?void 0:T.id)||E.role_id);const P=await k();w(P),x("Invitation resent successfully"),setTimeout(()=>x(""),3e3)}catch{}},S=async()=>{z(!1);const E=await k();w(E),x("Invitation sent successfully"),setTimeout(()=>x(""),3e3)},R=i.useMemo(()=>d?v.filter(E=>(E.email||"").toLowerCase().includes(d.toLowerCase())):v,[v,d]);return r||p||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[m&&e.jsxs("div",{style:{marginBottom:"16px",padding:"12px 16px",background:"var(--color-success-background)",color:"var(--color-success)",borderRadius:"6px",fontSize:"14px"},children:["✓ ",m]}),e.jsxs(Ca,{children:[e.jsx(wt,{value:d,onChange:l,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(K,{ref:_,onClick:()=>z(!y),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),y&&e.jsx(bx,{onClose:()=>z(!1),onSuccess:S,roles:C,createInvitation:b,triggerRef:_})]})]}),e.jsx("div",{children:R.length===0?e.jsx(it,{title:d?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsx("div",{style:{borderTop:"1px solid var(--color-border)"},children:R.map(E=>{var T,P,O;return e.jsxs(Px,{children:[e.jsx(Rx,{children:e.jsxs(Tx,{children:[e.jsx(Ox,{children:E.email}),e.jsx(Mx,{children:((T=E.initial_workspace_role)==null?void 0:T.name)||((P=E.initial_organization_role)==null?void 0:P.name)||((O=E.role)==null?void 0:O.name)})]})}),e.jsx(Lx,{children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsx(wl,{children:"•••"})}),e.jsxs(nt,{children:[e.jsx(Pe,{onClick:()=>j(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Wr,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Pe,{$destructive:!0,onClick:()=>I(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jo,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})]},E.id)})})})]})},Dx=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:a,addMemberRole:s,removeMemberRole:p}=Pt(),{session:g}=Fe(),{toast:c}=i.useContext(kr)||{},[h,d]=i.useState(""),{data:l=[],isLoading:m,mutate:x}=We(t?`/api/workspaces/${t.id}/members`:null,()=>o()||[]),{data:v=[],isLoading:w}=We(t?`/api/workspaces/${t.id}/roles`:null,()=>n()||[]),C=v,$=i.useMemo(()=>h?l.filter(b=>{var E;const f=b.public_user_data;if(!f)return!1;const I=f.first_name||"",j=f.last_name||"",S=((E=f.primary_email_address)==null?void 0:E.email)||"";return`${I} ${j}`.trim().toLowerCase().includes(h.toLowerCase())||S.toLowerCase().includes(h.toLowerCase())}):l,[l,h]),y=async b=>{try{await a(b),c==null||c("Member removed successfully","info"),x()}catch{c==null||c("Failed to remove member","error")}},z=async(b,f,I)=>{try{I?(await p(b,f),c==null||c("Role removed successfully","info")):(await s(b,f),c==null||c("Role added successfully","info")),x()}catch{c==null||c("Failed to toggle role","error"),c==null||c("Failed to update role","error")}},_=(b="",f="")=>`${b[0]||""}${f[0]||""}`.toUpperCase(),k=(b,f)=>{var I;return((I=b.roles)==null?void 0:I.some(j=>j.id===f))||!1};return r||m||w?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})}):e.jsxs(e.Fragment,{children:[e.jsx(Ca,{children:e.jsx(wt,{value:h,onChange:d,placeholder:"Search members..."})}),$.length===0?e.jsx(it,{title:h?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(jt,{children:[e.jsx(kt,{children:e.jsxs(Ue,{children:[e.jsx(Ce,{children:"Member"}),e.jsx(Ce,{children:"Joined"}),e.jsx(Ce,{children:"Role"})]})}),e.jsx(_t,{children:$.map(b=>{var S,R;const f=b.public_user_data,I=b.roles||[],j=(f==null?void 0:f.id)===((S=g==null?void 0:g.active_signin)==null?void 0:S.user_id);return e.jsxs(Ue,{children:[e.jsx(gl,{children:e.jsxs("div",{children:[e.jsx(Ix,{children:f&&f.profile_picture_url?e.jsx("img",{src:f.profile_picture_url,alt:`${f.first_name||""} ${f.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):_(f==null?void 0:f.first_name,f==null?void 0:f.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var T;if(!f)return"Unknown User";const E=`${f.first_name||""} ${f.last_name||""}`.trim();return E||((T=f.primary_email_address)==null?void 0:T.email)||"Unknown User"})()}),j&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(R=f==null?void 0:f.primary_email_address)==null?void 0:R.email})]})]})}),e.jsx(Oe,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(Ct,{children:e.jsxs(ot,{children:[e.jsx(at,{children:e.jsxs(K,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"8px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:I.length>0?I[0].name:"No role"}),e.jsx(er,{size:14})]})}),e.jsxs(nt,{children:[C.map(E=>{const T=k(b,E.id);return e.jsx(Pe,{onClick:()=>z(b.id,E.id,T),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:E.name}),T&&e.jsx(rt,{size:16,color:"var(--color-success)"})]})},E.id)}),e.jsx(tn,{}),e.jsx(Pe,{$destructive:!0,onClick:()=>y(b.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Jo,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},b.id)})})]})]})},Nx=()=>{const{activeWorkspace:t,loading:r,updateWorkspace:o}=Pt(),{deleteWorkspace:n}=yt(),{toast:a}=i.useContext(kr)||{},[s,p]=i.useState((t==null?void 0:t.name)||""),[g,c]=i.useState((t==null?void 0:t.description)||""),[h,d]=i.useState(null),[l,m]=i.useState((t==null?void 0:t.image_url)||null),[x,v]=i.useState(!1),[w,C]=i.useState(!1),[$,y]=i.useState(""),[z,_]=i.useState(!1),[k,b]=i.useState(!1),f=i.useRef(null),I=i.useRef(null);if(i.useEffect(()=>{t&&(p(t.name||""),c(t.description||""),m(t.image_url||null))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const j=N=>{var F;if((F=N.target.files)!=null&&F[0]){const J=N.target.files[0];d(J),m(URL.createObjectURL(J)),setTimeout(()=>R(),100)}},S=()=>{f.current&&f.current.click()},R=i.useCallback(async()=>{if(!(!t||w))try{C(!0);const N={};h&&(N.image=h,d(null)),s!==t.name&&(N.name=s),g!==t.description&&(N.description=g),Object.keys(N).length>0&&(await o(N),v(!0),setTimeout(()=>v(!1),3e3))}catch{a==null||a("Failed to auto-save workspace","error")}finally{C(!1)}},[t,o,s,g,h,w]),E=i.useCallback(()=>{I.current&&clearTimeout(I.current),I.current=setTimeout(()=>{R()},1e3)},[R]),T=N=>{p(N.target.value),E()},P=N=>{c(N.target.value),E()},O=()=>{I.current&&clearTimeout(I.current),R()},D=()=>{I.current&&clearTimeout(I.current),R()},M=async()=>{if(!(!t||$!==t.name))try{_(!0),await n(t),a==null||a("Workspace deleted successfully","info")}catch(N){a==null||a(N.message||"Failed to delete workspace","error")}finally{_(!1),y(""),b(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:l?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:S,onMouseEnter:N=>{N.currentTarget.style.borderColor="var(--color-primary)",N.currentTarget.style.transform="scale(1.02)"},onMouseLeave:N=>{N.currentTarget.style.borderColor="var(--color-border)",N.currentTarget.style.transform="scale(1)"},children:[l?e.jsx("img",{src:l,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Dr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:f,style:{display:"none"},accept:"image/*",onChange:j})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Logo"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your workspace"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(K,{onClick:()=>{var N;return(N=f.current)==null?void 0:N.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Dr,{size:14}),l?"Change":"Upload"]}),e.jsxs(K,{onClick:()=>{m(null),d(null),f.current&&(f.current.value=""),setTimeout(()=>R(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Jo,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Workspace Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your workspace"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"name",children:"Workspace Name"}),e.jsx(de,{id:"name",type:"text",value:s,onChange:T,onBlur:O,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"description",children:"Description"}),e.jsx(de,{id:"description",as:"textarea",value:g,onChange:P,onBlur:D,placeholder:"Tell us about your workspace",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your workspace and its purpose"})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:k?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Workspace"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete this workspace, there is no going back. Please be certain."})]}),e.jsx(K,{onClick:()=>{k?(b(!1),y("")):b(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:k?"Cancel":"Delete"})]}),k&&e.jsxs("div",{children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(de,{id:"confirm_workspace_name",type:"text",value:$,onChange:N=>y(N.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(K,{onClick:M,disabled:$!==(t==null?void 0:t.name)||z,style:{background:$===(t==null?void 0:t.name)?"var(--color-error)":"transparent",color:$===(t==null?void 0:t.name)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:$===(t==null?void 0:t.name)?"pointer":"not-allowed",opacity:$===(t==null?void 0:t.name)?1:.6,marginTop:"12px"},children:z?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]}),x&&e.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",background:"var(--color-success-background)",color:"var(--color-success)",padding:"var(--space-sm) var(--space-lg)",borderRadius:"var(--radius-lg)",boxShadow:"0 4px 12px var(--color-shadow)",display:"flex",alignItems:"center",gap:"var(--space-xs)",fontSize:"var(--font-xs)",fontWeight:500,zIndex:1e3,animation:"slideUp 0.3s ease-out"},children:"✓ Changes saved automatically"}),e.jsx("style",{children:`
3140
3140
  @keyframes slideUp {
3141
3141
  from {
3142
3142
  opacity: 0;
@@ -3498,7 +3498,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
3498
3498
  height: 16px;
3499
3499
  background: var(--color-border);
3500
3500
  border-radius: 2px;
3501
- `,Cl=({showPersonal:t=!0})=>{var ie,Y,ae;const[r,o]=i.useState(!1),[n,a]=i.useState(!1),[s,p]=i.useState(new Set),g=i.useRef(null),c=i.useRef(null),h=_l({triggerRef:g,isOpen:r,minWidth:300}),d=Or(!1),l=Or(!1),m=Or(!1),x=Or(!1),[v,w]=i.useState(null),[C,$]=i.useState(!1),[y,z]=i.useState(null),{organizationMemberships:_,loading:k,refetch:b}=bt(),{activeOrganization:f,leave:I}=Qe(),{activeWorkspace:j,leave:S}=Pt(),{workspaces:R,loading:E}=yt(),{session:T,loading:P,switchOrganization:O,switchWorkspace:D}=Fe(),{deployment:M}=ve(),{toast:N}=st(),F=M==null?void 0:M.b2b_settings.organizations_enabled,ee=M==null?void 0:M.b2b_settings.workspaces_enabled,ce=M==null?void 0:M.b2b_settings.allow_users_to_create_orgs,J=!((ie=T==null?void 0:T.active_signin)!=null&&ie.active_organization_membership_id),X=i.useMemo(()=>{var B,A;if(J)return{name:"Personal account",image_url:(A=(B=T==null?void 0:T.active_signin)==null?void 0:B.user)==null?void 0:A.profile_picture_url,isPersonal:!0};let q=(f==null?void 0:f.name)||"";return ee&&j&&(q=`${f==null?void 0:f.name} / ${j.name}`),{name:q,image_url:f==null?void 0:f.image_url,isPersonal:!1}},[J,f,j,T,ee]);i.useEffect(()=>{if(!r)return;let q=null;const B=setTimeout(()=>{const A=W=>{var G,se;const L=W.target;(G=g.current)!=null&&G.contains(L)||(se=c.current)!=null&&se.contains(L)||(o(!1),z(null))};document.addEventListener("mousedown",A),q=()=>{document.removeEventListener("mousedown",A)}},50);return()=>{clearTimeout(B),q==null||q()}},[r]),i.useEffect(()=>{if(y){const q=setTimeout(()=>{z(null)},5e3);return()=>clearTimeout(q)}},[y]);const U=()=>{b()};if(!F)return null;const Z=q=>{a(!0),O(q).finally(()=>{a(!1)})},Q=q=>{a(!0),D(q).finally(()=>{a(!1)})},ne=q=>{const B=new Set(s);B.has(q)?B.delete(q):B.add(q),p(B)},re=q=>q.split(" ").map(B=>B[0]).join("").toUpperCase().slice(0,2);return k||P?e.jsx(le,{children:e.jsx(Vs,{children:e.jsxs(Kx,{children:[e.jsxs(Gs,{children:[e.jsx(Qx,{}),e.jsx(Xx,{})]}),e.jsx(Jx,{})]})})}):e.jsx(le,{children:e.jsxs(Vs,{children:[e.jsxs(Bx,{ref:g,onClick:()=>{o(!r),r||z(null)},disabled:n,children:[e.jsxs(Gs,{children:[e.jsx(Ux,{children:X.image_url?e.jsx(Wx,{src:X.image_url,alt:X.name}):X.isPersonal?e.jsx(Mo,{size:12}):re(X.name)}),e.jsx(Vx,{children:X.name})]}),e.jsx(dh,{size:16})]}),typeof window<"u"&&Nr.createPortal(e.jsx(le,{children:e.jsx(Gx,{ref:c,$isOpen:r,$position:h,children:k||E?e.jsxs(Zx,{children:[e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsxs(bo,{children:[e.jsx(yo,{width:"120px"}),e.jsx(Qs,{width:"80px"})]})]}),e.jsx(lr,{}),e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsx(bo,{children:e.jsx(yo,{width:"100px"})})]}),e.jsx(lr,{}),e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsxs(bo,{children:[e.jsx(yo,{width:"140px"}),e.jsx(Qs,{width:"60px"})]})]}),e.jsx(lr,{}),e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsx(bo,{children:e.jsx(yo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Po,{as:"button",$isActive:J,onClick:q=>{q.stopPropagation(),J||Z()},disabled:n||J,children:[J&&e.jsx(go,{}),e.jsxs(ht,{children:[e.jsx(Hx,{children:(ae=(Y=T==null?void 0:T.active_signin)==null?void 0:Y.user)!=null&&ae.profile_picture_url?e.jsx(qx,{src:T.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Mo,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Personal account"})})]}),!J&&e.jsx(ho,{className:"hover-arrow",size:14})]}),!J&&f&&e.jsx(lr,{})]}),!J&&f&&e.jsxs(Po,{$isActive:!0,onClick:()=>{ee&&ne(f.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(go,{}),e.jsxs(ht,{children:[ee&&e.jsx(er,{size:12,style:{marginRight:"4px",transform:s.has(f.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Hs,{children:f.image_url?e.jsx(qs,{src:f.image_url,alt:f.name}):re(f.name)}),e.jsx(ft,{children:e.jsx(gt,{children:f.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ro,{onClick:q=>{q.stopPropagation(),l.open()},title:"Manage organization",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async q=>{q.stopPropagation(),$(!0),z(null);try{await I(),await b(),setTimeout(()=>{$(!1)},500)}catch(B){z(B instanceof Error?B.message:"Failed to leave organization"),$(!1)}},disabled:C,title:"Leave organization",children:e.jsx(zt,{size:12})})]})]}),f&&ee&&s.has(f.id)&&e.jsxs(e.Fragment,{children:[R==null?void 0:R.filter(q=>q.organization.id===f.id).map(q=>{const B=(j==null?void 0:j.id)===q.id;return e.jsxs(mo,{as:B?void 0:"button",$isActive:B,onClick:B?void 0:()=>Q(q.id),...B?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[B&&e.jsx(go,{}),e.jsxs(ht,{children:[e.jsx(Zs,{children:q.image_url?e.jsx("img",{src:q.image_url,alt:q.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):re(q.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:q.name})})]}),B?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ro,{onClick:A=>{A.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async A=>{A.stopPropagation();try{S&&await S()}catch(W){const L=W.message||"Failed to leave workspace. Please try again.";N(L,"error")}},title:"Leave workspace",children:e.jsx(zt,{size:12})})]}):e.jsx(ho,{className:"hover-arrow",size:14})]},q.id)}),e.jsx(mo,{as:"button",onClick:()=>{w(f.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{style:{width:"14px",height:"14px"},children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),(C||y)&&e.jsxs(e.Fragment,{children:[C&&e.jsxs(Ks,{children:[e.jsx(Yx,{}),"Leaving organization..."]}),y&&e.jsxs(Ks,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),y]})]}),e.jsx(lr,{}),_&&_.length>0&&e.jsx(e.Fragment,{children:_.filter(q=>q.organization.id!==(f==null?void 0:f.id)).map(q=>{const B=q.organization,A=(R==null?void 0:R.filter(L=>L.organization.id===B.id))||[],W=s.has(B.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Po,{as:"button",$isActive:!1,onClick:()=>{ee?ne(B.id):Z(B.id)},disabled:n,children:[e.jsxs(ht,{children:[ee&&e.jsx(er,{size:12,style:{marginRight:"4px",transform:W?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Hs,{children:B.image_url?e.jsx(qs,{src:B.image_url,alt:B.name}):re(B.name)}),e.jsx(ft,{children:e.jsx(gt,{children:B.name})})]}),e.jsx(ho,{className:"hover-arrow",size:14})]}),ee&&W&&e.jsxs(e.Fragment,{children:[A.map(L=>{const G=(j==null?void 0:j.id)===L.id;return e.jsxs(mo,{as:G?void 0:"button",$isActive:G,onClick:G?void 0:()=>Q(L.id),...G?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[G&&e.jsx(go,{}),e.jsxs(ht,{children:[e.jsx(Zs,{children:L.image_url?e.jsx("img",{src:L.image_url,alt:L.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):re(L.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:L.name})})]}),G?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ro,{onClick:se=>{se.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async se=>{se.stopPropagation();try{S&&await S()}catch(me){const Se=me.message||"Failed to leave workspace. Please try again.";N(Se,"error")}},title:"Leave workspace",children:e.jsx(zt,{size:12})})]}):e.jsx(ho,{className:"hover-arrow",size:16})]},L.id)}),e.jsx(mo,{as:"button",onClick:()=>{w(B.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{style:{width:"14px",height:"14px"},children:e.jsx(Je,{size:10})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),e.jsx(lr,{})]},B.id)})}),ee?f&&e.jsx(Ys,{onClick:()=>{w(f.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})}):ce&&e.jsx(Ys,{onClick:()=>{d.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create organization"})})]})})]})})}),document.body),F&&ce&&e.jsx(hm,{isOpen:d.isOpen,onClose:d.close,onCreated:U}),e.jsx(Um,{isOpen:l.isOpen,onClose:l.close}),e.jsx(kl,{isOpen:x.isOpen,onClose:x.close}),v&&e.jsx(yl,{isOpen:m.isOpen,onClose:()=>{m.close(),w(null)},organizationId:v})]})})};var e0=Object.defineProperty,Fo=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,$l=Object.prototype.propertyIsEnumerable,Xs=(t,r,o)=>r in t?e0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,pa=(t,r)=>{for(var o in r||(r={}))Sl.call(r,o)&&Xs(t,o,r[o]);if(Fo)for(var o of Fo(r))$l.call(r,o)&&Xs(t,o,r[o]);return t},ha=(t,r)=>{var o={};for(var n in t)Sl.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Fo)for(var n of Fo(t))r.indexOf(n)<0&&$l.call(t,n)&&(o[n]=t[n]);return o};/**
3501
+ `,Cl=({showPersonal:t=!0})=>{var ce,Y,se;const[r,o]=i.useState(!1),[n,a]=i.useState(!1),[s,p]=i.useState(new Set),g=i.useRef(null),c=i.useRef(null),h=_l({triggerRef:g,isOpen:r,minWidth:300}),d=Or(!1),l=Or(!1),m=Or(!1),x=Or(!1),[v,w]=i.useState(null),[C,$]=i.useState(!1),[y,z]=i.useState(null),{organizationMemberships:_,loading:k,refetch:b}=bt(),{activeOrganization:f,leave:I}=Qe(),{activeWorkspace:j,leave:S}=Pt(),{workspaces:R,loading:E}=yt(),{session:T,loading:P,switchOrganization:O,switchWorkspace:D}=Fe(),{deployment:M}=ve(),{toast:N}=st(),F=M==null?void 0:M.b2b_settings.organizations_enabled,J=M==null?void 0:M.b2b_settings.workspaces_enabled,ie=M==null?void 0:M.b2b_settings.allow_users_to_create_orgs,re=!((ce=T==null?void 0:T.active_signin)!=null&&ce.active_organization_membership_id),X=i.useMemo(()=>{var H,A;if(re)return{name:"Personal account",image_url:(A=(H=T==null?void 0:T.active_signin)==null?void 0:H.user)==null?void 0:A.profile_picture_url,isPersonal:!0};let q=(f==null?void 0:f.name)||"";return J&&j&&(q=`${f==null?void 0:f.name} / ${j.name}`),{name:q,image_url:f==null?void 0:f.image_url,isPersonal:!1}},[re,f,j,T,J]);i.useEffect(()=>{if(!r)return;let q=null;const H=setTimeout(()=>{const A=B=>{var W,ee;const L=B.target;(W=g.current)!=null&&W.contains(L)||(ee=c.current)!=null&&ee.contains(L)||(o(!1),z(null))};document.addEventListener("mousedown",A),q=()=>{document.removeEventListener("mousedown",A)}},50);return()=>{clearTimeout(H),q==null||q()}},[r]),i.useEffect(()=>{if(y){const q=setTimeout(()=>{z(null)},5e3);return()=>clearTimeout(q)}},[y]);const U=()=>{b()};if(!F)return null;const Z=q=>{a(!0),O(q).finally(()=>{a(!1)})},Q=q=>{a(!0),D(q).finally(()=>{a(!1)})},ae=q=>{const H=new Set(s);H.has(q)?H.delete(q):H.add(q),p(H)},oe=q=>q.split(" ").map(H=>H[0]).join("").toUpperCase().slice(0,2);return k||P?e.jsx(le,{children:e.jsx(Vs,{children:e.jsxs(Kx,{children:[e.jsxs(Gs,{children:[e.jsx(Qx,{}),e.jsx(Xx,{})]}),e.jsx(Jx,{})]})})}):e.jsx(le,{children:e.jsxs(Vs,{children:[e.jsxs(Bx,{ref:g,onClick:()=>{o(!r),r||z(null)},disabled:n,children:[e.jsxs(Gs,{children:[e.jsx(Ux,{children:X.image_url?e.jsx(Wx,{src:X.image_url,alt:X.name}):X.isPersonal?e.jsx(Mo,{size:12}):oe(X.name)}),e.jsx(Vx,{children:X.name})]}),e.jsx(dh,{size:16})]}),typeof window<"u"&&Nr.createPortal(e.jsx(le,{children:e.jsx(Gx,{ref:c,$isOpen:r,$position:h,children:k||E?e.jsxs(Zx,{children:[e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsxs(bo,{children:[e.jsx(yo,{width:"120px"}),e.jsx(Qs,{width:"80px"})]})]}),e.jsx(lr,{}),e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsx(bo,{children:e.jsx(yo,{width:"100px"})})]}),e.jsx(lr,{}),e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsxs(bo,{children:[e.jsx(yo,{width:"140px"}),e.jsx(Qs,{width:"60px"})]})]}),e.jsx(lr,{}),e.jsxs(xo,{children:[e.jsx(vo,{}),e.jsx(bo,{children:e.jsx(yo,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Po,{as:"button",$isActive:re,onClick:q=>{q.stopPropagation(),re||Z()},disabled:n||re,children:[re&&e.jsx(go,{}),e.jsxs(ht,{children:[e.jsx(Hx,{children:(se=(Y=T==null?void 0:T.active_signin)==null?void 0:Y.user)!=null&&se.profile_picture_url?e.jsx(qx,{src:T.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Mo,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Personal account"})})]}),!re&&e.jsx(ho,{className:"hover-arrow",size:14})]}),!re&&f&&e.jsx(lr,{})]}),!re&&f&&e.jsxs(Po,{$isActive:!0,onClick:()=>{J&&ae(f.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(go,{}),e.jsxs(ht,{children:[J&&e.jsx(er,{size:12,style:{marginRight:"4px",transform:s.has(f.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Hs,{children:f.image_url?e.jsx(qs,{src:f.image_url,alt:f.name}):oe(f.name)}),e.jsx(ft,{children:e.jsx(gt,{children:f.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ro,{onClick:q=>{q.stopPropagation(),l.open()},title:"Manage organization",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async q=>{q.stopPropagation(),$(!0),z(null);try{await I(),await b(),setTimeout(()=>{$(!1)},500)}catch(H){z(H instanceof Error?H.message:"Failed to leave organization"),$(!1)}},disabled:C,title:"Leave organization",children:e.jsx(zt,{size:12})})]})]}),f&&J&&s.has(f.id)&&e.jsxs(e.Fragment,{children:[R==null?void 0:R.filter(q=>q.organization.id===f.id).map(q=>{const H=(j==null?void 0:j.id)===q.id;return e.jsxs(mo,{as:H?void 0:"button",$isActive:H,onClick:H?void 0:()=>Q(q.id),...H?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[H&&e.jsx(go,{}),e.jsxs(ht,{children:[e.jsx(Zs,{children:q.image_url?e.jsx("img",{src:q.image_url,alt:q.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):oe(q.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:q.name})})]}),H?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ro,{onClick:A=>{A.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async A=>{A.stopPropagation();try{S&&await S()}catch(B){const L=B.message||"Failed to leave workspace. Please try again.";N(L,"error")}},title:"Leave workspace",children:e.jsx(zt,{size:12})})]}):e.jsx(ho,{className:"hover-arrow",size:14})]},q.id)}),e.jsx(mo,{as:"button",onClick:()=>{w(f.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{style:{width:"14px",height:"14px"},children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),(C||y)&&e.jsxs(e.Fragment,{children:[C&&e.jsxs(Ks,{children:[e.jsx(Yx,{}),"Leaving organization..."]}),y&&e.jsxs(Ks,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),y]})]}),e.jsx(lr,{}),_&&_.length>0&&e.jsx(e.Fragment,{children:_.filter(q=>q.organization.id!==(f==null?void 0:f.id)).map(q=>{const H=q.organization,A=(R==null?void 0:R.filter(L=>L.organization.id===H.id))||[],B=s.has(H.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Po,{as:"button",$isActive:!1,onClick:()=>{J?ae(H.id):Z(H.id)},disabled:n,children:[e.jsxs(ht,{children:[J&&e.jsx(er,{size:12,style:{marginRight:"4px",transform:B?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(Hs,{children:H.image_url?e.jsx(qs,{src:H.image_url,alt:H.name}):oe(H.name)}),e.jsx(ft,{children:e.jsx(gt,{children:H.name})})]}),e.jsx(ho,{className:"hover-arrow",size:14})]}),J&&B&&e.jsxs(e.Fragment,{children:[A.map(L=>{const W=(j==null?void 0:j.id)===L.id;return e.jsxs(mo,{as:W?void 0:"button",$isActive:W,onClick:W?void 0:()=>Q(L.id),...W?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[W&&e.jsx(go,{}),e.jsxs(ht,{children:[e.jsx(Zs,{children:L.image_url?e.jsx("img",{src:L.image_url,alt:L.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):oe(L.name).charAt(0)}),e.jsx(ft,{children:e.jsx(gt,{children:L.name})})]}),W?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ro,{onClick:ee=>{ee.stopPropagation(),x.open()},title:"Manage workspace",children:e.jsx(Kt,{size:12})}),e.jsx(Nn,{onClick:async ee=>{ee.stopPropagation();try{S&&await S()}catch(pe){const Se=pe.message||"Failed to leave workspace. Please try again.";N(Se,"error")}},title:"Leave workspace",children:e.jsx(zt,{size:12})})]}):e.jsx(ho,{className:"hover-arrow",size:16})]},L.id)}),e.jsx(mo,{as:"button",onClick:()=>{w(H.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{style:{width:"14px",height:"14px"},children:e.jsx(Je,{size:10})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})})]}),e.jsx(lr,{})]},H.id)})}),J?f&&e.jsx(Ys,{onClick:()=>{w(f.id),m.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create workspace"})})]})}):ie&&e.jsx(Ys,{onClick:()=>{d.open()},disabled:n,children:e.jsxs(ht,{children:[e.jsx(fo,{children:e.jsx(Je,{size:12})}),e.jsx(ft,{children:e.jsx(gt,{children:"Create organization"})})]})})]})})}),document.body),F&&ie&&e.jsx(hm,{isOpen:d.isOpen,onClose:d.close,onCreated:U}),e.jsx(Um,{isOpen:l.isOpen,onClose:l.close}),e.jsx(kl,{isOpen:x.isOpen,onClose:x.close}),v&&e.jsx(yl,{isOpen:m.isOpen,onClose:()=>{m.close(),w(null)},organizationId:v})]})})};var e0=Object.defineProperty,Fo=Object.getOwnPropertySymbols,Sl=Object.prototype.hasOwnProperty,$l=Object.prototype.propertyIsEnumerable,Xs=(t,r,o)=>r in t?e0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,pa=(t,r)=>{for(var o in r||(r={}))Sl.call(r,o)&&Xs(t,o,r[o]);if(Fo)for(var o of Fo(r))$l.call(r,o)&&Xs(t,o,r[o]);return t},ha=(t,r)=>{var o={};for(var n in t)Sl.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Fo)for(var n of Fo(t))r.indexOf(n)<0&&$l.call(t,n)&&(o[n]=t[n]);return o};/**
3502
3502
  * @license QR Code generator library (TypeScript)
3503
3503
  * Copyright (c) Project Nayuki.
3504
3504
  * SPDX-License-Identifier: MIT
@@ -3506,7 +3506,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
3506
3506
  * @license qrcode.react
3507
3507
  * Copyright (c) Paul O'Shannessy
3508
3508
  * SPDX-License-Identifier: ISC
3509
- */var t0={L:pr.QrCode.Ecc.LOW,M:pr.QrCode.Ecc.MEDIUM,Q:pr.QrCode.Ecc.QUARTILE,H:pr.QrCode.Ecc.HIGH},zl=128,El="L",Pl="#FFFFFF",Rl="#000000",Il=!1,Tl=1,r0=4,o0=0,n0=.1;function Ol(t,r=0){const o=[];return t.forEach(function(n,a){let s=null;n.forEach(function(p,g){if(!p&&s!==null){o.push(`M${s+r} ${a+r}h${g-s}v1H${s+r}z`),s=null;return}if(g===n.length-1){if(!p)return;s===null?o.push(`M${g+r},${a+r} h1v1H${g+r}z`):o.push(`M${s+r},${a+r} h${g+1-s}v1H${s+r}z`);return}p&&s===null&&(s=g)})}),o.join("")}function Ml(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((a,s)=>s<r.x||s>=r.x+r.w?a:!1))}function a0(t,r,o,n){if(n==null)return null;const a=t.length+o*2,s=Math.floor(r*n0),p=a/r,g=(n.width||s)*p,c=(n.height||s)*p,h=n.x==null?t.length/2-g/2:n.x*p,d=n.y==null?t.length/2-c/2:n.y*p,l=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let v=Math.floor(h),w=Math.floor(d),C=Math.ceil(g+h-v),$=Math.ceil(c+d-w);m={x:v,y:w,w:C,h:$}}const x=n.crossOrigin;return{x:h,y:d,h:c,w:g,excavation:m,opacity:l,crossOrigin:x}}function s0(t,r){return r!=null?Math.max(Math.floor(r),0):t?r0:o0}function Ll({value:t,level:r,minVersion:o,includeMargin:n,marginSize:a,imageSettings:s,size:p,boostLevel:g}){let c=i.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((w,C)=>(w.push(...pr.QrSegment.makeSegments(C)),w),[]);return pr.QrCode.encodeSegments(v,t0[r],o,void 0,void 0,g)},[t,r,o,g]);const{cells:h,margin:d,numCells:l,calculatedImageSettings:m}=i.useMemo(()=>{let x=c.getModules();const v=s0(n,a),w=x.length+v*2,C=a0(x,p,v,s);return{cells:x,margin:v,numCells:w,calculatedImageSettings:C}},[c,p,s,n,a]);return{qrcode:c,margin:d,cells:h,numCells:l,calculatedImageSettings:m}}var i0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),c0=i.forwardRef(function(r,o){const n=r,{value:a,size:s=zl,level:p=El,bgColor:g=Pl,fgColor:c=Rl,includeMargin:h=Il,minVersion:d=Tl,boostLevel:l,marginSize:m,imageSettings:x}=n,w=ha(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:C}=w,$=ha(w,["style"]),y=x==null?void 0:x.src,z=i.useRef(null),_=i.useRef(null),k=i.useCallback(P=>{z.current=P,typeof o=="function"?o(P):o&&(o.current=P)},[o]),[b,f]=i.useState(!1),{margin:I,cells:j,numCells:S,calculatedImageSettings:R}=Ll({value:a,level:p,minVersion:d,boostLevel:l,includeMargin:h,marginSize:m,imageSettings:x,size:s});i.useEffect(()=>{if(z.current!=null){const P=z.current,O=P.getContext("2d");if(!O)return;let D=j;const M=_.current,N=R!=null&&M!==null&&M.complete&&M.naturalHeight!==0&&M.naturalWidth!==0;N&&R.excavation!=null&&(D=Ml(j,R.excavation));const F=window.devicePixelRatio||1;P.height=P.width=s*F;const ee=s/S*F;O.scale(ee,ee),O.fillStyle=g,O.fillRect(0,0,S,S),O.fillStyle=c,i0?O.fill(new Path2D(Ol(D,I))):j.forEach(function(ce,J){ce.forEach(function(X,U){X&&O.fillRect(U+I,J+I,1,1)})}),R&&(O.globalAlpha=R.opacity),N&&O.drawImage(M,R.x+I,R.y+I,R.w,R.h)}}),i.useEffect(()=>{f(!1)},[y]);const E=pa({height:s,width:s},C);let T=null;return y!=null&&(T=i.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{f(!0)},ref:_,crossOrigin:R==null?void 0:R.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",pa({style:E,height:s,width:s,ref:k,role:"img"},$)),T)});c0.displayName="QRCodeCanvas";var Sa=i.forwardRef(function(r,o){const n=r,{value:a,size:s=zl,level:p=El,bgColor:g=Pl,fgColor:c=Rl,includeMargin:h=Il,minVersion:d=Tl,boostLevel:l,title:m,marginSize:x,imageSettings:v}=n,w=ha(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:C,cells:$,numCells:y,calculatedImageSettings:z}=Ll({value:a,level:p,minVersion:d,boostLevel:l,includeMargin:h,marginSize:x,imageSettings:v,size:s});let _=$,k=null;v!=null&&z!=null&&(z.excavation!=null&&(_=Ml($,z.excavation)),k=i.createElement("image",{href:v.src,height:z.h,width:z.w,x:z.x+C,y:z.y+C,preserveAspectRatio:"none",opacity:z.opacity,crossOrigin:z.crossOrigin}));const b=Ol(_,C);return i.createElement("svg",pa({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:o,role:"img"},w),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:g,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:b,shapeRendering:"crispEdges"}),k)});Sa.displayName="QRCodeSVG";const l0=u.div`
3509
+ */var t0={L:pr.QrCode.Ecc.LOW,M:pr.QrCode.Ecc.MEDIUM,Q:pr.QrCode.Ecc.QUARTILE,H:pr.QrCode.Ecc.HIGH},zl=128,El="L",Pl="#FFFFFF",Rl="#000000",Il=!1,Tl=1,r0=4,o0=0,n0=.1;function Ol(t,r=0){const o=[];return t.forEach(function(n,a){let s=null;n.forEach(function(p,g){if(!p&&s!==null){o.push(`M${s+r} ${a+r}h${g-s}v1H${s+r}z`),s=null;return}if(g===n.length-1){if(!p)return;s===null?o.push(`M${g+r},${a+r} h1v1H${g+r}z`):o.push(`M${s+r},${a+r} h${g+1-s}v1H${s+r}z`);return}p&&s===null&&(s=g)})}),o.join("")}function Ml(t,r){return t.slice().map((o,n)=>n<r.y||n>=r.y+r.h?o:o.map((a,s)=>s<r.x||s>=r.x+r.w?a:!1))}function a0(t,r,o,n){if(n==null)return null;const a=t.length+o*2,s=Math.floor(r*n0),p=a/r,g=(n.width||s)*p,c=(n.height||s)*p,h=n.x==null?t.length/2-g/2:n.x*p,d=n.y==null?t.length/2-c/2:n.y*p,l=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let v=Math.floor(h),w=Math.floor(d),C=Math.ceil(g+h-v),$=Math.ceil(c+d-w);m={x:v,y:w,w:C,h:$}}const x=n.crossOrigin;return{x:h,y:d,h:c,w:g,excavation:m,opacity:l,crossOrigin:x}}function s0(t,r){return r!=null?Math.max(Math.floor(r),0):t?r0:o0}function Ll({value:t,level:r,minVersion:o,includeMargin:n,marginSize:a,imageSettings:s,size:p,boostLevel:g}){let c=i.useMemo(()=>{const v=(Array.isArray(t)?t:[t]).reduce((w,C)=>(w.push(...pr.QrSegment.makeSegments(C)),w),[]);return pr.QrCode.encodeSegments(v,t0[r],o,void 0,void 0,g)},[t,r,o,g]);const{cells:h,margin:d,numCells:l,calculatedImageSettings:m}=i.useMemo(()=>{let x=c.getModules();const v=s0(n,a),w=x.length+v*2,C=a0(x,p,v,s);return{cells:x,margin:v,numCells:w,calculatedImageSettings:C}},[c,p,s,n,a]);return{qrcode:c,margin:d,cells:h,numCells:l,calculatedImageSettings:m}}var i0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),c0=i.forwardRef(function(r,o){const n=r,{value:a,size:s=zl,level:p=El,bgColor:g=Pl,fgColor:c=Rl,includeMargin:h=Il,minVersion:d=Tl,boostLevel:l,marginSize:m,imageSettings:x}=n,w=ha(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:C}=w,$=ha(w,["style"]),y=x==null?void 0:x.src,z=i.useRef(null),_=i.useRef(null),k=i.useCallback(P=>{z.current=P,typeof o=="function"?o(P):o&&(o.current=P)},[o]),[b,f]=i.useState(!1),{margin:I,cells:j,numCells:S,calculatedImageSettings:R}=Ll({value:a,level:p,minVersion:d,boostLevel:l,includeMargin:h,marginSize:m,imageSettings:x,size:s});i.useEffect(()=>{if(z.current!=null){const P=z.current,O=P.getContext("2d");if(!O)return;let D=j;const M=_.current,N=R!=null&&M!==null&&M.complete&&M.naturalHeight!==0&&M.naturalWidth!==0;N&&R.excavation!=null&&(D=Ml(j,R.excavation));const F=window.devicePixelRatio||1;P.height=P.width=s*F;const J=s/S*F;O.scale(J,J),O.fillStyle=g,O.fillRect(0,0,S,S),O.fillStyle=c,i0?O.fill(new Path2D(Ol(D,I))):j.forEach(function(ie,re){ie.forEach(function(X,U){X&&O.fillRect(U+I,re+I,1,1)})}),R&&(O.globalAlpha=R.opacity),N&&O.drawImage(M,R.x+I,R.y+I,R.w,R.h)}}),i.useEffect(()=>{f(!1)},[y]);const E=pa({height:s,width:s},C);let T=null;return y!=null&&(T=i.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{f(!0)},ref:_,crossOrigin:R==null?void 0:R.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",pa({style:E,height:s,width:s,ref:k,role:"img"},$)),T)});c0.displayName="QRCodeCanvas";var Sa=i.forwardRef(function(r,o){const n=r,{value:a,size:s=zl,level:p=El,bgColor:g=Pl,fgColor:c=Rl,includeMargin:h=Il,minVersion:d=Tl,boostLevel:l,title:m,marginSize:x,imageSettings:v}=n,w=ha(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:C,cells:$,numCells:y,calculatedImageSettings:z}=Ll({value:a,level:p,minVersion:d,boostLevel:l,includeMargin:h,marginSize:x,imageSettings:v,size:s});let _=$,k=null;v!=null&&z!=null&&(z.excavation!=null&&(_=Ml($,z.excavation)),k=i.createElement("image",{href:v.src,height:z.h,width:z.w,x:z.x+C,y:z.y+C,preserveAspectRatio:"none",opacity:z.opacity,crossOrigin:z.crossOrigin}));const b=Ol(_,C);return i.createElement("svg",pa({height:s,width:s,viewBox:`0 0 ${y} ${y}`,ref:o,role:"img"},w),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:g,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:b,shapeRendering:"crispEdges"}),k)});Sa.displayName="QRCodeSVG";const l0=u.div`
3510
3510
  position: fixed;
3511
3511
  background: var(--color-background);
3512
3512
  border-radius: var(--radius-md);
@@ -3545,7 +3545,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
3545
3545
  justify-content: center;
3546
3546
  color: var(--color-muted);
3547
3547
  flex-shrink: 0;
3548
- `,ti=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:a,triggerRef:s})=>{const p=i.useRef(null),[g,c]=i.useState(!1),[h,d]=i.useState({top:0,left:0}),{toast:l}=It();i.useEffect(()=>{c(!0);const b=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const j=s.current;if(j){const S=j.getBoundingClientRect(),R=380,E=300,T=8;let P=0,O=0;const D=window.innerHeight-S.bottom,M=S.top;D>=E+T?(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):M>=E+T?(P=S.top-E-T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left)),d({top:P,left:O})}},10),f=j=>{p.current&&!p.current.contains(j.target)&&t()},I=j=>{j.key==="Escape"&&t()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",I),()=>{clearTimeout(b),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",I)}},[t,s]);const[m,x]=i.useState(a?"otp":"email"),[v,w]=i.useState(a||""),[C,$]=i.useState(""),[y,z]=i.useState(!1),_=async()=>{if(!(!v||y)){z(!0);try{await r(v),x("otp")}catch(b){const f=b.message||"Failed to add email address. Please try again.";l(f,"error")}finally{z(!1)}}},k=async()=>{z(!0);try{await o(C),t()}catch(b){const f=b.message||"Failed to verify email. Please check the code and try again.";l(f,"error")}finally{z(!1)}};return g?e.jsx(l0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx(ei,{children:"Add email address"}),e.jsx(pe,{children:e.jsxs(d0,{children:[e.jsx(u0,{children:e.jsx(Wr,{size:16})}),e.jsx(de,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:b=>w(b.target.value),style:{flex:1}})]})}),e.jsxs(Js,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:_,disabled:!v||y,style:{width:"auto",padding:"0 var(--space-md)"},children:y?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ei,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",v]}),e.jsx(Rt,{onComplete:async b=>$(b),onResend:n,isSubmitting:y}),e.jsxs(Js,{children:[e.jsx(K,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(K,{onClick:k,disabled:C.length<6||y,style:{width:"auto",padding:"0 var(--space-md)"},children:y?"Verifying...":"Verify"})]})]})}):null},p0=u.div`
3548
+ `,ti=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:a,triggerRef:s})=>{const p=i.useRef(null),[g,c]=i.useState(!1),[h,d]=i.useState({top:0,left:0}),{toast:l}=It();i.useEffect(()=>{c(!0);const b=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const j=s.current;if(j){const S=j.getBoundingClientRect(),R=380,E=300,T=8;let P=0,O=0;const D=window.innerHeight-S.bottom,M=S.top;D>=E+T?(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):M>=E+T?(P=S.top-E-T,O=S.right-R,O<T&&(O=S.left,O+R>window.innerWidth-T&&(O=(window.innerWidth-R)/2))):(P=S.bottom+T,O=S.right-R,O<T&&(O=S.left)),d({top:P,left:O})}},10),f=j=>{p.current&&!p.current.contains(j.target)&&t()},I=j=>{j.key==="Escape"&&t()};return document.addEventListener("mousedown",f),document.addEventListener("keydown",I),()=>{clearTimeout(b),document.removeEventListener("mousedown",f),document.removeEventListener("keydown",I)}},[t,s]);const[m,x]=i.useState(a?"otp":"email"),[v,w]=i.useState(a||""),[C,$]=i.useState(""),[y,z]=i.useState(!1),_=async()=>{if(!(!v||y)){z(!0);try{await r(v),x("otp")}catch(b){const f=b.message||"Failed to add email address. Please try again.";l(f,"error")}finally{z(!1)}}},k=async()=>{z(!0);try{await o(C),t()}catch(b){const f=b.message||"Failed to verify email. Please check the code and try again.";l(f,"error")}finally{z(!1)}};return g?e.jsx(l0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx(ei,{children:"Add email address"}),e.jsx(he,{children:e.jsxs(d0,{children:[e.jsx(u0,{children:e.jsx(Wr,{size:16})}),e.jsx(de,{id:"email-input",type:"email",placeholder:"Email address",value:v,onChange:b=>w(b.target.value),style:{flex:1}})]})}),e.jsxs(Js,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:_,disabled:!v||y,style:{width:"auto",padding:"0 var(--space-md)"},children:y?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(ei,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",v]}),e.jsx(Rt,{onComplete:async b=>$(b),onResend:n,isSubmitting:y}),e.jsxs(Js,{children:[e.jsx(K,{$outline:!0,onClick:()=>x("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(K,{onClick:k,disabled:C.length<6||y,style:{width:"auto",padding:"0 var(--space-md)"},children:y?"Verifying...":"Verify"})]})]})}):null},p0=u.div`
3549
3549
  position: fixed;
3550
3550
  background: var(--color-background);
3551
3551
  border-radius: var(--radius-md);
@@ -3569,7 +3569,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
3569
3569
  font-weight: 400;
3570
3570
  color: var(--color-foreground);
3571
3571
  margin-bottom: 12px;
3572
- `,ni=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:a,triggerRef:s})=>{var I;const p=i.useRef(null),[g,c]=i.useState(!1),[h,d]=i.useState({top:0,left:0}),{toast:l}=It();i.useEffect(()=>{c(!0);const j=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const E=s.current;if(E){const T=E.getBoundingClientRect(),P=380,O=300,D=8;let M=0,N=0;const F=window.innerHeight-T.bottom,ee=T.top;F>=O+D?(M=T.bottom+D,N=T.right-P,N<D&&(N=T.left,N+P>window.innerWidth-D&&(N=(window.innerWidth-P)/2))):ee>=O+D?(M=T.top-O-D,N=T.right-P,N<D&&(N=T.left,N+P>window.innerWidth-D&&(N=(window.innerWidth-P)/2))):(M=T.bottom+D,N=T.right-P,N<D&&(N=T.left)),d({top:M,left:N})}},10),S=E=>{p.current&&!p.current.contains(E.target)&&t()},R=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",R),()=>{clearTimeout(j),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",R)}},[t,s]);const[m,x]=i.useState(n?"otp":"phone"),[v,w]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[C,$]=i.useState((I=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:I.pop()),[y,z]=i.useState(""),[_,k]=i.useState(!1),b=async()=>{if(!(!v||_)){k(!0);try{await r(v,C||""),x("otp")}catch(j){const S=j.message||"Failed to add phone number. Please try again.";l(S,"error")}finally{k(!1)}}},f=async()=>{k(!0);try{await o(y),t()}catch(j){const S=j.message||"Failed to verify phone. Please check the code and try again.";l(S,"error")}finally{k(!1)}};return g?e.jsx(p0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(oi,{children:"Add phone number"}),e.jsx(pe,{children:e.jsx(Br,{value:v,onChange:j=>w(j.target.value),error:"",countryCode:C,setCountryCode:$})}),e.jsxs(ri,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:b,disabled:!v||_,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{children:"Verify phone number"}),e.jsx(pe,{children:e.jsx(Rt,{onComplete:j=>z(j),onResend:async()=>a()})}),e.jsxs(ri,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:f,disabled:y.length!==6||_,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},h0=u.div`
3572
+ `,ni=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:a,triggerRef:s})=>{var I;const p=i.useRef(null),[g,c]=i.useState(!1),[h,d]=i.useState({top:0,left:0}),{toast:l}=It();i.useEffect(()=>{c(!0);const j=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const E=s.current;if(E){const T=E.getBoundingClientRect(),P=380,O=300,D=8;let M=0,N=0;const F=window.innerHeight-T.bottom,J=T.top;F>=O+D?(M=T.bottom+D,N=T.right-P,N<D&&(N=T.left,N+P>window.innerWidth-D&&(N=(window.innerWidth-P)/2))):J>=O+D?(M=T.top-O-D,N=T.right-P,N<D&&(N=T.left,N+P>window.innerWidth-D&&(N=(window.innerWidth-P)/2))):(M=T.bottom+D,N=T.right-P,N<D&&(N=T.left)),d({top:M,left:N})}},10),S=E=>{p.current&&!p.current.contains(E.target)&&t()},R=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",R),()=>{clearTimeout(j),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",R)}},[t,s]);const[m,x]=i.useState(n?"otp":"phone"),[v,w]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[C,$]=i.useState((I=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:I.pop()),[y,z]=i.useState(""),[_,k]=i.useState(!1),b=async()=>{if(!(!v||_)){k(!0);try{await r(v,C||""),x("otp")}catch(j){const S=j.message||"Failed to add phone number. Please try again.";l(S,"error")}finally{k(!1)}}},f=async()=>{k(!0);try{await o(y),t()}catch(j){const S=j.message||"Failed to verify phone. Please check the code and try again.";l(S,"error")}finally{k(!1)}};return g?e.jsx(p0,{ref:p,style:{top:`${h.top}px`,left:`${h.left}px`,visibility:h.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(oi,{children:"Add phone number"}),e.jsx(he,{children:e.jsx(Br,{value:v,onChange:j=>w(j.target.value),error:"",countryCode:C,setCountryCode:$})}),e.jsxs(ri,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:b,disabled:!v||_,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(oi,{children:"Verify phone number"}),e.jsx(he,{children:e.jsx(Rt,{onComplete:j=>z(j),onResend:async()=>a()})}),e.jsxs(ri,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:f,disabled:y.length!==6||_,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},h0=u.div`
3573
3573
  position: fixed;
3574
3574
  background: var(--color-background);
3575
3575
  border-radius: var(--radius-md);
@@ -3682,7 +3682,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
3682
3682
  color: var(--color-error);
3683
3683
  font-size: 12px;
3684
3684
  margin-top: 4px;
3685
- `,ci=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const a=i.useRef(null),[s,p]=i.useState(!1),[g,c]=i.useState({top:0,left:0}),[h,d]=i.useState(""),[l,m]=i.useState(""),[x,v]=i.useState(""),[w,C]=i.useState(!1),[$,y]=i.useState(!1),[z,_]=i.useState(!1),[k,b]=i.useState(!1),[f,I]=i.useState({});i.useEffect(()=>{p(!0);const S=setTimeout(()=>{if(!a.current||!(o!=null&&o.current))return;const T=o.current;if(T){const P=T.getBoundingClientRect(),O=380,D=350,M=8;let N=0,F=0;const ee=window.innerHeight-P.bottom,ce=P.top;ee>=D+M?(N=P.bottom+M,F=P.right-O,F<M&&(F=P.left,F+O>window.innerWidth-M&&(F=(window.innerWidth-O)/2))):ce>=D+M?(N=P.top-D-M,F=P.right-O,F<M&&(F=P.left,F+O>window.innerWidth-M&&(F=(window.innerWidth-O)/2))):(N=P.bottom+M,F=P.right-O,F<M&&(F=P.left)),c({top:N,left:F})}},10),R=T=>{a.current&&!a.current.contains(T.target)&&t()},E=T=>{T.key==="Escape"&&t()};return document.addEventListener("mousedown",R),document.addEventListener("keydown",E),()=>{clearTimeout(S),document.removeEventListener("mousedown",R),document.removeEventListener("keydown",E)}},[t,o]);const j=async()=>{if(k)return;const S={};if(!n&&!h&&(S.currentPassword="Current password is required"),l?l.length<8&&(S.newPassword="Password must be at least 8 characters"):S.newPassword="New password is required",l!==x&&(S.confirmPassword="Passwords do not match"),Object.keys(S).length>0){I(S);return}b(!0);try{await r(n?"":h,l),t()}catch(R){I({form:R.message||"Failed to update password"})}finally{b(!1)}};return s?e.jsxs(g0,{ref:a,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),children:[e.jsx(x0,{children:n?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&e.jsxs(Bn,{children:[e.jsx(ue,{children:"Current Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:w?"text":"password",placeholder:"Enter your current password",value:h,onChange:S=>d(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>C(!w),"aria-label":w?"Hide current password":"Show current password",children:w?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.currentPassword&&e.jsx(wo,{children:f.currentPassword})]}),e.jsxs(Bn,{children:[e.jsx(ue,{children:n?"Password":"New Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:$?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:l,onChange:S=>m(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>y(!$),"aria-label":$?"Hide new password":"Show new password",children:$?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.newPassword&&e.jsx(wo,{children:f.newPassword})]}),e.jsxs(Bn,{children:[e.jsx(ue,{children:"Confirm New Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:z?"text":"password",placeholder:"Confirm your new password",value:x,onChange:S=>v(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>_(!z),"aria-label":z?"Hide confirm password":"Show confirm password",children:z?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.confirmPassword&&e.jsx(wo,{children:f.confirmPassword})]}),f.form&&e.jsx(wo,{children:f.form}),e.jsxs(m0,{children:[e.jsx(ii,{onClick:t,children:"Cancel"}),e.jsx(ii,{$primary:!0,onClick:j,disabled:k,children:k?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},v0=u.div`
3685
+ `,ci=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const a=i.useRef(null),[s,p]=i.useState(!1),[g,c]=i.useState({top:0,left:0}),[h,d]=i.useState(""),[l,m]=i.useState(""),[x,v]=i.useState(""),[w,C]=i.useState(!1),[$,y]=i.useState(!1),[z,_]=i.useState(!1),[k,b]=i.useState(!1),[f,I]=i.useState({});i.useEffect(()=>{p(!0);const S=setTimeout(()=>{if(!a.current||!(o!=null&&o.current))return;const T=o.current;if(T){const P=T.getBoundingClientRect(),O=380,D=350,M=8;let N=0,F=0;const J=window.innerHeight-P.bottom,ie=P.top;J>=D+M?(N=P.bottom+M,F=P.right-O,F<M&&(F=P.left,F+O>window.innerWidth-M&&(F=(window.innerWidth-O)/2))):ie>=D+M?(N=P.top-D-M,F=P.right-O,F<M&&(F=P.left,F+O>window.innerWidth-M&&(F=(window.innerWidth-O)/2))):(N=P.bottom+M,F=P.right-O,F<M&&(F=P.left)),c({top:N,left:F})}},10),R=T=>{a.current&&!a.current.contains(T.target)&&t()},E=T=>{T.key==="Escape"&&t()};return document.addEventListener("mousedown",R),document.addEventListener("keydown",E),()=>{clearTimeout(S),document.removeEventListener("mousedown",R),document.removeEventListener("keydown",E)}},[t,o]);const j=async()=>{if(k)return;const S={};if(!n&&!h&&(S.currentPassword="Current password is required"),l?l.length<8&&(S.newPassword="Password must be at least 8 characters"):S.newPassword="New password is required",l!==x&&(S.confirmPassword="Passwords do not match"),Object.keys(S).length>0){I(S);return}b(!0);try{await r(n?"":h,l),t()}catch(R){I({form:R.message||"Failed to update password"})}finally{b(!1)}};return s?e.jsxs(g0,{ref:a,style:{top:`${g.top}px`,left:`${g.left}px`,visibility:g.top>0?"visible":"hidden"},onClick:S=>S.stopPropagation(),children:[e.jsx(x0,{children:n?"Set Password":"Change Password"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:n?"Set a password for your account to enable password authentication.":"Update your account password to keep it secure."}),!n&&e.jsxs(Bn,{children:[e.jsx(ue,{children:"Current Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:w?"text":"password",placeholder:"Enter your current password",value:h,onChange:S=>d(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>C(!w),"aria-label":w?"Hide current password":"Show current password",children:w?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.currentPassword&&e.jsx(wo,{children:f.currentPassword})]}),e.jsxs(Bn,{children:[e.jsx(ue,{children:n?"Password":"New Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:$?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:l,onChange:S=>m(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>y(!$),"aria-label":$?"Hide new password":"Show new password",children:$?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.newPassword&&e.jsx(wo,{children:f.newPassword})]}),e.jsxs(Bn,{children:[e.jsx(ue,{children:"Confirm New Password"}),e.jsxs(Un,{children:[e.jsx(de,{type:z?"text":"password",placeholder:"Confirm your new password",value:x,onChange:S=>v(S.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>_(!z),"aria-label":z?"Hide confirm password":"Show confirm password",children:z?e.jsx(kn,{size:16}):e.jsx(_n,{size:16})})]}),f.confirmPassword&&e.jsx(wo,{children:f.confirmPassword})]}),f.form&&e.jsx(wo,{children:f.form}),e.jsxs(m0,{children:[e.jsx(ii,{onClick:t,children:"Cancel"}),e.jsx(ii,{$primary:!0,onClick:j,disabled:k,children:k?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},v0=u.div`
3686
3686
  position: fixed;
3687
3687
  background: var(--color-background);
3688
3688
  border-radius: var(--radius-md);
@@ -3720,7 +3720,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
3720
3720
  color: var(--color-warning-text, var(--color-foreground));
3721
3721
  margin: 0;
3722
3722
  line-height: 1.5;
3723
- `,k0=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(!1),[p,g]=i.useState({top:0,left:0}),[c,h]=i.useState(""),[d,l]=i.useState(!1),{toast:m}=It();i.useEffect(()=>{s(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const $=o.current;if($){const y=$.getBoundingClientRect(),z=400,_=300,k=8;let b=0,f=0;const I=window.innerHeight-y.bottom,j=y.top;I>=_+k?(b=y.bottom+k,f=y.right-z,f<k&&(f=y.left,f+z>window.innerWidth-k&&(f=(window.innerWidth-z)/2))):j>=_+k?(b=y.top-_-k,f=y.right-z,f<k&&(f=y.left,f+z>window.innerWidth-k&&(f=(window.innerWidth-z)/2))):(b=y.bottom+k,f=y.right-z,f<k&&(f=y.left)),g({top:b,left:f})}},10),w=$=>{n.current&&!n.current.contains($.target)&&t()},C=$=>{$.key==="Escape"&&t()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",C),()=>{clearTimeout(v),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",C)}},[t,o]);const x=async()=>{if(!(!c||d)){l(!0);try{await r(c),t()}catch(v){const w=v.message||"Failed to remove password. Please try again.";m(w,"error")}finally{l(!1)}}};return a?e.jsxs(v0,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(y0,{children:[e.jsx(ut,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(w0,{children:e.jsx(j0,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(de,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:v=>h(v.target.value),autoFocus:!0})]}),e.jsxs(b0,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:x,disabled:!c||d,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:d?"Removing...":"Remove Password"})]})]}):null},_0=u.div`
3723
+ `,k0=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(!1),[p,g]=i.useState({top:0,left:0}),[c,h]=i.useState(""),[d,l]=i.useState(!1),{toast:m}=It();i.useEffect(()=>{s(!0);const v=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const $=o.current;if($){const y=$.getBoundingClientRect(),z=400,_=300,k=8;let b=0,f=0;const I=window.innerHeight-y.bottom,j=y.top;I>=_+k?(b=y.bottom+k,f=y.right-z,f<k&&(f=y.left,f+z>window.innerWidth-k&&(f=(window.innerWidth-z)/2))):j>=_+k?(b=y.top-_-k,f=y.right-z,f<k&&(f=y.left,f+z>window.innerWidth-k&&(f=(window.innerWidth-z)/2))):(b=y.bottom+k,f=y.right-z,f<k&&(f=y.left)),g({top:b,left:f})}},10),w=$=>{n.current&&!n.current.contains($.target)&&t()},C=$=>{$.key==="Escape"&&t()};return document.addEventListener("mousedown",w),document.addEventListener("keydown",C),()=>{clearTimeout(v),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",C)}},[t,o]);const x=async()=>{if(!(!c||d)){l(!0);try{await r(c),t()}catch(v){const w=v.message||"Failed to remove password. Please try again.";m(w,"error")}finally{l(!1)}}};return a?e.jsxs(v0,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:v=>v.stopPropagation(),children:[e.jsxs(y0,{children:[e.jsx(ut,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(w0,{children:e.jsx(j0,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(de,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:v=>h(v.target.value),autoFocus:!0})]}),e.jsxs(b0,{children:[e.jsx(K,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(K,{onClick:x,disabled:!c||d,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:d?"Removing...":"Remove Password"})]})]}):null},_0=u.div`
3724
3724
  position: fixed;
3725
3725
  background: var(--color-background);
3726
3726
  border-radius: var(--radius-md);
@@ -3928,9 +3928,9 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
3928
3928
  flex-shrink: 0;
3929
3929
  display: block;
3930
3930
  }
3931
- `,q0=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=rr(),{deployment:n}=ve(),a={google_oauth:{icon:e.jsx(Dc,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Ac,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(Lc,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(Bc,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(Fc,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(Uc,{}),label:"Discord"},x_oauth:{icon:e.jsx(Nc,{}),label:"X"}},s=(n==null?void 0:n.social_connections.filter(p=>p.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((p,g)=>{var d;const c=((d=t==null?void 0:t.social_connections)==null?void 0:d.filter(l=>l.provider===p.provider))||[],h=a[p.provider];return h?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(Al,{children:h.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:h.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(l=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:l.email_address}),e.jsx(nn,{onClick:async()=>{await r(l.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(Ke,{size:14})})]},l.id)),c.length>0?e.jsx(K,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(K,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),g<s.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},Dl=()=>{var x,v,w,C,$,y;const{loading:t}=rr(),{deployment:r}=ve(),[o,n]=i.useState("profile"),[a,s]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((z,_="info")=>{s(z),g(_),setTimeout(()=>s(null),3e3)},[s]);if(t)return e.jsx(le,{children:e.jsx(di,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})})});const h=r==null?void 0:r.auth_settings,d=(x=h==null?void 0:h.email_address)==null?void 0:x.enabled,l=(v=h==null?void 0:h.phone_number)==null?void 0:v.enabled,m=((w=h==null?void 0:h.password)==null?void 0:w.enabled)||((C=h==null?void 0:h.auth_factors_enabled)==null?void 0:C.authenticator)||(($=h==null?void 0:h.auth_factors_enabled)==null?void 0:$.phone_otp)||((y=h==null?void 0:h.auth_factors_enabled)==null?void 0:y.backup_code);return e.jsx(le,{children:e.jsx(D0,{children:e.jsx(kr.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(di,{children:[e.jsx(N0,{children:e.jsxs(F0,{children:[e.jsx(dr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(ur,{children:[e.jsx(Mo,{size:16}),"Profile"]})}),d&&e.jsx(dr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(ur,{children:[e.jsx(Wr,{size:16}),"Email"]})}),l&&e.jsx(dr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(ur,{children:[e.jsx(Rh,{size:16}),"Phone"]})}),e.jsx(dr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(ur,{children:[e.jsx(wh,{size:16}),"Connections"]})}),m&&e.jsx(dr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(ur,{children:[e.jsx(Xo,{size:16}),"Security"]})}),e.jsx(dr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(ur,{children:[e.jsx(Zp,{size:16}),"Sessions"]})})]})}),e.jsxs(B0,{children:[o==="profile"&&e.jsx(Z0,{}),o==="email"&&d&&e.jsx(G0,{}),o==="phone"&&l&&e.jsx(H0,{}),o==="social"&&e.jsx(q0,{}),o==="security"&&m&&e.jsx(Y0,{}),o==="sessions"&&e.jsx(V0,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})})})},Y0=()=>{var oe,ye,be;const{deployment:t}=ve(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:a,verifyAuthenticator:s,deleteAuthenticator:p,generateBackupCodes:g,regenerateBackupCodes:c,updateProfile:h}=rr(),{toast:d}=It(),[l,m]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[x,v]=i.useState(!1),w=async te=>{try{await h({second_factor_policy:te}),m(te),d("Second factor policy updated successfully","info")}catch($e){d($e.message||"Failed to update second factor policy","error")}},[C,$]=i.useState(!1),[y,z]=i.useState(!1),[_,k]=i.useState(!1),[b,f]=i.useState(!1),I=i.useRef(null),j=i.useRef(null),S=i.useRef(null),R=i.useRef(null),[E,T]=i.useState("table"),[P,O]=i.useState(""),[D,M]=i.useState(""),[N,F]=i.useState(""),[ee,ce]=i.useState(["",""]),[J,X]=i.useState([]),[U,Z]=i.useState(!1),[Q,ne]=i.useState(!1),[re]=i.useState(!1),[ie,Y]=i.useState(!1),ae=(oe=t==null?void 0:t.auth_settings)==null?void 0:oe.auth_factors_enabled,q=(be=(ye=t==null?void 0:t.auth_settings)==null?void 0:ye.password)==null?void 0:be.enabled;if(!(ae!=null&&ae.authenticator)&&!(ae!=null&&ae.backup_code)&&!q)return null;const B=async(te,$e)=>{await o(te,$e),await r.refetch(),d("Password updated successfully","info")},A=async te=>{await n(te),await r.refetch(),d("Password removed successfully","info")},W=()=>{var Ee,or,nr,Vr,za,Ea;if(!r)return!1;const te=(Ee=r.user_email_addresses)==null?void 0:Ee.some(_r=>_r.verified),$e=(or=r.user_phone_numbers)==null?void 0:or.some(_r=>_r.verified),he=r.social_connections&&r.social_connections.length>0,ke=t==null?void 0:t.auth_settings;return(ke==null?void 0:ke.first_factor)==="email_otp"&&te||((nr=ke==null?void 0:ke.magic_link)==null?void 0:nr.enabled)&&te||((Vr=ke==null?void 0:ke.passkey)==null?void 0:Vr.enabled)||((za=ke==null?void 0:ke.auth_factors_enabled)==null?void 0:za.phone_otp)&&$e||he&&((Ea=t==null?void 0:t.social_connections)==null?void 0:Ea.some(_r=>_r.enabled))},L=async()=>{if(ee.some(te=>te.length!==6)){d("Please enter both 6-digit verification codes","error");return}try{if(ne(!0),await s(N,ee),await r.refetch(),ae!=null&&ae.backup_code){const te=await g();X(te),await r.refetch(),T("backup")}else T("success")}catch(te){d(te.message||"Invalid verification codes","error")}finally{ne(!1)}},G=()=>{T("table"),O(""),M(""),F(""),ce(["",""]),X([]),d("Two-factor authentication setup completed successfully!","info")},se=async()=>{var te;if((te=r==null?void 0:r.user_authenticator)!=null&&te.id)try{Y(!0),await p(r.user_authenticator.id),await r.refetch(),v(!1),d("Two-factor authentication removed successfully","info")}catch($e){d($e.message||"Failed to remove authenticator","error")}finally{Y(!1)}},me=async()=>{if(!U)try{Z(!0);const te=await c();X(te),await r.refetch(),f(!0),d("New backup codes generated","info")}catch(te){d(te.message||"Failed to generate backup codes","error")}finally{Z(!1)}},Se=()=>{const te=J.join(`
3932
- `);navigator.clipboard.writeText(te).then(()=>{d("Backup codes copied to clipboard","info")}).catch(()=>{d("Failed to copy backup codes","error")})},Ne=()=>{const te=J.join(`
3933
- `),$e=new Blob([te],{type:"text/plain"}),he=URL.createObjectURL($e),ke=document.createElement("a");ke.href=he,ke.download="wacht-backup-codes.txt",ke.click(),URL.revokeObjectURL(he),d("Backup codes downloaded","info")},H=[];return q&&H.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),ae!=null&&ae.authenticator&&H.push({id:"authenticator",name:"Two-Factor Authentication",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&H.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),(r!=null&&r.user_authenticator||r!=null&&r.backup_codes_generated||r.second_factor_policy==="enforced"||r.primary_phone_number_id)&&H.push({id:"second_factor_policy",name:"Second Factor Policy",description:"Require a second factor for all sign-ins",status:l==="enforced"?"Enforced":"Optional",actions:["toggle"]}),E!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Bo,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Xo,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[E==="qr"&&"Setup Two-Factor Authentication",E==="verify"&&"Verify Your Authenticator",E==="backup"&&"Save Your Backup Codes",E==="success"&&"Setup Complete!"]})]}),e.jsx(K,{onClick:()=>T("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[E==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:re?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${A0} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):P?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Sa,{value:P,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:D||"Loading..."})]}),e.jsx(K,{onClick:()=>T("verify"),disabled:!P||!D,style:{padding:"10px 20px",background:!P||!D?"var(--color-border)":"var(--color-primary)",color:!P||!D?"var(--color-secondary-text)":"white",border:`1px solid ${!P||!D?"var(--color-border)":"var(--color-primary)"}`,cursor:!P||!D?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),E==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(de,{type:"text",placeholder:"000000",value:ee[0],onChange:te=>{const $e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([$e,ee[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(de,{type:"text",placeholder:"000000",value:ee[1],onChange:te=>{const $e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);ce([ee[0],$e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(K,{onClick:()=>T("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(K,{onClick:L,disabled:Q||ee.some(te=>te.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:Q?"Verifying...":"Verify & Continue"})]})]}),E==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ut,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:J.map((te,$e)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(te),children:te},$e))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(K,{onClick:Se,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(K,{onClick:Ne,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(Qo,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(K,{onClick:G,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),E==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(rt,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(K,{onClick:G,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bo,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),H.length?e.jsx("div",{children:H.map((te,$e)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:te.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:te.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:te.status==="Enabled"||te.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:te.status==="Enabled"||te.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:te.status}),e.jsxs("div",{style:{position:"relative"},children:[te.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:j,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),y&&e.jsx(ci,{triggerRef:j,onClose:()=>z(!1),onChangePassword:B})]}),W()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:S,onClick:()=>k(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),_&&e.jsx(k0,{triggerRef:S,onClose:()=>k(!1),onRemovePassword:A})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:j,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),y&&e.jsx(ci,{triggerRef:j,onClose:()=>z(!1),onChangePassword:B,isSetup:!0})]})}),te.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:I,onClick:()=>$(!0),disabled:re,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:re?"Setting up...":"Setup"}),C&&e.jsx(f0,{triggerRef:I,onClose:()=>$(!1),onSetupTOTP:async()=>{const he=await a();return F(he.id),he},onVerifyTOTP:async he=>{await s(N,he),await r.refetch(),d("Two-factor authentication enabled successfully!","info")}})]})}),te.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{onClick:()=>v(!0),disabled:ie,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:ie?"not-allowed":"pointer",opacity:ie?.6:1},children:ie?"Removing...":"Remove"}),x&&e.jsx(on,{title:"Remove MFA and reset policy to default?",onConfirm:se,onCancel:()=>v(!1)})]}),te.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:R,onClick:me,disabled:U,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:U?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),b&&e.jsx(P0,{triggerRef:R,codes:J,onClose:()=>f(!1),onCopy:Se,onDownload:Ne})]})}),te.id==="second_factor_policy"&&e.jsx(Ao,{checked:l==="enforced",onChange:he=>{w(he?"enforced":"none")}})]})]})]}),$e<H.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},te.id))}):e.jsx(it,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},Z0=()=>{var M,N;const{deployment:t}=ve(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:a}=rr(),{toast:s}=It(),[p,g]=i.useState(""),[c,h]=i.useState(""),[d,l]=i.useState(""),[m,x]=i.useState(!1),[v,w]=i.useState(!1),[C,$]=i.useState(!1),[y,z]=i.useState(""),[_,k]=i.useState((r==null?void 0:r.profile_picture_url)||null),b=i.useRef(null);i.useEffect(()=>{r&&!m&&(g(r.first_name||""),h(r.last_name||""),l(r.username||""),k(r.profile_picture_url||null),x(!0))},[r,m]);const f=i.useCallback(async()=>{if(r)try{const F={};p!==r.first_name&&(F.first_name=p),c!==r.last_name&&(F.last_name=c),d!==r.username&&(F.username=d),Object.keys(F).length>0&&await o(F)}catch(F){s(F.message||"Failed to save profile changes","error")}},[r,o,p,c,d,s]),I=F=>{g(F.target.value)},j=F=>{h(F.target.value)},S=F=>{l(F.target.value)},R=()=>{f()},E=()=>{f()},T=()=>{f()},P=F=>{var ee;if((ee=F.target.files)!=null&&ee[0]){const ce=F.target.files[0];k(URL.createObjectURL(ce)),setTimeout(async()=>{try{await n(ce),r.refetch(),s("Profile picture updated successfully","info")}catch(J){s(J.message||"Failed to update profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},100)}},O=()=>{b.current&&b.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const D=async()=>{if(!(!r||y!==r.username)){$(!0);try{await a(""),s("Account deleted successfully","info")}catch(F){s(F.message||"Failed to delete account","error")}finally{$(!1),z(""),w(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:_?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:O,onMouseEnter:F=>{F.currentTarget.style.borderColor="var(--color-primary)",F.currentTarget.style.transform="scale(1.02)"},onMouseLeave:F=>{F.currentTarget.style.borderColor="var(--color-border)",F.currentTarget.style.transform="scale(1)"},children:[_?e.jsx("img",{src:_,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Mo,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:b,style:{display:"none"},accept:"image/*",onChange:P})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(K,{onClick:()=>{var F;return(F=b.current)==null?void 0:F.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Qo,{size:14}),_?"Change":"Upload"]}),e.jsxs(K,{onClick:async()=>{k(null),b.current&&(b.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),s("Profile picture removed successfully","info")}catch(F){s(F.message||"Failed to remove profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ut,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(pe,{style:{flex:1},children:[e.jsx(ue,{htmlFor:"firstName",children:"First Name"}),e.jsx(de,{id:"firstName",type:"text",value:p,onChange:I,onBlur:R,placeholder:"Enter your first name",required:!0})]}),e.jsxs(pe,{style:{flex:1},children:[e.jsx(ue,{htmlFor:"lastName",children:"Last Name"}),e.jsx(de,{id:"lastName",type:"text",value:c,onChange:j,onBlur:E,placeholder:"Enter your last name",required:!0})]})]}),((N=(M=t==null?void 0:t.auth_settings)==null?void 0:M.username)==null?void 0:N.enabled)&&e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"username",children:"Username"}),e.jsx(de,{id:"username",type:"text",value:d,onChange:S,onBlur:T,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:v?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(K,{onClick:()=>{v?(w(!1),z("")):w(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:v?"Cancel":"Delete"})]}),v&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(pe,{children:[e.jsx(ue,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(de,{id:"confirm_username",type:"text",value:y,onChange:F=>z(F.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(K,{onClick:D,disabled:y!==(r==null?void 0:r.username)||C,style:{background:y===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:y===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:y===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:y===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:C?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})})},Nl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:g,showCloseButton:c})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(we.Header,{showCloseButton:c,children:a||o}),p||g||e.jsx(Dl,{}),s&&e.jsx(we.Footer,{children:s})]})})}),K0=u.div`
3931
+ `,q0=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=rr(),{deployment:n}=ve(),a={google_oauth:{icon:e.jsx(Dc,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Ac,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(Lc,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(Bc,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(Fc,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(Uc,{}),label:"Discord"},x_oauth:{icon:e.jsx(Nc,{}),label:"X"}},s=(n==null?void 0:n.social_connections.filter(p=>p.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((p,g)=>{var d;const c=((d=t==null?void 0:t.social_connections)==null?void 0:d.filter(l=>l.provider===p.provider))||[],h=a[p.provider];return h?e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"12px 0",minHeight:"58px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",color:"var(--color-foreground)"},children:[e.jsx(Al,{children:h.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:h.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(l=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:l.email_address}),e.jsx(nn,{onClick:async()=>{await r(l.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(Ke,{size:14})})]},l.id)),c.length>0?e.jsx(K,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(K,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),g<s.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},Dl=()=>{var x,v,w,C,$,y;const{loading:t}=rr(),{deployment:r}=ve(),[o,n]=i.useState("profile"),[a,s]=i.useState(null),[p,g]=i.useState("info"),c=i.useCallback((z,_="info")=>{s(z),g(_),setTimeout(()=>s(null),3e3)},[s]);if(t)return e.jsx(le,{children:e.jsx(di,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx(Re,{})})});const h=r==null?void 0:r.auth_settings,d=(x=h==null?void 0:h.email_address)==null?void 0:x.enabled,l=(v=h==null?void 0:h.phone_number)==null?void 0:v.enabled,m=((w=h==null?void 0:h.password)==null?void 0:w.enabled)||((C=h==null?void 0:h.auth_factors_enabled)==null?void 0:C.authenticator)||(($=h==null?void 0:h.auth_factors_enabled)==null?void 0:$.phone_otp)||((y=h==null?void 0:h.auth_factors_enabled)==null?void 0:y.backup_code);return e.jsx(le,{children:e.jsx(D0,{children:e.jsx(kr.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(di,{children:[e.jsx(N0,{children:e.jsxs(F0,{children:[e.jsx(dr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(ur,{children:[e.jsx(Mo,{size:16}),"Profile"]})}),d&&e.jsx(dr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(ur,{children:[e.jsx(Wr,{size:16}),"Email"]})}),l&&e.jsx(dr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(ur,{children:[e.jsx(Rh,{size:16}),"Phone"]})}),e.jsx(dr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(ur,{children:[e.jsx(wh,{size:16}),"Connections"]})}),m&&e.jsx(dr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(ur,{children:[e.jsx(Xo,{size:16}),"Security"]})}),e.jsx(dr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(ur,{children:[e.jsx(Zp,{size:16}),"Sessions"]})})]})}),e.jsxs(B0,{children:[o==="profile"&&e.jsx(Z0,{}),o==="email"&&d&&e.jsx(G0,{}),o==="phone"&&l&&e.jsx(H0,{}),o==="social"&&e.jsx(q0,{}),o==="security"&&m&&e.jsx(Y0,{}),o==="sessions"&&e.jsx(V0,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ut,{size:16,color:"var(--color-error)"}):e.jsx(rt,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})})})},Y0=()=>{var ne,ye,be;const{deployment:t}=ve(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:a,verifyAuthenticator:s,deleteAuthenticator:p,generateBackupCodes:g,regenerateBackupCodes:c,updateProfile:h}=rr(),{toast:d}=It(),[l,m]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[x,v]=i.useState(!1),w=async te=>{try{await h({second_factor_policy:te}),m(te),d("Second factor policy updated successfully","info")}catch($e){d($e.message||"Failed to update second factor policy","error")}},[C,$]=i.useState(!1),[y,z]=i.useState(!1),[_,k]=i.useState(!1),[b,f]=i.useState(!1),I=i.useRef(null),j=i.useRef(null),S=i.useRef(null),R=i.useRef(null),[E,T]=i.useState("table"),[P,O]=i.useState(""),[D,M]=i.useState(""),[N,F]=i.useState(""),[J,ie]=i.useState(["",""]),[re,X]=i.useState([]),[U,Z]=i.useState(!1),[Q,ae]=i.useState(!1),[oe]=i.useState(!1),[ce,Y]=i.useState(!1),se=(ne=t==null?void 0:t.auth_settings)==null?void 0:ne.auth_factors_enabled,q=(be=(ye=t==null?void 0:t.auth_settings)==null?void 0:ye.password)==null?void 0:be.enabled;if(!(se!=null&&se.authenticator)&&!(se!=null&&se.backup_code)&&!q)return null;const H=async(te,$e)=>{await o(te,$e),await r.refetch(),d("Password updated successfully","info")},A=async te=>{await n(te),await r.refetch(),d("Password removed successfully","info")},B=()=>{var Ee,or,nr,Vr,za,Ea;if(!r)return!1;const te=(Ee=r.user_email_addresses)==null?void 0:Ee.some(_r=>_r.verified),$e=(or=r.user_phone_numbers)==null?void 0:or.some(_r=>_r.verified),fe=r.social_connections&&r.social_connections.length>0,ke=t==null?void 0:t.auth_settings;return(ke==null?void 0:ke.first_factor)==="email_otp"&&te||((nr=ke==null?void 0:ke.magic_link)==null?void 0:nr.enabled)&&te||((Vr=ke==null?void 0:ke.passkey)==null?void 0:Vr.enabled)||((za=ke==null?void 0:ke.auth_factors_enabled)==null?void 0:za.phone_otp)&&$e||fe&&((Ea=t==null?void 0:t.social_connections)==null?void 0:Ea.some(_r=>_r.enabled))},L=async()=>{if(J.some(te=>te.length!==6)){d("Please enter both 6-digit verification codes","error");return}try{if(ae(!0),await s(N,J),await r.refetch(),se!=null&&se.backup_code){const te=await g();X(te),await r.refetch(),T("backup")}else T("success")}catch(te){d(te.message||"Invalid verification codes","error")}finally{ae(!1)}},W=()=>{T("table"),O(""),M(""),F(""),ie(["",""]),X([]),d("Two-factor authentication setup completed successfully!","info")},ee=async()=>{var te;if((te=r==null?void 0:r.user_authenticator)!=null&&te.id)try{Y(!0),await p(r.user_authenticator.id),await r.refetch(),v(!1),d("Two-factor authentication removed successfully","info")}catch($e){d($e.message||"Failed to remove authenticator","error")}finally{Y(!1)}},pe=async()=>{if(!U)try{Z(!0);const te=await c();X(te),await r.refetch(),f(!0),d("New backup codes generated","info")}catch(te){d(te.message||"Failed to generate backup codes","error")}finally{Z(!1)}},Se=()=>{const te=re.join(`
3932
+ `);navigator.clipboard.writeText(te).then(()=>{d("Backup codes copied to clipboard","info")}).catch(()=>{d("Failed to copy backup codes","error")})},Ne=()=>{const te=re.join(`
3933
+ `),$e=new Blob([te],{type:"text/plain"}),fe=URL.createObjectURL($e),ke=document.createElement("a");ke.href=fe,ke.download="wacht-backup-codes.txt",ke.click(),URL.revokeObjectURL(fe),d("Backup codes downloaded","info")},G=[];return q&&G.push({id:"password",name:"Password",description:"Secure your account with a strong password",status:r!=null&&r.has_password?"Enabled":"Disabled",actions:r!=null&&r.has_password?["change"]:["setup"]}),se!=null&&se.authenticator&&G.push({id:"authenticator",name:"Two-Factor Authentication",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&G.push({id:"backup_codes",name:"Backup Codes",description:"Recovery codes if you lose your authenticator",status:r!=null&&r.backup_codes_generated?"Generated":"Not Generated",actions:["generate"]}),(r!=null&&r.user_authenticator||r!=null&&r.backup_codes_generated||r.second_factor_policy==="enforced"||r.primary_phone_number_id)&&G.push({id:"second_factor_policy",name:"Second Factor Policy",description:"Require a second factor for all sign-ins",status:l==="enforced"?"Enforced":"Optional",actions:["toggle"]}),E!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Bo,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Xo,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[E==="qr"&&"Setup Two-Factor Authentication",E==="verify"&&"Verify Your Authenticator",E==="backup"&&"Save Your Backup Codes",E==="success"&&"Setup Complete!"]})]}),e.jsx(K,{onClick:()=>T("table"),style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",color:"var(--color-foreground)",fontWeight:"500",cursor:"pointer",transition:"all 0.2s ease"},children:"← Back"})]}),e.jsxs("div",{style:{maxWidth:"500px",margin:"0 auto",textAlign:"center",padding:"24px"},children:[E==="qr"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"24px"},children:oe?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${A0} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):P?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Sa,{value:P,size:200,level:"M",marginSize:0})}):e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)",color:"var(--color-error)",fontSize:"14px",textAlign:"center"},children:"QR Code Not Available"})}),e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"12px",marginBottom:"24px"},children:[e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:"0 0 8px 0"},children:"Or enter this code manually:"}),e.jsx("code",{style:{fontFamily:"monospace",fontSize:"14px",wordBreak:"break-all"},children:D||"Loading..."})]}),e.jsx(K,{onClick:()=>T("verify"),disabled:!P||!D,style:{padding:"10px 20px",background:!P||!D?"var(--color-border)":"var(--color-primary)",color:!P||!D?"var(--color-secondary-text)":"white",border:`1px solid ${!P||!D?"var(--color-border)":"var(--color-primary)"}`,cursor:!P||!D?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),E==="verify"&&e.jsxs(e.Fragment,{children:[e.jsx("p",{style:{color:"var(--color-secondary-text)",marginBottom:"24px"},children:"Enter two consecutive codes from your authenticator app to verify setup"}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(de,{type:"text",placeholder:"000000",value:J[0],onChange:te=>{const $e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);ie([$e,J[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(de,{type:"text",placeholder:"000000",value:J[1],onChange:te=>{const $e=te.target.value.replace(/[^0-9]/g,"").substring(0,6);ie([J[0],$e])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(K,{onClick:()=>T("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(K,{onClick:L,disabled:Q||J.some(te=>te.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:Q?"Verifying...":"Verify & Continue"})]})]}),E==="backup"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-md)",padding:"16px",marginBottom:"24px",display:"flex",alignItems:"flex-start",gap:"12px",textAlign:"left"},children:[e.jsx(ut,{size:16,style:{color:"var(--color-warning)",marginTop:"2px"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontWeight:500,marginBottom:"4px"},children:"Important!"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-secondary-text)"},children:"Store these codes safely. Each code can only be used once if you lose access to your authenticator device."})]})]}),e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"8px",marginBottom:"24px",maxWidth:"300px",margin:"0 auto 24px auto"},children:re.map((te,$e)=>e.jsx("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",fontFamily:"monospace",fontSize:"12px",textAlign:"center",cursor:"pointer"},onClick:()=>navigator.clipboard.writeText(te),children:te},$e))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(K,{onClick:Se,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(K,{onClick:Ne,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx(Qo,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(K,{onClick:W,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),E==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(rt,{size:48,style:{color:"var(--color-success)",marginBottom:"16px"}}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,margin:"0 0 8px 0"},children:"All Set!"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-secondary-text)",margin:0},children:"Your account is now protected with two-factor authentication."})]}),e.jsx(K,{onClick:W,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Bo,{children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:e.jsx("span",{style:{fontSize:"14px",fontWeight:400,color:"var(--color-foreground)"},children:"Security Settings"})})}),G.length?e.jsx("div",{children:G.map((te,$e)=>e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"16px 0"},children:[e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:400,color:"var(--color-foreground)"},children:te.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:te.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:te.status==="Enabled"||te.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:te.status==="Enabled"||te.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:te.status}),e.jsxs("div",{style:{position:"relative"},children:[te.id==="password"&&e.jsx(e.Fragment,{children:r!=null&&r.has_password?e.jsxs("div",{style:{display:"flex",gap:"8px"},children:[e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:j,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),y&&e.jsx(ci,{triggerRef:j,onClose:()=>z(!1),onChangePassword:H})]}),B()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:S,onClick:()=>k(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),_&&e.jsx(k0,{triggerRef:S,onClose:()=>k(!1),onRemovePassword:A})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:j,onClick:()=>z(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),y&&e.jsx(ci,{triggerRef:j,onClose:()=>z(!1),onChangePassword:H,isSetup:!0})]})}),te.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:I,onClick:()=>$(!0),disabled:oe,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:oe?"Setting up...":"Setup"}),C&&e.jsx(f0,{triggerRef:I,onClose:()=>$(!1),onSetupTOTP:async()=>{const fe=await a();return F(fe.id),fe},onVerifyTOTP:async fe=>{await s(N,fe),await r.refetch(),d("Two-factor authentication enabled successfully!","info")}})]})}),te.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{onClick:()=>v(!0),disabled:ce,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:ce?"not-allowed":"pointer",opacity:ce?.6:1},children:ce?"Removing...":"Remove"}),x&&e.jsx(on,{title:"Remove MFA and reset policy to default?",onConfirm:ee,onCancel:()=>v(!1)})]}),te.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(K,{ref:R,onClick:pe,disabled:U,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:U?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),b&&e.jsx(P0,{triggerRef:R,codes:re,onClose:()=>f(!1),onCopy:Se,onDownload:Ne})]})}),te.id==="second_factor_policy"&&e.jsx(Ao,{checked:l==="enforced",onChange:fe=>{w(fe?"enforced":"none")}})]})]})]}),$e<G.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},te.id))}):e.jsx(it,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},Z0=()=>{var M,N;const{deployment:t}=ve(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:a}=rr(),{toast:s}=It(),[p,g]=i.useState(""),[c,h]=i.useState(""),[d,l]=i.useState(""),[m,x]=i.useState(!1),[v,w]=i.useState(!1),[C,$]=i.useState(!1),[y,z]=i.useState(""),[_,k]=i.useState((r==null?void 0:r.profile_picture_url)||null),b=i.useRef(null);i.useEffect(()=>{r&&!m&&(g(r.first_name||""),h(r.last_name||""),l(r.username||""),k(r.profile_picture_url||null),x(!0))},[r,m]);const f=i.useCallback(async()=>{if(r)try{const F={};p!==r.first_name&&(F.first_name=p),c!==r.last_name&&(F.last_name=c),d!==r.username&&(F.username=d),Object.keys(F).length>0&&await o(F)}catch(F){s(F.message||"Failed to save profile changes","error")}},[r,o,p,c,d,s]),I=F=>{g(F.target.value)},j=F=>{h(F.target.value)},S=F=>{l(F.target.value)},R=()=>{f()},E=()=>{f()},T=()=>{f()},P=F=>{var J;if((J=F.target.files)!=null&&J[0]){const ie=F.target.files[0];k(URL.createObjectURL(ie)),setTimeout(async()=>{try{await n(ie),r.refetch(),s("Profile picture updated successfully","info")}catch(re){s(re.message||"Failed to update profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},100)}},O=()=>{b.current&&b.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx(Re,{})});const D=async()=>{if(!(!r||y!==r.username)){$(!0);try{await a(""),s("Account deleted successfully","info")}catch(F){s(F.message||"Failed to delete account","error")}finally{$(!1),z(""),w(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:_?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:O,onMouseEnter:F=>{F.currentTarget.style.borderColor="var(--color-primary)",F.currentTarget.style.transform="scale(1.02)"},onMouseLeave:F=>{F.currentTarget.style.borderColor="var(--color-border)",F.currentTarget.style.transform="scale(1)"},children:[_?e.jsx("img",{src:_,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Mo,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:b,style:{display:"none"},accept:"image/*",onChange:P})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Picture"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Upload an image to represent your profile"})]}),e.jsxs("div",{style:{display:"flex",gap:"var(--space-sm)",marginBottom:"var(--space-sm)"},children:[e.jsxs(K,{onClick:()=>{var F;return(F=b.current)==null?void 0:F.click()},style:{padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Qo,{size:14}),_?"Change":"Upload"]}),e.jsxs(K,{onClick:async()=>{k(null),b.current&&(b.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),s("Profile picture removed successfully","info")}catch(F){s(F.message||"Failed to remove profile picture","error"),k((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ut,{size:14}),"Remove"]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"var(--space-md)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"Profile Details"}),e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-secondary-text)",margin:0},children:"Basic information about your profile"})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-lg)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-md)"},children:[e.jsxs(he,{style:{flex:1},children:[e.jsx(ue,{htmlFor:"firstName",children:"First Name"}),e.jsx(de,{id:"firstName",type:"text",value:p,onChange:I,onBlur:R,placeholder:"Enter your first name",required:!0})]}),e.jsxs(he,{style:{flex:1},children:[e.jsx(ue,{htmlFor:"lastName",children:"Last Name"}),e.jsx(de,{id:"lastName",type:"text",value:c,onChange:j,onBlur:E,placeholder:"Enter your last name",required:!0})]})]}),((N=(M=t==null?void 0:t.auth_settings)==null?void 0:M.username)==null?void 0:N.enabled)&&e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"username",children:"Username"}),e.jsx(de,{id:"username",type:"text",value:d,onChange:S,onBlur:T,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:v?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(K,{onClick:()=>{v?(w(!1),z("")):w(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:v?"Cancel":"Delete"})]}),v&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(he,{children:[e.jsx(ue,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(de,{id:"confirm_username",type:"text",value:y,onChange:F=>z(F.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(K,{onClick:D,disabled:y!==(r==null?void 0:r.username)||C,style:{background:y===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:y===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:y===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:y===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:C?e.jsx(Re,{size:12}):"Delete Forever"})]})]})]})]})})},Nl=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:g,showCloseButton:c})=>e.jsx(we,{isOpen:t,onClose:r,children:e.jsx(we.Overlay,{children:e.jsxs(we.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(we.Header,{showCloseButton:c,children:a||o}),p||g||e.jsx(Dl,{}),s&&e.jsx(we.Footer,{children:s})]})})}),K0=u.div`
3934
3934
  position: relative;
3935
3935
  `,Q0=u.button`
3936
3936
  display: flex;
@@ -4793,7 +4793,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
4793
4793
  margin: 0 auto;
4794
4794
  padding: 6px 16px;
4795
4795
  font-size: 13px;
4796
- `,nv=()=>{var R,E;const{organizationMemberships:t,refetch:r,loading:o}=bt(),{workspaces:n}=yt(),{switchOrganization:a,switchWorkspace:s}=Fe(),{deployment:p}=ve(),[g,c]=i.useState(null),[h,d]=i.useState("orgList"),[l,m]=i.useState(null),x=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,v=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,w=i.useRef(!1);i.useEffect(()=>{if(!(w.current||!t)){if(w.current=!0,t.length===0){d("createOrg");return}if(!x){d("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),d("createWorkspace");return}d("orgList")}},[t,n,x]),console.log("view mode",h,x);const C=T=>T.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),$=async T=>{if(x){m(T.id),d("workspaceList");return}c(T.id);try{await a(T.id)}finally{c(null)}},y=async T=>{c(T.id);try{await s(T.id)}finally{c(null)}},z=async T=>{await r(),x&&T&&(m(T.id),d("createWorkspace"))},_=()=>{},k=async()=>{m(null),d("orgList")},b=(R=t==null?void 0:t.find(T=>T.organization.id===l))==null?void 0:R.organization,f=l?n==null?void 0:n.filter(T=>T.organization.id===l):[];if(o)return null;if(h==="createOrg")return e.jsx(we.Body,{style:{padding:0},children:e.jsx(rn,{onSuccess:z,onCancel:t&&t.length>0?()=>d("orgList"):void 0})});if(h==="createWorkspace"&&l)return e.jsx(we.Body,{style:{padding:0},children:e.jsx(_a,{organizationId:l,onSuccess:_,onCancel:()=>d("workspaceList"),onCreateOrganization:()=>d("createOrg")})});const I=h==="workspaceList",j=I?"Select a workspace":"Select an organization",S=I?`Choose a workspace in ${(b==null?void 0:b.name)||""}`:`to continue to ${((E=p==null?void 0:p.ui_settings)==null?void 0:E.app_name)||"App"}`;return e.jsxs(q1,{children:[e.jsxs(Y1,{children:[e.jsxs("div",{children:[e.jsx(Ae,{}),e.jsxs(ev,{children:[e.jsx(tv,{children:j}),e.jsx(rv,{children:S})]})]}),e.jsx($a,{showName:!0})]}),e.jsxs(Z1,{children:[e.jsxs(K1,{children:[e.jsxs(Q1,{children:[e.jsx(X1,{children:I?"Workspaces":"Your organizations"}),I&&e.jsxs(J1,{onClick:k,children:[e.jsx(Ur,{}),"Go back"]})]}),e.jsx(ov,{children:I?e.jsx(e.Fragment,{children:f&&f.length>0?f.map(T=>{var O,D,M;const P=((O=T.eligibility_restriction)==null?void 0:O.type)!=="none"&&((D=T.eligibility_restriction)==null?void 0:D.type)!==void 0;return e.jsxs($i,{onClick:()=>!P&&y(T),disabled:g===T.id||P,style:{opacity:P?.7:1},children:[e.jsx(zi,{children:T.image_url?e.jsx(Ei,{src:T.image_url,alt:T.name}):C(T.name).charAt(0)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:T.name}),e.jsxs(Ii,{children:[e.jsx(Lo,{}),"Workspace"]})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),P&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(M=T.eligibility_restriction)==null?void 0:M.message]})]},T.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No workspaces yet"}),e.jsxs(Ai,{children:["Create your first workspace for"," ",(b==null?void 0:b.name)||"this organization"]}),e.jsxs(Di,{onClick:()=>d("createWorkspace"),children:[e.jsx(Je,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(T=>{var J,X,U;const P=T.organization,O=n==null?void 0:n.filter(Z=>Z.organization.id===P.id),D=(O==null?void 0:O.length)||0,M=P.member_count,N=T.roles[0].name,F=T.roles.length-1,ee=F>0?`${N.charAt(0).toUpperCase()+N.slice(1)} +${F}`:N.charAt(0).toUpperCase()+N.slice(1),ce=((J=T.eligibility_restriction)==null?void 0:J.type)!=="none"&&((X=T.eligibility_restriction)==null?void 0:X.type)!==void 0;return e.jsxs($i,{onClick:()=>!ce&&$(P),disabled:g===P.id||ce,style:{opacity:ce?.7:1},children:[e.jsx(zi,{children:P.image_url?e.jsx(Ei,{src:P.image_url,alt:P.name}):C(P.name)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:P.name}),e.jsx(Ii,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Lo,{}),D," workspace",D!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(rh,{}),ee," • ",M," member",M!==1?"s":""]})})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),ce&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(U=T.eligibility_restriction)==null?void 0:U.message]})]},P.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No organizations yet"}),e.jsx(Ai,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Di,{onClick:()=>d("createOrg"),children:[e.jsx(Je,{}),"Create organization"]})]})})]}),I&&f&&f.length>0&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createWorkspace"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new workspace"]}),!I&&t&&t.length>0&&v&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createOrg"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new organization"]})]})]})},av=u(we.Content)`
4796
+ `,nv=()=>{var R,E;const{organizationMemberships:t,refetch:r,loading:o}=bt(),{workspaces:n}=yt(),{switchOrganization:a,switchWorkspace:s}=Fe(),{deployment:p}=ve(),[g,c]=i.useState(null),[h,d]=i.useState("orgList"),[l,m]=i.useState(null),x=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,v=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,w=i.useRef(!1);i.useEffect(()=>{if(!(w.current||!t)){if(w.current=!0,t.length===0){d("createOrg");return}if(!x){d("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),d("createWorkspace");return}d("orgList")}},[t,n,x]),console.log("view mode",h,x);const C=T=>T.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),$=async T=>{if(x){m(T.id),d("workspaceList");return}c(T.id);try{await a(T.id)}finally{c(null)}},y=async T=>{c(T.id);try{await s(T.id)}finally{c(null)}},z=async T=>{await r(),x&&T&&(m(T.id),d("createWorkspace"))},_=()=>{},k=async()=>{m(null),d("orgList")},b=(R=t==null?void 0:t.find(T=>T.organization.id===l))==null?void 0:R.organization,f=l?n==null?void 0:n.filter(T=>T.organization.id===l):[];if(o)return null;if(h==="createOrg")return e.jsx(we.Body,{style:{padding:0},children:e.jsx(rn,{onSuccess:z,onCancel:t&&t.length>0?()=>d("orgList"):void 0})});if(h==="createWorkspace"&&l)return e.jsx(we.Body,{style:{padding:0},children:e.jsx(_a,{organizationId:l,onSuccess:_,onCancel:()=>d("workspaceList"),onCreateOrganization:()=>d("createOrg")})});const I=h==="workspaceList",j=I?"Select a workspace":"Select an organization",S=I?`Choose a workspace in ${(b==null?void 0:b.name)||""}`:`to continue to ${((E=p==null?void 0:p.ui_settings)==null?void 0:E.app_name)||"App"}`;return e.jsxs(q1,{children:[e.jsxs(Y1,{children:[e.jsxs("div",{children:[e.jsx(Ae,{}),e.jsxs(ev,{children:[e.jsx(tv,{children:j}),e.jsx(rv,{children:S})]})]}),e.jsx($a,{showName:!0})]}),e.jsxs(Z1,{children:[e.jsxs(K1,{children:[e.jsxs(Q1,{children:[e.jsx(X1,{children:I?"Workspaces":"Your organizations"}),I&&e.jsxs(J1,{onClick:k,children:[e.jsx(Ur,{}),"Go back"]})]}),e.jsx(ov,{children:I?e.jsx(e.Fragment,{children:f&&f.length>0?f.map(T=>{var O,D,M;const P=((O=T.eligibility_restriction)==null?void 0:O.type)!=="none"&&((D=T.eligibility_restriction)==null?void 0:D.type)!==void 0;return e.jsxs($i,{onClick:()=>!P&&y(T),disabled:g===T.id||P,style:{opacity:P?.7:1},children:[e.jsx(zi,{children:T.image_url?e.jsx(Ei,{src:T.image_url,alt:T.name}):C(T.name).charAt(0)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:T.name}),e.jsxs(Ii,{children:[e.jsx(Lo,{}),"Workspace"]})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),P&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(M=T.eligibility_restriction)==null?void 0:M.message]})]},T.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No workspaces yet"}),e.jsxs(Ai,{children:["Create your first workspace for"," ",(b==null?void 0:b.name)||"this organization"]}),e.jsxs(Di,{onClick:()=>d("createWorkspace"),children:[e.jsx(Je,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(T=>{var re,X,U;const P=T.organization,O=n==null?void 0:n.filter(Z=>Z.organization.id===P.id),D=(O==null?void 0:O.length)||0,M=P.member_count,N=T.roles[0].name,F=T.roles.length-1,J=F>0?`${N.charAt(0).toUpperCase()+N.slice(1)} +${F}`:N.charAt(0).toUpperCase()+N.slice(1),ie=((re=T.eligibility_restriction)==null?void 0:re.type)!=="none"&&((X=T.eligibility_restriction)==null?void 0:X.type)!==void 0;return e.jsxs($i,{onClick:()=>!ie&&$(P),disabled:g===P.id||ie,style:{opacity:ie?.7:1},children:[e.jsx(zi,{children:P.image_url?e.jsx(Ei,{src:P.image_url,alt:P.name}):C(P.name)}),e.jsxs(Pi,{children:[e.jsx(Ri,{children:P.name}),e.jsx(Ii,{children:x?e.jsxs(e.Fragment,{children:[e.jsx(Lo,{}),D," workspace",D!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(rh,{}),J," • ",M," member",M!==1?"s":""]})})]}),e.jsx(Ti,{children:e.jsx(ua,{})}),ie&&e.jsxs(Oi,{children:[e.jsx(ut,{size:14}),(U=T.eligibility_restriction)==null?void 0:U.message]})]},P.id)}):e.jsxs(Mi,{children:[e.jsx(Li,{children:"No organizations yet"}),e.jsx(Ai,{children:v?"Create your first organization to get started":"You don't have access to any organizations yet"}),v&&e.jsxs(Di,{onClick:()=>d("createOrg"),children:[e.jsx(Je,{}),"Create organization"]})]})})]}),I&&f&&f.length>0&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createWorkspace"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new workspace"]}),!I&&t&&t.length>0&&v&&e.jsxs(K,{style:{marginTop:"var(--space-md)"},onClick:()=>d("createOrg"),disabled:g!==null,children:[e.jsx(Je,{size:12}),"Create new organization"]})]})]})},av=u(we.Content)`
4797
4797
  padding: 0;
4798
4798
  max-width: 90vw;
4799
4799
  `,sv=({children:t})=>{var w,C,$,y;const{loading:r,session:o}=Fe(),{activeOrganization:n}=Qe(),{activeWorkspace:a,loading:s}=Pt(),{workspaces:p}=yt(),{deployment:g}=ve(),{organizationMemberships:c}=bt(),h=(g==null?void 0:g.b2b_settings.workspaces_enabled)??!1,d=c==null?void 0:c.find(z=>z.organization.id===(n==null?void 0:n.id)),l=p==null?void 0:p.find(z=>{var _;return z.id===((_=o==null?void 0:o.active_signin)==null?void 0:_.active_workspace_membership_id)}),m=((w=d==null?void 0:d.eligibility_restriction)==null?void 0:w.type)!=="none"&&((C=d==null?void 0:d.eligibility_restriction)==null?void 0:C.type)!==void 0,x=(($=l==null?void 0:l.eligibility_restriction)==null?void 0:$.type)!=="none"&&((y=l==null?void 0:l.eligibility_restriction)==null?void 0:y.type)!==void 0;return r||h&&s?null:(m||x||!n?!1:h?a?p==null?void 0:p.some(_=>_.id===a.id&&_.organization.id===n.id):!1:!0)?(console.log("valid"),e.jsx(e.Fragment,{children:t})):e.jsx(le,{children:e.jsx(we,{isOpen:!0,children:e.jsx(we.Overlay,{children:e.jsx(av,{style:{width:"850px"},children:e.jsx(nv,{})})})})})},iv=u.div`
@@ -5478,7 +5478,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
5478
5478
  &:hover .expand-icon {
5479
5479
  opacity: 1;
5480
5480
  }
5481
- `,Gv=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:a,onClose:s,onDownload:p,onZoom:g,onReset:c,onWheel:h,onMouseDown:d,onMouseMove:l,onMouseUp:m})=>{const[x,v]=i.useState(!1),w=i.useRef(null);return i.useEffect(()=>(v(!0),()=>v(!1)),[]),i.useEffect(()=>{if(t){const C=document.body.style.overflow;document.body.style.overflow="hidden";const $=_=>{(_.ctrlKey||_.metaKey)&&_.preventDefault()},y=_=>{_.preventDefault()},z=_=>{_.preventDefault()};return document.addEventListener("wheel",$,{passive:!1}),document.addEventListener("gesturestart",y,{passive:!1}),document.addEventListener("gesturechange",z,{passive:!1}),()=>{document.body.style.overflow=C,document.removeEventListener("wheel",$),document.removeEventListener("gesturestart",y),document.removeEventListener("gesturechange",z)}}},[t]),!x||!t||!r?null:Nr.createPortal(e.jsx(le,{children:e.jsx(Dv,{ref:w,$isOpen:!0,onClick:C=>{C.target===C.currentTarget&&s()},children:e.jsxs(Nv,{onClick:C=>C.stopPropagation(),onWheel:C=>{C.preventDefault(),C.stopPropagation(),h(C)},onMouseMove:l,onMouseUp:m,onMouseLeave:m,children:[e.jsx(Fv,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:a,onMouseDown:d,draggable:!1}),e.jsx(ko,{$variant:"ghost",onClick:s,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(Ke,{size:14})}),e.jsxs(Bv,{children:[e.jsxs(Uv,{children:[e.jsx(ko,{$variant:"ghost",onClick:()=>g(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(qh,{size:14})}),e.jsxs(Wv,{children:[Math.round(o*100),"%"]}),e.jsx(ko,{$variant:"ghost",onClick:()=>g(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Gh,{size:14})}),e.jsx(ko,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(Sh,{size:14})})]}),e.jsxs(Hl,{$variant:"primary",onClick:p,title:"Download image",children:[e.jsx(Qo,{size:14}),"Download"]})]})]})})}),document.body)};function ql({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:a,selectedSession:s,selectSession:p}=Uo(),g=s==null?void 0:s.id;if(!g)return e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsx(Ni,{children:e.jsxs(Fi,{children:[e.jsx(jn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,h=!0,d="Start a conversation by typing a message below",[l,m]=i.useState(""),[x,v]=i.useState(!1),[w,C]=i.useState(null),[$,y]=i.useState([]),[z,_]=i.useState([]),[k,b]=i.useState(null),[f,I]=i.useState(1),[j,S]=i.useState(!1),[R,E]=i.useState({x:0,y:0}),[T,P]=i.useState({x:0,y:0}),O=i.useRef(null),D=i.useRef(null),{messages:M,pendingMessage:N,pendingImages:F,connectionState:ee,isConnected:ce,isExecuting:J,executionStatus:X,isWaitingForInput:U,sendMessage:Z,submitUserInput:Q,cancelExecution:ne}=lc({contextId:g,agentName:o,token:n,platformAdapter:a,autoConnect:c});i.useEffect(()=>{var H;(H=O.current)==null||H.scrollIntoView({behavior:"smooth"})},[M]),i.useEffect(()=>{var H;if(U){const oe=M.slice().reverse().find(ye=>{var be;return((be=ye.metadata)==null?void 0:be.type)==="user_input_request"});(H=oe==null?void 0:oe.metadata)!=null&&H.userInputRequest&&C(oe.metadata.userInputRequest)}else C(null),y([])},[U,M]);const re=H=>{if(H.preventDefault(),!!ce)if(U&&w){let oe=l.trim();w.input_type==="multiselect"&&(oe=$.join(",")),oe&&(Q(oe),m(""),y([]))}else!J&&l.trim()&&(Z(l,z.length>0?z:void 0),m(""),_([]))},ie=H=>{const oe=H.target.files;oe&&(Array.from(oe).forEach(ye=>{if(ye.type.startsWith("image/")){const be=new FileReader;be.onload=te=>{var $e;if(($e=te.target)!=null&&$e.result){const ke=te.target.result.split(",")[1];_(Te=>[...Te,{mime_type:ye.type,data:ke}])}},be.readAsDataURL(ye)}}),D.current&&(D.current.value=""))},Y=H=>{_(oe=>oe.filter((ye,be)=>be!==H))},ae=H=>{b(H),I(1),E({x:0,y:0})},q=()=>{b(null),I(1),E({x:0,y:0}),S(!1)},B=H=>{const oe=document.createElement("a");oe.href=H,oe.download=`image-${Date.now()}.png`,document.body.appendChild(oe),oe.click(),document.body.removeChild(oe)},A=H=>{I(oe=>{const ye=oe+H;return Math.min(Math.max(ye,.5),3)})},W=H=>{H.preventDefault(),H.stopPropagation();const oe=H.deltaY>0?-.1:.1;A(oe)},L=H=>{f>1&&(S(!0),P({x:H.clientX-R.x,y:H.clientY-R.y}))},G=H=>{j&&f>1&&E({x:H.clientX-T.x,y:H.clientY-T.y})},se=()=>{S(!1)},me=()=>ee.status===xt.CONNECTING?"Connecting...":ee.status===xt.ERROR?"Connection error":ee.status===xt.DISCONNECTED||!ce?"Disconnected":U?"Waiting for your input...":J?"Working...":"Ready",Se=()=>{if(!U||!w)return"Ask anything";switch(w.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},Ne=()=>!U||!w?!1:["select","multiselect","boolean","date"].includes(w.input_type||"");return e.jsxs(le,{style:{height:"100%",width:"100%"},children:[e.jsxs(Ni,{children:[e.jsxs(pv,{children:[e.jsxs(hv,{children:[t&&e.jsx(fv,{onClick:()=>{r?r():p(null)},children:e.jsx(Ur,{size:20})}),e.jsxs(gv,{children:[e.jsx(mv,{children:e.jsx(jn,{size:20})}),e.jsxs(xv,{children:[e.jsx(bv,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(vv,{$status:me()}),e.jsx(yv,{$status:me(),children:me()})]})]})]})]}),X!==Me.IDLE&&e.jsx(wv,{$status:X,children:X.replace("_"," ")})]}),e.jsx(jv,{children:M.length===0&&h?e.jsxs(Fi,{children:[e.jsx(jn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:d})]}):e.jsxs(e.Fragment,{children:[M.map((H,oe)=>{var ye,be,te,$e;if(((ye=H.metadata)==null?void 0:ye.type)==="user_input_request"&&H.metadata.userInputRequest){const he=H.metadata.userInputRequest,ke=!he.input_type||he.input_type==="text"||he.input_type==="number",Te=U&&(w==null?void 0:w.input_type)===he.input_type;return e.jsx(Vn,{$isUser:!1,children:e.jsxs(Sv,{children:[e.jsx("div",{className:"question",children:he.question}),he.context&&he.context.trim()&&e.jsx("div",{className:"context",children:he.context}),!ke&&e.jsxs("div",{className:"controls",children:[he.input_type==="select"&&he.options&&e.jsxs("select",{value:Te?l:"",onChange:Ee=>m(Ee.target.value),disabled:!Te,children:[e.jsx("option",{value:"",children:"Choose an option..."}),he.options.map(Ee=>e.jsx("option",{value:Ee,children:Ee},Ee))]}),he.input_type==="multiselect"&&he.options&&e.jsx("div",{className:"checkbox-group",children:he.options.map(Ee=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Te&&$.includes(Ee),onChange:or=>{or.target.checked?y([...$,Ee]):y($.filter(nr=>nr!==Ee))},disabled:!Te}),e.jsx("span",{children:Ee})]},Ee))}),he.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Te&&l==="true",onChange:Ee=>m(Ee.target.value),disabled:!Te}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Te&&l==="false",onChange:Ee=>m(Ee.target.value),disabled:!Te}),e.jsx("span",{children:"No"})]})]}),he.input_type==="date"&&e.jsx("input",{type:"date",value:Te?l:"",onChange:Ee=>m(Ee.target.value),disabled:!Te})]}),e.jsx("div",{className:"instruction",children:Te?ke?"Type your response below":he.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},H.id)}if(((be=H.metadata)==null?void 0:be.type)==="log"){const he=M[oe-1],ke=M[oe+1],Te=((te=he==null?void 0:he.metadata)==null?void 0:te.type)==="log",Ee=(($e=ke==null?void 0:ke.metadata)==null?void 0:$e.type)==="log",or=Te||Ee,nr=!Te&&Ee,Vr=Te&&!Ee;return e.jsx(Cv,{$isGrouped:or,$isFirstInGroup:nr,$isLastInGroup:Vr,children:e.jsx("div",{className:"log-content",children:H.content})},H.id)}return!H.content&&(!H.images||H.images.length===0)?null:e.jsx(Vn,{$isUser:H.role==="user",children:e.jsxs(Gl,{$isUser:H.role==="user",children:[e.jsx("div",{children:H.content}),H.images&&H.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:H.images.map((he,ke)=>{const Te=he.url||`data:${he.mime_type};base64,${he.data}`;return e.jsxs(Vv,{onClick:()=>ae(Te),title:"Click to preview",children:[e.jsx("img",{src:Te,alt:`Image ${ke+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(fh,{size:14})})]},ke)})}),H.isStreaming&&e.jsx(kv,{})]})},H.id)}),N&&e.jsx(Vn,{$isUser:!0,children:e.jsxs(_v,{$isUser:!0,children:[e.jsx("div",{children:N}),F&&F.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:F.map((H,oe)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:H.data?`data:${H.mime_type};base64,${H.data}`:"#",alt:`Image ${oe+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},oe))})]})}),e.jsx("div",{ref:O})]})}),z.length>0&&e.jsx(Iv,{children:z.map((H,oe)=>e.jsxs(Tv,{children:[e.jsx("img",{src:H.data?`data:${H.mime_type};base64,${H.data}`:"#",alt:`Upload ${oe+1}`}),e.jsx(Ov,{type:"button",onClick:()=>Y(oe),children:e.jsx(Ke,{size:12})})]},oe))}),e.jsx($v,{onSubmit:re,children:e.jsxs(zv,{children:[e.jsxs(Ev,{children:[e.jsx(Pv,{value:l,onChange:H=>m(H.target.value),onKeyDown:H=>{H.key==="Enter"&&!H.shiftKey&&(H.preventDefault(),re(H))},placeholder:Se(),disabled:!ce||J&&!U||Ne(),rows:1}),e.jsx(Rv,{children:e.jsxs(Lv,{type:"button",disabled:!ce||J,onClick:()=>{var H;return(H=D.current)==null?void 0:H.click()},children:[e.jsx(Eh,{size:16}),"Attach"]})}),e.jsx(Mv,{ref:D,type:"file",accept:"image/*",multiple:!0,onChange:ie})]}),e.jsx(Av,{type:J?"button":"submit",disabled:!ce||!U&&!J&&!l.trim(),onClick:J?ne:void 0,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{background:J&&x?"var(--color-error)":void 0},children:J?x?e.jsx(Ke,{size:14}):e.jsx(vr,{size:14,className:"animate-spin"}):e.jsx(qc,{size:14})})]})})]}),e.jsx(Gv,{isOpen:!!k,imageUrl:k,zoomLevel:f,dragPosition:R,isDragging:j,onClose:q,onDownload:()=>k&&B(k),onZoom:A,onReset:()=>{I(1),E({x:0,y:0})},onWheel:W,onMouseDown:L,onMouseMove:G,onMouseUp:se})]})}const Hv=u.div`
5481
+ `,Gv=({isOpen:t,imageUrl:r,zoomLevel:o,dragPosition:n,isDragging:a,onClose:s,onDownload:p,onZoom:g,onReset:c,onWheel:h,onMouseDown:d,onMouseMove:l,onMouseUp:m})=>{const[x,v]=i.useState(!1),w=i.useRef(null);return i.useEffect(()=>(v(!0),()=>v(!1)),[]),i.useEffect(()=>{if(t){const C=document.body.style.overflow;document.body.style.overflow="hidden";const $=_=>{(_.ctrlKey||_.metaKey)&&_.preventDefault()},y=_=>{_.preventDefault()},z=_=>{_.preventDefault()};return document.addEventListener("wheel",$,{passive:!1}),document.addEventListener("gesturestart",y,{passive:!1}),document.addEventListener("gesturechange",z,{passive:!1}),()=>{document.body.style.overflow=C,document.removeEventListener("wheel",$),document.removeEventListener("gesturestart",y),document.removeEventListener("gesturechange",z)}}},[t]),!x||!t||!r?null:Nr.createPortal(e.jsx(le,{children:e.jsx(Dv,{ref:w,$isOpen:!0,onClick:C=>{C.target===C.currentTarget&&s()},children:e.jsxs(Nv,{onClick:C=>C.stopPropagation(),onWheel:C=>{C.preventDefault(),C.stopPropagation(),h(C)},onMouseMove:l,onMouseUp:m,onMouseLeave:m,children:[e.jsx(Fv,{src:r,alt:"Preview",$zoom:o,$x:n.x,$y:n.y,$isDragging:a,onMouseDown:d,draggable:!1}),e.jsx(ko,{$variant:"ghost",onClick:s,title:"Close",style:{position:"absolute",top:"16px",right:"16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:e.jsx(Ke,{size:14})}),e.jsxs(Bv,{children:[e.jsxs(Uv,{children:[e.jsx(ko,{$variant:"ghost",onClick:()=>g(-.25),title:"Zoom out",disabled:o<=.5,children:e.jsx(qh,{size:14})}),e.jsxs(Wv,{children:[Math.round(o*100),"%"]}),e.jsx(ko,{$variant:"ghost",onClick:()=>g(.25),title:"Zoom in",disabled:o>=3,children:e.jsx(Gh,{size:14})}),e.jsx(ko,{$variant:"ghost",onClick:c,title:"Reset zoom",children:e.jsx(Sh,{size:14})})]}),e.jsxs(Hl,{$variant:"primary",onClick:p,title:"Download image",children:[e.jsx(Qo,{size:14}),"Download"]})]})]})})}),document.body)};function ql({showBackButton:t=!1,onBack:r}){const{agentName:o,token:n,platformAdapter:a,selectedSession:s,selectSession:p}=Uo(),g=s==null?void 0:s.id;if(!g)return e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsx(Ni,{children:e.jsxs(Fi,{children:[e.jsx(jn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:"No conversation selected"})]})})});const c=!0,h=!0,d="Start a conversation by typing a message below",[l,m]=i.useState(""),[x,v]=i.useState(!1),[w,C]=i.useState(null),[$,y]=i.useState([]),[z,_]=i.useState([]),[k,b]=i.useState(null),[f,I]=i.useState(1),[j,S]=i.useState(!1),[R,E]=i.useState({x:0,y:0}),[T,P]=i.useState({x:0,y:0}),O=i.useRef(null),D=i.useRef(null),{messages:M,pendingMessage:N,pendingImages:F,connectionState:J,isConnected:ie,isExecuting:re,executionStatus:X,isWaitingForInput:U,sendMessage:Z,submitUserInput:Q,cancelExecution:ae}=lc({contextId:g,agentName:o,token:n,platformAdapter:a,autoConnect:c});i.useEffect(()=>{var G;(G=O.current)==null||G.scrollIntoView({behavior:"smooth"})},[M]),i.useEffect(()=>{var G;if(U){const ne=M.slice().reverse().find(ye=>{var be;return((be=ye.metadata)==null?void 0:be.type)==="user_input_request"});(G=ne==null?void 0:ne.metadata)!=null&&G.userInputRequest&&C(ne.metadata.userInputRequest)}else C(null),y([])},[U,M]);const oe=G=>{if(G.preventDefault(),!!ie)if(U&&w){let ne=l.trim();w.input_type==="multiselect"&&(ne=$.join(",")),ne&&(Q(ne),m(""),y([]))}else!re&&l.trim()&&(Z(l,z.length>0?z:void 0),m(""),_([]))},ce=G=>{const ne=G.target.files;ne&&(Array.from(ne).forEach(ye=>{if(ye.type.startsWith("image/")){const be=new FileReader;be.onload=te=>{var $e;if(($e=te.target)!=null&&$e.result){const ke=te.target.result.split(",")[1];_(Te=>[...Te,{mime_type:ye.type,data:ke}])}},be.readAsDataURL(ye)}}),D.current&&(D.current.value=""))},Y=G=>{_(ne=>ne.filter((ye,be)=>be!==G))},se=G=>{b(G),I(1),E({x:0,y:0})},q=()=>{b(null),I(1),E({x:0,y:0}),S(!1)},H=G=>{const ne=document.createElement("a");ne.href=G,ne.download=`image-${Date.now()}.png`,document.body.appendChild(ne),ne.click(),document.body.removeChild(ne)},A=G=>{I(ne=>{const ye=ne+G;return Math.min(Math.max(ye,.5),3)})},B=G=>{G.preventDefault(),G.stopPropagation();const ne=G.deltaY>0?-.1:.1;A(ne)},L=G=>{f>1&&(S(!0),P({x:G.clientX-R.x,y:G.clientY-R.y}))},W=G=>{j&&f>1&&E({x:G.clientX-T.x,y:G.clientY-T.y})},ee=()=>{S(!1)},pe=()=>J.status===xt.CONNECTING?"Connecting...":J.status===xt.ERROR?"Connection error":J.status===xt.DISCONNECTED||!ie?"Disconnected":U?"Waiting for your input...":re?"Working...":"Ready",Se=()=>{if(!U||!w)return"Ask anything";switch(w.input_type){case"select":case"boolean":case"date":return"Use controls above to make selection";case"multiselect":return"Select options above";default:return"Enter your response..."}},Ne=()=>!U||!w?!1:["select","multiselect","boolean","date"].includes(w.input_type||"");return e.jsxs(le,{style:{height:"100%",width:"100%"},children:[e.jsxs(Ni,{children:[e.jsxs(pv,{children:[e.jsxs(hv,{children:[t&&e.jsx(fv,{onClick:()=>{r?r():p(null)},children:e.jsx(Ur,{size:20})}),e.jsxs(gv,{children:[e.jsx(mv,{children:e.jsx(jn,{size:20})}),e.jsxs(xv,{children:[e.jsx(bv,{children:o}),e.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[e.jsx(vv,{$status:pe()}),e.jsx(yv,{$status:pe(),children:pe()})]})]})]})]}),X!==Me.IDLE&&e.jsx(wv,{$status:X,children:X.replace("_"," ")})]}),e.jsx(jv,{children:M.length===0&&h?e.jsxs(Fi,{children:[e.jsx(jn,{size:48,strokeWidth:1.5}),e.jsx("p",{children:d})]}):e.jsxs(e.Fragment,{children:[M.map((G,ne)=>{var ye,be,te,$e;if(((ye=G.metadata)==null?void 0:ye.type)==="user_input_request"&&G.metadata.userInputRequest){const fe=G.metadata.userInputRequest,ke=!fe.input_type||fe.input_type==="text"||fe.input_type==="number",Te=U&&(w==null?void 0:w.input_type)===fe.input_type;return e.jsx(Vn,{$isUser:!1,children:e.jsxs(Sv,{children:[e.jsx("div",{className:"question",children:fe.question}),fe.context&&fe.context.trim()&&e.jsx("div",{className:"context",children:fe.context}),!ke&&e.jsxs("div",{className:"controls",children:[fe.input_type==="select"&&fe.options&&e.jsxs("select",{value:Te?l:"",onChange:Ee=>m(Ee.target.value),disabled:!Te,children:[e.jsx("option",{value:"",children:"Choose an option..."}),fe.options.map(Ee=>e.jsx("option",{value:Ee,children:Ee},Ee))]}),fe.input_type==="multiselect"&&fe.options&&e.jsx("div",{className:"checkbox-group",children:fe.options.map(Ee=>e.jsxs("label",{className:"checkbox-label",children:[e.jsx("input",{type:"checkbox",checked:Te&&$.includes(Ee),onChange:or=>{or.target.checked?y([...$,Ee]):y($.filter(nr=>nr!==Ee))},disabled:!Te}),e.jsx("span",{children:Ee})]},Ee))}),fe.input_type==="boolean"&&e.jsxs("div",{className:"radio-group",children:[e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"true",checked:Te&&l==="true",onChange:Ee=>m(Ee.target.value),disabled:!Te}),e.jsx("span",{children:"Yes"})]}),e.jsxs("label",{className:"radio-label",children:[e.jsx("input",{type:"radio",name:"boolean",value:"false",checked:Te&&l==="false",onChange:Ee=>m(Ee.target.value),disabled:!Te}),e.jsx("span",{children:"No"})]})]}),fe.input_type==="date"&&e.jsx("input",{type:"date",value:Te?l:"",onChange:Ee=>m(Ee.target.value),disabled:!Te})]}),e.jsx("div",{className:"instruction",children:Te?ke?"Type your response below":fe.input_type==="multiselect"?"Select options above and click send":"Make your selection above and click send":""})]})},G.id)}if(((be=G.metadata)==null?void 0:be.type)==="log"){const fe=M[ne-1],ke=M[ne+1],Te=((te=fe==null?void 0:fe.metadata)==null?void 0:te.type)==="log",Ee=(($e=ke==null?void 0:ke.metadata)==null?void 0:$e.type)==="log",or=Te||Ee,nr=!Te&&Ee,Vr=Te&&!Ee;return e.jsx(Cv,{$isGrouped:or,$isFirstInGroup:nr,$isLastInGroup:Vr,children:e.jsx("div",{className:"log-content",children:G.content})},G.id)}return!G.content&&(!G.images||G.images.length===0)?null:e.jsx(Vn,{$isUser:G.role==="user",children:e.jsxs(Gl,{$isUser:G.role==="user",children:[e.jsx("div",{children:G.content}),G.images&&G.images.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:G.images.map((fe,ke)=>{const Te=fe.url||`data:${fe.mime_type};base64,${fe.data}`;return e.jsxs(Vv,{onClick:()=>se(Te),title:"Click to preview",children:[e.jsx("img",{src:Te,alt:`Image ${ke+1}`,loading:"lazy"}),e.jsx("div",{className:"expand-icon",children:e.jsx(fh,{size:14})})]},ke)})}),G.isStreaming&&e.jsx(kv,{})]})},G.id)}),N&&e.jsx(Vn,{$isUser:!0,children:e.jsxs(_v,{$isUser:!0,children:[e.jsx("div",{children:N}),F&&F.length>0&&e.jsx("div",{style:{display:"flex",gap:"8px",marginTop:"8px",flexWrap:"wrap"},children:F.map((G,ne)=>e.jsx("div",{style:{width:"200px",height:"200px",borderRadius:"8px",border:"1px solid var(--color-border)",overflow:"hidden",backgroundColor:"var(--color-background-subtle)",position:"relative",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx("img",{src:G.data?`data:${G.mime_type};base64,${G.data}`:"#",alt:`Image ${ne+1}`,style:{maxWidth:"100%",maxHeight:"100%",width:"auto",height:"auto",objectFit:"contain"},loading:"lazy"})},ne))})]})}),e.jsx("div",{ref:O})]})}),z.length>0&&e.jsx(Iv,{children:z.map((G,ne)=>e.jsxs(Tv,{children:[e.jsx("img",{src:G.data?`data:${G.mime_type};base64,${G.data}`:"#",alt:`Upload ${ne+1}`}),e.jsx(Ov,{type:"button",onClick:()=>Y(ne),children:e.jsx(Ke,{size:12})})]},ne))}),e.jsx($v,{onSubmit:oe,children:e.jsxs(zv,{children:[e.jsxs(Ev,{children:[e.jsx(Pv,{value:l,onChange:G=>m(G.target.value),onKeyDown:G=>{G.key==="Enter"&&!G.shiftKey&&(G.preventDefault(),oe(G))},placeholder:Se(),disabled:!ie||re&&!U||Ne(),rows:1}),e.jsx(Rv,{children:e.jsxs(Lv,{type:"button",disabled:!ie||re,onClick:()=>{var G;return(G=D.current)==null?void 0:G.click()},children:[e.jsx(Eh,{size:16}),"Attach"]})}),e.jsx(Mv,{ref:D,type:"file",accept:"image/*",multiple:!0,onChange:ce})]}),e.jsx(Av,{type:re?"button":"submit",disabled:!ie||!U&&!re&&!l.trim(),onClick:re?ae:void 0,onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),style:{background:re&&x?"var(--color-error)":void 0},children:re?x?e.jsx(Ke,{size:14}):e.jsx(vr,{size:14,className:"animate-spin"}):e.jsx(qc,{size:14})})]})})]}),e.jsx(Gv,{isOpen:!!k,imageUrl:k,zoomLevel:f,dragPosition:R,isDragging:j,onClose:q,onDownload:()=>k&&H(k),onZoom:A,onReset:()=>{I(1),E({x:0,y:0})},onWheel:B,onMouseDown:L,onMouseMove:W,onMouseUp:ee})]})}const Hv=u.div`
5482
5482
  height: 100%;
5483
5483
  display: flex;
5484
5484
  flex-direction: column;
@@ -5831,5 +5831,5 @@ See https://s-c.sh/2BAXzed for more info.`),window[Qr]+=1);const le=u.div`
5831
5831
  display: flex;
5832
5832
  flex-direction: column;
5833
5833
  gap: var(--space-xs);
5834
- `;function R2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:a,selectSession:s,createSession:p,setShowHistory:g}=Uo(),c=async()=>{try{r(!0),await p()}finally{r(!1)}},h=d=>{try{const l=new Date(d),x=new Date().getTime()-l.getTime(),v=Math.floor(x/6e4),w=Math.floor(v/60),C=Math.floor(w/24);return C>0?`${C}d ago`:w>0?`${w}h ago`:v>0?`${v}m ago`:"Just now"}catch{return""}};return a?e.jsx(Yl,{showBackButton:!0}):n?e.jsx(ql,{showBackButton:!0}):e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsx(g2,{children:e.jsxs(m2,{children:[e.jsx(x2,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(v2,{children:"Hi there! 👋"}),e.jsx(b2,{children:"How can I help you today?"}),e.jsx(y2,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(w2,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(S2,{children:[e.jsxs($2,{children:[e.jsx(z2,{children:"Recent Chats"}),e.jsx(E2,{onClick:()=>g(!0),children:"View All →"})]}),e.jsx(P2,{children:o.slice(0,2).map(d=>e.jsx(j2,{onClick:()=>s(d),children:e.jsxs(C2,{children:[e.jsx(k2,{children:d.title}),e.jsxs(_2,{children:[e.jsx("span",{children:h(d.last_activity_at)}),d.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},d.id))})]})]})})})}const I2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(a=>r.startsWith(a))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(a=>r.startsWith(a))},T2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=qg;exports.AgentConversation=ql;exports.AgentConversationHistory=Yl;exports.AgentConversationHub=R2;exports.AgentConversationProvider=Id;exports.AuthFormImage=Ae;exports.ChannelSelector=uv;exports.CreateOrganizationForm=rn;exports.CreateWorkspaceDialog=yl;exports.CreateWorkspaceForm=_a;exports.DeploymentInitialized=iu;exports.DeploymentInitializing=cu;exports.DeploymentProvider=Ql;exports.Dialog=we;exports.DialogTrigger=lf;exports.Dropdown=ot;exports.DropdownDivider=tn;exports.DropdownItem=Pe;exports.DropdownItems=nt;exports.DropdownTrigger=at;exports.Form=dt;exports.FormGroup=pe;exports.Input=de;exports.Label=ue;exports.MagicLinkVerification=Fg;exports.ManageAccount=Dl;exports.ManageAccountDialog=Nl;exports.ManageOrganization=xl;exports.ManageWorkspace=jl;exports.ManageWorkspaceDialog=kl;exports.NavigateToSignIn=G1;exports.NavigateToSignUp=H1;exports.NavigationLink=tt;exports.NotificationBell=Wl;exports.NotificationItem=Bl;exports.NotificationPopover=Ul;exports.OAuthProvider=Xi;exports.OTPInput=Rt;exports.OrganizationSwitcher=Cl;exports.PhoneNumberInput=Br;exports.PhoneVerification=ll;exports.ProfileCompletion=ul;exports.RequireActiveTenancy=sv;exports.SSOCallback=Rg;exports.SignInForm=ug;exports.SignUpForm=Vp;exports.SignedIn=E1;exports.SignedInAccounts=V1;exports.SignedOut=P1;exports.SimpleDialog=cf;exports.Spinner=Re;exports.Switch=Ao;exports.TwoFactorMethodSelector=cl;exports.TwoFactorVerification=dl;exports.UserButton=$a;exports.UserControls=z1;exports.WaitlistForm=Sg;exports.clearTokenCache=Qt;exports.fetchChannelCounts=tu;exports.hasIncompleteProfile=Bg;exports.isExternalUrl=I2;exports.isSafeUrl=T2;exports.redirectToProfileCompletion=Ug;exports.useActiveOrganization=Qe;exports.useActiveTenancy=Jd;exports.useActiveWorkspace=Pt;exports.useAgentConversation=lc;exports.useAgentConversationContext=Uo;exports.useChannelCounts=su;exports.useClient=De;exports.useConversationSessions=Ki;exports.useDeployment=ve;exports.useForgotPassword=sc;exports.useInvitation=dc;exports.useMagicLinkParams=ac;exports.useMagicLinkVerification=nc;exports.useNavigation=He;exports.useNotificationStream=ic;exports.useNotifications=cc;exports.useOrganizationList=Wo;exports.useOrganizationMemberships=bt;exports.useSSOCallback=oc;exports.useSession=Fe;exports.useSignIn=Ji;exports.useSignInWithStrategy=Ar;exports.useSignUp=ec;exports.useUser=rr;exports.useUserSignins=tc;exports.useWaitlist=rc;exports.useWorkspaceList=yt;exports.useWorkspaceMemberships=Vo;Object.keys(Ve).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Ve[t]})});
5834
+ `;function R2(){const[t,r]=i.useState(!1),{sessions:o,selectedSession:n,showHistory:a,selectSession:s,createSession:p,setShowHistory:g}=Uo(),c=async()=>{try{r(!0),await p()}finally{r(!1)}},h=d=>{try{const l=new Date(d),x=new Date().getTime()-l.getTime(),v=Math.floor(x/6e4),w=Math.floor(v/60),C=Math.floor(w/24);return C>0?`${C}d ago`:w>0?`${w}h ago`:v>0?`${v}m ago`:"Just now"}catch{return""}};return a?e.jsx(Yl,{showBackButton:!0}):n?e.jsx(ql,{showBackButton:!0}):e.jsx(le,{style:{height:"100%",width:"100%"},children:e.jsx(g2,{children:e.jsxs(m2,{children:[e.jsx(x2,{children:e.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5,d:"M8 12h.01M12 12h.01M16 12h.01M21 12c0 4.418-4.03 8-9 8a9.863 9.863 0 01-4.255-.949L3 20l1.395-3.72C3.512 15.042 3 13.574 3 12c0-4.418 4.03-8 9-8s9 3.582 9 8z"})})}),e.jsx(v2,{children:"Hi there! 👋"}),e.jsx(b2,{children:"How can I help you today?"}),e.jsx(y2,{onClick:c,disabled:t,children:t?e.jsxs(e.Fragment,{children:["Starting",e.jsx(w2,{})]}):"Start a conversation"}),o.length>0&&e.jsxs(S2,{children:[e.jsxs($2,{children:[e.jsx(z2,{children:"Recent Chats"}),e.jsx(E2,{onClick:()=>g(!0),children:"View All →"})]}),e.jsx(P2,{children:o.slice(0,2).map(d=>e.jsx(j2,{onClick:()=>s(d),children:e.jsxs(C2,{children:[e.jsx(k2,{children:d.title}),e.jsxs(_2,{children:[e.jsx("span",{children:h(d.last_activity_at)}),d.status==="running"&&e.jsx("span",{children:"• Active"})]})]})},d.id))})]})]})})})}const I2=t=>{const r=t.toLowerCase().trim();return["javascript:","data:","vbscript:"].some(a=>r.startsWith(a))?!0:["http://","https://","//","ftp://","ftps://","mailto:","tel:","sms:","file:","blob:"].some(a=>r.startsWith(a))},T2=t=>{const r=t.toLowerCase().trim();return!["javascript:","data:","vbscript:"].some(n=>r.startsWith(n))};exports.AcceptInvite=qg;exports.AgentConversation=ql;exports.AgentConversationHistory=Yl;exports.AgentConversationHub=R2;exports.AgentConversationProvider=Id;exports.AuthFormImage=Ae;exports.ChannelSelector=uv;exports.CreateOrganizationForm=rn;exports.CreateWorkspaceDialog=yl;exports.CreateWorkspaceForm=_a;exports.DeploymentInitialized=iu;exports.DeploymentInitializing=cu;exports.DeploymentProvider=Ql;exports.Dialog=we;exports.DialogTrigger=lf;exports.Dropdown=ot;exports.DropdownDivider=tn;exports.DropdownItem=Pe;exports.DropdownItems=nt;exports.DropdownTrigger=at;exports.Form=dt;exports.FormGroup=he;exports.Input=de;exports.Label=ue;exports.MagicLinkVerification=Fg;exports.ManageAccount=Dl;exports.ManageAccountDialog=Nl;exports.ManageOrganization=xl;exports.ManageWorkspace=jl;exports.ManageWorkspaceDialog=kl;exports.NavigateToSignIn=G1;exports.NavigateToSignUp=H1;exports.NavigationLink=tt;exports.NotificationBell=Wl;exports.NotificationItem=Bl;exports.NotificationPopover=Ul;exports.OAuthProvider=Xi;exports.OTPInput=Rt;exports.OrganizationSwitcher=Cl;exports.PhoneNumberInput=Br;exports.PhoneVerification=ll;exports.ProfileCompletion=ul;exports.RequireActiveTenancy=sv;exports.SSOCallback=Rg;exports.SignInForm=ug;exports.SignUpForm=Vp;exports.SignedIn=E1;exports.SignedInAccounts=V1;exports.SignedOut=P1;exports.SimpleDialog=cf;exports.Spinner=Re;exports.Switch=Ao;exports.TwoFactorMethodSelector=cl;exports.TwoFactorVerification=dl;exports.UserButton=$a;exports.UserControls=z1;exports.WaitlistForm=Sg;exports.clearTokenCache=Qt;exports.fetchChannelCounts=tu;exports.hasIncompleteProfile=Bg;exports.isExternalUrl=I2;exports.isSafeUrl=T2;exports.redirectToProfileCompletion=Ug;exports.useActiveOrganization=Qe;exports.useActiveTenancy=Jd;exports.useActiveWorkspace=Pt;exports.useAgentConversation=lc;exports.useAgentConversationContext=Uo;exports.useChannelCounts=su;exports.useClient=De;exports.useConversationSessions=Ki;exports.useDeployment=ve;exports.useForgotPassword=sc;exports.useInvitation=dc;exports.useMagicLinkParams=ac;exports.useMagicLinkVerification=nc;exports.useNavigation=He;exports.useNotificationStream=ic;exports.useNotifications=cc;exports.useOrganizationList=Wo;exports.useOrganizationMemberships=bt;exports.useSSOCallback=oc;exports.useSession=Fe;exports.useSignIn=Ji;exports.useSignInWithStrategy=Ar;exports.useSignUp=ec;exports.useUser=rr;exports.useUserSignins=tc;exports.useWaitlist=rc;exports.useWorkspaceList=yt;exports.useWorkspaceMemberships=Vo;Object.keys(Ve).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>Ve[t]})});
5835
5835
  //# sourceMappingURL=index.cjs.js.map