1import{f as e,i as x,m as Ne}from"./motion-BTH3w9fV.js";import{aZ as $,L as we,a4 as ke,a3 as Ce,bV as D,bG as _,C as q,y as U,aE as de,bJ as O,a as Ae,av as K,aL as me,am as Me,by as Se,c8 as ee,f as R,bK as se,aX as te,bL as L,at as $e,a2 as xe,D as W,cn as Ee,cd as Ie,c9 as Re,a9 as De}from"./index-De4fohwc.js";import{F as Oe,T as Pe}from"./trash-2-BkpzJoqC.js";import{O as Le,A as Te}from"./OrgDomainUsageTable-BTPkWDaA.js";import{P as F}from"./PeacockStudioLoader-Ad5WJ3mn.js";import{h as pe,i as _e,k as Be,n as ue,y as Ue,u as ae,c as ze,g as Fe,m as Ge,d as He,b as ie,s as le,I as re,q as Ye,o as Ve,x as qe,r as We,t as Xe}from"./organizationRepository-DmhM1uAW.js";import{r as T}from"./refreshCloudMemberships-BfK12T1O.js";import{P as ne}from"./pencil-CdTAgBeC.js";import{P as Ke}from"./plus-DXpu4OFs.js";import{C as he}from"./ConfirmDialog-C4-QacZD.js";import"./Button-3SqDYXzX.js";import{F as Je}from"./FieldTextarea-pD-DHDLN.js";import{F as Ze}from"./FormField-DzVRspPJ.js";import{C as Qe}from"./check-CEKNgvXw.js";import{a as es}from"./profileRepository-aod7ApBa.js";import{U as be}from"./users-BP4zQ31u.js";import{U as X}from"./user-plus-CVI0kFki.js";import{u as ss,A as ts}from"./useOrgAnalytics-CHJzF8g9.js";import{C as as}from"./chart-column-BK4rPYyk.js";import"./clerk-C1qM4dBy.js";import"./sentry-C20HUQ3l.js";import"./supabaseClient-O2dscECL.js";import"./pdf-VhDWQxox.js";import"./turnstile-B5SSyqO-.js";import"./loader-circle-CMAN309H.js";import"./audit-BGPn82K9.js";import"./eye-Bgnwsabr.js";import"./analyticsRepository-Qh7yFis9.js";/** 2 * @license lucide-react v1.16.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const is=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 6v6h4",key:"135r8i"}]],ls=$("clock-3",is);/** 7 * @license lucide-react v1.16.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const rs=[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"M19 16v6",key:"tddt3s"}],["path",{d:"M16 19h6",key:"xwg31i"}]],oe=$("mail-plus",rs);/** 12 * @license lucide-react v1.16.0 - ISC 13 * 14 * This source code is licensed under the ISC license. 15 * See the LICENSE file in the root directory of this source tree. 16 */const ns=[["path",{d:"M21 10.656V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12.344",key:"2acyp4"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],os=$("square-check-big",ns);/** 17 * @license lucide-react v1.16.0 - ISC 18 * 19 * This source code is licensed under the ISC license. 20 * See the LICENSE file in the root directory of this source tree. 21 */const cs=[["path",{d:"M10 14.66v1.626a2 2 0 0 1-.976 1.696A5 5 0 0 0 7 21.978",key:"1n3hpd"}],["path",{d:"M14 14.66v1.626a2 2 0 0 0 .976 1.696A5 5 0 0 1 17 21.978",key:"rfe1zi"}],["path",{d:"M18 9h1.5a1 1 0 0 0 0-5H18",key:"7xy6bh"}],["path",{d:"M4 22h16",key:"57wxv0"}],["path",{d:"M6 9a6 6 0 0 0 12 0V3a1 1 0 0 0-1-1H7a1 1 0 0 0-1 1z",key:"1mhfuq"}],["path",{d:"M6 9H4.5a1 1 0 0 1 0-5H6",key:"tex48p"}]],ds=$("trophy",cs);/** 22 * @license lucide-react v1.16.0 - ISC 23 * 24 * This source code is licensed under the ISC license. 25 * See the LICENSE file in the root directory of this source tree. 26 */const ms=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],xs=$("user-minus",ms);/** 27 * @license lucide-react v1.16.0 - ISC 28 * 29 * This source code is licensed under the ISC license. 30 * See the LICENSE file in the root directory of this source tree. 31 */const ps=[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]],J=$("user-round",ps);/** 32 * @license lucide-react v1.16.0 - ISC 33 * 34 * This source code is licensed under the ISC license. 35 * See the LICENSE file in the root directory of this source tree. 36 */const us=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]],hs=$("user-x",us);
36function bs(s){const t=s.trim().split(/\s+/).filter(Boolean);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():`${t[0][0]??""}${t[1][0]??""}`.toUpperCase()}function B(s,t){const a=s[0];return!a||a.count<=0?null:`${a.displayName} · ${a.count} ${t}`}const gs=({board:s})=>{var i;const t=s.icon,a=((i=s.rows[0])==null?void 0:i.count)??0;return e.jsxs("article",{className:"overflow-hidden rounded-2xl border border-slate-200/80 bg-white shadow-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 border-b border-slate-100 px-4 py-3.5",children:[e.jsx("span",{className:`inline-flex rounded-xl bg-gradient-to-br ${s.accent} p-2 text-white shadow-md`,children:e.jsx(t,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"text-sm font-semibold text-slate-900",children:s.title}),e.jsx("p",{className:"text-[11px] text-slate-500",children:s.subtitle})]})]}),s.rows.length===0?e.jsx("p",{className:"px-4 py-8 text-center text-sm text-slate-500",children:"No data yet."}):e.jsx("ol",{className:"divide-y divide-slate-100",children:s.rows.slice(0,5).map((n,r)=>{const o=a>0?Math.round(n.count/a*100):0;return e.jsx("li",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-full text-xs font-bold ${r===0?"bg-amber-100 text-amber-800 ring-1 ring-amber-200":"bg-slate-100 text-slate-600"}`,title:n.displayName,children:r===0?"1":bs(n.displayName)}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsxs("p",{className:"truncate text-sm font-medium text-slate-900",children:[n.displayName,r===0?e.jsx("span",{className:"ml-2 text-[10px] font-semibold uppercase tracking-wide text-amber-700",children:"Leading"}):null]}),e.jsxs("p",{className:"shrink-0 text-sm font-semibold tabular-nums text-slate-800",children:[n.count,e.jsx("span",{className:"ml-1 text-xs font-medium text-slate-400",children:s.unit})]})]}),e.jsx("div",{className:"mt-1.5 h-1.5 overflow-hidden rounded-full bg-slate-100",children:e.jsx("div",{className:`h-full rounded-full bg-gradient-to-r ${s.accent}`,style:{width:`${o}%`}})})]})]})},`${s.title}-${n.email}`)})})]})};function fs(s){return{docs:B(s.docsByCreator,"docs")??void 0,tours:B(s.toursByCreator,"tours")??void 0,exports:B(s.exportsByActor,"exports")??void 0,shares:B(s.sharesByActor,"shares")??void 0}}const ge=({activity:s,days:t=30})=>{const a=[{title:"Docs created",subtitle:"All time by creator",unit:"docs",icon:we,accent:"from-peacock-500 to-peacock-700",rows:s.docsByCreator},{title:"Tours created",subtitle:"All time by creator",unit:"tours",icon:ke,accent:"from-brand-violet to-peacock-700",rows:s.toursByCreator},{title:"Exports",subtitle:`Last ${t} days`,unit:"exports",icon:Oe,accent:"from-brand-cyan to-peacock-600",rows:s.exportsByActor},{title:"Share links",subtitle:`Last ${t} days`,unit:"shares",icon:Ce,accent:"from-amber-500 to-orange-600",rows:s.sharesByActor}];return e.jsxs("section",{className:"space-y-4",children:[e.jsxs("header",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"inline-flex rounded-lg bg-amber-50 p-2 text-amber-700 ring-1 ring-amber-100",children:e.jsx(ds,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-900",children:"Top contributors"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Who created the most docs, tours, exports, and shares"})]})]}),e.jsx("div",{className:"grid gap-4 lg:grid-cols-2",children:a.map(i=>e.jsx(gs,{board:i},i.title))})]})},ce=30,vs=({organizationId:s})=>{const[t,a]=x.useState(null),[i,n]=x.useState([]),[r,o]=x.useState(!0),[l,u]=x.useState(null);return x.useEffect(()=>{let m=!1;return(async()=>{try{const[h,p]=await Promise.all([pe(s,ce),_e(s)]);m||(a(h),n(p))}catch(h){const p=D("Failed to load admin activity",h);m||(u(p.userMessage),_(p.title,p.userMessage))}finally{m||o(!1)}})(),()=>{m=!0}},[s]),r?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(F,{size:80})}):l||!t?e.jsx("p",{className:"text-sm text-red-600",children:l??"No activity data."}):e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-5",children:[{label:"Members",value:t.memberCount},{label:"Documents",value:t.documentCount},{label:"Tours",value:t.tourCount},{label:"Exports (30d)",value:t.exportCount},{label:"Shares (30d)",value:t.shareCount}].map(m=>e.jsxs("div",{className:"rounded-xl border border-slate-200 bg-white p-4 shadow-sm",children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-slate-500",children:m.label}),e.jsx("p",{className:"mt-1 text-2xl font-semibold text-slate-900",children:m.value})]},m.label))}),e.jsx(ge,{activity:t,days:ce}),e.jsx(Le,{rows:i}),e.jsxs("section",{className:"rounded-xl border border-dashed border-slate-200 bg-slate-50/80 p-5",children:[e.jsx("h2",{className:"text-sm font-semibold text-slate-900",children:"Audit log"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Audit log coming soon â an immutable admin history of invites, role changes, shares, and exports will appear here."})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-lg font-semibold text-slate-900",children:"Events by user (30d)"}),t.byActor.length===0?e.jsx("p",{className:"text-sm text-slate-500",children:"No anal
36ytics events yet."}):e.jsx("ul",{className:"divide-y divide-slate-100 rounded-xl border border-slate-200 bg-white",children:t.byActor.map(m=>e.jsxs("li",{className:"flex justify-between px-4 py-3 text-sm",children:[e.jsx("span",{className:"font-medium text-slate-900",children:m.displayName}),e.jsxs("span",{className:"text-slate-500",children:[m.eventCount," events"]})]},m.email))})]})]})},z={read:{label:"Read",hint:"View docs and tours in the library"},create:{label:"Create",hint:"Add new docs and tours"},edit:{label:"Edit",hint:"Update existing content"},delete:{label:"Delete",hint:"Remove library items"},share:{label:"Share",hint:"Create share links"},export:{label:"Export",hint:"Download PDFs and artifacts"},embed:{label:"Embed",hint:"Publish embeds"}};function Y(s){return s.trim().toLowerCase().endsWith("@unknown.local")}function fe(s,t,a){var n;if(a!=null&&a.email&&s.clerkUserId===a.clerkUserId&&!Y(a.email))return a.email;const i=t[s.clerkUserId];return i!=null&&i.email&&!Y(i.email)?i.email:Y(s.email)&&((n=i==null?void 0:i.displayName)==null?void 0:n.trim())||s.email}function ve(s,t,a){var o;if(a!=null&&a.displayName&&s.clerkUserId===a.clerkUserId&&a.displayName.trim()&&!a.displayName.includes("@"))return a.displayName.trim();const i=t[s.clerkUserId],n=[i==null?void 0:i.firstName,i==null?void 0:i.lastName].map(l=>l==null?void 0:l.trim()).filter(Boolean).join(" ").trim();if(n)return n;const r=(o=i==null?void 0:i.displayName)==null?void 0:o.trim();return r&&!r.includes("@")?r:null}function je(s,t){if(s){const a=s.split(/\s+/).filter(Boolean);return a.length>=2?`${a[0][0]??""}${a[1][0]??""}`.toUpperCase():s.slice(0,2).toUpperCase()}return ye(t)}function ye(s){const t=s.split("@")[0]??s,a=t.split(/[._-]+/).filter(Boolean);return a.length>=2?`${a[0][0]??""}${a[1][0]??""}`.toUpperCase():t.slice(0,2).toUpperCase()}function js(s){const a=new Date(s).getTime()-Date.now();if(a<=0)return{label:"Expired",urgency:"expired",progress:0};const i=Math.floor(a/(1440*60*1e3)),n=Math.floor(a%(1440*60*1e3)/(3600*1e3)),r=Math.max(1,Math.floor(a%(3600*1e3)/(60*1e3))),o=i>0?`${i}d ${n}h left`:n>0?`${n}h ${r}m left`:`${r}m left`,l=Math.min(1,Math.max(0,a/6048e5)),u=a<1440*60*1e3?"critical":a<2880*60*1e3?"soon":"ok";return{label:o,urgency:u,progress:l}}function Z(s){return s==="admin"?"Admin":"Member"}const Q=({value:s,onChange:t,disabled:a=!1,readOnly:i=!1})=>e.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-7",children:q.map(n=>{const r=s[n],o=z[n],l=!!t&&!i&&!a;return e.jsxs("button",{type:"button",disabled:!l,title:o.hint,onClick:()=>{!t||!l||t({...s,[n]:!r})},className:`group relative rounded-xl border px-3 py-2.5 text-left transition ${r?"border-peacock-300/80 bg-gradient-to-br from-peacock-50 to-white shadow-sm shadow-peacock-500/10 ring-1 ring-peacock-200/60":"border-slate-200/80 bg-slate-50/80 text-slate-500"} ${l?"hover:border-peacock-300 hover:shadow-sm cursor-pointer":"cursor-default"}`,children:[e.jsx("span",{className:`block text-xs font-semibold tracking-wide ${r?"text-peacock-800":"text-slate-500"}`,children:o.label}),e.jsx("span",{className:`mt-0.5 block text-[10px] leading-tight ${r?"text-peacock-600/80":"text-slate-400"}`,children:r?"Allowed":"Off"}),e.jsx("span",{"aria-hidden":!0,className:`absolute right-2 top-2 h-1.5 w-1.5 rounded-full ${r?"bg-peacock-500":"bg-slate-300"}`})]},n)})}),ys=({organizationId:s})=>{const[t,a]=x.useState([]),[i,n]=x.useState([]),[r,o]=x.useState(!0),[l,u]=x.useState(null),[m,g]=x.useState(""),[h,p]=x.useState(""),[f,y]=x.useState({...U}),[C,A]=x.useState([]),[k,M]=x.useState(!1),E=x.useCallback(async()=>{o(!0);try{const[c,N]=await Promise.all([Be(s),ue(s)]);a(c),n(N.filter(d=>d.status==="active"))}catch(c){_(c,"Load organization groups")}finally{o(!1)}},[s]);x.useEffect(()=>{E()},[E]);const S=()=>{u(null),g(""),p(""),y({...U}),A([])},v=c=>{u(c.id),g(c.name),p(c.description),y({...c.capabilities}),A([...c.memberIds])},I=async()=>{const c=m.trim();if(!c){_(new Error("Group name is required."),"Save group");return}M(!0);try{await O((async()=>{if(l)await Ue({groupId:l,name:c,description:h,capabilities:f}),await ae(l,C);else{const N=await ze({organizationId:s,name:c,description:h,capabilities:f});await ae(N.id,C)}await E(),await T(),S()})(),{loading:l?"Updating groupâ¦":"Creating groupâ¦",success:l?"Group updated":"Group created",context:"Save organization group"})}finally{M(!1)}}
36,P=async c=>{if(window.confirm("Delete this group? Members keep their personal capabilities.")){M(!0);try{await O(Fe(c).then(()=>E()),{loading:"Deleting groupâ¦",success:"Group deleted",context:"Delete organization group"}),l===c&&S(),await T()}finally{M(!1)}}},G=c=>{A(N=>N.includes(c)?N.filter(d=>d!==c):[...N,c])};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"rounded-xl bg-peacock-50 p-2 text-peacock-700 ring-1 ring-peacock-100",children:e.jsx(de,{className:"h-5 w-5","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold text-slate-900",children:l?"Edit group":"Create group"}),e.jsx("p",{className:"mt-1 text-sm text-slate-600",children:"Groups carry workspace-wide access rules. Members inherit the group's capabilities in addition to their personal settings."})]})]}),e.jsxs("div",{className:"mt-5 space-y-4",children:[e.jsxs("label",{className:"block text-sm font-medium text-slate-700",children:["Name",e.jsx("input",{value:m,onChange:c=>g(c.target.value),className:"mt-1.5 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm outline-none ring-peacock-500 focus:border-peacock-300 focus:ring-2",placeholder:"e.g. Editors",disabled:k})]}),e.jsxs("label",{className:"block text-sm font-medium text-slate-700",children:["Description",e.jsx("input",{value:h,onChange:c=>p(c.target.value),className:"mt-1.5 w-full rounded-xl border border-slate-200 px-3 py-2 text-sm outline-none ring-peacock-500 focus:border-peacock-300 focus:ring-2",placeholder:"Optional",disabled:k})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-700",children:"Access rules"}),e.jsx("div",{className:"mt-2",children:e.jsx(Q,{value:f,onChange:y,disabled:k})})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-slate-700",children:"Members"}),e.jsx("div",{className:"mt-2 max-h-48 space-y-1 overflow-y-auto rounded-xl border border-slate-200 p-2",children:i.length===0?e.jsx("p",{className:"px-2 py-3 text-sm text-slate-500",children:"No active members yet."}):i.map(c=>e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 rounded-lg px-2 py-1.5 text-sm text-slate-700 hover:bg-slate-50",children:[e.jsx("input",{type:"checkbox",checked:C.includes(c.id),onChange:()=>G(c.id),disabled:k}),e.jsx("span",{className:"truncate",children:c.email}),e.jsx("span",{className:"ml-auto text-xs uppercase tracking-wide text-slate-400",children:c.role})]},c.id))})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>void I(),disabled:k,className:"inline-flex items-center gap-2 rounded-xl bg-peacock-600 px-4 py-2 text-sm font-semibold text-white hover:bg-peacock-700 disabled:opacity-50",children:[l?e.jsx(ne,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(Ke,{className:"h-4 w-4","aria-hidden":!0}),l?"Save group":"Create group"]}),l?e.jsx("button",{type:"button",onClick:S,disabled:k,className:"rounded-xl border border-slate-200 px-4 py-2 text-sm font-medium text-slate-700 hover:bg-slate-50",children:"Cancel"}):null]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-white p-5 shadow-sm",children:[e.jsx("h3",{className:"text-base font-semibold text-slate-900",children:"Existing groups"}),r?e.jsx("p",{className:"mt-3 text-sm text-slate-500",children:"Loading groupsâ¦"}):t.length===0?e.jsx("p",{className:"mt-3 text-sm text-slate-500",children:"No groups yet. Create one above."}):e.jsx("ul",{className:"mt-4 divide-y divide-slate-100",children:t.map(c=>e.jsxs("li",{className:"flex flex-wrap items-center justify-between gap-3 py-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium text-slate-900",children:c.name}),e.jsxs("p",{className:"text-sm text-slate-500",children:[c.memberIds.length," member",c.memberIds.length===1?"":"s",c.description?` · ${c.description}`:""]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>v(c),className:"rounded-lg border border-slate-200 p-2 text-slate-600 hover:bg-slate-50",title:"Edit",children:e.jsx(ne,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx("button",{type:"button",onClick:()=>void P(c.id),className:"rounded-lg border border-red-200 p-2 text-red-700 hover:bg-red-50",title:"Delete",children:e.jsx(Pe,{className:"h-4 w-4","aria-hidden":!0})})]})]},c.id))})]})]})},Ns=({busy:s,onInvite:t,onCancel:a})=>{const[i,n]=x.useState(""),[r,o]=x.useState("member"),[l,u]=x.useState({...U}
36),[m,g]=x.useState(null);return x.useEffect(()=>{u(r==="admin"?{...Ae}:{...U})},[r]),e.jsxs("form",{noValidate:!0,onSubmit:h=>{h.preventDefault();const p=i.trim();if(!p||!p.includes("@")){g("Enter a valid work email.");return}g(null),(async()=>(await t({email:p,role:r,capabilities:l}),n(""),o("member")))()},className:"relative overflow-hidden rounded-2xl border border-peacock-200/50 bg-white shadow-sm shadow-peacock-900/5",children:[e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute inset-x-0 top-0 h-28 bg-gradient-to-br from-peacock-600 via-peacock-700 to-brand-violet"}),e.jsx("div",{"aria-hidden":!0,className:"pointer-events-none absolute -right-10 -top-10 h-40 w-40 rounded-full bg-white/10 blur-2xl"}),e.jsxs("div",{className:"relative px-6 pb-6 pt-5 sm:px-7",children:[e.jsxs("div",{className:"flex items-start justify-between gap-3 text-white",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("span",{className:"mt-0.5 inline-flex rounded-xl bg-white/15 p-2.5 ring-1 ring-white/20 backdrop-blur-sm",children:e.jsx(oe,{className:"h-5 w-5","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold tracking-tight",children:"Invite a teammate"}),e.jsx("p",{className:"mt-1 max-w-xl text-sm text-peacock-100/90",children:"Send a secure invitation that expires in 7 days. Set their role and permissions before they join."})]})]}),e.jsx("button",{type:"button",onClick:a,disabled:s,className:"shrink-0 rounded-lg px-2.5 py-1.5 text-sm font-medium text-white/90 transition hover:bg-white/10 disabled:opacity-60",children:"Cancel"})]}),e.jsxs("div",{className:"mt-6 space-y-5 rounded-2xl border border-slate-200/80 bg-white/95 p-5 shadow-sm backdrop-blur-sm sm:p-6",children:[e.jsxs("div",{className:"grid gap-4 lg:grid-cols-[1.4fr_1fr]",children:[e.jsx(Ze,{label:"Work email",htmlFor:"invite-email",className:"gap-1.5",error:m??void 0,children:e.jsx(Je,{id:"invite-email",type:"email",value:i,hasError:!!m,onChange:h=>{n(h.target.value),m&&g(null)},className:"ph-mask rounded-xl border-slate-200 bg-slate-50/80 px-3.5 py-2.5 text-slate-900 placeholder:text-slate-400 focus:border-peacock-400 focus:bg-white focus:ring-peacock-500/20",placeholder:"[email protected]",autoComplete:"email"})}),e.jsxs("fieldset",{children:[e.jsx("legend",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Role"}),e.jsx("div",{className:"mt-1.5 grid grid-cols-2 gap-2",children:[{id:"member",label:"Member",hint:"Create & collaborate",icon:J},{id:"admin",label:"Admin",hint:"Full org control",icon:K}].map(({id:h,label:p,hint:f,icon:y})=>{const C=r===h;return e.jsxs("button",{type:"button",onClick:()=>o(h),className:`rounded-xl border px-3 py-2.5 text-left transition ${C?"border-peacock-400 bg-peacock-50 ring-2 ring-peacock-500/20":"border-slate-200 bg-white hover:border-slate-300"}`,children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(y,{className:`h-4 w-4 ${C?"text-peacock-700":"text-slate-400"}`,"aria-hidden":!0}),e.jsx("span",{className:`text-sm font-semibold ${C?"text-peacock-900":"text-slate-700"}`,children:p})]}),e.jsx("span",{className:"mt-1 block text-[11px] text-slate-500",children:f})]},h)})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:"Permissions"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"Toggle what this person can do once they accept."}),e.jsx("div",{className:"mt-3",children:e.jsx(Q,{value:l,onChange:u,disabled:s})})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 border-t border-slate-100 pt-4",children:[e.jsx("p",{className:"text-xs text-slate-500",children:"Invitation link expires automatically after 7 days."}),e.jsxs("button",{type:"submit",disabled:s||!i.trim(),className:"inline-flex items-center gap-2 rounded-xl bg-gradient-to-r from-peacock-600 to-peacock-700 px-5 py-2.5 text-sm font-semibold text-white shadow-md shadow-peacock-600/25 transition hover:brightness-105 disabled:cursor-not-allowed disabled:opacity-60",children:[e.jsx(oe,{className:"h-4 w-4","aria-hidden":!0}),"Send invitation"]})]})]})]})]})},ws=({capability:s,active:t,disabled:a=!1,onToggle:i})=>{const n=z[s],r=!!i&&!a;return e.jsx("button",{type:"button",disabled:!r,title:`${n.label}: ${t?"Allowed":"Off"} â ${n.hint}`,"aria-label":`${n.label} ${t?"allowed":"denied"}`,onClick:()=>i==null?void 0:i(),className:`inline-flex h-8 w-8 items-center justify-center rounded-lg transition ${t?"bg-emerald-50 text-emerald-700 ring-1 ring-emerald-100":"bg-slate-50 text-slate-400 ring-1 ring-slate-200"} ${r?"hover:brightness-95 cursor-pointer":"cursor-default"}`,children:t?e.jsx(Qe,{className:"h-4 w-4","aria-hidden":!0}):e.jsx(me,{className:"h-4 w-4","aria-hidden":!0})})},ks=({members:s,profileByClerkId:t,currentUser:a,busy:i,onUpdateCapabilities:n,onRequestRevokeAccess:r,onRequestRemove:o})=>e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"min-w-full text-left text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-slate-100 text-[11px] font-semibold uppercase tracking-wide text-slate-400",children:[e.jsx("th",{className:"px-5 py-3 sm:px-6",children:"Member"}),e.jsx("th",{className:"px-2 py-3",children:"Role"}),q.map(l=>e.jsx("th",{className:"px-1.5 py-3 text-center",title:z[l].hint,children:z[l].label},l)),e.jsx("th",{className:"px-2 py-3",children:"Status"}),e.jsx("th",{className:"px-5 py-3 text-right sm:px-6",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-slate-100",children:s.map(l=>{const u=fe(l,t,a),m=ve(l,t,a),g=l.clerkUserId===a.clerkUserId,h=l.status==="disabled";return e.jsxs("tr",{className:h?"bg-slate-50/70 opacity-80":"",children:[e.jsx("td",{className:"px-5 py-3.5 sm:px-6",children:e.jsxs("div",{className:"flex min-w-0 items-center gap-2.5",children:[e.jsx("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-full bg-slate-100 text-[11px] font-bold text-slate-600",children:je(m,u)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate font-medium text-slate-900",children:m??u}),m?e.jsx("p",{className:"truncate text-xs text-slate-500",children:u}):null,g?e.jsx("span",{className:"text-[10px] font-semibold uppercase tracking-wide text-peacock-700",children:"You"}):null]})]})}),e.jsx("td",{className:"px-2 py-3.5 text-xs font-semibold text-slate-600",children:Z(l.role)}),q.map(p=>e.jsx("td",{className:"px-1.5 py-3.5 text-center",children:e.jsx("div",{className:"flex justify-center",children:e.jsx(ws,{capability:p,active:l.capabilities[p],disabled:i||h,onToggle:()=>void n(l.id,{...l.capabilities,[p]:!l.capabilities[p]})})})},p)),e.jsx("td",{className:"px-2 py-3.5",children:e.jsx("span",{className:`rounded-md px-2 py-0.5 text-[11px] font-semibold ring-1 ${h?"bg-rose-50 text-rose-700 ring-rose-100":"bg-emerald-50 text-emerald-700 ring-emerald-100"}`,children:h?"Disabled":"Active"})}),e.jsx("td",{className:"px-5 py-3.5 text-right sm:px-6",children:!g&&!h?e.jsxs("div",{className:"inline-flex flex-wrap justify-end gap-1.5",children:[e.jsxs("button",{type:"button",disabled:i,onClick:()=>r(l,u),className:"inline-flex items-center gap-1 rounded-lg border border-amber-200 bg-white px-2.5 py-1.5 text-xs font-medium text-amber-800 transition hover:bg-amber-50 disabled:opacity-60",children:[e.jsx(xs,{className:"h-3 w-3","aria-hidden":!0}),"Revoke access"]}),e.jsxs("button",{type:"button",disabled:i,onClick:()=>o(l,u),className:"inline-flex items-center gap-1 rounded-lg border border-rose-200 bg-white px-2.5 py-1.5 text-xs font-medium text-rose-700 transition hover:bg-rose-50 disabled:opacity-60",children:[e.jsx(hs,{className:"h-3 w-3","aria-hidden":!0}),"Remove"]})]}):e.jsx("span",{className:"text-xs text-slate-400",children:"â"})})]},l.id)})})]})}),Cs=({member:s,displayName:t,displayEmail:a,currentClerkUserId:i,busy:n,onUpdateCapabilities:r})=>{const o=s.clerkUserId===i,l=s.role==="admin",u=s.status==="disabled";return e.jsxs("div",{className:`px-5 py-5 sm:px-6 ${u?"bg-slate-50/70 opacity-80":""}`,children:[e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between sm:gap-6",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("span",{className:`flex h-11 w-11 shrink-0 items-center justify-center rounded-full text-sm font-bold text-white shadow-md ${l?"bg-gradient-to-br from-peacock-500 to-peacock-700 shadow-peacock-500/25":"bg-gradient-to-br from-slate-500 to-slate-700 shadow-slate-500/20"}`,children:je(t,a)}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("p",{className:"truncate font-semibold text-slate-900",children:t??a}),o?e.jsx("span",{className:"rounded-full bg-peacock-50 px-2 py-0.5 text-[10px] font-bold uppercase tracking-wide text-peacock-700 ring-1 ring-peacock-100",children:"You"}):null]}),t?e.jsx("p",{className:"mt-0.5 truncate text-sm text-slate-500",children:a}):null]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 sm:justify-end sm:shrink-0",children:[e.jsxs("span",{className:`inline-flex items-center gap-1 rounded-md px-2.5 py-1 text-[11px] font-semibold uppercase tracking-wide ring-1 ${l?"bg-peacock-50 text-peacock-800 ring-peacock-100":"bg-slate-100 text-slate-600 ring-slate-200"}`,children:[l?e.jsx(K,{className:"h-3 w-3","aria-hidden":!0}):e.jsx(J,{className:"h-3 w-3","aria-hidden":!0}),Z(s.role)]}),e.jsx("span",{className:"rounded-md bg-emerald-50 px-2.5 py-1 text-[11px] font-semibold text-emerald-700 ring-1 ring-emerald-100",children:"Active"})]})]}),e.jsxs("div",{className:"mt-4",children:[e.jsx("p",{className:"mb-2 text-[11px] font-semibold uppercase tracking-wide text-slate-400",children:"Capabilities"}),e.jsx(Q,{value:s.capabilities,disabled:n||u,onChange:m=>void r(s.id,m)})]})]})},As=({members:s,profileByClerkId:t,currentClerkUserId:a,currentUserEmail:i,currentUserDisplayName:n,busy:r,onUpdateCapabilities:o,onRequestRevokeAccess:l,onRequestRemove:u})=>{const m=s.filter(y=>y.status==="active"),g=s.filter(y=>y.status==="disabled"),h=s.length===1,p={clerkUserId:a,email:i,displayName:n},f=s[0];return e.jsxs("section",{className:"rounded-2xl border border-slate-200/80 bg-white shadow-sm",children:[e.jsx("div",{className:"flex items-center justify-between gap-3 border-b border-slate-100 px-5 py-4 sm:px-6",children:e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"inline-flex rounded-lg bg-peacock-50 p-2 text-peacock-700 ring-1 ring-peacock-100",children:e.jsx(J,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-900",children:"Team members"}),e.jsxs("p",{className:"text-xs text-slate-500",children:[m.length," active",g.length>0?` · ${g.length} disabled`:""]})]})]})}),h&&f?e.jsx(Cs,{member:f,displayName:ve(f,t,p),displayEmail:fe(f,t,p),currentClerkUserId:a,busy:r,onUpdateCapabilities:o}):e.jsx(ks,{members:s,profileByClerkId:t,currentUser:p,busy:r,onUpdateCapabilities:o,onRequestRevokeAccess:l,onRequestRemove:u})]})},Ms={ok:{bar:"bg-peacock-500",badge:"bg-peacock-50 text-peacock-700 ring-peacock-100"}
36,soon:{bar:"bg-amber-500",badge:"bg-amber-50 text-amber-800 ring-amber-100"},critical:{bar:"bg-rose-500",badge:"bg-rose-50 text-rose-700 ring-rose-100"},expired:{bar:"bg-slate-300",badge:"bg-slate-100 text-slate-600 ring-slate-200"}},Ss=({invites:s,busy:t,onResend:a,onRevoke:i})=>{const[n,r]=x.useState(null);return e.jsxs("section",{className:"rounded-2xl border border-slate-200/80 bg-white shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-slate-100 px-5 py-4 sm:px-6",children:[e.jsxs("div",{className:"flex items-center gap-2.5",children:[e.jsx("span",{className:"inline-flex rounded-lg bg-amber-50 p-2 text-amber-700 ring-1 ring-amber-100",children:e.jsx(ls,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold text-slate-900",children:"Pending invitations"}),e.jsx("p",{className:"text-xs text-slate-500",children:"Awaiting acceptance · auto-expire in 7 days"})]})]}),e.jsx("span",{className:"rounded-full bg-slate-100 px-2.5 py-1 text-xs font-semibold text-slate-600",children:s.length})]}),s.length===0?e.jsxs("div",{className:"px-6 py-10 text-center",children:[e.jsx("p",{className:"text-sm font-medium text-slate-700",children:"No open invitations"}),e.jsx("p",{className:"mt-1 text-xs text-slate-500",children:"New invites appear here until they are accepted or revoked."})]}):e.jsx("ul",{className:"divide-y divide-slate-100",children:s.map(o=>{const l=js(o.expiresAt),u=Ms[l.urgency];return e.jsxs("li",{className:"flex flex-col gap-4 px-5 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-6",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-gradient-to-br from-slate-100 to-slate-200 text-xs font-bold text-slate-600 ring-1 ring-slate-200",children:ye(o.email)}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"ph-mask truncate font-medium text-slate-900",children:o.email}),e.jsxs("div",{className:"mt-1.5 flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"rounded-md bg-slate-100 px-2 py-0.5 text-[11px] font-semibold uppercase tracking-wide text-slate-600",children:Z(o.role)}),e.jsx("span",{className:`rounded-md px-2 py-0.5 text-[11px] font-semibold ring-1 ${u.badge}`,children:l.label})]}),e.jsx("div",{className:"mt-2.5 h-1.5 w-full max-w-xs overflow-hidden rounded-full bg-slate-100",children:e.jsx("div",{className:`h-full rounded-full transition-all ${u.bar}`,style:{width:`${Math.round(l.progress*100)}%`}})})]})]}),e.jsxs("div",{className:"flex shrink-0 gap-2 self-end sm:self-center",children:[e.jsxs("button",{type:"button",disabled:t,onClick:()=>void a(o.id),className:"inline-flex items-center gap-1.5 rounded-xl border border-slate-200 bg-white px-3 py-2 text-sm font-medium text-slate-700 shadow-sm transition hover:border-peacock-200 hover:bg-peacock-50/50 hover:text-peacock-800 disabled:opacity-60",children:[e.jsx(Me,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Resend"]}),e.jsxs("button",{type:"button",disabled:t,onClick:()=>r(o),className:"inline-flex items-center gap-1.5 rounded-xl border border-rose-200 bg-white px-3 py-2 text-sm font-medium text-rose-700 shadow-sm transition hover:bg-rose-50 disabled:opacity-60",children:[e.jsx(me,{className:"h-3.5 w-3.5","aria-hidden":!0}),"Revoke"]})]})]},o.id)})}),e.jsx(he,{isOpen:!!n,title:"Revoke invitation?",description:n?`Revoke the pending invite for ${n.email}? They will no longer be able to join with this link.`:void 0,confirmLabel:"Revoke invite",isDestructive:!0,onCancel:()=>r(null),onConfirm:()=>{if(!n)return;const o=n.id;r(null),i(o)}})]})},$s=({organizationId:s,organizationName:t,workspaceType:a,inviterName:i,currentClerkUserId:n,currentUserEmail:r,currentUserDisplayName:o})=>{const[l,u]=x.useState([]),[m,g]=x.useState([]),[h,p]=x.useState({}),[f,y]=x.useState(!0),[C,A]=x.useState(null),[k,M]=x.useState(!1),[E,S]=x.useState(!1),[v,I]=x.useState(null),P=x.useCallback(async()=>{y(!0);try{const[d,b]=await Promise.all([ue(s),Ge(s)]),w=await es(d.map(j=>j.clerkUserId));u(d),g(b),p(w),A(null)}catch(d){const b=D("Failed to load members",d);
36A(b.userMessage),_(b.title,b.userMessage)}finally{y(!1)}},[s]);x.useEffect(()=>{P()},[P]);const G=l.filter(d=>d.status==="active").length,c=l.filter(d=>d.status==="active"&&d.role==="admin").length,N=async d=>{M(!0),A(null);try{await d(),await P()}catch(b){const w=D("Members action failed",b);throw A(w.userMessage),b}finally{M(!1)}};return f?e.jsx("div",{className:"flex justify-center py-16",children:e.jsx(F,{size:80})}):e.jsxs(Ne.div,{initial:{opacity:0,y:12},animate:{opacity:1,y:0},transition:{duration:.35},className:"space-y-6",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[{label:"Active members",value:G,icon:be,accent:"from-peacock-500 to-peacock-700"},{label:"Pending invites",value:m.length,icon:X,accent:"from-amber-500 to-orange-600"},{label:"Admins",value:c,icon:K,accent:"from-brand-violet to-peacock-700"}].map(({label:d,value:b,icon:w,accent:j})=>e.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-slate-200/80 bg-white p-4 shadow-sm",children:[e.jsx("div",{"aria-hidden":!0,className:`absolute -right-5 -top-5 h-20 w-20 rounded-full bg-gradient-to-br ${j} opacity-10`}),e.jsx("span",{className:`mb-3 inline-flex rounded-xl bg-gradient-to-br ${j} p-2 text-white shadow-md`,children:e.jsx(w,{className:"h-4 w-4","aria-hidden":!0})}),e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-slate-500",children:d}),e.jsx("p",{className:"mt-1 text-2xl font-semibold tabular-nums text-slate-900",children:b})]},d))}),C?e.jsx("p",{className:"rounded-xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-700",role:"alert",children:C}):null,a==="personal"?e.jsx("div",{className:"rounded-2xl border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-900",children:"Personal workspaces are single-user. Create or switch to a team workspace to invite members and manage roles."}):Se()?E?e.jsx(Ns,{busy:k,onCancel:()=>S(!1),onInvite:async d=>{await N(async()=>{const b=await He({organizationId:s,email:d.email,role:d.role,capabilities:d.capabilities}),w=ie(b.token);ee(R.memberInvited,{organization_id:s,role:d.role});try{await le({invitationId:b.id,inviterName:i}),se("Invitation sent",`Invite emailed to ${b.email} (expires in 7 days).`)}catch(j){if(await te(w),j instanceof re)L("Invite created â email not configured","Invite link copied. Send it manually to your teammate.");else{const H=j instanceof Error?j.message:"Unknown email error";L("Invite created â email failed",`${H} Invite link copied â share it manually.`),D("Send invite email",j)}}S(!1)})}}):e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-slate-200/80 bg-white px-4 py-3 shadow-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold text-slate-900",children:"Invite teammates"}),e.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:"Send a 7-day invitation with role and permissions."})]}),e.jsxs("button",{type:"button",disabled:k,onClick:()=>S(!0),className:"inline-flex items-center gap-2 rounded-xl bg-gradient-to-r from-peacock-600 to-peacock-700 px-4 py-2.5 text-sm font-semibold text-white shadow-md shadow-peacock-600/20 transition hover:brightness-105 disabled:opacity-60",children:[e.jsx(X,{className:"h-4 w-4","aria-hidden":!0}),"Invite"]})]}):e.jsx("div",{className:"rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm text-slate-600",children:"Team invitations are temporarily disabled."}),a==="team"?e.jsx(Ss,{invites:m,busy:k,onResend:async d=>{await N(async()=>{const b=await Ve(d),w=ie(b.token);ee(R.memberInviteResent,{organization_id:s});try{await le({invitationId:b.id,inviterName:i}),se("Invitation resent","Expiry reset to 7 days from now.")}catch(j){if(await te(w),j instanceof re)L("Invite updated â email not configured","Invite link copied. Send it manually.");else{const H=j instanceof Error?j.message:"Unknown email error";L("Invite updated â email failed",`${H} Invite link copied â share it manually.`),D("Resend invite email",j)}}})},onRevoke:async d=>{await N(async()=>{await O(Ye(d),{loading:"Revoking invitationâ¦",success:"Invitation revoked",context:"Revoke organization invitation",event:R.memberInviteRevoked,eventProps:{organization_id:s}})})}}):null,e.jsx(As,{members:l,profileByClerkId:h,currentClerkUserId:n,currentUserEmail:r,currentUserDisplayName:o,busy:k,onUpdateCapabilities:async(d,b)=>{await N(async()=>{await O(qe(d,b),{loading:"Updating permissionsâ¦",success:"Permissions updated",context:"Update member capabilities",event:R.memberCapabilitiesUpdated,eventProps:{organization_id:s,member_id:d}});const w=l.find(j=>j.id===d);(w==null?void 0:w.clerkUserId)===n&&await T(s)})},onRequestRevokeAccess:(d,b)=>I({kind:"revoke",member:d,displayEmail:b}),onRequestRemove:(d,b)=>I({kind:"remove",member:d,displayEmail:b})}),e.jsx(he,{isOpen:!!v,title:(v==null?void 0:v.kind)==="remove"?"Remove from organization?":"Revoke access?",description:(v==null?void 0:v.kind)==="remove"?`Remove ${v.displayEmail} from this organization? They will lose access immediately.`:v?`Revoke access for ${v.displayEmail}? They will no longer be able to use this workspace until re-enabled.`:void 0,confirmLabel:(v==null?void 0:v.kind)==="remove"?"Remove member":"Revoke access",isDestructive:!0,onCancel:()=>I(null),onConfirm:()=>{if(!v)return;const d=v;I(null),N(async()=>
36{if(d.kind==="remove"){await O(We(d.member.id).then(()=>T(s)),{loading:"Removing memberâ¦",success:"Member removed",context:"Remove organization member",event:R.memberStatusUpdated,eventProps:{organization_id:s,member_id:d.member.id,status:"removed"}});return}await O(Xe(d.member.id,"disabled").then(()=>T(s)),{loading:"Revoking accessâ¦",success:"Access revoked",context:"Disable organization member",event:R.memberStatusUpdated,eventProps:{organization_id:s,member_id:d.member.id,status:"disabled"}})})}})]})},Es=({onOpenMembers:s,onOpenActivity:t})=>e.jsxs("section",{className:"rounded-2xl border border-dashed border-peacock-200 bg-peacock-50/40 p-5",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.14em] text-peacock-700",children:"First week"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-slate-900",children:"Get your workspace ready"}),e.jsx("p",{className:"mt-1 text-sm text-slate-600",children:"You're the only member so far. A few steps help the team start documenting together."}),e.jsxs("ul",{className:"mt-4 space-y-3",children:[e.jsxs("li",{className:"flex items-start gap-3 rounded-xl border border-white/80 bg-white/80 px-3 py-2.5",children:[e.jsx("span",{className:"mt-0.5 inline-flex rounded-lg bg-peacock-50 p-2 text-peacock-700 ring-1 ring-peacock-100",children:e.jsx(X,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Invite a teammate"}),e.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-600",children:"Add an editor so docs stay owned by the team, not one inbox."}),e.jsx("button",{type:"button",onClick:s,className:"mt-1.5 text-xs font-semibold text-peacock-700 hover:text-peacock-900",children:"Open Members â"})]})]}),e.jsxs("li",{className:"flex items-start gap-3 rounded-xl border border-white/80 bg-white/80 px-3 py-2.5",children:[e.jsx("span",{className:"mt-0.5 inline-flex rounded-lg bg-peacock-50 p-2 text-peacock-700 ring-1 ring-peacock-100",children:e.jsx($e,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Share a flow doc"}),e.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-600",children:"Publish a secure share link from any saved documentation."}),e.jsx(xe,{to:W,className:"mt-1.5 inline-block text-xs font-semibold text-peacock-700 hover:text-peacock-900",children:"Go to library â"})]})]}),e.jsxs("li",{className:"flex items-start gap-3 rounded-xl border border-white/80 bg-white/80 px-3 py-2.5",children:[e.jsx("span",{className:"mt-0.5 inline-flex rounded-lg bg-peacock-50 p-2 text-peacock-700 ring-1 ring-peacock-100",children:e.jsx(os,{className:"h-4 w-4","aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-900",children:"Review workspace activity"}),e.jsx("p",{className:"mt-0.5 text-xs leading-relaxed text-slate-600",children:"Check the Activity tab after the first views and exports land."}),t?e.jsx("button",{type:"button",onClick:t,className:"mt-1.5 text-xs font-semibold text-peacock-700 hover:text-peacock-900",children:"Open Activity â"}):null]})]})]})]}),V=30,Is=({organizationId:s,onOpenMembers:t,onOpenActivity:a})=>{const{summary:i,isLoading:n}=ss(V),[r,o]=x.useState(null),[l,u]=x.useState(!0);if(x.useEffect(()=>{let p=!1;return u(!0),pe(s,V).then(f=>{p||o(f)}).catch(f=>{const y=D("Failed to load contributor stats",f);p||_(y.title,y.userMessage)}).finally(()=>{p||u(!1)}),()=>{p=!0}},[s]),n||l)return e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(F,{size:80})});const m=r?fs(r):{},g=r&&r.documentCount>0?i.totals.views/r.documentCount:0,h=!!(r&&r.memberCount<=1&&t);return e.jsxs("div",{className:"space-y-8",children:[h&&t?e.jsx(Es,{onOpenMembers:t,onOpenActivity:a}):null,e.jsx(ts,{summary:i,avgViewsPerDoc:g,leaderHints:{pdfExports:m.exports?`Top: ${m.exports}`:void 0,avgViews:m.docs?`Most docs: ${m.docs}`:void 0}}),r?e.jsx(ge,{activity:r,days:V}):null]})},rt=()=>{const s=Ee(),t=Ie(),{isAdmin:a,organizationId:i,organizationName:n}=Re(),[r,o]=x.useState("overview"),l=(t==null?void 0:t.workspaceType)==="team",u=x.useRef(!1),m=s!=="loading"&&s!=="connecting"&&(s!=="cloud"||!a||!i);if(x.useEffect(()=>{!m||u.current||(u.current=!0,L("Admin access required","Only organization admins can open workspace settings."))},[m]),s==="loading"||s==="connecting")return e.jsx("div",{className:"flex min-h-[50vh] items-center justify-center",children:e.jsx(F,{size:96})});if(m||!i)return e.jsx(De,{to:W,replace:!0});const g=[{id:"overview",label:"Overview",icon:as}
36,{id:"members",label:"Members",icon:be},...l?[{id:"groups",label:"Groups",icon:de}]:[],{id:"activity",label:"Activity",icon:Te}];return e.jsxs("div",{className:"mx-auto w-full max-w-6xl space-y-6 px-4 py-8 sm:px-6",children:[e.jsxs("div",{className:"flex flex-wrap items-end justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-peacock-700",children:"Organization admin"}),e.jsx("h1",{className:"text-2xl font-bold text-slate-900",children:n})]}),e.jsx(xe,{to:W,className:"text-sm font-medium text-slate-600 hover:text-slate-900",children:"â Back to library"})]}),e.jsx("div",{className:"flex gap-1 rounded-xl bg-slate-100 p-1 ring-1 ring-slate-200/80",children:g.map(({id:h,label:p,icon:f})=>e.jsxs("button",{type:"button",onClick:()=>o(h),className:`inline-flex flex-1 items-center justify-center gap-2 rounded-lg px-3 py-2 text-sm font-medium transition ${r===h?"bg-white text-peacock-700 shadow-sm":"text-slate-600 hover:text-slate-900"}`,children:[e.jsx(f,{className:"h-4 w-4","aria-hidden":!0}),p]},h))}),r==="overview"?e.jsx(Is,{organizationId:i,onOpenMembers:()=>o("members"),onOpenActivity:()=>o("activity")}):null,r==="members"&&t?e.jsx($s,{organizationId:i,organizationName:n??"Organization",workspaceType:t.workspaceType==="team"?"team":"personal",inviterName:t.userDisplayName,currentClerkUserId:t.clerkUserId,currentUserEmail:t.userEmail,currentUserDisplayName:t.userDisplayName}):null,r==="groups"&&l?e.jsx(ys,{organizationId:i}):null,r==="activity"?e.jsx(vs,{organizationId:i}):null]})};export{rt as OrgAdminPage}; 37//# sourceMappingURL=OrgAdminPage-DLFnRPdq.js.map
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.