@saas-support/react 0.7.2 → 0.7.3

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 CHANGED
@@ -1279,6 +1279,7 @@
1279
1279
  cursor: pointer;
1280
1280
  transition: background 0.15s, box-shadow 0.15s;
1281
1281
  font-family: ${e.authFontBody};
1282
+ max-width: 200px;
1282
1283
  }
1283
1284
 
1284
1285
  .ss-auth-user-trigger:hover {
@@ -2098,6 +2099,25 @@
2098
2099
  margin: 0;
2099
2100
  }
2100
2101
 
2102
+ .ss-auth-settings-back {
2103
+ display: flex;
2104
+ align-items: center;
2105
+ justify-content: center;
2106
+ width: 36px;
2107
+ height: 36px;
2108
+ border-radius: 8px;
2109
+ border: none;
2110
+ background: none;
2111
+ cursor: pointer;
2112
+ color: ${e.authOnSurfaceVariant};
2113
+ transition: background 0.15s, color 0.15s;
2114
+ }
2115
+ .ss-auth-settings-back:hover {
2116
+ background: ${e.authSurfaceContainer};
2117
+ color: ${e.authOnSurface};
2118
+ }
2119
+ .ss-auth-settings-back .material-symbols-outlined { font-size: 22px; }
2120
+
2101
2121
  .ss-auth-settings-layout {
2102
2122
  display: flex;
2103
2123
  flex: 1;
@@ -2156,6 +2176,9 @@
2156
2176
  flex: 1;
2157
2177
  overflow-y: auto;
2158
2178
  padding: 32px;
2179
+ max-width: 720px;
2180
+ margin: 0 auto;
2181
+ width: 100%;
2159
2182
  }
2160
2183
 
2161
2184
  .ss-auth-settings-content h3 {
@@ -2331,4 +2354,4 @@
2331
2354
  .ss-auth-trigger-org-name { display: none; }
2332
2355
  .ss-auth-user-trigger { padding: 0; border: none; background: none; }
2333
2356
  }
2334
- `}function M({children:e,appearance:a}){const t=r.useRef(null),[o,n]=r.useState(null);r.useEffect(()=>{var g;if(!t.current||t.current.shadowRoot){n(((g=t.current)==null?void 0:g.shadowRoot)??null);return}const i=t.current.attachShadow({mode:"open"});if((a==null?void 0:a.fontUrl)!==null){const p=(a==null?void 0:a.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 m=document.createElement("link");m.rel="stylesheet",m.href=p,document.head.appendChild(m)}const x=document.createElement("link");x.rel="stylesheet",x.href=p,i.appendChild(x)}const c=Q(a),d=document.createElement("style");d.textContent=J(c),i.appendChild(d);const l=document.createElement("div");i.appendChild(l),n(i)},[]),r.useEffect(()=>{if(!o)return;const i=o.querySelector("style");if(i){const c=Q(a);i.textContent=J(c)}},[a,o]);const u=(o==null?void 0:o.querySelector("div"))??null;return s.jsx("div",{ref:t,style:{display:"contents"},children:u&&js.createPortal(e,u)})}function W(){const{client:e,user:a,isLoaded:t}=I();return{isLoaded:t,isSignedIn:!!a,user:a,signOut:r.useCallback(()=>e.auth.signOut(),[e]),getToken:r.useCallback(()=>e.auth.getToken(),[e]),refreshUser:r.useCallback(()=>e.auth.refreshUser(),[e])}}function $s(){const{user:e,isLoaded:a}=I();return{user:e,isLoaded:a}}function K(){const{client:e}=I(),[a,t]=r.useState(!1),[o,n]=r.useState(null),u=r.useCallback(async(d,l)=>{t(!0),n(null);try{return await e.auth.signIn(d,l)}catch(g){return n(g instanceof Error?g.message:"Sign in failed"),null}finally{t(!1)}},[e]),i=r.useCallback(async d=>{t(!0),n(null);try{return await e.auth.signInWithOAuth(d)}catch(l){return n(l instanceof Error?l.message:"OAuth sign in failed"),null}finally{t(!1)}},[e]),c=r.useCallback(async(d,l)=>{t(!0),n(null);try{return await e.auth.submitMfaCode(d,l)}catch(g){return n(g instanceof Error?g.message:"MFA verification failed"),null}finally{t(!1)}},[e]);return{signIn:u,signInWithOAuth:i,submitMfaCode:c,isLoading:a,error:o,setError:n}}function es(){const{client:e}=I(),[a,t]=r.useState(!1),[o,n]=r.useState(null);return{signUp:r.useCallback(async(i,c)=>{t(!0),n(null);try{return await e.auth.signUp(i,c)}catch(d){return n(d instanceof Error?d.message:"Sign up failed"),null}finally{t(!1)}},[e]),isLoading:a,error:o,setError:n}}function H(){const{client:e}=I(),[a,t]=r.useState([]),[o,n]=r.useState(null),[u,i]=r.useState([]),[c,d]=r.useState([]),[l,g]=r.useState(!1),[p,x]=r.useState(null),m=r.useCallback(async()=>{g(!0),x(null);try{const S=await e.auth.listOrgs();if(t(S),!o&&S.length>0){const f=typeof window<"u"?localStorage.getItem("ss_selected_org"):null,z=(f?S.find(B=>B.id===f):null)??(S.length===1?S[0]:null);if(z){n(z),typeof window<"u"&&localStorage.setItem("ss_selected_org",z.id);try{const B=await e.auth.listMembers(z.id);i(B)}catch{}}}}catch(S){x(S instanceof Error?S.message:"Failed to load organizations")}finally{g(!1)}},[e,o]);r.useEffect(()=>{m()},[m]);const j=r.useCallback(async S=>{try{const f=await e.auth.getOrg(S);n(f),typeof window<"u"&&localStorage.setItem("ss_selected_org",S);const w=await e.auth.listMembers(S);i(w)}catch(f){x(f instanceof Error?f.message:"Failed to load organization")}},[e]),b=r.useCallback(async(S,f)=>{try{const w=await e.auth.createOrg(S,f);return t(z=>[...z,w]),w}catch(w){return x(w instanceof Error?w.message:"Failed to create organization"),null}},[e]),C=r.useCallback(async(S,f)=>{try{const w=await e.auth.updateOrg(S,f);return t(z=>z.map(B=>B.id===S?w:B)),(o==null?void 0:o.id)===S&&n(w),w}catch(w){return x(w instanceof Error?w.message:"Failed to update organization"),null}},[e,o]),h=r.useCallback(async S=>{try{return await e.auth.deleteOrg(S),t(f=>f.filter(w=>w.id!==S)),(o==null?void 0:o.id)===S&&(n(null),i([]),d([]),typeof window<"u"&&localStorage.removeItem("ss_selected_org")),!0}catch(f){return x(f instanceof Error?f.message:"Failed to delete organization"),!1}},[e,o]),v=r.useCallback(async(S,f,w)=>{try{return await e.auth.sendInvite(S,f,w)}catch(z){return x(z instanceof Error?z.message:"Failed to send invite"),null}},[e]),N=r.useCallback(async S=>{try{const f=await e.auth.listInvites(S);d(f)}catch(f){x(f instanceof Error?f.message:"Failed to load invites")}},[e]),$=r.useCallback(async(S,f)=>{try{return await e.auth.revokeInvite(S,f),d(w=>w.filter(z=>z.id!==f)),!0}catch(w){return x(w instanceof Error?w.message:"Failed to revoke invite"),!1}},[e]),P=r.useCallback(async(S,f,w)=>{try{return await e.auth.updateMemberRole(S,f,w),i(z=>z.map(B=>B.userId===f?{...B,role:w}:B)),!0}catch(z){return x(z instanceof Error?z.message:"Failed to update member role"),!1}},[e]),O=r.useCallback(async(S,f)=>{try{return await e.auth.removeMember(S,f),i(w=>w.filter(z=>z.userId!==f)),!0}catch(w){return x(w instanceof Error?w.message:"Failed to remove member"),!1}},[e]),E=r.useCallback(async S=>{try{const f=await e.auth.listMembers(S);i(f)}catch(f){x(f instanceof Error?f.message:"Failed to load members")}},[e]);return{orgs:a,selectedOrg:o,members:u,invites:c,isLoading:l,error:p,setError:x,refresh:m,selectOrg:j,createOrg:b,updateOrg:C,deleteOrg:h,sendInvite:v,refreshInvites:N,revokeInvite:$,updateMemberRole:P,removeMember:O,refreshMembers:E}}function as(){const{client:e}=I(),[a,t]=r.useState(!1),[o,n]=r.useState(null);return{deleteAccount:r.useCallback(async()=>{t(!0),n(null);try{return await e.auth.deleteAccount(),!0}catch(i){return n(i instanceof Error?i.message:"Failed to delete account"),!1}finally{t(!1)}},[e]),isLoading:a,error:o,setError:n}}function X(){const{client:e,user:a}=I(),[t,o]=r.useState(!1),[n,u]=r.useState(null),[i,c]=r.useState(null),d=r.useCallback(async p=>{o(!0),u(null),c(null);try{const x=await e.auth.updateProfile(p);return c("Profile updated"),x}catch(x){return u(x instanceof Error?x.message:"Failed to update profile"),null}finally{o(!1)}},[e]),l=r.useCallback(async(p,x)=>{o(!0),u(null),c(null);try{return await e.auth.changePassword(p,x),c("Password changed successfully"),!0}catch(m){return u(m instanceof Error?m.message:"Failed to change password"),!1}finally{o(!1)}},[e]),g=r.useCallback(async p=>{o(!0),u(null),c(null);try{const x=await e.auth.uploadAvatar(p);return c("Avatar updated"),x}catch(x){return u(x instanceof Error?x.message:"Failed to upload avatar"),null}finally{o(!1)}},[e]);return{user:a,updateProfile:d,uploadAvatar:g,changePassword:l,isLoading:t,error:n,success:i,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>',y={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",settings:"settings",group:"group",creditCard:"credit_card",edit:"edit",send:"send",personRemove:"person_remove"};function Cs({appearance:e,signUpUrl:a,onSignUp:t}){const{appearance:o,settings:n}=I(),{signIn:u,signInWithOAuth:i,submitMfaCode:c,isLoading:d,error:l,setError:g}=K(),p=e??o,[x,m]=r.useState(""),[j,b]=r.useState(""),[C,h]=r.useState(!1),[v,N]=r.useState(!1),[$,P]=r.useState(""),[O,E]=r.useState(["","","","","",""]),S=r.useRef([]),f=r.useCallback(async L=>{if(L.preventDefault(),v){await c($,O.join(""));return}const k=await u(x,j);k&&U.isMfaRequired(k)&&(P(k.mfaToken),N(!0),g(null))},[x,j,v,$,O,u,c,g]),w=r.useCallback(async L=>{await i(L)},[i]),z=r.useCallback((L,k)=>{var V;if(!/^\d*$/.test(k))return;const F=k.slice(-1);E(G=>{const q=[...G];return q[L]=F,q}),F&&L<5&&((V=S.current[L+1])==null||V.focus())},[]),B=r.useCallback((L,k)=>{var F;k.key==="Backspace"&&!O[L]&&L>0&&((F=S.current[L-1])==null||F.focus())},[O]),T=(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:y.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"})]}),!v&&T&&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:()=>w("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:()=>w("github"),disabled:d,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:rs}}),"GitHub"]})]}),s.jsx("div",{className:"ss-auth-divider",children:"or continue with"})]}),l&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:l})]}),s.jsxs("form",{onSubmit:f,children:[v?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:O.map((L,k)=>s.jsx("input",{ref:F=>{S.current[k]=F},className:"ss-auth-mfa-digit",type:"text",inputMode:"numeric",maxLength:1,value:L,onChange:F=>z(k,F.target.value),onKeyDown:F=>B(k,F),autoFocus:k===0},k))}),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:x,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:C?"text":"password",autoComplete:"current-password",placeholder:"••••••••",value:j,onChange:L=>b(L.target.value),required:!0}),s.jsx("button",{type:"button",className:"ss-auth-visibility-toggle",onClick:()=>h(!C),children:s.jsx("span",{className:"material-symbols-outlined",children:C?y.visibilityOff:y.visibility})})]})]})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:d,children:[d&&s.jsx("span",{className:"ss-auth-spinner"}),v?"Verify":"Sign in",!d&&s.jsx("span",{className:"material-symbols-outlined",children:y.arrowForward})]})]}),v?s.jsx("div",{className:"ss-auth-footer",children:s.jsx("span",{className:"ss-auth-link",onClick:()=>{N(!1),E(["","","","","",""]),g(null)},children:"Back to sign in"})}):s.jsxs("div",{className:"ss-auth-footer",children:["Don't have an account?"," ",t?s.jsx("span",{className:"ss-auth-link",onClick:t,children:"Sign up"}):a?s.jsx("a",{className:"ss-auth-link",href:a,children:"Sign up"}):s.jsx("span",{className:"ss-auth-link",children:"Sign up"})]})]})})})}function zs({appearance:e,signInUrl:a,onSignIn:t}){const{appearance:o,settings:n}=I(),{signUp:u,isLoading:i,error:c,setError:d}=es(),{signInWithOAuth:l}=K(),g=e??o,[p,x]=r.useState(""),[m,j]=r.useState(""),[b,C]=r.useState(""),[h,v]=r.useState(!1),[N,$]=r.useState(null),P=r.useCallback(async f=>{if(f.preventDefault(),$(null),m!==b){$("Passwords do not match");return}const w=(n==null?void 0:n.passwordMinLength)??8;if(m.length<w){$(`Password must be at least ${w} characters`);return}await u(p,m)},[p,m,b,n,u]),O=r.useCallback(async f=>{await l(f)},[l]),E=(n==null?void 0:n.googleEnabled)||(n==null?void 0:n.githubEnabled),S=N||c;return s.jsx(M,{appearance:g,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:y.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:[E&&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:()=>O("google"),disabled:i,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:()=>O("github"),disabled:i,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:rs}}),"GitHub"]})]}),s.jsx("div",{className:"ss-auth-divider",children:"or sign up with email"})]}),S&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:S})]}),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=>x(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=>{j(f.target.value),$(null)},required:!0}),s.jsx("button",{type:"button",className:"ss-auth-visibility-toggle",onClick:()=>v(!h),children:s.jsx("span",{className:"material-symbols-outlined",children:h?y.visibilityOff:y.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=>{C(f.target.value),$(null)},required:!0})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:i,children:[i&&s.jsx("span",{className:"ss-auth-spinner"}),"Sign up",!i&&s.jsx("span",{className:"material-symbols-outlined",children:y.arrowForward})]})]}),s.jsxs("div",{className:"ss-auth-footer",children:["Already have an account?"," ",t?s.jsx("span",{className:"ss-auth-link",onClick:t,children:"Sign in"}):a?s.jsx("a",{className:"ss-auth-link",href:a,children:"Sign in"}):s.jsx("span",{className:"ss-auth-link",children:"Sign in"})]})]})})]})})}const D=320,R=128;function Ps({file:e,onCrop:a,onCancel:t}){const o=r.useRef(null),n=r.useRef(null),[u,i]=r.useState(1),[c,d]=r.useState({x:0,y:0}),[l,g]=r.useState(!1),p=r.useRef({x:0,y:0,ox:0,oy:0}),[x,m]=r.useState(!1);r.useEffect(()=>{const h=new Image,v=URL.createObjectURL(e);return h.onload=()=>{n.current=h,m(!0),d({x:0,y:0}),i(1)},h.src=v,()=>URL.revokeObjectURL(v)},[e]),r.useEffect(()=>{if(!x||!n.current||!o.current)return;const h=o.current.getContext("2d");if(!h)return;const v=n.current;h.clearRect(0,0,D,D),h.fillStyle="#111",h.fillRect(0,0,D,D);const N=Math.max(D/v.width,D/v.height)*u,$=v.width*N,P=v.height*N,O=(D-$)/2+c.x,E=(D-P)/2+c.y;h.save(),h.beginPath(),h.arc(D/2,D/2,R,0,Math.PI*2),h.clip(),h.drawImage(v,O,E,$,P),h.restore(),h.save(),h.fillStyle="rgba(0, 0, 0, 0.6)",h.fillRect(0,0,D,D),h.globalCompositeOperation="destination-out",h.beginPath(),h.arc(D/2,D/2,R,0,Math.PI*2),h.fill(),h.restore(),h.save(),h.beginPath(),h.arc(D/2,D/2,R,0,Math.PI*2),h.clip(),h.drawImage(v,O,E,$,P),h.restore(),h.strokeStyle="rgba(255, 255, 255, 0.4)",h.lineWidth=2,h.beginPath(),h.arc(D/2,D/2,R,0,Math.PI*2),h.stroke()},[u,c,x]);const j=r.useCallback(h=>{g(!0),p.current={x:h.clientX,y:h.clientY,ox:c.x,oy:c.y},h.target.setPointerCapture(h.pointerId)},[c]),b=r.useCallback(h=>{l&&d({x:p.current.ox+(h.clientX-p.current.x),y:p.current.oy+(h.clientY-p.current.y)})},[l]),C=r.useCallback(()=>g(!1),[]);return r.useCallback(()=>{if(!n.current)return;const h=document.createElement("canvas"),v=R*2;h.width=v,h.height=v;const N=h.getContext("2d");if(!N)return;const $=n.current,P=Math.max(D/$.width,D/$.height)*u,O=$.width*P,E=$.height*P,S=(D-O)/2+c.x-(D/2-R),f=(D-E)/2+c.y-(D/2-R);N.beginPath(),N.arc(R,R,R,0,Math.PI*2),N.clip(),N.drawImage($,S,f,O,E),h.toBlob(w=>{w&&a(w)},"image/png")},[u,c,a]),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:D,height:D,style:{cursor:l?"grabbing":"grab",width:"100%",height:"100%"},onPointerDown:j,onPointerMove:b,onPointerUp:C}),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:y.zoomOut}),s.jsx("input",{type:"range",min:"1",max:"3",step:"0.01",value:u,onChange:h=>i(parseFloat(h.target.value)),className:"ss-auth-zoom-slider"}),s.jsx("span",{className:"material-symbols-outlined",children:y.zoomIn})]})]})}function ns({onUpload:e,onClose:a,isLoading:t}){const[o,n]=r.useState(null),[u,i]=r.useState(!1),[c,d]=r.useState(null),l=r.useRef(null),g=r.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=r.useCallback(m=>{m.preventDefault(),i(!1);const j=m.dataTransfer.files[0];j&&g(j)},[g]),x=r.useCallback(async m=>{await e(m)},[e]);return s.jsx("div",{className:"ss-auth-modal-overlay",onClick:m=>{m.target===m.currentTarget&&a()},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:a,children:s.jsx("span",{className:"material-symbols-outlined",children:y.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:y.errorOutline}),s.jsx("span",{children:c})]}),s.jsxs("div",{className:"ss-auth-upload-grid",children:[s.jsx("div",{children:o?s.jsx(Ps,{file:o,onCrop:x,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:y.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(),i(!0)},onDragLeave:()=>i(!1),onDrop:p,onClick:()=>{var m;return(m=l.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:y.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:l,type:"file",accept:"image/*",style:{display:"none"},onChange:m=>{var j;(j=m.target.files)!=null&&j[0]&&g(m.target.files[0])}})]}),s.jsxs("div",{className:"ss-auth-info-box",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.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:a,children:"Cancel"}),s.jsxs("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",onClick:()=>{},disabled:!o||t,style:{width:"auto"},children:[t&&s.jsx("span",{className:"ss-auth-spinner"}),"Save Profile",!t&&s.jsx("span",{className:"material-symbols-outlined",children:y.check})]})]})]})})}function os({onClose:e,afterDeleteAccountUrl:a,defaultTab:t="profile"}){const[o,n]=r.useState(t),u=[{key:"profile",label:"Profile",icon:y.person},{key:"organization",label:"Organization",icon:y.corporateFare},{key:"people",label:"People",icon:y.group},{key:"billing",label:"Billing",icon:y.creditCard}];return s.jsxs("div",{className:"ss-auth-settings-page",children:[s.jsxs("div",{className:"ss-auth-settings-header",children:[s.jsx("h2",{children:"Settings"}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:e,children:s.jsx("span",{className:"material-symbols-outlined",children:y.close})})]}),s.jsxs("div",{className:"ss-auth-settings-layout",children:[s.jsx("nav",{className:"ss-auth-settings-nav",children:u.map(i=>s.jsxs("button",{type:"button",className:`ss-auth-settings-nav-item${o===i.key?" ss-auth-settings-nav-item-active":""}`,onClick:()=>n(i.key),children:[s.jsx("span",{className:"material-symbols-outlined",children:i.icon}),i.label]},i.key))}),s.jsxs("div",{className:"ss-auth-settings-content",children:[o==="profile"&&s.jsx(Os,{afterDeleteAccountUrl:a}),o==="organization"&&s.jsx(Es,{}),o==="people"&&s.jsx(Is,{}),o==="billing"&&s.jsx(Fs,{})]})]})]})}function Os({afterDeleteAccountUrl:e}){const{user:a,updateProfile:t,uploadAvatar:o,changePassword:n,isLoading:u,error:i,success:c,setError:d,setSuccess:l}=X(),{signOut:g}=W(),{deleteAccount:p,isLoading:x,error:m,setError:j}=as(),[b,C]=r.useState((a==null?void 0:a.name)??""),[h,v]=r.useState((a==null?void 0:a.avatarUrl)??""),[N,$]=r.useState(!1),[P,O]=r.useState(""),[E,S]=r.useState(""),[f,w]=r.useState(""),[z,B]=r.useState(null),[T,L]=r.useState(!1),[k,F]=r.useState(""),V=r.useCallback(async A=>{A.preventDefault(),d(null),l(null),await t({name:b,avatarUrl:h||void 0})},[b,h,t,d,l]),G=r.useCallback(async A=>{const Y=await o(A);Y&&(v(Y.avatarUrl),$(!1))},[o]),q=r.useCallback(async A=>{if(A.preventDefault(),B(null),d(null),l(null),E!==f){B("Passwords do not match");return}if(E.length<8){B("Password must be at least 8 characters");return}await n(P,E)&&(O(""),S(""),w(""))},[P,E,f,n,d,l]),ms=r.useCallback(async()=>{await p()&&(await g(),e&&(window.location.href=e))},[p,g,e]),fs=(a==null?void 0:a.provider)==="email",bs=k===(a==null?void 0:a.email),ys=((a==null?void 0:a.name)||(a==null?void 0:a.email)||"?").charAt(0).toUpperCase();return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Profile"}),s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("div",{className:"ss-auth-profile-header",style:{border:"none",background:"none",padding:0,marginBottom:16},children:[s.jsxs("div",{className:"ss-auth-avatar-lg",onClick:()=>$(!0),children:[h?s.jsx("img",{src:h,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:y.camera}),s.jsx("span",{children:"Edit"})]})]}),s.jsxs("div",{className:"ss-auth-profile-info",children:[s.jsxs("h2",{className:"ss-auth-profile-name",children:[(a==null?void 0:a.name)||"Unnamed User",(a==null?void 0:a.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:y.verified}),"Verified"]})]}),s.jsx("p",{className:"ss-auth-profile-desc",children:a==null?void 0:a.email})]})]}),i&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:i})]}),c&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.check}),s.jsx("span",{children:c})]}),s.jsxs("form",{onSubmit:V,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:b,onChange:A=>C(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:(a==null?void 0:a.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:y.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:(a==null?void 0:a.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:u,style:{width:"auto"},children:[u&&s.jsx("span",{className:"ss-auth-spinner"}),"Save changes"]})})]})]}),fs&&s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("h4",{children:[s.jsx("span",{className:"material-symbols-outlined",children:y.security}),"Security Credentials"]}),z&&s.jsxs("div",{className:"ss-auth-error",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:z})]}),s.jsxs("form",{onSubmit:q,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:P,onChange:A=>O(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:E,onChange:A=>S(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:f,onChange:A=>w(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:u,children:"Update Security"})})]})]}),s.jsxs("div",{className:"ss-auth-settings-card ss-auth-settings-danger",children:[s.jsx("h4",{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."}),m&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:m})]}),T?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:a==null?void 0:a.email,value:k,onChange:A=>F(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:()=>{L(!1),F(""),j(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||x,onClick:ms,children:[x&&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:()=>L(!0),children:"Delete my account"})]}),N&&s.jsx(ns,{onUpload:G,onClose:()=>$(!1),isLoading:u})]})}function Es(){const{selectedOrg:e,updateOrg:a,deleteOrg:t,isLoading:o,error:n,setError:u}=H(),[i,c]=r.useState((e==null?void 0:e.name)??""),[d,l]=r.useState(!1),[g,p]=r.useState(!1),[x,m]=r.useState(!1),[j,b]=r.useState("");if(r.useEffect(()=>{e&&c(e.name)},[e]),!e)return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Organization"}),s.jsxs("div",{className:"ss-auth-settings-empty",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.corporateFare}),s.jsx("div",{children:"Select an organization from the user menu to manage its settings."})]})]});const C=async v=>{if(v.preventDefault(),!i.trim())return;l(!0),p(!1);const N=await a(e.id,{name:i.trim()});l(!1),N&&p(!0)},h=async()=>{await t(e.id)&&m(!1)};return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Organization"}),s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("h4",{children:[s.jsx("span",{className:"material-symbols-outlined",children:y.corporateFare}),"General"]}),n&&s.jsxs("div",{className:"ss-auth-error",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:n})]}),g&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.check}),s.jsx("span",{children:"Organization updated"})]}),s.jsxs("form",{onSubmit:C,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Organization Name"}),s.jsx("input",{className:"ss-auth-input",type:"text",value:i,onChange:v=>{c(v.target.value),p(!1)}})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Slug"}),s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"text",value:e.slug,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:d,style:{width:"auto"},children:[d&&s.jsx("span",{className:"ss-auth-spinner"}),"Save"]})})]})]}),s.jsxs("div",{className:"ss-auth-settings-card ss-auth-settings-danger",children:[s.jsx("h4",{children:"Danger Zone"}),s.jsx("p",{className:"ss-auth-section-desc",style:{marginBottom:"16px"},children:"Deleting this organization is permanent and will remove all members."}),x?s.jsxs("div",{children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Type the organization name to confirm"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:e.name,value:j,onChange:v=>b(v.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:()=>{m(!1),b("")},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:j!==e.name||o,onClick:h,children:[o&&s.jsx("span",{className:"ss-auth-spinner"}),"Delete organization"]})]})]}):s.jsx("button",{type:"button",className:"ss-auth-btn-outline",style:{borderColor:"currentColor",width:"auto"},onClick:()=>m(!0),children:"Delete this organization"})]})]})}function Is(){const{selectedOrg:e,members:a,invites:t,isLoading:o,error:n,setError:u,sendInvite:i,refreshInvites:c,revokeInvite:d,updateMemberRole:l,removeMember:g,refreshMembers:p}=H(),[x,m]=r.useState(""),[j,b]=r.useState("member"),[C,h]=r.useState(!1),[v,N]=r.useState(!1),[$,P]=r.useState(null),[O,E]=r.useState(""),[S,f]=r.useState(null);if(r.useEffect(()=>{e&&(p(e.id),c(e.id))},[e,p,c]),!e)return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"People"}),s.jsxs("div",{className:"ss-auth-settings-empty",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.group}),s.jsx("div",{children:"Select an organization from the user menu to manage members."})]})]});const w=async k=>{k.preventDefault(),N(!1),await i(e.id,x,j)&&(m(""),b("member"),N(!0),h(!1),c(e.id))},z=async()=>{if(!$)return;await l(e.id,$.userId,O)&&P(null)},B=async()=>{if(!S)return;await g(e.id,S.userId)&&f(null)},T=async k=>{await d(e.id,k)},L=k=>k==="owner"?"ss-auth-role-badge ss-auth-role-badge-owner":k==="admin"?"ss-auth-role-badge ss-auth-role-badge-admin":"ss-auth-role-badge ss-auth-role-badge-member";return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"People"}),n&&s.jsxs("div",{className:"ss-auth-error",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:n})]}),v&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.check}),s.jsx("span",{children:"Invitation sent"})]}),s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[s.jsxs("h4",{style:{margin:0},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.group}),"Members"]}),s.jsxs("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",style:{width:"auto"},onClick:()=>h(!C),children:[s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"16px"},children:y.add}),"Invite"]})]}),C&&s.jsx("form",{onSubmit:w,style:{marginBottom:"16px",padding:"16px",background:"rgba(0,0,0,0.05)",borderRadius:"8px"},children:s.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[s.jsxs("div",{style:{flex:1},children:[s.jsx("label",{className:"ss-auth-label",children:"Email"}),s.jsx("input",{className:"ss-auth-input",type:"email",placeholder:"member@example.com",value:x,onChange:k=>m(k.target.value),required:!0})]}),s.jsxs("div",{style:{width:"120px"},children:[s.jsx("label",{className:"ss-auth-label",children:"Role"}),s.jsxs("select",{className:"ss-auth-input",value:j,onChange:k=>b(k.target.value),style:{cursor:"pointer"},children:[s.jsx("option",{value:"admin",children:"Admin"}),s.jsx("option",{value:"member",children:"Member"})]})]}),s.jsx("button",{type:"submit",className:"ss-auth-btn-primary ss-auth-btn-sm",disabled:o,style:{width:"auto",marginBottom:"0"},children:"Send"})]})}),a.length===0?s.jsx("div",{className:"ss-auth-settings-empty",style:{padding:"20px"},children:s.jsx("div",{children:"No members yet."})}):s.jsxs("table",{className:"ss-auth-settings-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Email"}),s.jsx("th",{children:"Role"}),s.jsx("th",{style:{width:"80px"},children:"Actions"})]})}),s.jsx("tbody",{children:a.map(k=>s.jsxs("tr",{children:[s.jsx("td",{children:k.email}),s.jsx("td",{children:s.jsx("span",{className:L(k.role),children:k.role})}),s.jsx("td",{children:k.role==="owner"?s.jsx("span",{style:{fontSize:"12px",opacity:.4},children:"—"}):s.jsxs("div",{className:"ss-auth-settings-actions",children:[s.jsx("button",{type:"button",className:"ss-auth-icon-btn",title:"Edit role",onClick:()=>{P(k),E(k.role)},children:s.jsx("span",{className:"material-symbols-outlined",children:y.edit})}),s.jsx("button",{type:"button",className:"ss-auth-icon-btn ss-auth-icon-btn-danger",title:"Remove member",onClick:()=>f(k),children:s.jsx("span",{className:"material-symbols-outlined",children:y.personRemove})})]})})]},k.userId))})]})]}),t.length>0&&s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("h4",{children:[s.jsx("span",{className:"material-symbols-outlined",children:y.send}),"Pending Invites"]}),s.jsxs("table",{className:"ss-auth-settings-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Email"}),s.jsx("th",{children:"Role"}),s.jsx("th",{style:{width:"80px"},children:"Actions"})]})}),s.jsx("tbody",{children:t.map(k=>s.jsxs("tr",{children:[s.jsx("td",{children:k.email}),s.jsx("td",{children:s.jsx("span",{className:L(k.role),children:k.role})}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"ss-auth-icon-btn ss-auth-icon-btn-danger",title:"Revoke invite",onClick:()=>T(k.id),children:s.jsx("span",{className:"material-symbols-outlined",children:y.close})})})]},k.id))})]})]}),$&&s.jsx("div",{className:"ss-auth-modal-overlay",onClick:k=>{k.target===k.currentTarget&&P(null)},children:s.jsxs("div",{className:"ss-auth-modal",style:{maxWidth:"400px"},children:[s.jsxs("div",{className:"ss-auth-modal-header",children:[s.jsx("h2",{children:"Edit Role"}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:()=>P(null),children:s.jsx("span",{className:"material-symbols-outlined",children:y.close})})]}),s.jsxs("div",{className:"ss-auth-modal-body",children:[s.jsxs("p",{style:{fontSize:"14px",marginBottom:"16px",margin:"0 0 16px 0"},children:["Change role for ",s.jsx("strong",{children:$.email})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Role"}),s.jsxs("select",{className:"ss-auth-input",value:O,onChange:k=>E(k.target.value),style:{cursor:"pointer"},children:[s.jsx("option",{value:"admin",children:"Admin"}),s.jsx("option",{value:"member",children:"Member"})]})]}),s.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[s.jsx("button",{type:"button",className:"ss-auth-btn-ghost",onClick:()=>P(null),children:"Cancel"}),s.jsx("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",style:{width:"auto"},onClick:z,children:"Save"})]})]})]})}),S&&s.jsx("div",{className:"ss-auth-modal-overlay",onClick:k=>{k.target===k.currentTarget&&f(null)},children:s.jsxs("div",{className:"ss-auth-modal",style:{maxWidth:"400px"},children:[s.jsxs("div",{className:"ss-auth-modal-header",children:[s.jsx("h2",{children:"Remove Member"}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:()=>f(null),children:s.jsx("span",{className:"material-symbols-outlined",children:y.close})})]}),s.jsxs("div",{className:"ss-auth-modal-body",children:[s.jsxs("p",{style:{fontSize:"14px",margin:"0 0 16px 0"},children:["Are you sure you want to remove ",s.jsx("strong",{children:S.email})," from the organization?"]}),s.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[s.jsx("button",{type:"button",className:"ss-auth-btn-ghost",onClick:()=>f(null),children:"Cancel"}),s.jsx("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",style:{width:"auto",background:"linear-gradient(135deg, #ef4444, #dc2626)"},onClick:B,children:"Remove"})]})]})]})})]})}function Fs(){const{selectedOrg:e}=H();return e?s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Billing"}),s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("h4",{children:[s.jsx("span",{className:"material-symbols-outlined",children:y.creditCard}),"Plan & Billing"]}),s.jsx("div",{className:"ss-auth-settings-empty",style:{padding:"20px"},children:s.jsx("div",{children:"No billing plan configured for this organization."})})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Billing"}),s.jsxs("div",{className:"ss-auth-settings-empty",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.creditCard}),s.jsx("div",{children:"Select an organization from the user menu to manage billing."})]})]})}function Bs({appearance:e,afterSignOutUrl:a,afterDeleteAccountUrl:t,showOrgSwitcher:o=!0,onOrgChange:n,onOrgSettingsClick:u}){const{appearance:i}=I(),{user:c,signOut:d}=W(),l=e??i,[g,p]=r.useState(!1),[x,m]=r.useState(!1),[j,b]=r.useState(""),[C,h]=r.useState(null),[v,N]=r.useState(!1),$=r.useRef(null),{orgs:P,selectedOrg:O,selectOrg:E,createOrg:S}=H(),f=r.useCallback(z=>{$.current&&!z.composedPath().includes($.current)&&p(!1)},[]);r.useEffect(()=>{if(g){const z=setTimeout(()=>{document.addEventListener("click",f)},0);return()=>{clearTimeout(z),document.removeEventListener("click",f)}}},[g,f]);const w=r.useCallback(async z=>{z.preventDefault(),h(null),N(!0);const B=j.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");try{const T=await S(j,B);T&&(await E(T.id),n==null||n(T),b(""),p(!1))}catch(T){h(T instanceof Error?T.message:"Failed to create organization")}finally{N(!1)}},[j,S,E,n]);return c?s.jsx(M,{appearance:l,children:s.jsxs("div",{style:{position:"relative",display:"inline-block"},ref:$,children:[s.jsxs("button",{type:"button",className:"ss-auth-user-trigger",onClick:()=>p(!g),"aria-label":"User menu",children:[s.jsx("span",{className:"ss-auth-avatar-trigger",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()})}),O&&s.jsx("span",{className:"ss-auth-trigger-org-name",children:O.name})]}),g&&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:y.settings}),"Settings"]})}),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(z=>{const B=(O==null?void 0:O.id)===z.id,T=z.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 E(z.id),n==null||n(z)},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:T}),s.jsx("span",{style:{fontFamily:"'Manrope', sans-serif",letterSpacing:"-0.01em"},children:z.name}),z.planName&&s.jsx("span",{className:"ss-auth-plan-badge",children:z.planName})]}),B&&s.jsx("span",{className:"material-symbols-outlined ss-auth-org-check",style:{fontSize:"18px"},children:y.checkCircle})]},z.id)})}),s.jsxs("div",{className:"ss-auth-inline-create",children:[C&&s.jsx("div",{className:"ss-auth-error",style:{marginBottom:"8px",fontSize:"12px"},children:s.jsx("span",{children:C})}),s.jsx("form",{onSubmit:w,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:j,onChange:z=>b(z.target.value),required:!0,style:{fontSize:"13px",padding:"10px 40px 10px 12px"}}),s.jsx("button",{type:"submit",className:"ss-auth-inline-create-btn",disabled:v||!j.trim(),children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"20px"},children:y.add})})]})})]}),O&&u&&s.jsx("div",{style:{padding:"0 8px 4px"},children:s.jsxs("button",{type:"button",className:"ss-auth-dropdown-action",onClick:()=>{p(!1),u(O)},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.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(),a&&(window.location.href=a)},style:{color:"inherit"},children:[s.jsx("span",{className:"material-symbols-outlined",style:{color:"inherit"},children:y.logout}),"Sign out"]})})]}),x&&s.jsx(os,{onClose:()=>m(!1),afterDeleteAccountUrl:t})]})}):null}function Ls({appearance:e}){const{appearance:a}=I(),{user:t,signOut:o}=W(),{updateProfile:n,uploadAvatar:u,changePassword:i,isLoading:c,error:d,success:l,setError:g,setSuccess:p}=X(),x=e??a,[m,j]=r.useState((t==null?void 0:t.name)??""),[b,C]=r.useState((t==null?void 0:t.avatarUrl)??""),[h,v]=r.useState(!1),[N,$]=r.useState(""),[P,O]=r.useState(""),[E,S]=r.useState(""),[f,w]=r.useState(null),z=r.useCallback(async F=>{F.preventDefault(),g(null),p(null),await n({name:m,avatarUrl:b||void 0})},[m,b,n,g,p]),B=r.useCallback(async F=>{const V=await u(F);V&&(C(V.avatarUrl),v(!1))},[u]),T=r.useCallback(async F=>{if(F.preventDefault(),w(null),g(null),p(null),P!==E){w("Passwords do not match");return}if(P.length<8){w("Password must be at least 8 characters");return}await i(N,P)&&($(""),O(""),S(""))},[N,P,E,i,g,p]);if(!t)return null;const L=t.provider==="email",k=(t.name||t.email).charAt(0).toUpperCase();return s.jsx(M,{appearance:x,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:()=>v(!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:k}),s.jsxs("div",{className:"ss-auth-avatar-overlay",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.camera}),s.jsx("span",{children:"Edit"})]})]}),s.jsxs("div",{className:"ss-auth-profile-info",children:[s.jsxs("h2",{className:"ss-auth-profile-name",children:[t.name||"Unnamed User",t.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:y.verified}),"Verified"]})]}),s.jsx("p",{className:"ss-auth-profile-desc",children:t.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:y.errorOutline}),s.jsx("span",{children:d})]}),l&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.check}),s.jsx("span",{children:l})]}),s.jsxs("form",{onSubmit:z,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:F=>j(F.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:t.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:y.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:t.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:y.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:y.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:y.errorOutline}),s.jsx("span",{children:f})]}),s.jsxs("form",{onSubmit:T,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:N,onChange:F=>$(F.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:F=>O(F.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:E,onChange:F=>S(F.target.value),required:!0})]})]}),s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.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:y.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:()=>v(!1),isLoading:c})]})})}function Ds({appearance:e,onOrgChange:a}){const{appearance:t}=I(),{orgs:o,selectedOrg:n,selectOrg:u,createOrg:i,isLoading:c}=H(),d=e??t,[l,g]=r.useState(!1),[p,x]=r.useState(""),[m,j]=r.useState(""),[b,C]=r.useState(null),[h,v]=r.useState(!1),N=r.useRef(null),$=r.useCallback(f=>{N.current&&!f.composedPath().includes(N.current)&&g(!1)},[]);r.useEffect(()=>{if(l){const f=setTimeout(()=>{document.addEventListener("click",$)},0);return()=>{clearTimeout(f),document.removeEventListener("click",$)}}},[l,$]);const P=r.useCallback(f=>{x(f),j(f.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},[]),O=r.useCallback(async f=>{f.preventDefault(),C(null),v(!0);try{const w=await i(p,m);w&&(await u(w.id),a==null||a(w),x(""),j(""),g(!1))}catch(w){C(w instanceof Error?w.message:"Failed to create organization")}finally{v(!1)}},[p,m,i,u,a]);if(c)return null;const E=(n==null?void 0:n.name)??(o.length===0?"No organization":"Select organization"),S=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:N,children:[s.jsxs("button",{type:"button",className:"ss-auth-org-trigger",onClick:()=>g(!l),children:[s.jsxs("div",{className:"ss-auth-org-trigger-inner",children:[s.jsx("div",{className:"ss-auth-org-avatar",children:S}),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:E})]})]}),s.jsx("span",{className:"material-symbols-outlined",children:y.unfoldMore})]}),l&&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 w=(n==null?void 0:n.id)===f.id,z=f.name.split(" ").map(B=>B[0]).join("").slice(0,2).toUpperCase();return s.jsxs("button",{type:"button",className:`ss-auth-org-item${w?" ss-auth-org-item-active":""}`,onClick:async()=>{g(!1),await u(f.id),a==null||a(f)},children:[s.jsxs("div",{className:"ss-auth-org-item-inner",children:[s.jsx("div",{className:`ss-auth-org-avatar${w?"":" ss-auth-org-avatar-inactive"}`,children:z}),s.jsx("span",{style:{fontFamily:"'Manrope', sans-serif",letterSpacing:"-0.01em"},children:f.name})]}),w&&s.jsx("span",{className:"material-symbols-outlined ss-auth-org-check",style:{fontSize:"18px"},children:y.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:y.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:O,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=>j(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 Ts(e,a="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:a,minimumFractionDigits:e%100===0?0:2}).format(e/100)}function As({plans:e,currentPlanId:a,onSelectPlan:t,interval:o,appearance:n}){const{appearance:u}=I(),i=n??u,c=o?e.filter(d=>d.interval===o||d.isFree):e;return s.jsx(M,{appearance:i,children:s.jsx("div",{className:"ss-pricing-grid",children:c.map(d=>{const l=d.id===a;return s.jsxs("div",{className:`ss-pricing-card ${l?"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:Ts(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((g,p)=>s.jsxs("li",{className:"ss-pricing-feature",children:[s.jsx("span",{className:"ss-check",children:"✓"})," ",g]},p))}),s.jsx("button",{type:"button",className:`ss-btn ${l?"ss-btn-current":"ss-btn-primary"}`,disabled:l,onClick:()=>t(d.id),children:l?"Current plan":"Select plan"})]},d.id)})})})}function Ms(){const{client:e}=I();return{billing:e.billing}}function _(e){const{client:a}=I();return r.useMemo(()=>{if(e){const t=new U.Transport("https://api.saas-support.com/v1",{type:"portalToken",token:e});return new U.BillingClient(t)}return a.billing},[a,e])}function is(e,a){const t=_(a),[o,n]=r.useState(null),[u,i]=r.useState(!0),[c,d]=r.useState(null),l=r.useCallback(async()=>{i(!0),d(null);try{const g=await t.getCustomer(e);n(g)}catch(g){d(g instanceof Error?g.message:"Failed to load subscription")}finally{i(!1)}},[t,e]);return r.useEffect(()=>{l()},[l]),{customer:o,isLoading:u,error:c,refresh:l}}function ls(e,a){const t=_(a),[o,n]=r.useState([]),[u,i]=r.useState(!0),[c,d]=r.useState(null),l=r.useCallback(async()=>{i(!0),d(null);try{const g=await t.getInvoices(e);n(g)}catch(g){d(g instanceof Error?g.message:"Failed to load invoices")}finally{i(!1)}},[t,e]);return r.useEffect(()=>{l()},[l]),{invoices:o,isLoading:u,error:c,refresh:l}}function cs(e,a){const t=_(a),[o,n]=r.useState([]),[u,i]=r.useState(!0),[c,d]=r.useState(null),l=r.useCallback(async()=>{i(!0),d(null);try{const g=await t.getCurrentUsage(e);n(g)}catch(g){d(g instanceof Error?g.message:"Failed to load usage")}finally{i(!1)}},[t,e]);return r.useEffect(()=>{l()},[l]),{usage:o,isLoading:u,error:c,refresh:l}}const Us={active:"ss-badge-active"};function ds({customerId:e,portalToken:a,onChangePlan:t,onCancel:o,appearance:n}){const{appearance:u}=I(),{customer:i,isLoading:c,error:d}=is(e,a),l=n??u;return s.jsx(M,{appearance:l,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}),i&&!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:i.name||i.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 ${Us.active}`,children:"Active"})})]}),s.jsxs("div",{className:"ss-btn-group",children:[t&&s.jsx("button",{type:"button",className:"ss-btn ss-btn-primary",onClick:t,children:"Change plan"}),o&&s.jsx("button",{type:"button",className:"ss-btn ss-btn-danger",onClick:o,children:"Cancel subscription"})]})]})]})})}const Rs={paid:"ss-badge-active",open:"ss-badge-trialing",draft:"ss-badge-paused",void:"ss-badge-canceled",uncollectible:"ss-badge-past-due"};function Vs(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Hs(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(e/100)}function us({customerId:e,portalToken:a,appearance:t}){const{appearance:o}=I(),{invoices:n,isLoading:u,error:i}=ls(e,a),c=t??o,d=[...n].sort((l,g)=>new Date(g.createdAt).getTime()-new Date(l.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..."]}),i&&s.jsx("div",{className:"ss-global-error",children:i}),!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(l=>s.jsxs("tr",{className:"ss-tr",children:[s.jsx("td",{className:"ss-td",children:Vs(l.createdAt)}),s.jsx("td",{className:"ss-td",children:Hs(l.amountCents)}),s.jsx("td",{className:"ss-td",children:s.jsx("span",{className:`ss-badge ${Rs[l.status]||""}`,children:l.status})}),s.jsx("td",{className:"ss-td",children:l.pdfUrl?s.jsx("a",{className:"ss-link",href:l.pdfUrl,target:"_blank",rel:"noopener noreferrer",children:"Download"}):"—"})]},l.id))})]})]})})}function ps({customerId:e,limits:a,portalToken:t,appearance:o}){const{appearance:n}=I(),{usage:u,isLoading:i,error:c}=cs(e,t),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"}),i&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),c&&s.jsx("div",{className:"ss-global-error",children:c}),!i&&u.length===0&&s.jsx("p",{className:"ss-empty",children:"No usage data."}),!i&&u.map(l=>{const g=a==null?void 0:a[l.metric],p=g?Math.min(100,l.total/g*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:l.metric}),s.jsxs("span",{className:"ss-usage-value",children:[l.total.toLocaleString(),g?` / ${g.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}%`}})})]},l.metric)})]})})}function qs({customerId:e,portalToken:a,limits:t,onChangePlan:o,onCancel:n,appearance:u}){const{appearance:i}=I(),c=u??i,[d,l]=r.useState("subscription"),g=[{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:g.map(p=>s.jsx("button",{type:"button",className:`ss-tab ${d===p.id?"ss-tab-active":""}`,onClick:()=>l(p.id),children:p.label},p.id))}),s.jsxs("div",{className:"ss-tab-content",children:[d==="subscription"&&s.jsx(ds,{customerId:e,portalToken:a,onChangePlan:o,onCancel:n}),d==="invoices"&&s.jsx(us,{customerId:e,portalToken:a}),d==="usage"&&s.jsx(ps,{customerId:e,portalToken:a,limits:t})]})]})})}function Ws({customerId:e,portalToken:a,onApplied:t,appearance:o}){const{appearance:n}=I(),u=_(a),i=o??n,[c,d]=r.useState(""),[l,g]=r.useState(!1),[p,x]=r.useState(null),[m,j]=r.useState(null),b=r.useCallback(async C=>{if(C.preventDefault(),!!c.trim()){g(!0),x(null),j(null);try{const h=await u.applyCoupon(e,c.trim());j(`Coupon applied! ${h.discountType==="percent"?`${h.amount}% off`:`$${(h.amount/100).toFixed(2)} off`}`),d(""),t==null||t(h)}catch(h){x(h instanceof Error?h.message:"Invalid coupon code")}finally{g(!1)}}},[u,e,c,t]);return s.jsx(M,{appearance:i,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:C=>d(C.target.value),required:!0})]}),s.jsxs("button",{type:"submit",className:"ss-btn ss-btn-primary",disabled:l||!c.trim(),children:[l&&s.jsx("span",{className:"ss-spinner"}),"Apply"]})]})]})})}function _s(){const{client:e}=I();return{report:e.report}}function ss(){const{client:e}=I(),[a,t]=r.useState(null),[o,n]=r.useState(!1),[u,i]=r.useState(null),c=r.useCallback(async d=>{n(!0),i(null);try{const l=await e.report.executeQuery(d);return t(l),l}catch(l){return i(l instanceof Error?l.message:"Query failed"),null}finally{n(!1)}},[e]);return{result:a,execute:c,isLoading:o,error:u}}function hs(e){const{client:a}=I(),[t,o]=r.useState(null),[n,u]=r.useState(!0),[i,c]=r.useState(null),d=r.useCallback(async()=>{u(!0),c(null);try{const l=await a.report.listQueries(e);o(l)}catch(l){c(l instanceof Error?l.message:"Failed to load queries")}finally{u(!1)}},[a,e]);return r.useEffect(()=>{d()},[d]),{queries:(t==null?void 0:t.data)??[],meta:t==null?void 0:t.meta,isLoading:n,error:i,refresh:d}}function Gs(e){const{client:a}=I(),[t,o]=r.useState(null),[n,u]=r.useState(!0),[i,c]=r.useState(null),d=r.useCallback(async()=>{u(!0),c(null);try{const l=await a.report.getDashboard(e);o(l)}catch(l){c(l instanceof Error?l.message:"Failed to load dashboard")}finally{u(!1)}},[a,e]);return r.useEffect(()=>{d()},[d]),{dashboard:t,isLoading:n,error:i,refresh:d}}function Ys(e,a,t="https://api.saas-support.com/v1"){const o=r.useMemo(()=>{const p=new U.Transport(t,{type:"embedToken",token:e});return new U.ReportClient(p)},[e,t]),[n,u]=r.useState(null),[i,c]=r.useState(!0),[d,l]=r.useState(null),g=r.useCallback(async()=>{c(!0),l(null);try{const p=await o.getDashboard(a);u(p)}catch(p){l(p instanceof Error?p.message:"Failed to load dashboard")}finally{c(!1)}},[o,a]);return r.useEffect(()=>{g()},[g]),{dashboard:n,reportClient:o,isLoading:i,error:d,refresh:g}}function Qs({onResult:e,mode:a="both",placeholder:t,appearance:o}){const{appearance:n}=I(),{execute:u,isLoading:i,error:c}=ss(),d=o??n,[l,g]=r.useState(""),[p,x]=r.useState(a==="sql"?"sql":"nl"),m=r.useCallback(async j=>{if(j.preventDefault(),!l.trim())return;const C=await u(p==="sql"?{sql:l}:{naturalLanguage:l});C&&(e==null||e(C))},[l,p,u,e]);return s.jsx(M,{appearance:d,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[a==="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:()=>x("nl"),children:"Natural Language"}),s.jsx("button",{type:"button",className:`ss-tab ${p==="sql"?"ss-tab-active":""}`,onClick:()=>x("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:t??(p==="sql"?"SELECT ...":"Ask a question about your data..."),value:l,onChange:j=>g(j.target.value),rows:3})}),s.jsxs("button",{type:"submit",className:"ss-btn ss-btn-primary",disabled:i||!l.trim(),children:[i&&s.jsx("span",{className:"ss-spinner"}),"Run query"]})]})]})})}function xs({columns:e,rows:a,sortable:t=!0,maxRows:o,appearance:n}){const{appearance:u}=I(),i=n??u,[c,d]=r.useState(null),[l,g]=r.useState("asc"),p=r.useMemo(()=>c?[...a].sort((b,C)=>{const h=b[c],v=C[c];if(h==null&&v==null)return 0;if(h==null)return 1;if(v==null)return-1;if(typeof h=="number"&&typeof v=="number")return l==="asc"?h-v:v-h;const N=String(h),$=String(v);return l==="asc"?N.localeCompare($):$.localeCompare(N)}):a,[a,c,l]),x=o?p.slice(0,o):p,m=b=>{t&&(c===b?g(C=>C==="asc"?"desc":"asc"):(d(b),g("asc")))};function j(b){return b==null?"":typeof b=="object"?JSON.stringify(b):String(b)}return s.jsx(M,{appearance:i,children:s.jsxs("div",{className:"ss-table-container",children:[s.jsxs("table",{className:"ss-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.map(b=>s.jsxs("th",{className:`ss-th ${t?"ss-th-sortable":""} ${c===b?l==="asc"?"ss-sorted-asc":"ss-sorted-desc":""}`,onClick:()=>m(b),children:[b,c===b&&s.jsx("span",{className:"ss-sort-indicator",children:l==="asc"?" ▲":" ▼"})]},b))})}),s.jsx("tbody",{children:x.map((b,C)=>s.jsx("tr",{className:"ss-tr",children:e.map(h=>s.jsx("td",{className:"ss-td",children:j(b[h])},h))},C))})]}),o&&a.length>o&&s.jsxs("div",{className:"ss-table-footer",children:["Showing ",o," of ",a.length," rows"]})]})})}function Js(e,a="#6366f1"){const t=parseInt(a.replace("#","").slice(0,2),16),o=[];for(let n=0;n<e;n++){const u=(t+n*Math.floor(360/Math.max(e,1)))%360;o.push(`hsl(${u}, 65%, 55%)`)}return o}function Zs({labels:e,values:a,w:t,h:o,colors:n}){const u=Math.max(...a,1),i=40,c=t-i*2,d=o-i*2,l=Math.max(1,c/e.length-4);return s.jsxs("g",{children:[s.jsx("line",{x1:i,y1:o-i,x2:t-i,y2:o-i,stroke:"#ccc",strokeWidth:1}),a.map((g,p)=>{const x=g/u*d,m=i+c/e.length*p+2,j=o-i-x;return s.jsxs("g",{children:[s.jsx("rect",{x:m,y:j,width:l,height:x,fill:n[p%n.length],rx:2}),s.jsx("text",{x:m+l/2,y:o-i+14,textAnchor:"middle",fontSize:10,fill:"#666",children:e[p].length>8?e[p].slice(0,8)+"...":e[p]})]},p)})]})}function Ks({labels:e,values:a,w:t,h:o,colors:n}){const u=Math.max(...a,1),i=40,c=t-i*2,d=o-i*2,l=e.length>1?c/(e.length-1):0,g=a.map((p,x)=>{const m=i+l*x,j=o-i-p/u*d;return`${m},${j}`});return s.jsxs("g",{children:[[.25,.5,.75,1].map(p=>{const x=o-i-p*d;return s.jsx("line",{x1:i,y1:x,x2:t-i,y2:x,stroke:"#eee",strokeWidth:1},p)}),s.jsx("polyline",{points:g.join(" "),fill:"none",stroke:n[0],strokeWidth:2}),a.map((p,x)=>{const m=i+l*x,j=o-i-p/u*d;return s.jsx("circle",{cx:m,cy:j,r:4,fill:n[0]},x)})]})}function Xs({labels:e,values:a,w:t,h:o,colors:n}){const u=a.reduce((x,m)=>x+m,0)||1,i=t/2,c=o/2-20,d=Math.min(t,o)/2-40,l=2*Math.PI*d;let g=0;const p=a.map((x,m)=>{const j=x/u,b=j*l,C={dash:b,offset:g,color:n[m%n.length],label:e[m],pct:j};return g+=b,C});return s.jsxs("g",{children:[p.map((x,m)=>s.jsx("circle",{cx:i,cy:c,r:d,fill:"none",stroke:x.color,strokeWidth:d*.6,strokeDasharray:`${x.dash} ${l-x.dash}`,strokeDashoffset:-x.offset,transform:`rotate(-90 ${i} ${c})`},m)),s.jsx("g",{transform:`translate(${i-e.length*30}, ${o-20})`,children:p.slice(0,6).map((x,m)=>s.jsxs("g",{transform:`translate(${m*60}, 0)`,children:[s.jsx("rect",{width:10,height:10,fill:x.color,rx:2}),s.jsx("text",{x:14,y:9,fontSize:9,fill:"#666",children:x.label.length>6?x.label.slice(0,6)+"..":x.label})]},m))})]})}function gs({type:e,data:a,title:t,width:o=400,height:n=300,appearance:u}){const{appearance:i}=I(),c=u??i,d=r.useMemo(()=>Js(a.labels.length),[a.labels.length]);return s.jsx(M,{appearance:c,children:s.jsxs("div",{className:"ss-chart-container",children:[t&&s.jsx("h3",{className:"ss-chart-title",children:t}),s.jsxs("svg",{viewBox:`0 0 ${o} ${n}`,width:"100%",style:{maxWidth:o},children:[e==="bar"&&s.jsx(Zs,{labels:a.labels,values:a.values,w:o,h:n,colors:d}),e==="line"&&s.jsx(Ks,{labels:a.labels,values:a.values,w:o,h:n,colors:d}),e==="pie"&&s.jsx(Xs,{labels:a.labels,values:a.values,w:o,h:n,colors:d})]})]})})}function se({dashboardId:e,embedToken:a,baseUrl:t,refreshInterval:o,appearance:n}){const u=I(),i=n??(u==null?void 0:u.appearance),c=r.useMemo(()=>{if(a){const h=t??"https://api.saas-support.com/v1",v=new U.Transport(h,{type:"embedToken",token:a});return new U.ReportClient(v)}return u.client.report},[a,t,u]),[d,l]=r.useState([]),[g,p]=r.useState({}),[x,m]=r.useState(!0),[j,b]=r.useState(null),C=r.useCallback(async()=>{m(!0),b(null);try{const h=await c.getDashboard(e),v=JSON.parse(h.layoutJson||"[]");l(v);const N={};for(const $ of v)try{const P=await c.listQueries({search:$.queryId,perPage:1});if(P.data.length>0&&P.data[0].generatedSql){const O=await c.executeQuery({sql:P.data[0].generatedSql});N[$.queryId]=O}}catch{}p(N)}catch(h){b(h instanceof Error?h.message:"Failed to load dashboard")}finally{m(!1)}},[c,e]);return r.useEffect(()=>{C()},[C]),r.useEffect(()=>{if(!o||o<=0)return;const h=setInterval(C,o*1e3);return()=>clearInterval(h)},[o,C]),s.jsx(M,{appearance:i,children:s.jsxs("div",{className:"ss-dashboard-grid",children:[x&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading dashboard..."]}),j&&s.jsx("div",{className:"ss-global-error",children:j}),!x&&d.map((h,v)=>{const N=g[h.queryId];if(!N)return null;const $=N.columns.length>=2?{labels:N.rows.map(P=>String(P[N.columns[0]]??"")),values:N.rows.map(P=>Number(P[N.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(xs,{columns:N.columns,rows:N.rows,maxRows:50}):s.jsx(gs,{type:h.chartType||"bar",data:$,width:h.w,height:h.h})]},v)})]})})}function ee(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function ae({onSelectQuery:e,onRunQuery:a,appearance:t}){const{appearance:o}=I(),{queries:n,isLoading:u,error:i}=hs(),{execute:c,isLoading:d}=ss(),l=t??o,g=r.useCallback(async p=>{if(!p.generatedSql)return;const x=await c({sql:p.generatedSql});x&&(a==null||a(x))},[c,a]);return s.jsx(M,{appearance:l,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..."]}),i&&s.jsx("div",{className:"ss-global-error",children:i}),!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:()=>e==null?void 0:e(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:ee(p.createdAt)}),s.jsx("button",{type:"button",className:"ss-btn ss-btn-sm ss-btn-primary",disabled:d||!p.generatedSql,onClick:x=>{x.stopPropagation(),g(p)},children:d?s.jsx("span",{className:"ss-spinner"}):"Run"})]})]},p.id))]})})}function te({embedToken:e,dashboardId:a,baseUrl:t="https://api.saas-support.com/v1",refreshInterval:o,appearance:n}){const u=r.useMemo(()=>{const b=new U.Transport(t,{type:"embedToken",token:e});return new U.ReportClient(b)},[e,t]),[i,c]=r.useState([]),[d,l]=r.useState(!0),[g,p]=r.useState(null),x=r.useMemo(()=>Q(n),[n]),m=r.useMemo(()=>J(x),[x]),j=r.useCallback(async()=>{l(!0),p(null);try{const b=await u.getDashboard(a),C=JSON.parse(b.layoutJson||"[]"),h=await Promise.all(C.map(async v=>{try{const N=await u.listQueries({search:v.queryId,perPage:1});if(N.data.length>0&&N.data[0].generatedSql){const $=await u.executeQuery({sql:N.data[0].generatedSql});return{...v,result:$}}}catch{}return v}));c(h)}catch(b){p(b instanceof Error?b.message:"Failed to load dashboard")}finally{l(!1)}},[u,a]);return r.useEffect(()=>{j()},[j]),r.useEffect(()=>{if(!o||o<=0)return;const b=setInterval(j,o*1e3);return()=>clearInterval(b)},[o,j]),s.jsx("div",{ref:b=>{if(!b||b.shadowRoot)return;const C=b.attachShadow({mode:"open"}),h=document.createElement("style");h.textContent=m,C.appendChild(h);const v=document.createElement("div");C.appendChild(v)},style:{display:"contents"},children:s.jsxs("div",{className:"ss-dashboard-grid",children:[d&&s.jsx("div",{className:"ss-loading",children:"Loading dashboard..."}),g&&s.jsx("div",{className:"ss-global-error",children:g}),!d&&i.map((b,C)=>{if(!b.result)return null;const{columns:h,rows:v}=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(N=>s.jsx("th",{className:"ss-th",children:N},N))})}),s.jsx("tbody",{children:v.slice(0,50).map((N,$)=>s.jsx("tr",{className:"ss-tr",children:h.map(P=>s.jsx("td",{className:"ss-td",children:String(N[P]??"")},P))},$))})]})]},C)})]})})}exports.SaaSError=U.SaaSError;exports.SaaSSupport=U.SaaSSupport;exports.isMfaRequired=U.isMfaRequired;exports.Chart=gs;exports.CouponInput=Ws;exports.DashboardView=se;exports.DataTable=xs;exports.InvoiceHistory=us;exports.OrgSwitcher=Ds;exports.PaymentPortal=qs;exports.PricingTable=As;exports.QueryInput=Qs;exports.ReportEmbed=te;exports.SaaSContext=Z;exports.SaaSProvider=vs;exports.SavedQueryList=ae;exports.SettingsPanel=os;exports.SignIn=Cs;exports.SignUp=zs;exports.SubscriptionStatus=ds;exports.UsageDisplay=ps;exports.UserButton=Bs;exports.UserProfile=Ls;exports.useAuth=W;exports.useBilling=Ms;exports.useDashboard=Gs;exports.useDeleteAccount=as;exports.useEmbedDashboard=Ys;exports.useInvoices=ls;exports.useOrg=H;exports.useProfile=X;exports.useQuery=ss;exports.useReport=_s;exports.useSaaSContext=I;exports.useSavedQueries=hs;exports.useSignIn=K;exports.useSignUp=es;exports.useSubscription=is;exports.useUsage=cs;exports.useUser=$s;
2357
+ `}function M({children:e,appearance:a}){const t=r.useRef(null),[o,n]=r.useState(null);r.useEffect(()=>{var g;if(!t.current||t.current.shadowRoot){n(((g=t.current)==null?void 0:g.shadowRoot)??null);return}const i=t.current.attachShadow({mode:"open"});if((a==null?void 0:a.fontUrl)!==null){const p=(a==null?void 0:a.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 m=document.createElement("link");m.rel="stylesheet",m.href=p,document.head.appendChild(m)}const x=document.createElement("link");x.rel="stylesheet",x.href=p,i.appendChild(x)}const c=Q(a),d=document.createElement("style");d.textContent=J(c),i.appendChild(d);const l=document.createElement("div");i.appendChild(l),n(i)},[]),r.useEffect(()=>{if(!o)return;const i=o.querySelector("style");if(i){const c=Q(a);i.textContent=J(c)}},[a,o]);const u=(o==null?void 0:o.querySelector("div"))??null;return s.jsx("div",{ref:t,style:{display:"contents"},children:u&&js.createPortal(e,u)})}function W(){const{client:e,user:a,isLoaded:t}=I();return{isLoaded:t,isSignedIn:!!a,user:a,signOut:r.useCallback(()=>e.auth.signOut(),[e]),getToken:r.useCallback(()=>e.auth.getToken(),[e]),refreshUser:r.useCallback(()=>e.auth.refreshUser(),[e])}}function $s(){const{user:e,isLoaded:a}=I();return{user:e,isLoaded:a}}function K(){const{client:e}=I(),[a,t]=r.useState(!1),[o,n]=r.useState(null),u=r.useCallback(async(d,l)=>{t(!0),n(null);try{return await e.auth.signIn(d,l)}catch(g){return n(g instanceof Error?g.message:"Sign in failed"),null}finally{t(!1)}},[e]),i=r.useCallback(async d=>{t(!0),n(null);try{return await e.auth.signInWithOAuth(d)}catch(l){return n(l instanceof Error?l.message:"OAuth sign in failed"),null}finally{t(!1)}},[e]),c=r.useCallback(async(d,l)=>{t(!0),n(null);try{return await e.auth.submitMfaCode(d,l)}catch(g){return n(g instanceof Error?g.message:"MFA verification failed"),null}finally{t(!1)}},[e]);return{signIn:u,signInWithOAuth:i,submitMfaCode:c,isLoading:a,error:o,setError:n}}function es(){const{client:e}=I(),[a,t]=r.useState(!1),[o,n]=r.useState(null);return{signUp:r.useCallback(async(i,c)=>{t(!0),n(null);try{return await e.auth.signUp(i,c)}catch(d){return n(d instanceof Error?d.message:"Sign up failed"),null}finally{t(!1)}},[e]),isLoading:a,error:o,setError:n}}function H(){const{client:e}=I(),[a,t]=r.useState([]),[o,n]=r.useState(null),[u,i]=r.useState([]),[c,d]=r.useState([]),[l,g]=r.useState(!1),[p,x]=r.useState(null),m=r.useCallback(async()=>{g(!0),x(null);try{const S=await e.auth.listOrgs();if(t(S),!o&&S.length>0){const f=typeof window<"u"?localStorage.getItem("ss_selected_org"):null,z=(f?S.find(B=>B.id===f):null)??(S.length===1?S[0]:null);if(z){n(z),typeof window<"u"&&localStorage.setItem("ss_selected_org",z.id);try{const B=await e.auth.listMembers(z.id);i(B)}catch{}}}}catch(S){x(S instanceof Error?S.message:"Failed to load organizations")}finally{g(!1)}},[e,o]);r.useEffect(()=>{m()},[m]);const j=r.useCallback(async S=>{try{const f=await e.auth.getOrg(S);n(f),typeof window<"u"&&localStorage.setItem("ss_selected_org",S);const w=await e.auth.listMembers(S);i(w)}catch(f){x(f instanceof Error?f.message:"Failed to load organization")}},[e]),b=r.useCallback(async(S,f)=>{try{const w=await e.auth.createOrg(S,f);return t(z=>[...z,w]),w}catch(w){return x(w instanceof Error?w.message:"Failed to create organization"),null}},[e]),C=r.useCallback(async(S,f)=>{try{const w=await e.auth.updateOrg(S,f);return t(z=>z.map(B=>B.id===S?w:B)),(o==null?void 0:o.id)===S&&n(w),w}catch(w){return x(w instanceof Error?w.message:"Failed to update organization"),null}},[e,o]),h=r.useCallback(async S=>{try{return await e.auth.deleteOrg(S),t(f=>f.filter(w=>w.id!==S)),(o==null?void 0:o.id)===S&&(n(null),i([]),d([]),typeof window<"u"&&localStorage.removeItem("ss_selected_org")),!0}catch(f){return x(f instanceof Error?f.message:"Failed to delete organization"),!1}},[e,o]),v=r.useCallback(async(S,f,w)=>{try{return await e.auth.sendInvite(S,f,w)}catch(z){return x(z instanceof Error?z.message:"Failed to send invite"),null}},[e]),N=r.useCallback(async S=>{try{const f=await e.auth.listInvites(S);d(f)}catch(f){x(f instanceof Error?f.message:"Failed to load invites")}},[e]),$=r.useCallback(async(S,f)=>{try{return await e.auth.revokeInvite(S,f),d(w=>w.filter(z=>z.id!==f)),!0}catch(w){return x(w instanceof Error?w.message:"Failed to revoke invite"),!1}},[e]),P=r.useCallback(async(S,f,w)=>{try{return await e.auth.updateMemberRole(S,f,w),i(z=>z.map(B=>B.userId===f?{...B,role:w}:B)),!0}catch(z){return x(z instanceof Error?z.message:"Failed to update member role"),!1}},[e]),O=r.useCallback(async(S,f)=>{try{return await e.auth.removeMember(S,f),i(w=>w.filter(z=>z.userId!==f)),!0}catch(w){return x(w instanceof Error?w.message:"Failed to remove member"),!1}},[e]),E=r.useCallback(async S=>{try{const f=await e.auth.listMembers(S);i(f)}catch(f){x(f instanceof Error?f.message:"Failed to load members")}},[e]);return{orgs:a,selectedOrg:o,members:u,invites:c,isLoading:l,error:p,setError:x,refresh:m,selectOrg:j,createOrg:b,updateOrg:C,deleteOrg:h,sendInvite:v,refreshInvites:N,revokeInvite:$,updateMemberRole:P,removeMember:O,refreshMembers:E}}function as(){const{client:e}=I(),[a,t]=r.useState(!1),[o,n]=r.useState(null);return{deleteAccount:r.useCallback(async()=>{t(!0),n(null);try{return await e.auth.deleteAccount(),!0}catch(i){return n(i instanceof Error?i.message:"Failed to delete account"),!1}finally{t(!1)}},[e]),isLoading:a,error:o,setError:n}}function X(){const{client:e,user:a}=I(),[t,o]=r.useState(!1),[n,u]=r.useState(null),[i,c]=r.useState(null),d=r.useCallback(async p=>{o(!0),u(null),c(null);try{const x=await e.auth.updateProfile(p);return c("Profile updated"),x}catch(x){return u(x instanceof Error?x.message:"Failed to update profile"),null}finally{o(!1)}},[e]),l=r.useCallback(async(p,x)=>{o(!0),u(null),c(null);try{return await e.auth.changePassword(p,x),c("Password changed successfully"),!0}catch(m){return u(m instanceof Error?m.message:"Failed to change password"),!1}finally{o(!1)}},[e]),g=r.useCallback(async p=>{o(!0),u(null),c(null);try{const x=await e.auth.uploadAvatar(p);return c("Avatar updated"),x}catch(x){return u(x instanceof Error?x.message:"Failed to upload avatar"),null}finally{o(!1)}},[e]);return{user:a,updateProfile:d,uploadAvatar:g,changePassword:l,isLoading:t,error:n,success:i,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>',y={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",arrowBack:"arrow_back",arrowForward:"arrow_forward",verified:"verified",token:"token",autoAwesome:"auto_awesome",corporateFare:"corporate_fare",cloudDone:"cloud_done",check:"check",image:"image",settings:"settings",group:"group",creditCard:"credit_card",edit:"edit",send:"send",personRemove:"person_remove"};function Cs({appearance:e,signUpUrl:a,onSignUp:t}){const{appearance:o,settings:n}=I(),{signIn:u,signInWithOAuth:i,submitMfaCode:c,isLoading:d,error:l,setError:g}=K(),p=e??o,[x,m]=r.useState(""),[j,b]=r.useState(""),[C,h]=r.useState(!1),[v,N]=r.useState(!1),[$,P]=r.useState(""),[O,E]=r.useState(["","","","","",""]),S=r.useRef([]),f=r.useCallback(async L=>{if(L.preventDefault(),v){await c($,O.join(""));return}const k=await u(x,j);k&&U.isMfaRequired(k)&&(P(k.mfaToken),N(!0),g(null))},[x,j,v,$,O,u,c,g]),w=r.useCallback(async L=>{await i(L)},[i]),z=r.useCallback((L,k)=>{var V;if(!/^\d*$/.test(k))return;const F=k.slice(-1);E(G=>{const q=[...G];return q[L]=F,q}),F&&L<5&&((V=S.current[L+1])==null||V.focus())},[]),B=r.useCallback((L,k)=>{var F;k.key==="Backspace"&&!O[L]&&L>0&&((F=S.current[L-1])==null||F.focus())},[O]),T=(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:y.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"})]}),!v&&T&&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:()=>w("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:()=>w("github"),disabled:d,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:rs}}),"GitHub"]})]}),s.jsx("div",{className:"ss-auth-divider",children:"or continue with"})]}),l&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:l})]}),s.jsxs("form",{onSubmit:f,children:[v?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:O.map((L,k)=>s.jsx("input",{ref:F=>{S.current[k]=F},className:"ss-auth-mfa-digit",type:"text",inputMode:"numeric",maxLength:1,value:L,onChange:F=>z(k,F.target.value),onKeyDown:F=>B(k,F),autoFocus:k===0},k))}),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:x,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:C?"text":"password",autoComplete:"current-password",placeholder:"••••••••",value:j,onChange:L=>b(L.target.value),required:!0}),s.jsx("button",{type:"button",className:"ss-auth-visibility-toggle",onClick:()=>h(!C),children:s.jsx("span",{className:"material-symbols-outlined",children:C?y.visibilityOff:y.visibility})})]})]})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:d,children:[d&&s.jsx("span",{className:"ss-auth-spinner"}),v?"Verify":"Sign in",!d&&s.jsx("span",{className:"material-symbols-outlined",children:y.arrowForward})]})]}),v?s.jsx("div",{className:"ss-auth-footer",children:s.jsx("span",{className:"ss-auth-link",onClick:()=>{N(!1),E(["","","","","",""]),g(null)},children:"Back to sign in"})}):s.jsxs("div",{className:"ss-auth-footer",children:["Don't have an account?"," ",t?s.jsx("span",{className:"ss-auth-link",onClick:t,children:"Sign up"}):a?s.jsx("a",{className:"ss-auth-link",href:a,children:"Sign up"}):s.jsx("span",{className:"ss-auth-link",children:"Sign up"})]})]})})})}function zs({appearance:e,signInUrl:a,onSignIn:t}){const{appearance:o,settings:n}=I(),{signUp:u,isLoading:i,error:c,setError:d}=es(),{signInWithOAuth:l}=K(),g=e??o,[p,x]=r.useState(""),[m,j]=r.useState(""),[b,C]=r.useState(""),[h,v]=r.useState(!1),[N,$]=r.useState(null),P=r.useCallback(async f=>{if(f.preventDefault(),$(null),m!==b){$("Passwords do not match");return}const w=(n==null?void 0:n.passwordMinLength)??8;if(m.length<w){$(`Password must be at least ${w} characters`);return}await u(p,m)},[p,m,b,n,u]),O=r.useCallback(async f=>{await l(f)},[l]),E=(n==null?void 0:n.googleEnabled)||(n==null?void 0:n.githubEnabled),S=N||c;return s.jsx(M,{appearance:g,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:y.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:[E&&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:()=>O("google"),disabled:i,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:()=>O("github"),disabled:i,children:[s.jsx("span",{dangerouslySetInnerHTML:{__html:rs}}),"GitHub"]})]}),s.jsx("div",{className:"ss-auth-divider",children:"or sign up with email"})]}),S&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:S})]}),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=>x(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=>{j(f.target.value),$(null)},required:!0}),s.jsx("button",{type:"button",className:"ss-auth-visibility-toggle",onClick:()=>v(!h),children:s.jsx("span",{className:"material-symbols-outlined",children:h?y.visibilityOff:y.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=>{C(f.target.value),$(null)},required:!0})]}),s.jsxs("button",{type:"submit",className:"ss-auth-btn-primary",disabled:i,children:[i&&s.jsx("span",{className:"ss-auth-spinner"}),"Sign up",!i&&s.jsx("span",{className:"material-symbols-outlined",children:y.arrowForward})]})]}),s.jsxs("div",{className:"ss-auth-footer",children:["Already have an account?"," ",t?s.jsx("span",{className:"ss-auth-link",onClick:t,children:"Sign in"}):a?s.jsx("a",{className:"ss-auth-link",href:a,children:"Sign in"}):s.jsx("span",{className:"ss-auth-link",children:"Sign in"})]})]})})]})})}const D=320,R=128;function Ps({file:e,onCrop:a,onCancel:t}){const o=r.useRef(null),n=r.useRef(null),[u,i]=r.useState(1),[c,d]=r.useState({x:0,y:0}),[l,g]=r.useState(!1),p=r.useRef({x:0,y:0,ox:0,oy:0}),[x,m]=r.useState(!1);r.useEffect(()=>{const h=new Image,v=URL.createObjectURL(e);return h.onload=()=>{n.current=h,m(!0),d({x:0,y:0}),i(1)},h.src=v,()=>URL.revokeObjectURL(v)},[e]),r.useEffect(()=>{if(!x||!n.current||!o.current)return;const h=o.current.getContext("2d");if(!h)return;const v=n.current;h.clearRect(0,0,D,D),h.fillStyle="#111",h.fillRect(0,0,D,D);const N=Math.max(D/v.width,D/v.height)*u,$=v.width*N,P=v.height*N,O=(D-$)/2+c.x,E=(D-P)/2+c.y;h.save(),h.beginPath(),h.arc(D/2,D/2,R,0,Math.PI*2),h.clip(),h.drawImage(v,O,E,$,P),h.restore(),h.save(),h.fillStyle="rgba(0, 0, 0, 0.6)",h.fillRect(0,0,D,D),h.globalCompositeOperation="destination-out",h.beginPath(),h.arc(D/2,D/2,R,0,Math.PI*2),h.fill(),h.restore(),h.save(),h.beginPath(),h.arc(D/2,D/2,R,0,Math.PI*2),h.clip(),h.drawImage(v,O,E,$,P),h.restore(),h.strokeStyle="rgba(255, 255, 255, 0.4)",h.lineWidth=2,h.beginPath(),h.arc(D/2,D/2,R,0,Math.PI*2),h.stroke()},[u,c,x]);const j=r.useCallback(h=>{g(!0),p.current={x:h.clientX,y:h.clientY,ox:c.x,oy:c.y},h.target.setPointerCapture(h.pointerId)},[c]),b=r.useCallback(h=>{l&&d({x:p.current.ox+(h.clientX-p.current.x),y:p.current.oy+(h.clientY-p.current.y)})},[l]),C=r.useCallback(()=>g(!1),[]);return r.useCallback(()=>{if(!n.current)return;const h=document.createElement("canvas"),v=R*2;h.width=v,h.height=v;const N=h.getContext("2d");if(!N)return;const $=n.current,P=Math.max(D/$.width,D/$.height)*u,O=$.width*P,E=$.height*P,S=(D-O)/2+c.x-(D/2-R),f=(D-E)/2+c.y-(D/2-R);N.beginPath(),N.arc(R,R,R,0,Math.PI*2),N.clip(),N.drawImage($,S,f,O,E),h.toBlob(w=>{w&&a(w)},"image/png")},[u,c,a]),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:D,height:D,style:{cursor:l?"grabbing":"grab",width:"100%",height:"100%"},onPointerDown:j,onPointerMove:b,onPointerUp:C}),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:y.zoomOut}),s.jsx("input",{type:"range",min:"1",max:"3",step:"0.01",value:u,onChange:h=>i(parseFloat(h.target.value)),className:"ss-auth-zoom-slider"}),s.jsx("span",{className:"material-symbols-outlined",children:y.zoomIn})]})]})}function ns({onUpload:e,onClose:a,isLoading:t}){const[o,n]=r.useState(null),[u,i]=r.useState(!1),[c,d]=r.useState(null),l=r.useRef(null),g=r.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=r.useCallback(m=>{m.preventDefault(),i(!1);const j=m.dataTransfer.files[0];j&&g(j)},[g]),x=r.useCallback(async m=>{await e(m)},[e]);return s.jsx("div",{className:"ss-auth-modal-overlay",onClick:m=>{m.target===m.currentTarget&&a()},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:a,children:s.jsx("span",{className:"material-symbols-outlined",children:y.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:y.errorOutline}),s.jsx("span",{children:c})]}),s.jsxs("div",{className:"ss-auth-upload-grid",children:[s.jsx("div",{children:o?s.jsx(Ps,{file:o,onCrop:x,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:y.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(),i(!0)},onDragLeave:()=>i(!1),onDrop:p,onClick:()=>{var m;return(m=l.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:y.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:l,type:"file",accept:"image/*",style:{display:"none"},onChange:m=>{var j;(j=m.target.files)!=null&&j[0]&&g(m.target.files[0])}})]}),s.jsxs("div",{className:"ss-auth-info-box",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.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:a,children:"Cancel"}),s.jsxs("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",onClick:()=>{},disabled:!o||t,style:{width:"auto"},children:[t&&s.jsx("span",{className:"ss-auth-spinner"}),"Save Profile",!t&&s.jsx("span",{className:"material-symbols-outlined",children:y.check})]})]})]})})}function os({onClose:e,afterDeleteAccountUrl:a,defaultTab:t="profile"}){const[o,n]=r.useState(t),u=[{key:"profile",label:"Profile",icon:y.person},{key:"organization",label:"Organization",icon:y.corporateFare},{key:"people",label:"People",icon:y.group},{key:"billing",label:"Billing",icon:y.creditCard}];return s.jsxs("div",{className:"ss-auth-settings-page",children:[s.jsxs("div",{className:"ss-auth-settings-header",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px"},children:[s.jsx("button",{type:"button",className:"ss-auth-settings-back",onClick:e,children:s.jsx("span",{className:"material-symbols-outlined",children:y.arrowBack})}),s.jsx("h2",{children:"Settings"})]}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:e,children:s.jsx("span",{className:"material-symbols-outlined",children:y.close})})]}),s.jsxs("div",{className:"ss-auth-settings-layout",children:[s.jsx("nav",{className:"ss-auth-settings-nav",children:u.map(i=>s.jsxs("button",{type:"button",className:`ss-auth-settings-nav-item${o===i.key?" ss-auth-settings-nav-item-active":""}`,onClick:()=>n(i.key),children:[s.jsx("span",{className:"material-symbols-outlined",children:i.icon}),i.label]},i.key))}),s.jsxs("div",{className:"ss-auth-settings-content",children:[o==="profile"&&s.jsx(Os,{afterDeleteAccountUrl:a}),o==="organization"&&s.jsx(Es,{}),o==="people"&&s.jsx(Is,{}),o==="billing"&&s.jsx(Fs,{})]})]})]})}function Os({afterDeleteAccountUrl:e}){const{user:a,updateProfile:t,uploadAvatar:o,changePassword:n,isLoading:u,error:i,success:c,setError:d,setSuccess:l}=X(),{signOut:g}=W(),{deleteAccount:p,isLoading:x,error:m,setError:j}=as(),[b,C]=r.useState((a==null?void 0:a.name)??""),[h,v]=r.useState((a==null?void 0:a.avatarUrl)??""),[N,$]=r.useState(!1),[P,O]=r.useState(""),[E,S]=r.useState(""),[f,w]=r.useState(""),[z,B]=r.useState(null),[T,L]=r.useState(!1),[k,F]=r.useState(""),V=r.useCallback(async A=>{A.preventDefault(),d(null),l(null),await t({name:b,avatarUrl:h||void 0})},[b,h,t,d,l]),G=r.useCallback(async A=>{const Y=await o(A);Y&&(v(Y.avatarUrl),$(!1))},[o]),q=r.useCallback(async A=>{if(A.preventDefault(),B(null),d(null),l(null),E!==f){B("Passwords do not match");return}if(E.length<8){B("Password must be at least 8 characters");return}await n(P,E)&&(O(""),S(""),w(""))},[P,E,f,n,d,l]),ms=r.useCallback(async()=>{await p()&&(await g(),e&&(window.location.href=e))},[p,g,e]),fs=(a==null?void 0:a.provider)==="email",bs=k===(a==null?void 0:a.email),ys=((a==null?void 0:a.name)||(a==null?void 0:a.email)||"?").charAt(0).toUpperCase();return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Profile"}),s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("div",{className:"ss-auth-profile-header",style:{border:"none",background:"none",padding:0,marginBottom:16},children:[s.jsxs("div",{className:"ss-auth-avatar-lg",onClick:()=>$(!0),children:[h?s.jsx("img",{src:h,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:y.camera}),s.jsx("span",{children:"Edit"})]})]}),s.jsxs("div",{className:"ss-auth-profile-info",children:[s.jsxs("h2",{className:"ss-auth-profile-name",children:[(a==null?void 0:a.name)||"Unnamed User",(a==null?void 0:a.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:y.verified}),"Verified"]})]}),s.jsx("p",{className:"ss-auth-profile-desc",children:a==null?void 0:a.email})]})]}),i&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:i})]}),c&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.check}),s.jsx("span",{children:c})]}),s.jsxs("form",{onSubmit:V,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:b,onChange:A=>C(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:(a==null?void 0:a.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:y.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:(a==null?void 0:a.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:u,style:{width:"auto"},children:[u&&s.jsx("span",{className:"ss-auth-spinner"}),"Save changes"]})})]})]}),fs&&s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("h4",{children:[s.jsx("span",{className:"material-symbols-outlined",children:y.security}),"Security Credentials"]}),z&&s.jsxs("div",{className:"ss-auth-error",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:z})]}),s.jsxs("form",{onSubmit:q,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:P,onChange:A=>O(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:E,onChange:A=>S(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:f,onChange:A=>w(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:u,children:"Update Security"})})]})]}),s.jsxs("div",{className:"ss-auth-settings-card ss-auth-settings-danger",children:[s.jsx("h4",{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."}),m&&s.jsxs("div",{className:"ss-auth-error",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:m})]}),T?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:a==null?void 0:a.email,value:k,onChange:A=>F(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:()=>{L(!1),F(""),j(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||x,onClick:ms,children:[x&&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:()=>L(!0),children:"Delete my account"})]}),N&&s.jsx(ns,{onUpload:G,onClose:()=>$(!1),isLoading:u})]})}function Es(){const{selectedOrg:e,updateOrg:a,deleteOrg:t,isLoading:o,error:n,setError:u}=H(),[i,c]=r.useState((e==null?void 0:e.name)??""),[d,l]=r.useState(!1),[g,p]=r.useState(!1),[x,m]=r.useState(!1),[j,b]=r.useState("");if(r.useEffect(()=>{e&&c(e.name)},[e]),!e)return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Organization"}),s.jsxs("div",{className:"ss-auth-settings-empty",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.corporateFare}),s.jsx("div",{children:"Select an organization from the user menu to manage its settings."})]})]});const C=async v=>{if(v.preventDefault(),!i.trim())return;l(!0),p(!1);const N=await a(e.id,{name:i.trim()});l(!1),N&&p(!0)},h=async()=>{await t(e.id)&&m(!1)};return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Organization"}),s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("h4",{children:[s.jsx("span",{className:"material-symbols-outlined",children:y.corporateFare}),"General"]}),n&&s.jsxs("div",{className:"ss-auth-error",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:n})]}),g&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.check}),s.jsx("span",{children:"Organization updated"})]}),s.jsxs("form",{onSubmit:C,children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Organization Name"}),s.jsx("input",{className:"ss-auth-input",type:"text",value:i,onChange:v=>{c(v.target.value),p(!1)}})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Slug"}),s.jsx("input",{className:"ss-auth-input ss-auth-input-readonly",type:"text",value:e.slug,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:d,style:{width:"auto"},children:[d&&s.jsx("span",{className:"ss-auth-spinner"}),"Save"]})})]})]}),s.jsxs("div",{className:"ss-auth-settings-card ss-auth-settings-danger",children:[s.jsx("h4",{children:"Danger Zone"}),s.jsx("p",{className:"ss-auth-section-desc",style:{marginBottom:"16px"},children:"Deleting this organization is permanent and will remove all members."}),x?s.jsxs("div",{children:[s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Type the organization name to confirm"}),s.jsx("input",{className:"ss-auth-input",type:"text",placeholder:e.name,value:j,onChange:v=>b(v.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:()=>{m(!1),b("")},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:j!==e.name||o,onClick:h,children:[o&&s.jsx("span",{className:"ss-auth-spinner"}),"Delete organization"]})]})]}):s.jsx("button",{type:"button",className:"ss-auth-btn-outline",style:{borderColor:"currentColor",width:"auto"},onClick:()=>m(!0),children:"Delete this organization"})]})]})}function Is(){const{selectedOrg:e,members:a,invites:t,isLoading:o,error:n,setError:u,sendInvite:i,refreshInvites:c,revokeInvite:d,updateMemberRole:l,removeMember:g,refreshMembers:p}=H(),[x,m]=r.useState(""),[j,b]=r.useState("member"),[C,h]=r.useState(!1),[v,N]=r.useState(!1),[$,P]=r.useState(null),[O,E]=r.useState(""),[S,f]=r.useState(null);if(r.useEffect(()=>{e&&(p(e.id),c(e.id))},[e,p,c]),!e)return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"People"}),s.jsxs("div",{className:"ss-auth-settings-empty",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.group}),s.jsx("div",{children:"Select an organization from the user menu to manage members."})]})]});const w=async k=>{k.preventDefault(),N(!1),await i(e.id,x,j)&&(m(""),b("member"),N(!0),h(!1),c(e.id))},z=async()=>{if(!$)return;await l(e.id,$.userId,O)&&P(null)},B=async()=>{if(!S)return;await g(e.id,S.userId)&&f(null)},T=async k=>{await d(e.id,k)},L=k=>k==="owner"?"ss-auth-role-badge ss-auth-role-badge-owner":k==="admin"?"ss-auth-role-badge ss-auth-role-badge-admin":"ss-auth-role-badge ss-auth-role-badge-member";return s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"People"}),n&&s.jsxs("div",{className:"ss-auth-error",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.errorOutline}),s.jsx("span",{children:n})]}),v&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.check}),s.jsx("span",{children:"Invitation sent"})]}),s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"16px"},children:[s.jsxs("h4",{style:{margin:0},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.group}),"Members"]}),s.jsxs("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",style:{width:"auto"},onClick:()=>h(!C),children:[s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"16px"},children:y.add}),"Invite"]})]}),C&&s.jsx("form",{onSubmit:w,style:{marginBottom:"16px",padding:"16px",background:"rgba(0,0,0,0.05)",borderRadius:"8px"},children:s.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"flex-end"},children:[s.jsxs("div",{style:{flex:1},children:[s.jsx("label",{className:"ss-auth-label",children:"Email"}),s.jsx("input",{className:"ss-auth-input",type:"email",placeholder:"member@example.com",value:x,onChange:k=>m(k.target.value),required:!0})]}),s.jsxs("div",{style:{width:"120px"},children:[s.jsx("label",{className:"ss-auth-label",children:"Role"}),s.jsxs("select",{className:"ss-auth-input",value:j,onChange:k=>b(k.target.value),style:{cursor:"pointer"},children:[s.jsx("option",{value:"admin",children:"Admin"}),s.jsx("option",{value:"member",children:"Member"})]})]}),s.jsx("button",{type:"submit",className:"ss-auth-btn-primary ss-auth-btn-sm",disabled:o,style:{width:"auto",marginBottom:"0"},children:"Send"})]})}),a.length===0?s.jsx("div",{className:"ss-auth-settings-empty",style:{padding:"20px"},children:s.jsx("div",{children:"No members yet."})}):s.jsxs("table",{className:"ss-auth-settings-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Email"}),s.jsx("th",{children:"Role"}),s.jsx("th",{style:{width:"80px"},children:"Actions"})]})}),s.jsx("tbody",{children:a.map(k=>s.jsxs("tr",{children:[s.jsx("td",{children:k.email}),s.jsx("td",{children:s.jsx("span",{className:L(k.role),children:k.role})}),s.jsx("td",{children:k.role==="owner"?s.jsx("span",{style:{fontSize:"12px",opacity:.4},children:"—"}):s.jsxs("div",{className:"ss-auth-settings-actions",children:[s.jsx("button",{type:"button",className:"ss-auth-icon-btn",title:"Edit role",onClick:()=>{P(k),E(k.role)},children:s.jsx("span",{className:"material-symbols-outlined",children:y.edit})}),s.jsx("button",{type:"button",className:"ss-auth-icon-btn ss-auth-icon-btn-danger",title:"Remove member",onClick:()=>f(k),children:s.jsx("span",{className:"material-symbols-outlined",children:y.personRemove})})]})})]},k.userId))})]})]}),t.length>0&&s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("h4",{children:[s.jsx("span",{className:"material-symbols-outlined",children:y.send}),"Pending Invites"]}),s.jsxs("table",{className:"ss-auth-settings-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Email"}),s.jsx("th",{children:"Role"}),s.jsx("th",{style:{width:"80px"},children:"Actions"})]})}),s.jsx("tbody",{children:t.map(k=>s.jsxs("tr",{children:[s.jsx("td",{children:k.email}),s.jsx("td",{children:s.jsx("span",{className:L(k.role),children:k.role})}),s.jsx("td",{children:s.jsx("button",{type:"button",className:"ss-auth-icon-btn ss-auth-icon-btn-danger",title:"Revoke invite",onClick:()=>T(k.id),children:s.jsx("span",{className:"material-symbols-outlined",children:y.close})})})]},k.id))})]})]}),$&&s.jsx("div",{className:"ss-auth-modal-overlay",onClick:k=>{k.target===k.currentTarget&&P(null)},children:s.jsxs("div",{className:"ss-auth-modal",style:{maxWidth:"400px"},children:[s.jsxs("div",{className:"ss-auth-modal-header",children:[s.jsx("h2",{children:"Edit Role"}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:()=>P(null),children:s.jsx("span",{className:"material-symbols-outlined",children:y.close})})]}),s.jsxs("div",{className:"ss-auth-modal-body",children:[s.jsxs("p",{style:{fontSize:"14px",marginBottom:"16px",margin:"0 0 16px 0"},children:["Change role for ",s.jsx("strong",{children:$.email})]}),s.jsxs("div",{className:"ss-auth-field",children:[s.jsx("label",{className:"ss-auth-label",children:"Role"}),s.jsxs("select",{className:"ss-auth-input",value:O,onChange:k=>E(k.target.value),style:{cursor:"pointer"},children:[s.jsx("option",{value:"admin",children:"Admin"}),s.jsx("option",{value:"member",children:"Member"})]})]}),s.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[s.jsx("button",{type:"button",className:"ss-auth-btn-ghost",onClick:()=>P(null),children:"Cancel"}),s.jsx("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",style:{width:"auto"},onClick:z,children:"Save"})]})]})]})}),S&&s.jsx("div",{className:"ss-auth-modal-overlay",onClick:k=>{k.target===k.currentTarget&&f(null)},children:s.jsxs("div",{className:"ss-auth-modal",style:{maxWidth:"400px"},children:[s.jsxs("div",{className:"ss-auth-modal-header",children:[s.jsx("h2",{children:"Remove Member"}),s.jsx("button",{type:"button",className:"ss-auth-modal-close",onClick:()=>f(null),children:s.jsx("span",{className:"material-symbols-outlined",children:y.close})})]}),s.jsxs("div",{className:"ss-auth-modal-body",children:[s.jsxs("p",{style:{fontSize:"14px",margin:"0 0 16px 0"},children:["Are you sure you want to remove ",s.jsx("strong",{children:S.email})," from the organization?"]}),s.jsxs("div",{style:{display:"flex",gap:"8px",justifyContent:"flex-end"},children:[s.jsx("button",{type:"button",className:"ss-auth-btn-ghost",onClick:()=>f(null),children:"Cancel"}),s.jsx("button",{type:"button",className:"ss-auth-btn-primary ss-auth-btn-sm",style:{width:"auto",background:"linear-gradient(135deg, #ef4444, #dc2626)"},onClick:B,children:"Remove"})]})]})]})})]})}function Fs(){const{selectedOrg:e}=H();return e?s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Billing"}),s.jsxs("div",{className:"ss-auth-settings-card",children:[s.jsxs("h4",{children:[s.jsx("span",{className:"material-symbols-outlined",children:y.creditCard}),"Plan & Billing"]}),s.jsx("div",{className:"ss-auth-settings-empty",style:{padding:"20px"},children:s.jsx("div",{children:"No billing plan configured for this organization."})})]})]}):s.jsxs(s.Fragment,{children:[s.jsx("h3",{children:"Billing"}),s.jsxs("div",{className:"ss-auth-settings-empty",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.creditCard}),s.jsx("div",{children:"Select an organization from the user menu to manage billing."})]})]})}function Bs({appearance:e,afterSignOutUrl:a,afterDeleteAccountUrl:t,showOrgSwitcher:o=!0,onOrgChange:n,onOrgSettingsClick:u}){const{appearance:i}=I(),{user:c,signOut:d}=W(),l=e??i,[g,p]=r.useState(!1),[x,m]=r.useState(!1),[j,b]=r.useState(""),[C,h]=r.useState(null),[v,N]=r.useState(!1),$=r.useRef(null),{orgs:P,selectedOrg:O,selectOrg:E,createOrg:S}=H(),f=r.useCallback(z=>{$.current&&!z.composedPath().includes($.current)&&p(!1)},[]);r.useEffect(()=>{if(g){const z=setTimeout(()=>{document.addEventListener("click",f)},0);return()=>{clearTimeout(z),document.removeEventListener("click",f)}}},[g,f]);const w=r.useCallback(async z=>{z.preventDefault(),h(null),N(!0);const B=j.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");try{const T=await S(j,B);T&&(await E(T.id),n==null||n(T),b(""),p(!1))}catch(T){h(T instanceof Error?T.message:"Failed to create organization")}finally{N(!1)}},[j,S,E,n]);return c?s.jsx(M,{appearance:l,children:s.jsxs("div",{style:{position:"relative",display:"inline-block"},ref:$,children:[s.jsxs("button",{type:"button",className:"ss-auth-user-trigger",onClick:()=>p(!g),"aria-label":"User menu",children:[s.jsx("span",{className:"ss-auth-avatar-trigger",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()})}),O&&s.jsx("span",{className:"ss-auth-trigger-org-name",children:O.name})]}),g&&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:y.settings}),"Settings"]})}),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(z=>{const B=(O==null?void 0:O.id)===z.id,T=z.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 E(z.id),n==null||n(z)},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:T}),s.jsx("span",{style:{fontFamily:"'Manrope', sans-serif",letterSpacing:"-0.01em"},children:z.name}),z.planName&&s.jsx("span",{className:"ss-auth-plan-badge",children:z.planName})]}),B&&s.jsx("span",{className:"material-symbols-outlined ss-auth-org-check",style:{fontSize:"18px"},children:y.checkCircle})]},z.id)})}),s.jsxs("div",{className:"ss-auth-inline-create",children:[C&&s.jsx("div",{className:"ss-auth-error",style:{marginBottom:"8px",fontSize:"12px"},children:s.jsx("span",{children:C})}),s.jsx("form",{onSubmit:w,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:j,onChange:z=>b(z.target.value),required:!0,style:{fontSize:"13px",padding:"10px 40px 10px 12px"}}),s.jsx("button",{type:"submit",className:"ss-auth-inline-create-btn",disabled:v||!j.trim(),children:s.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"20px"},children:y.add})})]})})]}),O&&u&&s.jsx("div",{style:{padding:"0 8px 4px"},children:s.jsxs("button",{type:"button",className:"ss-auth-dropdown-action",onClick:()=>{p(!1),u(O)},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.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(),a&&(window.location.href=a)},style:{color:"inherit"},children:[s.jsx("span",{className:"material-symbols-outlined",style:{color:"inherit"},children:y.logout}),"Sign out"]})})]}),x&&s.jsx(os,{onClose:()=>m(!1),afterDeleteAccountUrl:t})]})}):null}function Ls({appearance:e}){const{appearance:a}=I(),{user:t,signOut:o}=W(),{updateProfile:n,uploadAvatar:u,changePassword:i,isLoading:c,error:d,success:l,setError:g,setSuccess:p}=X(),x=e??a,[m,j]=r.useState((t==null?void 0:t.name)??""),[b,C]=r.useState((t==null?void 0:t.avatarUrl)??""),[h,v]=r.useState(!1),[N,$]=r.useState(""),[P,O]=r.useState(""),[E,S]=r.useState(""),[f,w]=r.useState(null),z=r.useCallback(async F=>{F.preventDefault(),g(null),p(null),await n({name:m,avatarUrl:b||void 0})},[m,b,n,g,p]),B=r.useCallback(async F=>{const V=await u(F);V&&(C(V.avatarUrl),v(!1))},[u]),T=r.useCallback(async F=>{if(F.preventDefault(),w(null),g(null),p(null),P!==E){w("Passwords do not match");return}if(P.length<8){w("Password must be at least 8 characters");return}await i(N,P)&&($(""),O(""),S(""))},[N,P,E,i,g,p]);if(!t)return null;const L=t.provider==="email",k=(t.name||t.email).charAt(0).toUpperCase();return s.jsx(M,{appearance:x,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:()=>v(!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:k}),s.jsxs("div",{className:"ss-auth-avatar-overlay",children:[s.jsx("span",{className:"material-symbols-outlined",children:y.camera}),s.jsx("span",{children:"Edit"})]})]}),s.jsxs("div",{className:"ss-auth-profile-info",children:[s.jsxs("h2",{className:"ss-auth-profile-name",children:[t.name||"Unnamed User",t.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:y.verified}),"Verified"]})]}),s.jsx("p",{className:"ss-auth-profile-desc",children:t.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:y.errorOutline}),s.jsx("span",{children:d})]}),l&&s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.check}),s.jsx("span",{children:l})]}),s.jsxs("form",{onSubmit:z,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:F=>j(F.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:t.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:y.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:t.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:y.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:y.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:y.errorOutline}),s.jsx("span",{children:f})]}),s.jsxs("form",{onSubmit:T,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:N,onChange:F=>$(F.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:F=>O(F.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:E,onChange:F=>S(F.target.value),required:!0})]})]}),s.jsxs("div",{className:"ss-auth-info-box",style:{marginBottom:"16px"},children:[s.jsx("span",{className:"material-symbols-outlined",children:y.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:y.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:()=>v(!1),isLoading:c})]})})}function Ds({appearance:e,onOrgChange:a}){const{appearance:t}=I(),{orgs:o,selectedOrg:n,selectOrg:u,createOrg:i,isLoading:c}=H(),d=e??t,[l,g]=r.useState(!1),[p,x]=r.useState(""),[m,j]=r.useState(""),[b,C]=r.useState(null),[h,v]=r.useState(!1),N=r.useRef(null),$=r.useCallback(f=>{N.current&&!f.composedPath().includes(N.current)&&g(!1)},[]);r.useEffect(()=>{if(l){const f=setTimeout(()=>{document.addEventListener("click",$)},0);return()=>{clearTimeout(f),document.removeEventListener("click",$)}}},[l,$]);const P=r.useCallback(f=>{x(f),j(f.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,""))},[]),O=r.useCallback(async f=>{f.preventDefault(),C(null),v(!0);try{const w=await i(p,m);w&&(await u(w.id),a==null||a(w),x(""),j(""),g(!1))}catch(w){C(w instanceof Error?w.message:"Failed to create organization")}finally{v(!1)}},[p,m,i,u,a]);if(c)return null;const E=(n==null?void 0:n.name)??(o.length===0?"No organization":"Select organization"),S=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:N,children:[s.jsxs("button",{type:"button",className:"ss-auth-org-trigger",onClick:()=>g(!l),children:[s.jsxs("div",{className:"ss-auth-org-trigger-inner",children:[s.jsx("div",{className:"ss-auth-org-avatar",children:S}),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:E})]})]}),s.jsx("span",{className:"material-symbols-outlined",children:y.unfoldMore})]}),l&&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 w=(n==null?void 0:n.id)===f.id,z=f.name.split(" ").map(B=>B[0]).join("").slice(0,2).toUpperCase();return s.jsxs("button",{type:"button",className:`ss-auth-org-item${w?" ss-auth-org-item-active":""}`,onClick:async()=>{g(!1),await u(f.id),a==null||a(f)},children:[s.jsxs("div",{className:"ss-auth-org-item-inner",children:[s.jsx("div",{className:`ss-auth-org-avatar${w?"":" ss-auth-org-avatar-inactive"}`,children:z}),s.jsx("span",{style:{fontFamily:"'Manrope', sans-serif",letterSpacing:"-0.01em"},children:f.name})]}),w&&s.jsx("span",{className:"material-symbols-outlined ss-auth-org-check",style:{fontSize:"18px"},children:y.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:y.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:O,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=>j(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 Ts(e,a="USD"){return new Intl.NumberFormat("en-US",{style:"currency",currency:a,minimumFractionDigits:e%100===0?0:2}).format(e/100)}function As({plans:e,currentPlanId:a,onSelectPlan:t,interval:o,appearance:n}){const{appearance:u}=I(),i=n??u,c=o?e.filter(d=>d.interval===o||d.isFree):e;return s.jsx(M,{appearance:i,children:s.jsx("div",{className:"ss-pricing-grid",children:c.map(d=>{const l=d.id===a;return s.jsxs("div",{className:`ss-pricing-card ${l?"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:Ts(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((g,p)=>s.jsxs("li",{className:"ss-pricing-feature",children:[s.jsx("span",{className:"ss-check",children:"✓"})," ",g]},p))}),s.jsx("button",{type:"button",className:`ss-btn ${l?"ss-btn-current":"ss-btn-primary"}`,disabled:l,onClick:()=>t(d.id),children:l?"Current plan":"Select plan"})]},d.id)})})})}function Ms(){const{client:e}=I();return{billing:e.billing}}function _(e){const{client:a}=I();return r.useMemo(()=>{if(e){const t=new U.Transport("https://api.saas-support.com/v1",{type:"portalToken",token:e});return new U.BillingClient(t)}return a.billing},[a,e])}function is(e,a){const t=_(a),[o,n]=r.useState(null),[u,i]=r.useState(!0),[c,d]=r.useState(null),l=r.useCallback(async()=>{i(!0),d(null);try{const g=await t.getCustomer(e);n(g)}catch(g){d(g instanceof Error?g.message:"Failed to load subscription")}finally{i(!1)}},[t,e]);return r.useEffect(()=>{l()},[l]),{customer:o,isLoading:u,error:c,refresh:l}}function ls(e,a){const t=_(a),[o,n]=r.useState([]),[u,i]=r.useState(!0),[c,d]=r.useState(null),l=r.useCallback(async()=>{i(!0),d(null);try{const g=await t.getInvoices(e);n(g)}catch(g){d(g instanceof Error?g.message:"Failed to load invoices")}finally{i(!1)}},[t,e]);return r.useEffect(()=>{l()},[l]),{invoices:o,isLoading:u,error:c,refresh:l}}function cs(e,a){const t=_(a),[o,n]=r.useState([]),[u,i]=r.useState(!0),[c,d]=r.useState(null),l=r.useCallback(async()=>{i(!0),d(null);try{const g=await t.getCurrentUsage(e);n(g)}catch(g){d(g instanceof Error?g.message:"Failed to load usage")}finally{i(!1)}},[t,e]);return r.useEffect(()=>{l()},[l]),{usage:o,isLoading:u,error:c,refresh:l}}const Us={active:"ss-badge-active"};function ds({customerId:e,portalToken:a,onChangePlan:t,onCancel:o,appearance:n}){const{appearance:u}=I(),{customer:i,isLoading:c,error:d}=is(e,a),l=n??u;return s.jsx(M,{appearance:l,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}),i&&!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:i.name||i.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 ${Us.active}`,children:"Active"})})]}),s.jsxs("div",{className:"ss-btn-group",children:[t&&s.jsx("button",{type:"button",className:"ss-btn ss-btn-primary",onClick:t,children:"Change plan"}),o&&s.jsx("button",{type:"button",className:"ss-btn ss-btn-danger",onClick:o,children:"Cancel subscription"})]})]})]})})}const Rs={paid:"ss-badge-active",open:"ss-badge-trialing",draft:"ss-badge-paused",void:"ss-badge-canceled",uncollectible:"ss-badge-past-due"};function Vs(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function Hs(e){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(e/100)}function us({customerId:e,portalToken:a,appearance:t}){const{appearance:o}=I(),{invoices:n,isLoading:u,error:i}=ls(e,a),c=t??o,d=[...n].sort((l,g)=>new Date(g.createdAt).getTime()-new Date(l.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..."]}),i&&s.jsx("div",{className:"ss-global-error",children:i}),!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(l=>s.jsxs("tr",{className:"ss-tr",children:[s.jsx("td",{className:"ss-td",children:Vs(l.createdAt)}),s.jsx("td",{className:"ss-td",children:Hs(l.amountCents)}),s.jsx("td",{className:"ss-td",children:s.jsx("span",{className:`ss-badge ${Rs[l.status]||""}`,children:l.status})}),s.jsx("td",{className:"ss-td",children:l.pdfUrl?s.jsx("a",{className:"ss-link",href:l.pdfUrl,target:"_blank",rel:"noopener noreferrer",children:"Download"}):"—"})]},l.id))})]})]})})}function ps({customerId:e,limits:a,portalToken:t,appearance:o}){const{appearance:n}=I(),{usage:u,isLoading:i,error:c}=cs(e,t),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"}),i&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading..."]}),c&&s.jsx("div",{className:"ss-global-error",children:c}),!i&&u.length===0&&s.jsx("p",{className:"ss-empty",children:"No usage data."}),!i&&u.map(l=>{const g=a==null?void 0:a[l.metric],p=g?Math.min(100,l.total/g*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:l.metric}),s.jsxs("span",{className:"ss-usage-value",children:[l.total.toLocaleString(),g?` / ${g.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}%`}})})]},l.metric)})]})})}function qs({customerId:e,portalToken:a,limits:t,onChangePlan:o,onCancel:n,appearance:u}){const{appearance:i}=I(),c=u??i,[d,l]=r.useState("subscription"),g=[{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:g.map(p=>s.jsx("button",{type:"button",className:`ss-tab ${d===p.id?"ss-tab-active":""}`,onClick:()=>l(p.id),children:p.label},p.id))}),s.jsxs("div",{className:"ss-tab-content",children:[d==="subscription"&&s.jsx(ds,{customerId:e,portalToken:a,onChangePlan:o,onCancel:n}),d==="invoices"&&s.jsx(us,{customerId:e,portalToken:a}),d==="usage"&&s.jsx(ps,{customerId:e,portalToken:a,limits:t})]})]})})}function Ws({customerId:e,portalToken:a,onApplied:t,appearance:o}){const{appearance:n}=I(),u=_(a),i=o??n,[c,d]=r.useState(""),[l,g]=r.useState(!1),[p,x]=r.useState(null),[m,j]=r.useState(null),b=r.useCallback(async C=>{if(C.preventDefault(),!!c.trim()){g(!0),x(null),j(null);try{const h=await u.applyCoupon(e,c.trim());j(`Coupon applied! ${h.discountType==="percent"?`${h.amount}% off`:`$${(h.amount/100).toFixed(2)} off`}`),d(""),t==null||t(h)}catch(h){x(h instanceof Error?h.message:"Invalid coupon code")}finally{g(!1)}}},[u,e,c,t]);return s.jsx(M,{appearance:i,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:C=>d(C.target.value),required:!0})]}),s.jsxs("button",{type:"submit",className:"ss-btn ss-btn-primary",disabled:l||!c.trim(),children:[l&&s.jsx("span",{className:"ss-spinner"}),"Apply"]})]})]})})}function _s(){const{client:e}=I();return{report:e.report}}function ss(){const{client:e}=I(),[a,t]=r.useState(null),[o,n]=r.useState(!1),[u,i]=r.useState(null),c=r.useCallback(async d=>{n(!0),i(null);try{const l=await e.report.executeQuery(d);return t(l),l}catch(l){return i(l instanceof Error?l.message:"Query failed"),null}finally{n(!1)}},[e]);return{result:a,execute:c,isLoading:o,error:u}}function hs(e){const{client:a}=I(),[t,o]=r.useState(null),[n,u]=r.useState(!0),[i,c]=r.useState(null),d=r.useCallback(async()=>{u(!0),c(null);try{const l=await a.report.listQueries(e);o(l)}catch(l){c(l instanceof Error?l.message:"Failed to load queries")}finally{u(!1)}},[a,e]);return r.useEffect(()=>{d()},[d]),{queries:(t==null?void 0:t.data)??[],meta:t==null?void 0:t.meta,isLoading:n,error:i,refresh:d}}function Gs(e){const{client:a}=I(),[t,o]=r.useState(null),[n,u]=r.useState(!0),[i,c]=r.useState(null),d=r.useCallback(async()=>{u(!0),c(null);try{const l=await a.report.getDashboard(e);o(l)}catch(l){c(l instanceof Error?l.message:"Failed to load dashboard")}finally{u(!1)}},[a,e]);return r.useEffect(()=>{d()},[d]),{dashboard:t,isLoading:n,error:i,refresh:d}}function Ys(e,a,t="https://api.saas-support.com/v1"){const o=r.useMemo(()=>{const p=new U.Transport(t,{type:"embedToken",token:e});return new U.ReportClient(p)},[e,t]),[n,u]=r.useState(null),[i,c]=r.useState(!0),[d,l]=r.useState(null),g=r.useCallback(async()=>{c(!0),l(null);try{const p=await o.getDashboard(a);u(p)}catch(p){l(p instanceof Error?p.message:"Failed to load dashboard")}finally{c(!1)}},[o,a]);return r.useEffect(()=>{g()},[g]),{dashboard:n,reportClient:o,isLoading:i,error:d,refresh:g}}function Qs({onResult:e,mode:a="both",placeholder:t,appearance:o}){const{appearance:n}=I(),{execute:u,isLoading:i,error:c}=ss(),d=o??n,[l,g]=r.useState(""),[p,x]=r.useState(a==="sql"?"sql":"nl"),m=r.useCallback(async j=>{if(j.preventDefault(),!l.trim())return;const C=await u(p==="sql"?{sql:l}:{naturalLanguage:l});C&&(e==null||e(C))},[l,p,u,e]);return s.jsx(M,{appearance:d,children:s.jsxs("div",{className:"ss-card ss-card-wide",children:[a==="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:()=>x("nl"),children:"Natural Language"}),s.jsx("button",{type:"button",className:`ss-tab ${p==="sql"?"ss-tab-active":""}`,onClick:()=>x("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:t??(p==="sql"?"SELECT ...":"Ask a question about your data..."),value:l,onChange:j=>g(j.target.value),rows:3})}),s.jsxs("button",{type:"submit",className:"ss-btn ss-btn-primary",disabled:i||!l.trim(),children:[i&&s.jsx("span",{className:"ss-spinner"}),"Run query"]})]})]})})}function xs({columns:e,rows:a,sortable:t=!0,maxRows:o,appearance:n}){const{appearance:u}=I(),i=n??u,[c,d]=r.useState(null),[l,g]=r.useState("asc"),p=r.useMemo(()=>c?[...a].sort((b,C)=>{const h=b[c],v=C[c];if(h==null&&v==null)return 0;if(h==null)return 1;if(v==null)return-1;if(typeof h=="number"&&typeof v=="number")return l==="asc"?h-v:v-h;const N=String(h),$=String(v);return l==="asc"?N.localeCompare($):$.localeCompare(N)}):a,[a,c,l]),x=o?p.slice(0,o):p,m=b=>{t&&(c===b?g(C=>C==="asc"?"desc":"asc"):(d(b),g("asc")))};function j(b){return b==null?"":typeof b=="object"?JSON.stringify(b):String(b)}return s.jsx(M,{appearance:i,children:s.jsxs("div",{className:"ss-table-container",children:[s.jsxs("table",{className:"ss-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:e.map(b=>s.jsxs("th",{className:`ss-th ${t?"ss-th-sortable":""} ${c===b?l==="asc"?"ss-sorted-asc":"ss-sorted-desc":""}`,onClick:()=>m(b),children:[b,c===b&&s.jsx("span",{className:"ss-sort-indicator",children:l==="asc"?" ▲":" ▼"})]},b))})}),s.jsx("tbody",{children:x.map((b,C)=>s.jsx("tr",{className:"ss-tr",children:e.map(h=>s.jsx("td",{className:"ss-td",children:j(b[h])},h))},C))})]}),o&&a.length>o&&s.jsxs("div",{className:"ss-table-footer",children:["Showing ",o," of ",a.length," rows"]})]})})}function Js(e,a="#6366f1"){const t=parseInt(a.replace("#","").slice(0,2),16),o=[];for(let n=0;n<e;n++){const u=(t+n*Math.floor(360/Math.max(e,1)))%360;o.push(`hsl(${u}, 65%, 55%)`)}return o}function Zs({labels:e,values:a,w:t,h:o,colors:n}){const u=Math.max(...a,1),i=40,c=t-i*2,d=o-i*2,l=Math.max(1,c/e.length-4);return s.jsxs("g",{children:[s.jsx("line",{x1:i,y1:o-i,x2:t-i,y2:o-i,stroke:"#ccc",strokeWidth:1}),a.map((g,p)=>{const x=g/u*d,m=i+c/e.length*p+2,j=o-i-x;return s.jsxs("g",{children:[s.jsx("rect",{x:m,y:j,width:l,height:x,fill:n[p%n.length],rx:2}),s.jsx("text",{x:m+l/2,y:o-i+14,textAnchor:"middle",fontSize:10,fill:"#666",children:e[p].length>8?e[p].slice(0,8)+"...":e[p]})]},p)})]})}function Ks({labels:e,values:a,w:t,h:o,colors:n}){const u=Math.max(...a,1),i=40,c=t-i*2,d=o-i*2,l=e.length>1?c/(e.length-1):0,g=a.map((p,x)=>{const m=i+l*x,j=o-i-p/u*d;return`${m},${j}`});return s.jsxs("g",{children:[[.25,.5,.75,1].map(p=>{const x=o-i-p*d;return s.jsx("line",{x1:i,y1:x,x2:t-i,y2:x,stroke:"#eee",strokeWidth:1},p)}),s.jsx("polyline",{points:g.join(" "),fill:"none",stroke:n[0],strokeWidth:2}),a.map((p,x)=>{const m=i+l*x,j=o-i-p/u*d;return s.jsx("circle",{cx:m,cy:j,r:4,fill:n[0]},x)})]})}function Xs({labels:e,values:a,w:t,h:o,colors:n}){const u=a.reduce((x,m)=>x+m,0)||1,i=t/2,c=o/2-20,d=Math.min(t,o)/2-40,l=2*Math.PI*d;let g=0;const p=a.map((x,m)=>{const j=x/u,b=j*l,C={dash:b,offset:g,color:n[m%n.length],label:e[m],pct:j};return g+=b,C});return s.jsxs("g",{children:[p.map((x,m)=>s.jsx("circle",{cx:i,cy:c,r:d,fill:"none",stroke:x.color,strokeWidth:d*.6,strokeDasharray:`${x.dash} ${l-x.dash}`,strokeDashoffset:-x.offset,transform:`rotate(-90 ${i} ${c})`},m)),s.jsx("g",{transform:`translate(${i-e.length*30}, ${o-20})`,children:p.slice(0,6).map((x,m)=>s.jsxs("g",{transform:`translate(${m*60}, 0)`,children:[s.jsx("rect",{width:10,height:10,fill:x.color,rx:2}),s.jsx("text",{x:14,y:9,fontSize:9,fill:"#666",children:x.label.length>6?x.label.slice(0,6)+"..":x.label})]},m))})]})}function gs({type:e,data:a,title:t,width:o=400,height:n=300,appearance:u}){const{appearance:i}=I(),c=u??i,d=r.useMemo(()=>Js(a.labels.length),[a.labels.length]);return s.jsx(M,{appearance:c,children:s.jsxs("div",{className:"ss-chart-container",children:[t&&s.jsx("h3",{className:"ss-chart-title",children:t}),s.jsxs("svg",{viewBox:`0 0 ${o} ${n}`,width:"100%",style:{maxWidth:o},children:[e==="bar"&&s.jsx(Zs,{labels:a.labels,values:a.values,w:o,h:n,colors:d}),e==="line"&&s.jsx(Ks,{labels:a.labels,values:a.values,w:o,h:n,colors:d}),e==="pie"&&s.jsx(Xs,{labels:a.labels,values:a.values,w:o,h:n,colors:d})]})]})})}function se({dashboardId:e,embedToken:a,baseUrl:t,refreshInterval:o,appearance:n}){const u=I(),i=n??(u==null?void 0:u.appearance),c=r.useMemo(()=>{if(a){const h=t??"https://api.saas-support.com/v1",v=new U.Transport(h,{type:"embedToken",token:a});return new U.ReportClient(v)}return u.client.report},[a,t,u]),[d,l]=r.useState([]),[g,p]=r.useState({}),[x,m]=r.useState(!0),[j,b]=r.useState(null),C=r.useCallback(async()=>{m(!0),b(null);try{const h=await c.getDashboard(e),v=JSON.parse(h.layoutJson||"[]");l(v);const N={};for(const $ of v)try{const P=await c.listQueries({search:$.queryId,perPage:1});if(P.data.length>0&&P.data[0].generatedSql){const O=await c.executeQuery({sql:P.data[0].generatedSql});N[$.queryId]=O}}catch{}p(N)}catch(h){b(h instanceof Error?h.message:"Failed to load dashboard")}finally{m(!1)}},[c,e]);return r.useEffect(()=>{C()},[C]),r.useEffect(()=>{if(!o||o<=0)return;const h=setInterval(C,o*1e3);return()=>clearInterval(h)},[o,C]),s.jsx(M,{appearance:i,children:s.jsxs("div",{className:"ss-dashboard-grid",children:[x&&s.jsxs("div",{className:"ss-loading",children:[s.jsx("span",{className:"ss-spinner"})," Loading dashboard..."]}),j&&s.jsx("div",{className:"ss-global-error",children:j}),!x&&d.map((h,v)=>{const N=g[h.queryId];if(!N)return null;const $=N.columns.length>=2?{labels:N.rows.map(P=>String(P[N.columns[0]]??"")),values:N.rows.map(P=>Number(P[N.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(xs,{columns:N.columns,rows:N.rows,maxRows:50}):s.jsx(gs,{type:h.chartType||"bar",data:$,width:h.w,height:h.h})]},v)})]})})}function ee(e){return new Date(e).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric"})}function ae({onSelectQuery:e,onRunQuery:a,appearance:t}){const{appearance:o}=I(),{queries:n,isLoading:u,error:i}=hs(),{execute:c,isLoading:d}=ss(),l=t??o,g=r.useCallback(async p=>{if(!p.generatedSql)return;const x=await c({sql:p.generatedSql});x&&(a==null||a(x))},[c,a]);return s.jsx(M,{appearance:l,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..."]}),i&&s.jsx("div",{className:"ss-global-error",children:i}),!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:()=>e==null?void 0:e(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:ee(p.createdAt)}),s.jsx("button",{type:"button",className:"ss-btn ss-btn-sm ss-btn-primary",disabled:d||!p.generatedSql,onClick:x=>{x.stopPropagation(),g(p)},children:d?s.jsx("span",{className:"ss-spinner"}):"Run"})]})]},p.id))]})})}function te({embedToken:e,dashboardId:a,baseUrl:t="https://api.saas-support.com/v1",refreshInterval:o,appearance:n}){const u=r.useMemo(()=>{const b=new U.Transport(t,{type:"embedToken",token:e});return new U.ReportClient(b)},[e,t]),[i,c]=r.useState([]),[d,l]=r.useState(!0),[g,p]=r.useState(null),x=r.useMemo(()=>Q(n),[n]),m=r.useMemo(()=>J(x),[x]),j=r.useCallback(async()=>{l(!0),p(null);try{const b=await u.getDashboard(a),C=JSON.parse(b.layoutJson||"[]"),h=await Promise.all(C.map(async v=>{try{const N=await u.listQueries({search:v.queryId,perPage:1});if(N.data.length>0&&N.data[0].generatedSql){const $=await u.executeQuery({sql:N.data[0].generatedSql});return{...v,result:$}}}catch{}return v}));c(h)}catch(b){p(b instanceof Error?b.message:"Failed to load dashboard")}finally{l(!1)}},[u,a]);return r.useEffect(()=>{j()},[j]),r.useEffect(()=>{if(!o||o<=0)return;const b=setInterval(j,o*1e3);return()=>clearInterval(b)},[o,j]),s.jsx("div",{ref:b=>{if(!b||b.shadowRoot)return;const C=b.attachShadow({mode:"open"}),h=document.createElement("style");h.textContent=m,C.appendChild(h);const v=document.createElement("div");C.appendChild(v)},style:{display:"contents"},children:s.jsxs("div",{className:"ss-dashboard-grid",children:[d&&s.jsx("div",{className:"ss-loading",children:"Loading dashboard..."}),g&&s.jsx("div",{className:"ss-global-error",children:g}),!d&&i.map((b,C)=>{if(!b.result)return null;const{columns:h,rows:v}=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(N=>s.jsx("th",{className:"ss-th",children:N},N))})}),s.jsx("tbody",{children:v.slice(0,50).map((N,$)=>s.jsx("tr",{className:"ss-tr",children:h.map(P=>s.jsx("td",{className:"ss-td",children:String(N[P]??"")},P))},$))})]})]},C)})]})})}exports.SaaSError=U.SaaSError;exports.SaaSSupport=U.SaaSSupport;exports.isMfaRequired=U.isMfaRequired;exports.Chart=gs;exports.CouponInput=Ws;exports.DashboardView=se;exports.DataTable=xs;exports.InvoiceHistory=us;exports.OrgSwitcher=Ds;exports.PaymentPortal=qs;exports.PricingTable=As;exports.QueryInput=Qs;exports.ReportEmbed=te;exports.SaaSContext=Z;exports.SaaSProvider=vs;exports.SavedQueryList=ae;exports.SettingsPanel=os;exports.SignIn=Cs;exports.SignUp=zs;exports.SubscriptionStatus=ds;exports.UsageDisplay=ps;exports.UserButton=Bs;exports.UserProfile=Ls;exports.useAuth=W;exports.useBilling=Ms;exports.useDashboard=Gs;exports.useDeleteAccount=as;exports.useEmbedDashboard=Ys;exports.useInvoices=ls;exports.useOrg=H;exports.useProfile=X;exports.useQuery=ss;exports.useReport=_s;exports.useSaaSContext=I;exports.useSavedQueries=hs;exports.useSignIn=K;exports.useSignUp=es;exports.useSubscription=is;exports.useUsage=cs;exports.useUser=$s;
package/dist/react.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { jsx as e, jsxs as t, Fragment as j } from "react/jsx-runtime";
2
- import { createContext as ma, useContext as fa, useState as g, useEffect as U, useRef as _, useCallback as k, useMemo as G } from "react";
2
+ import { createContext as ma, useContext as fa, useState as g, useEffect as V, useRef as _, useCallback as k, useMemo as G } from "react";
3
3
  import { SaaSSupport as ba, isMfaRequired as xa, BillingClient as ya, Transport as Q, ReportClient as ta } from "./index.js";
4
4
  import { SaaSError as Ne } from "./index.js";
5
5
  import { createPortal as va } from "react-dom";
@@ -12,7 +12,7 @@ function A() {
12
12
  }
13
13
  function te({ publishableKey: a, apiKey: s, baseUrl: r, appearance: o, children: n }) {
14
14
  const [u] = g(() => new ba({ publishableKey: a, apiKey: s, baseUrl: r })), [i, l] = g(null), [d, c] = g(!1), [f, p] = g(null);
15
- return U(() => {
15
+ return V(() => {
16
16
  let m = !1;
17
17
  u.load().then(async () => {
18
18
  if (m) return;
@@ -1424,6 +1424,7 @@ function ea(a) {
1424
1424
  cursor: pointer;
1425
1425
  transition: background 0.15s, box-shadow 0.15s;
1426
1426
  font-family: ${a.authFontBody};
1427
+ max-width: 200px;
1427
1428
  }
1428
1429
 
1429
1430
  .ss-auth-user-trigger:hover {
@@ -2243,6 +2244,25 @@ function ea(a) {
2243
2244
  margin: 0;
2244
2245
  }
2245
2246
 
2247
+ .ss-auth-settings-back {
2248
+ display: flex;
2249
+ align-items: center;
2250
+ justify-content: center;
2251
+ width: 36px;
2252
+ height: 36px;
2253
+ border-radius: 8px;
2254
+ border: none;
2255
+ background: none;
2256
+ cursor: pointer;
2257
+ color: ${a.authOnSurfaceVariant};
2258
+ transition: background 0.15s, color 0.15s;
2259
+ }
2260
+ .ss-auth-settings-back:hover {
2261
+ background: ${a.authSurfaceContainer};
2262
+ color: ${a.authOnSurface};
2263
+ }
2264
+ .ss-auth-settings-back .material-symbols-outlined { font-size: 22px; }
2265
+
2246
2266
  .ss-auth-settings-layout {
2247
2267
  display: flex;
2248
2268
  flex: 1;
@@ -2301,6 +2321,9 @@ function ea(a) {
2301
2321
  flex: 1;
2302
2322
  overflow-y: auto;
2303
2323
  padding: 32px;
2324
+ max-width: 720px;
2325
+ margin: 0 auto;
2326
+ width: 100%;
2304
2327
  }
2305
2328
 
2306
2329
  .ss-auth-settings-content h3 {
@@ -2480,7 +2503,7 @@ function ea(a) {
2480
2503
  }
2481
2504
  function H({ children: a, appearance: s }) {
2482
2505
  const r = _(null), [o, n] = g(null);
2483
- U(() => {
2506
+ V(() => {
2484
2507
  var f;
2485
2508
  if (!r.current || r.current.shadowRoot) {
2486
2509
  n(((f = r.current) == null ? void 0 : f.shadowRoot) ?? null);
@@ -2500,7 +2523,7 @@ function H({ children: a, appearance: s }) {
2500
2523
  d.textContent = ea(l), i.appendChild(d);
2501
2524
  const c = document.createElement("div");
2502
2525
  i.appendChild(c), n(i);
2503
- }, []), U(() => {
2526
+ }, []), V(() => {
2504
2527
  if (!o) return;
2505
2528
  const i = o.querySelector("style");
2506
2529
  if (i) {
@@ -2604,7 +2627,7 @@ function Y() {
2604
2627
  f(!1);
2605
2628
  }
2606
2629
  }, [a, o]);
2607
- U(() => {
2630
+ V(() => {
2608
2631
  b();
2609
2632
  }, [b]);
2610
2633
  const w = k(async ($) => {
@@ -2661,13 +2684,13 @@ function Y() {
2661
2684
  } catch (E) {
2662
2685
  return m(E instanceof Error ? E.message : "Failed to update member role"), !1;
2663
2686
  }
2664
- }, [a]), F = k(async ($, x) => {
2687
+ }, [a]), B = k(async ($, x) => {
2665
2688
  try {
2666
2689
  return await a.auth.removeMember($, x), i((S) => S.filter((E) => E.userId !== x)), !0;
2667
2690
  } catch (S) {
2668
2691
  return m(S instanceof Error ? S.message : "Failed to remove member"), !1;
2669
2692
  }
2670
- }, [a]), B = k(async ($) => {
2693
+ }, [a]), F = k(async ($) => {
2671
2694
  try {
2672
2695
  const x = await a.auth.listMembers($);
2673
2696
  i(x);
@@ -2692,8 +2715,8 @@ function Y() {
2692
2715
  refreshInvites: C,
2693
2716
  revokeInvite: P,
2694
2717
  updateMemberRole: I,
2695
- removeMember: F,
2696
- refreshMembers: B
2718
+ removeMember: B,
2719
+ refreshMembers: F
2697
2720
  };
2698
2721
  }
2699
2722
  function Ca() {
@@ -2769,6 +2792,7 @@ const ia = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d=
2769
2792
  security: "security",
2770
2793
  errorOutline: "error_outline",
2771
2794
  info: "info",
2795
+ arrowBack: "arrow_back",
2772
2796
  arrowForward: "arrow_forward",
2773
2797
  verified: "verified",
2774
2798
  token: "token",
@@ -2785,16 +2809,16 @@ const ia = '<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg"><path d=
2785
2809
  personRemove: "person_remove"
2786
2810
  };
2787
2811
  function re({ appearance: a, signUpUrl: s, onSignUp: r }) {
2788
- const { appearance: o, settings: n } = A(), { signIn: u, signInWithOAuth: i, submitMfaCode: l, isLoading: d, error: c, setError: f } = na(), p = a ?? o, [m, b] = g(""), [w, y] = g(""), [O, h] = g(!1), [N, C] = g(!1), [P, I] = g(""), [F, B] = g(["", "", "", "", "", ""]), $ = _([]), x = k(
2812
+ const { appearance: o, settings: n } = A(), { signIn: u, signInWithOAuth: i, submitMfaCode: l, isLoading: d, error: c, setError: f } = na(), p = a ?? o, [m, b] = g(""), [w, y] = g(""), [O, h] = g(!1), [N, C] = g(!1), [P, I] = g(""), [B, F] = g(["", "", "", "", "", ""]), $ = _([]), x = k(
2789
2813
  async (T) => {
2790
2814
  if (T.preventDefault(), N) {
2791
- await l(P, F.join(""));
2815
+ await l(P, B.join(""));
2792
2816
  return;
2793
2817
  }
2794
2818
  const z = await u(m, w);
2795
2819
  z && xa(z) && (I(z.mfaToken), C(!0), f(null));
2796
2820
  },
2797
- [m, w, N, P, F, u, l, f]
2821
+ [m, w, N, P, B, u, l, f]
2798
2822
  ), S = k(
2799
2823
  async (T) => {
2800
2824
  await i(T);
@@ -2804,21 +2828,21 @@ function re({ appearance: a, signUpUrl: s, onSignUp: r }) {
2804
2828
  var W;
2805
2829
  if (!/^\d*$/.test(z)) return;
2806
2830
  const L = z.slice(-1);
2807
- B((K) => {
2831
+ F((K) => {
2808
2832
  const J = [...K];
2809
2833
  return J[T] = L, J;
2810
2834
  }), L && T < 5 && ((W = $.current[T + 1]) == null || W.focus());
2811
2835
  }, []), D = k((T, z) => {
2812
2836
  var L;
2813
- z.key === "Backspace" && !F[T] && T > 0 && ((L = $.current[T - 1]) == null || L.focus());
2814
- }, [F]), V = (n == null ? void 0 : n.googleEnabled) || (n == null ? void 0 : n.githubEnabled);
2837
+ z.key === "Backspace" && !B[T] && T > 0 && ((L = $.current[T - 1]) == null || L.focus());
2838
+ }, [B]), U = (n == null ? void 0 : n.googleEnabled) || (n == null ? void 0 : n.githubEnabled);
2815
2839
  return /* @__PURE__ */ e(H, { appearance: p, children: /* @__PURE__ */ e("div", { className: "ss-auth-card", children: /* @__PURE__ */ t("div", { className: "ss-auth-card-body", children: [
2816
2840
  /* @__PURE__ */ t("div", { className: "ss-auth-header", children: [
2817
2841
  /* @__PURE__ */ e("div", { className: "ss-auth-brand-icon", children: /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.token }) }),
2818
2842
  /* @__PURE__ */ e("h1", { className: "ss-auth-title", children: "Sign in to your account" }),
2819
2843
  /* @__PURE__ */ e("p", { className: "ss-auth-subtitle", children: "Welcome back to your workspace" })
2820
2844
  ] }),
2821
- !N && V && /* @__PURE__ */ t(j, { children: [
2845
+ !N && U && /* @__PURE__ */ t(j, { children: [
2822
2846
  /* @__PURE__ */ t("div", { className: "ss-auth-oauth-grid", children: [
2823
2847
  (n == null ? void 0 : n.googleEnabled) && /* @__PURE__ */ t(
2824
2848
  "button",
@@ -2858,7 +2882,7 @@ function re({ appearance: a, signUpUrl: s, onSignUp: r }) {
2858
2882
  /* @__PURE__ */ e("div", { className: "ss-auth-mfa-divider", children: /* @__PURE__ */ e("span", { children: "Verification Required" }) }),
2859
2883
  /* @__PURE__ */ t("div", { className: "ss-auth-field", children: [
2860
2884
  /* @__PURE__ */ e("label", { className: "ss-auth-label", children: "6-Digit Code" }),
2861
- /* @__PURE__ */ e("div", { className: "ss-auth-mfa-group", children: F.map((T, z) => /* @__PURE__ */ e(
2885
+ /* @__PURE__ */ e("div", { className: "ss-auth-mfa-group", children: B.map((T, z) => /* @__PURE__ */ e(
2862
2886
  "input",
2863
2887
  {
2864
2888
  ref: (L) => {
@@ -2936,7 +2960,7 @@ function re({ appearance: a, signUpUrl: s, onSignUp: r }) {
2936
2960
  {
2937
2961
  className: "ss-auth-link",
2938
2962
  onClick: () => {
2939
- C(!1), B(["", "", "", "", "", ""]), f(null);
2963
+ C(!1), F(["", "", "", "", "", ""]), f(null);
2940
2964
  },
2941
2965
  children: "Back to sign in"
2942
2966
  }
@@ -2962,12 +2986,12 @@ function ne({ appearance: a, signInUrl: s, onSignIn: r }) {
2962
2986
  await u(p, b);
2963
2987
  },
2964
2988
  [p, b, y, n, u]
2965
- ), F = k(
2989
+ ), B = k(
2966
2990
  async (x) => {
2967
2991
  await c(x);
2968
2992
  },
2969
2993
  [c]
2970
- ), B = (n == null ? void 0 : n.googleEnabled) || (n == null ? void 0 : n.githubEnabled), $ = C || l;
2994
+ ), F = (n == null ? void 0 : n.googleEnabled) || (n == null ? void 0 : n.githubEnabled), $ = C || l;
2971
2995
  return /* @__PURE__ */ e(H, { appearance: f, children: /* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", width: "100%", maxWidth: "520px" }, children: [
2972
2996
  /* @__PURE__ */ t("div", { className: "ss-auth-header", children: [
2973
2997
  /* @__PURE__ */ e("div", { className: "ss-auth-brand-icon-gradient", children: /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.autoAwesome }) }),
@@ -2975,14 +2999,14 @@ function ne({ appearance: a, signInUrl: s, onSignIn: r }) {
2975
2999
  /* @__PURE__ */ e("p", { className: "ss-auth-subtitle", children: "Join the ecosystem" })
2976
3000
  ] }),
2977
3001
  /* @__PURE__ */ e("div", { className: "ss-auth-card", children: /* @__PURE__ */ t("div", { className: "ss-auth-card-body", children: [
2978
- B && /* @__PURE__ */ t(j, { children: [
3002
+ F && /* @__PURE__ */ t(j, { children: [
2979
3003
  /* @__PURE__ */ t("div", { className: "ss-auth-oauth-grid", children: [
2980
3004
  (n == null ? void 0 : n.googleEnabled) && /* @__PURE__ */ t(
2981
3005
  "button",
2982
3006
  {
2983
3007
  type: "button",
2984
3008
  className: "ss-auth-btn-social",
2985
- onClick: () => F("google"),
3009
+ onClick: () => B("google"),
2986
3010
  disabled: i,
2987
3011
  children: [
2988
3012
  /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: ia } }),
@@ -2995,7 +3019,7 @@ function ne({ appearance: a, signInUrl: s, onSignIn: r }) {
2995
3019
  {
2996
3020
  type: "button",
2997
3021
  className: "ss-auth-btn-social",
2998
- onClick: () => F("github"),
3022
+ onClick: () => B("github"),
2999
3023
  disabled: i,
3000
3024
  children: [
3001
3025
  /* @__PURE__ */ e("span", { dangerouslySetInnerHTML: { __html: la } }),
@@ -3091,19 +3115,19 @@ function ne({ appearance: a, signInUrl: s, onSignIn: r }) {
3091
3115
  const M = 320, q = 128;
3092
3116
  function za({ file: a, onCrop: s, onCancel: r }) {
3093
3117
  const o = _(null), n = _(null), [u, i] = g(1), [l, d] = g({ x: 0, y: 0 }), [c, f] = g(!1), p = _({ x: 0, y: 0, ox: 0, oy: 0 }), [m, b] = g(!1);
3094
- U(() => {
3118
+ V(() => {
3095
3119
  const h = new Image(), N = URL.createObjectURL(a);
3096
3120
  return h.onload = () => {
3097
3121
  n.current = h, b(!0), d({ x: 0, y: 0 }), i(1);
3098
3122
  }, h.src = N, () => URL.revokeObjectURL(N);
3099
- }, [a]), U(() => {
3123
+ }, [a]), V(() => {
3100
3124
  if (!m || !n.current || !o.current) return;
3101
3125
  const h = o.current.getContext("2d");
3102
3126
  if (!h) return;
3103
3127
  const N = n.current;
3104
3128
  h.clearRect(0, 0, M, M), h.fillStyle = "#111", h.fillRect(0, 0, M, M);
3105
- const C = Math.max(M / N.width, M / N.height) * u, P = N.width * C, I = N.height * C, F = (M - P) / 2 + l.x, B = (M - I) / 2 + l.y;
3106
- h.save(), h.beginPath(), h.arc(M / 2, M / 2, q, 0, Math.PI * 2), h.clip(), h.drawImage(N, F, B, P, I), h.restore(), h.save(), h.fillStyle = "rgba(0, 0, 0, 0.6)", h.fillRect(0, 0, M, M), h.globalCompositeOperation = "destination-out", h.beginPath(), h.arc(M / 2, M / 2, q, 0, Math.PI * 2), h.fill(), h.restore(), h.save(), h.beginPath(), h.arc(M / 2, M / 2, q, 0, Math.PI * 2), h.clip(), h.drawImage(N, F, B, P, I), h.restore(), h.strokeStyle = "rgba(255, 255, 255, 0.4)", h.lineWidth = 2, h.beginPath(), h.arc(M / 2, M / 2, q, 0, Math.PI * 2), h.stroke();
3129
+ const C = Math.max(M / N.width, M / N.height) * u, P = N.width * C, I = N.height * C, B = (M - P) / 2 + l.x, F = (M - I) / 2 + l.y;
3130
+ h.save(), h.beginPath(), h.arc(M / 2, M / 2, q, 0, Math.PI * 2), h.clip(), h.drawImage(N, B, F, P, I), h.restore(), h.save(), h.fillStyle = "rgba(0, 0, 0, 0.6)", h.fillRect(0, 0, M, M), h.globalCompositeOperation = "destination-out", h.beginPath(), h.arc(M / 2, M / 2, q, 0, Math.PI * 2), h.fill(), h.restore(), h.save(), h.beginPath(), h.arc(M / 2, M / 2, q, 0, Math.PI * 2), h.clip(), h.drawImage(N, B, F, P, I), h.restore(), h.strokeStyle = "rgba(255, 255, 255, 0.4)", h.lineWidth = 2, h.beginPath(), h.arc(M / 2, M / 2, q, 0, Math.PI * 2), h.stroke();
3107
3131
  }, [u, l, m]);
3108
3132
  const w = k(
3109
3133
  (h) => {
@@ -3125,8 +3149,8 @@ function za({ file: a, onCrop: s, onCancel: r }) {
3125
3149
  h.width = N, h.height = N;
3126
3150
  const C = h.getContext("2d");
3127
3151
  if (!C) return;
3128
- const P = n.current, I = Math.max(M / P.width, M / P.height) * u, F = P.width * I, B = P.height * I, $ = (M - F) / 2 + l.x - (M / 2 - q), x = (M - B) / 2 + l.y - (M / 2 - q);
3129
- C.beginPath(), C.arc(q, q, q, 0, Math.PI * 2), C.clip(), C.drawImage(P, $, x, F, B), h.toBlob((S) => {
3152
+ const P = n.current, I = Math.max(M / P.width, M / P.height) * u, B = P.width * I, F = P.height * I, $ = (M - B) / 2 + l.x - (M / 2 - q), x = (M - F) / 2 + l.y - (M / 2 - q);
3153
+ C.beginPath(), C.arc(q, q, q, 0, Math.PI * 2), C.clip(), C.drawImage(P, $, x, B, F), h.toBlob((S) => {
3130
3154
  S && s(S);
3131
3155
  }, "image/png");
3132
3156
  }, [u, l, s]), /* @__PURE__ */ t("div", { style: { display: "flex", flexDirection: "column", alignItems: "center", gap: "24px" }, children: [
@@ -3296,7 +3320,10 @@ function Pa({ onClose: a, afterDeleteAccountUrl: s, defaultTab: r = "profile" })
3296
3320
  ];
3297
3321
  return /* @__PURE__ */ t("div", { className: "ss-auth-settings-page", children: [
3298
3322
  /* @__PURE__ */ t("div", { className: "ss-auth-settings-header", children: [
3299
- /* @__PURE__ */ e("h2", { children: "Settings" }),
3323
+ /* @__PURE__ */ t("div", { style: { display: "flex", alignItems: "center", gap: "12px" }, children: [
3324
+ /* @__PURE__ */ e("button", { type: "button", className: "ss-auth-settings-back", onClick: a, children: /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.arrowBack }) }),
3325
+ /* @__PURE__ */ e("h2", { children: "Settings" })
3326
+ ] }),
3300
3327
  /* @__PURE__ */ e("button", { type: "button", className: "ss-auth-modal-close", onClick: a, children: /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.close }) })
3301
3328
  ] }),
3302
3329
  /* @__PURE__ */ t("div", { className: "ss-auth-settings-layout", children: [
@@ -3317,13 +3344,13 @@ function Pa({ onClose: a, afterDeleteAccountUrl: s, defaultTab: r = "profile" })
3317
3344
  o === "profile" && /* @__PURE__ */ e(Oa, { afterDeleteAccountUrl: s }),
3318
3345
  o === "organization" && /* @__PURE__ */ e(Ea, {}),
3319
3346
  o === "people" && /* @__PURE__ */ e(Ia, {}),
3320
- o === "billing" && /* @__PURE__ */ e(Fa, {})
3347
+ o === "billing" && /* @__PURE__ */ e(Ba, {})
3321
3348
  ] })
3322
3349
  ] })
3323
3350
  ] });
3324
3351
  }
3325
3352
  function Oa({ afterDeleteAccountUrl: a }) {
3326
- const { user: s, updateProfile: r, uploadAvatar: o, changePassword: n, isLoading: u, error: i, success: l, setError: d, setSuccess: c } = oa(), { signOut: f } = sa(), { deleteAccount: p, isLoading: m, error: b, setError: w } = Ca(), [y, O] = g((s == null ? void 0 : s.name) ?? ""), [h, N] = g((s == null ? void 0 : s.avatarUrl) ?? ""), [C, P] = g(!1), [I, F] = g(""), [B, $] = g(""), [x, S] = g(""), [E, D] = g(null), [V, T] = g(!1), [z, L] = g(""), W = k(
3353
+ const { user: s, updateProfile: r, uploadAvatar: o, changePassword: n, isLoading: u, error: i, success: l, setError: d, setSuccess: c } = oa(), { signOut: f } = sa(), { deleteAccount: p, isLoading: m, error: b, setError: w } = Ca(), [y, O] = g((s == null ? void 0 : s.name) ?? ""), [h, N] = g((s == null ? void 0 : s.avatarUrl) ?? ""), [C, P] = g(!1), [I, B] = g(""), [F, $] = g(""), [x, S] = g(""), [E, D] = g(null), [U, T] = g(!1), [z, L] = g(""), W = k(
3327
3354
  async (R) => {
3328
3355
  R.preventDefault(), d(null), c(null), await r({ name: y, avatarUrl: h || void 0 });
3329
3356
  },
@@ -3336,17 +3363,17 @@ function Oa({ afterDeleteAccountUrl: a }) {
3336
3363
  [o]
3337
3364
  ), J = k(
3338
3365
  async (R) => {
3339
- if (R.preventDefault(), D(null), d(null), c(null), B !== x) {
3366
+ if (R.preventDefault(), D(null), d(null), c(null), F !== x) {
3340
3367
  D("Passwords do not match");
3341
3368
  return;
3342
3369
  }
3343
- if (B.length < 8) {
3370
+ if (F.length < 8) {
3344
3371
  D("Password must be at least 8 characters");
3345
3372
  return;
3346
3373
  }
3347
- await n(I, B) && (F(""), $(""), S(""));
3374
+ await n(I, F) && (B(""), $(""), S(""));
3348
3375
  },
3349
- [I, B, x, n, d, c]
3376
+ [I, F, x, n, d, c]
3350
3377
  ), ua = k(async () => {
3351
3378
  await p() && (await f(), a && (window.location.href = a));
3352
3379
  }, [p, f, a]), pa = (s == null ? void 0 : s.provider) === "email", ha = z === (s == null ? void 0 : s.email), ga = ((s == null ? void 0 : s.name) || (s == null ? void 0 : s.email) || "?").charAt(0).toUpperCase();
@@ -3434,12 +3461,12 @@ function Oa({ afterDeleteAccountUrl: a }) {
3434
3461
  /* @__PURE__ */ t("form", { onSubmit: J, children: [
3435
3462
  /* @__PURE__ */ t("div", { className: "ss-auth-field", children: [
3436
3463
  /* @__PURE__ */ e("label", { className: "ss-auth-label", children: "Current Password" }),
3437
- /* @__PURE__ */ e("input", { className: "ss-auth-input", type: "password", placeholder: "••••••••••••", value: I, onChange: (R) => F(R.target.value), required: !0 })
3464
+ /* @__PURE__ */ e("input", { className: "ss-auth-input", type: "password", placeholder: "••••••••••••", value: I, onChange: (R) => B(R.target.value), required: !0 })
3438
3465
  ] }),
3439
3466
  /* @__PURE__ */ t("div", { className: "ss-auth-profile-grid", style: { marginBottom: "16px" }, children: [
3440
3467
  /* @__PURE__ */ t("div", { children: [
3441
3468
  /* @__PURE__ */ e("label", { className: "ss-auth-label", children: "New Password" }),
3442
- /* @__PURE__ */ e("input", { className: "ss-auth-input", type: "password", placeholder: "Min. 8 characters", value: B, onChange: (R) => $(R.target.value), required: !0 })
3469
+ /* @__PURE__ */ e("input", { className: "ss-auth-input", type: "password", placeholder: "Min. 8 characters", value: F, onChange: (R) => $(R.target.value), required: !0 })
3443
3470
  ] }),
3444
3471
  /* @__PURE__ */ t("div", { children: [
3445
3472
  /* @__PURE__ */ e("label", { className: "ss-auth-label", children: "Confirm New Password" }),
@@ -3456,7 +3483,7 @@ function Oa({ afterDeleteAccountUrl: a }) {
3456
3483
  /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.errorOutline }),
3457
3484
  /* @__PURE__ */ e("span", { children: b })
3458
3485
  ] }),
3459
- V ? /* @__PURE__ */ t("div", { children: [
3486
+ U ? /* @__PURE__ */ t("div", { children: [
3460
3487
  /* @__PURE__ */ t("div", { className: "ss-auth-field", children: [
3461
3488
  /* @__PURE__ */ e("label", { className: "ss-auth-label", children: "Type your email to confirm" }),
3462
3489
  /* @__PURE__ */ e(
@@ -3521,7 +3548,7 @@ function Oa({ afterDeleteAccountUrl: a }) {
3521
3548
  }
3522
3549
  function Ea() {
3523
3550
  const { selectedOrg: a, updateOrg: s, deleteOrg: r, isLoading: o, error: n, setError: u } = Y(), [i, l] = g((a == null ? void 0 : a.name) ?? ""), [d, c] = g(!1), [f, p] = g(!1), [m, b] = g(!1), [w, y] = g("");
3524
- if (U(() => {
3551
+ if (V(() => {
3525
3552
  a && l(a.name);
3526
3553
  }, [a]), !a)
3527
3554
  return /* @__PURE__ */ t(j, { children: [
@@ -3643,8 +3670,8 @@ function Ia() {
3643
3670
  updateMemberRole: c,
3644
3671
  removeMember: f,
3645
3672
  refreshMembers: p
3646
- } = Y(), [m, b] = g(""), [w, y] = g("member"), [O, h] = g(!1), [N, C] = g(!1), [P, I] = g(null), [F, B] = g(""), [$, x] = g(null);
3647
- if (U(() => {
3673
+ } = Y(), [m, b] = g(""), [w, y] = g("member"), [O, h] = g(!1), [N, C] = g(!1), [P, I] = g(null), [B, F] = g(""), [$, x] = g(null);
3674
+ if (V(() => {
3648
3675
  a && (p(a.id), l(a.id));
3649
3676
  }, [a, p, l]), !a)
3650
3677
  return /* @__PURE__ */ t(j, { children: [
@@ -3658,11 +3685,11 @@ function Ia() {
3658
3685
  z.preventDefault(), C(!1), await i(a.id, m, w) && (b(""), y("member"), C(!0), h(!1), l(a.id));
3659
3686
  }, E = async () => {
3660
3687
  if (!P) return;
3661
- await c(a.id, P.userId, F) && I(null);
3688
+ await c(a.id, P.userId, B) && I(null);
3662
3689
  }, D = async () => {
3663
3690
  if (!$) return;
3664
3691
  await f(a.id, $.userId) && x(null);
3665
- }, V = async (z) => {
3692
+ }, U = async (z) => {
3666
3693
  await d(a.id, z);
3667
3694
  }, T = (z) => z === "owner" ? "ss-auth-role-badge ss-auth-role-badge-owner" : z === "admin" ? "ss-auth-role-badge ss-auth-role-badge-admin" : "ss-auth-role-badge ss-auth-role-badge-member";
3668
3695
  return /* @__PURE__ */ t(j, { children: [
@@ -3745,7 +3772,7 @@ function Ia() {
3745
3772
  className: "ss-auth-icon-btn",
3746
3773
  title: "Edit role",
3747
3774
  onClick: () => {
3748
- I(z), B(z.role);
3775
+ I(z), F(z.role);
3749
3776
  },
3750
3777
  children: /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.edit })
3751
3778
  }
@@ -3784,7 +3811,7 @@ function Ia() {
3784
3811
  type: "button",
3785
3812
  className: "ss-auth-icon-btn ss-auth-icon-btn-danger",
3786
3813
  title: "Revoke invite",
3787
- onClick: () => V(z.id),
3814
+ onClick: () => U(z.id),
3788
3815
  children: /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.close })
3789
3816
  }
3790
3817
  ) })
@@ -3809,8 +3836,8 @@ function Ia() {
3809
3836
  "select",
3810
3837
  {
3811
3838
  className: "ss-auth-input",
3812
- value: F,
3813
- onChange: (z) => B(z.target.value),
3839
+ value: B,
3840
+ onChange: (z) => F(z.target.value),
3814
3841
  style: { cursor: "pointer" },
3815
3842
  children: [
3816
3843
  /* @__PURE__ */ e("option", { value: "admin", children: "Admin" }),
@@ -3855,7 +3882,7 @@ function Ia() {
3855
3882
  ] }) })
3856
3883
  ] });
3857
3884
  }
3858
- function Fa() {
3885
+ function Ba() {
3859
3886
  const { selectedOrg: a } = Y();
3860
3887
  return a ? /* @__PURE__ */ t(j, { children: [
3861
3888
  /* @__PURE__ */ e("h3", { children: "Billing" }),
@@ -3882,10 +3909,10 @@ function oe({
3882
3909
  onOrgChange: n,
3883
3910
  onOrgSettingsClick: u
3884
3911
  }) {
3885
- const { appearance: i } = A(), { user: l, signOut: d } = sa(), c = a ?? i, [f, p] = g(!1), [m, b] = g(!1), [w, y] = g(""), [O, h] = g(null), [N, C] = g(!1), P = _(null), { orgs: I, selectedOrg: F, selectOrg: B, createOrg: $ } = Y(), x = k((E) => {
3912
+ const { appearance: i } = A(), { user: l, signOut: d } = sa(), c = a ?? i, [f, p] = g(!1), [m, b] = g(!1), [w, y] = g(""), [O, h] = g(null), [N, C] = g(!1), P = _(null), { orgs: I, selectedOrg: B, selectOrg: F, createOrg: $ } = Y(), x = k((E) => {
3886
3913
  P.current && !E.composedPath().includes(P.current) && p(!1);
3887
3914
  }, []);
3888
- U(() => {
3915
+ V(() => {
3889
3916
  if (f) {
3890
3917
  const E = setTimeout(() => {
3891
3918
  document.addEventListener("click", x);
@@ -3900,15 +3927,15 @@ function oe({
3900
3927
  E.preventDefault(), h(null), C(!0);
3901
3928
  const D = w.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
3902
3929
  try {
3903
- const V = await $(w, D);
3904
- V && (await B(V.id), n == null || n(V), y(""), p(!1));
3905
- } catch (V) {
3906
- h(V instanceof Error ? V.message : "Failed to create organization");
3930
+ const U = await $(w, D);
3931
+ U && (await F(U.id), n == null || n(U), y(""), p(!1));
3932
+ } catch (U) {
3933
+ h(U instanceof Error ? U.message : "Failed to create organization");
3907
3934
  } finally {
3908
3935
  C(!1);
3909
3936
  }
3910
3937
  },
3911
- [w, $, B, n]
3938
+ [w, $, F, n]
3912
3939
  );
3913
3940
  return l ? /* @__PURE__ */ e(H, { appearance: c, children: /* @__PURE__ */ t("div", { style: { position: "relative", display: "inline-block" }, ref: P, children: [
3914
3941
  /* @__PURE__ */ t(
@@ -3928,7 +3955,7 @@ function oe({
3928
3955
  fontSize: "16px",
3929
3956
  fontWeight: 700
3930
3957
  }, children: (l.name || l.email).charAt(0).toUpperCase() }) }),
3931
- F && /* @__PURE__ */ e("span", { className: "ss-auth-trigger-org-name", children: F.name })
3958
+ B && /* @__PURE__ */ e("span", { className: "ss-auth-trigger-org-name", children: B.name })
3932
3959
  ]
3933
3960
  }
3934
3961
  ),
@@ -3965,18 +3992,18 @@ function oe({
3965
3992
  o && /* @__PURE__ */ t(j, { children: [
3966
3993
  /* @__PURE__ */ e("div", { className: "ss-auth-section-label", children: "Organizations" }),
3967
3994
  /* @__PURE__ */ e("div", { style: { padding: "0 8px 4px" }, children: I.map((E) => {
3968
- const D = (F == null ? void 0 : F.id) === E.id, V = E.name.split(" ").map((T) => T[0]).join("").slice(0, 2).toUpperCase();
3995
+ const D = (B == null ? void 0 : B.id) === E.id, U = E.name.split(" ").map((T) => T[0]).join("").slice(0, 2).toUpperCase();
3969
3996
  return /* @__PURE__ */ t(
3970
3997
  "button",
3971
3998
  {
3972
3999
  type: "button",
3973
4000
  className: `ss-auth-org-item${D ? " ss-auth-org-item-active" : ""}`,
3974
4001
  onClick: async () => {
3975
- p(!1), await B(E.id), n == null || n(E);
4002
+ p(!1), await F(E.id), n == null || n(E);
3976
4003
  },
3977
4004
  children: [
3978
4005
  /* @__PURE__ */ t("div", { className: "ss-auth-org-item-inner", children: [
3979
- /* @__PURE__ */ e("div", { className: `ss-auth-org-avatar${D ? "" : " ss-auth-org-avatar-inactive"}`, children: V }),
4006
+ /* @__PURE__ */ e("div", { className: `ss-auth-org-avatar${D ? "" : " ss-auth-org-avatar-inactive"}`, children: U }),
3980
4007
  /* @__PURE__ */ e("span", { style: { fontFamily: "'Manrope', sans-serif", letterSpacing: "-0.01em" }, children: E.name }),
3981
4008
  E.planName && /* @__PURE__ */ e("span", { className: "ss-auth-plan-badge", children: E.planName })
3982
4009
  ] }),
@@ -4012,13 +4039,13 @@ function oe({
4012
4039
  )
4013
4040
  ] }) })
4014
4041
  ] }),
4015
- F && u && /* @__PURE__ */ e("div", { style: { padding: "0 8px 4px" }, children: /* @__PURE__ */ t(
4042
+ B && u && /* @__PURE__ */ e("div", { style: { padding: "0 8px 4px" }, children: /* @__PURE__ */ t(
4016
4043
  "button",
4017
4044
  {
4018
4045
  type: "button",
4019
4046
  className: "ss-auth-dropdown-action",
4020
4047
  onClick: () => {
4021
- p(!1), u(F);
4048
+ p(!1), u(B);
4022
4049
  },
4023
4050
  children: [
4024
4051
  /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.corporateFare }),
@@ -4053,7 +4080,7 @@ function oe({
4053
4080
  ] }) }) : null;
4054
4081
  }
4055
4082
  function ie({ appearance: a }) {
4056
- const { appearance: s } = A(), { user: r, signOut: o } = sa(), { updateProfile: n, uploadAvatar: u, changePassword: i, isLoading: l, error: d, success: c, setError: f, setSuccess: p } = oa(), m = a ?? s, [b, w] = g((r == null ? void 0 : r.name) ?? ""), [y, O] = g((r == null ? void 0 : r.avatarUrl) ?? ""), [h, N] = g(!1), [C, P] = g(""), [I, F] = g(""), [B, $] = g(""), [x, S] = g(null), E = k(
4083
+ const { appearance: s } = A(), { user: r, signOut: o } = sa(), { updateProfile: n, uploadAvatar: u, changePassword: i, isLoading: l, error: d, success: c, setError: f, setSuccess: p } = oa(), m = a ?? s, [b, w] = g((r == null ? void 0 : r.name) ?? ""), [y, O] = g((r == null ? void 0 : r.avatarUrl) ?? ""), [h, N] = g(!1), [C, P] = g(""), [I, B] = g(""), [F, $] = g(""), [x, S] = g(null), E = k(
4057
4084
  async (L) => {
4058
4085
  L.preventDefault(), f(null), p(null), await n({ name: b, avatarUrl: y || void 0 });
4059
4086
  },
@@ -4064,9 +4091,9 @@ function ie({ appearance: a }) {
4064
4091
  W && (O(W.avatarUrl), N(!1));
4065
4092
  },
4066
4093
  [u]
4067
- ), V = k(
4094
+ ), U = k(
4068
4095
  async (L) => {
4069
- if (L.preventDefault(), S(null), f(null), p(null), I !== B) {
4096
+ if (L.preventDefault(), S(null), f(null), p(null), I !== F) {
4070
4097
  S("Passwords do not match");
4071
4098
  return;
4072
4099
  }
@@ -4074,9 +4101,9 @@ function ie({ appearance: a }) {
4074
4101
  S("Password must be at least 8 characters");
4075
4102
  return;
4076
4103
  }
4077
- await i(C, I) && (P(""), F(""), $(""));
4104
+ await i(C, I) && (P(""), B(""), $(""));
4078
4105
  },
4079
- [C, I, B, i, f, p]
4106
+ [C, I, F, i, f, p]
4080
4107
  );
4081
4108
  if (!r) return null;
4082
4109
  const T = r.provider === "email", z = (r.name || r.email).charAt(0).toUpperCase();
@@ -4163,7 +4190,7 @@ function ie({ appearance: a }) {
4163
4190
  /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.errorOutline }),
4164
4191
  /* @__PURE__ */ e("span", { children: x })
4165
4192
  ] }),
4166
- /* @__PURE__ */ t("form", { onSubmit: V, children: [
4193
+ /* @__PURE__ */ t("form", { onSubmit: U, children: [
4167
4194
  /* @__PURE__ */ t("div", { className: "ss-auth-field", children: [
4168
4195
  /* @__PURE__ */ e("label", { className: "ss-auth-label", children: "Current Password" }),
4169
4196
  /* @__PURE__ */ e(
@@ -4188,7 +4215,7 @@ function ie({ appearance: a }) {
4188
4215
  type: "password",
4189
4216
  placeholder: "Min. 8 characters",
4190
4217
  value: I,
4191
- onChange: (L) => F(L.target.value),
4218
+ onChange: (L) => B(L.target.value),
4192
4219
  required: !0
4193
4220
  }
4194
4221
  )
@@ -4201,7 +4228,7 @@ function ie({ appearance: a }) {
4201
4228
  className: "ss-auth-input",
4202
4229
  type: "password",
4203
4230
  placeholder: "Repeat new password",
4204
- value: B,
4231
+ value: F,
4205
4232
  onChange: (L) => $(L.target.value),
4206
4233
  required: !0
4207
4234
  }
@@ -4249,7 +4276,7 @@ function le({ appearance: a, onOrgChange: s }) {
4249
4276
  const { appearance: r } = A(), { orgs: o, selectedOrg: n, selectOrg: u, createOrg: i, isLoading: l } = Y(), d = a ?? r, [c, f] = g(!1), [p, m] = g(""), [b, w] = g(""), [y, O] = g(null), [h, N] = g(!1), C = _(null), P = k((x) => {
4250
4277
  C.current && !x.composedPath().includes(C.current) && f(!1);
4251
4278
  }, []);
4252
- U(() => {
4279
+ V(() => {
4253
4280
  if (c) {
4254
4281
  const x = setTimeout(() => {
4255
4282
  document.addEventListener("click", P);
@@ -4261,7 +4288,7 @@ function le({ appearance: a, onOrgChange: s }) {
4261
4288
  }, [c, P]);
4262
4289
  const I = k((x) => {
4263
4290
  m(x), w(x.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, ""));
4264
- }, []), F = k(
4291
+ }, []), B = k(
4265
4292
  async (x) => {
4266
4293
  x.preventDefault(), O(null), N(!0);
4267
4294
  try {
@@ -4276,7 +4303,7 @@ function le({ appearance: a, onOrgChange: s }) {
4276
4303
  [p, b, i, u, s]
4277
4304
  );
4278
4305
  if (l) return null;
4279
- const B = (n == null ? void 0 : n.name) ?? (o.length === 0 ? "No organization" : "Select organization"), $ = n ? n.name.split(" ").map((x) => x[0]).join("").slice(0, 2).toUpperCase() : "--";
4306
+ const F = (n == null ? void 0 : n.name) ?? (o.length === 0 ? "No organization" : "Select organization"), $ = n ? n.name.split(" ").map((x) => x[0]).join("").slice(0, 2).toUpperCase() : "--";
4280
4307
  return /* @__PURE__ */ e(H, { appearance: d, children: /* @__PURE__ */ t("div", { style: { position: "relative", display: "inline-block", width: "100%", maxWidth: "360px" }, ref: C, children: [
4281
4308
  /* @__PURE__ */ t(
4282
4309
  "button",
@@ -4289,7 +4316,7 @@ function le({ appearance: a, onOrgChange: s }) {
4289
4316
  /* @__PURE__ */ e("div", { className: "ss-auth-org-avatar", children: $ }),
4290
4317
  /* @__PURE__ */ t("div", { style: { textAlign: "left" }, children: [
4291
4318
  /* @__PURE__ */ e("div", { className: "ss-auth-org-trigger-label", children: "Current Organization" }),
4292
- /* @__PURE__ */ e("div", { className: "ss-auth-org-trigger-name", children: B })
4319
+ /* @__PURE__ */ e("div", { className: "ss-auth-org-trigger-name", children: F })
4293
4320
  ] })
4294
4321
  ] }),
4295
4322
  /* @__PURE__ */ e("span", { className: "material-symbols-outlined", children: v.unfoldMore })
@@ -4325,7 +4352,7 @@ function le({ appearance: a, onOrgChange: s }) {
4325
4352
  /* @__PURE__ */ e("span", { children: "Create organization" })
4326
4353
  ] }),
4327
4354
  y && /* @__PURE__ */ e("div", { className: "ss-auth-error", style: { marginBottom: "12px", fontSize: "12px" }, children: /* @__PURE__ */ e("span", { children: y }) }),
4328
- /* @__PURE__ */ t("form", { onSubmit: F, children: [
4355
+ /* @__PURE__ */ t("form", { onSubmit: B, children: [
4329
4356
  /* @__PURE__ */ t("div", { className: "ss-auth-field", children: [
4330
4357
  /* @__PURE__ */ e("label", { className: "ss-auth-label", style: { fontSize: "10px" }, children: "Org Name" }),
4331
4358
  /* @__PURE__ */ e(
@@ -4377,7 +4404,7 @@ function le({ appearance: a, onOrgChange: s }) {
4377
4404
  ] })
4378
4405
  ] }) });
4379
4406
  }
4380
- function Ba(a, s = "USD") {
4407
+ function Fa(a, s = "USD") {
4381
4408
  return new Intl.NumberFormat("en-US", {
4382
4409
  style: "currency",
4383
4410
  currency: s,
@@ -4398,7 +4425,7 @@ function ce({ plans: a, currentPlanId: s, onSelectPlan: r, interval: o, appearan
4398
4425
  d.isFree && /* @__PURE__ */ e("span", { className: "ss-badge ss-badge-active", children: "Free" })
4399
4426
  ] }),
4400
4427
  /* @__PURE__ */ e("div", { className: "ss-pricing-price", children: d.isFree ? /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: "Free" }) : /* @__PURE__ */ t(j, { children: [
4401
- /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: Ba(d.amountCents, d.currency) }),
4428
+ /* @__PURE__ */ e("span", { className: "ss-pricing-amount", children: Fa(d.amountCents, d.currency) }),
4402
4429
  /* @__PURE__ */ t("span", { className: "ss-pricing-interval", children: [
4403
4430
  "/",
4404
4431
  d.interval
@@ -4449,7 +4476,7 @@ function La(a, s) {
4449
4476
  i(!1);
4450
4477
  }
4451
4478
  }, [r, a]);
4452
- return U(() => {
4479
+ return V(() => {
4453
4480
  c();
4454
4481
  }, [c]), { customer: o, isLoading: u, error: l, refresh: c };
4455
4482
  }
@@ -4465,7 +4492,7 @@ function Aa(a, s) {
4465
4492
  i(!1);
4466
4493
  }
4467
4494
  }, [r, a]);
4468
- return U(() => {
4495
+ return V(() => {
4469
4496
  c();
4470
4497
  }, [c]), { invoices: o, isLoading: u, error: l, refresh: c };
4471
4498
  }
@@ -4481,7 +4508,7 @@ function Da(a, s) {
4481
4508
  i(!1);
4482
4509
  }
4483
4510
  }, [r, a]);
4484
- return U(() => {
4511
+ return V(() => {
4485
4512
  c();
4486
4513
  }, [c]), { usage: o, isLoading: u, error: l, refresh: c };
4487
4514
  }
@@ -4519,14 +4546,14 @@ function Ma({
4519
4546
  ] })
4520
4547
  ] }) });
4521
4548
  }
4522
- const Ua = {
4549
+ const Va = {
4523
4550
  paid: "ss-badge-active",
4524
4551
  open: "ss-badge-trialing",
4525
4552
  draft: "ss-badge-paused",
4526
4553
  void: "ss-badge-canceled",
4527
4554
  uncollectible: "ss-badge-past-due"
4528
4555
  };
4529
- function Va(a) {
4556
+ function Ua(a) {
4530
4557
  return new Date(a).toLocaleDateString("en-US", { year: "numeric", month: "short", day: "numeric" });
4531
4558
  }
4532
4559
  function Ra(a) {
@@ -4550,9 +4577,9 @@ function Ha({ customerId: a, portalToken: s, appearance: r }) {
4550
4577
  /* @__PURE__ */ e("th", { className: "ss-th", children: "PDF" })
4551
4578
  ] }) }),
4552
4579
  /* @__PURE__ */ e("tbody", { children: d.map((c) => /* @__PURE__ */ t("tr", { className: "ss-tr", children: [
4553
- /* @__PURE__ */ e("td", { className: "ss-td", children: Va(c.createdAt) }),
4580
+ /* @__PURE__ */ e("td", { className: "ss-td", children: Ua(c.createdAt) }),
4554
4581
  /* @__PURE__ */ e("td", { className: "ss-td", children: Ra(c.amountCents) }),
4555
- /* @__PURE__ */ e("td", { className: "ss-td", children: /* @__PURE__ */ e("span", { className: `ss-badge ${Ua[c.status] || ""}`, children: c.status }) }),
4582
+ /* @__PURE__ */ e("td", { className: "ss-td", children: /* @__PURE__ */ e("span", { className: `ss-badge ${Va[c.status] || ""}`, children: c.status }) }),
4556
4583
  /* @__PURE__ */ e("td", { className: "ss-td", children: c.pdfUrl ? /* @__PURE__ */ e("a", { className: "ss-link", href: c.pdfUrl, target: "_blank", rel: "noopener noreferrer", children: "Download" }) : "—" })
4557
4584
  ] }, c.id)) })
4558
4585
  ] })
@@ -4700,7 +4727,7 @@ function qa(a) {
4700
4727
  u(!1);
4701
4728
  }
4702
4729
  }, [s, a]);
4703
- return U(() => {
4730
+ return V(() => {
4704
4731
  d();
4705
4732
  }, [d]), { queries: (r == null ? void 0 : r.data) ?? [], meta: r == null ? void 0 : r.meta, isLoading: n, error: i, refresh: d };
4706
4733
  }
@@ -4716,7 +4743,7 @@ function ge(a) {
4716
4743
  u(!1);
4717
4744
  }
4718
4745
  }, [s, a]);
4719
- return U(() => {
4746
+ return V(() => {
4720
4747
  d();
4721
4748
  }, [d]), { dashboard: r, isLoading: n, error: i, refresh: d };
4722
4749
  }
@@ -4735,7 +4762,7 @@ function me(a, s, r = "https://api.saas-support.com/v1") {
4735
4762
  l(!1);
4736
4763
  }
4737
4764
  }, [o, s]);
4738
- return U(() => {
4765
+ return V(() => {
4739
4766
  f();
4740
4767
  }, [f]), { dashboard: n, reportClient: o, isLoading: i, error: d, refresh: f };
4741
4768
  }
@@ -4921,8 +4948,8 @@ function be({ dashboardId: a, embedToken: s, baseUrl: r, refreshInterval: o, app
4921
4948
  try {
4922
4949
  const I = await l.listQueries({ search: P.queryId, perPage: 1 });
4923
4950
  if (I.data.length > 0 && I.data[0].generatedSql) {
4924
- const F = await l.executeQuery({ sql: I.data[0].generatedSql });
4925
- C[P.queryId] = F;
4951
+ const B = await l.executeQuery({ sql: I.data[0].generatedSql });
4952
+ C[P.queryId] = B;
4926
4953
  }
4927
4954
  } catch {
4928
4955
  }
@@ -4933,9 +4960,9 @@ function be({ dashboardId: a, embedToken: s, baseUrl: r, refreshInterval: o, app
4933
4960
  b(!1);
4934
4961
  }
4935
4962
  }, [l, a]);
4936
- return U(() => {
4963
+ return V(() => {
4937
4964
  O();
4938
- }, [O]), U(() => {
4965
+ }, [O]), V(() => {
4939
4966
  if (!o || o <= 0) return;
4940
4967
  const h = setInterval(O, o * 1e3);
4941
4968
  return () => clearInterval(h);
@@ -5043,9 +5070,9 @@ function ye({ embedToken: a, dashboardId: s, baseUrl: r = "https://api.saas-supp
5043
5070
  c(!1);
5044
5071
  }
5045
5072
  }, [u, s]);
5046
- return U(() => {
5073
+ return V(() => {
5047
5074
  w();
5048
- }, [w]), U(() => {
5075
+ }, [w]), V(() => {
5049
5076
  if (!o || o <= 0) return;
5050
5077
  const y = setInterval(w, o * 1e3);
5051
5078
  return () => clearInterval(y);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saas-support/react",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "description": "Unified embeddable SDK for SaaS Support — auth, billing, and reporting",
6
6
  "exports": {