@lunora/studio 1.0.0-alpha.290 → 1.0.0-alpha.291

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/standalone/{chunk-NR2U7C6X.js → chunk-47EMK7A6.js} +1 -1
  2. package/dist/standalone/{chunk-IHPSJ2PU.js → chunk-4EFBLED2.js} +1 -1
  3. package/dist/standalone/{chunk-SUOPCQD7.js → chunk-4ELKK7SE.js} +1 -1
  4. package/dist/standalone/{chunk-GJ6J6JZA.js → chunk-4GQJA35F.js} +1 -1
  5. package/dist/standalone/{chunk-GXXIGCIF.js → chunk-5O3OODSZ.js} +1 -1
  6. package/dist/standalone/{chunk-OKQS3RV4.js → chunk-5QRUAQNY.js} +1 -1
  7. package/dist/standalone/{chunk-VOJEROA7.js → chunk-5UEMUPTW.js} +1 -1
  8. package/dist/standalone/{chunk-FED7KM46.js → chunk-5XFBQCZ5.js} +1 -1
  9. package/dist/standalone/{chunk-YF7ZNDI4.js → chunk-627GZOJ7.js} +1 -1
  10. package/dist/standalone/{chunk-HGTKL66S.js → chunk-67YFV2GM.js} +1 -1
  11. package/dist/standalone/{chunk-4UO2OTLK.js → chunk-7GMSZEJR.js} +1 -1
  12. package/dist/standalone/{chunk-DVMO32RX.js → chunk-7HE4UK44.js} +1 -1
  13. package/dist/standalone/{chunk-5KFKN5DE.js → chunk-7IU6DKN3.js} +1 -1
  14. package/dist/standalone/{chunk-E5XPDR5D.js → chunk-AJEX5TMG.js} +1 -1
  15. package/dist/standalone/{chunk-YU53KJ7Y.js → chunk-AN4UDYUY.js} +1 -1
  16. package/dist/standalone/{chunk-TRPBILYS.js → chunk-C6SAOAML.js} +1 -1
  17. package/dist/standalone/{chunk-OE6FYYDJ.js → chunk-CVNG6XOK.js} +1 -1
  18. package/dist/standalone/{chunk-DQHTOUUS.js → chunk-CX4FEQNT.js} +1 -1
  19. package/dist/standalone/{chunk-JNKH43IG.js → chunk-D7NNCIX4.js} +1 -1
  20. package/dist/standalone/{chunk-JYTVI62T.js → chunk-DB4FJSOK.js} +1 -1
  21. package/dist/standalone/{chunk-KU6ZTYP4.js → chunk-DGJMFHBV.js} +1 -1
  22. package/dist/standalone/{chunk-KIVY3C4V.js → chunk-DY65YGY5.js} +1 -1
  23. package/dist/standalone/{chunk-VK26SQ7G.js → chunk-DYLF2FA5.js} +1 -1
  24. package/dist/standalone/{chunk-6JHWSJQU.js → chunk-EK6VMAUN.js} +1 -1
  25. package/dist/standalone/{chunk-ZMBT2OFU.js → chunk-EQSFFE7F.js} +1 -1
  26. package/dist/standalone/{chunk-6MPWC5MD.js → chunk-FJ4FPLVL.js} +1 -1
  27. package/dist/standalone/{chunk-GTV5WDXF.js → chunk-FJF55TPZ.js} +1 -1
  28. package/dist/standalone/{chunk-AGWOZ6P2.js → chunk-G5KWQMGT.js} +1 -1
  29. package/dist/standalone/{chunk-AF5ERKUP.js → chunk-GCG65T2K.js} +1 -1
  30. package/dist/standalone/{chunk-A6EGILT4.js → chunk-GN3LRVZ2.js} +1 -1
  31. package/dist/standalone/{chunk-6FGQ5E2B.js → chunk-HF4A3NUS.js} +1 -1
  32. package/dist/standalone/{chunk-FA46V4KR.js → chunk-IKKQNSLF.js} +1 -1
  33. package/dist/standalone/{chunk-6RXWGRH7.js → chunk-J6H3YTFH.js} +1 -1
  34. package/dist/standalone/{chunk-SFPHDV3R.js → chunk-JHYNLMYA.js} +1 -1
  35. package/dist/standalone/{chunk-ZKESOLYY.js → chunk-KGAUQL5T.js} +1 -1
  36. package/dist/standalone/{chunk-YK7KJ3B6.js → chunk-KVIBTEK5.js} +1 -1
  37. package/dist/standalone/{chunk-4U2J2ME3.js → chunk-L56P33FH.js} +1 -1
  38. package/dist/standalone/{chunk-OFURQPKP.js → chunk-LFPYL6YU.js} +1 -1
  39. package/dist/standalone/{chunk-FGWGG424.js → chunk-LW6ERMNX.js} +1 -1
  40. package/dist/standalone/{chunk-F6VN7MAF.js → chunk-M6LSAR5C.js} +1 -1
  41. package/dist/standalone/{chunk-XSZHBDQO.js → chunk-MEMHDCRE.js} +1 -1
  42. package/dist/standalone/{chunk-MKRA2W3P.js → chunk-MTZ5UOQ5.js} +1 -1
  43. package/dist/standalone/{chunk-YKGW4P6U.js → chunk-NJGORSBO.js} +1 -1
  44. package/dist/standalone/{chunk-ZEFFMYSN.js → chunk-O5IUJQBJ.js} +1 -1
  45. package/dist/standalone/{chunk-G6N5A4TA.js → chunk-OEKOZIPM.js} +1 -1
  46. package/dist/standalone/{chunk-PQPCOO6E.js → chunk-OFZX4WXS.js} +1 -1
  47. package/dist/standalone/{chunk-SAOBVEGV.js → chunk-OLQTBRWX.js} +1 -1
  48. package/dist/standalone/{chunk-63IQGHPL.js → chunk-ORVHXDZV.js} +1 -1
  49. package/dist/standalone/{chunk-PHEWXIFF.js → chunk-QAPKGURH.js} +1 -1
  50. package/dist/standalone/{chunk-MJ3WFI7T.js → chunk-QB55CQJC.js} +1 -1
  51. package/dist/standalone/{chunk-HPY2HNZK.js → chunk-QLPEA5F7.js} +1 -1
  52. package/dist/standalone/{chunk-CQWFDDTK.js → chunk-RVZ2WOZ5.js} +1 -1
  53. package/dist/standalone/{chunk-4A6ICQ33.js → chunk-RXZJYHAH.js} +1 -1
  54. package/dist/standalone/{chunk-KKVPUQD2.js → chunk-SJ7BLQMI.js} +1 -1
  55. package/dist/standalone/{chunk-HDVUWQQM.js → chunk-SMBKKLRX.js} +1 -1
  56. package/dist/standalone/{chunk-BL4ORKKN.js → chunk-UEKIUTCJ.js} +1 -1
  57. package/dist/standalone/{chunk-EASJRBTN.js → chunk-V2U4MITD.js} +1 -1
  58. package/dist/standalone/{chunk-54JZD74E.js → chunk-VEK3S7MV.js} +4 -4
  59. package/dist/standalone/{chunk-CK6HFTG7.js → chunk-W5TWX4V7.js} +1 -1
  60. package/dist/standalone/{chunk-EN2PGJWN.js → chunk-WFICP5DT.js} +1 -1
  61. package/dist/standalone/{chunk-4JV44PC5.js → chunk-WM6KXJGG.js} +2 -2
  62. package/dist/standalone/{chunk-C7DRRPQQ.js → chunk-WOPEVNW5.js} +1 -1
  63. package/dist/standalone/{chunk-CESYGLNZ.js → chunk-WRQAHEWF.js} +1 -1
  64. package/dist/standalone/{chunk-5WVYD4BT.js → chunk-WUJ3AOVG.js} +1 -1
  65. package/dist/standalone/{chunk-WSUUMPYP.js → chunk-XQSJORIU.js} +1 -1
  66. package/dist/standalone/{chunk-RY2R7KP5.js → chunk-YRVZM2TB.js} +1 -1
  67. package/dist/standalone/studio.js +1 -1
  68. package/package.json +5 -5
@@ -1 +1 @@
1
- import{b as me}from"./chunk-2I4NHEKA.js";import{a as $}from"./chunk-AF5ERKUP.js";import{a as ue}from"./chunk-SV764LKQ.js";import"./chunk-YU53KJ7Y.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import{a as de}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{b as P}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as A}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-6RXWGRH7.js";import{g as ne,h as oe}from"./chunk-KU6ZTYP4.js";import"./chunk-QAQDMS6R.js";import"./chunk-54JZD74E.js";import{a as C}from"./chunk-2IKDEUCX.js";import{d as D,f as I,g as Q,h as W,p as _,t as ie}from"./chunk-HJHSQPHW.js";import{a as f,d as T,e as qe,f as ae,g as le,i as M}from"./chunk-I26MS5PJ.js";var Y=T(ae(),1);var h=T(qe(),1);var fe=T(ae(),1);var B=T(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},he=f(()=>{let t=(0,fe.c)(18),e=D(),a=oe(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}case"polling":{let n;t[8]!==e?(n=e("Polling"),t[8]=e,t[9]=n):n=t[9],s=n;break e}default:s=a}let l=Me[a],c;t[10]!==l?(c=M("size-2 rounded-full",l),t[10]=l,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==a||t[15]!==i||t[16]!==s?(o=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[14]=a,t[15]=i,t[16]=s,t[17]=o):o=t[17],o},"T");var r=T(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=f((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=f((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","z"),xe=.01,ve=.05,je=f(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=D(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let n;e[2]!==o?(n=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==i||e[5]!==c?(m=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(P,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=m):m=e[6];let p;e[7]!==n||e[8]!==m?(p=(0,r.jsxs)(C,{className:"gap-0 py-0","data-testid":"hl-functions",children:[n,m]}),e[7]=n,e[8]=m,e[9]=p):p=e[9];let v;e[10]!==i?(v=i("Recent errors"),e[10]=i,e[11]=v):v=e[11];let d;e[12]!==v?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",g;e[14]!==a||e[15]!==u?(g=(0,r.jsx)(P,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=g):g=e[16];let x;e[17]!==d||e[18]!==g?(x=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,g]}),e[17]=d,e[18]=g,e[19]=x):x=e[19];let S;e[20]!==s?(S=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=S):S=e[21];let E;e[22]!==s||e[23]!==i||e[24]!==l.length?(E=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=E):E=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==S||e[29]!==E||e[30]!==q||e[31]!==x?(N=(0,r.jsxs)(C,{className:"gap-0 py-0",children:[x,S,E,q]}),e[28]=S,e[29]=E,e[30]=q,e[31]=x,e[32]=N):N=e[32];let k;return e[33]!==N||e[34]!==p?(k=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[p,N]}),e[33]=N,e[34]=p,e[35]=k):k=e[35],k},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}f(Ce,"Te");var pe={completed:0,failed:2,in_progress:1},Ie=f(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){l+=1;continue}s+=1,e+=o.requests,a+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=f(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=f(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=I(A.getAuthMetrics),Fe=I(A.getFunctionStats),Le=I(A.getLogs),Re=I(A.getMetrics),ze=I(A.migrationStatus),Oe=5,ge=2e3,Ke=5,_e=.1,$e=.3,Be=1,He=50,Ue=f((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ge=f(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=f(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=f((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=f(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=f(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,o=be[l],n;e[0]!==o?(n=M("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=n):n=e[1];let m;e[2]!==n?(m=(0,r.jsx)("span",{"aria-hidden":"true",className:n}),e[2]=n,e[3]=m):m=e[3];let p;e[4]!==s||e[5]!==m?(p=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[m,s]}),e[4]=s,e[5]=m,e[6]=p):p=e[6];let v=Ne[l],d;e[7]!==v?(d=M("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let g;e[13]!==a||e[14]!==u?(g=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=g):g=e[15];let x;return e[16]!==p||e[17]!==g?(x=(0,r.jsx)(C,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]})}),e[16]=p,e[17]=g,e[18]=x):x=e[18],x},"U"),Xe=f(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,n]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),m=s.map(([d,u,g])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),p=Ie(m),v=s[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(m.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:p.reachable===0&&v?.status==="rejected"?W(v.reason):null,migrations:De(m.map(d=>d.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:p}},"$e"),Ye=f(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=f(({initialShardKey:t})=>{let e=ne(),a=D(),[s,l]=(0,h.useState)([]),[c,i]=(0,h.useState)(null),[o,n]=(0,h.useState)(null),[m,p]=(0,h.useState)(null),[v,d]=(0,h.useState)([]),[u,g]=(0,h.useState)(null),[x,S]=(0,h.useState)(null),[E,q]=(0,h.useState)([]),[N]=(0,h.useState)(de),k=(0,h.useRef)(!1),w=(0,h.useRef)(0),G=(0,h.useRef)(0),j=(0,h.useRef)(null),F=t??"",L=(0,h.useCallback)(async()=>{if(k.current)return;k.current=!0;let b=w.current,y=await Xe(e,F,me(F,N));b===w.current&&(n(y.totals),p(y.metricsError),d(y.functions),q(y.migrations),l(y.entries),i(y.logsError),g(y.auth),S(y.scheduler),k.current=!1)},[e,N,F]);(0,h.useEffect)(()=>(_(L()),()=>{w.current+=1,k.current=!1,j.current!==null&&(clearTimeout(j.current),j.current=null)}),[L]);let ye=f(()=>{let b=Date.now()-G.current;if(b>=ge){G.current=Date.now(),_(L());return}j.current===null&&(j.current=setTimeout(()=>{j.current=null,G.current=Date.now(),_(L())},ge-b))},"ue"),{data:Z,liveError:we}=ce(A.getMetrics,{},{live:!0,shardKey:F});(0,h.useEffect)(()=>{Z!==void 0&&ye()},[Z]);let ee=s.filter(b=>b.level==="error"),ke=ee.slice(0,Oe),R=Ge(o?.history),te=Ye(u),Se=v.filter(b=>b.calls>0).toSorted((b,y)=>y.errors/y.calls-b.errors/b.calls||y.calls-b.calls).slice(0,Ke),V=Ve(E),Ee=o===null||o.requests===0?0:o.errors/o.requests,J=X(Ee,xe,ve),re=u===null?"ok":X(u.failureRate,_e,$e),se=x===null?"ok":Ue(x.backlog,Be,He),z=We([J,re,se,V.level]),O,K;return z==="crit"?(O=a("Critical"),K=a("One or more service levels are breached.")):z==="warn"?(O=a("Degraded"),K=a("Some service levels need attention.")):(O=a("All systems healthy"),K=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(C,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:M("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[z]),children:(0,r.jsx)("span",{className:M("size-3 rounded-full",be[z])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:O}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:K})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[R.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:R.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(o?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:M("text-lg font-semibold tabular-nums",Ne[J]),"data-testid":"hl-error-rate",children:o===null?"\u2014":U(o.errors,o.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(he,{}),(0,r.jsx)(ue,{message:we,prefix:"hl"})]})]})]}),m!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:m}),m===null&&o?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:R.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:R.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:o===null?"\u2014":U(o.errors,o.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:x===null?"\u2014":x.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:V.level,testId:"hl-slo-migrations",value:Je(V,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(C,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(P,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(b=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(P,{variant:"secondary",children:b})},b))})]})]})},"ut");export{xt as HealthPanel};
1
+ import{b as me}from"./chunk-2I4NHEKA.js";import{a as $}from"./chunk-GCG65T2K.js";import{a as ue}from"./chunk-SV764LKQ.js";import"./chunk-AN4UDYUY.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import{a as de}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{b as P}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as A}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-J6H3YTFH.js";import{g as ne,h as oe}from"./chunk-DGJMFHBV.js";import"./chunk-QAQDMS6R.js";import"./chunk-VEK3S7MV.js";import{a as C}from"./chunk-2IKDEUCX.js";import{d as D,f as I,g as Q,h as W,p as _,t as ie}from"./chunk-HJHSQPHW.js";import{a as f,d as T,e as qe,f as ae,g as le,i as M}from"./chunk-I26MS5PJ.js";var Y=T(ae(),1);var h=T(qe(),1);var fe=T(ae(),1);var B=T(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive",polling:"bg-warning"},he=f(()=>{let t=(0,fe.c)(18),e=D(),a=oe(),s;e:switch(a){case"connected":{let n;t[0]!==e?(n=e("Connected"),t[0]=e,t[1]=n):n=t[1],s=n;break e}case"connecting":{let n;t[2]!==e?(n=e("Connecting\u2026"),t[2]=e,t[3]=n):n=t[3],s=n;break e}case"idle":{let n;t[4]!==e?(n=e("Idle"),t[4]=e,t[5]=n):n=t[5],s=n;break e}case"offline":{let n;t[6]!==e?(n=e("Offline"),t[6]=e,t[7]=n):n=t[7],s=n;break e}case"polling":{let n;t[8]!==e?(n=e("Polling"),t[8]=e,t[9]=n):n=t[9],s=n;break e}default:s=a}let l=Me[a],c;t[10]!==l?(c=M("size-2 rounded-full",l),t[10]=l,t[11]=c):c=t[11];let i;t[12]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[12]=c,t[13]=i):i=t[13];let o;return t[14]!==a||t[15]!==i||t[16]!==s?(o=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[14]=a,t[15]=i,t[16]=s,t[17]=o):o=t[17],o},"T");var r=T(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=f((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=f((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","z"),xe=.01,ve=.05,je=f(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=D(),o;e[0]!==i?(o=i("Functions by error rate"),e[0]=i,e[1]=o):o=e[1];let n;e[2]!==o?(n=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==i||e[5]!==c?(m=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(P,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=m):m=e[6];let p;e[7]!==n||e[8]!==m?(p=(0,r.jsxs)(C,{className:"gap-0 py-0","data-testid":"hl-functions",children:[n,m]}),e[7]=n,e[8]=m,e[9]=p):p=e[9];let v;e[10]!==i?(v=i("Recent errors"),e[10]=i,e[11]=v):v=e[11];let d;e[12]!==v?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v}),e[12]=v,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",g;e[14]!==a||e[15]!==u?(g=(0,r.jsx)(P,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=g):g=e[16];let x;e[17]!==d||e[18]!==g?(x=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,g]}),e[17]=d,e[18]=g,e[19]=x):x=e[19];let S;e[20]!==s?(S=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=S):S=e[21];let E;e[22]!==s||e[23]!==i||e[24]!==l.length?(E=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=E):E=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==S||e[29]!==E||e[30]!==q||e[31]!==x?(N=(0,r.jsxs)(C,{className:"gap-0 py-0",children:[x,S,E,q]}),e[28]=S,e[29]=E,e[30]=q,e[31]=x,e[32]=N):N=e[32];let k;return e[33]!==N||e[34]!==p?(k=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[p,N]}),e[33]=N,e[34]=p,e[35]=k):k=e[35],k},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}f(Ce,"Te");var pe={completed:0,failed:2,in_progress:1},Ie=f(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:o}of t){if(o===null){l+=1;continue}s+=1,e+=o.requests,a+=o.errors,i.push(...o.history??[]),c||=o.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=f(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=f(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=I(A.getAuthMetrics),Fe=I(A.getFunctionStats),Le=I(A.getLogs),Re=I(A.getMetrics),ze=I(A.migrationStatus),Oe=5,ge=2e3,Ke=5,_e=.1,$e=.3,Be=1,He=50,Ue=f((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ge=f(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=f(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=f((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=f(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=f(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,o=be[l],n;e[0]!==o?(n=M("size-1.5 shrink-0 rounded-full",o),e[0]=o,e[1]=n):n=e[1];let m;e[2]!==n?(m=(0,r.jsx)("span",{"aria-hidden":"true",className:n}),e[2]=n,e[3]=m):m=e[3];let p;e[4]!==s||e[5]!==m?(p=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[m,s]}),e[4]=s,e[5]=m,e[6]=p):p=e[6];let v=Ne[l],d;e[7]!==v?(d=M("truncate text-2xl font-semibold tabular-nums",v),e[7]=v,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let g;e[13]!==a||e[14]!==u?(g=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=g):g=e[15];let x;return e[16]!==p||e[17]!==g?(x=(0,r.jsx)(C,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[p,g]})}),e[16]=p,e[17]=g,e[18]=x):x=e[18],x},"U"),Xe=f(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,o,n]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),m=s.map(([d,u,g])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:g.status==="fulfilled"?g.value.migrations:[]})),p=Ie(m),v=s[0]?.[0];return{auth:o.status==="fulfilled"?o.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(m.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:p.reachable===0&&v?.status==="rejected"?W(v.reason):null,migrations:De(m.map(d=>d.migrations)),scheduler:n.status==="fulfilled"?n.value:null,totals:p}},"$e"),Ye=f(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=f(({initialShardKey:t})=>{let e=ne(),a=D(),[s,l]=(0,h.useState)([]),[c,i]=(0,h.useState)(null),[o,n]=(0,h.useState)(null),[m,p]=(0,h.useState)(null),[v,d]=(0,h.useState)([]),[u,g]=(0,h.useState)(null),[x,S]=(0,h.useState)(null),[E,q]=(0,h.useState)([]),[N]=(0,h.useState)(de),k=(0,h.useRef)(!1),w=(0,h.useRef)(0),G=(0,h.useRef)(0),j=(0,h.useRef)(null),F=t??"",L=(0,h.useCallback)(async()=>{if(k.current)return;k.current=!0;let b=w.current,y=await Xe(e,F,me(F,N));b===w.current&&(n(y.totals),p(y.metricsError),d(y.functions),q(y.migrations),l(y.entries),i(y.logsError),g(y.auth),S(y.scheduler),k.current=!1)},[e,N,F]);(0,h.useEffect)(()=>(_(L()),()=>{w.current+=1,k.current=!1,j.current!==null&&(clearTimeout(j.current),j.current=null)}),[L]);let ye=f(()=>{let b=Date.now()-G.current;if(b>=ge){G.current=Date.now(),_(L());return}j.current===null&&(j.current=setTimeout(()=>{j.current=null,G.current=Date.now(),_(L())},ge-b))},"ue"),{data:Z,liveError:we}=ce(A.getMetrics,{},{live:!0,shardKey:F});(0,h.useEffect)(()=>{Z!==void 0&&ye()},[Z]);let ee=s.filter(b=>b.level==="error"),ke=ee.slice(0,Oe),R=Ge(o?.history),te=Ye(u),Se=v.filter(b=>b.calls>0).toSorted((b,y)=>y.errors/y.calls-b.errors/b.calls||y.calls-b.calls).slice(0,Ke),V=Ve(E),Ee=o===null||o.requests===0?0:o.errors/o.requests,J=X(Ee,xe,ve),re=u===null?"ok":X(u.failureRate,_e,$e),se=x===null?"ok":Ue(x.backlog,Be,He),z=We([J,re,se,V.level]),O,K;return z==="crit"?(O=a("Critical"),K=a("One or more service levels are breached.")):z==="warn"?(O=a("Degraded"),K=a("Some service levels need attention.")):(O=a("All systems healthy"),K=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(C,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:M("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[z]),children:(0,r.jsx)("span",{className:M("size-3 rounded-full",be[z])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:O}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:K})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[R.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:R.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(o?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:M("text-lg font-semibold tabular-nums",Ne[J]),"data-testid":"hl-error-rate",children:o===null?"\u2014":U(o.errors,o.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(he,{}),(0,r.jsx)(ue,{message:we,prefix:"hl"})]})]})]}),m!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:m}),m===null&&o?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:R.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:R.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:J,testId:"hl-slo-errorrate",value:o===null?"\u2014":U(o.errors,o.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:x===null?"\u2014":x.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:V.level,testId:"hl-slo-migrations",value:Je(V,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(C,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(P,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(b=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(P,{variant:"secondary",children:b})},b))})]})]})},"ut");export{xt as HealthPanel};
@@ -1 +1 @@
1
- import{a as O}from"./chunk-JQXA2OYK.js";import{a as H}from"./chunk-XHRKNCCI.js";import{a as ee}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Z}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as E}from"./chunk-6RXWGRH7.js";import{g as R}from"./chunk-KU6ZTYP4.js";import"./chunk-QAQDMS6R.js";import"./chunk-54JZD74E.js";import{a as _}from"./chunk-RWVIV3U7.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-HCTJKP5J.js";import{a as A,e as T}from"./chunk-2IKDEUCX.js";import{d as M,h as G,p as W,t as X}from"./chunk-HJHSQPHW.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-I26MS5PJ.js";var U=P(re(),1),Y=P(oe(),1);var t=P(ae(),1);var se=P(re(),1);var Q=P(oe(),1);var h=P(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","X"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"F"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"Y"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,f=R(),r=M(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let v=await(d??(()=>f.listScheduledJobs()))();return le(v)}),[x,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),y,k;e[1]!==f||e[2]!==l?(y=c(()=>{if(l)return f.subscribeScheduledJobs(v=>{m(void 0),n(le(v))})},"v"),k=[l,f],e[1]=f,e[2]=l,e[3]=y,e[4]=k):(y=e[3],k=e[4]),(0,Q.useEffect)(y,k);let g;e[5]!==N?(g=c(()=>{N.refetch()},"y"),e[5]=N,e[6]=g):g=e[6],O(g,!l);let J=ce(f,i,d),b=x??N.data,j=s??N.error,I=c(async v=>{if(J!==void 0){m(void 0);try{await J(v),l||N.refetch()}catch(D){m(G(D))}}},"A"),q="flex flex-col gap-3",B="lunora-scheduled-jobs",S;e[7]!==j?(S=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=S):S=e[8];let L;e[9]!==b?.length||e[10]!==r?(L=b?.length===0&&(0,h.jsx)(_,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=L):L=e[11];let $=b!==void 0&&b.length>0&&(0,h.jsx)(A,{className:"overflow-hidden py-0",children:(0,h.jsx)(T,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(F,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(v=>(0,h.jsxs)(F,{"data-testid":`sj-row-${v.id}`,children:[(0,h.jsx)(p,{className:"font-mono text-xs",children:v.workflow??v.functionPath}),(0,h.jsx)(p,{className:"text-muted-foreground tabular-nums",children:ie(v.scheduledFor)}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.pool??""}),(0,h.jsx)(p,{className:"tabular-nums",children:v.attempts??0}),(0,h.jsx)(p,{children:v.shardKey??""}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.id}),J!==void 0&&(0,h.jsx)(p,{className:"text-right",children:(0,h.jsx)(H,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{W(I(v.id))},"onConfirm"),testId:`sj-cancel-${v.id}`,children:r("Cancel")})})]},v.id))})]})})}),w;return e[12]!==$||e[13]!==S||e[14]!==L?(w=(0,h.jsxs)("div",{className:q,"data-testid":B,children:[S,L,$]}),e[12]=$,e[13]=S,e[14]=L,e[15]=w):w=e[15],w},"he");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"re"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=R(),d=M(),[f,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,x=me(i,a,e),n=c(async s=>{if(x!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await x(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(y=>({...y,[s]:{kind:"error",message:G(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(_,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),x!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=f[s.name]??he;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(p,{children:s.name}),(0,t.jsx)(p,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(p,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(p,{children:s.shardKey??""}),x!==void 0&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(H,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{W(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),pe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","se"),fe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:f,retryJob:r}=i,l=R(),o=M(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let x;e[3]!==l||e[4]!==d?(x=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=x):x=e[5];let n=E(N,x),s=n.data,[m,y]=(0,Y.useState)(void 0),k=n.error??m,g=d===void 0,J;e[6]!==l||e[7]!==g||e[8]!==r?(J=r??(g?C=>l.retryDeadJob(C):void 0),e[6]=l,e[7]=g,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==g||e[12]!==f?(j=f??(g?C=>l.removeDeadJob(C):void 0),e[10]=l,e[11]=g,e[12]=f,e[13]=j):j=e[13];let I=j,q;e[14]!==n?(q=c(()=>{n.refetch()},"$"),e[14]=n,e[15]=q):q=e[15],O(q,!0);let B;e[16]!==n?(B=c(async C=>{y(void 0);try{await C,n.refetch()}catch(ne){y(G(ne))}},"I"),e[16]=n,e[17]=B):B=e[17];let S=B,L=b!==void 0||I!==void 0,$;e[18]!==k?($=k!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:k}),e[18]=k,e[19]=$):$=e[19];let w;e[20]!==s?.length||e[21]!==o?(w=s?.length===0&&(0,t.jsx)(_,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=w):w=e[22];let v;e[23]!==S||e[24]!==L||e[25]!==s||e[26]!==I||e[27]!==b||e[28]!==o?(v=s!==void 0&&s.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),L&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(C=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${C.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:C.workflow??C.functionPath}),(0,t.jsx)(p,{className:"tabular-nums",children:C.attempts??0}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:pe(C.scheduledFor)}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.pool??""}),(0,t.jsx)(p,{children:C.shardKey??""}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.id}),L&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${C.id}`,onClick:c(()=>{W(S(b(C.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),I!==void 0&&(0,t.jsx)(H,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{W(S(I(C.id)))},"onConfirm"),testId:`dlq-remove-${C.id}`,children:o("Drop")})]})})]},C.id))})]})})}),e[23]=S,e[24]=L,e[25]=s,e[26]=I,e[27]=b,e[28]=o,e[29]=v):v=e[29];let D;return e[30]!==v||e[31]!==$||e[32]!==w?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,w,v]}),e[30]=v,e[31]=$,e[32]=w,e[33]=D):D=e[33],D},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"oe");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:f}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==f?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(A,{className:"flex-1 py-0",children:(0,t.jsxs)(T,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"E"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,f=R(),r=M(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==f||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>f.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"y"),e[4]=f,e[5]=d,e[6]=N):N=e[6];let x=E(o,N),{data:n,error:s}=x,m;e[7]!==x?(m=c(()=>{x.refetch()},"d"),e[7]=x,e[8]=m):m=e[8],O(m,!0);let y;e[9]!==s?(y=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=y):y=e[10];let k;e[11]!==n||e[12]!==r?(k=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=k):k=e[13];let g;e[14]!==n?.pools.length||e[15]!==r?(g=n?.pools.length===0&&(0,t.jsx)(_,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=g):g=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==y||e[21]!==k||e[22]!==g||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[y,k,g,J]}),e[20]=y,e[21]=k,e[22]=g,e[23]=J,e[24]=b):b=e[24],b},"ae");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(p,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(p,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(p,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"de");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:f,scheduledLoad:r}=i,l=M(),[o,N]=(0,Y.useState)("jobs"),x;e[2]!==l?(x=l("Cron triggers"),e[2]=l,e[3]=x):x=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let y;e[10]!==x||e[11]!==n||e[12]!==s||e[13]!==m?(y={cron:x,dead:n,jobs:s,pools:m},e[10]=x,e[11]=n,e[12]=s,e[13]=m,e[14]=y):y=e[14];let k=y,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c(w=>{N(w.currentTarget.dataset.view)},"f"),e[15]=g):g=e[15];let J=g,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==k?(j=Ne.map(w=>(0,t.jsx)(ee,{"aria-selected":o===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:J,role:"tab",size:"sm",type:"button",variant:o===w?"default":"outline",children:k[w]},w)),e[18]=o,e[19]=k,e[20]=j):j=e[20];let I;e[21]!==b||e[22]!==j?(I=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=I):I=e[23];let q;e[24]!==f||e[25]!==r||e[26]!==o?(q=o==="jobs"&&(0,t.jsx)(de,{cancelJob:f,loadJobs:r}),e[24]=f,e[25]=r,e[26]=o,e[27]=q):q=e[27];let B;e[28]!==o?(B=o==="dead"&&(0,t.jsx)(fe,{}),e[28]=o,e[29]=B):B=e[29];let S;e[30]!==o?(S=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=S):S=e[31];let L;e[32]!==d||e[33]!==o?(L=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=L):L=e[34];let $;return e[35]!==I||e[36]!==q||e[37]!==B||e[38]!==S||e[39]!==L?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[I,q,B,S,L]}),e[35]=I,e[36]=q,e[37]=B,e[38]=S,e[39]=L,e[40]=$):$=e[40],$},"Ie");export{Ve as SchedulePanel};
1
+ import{a as O}from"./chunk-JQXA2OYK.js";import{a as H}from"./chunk-XHRKNCCI.js";import{a as ee}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Z}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as E}from"./chunk-J6H3YTFH.js";import{g as R}from"./chunk-DGJMFHBV.js";import"./chunk-QAQDMS6R.js";import"./chunk-VEK3S7MV.js";import{a as _}from"./chunk-RWVIV3U7.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-HCTJKP5J.js";import{a as A,e as T}from"./chunk-2IKDEUCX.js";import{d as M,h as G,p as W,t as X}from"./chunk-HJHSQPHW.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-I26MS5PJ.js";var U=P(re(),1),Y=P(oe(),1);var t=P(ae(),1);var se=P(re(),1);var Q=P(oe(),1);var h=P(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","X"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"F"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"Y"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,f=R(),r=M(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let v=await(d??(()=>f.listScheduledJobs()))();return le(v)}),[x,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),y,k;e[1]!==f||e[2]!==l?(y=c(()=>{if(l)return f.subscribeScheduledJobs(v=>{m(void 0),n(le(v))})},"v"),k=[l,f],e[1]=f,e[2]=l,e[3]=y,e[4]=k):(y=e[3],k=e[4]),(0,Q.useEffect)(y,k);let g;e[5]!==N?(g=c(()=>{N.refetch()},"y"),e[5]=N,e[6]=g):g=e[6],O(g,!l);let J=ce(f,i,d),b=x??N.data,j=s??N.error,I=c(async v=>{if(J!==void 0){m(void 0);try{await J(v),l||N.refetch()}catch(D){m(G(D))}}},"A"),q="flex flex-col gap-3",B="lunora-scheduled-jobs",S;e[7]!==j?(S=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=S):S=e[8];let L;e[9]!==b?.length||e[10]!==r?(L=b?.length===0&&(0,h.jsx)(_,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=L):L=e[11];let $=b!==void 0&&b.length>0&&(0,h.jsx)(A,{className:"overflow-hidden py-0",children:(0,h.jsx)(T,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(F,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(v=>(0,h.jsxs)(F,{"data-testid":`sj-row-${v.id}`,children:[(0,h.jsx)(p,{className:"font-mono text-xs",children:v.workflow??v.functionPath}),(0,h.jsx)(p,{className:"text-muted-foreground tabular-nums",children:ie(v.scheduledFor)}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.pool??""}),(0,h.jsx)(p,{className:"tabular-nums",children:v.attempts??0}),(0,h.jsx)(p,{children:v.shardKey??""}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.id}),J!==void 0&&(0,h.jsx)(p,{className:"text-right",children:(0,h.jsx)(H,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{W(I(v.id))},"onConfirm"),testId:`sj-cancel-${v.id}`,children:r("Cancel")})})]},v.id))})]})})}),w;return e[12]!==$||e[13]!==S||e[14]!==L?(w=(0,h.jsxs)("div",{className:q,"data-testid":B,children:[S,L,$]}),e[12]=$,e[13]=S,e[14]=L,e[15]=w):w=e[15],w},"he");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"re"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=R(),d=M(),[f,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,x=me(i,a,e),n=c(async s=>{if(x!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await x(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(y=>({...y,[s]:{kind:"error",message:G(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(_,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),x!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=f[s.name]??he;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(p,{children:s.name}),(0,t.jsx)(p,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(p,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(p,{children:s.shardKey??""}),x!==void 0&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(H,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{W(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),pe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","se"),fe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:f,retryJob:r}=i,l=R(),o=M(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let x;e[3]!==l||e[4]!==d?(x=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=x):x=e[5];let n=E(N,x),s=n.data,[m,y]=(0,Y.useState)(void 0),k=n.error??m,g=d===void 0,J;e[6]!==l||e[7]!==g||e[8]!==r?(J=r??(g?C=>l.retryDeadJob(C):void 0),e[6]=l,e[7]=g,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==g||e[12]!==f?(j=f??(g?C=>l.removeDeadJob(C):void 0),e[10]=l,e[11]=g,e[12]=f,e[13]=j):j=e[13];let I=j,q;e[14]!==n?(q=c(()=>{n.refetch()},"$"),e[14]=n,e[15]=q):q=e[15],O(q,!0);let B;e[16]!==n?(B=c(async C=>{y(void 0);try{await C,n.refetch()}catch(ne){y(G(ne))}},"I"),e[16]=n,e[17]=B):B=e[17];let S=B,L=b!==void 0||I!==void 0,$;e[18]!==k?($=k!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:k}),e[18]=k,e[19]=$):$=e[19];let w;e[20]!==s?.length||e[21]!==o?(w=s?.length===0&&(0,t.jsx)(_,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=w):w=e[22];let v;e[23]!==S||e[24]!==L||e[25]!==s||e[26]!==I||e[27]!==b||e[28]!==o?(v=s!==void 0&&s.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),L&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(C=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${C.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:C.workflow??C.functionPath}),(0,t.jsx)(p,{className:"tabular-nums",children:C.attempts??0}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:pe(C.scheduledFor)}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.pool??""}),(0,t.jsx)(p,{children:C.shardKey??""}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.id}),L&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${C.id}`,onClick:c(()=>{W(S(b(C.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),I!==void 0&&(0,t.jsx)(H,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{W(S(I(C.id)))},"onConfirm"),testId:`dlq-remove-${C.id}`,children:o("Drop")})]})})]},C.id))})]})})}),e[23]=S,e[24]=L,e[25]=s,e[26]=I,e[27]=b,e[28]=o,e[29]=v):v=e[29];let D;return e[30]!==v||e[31]!==$||e[32]!==w?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,w,v]}),e[30]=v,e[31]=$,e[32]=w,e[33]=D):D=e[33],D},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"oe");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:f}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==f?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(A,{className:"flex-1 py-0",children:(0,t.jsxs)(T,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"E"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,f=R(),r=M(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==f||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>f.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"y"),e[4]=f,e[5]=d,e[6]=N):N=e[6];let x=E(o,N),{data:n,error:s}=x,m;e[7]!==x?(m=c(()=>{x.refetch()},"d"),e[7]=x,e[8]=m):m=e[8],O(m,!0);let y;e[9]!==s?(y=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=y):y=e[10];let k;e[11]!==n||e[12]!==r?(k=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=k):k=e[13];let g;e[14]!==n?.pools.length||e[15]!==r?(g=n?.pools.length===0&&(0,t.jsx)(_,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=g):g=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==y||e[21]!==k||e[22]!==g||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[y,k,g,J]}),e[20]=y,e[21]=k,e[22]=g,e[23]=J,e[24]=b):b=e[24],b},"ae");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(p,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(p,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(p,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"de");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:f,scheduledLoad:r}=i,l=M(),[o,N]=(0,Y.useState)("jobs"),x;e[2]!==l?(x=l("Cron triggers"),e[2]=l,e[3]=x):x=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let y;e[10]!==x||e[11]!==n||e[12]!==s||e[13]!==m?(y={cron:x,dead:n,jobs:s,pools:m},e[10]=x,e[11]=n,e[12]=s,e[13]=m,e[14]=y):y=e[14];let k=y,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c(w=>{N(w.currentTarget.dataset.view)},"f"),e[15]=g):g=e[15];let J=g,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==k?(j=Ne.map(w=>(0,t.jsx)(ee,{"aria-selected":o===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:J,role:"tab",size:"sm",type:"button",variant:o===w?"default":"outline",children:k[w]},w)),e[18]=o,e[19]=k,e[20]=j):j=e[20];let I;e[21]!==b||e[22]!==j?(I=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=I):I=e[23];let q;e[24]!==f||e[25]!==r||e[26]!==o?(q=o==="jobs"&&(0,t.jsx)(de,{cancelJob:f,loadJobs:r}),e[24]=f,e[25]=r,e[26]=o,e[27]=q):q=e[27];let B;e[28]!==o?(B=o==="dead"&&(0,t.jsx)(fe,{}),e[28]=o,e[29]=B):B=e[29];let S;e[30]!==o?(S=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=S):S=e[31];let L;e[32]!==d||e[33]!==o?(L=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=L):L=e[34];let $;return e[35]!==I||e[36]!==q||e[37]!==B||e[38]!==S||e[39]!==L?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[I,q,B,S,L]}),e[35]=I,e[36]=q,e[37]=B,e[38]=S,e[39]=L,e[40]=$):$=e[40],$},"Ie");export{Ve as SchedulePanel};
@@ -1 +1 @@
1
- import{a as $}from"./chunk-C7DRRPQQ.js";import{a as b}from"./chunk-KKVPUQD2.js";import"./chunk-NCPW7WHO.js";import"./chunk-CESYGLNZ.js";import"./chunk-55UGUCQ6.js";import{a as u}from"./chunk-4ZEL6BYL.js";import{c as p}from"./chunk-6RXWGRH7.js";import"./chunk-KU6ZTYP4.js";import"./chunk-QAQDMS6R.js";import"./chunk-54JZD74E.js";import{a as y,b as w,c as j,d as h,e as c,f as i}from"./chunk-HCTJKP5J.js";import{a as d,e as l}from"./chunk-2IKDEUCX.js";import{d as k}from"./chunk-HJHSQPHW.js";import{a as o,d as I,g as T,i as x}from"./chunk-I26MS5PJ.js";var e=I(T(),1);var m={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},A={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},C=o((r,a)=>`exempt: ${r.exemptReason===void 0||r.exemptReason===""?a:r.exemptReason}`,"E"),E=o(r=>r.toSorted((a,n)=>a.coverage==="clean"&&n.coverage!=="clean"?1:n.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-n.score),"S"),Y=o(({testId:r="advisor-health"})=>{let a=k(),n=p(u.getAdvisories,{},{live:!0}),g=p(u.getAdvisorProcedures,{},{live:!0}),f=n.data?.advisories??null,N=g.data?.procedures??null,t=f===null||N===null?null:$(N,f),v=g.error??n.error;if(v!==null)return(0,e.jsx)(b,{error:v,testId:`${r}-error`});if(t===null)return(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"py-8 text-center text-muted-foreground","data-testid":`${r}-loading`,children:a("Loading\u2026")})});let R=E(t.procedures);return(0,e.jsxs)("div",{className:"space-y-4","data-testid":r,children:[(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:x("text-4xl font-semibold tabular-nums",A[t.grade]),"data-testid":`${r}-score`,children:t.score}),(0,e.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,e.jsx)("span",{className:x("text-sm font-medium uppercase tracking-wide",A[t.grade]),"data-testid":`${r}-grade`,children:t.grade}),(0,e.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${r}-summary`,children:[(0,e.jsxs)("span",{className:m.clean,children:[t.summary.clean," ",a("clean")]}),(0,e.jsxs)("span",{className:m.warned,children:[t.summary.warned," ",a("warned")]}),(0,e.jsxs)("span",{className:m.failing,children:[t.summary.failing," ",a("failing")]}),(0,e.jsxs)("span",{className:m.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"py-4 text-sm","data-testid":`${r}-project`,children:[(0,e.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",t.project.checks.map(s=>s.name).join(", ")]})]})}),(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"p-0",children:(0,e.jsxs)(y,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(c,{className:"w-20",children:a("Score")}),(0,e.jsx)(c,{children:a("Procedure")}),(0,e.jsx)(c,{className:"w-32",children:a("Kind")}),(0,e.jsx)(c,{children:a("Rules fired")})]})}),(0,e.jsx)(j,{children:R.map(s=>(0,e.jsxs)(h,{"data-testid":`${r}-row`,children:[(0,e.jsx)(i,{className:x("tabular-nums font-medium",m[s.coverage]),children:s.coverage==="exempt"?"\u2014":s.score}),(0,e.jsx)(i,{className:"font-mono text-xs",children:s.id}),(0,e.jsxs)(i,{className:"text-muted-foreground text-xs",children:[s.visibility," ",s.kind,s.sensitivity.level==="high"&&(0,e.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,e.jsx)(i,{className:"text-muted-foreground text-xs",children:s.coverage==="exempt"?C(s,a("no reason given")):s.checks.map(S=>S.name).join(", ")})]},s.id))})]})})})]})},"Y");export{Y as default};
1
+ import{a as $}from"./chunk-WOPEVNW5.js";import{a as b}from"./chunk-SJ7BLQMI.js";import"./chunk-NCPW7WHO.js";import"./chunk-WRQAHEWF.js";import"./chunk-55UGUCQ6.js";import{a as u}from"./chunk-4ZEL6BYL.js";import{c as p}from"./chunk-J6H3YTFH.js";import"./chunk-DGJMFHBV.js";import"./chunk-QAQDMS6R.js";import"./chunk-VEK3S7MV.js";import{a as y,b as w,c as j,d as h,e as c,f as i}from"./chunk-HCTJKP5J.js";import{a as d,e as l}from"./chunk-2IKDEUCX.js";import{d as k}from"./chunk-HJHSQPHW.js";import{a as o,d as I,g as T,i as x}from"./chunk-I26MS5PJ.js";var e=I(T(),1);var m={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},A={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},C=o((r,a)=>`exempt: ${r.exemptReason===void 0||r.exemptReason===""?a:r.exemptReason}`,"E"),E=o(r=>r.toSorted((a,n)=>a.coverage==="clean"&&n.coverage!=="clean"?1:n.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-n.score),"S"),Y=o(({testId:r="advisor-health"})=>{let a=k(),n=p(u.getAdvisories,{},{live:!0}),g=p(u.getAdvisorProcedures,{},{live:!0}),f=n.data?.advisories??null,N=g.data?.procedures??null,t=f===null||N===null?null:$(N,f),v=g.error??n.error;if(v!==null)return(0,e.jsx)(b,{error:v,testId:`${r}-error`});if(t===null)return(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"py-8 text-center text-muted-foreground","data-testid":`${r}-loading`,children:a("Loading\u2026")})});let R=E(t.procedures);return(0,e.jsxs)("div",{className:"space-y-4","data-testid":r,children:[(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:x("text-4xl font-semibold tabular-nums",A[t.grade]),"data-testid":`${r}-score`,children:t.score}),(0,e.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,e.jsx)("span",{className:x("text-sm font-medium uppercase tracking-wide",A[t.grade]),"data-testid":`${r}-grade`,children:t.grade}),(0,e.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${r}-summary`,children:[(0,e.jsxs)("span",{className:m.clean,children:[t.summary.clean," ",a("clean")]}),(0,e.jsxs)("span",{className:m.warned,children:[t.summary.warned," ",a("warned")]}),(0,e.jsxs)("span",{className:m.failing,children:[t.summary.failing," ",a("failing")]}),(0,e.jsxs)("span",{className:m.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"py-4 text-sm","data-testid":`${r}-project`,children:[(0,e.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",t.project.checks.map(s=>s.name).join(", ")]})]})}),(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"p-0",children:(0,e.jsxs)(y,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(c,{className:"w-20",children:a("Score")}),(0,e.jsx)(c,{children:a("Procedure")}),(0,e.jsx)(c,{className:"w-32",children:a("Kind")}),(0,e.jsx)(c,{children:a("Rules fired")})]})}),(0,e.jsx)(j,{children:R.map(s=>(0,e.jsxs)(h,{"data-testid":`${r}-row`,children:[(0,e.jsx)(i,{className:x("tabular-nums font-medium",m[s.coverage]),children:s.coverage==="exempt"?"\u2014":s.score}),(0,e.jsx)(i,{className:"font-mono text-xs",children:s.id}),(0,e.jsxs)(i,{className:"text-muted-foreground text-xs",children:[s.visibility," ",s.kind,s.sensitivity.level==="high"&&(0,e.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,e.jsx)(i,{className:"text-muted-foreground text-xs",children:s.coverage==="exempt"?C(s,a("no reason given")):s.checks.map(S=>S.name).join(", ")})]},s.id))})]})})})]})},"Y");export{Y as default};
@@ -1 +1 @@
1
- import{m as h,n as v}from"./chunk-YU53KJ7Y.js";import{a as u,d as p,f as x,g as y,i as g}from"./chunk-I26MS5PJ.js";var b=p(x(),1);var n=p(y(),1);var w={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},j=u(i=>{let a=(0,b.c)(12),{ariaLabel:c,className:m,series:l,testId:d}=i;if(l.length<2)return null;let t;a[0]!==l?(t=l.slice(-40).map(N),a[0]=l,a[1]=t):t=a[1];let f=t,e;a[2]!==m?(e=g("h-6 w-[120px]",m),a[2]=m,a[3]=e):e=a[3];let o;a[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsx)(v,{dataKey:"value"}),a[4]=o):o=a[4];let r;a[5]!==f?(r=(0,n.jsx)(h,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:w,data:f,children:o}),a[5]=f,a[6]=r):r=a[6];let s;return a[7]!==c||a[8]!==e||a[9]!==r||a[10]!==d?(s=(0,n.jsx)("div",{"aria-label":c,className:e,"data-testid":d,role:"img",children:r}),a[7]=c,a[8]=e,a[9]=r,a[10]=d,a[11]=s):s=a[11],s},"w");function N(i,a){return{index:a,value:i}}u(N,"b");export{j as a};
1
+ import{m as h,n as v}from"./chunk-AN4UDYUY.js";import{a as u,d as p,f as x,g as y,i as g}from"./chunk-I26MS5PJ.js";var b=p(x(),1);var n=p(y(),1);var w={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},j=u(i=>{let a=(0,b.c)(12),{ariaLabel:c,className:m,series:l,testId:d}=i;if(l.length<2)return null;let t;a[0]!==l?(t=l.slice(-40).map(N),a[0]=l,a[1]=t):t=a[1];let f=t,e;a[2]!==m?(e=g("h-6 w-[120px]",m),a[2]=m,a[3]=e):e=a[3];let o;a[4]===Symbol.for("react.memo_cache_sentinel")?(o=(0,n.jsx)(v,{dataKey:"value"}),a[4]=o):o=a[4];let r;a[5]!==f?(r=(0,n.jsx)(h,{animationType:"none",barCategoryGap:1,className:"h-full w-full",config:w,data:f,children:o}),a[5]=f,a[6]=r):r=a[6];let s;return a[7]!==c||a[8]!==e||a[9]!==r||a[10]!==d?(s=(0,n.jsx)("div",{"aria-label":c,className:e,"data-testid":d,role:"img",children:r}),a[7]=c,a[8]=e,a[9]=r,a[10]=d,a[11]=s):s=a[11],s},"w");function N(i,a){return{index:a,value:i}}u(N,"b");export{j as a};
@@ -1 +1 @@
1
- import{a as C}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as v}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as j}from"./chunk-KKVPUQD2.js";import"./chunk-NCPW7WHO.js";import"./chunk-CESYGLNZ.js";import"./chunk-55UGUCQ6.js";import{a as g}from"./chunk-4ZEL6BYL.js";import{c as h}from"./chunk-6RXWGRH7.js";import"./chunk-KU6ZTYP4.js";import"./chunk-QAQDMS6R.js";import"./chunk-54JZD74E.js";import{a as $}from"./chunk-RWVIV3U7.js";import{a as I,b as _,c as q,d as p,e as o,f as i}from"./chunk-HCTJKP5J.js";import{a as S,e as K}from"./chunk-2IKDEUCX.js";import{d as T,t as F}from"./chunk-HJHSQPHW.js";import{a as d,d as k,e as ne,f as oe,g as ie}from"./chunk-I26MS5PJ.js";var Q=k(oe(),1),G=k(ne(),1);var e=k(ie(),1);var H="agent_threads",de="agent_messages",L="agent_run_queue",J=100,N=250,le={},ce={filters:[],limit:J,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:H},c=d((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"c"),B=d((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"E"),O=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"H"),me=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"de"),ue=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"le"),he=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ie"),ge=d(s=>{let t=(0,Q.c)(3),{fetched:a}=s,m=T(),l;return t[0]!==a||t[1]!==m?(l=a<=N?null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:m("Showing the latest {count} messages; older ones are not shown.",{count:N})}),t[0]=a,t[1]=m,t[2]=l):l=t[2],l},"ce"),Te=d(({initialShardKey:s=""})=>{let t=T(),[a,m]=(0,G.useState)(void 0),{data:l}=h(g.listTables,le,{live:!0,shardKey:s}),V=l!==void 0,f=Array.isArray(l)&&l.some(r=>r.name===H),W=Array.isArray(l)&&l.some(r=>r.name===L),{data:E,error:X,errorSource:Y,liveError:Z}=h(g.readTablePage,ce,{enabled:f,live:!0,shardKey:s}),ee={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:N+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:de},{data:P}=h(g.readTablePage,{limit:J,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:L},{enabled:W,live:!0,shardKey:s}),{data:U,error:te,errorSource:ae}=h(g.readTablePage,ee,{enabled:f&&a!==void 0,live:!0,shardKey:s}),b=Array.isArray(E?.rows)?E.rows:[],re=Array.isArray(P?.rows)?P.rows:[],z=d(r=>re.filter(n=>c(n,"threadKey")===r).length,"C"),M=Array.isArray(U?.rows)?U.rows:[],R=M.slice(0,N).toReversed(),D=b.find(r=>c(r,"key")===a),x;return V&&!f?x=(0,e.jsx)($,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):f&&b.length===0?x=(0,e.jsx)($,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):x=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(S,{className:"overflow-hidden py-0",children:(0,e.jsx)(K,{className:"px-0",children:(0,e.jsxs)(I,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)(q,{children:b.map(r=>{let n=c(r,"key")??"",u=c(r,"status"),y=O(r);return(0,e.jsxs)(p,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:c(r,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(v,{"data-testid":`agents-thread-status-${n}`,variant:ue(u),children:u??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:z(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:z(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:B(r,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:y??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:F(B(r,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(C,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{m(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),te!==null&&(0,e.jsx)(j,{error:ae,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(S,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(K,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,D!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",O(D)??0," ",t("Tokens")]})]}),(0,e.jsx)(C,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{m(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),(0,e.jsx)(ge,{fetched:M.length}),R.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(I,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)(q,{children:R.map((r,n)=>{let u=c(r,"role")??"\u2014",y=me(r),se=c(r,"toolName"),w=c(r,"status"),A=B(r,"seq")??n;return(0,e.jsxs)(p,{"data-testid":`agents-message-${String(A)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(r,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:se??(y.length>0?y.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:w===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-message-approval-${String(A)}`,variant:he(w),children:w})})]},c(r,"messageKey")??`${u}:${String(A)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[X!==null&&(0,e.jsx)(j,{error:Y,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),Z!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),x]})},"Ee");export{Te as default};
1
+ import{a as C}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as v}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as j}from"./chunk-SJ7BLQMI.js";import"./chunk-NCPW7WHO.js";import"./chunk-WRQAHEWF.js";import"./chunk-55UGUCQ6.js";import{a as g}from"./chunk-4ZEL6BYL.js";import{c as h}from"./chunk-J6H3YTFH.js";import"./chunk-DGJMFHBV.js";import"./chunk-QAQDMS6R.js";import"./chunk-VEK3S7MV.js";import{a as $}from"./chunk-RWVIV3U7.js";import{a as I,b as _,c as q,d as p,e as o,f as i}from"./chunk-HCTJKP5J.js";import{a as S,e as K}from"./chunk-2IKDEUCX.js";import{d as T,t as F}from"./chunk-HJHSQPHW.js";import{a as d,d as k,e as ne,f as oe,g as ie}from"./chunk-I26MS5PJ.js";var Q=k(oe(),1),G=k(ne(),1);var e=k(ie(),1);var H="agent_threads",de="agent_messages",L="agent_run_queue",J=100,N=250,le={},ce={filters:[],limit:J,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:H},c=d((s,t)=>{let a=s[t];return typeof a=="string"?a:void 0},"c"),B=d((s,t)=>{let a=s[t];return typeof a=="number"?a:void 0},"E"),O=d(s=>{let{usage:t}=s;if(t===null||typeof t!="object")return;let{totalTokens:a}=t;return typeof a=="number"?a:void 0},"H"),me=d(s=>{let{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},"de"),ue=d(s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},"le"),he=d(s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},"ie"),ge=d(s=>{let t=(0,Q.c)(3),{fetched:a}=s,m=T(),l;return t[0]!==a||t[1]!==m?(l=a<=N?null:(0,e.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:m("Showing the latest {count} messages; older ones are not shown.",{count:N})}),t[0]=a,t[1]=m,t[2]=l):l=t[2],l},"ce"),Te=d(({initialShardKey:s=""})=>{let t=T(),[a,m]=(0,G.useState)(void 0),{data:l}=h(g.listTables,le,{live:!0,shardKey:s}),V=l!==void 0,f=Array.isArray(l)&&l.some(r=>r.name===H),W=Array.isArray(l)&&l.some(r=>r.name===L),{data:E,error:X,errorSource:Y,liveError:Z}=h(g.readTablePage,ce,{enabled:f,live:!0,shardKey:s}),ee={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:N+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:de},{data:P}=h(g.readTablePage,{limit:J,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:L},{enabled:W,live:!0,shardKey:s}),{data:U,error:te,errorSource:ae}=h(g.readTablePage,ee,{enabled:f&&a!==void 0,live:!0,shardKey:s}),b=Array.isArray(E?.rows)?E.rows:[],re=Array.isArray(P?.rows)?P.rows:[],z=d(r=>re.filter(n=>c(n,"threadKey")===r).length,"C"),M=Array.isArray(U?.rows)?U.rows:[],R=M.slice(0,N).toReversed(),D=b.find(r=>c(r,"key")===a),x;return V&&!f?x=(0,e.jsx)($,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):f&&b.length===0?x=(0,e.jsx)($,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):x=(0,e.jsxs)("div",{className:"flex flex-col gap-6",children:[(0,e.jsx)(S,{className:"overflow-hidden py-0",children:(0,e.jsx)(K,{className:"px-0",children:(0,e.jsxs)(I,{"data-testid":"agents-threads-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Agent")}),(0,e.jsx)(o,{children:t("Key")}),(0,e.jsx)(o,{children:t("Status")}),(0,e.jsx)(o,{children:t("Queued")}),(0,e.jsx)(o,{children:t("Messages")}),(0,e.jsx)(o,{children:t("Tokens")}),(0,e.jsx)(o,{children:t("Updated")}),(0,e.jsx)(o,{"aria-label":t("Actions")})]})}),(0,e.jsx)(q,{children:b.map(r=>{let n=c(r,"key")??"",u=c(r,"status"),y=O(r);return(0,e.jsxs)(p,{"data-active":n===a?"":void 0,"data-testid":`agents-thread-${n}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:c(r,"agent")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:n}),(0,e.jsx)(i,{children:(0,e.jsx)(v,{"data-testid":`agents-thread-status-${n}`,variant:ue(u),children:u??"\u2014"})}),(0,e.jsx)(i,{className:"tabular-nums",children:z(n)===0?(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:z(n)})}),(0,e.jsx)(i,{className:"tabular-nums",children:B(r,"messageCount")??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums text-muted-foreground",children:y??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:F(B(r,"updatedAt"),"\u2014")}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsx)(C,{"data-testid":`agents-thread-open-${n}`,onClick:d(()=>{m(n)},"onClick"),size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),te!==null&&(0,e.jsx)(j,{error:ae,testId:"agents-messages-error"}),a!==void 0&&(0,e.jsx)(S,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:(0,e.jsxs)(K,{className:"flex flex-col gap-3 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t("Timeline")," \xB7 ",a,D!==void 0&&(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \xB7 ",t("Usage"),": ",O(D)??0," ",t("Tokens")]})]}),(0,e.jsx)(C,{"data-testid":"agents-thread-detail-close",onClick:d(()=>{m(void 0)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),(0,e.jsx)(ge,{fetched:M.length}),R.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):(0,e.jsxs)(I,{"data-testid":"agents-messages-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(o,{children:t("Role")}),(0,e.jsx)(o,{children:t("Content")}),(0,e.jsx)(o,{children:t("Tool")}),(0,e.jsx)(o,{children:t("Approval")})]})}),(0,e.jsx)(q,{children:R.map((r,n)=>{let u=c(r,"role")??"\u2014",y=me(r),se=c(r,"toolName"),w=c(r,"status"),A=B(r,"seq")??n;return(0,e.jsxs)(p,{"data-testid":`agents-message-${String(A)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),(0,e.jsx)(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(r,"content")??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs align-top text-muted-foreground",children:se??(y.length>0?y.join(", "):"\u2014")}),(0,e.jsx)(i,{className:"align-top",children:w===void 0?(0,e.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"}):(0,e.jsx)(v,{"data-testid":`agents-message-approval-${String(A)}`,variant:he(w),children:w})})]},c(r,"messageKey")??`${u}:${String(A)}`)})})]})]})})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[X!==null&&(0,e.jsx)(j,{error:Y,testId:"agents-error"}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),Z!==void 0&&(0,e.jsx)("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),x]})},"Ee");export{Te as default};
@@ -1 +1 @@
1
- import{a as wt}from"./chunk-FPI7AMQJ.js";import{a as Tt}from"./chunk-VOJEROA7.js";import{a as se}from"./chunk-OSGXNEFA.js";import{a as $t}from"./chunk-QJLHH3ET.js";import{a as Ot}from"./chunk-37WYCOQ2.js";import{a as zt,b as _t}from"./chunk-4WD4XGC3.js";import"./chunk-Z22BDS6N.js";import{a as kt}from"./chunk-JQXA2OYK.js";import{i as V}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as j}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as ge}from"./chunk-6RXWGRH7.js";import{g as oe}from"./chunk-KU6ZTYP4.js";import"./chunk-QAQDMS6R.js";import"./chunk-54JZD74E.js";import{a as ue}from"./chunk-RWVIV3U7.js";import{a as Ct,b as It,c as xt,d as Ve,e as me,f as de}from"./chunk-HCTJKP5J.js";import{a as vt,e as yt}from"./chunk-2IKDEUCX.js";import{d as Q,h as Nt,o as A,p as At,t as Dt}from"./chunk-HJHSQPHW.js";import{a as c,d as pt,e as Jt,f as Ut,g as Ht}from"./chunk-I26MS5PJ.js";var H=pt(Ut(),1);var F=pt(Jt(),1);var a=pt(Ht(),1);var Lt=c(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Tt"),Kt=c(t=>{let e=Lt(t),r={};for(let[d,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);r[d]=h}return r},"Qt"),Pt=c(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"$t"),G=c(t=>{let e=(0,H.c)(6),{children:r,htmlFor:d,label:h}=t,i;e[0]!==d||e[1]!==h?(i=(0,a.jsx)(Ot,{htmlFor:d,children:h}),e[0]=d,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"V"),ce=c(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:h,onClose:i,onSubmit:o,submitLabel:l,testId:n,title:m})=>{let s=Q();return(0,a.jsxs)($t,{label:m,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:m}),r,h!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,a.jsx)(j,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,a.jsx)(j,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?s("Saving\u2026"):l})]})]})},"me"),Rt=c(t=>{let e=(0,H.c)(79),{mode:r,onClose:d,onDone:h,org:i}=t,o=oe(),l=Q(),{busy:n,error:m,run:s}=se(),f;e[0]!==i?(f=i?A(i.name):"",e[0]=i,e[1]=f):f=e[1];let[u,b]=(0,F.useState)(f),v;e[2]!==i?(v=i?A(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,p]=(0,F.useState)(v),k;e[4]!==i?(k=i?A(i.logo):"",e[4]=i,e[5]=k):k=e[5];let[y,I]=(0,F.useState)(k),[C,w]=(0,F.useState)(""),x;e[6]!==r||e[7]!==i?.metadata?(x=r==="edit"?Pt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=x):x=e[8];let[z,N]=(0,F.useState)(x),_;e[9]!==o||e[10]!==y||e[11]!==z||e[12]!==r||e[13]!==u||e[14]!==d||e[15]!==h||e[16]!==i?.id||e[17]!==C||e[18]!==s||e[19]!==g?(_=c(()=>{s(async()=>{let S=z.trim()===""?void 0:Lt(z);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:S,name:u.trim(),ownerId:C.trim()===""?void 0:C.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:S,name:u.trim()===""?void 0:u.trim(),organizationId:A(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),d()})},"O"),e[9]=o,e[10]=y,e[11]=z,e[12]=r,e[13]=u,e[14]=d,e[15]=h,e[16]=i?.id,e[17]=C,e[18]=s,e[19]=g,e[20]=_):_=e[20];let D=_,O;e[21]!==r||e[22]!==u?(O=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=O):O=e[23];let T;e[24]!==r||e[25]!==l?(T=l(r==="create"?"Create":"Save"),e[24]=r,e[25]=l,e[26]=T):T=e[26];let $;e[27]!==r||e[28]!==l?($=l(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=l,e[29]=$):$=e[29];let E;e[30]!==l?(E=l("name"),e[30]=l,e[31]=E):E=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=c(S=>{b(S.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,a.jsx)(V,{"data-testid":"org-form-name",id:"org-form-name",onChange:Z,value:u}),e[33]=u,e[34]=B):B=e[34];let K;e[35]!==B||e[36]!==E?(K=(0,a.jsx)(G,{htmlFor:"org-form-name",label:E,children:B}),e[35]=B,e[36]=E,e[37]=K):K=e[37];let J;e[38]!==l?(J=l("Slug (optional \u2014 derived from name)"),e[38]=l,e[39]=J):J=e[39];let P;e[40]===Symbol.for("react.memo_cache_sentinel")?(P=c(S=>{p(S.target.value)},"P"),e[40]=P):P=e[40];let U;e[41]!==g?(U=(0,a.jsx)(V,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:P,value:g}),e[41]=g,e[42]=U):U=e[42];let L;e[43]!==J||e[44]!==U?(L=(0,a.jsx)(G,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=L):L=e[45];let Y;e[46]!==l?(Y=l("Logo URL (optional)"),e[46]=l,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=c(S=>{I(S.target.value)},"M"),e[48]=M):M=e[48];let R;e[49]!==y?(R=(0,a.jsx)(V,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=R):R=e[50];let q;e[51]!==Y||e[52]!==R?(q=(0,a.jsx)(G,{htmlFor:"org-form-logo",label:Y,children:R}),e[51]=Y,e[52]=R,e[53]=q):q=e[53];let W;e[54]!==r||e[55]!==C||e[56]!==l?(W=r==="create"&&(0,a.jsx)(G,{htmlFor:"org-form-owner",label:l("Owner user id (optional)"),children:(0,a.jsx)(V,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:c(S=>{w(S.target.value)},"onChange"),value:C})}),e[54]=r,e[55]=C,e[56]=l,e[57]=W):W=e[57];let te;e[58]!==l?(te=l("Metadata (JSON, optional)"),e[58]=l,e[59]=te):te=e[59];let ae;e[60]===Symbol.for("react.memo_cache_sentinel")?(ae=c(S=>{N(S.target.value)},"oe"),e[60]=ae):ae=e[60];let re;e[61]!==z?(re=(0,a.jsx)(wt,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:ae,value:z}),e[61]=z,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,a.jsx)(G,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let le;return e[66]!==n||e[67]!==m||e[68]!==d||e[69]!==D||e[70]!==K||e[71]!==L||e[72]!==q||e[73]!==W||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==$?(le=(0,a.jsxs)(ce,{busy:n,canSubmit:O,error:m,onClose:d,onSubmit:D,submitLabel:T,testId:"org-form",title:$,children:[K,L,q,W,ee]}),e[66]=n,e[67]=m,e[68]=d,e[69]=D,e[70]=K,e[71]=L,e[72]=q,e[73]=W,e[74]=ee,e[75]=O,e[76]=T,e[77]=$,e[78]=le):le=e[78],le},"yt"),Qt=c(t=>{let e=(0,H.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),[u,b]=(0,F.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==h||e[4]!==u||e[5]!==m||e[6]!==s?(v=c(()=>{m(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),d(),r()})},"p"),e[0]=i,e[1]=r,e[2]=d,e[3]=h,e[4]=u,e[5]=m,e[6]=s,e[7]=v):v=e[7];let g=v,p;e[8]!==s?(p=s.trim(),e[8]=s,e[9]=p):p=e[9];let k=p!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let I;e[12]!==o?(I=o("Add member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("User id"),e[14]=o,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=c($=>{f($.target.value)},"I"),e[16]=w):w=e[16];let x;e[17]!==s?(x=(0,a.jsx)(V,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=x):x=e[18];let z;e[19]!==C||e[20]!==x?(z=(0,a.jsx)(G,{htmlFor:"org-add-member-user",label:C,children:x}),e[19]=C,e[20]=x,e[21]=z):z=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{b($.target.value)},"O"),e[24]=_):_=e[24];let D;e[25]!==u?(D=(0,a.jsx)(V,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=D):D=e[26];let O;e[27]!==N||e[28]!==D?(O=(0,a.jsx)(G,{htmlFor:"org-add-member-role",label:N,children:D}),e[27]=N,e[28]=D,e[29]=O):O=e[29];let T;return e[30]!==l||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==k||e[36]!==y||e[37]!==I||e[38]!==z?(T=(0,a.jsxs)(ce,{busy:l,canSubmit:k,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:I,children:[z,O]}),e[30]=l,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=k,e[36]=y,e[37]=I,e[38]=z,e[39]=T):T=e[39],T},"Jt"),Zt=c(t=>{let e=(0,H.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),[u,b]=(0,F.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==d||e[4]!==h||e[5]!==u||e[6]!==m?(v=c(()=>{m(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),d(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=d,e[4]=h,e[5]=u,e[6]=m,e[7]=v):v=e[7];let g=v,p;e[8]!==s?(p=s.trim(),e[8]=s,e[9]=p):p=e[9];let k=p!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let I;e[12]!==o?(I=o("Invite member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("email"),e[14]=o,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=c($=>{f($.target.value)},"I"),e[16]=w):w=e[16];let x;e[17]!==s?(x=(0,a.jsx)(V,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=x):x=e[18];let z;e[19]!==C||e[20]!==x?(z=(0,a.jsx)(G,{htmlFor:"org-invite-member-email",label:C,children:x}),e[19]=C,e[20]=x,e[21]=z):z=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{b($.target.value)},"O"),e[24]=_):_=e[24];let D;e[25]!==u?(D=(0,a.jsx)(V,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=D):D=e[26];let O;e[27]!==N||e[28]!==D?(O=(0,a.jsx)(G,{htmlFor:"org-invite-member-role",label:N,children:D}),e[27]=N,e[28]=D,e[29]=O):O=e[29];let T;return e[30]!==l||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==k||e[36]!==y||e[37]!==I||e[38]!==z?(T=(0,a.jsxs)(ce,{busy:l,canSubmit:k,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:I,children:[z,O]}),e[30]=l,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=k,e[36]=y,e[37]=I,e[38]=z,e[39]=T):T=e[39],T},"Ut"),Yt=c(t=>{let e=(0,H.c)(32),{member:r,onClose:d,onDone:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),s;e[0]!==r.role?(s=c(()=>A(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[f,u]=(0,F.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==d||e[5]!==h||e[6]!==f||e[7]!==m?(b=c(()=>{m(async()=>{await i.setAuthOrgMemberRole({memberId:A(r.id),role:f.trim()}),h(),d()})},"g"),e[2]=i,e[3]=r.id,e[4]=d,e[5]=h,e[6]=f,e[7]=m,e[8]=b):b=e[8];let v=b,g;e[9]!==f?(g=f.trim(),e[9]=f,e[10]=g):g=e[10];let p=g!=="",k;e[11]!==o?(k=o("Save"),e[11]=o,e[12]=k):k=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let I;e[15]!==o?(I=o("Role"),e[15]=o,e[16]=I):I=e[16];let C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=c(N=>{u(N.target.value)},"y"),e[17]=C):C=e[17];let w;e[18]!==f?(w=(0,a.jsx)(V,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:C,value:f}),e[18]=f,e[19]=w):w=e[19];let x;e[20]!==I||e[21]!==w?(x=(0,a.jsx)(G,{htmlFor:"org-member-role-value",label:I,children:w}),e[20]=I,e[21]=w,e[22]=x):x=e[22];let z;return e[23]!==l||e[24]!==n||e[25]!==d||e[26]!==v||e[27]!==x||e[28]!==p||e[29]!==k||e[30]!==y?(z=(0,a.jsx)(ce,{busy:l,canSubmit:p,error:n,onClose:d,onSubmit:v,submitLabel:k,testId:"org-member-role",title:y,children:x}),e[23]=l,e[24]=n,e[25]=d,e[26]=v,e[27]=x,e[28]=p,e[29]=k,e[30]=y,e[31]=z):z=e[31],z},"Gt"),Mt=c(t=>{let e=(0,H.c)(36),{mode:r,onClose:d,onDone:h,organizationId:i,team:o}=t,l=oe(),n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==o?(u=o?A(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,F.useState)(u),g;e[2]!==l||e[3]!==r||e[4]!==b||e[5]!==d||e[6]!==h||e[7]!==i||e[8]!==f||e[9]!==o?.id?(g=c(()=>{f(async()=>{await(r==="create"?l.createAuthOrgTeam({name:b.trim(),organizationId:i}):l.updateAuthOrgTeam({name:b.trim(),teamId:A(o?.id)})),h(),d()})},"f"),e[2]=l,e[3]=r,e[4]=b,e[5]=d,e[6]=h,e[7]=i,e[8]=f,e[9]=o?.id,e[10]=g):g=e[10];let p=g,k;e[11]!==b?(k=b.trim(),e[11]=b,e[12]=k):k=e[12];let y=k!=="",I;e[13]!==r||e[14]!==n?(I=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=I):I=e[15];let C;e[16]!==r||e[17]!==n?(C=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=C):C=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let x;e[21]===Symbol.for("react.memo_cache_sentinel")?(x=c(D=>{v(D.target.value)},"x"),e[21]=x):x=e[21];let z;e[22]!==b?(z=(0,a.jsx)(V,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:x,value:b}),e[22]=b,e[23]=z):z=e[23];let N;e[24]!==w||e[25]!==z?(N=(0,a.jsx)(G,{htmlFor:"org-team-form-name",label:w,children:z}),e[24]=w,e[25]=z,e[26]=N):N=e[26];let _;return e[27]!==m||e[28]!==s||e[29]!==d||e[30]!==p||e[31]!==N||e[32]!==y||e[33]!==I||e[34]!==C?(_=(0,a.jsx)(ce,{busy:m,canSubmit:y,error:s,onClose:d,onSubmit:p,submitLabel:I,testId:"org-team-form",title:C,children:N}),e[27]=m,e[28]=s,e[29]=d,e[30]=p,e[31]=N,e[32]=y,e[33]=I,e[34]=C,e[35]=_):_=e[35],_},"Ct"),qt=c(t=>{let e=(0,H.c)(30),{onClose:r,onDone:d,teamId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==m||e[4]!==h||e[5]!==s?(u=c(()=>{m(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),d(),r()})},"c"),e[0]=i,e[1]=r,e[2]=d,e[3]=m,e[4]=h,e[5]=s,e[6]=u):u=e[6];let b=u,v;e[7]!==s?(v=s.trim(),e[7]=s,e[8]=v):v=e[8];let g=v!=="",p;e[9]!==o?(p=o("Add member"),e[9]=o,e[10]=p):p=e[10];let k;e[11]!==o?(k=o("Add team member"),e[11]=o,e[12]=k):k=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=c(z=>{f(z.target.value)},"C"),e[15]=I):I=e[15];let C;e[16]!==s?(C=(0,a.jsx)(V,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:I,value:s}),e[16]=s,e[17]=C):C=e[17];let w;e[18]!==y||e[19]!==C?(w=(0,a.jsx)(G,{htmlFor:"org-team-add-member-user",label:y,children:C}),e[18]=y,e[19]=C,e[20]=w):w=e[20];let x;return e[21]!==l||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==p||e[27]!==k||e[28]!==w?(x=(0,a.jsx)(ce,{busy:l,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:p,testId:"org-team-add-member",title:k,children:w}),e[21]=l,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=p,e[27]=k,e[28]=w,e[29]=x):x=e[29],x},"Ht"),Ft=c(t=>{let e=(0,H.c)(47),{mode:r,onClose:d,onDone:h,organizationId:i,role:o}=t,l=oe(),n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==o?(u=o?A(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,F.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Pt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[p,k]=(0,F.useState)(g),y;e[5]!==l||e[6]!==r||e[7]!==b||e[8]!==d||e[9]!==h||e[10]!==i||e[11]!==p||e[12]!==o?.id||e[13]!==f?(y=c(()=>{f(async()=>{let $=Kt(p);await(r==="create"?l.createAuthOrgRole({organizationId:i,permission:$,role:b.trim()}):l.updateAuthOrgRole({permission:$,roleId:A(o?.id)})),h(),d()})},"v"),e[5]=l,e[6]=r,e[7]=b,e[8]=d,e[9]=h,e[10]=i,e[11]=p,e[12]=o?.id,e[13]=f,e[14]=y):y=e[14];let I=y,C;e[15]!==r||e[16]!==b||e[17]!==p?(C=p.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=p,e[18]=C):C=e[18];let w;e[19]!==r||e[20]!==n?(w=n(r==="create"?"Create":"Save"),e[19]=r,e[20]=n,e[21]=w):w=e[21];let x;e[22]!==r||e[23]!==n?(x=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=x):x=e[24];let z;e[25]!==r||e[26]!==b||e[27]!==n?(z=r==="create"&&(0,a.jsx)(G,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,a.jsx)(V,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:c($=>{v($.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=z):z=e[28];let N;e[29]!==n?(N=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=N):N=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{k($.target.value)},"O"),e[31]=_):_=e[31];let D;e[32]!==p?(D=(0,a.jsx)(wt,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:p}),e[32]=p,e[33]=D):D=e[33];let O;e[34]!==D||e[35]!==N?(O=(0,a.jsx)(G,{htmlFor:"org-role-form-permission",label:N,children:D}),e[34]=D,e[35]=N,e[36]=O):O=e[36];let T;return e[37]!==m||e[38]!==s||e[39]!==d||e[40]!==I||e[41]!==O||e[42]!==C||e[43]!==w||e[44]!==x||e[45]!==z?(T=(0,a.jsxs)(ce,{busy:m,canSubmit:C,error:s,onClose:d,onSubmit:I,submitLabel:w,testId:"org-role-form",title:x,children:[z,O]}),e[37]=m,e[38]=s,e[39]=d,e[40]=I,e[41]=O,e[42]=C,e[43]=w,e[44]=x,e[45]=z,e[46]=T):T=e[46],T},"xt"),Bt=c(t=>{let e=(0,H.c)(18),{action:r,message:d,onClose:h,onDone:i,testId:o,title:l}=t,n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==f?(u=c(()=>{f(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=f,e[4]=u):u=e[4];let b=u,v;e[5]!==n?(v=n("Delete"),e[5]=n,e[6]=v):v=e[6];let g;e[7]!==d?(g=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=g):g=e[8];let p;return e[9]!==m||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==l?(p=(0,a.jsx)(ce,{busy:m,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:l,children:g}),e[9]=m,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=l,e[17]=p):p=e[17],p},"Mt"),Xe=c(t=>{let e=(0,H.c)(13),{action:r,children:d,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[0]=h,e[1]=o):o=e[1];let l;e[2]!==r?(l=r!==void 0&&(0,a.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=l):l=e[3];let n;e[4]!==o||e[5]!==l?(n=(0,a.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,l]}),e[4]=o,e[5]=l,e[6]=n):n=e[6];let m;e[7]!==d?(m=(0,a.jsx)(yt,{className:"px-0",children:d}),e[7]=d,e[8]=m):m=e[8];let s;return e[9]!==n||e[10]!==m||e[11]!==i?(s=(0,a.jsxs)(vt,{className:"overflow-hidden py-0","data-testid":i,children:[n,m]}),e[9]=n,e[10]=m,e[11]=i,e[12]=s):s=e[12],s},"We"),We=c(t=>{let e=(0,H.c)(23),{columns:r,rowActions:d,rowPrefix:h,rows:i}=t,o=Q(),l;e[0]!==r?(l=r.map(Gt),e[0]=r,e[1]=l):l=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==n?(m=(0,a.jsx)(me,{"aria-label":n}),e[4]=n,e[5]=m):m=e[5];let s;e[6]!==l||e[7]!==m?(s=(0,a.jsx)(It,{children:(0,a.jsxs)(Ve,{children:[l,m]})}),e[6]=l,e[7]=m,e[8]=s):s=e[8];let f;if(e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==d||e[16]!==h?(v=c((g,p)=>{let k=A(g.id),y=k===""?`index-${p.toString()}`:k;return(0,a.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(I=>(0,a.jsx)(de,{className:I.className,children:I.render(g)},I.head)),(0,a.jsx)(de,{children:(0,a.jsx)("div",{className:"flex justify-end gap-1",children:d(g)})})]},y)},"p"),e[14]=r,e[15]=d,e[16]=h,e[17]=v):v=e[17],f=i.map(v),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=f}else f=e[13];let u;e[18]!==f?(u=(0,a.jsx)(xt,{children:f}),e[18]=f,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,a.jsxs)(Ct,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"Xe");function Gt(t){return(0,a.jsx)(me,{children:t.head},t.head)}c(Gt,"Zt");var Vt=c(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:d,memberColumns:h,members:i,onDialog:o}=t,l=Q(),n;e[0]!==o?(n=c(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let m;e[2]!==l?(m=l("Add member"),e[2]=l,e[3]=m):m=e[3];let s;e[4]!==n||e[5]!==m?(s=(0,a.jsx)(j,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:m}),e[4]=n,e[5]=m,e[6]=s):s=e[6];let f;e[7]!==o?(f=c(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=f):f=e[8];let u;e[9]!==l?(u=l("Invite member"),e[9]=l,e[10]=u):u=e[10];let b;e[11]!==f||e[12]!==u?(b=(0,a.jsx)(j,{"data-testid":"org-open-invite-member",onClick:f,size:"xs",type:"button",variant:"outline",children:u}),e[11]=f,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,a.jsxs)(a.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==l?(g=l("Members"),e[17]=l,e[18]=g):g=e[18];let p;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==d||e[24]!==l?(p=i.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-members-empty",title:l("No members.")})}):(0,a.jsx)(We,{columns:h,rowActions:c(y=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"data-testid":`org-member-role-${A(y.id)}`,onClick:c(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Change role")}),(0,a.jsx)(j,{"data-testid":`org-remove-member-${A(y.id)}`,disabled:r,onClick:c(()=>{d(A(y.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=d,e[24]=l,e[25]=p):p=e[25];let k;return e[26]!==v||e[27]!==g||e[28]!==p?(k=(0,a.jsx)(Xe,{action:v,heading:g,testId:"org-members",children:p}),e[26]=v,e[27]=g,e[28]=p,e[29]=k):k=e[29],k},"qt"),Xt=c(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:d,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:l}=t,n=Q(),m;e[0]!==d?(m=c(()=>{d({kind:"team-create"})},"m"),e[0]=d,e[1]=m):m=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let f;e[4]!==m||e[5]!==s?(f=(0,a.jsx)(j,{"data-testid":"org-open-create-team",onClick:m,size:"xs",type:"button",variant:"outline",children:s}),e[4]=m,e[5]=s,e[6]=f):f=e[6];let u;e[7]!==n?(u=n("Teams"),e[7]=n,e[8]=u):u=e[8];let b;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==l?(b=l.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-teams-empty",title:n("No teams.")})}):(0,a.jsx)(We,{columns:o,rowActions:c(g=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"aria-pressed":i===A(g.id),"data-testid":`org-team-select-${A(g.id)}`,onClick:c(()=>{h(A(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,a.jsx)(j,{"data-testid":`org-team-rename-${A(g.id)}`,onClick:c(()=>{d({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,a.jsx)(j,{"data-testid":`org-team-delete-${A(g.id)}`,onClick:c(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:l}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=l,e[16]=b):b=e[16];let v;return e[17]!==f||e[18]!==u||e[19]!==b?(v=(0,a.jsx)(Xe,{action:f,heading:u,testId:"org-teams",children:b}),e[17]=f,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"Kt"),Wt=c(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:d,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:l}=t,n=Q(),m;e[0]!==h||e[1]!==i?(m=c(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=m):m=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let f;e[5]!==m||e[6]!==s?(f=(0,a.jsx)(j,{"data-testid":"org-open-add-team-member",onClick:m,size:"xs",type:"button",variant:"outline",children:s}),e[5]=m,e[6]=s,e[7]=f):f=e[7];let u;e[8]!==n?(u=n("Team members"),e[8]=n,e[9]=u):u=e[9];let b;e[10]!==r||e[11]!==d||e[12]!==n||e[13]!==o||e[14]!==l?(b=l.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,a.jsx)(We,{columns:o,rowActions:c(g=>(0,a.jsx)(j,{"data-testid":`org-team-remove-member-${A(g.id)}`,disabled:r,onClick:c(()=>{d(A(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:l}),e[10]=r,e[11]=d,e[12]=n,e[13]=o,e[14]=l,e[15]=b):b=e[15];let v;return e[16]!==f||e[17]!==u||e[18]!==b?(v=(0,a.jsx)(Xe,{action:f,heading:u,testId:"org-team-members",children:b}),e[16]=f,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"Vt"),er=c(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:d,roleColumns:h,roles:i}=t,o=Q(),l;e[0]!==d?(l=c(()=>{d({kind:"role-create"})},"i"),e[0]=d,e[1]=l):l=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==l||e[5]!==n?(m=(0,a.jsx)(j,{"data-testid":"org-open-create-role",onClick:l,size:"xs",type:"button",variant:"outline",children:n}),e[4]=l,e[5]=n,e[6]=m):m=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let f;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==o?(f=i.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,a.jsx)(We,{columns:h,rowActions:c(b=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"data-testid":`org-role-edit-${A(b.id)}`,onClick:c(()=>{d({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,a.jsx)(j,{"data-testid":`org-role-delete-${A(b.id)}`,onClick:c(()=>{r(A(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=o,e[14]=f):f=e[14];let u;return e[15]!==m||e[16]!==s||e[17]!==f?(u=(0,a.jsx)(Xe,{action:m,heading:s,testId:"org-roles",children:f}),e[15]=m,e[16]=s,e[17]=f,e[18]=u):u=e[18],u},"Wt"),Et=200,tr=c(t=>{let e=(0,H.c)(207),{organizationId:r,rolesEnabled:d,teamsEnabled:h}=t,i=oe(),o=Q(),[l,n]=(0,F.useState)(null),[m,s]=(0,F.useState)(null),[f,u]=(0,F.useState)(!1),[b,v]=(0,F.useState)(null),[g,p]=_t(r),k;e[0]!==g||e[1]!==r?(k=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=k):k=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=c(()=>i.listAuthOrgMembers({limit:Et,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let I=ge(k,y),C;e[7]!==r?(C=["lunora-auth-org-invitations",r],e[7]=r,e[8]=C):C=e[8];let w;e[9]!==i||e[10]!==r?(w=c(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let x=ge(C,w),z;e[12]!==r?(z=["lunora-auth-org-teams",r],e[12]=r,e[13]=z):z=e[13];let N;e[14]!==i||e[15]!==r?(N=c(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"D"),e[14]=i,e[15]=r,e[16]=N):N=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let D=ge(z,N,_),O;e[19]!==r?(O=["lunora-auth-org-roles",r],e[19]=r,e[20]=O):O=e[20];let T;e[21]!==i||e[22]!==r?(T=c(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let $;e[24]!==d?($={enabled:d},e[24]=d,e[25]=$):$=e[25];let E=ge(O,T,$),Z;e[26]!==m?(Z=["lunora-auth-org-team-members",m],e[26]=m,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==m?(B=c(()=>i.listAuthOrgTeamMembers({limit:200,teamId:m??""}),"B"),e[28]=i,e[29]=m,e[30]=B):B=e[30];let K=m!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let P=ge(Z,B,J),U;e[33]!==I.data?.rows?(U=I.data?.rows??[],e[33]=I.data?.rows,e[34]=U):U=e[34];let L=U,Y;e[35]!==x.data?.rows?(Y=x.data?.rows??[],e[35]=x.data?.rows,e[36]=Y):Y=e[36];let M=Y,R;e[37]!==D.data?.rows?(R=D.data?.rows??[],e[37]=D.data?.rows,e[38]=R):R=e[38];let q=R,W;e[39]!==E.data?.rows?(W=E.data?.rows??[],e[39]=E.data?.rows,e[40]=W):W=e[40];let te=W,ae;e[41]!==m||e[42]!==P?(ae=m===null?[]:P.data?.rows??[],e[41]=m,e[42]=P,e[43]=ae):ae=e[43];let re=ae,ee=I.error??x.error??D.error??E.error??P.error,le;e[44]!==x||e[45]!==I||e[46]!==d||e[47]!==E||e[48]!==m||e[49]!==P||e[50]!==h||e[51]!==D?(le=c(()=>{I.refetch(),x.refetch(),h&&D.refetch(),d&&E.refetch(),m!==null&&P.refetch()},"ie"),e[44]=x,e[45]=I,e[46]=d,e[47]=E,e[48]=m,e[49]=P,e[50]=h,e[51]=D,e[52]=le):le=e[52];let S=le;kt(S,!0);let et;e[53]===Symbol.for("react.memo_cache_sentinel")?(et=c(()=>{n(null)},"Ye"),e[53]=et):et=e[53];let ne=et,tt;e[54]!==S?(tt=c(X=>{At((async()=>{u(!0),v(null);try{await X(),S(),u(!1)}catch(mt){v(Nt(mt)),u(!1)}})())},"et"),e[54]=S,e[55]=tt):tt=e[55];let ie=tt,rt;e[56]!==i||e[57]!==o?(rt=c(X=>{let mt=A(X.id);n({action:c(async()=>{await i.removeAuthOrgTeam({teamId:mt}),s(St=>St===mt?null:St)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"tt"),e[56]=i,e[57]=o,e[58]=rt):rt=e[58];let dt=rt,he;e[59]!==o?(he=o("userId"),e[59]=o,e[60]=he):he=e[60];let be;e[61]!==he?(be={head:he,render:rr},e[61]=he,e[62]=be):be=e[62];let fe;e[63]!==o?(fe=o("role"),e[63]=o,e[64]=fe):fe=e[64];let pe;e[65]!==fe?(pe={head:fe,render:or},e[65]=fe,e[66]=pe):pe=e[66];let ot;e[67]!==be||e[68]!==pe?(ot=[be,pe],e[67]=be,e[68]=pe,e[69]=ot):ot=e[69];let ct=ot,ve;e[70]!==o?(ve=o("email"),e[70]=o,e[71]=ve):ve=e[71];let ye;e[72]!==ve?(ye={head:ve,render:ar},e[72]=ve,e[73]=ye):ye=e[73];let Ce;e[74]!==o?(Ce=o("role"),e[74]=o,e[75]=Ce):Ce=e[75];let Ie;e[76]!==Ce?(Ie={head:Ce,render:lr},e[76]=Ce,e[77]=Ie):Ie=e[77];let xe;e[78]!==o?(xe=o("status"),e[78]=o,e[79]=xe):xe=e[79];let we;e[80]!==xe?(we={head:xe,render:nr},e[80]=xe,e[81]=we):we=e[81];let at;e[82]!==ye||e[83]!==Ie||e[84]!==we?(at=[ye,Ie,we],e[82]=ye,e[83]=Ie,e[84]=we,e[85]=at):at=e[85];let ut=at,ke;e[86]!==o?(ke=o("id"),e[86]=o,e[87]=ke):ke=e[87];let ze;e[88]!==ke?(ze={className:"font-mono text-xs",head:ke,render:ir},e[88]=ke,e[89]=ze):ze=e[89];let Se;e[90]!==o?(Se=o("name"),e[90]=o,e[91]=Se):Se=e[91];let Ne;e[92]!==Se?(Ne={head:Se,render:sr},e[92]=Se,e[93]=Ne):Ne=e[93];let lt;e[94]!==ze||e[95]!==Ne?(lt=[ze,Ne],e[94]=ze,e[95]=Ne,e[96]=lt):lt=e[96];let gt=lt,Ae;e[97]!==o?(Ae=o("userId"),e[97]=o,e[98]=Ae):Ae=e[98];let nt;e[99]!==Ae?(nt=[{head:Ae,render:mr}],e[99]=Ae,e[100]=nt):nt=e[100];let ht=nt,De;e[101]!==o?(De=o("role"),e[101]=o,e[102]=De):De=e[102];let Oe;e[103]!==De?(Oe={head:De,render:dr},e[103]=De,e[104]=Oe):Oe=e[104];let _e;e[105]!==o?(_e=o("Permission"),e[105]=o,e[106]=_e):_e=e[106];let Te;e[107]!==_e?(Te={className:"font-mono text-xs whitespace-pre-wrap",head:_e,render:cr},e[107]=_e,e[108]=Te):Te=e[108];let it;e[109]!==Oe||e[110]!==Te?(it=[Oe,Te],e[109]=Oe,e[110]=Te,e[111]=it):it=e[111];let bt=it,$e;e[112]!==ee?($e=ee!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[112]=ee,e[113]=$e):$e=e[113];let Re;e[114]!==b?(Re=b!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[114]=b,e[115]=Re):Re=e[115];let Me;e[116]!==i||e[117]!==ie?(Me=c(X=>{ie(()=>i.removeAuthOrgMember({memberId:X}))},"$e"),e[116]=i,e[117]=ie,e[118]=Me):Me=e[118];let Fe;e[119]!==f||e[120]!==ct||e[121]!==L||e[122]!==Me?(Fe=(0,a.jsx)(Vt,{actionBusy:f,memberColumns:ct,members:L,onDialog:n,onRemoveMember:Me}),e[119]=f,e[120]=ct,e[121]=L,e[122]=Me,e[123]=Fe):Fe=e[123];let ft=I.data?.total,Ee;e[124]!==L.length||e[125]!==g||e[126]!==p||e[127]!==ft?(Ee=(0,a.jsx)(zt,{count:L.length,offset:g,onOffsetChange:p,pageSize:Et,prefix:"org-members",total:ft}),e[124]=L.length,e[125]=g,e[126]=p,e[127]=ft,e[128]=Ee):Ee=e[128];let je;e[129]!==f||e[130]!==i||e[131]!==ut||e[132]!==M||e[133]!==ie||e[134]!==o?(je=M.length>0&&(0,a.jsx)(Xe,{heading:o("Invitations"),testId:"org-invitations",children:(0,a.jsx)(We,{columns:ut,rowActions:c(X=>(0,a.jsx)(j,{"data-testid":`org-cancel-invitation-${A(X.id)}`,disabled:f,onClick:c(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:A(X.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[129]=f,e[130]=i,e[131]=ut,e[132]=M,e[133]=ie,e[134]=o,e[135]=je):je=e[135];let Le;e[136]!==dt||e[137]!==m||e[138]!==gt||e[139]!==q||e[140]!==h?(Le=h&&(0,a.jsx)(Xt,{onConfirmDeleteTeam:dt,onDialog:n,onSelectTeam:s,selectedTeam:m,teamColumns:gt,teams:q}),e[136]=dt,e[137]=m,e[138]=gt,e[139]=q,e[140]=h,e[141]=Le):Le=e[141];let Pe;e[142]!==f||e[143]!==i||e[144]!==ie||e[145]!==m||e[146]!==ht||e[147]!==re||e[148]!==h?(Pe=h&&m!==null&&(0,a.jsx)(Wt,{actionBusy:f,onDialog:n,onRemoveTeamMember:c(X=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:X}))},"onRemoveTeamMember"),selectedTeam:m,teamMemberColumns:ht,teamMembers:re}),e[142]=f,e[143]=i,e[144]=ie,e[145]=m,e[146]=ht,e[147]=re,e[148]=h,e[149]=Pe):Pe=e[149];let Be;e[150]!==i||e[151]!==bt||e[152]!==te||e[153]!==d||e[154]!==o?(Be=d&&(0,a.jsx)(er,{onConfirmDeleteRole:c(X=>{n({action:c(()=>i.deleteAuthOrgRole({roleId:X}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onConfirmDeleteRole"),onDialog:n,roleColumns:bt,roles:te}),e[150]=i,e[151]=bt,e[152]=te,e[153]=d,e[154]=o,e[155]=Be):Be=e[155];let Je;e[156]!==l?.kind||e[157]!==r||e[158]!==S?(Je=l?.kind==="add-member"&&(0,a.jsx)(Qt,{onClose:ne,onDone:S,organizationId:r}),e[156]=l?.kind,e[157]=r,e[158]=S,e[159]=Je):Je=e[159];let Ue;e[160]!==l?.kind||e[161]!==r||e[162]!==S?(Ue=l?.kind==="invite-member"&&(0,a.jsx)(Zt,{onClose:ne,onDone:S,organizationId:r}),e[160]=l?.kind,e[161]=r,e[162]=S,e[163]=Ue):Ue=e[163];let He;e[164]!==l||e[165]!==S?(He=l?.kind==="member-role"&&(0,a.jsx)(Yt,{member:l.member,onClose:ne,onDone:S}),e[164]=l,e[165]=S,e[166]=He):He=e[166];let Ke;e[167]!==l?.kind||e[168]!==r||e[169]!==S?(Ke=l?.kind==="team-create"&&(0,a.jsx)(Mt,{mode:"create",onClose:ne,onDone:S,organizationId:r}),e[167]=l?.kind,e[168]=r,e[169]=S,e[170]=Ke):Ke=e[170];let Qe;e[171]!==l||e[172]!==r||e[173]!==S?(Qe=l?.kind==="team-rename"&&(0,a.jsx)(Mt,{mode:"edit",onClose:ne,onDone:S,organizationId:r,team:l.team}),e[171]=l,e[172]=r,e[173]=S,e[174]=Qe):Qe=e[174];let Ze;e[175]!==l||e[176]!==S?(Ze=l?.kind==="team-add-member"&&(0,a.jsx)(qt,{onClose:ne,onDone:S,teamId:l.teamId}),e[175]=l,e[176]=S,e[177]=Ze):Ze=e[177];let Ye;e[178]!==l?.kind||e[179]!==r||e[180]!==S?(Ye=l?.kind==="role-create"&&(0,a.jsx)(Ft,{mode:"create",onClose:ne,onDone:S,organizationId:r}),e[178]=l?.kind,e[179]=r,e[180]=S,e[181]=Ye):Ye=e[181];let qe;e[182]!==l||e[183]!==r||e[184]!==S?(qe=l?.kind==="role-edit"&&(0,a.jsx)(Ft,{mode:"edit",onClose:ne,onDone:S,organizationId:r,role:l.role}),e[182]=l,e[183]=r,e[184]=S,e[185]=qe):qe=e[185];let Ge;e[186]!==l||e[187]!==S?(Ge=l?.kind==="confirm"&&(0,a.jsx)(Bt,{action:l.action,message:l.message,onClose:ne,onDone:S,testId:l.testId,title:l.title}),e[186]=l,e[187]=S,e[188]=Ge):Ge=e[188];let st;return e[189]!==$e||e[190]!==Re||e[191]!==Fe||e[192]!==Ee||e[193]!==je||e[194]!==Le||e[195]!==Pe||e[196]!==Be||e[197]!==Je||e[198]!==Ue||e[199]!==He||e[200]!==Ke||e[201]!==Qe||e[202]!==Ze||e[203]!==Ye||e[204]!==qe||e[205]!==Ge?(st=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Re,Fe,Ee,je,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge]}),e[189]=$e,e[190]=Re,e[191]=Fe,e[192]=Ee,e[193]=je,e[194]=Le,e[195]=Pe,e[196]=Be,e[197]=Je,e[198]=Ue,e[199]=He,e[200]=Ke,e[201]=Qe,e[202]=Ze,e[203]=Ye,e[204]=qe,e[205]=Ge,e[206]=st):st=e[206],st},"Xt");function rr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:A(t.userId)})}c(rr,"Yt");function or(t){return A(t.role)}c(or,"el");function ar(t){return A(t.email)}c(ar,"tl");function lr(t){return A(t.role)}c(lr,"ll");function nr(t){return A(t.status)}c(nr,"ol");function ir(t){return A(t.id)}c(ir,"il");function sr(t){return A(t.name)}c(sr,"rl");function mr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:A(t.userId)})}c(mr,"nl");function dr(t){return A(t.role)}c(dr,"sl");function cr(t){return A(t.permission)}c(cr,"al");var jt=100,Ar=c(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:d,ready:h}=Tt(),i=d.capabilities.organization,[o,l]=(0,F.useState)(null),[n,m]=(0,F.useState)(null),[s,f]=(0,F.useState)(0),u;t[0]!==s?(u=["lunora-auth-orgs",s],t[0]=s,t[1]=u):u=t[1];let b;t[2]!==e||t[3]!==s?(b=c(()=>e.listAuthOrganizations({limit:jt,offset:s}),"g"),t[2]=e,t[3]=s,t[4]=b):b=t[4];let v;t[5]!==i?(v={enabled:i},t[5]=i,t[6]=v):v=t[6];let g=ge(u,b,v),p=g.data?.rows??null,k;t[7]!==g?(k=c(()=>{g.refetch()},"S"),t[7]=g,t[8]=k):k=t[8],kt(k,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=c(()=>{m(null)},"v"),t[9]=y):y=t[9];let I=y,C;t[10]!==g?(C=c(()=>{g.refetch()},"y"),t[10]=g,t[11]=C):C=t[11];let w=C,x;t[12]===Symbol.for("react.memo_cache_sentinel")?(x=c(M=>{l(M)},"x"),t[12]=x):x=t[12];let z=x;if(h&&!i){let M;t[13]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=r,t[14]=M):M=t[14];let R;t[15]!==r?(R=r("Organizations are not enabled."),t[15]=r,t[16]=R):R=t[16];let q;return t[17]!==M||t[18]!==R?(q=(0,a.jsx)(ue,{description:M,testId:"org-disabled",title:R}),t[17]=M,t[18]=R,t[19]=q):q=t[19],q}let N;t[20]!==r?(N=r("Organizations"),t[20]=r,t[21]=N):N=t[21];let _;t[22]!==N?(_=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),t[22]=N,t[23]=_):_=t[23];let D;t[24]===Symbol.for("react.memo_cache_sentinel")?(D=c(()=>{m({kind:"create"})},"A"),t[24]=D):D=t[24];let O;t[25]!==r?(O=r("New organization"),t[25]=r,t[26]=O):O=t[26];let T;t[27]!==O?(T=(0,a.jsx)(j,{"data-testid":"org-new",onClick:D,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let $;t[29]!==T||t[30]!==_?($=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=$):$=t[31];let E;t[32]!==g.error?(E=g.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=E):E=t[33];let Z;t[34]!==p||t[35]!==r?(Z=p!==null&&p.length===0&&(0,a.jsx)(ue,{testId:"org-empty",title:r("No organizations.")}),t[34]=p,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==p||t[38]!==o||t[39]!==r?(B=p!==null&&p.length>0&&(0,a.jsx)(vt,{className:"overflow-hidden py-0",children:(0,a.jsx)(yt,{className:"px-0",children:(0,a.jsxs)(Ct,{"data-testid":"org-table",children:[(0,a.jsx)(It,{children:(0,a.jsxs)(Ve,{children:[(0,a.jsx)(me,{children:r("id")}),(0,a.jsx)(me,{children:r("name")}),(0,a.jsx)(me,{children:r("slug")}),(0,a.jsx)(me,{children:r("created")}),(0,a.jsx)(me,{"aria-label":r("Actions")})]})}),(0,a.jsx)(xt,{children:p.map(M=>{let R=A(M.id);return(0,a.jsxs)(Ve,{"data-testid":`org-row-${R}`,children:[(0,a.jsx)(de,{className:"font-mono text-xs",children:R}),(0,a.jsx)(de,{children:A(M.name)}),(0,a.jsx)(de,{children:A(M.slug)}),(0,a.jsx)(de,{className:"text-muted-foreground tabular-nums",children:Dt(M.createdAt)}),(0,a.jsx)(de,{children:(0,a.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,a.jsx)(j,{"aria-pressed":o===R,"data-testid":`org-select-${R}`,onClick:c(()=>{z(R)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,a.jsx)(j,{"data-testid":`org-edit-${R}`,onClick:c(()=>{m({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,a.jsx)(j,{"data-testid":`org-delete-${R}`,onClick:c(()=>{m({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},R)})})]})})}),t[37]=p,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==p||t[43]!==g.data?.total?(K=p!==null&&(0,a.jsx)(zt,{count:p.length,offset:s,onOffsetChange:f,pageSize:jt,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=p,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==d.organization||t[46]!==o?(J=o!==null&&(0,a.jsx)(tr,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[45]=d.organization,t[46]=o,t[47]=J):J=t[47];let P;t[48]!==n?.kind||t[49]!==w?(P=n?.kind==="create"&&(0,a.jsx)(Rt,{mode:"create",onClose:I,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=P):P=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,a.jsx)(Rt,{mode:"edit",onClose:I,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let L;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(L=n?.kind==="delete"&&(0,a.jsx)(Bt,{action:c(async()=>{let M=A(n.org.id);await e.deleteAuthOrganization({organizationId:M}),l(R=>R===M?null:R)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:I,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=L):L=t[58];let Y;return t[59]!==$||t[60]!==E||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==P||t[66]!==U||t[67]!==L?(Y=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[$,E,Z,B,K,J,P,U,L]}),t[59]=$,t[60]=E,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=P,t[66]=U,t[67]=L,t[68]=Y):Y=t[68],Y},"Al");export{Ar as default};
1
+ import{a as wt}from"./chunk-FPI7AMQJ.js";import{a as Tt}from"./chunk-5UEMUPTW.js";import{a as se}from"./chunk-OSGXNEFA.js";import{a as $t}from"./chunk-QJLHH3ET.js";import{a as Ot}from"./chunk-37WYCOQ2.js";import{a as zt,b as _t}from"./chunk-4WD4XGC3.js";import"./chunk-Z22BDS6N.js";import{a as kt}from"./chunk-JQXA2OYK.js";import{i as V}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as j}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as ge}from"./chunk-J6H3YTFH.js";import{g as oe}from"./chunk-DGJMFHBV.js";import"./chunk-QAQDMS6R.js";import"./chunk-VEK3S7MV.js";import{a as ue}from"./chunk-RWVIV3U7.js";import{a as Ct,b as It,c as xt,d as Ve,e as me,f as de}from"./chunk-HCTJKP5J.js";import{a as vt,e as yt}from"./chunk-2IKDEUCX.js";import{d as Q,h as Nt,o as A,p as At,t as Dt}from"./chunk-HJHSQPHW.js";import{a as c,d as pt,e as Jt,f as Ut,g as Ht}from"./chunk-I26MS5PJ.js";var H=pt(Ut(),1);var F=pt(Jt(),1);var a=pt(Ht(),1);var Lt=c(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Tt"),Kt=c(t=>{let e=Lt(t),r={};for(let[d,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${d}" must map to an array of action strings`);r[d]=h}return r},"Qt"),Pt=c(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"$t"),G=c(t=>{let e=(0,H.c)(6),{children:r,htmlFor:d,label:h}=t,i;e[0]!==d||e[1]!==h?(i=(0,a.jsx)(Ot,{htmlFor:d,children:h}),e[0]=d,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"V"),ce=c(({busy:t,canSubmit:e,children:r,destructive:d=!1,error:h,onClose:i,onSubmit:o,submitLabel:l,testId:n,title:m})=>{let s=Q();return(0,a.jsxs)($t,{label:m,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:m}),r,h!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,a.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,a.jsx)(j,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,a.jsx)(j,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:d?"destructive":"default",children:t?s("Saving\u2026"):l})]})]})},"me"),Rt=c(t=>{let e=(0,H.c)(79),{mode:r,onClose:d,onDone:h,org:i}=t,o=oe(),l=Q(),{busy:n,error:m,run:s}=se(),f;e[0]!==i?(f=i?A(i.name):"",e[0]=i,e[1]=f):f=e[1];let[u,b]=(0,F.useState)(f),v;e[2]!==i?(v=i?A(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,p]=(0,F.useState)(v),k;e[4]!==i?(k=i?A(i.logo):"",e[4]=i,e[5]=k):k=e[5];let[y,I]=(0,F.useState)(k),[C,w]=(0,F.useState)(""),x;e[6]!==r||e[7]!==i?.metadata?(x=r==="edit"?Pt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=x):x=e[8];let[z,N]=(0,F.useState)(x),_;e[9]!==o||e[10]!==y||e[11]!==z||e[12]!==r||e[13]!==u||e[14]!==d||e[15]!==h||e[16]!==i?.id||e[17]!==C||e[18]!==s||e[19]!==g?(_=c(()=>{s(async()=>{let S=z.trim()===""?void 0:Lt(z);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:S,name:u.trim(),ownerId:C.trim()===""?void 0:C.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:S,name:u.trim()===""?void 0:u.trim(),organizationId:A(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),d()})},"O"),e[9]=o,e[10]=y,e[11]=z,e[12]=r,e[13]=u,e[14]=d,e[15]=h,e[16]=i?.id,e[17]=C,e[18]=s,e[19]=g,e[20]=_):_=e[20];let D=_,O;e[21]!==r||e[22]!==u?(O=u.trim()!==""||r==="edit",e[21]=r,e[22]=u,e[23]=O):O=e[23];let T;e[24]!==r||e[25]!==l?(T=l(r==="create"?"Create":"Save"),e[24]=r,e[25]=l,e[26]=T):T=e[26];let $;e[27]!==r||e[28]!==l?($=l(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=l,e[29]=$):$=e[29];let E;e[30]!==l?(E=l("name"),e[30]=l,e[31]=E):E=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=c(S=>{b(S.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,a.jsx)(V,{"data-testid":"org-form-name",id:"org-form-name",onChange:Z,value:u}),e[33]=u,e[34]=B):B=e[34];let K;e[35]!==B||e[36]!==E?(K=(0,a.jsx)(G,{htmlFor:"org-form-name",label:E,children:B}),e[35]=B,e[36]=E,e[37]=K):K=e[37];let J;e[38]!==l?(J=l("Slug (optional \u2014 derived from name)"),e[38]=l,e[39]=J):J=e[39];let P;e[40]===Symbol.for("react.memo_cache_sentinel")?(P=c(S=>{p(S.target.value)},"P"),e[40]=P):P=e[40];let U;e[41]!==g?(U=(0,a.jsx)(V,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:P,value:g}),e[41]=g,e[42]=U):U=e[42];let L;e[43]!==J||e[44]!==U?(L=(0,a.jsx)(G,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=L):L=e[45];let Y;e[46]!==l?(Y=l("Logo URL (optional)"),e[46]=l,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=c(S=>{I(S.target.value)},"M"),e[48]=M):M=e[48];let R;e[49]!==y?(R=(0,a.jsx)(V,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=R):R=e[50];let q;e[51]!==Y||e[52]!==R?(q=(0,a.jsx)(G,{htmlFor:"org-form-logo",label:Y,children:R}),e[51]=Y,e[52]=R,e[53]=q):q=e[53];let W;e[54]!==r||e[55]!==C||e[56]!==l?(W=r==="create"&&(0,a.jsx)(G,{htmlFor:"org-form-owner",label:l("Owner user id (optional)"),children:(0,a.jsx)(V,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:c(S=>{w(S.target.value)},"onChange"),value:C})}),e[54]=r,e[55]=C,e[56]=l,e[57]=W):W=e[57];let te;e[58]!==l?(te=l("Metadata (JSON, optional)"),e[58]=l,e[59]=te):te=e[59];let ae;e[60]===Symbol.for("react.memo_cache_sentinel")?(ae=c(S=>{N(S.target.value)},"oe"),e[60]=ae):ae=e[60];let re;e[61]!==z?(re=(0,a.jsx)(wt,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:ae,value:z}),e[61]=z,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,a.jsx)(G,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let le;return e[66]!==n||e[67]!==m||e[68]!==d||e[69]!==D||e[70]!==K||e[71]!==L||e[72]!==q||e[73]!==W||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==$?(le=(0,a.jsxs)(ce,{busy:n,canSubmit:O,error:m,onClose:d,onSubmit:D,submitLabel:T,testId:"org-form",title:$,children:[K,L,q,W,ee]}),e[66]=n,e[67]=m,e[68]=d,e[69]=D,e[70]=K,e[71]=L,e[72]=q,e[73]=W,e[74]=ee,e[75]=O,e[76]=T,e[77]=$,e[78]=le):le=e[78],le},"yt"),Qt=c(t=>{let e=(0,H.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),[u,b]=(0,F.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==h||e[4]!==u||e[5]!==m||e[6]!==s?(v=c(()=>{m(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),d(),r()})},"p"),e[0]=i,e[1]=r,e[2]=d,e[3]=h,e[4]=u,e[5]=m,e[6]=s,e[7]=v):v=e[7];let g=v,p;e[8]!==s?(p=s.trim(),e[8]=s,e[9]=p):p=e[9];let k=p!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let I;e[12]!==o?(I=o("Add member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("User id"),e[14]=o,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=c($=>{f($.target.value)},"I"),e[16]=w):w=e[16];let x;e[17]!==s?(x=(0,a.jsx)(V,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=x):x=e[18];let z;e[19]!==C||e[20]!==x?(z=(0,a.jsx)(G,{htmlFor:"org-add-member-user",label:C,children:x}),e[19]=C,e[20]=x,e[21]=z):z=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{b($.target.value)},"O"),e[24]=_):_=e[24];let D;e[25]!==u?(D=(0,a.jsx)(V,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=D):D=e[26];let O;e[27]!==N||e[28]!==D?(O=(0,a.jsx)(G,{htmlFor:"org-add-member-role",label:N,children:D}),e[27]=N,e[28]=D,e[29]=O):O=e[29];let T;return e[30]!==l||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==k||e[36]!==y||e[37]!==I||e[38]!==z?(T=(0,a.jsxs)(ce,{busy:l,canSubmit:k,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:I,children:[z,O]}),e[30]=l,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=k,e[36]=y,e[37]=I,e[38]=z,e[39]=T):T=e[39],T},"Jt"),Zt=c(t=>{let e=(0,H.c)(40),{onClose:r,onDone:d,organizationId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),[u,b]=(0,F.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==d||e[4]!==h||e[5]!==u||e[6]!==m?(v=c(()=>{m(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),d(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=d,e[4]=h,e[5]=u,e[6]=m,e[7]=v):v=e[7];let g=v,p;e[8]!==s?(p=s.trim(),e[8]=s,e[9]=p):p=e[9];let k=p!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let I;e[12]!==o?(I=o("Invite member"),e[12]=o,e[13]=I):I=e[13];let C;e[14]!==o?(C=o("email"),e[14]=o,e[15]=C):C=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=c($=>{f($.target.value)},"I"),e[16]=w):w=e[16];let x;e[17]!==s?(x=(0,a.jsx)(V,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=x):x=e[18];let z;e[19]!==C||e[20]!==x?(z=(0,a.jsx)(G,{htmlFor:"org-invite-member-email",label:C,children:x}),e[19]=C,e[20]=x,e[21]=z):z=e[21];let N;e[22]!==o?(N=o("Role (optional)"),e[22]=o,e[23]=N):N=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{b($.target.value)},"O"),e[24]=_):_=e[24];let D;e[25]!==u?(D=(0,a.jsx)(V,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=D):D=e[26];let O;e[27]!==N||e[28]!==D?(O=(0,a.jsx)(G,{htmlFor:"org-invite-member-role",label:N,children:D}),e[27]=N,e[28]=D,e[29]=O):O=e[29];let T;return e[30]!==l||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==k||e[36]!==y||e[37]!==I||e[38]!==z?(T=(0,a.jsxs)(ce,{busy:l,canSubmit:k,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:I,children:[z,O]}),e[30]=l,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=k,e[36]=y,e[37]=I,e[38]=z,e[39]=T):T=e[39],T},"Ut"),Yt=c(t=>{let e=(0,H.c)(32),{member:r,onClose:d,onDone:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),s;e[0]!==r.role?(s=c(()=>A(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[f,u]=(0,F.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==d||e[5]!==h||e[6]!==f||e[7]!==m?(b=c(()=>{m(async()=>{await i.setAuthOrgMemberRole({memberId:A(r.id),role:f.trim()}),h(),d()})},"g"),e[2]=i,e[3]=r.id,e[4]=d,e[5]=h,e[6]=f,e[7]=m,e[8]=b):b=e[8];let v=b,g;e[9]!==f?(g=f.trim(),e[9]=f,e[10]=g):g=e[10];let p=g!=="",k;e[11]!==o?(k=o("Save"),e[11]=o,e[12]=k):k=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let I;e[15]!==o?(I=o("Role"),e[15]=o,e[16]=I):I=e[16];let C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=c(N=>{u(N.target.value)},"y"),e[17]=C):C=e[17];let w;e[18]!==f?(w=(0,a.jsx)(V,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:C,value:f}),e[18]=f,e[19]=w):w=e[19];let x;e[20]!==I||e[21]!==w?(x=(0,a.jsx)(G,{htmlFor:"org-member-role-value",label:I,children:w}),e[20]=I,e[21]=w,e[22]=x):x=e[22];let z;return e[23]!==l||e[24]!==n||e[25]!==d||e[26]!==v||e[27]!==x||e[28]!==p||e[29]!==k||e[30]!==y?(z=(0,a.jsx)(ce,{busy:l,canSubmit:p,error:n,onClose:d,onSubmit:v,submitLabel:k,testId:"org-member-role",title:y,children:x}),e[23]=l,e[24]=n,e[25]=d,e[26]=v,e[27]=x,e[28]=p,e[29]=k,e[30]=y,e[31]=z):z=e[31],z},"Gt"),Mt=c(t=>{let e=(0,H.c)(36),{mode:r,onClose:d,onDone:h,organizationId:i,team:o}=t,l=oe(),n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==o?(u=o?A(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,F.useState)(u),g;e[2]!==l||e[3]!==r||e[4]!==b||e[5]!==d||e[6]!==h||e[7]!==i||e[8]!==f||e[9]!==o?.id?(g=c(()=>{f(async()=>{await(r==="create"?l.createAuthOrgTeam({name:b.trim(),organizationId:i}):l.updateAuthOrgTeam({name:b.trim(),teamId:A(o?.id)})),h(),d()})},"f"),e[2]=l,e[3]=r,e[4]=b,e[5]=d,e[6]=h,e[7]=i,e[8]=f,e[9]=o?.id,e[10]=g):g=e[10];let p=g,k;e[11]!==b?(k=b.trim(),e[11]=b,e[12]=k):k=e[12];let y=k!=="",I;e[13]!==r||e[14]!==n?(I=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=I):I=e[15];let C;e[16]!==r||e[17]!==n?(C=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=C):C=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let x;e[21]===Symbol.for("react.memo_cache_sentinel")?(x=c(D=>{v(D.target.value)},"x"),e[21]=x):x=e[21];let z;e[22]!==b?(z=(0,a.jsx)(V,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:x,value:b}),e[22]=b,e[23]=z):z=e[23];let N;e[24]!==w||e[25]!==z?(N=(0,a.jsx)(G,{htmlFor:"org-team-form-name",label:w,children:z}),e[24]=w,e[25]=z,e[26]=N):N=e[26];let _;return e[27]!==m||e[28]!==s||e[29]!==d||e[30]!==p||e[31]!==N||e[32]!==y||e[33]!==I||e[34]!==C?(_=(0,a.jsx)(ce,{busy:m,canSubmit:y,error:s,onClose:d,onSubmit:p,submitLabel:I,testId:"org-team-form",title:C,children:N}),e[27]=m,e[28]=s,e[29]=d,e[30]=p,e[31]=N,e[32]=y,e[33]=I,e[34]=C,e[35]=_):_=e[35],_},"Ct"),qt=c(t=>{let e=(0,H.c)(30),{onClose:r,onDone:d,teamId:h}=t,i=oe(),o=Q(),{busy:l,error:n,run:m}=se(),[s,f]=(0,F.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==d||e[3]!==m||e[4]!==h||e[5]!==s?(u=c(()=>{m(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),d(),r()})},"c"),e[0]=i,e[1]=r,e[2]=d,e[3]=m,e[4]=h,e[5]=s,e[6]=u):u=e[6];let b=u,v;e[7]!==s?(v=s.trim(),e[7]=s,e[8]=v):v=e[8];let g=v!=="",p;e[9]!==o?(p=o("Add member"),e[9]=o,e[10]=p):p=e[10];let k;e[11]!==o?(k=o("Add team member"),e[11]=o,e[12]=k):k=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let I;e[15]===Symbol.for("react.memo_cache_sentinel")?(I=c(z=>{f(z.target.value)},"C"),e[15]=I):I=e[15];let C;e[16]!==s?(C=(0,a.jsx)(V,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:I,value:s}),e[16]=s,e[17]=C):C=e[17];let w;e[18]!==y||e[19]!==C?(w=(0,a.jsx)(G,{htmlFor:"org-team-add-member-user",label:y,children:C}),e[18]=y,e[19]=C,e[20]=w):w=e[20];let x;return e[21]!==l||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==p||e[27]!==k||e[28]!==w?(x=(0,a.jsx)(ce,{busy:l,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:p,testId:"org-team-add-member",title:k,children:w}),e[21]=l,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=p,e[27]=k,e[28]=w,e[29]=x):x=e[29],x},"Ht"),Ft=c(t=>{let e=(0,H.c)(47),{mode:r,onClose:d,onDone:h,organizationId:i,role:o}=t,l=oe(),n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==o?(u=o?A(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,F.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Pt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[p,k]=(0,F.useState)(g),y;e[5]!==l||e[6]!==r||e[7]!==b||e[8]!==d||e[9]!==h||e[10]!==i||e[11]!==p||e[12]!==o?.id||e[13]!==f?(y=c(()=>{f(async()=>{let $=Kt(p);await(r==="create"?l.createAuthOrgRole({organizationId:i,permission:$,role:b.trim()}):l.updateAuthOrgRole({permission:$,roleId:A(o?.id)})),h(),d()})},"v"),e[5]=l,e[6]=r,e[7]=b,e[8]=d,e[9]=h,e[10]=i,e[11]=p,e[12]=o?.id,e[13]=f,e[14]=y):y=e[14];let I=y,C;e[15]!==r||e[16]!==b||e[17]!==p?(C=p.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=p,e[18]=C):C=e[18];let w;e[19]!==r||e[20]!==n?(w=n(r==="create"?"Create":"Save"),e[19]=r,e[20]=n,e[21]=w):w=e[21];let x;e[22]!==r||e[23]!==n?(x=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=x):x=e[24];let z;e[25]!==r||e[26]!==b||e[27]!==n?(z=r==="create"&&(0,a.jsx)(G,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,a.jsx)(V,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:c($=>{v($.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=z):z=e[28];let N;e[29]!==n?(N=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=N):N=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=c($=>{k($.target.value)},"O"),e[31]=_):_=e[31];let D;e[32]!==p?(D=(0,a.jsx)(wt,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:p}),e[32]=p,e[33]=D):D=e[33];let O;e[34]!==D||e[35]!==N?(O=(0,a.jsx)(G,{htmlFor:"org-role-form-permission",label:N,children:D}),e[34]=D,e[35]=N,e[36]=O):O=e[36];let T;return e[37]!==m||e[38]!==s||e[39]!==d||e[40]!==I||e[41]!==O||e[42]!==C||e[43]!==w||e[44]!==x||e[45]!==z?(T=(0,a.jsxs)(ce,{busy:m,canSubmit:C,error:s,onClose:d,onSubmit:I,submitLabel:w,testId:"org-role-form",title:x,children:[z,O]}),e[37]=m,e[38]=s,e[39]=d,e[40]=I,e[41]=O,e[42]=C,e[43]=w,e[44]=x,e[45]=z,e[46]=T):T=e[46],T},"xt"),Bt=c(t=>{let e=(0,H.c)(18),{action:r,message:d,onClose:h,onDone:i,testId:o,title:l}=t,n=Q(),{busy:m,error:s,run:f}=se(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==f?(u=c(()=>{f(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=f,e[4]=u):u=e[4];let b=u,v;e[5]!==n?(v=n("Delete"),e[5]=n,e[6]=v):v=e[6];let g;e[7]!==d?(g=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:d}),e[7]=d,e[8]=g):g=e[8];let p;return e[9]!==m||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==l?(p=(0,a.jsx)(ce,{busy:m,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:l,children:g}),e[9]=m,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=l,e[17]=p):p=e[17],p},"Mt"),Xe=c(t=>{let e=(0,H.c)(13),{action:r,children:d,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[0]=h,e[1]=o):o=e[1];let l;e[2]!==r?(l=r!==void 0&&(0,a.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=l):l=e[3];let n;e[4]!==o||e[5]!==l?(n=(0,a.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,l]}),e[4]=o,e[5]=l,e[6]=n):n=e[6];let m;e[7]!==d?(m=(0,a.jsx)(yt,{className:"px-0",children:d}),e[7]=d,e[8]=m):m=e[8];let s;return e[9]!==n||e[10]!==m||e[11]!==i?(s=(0,a.jsxs)(vt,{className:"overflow-hidden py-0","data-testid":i,children:[n,m]}),e[9]=n,e[10]=m,e[11]=i,e[12]=s):s=e[12],s},"We"),We=c(t=>{let e=(0,H.c)(23),{columns:r,rowActions:d,rowPrefix:h,rows:i}=t,o=Q(),l;e[0]!==r?(l=r.map(Gt),e[0]=r,e[1]=l):l=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==n?(m=(0,a.jsx)(me,{"aria-label":n}),e[4]=n,e[5]=m):m=e[5];let s;e[6]!==l||e[7]!==m?(s=(0,a.jsx)(It,{children:(0,a.jsxs)(Ve,{children:[l,m]})}),e[6]=l,e[7]=m,e[8]=s):s=e[8];let f;if(e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==d||e[16]!==h?(v=c((g,p)=>{let k=A(g.id),y=k===""?`index-${p.toString()}`:k;return(0,a.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(I=>(0,a.jsx)(de,{className:I.className,children:I.render(g)},I.head)),(0,a.jsx)(de,{children:(0,a.jsx)("div",{className:"flex justify-end gap-1",children:d(g)})})]},y)},"p"),e[14]=r,e[15]=d,e[16]=h,e[17]=v):v=e[17],f=i.map(v),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=f}else f=e[13];let u;e[18]!==f?(u=(0,a.jsx)(xt,{children:f}),e[18]=f,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,a.jsxs)(Ct,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"Xe");function Gt(t){return(0,a.jsx)(me,{children:t.head},t.head)}c(Gt,"Zt");var Vt=c(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:d,memberColumns:h,members:i,onDialog:o}=t,l=Q(),n;e[0]!==o?(n=c(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let m;e[2]!==l?(m=l("Add member"),e[2]=l,e[3]=m):m=e[3];let s;e[4]!==n||e[5]!==m?(s=(0,a.jsx)(j,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:m}),e[4]=n,e[5]=m,e[6]=s):s=e[6];let f;e[7]!==o?(f=c(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=f):f=e[8];let u;e[9]!==l?(u=l("Invite member"),e[9]=l,e[10]=u):u=e[10];let b;e[11]!==f||e[12]!==u?(b=(0,a.jsx)(j,{"data-testid":"org-open-invite-member",onClick:f,size:"xs",type:"button",variant:"outline",children:u}),e[11]=f,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,a.jsxs)(a.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==l?(g=l("Members"),e[17]=l,e[18]=g):g=e[18];let p;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==d||e[24]!==l?(p=i.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-members-empty",title:l("No members.")})}):(0,a.jsx)(We,{columns:h,rowActions:c(y=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"data-testid":`org-member-role-${A(y.id)}`,onClick:c(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Change role")}),(0,a.jsx)(j,{"data-testid":`org-remove-member-${A(y.id)}`,disabled:r,onClick:c(()=>{d(A(y.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:l("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=d,e[24]=l,e[25]=p):p=e[25];let k;return e[26]!==v||e[27]!==g||e[28]!==p?(k=(0,a.jsx)(Xe,{action:v,heading:g,testId:"org-members",children:p}),e[26]=v,e[27]=g,e[28]=p,e[29]=k):k=e[29],k},"qt"),Xt=c(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:d,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:l}=t,n=Q(),m;e[0]!==d?(m=c(()=>{d({kind:"team-create"})},"m"),e[0]=d,e[1]=m):m=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let f;e[4]!==m||e[5]!==s?(f=(0,a.jsx)(j,{"data-testid":"org-open-create-team",onClick:m,size:"xs",type:"button",variant:"outline",children:s}),e[4]=m,e[5]=s,e[6]=f):f=e[6];let u;e[7]!==n?(u=n("Teams"),e[7]=n,e[8]=u):u=e[8];let b;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==l?(b=l.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-teams-empty",title:n("No teams.")})}):(0,a.jsx)(We,{columns:o,rowActions:c(g=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"aria-pressed":i===A(g.id),"data-testid":`org-team-select-${A(g.id)}`,onClick:c(()=>{h(A(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,a.jsx)(j,{"data-testid":`org-team-rename-${A(g.id)}`,onClick:c(()=>{d({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,a.jsx)(j,{"data-testid":`org-team-delete-${A(g.id)}`,onClick:c(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:l}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=l,e[16]=b):b=e[16];let v;return e[17]!==f||e[18]!==u||e[19]!==b?(v=(0,a.jsx)(Xe,{action:f,heading:u,testId:"org-teams",children:b}),e[17]=f,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"Kt"),Wt=c(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:d,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:l}=t,n=Q(),m;e[0]!==h||e[1]!==i?(m=c(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=m):m=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let f;e[5]!==m||e[6]!==s?(f=(0,a.jsx)(j,{"data-testid":"org-open-add-team-member",onClick:m,size:"xs",type:"button",variant:"outline",children:s}),e[5]=m,e[6]=s,e[7]=f):f=e[7];let u;e[8]!==n?(u=n("Team members"),e[8]=n,e[9]=u):u=e[9];let b;e[10]!==r||e[11]!==d||e[12]!==n||e[13]!==o||e[14]!==l?(b=l.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,a.jsx)(We,{columns:o,rowActions:c(g=>(0,a.jsx)(j,{"data-testid":`org-team-remove-member-${A(g.id)}`,disabled:r,onClick:c(()=>{d(A(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:l}),e[10]=r,e[11]=d,e[12]=n,e[13]=o,e[14]=l,e[15]=b):b=e[15];let v;return e[16]!==f||e[17]!==u||e[18]!==b?(v=(0,a.jsx)(Xe,{action:f,heading:u,testId:"org-team-members",children:b}),e[16]=f,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"Vt"),er=c(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:d,roleColumns:h,roles:i}=t,o=Q(),l;e[0]!==d?(l=c(()=>{d({kind:"role-create"})},"i"),e[0]=d,e[1]=l):l=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let m;e[4]!==l||e[5]!==n?(m=(0,a.jsx)(j,{"data-testid":"org-open-create-role",onClick:l,size:"xs",type:"button",variant:"outline",children:n}),e[4]=l,e[5]=n,e[6]=m):m=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let f;e[9]!==r||e[10]!==d||e[11]!==h||e[12]!==i||e[13]!==o?(f=i.length===0?(0,a.jsx)("div",{className:"p-3",children:(0,a.jsx)(ue,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,a.jsx)(We,{columns:h,rowActions:c(b=>(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(j,{"data-testid":`org-role-edit-${A(b.id)}`,onClick:c(()=>{d({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,a.jsx)(j,{"data-testid":`org-role-delete-${A(b.id)}`,onClick:c(()=>{r(A(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=d,e[11]=h,e[12]=i,e[13]=o,e[14]=f):f=e[14];let u;return e[15]!==m||e[16]!==s||e[17]!==f?(u=(0,a.jsx)(Xe,{action:m,heading:s,testId:"org-roles",children:f}),e[15]=m,e[16]=s,e[17]=f,e[18]=u):u=e[18],u},"Wt"),Et=200,tr=c(t=>{let e=(0,H.c)(207),{organizationId:r,rolesEnabled:d,teamsEnabled:h}=t,i=oe(),o=Q(),[l,n]=(0,F.useState)(null),[m,s]=(0,F.useState)(null),[f,u]=(0,F.useState)(!1),[b,v]=(0,F.useState)(null),[g,p]=_t(r),k;e[0]!==g||e[1]!==r?(k=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=k):k=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=c(()=>i.listAuthOrgMembers({limit:Et,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let I=ge(k,y),C;e[7]!==r?(C=["lunora-auth-org-invitations",r],e[7]=r,e[8]=C):C=e[8];let w;e[9]!==i||e[10]!==r?(w=c(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let x=ge(C,w),z;e[12]!==r?(z=["lunora-auth-org-teams",r],e[12]=r,e[13]=z):z=e[13];let N;e[14]!==i||e[15]!==r?(N=c(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"D"),e[14]=i,e[15]=r,e[16]=N):N=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let D=ge(z,N,_),O;e[19]!==r?(O=["lunora-auth-org-roles",r],e[19]=r,e[20]=O):O=e[20];let T;e[21]!==i||e[22]!==r?(T=c(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let $;e[24]!==d?($={enabled:d},e[24]=d,e[25]=$):$=e[25];let E=ge(O,T,$),Z;e[26]!==m?(Z=["lunora-auth-org-team-members",m],e[26]=m,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==m?(B=c(()=>i.listAuthOrgTeamMembers({limit:200,teamId:m??""}),"B"),e[28]=i,e[29]=m,e[30]=B):B=e[30];let K=m!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let P=ge(Z,B,J),U;e[33]!==I.data?.rows?(U=I.data?.rows??[],e[33]=I.data?.rows,e[34]=U):U=e[34];let L=U,Y;e[35]!==x.data?.rows?(Y=x.data?.rows??[],e[35]=x.data?.rows,e[36]=Y):Y=e[36];let M=Y,R;e[37]!==D.data?.rows?(R=D.data?.rows??[],e[37]=D.data?.rows,e[38]=R):R=e[38];let q=R,W;e[39]!==E.data?.rows?(W=E.data?.rows??[],e[39]=E.data?.rows,e[40]=W):W=e[40];let te=W,ae;e[41]!==m||e[42]!==P?(ae=m===null?[]:P.data?.rows??[],e[41]=m,e[42]=P,e[43]=ae):ae=e[43];let re=ae,ee=I.error??x.error??D.error??E.error??P.error,le;e[44]!==x||e[45]!==I||e[46]!==d||e[47]!==E||e[48]!==m||e[49]!==P||e[50]!==h||e[51]!==D?(le=c(()=>{I.refetch(),x.refetch(),h&&D.refetch(),d&&E.refetch(),m!==null&&P.refetch()},"ie"),e[44]=x,e[45]=I,e[46]=d,e[47]=E,e[48]=m,e[49]=P,e[50]=h,e[51]=D,e[52]=le):le=e[52];let S=le;kt(S,!0);let et;e[53]===Symbol.for("react.memo_cache_sentinel")?(et=c(()=>{n(null)},"Ye"),e[53]=et):et=e[53];let ne=et,tt;e[54]!==S?(tt=c(X=>{At((async()=>{u(!0),v(null);try{await X(),S(),u(!1)}catch(mt){v(Nt(mt)),u(!1)}})())},"et"),e[54]=S,e[55]=tt):tt=e[55];let ie=tt,rt;e[56]!==i||e[57]!==o?(rt=c(X=>{let mt=A(X.id);n({action:c(async()=>{await i.removeAuthOrgTeam({teamId:mt}),s(St=>St===mt?null:St)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"tt"),e[56]=i,e[57]=o,e[58]=rt):rt=e[58];let dt=rt,he;e[59]!==o?(he=o("userId"),e[59]=o,e[60]=he):he=e[60];let be;e[61]!==he?(be={head:he,render:rr},e[61]=he,e[62]=be):be=e[62];let fe;e[63]!==o?(fe=o("role"),e[63]=o,e[64]=fe):fe=e[64];let pe;e[65]!==fe?(pe={head:fe,render:or},e[65]=fe,e[66]=pe):pe=e[66];let ot;e[67]!==be||e[68]!==pe?(ot=[be,pe],e[67]=be,e[68]=pe,e[69]=ot):ot=e[69];let ct=ot,ve;e[70]!==o?(ve=o("email"),e[70]=o,e[71]=ve):ve=e[71];let ye;e[72]!==ve?(ye={head:ve,render:ar},e[72]=ve,e[73]=ye):ye=e[73];let Ce;e[74]!==o?(Ce=o("role"),e[74]=o,e[75]=Ce):Ce=e[75];let Ie;e[76]!==Ce?(Ie={head:Ce,render:lr},e[76]=Ce,e[77]=Ie):Ie=e[77];let xe;e[78]!==o?(xe=o("status"),e[78]=o,e[79]=xe):xe=e[79];let we;e[80]!==xe?(we={head:xe,render:nr},e[80]=xe,e[81]=we):we=e[81];let at;e[82]!==ye||e[83]!==Ie||e[84]!==we?(at=[ye,Ie,we],e[82]=ye,e[83]=Ie,e[84]=we,e[85]=at):at=e[85];let ut=at,ke;e[86]!==o?(ke=o("id"),e[86]=o,e[87]=ke):ke=e[87];let ze;e[88]!==ke?(ze={className:"font-mono text-xs",head:ke,render:ir},e[88]=ke,e[89]=ze):ze=e[89];let Se;e[90]!==o?(Se=o("name"),e[90]=o,e[91]=Se):Se=e[91];let Ne;e[92]!==Se?(Ne={head:Se,render:sr},e[92]=Se,e[93]=Ne):Ne=e[93];let lt;e[94]!==ze||e[95]!==Ne?(lt=[ze,Ne],e[94]=ze,e[95]=Ne,e[96]=lt):lt=e[96];let gt=lt,Ae;e[97]!==o?(Ae=o("userId"),e[97]=o,e[98]=Ae):Ae=e[98];let nt;e[99]!==Ae?(nt=[{head:Ae,render:mr}],e[99]=Ae,e[100]=nt):nt=e[100];let ht=nt,De;e[101]!==o?(De=o("role"),e[101]=o,e[102]=De):De=e[102];let Oe;e[103]!==De?(Oe={head:De,render:dr},e[103]=De,e[104]=Oe):Oe=e[104];let _e;e[105]!==o?(_e=o("Permission"),e[105]=o,e[106]=_e):_e=e[106];let Te;e[107]!==_e?(Te={className:"font-mono text-xs whitespace-pre-wrap",head:_e,render:cr},e[107]=_e,e[108]=Te):Te=e[108];let it;e[109]!==Oe||e[110]!==Te?(it=[Oe,Te],e[109]=Oe,e[110]=Te,e[111]=it):it=e[111];let bt=it,$e;e[112]!==ee?($e=ee!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[112]=ee,e[113]=$e):$e=e[113];let Re;e[114]!==b?(Re=b!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[114]=b,e[115]=Re):Re=e[115];let Me;e[116]!==i||e[117]!==ie?(Me=c(X=>{ie(()=>i.removeAuthOrgMember({memberId:X}))},"$e"),e[116]=i,e[117]=ie,e[118]=Me):Me=e[118];let Fe;e[119]!==f||e[120]!==ct||e[121]!==L||e[122]!==Me?(Fe=(0,a.jsx)(Vt,{actionBusy:f,memberColumns:ct,members:L,onDialog:n,onRemoveMember:Me}),e[119]=f,e[120]=ct,e[121]=L,e[122]=Me,e[123]=Fe):Fe=e[123];let ft=I.data?.total,Ee;e[124]!==L.length||e[125]!==g||e[126]!==p||e[127]!==ft?(Ee=(0,a.jsx)(zt,{count:L.length,offset:g,onOffsetChange:p,pageSize:Et,prefix:"org-members",total:ft}),e[124]=L.length,e[125]=g,e[126]=p,e[127]=ft,e[128]=Ee):Ee=e[128];let je;e[129]!==f||e[130]!==i||e[131]!==ut||e[132]!==M||e[133]!==ie||e[134]!==o?(je=M.length>0&&(0,a.jsx)(Xe,{heading:o("Invitations"),testId:"org-invitations",children:(0,a.jsx)(We,{columns:ut,rowActions:c(X=>(0,a.jsx)(j,{"data-testid":`org-cancel-invitation-${A(X.id)}`,disabled:f,onClick:c(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:A(X.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[129]=f,e[130]=i,e[131]=ut,e[132]=M,e[133]=ie,e[134]=o,e[135]=je):je=e[135];let Le;e[136]!==dt||e[137]!==m||e[138]!==gt||e[139]!==q||e[140]!==h?(Le=h&&(0,a.jsx)(Xt,{onConfirmDeleteTeam:dt,onDialog:n,onSelectTeam:s,selectedTeam:m,teamColumns:gt,teams:q}),e[136]=dt,e[137]=m,e[138]=gt,e[139]=q,e[140]=h,e[141]=Le):Le=e[141];let Pe;e[142]!==f||e[143]!==i||e[144]!==ie||e[145]!==m||e[146]!==ht||e[147]!==re||e[148]!==h?(Pe=h&&m!==null&&(0,a.jsx)(Wt,{actionBusy:f,onDialog:n,onRemoveTeamMember:c(X=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:X}))},"onRemoveTeamMember"),selectedTeam:m,teamMemberColumns:ht,teamMembers:re}),e[142]=f,e[143]=i,e[144]=ie,e[145]=m,e[146]=ht,e[147]=re,e[148]=h,e[149]=Pe):Pe=e[149];let Be;e[150]!==i||e[151]!==bt||e[152]!==te||e[153]!==d||e[154]!==o?(Be=d&&(0,a.jsx)(er,{onConfirmDeleteRole:c(X=>{n({action:c(()=>i.deleteAuthOrgRole({roleId:X}),"action"),kind:"confirm",message:o("Delete this custom role? Members keeping it will lose its grants."),testId:"org-role-delete",title:o("Delete role")})},"onConfirmDeleteRole"),onDialog:n,roleColumns:bt,roles:te}),e[150]=i,e[151]=bt,e[152]=te,e[153]=d,e[154]=o,e[155]=Be):Be=e[155];let Je;e[156]!==l?.kind||e[157]!==r||e[158]!==S?(Je=l?.kind==="add-member"&&(0,a.jsx)(Qt,{onClose:ne,onDone:S,organizationId:r}),e[156]=l?.kind,e[157]=r,e[158]=S,e[159]=Je):Je=e[159];let Ue;e[160]!==l?.kind||e[161]!==r||e[162]!==S?(Ue=l?.kind==="invite-member"&&(0,a.jsx)(Zt,{onClose:ne,onDone:S,organizationId:r}),e[160]=l?.kind,e[161]=r,e[162]=S,e[163]=Ue):Ue=e[163];let He;e[164]!==l||e[165]!==S?(He=l?.kind==="member-role"&&(0,a.jsx)(Yt,{member:l.member,onClose:ne,onDone:S}),e[164]=l,e[165]=S,e[166]=He):He=e[166];let Ke;e[167]!==l?.kind||e[168]!==r||e[169]!==S?(Ke=l?.kind==="team-create"&&(0,a.jsx)(Mt,{mode:"create",onClose:ne,onDone:S,organizationId:r}),e[167]=l?.kind,e[168]=r,e[169]=S,e[170]=Ke):Ke=e[170];let Qe;e[171]!==l||e[172]!==r||e[173]!==S?(Qe=l?.kind==="team-rename"&&(0,a.jsx)(Mt,{mode:"edit",onClose:ne,onDone:S,organizationId:r,team:l.team}),e[171]=l,e[172]=r,e[173]=S,e[174]=Qe):Qe=e[174];let Ze;e[175]!==l||e[176]!==S?(Ze=l?.kind==="team-add-member"&&(0,a.jsx)(qt,{onClose:ne,onDone:S,teamId:l.teamId}),e[175]=l,e[176]=S,e[177]=Ze):Ze=e[177];let Ye;e[178]!==l?.kind||e[179]!==r||e[180]!==S?(Ye=l?.kind==="role-create"&&(0,a.jsx)(Ft,{mode:"create",onClose:ne,onDone:S,organizationId:r}),e[178]=l?.kind,e[179]=r,e[180]=S,e[181]=Ye):Ye=e[181];let qe;e[182]!==l||e[183]!==r||e[184]!==S?(qe=l?.kind==="role-edit"&&(0,a.jsx)(Ft,{mode:"edit",onClose:ne,onDone:S,organizationId:r,role:l.role}),e[182]=l,e[183]=r,e[184]=S,e[185]=qe):qe=e[185];let Ge;e[186]!==l||e[187]!==S?(Ge=l?.kind==="confirm"&&(0,a.jsx)(Bt,{action:l.action,message:l.message,onClose:ne,onDone:S,testId:l.testId,title:l.title}),e[186]=l,e[187]=S,e[188]=Ge):Ge=e[188];let st;return e[189]!==$e||e[190]!==Re||e[191]!==Fe||e[192]!==Ee||e[193]!==je||e[194]!==Le||e[195]!==Pe||e[196]!==Be||e[197]!==Je||e[198]!==Ue||e[199]!==He||e[200]!==Ke||e[201]!==Qe||e[202]!==Ze||e[203]!==Ye||e[204]!==qe||e[205]!==Ge?(st=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[$e,Re,Fe,Ee,je,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge]}),e[189]=$e,e[190]=Re,e[191]=Fe,e[192]=Ee,e[193]=je,e[194]=Le,e[195]=Pe,e[196]=Be,e[197]=Je,e[198]=Ue,e[199]=He,e[200]=Ke,e[201]=Qe,e[202]=Ze,e[203]=Ye,e[204]=qe,e[205]=Ge,e[206]=st):st=e[206],st},"Xt");function rr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:A(t.userId)})}c(rr,"Yt");function or(t){return A(t.role)}c(or,"el");function ar(t){return A(t.email)}c(ar,"tl");function lr(t){return A(t.role)}c(lr,"ll");function nr(t){return A(t.status)}c(nr,"ol");function ir(t){return A(t.id)}c(ir,"il");function sr(t){return A(t.name)}c(sr,"rl");function mr(t){return(0,a.jsx)("span",{className:"font-mono text-xs",children:A(t.userId)})}c(mr,"nl");function dr(t){return A(t.role)}c(dr,"sl");function cr(t){return A(t.permission)}c(cr,"al");var jt=100,Ar=c(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:d,ready:h}=Tt(),i=d.capabilities.organization,[o,l]=(0,F.useState)(null),[n,m]=(0,F.useState)(null),[s,f]=(0,F.useState)(0),u;t[0]!==s?(u=["lunora-auth-orgs",s],t[0]=s,t[1]=u):u=t[1];let b;t[2]!==e||t[3]!==s?(b=c(()=>e.listAuthOrganizations({limit:jt,offset:s}),"g"),t[2]=e,t[3]=s,t[4]=b):b=t[4];let v;t[5]!==i?(v={enabled:i},t[5]=i,t[6]=v):v=t[6];let g=ge(u,b,v),p=g.data?.rows??null,k;t[7]!==g?(k=c(()=>{g.refetch()},"S"),t[7]=g,t[8]=k):k=t[8],kt(k,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=c(()=>{m(null)},"v"),t[9]=y):y=t[9];let I=y,C;t[10]!==g?(C=c(()=>{g.refetch()},"y"),t[10]=g,t[11]=C):C=t[11];let w=C,x;t[12]===Symbol.for("react.memo_cache_sentinel")?(x=c(M=>{l(M)},"x"),t[12]=x):x=t[12];let z=x;if(h&&!i){let M;t[13]!==r?(M=r("Enable the organization() plugin in your auth config to manage organizations here."),t[13]=r,t[14]=M):M=t[14];let R;t[15]!==r?(R=r("Organizations are not enabled."),t[15]=r,t[16]=R):R=t[16];let q;return t[17]!==M||t[18]!==R?(q=(0,a.jsx)(ue,{description:M,testId:"org-disabled",title:R}),t[17]=M,t[18]=R,t[19]=q):q=t[19],q}let N;t[20]!==r?(N=r("Organizations"),t[20]=r,t[21]=N):N=t[21];let _;t[22]!==N?(_=(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),t[22]=N,t[23]=_):_=t[23];let D;t[24]===Symbol.for("react.memo_cache_sentinel")?(D=c(()=>{m({kind:"create"})},"A"),t[24]=D):D=t[24];let O;t[25]!==r?(O=r("New organization"),t[25]=r,t[26]=O):O=t[26];let T;t[27]!==O?(T=(0,a.jsx)(j,{"data-testid":"org-new",onClick:D,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let $;t[29]!==T||t[30]!==_?($=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=$):$=t[31];let E;t[32]!==g.error?(E=g.error!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=E):E=t[33];let Z;t[34]!==p||t[35]!==r?(Z=p!==null&&p.length===0&&(0,a.jsx)(ue,{testId:"org-empty",title:r("No organizations.")}),t[34]=p,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==p||t[38]!==o||t[39]!==r?(B=p!==null&&p.length>0&&(0,a.jsx)(vt,{className:"overflow-hidden py-0",children:(0,a.jsx)(yt,{className:"px-0",children:(0,a.jsxs)(Ct,{"data-testid":"org-table",children:[(0,a.jsx)(It,{children:(0,a.jsxs)(Ve,{children:[(0,a.jsx)(me,{children:r("id")}),(0,a.jsx)(me,{children:r("name")}),(0,a.jsx)(me,{children:r("slug")}),(0,a.jsx)(me,{children:r("created")}),(0,a.jsx)(me,{"aria-label":r("Actions")})]})}),(0,a.jsx)(xt,{children:p.map(M=>{let R=A(M.id);return(0,a.jsxs)(Ve,{"data-testid":`org-row-${R}`,children:[(0,a.jsx)(de,{className:"font-mono text-xs",children:R}),(0,a.jsx)(de,{children:A(M.name)}),(0,a.jsx)(de,{children:A(M.slug)}),(0,a.jsx)(de,{className:"text-muted-foreground tabular-nums",children:Dt(M.createdAt)}),(0,a.jsx)(de,{children:(0,a.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,a.jsx)(j,{"aria-pressed":o===R,"data-testid":`org-select-${R}`,onClick:c(()=>{z(R)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,a.jsx)(j,{"data-testid":`org-edit-${R}`,onClick:c(()=>{m({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,a.jsx)(j,{"data-testid":`org-delete-${R}`,onClick:c(()=>{m({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},R)})})]})})}),t[37]=p,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==p||t[43]!==g.data?.total?(K=p!==null&&(0,a.jsx)(zt,{count:p.length,offset:s,onOffsetChange:f,pageSize:jt,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=p,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==d.organization||t[46]!==o?(J=o!==null&&(0,a.jsx)(tr,{organizationId:o,rolesEnabled:d.organization.roles,teamsEnabled:d.organization.teams}),t[45]=d.organization,t[46]=o,t[47]=J):J=t[47];let P;t[48]!==n?.kind||t[49]!==w?(P=n?.kind==="create"&&(0,a.jsx)(Rt,{mode:"create",onClose:I,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=P):P=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,a.jsx)(Rt,{mode:"edit",onClose:I,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let L;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(L=n?.kind==="delete"&&(0,a.jsx)(Bt,{action:c(async()=>{let M=A(n.org.id);await e.deleteAuthOrganization({organizationId:M}),l(R=>R===M?null:R)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:I,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=L):L=t[58];let Y;return t[59]!==$||t[60]!==E||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==P||t[66]!==U||t[67]!==L?(Y=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[$,E,Z,B,K,J,P,U,L]}),t[59]=$,t[60]=E,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=P,t[66]=U,t[67]=L,t[68]=Y):Y=t[68],Y},"Al");export{Ar as default};
@@ -1 +1 @@
1
- import{a as Be,b as Ue,c as We,d as De,e as we}from"./chunk-5QR2SQIS.js";import"./chunk-NRP22GKC.js";import"./chunk-OPM7ESDV.js";import{a as Ve}from"./chunk-OSGXNEFA.js";import{a as qe}from"./chunk-SV764LKQ.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Le}from"./chunk-R6U22RSY.js";import{a as _e}from"./chunk-YVR4SEPU.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as ke}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as ie}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as me}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{c as Ee}from"./chunk-6RXWGRH7.js";import{g as Ne}from"./chunk-KU6ZTYP4.js";import"./chunk-QAQDMS6R.js";import{b as Ie,c as $e}from"./chunk-54JZD74E.js";import{a as Ae}from"./chunk-RWVIV3U7.js";import{a as ze,b as Re,c as je,d as pe,e as B,f as z}from"./chunk-HCTJKP5J.js";import{a as Me,e as Ce}from"./chunk-2IKDEUCX.js";import{d as ue,f as re,g as be,h as Ke,p as le,t as Te}from"./chunk-HJHSQPHW.js";import{a as d,d as ye,e as Oe,f as Ge,g as He}from"./chunk-I26MS5PJ.js";var ge=ye(Ge(),1);var ne=ye(Oe(),1);var t=ye(He(),1);var Se="none",Je=["all","open","resolved","ignored"],Pe=["critical","high","medium","low"],Qe=re(U.resolveIssue),Xe=re(U.ignoreIssue),Fe=re(U.assignIssue),Ye=re(U.setIssueSeverity),Ze=re(U.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Je"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=Ne(),l=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:A,run:R}=Ve(),K;e[0]!==i||e[1]!==s||e[2]!==R||e[3]!==$?(K=d(()=>{o(void 0),R(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,g,be($));o(I)})},"C"),e[0]=i,e[1]=s,e[2]=R,e[3]=$,e[4]=K):K=e[4];let L=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Ie(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let T=k,E=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==l?(x=l("Suggested fix"),e[9]=l,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==T||e[14]!==s.hash||e[15]!==l?(v=T===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let b=`issues-explain-${s.hash}`,w;e[20]!==_||e[21]!==l?(w=l(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=l,e[22]=w):w=e[22];let m;e[23]!==_||e[24]!==L||e[25]!==w||e[26]!==b?(m=(0,t.jsx)("div",{children:(0,t.jsx)(ie,{"data-testid":b,disabled:_,onClick:L,size:"sm",type:"button",variant:"outline",children:w})}),e[23]=_,e[24]=L,e[25]=w,e[26]=b,e[27]=m):m=e[27];let f;e[28]!==A||e[29]!==s.hash?(f=A!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:A}),e[28]=A,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==l?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(z,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let S;return e[41]!==c||e[42]!==E?(S=(0,t.jsx)(pe,{"data-testid":E,children:c}),e[41]=c,e[42]=E,e[43]=S):S=e[43],S},"et"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:l}=n,a=ue(),[o,_]=(0,ne.useState)(!1),A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=d(()=>{_(rs)},"A"),e[0]=A):A=e[0];let R=A,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Se?null:ae;le(i(s.hash,Ye,{severity:ce}))},"C"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let L=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();le(i(s.hash,Fe,{assignee:ce===""?null:ce}))},"T"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let T=k,E=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let b;e[12]!==s.title?(b=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=b):b=e[13];let w;e[14]!==s.culprit?(w=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=w):w=e[15];let m;e[16]!==b||e[17]!==w?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[b,w]}),e[16]=b,e[17]=w,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:R,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(z,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let S=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==g?(I=(0,t.jsx)(z,{children:(0,t.jsx)(me,{"data-testid":S,variant:g,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=g,e[36]=I):I=e[36];let j=s.severity??Se,r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];let oe=`issues-severity-${s.hash}`,V;e[39]!==a?(V=a("\u2014"),e[39]=a,e[40]=V):V=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let C;e[44]!==V||e[45]!==N?(C=(0,t.jsx)(Ue,{placeholder:V,children:N}),e[44]=V,e[45]=N,e[46]=C):C=e[46];let q;e[47]!==r||e[48]!==oe||e[49]!==C?(q=(0,t.jsx)(We,{"aria-label":r,className:"h-7 w-[110px]","data-testid":oe,children:C}),e[47]=r,e[48]=oe,e[49]=C,e[50]=q):q=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Pe.map(ls),e[51]=de):de=e[51];let W;e[52]!==a?(W=a("Clear"),e[52]=a,e[53]=W):W=e[53];let D;e[54]!==W?(D=(0,t.jsxs)(De,{children:[de,(0,t.jsx)(we,{value:Se,children:W})]}),e[54]=W,e[55]=D):D=e[55];let F;e[56]!==u||e[57]!==L||e[58]!==j||e[59]!==q||e[60]!==D?(F=(0,t.jsx)(z,{children:(0,t.jsxs)(Be,{disabled:u,onValueChange:L,value:j,children:[q,D]})}),e[56]=u,e[57]=L,e[58]=j,e[59]=q,e[60]=D,e[61]=F):F=e[61];let O;e[62]!==a?(O=a("Assignee"),e[62]=a,e[63]=O):O=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==T||e[68]!==O||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(z,{children:(0,t.jsx)(ke,{"aria-label":O,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:T,placeholder:G},ve)}),e[66]=u,e[67]=T,e[68]=O,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let P;e[76]!==s.lastSeen?(P=Te(s.lastSeen),e[76]=s.lastSeen,e[77]=P):P=e[77];let Q;e[78]!==P?(Q=(0,t.jsx)(z,{className:"text-xs tabular-nums text-muted-foreground",children:P}),e[78]=P,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(ie,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(ie,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(ie,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Fe,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==I||e[105]!==F||e[106]!==H||e[107]!==J||e[108]!==Q||e[109]!==E||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":E,children:[c,I,F,H,J,Q,ee]}),e[103]=c,e[104]=I,e[105]=F,e[106]=H,e[107]=J,e[108]=Q,e[109]=E,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==l?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"tt"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=Ne(),{queryShardKey:i,setShardKey:l,shardKey:a}=Le(u),[o,_]=(0,ne.useState)("all"),[A,R]=(0,ne.useState)(ns),[K,L]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];let{data:E,error:h,liveError:x}=Ee(U.getIssues,k,T),M=E!==void 0,v;if(e[4]!==K||e[5]!==A||e[6]!==$||e[7]!==E||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(E),b;e[17]!==$||e[18]!==i?(b=d(async(r,oe,V)=>{L(N=>{if(!N.has(r))return N;let C=new Map(N);return C.delete(r),C}),R(N=>new Set(N).add(r));try{await $.query(oe,{...V,hash:r},be(i))}catch(N){let C=Ke(N);L(q=>new Map(q).set(r,C))}R(N=>{let C=new Set(N);return C.delete(r),C})},"S"),e[17]=$,e[18]=i,e[19]=b):b=e[19];let w=b,m;e[20]!==s?(m=d(r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==l||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=c):c=e[26];let S;e[27]!==x?(S=(0,t.jsx)(qe,{message:x,prefix:"issues"}),e[27]=x,e[28]=S):S=e[28];let g;e[29]!==o||e[30]!==f?(g=Je.map(r=>(0,t.jsx)(ie,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:d(()=>{_(r)},"onClick"),size:"xs",variant:o===r?"default":"outline",children:f(r)},r)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let I;e[32]!==g?(I=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=I):I=e[33];let j;e[34]!==I||e[35]!==c||e[36]!==S?(j=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,S,I]}),e[34]=I,e[35]=c,e[36]=S,e[37]=j):j=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,j,M&&y.length===0?(0,t.jsx)(Ae,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"issues-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(B,{children:s("Issue")}),(0,t.jsx)(B,{children:s("Status")}),(0,t.jsx)(B,{children:s("Severity")}),(0,t.jsx)(B,{children:s("Assignee")}),(0,t.jsx)(B,{className:"text-right",children:s("Events")}),(0,t.jsx)(B,{children:s("Last seen")}),(0,t.jsx)(B,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(je,{children:y.map(r=>(0,t.jsx)(is,{busy:A.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:w,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=A,e[6]=$,e[7]=E,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"Tt");function rs(n){return!n}d(rs,"st");function ls(n){return(0,t.jsx)(we,{value:n,children:n},n)}d(ls,"at");function ns(){return new Set}d(ns,"it");function os(){return new Map}d(os,"lt");export{ks as default};
1
+ import{a as Be,b as Ue,c as We,d as De,e as we}from"./chunk-5QR2SQIS.js";import"./chunk-NRP22GKC.js";import"./chunk-OPM7ESDV.js";import{a as Ve}from"./chunk-OSGXNEFA.js";import{a as qe}from"./chunk-SV764LKQ.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Le}from"./chunk-R6U22RSY.js";import{a as _e}from"./chunk-YVR4SEPU.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as ke}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as ie}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as me}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{c as Ee}from"./chunk-J6H3YTFH.js";import{g as Ne}from"./chunk-DGJMFHBV.js";import"./chunk-QAQDMS6R.js";import{b as Ie,c as $e}from"./chunk-VEK3S7MV.js";import{a as Ae}from"./chunk-RWVIV3U7.js";import{a as ze,b as Re,c as je,d as pe,e as B,f as z}from"./chunk-HCTJKP5J.js";import{a as Me,e as Ce}from"./chunk-2IKDEUCX.js";import{d as ue,f as re,g as be,h as Ke,p as le,t as Te}from"./chunk-HJHSQPHW.js";import{a as d,d as ye,e as Oe,f as Ge,g as He}from"./chunk-I26MS5PJ.js";var ge=ye(Ge(),1);var ne=ye(Oe(),1);var t=ye(He(),1);var Se="none",Je=["all","open","resolved","ignored"],Pe=["critical","high","medium","low"],Qe=re(U.resolveIssue),Xe=re(U.ignoreIssue),Fe=re(U.assignIssue),Ye=re(U.setIssueSeverity),Ze=re(U.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Je"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=Ne(),l=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:A,run:R}=Ve(),K;e[0]!==i||e[1]!==s||e[2]!==R||e[3]!==$?(K=d(()=>{o(void 0),R(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,g,be($));o(I)})},"C"),e[0]=i,e[1]=s,e[2]=R,e[3]=$,e[4]=K):K=e[4];let L=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Ie(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let T=k,E=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==l?(x=l("Suggested fix"),e[9]=l,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==T||e[14]!==s.hash||e[15]!==l?(v=T===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let b=`issues-explain-${s.hash}`,w;e[20]!==_||e[21]!==l?(w=l(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=l,e[22]=w):w=e[22];let m;e[23]!==_||e[24]!==L||e[25]!==w||e[26]!==b?(m=(0,t.jsx)("div",{children:(0,t.jsx)(ie,{"data-testid":b,disabled:_,onClick:L,size:"sm",type:"button",variant:"outline",children:w})}),e[23]=_,e[24]=L,e[25]=w,e[26]=b,e[27]=m):m=e[27];let f;e[28]!==A||e[29]!==s.hash?(f=A!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:A}),e[28]=A,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==l?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(z,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let S;return e[41]!==c||e[42]!==E?(S=(0,t.jsx)(pe,{"data-testid":E,children:c}),e[41]=c,e[42]=E,e[43]=S):S=e[43],S},"et"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:l}=n,a=ue(),[o,_]=(0,ne.useState)(!1),A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=d(()=>{_(rs)},"A"),e[0]=A):A=e[0];let R=A,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Se?null:ae;le(i(s.hash,Ye,{severity:ce}))},"C"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let L=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();le(i(s.hash,Fe,{assignee:ce===""?null:ce}))},"T"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let T=k,E=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let b;e[12]!==s.title?(b=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=b):b=e[13];let w;e[14]!==s.culprit?(w=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=w):w=e[15];let m;e[16]!==b||e[17]!==w?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[b,w]}),e[16]=b,e[17]=w,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:R,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(z,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let S=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==g?(I=(0,t.jsx)(z,{children:(0,t.jsx)(me,{"data-testid":S,variant:g,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=g,e[36]=I):I=e[36];let j=s.severity??Se,r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];let oe=`issues-severity-${s.hash}`,V;e[39]!==a?(V=a("\u2014"),e[39]=a,e[40]=V):V=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let C;e[44]!==V||e[45]!==N?(C=(0,t.jsx)(Ue,{placeholder:V,children:N}),e[44]=V,e[45]=N,e[46]=C):C=e[46];let q;e[47]!==r||e[48]!==oe||e[49]!==C?(q=(0,t.jsx)(We,{"aria-label":r,className:"h-7 w-[110px]","data-testid":oe,children:C}),e[47]=r,e[48]=oe,e[49]=C,e[50]=q):q=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Pe.map(ls),e[51]=de):de=e[51];let W;e[52]!==a?(W=a("Clear"),e[52]=a,e[53]=W):W=e[53];let D;e[54]!==W?(D=(0,t.jsxs)(De,{children:[de,(0,t.jsx)(we,{value:Se,children:W})]}),e[54]=W,e[55]=D):D=e[55];let F;e[56]!==u||e[57]!==L||e[58]!==j||e[59]!==q||e[60]!==D?(F=(0,t.jsx)(z,{children:(0,t.jsxs)(Be,{disabled:u,onValueChange:L,value:j,children:[q,D]})}),e[56]=u,e[57]=L,e[58]=j,e[59]=q,e[60]=D,e[61]=F):F=e[61];let O;e[62]!==a?(O=a("Assignee"),e[62]=a,e[63]=O):O=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==T||e[68]!==O||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(z,{children:(0,t.jsx)(ke,{"aria-label":O,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:T,placeholder:G},ve)}),e[66]=u,e[67]=T,e[68]=O,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let P;e[76]!==s.lastSeen?(P=Te(s.lastSeen),e[76]=s.lastSeen,e[77]=P):P=e[77];let Q;e[78]!==P?(Q=(0,t.jsx)(z,{className:"text-xs tabular-nums text-muted-foreground",children:P}),e[78]=P,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(ie,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(ie,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(ie,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Fe,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==I||e[105]!==F||e[106]!==H||e[107]!==J||e[108]!==Q||e[109]!==E||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":E,children:[c,I,F,H,J,Q,ee]}),e[103]=c,e[104]=I,e[105]=F,e[106]=H,e[107]=J,e[108]=Q,e[109]=E,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==l?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"tt"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=Ne(),{queryShardKey:i,setShardKey:l,shardKey:a}=Le(u),[o,_]=(0,ne.useState)("all"),[A,R]=(0,ne.useState)(ns),[K,L]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];let{data:E,error:h,liveError:x}=Ee(U.getIssues,k,T),M=E!==void 0,v;if(e[4]!==K||e[5]!==A||e[6]!==$||e[7]!==E||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(E),b;e[17]!==$||e[18]!==i?(b=d(async(r,oe,V)=>{L(N=>{if(!N.has(r))return N;let C=new Map(N);return C.delete(r),C}),R(N=>new Set(N).add(r));try{await $.query(oe,{...V,hash:r},be(i))}catch(N){let C=Ke(N);L(q=>new Map(q).set(r,C))}R(N=>{let C=new Set(N);return C.delete(r),C})},"S"),e[17]=$,e[18]=i,e[19]=b):b=e[19];let w=b,m;e[20]!==s?(m=d(r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==l||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=c):c=e[26];let S;e[27]!==x?(S=(0,t.jsx)(qe,{message:x,prefix:"issues"}),e[27]=x,e[28]=S):S=e[28];let g;e[29]!==o||e[30]!==f?(g=Je.map(r=>(0,t.jsx)(ie,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:d(()=>{_(r)},"onClick"),size:"xs",variant:o===r?"default":"outline",children:f(r)},r)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let I;e[32]!==g?(I=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=I):I=e[33];let j;e[34]!==I||e[35]!==c||e[36]!==S?(j=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,S,I]}),e[34]=I,e[35]=c,e[36]=S,e[37]=j):j=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,j,M&&y.length===0?(0,t.jsx)(Ae,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"issues-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(B,{children:s("Issue")}),(0,t.jsx)(B,{children:s("Status")}),(0,t.jsx)(B,{children:s("Severity")}),(0,t.jsx)(B,{children:s("Assignee")}),(0,t.jsx)(B,{className:"text-right",children:s("Events")}),(0,t.jsx)(B,{children:s("Last seen")}),(0,t.jsx)(B,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(je,{children:y.map(r=>(0,t.jsx)(is,{busy:A.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:w,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=A,e[6]=$,e[7]=E,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"Tt");function rs(n){return!n}d(rs,"st");function ls(n){return(0,t.jsx)(we,{value:n,children:n},n)}d(ls,"at");function ns(){return new Set}d(ns,"it");function os(){return new Map}d(os,"lt");export{ks as default};
@@ -1 +1 @@
1
- import{b as j,c as v,d as D,g}from"./chunk-KU6ZTYP4.js";import{f as S,g as w,h as P,p as q}from"./chunk-HJHSQPHW.js";import{a as i,d as A,e as x,f as M}from"./chunk-I26MS5PJ.js";var E=A(M(),1);var p=A(x(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"a"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"c"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,_=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"j"),O=i((t,r)=>[...t,r],"E");function W(t,r,e={}){let s=g(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=O(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{q(o.refetch())},"refetch")}}i(W,"F");function Y(t,r,e={}){let s=g(),n=v(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=_(t,r,o),C=W(m,()=>s.query(S(t),r,w(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),L=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),Q=s.subscribe(S(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(O(m,s.clientIdentifier()),h)},{...w(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),Q()}},[s,L,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=v(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:_(s,n,a??"");q(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
1
+ import{b as j,c as v,d as D,g}from"./chunk-DGJMFHBV.js";import{f as S,g as w,h as P,p as q}from"./chunk-HJHSQPHW.js";import{a as i,d as A,e as x,f as M}from"./chunk-I26MS5PJ.js";var E=A(M(),1);var p=A(x(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"a"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"c"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,_=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"j"),O=i((t,r)=>[...t,r],"E");function W(t,r,e={}){let s=g(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=O(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{q(o.refetch())},"refetch")}}i(W,"F");function Y(t,r,e={}){let s=g(),n=v(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=_(t,r,o),C=W(m,()=>s.query(S(t),r,w(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),L=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),Q=s.subscribe(S(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(O(m,s.clientIdentifier()),h)},{...w(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),Q()}},[s,L,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=v(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:_(s,n,a??"");q(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};