PageSourceSearch

https://app.elevante.ai/static/js/7807.e364d0e8.chunk.js

js elevante.ai collected 2026-09-29 10:55:51 UTC 107,898 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[7807],{17807:(e,s,a)=>{a.r(s),a.d(s,{default:()=>Ne});var t=a(89379),l=a(65043),i=a(34218),n=a(8729),r=a(53517),c=a(83256),d=a(39851),o=a(13390),x=a(91140),m=a(5949),h=a(55830),u=a(65598),p=a(92264),g=a(59938),j=a(84370),v=a(13416),y=a(19690),N=a(75395),b=a(26533),f=a(53639),A=a(20059),w=a(34537),C=a(27033),k=a(58280),S=a(6608),D=a(41680),z=a(26511),F=a(39292),L=a(71360),U=a(55731),E=a(7365),O=a(7118),I=a(50516),T=a(76833),R=a(37719),P=a(33005),$=a(26682),B=a(83204),J=a(44919),Z=a(9855),M=a(19233),W=a(42489),q=a(75088),X=a(40614),V=a(50797),_=a(95242),G=a(41180),H=a(75748),K=a(87734),Y=a(52185),Q=a(6026),ee=a(80379),se=a(28791),ae=a(16992),te=a(56102),le=a(17869),ie=a(82291),ne=a(39557),re=a(76245),ce=a(77819),de=a(76955),oe=a(22024),xe=a(70764),me=a(68931),he=a(70579);const ue={green:{ring:"ring-emerald-500/40",accent:"bg-emerald-500",text:"text-emerald-700",label:"Healthy",Icon:T.A},amber:{ring:"ring-amber-500/40",accent:"bg-amber-500",text:"text-amber-700",label:"Low",Icon:R.A},red:{ring:"ring-red-500/40",accent:"bg-red-500",text:"text-red-700",label:"Critical",Icon:re.A},error:{ring:"ring-rose-500/40",accent:"bg-rose-500",text:"text-rose-700",label:"Error",Icon:ce.A},unknown:{ring:"ring-slate-300",accent:"bg-slate-400",text:"text-slate-600",label:"Not configured",Icon:de.A}},pe={openai:{label:"OpenAI",scope:"LLM"},anthropic:{label:"Anthropic",scope:"LLM"},elevenlabs:{label:"ElevenLabs",scope:"Voice / TTS"},pexels:{label:"Pexels",scope:"Stock video"},vimeo:{label:"Vimeo",scope:"Hosting"},gamma:{label:"Gamma",scope:"Slides"},aws:{label:"AWS Lambda + S3",scope:"Render + Storage"},emergent:{label:"Emergent Universal Key",scope:"LLM Gateway"}},ge=e=>{let{block:s,onClick:a}=e;const t=ue[s.status]||ue.unknown,l=pe[s.provider]||{label:s.displayName,scope:""},{Icon:i}=t;return(0,he.jsxs)("button",{type:"button",onClick:a,"data-testid":"provider-card-".concat(s.provider),className:"group relative text-left bg-white rounded-xl border border-slate-200 p-5 transition-all hover:shadow-md hover:-translate-y-0.5 hover:border-slate-300 ring-1 ".concat(t.ring),children:[(0,he.jsxs)("div",{className:"flex items-start justify-between gap-2 mb-3",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("div",{className:"text-[11px] uppercase tracking-wide text-slate-400 font-medium",children:l.scope}),(0,he.jsx)("div",{className:"text-base font-semibold text-slate-900 leading-tight",children:l.label})]}),(0,he.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs font-medium ".concat(t.text),children:[(0,he.jsx)("span",{className:"w-2 h-2 rounded-full ".concat(t.accent)}),t.label]})]}),(0,he.jsx)("div",{className:"min-h-[50px]",children:s.metric?(0,he.jsxs)(he.Fragment,{children:[(0,he.jsx)("div",{className:"text-2xl font-semibold text-slate-900 tracking-tight",children:s.metric.pretty}),(0,he.jsx)("div",{className:"text-xs text-slate-500 mt-1",children:je(s.metric.kind)})]}):s.setupHint?(0,he.jsxs)("div",{className:"text-xs text-slate-500 leading-relaxed line-clamp-3",children:[(0,he.jsx)(i,{className:"w-3.5 h-3.5 inline mr-1 text-slate-400 relative -top-px"}),s.setupHint]}):(0,he.jsxs)("div",{className:"text-xs text-rose-600 leading-relaxed line-clamp-3",children:[(0,he.jsx)(i,{className:"w-3.5 h-3.5 inline mr-1 relative -top-px"}),s.error||"Unknown"]})})]})},je=e=>{switch(e){case"dollars_remaining":return"remaining";case"dollars_spent":return"cumulative spend";case"chars_remaining":return"characters left this cycle";case"credits_remaining":return"credits";case"requests_remaining":return"quota";default:return""}},ve=e=>{var s;let{block:a,open:t,onClose:i,onRefreshed:n}=e;const{toast:r}=(0,h.dj)(),[c,d]=(0,l.useState)(!1),[x,m]=(0,l.useState)(null);if((0,l.useEffect)(()=>{t||m(null)},[t,null===a||void 0===a?void 0:a.provider]),!t||!a)return null;const p=x||a,g=ue[p.status]||ue.unknown,j=pe[p.provider]||{label:p.displayName,scope:""};return(0,he.jsx)(u.lG,{open:t,onOpenChange:e=>!e&&i(),children:(0,he.jsxs)(u.Cf,{className:"max-w-lg","data-testid":"provider-detail-".concat(p.provider),children:[(0,he.jsxs)(u.c7,{children:[(0,he.jsxs)(u.L3,{className:"flex items-center gap-3",children:[j.label,(0,he.jsxs)("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium ".concat(g.text),children:[(0,he.jsx)("span",{className:"w-2 h-2 rounded-full ".concat(g.accent)}),g.label]})]}),(0,he.jsx)(u.rr,{children:j.scope})]}),p.metric&&(0,he.jsxs)("div",{className:"border rounded-lg p-4 bg-slate-50",children:[(0,he.jsx)("div",{className:"text-2xl font-semibold text-slate-900 tracking-tight",children:p.metric.pretty}),(0,he.jsx)("div",{className:"text-xs text-slate-500 mt-1",children:je(p.metric.kind)})]}),(null===(s=p.secondary)||void 0===s?void 0:s.length)>0&&(0,he.jsx)("div",{className:"space-y-2",children:p.secondary.map((e,s)=>(0,he.jsxs)("div",{className:"flex items-start justify-between gap-4 text-sm border-b border-slate-100 pb-2 last:border-b-0 last:pb-0",children:[(0,he.jsx)("span",{className:"text-slate-500 shrink-0",children:e.label}),(0,he.jsx)("span",{className:"text-slate-800 font-medium text-right",children:e.value})]},s))}),p.error&&(0,he.jsxs)("div",{className:"rounded-md bg-rose-50 border border-rose-200 p-3 text-xs text-rose-800",children:[(0,he.jsx)(ce.A,{className:"w-3.5 h-3.5 inline mr-1 relative -top-px"}),p.error]}),p.setupHint&&(0,he.jsx)("div",{className:"rounded-md bg-slate-50 border border-slate-200 p-3 text-xs text-slate-700",children:p.setupHint}),(0,he.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[(0,he.jsxs)("div",{className:"text-xs text-slate-400",children:["Refreshed ",p.lastRefreshedAt?new Date(p.lastRefreshedAt).toLocaleStr
1ing():"\u2014"]}),(0,he.jsxs)("div",{className:"flex gap-2",children:[p.docs&&(0,he.jsxs)("a",{href:p.docs,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs font-medium text-slate-600 hover:text-slate-900 border border-slate-200 px-3 py-1.5 rounded-md","data-testid":"provider-docs-link-".concat(p.provider),children:[(0,he.jsx)(xe.A,{className:"w-3 h-3"}),"Provider console"]}),(0,he.jsxs)(o.$,{size:"sm",variant:"outline",onClick:async()=>{try{d(!0);const e=await me.A.get("/admin/ai-usage/health/".concat(p.provider));m(e.data),n&&n(),r({title:"Refreshed ".concat(j.label)})}catch(a){var e,s;r({title:"Refresh failed",description:(null===a||void 0===a||null===(e=a.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||a.message,variant:"destructive"})}finally{d(!1)}},disabled:c,"data-testid":"provider-refresh-btn-".concat(p.provider),children:[c?(0,he.jsx)(oe.A,{className:"w-3.5 h-3.5 mr-1.5 animate-spin"}):(0,he.jsx)(I.A,{className:"w-3.5 h-3.5 mr-1.5"}),"Refresh"]})]})]})]})})},ye=()=>{const{toast:e}=(0,h.dj)(),[s,a]=(0,l.useState)(!0),[t,i]=(0,l.useState)(!1),[n,r]=(0,l.useState)(null),[c,d]=(0,l.useState)(null),u=(0,l.useCallback)(async function(){let s=arguments.length>0&&void 0!==arguments[0]&&arguments[0];try{s?i(!0):a(!0);const e=await me.A.get("/admin/ai-usage/health".concat(s?"?refresh=1":""));r(e.data)}catch(n){var t,l;e({title:"Failed to load provider health",description:(null===n||void 0===n||null===(t=n.response)||void 0===t||null===(l=t.data)||void 0===l?void 0:l.detail)||n.message,variant:"destructive"})}finally{a(!1),i(!1)}},[e]);(0,l.useEffect)(()=>{u(!1)},[u]);const p=null===n||void 0===n?void 0:n.summary;return(0,he.jsxs)("div",{className:"space-y-6","data-testid":"provider-balances-panel",children:[(0,he.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("h3",{className:"text-lg font-semibold tracking-tight",children:"Provider Balances"}),(0,he.jsx)("p",{className:"text-sm text-slate-500 mt-1",children:"Live balance, quota, and spend across every 3rd-party integration the platform depends on. Data is cached for 60s; click Refresh to force a live fetch."}),p&&(0,he.jsxs)("div",{className:"flex flex-wrap gap-2 mt-3",children:[p.green>0&&(0,he.jsxs)(m.E,{variant:"outline",className:"border-emerald-300 text-emerald-700","data-testid":"summary-green",children:[p.green," healthy"]}),p.amber>0&&(0,he.jsxs)(m.E,{variant:"outline",className:"border-amber-300 text-amber-700","data-testid":"summary-amber",children:[p.amber," low"]}),p.red>0&&(0,he.jsxs)(m.E,{variant:"outline",className:"border-red-300 text-red-700","data-testid":"summary-red",children:[p.red," critical"]}),p.error>0&&(0,he.jsxs)(m.E,{variant:"outline",className:"border-rose-300 text-rose-700","data-testid":"summary-error",children:[p.error," fetch error"]}),p.unknown>0&&(0,he.jsxs)(m.E,{variant:"outline",className:"border-slate-300 text-slate-600","data-testid":"summary-unknown",children:[p.unknown," not configured"]})]})]}),(0,he.jsxs)(o.$,{variant:"outline",size:"sm",onClick:()=>u(!0),disabled:t||s,"data-testid":"refresh-all-providers-btn",className:"shrink-0",children:[t?(0,he.jsx)(oe.A,{className:"w-4 h-4 mr-2 animate-spin"}):(0,he.jsx)(I.A,{className:"w-4 h-4 mr-2"}),"Refresh"]})]}),s?(0,he.jsx)("div",{className:"flex items-center justify-center py-16",children:(0,he.jsx)(oe.A,{className:"w-6 h-6 animate-spin text-slate-400"})}):n?(0,he.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:n.providers.map(e=>(0,he.jsx)(ge,{block:e,onClick:()=>d(e)},e.provider))}):(0,he.jsx)(x.Zp,{children:(0,he.jsx)(x.Wu,{className:"py-10 text-center text-slate-500",children:"No data"})}),(0,he.jsx)(ve,{block:c,open:!!c,onClose:()=>d(null),onRefreshed:()=>u(!0)})]})},Ne=()=>{var e,s,a,re,ce,de,oe,xe,me,ue,pe,ge,je,ve,Ne,be,fe,Ae,we,Ce,ke,Se,De,ze,Fe,Le,Ue,Ee,Oe,Ie,Te,Re,Pe,$e,Be,Je,Ze,Me,We,qe,Xe,Ve,_e,Ge,He,Ke,Ye,Qe,es,ss,as,ts,ls,is,ns,rs,cs,ds,os,xs,ms,hs,us,ps,gs,js,vs,ys,Ns,bs,fs,As,ws,Cs,ks,Ss,Ds,zs,Fs,Ls,Us;const{user:Es}=(0,n.A)(),Os=(0,i.Zp)(),{toast:Is}=(0,h.dj)(),[Ts,Rs]=(0,l.useState)("organizations"),[Ps,$s]=(0,l.useState)([]),[Bs,Js]=(0,l.useState)([]),[Zs,Ms]=(0,l.useState)(!1),[Ws,qs]=(0,l.useState)(!1),[Xs,Vs]=(0,l.useState)(null),[_s,Gs]=(0,l.useState)({enabled:!1,defaultVisibility:"allowlist",consumerOrgs:[]}),[Hs,Ks]=(0,l.useState)(!1),[Ys,Qs]=(0,l.useState)(null),[ea,sa]=(0,l.useState)(null),[aa,ta]=(0,l.useState)([]),[la,ia]=(0,l.useState)(!0),[n
1a,ra]=(0,l.useState)(!1),[ca,da]=(0,l.useState)(!1),[oa,xa]=(0,l.useState)(!1),[ma,ha]=(0,l.useState)(!1),[ua,pa]=(0,l.useState)(!1),[ga,ja]=(0,l.useState)(null),[va,ya]=(0,l.useState)(""),[Na,ba]=(0,l.useState)(""),[fa,Aa]=(0,l.useState)("all"),[wa,Ca]=(0,l.useState)("active"),[ka,Sa]=(0,l.useState)(null),[Da,za]=(0,l.useState)(!1),[Fa,La]=(0,l.useState)(null),[Ua,Ea]=(0,l.useState)(!1),[Oa,Ia]=(0,l.useState)([]),[Ta,Ra]=(0,l.useState)(!1),[Pa,$a]=(0,l.useState)(null),[Ba,Ja]=(0,l.useState)(!1),[Za,Ma]=(0,l.useState)({title:"",message:"",type:"info",targetOrgs:[],sendNotifications:!0}),[Wa,qa]=(0,l.useState)({name:"",type:"Institution",orgDomain:"",subdomain:"",logoUrl:"",logoFile:"",compactLogoUrl:"",compactLogoFile:"",phoneNumber:"",email:"",website:"",streetAddress:"",city:"",state:"",postalCode:"",country:"",taxId:"",registrationNumber:"",industry:"",primaryColor:"#FF6B35",secondaryColor:"#F7931E",tagline:"",description:""}),[Xa,Va]=(0,l.useState)(null),[_a,Ga]=(0,l.useState)(null),[Ha,Ka]=(0,l.useState)(null),[Ya,Qa]=(0,l.useState)(null),[et,st]=(0,l.useState)(null),[at,tt]=(0,l.useState)(null),[lt,it]=(0,l.useState)(!1),[nt,rt]=(0,l.useState)(""),[ct,dt]=(0,l.useState)(!1),[ot,xt]=(0,l.useState)([]),[mt,ht]=(0,l.useState)(!1),[ut,pt]=(0,l.useState)(1),[gt,jt]=(0,l.useState)(0),[vt,yt]=(0,l.useState)(()=>{const e=new Date,s=new Date(e);return s.setDate(s.getDate()-1),{action:"",orgId:"",startDate:s.toISOString().split("T")[0],endDate:e.toISOString().split("T")[0],datePreset:"1d"}}),[Nt,bt]=(0,l.useState)([]),[ft,At]=(0,l.useState)([]),[wt,Ct]=(0,l.useState)([]),[kt,St]=(0,l.useState)(!1),[Dt,zt]=(0,l.useState)(1),[Ft,Lt]=(0,l.useState)(0),[Ut,Et]=(0,l.useState)(()=>{const e=new Date,s=new Date(e);return s.setDate(s.getDate()-1),{orgId:"",action:"",startDate:s.toISOString().split("T")[0],endDate:e.toISOString().split("T")[0],datePreset:"1d"}}),[Ot,It]=(0,l.useState)({organizations:[],actions:[]}),[Tt,Rt]=(0,l.useState)("activity");(0,l.useEffect)(()=>{"SuperAdmin"===(null===Es||void 0===Es?void 0:Es.role)?(Zt(),Pt(),$t(),Bt()):Os("/courses")},[Es,Os]),(0,l.useEffect)(()=>{"audit-logs"===Ts&&_t(),"ai-usage"===Ts&&Jt()},[Ts]),(0,l.useEffect)(()=>{"audit-logs"===Ts&&"activity"===Tt&&_t()},[Ut.orgId,Ut.action,Ut.startDate,Ut.endDate,Dt]),(0,l.useEffect)(()=>{"audit-logs"===Ts&&"audit"===Tt&&Vt()},[vt.orgId,vt.action,vt.startDate,vt.endDate,ut]);const Pt=async()=>{try{za(!0);const e=await r.Ay.get("/superadmin/system/health");Sa(e.data)}catch(e){console.error("Error fetching system health:",e)}finally{za(!1)}},$t=async()=>{try{Ea(!0);const e=await r.Ay.get("/superadmin/analytics/global");La(e.data)}catch(e){console.error("Error fetching global analytics:",e)}finally{Ea(!1)}},Bt=async()=>{try{Ra(!0);const e=await r.Ay.get("/superadmin/announcements");Ia(e.data)}catch(e){console.error("Error fetching announcements:",e)}finally{Ra(!1)}},Jt=async()=>{try{Ja(!0);const e=await r.Ay.get("/superadmin/ai-usage/all-orgs");$a(e.data)}catch(e){console.error("Error fetching AI usage:",e)}finally{Ja(!1)}},Zt=async()=>{try{ia(!0);const e=await r.Ay.get("/superadmin/organizations");$s(e.data)}catch(e){Is({title:"Error",description:e.message,variant:"destructive"})}finally{ia(!1)}},Mt=async()=>{try{const e=await r.Ay.get("/admin/s2-parity");Qs(e.data)}catch(e){}};(0,l.useEffect)(()=>{Mt()},[]);const Wt=async()=>{try{Ms(!0);const e=await r.Ay.get("/superadmin/marketplaces");Js(e.data||[])}catch(a){var e,s;Is({title:"Failed to load marketplaces",description:(null===(e=a.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||a.message,variant:"destructive"})}finally{Ms(!1)}},qt=function(e,s){let a=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const l=e.target.files[0];if(!l)return;if(!l.type.startsWith("image/"))return void Is({title:"Error",description:"Please upload an image file",variant:"destructive"});if(l.size>2097152)return void Is({title:"Error",description:"File size must be less than 2MB",variant:"destructive"});const i=new FileReader;i.onloadend=()=>{const e=i.result;a?"primary"===s?(st((0,t.A)((0,t.A)({},et),{},{logoFile:e,logoUrl:""})),Ka(e)):(st((0,t.A)((0,t.A)({},et),{},{compactLogoFile:e,compactLogoUrl:""})),Qa(e)):"primary"===s?(qa((0,t.A)((0,t.A)({},Wa),{},{logoFile:e,logoUrl:""})),Va(e)):(qa((0,t.A)((0,t.A)({},Wa),{},{compactLogoFile:e,compactLogoUrl:""})),Ga(e))},i.readAsDataURL(l)},Xt=function(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1]?"primary"===e?(st((0,t.A)((0,t.A)({},et),{},{logoFile:"",logoUrl:""})),Ka(null)):(st((0,t.A)((0,t.A)({},et),{},{compactLogoFile:"",compactLogoUrl:""})),Qa(null)):"primary"===e?(qa((0,t.A)((0,t.A)({},Wa),{},{logoFile:"",logoUrl:""})),Va(null)):(qa((0,t.A)((0,t.A)({},Wa),{},{compactLogoFile:"",compactLogoUrl:""})),Ga(null))},Vt=async()=>{ht(!0);try{var e,s;const a=new URLSearchParams({page:ut,limit:20});vt.action&&a.append("action",vt.action),vt.orgId&&a.append("org_id",vt.orgId),vt.startDate&&a.append("start_date",vt.startDate),vt.endDate&&a.append("end_date",vt.endDate);const t=await r.Ay.get("/superadmin/audit-logs?".concat(a));xt(t.data.logs||[]),jt(t.data.total||0),null!==(e=t.data.filterOptions)&&void 0!==e&&e.organizations&&bt(t.data.filterOptions.organizations),null!==(s=t.data.filterOptions)&&void 0!==s&&s.actions&&At(t.data.filterOptions.actions)}catch(a){console.error("Failed to fetch audit logs:",a)}finally{ht(!1)}},_t=async()=>{St(!0);try{const e=new URLSearchParams({page:Dt,limit:20});Ut.orgId&&e.append("org_id",Ut.orgId),Ut.action&&e.append("action",Ut.action),Ut.startDate&&e.append("start_date",Ut.startDate),Ut.endD
1ate&&e.append("end_date",Ut.endDate);const s=await r.Ay.get("/superadmin/activity-logs?".concat(e));Ct(s.data.activities||[]),Lt(s.data.total||0),s.data.filterOptions&&It(s.data.filterOptions)}catch(e){console.error("Failed to fetch activity logs:",e)}finally{St(!1)}},Gt=()=>{st((0,t.A)({},ea)),ea.logoFile?Ka(ea.logoFile):ea.logoUrl?Ka(ea.logoUrl):Ka(null),ea.compactLogoFile?Qa(ea.compactLogoFile):ea.compactLogoUrl?Qa(ea.compactLogoUrl):Qa(null),xa(!0)},Ht=async(e,s)=>{s.stopPropagation(),ja(e),ha(!0),ba(""),Aa("all"),await(async e=>{try{ra(!0);const s=await r.Ay.get("/organizations/".concat(e,"/users"));ta(s.data)}catch(s){console.error("Error fetching users:",s),ta([])}finally{ra(!1)}})(e.id)},Kt=aa.filter(e=>{var s,a,t;const l=(null===(s=e.firstName)||void 0===s?void 0:s.toLowerCase().includes(Na.toLowerCase()))||(null===(a=e.lastName)||void 0===a?void 0:a.toLowerCase().includes(Na.toLowerCase()))||(null===(t=e.email)||void 0===t?void 0:t.toLowerCase().includes(Na.toLowerCase())),i="all"===fa||e.role===fa;return l&&i}),Yt=Ps.filter(e=>{var s;const a=e.name.toLowerCase().includes(va.toLowerCase())||(null===(s=e.type)||void 0===s?void 0:s.toLowerCase().includes(va.toLowerCase())),t="all"===wa||"active"===wa&&"inactive"!==e.status||"inactive"===wa&&"inactive"===e.status;return a&&t}),Qt=ea?(0,he.jsxs)("div",{className:"space-y-6",children:[(0,he.jsxs)("div",{children:[(0,he.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,he.jsx)("h3",{className:"text-lg font-semibold",children:ea.name}),(0,he.jsxs)(o.$,{size:"sm",onClick:Gt,"data-testid":"btn-edit-org-details",children:[(0,he.jsx)(b.A,{className:"w-4 h-4 mr-2"}),"Edit"]})]}),(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsx)(m.E,{variant:"active"===ea.status?"default":"secondary",children:ea.status||"active"}),(0,he.jsx)(o.$,{size:"sm",variant:"active"===ea.status?"outline":"default",onClick:async()=>{try{const e="active"===ea.status?"inactive":"active";await r.Ay.put("/superadmin/organizations/".concat(ea.id),{status:e}),Is({title:"Success",description:"Organization ".concat("active"===e?"activated":"deactivated"," successfully")}),Zt(),sa((0,t.A)((0,t.A)({},ea),{},{status:e}))}catch(e){console.error("Error toggling organization status:",e),Is({title:"Error",description:"Failed to update organization status",variant:"destructive"})}},className:"ml-auto",children:"active"===ea.status?"Deactivate":"Activate"})]})]}),(0,he.jsxs)("div",{className:"space-y-3",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-600",children:"Type"}),(0,he.jsx)("p",{className:"font-medium",children:ea.type})]}),ea.orgDomain&&(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-600",children:"Domain"}),(0,he.jsx)("p",{className:"font-medium",children:ea.orgDomain})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-600",children:"Slug"}),(0,he.jsx)("p",{className:"font-mono text-sm bg-gray-100 px-2 py-1 rounded inline-block",children:ea.slug})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-600",children:"Subdomain"}),ea.subdomain?(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsxs)("p",{className:"font-mono text-sm bg-blue-100 text-blue-800 px-2 py-1 rounded inline-block",children:["app.elevante.ai/",ea.subdomain]}),(0,he.jsx)(m.E,{variant:"outline",className:"text-xs text-green-600 border-green-300",children:"Active"})]}):(0,he.jsx)("p",{className:"text-sm text-gray-400 italic",children:"Not configured"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-600",children:"Created"}),(0,he.jsx)("p",{className:"font-medium",children:new Date(ea.createdAt).toLocaleDateString()})]})]})]}):(0,he.jsxs)("div",{className:"text-center text-gray-500 mt-8",children:[(0,he.jsx)(f.A,{className:"w-12 h-12 mx-auto mb-2 text-gray-400"}),(0,he.jsx)("p",{children:"Select an organization to view details"})]}),el=["#F26522","#F97316","#FB923C","#FDBA74","#FED7AA"];return la?(0,he.jsx)(c.A,{children:(0,he.jsx)("div",{className:"flex items-center justify-center h-full",children:(0,he.jsxs)("div",{className:"text-center",children:[(0,he.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-orange-500 mx-auto mb-4"}),(0,he.jsx)("p",{className:"text-gray-600",children:"Loading dashboard..."})]})})}):(0,he.jsxs)(c.A,{rightPanel:"organizations"===Ts?Qt:null,children:[(0,he.jsx)("div",{className:"h-full overflow-auto bg-gray-50 p-6",children:(0,he.jsxs)("div",{className:"max-w-6xl mx-auto",children:[(0,he.jsxs)("div",{className:"border-b pb-4 mb-6",children:[(0,he.jsx)("p",{className:"text-sm text-gray-500 mb-1",children:"System Administration"}),(0,he.jsxs)("div",{className:"flex items-center gap-3",children:[(0,he.jsx)("div",{className:"w-10 h-10 rounded-lg bg-gradient-to-br from-red-500 to-red-600 flex items-center justify-center",children:(0,he.jsx)(A.A,{className:"w-5 h-5 text-white"})}),(0,he.jsxs)("div",{children:[(0,he.jsx)("h1",{className:"text-xl md:text-2xl font-bold text-gray-900","data-testid":"super-admin-title",children:"Super Admin Dashboard"}),(0,he.jsx)("p",{className:"text-sm text-gray-600",children:"System-wide management and monitoring"})]})]})]}),Ys&&Ys.bakeStartedAt&&(0,he.jsx)("div",{className:"rounded-lg border p-4 ".concat(Ys.decommissionEligible?"bg-emerald-50 border-emerald-300":"bg-violet-50 border-violet-200"),"data-testid":"s2-parity-tile",children:(0,he.jsxs)("div",{className:"flex items-start justify-between gap-4 flex-wrap",children:[(0,he.jsxs)("div",{children:[(0,he.jsxs)("h3",{className:"text-sm font-medium ".concat(Ys.decommissionEligible?"text-emerald-900":"text-violet-900"," flex items-center gap-2"),children:["Cohort ACL bake \u2014 day ",Ys.daysElapsed," of ",Ys.windowDays,Ys.decommissionEligible&&(0,he.jsx)("span",{className:"text-[10px] px-2 py-0.5 rounded bg-emerald-200 text-emerald-900 font-semibold tracking-wide uppercase",children:"Ready for S2b"})]}),(0,he.jsxs)("p",{className:"text-xs mt-1 ".concat(Ys.decommissionEligible?"text-emerald-800":"text-violet-800"),children:["Dual-ACL discrepancies \u2014 last 24h: ",(0,he.jsx)("strong",{children:Ys.discrepancies.last24h}),"\xa0\xb7 last 7d: ",(0,he.jsx)("strong",{children:Ys.discrepancies.last7d}),"\xa0\xb7 total: ",(0,he.jsx)("strong",{children:Ys.discrepancies.total}),"\xa0\xb7\xa0by kind: ",(0,he.jsxs)("code",{children:["in_shadow_only=",Ys.byKind.in_shadow_only]}),", ",(0,he.jsxs)("code",{children:["in_memberships_only=",Ys.byKind.in_memberships_only]})]}),Ys.lastDiscrepancy&&(0,he.jsxs)("p",{className:"text-[11px] text-slate-600 mt-1",children:["Last: ",new Date(Ys.lastDiscrepancy.detectedAt).toLocaleStr
1ing()," \xb7 kind: ",Ys.lastDiscrepancy.kind," \xb7 user: ",null===(e=Ys.lastDiscrepancy.userId)||void 0===e?void 0:e.slice(0,8),"\u2026"]})]}),(0,he.jsx)(o.$,{variant:"ghost",size:"sm",onClick:Mt,"data-testid":"s2-parity-refresh-btn",className:"text-xs",children:"Refresh"})]})}),(0,he.jsxs)(y.tU,{value:Ts,onValueChange:Rs,className:"space-y-6",children:[(0,he.jsxs)(y.j7,{className:"grid w-full grid-cols-6",children:[(0,he.jsxs)(y.Xi,{value:"organizations",className:"flex items-center gap-2",title:"Manage tenant organizations, users, and settings",children:[(0,he.jsx)(f.A,{className:"w-4 h-4"}),"Organizations"]}),(0,he.jsxs)(y.Xi,{value:"health",className:"flex items-center gap-2",title:"Monitor platform uptime, response times, and system performance",children:[(0,he.jsx)(w.A,{className:"w-4 h-4"}),"System Health"]}),(0,he.jsxs)(y.Xi,{value:"analytics",className:"flex items-center gap-2",title:"Platform-wide usage metrics, active users, and engagement trends",children:[(0,he.jsx)(C.A,{className:"w-4 h-4"}),"Analytics"]}),(0,he.jsxs)(y.Xi,{value:"ai-usage",className:"flex items-center gap-2",title:"Track AI costs across providers (Emergent, OpenAI, Anthropic) per organization",children:[(0,he.jsx)(k.A,{className:"w-4 h-4"}),"AI Usage"]}),(0,he.jsxs)(y.Xi,{value:"announcements",className:"flex items-center gap-2",title:"Broadcast platform-wide messages and alerts to all organizations",children:[(0,he.jsx)(S.A,{className:"w-4 h-4"}),"Announcements"]}),(0,he.jsxs)(y.Xi,{value:"audit-logs",className:"flex items-center gap-2",title:"Global audit trail of admin actions and user activity across all orgs",onClick:()=>{Vt(),_t()},children:[(0,he.jsx)(D.A,{className:"w-4 h-4"}),"Audit Logs"]}),(0,he.jsxs)(y.Xi,{value:"marketplaces",className:"flex items-center gap-2",title:"Org-as-marketplace flags + cross-org course visibility",onClick:Wt,"data-testid":"tab-marketplaces",children:[(0,he.jsx)(z.A,{className:"w-4 h-4"}),"Marketplaces"]})]}),(0,he.jsxs)("p",{className:"text-xs text-gray-500 -mt-4",children:["organizations"===Ts&&"Manage all tenant organizations, their admins, plans, and configuration settings.","health"===Ts&&"Monitor platform uptime, database health, API response times, and active connections.","analytics"===Ts&&"View platform-wide usage metrics including active users, course completions, and engagement trends.","ai-usage"===Ts&&"Track AI generation costs across providers (Emergent, OpenAI, Anthropic) with per-organization breakdown.","announcements"===Ts&&"Create and manage platform-wide announcements and alerts broadcast to all organizations.","audit-logs"===Ts&&"View global audit trail of administrative actions and user activity across all organizations.","marketplaces"===Ts&&"Configure which organisations act as content marketplaces and which orgs can consume from them. (Cohort-First Redesign / Slice S7.)"]}),(0,he.jsxs)(y.av,{value:"organizations",className:"space-y-6",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between gap-4",children:[(0,he.jsxs)("div",{className:"flex items-center gap-3 flex-1",children:[(0,he.jsxs)("div",{className:"relative flex-1 max-w-md",children:[(0,he.jsx)(F.A,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),(0,he.jsx)(p.p,{placeholder:"Search organizations...",value:va,onChange:e=>ya(e.target.value),className:"pl-10","data-testid":"input-search-orgs"})]}),(0,he.jsxs)(j.l6,{value:wa,onValueChange:Ca,children:[(0,he.jsx)(j.bq,{className:"w-[150px]","data-testid":"select-status-filter",children:(0,he.jsx)(j.yv,{placeholder:"Status"})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"active",children:"Active Only"}),(0,he.jsx)(j.eb,{value:"inactive",children:"Inactive Only"}),(0,he.jsx)(j.eb,{value:"all",children:"All Status"})]})]})]}),(0,he.jsxs)(o.$,{onClick:()=>da(!0),"data-testid":"btn-create-org",children:[(0,he.jsx)(L.A,{className:"w-4 h-4 mr-2"}),"Create Organization"]})]}),(0,he.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:Yt.map(e=>(0,he.jsxs)(x.Zp,{"data-testid":"org-card-".concat(e.id),className:"cursor-pointer transition-all ".concat((null===ea||void 0===ea?void 0:ea.id)===e.id?"ring-2 ring-orange-500 bg-orange-50":"inactive"===e.status?"opacity-60 bg-gray-50 hover:shadow-md":"hover:shadow-md"),onClick:()=>sa(e),onDoubleClick:()=>{sa(e),Gt()},title:"Double-click to edit",children:[(0,he.jsxs)(x.aR,{className:"pb-3",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)(f.A,{className:"w-8 h-8 text-orange-600"}),(0,he.jsx)(m.E,{variant:"active"===e.status?"default":"secondary",children:e.status||"active"})]}),(0,he.jsx)(x.ZB,{className:"mt-3",children:e.name}),(0,he.jsx)(x.BT,{children:e.type})]}),(0,he.jsx)(x.Wu,{children:(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsxs)("div",{className:"text-sm text-gray-600 flex-1",children:[e.subdomain&&(0,he.jsxs)("p",{className:"mb-1 flex items-center gap-1",children:[(0,he.jsx)(U.A,{className:"w-3 h-3 text-blue-500"}),(0,he.jsxs)("span",{className:"font-mono text-xs text-blue-600",children:["app.elevante.ai/",e.subdomain]})]}),e.orgDomain&&(0,he.jsxs)("p",{className:"mb-1",children:["Domain: ",(0,he.jsx)("span",{className:"font-medium",children:e.orgDomain})]}),(0,he.jsxs)("p",{className:"text-xs text-gray-500",children:["Created: ",new Date(e.createdAt).toLocaleDateString()]})]}),(0,he.jsxs)("div",{className:"flex items-center gap-1 ml-2",children:[(0,he.jsx)(o.$,{variant:"ghost",size:"sm",onClick:s=>{s.stopPropagation();const a=e.subdomain||e.id;Os("/orgs/".concat(a,"/settings"))},"data-testid":"btn-org-settings-".concat(e.id),title:"Organization Settings (SSO, Branding)",children:(0,he.jsx)(E.A,{className:"w-4 h-4"})}),(0,he.jsx)(o.$,{variant:"ghost",size:"sm",onClick:s=>Ht(e,s),"data-testid":"btn-view-users-".concat(e.id),title:"View Users",children:(0,he.jsx)(O.A,{className:"w-4 h-4"})})]})]})})]},e.id))}),0===Yt.length&&(0,he.jsxs)("div",{className:"text-center py-12",children:[(0,he.jsx)(f.A,{className:"w-16 h-16 mx-auto text-gray-300 mb-4"}),(0,he.jsx)("p",{className:"text-gray-500",children:"No organizations foun
1d"})]})]}),(0,he.jsxs)(y.av,{value:"health",className:"space-y-6",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("h2",{className:"text-lg font-semibold",children:"System Health"}),(0,he.jsxs)(o.$,{variant:"outline",size:"sm",onClick:Pt,disabled:Da,children:[(0,he.jsx)(I.A,{className:"w-4 h-4 mr-2 ".concat(Da?"animate-spin":"")}),"Refresh"]})]}),Da?(0,he.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,he.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-orange-500"})}):ka?(0,he.jsxs)("div",{className:"space-y-6",children:[(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{className:"pb-3",children:(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)(x.ZB,{className:"text-base",children:"Overall Status"}),(0,he.jsxs)(m.E,{variant:"healthy"===ka.status?"default":"degraded"===ka.status?"outline":"destructive",children:["healthy"===ka.status?(0,he.jsx)(T.A,{className:"w-3 h-3 mr-1"}):(0,he.jsx)(R.A,{className:"w-3 h-3 mr-1"}),null===(s=ka.status)||void 0===s?void 0:s.toUpperCase()]})]})}),(0,he.jsx)(x.Wu,{children:(0,he.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-gray-500",children:"Response Time"}),(0,he.jsxs)("p",{className:"font-semibold",children:[ka.responseTime,"ms"]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-gray-500",children:"Active Sessions"}),(0,he.jsx)("p",{className:"font-semibold",children:(null===(a=ka.sessions)||void 0===a?void 0:a.active)||0})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-gray-500",children:"Active Organizations"}),(0,he.jsxs)("p",{className:"font-semibold",children:[(null===(re=ka.organizations)||void 0===re?void 0:re.active)||0," / ",(null===(ce=ka.organizations)||void 0===ce?void 0:ce.total)||0]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-gray-500",children:"Errors (24h)"}),(0,he.jsx)("p",{className:"font-semibold ".concat(ka.errors24h>0?"text-red-600":"text-green-600"),children:ka.errors24h||0})]})]})})]}),(0,he.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{className:"pb-2",children:(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsx)(P.A,{className:"w-5 h-5 text-blue-600"}),(0,he.jsx)(x.ZB,{className:"text-base",children:"Database"})]})}),(0,he.jsx)(x.Wu,{children:(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("span",{className:"text-sm text-gray-500",children:"Status"}),(0,he.jsx)(m.E,{variant:"healthy"===(null===(de=ka.database)||void 0===de?void 0:de.status)?"default":"destructive",children:null===(oe=ka.database)||void 0===oe?void 0:oe.status})]}),(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("span",{className:"text-sm text-gray-500",children:"Latency"}),(0,he.jsxs)("span",{className:"text-sm font-medium",children:[null===(xe=ka.database)||void 0===xe?void 0:xe.latency,"ms"]})]}),(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("span",{className:"text-sm text-gray-500",children:"Type"}),(0,he.jsx)("span",{className:"text-sm font-medium",children:null===(me=ka.database)||void 0===me?void 0:me.type})]})]})})]}),(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{className:"pb-2",children:(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsx)(k.A,{className:"w-5 h-5 text-green-600"}),(0,he.jsx)(x.ZB,{className:"text-base",children:"CPU"})]})}),(0,he.jsx)(x.Wu,{children:(0,he.jsxs)("div",{className:"space-y-3",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("span",{className:"text-sm text-gray-500",children:"Usage"}),(0,he.jsxs)("span",{className:"text-sm font-medium",children:[null===(ue=ka.system)||void 0===ue?void 0:ue.cpu,"%"]})]}),(0,he.jsx)(N.k,{value:(null===(pe=ka.system)||void 0===pe?void 0:pe.cpu)||0,className:"h-2"})]})})]}),(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{className:"pb-2",children:(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsx)($.A,{className:"w-5 h-5 text-purple-600"}),(0,he.jsx)(x.ZB,{className:"text-base",children:"Memory"})]})}),(0,he.jsx)(x.Wu,{children:(0,he.jsxs)("div",{className:"space-y-3",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("span",{className:"text-sm text-gray-500",children:"Used"}),(0,he.jsxs)("span",{className:"text-sm font-medium",children:[null===(ge=ka.system)||void 0===ge||null===(je=ge.memory)||void 0===je?void 0:je.used,"%"]})]}),(0,he.jsx)(N.k,{value:(null===(ve=ka.system)||void 0===ve||null===(Ne=ve.memory)||void 0===Ne?void 0:Ne.used)||0,className:"h-2"}),(0,he.jsxs)("p",{className:"text-xs text-gray-500",children:[null===(be=ka.system)||void 0===be||null===(fe=be.memory)||void 0===fe?void 0:fe.available," GB available of ",null===(Ae=ka.system)||void 0===Ae||null===(we=Ae.memory)||void 0===we?void 0:we.total," GB"]})]})})]})]}),(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{className:"pb-2",children:(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsx)(B.A,{className:"w-5 h-5 text-orange-600"}),(0,he.jsx)(x.ZB,{className:"text-base",children:"Disk Storage"})]})}),(0,he.jsx)(x.Wu,{children:(0,he.jsxs)("div",{className:"space-y-3",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("span",{className:"text-sm text-gray-500",children:"Used"}),(0,he.jsxs)("span",{className:"text-sm font-medium",children:[null===(Ce=ka.system)||void 0===Ce||null===(ke=Ce.disk)||void 0===ke?void 0:ke.used,"%"]})]}),(0,he.jsx)(N.k,{value:(null===(Se=ka.system)||void 0===Se||null===(De=Se.disk)||void 0===De?void 0:De.used)||0,className:"h-2"}),(0,he.jsxs)("p",{className:"text-xs text-gray-500",children:[null===(ze=ka.system)||void 0===ze||null===(Fe=ze.disk)||void 0===Fe?void 0:Fe.free," GB free of ",null===(Le=ka.system)||void 0===Le||null===(Ue=Le.disk)||void 0===Ue?void 0:Ue.total," GB total"]})]})})]})]}):(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"py-12 text-center",children:[(0,he.jsx)(w.A,{className:"w-12 h-12 mx-auto text-gray-300 mb-4"}),(0,he.jsx)("p",{className:"text-gray-500",children:"Unable to fetch system health data"})]})})]}),(0,he.jsxs)(y.av,{value:"analytics",className:"space-y-6",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("h2",{className:"text-lg font-semibold",children:"Platform Analytics"}),(0,he.jsxs)(o.$,{variant:"outline",size:"sm",onClick:$t,disabled:Ua,children:[(0,he.jsx)(I.A,{className:"w-4 h-4 mr-2 ".concat(Ua?"animate-spin":"")}),"Refresh"]})]}),Ua?(0,he.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,he.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-orange-500"})}):Fa?(0,he.jsxs)("div",{className:"space-y-6",children:[(0,he.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-5 ga
1p-4",children:[(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"pt-4",children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Total Users"}),(0,he.jsx)("p",{className:"text-2xl font-bold text-orange-600",children:(null===(Ee=Fa.overview)||void 0===Ee?void 0:Ee.totalUsers)||0})]})}),(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"pt-4",children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Active Learners"}),(0,he.jsx)("p",{className:"text-2xl font-bold text-green-600",children:(null===(Oe=Fa.overview)||void 0===Oe?void 0:Oe.activeLearners)||0})]})}),(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"pt-4",children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Total Courses"}),(0,he.jsx)("p",{className:"text-2xl font-bold text-blue-600",children:(null===(Ie=Fa.overview)||void 0===Ie?void 0:Ie.totalCourses)||0})]})}),(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"pt-4",children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Published"}),(0,he.jsx)("p",{className:"text-2xl font-bold text-purple-600",children:(null===(Te=Fa.overview)||void 0===Te?void 0:Te.publishedCourses)||0})]})}),(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"pt-4",children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Avg Completion"}),(0,he.jsxs)("p",{className:"text-2xl font-bold text-amber-600",children:[(null===(Re=Fa.overview)||void 0===Re?void 0:Re.avgCompletion)||0,"%"]})]})})]}),(0,he.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{children:(0,he.jsx)(x.ZB,{className:"text-base",children:"User Growth (6 Months)"})}),(0,he.jsx)(x.Wu,{children:(0,he.jsx)("div",{className:"h-64",children:(0,he.jsx)(G.u,{width:"100%",height:"100%",children:(0,he.jsxs)(H.b,{data:Fa.userGrowth||[],children:[(0,he.jsx)(K.d,{strokeDasharray:"3 3"}),(0,he.jsx)(Y.W,{dataKey:"month"}),(0,he.jsx)(Q.h,{}),(0,he.jsx)(ee.m,{}),(0,he.jsx)(se.N1,{type:"monotone",dataKey:"users",stroke:"#F26522",strokeWidth:2})]})})})})]}),(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{children:(0,he.jsx)(x.ZB,{className:"text-base",children:"Role Distribution"})}),(0,he.jsx)(x.Wu,{children:(0,he.jsx)("div",{className:"h-64",children:(0,he.jsx)(G.u,{width:"100%",height:"100%",children:(0,he.jsxs)(ae.r,{children:[(0,he.jsx)(te.Fq,{data:Fa.roleDistribution||[],cx:"50%",cy:"50%",labelLine:!1,label:e=>{let{name:s,percent:a}=e;return"".concat(s," (").concat((100*a).toFixed(0),"%)")},outerRadius:80,fill:"#8884d8",dataKey:"value",children:(Fa.roleDistribution||[]).map((e,s)=>(0,he.jsx)(le.f,{fill:el[s%el.length]},"cell-".concat(s)))}),(0,he.jsx)(ee.m,{})]})})})})]}),(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{children:(0,he.jsx)(x.ZB,{className:"text-base",children:"Enrollment Trends"})}),(0,he.jsx)(x.Wu,{children:(0,he.jsx)("div",{className:"h-64",children:(0,he.jsx)(G.u,{width:"100%",height:"100%",children:(0,he.jsxs)(ie.E,{data:Fa.enrollmentTrends||[],children:[(0,he.jsx)(K.d,{strokeDasharray:"3 3"}),(0,he.jsx)(Y.W,{dataKey:"month"}),(0,he.jsx)(Q.h,{}),(0,he.jsx)(ee.m,{}),(0,he.jsx)(ne.yP,{dataKey:"enrollments",fill:"#F97316"})]})})})})]}),(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{children:(0,he.jsx)(x.ZB,{className:"text-base",children:"Top Courses by Enrollment"})}),(0,he.jsx)(x.Wu,{children:(0,he.jsxs)("div",{className:"space-y-3",children:[(Fa.topCourses||[]).map((e,s)=>(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("span",{className:"text-sm truncate max-w-[200px]",children:e.name}),(0,he.jsxs)(m.E,{variant:"outline",children:[e.enrollments," enrolled"]})]},s)),0===(Fa.topCourses||[]).length&&(0,he.jsx)("p",{className:"text-sm text-gray-500 text-center py-4",children:"No course data available"})]})})]})]})]}):(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"py-12 text-center",children:[(0,he.jsx)(C.A,{className:"w-12 h-12 mx-auto text-gray-300 mb-4"}),(0,he.jsx)("p",{className:"text-gray-500",children:"Unable to fetch analytics data"})]})})]}),(0,he.jsxs)(y.av,{value:"ai-usage",className:"space-y-6","data-testid":"ai-usage-tab",children:[(0,he.jsxs)(x.Zp,{"data-testid":"provider-balances-card",children:[(0,he.jsxs)(x.aR,{children:[(0,he.jsx)(x.ZB,{className:"text-base",children:"Third-Party Provider Balances"}),(0,he.jsx)(x.BT,{children:"Live credit, quota, and spend signals for every integration the platform depends on. These are platform-level keys shared across all tenants \u2014 numbers represent total consumption, not per-org spend."})]}),(0,he.jsx)(x.Wu,{children:(0,he.jsx)(ye,{})})]}),(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("h2",{className:"text-lg font-semibold",children:"Global AI Usage"}),(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Cross-organization AI usage and provider breakdown"})]}),(0,he.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,he.jsx)(o.$,{variant:"outline",size:"sm",onClick:()=>Os("/superadmin/ai-api-calls"),"data-testid":"btn-view-ai-api-calls",children:"View Per-Call Log"}),(0,he.jsx)(o.$,{variant:"outline",size:"sm",onClick:()=>Os("/superadmin/lean-canvas-ai"),"data-testid":"btn-lean-canvas-ai",children:"Lean Canvas AI"}),(0,he.jsx)(o.$,{variant:"outline",size:"sm",onClick:()=>Os("/superadmin/stakeholder-sim"),"data-testid":"btn-stakeholder-sim-config",children:"Stakeholder Sim Prompts"}),(0,he.jsx)(o.$,{variant:"outline",size:"sm",onClick:()=>Os("/superadmin/industry-labs"),"data-testid":"btn-industry-lab-registry",children:"Industry Lab Registry"}),(0,he.jsx)(o.$,{variant:"outline",size:"sm",onClick:()=>Os("/superadmin/jobs"),"data-testid":"btn-job-monitor",children:"Job Monitor"}),(0,he.jsx)(o.$,{variant:"outline",size:"sm",onClick:()=>Os("/superadmin/perf"),"data-testid":"btn-perf-dashboard",children:"Performance"}),(0,he.jsxs)(o.$,{variant:"outline",size:"sm",onClick:Jt,disabled:Ba,children:[(0,he.jsx)(I.A,{className:"w-4 h-4 mr-2 ".concat(Ba?"animate-spin":"")}),"Refresh"]})]})]}),Ba?(0,he.jsxs)("div",{className:"flex items-center justify-center py-12",children:[(0,he.jsx)(I.A,{className:"w-6 h-6 animate-spin text-gray-400"}),(0,he.jsx)("span",{className:"ml-2 text-gray-500",children:"Loading AI usage data..."})]}):Pa?(0,he.jsxs)("div",{className:"space-y-6",children:[(0,he.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 ga
1p-4",children:[(0,he.jsx)(x.Zp,{"data-testid":"ai-usage-total-orgs",children:(0,he.jsx)(x.Wu,{className:"pt-6",children:(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Organizations"}),(0,he.jsx)("p",{className:"text-2xl font-bold text-gray-900",children:(null===(Pe=Pa.summary)||void 0===Pe?void 0:Pe.totalOrganizations)||0}),(0,he.jsx)("p",{className:"text-xs text-gray-400",children:"with AI enabled"})]}),(0,he.jsx)("div",{className:"p-3 rounded-full bg-blue-100",children:(0,he.jsx)(f.A,{className:"w-6 h-6 text-blue-600"})})]})})}),(0,he.jsx)(x.Zp,{"data-testid":"ai-usage-assistant-cost",children:(0,he.jsx)(x.Wu,{className:"pt-6",children:(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"AI Assistant"}),(0,he.jsxs)("p",{className:"text-2xl font-bold text-gray-900",children:["$",((null===($e=Pa.summary)||void 0===$e?void 0:$e.totalMonthlySpentUsd)||0).toFixed(4)]}),(0,he.jsxs)("p",{className:"text-xs text-gray-400",children:[(null===(Be=Pa.summary)||void 0===Be?void 0:Be.totalMonthlyMessages)||0," messages this month"]})]}),(0,he.jsx)("div",{className:"p-3 rounded-full bg-purple-100",children:(0,he.jsx)(k.A,{className:"w-6 h-6 text-purple-600"})})]})})}),(0,he.jsx)(x.Zp,{"data-testid":"ai-usage-blueprint-cost",children:(0,he.jsx)(x.Wu,{className:"pt-6",children:(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Course Blueprint"}),(0,he.jsxs)("p",{className:"text-2xl font-bold text-gray-900",children:["$",((null===(Je=Pa.llmUsage)||void 0===Je||null===(Ze=Je.byFeature)||void 0===Ze||null===(Me=Ze.courseBlueprint)||void 0===Me?void 0:Me.costUsd)||0).toFixed(4)]}),(0,he.jsxs)("p",{className:"text-xs text-gray-400",children:[(null===(We=Pa.llmUsage)||void 0===We||null===(qe=We.byFeature)||void 0===qe||null===(Xe=qe.courseBlueprint)||void 0===Xe?void 0:Xe.requests)||0," requests (30d)"]})]}),(0,he.jsx)("div",{className:"p-3 rounded-full bg-indigo-100",children:(0,he.jsx)(D.A,{className:"w-6 h-6 text-indigo-600"})})]})})}),(0,he.jsx)(x.Zp,{"data-testid":"ai-usage-blocks-cost",children:(0,he.jsx)(x.Wu,{className:"pt-6",children:(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Content Blocks"}),(0,he.jsxs)("p",{className:"text-2xl font-bold text-gray-900",children:["$",((null===(Ve=Pa.llmUsage)||void 0===Ve||null===(_e=Ve.byFeature)||void 0===_e||null===(Ge=_e.contentBlocks)||void 0===Ge?void 0:Ge.costUsd)||0).toFixed(4)]}),(0,he.jsxs)("p",{className:"text-xs text-gray-400",children:[(null===(He=Pa.llmUsage)||void 0===He||null===(Ke=He.byFeature)||void 0===Ke||null===(Ye=Ke.contentBlocks)||void 0===Ye?void 0:Ye.requests)||0," requests (30d)"]})]}),(0,he.jsx)("div",{className:"p-3 rounded-full bg-green-100",children:(0,he.jsx)(J.A,{className:"w-6 h-6 text-green-600"})})]})})}),(0,he.jsx)(x.Zp,{"data-testid":"ai-usage-success-rate",children:(0,he.jsx)(x.Wu,{className:"pt-6",children:(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Success Rate"}),(0,he.jsxs)("p",{className:"text-2xl font-bold text-gray-900",children:[(null===(Qe=Pa.llmUsage)||void 0===Qe?void 0:Qe.successRate)||0,"%"]}),(0,he.jsxs)("p",{className:"text-xs text-gray-400",children:[(null===(es=Pa.llmUsage)||void 0===es?void 0:es.failedRequests)||0," failed of ",(null===(ss=Pa.llmUsage)||void 0===ss?void 0:ss.totalRequests)||0]})]}),(0,he.jsx)("div",{className:"p-3 rounded-full bg-emerald-100",children:(0,he.jsx)(T.A,{className:"w-6 h-6 text-emerald-600"})})]})})})]}),(0,he.jsxs)(x.Zp,{"data-testid":"ai-usage-provider-breakdown",children:[(0,he.jsxs)(x.aR,{children:[(0,he.jsx)(x.ZB,{className:"text-base",children:"Provider Breakdown (Content Builder - 30 days)"}),(0,he.jsx)(x.BT,{children:"Usage by LLM key source"})]}),(0,he.jsx)(x.Wu,{children:(0,he.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[(0,he.jsxs)("div",{className:"p-4 border rounded-lg bg-purple-50 border-purple-200",children:[(0,he.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,he.jsx)("div",{className:"w-3 h-3 bg-purple-500 rounded-full"}),(0,he.jsx)("span",{className:"font-medium text-purple-900",children:"Emergent Key"})]}),(0,he.jsx)("p",{className:"text-2xl font-bold text-purple-900",children:(null===(as=Pa.llmUsage)||void 0===as||null===(ts=as.byProvider)||void 0===ts||null===(ls=ts.emergent)||void 0===ls?void 0:ls.requests)||0}),(0,he.jsx)("p",{className:"text-sm text-purple-700",children:"requests"}),(0,he.jsxs)("p",{className:"text-xs text-purple-600 mt-1",children:[((null===(is=Pa.llmUsage)||void 0===is||null===(ns=is.byProvider)||void 0===ns||null===(rs=ns.emergent)||void 0===rs?void 0:rs.tokens)||0).toLocaleStr
1ing()," tokens  | $",((null===(cs=Pa.llmUsage)||void 0===cs||null===(ds=cs.byProvider)||void 0===ds||null===(os=ds.emergent)||void 0===os?void 0:os.costUsd)||0).toFixed(4)]})]}),(0,he.jsxs)("div",{className:"p-4 border rounded-lg bg-green-50 border-green-200",children:[(0,he.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,he.jsx)("div",{className:"w-3 h-3 bg-green-500 rounded-full"}),(0,he.jsx)("span",{className:"font-medium text-green-900",children:"OpenAI Direct"})]}),(0,he.jsx)("p",{className:"text-2xl font-bold text-green-900",children:(null===(xs=Pa.llmUsage)||void 0===xs||null===(ms=xs.byProvider)||void 0===ms||null===(hs=ms.openai_direct)||void 0===hs?void 0:hs.requests)||0}),(0,he.jsx)("p",{className:"text-sm text-green-700",children:"requests"}),(0,he.jsxs)("p",{className:"text-xs text-green-600 mt-1",children:[((null===(us=Pa.llmUsage)||void 0===us||null===(ps=us.byProvider)||void 0===ps||null===(gs=ps.openai_direct)||void 0===gs?void 0:gs.tokens)||0).toLocaleString()," tokens  | $",((null===(js=Pa.llmUsage)||void 0===js||null===(vs=js.byProvider)||void 0===vs||null===(ys=vs.openai_direct)||void 0===ys?void 0:ys.costUsd)||0).toFixed(4)]})]}),(0,he.jsxs)("div",{className:"p-4 border rounded-lg bg-amber-50 border-amber-200",children:[(0,he.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,he.jsx)("div",{className:"w-3 h-3 bg-amber-500 rounded-full"}),(0,he.jsx)("span",{className:"font-medium text-amber-900",children:"Anthropic"})]}),(0,he.jsx)("p",{className:"text-2xl font-bold text-amber-900",children:(null===(Ns=Pa.llmUsage)||void 0===Ns||null===(bs=Ns.byProvider)||void 0===bs||null===(fs=bs.anthropic)||void 0===fs?void 0:fs.requests)||0}),(0,he.jsx)("p",{className:"text-sm text-amber-700",children:"requests"}),(0,he.jsxs)("p",{className:"text-xs text-amber-600 mt-1",children:[((null===(As=Pa.llmUsage)||void 0===As||null===(ws=As.byProvider)||void 0===ws||null===(Cs=ws.anthropic)||void 0===Cs?void 0:Cs.tokens)||0).toLocaleString()," tokens  | $",((null===(ks=Pa.llmUsage)||void 0===ks||null===(Ss=ks.byProvider)||void 0===Ss||null===(Ds=Ss.anthropic)||void 0===Ds?void 0:Ds.costUsd)||0).toFixed(4)]})]})]})})]}),(0,he.jsxs)(x.Zp,{"data-testid":"ai-usage-org-table",children:[(0,he.jsxs)(x.aR,{children:[(0,he.jsx)(x.ZB,{className:"text-base",children:"Per-Organization Usage Breakdown"}),(0,he.jsx)(x.BT,{children:"AI Assistant (monthly) + Content Builder (30 days) per organization"})]}),(0,he.jsx)(x.Wu,{children:(null===(zs=Pa.organizations)||void 0===zs?void 0:zs.length)>0?(0,he.jsx)("div",{className:"border rounded-lg overflow-x-auto",children:(0,he.jsxs)("table",{className:"w-full text-sm",children:[(0,he.jsx)("thead",{className:"bg-gray-50",children:(0,he.jsxs)("tr",{children:[(0,he.jsx)("th",{className:"px-4 py-3 text-left font-medium text-gray-600",children:"Organization"}),(0,he.jsx)("th",{className:"px-3 py-3 text-right font-medium text-purple-600",children:"AI Assistant"}),(0,he.jsx)("th",{className:"px-3 py-3 text-right font-medium text-indigo-600",children:"Blueprint"}),(0,he.jsx)("th",{className:"px-3 py-3 text-right font-medium text-green-600",children:"Blocks"}),(0,he.jsx)("th",{className:"px-3 py-3 text-right font-medium text-gray-800",children:"Total Cost"}),(0,he.jsx)("th",{className:"px-3 py-3 text-center font-medium text-gray-600",children:"Budget"}),(0,he.jsx)("th",{className:"px-3 py-3 text-center font-medium text-gray-600",children:"Status"})]})}),(0,he.jsx)("tbody",{className:"divide-y",children:Pa.organizations.map(e=>{var s,a,t,l,i;return(0,he.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,he.jsxs)("td",{className:"px-4 py-3",children:[(0,he.jsx)("div",{className:"font-medium",children:e.orgName}),(0,he.jsxs)("div",{className:"text-xs text-gray-400",children:[e.currentMonthMessages," assistant msgs"]})]}),(0,he.jsx)("td",{className:"px-3 py-3 text-right",children:(0,he.jsxs)("span",{className:"text-purple-700",children:["$",null===(s=e.currentMonthSpentUsd)||void 0===s?void 0:s.toFixed(4)]})}),(0,he.jsxs)("td",{className:"px-3 py-3 text-right",children:[(0,he.jsxs)("div",{className:"text-indigo-700",children:["$",null===(a=e.blueprintCostUsd)||void 0===a?void 0:a.toFixed(4)]}),(0,he.jsxs)("div",{className:"text-xs text-gray-400",children:[e.blueprintRequests," req"]})]}),(0,he.jsxs)("td",{className:"px-3 py-3 text-right",children:[(0,he.jsxs)("div",{className:"text-green-700",children:["$",null===(t=e.blocksCostUsd)||void 0===t?void 0:t.toFixed(4)]}),(0,he.jsxs)("div",{className:"text-xs text-gray-400",children:[e.blocksRequests," req"]})]}),(0,he.jsx)("td",{className:"px-3 py-3 text-right",children:(0,he.jsxs)("span",{className:"font-semibold",children:["$",null===(l=e.totalCostUsd)||void 0===l?void 0:l.toFixed(4)]})}),(0,he.jsxs)("td",{className:"px-3 py-3 text-center",children:[(0,he.jsxs)("div",{className:"text-xs text-gray-500",children:["$",null===(i=e.monthlyBudgetUsd)||void 0===i?void 0:i.toFixed(0)]}),(0,he.jsx)(N.k,{value:Math.min(e.usagePercent,100),className:"h-1.5 mt-1 w-16 mx-auto"})]}),(0,he.jsxs)("td",{className:"px-3 py-3 text-center",children:[e.isEnabled?(0,he.jsx)(m.E,{className:"bg-green-100 text-green-800",children:"Active"}):(0,he.jsx)(m.E,{variant:"outline",className:"text-gray-500",children:"Disabled"}),e.alertSent&&(0,he.jsx)(m.E,{className:"bg-amber-100 text-amber-800 ml-1",children:"Alert"})]})]},e.orgId)})})]})}):(0,he.jsx)("p",{className:"text-center text-gray-500 py-8",children:"No organization usage data available"})})]})]}):(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"py-12 text-center text-gray-500",children:[(0,he.jsx)(k.A,{className:"w-12 h-12 mx-auto text-gray-300 mb-3"}),(0,he.jsx)("p",{children:"No AI usage data available"}),(0,he.jsx)("p",{className:"text-sm",children:"Click Refresh to load data"})]})})]}),(0,he.jsxs)(y.av,{value:"announcements",className:"space-y-6",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsx)("h2",{className:"text-lg font-semibold",children:"System Announcements"}),(0,he.jsxs)(o.$,{onClick:()=>pa(!0),children:[(0,he.jsx)(S.A,{className:"w-4 h-4 mr-2"}),"New Announcement"]})]}),Ta?(0,he.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,he.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-orange-500"})}):(0,he.jsx)("div",{className:"space-y-4",children:Oa.length>0?Oa.map(e=>{var s;return(0,he.jsxs)(x.Zp,{children:[(0,he.jsx)(x.aR,{className:"pb-2",children:(0,he.jsxs)("div",{className:"flex items-center justify-between",children:[(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsx)(m.E,{variant:"critical"===e.type?"destructive":"warning"===e.type?"outline":"default",children:e.type}),(0,he.jsx)(x.ZB,{className:"text-base",children:e.title})]}),(0,he.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>(async e=>{try{await r.Ay.delete("/superadmin/announcements/".concat(e)),Is({title:"Success",description:"Announcement deleted"}),Bt()}catch(s){Is({title:"Error",description:s.message,variant:"destructive"})}})(e.id),children:(0,he.jsx)(Z.A,{className:"w-4 h-4 text-red-500"})})]})}),(0,he.jsxs)(x.Wu,{children:[(0,he.jsx)("p",{className:"text-sm text-gray-600 mb-2",children:e.message}),(0,he.jsxs)("p",{className:"text-xs text-gray-400",children:["Created: ",new Date(e.createdAt).toLocaleStr
1ing()," | Target: ",(null===(s=e.targetOrgs)||void 0===s?void 0:s.length)>0?"".concat(e.targetOrgs.length," orgs"):"All organizations"]})]})]},e.id)}):(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"py-12 text-center",children:[(0,he.jsx)(M.A,{className:"w-12 h-12 mx-auto text-gray-300 mb-4"}),(0,he.jsx)("p",{className:"text-gray-500",children:"No system announcements"}),(0,he.jsx)(o.$,{variant:"outline",className:"mt-4",onClick:()=>pa(!0),children:"Create First Announcement"})]})})})]}),(0,he.jsxs)(y.av,{value:"audit-logs",className:"space-y-6",children:[(0,he.jsxs)("div",{className:"flex items-center gap-4 border-b pb-4",children:[(0,he.jsxs)(o.$,{variant:"activity"===Tt?"default":"outline",size:"sm",onClick:()=>{Rt("activity"),_t()},children:[(0,he.jsx)(w.A,{className:"w-4 h-4 mr-2"}),"User Activity"]}),(0,he.jsxs)(o.$,{variant:"audit"===Tt?"default":"outline",size:"sm",onClick:()=>{Rt("audit"),Vt()},children:[(0,he.jsx)(W.A,{className:"w-4 h-4 mr-2"}),"System Audit Trail"]})]}),"activity"===Tt&&(0,he.jsxs)("div",{className:"space-y-4",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[(0,he.jsx)("h3",{className:"text-lg font-semibold",children:"User Activity Logs"}),(0,he.jsxs)("div",{className:"flex gap-2 flex-wrap items-center",children:[(0,he.jsxs)(j.l6,{value:Ut.orgId||"all",onValueChange:e=>{Et((0,t.A)((0,t.A)({},Ut),{},{orgId:"all"===e?"":e})),zt(1)},children:[(0,he.jsx)(j.bq,{className:"w-[180px]",children:(0,he.jsx)(j.yv,{placeholder:"All Organizations"})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"all",children:"All Organizations"}),null===(Fs=Ot.organizations)||void 0===Fs?void 0:Fs.map(e=>(0,he.jsx)(j.eb,{value:e.id,children:e.name},e.id))]})]}),(0,he.jsxs)(j.l6,{value:Ut.action||"all",onValueChange:e=>{Et((0,t.A)((0,t.A)({},Ut),{},{action:"all"===e?"":e})),zt(1)},children:[(0,he.jsx)(j.bq,{className:"w-[140px]",children:(0,he.jsx)(j.yv,{placeholder:"All Actions"})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"all",children:"All Actions"}),null===(Ls=Ot.actions)||void 0===Ls?void 0:Ls.map(e=>(0,he.jsx)(j.eb,{value:e,children:e.replace(/_/g," ")},e))]})]}),(0,he.jsx)(o.$,{variant:"outline",size:"sm",onClick:_t,children:(0,he.jsx)(I.A,{className:"w-4 h-4"})})]})]}),(0,he.jsxs)("div",{className:"flex items-center gap-2 flex-wrap bg-gray-50 p-3 rounded-lg",children:[(0,he.jsx)("span",{className:"text-sm text-gray-600 mr-2",children:"Date Range:"}),(0,he.jsxs)("div",{className:"flex gap-1",children:[(0,he.jsx)(o.$,{variant:"1d"===Ut.datePreset?"default":"outline",size:"sm",onClick:()=>{const e=new Date,s=new Date(e);s.setDate(s.getDate()-1),Et((0,t.A)((0,t.A)({},Ut),{},{startDate:s.toISOString().split("T")[0],endDate:e.toISOString().split("T")[0],datePreset:"1d"})),zt(1)},children:"Last 24h"}),(0,he.jsx)(o.$,{variant:"7d"===Ut.datePreset?"default":"outline",size:"sm",onClick:()=>{const e=new Date,s=new Date(e);s.setDate(s.getDate()-7),Et((0,t.A)((0,t.A)({},Ut),{},{startDate:s.toISOString().split("T")[0],endDate:e.toISOString().split("T")[0],datePreset:"7d"})),zt(1)},children:"Last 7 days"}),(0,he.jsx)(o.$,{variant:"30d"===Ut.datePreset?"default":"outline",size:"sm",onClick:()=>{const e=new Date,s=new Date(e);s.setDate(s.getDate()-30),Et((0,t.A)((0,t.A)({},Ut),{},{startDate:s.toISOString().split("T")[0],endDate:e.toISOString().split("T")[0],datePreset:"30d"})),zt(1)},children:"Last 30 days"}),(0,he.jsx)(o.$,{variant:Ut.datePreset?"outline":"default",size:"sm",onClick:()=>{Et((0,t.A)((0,t.A)({},Ut),{},{startDate:"",endDate:"",datePreset:""})),zt(1)},children:"All Time"})]}),(0,he.jsxs)("div",{className:"flex items-center gap-2 ml-4",children:[(0,he.jsx)(p.p,{type:"date",value:Ut.startDate||"",onChange:e=>Et((0,t.A)((0,t.A)({},Ut),{},{startDate:e.target.value,datePreset:"custom"})),className:"w-[140px] h-8"}),(0,he.jsx)("span",{className:"text-gray-400",children:"to"}),(0,he.jsx)(p.p,{type:"date",value:Ut.endDate||"",onChange:e=>Et((0,t.A)((0,t.A)({},Ut),{},{endDate:e.target.value,datePreset:"custom"})),className:"w-[140px] h-8"})]})]}),kt?(0,he.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,he.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-orange-500"})}):wt.length>0?(0,he.jsxs)(he.Fragment,{children:[(0,he.jsx)("div",{className:"rounded-lg border overflow-hidden",children:(0,he.jsxs)("table",{className:"w-full text-sm",children:[(0,he.jsx)("thead",{className:"bg-gray-50",children:(0,he.jsxs)("tr",{children:[(0,he.jsx)("th",{className:"px-4 py-3 text-left font-medium text-gray-600",children:"Time"}),(0,he.jsx)("th",{className:"px-4 py-3 text-left font-medium text-gray-600",children:"User"}),(0,he.jsx)("th",{className:"px-4 py-3 text-left font-medium text-gray-600",children:"Organization"}),(0,he.jsx)("th",{className:"px-4 py-3 text-left font-medium text-gray-600",children:"Cohort"}),(0,he.jsx)("th",{className:"px-4 py-3 text-left font-medium text-gray-600",children:"Action"}),(0,he.jsx)("th",{className:"px-4 py-3 text-left font-medium text-gray-600",children:"Details"})]})}),(0,he.jsx)("tbody",{className:"divide-y",children:wt.map(e=>{var s,a,t,l,i;return(0,he.jsxs)("tr",{className:"hover:bg-gray-50",children:[(0,he.jsx)("td",{className:"px-4 py-3 text-gray-500 whitespace-nowrap text-xs",children:(0,d.r6)(e.timestamp)}),(0,he.jsxs)("td",{className:"px-4 py-3",children:[(0,he.jsx)("div",{className:"font-medium text-gray-900",children:(null===(s=e.user)||void 0===s?void 0:s.name)||e.userName||"Unknown"}),(0,he.jsx)("div",{className:"text-xs text-gray-500",children:null===(a=e.user)||void 0===a?void 0:a.email})]}),(0,he.jsx)("td",{className:"px-4 py-3 text-gray-700",children:(null===(t=e.organization)||void 0===t?void 0:t.name)||"Unknown"}),(0,he.jsx)("td",{className:"px-4 py-3 text-gray-700","data-testid":"activity-cohort-".concat(e.id),children:(null===(l=e.cohort)||void 0===l?void 0:l.name)||(0,he.jsx)("span",{className:"text-gray-300",children:"\u2014"})}),(0,he.jsx)("td",{className:"px-4 py-3",children:(0,he.jsx)(m.E,{variant:"outline",className:"text-xs",children:null===(i=e.action)||void 0===i?void 0:i.replace(/_/g," ")})}),(0,he.jsx)("td",{className:"px-4 py-3 text-gray-600 text-xs max-w-[200px] truncate",children:e.detail||e.description||"-"})]},e.id)})})]})}),Ft>20&&(0,he.jsxs)("div",{className:"flex items-center justify-between pt-2",children:[(0,he.jsxs)("p",{className:"text-sm text-gray-500",children:["Showing ",20*(Dt-1)+1," - ",Math.min(20*Dt,Ft)," of ",Ft]}),(0,he.jsxs)("div",{className:"flex gap-2",children:[(0,he.jsx)(o.$,{variant:"outline",size:"sm",disabled:1===Dt,onClick:()=>{zt(e=>e-1),setTimeout(_t,0)},children:"Previous"}),(0,he.jsx)(o.$,{variant:"outline",size:"sm",disabled:20*Dt>=Ft,onClick:()=>{zt(e=>e+1),setTimeout(_t,0)},children:"Next"})]})]})]}):(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"py-12 text-center",children:[(0,he.jsx)(w.A,{className:"w-12 h-12 mx-auto text-gray-300 mb-4"}),(0,he.jsx)("p",{className:"text-gray-500",children:"No activity logs found"}),(0,he.jsx)("p",{className:"text-xs text-gray-400 mt-1",children:"User activities will appear here as they interact with the platform"})]})})]}),"audit"===Tt&&(0,he.jsxs)("div",{className:"space-y-4",children:[(0,he.jsxs)("div",{className:"flex items-center justify-between flex-wrap gap-2",children:[(0,he.jsx)("h3",{className:"text-lg font-semibold",children:"System Audit Trail"}),(0,he.jsxs)("div",{className:"flex gap-2 flex-wrap",children:[(0,he.jsxs)(j.l6,{value:vt.orgId||"all",onValueChange:e=>{yt((0,t.A)((0,t.A)({},vt),{},{orgId:"all"===e?"":e})),pt(1)},children:[(0,he.jsx)(j.bq,{className:"w-[180px]",children:(0,he.jsx)(j.yv,{placeholder:"All Organizations"})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"all",children:"All Organizations"}),null===(Us=Nt.length>0?Nt:Ot.organizations)||void 0===Us?void 0:Us.map(e=>(0,he.jsx)(j.eb,{value:e.id,children:e.name},e.id))]})]}),(0,he.jsxs)(j.l6,{value:vt.action||"all",onValueChange:e=>{yt((0,t.A)((0,t.A)({},vt),{},{action:"all"===e?"":e})),pt(1)},children:[(0,he.jsx)(j.bq,{className:"w-[160px]",children:(0,he.jsx)(j.yv,{placeholder:"All Actions"})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"all",children:"All Actions"}),ft.map(e=>(0,he.jsx)(j.eb,{value:e,children:e.replace(/\./g," ")},e))]})]}),(0,he.jsx)(o.$,{variant:"outline",size:"sm",onClick:Vt,children:(0,he.jsx)(I.A,{className:"w-4 h-4"})})]})]}),(0,he.jsxs)("div",{className:"flex items-center gap-2 flex-wrap bg-gray-50 p-3 rounded-lg",children:[(0,he.jsx)("span",{className:"text-sm text-gray-600 mr-2",children:"Date Range:"}),(0,he.jsxs)("div",{className:"flex gap-1",children:[(0,he.jsx)(o.$,{variant:"1d"===vt.datePreset?"default":"outline",size:"sm",onClick:()=>{const e=new Date,s=new Date(e);s.setDate(s.getDate()-1),yt((0,t.A)((0,t.A)({},vt),{},{startDate:s.toISOString().split("T")[0],endDate:e.toISOString().split("T")[0],datePreset:"1d"})),pt(1)},children:"Last 24h"}),(0,he.jsx)(o.$,{variant:"7d"===vt.datePreset?"default":"outline",size:"sm",onClick:()=>{const e=new Date,s=new Date(e);s.setDate(s.getDate()-7),yt((0,t.A)((0,t.A)({},vt),{},{startDate:s.toISOString().split("T")[0],endDate:e.toISOString().split("T")[0],datePreset:"7d"})),pt(1)},children:"Last 7 days"}),(0,he.jsx)(o.$,{variant:"30d"===vt.datePreset?"default":"outline",size:"sm",onClick:()=>{const e=new Date,s=new Date(e);s.setDate(s.getDate()-30),yt((0,t.A)((0,t.A)({},vt),{},{startDate:s.toISOString().split("T")[0],endDate:e.toISOString().split("T")[0],datePreset:"30d"})),pt(1)},children:"Last 30 days"}),(0,he.jsx)(o.$,{variant:vt.datePreset?"outline":"default",size:"sm",onClick:()=>{yt((0,t.A)((0,t.A)({},vt),{},{startDate:"",endDate:"",datePreset:""})),pt(1)},children:"All Time"})]}),(0,he.jsxs)("div",{className:"flex items-center gap-2 ml-4",children:[(0,he.jsx)(p.p,{type:"date",value:vt.startDate||"",onChange:e=>yt((0,t.A)((0,t.A)({},vt),{},{startDate:e.target.value,datePreset:"custom"})),className:"w-[140px] h-8"}),(0,he.jsx)("span",{className:"text-gray-400",children:"to"}),(0,he.jsx)(p.p,{type:"date",value:vt.endDate||"",onChange:e=>yt((0,t.A)((0,t.A)({},vt),{},{endDate:e.target.value,datePreset:"custom"})),className:"w-[140px] h-8"})]})]}),mt?(0,he.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,he.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-orange-500"})}):ot.length>0?(0,he.jsxs)(he.Fragment,{children:[(0,he.jsx)("div",{className:"space-y-3",children:ot.map(e=>{var s;return(0,he.jsx)(x.Zp,{className:"border-l-4 border-l-blue-500 bg-blue-50/30",children:(0,he.jsx)(x.Wu,{className:"py-3",children:(0,he.jsxs)("div",{className:"flex items-start justify-between gap-4",children:[(0,he.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,he.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,he.jsx)(m.E,{variant:"secondary",children:null===(s=e.action)||void 0===s?void 0:s.replace(/\./g," ")}),(0,he.jsxs)("span",{className:"text-xs text-gray-500",children:[e.targetType," ",e.targetId?"\u2022 ".concat(e.targetId.slice(0,8),"..."):""]})]}),(0,he.jsxs)("p",{className:"text-sm text-gray-700 mt-1",children:[(0,he.jsx)("span",{className:"font-medium",children:e.actorName||"System"})," performed action on ",(0,he.jsx)("span",{className:"font-medium",children:e.orgName})]}),e.description&&(0,he.jsx)("p",{className:"text-xs text-gray-600 mt-1",children:e.description})]}),(0,he.jsxs)("div",{className:"text-right text-xs text-gray-500 shrink-0",children:[(0,he.jsxs)("div",{className:"flex items-center gap-1",children:[(0,he.jsx)(q.A,{className:"w-3 h-3"}),e.timestamp?(0,d.r6)(e.timestamp):"Unknown"]}),(0,he.jsxs)("div",{className:"mt-1 text-gray-400",children:["by ",e.actorName||"System"]})]})]})})},e.id)})}),gt>20&&(0,he.jsxs)("div",{className:"flex items-center justify-between pt-4",children:[(0,he.jsxs)("p",{className:"text-sm text-gray-500",children:["Showing ",20*(ut-1)+1," - ",Math.min(20*ut,gt)," of ",gt]}),(0,he.jsxs)("div",{className:"flex gap-2",children:[(0,he.jsx)(o.$,{variant:"outline",size:"sm",disabled:1===ut,onClick:()=>{pt(e=>e-1),setTimeout(Vt,0)},children:"Previous"}),(0,he.jsx)(o.$,{variant:"outline",size:"sm",disabled:20*ut>=gt,onClick:()=>{pt(e=>e+1),setTimeout(Vt,0)},children:"Next"})]})]})]}):(0,he.jsx)(x.Zp,{children:(0,he.jsxs)(x.Wu,{className:"py-12 text-center",children:[(0,he.jsx)(D.A,{className:"w-12 h-12 mx-auto text-gray-300 mb-4"}),(0,he.jsx)("p",{className:"text-gray-500",children:"No audit logs found"}),(0,he.jsx)("p",{className:"text-xs text-gray-400 mt-1",children:"Audit logs will appear here when significant system changes are made"})]})})]})]}),(0,he.jsxs)(y.av,{value:"marketplaces",className:"space-y-6","data-testid":"marketplaces-tab-content",children:[(0,he.jsxs)(x.Zp,{children:[(0,he.jsxs)(x.aR,{className:"flex flex-row items-center justify-between",children:[(0,he.jsxs)("div",{children:[(0,he.jsxs)(x.ZB,{className:"flex items-center gap-2",children:[(0,he.jsx)(z.A,{className:"w-5 h-5"})," Active Marketplaces"]}),(0,he.jsx)(x.BT,{children:"Organizations with `marketplace.enabled=true` and their consumer-org + listing counts."})]}),(0,he.jsxs)(o.$,{onClick:Wt,variant:"outline",size:"sm",disabled:Zs,"data-testid":"refresh-marketplaces-btn",children:[(0,he.jsx)(I.A,{className:"w-4 h-4 mr-2 ".concat(Zs?"animate-spin":"")})," Refresh"]})]}),(0,he.jsx)(x.Wu,{children:0===Bs.length?(0,he.jsx)("div",{className:"text-sm text-gray-500 py-8 text-center","data-testid":"marketplaces-empty",children:"No organizations have marketplace mode enabled yet. Use the table below to flip the flag on for any org."}):(0,he.jsx)("div",{className:"overflow-x-auto",children:(0,he.jsxs)("table",{className:"w-full text-sm","data-testid":"active-marketplaces-table",children:[(0,he.jsx)("thead",{className:"text-left text-xs text-gray-500 border-b",children:(0,he.jsxs)("tr",{children:[(0,he.jsx)("th",{className:"py-2 pr-3",children:"Organization"}),(0,he.jsx)("th",{className:"py-2 pr-3",children:"Default Visibility"}),(0,he.jsx)("th",{className:"py-2 pr-3",children:"Consumers"}),(0,he.jsx)("th",{className:"py-2 pr-3",children:"Listings"}),(0,he.jsx)("th",{className:"py-2 pr-3",children:"Enabled At"}),(0,he.jsx)("th",{className:"py-2",children:"Enabled By"})]})}),(0,he.jsx)("tbody",{children:Bs.map(e=>(0,he.jsxs)("tr",{className:"border-b last:border-0",children:[(0,he.jsx)("td",{className:"py-2 pr-3 font-medium",children:e.name||e.orgId}),(0,he.jsx)("td",{className:"py-2 pr-3",children:(0,he.jsx)(m.E,{variant:"outline",className:"text-xs",children:e.defaultVisibility||"allowlist"})}),(0,he.jsx)("td",{className:"py-2 pr-3",children:e.consumerCount}),(0,he.jsx)("td",{className:"py-2 pr-3",children:e.listingCount}),(0,he.jsx)("td",{className:"py-2 pr-3 text-gray-500",children:e.enabledAt?new Date(e.enabledAt).toLocaleStr
1ing():"\u2014"}),(0,he.jsx)("td",{className:"py-2 text-gray-500 truncate max-w-xs",children:e.enabledBy||"\u2014"})]},e.orgId))})]})})})]}),(0,he.jsxs)(x.Zp,{children:[(0,he.jsxs)(x.aR,{children:[(0,he.jsxs)(x.ZB,{className:"flex items-center gap-2",children:[(0,he.jsx)(E.A,{className:"w-5 h-5"})," Configure Marketplace per Organisation"]}),(0,he.jsx)(x.BT,{children:'Click "Configure" on any org to flip its marketplace flag and choose consumer orgs.'})]}),(0,he.jsx)(x.Wu,{children:(0,he.jsx)("div",{className:"overflow-x-auto",children:(0,he.jsxs)("table",{className:"w-full text-sm",children:[(0,he.jsx)("thead",{className:"text-left text-xs text-gray-500 border-b",children:(0,he.jsxs)("tr",{children:[(0,he.jsx)("th",{className:"py-2 pr-3",children:"Organization"}),(0,he.jsx)("th",{className:"py-2 pr-3",children:"Status"}),(0,he.jsx)("th",{className:"py-2 pr-3",children:"Marketplace"}),(0,he.jsx)("th",{className:"py-2",children:"Actions"})]})}),(0,he.jsx)("tbody",{children:Ps.map(e=>{var s,a;const t=!(null===(s=e.marketplace)||void 0===s||!s.enabled);return(0,he.jsxs)("tr",{className:"border-b last:border-0","data-testid":"marketplace-row-".concat(e.id),children:[(0,he.jsx)("td",{className:"py-2 pr-3 font-medium",children:e.name}),(0,he.jsx)("td",{className:"py-2 pr-3",children:(0,he.jsx)(m.E,{variant:"active"===e.status?"default":"secondary",className:"text-xs",children:e.status})}),(0,he.jsxs)("td",{className:"py-2 pr-3",children:[(0,he.jsx)(m.E,{className:"text-xs ".concat(t?"bg-emerald-100 text-emerald-800":"bg-gray-100 text-gray-600"),"data-testid":"marketplace-pill-".concat(e.id),children:t?"ON":"OFF"}),t&&(0,he.jsxs)("span",{className:"ml-2 text-xs text-gray-500",children:[((null===(a=e.marketplace)||void 0===a?void 0:a.consumerOrgs)||[]).length," consumer(s)"]})]}),(0,he.jsx)("td",{className:"py-2",children:(0,he.jsx)(o.$,{size:"sm",variant:"outline",onClick:()=>(e=>{Vs(e);const s=e.marketplace||{};Gs({enabled:!!s.enabled,defaultVisibility:s.defaultVisibility||"allowlist",consumerOrgs:Array.isArray(s.consumerOrgs)?s.consumerOrgs:[]}),qs(!0)})(e),"data-testid":"configure-marketplace-btn-".concat(e.id),children:"Configure"})})]},e.id)})})]})})})]})]})]})]})}),(0,he.jsx)(u.lG,{open:ca,onOpenChange:da,children:(0,he.jsxs)(u.Cf,{className:"max-w-4xl max-h-[85vh]","data-testid":"create-org-dialog",children:[(0,he.jsxs)(u.c7,{children:[(0,he.jsx)(u.L3,{children:"Create New Organization"}),(0,he.jsx)(u.rr,{children:"Create a new tenant organization with complete profile"})]}),(0,he.jsxs)(y.tU,{defaultValue:"basic",className:"w-full",children:[(0,he.jsxs)(y.j7,{className:"grid w-full grid-cols-4",children:[(0,he.jsx)(y.Xi,{value:"basic",children:"Basic"}),(0,he.jsx)(y.Xi,{value:"branding",children:"Branding"}),(0,he.jsx)(y.Xi,{value:"contact",children:"Contact"}),(0,he.jsx)(y.Xi,{value:"business",children:"Business"})]}),(0,he.jsxs)("div",{className:"overflow-y-auto max-h-[55vh] mt-4",children:[(0,he.jsxs)(y.av,{value:"basic",className:"space-y-4",children:[(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"org-name",children:"Organization Name *"}),(0,he.jsx)(p.p,{id:"org-name",value:Wa.name,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{name:e.target.value})),placeholder:"ACME University","data-testid":"input-org-name"})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"org-type",children:"Type *"}),(0,he.jsxs)(j.l6,{value:Wa.type,onValueChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{type:e})),children:[(0,he.jsx)(j.bq,{"data-testid":"select-org-type",children:(0,he.jsx)(j.yv,{})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"Institution",children:"Institution"}),(0,he.jsx)(j.eb,{value:"Enterprise",children:"Enterprise"})]})]})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"org-domain",children:"Domain"}),(0,he.jsx)(p.p,{id:"org-domain",value:Wa.orgDomain,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{orgDomain:e.target.value})),placeholder:"example.com","data-testid":"input-org-domain"})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"subdomain",children:"Subdomain (Multi-Tenant URL)"}),(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsx)("span",{className:"text-sm text-gray-500",children:"app.elevante.ai/"}),(0,he.jsx)(p.p,{id:"subdomain",value:Wa.subdomain,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{subdomain:e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),placeholder:"acme",className:"max-w-[200px]","data-testid":"input-org-subdomain"})]}),(0,he.jsxs)("p",{className:"text-xs text-gray-500",children:["Users can access via app.elevante.ai/",Wa.subdomain||"subdomain"]})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"tagline",children:"Tagline"}),(0,he.jsx)(p.p,{id:"tagline",value:Wa.tagline,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{tagline:e.target.value})),placeholder:"Empowering education through AI"})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"description",children:"Description"}),(0,he.jsx)(v.T,{id:"description",value:Wa.description,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{description:e.target.value})),placeholder:"Brief description...",rows:3})]})]}),(0,he.jsxs)(y.av,{value:"branding",className:"space-y-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-base font-semibold",children:"Primary Logo (Login Page)"}),(0,he.jsx)("p",{className:"text-xs text-gray-500 mt-0.5",children:"Recommended: 200\xd780px or similar aspect ratio. Max height: 80px"}),(0,he.jsxs)("div",{className:"grid grid-cols-2 gap-4 mt-2",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-sm",children:"Upload File"}),(0,he.jsx)("div",{className:"mt-1 border-2 border-dashed rounded-lg p-3 text-center",children:Xa?(0,he.jsxs)("div",{className:"relative",children:[(0,he.jsx)("img",{src:Xa,alt:"Logo",className:"max-h-24 mx-auto"}),(0,he.jsx)(o.$,{size:"sm",variant:"destructive",className:"absolute top-0 right-0",onClick:()=>Xt("primary"),children:(0,he.jsx)(X.A,{className:"w-3 h-3"})})]}):(0,he.jsxs)("div",{children:[(0,he.jsx)(V.A,{className:"w-6 h-6 mx-auto text-gray-400 mb-1"}),(0,he.jsx)("input",{type:"file",accept:"image/*",onChange:e=>qt(e,"primary"),className:"hidden",id:"primary-logo"}),(0,he.jsx)(o.$,{size:"sm",variant:"outline",onClick:()=>document.getElementById("primary-logo").click(),children:"Choose File"})]})})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-sm",children:"Or URL"}),(0,he.jsx)(p.p,{value:Wa.logoUrl,onChange:e=>{qa((0,t.A)((0,t.A)({},Wa),{},{logoUrl:e.target.value,logoFile:""})),Va(e.target.value)},placeholder:"https://...",className:"mt-1"})]})]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-base font-semibold",children:"Compact Logo (Sidebar Header)"}),(0,he.jsx)("p",{className:"text-xs text-gray-500 mt-0.5",children:"Recommended: 150\xd740px or similar. Displays next to Elevante.AI logo. Max width: 150px, Max height: 40px"}),(0,he.jsxs)("div",{className:"grid grid-cols-2 gap-4 mt-2",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-sm",children:"Upload File"}),(0,he.jsx)("div",{className:"mt-1 border-2 border-dashed rounded-lg p-3 text-center",children:_a?(0,he.jsxs)("div",{className:"relative",children:[(0,he.jsx)("img",{src:_a,alt:"Compact Logo",className:"max-h-16 mx-auto"}),(0,he.jsx)(o.$,{size:"sm",variant:"destructive",className:"absolute top-0 right-0",onClick:()=>Xt("compact"),children:(0,he.jsx)(X.A,{className:"w-3 h-3"})})]}):(0,he.jsxs)("div",{children:[(0,he.jsx)(V.A,{className:"w-6 h-6 mx-auto text-gray-400 mb-1"}),(0,he.jsx)("input",{type:"file",accept:"image/*",onChange:e=>qt(e,"compact"),className:"hidden",id:"compact-logo"}),(0,he.jsx)(o.$,{size:"sm",variant:"outline",onClick:()=>document.getElementById("compact-logo").click(),children:"Choose File"})]})})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-sm",children:"Or URL"}),(0,he.jsx)(p.p,{value:Wa.compactLogoUrl,onChange:e=>{qa((0,t.A)((0,t.A)({},Wa),{},{compactLogoUrl:e.target.value,compactLogoFile:""})),Ga(e.target.value)},placeholder:"https://...",className:"mt-1"})]})]})]}),(0,he.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Primary Color"}),(0,he.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,he.jsx)(p.p,{type:"color",value:Wa.primaryColor,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{primaryColor:e.target.value})),className:"w-16 h-10"}),(0,he.jsx)(p.p,{value:Wa.primaryColor,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{primaryColor:e.target.value})),placeholder:"#FF6B35"})]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Secondary Color"}),(0,he.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,he.jsx)(p.p,{type:"color",value:Wa.secondaryColor,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{secondaryColor:e.target.value})),className:"w-16 h-10"}),(0,he.jsx)(p.p,{value:Wa.secondaryColor,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{secondaryColor:e.target.value})),placeholder:"#F7931E"})]})]})]})]}),(0,he.jsxs)(y.av,{value:"contact",className:"space-y-4",children:[(0,he.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Phone"}),(0,he.jsx)(p.p,{value:Wa.phoneNumber,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{phoneNumber:e.target.value})),placeholder:"+1 (555) 123-4567"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Email"}),(0,he.jsx)(p.p,{type:"email",value:Wa.email,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{email:e.target.value})),placeholder:"[email protected]"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Website"}),(0,he.jsx)(p.p,{value:Wa.website,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{website:e.target.value})),placeholder:"https://..."})]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Street Address"}),(0,he.jsx)(p.p,{value:Wa.streetAddress,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{streetAddress:e.target.value})),placeholder:"123 Main St"})]}),(0,he.jsxs)("div",{className:"grid grid-cols-4 gap-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"City"}),(0,he.jsx)(p.p,{value:Wa.city,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{city:e.target.value})),placeholder:"New York"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"State"}),(0,he.jsx)(p.p,{value:Wa.state,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{state:e.target.value})),placeholder:"NY"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Postal Code"}),(0,he.jsx)(p.p,{value:Wa.postalCode,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{postalCode:e.target.value})),placeholder:"10001"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Country"}),(0,he.jsx)(p.p,{value:Wa.country,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{country:e.target.value})),placeholder:"USA"})]})]})]}),(0,he.jsx)(y.av,{value:"business",className:"space-y-4",children:(0,he.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Tax ID / EIN"}),(0,he.jsx)(p.p,{value:Wa.taxId,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{taxId:e.target.value})),placeholder:"XX-XXXXXXX"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Registration Number"}),(0,he.jsx)(p.p,{value:Wa.registrationNumber,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{registrationNumber:e.target.value})),placeholder:"REG-12345"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Industry"}),(0,he.jsx)(p.p,{value:Wa.industry,onChange:e=>qa((0,t.A)((0,t.A)({},Wa),{},{industry:e.target.value})),placeholder:"Education"})]})]})})]})]}),(0,he.jsxs)(u.Es,{children:[(0,he.jsx)(o.$,{variant:"outline",onClick:()=>da(!1),"data-testid":"btn-cancel-org",children:"Cancel"}),(0,he.jsx)(o.$,{onClick:async()=>{try{await r.Ay.post("/superadmin/organizations",Wa),Is({title:"Success",description:"Organization created successfully"}),da(!1),qa({name:"",type:"Institution",orgDomain:"",subdomain:"",logoUrl:"",logoFile:"",compactLogoUrl:"",compactLogoFile:"",phoneNumber:"",email:"",website:"",streetAddress:"",city:"",state:"",postalCode:"",country:"",taxId:"",registrationNumber:"",industry:"",primaryColor:"#FF6B35",
1secondaryColor:"#F7931E",tagline:"",description:""}),Va(null),Ga(null),Zt()}catch(e){Is({title:"Error",description:e.message,variant:"destructive"})}},disabled:!Wa.name,"data-testid":"btn-save-org",children:"Create Organization"})]})]})}),(0,he.jsx)(u.lG,{open:ma,onOpenChange:ha,children:(0,he.jsxs)(u.Cf,{className:"max-w-3xl max-h-[80vh]","data-testid":"users-dialog",children:[(0,he.jsxs)(u.c7,{children:[(0,he.jsxs)(u.L3,{children:["Users in ",null===ga||void 0===ga?void 0:ga.name]}),(0,he.jsx)(u.rr,{children:"Manage users for this organization"})]}),(0,he.jsxs)("div",{className:"space-y-4",children:[(0,he.jsxs)("div",{className:"flex gap-3",children:[(0,he.jsxs)("div",{className:"flex-1 relative",children:[(0,he.jsx)(F.A,{className:"absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 w-4 h-4"}),(0,he.jsx)(p.p,{placeholder:"Search by name or email...",value:Na,onChange:e=>ba(e.target.value),className:"pl-10","data-testid":"input-search-users"})]}),(0,he.jsxs)(j.l6,{value:fa,onValueChange:Aa,children:[(0,he.jsx)(j.bq,{className:"w-40","data-testid":"select-role-filter",children:(0,he.jsx)(j.yv,{placeholder:"Filter by role"})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"all",children:"All Roles"}),(0,he.jsx)(j.eb,{value:"TenantAdmin",children:"Admin"}),(0,he.jsx)(j.eb,{value:"Instructor",children:"Instructor"}),(0,he.jsx)(j.eb,{value:"Learner",children:"Learner"})]})]})]}),(0,he.jsx)("div",{className:"border rounded-lg max-h-[50vh] overflow-auto",children:na?(0,he.jsxs)("div",{className:"p-8 text-center",children:[(0,he.jsx)("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-orange-500 mx-auto mb-2"}),(0,he.jsx)("p",{className:"text-sm text-gray-500",children:"Loading users..."})]}):Kt.length>0?(0,he.jsx)("div",{className:"divide-y",children:Kt.map(e=>(0,he.jsxs)("div",{className:"p-4 hover:bg-gray-50 flex items-center justify-between",children:[(0,he.jsxs)("div",{className:"flex-1",children:[(0,he.jsxs)("p",{className:"font-medium",children:[e.firstName," ",e.lastName]}),(0,he.jsx)("p",{className:"text-sm text-gray-600",children:e.email})]}),(0,he.jsx)(m.E,{variant:"outline",children:e.role})]},e.id))}):(0,he.jsxs)("div",{className:"p-8 text-center",children:[(0,he.jsx)(O.A,{className:"w-12 h-12 mx-auto text-gray-300 mb-2"}),(0,he.jsx)("p",{className:"text-gray-500",children:Na||"all"!==fa?"No users match your filters":"No users in this organization"})]})}),!na&&(0,he.jsxs)("div",{className:"flex items-center justify-between text-sm text-gray-600 pt-2 border-t",children:[(0,he.jsxs)("p",{children:["Showing ",Kt.length," of ",aa.length," users"]}),(Na||"all"!==fa)&&(0,he.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>{ba(""),Aa("all")},children:"Clear Filters"})]})]}),(0,he.jsx)(u.Es,{children:(0,he.jsx)(o.$,{variant:"outline",onClick:()=>ha(!1),children:"Close"})})]})}),(0,he.jsx)(u.lG,{open:oa,onOpenChange:xa,children:(0,he.jsxs)(u.Cf,{className:"max-w-4xl max-h-[85vh]","data-testid":"edit-org-dialog",children:[(0,he.jsxs)(u.c7,{children:[(0,he.jsx)(u.L3,{children:"Edit Organization"}),(0,he.jsx)(u.rr,{children:"Update organization profile and settings"})]}),et&&(0,he.jsxs)(y.tU,{defaultValue:"basic",className:"w-full",children:[(0,he.jsxs)(y.j7,{className:"grid w-full grid-cols-4",children:[(0,he.jsx)(y.Xi,{value:"basic",children:"Basic"}),(0,he.jsx)(y.Xi,{value:"branding",children:"Branding"}),(0,he.jsx)(y.Xi,{value:"contact",children:"Contact"}),(0,he.jsx)(y.Xi,{value:"business",children:"Business"})]}),(0,he.jsxs)("div",{className:"overflow-y-auto max-h-[55vh] mt-4",children:[(0,he.jsxs)(y.av,{value:"basic",className:"space-y-4",children:[(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"edit-org-name",children:"Organization Name *"}),(0,he.jsx)(p.p,{id:"edit-org-name",value:et.name,onChange:e=>st((0,t.A)((0,t.A)({},et),{},{name:e.target.value})),placeholder:"ACME University","data-testid":"input-edit-org-name"})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"edit-org-type",children:"Type *"}),(0,he.jsxs)(j.l6,{value:et.type,onValueChange:e=>st((0,t.A)((0,t.A)({},et),{},{type:e})),children:[(0,he.jsx)(j.bq,{"data-testid":"select-edit-org-type",children:(0,he.jsx)(j.yv,{})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"Institution",children:"Institution"}),(0,he.jsx)(j.eb,{value:"Enterprise",children:"Enterprise"})]})]})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"edit-org-domain",children:"Domain"}),(0,he.jsx)(p.p,{id:"edit-org-domain",value:et.orgDomain||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{orgDomain:e.target.value})),placeholder:"example.com","data-testid":"input-edit-org-domain"})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"edit-subdomain",children:"Subdomain (Multi-Tenant URL)"}),(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsx)("span",{className:"text-sm text-gray-500",children:"app.elevante.ai/"}),(0,he.jsx)(p.p,{id:"edit-subdomain",value:et.subdomain||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{subdomain:e.target.value.toLowerCase().replace(/[^a-z0-9-]/g,"")})),placeholder:"acme",className:"max-w-[200px]","data-testid":"input-edit-org-subdomain"})]}),(0,he.jsxs)("p",{className:"text-xs text-gray-500",children:["Users can access via app.elevante.ai/",et.subdomain||"subdomain"]})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"edit-org-status",children:"Status"}),(0,he.jsxs)(j.l6,{value:et.status||"active",onValueChange:e=>st((0,t.A)((0,t.A)({},et),{},{status:e})),children:[(0,he.jsx)(j.bq,{"data-testid":"select-edit-org-status",children:(0,he.jsx)(j.yv,{})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"active",children:"Active"}),(0,he.jsx)(j.eb,{value:"inactive",children:"Inactive"})]})]})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"edit-tagline",children:"Tagline"}),(0,he.jsx)(p.p,{id:"edit-tagline",value:et.tagline||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{tagline:e.target.value})),placeholder:"Empowering education through AI"})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"edit-description",children:"Description"}),(0,he.jsx)(v.T,{id:"edit-description",value:et.description||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{description:e.target.value})),placeholder:"Brief description...",rows:3})]})]}),(0,he.jsxs)(y.av,{value:"branding",className:"space-y-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-base font-semibold",children:"Primary Logo (Login Page)"}),(0,he.jsx)("p",{className:"text-xs text-gray-500 mt-0.5",children:"Recommended: 200\xd780px or similar aspect ratio. Max height: 80px"}),(0,he.jsxs)("div",{className:"grid grid-cols-2 gap-4 mt-2",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-sm",children:"Upload File"}),(0,he.jsx)("div",{className:"mt-1 border-2 border-dashed rounded-lg p-3 text-center",children:Ha?(0,he.jsxs)("div",{className:"relative",children:[(0,he.jsx)("img",{src:Ha,alt:"Logo",className:"max-h-24 mx-auto"}),(0,he.jsx)(o.$,{size:"sm",variant:"destructive",className:"absolute top-0 right-0",onClick:()=>Xt("primary",!0),children:(0,he.jsx)(X.A,{className:"w-3 h-3"})})]}):(0,he.jsxs)("div",{children:[(0,he.jsx)(V.A,{className:"w-6 h-6 mx-auto text-gray-400 mb-1"}),(0,he.jsx)("input",{type:"file",accept:"image/*",onChange:e=>qt(e,"primary",!0),className:"hidden",id:"edit-primary-logo"}),(0,he.jsx)(o.$,{size:"sm",variant:"outline",onClick:()=>document.getElementById("edit-primary-logo").click(),children:"Choose File"})]})})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-sm",children:"Or URL"}),(0,he.jsx)(p.p,{value:et.logoUrl||"",onChange:e=>{st((0,t.A)((0,t.A)({},et),{},{logoUrl:e.target.value,logoFile:""})),Ka(e.target.value)},placeholder:"https://...",className:"mt-1"})]})]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-base font-semibold",children:"Compact Logo (Sidebar Header)"}),(0,he.jsx)("p",{className:"text-xs text-gray-500 mt-0.5",children:"Recommended: 150\xd740px or similar. Displays next to Elevante.AI logo. Max width: 150px, Max height: 40px"}),(0,he.jsxs)("div",{className:"grid grid-cols-2 gap-4 mt-2",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-sm",children:"Upload File"}),(0,he.jsx)("div",{className:"mt-1 border-2 border-dashed rounded-lg p-3 text-center",children:Ya?(0,he.jsxs)("div",{className:"relative",children:[(0,he.jsx)("img",{src:Ya,alt:"Compact Logo",className:"max-h-16 mx-auto"}),(0,he.jsx)(o.$,{size:"sm",variant:"destructive",className:"absolute top-0 right-0",onClick:()=>Xt("compact",!0),children:(0,he.jsx)(X.A,{className:"w-3 h-3"})})]}):(0,he.jsxs)("div",{children:[(0,he.jsx)(V.A,{className:"w-6 h-6 mx-auto text-gray-400 mb-1"}),(0,he.jsx)("input",{type:"file",accept:"image/*",onChange:e=>qt(e,"compact",!0),className:"hidden",id:"edit-compact-logo"}),(0,he.jsx)(o.$,{size:"sm",variant:"outline",onClick:()=>document.getElementById("edit-compact-logo").click(),children:"Choose File"})]})})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{className:"text-sm",children:"Or URL"}),(0,he.jsx)(p.p,{value:et.compactLogoUrl||"",onChange:e=>{st((0,t.A)((0,t.A)({},et),{},{compactLogoUrl:e.target.value,compactLogoFile:""})),Qa(e.target.value)},placeholder:"https://...",className:"mt-1"})]})]})]}),(0,he.jsxs)("div",{className:"grid grid-cols-2 gap-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Primary Color"}),(0,he.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,he.jsx)(p.p,{type:"color",value:et.primaryColor||"#FF6B35",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{primaryColor:e.target.value})),className:"w-16 h-10"}),(0,he.jsx)(p.p,{value:et.primaryColor||"#FF6B35",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{primaryColor:e.target.value})),placeholder:"#FF6B35"})]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Secondary Color"}),(0,he.jsxs)("div",{className:"flex gap-2 mt-1",children:[(0,he.jsx)(p.p,{type:"color",value:et.secondaryColor||"#F7931E",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{secondaryColor:e.target.value})),className:"w-16 h-10"}),(0,he.jsx)(p.p,{value:et.secondaryColor||"#F7931E",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{secondaryColor:e.target.value})),placeholder:"#F7931E"})]})]})]})]}),(0,he.jsxs)(y.av,{value:"contact",className:"space-y-4",children:[(0,he.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Phone"}),(0,he.jsx)(p.p,{value:et.phoneNumber||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{phoneNumber:e.target.value})),placeholder:"+1 (555) 123-4567"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Email"}),(0,he.jsx)(p.p,{type:"email",value:et.email||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{email:e.target.value})),placeholder:"[email protected]"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Website"}),(0,he.jsx)(p.p,{value:et.website||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{website:e.target.value})),placeholder:"https://..."})]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Street Address"}),(0,he.jsx)(p.p,{value:et.streetAddress||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{streetAddress:e.target.value})),placeholder:"123 Main St"})]}),(0,he.jsxs)("div",{className:"grid grid-cols-4 gap-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"City"}),(0,he.jsx)(p.p,{value:et.city||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{city:e.target.value})),placeholder:"New York"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"State"}),(0,he.jsx)(p.p,{value:et.state||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{state:e.target.value})),placeholder:"NY"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Postal Code"}),(0,he.jsx)(p.p,{value:et.postalCode||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{postalCode:e.target.value})),placeholder:"10001"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Country"}),(0,he.jsx)(p.p,{value:et.country||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{country:e.target.value})),placeholder:"USA"})]})]})]}),(0,he.jsx)(y.av,{value:"business",className:"space-y-4",children:(0,he.jsxs)("div",{className:"grid grid-cols-3 gap-4",children:[(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Tax ID / EIN"}),(0,he.jsx)(p.p,{value:et.taxId||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{taxId:e.target.value})),placeholder:"XX-XXXXXXX"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Registration Number"}),(0,he.jsx)(p.p,{value:et.registrationNumber||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{registrationNumber:e.target.value})),placeholder:"REG-12345"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Industry"}),(0,he.jsx)(p.p,{value:et.industry||"",onChange:e=>st((0,t.A)((0,t.A)({},et),{},{industry:e.target.value})),placeholder:"Education"})]})]})})]})]}),(0,he.jsxs)(u.Es,{children:[(0,he.jsx)(o.$,{variant:"outline",onClick:()=>xa(!1),"data-testid":"btn-cancel-edit-org",children:"Cancel"}),(0,he.jsx)(o.$,{onClick:async()=>{try{await r.Ay.put("/superadmin/organizations/".concat(et.id),et),Is({title:"Success",description:"Organization updated successfully"}
1),xa(!1),st(null),tt(null),Zt(),(null===ea||void 0===ea?void 0:ea.id)===et.id&&sa(et)}catch(o){var e,s,a,t;if(409===(null===(e=o.response)||void 0===e?void 0:e.status)&&null!==(s=o.response)&&void 0!==s&&null!==(a=s.data)&&void 0!==a&&null!==(t=a.detail)&&void 0!==t&&t.conflictingOrg){const e=o.response.data.detail;tt({subdomain:et.subdomain,currentOwner:e.conflictingOrg,targetOrg:{id:et.id,name:et.name}}),it(!0)}else{var l,i,n,c,d;Is({title:"Error",description:(null===(l=o.response)||void 0===l||null===(i=l.data)||void 0===i||null===(n=i.detail)||void 0===n?void 0:n.message)||(null===(c=o.response)||void 0===c||null===(d=c.data)||void 0===d?void 0:d.detail)||o.message,variant:"destructive"})}}},disabled:!(null!==et&&void 0!==et&&et.name),"data-testid":"btn-save-edit-org",children:"Update Organization"})]})]})}),(0,he.jsx)(u.lG,{open:ua,onOpenChange:pa,children:(0,he.jsxs)(u.Cf,{className:"max-w-lg max-h-[85vh] overflow-y-auto",children:[(0,he.jsxs)(u.c7,{children:[(0,he.jsx)(u.L3,{children:"Create System Announcement"}),(0,he.jsx)(u.rr,{children:"Send a notification to all users across organizations"})]}),(0,he.jsxs)("div",{className:"space-y-4",children:[(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"announcement-title",children:"Title *"}),(0,he.jsx)(p.p,{id:"announcement-title",value:Za.title,onChange:e=>Ma((0,t.A)((0,t.A)({},Za),{},{title:e.target.value})),placeholder:"System maintenance scheduled"})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"announcement-message",children:"Message *"}),(0,he.jsx)(v.T,{id:"announcement-message",value:Za.message,onChange:e=>Ma((0,t.A)((0,t.A)({},Za),{},{message:e.target.value})),placeholder:"Provide details about the announcement...",rows:4})]}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"announcement-type",children:"Type"}),(0,he.jsxs)(j.l6,{value:Za.type,onValueChange:e=>Ma((0,t.A)((0,t.A)({},Za),{},{type:e})),children:[(0,he.jsx)(j.bq,{children:(0,he.jsx)(j.yv,{})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"info",children:"Info"}),(0,he.jsx)(j.eb,{value:"warning",children:"Warning"}),(0,he.jsx)(j.eb,{value:"critical",children:"Critical"})]})]})]}),(0,he.jsxs)("div",{className:"flex items-center gap-2",children:[(0,he.jsx)("input",{type:"checkbox",id:"send-notifications",checked:Za.sendNotifications,onChange:e=>Ma((0,t.A)((0,t.A)({},Za),{},{sendNotifications:e.target.checked})),className:"rounded border-gray-300"}),(0,he.jsx)(g.J,{htmlFor:"send-notifications",className:"text-sm font-normal",children:"Send push notifications to all users"})]})]}),(0,he.jsxs)(u.Es,{children:[(0,he.jsx)(o.$,{variant:"outline",onClick:()=>pa(!1),children:"Cancel"}),(0,he.jsxs)(o.$,{onClick:async()=>{try{await r.Ay.post("/superadmin/announcements",Za),Is({title:"Success",description:"System announcement created and notifications sent"}),pa(!1),Ma({title:"",message:"",type:"info",targetOrgs:[],sendNotifications:!0}),Bt()}catch(e){Is({title:"Error",description:e.message,variant:"destructive"})}},disabled:!Za.title||!Za.message,children:[(0,he.jsx)(S.A,{className:"w-4 h-4 mr-2"}),"Send Announcement"]})]})]})}),(0,he.jsx)(u.lG,{open:lt,onOpenChange:e=>{it(e),e||(tt(null),rt(""))},children:(0,he.jsxs)(u.Cf,{className:"max-w-lg","data-testid":"force-reassign-dialog",children:[(0,he.jsxs)(u.c7,{children:[(0,he.jsxs)(u.L3,{className:"flex items-center gap-2 text-amber-600",children:[(0,he.jsx)(_.A,{className:"w-5 h-5"}),"Subdomain Conflict"]}),(0,he.jsx)(u.rr,{children:"The subdomain you're trying to use is already assigned to another organization."})]}),at&&(0,he.jsxs)("div",{className:"space-y-4",children:[(0,he.jsxs)("div",{className:"bg-amber-50 border border-amber-200 rounded-lg p-4",children:[(0,he.jsxs)("p",{className:"text-sm font-medium text-amber-800 mb-3",children:['Subdomain "',at.subdomain,'" is currently owned by:']}),(0,he.jsxs)("div",{className:"bg-white rounded p-3 border border-amber-100",children:[(0,he.jsx)("p",{className:"font-semibold",children:at.currentOwner.name}),(0,he.jsxs)("p",{className:"text-xs text-gray-500 mt-1",children:["ID: ",at.currentOwner.id]})]})]}),(0,he.jsx)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:(0,he.jsxs)("div",{className:"flex items-start gap-2",children:[(0,he.jsx)(R.A,{className:"w-5 h-5 text-red-500 shrink-0 mt-0.5"}),(0,he.jsxs)("div",{children:[(0,he.jsx)("p",{className:"text-sm font-medium text-red-800",children:"Warning: This action will:"}),(0,he.jsxs)("ul",{className:"text-sm text-red-700 mt-2 list-disc list-inside space-y-1",children:[(0,he.jsxs)("li",{children:['Remove the subdomain from "',at.currentOwner.name,'"']}
1),(0,he.jsx)("li",{children:"Users accessing via this subdomain will be redirected"}),(0,he.jsx)("li",{children:"This action will be logged in the audit trail"})]})]})]})}),(0,he.jsxs)("div",{className:"space-y-2",children:[(0,he.jsx)(g.J,{htmlFor:"reassign-reason",className:"font-medium",children:"Reason for reassignment (required)"}),(0,he.jsx)(v.T,{id:"reassign-reason",value:nt,onChange:e=>rt(e.target.value),placeholder:"E.g., Reusing demo environment for a different client presentation...",rows:3,className:"resize-none","data-testid":"input-reassign-reason"}),(0,he.jsx)("p",{className:"text-xs text-gray-500",children:"Minimum 10 characters. This will be recorded in the audit log."})]})]}),(0,he.jsxs)(u.Es,{className:"gap-2 sm:gap-0",children:[(0,he.jsx)(o.$,{variant:"outline",onClick:()=>it(!1),children:"Cancel"}),(0,he.jsx)(o.$,{variant:"destructive",onClick:async()=>{if(!at||!nt||nt.length<10)Is({title:"Error",description:"Please provide a reason (at least 10 characters) for the reassignment",variant:"destructive"});else{dt(!0);try{const e=await r.Ay.post("/superadmin/subdomain/force-reassign",{target_org_id:at.targetOrg.id,subdomain:at.subdomain,reason:nt});Is({title:"Subdomain Reassigned",description:"Subdomain '".concat(at.subdomain,"' has been reassigned to '").concat(at.targetOrg.name,"'")}),it(!1),xa(!1),tt(null),rt(""),st(null),Zt(),Vt(),(null===ea||void 0===ea?void 0:ea.id)===at.targetOrg.id&&sa(e.data.organization)}catch(a){var e,s;Is({title:"Error",description:(null===(e=a.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail)||a.message,variant:"destructive"})}finally{dt(!1)}}},disabled:ct||!nt||nt.length<10,"data-testid":"btn-confirm-reassign",children:ct?(0,he.jsxs)(he.Fragment,{children:[(0,he.jsx)("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2 border-white mr-2"}),"Reassigning..."]}):(0,he.jsxs)(he.Fragment,{children:[(0,he.jsx)(W.A,{className:"w-4 h-4 mr-2"}),"Force Reassign Subdomain"]})})]})]})}),(0,he.jsx)(u.lG,{open:Ws,onOpenChange:qs,children:(0,he.jsxs)(u.Cf,{className:"max-w-2xl max-h-[85vh]","data-testid":"configure-marketplace-dialog",children:[(0,he.jsxs)(u.c7,{children:[(0,he.jsxs)(u.L3,{children:["Configure Marketplace \u2014 ",null===Xs||void 0===Xs?void 0:Xs.name]}),(0,he.jsx)(u.rr,{children:"Flip this organisation into a content marketplace and choose which other orgs may consume from it. Per-course listings are managed by TenantAdmins from the Course Builder."})]}),(0,he.jsxs)("div",{className:"space-y-5 py-2",children:[(0,he.jsxs)("label",{className:"flex items-center gap-3 cursor-pointer",children:[(0,he.jsx)("input",{type:"checkbox",checked:_s.enabled,onChange:e=>Gs((0,t.A)((0,t.A)({},_s),{},{enabled:e.target.checked})),disabled:Hs,className:"w-4 h-4","data-testid":"marketplace-enabled-toggle"}),(0,he.jsx)("span",{className:"font-medium",children:"Enable this org as a marketplace"})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Default visibility for new listings"}),(0,he.jsxs)(j.l6,{value:_s.defaultVisibility,onValueChange:e=>Gs((0,t.A)((0,t.A)({},_s),{},{defaultVisibility:e})),disabled:!_s.enabled||Hs,children:[(0,he.jsx)(j.bq,{"data-testid":"marketplace-default-visibility-select",children:(0,he.jsx)(j.yv,{})}),(0,he.jsxs)(j.gC,{children:[(0,he.jsx)(j.eb,{value:"allowlist",children:"Allow-list (per-listing opt-in, recommended)"}),(0,he.jsx)(j.eb,{value:"none",children:"None (no auto-visibility; every listing must be explicitly published)"})]})]})]}),(0,he.jsxs)("div",{children:[(0,he.jsx)(g.J,{children:"Consumer organisations"}),(0,he.jsx)("p",{className:"text-xs text-gray-500 mb-2",children:"Only the orgs you tick here can ever see any course this marketplace lists. The current org is automatically excluded."}),(0,he.jsx)("div",{className:"border rounded p-2 max-h-72 overflow-y-auto space-y-1 bg-gray-50","data-testid":"marketplace-consumers-list",children:(()=>{const e=new Set(_s.consumerOrgs||[]),s=Ps.filter(s=>s.id!==(null===Xs||void 0===Xs?void 0:Xs.id)&&("active"===s.status||e.has(s.id)));return 0===s.length?(0,he.jsx)("div",{className:"text-xs text-gray-500 px-2 py-2","data-testid":"marketplace-consumers-empty",children:"No other active organisations available."}):s.map(e=>{const s="inactive"===e.status;return(0,he.jsxs)("label",{className:"flex items-center gap-2 px-2 py-1 hover:bg-white rounded cursor-pointer ".concat(s?"bg-amber-50":""),"data-testid":"marketplace-consumer-row-".concat(e.id),children:[(0,he.jsx)("input",{type:"checkbox",checked:_s.consumerOrgs.includes(e.id),onChange:()=>
1{return s=e.id,void Gs(e=>{const a=e.consumerOrgs.includes(s);return(0,t.A)((0,t.A)({},e),{},{consumerOrgs:a?e.consumerOrgs.filter(e=>e!==s):[...e.consumerOrgs,s]})});var s},disabled:!_s.enabled||Hs,"data-testid":"marketplace-consumer-toggle-".concat(e.id)}),(0,he.jsx)("span",{className:"text-sm",children:e.name}),(0,he.jsxs)("span",{className:"text-xs text-gray-400",children:["(",e.type||"organization",")"]}),s&&(0,he.jsx)("span",{className:"ml-auto text-[10px] font-medium px-2 py-0.5 rounded-full bg-amber-100 text-amber-800 border border-amber-300",title:"This customer org is inactive. Untick to remove it from this marketplace, or reactivate the org from Organizations \u2192 Configure.","data-testid":"marketplace-consumer-inactive-badge-".concat(e.id),children:"\u26a0 inactive \u2014 untick to remove"})]},e.id)})})()})]})]}),(0,he.jsxs)(u.Es,{children:[(0,he.jsx)(o.$,{variant:"outline",onClick:()=>qs(!1),disabled:Hs,"data-testid":"marketplace-cancel-btn",children:"Cancel"}),(0,he.jsx)(o.$,{onClick:async()=>{if(Xs){Ks(!0);try{await r.Ay.patch("/superadmin/orgs/".concat(Xs.id,"/marketplace"),{enabled:_s.enabled,defaultVisibility:_s.defaultVisibility,consumerOrgs:_s.consumerOrgs}),Is({title:"Marketplace updated",description:"Saved settings for ".concat(Xs.name,".")}),qs(!1),await Promise.all([Zt(),Wt()])}catch(a){var e,s;const t=null===(e=a.response)||void 0===e||null===(s=e.data)||void 0===s?void 0:s.detail;Is({title:"Failed to save",description:"string"===typeof t?t:(null===t||void 0===t?void 0:t.message)||a.message,variant:"destructive"})}finally{Ks(!1)}}},disabled:Hs,"data-testid":"marketplace-save-btn",children:Hs?"Saving\u2026":"Save changes"})]})]})})]})}},39851:(e,s,a)=>{a.d(s,{Yq:()=>i,fH:()=>l,r6:()=>n,tX:()=>r});const t=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],l=e=>{if(null==e)return null;if(e instanceof Date)return e;if("string"!==typeof e)return new Date(e);const s=e.endsWith("Z")||/[+-]\d{2}:?\d{2}$/.test(e)||e.endsWith("+00:00"),a=e.includes("T")&&!s;return new Date(a?e+"Z":e)},i=e=>{if(!e)return"";try{const s="string"!==typeof e||e.endsWith("Z")||e.includes("+")||e.includes("-",10)?e:e+"Z",a=new Date(s);if(isNaN(a.getTime()))return"";const l=String(a.getDate()).padStart(2,"0"),i=t[a.getMonth()],n=a.getFullYear();return"".concat(l," ").concat(i," ").concat(n)}catch(s){return""}},n=e=>{if(!e)return"";try{var s;const a="string"!==typeof e||e.endsWith("Z")||e.includes("+")||e.includes("-",10)?e:e+"Z",l=new Date(a);if(isNaN(l.getTime()))return"";const i=String(l.getDate()).padStart(2,"0"),n=t[l.getMonth()],r=l.getFullYear(),c=String(l.getHours()).padStart(2,"0"),d=String(l.getMinutes()).padStart(2,"0"),o=(null===(s=new Intl.DateTimeFormat("en",{timeZoneName:"short"}).formatToParts(l).find(e=>"timeZoneName"===e.type))||void 0===s?void 0:s.value)||"";return"".concat(i," ").concat(n," ").concat(r,", ").concat(c,":").concat(d," ").concat(o).trim()}catch(a){return""}},r=(e,s)=>{const a=i(e);if(!s)return"".concat(a," - Ongoing");const t=i(s);return"".concat(a," - ").concat(t)}}}]);
2//# sourceMappingURL=7807.e364d0e8.chunk.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.