@wacht/jsx 0.0.1-alpha.57 → 0.0.1-alpha.58
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 +55 -55
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.es.js +775 -775
- package/dist/index.es.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),Ko=require("react-dom"),ts=require("@wacht/types"),gc=i.createContext(void 0);function _d({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[a,s]=i.useState(!0),[p,f]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function l(){if(!c.current)try{c.current=!0,s(!0);const[u,m,v]=r.split("_");if(!v)throw new Error("Invalid public key");let x=atob(v),y=m==="test",S=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){S=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",S??"");const w=new URL(window.location.href);w.searchParams.delete("__dev_session__"),window.history.replaceState({},"",w.toString())}else S=localStorage.getItem("__dev_session__");let k={};const z=new URLSearchParams;y?z.append("__dev_session__",S??""):k={credentials:"include"};const _=await fetch(`${x}/deployment${y?"?":""}${z.toString()}`,k);if(!_.ok){s(!1);return}const $=await _.json();$.data.backend_host=x,n&&($.data.ui_settings={...$.data.ui_settings,...n}),f($.data),y&&_.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",_.headers.get("x-development-session")??""),s(!1)}catch(u){console.error("Failed to initialize deployment:",u)}}l()},[r]);const d=i.useMemo(()=>({loading:a,deployment:p,adapter:o}),[a,p,o]);return e.jsx(gc.Provider,{value:d,children:t})}async function N(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}return{data:(await t.json()).data}}function xe(){const t=i.useContext(gc);if(t===void 0)throw new Error("useDeployment must be used within a DeploymentProvider");if(!t.loading&&!t.deployment)throw new Error("Deployment is not loaded");return t}function Ne(){const{deployment:t,loading:r}=xe();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,a)=>{const s=kd(t),p=new Headers(s.headers);a!=null&&a.headers&&new Headers(a.headers).forEach((l,u)=>{p.set(u,l)});const f=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&f.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(f,{...s,...a,headers:p});return t.mode==="staging"&&c.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",c.headers.get("x-development-session")??""),c},loading:r}}function kd(t){return t.mode==="staging"?{}:{credentials:"include"}}var mc=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(mc||{});function Cd(t,r){const o={username:Sd(t,r),email:zd(t,r),phone:Ed(t,r),email_otp:$d(t,r),magic_link:Pd(t,r),oauth:Rd(t),passkey:Id(t),generic:Td(t,r)};return function(a){return o[a]}}function Sd(t,r){return async({username:o,password:n})=>{var f,c;const a=new FormData;a.append("strategy","plain_username"),a.append("username",o),a.append("password",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await N(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function zd(t,r){return async({email:o,password:n})=>{var f,c;const a=new FormData;a.append("strategy","plain_email"),a.append("email",o),a.append("password",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await N(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function Ed(t,r){return async({phone:o})=>{var p,f;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const a=await t("/auth/signin",{method:"POST",body:n}),s=await N(a);return"data"in s&&((f=(p=s.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function $d(t,r){return async({email:o})=>{var p,f;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const a=await t("/auth/signin",{method:"POST",body:n}),s=await N(a);return"data"in s&&((f=(p=s.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Pd(t,r){return async({email:o})=>{var p,f;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const a=await t("/auth/signin",{method:"POST",body:n}),s=await N(a);return"data"in s&&((f=(p=s.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Rd(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const a=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),s=await N(a);return"data"in s&&s.data.oauth_url&&(window.location.href=s.data.oauth_url),s}}function Tr(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function rs(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);return a.buffer}function Id(t){return async()=>{var d;const r=await t("/auth/passkey/login/begin",{method:"POST"}),o=await N(r);if(!("data"in o))return o;const n=o.data.options.publicKey,a={challenge:rs(n.challenge),timeout:n.timeout,rpId:n.rpId,userVerification:n.userVerification,allowCredentials:(d=n.allowCredentials)==null?void 0:d.map(l=>({type:l.type,id:rs(l.id),transports:l.transports}))};let s;try{const l=await navigator.credentials.get({publicKey:a});if(!l)throw new Error("Failed to get credential");s=l}catch(l){throw l.name==="NotAllowedError"?new Error("No passkey found on this device. Please try a different sign-in method."):l.name==="AbortError"?new Error("Passkey sign-in was cancelled."):l}const p=s.response,f=new FormData;f.append("id",s.id),f.append("rawId",Tr(s.rawId)),f.append("type",s.type),f.append("clientDataJSON",Tr(p.clientDataJSON)),f.append("authenticatorData",Tr(p.authenticatorData)),f.append("signature",Tr(p.signature)),p.userHandle&&f.append("userHandle",Tr(p.userHandle));const c=await t("/auth/passkey/login/finish",{method:"POST",body:f});return N(c)}}function Td(t,r){return async({email:o,username:n,password:a,phone:s,strategy:p,token:f})=>{var u,m;const c=new FormData;p&&c.append("strategy",p),o&&c.append("email",o),n&&c.append("username",n),a&&c.append("password",a),s&&c.append("phone",s),f&&c.append("token",f);const d=await t("/auth/signin",{method:"POST",body:c}),l=await N(d);return"data"in l&&((m=(u=l.data)==null?void 0:u.signin_attempts)!=null&&m.length)&&r(l.data.signin_attempts.at(-1)||null),l}}function xc(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Cd(t,n),completeVerification:async a=>{var c,d;const s=new FormData;s.append("verification_code",a);const p=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:s}),f=await N(p);if("data"in f&&((d=(c=f.data)==null?void 0:c.signin_attempts)!=null&&d.length)){const l=f.data.signin_attempts.at(-1);return n(l||null),f.data}else throw new Error("Verification failed")},prepareVerification:async a=>{var f;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((f=o==null?void 0:o.id)==null?void 0:f.toString())||""),s.searchParams.set("strategy",a.strategy),s.searchParams.set("identifier_type","signin"),a.strategy==="phone_otp"&&a.lastDigits?s.searchParams.set("last_digits",a.lastDigits):(a.strategy==="email_otp"&&a.redirectUri||a.strategy==="magic_link"&&a.redirectUri)&&s.searchParams.set("redirect_uri",a.redirectUri);const p=await t(s.pathname+s.search,{method:"POST"});return N(p)},completeProfile:async a=>{var c;if(!o)throw new Error("No signin attempt found");const s=new FormData;for(const[d,l]of Object.entries(a))l&&s.append(d,l);const p=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:s}),f=await N(p);if("data"in f&&f.data){const d=(c=f.data.signin_attempts)==null?void 0:c.find(l=>l.id===o.id);return d&&n(d),f.data}else throw new Error("Profile completion failed")},identify:async a=>{const s=new FormData;s.append("identifier",a);const p=await t("/auth/identify",{method:"POST",body:s});return(await N(p)).data},initEnterpriseSso:async(a,s)=>{const p=new URLSearchParams({connection_id:a});s&&p.append("redirect_uri",s);const f=await t(`/auth/sso/login?${p.toString()}`,{method:"POST"});return(await N(f)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function jr(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:a,setSignInAttempt:s}=xc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:a,setSignInAttempt:s};const p=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"passkey":return o.createStrategy("passkey");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:p,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:a,setSignInAttempt:s}}function Od(t,r,o){return{create:async n=>{var f,c,d;const a=new FormData;for(const[l,u]of Object.entries(n))a.append(l,u);const s=await t("/auth/signup",{method:"POST",body:a}),p=await N(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(((d=p.data.signup_attempts)==null?void 0:d.at(-1))||null),p},prepareVerification:async n=>{var p;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((p=r==null?void 0:r.id)==null?void 0:p.toString())||""),a.searchParams.set("strategy",n.strategy),a.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?a.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&a.searchParams.set("redirect_uri",n.redirectUri);const s=await t(a.pathname+a.search,{method:"POST"});return N(s)},completeVerification:async n=>{var f,c;const a=new FormData;a.append("verification_code",n);const s=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:a}),p=await N(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(p.data.signup_attempts.at(-1)||null),p},validateDeploymentInvitation:async n=>{try{const a=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),s=await N(a);return"data"in s&&s.data?s.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(a){return{valid:!1,message:a.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function vc(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:Od(t,o,n)}}var Xr={exports:{}},un={};/**
|
|
2
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("react"),Ko=require("react-dom"),ts=require("@wacht/types"),gc=i.createContext(void 0);function _d({children:t,publicKey:r,adapter:o,uiOverwrites:n}){const[a,s]=i.useState(!0),[p,f]=i.useState(null),c=i.useRef(!1);i.useEffect(()=>{async function l(){if(!c.current)try{c.current=!0,s(!0);const[u,m,v]=r.split("_");if(!v)throw new Error("Invalid public key");let x=atob(v),y=m==="test",k=null;if(new URLSearchParams(window.location.search).has("__dev_session__")){k=new URLSearchParams(window.location.search).get("__dev_session__"),localStorage.setItem("__dev_session__",k??"");const w=new URL(window.location.href);w.searchParams.delete("__dev_session__"),window.history.replaceState({},"",w.toString())}else k=localStorage.getItem("__dev_session__");let z={};const S=new URLSearchParams;y?S.append("__dev_session__",k??""):z={credentials:"include"};const _=await fetch(`${x}/deployment${y?"?":""}${S.toString()}`,z);if(!_.ok){s(!1);return}const $=await _.json();$.data.backend_host=x,n&&($.data.ui_settings={...$.data.ui_settings,...n}),f($.data),y&&_.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",_.headers.get("x-development-session")??""),s(!1)}catch(u){console.error("Failed to initialize deployment:",u)}}l()},[r]);const d=i.useMemo(()=>({loading:a,deployment:p,adapter:o}),[a,p,o]);return e.jsx(gc.Provider,{value:d,children:t})}async function N(t){if(!t.ok){let o=`HTTP ${t.status}: ${t.statusText}`;try{const n=await t.json();n.message?o=n.message:n.errors&&n.errors.length>0&&(o=n.errors[0].message||o)}catch{}throw new Error(o)}return{data:(await t.json()).data}}function xe(){const t=i.useContext(gc);if(t===void 0)throw new Error("useDeployment must be used within a DeploymentProvider");if(!t.loading&&!t.deployment)throw new Error("Deployment is not loaded");return t}function Ne(){const{deployment:t,loading:r}=xe();return r||!t?{client:()=>Promise.reject(new Error("Deployment is loading")),loading:r}:{client:async(n,a)=>{const s=kd(t),p=new Headers(s.headers);a!=null&&a.headers&&new Headers(a.headers).forEach((l,u)=>{p.set(u,l)});const f=new URL(`${t.backend_host??""}${n}`);t.mode==="staging"&&f.searchParams.append("__dev_session__",localStorage.getItem("__dev_session__")??"");const c=await fetch(f,{...s,...a,headers:p});return t.mode==="staging"&&c.headers.get("x-development-session")&&localStorage.setItem("__dev_session__",c.headers.get("x-development-session")??""),c},loading:r}}function kd(t){return t.mode==="staging"?{}:{credentials:"include"}}var mc=(t=>(t.XOauth="x_oauth",t.GithubOauth="github_oauth",t.GitlabOauth="gitlab_oauth",t.GoogleOauth="google_oauth",t.FacebookOauth="facebook_oauth",t.MicrosoftOauth="microsoft_oauth",t.LinkedinOauth="linkedin_oauth",t.DiscordOauth="discord_oauth",t.AppleOauth="apple_oauth",t))(mc||{});function Cd(t,r){const o={username:Sd(t,r),email:zd(t,r),phone:Ed(t,r),email_otp:$d(t,r),magic_link:Pd(t,r),oauth:Rd(t),passkey:Id(t),generic:Td(t,r)};return function(a){return o[a]}}function Sd(t,r){return async({username:o,password:n})=>{var f,c;const a=new FormData;a.append("strategy","plain_username"),a.append("username",o),a.append("password",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await N(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function zd(t,r){return async({email:o,password:n})=>{var f,c;const a=new FormData;a.append("strategy","plain_email"),a.append("email",o),a.append("password",n);const s=await t("/auth/signin",{method:"POST",body:a}),p=await N(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signin_attempts)!=null&&c.length)&&r(p.data.signin_attempts.at(-1)||null),p}}function Ed(t,r){return async({phone:o})=>{var p,f;const n=new FormData;n.append("strategy","phone_otp"),n.append("phone",o);const a=await t("/auth/signin",{method:"POST",body:n}),s=await N(a);return"data"in s&&((f=(p=s.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function $d(t,r){return async({email:o})=>{var p,f;const n=new FormData;n.append("strategy","email_otp"),n.append("email",o);const a=await t("/auth/signin",{method:"POST",body:n}),s=await N(a);return"data"in s&&((f=(p=s.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Pd(t,r){return async({email:o})=>{var p,f;const n=new FormData;n.append("strategy","magic_link"),n.append("email",o);const a=await t("/auth/signin",{method:"POST",body:n}),s=await N(a);return"data"in s&&((f=(p=s.data)==null?void 0:p.signin_attempts)!=null&&f.length)&&r(s.data.signin_attempts.at(-1)||null),s}}function Rd(t){return async({provider:r,redirectUri:o})=>{const n=new URLSearchParams({provider:r});o&&n.append("redirect_uri",o);const a=await t(`/auth/oauth2/init?${n.toString()}`,{method:"POST"}),s=await N(a);return"data"in s&&s.data.oauth_url&&(window.location.href=s.data.oauth_url),s}}function Tr(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function rs(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);return a.buffer}function Id(t){return async()=>{var d;const r=await t("/auth/passkey/login/begin",{method:"POST"}),o=await N(r);if(!("data"in o))return o;const n=o.data.options.publicKey,a={challenge:rs(n.challenge),timeout:n.timeout,rpId:n.rpId,userVerification:n.userVerification,allowCredentials:(d=n.allowCredentials)==null?void 0:d.map(l=>({type:l.type,id:rs(l.id),transports:l.transports}))};let s;try{const l=await navigator.credentials.get({publicKey:a});if(!l)throw new Error("Failed to get credential");s=l}catch(l){throw l.name==="NotAllowedError"?new Error("No passkey found on this device. Please try a different sign-in method."):l.name==="AbortError"?new Error("Passkey sign-in was cancelled."):l}const p=s.response,f=new FormData;f.append("id",s.id),f.append("rawId",Tr(s.rawId)),f.append("type",s.type),f.append("clientDataJSON",Tr(p.clientDataJSON)),f.append("authenticatorData",Tr(p.authenticatorData)),f.append("signature",Tr(p.signature)),p.userHandle&&f.append("userHandle",Tr(p.userHandle));const c=await t("/auth/passkey/login/finish",{method:"POST",body:f});return N(c)}}function Td(t,r){return async({email:o,username:n,password:a,phone:s,strategy:p,token:f})=>{var u,m;const c=new FormData;p&&c.append("strategy",p),o&&c.append("email",o),n&&c.append("username",n),a&&c.append("password",a),s&&c.append("phone",s),f&&c.append("token",f);const d=await t("/auth/signin",{method:"POST",body:c}),l=await N(d);return"data"in l&&((m=(u=l.data)==null?void 0:u.signin_attempts)!=null&&m.length)&&r(l.data.signin_attempts.at(-1)||null),l}}function xc(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(null);return r?{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}:{loading:!1,signinAttempt:o,signIn:{createStrategy:Cd(t,n),completeVerification:async a=>{var c,d;const s=new FormData;s.append("verification_code",a);const p=await t(`/auth/attempt-verification?attempt_identifier=${o==null?void 0:o.id}&identifier_type=signin`,{method:"POST",body:s}),f=await N(p);if("data"in f&&((d=(c=f.data)==null?void 0:c.signin_attempts)!=null&&d.length)){const l=f.data.signin_attempts.at(-1);return n(l||null),f.data}else throw new Error("Verification failed")},prepareVerification:async a=>{var f;const s=new URL("/auth/prepare-verification",window.location.origin);s.searchParams.set("attempt_identifier",((f=o==null?void 0:o.id)==null?void 0:f.toString())||""),s.searchParams.set("strategy",a.strategy),s.searchParams.set("identifier_type","signin"),a.strategy==="phone_otp"&&a.lastDigits?s.searchParams.set("last_digits",a.lastDigits):(a.strategy==="email_otp"&&a.redirectUri||a.strategy==="magic_link"&&a.redirectUri)&&s.searchParams.set("redirect_uri",a.redirectUri);const p=await t(s.pathname+s.search,{method:"POST"});return N(p)},completeProfile:async a=>{var c;if(!o)throw new Error("No signin attempt found");const s=new FormData;for(const[d,l]of Object.entries(a))l&&s.append(d,l);const p=await t(`/auth/complete-profile?attempt_id=${o.id}`,{method:"POST",body:s}),f=await N(p);if("data"in f&&f.data){const d=(c=f.data.signin_attempts)==null?void 0:c.find(l=>l.id===o.id);return d&&n(d),f.data}else throw new Error("Profile completion failed")},identify:async a=>{const s=new FormData;s.append("identifier",a);const p=await t("/auth/identify",{method:"POST",body:s});return(await N(p)).data},initEnterpriseSso:async(a,s)=>{const p=new URLSearchParams({connection_id:a});s&&p.append("redirect_uri",s);const f=await t(`/auth/sso/login?${p.toString()}`,{method:"POST"});return(await N(f)).data}},discardSignInAttempt:()=>{n(null)},setSignInAttempt:n}}function jr(t){const{loading:r,signIn:o,signinAttempt:n,discardSignInAttempt:a,setSignInAttempt:s}=xc();if(r)return{loading:!0,signIn:null,signinAttempt:null,discardSignInAttempt:a,setSignInAttempt:s};const p=(()=>{switch(t){case"username":return o.createStrategy("username");case"email":return o.createStrategy("email");case"phone":return o.createStrategy("phone");case"email_otp":return o.createStrategy("email_otp");case"magic_link":return o.createStrategy("magic_link");case"oauth":return o.createStrategy("oauth");case"passkey":return o.createStrategy("passkey");case"generic":return o.createStrategy("generic");default:throw new Error("Invalid sign-in strategy")}})();return{loading:!1,signinAttempt:n,signIn:{create:p,completeVerification:o.completeVerification,prepareVerification:o.prepareVerification,completeProfile:o.completeProfile,identify:o.identify,initEnterpriseSso:o.initEnterpriseSso},discardSignInAttempt:a,setSignInAttempt:s}}function Od(t,r,o){return{create:async n=>{var f,c,d;const a=new FormData;for(const[l,u]of Object.entries(n))a.append(l,u);const s=await t("/auth/signup",{method:"POST",body:a}),p=await N(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(((d=p.data.signup_attempts)==null?void 0:d.at(-1))||null),p},prepareVerification:async n=>{var p;const a=new URL("/auth/prepare-verification",window.location.origin);a.searchParams.set("attempt_identifier",((p=r==null?void 0:r.id)==null?void 0:p.toString())||""),a.searchParams.set("strategy",n.strategy),a.searchParams.set("identifier_type","signup"),n.strategy==="phone_otp"&&n.lastDigits?a.searchParams.set("last_digits",n.lastDigits):n.strategy==="email_otp"&&n.redirectUri&&a.searchParams.set("redirect_uri",n.redirectUri);const s=await t(a.pathname+a.search,{method:"POST"});return N(s)},completeVerification:async n=>{var f,c;const a=new FormData;a.append("verification_code",n);const s=await t(`/auth/attempt-verification?attempt_identifier=${r==null?void 0:r.id}&identifier_type=signup`,{method:"POST",body:a}),p=await N(s);return"data"in p&&((c=(f=p.data)==null?void 0:f.signup_attempts)!=null&&c.length)&&o(p.data.signup_attempts.at(-1)||null),p},validateDeploymentInvitation:async n=>{try{const a=await t(`/deployment/invitations/validate?token=${encodeURIComponent(n)}`,{method:"GET"}),s=await N(a);return"data"in s&&s.data?s.data:{valid:!1,message:"Failed to validate invitation",error_code:"VALIDATION_ERROR"}}catch(a){return{valid:!1,message:a.message||"Failed to validate invitation",error_code:"NETWORK_ERROR"}}}}}function vc(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(null);return r?{loading:!0,signUp:null,signupAttempt:null,discardSignupAttempt:()=>{n(null)}}:{loading:!1,signupAttempt:o,discardSignupAttempt:()=>{n(null)},signUp:Od(t,o,n)}}var Xr={exports:{}},un={};/**
|
|
3
3
|
* @license React
|
|
4
4
|
* use-sync-external-store-shim.production.js
|
|
5
5
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* This source code is licensed under the MIT license found in the
|
|
9
9
|
* LICENSE file in the root directory of this source tree.
|
|
10
|
-
*/var os;function Md(){if(os)return un;os=1;var t=i;function r(u,m){return u===m&&(u!==0||1/u===1/m)||u!==u&&m!==m}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,a=t.useEffect,s=t.useLayoutEffect,p=t.useDebugValue;function f(u,m){var v=m(),x=n({inst:{value:v,getSnapshot:m}}),y=x[0].inst,
|
|
10
|
+
*/var os;function Md(){if(os)return un;os=1;var t=i;function r(u,m){return u===m&&(u!==0||1/u===1/m)||u!==u&&m!==m}var o=typeof Object.is=="function"?Object.is:r,n=t.useState,a=t.useEffect,s=t.useLayoutEffect,p=t.useDebugValue;function f(u,m){var v=m(),x=n({inst:{value:v,getSnapshot:m}}),y=x[0].inst,k=x[1];return s(function(){y.value=v,y.getSnapshot=m,c(y)&&k({inst:y})},[u,v,m]),a(function(){return c(y)&&k({inst:y}),u(function(){c(y)&&k({inst:y})})},[u]),p(v),v}function c(u){var m=u.getSnapshot;u=u.value;try{var v=m();return!o(u,v)}catch{return!0}}function d(u,m){return m()}var l=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:f;return un.useSyncExternalStore=t.useSyncExternalStore!==void 0?t.useSyncExternalStore:l,un}var pn={};/**
|
|
11
11
|
* @license React
|
|
12
12
|
* use-sync-external-store-shim.development.js
|
|
13
13
|
*
|
|
@@ -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 ns;function Ad(){return ns||(ns=1,process.env.NODE_ENV!=="production"&&function(){function t(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}function r(v,x){l||a.startTransition===void 0||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var y=x();if(!u){var S=x();s(y,S)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}S=p({inst:{value:y,getSnapshot:x}});var k=S[0].inst,z=S[1];return c(function(){k.value=y,k.getSnapshot=x,o(k)&&z({inst:k})},[v,y,x]),f(function(){return o(k)&&z({inst:k}),v(function(){o(k)&&z({inst:k})})},[v]),d(y),y}function o(v){var x=v.getSnapshot;v=v.value;try{var y=x();return!s(v,y)}catch{return!0}}function n(v,x){return x()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=i,s=typeof Object.is=="function"?Object.is:t,p=a.useState,f=a.useEffect,c=a.useLayoutEffect,d=a.useDebugValue,l=!1,u=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;pn.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())}()),pn}var as;function Ld(){return as||(as=1,process.env.NODE_ENV==="production"?Xr.exports=Md():Xr.exports=Ad()),Xr.exports}var Dd=Ld();const yc=0,bc=1,wc=2,ss=3;var is=Object.prototype.hasOwnProperty;function Qn(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&Qn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(is.call(t,o)&&++n&&!is.call(r,o)||!(o in r)||!Qn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const Ct=new WeakMap,Tt=()=>{},Xe=Tt(),Jn=Object,ze=t=>t===Xe,pt=t=>typeof t=="function",Mt=(t,r)=>({...t,...r}),jc=t=>pt(t.then),hn={},eo={},wa="undefined",Yr=typeof window!=wa,Xn=typeof document!=wa,Fd=Yr&&"Deno"in window,Nd=()=>Yr&&typeof window.requestAnimationFrame!=wa,_c=(t,r)=>{const o=Ct.get(t);return[()=>!ze(r)&&t.get(r)||hn,n=>{if(!ze(r)){const a=t.get(r);r in eo||(eo[r]=a),o[5](r,Mt(a,n),a||hn)}},o[6],()=>!ze(r)&&r in eo?eo[r]:!ze(r)&&t.get(r)||hn]};let ea=!0;const Bd=()=>ea,[ta,ra]=Yr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Tt,Tt],Ud=()=>{const t=Xn&&document.visibilityState;return ze(t)||t!=="hidden"},Wd=t=>(Xn&&document.addEventListener("visibilitychange",t),ta("focus",t),()=>{Xn&&document.removeEventListener("visibilitychange",t),ra("focus",t)}),Vd=t=>{const r=()=>{ea=!0,t()},o=()=>{ea=!1};return ta("online",r),ta("offline",o),()=>{ra("online",r),ra("offline",o)}},Gd={isOnline:Bd,isVisible:Ud},Hd={initFocus:Wd,initReconnect:Vd},cs=!i.useId,Hr=!Yr||Fd,qd=t=>Nd()?window.requestAnimationFrame(t):setTimeout(t,1),fn=Hr?i.useEffect:i.useLayoutEffect,gn=typeof navigator<"u"&&navigator.connection,ls=!Hr&&gn&&(["slow-2g","2g"].includes(gn.effectiveType)||gn.saveData),to=new WeakMap,Yd=t=>Jn.prototype.toString.call(t),mn=(t,r)=>t===`[object ${r}]`;let Zd=0;const oa=t=>{const r=typeof t,o=Yd(t),n=mn(o,"Date"),a=mn(o,"RegExp"),s=mn(o,"Object");let p,f;if(Jn(t)===t&&!n&&!a){if(p=to.get(t),p)return p;if(p=++Zd+"~",to.set(t,p),Array.isArray(t)){for(p="@",f=0;f<t.length;f++)p+=oa(t[f])+",";to.set(t,p)}if(s){p="#";const c=Jn.keys(t).sort();for(;!ze(f=c.pop());)ze(t[f])||(p+=f+":"+oa(t[f])+",");to.set(t,p)}}else p=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return p},ja=t=>{if(pt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?oa(t):"",[t,r]};let Kd=0;const na=()=>++Kd;async function kc(...t){const[r,o,n,a]=t,s=Mt({populateCache:!0,throwOnError:!0},typeof a=="boolean"?{revalidate:a}:a||{});let p=s.populateCache;const f=s.rollbackOnError;let c=s.optimisticData;const d=m=>typeof f=="function"?f(m):f!==!1,l=s.throwOnError;if(pt(o)){const m=o,v=[],x=r.keys();for(const y of x)!/^\$(inf|sub)\$/.test(y)&&m(r.get(y)._k)&&v.push(y);return Promise.all(v.map(u))}return u(o);async function u(m){const[v]=ja(m);if(!v)return;const[x,y]=_c(r,v),[S,k,z,_]=Ct.get(r),$=()=>{const P=S[v];return(pt(s.revalidate)?s.revalidate(x().data,m):s.revalidate!==!1)&&(delete z[v],delete _[v],P&&P[0])?P[0](wc).then(()=>x().data):x().data};if(t.length<3)return $();let w=n,b,g=!1;const C=na();k[v]=[C,0];const E=!ze(c),j=x(),T=j.data,I=j._c,O=ze(I)?T:I;if(E&&(c=pt(c)?c(O,T):c,y({data:c,_c:O})),pt(w))try{w=w(O)}catch(P){b=P,g=!0}if(w&&jc(w))if(w=await w.catch(P=>{b=P,g=!0}),C!==k[v][0]){if(g)throw b;return w}else g&&E&&d(b)&&(p=!0,y({data:O,_c:Xe}));if(p&&!g)if(pt(p)){const P=p(w,O);y({data:P,error:Xe,_c:Xe})}else y({data:w,error:Xe,_c:Xe});if(k[v][1]=na(),Promise.resolve($()).then(()=>{y({_c:Xe})}),g){if(l)throw b;return}return w}}const ds=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},Qd=(t,r)=>{if(!Ct.has(t)){const o=Mt(Hd,r),n=Object.create(null),a=kc.bind(Xe,t);let s=Tt;const p=Object.create(null),f=(l,u)=>{const m=p[l]||[];return p[l]=m,m.push(u),()=>m.splice(m.indexOf(u),1)},c=(l,u,m)=>{t.set(l,u);const v=p[l];if(v)for(const x of v)x(u,m)},d=()=>{if(!Ct.has(t)&&(Ct.set(t,[n,Object.create(null),Object.create(null),Object.create(null),a,c,f]),!Hr)){const l=o.initFocus(setTimeout.bind(Xe,ds.bind(Xe,n,yc))),u=o.initReconnect(setTimeout.bind(Xe,ds.bind(Xe,n,bc)));s=()=>{l&&l(),u&&u(),Ct.delete(t)}}};return d(),[t,a,d,s]}return[t,Ct.get(t)[4]]},Jd=(t,r,o,n,a)=>{const s=o.errorRetryCount,p=a.retryCount,f=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!ze(s)&&p>s||setTimeout(n,f,a)},Xd=Qn,[Cc,Nr]=Qd(new Map),eu=Mt({onLoadingSlow:Tt,onSuccess:Tt,onError:Tt,onErrorRetry:Jd,onDiscarded:Tt,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:ls?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:ls?5e3:3e3,compare:Xd,isPaused:()=>!1,cache:Cc,mutate:Nr,fallback:{}},Gd),tu=(t,r)=>{const o=Mt(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=Mt(a,p))}return o},ru=i.createContext({}),ou="$inf$",Sc=Yr&&window.__SWR_DEVTOOLS_USE__,nu=Sc?window.__SWR_DEVTOOLS_USE__:[],au=()=>{Sc&&(window.__SWR_DEVTOOLS_REACT__=i)},su=t=>pt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],zc=()=>Mt(eu,i.useContext(ru)),iu=t=>(r,o,n)=>t(r,o&&((...s)=>{const[p]=ja(r),[,,,f]=Ct.get(Cc);if(p.startsWith(ou))return o(...s);const c=f[p];return ze(c)?o(...s):(delete f[p],c)}),n),cu=nu.concat(iu),lu=t=>function(...o){const n=zc(),[a,s,p]=su(o),f=tu(n,p);let c=t;const{use:d}=f,l=(d||[]).concat(cu);for(let u=l.length;u--;)c=l[u](c);return c(a,s||f.fetcher||null,f)},du=(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())}};au();const xn=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}}),vn={dedupe:!0},uu=(t,r,o)=>{const{cache:n,compare:a,suspense:s,fallbackData:p,revalidateOnMount:f,revalidateIfStale:c,refreshInterval:d,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:m}=o,[v,x,y,S]=Ct.get(n),[k,z]=ja(t),_=i.useRef(!1),$=i.useRef(!1),w=i.useRef(k),b=i.useRef(r),g=i.useRef(o),C=()=>g.current,E=()=>C().isVisible()&&C().isOnline(),[j,T,I,O]=_c(n,k),P=i.useRef({}).current,M=ze(p)?ze(o.fallback)?Xe:o.fallback[k]:p,F=(Z,X)=>{for(const ee in P){const te=ee;if(te==="data"){if(!a(Z[te],X[te])&&(!ze(Z[te])||!a(K,X[te])))return!1}else if(X[te]!==Z[te])return!1}return!0},D=i.useMemo(()=>{const Z=!k||!r?!1:ze(f)?C().isPaused()||s?!1:c!==!1:f,X=le=>{const q=Mt(le);return delete q._k,Z?{isValidating:!0,isLoading:!0,...q}:q},ee=j(),te=O(),W=X(ee),Y=ee===te?W:X(te);let se=W;return[()=>{const le=X(j());return F(le,se)?(se.data=le.data,se.isLoading=le.isLoading,se.isValidating=le.isValidating,se.error=le.error,se):(se=le,le)},()=>Y]},[n,k]),L=Dd.useSyncExternalStore(i.useCallback(Z=>I(k,(X,ee)=>{F(ee,X)||Z()}),[n,k]),D[0],D[1]),R=!_.current,A=v[k]&&v[k].length>0,B=L.data,G=ze(B)?M&&jc(M)?xn(M):M:B,U=L.error,ne=i.useRef(G),K=m?ze(B)?ze(ne.current)?G:ne.current:B:G,ge=A&&!ze(U)?!1:R&&!ze(f)?f:C().isPaused()?!1:s?ze(G)?!1:c:ze(G)||c,pe=!!(k&&r&&R&&ge),ae=ze(L.isValidating)?pe:L.isValidating,he=ze(L.isLoading)?pe:L.isLoading,Q=i.useCallback(async Z=>{const X=b.current;if(!k||!X||$.current||C().isPaused())return!1;let ee,te,W=!0;const Y=Z||{},se=!y[k]||!Y.dedupe,le=()=>cs?!$.current&&k===w.current&&_.current:k===w.current,q={isValidating:!1,isLoading:!1},me=()=>{T(q)},H=()=>{const Te=y[k];Te&&Te[1]===te&&delete y[k]},we={isValidating:!0};ze(j().data)&&(we.isLoading=!0);try{if(se&&(T(we),o.loadingTimeout&&ze(j().data)&&setTimeout(()=>{W&&le()&&C().onLoadingSlow(k,o)},o.loadingTimeout),y[k]=[X(z),na()]),[ee,te]=y[k],ee=await ee,se&&setTimeout(H,o.dedupingInterval),!y[k]||y[k][1]!==te)return se&&le()&&C().onDiscarded(k),!1;q.error=Xe;const Te=x[k];if(!ze(Te)&&(te<=Te[0]||te<=Te[1]||Te[1]===0))return me(),se&&le()&&C().onDiscarded(k),!1;const Ye=j().data;q.data=a(Ye,ee)?Ye:ee,se&&le()&&C().onSuccess(ee,k,o)}catch(Te){H();const Ye=C(),{shouldRetryOnError:Re}=Ye;Ye.isPaused()||(q.error=Te,se&&le()&&(Ye.onError(Te,k,Ye),(Re===!0||pt(Re)&&Re(Te))&&(!C().revalidateOnFocus||!C().revalidateOnReconnect||E())&&Ye.onErrorRetry(Te,k,Ye,Wt=>{const bt=v[k];bt&&bt[0]&&bt[0](ss,Wt)},{retryCount:(Y.retryCount||0)+1,dedupe:!0})))}return W=!1,me(),!0},[k,n]),Se=i.useCallback((...Z)=>kc(n,w.current,...Z),[]);if(fn(()=>{b.current=r,g.current=o,ze(B)||(ne.current=B)}),fn(()=>{if(!k)return;const Z=Q.bind(Xe,vn);let X=0;C().revalidateOnFocus&&(X=Date.now()+C().focusThrottleInterval);const te=du(k,v,(W,Y={})=>{if(W==yc){const se=Date.now();C().revalidateOnFocus&&se>X&&E()&&(X=se+C().focusThrottleInterval,Z())}else if(W==bc)C().revalidateOnReconnect&&E()&&Z();else{if(W==wc)return Q();if(W==ss)return Q(Y)}});return $.current=!1,w.current=k,_.current=!0,T({_k:z}),ge&&(y[k]||(ze(G)||Hr?Z():qd(Z))),()=>{$.current=!0,te()}},[k]),fn(()=>{let Z;function X(){const te=pt(d)?d(j().data):d;te&&Z!==-1&&(Z=setTimeout(ee,te))}function ee(){!j().error&&(l||C().isVisible())&&(u||C().isOnline())?Q(vn).then(X):X()}return X(),()=>{Z&&(clearTimeout(Z),Z=-1)}},[d,l,u,k]),i.useDebugValue(K),s&&ze(G)&&k){if(!cs&&Hr)throw new Error("Fallback data is required when using Suspense in SSR.");b.current=r,g.current=o,$.current=!1;const Z=S[k];if(!ze(Z)){const X=Se(Z);xn(X)}if(ze(U)){const X=Q(vn);ze(K)||(X.status="fulfilled",X.value=!0),xn(X)}else throw U}return{mutate:Se,get data(){return P.data=!0,K},get error(){return P.error=!0,U},get isValidating(){return P.isValidating=!0,ae},get isLoading(){return P.isLoading=!0,he}}},Ue=lu(uu),Je=()=>{const{adapter:t,deployment:r}=xe(),o=t.useNavigate(),n=(c,d)=>{o?o(c,d):window.location.href=c},a=c=>{if(c)return c;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const d=a(c),l=new URLSearchParams;l.set("redirect_uri",d),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const d=a(c),l=new URLSearchParams;l.set("redirect_uri",d),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const d=a(c),l=new URLSearchParams;l.set("redirect_uri",d),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function pu(t){const r=await t("/session",{method:"GET"});return(await N(r)).data}async function hu(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return N(o)}async function fu(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return N(n)}async function gu(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return N(o)}async function mu(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return N(o)}const aa=new Map,Br=new Map;function St(){aa.clear(),Br.clear()}async function xu(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return N(o)}function He(){const{client:t,loading:r}=Ne(),{deployment:o}=xe(),{navigate:n}=Je(),{cache:a}=zc(),{data:s,error:p,mutate:f,isLoading:c}=Ue(r?null:"/session",()=>pu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),d=i.useCallback(async()=>{await f(void 0,{revalidate:!0})},[f]),l=i.useCallback(async(u="default")=>{if(!s)throw new Error("no session");const m=aa.get(u);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";Br.get(u)||Br.set(u,xu(t,u));const v=await Br.get(u);return Br.delete(u),aa.set(u,v.data),v.data.token},[t,s==null?void 0:s.active_signin]);return r||!s||c?{loading:!0,error:p,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:d}:{loading:c,error:p,session:s,switchSignIn:async u=>{await hu(t,u),St(),await Nr("/me/organization-memberships",void 0,{revalidate:!1}),await Nr("/me/workspace-memberships",void 0,{revalidate:!1}),await f(void 0,{revalidate:!0}),await Nr("/me/organization-memberships"),await Nr("/me/workspace-memberships")},signOut:async u=>{await fu(t,u);const m=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],v=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(a instanceof Map){const x=Array.from(a.keys());for(const y of x){let S=!1;(m.includes(y)||typeof y=="string"&&v.some(k=>y.startsWith(k)))&&(S=!0),S&&a.delete(y)}}St(),await f(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(u&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!u&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async u=>{await gu(t,u),St(),await f(void 0,{revalidate:!0})},switchWorkspace:async u=>{await mu(t,u),St(),await f(void 0,{revalidate:!0})},getToken:l,refetch:d}}const Qo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=$t(),{client:n}=Ne(),{refetch:a}=He(),s=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/roles`,{method:"GET"}))).data,[n]),p=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/members`,{method:"GET"}))).data,[n]),f=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/domains`,{method:"GET"}))).data,[n]),d=i.useCallback(async(L,R)=>{await n(`/organizations/${L.id}/members/${R.id}/remove`,{method:"POST"})},[n]),l=i.useCallback(async L=>{const R=new FormData;R.append("name",L.name),L.image&&R.append("image",L.image),L.description&&R.append("description",L.description);const A=await N(await n("/organizations",{method:"POST",body:R}));return St(),await r(),await a(),A},[a,r,n]),u=i.useCallback(async(L,R)=>{const A=Object.entries(R).reduce((G,[U,ne])=>(ne&&G.append(U,ne),G),new FormData),B=await N(await n(`/organizations/${L.id}/update`,{method:"POST",body:A}));return await r(),B},[r,n]),m=i.useCallback(async(L,R)=>{await n(`/organizations/${L.id}/roles/${R.id}/remove`,{method:"POST"})},[n]),v=i.useCallback(async(L,R)=>{const A=new FormData;return A.append("domain",R.fqdn),await N(await n(`/organizations/${L.id}/domains`,{method:"POST",body:A}))},[n]),x=i.useCallback(async(L,R)=>await N(await n(`/organizations/${L.id}/domains/${R.id}/verify`,{method:"POST"})),[n]),y=i.useCallback(async(L,R)=>await N(await n(`/organizations/${L.id}/domains/${R.id}/delete`,{method:"POST"})),[n]),S=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/enterprise-connections`,{method:"GET"}))).data,[n]),k=i.useCallback(async(L,R)=>{const A=new FormData;return A.append("protocol",R.protocol),R.domain_id&&A.append("domain_id",R.domain_id),R.idp_entity_id&&A.append("idp_entity_id",R.idp_entity_id),R.idp_sso_url&&A.append("idp_sso_url",R.idp_sso_url),R.idp_certificate&&A.append("idp_certificate",R.idp_certificate),R.oidc_client_id&&A.append("oidc_client_id",R.oidc_client_id),R.oidc_client_secret&&A.append("oidc_client_secret",R.oidc_client_secret),R.oidc_issuer_url&&A.append("oidc_issuer_url",R.oidc_issuer_url),R.oidc_scopes&&A.append("oidc_scopes",R.oidc_scopes),R.jit_enabled!==void 0&&A.append("jit_enabled",String(R.jit_enabled)),R.attribute_mapping&&A.append("attribute_mapping",JSON.stringify(R.attribute_mapping)),(await N(await n(`/organizations/${L.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),z=i.useCallback(async(L,R,A)=>{const B=new FormData;return A.domain_id&&B.append("domain_id",A.domain_id),A.idp_entity_id&&B.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&B.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&B.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&B.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&B.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&B.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&B.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&B.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await N(await n(`/organizations/${L.id}/enterprise-connections/${R}/update`,{method:"POST",body:B}))).data},[n]),_=i.useCallback(async(L,R)=>{await n(`/organizations/${L.id}/enterprise-connections/${R}/delete`,{method:"POST"})},[n]),$=i.useCallback(async(L,R)=>{const A=new FormData;return A.append("protocol",R.protocol),R.idp_entity_id&&A.append("idp_entity_id",R.idp_entity_id),R.idp_sso_url&&A.append("idp_sso_url",R.idp_sso_url),R.idp_certificate&&A.append("idp_certificate",R.idp_certificate),R.oidc_issuer_url&&A.append("oidc_issuer_url",R.oidc_issuer_url),R.oidc_client_id&&A.append("oidc_client_id",R.oidc_client_id),R.oidc_client_secret&&A.append("oidc_client_secret",R.oidc_client_secret),(await N(await n(`/organizations/${L.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),w=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/enterprise-connections/${R}/test`,{method:"POST"}))).data,[n]),b=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/enterprise-connections/${R}/scim/token`,{method:"POST"}))).data,[n]),g=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/enterprise-connections/${R}/scim/token`,{method:"GET"}))).data,[n]),C=i.useCallback(async(L,R)=>{await n(`/organizations/${L.id}/enterprise-connections/${R}/scim/token/revoke`,{method:"POST"})},[n]),E=i.useCallback(async(L,R)=>{const A=new FormData;return A.append("name",R.name),R.permissions&&R.permissions.forEach((G,U)=>{A.append(`permissions[${U}]`,G)}),await N(await n(`/organizations/${L.id}/roles`,{method:"POST",body:A}))},[n]),j=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/leave`,{method:"POST"}))).data,[n]),T=i.useCallback(async L=>{const R=await N(await n(`/organizations/${L.id}/delete`,{method:"POST"}));return St(),await r(),await a(),R.data},[n,r,a]),I=i.useCallback(async(L,R,A)=>(await N(await n(`/organizations/${L.id}/members/${R.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),O=i.useCallback(async(L,R,A)=>(await N(await n(`/organizations/${L.id}/members/${R.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),P=i.useCallback(async(L,R)=>{var G,U;const A=new FormData;return A.append("email",R.email),A.append("role_id",R.organizationRole.id),(G=R.workspace)!=null&&G.id&&A.append("workspace_id",R.workspace.id),(U=R.workspaceRole)!=null&&U.id&&A.append("workspace_role_id",R.workspaceRole.id),(await N(await n(`/organizations/${L.id}/invitations`,{method:"POST",body:A}))).data},[n]),M=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/invitations/${R.id}/discard`,{method:"POST"}))).data,[n]),F=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/invitations/${R.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(L=>L.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:j,getOrganizationRoles:s,getOrganizationMembers:p,removeOrganizationMember:d,createOrganization:l,getOrganizationInvitations:f,getOrganizationDomains:c,addOrganizationDomain:v,verifyOrganizationDomain:x,removeOrganizationDomain:y,addRoleToOrganizationMember:I,removeRoleFromOrganizationMember:O,inviteOrganizationMember:P,discardOrganizationInvitation:M,resendOrganizationInvitation:F,updateOrganization:u,addRole:E,removeOrganizationRoles:m,deleteOrganization:T,getEnterpriseConnections:S,createEnterpriseConnection:k,updateEnterpriseConnection:z,deleteEnterpriseConnection:_,testEnterpriseConnectionConfig:$,testEnterpriseConnection:w,generateSCIMToken:b,getSCIMToken:g,revokeSCIMToken:C}},tt=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:a,leaveOrganization:s,removeOrganizationMember:p,getOrganizationInvitations:f,getOrganizationDomains:c,removeOrganizationDomain:d,addOrganizationDomain:l,verifyOrganizationDomain:u,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:v,inviteOrganizationMember:x,discardOrganizationInvitation:y,resendOrganizationInvitation:S,updateOrganization:k,removeOrganizationRoles:z,getEnterpriseConnections:_,createEnterpriseConnection:$,updateEnterpriseConnection:w,deleteEnterpriseConnection:b,testEnterpriseConnectionConfig:g,testEnterpriseConnection:C,generateSCIMToken:E,getSCIMToken:j,revokeSCIMToken:T}=Qo(),{session:I,error:O,loading:P}=He(),{organizationMemberships:M}=$t(),F=i.useMemo(()=>(M==null?void 0:M.find(H=>{var we;return H.id===((we=I==null?void 0:I.active_signin)==null?void 0:we.active_organization_membership_id)}))||null,[M,I]),D=i.useMemo(()=>(F==null?void 0:F.organization)||null,[F]),L=i.useCallback(async H=>D?await k(D,H):[],[D,k]),R=i.useCallback(async()=>D?await n(D):[],[D,n]),A=i.useCallback(async()=>D?await a(D):[],[D,a]),B=i.useCallback(async H=>D?await p(D,H):[],[D,p]),G=i.useCallback(async H=>D?await z(D,H):void 0,[D,z]),U=i.useCallback(async()=>D?await c(D):[],[D,c]),ne=i.useCallback(async H=>D?await l(D,H):void 0,[D,l]),K=i.useCallback(async H=>D?await u(D,H):void 0,[D,u]),ge=i.useCallback(async H=>D?await d(D,H):void 0,[D,d]),pe=i.useCallback(async(H,we)=>D?await m(D,H,we):void 0,[D,m]),ae=i.useCallback(async(H,we)=>D?await v(D,H,we):void 0,[D,v]),he=i.useCallback(async H=>D?await x(D,H):void 0,[D,x]),Q=i.useCallback(async H=>D?await y(D,H):void 0,[D,y]),Se=i.useCallback(async H=>D?await S(D,H):void 0,[D,S]),ce=i.useCallback(async()=>{D&&await s(D)},[D,s]),Z=i.useCallback(async()=>D?await f(D):[],[D,f]),X=i.useCallback(async()=>D?await _(D):[],[D,_]),ee=i.useCallback(async H=>{if(D)return await $(D,H)},[D,$]),te=i.useCallback(async(H,we)=>{if(D)return await w(D,H,we)},[D,w]),W=i.useCallback(async H=>{D&&await b(D,H)},[D,b]),Y=i.useCallback(async H=>D?await g(D,H):null,[D,g]),se=i.useCallback(async H=>D?await C(D,H):null,[D,C]),le=i.useCallback(async H=>{if(D)return await E(D,H)},[D,E]),q=i.useCallback(async H=>{if(D)return await j(D,H)},[D,j]),me=i.useCallback(async H=>{D&&await T(D,H)},[D,T]);return P||t?{activeOrganization:null,activeMembership:null,loading:!0,error:O||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null,getEnterpriseConnections:null,createEnterpriseConnection:null,updateEnterpriseConnection:null,deleteEnterpriseConnection:null,generateSCIMToken:null,getSCIMToken:null,revokeSCIMToken:null}:{activeOrganization:D,activeMembership:F,loading:!1,refetch:o,getRoles:A,updateOrganization:L,getMembers:R,getDomains:U,addDomain:ne,verifyDomain:K,removeDomain:ge,getInvitations:Z,removeMember:B,leave:ce,removeRole:G,addMemberRole:pe,removeMemberRole:ae,inviteMember:he,discardInvitation:Q,resendInvitation:Se,getEnterpriseConnections:X,createEnterpriseConnection:ee,updateEnterpriseConnection:te,deleteEnterpriseConnection:W,testEnterpriseConnectionConfig:Y,testEnterpriseConnection:se,generateSCIMToken:le,getSCIMToken:q,revokeSCIMToken:me,error:null}};async function vu(t){return(await N(await t("/me/organization-memberships"))).data}const $t=()=>{const{client:t,loading:r}=Ne(),{data:o,isLoading:n,error:a,mutate:s}=Ue(r?null:"/me/organization-memberships",()=>vu(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 yu(t){return(await N(await t("/me/workspace-memberships"))).data}async function bu(t,r,o){return(await N(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Jo=()=>{const{client:t,loading:r}=Ne(),{deployment:o}=xe(),{data:n,isLoading:a,error:s,mutate:p}=Ue(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>yu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]);return{workspaceMemberships:n,loading:r||a,error:s,refetch:f}},Lt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Jo(),{client:a}=Ne(),s=i.useMemo(()=>t==null?void 0:t.map(w=>({...w.workspace,organization:w.organization,eligibility_restriction:w.eligibility_restriction})),[t]),p=i.useCallback(async(w,b,g,C)=>{const E=new FormData;E.append("name",b),g&&E.append("image",g),C&&E.append("description",C),E.append("organization_id",w);const j=await N(await a("/workspaces",{method:"POST",body:E}));return St(),await r(),j.data},[a,r]),f=i.useCallback(async(w,b)=>{const g=await bu(a,w,b);return await r(),g},[a,r]),c=i.useCallback(async(w,b)=>{const g=new FormData;b.name&&g.append("name",b.name),b.description&&g.append("description",b.description),b.image&&g.append("image",b.image),b.enforce_2fa!==void 0&&g.append("enforce_2fa",String(b.enforce_2fa)),b.enable_ip_restriction!==void 0&&g.append("enable_ip_restriction",String(b.enable_ip_restriction)),b.whitelisted_ips&&b.whitelisted_ips.forEach(E=>g.append("whitelisted_ips",E));const C=await N(await a(`/workspaces/${w.id}/update`,{method:"POST",body:g}));return await r(),C.data},[a,r]),d=i.useCallback(async w=>{const b=await N(await a(`/workspaces/${w.id}/delete`,{method:"POST"}));return St(),await r(),b.data},[a,r]),l=i.useCallback(async w=>(await N(await a(`/workspaces/${w.id}/members`,{method:"GET"}))).data,[a]),u=i.useCallback(async w=>(await N(await a(`/workspaces/${w.id}/roles`,{method:"GET"}))).data,[a]),m=i.useCallback(async(w,b,g)=>{const C=new FormData;return C.append("name",b),g.forEach(j=>C.append("permissions",j)),(await N(await a(`/workspaces/${w.id}/roles`,{method:"POST",body:C}))).data},[a]),v=i.useCallback(async(w,b)=>(await N(await a(`/workspaces/${w.id}/roles/${b.id}/delete`,{method:"POST"}))).data,[a]),x=i.useCallback(async(w,b)=>{const g=await N(await a(`/workspaces/${w.id}/members/${b}/remove`,{method:"POST"}));return await r(),g.data},[a,r]),y=i.useCallback(async(w,b,g)=>(await N(await a(`/workspaces/${w.id}/members/${b}/roles/${g}/add`,{method:"POST"}))).data,[a]),S=i.useCallback(async(w,b,g)=>(await N(await a(`/workspaces/${w.id}/members/${b}/roles/${g}/remove`,{method:"POST"}))).data,[a]),k=i.useCallback(async w=>(await N(await a(`/organizations/${w.organization.id}/invitations`,{method:"GET"}))).data.filter(g=>String(g.workspace_id)===String(w.id)),[a]),z=i.useCallback(async(w,b,g)=>{const C=new FormData;return C.append("email",b),C.append("workspace_id",w.id),g&&C.append("workspace_role_id",g),(await N(await a(`/organizations/${w.organization.id}/invitations`,{method:"POST",body:C}))).data},[a]),_=i.useCallback(async(w,b)=>(await N(await a(`/organizations/${w.organization.id}/invitations/${b}/discard`,{method:"POST"}))).data,[a]),$=i.useCallback(async(w,b)=>(await N(await a(`/organizations/${w.organization.id}/invitations/${b}/resend`,{method:"POST"}))).data,[a]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:f,createWorkspace:p,updateWorkspace:c,deleteWorkspace:d,getWorkspaceMembers:l,getWorkspaceRoles:u,createWorkspaceRole:m,deleteWorkspaceRole:v,removeWorkspaceMember:x,addWorkspaceMemberRole:y,removeWorkspaceMemberRole:S,getWorkspaceInvitations:k,createWorkspaceInvitation:z,discardWorkspaceInvitation:_,resendWorkspaceInvitation:$}},Dt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:a,updateWorkspace:s,deleteWorkspace:p,getWorkspaceMembers:f,getWorkspaceRoles:c,createWorkspaceRole:d,deleteWorkspaceRole:l,removeWorkspaceMember:u,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:v,getWorkspaceInvitations:x,createWorkspaceInvitation:y,discardWorkspaceInvitation:S,resendWorkspaceInvitation:k}=Lt(),{workspaceMemberships:z}=Jo(),{session:_,loading:$,error:w}=He(),b=i.useMemo(()=>(z==null?void 0:z.find(K=>{var ge;return K.id===((ge=_==null?void 0:_.active_signin)==null?void 0:ge.active_workspace_membership_id)}))||null,[z,_]),g=i.useMemo(()=>(b==null?void 0:b.workspace)||null,[b]),C=i.useCallback(async()=>{var K;if(!(!g||!((K=_==null?void 0:_.active_signin)!=null&&K.user_id)))return await a(g.id,_.active_signin.user_id)},[g,a,_]),E=i.useCallback(async K=>{if(g)return await s(g,K)},[g,s]),j=i.useCallback(async()=>{if(g)return await p(g)},[g,p]),T=i.useCallback(async()=>g?await f(g):[],[g,f]),I=i.useCallback(async()=>g?await c(g):[],[g,c]),O=i.useCallback(async(K,ge)=>{if(g)return await d(g,K,ge)},[g,d]),P=i.useCallback(async K=>{if(g)return await l(g,K)},[g,l]),M=i.useCallback(async K=>{if(g)return await u(g,K)},[g,u]),F=i.useCallback(async(K,ge)=>{if(g)return await m(g,K,ge)},[g,m]),D=i.useCallback(async(K,ge)=>{if(g)return await v(g,K,ge)},[g,v]),L=i.useMemo(()=>(n==null?void 0:n.find(K=>K.id===(g==null?void 0:g.id)))||null,[n,g]),R=i.useCallback(async()=>L?await x(L):[],[L,x]),A=i.useCallback(async(K,ge)=>{if(L)return await y(L,K,ge)},[L,y]),B=i.useCallback(async K=>{if(L)return await S(L,K)},[L,S]),G=i.useCallback(async K=>{if(L)return await k(L,K)},[L,k]),U=r||$,ne=o||w;return U?{activeWorkspace:null,activeMembership:null,loading:!0,error:ne,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null,getInvitations:null,discardInvitation:null,resendInvitation:null}:{activeWorkspace:g,activeMembership:b,loading:!1,error:ne,refetch:t,leave:C,updateWorkspace:E,deleteWorkspace:j,getMembers:T,getRoles:I,createRole:O,deleteRole:P,inviteMember:A,removeMember:M,addMemberRole:F,removeMemberRole:D,getInvitations:R,discardInvitation:B,resendInvitation:G}};function yn(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function bn(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);return a.buffer}const wu=async t=>(await N(await t("/me"))).data,ju=async t=>(await N(await t("/me/signins"))).data;function Ft(){const{client:t,loading:r}=Ne(),{data:o,error:n,isLoading:a,mutate:s}=Ue(r?null:"/user",()=>wu(t)),p=async L=>{const R=new FormData;for(const[B,G]of Object.entries(L))G!=null&&G!==""&&R.append(B,String(G));const A=await N(await t("/me",{method:"POST",body:R}));return s(),A},f=async()=>await N(await t("/me/email-addresses",{method:"GET"})),c=async L=>await N(await t(`/me/email-addresses/${L}`,{method:"GET"})),d=async L=>{const R=new FormData;return R.append("email",L),await N(await t("/me/email-addresses",{method:"POST",body:R}))},l=async L=>await N(await t(`/me/email-addresses/${L}/delete`,{method:"POST"})),u=async L=>await N(await t(`/me/email-addresses/${L}/prepare-verification`,{method:"POST"})),m=async(L,R)=>await N(await t(`/me/email-addresses/${L}/attempt-verification?code=${R}`,{method:"POST"})),v=async(L,R)=>{const A=new FormData;return A.append("phone_number",L),A.append("country_code",R),await N(await t("/me/phone-numbers",{method:"POST",body:A}))},x=async L=>await N(await t(`/me/phone-numbers/${L}/delete`,{method:"POST"})),y=async L=>await N(await t(`/me/phone-numbers/${L}/prepare-verification`,{method:"POST"})),S=async(L,R)=>{const A=new FormData;return A.append("code",R),await N(await t(`/me/phone-numbers/${L}/attempt-verification`,{method:"POST",body:A}))},k=async L=>{const R=await N(await t(`/me/phone-numbers/${L}/make-primary`,{method:"POST"}));return s(),R},z=async L=>await N(await t(`/me/email-addresses/${L}/make-primary`,{method:"POST"})),_=async()=>(await N(await t("/me/authenticator",{method:"POST"}))).data,$=async(L,R)=>{const A=new FormData;return A.append("authenticator_id",L),R.forEach(G=>{A.append("codes",G)}),await N(await t("/me/authenticator/attempt-verification",{method:"POST",body:A}))},w=async L=>await N(await t(`/me/authenticator/${L}/delete`,{method:"POST"})),b=async()=>(await N(await t("/me/backup-codes",{method:"POST"}))).data,g=async L=>{const R=new FormData;return R.append("file",L),await N(await t("/me/profile-picture",{method:"POST",body:R}))},C=async()=>(await N(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,E=async(L,R)=>{const A=new FormData;return A.append("current_password",L),A.append("new_password",R),await N(await t("/me/update-password",{method:"POST",body:A}))},j=async L=>{const R=new FormData;R.append("current_password",L);const A=await N(await t("/me/remove-password",{method:"POST",body:R}));return s(),A},T=async L=>{const R=new FormData;return R.append("password",L),await N(await t("/me/account/delete",{method:"POST",body:R}))},I=async L=>await N(await t(`/me/social-connections/${L}/disconnect`,{method:"POST"})),O=async({provider:L,redirectUri:R})=>{var G;const A=new URLSearchParams({provider:L});R&&A.append("redirect_uri",R);const B=await N(await t(`/me/init-sso-connection?${A.toString()}`,{method:"POST"}));return"data"in B&&((G=B.data)!=null&&G.oauth_url)&&window.open(B.data.oauth_url,"_blank"),B},P=async()=>await N(await t("/me/passkeys",{method:"GET"})),M=async L=>{var ge,pe;const R=await N(await t("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in R))return R;const A=R.data.options.publicKey,B={challenge:bn(A.challenge),rp:A.rp,user:{id:bn(A.user.id),name:A.user.name,displayName:A.user.displayName},pubKeyCredParams:A.pubKeyCredParams,timeout:A.timeout,attestation:A.attestation,authenticatorSelection:A.authenticatorSelection,excludeCredentials:(ge=A.excludeCredentials)==null?void 0:ge.map(ae=>({type:ae.type,id:bn(ae.id),transports:ae.transports}))},G=await navigator.credentials.create({publicKey:B});if(!G)throw new Error("Failed to create credential");const U=G.response,ne={id:G.id,rawId:yn(G.rawId),type:G.type,response:{clientDataJSON:yn(U.clientDataJSON),attestationObject:yn(U.attestationObject),transports:((pe=U.getTransports)==null?void 0:pe.call(U))||[]}};return await N(await t(`/me/passkeys/register/finish?name=${encodeURIComponent(L||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ne)}))},F=async L=>await N(await t(`/me/passkeys/${L}/delete`,{method:"POST"})),D=async(L,R)=>await N(await t(`/me/passkeys/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:R})}));return{user:{...o,refetch:s},loading:r||a,error:n||null,updateProfile:p,getEmailAddresses:f,getEmailAddress:c,createEmailAddress:d,deleteEmailAddress:l,prepareEmailVerification:u,attemptEmailVerification:m,makeEmailPrimary:z,createPhoneNumber:v,deletePhoneNumber:x,preparePhoneVerification:y,attemptPhoneVerification:S,makePhonePrimary:k,setupAuthenticator:_,verifyAuthenticator:$,deleteAuthenticator:w,generateBackupCodes:b,regenerateBackupCodes:C,updateProfilePicture:g,disconnectSocialConnection:I,connectSocialAccount:O,updatePassword:E,removePassword:j,deleteAccount:T,getPasskeys:P,registerPasskey:M,deletePasskey:F,renamePasskey:D}}function Ec(){const{client:t,loading:r}=Ne(),{data:o,error:n,isLoading:a,mutate:s}=Ue(r?null:"/me/signins",()=>ju(t));return{signins:o,error:n||null,removeSignin:async f=>await N(await t(`/me/signins/${f}/signout`,{method:"POST"})),refetch:s,loading:a||r}}function _u(){const{session:t,loading:r}=He(),{loading:o,organizationMemberships:n}=$t(),{loading:a,workspaceMemberships:s}=Jo();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 d;return c.id===((d=t.active_signin)==null?void 0:d.active_organization_membership_id)}),[t]),f=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(c=>{var d;return c.id===((d=t.active_signin)==null?void 0:d.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:p,workspaceMembership:f}}function $c(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(!1),a=async s=>{n(!0);try{const p=new FormData;for(const[d,l]of Object.entries(s))l&&p.append(d,l);const f=await t("/waitlist/join",{method:"POST",body:p});return await N(f)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:a}}function Pc(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[p,f]=i.useState(null),[c,d]=i.useState(null),[l,u]=i.useState(!1),[m,v]=i.useState(null);i.useEffect(()=>{if(l||r)return;const y=new URLSearchParams(window.location.search),S=y.get("code"),k=y.get("state"),z=y.get("error"),_=y.get("error_description");if(!S&&!z){u(!0);const $=new Error("No OAuth callback data found.");s($);return}if(u(!0),n(!0),z){const $=_||z,w=new Error(`OAuth Error: ${$}`);s(w),n(!1);return}if(S&&k)x(S,k);else{const $=new Error("Missing required OAuth parameters");s($),n(!1)}},[l,r]);const x=async(y,S)=>{try{let k,z;try{const w=S.split(".");if(w.length!==2)throw new Error("Invalid OAuth state format - missing signature");const b=w[0].replace(/-/g,"+").replace(/_/g,"/"),g=b.length%4?"=".repeat(4-b.length%4):"",E=atob(b+g).split("|")[0];if(E==="sign_in")k="/auth/oauth2/callback",z="GET";else if(E==="connect_social")k="/me/sso-connection-callback",z="POST";else throw new Error(`Unknown OAuth action: ${E}`)}catch(w){const b=w instanceof Error?w: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 _=await t(`${k}?code=${encodeURIComponent(y)}&state=${encodeURIComponent(S)}`,{method:z}),$=await N(_);if("data"in $){const w=$.data.session,b=$.data.redirect_uri||null;if(f(w),d(b),w.signin_attempts&&w.signin_attempts.length>0){const g=w.signin_attempts.at(-1);g&&v(g)}}else{const w=new Error("SSO callback failed");s(w)}}catch(k){const z=k instanceof Error?k:new Error("Unknown error occurred");s(z)}finally{n(!1)}};return{loading:o,error:a,session:p,redirectUri:c,processed:l,signinAttempt:m}}function Rc(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(!1),[a,s]=i.useState(null);return{loading:r||o,verifyMagicLink:async f=>{if(!f.token||!f.attempt)throw new Error("Invalid magic link parameters");n(!0),s(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",f.token),c.searchParams.set("attempt",f.attempt),f.redirectUri&&c.searchParams.set("redirect_uri",f.redirectUri);const d=await t(c.pathname+c.search,{method:"GET"}),l=await N(d);return n(!1),s(!0),l}catch(c){throw n(!1),s(!1),c}},success:a}}function Ic(){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 Tc(){const{client:t,loading:r}=Ne();return{loading:r,forgotPassword:async s=>{const p=new FormData;p.append("email",s);const f=await t("/auth/forgot-password",{method:"POST",body:p});return await N(f)},verifyOtp:async(s,p)=>{const f=new FormData;f.append("email",s),f.append("otp",p);const c=await t("/auth/forgot-password",{method:"POST",body:f});return await N(c)},resetPassword:async(s,p)=>{const f=new FormData;f.append("token",s),f.append("password",p);const c=await t("/auth/reset-password",{method:"POST",body:f});return await N(c)}}}function Oc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:a,onError:s,reconnectDelay:p=1e3,maxReconnectAttempts:f=5}={}){const{session:c,loading:d}=He(),{deployment:l,loading:u}=xe(),[m,v]=i.useState(!1),[x,y]=i.useState(null),S=i.useRef(null),k=i.useRef(null),z=i.useRef(0),_=i.useRef(null),$=i.useRef(a),w=i.useRef(s),b=i.useRef(r),g=i.useRef(o),C=i.useRef(n),E=i.useRef(p),j=i.useRef(f);$.current=a,w.current=s,b.current=r,g.current=o,C.current=n,E.current=p,j.current=f;const T=i.useCallback(()=>{k.current&&(clearTimeout(k.current),k.current=null),_.current&&(clearInterval(_.current),_.current=null),S.current&&(S.current.close(),S.current=null)},[]),I=i.useCallback(async()=>{var L;if(!t||d||u||!c||!l)return;T();const M=new URL(l.backend_host),F=M.protocol==="https:"?"wss:":"ws:",D=new URL("/realtime/notifications",`${F}//${M.host}`);if(l.mode==="staging"){const R=localStorage.getItem("__dev_session__");R&&D.searchParams.set("__dev_session__",R)}b.current&&b.current.length>0&&b.current.forEach(R=>D.searchParams.append("channels",R)),g.current&&g.current.length>0&&g.current.forEach(R=>D.searchParams.append("organization_ids",R.toString())),C.current&&C.current.length>0&&C.current.forEach(R=>D.searchParams.append("workspace_ids",R.toString()));try{const R=new WebSocket(D.toString());S.current=R,R.onopen=()=>{v(!0),y(null),z.current=0,_.current=setInterval(()=>{R.readyState===WebSocket.OPEN&&R.send("ping")},3e4)},R.onmessage=A=>{var B,G;try{const U=JSON.parse(A.data);if(U.type==="notification"&&U.data)(B=$.current)==null||B.call($,U.data);else if(U.type==="error"){const ne=U.error||"Unknown error occurred";y(ne),(G=w.current)==null||G.call(w,ne)}else U.type}catch{}},R.onerror=()=>{var A;y("Connection error occurred"),(A=w.current)==null||A.call(w,"Connection error occurred")},R.onclose=A=>{var B;if(v(!1),_.current&&(clearInterval(_.current),_.current=null),t&&A.code!==1e3&&z.current<j.current){z.current++;const G=E.current*Math.pow(2,z.current-1);k.current=setTimeout(()=>{I()},G)}else z.current>=j.current&&(y("Max reconnection attempts reached"),(B=w.current)==null||B.call(w,"Max reconnection attempts reached"))}}catch{y("Failed to connect"),(L=w.current)==null||L.call(w,"Failed to connect")}},[t,d,u,c,l,T]);i.useEffect(()=>(I(),()=>{T()}),[I,T]),i.useEffect(()=>{S.current&&S.current.readyState===WebSocket.OPEN&&I()},[r,o,n,I]);const O=i.useCallback(()=>{T(),v(!1)},[T]),P=i.useCallback(()=>{z.current=0,I()},[I]);return{isConnected:m,connectionError:x,disconnect:O,reconnect:P}}async function ku(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 N(a)).data}async function Cu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await N(r)).data}async function Su(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return N(o)}async function zu(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return N(r)}async function Eu(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return N(o)}function Mc(t){const{client:r,loading:o}=Ne(),{data:n,error:a,mutate:s,isLoading:p}=Ue(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>ku(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});Oc({enabled:!o&&!!n,onNotification:i.useCallback(u=>{s(async m=>!m||m.notifications.some(x=>x.id===u.id.toString())?m:{...m,notifications:[{id:u.id.toString(),user_id:u.user_id.toString(),deployment_id:u.deployment_id.toString(),title:u.title,body:u.body,severity:u.severity,action_url:u.action_url,action_label:u.action_label,is_read:!1,is_archived:!1,created_at:u.created_at,updated_at:u.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[s]),onError:i.useCallback(()=>{},[])});const f=i.useCallback(async u=>{o||(await s(async m=>m&&{...m,notifications:m.notifications.map(v=>v.id===u?{...v,is_read:!0}:v),unread_count:Math.max(0,m.unread_count-1)},!1),await Su(r,u),await s())},[r,o,s]),c=i.useCallback(async()=>{o||(await s(async u=>u&&{...u,notifications:u.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await zu(r),await s())},[r,s]),d=i.useCallback(async u=>{o||(await s(async m=>{if(!m)return m;const v=m.notifications.find(x=>x.id===u);return{...m,notifications:m.notifications.filter(x=>x.id!==u),unread_count:v&&!v.is_read?Math.max(0,m.unread_count-1):m.unread_count,total:Math.max(0,m.total-1)}},!1),await Eu(r,u),await s())},[r,o,s]),l=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:l}:{loading:!1,error:a,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:f,markAllAsRead:c,deleteNotification:d,refetch:l}}async function $u(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await N(r)).data}function Pu(){const{client:t,loading:r}=Ne(),{data:o,error:n,mutate:a}=Ue(r?null:"wacht-notifications:channel-counts",()=>$u(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 ro={DISCONNECTED:"disconnected",CONNECTED:"connected",ERROR:"error"},Ge={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Vt={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Ru(t){switch(t){case Vt.IDLE:return Ge.IDLE;case Vt.STARTING:return Ge.STARTING;case Vt.RUNNING:return Ge.RUNNING;case Vt.WAITING_FOR_INPUT:return Ge.WAITING_FOR_INPUT;case Vt.COMPLETED:return Ge.COMPLETED;case Vt.FAILED:case Vt.CANCELLED:return Ge.FAILED;default:return Ge.IDLE}}function Iu(t){return t===Ge.STARTING||t===Ge.RUNNING||t===Ge.WAITING_FOR_INPUT}function Tu(t){const{client:r}=Ne(),[o,n]=i.useState(!1),[a,s]=i.useState(!!t),[p,f]=i.useState(null),c=i.useRef(!1),d=i.useRef(!1);return i.useEffect(()=>{if(!t||c.current||d.current)return;(async()=>{d.current=!0;try{s(!0),(await r(`/api/agent/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"POST"})).ok?(c.current=!0,n(!0)):f(new Error("Failed to exchange ticket"))}catch(u){f(u instanceof Error?u:new Error("Failed to exchange ticket"))}finally{s(!1),d.current=!1}})()},[t,r]),{exchanged:o,loading:a,error:p}}function Ou({contextId:t,agentName:r,platformAdapter:o}){const{deployment:n}=xe(),{client:a}=Ne(),[s,p]=i.useState([]),[f,c]=i.useState([]),[d,l]=i.useState(null),[u,m]=i.useState(null),[v,x]=i.useState(null),[y,S]=i.useState(!1),[k,z]=i.useState(!1),[_,$]=i.useState(Ge.IDLE),[w,b]=i.useState({status:ro.DISCONNECTED}),[g,C]=i.useState(!0),[E,j]=i.useState(!1),T=i.useRef(null),I=i.useRef(null),O=i.useRef(null),P=i.useRef(new Set),M=i.useCallback(ce=>{var Y;const{id:Z,content:X}=ce,ee=ce.message_type||((Y=ce.metadata)==null?void 0:Y.message_type)||(X==null?void 0:X.type);let te="assistant";ee==="user_message"&&(te="user");const W={...ce,role:te,metadata:{...ce.metadata||{},message_type:ee}};if(ee==="system_decision"||ee==="action_execution_result"||ee==="context_results"){if(l(null),m(null),x(null),P.current.has(Z))return;P.current.add(Z),p(se=>[...se,W]);return}if(ee==="user_message"){if(l(null),m(null),x(null),P.current.has(Z))return;P.current.add(Z),console.log(P.current,Z),p(se=>[...se,W]);return}if(ee==="assistant_acknowledgment"){if(l(null),m(null),x(null),P.current.has(Z))return;P.current.add(Z),p(se=>[...se,W]),ce.further_action_required||(z(!1),$(Ge.IDLE),I.current=null);return}if(ee==="agent_response"){if(P.current.has(Z))return;P.current.add(Z),p(se=>[...se,W]),z(!1),$(Ge.IDLE),I.current=null;return}if(ee==="user_input_request"){if(P.current.has(Z))return;P.current.add(Z),$(Ge.WAITING_FOR_INPUT),p(se=>[...se,W]);return}if(ee==="execution_status"){const se=Ru(X.status);$(se),z(Iu(se));return}},[]),F=i.useCallback((ce,Z)=>{var X;(X=o==null?void 0:o.onPlatformEvent)==null||X.call(o,ce,Z)},[o]),D=i.useRef(M),L=i.useRef(F),R=i.useRef(a),A=i.useRef(n);i.useEffect(()=>{D.current=M,L.current=F,R.current=a,A.current=n});const B=i.useRef(null),G=i.useRef(null),U=i.useRef(0),ne=10,K=i.useCallback(async ce=>{if(t)try{const Z=new URLSearchParams({limit:"100"});ce&&(Z.append("before_id",ce),j(!0));const X=await a(`/api/agent/contexts/${t}/messages?${Z}`,{method:"GET"}),ee=await N(X);if(ee.data){const te=[...ee.data.data].sort((W,Y)=>{const se=new Date(W.timestamp).getTime(),le=new Date(Y.timestamp).getTime();return se-le});te.length>0&&(T.current=te[0].id),te.forEach(W=>{P.current.add(W.id)}),p(W=>ce?[...te,...W]:te),C(ee.data.has_more||!1),j(!1)}}catch(Z){console.error("Failed to fetch messages:",Z),j(!1)}},[t,a]);i.useEffect(()=>{const ce=A.current;if(!ce||!t)return;const Z=()=>{B.current&&(B.current.close(),B.current=null);const X=ce.backend_host.replace(/\/$/,""),ee=new URL(`${X}/realtime/agent/stream`);if(ee.searchParams.append("context_id",t),ce.mode==="staging"){const W=localStorage.getItem("__dev_session__");W&&ee.searchParams.append("__dev_session__",W)}console.log("SSE: Connecting to",ee.toString());const te=new EventSource(ee.toString(),{withCredentials:ce.mode!=="staging"});B.current=te,te.onopen=()=>{console.log("SSE: Connected successfully"),S(!0),b({status:ro.CONNECTED}),U.current>0&&setTimeout(()=>{a(`/api/agent/contexts/${t}/messages?limit=100`,{method:"GET"}).then(async W=>{const Y=await N(W);if(Y.data){const se=[...Y.data.data].sort((le,q)=>new Date(le.timestamp).getTime()-new Date(q.timestamp).getTime());p(se)}}).catch(W=>console.error("Failed to refetch messages:",W))},100),U.current=0},te.onerror=W=>{if(console.error("SSE error:",W),S(!1),b({status:ro.ERROR}),te.close(),B.current=null,U.current<ne){const Y=Math.min(1e3*Math.pow(2,U.current),3e4);console.log(`SSE: Reconnecting in ${Y}ms (attempt ${U.current+1}/${ne})`),G.current=setTimeout(()=>{U.current++,Z()},Y)}else console.error("SSE: Max reconnection attempts reached"),b({status:ro.DISCONNECTED})},te.addEventListener("conversation_message",W=>{try{console.log("SSE received conversation_message:",W.data);const Y=JSON.parse(W.data);Y.ConversationMessage&&D.current(Y.ConversationMessage)}catch(Y){console.error("Failed to parse conversation event:",Y)}}),te.addEventListener("platform_event",W=>{try{console.log("SSE received platform_event:",W.data);const Y=JSON.parse(W.data);Y.PlatformEvent&&L.current(Y.PlatformEvent[0],Y.PlatformEvent[1])}catch(Y){console.error("Failed to parse platform event:",Y)}}),te.addEventListener("user_input_request",W=>{try{console.log("SSE received user_input_request:",W.data);const Y=JSON.parse(W.data);Y.UserInputRequest&&M({id:`input-${Date.now()}`,content:Y.UserInputRequest,metadata:{message_type:"user_input_request"}})}catch(Y){console.error("Failed to parse user input request:",Y)}})};return Z(),()=>{console.log("SSE: Cleanup running, closing connection for context:",t),G.current&&(clearTimeout(G.current),G.current=null),B.current&&(B.current.close(),B.current=null),S(!1)}},[t]);const ge=i.useCallback(async(ce,Z,X)=>{if(!(!t||!n)){l(ce),Z&&Z.length>0&&m(Z),X&&X.length>0&&x(X);try{const ee=new FormData;ee.append("agent_name",r),ee.append("message",ce),X&&X.length>0&&X.forEach(W=>{ee.append("files",W)}),(await a(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ee})).ok?(z(!0),$(Ge.RUNNING)):(l(null),m(null),x(null))}catch(ee){console.error("Failed to send message:",ee),l(null),m(null),x(null)}}},[t,r,n,a,K]),pe=i.useCallback(async ce=>{if(!(!t||_!==Ge.WAITING_FOR_INPUT))try{const Z=new FormData;Z.append("agent_name",r),Z.append("user_input",ce),await a(`/api/agent/contexts/${t}/execute`,{method:"POST",body:Z}),$(Ge.RUNNING)}catch(Z){console.error("Failed to submit user input:",Z)}},[t,r,_,a]);i.useEffect(()=>{t&&O.current!==t&&(O.current=t,K())},[t]);const ae=i.useCallback(async()=>{if(!(E||!g||!T.current)){j(!0);try{await K(T.current)}finally{j(!1)}}},[E,g,K]),he=i.useCallback(()=>{p([]),c([]),l(null),m(null),x(null)},[]),Q=i.useCallback(()=>{},[]),Se=i.useCallback(async()=>{if(!(!t||!k))try{const ce=new FormData;ce.append("agent_name",r),ce.append("cancel","true"),await a(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ce}),z(!1),$(Ge.IDLE)}catch(ce){console.error("Failed to cancel execution:",ce)}},[t,k,r,a]);return{messages:s,quickQuestions:f,pendingMessage:d,pendingImages:u,pendingFiles:v,connectionState:w,isConnected:y,isExecuting:k,executionStatus:_,isWaitingForInput:_===Ge.WAITING_FOR_INPUT,hasMoreMessages:g,isLoadingMore:E,sendMessage:ge,submitUserInput:pe,clearMessages:he,loadMoreMessages:ae,cancelExecution:Se,connect:Q,disconnect:()=>{B.current&&(B.current.close(),B.current=null,S(!1))}}}function Mu(t){const{client:r}=Ne(),o=i.useCallback(async()=>{if(!t)return[];const c=await r(`/api/agent/integrations?agent_name=${t}`,{method:"GET"});return(await N(c)).data},[r,t]),{data:n,error:a,mutate:s}=Ue(t?`wacht-agent-integrations:${t}`:null,o,{revalidateOnFocus:!1}),p=i.useCallback(async c=>{const d=`/api/agent/integrations/${c}/consent-url`,l=await r(d,{method:"POST"});return(await N(l)).data},[r]),f=i.useCallback(async c=>{await r(`/api/agent/integrations/${c}/remove`,{method:"POST"}),await s(d=>d&&d.filter(l=>l.id!==c))},[r,s]);return{integrations:n||[],loading:!n&&!a,error:a,generateConsentURL:p,removeIntegration:f,refetch:async()=>{await s()}}}function Au(t){const{client:r}=Ne(),[o,n]=i.useState(!t),[a,s]=i.useState(!!t),[p,f]=i.useState(null),c=i.useRef(!1),d=i.useRef(!1),[l,u]=i.useState(null),m=o,v=i.useCallback(async()=>{const w=await r("/api/agent/session",{method:"GET"});if(!w.ok)throw w.status===401||w.status===403?new Error("NO_SESSION"):new Error("Failed to fetch session");return(await N(w)).data},[r]),{data:x,error:y,isLoading:S,mutate:k}=Ue(m?"wacht-agent-session":null,v,{revalidateOnFocus:!1});i.useEffect(()=>{if(!t||c.current||d.current)return;(async()=>{d.current=!0,s(!0);try{(await r(`/api/agent/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"POST"})).ok?(c.current=!0,n(!0)):f(new Error("Failed to exchange ticket"))}catch(b){f(b instanceof Error?b:new Error("Failed to exchange ticket"))}finally{s(!1),d.current=!1}})()},[t,r]),i.useEffect(()=>{!l&&(x!=null&&x.agents)&&x.agents.length>0&&u(x.agents[0])},[x,l]),i.useEffect(()=>{x!=null&&x.agents&&l&&!x.agents.some(b=>b.id===l.id)&&x.agents.length>0&&u(x.agents[0])},[x,l]);const z=!y||y.message!=="NO_SESSION",_=p||(y&&y.message!=="NO_SESSION"?y:null);return{hasSession:z,sessionLoading:a||m&&S,sessionError:_,sessionId:(x==null?void 0:x.session_id)||null,contextGroup:(x==null?void 0:x.context_group)||null,agents:(x==null?void 0:x.agents)||[],activeAgent:l,setActiveAgent:u,ticketExchanged:o,ticketLoading:a,refetch:async()=>{await k()}}}function Lu(t={}){const{client:r}=Ne(),{limit:o=20,offset:n=0,status:a,search:s}=t,p=i.useCallback(async()=>{const v=new URLSearchParams({limit:String(o),offset:String(n)});a&&v.append("status",a),s&&v.append("search",s);const x=await r(`/api/agent/contexts?${v.toString()}`,{method:"GET"});return(await N(x)).data},[r,o,n,a,s]),{data:f,error:c,mutate:d}=Ue(`wacht-agent-contexts:${o}:${n}:${a}:${s}`,p,{revalidateOnFocus:!1}),l=i.useCallback(async v=>{const x=new FormData;x.append("title",v.title),v.system_instructions&&x.append("system_instructions",v.system_instructions);const y=await r("/api/agent/contexts",{method:"POST",body:x}),S=await N(y);return await d(k=>k&&{...k,data:[S.data,...k.data]}),S.data},[r,d]),u=i.useCallback(async v=>{await r(`/api/agent/contexts/${v}/delete`,{method:"POST"}),await d(x=>x&&{...x,data:x.data.filter(y=>y.id!==v)})},[r,d]),m=i.useCallback(async(v,x)=>{const y=new FormData;if(x.title&&y.append("title",x.title),!(await r(`/api/agent/contexts/${v}/update`,{method:"POST",body:y})).ok)throw new Error("Failed to update context");await d(k=>k&&{...k,data:k.data.map(z=>z.id===v?{...z,...x}:z)})},[r,d]);return{contexts:(f==null?void 0:f.data)||[],loading:!f&&!c,error:c,hasMore:(f==null?void 0:f.has_more)||!1,createContext:l,deleteContext:u,updateContext:m,refetch:async()=>{await d()}}}const Ac=()=>{const{client:t}=Ne(),[r,o]=i.useState(!1),[n,a]=i.useState(null),[s,p]=i.useState(null),f=i.useCallback(async d=>{o(!0),a(null),p(null);try{const l=new FormData;l.append("token",d);const u=await t("/organizations/invitations/accept",{method:"POST",body:l}),v=(await N(u)).data;return p(v),v.error_code&&a(v.message||"Failed to accept invitation"),v}catch(l){const u=l.message||"Failed to accept invitation";a(u);const m={error_code:"NETWORK_ERROR",message:u};return p(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{a(null),p(null)},[]);return{acceptInvitation:f,invitationData:s,loading:r,error:n,reset:c}},Du=({children:t})=>{const{loading:r}=xe();return r?null:e.jsx(e.Fragment,{children:t})},Fu=({children:t})=>{const{loading:r}=xe();return r?e.jsx(e.Fragment,{children:t}):null};var et=function(){return et=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},et.apply(this,arguments)};function cr(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 Nu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var Bu=/^((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=Nu(function(t){return Bu.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ae="-ms-",Vr="-moz-",Pe="-webkit-",Lc="comm",Xo="rule",_a="decl",Wu="@import",Dc="@keyframes",Vu="@layer",Fc=Math.abs,ka=String.fromCharCode,sa=Object.assign;function Gu(t,r){return qe(t,0)^45?(((r<<2^qe(t,0))<<2^qe(t,1))<<2^qe(t,2))<<2^qe(t,3):0}function Nc(t){return t.trim()}function kt(t,r){return(t=r.exec(t))?t[0]:t}function ye(t,r,o){return t.replace(r,o)}function To(t,r,o){return t.indexOf(r,o)}function qe(t,r){return t.charCodeAt(r)|0}function _r(t,r,o){return t.slice(r,o)}function ut(t){return t.length}function Bc(t){return t.length}function Ur(t,r){return r.push(t),t}function Hu(t,r){return t.map(r).join("")}function us(t,r){return t.filter(function(o){return!kt(o,r)})}var en=1,kr=1,Uc=0,ot=0,We=0,$r="";function tn(t,r,o,n,a,s,p,f){return{value:t,root:r,parent:o,type:n,props:a,children:s,line:en,column:kr,length:p,return:"",siblings:f}}function It(t,r){return sa(tn("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function pr(t){for(;t.root;)t=It(t.root,{children:[t]});Ur(t,t.siblings)}function qu(){return We}function Yu(){return We=ot>0?qe($r,--ot):0,kr--,We===10&&(kr=1,en--),We}function nt(){return We=ot<Uc?qe($r,ot++):0,kr++,We===10&&(kr=1,en++),We}function or(){return qe($r,ot)}function Oo(){return ot}function rn(t,r){return _r($r,t,r)}function ia(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 Zu(t){return en=kr=1,Uc=ut($r=t),ot=0,[]}function Ku(t){return $r="",t}function wn(t){return Nc(rn(ot-1,ca(t===91?t+2:t===40?t+1:t)))}function Qu(t){for(;(We=or())&&We<33;)nt();return ia(t)>2||ia(We)>3?"":" "}function Ju(t,r){for(;--r&&nt()&&!(We<48||We>102||We>57&&We<65||We>70&&We<97););return rn(t,Oo()+(r<6&&or()==32&&nt()==32))}function ca(t){for(;nt();)switch(We){case t:return ot;case 34:case 39:t!==34&&t!==39&&ca(We);break;case 40:t===41&&ca(t);break;case 92:nt();break}return ot}function Xu(t,r){for(;nt()&&t+We!==57;)if(t+We===84&&or()===47)break;return"/*"+rn(r,ot-1)+"*"+ka(t===47?t:nt())}function ep(t){for(;!ia(or());)nt();return rn(t,ot)}function tp(t){return Ku(Mo("",null,null,null,[""],t=Zu(t),0,[0],t))}function Mo(t,r,o,n,a,s,p,f,c){for(var d=0,l=0,u=p,m=0,v=0,x=0,y=1,S=1,k=1,z=0,_="",$=a,w=s,b=n,g=_;S;)switch(x=z,z=nt()){case 40:if(x!=108&&qe(g,u-1)==58){To(g+=ye(wn(z),"&","&\f"),"&\f",Fc(d?f[d-1]:0))!=-1&&(k=-1);break}case 34:case 39:case 91:g+=wn(z);break;case 9:case 10:case 13:case 32:g+=Qu(x);break;case 92:g+=Ju(Oo()-1,7);continue;case 47:switch(or()){case 42:case 47:Ur(rp(Xu(nt(),Oo()),r,o,c),c);break;default:g+="/"}break;case 123*y:f[d++]=ut(g)*k;case 125*y:case 59:case 0:switch(z){case 0:case 125:S=0;case 59+l:k==-1&&(g=ye(g,/\f/g,"")),v>0&&ut(g)-u&&Ur(v>32?hs(g+";",n,o,u-1,c):hs(ye(g," ","")+";",n,o,u-2,c),c);break;case 59:g+=";";default:if(Ur(b=ps(g,r,o,d,l,a,f,_,$=[],w=[],u,s),s),z===123)if(l===0)Mo(g,r,b,b,$,s,u,f,w);else switch(m===99&&qe(g,3)===110?100:m){case 100:case 108:case 109:case 115:Mo(t,b,b,n&&Ur(ps(t,b,b,0,0,a,f,_,a,$=[],u,w),w),a,w,u,f,n?$:w);break;default:Mo(g,b,b,b,[""],w,0,f,w)}}d=l=v=0,y=k=1,_=g="",u=p;break;case 58:u=1+ut(g),v=x;default:if(y<1){if(z==123)--y;else if(z==125&&y++==0&&Yu()==125)continue}switch(g+=ka(z),z*y){case 38:k=l>0?1:(g+="\f",-1);break;case 44:f[d++]=(ut(g)-1)*k,k=1;break;case 64:or()===45&&(g+=wn(nt())),m=or(),l=u=ut(_=g+=ep(Oo())),z++;break;case 45:x===45&&ut(g)==2&&(y=0)}}return s}function ps(t,r,o,n,a,s,p,f,c,d,l,u){for(var m=a-1,v=a===0?s:[""],x=Bc(v),y=0,S=0,k=0;y<n;++y)for(var z=0,_=_r(t,m+1,m=Fc(S=p[y])),$=t;z<x;++z)($=Nc(S>0?v[z]+" "+_:ye(_,/&\f/g,v[z])))&&(c[k++]=$);return tn(t,r,o,a===0?Xo:f,c,d,l,u)}function rp(t,r,o,n){return tn(t,r,o,Lc,ka(qu()),_r(t,2,-2),0,n)}function hs(t,r,o,n,a){return tn(t,r,o,_a,_r(t,0,n),_r(t,n+1,-1),n,a)}function Wc(t,r,o){switch(Gu(t,r)){case 5103:return Pe+"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 Pe+t+t;case 4789:return Vr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Pe+t+Vr+t+Ae+t+t;case 5936:switch(qe(t,r+11)){case 114:return Pe+t+Ae+ye(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Pe+t+Ae+ye(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Pe+t+Ae+ye(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return Pe+t+Ae+t+t;case 6165:return Pe+t+Ae+"flex-"+t+t;case 5187:return Pe+t+ye(t,/(\w+).+(:[^]+)/,Pe+"box-$1$2"+Ae+"flex-$1$2")+t;case 5443:return Pe+t+Ae+"flex-item-"+ye(t,/flex-|-self/g,"")+(kt(t,/flex-|baseline/)?"":Ae+"grid-row-"+ye(t,/flex-|-self/g,""))+t;case 4675:return Pe+t+Ae+"flex-line-pack"+ye(t,/align-content|flex-|-self/g,"")+t;case 5548:return Pe+t+Ae+ye(t,"shrink","negative")+t;case 5292:return Pe+t+Ae+ye(t,"basis","preferred-size")+t;case 6060:return Pe+"box-"+ye(t,"-grow","")+Pe+t+Ae+ye(t,"grow","positive")+t;case 4554:return Pe+ye(t,/([^-])(transform)/g,"$1"+Pe+"$2")+t;case 6187:return ye(ye(ye(t,/(zoom-|grab)/,Pe+"$1"),/(image-set)/,Pe+"$1"),t,"")+t;case 5495:case 3959:return ye(t,/(image-set\([^]*)/,Pe+"$1$`$1");case 4968:return ye(ye(t,/(.+:)(flex-)?(.*)/,Pe+"box-pack:$3"+Ae+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Pe+t+t;case 4200:if(!kt(t,/flex-|baseline/))return Ae+"grid-column-align"+_r(t,r)+t;break;case 2592:case 3360:return Ae+ye(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,a){return r=a,kt(n.props,/grid-\w+-end/)})?~To(t+(o=o[r].value),"span",0)?t:Ae+ye(t,"-start","")+t+Ae+"grid-row-span:"+(~To(o,"span",0)?kt(o,/\d+/):+kt(o,/\d+/)-+kt(t,/\d+/))+";":Ae+ye(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return kt(n.props,/grid-\w+-start/)})?t:Ae+ye(ye(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ye(t,/(.+)-inline(.+)/,Pe+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ut(t)-1-r>6)switch(qe(t,r+1)){case 109:if(qe(t,r+4)!==45)break;case 102:return ye(t,/(.+:)(.+)-([^]+)/,"$1"+Pe+"$2-$3$1"+Vr+(qe(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~To(t,"stretch",0)?Wc(ye(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ye(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,a,s,p,f,c,d){return Ae+a+":"+s+d+(p?Ae+a+"-span:"+(f?c:+c-+s)+d:"")+t});case 4949:if(qe(t,r+6)===121)return ye(t,":",":"+Pe)+t;break;case 6444:switch(qe(t,qe(t,14)===45?18:11)){case 120:return ye(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Pe+(qe(t,14)===45?"inline-":"")+"box$3$1"+Pe+"$2$3$1"+Ae+"$2box$3")+t;case 100:return ye(t,":",":"+Ae)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ye(t,"scroll-","scroll-snap-")+t}return t}function Bo(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function op(t,r,o,n){switch(t.type){case Vu:if(t.children.length)break;case Wu:case _a:return t.return=t.return||t.value;case Lc:return"";case Dc:return t.return=t.value+"{"+Bo(t.children,n)+"}";case Xo:if(!ut(t.value=t.props.join(",")))return""}return ut(o=Bo(t.children,n))?t.return=t.value+"{"+o+"}":""}function np(t){var r=Bc(t);return function(o,n,a,s){for(var p="",f=0;f<r;f++)p+=t[f](o,n,a,s)||"";return p}}function ap(t){return function(r){r.root||(r=r.return)&&t(r)}}function sp(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case _a:t.return=Wc(t.value,t.length,o);return;case Dc:return Bo([It(t,{value:ye(t.value,"@","@"+Pe)})],n);case Xo:if(t.length)return Hu(o=t.props,function(a){switch(kt(a,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":pr(It(t,{props:[ye(a,/:(read-\w+)/,":"+Vr+"$1")]})),pr(It(t,{props:[a]})),sa(t,{props:us(o,n)});break;case"::placeholder":pr(It(t,{props:[ye(a,/:(plac\w+)/,":"+Pe+"input-$1")]})),pr(It(t,{props:[ye(a,/:(plac\w+)/,":"+Vr+"$1")]})),pr(It(t,{props:[ye(a,/:(plac\w+)/,Ae+"input-$1")]})),pr(It(t,{props:[a]})),sa(t,{props:us(o,n)});break}return""})}}var ip={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},lr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Vc="active",Gc="data-styled-version",on="6.1.19",Ca=`/*!sc*/
|
|
18
|
+
*/var ns;function Ad(){return ns||(ns=1,process.env.NODE_ENV!=="production"&&function(){function t(v,x){return v===x&&(v!==0||1/v===1/x)||v!==v&&x!==x}function r(v,x){l||a.startTransition===void 0||(l=!0,console.error("You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."));var y=x();if(!u){var k=x();s(y,k)||(console.error("The result of getSnapshot should be cached to avoid an infinite loop"),u=!0)}k=p({inst:{value:y,getSnapshot:x}});var z=k[0].inst,S=k[1];return c(function(){z.value=y,z.getSnapshot=x,o(z)&&S({inst:z})},[v,y,x]),f(function(){return o(z)&&S({inst:z}),v(function(){o(z)&&S({inst:z})})},[v]),d(y),y}function o(v){var x=v.getSnapshot;v=v.value;try{var y=x();return!s(v,y)}catch{return!0}}function n(v,x){return x()}typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());var a=i,s=typeof Object.is=="function"?Object.is:t,p=a.useState,f=a.useEffect,c=a.useLayoutEffect,d=a.useDebugValue,l=!1,u=!1,m=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?n:r;pn.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())}()),pn}var as;function Ld(){return as||(as=1,process.env.NODE_ENV==="production"?Xr.exports=Md():Xr.exports=Ad()),Xr.exports}var Dd=Ld();const yc=0,bc=1,wc=2,ss=3;var is=Object.prototype.hasOwnProperty;function Qn(t,r){var o,n;if(t===r)return!0;if(t&&r&&(o=t.constructor)===r.constructor){if(o===Date)return t.getTime()===r.getTime();if(o===RegExp)return t.toString()===r.toString();if(o===Array){if((n=t.length)===r.length)for(;n--&&Qn(t[n],r[n]););return n===-1}if(!o||typeof t=="object"){n=0;for(o in t)if(is.call(t,o)&&++n&&!is.call(r,o)||!(o in r)||!Qn(t[o],r[o]))return!1;return Object.keys(r).length===n}}return t!==t&&r!==r}const Ct=new WeakMap,Tt=()=>{},Xe=Tt(),Jn=Object,ze=t=>t===Xe,pt=t=>typeof t=="function",Mt=(t,r)=>({...t,...r}),jc=t=>pt(t.then),hn={},eo={},wa="undefined",Yr=typeof window!=wa,Xn=typeof document!=wa,Fd=Yr&&"Deno"in window,Nd=()=>Yr&&typeof window.requestAnimationFrame!=wa,_c=(t,r)=>{const o=Ct.get(t);return[()=>!ze(r)&&t.get(r)||hn,n=>{if(!ze(r)){const a=t.get(r);r in eo||(eo[r]=a),o[5](r,Mt(a,n),a||hn)}},o[6],()=>!ze(r)&&r in eo?eo[r]:!ze(r)&&t.get(r)||hn]};let ea=!0;const Bd=()=>ea,[ta,ra]=Yr&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[Tt,Tt],Ud=()=>{const t=Xn&&document.visibilityState;return ze(t)||t!=="hidden"},Wd=t=>(Xn&&document.addEventListener("visibilitychange",t),ta("focus",t),()=>{Xn&&document.removeEventListener("visibilitychange",t),ra("focus",t)}),Vd=t=>{const r=()=>{ea=!0,t()},o=()=>{ea=!1};return ta("online",r),ta("offline",o),()=>{ra("online",r),ra("offline",o)}},Gd={isOnline:Bd,isVisible:Ud},Hd={initFocus:Wd,initReconnect:Vd},cs=!i.useId,Hr=!Yr||Fd,qd=t=>Nd()?window.requestAnimationFrame(t):setTimeout(t,1),fn=Hr?i.useEffect:i.useLayoutEffect,gn=typeof navigator<"u"&&navigator.connection,ls=!Hr&&gn&&(["slow-2g","2g"].includes(gn.effectiveType)||gn.saveData),to=new WeakMap,Yd=t=>Jn.prototype.toString.call(t),mn=(t,r)=>t===`[object ${r}]`;let Zd=0;const oa=t=>{const r=typeof t,o=Yd(t),n=mn(o,"Date"),a=mn(o,"RegExp"),s=mn(o,"Object");let p,f;if(Jn(t)===t&&!n&&!a){if(p=to.get(t),p)return p;if(p=++Zd+"~",to.set(t,p),Array.isArray(t)){for(p="@",f=0;f<t.length;f++)p+=oa(t[f])+",";to.set(t,p)}if(s){p="#";const c=Jn.keys(t).sort();for(;!ze(f=c.pop());)ze(t[f])||(p+=f+":"+oa(t[f])+",");to.set(t,p)}}else p=n?t.toJSON():r=="symbol"?t.toString():r=="string"?JSON.stringify(t):""+t;return p},ja=t=>{if(pt(t))try{t=t()}catch{t=""}const r=t;return t=typeof t=="string"?t:(Array.isArray(t)?t.length:t)?oa(t):"",[t,r]};let Kd=0;const na=()=>++Kd;async function kc(...t){const[r,o,n,a]=t,s=Mt({populateCache:!0,throwOnError:!0},typeof a=="boolean"?{revalidate:a}:a||{});let p=s.populateCache;const f=s.rollbackOnError;let c=s.optimisticData;const d=m=>typeof f=="function"?f(m):f!==!1,l=s.throwOnError;if(pt(o)){const m=o,v=[],x=r.keys();for(const y of x)!/^\$(inf|sub)\$/.test(y)&&m(r.get(y)._k)&&v.push(y);return Promise.all(v.map(u))}return u(o);async function u(m){const[v]=ja(m);if(!v)return;const[x,y]=_c(r,v),[k,z,S,_]=Ct.get(r),$=()=>{const P=k[v];return(pt(s.revalidate)?s.revalidate(x().data,m):s.revalidate!==!1)&&(delete S[v],delete _[v],P&&P[0])?P[0](wc).then(()=>x().data):x().data};if(t.length<3)return $();let w=n,b,g=!1;const C=na();z[v]=[C,0];const E=!ze(c),j=x(),T=j.data,I=j._c,O=ze(I)?T:I;if(E&&(c=pt(c)?c(O,T):c,y({data:c,_c:O})),pt(w))try{w=w(O)}catch(P){b=P,g=!0}if(w&&jc(w))if(w=await w.catch(P=>{b=P,g=!0}),C!==z[v][0]){if(g)throw b;return w}else g&&E&&d(b)&&(p=!0,y({data:O,_c:Xe}));if(p&&!g)if(pt(p)){const P=p(w,O);y({data:P,error:Xe,_c:Xe})}else y({data:w,error:Xe,_c:Xe});if(z[v][1]=na(),Promise.resolve($()).then(()=>{y({_c:Xe})}),g){if(l)throw b;return}return w}}const ds=(t,r)=>{for(const o in t)t[o][0]&&t[o][0](r)},Qd=(t,r)=>{if(!Ct.has(t)){const o=Mt(Hd,r),n=Object.create(null),a=kc.bind(Xe,t);let s=Tt;const p=Object.create(null),f=(l,u)=>{const m=p[l]||[];return p[l]=m,m.push(u),()=>m.splice(m.indexOf(u),1)},c=(l,u,m)=>{t.set(l,u);const v=p[l];if(v)for(const x of v)x(u,m)},d=()=>{if(!Ct.has(t)&&(Ct.set(t,[n,Object.create(null),Object.create(null),Object.create(null),a,c,f]),!Hr)){const l=o.initFocus(setTimeout.bind(Xe,ds.bind(Xe,n,yc))),u=o.initReconnect(setTimeout.bind(Xe,ds.bind(Xe,n,bc)));s=()=>{l&&l(),u&&u(),Ct.delete(t)}}};return d(),[t,a,d,s]}return[t,Ct.get(t)[4]]},Jd=(t,r,o,n,a)=>{const s=o.errorRetryCount,p=a.retryCount,f=~~((Math.random()+.5)*(1<<(p<8?p:8)))*o.errorRetryInterval;!ze(s)&&p>s||setTimeout(n,f,a)},Xd=Qn,[Cc,Nr]=Qd(new Map),eu=Mt({onLoadingSlow:Tt,onSuccess:Tt,onError:Tt,onErrorRetry:Jd,onDiscarded:Tt,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:ls?1e4:5e3,focusThrottleInterval:5*1e3,dedupingInterval:2*1e3,loadingTimeout:ls?5e3:3e3,compare:Xd,isPaused:()=>!1,cache:Cc,mutate:Nr,fallback:{}},Gd),tu=(t,r)=>{const o=Mt(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=Mt(a,p))}return o},ru=i.createContext({}),ou="$inf$",Sc=Yr&&window.__SWR_DEVTOOLS_USE__,nu=Sc?window.__SWR_DEVTOOLS_USE__:[],au=()=>{Sc&&(window.__SWR_DEVTOOLS_REACT__=i)},su=t=>pt(t[1])?[t[0],t[1],t[2]||{}]:[t[0],null,(t[1]===null?t[2]:t[1])||{}],zc=()=>Mt(eu,i.useContext(ru)),iu=t=>(r,o,n)=>t(r,o&&((...s)=>{const[p]=ja(r),[,,,f]=Ct.get(Cc);if(p.startsWith(ou))return o(...s);const c=f[p];return ze(c)?o(...s):(delete f[p],c)}),n),cu=nu.concat(iu),lu=t=>function(...o){const n=zc(),[a,s,p]=su(o),f=tu(n,p);let c=t;const{use:d}=f,l=(d||[]).concat(cu);for(let u=l.length;u--;)c=l[u](c);return c(a,s||f.fetcher||null,f)},du=(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())}};au();const xn=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}}),vn={dedupe:!0},uu=(t,r,o)=>{const{cache:n,compare:a,suspense:s,fallbackData:p,revalidateOnMount:f,revalidateIfStale:c,refreshInterval:d,refreshWhenHidden:l,refreshWhenOffline:u,keepPreviousData:m}=o,[v,x,y,k]=Ct.get(n),[z,S]=ja(t),_=i.useRef(!1),$=i.useRef(!1),w=i.useRef(z),b=i.useRef(r),g=i.useRef(o),C=()=>g.current,E=()=>C().isVisible()&&C().isOnline(),[j,T,I,O]=_c(n,z),P=i.useRef({}).current,M=ze(p)?ze(o.fallback)?Xe:o.fallback[z]:p,F=(Z,X)=>{for(const ee in P){const te=ee;if(te==="data"){if(!a(Z[te],X[te])&&(!ze(Z[te])||!a(K,X[te])))return!1}else if(X[te]!==Z[te])return!1}return!0},D=i.useMemo(()=>{const Z=!z||!r?!1:ze(f)?C().isPaused()||s?!1:c!==!1:f,X=le=>{const q=Mt(le);return delete q._k,Z?{isValidating:!0,isLoading:!0,...q}:q},ee=j(),te=O(),W=X(ee),Y=ee===te?W:X(te);let se=W;return[()=>{const le=X(j());return F(le,se)?(se.data=le.data,se.isLoading=le.isLoading,se.isValidating=le.isValidating,se.error=le.error,se):(se=le,le)},()=>Y]},[n,z]),L=Dd.useSyncExternalStore(i.useCallback(Z=>I(z,(X,ee)=>{F(ee,X)||Z()}),[n,z]),D[0],D[1]),R=!_.current,A=v[z]&&v[z].length>0,B=L.data,G=ze(B)?M&&jc(M)?xn(M):M:B,U=L.error,ne=i.useRef(G),K=m?ze(B)?ze(ne.current)?G:ne.current:B:G,ge=A&&!ze(U)?!1:R&&!ze(f)?f:C().isPaused()?!1:s?ze(G)?!1:c:ze(G)||c,pe=!!(z&&r&&R&&ge),ae=ze(L.isValidating)?pe:L.isValidating,he=ze(L.isLoading)?pe:L.isLoading,Q=i.useCallback(async Z=>{const X=b.current;if(!z||!X||$.current||C().isPaused())return!1;let ee,te,W=!0;const Y=Z||{},se=!y[z]||!Y.dedupe,le=()=>cs?!$.current&&z===w.current&&_.current:z===w.current,q={isValidating:!1,isLoading:!1},me=()=>{T(q)},H=()=>{const Te=y[z];Te&&Te[1]===te&&delete y[z]},we={isValidating:!0};ze(j().data)&&(we.isLoading=!0);try{if(se&&(T(we),o.loadingTimeout&&ze(j().data)&&setTimeout(()=>{W&&le()&&C().onLoadingSlow(z,o)},o.loadingTimeout),y[z]=[X(S),na()]),[ee,te]=y[z],ee=await ee,se&&setTimeout(H,o.dedupingInterval),!y[z]||y[z][1]!==te)return se&&le()&&C().onDiscarded(z),!1;q.error=Xe;const Te=x[z];if(!ze(Te)&&(te<=Te[0]||te<=Te[1]||Te[1]===0))return me(),se&&le()&&C().onDiscarded(z),!1;const Ye=j().data;q.data=a(Ye,ee)?Ye:ee,se&&le()&&C().onSuccess(ee,z,o)}catch(Te){H();const Ye=C(),{shouldRetryOnError:Re}=Ye;Ye.isPaused()||(q.error=Te,se&&le()&&(Ye.onError(Te,z,Ye),(Re===!0||pt(Re)&&Re(Te))&&(!C().revalidateOnFocus||!C().revalidateOnReconnect||E())&&Ye.onErrorRetry(Te,z,Ye,Wt=>{const bt=v[z];bt&&bt[0]&&bt[0](ss,Wt)},{retryCount:(Y.retryCount||0)+1,dedupe:!0})))}return W=!1,me(),!0},[z,n]),Se=i.useCallback((...Z)=>kc(n,w.current,...Z),[]);if(fn(()=>{b.current=r,g.current=o,ze(B)||(ne.current=B)}),fn(()=>{if(!z)return;const Z=Q.bind(Xe,vn);let X=0;C().revalidateOnFocus&&(X=Date.now()+C().focusThrottleInterval);const te=du(z,v,(W,Y={})=>{if(W==yc){const se=Date.now();C().revalidateOnFocus&&se>X&&E()&&(X=se+C().focusThrottleInterval,Z())}else if(W==bc)C().revalidateOnReconnect&&E()&&Z();else{if(W==wc)return Q();if(W==ss)return Q(Y)}});return $.current=!1,w.current=z,_.current=!0,T({_k:S}),ge&&(y[z]||(ze(G)||Hr?Z():qd(Z))),()=>{$.current=!0,te()}},[z]),fn(()=>{let Z;function X(){const te=pt(d)?d(j().data):d;te&&Z!==-1&&(Z=setTimeout(ee,te))}function ee(){!j().error&&(l||C().isVisible())&&(u||C().isOnline())?Q(vn).then(X):X()}return X(),()=>{Z&&(clearTimeout(Z),Z=-1)}},[d,l,u,z]),i.useDebugValue(K),s&&ze(G)&&z){if(!cs&&Hr)throw new Error("Fallback data is required when using Suspense in SSR.");b.current=r,g.current=o,$.current=!1;const Z=k[z];if(!ze(Z)){const X=Se(Z);xn(X)}if(ze(U)){const X=Q(vn);ze(K)||(X.status="fulfilled",X.value=!0),xn(X)}else throw U}return{mutate:Se,get data(){return P.data=!0,K},get error(){return P.error=!0,U},get isValidating(){return P.isValidating=!0,ae},get isLoading(){return P.isLoading=!0,he}}},Ue=lu(uu),Je=()=>{const{adapter:t,deployment:r}=xe(),o=t.useNavigate(),n=(c,d)=>{o?o(c,d):window.location.href=c},a=c=>{if(c)return c;const l=new URLSearchParams(window.location.search).get("redirect_uri");return l||window.location.href};return{navigate:n,navigateToSignIn:c=>{if(!r)return;const d=a(c),l=new URLSearchParams;l.set("redirect_uri",d),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_in_page_url}?${l.toString()}`,{replace:!0})},navigateToAccountSelection:c=>{if(!r)return;const d=a(c),l=new URLSearchParams;l.set("redirect_uri",d),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`https://${r.frontend_host}?${l.toString()}`,{replace:!0})},navigateToSignUp:c=>{if(!r)return;const d=a(c),l=new URLSearchParams;l.set("redirect_uri",d),(r==null?void 0:r.mode)==="staging"&&l.set("__dev_session__",localStorage.getItem("__dev_session__")??""),n(`${r.ui_settings.sign_up_page_url}?${l.toString()}`,{replace:!0})}}};async function pu(t){const r=await t("/session",{method:"GET"});return(await N(r)).data}async function hu(t,r){const o=await t(`/session/switch-sign-in?sign_in_id=${r}`,{method:"POST"});return N(o)}async function fu(t,r){const o=r?`/session/sign-out?sign_in_id=${r}`:"/session/sign-out",n=await t(o,{method:"POST"});return N(n)}async function gu(t,r){const o=await t(`/session/switch-organization${r?`?organization_id=${r}`:""}`,{method:"POST"});return N(o)}async function mu(t,r){const o=await t(`/session/switch-workspace?workspace_id=${r}`,{method:"POST"});return N(o)}const aa=new Map,Br=new Map;function St(){aa.clear(),Br.clear()}async function xu(t,r){const o=await t(`/session/token${r?`?template=${r}`:""}`);return N(o)}function He(){const{client:t,loading:r}=Ne(),{deployment:o}=xe(),{navigate:n}=Je(),{cache:a}=zc(),{data:s,error:p,mutate:f,isLoading:c}=Ue(r?null:"/session",()=>pu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),d=i.useCallback(async()=>{await f(void 0,{revalidate:!0})},[f]),l=i.useCallback(async(u="default")=>{if(!s)throw new Error("no session");const m=aa.get(u);if(m&&m.expires>Date.now())return(m==null?void 0:m.token)||"";Br.get(u)||Br.set(u,xu(t,u));const v=await Br.get(u);return Br.delete(u),aa.set(u,v.data),v.data.token},[t,s==null?void 0:s.active_signin]);return r||!s||c?{loading:!0,error:p,session:null,switchSignIn:null,switchOrganization:null,switchWorkspace:null,signOut:null,getToken:null,refetch:d}:{loading:c,error:p,session:s,switchSignIn:async u=>{await hu(t,u),St(),await Nr("/me/organization-memberships",void 0,{revalidate:!1}),await Nr("/me/workspace-memberships",void 0,{revalidate:!1}),await f(void 0,{revalidate:!0}),await Nr("/me/organization-memberships"),await Nr("/me/workspace-memberships")},signOut:async u=>{await fu(t,u);const m=["/session","/user","/me/signins","/me/organization-memberships","/me/workspace-memberships","wacht-notifications:channel-counts"],v=["wacht-notifications:","wacht-agent-sessions:","wacht-agent-contexts:","wacht-org-domains:","wacht-api-workspaces:","wacht-api-organizations:"];if(a instanceof Map){const x=Array.from(a.keys());for(const y of x){let k=!1;(m.includes(y)||typeof y=="string"&&v.some(z=>y.startsWith(z)))&&(k=!0),k&&a.delete(y)}}St(),await f(void 0,{revalidate:!0}),o!=null&&o.ui_settings&&(u&&o.ui_settings.after_sign_out_one_page_url?n(o.ui_settings.after_sign_out_one_page_url):!u&&o.ui_settings.after_sign_out_all_page_url&&n(o.ui_settings.after_sign_out_all_page_url))},switchOrganization:async u=>{await gu(t,u),St(),await f(void 0,{revalidate:!0})},switchWorkspace:async u=>{await mu(t,u),St(),await f(void 0,{revalidate:!0})},getToken:l,refetch:d}}const Qo=()=>{const{organizationMemberships:t,refetch:r,loading:o}=$t(),{client:n}=Ne(),{refetch:a}=He(),s=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/roles`,{method:"GET"}))).data,[n]),p=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/members`,{method:"GET"}))).data,[n]),f=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/invitations`,{method:"GET"}))).data,[n]),c=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/domains`,{method:"GET"}))).data,[n]),d=i.useCallback(async(L,R)=>{await n(`/organizations/${L.id}/members/${R.id}/remove`,{method:"POST"})},[n]),l=i.useCallback(async L=>{const R=new FormData;R.append("name",L.name),L.image&&R.append("image",L.image),L.description&&R.append("description",L.description);const A=await N(await n("/organizations",{method:"POST",body:R}));return St(),await r(),await a(),A},[a,r,n]),u=i.useCallback(async(L,R)=>{const A=Object.entries(R).reduce((G,[U,ne])=>(ne&&G.append(U,ne),G),new FormData),B=await N(await n(`/organizations/${L.id}/update`,{method:"POST",body:A}));return await r(),B},[r,n]),m=i.useCallback(async(L,R)=>{await n(`/organizations/${L.id}/roles/${R.id}/remove`,{method:"POST"})},[n]),v=i.useCallback(async(L,R)=>{const A=new FormData;return A.append("domain",R.fqdn),await N(await n(`/organizations/${L.id}/domains`,{method:"POST",body:A}))},[n]),x=i.useCallback(async(L,R)=>await N(await n(`/organizations/${L.id}/domains/${R.id}/verify`,{method:"POST"})),[n]),y=i.useCallback(async(L,R)=>await N(await n(`/organizations/${L.id}/domains/${R.id}/delete`,{method:"POST"})),[n]),k=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/enterprise-connections`,{method:"GET"}))).data,[n]),z=i.useCallback(async(L,R)=>{const A=new FormData;return A.append("protocol",R.protocol),R.domain_id&&A.append("domain_id",R.domain_id),R.idp_entity_id&&A.append("idp_entity_id",R.idp_entity_id),R.idp_sso_url&&A.append("idp_sso_url",R.idp_sso_url),R.idp_certificate&&A.append("idp_certificate",R.idp_certificate),R.oidc_client_id&&A.append("oidc_client_id",R.oidc_client_id),R.oidc_client_secret&&A.append("oidc_client_secret",R.oidc_client_secret),R.oidc_issuer_url&&A.append("oidc_issuer_url",R.oidc_issuer_url),R.oidc_scopes&&A.append("oidc_scopes",R.oidc_scopes),R.jit_enabled!==void 0&&A.append("jit_enabled",String(R.jit_enabled)),R.attribute_mapping&&A.append("attribute_mapping",JSON.stringify(R.attribute_mapping)),(await N(await n(`/organizations/${L.id}/enterprise-connections`,{method:"POST",body:A}))).data},[n]),S=i.useCallback(async(L,R,A)=>{const B=new FormData;return A.domain_id&&B.append("domain_id",A.domain_id),A.idp_entity_id&&B.append("idp_entity_id",A.idp_entity_id),A.idp_sso_url&&B.append("idp_sso_url",A.idp_sso_url),A.idp_certificate&&B.append("idp_certificate",A.idp_certificate),A.oidc_client_id&&B.append("oidc_client_id",A.oidc_client_id),A.oidc_client_secret&&B.append("oidc_client_secret",A.oidc_client_secret),A.oidc_issuer_url&&B.append("oidc_issuer_url",A.oidc_issuer_url),A.oidc_scopes&&B.append("oidc_scopes",A.oidc_scopes),A.attribute_mapping&&B.append("attribute_mapping",JSON.stringify(A.attribute_mapping)),(await N(await n(`/organizations/${L.id}/enterprise-connections/${R}/update`,{method:"POST",body:B}))).data},[n]),_=i.useCallback(async(L,R)=>{await n(`/organizations/${L.id}/enterprise-connections/${R}/delete`,{method:"POST"})},[n]),$=i.useCallback(async(L,R)=>{const A=new FormData;return A.append("protocol",R.protocol),R.idp_entity_id&&A.append("idp_entity_id",R.idp_entity_id),R.idp_sso_url&&A.append("idp_sso_url",R.idp_sso_url),R.idp_certificate&&A.append("idp_certificate",R.idp_certificate),R.oidc_issuer_url&&A.append("oidc_issuer_url",R.oidc_issuer_url),R.oidc_client_id&&A.append("oidc_client_id",R.oidc_client_id),R.oidc_client_secret&&A.append("oidc_client_secret",R.oidc_client_secret),(await N(await n(`/organizations/${L.id}/enterprise-connections/test`,{method:"POST",body:A}))).data},[n]),w=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/enterprise-connections/${R}/test`,{method:"POST"}))).data,[n]),b=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/enterprise-connections/${R}/scim/token`,{method:"POST"}))).data,[n]),g=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/enterprise-connections/${R}/scim/token`,{method:"GET"}))).data,[n]),C=i.useCallback(async(L,R)=>{await n(`/organizations/${L.id}/enterprise-connections/${R}/scim/token/revoke`,{method:"POST"})},[n]),E=i.useCallback(async(L,R)=>{const A=new FormData;return A.append("name",R.name),R.permissions&&R.permissions.forEach((G,U)=>{A.append(`permissions[${U}]`,G)}),await N(await n(`/organizations/${L.id}/roles`,{method:"POST",body:A}))},[n]),j=i.useCallback(async L=>(await N(await n(`/organizations/${L.id}/leave`,{method:"POST"}))).data,[n]),T=i.useCallback(async L=>{const R=await N(await n(`/organizations/${L.id}/delete`,{method:"POST"}));return St(),await r(),await a(),R.data},[n,r,a]),I=i.useCallback(async(L,R,A)=>(await N(await n(`/organizations/${L.id}/members/${R.id}/roles/${A.id}/add`,{method:"POST"}))).data,[n]),O=i.useCallback(async(L,R,A)=>(await N(await n(`/organizations/${L.id}/members/${R.id}/roles/${A.id}/remove`,{method:"POST"}))).data,[n]),P=i.useCallback(async(L,R)=>{var G,U;const A=new FormData;return A.append("email",R.email),A.append("role_id",R.organizationRole.id),(G=R.workspace)!=null&&G.id&&A.append("workspace_id",R.workspace.id),(U=R.workspaceRole)!=null&&U.id&&A.append("workspace_role_id",R.workspaceRole.id),(await N(await n(`/organizations/${L.id}/invitations`,{method:"POST",body:A}))).data},[n]),M=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/invitations/${R.id}/discard`,{method:"POST"}))).data,[n]),F=i.useCallback(async(L,R)=>(await N(await n(`/organizations/${L.id}/invitations/${R.id}/resend`,{method:"POST"}))).data,[n]);return{organizations:i.useMemo(()=>t==null?void 0:t.map(L=>L.organization),[t]),loading:o,error:null,refetch:r,leaveOrganization:j,getOrganizationRoles:s,getOrganizationMembers:p,removeOrganizationMember:d,createOrganization:l,getOrganizationInvitations:f,getOrganizationDomains:c,addOrganizationDomain:v,verifyOrganizationDomain:x,removeOrganizationDomain:y,addRoleToOrganizationMember:I,removeRoleFromOrganizationMember:O,inviteOrganizationMember:P,discardOrganizationInvitation:M,resendOrganizationInvitation:F,updateOrganization:u,addRole:E,removeOrganizationRoles:m,deleteOrganization:T,getEnterpriseConnections:k,createEnterpriseConnection:z,updateEnterpriseConnection:S,deleteEnterpriseConnection:_,testEnterpriseConnectionConfig:$,testEnterpriseConnection:w,generateSCIMToken:b,getSCIMToken:g,revokeSCIMToken:C}},tt=()=>{const{loading:t,error:r,refetch:o,getOrganizationMembers:n,getOrganizationRoles:a,leaveOrganization:s,removeOrganizationMember:p,getOrganizationInvitations:f,getOrganizationDomains:c,removeOrganizationDomain:d,addOrganizationDomain:l,verifyOrganizationDomain:u,addRoleToOrganizationMember:m,removeRoleFromOrganizationMember:v,inviteOrganizationMember:x,discardOrganizationInvitation:y,resendOrganizationInvitation:k,updateOrganization:z,removeOrganizationRoles:S,getEnterpriseConnections:_,createEnterpriseConnection:$,updateEnterpriseConnection:w,deleteEnterpriseConnection:b,testEnterpriseConnectionConfig:g,testEnterpriseConnection:C,generateSCIMToken:E,getSCIMToken:j,revokeSCIMToken:T}=Qo(),{session:I,error:O,loading:P}=He(),{organizationMemberships:M}=$t(),F=i.useMemo(()=>(M==null?void 0:M.find(H=>{var we;return H.id===((we=I==null?void 0:I.active_signin)==null?void 0:we.active_organization_membership_id)}))||null,[M,I]),D=i.useMemo(()=>(F==null?void 0:F.organization)||null,[F]),L=i.useCallback(async H=>D?await z(D,H):[],[D,z]),R=i.useCallback(async()=>D?await n(D):[],[D,n]),A=i.useCallback(async()=>D?await a(D):[],[D,a]),B=i.useCallback(async H=>D?await p(D,H):[],[D,p]),G=i.useCallback(async H=>D?await S(D,H):void 0,[D,S]),U=i.useCallback(async()=>D?await c(D):[],[D,c]),ne=i.useCallback(async H=>D?await l(D,H):void 0,[D,l]),K=i.useCallback(async H=>D?await u(D,H):void 0,[D,u]),ge=i.useCallback(async H=>D?await d(D,H):void 0,[D,d]),pe=i.useCallback(async(H,we)=>D?await m(D,H,we):void 0,[D,m]),ae=i.useCallback(async(H,we)=>D?await v(D,H,we):void 0,[D,v]),he=i.useCallback(async H=>D?await x(D,H):void 0,[D,x]),Q=i.useCallback(async H=>D?await y(D,H):void 0,[D,y]),Se=i.useCallback(async H=>D?await k(D,H):void 0,[D,k]),ce=i.useCallback(async()=>{D&&await s(D)},[D,s]),Z=i.useCallback(async()=>D?await f(D):[],[D,f]),X=i.useCallback(async()=>D?await _(D):[],[D,_]),ee=i.useCallback(async H=>{if(D)return await $(D,H)},[D,$]),te=i.useCallback(async(H,we)=>{if(D)return await w(D,H,we)},[D,w]),W=i.useCallback(async H=>{D&&await b(D,H)},[D,b]),Y=i.useCallback(async H=>D?await g(D,H):null,[D,g]),se=i.useCallback(async H=>D?await C(D,H):null,[D,C]),le=i.useCallback(async H=>{if(D)return await E(D,H)},[D,E]),q=i.useCallback(async H=>{if(D)return await j(D,H)},[D,j]),me=i.useCallback(async H=>{D&&await T(D,H)},[D,T]);return P||t?{activeOrganization:null,activeMembership:null,loading:!0,error:O||r,updateOrganization:null,getRoles:null,getMembers:null,getDomains:null,addDomain:null,verifyDomain:null,removeDomain:null,removeRole:null,getInvitations:null,removeMember:null,addMemberRole:null,removeMemberRole:null,inviteMember:null,discardInvitation:null,resendInvitation:null,leave:null,getEnterpriseConnections:null,createEnterpriseConnection:null,updateEnterpriseConnection:null,deleteEnterpriseConnection:null,generateSCIMToken:null,getSCIMToken:null,revokeSCIMToken:null}:{activeOrganization:D,activeMembership:F,loading:!1,refetch:o,getRoles:A,updateOrganization:L,getMembers:R,getDomains:U,addDomain:ne,verifyDomain:K,removeDomain:ge,getInvitations:Z,removeMember:B,leave:ce,removeRole:G,addMemberRole:pe,removeMemberRole:ae,inviteMember:he,discardInvitation:Q,resendInvitation:Se,getEnterpriseConnections:X,createEnterpriseConnection:ee,updateEnterpriseConnection:te,deleteEnterpriseConnection:W,testEnterpriseConnectionConfig:Y,testEnterpriseConnection:se,generateSCIMToken:le,getSCIMToken:q,revokeSCIMToken:me,error:null}};async function vu(t){return(await N(await t("/me/organization-memberships"))).data}const $t=()=>{const{client:t,loading:r}=Ne(),{data:o,isLoading:n,error:a,mutate:s}=Ue(r?null:"/me/organization-memberships",()=>vu(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 yu(t){return(await N(await t("/me/workspace-memberships"))).data}async function bu(t,r,o){return(await N(await t(`/workspaces/${r}/members/${o}/remove`,{method:"POST"}))).data}const Jo=()=>{const{client:t,loading:r}=Ne(),{deployment:o}=xe(),{data:n,isLoading:a,error:s,mutate:p}=Ue(!r&&(o!=null&&o.b2b_settings.workspaces_enabled)?"/me/workspace-memberships":null,()=>yu(t),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,revalidateIfStale:!1,dedupingInterval:5e3}),f=i.useCallback(async()=>{await p(void 0,{revalidate:!0})},[p]);return{workspaceMemberships:n,loading:r||a,error:s,refetch:f}},Lt=()=>{const{workspaceMemberships:t,refetch:r,loading:o,error:n}=Jo(),{client:a}=Ne(),s=i.useMemo(()=>t==null?void 0:t.map(w=>({...w.workspace,organization:w.organization,eligibility_restriction:w.eligibility_restriction})),[t]),p=i.useCallback(async(w,b,g,C)=>{const E=new FormData;E.append("name",b),g&&E.append("image",g),C&&E.append("description",C),E.append("organization_id",w);const j=await N(await a("/workspaces",{method:"POST",body:E}));return St(),await r(),j.data},[a,r]),f=i.useCallback(async(w,b)=>{const g=await bu(a,w,b);return await r(),g},[a,r]),c=i.useCallback(async(w,b)=>{const g=new FormData;b.name&&g.append("name",b.name),b.description&&g.append("description",b.description),b.image&&g.append("image",b.image),b.enforce_2fa!==void 0&&g.append("enforce_2fa",String(b.enforce_2fa)),b.enable_ip_restriction!==void 0&&g.append("enable_ip_restriction",String(b.enable_ip_restriction)),b.whitelisted_ips&&b.whitelisted_ips.forEach(E=>g.append("whitelisted_ips",E));const C=await N(await a(`/workspaces/${w.id}/update`,{method:"POST",body:g}));return await r(),C.data},[a,r]),d=i.useCallback(async w=>{const b=await N(await a(`/workspaces/${w.id}/delete`,{method:"POST"}));return St(),await r(),b.data},[a,r]),l=i.useCallback(async w=>(await N(await a(`/workspaces/${w.id}/members`,{method:"GET"}))).data,[a]),u=i.useCallback(async w=>(await N(await a(`/workspaces/${w.id}/roles`,{method:"GET"}))).data,[a]),m=i.useCallback(async(w,b,g)=>{const C=new FormData;return C.append("name",b),g.forEach(j=>C.append("permissions",j)),(await N(await a(`/workspaces/${w.id}/roles`,{method:"POST",body:C}))).data},[a]),v=i.useCallback(async(w,b)=>(await N(await a(`/workspaces/${w.id}/roles/${b.id}/delete`,{method:"POST"}))).data,[a]),x=i.useCallback(async(w,b)=>{const g=await N(await a(`/workspaces/${w.id}/members/${b}/remove`,{method:"POST"}));return await r(),g.data},[a,r]),y=i.useCallback(async(w,b,g)=>(await N(await a(`/workspaces/${w.id}/members/${b}/roles/${g}/add`,{method:"POST"}))).data,[a]),k=i.useCallback(async(w,b,g)=>(await N(await a(`/workspaces/${w.id}/members/${b}/roles/${g}/remove`,{method:"POST"}))).data,[a]),z=i.useCallback(async w=>(await N(await a(`/organizations/${w.organization.id}/invitations`,{method:"GET"}))).data.filter(g=>String(g.workspace_id)===String(w.id)),[a]),S=i.useCallback(async(w,b,g)=>{const C=new FormData;return C.append("email",b),C.append("workspace_id",w.id),g&&C.append("workspace_role_id",g),(await N(await a(`/organizations/${w.organization.id}/invitations`,{method:"POST",body:C}))).data},[a]),_=i.useCallback(async(w,b)=>(await N(await a(`/organizations/${w.organization.id}/invitations/${b}/discard`,{method:"POST"}))).data,[a]),$=i.useCallback(async(w,b)=>(await N(await a(`/organizations/${w.organization.id}/invitations/${b}/resend`,{method:"POST"}))).data,[a]);return{workspaces:s||[],loading:o,error:n,refetch:r,leaveWorkspace:f,createWorkspace:p,updateWorkspace:c,deleteWorkspace:d,getWorkspaceMembers:l,getWorkspaceRoles:u,createWorkspaceRole:m,deleteWorkspaceRole:v,removeWorkspaceMember:x,addWorkspaceMemberRole:y,removeWorkspaceMemberRole:k,getWorkspaceInvitations:z,createWorkspaceInvitation:S,discardWorkspaceInvitation:_,resendWorkspaceInvitation:$}},Dt=()=>{const{refetch:t,loading:r,error:o,workspaces:n,leaveWorkspace:a,updateWorkspace:s,deleteWorkspace:p,getWorkspaceMembers:f,getWorkspaceRoles:c,createWorkspaceRole:d,deleteWorkspaceRole:l,removeWorkspaceMember:u,addWorkspaceMemberRole:m,removeWorkspaceMemberRole:v,getWorkspaceInvitations:x,createWorkspaceInvitation:y,discardWorkspaceInvitation:k,resendWorkspaceInvitation:z}=Lt(),{workspaceMemberships:S}=Jo(),{session:_,loading:$,error:w}=He(),b=i.useMemo(()=>(S==null?void 0:S.find(K=>{var ge;return K.id===((ge=_==null?void 0:_.active_signin)==null?void 0:ge.active_workspace_membership_id)}))||null,[S,_]),g=i.useMemo(()=>(b==null?void 0:b.workspace)||null,[b]),C=i.useCallback(async()=>{var K;if(!(!g||!((K=_==null?void 0:_.active_signin)!=null&&K.user_id)))return await a(g.id,_.active_signin.user_id)},[g,a,_]),E=i.useCallback(async K=>{if(g)return await s(g,K)},[g,s]),j=i.useCallback(async()=>{if(g)return await p(g)},[g,p]),T=i.useCallback(async()=>g?await f(g):[],[g,f]),I=i.useCallback(async()=>g?await c(g):[],[g,c]),O=i.useCallback(async(K,ge)=>{if(g)return await d(g,K,ge)},[g,d]),P=i.useCallback(async K=>{if(g)return await l(g,K)},[g,l]),M=i.useCallback(async K=>{if(g)return await u(g,K)},[g,u]),F=i.useCallback(async(K,ge)=>{if(g)return await m(g,K,ge)},[g,m]),D=i.useCallback(async(K,ge)=>{if(g)return await v(g,K,ge)},[g,v]),L=i.useMemo(()=>(n==null?void 0:n.find(K=>K.id===(g==null?void 0:g.id)))||null,[n,g]),R=i.useCallback(async()=>L?await x(L):[],[L,x]),A=i.useCallback(async(K,ge)=>{if(L)return await y(L,K,ge)},[L,y]),B=i.useCallback(async K=>{if(L)return await k(L,K)},[L,k]),G=i.useCallback(async K=>{if(L)return await z(L,K)},[L,z]),U=r||$,ne=o||w;return U?{activeWorkspace:null,activeMembership:null,loading:!0,error:ne,refetch:t,leave:null,updateWorkspace:null,deleteWorkspace:null,getMembers:null,getRoles:null,createRole:null,deleteRole:null,inviteMember:null,removeMember:null,addMemberRole:null,removeMemberRole:null,getInvitations:null,discardInvitation:null,resendInvitation:null}:{activeWorkspace:g,activeMembership:b,loading:!1,error:ne,refetch:t,leave:C,updateWorkspace:E,deleteWorkspace:j,getMembers:T,getRoles:I,createRole:O,deleteRole:P,inviteMember:A,removeMember:M,addMemberRole:F,removeMemberRole:D,getInvitations:R,discardInvitation:B,resendInvitation:G}};function yn(t){const r=new Uint8Array(t);let o="";for(let n=0;n<r.length;n++)o+=String.fromCharCode(r[n]);return btoa(o).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function bn(t){const r=t.replace(/-/g,"+").replace(/_/g,"/"),o=r.padEnd(r.length+(4-r.length%4)%4,"="),n=atob(o),a=new Uint8Array(n.length);for(let s=0;s<n.length;s++)a[s]=n.charCodeAt(s);return a.buffer}const wu=async t=>(await N(await t("/me"))).data,ju=async t=>(await N(await t("/me/signins"))).data;function Ft(){const{client:t,loading:r}=Ne(),{data:o,error:n,isLoading:a,mutate:s}=Ue(r?null:"/user",()=>wu(t)),p=async L=>{const R=new FormData;for(const[B,G]of Object.entries(L))G!=null&&G!==""&&R.append(B,String(G));const A=await N(await t("/me",{method:"POST",body:R}));return s(),A},f=async()=>await N(await t("/me/email-addresses",{method:"GET"})),c=async L=>await N(await t(`/me/email-addresses/${L}`,{method:"GET"})),d=async L=>{const R=new FormData;return R.append("email",L),await N(await t("/me/email-addresses",{method:"POST",body:R}))},l=async L=>await N(await t(`/me/email-addresses/${L}/delete`,{method:"POST"})),u=async L=>await N(await t(`/me/email-addresses/${L}/prepare-verification`,{method:"POST"})),m=async(L,R)=>await N(await t(`/me/email-addresses/${L}/attempt-verification?code=${R}`,{method:"POST"})),v=async(L,R)=>{const A=new FormData;return A.append("phone_number",L),A.append("country_code",R),await N(await t("/me/phone-numbers",{method:"POST",body:A}))},x=async L=>await N(await t(`/me/phone-numbers/${L}/delete`,{method:"POST"})),y=async L=>await N(await t(`/me/phone-numbers/${L}/prepare-verification`,{method:"POST"})),k=async(L,R)=>{const A=new FormData;return A.append("code",R),await N(await t(`/me/phone-numbers/${L}/attempt-verification`,{method:"POST",body:A}))},z=async L=>{const R=await N(await t(`/me/phone-numbers/${L}/make-primary`,{method:"POST"}));return s(),R},S=async L=>await N(await t(`/me/email-addresses/${L}/make-primary`,{method:"POST"})),_=async()=>(await N(await t("/me/authenticator",{method:"POST"}))).data,$=async(L,R)=>{const A=new FormData;return A.append("authenticator_id",L),R.forEach(G=>{A.append("codes",G)}),await N(await t("/me/authenticator/attempt-verification",{method:"POST",body:A}))},w=async L=>await N(await t(`/me/authenticator/${L}/delete`,{method:"POST"})),b=async()=>(await N(await t("/me/backup-codes",{method:"POST"}))).data,g=async L=>{const R=new FormData;return R.append("file",L),await N(await t("/me/profile-picture",{method:"POST",body:R}))},C=async()=>(await N(await t("/me/backup-codes/regenerate",{method:"POST"}))).data,E=async(L,R)=>{const A=new FormData;return A.append("current_password",L),A.append("new_password",R),await N(await t("/me/update-password",{method:"POST",body:A}))},j=async L=>{const R=new FormData;R.append("current_password",L);const A=await N(await t("/me/remove-password",{method:"POST",body:R}));return s(),A},T=async L=>{const R=new FormData;return R.append("password",L),await N(await t("/me/account/delete",{method:"POST",body:R}))},I=async L=>await N(await t(`/me/social-connections/${L}/disconnect`,{method:"POST"})),O=async({provider:L,redirectUri:R})=>{var G;const A=new URLSearchParams({provider:L});R&&A.append("redirect_uri",R);const B=await N(await t(`/me/init-sso-connection?${A.toString()}`,{method:"POST"}));return"data"in B&&((G=B.data)!=null&&G.oauth_url)&&window.open(B.data.oauth_url,"_blank"),B},P=async()=>await N(await t("/me/passkeys",{method:"GET"})),M=async L=>{var ge,pe;const R=await N(await t("/me/passkeys/register/begin",{method:"POST"}));if(!("data"in R))return R;const A=R.data.options.publicKey,B={challenge:bn(A.challenge),rp:A.rp,user:{id:bn(A.user.id),name:A.user.name,displayName:A.user.displayName},pubKeyCredParams:A.pubKeyCredParams,timeout:A.timeout,attestation:A.attestation,authenticatorSelection:A.authenticatorSelection,excludeCredentials:(ge=A.excludeCredentials)==null?void 0:ge.map(ae=>({type:ae.type,id:bn(ae.id),transports:ae.transports}))},G=await navigator.credentials.create({publicKey:B});if(!G)throw new Error("Failed to create credential");const U=G.response,ne={id:G.id,rawId:yn(G.rawId),type:G.type,response:{clientDataJSON:yn(U.clientDataJSON),attestationObject:yn(U.attestationObject),transports:((pe=U.getTransports)==null?void 0:pe.call(U))||[]}};return await N(await t(`/me/passkeys/register/finish?name=${encodeURIComponent(L||"")}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ne)}))},F=async L=>await N(await t(`/me/passkeys/${L}/delete`,{method:"POST"})),D=async(L,R)=>await N(await t(`/me/passkeys/${L}`,{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:R})}));return{user:{...o,refetch:s},loading:r||a,error:n||null,updateProfile:p,getEmailAddresses:f,getEmailAddress:c,createEmailAddress:d,deleteEmailAddress:l,prepareEmailVerification:u,attemptEmailVerification:m,makeEmailPrimary:S,createPhoneNumber:v,deletePhoneNumber:x,preparePhoneVerification:y,attemptPhoneVerification:k,makePhonePrimary:z,setupAuthenticator:_,verifyAuthenticator:$,deleteAuthenticator:w,generateBackupCodes:b,regenerateBackupCodes:C,updateProfilePicture:g,disconnectSocialConnection:I,connectSocialAccount:O,updatePassword:E,removePassword:j,deleteAccount:T,getPasskeys:P,registerPasskey:M,deletePasskey:F,renamePasskey:D}}function Ec(){const{client:t,loading:r}=Ne(),{data:o,error:n,isLoading:a,mutate:s}=Ue(r?null:"/me/signins",()=>ju(t));return{signins:o,error:n||null,removeSignin:async f=>await N(await t(`/me/signins/${f}/signout`,{method:"POST"})),refetch:s,loading:a||r}}function _u(){const{session:t,loading:r}=He(),{loading:o,organizationMemberships:n}=$t(),{loading:a,workspaceMemberships:s}=Jo();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 d;return c.id===((d=t.active_signin)==null?void 0:d.active_organization_membership_id)}),[t]),f=i.useMemo(()=>!t||!t.signins||t.signins.length===0?null:s==null?void 0:s.find(c=>{var d;return c.id===((d=t.active_signin)==null?void 0:d.active_workspace_membership_id)}),[t]);return{loading:!1,orgMembership:p,workspaceMembership:f}}function $c(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(!1),a=async s=>{n(!0);try{const p=new FormData;for(const[d,l]of Object.entries(s))l&&p.append(d,l);const f=await t("/waitlist/join",{method:"POST",body:p});return await N(f)}finally{n(!1)}};return r?{loading:!0,joinWaitlist:null}:{loading:o,joinWaitlist:a}}function Pc(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(!1),[a,s]=i.useState(null),[p,f]=i.useState(null),[c,d]=i.useState(null),[l,u]=i.useState(!1),[m,v]=i.useState(null);i.useEffect(()=>{if(l||r)return;const y=new URLSearchParams(window.location.search),k=y.get("code"),z=y.get("state"),S=y.get("error"),_=y.get("error_description");if(!k&&!S){u(!0);const $=new Error("No OAuth callback data found.");s($);return}if(u(!0),n(!0),S){const $=_||S,w=new Error(`OAuth Error: ${$}`);s(w),n(!1);return}if(k&&z)x(k,z);else{const $=new Error("Missing required OAuth parameters");s($),n(!1)}},[l,r]);const x=async(y,k)=>{try{let z,S;try{const w=k.split(".");if(w.length!==2)throw new Error("Invalid OAuth state format - missing signature");const b=w[0].replace(/-/g,"+").replace(/_/g,"/"),g=b.length%4?"=".repeat(4-b.length%4):"",E=atob(b+g).split("|")[0];if(E==="sign_in")z="/auth/oauth2/callback",S="GET";else if(E==="connect_social")z="/me/sso-connection-callback",S="POST";else throw new Error(`Unknown OAuth action: ${E}`)}catch(w){const b=w instanceof Error?w: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 _=await t(`${z}?code=${encodeURIComponent(y)}&state=${encodeURIComponent(k)}`,{method:S}),$=await N(_);if("data"in $){const w=$.data.session,b=$.data.redirect_uri||null;if(f(w),d(b),w.signin_attempts&&w.signin_attempts.length>0){const g=w.signin_attempts.at(-1);g&&v(g)}}else{const w=new Error("SSO callback failed");s(w)}}catch(z){const S=z instanceof Error?z:new Error("Unknown error occurred");s(S)}finally{n(!1)}};return{loading:o,error:a,session:p,redirectUri:c,processed:l,signinAttempt:m}}function Rc(){const{client:t,loading:r}=Ne(),[o,n]=i.useState(!1),[a,s]=i.useState(null);return{loading:r||o,verifyMagicLink:async f=>{if(!f.token||!f.attempt)throw new Error("Invalid magic link parameters");n(!0),s(null);try{const c=new URL("/auth/verify-magic-link",window.location.origin);c.searchParams.set("token",f.token),c.searchParams.set("attempt",f.attempt),f.redirectUri&&c.searchParams.set("redirect_uri",f.redirectUri);const d=await t(c.pathname+c.search,{method:"GET"}),l=await N(d);return n(!1),s(!0),l}catch(c){throw n(!1),s(!1),c}},success:a}}function Ic(){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 Tc(){const{client:t,loading:r}=Ne();return{loading:r,forgotPassword:async s=>{const p=new FormData;p.append("email",s);const f=await t("/auth/forgot-password",{method:"POST",body:p});return await N(f)},verifyOtp:async(s,p)=>{const f=new FormData;f.append("email",s),f.append("otp",p);const c=await t("/auth/forgot-password",{method:"POST",body:f});return await N(c)},resetPassword:async(s,p)=>{const f=new FormData;f.append("token",s),f.append("password",p);const c=await t("/auth/reset-password",{method:"POST",body:f});return await N(c)}}}function Oc({enabled:t=!0,channels:r,organizationIds:o,workspaceIds:n,onNotification:a,onError:s,reconnectDelay:p=1e3,maxReconnectAttempts:f=5}={}){const{session:c,loading:d}=He(),{deployment:l,loading:u}=xe(),[m,v]=i.useState(!1),[x,y]=i.useState(null),k=i.useRef(null),z=i.useRef(null),S=i.useRef(0),_=i.useRef(null),$=i.useRef(a),w=i.useRef(s),b=i.useRef(r),g=i.useRef(o),C=i.useRef(n),E=i.useRef(p),j=i.useRef(f);$.current=a,w.current=s,b.current=r,g.current=o,C.current=n,E.current=p,j.current=f;const T=i.useCallback(()=>{z.current&&(clearTimeout(z.current),z.current=null),_.current&&(clearInterval(_.current),_.current=null),k.current&&(k.current.close(),k.current=null)},[]),I=i.useCallback(async()=>{var L;if(!t||d||u||!c||!l)return;T();const M=new URL(l.backend_host),F=M.protocol==="https:"?"wss:":"ws:",D=new URL("/realtime/notifications",`${F}//${M.host}`);if(l.mode==="staging"){const R=localStorage.getItem("__dev_session__");R&&D.searchParams.set("__dev_session__",R)}b.current&&b.current.length>0&&b.current.forEach(R=>D.searchParams.append("channels",R)),g.current&&g.current.length>0&&g.current.forEach(R=>D.searchParams.append("organization_ids",R.toString())),C.current&&C.current.length>0&&C.current.forEach(R=>D.searchParams.append("workspace_ids",R.toString()));try{const R=new WebSocket(D.toString());k.current=R,R.onopen=()=>{v(!0),y(null),S.current=0,_.current=setInterval(()=>{R.readyState===WebSocket.OPEN&&R.send("ping")},3e4)},R.onmessage=A=>{var B,G;try{const U=JSON.parse(A.data);if(U.type==="notification"&&U.data)(B=$.current)==null||B.call($,U.data);else if(U.type==="error"){const ne=U.error||"Unknown error occurred";y(ne),(G=w.current)==null||G.call(w,ne)}else U.type}catch{}},R.onerror=()=>{var A;y("Connection error occurred"),(A=w.current)==null||A.call(w,"Connection error occurred")},R.onclose=A=>{var B;if(v(!1),_.current&&(clearInterval(_.current),_.current=null),t&&A.code!==1e3&&S.current<j.current){S.current++;const G=E.current*Math.pow(2,S.current-1);z.current=setTimeout(()=>{I()},G)}else S.current>=j.current&&(y("Max reconnection attempts reached"),(B=w.current)==null||B.call(w,"Max reconnection attempts reached"))}}catch{y("Failed to connect"),(L=w.current)==null||L.call(w,"Failed to connect")}},[t,d,u,c,l,T]);i.useEffect(()=>(I(),()=>{T()}),[I,T]),i.useEffect(()=>{k.current&&k.current.readyState===WebSocket.OPEN&&I()},[r,o,n,I]);const O=i.useCallback(()=>{T(),v(!1)},[T]),P=i.useCallback(()=>{S.current=0,I()},[I]);return{isConnected:m,connectionError:x,disconnect:O,reconnect:P}}async function ku(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 N(a)).data}async function Cu(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await N(r)).data}async function Su(t,r){const o=await t(`/notifications/${r}/read`,{method:"POST"});return N(o)}async function zu(t){const r=await t("/notifications/mark-all-read",{method:"POST"});return N(r)}async function Eu(t,r){const o=await t(`/notifications/${r}/delete`,{method:"POST"});return N(o)}function Mc(t){const{client:r,loading:o}=Ne(),{data:n,error:a,mutate:s,isLoading:p}=Ue(o?null:`wacht-notifications:${JSON.stringify(t)}`,()=>ku(r,t),{refreshInterval:6e4,revalidateOnFocus:!0});Oc({enabled:!o&&!!n,onNotification:i.useCallback(u=>{s(async m=>!m||m.notifications.some(x=>x.id===u.id.toString())?m:{...m,notifications:[{id:u.id.toString(),user_id:u.user_id.toString(),deployment_id:u.deployment_id.toString(),title:u.title,body:u.body,severity:u.severity,action_url:u.action_url,action_label:u.action_label,is_read:!1,is_archived:!1,created_at:u.created_at,updated_at:u.created_at},...m.notifications],unread_count:m.unread_count+1,total:m.total+1},!1)},[s]),onError:i.useCallback(()=>{},[])});const f=i.useCallback(async u=>{o||(await s(async m=>m&&{...m,notifications:m.notifications.map(v=>v.id===u?{...v,is_read:!0}:v),unread_count:Math.max(0,m.unread_count-1)},!1),await Su(r,u),await s())},[r,o,s]),c=i.useCallback(async()=>{o||(await s(async u=>u&&{...u,notifications:u.notifications.map(m=>({...m,is_read:!0})),unread_count:0},!1),await zu(r),await s())},[r,s]),d=i.useCallback(async u=>{o||(await s(async m=>{if(!m)return m;const v=m.notifications.find(x=>x.id===u);return{...m,notifications:m.notifications.filter(x=>x.id!==u),unread_count:v&&!v.is_read?Math.max(0,m.unread_count-1):m.unread_count,total:Math.max(0,m.total-1)}},!1),await Eu(r,u),await s())},[r,o,s]),l=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:l}:{loading:!1,error:a,notifications:n.notifications,unreadCount:n.unread_count,unreadCounts:n.unread_counts,channels:n.channels,hasMore:n.has_more,markAsRead:f,markAllAsRead:c,deleteNotification:d,refetch:l}}async function $u(t){const r=await t("/notifications/channel-counts",{method:"GET"});return(await N(r)).data}function Pu(){const{client:t,loading:r}=Ne(),{data:o,error:n,mutate:a}=Ue(r?null:"wacht-notifications:channel-counts",()=>$u(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 ro={DISCONNECTED:"disconnected",CONNECTED:"connected",ERROR:"error"},Ge={IDLE:"idle",STARTING:"starting",RUNNING:"running",WAITING_FOR_INPUT:"waiting_for_input",COMPLETED:"completed",FAILED:"failed"},Vt={IDLE:"Idle",STARTING:"Starting",RUNNING:"Running",WAITING_FOR_INPUT:"WaitingForInput",COMPLETED:"Completed",FAILED:"Failed",CANCELLED:"Cancelled"};function Ru(t){switch(t){case Vt.IDLE:return Ge.IDLE;case Vt.STARTING:return Ge.STARTING;case Vt.RUNNING:return Ge.RUNNING;case Vt.WAITING_FOR_INPUT:return Ge.WAITING_FOR_INPUT;case Vt.COMPLETED:return Ge.COMPLETED;case Vt.FAILED:case Vt.CANCELLED:return Ge.FAILED;default:return Ge.IDLE}}function Iu(t){return t===Ge.STARTING||t===Ge.RUNNING||t===Ge.WAITING_FOR_INPUT}function Tu(t){const{client:r}=Ne(),[o,n]=i.useState(!1),[a,s]=i.useState(!!t),[p,f]=i.useState(null),c=i.useRef(!1),d=i.useRef(!1);return i.useEffect(()=>{if(!t||c.current||d.current)return;(async()=>{d.current=!0;try{s(!0),(await r(`/api/agent/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"POST"})).ok?(c.current=!0,n(!0)):f(new Error("Failed to exchange ticket"))}catch(u){f(u instanceof Error?u:new Error("Failed to exchange ticket"))}finally{s(!1),d.current=!1}})()},[t,r]),{exchanged:o,loading:a,error:p}}function Ou({contextId:t,agentName:r,platformAdapter:o}){const{deployment:n}=xe(),{client:a}=Ne(),[s,p]=i.useState([]),[f,c]=i.useState([]),[d,l]=i.useState(null),[u,m]=i.useState(null),[v,x]=i.useState(null),[y,k]=i.useState(!1),[z,S]=i.useState(!1),[_,$]=i.useState(Ge.IDLE),[w,b]=i.useState({status:ro.DISCONNECTED}),[g,C]=i.useState(!0),[E,j]=i.useState(!1),T=i.useRef(null),I=i.useRef(null),O=i.useRef(null),P=i.useRef(new Set),M=i.useCallback(ce=>{var Y;const{id:Z,content:X}=ce,ee=ce.message_type||((Y=ce.metadata)==null?void 0:Y.message_type)||(X==null?void 0:X.type);let te="assistant";ee==="user_message"&&(te="user");const W={...ce,role:te,metadata:{...ce.metadata||{},message_type:ee}};if(ee==="system_decision"||ee==="action_execution_result"||ee==="context_results"){if(l(null),m(null),x(null),P.current.has(Z))return;P.current.add(Z),p(se=>[...se,W]);return}if(ee==="user_message"){if(l(null),m(null),x(null),P.current.has(Z))return;P.current.add(Z),console.log(P.current,Z),p(se=>[...se,W]);return}if(ee==="assistant_acknowledgment"){if(l(null),m(null),x(null),P.current.has(Z))return;P.current.add(Z),p(se=>[...se,W]),ce.further_action_required||(S(!1),$(Ge.IDLE),I.current=null);return}if(ee==="agent_response"){if(P.current.has(Z))return;P.current.add(Z),p(se=>[...se,W]),S(!1),$(Ge.IDLE),I.current=null;return}if(ee==="user_input_request"){if(P.current.has(Z))return;P.current.add(Z),$(Ge.WAITING_FOR_INPUT),p(se=>[...se,W]);return}if(ee==="execution_status"){const se=Ru(X.status);$(se),S(Iu(se));return}},[]),F=i.useCallback((ce,Z)=>{var X;(X=o==null?void 0:o.onPlatformEvent)==null||X.call(o,ce,Z)},[o]),D=i.useRef(M),L=i.useRef(F),R=i.useRef(a),A=i.useRef(n);i.useEffect(()=>{D.current=M,L.current=F,R.current=a,A.current=n});const B=i.useRef(null),G=i.useRef(null),U=i.useRef(0),ne=10,K=i.useCallback(async ce=>{if(t)try{const Z=new URLSearchParams({limit:"100"});ce&&(Z.append("before_id",ce),j(!0));const X=await a(`/api/agent/contexts/${t}/messages?${Z}`,{method:"GET"}),ee=await N(X);if(ee.data){const te=[...ee.data.data].sort((W,Y)=>{const se=new Date(W.timestamp).getTime(),le=new Date(Y.timestamp).getTime();return se-le});te.length>0&&(T.current=te[0].id),te.forEach(W=>{P.current.add(W.id)}),p(W=>ce?[...te,...W]:te),C(ee.data.has_more||!1),j(!1)}}catch(Z){console.error("Failed to fetch messages:",Z),j(!1)}},[t,a]);i.useEffect(()=>{const ce=A.current;if(!ce||!t)return;const Z=()=>{B.current&&(B.current.close(),B.current=null);const X=ce.backend_host.replace(/\/$/,""),ee=new URL(`${X}/realtime/agent/stream`);if(ee.searchParams.append("context_id",t),ce.mode==="staging"){const W=localStorage.getItem("__dev_session__");W&&ee.searchParams.append("__dev_session__",W)}console.log("SSE: Connecting to",ee.toString());const te=new EventSource(ee.toString(),{withCredentials:ce.mode!=="staging"});B.current=te,te.onopen=()=>{console.log("SSE: Connected successfully"),k(!0),b({status:ro.CONNECTED}),U.current>0&&setTimeout(()=>{a(`/api/agent/contexts/${t}/messages?limit=100`,{method:"GET"}).then(async W=>{const Y=await N(W);if(Y.data){const se=[...Y.data.data].sort((le,q)=>new Date(le.timestamp).getTime()-new Date(q.timestamp).getTime());p(se)}}).catch(W=>console.error("Failed to refetch messages:",W))},100),U.current=0},te.onerror=W=>{if(console.error("SSE error:",W),k(!1),b({status:ro.ERROR}),te.close(),B.current=null,U.current<ne){const Y=Math.min(1e3*Math.pow(2,U.current),3e4);console.log(`SSE: Reconnecting in ${Y}ms (attempt ${U.current+1}/${ne})`),G.current=setTimeout(()=>{U.current++,Z()},Y)}else console.error("SSE: Max reconnection attempts reached"),b({status:ro.DISCONNECTED})},te.addEventListener("conversation_message",W=>{try{console.log("SSE received conversation_message:",W.data);const Y=JSON.parse(W.data);Y.ConversationMessage&&D.current(Y.ConversationMessage)}catch(Y){console.error("Failed to parse conversation event:",Y)}}),te.addEventListener("platform_event",W=>{try{console.log("SSE received platform_event:",W.data);const Y=JSON.parse(W.data);Y.PlatformEvent&&L.current(Y.PlatformEvent[0],Y.PlatformEvent[1])}catch(Y){console.error("Failed to parse platform event:",Y)}}),te.addEventListener("user_input_request",W=>{try{console.log("SSE received user_input_request:",W.data);const Y=JSON.parse(W.data);Y.UserInputRequest&&M({id:`input-${Date.now()}`,content:Y.UserInputRequest,metadata:{message_type:"user_input_request"}})}catch(Y){console.error("Failed to parse user input request:",Y)}})};return Z(),()=>{console.log("SSE: Cleanup running, closing connection for context:",t),G.current&&(clearTimeout(G.current),G.current=null),B.current&&(B.current.close(),B.current=null),k(!1)}},[t]);const ge=i.useCallback(async(ce,Z,X)=>{if(!(!t||!n)){l(ce),Z&&Z.length>0&&m(Z),X&&X.length>0&&x(X);try{const ee=new FormData;ee.append("agent_name",r),ee.append("message",ce),X&&X.length>0&&X.forEach(W=>{ee.append("files",W)}),(await a(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ee})).ok?(S(!0),$(Ge.RUNNING)):(l(null),m(null),x(null))}catch(ee){console.error("Failed to send message:",ee),l(null),m(null),x(null)}}},[t,r,n,a,K]),pe=i.useCallback(async ce=>{if(!(!t||_!==Ge.WAITING_FOR_INPUT))try{const Z=new FormData;Z.append("agent_name",r),Z.append("user_input",ce),await a(`/api/agent/contexts/${t}/execute`,{method:"POST",body:Z}),$(Ge.RUNNING)}catch(Z){console.error("Failed to submit user input:",Z)}},[t,r,_,a]);i.useEffect(()=>{t&&O.current!==t&&(O.current=t,K())},[t]);const ae=i.useCallback(async()=>{if(!(E||!g||!T.current)){j(!0);try{await K(T.current)}finally{j(!1)}}},[E,g,K]),he=i.useCallback(()=>{p([]),c([]),l(null),m(null),x(null)},[]),Q=i.useCallback(()=>{},[]),Se=i.useCallback(async()=>{if(!(!t||!z))try{const ce=new FormData;ce.append("agent_name",r),ce.append("cancel","true"),await a(`/api/agent/contexts/${t}/execute`,{method:"POST",body:ce}),S(!1),$(Ge.IDLE)}catch(ce){console.error("Failed to cancel execution:",ce)}},[t,z,r,a]);return{messages:s,quickQuestions:f,pendingMessage:d,pendingImages:u,pendingFiles:v,connectionState:w,isConnected:y,isExecuting:z,executionStatus:_,isWaitingForInput:_===Ge.WAITING_FOR_INPUT,hasMoreMessages:g,isLoadingMore:E,sendMessage:ge,submitUserInput:pe,clearMessages:he,loadMoreMessages:ae,cancelExecution:Se,connect:Q,disconnect:()=>{B.current&&(B.current.close(),B.current=null,k(!1))}}}function Mu(t){const{client:r}=Ne(),o=i.useCallback(async()=>{if(!t)return[];const c=await r(`/api/agent/integrations?agent_name=${t}`,{method:"GET"});return(await N(c)).data},[r,t]),{data:n,error:a,mutate:s}=Ue(t?`wacht-agent-integrations:${t}`:null,o,{revalidateOnFocus:!1}),p=i.useCallback(async c=>{const d=`/api/agent/integrations/${c}/consent-url`,l=await r(d,{method:"POST"});return(await N(l)).data},[r]),f=i.useCallback(async c=>{await r(`/api/agent/integrations/${c}/remove`,{method:"POST"}),await s(d=>d&&d.filter(l=>l.id!==c))},[r,s]);return{integrations:n||[],loading:!n&&!a,error:a,generateConsentURL:p,removeIntegration:f,refetch:async()=>{await s()}}}function Au(t){const{client:r}=Ne(),[o,n]=i.useState(!t),[a,s]=i.useState(!!t),[p,f]=i.useState(null),c=i.useRef(!1),d=i.useRef(!1),[l,u]=i.useState(null),m=o,v=i.useCallback(async()=>{const w=await r("/api/agent/session",{method:"GET"});if(!w.ok)throw w.status===401||w.status===403?new Error("NO_SESSION"):new Error("Failed to fetch session");return(await N(w)).data},[r]),{data:x,error:y,isLoading:k,mutate:z}=Ue(m?"wacht-agent-session":null,v,{revalidateOnFocus:!1});i.useEffect(()=>{if(!t||c.current||d.current)return;(async()=>{d.current=!0,s(!0);try{(await r(`/api/agent/ticket/exchange?ticket=${encodeURIComponent(t)}`,{method:"POST"})).ok?(c.current=!0,n(!0)):f(new Error("Failed to exchange ticket"))}catch(b){f(b instanceof Error?b:new Error("Failed to exchange ticket"))}finally{s(!1),d.current=!1}})()},[t,r]),i.useEffect(()=>{!l&&(x!=null&&x.agents)&&x.agents.length>0&&u(x.agents[0])},[x,l]),i.useEffect(()=>{x!=null&&x.agents&&l&&!x.agents.some(b=>b.id===l.id)&&x.agents.length>0&&u(x.agents[0])},[x,l]);const S=!y||y.message!=="NO_SESSION",_=p||(y&&y.message!=="NO_SESSION"?y:null);return{hasSession:S,sessionLoading:a||m&&k,sessionError:_,sessionId:(x==null?void 0:x.session_id)||null,contextGroup:(x==null?void 0:x.context_group)||null,agents:(x==null?void 0:x.agents)||[],activeAgent:l,setActiveAgent:u,ticketExchanged:o,ticketLoading:a,refetch:async()=>{await z()}}}function Lu(t={}){const{client:r}=Ne(),{limit:o=20,offset:n=0,status:a,search:s,enabled:p=!0}=t,f=i.useCallback(async()=>{const x=new URLSearchParams({limit:String(o),offset:String(n)});a&&x.append("status",a),s&&x.append("search",s);const y=await r(`/api/agent/contexts?${x.toString()}`,{method:"GET"});return(await N(y)).data},[r,o,n,a,s]),{data:c,error:d,mutate:l}=Ue(p?`wacht-agent-contexts:${o}:${n}:${a}:${s}`:null,f,{revalidateOnFocus:!1}),u=i.useCallback(async x=>{const y=new FormData;y.append("title",x.title),x.system_instructions&&y.append("system_instructions",x.system_instructions);const k=await r("/api/agent/contexts",{method:"POST",body:y}),z=await N(k);return await l(S=>S&&{...S,data:[z.data,...S.data]}),z.data},[r,l]),m=i.useCallback(async x=>{await r(`/api/agent/contexts/${x}/delete`,{method:"POST"}),await l(y=>y&&{...y,data:y.data.filter(k=>k.id!==x)})},[r,l]),v=i.useCallback(async(x,y)=>{const k=new FormData;if(y.title&&k.append("title",y.title),!(await r(`/api/agent/contexts/${x}/update`,{method:"POST",body:k})).ok)throw new Error("Failed to update context");await l(S=>S&&{...S,data:S.data.map(_=>_.id===x?{..._,...y}:_)})},[r,l]);return{contexts:(c==null?void 0:c.data)||[],loading:!c&&!d,error:d,hasMore:(c==null?void 0:c.has_more)||!1,createContext:u,deleteContext:m,updateContext:v,refetch:async()=>{await l()}}}const Ac=()=>{const{client:t}=Ne(),[r,o]=i.useState(!1),[n,a]=i.useState(null),[s,p]=i.useState(null),f=i.useCallback(async d=>{o(!0),a(null),p(null);try{const l=new FormData;l.append("token",d);const u=await t("/organizations/invitations/accept",{method:"POST",body:l}),v=(await N(u)).data;return p(v),v.error_code&&a(v.message||"Failed to accept invitation"),v}catch(l){const u=l.message||"Failed to accept invitation";a(u);const m={error_code:"NETWORK_ERROR",message:u};return p(m),m}finally{o(!1)}},[t]),c=i.useCallback(()=>{a(null),p(null)},[]);return{acceptInvitation:f,invitationData:s,loading:r,error:n,reset:c}},Du=({children:t})=>{const{loading:r}=xe();return r?null:e.jsx(e.Fragment,{children:t})},Fu=({children:t})=>{const{loading:r}=xe();return r?e.jsx(e.Fragment,{children:t}):null};var et=function(){return et=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},et.apply(this,arguments)};function cr(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 Nu(t){var r=Object.create(null);return function(o){return r[o]===void 0&&(r[o]=t(o)),r[o]}}var Bu=/^((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=Nu(function(t){return Bu.test(t)||t.charCodeAt(0)===111&&t.charCodeAt(1)===110&&t.charCodeAt(2)<91}),Ae="-ms-",Vr="-moz-",Pe="-webkit-",Lc="comm",Xo="rule",_a="decl",Wu="@import",Dc="@keyframes",Vu="@layer",Fc=Math.abs,ka=String.fromCharCode,sa=Object.assign;function Gu(t,r){return qe(t,0)^45?(((r<<2^qe(t,0))<<2^qe(t,1))<<2^qe(t,2))<<2^qe(t,3):0}function Nc(t){return t.trim()}function kt(t,r){return(t=r.exec(t))?t[0]:t}function ye(t,r,o){return t.replace(r,o)}function To(t,r,o){return t.indexOf(r,o)}function qe(t,r){return t.charCodeAt(r)|0}function _r(t,r,o){return t.slice(r,o)}function ut(t){return t.length}function Bc(t){return t.length}function Ur(t,r){return r.push(t),t}function Hu(t,r){return t.map(r).join("")}function us(t,r){return t.filter(function(o){return!kt(o,r)})}var en=1,kr=1,Uc=0,ot=0,We=0,$r="";function tn(t,r,o,n,a,s,p,f){return{value:t,root:r,parent:o,type:n,props:a,children:s,line:en,column:kr,length:p,return:"",siblings:f}}function It(t,r){return sa(tn("",null,null,"",null,null,0,t.siblings),t,{length:-t.length},r)}function pr(t){for(;t.root;)t=It(t.root,{children:[t]});Ur(t,t.siblings)}function qu(){return We}function Yu(){return We=ot>0?qe($r,--ot):0,kr--,We===10&&(kr=1,en--),We}function nt(){return We=ot<Uc?qe($r,ot++):0,kr++,We===10&&(kr=1,en++),We}function or(){return qe($r,ot)}function Oo(){return ot}function rn(t,r){return _r($r,t,r)}function ia(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 Zu(t){return en=kr=1,Uc=ut($r=t),ot=0,[]}function Ku(t){return $r="",t}function wn(t){return Nc(rn(ot-1,ca(t===91?t+2:t===40?t+1:t)))}function Qu(t){for(;(We=or())&&We<33;)nt();return ia(t)>2||ia(We)>3?"":" "}function Ju(t,r){for(;--r&&nt()&&!(We<48||We>102||We>57&&We<65||We>70&&We<97););return rn(t,Oo()+(r<6&&or()==32&&nt()==32))}function ca(t){for(;nt();)switch(We){case t:return ot;case 34:case 39:t!==34&&t!==39&&ca(We);break;case 40:t===41&&ca(t);break;case 92:nt();break}return ot}function Xu(t,r){for(;nt()&&t+We!==57;)if(t+We===84&&or()===47)break;return"/*"+rn(r,ot-1)+"*"+ka(t===47?t:nt())}function ep(t){for(;!ia(or());)nt();return rn(t,ot)}function tp(t){return Ku(Mo("",null,null,null,[""],t=Zu(t),0,[0],t))}function Mo(t,r,o,n,a,s,p,f,c){for(var d=0,l=0,u=p,m=0,v=0,x=0,y=1,k=1,z=1,S=0,_="",$=a,w=s,b=n,g=_;k;)switch(x=S,S=nt()){case 40:if(x!=108&&qe(g,u-1)==58){To(g+=ye(wn(S),"&","&\f"),"&\f",Fc(d?f[d-1]:0))!=-1&&(z=-1);break}case 34:case 39:case 91:g+=wn(S);break;case 9:case 10:case 13:case 32:g+=Qu(x);break;case 92:g+=Ju(Oo()-1,7);continue;case 47:switch(or()){case 42:case 47:Ur(rp(Xu(nt(),Oo()),r,o,c),c);break;default:g+="/"}break;case 123*y:f[d++]=ut(g)*z;case 125*y:case 59:case 0:switch(S){case 0:case 125:k=0;case 59+l:z==-1&&(g=ye(g,/\f/g,"")),v>0&&ut(g)-u&&Ur(v>32?hs(g+";",n,o,u-1,c):hs(ye(g," ","")+";",n,o,u-2,c),c);break;case 59:g+=";";default:if(Ur(b=ps(g,r,o,d,l,a,f,_,$=[],w=[],u,s),s),S===123)if(l===0)Mo(g,r,b,b,$,s,u,f,w);else switch(m===99&&qe(g,3)===110?100:m){case 100:case 108:case 109:case 115:Mo(t,b,b,n&&Ur(ps(t,b,b,0,0,a,f,_,a,$=[],u,w),w),a,w,u,f,n?$:w);break;default:Mo(g,b,b,b,[""],w,0,f,w)}}d=l=v=0,y=z=1,_=g="",u=p;break;case 58:u=1+ut(g),v=x;default:if(y<1){if(S==123)--y;else if(S==125&&y++==0&&Yu()==125)continue}switch(g+=ka(S),S*y){case 38:z=l>0?1:(g+="\f",-1);break;case 44:f[d++]=(ut(g)-1)*z,z=1;break;case 64:or()===45&&(g+=wn(nt())),m=or(),l=u=ut(_=g+=ep(Oo())),S++;break;case 45:x===45&&ut(g)==2&&(y=0)}}return s}function ps(t,r,o,n,a,s,p,f,c,d,l,u){for(var m=a-1,v=a===0?s:[""],x=Bc(v),y=0,k=0,z=0;y<n;++y)for(var S=0,_=_r(t,m+1,m=Fc(k=p[y])),$=t;S<x;++S)($=Nc(k>0?v[S]+" "+_:ye(_,/&\f/g,v[S])))&&(c[z++]=$);return tn(t,r,o,a===0?Xo:f,c,d,l,u)}function rp(t,r,o,n){return tn(t,r,o,Lc,ka(qu()),_r(t,2,-2),0,n)}function hs(t,r,o,n,a){return tn(t,r,o,_a,_r(t,0,n),_r(t,n+1,-1),n,a)}function Wc(t,r,o){switch(Gu(t,r)){case 5103:return Pe+"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 Pe+t+t;case 4789:return Vr+t+t;case 5349:case 4246:case 4810:case 6968:case 2756:return Pe+t+Vr+t+Ae+t+t;case 5936:switch(qe(t,r+11)){case 114:return Pe+t+Ae+ye(t,/[svh]\w+-[tblr]{2}/,"tb")+t;case 108:return Pe+t+Ae+ye(t,/[svh]\w+-[tblr]{2}/,"tb-rl")+t;case 45:return Pe+t+Ae+ye(t,/[svh]\w+-[tblr]{2}/,"lr")+t}case 6828:case 4268:case 2903:return Pe+t+Ae+t+t;case 6165:return Pe+t+Ae+"flex-"+t+t;case 5187:return Pe+t+ye(t,/(\w+).+(:[^]+)/,Pe+"box-$1$2"+Ae+"flex-$1$2")+t;case 5443:return Pe+t+Ae+"flex-item-"+ye(t,/flex-|-self/g,"")+(kt(t,/flex-|baseline/)?"":Ae+"grid-row-"+ye(t,/flex-|-self/g,""))+t;case 4675:return Pe+t+Ae+"flex-line-pack"+ye(t,/align-content|flex-|-self/g,"")+t;case 5548:return Pe+t+Ae+ye(t,"shrink","negative")+t;case 5292:return Pe+t+Ae+ye(t,"basis","preferred-size")+t;case 6060:return Pe+"box-"+ye(t,"-grow","")+Pe+t+Ae+ye(t,"grow","positive")+t;case 4554:return Pe+ye(t,/([^-])(transform)/g,"$1"+Pe+"$2")+t;case 6187:return ye(ye(ye(t,/(zoom-|grab)/,Pe+"$1"),/(image-set)/,Pe+"$1"),t,"")+t;case 5495:case 3959:return ye(t,/(image-set\([^]*)/,Pe+"$1$`$1");case 4968:return ye(ye(t,/(.+:)(flex-)?(.*)/,Pe+"box-pack:$3"+Ae+"flex-pack:$3"),/s.+-b[^;]+/,"justify")+Pe+t+t;case 4200:if(!kt(t,/flex-|baseline/))return Ae+"grid-column-align"+_r(t,r)+t;break;case 2592:case 3360:return Ae+ye(t,"template-","")+t;case 4384:case 3616:return o&&o.some(function(n,a){return r=a,kt(n.props,/grid-\w+-end/)})?~To(t+(o=o[r].value),"span",0)?t:Ae+ye(t,"-start","")+t+Ae+"grid-row-span:"+(~To(o,"span",0)?kt(o,/\d+/):+kt(o,/\d+/)-+kt(t,/\d+/))+";":Ae+ye(t,"-start","")+t;case 4896:case 4128:return o&&o.some(function(n){return kt(n.props,/grid-\w+-start/)})?t:Ae+ye(ye(t,"-end","-span"),"span ","")+t;case 4095:case 3583:case 4068:case 2532:return ye(t,/(.+)-inline(.+)/,Pe+"$1$2")+t;case 8116:case 7059:case 5753:case 5535:case 5445:case 5701:case 4933:case 4677:case 5533:case 5789:case 5021:case 4765:if(ut(t)-1-r>6)switch(qe(t,r+1)){case 109:if(qe(t,r+4)!==45)break;case 102:return ye(t,/(.+:)(.+)-([^]+)/,"$1"+Pe+"$2-$3$1"+Vr+(qe(t,r+3)==108?"$3":"$2-$3"))+t;case 115:return~To(t,"stretch",0)?Wc(ye(t,"stretch","fill-available"),r,o)+t:t}break;case 5152:case 5920:return ye(t,/(.+?):(\d+)(\s*\/\s*(span)?\s*(\d+))?(.*)/,function(n,a,s,p,f,c,d){return Ae+a+":"+s+d+(p?Ae+a+"-span:"+(f?c:+c-+s)+d:"")+t});case 4949:if(qe(t,r+6)===121)return ye(t,":",":"+Pe)+t;break;case 6444:switch(qe(t,qe(t,14)===45?18:11)){case 120:return ye(t,/(.+:)([^;\s!]+)(;|(\s+)?!.+)?/,"$1"+Pe+(qe(t,14)===45?"inline-":"")+"box$3$1"+Pe+"$2$3$1"+Ae+"$2box$3")+t;case 100:return ye(t,":",":"+Ae)+t}break;case 5719:case 2647:case 2135:case 3927:case 2391:return ye(t,"scroll-","scroll-snap-")+t}return t}function Bo(t,r){for(var o="",n=0;n<t.length;n++)o+=r(t[n],n,t,r)||"";return o}function op(t,r,o,n){switch(t.type){case Vu:if(t.children.length)break;case Wu:case _a:return t.return=t.return||t.value;case Lc:return"";case Dc:return t.return=t.value+"{"+Bo(t.children,n)+"}";case Xo:if(!ut(t.value=t.props.join(",")))return""}return ut(o=Bo(t.children,n))?t.return=t.value+"{"+o+"}":""}function np(t){var r=Bc(t);return function(o,n,a,s){for(var p="",f=0;f<r;f++)p+=t[f](o,n,a,s)||"";return p}}function ap(t){return function(r){r.root||(r=r.return)&&t(r)}}function sp(t,r,o,n){if(t.length>-1&&!t.return)switch(t.type){case _a:t.return=Wc(t.value,t.length,o);return;case Dc:return Bo([It(t,{value:ye(t.value,"@","@"+Pe)})],n);case Xo:if(t.length)return Hu(o=t.props,function(a){switch(kt(a,n=/(::plac\w+|:read-\w+)/)){case":read-only":case":read-write":pr(It(t,{props:[ye(a,/:(read-\w+)/,":"+Vr+"$1")]})),pr(It(t,{props:[a]})),sa(t,{props:us(o,n)});break;case"::placeholder":pr(It(t,{props:[ye(a,/:(plac\w+)/,":"+Pe+"input-$1")]})),pr(It(t,{props:[ye(a,/:(plac\w+)/,":"+Vr+"$1")]})),pr(It(t,{props:[ye(a,/:(plac\w+)/,Ae+"input-$1")]})),pr(It(t,{props:[a]})),sa(t,{props:us(o,n)});break}return""})}}var ip={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},lr=typeof process<"u"&&process.env!==void 0&&(process.env.REACT_APP_SC_ATTR||process.env.SC_ATTR)||"data-styled",Vc="active",Gc="data-styled-version",on="6.1.19",Ca=`/*!sc*/
|
|
19
19
|
`,Uo=typeof window<"u"&&typeof document<"u",cp=!!(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"),fs=/invalid hook call/i,oo=new Set,lp=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 _p(){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 Pr(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(_p.apply(void 0,cr([jp[t]],r,!1)).trim())}var kp=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 Pr(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 f=this.indexOfGroup(r+1),c=(p=0,o.length);p<c;p++)this.tag.insertRule(f,o[p])&&(this.groupSizes[r]++,f++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),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(Ca);return o},t}(),Cp=1<<30,Ao=new Map,Wo=new Map,Lo=1,ao=function(t){if(Ao.has(t))return Ao.get(t);for(;Wo.has(Lo);)Lo++;var r=Lo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Cp))throw Pr(16,"".concat(r));return Ao.set(t,r),Wo.set(r,t),r},Sp=function(t,r){Lo=r+1,Ao.set(t,r),Wo.set(r,t)},zp="style[".concat(lr,"][").concat(Gc,'="').concat(on,'"]'),Ep=new RegExp("^".concat(lr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),$p=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)},Pp=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(Ca),a=[],s=0,p=n.length;s<p;s++){var f=n[s].trim();if(f){var c=f.match(Ep);if(c){var d=0|parseInt(c[1],10),l=c[2];d!==0&&(Sp(l,d),$p(t,l,c[3]),t.getTag().insertRules(d,a)),a.length=0}else a.push(f)}}},bs=function(t){for(var r=document.querySelectorAll(zp),o=0,n=r.length;o<n;o++){var a=r[o];a&&a.getAttribute(lr)!==Vc&&(Pp(t,a),a.parentNode&&a.parentNode.removeChild(a))}};function Rp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var el=function(t){var r=document.head,o=t||r,n=document.createElement("style"),a=function(f){var c=Array.from(f.querySelectorAll("style[".concat(lr,"]")));return c[c.length-1]}(o),s=a!==void 0?a.nextSibling:null;n.setAttribute(lr,Vc),n.setAttribute(Gc,on);var p=Rp();return p&&n.setAttribute("nonce",p),o.insertBefore(n,s),n},Ip=function(){function t(r){this.element=el(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 Pr(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}(),Tp=function(){function t(r){this.element=el(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}(),ws=Uo,Mp={isServer:!Uo,useCSSOMInjection:!cp},tl=function(){function t(r,o,n){r===void 0&&(r=Cr),o===void 0&&(o={});var a=this;this.options=et(et({},Mp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&Uo&&ws&&(ws=!1,bs(this)),za(this,function(){return function(s){for(var p=s.getTag(),f=p.length,c="",d=function(u){var m=function(k){return Wo.get(k)}(u);if(m===void 0)return"continue";var v=s.names.get(m),x=p.getGroup(u);if(v===void 0||!v.size||x.length===0)return"continue";var y="".concat(lr,".g").concat(u,'[id="').concat(m,'"]'),S="";v!==void 0&&v.forEach(function(k){k.length>0&&(S+="".concat(k,","))}),c+="".concat(x).concat(y,'{content:"').concat(S,'"}').concat(Ca)},l=0;l<f;l++)d(l);return c}(a)})}return t.registerId=function(r){return ao(r)},t.prototype.rehydrate=function(){!this.server&&Uo&&bs(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(et(et({},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 Ip(a):new Tp(a)}(this.options),new kp(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(ao(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(ao(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(ao(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),Ap=/&/g,Lp=/^\s*\/\/.*$/gm;function rl(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=rl(o.children,r)),o})}function Dp(t){var r,o,n,a=Cr,s=a.options,p=s===void 0?Cr:s,f=a.plugins,c=f===void 0?nn:f,d=function(m,v,x){return x.startsWith(o)&&x.endsWith(o)&&x.replaceAll(o,"").length>0?".".concat(r):m},l=c.slice();l.push(function(m){m.type===Xo&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(Ap,o).replace(n,d))}),p.prefix&&l.push(sp),l.push(op);var u=function(m,v,x,y){v===void 0&&(v=""),x===void 0&&(x=""),y===void 0&&(y="&"),r=y,o=v,n=new RegExp("\\".concat(o,"\\b"),"g");var S=m.replace(Lp,""),k=tp(x||v?"".concat(x," ").concat(v," { ").concat(S," }"):S);p.namespace&&(k=rl(k,p.namespace));var z=[];return Bo(k,np(l.concat(ap(function(_){return z.push(_)})))),z};return u.hash=c.length?c.reduce(function(m,v){return v.name||Pr(15),tr(m,v.name)},Hc).toString():"",u}var Fp=new tl,ha=Dp(),ol=i.createContext({shouldForwardProp:void 0,styleSheet:Fp,stylis:ha});ol.Consumer;i.createContext(void 0);function js(){return i.useContext(ol)}var fa=function(){function t(r,o){var n=this;this.inject=function(a,s){s===void 0&&(s=ha);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,za(this,function(){throw Pr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=ha),this.name+r.hash},t}(),Np=function(t){return t>="A"&&t<="Z"};function _s(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;Np(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var nl=function(t){return t==null||t===!1||t===""},al=function(t){var r,o,n=[];for(var a in t){var s=t[a];t.hasOwnProperty(a)&&!nl(s)&&(Array.isArray(s)&&s.isCss||Sr(s)?n.push("".concat(_s(a),":"),s,";"):zr(s)?n.push.apply(n,cr(cr(["".concat(a," {")],al(s),!1),["}"],!1)):n.push("".concat(_s(a),": ").concat((r=a,(o=s)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in ip||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function nr(t,r,o,n){if(nl(t))return[];if(Sa(t))return[".".concat(t.styledComponentId)];if(Sr(t)){if(!Sr(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 fa||zr(a)||a===null||console.error("".concat(Zc(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.")),nr(a,r,o,n)}var s;return t instanceof fa?o?(t.inject(o,n),[t.getName(n)]):[t]:zr(t)?al(t):Array.isArray(t)?Array.prototype.concat.apply(nn,t.map(function(p){return nr(p,r,o,n)})):[t.toString()]}function Bp(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(Sr(o)&&!Sa(o))return!1}return!0}var Up=qc(on),Wp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&Bp(r),this.componentId=o,this.baseHash=tr(Up,o),this.baseStyle=n,tl.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=rr(a,this.staticRulesId);else{var s=ua(nr(this.rules,r,o,n)),p=da(tr(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,p)){var f=n(s,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,f)}a=rr(a,p),this.staticRulesId=p}else{for(var c=tr(this.baseHash,n.hash),d="",l=0;l<this.rules.length;l++){var u=this.rules[l];if(typeof u=="string")d+=u,process.env.NODE_ENV!=="production"&&(c=tr(c,u));else if(u){var m=ua(nr(u,r,o,n));c=tr(c,m+l),d+=m}}if(d){var v=da(c>>>0);o.hasNameForId(this.componentId,v)||o.insertRules(this.componentId,v,n(d,".".concat(v),void 0,this.componentId)),a=rr(a,v)}}return a},t}(),sl=i.createContext(void 0);sl.Consumer;var kn={},ks=new Set;function Vp(t,r,o){var n=Sa(t),a=t,s=!_n(t),p=r.attrs,f=p===void 0?nn:p,c=r.componentId,d=c===void 0?function($,w){var b=typeof $!="string"?"sc":gs($);kn[b]=(kn[b]||0)+1;var g="".concat(b,"-").concat(Yc(on+b+kn[b]));return w?"".concat(w,"-").concat(g):g}(r.displayName,r.parentComponentId):c,l=r.displayName,u=l===void 0?function($){return _n($)?"styled.".concat($):"Styled(".concat(Zc($),")")}(t):l,m=r.displayName&&r.componentId?"".concat(gs(r.displayName),"-").concat(r.componentId):r.componentId||d,v=n&&a.attrs?a.attrs.concat(f).filter(Boolean):f,x=r.shouldForwardProp;if(n&&a.shouldForwardProp){var y=a.shouldForwardProp;if(r.shouldForwardProp){var S=r.shouldForwardProp;x=function($,w){return y($,w)&&S($,w)}}else x=y}var k=new Wp(o,m,n?a.componentStyle:void 0);function z($,w){return function(b,g,C){var E=b.attrs,j=b.componentStyle,T=b.defaultProps,I=b.foldedComponentIds,O=b.styledComponentId,P=b.target,M=i.useContext(sl),F=js(),D=b.shouldForwardProp||F.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(O);var L=dp(g,M,T)||Cr,R=function(K,ge,pe){for(var ae,he=et(et({},ge),{className:void 0,theme:pe}),Q=0;Q<K.length;Q+=1){var Se=Sr(ae=K[Q])?ae(he):ae;for(var ce in Se)he[ce]=ce==="className"?rr(he[ce],Se[ce]):ce==="style"?et(et({},he[ce]),Se[ce]):Se[ce]}return ge.className&&(he.className=rr(he.className,ge.className)),he}(E,g,L),A=R.as||P,B={};for(var G in R)R[G]===void 0||G[0]==="$"||G==="as"||G==="theme"&&R.theme===L||(G==="forwardedAs"?B.as=R.forwardedAs:D&&!D(G,A)||(B[G]=R[G],D||process.env.NODE_ENV!=="development"||Uu(G)||ks.has(G)||!la.has(A)||(ks.add(G),console.warn('styled-components: it looks like an unknown prop "'.concat(G,'" 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 U=function(K,ge){var pe=js(),ae=K.generateAndInjectStyles(ge,pe.styleSheet,pe.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(ae),ae}(j,R);process.env.NODE_ENV!=="production"&&b.warnTooManyClasses&&b.warnTooManyClasses(U);var ne=rr(I,O);return U&&(ne+=" "+U),R.className&&(ne+=" "+R.className),B[_n(A)&&!la.has(A)?"class":"className"]=ne,C&&(B.ref=C),i.createElement(A,B)}(_,$,w)}z.displayName=u;var _=i.forwardRef(z);return _.attrs=v,_.componentStyle=k,_.displayName=u,_.shouldForwardProp=x,_.foldedComponentIds=n?rr(a.foldedComponentIds,a.styledComponentId):"",_.styledComponentId=m,_.target=n?a.target:t,Object.defineProperty(_,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function($){this._foldedDefaultProps=n?function(w){for(var b=[],g=1;g<arguments.length;g++)b[g-1]=arguments[g];for(var C=0,E=b;C<E.length;C++)pa(w,E[C],!0);return w}({},a.defaultProps,$):$}}),process.env.NODE_ENV!=="production"&&(lp(u,m),_.warnTooManyClasses=function($,w){var b={},g=!1;return function(C){if(!g&&(b[C]=!0,Object.keys(b).length>=200)){var E=w?' with the id of "'.concat(w,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat($).concat(E,`.
|
|
64
|
+
`,18:"ThemeProvider: Please make sure your useTheme hook is within a `<ThemeProvider>`"}:{};function _p(){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 Pr(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(_p.apply(void 0,cr([jp[t]],r,!1)).trim())}var kp=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 Pr(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 f=this.indexOfGroup(r+1),c=(p=0,o.length);p<c;p++)this.tag.insertRule(f,o[p])&&(this.groupSizes[r]++,f++)},t.prototype.clearGroup=function(r){if(r<this.length){var o=this.groupSizes[r],n=this.indexOfGroup(r),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(Ca);return o},t}(),Cp=1<<30,Ao=new Map,Wo=new Map,Lo=1,ao=function(t){if(Ao.has(t))return Ao.get(t);for(;Wo.has(Lo);)Lo++;var r=Lo++;if(process.env.NODE_ENV!=="production"&&((0|r)<0||r>Cp))throw Pr(16,"".concat(r));return Ao.set(t,r),Wo.set(r,t),r},Sp=function(t,r){Lo=r+1,Ao.set(t,r),Wo.set(r,t)},zp="style[".concat(lr,"][").concat(Gc,'="').concat(on,'"]'),Ep=new RegExp("^".concat(lr,'\\.g(\\d+)\\[id="([\\w\\d-]+)"\\].*?"([^"]*)')),$p=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)},Pp=function(t,r){for(var o,n=((o=r.textContent)!==null&&o!==void 0?o:"").split(Ca),a=[],s=0,p=n.length;s<p;s++){var f=n[s].trim();if(f){var c=f.match(Ep);if(c){var d=0|parseInt(c[1],10),l=c[2];d!==0&&(Sp(l,d),$p(t,l,c[3]),t.getTag().insertRules(d,a)),a.length=0}else a.push(f)}}},bs=function(t){for(var r=document.querySelectorAll(zp),o=0,n=r.length;o<n;o++){var a=r[o];a&&a.getAttribute(lr)!==Vc&&(Pp(t,a),a.parentNode&&a.parentNode.removeChild(a))}};function Rp(){return typeof __webpack_nonce__<"u"?__webpack_nonce__:null}var el=function(t){var r=document.head,o=t||r,n=document.createElement("style"),a=function(f){var c=Array.from(f.querySelectorAll("style[".concat(lr,"]")));return c[c.length-1]}(o),s=a!==void 0?a.nextSibling:null;n.setAttribute(lr,Vc),n.setAttribute(Gc,on);var p=Rp();return p&&n.setAttribute("nonce",p),o.insertBefore(n,s),n},Ip=function(){function t(r){this.element=el(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 Pr(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}(),Tp=function(){function t(r){this.element=el(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}(),ws=Uo,Mp={isServer:!Uo,useCSSOMInjection:!cp},tl=function(){function t(r,o,n){r===void 0&&(r=Cr),o===void 0&&(o={});var a=this;this.options=et(et({},Mp),r),this.gs=o,this.names=new Map(n),this.server=!!r.isServer,!this.server&&Uo&&ws&&(ws=!1,bs(this)),za(this,function(){return function(s){for(var p=s.getTag(),f=p.length,c="",d=function(u){var m=function(z){return Wo.get(z)}(u);if(m===void 0)return"continue";var v=s.names.get(m),x=p.getGroup(u);if(v===void 0||!v.size||x.length===0)return"continue";var y="".concat(lr,".g").concat(u,'[id="').concat(m,'"]'),k="";v!==void 0&&v.forEach(function(z){z.length>0&&(k+="".concat(z,","))}),c+="".concat(x).concat(y,'{content:"').concat(k,'"}').concat(Ca)},l=0;l<f;l++)d(l);return c}(a)})}return t.registerId=function(r){return ao(r)},t.prototype.rehydrate=function(){!this.server&&Uo&&bs(this)},t.prototype.reconstructWithOptions=function(r,o){return o===void 0&&(o=!0),new t(et(et({},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 Ip(a):new Tp(a)}(this.options),new kp(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(ao(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(ao(r),n)},t.prototype.clearNames=function(r){this.names.has(r)&&this.names.get(r).clear()},t.prototype.clearRules=function(r){this.getTag().clearGroup(ao(r)),this.clearNames(r)},t.prototype.clearTag=function(){this.tag=void 0},t}(),Ap=/&/g,Lp=/^\s*\/\/.*$/gm;function rl(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=rl(o.children,r)),o})}function Dp(t){var r,o,n,a=Cr,s=a.options,p=s===void 0?Cr:s,f=a.plugins,c=f===void 0?nn:f,d=function(m,v,x){return x.startsWith(o)&&x.endsWith(o)&&x.replaceAll(o,"").length>0?".".concat(r):m},l=c.slice();l.push(function(m){m.type===Xo&&m.value.includes("&")&&(m.props[0]=m.props[0].replace(Ap,o).replace(n,d))}),p.prefix&&l.push(sp),l.push(op);var u=function(m,v,x,y){v===void 0&&(v=""),x===void 0&&(x=""),y===void 0&&(y="&"),r=y,o=v,n=new RegExp("\\".concat(o,"\\b"),"g");var k=m.replace(Lp,""),z=tp(x||v?"".concat(x," ").concat(v," { ").concat(k," }"):k);p.namespace&&(z=rl(z,p.namespace));var S=[];return Bo(z,np(l.concat(ap(function(_){return S.push(_)})))),S};return u.hash=c.length?c.reduce(function(m,v){return v.name||Pr(15),tr(m,v.name)},Hc).toString():"",u}var Fp=new tl,ha=Dp(),ol=i.createContext({shouldForwardProp:void 0,styleSheet:Fp,stylis:ha});ol.Consumer;i.createContext(void 0);function js(){return i.useContext(ol)}var fa=function(){function t(r,o){var n=this;this.inject=function(a,s){s===void 0&&(s=ha);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,za(this,function(){throw Pr(12,String(n.name))})}return t.prototype.getName=function(r){return r===void 0&&(r=ha),this.name+r.hash},t}(),Np=function(t){return t>="A"&&t<="Z"};function _s(t){for(var r="",o=0;o<t.length;o++){var n=t[o];if(o===1&&n==="-"&&t[0]==="-")return t;Np(n)?r+="-"+n.toLowerCase():r+=n}return r.startsWith("ms-")?"-"+r:r}var nl=function(t){return t==null||t===!1||t===""},al=function(t){var r,o,n=[];for(var a in t){var s=t[a];t.hasOwnProperty(a)&&!nl(s)&&(Array.isArray(s)&&s.isCss||Sr(s)?n.push("".concat(_s(a),":"),s,";"):zr(s)?n.push.apply(n,cr(cr(["".concat(a," {")],al(s),!1),["}"],!1)):n.push("".concat(_s(a),": ").concat((r=a,(o=s)==null||typeof o=="boolean"||o===""?"":typeof o!="number"||o===0||r in ip||r.startsWith("--")?String(o).trim():"".concat(o,"px")),";")))}return n};function nr(t,r,o,n){if(nl(t))return[];if(Sa(t))return[".".concat(t.styledComponentId)];if(Sr(t)){if(!Sr(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 fa||zr(a)||a===null||console.error("".concat(Zc(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.")),nr(a,r,o,n)}var s;return t instanceof fa?o?(t.inject(o,n),[t.getName(n)]):[t]:zr(t)?al(t):Array.isArray(t)?Array.prototype.concat.apply(nn,t.map(function(p){return nr(p,r,o,n)})):[t.toString()]}function Bp(t){for(var r=0;r<t.length;r+=1){var o=t[r];if(Sr(o)&&!Sa(o))return!1}return!0}var Up=qc(on),Wp=function(){function t(r,o,n){this.rules=r,this.staticRulesId="",this.isStatic=process.env.NODE_ENV==="production"&&(n===void 0||n.isStatic)&&Bp(r),this.componentId=o,this.baseHash=tr(Up,o),this.baseStyle=n,tl.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=rr(a,this.staticRulesId);else{var s=ua(nr(this.rules,r,o,n)),p=da(tr(this.baseHash,s)>>>0);if(!o.hasNameForId(this.componentId,p)){var f=n(s,".".concat(p),void 0,this.componentId);o.insertRules(this.componentId,p,f)}a=rr(a,p),this.staticRulesId=p}else{for(var c=tr(this.baseHash,n.hash),d="",l=0;l<this.rules.length;l++){var u=this.rules[l];if(typeof u=="string")d+=u,process.env.NODE_ENV!=="production"&&(c=tr(c,u));else if(u){var m=ua(nr(u,r,o,n));c=tr(c,m+l),d+=m}}if(d){var v=da(c>>>0);o.hasNameForId(this.componentId,v)||o.insertRules(this.componentId,v,n(d,".".concat(v),void 0,this.componentId)),a=rr(a,v)}}return a},t}(),sl=i.createContext(void 0);sl.Consumer;var kn={},ks=new Set;function Vp(t,r,o){var n=Sa(t),a=t,s=!_n(t),p=r.attrs,f=p===void 0?nn:p,c=r.componentId,d=c===void 0?function($,w){var b=typeof $!="string"?"sc":gs($);kn[b]=(kn[b]||0)+1;var g="".concat(b,"-").concat(Yc(on+b+kn[b]));return w?"".concat(w,"-").concat(g):g}(r.displayName,r.parentComponentId):c,l=r.displayName,u=l===void 0?function($){return _n($)?"styled.".concat($):"Styled(".concat(Zc($),")")}(t):l,m=r.displayName&&r.componentId?"".concat(gs(r.displayName),"-").concat(r.componentId):r.componentId||d,v=n&&a.attrs?a.attrs.concat(f).filter(Boolean):f,x=r.shouldForwardProp;if(n&&a.shouldForwardProp){var y=a.shouldForwardProp;if(r.shouldForwardProp){var k=r.shouldForwardProp;x=function($,w){return y($,w)&&k($,w)}}else x=y}var z=new Wp(o,m,n?a.componentStyle:void 0);function S($,w){return function(b,g,C){var E=b.attrs,j=b.componentStyle,T=b.defaultProps,I=b.foldedComponentIds,O=b.styledComponentId,P=b.target,M=i.useContext(sl),F=js(),D=b.shouldForwardProp||F.shouldForwardProp;process.env.NODE_ENV!=="production"&&i.useDebugValue(O);var L=dp(g,M,T)||Cr,R=function(K,ge,pe){for(var ae,he=et(et({},ge),{className:void 0,theme:pe}),Q=0;Q<K.length;Q+=1){var Se=Sr(ae=K[Q])?ae(he):ae;for(var ce in Se)he[ce]=ce==="className"?rr(he[ce],Se[ce]):ce==="style"?et(et({},he[ce]),Se[ce]):Se[ce]}return ge.className&&(he.className=rr(he.className,ge.className)),he}(E,g,L),A=R.as||P,B={};for(var G in R)R[G]===void 0||G[0]==="$"||G==="as"||G==="theme"&&R.theme===L||(G==="forwardedAs"?B.as=R.forwardedAs:D&&!D(G,A)||(B[G]=R[G],D||process.env.NODE_ENV!=="development"||Uu(G)||ks.has(G)||!la.has(A)||(ks.add(G),console.warn('styled-components: it looks like an unknown prop "'.concat(G,'" 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 U=function(K,ge){var pe=js(),ae=K.generateAndInjectStyles(ge,pe.styleSheet,pe.stylis);return process.env.NODE_ENV!=="production"&&i.useDebugValue(ae),ae}(j,R);process.env.NODE_ENV!=="production"&&b.warnTooManyClasses&&b.warnTooManyClasses(U);var ne=rr(I,O);return U&&(ne+=" "+U),R.className&&(ne+=" "+R.className),B[_n(A)&&!la.has(A)?"class":"className"]=ne,C&&(B.ref=C),i.createElement(A,B)}(_,$,w)}S.displayName=u;var _=i.forwardRef(S);return _.attrs=v,_.componentStyle=z,_.displayName=u,_.shouldForwardProp=x,_.foldedComponentIds=n?rr(a.foldedComponentIds,a.styledComponentId):"",_.styledComponentId=m,_.target=n?a.target:t,Object.defineProperty(_,"defaultProps",{get:function(){return this._foldedDefaultProps},set:function($){this._foldedDefaultProps=n?function(w){for(var b=[],g=1;g<arguments.length;g++)b[g-1]=arguments[g];for(var C=0,E=b;C<E.length;C++)pa(w,E[C],!0);return w}({},a.defaultProps,$):$}}),process.env.NODE_ENV!=="production"&&(lp(u,m),_.warnTooManyClasses=function($,w){var b={},g=!1;return function(C){if(!g&&(b[C]=!0,Object.keys(b).length>=200)){var E=w?' with the id of "'.concat(w,'"'):"";console.warn("Over ".concat(200," classes were generated for component ").concat($).concat(E,`.
|
|
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 => ({
|
|
@@ -477,7 +477,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[so]+=1);/**
|
|
|
477
477
|
font-size: var(--font-xs);
|
|
478
478
|
display: block;
|
|
479
479
|
text-align: center;
|
|
480
|
-
`;function Bt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:a=!1}){const[s,p]=i.useState(new Array(t).fill("")),[f,c]=i.useState(60),[d,l]=i.useState(!1),u=i.useRef([]),m=i.useCallback(()=>{const
|
|
480
|
+
`;function Bt({length:t=6,onComplete:r,onResend:o,error:n,isSubmitting:a=!1}){const[s,p]=i.useState(new Array(t).fill("")),[f,c]=i.useState(60),[d,l]=i.useState(!1),u=i.useRef([]),m=i.useCallback(()=>{const z=setInterval(()=>{c(S=>S<=1?(l(!0),clearInterval(z),0):S-1)},1e3);return z},[]);i.useEffect(()=>{const z=m();return()=>clearInterval(z)},[m]);const v=async()=>{var z;!d||a||!o||(await o(),l(!1),c(60),p(new Array(t).fill("")),(z=u.current[0])==null||z.focus(),m())},x=(z,S)=>{var b;if(a)return;const _=z.value,$=[...s];$[S]=_.replace(/[^0-9]/g,""),p($);const w=$.join("");w.length===t&&r(w),_&&S<t-1&&((b=u.current[S+1])==null||b.focus())},y=(z,S)=>{var _;a||z.key==="Backspace"&&!s[S]&&S>0&&((_=u.current[S-1])==null||_.focus())},k=(z,S)=>{var g,C,E;if(a)return;z.preventDefault();const $=z.clipboardData.getData("text/plain").replace(/[^0-9]/g,"").slice(0,t);if($.length===0)return;const w=[...s];for(let j=0;j<$.length&&S+j<t;j++)w[S+j]=$[j];if(S===0&&$.length===t)for(let j=0;j<t;j++)w[j]=$[j];p(w);const b=w.join("");if(b.length===t)r(b),(g=u.current[t-1])==null||g.focus();else{const j=w.findIndex((T,I)=>I>=S&&!T);if(j!==-1)(C=u.current[j])==null||C.focus();else{const T=w.map((I,O)=>I?O:-1).filter(I=>I!==-1).pop();T!==void 0&&T<t-1&&((E=u.current[T+1])==null||E.focus())}}};return e.jsxs(Lh,{children:[e.jsx(Dh,{children:s.map((z,S)=>e.jsx(Fh,{type:"text",maxLength:1,value:z,onChange:_=>x(_.target,S),onKeyDown:_=>y(_,S),onPaste:_=>k(_,S),ref:_=>{u.current[S]=_},disabled:a,autoFocus:S===0},S))}),n&&e.jsx(Nh,{children:n}),o&&e.jsx("div",{children:d?e.jsx(Bh,{type:"button",onClick:v,disabled:a,children:"Didn't receive a code? Resend"}):e.jsxs(Uh,{children:["Resend code in ",f,"s"]})})]})}const ul=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",fill:"currentColor","aria-labelledby":"githubIconTitle",...t,children:[e.jsx("title",{id:"githubIconTitle",children:"GitHub"}),e.jsx("path",{d:"M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.109-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.91 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z"})]}),pl=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#4285F4",d:"M14.9 8.161c0-.476-.039-.954-.121-1.422h-6.64v2.695h3.802a3.24 3.24 0 01-1.407 2.127v1.75h2.269c1.332-1.22 2.097-3.02 2.097-5.15z"}),e.jsx("path",{fill:"#34A853",d:"M8.14 15c1.898 0 3.499-.62 4.665-1.69l-2.268-1.749c-.631.427-1.446.669-2.395.669-1.836 0-3.393-1.232-3.952-2.888H1.85v1.803A7.044 7.044 0 008.14 15z"}),e.jsx("path",{fill:"#FBBC04",d:"M4.187 9.342a4.17 4.17 0 010-2.68V4.859H1.849a6.97 6.97 0 000 6.286l2.338-1.803z"}),e.jsx("path",{fill:"#EA4335",d:"M8.14 3.77a3.837 3.837 0 012.7 1.05l2.01-1.999a6.786 6.786 0 00-4.71-1.82 7.042 7.042 0 00-6.29 3.858L4.186 6.66c.556-1.658 2.116-2.89 3.952-2.89z"})]}),hl=t=>e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",x:"0px",y:"0px",width:"50",height:"50",viewBox:"0 0 50 50",...t,children:e.jsx("path",{d:"M 6.9199219 6 L 21.136719 26.726562 L 6.2285156 44 L 9.40625 44 L 22.544922 28.777344 L 32.986328 44 L 43 44 L 28.123047 22.3125 L 42.203125 6 L 39.027344 6 L 26.716797 20.261719 L 16.933594 6 L 6.9199219 6 z"})}),Wh=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M24 12.073c0-6.627-5.373-12-12-12s-12 5.373-12 12c0 5.99 4.388 10.954 10.125 11.854v-8.385H7.078v-3.47h3.047V9.43c0-3.007 1.792-4.669 4.533-4.669 1.312 0 2.686.235 2.686.235v2.953H15.83c-1.491 0-1.956.925-1.956 1.874v2.25h3.328l-.532 3.47h-2.796v8.385C19.612 23.027 24 18.062 24 12.073z"})}),fl=()=>e.jsx("svg",{width:"20",height:"20",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",children:e.jsx("path",{fill:"#0A66C2",d:"M12.225 12.225h-1.778V9.44c0-.664-.012-1.519-.925-1.519-.926 0-1.068.724-1.068 1.47v2.834H6.676V6.498h1.707v.783h.024c.348-.594.996-.95 1.684-.925 1.802 0 2.135 1.185 2.135 2.728l-.001 3.14zM4.67 5.715a1.037 1.037 0 01-1.032-1.031c0-.566.466-1.032 1.032-1.032.566 0 1.031.466 1.032 1.032 0 .566-.466 1.032-1.032 1.032zm.889 6.51h-1.78V6.498h1.78v5.727zM13.11 2H2.885A.88.88 0 002 2.866v10.268a.88.88 0 00.885.866h10.226a.882.882 0 00.889-.866V2.865a.88.88 0 00-.889-.864z"})}),gl=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("path",{d:"M12 21.42L15.54 10.86H8.46L12 21.42Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L8.46 10.86H2.28L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M2.28 10.86L0.86 15.14C0.72 15.54 0.86 15.98 1.18 16.24L12 21.42L2.28 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M2.28 10.86H8.46L6.12 3.58C5.98 3.18 5.42 3.18 5.28 3.58L2.28 10.86Z",fill:"#E24329"}),e.jsx("path",{d:"M12 21.42L15.54 10.86H21.72L12 21.42Z",fill:"#FC6D26"}),e.jsx("path",{d:"M21.72 10.86L23.14 15.14C23.28 15.54 23.14 15.98 22.82 16.24L12 21.42L21.72 10.86Z",fill:"#FCA326"}),e.jsx("path",{d:"M21.72 10.86H15.54L17.88 3.58C18.02 3.18 18.58 3.18 18.72 3.58L21.72 10.86Z",fill:"#E24329"})]}),Vh=()=>e.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701"})}),ml=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 1024 1024",xmlns:"http://www.w3.org/2000/svg",children:[e.jsx("circle",{cx:"512",cy:"512",r:"512",style:{fill:"#5865f2"}}),e.jsx("path",{d:"M689.43 349a422.21 422.21 0 0 0-104.22-32.32 1.58 1.58 0 0 0-1.68.79 294.11 294.11 0 0 0-13 26.66 389.78 389.78 0 0 0-117.05 0 269.75 269.75 0 0 0-13.18-26.66 1.64 1.64 0 0 0-1.68-.79A421 421 0 0 0 334.44 349a1.49 1.49 0 0 0-.69.59c-66.37 99.17-84.55 195.9-75.63 291.41a1.76 1.76 0 0 0 .67 1.2 424.58 424.58 0 0 0 127.85 64.63 1.66 1.66 0 0 0 1.8-.59 303.45 303.45 0 0 0 26.15-42.54 1.62 1.62 0 0 0-.89-2.25 279.6 279.6 0 0 1-39.94-19 1.64 1.64 0 0 1-.16-2.72c2.68-2 5.37-4.1 7.93-6.22a1.58 1.58 0 0 1 1.65-.22c83.79 38.26 174.51 38.26 257.31 0a1.58 1.58 0 0 1 1.68.2c2.56 2.11 5.25 4.23 8 6.24a1.64 1.64 0 0 1-.14 2.72 262.37 262.37 0 0 1-40 19 1.63 1.63 0 0 0-.87 2.28 340.72 340.72 0 0 0 26.13 42.52 1.62 1.62 0 0 0 1.8.61 423.17 423.17 0 0 0 128-64.63 1.64 1.64 0 0 0 .67-1.18c10.68-110.44-17.88-206.38-75.7-291.42a1.3 1.3 0 0 0-.63-.63zM427.09 582.85c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.02 28.44-20.37 51.6-46 51.6zm170.13 0c-25.23 0-46-23.16-46-51.6s20.38-51.6 46-51.6c25.83 0 46.42 23.36 46 51.6.01 28.44-20.17 51.6-46 51.6z",style:{fill:"#fff"}})]}),zn={google_oauth:{shortLabel:"Google",fullLabel:"Continue with Google",icon:e.jsx(pl,{})},github_oauth:{shortLabel:"GitHub",fullLabel:"Continue with GitHub",icon:e.jsx(ul,{})},x_oauth:{shortLabel:"X",fullLabel:"Continue with X",icon:e.jsx(hl,{})},facebook_oauth:{shortLabel:"Facebook",fullLabel:"Continue with Facebook",icon:e.jsx(Wh,{})},linkedin_oauth:{shortLabel:"LinkedIn",fullLabel:"Continue with LinkedIn",icon:e.jsx(fl,{})},gitlab_oauth:{shortLabel:"GitLab",fullLabel:"Continue with GitLab",icon:e.jsx(gl,{})},apple_oauth:{shortLabel:"Apple",fullLabel:"Continue with Apple",icon:e.jsx(Vh,{})},discord_oauth:{shortLabel:"Discord",fullLabel:"Continue with Discord",icon:e.jsx(ml,{})}},Gh=h.div`
|
|
481
481
|
display: flex;
|
|
482
482
|
flex-direction: column;
|
|
483
483
|
gap: var(--space-xs);
|
|
@@ -683,7 +683,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[so]+=1);/**
|
|
|
683
683
|
}
|
|
684
684
|
`,rf=h(J)`
|
|
685
685
|
flex: 1;
|
|
686
|
-
`,Zr=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:a})=>{const[s,p]=i.useState(!1),[f,c]=i.useState(Do.find(x=>x.code===n)||Do[0]),d=i.useRef(null),[l,u]=i.useState(""),m=i.useRef(null);i.useEffect(()=>{function x(y){d.current&&!d.current.contains(y.target)&&p(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const v=Do.filter(x=>x.name.toLowerCase().includes(l.toLowerCase())||x.dialCode.includes(l));return i.useEffect(()=>{a(f.dialCode)},[f,a]),e.jsxs(Zh,{children:[e.jsxs(Kh,{ref:d,children:[e.jsxs(Qh,{type:"button",onClick:()=>p(x=>!x),children:[e.jsx("span",{children:f.flag}),e.jsx("span",{children:f.dialCode})]}),e.jsxs(Jh,{$isOpen:s,children:[e.jsx(Xh,{type:"text",placeholder:"Search country...",value:l,onChange:x=>u(x.target.value),onClick:x=>x.stopPropagation()}),e.jsx(ef,{children:v.map(x=>e.jsxs(tf,{onClick:y=>{var
|
|
686
|
+
`,Zr=({value:t,onChange:r,error:o,countryCode:n,setCountryCode:a})=>{const[s,p]=i.useState(!1),[f,c]=i.useState(Do.find(x=>x.code===n)||Do[0]),d=i.useRef(null),[l,u]=i.useState(""),m=i.useRef(null);i.useEffect(()=>{function x(y){d.current&&!d.current.contains(y.target)&&p(!1)}return document.addEventListener("mousedown",x),()=>{document.removeEventListener("mousedown",x)}},[]);const v=Do.filter(x=>x.name.toLowerCase().includes(l.toLowerCase())||x.dialCode.includes(l));return i.useEffect(()=>{a(f.dialCode)},[f,a]),e.jsxs(Zh,{children:[e.jsxs(Kh,{ref:d,children:[e.jsxs(Qh,{type:"button",onClick:()=>p(x=>!x),children:[e.jsx("span",{children:f.flag}),e.jsx("span",{children:f.dialCode})]}),e.jsxs(Jh,{$isOpen:s,children:[e.jsx(Xh,{type:"text",placeholder:"Search country...",value:l,onChange:x=>u(x.target.value),onClick:x=>x.stopPropagation()}),e.jsx(ef,{children:v.map(x=>e.jsxs(tf,{onClick:y=>{var k;y.stopPropagation(),y.preventDefault(),c(x),p(!1),(k=m.current)==null||k.focus()},children:[e.jsx("span",{children:x.flag}),e.jsx("span",{children:x.name}),e.jsx("span",{className:"country-code",children:x.dialCode})]},x.code))})]})]}),e.jsx(rf,{style:{height:"100%"},type:"tel",id:"phone",name:"phone",required:!0,minLength:7,maxLength:15,ref:m,value:t,onChange:r,placeholder:"Phone number","aria-invalid":!!o,pattern:"^\\d{7,15}$"})]})},of=h.div`
|
|
687
687
|
display: flex;
|
|
688
688
|
justify-content: center;
|
|
689
689
|
margin-bottom: var(--space-lg);
|
|
@@ -891,7 +891,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[so]+=1);/**
|
|
|
891
891
|
`,gr=h.span`
|
|
892
892
|
color: var(--color-danger);
|
|
893
893
|
margin-left: 2px;
|
|
894
|
-
`;function xf(){var U,ne,K,ge,pe,ae,he,Q,Se,ce,Z,X,ee,te,W,Y,se;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=vc(),{signIn:a}=jr("oauth"),{deployment:s}=xe(),{navigate:p}=Je(),{session:f,refetch:c,loading:d}=He(),[l,u]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,v]=i.useState({}),[x,y]=i.useState(!1),[S,k]=i.useState(void 0),[z,_]=i.useState(null),[$,w]=i.useState(null),[b,g]=i.useState(!1),C=((U=s==null?void 0:s.restrictions)==null?void 0:U.sign_up_mode)==="restricted",E=((ne=s==null?void 0:s.restrictions)==null?void 0:ne.sign_up_mode)==="waitlist",j=((ge=(K=s==null?void 0:s.auth_settings)==null?void 0:K.multi_session_support)==null?void 0:ge.enabled)??!1;i.useEffect(()=>{var le;if(!d&&(f!=null&&f.active_signin)&&!j&&!b){g(!0);let q=new URLSearchParams(window.location.search).get("redirect_uri");q||(q=((le=s==null?void 0:s.ui_settings)==null?void 0:le.after_signin_redirect_url)||null),!q&&(s!=null&&s.frontend_host)&&(q=`https://${s.frontend_host}`),!q&&(s!=null&&s.frontend_host)&&(q=`https://${s.frontend_host}`),q&&p(q)}},[f,d,j,s,p,b]),i.useEffect(()=>{var me;if(!s)return;const q=new URLSearchParams(window.location.search).get("invite_token");if(E&&!q){g(!0);const H=((me=s.ui_settings)==null?void 0:me.waitlist_page_url)||`https://${s.frontend_host}/waitlist`;p(H);return}q&&!z&&r&&(w(q),r.validateDeploymentInvitation(q).then(H=>{_(H),H.valid&&u(we=>({...we,first_name:H.first_name||we.first_name,last_name:H.last_name||we.last_name,email:H.email||we.email}))}).catch(H=>{console.error("Failed to validate invitation:",H)}))},[s,E,p,z,r]);const[T,I]=i.useState(!1),[O,P]=i.useState(""),M=le=>{let{name:q,value:me}=le.target;q==="phone_number"?me=me.replace(/[^0-9-]/g,""):q==="email"&&(me=me.toLowerCase()),u(H=>({...H,[q]:me})),v(H=>({...H,[q]:""}))},F=()=>{u({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),v({}),I(!1),P(""),n()},D=async le=>{if(le.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",l),t||x)return;const q={},me=/^[a-zA-Z]{3,30}$/,H=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,we=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Te=/^\d{7,15}$/,Ye=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!l.first_name?q.first_name="First name is required":l.first_name&&!me.test(l.first_name)&&(q.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!l.last_name?q.last_name="Last name is required":l.last_name&&!me.test(l.last_name)&&(q.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!l.username?q.username="Username is required":l.username&&!H.test(l.username)&&(q.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!l.email?q.email="Email address is required":l.email&&!we.test(l.email)&&(q.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!l.phone_number?q.phone_number="Phone number is required":l.phone_number&&!Te.test(l.phone_number)&&(q.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(l.password?Ye.test(l.password)||(q.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):q.password="Password is required"),v(q),Object.keys(q).length>0){console.log("Signup validation failed. Errors:",q);return}console.log("Signup validation passed"),y(!0);try{const Re={...l};l.phone_number&&S&&(Re.phone_country_code=S),$&&(Re.invite_token=$),console.log("Submitting signup data:",Re),console.log("Phone number:",Re.phone_number),console.log("Phone country code:",Re.phone_country_code),await r.create(Re)}catch(Re){v({submit:Re.message})}finally{y(!1)}},L=async le=>{if(!(t||x)){y(!0);try{const me=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:H}=await a.create({provider:le.provider,redirectUri:me});H&&typeof H=="object"&&"oauth_url"in H&&(window.location.href=H.oauth_url)}catch(q){v({submit:q.message})}finally{y(!1)}}},R=(s==null?void 0:s.social_connections.filter(le=>le.enabled))||[],A=s==null?void 0:s.auth_settings,B=!!((pe=A==null?void 0:A.first_name)!=null&&pe.enabled&&((ae=A==null?void 0:A.last_name)!=null&&ae.enabled)),G=async le=>{var me;if(le.preventDefault(),t||x)return;y(!0);const q={};if(!O){q.otp="OTP code is required",v(q),y(!1);return}v(q);try{const H=await r.completeVerification(O);"data"in H&&((me=H.data)!=null&&me.active_signin)&&await c()}catch(H){console.error("Verification failed:",H)}finally{y(!1)}};return i.useEffect(()=>{var le;if(o){if(o.completed){let q=new URLSearchParams(window.location.search).get("redirect_uri");if(q||(q=((le=s==null?void 0:s.ui_settings)==null?void 0:le.after_signup_redirect_url)||null),!q&&(s!=null&&s.frontend_host)&&(q=`https://${s.frontend_host}`),q){let me;try{me=new URL(q)}catch{me=new URL(q,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(me.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}I(!0)}}},[o,r,T,s,f,p]),d?e.jsx(ue,{children:e.jsxs(io,{children:[e.jsx(Ie,{}),e.jsx(zs,{children:e.jsx(zt,{size:32})})]})}):b?e.jsx(ue,{children:e.jsxs(io,{children:[e.jsx(Ie,{}),e.jsx(zs,{children:e.jsx(zt,{size:32})})]})}):C?e.jsx(ue,{children:e.jsxs(io,{children:[e.jsx(Ie,{}),e.jsx(En,{children:e.jsx($n,{children:"Sign up Restricted!"})}),e.jsx(pf,{children:e.jsx(hf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(ff,{children:e.jsxs(gf,{children:["Need assistance?"," ",e.jsx(mf,{href:(he=s==null?void 0:s.ui_settings)!=null&&he.sign_in_page_url?`${s.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(ue,{children:e.jsx(io,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(En,{children:[e.jsxs($n,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(Es,{children:(o==null?void 0:o.current_step)==="verify_email"?`${l.email} to continue to ${(Q=s==null?void 0:s.ui_settings)==null?void 0:Q.app_name}`:`${l.phone_number} to continue to ${(Se=s==null?void 0:s.ui_settings)==null?void 0:Se.app_name}`})]}),e.jsxs($s,{style:{gap:"15px"},onSubmit:G,noValidate:!0,children:[e.jsx(Bt,{onComplete:async le=>{P(le)},onResend:async()=>{const le=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:le})},error:m.otp,isSubmitting:x}),e.jsx(Ps,{type:"submit",disabled:x||t||!O,children:x?"Verifying...":`Continue to ${(ce=s==null?void 0:s.ui_settings)==null?void 0:ce.app_name}`})]}),e.jsxs(Rs,{children:["Having trouble?"," ",e.jsx(Pn,{children:e.jsx(st,{to:s.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Pn,{onClick:()=>{F()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{}),e.jsxs(En,{children:[e.jsx($n,{children:"Create your account"}),e.jsx(Es,{children:z!=null&&z.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),R.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ia,{connections:R,callback:L}),e.jsx(cf,{children:e.jsx(lf,{children:"or"})})]}),e.jsxs($s,{onSubmit:D,noValidate:!0,children:[(((Z=A==null?void 0:A.first_name)==null?void 0:Z.enabled)||((X=A==null?void 0:A.last_name)==null?void 0:X.enabled))&&e.jsxs(df,{$isBothEnabled:B,children:[((ee=A==null?void 0:A.first_name)==null?void 0:ee.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"first_name",children:["First name",((te=A==null?void 0:A.first_name)==null?void 0:te.required)&&e.jsx(gr,{children:"*"})]}),e.jsx(J,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:M,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Gt,{children:m.first_name})]}),((W=A==null?void 0:A.last_name)==null?void 0:W.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"last_name",children:["Last name",((Y=A==null?void 0:A.last_name)==null?void 0:Y.required)&&e.jsx(gr,{children:"*"})]}),e.jsx(J,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:M,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Gt,{children:m.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(gr,{children:"*"})]}),e.jsx(J,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:M,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Gt,{children:m.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(gr,{children:"*"})]}),e.jsx(J,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:M,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(z==null?void 0:z.valid)&&!!(z!=null&&z.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Gt,{children:m.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(gr,{children:"*"})]}),e.jsx(Zr,{value:l.phone_number,onChange:M,error:m.phone_number,countryCode:S,setCountryCode:k}),m.phone_number&&e.jsx(Gt,{children:m.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(gr,{children:"*"})]}),e.jsx(uf,{children:e.jsx(J,{type:"password",id:"password",name:"password",value:l.password,onChange:M,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(Gt,{children:m.password})]}),m.submit&&e.jsx(Gt,{children:m.submit}),e.jsx(Ps,{type:"submit",disabled:x||t,children:x?"Creating account...":"Continue"})]}),e.jsxs(Rs,{children:["Already have an account?"," ",e.jsx(Pn,{children:e.jsx(st,{to:`${(se=s.ui_settings)==null?void 0:se.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const xl=i.createContext(void 0),vl=()=>{const t=i.useContext(xl);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},vf=h.div`
|
|
894
|
+
`;function xf(){var U,ne,K,ge,pe,ae,he,Q,Se,ce,Z,X,ee,te,W,Y,se;const{loading:t,signUp:r,signupAttempt:o,discardSignupAttempt:n}=vc(),{signIn:a}=jr("oauth"),{deployment:s}=xe(),{navigate:p}=Je(),{session:f,refetch:c,loading:d}=He(),[l,u]=i.useState({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),[m,v]=i.useState({}),[x,y]=i.useState(!1),[k,z]=i.useState(void 0),[S,_]=i.useState(null),[$,w]=i.useState(null),[b,g]=i.useState(!1),C=((U=s==null?void 0:s.restrictions)==null?void 0:U.sign_up_mode)==="restricted",E=((ne=s==null?void 0:s.restrictions)==null?void 0:ne.sign_up_mode)==="waitlist",j=((ge=(K=s==null?void 0:s.auth_settings)==null?void 0:K.multi_session_support)==null?void 0:ge.enabled)??!1;i.useEffect(()=>{var le;if(!d&&(f!=null&&f.active_signin)&&!j&&!b){g(!0);let q=new URLSearchParams(window.location.search).get("redirect_uri");q||(q=((le=s==null?void 0:s.ui_settings)==null?void 0:le.after_signin_redirect_url)||null),!q&&(s!=null&&s.frontend_host)&&(q=`https://${s.frontend_host}`),!q&&(s!=null&&s.frontend_host)&&(q=`https://${s.frontend_host}`),q&&p(q)}},[f,d,j,s,p,b]),i.useEffect(()=>{var me;if(!s)return;const q=new URLSearchParams(window.location.search).get("invite_token");if(E&&!q){g(!0);const H=((me=s.ui_settings)==null?void 0:me.waitlist_page_url)||`https://${s.frontend_host}/waitlist`;p(H);return}q&&!S&&r&&(w(q),r.validateDeploymentInvitation(q).then(H=>{_(H),H.valid&&u(we=>({...we,first_name:H.first_name||we.first_name,last_name:H.last_name||we.last_name,email:H.email||we.email}))}).catch(H=>{console.error("Failed to validate invitation:",H)}))},[s,E,p,S,r]);const[T,I]=i.useState(!1),[O,P]=i.useState(""),M=le=>{let{name:q,value:me}=le.target;q==="phone_number"?me=me.replace(/[^0-9-]/g,""):q==="email"&&(me=me.toLowerCase()),u(H=>({...H,[q]:me})),v(H=>({...H,[q]:""}))},F=()=>{u({first_name:"",last_name:"",email:"",password:"",username:"",phone_number:""}),v({}),I(!1),P(""),n()},D=async le=>{if(le.preventDefault(),console.log("Signup form - handleSubmit called"),console.log("Auth settings:",A),console.log("Form data:",l),t||x)return;const q={},me=/^[a-zA-Z]{3,30}$/,H=/^[a-zA-Z][a-zA-Z0-9_.]{2,29}$/,we=/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/,Te=/^\d{7,15}$/,Ye=/^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[@$!%*?&])[A-Za-z\d@$!%*?&]{8,125}$/;if(A!=null&&A.first_name.enabled&&(A!=null&&A.first_name.required&&!l.first_name?q.first_name="First name is required":l.first_name&&!me.test(l.first_name)&&(q.first_name="Invalid name")),A!=null&&A.last_name.enabled&&(A!=null&&A.last_name.required&&!l.last_name?q.last_name="Last name is required":l.last_name&&!me.test(l.last_name)&&(q.last_name="Invalid last name")),A!=null&&A.username.enabled&&(A!=null&&A.username.required&&!l.username?q.username="Username is required":l.username&&!H.test(l.username)&&(q.username="Username must be 3-20 characters")),A!=null&&A.email_address.enabled&&(A!=null&&A.email_address.required&&!l.email?q.email="Email address is required":l.email&&!we.test(l.email)&&(q.email="Invalid email address")),A!=null&&A.phone_number.enabled&&(A!=null&&A.phone_number.required&&!l.phone_number?q.phone_number="Phone number is required":l.phone_number&&!Te.test(l.phone_number)&&(q.phone_number="Phone number must contain 7-15 digits")),A!=null&&A.password.enabled&&(l.password?Ye.test(l.password)||(q.password="Password must be 8-125 characters and include uppercase, lowercase, number, and special character"):q.password="Password is required"),v(q),Object.keys(q).length>0){console.log("Signup validation failed. Errors:",q);return}console.log("Signup validation passed"),y(!0);try{const Re={...l};l.phone_number&&k&&(Re.phone_country_code=k),$&&(Re.invite_token=$),console.log("Submitting signup data:",Re),console.log("Phone number:",Re.phone_number),console.log("Phone country code:",Re.phone_country_code),await r.create(Re)}catch(Re){v({submit:Re.message})}finally{y(!1)}},L=async le=>{if(!(t||x)){y(!0);try{const me=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:H}=await a.create({provider:le.provider,redirectUri:me});H&&typeof H=="object"&&"oauth_url"in H&&(window.location.href=H.oauth_url)}catch(q){v({submit:q.message})}finally{y(!1)}}},R=(s==null?void 0:s.social_connections.filter(le=>le.enabled))||[],A=s==null?void 0:s.auth_settings,B=!!((pe=A==null?void 0:A.first_name)!=null&&pe.enabled&&((ae=A==null?void 0:A.last_name)!=null&&ae.enabled)),G=async le=>{var me;if(le.preventDefault(),t||x)return;y(!0);const q={};if(!O){q.otp="OTP code is required",v(q),y(!1);return}v(q);try{const H=await r.completeVerification(O);"data"in H&&((me=H.data)!=null&&me.active_signin)&&await c()}catch(H){console.error("Verification failed:",H)}finally{y(!1)}};return i.useEffect(()=>{var le;if(o){if(o.completed){let q=new URLSearchParams(window.location.search).get("redirect_uri");if(q||(q=((le=s==null?void 0:s.ui_settings)==null?void 0:le.after_signup_redirect_url)||null),!q&&(s!=null&&s.frontend_host)&&(q=`https://${s.frontend_host}`),q){let me;try{me=new URL(q)}catch{me=new URL(q,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&me.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(me.toString())}return}if(!T){switch(o.current_step){case"verify_email":r.prepareVerification({strategy:"email_otp"});break;case"verify_phone":r.prepareVerification({strategy:"phone_otp"});break}I(!0)}}},[o,r,T,s,f,p]),d?e.jsx(ue,{children:e.jsxs(io,{children:[e.jsx(Ie,{}),e.jsx(zs,{children:e.jsx(zt,{size:32})})]})}):b?e.jsx(ue,{children:e.jsxs(io,{children:[e.jsx(Ie,{}),e.jsx(zs,{children:e.jsx(zt,{size:32})})]})}):C?e.jsx(ue,{children:e.jsxs(io,{children:[e.jsx(Ie,{}),e.jsx(En,{children:e.jsx($n,{children:"Sign up Restricted!"})}),e.jsx(pf,{children:e.jsx(hf,{children:"New account registration is currently restricted. Please check back later."})}),e.jsx(ff,{children:e.jsxs(gf,{children:["Need assistance?"," ",e.jsx(mf,{href:(he=s==null?void 0:s.ui_settings)!=null&&he.sign_in_page_url?`${s.ui_settings.sign_in_page_url}?help=true`:"/contact",children:"Get help"})]})})]})}):e.jsx(ue,{children:e.jsx(io,{children:T?e.jsxs(e.Fragment,{children:[e.jsxs(En,{children:[e.jsxs($n,{children:["Check your"," ",(o==null?void 0:o.current_step)==="verify_email"?"email":"phone"]}),e.jsx(Es,{children:(o==null?void 0:o.current_step)==="verify_email"?`${l.email} to continue to ${(Q=s==null?void 0:s.ui_settings)==null?void 0:Q.app_name}`:`${l.phone_number} to continue to ${(Se=s==null?void 0:s.ui_settings)==null?void 0:Se.app_name}`})]}),e.jsxs($s,{style:{gap:"15px"},onSubmit:G,noValidate:!0,children:[e.jsx(Bt,{onComplete:async le=>{P(le)},onResend:async()=>{const le=(o==null?void 0:o.current_step)==="verify_email"?"email_otp":"phone_otp";await r.prepareVerification({strategy:le})},error:m.otp,isSubmitting:x}),e.jsx(Ps,{type:"submit",disabled:x||t||!O,children:x?"Verifying...":`Continue to ${(ce=s==null?void 0:s.ui_settings)==null?void 0:ce.app_name}`})]}),e.jsxs(Rs,{children:["Having trouble?"," ",e.jsx(Pn,{children:e.jsx(st,{to:s.ui_settings.support_page_url,children:"Contact support"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(Pn,{onClick:()=>{F()},style:{cursor:"pointer"},children:"Use other method"})})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ie,{}),e.jsxs(En,{children:[e.jsx($n,{children:"Create your account"}),e.jsx(Es,{children:S!=null&&S.valid?"You've been invited! Complete your registration below.":"Welcome! Please fill in the details to get started."})]}),R.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(Ia,{connections:R,callback:L}),e.jsx(cf,{children:e.jsx(lf,{children:"or"})})]}),e.jsxs($s,{onSubmit:D,noValidate:!0,children:[(((Z=A==null?void 0:A.first_name)==null?void 0:Z.enabled)||((X=A==null?void 0:A.last_name)==null?void 0:X.enabled))&&e.jsxs(df,{$isBothEnabled:B,children:[((ee=A==null?void 0:A.first_name)==null?void 0:ee.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"first_name",children:["First name",((te=A==null?void 0:A.first_name)==null?void 0:te.required)&&e.jsx(gr,{children:"*"})]}),e.jsx(J,{type:"text",id:"first_name",name:"first_name",required:!0,minLength:3,maxLength:30,value:l.first_name,onChange:M,placeholder:"First name","aria-invalid":!!m.first_name,pattern:"^[a-zA-Z]{3,30}$"}),m.first_name&&e.jsx(Gt,{children:m.first_name})]}),((W=A==null?void 0:A.last_name)==null?void 0:W.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"last_name",children:["Last name",((Y=A==null?void 0:A.last_name)==null?void 0:Y.required)&&e.jsx(gr,{children:"*"})]}),e.jsx(J,{type:"text",id:"last_name",name:"last_name",required:!0,minLength:3,maxLength:30,value:l.last_name,onChange:M,placeholder:"Last name","aria-invalid":!!m.last_name,pattern:"^[a-zA-Z]{3,30}$"}),m.last_name&&e.jsx(Gt,{children:m.last_name})]})]}),(A==null?void 0:A.username.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"username",children:["Username",A.username.required&&e.jsx(gr,{children:"*"})]}),e.jsx(J,{type:"text",id:"username",name:"username",minLength:3,maxLength:20,value:l.username,onChange:M,placeholder:"Choose a username","aria-invalid":!!m.username,required:!0,pattern:"^[a-zA-Z][a-zA-Z0-9_.]{2,29}$"}),m.username&&e.jsx(Gt,{children:m.username})]}),(A==null?void 0:A.email_address.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"email",children:["Email address",A.email_address.required&&e.jsx(gr,{children:"*"})]}),e.jsx(J,{type:"email",id:"email",name:"email",maxLength:320,value:l.email,onChange:M,placeholder:"Enter your email address","aria-invalid":!!m.email,required:!0,readOnly:(S==null?void 0:S.valid)&&!!(S!=null&&S.email),pattern:"^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"}),m.email&&e.jsx(Gt,{children:m.email})]}),(A==null?void 0:A.phone_number.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"phone_number",children:["Phone number",A.phone_number.required&&e.jsx(gr,{children:"*"})]}),e.jsx(Zr,{value:l.phone_number,onChange:M,error:m.phone_number,countryCode:k,setCountryCode:z}),m.phone_number&&e.jsx(Gt,{children:m.phone_number})]}),(A==null?void 0:A.password.enabled)&&e.jsxs(hr,{children:[e.jsxs(fr,{htmlFor:"password",children:["Password",A.password.required&&e.jsx(gr,{children:"*"})]}),e.jsx(uf,{children:e.jsx(J,{type:"password",id:"password",name:"password",value:l.password,onChange:M,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(Gt,{children:m.password})]}),m.submit&&e.jsx(Gt,{children:m.submit}),e.jsx(Ps,{type:"submit",disabled:x||t,children:x?"Creating account...":"Continue"})]}),e.jsxs(Rs,{children:["Already have an account?"," ",e.jsx(Pn,{children:e.jsx(st,{to:`${(se=s.ui_settings)==null?void 0:se.sign_in_page_url}${window.location.search}`,children:"Sign in"})})]})]})})})}const xl=i.createContext(void 0),vl=()=>{const t=i.useContext(xl);if(!t)throw new Error("Dialog components must be used within a Dialog");return t},vf=h.div`
|
|
895
895
|
position: fixed;
|
|
896
896
|
inset: 0;
|
|
897
897
|
background-color: var(--color-dialog-backdrop, rgba(0, 0, 0, 0.5));
|
|
@@ -953,7 +953,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[so]+=1);/**
|
|
|
953
953
|
display: grid;
|
|
954
954
|
`,Of=h.div`
|
|
955
955
|
width: fit-content;
|
|
956
|
-
`,yl=i.createContext(void 0),bl=()=>{const t=i.useContext(yl);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},it=({children:t,open:r,openChange:o,style:n})=>{const a=i.useRef(null),[s,p]=i.useState(!1);return i.useEffect(()=>{const f=c=>{a.current&&!a.current.contains(c.target)&&p(!1)};return s&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[s,o]),i.useEffect(()=>{o==null||o(s)},[s]),i.useEffect(()=>{p(!!r)},[r]),e.jsx(yl.Provider,{value:{open:s,openChange:f=>p(f)},children:e.jsx(Of,{style:n,ref:a,children:t})})},ct=({children:t,style:r})=>{const{open:o}=bl(),[n,a]=i.useState({top:0,left:0}),[s,p]=i.useState(!1),f=i.useRef(null);return i.useEffect(()=>{o&&f.current?(p(!1),requestAnimationFrame(()=>{var l,u;const c=(l=f.current)==null?void 0:l.parentElement;if(!c)return;const d=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(d&&d!==f.current){const m=d.getBoundingClientRect(),v=(u=f.current)==null?void 0:u.getBoundingClientRect(),x=window.innerWidth,y=window.innerHeight;let
|
|
956
|
+
`,yl=i.createContext(void 0),bl=()=>{const t=i.useContext(yl);if(!t)throw new Error("useDropdownContext must be used within a DropdownProvider");return t},it=({children:t,open:r,openChange:o,style:n})=>{const a=i.useRef(null),[s,p]=i.useState(!1);return i.useEffect(()=>{const f=c=>{a.current&&!a.current.contains(c.target)&&p(!1)};return s&&document.addEventListener("mousedown",f),()=>{document.removeEventListener("mousedown",f)}},[s,o]),i.useEffect(()=>{o==null||o(s)},[s]),i.useEffect(()=>{p(!!r)},[r]),e.jsx(yl.Provider,{value:{open:s,openChange:f=>p(f)},children:e.jsx(Of,{style:n,ref:a,children:t})})},ct=({children:t,style:r})=>{const{open:o}=bl(),[n,a]=i.useState({top:0,left:0}),[s,p]=i.useState(!1),f=i.useRef(null);return i.useEffect(()=>{o&&f.current?(p(!1),requestAnimationFrame(()=>{var l,u;const c=(l=f.current)==null?void 0:l.parentElement;if(!c)return;const d=c.querySelector("[data-dropdown-trigger]")||c.firstElementChild;if(d&&d!==f.current){const m=d.getBoundingClientRect(),v=(u=f.current)==null?void 0:u.getBoundingClientRect(),x=window.innerWidth,y=window.innerHeight;let k=m.bottom+4,z=m.right-200;z<8&&(z=m.left),z+200>x-8&&(z=x-208),v&&k+v.height>y-8&&(k=m.top-(v.height+4)),a({top:k,left:z}),p(!0)}})):p(!1)},[o]),o?e.jsx(Tf,{ref:f,style:{...r,top:`${n.top}px`,left:`${n.left}px`,visibility:s?"visible":"hidden",opacity:s?1:0,transition:s?"opacity 0.15s ease-in-out":"none"},children:t}):null},lt=({children:t})=>{const{openChange:r,open:o}=bl(),n=i.useCallback(()=>{r(!o)},[o,r]);return e.jsx("div",{style:{position:"relative"},onClick:n,"data-dropdown-trigger":!0,children:t})},Le=h.button`
|
|
957
957
|
width: 100%;
|
|
958
958
|
padding: 8px 12px;
|
|
959
959
|
background: none;
|
|
@@ -1177,7 +1177,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[so]+=1);/**
|
|
|
1177
1177
|
text-transform: uppercase;
|
|
1178
1178
|
color: var(--color-muted);
|
|
1179
1179
|
background: var(--color-background-hover);
|
|
1180
|
-
`,Ta=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:a=!1,searchable:s=!1,width:p,name:f,id:c,groupsEnabled:d=!1,className:l})=>{const[u,m]=i.useState(!1),[v,x]=i.useState(""),y=i.useRef(null),
|
|
1180
|
+
`,Ta=({options:t,value:r,onChange:o,placeholder:n="Select an option",disabled:a=!1,searchable:s=!1,width:p,name:f,id:c,groupsEnabled:d=!1,className:l})=>{const[u,m]=i.useState(!1),[v,x]=i.useState(""),y=i.useRef(null),k=i.useRef(null),z=d&&"options"in t[0],_=(z?t.flatMap(g=>g.options):t).find(g=>g.value===r),$=v?z?t.map(g=>({...g,options:g.options.filter(C=>C.label.toLowerCase().includes(v.toLowerCase()))})).filter(g=>g.options.length>0):t.filter(g=>g.label.toLowerCase().includes(v.toLowerCase())):t,w=(g,C=!1)=>{C||(o(g),m(!1),x(""))},b=()=>{a||m(!u)};return i.useEffect(()=>{u&&s&&k.current&&setTimeout(()=>{var g;(g=k.current)==null||g.focus()},10)},[u,s]),i.useEffect(()=>{const g=C=>{y.current&&!y.current.contains(C.target)&&(m(!1),x(""))};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[]),e.jsxs(wl,{ref:y,style:{width:p},className:l,children:[e.jsxs(jl,{type:"button",onClick:b,disabled:a,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[_?_.label:e.jsx(Cl,{children:n}),u?e.jsx(ll,{size:16}):e.jsx(At,{size:16})]}),e.jsxs(_l,{isOpen:u,role:"listbox",children:[s&&e.jsx(kl,{ref:k,type:"text",placeholder:"Search...",value:v,onChange:g=>x(g.target.value),onClick:g=>g.stopPropagation()}),z?$.map((g,C)=>e.jsxs(i.Fragment,{children:[e.jsx(Sl,{children:g.label}),g.options.length===0?e.jsx(qo,{children:"No options available"}):g.options.map(E=>e.jsxs(Ho,{isSelected:E.value===r,disabled:E.disabled,onClick:()=>w(E.value,E.disabled),role:"option","aria-selected":E.value===r,children:[E.label,E.value===r&&e.jsx(Qe,{size:16})]},E.value))]},`group-${C}`)):e.jsx(e.Fragment,{children:$.length===0?e.jsx(qo,{children:"No options available"}):$.map(g=>e.jsxs(Ho,{isSelected:g.value===r,disabled:g.disabled,onClick:()=>w(g.value,g.disabled),role:"option","aria-selected":g.value===r,children:[g.label,g.value===r&&e.jsx(Qe,{size:16})]},g.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r||""})]})},zl=({options:t,value:r,onChange:o,placeholder:n="Select options",disabled:a=!1,searchable:s=!1,width:p,name:f,id:c,groupsEnabled:d=!1,className:l})=>{const[u,m]=i.useState(!1),[v,x]=i.useState(""),y=i.useRef(null),k=i.useRef(null),z=d&&"options"in t[0],_=(z?t.flatMap(g=>g.options):t).filter(g=>r.includes(g.value)),$=v?z?t.map(g=>({...g,options:g.options.filter(C=>C.label.toLowerCase().includes(v.toLowerCase()))})).filter(g=>g.options.length>0):t.filter(g=>g.label.toLowerCase().includes(v.toLowerCase())):t,w=(g,C=!1)=>{C||(r.includes(g)?o(r.filter(E=>E!==g)):o([...r,g]))},b=()=>{a||m(!u)};return i.useEffect(()=>{u&&s&&k.current&&setTimeout(()=>{var g;(g=k.current)==null||g.focus()},10)},[u,s]),i.useEffect(()=>{const g=C=>{y.current&&!y.current.contains(C.target)&&(m(!1),x(""))};return document.addEventListener("mousedown",g),()=>{document.removeEventListener("mousedown",g)}},[]),e.jsxs(wl,{ref:y,style:{width:p},className:l,children:[e.jsxs(jl,{type:"button",onClick:b,disabled:a,"aria-haspopup":"listbox","aria-expanded":u,id:c,children:[_.length>0?_.map(g=>g.label).join(", "):e.jsx(Cl,{children:n}),u?e.jsx(ll,{size:16}):e.jsx(At,{size:16})]}),e.jsxs(_l,{isOpen:u,role:"listbox",children:[s&&e.jsx(kl,{ref:k,type:"text",placeholder:"Search...",value:v,onChange:g=>x(g.target.value),onClick:g=>g.stopPropagation()}),z?$.map((g,C)=>e.jsxs(i.Fragment,{children:[e.jsx(Sl,{children:g.label}),g.options.length===0?e.jsx(qo,{children:"No options available"}):g.options.map(E=>e.jsxs(Ho,{isSelected:r.includes(E.value),disabled:E.disabled,onClick:()=>w(E.value,E.disabled),role:"option","aria-selected":r.includes(E.value),children:[E.label,r.includes(E.value)&&e.jsx(Qe,{size:16})]},E.value))]},`group-${C}`)):e.jsx(e.Fragment,{children:$.length===0?e.jsx(qo,{children:"No options available"}):$.map(g=>e.jsxs(Ho,{isSelected:r.includes(g.value),disabled:g.disabled,onClick:()=>w(g.value,g.disabled),role:"option","aria-selected":r.includes(g.value),children:[g.label,r.includes(g.value)&&e.jsx(Qe,{size:16})]},g.value))})]}),f&&e.jsx("input",{type:"hidden",name:f,value:r.join(",")})]})},El=i.createContext(void 0);function $l(){const t=i.useContext(El);if(!t)throw new Error("useSignIn must be used within a SignInProvider");return t}function Bf({children:t}){const{deployment:r}=xe(),[o,n]=i.useState((r==null?void 0:r.auth_settings.first_factor)||"email_password"),[a,s]=i.useState(""),[p,f]=i.useState(!1),[c,d]=i.useState(!1),[l,u]=i.useState(!1),[m,v]=i.useState("identifier"),x=(r==null?void 0:r.social_connections.filter(k=>k.enabled))||[],y=r==null?void 0:r.auth_settings;return e.jsx(El.Provider,{value:{email:a,showOtherOptions:p,showForgotPassword:c,otpSent:l,setFirstFactor:n,setEmail:s,setShowOtherOptions:f,setShowForgotPassword:d,setOtpSent:u,enabledSocialsProviders:x,authSettings:y,firstFactor:o,signInStep:m,setSignInStep:v},children:t})}const Or=h.button`
|
|
1181
1181
|
width: 100%;
|
|
1182
1182
|
padding: var(--space-sm) var(--space-md);
|
|
1183
1183
|
background: var(--color-input-background);
|
|
@@ -1264,7 +1264,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[so]+=1);/**
|
|
|
1264
1264
|
&:hover {
|
|
1265
1265
|
text-decoration: underline;
|
|
1266
1266
|
}
|
|
1267
|
-
`;function Hf({onBack:t}){const{deployment:r}=xe(),{navigate:o}=Je(),[n,a]=i.useState("start"),[s,p]=i.useState(""),[f,c]=i.useState(""),[d,l]=i.useState(""),[u,m]=i.useState(""),[v,x]=i.useState(""),{forgotPassword:y,verifyOtp:
|
|
1267
|
+
`;function Hf({onBack:t}){const{deployment:r}=xe(),{navigate:o}=Je(),[n,a]=i.useState("start"),[s,p]=i.useState(""),[f,c]=i.useState(""),[d,l]=i.useState(""),[u,m]=i.useState(""),[v,x]=i.useState(""),{forgotPassword:y,verifyOtp:k,resetPassword:z}=Tc(),[S,_]=i.useState(!1),[$,w]=i.useState(null),b=async j=>{if(j.preventDefault(),!!s){_(!0),w(null);try{await y(s),a("otp")}catch(T){w(T)}finally{_(!1)}}},g=async j=>{if(j.preventDefault(),f.length===6){_(!0),w(null);try{const T=await k(s,f);T.data&&(l(T.data.token),a("reset"))}catch(T){w(T)}finally{_(!1)}}},C=async j=>{var T,I;if(j.preventDefault(),u===v&&!(u.length<8)){_(!0),w(null);try{const O=await z(d,u);if(O.data){const P=O.data,M=P.signin_attempts&&P.signin_attempts.length>0?P.signin_attempts[P.signin_attempts.length-1]:null;if(M&&!M.completed){const F=(T=r==null?void 0:r.ui_settings)==null?void 0:T.sign_in_page_url;if(F){const D=new URL(F,window.location.origin);D.searchParams.set("signin_attempt_id",M.id),o(D.toString())}else t()}else{const F=((I=r==null?void 0:r.ui_settings)==null?void 0:I.after_signin_redirect_url)||"/";o(F)}}}catch(O){w(O)}finally{_(!1)}}},E=()=>e.jsxs(e.Fragment,{children:[e.jsx(Ie,{}),e.jsx(co,{children:e.jsx(lo,{children:"Forgot Password"})}),e.jsx(Wf,{onClick:()=>a("email"),disabled:S,children:"Reset your password"}),e.jsx(Vf,{children:e.jsx(Gf,{children:"Or, sign in with another method"})}),e.jsx(Pl,{}),e.jsxs(uo,{children:[e.jsxs(Mr,{children:["Unable to reset password? ",e.jsx(Ar,{href:"/contact",children:"Get help"})]}),e.jsx(Mr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ar,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]});return e.jsx(ue,{children:e.jsxs(Uf,{children:[n==="start"&&E(),n==="email"&&e.jsxs(e.Fragment,{children:[e.jsx(Ie,{}),e.jsxs(co,{children:[e.jsx(lo,{children:"Forgot Password"}),e.jsx(Rn,{children:"Enter your email address and we'll send you a code to reset your password."})]}),e.jsxs(ht,{onSubmit:b,noValidate:!0,children:[e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"email",children:"Email Address"}),e.jsx(J,{type:"email",id:"email",value:s,onChange:j=>p(j.target.value),placeholder:"Enter your email",required:!0})]}),$&&e.jsx(In,{children:$.message}),e.jsx(V,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Sending...":"Send Code"})]}),e.jsx(uo,{children:e.jsx(Mr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ar,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="otp"&&e.jsxs(e.Fragment,{children:[e.jsx(Ie,{}),e.jsxs(co,{children:[e.jsx(lo,{children:"Enter Verification Code"}),e.jsxs(Rn,{children:["We've sent a 6-digit code to ",s,". Please enter it below."]})]}),e.jsxs(ht,{onSubmit:g,noValidate:!0,children:[e.jsx(Bt,{onComplete:j=>c(j),isSubmitting:S,error:$==null?void 0:$.message,onResend:async()=>{await y(s)}}),$&&e.jsx(In,{children:$.message}),e.jsx(V,{type:"submit",disabled:S||f.length!==6,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Verifying...":"Verify"})]}),e.jsx(uo,{children:e.jsx(Mr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ar,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]}),n==="reset"&&e.jsxs(e.Fragment,{children:[e.jsx(Ie,{}),e.jsxs(co,{children:[e.jsx(lo,{children:"Reset Password"}),e.jsx(Rn,{children:"Create a new password for your account."})]}),e.jsxs(ht,{onSubmit:C,noValidate:!0,children:[e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"password",children:"New Password"}),e.jsx(J,{type:"password",id:"password",value:u,onChange:j=>m(j.target.value),placeholder:"Enter new password",required:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(J,{type:"password",id:"confirmPassword",value:v,onChange:j=>x(j.target.value),placeholder:"Confirm new password",required:!0})]}),$&&e.jsx(In,{children:$.message}),e.jsx(V,{type:"submit",disabled:S,style:{width:"100%",marginTop:"var(--space-md)"},children:S?"Resetting...":"Reset Password"})]}),e.jsx(uo,{children:e.jsx(Mr,{style:{marginTop:"var(--space-sm)"},children:e.jsx(Ar,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})})]})]})})}const qf=h.div`
|
|
1268
1268
|
max-width: 360px;
|
|
1269
1269
|
width: 360px;
|
|
1270
1270
|
padding: var(--space-2xl);
|
|
@@ -1487,7 +1487,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[so]+=1);/**
|
|
|
1487
1487
|
}
|
|
1488
1488
|
`,Cg=h(J)`
|
|
1489
1489
|
padding: var(--space-sm) var(--space-md);
|
|
1490
|
-
`;function Tl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:a}=xe(),[s,p]=i.useState(""),[f,c]=i.useState({}),[d,l]=i.useState(!1),[u,m]=i.useState(null),[v,x]=i.useState(!0),[y,
|
|
1490
|
+
`;function Tl({onBack:t,attempt:r,completeVerification:o,prepareVerification:n}){const{deployment:a}=xe(),[s,p]=i.useState(""),[f,c]=i.useState({}),[d,l]=i.useState(!1),[u,m]=i.useState(null),[v,x]=i.useState(!0),[y,k]=i.useState(!1),[z,S]=i.useState(""),[_,$]=i.useState(!1),{navigate:w}=Je(),b=(r==null?void 0:r.available_2fa_methods)||[],g=[{id:"authenticator",name:"Authenticator app",description:"Use your authenticator app",icon:e.jsx(yg,{}),available:b.includes("authenticator")},{id:"phone_otp",name:"Text message",description:"Get a code via SMS",icon:e.jsx(bg,{}),available:b.includes("phone_otp"),phoneNumber:z},{id:"backup_code",name:"Backup code",description:"Use one of your backup codes",icon:e.jsx(wg,{}),available:b.includes("backup_code")}].filter(I=>I.available),C=async I=>{m(I),x(!1),I==="phone_otp"&&k(!0)},E=async I=>{var O,P;if(r){l(!0);try{const M=await n({strategy:"phone_otp",lastDigits:I});M&&"data"in M&&((O=M.data)!=null&&O.otp_sent)?((P=M.data)!=null&&P.masked_phone&&S(M.data.masked_phone),k(!1)):c({phone:"Phone number verification failed"})}catch(M){c({phone:M.message})}finally{l(!1)}}},j=async(I,O)=>{if(I.preventDefault(),d)return;const P=O||s,M={};if(P?u==="authenticator"&&P.length!==6?M.code="Authentication code must be 6 digits":u==="phone_otp"&&P.length!==6&&(M.code="SMS code must be 6 digits"):M.code="Verification code is required",c(M),!(Object.keys(M).length>0)){l(!0);try{await o(P)}catch(F){c({submit:F.message})}finally{l(!1)}}},T=I=>{let O=I.target.value;u!=="backup_code"&&(O=O.replace(/\D/g,"").slice(0,6)),p(O),c(P=>({...P,code:""}))};return i.useEffect(()=>{var I;if(r.completed){$(!0);let O=new URLSearchParams(window.location.search).get("redirect_uri");if(O||(O=((I=a==null?void 0:a.ui_settings)==null?void 0:I.after_signin_redirect_url)||null),!O&&(a!=null&&a.frontend_host)&&(O=`https://${a.frontend_host}`),O){let P;try{P=new URL(O)}catch{P=new URL(O,window.location.origin)}(a==null?void 0:a.mode)==="staging"&&P.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),w(P.toString())}return}},[r,a]),_?e.jsx(ue,{children:e.jsxs(Tn,{children:[e.jsx(Ie,{}),e.jsx(_g,{children:e.jsx(zt,{size:32})})]})}):v?g.length===0?e.jsx(ue,{children:e.jsxs(Tn,{children:[e.jsx(Ie,{}),e.jsxs(Os,{children:[e.jsx(Ms,{children:"Set Up Two-Factor Authentication"}),e.jsx(As,{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(Ds,{children:[t&&e.jsx("div",{children:e.jsx(Lr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Lr,{children:e.jsx(st,{to:(a==null?void 0:a.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})}):e.jsx(Rl,{methods:g,onSelectMethod:C,onBack:t}):y&&u==="phone_otp"?e.jsx(Il,{onVerify:E,onBack:()=>{k(!1),x(!0),m(null)},loading:d}):e.jsx(ue,{children:e.jsxs(Tn,{children:[e.jsx(Ie,{}),e.jsxs(Os,{children:[e.jsx(Ms,{children:"Two-factor authentication"}),e.jsxs(As,{children:[u==="authenticator"&&"Enter the 6-digit code from your authenticator app",u==="phone_otp"&&`Enter the 6-digit code sent to your phone ${z}`,u==="backup_code"&&"Enter one of your backup codes"]})]}),e.jsxs(ht,{onSubmit:j,noValidate:!0,children:[u==="backup_code"?e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"code",children:"Backup code"}),e.jsx(Cg,{type:"text",id:"code",name:"code",value:s,onChange:T,placeholder:"Enter backup code",maxLength:20,autoComplete:"one-time-code","aria-invalid":!!f.code,autoFocus:!0}),f.code&&e.jsx(Ls,{children:f.code})]}):e.jsx(Bt,{onComplete:async I=>{if(p(I),u!=="backup_code"){const O=new Event("submit",{bubbles:!0,cancelable:!0});await j(O,I)}},onResend:u==="phone_otp"?async()=>{try{await n({strategy:"phone_otp",lastDigits:z.slice(-4)})}catch(I){c({submit:I.message})}}:void 0,error:f.code,isSubmitting:d}),e.jsxs("div",{children:[f.submit&&e.jsx(Ls,{children:f.submit}),e.jsx(kg,{type:"submit",disabled:d||!s,children:d?"Verifying...":"Verify"})]})]}),e.jsxs(Ds,{children:[e.jsx(Lr,{onClick:()=>{x(!0),m(null),p(""),c({})},style:{cursor:"pointer"},children:"Try another method"}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(Lr,{children:e.jsx(st,{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(Lr,{onClick:t,style:{cursor:"pointer"},children:"Back to login"})})]})]})})}const On=h.div`
|
|
1491
1491
|
max-width: 380px;
|
|
1492
1492
|
width: 380px;
|
|
1493
1493
|
padding: var(--space-3xl);
|
|
@@ -1552,7 +1552,7 @@ See https://s-c.sh/2BAXzed for more info.`),window[so]+=1);/**
|
|
|
1552
1552
|
transform: rotate(360deg);
|
|
1553
1553
|
}
|
|
1554
1554
|
}
|
|
1555
|
-
`;function Ol({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:a}){var L,R,A,B,G,U,ne,K,ge;const{deployment:s}=xe(),{navigate:p}=Je(),[f,c]=i.useState({}),[d,l]=i.useState({}),[u,m]=i.useState("US"),[v,x]=i.useState(!1),[y,
|
|
1555
|
+
`;function Ol({attempt:t,onBack:r,completeProfile:o,completeVerification:n,prepareVerification:a}){var L,R,A,B,G,U,ne,K,ge;const{deployment:s}=xe(),{navigate:p}=Je(),[f,c]=i.useState({}),[d,l]=i.useState({}),[u,m]=i.useState("US"),[v,x]=i.useState(!1),[y,k]=i.useState(!1),[z,S]=i.useState(null),[_,$]=i.useState(!1),w=z,b=y,g=async pe=>{var ae;k(!0),S(null);try{if(await o(pe)){$(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((ae=s==null?void 0:s.ui_settings)==null?void 0:ae.after_signin_redirect_url)||null),!Q&&(s!=null&&s.frontend_host)&&(Q=`https://${s.frontend_host}`),Q){let Se;try{Se=new URL(Q)}catch{Se=new URL(Q,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&Se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(Se.toString())}}}catch(he){const Q=he;throw S(Q),Q}finally{k(!1)}},C=async pe=>{var ae;k(!0),S(null);try{if(await n(pe)){$(!0);let Q=new URLSearchParams(window.location.search).get("redirect_uri");if(Q||(Q=((ae=s==null?void 0:s.ui_settings)==null?void 0:ae.after_signin_redirect_url)||null),!Q&&(s!=null&&s.frontend_host)&&(Q=`https://${s.frontend_host}`),Q){let Se;try{Se=new URL(Q)}catch{Se=new URL(Q,window.location.origin)}(s==null?void 0:s.mode)==="staging"&&Se.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),p(Se.toString())}}return!0}catch(he){return S(he),!1}finally{k(!1)}};if(_||!t)return e.jsx(ue,{children:e.jsxs(On,{children:[e.jsx(Ie,{}),e.jsx(Eg,{children:e.jsx(zt,{size:32})})]})});const E=t.missing_fields||[],j="Complete Your Profile",T="Please provide the following information to continue",I=s==null?void 0:s.auth_settings,O=(t==null?void 0:t.current_step)==="verify_phone_otp"||(t==null?void 0:t.current_step)==="verify_email_otp"||v,P=pe=>{const{name:ae,value:he}=pe.target;c(Q=>({...Q,[ae]:he})),d[ae]&&l(Q=>({...Q,[ae]:""}))},M=()=>{const pe={};return E.forEach(ae=>{var Se,ce,Z,X,ee;const he=f[ae];let Q=!1;switch(ae){case"first_name":Q=((Se=I==null?void 0:I.first_name)==null?void 0:Se.enabled)||!1;break;case"last_name":Q=((ce=I==null?void 0:I.last_name)==null?void 0:ce.enabled)||!1;break;case"username":Q=((Z=I==null?void 0:I.username)==null?void 0:Z.enabled)||!1;break;case"phone_number":Q=((X=I==null?void 0:I.phone_number)==null?void 0:X.enabled)||!1;break;case"email_address":Q=((ee=I==null?void 0:I.email_address)==null?void 0:ee.enabled)||!1;break;default:Q=!0}if(Q&&(!he||he.trim()==="")){const te=ae.replace("_"," ").replace(/\b\w/g,W=>W.toUpperCase());pe[ae]=`${te} is required`}}),f.username&&E.includes("username")&&(/^[a-zA-Z0-9_-]{3,30}$/.test(f.username)||(pe.username="Username must be 3-30 characters and contain only letters, numbers, underscores, and hyphens")),f.phone_number&&E.includes("phone_number")&&(/^\d{7,15}$/.test(f.phone_number)||(pe.phone_number="Phone number must contain 7-15 digits")),f.email&&E.includes("email_address")&&(/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(f.email)||(pe.email_address="Please enter a valid email address")),l(pe),Object.keys(pe).length===0},F=async pe=>{if(pe.preventDefault(),!M())return;const ae={...f};f.phone_number&&u&&(ae.phone_country_code=u),await g(ae)},D=pe=>{const ae=pe.target.value;c(he=>({...he,phone_number:ae})),d.phone_number&&l(he=>({...he,phone_number:""}))};if(O){const pe=t.current_step==="verify_phone_otp"?"Verify Your Phone Number":"Verify Your Email",ae=t.current_step==="verify_phone_otp"?"Enter the 6-digit code sent to your phone":"Enter the 6-digit code sent to your email",he=t.current_step==="verify_phone_otp"?"phone_otp":"email_otp";return e.jsx(ue,{children:e.jsxs(On,{children:[e.jsx(Ie,{}),e.jsxs(Fs,{children:[e.jsx(Ns,{children:pe}),e.jsx(Bs,{children:ae})]}),e.jsxs(ht,{onSubmit:Q=>Q.preventDefault(),noValidate:!0,children:[e.jsx(Bt,{onComplete:C,onResend:async()=>{await a({strategy:he})},error:w==null?void 0:w.message,isSubmitting:b}),w&&e.jsx(Ht,{style:{marginBottom:"var(--space-md)"},children:w.message})]}),e.jsxs(Us,{children:[e.jsx("div",{children:e.jsx(po,{onClick:()=>x(!1),style:{cursor:"pointer"},children:"Back to profile completion"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(po,{children:e.jsx(st,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}return e.jsx(ue,{children:e.jsxs(On,{children:[e.jsx(Ie,{}),e.jsxs(Fs,{children:[e.jsx(Ns,{children:j}),e.jsx(Bs,{children:T})]}),e.jsxs(ht,{onSubmit:F,noValidate:!0,children:[(E.includes("first_name")||E.includes("last_name"))&&(((L=I==null?void 0:I.first_name)==null?void 0:L.enabled)||((R=I==null?void 0:I.last_name)==null?void 0:R.enabled))&&e.jsxs(Sg,{$isBothEnabled:!!((A=I==null?void 0:I.first_name)!=null&&A.enabled&&((B=I==null?void 0:I.last_name)!=null&&B.enabled)&&E.includes("first_name")&&E.includes("last_name")),children:[E.includes("first_name")&&((G=I==null?void 0:I.first_name)==null?void 0:G.enabled)&&e.jsxs(ie,{children:[e.jsxs(oe,{htmlFor:"first_name",children:["First name ",I.first_name.required&&"*"]}),e.jsx(J,{type:"text",id:"first_name",name:"first_name",value:f.first_name||"",onChange:P,placeholder:"Enter your first name","aria-invalid":!!d.first_name,disabled:b,autoComplete:"given-name"}),d.first_name&&e.jsx(Ht,{children:d.first_name})]}),E.includes("last_name")&&((U=I==null?void 0:I.last_name)==null?void 0:U.enabled)&&e.jsxs(ie,{children:[e.jsxs(oe,{htmlFor:"last_name",children:["Last name ",I.last_name.required&&"*"]}),e.jsx(J,{type:"text",id:"last_name",name:"last_name",value:f.last_name||"",onChange:P,placeholder:"Enter your last name","aria-invalid":!!d.last_name,disabled:b,autoComplete:"family-name"}),d.last_name&&e.jsx(Ht,{children:d.last_name})]})]}),E.includes("username")&&((ne=I==null?void 0:I.username)==null?void 0:ne.enabled)&&e.jsxs(ie,{children:[e.jsxs(oe,{htmlFor:"username",children:["Username ",I.username.required&&"*"]}),e.jsx(J,{type:"text",id:"username",name:"username",value:f.username||"",onChange:P,placeholder:"Choose a username","aria-invalid":!!d.username,disabled:b,autoComplete:"username"}),d.username&&e.jsx(Ht,{children:d.username})]}),E.includes("phone_number")&&((K=I==null?void 0:I.phone_number)==null?void 0:K.enabled)&&e.jsxs(ie,{children:[e.jsxs(oe,{htmlFor:"phone_number",children:["Phone number ",I.phone_number.required&&"*"]}),e.jsx(Zr,{value:f.phone_number||"",onChange:D,error:d.phone_number,countryCode:u,setCountryCode:m}),d.phone_number&&e.jsx(Ht,{children:d.phone_number})]}),E.includes("email_address")&&((ge=I==null?void 0:I.email_address)==null?void 0:ge.enabled)&&e.jsxs(ie,{children:[e.jsxs(oe,{htmlFor:"email",children:["Email address ",I.email_address.required&&"*"]}),e.jsx(J,{type:"email",id:"email",name:"email",value:f.email||"",onChange:P,placeholder:"Enter your email address","aria-invalid":!!d.email_address,disabled:b,autoComplete:"email"}),d.email_address&&e.jsx(Ht,{children:d.email_address})]}),w&&e.jsx(Ht,{style:{marginBottom:"var(--space-md)"},children:w.message}),e.jsx(zg,{type:"submit",disabled:b,children:b?"Completing...":"Continue"})]}),e.jsxs(Us,{children:[r&&e.jsx("div",{children:e.jsx(po,{onClick:r,style:{cursor:"pointer"},children:"Back to login"})}),e.jsxs("div",{style:{marginTop:"var(--space-sm)"},children:["Having trouble?"," ",e.jsx(po,{children:e.jsx(st,{to:(s==null?void 0:s.ui_settings.support_page_url)||"#",children:"Get help"})})]})]})]})})}const $g=h.div`
|
|
1556
1556
|
text-align: center;
|
|
1557
1557
|
margin-bottom: var(--space-2xl);
|
|
1558
1558
|
`,Pg=h.div`
|
|
@@ -1776,7 +1776,7 @@ cursor: pointer;
|
|
|
1776
1776
|
&:hover {
|
|
1777
1777
|
color: var(--color-primary-hover);
|
|
1778
1778
|
}
|
|
1779
|
-
`;function Yg(){return e.jsx(Bf,{children:e.jsx(Zg,{})})}function Zg(){var te,W,Y,se,le,q,me,H,we,Te,Ye,Re,Wt,bt,Kr,Qr;const{deployment:t}=xe(),{navigate:r}=Je(),{session:o,loading:n,refetch:a}=He(),s=((W=(te=t==null?void 0:t.auth_settings)==null?void 0:te.multi_session_support)==null?void 0:W.enabled)??!1,{setEmail:p,otpSent:f,setOtpSent:c,showForgotPassword:d,setShowForgotPassword:l,showOtherOptions:u,setShowOtherOptions:m,enabledSocialsProviders:v,firstFactor:x,signInStep:y,setSignInStep:S}=$l(),{loading:k,signIn:z,signinAttempt:_,discardSignInAttempt:$,setSignInAttempt:w}=jr("generic"),{signIn:b}=jr("oauth"),{signIn:g}=jr("passkey"),[C,E]=i.useState({email:"",username:"",password:"",phone:""}),[j,T]=i.useState({}),[I,O]=i.useState(!1),[P,M]=i.useState(""),[F,D]=i.useState("US"),[L,R]=i.useState(!1),[A,B]=i.useState(null),[G,U]=i.useState(!1),[ne,K]=i.useState(null);i.useEffect(()=>{const fe=new URLSearchParams(window.location.search),de=fe.get("error"),ve=fe.get("error_description");if(de==="access_denied"&&ve){B(ve),fe.delete("error"),fe.delete("error_description");const je=fe.toString()?`${window.location.pathname}?${fe.toString()}`:window.location.pathname;window.history.replaceState({},"",je)}},[]),i.useEffect(()=>{var fe,de,ve,je;if(!n&&(o!=null&&o.active_signin)&&!s&&!L&&!G){let Ee=new URLSearchParams(window.location.search).get("redirect_uri");Ee||(Ee=((fe=t==null?void 0:t.ui_settings)==null?void 0:fe.after_signin_redirect_url)||null),!Ee&&(t!=null&&t.frontend_host)&&(Ee=`https://${t.frontend_host}`);const Be=(de=t==null?void 0:t.auth_settings)==null?void 0:de.passkey;(Be==null?void 0:Be.enabled)&&(Be==null?void 0:Be.prompt_registration_on_auth)&&!((je=(ve=o.active_signin)==null?void 0:ve.user)!=null&&je.has_passkeys)?(K(Ee),U(!0)):Ee&&(R(!0),r(Ee))}},[o,n,s,t,r,L]);const ge=fe=>{let{name:de,value:ve}=fe.target;de==="phone"?ve=ve.replace(/[^0-9]/g,""):de==="email"&&(p(ve),ve=ve.toLowerCase()),E(je=>({...je,[de]:ve})),T(je=>({...je,[de]:""}))},pe=()=>{E({email:"",username:"",password:"",phone:""}),T({}),D("US"),S("identifier")},ae=async fe=>{if(!fe){T({email:"Email address is required"});return}O(!0),T({});try{const de=await z.identify(fe);if(de.strategy==="sso"&&de.connection_id){const je=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Ee=await z.initEnterpriseSso(de.connection_id,je);if(Ee&&Ee.sso_url){R(!0),window.location.href=Ee.sso_url;return}}else if(de.strategy==="social"&&de.provider){const ve=v.find(je=>je.provider===de.provider);if(ve){const Ee=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Be}=await b.create({provider:ve.provider,redirectUri:Ee});if(Be&&typeof Be=="object"&&"oauth_url"in Be){R(!0),window.location.href=Be.oauth_url;return}}else S("password")}else S("password")}catch(de){T({submit:de.message})}finally{L||O(!1)}},he=async fe=>{if(fe.preventDefault(),k||I)return;$();const de={};if(y==="identifier"&&x==="email_password"){if(!C.email){T({email:"Email address is required"});return}await ae(C.email);return}if(x==="email_password"?(C.email||(de.email="Email address is required"),C.password||(de.password="Password is required")):x==="username_password"?(C.username||(de.username="Username is required"),C.password||(de.password="Password is required")):x==="email_otp"||x==="email_magic_link"?C.email||(de.email="Email address is required"):x==="phone_otp"&&(C.phone?/^\d{7,15}$/.test(C.phone)||(de.phone="Phone number must contain 7-15 digits"):de.phone="Phone number is required"),T(de),Object.keys(de).length>0)return;let ve="";switch(x){case"email_password":ve="plain_email";break;case"username_password":ve="plain_username";break;case"email_otp":ve="email_otp";break;case"email_magic_link":ve="magic_link";break;case"phone_otp":ve="phone_otp";break}O(!0);try{const je={...C,strategy:ve};x==="phone_otp"&&F&&(je.phone_country_code=F),await z.create(je)}catch(je){T({submit:je.message}),O(!1)}},Q=async fe=>{if(fe.preventDefault(),k||I)return;const de={};if(!P){de.otp="OTP code is required",T(de);return}O(!0),T({});try{await z.completeVerification(P),c(!1),M("")}catch(ve){T({otp:ve.message||"Verification failed"})}finally{O(!1)}},Se=async fe=>{if(!(k||I)){O(!0);try{const ve=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:je}=await b.create({provider:fe.provider,redirectUri:ve});je&&typeof je=="object"&&"oauth_url"in je&&(window.location.href=je.oauth_url)}catch(de){T({submit:de.message})}finally{O(!1)}}},ce=async()=>{var fe;if(!(k||I)){O(!0),T({});try{const de=await g.create();if("data"in de&&de.data){await a();let ve=new URLSearchParams(window.location.search).get("redirect_uri");ve||(ve=((fe=t==null?void 0:t.ui_settings)==null?void 0:fe.after_signin_redirect_url)||null),!ve&&(t!=null&&t.frontend_host)&&(ve=`https://${t.frontend_host}`),R(!0),ve&&r(ve)}}catch(de){T({submit:de.message||"Passkey sign-in failed"})}finally{O(!1)}}},Z=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const fe=new URLSearchParams(window.location.search),de=fe.get("impersonation_token");if(de&&!_&&!k&&!Z.current){Z.current=!0,fe.delete("impersonation_token");const je=fe.toString()?`${window.location.pathname}?${fe.toString()} `:window.location.pathname;window.history.replaceState({},"",je),(async()=>{try{O(!0),await z.create({strategy:"impersonation",token:de})}catch(Be){T({submit:Be.message}),O(!1),Z.current=!1}})();return}const ve=fe.get("signin_attempt_id");if(ve&&(o!=null&&o.signin_attempts)&&!_){const je=o.signin_attempts.find(Ee=>Ee.id===ve);if(je){w(je),fe.delete("signin_attempt_id");const Ee=fe.toString()?`${window.location.pathname}?${fe.toString()} `:window.location.pathname;window.history.replaceState({},"",Ee)}}},[o,n,_,w,k]),i.useEffect(()=>{var je;if(!_)return;if(_.completed){R(!0);let Ee=new URLSearchParams(window.location.search).get("redirect_uri");if(Ee||(Ee=((je=t==null?void 0:t.ui_settings)==null?void 0:je.after_signin_redirect_url)||null),!Ee&&(t!=null&&t.frontend_host)&&(Ee=`https://${t.frontend_host}`),Ee){let Be;try{Be=new URL(Ee)}catch{Be=new URL(Ee,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Be.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(Be.toString())}return}if(!z||f)return;const de={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[_.current_step];if(!de)return;(async()=>{try{await z.prepareVerification({strategy:de}),c(!0)}catch(Ee){console.error("Failed to prepare verification:",Ee),T({submit:"Failed to send verification. Please try again."})}finally{O(!1)}})()},[_,z,f,c,r,t]),i.useEffect(()=>{},[]),u)return e.jsx(Jf,{onBack:()=>m(!1)});if(d)return e.jsx(Hf,{onBack:()=>l(!1)});if((_==null?void 0:_.current_step)==="verify_second_factor")return e.jsx(Tl,{attempt:_,completeVerification:z.completeVerification,prepareVerification:z.prepareVerification,onBack:()=>{$(),pe(),c(!1)}});if((_==null?void 0:_.current_step)==="complete_profile")return e.jsx(Ol,{attempt:_,completeProfile:z.completeProfile,completeVerification:z.completeVerification,prepareVerification:z.prepareVerification,onBack:()=>{$(),pe(),c(!1)}});if(G){const fe=()=>{U(!1),ne&&(R(!0),r(ne))},de=()=>{U(!1),ne&&(R(!0),r(ne))};return e.jsx(ue,{children:e.jsxs(ho,{children:[e.jsx(Ie,{}),e.jsx(Ml,{onComplete:fe,onSkip:de})]})})}if(n)return e.jsx(ue,{children:e.jsxs(ho,{children:[e.jsx(Ie,{}),e.jsx(Ws,{children:e.jsx(zt,{size:32})})]})});if(L)return e.jsx(ue,{children:e.jsxs(ho,{children:[e.jsx(Ie,{}),e.jsx(Ws,{children:e.jsx(zt,{size:32})})]})});const ee=(_==null?void 0:_.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(_.current_step)&&f;return e.jsx(ue,{children:e.jsxs(ho,{children:[e.jsx(Ie,{}),ee?e.jsx(e.Fragment,{children:e.jsxs(Vs,{children:[e.jsx(Gs,{children:x==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Hs,{children:x==="email_magic_link"?`If ${C.email} exists in our records, you will receive a magic link. Click the link to sign in.`:x==="phone_otp"?`If ${C.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${C.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(Vs,{children:[e.jsx(Gs,{children:"Sign in to your account"}),e.jsxs(Hs,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),A&&e.jsxs(Vg,{children:[e.jsx(Gg,{children:"Access Denied"}),e.jsx(Hg,{children:A}),e.jsx(qg,{onClick:()=>B(null),children:"Try again"})]}),ee?x==="email_magic_link"?e.jsxs(Mn,{children:["Having trouble?"," ",e.jsx(qt,{children:e.jsx(st,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(qt,{onClick:()=>{c(!1),$(),pe()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ht,{style:{gap:"15px"},onSubmit:Q,noValidate:!0,children:[e.jsx(Bt,{onComplete:async fe=>{if(M(fe),fe&&fe.length===6){O(!0),T({});try{await z.completeVerification(fe),c(!1)}catch(de){T({otp:de.message||"Verification failed"})}finally{O(!1)}}},onResend:async()=>{const fe=x==="email_otp"?"email_otp":"phone_otp";await z.prepareVerification({strategy:fe})},error:j.otp,isSubmitting:I}),e.jsx(qs,{type:"submit",disabled:I||k||!P,style:{margin:0},children:I?"Verifying...":`Continue to ${(Qr=t==null?void 0:t.ui_settings)==null?void 0:Qr.app_name}`})]}),e.jsxs(Mn,{children:["Having trouble?"," ",e.jsx(qt,{children:e.jsx(st,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(qt,{onClick:()=>{c(!1),$(),pe()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[v.length>0&&e.jsx(e.Fragment,{children:e.jsx(Ia,{connections:v,callback:Se})}),((se=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.passkey)==null?void 0:se.enabled)&&e.jsxs(Wg,{type:"button",onClick:ce,disabled:I,children:[e.jsx(xa,{size:18}),"Sign in with Passkey"]}),(v.length>0||((q=(le=t==null?void 0:t.auth_settings)==null?void 0:le.passkey)==null?void 0:q.enabled))&&e.jsx(Fg,{children:e.jsx(Ng,{children:"or"})}),e.jsxs(ht,{onSubmit:he,noValidate:!0,children:[(x==="email_password"||x==="email_otp"||x==="email_magic_link")&&((H=(me=t==null?void 0:t.auth_settings)==null?void 0:me.email_address)==null?void 0:H.enabled)&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"email",children:"Email address"}),e.jsx(J,{type:"email",id:"email",name:"email",value:C.email,onChange:ge,placeholder:"Enter your email address","aria-invalid":!!j.email}),j.email&&e.jsx(Dr,{children:j.email})]}),x==="username_password"&&((Te=(we=t==null?void 0:t.auth_settings)==null?void 0:we.username)==null?void 0:Te.enabled)&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"username",children:"Username"}),e.jsx(J,{type:"text",id:"username",name:"username",value:C.username,onChange:ge,placeholder:"Enter your username","aria-invalid":!!j.username}),j.username&&e.jsx(Dr,{children:j.username})]}),x==="phone_otp"&&((Re=(Ye=t==null?void 0:t.auth_settings)==null?void 0:Ye.phone_number)==null?void 0:Re.enabled)&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"phone",children:"Phone number"}),e.jsx(Zr,{value:C.phone,onChange:ge,error:j.phone,countryCode:F,setCountryCode:D}),j.phone&&e.jsx(Dr,{children:j.phone})]}),y==="password"&&(x==="email_password"||x==="username_password")&&((bt=(Wt=t==null?void 0:t.auth_settings)==null?void 0:Wt.password)==null?void 0:bt.enabled)&&e.jsxs(ie,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(oe,{htmlFor:"password",children:"Password"}),e.jsx(qt,{style:{fontSize:"12px"},onClick:()=>l(!0),children:"Forgot password?"})]}),e.jsx(Bg,{children:e.jsx(J,{type:"password",id:"password",name:"password",value:C.password,onChange:ge,placeholder:"Enter your password","aria-invalid":!!j.password})}),j.password&&e.jsx(Dr,{children:j.password})]}),e.jsxs("div",{children:[j.submit&&e.jsx(Dr,{children:j.submit}),e.jsx(qs,{type:"submit",disabled:I||k,children:I?e.jsx(Ug,{size:16}):y==="identifier"?"Continue":"Sign in"})]}),e.jsx(qt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>m(!0),children:"Use other methods"})]}),e.jsxs(Mn,{children:["Don't have an account?"," ",e.jsx(qt,{children:e.jsx(st,{to:`${(Kr=t.ui_settings)==null?void 0:Kr.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Ys=h.div`
|
|
1779
|
+
`;function Yg(){return e.jsx(Bf,{children:e.jsx(Zg,{})})}function Zg(){var te,W,Y,se,le,q,me,H,we,Te,Ye,Re,Wt,bt,Kr,Qr;const{deployment:t}=xe(),{navigate:r}=Je(),{session:o,loading:n,refetch:a}=He(),s=((W=(te=t==null?void 0:t.auth_settings)==null?void 0:te.multi_session_support)==null?void 0:W.enabled)??!1,{setEmail:p,otpSent:f,setOtpSent:c,showForgotPassword:d,setShowForgotPassword:l,showOtherOptions:u,setShowOtherOptions:m,enabledSocialsProviders:v,firstFactor:x,signInStep:y,setSignInStep:k}=$l(),{loading:z,signIn:S,signinAttempt:_,discardSignInAttempt:$,setSignInAttempt:w}=jr("generic"),{signIn:b}=jr("oauth"),{signIn:g}=jr("passkey"),[C,E]=i.useState({email:"",username:"",password:"",phone:""}),[j,T]=i.useState({}),[I,O]=i.useState(!1),[P,M]=i.useState(""),[F,D]=i.useState("US"),[L,R]=i.useState(!1),[A,B]=i.useState(null),[G,U]=i.useState(!1),[ne,K]=i.useState(null);i.useEffect(()=>{const fe=new URLSearchParams(window.location.search),de=fe.get("error"),ve=fe.get("error_description");if(de==="access_denied"&&ve){B(ve),fe.delete("error"),fe.delete("error_description");const je=fe.toString()?`${window.location.pathname}?${fe.toString()}`:window.location.pathname;window.history.replaceState({},"",je)}},[]),i.useEffect(()=>{var fe,de,ve,je;if(!n&&(o!=null&&o.active_signin)&&!s&&!L&&!G){let Ee=new URLSearchParams(window.location.search).get("redirect_uri");Ee||(Ee=((fe=t==null?void 0:t.ui_settings)==null?void 0:fe.after_signin_redirect_url)||null),!Ee&&(t!=null&&t.frontend_host)&&(Ee=`https://${t.frontend_host}`);const Be=(de=t==null?void 0:t.auth_settings)==null?void 0:de.passkey;(Be==null?void 0:Be.enabled)&&(Be==null?void 0:Be.prompt_registration_on_auth)&&!((je=(ve=o.active_signin)==null?void 0:ve.user)!=null&&je.has_passkeys)?(K(Ee),U(!0)):Ee&&(R(!0),r(Ee))}},[o,n,s,t,r,L]);const ge=fe=>{let{name:de,value:ve}=fe.target;de==="phone"?ve=ve.replace(/[^0-9]/g,""):de==="email"&&(p(ve),ve=ve.toLowerCase()),E(je=>({...je,[de]:ve})),T(je=>({...je,[de]:""}))},pe=()=>{E({email:"",username:"",password:"",phone:""}),T({}),D("US"),k("identifier")},ae=async fe=>{if(!fe){T({email:"Email address is required"});return}O(!0),T({});try{const de=await S.identify(fe);if(de.strategy==="sso"&&de.connection_id){const je=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,Ee=await S.initEnterpriseSso(de.connection_id,je);if(Ee&&Ee.sso_url){R(!0),window.location.href=Ee.sso_url;return}}else if(de.strategy==="social"&&de.provider){const ve=v.find(je=>je.provider===de.provider);if(ve){const Ee=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:Be}=await b.create({provider:ve.provider,redirectUri:Ee});if(Be&&typeof Be=="object"&&"oauth_url"in Be){R(!0),window.location.href=Be.oauth_url;return}}else k("password")}else k("password")}catch(de){T({submit:de.message})}finally{L||O(!1)}},he=async fe=>{if(fe.preventDefault(),z||I)return;$();const de={};if(y==="identifier"&&x==="email_password"){if(!C.email){T({email:"Email address is required"});return}await ae(C.email);return}if(x==="email_password"?(C.email||(de.email="Email address is required"),C.password||(de.password="Password is required")):x==="username_password"?(C.username||(de.username="Username is required"),C.password||(de.password="Password is required")):x==="email_otp"||x==="email_magic_link"?C.email||(de.email="Email address is required"):x==="phone_otp"&&(C.phone?/^\d{7,15}$/.test(C.phone)||(de.phone="Phone number must contain 7-15 digits"):de.phone="Phone number is required"),T(de),Object.keys(de).length>0)return;let ve="";switch(x){case"email_password":ve="plain_email";break;case"username_password":ve="plain_username";break;case"email_otp":ve="email_otp";break;case"email_magic_link":ve="magic_link";break;case"phone_otp":ve="phone_otp";break}O(!0);try{const je={...C,strategy:ve};x==="phone_otp"&&F&&(je.phone_country_code=F),await S.create(je)}catch(je){T({submit:je.message}),O(!1)}},Q=async fe=>{if(fe.preventDefault(),z||I)return;const de={};if(!P){de.otp="OTP code is required",T(de);return}O(!0),T({});try{await S.completeVerification(P),c(!1),M("")}catch(ve){T({otp:ve.message||"Verification failed"})}finally{O(!1)}},Se=async fe=>{if(!(z||I)){O(!0);try{const ve=new URLSearchParams(window.location.search).get("redirect_uri")||void 0,{data:je}=await b.create({provider:fe.provider,redirectUri:ve});je&&typeof je=="object"&&"oauth_url"in je&&(window.location.href=je.oauth_url)}catch(de){T({submit:de.message})}finally{O(!1)}}},ce=async()=>{var fe;if(!(z||I)){O(!0),T({});try{const de=await g.create();if("data"in de&&de.data){await a();let ve=new URLSearchParams(window.location.search).get("redirect_uri");ve||(ve=((fe=t==null?void 0:t.ui_settings)==null?void 0:fe.after_signin_redirect_url)||null),!ve&&(t!=null&&t.frontend_host)&&(ve=`https://${t.frontend_host}`),R(!0),ve&&r(ve)}}catch(de){T({submit:de.message||"Passkey sign-in failed"})}finally{O(!1)}}},Z=i.useRef(!1);if(i.useEffect(()=>{if(n)return;const fe=new URLSearchParams(window.location.search),de=fe.get("impersonation_token");if(de&&!_&&!z&&!Z.current){Z.current=!0,fe.delete("impersonation_token");const je=fe.toString()?`${window.location.pathname}?${fe.toString()} `:window.location.pathname;window.history.replaceState({},"",je),(async()=>{try{O(!0),await S.create({strategy:"impersonation",token:de})}catch(Be){T({submit:Be.message}),O(!1),Z.current=!1}})();return}const ve=fe.get("signin_attempt_id");if(ve&&(o!=null&&o.signin_attempts)&&!_){const je=o.signin_attempts.find(Ee=>Ee.id===ve);if(je){w(je),fe.delete("signin_attempt_id");const Ee=fe.toString()?`${window.location.pathname}?${fe.toString()} `:window.location.pathname;window.history.replaceState({},"",Ee)}}},[o,n,_,w,z]),i.useEffect(()=>{var je;if(!_)return;if(_.completed){R(!0);let Ee=new URLSearchParams(window.location.search).get("redirect_uri");if(Ee||(Ee=((je=t==null?void 0:t.ui_settings)==null?void 0:je.after_signin_redirect_url)||null),!Ee&&(t!=null&&t.frontend_host)&&(Ee=`https://${t.frontend_host}`),Ee){let Be;try{Be=new URL(Ee)}catch{Be=new URL(Ee,window.location.origin)}(t==null?void 0:t.mode)==="staging"&&Be.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),r(Be.toString())}return}if(!S||f)return;const de={verify_email:"email_otp",verify_email_otp:"email_otp",verify_email_link:"magic_link",verify_phone:"phone_otp",verify_phone_otp:"phone_otp"}[_.current_step];if(!de)return;(async()=>{try{await S.prepareVerification({strategy:de}),c(!0)}catch(Ee){console.error("Failed to prepare verification:",Ee),T({submit:"Failed to send verification. Please try again."})}finally{O(!1)}})()},[_,S,f,c,r,t]),i.useEffect(()=>{},[]),u)return e.jsx(Jf,{onBack:()=>m(!1)});if(d)return e.jsx(Hf,{onBack:()=>l(!1)});if((_==null?void 0:_.current_step)==="verify_second_factor")return e.jsx(Tl,{attempt:_,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{$(),pe(),c(!1)}});if((_==null?void 0:_.current_step)==="complete_profile")return e.jsx(Ol,{attempt:_,completeProfile:S.completeProfile,completeVerification:S.completeVerification,prepareVerification:S.prepareVerification,onBack:()=>{$(),pe(),c(!1)}});if(G){const fe=()=>{U(!1),ne&&(R(!0),r(ne))},de=()=>{U(!1),ne&&(R(!0),r(ne))};return e.jsx(ue,{children:e.jsxs(ho,{children:[e.jsx(Ie,{}),e.jsx(Ml,{onComplete:fe,onSkip:de})]})})}if(n)return e.jsx(ue,{children:e.jsxs(ho,{children:[e.jsx(Ie,{}),e.jsx(Ws,{children:e.jsx(zt,{size:32})})]})});if(L)return e.jsx(ue,{children:e.jsxs(ho,{children:[e.jsx(Ie,{}),e.jsx(Ws,{children:e.jsx(zt,{size:32})})]})});const ee=(_==null?void 0:_.current_step)&&["verify_email","verify_email_otp","verify_email_link","verify_phone","verify_phone_otp"].includes(_.current_step)&&f;return e.jsx(ue,{children:e.jsxs(ho,{children:[e.jsx(Ie,{}),ee?e.jsx(e.Fragment,{children:e.jsxs(Vs,{children:[e.jsx(Gs,{children:x==="phone_otp"?"Check your phone":"Check your email"}),e.jsx(Hs,{children:x==="email_magic_link"?`If ${C.email} exists in our records, you will receive a magic link. Click the link to sign in.`:x==="phone_otp"?`If ${C.phone} exists in our records, you will receive a verification code via SMS. Enter it below to continue.`:`If ${C.email} exists in our records, you will receive a verification code. Enter it below to continue.`})]})}):e.jsxs(Vs,{children:[e.jsx(Gs,{children:"Sign in to your account"}),e.jsxs(Hs,{children:["Please enter your details to continue to"," ",(t==null?void 0:t.ui_settings.app_name)||"App","!"]})]}),A&&e.jsxs(Vg,{children:[e.jsx(Gg,{children:"Access Denied"}),e.jsx(Hg,{children:A}),e.jsx(qg,{onClick:()=>B(null),children:"Try again"})]}),ee?x==="email_magic_link"?e.jsxs(Mn,{children:["Having trouble?"," ",e.jsx(qt,{children:e.jsx(st,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(qt,{onClick:()=>{c(!1),$(),pe()},style:{cursor:"pointer"},children:"Back to login"})})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ht,{style:{gap:"15px"},onSubmit:Q,noValidate:!0,children:[e.jsx(Bt,{onComplete:async fe=>{if(M(fe),fe&&fe.length===6){O(!0),T({});try{await S.completeVerification(fe),c(!1)}catch(de){T({otp:de.message||"Verification failed"})}finally{O(!1)}}},onResend:async()=>{const fe=x==="email_otp"?"email_otp":"phone_otp";await S.prepareVerification({strategy:fe})},error:j.otp,isSubmitting:I}),e.jsx(qs,{type:"submit",disabled:I||z||!P,style:{margin:0},children:I?"Verifying...":`Continue to ${(Qr=t==null?void 0:t.ui_settings)==null?void 0:Qr.app_name}`})]}),e.jsxs(Mn,{children:["Having trouble?"," ",e.jsx(qt,{children:e.jsx(st,{to:t.ui_settings.support_page_url,children:"Get help"})}),e.jsx("div",{style:{marginTop:"var(--space-sm)"},children:e.jsx(qt,{onClick:()=>{c(!1),$(),pe()},style:{cursor:"pointer"},children:"Back to login"})})]})]}):e.jsxs(e.Fragment,{children:[v.length>0&&e.jsx(e.Fragment,{children:e.jsx(Ia,{connections:v,callback:Se})}),((se=(Y=t==null?void 0:t.auth_settings)==null?void 0:Y.passkey)==null?void 0:se.enabled)&&e.jsxs(Wg,{type:"button",onClick:ce,disabled:I,children:[e.jsx(xa,{size:18}),"Sign in with Passkey"]}),(v.length>0||((q=(le=t==null?void 0:t.auth_settings)==null?void 0:le.passkey)==null?void 0:q.enabled))&&e.jsx(Fg,{children:e.jsx(Ng,{children:"or"})}),e.jsxs(ht,{onSubmit:he,noValidate:!0,children:[(x==="email_password"||x==="email_otp"||x==="email_magic_link")&&((H=(me=t==null?void 0:t.auth_settings)==null?void 0:me.email_address)==null?void 0:H.enabled)&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"email",children:"Email address"}),e.jsx(J,{type:"email",id:"email",name:"email",value:C.email,onChange:ge,placeholder:"Enter your email address","aria-invalid":!!j.email}),j.email&&e.jsx(Dr,{children:j.email})]}),x==="username_password"&&((Te=(we=t==null?void 0:t.auth_settings)==null?void 0:we.username)==null?void 0:Te.enabled)&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"username",children:"Username"}),e.jsx(J,{type:"text",id:"username",name:"username",value:C.username,onChange:ge,placeholder:"Enter your username","aria-invalid":!!j.username}),j.username&&e.jsx(Dr,{children:j.username})]}),x==="phone_otp"&&((Re=(Ye=t==null?void 0:t.auth_settings)==null?void 0:Ye.phone_number)==null?void 0:Re.enabled)&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"phone",children:"Phone number"}),e.jsx(Zr,{value:C.phone,onChange:ge,error:j.phone,countryCode:F,setCountryCode:D}),j.phone&&e.jsx(Dr,{children:j.phone})]}),y==="password"&&(x==="email_password"||x==="username_password")&&((bt=(Wt=t==null?void 0:t.auth_settings)==null?void 0:Wt.password)==null?void 0:bt.enabled)&&e.jsxs(ie,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[e.jsx(oe,{htmlFor:"password",children:"Password"}),e.jsx(qt,{style:{fontSize:"12px"},onClick:()=>l(!0),children:"Forgot password?"})]}),e.jsx(Bg,{children:e.jsx(J,{type:"password",id:"password",name:"password",value:C.password,onChange:ge,placeholder:"Enter your password","aria-invalid":!!j.password})}),j.password&&e.jsx(Dr,{children:j.password})]}),e.jsxs("div",{children:[j.submit&&e.jsx(Dr,{children:j.submit}),e.jsx(qs,{type:"submit",disabled:I||z,children:I?e.jsx(Ug,{size:16}):y==="identifier"?"Continue":"Sign in"})]}),e.jsx(qt,{style:{fontSize:"12px",textAlign:"center"},onClick:()=>m(!0),children:"Use other methods"})]}),e.jsxs(Mn,{children:["Don't have an account?"," ",e.jsx(qt,{children:e.jsx(st,{to:`${(Kr=t.ui_settings)==null?void 0:Kr.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})]})})}const Ys=h.div`
|
|
1780
1780
|
max-width: 380px;
|
|
1781
1781
|
width: 380px;
|
|
1782
1782
|
padding: var(--space-3xl);
|
|
@@ -1877,7 +1877,7 @@ cursor: pointer;
|
|
|
1877
1877
|
color: var(--color-primary);
|
|
1878
1878
|
text-decoration: none;
|
|
1879
1879
|
cursor: pointer;
|
|
1880
|
-
`;function lm(){var
|
|
1880
|
+
`;function lm(){var k,z,S,_,$,w,b,g,C,E,j,T;const{deployment:t}=xe(),{loading:r,joinWaitlist:o}=$c(),[n,a]=i.useState({first_name:"",last_name:"",email:""}),[s,p]=i.useState(!1),[f,c]=i.useState(!1),[d,l]=i.useState(null),u=I=>{if(d)return d.message},m=t==null?void 0:t.auth_settings,v=!!((k=m==null?void 0:m.first_name)!=null&&k.enabled&&((z=m==null?void 0:m.last_name)!=null&&z.enabled)),x=I=>{const{name:O,value:P}=I.target;a(M=>({...M,[O]:P}))},y=async I=>{if(I.preventDefault(),!!m){c(!0),l(null);try{(await o(n)).data&&p(!0)}catch(O){l(O)}finally{c(!1)}}};return s?e.jsx(ue,{children:e.jsx(Ys,{children:e.jsxs(rm,{children:[e.jsx(om,{children:e.jsx(Qe,{size:32})}),e.jsx(nm,{children:"You're on the waitlist!"}),e.jsxs(am,{children:["Thanks for your interest! We'll notify you at ",n.email," ","when we're ready for you to join."]})]})})}):e.jsx(ue,{children:e.jsxs(Ys,{children:[e.jsx(Ie,{}),e.jsxs(Kg,{children:[e.jsx(Qg,{children:"Join the waitlist"}),e.jsx(Jg,{children:"Be the first to know when we launch!"})]}),e.jsxs(Xg,{onSubmit:y,noValidate:!0,children:[(((S=m==null?void 0:m.first_name)==null?void 0:S.enabled)||((_=m==null?void 0:m.last_name)==null?void 0:_.enabled))&&e.jsxs(em,{$isBothEnabled:v,children:[(($=m==null?void 0:m.first_name)==null?void 0:$.enabled)&&e.jsxs(An,{children:[e.jsxs(Ln,{htmlFor:"first_name",children:["First name",((w=m==null?void 0:m.first_name)==null?void 0:w.required)&&e.jsx(Dn,{children:"*"})]}),e.jsx(J,{type:"text",id:"first_name",name:"first_name",required:(b=m==null?void 0:m.first_name)==null?void 0:b.required,minLength:2,maxLength:50,value:n.first_name,onChange:x,placeholder:"First name","aria-invalid":!!u()}),u()&&e.jsx(fo,{children:u()})]}),((g=m==null?void 0:m.last_name)==null?void 0:g.enabled)&&e.jsxs(An,{children:[e.jsxs(Ln,{htmlFor:"last_name",children:["Last name",((C=m==null?void 0:m.last_name)==null?void 0:C.required)&&e.jsx(Dn,{children:"*"})]}),e.jsx(J,{type:"text",id:"last_name",name:"last_name",required:(E=m==null?void 0:m.last_name)==null?void 0:E.required,minLength:2,maxLength:50,value:n.last_name,onChange:x,placeholder:"Last name","aria-invalid":!!u()}),u()&&e.jsx(fo,{children:u()})]})]}),e.jsxs(An,{children:[e.jsxs(Ln,{htmlFor:"email",children:["Email address",((j=m==null?void 0:m.email_address)==null?void 0:j.required)&&e.jsx(Dn,{children:"*"})]}),e.jsx(J,{type:"email",id:"email",name:"email",required:(T=m==null?void 0:m.email_address)==null?void 0:T.required,value:n.email,onChange:x,placeholder:"Enter your email address","aria-invalid":!!u()}),u()&&e.jsx(fo,{children:u()})]}),u()&&e.jsx(fo,{children:u()}),e.jsx(tm,{type:"submit",$primary:!0,disabled:f||r,children:f||r?"Joining waitlist...":"Join waitlist"})]}),e.jsx(sm,{children:e.jsxs(im,{children:["Need assistance? ",e.jsx(cm,{href:"/contact",children:"Get help"})]})})]})})}const Fr=h.div`
|
|
1881
1881
|
max-width: 380px;
|
|
1882
1882
|
width: 380px;
|
|
1883
1883
|
padding: var(--space-3xl);
|
|
@@ -1964,7 +1964,7 @@ cursor: pointer;
|
|
|
1964
1964
|
color: var(--color-primary-hover);
|
|
1965
1965
|
text-decoration: underline;
|
|
1966
1966
|
}
|
|
1967
|
-
`;function fm(){const{deployment:t}=xe(),{navigate:r}=Je(),{error:o,session:n,processed:a,signinAttempt:s,redirectUri:p,loading:f}=Pc(),[c,d]=i.useState(!1),[l,u]=i.useState(null),m=()=>{window.location.reload()},v=()=>{var
|
|
1967
|
+
`;function fm(){const{deployment:t}=xe(),{navigate:r}=Je(),{error:o,session:n,processed:a,signinAttempt:s,redirectUri:p,loading:f}=Pc(),[c,d]=i.useState(!1),[l,u]=i.useState(null),m=()=>{window.location.reload()},v=()=>{var z;const k=((z=t==null?void 0:t.ui_settings)==null?void 0:z.sign_in_page_url)||"/sign-in";r(k)},x=()=>{d(!1),l&&r(l)},y=()=>{d(!1),l&&r(l)};if(i.useEffect(()=>{var k,z,S,_,$;if(!(!a||f||c)){if(s&&!s.completed){const w=(k=t==null?void 0:t.ui_settings)==null?void 0:k.sign_in_page_url;if(w){const b=new URL(w,window.location.origin);b.searchParams.set("signin_attempt_id",s.id),p&&b.searchParams.set("redirect_uri",p),r(b.toString())}return}if(s!=null&&s.completed){const w=p||((z=t==null?void 0:t.ui_settings)==null?void 0:z.after_signin_redirect_url)||(t==null?void 0:t.frontend_host)||"/";let b;try{b=new URL(w)}catch{b=new URL(w,window.location.origin)}if(b){(t==null?void 0:t.mode)==="staging"&&b.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||"");const g=(S=t==null?void 0:t.auth_settings)==null?void 0:S.passkey;(g==null?void 0:g.enabled)&&(g==null?void 0:g.prompt_registration_on_auth)&&!(($=(_=n==null?void 0:n.active_signin)==null?void 0:_.user)!=null&&$.has_passkeys)?(u(b.toString()),d(!0)):r(b.toString())}}}},[n,a,f,p,t,s,r]),i.useEffect(()=>{o&&o.message.includes("No OAuth callback data found")&&setTimeout(()=>{var z;const k=((z=t==null?void 0:t.ui_settings)==null?void 0:z.sign_in_page_url)||(t==null?void 0:t.frontend_host);k&&r(k)},2e3)},[o,t,r]),f&&!a)return e.jsx(ue,{children:e.jsxs(Fr,{children:[e.jsxs(go,{children:[e.jsx(mo,{children:"Completing sign in"}),e.jsx(xo,{children:"Please wait while we authenticate you"})]}),e.jsxs(vo,{children:[e.jsx(Zs,{}),e.jsx(yo,{children:"Verifying your credentials..."}),e.jsx(bo,{children:"This will only take a moment."})]})]})});if(c)return e.jsx(ue,{children:e.jsxs(Fr,{children:[e.jsx(Ie,{}),e.jsx(Ml,{onComplete:x,onSkip:y})]})});if(n&&a&&!o)return e.jsx(ue,{children:e.jsxs(Fr,{children:[e.jsxs(go,{children:[e.jsx(mo,{children:"Success!"}),e.jsx(xo,{children:"Authentication completed successfully"})]}),e.jsxs(vo,{children:[e.jsx(um,{children:"✓"}),e.jsx(yo,{children:"Redirecting you now..."}),e.jsx(bo,{children:"You'll be redirected to your destination shortly."})]})]})});if(o){const k=o.message.includes("No OAuth callback data found");return e.jsx(ue,{children:e.jsxs(Fr,{children:[e.jsxs(go,{children:[e.jsx(mo,{children:"Something went wrong"}),e.jsx(xo,{children:"We couldn't complete your sign in"})]}),e.jsxs(vo,{children:[e.jsx(dm,{children:"✗"}),e.jsx(yo,{children:"Authentication Failed"}),e.jsx(bo,{children:o.message||"An unexpected error occurred during authentication."}),!k&&e.jsx(V,{onClick:m,style:{marginTop:"var(--space-lg)"},children:"Try Again"})]}),!k&&e.jsx(pm,{children:e.jsxs("div",{children:["Having trouble?"," ",e.jsx(hm,{onClick:v,children:"Return to sign in"})]})})]})})}return e.jsx(ue,{children:e.jsxs(Fr,{children:[e.jsxs(go,{children:[e.jsx(mo,{children:"Completing sign in"}),e.jsx(xo,{children:"Please wait while we authenticate you"})]}),e.jsxs(vo,{children:[e.jsx(Zs,{}),e.jsx(yo,{children:"Verifying your credentials..."}),e.jsx(bo,{children:"This will only take a moment."})]})]})})}const gm=h.div`
|
|
1968
1968
|
max-width: 380px;
|
|
1969
1969
|
width: 380px;
|
|
1970
1970
|
padding: var(--space-3xl);
|
|
@@ -2029,7 +2029,7 @@ cursor: pointer;
|
|
|
2029
2029
|
`,Fn=h.p`
|
|
2030
2030
|
font-size: var(--font-xs);
|
|
2031
2031
|
color: var(--color-secondary-text);
|
|
2032
|
-
`;function _m({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[a,s]=i.useState(""),{token:p,attempt:f,redirectUri:c}=Ic(),{verifyMagicLink:d}=Rc(),{navigate:l}=Je(),{deployment:u}=xe(),m=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!m.current){if(!p||!f){n("error"),s("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}m.current=!0,n("loading"),s("Please wait while we verify your magic link.");try{await d({token:p,attempt:f,redirectUri:c}),n("success"),s("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var
|
|
2032
|
+
`;function _m({onSuccess:t,onError:r}={}){const[o,n]=i.useState("loading"),[a,s]=i.useState(""),{token:p,attempt:f,redirectUri:c}=Ic(),{verifyMagicLink:d}=Rc(),{navigate:l}=Je(),{deployment:u}=xe(),m=i.useRef(!1);i.useEffect(()=>{(async()=>{if(!m.current){if(!p||!f){n("error"),s("The magic link appears to be malformed. Please try signing in again."),r==null||r("Invalid magic link parameters");return}m.current=!0,n("loading"),s("Please wait while we verify your magic link.");try{await d({token:p,attempt:f,redirectUri:c}),n("success"),s("You will be redirected to your account shortly."),t==null||t(),setTimeout(()=>{var k;let y=c;if(y||(y=(k=u==null?void 0:u.ui_settings)==null?void 0:k.after_signin_redirect_url),!y&&(u!=null&&u.frontend_host)&&(y=`https://${u.frontend_host}`),y){const z=new URL(y);(u==null?void 0:u.mode)==="staging"&&z.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")||""),l(z.toString())}},2e3)}catch(y){n("error"),s("The magic link may have expired or already been used. Please try signing in again."),r==null||r(y.message)}}})()},[p,f]);const v=()=>{var x;(x=u==null?void 0:u.ui_settings)!=null&&x.sign_in_page_url&&l(u.ui_settings.sign_in_page_url)};return e.jsx(ue,{children:e.jsxs(gm,{children:[e.jsxs(mm,{children:[e.jsx(xm,{children:"Magic Link Verification"}),e.jsx(vm,{children:"Verifying your magic link"})]}),e.jsxs(ym,{children:[o==="loading"&&e.jsxs(e.Fragment,{children:[e.jsx(jm,{}),e.jsx(Fn,{children:a})]}),o==="success"&&e.jsxs(e.Fragment,{children:[e.jsx(bm,{children:"✓"}),e.jsx(Fn,{children:a})]}),o==="error"&&e.jsxs(e.Fragment,{children:[e.jsx(wm,{children:"✗"}),e.jsx(Fn,{children:a}),e.jsx(V,{onClick:v,style:{marginTop:"var(--space-xl)"},children:"Try Again"})]})]})]})})}function km(t){var n,a;return t?((n=t.signin_attempts)==null?void 0:n.find(s=>s.requires_completion&&!s.completed))?!0:!!((a=t.signup_attempts)==null?void 0:a.find(s=>{var p,f;return((p=s.missing_fields)==null?void 0:p.length)>0||((f=s.remaining_steps)==null?void 0:f.length)>0&&!s.completed})):!1}function Cm(t){const r=t?`/profile-completion?redirect_uri=${encodeURIComponent(t)}`:"/profile-completion";window.location.href=r}const Yt=h.div`
|
|
2033
2033
|
max-width: 380px;
|
|
2034
2034
|
width: 380px;
|
|
2035
2035
|
padding: var(--space-3xl);
|
|
@@ -2129,7 +2129,7 @@ cursor: pointer;
|
|
|
2129
2129
|
&:hover {
|
|
2130
2130
|
color: var(--color-primary-hover);
|
|
2131
2131
|
}
|
|
2132
|
-
`;function Pm({token:t,onSuccess:r,onError:o}){var y;const{acceptInvitation:n,invitationData:a,loading:s,error:p}=Ac(),{navigate:f}=Je(),{deployment:c}=xe(),d=i.useRef(!1),l=()=>{var
|
|
2132
|
+
`;function Pm({token:t,onSuccess:r,onError:o}){var y;const{acceptInvitation:n,invitationData:a,loading:s,error:p}=Ac(),{navigate:f}=Je(),{deployment:c}=xe(),d=i.useRef(!1),l=()=>{var z;const k=new URLSearchParams(window.location.search);return{token:t||k.get("invite_token")||k.get("token"),redirectUri:k.get("redirect_uri")||((z=c==null?void 0:c.ui_settings)==null?void 0:z.after_signin_redirect_url)||"/"}};i.useEffect(()=>{if(d.current)return;const{token:k}=l();k&&(d.current=!0,n(k))},[n]),i.useEffect(()=>{var k;a&&(a.organization&&!a.requires_signin&&r&&r(a.organization.id,(k=a.workspace)==null?void 0:k.id),a.error_code&&o&&o(a.message||"Failed to accept invitation"))},[a,r,o]);const u=()=>{const{redirectUri:k}=l();f(k)},m=()=>{var g,C;const{token:k}=l(),z=((g=c==null?void 0:c.ui_settings)==null?void 0:g.sign_in_page_url)||"/sign-in",S=((C=c==null?void 0:c.ui_settings)==null?void 0:C.sign_up_page_url)||"/sign-up",_=new URLSearchParams;k&&_.set("invite_token",k),a!=null&&a.invited_email&&_.set("invited_email",a.invited_email);const w=`${window.location.pathname}?token=${k}`;_.set("redirect_uri",w),a!=null&&a.message&&_.set("message",a.message);const b=(a==null?void 0:a.error_code)==="INVITATION_REQUIRES_SIGNUP";f(`${b?S:z}?${_.toString()}`)},v=()=>{const{token:k}=l();k&&(d.current=!1,n(k))},{token:x}=l();if(!x&&!s)return e.jsx(ue,{children:e.jsxs(Yt,{children:[e.jsxs(Zt,{children:[e.jsx(Kt,{children:"Invalid Invitation"}),e.jsx(Qt,{children:"No invitation token found"})]}),e.jsxs(Jt,{children:[e.jsx(Nn,{children:"✗"}),e.jsx(Xt,{children:"Missing Invitation Token"}),e.jsx(er,{children:"The invitation link appears to be invalid or incomplete."}),e.jsx(V,{onClick:()=>f("/"),style:{marginTop:"var(--space-lg)"},children:"Go to Home"})]})]})});if(s)return e.jsx(ue,{children:e.jsxs(Yt,{children:[e.jsxs(Zt,{children:[e.jsx(Kt,{children:"Processing Invitation"}),e.jsx(Qt,{children:"Please wait while we verify your invitation"})]}),e.jsxs(Jt,{children:[e.jsx(zm,{}),e.jsx(Xt,{children:"Verifying invitation..."}),e.jsx(er,{children:"This will only take a moment."})]})]})});if(a!=null&&a.organization&&!a.requires_signin)return e.jsx(ue,{children:e.jsxs(Yt,{children:[e.jsxs(Zt,{children:[e.jsx(Kt,{children:"Invitation Accepted!"}),e.jsx(Qt,{children:"You've successfully joined the organization"})]}),e.jsxs(Jt,{children:[e.jsx(Sm,{children:"✓"}),e.jsxs(Xt,{children:["Welcome to ",a.organization.name,"!"]}),a.workspace&&e.jsxs(er,{children:["You've been added to the ",a.workspace.name," workspace."]}),e.jsx(V,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(a!=null&&a.already_member)return e.jsx(ue,{children:e.jsxs(Yt,{children:[e.jsxs(Zt,{children:[e.jsx(Kt,{children:"Already a Member"}),e.jsx(Qt,{children:"You're already part of this organization"})]}),e.jsxs(Jt,{children:[e.jsx(Ks,{children:"ℹ"}),e.jsxs(Xt,{children:["You're already a member of ",((y=a.organization)==null?void 0:y.name)||"this organization"]}),e.jsx(er,{children:"No action needed - you already have access."}),e.jsx(V,{onClick:u,style:{marginTop:"var(--space-lg)"},children:"Continue to Application"})]})]})});if(a!=null&&a.requires_signin){const k=a.error_code==="INVITATION_REQUIRES_SIGNUP";return e.jsx(ue,{children:e.jsxs(Yt,{children:[e.jsxs(Zt,{children:[e.jsx(Kt,{children:k?"Sign Up Required":"Sign In Required"}),e.jsx(Qt,{children:"To accept this invitation"})]}),e.jsxs(Jt,{children:[e.jsx(Ks,{children:"ℹ"}),e.jsxs(Xt,{children:["This invitation is for ",e.jsx(Qs,{children:a.invited_email})]}),e.jsx(er,{children:k?"You need to create an account with this email address to accept the invitation.":a.error_code==="INVITATION_EMAIL_MISMATCH"?"You're currently signed in with a different account. Please sign in with the invited email.":"Please sign in to accept this invitation."}),e.jsx(V,{onClick:m,style:{marginTop:"var(--space-lg)"},children:k?"Sign Up to Accept":"Sign In to Accept"})]})]})})}return(a==null?void 0:a.error_code)==="INVITATION_EXPIRED"?e.jsx(ue,{children:e.jsxs(Yt,{children:[e.jsxs(Zt,{children:[e.jsx(Kt,{children:"Invitation Expired"}),e.jsx(Qt,{children:"This invitation is no longer valid"})]}),e.jsxs(Jt,{children:[e.jsx(Nn,{children:"⏱"}),e.jsxs(Xt,{children:["Invitation for ",e.jsx(Qs,{children:a.invited_email})," has expired"]}),e.jsx(er,{children:"Invitations are valid for 10 days. Please request a new invitation from your organization administrator."})]})]})}):p||a!=null&&a.error_code?e.jsx(ue,{children:e.jsxs(Yt,{children:[e.jsxs(Zt,{children:[e.jsx(Kt,{children:"Invitation Error"}),e.jsx(Qt,{children:"Unable to process invitation"})]}),e.jsxs(Jt,{children:[e.jsx(Nn,{children:"✗"}),e.jsx(Xt,{children:"Something went wrong"}),e.jsx(er,{children:(a==null?void 0:a.message)||p||"Failed to accept invitation"}),e.jsx(V,{onClick:v,style:{marginTop:"var(--space-lg)"},children:"Try Again"}),e.jsx(Em,{children:e.jsxs("div",{style:{marginTop:"var(--space-md)"},children:["Having trouble?"," ",e.jsx($m,{onClick:m,children:"Sign in manually"})]})})]})]})}):null}const Oa=i.createContext({screen:null,setScreen:()=>{},toast:(t,r)=>{}}),Ze=()=>{const t=i.useContext(Oa);if(!t)throw new Error("useScreenContext must be used within a ScreenContextProvider");return t},Rm=h.div`
|
|
2133
2133
|
display: flex;
|
|
2134
2134
|
height: 100%;
|
|
2135
2135
|
min-height: 400px;
|
|
@@ -2318,7 +2318,7 @@ cursor: pointer;
|
|
|
2318
2318
|
color: white;
|
|
2319
2319
|
font-size: 12px;
|
|
2320
2320
|
font-weight: 400;
|
|
2321
|
-
`,ln=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[a,s]=i.useState(""),[p,f]=i.useState(),[c,d]=i.useState(null),[l,u]=i.useState(!1),m=i.useRef(null),{createOrganization:v}=Qo(),{toast:x}=Ze(),y=b=>{n(b)},
|
|
2321
|
+
`,ln=({onSuccess:t,onCancel:r})=>{const[o,n]=i.useState(""),[a,s]=i.useState(""),[p,f]=i.useState(),[c,d]=i.useState(null),[l,u]=i.useState(!1),m=i.useRef(null),{createOrganization:v}=Qo(),{toast:x}=Ze(),y=b=>{n(b)},k=b=>{if(b.target.files&&b.target.files[0]){const g=b.target.files[0];if(g.size>2*1024*1024){x("File size cannot exceed 2MB","error");return}if(!g.type.startsWith("image/")){x("Please select a valid image file","error");return}c&&URL.revokeObjectURL(c),f(g),d(URL.createObjectURL(g))}},z=()=>{var b;(b=m.current)==null||b.click()},S=b=>b.split(" ").map(g=>g[0]).join("").toUpperCase().slice(0,2)||"O";i.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]);const _=b=>b.trim().replace(/[<>\"'&]/g,""),$=b=>b.length>=2&&b.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(b),w=async()=>{const b=_(o),g=_(a);if(!b){x("Please enter an organization name","error");return}if(!$(b)){x("Organization name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(g.length>500){x("Description must be less than 500 characters","error");return}u(!0);try{const C=await v({name:b,description:g,image:p});t==null||t(C)}catch(C){const E=C.message||"Failed to create organization. Please try again.";x(E,"error")}finally{u(!1)}};return e.jsx(ue,{children:e.jsxs(Rm,{children:[e.jsxs(Im,{children:[e.jsxs(Ll,{hasImage:!!c,onClick:z,children:[c?e.jsx(Om,{src:c,alt:"Organization logo"}):e.jsx(Mm,{children:S(o||"O")}),e.jsx(Ym,{children:e.jsx(Zm,{children:"Upload Logo"})})]}),e.jsx(qm,{type:"file",ref:m,onChange:k,accept:"image/png, image/jpeg, image/gif",disabled:l}),e.jsx(Am,{children:"Create new organization"}),e.jsx(Lm,{children:"Organizations help you manage all your team members for an org in one umbrella."})]}),e.jsxs(Tm,{children:[e.jsxs(Dm,{children:[e.jsx(Fm,{children:"Choose your organization name"}),e.jsx(Nm,{children:"This is the name of your company or team. You can always change it later."})]}),e.jsxs(Bm,{children:[e.jsxs(Js,{children:[e.jsx(Xs,{children:"Organization name"}),e.jsx(Um,{type:"text",value:o,onChange:b=>y(b.target.value),placeholder:"Acme Inc.",disabled:l})]}),e.jsxs(Js,{children:[e.jsx(Xs,{children:"Description (optional)"}),e.jsx(Wm,{value:a,onChange:b=>s(b.target.value),placeholder:"What does your organization do?",disabled:l})]})]}),e.jsxs(Vm,{children:[r?e.jsxs(Gm,{onClick:r,disabled:l,children:[e.jsx(Ea,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Hm,{onClick:w,disabled:l||!o.trim(),children:l?"Creating...":"Create"})]})]})]})})},Km=({isOpen:t,onClose:r,onCreated:o})=>{const n=()=>{o==null||o(),r==null||r()};return e.jsx(ue,{children:e.jsx(_e,{isOpen:t,onClose:r,children:e.jsx(_e.Overlay,{children:e.jsx(_e.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(_e.Body,{style:{padding:0},children:e.jsx(ln,{onSuccess:n,onCancel:r})})})})})})},Qm=h.div`
|
|
2322
2322
|
position: fixed;
|
|
2323
2323
|
width: 360px;
|
|
2324
2324
|
max-width: calc(100vw - 48px);
|
|
@@ -2367,7 +2367,7 @@ cursor: pointer;
|
|
|
2367
2367
|
color: var(--color-foreground);
|
|
2368
2368
|
background: var(--color-input-background);
|
|
2369
2369
|
}
|
|
2370
|
-
`,ai=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(),[p,f]=i.useState(""),[c,d]=i.useState(!1),[l,u]=i.useState(!1),[m,v]=i.useState({top:0,left:0}),{addDomain:x,verifyDomain:y}=tt(),{toast:
|
|
2370
|
+
`,ai=({onClose:t,domain:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(),[p,f]=i.useState(""),[c,d]=i.useState(!1),[l,u]=i.useState(!1),[m,v]=i.useState({top:0,left:0}),{addDomain:x,verifyDomain:y}=tt(),{toast:k}=Ze(),z=w=>/^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\.[a-zA-Z]{2,}$/.test(w),S=w=>w.trim().toLowerCase().replace(/^https?:\/\//,""),_=async()=>{const w=S(p);if(!w){k("Please enter a domain name","error");return}if(!z(w)){k("Please enter a valid domain name (e.g., example.com)","error");return}if(w.length>253){k("Domain name is too long","error");return}try{const b=await x({fqdn:w});k("Domain added successfully","info"),s(b.data)}catch(b){const g=b.message||"Failed to add domain. Please try again.";k(g,"error")}},$=async()=>{if(!(!a||c)){d(!0);try{await y(a),t==null||t(),k("Domain verified successfully","info")}catch(w){const b=w.message||"Failed to verify domain. Please check DNS records and try again.";k(b,"error")}finally{d(!1)}}};return i.useEffect(()=>{u(!0);const w=setTimeout(()=>{if(!n.current)return;const C=o==null?void 0:o.current,E=360,j=250,T=8;let I=0,O=0;if(!C){const D=n.current.getBoundingClientRect(),L=D.width||E,R=D.height||j;I=Math.max(T,(window.innerHeight-R)/2),O=Math.max(T,(window.innerWidth-L)/2),v({top:I,left:O});return}const P=C.getBoundingClientRect(),M=window.innerHeight-P.bottom,F=P.top;M>=j+T?(I=P.bottom+T,O=P.right-E,O<T&&(O=P.left,O+E>window.innerWidth-T&&(O=(window.innerWidth-E)/2))):F>=j+T?(I=P.top-j-T,O=P.right-E,O<T&&(O=P.left,O+E>window.innerWidth-T&&(O=(window.innerWidth-E)/2))):(I=P.bottom+T,O=P.right-E,O<T&&(O=P.left)),v({top:I,left:O})},10),b=C=>{n.current&&!n.current.contains(C.target)&&(t==null||t())},g=C=>{C.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",b),document.addEventListener("keydown",g),()=>{clearTimeout(w),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",g)}},[t,o]),i.useEffect(()=>{r&&s(r)},[r]),l?e.jsx(Qm,{ref:n,style:{top:`${m.top}px`,left:`${m.left}px`,visibility:m.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),role:"dialog","aria-labelledby":"add-domain-title","aria-modal":"true",children:a?e.jsxs(e.Fragment,{children:[e.jsxs(ei,{children:[e.jsx(ti,{id:"verify-domain-title",children:"Verify Domain"}),e.jsx(ni,{onClick:t,"aria-label":"Close domain verification dialog",children:e.jsx(Et,{size:16})})]}),e.jsxs(ri,{children:[e.jsx("div",{style:{marginBottom:"var(--space-md)"},children:e.jsx("p",{style:{fontSize:"var(--font-xs)",color:"var(--color-muted)",margin:0,textAlign:"left"},children:"Add the following DNS record to your domain"})}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"Record Type"}),e.jsx(J,{value:a==null?void 0:a.verification_dns_record_type,disabled:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Record Name"}),e.jsx(J,{value:a==null?void 0:a.verification_dns_record_name,disabled:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Record Data"}),e.jsx(J,{type:"text",value:a==null?void 0:a.verification_dns_record_data,disabled:!0})]})]})]}),e.jsxs(oi,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(V,{onClick:$,disabled:c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx($e,{size:14})," Verifying..."]}):"Verify Domain"})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ei,{children:[e.jsx(ti,{id:"add-domain-title",children:"Add Domain"}),e.jsx(ni,{onClick:t,"aria-label":"Close add domain dialog",children:e.jsx(Et,{size:16})})]}),e.jsx(ri,{children:e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:e.jsxs(ie,{children:[e.jsx(oe,{children:"Enter FQDN"}),e.jsx(J,{type:"text",placeholder:"Enter your domain",value:p,onChange:w=>f(w.target.value),autoFocus:!0,"aria-label":"Domain name (FQDN)","aria-describedby":"domain-help"})]})})}),e.jsxs(oi,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(V,{onClick:_,disabled:!p||c,style:{width:"auto"},children:c?e.jsxs(e.Fragment,{children:[e.jsx($e,{size:14})," Adding..."]}):"Continue"})]})]})}):null},Jm=h.div`
|
|
2371
2371
|
position: fixed;
|
|
2372
2372
|
width: 360px;
|
|
2373
2373
|
max-width: calc(100vw - 48px);
|
|
@@ -2416,7 +2416,7 @@ cursor: pointer;
|
|
|
2416
2416
|
color: var(--color-foreground);
|
|
2417
2417
|
background: var(--color-input-background);
|
|
2418
2418
|
}
|
|
2419
|
-
`,Dl=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const a=i.useRef(null),[s,p]=i.useState(""),[f,c]=i.useState(null),[d,l]=i.useState(!1),[u,m]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{inviteMember:y}=tt(),{toast:
|
|
2419
|
+
`,Dl=({onClose:t,onSuccess:r,roles:o,triggerRef:n})=>{const a=i.useRef(null),[s,p]=i.useState(""),[f,c]=i.useState(null),[d,l]=i.useState(!1),[u,m]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{inviteMember:y}=tt(),{toast:k}=Ze(),z=o.map($=>({value:$.id,label:$.name})),S=$=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test($),_=async()=>{const $=s.trim().toLowerCase();if(!(!$||!f)){if(!S($)){k("Please enter a valid email address","error");return}if($.length>320){k("Email address is too long","error");return}l(!0);try{await y({email:$,organizationRole:f}),r==null||r()}catch(w){const b=w.message||"Failed to send invitation. Please try again.";k(b,"error")}finally{l(!1)}}};return i.useEffect(()=>{m(!0);const $=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const g=n.current;if(g){const C=g.getBoundingClientRect(),E=360,j=250,T=8;let I=0,O=0;const P=window.innerHeight-C.bottom,M=C.top;P>=j+T?(I=C.bottom+T,O=C.right-E,O<T&&(O=C.left,O+E>window.innerWidth-T&&(O=(window.innerWidth-E)/2))):M>=j+T?(I=C.top-j-T,O=C.right-E,O<T&&(O=C.left,O+E>window.innerWidth-T&&(O=(window.innerWidth-E)/2))):(I=C.bottom+T,O=C.right-E,O<T&&(O=C.left)),x({top:I,left:O})}},10),w=g=>{a.current&&!a.current.contains(g.target)&&(t==null||t())},b=g=>{g.key==="Escape"&&(t==null||t())};return document.addEventListener("mousedown",w),document.addEventListener("keydown",b),()=>{clearTimeout($),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",b)}},[t,n]),u?e.jsxs(Jm,{ref:a,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:$=>$.stopPropagation(),role:"dialog","aria-labelledby":"invite-member-title","aria-modal":"true",children:[e.jsxs(Xm,{children:[e.jsx(ex,{id:"invite-member-title",children:"Invite Member"}),e.jsx(ox,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Et,{size:16})})]}),e.jsx(tx,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"Email Address"}),e.jsx(J,{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(ie,{children:[e.jsx(oe,{children:"Role"}),e.jsx(Ta,{options:z,value:f==null?void 0:f.id,onChange:$=>c(o.find(w=>w.id===$)),placeholder:"Select a role","aria-label":"Select role for invited member"})]})]})}),e.jsxs(rx,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(V,{onClick:_,disabled:!s||!f||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx($e,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},nx=h.div`
|
|
2420
2420
|
position: fixed;
|
|
2421
2421
|
width: 400px;
|
|
2422
2422
|
max-width: calc(100vw - 48px);
|
|
@@ -2467,7 +2467,7 @@ cursor: pointer;
|
|
|
2467
2467
|
color: var(--color-foreground);
|
|
2468
2468
|
background: var(--color-input-background);
|
|
2469
2469
|
}
|
|
2470
|
-
`,si=({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)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]);tt();const[d,l]=i.useState(!1),[u,m]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{deployment:y}=xe(),{toast:
|
|
2470
|
+
`,si=({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)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]);tt();const[d,l]=i.useState(!1),[u,m]=i.useState(!1),[v,x]=i.useState({top:0,left:0}),{deployment:y}=xe(),{toast:k}=Ze(),z=!!o,S=Array.isArray((b=y==null?void 0:y.b2b_settings)==null?void 0:b.organization_permissions)?y.b2b_settings.organization_permissions.map(g=>({value:g,label:g})):[];i.useEffect(()=>{m(!0);const g=setTimeout(()=>{if(!a.current)return;let T=null;if(n!=null&&n.current)T=n.current;else if(z){const I=document.querySelectorAll("[data-role-dropdown-trigger]");for(let O=0;O<I.length;O++){const P=I[O];if(P.offsetParent!==null){T=P;break}}}else{const I=document.querySelectorAll("button");for(let O=0;O<I.length;O++){const P=I[O];if(P.textContent==="Add role"&&P.offsetParent!==null){T=P;break}}}if(T){const I=T.getBoundingClientRect(),O=400;let P=I.bottom+8,M=I.right-O;M<10&&(M=I.left),P+300>window.innerHeight&&(P=I.top-300-8),x({top:P,left:M})}},10),C=T=>{a.current&&!a.current.contains(T.target)&&(t==null||t())},E=T=>{T.key==="Escape"&&(t==null||t())},j=setTimeout(()=>{document.addEventListener("mousedown",C),document.addEventListener("keydown",E)},100);return()=>{clearTimeout(g),clearTimeout(j),document.removeEventListener("mousedown",C),document.removeEventListener("keydown",E)}},[t,z,n]);const _=g=>g.trim().replace(/[<>\"'&]/g,""),$=g=>g.length>=2&&g.length<=50&&/^[a-zA-Z0-9\s_-]+$/.test(g),w=async()=>{const g=_(s);if(!g){k("Please enter a role name","error");return}if(!$(g)){k("Role name must be 2-50 characters and contain only letters, numbers, spaces, underscores, and hyphens","error");return}if(f.length===0){k("Please select at least one permission","error");return}l(!0);try{const C={id:o==null?void 0:o.id,name:g,permissions:f||[]};r==null||r(C)}catch(C){const E=C.message||`Failed to ${z?"update":"create"} role. Please try again.`;k(E,"error")}finally{l(!1)}};return u?e.jsxs(nx,{ref:a,$isInTable:z,style:{top:`${v.top}px`,left:`${v.left}px`,visibility:v.top>0?"visible":"hidden"},onClick:g=>g.stopPropagation(),role:"dialog","aria-labelledby":"role-dialog-title","aria-modal":"true",children:[e.jsxs(ax,{children:[e.jsx(sx,{id:"role-dialog-title",children:z?"Edit Role":"Create New Role"}),e.jsx(lx,{onClick:t,"aria-label":`Close ${z?"edit":"create"} role dialog`,children:e.jsx(Et,{size:16})})]}),e.jsx(ix,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"Role Name"}),e.jsx(J,{type:"text",placeholder:"e.g. Admin, Editor, Viewer",value:s,onChange:g=>p(g.target.value),autoFocus:!0,"aria-label":"Role name","aria-describedby":"role-name-help"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Permissions"}),e.jsx(zl,{options:S,value:f,onChange:c,placeholder:"Select permissions","aria-label":"Select permissions for role"})]})]})}),e.jsxs(cx,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(V,{onClick:w,disabled:!s||d,style:{width:"auto"},children:d?e.jsxs(e.Fragment,{children:[e.jsx($e,{size:14})," ",z?"Updating...":"Creating..."]}):z?"Update Role":"Create Role"})]})]}):null},mt=h.table`
|
|
2471
2471
|
width: 100%;
|
|
2472
2472
|
border-collapse: separate;
|
|
2473
2473
|
border-spacing: 0;
|
|
@@ -2693,7 +2693,7 @@ cursor: pointer;
|
|
|
2693
2693
|
outline: none;
|
|
2694
2694
|
border-color: var(--color-primary);
|
|
2695
2695
|
}
|
|
2696
|
-
`,jx=()=>{const{activeOrganization:t,loading:r,getEnterpriseConnections:o,createEnterpriseConnection:n,deleteEnterpriseConnection:a,testEnterpriseConnection:s,generateSCIMToken:p,getSCIMToken:f,revokeSCIMToken:c}=tt(),{toast:d}=Ze(),[l,u]=i.useState(!1),[m,v]=i.useState(null),{data:x=[],isLoading:y,mutate:
|
|
2696
|
+
`,jx=()=>{const{activeOrganization:t,loading:r,getEnterpriseConnections:o,createEnterpriseConnection:n,deleteEnterpriseConnection:a,testEnterpriseConnection:s,generateSCIMToken:p,getSCIMToken:f,revokeSCIMToken:c}=tt(),{toast:d}=Ze(),[l,u]=i.useState(!1),[m,v]=i.useState(null),{data:x=[],isLoading:y,mutate:k}=Ue(t!=null&&t.id?`wacht-org-sso:${t.id}`:null,async()=>await(o==null?void 0:o())||[],{refreshInterval:3e4,revalidateOnFocus:!1}),z=async S=>{try{await(a==null?void 0:a(S)),k(),d("SSO connection deleted","info")}catch(_){d(_.message||"Failed to delete connection","error")}v(null)};return r||y?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):l?e.jsx(zx,{onClose:()=>u(!1),onCreate:async S=>{try{await(n==null?void 0:n(S)),k(),u(!1),d("SSO connection created","info")}catch(_){d(_.message||"Failed to create connection","error")}}}):e.jsx(e.Fragment,{children:x.length===0?e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"80px 24px",textAlign:"center"},children:[e.jsx(at,{size:56,strokeWidth:1,style:{color:"var(--color-primary)",marginBottom:"20px",opacity:.7}}),e.jsx("h3",{style:{margin:"0 0 8px 0",fontSize:"18px",fontWeight:500,color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"0 0 24px 0",fontSize:"14px",color:"var(--color-muted)",maxWidth:"360px",lineHeight:"1.6"},children:"Set up SAML or OIDC single sign-on to allow members to sign in with your identity provider."}),e.jsxs(V,{onClick:()=>u(!0),style:{width:"auto"},children:[e.jsx(rt,{size:16})," Configure SSO"]})]}):e.jsxs(e.Fragment,{children:[e.jsx(mx,{children:e.jsxs("div",{style:{flex:1},children:[e.jsx("h3",{style:{margin:0,fontSize:"16px",color:"var(--color-foreground)"},children:"Enterprise SSO"}),e.jsx("p",{style:{margin:"4px 0 0",fontSize:"13px",color:"var(--color-muted)"},children:"Configure SAML or OIDC SSO for your organization"})]})}),x.map(S=>e.jsx(Sx,{connection:S,onDelete:_=>v(_),connectionToDelete:m,onConfirmDelete:z,onCancelDelete:()=>v(null),testConnection:s||null,generateSCIMToken:p,getSCIMToken:f,revokeSCIMToken:c,toast:d},S.id))]})})},_x=h.div`
|
|
2697
2697
|
margin-top: 16px;
|
|
2698
2698
|
padding-top: 16px;
|
|
2699
2699
|
border-top: 1px solid var(--color-border);
|
|
@@ -2709,14 +2709,14 @@ cursor: pointer;
|
|
|
2709
2709
|
display: flex;
|
|
2710
2710
|
gap: 8px;
|
|
2711
2711
|
flex-wrap: wrap;
|
|
2712
|
-
`,Sx=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:a,testConnection:s,generateSCIMToken:p,getSCIMToken:f,revokeSCIMToken:c,toast:d})=>{var j,T,I,O,P;const[l,u]=i.useState(null),[m,v]=i.useState(!1),[x,y]=i.useState(null),[
|
|
2712
|
+
`,Sx=({connection:t,onDelete:r,connectionToDelete:o,onConfirmDelete:n,onCancelDelete:a,testConnection:s,generateSCIMToken:p,getSCIMToken:f,revokeSCIMToken:c,toast:d})=>{var j,T,I,O,P;const[l,u]=i.useState(null),[m,v]=i.useState(!1),[x,y]=i.useState(null),[k,z]=i.useState(null),[S,_]=i.useState(!1),[$,w]=i.useState(null);i.useEffect(()=>{f&&t.id&&f(t.id).then(u).catch(()=>{})},[t.id,f]);const b=async()=>{if(s){_(!0),w(null);try{const M=await s(t.id);w(M)}catch(M){w({success:!1,checks:{},errors:{general:M.message||"Test failed"}})}finally{_(!1)}}},g=async()=>{if(p){v(!0);try{const M=await p(t.id);y(M.token),u({exists:!0,token:M}),d("SCIM token generated. Copy it now - it won't be shown again!","info")}catch(M){d(M.message||"Failed to generate token","error")}finally{v(!1)}}},C=async()=>{if(c){v(!0);try{await c(t.id),u({exists:!1,scim_base_url:l==null?void 0:l.scim_base_url}),y(null),d("SCIM token revoked","info")}catch(M){d(M.message||"Failed to revoke token","error")}finally{v(!1)}}},E=(M,F)=>{navigator.clipboard.writeText(M),z(F),setTimeout(()=>z(null),2e3)};return e.jsxs(xx,{children:[e.jsxs(vx,{children:[e.jsxs(yx,{children:[e.jsx(at,{size:16}),t.protocol==="oidc"?"OIDC SSO":"SAML SSO",e.jsx(bx,{children:t.protocol.toUpperCase()})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(V,{onClick:b,disabled:S,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:S?e.jsx($e,{size:14}):"Test"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{$outline:!0,onClick:()=>r(t.id),style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Remove"}),o===t.id&&e.jsx(Er,{title:"Delete this SSO connection?",onConfirm:()=>n(t.id),onCancel:a})]})]})]}),$&&e.jsxs("div",{style:{marginBottom:"12px",padding:"8px 12px",background:$.success?"var(--color-success-background, rgba(34, 197, 94, 0.1))":"var(--color-error-background, rgba(239, 68, 68, 0.1))",borderRadius:"6px",fontSize:"12px",color:$.success?"var(--color-success, #22c55e)":"var(--color-error)",fontWeight:500},children:[$.success?"✓ Connection is valid":"✗ Connection failed",$.errors&&Object.entries($.errors).map(([M,F])=>e.jsxs("div",{style:{fontWeight:400,marginTop:"4px"},children:[M.replace(/_/g," "),": ",F]},M))]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"auto 1fr",gap:"4px 16px",fontSize:"12px",marginBottom:"16px"},children:[t.protocol==="saml"?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Entity ID"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_entity_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"SSO URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.idp_sso_url})]}):e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{color:"var(--color-muted)"},children:"Issuer URL"}),e.jsx("span",{style:{color:"var(--color-foreground)",wordBreak:"break-all"},children:t.oidc_issuer_url}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Client ID"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_client_id}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Scopes"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:t.oidc_scopes||"openid profile email"})]}),e.jsx("span",{style:{color:"var(--color-muted)"},children:"Created"}),e.jsx("span",{style:{color:"var(--color-foreground)"},children:new Date(t.created_at).toLocaleDateString()})]}),e.jsxs(_x,{children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsxs(kx,{style:{marginBottom:0},children:[e.jsx(at,{size:14}),"SCIM Provisioning"]}),e.jsx(Cx,{children:!(l!=null&&l.exists)||!((j=l==null?void 0:l.token)!=null&&j.enabled)?e.jsx(V,{onClick:g,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"130px"},children:m?e.jsx($e,{size:14}):"Generate Token"}):e.jsxs(e.Fragment,{children:[e.jsx(V,{onClick:g,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"80px"},children:m?e.jsx($e,{size:14}):"Rotate"}),e.jsx(V,{$outline:!0,onClick:C,disabled:m,style:{fontSize:"12px",padding:"6px 14px",width:"80px",color:"var(--color-error)",borderColor:"var(--color-error)"},children:"Revoke"})]})})]}),(((T=l==null?void 0:l.token)==null?void 0:T.scim_base_url)||x)&&e.jsx("div",{style:{marginBottom:"8px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Base URL:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)"},children:((I=l==null?void 0:l.token)==null?void 0:I.scim_base_url)||"Loading..."}),((O=l==null?void 0:l.token)==null?void 0:O.scim_base_url)&&e.jsx(Gr,{onClick:()=>E(l.token.scim_base_url,"scim-url"),children:k==="scim-url"?e.jsx(Qe,{size:12}):e.jsx(sr,{size:12})})]})}),x&&e.jsxs("div",{style:{marginBottom:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"11px",color:"var(--color-muted)",minWidth:"70px"},children:"Token:"}),e.jsx("code",{style:{fontSize:"11px",flex:1,wordBreak:"break-all",color:"var(--color-foreground)",fontFamily:"monospace"},children:x}),e.jsx(Gr,{onClick:()=>E(x,"scim-token"),children:k==="scim-token"?e.jsx(Qe,{size:12}):e.jsx(sr,{size:12})})]}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-warning)",marginTop:"6px"},children:"⚠️ Copy this token now. It won't be shown again."})]}),(l==null?void 0:l.exists)&&((P=l==null?void 0:l.token)==null?void 0:P.enabled)&&!x&&e.jsxs("div",{style:{fontSize:"11px",color:"var(--color-muted)"},children:["Token: ",e.jsxs("code",{style:{color:"var(--color-foreground)",background:"var(--color-background-alt)",padding:"2px 6px",borderRadius:"4px"},children:[l.token.token_prefix,"..."]}),l.token.last_used_at&&e.jsxs("span",{children:[" · Last used: ",new Date(l.token.last_used_at).toLocaleDateString()]})]})]})]})},Un=h.h3`
|
|
2713
2713
|
margin: 0 0 12px 0;
|
|
2714
2714
|
font-size: 13px;
|
|
2715
2715
|
font-weight: 600;
|
|
2716
2716
|
color: var(--color-foreground);
|
|
2717
2717
|
text-transform: uppercase;
|
|
2718
2718
|
letter-spacing: 0.5px;
|
|
2719
|
-
`,zx=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=tt(),{deployment:n}=xe(),{toast:a}=Ze(),[s,p]=i.useState(!1),[f,c]=i.useState(null),[d,l]=i.useState("saml"),[u,m]=i.useState(null),[v,x]=i.useState(!1),[y,S]=i.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[k,z]=i.useState(!1),[_,$]=i.useState(null),{data:w=[],isLoading:b}=Ue("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(M=>M.verified),{revalidateOnFocus:!1}),g=P=>{c(P),l(P.protocol),P.protocol==="saml"?S(M=>{var F,D,L;return{...M,idp_entity_id:P.placeholders.entityId||"",idp_sso_url:P.placeholders.ssoUrl||"",attr_first_name:((F=P.attributeMapping)==null?void 0:F.first_name)||"",attr_last_name:((D=P.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=P.attributeMapping)==null?void 0:L.email)||""}}):S(M=>{var F,D,L;return{...M,oidc_issuer_url:P.placeholders.issuerUrl||"",oidc_scopes:P.placeholders.scopes||"openid profile email",attr_first_name:((F=P.attributeMapping)==null?void 0:F.first_name)||"",attr_last_name:((D=P.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=P.attributeMapping)==null?void 0:L.email)||""}})},C=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",E=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",j=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",T=(P,M)=>{navigator.clipboard.writeText(P),m(M),setTimeout(()=>m(null),2e3)},I=async P=>{P.preventDefault();const M=F=>F.includes("{")||F.includes("}");if(d==="saml"){if(!y.idp_entity_id||M(y.idp_entity_id)){a("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!y.idp_sso_url||M(y.idp_sso_url)){a("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!y.idp_certificate){a("Please provide the X.509 Certificate","error");return}}else{if(!y.oidc_issuer_url||M(y.oidc_issuer_url)){a("Please enter a valid Issuer URL (no placeholders)","error");return}if(!y.oidc_client_id||M(y.oidc_client_id)){a("Please enter a valid Client ID (no placeholders)","error");return}if(!y.oidc_client_secret){a("Please enter the Client Secret","error");return}}p(!0);try{const F={};y.attr_first_name&&(F.first_name=y.attr_first_name),y.attr_last_name&&(F.last_name=y.attr_last_name),y.attr_email&&(F.email=y.attr_email);const D=Object.keys(F).length>0;d==="saml"?await t({protocol:"saml",domain_id:y.domain_id||void 0,idp_entity_id:y.idp_entity_id,idp_sso_url:y.idp_sso_url,idp_certificate:y.idp_certificate,jit_enabled:y.jit_enabled,...D&&{attribute_mapping:F}}):await t({protocol:"oidc",domain_id:y.domain_id||void 0,oidc_issuer_url:y.oidc_issuer_url,oidc_client_id:y.oidc_client_id,oidc_client_secret:y.oidc_client_secret,oidc_scopes:y.oidc_scopes,jit_enabled:y.jit_enabled,...D&&{attribute_mapping:F}})}finally{p(!1)}},O=async()=>{z(!0),$(null);const P=D=>D.includes("{")||D.includes("}"),M={},F={};if(d==="saml"?(y.idp_entity_id?P(y.idp_entity_id)?(F.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):F.entity_id_valid=!0:(F.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID is required"),y.idp_sso_url?P(y.idp_sso_url)?(F.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):F.sso_url_valid=!0:(F.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL is required"),y.idp_certificate?F.certificate_provided=!0:(F.certificate_provided=!1,M.certificate_provided="X.509 Certificate is required")):(y.oidc_issuer_url?P(y.oidc_issuer_url)?(F.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):F.issuer_url_valid=!0:(F.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL is required"),y.oidc_client_id?P(y.oidc_client_id)?(F.client_id_valid=!1,M.client_id_valid="Client ID contains placeholder values - please replace with actual values"):F.client_id_valid=!0:(F.client_id_valid=!1,M.client_id_valid="Client ID is required")),Object.keys(M).length>0){$({success:!1,checks:F,errors:M}),z(!1);return}try{const D=d==="saml"?{protocol:"saml",idp_entity_id:y.idp_entity_id,idp_sso_url:y.idp_sso_url,idp_certificate:y.idp_certificate}:{protocol:"oidc",oidc_issuer_url:y.oidc_issuer_url,oidc_client_id:y.oidc_client_id,oidc_client_secret:y.oidc_client_secret},L=await(o==null?void 0:o(D));L&&$(L)}catch(D){$({success:!1,checks:{},errors:{general:"Test failed: "+D.message}})}finally{z(!1)}};return e.jsxs("form",{onSubmit:I,autoComplete:"off",children:[f?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[f.logo?e.jsx(Bn,{src:f.logo,alt:f.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(at,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:f.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:f.protocol})]}),e.jsx("button",{type:"button",onClick:()=>c(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Un,{children:"SAML Providers"}),e.jsx(li,{children:ci.filter(P=>P.protocol==="saml").map(P=>e.jsxs(di,{type:"button",$selected:!1,onClick:()=>g(P),children:[P.logo?e.jsx(Bn,{src:P.logo,alt:P.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(at,{size:18,color:"#666"})}),e.jsx(ui,{children:P.name})]},P.id))}),e.jsx(Un,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(li,{children:ci.filter(P=>P.protocol==="oidc").map(P=>e.jsxs(di,{type:"button",$selected:!1,onClick:()=>g(P),children:[P.logo?e.jsx(Bn,{src:P.logo,alt:P.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(at,{size:18,color:"#666"})}),e.jsx(ui,{children:P.name})]},P.id))})]}),f&&e.jsxs(e.Fragment,{children:[e.jsxs(ii,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:d==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:j}),e.jsx(Gr,{onClick:()=>T(j,"acs"),children:u==="acs"?e.jsx(Qe,{size:12}):e.jsx(sr,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:E}),e.jsx(Gr,{onClick:()=>T(E,"metadata"),children:u==="metadata"?e.jsx(Qe,{size:12}):e.jsx(sr,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:C}),e.jsx(Gr,{onClick:()=>T(C,"callback"),children:u==="callback"?e.jsx(Qe,{size:12}):e.jsx(sr,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Un,{style:{margin:0},children:f?`${f.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[f&&f.docUrl&&e.jsxs("a",{href:f.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Pa,{size:12})," Docs"]}),e.jsx(V,{type:"button",onClick:O,disabled:k||!f,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:k?e.jsx($e,{size:16}):"Test Connection"}),e.jsx(V,{type:"submit",disabled:s||w.length===0||!f,style:{width:"auto",padding:"8px 16px"},children:s?e.jsx($e,{size:16}):"Create Connection"})]})]}),_&&(()=>{const P={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:_.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${_.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:_.success?"#10b981":"#ef4444"},children:_.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(_.checks).map(([M,F])=>{var D;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:F?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:F?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:P[M]||M.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((D=_.errors)==null?void 0:D[M])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:_.errors[M]})]})]},M)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!f&&e.jsxs(ie,{children:[e.jsx(oe,{children:"Protocol *"}),e.jsxs(pi,{value:d,onChange:P=>l(P.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(ie,{style:{gridColumn:"1 / -1"},children:[e.jsx(oe,{children:"Domain *"}),b?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):w.length===0?e.jsx(ii,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(pi,{value:y.domain_id,onChange:P=>S({...y,domain_id:P.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),w.map(P=>e.jsx("option",{value:P.id,children:P.fqdn},P.id))]})]}),d==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"IdP Entity ID *"}),e.jsx(J,{type:"text",value:y.idp_entity_id,onChange:P=>S({...y,idp_entity_id:P.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"IdP SSO URL *"}),e.jsx(J,{type:"url",value:y.idp_sso_url,onChange:P=>S({...y,idp_sso_url:P.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(ie,{style:{gridColumn:"1 / -1"},children:[e.jsx(oe,{children:"X.509 Certificate *"}),e.jsx(wx,{value:y.idp_certificate,onChange:P=>S({...y,idp_certificate:P.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"Issuer URL *"}),e.jsx(J,{type:"url",value:y.oidc_issuer_url,onChange:P=>S({...y,oidc_issuer_url:P.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Client ID *"}),e.jsx(J,{type:"text",value:y.oidc_client_id,onChange:P=>S({...y,oidc_client_id:P.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Client Secret *"}),e.jsx(J,{type:"password",value:y.oidc_client_secret,onChange:P=>S({...y,oidc_client_secret:P.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Scopes"}),e.jsx(J,{type:"text",value:y.oidc_scopes,onChange:P=>S({...y,oidc_scopes:P.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(ie,{style:{gridColumn:"1 / -1"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsx(dr,{checked:y.jit_enabled,onChange:()=>S({...y,jit_enabled:!y.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>x(!v),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:v?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:v?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),v&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"First Name Attribute"}),e.jsx(J,{type:"text",value:y.attr_first_name,onChange:P=>S({...y,attr_first_name:P.target.value}),placeholder:d==="saml"?"givenName":"given_name"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Last Name Attribute"}),e.jsx(J,{type:"text",value:y.attr_last_name,onChange:P=>S({...y,attr_last_name:P.target.value}),placeholder:d==="saml"?"surname":"family_name"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Email Attribute"}),e.jsx(J,{type:"text",value:y.attr_email,onChange:P=>S({...y,attr_email:P.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},hi=h.div`
|
|
2719
|
+
`,zx=({onCreate:t})=>{const{getDomains:r,testEnterpriseConnectionConfig:o}=tt(),{deployment:n}=xe(),{toast:a}=Ze(),[s,p]=i.useState(!1),[f,c]=i.useState(null),[d,l]=i.useState("saml"),[u,m]=i.useState(null),[v,x]=i.useState(!1),[y,k]=i.useState({domain_id:"",idp_entity_id:"",idp_sso_url:"",idp_certificate:"",oidc_issuer_url:"",oidc_client_id:"",oidc_client_secret:"",oidc_scopes:"openid profile email",jit_enabled:!0,attr_first_name:"",attr_last_name:"",attr_email:""}),[z,S]=i.useState(!1),[_,$]=i.useState(null),{data:w=[],isLoading:b}=Ue("wacht-org-verified-domains-for-sso-screen",async()=>(await(r==null?void 0:r())||[]).filter(M=>M.verified),{revalidateOnFocus:!1}),g=P=>{c(P),l(P.protocol),P.protocol==="saml"?k(M=>{var F,D,L;return{...M,idp_entity_id:P.placeholders.entityId||"",idp_sso_url:P.placeholders.ssoUrl||"",attr_first_name:((F=P.attributeMapping)==null?void 0:F.first_name)||"",attr_last_name:((D=P.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=P.attributeMapping)==null?void 0:L.email)||""}}):k(M=>{var F,D,L;return{...M,oidc_issuer_url:P.placeholders.issuerUrl||"",oidc_scopes:P.placeholders.scopes||"openid profile email",attr_first_name:((F=P.attributeMapping)==null?void 0:F.first_name)||"",attr_last_name:((D=P.attributeMapping)==null?void 0:D.last_name)||"",attr_email:((L=P.attributeMapping)==null?void 0:L.email)||""}})},C=n!=null&&n.backend_host?`${n.backend_host.startsWith("https://")?"":"https://"}${n.backend_host}/auth/sso/oidc/callback`:"",E=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/metadata`:"",j=n!=null&&n.backend_host?`https://${n.backend_host}/auth/sso/callback`:"",T=(P,M)=>{navigator.clipboard.writeText(P),m(M),setTimeout(()=>m(null),2e3)},I=async P=>{P.preventDefault();const M=F=>F.includes("{")||F.includes("}");if(d==="saml"){if(!y.idp_entity_id||M(y.idp_entity_id)){a("Please enter a valid IdP Entity ID (no placeholders)","error");return}if(!y.idp_sso_url||M(y.idp_sso_url)){a("Please enter a valid IdP SSO URL (no placeholders)","error");return}if(!y.idp_certificate){a("Please provide the X.509 Certificate","error");return}}else{if(!y.oidc_issuer_url||M(y.oidc_issuer_url)){a("Please enter a valid Issuer URL (no placeholders)","error");return}if(!y.oidc_client_id||M(y.oidc_client_id)){a("Please enter a valid Client ID (no placeholders)","error");return}if(!y.oidc_client_secret){a("Please enter the Client Secret","error");return}}p(!0);try{const F={};y.attr_first_name&&(F.first_name=y.attr_first_name),y.attr_last_name&&(F.last_name=y.attr_last_name),y.attr_email&&(F.email=y.attr_email);const D=Object.keys(F).length>0;d==="saml"?await t({protocol:"saml",domain_id:y.domain_id||void 0,idp_entity_id:y.idp_entity_id,idp_sso_url:y.idp_sso_url,idp_certificate:y.idp_certificate,jit_enabled:y.jit_enabled,...D&&{attribute_mapping:F}}):await t({protocol:"oidc",domain_id:y.domain_id||void 0,oidc_issuer_url:y.oidc_issuer_url,oidc_client_id:y.oidc_client_id,oidc_client_secret:y.oidc_client_secret,oidc_scopes:y.oidc_scopes,jit_enabled:y.jit_enabled,...D&&{attribute_mapping:F}})}finally{p(!1)}},O=async()=>{S(!0),$(null);const P=D=>D.includes("{")||D.includes("}"),M={},F={};if(d==="saml"?(y.idp_entity_id?P(y.idp_entity_id)?(F.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID contains placeholder values - please replace with actual values"):F.entity_id_valid=!0:(F.entity_id_valid=!1,M.entity_id_valid="IdP Entity ID is required"),y.idp_sso_url?P(y.idp_sso_url)?(F.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL contains placeholder values - please replace with actual values"):F.sso_url_valid=!0:(F.sso_url_valid=!1,M.sso_url_valid="IdP SSO URL is required"),y.idp_certificate?F.certificate_provided=!0:(F.certificate_provided=!1,M.certificate_provided="X.509 Certificate is required")):(y.oidc_issuer_url?P(y.oidc_issuer_url)?(F.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL contains placeholder values - please replace with actual values"):F.issuer_url_valid=!0:(F.issuer_url_valid=!1,M.issuer_url_valid="Issuer URL is required"),y.oidc_client_id?P(y.oidc_client_id)?(F.client_id_valid=!1,M.client_id_valid="Client ID contains placeholder values - please replace with actual values"):F.client_id_valid=!0:(F.client_id_valid=!1,M.client_id_valid="Client ID is required")),Object.keys(M).length>0){$({success:!1,checks:F,errors:M}),S(!1);return}try{const D=d==="saml"?{protocol:"saml",idp_entity_id:y.idp_entity_id,idp_sso_url:y.idp_sso_url,idp_certificate:y.idp_certificate}:{protocol:"oidc",oidc_issuer_url:y.oidc_issuer_url,oidc_client_id:y.oidc_client_id,oidc_client_secret:y.oidc_client_secret},L=await(o==null?void 0:o(D));L&&$(L)}catch(D){$({success:!1,checks:{},errors:{general:"Test failed: "+D.message}})}finally{S(!1)}};return e.jsxs("form",{onSubmit:I,autoComplete:"off",children:[f?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"12px",background:"var(--color-primary-background)",borderRadius:"8px",border:"1px solid var(--color-primary)",marginBottom:"16px"},children:[f.logo?e.jsx(Bn,{src:f.logo,alt:f.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(at,{size:18,color:"#666"})}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,fontSize:"14px",color:"var(--color-foreground)"},children:f.name}),e.jsx("div",{style:{fontSize:"11px",color:"var(--color-muted)",textTransform:"uppercase"},children:f.protocol})]}),e.jsx("button",{type:"button",onClick:()=>c(null),style:{background:"none",border:"none",color:"var(--color-primary)",cursor:"pointer",fontSize:"12px",padding:"4px 8px"},children:"Change"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Un,{children:"SAML Providers"}),e.jsx(li,{children:ci.filter(P=>P.protocol==="saml").map(P=>e.jsxs(di,{type:"button",$selected:!1,onClick:()=>g(P),children:[P.logo?e.jsx(Bn,{src:P.logo,alt:P.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(at,{size:18,color:"#666"})}),e.jsx(ui,{children:P.name})]},P.id))}),e.jsx(Un,{style:{marginTop:"20px"},children:"OIDC Providers"}),e.jsx(li,{children:ci.filter(P=>P.protocol==="oidc").map(P=>e.jsxs(di,{type:"button",$selected:!1,onClick:()=>g(P),children:[P.logo?e.jsx(Bn,{src:P.logo,alt:P.name}):e.jsx("div",{style:{height:"24px",width:"24px",display:"flex",alignItems:"center",justifyContent:"center",background:"white",borderRadius:"4px",padding:"3px"},children:e.jsx(at,{size:18,color:"#666"})}),e.jsx(ui,{children:P.name})]},P.id))})]}),f&&e.jsxs(e.Fragment,{children:[e.jsxs(ii,{style:{marginTop:"16px"},children:[e.jsx("div",{style:{marginBottom:"12px",fontWeight:500},children:"Service Provider Details"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:d==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"ACS URL:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:j}),e.jsx(Gr,{onClick:()=>T(j,"acs"),children:u==="acs"?e.jsx(Qe,{size:12}):e.jsx(sr,{size:12})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Metadata:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:E}),e.jsx(Gr,{onClick:()=>T(E,"metadata"),children:u==="metadata"?e.jsx(Qe,{size:12}):e.jsx(sr,{size:12})})]})]}):e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{minWidth:"80px",fontSize:"12px"},children:"Callback:"}),e.jsx("code",{style:{flex:1,fontSize:"11px"},children:C}),e.jsx(Gr,{onClick:()=>T(C,"callback"),children:u==="callback"?e.jsx(Qe,{size:12}):e.jsx(sr,{size:12})})]})})]}),e.jsxs("div",{style:{marginTop:"24px"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[e.jsx(Un,{style:{margin:0},children:f?`${f.name} Configuration`:"Configuration"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[f&&f.docUrl&&e.jsxs("a",{href:f.docUrl,target:"_blank",rel:"noopener noreferrer",style:{fontSize:"12px",color:"var(--color-primary)",textDecoration:"none",display:"flex",gap:"2px",alignItems:"center"},children:[e.jsx(Pa,{size:12})," Docs"]}),e.jsx(V,{type:"button",onClick:O,disabled:z||!f,style:{width:"auto",padding:"8px 16px",background:"transparent",border:"1px solid var(--color-border)"},children:z?e.jsx($e,{size:16}):"Test Connection"}),e.jsx(V,{type:"submit",disabled:s||w.length===0||!f,style:{width:"auto",padding:"8px 16px"},children:s?e.jsx($e,{size:16}):"Create Connection"})]})]}),_&&(()=>{const P={entity_id_valid:"IdP Entity ID",sso_url_valid:"IdP SSO URL",certificate_provided:"X.509 Certificate",issuer_url_valid:"Issuer URL",client_id_valid:"Client ID",certificate_valid:"Certificate Valid",sso_url_reachable:"SSO URL Reachable",discovery_reachable:"Discovery Endpoint",discovery_valid:"Discovery Valid",authorization_endpoint:"Authorization Endpoint",token_endpoint:"Token Endpoint",issuer_valid:"Issuer URL Valid"};return e.jsxs("div",{style:{padding:"16px",marginBottom:"16px",borderRadius:"8px",background:_.success?"rgba(16, 185, 129, 0.1)":"rgba(239, 68, 68, 0.1)",border:`1px solid ${_.success?"#10b981":"#ef4444"}`},children:[e.jsx("div",{style:{fontWeight:600,marginBottom:"12px",fontSize:"14px",color:_.success?"#10b981":"#ef4444"},children:_.success?"✓ All checks passed":"✗ Some checks failed"}),e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:Object.entries(_.checks).map(([M,F])=>{var D;return e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:"8px",padding:"8px 12px",background:"var(--color-background)",borderRadius:"6px",border:"1px solid var(--color-border)"},children:[e.jsx("span",{style:{color:F?"#10b981":"#ef4444",fontWeight:600,fontSize:"14px",minWidth:"16px"},children:F?"✓":"✗"}),e.jsxs("div",{style:{flex:1},children:[e.jsx("div",{style:{fontWeight:500,color:"var(--color-foreground)",fontSize:"13px"},children:P[M]||M.replace(/_/g," ").replace(/\b\w/g,L=>L.toUpperCase())}),((D=_.errors)==null?void 0:D[M])&&e.jsx("div",{style:{color:"#ef4444",fontSize:"12px",marginTop:"4px"},children:_.errors[M]})]})]},M)})})]})})(),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"16px"},children:[!f&&e.jsxs(ie,{children:[e.jsx(oe,{children:"Protocol *"}),e.jsxs(pi,{value:d,onChange:P=>l(P.target.value),children:[e.jsx("option",{value:"saml",children:"SAML"}),e.jsx("option",{value:"oidc",children:"OpenID Connect (OIDC)"})]})]}),e.jsxs(ie,{style:{gridColumn:"1 / -1"},children:[e.jsx(oe,{children:"Domain *"}),b?e.jsx("div",{style:{padding:"10px",color:"var(--color-muted)"},children:"Loading domains..."}):w.length===0?e.jsx(ii,{style:{marginBottom:0},children:"No verified domains found. Please add and verify a domain first."}):e.jsxs(pi,{value:y.domain_id,onChange:P=>k({...y,domain_id:P.target.value}),required:!0,children:[e.jsx("option",{value:"",children:"Select a verified domain"}),w.map(P=>e.jsx("option",{value:P.id,children:P.fqdn},P.id))]})]}),d==="saml"?e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"IdP Entity ID *"}),e.jsx(J,{type:"text",value:y.idp_entity_id,onChange:P=>k({...y,idp_entity_id:P.target.value}),placeholder:"https://idp.example.com/entity",required:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"IdP SSO URL *"}),e.jsx(J,{type:"url",value:y.idp_sso_url,onChange:P=>k({...y,idp_sso_url:P.target.value}),placeholder:"https://idp.example.com/sso",required:!0})]}),e.jsxs(ie,{style:{gridColumn:"1 / -1"},children:[e.jsx(oe,{children:"X.509 Certificate *"}),e.jsx(wx,{value:y.idp_certificate,onChange:P=>k({...y,idp_certificate:P.target.value}),placeholder:"-----BEGIN CERTIFICATE-----...",required:!0})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"Issuer URL *"}),e.jsx(J,{type:"url",value:y.oidc_issuer_url,onChange:P=>k({...y,oidc_issuer_url:P.target.value}),placeholder:"https://login.example.com",required:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Client ID *"}),e.jsx(J,{type:"text",value:y.oidc_client_id,onChange:P=>k({...y,oidc_client_id:P.target.value}),placeholder:"your-client-id",required:!0,autoComplete:"off","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Client Secret *"}),e.jsx(J,{type:"password",value:y.oidc_client_secret,onChange:P=>k({...y,oidc_client_secret:P.target.value}),placeholder:"your-client-secret",required:!0,autoComplete:"new-password","data-lpignore":"true","data-form-type":"other"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Scopes"}),e.jsx(J,{type:"text",value:y.oidc_scopes,onChange:P=>k({...y,oidc_scopes:P.target.value}),placeholder:"openid profile email"})]})]}),e.jsx(ie,{style:{gridColumn:"1 / -1"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx("span",{style:{fontWeight:400,color:"var(--color-foreground)",display:"block"},children:"Enable JIT Provisioning"}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginTop:"4px"},children:"When enabled, new users are automatically created on their first SSO login. When disabled, only pre-existing users can sign in via SSO."})]}),e.jsx(dr,{checked:y.jit_enabled,onChange:()=>k({...y,jit_enabled:!y.jit_enabled})})]})}),e.jsxs("div",{style:{gridColumn:"1 / -1",marginTop:"8px",marginBottom:"24px"},children:[e.jsxs("div",{onClick:()=>x(!v),style:{display:"flex",alignItems:"center",gap:"8px",cursor:"pointer",color:"var(--color-primary)",fontSize:"13px",fontWeight:500,marginBottom:v?"16px":"0"},children:[e.jsx("span",{style:{fontSize:"10px"},children:v?"▼":"▶"}),"Advanced Options (Attribute Mapping)"]}),v&&e.jsxs("div",{style:{padding:"16px",background:"var(--color-background-alt)",borderRadius:"8px",border:"1px solid var(--color-border)"},children:[e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)",marginBottom:"12px"},children:"Map IdP attribute names to Wacht user fields. Leave empty to use default attribute names."}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:"12px"},children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"First Name Attribute"}),e.jsx(J,{type:"text",value:y.attr_first_name,onChange:P=>k({...y,attr_first_name:P.target.value}),placeholder:d==="saml"?"givenName":"given_name"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Last Name Attribute"}),e.jsx(J,{type:"text",value:y.attr_last_name,onChange:P=>k({...y,attr_last_name:P.target.value}),placeholder:d==="saml"?"surname":"family_name"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Email Attribute"}),e.jsx(J,{type:"text",value:y.attr_email,onChange:P=>k({...y,attr_email:P.target.value}),placeholder:"email"})]})]})]})]})]})]})]})]})},hi=h.div`
|
|
2720
2720
|
* {
|
|
2721
2721
|
box-sizing: border-box;
|
|
2722
2722
|
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
@@ -2818,9 +2818,9 @@ cursor: pointer;
|
|
|
2818
2818
|
flex-wrap: wrap;
|
|
2819
2819
|
gap: 12px;
|
|
2820
2820
|
margin-bottom: 24px;
|
|
2821
|
-
`,Rx=()=>{var M,F,D,L;const{activeOrganization:t,loading:r}=tt(),{switchOrganization:o,refetch:n}=He(),{workspaces:a}=Lt(),{deployment:s}=xe(),{deleteOrganization:p,updateOrganization:f}=Qo(),{toast:c}=Ze(),[d,l]=i.useState((t==null?void 0:t.name)||""),[u,m]=i.useState((t==null?void 0:t.description)||""),[v,x]=i.useState((t==null?void 0:t.image_url)||null),y=i.useRef(null),[
|
|
2822
|
-
`))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const T=i.useMemo(()=>a.filter(A=>A.organization.id===(t==null?void 0:t.id)),[a,t==null?void 0:t.id]),I=async()=>{if(!(!t||$!==t.name))try{g(!0),await o(""),await p(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{g(!1),w("")}};if(i.useEffect(()=>()=>{v&&URL.revokeObjectURL(v)},[v]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})});const O=R=>{var A;if((A=R.target.files)!=null&&A[0]){const B=R.target.files[0];if(B.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!B.type.startsWith("image/")){c("Please select a valid image file","error");return}v&&URL.revokeObjectURL(v),x(URL.createObjectURL(B)),setTimeout(()=>j(),100)}},P=()=>{y.current&&y.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:v?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:P,onMouseEnter:R=>{R.currentTarget.style.borderColor="var(--color-primary)",R.currentTarget.style.transform="scale(1.02)"},onMouseLeave:R=>{R.currentTarget.style.borderColor="var(--color-border)",R.currentTarget.style.transform="scale(1)"},children:[v?e.jsx("img",{src:v,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(qr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:O,"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(V,{onClick:()=>{var R;return(R=y.current)==null?void 0:R.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(qr,{size:14}),v?"Change":"Upload"]}),e.jsxs(V,{onClick:()=>{x(null),y.current&&(y.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(sn,{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(ie,{children:[e.jsx(oe,{htmlFor:"name",children:"Organization Name"}),e.jsx(J,{id:"name",type:"text",value:d,onChange:R=>l(R.target.value),onBlur:j,placeholder:"Enter organization name",required:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"description",children:"Description"}),e.jsx(J,{id:"description",as:"textarea",value:u,onChange:R=>m(R.target.value),onBlur:j,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),((M=s==null?void 0:s.b2b_settings)==null?void 0:M.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(oe,{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(dr,{checked:
|
|
2823
|
-
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)&&T.length>0&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Ta,{options:T.map(R=>({value:R.id,label:R.name})),value:
|
|
2821
|
+
`,Rx=()=>{var M,F,D,L;const{activeOrganization:t,loading:r}=tt(),{switchOrganization:o,refetch:n}=He(),{workspaces:a}=Lt(),{deployment:s}=xe(),{deleteOrganization:p,updateOrganization:f}=Qo(),{toast:c}=Ze(),[d,l]=i.useState((t==null?void 0:t.name)||""),[u,m]=i.useState((t==null?void 0:t.description)||""),[v,x]=i.useState((t==null?void 0:t.image_url)||null),y=i.useRef(null),[k,z]=i.useState(!1),[S,_]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:"",default_workspace_id:""}),[$,w]=i.useState(""),[b,g]=i.useState(!1),[C,E]=i.useState(!1),j=i.useCallback(async()=>{if(!(!t||k))try{z(!0),await f(t,{name:d,description:u}),c("Changes saved","info")}catch(R){const A=R.message||"Failed to save changes. Please try again.";c(A,"error")}finally{z(!1)}},[t,d,u,v,S,f,c]);i.useEffect(()=>{var R;t&&(l(t.name||""),m(t.description||""),x(t.image_url||null),_({allowed_ips:((R=t.whitelisted_ips)==null?void 0:R.join(`
|
|
2822
|
+
`))||"",ip_restrictions:t.enable_ip_restriction||!1,mfa_required:t.enforce_mfa||!1,default_workspace_id:t.auto_assigned_workspace_id||""}))},[t]);const T=i.useMemo(()=>a.filter(A=>A.organization.id===(t==null?void 0:t.id)),[a,t==null?void 0:t.id]),I=async()=>{if(!(!t||$!==t.name))try{g(!0),await o(""),await p(t),await n(),c("Organization deleted successfully","info")}catch{c("Failed to delete organization","error")}finally{g(!1),w("")}};if(i.useEffect(()=>()=>{v&&URL.revokeObjectURL(v)},[v]),r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})});const O=R=>{var A;if((A=R.target.files)!=null&&A[0]){const B=R.target.files[0];if(B.size>2*1024*1024){c("File size cannot exceed 2MB","error");return}if(!B.type.startsWith("image/")){c("Please select a valid image file","error");return}v&&URL.revokeObjectURL(v),x(URL.createObjectURL(B)),setTimeout(()=>j(),100)}},P=()=>{y.current&&y.current.click()};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:v?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:P,onMouseEnter:R=>{R.currentTarget.style.borderColor="var(--color-primary)",R.currentTarget.style.transform="scale(1.02)"},onMouseLeave:R=>{R.currentTarget.style.borderColor="var(--color-border)",R.currentTarget.style.transform="scale(1)"},children:[v?e.jsx("img",{src:v,alt:"Organization Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(qr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:y,style:{display:"none"},accept:"image/*",onChange:O,"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(V,{onClick:()=>{var R;return(R=y.current)==null?void 0:R.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(qr,{size:14}),v?"Change":"Upload"]}),e.jsxs(V,{onClick:()=>{x(null),y.current&&(y.current.value="")},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(sn,{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(ie,{children:[e.jsx(oe,{htmlFor:"name",children:"Organization Name"}),e.jsx(J,{id:"name",type:"text",value:d,onChange:R=>l(R.target.value),onBlur:j,placeholder:"Enter organization name",required:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"description",children:"Description"}),e.jsx(J,{id:"description",as:"textarea",value:u,onChange:R=>m(R.target.value),onBlur:j,placeholder:"Enter organization description",style:{minHeight:"80px",resize:"vertical",fontFamily:"inherit"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Brief description of your organization"})]}),((M=s==null?void 0:s.b2b_settings)==null?void 0:M.enforce_mfa_per_org_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(oe,{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(dr,{checked:S.mfa_required,onChange:()=>{_(R=>({...R,mfa_required:!R.mfa_required})),setTimeout(()=>j(),100)}})]}),((F=s==null?void 0:s.b2b_settings)==null?void 0:F.ip_allowlist_per_org_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(oe,{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(dr,{checked:S.ip_restrictions,onChange:()=>{_(R=>({...R,ip_restrictions:!R.ip_restrictions})),setTimeout(()=>j(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),S.ip_restrictions&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(J,{id:"allowed_ips",as:"textarea",value:S.allowed_ips,onChange:R=>_(A=>({...A,allowed_ips:R.target.value})),onBlur:j,placeholder:`192.168.1.1
|
|
2823
|
+
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)&&T.length>0&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"default_workspace",children:"Default Workspace"}),e.jsx(Ta,{options:T.map(R=>({value:R.id,label:R.name})),value:S.default_workspace_id,onChange:R=>{_(A=>({...A,default_workspace_id:R})),setTimeout(()=>j(),100)},placeholder:"Select default workspace"}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Workspace that new members will be added to automatically"})]})]})]}),((L=s==null?void 0:s.b2b_settings)==null?void 0:L.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:C?"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(V,{onClick:()=>{C?(E(!1),w("")):E(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:C?"Cancel":"Delete"})]}),C&&e.jsxs("div",{children:[e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"confirm_name",children:"Confirm by typing the organization name"}),e.jsx(J,{id:"confirm_name",type:"text",value:$,onChange:R=>w(R.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(V,{onClick:I,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($e,{size:12}):"Delete Forever"})]})]})]})]})]})})},fi=h.span`
|
|
2824
2824
|
background: var(--color-primary-background);
|
|
2825
2825
|
color: var(--color-primary);
|
|
2826
2826
|
padding: 4px 8px;
|
|
@@ -2857,7 +2857,7 @@ cursor: pointer;
|
|
|
2857
2857
|
opacity: 0.5;
|
|
2858
2858
|
cursor: not-allowed;
|
|
2859
2859
|
}
|
|
2860
|
-
`,Ix=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=tt(),a=i.useRef(null),[s,p]=i.useState(null),{data:f=[],isLoading:c,mutate:d}=Ue(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((E,j)=>({...E,verified:E.verified!==void 0?E.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),l=f,[u,m]=i.useState(!1),[v,x]=i.useState(null),[y,
|
|
2860
|
+
`,Ix=()=>{const{activeOrganization:t,loading:r,getDomains:o,removeDomain:n}=tt(),a=i.useRef(null),[s,p]=i.useState(null),{data:f=[],isLoading:c,mutate:d}=Ue(t!=null&&t.id?`wacht-org-domains:${t.id}`:null,async()=>(await(o==null?void 0:o())||[]).map((E,j)=>({...E,verified:E.verified!==void 0?E.verified:j%2===0})),{refreshInterval:3e4,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:5e3}),l=f,[u,m]=i.useState(!1),[v,x]=i.useState(null),[y,k]=i.useState(""),[z,S]=i.useState(null),_=i.useRef(null),$=i.useRef({}),w=i.useMemo(()=>{let C=l;if(y.trim()!==""){const E=y.toLowerCase();C=C.filter(j=>j.fqdn.toLowerCase().includes(E))}return C},[l,y]),b=async C=>{await n(C),d()},g=async C=>{x(C)};return r||c?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(Nl,{children:[e.jsx(Pt,{value:y,onChange:k,placeholder:"Search Domain"}),e.jsxs("div",{children:[e.jsx(V,{ref:_,onClick:()=>m(!u),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"New Domain"}),u&&e.jsx(ai,{onClose:()=>{m(!1),d()},triggerRef:_})]})]}),e.jsxs("div",{style:{padding:"12px 16px",background:"var(--color-background-alt)",borderRadius:"8px",marginBottom:"24px",border:"1px solid var(--color-border)",fontSize:"13px",color:"var(--color-secondary-text)"},children:["Users with verified domain emails automatically join this organization",(t==null?void 0:t.auto_assigned_workspace_id)&&" and its default workspace","."]}),w!=null&&w.length?e.jsxs(mt,{ref:a,children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Domain"}),e.jsx(ke,{children:"Status"}),e.jsx(ke,{children:"Date Added"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:w.map(C=>e.jsxs(Ve,{children:[e.jsx(De,{children:C.fqdn}),e.jsx(De,{children:C.verified?e.jsx(fi,{style:{background:"var(--color-primary-background)",color:"var(--color-primary)"},children:"✓ Verified"}):e.jsxs(fi,{style:{background:"var(--color-warning-background)",color:"var(--color-warning)",border:"1px solid var(--color-warning-border)"},children:[e.jsx(ft,{size:9})," Pending Verification"]})}),e.jsx(De,{children:new Date(C.created_at).toLocaleDateString()}),e.jsx(yt,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsxs(it,{style:{marginLeft:"auto"},open:z===C.id,openChange:E=>S(E?C.id:null),children:[e.jsx(lt,{children:e.jsx(Ma,{ref:E=>{$.current[C.id]=E},children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Le,{onClick:()=>{g(C.id),S(null)},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:C.verified?"📋 View DNS Record":"✓ Verify Domain"})}),e.jsx(Le,{onClick:()=>{S(null),navigator.clipboard.writeText(C.fqdn)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(sr,{size:16,color:"var(--color-muted)"})," Copy Domain"]})}),e.jsx(Le,{onClick:()=>{window.open(`https://${C.fqdn}`,"_blank"),S(null)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Pa,{size:16,color:"var(--color-muted)"})," ","Visit Domain"]})}),e.jsx(cn,{}),e.jsx(Le,{$destructive:!0,onClick:()=>{S(null),p(C.id)},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(sn,{size:16,color:"var(--color-error)"})," ","Remove Domain"]})})]})]}),s===C.id&&e.jsx(Er,{title:"Are you sure you want to delete this domain?",onConfirm:()=>b(C),onCancel:()=>p(null)}),v===C.id&&e.jsx(ai,{domain:C,onClose:()=>x(null),triggerRef:{current:$.current[C.id]}})]})})]},C.id))})]}):e.jsx(dt,{title:y!=="all"?"No domains match your criteria":"No domains added",description:"Add a domain to get started"})]})},Tx=h.div`
|
|
2861
2861
|
width: 40px;
|
|
2862
2862
|
height: 40px;
|
|
2863
2863
|
border-radius: 50%;
|
|
@@ -2869,7 +2869,7 @@ cursor: pointer;
|
|
|
2869
2869
|
font-weight: 400;
|
|
2870
2870
|
font-size: 14px;
|
|
2871
2871
|
overflow: hidden;
|
|
2872
|
-
`,Ox=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:a,removeMemberRole:s,removeMember:p}=tt(),{session:f}=He(),{toast:c}=Ze(),[d,l]=i.useState(""),[u,m]=i.useState(!1),v=i.useRef(null),{data:x=[],isLoading:y,mutate:S}=Ue(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:k=[],isLoading:z}=Ue(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),_=k,$=i.useMemo(()=>d?x.filter(j=>{var F;const T=j.user;if(!T)return!1;const I=T.first_name||"",O=T.last_name||"",P=((F=T.primary_email_address)==null?void 0:F.email)||"";return`${I} ${O}`.trim().toLowerCase().includes(d.toLowerCase())||P.toLowerCase().includes(d.toLowerCase())}):x,[x,d]),w=async(j,T,I)=>{try{I?(await s(j,T),c("Role removed successfully","info")):(await a(j,T),c("Role added successfully","info")),S()}catch(O){const P=O.message||"Failed to update role. Please try again.";c(P,"error")}},b=(j="",T="")=>`${j[0]||""}${T[0]||""}`.toUpperCase(),g=(j,T)=>{var I;return((I=j.roles)==null?void 0:I.some(O=>O.id===T))||!1},C=async j=>{try{await p(j),S(),c("Member removed successfully","info")}catch(T){const I=T.message||"Failed to remove member. Please try again.";c(I,"error")}},E=()=>{m(!1),S(),c("Invitation sent successfully","info")};return r||y||z?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(Pt,{value:d,onChange:l,placeholder:"Search members..."})}),e.jsx(V,{ref:v,onClick:()=>m(!u),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),u&&e.jsx(Dl,{onClose:()=>m(!1),onSuccess:E,roles:_,triggerRef:v}),$.length===0?e.jsx(dt,{title:d?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Member"}),e.jsx(ke,{children:"Joined"}),e.jsx(ke,{children:"Roles"})]})}),e.jsx(vt,{children:$.map(j=>{var P,M;const T=j.roles||[],I=j.user,O=(I==null?void 0:I.id)===((P=f==null?void 0:f.active_signin)==null?void 0:P.user_id);return e.jsxs(Ve,{children:[e.jsx(Fl,{children:e.jsxs("div",{children:[e.jsx(Tx,{children:I!=null&&I.profile_picture_url?e.jsx("img",{src:I.profile_picture_url,alt:`${I.first_name||""} ${I.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):b(I==null?void 0:I.first_name,I==null?void 0:I.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 D;if(!I)return"Unknown User";const F=`${I.first_name||""} ${I.last_name||""}`.trim();return F||((D=I.primary_email_address)==null?void 0:D.email)||"Unknown User"})()}),O&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(M=I==null?void 0:I.primary_email_address)==null?void 0:M.email})]})]})}),e.jsx(De,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(yt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(it,{children:[e.jsx(lt,{children:e.jsxs(V,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:T.length>0?T[0].name:"No role"}),e.jsx(At,{size:14})]})}),e.jsxs(ct,{children:[_.map(F=>{const D=g(j,F.id);return e.jsx(Le,{onClick:()=>w(j,F,D),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:F.name}),D&&e.jsx(Qe,{size:16,color:"var(--color-success)"})]})},F.id)}),e.jsx(cn,{}),e.jsx(Le,{$destructive:!0,onClick:()=>C(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(sn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},Mx=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:a,resendInvitation:s}=tt(),{toast:p}=Ze(),[f,c]=i.useState(!1),[d,l]=i.useState(""),u=i.useRef(null),{data:m=[],isLoading:v,mutate:x}=Ue(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:y=[],isLoading:S}=Ue(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),k=y,z=i.useMemo(()=>d?m.filter(b=>b.email.toLowerCase().includes(d.toLowerCase())):m,[m,d]),_=()=>{p("Invitation sent successfully","info"),x(),c(!1)},$=async b=>{try{await a(b),x(),p("Invitation cancelled successfully","info")}catch(g){const C=g.message||"Failed to cancel invitation. Please try again.";p(C,"error")}},w=async b=>{try{await s(b),p("Invitation resent successfully","info")}catch(g){const C=g.message||"Failed to resend invitation. Please try again.";p(C,"error")}};return r||v||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(Pt,{value:d,onChange:l,placeholder:"Search invitations..."})}),e.jsx(V,{ref:u,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx(Dl,{onClose:()=>c(!1),onSuccess:_,roles:k,triggerRef:u}),z.length===0?e.jsx(dt,{title:d?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Email"}),e.jsx(ke,{children:"Role"}),e.jsx(ke,{children:"Invited"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:z.map(b=>{var g;return e.jsxs(Ve,{children:[e.jsx(De,{children:b.email}),e.jsx(De,{children:((g=b.initial_organization_role)==null?void 0:g.name)||"No role"}),e.jsx(De,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(yt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(it,{children:[e.jsx(lt,{children:e.jsx(Ma,{children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Le,{onClick:()=>w(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(an,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Le,{$destructive:!0,onClick:()=>$(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(sn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},b.id)})})]})]})},Ax=()=>{var b;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=tt(),{deployment:a}=xe(),[s,p]=i.useState({isOpen:!1}),[f,c]=i.useState(null),[d,l]=i.useState(null),[u,m]=i.useState(""),[v,x]=i.useState(null),y=i.useRef(null),{data:S=[],isLoading:k,mutate:z}=Ue(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),_=i.useMemo(()=>u?S.filter(g=>g.name.toLowerCase().includes(u.toLowerCase())):S,[S,u]),$=async g=>{try{g.id?(await new Promise(C=>setTimeout(C,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(C=>setTimeout(C,1e3)),c({text:"Role created successfully",type:"success"})),p({isOpen:!1}),z()}catch(C){const E=(C==null?void 0:C.message)||(g.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");g.id?c({text:E,type:"error"}):c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},w=async g=>{try{await n(g),z()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(ft,{size:16}),f.text]}),e.jsxs(Nl,{children:[e.jsx(Pt,{placeholder:"Search roles",onChange:m,value:u}),((b=a==null?void 0:a.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(V,{ref:y,onClick:()=>p({isOpen:!s.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),s.isOpen&&!s.role&&e.jsx(si,{role:s.role,onClose:()=>p({isOpen:!1}),onSuccess:$,triggerRef:y})]})]}),_.length===0?e.jsx(dt,{title:u?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Role"}),e.jsx(ke,{children:"Permissions"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:_.map(g=>{var C;return e.jsxs(Ve,{children:[e.jsx(De,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:g.name})}),e.jsx(De,{style:{color:"var(--color-secondary-text)"},children:g.permissions.join(", ")}),e.jsx(yt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(it,{open:d===g.id,openChange:E=>l(E?g.id:null),children:[e.jsx(lt,{children:e.jsx(Ma,{disabled:!g.organization_id,"data-role-dropdown-trigger":g.id,children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Le,{onClick:()=>{l(null),p({isOpen:!0,role:g})},children:"Edit Role"}),e.jsx(Le,{$destructive:!0,onClick:()=>{l(null),x(g.id)},children:"Remove Role"})]})]}),v===g.id&&e.jsx(Er,{title:"Are you sure you want to delete this role?",onConfirm:()=>w(g),onCancel:()=>x(null)}),s.isOpen&&((C=s.role)==null?void 0:C.id)===g.id&&e.jsx(si,{role:s.role,onClose:()=>{p({isOpen:!1}),l(null)},onSuccess:$})]})})]},g.id)})})]})]})},Bl=()=>{var l;const{loading:t,activeOrganization:r}=tt(),{deployment:o}=xe(),[n,a]=i.useState("general"),[s,p]=i.useState(null),[f,c]=i.useState("info"),d=i.useCallback((u,m="info")=>{p(u),c(m),setTimeout(()=>p(null),3e3)},[p]);return t?e.jsx(Wn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx($e,{})}):r?e.jsx(hi,{children:e.jsx(Oa.Provider,{value:{screen:null,setScreen:()=>{},toast:d},children:e.jsxs(Wn,{children:[e.jsx(Ex,{children:e.jsxs($x,{children:[e.jsx(mr,{$isActive:n==="general",onClick:()=>a("general"),children:e.jsxs(xr,{children:[e.jsx(ir,{size:16}),"General"]})}),e.jsx(mr,{$isActive:n==="domains",onClick:()=>a("domains"),children:e.jsxs(xr,{children:[e.jsx(xh,{size:16}),"Domains"]})}),e.jsx(mr,{$isActive:n==="members",onClick:()=>a("members"),children:e.jsxs(xr,{children:[e.jsx(Go,{size:16}),"Members"]})}),e.jsx(mr,{$isActive:n==="invitations",onClick:()=>a("invitations"),children:e.jsxs(xr,{children:[e.jsx(an,{size:16}),"Invitations"]})}),e.jsx(mr,{$isActive:n==="roles",onClick:()=>a("roles"),children:e.jsxs(xr,{children:[e.jsx(at,{size:16}),"Roles"]})}),((l=o==null?void 0:o.b2b_settings)==null?void 0:l.enterprise_sso_enabled)&&e.jsx(mr,{$isActive:n==="sso",onClick:()=>a("sso"),children:e.jsxs(xr,{children:[e.jsx(at,{size:16}),"Single Sign-On"]})})]})}),e.jsxs(Px,{children:[n==="general"&&e.jsx(Rx,{}),n==="domains"&&e.jsx(Ix,{}),n==="members"&&e.jsx(Ox,{}),n==="invitations"&&e.jsx(Mx,{}),n==="roles"&&e.jsx(Ax,{}),n==="sso"&&e.jsx(jx,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f==="error"?e.jsx(ft,{size:16,color:"var(--color-error)"}):e.jsx(Qe,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):e.jsx(hi,{children:e.jsx(Wn,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(qr,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(ed,{})]})})})},Lx=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:f,showCloseButton:c})=>e.jsx(_e,{isOpen:t,onClose:r,children:e.jsx(_e.Overlay,{children:e.jsxs(_e.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(_e.Header,{showCloseButton:c,children:a||o}),p||f||e.jsx(Bl,{}),s&&e.jsx(_e.Footer,{children:s})]})})}),Dx=h.div`
|
|
2872
|
+
`,Ox=()=>{const{activeOrganization:t,loading:r,getMembers:o,getRoles:n,addMemberRole:a,removeMemberRole:s,removeMember:p}=tt(),{session:f}=He(),{toast:c}=Ze(),[d,l]=i.useState(""),[u,m]=i.useState(!1),v=i.useRef(null),{data:x=[],isLoading:y,mutate:k}=Ue(t?`wacht-api-organizations:${t.id}:members`:null,()=>(o==null?void 0:o())||[]),{data:z=[],isLoading:S}=Ue(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),_=z,$=i.useMemo(()=>d?x.filter(j=>{var F;const T=j.user;if(!T)return!1;const I=T.first_name||"",O=T.last_name||"",P=((F=T.primary_email_address)==null?void 0:F.email)||"";return`${I} ${O}`.trim().toLowerCase().includes(d.toLowerCase())||P.toLowerCase().includes(d.toLowerCase())}):x,[x,d]),w=async(j,T,I)=>{try{I?(await s(j,T),c("Role removed successfully","info")):(await a(j,T),c("Role added successfully","info")),k()}catch(O){const P=O.message||"Failed to update role. Please try again.";c(P,"error")}},b=(j="",T="")=>`${j[0]||""}${T[0]||""}`.toUpperCase(),g=(j,T)=>{var I;return((I=j.roles)==null?void 0:I.some(O=>O.id===T))||!1},C=async j=>{try{await p(j),k(),c("Member removed successfully","info")}catch(T){const I=T.message||"Failed to remove member. Please try again.";c(I,"error")}},E=()=>{m(!1),k(),c("Invitation sent successfully","info")};return r||y||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(Pt,{value:d,onChange:l,placeholder:"Search members..."})}),e.jsx(V,{ref:v,onClick:()=>m(!u),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),u&&e.jsx(Dl,{onClose:()=>m(!1),onSuccess:E,roles:_,triggerRef:v}),$.length===0?e.jsx(dt,{title:d?"No members match your search":"No members yet",description:"Invite members to your organization to get started."}):e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Member"}),e.jsx(ke,{children:"Joined"}),e.jsx(ke,{children:"Roles"})]})}),e.jsx(vt,{children:$.map(j=>{var P,M;const T=j.roles||[],I=j.user,O=(I==null?void 0:I.id)===((P=f==null?void 0:f.active_signin)==null?void 0:P.user_id);return e.jsxs(Ve,{children:[e.jsx(Fl,{children:e.jsxs("div",{children:[e.jsx(Tx,{children:I!=null&&I.profile_picture_url?e.jsx("img",{src:I.profile_picture_url,alt:`${I.first_name||""} ${I.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):b(I==null?void 0:I.first_name,I==null?void 0:I.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 D;if(!I)return"Unknown User";const F=`${I.first_name||""} ${I.last_name||""}`.trim();return F||((D=I.primary_email_address)==null?void 0:D.email)||"Unknown User"})()}),O&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(M=I==null?void 0:I.primary_email_address)==null?void 0:M.email})]})]})}),e.jsx(De,{children:new Date(j.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(yt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(it,{children:[e.jsx(lt,{children:e.jsxs(V,{style:{background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"6px 12px",fontSize:"14px",color:"var(--color-foreground)",display:"flex",alignItems:"center",gap:"4px",minWidth:"120px",justifyContent:"space-between"},children:[e.jsx("span",{children:T.length>0?T[0].name:"No role"}),e.jsx(At,{size:14})]})}),e.jsxs(ct,{children:[_.map(F=>{const D=g(j,F.id);return e.jsx(Le,{onClick:()=>w(j,F,D),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:F.name}),D&&e.jsx(Qe,{size:16,color:"var(--color-success)"})]})},F.id)}),e.jsx(cn,{}),e.jsx(Le,{$destructive:!0,onClick:()=>C(j),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(sn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})})]},j.id)})})]})]})},Mx=()=>{const{activeOrganization:t,loading:r,getInvitations:o,getRoles:n,discardInvitation:a,resendInvitation:s}=tt(),{toast:p}=Ze(),[f,c]=i.useState(!1),[d,l]=i.useState(""),u=i.useRef(null),{data:m=[],isLoading:v,mutate:x}=Ue(t?`wacht-api-organizations:${t.id}:invitations`:null,()=>(o==null?void 0:o())||[]),{data:y=[],isLoading:k}=Ue(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(n==null?void 0:n())||[]),z=y,S=i.useMemo(()=>d?m.filter(b=>b.email.toLowerCase().includes(d.toLowerCase())):m,[m,d]),_=()=>{p("Invitation sent successfully","info"),x(),c(!1)},$=async b=>{try{await a(b),x(),p("Invitation cancelled successfully","info")}catch(g){const C=g.message||"Failed to cancel invitation. Please try again.";p(C,"error")}},w=async b=>{try{await s(b),p("Invitation resent successfully","info")}catch(g){const C=g.message||"Failed to resend invitation. Please try again.";p(C,"error")}};return r||v||k?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:"16px"},children:[e.jsx("div",{style:{flex:1},children:e.jsx(Pt,{value:d,onChange:l,placeholder:"Search invitations..."})}),e.jsx(V,{ref:u,onClick:()=>c(!f),style:{background:"var(--color-primary)",color:"white",border:"none",padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,whiteSpace:"nowrap",height:"36px",width:"auto"},children:"Invite Members"})]}),f&&e.jsx(Dl,{onClose:()=>c(!1),onSuccess:_,roles:z,triggerRef:u}),S.length===0?e.jsx(dt,{title:d?"No invitations match your search":"No pending invitations",description:"Invite new members to your organization."}):e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Email"}),e.jsx(ke,{children:"Role"}),e.jsx(ke,{children:"Invited"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:S.map(b=>{var g;return e.jsxs(Ve,{children:[e.jsx(De,{children:b.email}),e.jsx(De,{children:((g=b.initial_organization_role)==null?void 0:g.name)||"No role"}),e.jsx(De,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(yt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(it,{children:[e.jsx(lt,{children:e.jsx(Ma,{children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Le,{onClick:()=>w(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(an,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Le,{$destructive:!0,onClick:()=>$(b),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(sn,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},b.id)})})]})]})},Ax=()=>{var b;const{activeOrganization:t,loading:r,getRoles:o,removeRole:n}=tt(),{deployment:a}=xe(),[s,p]=i.useState({isOpen:!1}),[f,c]=i.useState(null),[d,l]=i.useState(null),[u,m]=i.useState(""),[v,x]=i.useState(null),y=i.useRef(null),{data:k=[],isLoading:z,mutate:S}=Ue(t?`wacht-api-organizations:${t.id}:roles`:null,()=>(o==null?void 0:o())||[]),_=i.useMemo(()=>u?k.filter(g=>g.name.toLowerCase().includes(u.toLowerCase())):k,[k,u]),$=async g=>{try{g.id?(await new Promise(C=>setTimeout(C,1e3)),c({text:"Role updated successfully",type:"success"})):(await new Promise(C=>setTimeout(C,1e3)),c({text:"Role created successfully",type:"success"})),p({isOpen:!1}),S()}catch(C){const E=(C==null?void 0:C.message)||(g.id?"Failed to update role. Please try again.":"Failed to create role. Please try again.");g.id?c({text:E,type:"error"}):c({text:E,type:"error"})}finally{setTimeout(()=>c(null),3e3)}},w=async g=>{try{await n(g),S()}catch{}finally{setTimeout(()=>c(null),3e3)}};return r||z?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[f&&e.jsxs("div",{style:{marginBottom:"20px",padding:"8px",background:f.type==="success"?"var(--color-success-background)":"var(--color-error-background)",color:f.type==="success"?"var(--color-success)":"var(--color-error)",borderRadius:"8px",display:"flex",alignItems:"center",gap:"8px"},children:[f.type==="success"?"✓":e.jsx(ft,{size:16}),f.text]}),e.jsxs(Nl,{children:[e.jsx(Pt,{placeholder:"Search roles",onChange:m,value:u}),((b=a==null?void 0:a.b2b_settings)==null?void 0:b.custom_org_role_enabled)&&e.jsxs("div",{children:[e.jsx(V,{ref:y,onClick:()=>p({isOpen:!s.isOpen}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),s.isOpen&&!s.role&&e.jsx(si,{role:s.role,onClose:()=>p({isOpen:!1}),onSuccess:$,triggerRef:y})]})]}),_.length===0?e.jsx(dt,{title:u?"No roles match your search":"No roles defined yet. Create your first role to get started.",description:"Create a role to get started"}):e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Role"}),e.jsx(ke,{children:"Permissions"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:_.map(g=>{var C;return e.jsxs(Ve,{children:[e.jsx(De,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:g.name})}),e.jsx(De,{style:{color:"var(--color-secondary-text)"},children:g.permissions.join(", ")}),e.jsx(yt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(it,{open:d===g.id,openChange:E=>l(E?g.id:null),children:[e.jsx(lt,{children:e.jsx(Ma,{disabled:!g.organization_id,"data-role-dropdown-trigger":g.id,children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Le,{onClick:()=>{l(null),p({isOpen:!0,role:g})},children:"Edit Role"}),e.jsx(Le,{$destructive:!0,onClick:()=>{l(null),x(g.id)},children:"Remove Role"})]})]}),v===g.id&&e.jsx(Er,{title:"Are you sure you want to delete this role?",onConfirm:()=>w(g),onCancel:()=>x(null)}),s.isOpen&&((C=s.role)==null?void 0:C.id)===g.id&&e.jsx(si,{role:s.role,onClose:()=>{p({isOpen:!1}),l(null)},onSuccess:$})]})})]},g.id)})})]})]})},Bl=()=>{var l;const{loading:t,activeOrganization:r}=tt(),{deployment:o}=xe(),[n,a]=i.useState("general"),[s,p]=i.useState(null),[f,c]=i.useState("info"),d=i.useCallback((u,m="info")=>{p(u),c(m),setTimeout(()=>p(null),3e3)},[p]);return t?e.jsx(Wn,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx($e,{})}):r?e.jsx(hi,{children:e.jsx(Oa.Provider,{value:{screen:null,setScreen:()=>{},toast:d},children:e.jsxs(Wn,{children:[e.jsx(Ex,{children:e.jsxs($x,{children:[e.jsx(mr,{$isActive:n==="general",onClick:()=>a("general"),children:e.jsxs(xr,{children:[e.jsx(ir,{size:16}),"General"]})}),e.jsx(mr,{$isActive:n==="domains",onClick:()=>a("domains"),children:e.jsxs(xr,{children:[e.jsx(xh,{size:16}),"Domains"]})}),e.jsx(mr,{$isActive:n==="members",onClick:()=>a("members"),children:e.jsxs(xr,{children:[e.jsx(Go,{size:16}),"Members"]})}),e.jsx(mr,{$isActive:n==="invitations",onClick:()=>a("invitations"),children:e.jsxs(xr,{children:[e.jsx(an,{size:16}),"Invitations"]})}),e.jsx(mr,{$isActive:n==="roles",onClick:()=>a("roles"),children:e.jsxs(xr,{children:[e.jsx(at,{size:16}),"Roles"]})}),((l=o==null?void 0:o.b2b_settings)==null?void 0:l.enterprise_sso_enabled)&&e.jsx(mr,{$isActive:n==="sso",onClick:()=>a("sso"),children:e.jsxs(xr,{children:[e.jsx(at,{size:16}),"Single Sign-On"]})})]})}),e.jsxs(Px,{children:[n==="general"&&e.jsx(Rx,{}),n==="domains"&&e.jsx(Ix,{}),n==="members"&&e.jsx(Ox,{}),n==="invitations"&&e.jsx(Mx,{}),n==="roles"&&e.jsx(Ax,{}),n==="sso"&&e.jsx(jx,{})]}),s&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",maxWidth:"360px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"8px",padding:"12px 16px",boxShadow:"0 4px 12px var(--color-shadow)",animation:"slideUp 0.3s ease-out",wordBreak:"break-word"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[f==="error"?e.jsx(ft,{size:16,color:"var(--color-error)"}):e.jsx(Qe,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:s})]})})]})})}):e.jsx(hi,{children:e.jsx(Wn,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",height:"100%",padding:"40px 24px",textAlign:"center"},children:[e.jsx("div",{style:{width:"80px",height:"80px",borderRadius:"50%",background:"var(--color-input-background)",display:"flex",alignItems:"center",justifyContent:"center",marginBottom:"24px",border:"2px dashed var(--color-border)"},children:e.jsx(qr,{size:32,color:"var(--color-muted)"})}),e.jsx("h3",{style:{fontSize:"18px",fontWeight:600,color:"var(--color-foreground)",margin:"0 0 8px 0"},children:"No Organization Selected"}),e.jsx(ed,{})]})})})},Lx=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:f,showCloseButton:c})=>e.jsx(_e,{isOpen:t,onClose:r,children:e.jsx(_e.Overlay,{children:e.jsxs(_e.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(_e.Header,{showCloseButton:c,children:a||o}),p||f||e.jsx(Bl,{}),s&&e.jsx(_e.Footer,{children:s})]})})}),Dx=h.div`
|
|
2873
2873
|
display: flex;
|
|
2874
2874
|
height: 100%;
|
|
2875
2875
|
min-height: 400px;
|
|
@@ -3160,7 +3160,7 @@ cursor: pointer;
|
|
|
3160
3160
|
align-items: center;
|
|
3161
3161
|
justify-content: center;
|
|
3162
3162
|
color: var(--color-primary);
|
|
3163
|
-
`,Aa=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var P;const[a,s]=i.useState(""),[p,f]=i.useState(""),[c,d]=i.useState(),[l,u]=i.useState(null),[m,v]=i.useState(!1),[x,y]=i.useState(!1),[
|
|
3163
|
+
`,Aa=({organizationId:t,onSuccess:r,onCancel:o,onCreateOrganization:n})=>{var P;const[a,s]=i.useState(""),[p,f]=i.useState(""),[c,d]=i.useState(),[l,u]=i.useState(null),[m,v]=i.useState(!1),[x,y]=i.useState(!1),[k,z]=i.useState(t),S=i.useRef(null),_=i.useRef(null),{toast:$}=Ze(),{createWorkspace:w}=Lt(),{organizationMemberships:b}=$t(),g=(P=b==null?void 0:b.find(M=>M.organization.id===k))==null?void 0:P.organization,C=M=>{if(M.target.files&&M.target.files[0]){const F=M.target.files[0];if(F.size>2*1024*1024){$("File size cannot exceed 2MB","error");return}if(!F.type.startsWith("image/")){$("Please select a valid image file","error");return}l&&URL.revokeObjectURL(l),d(F),u(URL.createObjectURL(F))}},E=()=>{var M;(M=S.current)==null||M.click()},j=M=>M.split(" ").map(F=>F[0]).join("").toUpperCase().slice(0,2)||"W",T=M=>M.trim().replace(/[<>\"'&]/g,""),I=M=>M.length>=2&&M.length<=100&&/^[a-zA-Z0-9\s_.-]+$/.test(M),O=async()=>{const M=T(a),F=T(p);if(!M||!k){$("Please enter a workspace name","error");return}if(!I(M)){$("Workspace name must be 2-100 characters and contain only letters, numbers, spaces, dots, underscores, and hyphens","error");return}if(F.length>500){$("Description must be less than 500 characters","error");return}v(!0);try{const D=await w(k,M,c,F);r==null||r(D)}catch(D){const L=D.message||"Failed to create workspace. Please try again.";$(L,"error")}finally{v(!1)}};return i.useEffect(()=>()=>{l&&URL.revokeObjectURL(l)},[l]),i.useEffect(()=>{const M=F=>{_.current&&!_.current.contains(F.target)&&y(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]),e.jsx(ue,{children:e.jsxs(Dx,{children:[e.jsxs(Fx,{children:[e.jsxs(Ul,{hasImage:!!l,onClick:E,children:[l?e.jsx(Bx,{src:l,alt:"Workspace logo"}):e.jsx(Ux,{children:j(a||"W")}),e.jsx(t0,{children:e.jsx(r0,{children:"Upload Logo"})})]}),e.jsx(e0,{type:"file",ref:S,onChange:C,accept:"image/png, image/jpeg, image/gif",disabled:m}),e.jsx(Wx,{children:"Create new workspace"}),e.jsx(Vx,{children:"Workspaces are used to organize your projects and team members into logical groups."})]}),e.jsxs(Nx,{children:[e.jsxs(Gx,{children:[e.jsx(Hx,{children:"Choose your workspace name"}),e.jsx(qx,{children:"Enter a name for your new workspace. This will be visible to all members."})]}),e.jsxs(Yx,{children:[e.jsxs(Vn,{children:[e.jsx(Gn,{children:"Organization"}),e.jsxs(o0,{ref:_,children:[e.jsxs(n0,{type:"button",onClick:()=>y(!x),disabled:m,children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(gi,{children:g!=null&&g.image_url?e.jsx(mi,{src:g.image_url,alt:g.name}):j((g==null?void 0:g.name)||"O").charAt(0)}),e.jsx("span",{children:(g==null?void 0:g.name)||"Select organization"})]}),e.jsx(At,{size:16,style:{color:"var(--color-secondary-text)"}})]}),x&&e.jsxs(a0,{children:[b==null?void 0:b.map(M=>e.jsxs(Wl,{onClick:()=>{z(M.organization.id),y(!1)},children:[e.jsx(gi,{children:M.organization.image_url?e.jsx(mi,{src:M.organization.image_url,alt:M.organization.name}):j(M.organization.name).charAt(0)}),e.jsx("span",{children:M.organization.name})]},M.organization.id)),e.jsxs(s0,{onClick:()=>{y(!1),n==null||n()},children:[e.jsx(i0,{children:e.jsx(rt,{size:12})}),e.jsx("span",{children:"Create new organization"})]})]})]})]}),e.jsxs(Vn,{children:[e.jsx(Gn,{children:"Workspace name"}),e.jsx(Zx,{type:"text",value:a,onChange:M=>s(M.target.value),placeholder:"Workspace Name",disabled:m})]}),e.jsxs(Vn,{children:[e.jsx(Gn,{children:"Description (optional)"}),e.jsx(Kx,{value:p,onChange:M=>f(M.target.value),placeholder:"What is this workspace for?",disabled:m})]})]}),e.jsxs(Qx,{children:[o?e.jsxs(Jx,{onClick:o,disabled:m,children:[e.jsx(Ea,{size:16}),"Back"]}):e.jsx("div",{}),e.jsx(Xx,{onClick:O,disabled:m||!a.trim(),children:m?"Creating...":"Create"})]})]})]})})},Vl=({isOpen:t,onClose:r,onCreated:o,organizationId:n})=>{const[a,s]=i.useState(!1),[p,f]=i.useState(n),{refetch:c,organizationMemberships:d}=$t(),l=()=>{o==null||o(),r==null||r()},u=()=>{s(!0)},m=async()=>{await c(),setTimeout(()=>{if(d&&d.length>0){const v=d[d.length-1];f(v.organization.id)}s(!1)},500)};return e.jsx(ue,{children:e.jsx(_e,{isOpen:t,onClose:r,children:e.jsx(_e.Overlay,{children:e.jsx(_e.Content,{style:{width:"900px",maxWidth:"90vw"},children:e.jsx(_e.Body,{style:{padding:0},children:a?e.jsx(ln,{onSuccess:m,onCancel:()=>s(!1)}):e.jsx(Aa,{organizationId:p||n,onSuccess:l,onCancel:r,onCreateOrganization:u})})})})})})},c0=h.div`
|
|
3164
3164
|
position: fixed;
|
|
3165
3165
|
width: 360px;
|
|
3166
3166
|
max-width: calc(100vw - 48px);
|
|
@@ -3209,7 +3209,7 @@ cursor: pointer;
|
|
|
3209
3209
|
color: var(--color-foreground);
|
|
3210
3210
|
background: var(--color-input-background);
|
|
3211
3211
|
}
|
|
3212
|
-
`,f0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:a})=>{const s=i.useRef(null),[p,f]=i.useState(""),[c,d]=i.useState(null),[l,u]=i.useState(!1),[m,v]=i.useState(!1),[x,y]=i.useState({top:0,left:0}),{toast:
|
|
3212
|
+
`,f0=({onClose:t,onSuccess:r,roles:o,createInvitation:n,triggerRef:a})=>{const s=i.useRef(null),[p,f]=i.useState(""),[c,d]=i.useState(null),[l,u]=i.useState(!1),[m,v]=i.useState(!1),[x,y]=i.useState({top:0,left:0}),{toast:k}=Ze(),z=o.map($=>({value:$.id,label:$.name}));i.useEffect(()=>{v(!0);const $=setTimeout(()=>{if(!s.current||!(a!=null&&a.current))return;const C=a.current;if(C){const E=C.getBoundingClientRect(),j=360,T=250,I=8;let O=0,P=0;const M=window.innerHeight-E.bottom,F=E.top;M>=T+I?(O=E.bottom+I,P=E.right-j,P<I&&(P=E.left,P+j>window.innerWidth-I&&(P=(window.innerWidth-j)/2))):F>=T+I?(O=E.top-T-I,P=E.right-j,P<I&&(P=E.left,P+j>window.innerWidth-I&&(P=(window.innerWidth-j)/2))):(O=E.bottom+I,P=E.right-j,P<I&&(P=E.left)),y({top:O,left:P})}},10),w=C=>{s.current&&!s.current.contains(C.target)&&(t==null||t())},b=C=>{C.key==="Escape"&&(t==null||t())},g=setTimeout(()=>{document.addEventListener("mousedown",w),document.addEventListener("keydown",b)},100);return()=>{clearTimeout($),clearTimeout(g),document.removeEventListener("mousedown",w),document.removeEventListener("keydown",b)}},[t,a]);const S=$=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test($),_=async()=>{const $=p.trim().toLowerCase();if(!(!$||!c)){if(!S($)){k("Please enter a valid email address","error");return}if($.length>320){k("Email address is too long","error");return}u(!0);try{await n($,c.id),r==null||r()}catch(w){const b=w.message||"Failed to send invitation. Please try again.";k(b,"error")}finally{u(!1)}}};return m?e.jsxs(c0,{ref:s,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:$=>$.stopPropagation(),role:"dialog","aria-labelledby":"invite-workspace-member-title","aria-modal":"true",children:[e.jsxs(l0,{children:[e.jsx(d0,{id:"invite-workspace-member-title",children:"Invite Member"}),e.jsx(h0,{onClick:t,"aria-label":"Close invite member dialog",children:e.jsx(Et,{size:16})})]}),e.jsx(u0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"Email Address"}),e.jsx(J,{type:"email",placeholder:"colleague@company.com",value:p,onChange:$=>f($.target.value),autoFocus:!0,"aria-label":"Email address for workspace invitation","aria-describedby":"workspace-email-help"})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Role"}),e.jsx(Ta,{options:z,value:c==null?void 0:c.id,onChange:$=>d(o.find(w=>w.id===$)),placeholder:"Select a role","aria-label":"Select role for invited workspace member"})]})]})}),e.jsxs(p0,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(V,{onClick:_,disabled:!p||!c||l,style:{width:"auto"},children:l?e.jsxs(e.Fragment,{children:[e.jsx($e,{size:14})," Sending..."]}):"Send Invitation"})]})]}):null},g0=h.div`
|
|
3213
3213
|
position: fixed;
|
|
3214
3214
|
width: 360px;
|
|
3215
3215
|
max-width: calc(100vw - 48px);
|
|
@@ -3258,7 +3258,7 @@ cursor: pointer;
|
|
|
3258
3258
|
color: var(--color-foreground);
|
|
3259
3259
|
background: var(--color-input-background);
|
|
3260
3260
|
}
|
|
3261
|
-
`,xi=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var $;const a=i.useRef(null),[s,p]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]),[d,l]=i.useState(!1),{deployment:u}=xe(),[m,v]=i.useState(!1),[x,y]=i.useState({top:0,left:0}),{toast:
|
|
3261
|
+
`,xi=({onClose:t,onSuccess:r,role:o,triggerRef:n})=>{var $;const a=i.useRef(null),[s,p]=i.useState((o==null?void 0:o.name)||""),[f,c]=i.useState((o==null?void 0:o.permissions)||[]),[d,l]=i.useState(!1),{deployment:u}=xe(),[m,v]=i.useState(!1),[x,y]=i.useState({top:0,left:0}),{toast:k}=Ze(),z=!!o,S=((($=u==null?void 0:u.b2b_settings)==null?void 0:$.workspace_permissions)||[]).map(w=>({value:w,label:w}));i.useEffect(()=>{v(!0);const w=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const E=n.current;if(E){const j=E.getBoundingClientRect(),T=360,I=250,O=8;let P=0,M=0;const F=window.innerHeight-j.bottom,D=j.top;F>=I+O?(P=j.bottom+O,M=j.right-T,M<O&&(M=j.left,M+T>window.innerWidth-O&&(M=(window.innerWidth-T)/2))):D>=I+O?(P=j.top-I-O,M=j.right-T,M<O&&(M=j.left,M+T>window.innerWidth-O&&(M=(window.innerWidth-T)/2))):(P=j.bottom+O,M=j.right-T,M<O&&(M=j.left)),y({top:P,left:M})}},10),b=E=>{a.current&&!a.current.contains(E.target)&&(t==null||t())},g=E=>{E.key==="Escape"&&(t==null||t())},C=setTimeout(()=>{document.addEventListener("mousedown",b),document.addEventListener("keydown",g)},100);return()=>{clearTimeout(w),clearTimeout(C),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",g)}},[t,n]);const _=async()=>{if(s.trim()){l(!0);try{const w={id:o==null?void 0:o.id,name:s.trim(),permissions:f};r==null||r(w)}catch(w){const b=w.message||"Failed to save role. Please try again.";k(b,"error")}finally{l(!1)}}};return m?e.jsxs(g0,{ref:a,style:{top:`${x.top}px`,left:`${x.left}px`,visibility:x.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:[e.jsxs(m0,{children:[e.jsx(x0,{children:z?"Edit Role":"Add Role"}),e.jsx(b0,{onClick:t,children:e.jsx(Et,{size:16})})]}),e.jsx(v0,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-sm)"},children:[e.jsxs(ie,{children:[e.jsx(oe,{children:"Role Name"}),e.jsx(J,{type:"text",value:s,onChange:w=>p(w.target.value),placeholder:"Enter role name",autoFocus:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{children:"Permissions"}),e.jsx(zl,{options:S,value:f,onChange:c,placeholder:"Select permissions"})]})]})}),e.jsxs(y0,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto"},children:"Cancel"}),e.jsx(V,{onClick:_,disabled:!s.trim()||d,style:{width:"auto"},children:d?"Saving...":z?"Update":"Create"})]})]}):null},w0=h.div`
|
|
3262
3262
|
* {
|
|
3263
3263
|
box-sizing: border-box;
|
|
3264
3264
|
font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
|
|
@@ -3394,11 +3394,11 @@ cursor: pointer;
|
|
|
3394
3394
|
opacity: 0.5;
|
|
3395
3395
|
cursor: not-allowed;
|
|
3396
3396
|
}
|
|
3397
|
-
`,S0=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,inviteMember:a,discardInvitation:s,resendInvitation:p}=Dt(),{toast:f}=Ze(),[c,d]=i.useState(!0),[l,u]=i.useState(!0),[m,v]=i.useState(""),[x,y]=i.useState([]),[
|
|
3398
|
-
`))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})});const I=U=>{var ne;if((ne=U.target.files)!=null&&ne[0]){const K=U.target.files[0];v(K),y(URL.createObjectURL(K)),setTimeout(()=>P(),100)}},O=()=>{j.current&&j.current.click()},P=i.useCallback(async()=>{if(!(!t||
|
|
3397
|
+
`,S0=()=>{const{activeWorkspace:t,loading:r,getRoles:o,getInvitations:n,inviteMember:a,discardInvitation:s,resendInvitation:p}=Dt(),{toast:f}=Ze(),[c,d]=i.useState(!0),[l,u]=i.useState(!0),[m,v]=i.useState(""),[x,y]=i.useState([]),[k,z]=i.useState([]),[S,_]=i.useState(!1),$=i.useRef(null);i.useEffect(()=>{if(!t)return;(async()=>{d(!0),u(!0);try{const[j,T]=await Promise.all([o(),n()]);z(j),y(T)}catch{}finally{d(!1),u(!1)}})()},[t==null?void 0:t.id]);const w=async E=>{try{await s(E.id);const j=await n();y(j)}catch{}},b=async E=>{try{await p(E.id);const j=await n();y(j),f("Invitation resent successfully","info")}catch{}},g=async()=>{_(!1);const E=await n();y(E),f("Invitation sent successfully","info")},C=i.useMemo(()=>m?x.filter(E=>(E.email||"").toLowerCase().includes(m.toLowerCase())):x,[x,m]);return r||c||l?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(La,{children:[e.jsx(Pt,{value:m,onChange:v,placeholder:"Search Invitation"}),e.jsxs("div",{children:[e.jsx(V,{ref:$,onClick:()=>_(!S),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Invite Members"}),S&&e.jsx(f0,{onClose:()=>_(!1),onSuccess:g,roles:k,createInvitation:a,triggerRef:$})]})]}),e.jsx("div",{children:C.length===0?e.jsx(dt,{title:m?"No invitations match your search":"No pending invitations",description:"Invite new members to your workspace."}):e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Email"}),e.jsx(ke,{children:"Role"}),e.jsx(ke,{children:"Invited"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:C.map(E=>{var j,T;return e.jsxs(Ve,{children:[e.jsx(De,{children:E.email}),e.jsx(De,{children:((j=E.initial_workspace_role)==null?void 0:j.name)||((T=E.initial_organization_role)==null?void 0:T.name)||"No role"}),e.jsx(De,{children:new Date(E.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(yt,{children:e.jsx("div",{style:{position:"relative"},children:e.jsxs(it,{children:[e.jsx(lt,{children:e.jsx(Gl,{children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Le,{onClick:()=>b(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(dl,{size:16,color:"var(--color-muted)"}),e.jsx("span",{children:"Resend Invitation"})]})}),e.jsx(Le,{$destructive:!0,onClick:()=>w(E),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ra,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Cancel Invitation"})]})})]})]})})})]},E.id)})})]})})]})},z0=()=>{const{activeWorkspace:t,loading:r,getMembers:o,getRoles:n,removeMember:a,addMemberRole:s,removeMemberRole:p}=Dt(),{session:f}=He(),{toast:c}=Ze(),[d,l]=i.useState(""),{data:u=[],isLoading:m,mutate:v}=Ue(t?`wacht-api-workspaces:${t.id}:members`:null,()=>o()||[]),{data:x=[],isLoading:y}=Ue(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>n()||[]),k=x,z=i.useMemo(()=>d?u.filter(b=>{var I;const g=b.public_user_data;if(!g)return!1;const C=g.first_name||"",E=g.last_name||"",j=((I=g.primary_email_address)==null?void 0:I.email)||"";return`${C} ${E}`.trim().toLowerCase().includes(d.toLowerCase())||j.toLowerCase().includes(d.toLowerCase())}):u,[u,d]),S=async b=>{try{await a(b),c("Member removed successfully","info"),v()}catch{c("Failed to remove member","error")}},_=async(b,g,C)=>{try{C?(await p(b,g),c("Role removed successfully","info")):(await s(b,g),c("Role added successfully","info")),v()}catch{c("Failed to toggle role","error"),c("Failed to update role","error")}},$=(b="",g="")=>`${b[0]||""}${g[0]||""}`.toUpperCase(),w=(b,g)=>{var C;return((C=b.roles)==null?void 0:C.some(E=>E.id===g))||!1};return r||m||y?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsx(La,{children:e.jsx(Pt,{value:d,onChange:l,placeholder:"Search members..."})}),z.length===0?e.jsx(dt,{title:d?"No members match your search":"No members yet",description:"Invite members to your workspace to get started."}):e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Member"}),e.jsx(ke,{children:"Joined"}),e.jsx(ke,{children:"Role"})]})}),e.jsx(vt,{children:z.map(b=>{var j,T;const g=b.public_user_data,C=b.roles||[],E=(g==null?void 0:g.id)===((j=f==null?void 0:f.active_signin)==null?void 0:j.user_id);return e.jsxs(Ve,{children:[e.jsx(Fl,{children:e.jsxs("div",{children:[e.jsx(C0,{children:g&&g.profile_picture_url?e.jsx("img",{src:g.profile_picture_url,alt:`${g.first_name||""} ${g.last_name||""}`,style:{width:"100%",height:"100%",objectFit:"cover"}}):$(g==null?void 0:g.first_name,g==null?void 0:g.last_name)||"?"}),e.jsxs("div",{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:(()=>{var O;if(!g)return"Unknown User";const I=`${g.first_name||""} ${g.last_name||""}`.trim();return I||((O=g.primary_email_address)==null?void 0:O.email)||"Unknown User"})()}),E&&e.jsx("span",{style:{fontSize:"12px",padding:"2px 8px",background:"var(--color-background-alt)",borderRadius:"4px",color:"var(--color-secondary-text)"},children:"You"})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:(T=g==null?void 0:g.primary_email_address)==null?void 0:T.email})]})]})}),e.jsx(De,{children:new Date(b.created_at).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}),e.jsx(yt,{children:e.jsxs(it,{children:[e.jsx(lt,{children:e.jsxs(V,{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:C.length>0?C[0].name:"No role"}),e.jsx(At,{size:14})]})}),e.jsxs(ct,{children:[k.map(I=>{const O=w(b,I.id);return e.jsx(Le,{onClick:()=>_(b.id,I.id,O),children:e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",width:"100%"},children:[e.jsx("span",{children:I.name}),O&&e.jsx(Qe,{size:16,color:"var(--color-success)"})]})},I.id)}),e.jsx(cn,{}),e.jsx(Le,{$destructive:!0,onClick:()=>S(b.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ra,{size:16,color:"var(--color-error)"}),e.jsx("span",{children:"Remove Member"})]})})]})]})})]},b.id)})})]})]})},E0=()=>{var B,G;const{activeWorkspace:t,loading:r,updateWorkspace:o}=Dt(),{deleteWorkspace:n}=Lt(),{deployment:a}=xe(),{toast:s}=Ze(),[p,f]=i.useState((t==null?void 0:t.name)||""),[c,d]=i.useState((t==null?void 0:t.description)||""),[l,u]=i.useState({mfa_required:!1,ip_restrictions:!1,allowed_ips:""}),[m,v]=i.useState(null),[x,y]=i.useState((t==null?void 0:t.image_url)||null),[k,z]=i.useState(!1),[S,_]=i.useState(!1),[$,w]=i.useState(""),[b,g]=i.useState(!1),[C,E]=i.useState(!1),j=i.useRef(null),T=i.useRef(null);if(i.useEffect(()=>{var U;t&&(f(t.name||""),d(t.description||""),y(t.image_url||null),u({mfa_required:t.enforce_2fa||!1,ip_restrictions:t.enable_ip_restriction||!1,allowed_ips:((U=t.whitelisted_ips)==null?void 0:U.join(`
|
|
3398
|
+
`))||""}))},[t]),r||!t)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})});const I=U=>{var ne;if((ne=U.target.files)!=null&&ne[0]){const K=U.target.files[0];v(K),y(URL.createObjectURL(K)),setTimeout(()=>P(),100)}},O=()=>{j.current&&j.current.click()},P=i.useCallback(async()=>{if(!(!t||S))try{_(!0);const U={};m&&(U.image=m,v(null)),p!==t.name&&(U.name=p),c!==t.description&&(U.description=c),l.mfa_required!==t.enforce_2fa&&(U.enforce_2fa=l.mfa_required),l.ip_restrictions!==t.enable_ip_restriction&&(U.enable_ip_restriction=l.ip_restrictions);const ne=(t.whitelisted_ips||[]).join(`
|
|
3399
3399
|
`);l.allowed_ips!==ne&&(U.whitelisted_ips=l.allowed_ips.split(`
|
|
3400
|
-
`).map(K=>K.trim()).filter(K=>K!=="")),Object.keys(U).length>0&&(await o(U),
|
|
3401
|
-
10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:C?"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(V,{onClick:()=>{C?(E(!1),w("")):E(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:C?"Cancel":"Delete"})]}),C&&e.jsxs("div",{children:[e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(J,{id:"confirm_workspace_name",type:"text",value:$,onChange:U=>w(U.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(V,{onClick:A,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($e,{size:12}):"Delete Forever"})]})]})]})]}),
|
|
3400
|
+
`).map(K=>K.trim()).filter(K=>K!=="")),Object.keys(U).length>0&&(await o(U),z(!0),setTimeout(()=>z(!1),3e3))}catch{s("Failed to auto-save workspace","error")}finally{_(!1)}},[t,o,p,c,m,l,S]),M=i.useCallback(()=>{T.current&&clearTimeout(T.current),T.current=setTimeout(()=>{P()},1e3)},[P]),F=U=>{f(U.target.value),M()},D=U=>{d(U.target.value),M()},L=()=>{T.current&&clearTimeout(T.current),P()},R=()=>{T.current&&clearTimeout(T.current),P()},A=async()=>{if(!(!t||$!==t.name))try{g(!0),await n(t),s("Workspace deleted successfully","info")}catch(U){s(U.message||"Failed to delete workspace","error")}finally{g(!1),w(""),E(!1)}};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:x?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:O,onMouseEnter:U=>{U.currentTarget.style.borderColor="var(--color-primary)",U.currentTarget.style.transform="scale(1.02)"},onMouseLeave:U=>{U.currentTarget.style.borderColor="var(--color-border)",U.currentTarget.style.transform="scale(1)"},children:[x?e.jsx("img",{src:x,alt:"Workspace Logo",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(qr,{size:32,color:"var(--color-muted)"}),e.jsx("input",{type:"file",ref:j,style:{display:"none"},accept:"image/*",onChange:I})]})}),e.jsxs("div",{style:{flex:1},children:[e.jsxs("div",{style:{marginBottom:"var(--space-lg)"},children:[e.jsx("h3",{style:{fontSize:"var(--font-sm)",color:"var(--color-foreground)",margin:"0 0 var(--space-2xs) 0"},children:"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(V,{onClick:()=>{var U;return(U=j.current)==null?void 0:U.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(qr,{size:14}),x?"Change":"Upload"]}),e.jsxs(V,{onClick:()=>{y(null),v(null),j.current&&(j.current.value=""),setTimeout(()=>P(),100)},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(Ra,{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(ie,{children:[e.jsx(oe,{htmlFor:"name",children:"Workspace Name"}),e.jsx(J,{id:"name",type:"text",value:p,onChange:F,onBlur:L,placeholder:"Enter workspace name",required:!0})]}),e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"description",children:"Description"}),e.jsx(J,{id:"description",as:"textarea",value:c,onChange:D,onBlur:R,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"})]}),((B=a==null?void 0:a.b2b_settings)==null?void 0:B.enforce_mfa_per_workspace_enabled)&&e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(oe,{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(dr,{checked:l.mfa_required,onChange:()=>{u(U=>({...U,mfa_required:!U.mfa_required})),setTimeout(()=>P(),100)}})]}),((G=a==null?void 0:a.b2b_settings)==null?void 0:G.ip_allowlist_per_workspace_enabled)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[e.jsxs("div",{children:[e.jsx(oe,{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(dr,{checked:l.ip_restrictions,onChange:()=>{u(U=>({...U,ip_restrictions:!U.ip_restrictions})),setTimeout(()=>P(),100)},"aria-label":"Enable IP address restrictions","aria-describedby":"ip-restrictions-description"})]}),l.ip_restrictions&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"allowed_ips",children:"Allowed IP Addresses"}),e.jsx(J,{id:"allowed_ips",as:"textarea",value:l.allowed_ips,onChange:U=>u(ne=>({...ne,allowed_ips:U.target.value})),onBlur:P,placeholder:`192.168.1.1
|
|
3401
|
+
10.0.0.0/24`,style:{minHeight:"80px",resize:"vertical",fontFamily:"monospace"}}),e.jsx("p",{style:{fontSize:"var(--font-2xs)",color:"var(--color-muted)",margin:"var(--space-2xs) 0 0 0"},children:"Enter one IP address or CIDR block per line"})]})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:C?"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(V,{onClick:()=>{C?(E(!1),w("")):E(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:C?"Cancel":"Delete"})]}),C&&e.jsxs("div",{children:[e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"confirm_workspace_name",children:"Confirm by typing the workspace name"}),e.jsx(J,{id:"confirm_workspace_name",type:"text",value:$,onChange:U=>w(U.target.value),placeholder:`Type "${t==null?void 0:t.name}" to confirm`})]}),e.jsx(V,{onClick:A,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($e,{size:12}):"Delete Forever"})]})]})]})]}),k&&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:`
|
|
3402
3402
|
@keyframes slideUp {
|
|
3403
3403
|
from {
|
|
3404
3404
|
opacity: 0;
|
|
@@ -3409,7 +3409,7 @@ cursor: pointer;
|
|
|
3409
3409
|
transform: translateX(-50%) translateY(0);
|
|
3410
3410
|
}
|
|
3411
3411
|
}
|
|
3412
|
-
`})]})},$0=()=>{var g;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:a}=Dt(),{toast:s}=Ze(),{deployment:p}=xe(),[f,c]=i.useState(""),[d,l]=i.useState({isOpen:!1}),[u,m]=i.useState(null),[v,x]=i.useState(null),y=i.useRef(null),
|
|
3412
|
+
`})]})},$0=()=>{var g;const{activeWorkspace:t,loading:r,getRoles:o,createRole:n,deleteRole:a}=Dt(),{toast:s}=Ze(),{deployment:p}=xe(),[f,c]=i.useState(""),[d,l]=i.useState({isOpen:!1}),[u,m]=i.useState(null),[v,x]=i.useState(null),y=i.useRef(null),k=i.useRef(new Map),{data:z=[],isLoading:S,mutate:_}=Ue(t?`wacht-api-workspaces:${t.id}:roles`:null,()=>o()||[]),$=i.useMemo(()=>f?z.filter(C=>C.name.toLowerCase().includes(f.toLowerCase())):z,[z,f]),w=async C=>{try{await n(C.name,C.permissions||[]),s("Role created successfully","info"),l({isOpen:!1}),_()}catch{s("Failed to save role","error"),s("Failed to create role","error")}},b=async C=>{try{await a(C),s("Role deleted successfully","info"),x(null),_()}catch{s("Failed to delete role","error"),s("Failed to delete role","error")}};return r||S?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs(La,{children:[e.jsx(Pt,{placeholder:"Search roles",onChange:c,value:f}),e.jsxs("div",{style:{position:"relative"},children:[((g=p==null?void 0:p.b2b_settings)==null?void 0:g.custom_workspace_role_enabled)&&e.jsx(V,{ref:y,onClick:()=>l({isOpen:!0,triggerElement:y.current}),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add role"}),d.isOpen&&!d.role&&e.jsx(xi,{role:d.role,triggerRef:{current:d.triggerElement||null},onClose:()=>l({isOpen:!1}),onSuccess:w})]})]}),$.length===0?e.jsx(dt,{title:f?"No roles match your search":"No roles available",description:f?"Try adjusting your search query":"Contact your administrator to set up workspace roles."}):e.jsx("div",{style:{position:"relative",overflowX:"auto",overflowY:"visible"},children:e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Role"}),e.jsx(ke,{children:"Permissions"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:$.map(C=>{var E;return e.jsxs(Ve,{children:[e.jsx(De,{children:e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:C.name})}),e.jsx(De,{style:{color:"var(--color-secondary-text)"},children:C.permissions&&C.permissions.length>0?C.permissions.join(", "):""}),e.jsx(yt,{children:e.jsxs("div",{style:{display:"flex",gap:"10px",alignItems:"center",justifyContent:"flex-end",position:"relative"},children:[e.jsxs(it,{open:u===C.id,openChange:j=>m(j?C.id:null),children:[e.jsx(lt,{children:e.jsx(Gl,{ref:j=>{j&&k.current.set(C.id,j)},disabled:!C.workspace_id,"data-role-dropdown-trigger":C.id,children:"•••"})}),e.jsxs(ct,{children:[e.jsx(Le,{onClick:()=>{m(null);const j=k.current.get(C.id);l({isOpen:!0,role:C,triggerElement:j||null})},children:"Edit Role"}),e.jsx(Le,{$destructive:!0,onClick:()=>{m(null),x(C.id)},children:"Remove Role"})]})]}),v===C.id&&e.jsx(Er,{title:"Are you sure you want to delete this role?",onConfirm:()=>b(C),onCancel:()=>x(null)}),d.isOpen&&((E=d.role)==null?void 0:E.id)===C.id&&e.jsx(xi,{role:d.role,triggerRef:{current:d.triggerElement||null},onClose:()=>{l({isOpen:!1}),m(null)},onSuccess:w})]})})]},C.id)})})]})})]})},Hl=()=>{const{activeWorkspace:t,loading:r}=Dt(),[o,n]=i.useState("general"),[a,s]=i.useState(null),[p,f]=i.useState("info"),c=i.useCallback((d,l="info")=>{s(d),f(l),setTimeout(()=>s(null),3e3)},[]);return r?e.jsx(vi,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx($e,{})}):t?e.jsx(Oa.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsx(w0,{children:e.jsxs(vi,{children:[e.jsx(j0,{children:e.jsxs(_0,{children:[e.jsx(wo,{$isActive:o==="general",onClick:()=>n("general"),children:e.jsxs(jo,{children:[e.jsx(ir,{size:16}),"General"]})}),e.jsx(wo,{$isActive:o==="members",onClick:()=>n("members"),children:e.jsxs(jo,{children:[e.jsx(Go,{size:16}),"Members"]})}),e.jsx(wo,{$isActive:o==="invitations",onClick:()=>n("invitations"),children:e.jsxs(jo,{children:[e.jsx(dl,{size:16}),"Invitations"]})}),e.jsx(wo,{$isActive:o==="roles",onClick:()=>n("roles"),children:e.jsxs(jo,{children:[e.jsx(at,{size:16}),"Roles"]})})]})}),e.jsxs(k0,{children:[o==="general"&&e.jsx(E0,{}),o==="members"&&e.jsx(z0,{}),o==="invitations"&&e.jsx(S0,{}),o==="roles"&&e.jsx($0,{})]}),a&&e.jsx("div",{style:{position:"absolute",bottom:"20px",right:"20px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",padding:"12px 16px",borderRadius:"8px",boxShadow:"0 4px 12px var(--color-shadow)",zIndex:50,animation:"slideUp 0.3s ease-out"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[p==="error"?e.jsx(ft,{size:16,color:"var(--color-error)"}):e.jsx(Qe,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})}):null},ql=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:f,showCloseButton:c})=>e.jsx(_e,{isOpen:t,onClose:r,children:e.jsx(_e.Overlay,{children:e.jsxs(_e.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(_e.Header,{showCloseButton:c,children:a||o}),p||f||e.jsx(Hl,{}),s&&e.jsx(_e.Footer,{children:s})]})})}),Yl=({triggerRef:t,isOpen:r,minWidth:o=300,defaultMaxHeight:n=400,offset:a=8})=>{const[s,p]=i.useState();return i.useEffect(()=>{if(!r||!t.current){p(void 0);return}const f=()=>{if(!t.current)return;const c=t.current.getBoundingClientRect(),d=window.innerWidth,l=window.innerHeight,u=d-c.left,m=c.right,v=l-c.bottom,x=c.top;let y={};u>=o?y.left=c.left:m>=o?y.left=c.right-o:y.left=Math.max(a,Math.min(d-o-a,c.left)),v>=150?(y.top=c.bottom+a,y.maxHeight=Math.min(n,v-a*2)):x>=150?(y.bottom=l-c.top+a,y.maxHeight=Math.min(n,x-a*2)):(y.top=c.bottom+a,y.maxHeight=Math.max(100,v-a*2)),p(y)};return f(),window.addEventListener("resize",f),window.addEventListener("scroll",f,!0),()=>{window.removeEventListener("resize",f),window.removeEventListener("scroll",f,!0)}},[r,o,n,a]),s},Zl=["organization:admin"],Kl=["organization:admin","organization:manage"],Ql=["workspace:admin"],Jl=["workspace:admin","workspace:manage"];function Da(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(a=>r.includes(a))}):!1}function Xl(t){return Da(t,Kl)}function P0(t){return Da(t,Zl)}function Fa(t,r){return t!=null&&t.roles?t.roles.some(o=>{var n;return(n=o.permissions)==null?void 0:n.some(a=>r.includes(a))}):!1}function va(t){return Fa(t,Jl)}function R0(t){return Fa(t,Ql)}const yi=h.div`
|
|
3413
3413
|
position: relative;
|
|
3414
3414
|
display: inline-block;
|
|
3415
3415
|
width: 100%;
|
|
@@ -3760,15 +3760,15 @@ cursor: pointer;
|
|
|
3760
3760
|
height: 16px;
|
|
3761
3761
|
background: var(--color-border);
|
|
3762
3762
|
border-radius: 2px;
|
|
3763
|
-
`,ed=({showPersonal:t=!0})=>{var Z,X,ee,te;const[r,o]=i.useState(!1),[n,a]=i.useState(!1),[s,p]=i.useState(new Set),f=i.useRef(null),c=i.useRef(null),d=Yl({triggerRef:f,isOpen:r,minWidth:300}),l=Wr(!1),u=Wr(!1),m=Wr(!1),v=Wr(!1),[x,y]=i.useState(null),[
|
|
3763
|
+
`,ed=({showPersonal:t=!0})=>{var Z,X,ee,te;const[r,o]=i.useState(!1),[n,a]=i.useState(!1),[s,p]=i.useState(new Set),f=i.useRef(null),c=i.useRef(null),d=Yl({triggerRef:f,isOpen:r,minWidth:300}),l=Wr(!1),u=Wr(!1),m=Wr(!1),v=Wr(!1),[x,y]=i.useState(null),[k,z]=i.useState(!1),[S,_]=i.useState(null),{organizationMemberships:$,loading:w,refetch:b}=$t(),{activeOrganization:g,activeMembership:C,leave:E}=tt(),{activeWorkspace:j,activeMembership:T,leave:I}=Dt(),{workspaces:O,loading:P}=Lt(),{session:M,loading:F,switchOrganization:D,switchWorkspace:L}=He(),{deployment:R}=xe(),{toast:A}=Ze(),B=R==null?void 0:R.b2b_settings.organizations_enabled,G=R==null?void 0:R.b2b_settings.workspaces_enabled,U=R==null?void 0:R.b2b_settings.allow_users_to_create_orgs,ne=!((Z=M==null?void 0:M.active_signin)!=null&&Z.active_organization_membership_id),K=i.useMemo(()=>{var Y,se;if(ne)return{name:"Personal account",image_url:(se=(Y=M==null?void 0:M.active_signin)==null?void 0:Y.user)==null?void 0:se.profile_picture_url,isPersonal:!0};let W=(g==null?void 0:g.name)||"";return G&&j&&(W=`${g==null?void 0:g.name} / ${j.name}`),{name:W,image_url:g==null?void 0:g.image_url,isPersonal:!1}},[ne,g,j,M,G]);i.useEffect(()=>{if(!r)return;let W=null;const Y=setTimeout(()=>{const se=le=>{var me,H;const q=le.target;(me=f.current)!=null&&me.contains(q)||(H=c.current)!=null&&H.contains(q)||(o(!1),_(null))};document.addEventListener("mousedown",se),W=()=>{document.removeEventListener("mousedown",se)}},50);return()=>{clearTimeout(Y),W==null||W()}},[r]),i.useEffect(()=>{if(S){const W=setTimeout(()=>{_(null)},5e3);return()=>clearTimeout(W)}},[S]);const ge=()=>{b()};if(!B)return null;const pe=W=>{a(!0),D(W).finally(()=>{a(!1)})},ae=W=>{a(!0),L(W).finally(()=>{a(!1)})},he=W=>{const Y=new Set(s);Y.has(W)?Y.delete(W):Y.add(W),p(Y)},Q=W=>W.split(" ").map(Y=>Y[0]).join("").toUpperCase().slice(0,2),Se=!!((X=M==null?void 0:M.active_signin)!=null&&X.active_organization_membership_id);return w||F||!$&&Se?e.jsx(ue,{children:e.jsx(yi,{children:e.jsxs(B0,{children:[e.jsxs(bi,{children:[e.jsx(U0,{}),e.jsx(W0,{})]}),e.jsx(V0,{})]})})}):e.jsx(ue,{children:e.jsxs(yi,{children:[e.jsxs(I0,{ref:f,onClick:()=>{o(!r),r||_(null)},disabled:n,children:[e.jsxs(bi,{children:[e.jsx(T0,{children:K.image_url?e.jsx(O0,{src:K.image_url,alt:K.name}):K.isPersonal?e.jsx(Vo,{size:12}):Q(K.name)}),e.jsx(M0,{children:K.name})]}),e.jsx(lh,{size:16})]}),typeof window<"u"&&Ko.createPortal(e.jsx(ue,{children:e.jsx(A0,{ref:c,$isOpen:r,$position:d,children:w||P?e.jsxs(N0,{children:[e.jsxs(zo,{children:[e.jsx(Eo,{}),e.jsxs($o,{children:[e.jsx(Po,{width:"120px"}),e.jsx(Si,{width:"80px"})]})]}),e.jsx(vr,{}),e.jsxs(zo,{children:[e.jsx(Eo,{}),e.jsx($o,{children:e.jsx(Po,{width:"100px"})})]}),e.jsx(vr,{}),e.jsxs(zo,{children:[e.jsx(Eo,{}),e.jsxs($o,{children:[e.jsx(Po,{width:"140px"}),e.jsx(Si,{width:"60px"})]})]}),e.jsx(vr,{}),e.jsxs(zo,{children:[e.jsx(Eo,{}),e.jsx($o,{children:e.jsx(Po,{width:"110px"})})]})]}):e.jsxs("div",{children:[t&&e.jsxs(e.Fragment,{children:[e.jsxs(Fo,{as:"button",$isActive:ne,onClick:W=>{W.stopPropagation(),ne||pe()},disabled:n||ne,children:[ne&&e.jsx(Co,{}),e.jsxs(wt,{children:[e.jsx(L0,{children:(te=(ee=M==null?void 0:M.active_signin)==null?void 0:ee.user)!=null&&te.profile_picture_url?e.jsx(D0,{src:M.active_signin.user.profile_picture_url,alt:"Personal account"}):e.jsx(Vo,{size:12})}),e.jsx(jt,{children:e.jsx(_t,{children:"Personal account"})})]}),!ne&&e.jsx(_o,{className:"hover-arrow",size:14})]}),!ne&&g&&e.jsx(vr,{})]}),!ne&&g&&e.jsxs(Fo,{$isActive:!0,onClick:()=>{G&&he(g.id)},style:n?{pointerEvents:"none",opacity:.7}:void 0,children:[e.jsx(Co,{}),e.jsxs(wt,{children:[G&&e.jsx(At,{size:12,style:{marginRight:"4px",transform:s.has(g.id)?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(wi,{children:g.image_url?e.jsx(ji,{src:g.image_url,alt:g.name}):Q(g.name)}),e.jsx(jt,{children:e.jsx(_t,{children:g.name})})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[Xl(C)&&e.jsx(No,{onClick:W=>{W.stopPropagation(),u.open()},title:"Manage organization",children:e.jsx(ir,{size:12})}),e.jsx(Hn,{onClick:async W=>{W.stopPropagation(),z(!0),_(null);try{await E(),await b(),setTimeout(()=>{z(!1)},500)}catch(Y){_(Y instanceof Error?Y.message:"Failed to leave organization"),z(!1)}},disabled:k,title:"Leave organization",children:e.jsx(Ot,{size:12})})]})]}),g&&G&&s.has(g.id)&&e.jsxs(e.Fragment,{children:[O==null?void 0:O.filter(W=>W.organization.id===g.id).map(W=>{const Y=(j==null?void 0:j.id)===W.id;return e.jsxs(So,{as:Y?void 0:"button",$isActive:Y,onClick:Y?void 0:()=>ae(W.id),...Y?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[Y&&e.jsx(Co,{}),e.jsxs(wt,{children:[e.jsx(ki,{children:W.image_url?e.jsx("img",{src:W.image_url,alt:W.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(W.name).charAt(0)}),e.jsx(jt,{children:e.jsx(_t,{children:W.name})})]}),Y?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[va(T)&&e.jsx(No,{onClick:se=>{se.stopPropagation(),v.open()},title:"Manage workspace",children:e.jsx(ir,{size:12})}),e.jsx(Hn,{onClick:async se=>{se.stopPropagation();try{I&&await I()}catch(le){const q=le.message||"Failed to leave workspace. Please try again.";A(q,"error")}},title:"Leave workspace",children:e.jsx(Ot,{size:12})})]}):e.jsx(_o,{className:"hover-arrow",size:14})]},W.id)}),e.jsx(So,{as:"button",onClick:()=>{y(g.id),m.open()},disabled:n,children:e.jsxs(wt,{children:[e.jsx(ko,{style:{width:"14px",height:"14px"},children:e.jsx(rt,{size:12})}),e.jsx(jt,{children:e.jsx(_t,{children:"Create workspace"})})]})})]}),(k||S)&&e.jsxs(e.Fragment,{children:[k&&e.jsxs(Ci,{children:[e.jsx(F0,{}),"Leaving organization..."]}),S&&e.jsxs(Ci,{$isError:!0,children:[e.jsx("span",{children:"⚠️"}),S]})]}),e.jsx(vr,{}),$&&$.length>0&&e.jsx(e.Fragment,{children:$.filter(W=>W.organization.id!==(g==null?void 0:g.id)).map(W=>{const Y=W.organization,se=(O==null?void 0:O.filter(q=>q.organization.id===Y.id))||[],le=s.has(Y.id);return e.jsxs(i.Fragment,{children:[e.jsxs(Fo,{as:"button",$isActive:!1,onClick:()=>{G?he(Y.id):pe(Y.id)},disabled:n,children:[e.jsxs(wt,{children:[G&&e.jsx(At,{size:12,style:{marginRight:"4px",transform:le?"rotate(0deg)":"rotate(-90deg)",transition:"transform 0.2s ease",color:"var(--color-secondary-text)"}}),e.jsx(wi,{children:Y.image_url?e.jsx(ji,{src:Y.image_url,alt:Y.name}):Q(Y.name)}),e.jsx(jt,{children:e.jsx(_t,{children:Y.name})})]}),e.jsx(_o,{className:"hover-arrow",size:14})]}),G&&le&&e.jsxs(e.Fragment,{children:[se.map(q=>{const me=(j==null?void 0:j.id)===q.id;return e.jsxs(So,{as:me?void 0:"button",$isActive:me,onClick:me?void 0:()=>ae(q.id),...me?{style:n?{pointerEvents:"none",opacity:.7}:void 0}:{disabled:n},children:[me&&e.jsx(Co,{}),e.jsxs(wt,{children:[e.jsx(ki,{children:q.image_url?e.jsx("img",{src:q.image_url,alt:q.name,style:{width:"100%",height:"100%",objectFit:"cover"}}):Q(q.name).charAt(0)}),e.jsx(jt,{children:e.jsx(_t,{children:q.name})})]}),me?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[va(T)&&e.jsx(No,{onClick:H=>{H.stopPropagation(),v.open()},title:"Manage workspace",children:e.jsx(ir,{size:12})}),e.jsx(Hn,{onClick:async H=>{H.stopPropagation();try{I&&await I()}catch(we){const Te=we.message||"Failed to leave workspace. Please try again.";A(Te,"error")}},title:"Leave workspace",children:e.jsx(Ot,{size:12})})]}):e.jsx(_o,{className:"hover-arrow",size:16})]},q.id)}),e.jsx(So,{as:"button",onClick:()=>{y(Y.id),m.open()},disabled:n,children:e.jsxs(wt,{children:[e.jsx(ko,{style:{width:"14px",height:"14px"},children:e.jsx(rt,{size:10})}),e.jsx(jt,{children:e.jsx(_t,{children:"Create workspace"})})]})})]}),e.jsx(vr,{})]},Y.id)})}),G?g&&e.jsx(_i,{onClick:()=>{y(g.id),m.open()},disabled:n,children:e.jsxs(wt,{children:[e.jsx(ko,{children:e.jsx(rt,{size:12})}),e.jsx(jt,{children:e.jsx(_t,{children:"Create workspace"})})]})}):U&&e.jsx(_i,{onClick:()=>{l.open()},disabled:n,children:e.jsxs(wt,{children:[e.jsx(ko,{children:e.jsx(rt,{size:12})}),e.jsx(jt,{children:e.jsx(_t,{children:"Create organization"})})]})})]})})}),document.body),B&&U&&e.jsx(Km,{isOpen:l.isOpen,onClose:l.close,onCreated:ge}),e.jsx(Lx,{isOpen:u.isOpen,onClose:u.close}),e.jsx(ql,{isOpen:v.isOpen,onClose:v.close}),x&&e.jsx(Vl,{isOpen:m.isOpen,onClose:()=>{m.close(),y(null)},organizationId:x})]})})};var G0=Object.defineProperty,Yo=Object.getOwnPropertySymbols,td=Object.prototype.hasOwnProperty,rd=Object.prototype.propertyIsEnumerable,zi=(t,r,o)=>r in t?G0(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o,ya=(t,r)=>{for(var o in r||(r={}))td.call(r,o)&&zi(t,o,r[o]);if(Yo)for(var o of Yo(r))rd.call(r,o)&&zi(t,o,r[o]);return t},ba=(t,r)=>{var o={};for(var n in t)td.call(t,n)&&r.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&Yo)for(var n of Yo(t))r.indexOf(n)<0&&rd.call(t,n)&&(o[n]=t[n]);return o};/**
|
|
3764
3764
|
* @license QR Code generator library (TypeScript)
|
|
3765
3765
|
* Copyright (c) Project Nayuki.
|
|
3766
3766
|
* SPDX-License-Identifier: MIT
|
|
3767
|
-
*/var ur;(t=>{const r=class be{constructor(c,d,l,u){if(this.version=c,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],c<be.MIN_VERSION||c>be.MAX_VERSION)throw new RangeError("Version value out of range");if(u<-1||u>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let m=[];for(let x=0;x<this.size;x++)m.push(!1);for(let x=0;x<this.size;x++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(l);if(this.drawCodewords(v),u==-1){let x=1e9;for(let y=0;y<8;y++){this.applyMask(y),this.drawFormatBits(y);const S=this.getPenaltyScore();S<x&&(u=y,x=S),this.applyMask(y)}}a(0<=u&&u<=7),this.mask=u,this.applyMask(u),this.drawFormatBits(u),this.isFunction=[]}static encodeText(c,d){const l=t.QrSegment.makeSegments(c);return be.encodeSegments(l,d)}static encodeBinary(c,d){const l=t.QrSegment.makeBytes(c);return be.encodeSegments([l],d)}static encodeSegments(c,d,l=1,u=40,m=-1,v=!0){if(!(be.MIN_VERSION<=l&&l<=u&&u<=be.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let x,y;for(x=l;;x++){const _=be.getNumDataCodewords(x,d)*8,$=p.getTotalBits(c,x);if($<=_){y=$;break}if(x>=u)throw new RangeError("Data too long")}for(const _ of[be.Ecc.MEDIUM,be.Ecc.QUARTILE,be.Ecc.HIGH])v&&y<=be.getNumDataCodewords(x,_)*8&&(d=_);let S=[];for(const _ of c){o(_.mode.modeBits,4,S),o(_.numChars,_.mode.numCharCountBits(x),S);for(const $ of _.getData())S.push($)}a(S.length==y);const k=be.getNumDataCodewords(x,d)*8;a(S.length<=k),o(0,Math.min(4,k-S.length),S),o(0,(8-S.length%8)%8,S),a(S.length%8==0);for(let _=236;S.length<k;_^=253)o(_,8,S);let z=[];for(;z.length*8<S.length;)z.push(0);return S.forEach((_,$)=>z[$>>>3]|=_<<7-($&7)),new be(x,d,z,m)}getModule(c,d){return 0<=c&&c<this.size&&0<=d&&d<this.size&&this.modules[d][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),d=c.length;for(let l=0;l<d;l++)for(let u=0;u<d;u++)l==0&&u==0||l==0&&u==d-1||l==d-1&&u==0||this.drawAlignmentPattern(c[l],c[u]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const d=this.errorCorrectionLevel.formatBits<<3|c;let l=d;for(let m=0;m<10;m++)l=l<<1^(l>>>9)*1335;const u=(d<<10|l)^21522;a(u>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,n(u,m));this.setFunctionModule(8,7,n(u,6)),this.setFunctionModule(8,8,n(u,7)),this.setFunctionModule(7,8,n(u,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,n(u,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,n(u,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,n(u,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let l=0;l<12;l++)c=c<<1^(c>>>11)*7973;const d=this.version<<12|c;a(d>>>18==0);for(let l=0;l<18;l++){const u=n(d,l),m=this.size-11+l%3,v=Math.floor(l/3);this.setFunctionModule(m,v,u),this.setFunctionModule(v,m,u)}}drawFinderPattern(c,d){for(let l=-4;l<=4;l++)for(let u=-4;u<=4;u++){const m=Math.max(Math.abs(u),Math.abs(l)),v=c+u,x=d+l;0<=v&&v<this.size&&0<=x&&x<this.size&&this.setFunctionModule(v,x,m!=2&&m!=4)}}drawAlignmentPattern(c,d){for(let l=-2;l<=2;l++)for(let u=-2;u<=2;u++)this.setFunctionModule(c+u,d+l,Math.max(Math.abs(u),Math.abs(l))!=1)}setFunctionModule(c,d,l){this.modules[d][c]=l,this.isFunction[d][c]=!0}addEccAndInterleave(c){const d=this.version,l=this.errorCorrectionLevel;if(c.length!=be.getNumDataCodewords(d,l))throw new RangeError("Invalid argument");const u=be.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][d],m=be.ECC_CODEWORDS_PER_BLOCK[l.ordinal][d],v=Math.floor(be.getNumRawDataModules(d)/8),x=u-v%u,y=Math.floor(v/u);let S=[];const k=be.reedSolomonComputeDivisor(m);for(let _=0,$=0;_<u;_++){let w=c.slice($,$+y-m+(_<x?0:1));$+=w.length;const b=be.reedSolomonComputeRemainder(w,k);_<x&&w.push(0),S.push(w.concat(b))}let z=[];for(let _=0;_<S[0].length;_++)S.forEach(($,w)=>{(_!=y-m||w>=x)&&z.push($[_])});return a(z.length==v),z}drawCodewords(c){if(c.length!=Math.floor(be.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let u=0;u<this.size;u++)for(let m=0;m<2;m++){const v=l-m,y=(l+1&2)==0?this.size-1-u:u;!this.isFunction[y][v]&&d<c.length*8&&(this.modules[y][v]=n(c[d>>>3],7-(d&7)),d++)}}a(d==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let l=0;l<this.size;l++){let u;switch(c){case 0:u=(l+d)%2==0;break;case 1:u=d%2==0;break;case 2:u=l%3==0;break;case 3:u=(l+d)%3==0;break;case 4:u=(Math.floor(l/3)+Math.floor(d/2))%2==0;break;case 5:u=l*d%2+l*d%3==0;break;case 6:u=(l*d%2+l*d%3)%2==0;break;case 7:u=((l+d)%2+l*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][l]&&u&&(this.modules[d][l]=!this.modules[d][l])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let v=!1,x=0,y=[0,0,0,0,0,0,0];for(let S=0;S<this.size;S++)this.modules[m][S]==v?(x++,x==5?c+=be.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,y),v||(c+=this.finderPenaltyCountPatterns(y)*be.PENALTY_N3),v=this.modules[m][S],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,y)*be.PENALTY_N3}for(let m=0;m<this.size;m++){let v=!1,x=0,y=[0,0,0,0,0,0,0];for(let S=0;S<this.size;S++)this.modules[S][m]==v?(x++,x==5?c+=be.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,y),v||(c+=this.finderPenaltyCountPatterns(y)*be.PENALTY_N3),v=this.modules[S][m],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,y)*be.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let v=0;v<this.size-1;v++){const x=this.modules[m][v];x==this.modules[m][v+1]&&x==this.modules[m+1][v]&&x==this.modules[m+1][v+1]&&(c+=be.PENALTY_N2)}let d=0;for(const m of this.modules)d=m.reduce((v,x)=>v+(x?1:0),d);const l=this.size*this.size,u=Math.ceil(Math.abs(d*20-l*10)/l)-1;return a(0<=u&&u<=9),c+=u*be.PENALTY_N4,a(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let l=[6];for(let u=this.size-7;l.length<c;u-=d)l.splice(1,0,u);return l}}static getNumRawDataModules(c){if(c<be.MIN_VERSION||c>be.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;d-=(25*l-10)*l-55,c>=7&&(d-=36)}return a(208<=d&&d<=29648),d}static getNumDataCodewords(c,d){return Math.floor(be.getNumRawDataModules(c)/8)-be.ECC_CODEWORDS_PER_BLOCK[d.ordinal][c]*be.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let d=[];for(let u=0;u<c-1;u++)d.push(0);d.push(1);let l=1;for(let u=0;u<c;u++){for(let m=0;m<d.length;m++)d[m]=be.reedSolomonMultiply(d[m],l),m+1<d.length&&(d[m]^=d[m+1]);l=be.reedSolomonMultiply(l,2)}return d}static reedSolomonComputeRemainder(c,d){let l=d.map(u=>0);for(const u of c){const m=u^l.shift();l.push(0),d.forEach((v,x)=>l[x]^=be.reedSolomonMultiply(v,m))}return l}static reedSolomonMultiply(c,d){if(c>>>8||d>>>8)throw new RangeError("Byte out of range");let l=0;for(let u=7;u>=0;u--)l=l<<1^(l>>>7)*285,l^=(d>>>u&1)*c;return a(l>>>8==0),l}finderPenaltyCountPatterns(c){const d=c[1];a(d<=this.size*3);const l=d>0&&c[2]==d&&c[3]==d*3&&c[4]==d&&c[5]==d;return(l&&c[0]>=d*4&&c[6]>=d?1:0)+(l&&c[6]>=d*4&&c[0]>=d?1:0)}finderPenaltyTerminateAndCount(c,d,l){return c&&(this.finderPenaltyAddHistory(d,l),d=0),d+=this.size,this.finderPenaltyAddHistory(d,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(c,d){d[0]==0&&(c+=this.size),d.pop(),d.unshift(c)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function o(f,c,d){if(c<0||c>31||f>>>c)throw new RangeError("Value out of range");for(let l=c-1;l>=0;l--)d.push(f>>>l&1)}function n(f,c){return(f>>>c&1)!=0}function a(f){if(!f)throw new Error("Assertion error")}const s=class Fe{constructor(c,d,l){if(this.mode=c,this.numChars=d,this.bitData=l,d<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let d=[];for(const l of c)o(l,8,d);return new Fe(Fe.Mode.BYTE,c.length,d)}static makeNumeric(c){if(!Fe.isNumeric(c))throw new RangeError("String contains non-numeric characters");let d=[];for(let l=0;l<c.length;){const u=Math.min(c.length-l,3);o(parseInt(c.substring(l,l+u),10),u*3+1,d),l+=u}return new Fe(Fe.Mode.NUMERIC,c.length,d)}static makeAlphanumeric(c){if(!Fe.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],l;for(l=0;l+2<=c.length;l+=2){let u=Fe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;u+=Fe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),o(u,11,d)}return l<c.length&&o(Fe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,d),new Fe(Fe.Mode.ALPHANUMERIC,c.length,d)}static makeSegments(c){return c==""?[]:Fe.isNumeric(c)?[Fe.makeNumeric(c)]:Fe.isAlphanumeric(c)?[Fe.makeAlphanumeric(c)]:[Fe.makeBytes(Fe.toUtf8ByteArray(c))]}static makeEci(c){let d=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,d);else if(c<16384)o(2,2,d),o(c,14,d);else if(c<1e6)o(6,3,d),o(c,21,d);else throw new RangeError("ECI assignment value out of range");return new Fe(Fe.Mode.ECI,0,d)}static isNumeric(c){return Fe.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Fe.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,d){let l=0;for(const u of c){const m=u.mode.numCharCountBits(d);if(u.numChars>=1<<m)return 1/0;l+=4+m+u.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let d=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?d.push(c.charCodeAt(l)):(d.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return d}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let p=s;t.QrSegment=s})(ur||(ur={}));(t=>{(r=>{const o=class{constructor(a,s){this.ordinal=a,this.formatBits=s}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(ur||(ur={}));(t=>{(r=>{const o=class{constructor(a,s){this.modeBits=a,this.numBitsCharCount=s}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(ur||(ur={}));var wr=ur;/**
|
|
3767
|
+
*/var ur;(t=>{const r=class be{constructor(c,d,l,u){if(this.version=c,this.errorCorrectionLevel=d,this.modules=[],this.isFunction=[],c<be.MIN_VERSION||c>be.MAX_VERSION)throw new RangeError("Version value out of range");if(u<-1||u>7)throw new RangeError("Mask value out of range");this.size=c*4+17;let m=[];for(let x=0;x<this.size;x++)m.push(!1);for(let x=0;x<this.size;x++)this.modules.push(m.slice()),this.isFunction.push(m.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(l);if(this.drawCodewords(v),u==-1){let x=1e9;for(let y=0;y<8;y++){this.applyMask(y),this.drawFormatBits(y);const k=this.getPenaltyScore();k<x&&(u=y,x=k),this.applyMask(y)}}a(0<=u&&u<=7),this.mask=u,this.applyMask(u),this.drawFormatBits(u),this.isFunction=[]}static encodeText(c,d){const l=t.QrSegment.makeSegments(c);return be.encodeSegments(l,d)}static encodeBinary(c,d){const l=t.QrSegment.makeBytes(c);return be.encodeSegments([l],d)}static encodeSegments(c,d,l=1,u=40,m=-1,v=!0){if(!(be.MIN_VERSION<=l&&l<=u&&u<=be.MAX_VERSION)||m<-1||m>7)throw new RangeError("Invalid value");let x,y;for(x=l;;x++){const _=be.getNumDataCodewords(x,d)*8,$=p.getTotalBits(c,x);if($<=_){y=$;break}if(x>=u)throw new RangeError("Data too long")}for(const _ of[be.Ecc.MEDIUM,be.Ecc.QUARTILE,be.Ecc.HIGH])v&&y<=be.getNumDataCodewords(x,_)*8&&(d=_);let k=[];for(const _ of c){o(_.mode.modeBits,4,k),o(_.numChars,_.mode.numCharCountBits(x),k);for(const $ of _.getData())k.push($)}a(k.length==y);const z=be.getNumDataCodewords(x,d)*8;a(k.length<=z),o(0,Math.min(4,z-k.length),k),o(0,(8-k.length%8)%8,k),a(k.length%8==0);for(let _=236;k.length<z;_^=253)o(_,8,k);let S=[];for(;S.length*8<k.length;)S.push(0);return k.forEach((_,$)=>S[$>>>3]|=_<<7-($&7)),new be(x,d,S,m)}getModule(c,d){return 0<=c&&c<this.size&&0<=d&&d<this.size&&this.modules[d][c]}getModules(){return this.modules}drawFunctionPatterns(){for(let l=0;l<this.size;l++)this.setFunctionModule(6,l,l%2==0),this.setFunctionModule(l,6,l%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const c=this.getAlignmentPatternPositions(),d=c.length;for(let l=0;l<d;l++)for(let u=0;u<d;u++)l==0&&u==0||l==0&&u==d-1||l==d-1&&u==0||this.drawAlignmentPattern(c[l],c[u]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(c){const d=this.errorCorrectionLevel.formatBits<<3|c;let l=d;for(let m=0;m<10;m++)l=l<<1^(l>>>9)*1335;const u=(d<<10|l)^21522;a(u>>>15==0);for(let m=0;m<=5;m++)this.setFunctionModule(8,m,n(u,m));this.setFunctionModule(8,7,n(u,6)),this.setFunctionModule(8,8,n(u,7)),this.setFunctionModule(7,8,n(u,8));for(let m=9;m<15;m++)this.setFunctionModule(14-m,8,n(u,m));for(let m=0;m<8;m++)this.setFunctionModule(this.size-1-m,8,n(u,m));for(let m=8;m<15;m++)this.setFunctionModule(8,this.size-15+m,n(u,m));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let c=this.version;for(let l=0;l<12;l++)c=c<<1^(c>>>11)*7973;const d=this.version<<12|c;a(d>>>18==0);for(let l=0;l<18;l++){const u=n(d,l),m=this.size-11+l%3,v=Math.floor(l/3);this.setFunctionModule(m,v,u),this.setFunctionModule(v,m,u)}}drawFinderPattern(c,d){for(let l=-4;l<=4;l++)for(let u=-4;u<=4;u++){const m=Math.max(Math.abs(u),Math.abs(l)),v=c+u,x=d+l;0<=v&&v<this.size&&0<=x&&x<this.size&&this.setFunctionModule(v,x,m!=2&&m!=4)}}drawAlignmentPattern(c,d){for(let l=-2;l<=2;l++)for(let u=-2;u<=2;u++)this.setFunctionModule(c+u,d+l,Math.max(Math.abs(u),Math.abs(l))!=1)}setFunctionModule(c,d,l){this.modules[d][c]=l,this.isFunction[d][c]=!0}addEccAndInterleave(c){const d=this.version,l=this.errorCorrectionLevel;if(c.length!=be.getNumDataCodewords(d,l))throw new RangeError("Invalid argument");const u=be.NUM_ERROR_CORRECTION_BLOCKS[l.ordinal][d],m=be.ECC_CODEWORDS_PER_BLOCK[l.ordinal][d],v=Math.floor(be.getNumRawDataModules(d)/8),x=u-v%u,y=Math.floor(v/u);let k=[];const z=be.reedSolomonComputeDivisor(m);for(let _=0,$=0;_<u;_++){let w=c.slice($,$+y-m+(_<x?0:1));$+=w.length;const b=be.reedSolomonComputeRemainder(w,z);_<x&&w.push(0),k.push(w.concat(b))}let S=[];for(let _=0;_<k[0].length;_++)k.forEach(($,w)=>{(_!=y-m||w>=x)&&S.push($[_])});return a(S.length==v),S}drawCodewords(c){if(c.length!=Math.floor(be.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let d=0;for(let l=this.size-1;l>=1;l-=2){l==6&&(l=5);for(let u=0;u<this.size;u++)for(let m=0;m<2;m++){const v=l-m,y=(l+1&2)==0?this.size-1-u:u;!this.isFunction[y][v]&&d<c.length*8&&(this.modules[y][v]=n(c[d>>>3],7-(d&7)),d++)}}a(d==c.length*8)}applyMask(c){if(c<0||c>7)throw new RangeError("Mask value out of range");for(let d=0;d<this.size;d++)for(let l=0;l<this.size;l++){let u;switch(c){case 0:u=(l+d)%2==0;break;case 1:u=d%2==0;break;case 2:u=l%3==0;break;case 3:u=(l+d)%3==0;break;case 4:u=(Math.floor(l/3)+Math.floor(d/2))%2==0;break;case 5:u=l*d%2+l*d%3==0;break;case 6:u=(l*d%2+l*d%3)%2==0;break;case 7:u=((l+d)%2+l*d%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[d][l]&&u&&(this.modules[d][l]=!this.modules[d][l])}}getPenaltyScore(){let c=0;for(let m=0;m<this.size;m++){let v=!1,x=0,y=[0,0,0,0,0,0,0];for(let k=0;k<this.size;k++)this.modules[m][k]==v?(x++,x==5?c+=be.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,y),v||(c+=this.finderPenaltyCountPatterns(y)*be.PENALTY_N3),v=this.modules[m][k],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,y)*be.PENALTY_N3}for(let m=0;m<this.size;m++){let v=!1,x=0,y=[0,0,0,0,0,0,0];for(let k=0;k<this.size;k++)this.modules[k][m]==v?(x++,x==5?c+=be.PENALTY_N1:x>5&&c++):(this.finderPenaltyAddHistory(x,y),v||(c+=this.finderPenaltyCountPatterns(y)*be.PENALTY_N3),v=this.modules[k][m],x=1);c+=this.finderPenaltyTerminateAndCount(v,x,y)*be.PENALTY_N3}for(let m=0;m<this.size-1;m++)for(let v=0;v<this.size-1;v++){const x=this.modules[m][v];x==this.modules[m][v+1]&&x==this.modules[m+1][v]&&x==this.modules[m+1][v+1]&&(c+=be.PENALTY_N2)}let d=0;for(const m of this.modules)d=m.reduce((v,x)=>v+(x?1:0),d);const l=this.size*this.size,u=Math.ceil(Math.abs(d*20-l*10)/l)-1;return a(0<=u&&u<=9),c+=u*be.PENALTY_N4,a(0<=c&&c<=2568888),c}getAlignmentPatternPositions(){if(this.version==1)return[];{const c=Math.floor(this.version/7)+2,d=this.version==32?26:Math.ceil((this.version*4+4)/(c*2-2))*2;let l=[6];for(let u=this.size-7;l.length<c;u-=d)l.splice(1,0,u);return l}}static getNumRawDataModules(c){if(c<be.MIN_VERSION||c>be.MAX_VERSION)throw new RangeError("Version number out of range");let d=(16*c+128)*c+64;if(c>=2){const l=Math.floor(c/7)+2;d-=(25*l-10)*l-55,c>=7&&(d-=36)}return a(208<=d&&d<=29648),d}static getNumDataCodewords(c,d){return Math.floor(be.getNumRawDataModules(c)/8)-be.ECC_CODEWORDS_PER_BLOCK[d.ordinal][c]*be.NUM_ERROR_CORRECTION_BLOCKS[d.ordinal][c]}static reedSolomonComputeDivisor(c){if(c<1||c>255)throw new RangeError("Degree out of range");let d=[];for(let u=0;u<c-1;u++)d.push(0);d.push(1);let l=1;for(let u=0;u<c;u++){for(let m=0;m<d.length;m++)d[m]=be.reedSolomonMultiply(d[m],l),m+1<d.length&&(d[m]^=d[m+1]);l=be.reedSolomonMultiply(l,2)}return d}static reedSolomonComputeRemainder(c,d){let l=d.map(u=>0);for(const u of c){const m=u^l.shift();l.push(0),d.forEach((v,x)=>l[x]^=be.reedSolomonMultiply(v,m))}return l}static reedSolomonMultiply(c,d){if(c>>>8||d>>>8)throw new RangeError("Byte out of range");let l=0;for(let u=7;u>=0;u--)l=l<<1^(l>>>7)*285,l^=(d>>>u&1)*c;return a(l>>>8==0),l}finderPenaltyCountPatterns(c){const d=c[1];a(d<=this.size*3);const l=d>0&&c[2]==d&&c[3]==d*3&&c[4]==d&&c[5]==d;return(l&&c[0]>=d*4&&c[6]>=d?1:0)+(l&&c[6]>=d*4&&c[0]>=d?1:0)}finderPenaltyTerminateAndCount(c,d,l){return c&&(this.finderPenaltyAddHistory(d,l),d=0),d+=this.size,this.finderPenaltyAddHistory(d,l),this.finderPenaltyCountPatterns(l)}finderPenaltyAddHistory(c,d){d[0]==0&&(c+=this.size),d.pop(),d.unshift(c)}};r.MIN_VERSION=1,r.MAX_VERSION=40,r.PENALTY_N1=3,r.PENALTY_N2=3,r.PENALTY_N3=40,r.PENALTY_N4=10,r.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],r.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],t.QrCode=r;function o(f,c,d){if(c<0||c>31||f>>>c)throw new RangeError("Value out of range");for(let l=c-1;l>=0;l--)d.push(f>>>l&1)}function n(f,c){return(f>>>c&1)!=0}function a(f){if(!f)throw new Error("Assertion error")}const s=class Fe{constructor(c,d,l){if(this.mode=c,this.numChars=d,this.bitData=l,d<0)throw new RangeError("Invalid argument");this.bitData=l.slice()}static makeBytes(c){let d=[];for(const l of c)o(l,8,d);return new Fe(Fe.Mode.BYTE,c.length,d)}static makeNumeric(c){if(!Fe.isNumeric(c))throw new RangeError("String contains non-numeric characters");let d=[];for(let l=0;l<c.length;){const u=Math.min(c.length-l,3);o(parseInt(c.substring(l,l+u),10),u*3+1,d),l+=u}return new Fe(Fe.Mode.NUMERIC,c.length,d)}static makeAlphanumeric(c){if(!Fe.isAlphanumeric(c))throw new RangeError("String contains unencodable characters in alphanumeric mode");let d=[],l;for(l=0;l+2<=c.length;l+=2){let u=Fe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l))*45;u+=Fe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l+1)),o(u,11,d)}return l<c.length&&o(Fe.ALPHANUMERIC_CHARSET.indexOf(c.charAt(l)),6,d),new Fe(Fe.Mode.ALPHANUMERIC,c.length,d)}static makeSegments(c){return c==""?[]:Fe.isNumeric(c)?[Fe.makeNumeric(c)]:Fe.isAlphanumeric(c)?[Fe.makeAlphanumeric(c)]:[Fe.makeBytes(Fe.toUtf8ByteArray(c))]}static makeEci(c){let d=[];if(c<0)throw new RangeError("ECI assignment value out of range");if(c<128)o(c,8,d);else if(c<16384)o(2,2,d),o(c,14,d);else if(c<1e6)o(6,3,d),o(c,21,d);else throw new RangeError("ECI assignment value out of range");return new Fe(Fe.Mode.ECI,0,d)}static isNumeric(c){return Fe.NUMERIC_REGEX.test(c)}static isAlphanumeric(c){return Fe.ALPHANUMERIC_REGEX.test(c)}getData(){return this.bitData.slice()}static getTotalBits(c,d){let l=0;for(const u of c){const m=u.mode.numCharCountBits(d);if(u.numChars>=1<<m)return 1/0;l+=4+m+u.bitData.length}return l}static toUtf8ByteArray(c){c=encodeURI(c);let d=[];for(let l=0;l<c.length;l++)c.charAt(l)!="%"?d.push(c.charCodeAt(l)):(d.push(parseInt(c.substring(l+1,l+3),16)),l+=2);return d}};s.NUMERIC_REGEX=/^[0-9]*$/,s.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,s.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let p=s;t.QrSegment=s})(ur||(ur={}));(t=>{(r=>{const o=class{constructor(a,s){this.ordinal=a,this.formatBits=s}};o.LOW=new o(0,1),o.MEDIUM=new o(1,0),o.QUARTILE=new o(2,3),o.HIGH=new o(3,2),r.Ecc=o})(t.QrCode||(t.QrCode={}))})(ur||(ur={}));(t=>{(r=>{const o=class{constructor(a,s){this.modeBits=a,this.numBitsCharCount=s}numCharCountBits(a){return this.numBitsCharCount[Math.floor((a+7)/17)]}};o.NUMERIC=new o(1,[10,12,14]),o.ALPHANUMERIC=new o(2,[9,11,13]),o.BYTE=new o(4,[8,16,16]),o.KANJI=new o(8,[8,10,12]),o.ECI=new o(7,[0,0,0]),r.Mode=o})(t.QrSegment||(t.QrSegment={}))})(ur||(ur={}));var wr=ur;/**
|
|
3768
3768
|
* @license qrcode.react
|
|
3769
3769
|
* Copyright (c) Paul O'Shannessy
|
|
3770
3770
|
* SPDX-License-Identifier: ISC
|
|
3771
|
-
*/var H0={L:wr.QrCode.Ecc.LOW,M:wr.QrCode.Ecc.MEDIUM,Q:wr.QrCode.Ecc.QUARTILE,H:wr.QrCode.Ecc.HIGH},od=128,nd="L",ad="#FFFFFF",sd="#000000",id=!1,cd=1,q0=4,Y0=0,Z0=.1;function ld(t,r=0){const o=[];return t.forEach(function(n,a){let s=null;n.forEach(function(p,f){if(!p&&s!==null){o.push(`M${s+r} ${a+r}h${f-s}v1H${s+r}z`),s=null;return}if(f===n.length-1){if(!p)return;s===null?o.push(`M${f+r},${a+r} h1v1H${f+r}z`):o.push(`M${s+r},${a+r} h${f+1-s}v1H${s+r}z`);return}p&&s===null&&(s=f)})}),o.join("")}function dd(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 K0(t,r,o,n){if(n==null)return null;const a=t.length+o*2,s=Math.floor(r*Z0),p=a/r,f=(n.width||s)*p,c=(n.height||s)*p,d=n.x==null?t.length/2-f/2:n.x*p,l=n.y==null?t.length/2-c/2:n.y*p,u=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let x=Math.floor(d),y=Math.floor(l),
|
|
3771
|
+
*/var H0={L:wr.QrCode.Ecc.LOW,M:wr.QrCode.Ecc.MEDIUM,Q:wr.QrCode.Ecc.QUARTILE,H:wr.QrCode.Ecc.HIGH},od=128,nd="L",ad="#FFFFFF",sd="#000000",id=!1,cd=1,q0=4,Y0=0,Z0=.1;function ld(t,r=0){const o=[];return t.forEach(function(n,a){let s=null;n.forEach(function(p,f){if(!p&&s!==null){o.push(`M${s+r} ${a+r}h${f-s}v1H${s+r}z`),s=null;return}if(f===n.length-1){if(!p)return;s===null?o.push(`M${f+r},${a+r} h1v1H${f+r}z`):o.push(`M${s+r},${a+r} h${f+1-s}v1H${s+r}z`);return}p&&s===null&&(s=f)})}),o.join("")}function dd(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 K0(t,r,o,n){if(n==null)return null;const a=t.length+o*2,s=Math.floor(r*Z0),p=a/r,f=(n.width||s)*p,c=(n.height||s)*p,d=n.x==null?t.length/2-f/2:n.x*p,l=n.y==null?t.length/2-c/2:n.y*p,u=n.opacity==null?1:n.opacity;let m=null;if(n.excavate){let x=Math.floor(d),y=Math.floor(l),k=Math.ceil(f+d-x),z=Math.ceil(c+l-y);m={x,y,w:k,h:z}}const v=n.crossOrigin;return{x:d,y:l,h:c,w:f,excavation:m,opacity:u,crossOrigin:v}}function Q0(t,r){return r!=null?Math.max(Math.floor(r),0):t?q0:Y0}function ud({value:t,level:r,minVersion:o,includeMargin:n,marginSize:a,imageSettings:s,size:p,boostLevel:f}){let c=i.useMemo(()=>{const x=(Array.isArray(t)?t:[t]).reduce((y,k)=>(y.push(...wr.QrSegment.makeSegments(k)),y),[]);return wr.QrCode.encodeSegments(x,H0[r],o,void 0,void 0,f)},[t,r,o,f]);const{cells:d,margin:l,numCells:u,calculatedImageSettings:m}=i.useMemo(()=>{let v=c.getModules();const x=Q0(n,a),y=v.length+x*2,k=K0(v,p,x,s);return{cells:v,margin:x,numCells:y,calculatedImageSettings:k}},[c,p,s,n,a]);return{qrcode:c,margin:l,cells:d,numCells:u,calculatedImageSettings:m}}var J0=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),X0=i.forwardRef(function(r,o){const n=r,{value:a,size:s=od,level:p=nd,bgColor:f=ad,fgColor:c=sd,includeMargin:d=id,minVersion:l=cd,boostLevel:u,marginSize:m,imageSettings:v}=n,y=ba(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:k}=y,z=ba(y,["style"]),S=v==null?void 0:v.src,_=i.useRef(null),$=i.useRef(null),w=i.useCallback(P=>{_.current=P,typeof o=="function"?o(P):o&&(o.current=P)},[o]),[b,g]=i.useState(!1),{margin:C,cells:E,numCells:j,calculatedImageSettings:T}=ud({value:a,level:p,minVersion:l,boostLevel:u,includeMargin:d,marginSize:m,imageSettings:v,size:s});i.useEffect(()=>{if(_.current!=null){const P=_.current,M=P.getContext("2d");if(!M)return;let F=E;const D=$.current,L=T!=null&&D!==null&&D.complete&&D.naturalHeight!==0&&D.naturalWidth!==0;L&&T.excavation!=null&&(F=dd(E,T.excavation));const R=window.devicePixelRatio||1;P.height=P.width=s*R;const A=s/j*R;M.scale(A,A),M.fillStyle=f,M.fillRect(0,0,j,j),M.fillStyle=c,J0?M.fill(new Path2D(ld(F,C))):E.forEach(function(B,G){B.forEach(function(U,ne){U&&M.fillRect(ne+C,G+C,1,1)})}),T&&(M.globalAlpha=T.opacity),L&&M.drawImage(D,T.x+C,T.y+C,T.w,T.h)}}),i.useEffect(()=>{g(!1)},[S]);const I=ya({height:s,width:s},k);let O=null;return S!=null&&(O=i.createElement("img",{src:S,key:S,style:{display:"none"},onLoad:()=>{g(!0)},ref:$,crossOrigin:T==null?void 0:T.crossOrigin})),i.createElement(i.Fragment,null,i.createElement("canvas",ya({style:I,height:s,width:s,ref:w,role:"img"},z)),O)});X0.displayName="QRCodeCanvas";var Na=i.forwardRef(function(r,o){const n=r,{value:a,size:s=od,level:p=nd,bgColor:f=ad,fgColor:c=sd,includeMargin:d=id,minVersion:l=cd,boostLevel:u,title:m,marginSize:v,imageSettings:x}=n,y=ba(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:k,cells:z,numCells:S,calculatedImageSettings:_}=ud({value:a,level:p,minVersion:l,boostLevel:u,includeMargin:d,marginSize:v,imageSettings:x,size:s});let $=z,w=null;x!=null&&_!=null&&(_.excavation!=null&&($=dd(z,_.excavation)),w=i.createElement("image",{href:x.src,height:_.h,width:_.w,x:_.x+k,y:_.y+k,preserveAspectRatio:"none",opacity:_.opacity,crossOrigin:_.crossOrigin}));const b=ld($,k);return i.createElement("svg",ya({height:s,width:s,viewBox:`0 0 ${S} ${S}`,ref:o,role:"img"},y),!!m&&i.createElement("title",null,m),i.createElement("path",{fill:f,d:`M0,0 h${S}v${S}H0z`,shapeRendering:"crispEdges"}),i.createElement("path",{fill:c,d:b,shapeRendering:"crispEdges"}),w)});Na.displayName="QRCodeSVG";const pd=i.createContext(void 0),Ut=()=>{const t=i.useContext(pd);if(!t)throw new Error("useScreenContext must be used within a ScreenProvider");return t},ev=h.div`
|
|
3772
3772
|
position: fixed;
|
|
3773
3773
|
background: var(--color-background);
|
|
3774
3774
|
border-radius: var(--radius-md);
|
|
@@ -3807,7 +3807,7 @@ cursor: pointer;
|
|
|
3807
3807
|
justify-content: center;
|
|
3808
3808
|
color: var(--color-muted);
|
|
3809
3809
|
flex-shrink: 0;
|
|
3810
|
-
`,Pi=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:a,triggerRef:s})=>{const p=i.useRef(null),[f,c]=i.useState(!1),[d,l]=i.useState({top:0,left:0}),{toast:u}=Ut();i.useEffect(()=>{c(!0);const b=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const E=s.current;if(E){const j=E.getBoundingClientRect(),T=380,I=300,O=8;let P=0,M=0;const F=window.innerHeight-j.bottom,D=j.top;F>=I+O?(P=j.bottom+O,M=j.right-T,M<O&&(M=j.left,M+T>window.innerWidth-O&&(M=(window.innerWidth-T)/2))):D>=I+O?(P=j.top-I-O,M=j.right-T,M<O&&(M=j.left,M+T>window.innerWidth-O&&(M=(window.innerWidth-T)/2))):(P=j.bottom+O,M=j.right-T,M<O&&(M=j.left)),l({top:P,left:M})}},10),g=E=>{p.current&&!p.current.contains(E.target)&&t()},C=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",C),()=>{clearTimeout(b),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",C)}},[t,s]);const[m,v]=i.useState(a?"otp":"email"),[x,y]=i.useState(a||""),[
|
|
3810
|
+
`,Pi=({onClose:t,onAddEmail:r,onAttemptVerification:o,onPrepareVerification:n,existingEmail:a,triggerRef:s})=>{const p=i.useRef(null),[f,c]=i.useState(!1),[d,l]=i.useState({top:0,left:0}),{toast:u}=Ut();i.useEffect(()=>{c(!0);const b=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const E=s.current;if(E){const j=E.getBoundingClientRect(),T=380,I=300,O=8;let P=0,M=0;const F=window.innerHeight-j.bottom,D=j.top;F>=I+O?(P=j.bottom+O,M=j.right-T,M<O&&(M=j.left,M+T>window.innerWidth-O&&(M=(window.innerWidth-T)/2))):D>=I+O?(P=j.top-I-O,M=j.right-T,M<O&&(M=j.left,M+T>window.innerWidth-O&&(M=(window.innerWidth-T)/2))):(P=j.bottom+O,M=j.right-T,M<O&&(M=j.left)),l({top:P,left:M})}},10),g=E=>{p.current&&!p.current.contains(E.target)&&t()},C=E=>{E.key==="Escape"&&t()};return document.addEventListener("mousedown",g),document.addEventListener("keydown",C),()=>{clearTimeout(b),document.removeEventListener("mousedown",g),document.removeEventListener("keydown",C)}},[t,s]);const[m,v]=i.useState(a?"otp":"email"),[x,y]=i.useState(a||""),[k,z]=i.useState(""),[S,_]=i.useState(!1),$=async()=>{if(!(!x||S)){_(!0);try{await r(x),v("otp")}catch(b){const g=b.message||"Failed to add email address. Please try again.";u(g,"error")}finally{_(!1)}}},w=async()=>{_(!0);try{await o(k),t()}catch(b){const g=b.message||"Failed to verify email. Please check the code and try again.";u(g,"error")}finally{_(!1)}};return f?e.jsx(ev,{ref:p,style:{top:`${d.top}px`,left:`${d.left}px`,visibility:d.top>0?"visible":"hidden"},onClick:b=>b.stopPropagation(),children:m==="email"?e.jsxs(e.Fragment,{children:[e.jsx($i,{children:"Add email address"}),e.jsx(ie,{children:e.jsxs(tv,{children:[e.jsx(rv,{children:e.jsx(an,{size:16})}),e.jsx(J,{id:"email-input",type:"email",placeholder:"Email address",value:x,onChange:b=>y(b.target.value),style:{flex:1}})]})}),e.jsxs(Ei,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(V,{onClick:$,disabled:!x||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Adding...":"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx($i,{children:"Verify your email"}),e.jsxs("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:["Enter the 6-digit code sent to ",x]}),e.jsx(Bt,{onComplete:async b=>z(b),onResend:n,isSubmitting:S}),e.jsxs(Ei,{children:[e.jsx(V,{$outline:!0,onClick:()=>v("email"),style:{width:"auto",padding:"0 var(--space-md)"},children:"Back"}),e.jsx(V,{onClick:w,disabled:k.length<6||S,style:{width:"auto",padding:"0 var(--space-md)"},children:S?"Verifying...":"Verify"})]})]})}):null},ov=h.div`
|
|
3811
3811
|
position: fixed;
|
|
3812
3812
|
background: var(--color-background);
|
|
3813
3813
|
border-radius: var(--radius-md);
|
|
@@ -3831,7 +3831,7 @@ cursor: pointer;
|
|
|
3831
3831
|
font-weight: 400;
|
|
3832
3832
|
color: var(--color-foreground);
|
|
3833
3833
|
margin-bottom: 12px;
|
|
3834
|
-
`,Ti=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:a,triggerRef:s})=>{var C;const p=i.useRef(null),[f,c]=i.useState(!1),[d,l]=i.useState({top:0,left:0}),{toast:u}=Ut();i.useEffect(()=>{c(!0);const E=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const I=s.current;if(I){const O=I.getBoundingClientRect(),P=380,M=300,F=8;let D=0,L=0;const R=window.innerHeight-O.bottom,A=O.top;R>=M+F?(D=O.bottom+F,L=O.right-P,L<F&&(L=O.left,L+P>window.innerWidth-F&&(L=(window.innerWidth-P)/2))):A>=M+F?(D=O.top-M-F,L=O.right-P,L<F&&(L=O.left,L+P>window.innerWidth-F&&(L=(window.innerWidth-P)/2))):(D=O.bottom+F,L=O.right-P,L<F&&(L=O.left)),l({top:D,left:L})}},10),j=I=>{p.current&&!p.current.contains(I.target)&&t()},T=I=>{I.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",T),()=>{clearTimeout(E),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",T)}},[t,s]);const[m,v]=i.useState(n?"otp":"phone"),[x,y]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[
|
|
3834
|
+
`,Ti=({onClose:t,onAddPhone:r,onAttemptVerification:o,existingPhone:n,onPrepareVerification:a,triggerRef:s})=>{var C;const p=i.useRef(null),[f,c]=i.useState(!1),[d,l]=i.useState({top:0,left:0}),{toast:u}=Ut();i.useEffect(()=>{c(!0);const E=setTimeout(()=>{if(!p.current||!(s!=null&&s.current))return;const I=s.current;if(I){const O=I.getBoundingClientRect(),P=380,M=300,F=8;let D=0,L=0;const R=window.innerHeight-O.bottom,A=O.top;R>=M+F?(D=O.bottom+F,L=O.right-P,L<F&&(L=O.left,L+P>window.innerWidth-F&&(L=(window.innerWidth-P)/2))):A>=M+F?(D=O.top-M-F,L=O.right-P,L<F&&(L=O.left,L+P>window.innerWidth-F&&(L=(window.innerWidth-P)/2))):(D=O.bottom+F,L=O.right-P,L<F&&(L=O.left)),l({top:D,left:L})}},10),j=I=>{p.current&&!p.current.contains(I.target)&&t()},T=I=>{I.key==="Escape"&&t()};return document.addEventListener("mousedown",j),document.addEventListener("keydown",T),()=>{clearTimeout(E),document.removeEventListener("mousedown",j),document.removeEventListener("keydown",T)}},[t,s]);const[m,v]=i.useState(n?"otp":"phone"),[x,y]=i.useState((n==null?void 0:n.replace(/^\+\d+/,""))||""),[k,z]=i.useState((C=Intl.DateTimeFormat().resolvedOptions().locale.split("-"))==null?void 0:C.pop()),[S,_]=i.useState(""),[$,w]=i.useState(!1),b=async()=>{if(!(!x||$)){w(!0);try{await r(x,k||""),v("otp")}catch(E){const j=E.message||"Failed to add phone number. Please try again.";u(j,"error")}finally{w(!1)}}},g=async()=>{w(!0);try{await o(S),t()}catch(E){const j=E.message||"Failed to verify phone. Please check the code and try again.";u(j,"error")}finally{w(!1)}};return f?e.jsx(ov,{ref:p,style:{top:`${d.top}px`,left:`${d.left}px`,visibility:d.top>0?"visible":"hidden"},onClick:E=>E.stopPropagation(),children:m==="phone"?e.jsxs(e.Fragment,{children:[e.jsx(Ii,{children:"Add phone number"}),e.jsx(ie,{children:e.jsx(Zr,{value:x,onChange:E=>y(E.target.value),error:"",countryCode:k,setCountryCode:z})}),e.jsxs(Ri,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(V,{onClick:b,disabled:!x||$,style:{width:"auto",padding:"0 var(--space-md)"},children:"Continue"})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ii,{children:"Verify phone number"}),e.jsx(ie,{children:e.jsx(Bt,{onComplete:E=>_(E),onResend:async()=>a()})}),e.jsxs(Ri,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(V,{onClick:g,disabled:S.length!==6||$,style:{width:"auto",padding:"0 var(--space-md)"},children:"Verify"})]})]})}):null},nv=h.div`
|
|
3835
3835
|
position: fixed;
|
|
3836
3836
|
background: var(--color-background);
|
|
3837
3837
|
border-radius: var(--radius-md);
|
|
@@ -3874,7 +3874,7 @@ cursor: pointer;
|
|
|
3874
3874
|
font-weight: 400;
|
|
3875
3875
|
color: var(--color-foreground);
|
|
3876
3876
|
margin-bottom: 8px;
|
|
3877
|
-
`,av=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const a=i.useRef(null),[s,p]=i.useState("qr"),[f,c]=i.useState(""),[d,l]=i.useState(""),[u,m]=i.useState(["",""]),[v,x]=i.useState(!1),[y,
|
|
3877
|
+
`,av=({onClose:t,onSetupTOTP:r,onVerifyTOTP:o,triggerRef:n})=>{const a=i.useRef(null),[s,p]=i.useState("qr"),[f,c]=i.useState(""),[d,l]=i.useState(""),[u,m]=i.useState(["",""]),[v,x]=i.useState(!1),[y,k]=i.useState(!1),[z,S]=i.useState({top:0,left:0}),{toast:_}=Ut();i.useEffect(()=>{k(!0);const w=setTimeout(()=>{if(!a.current||!(n!=null&&n.current))return;const C=n.current;if(C){const E=C.getBoundingClientRect(),j=380,T=400,I=8;let O=0,P=0;const M=window.innerHeight-E.bottom,F=E.top;M>=T+I?(O=E.bottom+I,P=E.right-j,P<I&&(P=E.left,P+j>window.innerWidth-I&&(P=(window.innerWidth-j)/2))):F>=T+I?(O=E.top-T-I,P=E.right-j,P<I&&(P=E.left,P+j>window.innerWidth-I&&(P=(window.innerWidth-j)/2))):(O=E.bottom+I,P=E.right-j,P<I&&(P=E.left)),S({top:O,left:P})}},10),b=C=>{a.current&&!a.current.contains(C.target)&&t()},g=C=>{C.key==="Escape"&&t()};return document.addEventListener("mousedown",b),document.addEventListener("keydown",g),()=>{clearTimeout(w),document.removeEventListener("mousedown",b),document.removeEventListener("keydown",g)}},[t,n]),i.useEffect(()=>{(async()=>{x(!0);try{const b=await r();c(b.otp_url||""),l(b.totp_secret||"")}catch(b){const g=b.message||"Failed to setup two-factor authentication. Please try again.";_(g,"error")}finally{x(!1)}})()},[]);const $=async()=>{if(!u.some(w=>w.length!==6)){x(!0);try{await o(u),t()}catch(w){const b=w.message||"Failed to verify codes. Please check your authenticator app and try again.";_(b,"error")}finally{x(!1)}}};return y?e.jsx(nv,{ref:a,style:{top:`${z.top}px`,left:`${z.left}px`,visibility:z.top>0?"visible":"hidden"},onClick:w=>w.stopPropagation(),children:s==="qr"?e.jsxs(e.Fragment,{children:[e.jsx(Mi,{children:"Setup Two-Factor Authentication"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Scan this QR code with your authenticator app (Google Authenticator, Authy, etc.)"}),e.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"16px"},children:v?e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)"},children:"Loading..."}):f?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",background:"white"},children:e.jsx(Na,{value:f,size:150,title:"QR Code for Two-Factor Authentication Setup","aria-label":"Scan this QR code with your authenticator app to set up two-factor authentication"})}):e.jsx("div",{style:{width:"150px",height:"150px",display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",background:"var(--color-input-background)",color:"var(--color-error)"},children:"QR Code Not Available"})}),d&&e.jsxs("div",{style:{background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"8px",marginBottom:"16px",fontSize:"12px"},children:[e.jsx("div",{style:{color:"var(--color-secondary-text)",marginBottom:"4px"},children:"Or enter manually:"}),e.jsx("code",{style:{fontFamily:"monospace",wordBreak:"break-all",color:"var(--color-secondary-text)"},children:d})]}),e.jsx(Oi,{children:e.jsx(qn,{$primary:!0,onClick:()=>p("verify"),disabled:v||!f,children:"I've Scanned the Code"})})]}):e.jsxs(e.Fragment,{children:[e.jsx(Mi,{children:"Verify Your Authenticator"}),e.jsx("div",{style:{fontSize:"14px",color:"var(--color-muted)",marginBottom:"16px"},children:"Enter two consecutive codes from your authenticator app"}),e.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:[e.jsx(J,{id:"totp-code-1",type:"text",placeholder:"000000",value:u[0],onChange:w=>{const b=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([b,u[1]])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"First verification code from authenticator app"}),e.jsx(J,{id:"totp-code-2",type:"text",placeholder:"000000",value:u[1],onChange:w=>{const b=w.target.value.replace(/[^0-9]/g,"").substring(0,6);m([u[0],b])},maxLength:6,style:{textAlign:"center",fontFamily:"monospace"},"aria-label":"Second verification code from authenticator app"})]}),e.jsxs(Oi,{children:[e.jsx(qn,{onClick:()=>p("qr"),children:"Back"}),e.jsx(qn,{$primary:!0,onClick:$,disabled:v||u.some(w=>w.length!==6),children:v?"Verifying...":"Verify"})]})]})}):null},sv=h.div`
|
|
3878
3878
|
position: fixed;
|
|
3879
3879
|
background: var(--color-background);
|
|
3880
3880
|
border-radius: var(--radius-md);
|
|
@@ -3944,7 +3944,7 @@ cursor: pointer;
|
|
|
3944
3944
|
color: var(--color-error);
|
|
3945
3945
|
font-size: 12px;
|
|
3946
3946
|
margin-top: 4px;
|
|
3947
|
-
`,Li=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const a=i.useRef(null),[s,p]=i.useState(!1),[f,c]=i.useState({top:0,left:0}),[d,l]=i.useState(""),[u,m]=i.useState(""),[v,x]=i.useState(""),[y,
|
|
3947
|
+
`,Li=({onClose:t,onChangePassword:r,triggerRef:o,isSetup:n=!1})=>{const a=i.useRef(null),[s,p]=i.useState(!1),[f,c]=i.useState({top:0,left:0}),[d,l]=i.useState(""),[u,m]=i.useState(""),[v,x]=i.useState(""),[y,k]=i.useState(!1),[z,S]=i.useState(!1),[_,$]=i.useState(!1),[w,b]=i.useState(!1),[g,C]=i.useState({});i.useEffect(()=>{p(!0);const j=setTimeout(()=>{if(!a.current||!(o!=null&&o.current))return;const O=o.current;if(O){const P=O.getBoundingClientRect(),M=380,F=350,D=8;let L=0,R=0;const A=window.innerHeight-P.bottom,B=P.top;A>=F+D?(L=P.bottom+D,R=P.right-M,R<D&&(R=P.left,R+M>window.innerWidth-D&&(R=(window.innerWidth-M)/2))):B>=F+D?(L=P.top-F-D,R=P.right-M,R<D&&(R=P.left,R+M>window.innerWidth-D&&(R=(window.innerWidth-M)/2))):(L=P.bottom+D,R=P.right-M,R<D&&(R=P.left)),c({top:L,left:R})}},10),T=O=>{a.current&&!a.current.contains(O.target)&&t()},I=O=>{O.key==="Escape"&&t()};return document.addEventListener("mousedown",T),document.addEventListener("keydown",I),()=>{clearTimeout(j),document.removeEventListener("mousedown",T),document.removeEventListener("keydown",I)}},[t,o]);const E=async()=>{if(w)return;const j={};if(!n&&!d&&(j.currentPassword="Current password is required"),u?u.length<8&&(j.newPassword="Password must be at least 8 characters"):j.newPassword="New password is required",u!==v&&(j.confirmPassword="Passwords do not match"),Object.keys(j).length>0){C(j);return}b(!0);try{await r(n?"":d,u),t()}catch(T){C({form:T.message||"Failed to update password"})}finally{b(!1)}};return s?e.jsxs(sv,{ref:a,style:{top:`${f.top}px`,left:`${f.left}px`,visibility:f.top>0?"visible":"hidden"},onClick:j=>j.stopPropagation(),children:[e.jsx(cv,{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(Yn,{children:[e.jsx(oe,{children:"Current Password"}),e.jsxs(Zn,{children:[e.jsx(J,{type:y?"text":"password",placeholder:"Enter your current password",value:d,onChange:j=>l(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>k(!y),"aria-label":y?"Hide current password":"Show current password",children:y?e.jsx(Cn,{size:16}):e.jsx(Sn,{size:16})})]}),g.currentPassword&&e.jsx(Ro,{children:g.currentPassword})]}),e.jsxs(Yn,{children:[e.jsx(oe,{children:n?"Password":"New Password"}),e.jsxs(Zn,{children:[e.jsx(J,{type:z?"text":"password",placeholder:n?"Enter your password":"Enter your new password",value:u,onChange:j=>m(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>S(!z),"aria-label":z?"Hide new password":"Show new password",children:z?e.jsx(Cn,{size:16}):e.jsx(Sn,{size:16})})]}),g.newPassword&&e.jsx(Ro,{children:g.newPassword})]}),e.jsxs(Yn,{children:[e.jsx(oe,{children:"Confirm New Password"}),e.jsxs(Zn,{children:[e.jsx(J,{type:_?"text":"password",placeholder:"Confirm your new password",value:v,onChange:j=>x(j.target.value),style:{paddingRight:"40px"}}),e.jsx("button",{type:"button",onClick:()=>$(!_),"aria-label":_?"Hide confirm password":"Show confirm password",children:_?e.jsx(Cn,{size:16}):e.jsx(Sn,{size:16})})]}),g.confirmPassword&&e.jsx(Ro,{children:g.confirmPassword})]}),g.form&&e.jsx(Ro,{children:g.form}),e.jsxs(iv,{children:[e.jsx(Ai,{onClick:t,children:"Cancel"}),e.jsx(Ai,{$primary:!0,onClick:E,disabled:w,children:w?n?"Setting...":"Updating...":n?"Set Password":"Update Password"})]})]}):null},lv=h.div`
|
|
3948
3948
|
position: fixed;
|
|
3949
3949
|
background: var(--color-background);
|
|
3950
3950
|
border-radius: var(--radius-md);
|
|
@@ -3982,7 +3982,7 @@ cursor: pointer;
|
|
|
3982
3982
|
color: var(--color-warning-text, var(--color-foreground));
|
|
3983
3983
|
margin: 0;
|
|
3984
3984
|
line-height: 1.5;
|
|
3985
|
-
`,fv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(!1),[p,f]=i.useState({top:0,left:0}),[c,d]=i.useState(""),[l,u]=i.useState(!1),{toast:m}=Ut();i.useEffect(()=>{s(!0);const x=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const
|
|
3985
|
+
`,fv=({onClose:t,onRemovePassword:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(!1),[p,f]=i.useState({top:0,left:0}),[c,d]=i.useState(""),[l,u]=i.useState(!1),{toast:m}=Ut();i.useEffect(()=>{s(!0);const x=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const z=o.current;if(z){const S=z.getBoundingClientRect(),_=400,$=300,w=8;let b=0,g=0;const C=window.innerHeight-S.bottom,E=S.top;C>=$+w?(b=S.bottom+w,g=S.right-_,g<w&&(g=S.left,g+_>window.innerWidth-w&&(g=(window.innerWidth-_)/2))):E>=$+w?(b=S.top-$-w,g=S.right-_,g<w&&(g=S.left,g+_>window.innerWidth-w&&(g=(window.innerWidth-_)/2))):(b=S.bottom+w,g=S.right-_,g<w&&(g=S.left)),f({top:b,left:g})}},10),y=z=>{n.current&&!n.current.contains(z.target)&&t()},k=z=>{z.key==="Escape"&&t()};return document.addEventListener("mousedown",y),document.addEventListener("keydown",k),()=>{clearTimeout(x),document.removeEventListener("mousedown",y),document.removeEventListener("keydown",k)}},[t,o]);const v=async()=>{if(!(!c||l)){u(!0);try{await r(c),t()}catch(x){const y=x.message||"Failed to remove password. Please try again.";m(y,"error")}finally{u(!1)}}};return a?e.jsxs(lv,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:x=>x.stopPropagation(),children:[e.jsxs(uv,{children:[e.jsx(ft,{size:18,color:"var(--color-warning, #fbbf24)"}),"Remove Password"]}),e.jsx(pv,{children:e.jsx(hv,{children:"You're about to remove password authentication from your account. Make sure you have another way to sign in (email, phone, social login, or passkey) before continuing."})}),e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"current-password",children:"Confirm your current password"}),e.jsx(J,{id:"current-password",type:"password",placeholder:"Enter current password",value:c,onChange:x=>d(x.target.value),autoFocus:!0})]}),e.jsxs(dv,{children:[e.jsx(V,{$outline:!0,onClick:t,style:{width:"auto",padding:"0 var(--space-md)"},children:"Cancel"}),e.jsx(V,{onClick:v,disabled:!c||l,style:{width:"auto",padding:"0 var(--space-md)",background:"var(--color-error)",borderColor:"var(--color-error)"},children:l?"Removing...":"Remove Password"})]})]}):null},gv=h.div`
|
|
3986
3986
|
position: fixed;
|
|
3987
3987
|
background: var(--color-background);
|
|
3988
3988
|
border-radius: var(--radius-md);
|
|
@@ -4048,7 +4048,7 @@ cursor: pointer;
|
|
|
4048
4048
|
background: var(--color-input-background-hover);
|
|
4049
4049
|
border-color: var(--color-primary);
|
|
4050
4050
|
}
|
|
4051
|
-
`,wv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:a})=>{const s=i.useRef(null),[p,f]=i.useState(!1),[c,d]=i.useState({top:0,left:0});return i.useEffect(()=>{f(!0);const l=setTimeout(()=>{if(!s.current||!(a!=null&&a.current))return;const v=a.current;if(v){const x=v.getBoundingClientRect(),y=380,
|
|
4051
|
+
`,wv=({codes:t,onClose:r,onCopy:o,onDownload:n,triggerRef:a})=>{const s=i.useRef(null),[p,f]=i.useState(!1),[c,d]=i.useState({top:0,left:0});return i.useEffect(()=>{f(!0);const l=setTimeout(()=>{if(!s.current||!(a!=null&&a.current))return;const v=a.current;if(v){const x=v.getBoundingClientRect(),y=380,k=300,z=8;let S=0,_=0;const $=window.innerHeight-x.bottom,w=x.top;$>=k+z?(S=x.bottom+z,_=x.right-y,_<z&&(_=x.left,_+y>window.innerWidth-z&&(_=(window.innerWidth-y)/2))):w>=k+z?(S=x.top-k-z,_=x.right-y,_<z&&(_=x.left,_+y>window.innerWidth-z&&(_=(window.innerWidth-y)/2))):(S=x.bottom+z,_=x.right-y,_<z&&(_=x.left)),d({top:S,left:_})}},10),u=v=>{s.current&&!s.current.contains(v.target)&&r()},m=v=>{v.key==="Escape"&&r()};return document.addEventListener("mousedown",u),document.addEventListener("keydown",m),()=>{clearTimeout(l),document.removeEventListener("mousedown",u),document.removeEventListener("keydown",m)}},[r,a]),p?e.jsxs(gv,{ref:s,style:{top:`${c.top}px`,left:`${c.left}px`,visibility:c.top>0?"visible":"hidden"},onClick:l=>l.stopPropagation(),children:[e.jsxs(mv,{children:[e.jsx(xv,{children:"Backup Codes"}),e.jsxs(vv,{children:[e.jsxs(Di,{onClick:o,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx(sr,{size:14}),"Copy"]}),e.jsxs(Di,{onClick:n,style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:"4px"},children:[e.jsx($a,{size:14}),"Download"]})]})]}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)",marginBottom:"8px"},children:"Save these backup codes in a secure location. Each code can only be used once."}),e.jsx(yv,{children:t.map((l,u)=>e.jsx(bv,{onClick:()=>{navigator.clipboard.writeText(l)},title:"Click to copy",children:l},u))}),e.jsxs("div",{style:{fontSize:"12px",color:"var(--color-warning)",padding:"6px 10px",background:"var(--color-warning-background)",border:"1px solid var(--color-warning-border)",borderRadius:"var(--radius-sm)",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx("span",{style:{fontSize:"14px"},children:"⚠️"}),e.jsx("span",{children:"Keep these codes safe! They won't be shown again."})]})]}):null},jv=h.div`
|
|
4052
4052
|
position: fixed;
|
|
4053
4053
|
background: var(--color-background);
|
|
4054
4054
|
border-radius: var(--radius-md);
|
|
@@ -4100,7 +4100,7 @@ cursor: pointer;
|
|
|
4100
4100
|
color: var(--color-error);
|
|
4101
4101
|
font-size: 12px;
|
|
4102
4102
|
margin-top: 4px;
|
|
4103
|
-
`,zv=({onClose:t,onAddPasskey:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(!1),[p,f]=i.useState({top:0,left:0}),[c,d]=i.useState(""),[l,u]=i.useState(!1),[m,v]=i.useState("");i.useEffect(()=>{s(!0);const y=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const z=o.current;if(z){const _=z.getBoundingClientRect(),$=320,w=180,b=8;let g=0,C=0;const E=window.innerHeight-_.bottom,j=_.top;E>=w+b?(g=_.bottom+b,C=_.right-$,C<b&&(C=_.left,C+$>window.innerWidth-b&&(C=(window.innerWidth-$)/2))):j>=w+b?(g=_.top-w-b,C=_.right-$,C<b&&(C=_.left,C+$>window.innerWidth-b&&(C=(window.innerWidth-$)/2))):(g=_.bottom+b,C=_.right-$,C<b&&(C=_.left)),f({top:g,left:C})}},10),S=z=>{n.current&&!n.current.contains(z.target)&&t()},k=z=>{z.key==="Escape"&&t()};return document.addEventListener("mousedown",S),document.addEventListener("keydown",k),()=>{clearTimeout(y),document.removeEventListener("mousedown",S),document.removeEventListener("keydown",k)}},[t,o]);const x=async()=>{if(!l){u(!0),v("");try{await r(c.trim()),t()}catch(y){v(y.message||"Failed to register passkey"),u(!1)}}};return a?e.jsxs(jv,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),children:[e.jsx(kv,{children:"Add Passkey"}),e.jsx(Cv,{children:e.jsx(J,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:c,onChange:y=>d(y.target.value),autoFocus:!0})}),m&&e.jsx(Sv,{children:m}),e.jsxs(_v,{children:[e.jsx(Fi,{onClick:t,children:"Cancel"}),e.jsx(Fi,{$primary:!0,onClick:x,disabled:l,children:l?"Registering...":"Continue"})]})]}):null},Ev=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),e.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),e.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),$v=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),Pv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),Rv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),Iv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),Tv=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),Ov=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),Mv=Nt`
|
|
4103
|
+
`,zv=({onClose:t,onAddPasskey:r,triggerRef:o})=>{const n=i.useRef(null),[a,s]=i.useState(!1),[p,f]=i.useState({top:0,left:0}),[c,d]=i.useState(""),[l,u]=i.useState(!1),[m,v]=i.useState("");i.useEffect(()=>{s(!0);const y=setTimeout(()=>{if(!n.current||!(o!=null&&o.current))return;const S=o.current;if(S){const _=S.getBoundingClientRect(),$=320,w=180,b=8;let g=0,C=0;const E=window.innerHeight-_.bottom,j=_.top;E>=w+b?(g=_.bottom+b,C=_.right-$,C<b&&(C=_.left,C+$>window.innerWidth-b&&(C=(window.innerWidth-$)/2))):j>=w+b?(g=_.top-w-b,C=_.right-$,C<b&&(C=_.left,C+$>window.innerWidth-b&&(C=(window.innerWidth-$)/2))):(g=_.bottom+b,C=_.right-$,C<b&&(C=_.left)),f({top:g,left:C})}},10),k=S=>{n.current&&!n.current.contains(S.target)&&t()},z=S=>{S.key==="Escape"&&t()};return document.addEventListener("mousedown",k),document.addEventListener("keydown",z),()=>{clearTimeout(y),document.removeEventListener("mousedown",k),document.removeEventListener("keydown",z)}},[t,o]);const x=async()=>{if(!l){u(!0),v("");try{await r(c.trim()),t()}catch(y){v(y.message||"Failed to register passkey"),u(!1)}}};return a?e.jsxs(jv,{ref:n,style:{top:`${p.top}px`,left:`${p.left}px`,visibility:p.top>0?"visible":"hidden"},onClick:y=>y.stopPropagation(),children:[e.jsx(kv,{children:"Add Passkey"}),e.jsx(Cv,{children:e.jsx(J,{type:"text",placeholder:"e.g., MacBook Pro, iPhone",value:c,onChange:y=>d(y.target.value),autoFocus:!0})}),m&&e.jsx(Sv,{children:m}),e.jsxs(_v,{children:[e.jsx(Fi,{onClick:t,children:"Cancel"}),e.jsx(Fi,{$primary:!0,onClick:x,disabled:l,children:l?"Registering...":"Continue"})]})]}):null},Ev=t=>e.jsxs("svg",{width:"800px",height:"800px",viewBox:"0 0 16 16",xmlns:"http://www.w3.org/2000/svg",fill:"none",...t,children:[e.jsx("path",{fill:"#F35325",d:"M1 1h6.5v6.5H1V1z"}),e.jsx("path",{fill:"#81BC06",d:"M8.5 1H15v6.5H8.5V1z"}),e.jsx("path",{fill:"#05A6F0",d:"M1 8.5h6.5V15H1V8.5z"}),e.jsx("path",{fill:"#FFBA08",d:"M8.5 8.5H15V15H8.5V8.5z"})]}),$v=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"a",x1:3.217,x2:44.781,y1:15,y2:15,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#d93025"}),e.jsx("stop",{offset:1,stopColor:"#ea4335"})]}),e.jsxs("linearGradient",{id:"b",x1:20.722,x2:41.504,y1:47.679,y2:11.684,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#fcc934"}),e.jsx("stop",{offset:1,stopColor:"#fbbc04"})]}),e.jsxs("linearGradient",{id:"c",x1:26.598,x2:5.816,y1:46.502,y2:10.506,gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1e8e3e"}),e.jsx("stop",{offset:1,stopColor:"#34a853"})]})]}),e.jsx("circle",{cx:24,cy:23.995,r:12,style:{fill:"#fff"}}),e.jsx("path",{d:"M3.215 36A24 24 0 1 0 12 3.215 24 24 0 0 0 3.215 36Zm31.177-18A12 12 0 1 1 18 13.608 12 12 0 0 1 34.392 18Z",style:{fill:"none"}}),e.jsx("path",{d:"M24 12h20.781a23.994 23.994 0 0 0-41.564.003L13.607 30l.01-.002A11.985 11.985 0 0 1 24 12Z",style:{fill:"url(#a)"}}),e.jsx("circle",{cx:24,cy:24,r:9.5,style:{fill:"#1a73e8"}}),e.jsx("path",{d:"M34.391 30.003 24.001 48A23.994 23.994 0 0 0 44.78 12.003H23.999l-.003.01a11.985 11.985 0 0 1 10.395 17.99Z",style:{fill:"url(#b)"}}),e.jsx("path",{d:"M13.609 30.003 3.218 12.006A23.994 23.994 0 0 0 24.003 48l10.39-17.997-.007-.007a11.985 11.985 0 0 1-20.777.007Z",style:{fill:"url(#c)"}})]}),Pv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:512,height:512,viewBox:"0 0 512 512",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"g",cx:"210%",cy:"-100%",r:"290%",children:[e.jsx("stop",{offset:.1,stopColor:"#ffe226"}),e.jsx("stop",{offset:.79,stopColor:"#ff7139"})]}),e.jsxs("radialGradient",{id:"c",cx:"49%",cy:"40%",r:"128%",gradientTransform:"matrix(.82 0 0 1 .088 0)",children:[e.jsx("stop",{offset:.3,stopColor:"#960e18"}),e.jsx("stop",{offset:.35,stopColor:"#b11927",stopOpacity:.74}),e.jsx("stop",{offset:.43,stopColor:"#db293d",stopOpacity:.34}),e.jsx("stop",{offset:.5,stopColor:"#f5334b",stopOpacity:.09}),e.jsx("stop",{offset:.53,stopColor:"#ff3750",stopOpacity:0})]}),e.jsxs("radialGradient",{id:"d",cx:"48%",cy:"-12%",r:"140%",children:[e.jsx("stop",{offset:.13,stopColor:"#fff44f"}),e.jsx("stop",{offset:.53,stopColor:"#ff980e"})]}),e.jsxs("radialGradient",{id:"e",cx:"22.76%",cy:"110.11%",r:"100%",children:[e.jsx("stop",{offset:.35,stopColor:"#3a8ee6"}),e.jsx("stop",{offset:.67,stopColor:"#9059ff"}),e.jsx("stop",{offset:1,stopColor:"#c139e6"})]}),e.jsxs("radialGradient",{id:"f",cx:"52%",cy:"33%",r:"59%",gradientTransform:"scale(.9 1)",children:[e.jsx("stop",{offset:.21,stopColor:"#9059ff",stopOpacity:0}),e.jsx("stop",{offset:.97,stopColor:"#6e008b",stopOpacity:.6})]}),e.jsxs("radialGradient",{id:"b",cx:"87.4%",cy:"-12.9%",r:"128%",gradientTransform:"matrix(.8 0 0 1 .178 .129)",children:[e.jsx("stop",{offset:.13,stopColor:"#ffbd4f"}),e.jsx("stop",{offset:.28,stopColor:"#ff980e"}),e.jsx("stop",{offset:.47,stopColor:"#ff3750"}),e.jsx("stop",{offset:.78,stopColor:"#eb0878"}),e.jsx("stop",{offset:.86,stopColor:"#e50080"})]}),e.jsxs("radialGradient",{id:"h",cx:"84%",cy:"-41%",r:"180%",children:[e.jsx("stop",{offset:.11,stopColor:"#fff44f"}),e.jsx("stop",{offset:.46,stopColor:"#ff980e"}),e.jsx("stop",{offset:.72,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"i",cx:"16.1%",cy:"-18.6%",r:"348.8%",gradientTransform:"scale(1 .47) rotate(84 .279 -.297)",children:[e.jsx("stop",{offset:0,stopColor:"#fff44f"}),e.jsx("stop",{offset:.3,stopColor:"#ff980e"}),e.jsx("stop",{offset:.57,stopColor:"#ff3647"}),e.jsx("stop",{offset:.74,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"j",cx:"18.9%",cy:"-42.5%",r:"238.4%",children:[e.jsx("stop",{offset:.14,stopColor:"#fff44f"}),e.jsx("stop",{offset:.48,stopColor:"#ff980e"}),e.jsx("stop",{offset:.66,stopColor:"#ff3647"}),e.jsx("stop",{offset:.9,stopColor:"#e31587"})]}),e.jsxs("radialGradient",{id:"k",cx:"159.3%",cy:"-44.72%",r:"313.1%",children:[e.jsx("stop",{offset:.09,stopColor:"#fff44f"}),e.jsx("stop",{offset:.63,stopColor:"#ff980e"})]}),e.jsxs("linearGradient",{id:"a",x1:"87.25%",x2:"9.4%",y1:"15.5%",y2:"93.1%",children:[e.jsx("stop",{offset:.05,stopColor:"#fff44f"}),e.jsx("stop",{offset:.37,stopColor:"#ff980e"}),e.jsx("stop",{offset:.53,stopColor:"#ff3647"}),e.jsx("stop",{offset:.7,stopColor:"#e31587"})]}),e.jsxs("linearGradient",{id:"l",x1:"80%",x2:"18%",y1:"14%",y2:"84%",children:[e.jsx("stop",{offset:.17,stopColor:"#fff44f",stopOpacity:.8}),e.jsx("stop",{offset:.6,stopColor:"#fff44f",stopOpacity:0})]})]}),e.jsx("path",{fill:"url(#a)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484a120.249 120.249 0 0 0-66.142 25.488 71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.913c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.08 12.7-2.365 15-.022.177-.032.347-.053.524a229.066 229.066 0 0 0-3.9 33.157c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zM201.716 354.447c1.124.537 2.18 1.124 3.334 1.639.048.033.114.07.163.1a126.191 126.191 0 0 1-3.497-1.739zm55.053-144.93zm198.131-30.59-.032-.233c.012.085.027.174.04.259z"}),e.jsx("path",{fill:"url(#b)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#c)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0-.058.011.048.036.226.012.085.027.174.04.259 22.675 61.47 10.322 123.978-7.479 162.175-27.539 59.1-94.215 119.67-198.576 116.716C136.1 454.651 36.766 370.988 18.223 261.41c-3.379-17.28 0-26.054 1.7-40.084-2.071 10.816-2.86 13.94-3.9 33.157 0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746z"}),e.jsx("path",{fill:"url(#d)",d:"M361.922 194.6c.524.368 1 .734 1.493 1.1a130.706 130.706 0 0 0-22.31-29.112C266.4 91.892 321.516 4.626 330.811.194c.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.051 0 84.289 24.77 105.301 61.487z"}),e.jsx("path",{fill:"url(#e)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#f)",d:"M256.772 209.514c-.393 5.978-21.514 26.593-28.9 26.593-68.339 0-79.432 41.335-79.432 41.335 3.027 34.81 27.261 63.475 56.611 78.643 1.339.692 2.694 1.317 4.05 1.935a132.768 132.768 0 0 0 7.059 2.886 106.743 106.743 0 0 0 31.271 6.031c119.78 5.618 142.986-143.194 56.545-186.408 22.137-3.85 45.115 5.053 57.947 14.067-21.012-36.714-60.25-61.484-105.3-61.484-2.85 0-5.641.235-8.442.429a120.249 120.249 0 0 0-66.142 25.488c3.664 3.1 7.8 7.244 16.514 15.828 16.302 16.067 58.13 32.705 58.219 34.657z"}),e.jsx("path",{fill:"url(#g)",d:"M170.829 151.036a244.042 244.042 0 0 1 4.981 3.3 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7 1.155-.033 36.014-.66 53.543 10.732z"}),e.jsx("path",{fill:"url(#h)",d:"M18.223 261.41C36.766 370.988 136.1 454.651 248.855 457.844c104.361 2.954 171.037-57.62 198.576-116.716 17.8-38.2 30.154-100.7 7.479-162.175l-.008-.026-.032-.233c-.025-.178-.04-.284-.036-.226 0 .039.015.136.047.4 8.524 55.661-19.79 109.584-64.051 146.044l-.133.313c-86.245 70.223-168.774 42.368-185.484 30.966a144.108 144.108 0 0 1-3.5-1.743c-50.282-24.029-71.054-69.838-66.6-109.124-42.457 0-56.934-35.809-56.934-35.809s38.119-27.179 88.358-3.541c46.53 21.893 90.228 3.543 90.233 3.541-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 282.929 282.929 0 0 0-4.981-3.3c-17.528-11.392-52.388-10.765-53.543-10.735h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.442 26.919c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-8.65 37.842-4.44 57.199z"}),e.jsx("path",{fill:"url(#i)",d:"M341.105 166.587a130.706 130.706 0 0 1 22.31 29.112c1.323.994 2.559 1.985 3.608 2.952 54.482 50.2 25.936 121.2 23.807 126.26 44.261-36.46 72.575-90.383 64.051-146.044C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1-9.291 4.428-64.407 91.694 10.298 166.389z"}),e.jsx("path",{fill:"url(#j)",d:"M367.023 198.651c-1.049-.967-2.285-1.958-3.608-2.952-.489-.368-.969-.734-1.493-1.1-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1 16.71 11.4 99.239 39.257 185.484-30.966l.133-.313c2.129-5.054 30.675-76.057-23.807-126.258z"}),e.jsx("path",{fill:"url(#k)",d:"M148.439 277.443s11.093-41.335 79.432-41.335c7.388 0 28.509-20.615 28.9-26.593s-43.7 18.352-90.233-3.541c-50.239-23.638-88.358 3.541-88.358 3.541s14.477 35.809 56.934 35.809c-4.453 39.286 16.319 85.1 66.6 109.124 1.124.537 2.18 1.124 3.334 1.639-29.348-15.169-53.582-43.834-56.609-78.644z"}),e.jsx("path",{fill:"url(#l)",d:"M478.711 166.353c-10.445-25.124-31.6-52.248-48.212-60.821 13.52 26.505 21.345 53.093 24.335 72.936 0 .039.015.136.047.4C427.706 111.135 381.627 83.823 344 24.355c-1.9-3.007-3.805-6.022-5.661-9.2a73.716 73.716 0 0 1-2.646-4.972A43.7 43.7 0 0 1 332.1.677a.626.626 0 0 0-.546-.644.818.818 0 0 0-.451 0c-.034.012-.084.051-.12.065-.053.021-.12.069-.176.1.027-.036.083-.117.1-.136-60.37 35.356-80.85 100.761-82.732 133.484 2.8-.194 5.592-.429 8.442-.429 45.053 0 84.291 24.77 105.3 61.484-12.832-9.014-35.81-17.917-57.947-14.067 86.441 43.214 63.235 192.026-56.545 186.408a106.743 106.743 0 0 1-31.271-6.031 134.51 134.51 0 0 1-7.059-2.886c-1.356-.618-2.711-1.243-4.05-1.935.048.033.114.07.163.1a144.108 144.108 0 0 1-3.5-1.743c1.124.537 2.18 1.124 3.334 1.639-29.35-15.168-53.584-43.833-56.611-78.643 0 0 11.093-41.335 79.432-41.335 7.388 0 28.509-20.615 28.9-26.593-.089-1.952-41.917-18.59-58.223-34.656-8.713-8.584-12.85-12.723-16.514-15.828a71.355 71.355 0 0 0-6.225-4.7 111.338 111.338 0 0 1-.674-58.732c-24.688 11.241-43.89 29.01-57.85 44.7h-.111c-9.527-12.067-8.855-51.873-8.312-60.184-.114-.515-7.107 3.63-8.023 4.255a175.073 175.073 0 0 0-23.486 20.12 210.478 210.478 0 0 0-22.435 26.916c0 .012-.007.026-.011.038 0-.013.007-.026.011-.038a202.838 202.838 0 0 0-32.247 72.805c-.115.521-.212 1.061-.324 1.586-.452 2.116-2.486 12.853-2.77 15.156-.022.177.021-.176 0 0a279.565 279.565 0 0 0-3.544 33.53c0 .41-.025.816-.025 1.227C16 388.418 123.6 496 256.324 496c118.865 0 217.56-86.288 236.882-199.63.407-3.076.733-6.168 1.092-9.271 4.777-41.21-.53-84.525-15.587-120.746zm-23.841 12.341c.012.085.027.174.04.259l-.008-.026-.032-.233z"})]}),Rv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",width:250.076,height:248.707,viewBox:"0 0 66.166 65.804",...t,children:[e.jsxs("defs",{children:[e.jsxs("linearGradient",{id:"b",children:[e.jsx("stop",{offset:0,stopColor:"#06c2e7"}),e.jsx("stop",{offset:.25,stopColor:"#0db8ec"}),e.jsx("stop",{offset:.5,stopColor:"#12aef1"}),e.jsx("stop",{offset:.75,stopColor:"#1f86f9"}),e.jsx("stop",{offset:1,stopColor:"#107ddd"})]}),e.jsxs("linearGradient",{id:"a",children:[e.jsx("stop",{offset:0,stopColor:"#bdbdbd"}),e.jsx("stop",{offset:1,stopColor:"#fff"})]}),e.jsx("linearGradient",{xlinkHref:"#a",id:"d",x1:412.975,x2:412.975,y1:237.608,y2:59.392,gradientTransform:"translate(206.79 159.773) scale(.35154)",gradientUnits:"userSpaceOnUse"}),e.jsx("filter",{id:"f",width:1.042,height:1.045,x:-.021,y:-.022,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:.958})}),e.jsx("filter",{id:"c",width:1.096,height:1.096,x:-.048,y:-.048,colorInterpolationFilters:"sRGB",children:e.jsx("feGaussianBlur",{stdDeviation:3.564})}),e.jsx("radialGradient",{xlinkHref:"#b",id:"e",cx:413.061,cy:136.818,r:82.125,fx:413.061,fy:136.818,gradientTransform:"translate(194.545 155.58) scale(.38143)",gradientUnits:"userSpaceOnUse"})]}),e.jsx("path",{d:"M502.083 148.5a89.108 89.108 0 0 1-89.108 89.108 89.108 89.108 0 0 1-89.108-89.108 89.108 89.108 0 0 1 89.108-89.108 89.108 89.108 0 0 1 89.108 89.108Z",filter:"url(#c)",opacity:.53,paintOrder:"markers stroke fill",transform:"matrix(.33865 0 0 .3261 -106.77 -14.478)"}),e.jsx("path",{fill:"url(#d)",stroke:"#cdcdcd",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:.093,d:"M383.294 211.977a31.325 31.325 0 0 1-31.325 31.325 31.325 31.325 0 0 1-31.326-31.325 31.325 31.325 0 0 1 31.326-31.325 31.325 31.325 0 0 1 31.325 31.325z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"url(#e)",d:"M380.84 211.977a28.87 28.87 0 0 1-28.871 28.87 28.87 28.87 0 0 1-28.871-28.87 28.87 28.87 0 0 1 28.87-28.87 28.87 28.87 0 0 1 28.871 28.87z",paintOrder:"markers stroke fill",transform:"translate(-318.886 -180.595)"}),e.jsx("path",{fill:"#f4f2f3",d:"M33.083 4.017a.42.42 0 0 0-.421.42v4.856a.42.42 0 1 0 .842 0V4.438a.42.42 0 0 0-.421-.421zm-2.754.174a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.087l-.212-2.03a.42.42 0 0 0-.377-.376zm5.527.002a.42.42 0 0 0-.377.375l-.214 2.03a.42.42 0 1 0 .837.089l.214-2.031a.42.42 0 0 0-.46-.463zM27.5 4.6a.42.42 0 0 0-.41.508l1.005 4.75a.42.42 0 1 0 .824-.174l-1.005-4.75A.42.42 0 0 0 27.5 4.6zm11.183.004a.42.42 0 0 0-.414.333l-1.009 4.75a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm-13.883.757a.42.42 0 0 0-.437.55l.632 1.942a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm16.568.001a.42.42 0 0 0-.364.29l-.632 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.436-.55zM22.13 6.34a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm21.937.015a.42.42 0 0 0-.392.25l-1.978 4.434a.42.42 0 1 0 .769.343l1.978-4.434a.42.42 0 0 0-.377-.593zM19.654 7.65a.42.42 0 0 0-.394.63l1.02 1.77a.42.42 0 1 0 .73-.421L19.989 7.86a.42.42 0 0 0-.335-.21zm26.858 0a.419.419 0 0 0-.335.21l-1.021 1.769a.42.42 0 1 0 .73.42l1.02-1.768a.42.42 0 0 0-.394-.63zm-29.265 1.5a.422.422 0 0 0-.326.669l2.85 3.93a.42.42 0 1 0 .682-.494l-2.85-3.93a.42.42 0 0 0-.356-.174zm31.702.022a.42.42 0 0 0-.356.174l-2.856 3.926a.42.42 0 1 0 .681.495l2.856-3.926a.42.42 0 0 0-.325-.669zm-33.852 1.783a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.14zm35.975.003a.421.421 0 0 0-.29.139l-1.367 1.517a.42.42 0 1 0 .625.564l1.367-1.518a.42.42 0 0 0-.335-.702zm-38.037 1.977a.42.42 0 0 0-.26.733l3.61 3.249a.42.42 0 1 0 .563-.626l-3.609-3.248a.42.42 0 0 0-.304-.108zm40.109.014a.419.419 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm-41.823 2.19a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm43.535.015a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.681l1.653-1.2a.42.42 0 0 0-.262-.76zM9.72 17.49a.42.42 0 0 0-.18.785l4.204 2.427a.42.42 0 1 0 .42-.729L9.96 17.546a.42.42 0 0 0-.24-.056zm46.728 0a.417.417 0 0 0-.24.056l-4.205 2.427a.42.42 0 1 0 .42.73l4.206-2.428a.42.42 0 0 0-.181-.785zM8.508 19.996a.42.42 0 0 0-.18.806l1.866.832a.42.42 0 1 0 .343-.77l-1.866-.831a.42.42 0 0 0-.163-.037zm49.158.017a.42.42 0 0 0-.164.037l-1.865.83a.42.42 0 1 0 .342.77l1.866-.831a.42.42 0 0 0-.179-.806zM7.429 22.615a.42.42 0 0 0-.094.82l4.615 1.504a.42.42 0 1 0 .261-.8l-4.616-1.504a.421.421 0 0 0-.166-.02zm51.314.018a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zM6.756 25.365a.42.42 0 0 0-.09.833l1.998.424a.42.42 0 1 0 .175-.823l-1.998-.425a.413.413 0 0 0-.085-.009zm52.655.004a.518.518 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zM6.247 28.13a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.829-.51a.432.432 0 0 0-.085 0zm53.676.037a.386.386 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.837l4.83-.504a.42.42 0 0 0-.003-.837zM6.165 30.96a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm51.793 0a.42.42 0 1 0 0 .842h2.043a.42.42 0 1 0 0-.842zm-46.803 2.295a.384.384 0 0 0-.085 0l-4.83.504a.42.42 0 1 0 .088.838l4.83-.504a.42.42 0 0 0-.003-.838zm43.853.03a.42.42 0 0 0-.003.838l4.828.51a.42.42 0 1 0 .089-.837l-4.828-.51a.434.434 0 0 0-.086-.001zM8.748 36.13a.43.43 0 0 0-.085.009l-1.998.424a.42.42 0 1 0 .175.823l1.998-.424a.42.42 0 0 0-.09-.833zm48.67.004a.42.42 0 0 0-.09.833l1.997.424a.42.42 0 1 0 .175-.824l-1.998-.424a.413.413 0 0 0-.085-.01zM12.111 37.79a.408.408 0 0 0-.166.02l-4.617 1.5a.42.42 0 1 0 .26.801l4.617-1.5a.42.42 0 0 0-.094-.82zm41.937.015a.42.42 0 0 0-.094.82l4.616 1.504a.42.42 0 1 0 .26-.8l-4.615-1.504a.421.421 0 0 0-.167-.02zM10.35 41.08a.42.42 0 0 0-.163.036l-1.866.831a.42.42 0 1 0 .342.769l1.866-.83a.42.42 0 0 0-.179-.806zm45.459.016a.42.42 0 0 0-.18.805l1.865.832a.42.42 0 1 0 .343-.769l-1.865-.832a.42.42 0 0 0-.163-.036zm-41.826.912a.417.417 0 0 0-.24.056L9.538 44.49a.42.42 0 1 0 .421.73l4.205-2.428a.42.42 0 0 0-.181-.785zm38.2 0a.42.42 0 0 0-.181.785l4.205 2.427a.42.42 0 1 0 .42-.729l-4.204-2.427a.42.42 0 0 0-.24-.056zm-39.249 3.562a.421.421 0 0 0-.233.08l-1.653 1.2a.42.42 0 1 0 .495.682l1.653-1.2a.42.42 0 0 0-.262-.762zm40.288.015a.42.42 0 0 0-.262.762l1.652 1.2a.42.42 0 1 0 .495-.681l-1.652-1.2a.42.42 0 0 0-.233-.081zm-36.544.145a.418.418 0 0 0-.304.108l-3.61 3.245a.42.42 0 1 0 .562.626l3.61-3.245a.42.42 0 0 0-.258-.734zm32.8.011a.421.421 0 0 0-.26.734l3.609 3.248a.42.42 0 1 0 .563-.625l-3.608-3.249a.42.42 0 0 0-.304-.107zm-29.375 3.084a.42.42 0 0 0-.355.173l-2.856 3.927a.42.42 0 1 0 .68.495l2.857-3.926a.42.42 0 0 0-.326-.669zm25.936.018a.421.421 0 0 0-.326.668l2.85 3.93a.42.42 0 1 0 .682-.494l-2.851-3.93a.42.42 0 0 0-.355-.174zm-29.623.606a.421.421 0 0 0-.29.14l-1.367 1.517a.42.42 0 1 0 .625.563l1.367-1.517a.42.42 0 0 0-.335-.703zm33.331.002a.42.42 0 0 0-.335.702l1.366 1.518a.42.42 0 1 0 .626-.563l-1.366-1.518a.42.42 0 0 0-.291-.139zm-25.655 1.684a.419.419 0 0 0-.393.25l-1.978 4.433a.42.42 0 1 0 .77.343l1.977-4.434a.42.42 0 0 0-.376-.592zm17.955.012a.42.42 0 0 0-.377.592l1.972 4.437a.42.42 0 1 0 .77-.342l-1.972-4.437a.42.42 0 0 0-.393-.25zm-21.431 1.359a.419.419 0 0 0-.335.21l-1.021 1.768a.42.42 0 1 0 .729.421l1.02-1.769a.42.42 0 0 0-.393-.63zm24.934 0a.42.42 0 0 0-.394.63l1.021 1.77a.42.42 0 1 0 .73-.422l-1.022-1.769a.42.42 0 0 0-.335-.21zm-17.054.063a.42.42 0 0 0-.415.334l-1.009 4.749a.42.42 0 1 0 .824.175l1.009-4.75a.42.42 0 0 0-.41-.508zm9.16.003a.42.42 0 0 0-.41.508l1.006 4.75a.42.42 0 1 0 .823-.175l-1.006-4.75a.42.42 0 0 0-.414-.333zm-4.573.48a.42.42 0 0 0-.421.42v4.855a.42.42 0 1 0 .842 0v-4.855a.42.42 0 0 0-.421-.42zm-7.727 1.568a.42.42 0 0 0-.364.29l-.631 1.942a.42.42 0 1 0 .8.26l.632-1.942a.42.42 0 0 0-.437-.55zm15.45 0a.42.42 0 0 0-.437.55l.632 1.943a.42.42 0 1 0 .8-.26l-.63-1.942a.42.42 0 0 0-.365-.29zm-10.365 1.083a.42.42 0 0 0-.378.375l-.213 2.03a.42.42 0 1 0 .837.088l.214-2.03a.42.42 0 0 0-.46-.463zm5.267.002a.42.42 0 0 0-.46.463l.212 2.03a.42.42 0 1 0 .837-.088l-.212-2.03a.42.42 0 0 0-.377-.375z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m469.096 100.607-65.51 38.061-41.42 65.207 60.595-44.882z",filter:"url(#f)",opacity:.409,paintOrder:"markers stroke fill",transform:"translate(-112.095 -20.822) scale(.35154)"}),e.jsx("path",{fill:"#ff5150",d:"m36.383 34.838-6.6-6.913 23.416-15.752z",paintOrder:"markers stroke fill"}),e.jsx("path",{fill:"#f1f1f1",d:"m36.383 34.838-6.6-6.913L12.966 50.59z",paintOrder:"markers stroke fill"}),e.jsx("path",{d:"m12.967 50.59 23.416-15.752L53.2 12.173z",opacity:.243})]}),Iv=t=>e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256",...t,children:[e.jsxs("defs",{children:[e.jsxs("radialGradient",{id:"b",cx:161.8,cy:68.9,r:95.4,gradientTransform:"matrix(1 0 0 -.95 0 248.8)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.7,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"d",cx:-340.3,cy:63,r:143.2,gradientTransform:"matrix(.15 -.99 -.8 -.12 176.6 -125.4)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:.8,stopOpacity:0}),e.jsx("stop",{offset:.9,stopOpacity:.5}),e.jsx("stop",{offset:1})]}),e.jsxs("radialGradient",{id:"e",cx:113.4,cy:570.2,r:202.4,gradientTransform:"matrix(-.04 1 2.13 .08 -1179.5 -106.7)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#35c1f1"}),e.jsx("stop",{offset:.1,stopColor:"#34c1ed"}),e.jsx("stop",{offset:.2,stopColor:"#2fc2df"}),e.jsx("stop",{offset:.3,stopColor:"#2bc3d2"}),e.jsx("stop",{offset:.7,stopColor:"#36c752"})]}),e.jsxs("radialGradient",{id:"f",cx:376.5,cy:568,r:97.3,gradientTransform:"matrix(.28 .96 .78 -.23 -303.8 -148.5)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#66eb6e"}),e.jsx("stop",{offset:1,stopColor:"#66eb6e",stopOpacity:0})]}),e.jsxs("linearGradient",{id:"a",x1:63.3,x2:241.7,y1:84,y2:84,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#0c59a4"}),e.jsx("stop",{offset:1,stopColor:"#114a8b"})]}),e.jsxs("linearGradient",{id:"c",x1:157.3,x2:46,y1:161.4,y2:40.1,gradientTransform:"matrix(1 0 0 -1 0 266)",gradientUnits:"userSpaceOnUse",children:[e.jsx("stop",{offset:0,stopColor:"#1b9de2"}),e.jsx("stop",{offset:.2,stopColor:"#1595df"}),e.jsx("stop",{offset:.7,stopColor:"#0680d7"}),e.jsx("stop",{offset:1,stopColor:"#0078d4"})]})]}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{fill:"url(#a)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M235.7 195.5a93.7 93.7 0 0 1-10.6 4.7 101.9 101.9 0 0 1-35.9 6.4c-47.3 0-88.5-32.5-88.5-74.3a31.5 31.5 0 0 1 16.4-27.3c-42.8 1.8-53.8 46.4-53.8 72.5 0 74 68.1 81.4 82.8 81.4 7.9 0 19.8-2.3 27-4.6l1.3-.4a128.3 128.3 0 0 0 66.6-52.8 4 4 0 0 0-5.3-5.6Z",style:{isolation:"isolate",opacity:.35,fill:"url(#b)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{fill:"url(#c)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M110.3 246.3A79.2 79.2 0 0 1 87.6 225a80.7 80.7 0 0 1 29.5-120c3.2-1.5 8.5-4.1 15.6-4a32.4 32.4 0 0 1 25.7 13 31.9 31.9 0 0 1 6.3 18.7c0-.2 24.5-79.6-80-79.6-43.9 0-80 41.6-80 78.2a130.2 130.2 0 0 0 12.1 56 128 128 0 0 0 156.4 67 75.5 75.5 0 0 1-62.8-8Z",style:{opacity:.41,fill:"url(#d)",isolation:"isolate"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#e)"},transform:"translate(-4.6 -5)"}),e.jsx("path",{d:"M157 153.8c-.9 1-3.4 2.5-3.4 5.6 0 2.6 1.7 5.2 4.8 7.3 14.3 10 41.4 8.6 41.5 8.6a59.6 59.6 0 0 0 30.3-8.3 61.4 61.4 0 0 0 30.4-52.9c.3-22.4-8-37.3-11.3-43.9C228 28.8 182.3 5 132.6 5a128 128 0 0 0-128 126.2c.5-36.5 36.8-66 80-66 3.5 0 23.5.3 42 10a72.6 72.6 0 0 1 30.9 29.3c6.1 10.6 7.2 24.1 7.2 29.5s-2.7 13.3-7.8 19.9Z",style:{fill:"url(#f)"},transform:"translate(-4.6 -5)"})]}),Tv=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Opera",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"opera-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FF1B2D"}),e.jsx("stop",{offset:"50%",stopColor:"#CC0000"}),e.jsx("stop",{offset:"100%",stopColor:"#A02128"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#opera-gradient)"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"6.5",ry:"8.5",fill:"none",stroke:"#fff",strokeWidth:"1.2",opacity:"0.9"}),e.jsx("ellipse",{cx:"12",cy:"12",rx:"3.5",ry:"5.5",fill:"#fff"}),e.jsx("path",{d:"M12 8.5c-1.4 0-2.5 1.6-2.5 3.5s1.1 3.5 2.5 3.5 2.5-1.6 2.5-3.5-1.1-3.5-2.5-3.5z",fill:"url(#opera-gradient)"})]}),Ov=t=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",...t,role:"img","aria-label":"Brave",children:[e.jsx("defs",{children:e.jsxs("linearGradient",{id:"brave-gradient",x1:"0%",y1:"0%",x2:"100%",y2:"100%",children:[e.jsx("stop",{offset:"0%",stopColor:"#FB542B"}),e.jsx("stop",{offset:"50%",stopColor:"#FF6B35"}),e.jsx("stop",{offset:"100%",stopColor:"#FF4500"})]})}),e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"url(#brave-gradient)"}),e.jsx("path",{d:"M12 3.5l1.5 2h2.5l-.8 3 1.3 2.5-2.5.8v2.7l-2-.7-2 .7v-2.7l-2.5-.8L8.8 8.5 8 5.5h2.5L12 3.5z",fill:"#fff"}),e.jsx("path",{d:"M12 6.5c-.8 0-1.5.7-1.5 1.5v3c0 .8.7 1.5 1.5 1.5s1.5-.7 1.5-1.5V8c0-.8-.7-1.5-1.5-1.5z",fill:"url(#brave-gradient)"}),e.jsx("circle",{cx:"12",cy:"16",r:"1",fill:"url(#brave-gradient)"})]}),Mv=Nt`
|
|
4104
4104
|
0% { transform: rotate(0deg); }
|
|
4105
4105
|
100% { transform: rotate(360deg); }
|
|
4106
4106
|
`,Av=h.div`
|
|
@@ -4235,7 +4235,7 @@ cursor: pointer;
|
|
|
4235
4235
|
flex-wrap: wrap;
|
|
4236
4236
|
gap: 12px;
|
|
4237
4237
|
margin-bottom: 0;
|
|
4238
|
-
`,Nv=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),Bv=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx($v,{...o}):r.includes("firefox")?e.jsx(Pv,{...o}):r.includes("safari")?e.jsx(Rv,{...o}):r.includes("edge")?e.jsx(Iv,{...o}):r.includes("opera")?e.jsx(Tv,{...o}):r.includes("brave")?e.jsx(Ov,{...o}):e.jsx(Nv,{})},Uv=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:a,loading:s}=Ec(),{refetch:p}=He(),{toast:f}=Ut(),c=o,d=async u=>{try{await n(u),await Promise.all([a(),p()]),r(null),f("Session ended successfully","info")}catch(m){f(m.message||"Failed to end session. Please try again.","error")}},l=u=>{if(!u||u.trim()==="")return"Unknown";const m=new Date(u);if(isNaN(m.getTime()))return"Unknown";const x=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return x<1?"Just now":x<60?`${x}m ago`:x<1440?`${Math.floor(x/60)}h ago`:m.toLocaleDateString()};return s?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:c&&c.length>0?e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Browser & Device"}),e.jsx(ke,{children:"Location"}),e.jsx(ke,{children:"Last Active"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:c.map(u=>e.jsxs(Ve,{children:[e.jsx(De,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(hd,{children:e.jsx(Bv,{browser:u.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:u.browser||"Unknown Browser"}),u.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.device})]})]})}),e.jsx(De,{children:e.jsxs("div",{children:[e.jsx("div",{children:u.city&&u.country?`${u.city}, ${u.country}`:"Unknown location"}),u.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.ip_address})]})}),e.jsx(De,{children:l(u.last_active_at)}),e.jsx(yt,{children:e.jsxs(it,{open:t===u.id,openChange:m=>r(m?u.id:null),children:[e.jsx(lt,{children:e.jsx(dn,{children:"•••"})}),e.jsx(ct,{children:e.jsx(Le,{onClick:()=>d(u.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ot,{size:14}),"End Session"]})})})]})})]},u.id))})]}):e.jsx(dt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},Wv=()=>{var b,g,C,E;const{deployment:t}=xe(),{toast:r}=Ut(),[o,n]=i.useState(null),[a,s]=i.useState(""),[p,f]=i.useState(!1),[c,d]=i.useState(null),[l,u]=i.useState(""),m=i.useRef(null),v=i.useRef({}),{user:x,createEmailAddress:y,deleteEmailAddress:
|
|
4238
|
+
`,Nv=()=>e.jsxs("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",style:{color:"var(--color-secondary-text)"},children:[e.jsx("circle",{cx:"12",cy:"12",r:"11",fill:"currentColor",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.6"}),e.jsx("circle",{cx:"12",cy:"12",r:"8",fill:"none",stroke:"currentColor",strokeWidth:"0.5",opacity:"0.3"}),e.jsx("path",{d:"M12 8c-2.2 0-4 1.8-4 4s1.8 4 4 4 4-1.8 4-4-1.8-4-4-4zm0 6c-1.1 0-2-.9-2-2s.9-2 2-2 2 .9 2 2-.9 2-2 2z",fill:"currentColor",opacity:"0.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1",fill:"currentColor"}),e.jsx("text",{x:"12",y:"16.5",textAnchor:"middle",fill:"currentColor",fontSize:"6",opacity:"0.7",children:"?"})]}),Bv=({browser:t})=>{const r=(t==null?void 0:t.toLowerCase())||"",o={width:20,height:20};return r.includes("chrome")?e.jsx($v,{...o}):r.includes("firefox")?e.jsx(Pv,{...o}):r.includes("safari")?e.jsx(Rv,{...o}):r.includes("edge")?e.jsx(Iv,{...o}):r.includes("opera")?e.jsx(Tv,{...o}):r.includes("brave")?e.jsx(Ov,{...o}):e.jsx(Nv,{})},Uv=()=>{const[t,r]=i.useState(null),{signins:o,removeSignin:n,refetch:a,loading:s}=Ec(),{refetch:p}=He(),{toast:f}=Ut(),c=o,d=async u=>{try{await n(u),await Promise.all([a(),p()]),r(null),f("Session ended successfully","info")}catch(m){f(m.message||"Failed to end session. Please try again.","error")}},l=u=>{if(!u||u.trim()==="")return"Unknown";const m=new Date(u);if(isNaN(m.getTime()))return"Unknown";const x=Math.floor((new Date().getTime()-m.getTime())/(1e3*60));return x<1?"Just now":x<60?`${x}m ago`:x<1440?`${Math.floor(x/60)}h ago`:m.toLocaleDateString()};return s?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"20px"},children:e.jsx($e,{})}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:0},children:"Active Sessions"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Manage your active browser sessions and sign-ins"})]}),e.jsx("div",{children:c&&c.length>0?e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Browser & Device"}),e.jsx(ke,{children:"Location"}),e.jsx(ke,{children:"Last Active"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:c.map(u=>e.jsxs(Ve,{children:[e.jsx(De,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(hd,{children:e.jsx(Bv,{browser:u.browser||"Unknown"})}),e.jsxs("div",{children:[e.jsx("div",{children:u.browser||"Unknown Browser"}),u.device&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.device})]})]})}),e.jsx(De,{children:e.jsxs("div",{children:[e.jsx("div",{children:u.city&&u.country?`${u.city}, ${u.country}`:"Unknown location"}),u.ip_address&&e.jsx("div",{style:{fontSize:"12px",color:"var(--color-muted)"},children:u.ip_address})]})}),e.jsx(De,{children:l(u.last_active_at)}),e.jsx(yt,{children:e.jsxs(it,{open:t===u.id,openChange:m=>r(m?u.id:null),children:[e.jsx(lt,{children:e.jsx(dn,{children:"•••"})}),e.jsx(ct,{children:e.jsx(Le,{onClick:()=>d(u.id),children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(Ot,{size:14}),"End Session"]})})})]})})]},u.id))})]}):e.jsx(dt,{title:"No active sessions",description:"You don't have any active sessions at the moment."})})]})},Wv=()=>{var b,g,C,E;const{deployment:t}=xe(),{toast:r}=Ut(),[o,n]=i.useState(null),[a,s]=i.useState(""),[p,f]=i.useState(!1),[c,d]=i.useState(null),[l,u]=i.useState(""),m=i.useRef(null),v=i.useRef({}),{user:x,createEmailAddress:y,deleteEmailAddress:k,prepareEmailVerification:z,attemptEmailVerification:S,makeEmailPrimary:_}=Ft();if(!((g=(b=t==null?void 0:t.auth_settings)==null?void 0:b.email_address)!=null&&g.enabled))return null;const $=async j=>{try{if(j===(x==null?void 0:x.primary_email_address_id)){r("Cannot delete primary email address. Please set another email as primary first.","error");return}await k(j),x.refetch(),r("Email address deleted successfully","info")}catch(T){r(T.message||"Failed to delete email address. Please try again.","error")}},w=i.useMemo(()=>x!=null&&x.user_email_addresses?l.trim()?x.user_email_addresses.filter(j=>j.email.toLowerCase().includes(l.toLowerCase())):x.user_email_addresses:[],[x==null?void 0:x.user_email_addresses,l]);return e.jsxs(e.Fragment,{children:[e.jsxs(Zo,{style:{marginBottom:"20px"},children:[e.jsx(Pt,{value:l,onChange:u,placeholder:"Search Email"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:m,onClick:()=>f(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Email"}),p&&e.jsx(Pi,{triggerRef:m,onClose:()=>f(!1),onAddEmail:async j=>{const T=await y(j);s(T.data.id),await z(T.data.id),x.refetch()},onPrepareVerification:async()=>{await z(a),x.refetch()},onAttemptVerification:async j=>{await S(a,j),x.refetch(),f(!1),s(""),r("Email added and verified successfully!","info")}})]})]}),w!=null&&w.length?e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Email Address"}),e.jsx(ke,{children:"Status"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:w.map(j=>e.jsxs(Ve,{children:[e.jsx(De,{children:j.email}),e.jsx(De,{children:j.id===(x==null?void 0:x.primary_email_address_id)?"Primary":j.verified?"Verified":"Not Verified"}),e.jsx(yt,{children:j.id!==(x==null?void 0:x.primary_email_address_id)||!j.verified?e.jsxs(it,{open:o===j.id,openChange:T=>n(T?j.id:null),children:[e.jsx(lt,{children:e.jsx(dn,{ref:T=>{T&&(v.current[j.id]=T)},children:"•••"})}),e.jsxs(ct,{children:[j.id!==(x==null?void 0:x.primary_email_address_id)&&j.verified&&e.jsx(Le,{onClick:async()=>{try{await _(j.id),x.refetch(),n(null),r("Primary email updated successfully","info")}catch(T){r(T.message||"Failed to update primary email","error")}},children:"Make primary"}),!j.verified&&e.jsx(Le,{onClick:async()=>{n(null),await z(j.id),d(j.id)},children:"Verify email"}),j.id!==(x==null?void 0:x.primary_email_address_id)&&e.jsx(Le,{$destructive:!0,onClick:()=>{$(j.id),n(null)},children:"Remove"})]})]}):null})]},j.id))})]}):e.jsx(dt,{title:l?"No emails match your search":"No email addresses",description:"Add an email address to get started."}),c&&e.jsx(Pi,{existingEmail:(E=(C=x==null?void 0:x.user_email_addresses)==null?void 0:C.find(j=>j.id===c))==null?void 0:E.email,triggerRef:{current:v.current[c]},onClose:()=>d(null),onAddEmail:async()=>{},onPrepareVerification:async()=>{await z(c),x.refetch()},onAttemptVerification:async j=>{await S(c,j),x.refetch(),d(null),r("Email verified successfully!","info")}})]})},Vv=()=>{var w,b,g,C;const{deployment:t}=xe(),[r,o]=i.useState(null),[n,a]=i.useState(""),[s,p]=i.useState(!1),[f,c]=i.useState(null),[d,l]=i.useState(""),u=i.useRef(null),m=i.useRef({}),{user:v,createPhoneNumber:x,deletePhoneNumber:y,preparePhoneVerification:k,attemptPhoneVerification:z,makePhonePrimary:S}=Ft();if(!((b=(w=t==null?void 0:t.auth_settings)==null?void 0:w.phone_number)!=null&&b.enabled))return null;const _=E=>{const j=Do.find(T=>T.dialCode===E);return(j==null?void 0:j.flag)||"🌍"},$=i.useMemo(()=>v!=null&&v.user_phone_numbers?d.trim()?v.user_phone_numbers.filter(E=>E.phone_number.toLowerCase().includes(d.toLowerCase())):v.user_phone_numbers:[],[v==null?void 0:v.user_phone_numbers,d]);return e.jsxs(e.Fragment,{children:[e.jsxs(Zo,{style:{marginBottom:"20px"},children:[e.jsx(Pt,{value:d,onChange:l,placeholder:"Search Phone"}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:u,onClick:()=>p(!0),style:{padding:"8px 16px",borderRadius:"6px",fontSize:"14px",fontWeight:500,height:"36px"},children:"Add Phone"}),s&&e.jsx(Ti,{triggerRef:u,onClose:()=>p(!1),onAddPhone:async(E,j)=>{const T=await x(E,j);a(T.data.id),await k(T.data.id)},onPrepareVerification:async()=>{await k(n),v.refetch()},onAttemptVerification:async E=>{await z(n,E),v.refetch(),p(!1)}}),f&&e.jsx(Ti,{existingPhone:(C=(g=v==null?void 0:v.user_phone_numbers)==null?void 0:g.find(E=>E.id===f))==null?void 0:C.phone_number,triggerRef:{current:m.current[f]},onClose:()=>c(null),onAddPhone:async()=>{},onPrepareVerification:async()=>{await k(f),v.refetch()},onAttemptVerification:async E=>{await z(f,E),v.refetch(),c(null)}})]})]}),$!=null&&$.length?e.jsxs(mt,{children:[e.jsx(xt,{children:e.jsxs(Ve,{children:[e.jsx(ke,{children:"Phone Number"}),e.jsx(ke,{children:"Status"}),e.jsx(ke,{})]})}),e.jsx(vt,{children:$.map(E=>e.jsxs(Ve,{children:[e.jsx(De,{children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx("span",{style:{fontSize:"18px"},children:_(E.country_code)}),e.jsx("span",{children:E.country_code}),e.jsx("span",{children:E.phone_number})]})}),e.jsx(De,{children:E.id===(v==null?void 0:v.primary_phone_number_id)?"Primary":E.verified?"Verified":"Not Verified"}),e.jsx(yt,{children:e.jsxs(it,{open:r===E.id,openChange:j=>o(j?E.id:null),children:[e.jsx(lt,{children:e.jsx(dn,{ref:j=>{j&&(m.current[E.id]=j)},children:"•••"})}),e.jsxs(ct,{children:[E.id!==(v==null?void 0:v.primary_phone_number_id)&&E.verified&&e.jsx(Le,{onClick:async()=>{await S(E.id),o(null),v.refetch()},children:"Make primary"}),!E.verified&&e.jsx(Le,{onClick:async()=>{await k(E.id),c(E.id),o(null)},children:"Verify phone"}),e.jsx(Le,{$destructive:!0,onClick:async()=>{await y(E.id),o(null),v.refetch()},children:"Remove"})]})]})})]},E.id))})]}):e.jsx(dt,{title:d?"No phones match your search":"No phone numbers",description:"Add a phone number to get started."})]})},hd=h.div`
|
|
4239
4239
|
width: 20px;
|
|
4240
4240
|
height: 20px;
|
|
4241
4241
|
flex-shrink: 0;
|
|
@@ -4250,9 +4250,9 @@ cursor: pointer;
|
|
|
4250
4250
|
flex-shrink: 0;
|
|
4251
4251
|
display: block;
|
|
4252
4252
|
}
|
|
4253
|
-
`,Gv=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=Ft(),{deployment:n}=xe(),a={google_oauth:{icon:e.jsx(pl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Ev,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(ul,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(gl,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(fl,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(ml,{}),label:"Discord"},x_oauth:{icon:e.jsx(hl,{}),label:"X"}},s=(n==null?void 0:n.social_connections.filter(p=>p.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((p,f)=>{var l;const c=((l=t==null?void 0:t.social_connections)==null?void 0:l.filter(u=>u.provider===p.provider))||[],d=a[p.provider];return d?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(hd,{children:d.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:d.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(u=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:u.email_address}),e.jsx(dn,{onClick:async()=>{await r(u.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(Et,{size:14})})]},u.id)),c.length>0?e.jsx(V,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(V,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<s.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},fd=()=>{var x,y,
|
|
4253
|
+
`,Gv=()=>{const{user:t,disconnectSocialConnection:r,connectSocialAccount:o}=Ft(),{deployment:n}=xe(),a={google_oauth:{icon:e.jsx(pl,{}),label:"Google"},microsoft_oauth:{icon:e.jsx(Ev,{}),label:"Microsoft"},github_oauth:{icon:e.jsx(ul,{}),label:"GitHub"},gitlab_oauth:{icon:e.jsx(gl,{}),label:"GitLab"},linkedin_oauth:{icon:e.jsx(fl,{}),label:"LinkedIn"},discord_oauth:{icon:e.jsx(ml,{}),label:"Discord"},x_oauth:{icon:e.jsx(hl,{}),label:"X"}},s=(n==null?void 0:n.social_connections.filter(p=>p.enabled))||[];return e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx("h3",{style:{fontSize:"16px",margin:"0 0 6px 0",letterSpacing:"-0.01em",color:"var(--color-foreground)"},children:"Connected Accounts"}),e.jsx("p",{style:{fontSize:"13px",margin:0,lineHeight:"1.5",color:"var(--color-muted)"},children:"Connect social accounts for easy sign-in and profile sync"})]}),e.jsx("div",{style:{display:"flex",flexDirection:"column"},children:s.map((p,f)=>{var l;const c=((l=t==null?void 0:t.social_connections)==null?void 0:l.filter(u=>u.provider===p.provider))||[],d=a[p.provider];return d?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(hd,{children:d.icon}),e.jsx("div",{style:{fontSize:"14px",fontWeight:500},children:d.label})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"flex-end",gap:"8px"},children:[c.map(u=>e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--color-input-background)",border:"1px solid var(--color-border)",borderRadius:"6px",padding:"4px 8px",fontSize:"13px",color:"var(--color-muted)"},children:[e.jsx("span",{children:u.email_address}),e.jsx(dn,{onClick:async()=>{await r(u.id.toString()),t.refetch()},style:{padding:"2px"},children:e.jsx(Et,{size:14})})]},u.id)),c.length>0?e.jsx(V,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 24px",fontSize:"13px"},children:"Add"}):e.jsx(V,{onClick:()=>{o({provider:p.provider,redirectUri:window.location.href})},style:{padding:"6px 14px",fontSize:"13px"},children:"Connect"})]})]}),f<s.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)"}})]},p.provider):null})})]})},fd=()=>{var x,y,k,z,S,_,$;const{loading:t}=Ft(),{deployment:r}=xe(),[o,n]=i.useState("profile"),[a,s]=i.useState(null),[p,f]=i.useState("info"),c=i.useCallback((w,b="info")=>{s(w),f(b),setTimeout(()=>s(null),3e3)},[s]);if(t)return e.jsx(ue,{children:e.jsx(Ni,{style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.jsx($e,{})})});const d=r==null?void 0:r.auth_settings,l=(x=d==null?void 0:d.email_address)==null?void 0:x.enabled,u=(y=d==null?void 0:d.phone_number)==null?void 0:y.enabled,m=((k=r==null?void 0:r.social_connections)==null?void 0:k.some(w=>w.enabled))||!1,v=((z=d==null?void 0:d.password)==null?void 0:z.enabled)||((S=d==null?void 0:d.auth_factors_enabled)==null?void 0:S.authenticator)||((_=d==null?void 0:d.auth_factors_enabled)==null?void 0:_.phone_otp)||(($=d==null?void 0:d.auth_factors_enabled)==null?void 0:$.backup_code);return e.jsx(ue,{children:e.jsx(Av,{children:e.jsx(pd.Provider,{value:{screen:null,setScreen:()=>{},toast:c},children:e.jsxs(Ni,{children:[e.jsx(Lv,{children:e.jsxs(Dv,{children:[e.jsx(yr,{$isActive:o==="profile",onClick:()=>n("profile"),children:e.jsxs(br,{children:[e.jsx(Vo,{size:16}),"Profile"]})}),l&&e.jsx(yr,{$isActive:o==="email",onClick:()=>n("email"),children:e.jsxs(br,{children:[e.jsx(an,{size:16}),"Email"]})}),u&&e.jsx(yr,{$isActive:o==="phone",onClick:()=>n("phone"),children:e.jsxs(br,{children:[e.jsx(kh,{size:16}),"Phone"]})}),m&&e.jsx(yr,{$isActive:o==="social",onClick:()=>n("social"),children:e.jsxs(br,{children:[e.jsx(yh,{size:16}),"Connections"]})}),v&&e.jsx(yr,{$isActive:o==="security",onClick:()=>n("security"),children:e.jsxs(br,{children:[e.jsx(at,{size:16}),"Security"]})}),e.jsx(yr,{$isActive:o==="sessions",onClick:()=>n("sessions"),children:e.jsxs(br,{children:[e.jsx(Zp,{size:16}),"Sessions"]})})]})}),e.jsxs(Fv,{children:[o==="profile"&&e.jsx(qv,{}),o==="email"&&l&&e.jsx(Wv,{}),o==="phone"&&u&&e.jsx(Vv,{}),o==="social"&&m&&e.jsx(Gv,{}),o==="security"&&v&&e.jsx(Hv,{}),o==="sessions"&&e.jsx(Uv,{})]}),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(ft,{size:16,color:"var(--color-error)"}):e.jsx(Qe,{size:16,color:"var(--color-success)"}),e.jsx("span",{style:{fontSize:"14px",color:"var(--color-foreground)"},children:a})]})})]})})})})},Hv=()=>{var Ua,Wa,Va,Ga,Ha,qa,Ya;const{deployment:t}=xe(),{user:r,updatePassword:o,removePassword:n,setupAuthenticator:a,verifyAuthenticator:s,deleteAuthenticator:p,generateBackupCodes:f,regenerateBackupCodes:c,updateProfile:d,getPasskeys:l,registerPasskey:u,deletePasskey:m}=Ft(),{toast:v}=Ut(),[x,y]=i.useState((r==null?void 0:r.second_factor_policy)||"none"),[k,z]=i.useState(!1),S=async re=>{try{await d({second_factor_policy:re}),y(re),v("2FA requirement updated successfully","info")}catch(Oe){v(Oe.message||"Failed to update 2FA requirement","error")}},[_,$]=i.useState(!1),[w,b]=i.useState(!1),[g,C]=i.useState(!1),[E,j]=i.useState(!1),T=i.useRef(null),I=i.useRef(null),O=i.useRef(null),P=i.useRef(null),[M,F]=i.useState([]),[D,L]=i.useState(!1),[R,A]=i.useState(!1),[B,G]=i.useState(!1),[U,ne]=i.useState(!1),[K,ge]=i.useState(null),pe=i.useRef(null),[ae,he]=i.useState("table"),[Q,Se]=i.useState(""),[ce,Z]=i.useState(""),[X,ee]=i.useState(""),[te,W]=i.useState(["",""]),[Y,se]=i.useState([]),[le,q]=i.useState(!1),[me,H]=i.useState(!1),[we]=i.useState(!1),[Te,Ye]=i.useState(!1),Re=(Ua=t==null?void 0:t.auth_settings)==null?void 0:Ua.auth_factors_enabled,Wt=(Va=(Wa=t==null?void 0:t.auth_settings)==null?void 0:Wa.password)==null?void 0:Va.enabled;if(!(Re!=null&&Re.authenticator)&&!(Re!=null&&Re.backup_code)&&!Wt)return null;const bt=async(re,Oe)=>{await o(re,Oe),await r.refetch(),v("Password updated successfully","info")},Kr=async re=>{await n(re),await r.refetch(),v("Password removed successfully","info")},Qr=()=>{var Za,Ka,Qa,Ja,Xa,es;if(!r)return!1;const re=(Za=r.user_email_addresses)==null?void 0:Za.some(Ir=>Ir.verified),Oe=(Ka=r.user_phone_numbers)==null?void 0:Ka.some(Ir=>Ir.verified),Me=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"&&re||((Qa=Ke==null?void 0:Ke.magic_link)==null?void 0:Qa.enabled)&&re||((Ja=Ke==null?void 0:Ke.passkey)==null?void 0:Ja.enabled)||((Xa=Ke==null?void 0:Ke.auth_factors_enabled)==null?void 0:Xa.phone_otp)&&Oe||Me&&((es=t==null?void 0:t.social_connections)==null?void 0:es.some(Ir=>Ir.enabled))},fe=async()=>{if(te.some(re=>re.length!==6)){v("Please enter both 6-digit verification codes","error");return}try{if(H(!0),await s(X,te),await r.refetch(),Re!=null&&Re.backup_code){const re=await f();se(re),await r.refetch(),he("backup")}else he("success")}catch(re){v(re.message||"Invalid verification codes","error")}finally{H(!1)}},de=()=>{he("table"),Se(""),Z(""),ee(""),W(["",""]),se([]),v("Two-factor authentication setup completed successfully!","info")},ve=async()=>{var re;if((re=r==null?void 0:r.user_authenticator)!=null&&re.id)try{Ye(!0),await p(r.user_authenticator.id),await r.refetch(),z(!1),v("Two-factor authentication removed successfully","info")}catch(Oe){v(Oe.message||"Failed to remove authenticator","error")}finally{Ye(!1)}},je=async()=>{if(!le)try{q(!0);const re=await c();se(re),await r.refetch(),j(!0),v("New backup codes generated","info")}catch(re){v(re.message||"Failed to generate backup codes","error")}finally{q(!1)}},Ee=()=>{const re=Y.join(`
|
|
4254
4254
|
`);navigator.clipboard.writeText(re).then(()=>{v("Backup codes copied to clipboard","info")}).catch(()=>{v("Failed to copy backup codes","error")})},Be=()=>{const re=Y.join(`
|
|
4255
|
-
`),Oe=new Blob([re],{type:"text/plain"}),Me=URL.createObjectURL(Oe),Ke=document.createElement("a");Ke.href=Me,Ke.download="wacht-backup-codes.txt",Ke.click(),URL.revokeObjectURL(Me),v("Backup codes downloaded","info")},Jr=async()=>{var re,Oe;if((Oe=(re=t==null?void 0:t.auth_settings)==null?void 0:re.passkey)!=null&&Oe.enabled)try{L(!0);const Me=await l();F(Me.data||[])}catch(Me){console.error("Failed to load passkeys:",Me)}finally{L(!1)}},wd=async re=>{try{A(!0),await u(re||void 0),await Jr(),v("Passkey registered successfully!","info")}catch(Oe){throw v(Oe.message||"Failed to register passkey","error"),Oe}finally{A(!1)}},jd=async re=>{try{await m(re),await Jr(),v("Passkey removed","info")}catch(Oe){v(Oe.message||"Failed to remove passkey","error")}};i.useEffect(()=>{Jr()},[(Ha=(Ga=t==null?void 0:t.auth_settings)==null?void 0:Ga.passkey)==null?void 0:Ha.enabled]);const Rt=[];return Wt&&Rt.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"]}),(Ya=(qa=t==null?void 0:t.auth_settings)==null?void 0:qa.passkey)!=null&&Ya.enabled&&Rt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:M.length>0?`${M.length} registered`:"",actions:M.length>0?["manage","add"]:["add"]}),Re!=null&&Re.authenticator&&Rt.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&Rt.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&&Rt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:x==="enforced"?"Enforced":"Optional",actions:["toggle"]}),ae!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Zo,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(at,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[ae==="qr"&&"Setup Two-Factor Authentication",ae==="verify"&&"Verify Your Authenticator",ae==="backup"&&"Save Your Backup Codes",ae==="success"&&"Setup Complete!"]})]}),e.jsx(V,{onClick:()=>he("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:[ae==="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:we?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${Mv} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):Q?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Na,{value:Q,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:ce||"Loading..."})]}),e.jsx(V,{onClick:()=>he("verify"),disabled:!Q||!ce,style:{padding:"10px 20px",background:!Q||!ce?"var(--color-border)":"var(--color-primary)",color:!Q||!ce?"var(--color-secondary-text)":"white",border:`1px solid ${!Q||!ce?"var(--color-border)":"var(--color-primary)"}`,cursor:!Q||!ce?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),ae==="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(J,{type:"text",placeholder:"000000",value:te[0],onChange:re=>{const Oe=re.target.value.replace(/[^0-9]/g,"").substring(0,6);W([Oe,te[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(J,{type:"text",placeholder:"000000",value:te[1],onChange:re=>{const Oe=re.target.value.replace(/[^0-9]/g,"").substring(0,6);W([te[0],Oe])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(V,{onClick:()=>he("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(V,{onClick:fe,disabled:me||te.some(re=>re.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:me?"Verifying...":"Verify & Continue"})]})]}),ae==="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(ft,{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:Y.map((re,Oe)=>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(re),children:re},Oe))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(V,{onClick:Ee,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(V,{onClick:Be,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx($a,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(V,{onClick:de,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),ae==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(Qe,{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(V,{onClick:de,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Zo,{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"})})}),Rt.length?e.jsx("div",{children:Rt.map((re,Oe)=>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:re.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:re.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[re.status&&re.id!=="passkey"&&e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:re.status==="Enabled"||re.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:re.status==="Enabled"||re.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:re.status}),e.jsxs("div",{style:{position:"relative"},children:[re.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(V,{ref:I,onClick:()=>b(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),w&&e.jsx(Li,{triggerRef:I,onClose:()=>b(!1),onChangePassword:bt})]}),Qr()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:O,onClick:()=>C(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),g&&e.jsx(fv,{triggerRef:O,onClose:()=>C(!1),onRemovePassword:Kr})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:I,onClick:()=>b(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),w&&e.jsx(Li,{triggerRef:I,onClose:()=>b(!1),onChangePassword:bt,isSetup:!0})]})}),re.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:T,onClick:()=>$(!0),disabled:we,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:we?"Setting up...":"Setup"}),_&&e.jsx(av,{triggerRef:T,onClose:()=>$(!1),onSetupTOTP:async()=>{const Me=await a();return ee(Me.id),Me},onVerifyTOTP:async Me=>{await s(X,Me),await r.refetch(),v("Two-factor authentication enabled successfully!","info")}})]})}),re.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{onClick:()=>k(!0),disabled:Te,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:Te?"not-allowed":"pointer",opacity:Te?.6:1},children:Te?"Removing...":"Remove"}),S&&e.jsx(Er,{title:"Remove MFA and reset policy to default?",onConfirm:ve,onCancel:()=>k(!1)})]}),re.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:P,onClick:je,disabled:le,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:le?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),E&&e.jsx(wv,{triggerRef:P,codes:Y,onClose:()=>j(!1),onCopy:Ee,onDownload:Be})]})}),re.id==="second_factor_policy"&&e.jsx(dr,{checked:x==="enforced",onChange:Me=>{z(Me?"enforced":"none")}}),re.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(V,{onClick:()=>G(!B),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"auto",height:"auto"},children:[B?"Hide":"Manage"," (",M.length,")",e.jsx(At,{size:14,style:{transform:B?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:pe,onClick:()=>ne(!0),disabled:R,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:R?"not-allowed":"pointer",opacity:R?.7:1,whiteSpace:"nowrap",width:"auto",height:"auto"},children:R?"Registering...":"Add"}),U&&e.jsx(zv,{triggerRef:pe,onClose:()=>ne(!1),onAddPasskey:wd})]})]})]})]})]}),re.id==="passkey"&&B&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:D?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx($e,{})}):M.length===0?e.jsx("div",{style:{textAlign:"center",padding:"16px",color:"var(--color-secondary-text)",fontSize:"13px"},children:"No passkeys registered yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:M.map(Me=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:"var(--color-foreground)"},children:Me.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[Me.device_type==="platform"?"This device":"Security key",Me.last_used_at&&` • Last used ${new Date(Me.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{onClick:()=>ge(Me.id),style:{padding:"4px 10px",fontSize:"12px",background:"transparent",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",color:"var(--color-error)",cursor:"pointer",flexShrink:0,width:"auto"},children:"Remove"}),K===Me.id&&e.jsx(Er,{title:`Remove "${Me.name||"Unnamed Passkey"}"?`,onConfirm:()=>{jd(Me.id),ge(null)},onCancel:()=>ge(null)})]})]},Me.id))})}),Oe<Rt.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},re.id))}):e.jsx(dt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},qv=()=>{var D,L;const{deployment:t}=xe(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:a}=Ft(),{toast:s}=Ut(),[p,f]=i.useState(""),[c,d]=i.useState(""),[l,u]=i.useState(""),[m,v]=i.useState(!1),[x,y]=i.useState(!1),[S,k]=i.useState(!1),[z,_]=i.useState(""),[$,w]=i.useState((r==null?void 0:r.profile_picture_url)||null),b=i.useRef(null);i.useEffect(()=>{r&&!m&&(f(r.first_name||""),d(r.last_name||""),u(r.username||""),w(r.profile_picture_url||null),v(!0))},[r,m]);const g=i.useCallback(async()=>{if(r)try{const R={};p!==r.first_name&&(R.first_name=p),c!==r.last_name&&(R.last_name=c),l!==r.username&&(R.username=l),Object.keys(R).length>0&&await o(R)}catch(R){s(R.message||"Failed to save profile changes","error")}},[r,o,p,c,l,s]),C=R=>{f(R.target.value)},E=R=>{d(R.target.value)},j=R=>{u(R.target.value)},T=()=>{g()},I=()=>{g()},O=()=>{g()},P=R=>{var A;if((A=R.target.files)!=null&&A[0]){const B=R.target.files[0];w(URL.createObjectURL(B)),setTimeout(async()=>{try{await n(B),r.refetch(),s("Profile picture updated successfully","info")}catch(G){s(G.message||"Failed to update profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},100)}},M=()=>{b.current&&b.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})});const F=async()=>{if(!(!r||z!==r.username)){k(!0);try{await a(""),s("Account deleted successfully","info")}catch(R){s(R.message||"Failed to delete account","error")}finally{k(!1),_(""),y(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:$?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,onMouseEnter:R=>{R.currentTarget.style.borderColor="var(--color-primary)",R.currentTarget.style.transform="scale(1.02)"},onMouseLeave:R=>{R.currentTarget.style.borderColor="var(--color-border)",R.currentTarget.style.transform="scale(1)"},children:[$?e.jsx("img",{src:$,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Vo,{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(V,{onClick:()=>{var R;return(R=b.current)==null?void 0:R.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($a,{size:14}),$?"Change":"Upload"]}),e.jsxs(V,{onClick:async()=>{w(null),b.current&&(b.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),s("Profile picture removed successfully","info")}catch(R){s(R.message||"Failed to remove profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ft,{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(ie,{style:{flex:1},children:[e.jsx(oe,{htmlFor:"firstName",children:"First Name"}),e.jsx(J,{id:"firstName",type:"text",value:p,onChange:C,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(ie,{style:{flex:1},children:[e.jsx(oe,{htmlFor:"lastName",children:"Last Name"}),e.jsx(J,{id:"lastName",type:"text",value:c,onChange:E,onBlur:I,placeholder:"Enter your last name",required:!0})]})]}),((L=(D=t==null?void 0:t.auth_settings)==null?void 0:D.username)==null?void 0:L.enabled)&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"username",children:"Username"}),e.jsx(J,{id:"username",type:"text",value:l,onChange:j,onBlur:O,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:x?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(V,{onClick:()=>{x?(y(!1),_("")):y(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:x?"Cancel":"Delete"})]}),x&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(J,{id:"confirm_username",type:"text",value:z,onChange:R=>_(R.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(V,{onClick:F,disabled:z!==(r==null?void 0:r.username)||S,style:{background:z===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:z===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:z===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:z===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:S?e.jsx($e,{size:12}):"Delete Forever"})]})]})]})]})})},gd=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:f,showCloseButton:c})=>e.jsx(_e,{isOpen:t,onClose:r,children:e.jsx(_e.Overlay,{children:e.jsxs(_e.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(_e.Header,{showCloseButton:c,children:a||o}),p||f||e.jsx(fd,{}),s&&e.jsx(_e.Footer,{children:s})]})})}),Yv=h.div`
|
|
4255
|
+
`),Oe=new Blob([re],{type:"text/plain"}),Me=URL.createObjectURL(Oe),Ke=document.createElement("a");Ke.href=Me,Ke.download="wacht-backup-codes.txt",Ke.click(),URL.revokeObjectURL(Me),v("Backup codes downloaded","info")},Jr=async()=>{var re,Oe;if((Oe=(re=t==null?void 0:t.auth_settings)==null?void 0:re.passkey)!=null&&Oe.enabled)try{L(!0);const Me=await l();F(Me.data||[])}catch(Me){console.error("Failed to load passkeys:",Me)}finally{L(!1)}},wd=async re=>{try{A(!0),await u(re||void 0),await Jr(),v("Passkey registered successfully!","info")}catch(Oe){throw v(Oe.message||"Failed to register passkey","error"),Oe}finally{A(!1)}},jd=async re=>{try{await m(re),await Jr(),v("Passkey removed","info")}catch(Oe){v(Oe.message||"Failed to remove passkey","error")}};i.useEffect(()=>{Jr()},[(Ha=(Ga=t==null?void 0:t.auth_settings)==null?void 0:Ga.passkey)==null?void 0:Ha.enabled]);const Rt=[];return Wt&&Rt.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"]}),(Ya=(qa=t==null?void 0:t.auth_settings)==null?void 0:qa.passkey)!=null&&Ya.enabled&&Rt.push({id:"passkey",name:"Passkeys",description:"Sign in faster with fingerprint, face, or screen lock",status:M.length>0?`${M.length} registered`:"",actions:M.length>0?["manage","add"]:["add"]}),Re!=null&&Re.authenticator&&Rt.push({id:"authenticator",name:"Authenticator App",description:"Use an authenticator app for extra security",status:r!=null&&r.user_authenticator?"Enabled":"Disabled",actions:r!=null&&r.user_authenticator?["remove"]:["setup"]}),r!=null&&r.user_authenticator&&Rt.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&&Rt.push({id:"second_factor_policy",name:"Require 2FA",description:"Require a second factor for all sign-ins",status:x==="enforced"?"Enforced":"Optional",actions:["toggle"]}),ae!=="table"?e.jsxs(e.Fragment,{children:[e.jsxs(Zo,{children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[e.jsx(at,{size:16}),e.jsxs("span",{style:{fontSize:"14px",fontWeight:500,color:"var(--color-foreground)"},children:[ae==="qr"&&"Setup Two-Factor Authentication",ae==="verify"&&"Verify Your Authenticator",ae==="backup"&&"Save Your Backup Codes",ae==="success"&&"Setup Complete!"]})]}),e.jsx(V,{onClick:()=>he("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:[ae==="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:we?e.jsx("div",{style:{width:"200px",height:"200px",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",display:"flex",alignItems:"center",justifyContent:"center",background:"var(--color-input-background)"},children:e.jsxs("div",{style:{textAlign:"center"},children:[e.jsx("div",{style:{width:"24px",height:"24px",border:"2px solid var(--color-border)",borderTop:"2px solid var(--color-primary)",borderRadius:"50%",animation:`${Mv} 1s linear infinite`,margin:"0 auto 8px"}}),e.jsx("div",{style:{fontSize:"12px",color:"var(--color-secondary-text)"},children:"Loading QR Code..."})]})}):Q?e.jsx("div",{style:{border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",padding:"16px",background:"white"},children:e.jsx(Na,{value:Q,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:ce||"Loading..."})]}),e.jsx(V,{onClick:()=>he("verify"),disabled:!Q||!ce,style:{padding:"10px 20px",background:!Q||!ce?"var(--color-border)":"var(--color-primary)",color:!Q||!ce?"var(--color-secondary-text)":"white",border:`1px solid ${!Q||!ce?"var(--color-border)":"var(--color-primary)"}`,cursor:!Q||!ce?"not-allowed":"pointer"},children:"I've Scanned the Code"})]}),ae==="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(J,{type:"text",placeholder:"000000",value:te[0],onChange:re=>{const Oe=re.target.value.replace(/[^0-9]/g,"").substring(0,6);W([Oe,te[1]])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}}),e.jsx(J,{type:"text",placeholder:"000000",value:te[1],onChange:re=>{const Oe=re.target.value.replace(/[^0-9]/g,"").substring(0,6);W([te[0],Oe])},maxLength:6,style:{width:"100px",textAlign:"center",fontFamily:"monospace"}})]}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center"},children:[e.jsx(V,{onClick:()=>he("qr"),style:{padding:"8px 16px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Back"}),e.jsx(V,{onClick:fe,disabled:me||te.some(re=>re.length!==6),style:{padding:"8px 16px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:me?"Verifying...":"Verify & Continue"})]})]}),ae==="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(ft,{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:Y.map((re,Oe)=>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(re),children:re},Oe))}),e.jsxs("div",{style:{display:"flex",gap:"12px",justifyContent:"center",marginBottom:"24px"},children:[e.jsx(V,{onClick:Ee,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:"Copy All"}),e.jsxs(V,{onClick:Be,style:{padding:"8px 16px",fontSize:"14px",background:"var(--color-background)",border:"1px solid var(--color-border)"},children:[e.jsx($a,{size:16,style:{marginRight:"4px"}}),"Download"]})]}),e.jsx(V,{onClick:de,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Complete Setup"})]}),ae==="success"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{marginBottom:"24px"},children:[e.jsx(Qe,{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(V,{onClick:de,style:{padding:"10px 20px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)"},children:"Continue to Security"})]})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Zo,{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"})})}),Rt.length?e.jsx("div",{children:Rt.map((re,Oe)=>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:re.name}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-secondary-text)"},children:re.description})]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[re.status&&re.id!=="passkey"&&e.jsx("span",{style:{padding:"4px 12px",borderRadius:"16px",fontSize:"12px",fontWeight:400,background:re.status==="Enabled"||re.status==="Generated"?"var(--color-success-background)":"var(--color-background-hover)",color:re.status==="Enabled"||re.status==="Generated"?"var(--color-success)":"var(--color-secondary-text)"},children:re.status}),e.jsxs("div",{style:{position:"relative"},children:[re.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(V,{ref:I,onClick:()=>b(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Change"}),w&&e.jsx(Li,{triggerRef:I,onClose:()=>b(!1),onChangePassword:bt})]}),Qr()&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:O,onClick:()=>C(!0),style:{padding:"6px 12px",fontSize:"12px",background:"transparent",color:"var(--color-error)",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Remove"}),g&&e.jsx(fv,{triggerRef:O,onClose:()=>C(!1),onRemovePassword:Kr})]})]}):e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:I,onClick:()=>b(!0),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400"},children:"Setup"}),w&&e.jsx(Li,{triggerRef:I,onClose:()=>b(!1),onChangePassword:bt,isSetup:!0})]})}),re.id==="authenticator"&&!(r!=null&&r.user_authenticator)&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:T,onClick:()=>$(!0),disabled:we,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:we?"Setting up...":"Setup"}),_&&e.jsx(av,{triggerRef:T,onClose:()=>$(!1),onSetupTOTP:async()=>{const Me=await a();return ee(Me.id),Me},onVerifyTOTP:async Me=>{await s(X,Me),await r.refetch(),v("Two-factor authentication enabled successfully!","info")}})]})}),re.id==="authenticator"&&(r==null?void 0:r.user_authenticator)&&e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{onClick:()=>z(!0),disabled:Te,style:{padding:"6px 16px",fontSize:"13px",background:"var(--color-error)",border:"1px solid var(--color-error)",color:"white",cursor:Te?"not-allowed":"pointer",opacity:Te?.6:1},children:Te?"Removing...":"Remove"}),k&&e.jsx(Er,{title:"Remove MFA and reset policy to default?",onConfirm:ve,onCancel:()=>z(!1)})]}),re.id==="backup_codes"&&e.jsx(e.Fragment,{children:e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:P,onClick:je,disabled:le,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:le?"Generating...":r!=null&&r.backup_codes_generated?"Regenerate":"Generate"}),E&&e.jsx(wv,{triggerRef:P,codes:Y,onClose:()=>j(!1),onCopy:Ee,onDownload:Be})]})}),re.id==="second_factor_policy"&&e.jsx(dr,{checked:x==="enforced",onChange:Me=>{S(Me?"enforced":"none")}}),re.id==="passkey"&&e.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center"},children:[e.jsxs(V,{onClick:()=>G(!B),style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-background)",border:"1px solid var(--color-border)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:"pointer",display:"flex",alignItems:"center",gap:"6px",whiteSpace:"nowrap",flexShrink:0,width:"auto",height:"auto"},children:[B?"Hide":"Manage"," (",M.length,")",e.jsx(At,{size:14,style:{transform:B?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"}})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{ref:pe,onClick:()=>ne(!0),disabled:R,style:{padding:"6px 12px",fontSize:"12px",background:"var(--color-primary)",color:"white",border:"1px solid var(--color-primary)",borderRadius:"var(--radius-md)",fontWeight:"400",cursor:R?"not-allowed":"pointer",opacity:R?.7:1,whiteSpace:"nowrap",width:"auto",height:"auto"},children:R?"Registering...":"Add"}),U&&e.jsx(zv,{triggerRef:pe,onClose:()=>ne(!1),onAddPasskey:wd})]})]})]})]})]}),re.id==="passkey"&&B&&e.jsx("div",{style:{padding:"12px 0",borderTop:"1px solid var(--color-border)",marginTop:"8px"},children:D?e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"16px"},children:e.jsx($e,{})}):M.length===0?e.jsx("div",{style:{textAlign:"center",padding:"16px",color:"var(--color-secondary-text)",fontSize:"13px"},children:"No passkeys registered yet"}):e.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:M.map(Me=>e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"10px 12px",background:"var(--color-input-background)",borderRadius:"var(--radius-md)",border:"1px solid var(--color-border)"},children:[e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[e.jsx("span",{style:{fontWeight:500,fontSize:"13px",color:"var(--color-foreground)"},children:Me.name||"Unnamed Passkey"}),e.jsxs("span",{style:{fontSize:"11px",color:"var(--color-secondary-text)"},children:[Me.device_type==="platform"?"This device":"Security key",Me.last_used_at&&` • Last used ${new Date(Me.last_used_at).toLocaleDateString()}`]})]}),e.jsxs("div",{style:{position:"relative"},children:[e.jsx(V,{onClick:()=>ge(Me.id),style:{padding:"4px 10px",fontSize:"12px",background:"transparent",border:"1px solid var(--color-error)",borderRadius:"var(--radius-md)",color:"var(--color-error)",cursor:"pointer",flexShrink:0,width:"auto"},children:"Remove"}),K===Me.id&&e.jsx(Er,{title:`Remove "${Me.name||"Unnamed Passkey"}"?`,onConfirm:()=>{jd(Me.id),ge(null)},onCancel:()=>ge(null)})]})]},Me.id))})}),Oe<Rt.length-1&&e.jsx("div",{style:{height:"1px",background:"var(--color-border)",margin:"0"}})]},re.id))}):e.jsx(dt,{title:"No security features available",description:"Contact your administrator to enable security features."})]})},qv=()=>{var D,L;const{deployment:t}=xe(),{user:r,updateProfile:o,updateProfilePicture:n,deleteAccount:a}=Ft(),{toast:s}=Ut(),[p,f]=i.useState(""),[c,d]=i.useState(""),[l,u]=i.useState(""),[m,v]=i.useState(!1),[x,y]=i.useState(!1),[k,z]=i.useState(!1),[S,_]=i.useState(""),[$,w]=i.useState((r==null?void 0:r.profile_picture_url)||null),b=i.useRef(null);i.useEffect(()=>{r&&!m&&(f(r.first_name||""),d(r.last_name||""),u(r.username||""),w(r.profile_picture_url||null),v(!0))},[r,m]);const g=i.useCallback(async()=>{if(r)try{const R={};p!==r.first_name&&(R.first_name=p),c!==r.last_name&&(R.last_name=c),l!==r.username&&(R.username=l),Object.keys(R).length>0&&await o(R)}catch(R){s(R.message||"Failed to save profile changes","error")}},[r,o,p,c,l,s]),C=R=>{f(R.target.value)},E=R=>{d(R.target.value)},j=R=>{u(R.target.value)},T=()=>{g()},I=()=>{g()},O=()=>{g()},P=R=>{var A;if((A=R.target.files)!=null&&A[0]){const B=R.target.files[0];w(URL.createObjectURL(B)),setTimeout(async()=>{try{await n(B),r.refetch(),s("Profile picture updated successfully","info")}catch(G){s(G.message||"Failed to update profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},100)}},M=()=>{b.current&&b.current.click()};if(!r)return e.jsx("div",{style:{display:"flex",justifyContent:"center",padding:"40px 0"},children:e.jsx($e,{})});const F=async()=>{if(!(!r||S!==r.username)){z(!0);try{await a(""),s("Account deleted successfully","info")}catch(R){s(R.message||"Failed to delete account","error")}finally{z(!1),_(""),y(!1)}}};return e.jsx(e.Fragment,{children:e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"var(--space-2xl)"},children:[e.jsxs("div",{style:{display:"flex",gap:"var(--space-2xl)",alignItems:"center"},children:[e.jsx("div",{style:{flexShrink:0},children:e.jsxs("div",{style:{width:"120px",height:"120px",borderRadius:"50%",border:"2px dashed var(--color-border)",background:$?"transparent":"var(--color-input-background)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",transition:"all 0.2s ease"},onClick:M,onMouseEnter:R=>{R.currentTarget.style.borderColor="var(--color-primary)",R.currentTarget.style.transform="scale(1.02)"},onMouseLeave:R=>{R.currentTarget.style.borderColor="var(--color-border)",R.currentTarget.style.transform="scale(1)"},children:[$?e.jsx("img",{src:$,alt:"Profile Picture",style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"50%"}}):e.jsx(Vo,{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(V,{onClick:()=>{var R;return(R=b.current)==null?void 0:R.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($a,{size:14}),$?"Change":"Upload"]}),e.jsxs(V,{onClick:async()=>{w(null),b.current&&(b.current.value="");try{await o({remove_profile_picture:!0}),await r.refetch(),s("Profile picture removed successfully","info")}catch(R){s(R.message||"Failed to remove profile picture","error"),w((r==null?void 0:r.profile_picture_url)||null)}},style:{background:"transparent",color:"var(--color-muted)",border:"1px solid var(--color-border)",padding:"var(--space-xs) var(--space-md)",fontSize:"var(--font-xs)",height:"32px",width:"100px",display:"flex",alignItems:"center",gap:"6px"},children:[e.jsx(ft,{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(ie,{style:{flex:1},children:[e.jsx(oe,{htmlFor:"firstName",children:"First Name"}),e.jsx(J,{id:"firstName",type:"text",value:p,onChange:C,onBlur:T,placeholder:"Enter your first name",required:!0})]}),e.jsxs(ie,{style:{flex:1},children:[e.jsx(oe,{htmlFor:"lastName",children:"Last Name"}),e.jsx(J,{id:"lastName",type:"text",value:c,onChange:E,onBlur:I,placeholder:"Enter your last name",required:!0})]})]}),((L=(D=t==null?void 0:t.auth_settings)==null?void 0:D.username)==null?void 0:L.enabled)&&e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"username",children:"Username"}),e.jsx(J,{id:"username",type:"text",value:l,onChange:j,onBlur:O,placeholder:"Enter your username",required:!0})]})]})]}),e.jsx("div",{style:{position:"relative",height:"1px",background:"var(--color-divider)",margin:"0"}}),e.jsxs("div",{children:[e.jsxs("div",{style:{marginBottom:"16px"},children:[e.jsx("h3",{style:{fontSize:"16px",color:"var(--color-foreground)",margin:"0 0 4px 0"},children:"Danger Zone"}),e.jsx("p",{style:{fontSize:"14px",color:"var(--color-muted)",margin:0},children:"Irreversible and destructive actions"})]}),e.jsxs("div",{style:{padding:"20px",border:"1px solid var(--color-error)",borderRadius:"8px"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:x?"20px":"0"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",color:"var(--color-foreground)",marginBottom:"4px",fontWeight:"500"},children:"Delete Account"}),e.jsx("div",{style:{fontSize:"13px",color:"var(--color-muted)"},children:"Once you delete your account, there is no going back. Please be certain."})]}),e.jsx(V,{onClick:()=>{x?(y(!1),_("")):y(!0)},style:{background:"var(--color-error)",color:"white",border:"none",padding:"6px 12px",fontSize:"13px",height:"32px",width:"auto"},children:x?"Cancel":"Delete"})]}),x&&e.jsxs("div",{style:{maxWidth:"400px"},children:[e.jsxs(ie,{children:[e.jsx(oe,{htmlFor:"confirm_username",children:"Confirm by typing your username"}),e.jsx(J,{id:"confirm_username",type:"text",value:S,onChange:R=>_(R.target.value),placeholder:`Type "${r==null?void 0:r.username}" to confirm`})]}),e.jsx(V,{onClick:F,disabled:S!==(r==null?void 0:r.username)||k,style:{background:S===(r==null?void 0:r.username)?"var(--color-error)":"transparent",color:S===(r==null?void 0:r.username)?"white":"var(--color-muted)",border:"1px solid var(--color-border)",padding:"8px 16px",fontSize:"14px",height:"36px",cursor:S===(r==null?void 0:r.username)?"pointer":"not-allowed",opacity:S===(r==null?void 0:r.username)?1:.6,marginTop:"12px"},children:k?e.jsx($e,{size:12}):"Delete Forever"})]})]})]})]})})},gd=({isOpen:t,onClose:r,title:o,showHeader:n,headerContent:a,footerContent:s,customContent:p,children:f,showCloseButton:c})=>e.jsx(_e,{isOpen:t,onClose:r,children:e.jsx(_e.Overlay,{children:e.jsxs(_e.Content,{style:{width:"900px",maxWidth:"100%"},children:[n&&e.jsx(_e.Header,{showCloseButton:c,children:a||o}),p||f||e.jsx(fd,{}),s&&e.jsx(_e.Footer,{children:s})]})})}),Yv=h.div`
|
|
4256
4256
|
position: relative;
|
|
4257
4257
|
`,Zv=h.button`
|
|
4258
4258
|
display: flex;
|
|
@@ -4391,7 +4391,7 @@ cursor: pointer;
|
|
|
4391
4391
|
width: 14px;
|
|
4392
4392
|
height: 14px;
|
|
4393
4393
|
}
|
|
4394
|
-
`,Ba=({showName:t=!0})=>{var b,g,C,E;const[r,o]=i.useState(!1),n=i.useRef(null),a=i.useRef(null),s=Yl({triggerRef:n,isOpen:r,minWidth:380}),p=Wr(!1),{session:f,signOut:c,switchSignIn:d,refetch:l}=He(),{navigateToSignIn:u}=Je(),{deployment:m}=xe(),v=(b=f==null?void 0:f.active_signin)==null?void 0:b.user,x=((C=(g=m==null?void 0:m.auth_settings)==null?void 0:g.multi_session_support)==null?void 0:C.enabled)??!1,y=(((E=f==null?void 0:f.signins)==null?void 0:E.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const T=I=>{var P,M;const O=I.target;(P=n.current)!=null&&P.contains(O)||(M=a.current)!=null&&M.contains(O)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(j)}},[r]);const
|
|
4394
|
+
`,Ba=({showName:t=!0})=>{var b,g,C,E;const[r,o]=i.useState(!1),n=i.useRef(null),a=i.useRef(null),s=Yl({triggerRef:n,isOpen:r,minWidth:380}),p=Wr(!1),{session:f,signOut:c,switchSignIn:d,refetch:l}=He(),{navigateToSignIn:u}=Je(),{deployment:m}=xe(),v=(b=f==null?void 0:f.active_signin)==null?void 0:b.user,x=((C=(g=m==null?void 0:m.auth_settings)==null?void 0:g.multi_session_support)==null?void 0:C.enabled)??!1,y=(((E=f==null?void 0:f.signins)==null?void 0:E.length)??0)>1;i.useEffect(()=>{if(!r)return;const j=setTimeout(()=>{const T=I=>{var P,M;const O=I.target;(P=n.current)!=null&&P.contains(O)||(M=a.current)!=null&&M.contains(O)||o(!1)};return document.addEventListener("mousedown",T),()=>{document.removeEventListener("mousedown",T)}},50);return()=>{clearTimeout(j)}},[r]);const k=()=>{o(!r)},z=j=>j.split(" ").map(T=>T[0]).join("").toUpperCase(),S=async j=>{try{await c(j),await l(),o(!1)}catch{}},_=async()=>{try{await c(),await l(),o(!1)}catch{}},$=async j=>{try{await d(j),await l(),o(!1)}catch{}},w=()=>{p.open(),o(!1)};return e.jsx(ue,{children:e.jsxs(Yv,{children:[e.jsxs(Zv,{ref:n,onClick:k,children:[e.jsx(Kn,{children:e.jsx(md,{children:v!=null&&v.has_profile_picture?e.jsx("img",{src:v.profile_picture_url,alt:v.first_name}):z(`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`)})}),t&&e.jsx(Kv,{children:`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`})]}),typeof window<"u"&&r&&Ko.createPortal(e.jsx(ue,{children:e.jsx(Qv,{ref:a,$position:s,$isOpen:r,$maxHeight:s==null?void 0:s.maxHeight,children:e.jsxs("div",{children:[x?(()=>{const j=[...(f==null?void 0:f.signins)||[]].sort((T,I)=>{const O=T.user.id===(v==null?void 0:v.id),P=I.user.id===(v==null?void 0:v.id);return O&&!P?-1:!O&&P?1:0});return j.map(({user:T,id:I},O)=>{const P=T.id===(v==null?void 0:v.id),M=!P;return e.jsxs(i.Fragment,{children:[e.jsxs(Wi,{$isClickable:M,onClick:M?()=>$(I):void 0,children:[e.jsxs(Vi,{children:[e.jsx(Kn,{children:e.jsx(qi,{children:T.has_profile_picture?e.jsx("img",{src:T.profile_picture_url,alt:T.first_name}):z(`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`)})}),e.jsxs(Gi,{children:[e.jsx(Hi,{children:e.jsx(Bi,{children:`${(T==null?void 0:T.first_name)||""} ${(T==null?void 0:T.last_name)||""}`})}),e.jsx(Ui,{children:T.primary_email_address.email})]})]}),P&&e.jsxs(Yi,{children:[e.jsxs(Io,{onClick:w,children:[e.jsx(ir,{}),"Manage account"]}),e.jsxs(Io,{$destructive:!0,onClick:()=>S(I),children:[e.jsx(Ot,{}),"Sign out"]})]})]}),O===0&&j.length>1&&e.jsx("div",{style:{borderBottom:"1px solid var(--color-border)",margin:"0"}})]},T.id)})})():v&&e.jsxs(Wi,{$isClickable:!1,children:[e.jsxs(Vi,{children:[e.jsx(Kn,{children:e.jsx(qi,{children:v.has_profile_picture?e.jsx("img",{src:v.profile_picture_url,alt:v.first_name}):z(`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`)})}),e.jsxs(Gi,{children:[e.jsx(Hi,{children:e.jsx(Bi,{children:`${(v==null?void 0:v.first_name)||""} ${(v==null?void 0:v.last_name)||""}`})}),e.jsx(Ui,{children:v.primary_email_address.email})]})]}),e.jsxs(Yi,{children:[e.jsxs(Io,{onClick:w,children:[e.jsx(ir,{}),"Manage account"]}),e.jsxs(Io,{$destructive:!0,onClick:()=>{var j;return S(((j=f==null?void 0:f.active_signin)==null?void 0:j.id)||"")},children:[e.jsx(Ot,{}),"Sign out"]})]})]}),x&&e.jsxs(e.Fragment,{children:[e.jsx(Zi,{style:{borderBottom:"1px solid var(--color-border)"},children:e.jsxs(Ki,{onClick:()=>u(),children:[e.jsx(rt,{}),"Add new account"]})}),y&&e.jsx(Zi,{children:e.jsxs(Ki,{onClick:_,children:[e.jsx(Ot,{}),"Sign out of all accounts"]})})]})]})})}),document.body),e.jsx(gd,{isOpen:p.isOpen,onClose:p.close})]})})},Jv=h.div`
|
|
4395
4395
|
padding: var(--space-md) var(--space-lg);
|
|
4396
4396
|
background: ${t=>t.$unread?"var(--color-background-hover)":"transparent"};
|
|
4397
4397
|
transition: all 0.2s ease;
|
|
@@ -4674,7 +4674,7 @@ cursor: pointer;
|
|
|
4674
4674
|
justify-content: center;
|
|
4675
4675
|
border: 2px solid var(--color-background);
|
|
4676
4676
|
box-shadow: 0 1px 3px var(--color-shadow);
|
|
4677
|
-
`;function yd({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:a}){const[s,p]=i.useState(!1),[f,c]=i.useState(),d=i.useRef(null),l=i.useRef(null),u={channels:o,organization_ids:n,workspace_ids:a,limit:20},{unreadCount:m,notifications:v,loading:x,markAsRead:y,markAllAsRead:
|
|
4677
|
+
`;function yd({className:t,showBadge:r=!0,channels:o=["user"],organizationIds:n,workspaceIds:a}){const[s,p]=i.useState(!1),[f,c]=i.useState(),d=i.useRef(null),l=i.useRef(null),u={channels:o,organization_ids:n,workspace_ids:a,limit:20},{unreadCount:m,notifications:v,loading:x,markAsRead:y,markAllAsRead:k,deleteNotification:z}=Mc(u);return i.useEffect(()=>{if(!s)return;const S=setTimeout(()=>{const _=$=>{var b,g;const w=$.target;(b=d.current)!=null&&b.contains(w)||(g=l.current)!=null&&g.contains(w)||p(!1)};return document.addEventListener("mousedown",_),()=>{document.removeEventListener("mousedown",_)}},50);return()=>{clearTimeout(S)}},[s]),i.useEffect(()=>{if(s&&d.current){const S=d.current.getBoundingClientRect(),_=400,$=600,w=window.innerWidth,b=window.innerHeight,g=w-S.left,C=b-S.bottom,E=S.top;let j,T;g>=_?j=S.left:T=w-S.right;let I,O;C>=$+8?I=S.bottom+8:E>=$+8?O=b-S.top+8:I=S.bottom+8,c({top:I,bottom:O,left:j,right:T})}else c(void 0)},[s]),e.jsx(ue,{children:e.jsxs(w1,{ref:d,className:t,children:[e.jsx(j1,{children:e.jsxs(_1,{onClick:()=>p(!s),children:[e.jsx(Xp,{size:16}),r&&m>0&&e.jsx(k1,{children:m>9?"9+":m})]})}),typeof window<"u"&&s&&Ko.createPortal(e.jsx(ue,{children:e.jsx(vd,{ref:l,position:f,notifications:v,loading:x,onMarkAsRead:y,onMarkAllAsRead:k,onDelete:z})}),document.body)]})})}const C1=h.div`
|
|
4678
4678
|
display: flex;
|
|
4679
4679
|
align-items: center;
|
|
4680
4680
|
gap: 8px;
|
|
@@ -4907,7 +4907,7 @@ cursor: pointer;
|
|
|
4907
4907
|
&:hover {
|
|
4908
4908
|
color: var(--color-primary-hover);
|
|
4909
4909
|
}
|
|
4910
|
-
`,U1=({onAccountSelect:t,showAddAccount:r=!0})=>{var $,w,b,g,C;const{session:o,loading:n,switchSignIn:a,signOut:s}=He(),{deployment:p}=xe(),{navigateToSignIn:f,navigate:c}=Je(),[d,l]=i.useState(null),[u,m]=i.useState(null),v=o==null?void 0:o.active_signin,x=(o==null?void 0:o.signins)||[],y=((w=($=p==null?void 0:p.auth_settings)==null?void 0:$.multi_session_support)==null?void 0:w.enabled)??!1;i.useEffect(()=>{n||x.length||f()},[n,x,f]);const
|
|
4910
|
+
`,U1=({onAccountSelect:t,showAddAccount:r=!0})=>{var $,w,b,g,C;const{session:o,loading:n,switchSignIn:a,signOut:s}=He(),{deployment:p}=xe(),{navigateToSignIn:f,navigate:c}=Je(),[d,l]=i.useState(null),[u,m]=i.useState(null),v=o==null?void 0:o.active_signin,x=(o==null?void 0:o.signins)||[],y=((w=($=p==null?void 0:p.auth_settings)==null?void 0:$.multi_session_support)==null?void 0:w.enabled)??!1;i.useEffect(()=>{n||x.length||f()},[n,x,f]);const k=E=>E.split(" ").map(j=>j[0]).join("").toUpperCase().slice(0,2),z=async E=>{var j;if(!(E===(v==null?void 0:v.id)||u)){m(E);try{if(await a(E),t)t(E),m(null);else{let T=new URLSearchParams(window.location.search).get("redirect_uri");if(T||(T=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),T){let I;try{I=new URL(T)}catch{I=new URL(T,window.location.origin)}(p==null?void 0:p.mode)==="staging"&&I.searchParams.set("__dev_session__",localStorage.getItem("__dev_session__")??""),c(I.toString())}else m(null)}}catch(T){console.error("Failed to switch account:",T),m(null)}}},S=async(E,j)=>{E.stopPropagation(),l(j);try{await s(j)}catch(T){console.error("Failed to sign out:",T)}finally{l(null)}},_=()=>{var j;let E=new URLSearchParams(window.location.search).get("redirect_uri");E||(E=(j=p.ui_settings)==null?void 0:j.after_signin_redirect_url),f(E)};return n?e.jsx(ue,{children:e.jsxs(Qi,{children:[e.jsx(Ie,{}),e.jsxs(Xi,{children:[e.jsx(ec,{children:"Choose an account"}),e.jsxs(tc,{children:["to continue to ",((b=p==null?void 0:p.ui_settings)==null?void 0:b.app_name)||"App"]})]}),e.jsx(Ji,{children:[1,2].map(E=>e.jsxs(L1,{children:[e.jsx(D1,{}),e.jsxs(F1,{children:[e.jsx(rc,{}),e.jsx(rc,{$width:"small"})]})]},E))})]})}):x.length?e.jsx(ue,{children:e.jsxs(Qi,{children:[e.jsx(Ie,{}),e.jsxs(Xi,{children:[e.jsx(ec,{children:"Choose an account"}),e.jsxs(tc,{children:["to continue to ",(g=p==null?void 0:p.ui_settings)==null?void 0:g.app_name]})]}),e.jsxs(Ji,{children:[x.map(({user:E,id:j})=>{var P,M,F,D,L;if(!E)return null;const T=j===(v==null?void 0:v.id),I=u===j,O=`${E.first_name||""} ${E.last_name||""}`.trim();return e.jsxs(P1,{$isActive:T,$isSwitching:I,onClick:()=>z(j),children:[e.jsx(R1,{children:E.has_profile_picture?e.jsx("img",{src:E.profile_picture_url,alt:O}):k(O||((P=E.primary_email_address)==null?void 0:P.email)||((M=E.primary_phone_number)==null?void 0:M.phone_number)||E.username||"U")}),e.jsxs(I1,{children:[e.jsx(T1,{children:O||((F=E.primary_email_address)==null?void 0:F.email)||((D=E.primary_phone_number)==null?void 0:D.phone_number)||E.username||"User"}),e.jsx(O1,{children:((L=E.primary_email_address)==null?void 0:L.email)||E.username})]}),!I&&e.jsxs(M1,{onClick:R=>S(R,j),$isLoading:d===j,disabled:d===j,children:[d===j?e.jsx(zt,{size:12}):e.jsx(Ot,{size:12}),d===j?"Signing out...":"Sign out"]})]},j)}),r&&y&&e.jsxs(A1,{onClick:_,children:[e.jsx(rt,{}),"Add another account"]})]}),e.jsxs(N1,{children:["Don't have an account?"," ",e.jsx(B1,{children:e.jsx(st,{to:`${(C=p.ui_settings)==null?void 0:C.sign_up_page_url}${window.location.search}`,children:"Sign up"})})]})]})}):null},W1=()=>{const{navigateToSignIn:t}=Je();return i.useEffect(()=>{t()},[t]),null},V1=()=>{const{navigateToSignUp:t}=Je();return i.useEffect(()=>{t()},[t]),null},G1=h.div`
|
|
4911
4911
|
width: 100%;
|
|
4912
4912
|
height: 500px;
|
|
4913
4913
|
background: var(--color-background);
|
|
@@ -5115,10 +5115,10 @@ cursor: pointer;
|
|
|
5115
5115
|
margin: 0 auto;
|
|
5116
5116
|
padding: 6px 16px;
|
|
5117
5117
|
font-size: 13px;
|
|
5118
|
-
`,r2=()=>{var T,I;const{organizationMemberships:t,refetch:r,loading:o}=$t(),{workspaces:n}=Lt(),{switchOrganization:a,switchWorkspace:s}=He(),{deployment:p}=xe(),[f,c]=i.useState(null),[d,l]=i.useState("orgList"),[u,m]=i.useState(null),v=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,x=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,y=i.useRef(!1);i.useEffect(()=>{if(!(y.current||!t)){if(y.current=!0,t.length===0){l("createOrg");return}if(!v){l("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),l("createWorkspace");return}l("orgList")}},[t,n,v]),console.log("view mode",d,v);const
|
|
5118
|
+
`,r2=()=>{var T,I;const{organizationMemberships:t,refetch:r,loading:o}=$t(),{workspaces:n}=Lt(),{switchOrganization:a,switchWorkspace:s}=He(),{deployment:p}=xe(),[f,c]=i.useState(null),[d,l]=i.useState("orgList"),[u,m]=i.useState(null),v=(p==null?void 0:p.b2b_settings.workspaces_enabled)??!1,x=(p==null?void 0:p.b2b_settings.allow_users_to_create_orgs)??!1,y=i.useRef(!1);i.useEffect(()=>{if(!(y.current||!t)){if(y.current=!0,t.length===0){l("createOrg");return}if(!v){l("orgList");return}if(!n||n.length===0){t[0]&&m(t[0].organization.id),l("createWorkspace");return}l("orgList")}},[t,n,v]),console.log("view mode",d,v);const k=O=>O.split(" ").map(P=>P[0]).join("").toUpperCase().slice(0,2),z=async O=>{if(v){m(O.id),l("workspaceList");return}c(O.id);try{await a(O.id)}finally{c(null)}},S=async O=>{c(O.id);try{await s(O.id)}finally{c(null)}},_=async O=>{await r(),v&&O&&(m(O.id),l("createWorkspace"))},$=()=>{},w=async()=>{m(null),l("orgList")},b=(T=t==null?void 0:t.find(O=>O.organization.id===u))==null?void 0:T.organization,g=u?n==null?void 0:n.filter(O=>O.organization.id===u):[];if(o)return null;if(d==="createOrg")return e.jsx(_e.Body,{style:{padding:0},children:e.jsx(ln,{onSuccess:_,onCancel:()=>l("orgList")})});if(d==="createWorkspace"&&u)return e.jsx(_e.Body,{style:{padding:0},children:e.jsx(Aa,{organizationId:u,onSuccess:$,onCancel:()=>l("workspaceList"),onCreateOrganization:()=>l("createOrg")})});const C=d==="workspaceList",E=C?"Select a workspace":"Select an organization",j=C?`Choose a workspace in ${(b==null?void 0:b.name)||""}`:`to continue to ${((I=p==null?void 0:p.ui_settings)==null?void 0:I.app_name)||"App"}`;return e.jsxs(G1,{children:[e.jsxs(H1,{children:[e.jsxs("div",{children:[e.jsx(Ie,{}),e.jsxs(J1,{children:[e.jsx(X1,{children:E}),e.jsx(e2,{children:j})]})]}),e.jsx(Ba,{showName:!0})]}),e.jsxs(q1,{children:[e.jsxs(Y1,{children:[e.jsxs(Z1,{children:[e.jsx(K1,{children:C?"Workspaces":"Your organizations"}),C&&e.jsxs(Q1,{onClick:w,children:[e.jsx(Ea,{}),"Go back"]})]}),e.jsx(t2,{children:C?e.jsx(e.Fragment,{children:g&&g.length>0?g.map(O=>{var M,F,D;const P=((M=O.eligibility_restriction)==null?void 0:M.type)!=="none"&&((F=O.eligibility_restriction)==null?void 0:F.type)!==void 0;return e.jsxs(oc,{onClick:()=>!P&&S(O),disabled:f===O.id||P,style:{opacity:P?.7:1},children:[e.jsx(nc,{children:O.image_url?e.jsx(ac,{src:O.image_url,alt:O.name}):k(O.name).charAt(0)}),e.jsxs(sc,{children:[e.jsx(ic,{children:O.name}),e.jsxs(cc,{children:[e.jsx(Go,{}),"Workspace"]})]}),e.jsx(lc,{children:e.jsx(ma,{})}),P&&e.jsxs(dc,{children:[e.jsx(ft,{size:14}),(D=O.eligibility_restriction)==null?void 0:D.message]})]},O.id)}):e.jsxs(uc,{children:[e.jsx(pc,{children:"No workspaces yet"}),e.jsxs(hc,{children:["Create your first workspace for"," ",(b==null?void 0:b.name)||"this organization"]}),e.jsxs(fc,{onClick:()=>l("createWorkspace"),children:[e.jsx(rt,{}),"Create workspace"]})]})}):t&&t.length>0?t.map(O=>{var G,U,ne;const P=O.organization,M=n==null?void 0:n.filter(K=>K.organization.id===P.id),F=(M==null?void 0:M.length)||0,D=P.member_count,L=O.roles[0].name,R=O.roles.length-1,A=R>0?`${L.charAt(0).toUpperCase()+L.slice(1)} +${R}`:L.charAt(0).toUpperCase()+L.slice(1),B=((G=O.eligibility_restriction)==null?void 0:G.type)!=="none"&&((U=O.eligibility_restriction)==null?void 0:U.type)!==void 0;return e.jsxs(oc,{onClick:()=>!B&&z(P),disabled:f===P.id||B,style:{opacity:B?.7:1},children:[e.jsx(nc,{children:P.image_url?e.jsx(ac,{src:P.image_url,alt:P.name}):k(P.name)}),e.jsxs(sc,{children:[e.jsx(ic,{children:P.name}),e.jsx(cc,{children:v?e.jsxs(e.Fragment,{children:[e.jsx(Go,{}),F," workspace",F!==1?"s":""]}):e.jsxs(e.Fragment,{children:[e.jsx(th,{}),A," • ",D," member",D!==1?"s":""]})})]}),e.jsx(lc,{children:e.jsx(ma,{})}),B&&e.jsxs(dc,{children:[e.jsx(ft,{size:14}),(ne=O.eligibility_restriction)==null?void 0:ne.message]})]},P.id)}):e.jsxs(uc,{children:[e.jsx(pc,{children:"No organizations yet"}),e.jsx(hc,{children:x?"Create your first organization to get started":"You don't have access to any organizations yet"}),x&&e.jsxs(fc,{onClick:()=>l("createOrg"),children:[e.jsx(rt,{}),"Create organization"]})]})})]}),C&&g&&g.length>0&&e.jsxs(V,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createWorkspace"),disabled:f!==null,children:[e.jsx(rt,{size:12}),"Create new workspace"]}),!C&&t&&t.length>0&&x&&e.jsxs(V,{style:{marginTop:"var(--space-md)"},onClick:()=>l("createOrg"),disabled:f!==null,children:[e.jsx(rt,{size:12}),"Create new organization"]})]})]})},o2=h(_e.Content)`
|
|
5119
5119
|
padding: 0;
|
|
5120
5120
|
max-width: 90vw;
|
|
5121
|
-
`,n2=({children:t})=>{var y,
|
|
5121
|
+
`,n2=({children:t})=>{var y,k,z,S;const{loading:r,session:o}=He(),{activeOrganization:n}=tt(),{activeWorkspace:a,loading:s}=Dt(),{workspaces:p}=Lt(),{deployment:f}=xe(),{organizationMemberships:c}=$t(),d=(f==null?void 0:f.b2b_settings.workspaces_enabled)??!1,l=c==null?void 0:c.find(_=>_.organization.id===(n==null?void 0:n.id)),u=p==null?void 0:p.find(_=>{var $;return _.id===(($=o==null?void 0:o.active_signin)==null?void 0:$.active_workspace_membership_id)}),m=((y=l==null?void 0:l.eligibility_restriction)==null?void 0:y.type)!=="none"&&((k=l==null?void 0:l.eligibility_restriction)==null?void 0:k.type)!==void 0,v=((z=u==null?void 0:u.eligibility_restriction)==null?void 0:z.type)!=="none"&&((S=u==null?void 0:u.eligibility_restriction)==null?void 0:S.type)!==void 0;return r||d&&s?null:(m||v||!n?!1:d?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(ue,{children:e.jsx(_e,{isOpen:!0,children:e.jsx(_e.Overlay,{children:e.jsx(o2,{style:{width:"850px"},children:e.jsx(r2,{})})})})})},a2=h.div`
|
|
5122
5122
|
display: flex;
|
|
5123
5123
|
gap: 8px;
|
|
5124
5124
|
flex-wrap: wrap;
|