@saas-support/react 0.6.0 → 0.6.2
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/react.cjs +3 -3
- package/dist/react.js +146 -141
- package/package.json +1 -1
package/dist/react.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("react"),U=require("./index.cjs"),vs=require("react-dom"),J=t.createContext(null);function E(){const a=t.useContext(J);if(!a)throw new Error("useSaaSContext must be used within a <SaaSProvider>");return a}function js({publishableKey:a,apiKey:r,baseUrl:e,appearance:o,children:n}){const[u]=t.useState(()=>new U.SaaSSupport({publishableKey:a,apiKey:r,baseUrl:e})),[l,c]=t.useState(null),[d,i]=t.useState(!1),[x,p]=t.useState(null);return t.useEffect(()=>{let g=!1;u.load().then(async()=>{if(g)return;const v=await u.auth.getUser(),b=await u.auth.getSettings();c(v),p(b),i(!0)});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),t=require("react"),U=require("./index.cjs"),vs=require("react-dom"),J=t.createContext(null);function E(){const a=t.useContext(J);if(!a)throw new Error("useSaaSContext must be used within a <SaaSProvider>");return a}function js({publishableKey:a,apiKey:r,baseUrl:e,appearance:o,children:n}){const[u]=t.useState(()=>new U.SaaSSupport({publishableKey:a,apiKey:r,baseUrl:e})),[l,c]=t.useState(null),[d,i]=t.useState(!1),[x,p]=t.useState(null);return t.useEffect(()=>{let g=!1;u.load().then(async()=>{if(g)return;const v=await u.auth.getUser(),b=await u.auth.getSettings();c(v),p(b),i(!0)});const f=u.auth.onAuthStateChange(v=>{g||c(v)});return()=>{g=!0,f(),u.destroy()}},[u]),s.jsx(J.Provider,{value:{client:u,user:l,isLoaded:d,appearance:o,settings:x},children:n})}const ws={colorPrimary:"#6366f1",colorPrimaryHover:"#4f46e5",colorBackground:"#ffffff",colorText:"#1a1a2e",colorTextSecondary:"#6b7280",colorInputBackground:"#f9fafb",colorInputBorder:"#d1d5db",colorError:"#ef4444",colorSuccess:"#22c55e",colorWarning:"#f59e0b",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',borderRadius:"8px",authPrimary:"#4648d4",authPrimaryContainer:"#6063ee",authOnPrimary:"#ffffff",authPrimaryFixed:"#e1e0ff",authSurface:"#fcf8ff",authSurfaceContainerLowest:"#ffffff",authSurfaceContainerLow:"#f5f2ff",authSurfaceContainer:"#efecff",authSurfaceContainerHigh:"#e8e5ff",authSurfaceContainerHighest:"#e2e0fc",authOnSurface:"#1a1a2e",authOnSurfaceVariant:"#464554",authOutline:"#767586",authOutlineVariant:"#c7c4d7",authError:"#ba1a1a",authErrorContainer:"#ffdad6",authSuccess:"#22c55e",authFontHeadline:"'Manrope', sans-serif",authFontBody:"'Inter', sans-serif"},Ss={colorPrimary:"#818cf8",colorPrimaryHover:"#6366f1",colorBackground:"#1e1e2e",colorText:"#e2e8f0",colorTextSecondary:"#94a3b8",colorInputBackground:"#2a2a3e",colorInputBorder:"#3f3f5e",colorError:"#f87171",colorSuccess:"#4ade80",colorWarning:"#fbbf24",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',borderRadius:"8px",authPrimary:"#818cf8",authPrimaryContainer:"#6063ee",authOnPrimary:"#ffffff",authPrimaryFixed:"#2a2a3e",authSurface:"#1e1e2e",authSurfaceContainerLowest:"#161623",authSurfaceContainerLow:"#27273a",authSurfaceContainer:"#2d2d44",authSurfaceContainerHigh:"#363654",authSurfaceContainerHighest:"#3f3f61",authOnSurface:"#e2e8f0",authOnSurfaceVariant:"#94a3b8",authOutline:"#464554",authOutlineVariant:"#44445a",authError:"#f87171",authErrorContainer:"#93000a",authSuccess:"#4ade80",authFontHeadline:"'Manrope', sans-serif",authFontBody:"'Inter', sans-serif"};function Y(a){const r=(a==null?void 0:a.baseTheme)==="dark"?Ss:ws,e=a==null?void 0:a.variables,o=(e==null?void 0:e.colorPrimary)??r.authPrimary;return{colorPrimary:(e==null?void 0:e.colorPrimary)??r.colorPrimary,colorPrimaryHover:e!=null&&e.colorPrimary?Ns(e.colorPrimary,10):r.colorPrimaryHover,colorBackground:(e==null?void 0:e.colorBackground)??r.colorBackground,colorText:(e==null?void 0:e.colorText)??r.colorText,colorTextSecondary:r.colorTextSecondary,colorInputBackground:(e==null?void 0:e.colorInputBackground)??r.colorInputBackground,colorInputBorder:(e==null?void 0:e.colorInputBorder)??r.colorInputBorder,colorError:(e==null?void 0:e.colorError)??r.colorError,colorSuccess:(e==null?void 0:e.colorSuccess)??r.colorSuccess,colorWarning:(e==null?void 0:e.colorWarning)??r.colorWarning,fontFamily:(e==null?void 0:e.fontFamily)??r.fontFamily,borderRadius:(e==null?void 0:e.borderRadius)??r.borderRadius,authPrimary:o,authPrimaryContainer:e!=null&&e.colorPrimary?ks(o,15):r.authPrimaryContainer,authOnPrimary:r.authOnPrimary,authPrimaryFixed:r.authPrimaryFixed,authSurface:(e==null?void 0:e.colorBackground)??r.authSurface,authSurfaceContainerLowest:r.authSurfaceContainerLowest,authSurfaceContainerLow:(e==null?void 0:e.colorInputBackground)??r.authSurfaceContainerLow,authSurfaceContainer:r.authSurfaceContainer,authSurfaceContainerHigh:r.authSurfaceContainerHigh,authSurfaceContainerHighest:r.authSurfaceContainerHighest,authOnSurface:(e==null?void 0:e.colorText)??r.authOnSurface,authOnSurfaceVariant:r.authOnSurfaceVariant,authOutline:r.authOutline,authOutlineVariant:(e==null?void 0:e.colorInputBorder)??r.authOutlineVariant,authError:(e==null?void 0:e.colorError)??r.authError,authErrorContainer:r.authErrorContainer,authSuccess:(e==null?void 0:e.colorSuccess)??r.authSuccess,authFontHeadline:(e==null?void 0:e.fontFamily)??r.authFontHeadline,authFontBody:(e==null?void 0:e.fontFamily)??r.authFontBody}}function Ns(a,r){const e=parseInt(a.replace("#",""),16),o=Math.max(0,(e>>16)-Math.round(2.55*r)),n=Math.max(0,(e>>8&255)-Math.round(2.55*r)),u=Math.max(0,(e&255)-Math.round(2.55*r));return`#${(o<<16|n<<8|u).toString(16).padStart(6,"0")}`}function ks(a,r){const e=parseInt(a.replace("#",""),16),o=Math.min(255,(e>>16)+Math.round(2.55*r)),n=Math.min(255,(e>>8&255)+Math.round(2.55*r)),u=Math.min(255,(e&255)+Math.round(2.55*r));return`#${(o<<16|n<<8|u).toString(16).padStart(6,"0")}`}function Q(a){return`
|
|
2
2
|
:host {
|
|
3
3
|
all: initial;
|
|
4
4
|
font-family: ${a.fontFamily};
|
|
@@ -879,7 +879,7 @@
|
|
|
879
879
|
border: 1px solid ${a.authOutlineVariant}26;
|
|
880
880
|
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
|
|
881
881
|
width: 100%;
|
|
882
|
-
max-width:
|
|
882
|
+
max-width: 520px;
|
|
883
883
|
overflow: hidden;
|
|
884
884
|
}
|
|
885
885
|
|
|
@@ -2040,4 +2040,4 @@
|
|
|
2040
2040
|
.ss-auth-signout-row { flex-direction: column; text-align: center; }
|
|
2041
2041
|
.ss-auth-signout-info { flex-direction: column; }
|
|
2042
2042
|
}
|
|
2043
|
-
`}function M({children:a,appearance:r}){const e=t.useRef(null),[o,n]=t.useState(null);t.useEffect(()=>{var x;if(!e.current||e.current.shadowRoot){n(((x=e.current)==null?void 0:x.shadowRoot)??null);return}const l=e.current.attachShadow({mode:"open"});if((r==null?void 0:r.fontUrl)!==null){const p=document.createElement("link");p.rel="stylesheet",p.href=(r==null?void 0:r.fontUrl)??"https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Inter:wght@400;500;600&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap",l.appendChild(p)}const c=Y(r),d=document.createElement("style");d.textContent=Q(c),l.appendChild(d);const i=document.createElement("div");l.appendChild(i),n(l)},[]),t.useEffect(()=>{if(!o)return;const l=o.querySelector("style");if(l){const c=Y(r);l.textContent=Q(c)}},[r,o]);const u=(o==null?void 0:o.querySelector("div"))??null;return s.jsx("div",{ref:e,style:{display:"contents"},children:u&&vs.createPortal(a,u)})}function H(){const{client:a,user:r,isLoaded:e}=E();return{isLoaded:e,isSignedIn:!!r,user:r,signOut:t.useCallback(()=>a.auth.signOut(),[a]),getToken:t.useCallback(()=>a.auth.getToken(),[a])}}function $s(){const{user:a,isLoaded:r}=E();return{user:a,isLoaded:r}}function Z(){const{client:a}=E(),[r,e]=t.useState(!1),[o,n]=t.useState(null),u=t.useCallback(async(d,i)=>{e(!0),n(null);try{return await a.auth.signIn(d,i)}catch(x){return n(x instanceof Error?x.message:"Sign in failed"),null}finally{e(!1)}},[a]),l=t.useCallback(async d=>{e(!0),n(null);try{return await a.auth.signInWithOAuth(d)}catch(i){return n(i instanceof Error?i.message:"OAuth sign in failed"),null}finally{e(!1)}},[a]),c=t.useCallback(async(d,i)=>{e(!0),n(null);try{return await a.auth.submitMfaCode(d,i)}catch(x){return n(x instanceof Error?x.message:"MFA verification failed"),null}finally{e(!1)}},[a]);return{signIn:u,signInWithOAuth:l,submitMfaCode:c,isLoading:r,error:o,setError:n}}function as(){const{client:a}=E(),[r,e]=t.useState(!1),[o,n]=t.useState(null);return{signUp:t.useCallback(async(l,c)=>{e(!0),n(null);try{return await a.auth.signUp(l,c)}catch(d){return n(d instanceof Error?d.message:"Sign up failed"),null}finally{e(!1)}},[a]),isLoading:r,error:o,setError:n}}function K(){const{client:a}=E(),[r,e]=t.useState([]),[o,n]=t.useState(null),[u,l]=t.useState([]),[c,d]=t.useState([]),[i,x]=t.useState(!1),[p,g]=t.useState(null),m=t.useCallback(async()=>{x(!0),g(null);try{const w=await a.auth.listOrgs();e(w);const f=typeof window<"u"?localStorage.getItem("ss_selected_org"):null;if(f&&w.some(y=>y.id===f)&&!o){const y=w.find(C=>C.id===f);n(y);try{const C=await a.auth.listMembers(y.id);l(C)}catch{}}}catch(w){g(w instanceof Error?w.message:"Failed to load organizations")}finally{x(!1)}},[a,o]);t.useEffect(()=>{m()},[m]);const v=t.useCallback(async w=>{try{const f=await a.auth.getOrg(w);n(f),typeof window<"u"&&localStorage.setItem("ss_selected_org",w);const y=await a.auth.listMembers(w);l(y)}catch(f){g(f instanceof Error?f.message:"Failed to load organization")}},[a]),b=t.useCallback(async(w,f)=>{try{const y=await a.auth.createOrg(w,f);return e(C=>[...C,y]),y}catch(y){return g(y instanceof Error?y.message:"Failed to create organization"),null}},[a]),N=t.useCallback(async(w,f)=>{try{const y=await a.auth.updateOrg(w,f);return e(C=>C.map(B=>B.id===w?y:B)),(o==null?void 0:o.id)===w&&n(y),y}catch(y){return g(y instanceof Error?y.message:"Failed to update organization"),null}},[a,o]),h=t.useCallback(async w=>{try{return await a.auth.deleteOrg(w),e(f=>f.filter(y=>y.id!==w)),(o==null?void 0:o.id)===w&&(n(null),l([]),d([]),typeof window<"u"&&localStorage.removeItem("ss_selected_org")),!0}catch(f){return g(f instanceof Error?f.message:"Failed to delete organization"),!1}},[a,o]),j=t.useCallback(async(w,f,y)=>{try{return await a.auth.sendInvite(w,f,y)}catch(C){return g(C instanceof Error?C.message:"Failed to send invite"),null}},[a]),S=t.useCallback(async w=>{try{const f=await a.auth.listInvites(w);d(f)}catch(f){g(f instanceof Error?f.message:"Failed to load invites")}},[a]),k=t.useCallback(async(w,f)=>{try{return await a.auth.revokeInvite(w,f),d(y=>y.filter(C=>C.id!==f)),!0}catch(y){return g(y instanceof Error?y.message:"Failed to revoke invite"),!1}},[a]),P=t.useCallback(async(w,f,y)=>{try{return await a.auth.updateMemberRole(w,f,y),l(C=>C.map(B=>B.userId===f?{...B,role:y}:B)),!0}catch(C){return g(C instanceof Error?C.message:"Failed to update member role"),!1}},[a]),z=t.useCallback(async(w,f)=>{try{return await a.auth.removeMember(w,f),l(y=>y.filter(C=>C.userId!==f)),!0}catch(y){return g(y instanceof Error?y.message:"Failed to remove member"),!1}},[a]),F=t.useCallback(async w=>{try{const f=await a.auth.listMembers(w);l(f)}catch(f){g(f instanceof Error?f.message:"Failed to load members")}},[a]);return{orgs:r,selectedOrg:o,members:u,invites:c,isLoading:i,error:p,setError:g,refresh:m,selectOrg:v,createOrg:b,updateOrg:N,deleteOrg:h,sendInvite:j,refreshInvites:S,revokeInvite:k,updateMemberRole:P,removeMember:z,refreshMembers:F}}function es(){const{client:a}=E(),[r,e]=t.useState(!1),[o,n]=t.useState(null);return{deleteAccount:t.useCallback(async()=>{e(!0),n(null);try{return await a.auth.deleteAccount(),!0}catch(l){return n(l instanceof Error?l.message:"Failed to delete account"),!1}finally{e(!1)}},[a]),isLoading:r,error:o,setError:n}}function X(){const{client:a,user:r}=E(),[e,o]=t.useState(!1),[n,u]=t.useState(null),[l,c]=t.useState(null),d=t.useCallback(async p=>{o(!0),u(null),c(null);try{const g=await a.auth.updateProfile(p);return c("Profile updated"),g}catch(g){return u(g instanceof Error?g.message:"Failed to update profile"),null}finally{o(!1)}},[a]),i=t.useCallback(async(p,g)=>{o(!0),u(null),c(null);try{return await a.auth.changePassword(p,g),c("Password changed successfully"),!0}catch(m){return u(m instanceof Error?m.message:"Failed to change password"),!1}finally{o(!1)}},[a]),x=t.useCallback(async p=>{o(!0),u(null),c(null);try{const g=await a.auth.uploadAvatar(p);return c("Avatar updated"),g}catch(g){return u(g instanceof Error?g.message:"Failed to upload avatar"),null}finally{o(!1)}},[a]);return{user:r,updateProfile:d,uploadAvatar:x,changePassword:i,isLoading:e,error:n,success:l,setError:u,setSuccess:c}}const ts='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/></svg>',rs='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" fill="currentColor"/></svg>',$={close:"close",person:"person",logout:"logout",checkCircle:"check_circle",unfoldMore:"unfold_more",cloudUpload:"cloud_upload",zoomIn:"zoom_in",zoomOut:"zoom_out",lock:"lock",visibility:"visibility",visibilityOff:"visibility_off",add:"add",addCircle:"add_circle",camera:"photo_camera",security:"security",errorOutline:"error_outline",info:"info",arrowForward:"arrow_forward",verified:"verified",token:"token",autoAwesome:"auto_awesome",corporateFare:"corporate_fare",cloudDone:"cloud_done",check:"check",image:"image"};function Cs({appearance:a,signUpUrl:r,onSignUp:e}){const{appearance:o,settings:n}=E(),{signIn:u,signInWithOAuth:l,submitMfaCode:c,isLoading:d,error:i,setError:x}=Z(),p=a??o,[g,m]=t.useState(""),[v,b]=t.useState(""),[N,h]=t.useState(!1),[j,S]=t.useState(!1),[k,P]=t.useState(""),[z,F]=t.useState(["","","","","",""]),w=t.useRef([]),f=t.useCallback(async L=>{if(L.preventDefault(),j){await c(k,z.join(""));return}const T=await u(g,v);T&&U.isMfaRequired(T)&&(P(T.mfaToken),S(!0),x(null))},[g,v,j,k,z,u,c,x]),y=t.useCallback(async L=>{await l(L)},[l]),C=t.useCallback((L,T)=>{var R;if(!/^\d*$/.test(T))return;const O=T.slice(-1);F(_=>{const q=[..._];return q[L]=O,q}),O&&L<5&&((R=w.current[L+1])==null||R.focus())},[]),B=t.useCallback((L,T)=>{var O;T.key==="Backspace"&&!z[L]&&L>0&&((O=w.current[L-1])==null||O.focus())},[z]),D=(n==null?void 0:n.googleEnabled)||(n==null?void 0:n.githubEnabled);return s.jsx(M,{appearance:p,children:s.jsx("div",{className:"ss-auth-card",children:s.jsxs("div",{className:"ss-auth-card-body",children:[s.jsxs("div",{className:"ss-auth-header",children:[s.jsx("div",{className:"ss-auth-brand-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:$.token})}),s.jsx("h1",{className:"ss-auth-title",children:"Sign in to your account"}),s.jsx("p",{className:"ss-auth-subtitle",children:"Welcome back to your workspace"})]}),!j&&D&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ss-auth-oauth-grid",children:[(n==null?void 0:n.googleEnabled)&&s.jsxs("button",{type:"button",className:"ss-auth-btn-social",onClick:()=>y("google"),disabled:d,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:ts}}),"Google"]}),(n==null?void 0:n.githubEnabled)&&s.jsxs("button",{type:"button",className:"ss-auth-btn-social",onClick:()=>y("github"),disabled:d,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:rs}}),"GitHub"]})]}),s.jsx("div",{className:"ss-auth-divider",children:"or continue with"})]}),i&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:i})]}),s.jsxs("form",{onSubmit:f,children:[j?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ss-auth-mfa-divider",children:s.jsx("span",{children:"Verification Required"})}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"6-Digit Code"}),s.jsx("div",{className:"ss-auth-mfa-group",children:z.map((L,T)=>s.jsx("input",{ref:O=>{w.current[T]=O},className:"ss-auth-mfa-digit",type:"text",inputMode:"numeric",maxLength:1,value:L,onChange:O=>C(T,O.target.value),onKeyDown:O=>B(T,O),autoFocus:T===0},T))}),s.jsx("p",{className:"ss-auth-mfa-hint",children:"We sent a 6-digit code to your registered email."})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-email",children:"Email Address"}),s.jsx("input",{id:"ss-email",className:"ss-auth-input",type:"email",autoComplete:"email",placeholder:"name@company.com",value:g,onChange:L=>m(L.target.value),required:!0})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsxs("div",{className:"ss-auth-field-row",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-password",style:{marginBottom:0},children:"Password"}),s.jsx("span",{className:"ss-auth-link",style:{fontSize:"12px"},children:"Forgot?"})]}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{id:"ss-password",className:"ss-auth-input",type:N?"text":"password",autoComplete:"current-password",placeholder:"••••••••",value:v,onChange:L=>b(L.target.value),required:!0}),s.jsx("button",{type:"button",className:"ss-auth-visibility-toggle",onClick:()=>h(!N),children:s.jsx("span",{className:"material-symbols-outlined",children:N?$.visibilityOff:$.visibility})})]})]})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:d,children:[d&&s.jsx("span",{className:"ss-auth-spinner"}),j?"Verify":"Sign in",!d&&s.jsx("span",{className:"material-symbols-outlined",children:$.arrowForward})]})]}),j?s.jsx("div",{className:"ss-auth-footer",children:s.jsx("span",{className:"ss-auth-link",onClick:()=>{S(!1),F(["","","","","",""]),x(null)},children:"Back to sign in"})}):s.jsxs("div",{className:"ss-auth-footer",children:["Don't have an account?"," ",e?s.jsx("span",{className:"ss-auth-link",onClick:e,children:"Sign up"}):r?s.jsx("a",{className:"ss-auth-link",href:r,children:"Sign up"}):s.jsx("span",{className:"ss-auth-link",children:"Sign up"})]})]})})})}function Ps({appearance:a,signInUrl:r,onSignIn:e}){const{appearance:o,settings:n}=E(),{signUp:u,isLoading:l,error:c,setError:d}=as(),{signInWithOAuth:i}=Z(),x=a??o,[p,g]=t.useState(""),[m,v]=t.useState(""),[b,N]=t.useState(""),[h,j]=t.useState(!1),[S,k]=t.useState(null),P=t.useCallback(async f=>{if(f.preventDefault(),k(null),m!==b){k("Passwords do not match");return}const y=(n==null?void 0:n.passwordMinLength)??8;if(m.length<y){k(`Password must be at least ${y} characters`);return}await u(p,m)},[p,m,b,n,u]),z=t.useCallback(async f=>{await i(f)},[i]),F=(n==null?void 0:n.googleEnabled)||(n==null?void 0:n.githubEnabled),w=S||c;return s.jsx(M,{appearance:x,children:s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",maxWidth:"440px"},children:[s.jsxs("div",{className:"ss-auth-header",children:[s.jsx("div",{className:"ss-auth-brand-icon-gradient",children:s.jsx("span",{className:"material-symbols-outlined",children:$.autoAwesome})}),s.jsx("h1",{className:"ss-auth-title ss-auth-title-lg",children:"Create your account"}),s.jsx("p",{className:"ss-auth-subtitle",children:"Join the ecosystem"})]}),s.jsx("div",{className:"ss-auth-card",children:s.jsxs("div",{className:"ss-auth-card-body",children:[F&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ss-auth-oauth-grid",children:[(n==null?void 0:n.googleEnabled)&&s.jsxs("button",{type:"button",className:"ss-auth-btn-social",onClick:()=>z("google"),disabled:l,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:ts}}),"Google"]}),(n==null?void 0:n.githubEnabled)&&s.jsxs("button",{type:"button",className:"ss-auth-btn-social",onClick:()=>z("github"),disabled:l,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:rs}}),"GitHub"]})]}),s.jsx("div",{className:"ss-auth-divider",children:"or sign up with email"})]}),w&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:w})]}),s.jsxs("form",{onSubmit:P,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-signup-email",children:"Email"}),s.jsx("input",{id:"ss-signup-email",className:"ss-auth-input",type:"email",autoComplete:"email",placeholder:"name@company.com",value:p,onChange:f=>g(f.target.value),required:!0})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-signup-password",children:"Password"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{id:"ss-signup-password",className:"ss-auth-input",type:h?"text":"password",autoComplete:"new-password",placeholder:"••••••••",value:m,onChange:f=>{v(f.target.value),k(null)},required:!0}),s.jsx("button",{type:"button",className:"ss-auth-visibility-toggle",onClick:()=>j(!h),children:s.jsx("span",{className:"material-symbols-outlined",children:h?$.visibilityOff:$.visibility})})]})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-signup-confirm",children:"Confirm Password"}),s.jsx("input",{id:"ss-signup-confirm",className:"ss-auth-input",type:"password",autoComplete:"new-password",placeholder:"••••••••",value:b,onChange:f=>{N(f.target.value),k(null)},required:!0})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:l,children:[l&&s.jsx("span",{className:"ss-auth-spinner"}),"Sign up",!l&&s.jsx("span",{className:"material-symbols-outlined",children:$.arrowForward})]})]}),s.jsxs("div",{className:"ss-auth-footer",children:["Already have an account?"," ",e?s.jsx("span",{className:"ss-auth-link",onClick:e,children:"Sign in"}):r?s.jsx("a",{className:"ss-auth-link",href:r,children:"Sign in"}):s.jsx("span",{className:"ss-auth-link",children:"Sign in"})]})]})})]})})}const I=320,V=128;function zs({file:a,onCrop:r,onCancel:e}){const o=t.useRef(null),n=t.useRef(null),[u,l]=t.useState(1),[c,d]=t.useState({x:0,y:0}),[i,x]=t.useState(!1),p=t.useRef({x:0,y:0,ox:0,oy:0}),[g,m]=t.useState(!1);t.useEffect(()=>{const h=new Image,j=URL.createObjectURL(a);return h.onload=()=>{n.current=h,m(!0),d({x:0,y:0}),l(1)},h.src=j,()=>URL.revokeObjectURL(j)},[a]),t.useEffect(()=>{if(!g||!n.current||!o.current)return;const h=o.current.getContext("2d");if(!h)return;const j=n.current;h.clearRect(0,0,I,I),h.fillStyle="#111",h.fillRect(0,0,I,I);const S=Math.max(I/j.width,I/j.height)*u,k=j.width*S,P=j.height*S,z=(I-k)/2+c.x,F=(I-P)/2+c.y;h.save(),h.beginPath(),h.arc(I/2,I/2,V,0,Math.PI*2),h.clip(),h.drawImage(j,z,F,k,P),h.restore(),h.save(),h.fillStyle="rgba(0, 0, 0, 0.6)",h.fillRect(0,0,I,I),h.globalCompositeOperation="destination-out",h.beginPath(),h.arc(I/2,I/2,V,0,Math.PI*2),h.fill(),h.restore(),h.save(),h.beginPath(),h.arc(I/2,I/2,V,0,Math.PI*2),h.clip(),h.drawImage(j,z,F,k,P),h.restore(),h.strokeStyle="rgba(255, 255, 255, 0.4)",h.lineWidth=2,h.beginPath(),h.arc(I/2,I/2,V,0,Math.PI*2),h.stroke()},[u,c,g]);const v=t.useCallback(h=>{x(!0),p.current={x:h.clientX,y:h.clientY,ox:c.x,oy:c.y},h.target.setPointerCapture(h.pointerId)},[c]),b=t.useCallback(h=>{i&&d({x:p.current.ox+(h.clientX-p.current.x),y:p.current.oy+(h.clientY-p.current.y)})},[i]),N=t.useCallback(()=>x(!1),[]);return t.useCallback(()=>{if(!n.current)return;const h=document.createElement("canvas"),j=V*2;h.width=j,h.height=j;const S=h.getContext("2d");if(!S)return;const k=n.current,P=Math.max(I/k.width,I/k.height)*u,z=k.width*P,F=k.height*P,w=(I-z)/2+c.x-(I/2-V),f=(I-F)/2+c.y-(I/2-V);S.beginPath(),S.arc(V,V,V,0,Math.PI*2),S.clip(),S.drawImage(k,w,f,z,F),h.toBlob(y=>{y&&r(y)},"image/png")},[u,c,r]),s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"24px"},children:[s.jsxs("div",{className:"ss-auth-crop-area",children:[s.jsx("canvas",{ref:o,width:I,height:I,style:{cursor:i?"grabbing":"grab",width:"100%",height:"100%"},onPointerDown:v,onPointerMove:b,onPointerUp:N}),s.jsx("div",{className:"ss-auth-crop-size-badge",children:"256 x 256 px"})]}),s.jsxs("div",{className:"ss-auth-zoom-control",style:{width:"100%",maxWidth:"280px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.zoomOut}),s.jsx("input",{type:"range",min:"1",max:"3",step:"0.01",value:u,onChange:h=>l(parseFloat(h.target.value)),className:"ss-auth-zoom-slider"}),s.jsx("span",{className:"material-symbols-outlined",children:$.zoomIn})]})]})}function ns({onUpload:a,onClose:r,isLoading:e}){const[o,n]=t.useState(null),[u,l]=t.useState(!1),[c,d]=t.useState(null),i=t.useRef(null),x=t.useCallback(m=>{if(!m.type.startsWith("image/")){d("Please select an image file");return}if(m.size>5*1024*1024){d("Image must be smaller than 5 MB");return}d(null),n(m)},[]),p=t.useCallback(m=>{m.preventDefault(),l(!1);const v=m.dataTransfer.files[0];v&&x(v)},[x]),g=t.useCallback(async m=>{await a(m)},[a]);return s.jsx("div",{className:"ss-auth-modal-overlay",onClick:m=>{m.target===m.currentTarget&&r()},children:s.jsxs("div",{className:"ss-auth-modal ss-auth-card-wide",children:[s.jsxs("div",{className:"ss-auth-modal-header",children:[s.jsx("h2",{children:"Upload avatar"}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:r,children:s.jsx("span",{className:"material-symbols-outlined",children:$.close})})]}),s.jsxs("div",{className:"ss-auth-modal-body",children:[c&&s.jsxs("div",{className:"ss-auth-error",style:{marginBottom:"24px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:c})]}),s.jsxs("div",{className:"ss-auth-upload-grid",children:[s.jsx("div",{children:o?s.jsx(zs,{file:o,onCrop:g,onCancel:()=>n(null)}):s.jsxs("div",{className:"ss-auth-crop-area",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",aspectRatio:"1"},children:[s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"48px",opacity:.3},children:$.image}),s.jsx("span",{style:{fontSize:"12px",opacity:.4},children:"No image selected"})]})}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[s.jsxs("div",{className:`ss-auth-dropzone${u?" ss-auth-dropzone-active":""}`,onDragOver:m=>{m.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:p,onClick:()=>{var m;return(m=i.current)==null?void 0:m.click()},style:{minHeight:"180px"},children:[s.jsx("div",{className:"ss-auth-dropzone-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:$.cloudUpload})}),s.jsx("span",{className:"ss-auth-dropzone-title",children:"Drag and drop"}),s.jsxs("span",{className:"ss-auth-dropzone-desc",children:["JPG, PNG or WEBP",s.jsx("br",{}),"Max file size 5 MB"]}),s.jsx("button",{type:"button",className:"ss-auth-dropzone-btn",children:"Choose File"}),s.jsx("input",{ref:i,type:"file",accept:"image/*",style:{display:"none"},onChange:m=>{var v;(v=m.target.files)!=null&&v[0]&&x(m.target.files[0])}})]}),s.jsxs("div",{className:"ss-auth-info-box",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.info}),s.jsx("span",{children:"Your profile photo will be visible to all members of your organization."})]})]})]})]}),s.jsxs("div",{className:"ss-auth-modal-footer",children:[s.jsx("button",{type:"button",className:"ss-auth-btn-ghost",onClick:r,children:"Cancel"}),s.jsxs("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",onClick:()=>{},disabled:!o||e,style:{width:"auto"},children:[e&&s.jsx("span",{className:"ss-auth-spinner"}),"Save Profile",!e&&s.jsx("span",{className:"material-symbols-outlined",children:$.check})]})]})]})})}function Es({appearance:a,afterSignOutUrl:r,afterDeleteAccountUrl:e,showOrgSwitcher:o=!0,onOrgChange:n,onOrgSettingsClick:u}){const{appearance:l}=E(),{user:c,signOut:d}=H(),i=a??l,[x,p]=t.useState(!1),[g,m]=t.useState(!1),[v,b]=t.useState(""),[N,h]=t.useState(null),[j,S]=t.useState(!1),k=t.useRef(null),{orgs:P,selectedOrg:z,selectOrg:F,createOrg:w}=K(),f=t.useCallback(C=>{k.current&&!C.composedPath().includes(k.current)&&p(!1)},[]);t.useEffect(()=>{if(x){const C=setTimeout(()=>{document.addEventListener("click",f)},0);return()=>{clearTimeout(C),document.removeEventListener("click",f)}}},[x,f]);const y=t.useCallback(async C=>{C.preventDefault(),h(null),S(!0);const B=v.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");try{const D=await w(v,B);D&&(await F(D.id),n==null||n(D),b(""),p(!1))}catch(D){h(D instanceof Error?D.message:"Failed to create organization")}finally{S(!1)}},[v,w,F,n]);return c?s.jsx(M,{appearance:i,children:s.jsxs("div",{style:{position:"relative",display:"inline-block"},ref:k,children:[s.jsx("button",{type:"button",className:"ss-auth-avatar-trigger",onClick:()=>p(!x),"aria-label":"User menu",children:c.avatarUrl?s.jsx("img",{src:c.avatarUrl,alt:""}):s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",fontWeight:700},children:(c.name||c.email).charAt(0).toUpperCase()})}),x&&s.jsxs("div",{className:"ss-auth-dropdown ss-auth-glass-panel",style:{minWidth:"320px"},children:[s.jsxs("div",{className:"ss-auth-dropdown-header",children:[s.jsx("div",{className:"ss-auth-dropdown-avatar",children:c.avatarUrl?s.jsx("img",{src:c.avatarUrl,alt:""}):s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"20px",fontWeight:800},children:(c.name||c.email).charAt(0).toUpperCase()})}),s.jsxs("div",{children:[c.name&&s.jsx("div",{className:"ss-auth-dropdown-name",children:c.name}),s.jsx("div",{className:"ss-auth-dropdown-email",children:c.email})]})]}),s.jsx("div",{style:{padding:"4px 8px"},children:s.jsxs("button",{type:"button",className:"ss-auth-dropdown-action",onClick:()=>{p(!1),m(!0)},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.person}),"Profile"]})}),o&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ss-auth-section-label",children:"Organizations"}),s.jsx("div",{style:{padding:"0 8px 4px"},children:P.map(C=>{const B=(z==null?void 0:z.id)===C.id,D=C.name.split(" ").map(L=>L[0]).join("").slice(0,2).toUpperCase();return s.jsxs("button",{type:"button",className:`ss-auth-org-item${B?" ss-auth-org-item-active":""}`,onClick:async()=>{p(!1),await F(C.id),n==null||n(C)},children:[s.jsxs("div",{className:"ss-auth-org-item-inner",children:[s.jsx("div",{className:`ss-auth-org-avatar${B?"":" ss-auth-org-avatar-inactive"}`,children:D}),s.jsx("span",{style:{fontFamily:"'Manrope', sans-serif",letterSpacing:"-0.01em"},children:C.name})]}),B&&s.jsx("span",{className:"material-symbols-outlined ss-auth-org-check",style:{fontSize:"18px"},children:$.checkCircle})]},C.id)})}),s.jsxs("div",{className:"ss-auth-inline-create",children:[N&&s.jsx("div",{className:"ss-auth-error",style:{marginBottom:"8px",fontSize:"12px"},children:s.jsx("span",{children:N})}),s.jsx("form",{onSubmit:y,children:s.jsxs("div",{className:"ss-auth-inline-create-input",children:[s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"New organization name",value:v,onChange:C=>b(C.target.value),required:!0,style:{fontSize:"13px",padding:"10px 40px 10px 12px"}}),s.jsx("button",{type:"submit",className:"ss-auth-inline-create-btn",disabled:j||!v.trim(),children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"20px"},children:$.add})})]})})]}),z&&u&&s.jsx("div",{style:{padding:"0 8px 4px"},children:s.jsxs("button",{type:"button",className:"ss-auth-dropdown-action",onClick:()=>{p(!1),u(z)},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.corporateFare}),"Org settings"]})})]}),s.jsx("div",{className:"ss-auth-signout-section",style:{padding:"8px"},children:s.jsxs("button",{type:"button",className:"ss-auth-dropdown-action",onClick:async()=>{p(!1),await d(),r&&(window.location.href=r)},style:{color:"inherit"},children:[s.jsx("span",{className:"material-symbols-outlined",style:{color:"inherit"},children:$.logout}),"Sign out"]})})]}),g&&s.jsx(Os,{onClose:()=>m(!1),afterDeleteAccountUrl:e})]})}):null}function Os({onClose:a,afterDeleteAccountUrl:r}){const{user:e,updateProfile:o,uploadAvatar:n,changePassword:u,isLoading:l,error:c,success:d,setError:i,setSuccess:x}=X(),{signOut:p}=H(),{deleteAccount:g,isLoading:m,error:v,setError:b}=es(),[N,h]=t.useState((e==null?void 0:e.name)??""),[j,S]=t.useState((e==null?void 0:e.avatarUrl)??""),[k,P]=t.useState(!1),[z,F]=t.useState(""),[w,f]=t.useState(""),[y,C]=t.useState(""),[B,D]=t.useState(null),[L,T]=t.useState(!1),[O,R]=t.useState(""),_=t.useCallback(async A=>{A.preventDefault(),i(null),x(null),await o({name:N,avatarUrl:j||void 0})},[N,j,o,i,x]),q=t.useCallback(async A=>{const G=await n(A);G&&(S(G.avatarUrl),P(!1))},[n]),gs=t.useCallback(async A=>{if(A.preventDefault(),D(null),i(null),x(null),w!==y){D("Passwords do not match");return}if(w.length<8){D("Password must be at least 8 characters");return}await u(z,w)&&(F(""),f(""),C(""))},[z,w,y,u,i,x]),fs=t.useCallback(async()=>{await g()&&(await p(),r&&(window.location.href=r))},[g,p,r]),ms=(e==null?void 0:e.provider)==="email",bs=O===(e==null?void 0:e.email),ys=((e==null?void 0:e.name)||(e==null?void 0:e.email)||"?").charAt(0).toUpperCase();return s.jsx("div",{className:"ss-auth-modal-overlay",onClick:A=>{A.target===A.currentTarget&&a()},children:s.jsxs("div",{className:"ss-auth-modal",style:{maxWidth:"640px"},children:[s.jsxs("div",{className:"ss-auth-modal-header",children:[s.jsx("h2",{children:"Profile"}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:a,children:s.jsx("span",{className:"material-symbols-outlined",children:$.close})})]}),s.jsxs("div",{className:"ss-auth-profile-header",children:[s.jsxs("div",{className:"ss-auth-avatar-lg",onClick:()=>P(!0),children:[j?s.jsx("img",{src:j,alt:""}):s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"48px",fontWeight:800,opacity:.4},children:ys}),s.jsxs("div",{className:"ss-auth-avatar-overlay",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.camera}),s.jsx("span",{children:"Edit"})]})]}),s.jsxs("div",{className:"ss-auth-profile-info",children:[s.jsxs("h2",{className:"ss-auth-profile-name",children:[(e==null?void 0:e.name)||"Unnamed User",(e==null?void 0:e.emailVerified)&&s.jsxs("span",{className:"ss-auth-badge ss-auth-badge-success",children:[s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"12px",fontVariationSettings:"'FILL' 1"},children:$.verified}),"Verified"]})]}),s.jsx("p",{className:"ss-auth-profile-desc",children:e==null?void 0:e.email})]})]}),s.jsxs("div",{className:"ss-auth-modal-body",children:[c&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:c})]}),d&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.check}),s.jsx("span",{children:d})]}),s.jsxs("form",{onSubmit:_,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Full Name"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"Your name",value:N,onChange:A=>h(A.target.value)})]}),s.jsxs("div",{className:"ss-auth-profile-grid",style:{marginBottom:"16px"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Email Address"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"email",value:(e==null?void 0:e.email)??"",readOnly:!0}),s.jsx("span",{className:"ss-auth-visibility-toggle",style:{cursor:"default"},children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"18px"},children:$.lock})})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Auth Provider"}),s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"text",value:(e==null?void 0:e.provider)??"",readOnly:!0})]})]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary ss-auth-btn-sm",disabled:l,style:{width:"auto"},children:[l&&s.jsx("span",{className:"ss-auth-spinner"}),"Save changes"]})})]}),ms&&s.jsxs("div",{className:"ss-auth-section",children:[s.jsxs("div",{className:"ss-auth-section-title",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.security}),"Security Credentials"]}),B&&s.jsxs("div",{className:"ss-auth-error",style:{marginTop:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:B})]}),s.jsxs("form",{onSubmit:gs,style:{marginTop:"16px"},children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Current Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"••••••••••••",value:z,onChange:A=>F(A.target.value),required:!0})]}),s.jsxs("div",{className:"ss-auth-profile-grid",style:{marginBottom:"16px"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"New Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"Min. 8 characters",value:w,onChange:A=>f(A.target.value),required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Confirm New Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"Repeat new password",value:y,onChange:A=>C(A.target.value),required:!0})]})]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:s.jsx("button",{type:"submit",className:"ss-auth-btn-ghost",disabled:l,children:"Update Security"})})]})]}),s.jsxs("div",{className:"ss-auth-section",children:[s.jsx("div",{className:"ss-auth-section-title",style:{color:"inherit"},children:"Danger Zone"}),s.jsx("p",{className:"ss-auth-section-desc",style:{marginBottom:"16px"},children:"Deleting your account is permanent. All organizations you own will also be deleted."}),v&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:v})]}),L?s.jsxs("div",{children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Type your email to confirm"}),s.jsx("input",{className:"ss-auth-input",type:"email",placeholder:e==null?void 0:e.email,value:O,onChange:A=>R(A.target.value),autoFocus:!0})]}),s.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[s.jsx("button",{type:"button",className:"ss-auth-btn-ghost",onClick:()=>{T(!1),R(""),b(null)},children:"Cancel"}),s.jsxs("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",style:{width:"auto",background:"linear-gradient(135deg, #ef4444, #dc2626)"},disabled:!bs||m,onClick:fs,children:[m&&s.jsx("span",{className:"ss-auth-spinner"}),"Delete account"]})]})]}):s.jsx("button",{type:"button",className:"ss-auth-btn-outline",style:{borderColor:"currentColor",width:"auto"},onClick:()=>T(!0),children:"Delete my account"})]})]}),k&&s.jsx(ns,{onUpload:q,onClose:()=>P(!1),isLoading:l})]})})}function Is({appearance:a}){const{appearance:r}=E(),{user:e,signOut:o}=H(),{updateProfile:n,uploadAvatar:u,changePassword:l,isLoading:c,error:d,success:i,setError:x,setSuccess:p}=X(),g=a??r,[m,v]=t.useState((e==null?void 0:e.name)??""),[b,N]=t.useState((e==null?void 0:e.avatarUrl)??""),[h,j]=t.useState(!1),[S,k]=t.useState(""),[P,z]=t.useState(""),[F,w]=t.useState(""),[f,y]=t.useState(null),C=t.useCallback(async O=>{O.preventDefault(),x(null),p(null),await n({name:m,avatarUrl:b||void 0})},[m,b,n,x,p]),B=t.useCallback(async O=>{const R=await u(O);R&&(N(R.avatarUrl),j(!1))},[u]),D=t.useCallback(async O=>{if(O.preventDefault(),y(null),x(null),p(null),P!==F){y("Passwords do not match");return}if(P.length<8){y("Password must be at least 8 characters");return}await l(S,P)&&(k(""),z(""),w(""))},[S,P,F,l,x,p]);if(!e)return null;const L=e.provider==="email",T=(e.name||e.email).charAt(0).toUpperCase();return s.jsx(M,{appearance:g,children:s.jsxs("div",{className:"ss-auth-card",style:{maxWidth:"640px"},children:[s.jsxs("div",{className:"ss-auth-profile-header",children:[s.jsxs("div",{className:"ss-auth-avatar-lg",onClick:()=>j(!0),children:[b?s.jsx("img",{src:b,alt:""}):s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"48px",fontWeight:800,opacity:.4},children:T}),s.jsxs("div",{className:"ss-auth-avatar-overlay",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.camera}),s.jsx("span",{children:"Edit"})]})]}),s.jsxs("div",{className:"ss-auth-profile-info",children:[s.jsxs("h2",{className:"ss-auth-profile-name",children:[e.name||"Unnamed User",e.emailVerified&&s.jsxs("span",{className:"ss-auth-badge ss-auth-badge-success",children:[s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"12px",fontVariationSettings:"'FILL' 1"},children:$.verified}),"Verified"]})]}),s.jsx("p",{className:"ss-auth-profile-desc",children:e.email})]})]}),s.jsxs("div",{className:"ss-auth-card-body",children:[d&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:d})]}),i&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.check}),s.jsx("span",{children:i})]}),s.jsxs("form",{onSubmit:C,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Full Name"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"Your name",value:m,onChange:O=>v(O.target.value)})]}),s.jsxs("div",{className:"ss-auth-profile-grid",style:{marginBottom:"16px"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Email Address"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"email",value:e.email,readOnly:!0}),s.jsx("span",{className:"ss-auth-visibility-toggle",style:{cursor:"default"},children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"18px"},children:$.lock})})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Auth Provider"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"text",value:e.provider,readOnly:!0}),s.jsx("span",{className:"ss-auth-visibility-toggle",style:{cursor:"default"},children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"18px"},children:$.cloudDone})})]})]})]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary ss-auth-btn-sm",disabled:c,style:{width:"auto"},children:[c&&s.jsx("span",{className:"ss-auth-spinner"}),"Save changes"]})})]}),L&&s.jsxs("div",{className:"ss-auth-section",children:[s.jsxs("div",{className:"ss-auth-section-title",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.security}),"Security Credentials"]}),s.jsx("p",{className:"ss-auth-section-desc",style:{marginBottom:"24px"},children:"Update your password to keep your account secure."}),f&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:f})]}),s.jsxs("form",{onSubmit:D,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Current Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"••••••••••••",value:S,onChange:O=>k(O.target.value),required:!0})]}),s.jsxs("div",{className:"ss-auth-profile-grid",style:{marginBottom:"16px"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"New Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"Min. 8 characters",value:P,onChange:O=>z(O.target.value),required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Confirm New Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"Repeat new password",value:F,onChange:O=>w(O.target.value),required:!0})]})]}),s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.info}),s.jsx("span",{children:"Password must be at least 8 characters long."})]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:s.jsx("button",{type:"submit",className:"ss-auth-btn-ghost",disabled:c,children:"Update Security"})})]})]}),s.jsx("div",{className:"ss-auth-section",style:{borderTop:"none",paddingTop:0,marginTop:"24px"},children:s.jsx("div",{className:"ss-auth-signout-section",style:{borderRadius:"12px",padding:"16px 20px"},children:s.jsxs("div",{className:"ss-auth-signout-row",children:[s.jsxs("div",{className:"ss-auth-signout-info",children:[s.jsx("div",{className:"ss-auth-signout-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:$.logout})}),s.jsxs("div",{children:[s.jsx("div",{className:"ss-auth-signout-title",children:"End Session"}),s.jsx("div",{className:"ss-auth-signout-desc",children:"Terminate your active session"})]})]}),s.jsx("button",{type:"button",className:"ss-auth-btn-outline",onClick:()=>o(),style:{width:"auto",flexShrink:0},children:"Sign out"})]})})})]}),h&&s.jsx(ns,{onUpload:B,onClose:()=>j(!1),isLoading:c})]})})}function Fs({appearance:a,onOrgChange:r}){const{appearance:e}=E(),{orgs:o,selectedOrg:n,selectOrg:u,createOrg:l,isLoading:c}=K(),d=a??e,[i,x]=t.useState(!1),[p,g]=t.useState(""),[m,v]=t.useState(""),[b,N]=t.useState(null),[h,j]=t.useState(!1),S=t.useRef(null),k=t.useCallback(f=>{S.current&&!f.composedPath().includes(S.current)&&x(!1)},[]);t.useEffect(()=>{if(i){const f=setTimeout(()=>{document.addEventListener("click",k)},0);return()=>{clearTimeout(f),document.removeEventListener("click",k)}}},[i,k]);const P=t.useCallback(f=>{g(f),v(f.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},[]),z=t.useCallback(async f=>{f.preventDefault(),N(null),j(!0);try{const y=await l(p,m);y&&(await u(y.id),r==null||r(y),g(""),v(""),x(!1))}catch(y){N(y instanceof Error?y.message:"Failed to create organization")}finally{j(!1)}},[p,m,l,u,r]);if(c)return null;const F=(n==null?void 0:n.name)??(o.length===0?"No organization":"Select organization"),w=n?n.name.split(" ").map(f=>f[0]).join("").slice(0,2).toUpperCase():"--";return s.jsx(M,{appearance:d,children:s.jsxs("div",{style:{position:"relative",display:"inline-block",width:"100%",maxWidth:"360px"},ref:S,children:[s.jsxs("button",{type:"button",className:"ss-auth-org-trigger",onClick:()=>x(!i),children:[s.jsxs("div",{className:"ss-auth-org-trigger-inner",children:[s.jsx("div",{className:"ss-auth-org-avatar",children:w}),s.jsxs("div",{style:{textAlign:"left"},children:[s.jsx("div",{className:"ss-auth-org-trigger-label",children:"Current Organization"}),s.jsx("div",{className:"ss-auth-org-trigger-name",children:F})]})]}),s.jsx("span",{className:"material-symbols-outlined",children:$.unfoldMore})]}),i&&s.jsxs("div",{className:"ss-auth-dropdown ss-auth-dropdown-left ss-auth-glass-panel",style:{width:"100%"},children:[s.jsx("div",{className:"ss-auth-section-label",children:"Your Organizations"}),s.jsx("div",{style:{padding:"0 8px 4px"},children:o.map(f=>{const y=(n==null?void 0:n.id)===f.id,C=f.name.split(" ").map(B=>B[0]).join("").slice(0,2).toUpperCase();return s.jsxs("button",{type:"button",className:`ss-auth-org-item${y?" ss-auth-org-item-active":""}`,onClick:async()=>{x(!1),await u(f.id),r==null||r(f)},children:[s.jsxs("div",{className:"ss-auth-org-item-inner",children:[s.jsx("div",{className:`ss-auth-org-avatar${y?"":" ss-auth-org-avatar-inactive"}`,children:C}),s.jsx("span",{style:{fontFamily:"'Manrope', sans-serif",letterSpacing:"-0.01em"},children:f.name})]}),y&&s.jsx("span",{className:"material-symbols-outlined ss-auth-org-check",style:{fontSize:"18px"},children:$.checkCircle})]},f.id)})}),s.jsxs("div",{className:"ss-auth-org-create",children:[s.jsxs("div",{className:"ss-auth-org-create-header",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.addCircle}),s.jsx("span",{children:"Create organization"})]}),b&&s.jsx("div",{className:"ss-auth-error",style:{marginBottom:"12px",fontSize:"12px"},children:s.jsx("span",{children:b})}),s.jsxs("form",{onSubmit:z,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",style:{fontSize:"10px"},children:"Org Name"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"e.g. Nexus Dynamics",value:p,onChange:f=>P(f.target.value),required:!0,style:{fontSize:"13px",padding:"10px 12px"}})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",style:{fontSize:"10px"},children:"Workspace Slug"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("span",{className:"ss-auth-org-slug-prefix",children:"/"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"nexus-dynamics",value:m,onChange:f=>v(f.target.value),required:!0,style:{fontSize:"13px",padding:"10px 12px 10px 22px"}})]})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:h||!p.trim(),style:{marginTop:"8px"},children:[h&&s.jsx("span",{className:"ss-auth-spinner"}),"Initialize Organization"]})]})]})]})]})})}function Ls(a,r="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:r,minimumFractionDigits:a%100===0?0:2}).format(a/100)}function Bs({plans:a,currentPlanId:r,onSelectPlan:e,interval:o,appearance:n}){const{appearance:u}=E(),l=n??u,c=o?a.filter(d=>d.interval===o||d.isFree):a;return s.jsx(M,{appearance:l,children:s.jsx("div",{className:"ss-pricing-grid",children:c.map(d=>{const i=d.id===r;return s.jsxs("div",{className:`ss-pricing-card ${i?"ss-pricing-card-current":""}`,children:[s.jsxs("div",{className:"ss-pricing-header",children:[s.jsx("h3",{className:"ss-pricing-name",children:d.name}),d.trialDays>0&&s.jsxs("span",{className:"ss-badge ss-badge-trialing",children:[d.trialDays,"-day trial"]}),d.isFree&&s.jsx("span",{className:"ss-badge ss-badge-active",children:"Free"})]}),s.jsx("div",{className:"ss-pricing-price",children:d.isFree?s.jsx("span",{className:"ss-pricing-amount",children:"Free"}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ss-pricing-amount",children:Ls(d.amountCents,d.currency)}),s.jsxs("span",{className:"ss-pricing-interval",children:["/",d.interval]})]})}),d.description&&s.jsx("p",{className:"ss-pricing-desc",children:d.description}),d.features.length>0&&s.jsx("ul",{className:"ss-pricing-features",children:d.features.map((x,p)=>s.jsxs("li",{className:"ss-pricing-feature",children:[s.jsx("span",{className:"ss-check",children:"✓"})," ",x]},p))}),s.jsx("button",{type:"button",className:`ss-btn ${i?"ss-btn-current":"ss-btn-primary"}`,disabled:i,onClick:()=>e(d.id),children:i?"Current plan":"Select plan"})]},d.id)})})})}function Ts(){const{client:a}=E();return{billing:a.billing}}function W(a){const{client:r}=E();return t.useMemo(()=>{if(a){const e=new U.Transport("https://api.saas-support.com/v1",{type:"portalToken",token:a});return new U.BillingClient(e)}return r.billing},[r,a])}function os(a,r){const e=W(r),[o,n]=t.useState(null),[u,l]=t.useState(!0),[c,d]=t.useState(null),i=t.useCallback(async()=>{l(!0),d(null);try{const x=await e.getCustomer(a);n(x)}catch(x){d(x instanceof Error?x.message:"Failed to load subscription")}finally{l(!1)}},[e,a]);return t.useEffect(()=>{i()},[i]),{customer:o,isLoading:u,error:c,refresh:i}}function is(a,r){const e=W(r),[o,n]=t.useState([]),[u,l]=t.useState(!0),[c,d]=t.useState(null),i=t.useCallback(async()=>{l(!0),d(null);try{const x=await e.getInvoices(a);n(x)}catch(x){d(x instanceof Error?x.message:"Failed to load invoices")}finally{l(!1)}},[e,a]);return t.useEffect(()=>{i()},[i]),{invoices:o,isLoading:u,error:c,refresh:i}}function ls(a,r){const e=W(r),[o,n]=t.useState([]),[u,l]=t.useState(!0),[c,d]=t.useState(null),i=t.useCallback(async()=>{l(!0),d(null);try{const x=await e.getCurrentUsage(a);n(x)}catch(x){d(x instanceof Error?x.message:"Failed to load usage")}finally{l(!1)}},[e,a]);return t.useEffect(()=>{i()},[i]),{usage:o,isLoading:u,error:c,refresh:i}}const As={active:"ss-badge-active"};function cs({customerId:a,portalToken:r,onChangePlan:e,onCancel:o,appearance:n}){const{appearance:u}=E(),{customer:l,isLoading:c,error:d}=os(a,r),i=n??u;return s.jsx(M,{appearance:i,children:s.jsxs("div",{className:"ss-card",children:[s.jsx("h2",{className:"ss-title",children:"Subscription"}),c&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),d&&s.jsx("div",{className:"ss-global-error",children:d}),l&&!c&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ss-field",children:[s.jsx("label",{className:"ss-label",children:"Customer"}),s.jsx("input",{className:"ss-input",value:l.name||l.email,disabled:!0,readOnly:!0})]}),s.jsxs("div",{className:"ss-field",children:[s.jsx("label",{className:"ss-label",children:"Status"}),s.jsx("div",{children:s.jsx("span",{className:`ss-badge ${As.active}`,children:"Active"})})]}),s.jsxs("div",{className:"ss-btn-group",children:[e&&s.jsx("button",{type:"button",className:"ss-btn ss-btn-primary",onClick:e,children:"Change plan"}),o&&s.jsx("button",{type:"button",className:"ss-btn ss-btn-danger",onClick:o,children:"Cancel subscription"})]})]})]})})}const Ds={paid:"ss-badge-active",open:"ss-badge-trialing",draft:"ss-badge-paused",void:"ss-badge-canceled",uncollectible:"ss-badge-past-due"};function Ms(a){return new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Us(a){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(a/100)}function ds({customerId:a,portalToken:r,appearance:e}){const{appearance:o}=E(),{invoices:n,isLoading:u,error:l}=is(a,r),c=e??o,d=[...n].sort((i,x)=>new Date(x.createdAt).getTime()-new Date(i.createdAt).getTime());return s.jsx(M,{appearance:c,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[s.jsx("h2",{className:"ss-title",children:"Invoices"}),u&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),l&&s.jsx("div",{className:"ss-global-error",children:l}),!u&&d.length===0&&s.jsx("p",{className:"ss-empty",children:"No invoices yet."}),!u&&d.length>0&&s.jsxs("table",{className:"ss-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"ss-th",children:"Date"}),s.jsx("th",{className:"ss-th",children:"Amount"}),s.jsx("th",{className:"ss-th",children:"Status"}),s.jsx("th",{className:"ss-th",children:"PDF"})]})}),s.jsx("tbody",{children:d.map(i=>s.jsxs("tr",{className:"ss-tr",children:[s.jsx("td",{className:"ss-td",children:Ms(i.createdAt)}),s.jsx("td",{className:"ss-td",children:Us(i.amountCents)}),s.jsx("td",{className:"ss-td",children:s.jsx("span",{className:`ss-badge ${Ds[i.status]||""}`,children:i.status})}),s.jsx("td",{className:"ss-td",children:i.pdfUrl?s.jsx("a",{className:"ss-link",href:i.pdfUrl,target:"_blank",rel:"noopener noreferrer",children:"Download"}):"—"})]},i.id))})]})]})})}function us({customerId:a,limits:r,portalToken:e,appearance:o}){const{appearance:n}=E(),{usage:u,isLoading:l,error:c}=ls(a,e),d=o??n;return s.jsx(M,{appearance:d,children:s.jsxs("div",{className:"ss-card",children:[s.jsx("h2",{className:"ss-title",children:"Usage"}),l&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),c&&s.jsx("div",{className:"ss-global-error",children:c}),!l&&u.length===0&&s.jsx("p",{className:"ss-empty",children:"No usage data."}),!l&&u.map(i=>{const x=r==null?void 0:r[i.metric],p=x?Math.min(100,i.total/x*100):null;return s.jsxs("div",{className:"ss-usage-item",children:[s.jsxs("div",{className:"ss-usage-header",children:[s.jsx("span",{className:"ss-usage-metric",children:i.metric}),s.jsxs("span",{className:"ss-usage-value",children:[i.total.toLocaleString(),x?` / ${x.toLocaleString()}`:""]})]}),p!==null&&s.jsx("div",{className:"ss-progress-bar",children:s.jsx("div",{className:`ss-progress-fill ${p>90?"ss-progress-danger":""}`,style:{width:`${p}%`}})})]},i.metric)})]})})}function Vs({customerId:a,portalToken:r,limits:e,onChangePlan:o,onCancel:n,appearance:u}){const{appearance:l}=E(),c=u??l,[d,i]=t.useState("subscription"),x=[{id:"subscription",label:"Subscription"},{id:"invoices",label:"Invoices"},{id:"usage",label:"Usage"}];return s.jsx(M,{appearance:c,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[s.jsx("h2",{className:"ss-title",children:"Billing"}),s.jsx("div",{className:"ss-tab-group",children:x.map(p=>s.jsx("button",{type:"button",className:`ss-tab ${d===p.id?"ss-tab-active":""}`,onClick:()=>i(p.id),children:p.label},p.id))}),s.jsxs("div",{className:"ss-tab-content",children:[d==="subscription"&&s.jsx(cs,{customerId:a,portalToken:r,onChangePlan:o,onCancel:n}),d==="invoices"&&s.jsx(ds,{customerId:a,portalToken:r}),d==="usage"&&s.jsx(us,{customerId:a,portalToken:r,limits:e})]})]})})}function Rs({customerId:a,portalToken:r,onApplied:e,appearance:o}){const{appearance:n}=E(),u=W(r),l=o??n,[c,d]=t.useState(""),[i,x]=t.useState(!1),[p,g]=t.useState(null),[m,v]=t.useState(null),b=t.useCallback(async N=>{if(N.preventDefault(),!!c.trim()){x(!0),g(null),v(null);try{const h=await u.applyCoupon(a,c.trim());v(`Coupon applied! ${h.discountType==="percent"?`${h.amount}% off`:`$${(h.amount/100).toFixed(2)} off`}`),d(""),e==null||e(h)}catch(h){g(h instanceof Error?h.message:"Invalid coupon code")}finally{x(!1)}}},[u,a,c,e]);return s.jsx(M,{appearance:l,children:s.jsxs("div",{className:"ss-card",children:[s.jsx("h2",{className:"ss-title",children:"Apply coupon"}),p&&s.jsx("div",{className:"ss-global-error",children:p}),m&&s.jsx("div",{className:"ss-success-msg",children:m}),s.jsxs("form",{onSubmit:b,children:[s.jsxs("div",{className:"ss-field",children:[s.jsx("label",{className:"ss-label",htmlFor:"ss-coupon-code",children:"Coupon code"}),s.jsx("input",{id:"ss-coupon-code",className:"ss-input",type:"text",placeholder:"Enter coupon code",value:c,onChange:N=>d(N.target.value),required:!0})]}),s.jsxs("button",{type:"submit",className:"ss-btn ss-btn-primary",disabled:i||!c.trim(),children:[i&&s.jsx("span",{className:"ss-spinner"}),"Apply"]})]})]})})}function qs(){const{client:a}=E();return{report:a.report}}function ss(){const{client:a}=E(),[r,e]=t.useState(null),[o,n]=t.useState(!1),[u,l]=t.useState(null),c=t.useCallback(async d=>{n(!0),l(null);try{const i=await a.report.executeQuery(d);return e(i),i}catch(i){return l(i instanceof Error?i.message:"Query failed"),null}finally{n(!1)}},[a]);return{result:r,execute:c,isLoading:o,error:u}}function ps(a){const{client:r}=E(),[e,o]=t.useState(null),[n,u]=t.useState(!0),[l,c]=t.useState(null),d=t.useCallback(async()=>{u(!0),c(null);try{const i=await r.report.listQueries(a);o(i)}catch(i){c(i instanceof Error?i.message:"Failed to load queries")}finally{u(!1)}},[r,a]);return t.useEffect(()=>{d()},[d]),{queries:(e==null?void 0:e.data)??[],meta:e==null?void 0:e.meta,isLoading:n,error:l,refresh:d}}function Hs(a){const{client:r}=E(),[e,o]=t.useState(null),[n,u]=t.useState(!0),[l,c]=t.useState(null),d=t.useCallback(async()=>{u(!0),c(null);try{const i=await r.report.getDashboard(a);o(i)}catch(i){c(i instanceof Error?i.message:"Failed to load dashboard")}finally{u(!1)}},[r,a]);return t.useEffect(()=>{d()},[d]),{dashboard:e,isLoading:n,error:l,refresh:d}}function Ws(a,r,e="https://api.saas-support.com/v1"){const o=t.useMemo(()=>{const p=new U.Transport(e,{type:"embedToken",token:a});return new U.ReportClient(p)},[a,e]),[n,u]=t.useState(null),[l,c]=t.useState(!0),[d,i]=t.useState(null),x=t.useCallback(async()=>{c(!0),i(null);try{const p=await o.getDashboard(r);u(p)}catch(p){i(p instanceof Error?p.message:"Failed to load dashboard")}finally{c(!1)}},[o,r]);return t.useEffect(()=>{x()},[x]),{dashboard:n,reportClient:o,isLoading:l,error:d,refresh:x}}function _s({onResult:a,mode:r="both",placeholder:e,appearance:o}){const{appearance:n}=E(),{execute:u,isLoading:l,error:c}=ss(),d=o??n,[i,x]=t.useState(""),[p,g]=t.useState(r==="sql"?"sql":"nl"),m=t.useCallback(async v=>{if(v.preventDefault(),!i.trim())return;const N=await u(p==="sql"?{sql:i}:{naturalLanguage:i});N&&(a==null||a(N))},[i,p,u,a]);return s.jsx(M,{appearance:d,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[r==="both"&&s.jsxs("div",{className:"ss-tab-group ss-tab-group-sm",children:[s.jsx("button",{type:"button",className:`ss-tab ${p==="nl"?"ss-tab-active":""}`,onClick:()=>g("nl"),children:"Natural Language"}),s.jsx("button",{type:"button",className:`ss-tab ${p==="sql"?"ss-tab-active":""}`,onClick:()=>g("sql"),children:"SQL"})]}),c&&s.jsx("div",{className:"ss-global-error",children:c}),s.jsxs("form",{onSubmit:m,children:[s.jsx("div",{className:"ss-field",children:s.jsx("textarea",{className:"ss-input ss-query-textarea",placeholder:e??(p==="sql"?"SELECT ...":"Ask a question about your data..."),value:i,onChange:v=>x(v.target.value),rows:3})}),s.jsxs("button",{type:"submit",className:"ss-btn ss-btn-primary",disabled:l||!i.trim(),children:[l&&s.jsx("span",{className:"ss-spinner"}),"Run query"]})]})]})})}function hs({columns:a,rows:r,sortable:e=!0,maxRows:o,appearance:n}){const{appearance:u}=E(),l=n??u,[c,d]=t.useState(null),[i,x]=t.useState("asc"),p=t.useMemo(()=>c?[...r].sort((b,N)=>{const h=b[c],j=N[c];if(h==null&&j==null)return 0;if(h==null)return 1;if(j==null)return-1;if(typeof h=="number"&&typeof j=="number")return i==="asc"?h-j:j-h;const S=String(h),k=String(j);return i==="asc"?S.localeCompare(k):k.localeCompare(S)}):r,[r,c,i]),g=o?p.slice(0,o):p,m=b=>{e&&(c===b?x(N=>N==="asc"?"desc":"asc"):(d(b),x("asc")))};function v(b){return b==null?"":typeof b=="object"?JSON.stringify(b):String(b)}return s.jsx(M,{appearance:l,children:s.jsxs("div",{className:"ss-table-container",children:[s.jsxs("table",{className:"ss-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:a.map(b=>s.jsxs("th",{className:`ss-th ${e?"ss-th-sortable":""} ${c===b?i==="asc"?"ss-sorted-asc":"ss-sorted-desc":""}`,onClick:()=>m(b),children:[b,c===b&&s.jsx("span",{className:"ss-sort-indicator",children:i==="asc"?" ▲":" ▼"})]},b))})}),s.jsx("tbody",{children:g.map((b,N)=>s.jsx("tr",{className:"ss-tr",children:a.map(h=>s.jsx("td",{className:"ss-td",children:v(b[h])},h))},N))})]}),o&&r.length>o&&s.jsxs("div",{className:"ss-table-footer",children:["Showing ",o," of ",r.length," rows"]})]})})}function Gs(a,r="#6366f1"){const e=parseInt(r.replace("#","").slice(0,2),16),o=[];for(let n=0;n<a;n++){const u=(e+n*Math.floor(360/Math.max(a,1)))%360;o.push(`hsl(${u}, 65%, 55%)`)}return o}function Ys({labels:a,values:r,w:e,h:o,colors:n}){const u=Math.max(...r,1),l=40,c=e-l*2,d=o-l*2,i=Math.max(1,c/a.length-4);return s.jsxs("g",{children:[s.jsx("line",{x1:l,y1:o-l,x2:e-l,y2:o-l,stroke:"#ccc",strokeWidth:1}),r.map((x,p)=>{const g=x/u*d,m=l+c/a.length*p+2,v=o-l-g;return s.jsxs("g",{children:[s.jsx("rect",{x:m,y:v,width:i,height:g,fill:n[p%n.length],rx:2}),s.jsx("text",{x:m+i/2,y:o-l+14,textAnchor:"middle",fontSize:10,fill:"#666",children:a[p].length>8?a[p].slice(0,8)+"...":a[p]})]},p)})]})}function Qs({labels:a,values:r,w:e,h:o,colors:n}){const u=Math.max(...r,1),l=40,c=e-l*2,d=o-l*2,i=a.length>1?c/(a.length-1):0,x=r.map((p,g)=>{const m=l+i*g,v=o-l-p/u*d;return`${m},${v}`});return s.jsxs("g",{children:[[.25,.5,.75,1].map(p=>{const g=o-l-p*d;return s.jsx("line",{x1:l,y1:g,x2:e-l,y2:g,stroke:"#eee",strokeWidth:1},p)}),s.jsx("polyline",{points:x.join(" "),fill:"none",stroke:n[0],strokeWidth:2}),r.map((p,g)=>{const m=l+i*g,v=o-l-p/u*d;return s.jsx("circle",{cx:m,cy:v,r:4,fill:n[0]},g)})]})}function Js({labels:a,values:r,w:e,h:o,colors:n}){const u=r.reduce((g,m)=>g+m,0)||1,l=e/2,c=o/2-20,d=Math.min(e,o)/2-40,i=2*Math.PI*d;let x=0;const p=r.map((g,m)=>{const v=g/u,b=v*i,N={dash:b,offset:x,color:n[m%n.length],label:a[m],pct:v};return x+=b,N});return s.jsxs("g",{children:[p.map((g,m)=>s.jsx("circle",{cx:l,cy:c,r:d,fill:"none",stroke:g.color,strokeWidth:d*.6,strokeDasharray:`${g.dash} ${i-g.dash}`,strokeDashoffset:-g.offset,transform:`rotate(-90 ${l} ${c})`},m)),s.jsx("g",{transform:`translate(${l-a.length*30}, ${o-20})`,children:p.slice(0,6).map((g,m)=>s.jsxs("g",{transform:`translate(${m*60}, 0)`,children:[s.jsx("rect",{width:10,height:10,fill:g.color,rx:2}),s.jsx("text",{x:14,y:9,fontSize:9,fill:"#666",children:g.label.length>6?g.label.slice(0,6)+"..":g.label})]},m))})]})}function xs({type:a,data:r,title:e,width:o=400,height:n=300,appearance:u}){const{appearance:l}=E(),c=u??l,d=t.useMemo(()=>Gs(r.labels.length),[r.labels.length]);return s.jsx(M,{appearance:c,children:s.jsxs("div",{className:"ss-chart-container",children:[e&&s.jsx("h3",{className:"ss-chart-title",children:e}),s.jsxs("svg",{viewBox:`0 0 ${o} ${n}`,width:"100%",style:{maxWidth:o},children:[a==="bar"&&s.jsx(Ys,{labels:r.labels,values:r.values,w:o,h:n,colors:d}),a==="line"&&s.jsx(Qs,{labels:r.labels,values:r.values,w:o,h:n,colors:d}),a==="pie"&&s.jsx(Js,{labels:r.labels,values:r.values,w:o,h:n,colors:d})]})]})})}function Zs({dashboardId:a,embedToken:r,baseUrl:e,refreshInterval:o,appearance:n}){const u=E(),l=n??(u==null?void 0:u.appearance),c=t.useMemo(()=>{if(r){const h=e??"https://api.saas-support.com/v1",j=new U.Transport(h,{type:"embedToken",token:r});return new U.ReportClient(j)}return u.client.report},[r,e,u]),[d,i]=t.useState([]),[x,p]=t.useState({}),[g,m]=t.useState(!0),[v,b]=t.useState(null),N=t.useCallback(async()=>{m(!0),b(null);try{const h=await c.getDashboard(a),j=JSON.parse(h.layoutJson||"[]");i(j);const S={};for(const k of j)try{const P=await c.listQueries({search:k.queryId,perPage:1});if(P.data.length>0&&P.data[0].generatedSql){const z=await c.executeQuery({sql:P.data[0].generatedSql});S[k.queryId]=z}}catch{}p(S)}catch(h){b(h instanceof Error?h.message:"Failed to load dashboard")}finally{m(!1)}},[c,a]);return t.useEffect(()=>{N()},[N]),t.useEffect(()=>{if(!o||o<=0)return;const h=setInterval(N,o*1e3);return()=>clearInterval(h)},[o,N]),s.jsx(M,{appearance:l,children:s.jsxs("div",{className:"ss-dashboard-grid",children:[g&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading dashboard..."]}),v&&s.jsx("div",{className:"ss-global-error",children:v}),!g&&d.map((h,j)=>{const S=x[h.queryId];if(!S)return null;const k=S.columns.length>=2?{labels:S.rows.map(P=>String(P[S.columns[0]]??"")),values:S.rows.map(P=>Number(P[S.columns[1]]??0))}:{labels:[],values:[]};return s.jsxs("div",{className:"ss-widget",children:[h.title&&s.jsx("h4",{className:"ss-widget-header",children:h.title}),h.chartType==="table"?s.jsx(hs,{columns:S.columns,rows:S.rows,maxRows:50}):s.jsx(xs,{type:h.chartType||"bar",data:k,width:h.w,height:h.h})]},j)})]})})}function Ks(a){return new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Xs({onSelectQuery:a,onRunQuery:r,appearance:e}){const{appearance:o}=E(),{queries:n,isLoading:u,error:l}=ps(),{execute:c,isLoading:d}=ss(),i=e??o,x=t.useCallback(async p=>{if(!p.generatedSql)return;const g=await c({sql:p.generatedSql});g&&(r==null||r(g))},[c,r]);return s.jsx(M,{appearance:i,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[s.jsx("h2",{className:"ss-title",children:"Saved Queries"}),u&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),l&&s.jsx("div",{className:"ss-global-error",children:l}),!u&&n.length===0&&s.jsx("p",{className:"ss-empty",children:"No saved queries."}),!u&&n.map(p=>s.jsxs("div",{className:"ss-saved-query-card",onClick:()=>a==null?void 0:a(p),children:[s.jsxs("div",{className:"ss-saved-query-header",children:[s.jsx("span",{className:"ss-saved-query-name",children:p.name}),p.chartType&&s.jsx("span",{className:"ss-badge",children:p.chartType})]}),p.naturalLanguage&&s.jsx("p",{className:"ss-saved-query-desc",children:p.naturalLanguage}),s.jsxs("div",{className:"ss-saved-query-footer",children:[s.jsx("span",{className:"ss-saved-query-date",children:Ks(p.createdAt)}),s.jsx("button",{type:"button",className:"ss-btn ss-btn-sm ss-btn-primary",disabled:d||!p.generatedSql,onClick:g=>{g.stopPropagation(),x(p)},children:d?s.jsx("span",{className:"ss-spinner"}):"Run"})]})]},p.id))]})})}function sa({embedToken:a,dashboardId:r,baseUrl:e="https://api.saas-support.com/v1",refreshInterval:o,appearance:n}){const u=t.useMemo(()=>{const b=new U.Transport(e,{type:"embedToken",token:a});return new U.ReportClient(b)},[a,e]),[l,c]=t.useState([]),[d,i]=t.useState(!0),[x,p]=t.useState(null),g=t.useMemo(()=>Y(n),[n]),m=t.useMemo(()=>Q(g),[g]),v=t.useCallback(async()=>{i(!0),p(null);try{const b=await u.getDashboard(r),N=JSON.parse(b.layoutJson||"[]"),h=await Promise.all(N.map(async j=>{try{const S=await u.listQueries({search:j.queryId,perPage:1});if(S.data.length>0&&S.data[0].generatedSql){const k=await u.executeQuery({sql:S.data[0].generatedSql});return{...j,result:k}}}catch{}return j}));c(h)}catch(b){p(b instanceof Error?b.message:"Failed to load dashboard")}finally{i(!1)}},[u,r]);return t.useEffect(()=>{v()},[v]),t.useEffect(()=>{if(!o||o<=0)return;const b=setInterval(v,o*1e3);return()=>clearInterval(b)},[o,v]),s.jsx("div",{ref:b=>{if(!b||b.shadowRoot)return;const N=b.attachShadow({mode:"open"}),h=document.createElement("style");h.textContent=m,N.appendChild(h);const j=document.createElement("div");N.appendChild(j)},style:{display:"contents"},children:s.jsxs("div",{className:"ss-dashboard-grid",children:[d&&s.jsx("div",{className:"ss-loading",children:"Loading dashboard..."}),x&&s.jsx("div",{className:"ss-global-error",children:x}),!d&&l.map((b,N)=>{if(!b.result)return null;const{columns:h,rows:j}=b.result;return s.jsxs("div",{className:"ss-widget",children:[b.title&&s.jsx("h4",{className:"ss-widget-header",children:b.title}),s.jsxs("table",{className:"ss-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:h.map(S=>s.jsx("th",{className:"ss-th",children:S},S))})}),s.jsx("tbody",{children:j.slice(0,50).map((S,k)=>s.jsx("tr",{className:"ss-tr",children:h.map(P=>s.jsx("td",{className:"ss-td",children:String(S[P]??"")},P))},k))})]})]},N)})]})})}exports.SaaSError=U.SaaSError;exports.SaaSSupport=U.SaaSSupport;exports.isMfaRequired=U.isMfaRequired;exports.Chart=xs;exports.CouponInput=Rs;exports.DashboardView=Zs;exports.DataTable=hs;exports.InvoiceHistory=ds;exports.OrgSwitcher=Fs;exports.PaymentPortal=Vs;exports.PricingTable=Bs;exports.QueryInput=_s;exports.ReportEmbed=sa;exports.SaaSContext=J;exports.SaaSProvider=js;exports.SavedQueryList=Xs;exports.SignIn=Cs;exports.SignUp=Ps;exports.SubscriptionStatus=cs;exports.UsageDisplay=us;exports.UserButton=Es;exports.UserProfile=Is;exports.useAuth=H;exports.useBilling=Ts;exports.useDashboard=Hs;exports.useDeleteAccount=es;exports.useEmbedDashboard=Ws;exports.useInvoices=is;exports.useOrg=K;exports.useProfile=X;exports.useQuery=ss;exports.useReport=qs;exports.useSaaSContext=E;exports.useSavedQueries=ps;exports.useSignIn=Z;exports.useSignUp=as;exports.useSubscription=os;exports.useUsage=ls;exports.useUser=$s;
|
|
2043
|
+
`}function M({children:a,appearance:r}){const e=t.useRef(null),[o,n]=t.useState(null);t.useEffect(()=>{var x;if(!e.current||e.current.shadowRoot){n(((x=e.current)==null?void 0:x.shadowRoot)??null);return}const l=e.current.attachShadow({mode:"open"});if((r==null?void 0:r.fontUrl)!==null){const p=(r==null?void 0:r.fontUrl)??"https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Inter:wght@400;500;600&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap";if(!document.querySelector(`link[href="${p}"]`)){const f=document.createElement("link");f.rel="stylesheet",f.href=p,document.head.appendChild(f)}const g=document.createElement("link");g.rel="stylesheet",g.href=p,l.appendChild(g)}const c=Y(r),d=document.createElement("style");d.textContent=Q(c),l.appendChild(d);const i=document.createElement("div");l.appendChild(i),n(l)},[]),t.useEffect(()=>{if(!o)return;const l=o.querySelector("style");if(l){const c=Y(r);l.textContent=Q(c)}},[r,o]);const u=(o==null?void 0:o.querySelector("div"))??null;return s.jsx("div",{ref:e,style:{display:"contents"},children:u&&vs.createPortal(a,u)})}function H(){const{client:a,user:r,isLoaded:e}=E();return{isLoaded:e,isSignedIn:!!r,user:r,signOut:t.useCallback(()=>a.auth.signOut(),[a]),getToken:t.useCallback(()=>a.auth.getToken(),[a])}}function $s(){const{user:a,isLoaded:r}=E();return{user:a,isLoaded:r}}function Z(){const{client:a}=E(),[r,e]=t.useState(!1),[o,n]=t.useState(null),u=t.useCallback(async(d,i)=>{e(!0),n(null);try{return await a.auth.signIn(d,i)}catch(x){return n(x instanceof Error?x.message:"Sign in failed"),null}finally{e(!1)}},[a]),l=t.useCallback(async d=>{e(!0),n(null);try{return await a.auth.signInWithOAuth(d)}catch(i){return n(i instanceof Error?i.message:"OAuth sign in failed"),null}finally{e(!1)}},[a]),c=t.useCallback(async(d,i)=>{e(!0),n(null);try{return await a.auth.submitMfaCode(d,i)}catch(x){return n(x instanceof Error?x.message:"MFA verification failed"),null}finally{e(!1)}},[a]);return{signIn:u,signInWithOAuth:l,submitMfaCode:c,isLoading:r,error:o,setError:n}}function as(){const{client:a}=E(),[r,e]=t.useState(!1),[o,n]=t.useState(null);return{signUp:t.useCallback(async(l,c)=>{e(!0),n(null);try{return await a.auth.signUp(l,c)}catch(d){return n(d instanceof Error?d.message:"Sign up failed"),null}finally{e(!1)}},[a]),isLoading:r,error:o,setError:n}}function K(){const{client:a}=E(),[r,e]=t.useState([]),[o,n]=t.useState(null),[u,l]=t.useState([]),[c,d]=t.useState([]),[i,x]=t.useState(!1),[p,g]=t.useState(null),f=t.useCallback(async()=>{x(!0),g(null);try{const w=await a.auth.listOrgs();e(w);const m=typeof window<"u"?localStorage.getItem("ss_selected_org"):null;if(m&&w.some(y=>y.id===m)&&!o){const y=w.find(C=>C.id===m);n(y);try{const C=await a.auth.listMembers(y.id);l(C)}catch{}}}catch(w){g(w instanceof Error?w.message:"Failed to load organizations")}finally{x(!1)}},[a,o]);t.useEffect(()=>{f()},[f]);const v=t.useCallback(async w=>{try{const m=await a.auth.getOrg(w);n(m),typeof window<"u"&&localStorage.setItem("ss_selected_org",w);const y=await a.auth.listMembers(w);l(y)}catch(m){g(m instanceof Error?m.message:"Failed to load organization")}},[a]),b=t.useCallback(async(w,m)=>{try{const y=await a.auth.createOrg(w,m);return e(C=>[...C,y]),y}catch(y){return g(y instanceof Error?y.message:"Failed to create organization"),null}},[a]),N=t.useCallback(async(w,m)=>{try{const y=await a.auth.updateOrg(w,m);return e(C=>C.map(B=>B.id===w?y:B)),(o==null?void 0:o.id)===w&&n(y),y}catch(y){return g(y instanceof Error?y.message:"Failed to update organization"),null}},[a,o]),h=t.useCallback(async w=>{try{return await a.auth.deleteOrg(w),e(m=>m.filter(y=>y.id!==w)),(o==null?void 0:o.id)===w&&(n(null),l([]),d([]),typeof window<"u"&&localStorage.removeItem("ss_selected_org")),!0}catch(m){return g(m instanceof Error?m.message:"Failed to delete organization"),!1}},[a,o]),j=t.useCallback(async(w,m,y)=>{try{return await a.auth.sendInvite(w,m,y)}catch(C){return g(C instanceof Error?C.message:"Failed to send invite"),null}},[a]),S=t.useCallback(async w=>{try{const m=await a.auth.listInvites(w);d(m)}catch(m){g(m instanceof Error?m.message:"Failed to load invites")}},[a]),k=t.useCallback(async(w,m)=>{try{return await a.auth.revokeInvite(w,m),d(y=>y.filter(C=>C.id!==m)),!0}catch(y){return g(y instanceof Error?y.message:"Failed to revoke invite"),!1}},[a]),P=t.useCallback(async(w,m,y)=>{try{return await a.auth.updateMemberRole(w,m,y),l(C=>C.map(B=>B.userId===m?{...B,role:y}:B)),!0}catch(C){return g(C instanceof Error?C.message:"Failed to update member role"),!1}},[a]),z=t.useCallback(async(w,m)=>{try{return await a.auth.removeMember(w,m),l(y=>y.filter(C=>C.userId!==m)),!0}catch(y){return g(y instanceof Error?y.message:"Failed to remove member"),!1}},[a]),F=t.useCallback(async w=>{try{const m=await a.auth.listMembers(w);l(m)}catch(m){g(m instanceof Error?m.message:"Failed to load members")}},[a]);return{orgs:r,selectedOrg:o,members:u,invites:c,isLoading:i,error:p,setError:g,refresh:f,selectOrg:v,createOrg:b,updateOrg:N,deleteOrg:h,sendInvite:j,refreshInvites:S,revokeInvite:k,updateMemberRole:P,removeMember:z,refreshMembers:F}}function es(){const{client:a}=E(),[r,e]=t.useState(!1),[o,n]=t.useState(null);return{deleteAccount:t.useCallback(async()=>{e(!0),n(null);try{return await a.auth.deleteAccount(),!0}catch(l){return n(l instanceof Error?l.message:"Failed to delete account"),!1}finally{e(!1)}},[a]),isLoading:r,error:o,setError:n}}function X(){const{client:a,user:r}=E(),[e,o]=t.useState(!1),[n,u]=t.useState(null),[l,c]=t.useState(null),d=t.useCallback(async p=>{o(!0),u(null),c(null);try{const g=await a.auth.updateProfile(p);return c("Profile updated"),g}catch(g){return u(g instanceof Error?g.message:"Failed to update profile"),null}finally{o(!1)}},[a]),i=t.useCallback(async(p,g)=>{o(!0),u(null),c(null);try{return await a.auth.changePassword(p,g),c("Password changed successfully"),!0}catch(f){return u(f instanceof Error?f.message:"Failed to change password"),!1}finally{o(!1)}},[a]),x=t.useCallback(async p=>{o(!0),u(null),c(null);try{const g=await a.auth.uploadAvatar(p);return c("Avatar updated"),g}catch(g){return u(g instanceof Error?g.message:"Failed to upload avatar"),null}finally{o(!1)}},[a]);return{user:r,updateProfile:d,uploadAvatar:x,changePassword:i,isLoading:e,error:n,success:l,setError:u,setSuccess:c}}const ts='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 0 1-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z" fill="#4285F4"/><path d="M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z" fill="#34A853"/><path d="M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z" fill="#FBBC05"/><path d="M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z" fill="#EA4335"/></svg>',rs='<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0 0 24 12c0-6.63-5.37-12-12-12z" fill="currentColor"/></svg>',$={close:"close",person:"person",logout:"logout",checkCircle:"check_circle",unfoldMore:"unfold_more",cloudUpload:"cloud_upload",zoomIn:"zoom_in",zoomOut:"zoom_out",lock:"lock",visibility:"visibility",visibilityOff:"visibility_off",add:"add",addCircle:"add_circle",camera:"photo_camera",security:"security",errorOutline:"error_outline",info:"info",arrowForward:"arrow_forward",verified:"verified",token:"token",autoAwesome:"auto_awesome",corporateFare:"corporate_fare",cloudDone:"cloud_done",check:"check",image:"image"};function Cs({appearance:a,signUpUrl:r,onSignUp:e}){const{appearance:o,settings:n}=E(),{signIn:u,signInWithOAuth:l,submitMfaCode:c,isLoading:d,error:i,setError:x}=Z(),p=a??o,[g,f]=t.useState(""),[v,b]=t.useState(""),[N,h]=t.useState(!1),[j,S]=t.useState(!1),[k,P]=t.useState(""),[z,F]=t.useState(["","","","","",""]),w=t.useRef([]),m=t.useCallback(async L=>{if(L.preventDefault(),j){await c(k,z.join(""));return}const T=await u(g,v);T&&U.isMfaRequired(T)&&(P(T.mfaToken),S(!0),x(null))},[g,v,j,k,z,u,c,x]),y=t.useCallback(async L=>{await l(L)},[l]),C=t.useCallback((L,T)=>{var R;if(!/^\d*$/.test(T))return;const O=T.slice(-1);F(_=>{const q=[..._];return q[L]=O,q}),O&&L<5&&((R=w.current[L+1])==null||R.focus())},[]),B=t.useCallback((L,T)=>{var O;T.key==="Backspace"&&!z[L]&&L>0&&((O=w.current[L-1])==null||O.focus())},[z]),D=(n==null?void 0:n.googleEnabled)||(n==null?void 0:n.githubEnabled);return s.jsx(M,{appearance:p,children:s.jsx("div",{className:"ss-auth-card",children:s.jsxs("div",{className:"ss-auth-card-body",children:[s.jsxs("div",{className:"ss-auth-header",children:[s.jsx("div",{className:"ss-auth-brand-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:$.token})}),s.jsx("h1",{className:"ss-auth-title",children:"Sign in to your account"}),s.jsx("p",{className:"ss-auth-subtitle",children:"Welcome back to your workspace"})]}),!j&&D&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ss-auth-oauth-grid",children:[(n==null?void 0:n.googleEnabled)&&s.jsxs("button",{type:"button",className:"ss-auth-btn-social",onClick:()=>y("google"),disabled:d,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:ts}}),"Google"]}),(n==null?void 0:n.githubEnabled)&&s.jsxs("button",{type:"button",className:"ss-auth-btn-social",onClick:()=>y("github"),disabled:d,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:rs}}),"GitHub"]})]}),s.jsx("div",{className:"ss-auth-divider",children:"or continue with"})]}),i&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:i})]}),s.jsxs("form",{onSubmit:m,children:[j?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ss-auth-mfa-divider",children:s.jsx("span",{children:"Verification Required"})}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"6-Digit Code"}),s.jsx("div",{className:"ss-auth-mfa-group",children:z.map((L,T)=>s.jsx("input",{ref:O=>{w.current[T]=O},className:"ss-auth-mfa-digit",type:"text",inputMode:"numeric",maxLength:1,value:L,onChange:O=>C(T,O.target.value),onKeyDown:O=>B(T,O),autoFocus:T===0},T))}),s.jsx("p",{className:"ss-auth-mfa-hint",children:"We sent a 6-digit code to your registered email."})]})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-email",children:"Email Address"}),s.jsx("input",{id:"ss-email",className:"ss-auth-input",type:"email",autoComplete:"email",placeholder:"name@company.com",value:g,onChange:L=>f(L.target.value),required:!0})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsxs("div",{className:"ss-auth-field-row",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-password",style:{marginBottom:0},children:"Password"}),s.jsx("span",{className:"ss-auth-link",style:{fontSize:"12px"},children:"Forgot?"})]}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{id:"ss-password",className:"ss-auth-input",type:N?"text":"password",autoComplete:"current-password",placeholder:"••••••••",value:v,onChange:L=>b(L.target.value),required:!0}),s.jsx("button",{type:"button",className:"ss-auth-visibility-toggle",onClick:()=>h(!N),children:s.jsx("span",{className:"material-symbols-outlined",children:N?$.visibilityOff:$.visibility})})]})]})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:d,children:[d&&s.jsx("span",{className:"ss-auth-spinner"}),j?"Verify":"Sign in",!d&&s.jsx("span",{className:"material-symbols-outlined",children:$.arrowForward})]})]}),j?s.jsx("div",{className:"ss-auth-footer",children:s.jsx("span",{className:"ss-auth-link",onClick:()=>{S(!1),F(["","","","","",""]),x(null)},children:"Back to sign in"})}):s.jsxs("div",{className:"ss-auth-footer",children:["Don't have an account?"," ",e?s.jsx("span",{className:"ss-auth-link",onClick:e,children:"Sign up"}):r?s.jsx("a",{className:"ss-auth-link",href:r,children:"Sign up"}):s.jsx("span",{className:"ss-auth-link",children:"Sign up"})]})]})})})}function Ps({appearance:a,signInUrl:r,onSignIn:e}){const{appearance:o,settings:n}=E(),{signUp:u,isLoading:l,error:c,setError:d}=as(),{signInWithOAuth:i}=Z(),x=a??o,[p,g]=t.useState(""),[f,v]=t.useState(""),[b,N]=t.useState(""),[h,j]=t.useState(!1),[S,k]=t.useState(null),P=t.useCallback(async m=>{if(m.preventDefault(),k(null),f!==b){k("Passwords do not match");return}const y=(n==null?void 0:n.passwordMinLength)??8;if(f.length<y){k(`Password must be at least ${y} characters`);return}await u(p,f)},[p,f,b,n,u]),z=t.useCallback(async m=>{await i(m)},[i]),F=(n==null?void 0:n.googleEnabled)||(n==null?void 0:n.githubEnabled),w=S||c;return s.jsx(M,{appearance:x,children:s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",maxWidth:"520px"},children:[s.jsxs("div",{className:"ss-auth-header",children:[s.jsx("div",{className:"ss-auth-brand-icon-gradient",children:s.jsx("span",{className:"material-symbols-outlined",children:$.autoAwesome})}),s.jsx("h1",{className:"ss-auth-title ss-auth-title-lg",children:"Create your account"}),s.jsx("p",{className:"ss-auth-subtitle",children:"Join the ecosystem"})]}),s.jsx("div",{className:"ss-auth-card",children:s.jsxs("div",{className:"ss-auth-card-body",children:[F&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ss-auth-oauth-grid",children:[(n==null?void 0:n.googleEnabled)&&s.jsxs("button",{type:"button",className:"ss-auth-btn-social",onClick:()=>z("google"),disabled:l,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:ts}}),"Google"]}),(n==null?void 0:n.githubEnabled)&&s.jsxs("button",{type:"button",className:"ss-auth-btn-social",onClick:()=>z("github"),disabled:l,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:rs}}),"GitHub"]})]}),s.jsx("div",{className:"ss-auth-divider",children:"or sign up with email"})]}),w&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:w})]}),s.jsxs("form",{onSubmit:P,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-signup-email",children:"Email"}),s.jsx("input",{id:"ss-signup-email",className:"ss-auth-input",type:"email",autoComplete:"email",placeholder:"name@company.com",value:p,onChange:m=>g(m.target.value),required:!0})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-signup-password",children:"Password"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{id:"ss-signup-password",className:"ss-auth-input",type:h?"text":"password",autoComplete:"new-password",placeholder:"••••••••",value:f,onChange:m=>{v(m.target.value),k(null)},required:!0}),s.jsx("button",{type:"button",className:"ss-auth-visibility-toggle",onClick:()=>j(!h),children:s.jsx("span",{className:"material-symbols-outlined",children:h?$.visibilityOff:$.visibility})})]})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",htmlFor:"ss-signup-confirm",children:"Confirm Password"}),s.jsx("input",{id:"ss-signup-confirm",className:"ss-auth-input",type:"password",autoComplete:"new-password",placeholder:"••••••••",value:b,onChange:m=>{N(m.target.value),k(null)},required:!0})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:l,children:[l&&s.jsx("span",{className:"ss-auth-spinner"}),"Sign up",!l&&s.jsx("span",{className:"material-symbols-outlined",children:$.arrowForward})]})]}),s.jsxs("div",{className:"ss-auth-footer",children:["Already have an account?"," ",e?s.jsx("span",{className:"ss-auth-link",onClick:e,children:"Sign in"}):r?s.jsx("a",{className:"ss-auth-link",href:r,children:"Sign in"}):s.jsx("span",{className:"ss-auth-link",children:"Sign in"})]})]})})]})})}const I=320,V=128;function zs({file:a,onCrop:r,onCancel:e}){const o=t.useRef(null),n=t.useRef(null),[u,l]=t.useState(1),[c,d]=t.useState({x:0,y:0}),[i,x]=t.useState(!1),p=t.useRef({x:0,y:0,ox:0,oy:0}),[g,f]=t.useState(!1);t.useEffect(()=>{const h=new Image,j=URL.createObjectURL(a);return h.onload=()=>{n.current=h,f(!0),d({x:0,y:0}),l(1)},h.src=j,()=>URL.revokeObjectURL(j)},[a]),t.useEffect(()=>{if(!g||!n.current||!o.current)return;const h=o.current.getContext("2d");if(!h)return;const j=n.current;h.clearRect(0,0,I,I),h.fillStyle="#111",h.fillRect(0,0,I,I);const S=Math.max(I/j.width,I/j.height)*u,k=j.width*S,P=j.height*S,z=(I-k)/2+c.x,F=(I-P)/2+c.y;h.save(),h.beginPath(),h.arc(I/2,I/2,V,0,Math.PI*2),h.clip(),h.drawImage(j,z,F,k,P),h.restore(),h.save(),h.fillStyle="rgba(0, 0, 0, 0.6)",h.fillRect(0,0,I,I),h.globalCompositeOperation="destination-out",h.beginPath(),h.arc(I/2,I/2,V,0,Math.PI*2),h.fill(),h.restore(),h.save(),h.beginPath(),h.arc(I/2,I/2,V,0,Math.PI*2),h.clip(),h.drawImage(j,z,F,k,P),h.restore(),h.strokeStyle="rgba(255, 255, 255, 0.4)",h.lineWidth=2,h.beginPath(),h.arc(I/2,I/2,V,0,Math.PI*2),h.stroke()},[u,c,g]);const v=t.useCallback(h=>{x(!0),p.current={x:h.clientX,y:h.clientY,ox:c.x,oy:c.y},h.target.setPointerCapture(h.pointerId)},[c]),b=t.useCallback(h=>{i&&d({x:p.current.ox+(h.clientX-p.current.x),y:p.current.oy+(h.clientY-p.current.y)})},[i]),N=t.useCallback(()=>x(!1),[]);return t.useCallback(()=>{if(!n.current)return;const h=document.createElement("canvas"),j=V*2;h.width=j,h.height=j;const S=h.getContext("2d");if(!S)return;const k=n.current,P=Math.max(I/k.width,I/k.height)*u,z=k.width*P,F=k.height*P,w=(I-z)/2+c.x-(I/2-V),m=(I-F)/2+c.y-(I/2-V);S.beginPath(),S.arc(V,V,V,0,Math.PI*2),S.clip(),S.drawImage(k,w,m,z,F),h.toBlob(y=>{y&&r(y)},"image/png")},[u,c,r]),s.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"24px"},children:[s.jsxs("div",{className:"ss-auth-crop-area",children:[s.jsx("canvas",{ref:o,width:I,height:I,style:{cursor:i?"grabbing":"grab",width:"100%",height:"100%"},onPointerDown:v,onPointerMove:b,onPointerUp:N}),s.jsx("div",{className:"ss-auth-crop-size-badge",children:"256 x 256 px"})]}),s.jsxs("div",{className:"ss-auth-zoom-control",style:{width:"100%",maxWidth:"280px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.zoomOut}),s.jsx("input",{type:"range",min:"1",max:"3",step:"0.01",value:u,onChange:h=>l(parseFloat(h.target.value)),className:"ss-auth-zoom-slider"}),s.jsx("span",{className:"material-symbols-outlined",children:$.zoomIn})]})]})}function ns({onUpload:a,onClose:r,isLoading:e}){const[o,n]=t.useState(null),[u,l]=t.useState(!1),[c,d]=t.useState(null),i=t.useRef(null),x=t.useCallback(f=>{if(!f.type.startsWith("image/")){d("Please select an image file");return}if(f.size>5*1024*1024){d("Image must be smaller than 5 MB");return}d(null),n(f)},[]),p=t.useCallback(f=>{f.preventDefault(),l(!1);const v=f.dataTransfer.files[0];v&&x(v)},[x]),g=t.useCallback(async f=>{await a(f)},[a]);return s.jsx("div",{className:"ss-auth-modal-overlay",onClick:f=>{f.target===f.currentTarget&&r()},children:s.jsxs("div",{className:"ss-auth-modal ss-auth-card-wide",children:[s.jsxs("div",{className:"ss-auth-modal-header",children:[s.jsx("h2",{children:"Upload avatar"}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:r,children:s.jsx("span",{className:"material-symbols-outlined",children:$.close})})]}),s.jsxs("div",{className:"ss-auth-modal-body",children:[c&&s.jsxs("div",{className:"ss-auth-error",style:{marginBottom:"24px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:c})]}),s.jsxs("div",{className:"ss-auth-upload-grid",children:[s.jsx("div",{children:o?s.jsx(zs,{file:o,onCrop:g,onCancel:()=>n(null)}):s.jsxs("div",{className:"ss-auth-crop-area",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",width:"100%",aspectRatio:"1"},children:[s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"48px",opacity:.3},children:$.image}),s.jsx("span",{style:{fontSize:"12px",opacity:.4},children:"No image selected"})]})}),s.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"16px"},children:[s.jsxs("div",{className:`ss-auth-dropzone${u?" ss-auth-dropzone-active":""}`,onDragOver:f=>{f.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:p,onClick:()=>{var f;return(f=i.current)==null?void 0:f.click()},style:{minHeight:"180px"},children:[s.jsx("div",{className:"ss-auth-dropzone-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:$.cloudUpload})}),s.jsx("span",{className:"ss-auth-dropzone-title",children:"Drag and drop"}),s.jsxs("span",{className:"ss-auth-dropzone-desc",children:["JPG, PNG or WEBP",s.jsx("br",{}),"Max file size 5 MB"]}),s.jsx("button",{type:"button",className:"ss-auth-dropzone-btn",children:"Choose File"}),s.jsx("input",{ref:i,type:"file",accept:"image/*",style:{display:"none"},onChange:f=>{var v;(v=f.target.files)!=null&&v[0]&&x(f.target.files[0])}})]}),s.jsxs("div",{className:"ss-auth-info-box",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.info}),s.jsx("span",{children:"Your profile photo will be visible to all members of your organization."})]})]})]})]}),s.jsxs("div",{className:"ss-auth-modal-footer",children:[s.jsx("button",{type:"button",className:"ss-auth-btn-ghost",onClick:r,children:"Cancel"}),s.jsxs("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",onClick:()=>{},disabled:!o||e,style:{width:"auto"},children:[e&&s.jsx("span",{className:"ss-auth-spinner"}),"Save Profile",!e&&s.jsx("span",{className:"material-symbols-outlined",children:$.check})]})]})]})})}function Es({appearance:a,afterSignOutUrl:r,afterDeleteAccountUrl:e,showOrgSwitcher:o=!0,onOrgChange:n,onOrgSettingsClick:u}){const{appearance:l}=E(),{user:c,signOut:d}=H(),i=a??l,[x,p]=t.useState(!1),[g,f]=t.useState(!1),[v,b]=t.useState(""),[N,h]=t.useState(null),[j,S]=t.useState(!1),k=t.useRef(null),{orgs:P,selectedOrg:z,selectOrg:F,createOrg:w}=K(),m=t.useCallback(C=>{k.current&&!C.composedPath().includes(k.current)&&p(!1)},[]);t.useEffect(()=>{if(x){const C=setTimeout(()=>{document.addEventListener("click",m)},0);return()=>{clearTimeout(C),document.removeEventListener("click",m)}}},[x,m]);const y=t.useCallback(async C=>{C.preventDefault(),h(null),S(!0);const B=v.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");try{const D=await w(v,B);D&&(await F(D.id),n==null||n(D),b(""),p(!1))}catch(D){h(D instanceof Error?D.message:"Failed to create organization")}finally{S(!1)}},[v,w,F,n]);return c?s.jsx(M,{appearance:i,children:s.jsxs("div",{style:{position:"relative",display:"inline-block"},ref:k,children:[s.jsx("button",{type:"button",className:"ss-auth-avatar-trigger",onClick:()=>p(!x),"aria-label":"User menu",children:c.avatarUrl?s.jsx("img",{src:c.avatarUrl,alt:""}):s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"16px",fontWeight:700},children:(c.name||c.email).charAt(0).toUpperCase()})}),x&&s.jsxs("div",{className:"ss-auth-dropdown ss-auth-glass-panel",style:{minWidth:"320px"},children:[s.jsxs("div",{className:"ss-auth-dropdown-header",children:[s.jsx("div",{className:"ss-auth-dropdown-avatar",children:c.avatarUrl?s.jsx("img",{src:c.avatarUrl,alt:""}):s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"20px",fontWeight:800},children:(c.name||c.email).charAt(0).toUpperCase()})}),s.jsxs("div",{children:[c.name&&s.jsx("div",{className:"ss-auth-dropdown-name",children:c.name}),s.jsx("div",{className:"ss-auth-dropdown-email",children:c.email})]})]}),s.jsx("div",{style:{padding:"4px 8px"},children:s.jsxs("button",{type:"button",className:"ss-auth-dropdown-action",onClick:()=>{p(!1),f(!0)},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.person}),"Profile"]})}),o&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"ss-auth-section-label",children:"Organizations"}),s.jsx("div",{style:{padding:"0 8px 4px"},children:P.map(C=>{const B=(z==null?void 0:z.id)===C.id,D=C.name.split(" ").map(L=>L[0]).join("").slice(0,2).toUpperCase();return s.jsxs("button",{type:"button",className:`ss-auth-org-item${B?" ss-auth-org-item-active":""}`,onClick:async()=>{p(!1),await F(C.id),n==null||n(C)},children:[s.jsxs("div",{className:"ss-auth-org-item-inner",children:[s.jsx("div",{className:`ss-auth-org-avatar${B?"":" ss-auth-org-avatar-inactive"}`,children:D}),s.jsx("span",{style:{fontFamily:"'Manrope', sans-serif",letterSpacing:"-0.01em"},children:C.name})]}),B&&s.jsx("span",{className:"material-symbols-outlined ss-auth-org-check",style:{fontSize:"18px"},children:$.checkCircle})]},C.id)})}),s.jsxs("div",{className:"ss-auth-inline-create",children:[N&&s.jsx("div",{className:"ss-auth-error",style:{marginBottom:"8px",fontSize:"12px"},children:s.jsx("span",{children:N})}),s.jsx("form",{onSubmit:y,children:s.jsxs("div",{className:"ss-auth-inline-create-input",children:[s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"New organization name",value:v,onChange:C=>b(C.target.value),required:!0,style:{fontSize:"13px",padding:"10px 40px 10px 12px"}}),s.jsx("button",{type:"submit",className:"ss-auth-inline-create-btn",disabled:j||!v.trim(),children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"20px"},children:$.add})})]})})]}),z&&u&&s.jsx("div",{style:{padding:"0 8px 4px"},children:s.jsxs("button",{type:"button",className:"ss-auth-dropdown-action",onClick:()=>{p(!1),u(z)},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.corporateFare}),"Org settings"]})})]}),s.jsx("div",{className:"ss-auth-signout-section",style:{padding:"8px"},children:s.jsxs("button",{type:"button",className:"ss-auth-dropdown-action",onClick:async()=>{p(!1),await d(),r&&(window.location.href=r)},style:{color:"inherit"},children:[s.jsx("span",{className:"material-symbols-outlined",style:{color:"inherit"},children:$.logout}),"Sign out"]})})]}),g&&s.jsx(Os,{onClose:()=>f(!1),afterDeleteAccountUrl:e})]})}):null}function Os({onClose:a,afterDeleteAccountUrl:r}){const{user:e,updateProfile:o,uploadAvatar:n,changePassword:u,isLoading:l,error:c,success:d,setError:i,setSuccess:x}=X(),{signOut:p}=H(),{deleteAccount:g,isLoading:f,error:v,setError:b}=es(),[N,h]=t.useState((e==null?void 0:e.name)??""),[j,S]=t.useState((e==null?void 0:e.avatarUrl)??""),[k,P]=t.useState(!1),[z,F]=t.useState(""),[w,m]=t.useState(""),[y,C]=t.useState(""),[B,D]=t.useState(null),[L,T]=t.useState(!1),[O,R]=t.useState(""),_=t.useCallback(async A=>{A.preventDefault(),i(null),x(null),await o({name:N,avatarUrl:j||void 0})},[N,j,o,i,x]),q=t.useCallback(async A=>{const G=await n(A);G&&(S(G.avatarUrl),P(!1))},[n]),gs=t.useCallback(async A=>{if(A.preventDefault(),D(null),i(null),x(null),w!==y){D("Passwords do not match");return}if(w.length<8){D("Password must be at least 8 characters");return}await u(z,w)&&(F(""),m(""),C(""))},[z,w,y,u,i,x]),fs=t.useCallback(async()=>{await g()&&(await p(),r&&(window.location.href=r))},[g,p,r]),ms=(e==null?void 0:e.provider)==="email",bs=O===(e==null?void 0:e.email),ys=((e==null?void 0:e.name)||(e==null?void 0:e.email)||"?").charAt(0).toUpperCase();return s.jsx("div",{className:"ss-auth-modal-overlay",onClick:A=>{A.target===A.currentTarget&&a()},children:s.jsxs("div",{className:"ss-auth-modal",style:{maxWidth:"640px"},children:[s.jsxs("div",{className:"ss-auth-modal-header",children:[s.jsx("h2",{children:"Profile"}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:a,children:s.jsx("span",{className:"material-symbols-outlined",children:$.close})})]}),s.jsxs("div",{className:"ss-auth-profile-header",children:[s.jsxs("div",{className:"ss-auth-avatar-lg",onClick:()=>P(!0),children:[j?s.jsx("img",{src:j,alt:""}):s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"48px",fontWeight:800,opacity:.4},children:ys}),s.jsxs("div",{className:"ss-auth-avatar-overlay",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.camera}),s.jsx("span",{children:"Edit"})]})]}),s.jsxs("div",{className:"ss-auth-profile-info",children:[s.jsxs("h2",{className:"ss-auth-profile-name",children:[(e==null?void 0:e.name)||"Unnamed User",(e==null?void 0:e.emailVerified)&&s.jsxs("span",{className:"ss-auth-badge ss-auth-badge-success",children:[s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"12px",fontVariationSettings:"'FILL' 1"},children:$.verified}),"Verified"]})]}),s.jsx("p",{className:"ss-auth-profile-desc",children:e==null?void 0:e.email})]})]}),s.jsxs("div",{className:"ss-auth-modal-body",children:[c&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:c})]}),d&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.check}),s.jsx("span",{children:d})]}),s.jsxs("form",{onSubmit:_,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Full Name"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"Your name",value:N,onChange:A=>h(A.target.value)})]}),s.jsxs("div",{className:"ss-auth-profile-grid",style:{marginBottom:"16px"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Email Address"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"email",value:(e==null?void 0:e.email)??"",readOnly:!0}),s.jsx("span",{className:"ss-auth-visibility-toggle",style:{cursor:"default"},children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"18px"},children:$.lock})})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Auth Provider"}),s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"text",value:(e==null?void 0:e.provider)??"",readOnly:!0})]})]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary ss-auth-btn-sm",disabled:l,style:{width:"auto"},children:[l&&s.jsx("span",{className:"ss-auth-spinner"}),"Save changes"]})})]}),ms&&s.jsxs("div",{className:"ss-auth-section",children:[s.jsxs("div",{className:"ss-auth-section-title",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.security}),"Security Credentials"]}),B&&s.jsxs("div",{className:"ss-auth-error",style:{marginTop:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:B})]}),s.jsxs("form",{onSubmit:gs,style:{marginTop:"16px"},children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Current Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"••••••••••••",value:z,onChange:A=>F(A.target.value),required:!0})]}),s.jsxs("div",{className:"ss-auth-profile-grid",style:{marginBottom:"16px"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"New Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"Min. 8 characters",value:w,onChange:A=>m(A.target.value),required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Confirm New Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"Repeat new password",value:y,onChange:A=>C(A.target.value),required:!0})]})]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:s.jsx("button",{type:"submit",className:"ss-auth-btn-ghost",disabled:l,children:"Update Security"})})]})]}),s.jsxs("div",{className:"ss-auth-section",children:[s.jsx("div",{className:"ss-auth-section-title",style:{color:"inherit"},children:"Danger Zone"}),s.jsx("p",{className:"ss-auth-section-desc",style:{marginBottom:"16px"},children:"Deleting your account is permanent. All organizations you own will also be deleted."}),v&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:v})]}),L?s.jsxs("div",{children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Type your email to confirm"}),s.jsx("input",{className:"ss-auth-input",type:"email",placeholder:e==null?void 0:e.email,value:O,onChange:A=>R(A.target.value),autoFocus:!0})]}),s.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[s.jsx("button",{type:"button",className:"ss-auth-btn-ghost",onClick:()=>{T(!1),R(""),b(null)},children:"Cancel"}),s.jsxs("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",style:{width:"auto",background:"linear-gradient(135deg, #ef4444, #dc2626)"},disabled:!bs||f,onClick:fs,children:[f&&s.jsx("span",{className:"ss-auth-spinner"}),"Delete account"]})]})]}):s.jsx("button",{type:"button",className:"ss-auth-btn-outline",style:{borderColor:"currentColor",width:"auto"},onClick:()=>T(!0),children:"Delete my account"})]})]}),k&&s.jsx(ns,{onUpload:q,onClose:()=>P(!1),isLoading:l})]})})}function Is({appearance:a}){const{appearance:r}=E(),{user:e,signOut:o}=H(),{updateProfile:n,uploadAvatar:u,changePassword:l,isLoading:c,error:d,success:i,setError:x,setSuccess:p}=X(),g=a??r,[f,v]=t.useState((e==null?void 0:e.name)??""),[b,N]=t.useState((e==null?void 0:e.avatarUrl)??""),[h,j]=t.useState(!1),[S,k]=t.useState(""),[P,z]=t.useState(""),[F,w]=t.useState(""),[m,y]=t.useState(null),C=t.useCallback(async O=>{O.preventDefault(),x(null),p(null),await n({name:f,avatarUrl:b||void 0})},[f,b,n,x,p]),B=t.useCallback(async O=>{const R=await u(O);R&&(N(R.avatarUrl),j(!1))},[u]),D=t.useCallback(async O=>{if(O.preventDefault(),y(null),x(null),p(null),P!==F){y("Passwords do not match");return}if(P.length<8){y("Password must be at least 8 characters");return}await l(S,P)&&(k(""),z(""),w(""))},[S,P,F,l,x,p]);if(!e)return null;const L=e.provider==="email",T=(e.name||e.email).charAt(0).toUpperCase();return s.jsx(M,{appearance:g,children:s.jsxs("div",{className:"ss-auth-card",style:{maxWidth:"640px"},children:[s.jsxs("div",{className:"ss-auth-profile-header",children:[s.jsxs("div",{className:"ss-auth-avatar-lg",onClick:()=>j(!0),children:[b?s.jsx("img",{src:b,alt:""}):s.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"48px",fontWeight:800,opacity:.4},children:T}),s.jsxs("div",{className:"ss-auth-avatar-overlay",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.camera}),s.jsx("span",{children:"Edit"})]})]}),s.jsxs("div",{className:"ss-auth-profile-info",children:[s.jsxs("h2",{className:"ss-auth-profile-name",children:[e.name||"Unnamed User",e.emailVerified&&s.jsxs("span",{className:"ss-auth-badge ss-auth-badge-success",children:[s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"12px",fontVariationSettings:"'FILL' 1"},children:$.verified}),"Verified"]})]}),s.jsx("p",{className:"ss-auth-profile-desc",children:e.email})]})]}),s.jsxs("div",{className:"ss-auth-card-body",children:[d&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:d})]}),i&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.check}),s.jsx("span",{children:i})]}),s.jsxs("form",{onSubmit:C,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Full Name"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"Your name",value:f,onChange:O=>v(O.target.value)})]}),s.jsxs("div",{className:"ss-auth-profile-grid",style:{marginBottom:"16px"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Email Address"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"email",value:e.email,readOnly:!0}),s.jsx("span",{className:"ss-auth-visibility-toggle",style:{cursor:"default"},children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"18px"},children:$.lock})})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Auth Provider"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"text",value:e.provider,readOnly:!0}),s.jsx("span",{className:"ss-auth-visibility-toggle",style:{cursor:"default"},children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"18px"},children:$.cloudDone})})]})]})]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary ss-auth-btn-sm",disabled:c,style:{width:"auto"},children:[c&&s.jsx("span",{className:"ss-auth-spinner"}),"Save changes"]})})]}),L&&s.jsxs("div",{className:"ss-auth-section",children:[s.jsxs("div",{className:"ss-auth-section-title",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.security}),"Security Credentials"]}),s.jsx("p",{className:"ss-auth-section-desc",style:{marginBottom:"24px"},children:"Update your password to keep your account secure."}),m&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.errorOutline}),s.jsx("span",{children:m})]}),s.jsxs("form",{onSubmit:D,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Current Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"••••••••••••",value:S,onChange:O=>k(O.target.value),required:!0})]}),s.jsxs("div",{className:"ss-auth-profile-grid",style:{marginBottom:"16px"},children:[s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"New Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"Min. 8 characters",value:P,onChange:O=>z(O.target.value),required:!0})]}),s.jsxs("div",{children:[s.jsx("label",{className:"ss-auth-label",children:"Confirm New Password"}),s.jsx("input",{className:"ss-auth-input",type:"password",placeholder:"Repeat new password",value:F,onChange:O=>w(O.target.value),required:!0})]})]}),s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:$.info}),s.jsx("span",{children:"Password must be at least 8 characters long."})]}),s.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:s.jsx("button",{type:"submit",className:"ss-auth-btn-ghost",disabled:c,children:"Update Security"})})]})]}),s.jsx("div",{className:"ss-auth-section",style:{borderTop:"none",paddingTop:0,marginTop:"24px"},children:s.jsx("div",{className:"ss-auth-signout-section",style:{borderRadius:"12px",padding:"16px 20px"},children:s.jsxs("div",{className:"ss-auth-signout-row",children:[s.jsxs("div",{className:"ss-auth-signout-info",children:[s.jsx("div",{className:"ss-auth-signout-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:$.logout})}),s.jsxs("div",{children:[s.jsx("div",{className:"ss-auth-signout-title",children:"End Session"}),s.jsx("div",{className:"ss-auth-signout-desc",children:"Terminate your active session"})]})]}),s.jsx("button",{type:"button",className:"ss-auth-btn-outline",onClick:()=>o(),style:{width:"auto",flexShrink:0},children:"Sign out"})]})})})]}),h&&s.jsx(ns,{onUpload:B,onClose:()=>j(!1),isLoading:c})]})})}function Fs({appearance:a,onOrgChange:r}){const{appearance:e}=E(),{orgs:o,selectedOrg:n,selectOrg:u,createOrg:l,isLoading:c}=K(),d=a??e,[i,x]=t.useState(!1),[p,g]=t.useState(""),[f,v]=t.useState(""),[b,N]=t.useState(null),[h,j]=t.useState(!1),S=t.useRef(null),k=t.useCallback(m=>{S.current&&!m.composedPath().includes(S.current)&&x(!1)},[]);t.useEffect(()=>{if(i){const m=setTimeout(()=>{document.addEventListener("click",k)},0);return()=>{clearTimeout(m),document.removeEventListener("click",k)}}},[i,k]);const P=t.useCallback(m=>{g(m),v(m.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},[]),z=t.useCallback(async m=>{m.preventDefault(),N(null),j(!0);try{const y=await l(p,f);y&&(await u(y.id),r==null||r(y),g(""),v(""),x(!1))}catch(y){N(y instanceof Error?y.message:"Failed to create organization")}finally{j(!1)}},[p,f,l,u,r]);if(c)return null;const F=(n==null?void 0:n.name)??(o.length===0?"No organization":"Select organization"),w=n?n.name.split(" ").map(m=>m[0]).join("").slice(0,2).toUpperCase():"--";return s.jsx(M,{appearance:d,children:s.jsxs("div",{style:{position:"relative",display:"inline-block",width:"100%",maxWidth:"360px"},ref:S,children:[s.jsxs("button",{type:"button",className:"ss-auth-org-trigger",onClick:()=>x(!i),children:[s.jsxs("div",{className:"ss-auth-org-trigger-inner",children:[s.jsx("div",{className:"ss-auth-org-avatar",children:w}),s.jsxs("div",{style:{textAlign:"left"},children:[s.jsx("div",{className:"ss-auth-org-trigger-label",children:"Current Organization"}),s.jsx("div",{className:"ss-auth-org-trigger-name",children:F})]})]}),s.jsx("span",{className:"material-symbols-outlined",children:$.unfoldMore})]}),i&&s.jsxs("div",{className:"ss-auth-dropdown ss-auth-dropdown-left ss-auth-glass-panel",style:{width:"100%"},children:[s.jsx("div",{className:"ss-auth-section-label",children:"Your Organizations"}),s.jsx("div",{style:{padding:"0 8px 4px"},children:o.map(m=>{const y=(n==null?void 0:n.id)===m.id,C=m.name.split(" ").map(B=>B[0]).join("").slice(0,2).toUpperCase();return s.jsxs("button",{type:"button",className:`ss-auth-org-item${y?" ss-auth-org-item-active":""}`,onClick:async()=>{x(!1),await u(m.id),r==null||r(m)},children:[s.jsxs("div",{className:"ss-auth-org-item-inner",children:[s.jsx("div",{className:`ss-auth-org-avatar${y?"":" ss-auth-org-avatar-inactive"}`,children:C}),s.jsx("span",{style:{fontFamily:"'Manrope', sans-serif",letterSpacing:"-0.01em"},children:m.name})]}),y&&s.jsx("span",{className:"material-symbols-outlined ss-auth-org-check",style:{fontSize:"18px"},children:$.checkCircle})]},m.id)})}),s.jsxs("div",{className:"ss-auth-org-create",children:[s.jsxs("div",{className:"ss-auth-org-create-header",children:[s.jsx("span",{className:"material-symbols-outlined",children:$.addCircle}),s.jsx("span",{children:"Create organization"})]}),b&&s.jsx("div",{className:"ss-auth-error",style:{marginBottom:"12px",fontSize:"12px"},children:s.jsx("span",{children:b})}),s.jsxs("form",{onSubmit:z,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",style:{fontSize:"10px"},children:"Org Name"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"e.g. Nexus Dynamics",value:p,onChange:m=>P(m.target.value),required:!0,style:{fontSize:"13px",padding:"10px 12px"}})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",style:{fontSize:"10px"},children:"Workspace Slug"}),s.jsxs("div",{style:{position:"relative"},children:[s.jsx("span",{className:"ss-auth-org-slug-prefix",children:"/"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:"nexus-dynamics",value:f,onChange:m=>v(m.target.value),required:!0,style:{fontSize:"13px",padding:"10px 12px 10px 22px"}})]})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:h||!p.trim(),style:{marginTop:"8px"},children:[h&&s.jsx("span",{className:"ss-auth-spinner"}),"Initialize Organization"]})]})]})]})]})})}function Ls(a,r="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:r,minimumFractionDigits:a%100===0?0:2}).format(a/100)}function Bs({plans:a,currentPlanId:r,onSelectPlan:e,interval:o,appearance:n}){const{appearance:u}=E(),l=n??u,c=o?a.filter(d=>d.interval===o||d.isFree):a;return s.jsx(M,{appearance:l,children:s.jsx("div",{className:"ss-pricing-grid",children:c.map(d=>{const i=d.id===r;return s.jsxs("div",{className:`ss-pricing-card ${i?"ss-pricing-card-current":""}`,children:[s.jsxs("div",{className:"ss-pricing-header",children:[s.jsx("h3",{className:"ss-pricing-name",children:d.name}),d.trialDays>0&&s.jsxs("span",{className:"ss-badge ss-badge-trialing",children:[d.trialDays,"-day trial"]}),d.isFree&&s.jsx("span",{className:"ss-badge ss-badge-active",children:"Free"})]}),s.jsx("div",{className:"ss-pricing-price",children:d.isFree?s.jsx("span",{className:"ss-pricing-amount",children:"Free"}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"ss-pricing-amount",children:Ls(d.amountCents,d.currency)}),s.jsxs("span",{className:"ss-pricing-interval",children:["/",d.interval]})]})}),d.description&&s.jsx("p",{className:"ss-pricing-desc",children:d.description}),d.features.length>0&&s.jsx("ul",{className:"ss-pricing-features",children:d.features.map((x,p)=>s.jsxs("li",{className:"ss-pricing-feature",children:[s.jsx("span",{className:"ss-check",children:"✓"})," ",x]},p))}),s.jsx("button",{type:"button",className:`ss-btn ${i?"ss-btn-current":"ss-btn-primary"}`,disabled:i,onClick:()=>e(d.id),children:i?"Current plan":"Select plan"})]},d.id)})})})}function Ts(){const{client:a}=E();return{billing:a.billing}}function W(a){const{client:r}=E();return t.useMemo(()=>{if(a){const e=new U.Transport("https://api.saas-support.com/v1",{type:"portalToken",token:a});return new U.BillingClient(e)}return r.billing},[r,a])}function os(a,r){const e=W(r),[o,n]=t.useState(null),[u,l]=t.useState(!0),[c,d]=t.useState(null),i=t.useCallback(async()=>{l(!0),d(null);try{const x=await e.getCustomer(a);n(x)}catch(x){d(x instanceof Error?x.message:"Failed to load subscription")}finally{l(!1)}},[e,a]);return t.useEffect(()=>{i()},[i]),{customer:o,isLoading:u,error:c,refresh:i}}function is(a,r){const e=W(r),[o,n]=t.useState([]),[u,l]=t.useState(!0),[c,d]=t.useState(null),i=t.useCallback(async()=>{l(!0),d(null);try{const x=await e.getInvoices(a);n(x)}catch(x){d(x instanceof Error?x.message:"Failed to load invoices")}finally{l(!1)}},[e,a]);return t.useEffect(()=>{i()},[i]),{invoices:o,isLoading:u,error:c,refresh:i}}function ls(a,r){const e=W(r),[o,n]=t.useState([]),[u,l]=t.useState(!0),[c,d]=t.useState(null),i=t.useCallback(async()=>{l(!0),d(null);try{const x=await e.getCurrentUsage(a);n(x)}catch(x){d(x instanceof Error?x.message:"Failed to load usage")}finally{l(!1)}},[e,a]);return t.useEffect(()=>{i()},[i]),{usage:o,isLoading:u,error:c,refresh:i}}const As={active:"ss-badge-active"};function cs({customerId:a,portalToken:r,onChangePlan:e,onCancel:o,appearance:n}){const{appearance:u}=E(),{customer:l,isLoading:c,error:d}=os(a,r),i=n??u;return s.jsx(M,{appearance:i,children:s.jsxs("div",{className:"ss-card",children:[s.jsx("h2",{className:"ss-title",children:"Subscription"}),c&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),d&&s.jsx("div",{className:"ss-global-error",children:d}),l&&!c&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"ss-field",children:[s.jsx("label",{className:"ss-label",children:"Customer"}),s.jsx("input",{className:"ss-input",value:l.name||l.email,disabled:!0,readOnly:!0})]}),s.jsxs("div",{className:"ss-field",children:[s.jsx("label",{className:"ss-label",children:"Status"}),s.jsx("div",{children:s.jsx("span",{className:`ss-badge ${As.active}`,children:"Active"})})]}),s.jsxs("div",{className:"ss-btn-group",children:[e&&s.jsx("button",{type:"button",className:"ss-btn ss-btn-primary",onClick:e,children:"Change plan"}),o&&s.jsx("button",{type:"button",className:"ss-btn ss-btn-danger",onClick:o,children:"Cancel subscription"})]})]})]})})}const Ds={paid:"ss-badge-active",open:"ss-badge-trialing",draft:"ss-badge-paused",void:"ss-badge-canceled",uncollectible:"ss-badge-past-due"};function Ms(a){return new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Us(a){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(a/100)}function ds({customerId:a,portalToken:r,appearance:e}){const{appearance:o}=E(),{invoices:n,isLoading:u,error:l}=is(a,r),c=e??o,d=[...n].sort((i,x)=>new Date(x.createdAt).getTime()-new Date(i.createdAt).getTime());return s.jsx(M,{appearance:c,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[s.jsx("h2",{className:"ss-title",children:"Invoices"}),u&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),l&&s.jsx("div",{className:"ss-global-error",children:l}),!u&&d.length===0&&s.jsx("p",{className:"ss-empty",children:"No invoices yet."}),!u&&d.length>0&&s.jsxs("table",{className:"ss-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{className:"ss-th",children:"Date"}),s.jsx("th",{className:"ss-th",children:"Amount"}),s.jsx("th",{className:"ss-th",children:"Status"}),s.jsx("th",{className:"ss-th",children:"PDF"})]})}),s.jsx("tbody",{children:d.map(i=>s.jsxs("tr",{className:"ss-tr",children:[s.jsx("td",{className:"ss-td",children:Ms(i.createdAt)}),s.jsx("td",{className:"ss-td",children:Us(i.amountCents)}),s.jsx("td",{className:"ss-td",children:s.jsx("span",{className:`ss-badge ${Ds[i.status]||""}`,children:i.status})}),s.jsx("td",{className:"ss-td",children:i.pdfUrl?s.jsx("a",{className:"ss-link",href:i.pdfUrl,target:"_blank",rel:"noopener noreferrer",children:"Download"}):"—"})]},i.id))})]})]})})}function us({customerId:a,limits:r,portalToken:e,appearance:o}){const{appearance:n}=E(),{usage:u,isLoading:l,error:c}=ls(a,e),d=o??n;return s.jsx(M,{appearance:d,children:s.jsxs("div",{className:"ss-card",children:[s.jsx("h2",{className:"ss-title",children:"Usage"}),l&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),c&&s.jsx("div",{className:"ss-global-error",children:c}),!l&&u.length===0&&s.jsx("p",{className:"ss-empty",children:"No usage data."}),!l&&u.map(i=>{const x=r==null?void 0:r[i.metric],p=x?Math.min(100,i.total/x*100):null;return s.jsxs("div",{className:"ss-usage-item",children:[s.jsxs("div",{className:"ss-usage-header",children:[s.jsx("span",{className:"ss-usage-metric",children:i.metric}),s.jsxs("span",{className:"ss-usage-value",children:[i.total.toLocaleString(),x?` / ${x.toLocaleString()}`:""]})]}),p!==null&&s.jsx("div",{className:"ss-progress-bar",children:s.jsx("div",{className:`ss-progress-fill ${p>90?"ss-progress-danger":""}`,style:{width:`${p}%`}})})]},i.metric)})]})})}function Vs({customerId:a,portalToken:r,limits:e,onChangePlan:o,onCancel:n,appearance:u}){const{appearance:l}=E(),c=u??l,[d,i]=t.useState("subscription"),x=[{id:"subscription",label:"Subscription"},{id:"invoices",label:"Invoices"},{id:"usage",label:"Usage"}];return s.jsx(M,{appearance:c,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[s.jsx("h2",{className:"ss-title",children:"Billing"}),s.jsx("div",{className:"ss-tab-group",children:x.map(p=>s.jsx("button",{type:"button",className:`ss-tab ${d===p.id?"ss-tab-active":""}`,onClick:()=>i(p.id),children:p.label},p.id))}),s.jsxs("div",{className:"ss-tab-content",children:[d==="subscription"&&s.jsx(cs,{customerId:a,portalToken:r,onChangePlan:o,onCancel:n}),d==="invoices"&&s.jsx(ds,{customerId:a,portalToken:r}),d==="usage"&&s.jsx(us,{customerId:a,portalToken:r,limits:e})]})]})})}function Rs({customerId:a,portalToken:r,onApplied:e,appearance:o}){const{appearance:n}=E(),u=W(r),l=o??n,[c,d]=t.useState(""),[i,x]=t.useState(!1),[p,g]=t.useState(null),[f,v]=t.useState(null),b=t.useCallback(async N=>{if(N.preventDefault(),!!c.trim()){x(!0),g(null),v(null);try{const h=await u.applyCoupon(a,c.trim());v(`Coupon applied! ${h.discountType==="percent"?`${h.amount}% off`:`$${(h.amount/100).toFixed(2)} off`}`),d(""),e==null||e(h)}catch(h){g(h instanceof Error?h.message:"Invalid coupon code")}finally{x(!1)}}},[u,a,c,e]);return s.jsx(M,{appearance:l,children:s.jsxs("div",{className:"ss-card",children:[s.jsx("h2",{className:"ss-title",children:"Apply coupon"}),p&&s.jsx("div",{className:"ss-global-error",children:p}),f&&s.jsx("div",{className:"ss-success-msg",children:f}),s.jsxs("form",{onSubmit:b,children:[s.jsxs("div",{className:"ss-field",children:[s.jsx("label",{className:"ss-label",htmlFor:"ss-coupon-code",children:"Coupon code"}),s.jsx("input",{id:"ss-coupon-code",className:"ss-input",type:"text",placeholder:"Enter coupon code",value:c,onChange:N=>d(N.target.value),required:!0})]}),s.jsxs("button",{type:"submit",className:"ss-btn ss-btn-primary",disabled:i||!c.trim(),children:[i&&s.jsx("span",{className:"ss-spinner"}),"Apply"]})]})]})})}function qs(){const{client:a}=E();return{report:a.report}}function ss(){const{client:a}=E(),[r,e]=t.useState(null),[o,n]=t.useState(!1),[u,l]=t.useState(null),c=t.useCallback(async d=>{n(!0),l(null);try{const i=await a.report.executeQuery(d);return e(i),i}catch(i){return l(i instanceof Error?i.message:"Query failed"),null}finally{n(!1)}},[a]);return{result:r,execute:c,isLoading:o,error:u}}function ps(a){const{client:r}=E(),[e,o]=t.useState(null),[n,u]=t.useState(!0),[l,c]=t.useState(null),d=t.useCallback(async()=>{u(!0),c(null);try{const i=await r.report.listQueries(a);o(i)}catch(i){c(i instanceof Error?i.message:"Failed to load queries")}finally{u(!1)}},[r,a]);return t.useEffect(()=>{d()},[d]),{queries:(e==null?void 0:e.data)??[],meta:e==null?void 0:e.meta,isLoading:n,error:l,refresh:d}}function Hs(a){const{client:r}=E(),[e,o]=t.useState(null),[n,u]=t.useState(!0),[l,c]=t.useState(null),d=t.useCallback(async()=>{u(!0),c(null);try{const i=await r.report.getDashboard(a);o(i)}catch(i){c(i instanceof Error?i.message:"Failed to load dashboard")}finally{u(!1)}},[r,a]);return t.useEffect(()=>{d()},[d]),{dashboard:e,isLoading:n,error:l,refresh:d}}function Ws(a,r,e="https://api.saas-support.com/v1"){const o=t.useMemo(()=>{const p=new U.Transport(e,{type:"embedToken",token:a});return new U.ReportClient(p)},[a,e]),[n,u]=t.useState(null),[l,c]=t.useState(!0),[d,i]=t.useState(null),x=t.useCallback(async()=>{c(!0),i(null);try{const p=await o.getDashboard(r);u(p)}catch(p){i(p instanceof Error?p.message:"Failed to load dashboard")}finally{c(!1)}},[o,r]);return t.useEffect(()=>{x()},[x]),{dashboard:n,reportClient:o,isLoading:l,error:d,refresh:x}}function _s({onResult:a,mode:r="both",placeholder:e,appearance:o}){const{appearance:n}=E(),{execute:u,isLoading:l,error:c}=ss(),d=o??n,[i,x]=t.useState(""),[p,g]=t.useState(r==="sql"?"sql":"nl"),f=t.useCallback(async v=>{if(v.preventDefault(),!i.trim())return;const N=await u(p==="sql"?{sql:i}:{naturalLanguage:i});N&&(a==null||a(N))},[i,p,u,a]);return s.jsx(M,{appearance:d,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[r==="both"&&s.jsxs("div",{className:"ss-tab-group ss-tab-group-sm",children:[s.jsx("button",{type:"button",className:`ss-tab ${p==="nl"?"ss-tab-active":""}`,onClick:()=>g("nl"),children:"Natural Language"}),s.jsx("button",{type:"button",className:`ss-tab ${p==="sql"?"ss-tab-active":""}`,onClick:()=>g("sql"),children:"SQL"})]}),c&&s.jsx("div",{className:"ss-global-error",children:c}),s.jsxs("form",{onSubmit:f,children:[s.jsx("div",{className:"ss-field",children:s.jsx("textarea",{className:"ss-input ss-query-textarea",placeholder:e??(p==="sql"?"SELECT ...":"Ask a question about your data..."),value:i,onChange:v=>x(v.target.value),rows:3})}),s.jsxs("button",{type:"submit",className:"ss-btn ss-btn-primary",disabled:l||!i.trim(),children:[l&&s.jsx("span",{className:"ss-spinner"}),"Run query"]})]})]})})}function hs({columns:a,rows:r,sortable:e=!0,maxRows:o,appearance:n}){const{appearance:u}=E(),l=n??u,[c,d]=t.useState(null),[i,x]=t.useState("asc"),p=t.useMemo(()=>c?[...r].sort((b,N)=>{const h=b[c],j=N[c];if(h==null&&j==null)return 0;if(h==null)return 1;if(j==null)return-1;if(typeof h=="number"&&typeof j=="number")return i==="asc"?h-j:j-h;const S=String(h),k=String(j);return i==="asc"?S.localeCompare(k):k.localeCompare(S)}):r,[r,c,i]),g=o?p.slice(0,o):p,f=b=>{e&&(c===b?x(N=>N==="asc"?"desc":"asc"):(d(b),x("asc")))};function v(b){return b==null?"":typeof b=="object"?JSON.stringify(b):String(b)}return s.jsx(M,{appearance:l,children:s.jsxs("div",{className:"ss-table-container",children:[s.jsxs("table",{className:"ss-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:a.map(b=>s.jsxs("th",{className:`ss-th ${e?"ss-th-sortable":""} ${c===b?i==="asc"?"ss-sorted-asc":"ss-sorted-desc":""}`,onClick:()=>f(b),children:[b,c===b&&s.jsx("span",{className:"ss-sort-indicator",children:i==="asc"?" ▲":" ▼"})]},b))})}),s.jsx("tbody",{children:g.map((b,N)=>s.jsx("tr",{className:"ss-tr",children:a.map(h=>s.jsx("td",{className:"ss-td",children:v(b[h])},h))},N))})]}),o&&r.length>o&&s.jsxs("div",{className:"ss-table-footer",children:["Showing ",o," of ",r.length," rows"]})]})})}function Gs(a,r="#6366f1"){const e=parseInt(r.replace("#","").slice(0,2),16),o=[];for(let n=0;n<a;n++){const u=(e+n*Math.floor(360/Math.max(a,1)))%360;o.push(`hsl(${u}, 65%, 55%)`)}return o}function Ys({labels:a,values:r,w:e,h:o,colors:n}){const u=Math.max(...r,1),l=40,c=e-l*2,d=o-l*2,i=Math.max(1,c/a.length-4);return s.jsxs("g",{children:[s.jsx("line",{x1:l,y1:o-l,x2:e-l,y2:o-l,stroke:"#ccc",strokeWidth:1}),r.map((x,p)=>{const g=x/u*d,f=l+c/a.length*p+2,v=o-l-g;return s.jsxs("g",{children:[s.jsx("rect",{x:f,y:v,width:i,height:g,fill:n[p%n.length],rx:2}),s.jsx("text",{x:f+i/2,y:o-l+14,textAnchor:"middle",fontSize:10,fill:"#666",children:a[p].length>8?a[p].slice(0,8)+"...":a[p]})]},p)})]})}function Qs({labels:a,values:r,w:e,h:o,colors:n}){const u=Math.max(...r,1),l=40,c=e-l*2,d=o-l*2,i=a.length>1?c/(a.length-1):0,x=r.map((p,g)=>{const f=l+i*g,v=o-l-p/u*d;return`${f},${v}`});return s.jsxs("g",{children:[[.25,.5,.75,1].map(p=>{const g=o-l-p*d;return s.jsx("line",{x1:l,y1:g,x2:e-l,y2:g,stroke:"#eee",strokeWidth:1},p)}),s.jsx("polyline",{points:x.join(" "),fill:"none",stroke:n[0],strokeWidth:2}),r.map((p,g)=>{const f=l+i*g,v=o-l-p/u*d;return s.jsx("circle",{cx:f,cy:v,r:4,fill:n[0]},g)})]})}function Js({labels:a,values:r,w:e,h:o,colors:n}){const u=r.reduce((g,f)=>g+f,0)||1,l=e/2,c=o/2-20,d=Math.min(e,o)/2-40,i=2*Math.PI*d;let x=0;const p=r.map((g,f)=>{const v=g/u,b=v*i,N={dash:b,offset:x,color:n[f%n.length],label:a[f],pct:v};return x+=b,N});return s.jsxs("g",{children:[p.map((g,f)=>s.jsx("circle",{cx:l,cy:c,r:d,fill:"none",stroke:g.color,strokeWidth:d*.6,strokeDasharray:`${g.dash} ${i-g.dash}`,strokeDashoffset:-g.offset,transform:`rotate(-90 ${l} ${c})`},f)),s.jsx("g",{transform:`translate(${l-a.length*30}, ${o-20})`,children:p.slice(0,6).map((g,f)=>s.jsxs("g",{transform:`translate(${f*60}, 0)`,children:[s.jsx("rect",{width:10,height:10,fill:g.color,rx:2}),s.jsx("text",{x:14,y:9,fontSize:9,fill:"#666",children:g.label.length>6?g.label.slice(0,6)+"..":g.label})]},f))})]})}function xs({type:a,data:r,title:e,width:o=400,height:n=300,appearance:u}){const{appearance:l}=E(),c=u??l,d=t.useMemo(()=>Gs(r.labels.length),[r.labels.length]);return s.jsx(M,{appearance:c,children:s.jsxs("div",{className:"ss-chart-container",children:[e&&s.jsx("h3",{className:"ss-chart-title",children:e}),s.jsxs("svg",{viewBox:`0 0 ${o} ${n}`,width:"100%",style:{maxWidth:o},children:[a==="bar"&&s.jsx(Ys,{labels:r.labels,values:r.values,w:o,h:n,colors:d}),a==="line"&&s.jsx(Qs,{labels:r.labels,values:r.values,w:o,h:n,colors:d}),a==="pie"&&s.jsx(Js,{labels:r.labels,values:r.values,w:o,h:n,colors:d})]})]})})}function Zs({dashboardId:a,embedToken:r,baseUrl:e,refreshInterval:o,appearance:n}){const u=E(),l=n??(u==null?void 0:u.appearance),c=t.useMemo(()=>{if(r){const h=e??"https://api.saas-support.com/v1",j=new U.Transport(h,{type:"embedToken",token:r});return new U.ReportClient(j)}return u.client.report},[r,e,u]),[d,i]=t.useState([]),[x,p]=t.useState({}),[g,f]=t.useState(!0),[v,b]=t.useState(null),N=t.useCallback(async()=>{f(!0),b(null);try{const h=await c.getDashboard(a),j=JSON.parse(h.layoutJson||"[]");i(j);const S={};for(const k of j)try{const P=await c.listQueries({search:k.queryId,perPage:1});if(P.data.length>0&&P.data[0].generatedSql){const z=await c.executeQuery({sql:P.data[0].generatedSql});S[k.queryId]=z}}catch{}p(S)}catch(h){b(h instanceof Error?h.message:"Failed to load dashboard")}finally{f(!1)}},[c,a]);return t.useEffect(()=>{N()},[N]),t.useEffect(()=>{if(!o||o<=0)return;const h=setInterval(N,o*1e3);return()=>clearInterval(h)},[o,N]),s.jsx(M,{appearance:l,children:s.jsxs("div",{className:"ss-dashboard-grid",children:[g&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading dashboard..."]}),v&&s.jsx("div",{className:"ss-global-error",children:v}),!g&&d.map((h,j)=>{const S=x[h.queryId];if(!S)return null;const k=S.columns.length>=2?{labels:S.rows.map(P=>String(P[S.columns[0]]??"")),values:S.rows.map(P=>Number(P[S.columns[1]]??0))}:{labels:[],values:[]};return s.jsxs("div",{className:"ss-widget",children:[h.title&&s.jsx("h4",{className:"ss-widget-header",children:h.title}),h.chartType==="table"?s.jsx(hs,{columns:S.columns,rows:S.rows,maxRows:50}):s.jsx(xs,{type:h.chartType||"bar",data:k,width:h.w,height:h.h})]},j)})]})})}function Ks(a){return new Date(a).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Xs({onSelectQuery:a,onRunQuery:r,appearance:e}){const{appearance:o}=E(),{queries:n,isLoading:u,error:l}=ps(),{execute:c,isLoading:d}=ss(),i=e??o,x=t.useCallback(async p=>{if(!p.generatedSql)return;const g=await c({sql:p.generatedSql});g&&(r==null||r(g))},[c,r]);return s.jsx(M,{appearance:i,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[s.jsx("h2",{className:"ss-title",children:"Saved Queries"}),u&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),l&&s.jsx("div",{className:"ss-global-error",children:l}),!u&&n.length===0&&s.jsx("p",{className:"ss-empty",children:"No saved queries."}),!u&&n.map(p=>s.jsxs("div",{className:"ss-saved-query-card",onClick:()=>a==null?void 0:a(p),children:[s.jsxs("div",{className:"ss-saved-query-header",children:[s.jsx("span",{className:"ss-saved-query-name",children:p.name}),p.chartType&&s.jsx("span",{className:"ss-badge",children:p.chartType})]}),p.naturalLanguage&&s.jsx("p",{className:"ss-saved-query-desc",children:p.naturalLanguage}),s.jsxs("div",{className:"ss-saved-query-footer",children:[s.jsx("span",{className:"ss-saved-query-date",children:Ks(p.createdAt)}),s.jsx("button",{type:"button",className:"ss-btn ss-btn-sm ss-btn-primary",disabled:d||!p.generatedSql,onClick:g=>{g.stopPropagation(),x(p)},children:d?s.jsx("span",{className:"ss-spinner"}):"Run"})]})]},p.id))]})})}function sa({embedToken:a,dashboardId:r,baseUrl:e="https://api.saas-support.com/v1",refreshInterval:o,appearance:n}){const u=t.useMemo(()=>{const b=new U.Transport(e,{type:"embedToken",token:a});return new U.ReportClient(b)},[a,e]),[l,c]=t.useState([]),[d,i]=t.useState(!0),[x,p]=t.useState(null),g=t.useMemo(()=>Y(n),[n]),f=t.useMemo(()=>Q(g),[g]),v=t.useCallback(async()=>{i(!0),p(null);try{const b=await u.getDashboard(r),N=JSON.parse(b.layoutJson||"[]"),h=await Promise.all(N.map(async j=>{try{const S=await u.listQueries({search:j.queryId,perPage:1});if(S.data.length>0&&S.data[0].generatedSql){const k=await u.executeQuery({sql:S.data[0].generatedSql});return{...j,result:k}}}catch{}return j}));c(h)}catch(b){p(b instanceof Error?b.message:"Failed to load dashboard")}finally{i(!1)}},[u,r]);return t.useEffect(()=>{v()},[v]),t.useEffect(()=>{if(!o||o<=0)return;const b=setInterval(v,o*1e3);return()=>clearInterval(b)},[o,v]),s.jsx("div",{ref:b=>{if(!b||b.shadowRoot)return;const N=b.attachShadow({mode:"open"}),h=document.createElement("style");h.textContent=f,N.appendChild(h);const j=document.createElement("div");N.appendChild(j)},style:{display:"contents"},children:s.jsxs("div",{className:"ss-dashboard-grid",children:[d&&s.jsx("div",{className:"ss-loading",children:"Loading dashboard..."}),x&&s.jsx("div",{className:"ss-global-error",children:x}),!d&&l.map((b,N)=>{if(!b.result)return null;const{columns:h,rows:j}=b.result;return s.jsxs("div",{className:"ss-widget",children:[b.title&&s.jsx("h4",{className:"ss-widget-header",children:b.title}),s.jsxs("table",{className:"ss-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:h.map(S=>s.jsx("th",{className:"ss-th",children:S},S))})}),s.jsx("tbody",{children:j.slice(0,50).map((S,k)=>s.jsx("tr",{className:"ss-tr",children:h.map(P=>s.jsx("td",{className:"ss-td",children:String(S[P]??"")},P))},k))})]})]},N)})]})})}exports.SaaSError=U.SaaSError;exports.SaaSSupport=U.SaaSSupport;exports.isMfaRequired=U.isMfaRequired;exports.Chart=xs;exports.CouponInput=Rs;exports.DashboardView=Zs;exports.DataTable=hs;exports.InvoiceHistory=ds;exports.OrgSwitcher=Fs;exports.PaymentPortal=Vs;exports.PricingTable=Bs;exports.QueryInput=_s;exports.ReportEmbed=sa;exports.SaaSContext=J;exports.SaaSProvider=js;exports.SavedQueryList=Xs;exports.SignIn=Cs;exports.SignUp=Ps;exports.SubscriptionStatus=cs;exports.UsageDisplay=us;exports.UserButton=Es;exports.UserProfile=Is;exports.useAuth=H;exports.useBilling=Ts;exports.useDashboard=Hs;exports.useDeleteAccount=es;exports.useEmbedDashboard=Ws;exports.useInvoices=is;exports.useOrg=K;exports.useProfile=X;exports.useQuery=ss;exports.useReport=qs;exports.useSaaSContext=E;exports.useSavedQueries=ps;exports.useSignIn=Z;exports.useSignUp=as;exports.useSubscription=os;exports.useUsage=ls;exports.useUser=$s;
|
package/dist/react.js
CHANGED
|
@@ -19,11 +19,11 @@ function Xa({ publishableKey: a, apiKey: s, baseUrl: t, appearance: o, children:
|
|
|
19
19
|
const w = await u.auth.getUser(), y = await u.auth.getSettings();
|
|
20
20
|
c(w), p(y), i(!0);
|
|
21
21
|
});
|
|
22
|
-
const
|
|
22
|
+
const b = u.auth.onAuthStateChange((w) => {
|
|
23
23
|
m || c(w);
|
|
24
24
|
});
|
|
25
25
|
return () => {
|
|
26
|
-
m = !0,
|
|
26
|
+
m = !0, b(), u.destroy();
|
|
27
27
|
};
|
|
28
28
|
}, [u]), /* @__PURE__ */ e(ra.Provider, { value: { client: u, user: l, isLoaded: d, appearance: o, settings: f }, children: n });
|
|
29
29
|
}
|
|
@@ -1024,7 +1024,7 @@ function aa(a) {
|
|
|
1024
1024
|
border: 1px solid ${a.authOutlineVariant}26;
|
|
1025
1025
|
box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
|
|
1026
1026
|
width: 100%;
|
|
1027
|
-
max-width:
|
|
1027
|
+
max-width: 520px;
|
|
1028
1028
|
overflow: hidden;
|
|
1029
1029
|
}
|
|
1030
1030
|
|
|
@@ -2197,8 +2197,13 @@ function q({ children: a, appearance: s }) {
|
|
|
2197
2197
|
}
|
|
2198
2198
|
const l = t.current.attachShadow({ mode: "open" });
|
|
2199
2199
|
if ((s == null ? void 0 : s.fontUrl) !== null) {
|
|
2200
|
-
const p =
|
|
2201
|
-
|
|
2200
|
+
const p = (s == null ? void 0 : s.fontUrl) ?? "https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Inter:wght@400;500;600&family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200&display=swap";
|
|
2201
|
+
if (!document.querySelector(`link[href="${p}"]`)) {
|
|
2202
|
+
const b = document.createElement("link");
|
|
2203
|
+
b.rel = "stylesheet", b.href = p, document.head.appendChild(b);
|
|
2204
|
+
}
|
|
2205
|
+
const m = document.createElement("link");
|
|
2206
|
+
m.rel = "stylesheet", m.href = p, l.appendChild(m);
|
|
2202
2207
|
}
|
|
2203
2208
|
const c = X(s), d = document.createElement("style");
|
|
2204
2209
|
d.textContent = aa(c), l.appendChild(d);
|
|
@@ -2286,14 +2291,14 @@ function Ca() {
|
|
|
2286
2291
|
), isLoading: s, error: o, setError: n };
|
|
2287
2292
|
}
|
|
2288
2293
|
function na() {
|
|
2289
|
-
const { client: a } = L(), [s, t] = g([]), [o, n] = g(null), [u, l] = g([]), [c, d] = g([]), [i, f] = g(!1), [p, m] = g(null),
|
|
2294
|
+
const { client: a } = L(), [s, t] = g([]), [o, n] = g(null), [u, l] = g([]), [c, d] = g([]), [i, f] = g(!1), [p, m] = g(null), b = $(async () => {
|
|
2290
2295
|
f(!0), m(null);
|
|
2291
2296
|
try {
|
|
2292
2297
|
const S = await a.auth.listOrgs();
|
|
2293
2298
|
t(S);
|
|
2294
|
-
const
|
|
2295
|
-
if (
|
|
2296
|
-
const v = S.find((O) => O.id ===
|
|
2299
|
+
const x = typeof window < "u" ? localStorage.getItem("ss_selected_org") : null;
|
|
2300
|
+
if (x && S.some((v) => v.id === x) && !o) {
|
|
2301
|
+
const v = S.find((O) => O.id === x);
|
|
2297
2302
|
n(v);
|
|
2298
2303
|
try {
|
|
2299
2304
|
const O = await a.auth.listMembers(v.id);
|
|
@@ -2308,74 +2313,74 @@ function na() {
|
|
|
2308
2313
|
}
|
|
2309
2314
|
}, [a, o]);
|
|
2310
2315
|
V(() => {
|
|
2311
|
-
|
|
2312
|
-
}, [
|
|
2316
|
+
b();
|
|
2317
|
+
}, [b]);
|
|
2313
2318
|
const w = $(async (S) => {
|
|
2314
2319
|
try {
|
|
2315
|
-
const
|
|
2316
|
-
n(
|
|
2320
|
+
const x = await a.auth.getOrg(S);
|
|
2321
|
+
n(x), typeof window < "u" && localStorage.setItem("ss_selected_org", S);
|
|
2317
2322
|
const v = await a.auth.listMembers(S);
|
|
2318
2323
|
l(v);
|
|
2319
|
-
} catch (
|
|
2320
|
-
m(
|
|
2324
|
+
} catch (x) {
|
|
2325
|
+
m(x instanceof Error ? x.message : "Failed to load organization");
|
|
2321
2326
|
}
|
|
2322
|
-
}, [a]), y = $(async (S,
|
|
2327
|
+
}, [a]), y = $(async (S, x) => {
|
|
2323
2328
|
try {
|
|
2324
|
-
const v = await a.auth.createOrg(S,
|
|
2329
|
+
const v = await a.auth.createOrg(S, x);
|
|
2325
2330
|
return t((O) => [...O, v]), v;
|
|
2326
2331
|
} catch (v) {
|
|
2327
2332
|
return m(v instanceof Error ? v.message : "Failed to create organization"), null;
|
|
2328
2333
|
}
|
|
2329
|
-
}, [a]), C = $(async (S,
|
|
2334
|
+
}, [a]), C = $(async (S, x) => {
|
|
2330
2335
|
try {
|
|
2331
|
-
const v = await a.auth.updateOrg(S,
|
|
2336
|
+
const v = await a.auth.updateOrg(S, x);
|
|
2332
2337
|
return t((O) => O.map((D) => D.id === S ? v : D)), (o == null ? void 0 : o.id) === S && n(v), v;
|
|
2333
2338
|
} catch (v) {
|
|
2334
2339
|
return m(v instanceof Error ? v.message : "Failed to update organization"), null;
|
|
2335
2340
|
}
|
|
2336
2341
|
}, [a, o]), h = $(async (S) => {
|
|
2337
2342
|
try {
|
|
2338
|
-
return await a.auth.deleteOrg(S), t((
|
|
2339
|
-
} catch (
|
|
2340
|
-
return m(
|
|
2343
|
+
return await a.auth.deleteOrg(S), t((x) => x.filter((v) => v.id !== S)), (o == null ? void 0 : o.id) === S && (n(null), l([]), d([]), typeof window < "u" && localStorage.removeItem("ss_selected_org")), !0;
|
|
2344
|
+
} catch (x) {
|
|
2345
|
+
return m(x instanceof Error ? x.message : "Failed to delete organization"), !1;
|
|
2341
2346
|
}
|
|
2342
|
-
}, [a, o]), N = $(async (S,
|
|
2347
|
+
}, [a, o]), N = $(async (S, x, v) => {
|
|
2343
2348
|
try {
|
|
2344
|
-
return await a.auth.sendInvite(S,
|
|
2349
|
+
return await a.auth.sendInvite(S, x, v);
|
|
2345
2350
|
} catch (O) {
|
|
2346
2351
|
return m(O instanceof Error ? O.message : "Failed to send invite"), null;
|
|
2347
2352
|
}
|
|
2348
2353
|
}, [a]), k = $(async (S) => {
|
|
2349
2354
|
try {
|
|
2350
|
-
const
|
|
2351
|
-
d(
|
|
2352
|
-
} catch (
|
|
2353
|
-
m(
|
|
2355
|
+
const x = await a.auth.listInvites(S);
|
|
2356
|
+
d(x);
|
|
2357
|
+
} catch (x) {
|
|
2358
|
+
m(x instanceof Error ? x.message : "Failed to load invites");
|
|
2354
2359
|
}
|
|
2355
|
-
}, [a]), z = $(async (S,
|
|
2360
|
+
}, [a]), z = $(async (S, x) => {
|
|
2356
2361
|
try {
|
|
2357
|
-
return await a.auth.revokeInvite(S,
|
|
2362
|
+
return await a.auth.revokeInvite(S, x), d((v) => v.filter((O) => O.id !== x)), !0;
|
|
2358
2363
|
} catch (v) {
|
|
2359
2364
|
return m(v instanceof Error ? v.message : "Failed to revoke invite"), !1;
|
|
2360
2365
|
}
|
|
2361
|
-
}, [a]), E = $(async (S,
|
|
2366
|
+
}, [a]), E = $(async (S, x, v) => {
|
|
2362
2367
|
try {
|
|
2363
|
-
return await a.auth.updateMemberRole(S,
|
|
2368
|
+
return await a.auth.updateMemberRole(S, x, v), l((O) => O.map((D) => D.userId === x ? { ...D, role: v } : D)), !0;
|
|
2364
2369
|
} catch (O) {
|
|
2365
2370
|
return m(O instanceof Error ? O.message : "Failed to update member role"), !1;
|
|
2366
2371
|
}
|
|
2367
|
-
}, [a]), I = $(async (S,
|
|
2372
|
+
}, [a]), I = $(async (S, x) => {
|
|
2368
2373
|
try {
|
|
2369
|
-
return await a.auth.removeMember(S,
|
|
2374
|
+
return await a.auth.removeMember(S, x), l((v) => v.filter((O) => O.userId !== x)), !0;
|
|
2370
2375
|
} catch (v) {
|
|
2371
2376
|
return m(v instanceof Error ? v.message : "Failed to remove member"), !1;
|
|
2372
2377
|
}
|
|
2373
2378
|
}, [a]), A = $(async (S) => {
|
|
2374
2379
|
try {
|
|
2375
|
-
const
|
|
2376
|
-
l(
|
|
2377
|
-
} catch (
|
|
2378
|
-
m(
|
|
2380
|
+
const x = await a.auth.listMembers(S);
|
|
2381
|
+
l(x);
|
|
2382
|
+
} catch (x) {
|
|
2383
|
+
m(x instanceof Error ? x.message : "Failed to load members");
|
|
2379
2384
|
}
|
|
2380
2385
|
}, [a]);
|
|
2381
2386
|
return {
|
|
@@ -2386,7 +2391,7 @@ function na() {
|
|
|
2386
2391
|
isLoading: i,
|
|
2387
2392
|
error: p,
|
|
2388
2393
|
setError: m,
|
|
2389
|
-
refresh:
|
|
2394
|
+
refresh: b,
|
|
2390
2395
|
selectOrg: w,
|
|
2391
2396
|
createOrg: y,
|
|
2392
2397
|
updateOrg: C,
|
|
@@ -2431,8 +2436,8 @@ function oa() {
|
|
|
2431
2436
|
o(!0), u(null), c(null);
|
|
2432
2437
|
try {
|
|
2433
2438
|
return await a.auth.changePassword(p, m), c("Password changed successfully"), !0;
|
|
2434
|
-
} catch (
|
|
2435
|
-
return u(
|
|
2439
|
+
} catch (b) {
|
|
2440
|
+
return u(b instanceof Error ? b.message : "Failed to change password"), !1;
|
|
2436
2441
|
} finally {
|
|
2437
2442
|
o(!1);
|
|
2438
2443
|
}
|
|
@@ -2482,7 +2487,7 @@ const ia = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d=
|
|
|
2482
2487
|
image: "image"
|
|
2483
2488
|
};
|
|
2484
2489
|
function ee({ appearance: a, signUpUrl: s, onSignUp: t }) {
|
|
2485
|
-
const { appearance: o, settings: n } = L(), { signIn: u, signInWithOAuth: l, submitMfaCode: c, isLoading: d, error: i, setError: f } = sa(), p = a ?? o, [m,
|
|
2490
|
+
const { appearance: o, settings: n } = L(), { signIn: u, signInWithOAuth: l, submitMfaCode: c, isLoading: d, error: i, setError: f } = sa(), p = a ?? o, [m, b] = g(""), [w, y] = g(""), [C, h] = g(!1), [N, k] = g(!1), [z, E] = g(""), [I, A] = g(["", "", "", "", "", ""]), S = W([]), x = $(
|
|
2486
2491
|
async (T) => {
|
|
2487
2492
|
if (T.preventDefault(), N) {
|
|
2488
2493
|
await c(z, I.join(""));
|
|
@@ -2550,7 +2555,7 @@ function ee({ appearance: a, signUpUrl: s, onSignUp: t }) {
|
|
|
2550
2555
|
/* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: P.errorOutline }),
|
|
2551
2556
|
/* @__PURE__ */ e("span", { children: i })
|
|
2552
2557
|
] }),
|
|
2553
|
-
/* @__PURE__ */ r("form", { onSubmit:
|
|
2558
|
+
/* @__PURE__ */ r("form", { onSubmit: x, children: [
|
|
2554
2559
|
N ? /* @__PURE__ */ r(G, { children: [
|
|
2555
2560
|
/* @__PURE__ */ e("div", { className: "ss-auth-mfa-divider", children: /* @__PURE__ */ e("span", { children: "Verification Required" }) }),
|
|
2556
2561
|
/* @__PURE__ */ r("div", { className: "ss-auth-field", children: [
|
|
@@ -2586,7 +2591,7 @@ function ee({ appearance: a, signUpUrl: s, onSignUp: t }) {
|
|
|
2586
2591
|
autoComplete: "email",
|
|
2587
2592
|
placeholder: "name@company.com",
|
|
2588
2593
|
value: m,
|
|
2589
|
-
onChange: (T) =>
|
|
2594
|
+
onChange: (T) => b(T.target.value),
|
|
2590
2595
|
required: !0
|
|
2591
2596
|
}
|
|
2592
2597
|
)
|
|
@@ -2645,27 +2650,27 @@ function ee({ appearance: a, signUpUrl: s, onSignUp: t }) {
|
|
|
2645
2650
|
] }) }) });
|
|
2646
2651
|
}
|
|
2647
2652
|
function te({ appearance: a, signInUrl: s, onSignIn: t }) {
|
|
2648
|
-
const { appearance: o, settings: n } = L(), { signUp: u, isLoading: l, error: c, setError: d } = Ca(), { signInWithOAuth: i } = sa(), f = a ?? o, [p, m] = g(""), [
|
|
2649
|
-
async (
|
|
2650
|
-
if (
|
|
2653
|
+
const { appearance: o, settings: n } = L(), { signUp: u, isLoading: l, error: c, setError: d } = Ca(), { signInWithOAuth: i } = sa(), f = a ?? o, [p, m] = g(""), [b, w] = g(""), [y, C] = g(""), [h, N] = g(!1), [k, z] = g(null), E = $(
|
|
2654
|
+
async (x) => {
|
|
2655
|
+
if (x.preventDefault(), z(null), b !== y) {
|
|
2651
2656
|
z("Passwords do not match");
|
|
2652
2657
|
return;
|
|
2653
2658
|
}
|
|
2654
2659
|
const v = (n == null ? void 0 : n.passwordMinLength) ?? 8;
|
|
2655
|
-
if (
|
|
2660
|
+
if (b.length < v) {
|
|
2656
2661
|
z(`Password must be at least ${v} characters`);
|
|
2657
2662
|
return;
|
|
2658
2663
|
}
|
|
2659
|
-
await u(p,
|
|
2664
|
+
await u(p, b);
|
|
2660
2665
|
},
|
|
2661
|
-
[p,
|
|
2666
|
+
[p, b, y, n, u]
|
|
2662
2667
|
), I = $(
|
|
2663
|
-
async (
|
|
2664
|
-
await i(
|
|
2668
|
+
async (x) => {
|
|
2669
|
+
await i(x);
|
|
2665
2670
|
},
|
|
2666
2671
|
[i]
|
|
2667
2672
|
), A = (n == null ? void 0 : n.googleEnabled) || (n == null ? void 0 : n.githubEnabled), S = k || c;
|
|
2668
|
-
return /* @__PURE__ */ e(q, { appearance: f, children: /* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", width: "100%", maxWidth: "
|
|
2673
|
+
return /* @__PURE__ */ e(q, { appearance: f, children: /* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", width: "100%", maxWidth: "520px" }, children: [
|
|
2669
2674
|
/* @__PURE__ */ r("div", { className: "ss-auth-header", children: [
|
|
2670
2675
|
/* @__PURE__ */ e("div", { className: "ss-auth-brand-icon-gradient", children: /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: P.autoAwesome }) }),
|
|
2671
2676
|
/* @__PURE__ */ e("h1", { className: "ss-auth-title ss-auth-title-lg", children: "Create your account" }),
|
|
@@ -2719,7 +2724,7 @@ function te({ appearance: a, signInUrl: s, onSignIn: t }) {
|
|
|
2719
2724
|
autoComplete: "email",
|
|
2720
2725
|
placeholder: "name@company.com",
|
|
2721
2726
|
value: p,
|
|
2722
|
-
onChange: (
|
|
2727
|
+
onChange: (x) => m(x.target.value),
|
|
2723
2728
|
required: !0
|
|
2724
2729
|
}
|
|
2725
2730
|
)
|
|
@@ -2735,9 +2740,9 @@ function te({ appearance: a, signInUrl: s, onSignIn: t }) {
|
|
|
2735
2740
|
type: h ? "text" : "password",
|
|
2736
2741
|
autoComplete: "new-password",
|
|
2737
2742
|
placeholder: "••••••••",
|
|
2738
|
-
value:
|
|
2739
|
-
onChange: (
|
|
2740
|
-
w(
|
|
2743
|
+
value: b,
|
|
2744
|
+
onChange: (x) => {
|
|
2745
|
+
w(x.target.value), z(null);
|
|
2741
2746
|
},
|
|
2742
2747
|
required: !0
|
|
2743
2748
|
}
|
|
@@ -2764,8 +2769,8 @@ function te({ appearance: a, signInUrl: s, onSignIn: t }) {
|
|
|
2764
2769
|
autoComplete: "new-password",
|
|
2765
2770
|
placeholder: "••••••••",
|
|
2766
2771
|
value: y,
|
|
2767
|
-
onChange: (
|
|
2768
|
-
C(
|
|
2772
|
+
onChange: (x) => {
|
|
2773
|
+
C(x.target.value), z(null);
|
|
2769
2774
|
},
|
|
2770
2775
|
required: !0
|
|
2771
2776
|
}
|
|
@@ -2787,11 +2792,11 @@ function te({ appearance: a, signInUrl: s, onSignIn: t }) {
|
|
|
2787
2792
|
}
|
|
2788
2793
|
const B = 320, j = 128;
|
|
2789
2794
|
function Pa({ file: a, onCrop: s, onCancel: t }) {
|
|
2790
|
-
const o = W(null), n = W(null), [u, l] = g(1), [c, d] = g({ x: 0, y: 0 }), [i, f] = g(!1), p = W({ x: 0, y: 0, ox: 0, oy: 0 }), [m,
|
|
2795
|
+
const o = W(null), n = W(null), [u, l] = g(1), [c, d] = g({ x: 0, y: 0 }), [i, f] = g(!1), p = W({ x: 0, y: 0, ox: 0, oy: 0 }), [m, b] = g(!1);
|
|
2791
2796
|
V(() => {
|
|
2792
2797
|
const h = new Image(), N = URL.createObjectURL(a);
|
|
2793
2798
|
return h.onload = () => {
|
|
2794
|
-
n.current = h,
|
|
2799
|
+
n.current = h, b(!0), d({ x: 0, y: 0 }), l(1);
|
|
2795
2800
|
}, h.src = N, () => URL.revokeObjectURL(N);
|
|
2796
2801
|
}, [a]), V(() => {
|
|
2797
2802
|
if (!m || !n.current || !o.current) return;
|
|
@@ -2822,8 +2827,8 @@ function Pa({ file: a, onCrop: s, onCancel: t }) {
|
|
|
2822
2827
|
h.width = N, h.height = N;
|
|
2823
2828
|
const k = h.getContext("2d");
|
|
2824
2829
|
if (!k) return;
|
|
2825
|
-
const z = n.current, E = Math.max(B / z.width, B / z.height) * u, I = z.width * E, A = z.height * E, S = (B - I) / 2 + c.x - (B / 2 - j),
|
|
2826
|
-
k.beginPath(), k.arc(j, j, j, 0, Math.PI * 2), k.clip(), k.drawImage(z, S,
|
|
2830
|
+
const z = n.current, E = Math.max(B / z.width, B / z.height) * u, I = z.width * E, A = z.height * E, S = (B - I) / 2 + c.x - (B / 2 - j), x = (B - A) / 2 + c.y - (B / 2 - j);
|
|
2831
|
+
k.beginPath(), k.arc(j, j, j, 0, Math.PI * 2), k.clip(), k.drawImage(z, S, x, I, A), h.toBlob((v) => {
|
|
2827
2832
|
v && s(v);
|
|
2828
2833
|
}, "image/png");
|
|
2829
2834
|
}, [u, c, s]), /* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "24px" }, children: [
|
|
@@ -2861,31 +2866,31 @@ function Pa({ file: a, onCrop: s, onCancel: t }) {
|
|
|
2861
2866
|
] });
|
|
2862
2867
|
}
|
|
2863
2868
|
function ca({ onUpload: a, onClose: s, isLoading: t }) {
|
|
2864
|
-
const [o, n] = g(null), [u, l] = g(!1), [c, d] = g(null), i = W(null), f = $((
|
|
2865
|
-
if (!
|
|
2869
|
+
const [o, n] = g(null), [u, l] = g(!1), [c, d] = g(null), i = W(null), f = $((b) => {
|
|
2870
|
+
if (!b.type.startsWith("image/")) {
|
|
2866
2871
|
d("Please select an image file");
|
|
2867
2872
|
return;
|
|
2868
2873
|
}
|
|
2869
|
-
if (
|
|
2874
|
+
if (b.size > 5 * 1024 * 1024) {
|
|
2870
2875
|
d("Image must be smaller than 5 MB");
|
|
2871
2876
|
return;
|
|
2872
2877
|
}
|
|
2873
|
-
d(null), n(
|
|
2878
|
+
d(null), n(b);
|
|
2874
2879
|
}, []), p = $(
|
|
2875
|
-
(
|
|
2876
|
-
|
|
2877
|
-
const w =
|
|
2880
|
+
(b) => {
|
|
2881
|
+
b.preventDefault(), l(!1);
|
|
2882
|
+
const w = b.dataTransfer.files[0];
|
|
2878
2883
|
w && f(w);
|
|
2879
2884
|
},
|
|
2880
2885
|
[f]
|
|
2881
2886
|
), m = $(
|
|
2882
|
-
async (
|
|
2883
|
-
await a(
|
|
2887
|
+
async (b) => {
|
|
2888
|
+
await a(b);
|
|
2884
2889
|
},
|
|
2885
2890
|
[a]
|
|
2886
2891
|
);
|
|
2887
|
-
return /* @__PURE__ */ e("div", { className: "ss-auth-modal-overlay", onClick: (
|
|
2888
|
-
|
|
2892
|
+
return /* @__PURE__ */ e("div", { className: "ss-auth-modal-overlay", onClick: (b) => {
|
|
2893
|
+
b.target === b.currentTarget && s();
|
|
2889
2894
|
}, children: /* @__PURE__ */ r("div", { className: "ss-auth-modal ss-auth-card-wide", children: [
|
|
2890
2895
|
/* @__PURE__ */ r("div", { className: "ss-auth-modal-header", children: [
|
|
2891
2896
|
/* @__PURE__ */ e("h2", { children: "Upload avatar" }),
|
|
@@ -2921,14 +2926,14 @@ function ca({ onUpload: a, onClose: s, isLoading: t }) {
|
|
|
2921
2926
|
"div",
|
|
2922
2927
|
{
|
|
2923
2928
|
className: `ss-auth-dropzone${u ? " ss-auth-dropzone-active" : ""}`,
|
|
2924
|
-
onDragOver: (
|
|
2925
|
-
|
|
2929
|
+
onDragOver: (b) => {
|
|
2930
|
+
b.preventDefault(), l(!0);
|
|
2926
2931
|
},
|
|
2927
2932
|
onDragLeave: () => l(!1),
|
|
2928
2933
|
onDrop: p,
|
|
2929
2934
|
onClick: () => {
|
|
2930
|
-
var
|
|
2931
|
-
return (
|
|
2935
|
+
var b;
|
|
2936
|
+
return (b = i.current) == null ? void 0 : b.click();
|
|
2932
2937
|
},
|
|
2933
2938
|
style: { minHeight: "180px" },
|
|
2934
2939
|
children: [
|
|
@@ -2947,9 +2952,9 @@ function ca({ onUpload: a, onClose: s, isLoading: t }) {
|
|
|
2947
2952
|
type: "file",
|
|
2948
2953
|
accept: "image/*",
|
|
2949
2954
|
style: { display: "none" },
|
|
2950
|
-
onChange: (
|
|
2955
|
+
onChange: (b) => {
|
|
2951
2956
|
var w;
|
|
2952
|
-
(w =
|
|
2957
|
+
(w = b.target.files) != null && w[0] && f(b.target.files[0]);
|
|
2953
2958
|
}
|
|
2954
2959
|
}
|
|
2955
2960
|
)
|
|
@@ -2992,19 +2997,19 @@ function re({
|
|
|
2992
2997
|
onOrgChange: n,
|
|
2993
2998
|
onOrgSettingsClick: u
|
|
2994
2999
|
}) {
|
|
2995
|
-
const { appearance: l } = L(), { user: c, signOut: d } = ta(), i = a ?? l, [f, p] = g(!1), [m,
|
|
3000
|
+
const { appearance: l } = L(), { user: c, signOut: d } = ta(), i = a ?? l, [f, p] = g(!1), [m, b] = g(!1), [w, y] = g(""), [C, h] = g(null), [N, k] = g(!1), z = W(null), { orgs: E, selectedOrg: I, selectOrg: A, createOrg: S } = na(), x = $((O) => {
|
|
2996
3001
|
z.current && !O.composedPath().includes(z.current) && p(!1);
|
|
2997
3002
|
}, []);
|
|
2998
3003
|
V(() => {
|
|
2999
3004
|
if (f) {
|
|
3000
3005
|
const O = setTimeout(() => {
|
|
3001
|
-
document.addEventListener("click",
|
|
3006
|
+
document.addEventListener("click", x);
|
|
3002
3007
|
}, 0);
|
|
3003
3008
|
return () => {
|
|
3004
|
-
clearTimeout(O), document.removeEventListener("click",
|
|
3009
|
+
clearTimeout(O), document.removeEventListener("click", x);
|
|
3005
3010
|
};
|
|
3006
3011
|
}
|
|
3007
|
-
}, [f,
|
|
3012
|
+
}, [f, x]);
|
|
3008
3013
|
const v = $(
|
|
3009
3014
|
async (O) => {
|
|
3010
3015
|
O.preventDefault(), h(null), k(!0);
|
|
@@ -3061,7 +3066,7 @@ function re({
|
|
|
3061
3066
|
type: "button",
|
|
3062
3067
|
className: "ss-auth-dropdown-action",
|
|
3063
3068
|
onClick: () => {
|
|
3064
|
-
p(!1),
|
|
3069
|
+
p(!1), b(!0);
|
|
3065
3070
|
},
|
|
3066
3071
|
children: [
|
|
3067
3072
|
/* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: P.person }),
|
|
@@ -3152,14 +3157,14 @@ function re({
|
|
|
3152
3157
|
m && /* @__PURE__ */ e(
|
|
3153
3158
|
Oa,
|
|
3154
3159
|
{
|
|
3155
|
-
onClose: () =>
|
|
3160
|
+
onClose: () => b(!1),
|
|
3156
3161
|
afterDeleteAccountUrl: t
|
|
3157
3162
|
}
|
|
3158
3163
|
)
|
|
3159
3164
|
] }) }) : null;
|
|
3160
3165
|
}
|
|
3161
3166
|
function Oa({ onClose: a, afterDeleteAccountUrl: s }) {
|
|
3162
|
-
const { user: t, updateProfile: o, uploadAvatar: n, changePassword: u, isLoading: l, error: c, success: d, setError: i, setSuccess: f } = oa(), { signOut: p } = ta(), { deleteAccount: m, isLoading:
|
|
3167
|
+
const { user: t, updateProfile: o, uploadAvatar: n, changePassword: u, isLoading: l, error: c, success: d, setError: i, setSuccess: f } = oa(), { signOut: p } = ta(), { deleteAccount: m, isLoading: b, error: w, setError: y } = za(), [C, h] = g((t == null ? void 0 : t.name) ?? ""), [N, k] = g((t == null ? void 0 : t.avatarUrl) ?? ""), [z, E] = g(!1), [I, A] = g(""), [S, x] = g(""), [v, O] = g(""), [D, H] = g(null), [T, M] = g(!1), [F, R] = g(""), Z = $(
|
|
3163
3168
|
async (U) => {
|
|
3164
3169
|
U.preventDefault(), i(null), f(null), await o({ name: C, avatarUrl: N || void 0 });
|
|
3165
3170
|
},
|
|
@@ -3180,7 +3185,7 @@ function Oa({ onClose: a, afterDeleteAccountUrl: s }) {
|
|
|
3180
3185
|
H("Password must be at least 8 characters");
|
|
3181
3186
|
return;
|
|
3182
3187
|
}
|
|
3183
|
-
await u(I, S) && (A(""),
|
|
3188
|
+
await u(I, S) && (A(""), x(""), O(""));
|
|
3184
3189
|
},
|
|
3185
3190
|
[I, S, v, u, i, f]
|
|
3186
3191
|
), pa = $(async () => {
|
|
@@ -3279,7 +3284,7 @@ function Oa({ onClose: a, afterDeleteAccountUrl: s }) {
|
|
|
3279
3284
|
/* @__PURE__ */ r("div", { className: "ss-auth-profile-grid", style: { marginBottom: "16px" }, children: [
|
|
3280
3285
|
/* @__PURE__ */ r("div", { children: [
|
|
3281
3286
|
/* @__PURE__ */ e("label", { className: "ss-auth-label", children: "New Password" }),
|
|
3282
|
-
/* @__PURE__ */ e("input", { className: "ss-auth-input", type: "password", placeholder: "Min. 8 characters", value: S, onChange: (U) =>
|
|
3287
|
+
/* @__PURE__ */ e("input", { className: "ss-auth-input", type: "password", placeholder: "Min. 8 characters", value: S, onChange: (U) => x(U.target.value), required: !0 })
|
|
3283
3288
|
] }),
|
|
3284
3289
|
/* @__PURE__ */ r("div", { children: [
|
|
3285
3290
|
/* @__PURE__ */ e("label", { className: "ss-auth-label", children: "Confirm New Password" }),
|
|
@@ -3329,10 +3334,10 @@ function Oa({ onClose: a, afterDeleteAccountUrl: s }) {
|
|
|
3329
3334
|
type: "button",
|
|
3330
3335
|
className: "ss-auth-btn-primary ss-auth-btn-sm",
|
|
3331
3336
|
style: { width: "auto", background: "linear-gradient(135deg, #ef4444, #dc2626)" },
|
|
3332
|
-
disabled: !ga ||
|
|
3337
|
+
disabled: !ga || b,
|
|
3333
3338
|
onClick: pa,
|
|
3334
3339
|
children: [
|
|
3335
|
-
|
|
3340
|
+
b && /* @__PURE__ */ e("span", { className: "ss-auth-spinner" }),
|
|
3336
3341
|
"Delete account"
|
|
3337
3342
|
]
|
|
3338
3343
|
}
|
|
@@ -3361,11 +3366,11 @@ function Oa({ onClose: a, afterDeleteAccountUrl: s }) {
|
|
|
3361
3366
|
] }) });
|
|
3362
3367
|
}
|
|
3363
3368
|
function se({ appearance: a }) {
|
|
3364
|
-
const { appearance: s } = L(), { user: t, signOut: o } = ta(), { updateProfile: n, uploadAvatar: u, changePassword: l, isLoading: c, error: d, success: i, setError: f, setSuccess: p } = oa(), m = a ?? s, [
|
|
3369
|
+
const { appearance: s } = L(), { user: t, signOut: o } = ta(), { updateProfile: n, uploadAvatar: u, changePassword: l, isLoading: c, error: d, success: i, setError: f, setSuccess: p } = oa(), m = a ?? s, [b, w] = g((t == null ? void 0 : t.name) ?? ""), [y, C] = g((t == null ? void 0 : t.avatarUrl) ?? ""), [h, N] = g(!1), [k, z] = g(""), [E, I] = g(""), [A, S] = g(""), [x, v] = g(null), O = $(
|
|
3365
3370
|
async (F) => {
|
|
3366
|
-
F.preventDefault(), f(null), p(null), await n({ name:
|
|
3371
|
+
F.preventDefault(), f(null), p(null), await n({ name: b, avatarUrl: y || void 0 });
|
|
3367
3372
|
},
|
|
3368
|
-
[
|
|
3373
|
+
[b, y, n, f, p]
|
|
3369
3374
|
), D = $(
|
|
3370
3375
|
async (F) => {
|
|
3371
3376
|
const R = await u(F);
|
|
@@ -3435,7 +3440,7 @@ function se({ appearance: a }) {
|
|
|
3435
3440
|
className: "ss-auth-input",
|
|
3436
3441
|
type: "text",
|
|
3437
3442
|
placeholder: "Your name",
|
|
3438
|
-
value:
|
|
3443
|
+
value: b,
|
|
3439
3444
|
onChange: (F) => w(F.target.value)
|
|
3440
3445
|
}
|
|
3441
3446
|
)
|
|
@@ -3467,9 +3472,9 @@ function se({ appearance: a }) {
|
|
|
3467
3472
|
"Security Credentials"
|
|
3468
3473
|
] }),
|
|
3469
3474
|
/* @__PURE__ */ e("p", { className: "ss-auth-section-desc", style: { marginBottom: "24px" }, children: "Update your password to keep your account secure." }),
|
|
3470
|
-
|
|
3475
|
+
x && /* @__PURE__ */ r("div", { className: "ss-auth-error", children: [
|
|
3471
3476
|
/* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: P.errorOutline }),
|
|
3472
|
-
/* @__PURE__ */ e("span", { children:
|
|
3477
|
+
/* @__PURE__ */ e("span", { children: x })
|
|
3473
3478
|
] }),
|
|
3474
3479
|
/* @__PURE__ */ r("form", { onSubmit: H, children: [
|
|
3475
3480
|
/* @__PURE__ */ r("div", { className: "ss-auth-field", children: [
|
|
@@ -3554,26 +3559,26 @@ function se({ appearance: a }) {
|
|
|
3554
3559
|
] }) });
|
|
3555
3560
|
}
|
|
3556
3561
|
function ne({ appearance: a, onOrgChange: s }) {
|
|
3557
|
-
const { appearance: t } = L(), { orgs: o, selectedOrg: n, selectOrg: u, createOrg: l, isLoading: c } = na(), d = a ?? t, [i, f] = g(!1), [p, m] = g(""), [
|
|
3558
|
-
k.current && !
|
|
3562
|
+
const { appearance: t } = L(), { orgs: o, selectedOrg: n, selectOrg: u, createOrg: l, isLoading: c } = na(), d = a ?? t, [i, f] = g(!1), [p, m] = g(""), [b, w] = g(""), [y, C] = g(null), [h, N] = g(!1), k = W(null), z = $((x) => {
|
|
3563
|
+
k.current && !x.composedPath().includes(k.current) && f(!1);
|
|
3559
3564
|
}, []);
|
|
3560
3565
|
V(() => {
|
|
3561
3566
|
if (i) {
|
|
3562
|
-
const
|
|
3567
|
+
const x = setTimeout(() => {
|
|
3563
3568
|
document.addEventListener("click", z);
|
|
3564
3569
|
}, 0);
|
|
3565
3570
|
return () => {
|
|
3566
|
-
clearTimeout(
|
|
3571
|
+
clearTimeout(x), document.removeEventListener("click", z);
|
|
3567
3572
|
};
|
|
3568
3573
|
}
|
|
3569
3574
|
}, [i, z]);
|
|
3570
|
-
const E = $((
|
|
3571
|
-
m(
|
|
3575
|
+
const E = $((x) => {
|
|
3576
|
+
m(x), w(x.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""));
|
|
3572
3577
|
}, []), I = $(
|
|
3573
|
-
async (
|
|
3574
|
-
|
|
3578
|
+
async (x) => {
|
|
3579
|
+
x.preventDefault(), C(null), N(!0);
|
|
3575
3580
|
try {
|
|
3576
|
-
const v = await l(p,
|
|
3581
|
+
const v = await l(p, b);
|
|
3577
3582
|
v && (await u(v.id), s == null || s(v), m(""), w(""), f(!1));
|
|
3578
3583
|
} catch (v) {
|
|
3579
3584
|
C(v instanceof Error ? v.message : "Failed to create organization");
|
|
@@ -3581,10 +3586,10 @@ function ne({ appearance: a, onOrgChange: s }) {
|
|
|
3581
3586
|
N(!1);
|
|
3582
3587
|
}
|
|
3583
3588
|
},
|
|
3584
|
-
[p,
|
|
3589
|
+
[p, b, l, u, s]
|
|
3585
3590
|
);
|
|
3586
3591
|
if (c) return null;
|
|
3587
|
-
const A = (n == null ? void 0 : n.name) ?? (o.length === 0 ? "No organization" : "Select organization"), S = n ? n.name.split(" ").map((
|
|
3592
|
+
const A = (n == null ? void 0 : n.name) ?? (o.length === 0 ? "No organization" : "Select organization"), S = n ? n.name.split(" ").map((x) => x[0]).join("").slice(0, 2).toUpperCase() : "--";
|
|
3588
3593
|
return /* @__PURE__ */ e(q, { appearance: d, children: /* @__PURE__ */ r("div", { style: { position: "relative", display: "inline-block", width: "100%", maxWidth: "360px" }, ref: k, children: [
|
|
3589
3594
|
/* @__PURE__ */ r(
|
|
3590
3595
|
"button",
|
|
@@ -3606,25 +3611,25 @@ function ne({ appearance: a, onOrgChange: s }) {
|
|
|
3606
3611
|
),
|
|
3607
3612
|
i && /* @__PURE__ */ r("div", { className: "ss-auth-dropdown ss-auth-dropdown-left ss-auth-glass-panel", style: { width: "100%" }, children: [
|
|
3608
3613
|
/* @__PURE__ */ e("div", { className: "ss-auth-section-label", children: "Your Organizations" }),
|
|
3609
|
-
/* @__PURE__ */ e("div", { style: { padding: "0 8px 4px" }, children: o.map((
|
|
3610
|
-
const v = (n == null ? void 0 : n.id) ===
|
|
3614
|
+
/* @__PURE__ */ e("div", { style: { padding: "0 8px 4px" }, children: o.map((x) => {
|
|
3615
|
+
const v = (n == null ? void 0 : n.id) === x.id, O = x.name.split(" ").map((D) => D[0]).join("").slice(0, 2).toUpperCase();
|
|
3611
3616
|
return /* @__PURE__ */ r(
|
|
3612
3617
|
"button",
|
|
3613
3618
|
{
|
|
3614
3619
|
type: "button",
|
|
3615
3620
|
className: `ss-auth-org-item${v ? " ss-auth-org-item-active" : ""}`,
|
|
3616
3621
|
onClick: async () => {
|
|
3617
|
-
f(!1), await u(
|
|
3622
|
+
f(!1), await u(x.id), s == null || s(x);
|
|
3618
3623
|
},
|
|
3619
3624
|
children: [
|
|
3620
3625
|
/* @__PURE__ */ r("div", { className: "ss-auth-org-item-inner", children: [
|
|
3621
3626
|
/* @__PURE__ */ e("div", { className: `ss-auth-org-avatar${v ? "" : " ss-auth-org-avatar-inactive"}`, children: O }),
|
|
3622
|
-
/* @__PURE__ */ e("span", { style: { fontFamily: "'Manrope', sans-serif", letterSpacing: "-0.01em" }, children:
|
|
3627
|
+
/* @__PURE__ */ e("span", { style: { fontFamily: "'Manrope', sans-serif", letterSpacing: "-0.01em" }, children: x.name })
|
|
3623
3628
|
] }),
|
|
3624
3629
|
v && /* @__PURE__ */ e("span", { className: "material-symbols-outlined ss-auth-org-check", style: { fontSize: "18px" }, children: P.checkCircle })
|
|
3625
3630
|
]
|
|
3626
3631
|
},
|
|
3627
|
-
|
|
3632
|
+
x.id
|
|
3628
3633
|
);
|
|
3629
3634
|
}) }),
|
|
3630
3635
|
/* @__PURE__ */ r("div", { className: "ss-auth-org-create", children: [
|
|
@@ -3643,7 +3648,7 @@ function ne({ appearance: a, onOrgChange: s }) {
|
|
|
3643
3648
|
type: "text",
|
|
3644
3649
|
placeholder: "e.g. Nexus Dynamics",
|
|
3645
3650
|
value: p,
|
|
3646
|
-
onChange: (
|
|
3651
|
+
onChange: (x) => E(x.target.value),
|
|
3647
3652
|
required: !0,
|
|
3648
3653
|
style: { fontSize: "13px", padding: "10px 12px" }
|
|
3649
3654
|
}
|
|
@@ -3659,8 +3664,8 @@ function ne({ appearance: a, onOrgChange: s }) {
|
|
|
3659
3664
|
className: "ss-auth-input",
|
|
3660
3665
|
type: "text",
|
|
3661
3666
|
placeholder: "nexus-dynamics",
|
|
3662
|
-
value:
|
|
3663
|
-
onChange: (
|
|
3667
|
+
value: b,
|
|
3668
|
+
onChange: (x) => w(x.target.value),
|
|
3664
3669
|
required: !0,
|
|
3665
3670
|
style: { fontSize: "13px", padding: "10px 12px 10px 22px" }
|
|
3666
3671
|
}
|
|
@@ -3938,7 +3943,7 @@ function le({
|
|
|
3938
3943
|
] }) });
|
|
3939
3944
|
}
|
|
3940
3945
|
function ce({ customerId: a, portalToken: s, onApplied: t, appearance: o }) {
|
|
3941
|
-
const { appearance: n } = L(), u = Q(s), l = o ?? n, [c, d] = g(""), [i, f] = g(!1), [p, m] = g(null), [
|
|
3946
|
+
const { appearance: n } = L(), u = Q(s), l = o ?? n, [c, d] = g(""), [i, f] = g(!1), [p, m] = g(null), [b, w] = g(null), y = $(async (C) => {
|
|
3942
3947
|
if (C.preventDefault(), !!c.trim()) {
|
|
3943
3948
|
f(!0), m(null), w(null);
|
|
3944
3949
|
try {
|
|
@@ -3954,7 +3959,7 @@ function ce({ customerId: a, portalToken: s, onApplied: t, appearance: o }) {
|
|
|
3954
3959
|
return /* @__PURE__ */ e(q, { appearance: l, children: /* @__PURE__ */ r("div", { className: "ss-card", children: [
|
|
3955
3960
|
/* @__PURE__ */ e("h2", { className: "ss-title", children: "Apply coupon" }),
|
|
3956
3961
|
p && /* @__PURE__ */ e("div", { className: "ss-global-error", children: p }),
|
|
3957
|
-
|
|
3962
|
+
b && /* @__PURE__ */ e("div", { className: "ss-success-msg", children: b }),
|
|
3958
3963
|
/* @__PURE__ */ r("form", { onSubmit: y, children: [
|
|
3959
3964
|
/* @__PURE__ */ r("div", { className: "ss-field", children: [
|
|
3960
3965
|
/* @__PURE__ */ e("label", { className: "ss-label", htmlFor: "ss-coupon-code", children: "Coupon code" }),
|
|
@@ -4048,7 +4053,7 @@ function pe(a, s, t = "https://api.saas-support.com/v1") {
|
|
|
4048
4053
|
}, [f]), { dashboard: n, reportClient: o, isLoading: l, error: d, refresh: f };
|
|
4049
4054
|
}
|
|
4050
4055
|
function he({ onResult: a, mode: s = "both", placeholder: t, appearance: o }) {
|
|
4051
|
-
const { appearance: n } = L(), { execute: u, isLoading: l, error: c } = da(), d = o ?? n, [i, f] = g(""), [p, m] = g(s === "sql" ? "sql" : "nl"),
|
|
4056
|
+
const { appearance: n } = L(), { execute: u, isLoading: l, error: c } = da(), d = o ?? n, [i, f] = g(""), [p, m] = g(s === "sql" ? "sql" : "nl"), b = $(async (w) => {
|
|
4052
4057
|
if (w.preventDefault(), !i.trim()) return;
|
|
4053
4058
|
const C = await u(p === "sql" ? { sql: i } : { naturalLanguage: i });
|
|
4054
4059
|
C && (a == null || a(C));
|
|
@@ -4075,7 +4080,7 @@ function he({ onResult: a, mode: s = "both", placeholder: t, appearance: o }) {
|
|
|
4075
4080
|
)
|
|
4076
4081
|
] }),
|
|
4077
4082
|
c && /* @__PURE__ */ e("div", { className: "ss-global-error", children: c }),
|
|
4078
|
-
/* @__PURE__ */ r("form", { onSubmit:
|
|
4083
|
+
/* @__PURE__ */ r("form", { onSubmit: b, children: [
|
|
4079
4084
|
/* @__PURE__ */ e("div", { className: "ss-field", children: /* @__PURE__ */ e(
|
|
4080
4085
|
"textarea",
|
|
4081
4086
|
{
|
|
@@ -4103,7 +4108,7 @@ function qa({ columns: a, rows: s, sortable: t = !0, maxRows: o, appearance: n }
|
|
|
4103
4108
|
return i === "asc" ? h - N : N - h;
|
|
4104
4109
|
const k = String(h), z = String(N);
|
|
4105
4110
|
return i === "asc" ? k.localeCompare(z) : z.localeCompare(k);
|
|
4106
|
-
}) : s, [s, c, i]), m = o ? p.slice(0, o) : p,
|
|
4111
|
+
}) : s, [s, c, i]), m = o ? p.slice(0, o) : p, b = (y) => {
|
|
4107
4112
|
t && (c === y ? f((C) => C === "asc" ? "desc" : "asc") : (d(y), f("asc")));
|
|
4108
4113
|
};
|
|
4109
4114
|
function w(y) {
|
|
@@ -4115,7 +4120,7 @@ function qa({ columns: a, rows: s, sortable: t = !0, maxRows: o, appearance: n }
|
|
|
4115
4120
|
"th",
|
|
4116
4121
|
{
|
|
4117
4122
|
className: `ss-th ${t ? "ss-th-sortable" : ""} ${c === y ? i === "asc" ? "ss-sorted-asc" : "ss-sorted-desc" : ""}`,
|
|
4118
|
-
onClick: () =>
|
|
4123
|
+
onClick: () => b(y),
|
|
4119
4124
|
children: [
|
|
4120
4125
|
y,
|
|
4121
4126
|
c === y && /* @__PURE__ */ e("span", { className: "ss-sort-indicator", children: i === "asc" ? " ▲" : " ▼" })
|
|
@@ -4147,18 +4152,18 @@ function Ra({ labels: a, values: s, w: t, h: o, colors: n }) {
|
|
|
4147
4152
|
return /* @__PURE__ */ r("g", { children: [
|
|
4148
4153
|
/* @__PURE__ */ e("line", { x1: l, y1: o - l, x2: t - l, y2: o - l, stroke: "#ccc", strokeWidth: 1 }),
|
|
4149
4154
|
s.map((f, p) => {
|
|
4150
|
-
const m = f / u * d,
|
|
4155
|
+
const m = f / u * d, b = l + c / a.length * p + 2, w = o - l - m;
|
|
4151
4156
|
return /* @__PURE__ */ r("g", { children: [
|
|
4152
|
-
/* @__PURE__ */ e("rect", { x, y: w, width: i, height: m, fill: n[p % n.length], rx: 2 }),
|
|
4153
|
-
/* @__PURE__ */ e("text", { x:
|
|
4157
|
+
/* @__PURE__ */ e("rect", { x: b, y: w, width: i, height: m, fill: n[p % n.length], rx: 2 }),
|
|
4158
|
+
/* @__PURE__ */ e("text", { x: b + i / 2, y: o - l + 14, textAnchor: "middle", fontSize: 10, fill: "#666", children: a[p].length > 8 ? a[p].slice(0, 8) + "..." : a[p] })
|
|
4154
4159
|
] }, p);
|
|
4155
4160
|
})
|
|
4156
4161
|
] });
|
|
4157
4162
|
}
|
|
4158
4163
|
function Wa({ labels: a, values: s, w: t, h: o, colors: n }) {
|
|
4159
4164
|
const u = Math.max(...s, 1), l = 40, c = t - l * 2, d = o - l * 2, i = a.length > 1 ? c / (a.length - 1) : 0, f = s.map((p, m) => {
|
|
4160
|
-
const
|
|
4161
|
-
return `${
|
|
4165
|
+
const b = l + i * m, w = o - l - p / u * d;
|
|
4166
|
+
return `${b},${w}`;
|
|
4162
4167
|
});
|
|
4163
4168
|
return /* @__PURE__ */ r("g", { children: [
|
|
4164
4169
|
[0.25, 0.5, 0.75, 1].map((p) => {
|
|
@@ -4167,20 +4172,20 @@ function Wa({ labels: a, values: s, w: t, h: o, colors: n }) {
|
|
|
4167
4172
|
}),
|
|
4168
4173
|
/* @__PURE__ */ e("polyline", { points: f.join(" "), fill: "none", stroke: n[0], strokeWidth: 2 }),
|
|
4169
4174
|
s.map((p, m) => {
|
|
4170
|
-
const
|
|
4171
|
-
return /* @__PURE__ */ e("circle", { cx:
|
|
4175
|
+
const b = l + i * m, w = o - l - p / u * d;
|
|
4176
|
+
return /* @__PURE__ */ e("circle", { cx: b, cy: w, r: 4, fill: n[0] }, m);
|
|
4172
4177
|
})
|
|
4173
4178
|
] });
|
|
4174
4179
|
}
|
|
4175
4180
|
function _a({ labels: a, values: s, w: t, h: o, colors: n }) {
|
|
4176
|
-
const u = s.reduce((m,
|
|
4181
|
+
const u = s.reduce((m, b) => m + b, 0) || 1, l = t / 2, c = o / 2 - 20, d = Math.min(t, o) / 2 - 40, i = 2 * Math.PI * d;
|
|
4177
4182
|
let f = 0;
|
|
4178
|
-
const p = s.map((m,
|
|
4179
|
-
const w = m / u, y = w * i, C = { dash: y, offset: f, color: n[
|
|
4183
|
+
const p = s.map((m, b) => {
|
|
4184
|
+
const w = m / u, y = w * i, C = { dash: y, offset: f, color: n[b % n.length], label: a[b], pct: w };
|
|
4180
4185
|
return f += y, C;
|
|
4181
4186
|
});
|
|
4182
4187
|
return /* @__PURE__ */ r("g", { children: [
|
|
4183
|
-
p.map((m,
|
|
4188
|
+
p.map((m, b) => /* @__PURE__ */ e(
|
|
4184
4189
|
"circle",
|
|
4185
4190
|
{
|
|
4186
4191
|
cx: l,
|
|
@@ -4193,12 +4198,12 @@ function _a({ labels: a, values: s, w: t, h: o, colors: n }) {
|
|
|
4193
4198
|
strokeDashoffset: -m.offset,
|
|
4194
4199
|
transform: `rotate(-90 ${l} ${c})`
|
|
4195
4200
|
},
|
|
4196
|
-
|
|
4201
|
+
b
|
|
4197
4202
|
)),
|
|
4198
|
-
/* @__PURE__ */ e("g", { transform: `translate(${l - a.length * 30}, ${o - 20})`, children: p.slice(0, 6).map((m,
|
|
4203
|
+
/* @__PURE__ */ e("g", { transform: `translate(${l - a.length * 30}, ${o - 20})`, children: p.slice(0, 6).map((m, b) => /* @__PURE__ */ r("g", { transform: `translate(${b * 60}, 0)`, children: [
|
|
4199
4204
|
/* @__PURE__ */ e("rect", { width: 10, height: 10, fill: m.color, rx: 2 }),
|
|
4200
4205
|
/* @__PURE__ */ e("text", { x: 14, y: 9, fontSize: 9, fill: "#666", children: m.label.length > 6 ? m.label.slice(0, 6) + ".." : m.label })
|
|
4201
|
-
] },
|
|
4206
|
+
] }, b)) })
|
|
4202
4207
|
] });
|
|
4203
4208
|
}
|
|
4204
4209
|
function Ga({ type: a, data: s, title: t, width: o = 400, height: n = 300, appearance: u }) {
|
|
@@ -4219,8 +4224,8 @@ function ge({ dashboardId: a, embedToken: s, baseUrl: t, refreshInterval: o, app
|
|
|
4219
4224
|
return new ea(N);
|
|
4220
4225
|
}
|
|
4221
4226
|
return u.client.report;
|
|
4222
|
-
}, [s, t, u]), [d, i] = g([]), [f, p] = g({}), [m,
|
|
4223
|
-
|
|
4227
|
+
}, [s, t, u]), [d, i] = g([]), [f, p] = g({}), [m, b] = g(!0), [w, y] = g(null), C = $(async () => {
|
|
4228
|
+
b(!0), y(null);
|
|
4224
4229
|
try {
|
|
4225
4230
|
const h = await c.getDashboard(a), N = JSON.parse(h.layoutJson || "[]");
|
|
4226
4231
|
i(N);
|
|
@@ -4238,7 +4243,7 @@ function ge({ dashboardId: a, embedToken: s, baseUrl: t, refreshInterval: o, app
|
|
|
4238
4243
|
} catch (h) {
|
|
4239
4244
|
y(h instanceof Error ? h.message : "Failed to load dashboard");
|
|
4240
4245
|
} finally {
|
|
4241
|
-
|
|
4246
|
+
b(!1);
|
|
4242
4247
|
}
|
|
4243
4248
|
}, [c, a]);
|
|
4244
4249
|
return V(() => {
|
|
@@ -4328,7 +4333,7 @@ function me({ embedToken: a, dashboardId: s, baseUrl: t = "https://api.saas-supp
|
|
|
4328
4333
|
const u = _(() => {
|
|
4329
4334
|
const y = new J(t, { type: "embedToken", token: a });
|
|
4330
4335
|
return new ea(y);
|
|
4331
|
-
}, [a, t]), [l, c] = g([]), [d, i] = g(!0), [f, p] = g(null), m = _(() => X(n), [n]),
|
|
4336
|
+
}, [a, t]), [l, c] = g([]), [d, i] = g(!0), [f, p] = g(null), m = _(() => X(n), [n]), b = _(() => aa(m), [m]), w = $(async () => {
|
|
4332
4337
|
i(!0), p(null);
|
|
4333
4338
|
try {
|
|
4334
4339
|
const y = await u.getDashboard(s), C = JSON.parse(y.layoutJson || "[]"), h = await Promise.all(
|
|
@@ -4363,7 +4368,7 @@ function me({ embedToken: a, dashboardId: s, baseUrl: t = "https://api.saas-supp
|
|
|
4363
4368
|
ref: (y) => {
|
|
4364
4369
|
if (!y || y.shadowRoot) return;
|
|
4365
4370
|
const C = y.attachShadow({ mode: "open" }), h = document.createElement("style");
|
|
4366
|
-
h.textContent =
|
|
4371
|
+
h.textContent = b, C.appendChild(h);
|
|
4367
4372
|
const N = document.createElement("div");
|
|
4368
4373
|
C.appendChild(N);
|
|
4369
4374
|
},
|