@lunora/studio 1.0.0-alpha.336 → 1.0.0-alpha.338

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 (82) hide show
  1. package/dist/index.d.mts +4 -2
  2. package/dist/index.d.ts +4 -2
  3. package/dist/index.mjs +1 -1
  4. package/dist/packem_chunks/ApiTab.mjs +1 -1
  5. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  6. package/dist/packem_chunks/SqlEditorPanel.mjs +8 -8
  7. package/dist/packem_chunks/migrations-route.mjs +1 -1
  8. package/dist/packem_shared/OpenRpcReferencePanel-nYyfjjse.mjs +1 -0
  9. package/dist/packem_shared/schema-diagram-ghsOCED7.mjs +2 -0
  10. package/dist/standalone/{chunk-VQH2F33R.js → chunk-2JD6VLW7.js} +1 -1
  11. package/dist/standalone/{chunk-6K7ZB6M6.js → chunk-2OOWQRI5.js} +1 -1
  12. package/dist/standalone/{chunk-3EFAEGID.js → chunk-3DNOCE5K.js} +1 -1
  13. package/dist/standalone/{chunk-7XBIOLIW.js → chunk-3FRBAQI7.js} +1 -1
  14. package/dist/standalone/chunk-3JVXNEBO.js +7 -0
  15. package/dist/standalone/{chunk-KT4UNIZB.js → chunk-4KMJQGIN.js} +1 -1
  16. package/dist/standalone/{chunk-EA2RNGEE.js → chunk-4ZISAQ2B.js} +1 -1
  17. package/dist/standalone/{chunk-JNW2ARJO.js → chunk-5B4SQYIP.js} +1 -1
  18. package/dist/standalone/{chunk-AWGYECJN.js → chunk-5NCDYUAL.js} +1 -1
  19. package/dist/standalone/chunk-6LNSHLOB.js +15 -0
  20. package/dist/standalone/{chunk-IIIYLX6U.js → chunk-7LPVTOAF.js} +1 -1
  21. package/dist/standalone/{chunk-TKMI2XAK.js → chunk-7VF6QXGR.js} +1 -1
  22. package/dist/standalone/{chunk-3APWNQJ3.js → chunk-7WWDCRLQ.js} +1 -1
  23. package/dist/standalone/{chunk-SL7YMFRX.js → chunk-AHQIBM3C.js} +1 -1
  24. package/dist/standalone/{chunk-NRAAYZ4C.js → chunk-BAWEGZ7T.js} +3 -3
  25. package/dist/standalone/{chunk-EOCVVABQ.js → chunk-BCGCD4CO.js} +1 -1
  26. package/dist/standalone/{chunk-2OSBOZSF.js → chunk-CG7AWLQB.js} +1 -1
  27. package/dist/standalone/{chunk-35LRTD6L.js → chunk-CHYVUB6Y.js} +1 -1
  28. package/dist/standalone/{chunk-ZFW3QEVE.js → chunk-CMVOO3MU.js} +1 -1
  29. package/dist/standalone/{chunk-HFR5DYKT.js → chunk-DW67E5WI.js} +1 -1
  30. package/dist/standalone/{chunk-T4Y5DPRN.js → chunk-DXC6YGNT.js} +1 -1
  31. package/dist/standalone/{chunk-FKS6EUNJ.js → chunk-EFT6JH6H.js} +1 -1
  32. package/dist/standalone/{chunk-T6J6Q5Q2.js → chunk-EJ7YAEPM.js} +1 -1
  33. package/dist/standalone/{chunk-FYW6TV4Q.js → chunk-G2YF7RNG.js} +1 -1
  34. package/dist/standalone/{chunk-CS7K5PAU.js → chunk-G5DO7HSE.js} +1 -1
  35. package/dist/standalone/{chunk-HD2IF5L4.js → chunk-GABRCO5N.js} +1 -1
  36. package/dist/standalone/{chunk-R36PEHB2.js → chunk-GDD7FNZA.js} +1 -1
  37. package/dist/standalone/{chunk-SHCUZSRI.js → chunk-GNX7VKQY.js} +1 -1
  38. package/dist/standalone/{chunk-KVEG7CIS.js → chunk-H4BEW5RF.js} +1 -1
  39. package/dist/standalone/{chunk-Z643LPA5.js → chunk-H6MI6GGH.js} +1 -1
  40. package/dist/standalone/{chunk-3VI2EZN2.js → chunk-HC6E6BIJ.js} +1 -1
  41. package/dist/standalone/{chunk-VOLGQ2EF.js → chunk-JIWDKEGI.js} +1 -1
  42. package/dist/standalone/chunk-KRSOII6O.js +1 -0
  43. package/dist/standalone/{chunk-BOUF5HG7.js → chunk-LQM7KUEA.js} +1 -1
  44. package/dist/standalone/{chunk-AX2GEOKC.js → chunk-LVNRJL4S.js} +1 -1
  45. package/dist/standalone/{chunk-5AXRIRHW.js → chunk-LXQGF74P.js} +1 -1
  46. package/dist/standalone/{chunk-XC2LTW44.js → chunk-M27YVZWM.js} +1 -1
  47. package/dist/standalone/{chunk-JT3XCMAO.js → chunk-MFUYHLXW.js} +1 -1
  48. package/dist/standalone/{chunk-MC44447W.js → chunk-NQZ5IJWF.js} +1 -1
  49. package/dist/standalone/{chunk-YSPQIRER.js → chunk-NWWMHMGA.js} +1 -1
  50. package/dist/standalone/{chunk-3DRBFZ2R.js → chunk-O75FH2VA.js} +1 -1
  51. package/dist/standalone/{chunk-7COKTU5I.js → chunk-OPXOPRI2.js} +1 -1
  52. package/dist/standalone/{chunk-ZRFRFHRU.js → chunk-OYDOFRRB.js} +1 -1
  53. package/dist/standalone/{chunk-5UDEPHRK.js → chunk-Q5CSRWLU.js} +1 -1
  54. package/dist/standalone/{chunk-7FTJLXZH.js → chunk-QYLNHUWI.js} +1 -1
  55. package/dist/standalone/{chunk-ZPYEW5ZL.js → chunk-QZFWP5PG.js} +1 -1
  56. package/dist/standalone/{chunk-AUUB5SEX.js → chunk-ROX3SLF7.js} +1 -1
  57. package/dist/standalone/{chunk-LVKT5NQQ.js → chunk-RZAWVHB7.js} +1 -1
  58. package/dist/standalone/{chunk-VHL2HNC5.js → chunk-SKTCA3PL.js} +1 -1
  59. package/dist/standalone/{chunk-XN2YDTTH.js → chunk-STF2OPKL.js} +1 -1
  60. package/dist/standalone/{chunk-BPDWF4EX.js → chunk-TNXRQCSI.js} +1 -1
  61. package/dist/standalone/{chunk-3SSDUHUE.js → chunk-UEHILSMN.js} +1 -1
  62. package/dist/standalone/{chunk-L5UNLRGK.js → chunk-UQJRKAQX.js} +1 -1
  63. package/dist/standalone/{chunk-SBDEC37M.js → chunk-V65TMRRH.js} +1 -1
  64. package/dist/standalone/{chunk-P7I3HBJN.js → chunk-VTLEHQAN.js} +1 -1
  65. package/dist/standalone/{chunk-YHTANVUO.js → chunk-VVB3GENM.js} +2 -2
  66. package/dist/standalone/{chunk-BUH67LRI.js → chunk-VVGQZR53.js} +1 -1
  67. package/dist/standalone/{chunk-L3NY3CEL.js → chunk-VVRT5OAX.js} +1 -1
  68. package/dist/standalone/{chunk-5OGXAO7S.js → chunk-W77PDXGW.js} +1 -1
  69. package/dist/standalone/{chunk-Q5KTZWZ2.js → chunk-WYP2Z35M.js} +6 -6
  70. package/dist/standalone/{chunk-W4CQMJH3.js → chunk-XSW4R2MI.js} +1 -1
  71. package/dist/standalone/{chunk-3LD7PBIC.js → chunk-YGV4V7VT.js} +1 -1
  72. package/dist/standalone/{chunk-6XRGQ3ND.js → chunk-YI7WVSMX.js} +1 -1
  73. package/dist/standalone/{chunk-XBTCFWYG.js → chunk-YJ5SU2PD.js} +1 -1
  74. package/dist/standalone/{chunk-6RYVH5BG.js → chunk-YXW7GATV.js} +1 -1
  75. package/dist/standalone/{chunk-MW6W7DGV.js → chunk-Z277L2BQ.js} +1 -1
  76. package/dist/standalone/studio.js +1 -1
  77. package/package.json +5 -5
  78. package/dist/packem_shared/OpenRpcReferencePanel-CPIr-u-J.mjs +0 -1
  79. package/dist/packem_shared/schema-diagram-LRfchcoA.mjs +0 -2
  80. package/dist/standalone/chunk-EQRZJZD4.js +0 -7
  81. package/dist/standalone/chunk-GW4GGPRY.js +0 -15
  82. package/dist/standalone/chunk-IKT6EYHN.js +0 -1
@@ -1 +1 @@
1
- import{a as Ot,b as Qt,c as ot}from"./chunk-CVXNHIQW.js";import{a as me}from"./chunk-253UHWDX.js";import{a as Kt,b as At,c as Pt,d as $t}from"./chunk-2I4NHEKA.js";import{a as it}from"./chunk-7FTJLXZH.js";import{a as It,b as Rt,c as Tt,d as zt,e as Qe}from"./chunk-5QR2SQIS.js";import{a as Ft}from"./chunk-VCFEO3RI.js";import{a as Lt}from"./chunk-K2EHRNYW.js";import"./chunk-VESGIGMQ.js";import"./chunk-NRP22GKC.js";import{e as Ct}from"./chunk-UYEZR3BI.js";import"./chunk-OPM7ESDV.js";import{a as Dt}from"./chunk-EWMBX5N2.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Ze,b as et,c as tt,d as Nt,e as yt,f as rt,g as at,h as wt,i as St}from"./chunk-W4CQMJH3.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import{a as Mt}from"./chunk-R6U22RSY.js";import{a as _t}from"./chunk-7Q256NLI.js";import{a as qt,b as kt}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-OQ6I6OXT.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as Je}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Ge}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as Ke}from"./chunk-4ZEL6BYL.js";import{c as $e}from"./chunk-YSPQIRER.js";import{a as ct,l as mt}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as gt}from"./chunk-RWVIV3U7.js";import{a as st,b as lt,c as nt,d as Oe,e as ce,f as V}from"./chunk-HCTJKP5J.js";import{a as fe,b as Ae,c as Pe,d as ht,e as pe}from"./chunk-2IKDEUCX.js";import{d as ge,f as ft,g as pt,h as xt,i as bt,m as Ve,q as vt}from"./chunk-74IYYDDI.js";import{a as d,d as Ye,e as Et,f as Ht,g as Ut,i as ut}from"./chunk-I26MS5PJ.js";var B=Ye(Et(),1);var xe=Ye(Ht(),1);var t=Ye(Ut(),1);var jt=d((l,e,s)=>`${l}:${e}:${ct(s??{})}`,"ut"),Bt=d((l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,"ft"),Gt=d((l,e)=>Bt(l,e),"Vt"),Vt=d(l=>Bt(l.kind,l),"Gt"),dt=d(l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),"We"),Wt=d(l=>Array.isArray(l?.series)?l.series:[],"Jt"),Xt="FUNCTION_NOT_FOUND",Yt=d(l=>{let e=new Map;if(!Array.isArray(l?.series))return e;for(let s of l.series)e.set(jt(s.kind,s.name,s.attributes),s.points);return e},"Xt"),Jt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=d(l=>{let e=(0,xe.c)(18),{name:s,onOpenTrace:a,traceId:r}=l,h=ge();if(r===void 0){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=c):c=e[0],c}let i;e[1]!==r?(i=r.slice(0,8),e[1]=r,e[2]=i):i=e[2];let n=i;if(a===void 0){let c=`mt-instrument-trace-${s}`,p;return e[3]!==n||e[4]!==c||e[5]!==r?(p=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":c,title:r,children:n}),e[3]=n,e[4]=c,e[5]=r,e[6]=p):p=e[6],p}let g=`mt-instrument-trace-${s}`,v;e[7]!==a||e[8]!==r?(v=d(()=>{a(r)},"v"),e[7]=a,e[8]=r,e[9]=v):v=e[9];let S;e[10]!==h||e[11]!==r?(S=h("Open the exemplar trace {trace}",{trace:r}),e[10]=h,e[11]=r,e[12]=S):S=e[12];let f;return e[13]!==n||e[14]!==g||e[15]!==v||e[16]!==S?(f=(0,t.jsx)("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":g,onClick:v,title:S,type:"button",children:n}),e[13]=n,e[14]=g,e[15]=v,e[16]=S,e[17]=f):f=e[17],f},"Zt"),er=d(l=>{let e=(0,xe.c)(105),{onOpenTrace:s,shardKey:a}=l,r=ge(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={},e[0]=h):h=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];let{data:n,error:g,errorSource:v}=$e(Ke.getMetricSeries,h,i),S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let f;e[4]!==a?(f={live:!0,shardKey:a},e[4]=a,e[5]=f):f=e[5];let{data:c}=$e(Ke.getMetricHistory,S,f),p,N,q,M,o,k,x,b,_,D,u,C,I;if(e[6]!==n||e[7]!==g||e[8]!==v||e[9]!==c||e[10]!==s||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{let A=Wt(n),P=bt(v)===Xt;if(g!==null&&!P){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let j;e[27]!==m?(j=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=j):j=e[28];let E;e[29]!==g||e[30]!==r?(E=r("Instruments unavailable: {error}",{error:g}),e[29]=g,e[30]=r,e[31]=E):E=e[31];let H;e[32]!==E?(H=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:E}),e[32]=E,e[33]=H):H=e[33];let de;e[34]!==j||e[35]!==H?(de=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[j,H]}),e[34]=j,e[35]=H,e[36]=de):de=e[36],b=de;break e}if(A.length===0){b=null;break e}let $=Yt(c),L;e[37]!==r?(L=d(m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),"L"),e[37]=r,e[38]=L):L=e[38];let U=L;o="flex flex-col gap-2",k="mt-instruments";let Q;e[39]!==r?(Q=r("Instruments"),e[39]=r,e[40]=Q):Q=e[40],e[41]!==Q?(x=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:Q}),e[41]=Q,e[42]=x):x=e[42],M=fe,I="overflow-hidden py-0",q=pe,C="px-0",N=st,D="mt-instruments-table";let K;e[43]!==r?(K=r("name"),e[43]=r,e[44]=K):K=e[44];let O;e[45]!==K?(O=(0,t.jsx)(ce,{children:K}),e[45]=K,e[46]=O):O=e[46];let W;e[47]!==r?(W=r("kind"),e[47]=r,e[48]=W):W=e[48];let X;e[49]!==W?(X=(0,t.jsx)(ce,{children:W}),e[49]=W,e[50]=X):X=e[50];let Y;e[51]!==r?(Y=r("value"),e[51]=r,e[52]=Y):Y=e[52];let J;e[53]!==Y?(J=(0,t.jsx)(ce,{className:"text-right",children:Y}),e[53]=Y,e[54]=J):J=e[54];let Z;e[55]!==r?(Z=r("count"),e[55]=r,e[56]=Z):Z=e[56];let ee;e[57]!==Z?(ee=(0,t.jsx)(ce,{className:"text-right",children:Z}),e[57]=Z,e[58]=ee):ee=e[58];let te;e[59]!==r?(te=r("range"),e[59]=r,e[60]=te):te=e[60];let re;e[61]!==te?(re=(0,t.jsx)(ce,{className:"text-right",children:te}),e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==r?(ae=r("trend"),e[63]=r,e[64]=ae):ae=e[64];let se;e[65]!==ae?(se=(0,t.jsx)(ce,{children:ae}),e[65]=ae,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ne;e[69]!==le?(ne=(0,t.jsx)(ce,{children:le}),e[69]=le,e[70]=ne):ne=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let oe;e[73]!==ie?(oe=(0,t.jsx)(ce,{children:ie}),e[73]=ie,e[74]=oe):oe=e[74],e[75]!==O||e[76]!==X||e[77]!==J||e[78]!==ee||e[79]!==re||e[80]!==se||e[81]!==ne||e[82]!==oe?(u=(0,t.jsx)(lt,{children:(0,t.jsxs)(Oe,{children:[O,X,J,ee,re,se,ne,oe]})}),e[75]=O,e[76]=X,e[77]=J,e[78]=ee,e[79]=re,e[80]=se,e[81]=ne,e[82]=oe,e[83]=u):u=e[83],p=nt,_=A.map(m=>{let j=Ft(m.attributes),E=jt(m.kind,m.name,m.attributes),H=($.get(E)??[]).map(de=>Gt(m.kind,de));return(0,t.jsxs)(Oe,{"data-testid":`mt-instrument-${m.name}`,children:[(0,t.jsx)(V,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),(0,t.jsx)(V,{children:(0,t.jsx)(Ge,{variant:Jt[m.kind],children:U(m.kind)})}),(0,t.jsx)(V,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:dt(Vt(m))}),(0,t.jsx)(V,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),(0,t.jsx)(V,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"\u2014":`${dt(m.min)}\u2013${dt(m.max)}`}),(0,t.jsx)(V,{children:H.length>=2?(0,t.jsx)(it,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:H,testId:`mt-instrument-trend-${m.name}`}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(V,{className:"font-mono text-xs",children:(0,t.jsx)(Zt,{name:m.name,onOpenTrace:s,traceId:m.exemplarTraceId})}),(0,t.jsx)(V,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:j,children:j===""?"\u2014":j})]},E)})}e[6]=n,e[7]=g,e[8]=v,e[9]=c,e[10]=s,e[11]=r,e[12]=p,e[13]=N,e[14]=q,e[15]=M,e[16]=o,e[17]=k,e[18]=x,e[19]=b,e[20]=_,e[21]=D,e[22]=u,e[23]=C,e[24]=I}else p=e[12],N=e[13],q=e[14],M=e[15],o=e[16],k=e[17],x=e[18],b=e[19],_=e[20],D=e[21],u=e[22],C=e[23],I=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let R;e[84]!==p||e[85]!==_?(R=(0,t.jsx)(p,{children:_}),e[84]=p,e[85]=_,e[86]=R):R=e[86];let T;e[87]!==N||e[88]!==R||e[89]!==D||e[90]!==u?(T=(0,t.jsxs)(N,{"data-testid":D,children:[u,R]}),e[87]=N,e[88]=R,e[89]=D,e[90]=u,e[91]=T):T=e[91];let w;e[92]!==q||e[93]!==T||e[94]!==C?(w=(0,t.jsx)(q,{className:C,children:T}),e[92]=q,e[93]=T,e[94]=C,e[95]=w):w=e[95];let y;e[96]!==M||e[97]!==w||e[98]!==I?(y=(0,t.jsx)(M,{className:I,children:w}),e[96]=M,e[97]=w,e[98]=I,e[99]=y):y=e[99];let F;return e[100]!==o||e[101]!==k||e[102]!==x||e[103]!==y?(F=(0,t.jsxs)("section",{className:o,"data-testid":k,children:[x,y]}),e[100]=o,e[101]=k,e[102]=x,e[103]=y,e[104]=F):F=e[104],F},"er"),tr=d(l=>{let e=(0,xe.c)(74),{aggregate:s,shardResults:a}=l,r=ge(),h;e[0]!==r?(h=r("Shards"),e[0]=r,e[1]=h):h=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==r?(i=s.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):r("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==h||e[7]!==i?(n=(0,t.jsx)(me,{label:h,testId:"mt-agg-shards",value:i}),e[6]=h,e[7]=i,e[8]=n):n=e[8];let g;e[9]!==r?(g=r("Total requests"),e[9]=r,e[10]=g):g=e[10];let v;e[11]!==s.totalRequests||e[12]!==g?(v=(0,t.jsx)(me,{label:g,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=g,e[13]=v):v=e[13];let S;e[14]!==r?(S=r("Total errors"),e[14]=r,e[15]=S):S=e[15];let f;e[16]!==s.totalErrors||e[17]!==S?(f=(0,t.jsx)(me,{label:S,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=S,e[18]=f):f=e[18];let c;e[19]!==r?(c=r("Total database size"),e[19]=r,e[20]=c):c=e[20];let p;e[21]!==s.totalDatabaseSize?(p=Ve(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=p):p=e[22];let N;e[23]!==c||e[24]!==p?(N=(0,t.jsx)(me,{label:c,testId:"mt-agg-db-size",value:p}),e[23]=c,e[24]=p,e[25]=N):N=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let M;e[28]!==s.hitRate||e[29]!==r?(M=s.hitRate===null?r("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=r,e[30]=M):M=e[30];let o;e[31]!==q||e[32]!==M?(o=(0,t.jsx)(me,{label:q,testId:"mt-agg-cache",value:M}),e[31]=q,e[32]=M,e[33]=o):o=e[33];let k;e[34]!==N||e[35]!==o||e[36]!==n||e[37]!==v||e[38]!==f?(k=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,v,f,N,o]}),e[34]=N,e[35]=o,e[36]=n,e[37]=v,e[38]=f,e[39]=k):k=e[39];let x;e[40]!==r?(x=r("shard"),e[40]=r,e[41]=x):x=e[41];let b;e[42]!==x?(b=(0,t.jsx)(ce,{children:x}),e[42]=x,e[43]=b):b=e[43];let _;e[44]!==r?(_=r("requests"),e[44]=r,e[45]=_):_=e[45];let D;e[46]!==_?(D=(0,t.jsx)(ce,{children:_}),e[46]=_,e[47]=D):D=e[47];let u;e[48]!==r?(u=r("errors"),e[48]=r,e[49]=u):u=e[49];let C;e[50]!==u?(C=(0,t.jsx)(ce,{children:u}),e[50]=u,e[51]=C):C=e[51];let I;e[52]!==r?(I=r("db size"),e[52]=r,e[53]=I):I=e[53];let R;e[54]!==I?(R=(0,t.jsx)(ce,{children:I}),e[54]=I,e[55]=R):R=e[55];let T;e[56]!==b||e[57]!==D||e[58]!==C||e[59]!==R?(T=(0,t.jsx)(lt,{children:(0,t.jsxs)(Oe,{children:[b,D,C,R]})}),e[56]=b,e[57]=D,e[58]=C,e[59]=R,e[60]=T):T=e[60];let w;if(e[61]!==a||e[62]!==r){let P;e[64]!==r?(P=d($=>(0,t.jsxs)(Oe,{"data-testid":`mt-agg-row-${$.shard}`,children:[(0,t.jsx)(V,{children:$.shard}),$.metrics===null?(0,t.jsx)(V,{className:"text-destructive",colSpan:3,children:$.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(V,{className:"tabular-nums",children:$.metrics.requests}),(0,t.jsx)(V,{className:"tabular-nums",children:$.metrics.errors}),(0,t.jsx)(V,{className:"tabular-nums",children:Ve($.metrics.databaseSize)})]})]},$.shard),"z"),e[64]=r,e[65]=P):P=e[65],w=a.map(P),e[61]=a,e[62]=r,e[63]=w}else w=e[63];let y;e[66]!==w?(y=(0,t.jsx)(nt,{children:w}),e[66]=w,e[67]=y):y=e[67];let F;e[68]!==T||e[69]!==y?(F=(0,t.jsx)(fe,{className:"overflow-hidden py-0",children:(0,t.jsx)(pe,{className:"px-0",children:(0,t.jsxs)(st,{"data-testid":"mt-agg-table",children:[T,y]})})}),e[68]=T,e[69]=y,e[70]=F):F=e[70];let A;return e[71]!==k||e[72]!==F?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[k,F]}),e[71]=k,e[72]=F,e[73]=A):A=e[73],A},"tr"),rr=d(l=>{let e=(0,xe.c)(75),{currentDelta:s,errorRate:a,history:r,latencyPercentiles:h,metrics:i}=l,n=ge(),{cache:g}=i,v;e[0]!==r||e[1]!==n?(v=r.length>=2?(0,t.jsx)(it,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=n,e[2]=v):v=e[2];let S;e[3]!==s||e[4]!==r.length||e[5]!==n?(S=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples\u2026")}),e[3]=s,e[4]=r.length,e[5]=n,e[6]=S):S=e[6];let f;e[7]!==n?(f=n("Requests"),e[7]=n,e[8]=f):f=e[8];let c;e[9]!==i.requests||e[10]!==v||e[11]!==S||e[12]!==f?(c=(0,t.jsx)(me,{chart:v,footer:S,label:f,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=v,e[11]=S,e[12]=f,e[13]=c):c=e[13];let p;e[14]!==a||e[15]!==n?(p=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=p):p=e[16];let N;e[17]!==n?(N=n("Errors"),e[17]=n,e[18]=N):N=e[18];let q;e[19]!==a||e[20]!==i.errors?(q=(0,t.jsxs)(t.Fragment,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=q):q=e[21];let M;e[22]!==p||e[23]!==N||e[24]!==q?(M=(0,t.jsx)(me,{footer:p,label:N,testId:"mt-errors",value:q}),e[22]=p,e[23]=N,e[24]=q,e[25]=M):M=e[25];let o;e[26]!==h.p90?(o=h.p90>0?`P90 ${ot(h.p90)}`:void 0,e[26]=h.p90,e[27]=o):o=e[27];let k;e[28]!==n?(k=n("P95 latency"),e[28]=n,e[29]=k):k=e[29];let x;e[30]!==h.p95?(x=h.p95>0?ot(h.p95):"\u2014",e[30]=h.p95,e[31]=x):x=e[31];let b;e[32]!==k||e[33]!==x||e[34]!==o?(b=(0,t.jsx)(me,{footer:o,label:k,testId:"mt-p95",value:x}),e[32]=k,e[33]=x,e[34]=o,e[35]=b):b=e[35];let _;e[36]!==g||e[37]!==n?(_=g?`${g.entries.toLocaleString()} ${n("cache entries")}`:void 0,e[36]=g,e[37]=n,e[38]=_):_=e[38];let D;e[39]!==n?(D=n("Database size"),e[39]=n,e[40]=D):D=e[40];let u;e[41]!==i.databaseSize?(u=Ve(i.databaseSize),e[41]=i.databaseSize,e[42]=u):u=e[42];let C;e[43]!==_||e[44]!==D||e[45]!==u?(C=(0,t.jsx)(me,{footer:_,label:D,testId:"mt-db-size",value:u}),e[43]=_,e[44]=D,e[45]=u,e[46]=C):C=e[46];let I;e[47]!==n?(I=n("Shard"),e[47]=n,e[48]=I):I=e[48];let R;e[49]!==i.shard||e[50]!==I?(R=(0,t.jsx)(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=R):R=e[51];let T;e[52]!==n?(T=n("Uptime"),e[52]=n,e[53]=T):T=e[53];let w;e[54]!==i.uptimeMs?(w=Ot(i.uptimeMs),e[54]=i.uptimeMs,e[55]=w):w=e[55];let y;e[56]!==T||e[57]!==w?(y=(0,t.jsx)(me,{label:T,testId:"mt-uptime",value:w}),e[56]=T,e[57]=w,e[58]=y):y=e[58];let F;e[59]!==n?(F=n("Cache hit rate"),e[59]=n,e[60]=F):F=e[60];let A;e[61]!==g||e[62]!==n?(A=g?n("{rate} ({count} entries)",{count:g.entries,rate:Qt(g.hits,g.misses)}):n("no cache configured"),e[61]=g,e[62]=n,e[63]=A):A=e[63];let P;e[64]!==F||e[65]!==A?(P=(0,t.jsx)(me,{label:F,testId:"mt-cache",value:A}),e[64]=F,e[65]=A,e[66]=P):P=e[66];let $;return e[67]!==b||e[68]!==C||e[69]!==R||e[70]!==y||e[71]!==P||e[72]!==c||e[73]!==M?($=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[c,M,b,C,R,y,P]}),e[67]=b,e[68]=C,e[69]=R,e[70]=y,e[71]=P,e[72]=c,e[73]=M,e[74]=$):$=e[74],$},"rr"),Xe=d(l=>l>=100?"critical":l>=50?"warning":"good","Ge"),je=d(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"Ee"),We=d(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"Ue"),ar=d(l=>{let e=(0,xe.c)(3),{level:s}=l;if(s==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Ge,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(s==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=a):a=e[2],a},"sr"),sr=d((l,e)=>{let s=[...l];return s.sort((a,r)=>{switch(e){case"avgTime":return r.avgDurationMs-a.avgDurationMs;case"execCount":return r.execCount-a.execCount;case"rowsRead":return r.rowsRead-a.rowsRead;default:return r.totalDurationMs-a.totalDurationMs}}),s},"lr"),lr=d(l=>{let e=(0,xe.c)(161),{queryStats:s}=l,a=ge(),[r,h]=(0,B.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[n,g]=(0,B.useState)(i),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=d(I=>{I!==null&&h(I)},"v"),e[1]=v):v=e[1];let S=v,f,c,p,N,q,M,o,k,x,b;if(e[2]!==n||e[3]!==s||e[4]!==r||e[5]!==a){p=Symbol.for("react.early_return_sentinel");e:{let I=sr(s,r),R;e[16]!==s?(R=s.filter(nr),e[16]=s,e[17]=R):R=e[17];let T=R.length,w;e[18]!==s?(w=s.filter(ir),e[18]=s,e[19]=w):w=e[19];let y=w.length,F;e[20]!==s?(F=s.filter(or),e[20]=s,e[21]=F):F=e[21];let A=F.length,P;e[22]===Symbol.for("react.memo_cache_sentinel")?(P=d(z=>{g(ue=>{let G=new Set(ue);return G.has(z)?G.delete(z):G.add(z),G})},"z"),e[22]=P):P=e[22];let $=P;if(s.length===0){let z;e[23]!==a?(z=a("No query insights yet"),e[23]=a,e[24]=z):z=e[24];let ue;e[25]!==z?(ue=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:z}),e[25]=z,e[26]=ue):ue=e[26];let G;e[27]!==a?(G=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=G):G=e[28];let he;e[29]!==G?(he=(0,t.jsx)("p",{className:"mt-1 text-sm",children:G}),e[29]=G,e[30]=he):he=e[30];let Ue;e[31]!==ue||e[32]!==he?(Ue=(0,t.jsx)(fe,{children:(0,t.jsx)(pe,{className:"py-12",children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground",children:[ue,he]})})}),e[31]=ue,e[32]=he,e[33]=Ue):Ue=e[33],p=Ue;break e}o="space-y-4",k="qi-root";let L;e[34]!==a?(L=a("Critical queries"),e[34]=a,e[35]=L):L=e[35];let U;e[36]!==L?(U=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=U):U=e[37];let Q;e[38]!==T?(Q=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:T}),e[38]=T,e[39]=Q):Q=e[39];let K;e[40]!==a?(K=a(">100ms avg execution"),e[40]=a,e[41]=K):K=e[41];let O;e[42]!==K?(O=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:K}),e[42]=K,e[43]=O):O=e[43];let W;e[44]!==Q||e[45]!==O?(W=(0,t.jsxs)(pe,{children:[Q,O]}),e[44]=Q,e[45]=O,e[46]=W):W=e[46];let X;e[47]!==U||e[48]!==W?(X=(0,t.jsxs)(fe,{children:[U,W]}),e[47]=U,e[48]=W,e[49]=X):X=e[49];let Y;e[50]!==a?(Y=a("Moderate queries"),e[50]=a,e[51]=Y):Y=e[51];let J;e[52]!==Y?(J=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:Y})}),e[52]=Y,e[53]=J):J=e[53];let Z;e[54]!==y?(Z=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:y}),e[54]=y,e[55]=Z):Z=e[55];let ee;e[56]!==a?(ee=a("50\u2013100ms avg execution"),e[56]=a,e[57]=ee):ee=e[57];let te;e[58]!==ee?(te=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ee}),e[58]=ee,e[59]=te):te=e[59];let re;e[60]!==Z||e[61]!==te?(re=(0,t.jsxs)(pe,{children:[Z,te]}),e[60]=Z,e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==J||e[64]!==re?(ae=(0,t.jsxs)(fe,{children:[J,re]}),e[63]=J,e[64]=re,e[65]=ae):ae=e[65];let se;e[66]!==a?(se=a("Fast queries"),e[66]=a,e[67]=se):se=e[67];let le;e[68]!==se?(le=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ne;e[70]!==A?(ne=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:A}),e[70]=A,e[71]=ne):ne=e[71];let ie;e[72]!==a?(ie=a("<50ms avg execution"),e[72]=a,e[73]=ie):ie=e[73];let oe;e[74]!==ie?(oe=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=oe):oe=e[75];let m;e[76]!==ne||e[77]!==oe?(m=(0,t.jsxs)(pe,{children:[ne,oe]}),e[76]=ne,e[77]=oe,e[78]=m):m=e[78];let j;e[79]!==le||e[80]!==m?(j=(0,t.jsxs)(fe,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=j):j=e[81],e[82]!==X||e[83]!==ae||e[84]!==j?(x=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[X,ae,j]}),e[82]=X,e[83]=ae,e[84]=j,e[85]=x):x=e[85];let E;e[86]!==a?(E=a("Query leaderboard"),e[86]=a,e[87]=E):E=e[87];let H;e[88]!==E?(H=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:E}),e[88]=E,e[89]=H):H=e[89];let de;e[90]!==r||e[91]!==a?(de=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=de):de=e[92];let be;e[93]!==de?(be=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:de}),e[93]=de,e[94]=be):be=e[94];let ve;e[95]!==H||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[H,be]}),e[95]=H,e[96]=be,e[97]=ve):ve=e[97];let Ne;e[98]!==a?(Ne=a("Sort by"),e[98]=a,e[99]=Ne):Ne=e[99];let ye;e[100]!==Ne?(ye=(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:Ne}),e[100]=Ne,e[101]=ye):ye=e[101];let we;e[102]!==a?(we=a("Sort queries by"),e[102]=a,e[103]=we):we=e[103];let Be;e[104]===Symbol.for("react.memo_cache_sentinel")?(Be=(0,t.jsx)(Rt,{}),e[104]=Be):Be=e[104];let Se;e[105]!==we?(Se=(0,t.jsx)(Tt,{"aria-label":we,className:"w-[140px]","data-testid":"qi-sort",children:Be}),e[105]=we,e[106]=Se):Se=e[106];let qe;e[107]!==a?(qe=a("Total time"),e[107]=a,e[108]=qe):qe=e[108];let ke;e[109]!==qe?(ke=(0,t.jsx)(Qe,{value:"totalTime",children:qe}),e[109]=qe,e[110]=ke):ke=e[110];let _e;e[111]!==a?(_e=a("Avg time"),e[111]=a,e[112]=_e):_e=e[112];let Me;e[113]!==_e?(Me=(0,t.jsx)(Qe,{value:"avgTime",children:_e}),e[113]=_e,e[114]=Me):Me=e[114];let De;e[115]!==a?(De=a("Execution count"),e[115]=a,e[116]=De):De=e[116];let Ce;e[117]!==De?(Ce=(0,t.jsx)(Qe,{value:"execCount",children:De}),e[117]=De,e[118]=Ce):Ce=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Re;e[121]!==Ie?(Re=(0,t.jsx)(Qe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Re):Re=e[122];let Te;e[123]!==ke||e[124]!==Me||e[125]!==Ce||e[126]!==Re?(Te=(0,t.jsxs)(zt,{children:[ke,Me,Ce,Re]}),e[123]=ke,e[124]=Me,e[125]=Ce,e[126]=Re,e[127]=Te):Te=e[127];let ze;e[128]!==r||e[129]!==Se||e[130]!==Te?(ze=(0,t.jsxs)(It,{onValueChange:S,value:r,children:[Se,Te]}),e[128]=r,e[129]=Se,e[130]=Te,e[131]=ze):ze=e[131];let Fe;e[132]!==ye||e[133]!==ze?(Fe=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[ye,ze]}),e[132]=ye,e[133]=ze,e[134]=Fe):Fe=e[134],e[135]!==ve||e[136]!==Fe?(b=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,Fe]}),e[135]=ve,e[136]=Fe,e[137]=b):b=e[137],c=fe;let Le;e[138]!==a?(Le=a("Statements"),e[138]=a,e[139]=Le):Le=e[139];let Ee;e[140]!==Le?(Ee=(0,t.jsx)(Pe,{children:Le}),e[140]=Le,e[141]=Ee):Ee=e[141],M=(0,t.jsxs)(Ae,{children:[Ee,(0,t.jsx)(ht,{children:a("{count} tracked statements",{count:I.length})})]}),f=pe,N="space-y-2";let He;e[142]!==n||e[143]!==a?(He=d(z=>{let ue=z.normalizedSql,G=n.has(ue),he=Xe(z.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":G,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:d(()=>{$(ue)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(ar,{level:he}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:z.normalizedSql})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.totalDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),z.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.p95DurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:We(z.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),G&&(0,t.jsxs)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),(0,t.jsx)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:z.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[z.p50DurationMs!==void 0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("p50")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:je(z.p50DurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Exec count")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.execCount)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Total time")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:je(z.totalDurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows read")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.rowsRead)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows written")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.rowsWritten)})]})]})]})]},ue)},"Ke"),e[142]=n,e[143]=a,e[144]=He):He=e[144],q=I.map(He)}e[2]=n,e[3]=s,e[4]=r,e[5]=a,e[6]=f,e[7]=c,e[8]=p,e[9]=N,e[10]=q,e[11]=M,e[12]=o,e[13]=k,e[14]=x,e[15]=b}else f=e[6],c=e[7],p=e[8],N=e[9],q=e[10],M=e[11],o=e[12],k=e[13],x=e[14],b=e[15];if(p!==Symbol.for("react.early_return_sentinel"))return p;let _;e[145]!==N||e[146]!==q?(_=(0,t.jsx)("div",{className:N,children:q}),e[145]=N,e[146]=q,e[147]=_):_=e[147];let D;e[148]!==f||e[149]!==_?(D=(0,t.jsx)(f,{children:_}),e[148]=f,e[149]=_,e[150]=D):D=e[150];let u;e[151]!==c||e[152]!==D||e[153]!==M?(u=(0,t.jsxs)(c,{children:[M,D]}),e[151]=c,e[152]=D,e[153]=M,e[154]=u):u=e[154];let C;return e[155]!==u||e[156]!==o||e[157]!==k||e[158]!==x||e[159]!==b?(C=(0,t.jsxs)("div",{className:o,"data-testid":k,children:[x,b,u]}),e[155]=u,e[156]=o,e[157]=k,e[158]=x,e[159]=b,e[160]=C):C=e[160],C},"ar");function nr(l){return Xe(l.avgDurationMs)==="critical"}d(nr,"ir");function ir(l){return Xe(l.avgDurationMs)==="warning"}d(ir,"nr");function or(l){return Xe(l.avgDurationMs)==="good"}d(or,"or");var dr=["1m","5m","15m","1h"],cr=d(l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"dr"),mr=d(l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:cr(e.bucketMs)})),"mr"),ur=d(({shardKey:l=""})=>{let e=ge(),[s,a]=(0,B.useState)("15m"),r=$e(Ke.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,h=mr(r?.buckets??[]);return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:dr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===s,className:ut("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:d(()=>{a(i)},"onClick"),type:"button",children:i},i))}),r?.capped===!0&&(0,t.jsx)(Ge,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),h.length===0?(0,t.jsx)(gt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):(0,t.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(St,{data:h,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(yt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(wt,{data:h,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(Nt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(lr,{queryStats:r?.entries??[]})]})},"ur"),hr=ft(Ke.getMetrics),gr=d((l,e)=>l?e:"overview","hr"),Or=d(({initialShardKey:l})=>{let e=mt(),s=ge(),{queryShardKey:a,setShardKey:r,shardKey:h}=Mt(l),[i,n]=(0,B.useState)("overview"),[g,v]=(0,B.useState)([]),S=(0,B.useRef)(null),f=(0,B.useRef)(null),c=(0,B.useRef)(!0);(0,B.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=Lt(a),{data:N,error:q,liveError:M}=$e(Ke.getMetrics,{},{live:!0,shardKey:a}),o=N??null;(0,B.useEffect)(()=>{if(N===void 0)return;kt(a);let L=N,U=S.current,Q=f.current!==null&&f.current!==L.shard;if(f.current=L.shard,S.current=L.requests,Q){v([]);return}U!==null&&L.requests>=U&&v(K=>[...K,L.requests-U].slice(-30))},[N,a]);let[k,x]=(0,B.useState)(null),[b,_]=(0,B.useState)(!1),D=d(async()=>{_(!0);let L=h,U=At(L,qt());try{let Q=await Promise.all(U.map(async K=>{try{let O=await e.query(hr,{},pt(K));return{error:null,metrics:O,shard:K===""?O.shard:K}}catch(O){return{error:xt(O),metrics:null,shard:K===""?"__root__":K}}}));c.current&&x({results:Q,shard:L})}finally{c.current&&_(!1)}},"R"),u=k?.shard===h?k.results:null,C=u===null?null:Kt(u),I=o===null||o.requests===0?"\u2014":`${(o.errors/o.requests*100).toFixed(1)}%`,R=g.length>0?g.at(-1):0,T=o?Pt(o):{p90:0,p95:0},w=(0,B.useMemo)(()=>{if(!o||!("queryStats"in o))return;let L=o.queryStats;if(!(!L||!Array.isArray(L)))return $t(L)},[o]),y=gr(w!==void 0,i),F=d(()=>{vt(D())},"A"),A=d(()=>{x(null)},"F"),P=d(()=>{n("overview")},"z"),$=d(()=>{n("query-insights")},"O");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(_t,{onChange:r,testId:"mt-shard-input",value:h}),(0,t.jsx)(Dt,{message:M,prefix:"mt"}),(0,t.jsx)(Je,{"data-testid":"mt-aggregate",disabled:b,onClick:F,size:"sm",type:"button",variant:"secondary",children:s(b?"Aggregating\u2026":"All shards")}),u!==null&&(0,t.jsx)(Je,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")}),(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:Ct,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")})]}),q!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),w!==void 0&&(0,t.jsxs)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsx)("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:P,type:"button",children:s("Overview")}),(0,t.jsxs)("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:$,type:"button",children:[s("Query insights"),w.length>0&&(0,t.jsx)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:w.length})]})]}),y==="query-insights"&&w!==void 0&&(0,t.jsx)(ur,{shardKey:a}),y==="overview"&&o!==null&&(0,t.jsx)(rr,{currentDelta:R,errorRate:I,history:g,latencyPercentiles:T,metrics:o}),y==="overview"&&o===null&&null,y==="overview"&&(0,t.jsx)(er,{onOpenTrace:p,shardKey:a}),y==="overview"&&C!==null&&u!==null&&(0,t.jsx)(tr,{aggregate:C,shardResults:u})]})},"Qr");export{Or as MetricsPanel};
1
+ import{a as Ot,b as Qt,c as ot}from"./chunk-CVXNHIQW.js";import{a as me}from"./chunk-253UHWDX.js";import{a as Kt,b as At,c as Pt,d as $t}from"./chunk-2I4NHEKA.js";import{a as it}from"./chunk-QYLNHUWI.js";import{a as It,b as Rt,c as Tt,d as zt,e as Qe}from"./chunk-5QR2SQIS.js";import{a as Ft}from"./chunk-VCFEO3RI.js";import{a as Lt}from"./chunk-K2EHRNYW.js";import"./chunk-VESGIGMQ.js";import"./chunk-NRP22GKC.js";import{e as Ct}from"./chunk-UYEZR3BI.js";import"./chunk-OPM7ESDV.js";import{a as Dt}from"./chunk-EWMBX5N2.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Ze,b as et,c as tt,d as Nt,e as yt,f as rt,g as at,h as wt,i as St}from"./chunk-XSW4R2MI.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import{a as Mt}from"./chunk-R6U22RSY.js";import{a as _t}from"./chunk-7Q256NLI.js";import{a as qt,b as kt}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-OQ6I6OXT.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as Je}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Ge}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as Ke}from"./chunk-4ZEL6BYL.js";import{c as $e}from"./chunk-NWWMHMGA.js";import{a as ct,l as mt}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as gt}from"./chunk-RWVIV3U7.js";import{a as st,b as lt,c as nt,d as Oe,e as ce,f as V}from"./chunk-HCTJKP5J.js";import{a as fe,b as Ae,c as Pe,d as ht,e as pe}from"./chunk-2IKDEUCX.js";import{d as ge,f as ft,g as pt,h as xt,i as bt,m as Ve,q as vt}from"./chunk-74IYYDDI.js";import{a as d,d as Ye,e as Et,f as Ht,g as Ut,i as ut}from"./chunk-I26MS5PJ.js";var B=Ye(Et(),1);var xe=Ye(Ht(),1);var t=Ye(Ut(),1);var jt=d((l,e,s)=>`${l}:${e}:${ct(s??{})}`,"ut"),Bt=d((l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,"ft"),Gt=d((l,e)=>Bt(l,e),"Vt"),Vt=d(l=>Bt(l.kind,l),"Gt"),dt=d(l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),"We"),Wt=d(l=>Array.isArray(l?.series)?l.series:[],"Jt"),Xt="FUNCTION_NOT_FOUND",Yt=d(l=>{let e=new Map;if(!Array.isArray(l?.series))return e;for(let s of l.series)e.set(jt(s.kind,s.name,s.attributes),s.points);return e},"Xt"),Jt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=d(l=>{let e=(0,xe.c)(18),{name:s,onOpenTrace:a,traceId:r}=l,h=ge();if(r===void 0){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=c):c=e[0],c}let i;e[1]!==r?(i=r.slice(0,8),e[1]=r,e[2]=i):i=e[2];let n=i;if(a===void 0){let c=`mt-instrument-trace-${s}`,p;return e[3]!==n||e[4]!==c||e[5]!==r?(p=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":c,title:r,children:n}),e[3]=n,e[4]=c,e[5]=r,e[6]=p):p=e[6],p}let g=`mt-instrument-trace-${s}`,v;e[7]!==a||e[8]!==r?(v=d(()=>{a(r)},"v"),e[7]=a,e[8]=r,e[9]=v):v=e[9];let S;e[10]!==h||e[11]!==r?(S=h("Open the exemplar trace {trace}",{trace:r}),e[10]=h,e[11]=r,e[12]=S):S=e[12];let f;return e[13]!==n||e[14]!==g||e[15]!==v||e[16]!==S?(f=(0,t.jsx)("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":g,onClick:v,title:S,type:"button",children:n}),e[13]=n,e[14]=g,e[15]=v,e[16]=S,e[17]=f):f=e[17],f},"Zt"),er=d(l=>{let e=(0,xe.c)(105),{onOpenTrace:s,shardKey:a}=l,r=ge(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={},e[0]=h):h=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];let{data:n,error:g,errorSource:v}=$e(Ke.getMetricSeries,h,i),S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let f;e[4]!==a?(f={live:!0,shardKey:a},e[4]=a,e[5]=f):f=e[5];let{data:c}=$e(Ke.getMetricHistory,S,f),p,N,q,M,o,k,x,b,_,D,u,C,I;if(e[6]!==n||e[7]!==g||e[8]!==v||e[9]!==c||e[10]!==s||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{let A=Wt(n),P=bt(v)===Xt;if(g!==null&&!P){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let j;e[27]!==m?(j=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=j):j=e[28];let E;e[29]!==g||e[30]!==r?(E=r("Instruments unavailable: {error}",{error:g}),e[29]=g,e[30]=r,e[31]=E):E=e[31];let H;e[32]!==E?(H=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:E}),e[32]=E,e[33]=H):H=e[33];let de;e[34]!==j||e[35]!==H?(de=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[j,H]}),e[34]=j,e[35]=H,e[36]=de):de=e[36],b=de;break e}if(A.length===0){b=null;break e}let $=Yt(c),L;e[37]!==r?(L=d(m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),"L"),e[37]=r,e[38]=L):L=e[38];let U=L;o="flex flex-col gap-2",k="mt-instruments";let Q;e[39]!==r?(Q=r("Instruments"),e[39]=r,e[40]=Q):Q=e[40],e[41]!==Q?(x=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:Q}),e[41]=Q,e[42]=x):x=e[42],M=fe,I="overflow-hidden py-0",q=pe,C="px-0",N=st,D="mt-instruments-table";let K;e[43]!==r?(K=r("name"),e[43]=r,e[44]=K):K=e[44];let O;e[45]!==K?(O=(0,t.jsx)(ce,{children:K}),e[45]=K,e[46]=O):O=e[46];let W;e[47]!==r?(W=r("kind"),e[47]=r,e[48]=W):W=e[48];let X;e[49]!==W?(X=(0,t.jsx)(ce,{children:W}),e[49]=W,e[50]=X):X=e[50];let Y;e[51]!==r?(Y=r("value"),e[51]=r,e[52]=Y):Y=e[52];let J;e[53]!==Y?(J=(0,t.jsx)(ce,{className:"text-right",children:Y}),e[53]=Y,e[54]=J):J=e[54];let Z;e[55]!==r?(Z=r("count"),e[55]=r,e[56]=Z):Z=e[56];let ee;e[57]!==Z?(ee=(0,t.jsx)(ce,{className:"text-right",children:Z}),e[57]=Z,e[58]=ee):ee=e[58];let te;e[59]!==r?(te=r("range"),e[59]=r,e[60]=te):te=e[60];let re;e[61]!==te?(re=(0,t.jsx)(ce,{className:"text-right",children:te}),e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==r?(ae=r("trend"),e[63]=r,e[64]=ae):ae=e[64];let se;e[65]!==ae?(se=(0,t.jsx)(ce,{children:ae}),e[65]=ae,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ne;e[69]!==le?(ne=(0,t.jsx)(ce,{children:le}),e[69]=le,e[70]=ne):ne=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let oe;e[73]!==ie?(oe=(0,t.jsx)(ce,{children:ie}),e[73]=ie,e[74]=oe):oe=e[74],e[75]!==O||e[76]!==X||e[77]!==J||e[78]!==ee||e[79]!==re||e[80]!==se||e[81]!==ne||e[82]!==oe?(u=(0,t.jsx)(lt,{children:(0,t.jsxs)(Oe,{children:[O,X,J,ee,re,se,ne,oe]})}),e[75]=O,e[76]=X,e[77]=J,e[78]=ee,e[79]=re,e[80]=se,e[81]=ne,e[82]=oe,e[83]=u):u=e[83],p=nt,_=A.map(m=>{let j=Ft(m.attributes),E=jt(m.kind,m.name,m.attributes),H=($.get(E)??[]).map(de=>Gt(m.kind,de));return(0,t.jsxs)(Oe,{"data-testid":`mt-instrument-${m.name}`,children:[(0,t.jsx)(V,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),(0,t.jsx)(V,{children:(0,t.jsx)(Ge,{variant:Jt[m.kind],children:U(m.kind)})}),(0,t.jsx)(V,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:dt(Vt(m))}),(0,t.jsx)(V,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),(0,t.jsx)(V,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"\u2014":`${dt(m.min)}\u2013${dt(m.max)}`}),(0,t.jsx)(V,{children:H.length>=2?(0,t.jsx)(it,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:H,testId:`mt-instrument-trend-${m.name}`}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(V,{className:"font-mono text-xs",children:(0,t.jsx)(Zt,{name:m.name,onOpenTrace:s,traceId:m.exemplarTraceId})}),(0,t.jsx)(V,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:j,children:j===""?"\u2014":j})]},E)})}e[6]=n,e[7]=g,e[8]=v,e[9]=c,e[10]=s,e[11]=r,e[12]=p,e[13]=N,e[14]=q,e[15]=M,e[16]=o,e[17]=k,e[18]=x,e[19]=b,e[20]=_,e[21]=D,e[22]=u,e[23]=C,e[24]=I}else p=e[12],N=e[13],q=e[14],M=e[15],o=e[16],k=e[17],x=e[18],b=e[19],_=e[20],D=e[21],u=e[22],C=e[23],I=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let R;e[84]!==p||e[85]!==_?(R=(0,t.jsx)(p,{children:_}),e[84]=p,e[85]=_,e[86]=R):R=e[86];let T;e[87]!==N||e[88]!==R||e[89]!==D||e[90]!==u?(T=(0,t.jsxs)(N,{"data-testid":D,children:[u,R]}),e[87]=N,e[88]=R,e[89]=D,e[90]=u,e[91]=T):T=e[91];let w;e[92]!==q||e[93]!==T||e[94]!==C?(w=(0,t.jsx)(q,{className:C,children:T}),e[92]=q,e[93]=T,e[94]=C,e[95]=w):w=e[95];let y;e[96]!==M||e[97]!==w||e[98]!==I?(y=(0,t.jsx)(M,{className:I,children:w}),e[96]=M,e[97]=w,e[98]=I,e[99]=y):y=e[99];let F;return e[100]!==o||e[101]!==k||e[102]!==x||e[103]!==y?(F=(0,t.jsxs)("section",{className:o,"data-testid":k,children:[x,y]}),e[100]=o,e[101]=k,e[102]=x,e[103]=y,e[104]=F):F=e[104],F},"er"),tr=d(l=>{let e=(0,xe.c)(74),{aggregate:s,shardResults:a}=l,r=ge(),h;e[0]!==r?(h=r("Shards"),e[0]=r,e[1]=h):h=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==r?(i=s.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):r("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==h||e[7]!==i?(n=(0,t.jsx)(me,{label:h,testId:"mt-agg-shards",value:i}),e[6]=h,e[7]=i,e[8]=n):n=e[8];let g;e[9]!==r?(g=r("Total requests"),e[9]=r,e[10]=g):g=e[10];let v;e[11]!==s.totalRequests||e[12]!==g?(v=(0,t.jsx)(me,{label:g,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=g,e[13]=v):v=e[13];let S;e[14]!==r?(S=r("Total errors"),e[14]=r,e[15]=S):S=e[15];let f;e[16]!==s.totalErrors||e[17]!==S?(f=(0,t.jsx)(me,{label:S,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=S,e[18]=f):f=e[18];let c;e[19]!==r?(c=r("Total database size"),e[19]=r,e[20]=c):c=e[20];let p;e[21]!==s.totalDatabaseSize?(p=Ve(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=p):p=e[22];let N;e[23]!==c||e[24]!==p?(N=(0,t.jsx)(me,{label:c,testId:"mt-agg-db-size",value:p}),e[23]=c,e[24]=p,e[25]=N):N=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let M;e[28]!==s.hitRate||e[29]!==r?(M=s.hitRate===null?r("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=r,e[30]=M):M=e[30];let o;e[31]!==q||e[32]!==M?(o=(0,t.jsx)(me,{label:q,testId:"mt-agg-cache",value:M}),e[31]=q,e[32]=M,e[33]=o):o=e[33];let k;e[34]!==N||e[35]!==o||e[36]!==n||e[37]!==v||e[38]!==f?(k=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,v,f,N,o]}),e[34]=N,e[35]=o,e[36]=n,e[37]=v,e[38]=f,e[39]=k):k=e[39];let x;e[40]!==r?(x=r("shard"),e[40]=r,e[41]=x):x=e[41];let b;e[42]!==x?(b=(0,t.jsx)(ce,{children:x}),e[42]=x,e[43]=b):b=e[43];let _;e[44]!==r?(_=r("requests"),e[44]=r,e[45]=_):_=e[45];let D;e[46]!==_?(D=(0,t.jsx)(ce,{children:_}),e[46]=_,e[47]=D):D=e[47];let u;e[48]!==r?(u=r("errors"),e[48]=r,e[49]=u):u=e[49];let C;e[50]!==u?(C=(0,t.jsx)(ce,{children:u}),e[50]=u,e[51]=C):C=e[51];let I;e[52]!==r?(I=r("db size"),e[52]=r,e[53]=I):I=e[53];let R;e[54]!==I?(R=(0,t.jsx)(ce,{children:I}),e[54]=I,e[55]=R):R=e[55];let T;e[56]!==b||e[57]!==D||e[58]!==C||e[59]!==R?(T=(0,t.jsx)(lt,{children:(0,t.jsxs)(Oe,{children:[b,D,C,R]})}),e[56]=b,e[57]=D,e[58]=C,e[59]=R,e[60]=T):T=e[60];let w;if(e[61]!==a||e[62]!==r){let P;e[64]!==r?(P=d($=>(0,t.jsxs)(Oe,{"data-testid":`mt-agg-row-${$.shard}`,children:[(0,t.jsx)(V,{children:$.shard}),$.metrics===null?(0,t.jsx)(V,{className:"text-destructive",colSpan:3,children:$.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(V,{className:"tabular-nums",children:$.metrics.requests}),(0,t.jsx)(V,{className:"tabular-nums",children:$.metrics.errors}),(0,t.jsx)(V,{className:"tabular-nums",children:Ve($.metrics.databaseSize)})]})]},$.shard),"z"),e[64]=r,e[65]=P):P=e[65],w=a.map(P),e[61]=a,e[62]=r,e[63]=w}else w=e[63];let y;e[66]!==w?(y=(0,t.jsx)(nt,{children:w}),e[66]=w,e[67]=y):y=e[67];let F;e[68]!==T||e[69]!==y?(F=(0,t.jsx)(fe,{className:"overflow-hidden py-0",children:(0,t.jsx)(pe,{className:"px-0",children:(0,t.jsxs)(st,{"data-testid":"mt-agg-table",children:[T,y]})})}),e[68]=T,e[69]=y,e[70]=F):F=e[70];let A;return e[71]!==k||e[72]!==F?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[k,F]}),e[71]=k,e[72]=F,e[73]=A):A=e[73],A},"tr"),rr=d(l=>{let e=(0,xe.c)(75),{currentDelta:s,errorRate:a,history:r,latencyPercentiles:h,metrics:i}=l,n=ge(),{cache:g}=i,v;e[0]!==r||e[1]!==n?(v=r.length>=2?(0,t.jsx)(it,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=n,e[2]=v):v=e[2];let S;e[3]!==s||e[4]!==r.length||e[5]!==n?(S=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples\u2026")}),e[3]=s,e[4]=r.length,e[5]=n,e[6]=S):S=e[6];let f;e[7]!==n?(f=n("Requests"),e[7]=n,e[8]=f):f=e[8];let c;e[9]!==i.requests||e[10]!==v||e[11]!==S||e[12]!==f?(c=(0,t.jsx)(me,{chart:v,footer:S,label:f,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=v,e[11]=S,e[12]=f,e[13]=c):c=e[13];let p;e[14]!==a||e[15]!==n?(p=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=p):p=e[16];let N;e[17]!==n?(N=n("Errors"),e[17]=n,e[18]=N):N=e[18];let q;e[19]!==a||e[20]!==i.errors?(q=(0,t.jsxs)(t.Fragment,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=q):q=e[21];let M;e[22]!==p||e[23]!==N||e[24]!==q?(M=(0,t.jsx)(me,{footer:p,label:N,testId:"mt-errors",value:q}),e[22]=p,e[23]=N,e[24]=q,e[25]=M):M=e[25];let o;e[26]!==h.p90?(o=h.p90>0?`P90 ${ot(h.p90)}`:void 0,e[26]=h.p90,e[27]=o):o=e[27];let k;e[28]!==n?(k=n("P95 latency"),e[28]=n,e[29]=k):k=e[29];let x;e[30]!==h.p95?(x=h.p95>0?ot(h.p95):"\u2014",e[30]=h.p95,e[31]=x):x=e[31];let b;e[32]!==k||e[33]!==x||e[34]!==o?(b=(0,t.jsx)(me,{footer:o,label:k,testId:"mt-p95",value:x}),e[32]=k,e[33]=x,e[34]=o,e[35]=b):b=e[35];let _;e[36]!==g||e[37]!==n?(_=g?`${g.entries.toLocaleString()} ${n("cache entries")}`:void 0,e[36]=g,e[37]=n,e[38]=_):_=e[38];let D;e[39]!==n?(D=n("Database size"),e[39]=n,e[40]=D):D=e[40];let u;e[41]!==i.databaseSize?(u=Ve(i.databaseSize),e[41]=i.databaseSize,e[42]=u):u=e[42];let C;e[43]!==_||e[44]!==D||e[45]!==u?(C=(0,t.jsx)(me,{footer:_,label:D,testId:"mt-db-size",value:u}),e[43]=_,e[44]=D,e[45]=u,e[46]=C):C=e[46];let I;e[47]!==n?(I=n("Shard"),e[47]=n,e[48]=I):I=e[48];let R;e[49]!==i.shard||e[50]!==I?(R=(0,t.jsx)(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=R):R=e[51];let T;e[52]!==n?(T=n("Uptime"),e[52]=n,e[53]=T):T=e[53];let w;e[54]!==i.uptimeMs?(w=Ot(i.uptimeMs),e[54]=i.uptimeMs,e[55]=w):w=e[55];let y;e[56]!==T||e[57]!==w?(y=(0,t.jsx)(me,{label:T,testId:"mt-uptime",value:w}),e[56]=T,e[57]=w,e[58]=y):y=e[58];let F;e[59]!==n?(F=n("Cache hit rate"),e[59]=n,e[60]=F):F=e[60];let A;e[61]!==g||e[62]!==n?(A=g?n("{rate} ({count} entries)",{count:g.entries,rate:Qt(g.hits,g.misses)}):n("no cache configured"),e[61]=g,e[62]=n,e[63]=A):A=e[63];let P;e[64]!==F||e[65]!==A?(P=(0,t.jsx)(me,{label:F,testId:"mt-cache",value:A}),e[64]=F,e[65]=A,e[66]=P):P=e[66];let $;return e[67]!==b||e[68]!==C||e[69]!==R||e[70]!==y||e[71]!==P||e[72]!==c||e[73]!==M?($=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[c,M,b,C,R,y,P]}),e[67]=b,e[68]=C,e[69]=R,e[70]=y,e[71]=P,e[72]=c,e[73]=M,e[74]=$):$=e[74],$},"rr"),Xe=d(l=>l>=100?"critical":l>=50?"warning":"good","Ge"),je=d(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"Ee"),We=d(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"Ue"),ar=d(l=>{let e=(0,xe.c)(3),{level:s}=l;if(s==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Ge,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(s==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=a):a=e[2],a},"sr"),sr=d((l,e)=>{let s=[...l];return s.sort((a,r)=>{switch(e){case"avgTime":return r.avgDurationMs-a.avgDurationMs;case"execCount":return r.execCount-a.execCount;case"rowsRead":return r.rowsRead-a.rowsRead;default:return r.totalDurationMs-a.totalDurationMs}}),s},"lr"),lr=d(l=>{let e=(0,xe.c)(161),{queryStats:s}=l,a=ge(),[r,h]=(0,B.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[n,g]=(0,B.useState)(i),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=d(I=>{I!==null&&h(I)},"v"),e[1]=v):v=e[1];let S=v,f,c,p,N,q,M,o,k,x,b;if(e[2]!==n||e[3]!==s||e[4]!==r||e[5]!==a){p=Symbol.for("react.early_return_sentinel");e:{let I=sr(s,r),R;e[16]!==s?(R=s.filter(nr),e[16]=s,e[17]=R):R=e[17];let T=R.length,w;e[18]!==s?(w=s.filter(ir),e[18]=s,e[19]=w):w=e[19];let y=w.length,F;e[20]!==s?(F=s.filter(or),e[20]=s,e[21]=F):F=e[21];let A=F.length,P;e[22]===Symbol.for("react.memo_cache_sentinel")?(P=d(z=>{g(ue=>{let G=new Set(ue);return G.has(z)?G.delete(z):G.add(z),G})},"z"),e[22]=P):P=e[22];let $=P;if(s.length===0){let z;e[23]!==a?(z=a("No query insights yet"),e[23]=a,e[24]=z):z=e[24];let ue;e[25]!==z?(ue=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:z}),e[25]=z,e[26]=ue):ue=e[26];let G;e[27]!==a?(G=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=G):G=e[28];let he;e[29]!==G?(he=(0,t.jsx)("p",{className:"mt-1 text-sm",children:G}),e[29]=G,e[30]=he):he=e[30];let Ue;e[31]!==ue||e[32]!==he?(Ue=(0,t.jsx)(fe,{children:(0,t.jsx)(pe,{className:"py-12",children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground",children:[ue,he]})})}),e[31]=ue,e[32]=he,e[33]=Ue):Ue=e[33],p=Ue;break e}o="space-y-4",k="qi-root";let L;e[34]!==a?(L=a("Critical queries"),e[34]=a,e[35]=L):L=e[35];let U;e[36]!==L?(U=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=U):U=e[37];let Q;e[38]!==T?(Q=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:T}),e[38]=T,e[39]=Q):Q=e[39];let K;e[40]!==a?(K=a(">100ms avg execution"),e[40]=a,e[41]=K):K=e[41];let O;e[42]!==K?(O=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:K}),e[42]=K,e[43]=O):O=e[43];let W;e[44]!==Q||e[45]!==O?(W=(0,t.jsxs)(pe,{children:[Q,O]}),e[44]=Q,e[45]=O,e[46]=W):W=e[46];let X;e[47]!==U||e[48]!==W?(X=(0,t.jsxs)(fe,{children:[U,W]}),e[47]=U,e[48]=W,e[49]=X):X=e[49];let Y;e[50]!==a?(Y=a("Moderate queries"),e[50]=a,e[51]=Y):Y=e[51];let J;e[52]!==Y?(J=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:Y})}),e[52]=Y,e[53]=J):J=e[53];let Z;e[54]!==y?(Z=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:y}),e[54]=y,e[55]=Z):Z=e[55];let ee;e[56]!==a?(ee=a("50\u2013100ms avg execution"),e[56]=a,e[57]=ee):ee=e[57];let te;e[58]!==ee?(te=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ee}),e[58]=ee,e[59]=te):te=e[59];let re;e[60]!==Z||e[61]!==te?(re=(0,t.jsxs)(pe,{children:[Z,te]}),e[60]=Z,e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==J||e[64]!==re?(ae=(0,t.jsxs)(fe,{children:[J,re]}),e[63]=J,e[64]=re,e[65]=ae):ae=e[65];let se;e[66]!==a?(se=a("Fast queries"),e[66]=a,e[67]=se):se=e[67];let le;e[68]!==se?(le=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ne;e[70]!==A?(ne=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:A}),e[70]=A,e[71]=ne):ne=e[71];let ie;e[72]!==a?(ie=a("<50ms avg execution"),e[72]=a,e[73]=ie):ie=e[73];let oe;e[74]!==ie?(oe=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=oe):oe=e[75];let m;e[76]!==ne||e[77]!==oe?(m=(0,t.jsxs)(pe,{children:[ne,oe]}),e[76]=ne,e[77]=oe,e[78]=m):m=e[78];let j;e[79]!==le||e[80]!==m?(j=(0,t.jsxs)(fe,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=j):j=e[81],e[82]!==X||e[83]!==ae||e[84]!==j?(x=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[X,ae,j]}),e[82]=X,e[83]=ae,e[84]=j,e[85]=x):x=e[85];let E;e[86]!==a?(E=a("Query leaderboard"),e[86]=a,e[87]=E):E=e[87];let H;e[88]!==E?(H=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:E}),e[88]=E,e[89]=H):H=e[89];let de;e[90]!==r||e[91]!==a?(de=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=de):de=e[92];let be;e[93]!==de?(be=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:de}),e[93]=de,e[94]=be):be=e[94];let ve;e[95]!==H||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[H,be]}),e[95]=H,e[96]=be,e[97]=ve):ve=e[97];let Ne;e[98]!==a?(Ne=a("Sort by"),e[98]=a,e[99]=Ne):Ne=e[99];let ye;e[100]!==Ne?(ye=(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:Ne}),e[100]=Ne,e[101]=ye):ye=e[101];let we;e[102]!==a?(we=a("Sort queries by"),e[102]=a,e[103]=we):we=e[103];let Be;e[104]===Symbol.for("react.memo_cache_sentinel")?(Be=(0,t.jsx)(Rt,{}),e[104]=Be):Be=e[104];let Se;e[105]!==we?(Se=(0,t.jsx)(Tt,{"aria-label":we,className:"w-[140px]","data-testid":"qi-sort",children:Be}),e[105]=we,e[106]=Se):Se=e[106];let qe;e[107]!==a?(qe=a("Total time"),e[107]=a,e[108]=qe):qe=e[108];let ke;e[109]!==qe?(ke=(0,t.jsx)(Qe,{value:"totalTime",children:qe}),e[109]=qe,e[110]=ke):ke=e[110];let _e;e[111]!==a?(_e=a("Avg time"),e[111]=a,e[112]=_e):_e=e[112];let Me;e[113]!==_e?(Me=(0,t.jsx)(Qe,{value:"avgTime",children:_e}),e[113]=_e,e[114]=Me):Me=e[114];let De;e[115]!==a?(De=a("Execution count"),e[115]=a,e[116]=De):De=e[116];let Ce;e[117]!==De?(Ce=(0,t.jsx)(Qe,{value:"execCount",children:De}),e[117]=De,e[118]=Ce):Ce=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Re;e[121]!==Ie?(Re=(0,t.jsx)(Qe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Re):Re=e[122];let Te;e[123]!==ke||e[124]!==Me||e[125]!==Ce||e[126]!==Re?(Te=(0,t.jsxs)(zt,{children:[ke,Me,Ce,Re]}),e[123]=ke,e[124]=Me,e[125]=Ce,e[126]=Re,e[127]=Te):Te=e[127];let ze;e[128]!==r||e[129]!==Se||e[130]!==Te?(ze=(0,t.jsxs)(It,{onValueChange:S,value:r,children:[Se,Te]}),e[128]=r,e[129]=Se,e[130]=Te,e[131]=ze):ze=e[131];let Fe;e[132]!==ye||e[133]!==ze?(Fe=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[ye,ze]}),e[132]=ye,e[133]=ze,e[134]=Fe):Fe=e[134],e[135]!==ve||e[136]!==Fe?(b=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,Fe]}),e[135]=ve,e[136]=Fe,e[137]=b):b=e[137],c=fe;let Le;e[138]!==a?(Le=a("Statements"),e[138]=a,e[139]=Le):Le=e[139];let Ee;e[140]!==Le?(Ee=(0,t.jsx)(Pe,{children:Le}),e[140]=Le,e[141]=Ee):Ee=e[141],M=(0,t.jsxs)(Ae,{children:[Ee,(0,t.jsx)(ht,{children:a("{count} tracked statements",{count:I.length})})]}),f=pe,N="space-y-2";let He;e[142]!==n||e[143]!==a?(He=d(z=>{let ue=z.normalizedSql,G=n.has(ue),he=Xe(z.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":G,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:d(()=>{$(ue)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(ar,{level:he}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:z.normalizedSql})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.totalDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),z.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.p95DurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:We(z.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),G&&(0,t.jsxs)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),(0,t.jsx)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:z.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[z.p50DurationMs!==void 0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("p50")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:je(z.p50DurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Exec count")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.execCount)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Total time")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:je(z.totalDurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows read")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.rowsRead)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows written")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.rowsWritten)})]})]})]})]},ue)},"Ke"),e[142]=n,e[143]=a,e[144]=He):He=e[144],q=I.map(He)}e[2]=n,e[3]=s,e[4]=r,e[5]=a,e[6]=f,e[7]=c,e[8]=p,e[9]=N,e[10]=q,e[11]=M,e[12]=o,e[13]=k,e[14]=x,e[15]=b}else f=e[6],c=e[7],p=e[8],N=e[9],q=e[10],M=e[11],o=e[12],k=e[13],x=e[14],b=e[15];if(p!==Symbol.for("react.early_return_sentinel"))return p;let _;e[145]!==N||e[146]!==q?(_=(0,t.jsx)("div",{className:N,children:q}),e[145]=N,e[146]=q,e[147]=_):_=e[147];let D;e[148]!==f||e[149]!==_?(D=(0,t.jsx)(f,{children:_}),e[148]=f,e[149]=_,e[150]=D):D=e[150];let u;e[151]!==c||e[152]!==D||e[153]!==M?(u=(0,t.jsxs)(c,{children:[M,D]}),e[151]=c,e[152]=D,e[153]=M,e[154]=u):u=e[154];let C;return e[155]!==u||e[156]!==o||e[157]!==k||e[158]!==x||e[159]!==b?(C=(0,t.jsxs)("div",{className:o,"data-testid":k,children:[x,b,u]}),e[155]=u,e[156]=o,e[157]=k,e[158]=x,e[159]=b,e[160]=C):C=e[160],C},"ar");function nr(l){return Xe(l.avgDurationMs)==="critical"}d(nr,"ir");function ir(l){return Xe(l.avgDurationMs)==="warning"}d(ir,"nr");function or(l){return Xe(l.avgDurationMs)==="good"}d(or,"or");var dr=["1m","5m","15m","1h"],cr=d(l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"dr"),mr=d(l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:cr(e.bucketMs)})),"mr"),ur=d(({shardKey:l=""})=>{let e=ge(),[s,a]=(0,B.useState)("15m"),r=$e(Ke.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,h=mr(r?.buckets??[]);return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:dr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===s,className:ut("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:d(()=>{a(i)},"onClick"),type:"button",children:i},i))}),r?.capped===!0&&(0,t.jsx)(Ge,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),h.length===0?(0,t.jsx)(gt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):(0,t.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(St,{data:h,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(yt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(wt,{data:h,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(Nt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(lr,{queryStats:r?.entries??[]})]})},"ur"),hr=ft(Ke.getMetrics),gr=d((l,e)=>l?e:"overview","hr"),Or=d(({initialShardKey:l})=>{let e=mt(),s=ge(),{queryShardKey:a,setShardKey:r,shardKey:h}=Mt(l),[i,n]=(0,B.useState)("overview"),[g,v]=(0,B.useState)([]),S=(0,B.useRef)(null),f=(0,B.useRef)(null),c=(0,B.useRef)(!0);(0,B.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=Lt(a),{data:N,error:q,liveError:M}=$e(Ke.getMetrics,{},{live:!0,shardKey:a}),o=N??null;(0,B.useEffect)(()=>{if(N===void 0)return;kt(a);let L=N,U=S.current,Q=f.current!==null&&f.current!==L.shard;if(f.current=L.shard,S.current=L.requests,Q){v([]);return}U!==null&&L.requests>=U&&v(K=>[...K,L.requests-U].slice(-30))},[N,a]);let[k,x]=(0,B.useState)(null),[b,_]=(0,B.useState)(!1),D=d(async()=>{_(!0);let L=h,U=At(L,qt());try{let Q=await Promise.all(U.map(async K=>{try{let O=await e.query(hr,{},pt(K));return{error:null,metrics:O,shard:K===""?O.shard:K}}catch(O){return{error:xt(O),metrics:null,shard:K===""?"__root__":K}}}));c.current&&x({results:Q,shard:L})}finally{c.current&&_(!1)}},"R"),u=k?.shard===h?k.results:null,C=u===null?null:Kt(u),I=o===null||o.requests===0?"\u2014":`${(o.errors/o.requests*100).toFixed(1)}%`,R=g.length>0?g.at(-1):0,T=o?Pt(o):{p90:0,p95:0},w=(0,B.useMemo)(()=>{if(!o||!("queryStats"in o))return;let L=o.queryStats;if(!(!L||!Array.isArray(L)))return $t(L)},[o]),y=gr(w!==void 0,i),F=d(()=>{vt(D())},"A"),A=d(()=>{x(null)},"F"),P=d(()=>{n("overview")},"z"),$=d(()=>{n("query-insights")},"O");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(_t,{onChange:r,testId:"mt-shard-input",value:h}),(0,t.jsx)(Dt,{message:M,prefix:"mt"}),(0,t.jsx)(Je,{"data-testid":"mt-aggregate",disabled:b,onClick:F,size:"sm",type:"button",variant:"secondary",children:s(b?"Aggregating\u2026":"All shards")}),u!==null&&(0,t.jsx)(Je,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")}),(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:Ct,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")})]}),q!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),w!==void 0&&(0,t.jsxs)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsx)("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:P,type:"button",children:s("Overview")}),(0,t.jsxs)("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:$,type:"button",children:[s("Query insights"),w.length>0&&(0,t.jsx)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:w.length})]})]}),y==="query-insights"&&w!==void 0&&(0,t.jsx)(ur,{shardKey:a}),y==="overview"&&o!==null&&(0,t.jsx)(rr,{currentDelta:R,errorRate:I,history:g,latencyPercentiles:T,metrics:o}),y==="overview"&&o===null&&null,y==="overview"&&(0,t.jsx)(er,{onOpenTrace:p,shardKey:a}),y==="overview"&&C!==null&&u!==null&&(0,t.jsx)(tr,{aggregate:C,shardResults:u})]})},"Qr");export{Or as MetricsPanel};
@@ -1 +1 @@
1
- import{a as ae}from"./chunk-FPI7AMQJ.js";import{a as A}from"./chunk-37WYCOQ2.js";import{a as re}from"./chunk-LXCVA5SP.js";import{a as te}from"./chunk-7Q256NLI.js";import{b as ee}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as W}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as w}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as O}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as Q}from"./chunk-4ZEL6BYL.js";import{c as I,d as P,l as U}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{d as q,e as G,f as V,h as j,n as H,q as X,u as Y}from"./chunk-74IYYDDI.js";import{a as o,d as M,e as he,g as ge}from"./chunk-I26MS5PJ.js";var c=M(he(),1);var a=M(ge(),1);var be=o(t=>t.kind==="id"?t.table===void 0?"id":`id<${t.table}>`:t.kind==="array"?t.element===void 0?"array":`${t.element}[]`:t.kind,"me"),xe=o(t=>t===void 0||t.length===0?"()":`(${t.map(e=>`${e.name}${e.optional?"?":""}: ${be(e)}`).join(", ")})`,"ge"),ye=o(t=>{switch(t){case"array":return[];case"bigint":return I(0n);case"boolean":return!1;case"bytes":return I(new ArrayBuffer(0));case"number":return 0;case"object":case"record":return{};default:return""}},"be"),ve=o(t=>{let e={};for(let r of t??[])r.optional||(e[r.name]=ye(r.kind));return JSON.stringify(e,void 0,2)},"xe"),Ne=V(Q.runAs),h="\xABsensitive\xBB",we=o(t=>(t??[]).filter(e=>e.sensitive===!0).map(e=>e.name),"ve"),Ae=o((t,e)=>{if(e.length===0)return t;try{let r=JSON.parse(t);if(typeof r!="object"||r===null||Array.isArray(r))return"";let l={...r};for(let i of e)Object.hasOwn(l,i)&&(l[i]=h);return JSON.stringify(l,null,2)}catch{return""}},"Ne"),Se=4,ke=o(t=>{let e=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}},"Se"),$e=o(t=>Array.isArray(t)?[]:Object.keys(t).filter(e=>e.length>0),"we"),Ie=o(t=>{let e=[],r=new Set,l=[t];for(;l.length>0;){let i=l.pop();if(typeof i=="string")i.length>0&&e.push(i);else if(typeof i=="number"||typeof i=="bigint")e.push(String(i));else if(i instanceof ArrayBuffer||ArrayBuffer.isView(i)){let u=ke(i);u!==void 0&&u.length>0&&e.push(u)}else typeof i=="object"&&i!==null&&!r.has(i)&&(r.add(i),e.push(...$e(i)),l.push(...Object.values(i)))}return e},"ke"),Oe=o((t,e)=>{let r=[],l=new Set,i=[[t,e]];for(;i.length>0;){let[u,n]=i.pop()??[void 0,void 0];typeof n=="boolean"?r.push({key:u,text:n?"true":"false"}):typeof n=="object"&&n!==null&&!l.has(n)&&(l.add(n),Array.isArray(n)?i.push(...n.map(p=>[void 0,p])):i.push(...Object.entries(n)))}return r},"Re"),se=o(t=>t.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`),"P"),je=o((t,e)=>e.length>=Se?t.replaceAll(e,h):t.replaceAll(new RegExp(`(?<![A-Za-z0-9])${se(e)}(?![A-Za-z0-9])`,"gu"),h),"Oe"),Re=o((t,e)=>{let r=t.replaceAll(`"${e.text}"`,h);if(e.key===void 0)return r;let l=se(e.key);return r.replaceAll(new RegExp(`(?<![A-Za-z0-9_])${l}=${e.text}(?![A-Za-z0-9_])`,"gu"),`${e.key}=${h}`).replaceAll(new RegExp(String.raw`"${l}":\s*${e.text}(?![A-Za-z0-9_])`,"gu"),`"${e.key}":${h}`)},"Ie"),Ce=o((t,e,r)=>{if(r.length===0||typeof e!="object"||e===null)return t;let l=r.flatMap(n=>Oe(n,e[n])),i=r.flatMap(n=>Ie(e[n])).flatMap(n=>{let p=JSON.stringify(n).slice(1,-1);return p===n?[n]:[n,p]}).toSorted((n,p)=>p.length-n.length),u=t;for(let n of l)u=Re(u,n);for(let n of i)u=je(u,n);return u},"$e"),Te=10,Fe=o(t=>t===void 0?"undefined":JSON.stringify(t,H,2),"Ee"),ze=o((t,e)=>[{argsText:Ae(e.argsText,e.sensitive),at:Date.now(),id:(t[0]?.id??0)+1,kind:e.selected.kind,path:e.selected.path,redacted:e.sensitive.length>0,shardKey:e.shardKey,status:e.runStatus},...t].slice(0,Te),"je"),Ge=o(({functions:t,runAsIdentity:e=!1}={})=>{let r=q(),l=U(),[i,u]=(0,c.useState)(null),[n,p]=(0,c.useState)(null),S=t??i??[],[R,C]=(0,c.useState)(""),[y,k]=(0,c.useState)("{}"),[g,T]=(0,c.useState)(""),[b,ne]=(0,c.useState)(""),[$,x]=(0,c.useState)("idle"),[ie,v]=(0,c.useState)(void 0),[F,N]=(0,c.useState)(null),[z,oe]=(0,c.useState)([]);(0,c.useEffect)(()=>{if(t!==void 0)return;let s=!1;return l.listFunctions().then(f=>(s||u(f),f)).catch(f=>{s||p(j(f))}),()=>{s=!0}},[l,t]);let B=R===""?S[0]?.path??"":R,d=S.find(s=>s.path===B),le=o(async()=>{if(!d)return;let s;try{s=y.trim()===""?{}:P(JSON.parse(y))}catch(m){x("error"),v(void 0),N(r("Invalid JSON args: {message}",{message:m.message}));return}let f={__lunoraRef:d.path},E=g.trim()===""?{}:{shardKey:g.trim()},K=e?b.trim():"",Z=we(d.args),D=o(m=>{oe(me=>ze(me,{argsText:y,runStatus:m,selected:d,sensitive:Z,shardKey:g}))},"M");x("running"),N(null);try{let m=K===""?await G(l,d.kind,f,s,E):await l.query(Ne,{args:s,functionPath:d.path,userId:K},E);ee(g),v(m),x("success"),D("success")}catch(m){v(void 0),N(Ce(j(m),s,Z)),x("error"),D("error")}},"H"),de=o(s=>{if(C(s.path),T(s.shardKey),s.redacted){v(void 0),N(r("Re-enter the sensitive values before running this again.")),x("error");return}k(s.argsText)},"G"),ue=o(s=>{C(s.target.value)},"W"),ce=o(s=>{k(s.target.value)},"X"),fe=o(s=>{ne(s.target.value)},"Y"),J=o(()=>{X(le())},"C"),L=e?b.trim():"",_=$==="running"||d===void 0,pe=o(()=>{k(ve(d?.args))},"_");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[n!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:n}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(A,{htmlFor:"function-select",children:r("Function")}),(0,a.jsx)("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:ue,value:B,children:S.map(s=>(0,a.jsxs)("option",{value:s.path,children:[s.path," (",s.kind,")"]},s.path))}),d!==void 0&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"mr-1.5 font-medium",children:r("Signature")}),(0,a.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:xe(d.args)})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)(A,{htmlFor:"args-input",children:r("Arguments")}),(0,a.jsx)(w,{"data-testid":"prefill-button",disabled:d===void 0,onClick:pe,size:"xs",type:"button",variant:"ghost",children:r("Prefill")})]}),(0,a.jsx)(ae,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:ce,value:y})]}),(0,a.jsx)(te,{onChange:T,testId:"shard-input",value:g}),e&&(0,a.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,a.jsx)(A,{htmlFor:"run-as-input",children:r("Run as identity (userId)")}),(0,a.jsx)(W,{"aria-label":r("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:fe,placeholder:r("Leave empty to run as admin"),value:b}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground",children:r("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[L!==""&&d!==void 0&&d.kind!=="query"?(0,a.jsx)(re,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:d.path,userId:L}),disabled:_,onConfirm:J,testId:"run-button",children:r("Run")}):(0,a.jsx)(w,{"data-testid":"run-button",disabled:_,onClick:J,type:"button",children:r("Run")}),d!==void 0&&(0,a.jsx)(O,{variant:"outline",children:d.kind}),e&&b.trim()!==""&&(0,a.jsx)(O,{"data-testid":"run-as-badge",variant:"secondary",children:r("as {userId}",{userId:b.trim()})})]})]}),$==="error"&&F!==null&&(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:F}),$==="success"&&(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:Fe(ie)}),z.length>0&&(0,a.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:z.map((s,f)=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,a.jsx)("span",{className:s.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${f.toString()}`,children:s.status==="success"?"\u2713":"\u2717"})," ",(0,a.jsxs)("span",{className:"font-mono text-xs",children:[s.path," (",s.kind,")"]})," ",(0,a.jsx)("time",{className:"text-xs text-muted-foreground",children:Y(s.at)})," ",(0,a.jsx)(w,{className:"ml-auto","data-testid":`fn-history-load-${f.toString()}`,onClick:o(()=>{de(s)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Load")})]},s.id))})]})},"Ge");export{Ge as FunctionRunner};
1
+ import{a as ae}from"./chunk-FPI7AMQJ.js";import{a as A}from"./chunk-37WYCOQ2.js";import{a as re}from"./chunk-LXCVA5SP.js";import{a as te}from"./chunk-7Q256NLI.js";import{b as ee}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as W}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as w}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as O}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as Q}from"./chunk-4ZEL6BYL.js";import{c as I,d as P,l as U}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{d as q,e as G,f as V,h as j,n as H,q as X,u as Y}from"./chunk-74IYYDDI.js";import{a as o,d as M,e as he,g as ge}from"./chunk-I26MS5PJ.js";var c=M(he(),1);var a=M(ge(),1);var be=o(t=>t.kind==="id"?t.table===void 0?"id":`id<${t.table}>`:t.kind==="array"?t.element===void 0?"array":`${t.element}[]`:t.kind,"me"),xe=o(t=>t===void 0||t.length===0?"()":`(${t.map(e=>`${e.name}${e.optional?"?":""}: ${be(e)}`).join(", ")})`,"ge"),ye=o(t=>{switch(t){case"array":return[];case"bigint":return I(0n);case"boolean":return!1;case"bytes":return I(new ArrayBuffer(0));case"number":return 0;case"object":case"record":return{};default:return""}},"be"),ve=o(t=>{let e={};for(let r of t??[])r.optional||(e[r.name]=ye(r.kind));return JSON.stringify(e,void 0,2)},"xe"),Ne=V(Q.runAs),h="\xABsensitive\xBB",we=o(t=>(t??[]).filter(e=>e.sensitive===!0).map(e=>e.name),"ve"),Ae=o((t,e)=>{if(e.length===0)return t;try{let r=JSON.parse(t);if(typeof r!="object"||r===null||Array.isArray(r))return"";let l={...r};for(let i of e)Object.hasOwn(l,i)&&(l[i]=h);return JSON.stringify(l,null,2)}catch{return""}},"Ne"),Se=4,ke=o(t=>{let e=t instanceof ArrayBuffer?new Uint8Array(t):new Uint8Array(t.buffer,t.byteOffset,t.byteLength);try{return new TextDecoder("utf-8",{fatal:!0}).decode(e)}catch{return}},"Se"),$e=o(t=>Array.isArray(t)?[]:Object.keys(t).filter(e=>e.length>0),"we"),Ie=o(t=>{let e=[],r=new Set,l=[t];for(;l.length>0;){let i=l.pop();if(typeof i=="string")i.length>0&&e.push(i);else if(typeof i=="number"||typeof i=="bigint")e.push(String(i));else if(i instanceof ArrayBuffer||ArrayBuffer.isView(i)){let u=ke(i);u!==void 0&&u.length>0&&e.push(u)}else typeof i=="object"&&i!==null&&!r.has(i)&&(r.add(i),e.push(...$e(i)),l.push(...Object.values(i)))}return e},"ke"),Oe=o((t,e)=>{let r=[],l=new Set,i=[[t,e]];for(;i.length>0;){let[u,n]=i.pop()??[void 0,void 0];typeof n=="boolean"?r.push({key:u,text:n?"true":"false"}):typeof n=="object"&&n!==null&&!l.has(n)&&(l.add(n),Array.isArray(n)?i.push(...n.map(p=>[void 0,p])):i.push(...Object.entries(n)))}return r},"Re"),se=o(t=>t.replaceAll(/[$()*+.?[\\\]^{|}]/gu,String.raw`\$&`),"P"),je=o((t,e)=>e.length>=Se?t.replaceAll(e,h):t.replaceAll(new RegExp(`(?<![A-Za-z0-9])${se(e)}(?![A-Za-z0-9])`,"gu"),h),"Oe"),Re=o((t,e)=>{let r=t.replaceAll(`"${e.text}"`,h);if(e.key===void 0)return r;let l=se(e.key);return r.replaceAll(new RegExp(`(?<![A-Za-z0-9_])${l}=${e.text}(?![A-Za-z0-9_])`,"gu"),`${e.key}=${h}`).replaceAll(new RegExp(String.raw`"${l}":\s*${e.text}(?![A-Za-z0-9_])`,"gu"),`"${e.key}":${h}`)},"Ie"),Ce=o((t,e,r)=>{if(r.length===0||typeof e!="object"||e===null)return t;let l=r.flatMap(n=>Oe(n,e[n])),i=r.flatMap(n=>Ie(e[n])).flatMap(n=>{let p=JSON.stringify(n).slice(1,-1);return p===n?[n]:[n,p]}).toSorted((n,p)=>p.length-n.length),u=t;for(let n of l)u=Re(u,n);for(let n of i)u=je(u,n);return u},"$e"),Te=10,Fe=o(t=>t===void 0?"undefined":JSON.stringify(t,H,2),"Ee"),ze=o((t,e)=>[{argsText:Ae(e.argsText,e.sensitive),at:Date.now(),id:(t[0]?.id??0)+1,kind:e.selected.kind,path:e.selected.path,redacted:e.sensitive.length>0,shardKey:e.shardKey,status:e.runStatus},...t].slice(0,Te),"je"),Ge=o(({functions:t,runAsIdentity:e=!1}={})=>{let r=q(),l=U(),[i,u]=(0,c.useState)(null),[n,p]=(0,c.useState)(null),S=t??i??[],[R,C]=(0,c.useState)(""),[y,k]=(0,c.useState)("{}"),[g,T]=(0,c.useState)(""),[b,ne]=(0,c.useState)(""),[$,x]=(0,c.useState)("idle"),[ie,v]=(0,c.useState)(void 0),[F,N]=(0,c.useState)(null),[z,oe]=(0,c.useState)([]);(0,c.useEffect)(()=>{if(t!==void 0)return;let s=!1;return l.listFunctions().then(f=>(s||u(f),f)).catch(f=>{s||p(j(f))}),()=>{s=!0}},[l,t]);let B=R===""?S[0]?.path??"":R,d=S.find(s=>s.path===B),le=o(async()=>{if(!d)return;let s;try{s=y.trim()===""?{}:P(JSON.parse(y))}catch(m){x("error"),v(void 0),N(r("Invalid JSON args: {message}",{message:m.message}));return}let f={__lunoraRef:d.path},E=g.trim()===""?{}:{shardKey:g.trim()},K=e?b.trim():"",Z=we(d.args),D=o(m=>{oe(me=>ze(me,{argsText:y,runStatus:m,selected:d,sensitive:Z,shardKey:g}))},"M");x("running"),N(null);try{let m=K===""?await G(l,d.kind,f,s,E):await l.query(Ne,{args:s,functionPath:d.path,userId:K},E);ee(g),v(m),x("success"),D("success")}catch(m){v(void 0),N(Ce(j(m),s,Z)),x("error"),D("error")}},"H"),de=o(s=>{if(C(s.path),T(s.shardKey),s.redacted){v(void 0),N(r("Re-enter the sensitive values before running this again.")),x("error");return}k(s.argsText)},"G"),ue=o(s=>{C(s.target.value)},"W"),ce=o(s=>{k(s.target.value)},"X"),fe=o(s=>{ne(s.target.value)},"Y"),J=o(()=>{X(le())},"C"),L=e?b.trim():"",_=$==="running"||d===void 0,pe=o(()=>{k(ve(d?.args))},"_");return(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[n!==null&&(0,a.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:n}),(0,a.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(A,{htmlFor:"function-select",children:r("Function")}),(0,a.jsx)("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:ue,value:B,children:S.map(s=>(0,a.jsxs)("option",{value:s.path,children:[s.path," (",s.kind,")"]},s.path))}),d!==void 0&&(0,a.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,a.jsx)("span",{className:"mr-1.5 font-medium",children:r("Signature")}),(0,a.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:xe(d.args)})]})]}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,a.jsx)(A,{htmlFor:"args-input",children:r("Arguments")}),(0,a.jsx)(w,{"data-testid":"prefill-button",disabled:d===void 0,onClick:pe,size:"xs",type:"button",variant:"ghost",children:r("Prefill")})]}),(0,a.jsx)(ae,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:ce,value:y})]}),(0,a.jsx)(te,{onChange:T,testId:"shard-input",value:g}),e&&(0,a.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,a.jsx)(A,{htmlFor:"run-as-input",children:r("Run as identity (userId)")}),(0,a.jsx)(W,{"aria-label":r("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:fe,placeholder:r("Leave empty to run as admin"),value:b}),(0,a.jsx)("p",{className:"text-[11px] text-muted-foreground",children:r("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[L!==""&&d!==void 0&&d.kind!=="query"?(0,a.jsx)(re,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:d.path,userId:L}),disabled:_,onConfirm:J,testId:"run-button",children:r("Run")}):(0,a.jsx)(w,{"data-testid":"run-button",disabled:_,onClick:J,type:"button",children:r("Run")}),d!==void 0&&(0,a.jsx)(O,{variant:"outline",children:d.kind}),e&&b.trim()!==""&&(0,a.jsx)(O,{"data-testid":"run-as-badge",variant:"secondary",children:r("as {userId}",{userId:b.trim()})})]})]}),$==="error"&&F!==null&&(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:F}),$==="success"&&(0,a.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:Fe(ie)}),z.length>0&&(0,a.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:z.map((s,f)=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,a.jsx)("span",{className:s.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${f.toString()}`,children:s.status==="success"?"\u2713":"\u2717"})," ",(0,a.jsxs)("span",{className:"font-mono text-xs",children:[s.path," (",s.kind,")"]})," ",(0,a.jsx)("time",{className:"text-xs text-muted-foreground",children:Y(s.at)})," ",(0,a.jsx)(w,{className:"ml-auto","data-testid":`fn-history-load-${f.toString()}`,onClick:o(()=>{de(s)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Load")})]},s.id))})]})},"Ge");export{Ge as FunctionRunner};
@@ -1 +1 @@
1
- import{a as N}from"./chunk-XC2LTW44.js";import{a as v,b as w,c as y,d,e as c,f as i}from"./chunk-HCTJKP5J.js";import{a as x,e as b}from"./chunk-2IKDEUCX.js";import{d as h}from"./chunk-74IYYDDI.js";import{a,d as p,e as I,g as R,i as g}from"./chunk-I26MS5PJ.js";var $=p(I(),1);var e=p(R(),1);var A={ERROR:"error",INFO:"info",WARN:"warning"},q=a(r=>{let n=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:n,issueType:r.title,key:r.cacheKey,level:A[r.level]}},"z"),C=["error","warning","info"],O={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},S=a((r,n)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[n],"$"),j=a((r,n,o)=>({error:r("{count} errors",{count:o}),info:r("{count} suggestions",{count:o}),warning:r("{count} warnings",{count:o})})[n],"k"),z=a((r,n)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[n],"V"),F=a(r=>{let n={error:0,info:0,warning:0};for(let o of r??[])n[o.level]+=1;return n},"O"),B=a(({error:r=null,errorSource:n,rows:o,testId:l,toolbar:f})=>{let s=h(),[m,k]=(0,$.useState)("error"),T=F(o),u=(o??[]).filter(t=>t.level===m),E=a(t=>{k(t.currentTarget.dataset.level)},"h");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:C.map(t=>(0,e.jsxs)("button",{"aria-selected":m===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:E,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:g("size-2 rounded-sm",O[t])}),S(s,t)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:j(s,t,T[t])})]},t))}),f!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:f}),r!==null&&(0,e.jsx)(N,{error:n??r,testId:`${l}-error`}),(0,e.jsx)(x,{className:"overflow-hidden py-0",children:(0,e.jsx)(b,{className:"px-0",children:(0,e.jsxs)(v,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(d,{children:[(0,e.jsx)(c,{children:s("Issue type")}),(0,e.jsx)(c,{children:s("Entity/item")}),(0,e.jsx)(c,{children:s("Description")})]})}),(0,e.jsx)(y,{children:u.length===0?(0,e.jsx)(d,{children:(0,e.jsxs)(i,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:z(s,m)}),(0,e.jsx)("span",{className:"block text-sm",children:s("Nothing to report for this deployment.")})]})}):u.map(t=>(0,e.jsxs)(d,{children:[(0,e.jsx)(i,{className:"font-medium text-foreground",children:t.issueType}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"}),(0,e.jsxs)(i,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:t.description}),t.action!==void 0&&(0,e.jsx)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action})]})]},t.key))})]})})})]})},"F");export{q as a,B as b};
1
+ import{a as N}from"./chunk-M27YVZWM.js";import{a as v,b as w,c as y,d,e as c,f as i}from"./chunk-HCTJKP5J.js";import{a as x,e as b}from"./chunk-2IKDEUCX.js";import{d as h}from"./chunk-74IYYDDI.js";import{a,d as p,e as I,g as R,i as g}from"./chunk-I26MS5PJ.js";var $=p(I(),1);var e=p(R(),1);var A={ERROR:"error",INFO:"info",WARN:"warning"},q=a(r=>{let n=typeof r.metadata.table=="string"?r.metadata.table:void 0;return{description:`${r.detail} ${r.remediation}`,entity:n,issueType:r.title,key:r.cacheKey,level:A[r.level]}},"z"),C=["error","warning","info"],O={error:"bg-destructive",info:"bg-info",warning:"bg-warning"},S=a((r,n)=>({error:r("Errors"),info:r("Info"),warning:r("Warnings")})[n],"$"),j=a((r,n,o)=>({error:r("{count} errors",{count:o}),info:r("{count} suggestions",{count:o}),warning:r("{count} warnings",{count:o})})[n],"k"),z=a((r,n)=>({error:r("No errors detected"),info:r("No suggestions"),warning:r("No warnings detected")})[n],"V"),F=a(r=>{let n={error:0,info:0,warning:0};for(let o of r??[])n[o.level]+=1;return n},"O"),B=a(({error:r=null,errorSource:n,rows:o,testId:l,toolbar:f})=>{let s=h(),[m,k]=(0,$.useState)("error"),T=F(o),u=(o??[]).filter(t=>t.level===m),E=a(t=>{k(t.currentTarget.dataset.level)},"h");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":l,children:[(0,e.jsx)("div",{className:"flex border-b border-border",role:"tablist",children:C.map(t=>(0,e.jsxs)("button",{"aria-selected":m===t,className:"flex min-w-32 flex-col gap-0.5 border-b-2 border-transparent px-4 py-2 text-start outline-none transition-colors hover:bg-muted/40 focus-visible:bg-muted/40 aria-selected:border-foreground","data-level":t,"data-testid":`${l}-tab-${t}`,onClick:E,role:"tab",type:"button",children:[(0,e.jsxs)("span",{className:"flex items-center gap-2 text-sm font-medium text-foreground",children:[(0,e.jsx)("span",{"aria-hidden":"true",className:g("size-2 rounded-sm",O[t])}),S(s,t)]}),(0,e.jsx)("span",{className:"ps-4 text-xs text-muted-foreground",children:j(s,t,T[t])})]},t))}),f!==void 0&&(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:f}),r!==null&&(0,e.jsx)(N,{error:n??r,testId:`${l}-error`}),(0,e.jsx)(x,{className:"overflow-hidden py-0",children:(0,e.jsx)(b,{className:"px-0",children:(0,e.jsxs)(v,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(d,{children:[(0,e.jsx)(c,{children:s("Issue type")}),(0,e.jsx)(c,{children:s("Entity/item")}),(0,e.jsx)(c,{children:s("Description")})]})}),(0,e.jsx)(y,{children:u.length===0?(0,e.jsx)(d,{children:(0,e.jsxs)(i,{className:"h-40 text-center align-middle text-muted-foreground",colSpan:3,"data-testid":`${l}-empty`,children:[(0,e.jsx)("span",{className:"block text-sm font-medium text-foreground",children:z(s,m)}),(0,e.jsx)("span",{className:"block text-sm",children:s("Nothing to report for this deployment.")})]})}):u.map(t=>(0,e.jsxs)(d,{children:[(0,e.jsx)(i,{className:"font-medium text-foreground",children:t.issueType}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.entity??"\u2014"}),(0,e.jsxs)(i,{className:"text-muted-foreground",children:[(0,e.jsx)("span",{children:t.description}),t.action!==void 0&&(0,e.jsx)("span",{className:"mt-1.5 flex flex-wrap items-center gap-1.5",children:t.action})]})]},t.key))})]})})})]})},"F");export{q as a,B as b};
@@ -1 +1 @@
1
- import{a as Ot}from"./chunk-FPI7AMQJ.js";import{a as Et}from"./chunk-5UDEPHRK.js";import{a as me}from"./chunk-WVWCUB4S.js";import{a as Lt}from"./chunk-QJLHH3ET.js";import{a as Mt}from"./chunk-37WYCOQ2.js";import{a as _t,b as jt}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as be,b as Ft}from"./chunk-ZRFRFHRU.js";import{i as X}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as L}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as he}from"./chunk-YSPQIRER.js";import{l as oe}from"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as ge}from"./chunk-RWVIV3U7.js";import{a as Nt,b as At,c as Dt,d as Ve,e as de,f as ce}from"./chunk-HCTJKP5J.js";import{a as zt,e as kt}from"./chunk-2IKDEUCX.js";import{d as Q,h as Rt,p as D,q as St,u as $t}from"./chunk-74IYYDDI.js";import{a as m,d as wt,e as Yt,f as qt,g as Gt}from"./chunk-I26MS5PJ.js";var H=wt(qt(),1);var E=wt(Yt(),1);var l=wt(Gt(),1);var Kt=m(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Pt"),Wt=m(t=>{let e=Kt(t),r={};for(let[c,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${c}" must map to an array of action strings`);r[c]=h}return r},"qt"),Qt=m(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"jt"),W=m(t=>{let e=(0,H.c)(6),{children:r,htmlFor:c,label:h}=t,i;e[0]!==c||e[1]!==h?(i=(0,l.jsx)(Mt,{htmlFor:c,children:h}),e[0]=c,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"W"),ue=m(({busy:t,canSubmit:e,children:r,destructive:c=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:n,title:d})=>{let s=Q();return(0,l.jsxs)(Lt,{label:d,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,l.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:d}),r,h!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,l.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,l.jsx)(L,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,l.jsx)(L,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:c?"destructive":"default",children:t?s("Saving\u2026"):a})]})]})},"de"),Pt=m(t=>{let e=(0,H.c)(79),{mode:r,onClose:c,onDone:h,org:i}=t,o=oe(),a=Q(),{busy:n,error:d,run:s}=me(),p;e[0]!==i?(p=i?D(i.name):"",e[0]=i,e[1]=p):p=e[1];let[u,b]=(0,E.useState)(p),v;e[2]!==i?(v=i?D(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,f]=(0,E.useState)(v),z;e[4]!==i?(z=i?D(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[y,C]=(0,E.useState)(z),[x,w]=(0,E.useState)(""),I;e[6]!==r||e[7]!==i?.metadata?(I=r==="edit"?Qt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=I):I=e[8];let[k,S]=(0,E.useState)(I),_;e[9]!==o||e[10]!==y||e[11]!==k||e[12]!==r||e[13]!==u||e[14]!==c||e[15]!==h||e[16]!==i?.id||e[17]!==x||e[18]!==s||e[19]!==g?(_=m(()=>{s(async()=>{let N=k.trim()===""?void 0:Kt(k);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim(),ownerId:x.trim()===""?void 0:x.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim()===""?void 0:u.trim(),organizationId:D(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),c()})},"O"),e[9]=o,e[10]=y,e[11]=k,e[12]=r,e[13]=u,e[14]=c,e[15]=h,e[16]=i?.id,e[17]=x,e[18]=s,e[19]=g,e[20]=_):_=e[20];let A=_,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]!==a?(T=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=T):T=e[26];let R;e[27]!==r||e[28]!==a?(R=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=R):R=e[29];let F;e[30]!==a?(F=a("name"),e[30]=a,e[31]=F):F=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=m(N=>{b(N.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,l.jsx)(X,{"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]!==F?(K=(0,l.jsx)(W,{htmlFor:"org-form-name",label:F,children:B}),e[35]=B,e[36]=F,e[37]=K):K=e[37];let J;e[38]!==a?(J=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=J):J=e[39];let j;e[40]===Symbol.for("react.memo_cache_sentinel")?(j=m(N=>{f(N.target.value)},"F"),e[40]=j):j=e[40];let U;e[41]!==g?(U=(0,l.jsx)(X,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:j,value:g}),e[41]=g,e[42]=U):U=e[42];let P;e[43]!==J||e[44]!==U?(P=(0,l.jsx)(W,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=P):P=e[45];let Y;e[46]!==a?(Y=a("Logo URL (optional)"),e[46]=a,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=m(N=>{C(N.target.value)},"M"),e[48]=M):M=e[48];let $;e[49]!==y?($=(0,l.jsx)(X,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=$):$=e[50];let q;e[51]!==Y||e[52]!==$?(q=(0,l.jsx)(W,{htmlFor:"org-form-logo",label:Y,children:$}),e[51]=Y,e[52]=$,e[53]=q):q=e[53];let V;e[54]!==r||e[55]!==x||e[56]!==a?(V=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,l.jsx)(X,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:m(N=>{w(N.target.value)},"onChange"),value:x})}),e[54]=r,e[55]=x,e[56]=a,e[57]=V):V=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=m(N=>{S(N.target.value)},"oe"),e[60]=le):le=e[60];let re;e[61]!==k?(re=(0,l.jsx)(Ot,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:le,value:k}),e[61]=k,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,l.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let ae;return e[66]!==n||e[67]!==d||e[68]!==c||e[69]!==A||e[70]!==K||e[71]!==P||e[72]!==q||e[73]!==V||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==R?(ae=(0,l.jsxs)(ue,{busy:n,canSubmit:O,error:d,onClose:c,onSubmit:A,submitLabel:T,testId:"org-form",title:R,children:[K,P,q,V,ee]}),e[66]=n,e[67]=d,e[68]=c,e[69]=A,e[70]=K,e[71]=P,e[72]=q,e[73]=V,e[74]=ee,e[75]=O,e[76]=T,e[77]=R,e[78]=ae):ae=e[78],ae},"Dt"),Xt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==h||e[4]!==u||e[5]!==d||e[6]!==s?(v=m(()=>{d(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),c(),r()})},"p"),e[0]=i,e[1]=r,e[2]=c,e[3]=h,e[4]=u,e[5]=d,e[6]=s,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Add member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("User id"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-add-member-user",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Kt"),Vt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==c||e[4]!==h||e[5]!==u||e[6]!==d?(v=m(()=>{d(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),c(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=c,e[4]=h,e[5]=u,e[6]=d,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Invite member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("email"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-invite-member-email",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Vt"),er=m(t=>{let e=(0,H.c)(32),{member:r,onClose:c,onDone:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),s;e[0]!==r.role?(s=m(()=>D(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[p,u]=(0,E.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==c||e[5]!==h||e[6]!==p||e[7]!==d?(b=m(()=>{d(async()=>{await i.setAuthOrgMemberRole({memberId:D(r.id),role:p.trim()}),h(),c()})},"g"),e[2]=i,e[3]=r.id,e[4]=c,e[5]=h,e[6]=p,e[7]=d,e[8]=b):b=e[8];let v=b,g;e[9]!==p?(g=p.trim(),e[9]=p,e[10]=g):g=e[10];let f=g!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let C;e[15]!==o?(C=o("Role"),e[15]=o,e[16]=C):C=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=m(S=>{u(S.target.value)},"x"),e[17]=x):x=e[17];let w;e[18]!==p?(w=(0,l.jsx)(X,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:x,value:p}),e[18]=p,e[19]=w):w=e[19];let I;e[20]!==C||e[21]!==w?(I=(0,l.jsx)(W,{htmlFor:"org-member-role-value",label:C,children:w}),e[20]=C,e[21]=w,e[22]=I):I=e[22];let k;return e[23]!==a||e[24]!==n||e[25]!==c||e[26]!==v||e[27]!==I||e[28]!==f||e[29]!==z||e[30]!==y?(k=(0,l.jsx)(ue,{busy:a,canSubmit:f,error:n,onClose:c,onSubmit:v,submitLabel:z,testId:"org-member-role",title:y,children:I}),e[23]=a,e[24]=n,e[25]=c,e[26]=v,e[27]=I,e[28]=f,e[29]=z,e[30]=y,e[31]=k):k=e[31],k},"Wt"),Bt=m(t=>{let e=(0,H.c)(36),{mode:r,onClose:c,onDone:h,organizationId:i,team:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==a||e[3]!==r||e[4]!==b||e[5]!==c||e[6]!==h||e[7]!==i||e[8]!==p||e[9]!==o?.id?(g=m(()=>{p(async()=>{await(r==="create"?a.createAuthOrgTeam({name:b.trim(),organizationId:i}):a.updateAuthOrgTeam({name:b.trim(),teamId:D(o?.id)})),h(),c()})},"f"),e[2]=a,e[3]=r,e[4]=b,e[5]=c,e[6]=h,e[7]=i,e[8]=p,e[9]=o?.id,e[10]=g):g=e[10];let f=g,z;e[11]!==b?(z=b.trim(),e[11]=b,e[12]=z):z=e[12];let y=z!=="",C;e[13]!==r||e[14]!==n?(C=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=C):C=e[15];let x;e[16]!==r||e[17]!==n?(x=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=x):x=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=m(A=>{v(A.target.value)},"C"),e[21]=I):I=e[21];let k;e[22]!==b?(k=(0,l.jsx)(X,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:I,value:b}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==w||e[25]!==k?(S=(0,l.jsx)(W,{htmlFor:"org-team-form-name",label:w,children:k}),e[24]=w,e[25]=k,e[26]=S):S=e[26];let _;return e[27]!==d||e[28]!==s||e[29]!==c||e[30]!==f||e[31]!==S||e[32]!==y||e[33]!==C||e[34]!==x?(_=(0,l.jsx)(ue,{busy:d,canSubmit:y,error:s,onClose:c,onSubmit:f,submitLabel:C,testId:"org-team-form",title:x,children:S}),e[27]=d,e[28]=s,e[29]=c,e[30]=f,e[31]=S,e[32]=y,e[33]=C,e[34]=x,e[35]=_):_=e[35],_},"zt"),tr=m(t=>{let e=(0,H.c)(30),{onClose:r,onDone:c,teamId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==d||e[4]!==h||e[5]!==s?(u=m(()=>{d(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),c(),r()})},"c"),e[0]=i,e[1]=r,e[2]=c,e[3]=d,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!=="",f;e[9]!==o?(f=o("Add member"),e[9]=o,e[10]=f):f=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=m(k=>{p(k.target.value)},"y"),e[15]=C):C=e[15];let x;e[16]!==s?(x=(0,l.jsx)(X,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:C,value:s}),e[16]=s,e[17]=x):x=e[17];let w;e[18]!==y||e[19]!==x?(w=(0,l.jsx)(W,{htmlFor:"org-team-add-member-user",label:y,children:x}),e[18]=y,e[19]=x,e[20]=w):w=e[20];let I;return e[21]!==a||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==f||e[27]!==z||e[28]!==w?(I=(0,l.jsx)(ue,{busy:a,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:f,testId:"org-team-add-member",title:z,children:w}),e[21]=a,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=f,e[27]=z,e[28]=w,e[29]=I):I=e[29],I},"Xt"),Jt=m(t=>{let e=(0,H.c)(47),{mode:r,onClose:c,onDone:h,organizationId:i,role:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Qt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[f,z]=(0,E.useState)(g),y;e[5]!==a||e[6]!==r||e[7]!==b||e[8]!==c||e[9]!==h||e[10]!==i||e[11]!==f||e[12]!==o?.id||e[13]!==p?(y=m(()=>{p(async()=>{let R=Wt(f);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:R,role:b.trim()}):a.updateAuthOrgRole({permission:R,roleId:D(o?.id)})),h(),c()})},"v"),e[5]=a,e[6]=r,e[7]=b,e[8]=c,e[9]=h,e[10]=i,e[11]=f,e[12]=o?.id,e[13]=p,e[14]=y):y=e[14];let C=y,x;e[15]!==r||e[16]!==b||e[17]!==f?(x=f.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=f,e[18]=x):x=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 I;e[22]!==r||e[23]!==n?(I=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=I):I=e[24];let k;e[25]!==r||e[26]!==b||e[27]!==n?(k=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,l.jsx)(X,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:m(R=>{v(R.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=k):k=e[28];let S;e[29]!==n?(S=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=S):S=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{z(R.target.value)},"O"),e[31]=_):_=e[31];let A;e[32]!==f?(A=(0,l.jsx)(Ot,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:f}),e[32]=f,e[33]=A):A=e[33];let O;e[34]!==A||e[35]!==S?(O=(0,l.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=O):O=e[36];let T;return e[37]!==d||e[38]!==s||e[39]!==c||e[40]!==C||e[41]!==O||e[42]!==x||e[43]!==w||e[44]!==I||e[45]!==k?(T=(0,l.jsxs)(ue,{busy:d,canSubmit:x,error:s,onClose:c,onSubmit:C,submitLabel:w,testId:"org-role-form",title:I,children:[k,O]}),e[37]=d,e[38]=s,e[39]=c,e[40]=C,e[41]=O,e[42]=x,e[43]=w,e[44]=I,e[45]=k,e[46]=T):T=e[46],T},"At"),Zt=m(t=>{let e=(0,H.c)(18),{action:r,message:c,onClose:h,onDone:i,testId:o,title:a}=t,n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==p?(u=m(()=>{p(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=p,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]!==c?(g=(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:c}),e[7]=c,e[8]=g):g=e[8];let f;return e[9]!==d||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==a?(f=(0,l.jsx)(ue,{busy:d,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:a,children:g}),e[9]=d,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=a,e[17]=f):f=e[17],f},"Lt"),et=m(t=>{let e=(0,H.c)(13),{action:r,children:c,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,l.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 a;e[2]!==r?(a=r!==void 0&&(0,l.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let n;e[4]!==o||e[5]!==a?(n=(0,l.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,a]}),e[4]=o,e[5]=a,e[6]=n):n=e[6];let d;e[7]!==c?(d=(0,l.jsx)(kt,{className:"px-0",children:c}),e[7]=c,e[8]=d):d=e[8];let s;return e[9]!==n||e[10]!==d||e[11]!==i?(s=(0,l.jsxs)(zt,{className:"overflow-hidden py-0","data-testid":i,children:[n,d]}),e[9]=n,e[10]=d,e[11]=i,e[12]=s):s=e[12],s},"Ye"),tt=m(t=>{let e=(0,H.c)(23),{columns:r,rowActions:c,rowPrefix:h,rows:i}=t,o=Q(),a;e[0]!==r?(a=r.map(rr),e[0]=r,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==n?(d=(0,l.jsx)(de,{"aria-label":n}),e[4]=n,e[5]=d):d=e[5];let s;e[6]!==a||e[7]!==d?(s=(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[a,d]})}),e[6]=a,e[7]=d,e[8]=s):s=e[8];let p;if(e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==c||e[16]!==h?(v=m((g,f)=>{let z=D(g.id),y=z===""?`index-${f.toString()}`:z;return(0,l.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(C=>(0,l.jsx)(ce,{className:C.className,children:C.render(g)},C.head)),(0,l.jsx)(ce,{children:(0,l.jsx)("div",{className:"flex justify-end gap-1",children:c(g)})})]},y)},"p"),e[14]=r,e[15]=c,e[16]=h,e[17]=v):v=e[17],p=i.map(v),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=p}else p=e[13];let u;e[18]!==p?(u=(0,l.jsx)(Dt,{children:p}),e[18]=p,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,l.jsxs)(Nt,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"et");function rr(t){return(0,l.jsx)(de,{children:t.head},t.head)}m(rr,"Yt");var or=m(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:c,memberColumns:h,members:i,onDialog:o}=t,a=Q(),n;e[0]!==o?(n=m(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let d;e[2]!==a?(d=a("Add member"),e[2]=a,e[3]=d):d=e[3];let s;e[4]!==n||e[5]!==d?(s=(0,l.jsx)(L,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:d}),e[4]=n,e[5]=d,e[6]=s):s=e[6];let p;e[7]!==o?(p=m(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=p):p=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let b;e[11]!==p||e[12]!==u?(b=(0,l.jsx)(L,{"data-testid":"org-open-invite-member",onClick:p,size:"xs",type:"button",variant:"outline",children:u}),e[11]=p,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,l.jsxs)(l.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==a?(g=a("Members"),e[17]=a,e[18]=g):g=e[18];let f;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==c||e[24]!==a?(f=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-members-empty",title:a("No members.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(y=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-member-role-${D(y.id)}`,onClick:m(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,l.jsx)(L,{"data-testid":`org-remove-member-${D(y.id)}`,disabled:r,onClick:m(()=>{c(D(y.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=c,e[24]=a,e[25]=f):f=e[25];let z;return e[26]!==v||e[27]!==g||e[28]!==f?(z=(0,l.jsx)(et,{action:v,heading:g,testId:"org-members",children:f}),e[26]=v,e[27]=g,e[28]=f,e[29]=z):z=e[29],z},"el"),lr=m(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:c,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,n=Q(),d;e[0]!==c?(d=m(()=>{c({kind:"team-create"})},"m"),e[0]=c,e[1]=d):d=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let p;e[4]!==d||e[5]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-create-team",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[4]=d,e[5]=s,e[6]=p):p=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]!==c||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-teams-empty",title:n("No teams.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"aria-pressed":i===D(g.id),"data-testid":`org-team-select-${D(g.id)}`,onClick:m(()=>{h(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,l.jsx)(L,{"data-testid":`org-team-rename-${D(g.id)}`,onClick:m(()=>{c({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,l.jsx)(L,{"data-testid":`org-team-delete-${D(g.id)}`,onClick:m(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=a,e[16]=b):b=e[16];let v;return e[17]!==p||e[18]!==u||e[19]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-teams",children:b}),e[17]=p,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"tl"),ar=m(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:c,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,n=Q(),d;e[0]!==h||e[1]!==i?(d=m(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=d):d=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let p;e[5]!==d||e[6]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[5]=d,e[6]=s,e[7]=p):p=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]!==c||e[12]!==n||e[13]!==o||e[14]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsx)(L,{"data-testid":`org-team-remove-member-${D(g.id)}`,disabled:r,onClick:m(()=>{c(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=c,e[12]=n,e[13]=o,e[14]=a,e[15]=b):b=e[15];let v;return e[16]!==p||e[17]!==u||e[18]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-team-members",children:b}),e[16]=p,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"ll"),nr=m(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:c,roleColumns:h,roles:i}=t,o=Q(),a;e[0]!==c?(a=m(()=>{c({kind:"role-create"})},"i"),e[0]=c,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==a||e[5]!==n?(d=(0,l.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:n}),e[4]=a,e[5]=n,e[6]=d):d=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let p;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==o?(p=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(b=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-role-edit-${D(b.id)}`,onClick:m(()=>{c({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,l.jsx)(L,{"data-testid":`org-role-delete-${D(b.id)}`,onClick:m(()=>{r(D(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=o,e[14]=p):p=e[14];let u;return e[15]!==d||e[16]!==s||e[17]!==p?(u=(0,l.jsx)(et,{action:d,heading:s,testId:"org-roles",children:p}),e[15]=d,e[16]=s,e[17]=p,e[18]=u):u=e[18],u},"ol"),Ut=200,ir=m(t=>{let e=(0,H.c)(217),{organizationId:r,rolesEnabled:c,teamsEnabled:h}=t,i=oe(),o=Q(),[a,n]=(0,E.useState)(null),[d,s]=(0,E.useState)(null),[p,u]=(0,E.useState)(!1),[b,v]=(0,E.useState)(null),[g,f]=jt(r),z;e[0]!==g||e[1]!==r?(z=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=z):z=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=m(()=>i.listAuthOrgMembers({limit:Ut,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let C=he(z,y),x;e[7]!==r?(x=["lunora-auth-org-invitations",r],e[7]=r,e[8]=x):x=e[8];let w;e[9]!==i||e[10]!==r?(w=m(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let I=he(x,w),k;e[12]!==r?(k=["lunora-auth-org-teams",r],e[12]=r,e[13]=k):k=e[13];let S;e[14]!==i||e[15]!==r?(S=m(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"k"),e[14]=i,e[15]=r,e[16]=S):S=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let A=he(k,S,_),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=m(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let R;e[24]!==c?(R={enabled:c},e[24]=c,e[25]=R):R=e[25];let F=he(O,T,R),Z;e[26]!==d?(Z=["lunora-auth-org-team-members",d],e[26]=d,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==d?(B=m(()=>i.listAuthOrgTeamMembers({limit:200,teamId:d??""}),"B"),e[28]=i,e[29]=d,e[30]=B):B=e[30];let K=d!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let j=he(Z,B,J),U;e[33]!==C.data?.rows?(U=C.data?.rows??[],e[33]=C.data?.rows,e[34]=U):U=e[34];let P=U,Y;e[35]!==I.data?.rows?(Y=I.data?.rows??[],e[35]=I.data?.rows,e[36]=Y):Y=e[36];let M=Y,$;e[37]!==A.data?.rows?($=A.data?.rows??[],e[37]=A.data?.rows,e[38]=$):$=e[38];let q=$,V;e[39]!==F.data?.rows?(V=F.data?.rows??[],e[39]=F.data?.rows,e[40]=V):V=e[40];let te=V,le;e[41]!==d||e[42]!==j.data?.rows?(le=d===null?[]:j.data?.rows??[],e[41]=d,e[42]=j.data?.rows,e[43]=le):le=e[43];let re=le,ee=C.error??I.error??A.error??F.error??j.error,ae;if(e[44]!==I||e[45]!==C||e[46]!==c||e[47]!==F||e[48]!==d||e[49]!==j||e[50]!==h||e[51]!==A){let G=m(()=>{let se=[C.poll(),I.poll()];return h&&se.push(A.poll()),c&&se.push(F.poll()),d!==null&&se.push(j.poll()),Ft(se)},"V");ae=m(()=>{St(G())},"ie"),e[44]=I,e[45]=C,e[46]=c,e[47]=F,e[48]=d,e[49]=j,e[50]=h,e[51]=A,e[52]=ae}else ae=e[52];let N=ae,rt;e[53]!==C?(rt=m(()=>C.poll(),"tt"),e[53]=C,e[54]=rt):rt=e[54],be(rt,!0);let ot;e[55]!==I?(ot=m(()=>I.poll(),"lt"),e[55]=I,e[56]=ot):ot=e[56],be(ot,!0);let lt;e[57]!==A?(lt=m(()=>A.poll(),"ot"),e[57]=A,e[58]=lt):lt=e[58],be(lt,h);let at;e[59]!==F?(at=m(()=>F.poll(),"it"),e[59]=F,e[60]=at):at=e[60],be(at,c);let nt;e[61]!==j?(nt=m(()=>j.poll(),"rt"),e[61]=j,e[62]=nt):nt=e[62],be(nt,d!==null);let it;e[63]===Symbol.for("react.memo_cache_sentinel")?(it=m(()=>{n(null)},"st"),e[63]=it):it=e[63];let ne=it,st;e[64]!==N?(st=m(G=>{St((async()=>{u(!0),v(null);try{await G(),N(),u(!1)}catch(se){v(Rt(se)),u(!1)}})())},"nt"),e[64]=N,e[65]=st):st=e[65];let ie=st,mt;e[66]!==i||e[67]!==o?(mt=m(G=>{let se=D(G.id);n({action:m(async()=>{await i.removeAuthOrgTeam({teamId:se}),s(Tt=>Tt===se?null:Tt)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"at"),e[66]=i,e[67]=o,e[68]=mt):mt=e[68];let pt=mt,pe;e[69]!==o?(pe=o("userId"),e[69]=o,e[70]=pe):pe=e[70];let fe;e[71]!==pe?(fe={head:pe,render:sr},e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o?(ve=o("role"),e[73]=o,e[74]=ve):ve=e[74];let ye;e[75]!==ve?(ye={head:ve,render:mr},e[75]=ve,e[76]=ye):ye=e[76];let dt;e[77]!==fe||e[78]!==ye?(dt=[fe,ye],e[77]=fe,e[78]=ye,e[79]=dt):dt=e[79];let ft=dt,Ce;e[80]!==o?(Ce=o("email"),e[80]=o,e[81]=Ce):Ce=e[81];let Ie;e[82]!==Ce?(Ie={head:Ce,render:dr},e[82]=Ce,e[83]=Ie):Ie=e[83];let xe;e[84]!==o?(xe=o("role"),e[84]=o,e[85]=xe):xe=e[85];let we;e[86]!==xe?(we={head:xe,render:cr},e[86]=xe,e[87]=we):we=e[87];let ze;e[88]!==o?(ze=o("status"),e[88]=o,e[89]=ze):ze=e[89];let ke;e[90]!==ze?(ke={head:ze,render:ur},e[90]=ze,e[91]=ke):ke=e[91];let ct;e[92]!==Ie||e[93]!==we||e[94]!==ke?(ct=[Ie,we,ke],e[92]=Ie,e[93]=we,e[94]=ke,e[95]=ct):ct=e[95];let vt=ct,Se;e[96]!==o?(Se=o("id"),e[96]=o,e[97]=Se):Se=e[97];let Ne;e[98]!==Se?(Ne={className:"font-mono text-xs",head:Se,render:gr},e[98]=Se,e[99]=Ne):Ne=e[99];let Ae;e[100]!==o?(Ae=o("name"),e[100]=o,e[101]=Ae):Ae=e[101];let De;e[102]!==Ae?(De={head:Ae,render:hr},e[102]=Ae,e[103]=De):De=e[103];let ut;e[104]!==Ne||e[105]!==De?(ut=[Ne,De],e[104]=Ne,e[105]=De,e[106]=ut):ut=e[106];let yt=ut,Oe;e[107]!==o?(Oe=o("userId"),e[107]=o,e[108]=Oe):Oe=e[108];let gt;e[109]!==Oe?(gt=[{head:Oe,render:br}],e[109]=Oe,e[110]=gt):gt=e[110];let Ct=gt,_e;e[111]!==o?(_e=o("role"),e[111]=o,e[112]=_e):_e=e[112];let Te;e[113]!==_e?(Te={head:_e,render:pr},e[113]=_e,e[114]=Te):Te=e[114];let Re;e[115]!==o?(Re=o("Permission"),e[115]=o,e[116]=Re):Re=e[116];let $e;e[117]!==Re?($e={className:"font-mono text-xs whitespace-pre-wrap",head:Re,render:fr},e[117]=Re,e[118]=$e):$e=e[118];let ht;e[119]!==Te||e[120]!==$e?(ht=[Te,$e],e[119]=Te,e[120]=$e,e[121]=ht):ht=e[121];let It=ht,Me;e[122]!==ee?(Me=ee!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[122]=ee,e[123]=Me):Me=e[123];let Fe;e[124]!==b?(Fe=b!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[124]=b,e[125]=Fe):Fe=e[125];let je;e[126]!==i||e[127]!==ie?(je=m(G=>{ie(()=>i.removeAuthOrgMember({memberId:G}))},"Me"),e[126]=i,e[127]=ie,e[128]=je):je=e[128];let Ee;e[129]!==p||e[130]!==ft||e[131]!==P||e[132]!==je?(Ee=(0,l.jsx)(or,{actionBusy:p,memberColumns:ft,members:P,onDialog:n,onRemoveMember:je}),e[129]=p,e[130]=ft,e[131]=P,e[132]=je,e[133]=Ee):Ee=e[133];let xt=C.data?.total,Le;e[134]!==P.length||e[135]!==g||e[136]!==f||e[137]!==xt?(Le=(0,l.jsx)(_t,{count:P.length,offset:g,onOffsetChange:f,pageSize:Ut,prefix:"org-members",total:xt}),e[134]=P.length,e[135]=g,e[136]=f,e[137]=xt,e[138]=Le):Le=e[138];let Pe;e[139]!==p||e[140]!==i||e[141]!==vt||e[142]!==M||e[143]!==ie||e[144]!==o?(Pe=M.length>0&&(0,l.jsx)(et,{heading:o("Invitations"),testId:"org-invitations",children:(0,l.jsx)(tt,{columns:vt,rowActions:m(G=>(0,l.jsx)(L,{"data-testid":`org-cancel-invitation-${D(G.id)}`,disabled:p,onClick:m(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:D(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[139]=p,e[140]=i,e[141]=vt,e[142]=M,e[143]=ie,e[144]=o,e[145]=Pe):Pe=e[145];let Be;e[146]!==pt||e[147]!==d||e[148]!==yt||e[149]!==q||e[150]!==h?(Be=h&&(0,l.jsx)(lr,{onConfirmDeleteTeam:pt,onDialog:n,onSelectTeam:s,selectedTeam:d,teamColumns:yt,teams:q}),e[146]=pt,e[147]=d,e[148]=yt,e[149]=q,e[150]=h,e[151]=Be):Be=e[151];let Je;e[152]!==p||e[153]!==i||e[154]!==ie||e[155]!==d||e[156]!==Ct||e[157]!==re||e[158]!==h?(Je=h&&d!==null&&(0,l.jsx)(ar,{actionBusy:p,onDialog:n,onRemoveTeamMember:m(G=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:d,teamMemberColumns:Ct,teamMembers:re}),e[152]=p,e[153]=i,e[154]=ie,e[155]=d,e[156]=Ct,e[157]=re,e[158]=h,e[159]=Je):Je=e[159];let Ue;e[160]!==i||e[161]!==It||e[162]!==te||e[163]!==c||e[164]!==o?(Ue=c&&(0,l.jsx)(nr,{onConfirmDeleteRole:m(G=>{n({action:m(()=>i.deleteAuthOrgRole({roleId:G}),"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:It,roles:te}),e[160]=i,e[161]=It,e[162]=te,e[163]=c,e[164]=o,e[165]=Ue):Ue=e[165];let He;e[166]!==a?.kind||e[167]!==r||e[168]!==N?(He=a?.kind==="add-member"&&(0,l.jsx)(Xt,{onClose:ne,onDone:N,organizationId:r}),e[166]=a?.kind,e[167]=r,e[168]=N,e[169]=He):He=e[169];let Ke;e[170]!==a?.kind||e[171]!==r||e[172]!==N?(Ke=a?.kind==="invite-member"&&(0,l.jsx)(Vt,{onClose:ne,onDone:N,organizationId:r}),e[170]=a?.kind,e[171]=r,e[172]=N,e[173]=Ke):Ke=e[173];let Qe;e[174]!==a||e[175]!==N?(Qe=a?.kind==="member-role"&&(0,l.jsx)(er,{member:a.member,onClose:ne,onDone:N}),e[174]=a,e[175]=N,e[176]=Qe):Qe=e[176];let Ze;e[177]!==a?.kind||e[178]!==r||e[179]!==N?(Ze=a?.kind==="team-create"&&(0,l.jsx)(Bt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[177]=a?.kind,e[178]=r,e[179]=N,e[180]=Ze):Ze=e[180];let Ye;e[181]!==a||e[182]!==r||e[183]!==N?(Ye=a?.kind==="team-rename"&&(0,l.jsx)(Bt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,team:a.team}),e[181]=a,e[182]=r,e[183]=N,e[184]=Ye):Ye=e[184];let qe;e[185]!==a||e[186]!==N?(qe=a?.kind==="team-add-member"&&(0,l.jsx)(tr,{onClose:ne,onDone:N,teamId:a.teamId}),e[185]=a,e[186]=N,e[187]=qe):qe=e[187];let Ge;e[188]!==a?.kind||e[189]!==r||e[190]!==N?(Ge=a?.kind==="role-create"&&(0,l.jsx)(Jt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[188]=a?.kind,e[189]=r,e[190]=N,e[191]=Ge):Ge=e[191];let We;e[192]!==a||e[193]!==r||e[194]!==N?(We=a?.kind==="role-edit"&&(0,l.jsx)(Jt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,role:a.role}),e[192]=a,e[193]=r,e[194]=N,e[195]=We):We=e[195];let Xe;e[196]!==a||e[197]!==N?(Xe=a?.kind==="confirm"&&(0,l.jsx)(Zt,{action:a.action,message:a.message,onClose:ne,onDone:N,testId:a.testId,title:a.title}),e[196]=a,e[197]=N,e[198]=Xe):Xe=e[198];let bt;return e[199]!==Me||e[200]!==Fe||e[201]!==Ee||e[202]!==Le||e[203]!==Pe||e[204]!==Be||e[205]!==Je||e[206]!==Ue||e[207]!==He||e[208]!==Ke||e[209]!==Qe||e[210]!==Ze||e[211]!==Ye||e[212]!==qe||e[213]!==Ge||e[214]!==We||e[215]!==Xe?(bt=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[Me,Fe,Ee,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge,We,Xe]}),e[199]=Me,e[200]=Fe,e[201]=Ee,e[202]=Le,e[203]=Pe,e[204]=Be,e[205]=Je,e[206]=Ue,e[207]=He,e[208]=Ke,e[209]=Qe,e[210]=Ze,e[211]=Ye,e[212]=qe,e[213]=Ge,e[214]=We,e[215]=Xe,e[216]=bt):bt=e[216],bt},"il");function sr(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(sr,"rl");function mr(t){return D(t.role)}m(mr,"sl");function dr(t){return D(t.email)}m(dr,"nl");function cr(t){return D(t.role)}m(cr,"al");function ur(t){return D(t.status)}m(ur,"ml");function gr(t){return D(t.id)}m(gr,"dl");function hr(t){return D(t.name)}m(hr,"cl");function br(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(br,"fl");function pr(t){return D(t.role)}m(pr,"ul");function fr(t){return D(t.permission)}m(fr,"gl");var Ht=100,$r=m(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:c,ready:h}=Et(),i=c.capabilities.organization,[o,a]=(0,E.useState)(null),[n,d]=(0,E.useState)(null),[s,p]=(0,E.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=m(()=>e.listAuthOrganizations({limit:Ht,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=he(u,b,v),f=g.data?.rows??null,z;t[7]!==g?(z=m(()=>g.poll(),"S"),t[7]=g,t[8]=z):z=t[8],be(z,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=m(()=>{d(null)},"v"),t[9]=y):y=t[9];let C=y,x;t[10]!==g?(x=m(()=>{g.refetch()},"x"),t[10]=g,t[11]=x):x=t[11];let w=x,I;t[12]===Symbol.for("react.memo_cache_sentinel")?(I=m(M=>{a(M)},"C"),t[12]=I):I=t[12];let k=I;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 $;t[15]!==r?($=r("Organizations are not enabled."),t[15]=r,t[16]=$):$=t[16];let q;return t[17]!==M||t[18]!==$?(q=(0,l.jsx)(ge,{description:M,testId:"org-disabled",title:$}),t[17]=M,t[18]=$,t[19]=q):q=t[19],q}let S;t[20]!==r?(S=r("Organizations"),t[20]=r,t[21]=S):S=t[21];let _;t[22]!==S?(_=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S}),t[22]=S,t[23]=_):_=t[23];let A;t[24]===Symbol.for("react.memo_cache_sentinel")?(A=m(()=>{d({kind:"create"})},"z"),t[24]=A):A=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,l.jsx)(L,{"data-testid":"org-new",onClick:A,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let R;t[29]!==T||t[30]!==_?(R=(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=R):R=t[31];let F;t[32]!==g.error?(F=g.error!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=F):F=t[33];let Z;t[34]!==f||t[35]!==r?(Z=f!==null&&f.length===0&&(0,l.jsx)(ge,{testId:"org-empty",title:r("No organizations.")}),t[34]=f,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==f||t[38]!==o||t[39]!==r?(B=f!==null&&f.length>0&&(0,l.jsx)(zt,{className:"overflow-hidden py-0",children:(0,l.jsx)(kt,{className:"px-0",children:(0,l.jsxs)(Nt,{"data-testid":"org-table",children:[(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[(0,l.jsx)(de,{children:r("id")}),(0,l.jsx)(de,{children:r("name")}),(0,l.jsx)(de,{children:r("slug")}),(0,l.jsx)(de,{children:r("created")}),(0,l.jsx)(de,{"aria-label":r("Actions")})]})}),(0,l.jsx)(Dt,{children:f.map(M=>{let $=D(M.id);return(0,l.jsxs)(Ve,{"data-testid":`org-row-${$}`,children:[(0,l.jsx)(ce,{className:"font-mono text-xs",children:$}),(0,l.jsx)(ce,{children:D(M.name)}),(0,l.jsx)(ce,{children:D(M.slug)}),(0,l.jsx)(ce,{className:"text-muted-foreground tabular-nums",children:$t(M.createdAt)}),(0,l.jsx)(ce,{children:(0,l.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,l.jsx)(L,{"aria-pressed":o===$,"data-testid":`org-select-${$}`,onClick:m(()=>{k($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,l.jsx)(L,{"data-testid":`org-edit-${$}`,onClick:m(()=>{d({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,l.jsx)(L,{"data-testid":`org-delete-${$}`,onClick:m(()=>{d({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},$)})})]})})}),t[37]=f,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==f||t[43]!==g.data?.total?(K=f!==null&&(0,l.jsx)(_t,{count:f.length,offset:s,onOffsetChange:p,pageSize:Ht,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=f,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==c.organization||t[46]!==o?(J=o!==null&&(0,l.jsx)(ir,{organizationId:o,rolesEnabled:c.organization.roles,teamsEnabled:c.organization.teams}),t[45]=c.organization,t[46]=o,t[47]=J):J=t[47];let j;t[48]!==n?.kind||t[49]!==w?(j=n?.kind==="create"&&(0,l.jsx)(Pt,{mode:"create",onClose:C,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=j):j=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,l.jsx)(Pt,{mode:"edit",onClose:C,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let P;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(P=n?.kind==="delete"&&(0,l.jsx)(Zt,{action:m(async()=>{let M=D(n.org.id);await e.deleteAuthOrganization({organizationId:M}),a($=>$===M?null:$)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:C,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=P):P=t[58];let Y;return t[59]!==R||t[60]!==F||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==j||t[66]!==U||t[67]!==P?(Y=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[R,F,Z,B,K,J,j,U,P]}),t[59]=R,t[60]=F,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=j,t[66]=U,t[67]=P,t[68]=Y):Y=t[68],Y},"Ml");export{$r as default};
1
+ import{a as Ot}from"./chunk-FPI7AMQJ.js";import{a as Et}from"./chunk-Q5CSRWLU.js";import{a as me}from"./chunk-WVWCUB4S.js";import{a as Lt}from"./chunk-QJLHH3ET.js";import{a as Mt}from"./chunk-37WYCOQ2.js";import{a as _t,b as jt}from"./chunk-VQRCJJXS.js";import"./chunk-PSMQQV6S.js";import{a as be,b as Ft}from"./chunk-OYDOFRRB.js";import{i as X}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as L}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{b as he}from"./chunk-NWWMHMGA.js";import{l as oe}from"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as ge}from"./chunk-RWVIV3U7.js";import{a as Nt,b as At,c as Dt,d as Ve,e as de,f as ce}from"./chunk-HCTJKP5J.js";import{a as zt,e as kt}from"./chunk-2IKDEUCX.js";import{d as Q,h as Rt,p as D,q as St,u as $t}from"./chunk-74IYYDDI.js";import{a as m,d as wt,e as Yt,f as qt,g as Gt}from"./chunk-I26MS5PJ.js";var H=wt(qt(),1);var E=wt(Yt(),1);var l=wt(Gt(),1);var Kt=m(t=>{let e=JSON.parse(t);if(typeof e!="object"||e===null||Array.isArray(e))throw new TypeError("Expected a JSON object");return e},"Pt"),Wt=m(t=>{let e=Kt(t),r={};for(let[c,h]of Object.entries(e)){if(!Array.isArray(h)||h.some(i=>typeof i!="string"))throw new TypeError(`"${c}" must map to an array of action strings`);r[c]=h}return r},"qt"),Qt=m(t=>t==null||t===""?"":typeof t=="string"?t:JSON.stringify(t,null,2),"jt"),W=m(t=>{let e=(0,H.c)(6),{children:r,htmlFor:c,label:h}=t,i;e[0]!==c||e[1]!==h?(i=(0,l.jsx)(Mt,{htmlFor:c,children:h}),e[0]=c,e[1]=h,e[2]=i):i=e[2];let o;return e[3]!==r||e[4]!==i?(o=(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[i,r]}),e[3]=r,e[4]=i,e[5]=o):o=e[5],o},"W"),ue=m(({busy:t,canSubmit:e,children:r,destructive:c=!1,error:h,onClose:i,onSubmit:o,submitLabel:a,testId:n,title:d})=>{let s=Q();return(0,l.jsxs)(Lt,{label:d,onClose:i,panelTestId:`${n}-panel`,testId:`${n}-overlay`,variant:"dialog",children:[(0,l.jsx)("h2",{className:"text-sm font-semibold text-foreground",children:d}),r,h!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":`${n}-error`,role:"alert",children:h}),(0,l.jsxs)("div",{className:"flex justify-end gap-2 pt-1",children:[(0,l.jsx)(L,{"data-testid":`${n}-cancel`,onClick:i,size:"sm",type:"button",variant:"outline",children:s("Cancel")}),(0,l.jsx)(L,{"data-testid":`${n}-submit`,disabled:t||!e,onClick:o,size:"sm",type:"button",variant:c?"destructive":"default",children:t?s("Saving\u2026"):a})]})]})},"de"),Pt=m(t=>{let e=(0,H.c)(79),{mode:r,onClose:c,onDone:h,org:i}=t,o=oe(),a=Q(),{busy:n,error:d,run:s}=me(),p;e[0]!==i?(p=i?D(i.name):"",e[0]=i,e[1]=p):p=e[1];let[u,b]=(0,E.useState)(p),v;e[2]!==i?(v=i?D(i.slug):"",e[2]=i,e[3]=v):v=e[3];let[g,f]=(0,E.useState)(v),z;e[4]!==i?(z=i?D(i.logo):"",e[4]=i,e[5]=z):z=e[5];let[y,C]=(0,E.useState)(z),[x,w]=(0,E.useState)(""),I;e[6]!==r||e[7]!==i?.metadata?(I=r==="edit"?Qt(i?.metadata):"",e[6]=r,e[7]=i?.metadata,e[8]=I):I=e[8];let[k,S]=(0,E.useState)(I),_;e[9]!==o||e[10]!==y||e[11]!==k||e[12]!==r||e[13]!==u||e[14]!==c||e[15]!==h||e[16]!==i?.id||e[17]!==x||e[18]!==s||e[19]!==g?(_=m(()=>{s(async()=>{let N=k.trim()===""?void 0:Kt(k);r==="create"?await o.createAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim(),ownerId:x.trim()===""?void 0:x.trim(),slug:g.trim()===""?void 0:g.trim()}):await o.updateAuthOrganization({logo:y.trim()===""?void 0:y.trim(),metadata:N,name:u.trim()===""?void 0:u.trim(),organizationId:D(i?.id),slug:g.trim()===""?void 0:g.trim()}),h(),c()})},"O"),e[9]=o,e[10]=y,e[11]=k,e[12]=r,e[13]=u,e[14]=c,e[15]=h,e[16]=i?.id,e[17]=x,e[18]=s,e[19]=g,e[20]=_):_=e[20];let A=_,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]!==a?(T=a(r==="create"?"Create":"Save"),e[24]=r,e[25]=a,e[26]=T):T=e[26];let R;e[27]!==r||e[28]!==a?(R=a(r==="create"?"New organization":"Edit organization"),e[27]=r,e[28]=a,e[29]=R):R=e[29];let F;e[30]!==a?(F=a("name"),e[30]=a,e[31]=F):F=e[31];let Z;e[32]===Symbol.for("react.memo_cache_sentinel")?(Z=m(N=>{b(N.target.value)},"H"),e[32]=Z):Z=e[32];let B;e[33]!==u?(B=(0,l.jsx)(X,{"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]!==F?(K=(0,l.jsx)(W,{htmlFor:"org-form-name",label:F,children:B}),e[35]=B,e[36]=F,e[37]=K):K=e[37];let J;e[38]!==a?(J=a("Slug (optional \u2014 derived from name)"),e[38]=a,e[39]=J):J=e[39];let j;e[40]===Symbol.for("react.memo_cache_sentinel")?(j=m(N=>{f(N.target.value)},"F"),e[40]=j):j=e[40];let U;e[41]!==g?(U=(0,l.jsx)(X,{"data-testid":"org-form-slug",id:"org-form-slug",onChange:j,value:g}),e[41]=g,e[42]=U):U=e[42];let P;e[43]!==J||e[44]!==U?(P=(0,l.jsx)(W,{htmlFor:"org-form-slug",label:J,children:U}),e[43]=J,e[44]=U,e[45]=P):P=e[45];let Y;e[46]!==a?(Y=a("Logo URL (optional)"),e[46]=a,e[47]=Y):Y=e[47];let M;e[48]===Symbol.for("react.memo_cache_sentinel")?(M=m(N=>{C(N.target.value)},"M"),e[48]=M):M=e[48];let $;e[49]!==y?($=(0,l.jsx)(X,{"data-testid":"org-form-logo",id:"org-form-logo",onChange:M,value:y}),e[49]=y,e[50]=$):$=e[50];let q;e[51]!==Y||e[52]!==$?(q=(0,l.jsx)(W,{htmlFor:"org-form-logo",label:Y,children:$}),e[51]=Y,e[52]=$,e[53]=q):q=e[53];let V;e[54]!==r||e[55]!==x||e[56]!==a?(V=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-form-owner",label:a("Owner user id (optional)"),children:(0,l.jsx)(X,{"data-testid":"org-form-owner",id:"org-form-owner",onChange:m(N=>{w(N.target.value)},"onChange"),value:x})}),e[54]=r,e[55]=x,e[56]=a,e[57]=V):V=e[57];let te;e[58]!==a?(te=a("Metadata (JSON, optional)"),e[58]=a,e[59]=te):te=e[59];let le;e[60]===Symbol.for("react.memo_cache_sentinel")?(le=m(N=>{S(N.target.value)},"oe"),e[60]=le):le=e[60];let re;e[61]!==k?(re=(0,l.jsx)(Ot,{"data-testid":"org-form-metadata",id:"org-form-metadata",onChange:le,value:k}),e[61]=k,e[62]=re):re=e[62];let ee;e[63]!==te||e[64]!==re?(ee=(0,l.jsx)(W,{htmlFor:"org-form-metadata",label:te,children:re}),e[63]=te,e[64]=re,e[65]=ee):ee=e[65];let ae;return e[66]!==n||e[67]!==d||e[68]!==c||e[69]!==A||e[70]!==K||e[71]!==P||e[72]!==q||e[73]!==V||e[74]!==ee||e[75]!==O||e[76]!==T||e[77]!==R?(ae=(0,l.jsxs)(ue,{busy:n,canSubmit:O,error:d,onClose:c,onSubmit:A,submitLabel:T,testId:"org-form",title:R,children:[K,P,q,V,ee]}),e[66]=n,e[67]=d,e[68]=c,e[69]=A,e[70]=K,e[71]=P,e[72]=q,e[73]=V,e[74]=ee,e[75]=O,e[76]=T,e[77]=R,e[78]=ae):ae=e[78],ae},"Dt"),Xt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==h||e[4]!==u||e[5]!==d||e[6]!==s?(v=m(()=>{d(async()=>{await i.addAuthOrgMember({organizationId:h,role:u.trim()===""?void 0:u.trim(),userId:s.trim()}),c(),r()})},"p"),e[0]=i,e[1]=r,e[2]=c,e[3]=h,e[4]=u,e[5]=d,e[6]=s,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Add member"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Add member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("User id"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-add-member-user",id:"org-add-member-user",onChange:w,value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-add-member-user",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-add-member-role",id:"org-add-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-add-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-add-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Kt"),Vt=m(t=>{let e=(0,H.c)(40),{onClose:r,onDone:c,organizationId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),[u,b]=(0,E.useState)(""),v;e[0]!==i||e[1]!==s||e[2]!==r||e[3]!==c||e[4]!==h||e[5]!==u||e[6]!==d?(v=m(()=>{d(async()=>{await i.inviteAuthOrgMember({email:s.trim(),organizationId:h,role:u.trim()===""?void 0:u.trim()}),c(),r()})},"p"),e[0]=i,e[1]=s,e[2]=r,e[3]=c,e[4]=h,e[5]=u,e[6]=d,e[7]=v):v=e[7];let g=v,f;e[8]!==s?(f=s.trim(),e[8]=s,e[9]=f):f=e[9];let z=f!=="",y;e[10]!==o?(y=o("Send invitation"),e[10]=o,e[11]=y):y=e[11];let C;e[12]!==o?(C=o("Invite member"),e[12]=o,e[13]=C):C=e[13];let x;e[14]!==o?(x=o("email"),e[14]=o,e[15]=x):x=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=m(R=>{p(R.target.value)},"I"),e[16]=w):w=e[16];let I;e[17]!==s?(I=(0,l.jsx)(X,{"data-testid":"org-invite-member-email",id:"org-invite-member-email",onChange:w,type:"email",value:s}),e[17]=s,e[18]=I):I=e[18];let k;e[19]!==x||e[20]!==I?(k=(0,l.jsx)(W,{htmlFor:"org-invite-member-email",label:x,children:I}),e[19]=x,e[20]=I,e[21]=k):k=e[21];let S;e[22]!==o?(S=o("Role (optional)"),e[22]=o,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{b(R.target.value)},"O"),e[24]=_):_=e[24];let A;e[25]!==u?(A=(0,l.jsx)(X,{"data-testid":"org-invite-member-role",id:"org-invite-member-role",onChange:_,value:u}),e[25]=u,e[26]=A):A=e[26];let O;e[27]!==S||e[28]!==A?(O=(0,l.jsx)(W,{htmlFor:"org-invite-member-role",label:S,children:A}),e[27]=S,e[28]=A,e[29]=O):O=e[29];let T;return e[30]!==a||e[31]!==n||e[32]!==r||e[33]!==g||e[34]!==O||e[35]!==z||e[36]!==y||e[37]!==C||e[38]!==k?(T=(0,l.jsxs)(ue,{busy:a,canSubmit:z,error:n,onClose:r,onSubmit:g,submitLabel:y,testId:"org-invite-member",title:C,children:[k,O]}),e[30]=a,e[31]=n,e[32]=r,e[33]=g,e[34]=O,e[35]=z,e[36]=y,e[37]=C,e[38]=k,e[39]=T):T=e[39],T},"Vt"),er=m(t=>{let e=(0,H.c)(32),{member:r,onClose:c,onDone:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),s;e[0]!==r.role?(s=m(()=>D(r.role),"a"),e[0]=r.role,e[1]=s):s=e[1];let[p,u]=(0,E.useState)(s),b;e[2]!==i||e[3]!==r.id||e[4]!==c||e[5]!==h||e[6]!==p||e[7]!==d?(b=m(()=>{d(async()=>{await i.setAuthOrgMemberRole({memberId:D(r.id),role:p.trim()}),h(),c()})},"g"),e[2]=i,e[3]=r.id,e[4]=c,e[5]=h,e[6]=p,e[7]=d,e[8]=b):b=e[8];let v=b,g;e[9]!==p?(g=p.trim(),e[9]=p,e[10]=g):g=e[10];let f=g!=="",z;e[11]!==o?(z=o("Save"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("Change member role"),e[13]=o,e[14]=y):y=e[14];let C;e[15]!==o?(C=o("Role"),e[15]=o,e[16]=C):C=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=m(S=>{u(S.target.value)},"x"),e[17]=x):x=e[17];let w;e[18]!==p?(w=(0,l.jsx)(X,{"data-testid":"org-member-role-value",id:"org-member-role-value",onChange:x,value:p}),e[18]=p,e[19]=w):w=e[19];let I;e[20]!==C||e[21]!==w?(I=(0,l.jsx)(W,{htmlFor:"org-member-role-value",label:C,children:w}),e[20]=C,e[21]=w,e[22]=I):I=e[22];let k;return e[23]!==a||e[24]!==n||e[25]!==c||e[26]!==v||e[27]!==I||e[28]!==f||e[29]!==z||e[30]!==y?(k=(0,l.jsx)(ue,{busy:a,canSubmit:f,error:n,onClose:c,onSubmit:v,submitLabel:z,testId:"org-member-role",title:y,children:I}),e[23]=a,e[24]=n,e[25]=c,e[26]=v,e[27]=I,e[28]=f,e[29]=z,e[30]=y,e[31]=k):k=e[31],k},"Wt"),Bt=m(t=>{let e=(0,H.c)(36),{mode:r,onClose:c,onDone:h,organizationId:i,team:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.name):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==a||e[3]!==r||e[4]!==b||e[5]!==c||e[6]!==h||e[7]!==i||e[8]!==p||e[9]!==o?.id?(g=m(()=>{p(async()=>{await(r==="create"?a.createAuthOrgTeam({name:b.trim(),organizationId:i}):a.updateAuthOrgTeam({name:b.trim(),teamId:D(o?.id)})),h(),c()})},"f"),e[2]=a,e[3]=r,e[4]=b,e[5]=c,e[6]=h,e[7]=i,e[8]=p,e[9]=o?.id,e[10]=g):g=e[10];let f=g,z;e[11]!==b?(z=b.trim(),e[11]=b,e[12]=z):z=e[12];let y=z!=="",C;e[13]!==r||e[14]!==n?(C=n(r==="create"?"Create":"Save"),e[13]=r,e[14]=n,e[15]=C):C=e[15];let x;e[16]!==r||e[17]!==n?(x=n(r==="create"?"New team":"Rename team"),e[16]=r,e[17]=n,e[18]=x):x=e[18];let w;e[19]!==n?(w=n("name"),e[19]=n,e[20]=w):w=e[20];let I;e[21]===Symbol.for("react.memo_cache_sentinel")?(I=m(A=>{v(A.target.value)},"C"),e[21]=I):I=e[21];let k;e[22]!==b?(k=(0,l.jsx)(X,{"data-testid":"org-team-form-name",id:"org-team-form-name",onChange:I,value:b}),e[22]=b,e[23]=k):k=e[23];let S;e[24]!==w||e[25]!==k?(S=(0,l.jsx)(W,{htmlFor:"org-team-form-name",label:w,children:k}),e[24]=w,e[25]=k,e[26]=S):S=e[26];let _;return e[27]!==d||e[28]!==s||e[29]!==c||e[30]!==f||e[31]!==S||e[32]!==y||e[33]!==C||e[34]!==x?(_=(0,l.jsx)(ue,{busy:d,canSubmit:y,error:s,onClose:c,onSubmit:f,submitLabel:C,testId:"org-team-form",title:x,children:S}),e[27]=d,e[28]=s,e[29]=c,e[30]=f,e[31]=S,e[32]=y,e[33]=C,e[34]=x,e[35]=_):_=e[35],_},"zt"),tr=m(t=>{let e=(0,H.c)(30),{onClose:r,onDone:c,teamId:h}=t,i=oe(),o=Q(),{busy:a,error:n,run:d}=me(),[s,p]=(0,E.useState)(""),u;e[0]!==i||e[1]!==r||e[2]!==c||e[3]!==d||e[4]!==h||e[5]!==s?(u=m(()=>{d(async()=>{await i.addAuthOrgTeamMember({teamId:h,userId:s.trim()}),c(),r()})},"c"),e[0]=i,e[1]=r,e[2]=c,e[3]=d,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!=="",f;e[9]!==o?(f=o("Add member"),e[9]=o,e[10]=f):f=e[10];let z;e[11]!==o?(z=o("Add team member"),e[11]=o,e[12]=z):z=e[12];let y;e[13]!==o?(y=o("User id"),e[13]=o,e[14]=y):y=e[14];let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=m(k=>{p(k.target.value)},"y"),e[15]=C):C=e[15];let x;e[16]!==s?(x=(0,l.jsx)(X,{"data-testid":"org-team-add-member-user",id:"org-team-add-member-user",onChange:C,value:s}),e[16]=s,e[17]=x):x=e[17];let w;e[18]!==y||e[19]!==x?(w=(0,l.jsx)(W,{htmlFor:"org-team-add-member-user",label:y,children:x}),e[18]=y,e[19]=x,e[20]=w):w=e[20];let I;return e[21]!==a||e[22]!==n||e[23]!==r||e[24]!==b||e[25]!==g||e[26]!==f||e[27]!==z||e[28]!==w?(I=(0,l.jsx)(ue,{busy:a,canSubmit:g,error:n,onClose:r,onSubmit:b,submitLabel:f,testId:"org-team-add-member",title:z,children:w}),e[21]=a,e[22]=n,e[23]=r,e[24]=b,e[25]=g,e[26]=f,e[27]=z,e[28]=w,e[29]=I):I=e[29],I},"Xt"),Jt=m(t=>{let e=(0,H.c)(47),{mode:r,onClose:c,onDone:h,organizationId:i,role:o}=t,a=oe(),n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==o?(u=o?D(o.role):"",e[0]=o,e[1]=u):u=e[1];let[b,v]=(0,E.useState)(u),g;e[2]!==r||e[3]!==o?.permission?(g=r==="edit"?Qt(o?.permission):"",e[2]=r,e[3]=o?.permission,e[4]=g):g=e[4];let[f,z]=(0,E.useState)(g),y;e[5]!==a||e[6]!==r||e[7]!==b||e[8]!==c||e[9]!==h||e[10]!==i||e[11]!==f||e[12]!==o?.id||e[13]!==p?(y=m(()=>{p(async()=>{let R=Wt(f);await(r==="create"?a.createAuthOrgRole({organizationId:i,permission:R,role:b.trim()}):a.updateAuthOrgRole({permission:R,roleId:D(o?.id)})),h(),c()})},"v"),e[5]=a,e[6]=r,e[7]=b,e[8]=c,e[9]=h,e[10]=i,e[11]=f,e[12]=o?.id,e[13]=p,e[14]=y):y=e[14];let C=y,x;e[15]!==r||e[16]!==b||e[17]!==f?(x=f.trim()!==""&&(r==="edit"||b.trim()!==""),e[15]=r,e[16]=b,e[17]=f,e[18]=x):x=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 I;e[22]!==r||e[23]!==n?(I=n(r==="create"?"New role":"Edit role"),e[22]=r,e[23]=n,e[24]=I):I=e[24];let k;e[25]!==r||e[26]!==b||e[27]!==n?(k=r==="create"&&(0,l.jsx)(W,{htmlFor:"org-role-form-name",label:n("Role name"),children:(0,l.jsx)(X,{"data-testid":"org-role-form-name",id:"org-role-form-name",onChange:m(R=>{v(R.target.value)},"onChange"),value:b})}),e[25]=r,e[26]=b,e[27]=n,e[28]=k):k=e[28];let S;e[29]!==n?(S=n('Permission (JSON, e.g. {"project":["create","update"]})'),e[29]=n,e[30]=S):S=e[30];let _;e[31]===Symbol.for("react.memo_cache_sentinel")?(_=m(R=>{z(R.target.value)},"O"),e[31]=_):_=e[31];let A;e[32]!==f?(A=(0,l.jsx)(Ot,{"data-testid":"org-role-form-permission",id:"org-role-form-permission",onChange:_,value:f}),e[32]=f,e[33]=A):A=e[33];let O;e[34]!==A||e[35]!==S?(O=(0,l.jsx)(W,{htmlFor:"org-role-form-permission",label:S,children:A}),e[34]=A,e[35]=S,e[36]=O):O=e[36];let T;return e[37]!==d||e[38]!==s||e[39]!==c||e[40]!==C||e[41]!==O||e[42]!==x||e[43]!==w||e[44]!==I||e[45]!==k?(T=(0,l.jsxs)(ue,{busy:d,canSubmit:x,error:s,onClose:c,onSubmit:C,submitLabel:w,testId:"org-role-form",title:I,children:[k,O]}),e[37]=d,e[38]=s,e[39]=c,e[40]=C,e[41]=O,e[42]=x,e[43]=w,e[44]=I,e[45]=k,e[46]=T):T=e[46],T},"At"),Zt=m(t=>{let e=(0,H.c)(18),{action:r,message:c,onClose:h,onDone:i,testId:o,title:a}=t,n=Q(),{busy:d,error:s,run:p}=me(),u;e[0]!==r||e[1]!==h||e[2]!==i||e[3]!==p?(u=m(()=>{p(async()=>{await r(),i(),h()})},"c"),e[0]=r,e[1]=h,e[2]=i,e[3]=p,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]!==c?(g=(0,l.jsx)("p",{className:"text-sm text-muted-foreground",children:c}),e[7]=c,e[8]=g):g=e[8];let f;return e[9]!==d||e[10]!==s||e[11]!==h||e[12]!==b||e[13]!==v||e[14]!==g||e[15]!==o||e[16]!==a?(f=(0,l.jsx)(ue,{busy:d,canSubmit:!0,destructive:!0,error:s,onClose:h,onSubmit:b,submitLabel:v,testId:o,title:a,children:g}),e[9]=d,e[10]=s,e[11]=h,e[12]=b,e[13]=v,e[14]=g,e[15]=o,e[16]=a,e[17]=f):f=e[17],f},"Lt"),et=m(t=>{let e=(0,H.c)(13),{action:r,children:c,heading:h,testId:i}=t,o;e[0]!==h?(o=(0,l.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 a;e[2]!==r?(a=r!==void 0&&(0,l.jsx)("div",{className:"flex items-center gap-2",children:r}),e[2]=r,e[3]=a):a=e[3];let n;e[4]!==o||e[5]!==a?(n=(0,l.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[o,a]}),e[4]=o,e[5]=a,e[6]=n):n=e[6];let d;e[7]!==c?(d=(0,l.jsx)(kt,{className:"px-0",children:c}),e[7]=c,e[8]=d):d=e[8];let s;return e[9]!==n||e[10]!==d||e[11]!==i?(s=(0,l.jsxs)(zt,{className:"overflow-hidden py-0","data-testid":i,children:[n,d]}),e[9]=n,e[10]=d,e[11]=i,e[12]=s):s=e[12],s},"Ye"),tt=m(t=>{let e=(0,H.c)(23),{columns:r,rowActions:c,rowPrefix:h,rows:i}=t,o=Q(),a;e[0]!==r?(a=r.map(rr),e[0]=r,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("Actions"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==n?(d=(0,l.jsx)(de,{"aria-label":n}),e[4]=n,e[5]=d):d=e[5];let s;e[6]!==a||e[7]!==d?(s=(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[a,d]})}),e[6]=a,e[7]=d,e[8]=s):s=e[8];let p;if(e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i){let v;e[14]!==r||e[15]!==c||e[16]!==h?(v=m((g,f)=>{let z=D(g.id),y=z===""?`index-${f.toString()}`:z;return(0,l.jsxs)(Ve,{"data-testid":`${h}-${y}`,children:[r.map(C=>(0,l.jsx)(ce,{className:C.className,children:C.render(g)},C.head)),(0,l.jsx)(ce,{children:(0,l.jsx)("div",{className:"flex justify-end gap-1",children:c(g)})})]},y)},"p"),e[14]=r,e[15]=c,e[16]=h,e[17]=v):v=e[17],p=i.map(v),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=p}else p=e[13];let u;e[18]!==p?(u=(0,l.jsx)(Dt,{children:p}),e[18]=p,e[19]=u):u=e[19];let b;return e[20]!==s||e[21]!==u?(b=(0,l.jsxs)(Nt,{children:[s,u]}),e[20]=s,e[21]=u,e[22]=b):b=e[22],b},"et");function rr(t){return(0,l.jsx)(de,{children:t.head},t.head)}m(rr,"Yt");var or=m(t=>{let e=(0,H.c)(30),{actionBusy:r,onRemoveMember:c,memberColumns:h,members:i,onDialog:o}=t,a=Q(),n;e[0]!==o?(n=m(()=>{o({kind:"add-member"})},"r"),e[0]=o,e[1]=n):n=e[1];let d;e[2]!==a?(d=a("Add member"),e[2]=a,e[3]=d):d=e[3];let s;e[4]!==n||e[5]!==d?(s=(0,l.jsx)(L,{"data-testid":"org-open-add-member",onClick:n,size:"xs",type:"button",variant:"outline",children:d}),e[4]=n,e[5]=d,e[6]=s):s=e[6];let p;e[7]!==o?(p=m(()=>{o({kind:"invite-member"})},"h"),e[7]=o,e[8]=p):p=e[8];let u;e[9]!==a?(u=a("Invite member"),e[9]=a,e[10]=u):u=e[10];let b;e[11]!==p||e[12]!==u?(b=(0,l.jsx)(L,{"data-testid":"org-open-invite-member",onClick:p,size:"xs",type:"button",variant:"outline",children:u}),e[11]=p,e[12]=u,e[13]=b):b=e[13];let v;e[14]!==s||e[15]!==b?(v=(0,l.jsxs)(l.Fragment,{children:[s,b]}),e[14]=s,e[15]=b,e[16]=v):v=e[16];let g;e[17]!==a?(g=a("Members"),e[17]=a,e[18]=g):g=e[18];let f;e[19]!==r||e[20]!==h||e[21]!==i||e[22]!==o||e[23]!==c||e[24]!==a?(f=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-members-empty",title:a("No members.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(y=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-member-role-${D(y.id)}`,onClick:m(()=>{o({kind:"member-role",member:y})},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Change role")}),(0,l.jsx)(L,{"data-testid":`org-remove-member-${D(y.id)}`,disabled:r,onClick:m(()=>{c(D(y.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Remove")})]}),"rowActions"),rowPrefix:"org-member",rows:i}),e[19]=r,e[20]=h,e[21]=i,e[22]=o,e[23]=c,e[24]=a,e[25]=f):f=e[25];let z;return e[26]!==v||e[27]!==g||e[28]!==f?(z=(0,l.jsx)(et,{action:v,heading:g,testId:"org-members",children:f}),e[26]=v,e[27]=g,e[28]=f,e[29]=z):z=e[29],z},"el"),lr=m(t=>{let e=(0,H.c)(21),{onConfirmDeleteTeam:r,onDialog:c,onSelectTeam:h,selectedTeam:i,teamColumns:o,teams:a}=t,n=Q(),d;e[0]!==c?(d=m(()=>{c({kind:"team-create"})},"m"),e[0]=c,e[1]=d):d=e[1];let s;e[2]!==n?(s=n("New team"),e[2]=n,e[3]=s):s=e[3];let p;e[4]!==d||e[5]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-create-team",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[4]=d,e[5]=s,e[6]=p):p=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]!==c||e[11]!==h||e[12]!==i||e[13]!==n||e[14]!==o||e[15]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-teams-empty",title:n("No teams.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"aria-pressed":i===D(g.id),"data-testid":`org-team-select-${D(g.id)}`,onClick:m(()=>{h(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Members")}),(0,l.jsx)(L,{"data-testid":`org-team-rename-${D(g.id)}`,onClick:m(()=>{c({kind:"team-rename",team:g})},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Rename")}),(0,l.jsx)(L,{"data-testid":`org-team-delete-${D(g.id)}`,onClick:m(()=>{r(g)},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Delete")})]}),"rowActions"),rowPrefix:"org-team",rows:a}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=n,e[14]=o,e[15]=a,e[16]=b):b=e[16];let v;return e[17]!==p||e[18]!==u||e[19]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-teams",children:b}),e[17]=p,e[18]=u,e[19]=b,e[20]=v):v=e[20],v},"tl"),ar=m(t=>{let e=(0,H.c)(20),{actionBusy:r,onRemoveTeamMember:c,onDialog:h,selectedTeam:i,teamMemberColumns:o,teamMembers:a}=t,n=Q(),d;e[0]!==h||e[1]!==i?(d=m(()=>{h({kind:"team-add-member",teamId:i})},"m"),e[0]=h,e[1]=i,e[2]=d):d=e[2];let s;e[3]!==n?(s=n("Add member"),e[3]=n,e[4]=s):s=e[4];let p;e[5]!==d||e[6]!==s?(p=(0,l.jsx)(L,{"data-testid":"org-open-add-team-member",onClick:d,size:"xs",type:"button",variant:"outline",children:s}),e[5]=d,e[6]=s,e[7]=p):p=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]!==c||e[12]!==n||e[13]!==o||e[14]!==a?(b=a.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-team-members-empty",title:n("No team members.")})}):(0,l.jsx)(tt,{columns:o,rowActions:m(g=>(0,l.jsx)(L,{"data-testid":`org-team-remove-member-${D(g.id)}`,disabled:r,onClick:m(()=>{c(D(g.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:n("Remove")}),"rowActions"),rowPrefix:"org-team-member",rows:a}),e[10]=r,e[11]=c,e[12]=n,e[13]=o,e[14]=a,e[15]=b):b=e[15];let v;return e[16]!==p||e[17]!==u||e[18]!==b?(v=(0,l.jsx)(et,{action:p,heading:u,testId:"org-team-members",children:b}),e[16]=p,e[17]=u,e[18]=b,e[19]=v):v=e[19],v},"ll"),nr=m(t=>{let e=(0,H.c)(19),{onConfirmDeleteRole:r,onDialog:c,roleColumns:h,roles:i}=t,o=Q(),a;e[0]!==c?(a=m(()=>{c({kind:"role-create"})},"i"),e[0]=c,e[1]=a):a=e[1];let n;e[2]!==o?(n=o("New role"),e[2]=o,e[3]=n):n=e[3];let d;e[4]!==a||e[5]!==n?(d=(0,l.jsx)(L,{"data-testid":"org-open-create-role",onClick:a,size:"xs",type:"button",variant:"outline",children:n}),e[4]=a,e[5]=n,e[6]=d):d=e[6];let s;e[7]!==o?(s=o("Roles"),e[7]=o,e[8]=s):s=e[8];let p;e[9]!==r||e[10]!==c||e[11]!==h||e[12]!==i||e[13]!==o?(p=i.length===0?(0,l.jsx)("div",{className:"p-3",children:(0,l.jsx)(ge,{testId:"org-roles-empty",title:o("No custom roles.")})}):(0,l.jsx)(tt,{columns:h,rowActions:m(b=>(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(L,{"data-testid":`org-role-edit-${D(b.id)}`,onClick:m(()=>{c({kind:"role-edit",role:b})},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Edit")}),(0,l.jsx)(L,{"data-testid":`org-role-delete-${D(b.id)}`,onClick:m(()=>{r(D(b.id))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Delete")})]}),"rowActions"),rowPrefix:"org-role",rows:i}),e[9]=r,e[10]=c,e[11]=h,e[12]=i,e[13]=o,e[14]=p):p=e[14];let u;return e[15]!==d||e[16]!==s||e[17]!==p?(u=(0,l.jsx)(et,{action:d,heading:s,testId:"org-roles",children:p}),e[15]=d,e[16]=s,e[17]=p,e[18]=u):u=e[18],u},"ol"),Ut=200,ir=m(t=>{let e=(0,H.c)(217),{organizationId:r,rolesEnabled:c,teamsEnabled:h}=t,i=oe(),o=Q(),[a,n]=(0,E.useState)(null),[d,s]=(0,E.useState)(null),[p,u]=(0,E.useState)(!1),[b,v]=(0,E.useState)(null),[g,f]=jt(r),z;e[0]!==g||e[1]!==r?(z=["lunora-auth-org-members",r,g],e[0]=g,e[1]=r,e[2]=z):z=e[2];let y;e[3]!==i||e[4]!==g||e[5]!==r?(y=m(()=>i.listAuthOrgMembers({limit:Ut,offset:g,organizationId:r}),"v"),e[3]=i,e[4]=g,e[5]=r,e[6]=y):y=e[6];let C=he(z,y),x;e[7]!==r?(x=["lunora-auth-org-invitations",r],e[7]=r,e[8]=x):x=e[8];let w;e[9]!==i||e[10]!==r?(w=m(()=>i.listAuthOrgInvitations({limit:200,organizationId:r}),"I"),e[9]=i,e[10]=r,e[11]=w):w=e[11];let I=he(x,w),k;e[12]!==r?(k=["lunora-auth-org-teams",r],e[12]=r,e[13]=k):k=e[13];let S;e[14]!==i||e[15]!==r?(S=m(()=>i.listAuthOrgTeams({limit:200,organizationId:r}),"k"),e[14]=i,e[15]=r,e[16]=S):S=e[16];let _;e[17]!==h?(_={enabled:h},e[17]=h,e[18]=_):_=e[18];let A=he(k,S,_),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=m(()=>i.listAuthOrgRoles({limit:200,organizationId:r}),"_"),e[21]=i,e[22]=r,e[23]=T):T=e[23];let R;e[24]!==c?(R={enabled:c},e[24]=c,e[25]=R):R=e[25];let F=he(O,T,R),Z;e[26]!==d?(Z=["lunora-auth-org-team-members",d],e[26]=d,e[27]=Z):Z=e[27];let B;e[28]!==i||e[29]!==d?(B=m(()=>i.listAuthOrgTeamMembers({limit:200,teamId:d??""}),"B"),e[28]=i,e[29]=d,e[30]=B):B=e[30];let K=d!==null,J;e[31]!==K?(J={enabled:K},e[31]=K,e[32]=J):J=e[32];let j=he(Z,B,J),U;e[33]!==C.data?.rows?(U=C.data?.rows??[],e[33]=C.data?.rows,e[34]=U):U=e[34];let P=U,Y;e[35]!==I.data?.rows?(Y=I.data?.rows??[],e[35]=I.data?.rows,e[36]=Y):Y=e[36];let M=Y,$;e[37]!==A.data?.rows?($=A.data?.rows??[],e[37]=A.data?.rows,e[38]=$):$=e[38];let q=$,V;e[39]!==F.data?.rows?(V=F.data?.rows??[],e[39]=F.data?.rows,e[40]=V):V=e[40];let te=V,le;e[41]!==d||e[42]!==j.data?.rows?(le=d===null?[]:j.data?.rows??[],e[41]=d,e[42]=j.data?.rows,e[43]=le):le=e[43];let re=le,ee=C.error??I.error??A.error??F.error??j.error,ae;if(e[44]!==I||e[45]!==C||e[46]!==c||e[47]!==F||e[48]!==d||e[49]!==j||e[50]!==h||e[51]!==A){let G=m(()=>{let se=[C.poll(),I.poll()];return h&&se.push(A.poll()),c&&se.push(F.poll()),d!==null&&se.push(j.poll()),Ft(se)},"V");ae=m(()=>{St(G())},"ie"),e[44]=I,e[45]=C,e[46]=c,e[47]=F,e[48]=d,e[49]=j,e[50]=h,e[51]=A,e[52]=ae}else ae=e[52];let N=ae,rt;e[53]!==C?(rt=m(()=>C.poll(),"tt"),e[53]=C,e[54]=rt):rt=e[54],be(rt,!0);let ot;e[55]!==I?(ot=m(()=>I.poll(),"lt"),e[55]=I,e[56]=ot):ot=e[56],be(ot,!0);let lt;e[57]!==A?(lt=m(()=>A.poll(),"ot"),e[57]=A,e[58]=lt):lt=e[58],be(lt,h);let at;e[59]!==F?(at=m(()=>F.poll(),"it"),e[59]=F,e[60]=at):at=e[60],be(at,c);let nt;e[61]!==j?(nt=m(()=>j.poll(),"rt"),e[61]=j,e[62]=nt):nt=e[62],be(nt,d!==null);let it;e[63]===Symbol.for("react.memo_cache_sentinel")?(it=m(()=>{n(null)},"st"),e[63]=it):it=e[63];let ne=it,st;e[64]!==N?(st=m(G=>{St((async()=>{u(!0),v(null);try{await G(),N(),u(!1)}catch(se){v(Rt(se)),u(!1)}})())},"nt"),e[64]=N,e[65]=st):st=e[65];let ie=st,mt;e[66]!==i||e[67]!==o?(mt=m(G=>{let se=D(G.id);n({action:m(async()=>{await i.removeAuthOrgTeam({teamId:se}),s(Tt=>Tt===se?null:Tt)},"action"),kind:"confirm",message:o("Delete this team and its memberships? This cannot be undone."),testId:"org-team-delete",title:o("Delete team")})},"at"),e[66]=i,e[67]=o,e[68]=mt):mt=e[68];let pt=mt,pe;e[69]!==o?(pe=o("userId"),e[69]=o,e[70]=pe):pe=e[70];let fe;e[71]!==pe?(fe={head:pe,render:sr},e[71]=pe,e[72]=fe):fe=e[72];let ve;e[73]!==o?(ve=o("role"),e[73]=o,e[74]=ve):ve=e[74];let ye;e[75]!==ve?(ye={head:ve,render:mr},e[75]=ve,e[76]=ye):ye=e[76];let dt;e[77]!==fe||e[78]!==ye?(dt=[fe,ye],e[77]=fe,e[78]=ye,e[79]=dt):dt=e[79];let ft=dt,Ce;e[80]!==o?(Ce=o("email"),e[80]=o,e[81]=Ce):Ce=e[81];let Ie;e[82]!==Ce?(Ie={head:Ce,render:dr},e[82]=Ce,e[83]=Ie):Ie=e[83];let xe;e[84]!==o?(xe=o("role"),e[84]=o,e[85]=xe):xe=e[85];let we;e[86]!==xe?(we={head:xe,render:cr},e[86]=xe,e[87]=we):we=e[87];let ze;e[88]!==o?(ze=o("status"),e[88]=o,e[89]=ze):ze=e[89];let ke;e[90]!==ze?(ke={head:ze,render:ur},e[90]=ze,e[91]=ke):ke=e[91];let ct;e[92]!==Ie||e[93]!==we||e[94]!==ke?(ct=[Ie,we,ke],e[92]=Ie,e[93]=we,e[94]=ke,e[95]=ct):ct=e[95];let vt=ct,Se;e[96]!==o?(Se=o("id"),e[96]=o,e[97]=Se):Se=e[97];let Ne;e[98]!==Se?(Ne={className:"font-mono text-xs",head:Se,render:gr},e[98]=Se,e[99]=Ne):Ne=e[99];let Ae;e[100]!==o?(Ae=o("name"),e[100]=o,e[101]=Ae):Ae=e[101];let De;e[102]!==Ae?(De={head:Ae,render:hr},e[102]=Ae,e[103]=De):De=e[103];let ut;e[104]!==Ne||e[105]!==De?(ut=[Ne,De],e[104]=Ne,e[105]=De,e[106]=ut):ut=e[106];let yt=ut,Oe;e[107]!==o?(Oe=o("userId"),e[107]=o,e[108]=Oe):Oe=e[108];let gt;e[109]!==Oe?(gt=[{head:Oe,render:br}],e[109]=Oe,e[110]=gt):gt=e[110];let Ct=gt,_e;e[111]!==o?(_e=o("role"),e[111]=o,e[112]=_e):_e=e[112];let Te;e[113]!==_e?(Te={head:_e,render:pr},e[113]=_e,e[114]=Te):Te=e[114];let Re;e[115]!==o?(Re=o("Permission"),e[115]=o,e[116]=Re):Re=e[116];let $e;e[117]!==Re?($e={className:"font-mono text-xs whitespace-pre-wrap",head:Re,render:fr},e[117]=Re,e[118]=$e):$e=e[118];let ht;e[119]!==Te||e[120]!==$e?(ht=[Te,$e],e[119]=Te,e[120]=$e,e[121]=ht):ht=e[121];let It=ht,Me;e[122]!==ee?(Me=ee!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-detail-error",role:"alert",children:ee}),e[122]=ee,e[123]=Me):Me=e[123];let Fe;e[124]!==b?(Fe=b!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-action-error",role:"alert",children:b}),e[124]=b,e[125]=Fe):Fe=e[125];let je;e[126]!==i||e[127]!==ie?(je=m(G=>{ie(()=>i.removeAuthOrgMember({memberId:G}))},"Me"),e[126]=i,e[127]=ie,e[128]=je):je=e[128];let Ee;e[129]!==p||e[130]!==ft||e[131]!==P||e[132]!==je?(Ee=(0,l.jsx)(or,{actionBusy:p,memberColumns:ft,members:P,onDialog:n,onRemoveMember:je}),e[129]=p,e[130]=ft,e[131]=P,e[132]=je,e[133]=Ee):Ee=e[133];let xt=C.data?.total,Le;e[134]!==P.length||e[135]!==g||e[136]!==f||e[137]!==xt?(Le=(0,l.jsx)(_t,{count:P.length,offset:g,onOffsetChange:f,pageSize:Ut,prefix:"org-members",total:xt}),e[134]=P.length,e[135]=g,e[136]=f,e[137]=xt,e[138]=Le):Le=e[138];let Pe;e[139]!==p||e[140]!==i||e[141]!==vt||e[142]!==M||e[143]!==ie||e[144]!==o?(Pe=M.length>0&&(0,l.jsx)(et,{heading:o("Invitations"),testId:"org-invitations",children:(0,l.jsx)(tt,{columns:vt,rowActions:m(G=>(0,l.jsx)(L,{"data-testid":`org-cancel-invitation-${D(G.id)}`,disabled:p,onClick:m(()=>{ie(()=>i.cancelAuthOrgInvitation({invitationId:D(G.id)}))},"onClick"),size:"xs",type:"button",variant:"ghost",children:o("Cancel")}),"rowActions"),rowPrefix:"org-invitation",rows:M})}),e[139]=p,e[140]=i,e[141]=vt,e[142]=M,e[143]=ie,e[144]=o,e[145]=Pe):Pe=e[145];let Be;e[146]!==pt||e[147]!==d||e[148]!==yt||e[149]!==q||e[150]!==h?(Be=h&&(0,l.jsx)(lr,{onConfirmDeleteTeam:pt,onDialog:n,onSelectTeam:s,selectedTeam:d,teamColumns:yt,teams:q}),e[146]=pt,e[147]=d,e[148]=yt,e[149]=q,e[150]=h,e[151]=Be):Be=e[151];let Je;e[152]!==p||e[153]!==i||e[154]!==ie||e[155]!==d||e[156]!==Ct||e[157]!==re||e[158]!==h?(Je=h&&d!==null&&(0,l.jsx)(ar,{actionBusy:p,onDialog:n,onRemoveTeamMember:m(G=>{ie(()=>i.removeAuthOrgTeamMember({teamMemberId:G}))},"onRemoveTeamMember"),selectedTeam:d,teamMemberColumns:Ct,teamMembers:re}),e[152]=p,e[153]=i,e[154]=ie,e[155]=d,e[156]=Ct,e[157]=re,e[158]=h,e[159]=Je):Je=e[159];let Ue;e[160]!==i||e[161]!==It||e[162]!==te||e[163]!==c||e[164]!==o?(Ue=c&&(0,l.jsx)(nr,{onConfirmDeleteRole:m(G=>{n({action:m(()=>i.deleteAuthOrgRole({roleId:G}),"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:It,roles:te}),e[160]=i,e[161]=It,e[162]=te,e[163]=c,e[164]=o,e[165]=Ue):Ue=e[165];let He;e[166]!==a?.kind||e[167]!==r||e[168]!==N?(He=a?.kind==="add-member"&&(0,l.jsx)(Xt,{onClose:ne,onDone:N,organizationId:r}),e[166]=a?.kind,e[167]=r,e[168]=N,e[169]=He):He=e[169];let Ke;e[170]!==a?.kind||e[171]!==r||e[172]!==N?(Ke=a?.kind==="invite-member"&&(0,l.jsx)(Vt,{onClose:ne,onDone:N,organizationId:r}),e[170]=a?.kind,e[171]=r,e[172]=N,e[173]=Ke):Ke=e[173];let Qe;e[174]!==a||e[175]!==N?(Qe=a?.kind==="member-role"&&(0,l.jsx)(er,{member:a.member,onClose:ne,onDone:N}),e[174]=a,e[175]=N,e[176]=Qe):Qe=e[176];let Ze;e[177]!==a?.kind||e[178]!==r||e[179]!==N?(Ze=a?.kind==="team-create"&&(0,l.jsx)(Bt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[177]=a?.kind,e[178]=r,e[179]=N,e[180]=Ze):Ze=e[180];let Ye;e[181]!==a||e[182]!==r||e[183]!==N?(Ye=a?.kind==="team-rename"&&(0,l.jsx)(Bt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,team:a.team}),e[181]=a,e[182]=r,e[183]=N,e[184]=Ye):Ye=e[184];let qe;e[185]!==a||e[186]!==N?(qe=a?.kind==="team-add-member"&&(0,l.jsx)(tr,{onClose:ne,onDone:N,teamId:a.teamId}),e[185]=a,e[186]=N,e[187]=qe):qe=e[187];let Ge;e[188]!==a?.kind||e[189]!==r||e[190]!==N?(Ge=a?.kind==="role-create"&&(0,l.jsx)(Jt,{mode:"create",onClose:ne,onDone:N,organizationId:r}),e[188]=a?.kind,e[189]=r,e[190]=N,e[191]=Ge):Ge=e[191];let We;e[192]!==a||e[193]!==r||e[194]!==N?(We=a?.kind==="role-edit"&&(0,l.jsx)(Jt,{mode:"edit",onClose:ne,onDone:N,organizationId:r,role:a.role}),e[192]=a,e[193]=r,e[194]=N,e[195]=We):We=e[195];let Xe;e[196]!==a||e[197]!==N?(Xe=a?.kind==="confirm"&&(0,l.jsx)(Zt,{action:a.action,message:a.message,onClose:ne,onDone:N,testId:a.testId,title:a.title}),e[196]=a,e[197]=N,e[198]=Xe):Xe=e[198];let bt;return e[199]!==Me||e[200]!==Fe||e[201]!==Ee||e[202]!==Le||e[203]!==Pe||e[204]!==Be||e[205]!==Je||e[206]!==Ue||e[207]!==He||e[208]!==Ke||e[209]!==Qe||e[210]!==Ze||e[211]!==Ye||e[212]!==qe||e[213]!==Ge||e[214]!==We||e[215]!==Xe?(bt=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"org-detail",children:[Me,Fe,Ee,Le,Pe,Be,Je,Ue,He,Ke,Qe,Ze,Ye,qe,Ge,We,Xe]}),e[199]=Me,e[200]=Fe,e[201]=Ee,e[202]=Le,e[203]=Pe,e[204]=Be,e[205]=Je,e[206]=Ue,e[207]=He,e[208]=Ke,e[209]=Qe,e[210]=Ze,e[211]=Ye,e[212]=qe,e[213]=Ge,e[214]=We,e[215]=Xe,e[216]=bt):bt=e[216],bt},"il");function sr(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(sr,"rl");function mr(t){return D(t.role)}m(mr,"sl");function dr(t){return D(t.email)}m(dr,"nl");function cr(t){return D(t.role)}m(cr,"al");function ur(t){return D(t.status)}m(ur,"ml");function gr(t){return D(t.id)}m(gr,"dl");function hr(t){return D(t.name)}m(hr,"cl");function br(t){return(0,l.jsx)("span",{className:"font-mono text-xs",children:D(t.userId)})}m(br,"fl");function pr(t){return D(t.role)}m(pr,"ul");function fr(t){return D(t.permission)}m(fr,"gl");var Ht=100,$r=m(()=>{let t=(0,H.c)(69),e=oe(),r=Q(),{config:c,ready:h}=Et(),i=c.capabilities.organization,[o,a]=(0,E.useState)(null),[n,d]=(0,E.useState)(null),[s,p]=(0,E.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=m(()=>e.listAuthOrganizations({limit:Ht,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=he(u,b,v),f=g.data?.rows??null,z;t[7]!==g?(z=m(()=>g.poll(),"S"),t[7]=g,t[8]=z):z=t[8],be(z,i);let y;t[9]===Symbol.for("react.memo_cache_sentinel")?(y=m(()=>{d(null)},"v"),t[9]=y):y=t[9];let C=y,x;t[10]!==g?(x=m(()=>{g.refetch()},"x"),t[10]=g,t[11]=x):x=t[11];let w=x,I;t[12]===Symbol.for("react.memo_cache_sentinel")?(I=m(M=>{a(M)},"C"),t[12]=I):I=t[12];let k=I;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 $;t[15]!==r?($=r("Organizations are not enabled."),t[15]=r,t[16]=$):$=t[16];let q;return t[17]!==M||t[18]!==$?(q=(0,l.jsx)(ge,{description:M,testId:"org-disabled",title:$}),t[17]=M,t[18]=$,t[19]=q):q=t[19],q}let S;t[20]!==r?(S=r("Organizations"),t[20]=r,t[21]=S):S=t[21];let _;t[22]!==S?(_=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:S}),t[22]=S,t[23]=_):_=t[23];let A;t[24]===Symbol.for("react.memo_cache_sentinel")?(A=m(()=>{d({kind:"create"})},"z"),t[24]=A):A=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,l.jsx)(L,{"data-testid":"org-new",onClick:A,size:"sm",type:"button",children:O}),t[27]=O,t[28]=T):T=t[28];let R;t[29]!==T||t[30]!==_?(R=(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[_,T]}),t[29]=T,t[30]=_,t[31]=R):R=t[31];let F;t[32]!==g.error?(F=g.error!==null&&(0,l.jsx)("p",{className:"text-sm text-destructive","data-testid":"org-error",role:"alert",children:g.error}),t[32]=g.error,t[33]=F):F=t[33];let Z;t[34]!==f||t[35]!==r?(Z=f!==null&&f.length===0&&(0,l.jsx)(ge,{testId:"org-empty",title:r("No organizations.")}),t[34]=f,t[35]=r,t[36]=Z):Z=t[36];let B;t[37]!==f||t[38]!==o||t[39]!==r?(B=f!==null&&f.length>0&&(0,l.jsx)(zt,{className:"overflow-hidden py-0",children:(0,l.jsx)(kt,{className:"px-0",children:(0,l.jsxs)(Nt,{"data-testid":"org-table",children:[(0,l.jsx)(At,{children:(0,l.jsxs)(Ve,{children:[(0,l.jsx)(de,{children:r("id")}),(0,l.jsx)(de,{children:r("name")}),(0,l.jsx)(de,{children:r("slug")}),(0,l.jsx)(de,{children:r("created")}),(0,l.jsx)(de,{"aria-label":r("Actions")})]})}),(0,l.jsx)(Dt,{children:f.map(M=>{let $=D(M.id);return(0,l.jsxs)(Ve,{"data-testid":`org-row-${$}`,children:[(0,l.jsx)(ce,{className:"font-mono text-xs",children:$}),(0,l.jsx)(ce,{children:D(M.name)}),(0,l.jsx)(ce,{children:D(M.slug)}),(0,l.jsx)(ce,{className:"text-muted-foreground tabular-nums",children:$t(M.createdAt)}),(0,l.jsx)(ce,{children:(0,l.jsxs)("div",{className:"flex justify-end gap-1",children:[(0,l.jsx)(L,{"aria-pressed":o===$,"data-testid":`org-select-${$}`,onClick:m(()=>{k($)},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Manage")}),(0,l.jsx)(L,{"data-testid":`org-edit-${$}`,onClick:m(()=>{d({kind:"edit",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Edit")}),(0,l.jsx)(L,{"data-testid":`org-delete-${$}`,onClick:m(()=>{d({kind:"delete",org:M})},"onClick"),size:"xs",type:"button",variant:"ghost",children:r("Delete")})]})})]},$)})})]})})}),t[37]=f,t[38]=o,t[39]=r,t[40]=B):B=t[40];let K;t[41]!==s||t[42]!==f||t[43]!==g.data?.total?(K=f!==null&&(0,l.jsx)(_t,{count:f.length,offset:s,onOffsetChange:p,pageSize:Ht,prefix:"org",total:g.data?.total}),t[41]=s,t[42]=f,t[43]=g.data?.total,t[44]=K):K=t[44];let J;t[45]!==c.organization||t[46]!==o?(J=o!==null&&(0,l.jsx)(ir,{organizationId:o,rolesEnabled:c.organization.roles,teamsEnabled:c.organization.teams}),t[45]=c.organization,t[46]=o,t[47]=J):J=t[47];let j;t[48]!==n?.kind||t[49]!==w?(j=n?.kind==="create"&&(0,l.jsx)(Pt,{mode:"create",onClose:C,onDone:w}),t[48]=n?.kind,t[49]=w,t[50]=j):j=t[50];let U;t[51]!==n||t[52]!==w?(U=n?.kind==="edit"&&(0,l.jsx)(Pt,{mode:"edit",onClose:C,onDone:w,org:n.org}),t[51]=n,t[52]=w,t[53]=U):U=t[53];let P;t[54]!==e||t[55]!==n||t[56]!==w||t[57]!==r?(P=n?.kind==="delete"&&(0,l.jsx)(Zt,{action:m(async()=>{let M=D(n.org.id);await e.deleteAuthOrganization({organizationId:M}),a($=>$===M?null:$)},"action"),message:r("Delete this organization? Its members, invitations, teams, and custom roles are removed. This cannot be undone."),onClose:C,onDone:w,testId:"org-delete",title:r("Delete organization")}),t[54]=e,t[55]=n,t[56]=w,t[57]=r,t[58]=P):P=t[58];let Y;return t[59]!==R||t[60]!==F||t[61]!==Z||t[62]!==B||t[63]!==K||t[64]!==J||t[65]!==j||t[66]!==U||t[67]!==P?(Y=(0,l.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-organizations",children:[R,F,Z,B,K,J,j,U,P]}),t[59]=R,t[60]=F,t[61]=Z,t[62]=B,t[63]=K,t[64]=J,t[65]=j,t[66]=U,t[67]=P,t[68]=Y):Y=t[68],Y},"Ml");export{$r as default};
@@ -1 +1 @@
1
- import{b as g}from"./chunk-Z643LPA5.js";import"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-YSPQIRER.js";import"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import"./chunk-HCTJKP5J.js";import"./chunk-2IKDEUCX.js";import{d as p}from"./chunk-74IYYDDI.js";import{a as r,d as h,f as S,g as A}from"./chunk-I26MS5PJ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
1
+ import{b as g}from"./chunk-H6MI6GGH.js";import"./chunk-M27YVZWM.js";import"./chunk-NCPW7WHO.js";import"./chunk-LXQGF74P.js";import"./chunk-55UGUCQ6.js";import{a as f}from"./chunk-4ZEL6BYL.js";import{c as m}from"./chunk-NWWMHMGA.js";import"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import"./chunk-HCTJKP5J.js";import"./chunk-2IKDEUCX.js";import{d as p}from"./chunk-74IYYDDI.js";import{a as r,d as h,f as S,g as A}from"./chunk-I26MS5PJ.js";var R=h(S(),1);var k=h(A(),1);var _=r((e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],"k"),w=r(e=>Array.isArray(e.findings)?e.findings:[],"g"),b=r(e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],"S"),E=r((e,s)=>({"admin-token-weak":e("Your admin token is {length} characters \u2014 use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters \u2014 use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed \u2014 browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected \u2014 they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],"A"),O=r(()=>{let e=(0,R.c)(8),s=p(),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i={},e[0]=i):i=e[0];let{data:a,error:d,errorSource:c}=m(f.getSecurityAudit,i),n;if(e[1]!==a||e[2]!==s){let u=a===void 0?null:w(a);n=u===null?null:u.map(t=>({description:E(s,t),entity:b(t),issueType:_(s,t),key:t.kind,level:t.level})),e[1]=a,e[2]=s,e[3]=n}else n=e[3];let l=n,o;return e[4]!==d||e[5]!==c||e[6]!==l?(o=(0,k.jsx)(g,{error:d,errorSource:c,rows:l,testId:"lunora-security-advisor"}),e[4]=d,e[5]=c,e[6]=l,e[7]=o):o=e[7],o},"T");export{O as default};
@@ -0,0 +1 @@
1
+ import{a as y,b as D}from"./chunk-Q6IT6ZD7.js";import{a as _,b as z,c as j,d as E,e as B,f as H,g as L,h as V,i as O,j as T,k as Z,l as q}from"./chunk-CMVOO3MU.js";import{i as P}from"./chunk-E4PXACVL.js";import{a as k}from"./chunk-7G4Z6Q7X.js";import{b as w}from"./chunk-Q6ED4KUL.js";import{d as $,q as I}from"./chunk-74IYYDDI.js";import{a as u,d as S,e as le,f as se,g as de,i as N}from"./chunk-I26MS5PJ.js";var v=S(se(),1);var b=S(le(),1);var s=S(de(),1);function ie(a){let e=(0,v.c)(10),t,n,r;e[0]!==a?({className:t,selected:r,...n}=a,e[0]=a,e[1]=t,e[2]=n,e[3]=r):(t=e[1],n=e[2],r=e[3]);let l=r===!0?"":void 0,o;e[4]!==t?(o=N("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=o):o=e[5];let d;return e[6]!==n||e[7]!==l||e[8]!==o?(d=(0,s.jsx)("div",{"data-slot":"base-node","data-selected":l,className:o,...n}),e[6]=n,e[7]=l,e[8]=o,e[9]=d):d=e[9],d}u(ie,"ie");function ce(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-header",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(ce,"ce");function me(a){let e=(0,v.c)(8),t,n;e[0]!==a?({className:t,...n}=a,e[0]=a,e[1]=t,e[2]=n):(t=e[1],n=e[2]);let r;e[3]!==t?(r=N("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let l;return e[5]!==n||e[6]!==r?(l=(0,s.jsx)("div",{"data-slot":"base-node-content",className:r,...n}),e[5]=n,e[6]=r,e[7]=l):l=e[7],l}u(me,"de");var ue=3,fe=u((a,e,t)=>{let n=e?a:a.slice(0,ue),r=n.map(o=>JSON.stringify(o)).join(" | "),l=a.length-n.length;return l>0?`${r} ${t("+{count} more",{count:l})}`:r},"fe"),J=u((a,e,t)=>{let n=a.enumValues??[],r=n.length===0?a.type:fe(n,e,t),l=a.ref===void 0?r:`${r} \u2192 ${a.ref}`;return a.optional===!0?`${l}?`:l},"H"),pe=u(a=>{let e=(0,v.c)(23),{data:t,selected:n}=a,r=$(),l;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(l=t.loadError===!0?(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):(0,s.jsx)("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"\u2014"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=l):l=e[3];let o=l,d=`sd-node-${t.label}`,c;e[4]!==t.label?(c=(0,s.jsx)("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=c):c=e[5];let m;e[6]!==t.tier?(m=(0,s.jsx)("span",{className:"ms-auto",children:(0,s.jsx)(D,{tier:t.tier})}),e[6]=t.tier,e[7]=m):m=e[7];let i;e[8]!==c||e[9]!==m?(i=(0,s.jsxs)(ce,{children:[c,m]}),e[8]=c,e[9]=m,e[10]=i):i=e[10];let f;e[11]!==t.columns||e[12]!==t.label||e[13]!==o||e[14]!==r?(f=t.columns.length===0?o:t.columns.map(h=>(0,s.jsxs)("div",{className:N("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",h.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${h.name}`,children:[(0,s.jsx)(E,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Left,type:"target"}),(0,s.jsx)("span",{className:"truncate font-mono",title:h.name,children:h.name}),h.pk===!0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),h.ref!==void 0&&(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),(0,s.jsx)("span",{className:"ms-auto truncate text-muted-foreground",title:J(h,!0,r),children:J(h,!1,r)}),(0,s.jsx)(E,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:h.name,isConnectable:!1,position:_.Right,type:"source"})]},h.name)),e[11]=t.columns,e[12]=t.label,e[13]=o,e[14]=r,e[15]=f):f=e[15];let p;e[16]!==f?(p=(0,s.jsx)(me,{children:f}),e[16]=f,e[17]=p):p=e[17];let x;return e[18]!==n||e[19]!==d||e[20]!==i||e[21]!==p?(x=(0,s.jsxs)(ie,{className:"w-64 overflow-hidden","data-testid":d,selected:n,children:[i,p]}),e[18]=n,e[19]=d,e[20]=i,e[21]=p,e[22]=x):x=e[22],x},"ue"),G=256,Q=112,W=36,M=24,he=480,be=1.4,ge=u(a=>{let e=Math.max(1,Math.round(Math.sqrt(be*a/(G+Q))));return Math.max(he,a/e)},"ge"),xe=38,Ne=28,A=u(a=>xe+Math.max(1,a)*Ne,"B"),ye=u((a,e)=>{let t=new Map;for(let o of a)t.set(o,[]);for(let o of e)o.to!==o.from&&t.has(o.from)&&t.has(o.to)&&t.get(o.from)?.push(o.to);let n=new Map,r=new Set,l=u(o=>{let d=n.get(o);if(d!==void 0)return d;if(r.has(o))return 0;r.add(o);let c=0;for(let m of t.get(o)??[])c=Math.max(c,l(m)+1);return r.delete(o),n.set(o,c),c},"r");for(let o of a)l(o);return n},"Ne"),ve=u((a,e,t)=>{let n=ye(a,e),r=new Map;for(let m of a){let i=n.get(m)??0,f=r.get(i);f===void 0?r.set(i,[m]):f.push(m)}let l=a.reduce((m,i)=>m+A(t.get(i)??0)+W,0),o=ge(l),d=[],c=0;for(let m of[...r.keys()].toSorted((i,f)=>i-f)){let i=0,f=M;for(let p of r.get(m)??[]){let x=A(t.get(p)??0);f>M&&f+x>o&&(i+=1,f=M),d.push({name:p,x:M+(c+i)*(G+Q),y:f}),f+=x+W}c+=i+1}return d},"ye"),we={databaseSchema:pe},U={backgroundColor:y.shard.color},X={backgroundColor:y.global.color},$e={global:!0,shard:!0},Me={},Ce=u(a=>{let e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},"_e"),Y=u(a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),"K"),Se=u((a,e,t)=>{let n=a.map(d=>d.name),r=new Map(a.map(d=>[d.name,d.columns.length])),l=ve(n,Y(a),r),o=new Map(a.map(d=>[d.name,d]));return l.flatMap(({name:d,x:c,y:m})=>{let i=o.get(d);return i===void 0?[]:[{className:t[d],data:{columns:i.columns,label:d,loadError:e,tier:i.tier},id:d,position:{x:c,y:m},type:"databaseSchema"}]})},"we"),ke=u(a=>{let e=new Map(a.map(t=>[t.name,t.columns]));return Y(a).flatMap(t=>{let n=e.get(t.to)??[],r=e.get(t.from)??[],l=Ce(n);return!n.some(o=>o.name===l)||!r.some(o=>o.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:l,target:t.from,targetHandle:t.column}]})},"Me"),_e=u(()=>{let a=(0,v.c)(15),e=$(),t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),a[0]=t):t=a[0];let n;a[1]===Symbol.for("react.memo_cache_sentinel")?(n=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]}),a[1]=n):n=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let l;a[3]!==e?(l=e("Primary key"),a[3]=e,a[4]=l):l=a[4];let o;a[5]!==l?(o=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[r,l]}),a[5]=l,a[6]=o):o=a[6];let d;a[7]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)(w,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=d):d=a[7];let c;a[8]!==e?(c=e("Foreign key"),a[8]=e,a[9]=c):c=a[9];let m;a[10]!==c?(m=(0,s.jsxs)("span",{className:"flex items-center gap-1",children:[d,c]}),a[10]=c,a[11]=m):m=a[11];let i;return a[12]!==o||a[13]!==m?(i=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,n,o,m]}),a[12]=o,a[13]=m,a[14]=i):i=a[14],i},"Ce"),ze=12,Ee=u(a=>{let e=(0,v.c)(9),{containerRef:t,seedKey:n}=a,r=V(),{fitView:l}=j(),o;e[0]!==t||e[1]!==l||e[2]!==r?(o=u(()=>{if(!r)return;let c=u(()=>{I(l({duration:0,maxZoom:1.6,padding:.14}))},"d");c();let m=t.current;if(m===null)return;let i=new ResizeObserver(()=>{c()});return i.observe(m),()=>{i.disconnect()}},"a"),e[0]=t,e[1]=l,e[2]=r,e[3]=o):o=e[3];let d;return e[4]!==t||e[5]!==l||e[6]!==r||e[7]!==n?(d=[t,l,r,n],e[4]=t,e[5]=l,e[6]=r,e[7]=n,e[8]=d):d=e[8],(0,b.useEffect)(o,d),null},"Te"),Ve=u(({columnsError:a,fill:e=!1,nodeClasses:t,tables:n,testIdPrefix:r})=>{let l=$(),[o,d]=(0,b.useState)($e),[c,m]=(0,b.useState)(""),i=(0,b.useMemo)(()=>{let g=c.trim().toLowerCase();return n.filter(K=>o[K.tier]&&K.name.toLowerCase().includes(g))},[n,o,c]),f=(0,b.useMemo)(()=>Se(i,a??!1,t??Me),[i,a,t]),p=(0,b.useMemo)(()=>ke(i),[i]),x=i.map(g=>g.name).join(","),[h,R,ee]=H(f),[te,F,ae]=L(p),C=(0,b.useRef)(null);(0,b.useEffect)(()=>{R(f)},[f,R]),(0,b.useEffect)(()=>{F(p)},[p,F]);let re=u(g=>{m(g.target.value)},"V"),oe=u(()=>{d(g=>({...g,shard:!g.shard}))},"W"),ne=u(()=>{d(g=>({...g,global:!g.global}))},"Y");return n.length===0?(0,s.jsx)("section",{className:"flex flex-col gap-2","data-testid":`${r}-section`,children:(0,s.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":`${r}-empty`,children:l("No tables to graph.")})}):(0,s.jsx)("section",{className:N("flex flex-col",e&&"min-h-0 flex-1"),"data-testid":`${r}-section`,children:(0,s.jsx)("div",{className:N("w-full overflow-hidden border border-border bg-muted/20",e?"min-h-0 flex-1":"h-[560px]"),"data-testid":`${r}-canvas`,ref:C,children:(0,s.jsxs)(B,{edges:te,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:h,nodesConnectable:!1,nodeTypes:we,onEdgesChange:ae,onNodesChange:ee,children:[(0,s.jsx)(O,{}),(0,s.jsx)(z,{position:"top-left",children:(0,s.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[(0,s.jsx)(P,{"aria-label":l("Find table\u2026"),className:"h-7 w-44 text-xs","data-testid":`${r}-find`,onChange:re,placeholder:l("Find table\u2026"),value:c}),(0,s.jsxs)("div",{"aria-label":l("Storage tiers"),className:"flex items-center gap-1.5",role:"group",children:[(0,s.jsxs)(k,{"aria-pressed":o.shard,className:"gap-1.5","data-testid":`${r}-tier-shard`,onClick:oe,size:"xs",type:"button",variant:o.shard?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:U}),y.shard.label]}),(0,s.jsxs)(k,{"aria-pressed":o.global,className:"gap-1.5","data-testid":`${r}-tier-global`,onClick:ne,size:"xs",type:"button",variant:o.global?"default":"outline",children:[(0,s.jsx)("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:X}),y.global.label]})]})]})}),(0,s.jsx)(z,{position:"bottom-center",children:(0,s.jsx)(_e,{})}),(0,s.jsx)(T,{showInteractive:!1}),i.length>ze&&(0,s.jsx)(Z,{className:"!border !border-border !bg-card",maskColor:"var(--color-muted)",nodeColor:"var(--color-muted-foreground)",nodeStrokeWidth:0,pannable:!0,zoomable:!0}),(0,s.jsx)(q,{containerRef:C,filenameBase:`${r}-schema-diagram`,testIdPrefix:r}),(0,s.jsx)(Ee,{containerRef:C,seedKey:x})]})})})},"Ke");export{Ve as a};
@@ -1 +1 @@
1
- import{i as k}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as q}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as j}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as U}from"./chunk-XC2LTW44.js";import"./chunk-NCPW7WHO.js";import"./chunk-5AXRIRHW.js";import"./chunk-55UGUCQ6.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-YSPQIRER.js";import"./chunk-EQRZJZD4.js";import"./chunk-QAQDMS6R.js";import"./chunk-NRAAYZ4C.js";import{a as M}from"./chunk-RWVIV3U7.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HCTJKP5J.js";import{a as z,e as D}from"./chunk-2IKDEUCX.js";import{d as F,u as O}from"./chunk-74IYYDDI.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-I26MS5PJ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=F(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=P(R.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(M,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:O(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};
1
+ import{i as k}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as q}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as j}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as U}from"./chunk-M27YVZWM.js";import"./chunk-NCPW7WHO.js";import"./chunk-LXQGF74P.js";import"./chunk-55UGUCQ6.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as P}from"./chunk-NWWMHMGA.js";import"./chunk-3JVXNEBO.js";import"./chunk-QAQDMS6R.js";import"./chunk-BAWEGZ7T.js";import{a as M}from"./chunk-RWVIV3U7.js";import{a as G,b as H,c as J,d as B,e as x,f as N}from"./chunk-HCTJKP5J.js";import{a as z,e as D}from"./chunk-2IKDEUCX.js";import{d as F,u as O}from"./chunk-74IYYDDI.js";import{a as A,d as T,e as $,f as X,g as Y}from"./chunk-I26MS5PJ.js";var K=T(X(),1),Q=T($(),1);var t=T(Y(),1);var de=A(()=>{let e=(0,K.c)(39),a=F(),[s,V]=(0,Q.useState)(""),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];let{data:C,error:l,errorSource:S,isLoading:E,refetch:_}=P(R.getAuthAuditLog,y),I;if(e[1]!==C?.entries||e[2]!==s){let r=C?.entries??[],v=s.trim().toLowerCase();I=v===""?r:r.filter(w=>w.event.toLowerCase().includes(v)||(w.actorId??"").toLowerCase().includes(v)||(w.actorEmail??"").toLowerCase().includes(v)||(w.ip??"").toLowerCase().includes(v)||w.outcome.toLowerCase().includes(v)),e[1]=C?.entries,e[2]=s,e[3]=I}else I=e[3];let o=I,L;e[4]===Symbol.for("react.memo_cache_sentinel")?(L=A(r=>{V(r.target.value)},"I"),e[4]=L):L=e[4];let W=L,i;e[5]!==a?(i=a("Filter security events"),e[5]=a,e[6]=i):i=e[6];let n;e[7]!==a?(n=a("filter event, actor, IP"),e[7]=a,e[8]=n):n=e[8];let c;e[9]!==s||e[10]!==i||e[11]!==n?(c=(0,t.jsx)(k,{"aria-label":i,className:"h-8 w-56","data-testid":"aa-search",onChange:W,placeholder:n,value:s}),e[9]=s,e[10]=i,e[11]=n,e[12]=c):c=e[12];let d;e[13]!==_?(d=A(()=>{_()},"m"),e[13]=_,e[14]=d):d=e[14];let m;e[15]!==a?(m=a("Refresh"),e[15]=a,e[16]=m):m=e[16];let u;e[17]!==d||e[18]!==m?(u=(0,t.jsx)(q,{"data-testid":"aa-refresh",onClick:d,size:"xs",type:"button",variant:"ghost",children:m}),e[17]=d,e[18]=m,e[19]=u):u=e[19];let h;e[20]!==c||e[21]!==u?(h=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,u]}),e[20]=c,e[21]=u,e[22]=h):h=e[22];let f;e[23]!==l||e[24]!==S?(f=l!==null&&(0,t.jsx)(U,{error:S,testId:"aa-error"}),e[23]=l,e[24]=S,e[25]=f):f=e[25];let p;e[26]!==l||e[27]!==o.length||e[28]!==E||e[29]!==a?(p=l===null&&!E&&o.length===0&&(0,t.jsx)(M,{description:a("Authentication and security events are recorded here."),testId:"aa-empty",title:a("No security events.")}),e[26]=l,e[27]=o.length,e[28]=E,e[29]=a,e[30]=p):p=e[30];let g;e[31]!==o||e[32]!==a?(g=o.length>0&&(0,t.jsx)(z,{className:"overflow-hidden py-0",children:(0,t.jsx)(D,{className:"max-h-[30rem] overflow-auto px-0",children:(0,t.jsxs)(G,{"data-testid":"aa-table",children:[(0,t.jsx)(H,{children:(0,t.jsxs)(B,{children:[(0,t.jsx)(x,{children:a("time")}),(0,t.jsx)(x,{children:a("event")}),(0,t.jsx)(x,{children:a("actor")}),(0,t.jsx)(x,{children:a("ip / user agent")}),(0,t.jsx)(x,{children:a("outcome")})]})}),(0,t.jsx)(J,{children:o.map(r=>(0,t.jsxs)(B,{"data-testid":"aa-row",children:[(0,t.jsx)(N,{className:"text-muted-foreground tabular-nums",children:O(r.ts,"\u2014")}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:"secondary",children:r.event})}),(0,t.jsx)(N,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,t.jsxs)(N,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),r.userAgent!==void 0&&(0,t.jsxs)("span",{className:"ml-1 opacity-70",children:["\xB7 ",r.userAgent]})]}),(0,t.jsx)(N,{children:(0,t.jsx)(j,{variant:r.outcome==="failure"?"destructive":"outline",children:a(r.outcome)})})]},r.seq))})]})})}),e[31]=o,e[32]=a,e[33]=g):g=e[33];let b;return e[34]!==f||e[35]!==p||e[36]!==g||e[37]!==h?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[h,f,p,g]}),e[34]=f,e[35]=p,e[36]=g,e[37]=h,e[38]=b):b=e[38],b},"ne");export{de as default};