PageSourceSearch

https://klerkbot.com/assets/app.settings-1BHfrWl7.js

js klerkbot.com collected 2026-10-09 22:03:07 UTC 25,780 bytes, 1 lines download raw bytes

1import{y as oe,r as p,at as J,e as B,au as le,av as de,ai as ce,aj as X,x as G,ak as E,t as l,s as c,j as e,aw as T,ax as D,ay as L,az as A,aA as F,c as R,I as q,B as u,L as P,ag as ne,H as K,aB as ie,aC as I,a as me,G as ue,aD as xe,U as he,aE as pe,al as ge,am as fe,an as je,ao as ye,ap as Z,as as ve}from"./index-B1E3Xhcp.js";import{c as Ne}from"./createServerFn-Cwf8tImh.js";import{U as we}from"./upload-CUtzIlus.js";import{G as _e}from"./globe-BO25VCGI.js";import{B as be}from"./building-2-c0-r8iyF.js";function ke(r){const t=oe();return p.useCallback(async(...f)=>{try{const o=await r(...f);if(J(o))throw o;return o}catch(o){if(J(o))return o.options._fromLocation=t.stores.location.get(),t.navigate(t.resolveRedirect(o).options);throw o}},[t,r])}const Se=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Ce=B("circle-alert",Se);const Ee=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],ze=B("circle-check",Ee);const qe=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],ee=B("image",qe);const Pe=[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]],Te=B("user",Pe),De=le({type:"function"}),Le=Ne({method:"POST"}).middleware([De]).handler(de("ec0f70e4d7131781dc21eed1c3beb09b3e4fba12110499778600daf72ea02869")),Ae="185.158.133.1",Fe="klerkbot.com";ce({orgId:X().uuid(),domain:X().min(3).max(253).regex(/^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$/i,"Invalid domain")});const se=["image/png","image/jpeg","image/webp","image/svg+xml"],Re=2*1024*1024,Oe=3600*24*365*10,Q=Fe,ae=Ae;function te(r){return r.trim().toLowerCase().replace(/^https?:\/\//,"").replace(/\/.*$/,"").replace(/\s+/g,"")}function V(r){return r?/^([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,}$/.test(r):!1}function re(r){return r.split(".").length<=2}function Ue({orgId:r,slug:t,logoUrl:f}){const o=G(),N=p.useRef(null),[w,_]=p.useState(t??""),[d,g]=p.useState(f??""),[v,m]=p.useState(!1);p.useEffect(()=>{_(t??""),g(f??"")},[t,f]);const j=E({mutationFn:async()=>{const a=w.trim().toLowerCase().replace(/[^a-z0-9-]+/g,"-").replace(/^-+|-+$/g,"");if(!a)throw new Error("Slug is required");const{error:n}=await c.from("organizations").update({slug:a}).eq("id",r);if(n)throw n;return a},onSuccess:a=>{_(a),l.success("Slug saved"),o.invalidateQueries({queryKey:["organizations"]}),o.invalidateQueries({queryKey:["organization-detail"]})},onError:a=>l.error(a instanceof Error?a.message:"Failed to save slug")}),x=E({mutationFn:async a=>{const{error:n}=await c.from("organizations").update({logo_url:a}).eq("id",r);if(n)throw n;return a},onSuccess:()=>{l.success("Logo updated"),o.invalidateQueries({queryKey:["organizations"]}),o.invalidateQueries({queryKey:["organization-detail"]}),o.invalidateQueries({queryKey:["portal-org-login"]})},onError:a=>l.error(a instanceof Error?a.message:"Failed to save logo")}),b=async a=>{if(!se.includes(a.type)){l.error("Logo must be PNG, JPG, WebP, or SVG");return}if(a.size>Re){l.error("Logo must be under 2 MB");return}m(!0);try{const n=a.name.split(".").pop()?.toLowerCase()||"png",z=`${r}/logo-${Date.now()}.${n}`,{error:S}=await c.storage.from("portal-logos").upload(z,a,{cacheControl:"3600",upsert:!0,contentType:a.type});if(S)throw S;const{data:h,error:O}=await c.storage.from("portal-logos").createSignedUrl(z,Oe);if(O||!h?.signedUrl)throw O??new Error("Could not sign URL");g(h.signedUrl),await x.mutateAsync(h.signedUrl)}catch(n){l.error(n instanceof Error?n.message:"Upload failed")}finally{m(!1),N.current&&(N.current.value="")}},y=async()=>{g(""),await x.mutateAsync(null)},k=typeof window<"u"&&w?`${window.location.origin}/portal/${w}/login`:null;return e.jsxs(e.Fragment,{children:[e.jsxs(T,{className:"mt-6",children:[e.jsxs(D,{children:[e.jsxs(L,{className:"flex items-center gap-2 font-display",children:[e.jsx(ee,{className:"h-4 w-4",strokeWidth:1.75})," Branded portal"]}),e.jsx(A,{children:"Set the URL slug and upload the logo shown to invited portal users."})]}),e.jsxs(F,{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx(R,{htmlFor:"slug",children:"Worksp
1ace slug"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx(q,{id:"slug",value:w,onChange:a=>_(a.target.value),placeholder:"acme"}),e.jsxs(u,{className:"rounded-full",disabled:j.isPending,onClick:()=>j.mutate(),children:[j.isPending&&e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]})]}),w&&k&&e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Portal address:"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:k})]})]}),e.jsxs("div",{children:[e.jsx(R,{children:"Portal logo"}),e.jsxs("div",{className:"mt-2 flex items-center gap-4",children:[e.jsx("div",{className:"flex h-20 w-20 items-center justify-center overflow-hidden rounded-md border border-border bg-card",children:d?e.jsx("img",{src:d,alt:"Logo preview",className:"max-h-16 max-w-16 object-contain"}):e.jsx(ee,{className:"h-6 w-6 text-muted-foreground"})}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsx("input",{ref:N,type:"file",accept:se.join(","),className:"hidden",onChange:a=>{const n=a.target.files?.[0];n&&b(n)}}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(u,{type:"button",variant:"outline",className:"rounded-full",disabled:v,onClick:()=>N.current?.click(),children:[v?e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}):e.jsx(we,{className:"mr-2 h-4 w-4"}),d?"Replace logo":"Upload logo"]}),d&&e.jsxs(u,{type:"button",variant:"ghost",className:"rounded-full text-destructive hover:text-destructive",onClick:y,disabled:x.isPending,children:[e.jsx(ne,{className:"mr-2 h-4 w-4"}),"Remove"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"PNG, JPG, WebP, or SVG. Max 2 MB."})]})]}),e.jsxs("details",{className:"mt-4",children:[e.jsx("summary",{className:"cursor-pointer text-xs text-muted-foreground",children:"Advanced: use an external logo URL"}),e.jsxs("div",{className:"mt-2 flex gap-2",children:[e.jsx(q,{value:d,onChange:a=>g(a.target.value),placeholder:"https://your-cdn.com/logo.png"}),e.jsx(u,{type:"button",variant:"outline",className:"rounded-full",onClick:()=>x.mutate(d.trim()||null),disabled:x.isPending,children:"Save URL"})]})]})]})]})]}),e.jsx(Ke,{orgId:r})]})}function Ke({orgId:r}){const t=G(),[f,o]=p.useState(""),N=ke(Le),[w,_]=p.useState(!1),{data:d}=K({queryKey:["org-custom-domain",r],queryFn:async()=>{const{data:a,error:n}=await c.from("organizations").select("custom_portal_domain, custom_domain_status, custom_domain_status_message, custom_domain_last_checked_at").eq("id",r).maybeSingle();if(n)throw n;return a}});p.useEffect(()=>{d?.custom_portal_domain&&o(d.custom_portal_domain)},[d?.custom_portal_domain]);const g=E({mutationFn:async a=>{if(a===null){const{error:h}=await c.from("organizations").update({custom_portal_domain:null,custom_domain_status:"none",custom_domain_status_message:null,custom_domain_last_checked_at:null}).eq("id",r);if(h)throw h;return null}const n=te(a);if(!V(n))throw new Error("Enter a valid domain like portal.example.com");const{data:z}=await c.from("organizations").select("id").ilike("custom_portal_domain",n).neq("id",r).maybeSingle();if(z)throw new Error("That domain is already used by another workspace");const{error:S}=await c.from("organizations").update({custom_portal_domain:n,custom_domain_status:"pending",custom_domain_status_message:"Awaiting DNS configuration."}).eq("id",r);if(S)throw S;return n},onSuccess:()=>{l.success("Custom domain saved"),t.invalidateQueries({queryKey:["org-custom-domain",r]})},onError:a=>l.error(a instanceof Error?a.message:"Failed to save custom domain")}),v=E({mutationFn:async()=>{const a=d?.custom_portal_domain;if(!a)throw new Error("Save a custom domain first");return await N({data:{orgId:r,domain:a}})},onSuccess:a=>{a.ok?l.success("Domain verified"):l.error(a.message),t.invalidateQueries({queryKey:["org-custom-domain",r]})},onError:a=>l.error(a instanceof Error?a.message:"Verification failed")}),m=te(f);m&&m.split(".")[0],m&&re(m);const j=async a=>{await navigator.clipboard.writeText(a),_(!0),setTimeout(()=>_(!1),1500)},x=d?.custom_domain_status??"none",b=!!d?.custom_portal_domain,y=m&&V(m)?m.split(".")[0]:"portal",k=m&&V(m)?re(m):!1;return e.jsxs(T,{className:"mt-6",children:[e.jsxs(D,{children:[e.jsxs(L,{className:"flex items-center gap-2 font-display",children:[e.jsx(_e,{className:"h-4 w-4",strokeWidth:1.75})," Custom portal domain"]}),e.jsxs(A,{children:["Serve the portal from your own domain like"," ",e.jsx("code",{className:"rounded bg-muted px-1 py-0.5",children:"portal.yourcompany.com"}),"."]})]}),e.jsxs(F,{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx(R,{htmlFor:"custom-domain",children:"Custom domain"}),e.jsxs("div",{className:"mt-1 flex gap-2",children:[e.jsx(q,{id:"custom-domain",value:f,onChange:a=>o(a.target.value),placeholder:"portal.client.com"}),e.jsxs(u,{className:"rounded-full",disabled:g.isPending,onClick:()=>g.mutate(f),children:[g.isPending&&e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}),"Save"]}),b&&e.jsx(u,{variant:"ghost",className:"rounded-full text-destructive hover:text-destructive",onClick:()=>{o(""),g.mutate(null)},disabled:g.isPending,children:e.jsx(ne,{className:"h-4 w-4"})})]}),b&&e.jsxs("div",{className:"mt-2 flex items-center gap-2 text-xs",children:[e.jsxs(ie,{variant:x==="verified"?"default":"secondary",className:"capitalize",children:[x==="verified"?e.jsx(ze,{className:"mr-1 h-3 w-3"}):e.jsx(Ce,{className:"mr-1 h-3 w-3"}),x==="none"?"pending":x==="dns_ok"?"DNS ok — hosting pending":x]}),d.custom_domain_status_message&&e.jsx("span",{className:"text-muted-foreground",children:d.custom_domain_status_message})]})]}),e.jsxs("div",{className:"rounded-md border border-border bg-muted/30 p-4",children:[e.jsx("p",{className:"text-sm font-medium",children:"Domain setup"}),e.jsxs("p",{className:"mt-1 text-xs text-muted-foreground",children:["Your domain stays in the visitor's address bar the whole time — the portal is served at"," ",e.jsxs("code",{className:"rounded bg-background px-1 py-0.5",children:["https://",y,"/login"]})," and never redirects anywhere else. Pick one of the two options below."]}),e.jsx("p",{className:"mt-4 text-sm font-medium",children:"Option A — Cloudflare proxy (recommended, fully self-serve)"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Cloudflare issues the HTTPS certificate for your domain, so nothing has to be activated on the Klerk side. Your domain must be on a Cloudflare zone (free plan is enough)."}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-2 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:"Enter your domain in the field above and click Save."}),e.jsxs("li",{children:["In Cloudflare, open ",e.jsx("span",{className:"font-medium text-foreground",children:"DNS → Records"})," ","→ ",e.jsx("span",{className:"font-medium text-foreground",children:"Add record"})," and create:",e.jsxs("div",{className:"mt-1 space-y-1",children:[e.jsxs("div",{children:["Type: ",e.jsx("code",{className:"rounded bg-background px-1 py-0.5",children:"CNAME"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:["Name: ",e.jsx("code",{className:"rounded bg-background px-1 py-0.5",children:y}),e.jsx(u,{variant:"ghost",size:"sm",className:"h-6 px-1",onClick:()=>j(y),children:e.jsx(I,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:["Target: ",e.jsx("code",{className:"rounded bg-background px-1 py-0.5",children:Q}),e.jsx(u,{variant:"ghost",size:"sm",className:"h-6 px-1",onClick:()=>j(Q),children:e.jsx(I,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:["Proxy status:"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Proxied (orange cloud ON)"})," — this is what gives you the certificate."]}),e.jsxs("div",{children:["TTL: ",e.jsx("span",{className:"font-medium text-foreground",children:"Auto"})]})]})]}),e.jsxs("li",{children:["Open ",e.jsx("span",{className:"font-medium text-foreground",children:"SSL/TLS → Overview"})," and set the encryption mode to ",e.jsx("span",{className:"font-medium text-foreground",children:"Full"}),". Flexible will cause a redirect loop."]}),e.jsxs("li",{children:["Open ",e.jsx("span",{className:"font-medium text-foreground",children:"Rules → Origin Rules"})," →"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Create rule"}),":",e.jsxs("div",{className:"mt-1 space-y-1",children:[e.jsxs("div",{children:["When incoming requests match: Hostname"," ",e.jsx("span",{className:"font-medium text-foreground",children:"equals"})," ",e.jsx("code",{className:"rounded bg-background px-1 py-0.5",children:y})]}),e.jsxs("div",{children:["Then: enable"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Host Header"})," rewrite and set it to ",e.jsx("code",{className:"rounded bg-background px-1 py-0.5",children:Q})]}),e.jsx("div",{children:"Deploy the rule."})]}),"This header is only sent to our servers so we can resolve your workspace — visitors never see it."]}),e.jsxs("li",{children:["Come back here and click"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Verify domain"}),". Your branded portal is then live on your own domain."]})]}),e.jsx("p",{className:"mt-5 text-sm font-medium",children:"Option B — direct A record (no proxy)"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Works with any DNS provider (GoDaddy, Namecheap, Route 53). The HTTPS certificate is issued on the Klerk side, so this option needs a one-time activation from us after your DNS is in place."}),e.jsxs("ol",{className:"mt-2 list-decimal space-y-2 pl-5 text-sm text-muted-foreground",children:[e.jsx("li",{children:"Enter your domain in the field above and click Save."}),e.jsxs("li",{children:["In your DNS provider, add:",e.jsxs("div",{className:"mt-1 space-y-1",children:[e.jsxs("div",{children:["Type: ",e.jsx("code",{className:"rounded bg-background px-1 py-0.5",children:"A"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:["Host / Name: ",e.jsx("code",{className:"rounded bg-background px-1 py-0.5",children:y}),e.jsx(u,{variant:"ghost",size:"sm",className:"h-6 px-1",onClick:()=>j(y),children:e.jsx(I,{className:"h-3 w-3"})})]}),e.jsxs("div",{className:"flex items-center gap-1",children:["Value / Points to:"," ",e.jsx("code",{className:"rounded bg-background px-1 py-0.5",children:ae}),e.jsx(u,{variant:"ghost",size:"sm",className:"h-6 px-1",onClick:()=>j(ae),children:e.jsx(I,{className:"h-3 w-3"})})]}),e.jsxs("div",{children:["TTL: ",e.jsx("span",{className:"font-medium text-foreground",children:"default / 1 hour"})]})]})]}),e.jsx("li",{children:"Delete any other A, AAAA, CNAME or domain-forwarding record on the same host. Forwarding rules break HTTPS and login."}),e.jsx("li",{children:"Tell us the domain so we can activate the certificate for it — with no proxy in front, that step has to happen on our side."}),e.jsxs("li",{children:["Once DNS has propagated (usually minutes, up to 24 hours), click"," ",e.jsx("span",{className:"font-medium text-foreground",children:"Verify domain"}),"."]})]}
1),k&&e.jsxs("p",{className:"mt-4 text-xs text-amber-600 dark:text-amber-400",children:["Note: root/apex domains (like ",e.jsx("code",{children:"example.com"}),") work with the A record above, but a subdomain such as ",e.jsx("code",{children:"portal.example.com"})," is recommended so your main website keeps working."]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsxs(u,{size:"sm",variant:"outline",className:"rounded-full",onClick:()=>v.mutate(),disabled:v.isPending||!b,children:[v.isPending&&e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}),"Verify domain"]}),!b&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"Save a custom domain first."}),d?.custom_domain_last_checked_at&&e.jsxs("span",{className:"text-xs text-muted-foreground",children:["Last checked ",new Date(d.custom_domain_last_checked_at).toLocaleString()]})]}),e.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:["Once verified, your team signs in at ",e.jsxs("code",{children:[m||y,"/login"]})," and works at ",e.jsx("code",{children:"/dashboard"}),", ",e.jsx("code",{children:"/leads"})," and ",e.jsx("code",{children:"/conversations"})," — no Klerk branding or workspace slug in the URL."]})]})]})]})}function Ge(){const{user:r}=me(),{currentOrg:t,organizations:f}=ue(),o=G(),{data:N}=K({queryKey:["profile",r?.id],enabled:!!r,queryFn:async()=>{const{data:s,error:i}=await c.from("profiles").select("display_name, avatar_url").eq("user_id",r.id).maybeSingle();if(i)throw i;return s}}),[w,_]=p.useState(""),[d,g]=p.useState(""),[v,m]=p.useState(""),[j,x]=p.useState(""),[b,y]=p.useState("member");N&&w===""&&N.display_name&&_(N.display_name),t&&d===""&&g(t.name);const{data:k}=K({queryKey:["organization-detail",t?.id],enabled:!!t,queryFn:async()=>{const{data:s,error:i}=await c.from("organizations").select("id, slug, logo_url, default_lead_owner_id").eq("id",t.id).maybeSingle();if(i)throw i;return s}}),{data:a=[]}=K({queryKey:["members",t?.id],enabled:!!t,queryFn:async()=>{const{data:s,error:i}=await c.from("organization_members").select("id, user_id, role, created_at").eq("org_id",t.id).order("created_at",{ascending:!0});if(i)throw i;const U=(s??[]).map(C=>C.user_id),$=new Map;if(U.length>0){const{data:C,error:H}=await c.from("profiles").select("user_id, display_name").in("user_id",U);if(H)throw H;for(const Y of C??[])$.set(Y.user_id,Y.display_name)}return(s??[]).map(C=>({id:C.id,user_id:C.user_id,role:C.role,created_at:C.created_at,display_name:$.get(C.user_id)??null}))}}),n=E({mutationFn:async s=>{const{error:i}=await c.from("profiles").update({display_name:s}).eq("user_id",r.id);if(i)throw i},onSuccess:()=>{l.success("Profile updated"),o.invalidateQueries({queryKey:["profile"]})},onError:s=>l.error(s instanceof Error?s.message:"Failed to update profile")}),z=E({mutationFn:async s=>{const{error:i}=await c.from("organizations").update({name:s}).eq("id",t.id);if(i)throw i},onSuccess:()=>{l.success("Organization updated"),o.invalidateQueries({queryKey:["organizations"]})},onError:s=>l.error(s instanceof Error?s.message:"Failed to update org")}),S=E({mutationFn:async s=>{const{data:i,error:U}=await c.rpc("create_organization",{_name:s});if(U)throw U;return i},onSuccess:()=>{l.success("Organization created"),m(""),o.invalidateQueries({queryKey:["organizations"]})},onError:s=>l.error(s instanceof Error?s.message:"Failed to create org")}),h=t?.role==="owner"||t?.role==="admin",{data:O=[]}=K({queryKey:["invitations",t?.id],enabled:!!t&&h,queryFn:async()=>{const{data:s,error:i}=await c.from("org_invitations").select("id, email, role, status, created_at").eq("org_id",t.id).eq("status","pending").order("created_at",{ascending:!1});if(i)throw i;return s??[]}}),M=E({mutationFn:async()=>{const s=j.trim().toLowerCase();if(!s)throw new Error("Email is required");const{error:i}=await c.from("org_invitations").insert({org_id:t.id,email:s,role:b,invited_by:r.id});if(i)throw i},onSuccess:()=>{l.success("Invitation sent"),x(""),y("member"),o.invalidateQueries({queryKey:["invitations",t?.id]})},onError:s=>l.error(s instanceof Error?s.message:"Failed to send invitation")}),W=E({mutationFn:async s=>{const{error:i}=await c.from("org_invitations").update({status:"revoked"}).eq("id",s);if(i)throw i},onSuccess:()=>{l.success("Invitation revoked"),o.invalidateQueries({queryKey:["invitations",t?.id]})},onError:s=>l.error(s instanceof Error?s.message:"Failed to revoke")});return e.jsxs("div",{className:"mx-auto max-w-3xl px-6 py-10",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight",children:"Settings"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Manage your profile, organizations, and members."})]}),e.jsxs(T,{className:"mt-8",children:[e.jsxs(D,{children:[e.jsxs(L,{className:"flex items-center gap-2 font-display",children:[e.jsx(Te,{className:"h-4 w-4",strokeWidth:1.75}),"Your profile"]}),e.jsx(A,{children:"How you appear inside Klerk."})]}),e.jsx(F,{children:e.jsxs("form",{onSubmit:s=>{s.preventDefault(),n.mutate(w)},className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{htmlFor:"email",children:"Email"}),e.jsx(q,{id:"email",value:r?.email??"",disabled:!0})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{htmlFor:"displayName",children:"Display name"}),e.jsx(q,{id:"displayName",value:w,onChange:s=>_(s.target.value),placeholder:"Your name"})]}),e.jsxs(u,{type:"submit",disabled:n.isPending,className:"rounded-full",children:[n.isPending&&e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}),"Save profile"]})]})})]}),e.jsxs(T,{className:"mt-6",children:[e.jsxs(D,{children:[e.jsxs(L,{className:"flex items-center gap-2 font-display",children:[e.jsx(be,{className:"h-4 w-4",strokeWidth:1.75}),"Current organization"]}),e.jsx(A,{children:t?`You are ${t.role} in this workspace.`:"No org selected."})]}),e.jsx(F,{children:e.jsxs("form",{onSubmit:s=>{s.preventDefault(),h&&z.mutate(d)},className:"space-y-4",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx(R,{htmlFor:"orgName",children:"Organization name"}),e.jsx(q,{id:"orgName",value:d,onChange:s=>g(s.target.value),disabled:!h})]}),h&&e.jsxs(u,{type:"submit",disabled:z.isPending,className:"rounded-full",children:[z.isPending&&e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}),"Save organization"]})]})})]}),h&&t&&e.jsx(Ue,{orgId:t.id,slug:k?.slug??t.slug??null,logoUrl:k?.logo_url??t.logo_url??null}),h&&t&&e.jsx(xe,{org:{id:t.id,slug:k?.slug??t.slug??null,default_lead_owner_id:k?.default_lead_owner_id??null}}),e.jsxs(T,{className:"mt-6",children:[e.jsxs(D,{children:[e.jsxs(L,{className:"flex items-center gap-2 font-display",children:[e.jsx(he,{className:"h-4 w-4",strokeWidth:1.75}),"Members"]}),e.jsx(A,{children:"Everyone with access to this organization."})]}),e.jsx(F,{children:e.jsxs("div",{className:"divide-y divide-border",children:[a.map(s=>e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"flex h-8 w-8 items-center justify-center rounded-full bg-secondary text-xs font-semibold",children:(s.display_name??"?").charAt(0).toUpperCase()}),e.jsxs("div",{children:[e.jsxs("div",{className:"text-sm font-medium",children:[s.display_name??"Unnamed user",s.user_id===r?.id&&e.jsx("span",{className:"ml-2 text-xs text-muted-foreground",children:"(you)"})]}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Joined ",new Date(s.created_at).toLocaleDateString()]})]})]}),e.jsx(ie,{variant:"secondary",className:"capitalize",children:s.role})]},s.id)),a.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-muted-foreground",children:"No members loaded."})]})})]}),h&&e.jsxs(T,{className:"mt-6",children:[e.jsxs(D,{children:[e.jsxs(L,{className:"flex items-center gap-2 font-display",children:[e.jsx(pe,{className:"h-4 w-4",strokeWidth:1.75}),"Invite members"]}),e.jsx(A,{children:"Invite people to this workspace by email. Admins can manage bots; members only see conversations and leads."})]}),e.jsxs(F,{children:[e.jsxs("form",{onSubmit:s=>{s.preventDefault(),M.mutate()},className:"flex flex-col gap-2 sm:flex-row",children:[e.jsx(q,{type:"email",value:j,onChange:s=>x(s.target.value),placeholder:"[email protected]",required:!0,className:"flex-1"}),e.jsxs(ge,{value:b,onValueChange:s=>y(s),children:[e.jsx(fe,{className:"w-full sm:w-36",children:e.jsx(je,{})}),e.jsxs(ye,{children:[e.jsx(Z,{value:"member",children:"Member"}),e.jsx(Z,{value:"admin",children:"Admin"})]})]}),e.jsxs(u,{type:"submit",disabled:M.isPending||j.trim().length===0,className:"rounded-full",children:[M.isPending&&e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}),"Send invite"]})]}),O.length>0&&e.jsxs("div",{className:"mt-6 divide-y divide-border",children:[e.jsx("p",{className:"pb-2 text-xs font-medium uppercase tracking-wider text-muted-foreground",children:"Pending invitations"}),O.map(s=>e.jsxs("div",{className:"flex items-center justify-between py-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-sm font-medium",children:s.email}),e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Invited as ",s.role," ·"," ",new Date(s.created_at).toLocaleDateString()]})]}),e.jsxs(u,{variant:"ghost",size:"sm",onClick:()=>
1W.mutate(s.id),disabled:W.isPending,children:[e.jsx(ve,{className:"h-4 w-4"}),e.jsx("span",{className:"sr-only",children:"Revoke"})]})]},s.id))]}),e.jsx("p",{className:"mt-4 text-xs text-muted-foreground",children:"Invitees can sign up with the invited email and will join this workspace automatically."})]})]}),e.jsxs(T,{className:"mt-6",children:[e.jsxs(D,{children:[e.jsx(L,{className:"font-display",children:"Create another organization"}),e.jsxs(A,{children:["You currently belong to ",f.length," ",f.length===1?"organization":"organizations","."]})]}),e.jsx(F,{children:e.jsxs("form",{onSubmit:s=>{s.preventDefault(),v.trim().length!==0&&S.mutate(v.trim())},className:"flex gap-2",children:[e.jsx(q,{value:v,onChange:s=>m(s.target.value),placeholder:"Acme Inc.",maxLength:120}),e.jsxs(u,{type:"submit",disabled:S.isPending||v.trim().length===0,className:"rounded-full",children:[S.isPending&&e.jsx(P,{className:"mr-2 h-4 w-4 animate-spin"}),"Create"]})]})})]})]})}export{Ge as component};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.