@lunora/studio 1.0.0-alpha.147 → 1.0.0-alpha.149

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 (71) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
  3. package/dist/packem_chunks/SqlEditorPanel.mjs +7 -7
  4. package/dist/packem_chunks/TableEditor.mjs +1 -1
  5. package/dist/packem_chunks/payments-panel.mjs +1 -1
  6. package/dist/packem_shared/{DataBrowser-Bpj-0P1G.mjs → DataBrowser-B0XdZT2Z.mjs} +1 -1
  7. package/dist/packem_shared/wire-codec-oeb8YWV3.mjs +1 -0
  8. package/dist/standalone/{chunk-T3VYCKM7.js → chunk-3WOJTY4R.js} +1 -1
  9. package/dist/standalone/{chunk-HRYPE4NU.js → chunk-4FRHYJK4.js} +1 -1
  10. package/dist/standalone/{chunk-LFDP6ANM.js → chunk-4MDOVJ4W.js} +1 -1
  11. package/dist/standalone/{chunk-4XIC6MLF.js → chunk-66I57F5M.js} +1 -1
  12. package/dist/standalone/{chunk-OSLV4PT6.js → chunk-6DX7WXXT.js} +1 -1
  13. package/dist/standalone/chunk-6UKUXEBW.js +8 -0
  14. package/dist/standalone/{chunk-3KDC7UYQ.js → chunk-7J33QSVR.js} +1 -1
  15. package/dist/standalone/{chunk-GWW7SJR6.js → chunk-7ROGUMLR.js} +1 -1
  16. package/dist/standalone/{chunk-KCEVLJ65.js → chunk-7WRJROPR.js} +1 -1
  17. package/dist/standalone/{chunk-2GPQJLCR.js → chunk-7ZETHOUS.js} +1 -1
  18. package/dist/standalone/{chunk-DLT5B4TL.js → chunk-AHK42KDL.js} +1 -1
  19. package/dist/standalone/{chunk-2GZVY7CX.js → chunk-AMZKMGKY.js} +1 -1
  20. package/dist/standalone/{chunk-4R6AMNIM.js → chunk-APXBR22Z.js} +1 -1
  21. package/dist/standalone/{chunk-ZYCM7BV2.js → chunk-AUWQMDAX.js} +1 -1
  22. package/dist/standalone/{chunk-HR42URDR.js → chunk-AX2APCG6.js} +1 -1
  23. package/dist/standalone/{chunk-QNSRFASE.js → chunk-C4YXQWPA.js} +1 -1
  24. package/dist/standalone/{chunk-GIOZAYBS.js → chunk-D3PZ6MIM.js} +1 -1
  25. package/dist/standalone/{chunk-WWXSQVPE.js → chunk-DCUJOJLT.js} +1 -1
  26. package/dist/standalone/{chunk-2Z5PSAHC.js → chunk-DEXFM45H.js} +1 -1
  27. package/dist/standalone/{chunk-CZY6LNTK.js → chunk-DRYRBVT5.js} +1 -1
  28. package/dist/standalone/{chunk-VWFNJLMK.js → chunk-DSFSMWDN.js} +1 -1
  29. package/dist/standalone/{chunk-WXRI2LBR.js → chunk-FLNL5VTQ.js} +1 -1
  30. package/dist/standalone/{chunk-OEVYSTUL.js → chunk-GB2JAHPX.js} +1 -1
  31. package/dist/standalone/{chunk-EERTS7JH.js → chunk-GJZHLAVK.js} +1 -1
  32. package/dist/standalone/{chunk-JWPJS6AI.js → chunk-GV7UT4HH.js} +1 -1
  33. package/dist/standalone/{chunk-SLFPZM2C.js → chunk-H5ZCOPNG.js} +1 -1
  34. package/dist/standalone/{chunk-JY4ANRPG.js → chunk-IODDEC5H.js} +1 -1
  35. package/dist/standalone/{chunk-RDYIEOYN.js → chunk-J5NCVH3C.js} +1 -1
  36. package/dist/standalone/{chunk-GDB2JX2H.js → chunk-J77YHYKR.js} +1 -1
  37. package/dist/standalone/{chunk-NZ57KZSG.js → chunk-JDDCFPPX.js} +1 -1
  38. package/dist/standalone/{chunk-YCEVUCMI.js → chunk-JKUQYLWD.js} +1 -1
  39. package/dist/standalone/{chunk-6UG4S7I7.js → chunk-KASSSQS4.js} +1 -1
  40. package/dist/standalone/{chunk-5EWLJXES.js → chunk-KB45MOFE.js} +1 -1
  41. package/dist/standalone/{chunk-FIACUWE5.js → chunk-KCQPXMOO.js} +1 -1
  42. package/dist/standalone/{chunk-JOYK6ITY.js → chunk-KLME5CLU.js} +1 -1
  43. package/dist/standalone/{chunk-3CGQYQDZ.js → chunk-KRXMPCR7.js} +1 -1
  44. package/dist/standalone/{chunk-R5QR5EZZ.js → chunk-L47XJL6L.js} +1 -1
  45. package/dist/standalone/{chunk-KJ4YYMID.js → chunk-N6EJBSDR.js} +1 -1
  46. package/dist/standalone/{chunk-7BRTPMJO.js → chunk-NAG6ZTZT.js} +1 -1
  47. package/dist/standalone/{chunk-5OFSVXDU.js → chunk-NOVVYTNU.js} +1 -1
  48. package/dist/standalone/chunk-OVTMYZN2.js +1 -0
  49. package/dist/standalone/{chunk-XVX3KH35.js → chunk-P4CS3RZR.js} +1 -1
  50. package/dist/standalone/{chunk-2LOBQ4CX.js → chunk-PUP4LTHC.js} +1 -1
  51. package/dist/standalone/chunk-Q443C75G.js +1 -0
  52. package/dist/standalone/{chunk-7IY5BR52.js → chunk-QBDSW2YH.js} +1 -1
  53. package/dist/standalone/{chunk-XHM5CP2I.js → chunk-QFS5WAWF.js} +1 -1
  54. package/dist/standalone/{chunk-VLCHF5SE.js → chunk-SI7NMHGS.js} +1 -1
  55. package/dist/standalone/{chunk-VGJ6HFCF.js → chunk-V23FBXTK.js} +1 -1
  56. package/dist/standalone/{chunk-VWXU7LIX.js → chunk-VEWOXE6L.js} +1 -1
  57. package/dist/standalone/{chunk-6DQKYWZI.js → chunk-VO3YI35Z.js} +1 -1
  58. package/dist/standalone/{chunk-PIGJKRDD.js → chunk-VZRWYNKZ.js} +1 -1
  59. package/dist/standalone/{chunk-BVRZVNKL.js → chunk-XFZGJQY4.js} +1 -1
  60. package/dist/standalone/{chunk-5K2UDZLN.js → chunk-XJDQG6VV.js} +1 -1
  61. package/dist/standalone/{chunk-XZCNX7YU.js → chunk-XTLR2A7C.js} +1 -1
  62. package/dist/standalone/{chunk-MNGNHBOS.js → chunk-XVONF2UL.js} +1 -1
  63. package/dist/standalone/{chunk-LK4TLRSU.js → chunk-YSX56MFQ.js} +1 -1
  64. package/dist/standalone/{chunk-N74RUMRA.js → chunk-ZD7TZD5E.js} +1 -1
  65. package/dist/standalone/{chunk-KQFH6FFC.js → chunk-ZXRRPWQV.js} +1 -1
  66. package/dist/standalone/studio.js +1 -1
  67. package/package.json +4 -4
  68. package/dist/packem_shared/wire-codec-C0jSa3ZC.mjs +0 -1
  69. package/dist/standalone/chunk-LSWAITBZ.js +0 -1
  70. package/dist/standalone/chunk-QYEQOTRN.js +0 -8
  71. package/dist/standalone/chunk-ZTDD3M5D.js +0 -1
@@ -1,4 +1,4 @@
1
- import{c as V}from"react/compiler-runtime";import{useLunora as ct}from"@lunora/react";import{useState as $,useEffect as Ve,useMemo as Tt,useRef as Je,useCallback as at}from"react";import{ShardInput as Pn}from"./ShardInput-C6mjgAh4.mjs";import{u as Xe}from"./use-admin-query-BKXiqLci.mjs";import{ADMIN_FUNCTIONS as pe}from"./ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{b as Ut}from"./browser-storage-BH1MxLZs.mjs";import{f as Ce,i as je,j as Qt,b as Ot,c as Te,d as ke,h as On}from"./internal-B6haJbiP.mjs";import{m as Mn,c as Yt,d as vt,G as Ln,a as Fn,u as wt,b as Bn,T as Vn,D as jn}from"./table-list-sidebar-DHG1UJC4.mjs";import{u as zn}from"./use-sql-assistant-BhIMDQHV.mjs";import{d as Rt,i as Xt,e as Zt,a as qn}from"./wire-codec-C0jSa3ZC.mjs";import{B as yt}from"./button-q0UYSmrn.mjs";import{I as Gn}from"./input-CXhxesPC.mjs";import{L as Mt}from"./label-DKFzyHq6.mjs";import{M as dt}from"./modal-shell-CDztwLnv.mjs";import{useT as he}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as d,jsxs as E,Fragment as Ze}from"react/jsx-runtime";import{ConfirmButton as Lt}from"./ConfirmButton-DU4p72Er.mjs";import{E as Kn}from"./empty-state-D7jEML_T.mjs";import{C as Et,a as De}from"./control-button-BOZ5K-FC.mjs";import{useReactTable as Jn,getSortedRowModel as Wn,getCoreRowModel as Hn,flexRender as Un}from"@tanstack/react-table";import{useVirtualizer as Qn}from"@tanstack/react-virtual";import{C as $t}from"./checkbox-CnS9cyCz.mjs";import{c as it}from"./utils-bhneXptQ.mjs";import{f as Yn}from"./virtual-rect-D_j7aLxX.mjs";import{C as Ct,G as Xn,T as Zn}from"./data-grid-DTBAKZlm.mjs";import{DataFilters as eo,toFilterClauses as Oe}from"./DataFilters-3nbW0uax.mjs";import{G as to,C as no}from"./grid-features-Dl7bCGRN.mjs";import Ft from"./useDebounced-DVeQ5-oW.mjs";import{r as oo,l as so}from"./shard-history-CaO3C4KQ.mjs";const lo=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,references:o.ref,table:e}))}))}),ro=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const c=t.references,l=`${c}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(c)??[];r.push({...t,table:o.name}),e.set(c,r)}return e},ao=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const c of t.children)o.push(c)}return n},Bt=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const c of t)c.ref===s&&n.push({column:c.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},Dt=s=>`${s.table}.${s.column}`,io=s=>{const e=V(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:a}=s,i=he(),[m,u]=$(n[0]??""),[p,b]=$("");let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=ee=>{u(ee.target.value)},e[0]=f):f=e[0];const g=f;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=ee=>{b(ee.target.value)},e[1]=h):h=e[1];const x=h;let v;e[2]!==p?(v=p.trim(),e[2]=p,e[3]=v):v=e[3];const w=v==="";let y,N;if(e[4]!==w||e[5]!==i||e[6]!==p){if(!w)try{N=Rt(JSON.parse(p))}catch(ee){y=i("Invalid JSON: {message}",{message:ee.message})}e[4]=w,e[5]=i,e[6]=p,e[7]=y,e[8]=N}else y=e[7],N=e[8];let T;e[9]!==m||e[10]!==r||e[11]!==a?(T=a.has(m)&&r>1,e[9]=m,e[10]=r,e[11]=a,e[12]=T):T=e[12];const C=T,S=m!==""&&!w&&y===void 0&&!C;let k;e[13]!==S||e[14]!==m||e[15]!==o||e[16]!==t||e[17]!==N?(k=()=>{S&&(o({[m]:N}),t())},e[13]=S,e[14]=m,e[15]=o,e[16]=t,e[17]=N,e[18]=k):k=e[18];const O=k;let R;e[19]!==i?(R=i("Set a column on matching rows"),e[19]=i,e[20]=R):R=e[20];let _;e[21]!==i?(_=i("Set a column on matching rows"),e[21]=i,e[22]=_):_=e[22];let D;e[23]!==_?(D=d("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:_}),e[23]=_,e[24]=D):D=e[24];let A;e[25]!==i||e[26]!==l||e[27]!==r?(A=i("Writes {total} rows of {table} through the schema-aware writer — validators and indexes apply, exactly like a mutation.",{table:l,total:r.toString()}),e[25]=i,e[26]=l,e[27]=r,e[28]=A):A=e[28];let L;e[29]!==A?(L=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:A}),e[29]=A,e[30]=L):L=e[30];let P;e[31]!==c||e[32]!==i?(P=c===""?i("Shard: root"):i("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=i,e[33]=P):P=e[33];let j;e[34]!==P?(j=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:P}),e[34]=P,e[35]=j):j=e[35];let q;e[36]!==L||e[37]!==j||e[38]!==D?(q=E("div",{className:"flex flex-col gap-0.5",children:[D,L,j]}),e[36]=L,e[37]=j,e[38]=D,e[39]=q):q=e[39];let M;e[40]!==i?(M=i("Close"),e[40]=i,e[41]=M):M=e[41];let B;e[42]!==t||e[43]!==M?(B=d(yt,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:M}),e[42]=t,e[43]=M,e[44]=B):B=e[44];let J;e[45]!==q||e[46]!==B?(J=E("div",{className:"flex items-start justify-between",children:[q,B]}),e[45]=q,e[46]=B,e[47]=J):J=e[47];let G;e[48]!==i?(G=i("Column"),e[48]=i,e[49]=G):G=e[49];let X;e[50]!==G?(X=d(Mt,{htmlFor:"bulk-patch-column",children:G}),e[50]=G,e[51]=X):X=e[51];let Q;e[52]!==i?(Q=i("Column"),e[52]=i,e[53]=Q):Q=e[53];let Z;e[54]!==n?(Z=n.map(co),e[54]=n,e[55]=Z):Z=e[55];let fe;e[56]!==m||e[57]!==Q||e[58]!==Z?(fe=d("select",{"aria-label":Q,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:g,value:m,children:Z}),e[56]=m,e[57]=Q,e[58]=Z,e[59]=fe):fe=e[59];let ne;e[60]!==i?(ne=i("Value"),e[60]=i,e[61]=ne):ne=e[61];let ce;e[62]!==ne?(ce=d(Mt,{htmlFor:"bulk-patch-value",children:ne}),e[62]=ne,e[63]=ce):ce=e[63];let de;e[64]!==p?(de=d(Gn,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:x,placeholder:"true",value:p}),e[64]=p,e[65]=de):de=e[65];let me;e[66]!==X||e[67]!==fe||e[68]!==ce||e[69]!==de?(me=E("div",{className:"flex items-center gap-2",children:[X,fe,ce,de]}),e[66]=X,e[67]=fe,e[68]=ce,e[69]=de,e[70]=me):me=e[70];let le;e[71]!==y?(le=y!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:y}),e[71]=y,e[72]=le):le=e[72];let ue;e[73]!==m||e[74]!==i||e[75]!==r||e[76]!==C?(ue=C&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:i("{column} has a unique index — the same value cannot be set on {total} rows.",{column:m,total:r.toString()})}),e[73]=m,e[74]=i,e[75]=r,e[76]=C,e[77]=ue):ue=e[77];let re;e[78]!==w||e[79]!==i||e[80]!==C?(re=w&&!C&&d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:i('Enter a JSON value — for example true, 0, null, or "done".')}),e[78]=w,e[79]=i,e[80]=C,e[81]=re):re=e[81];let Y;e[82]!==S||e[83]!==m||e[84]!==p?(Y=S&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${m} = ${p.trim()}`}),e[82]=S,e[83]=m,e[84]=p,e[85]=Y):Y=e[85];let be;e[86]!==i?(be=i("Cancel"),e[86]=i,e[87]=be):be=e[87];let te;e[88]!==t||e[89]!==be?(te=d(yt,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:be}),e[88]=t,e[89]=be,e[90]=te):te=e[90];const xe=!S;let ae;e[91]!==i||e[92]!==r?(ae=i("Set on {total} rows",{total:r.toString()}),e[91]=i,e[92]=r,e[93]=ae):ae=e[93];let ie;e[94]!==O||e[95]!==xe||e[96]!==ae?(ie=d(yt,{"data-testid":"bulk-patch-apply",disabled:xe,onClick:O,size:"xs",children:ae}),e[94]=O,e[95]=xe,e[96]=ae,e[97]=ie):ie=e[97];let W;e[98]!==te||e[99]!==ie?(W=E("div",{className:"flex justify-end gap-2",children:[te,ie]}),e[98]=te,e[99]=ie,e[100]=W):W=e[100];let K;return e[101]!==t||e[102]!==J||e[103]!==me||e[104]!==le||e[105]!==ue||e[106]!==re||e[107]!==Y||e[108]!==W||e[109]!==R?(K=E(dt,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,me,le,ue,re,Y,W]}),e[101]=t,e[102]=J,e[103]=me,e[104]=le,e[105]=ue,e[106]=re,e[107]=Y,e[108]=W,e[109]=R,e[110]=K):K=e[110],K};function co(s){return d("option",{value:s,children:s},s)}const Vt=6,lt=100,uo=s=>({paddingLeft:s*16}),fo=s=>{const e=V(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},mo=s=>{const e=V(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},go=s=>{const e=V(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},po=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d(mo,{table:s.table}):s.isRestrict?d(fo,{table:s.table}):d(go,{table:s.table}),en=s=>{const e=V(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=uo(n),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==n?(l=n>0&&d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=d("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let a;e[6]!==o.relation||e[7]!==o.table?(a=o.relation!==void 0&&E("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=a):a=e[8];let i;e[9]!==o.rowCount?(i=o.rowCount.toString(),e[9]=o.rowCount,e[10]=i):i=e[10];let m;e[11]!==i?(m=E("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=m):m=e[12];let u;e[13]!==o?(u=po(o),e[13]=o,e[14]=u):u=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&E("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let b;e[18]!==t||e[19]!==c||e[20]!==l||e[21]!==r||e[22]!==a||e[23]!==m||e[24]!==u||e[25]!==p?(b=E("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:c,children:[l,r,a,m,u,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=a,e[23]=m,e[24]=u,e[25]=p,e[26]=b):b=e[26];let f;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(x,v)=>d(en,{depth:n+1,node:x},`${x.table}-${x.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],f=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=f}else f=e[29];let g;return e[32]!==b||e[33]!==f?(g=E(Ze,{children:[b,f]}),e[32]=b,e[33]=f,e[34]=g):g=e[34],g},bo=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},ho=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(a=>bo(a)||[]).slice(0,lt),l=t.total??0;return{capNote:l>lt?`showing first ${lt.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},tn=async(s,e,n,o,t,c,l)=>{const{capNote:r,rowCount:a,rowIds:i}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await ho(s,n.field,e,l),m=n?.onDelete==="restrict",u=[],p=`${s}:${e}`,b=c>=Vt;if(!t.has(p)&&!b){t.add(p);const g=o.get(s)??[];for(const h of g)for(const x of i.slice(0,10)){const v=await tn(h.table,x,h,o,t,c+1,l);(v.rowCount>0||c===0)&&u.push(v)}t.delete(p)}let f=r;if(b){const g=`depth capped at ${Vt.toString()}`;f=r===void 0?g:`${r}; ${g}`}return{capNote:f,children:u,isRestrict:m,relation:n,rowCount:a,rowIds:i,table:s}},xo=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=he(),[r,a]=$(!0),[i,m]=$(null),[u,p]=$(null);Ve(()=>{let g=!1;return Ce((async()=>{try{a(!0),p(null);const x=ro(t);if(!((x.get(c)??[]).length>0)){g||(m({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),a(!1));return}const w=await tn(c,o,void 0,x,new Set,0,n);g||(m(w),a(!1))}catch(x){g||(p(x.message),a(!1))}})()),()=>{g=!0}},[o,c]);const b=i!==null&&ao(i,g=>g.isRestrict).length>0,f=()=>{e(),s()};return E(dt,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),u!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:u}),!r&&i!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(en,{depth:0,node:i})}),!r&&i!==null&&i.children.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),b&&d("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),d("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:f,type:"button",children:l("Delete")})]})]})},vo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(u=>u.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let a=0,i=0,m=0;for(const u of s){const p=u.getSize(),b=e.has(u.id),f=a+p>c&&a<l;b||f?r.add(u.id):a<c?i+=p:m+=p,a+=p}return{ids:r,leadPx:i,tailPx:m}},wo=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},yo=()=>{const s=V(12);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=$(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(g,h,x)=>{o(v=>({...v,[g]:{...v[g],[h]:x}}))},s[1]=t):t=s[1];const c=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let a;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h)=>{o(x=>{const v=x[g];if(v===void 0)return x;const w=Object.fromEntries(Object.entries(v).filter(y=>{const[N,T]=y;return!(N in h)||!Object.is(T,h[N])}));return Object.keys(w).length===0?Object.fromEntries(Object.entries(x).filter(y=>{const[N]=y;return N!==g})):{...x,[g]:w}})},s[3]=a):a=s[3];const i=a;let m;s[4]!==n?(m=(g,h)=>{const x=n[g];return x!==void 0&&h in x?{value:x[h]}:void 0},s[4]=n,s[5]=m):m=s[5];const u=m;let p;s[6]!==n?(p=Object.values(n).reduce(No,0),s[6]=n,s[7]=p):p=s[7];const b=p;let f;return s[8]!==b||s[9]!==n||s[10]!==u?(f={clear:r,count:b,drop:i,stage:c,staged:n,stagedValue:u},s[8]=b,s[9]=n,s[10]=u,s[11]=f):f=s[11],f},nn=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},Co=s=>{const e=V(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=he();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let a;e[3]!==r?(a=d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=a):a=e[4];let i;e[5]!==o||e[6]!==l?(i=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=i):i=e[7];let m;e[8]!==o||e[9]!==t||e[10]!==i?(m=d("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:i}),e[8]=o,e[9]=t,e[10]=i,e[11]=m):m=e[11];let u;e[12]!==l?(u=l("Discard"),e[12]=l,e[13]=u):u=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==u?(p=d("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:c,type:"button",children:u}),e[14]=o,e[15]=c,e[16]=u,e[17]=p):p=e[17];let b;e[18]!==a||e[19]!==m||e[20]!==p?(b=E("div",{className:"flex flex-wrap items-center gap-2",children:[a,m,p]}),e[18]=a,e[19]=m,e[20]=p,e[21]=b):b=e[21];let f;e[22]!==n?(f=n.map(So),e[22]=n,e[23]=f):f=e[23];let g;e[24]!==f?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:f}),e[24]=f,e[25]=g):g=e[25];let h;return e[26]!==b||e[27]!==g?(h=E("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,g]}),e[26]=b,e[27]=g,e[28]=h):h=e[28],h};function No(s,e){return s+Object.keys(e).length}function So(s){return E("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[E("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),d("span",{className:"text-destructive line-through",children:je(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:je(s.newValue)})]},`${s.rowId}:${s.column}`)}const jt=400,ko=36,To={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Eo={width:"100%"},_o=/\n$/u,Ro={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},$o={display:"flex",width:"100%"},zt={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},Do="2.5rem",on={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},At=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),sn=(s,e)=>({...At(s),left:`calc(${Do} + ${e.toString()}px)`,position:"sticky",zIndex:2}),Nt="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",Ao=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,_t="__back__:",Io=s=>`${_t}${s.table}.${s.column}`,Po=s=>{const e=V(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=d("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let c;return e[1]!==t?(c=d("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=c):c=e[2],c},Ae=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},Oo=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},Mo=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return Oo(s,n);const o=nn(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},Lo=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
1
+ import{c as V}from"react/compiler-runtime";import{useLunora as ct}from"@lunora/react";import{useState as $,useEffect as Ve,useMemo as Tt,useRef as Je,useCallback as at}from"react";import{ShardInput as Pn}from"./ShardInput-C6mjgAh4.mjs";import{u as Xe}from"./use-admin-query-BKXiqLci.mjs";import{ADMIN_FUNCTIONS as pe}from"./ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{b as Ut}from"./browser-storage-BH1MxLZs.mjs";import{f as Ce,i as je,j as Qt,b as Ot,c as Te,d as ke,h as On}from"./internal-B6haJbiP.mjs";import{m as Mn,c as Yt,d as vt,G as Ln,a as Fn,u as wt,b as Bn,T as Vn,D as jn}from"./table-list-sidebar-DHG1UJC4.mjs";import{u as zn}from"./use-sql-assistant-BhIMDQHV.mjs";import{d as Rt,i as Xt,e as Zt,a as qn}from"./wire-codec-oeb8YWV3.mjs";import{B as yt}from"./button-q0UYSmrn.mjs";import{I as Gn}from"./input-CXhxesPC.mjs";import{L as Mt}from"./label-DKFzyHq6.mjs";import{M as dt}from"./modal-shell-CDztwLnv.mjs";import{useT as he}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as d,jsxs as E,Fragment as Ze}from"react/jsx-runtime";import{ConfirmButton as Lt}from"./ConfirmButton-DU4p72Er.mjs";import{E as Kn}from"./empty-state-D7jEML_T.mjs";import{C as Et,a as De}from"./control-button-BOZ5K-FC.mjs";import{useReactTable as Jn,getSortedRowModel as Wn,getCoreRowModel as Hn,flexRender as Un}from"@tanstack/react-table";import{useVirtualizer as Qn}from"@tanstack/react-virtual";import{C as $t}from"./checkbox-CnS9cyCz.mjs";import{c as it}from"./utils-bhneXptQ.mjs";import{f as Yn}from"./virtual-rect-D_j7aLxX.mjs";import{C as Ct,G as Xn,T as Zn}from"./data-grid-DTBAKZlm.mjs";import{DataFilters as eo,toFilterClauses as Oe}from"./DataFilters-3nbW0uax.mjs";import{G as to,C as no}from"./grid-features-Dl7bCGRN.mjs";import Ft from"./useDebounced-DVeQ5-oW.mjs";import{r as oo,l as so}from"./shard-history-CaO3C4KQ.mjs";const lo=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,references:o.ref,table:e}))}))}),ro=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const c=t.references,l=`${c}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(c)??[];r.push({...t,table:o.name}),e.set(c,r)}return e},ao=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const c of t.children)o.push(c)}return n},Bt=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const c of t)c.ref===s&&n.push({column:c.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},Dt=s=>`${s.table}.${s.column}`,io=s=>{const e=V(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:a}=s,i=he(),[m,u]=$(n[0]??""),[p,b]=$("");let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=ee=>{u(ee.target.value)},e[0]=f):f=e[0];const g=f;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=ee=>{b(ee.target.value)},e[1]=h):h=e[1];const x=h;let v;e[2]!==p?(v=p.trim(),e[2]=p,e[3]=v):v=e[3];const w=v==="";let y,N;if(e[4]!==w||e[5]!==i||e[6]!==p){if(!w)try{N=Rt(JSON.parse(p))}catch(ee){y=i("Invalid JSON: {message}",{message:ee.message})}e[4]=w,e[5]=i,e[6]=p,e[7]=y,e[8]=N}else y=e[7],N=e[8];let T;e[9]!==m||e[10]!==r||e[11]!==a?(T=a.has(m)&&r>1,e[9]=m,e[10]=r,e[11]=a,e[12]=T):T=e[12];const C=T,S=m!==""&&!w&&y===void 0&&!C;let k;e[13]!==S||e[14]!==m||e[15]!==o||e[16]!==t||e[17]!==N?(k=()=>{S&&(o({[m]:N}),t())},e[13]=S,e[14]=m,e[15]=o,e[16]=t,e[17]=N,e[18]=k):k=e[18];const O=k;let R;e[19]!==i?(R=i("Set a column on matching rows"),e[19]=i,e[20]=R):R=e[20];let _;e[21]!==i?(_=i("Set a column on matching rows"),e[21]=i,e[22]=_):_=e[22];let D;e[23]!==_?(D=d("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:_}),e[23]=_,e[24]=D):D=e[24];let A;e[25]!==i||e[26]!==l||e[27]!==r?(A=i("Writes {total} rows of {table} through the schema-aware writer — validators and indexes apply, exactly like a mutation.",{table:l,total:r.toString()}),e[25]=i,e[26]=l,e[27]=r,e[28]=A):A=e[28];let L;e[29]!==A?(L=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:A}),e[29]=A,e[30]=L):L=e[30];let P;e[31]!==c||e[32]!==i?(P=c===""?i("Shard: root"):i("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=i,e[33]=P):P=e[33];let j;e[34]!==P?(j=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:P}),e[34]=P,e[35]=j):j=e[35];let q;e[36]!==L||e[37]!==j||e[38]!==D?(q=E("div",{className:"flex flex-col gap-0.5",children:[D,L,j]}),e[36]=L,e[37]=j,e[38]=D,e[39]=q):q=e[39];let M;e[40]!==i?(M=i("Close"),e[40]=i,e[41]=M):M=e[41];let B;e[42]!==t||e[43]!==M?(B=d(yt,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:M}),e[42]=t,e[43]=M,e[44]=B):B=e[44];let J;e[45]!==q||e[46]!==B?(J=E("div",{className:"flex items-start justify-between",children:[q,B]}),e[45]=q,e[46]=B,e[47]=J):J=e[47];let G;e[48]!==i?(G=i("Column"),e[48]=i,e[49]=G):G=e[49];let X;e[50]!==G?(X=d(Mt,{htmlFor:"bulk-patch-column",children:G}),e[50]=G,e[51]=X):X=e[51];let Q;e[52]!==i?(Q=i("Column"),e[52]=i,e[53]=Q):Q=e[53];let Z;e[54]!==n?(Z=n.map(co),e[54]=n,e[55]=Z):Z=e[55];let fe;e[56]!==m||e[57]!==Q||e[58]!==Z?(fe=d("select",{"aria-label":Q,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:g,value:m,children:Z}),e[56]=m,e[57]=Q,e[58]=Z,e[59]=fe):fe=e[59];let ne;e[60]!==i?(ne=i("Value"),e[60]=i,e[61]=ne):ne=e[61];let ce;e[62]!==ne?(ce=d(Mt,{htmlFor:"bulk-patch-value",children:ne}),e[62]=ne,e[63]=ce):ce=e[63];let de;e[64]!==p?(de=d(Gn,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:x,placeholder:"true",value:p}),e[64]=p,e[65]=de):de=e[65];let me;e[66]!==X||e[67]!==fe||e[68]!==ce||e[69]!==de?(me=E("div",{className:"flex items-center gap-2",children:[X,fe,ce,de]}),e[66]=X,e[67]=fe,e[68]=ce,e[69]=de,e[70]=me):me=e[70];let le;e[71]!==y?(le=y!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:y}),e[71]=y,e[72]=le):le=e[72];let ue;e[73]!==m||e[74]!==i||e[75]!==r||e[76]!==C?(ue=C&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:i("{column} has a unique index — the same value cannot be set on {total} rows.",{column:m,total:r.toString()})}),e[73]=m,e[74]=i,e[75]=r,e[76]=C,e[77]=ue):ue=e[77];let re;e[78]!==w||e[79]!==i||e[80]!==C?(re=w&&!C&&d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:i('Enter a JSON value — for example true, 0, null, or "done".')}),e[78]=w,e[79]=i,e[80]=C,e[81]=re):re=e[81];let Y;e[82]!==S||e[83]!==m||e[84]!==p?(Y=S&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${m} = ${p.trim()}`}),e[82]=S,e[83]=m,e[84]=p,e[85]=Y):Y=e[85];let be;e[86]!==i?(be=i("Cancel"),e[86]=i,e[87]=be):be=e[87];let te;e[88]!==t||e[89]!==be?(te=d(yt,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:be}),e[88]=t,e[89]=be,e[90]=te):te=e[90];const xe=!S;let ae;e[91]!==i||e[92]!==r?(ae=i("Set on {total} rows",{total:r.toString()}),e[91]=i,e[92]=r,e[93]=ae):ae=e[93];let ie;e[94]!==O||e[95]!==xe||e[96]!==ae?(ie=d(yt,{"data-testid":"bulk-patch-apply",disabled:xe,onClick:O,size:"xs",children:ae}),e[94]=O,e[95]=xe,e[96]=ae,e[97]=ie):ie=e[97];let W;e[98]!==te||e[99]!==ie?(W=E("div",{className:"flex justify-end gap-2",children:[te,ie]}),e[98]=te,e[99]=ie,e[100]=W):W=e[100];let K;return e[101]!==t||e[102]!==J||e[103]!==me||e[104]!==le||e[105]!==ue||e[106]!==re||e[107]!==Y||e[108]!==W||e[109]!==R?(K=E(dt,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,me,le,ue,re,Y,W]}),e[101]=t,e[102]=J,e[103]=me,e[104]=le,e[105]=ue,e[106]=re,e[107]=Y,e[108]=W,e[109]=R,e[110]=K):K=e[110],K};function co(s){return d("option",{value:s,children:s},s)}const Vt=6,lt=100,uo=s=>({paddingLeft:s*16}),fo=s=>{const e=V(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},mo=s=>{const e=V(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},go=s=>{const e=V(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},po=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d(mo,{table:s.table}):s.isRestrict?d(fo,{table:s.table}):d(go,{table:s.table}),en=s=>{const e=V(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=uo(n),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==n?(l=n>0&&d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=d("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let a;e[6]!==o.relation||e[7]!==o.table?(a=o.relation!==void 0&&E("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=a):a=e[8];let i;e[9]!==o.rowCount?(i=o.rowCount.toString(),e[9]=o.rowCount,e[10]=i):i=e[10];let m;e[11]!==i?(m=E("span",{className:"text-muted-foreground",children:["(",i," rows)"]}),e[11]=i,e[12]=m):m=e[12];let u;e[13]!==o?(u=po(o),e[13]=o,e[14]=u):u=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&E("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let b;e[18]!==t||e[19]!==c||e[20]!==l||e[21]!==r||e[22]!==a||e[23]!==m||e[24]!==u||e[25]!==p?(b=E("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:c,children:[l,r,a,m,u,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=a,e[23]=m,e[24]=u,e[25]=p,e[26]=b):b=e[26];let f;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(x,v)=>d(en,{depth:n+1,node:x},`${x.table}-${x.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],f=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=f}else f=e[29];let g;return e[32]!==b||e[33]!==f?(g=E(Ze,{children:[b,f]}),e[32]=b,e[33]=f,e[34]=g):g=e[34],g},bo=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},ho=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(a=>bo(a)||[]).slice(0,lt),l=t.total??0;return{capNote:l>lt?`showing first ${lt.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},tn=async(s,e,n,o,t,c,l)=>{const{capNote:r,rowCount:a,rowIds:i}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await ho(s,n.field,e,l),m=n?.onDelete==="restrict",u=[],p=`${s}:${e}`,b=c>=Vt;if(!t.has(p)&&!b){t.add(p);const g=o.get(s)??[];for(const h of g)for(const x of i.slice(0,10)){const v=await tn(h.table,x,h,o,t,c+1,l);(v.rowCount>0||c===0)&&u.push(v)}t.delete(p)}let f=r;if(b){const g=`depth capped at ${Vt.toString()}`;f=r===void 0?g:`${r}; ${g}`}return{capNote:f,children:u,isRestrict:m,relation:n,rowCount:a,rowIds:i,table:s}},xo=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=he(),[r,a]=$(!0),[i,m]=$(null),[u,p]=$(null);Ve(()=>{let g=!1;return Ce((async()=>{try{a(!0),p(null);const x=ro(t);if(!((x.get(c)??[]).length>0)){g||(m({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),a(!1));return}const w=await tn(c,o,void 0,x,new Set,0,n);g||(m(w),a(!1))}catch(x){g||(p(x.message),a(!1))}})()),()=>{g=!0}},[o,c]);const b=i!==null&&ao(i,g=>g.isRestrict).length>0,f=()=>{e(),s()};return E(dt,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),u!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:u}),!r&&i!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(en,{depth:0,node:i})}),!r&&i!==null&&i.children.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),b&&d("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),d("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:f,type:"button",children:l("Delete")})]})]})},vo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(u=>u.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let a=0,i=0,m=0;for(const u of s){const p=u.getSize(),b=e.has(u.id),f=a+p>c&&a<l;b||f?r.add(u.id):a<c?i+=p:m+=p,a+=p}return{ids:r,leadPx:i,tailPx:m}},wo=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},yo=()=>{const s=V(12);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=$(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(g,h,x)=>{o(v=>({...v,[g]:{...v[g],[h]:x}}))},s[1]=t):t=s[1];const c=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let a;s[3]===Symbol.for("react.memo_cache_sentinel")?(a=(g,h)=>{o(x=>{const v=x[g];if(v===void 0)return x;const w=Object.fromEntries(Object.entries(v).filter(y=>{const[N,T]=y;return!(N in h)||!Object.is(T,h[N])}));return Object.keys(w).length===0?Object.fromEntries(Object.entries(x).filter(y=>{const[N]=y;return N!==g})):{...x,[g]:w}})},s[3]=a):a=s[3];const i=a;let m;s[4]!==n?(m=(g,h)=>{const x=n[g];return x!==void 0&&h in x?{value:x[h]}:void 0},s[4]=n,s[5]=m):m=s[5];const u=m;let p;s[6]!==n?(p=Object.values(n).reduce(No,0),s[6]=n,s[7]=p):p=s[7];const b=p;let f;return s[8]!==b||s[9]!==n||s[10]!==u?(f={clear:r,count:b,drop:i,stage:c,staged:n,stagedValue:u},s[8]=b,s[9]=n,s[10]=u,s[11]=f):f=s[11],f},nn=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},Co=s=>{const e=V(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=he();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let a;e[3]!==r?(a=d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=a):a=e[4];let i;e[5]!==o||e[6]!==l?(i=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=i):i=e[7];let m;e[8]!==o||e[9]!==t||e[10]!==i?(m=d("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:i}),e[8]=o,e[9]=t,e[10]=i,e[11]=m):m=e[11];let u;e[12]!==l?(u=l("Discard"),e[12]=l,e[13]=u):u=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==u?(p=d("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:c,type:"button",children:u}),e[14]=o,e[15]=c,e[16]=u,e[17]=p):p=e[17];let b;e[18]!==a||e[19]!==m||e[20]!==p?(b=E("div",{className:"flex flex-wrap items-center gap-2",children:[a,m,p]}),e[18]=a,e[19]=m,e[20]=p,e[21]=b):b=e[21];let f;e[22]!==n?(f=n.map(So),e[22]=n,e[23]=f):f=e[23];let g;e[24]!==f?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:f}),e[24]=f,e[25]=g):g=e[25];let h;return e[26]!==b||e[27]!==g?(h=E("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,g]}),e[26]=b,e[27]=g,e[28]=h):h=e[28],h};function No(s,e){return s+Object.keys(e).length}function So(s){return E("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[E("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),d("span",{className:"text-destructive line-through",children:je(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:je(s.newValue)})]},`${s.rowId}:${s.column}`)}const jt=400,ko=36,To={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Eo={width:"100%"},_o=/\n$/u,Ro={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},$o={display:"flex",width:"100%"},zt={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},Do="2.5rem",on={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},At=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),sn=(s,e)=>({...At(s),left:`calc(${Do} + ${e.toString()}px)`,position:"sticky",zIndex:2}),Nt="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",Ao=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,_t="__back__:",Io=s=>`${_t}${s.table}.${s.column}`,Po=s=>{const e=V(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=d("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let c;return e[1]!==t?(c=d("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=c):c=e[2],c},Ae=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},Oo=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},Mo=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return Oo(s,n);const o=nn(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},Lo=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
2
2
  `,`
3
3
  `).replace(_o,"").split(`
4
4
  `),r=[];let a=0;for(const[i,m]of l.entries()){const u=t[s.row+i],p=u===void 0?null:Ae(u),b=m.split(" ");if(u===void 0||p===null){a+=b.length;continue}for(const[f,g]of b.entries()){const h=e[s.col+f],x=h===void 0||!o(h)?void 0:Mo(g,u[h],n?.[h]);h===void 0||x===void 0?a+=1:r.push({column:h,rowId:p,value:x.value})}}return{edits:r,skipped:a}},ln=(s,e)=>Ae(s)??`row-${e.toString()}`,Fo=8,Bo=s=>{const e=V(17),{anchor:n,mask:o,state:t}=s,c=he();let l;e[0]!==n.left||e[1]!==n.top?(l={left:n.left,position:"fixed",top:n.top,zIndex:50},e[0]=n.left,e[1]=n.top,e[2]=l):l=e[2];const r=l;let a;if(t==="loading"){let m;e[3]!==c?(m=c("Loading…"),e[3]=c,e[4]=m):m=e[4];let u;e[5]!==m?(u=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:m}),e[5]=m,e[6]=u):u=e[6],a=u}else if(t.row===null){let m;e[7]!==c?(m=c("No matching row."),e[7]=c,e[8]=m):m=e[8];let u;e[9]!==m?(u=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:m}),e[9]=m,e[10]=u):u=e[10],a=u}else{let m;if(e[11]!==o||e[12]!==t.row){const u=Object.entries(Yt(t.row,o)).slice(0,Fo);m=d("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:u.map(Yo)}),e[11]=o,e[12]=t.row,e[13]=m}else m=e[13];a=m}let i;return e[14]!==a||e[15]!==r?(i=d("div",{className:"pointer-events-none w-72 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground","data-testid":"db-ref-preview",role:"tooltip",style:r,children:a}),e[14]=a,e[15]=r,e[16]=i):i=e[16],i},Vo=s=>{const e=V(24),{column:n,id:o,maskViewFor:t,onNavigate:c,onPreview:l,target:r}=s,[a,i]=$(null),[m,u]=$("idle");let p;e[0]!==o||e[1]!==c||e[2]!==r?(p=()=>{c(r,o)},e[0]=o,e[1]=c,e[2]=r,e[3]=p):p=e[3];const b=p;let f;e[4]!==o||e[5]!==l||e[6]!==m||e[7]!==r?(f=C=>{const S=C.currentTarget.getBoundingClientRect();if(i({left:S.left,top:S.bottom+4}),m!=="idle")return;u("loading"),Ce((async()=>{try{u({row:await l(r,o)})}catch{u({row:null})}})())},e[4]=o,e[5]=l,e[6]=m,e[7]=r,e[8]=f):f=e[8];const g=f;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{i(null)},e[9]=h):h=e[9];const x=h,v=`db-ref-${n}`,w=`Open ${r} ${o}`;let y;e[10]!==o||e[11]!==b||e[12]!==g||e[13]!==v||e[14]!==w?(y=E("button",{"data-testid":v,onBlur:x,onClick:b,onFocus:g,onMouseEnter:g,onMouseLeave:x,title:w,type:"button",children:[o," ↗"]}),e[10]=o,e[11]=b,e[12]=g,e[13]=v,e[14]=w,e[15]=y):y=e[15];let N;e[16]!==a||e[17]!==t||e[18]!==m||e[19]!==r?(N=a!==null&&m!=="idle"&&d(Bo,{anchor:a,mask:t(r,m==="loading"||m.row===null?[]:Object.keys(m.row)),state:m}),e[16]=a,e[17]=t,e[18]=m,e[19]=r,e[20]=N):N=e[20];let T;return e[21]!==y||e[22]!==N?(T=E(Ze,{children:[y,N]}),e[21]=y,e[22]=N,e[23]=T):T=e[23],T},jo=s=>s==="asc"?" ▲":s==="desc"?" ▼":"",zo="absolute end-1 top-1/2 hidden -translate-y-1/2 items-center justify-center rounded text-muted-foreground outline-none group-hover/cell:flex hover:text-foreground focus-visible:flex",qt=s=>{const e=V(8),{column:n,onExpand:o,value:t}=s;let c;e[0]!==n||e[1]!==o||e[2]!==t?(c=()=>{o(n,t)},e[0]=n,e[1]=o,e[2]=t,e[3]=c):c=e[3];const l=c,r=`db-expand-${n}`;let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a=d("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:d("path",{d:"M9 21H5a2 2 0 0 1-2-2v-4m18 0v4a2 2 0 0 1-2 2h-4M3 9V5a2 2 0 0 1 2-2h4m6 0h4a2 2 0 0 1 2 2v4"})}),e[4]=a):a=e[4];let i;return e[5]!==l||e[6]!==r?(i=d("button",{"aria-label":"Expand cell",className:zo,"data-testid":r,onClick:l,type:"button",children:a}),e[5]=l,e[6]=r,e[7]=i):i=e[7],i},qo=s=>{const e=V(15),{column:n,initial:o,onCancel:t,onCommit:c,recordId:l}=s,r=Je(null);let a,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{r.current?.select()},i=[],e[0]=a,e[1]=i):(a=e[0],i=e[1]),Ve(a,i);let m;e[2]!==t||e[3]!==c?(m=x=>{x.key==="Enter"?(x.preventDefault(),c(x.currentTarget.value)):x.key==="Escape"&&(x.preventDefault(),t())},e[2]=t,e[3]=c,e[4]=m):m=e[4];const u=m;let p;e[5]!==c?(p=x=>{c(x.currentTarget.value)},e[5]=c,e[6]=p):p=e[6];const b=p,f=`db-cell-input-${l}-${n}`;let g;e[7]!==o?(g=je(o),e[7]=o,e[8]=g):g=e[8];let h;return e[9]!==n||e[10]!==b||e[11]!==u||e[12]!==f||e[13]!==g?(h=d("input",{"aria-label":n,className:"w-full rounded border border-ring bg-background px-1 py-0.5 font-mono text-xs outline-none","data-testid":f,defaultValue:g,onBlur:b,onKeyDown:u,ref:r}),e[9]=n,e[10]=b,e[11]=u,e[12]=f,e[13]=g,e[14]=h):h=e[14],h},Go=s=>{const e=V(70),{cell:n,edit:o,highlight:t,mask:c,refs:l}=s,r=n.column.id;let a,i,m,u;if(e[0]!==n||e[1]!==r||e[2]!==o||e[3]!==c||e[4]!==l.columns||e[5]!==l.maskViewFor||e[6]!==l.onNavigate||e[7]!==l.onPreview){u=Symbol.for("react.early_return_sentinel");e:{i=n.getValue(),a=Ae(n.row.original);const R=l.columns?.[r];if(c.enabled&&c.columns.has(r)){const _=`db-masked-${r}`,D=d(Ct,{value:Mn(i,r,c)});let A;e[12]!==_||e[13]!==D?(A=d("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:D}),e[12]=_,e[13]=D,e[14]=A):A=e[14],u=A;break e}if(R!==void 0&&(typeof i=="string"||typeof i=="number")&&String(i)!==""){const _=String(i),D=`${R}:${String(i)}`;let A;e[15]!==r||e[16]!==l.maskViewFor||e[17]!==l.onNavigate||e[18]!==l.onPreview||e[19]!==_||e[20]!==D||e[21]!==R?(A=d(Vo,{column:r,id:_,maskViewFor:l.maskViewFor,onNavigate:l.onNavigate,onPreview:l.onPreview,target:R},D),e[15]=r,e[16]=l.maskViewFor,e[17]=l.onNavigate,e[18]=l.onPreview,e[19]=_,e[20]=D,e[21]=R,e[22]=A):A=e[22],u=A;break e}if(a===null){let _;e[23]!==i?(_=d(Ct,{value:i}),e[23]=i,e[24]=_):_=e[24];let D;e[25]!==r||e[26]!==o.onExpandCell||e[27]!==i?(D=d(qt,{column:r,onExpand:o.onExpandCell,value:i}),e[25]=r,e[26]=o.onExpandCell,e[27]=i,e[28]=D):D=e[28];let A;e[29]!==_||e[30]!==D?(A=E(Ze,{children:[_,D]}),e[29]=_,e[30]=D,e[31]=A):A=e[31],u=A;break e}m=o.stagedValue(a,r)}e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=l.columns,e[5]=l.maskViewFor,e[6]=l.onNavigate,e[7]=l.onPreview,e[8]=a,e[9]=i,e[10]=m,e[11]=u}else a=e[8],i=e[9],m=e[10],u=e[11];if(u!==Symbol.for("react.early_return_sentinel"))return u;const p=m,b=p===void 0?i:p.value;let f;e[32]!==r||e[33]!==o?(f=o.editable&&o.editableColumn(r),e[32]=r,e[33]=o,e[34]=f):f=e[34];const g=f;if(o.editingCell!==null&&o.editingCell.rowId===a&&o.editingCell.column===r){let R;e[35]!==r||e[36]!==o||e[37]!==a||e[38]!==i?(R=D=>{o.stage(a,r,nn(D,i)),o.cancelEdit()},e[35]=r,e[36]=o,e[37]=a,e[38]=i,e[39]=R):R=e[39];let _;return e[40]!==r||e[41]!==b||e[42]!==o.cancelEdit||e[43]!==a||e[44]!==R?(_=d(qo,{column:r,initial:b,onCancel:o.cancelEdit,onCommit:R,recordId:a}),e[40]=r,e[41]=b,e[42]=o.cancelEdit,e[43]=a,e[44]=R,e[45]=_):_=e[45],_}let x;p!==void 0?x="rounded bg-warning/15 px-1":g&&(x="cursor-text");let v;e[46]!==g||e[47]!==r||e[48]!==o||e[49]!==a?(v=g?()=>{o.startEdit(a,r)}:void 0,e[46]=g,e[47]=r,e[48]=o,e[49]=a,e[50]=v):v=e[50];const w=v,y=x,N=`db-cell-${a}-${r}`;let T;e[51]!==r||e[52]!==t||e[53]!==c?(T=Ao(t,c,r),e[51]=r,e[52]=t,e[53]=c,e[54]=T):T=e[54];let C;e[55]!==b||e[56]!==T?(C=d(Ct,{highlight:T,value:b}),e[55]=b,e[56]=T,e[57]=C):C=e[57];let S;e[58]!==x||e[59]!==w||e[60]!==N||e[61]!==C?(S=d("span",{className:y,"data-testid":N,onDoubleClick:w,children:C}),e[58]=x,e[59]=w,e[60]=N,e[61]=C,e[62]=S):S=e[62];let k;e[63]!==r||e[64]!==b||e[65]!==o.onExpandCell?(k=d(qt,{column:r,onExpand:o.onExpandCell,value:b}),e[63]=r,e[64]=b,e[65]=o.onExpandCell,e[66]=k):k=e[66];let O;return e[67]!==k||e[68]!==S?(O=E(Ze,{children:[S,k]}),e[67]=k,e[68]=S,e[69]=O):O=e[69],O},Ko=s=>{s.preventDefault()},Gt={any:"?",array:"[]",bigint:"#",boolean:"01",bytes:"0x",id:"→",number:"#",object:"{}",storage:"◫",string:"T",union:"|"},Jo=({declaredType:s,draggedRef:e,header:n,masked:o=!1,onTogglePin:t,pinnedOffset:c,table:l})=>{const r=()=>{e.current=n.column.id},a=()=>{const i=e.current,m=n.column.id;if(e.current=null,i===null||i===m)return;const u=l.getState().columnOrder,b=(u.length>0?u:l.getAllLeafColumns().map(g=>g.id)).filter(g=>g!==i),f=b.indexOf(m);b.splice(f===-1?b.length:f,0,i),l.setColumnOrder(b)};return E("th",{className:it("group/head text-start text-xs font-medium text-muted-foreground",c!==void 0&&"border-e border-border bg-muted"),draggable:!0,onDragOver:Ko,onDragStart:r,onDrop:a,style:c===void 0?At(n.getSize()):sn(n.getSize(),c),children:[E("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${n.column.id}`,onClick:n.column.getToggleSortingHandler(),type:"button",children:[Un(n.column.columnDef.header,n.getContext()),jo(n.column.getIsSorted())]}),s!==void 0&&Gt[s]!==void 0&&d("span",{className:"ms-1 font-mono text-[0.625rem] text-muted-foreground/70","data-testid":`db-type-${n.column.id}`,title:s,children:Gt[s]}),o&&d("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`db-mask-chip-${n.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),d("button",{"aria-label":c===void 0?`Pin ${n.column.id}`:`Unpin ${n.column.id}`,"aria-pressed":c!==void 0,className:it("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",c===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${n.column.id}`,onClick:()=>{t(n.column.id)},type:"button",children:"📌"}),d("span",{"aria-hidden":"true",className:"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-ring/60 data-[resizing=true]:bg-ring","data-resizing":n.column.getIsResizing(),"data-testid":`db-resize-${n.column.id}`,onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler()})]})},Wo=s=>{const e=V(13),{table:n}=s,o=he();let t;e[0]!==n?(t=m=>{n.toggleAllRowsSelected(m)},e[0]=n,e[1]=t):t=e[1];const c=t;let l;e[2]!==o?(l=o("Select all rows"),e[2]=o,e[3]=l):l=e[3];let r;e[4]!==n?(r=n.getIsAllRowsSelected(),e[4]=n,e[5]=r):r=e[5];let a;e[6]!==n?(a=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=a):a=e[7];let i;return e[8]!==c||e[9]!==l||e[10]!==r||e[11]!==a?(i=d("th",{className:"bg-muted",style:on,children:d($t,{"aria-label":l,checked:r,"data-testid":"db-select-all",indeterminate:a,onCheckedChange:c})}),e[8]=c,e[9]=l,e[10]=r,e[11]=a,e[12]=i):i=e[12],i},Ho=s=>{const e=V(17),{row:n}=s,o=he();let t;e[0]!==n.original?(t=Ae(n.original),e[0]=n.original,e[1]=t):t=e[1];const c=t;let l;e[2]!==n?(l=f=>{n.toggleSelected(f)},e[2]=n,e[3]=l):l=e[3];const r=l;let a;e[4]!==o?(a=o("Select row"),e[4]=o,e[5]=a):a=e[5];let i;e[6]!==n?(i=n.getIsSelected(),e[6]=n,e[7]=i):i=e[7];let m;e[8]!==n.index||e[9]!==n.original?(m=ln(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=m):m=e[10];const u=`db-select-${m}`,p=c===null;let b;return e[11]!==r||e[12]!==a||e[13]!==i||e[14]!==u||e[15]!==p?(b=d("td",{className:"bg-background",style:on,children:d($t,{"aria-label":a,checked:i,"data-testid":u,disabled:p,onCheckedChange:r})}),e[11]=r,e[12]=a,e[13]=i,e[14]=u,e[15]=p,e[16]=b):b=e[16],b},Uo=s=>{const e=V(91),{columnMeta:n,edit:o,editable:t,mask:c,onDelete:l,onEdit:r,onInspect:a,highlight:i,backRelationCounts:m,onTogglePin:u,pinnedColumns:p,refs:b,tableModel:f}=s,g=he(),{attachScroll:h,scrollLeft:x,scrollToIndex:v,table:w,tableRows:y,tbodyStyle:N,viewportWidth:T,virtualRows:C}=f,S=Je(null),[k,O]=$(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={columns:"",count:0},e[0]=R):R=e[0];const[_,D]=$(R);let A;e[1]!==w?(A=w.getVisibleLeafColumns(),e[1]=w,e[2]=A):A=e[2];const L=A.length;let P;e[3]!==k||e[4]!==L||e[5]!==o||e[6]!==w||e[7]!==y?(P=ee=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(ee.key))return;ee.preventDefault();const H=k??{col:0,row:0};if(ee.key==="Enter"){const we=y[H.row],ye=w.getVisibleLeafColumns()[H.col];if(we!==void 0&&ye!==void 0){const U=Ae(we.original);U!==null&&o.editableColumn(ye.id)&&o.startEdit(U,ye.id)}O(H);return}let{col:ve,row:ge}=H;e:switch(ee.key){case"ArrowDown":{ge=Math.min(ge+1,y.length-1);break e}case"ArrowRight":{ve=Math.min(ve+1,L-1);break e}case"ArrowUp":{ge=Math.max(ge-1,0);break e}default:ve=Math.max(ve-1,0)}O({col:ve,row:ge})},e[3]=k,e[4]=L,e[5]=o,e[6]=w,e[7]=y,e[8]=P):P=e[8];const j=P;let q;e[9]!==k||e[10]!==n||e[11]!==o||e[12]!==w||e[13]!==y?(q=ee=>{const H=o.editable?ee.clipboardData.getData("text/plain"):"";if(H==="")return;ee.preventDefault();const ve=w.getVisibleLeafColumns().map(Xo),ge=Lo({anchor:k??{col:0,row:0},columnIds:ve,columnMeta:n,editableColumn:o.editableColumn,rows:y.map(Zo),text:H});for(const we of ge.edits)o.stage(we.rowId,we.column,we.value);D({columns:ve.join("\0"),count:ge.skipped})},e[9]=k,e[10]=n,e[11]=o,e[12]=w,e[13]=y,e[14]=q):q=e[14];const M=q;let B,J;e[15]!==k||e[16]!==v?(B=()=>{k!==null&&v(k.row)},J=[k,v],e[15]=k,e[16]=v,e[17]=B,e[18]=J):(B=e[17],J=e[18]),Ve(B,J);let G,X,Q,Z,fe,ne,ce,de,me,le,ue,re,Y,be,te,xe;if(e[19]!==k||e[20]!==h||e[21]!==m||e[22]!==n||e[23]!==o||e[24]!==t||e[25]!==i||e[26]!==c||e[27]!==l||e[28]!==r||e[29]!==j||e[30]!==M||e[31]!==a||e[32]!==u||e[33]!==_.columns||e[34]!==_.count||e[35]!==p||e[36]!==b||e[37]!==x||e[38]!==g||e[39]!==w||e[40]!==y||e[41]!==N||e[42]!==T||e[43]!==C){const ee=w.getVisibleLeafColumns().map(es),H=vo(ee,p,x,T),ve=wo(w.getVisibleLeafColumns().map(ts),p),ge=U=>{const oe=y[U.index],{original:Me}=oe,Ie=Ae(Me),Pe=ln(Me,U.index),He={...Ro,height:`${U.size.toString()}px`,transform:`translateY(${U.start.toString()}px)`};return E("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:He,children:[d(Ho,{row:oe}),H.leadPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${H.leadPx.toString()}px`}}),oe.getVisibleCells().map((Se,ze)=>{if(!H.ids.has(Se.column.id))return null;const Le=ve.get(Se.column.id),Ue=k!==null&&k.row===U.index&&k.col===ze?" ring-1 ring-ring ring-inset":"";return d("td",{className:it("group/cell truncate font-mono text-muted-foreground",Le!==void 0&&"border-e border-border bg-background",Ue),onPointerDown:()=>{O({col:ze,row:U.index})},style:Le===void 0?At(Se.column.getSize()):sn(Se.column.getSize(),Le),children:Se.column.id.startsWith(_t)?d(Po,{counts:m[Se.column.id.slice(_t.length)],rowId:Pe}):d(Go,{cell:Se,edit:o,highlight:i,mask:c,refs:b})},Se.id)}),H.tailPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${H.tailPx.toString()}px`}}),E("td",{className:"flex items-center gap-1",style:zt,children:[d("button",{className:Nt,"data-testid":`db-inspect-${Pe}`,onClick:()=>{a(Me)},type:"button",children:"Details"}),t&&E(Ze,{children:[d("button",{className:Nt,"data-testid":`db-edit-${Pe}`,disabled:Ie===null,onClick:()=>{r(Ie,Me)},type:"button",children:"Edit"}),d("button",{className:Nt,"data-testid":`db-delete-${Pe}`,disabled:Ie===null,onClick:()=>{l(Ie)},type:"button",children:"Delete"})]})]})]},oe.id)};G=Xn,re="fill",e[60]!==_.columns||e[61]!==_.count||e[62]!==g||e[63]!==w?(Y=_.count>0&&_.columns===w.getVisibleLeafColumns().map(ns).join("\0")&&d("p",{className:"border-b border-warning/40 bg-warning/5 px-3 py-1.5 text-xs text-warning","data-testid":"db-paste-skipped",children:g("{count} pasted cells were skipped",{count:_.count})}),e[60]=_.columns,e[61]=_.count,e[62]=g,e[63]=w,e[64]=Y):Y=e[64],fe="db-scroll",ne=j,ce=M,de=h,me="grid",le=To,ue=0,xe="w-full text-xs",X="db-rows",Q=Eo;let we;e[65]!==w?(we=d(Wo,{table:w}),e[65]=w,e[66]=we):we=e[66];let ye;e[67]===Symbol.for("react.memo_cache_sentinel")?(ye=d("th",{"aria-label":"Row actions",style:zt}),e[67]=ye):ye=e[67],Z=d("thead",{className:"bg-muted/50",children:E("tr",{className:"border-b border-border",style:$o,children:[we,H.leadPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${H.leadPx.toString()}px`}}),w.getFlatHeaders().map(U=>H.ids.has(U.column.id)?d(Jo,{declaredType:n?.[U.column.id]?.type,draggedRef:S,header:U,masked:c.columns.has(U.column.id),onTogglePin:u,pinnedOffset:ve.get(U.column.id),table:w},U.id):null),H.tailPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${H.tailPx.toString()}px`}}),ye]})}),be=N,te=C.map(U=>ge(U)),e[19]=k,e[20]=h,e[21]=m,e[22]=n,e[23]=o,e[24]=t,e[25]=i,e[26]=c,e[27]=l,e[28]=r,e[29]=j,e[30]=M,e[31]=a,e[32]=u,e[33]=_.columns,e[34]=_.count,e[35]=p,e[36]=b,e[37]=x,e[38]=g,e[39]=w,e[40]=y,e[41]=N,e[42]=T,e[43]=C,e[44]=G,e[45]=X,e[46]=Q,e[47]=Z,e[48]=fe,e[49]=ne,e[50]=ce,e[51]=de,e[52]=me,e[53]=le,e[54]=ue,e[55]=re,e[56]=Y,e[57]=be,e[58]=te,e[59]=xe}else G=e[44],X=e[45],Q=e[46],Z=e[47],fe=e[48],ne=e[49],ce=e[50],de=e[51],me=e[52],le=e[53],ue=e[54],re=e[55],Y=e[56],be=e[57],te=e[58],xe=e[59];let ae;e[68]!==be||e[69]!==te?(ae=d("tbody",{style:be,children:te}),e[68]=be,e[69]=te,e[70]=ae):ae=e[70];let ie;e[71]!==X||e[72]!==Q||e[73]!==Z||e[74]!==ae||e[75]!==xe?(ie=E("table",{className:xe,"data-testid":X,style:Q,children:[Z,ae]}),e[71]=X,e[72]=Q,e[73]=Z,e[74]=ae,e[75]=xe,e[76]=ie):ie=e[76];let W;e[77]!==fe||e[78]!==ne||e[79]!==ce||e[80]!==de||e[81]!==me||e[82]!==le||e[83]!==ue||e[84]!==ie?(W=d("div",{"data-testid":fe,onKeyDown:ne,onPaste:ce,ref:de,role:me,style:le,tabIndex:ue,children:ie}),e[77]=fe,e[78]=ne,e[79]=ce,e[80]=de,e[81]=me,e[82]=le,e[83]=ue,e[84]=ie,e[85]=W):W=e[85];let K;return e[86]!==G||e[87]!==re||e[88]!==Y||e[89]!==W?(K=E(G,{layout:re,children:[Y,W]}),e[86]=G,e[87]=re,e[88]=Y,e[89]=W,e[90]=K):K=e[90],K},Qo=(s,e,n,o=[])=>{const t=s?.columns,c=s?.rows,l=s?.refs,r=Tt(()=>{if(t===void 0)return[];const S=t.map(k=>({accessorFn:O=>O[k],header:l?.[k]===void 0?k:`${k} →`,id:k}));for(const k of o)S.push({accessorFn:()=>{},enableSorting:!1,header:`← ${k.table}`,id:Io(k)});return S},[o,t,l]),a=Tt(()=>c??[],[c]),[i,m]=$({}),[u,p]=$({}),b=Jn({columnResizeMode:"onChange",columns:r,data:a,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:S=>Ae(S.original)!==null,getCoreRowModel:Hn(),getRowId:(S,k)=>Ae(S)??`row-${k.toString()}`,getSortedRowModel:Wn(),manualSorting:!0,onColumnVisibilityChange:p,onRowSelectionChange:m,onSortingChange:n,state:{columnVisibility:u,rowSelection:i,sorting:e}}),f=b.getRowModel().rows,g=Je(null),h=Qn({count:f.length,estimateSize:()=>ko,getScrollElement:()=>g.current,initialRect:{height:jt,width:0},observeElementRect:(S,k)=>Yn(S,k,jt),overscan:8}),x=at(S=>{h.scrollToIndex(S)},[h]),[v,w]=$({left:0,width:0}),y=at(S=>{if(g.current=S,S===null)return;const k=()=>{w(R=>R.left===S.scrollLeft&&R.width===S.clientWidth?R:{left:S.scrollLeft,width:S.clientWidth})};S.addEventListener("scroll",k,{passive:!0});const O=new ResizeObserver(k);return O.observe(S),()=>{S.removeEventListener("scroll",k),O.disconnect(),g.current=null}},[]),N=h.getVirtualItems(),C={display:"block",height:`${h.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:y,scrollLeft:v.left,scrollToIndex:x,table:b,tableRows:f,tbodyStyle:C,viewportWidth:v.width,virtualRows:N}};function Yo(s){const[e,n]=s;return E("div",{className:"contents",children:[d("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),d("dd",{className:"truncate font-mono text-[11px] text-foreground",title:je(n),children:je(n)})]},e)}function Xo(s){return s.id}function Zo(s){return s.original}function es(s){return{getSize:()=>s.getSize(),id:s.id}}function ts(s){return{getSize:()=>s.getSize(),id:s.id}}function ns(s){return s.id}const os=s=>{const e=V(22),{onCommit:n}=s,o=he(),[t,c]=$(""),l=Je(null);let r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{l.current?.focus()},a=[],e[0]=r,e[1]=a):(r=e[0],a=e[1]),Ve(r,a);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=w=>{c(w.target.value)},e[2]=i):i=e[2];const m=i;let u;e[3]!==t||e[4]!==n?(u=()=>{const w=t.trim();w!==""&&n(w)},e[3]=t,e[4]=n,e[5]=u):u=e[5];const p=u;let b;e[6]!==o?(b=o("Query name"),e[6]=o,e[7]=b):b=e[7];let f;e[8]!==o?(f=o("Query name"),e[8]=o,e[9]=f):f=e[9];let g;e[10]!==t||e[11]!==b||e[12]!==f?(g=d("input",{"aria-label":b,className:"h-7 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"db-save-query-name",onChange:m,placeholder:f,ref:l,value:t}),e[10]=t,e[11]=b,e[12]=f,e[13]=g):g=e[13];let h;e[14]!==o?(h=o("Save"),e[14]=o,e[15]=h):h=e[15];let x;e[16]!==p||e[17]!==h?(x=d("button",{className:Et,"data-testid":"db-save-query-confirm",onClick:p,type:"button",children:h}),e[16]=p,e[17]=h,e[18]=x):x=e[18];let v;return e[19]!==g||e[20]!==x?(v=E("span",{className:"inline-flex items-center gap-1",children:[g,x]}),e[19]=g,e[20]=x,e[21]=v):v=e[21],v},ss=s=>{const e=V(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:c,saved:l}=s,r=he(),[a,i]=$(!1);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{i(!0)},e[0]=m):m=e[0];const u=m;let p;e[1]!==c?(p=C=>{c(C),i(!1)},e[1]=c,e[2]=p):p=e[2];const b=p;let f;e[3]!==n||e[4]!==l?(f=C=>{const S=l[Number(C.currentTarget.dataset.index)];S!==void 0&&n(S)},e[3]=n,e[4]=l,e[5]=f):f=e[5];const g=f;let h;e[6]!==t||e[7]!==l?(h=C=>{const S=l[Number(C.currentTarget.dataset.index)];S!==void 0&&t(S.name)},e[6]=t,e[7]=l,e[8]=h):h=e[8];const x=h;let v;e[9]!==r?(v=r("Copy link"),e[9]=r,e[10]=v):v=e[10];let w;e[11]!==o||e[12]!==v?(w=d("button",{className:Et,"data-testid":"db-copy-link",onClick:o,type:"button",children:v}),e[11]=o,e[12]=v,e[13]=w):w=e[13];let y;e[14]!==b||e[15]!==a||e[16]!==r?(y=a?d(os,{onCommit:b}):d("button",{className:Et,"data-testid":"db-save-query",onClick:u,type:"button",children:r("Save query")}),e[14]=b,e[15]=a,e[16]=r,e[17]=y):y=e[17];let N;e[18]!==g||e[19]!==x||e[20]!==l||e[21]!==r?(N=l.length>0&&E("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r("Saved")}),l.map((C,S)=>E("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[d("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":S,"data-testid":`db-saved-query-${C.name}`,onClick:g,type:"button",children:C.name}),d("button",{"aria-label":r("Delete saved query {name}",{name:C.name}),className:"border-l border-border px-1 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive","data-index":S,"data-testid":`db-saved-query-delete-${C.name}`,onClick:x,type:"button",children:"✕"})]},C.name))]}),e[18]=g,e[19]=x,e[20]=l,e[21]=r,e[22]=N):N=e[22];let T;return e[23]!==w||e[24]!==y||e[25]!==N?(T=E("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[w,y,N]}),e[23]=w,e[24]=y,e[25]=N,e[26]=T):T=e[26],T},We="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",rn=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Kt=(s,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?rn.test(s)?"date":"number":e!==null&&typeof e=="object"?"json":"text",ls=(s,e,n)=>n===void 0?Kt(s,e):n.enumValues!==void 0&&n.enumValues.length>0?"enum":n.type==="boolean"?"boolean":n.type==="number"?rn.test(s)?"date":"number":Kt(s,e),rs=s=>{try{const e=JSON.parse(s);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},as=s=>{const e=new Date(s),n=o=>String(o).padStart(2,"0");return`${e.getFullYear().toString()}-${n(e.getMonth()+1)}-${n(e.getDate())}T${n(e.getHours())}:${n(e.getMinutes())}`},Ke="\0clear",is=s=>{const e=V(23),{column:n,nullable:o,onChange:t,value:c}=s,l=he();let r;e[0]!==n||e[1]!==t?(r=v=>{t(n,v)},e[0]=n,e[1]=t,e[2]=r):r=e[2];const a=r;let i;e[3]!==n||e[4]!==t?(i=v=>{t(n,v.target.value===Ke?null:v.target.value==="true")},e[3]=n,e[4]=t,e[5]=i):i=e[5];const m=i;if(!o&&c!==null){const v=c===!0,w=`db-field-${n}`;let y;return e[6]!==n||e[7]!==a||e[8]!==v||e[9]!==w?(y=d($t,{"aria-label":n,checked:v,"data-testid":w,onCheckedChange:a}),e[6]=n,e[7]=a,e[8]=v,e[9]=w,e[10]=y):y=e[10],y}const u=`db-field-${n}`,p=c===!0||c===!1?String(c):Ke;let b;e[11]!==l?(b=l("(none)"),e[11]=l,e[12]=b):b=e[12];let f;e[13]!==b?(f=d("option",{value:Ke,children:b}),e[13]=b,e[14]=f):f=e[14];let g,h;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=d("option",{value:"true",children:"true"}),h=d("option",{value:"false",children:"false"}),e[15]=g,e[16]=h):(g=e[15],h=e[16]);let x;return e[17]!==n||e[18]!==m||e[19]!==u||e[20]!==p||e[21]!==f?(x=E("select",{"aria-label":n,className:We,"data-testid":u,onChange:m,value:p,children:[f,g,h]}),e[17]=n,e[18]=m,e[19]=u,e[20]=p,e[21]=f,e[22]=x):x=e[22],x},cs=s=>{const e=V(23),{column:n,nullable:o,onChange:t,options:c,value:l}=s,r=he(),a=typeof l=="string"?l:null;let i;e[0]!==c||e[1]!==a?(i=a!==null&&!c.includes(a),e[0]=c,e[1]=a,e[2]=i):i=e[2];const m=i;let u;e[3]!==n||e[4]!==t?(u=w=>{t(n,w.target.value===Ke?null:w.target.value)},e[3]=n,e[4]=t,e[5]=u):u=e[5];const p=u,b=`db-field-${n}`,f=a??Ke;let g;e[6]!==o||e[7]!==a||e[8]!==r?(g=(o||a===null)&&d("option",{value:Ke,children:r("(none)")}),e[6]=o,e[7]=a,e[8]=r,e[9]=g):g=e[9];let h;e[10]!==a||e[11]!==m?(h=m&&d("option",{value:a,children:a}),e[10]=a,e[11]=m,e[12]=h):h=e[12];let x;e[13]!==c?(x=c.map(bs),e[13]=c,e[14]=x):x=e[14];let v;return e[15]!==n||e[16]!==p||e[17]!==b||e[18]!==f||e[19]!==g||e[20]!==h||e[21]!==x?(v=E("select",{"aria-label":n,className:We,"data-testid":b,onChange:p,value:f,children:[g,h,x]}),e[15]=n,e[16]=p,e[17]=b,e[18]=f,e[19]=g,e[20]=h,e[21]=x,e[22]=v):v=e[22],v},ds=s=>{const e=V(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=m=>{const u=Number(m.target.value);m.target.value!==""&&!Number.isNaN(u)&&o(n,u)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="number"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"number",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},us=s=>{const e=V(10),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=m=>{const u=new Date(m.target.value).getTime();Number.isNaN(u)||o(n,u)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`;let a;e[3]!==t?(a=typeof t=="number"?as(t):"",e[3]=t,e[4]=a):a=e[4];let i;return e[5]!==n||e[6]!==l||e[7]!==r||e[8]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"datetime-local",value:a}),e[5]=n,e[6]=l,e[7]=r,e[8]=a,e[9]=i):i=e[9],i},fs=s=>{const e=V(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=m=>{o(n,m.target.value)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,a=typeof t=="string"?t:"";let i;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==a?(i=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"text",value:a}),e[3]=n,e[4]=l,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},ms=s=>{const e=V(20),{column:n,onChange:o,value:t}=s,c=he();let l;e[0]!==t?(l=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=l):l=e[1];const[r,a]=$(l),[i,m]=$(!1);let u;e[2]!==n||e[3]!==o?(u=w=>{const y=w.target.value;a(y);try{o(n,JSON.parse(y)),m(!1)}catch{m(!0)}},e[2]=n,e[3]=o,e[4]=u):u=e[4];const p=u,b=i&&"border-destructive";let f;e[5]!==b?(f=it(We,"min-h-16",b),e[5]=b,e[6]=f):f=e[6];const g=`db-field-${n}`;let h;e[7]!==n||e[8]!==p||e[9]!==f||e[10]!==g||e[11]!==r?(h=d("textarea",{"aria-label":n,className:f,"data-testid":g,onChange:p,value:r}),e[7]=n,e[8]=p,e[9]=f,e[10]=g,e[11]=r,e[12]=h):h=e[12];let x;e[13]!==n||e[14]!==i||e[15]!==c?(x=i&&d("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:c("Invalid JSON")}),e[13]=n,e[14]=i,e[15]=c,e[16]=x):x=e[16];let v;return e[17]!==h||e[18]!==x?(v=E("div",{className:"flex flex-col gap-1",children:[h,x]}),e[17]=h,e[18]=x,e[19]=v):v=e[19],v},gs=s=>{const e=V(56),{column:n,meta:o,onChange:t,target:c,value:l}=s;let r;e[0]!==n||e[1]!==o||e[2]!==l?(r=ls(n,l,o),e[0]=n,e[1]=o,e[2]=l,e[3]=r):r=e[3];const a=r,i=`db-field-${n}`;let m;e[4]!==n?(m=d("span",{className:"font-mono",children:n}),e[4]=n,e[5]=m):m=e[5];let u;e[6]!==n||e[7]!==o?(u=o!==void 0&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide","data-testid":`db-field-type-${n}`,children:o.type}),e[6]=n,e[7]=o,e[8]=u):u=e[8];let p;e[9]!==c?(p=c!==void 0&&E("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["→ ",c]}),e[9]=c,e[10]=p):p=e[10];let b;e[11]!==m||e[12]!==u||e[13]!==p?(b=E("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[m,u,p]}),e[11]=m,e[12]=u,e[13]=p,e[14]=b):b=e[14];let f;e[15]!==n||e[16]!==a||e[17]!==o?.nullable||e[18]!==t||e[19]!==l?(f=a==="boolean"&&d(is,{column:n,nullable:o?.nullable===!0,onChange:t,value:l}),e[15]=n,e[16]=a,e[17]=o?.nullable,e[18]=t,e[19]=l,e[20]=f):f=e[20];let g;e[21]!==n||e[22]!==a||e[23]!==o||e[24]!==t||e[25]!==l?(g=a==="enum"&&o?.enumValues!==void 0&&d(cs,{column:n,nullable:o.nullable===!0,onChange:t,options:o.enumValues,value:l}),e[21]=n,e[22]=a,e[23]=o,e[24]=t,e[25]=l,e[26]=g):g=e[26];let h;e[27]!==n||e[28]!==a||e[29]!==t||e[30]!==l?(h=a==="number"&&d(ds,{column:n,onChange:t,value:l}),e[27]=n,e[28]=a,e[29]=t,e[30]=l,e[31]=h):h=e[31];let x;e[32]!==n||e[33]!==a||e[34]!==t||e[35]!==l?(x=a==="date"&&d(us,{column:n,onChange:t,value:l}),e[32]=n,e[33]=a,e[34]=t,e[35]=l,e[36]=x):x=e[36];let v;e[37]!==n||e[38]!==a||e[39]!==t||e[40]!==l?(v=a==="json"&&d(ms,{column:n,onChange:t,value:l}),e[37]=n,e[38]=a,e[39]=t,e[40]=l,e[41]=v):v=e[41];let w;e[42]!==n||e[43]!==a||e[44]!==t||e[45]!==l?(w=a==="text"&&d(fs,{column:n,onChange:t,value:l}),e[42]=n,e[43]=a,e[44]=t,e[45]=l,e[46]=w):w=e[46];let y;return e[47]!==x||e[48]!==v||e[49]!==w||e[50]!==i||e[51]!==b||e[52]!==f||e[53]!==g||e[54]!==h?(y=E("label",{className:"flex flex-col gap-1 text-xs",htmlFor:i,children:[b,f,g,h,x,v,w]}),e[47]=x,e[48]=v,e[49]=w,e[50]=i,e[51]=b,e[52]=f,e[53]=g,e[54]=h,e[55]=y):y=e[55],y},ps=s=>{const e=V(49),{columnMeta:n,documentText:o,onCancel:t,onDocumentTextChange:c,onSave:l,refs:r}=s,a=he();let i;e[0]!==o?(i=rs(o),e[0]=o,e[1]=i):i=e[1];const m=i,[u,p]=$(!1),b=!u&&m!==null;let f;e[2]!==m||e[3]!==c?(f=(B,J)=>{c(JSON.stringify({...m,[B]:J},null,2))},e[2]=m,e[3]=c,e[4]=f):f=e[4];const g=f;let h;e[5]!==c?(h=B=>{c(B.target.value)},e[5]=c,e[6]=h):h=e[6];const x=h;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{p(!1)},e[7]=v):v=e[7];const w=v;let y;e[8]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{p(!0)},e[8]=y):y=e[8];const N=y,T=m===null;let C;e[9]!==a?(C=a("Form"),e[9]=a,e[10]=C):C=e[10];let S;e[11]!==b||e[12]!==T||e[13]!==C?(S=d("button",{"aria-pressed":b,className:De,"data-testid":"db-editor-form",disabled:T,onClick:w,type:"button",children:C}),e[11]=b,e[12]=T,e[13]=C,e[14]=S):S=e[14];const k=!b;let O;e[15]!==a?(O=a("JSON"),e[15]=a,e[16]=O):O=e[16];let R;e[17]!==O||e[18]!==k?(R=d("button",{"aria-pressed":k,className:De,"data-testid":"db-editor-json",onClick:N,type:"button",children:O}),e[17]=O,e[18]=k,e[19]=R):R=e[19];let _;e[20]!==R||e[21]!==S?(_=E("div",{className:"flex items-center gap-1.5",children:[S,R]}),e[20]=R,e[21]=S,e[22]=_):_=e[22];let D;e[23]!==n||e[24]!==o||e[25]!==m||e[26]!==g||e[27]!==x||e[28]!==r||e[29]!==b||e[30]!==a?(D=b?d("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(m).map(B=>{const[J,G]=B;return d(gs,{column:J,meta:n?.[J],onChange:g,target:r?.[J],value:G},J)})}):d("textarea",{"aria-label":a("Row document JSON"),className:"min-h-28 w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"db-editor-doc",onChange:x,value:o}),e[23]=n,e[24]=o,e[25]=m,e[26]=g,e[27]=x,e[28]=r,e[29]=b,e[30]=a,e[31]=D):D=e[31];let A;e[32]!==a?(A=a("Save"),e[32]=a,e[33]=A):A=e[33];let L;e[34]!==l||e[35]!==A?(L=d("button",{className:De,"data-testid":"db-editor-save",onClick:l,type:"button",children:A}),e[34]=l,e[35]=A,e[36]=L):L=e[36];let P;e[37]!==a?(P=a("Cancel"),e[37]=a,e[38]=P):P=e[38];let j;e[39]!==t||e[40]!==P?(j=d("button",{className:De,"data-testid":"db-editor-cancel",onClick:t,type:"button",children:P}),e[39]=t,e[40]=P,e[41]=j):j=e[41];let q;e[42]!==L||e[43]!==j?(q=E("div",{className:"flex items-center gap-1.5",children:[L,j]}),e[42]=L,e[43]=j,e[44]=q):q=e[44];let M;return e[45]!==_||e[46]!==D||e[47]!==q?(M=E("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,D,q]}),e[45]=_,e[46]=D,e[47]=q,e[48]=M):M=e[48],M};function bs(s){return d("option",{value:s,children:s},s)}const hs=s=>{const e=V(66),{columns:n,editable:o,filter:t,filters:c,hasMaskedColumns:l,hasPredicate:r,liveError:a,maskOn:i,onAddRow:m,onBulkDelete:u,onBulkPatch:p,onAskAiFilter:b,onClearTable:f,onFilterChange:g,onFiltersChange:h,onGenerateRows:x,onShowJson:v,onShowTable:w,onToggleMask:y,total:N,viewMode:T}=s,C=he(),S=T==="table";let k;e[0]!==w||e[1]!==S?(k=d("button",{"aria-pressed":S,className:De,"data-testid":"db-view-table",onClick:w,type:"button",children:"Table"}),e[0]=w,e[1]=S,e[2]=k):k=e[2];const O=T==="json";let R;e[3]!==v||e[4]!==O?(R=d("button",{"aria-pressed":O,className:De,"data-testid":"db-view-json",onClick:v,type:"button",children:"JSON"}),e[3]=v,e[4]=O,e[5]=R):R=e[5];let _;e[6]!==a||e[7]!==C?(_=a===void 0?C("Live — changes stream in automatically"):C("Live unavailable: {liveError}",{liveError:a}),e[6]=a,e[7]=C,e[8]=_):_=e[8];const D=`size-1.5 rounded-full ${a===void 0?"bg-success":"bg-muted-foreground/50"}`;let A;e[9]!==D?(A=d("span",{"aria-hidden":"true",className:D}),e[9]=D,e[10]=A):A=e[10];let L;e[11]!==a||e[12]!==C?(L=C(a===void 0?"Live":"Live unavailable"),e[11]=a,e[12]=C,e[13]=L):L=e[13];let P;e[14]!==_||e[15]!==A||e[16]!==L?(P=E("span",{className:"inline-flex items-center gap-1.5 px-1 text-xs font-medium text-muted-foreground","data-testid":"db-live-indicator",role:"status",title:_,children:[A,L]}),e[14]=_,e[15]=A,e[16]=L,e[17]=P):P=e[17];let j;e[18]!==l||e[19]!==i||e[20]!==y||e[21]!==C?(j=l&&d("button",{"aria-pressed":i,className:De,"data-testid":"db-mask-toggle",onClick:y,type:"button",children:C("Mask sensitive columns")}),e[18]=l,e[19]=i,e[20]=y,e[21]=C,e[22]=j):j=e[22];let q;e[23]!==o||e[24]!==m?(q=o&&d("button",{className:De,"data-testid":"db-add-row",onClick:m,type:"button",children:"Add row"}),e[23]=o,e[24]=m,e[25]=q):q=e[25];let M;e[26]!==o||e[27]!==x||e[28]!==C?(M=o&&d("button",{className:De,"data-testid":"db-generate-rows",onClick:x,type:"button",children:C("Generate rows")}),e[26]=o,e[27]=x,e[28]=C,e[29]=M):M=e[29];let B;e[30]!==o||e[31]!==r||e[32]!==u||e[33]!==N?(B=o&&N>0&&r&&d(Lt,{confirmLabel:`Delete ${N.toString()} matching?`,onConfirm:u,testId:"db-bulk-delete",children:`Delete ${N.toString()} matching`}),e[30]=o,e[31]=r,e[32]=u,e[33]=N,e[34]=B):B=e[34];let J;e[35]!==o||e[36]!==r||e[37]!==p||e[38]!==C||e[39]!==N?(J=o&&N>0&&r&&d("button",{className:De,"data-testid":"db-bulk-patch",onClick:p,type:"button",children:C("Set column on {total} matching",{total:N.toString()})}),e[35]=o,e[36]=r,e[37]=p,e[38]=C,e[39]=N,e[40]=J):J=e[40];let G;e[41]!==o||e[42]!==r||e[43]!==f||e[44]!==N?(G=o&&N>0&&!r&&d(Lt,{confirmLabel:`Clear all ${N.toString()} rows?`,onConfirm:f,testId:"db-clear-table",children:`Clear table (${N.toString()})`}),e[41]=o,e[42]=r,e[43]=f,e[44]=N,e[45]=G):G=e[45];let X;e[46]!==j||e[47]!==q||e[48]!==M||e[49]!==B||e[50]!==J||e[51]!==G||e[52]!==k||e[53]!==R||e[54]!==P?(X=E("div",{className:"flex flex-wrap items-center gap-1.5",children:[k,R,P,j,q,M,B,J,G]}),e[46]=j,e[47]=q,e[48]=M,e[49]=B,e[50]=J,e[51]=G,e[52]=k,e[53]=R,e[54]=P,e[55]=X):X=e[55];let Q;e[56]!==n||e[57]!==t||e[58]!==c||e[59]!==b||e[60]!==g||e[61]!==h?(Q=d(eo,{columns:n,filters:c,onAskAi:b,onFiltersChange:h,onSearchChange:g,search:t}),e[56]=n,e[57]=t,e[58]=c,e[59]=b,e[60]=g,e[61]=h,e[62]=Q):Q=e[62];let Z;return e[63]!==X||e[64]!==Q?(Z=E("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[X,Q]}),e[63]=X,e[64]=Q,e[65]=Z):Z=e[65],Z},xs=s=>{const e=V(109),{assistant:n,backRelations:o,browser:t,columnMeta:c,edit:l,editable:r,onAskAiFilter:a,onInspect:i,onOpenBulkPatch:m,onOpenGenerateRows:u,onRowDelete:p,onSaveQuery:b,page:f,preferences:g,queryBar:h,references:x}=s,v=g.maskColumns.size>0,w=n.unavailable?void 0:a;let y;e[0]!==t.addRow||e[1]!==t.bulkDelete||e[2]!==t.clearTable||e[3]!==t.columns||e[4]!==t.filter||e[5]!==t.filters||e[6]!==t.hasPredicate||e[7]!==t.liveError||e[8]!==t.onFilterChange||e[9]!==t.onFiltersChange||e[10]!==t.showJson||e[11]!==t.showTable||e[12]!==t.total||e[13]!==t.viewMode||e[14]!==r||e[15]!==m||e[16]!==u||e[17]!==g.maskOn||e[18]!==g.onToggleMask||e[19]!==v||e[20]!==w?(y=d(hs,{columns:t.columns,editable:r,filter:t.filter,filters:t.filters,hasMaskedColumns:v,hasPredicate:t.hasPredicate,liveError:t.liveError,maskOn:g.maskOn,onAddRow:t.addRow,onAskAiFilter:w,onBulkDelete:t.bulkDelete,onBulkPatch:m,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:u,onShowJson:t.showJson,onShowTable:t.showTable,onToggleMask:g.onToggleMask,total:t.total,viewMode:t.viewMode}),e[0]=t.addRow,e[1]=t.bulkDelete,e[2]=t.clearTable,e[3]=t.columns,e[4]=t.filter,e[5]=t.filters,e[6]=t.hasPredicate,e[7]=t.liveError,e[8]=t.onFilterChange,e[9]=t.onFiltersChange,e[10]=t.showJson,e[11]=t.showTable,e[12]=t.total,e[13]=t.viewMode,e[14]=r,e[15]=m,e[16]=u,e[17]=g.maskOn,e[18]=g.onToggleMask,e[19]=v,e[20]=w,e[21]=y):y=e[21];let N;e[22]!==b||e[23]!==h?(N=h!==void 0&&d(ss,{onApply:h.onApplyQuery,onCopyLink:h.onCopyLink,onDelete:h.onDeleteQuery,onSave:b,saved:h.saved}),e[22]=b,e[23]=h,e[24]=N):N=e[24];let T;e[25]!==o||e[26]!==t.onBulkDeleteSelected||e[27]!==t.selectedTable||e[28]!==t.table||e[29]!==t.viewMode||e[30]!==r||e[31]!==f||e[32]!==g.maskView||e[33]!==g.onToggleTranspose||e[34]!==g.transposed?(T=t.viewMode==="table"&&f.rows.length>0&&d(to,{backRelations:o.available,columns:f.columns,editable:r,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:g.onToggleTranspose,rows:vt(f.rows,g.maskView),table:t.table.table,transposed:g.transposed}),e[25]=o,e[26]=t.onBulkDeleteSelected,e[27]=t.selectedTable,e[28]=t.table,e[29]=t.viewMode,e[30]=r,e[31]=f,e[32]=g.maskView,e[33]=g.onToggleTranspose,e[34]=g.transposed,e[35]=T):T=e[35];let C;e[36]!==t.cancelEdit||e[37]!==t.editing||e[38]!==t.saveEdit||e[39]!==t.setEditorDocumentText||e[40]!==c||e[41]!==r||e[42]!==f?(C=r&&t.editing!==null&&d(ps,{columnMeta:c,documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:f.refs}),e[36]=t.cancelEdit,e[37]=t.editing,e[38]=t.saveEdit,e[39]=t.setEditorDocumentText,e[40]=c,e[41]=r,e[42]=f,e[43]=C):C=e[43];let S;e[44]!==t.committing||e[45]!==t.discardStaged||e[46]!==t.onCommitStaged||e[47]!==t.stagedChanges||e[48]!==r?(S=r&&t.stagedChanges.length>0&&d(Co,{changes:t.stagedChanges,committing:t.committing,onCommit:t.onCommitStaged,onDiscard:t.discardStaged}),e[44]=t.committing,e[45]=t.discardStaged,e[46]=t.onCommitStaged,e[47]=t.stagedChanges,e[48]=r,e[49]=S):S=e[49];let k;e[50]!==t.writeError?(k=t.writeError!==null&&d("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:t.writeError}),e[50]=t.writeError,e[51]=k):k=e[51];let O;e[52]!==t.writeNotice?(O=t.writeNotice!==null&&d("p",{className:"text-sm text-muted-foreground","data-testid":"db-write-notice",role:"status",children:t.writeNotice}),e[52]=t.writeNotice,e[53]=O):O=e[53];let R;e[54]!==y||e[55]!==N||e[56]!==T||e[57]!==C||e[58]!==S||e[59]!==k||e[60]!==O?(R=E("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[y,N,T,C,S,k,O]}),e[54]=y,e[55]=N,e[56]=T,e[57]=C,e[58]=S,e[59]=k,e[60]=O,e[61]=R):R=e[61];let _;e[62]!==t.viewMode||e[63]!==f?(_=t.viewMode==="table"&&f.rows.length===0&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d(Kn,{description:"Rows you insert into this table will show up here.",icon:d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[62]=t.viewMode,e[63]=f,e[64]=_):_=e[64];let D;e[65]!==t.viewMode||e[66]!==f||e[67]!==g.maskView||e[68]!==g.transposed?(D=t.viewMode==="table"&&f.rows.length>0&&g.transposed&&d(Zn,{columns:f.columns,rows:vt(f.rows,g.maskView)}),e[65]=t.viewMode,e[66]=f,e[67]=g.maskView,e[68]=g.transposed,e[69]=D):D=e[69];let A;e[70]!==o||e[71]!==t.filter||e[72]!==t.onRowEdit||e[73]!==t.table||e[74]!==t.viewMode||e[75]!==c||e[76]!==l||e[77]!==r||e[78]!==i||e[79]!==p||e[80]!==f||e[81]!==g.maskView||e[82]!==g.onTogglePin||e[83]!==g.pinnedColumns||e[84]!==g.transposed||e[85]!==x?(A=t.viewMode==="table"&&f.rows.length>0&&!g.transposed&&d(Uo,{backRelationCounts:o.counts,columnMeta:c,edit:l,editable:r,highlight:t.filter,mask:g.maskView,onDelete:p,onEdit:t.onRowEdit,onInspect:i,onTogglePin:g.onTogglePin,pinnedColumns:g.pinnedColumns,refs:x,tableModel:t.table}),e[70]=o,e[71]=t.filter,e[72]=t.onRowEdit,e[73]=t.table,e[74]=t.viewMode,e[75]=c,e[76]=l,e[77]=r,e[78]=i,e[79]=p,e[80]=f,e[81]=g.maskView,e[82]=g.onTogglePin,e[83]=g.pinnedColumns,e[84]=g.transposed,e[85]=x,e[86]=A):A=e[86];let L;e[87]!==t.viewMode||e[88]!==f||e[89]!==g.maskView?(L=t.viewMode==="json"&&d("pre",{className:"min-h-0 flex-1 overflow-auto border-t border-border bg-muted/30 p-3 text-xs","data-testid":"db-json",children:JSON.stringify(vt(f.rows,g.maskView),Qt,2)}),e[87]=t.viewMode,e[88]=f,e[89]=g.maskView,e[90]=L):L=e[90];let P;e[91]!==t.changePageSize||e[92]!==t.goNext||e[93]!==t.goPrevious||e[94]!==t.hasNext||e[95]!==t.hasPrevious||e[96]!==t.jumpToPage||e[97]!==t.pageSize||e[98]!==t.rangeEnd||e[99]!==t.rangeStart||e[100]!==t.total?(P=d("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:d(Ln,{hasNext:t.hasNext,hasPrevious:t.hasPrevious,onJumpToPage:t.jumpToPage,onNext:t.goNext,onPageSizeChange:t.changePageSize,onPrevious:t.goPrevious,pageSize:t.pageSize,prefix:"db",rangeEnd:t.rangeEnd,rangeStart:t.rangeStart,total:t.total})}),e[91]=t.changePageSize,e[92]=t.goNext,e[93]=t.goPrevious,e[94]=t.hasNext,e[95]=t.hasPrevious,e[96]=t.jumpToPage,e[97]=t.pageSize,e[98]=t.rangeEnd,e[99]=t.rangeStart,e[100]=t.total,e[101]=P):P=e[101];let j;return e[102]!==R||e[103]!==_||e[104]!==D||e[105]!==A||e[106]!==L||e[107]!==P?(j=E("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[R,_,D,A,L,P]}),e[102]=R,e[103]=_,e[104]=D,e[105]=A,e[106]=L,e[107]=P,e[108]=j):j=e[108],j},vs="/__lunora/seed",St=200,ws=50,ys=(s,e)=>{const n=[];for(const o of s)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},Cs=s=>Array.isArray(s)&&s.every(e=>Xt(e)),Ns=async s=>{let e;try{e=await fetch(vs,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"})}catch(o){return{kind:"error",message:`seed request failed: ${Ot(o)}`}}let n;try{n=await e.json()??{}}catch{return{kind:"error",message:`seed request failed (${String(e.status)})`}}if(e.ok&&n.rows!==void 0){let o;try{o=Rt(n.rows)}catch(t){return{kind:"error",message:`seed response could not be decoded: ${Ot(t)}`}}return Cs(o)?{kind:"ok",rows:o}:{kind:"error",message:"seed response did not carry a list of row documents"}}return n.error==="fk-parents-empty"?{kind:"error",message:`no rows to reference in ${(Array.isArray(n.tables)?n.tables.filter(t=>typeof t=="string"):[]).join(", ")} — seed those tables first`}:{kind:"error",message:typeof n.error=="string"?n.error:`seed request failed (${String(e.status)})`}},Ss="rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",ks="rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",Ts=({columns:s,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const c=he(),[l,r]=$(10),[a,i]=$(!1),[m,u]=$(void 0),[p,b]=$(void 0),[f,g]=$(0),h=N=>{const T=Number(N.target.value);!Number.isNaN(T)&&T>=1&&r(Math.min(T,St))},x=async()=>{u(void 0),b(void 0),g(0),i(!0);try{const N=await Ns({count:l,existingIds:e,seed:Date.now(),table:t});if(N.kind==="error"){u(N.message);return}const{rows:T}=N;if(T.length===0){u(c("No rows generated — all columns were skipped."));return}const C=await o(T);if(C.error!==void 0){u(C.error);return}b(C.inserted),g(C.conflicts)}finally{i(!1)}},v=()=>{Ce(x())},w=s.filter(N=>N.pk!==!0),y=ys(s,e);return E(dt,{label:c("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[E("div",{className:"flex items-start justify-between",children:[E("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:c("Generate dummy rows")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:c("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:t})})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:c("Close")})]}),E("div",{className:"flex items-center gap-2",children:[d("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:c("Row count")}),d("input",{className:"w-20 rounded-md border border-border bg-background px-2 py-1 text-xs outline-none focus-visible:border-ring","data-testid":"gen-rows-count",id:"gen-rows-count",max:St,min:1,onChange:h,type:"number",value:l}),d("span",{className:"text-xs text-muted-foreground",children:c("(max {max})",{max:St.toString()})})]}),w.length>0&&E("div",{className:"flex flex-col gap-1",children:[d("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c("Columns to seed")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:w.map(N=>{const T=N.ref!==void 0&&N.type==="id",C=T&&(e[N.ref??""]??[]).length===0,S=C?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",k=C?`gen-rows-fk-empty-${N.name}`:`gen-rows-fk-ok-${N.name}`,O=C?c("FK: no rows in {ref} — seed it first",{ref:N.ref??""}):c("→ {ref}",{ref:N.ref??""});return E("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[d("span",{className:"text-foreground",children:N.name}),E("span",{className:"text-muted-foreground",children:["(",N.type,")"]}),N.optional&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),T&&d("span",{className:S,"data-testid":k,children:O})]},N.name)})})]}),y.length>0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-blocked",role:"alert",children:c("Cannot generate rows: these columns reference tables with no rows: {cols}. Seed those tables first.",{cols:y.join(", ")})}),m!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:m}),p!==void 0&&m===void 0&&d("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:f>0?c("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:f.toString(),inserted:p.toString(),total:(p+f).toString()}):c("Inserted {count} rows successfully.",{count:p.toString()})}),E("div",{className:"flex justify-end gap-2",children:[d("button",{className:Ss,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:c("Cancel")}),d("button",{className:ks,"data-testid":"gen-rows-generate",disabled:a||y.length>0,onClick:v,type:"button",children:c(a?"Inserting…":"Generate & insert")})]})]})},Es=Te(pe.backRelationCounts),_s=(s,e,n,o)=>{const t=V(16),c=ct();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},t[0]=l):l=t[0];const[r,a]=$(l);let i;if(t[1]!==s||t[2]!==e){let x;t[4]!==s?(x=v=>s.has(Dt(v)),t[4]=s,t[5]=x):x=t[5],i=e.filter(x),t[1]=s,t[2]=e,t[3]=i}else i=t[3];const m=i;let u;t[6]!==n||t[7]!==m?(u=JSON.stringify([m,n]),t[6]=n,t[7]=m,t[8]=u):u=t[8];const p=u;let b;t[9]!==c||t[10]!==o||t[11]!==p?(b=async x=>{const[v,w]=JSON.parse(p);if(v.length===0||w.length===0){x.cancelled||a({});return}try{const y=await c.query(Es,{ids:w,relations:v},ke(o));x.cancelled||a(Object.fromEntries(y.relations.map(Rs)))}catch{}},t[9]=c,t[10]=o,t[11]=p,t[12]=b):b=t[12];const f=b;let g,h;return t[13]!==f?(g=()=>{const x={cancelled:!1};return Ce(f(x)),()=>{x.cancelled=!0}},h=[f],t[13]=f,t[14]=g,t[15]=h):(g=t[14],h=t[15]),Ve(g,h),r};function Rs(s){return[Dt(s),s.counts]}const $s=async s=>{const{args:e,maxBatches:n,openCursor:o,query:t}=s;let c=o,l=0,r="cap-hit";for(let a=0;a<n;a+=1){const i=await t({...e,after:c});if(l+=i.count,c=i.cursor,!i.hasMore){r="completed";break}}return{cursor:r==="cap-hit"?c:void 0,outcome:r,written:l}},rt=s=>{const e=s[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},an=s=>s==null?"":typeof s=="object"?JSON.stringify(s):String(s),Jt=s=>s.map(e=>({column:e.column,operator:e.operator,value:e.value===void 0?"":an(e.value)})),Wt=s=>s===void 0?[]:[{desc:s.direction==="desc",id:s.column}],Ds=s=>[s.column,s.operator,s.value],st=(s,e,n,o)=>JSON.stringify([s??"",e??"",(n??[]).map(t=>Ds(t)),o===void 0?null:[o.column,o.direction]]),It=200,As=20,Is=Te(pe.readTablePage),Ps=Te(pe.facetColumn),kt=Te(pe.writeRow),Os=Te(pe.deleteRows),Ms=Te(pe.clearTable),Ls=Te(pe.patchRows),Fs={},Pt=new Set(["__doc__","__id__","_creationTime","_id","id"]),Bs=s=>{const e=s.__doc__;if(typeof e=="string"){const o=qn(e);if(o!==void 0)return o}const n={};for(const[o,t]of Object.entries(s))Pt.has(o)||(n[o]=t);return n},Vs=(s,e,n)=>JSON.stringify([s.__lunoraRef,n,Zt(e)]),js=({filters:s,offset:e,pageSize:n,search:o,sorting:t,table:c})=>({filters:Oe(s),limit:n,offset:e,orderBy:rt(t),search:o,skipCount:!0,table:c}),zs=({filters:s,search:e,table:n})=>({filters:Oe(s),limit:1,search:e,table:n}),qs=(s,e)=>{const n=new Map;for(const t of s?.rows??[]){const c=Ae(t);c!==null&&n.set(c,t)}const o=[];for(const[t,c]of Object.entries(e))for(const[l,r]of Object.entries(c))o.push({column:l,newValue:r,oldValue:n.get(t)?.[l],rowId:t});return o},Gs=s=>!Pt.has(s),Ks=`Stopped after ${It.toString()} batches — rows still match. Run it again to remove the rest.`,Js=`Stopped after ${It.toString()} batches — rows still match. Run it again to set the rest.`,Ht={resumable:!1,truncated:Ks,verb:"deleted"},Ws={resumable:!0,truncated:Js,verb:"written"},Hs=({initialFilters:s,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:c,pageSize:l,resolveBackRelations:r,tableParam:a})=>{const i=ct(),[m,u]=$(l),[p,b]=$(o??""),f=a===void 0||a===""?null:a,[g,h]=$(0),[x,v]=$("table"),[w,y]=$(()=>Wt(e)),[N,T]=$(n??""),[C,S]=$(()=>Jt(s??[])),{clearFacets:k,facets:O,refetchFacets:R,toggleFacet:_}=Fn(),[D,A]=$(null),[L,P]=$(null),[j,q]=$(null),M=Je(null),B=yo(),[J,G]=$(null),[X,Q]=$(!1),[Z,fe]=$(a),[ne,ce]=$(()=>st(o,n,s,e)),[de,me]=$(0),[le,ue]=$(()=>st(o,n,s,e)),re=a!==Z,Y=st(o,n,s,e),te=re||!re&&Y!==ne&&Y!==le;if(te){fe(a),ce(Y),me(z=>z+1),y(Wt(e)),T(n??"");const I=Jt(s??[]);S(I),b(o??""),k(),B.clear(),G(null),h(0),P(null),q(null),M.current=null}else Y!==ne&&ce(Y);const xe=te?n??"":N,ae=te?o??"":p,ie=`${a??""}:${de.toString()}`,W=Ft(xe.trim(),300,ie),K=Ft(ae.trim(),400,ie),ee=st(K,W,Oe(C),rt(w));ee!==le&&ue(ee);const H=Xe(pe.listTables,Fs,{live:!0,shardKey:K}),ve=H.data??null,ge=H.error,we=js({filters:C,offset:g,pageSize:m,search:W,sorting:w,table:f??""}),ye=zs({filters:C,search:W,table:f??""}),U=Xe(pe.readTablePage,we,{enabled:f!==null,keepPreviousData:!1,live:!0,shardKey:K}),oe=U.data??null,Me=U.error,{liveError:Ie}=U,Pe=Xe(pe.readTablePage,ye,{enabled:f!==null,live:!0,shardKey:K});Ve(()=>{H.data!==void 0&&oo(K)},[H.data,K]);const He=I=>{t?.(I)},Se=(I,z)=>{t?.(I,{search:z})},ze=async(I,z)=>{try{return(await i.query(Is,{filters:[],limit:As,offset:0,search:z,table:I},ke(K))).rows.find(_e=>Ae(_e)===z)??null}catch{return null}},Le=(I,z,Ne,_e)=>$e=>i.query(Ps,{column:$e,filters:Oe(Ne),search:_e,table:z},ke(I)),Ue=I=>{_(I,f===null?null:Le(K,f,C,W))},ut=(I,z)=>{const Ne=an(z);S(_e=>[..._e.filter($e=>$e.column!==I),{column:I,operator:"eq",value:Ne}]),h(0)},ft=wt(Le),et=wt(R),tt=wt(c);Ve(()=>{f!==null&&et.current(ft.current(K,f,C,W))},[K,f,C,W]),Ve(()=>{f===null||tt.current===void 0||Z!==a||ne!==Y||tt.current({filters:Oe(C),orderBy:rt(w),search:W,shard:K})},[f,a,Z,ne,Y,C,w,W,K]);const Qe=I=>{f!==null&&h(Math.max(0,I))},nt=(I,z)=>{G({column:z,rowId:I})},mt=()=>{G(null)},gt=async()=>{if(f!==null){P(null),Q(!0);try{for(const[I,z]of Object.entries(B.staged))await i.query(kt,{doc:z,id:I,op:"patch",table:f},ke(K)),B.drop(I,z)}catch(I){P(I.message)}G(null),U.refetch(),Q(!1)}},pt=()=>{B.clear(),G(null)},bt=qs(oe,B.staged),ot=async(I,z,Ne)=>{if(f===null)return;P(null);let _e;if(I!=="delete"){let $e;try{$e=Ne===void 0||Ne.trim()===""?{}:JSON.parse(Ne)}catch(Be){P(`Invalid JSON: ${Be.message}`);return}try{const Be=Rt($e);if(!Xt(Be)){P("The document must be a JSON object.");return}_e=Be}catch(Be){P(`Invalid document: ${Be.message}`);return}}try{await i.query(kt,{doc:_e,id:z??void 0,op:I,table:f},ke(K)),A(null),U.refetch()}catch($e){P($e.message)}},Ye=async(I,z,Ne)=>{if(f===null)return 0;P(null),q(null);const _e=Vs(I,z,K),$e=M.current?.key===_e?M.current.after:void 0,Be=Ne.resumable?$e??"":void 0;let qe=0;try{const Ge=await $s({args:z,maxBatches:It,openCursor:Be,query:async In=>await i.query(I,In,ke(K))});return qe=Ge.written,M.current=Ge.cursor===void 0?null:{after:Ge.cursor,key:_e},Ge.outcome==="cap-hit"&&P(Ne.truncated),q(`${qe.toString()} ${qe===1?"row":"rows"} ${Ne.verb}.`),qe}catch(Ge){return P(`${Ge.message} (at least ${qe.toString()} rows were already ${Ne.verb})`),M.current=null,qe}finally{h(0),U.refetch()}},ht=I=>{y(I),h(0)},F=Tt(()=>f===null?[]:r?.(f)??[],[r,f]),se=Qo(oe,w,ht,F),Ee={filters:Oe(C),orderBy:rt(w),search:W,shard:p,table:f??void 0},Re=Pe.data?.total??(oe===null?0:g+oe.rows.length),Fe=g>0,xt=W!==""||Oe(C).length>0,cn=oe!==null&&g+oe.rows.length<Re,dn=oe===null||oe.rows.length===0?0:g+1,un=oe===null?0:g+oe.rows.length,fn=()=>{H.refetch()},mn=()=>{v("table")},gn=()=>{v("json")},pn=()=>{Ce(Ye(Os,{filters:Oe(C),search:W,table:f},Ht))},bn=()=>{Ce(Ye(Ms,{table:f},Ht))},hn=I=>{Ce(Ye(Ls,{doc:I,filters:Oe(C),search:W,table:f},Ws))},xn=I=>{T(I.target.value),h(0)},vn=I=>{S(I),h(0)},wn=()=>{P(null);const I={};for(const z of oe?.columns??[])Pt.has(z)||(I[z]="");A({docText:JSON.stringify(I,null,2),id:""})},yn=I=>{A(z=>z===null?z:{docText:I,id:z.id})},Cn=()=>{D!==null&&Ce(ot(D.id===""?"insert":"patch",D.id===""?null:D.id,D.docText))},Nn=()=>{A(null),P(null)},Sn=()=>{Qe(g-m)},kn=()=>{Qe(g+m)},Tn=I=>{Qe(Math.max(0,(I-1)*m))},En=I=>{u(I),h(0)},_n=(I,z)=>{P(null),A({docText:JSON.stringify(Zt(Bs(z)),null,2),id:I})},Rn=I=>{Ce(ot("delete",I))},$n=async I=>{if(!(f===null||I.length===0)){P(null);try{for(const z of I)await i.query(kt,{id:z,op:"delete",table:f},ke(K));U.refetch()}catch(z){P(z.message)}}},Dn=I=>{Ce($n(I))},An=()=>{Ce(gt())};return{addRow:wn,bulkDelete:pn,bulkPatch:hn,cancelCellEdit:mt,cancelEdit:Nn,changePageSize:En,clearTable:bn,columns:oe?.columns??[],committing:X,currentView:Ee,discardStaged:pt,editableColumn:Gs,editing:D,editingCell:J,facetFilter:ut,facets:O,filter:N,filters:C,goNext:kn,goPrevious:Sn,hasNext:cn,hasPredicate:xt,hasPrevious:Fe,jumpToPage:Tn,liveError:Ie,loadTables:fn,navigateToRef:Se,onBulkDeleteSelected:Dn,onCommitStaged:An,onFilterChange:xn,onFiltersChange:vn,onRowDelete:Rn,onRowEdit:_n,page:oe,previewRef:ze,pageError:Me,pageSize:m,rangeEnd:un,rangeStart:dn,queryShardKey:K,saveEdit:Cn,selectedTable:f,selectTable:He,setEditorDocumentText:yn,setShardKey:b,shardKey:p,showJson:gn,showTable:mn,stage:B.stage,stagedChanges:bt,stagedValue:B.stagedValue,startCellEdit:nt,table:se,tables:ve,tablesError:ge,toggleFacet:Ue,total:Re,viewMode:x,writeError:L,writeNotice:j}},Us="lunora-studio-pinned-columns",Qs=s=>{const e=V(21),{columns:n,initialPins:o,selectedTable:t}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];const[l,r]=Ut(Us,c),a=t??"",i=l[a];let m;e[1]!==o||e[2]!==i?(m=i===void 0?new Set((o??"").split(",").filter(Ys)):new Set(i),e[1]=o,e[2]=i,e[3]=m):m=e[3];const u=m;let p;e[4]!==a||e[5]!==u||e[6]!==r?(p=k=>{r(O=>{const R=O[a]??[...u],_=R.includes(k)?R.filter(D=>D!==k):[...R,k];return{...O,[a]:_}})},e[4]=a,e[5]=u,e[6]=r,e[7]=p):p=e[7];const b=p,[f,g]=$(!1);let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{g(Xs)},e[8]=h):h=e[8];const x=h;let v;e[9]!==n||e[10]!==t?(v={columns:n,selectedTable:t},e[9]=n,e[10]=t,e[11]=v):v=e[11];const{maskColumns:w,maskOn:y,maskView:N,maskViewFor:T,onToggleMask:C}=Bn(v);let S;return e[12]!==w||e[13]!==y||e[14]!==N||e[15]!==T||e[16]!==C||e[17]!==b||e[18]!==u||e[19]!==f?(S={maskColumns:w,maskOn:y,maskView:N,maskViewFor:T,onToggleMask:C,onTogglePin:b,onToggleTranspose:x,pinnedColumns:u,transposed:f},e[12]=w,e[13]=y,e[14]=N,e[15]=T,e[16]=C,e[17]=b,e[18]=u,e[19]=f,e[20]=S):S=e[20],S};function Ys(s){return s!==""}function Xs(s){return!s}const Zs=Te(pe.describeTable),el=Te(pe.readTablePage),tl=Te(pe.importShard),nl=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},ol=s=>{const e=Object.values(s.inserted).reduce((a,i)=>a+i,0),[n]=s.errors;if(n===void 0)return{conflicts:s.conflicts,error:void 0,inserted:e};const o=s.errors.length-1,t=e+s.conflicts+s.errors.length,c=o===1?"error":"errors",l=o>0?` (+${o.toString()} more ${c})`:"",r=`Inserted ${e.toString()} of ${t.toString()} rows — row ${n.line.toString()} (${n.table}): ${n.message}${l}`;return{conflicts:s.conflicts,error:r,inserted:e}},sl=s=>{const e=ct(),[n,o]=$(!1),[t,c]=$(void 0),[l,r]=$(void 0),[a,i]=$(void 0),[m,u]=$({}),[p,b]=$(!1),[f,g]=$(void 0),h=async(y,N)=>{o(!0),c(y),r(N),i(void 0),u({}),g(void 0),b(!0);try{const T=await e.query(Zs,{table:y},ke(N)),{columns:C}=T;i(C);const S={},k=C.filter(O=>O.ref!==void 0&&O.type==="id"&&O.pk!==!0);for(const O of k){if(O.ref===void 0)continue;const{ref:R}=O;if(S[R]===void 0)try{const _=await e.query(el,{filters:[],limit:ws,offset:0,search:"",table:R},ke(N));S[R]=_.rows.flatMap(D=>nl(D)||[])}catch{S[R]=[]}}u(S)}catch(T){g(T.message)}b(!1)};return{closeDialog:()=>{o(!1),c(void 0),r(void 0),i(void 0),u({}),g(void 0)},columnMeta:a,error:f,fkPools:m,insertBatch:async(y,N)=>{if(t===void 0||l===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const T=await e.query(tl,{rows:y.map(S=>({doc:S,table:t}))},ke(l)),C=ol(T);return C.error!==void 0||(N(),s()),C}catch(T){return{conflicts:0,error:T.message,inserted:0}}},loading:p,open:n,openDialog:(y,N)=>{Ce(h(y,N))},shardKey:l,table:t}},ll=()=>{const s=V(6),[e,n]=$(null);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{n(null)},s[0]=o):o=s[0];const t=o,[c,l]=$(null);let r;s[1]===Symbol.for("react.memo_cache_sentinel")?(r=(p,b)=>{l({column:p,value:b})},s[1]=r):r=s[1];const a=r;let i;s[2]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{l(null)},s[2]=i):i=s[2];const m=i;let u;return s[3]!==c||s[4]!==e?(u={closeExpandedCell:m,closeInspect:t,expandedCell:c,inspecting:e,onExpandCell:a,onInspect:n},s[3]=c,s[4]=e,s[5]=u):u=s[5],u},rl=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,al=(s,e)=>typeof e=="number"&&rl.test(s),il=s=>{const e=V(36),{column:n,masked:o,onNavigate:t,target:c,value:l}=s;let r;e[0]!==t||e[1]!==c||e[2]!==l?(r=()=>{c!==void 0&&t(c,String(l))},e[0]=t,e[1]=c,e[2]=l,e[3]=r):r=e[3];const a=r;if(l==null){let u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(u=d("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=u):u=e[4],u}if(o){const u=`rd-masked-${n}`;let p;e[5]!==l?(p=je(l),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==u||e[8]!==p?(b=d("span",{className:"italic text-muted-foreground","data-testid":u,title:"Masked (preview)",children:p}),e[7]=u,e[8]=p,e[9]=b):b=e[9],b}if(c!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const u=`rd-ref-${n}`,p=`Open ${c} ${String(l)}`,b=String(l);let f;return e[10]!==a||e[11]!==u||e[12]!==p||e[13]!==b?(f=E("button",{"data-testid":u,onClick:a,title:p,type:"button",children:[b," ↗"]}),e[10]=a,e[11]=u,e[12]=p,e[13]=b,e[14]=f):f=e[14],f}if(al(n,l)){const u=`rd-ts-${n}`;let p;e[15]!==l?(p=l.toString(),e[15]=l,e[16]=p):p=e[16];let b;e[17]!==l?(b=On(l),e[17]=l,e[18]=b):b=e[18];let f;return e[19]!==u||e[20]!==p||e[21]!==b?(f=d("span",{"data-testid":u,title:p,children:b}),e[19]=u,e[20]=p,e[21]=b,e[22]=f):f=e[22],f}if(l instanceof ArrayBuffer||ArrayBuffer.isView(l)){const u=`rd-bytes-${n}`;let p;e[23]!==l?(p=je(l),e[23]=l,e[24]=p):p=e[24];let b;return e[25]!==u||e[26]!==p?(b=d("span",{"data-testid":u,children:p}),e[25]=u,e[26]=p,e[27]=b):b=e[27],b}if(typeof l=="object"){let u;e[28]!==l?(u=JSON.stringify(l,Qt,2),e[28]=l,e[29]=u):u=e[29];let p;return e[30]!==u?(p=d("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:u}),e[30]=u,e[31]=p):p=e[31],p}let i;e[32]!==l?(i=je(l),e[32]=l,e[33]=i):i=e[33];let m;return e[34]!==i?(m=d("span",{children:i}),e[34]=i,e[35]=m):m=e[35],m},cl=s=>{const e=V(23),{columns:n,mask:o,onClose:t,onNavigate:c,refs:l,row:r}=s;let a;e[0]!==t||e[1]!==c?(a=(g,h)=>{c(g,h),t()},e[0]=t,e[1]=c,e[2]=a):a=e[2];const i=a;let m;e[3]===Symbol.for("react.memo_cache_sentinel")?(m=d("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=m):m=e[3];let u;e[4]!==t?(u=E("div",{className:"mb-3 flex items-center justify-between",children:[m,d("button",{"data-testid":"rd-close",onClick:t,type:"button",children:"Close"})]}),e[4]=t,e[5]=u):u=e[5];let p;if(e[6]!==n||e[7]!==o||e[8]!==i||e[9]!==l||e[10]!==r){let g;e[12]!==o||e[13]!==i||e[14]!==l||e[15]!==r?(g=h=>E("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${h}`,children:[d("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:h}),d("dd",{className:"m-0",children:d(il,{column:h,masked:o.enabled&&o.columns.has(h),onNavigate:i,target:l?.[h],value:r[h]})})]},h),e[12]=o,e[13]=i,e[14]=l,e[15]=r,e[16]=g):g=e[16],p=n.map(g),e[6]=n,e[7]=o,e[8]=i,e[9]=l,e[10]=r,e[11]=p}else p=e[11];let b;e[17]!==p?(b=d("dl",{"data-testid":"rd-fields",children:p}),e[17]=p,e[18]=b):b=e[18];let f;return e[19]!==t||e[20]!==u||e[21]!==b?(f=E(dt,{label:"Row detail",onClose:t,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[u,b]}),e[19]=t,e[20]=u,e[21]=b,e[22]=f):f=e[22],f},dl=50,ul=s=>{const e=V(8),{active:n,onPick:o,shard:t}=s;let c;e[0]!==o||e[1]!==t?(c=()=>{o(t)},e[0]=o,e[1]=t,e[2]=c):c=e[2];const l=c,r=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,a=`shard-explorer-item-${t}`;let i;return e[3]!==l||e[4]!==t||e[5]!==r||e[6]!==a?(i=d("button",{className:r,"data-testid":a,onClick:l,type:"button",children:t}),e[3]=l,e[4]=t,e[5]=r,e[6]=a,e[7]=i):i=e[7],i},fl=({onFetchTables:s,onSelect:e})=>{const n=he(),[o]=$(()=>so()),[t,c]=$(!1),[l,r]=$(void 0),[a,i]=$(void 0),[m,u]=$(!1),[p,b]=$(void 0),f=Je(0),g=()=>{c(v=>!v)},h=async v=>{e(v),r(v),i(void 0),b(void 0),u(!0),f.current+=1;const w=f.current;try{const y=await s(v);f.current===w&&i(y?.slice(0,dl))}catch(y){f.current===w&&b(y.message)}f.current===w&&u(!1)},x=v=>{Ce(h(v))};return o.length===0?null:E("div",{"data-testid":"shard-explorer",children:[E("button",{"aria-controls":"shard-explorer-panel","aria-expanded":t,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"shard-explorer-toggle",onClick:g,type:"button",children:[n("Shards seen"),d("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${t?"rotate-180":""}`,children:"▾"})]}),t&&E("div",{className:"mt-1 flex flex-col gap-1 rounded-md border border-border bg-popover p-2","data-testid":"shard-explorer-panel",id:"shard-explorer-panel",children:[d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards — click to switch")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(v=>d("li",{children:d(ul,{active:l===v,onPick:x,shard:v})},v))}),l!==void 0&&E("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[d("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:l})}),m&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading…")}),p!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:p}),!m&&p===void 0&&a?.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!m&&p===void 0&&a!==void 0&&a.length>0&&d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:a.map(v=>E("li",{className:"flex items-center justify-between text-xs",children:[d("span",{"data-testid":`shard-explorer-table-${v.name}`,children:v.name}),d("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${v.name}`,children:v.rowCount})]},v.name))})]})]})]})},ml="lunora-studio-back-relations",gl=s=>new Set((s??[]).filter(e=>e.unique===!0&&e.fields.length===1).map(e=>e.fields[0]??"")),pl={},bl=50,hl=[],xl=Te(pe.listTables),vl=Te(pe.readTablePage),wl=s=>{const e=V(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:c}=s;let l;e[0]!==o||e[1]!==c?(l=d(Pn,{onChange:o,testId:"db-shard-input",value:c}),e[0]=o,e[1]=c,e[2]=l):l=e[2];let r;e[3]!==n||e[4]!==o?(r=d(fl,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=r):r=e[5];let a;return e[6]!==t||e[7]!==l||e[8]!==r?(a=E("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[t,l,r]}),e[6]=t,e[7]=l,e[8]=r,e[9]=a):a=e[9],a},Yl=({editable:s=!1,globalTableNames:e,initialFilters:n,initialOrderBy:o,initialPins:t,initialSearch:c,initialShardKey:l,onNavigateToGlobal:r,onSelectTable:a,onViewChange:i,pageSize:m=bl,queryBar:u,schemaSwitch:p,tableParam:b})=>{const f=Xe(pe.describeTables,{},{shardKey:l??""}),g=Xe(pe.listTablesIndexes,{},{shardKey:l??""}),h=f.data?.columnsByTable??pl,[x,v]=Ut(ml,{}),w=at(F=>{const se=new Set(x[F]);return Bt(F,h).filter(Ee=>se.has(Dt(Ee)))},[x,h]),y=Hs({initialFilters:n,initialOrderBy:o,initialSearch:c,initialShardKey:l,onSelectTable:a,onViewChange:i,pageSize:m,resolveBackRelations:w,tableParam:b}),{cancelCellEdit:N,columns:T,currentView:C,editableColumn:S,editingCell:k,facetFilter:O,facets:R,loadTables:_,navigateToRef:D,onFiltersChange:A,page:L,pageError:P,previewRef:j,queryShardKey:q,selectedTable:M,selectTable:B,setShardKey:J,shardKey:G,stage:X,stagedValue:Q,startCellEdit:Z,tables:fe,tablesError:ne,toggleFacet:ce}=y,de=zn(G),me=F=>{Ce((async()=>{const Ee=await de.suggestFilter(F,M??"");Ee!==void 0&&A(Ee.map(Re=>{const Fe=Re.value,xt=typeof Fe=="string"||typeof Fe=="number"||typeof Fe=="boolean"?String(Fe):"";return{column:Re.column,operator:Re.operator,value:xt}}))})())},le=M===null?[]:Bt(M,h),ue=new Set(x[M??""]),re=[];for(const F of L?.rows??[]){const se=F._id??F.id;typeof se=="string"&&se!==""&&re.push(se)}const Y=_s(ue,le,re,q),be=F=>{v(se=>{const Ee=M??"",Re=se[Ee]??[];return{...se,[Ee]:Re.includes(F)?Re.filter(Fe=>Fe!==F):[...Re,F]}})},te=Qs({columns:T,initialPins:t,selectedTable:M}),xe=ll(),[ae,ie]=$(null),{closeExpandedCell:W,closeInspect:K,expandedCell:ee,inspecting:H,onExpandCell:ve}=xe,ge=ct(),we=Object.fromEntries((h[M??""]??[]).map(F=>[F.name,F])),ye=new Map;for(const F of h[M??""]??[])F.isStorage===!0&&ye.set(F.name,F.bucket);const U=at(async(F,se)=>ge.signedStorageUrl(F,se===void 0?{}:{bucket:se}),[ge]),oe=async F=>await ge.query(xl,{},ke(F)),Me=()=>{M!==null&&B(M)},{closeDialog:Ie,columnMeta:Pe,fkPools:He,insertBatch:Se,open:ze,openDialog:Le}=sl(Me),Ue=()=>{M!==null&&Le(M,G)},ut=F=>Se(F,Ie),[ft,et]=$(!1),tt=()=>{et(!0)},Qe=()=>{et(!1)},nt=(F,se)=>{if(r!==void 0&&e?.has(F)===!0){r(F,se);return}D(F,se)},mt=u?.onSaveQuery,gt=F=>{mt?.(F,C)},pt={cancelEdit:N,editable:s,editableColumn:S,editingCell:k,onExpandCell:ve,stage:X,stagedValue:Q,startEdit:Z},bt=F=>{F!==null&&ie(F)},ot=()=>{y.onRowDelete(ae)},Ye=async(F,se,Ee)=>await ge.query(vl,{filters:[{column:se,operator:"eq",value:Ee}],limit:lt,offset:0,orderBy:[],table:F},ke(q)),ht={columns:L?.refs,maskViewFor:te.maskViewFor,onNavigate:nt,onPreview:j};return E("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[d(Vn,{header:d(wl,{onFetchShardTables:oe,onShardChange:J,schemaSwitch:p,shardKey:G}),onReload:_,onSelect:B,prefix:"db",selected:M,tables:fe??hl}),E("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[ne!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:ne}),L===null&&P===null&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),P!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:P}),L!==null&&d(xs,{assistant:de,backRelations:{available:le,counts:Y,enabled:ue,onToggle:be},browser:y,columnMeta:we,edit:pt,editable:s,onAskAiFilter:me,onInspect:xe.onInspect,onOpenBulkPatch:tt,onOpenGenerateRows:Ue,onRowDelete:bt,onSaveQuery:gt,page:L,preferences:te,queryBar:u,references:ht})]}),L!==null&&d(jn,{columns:T,facets:R,mask:te.maskView,onFacetFilter:O,onToggleFacet:ce}),H!==null&&L!==null&&d(cl,{columns:L.columns,mask:te.maskView,onClose:K,onNavigate:nt,refs:L.refs,row:Yt(H,te.maskView)}),ae!==null&&M!==null&&d(xo,{onClose:()=>{ie(null)},onConfirm:ot,readPage:Ye,rowId:ae,schema:lo(h),table:M}),ee!==null&&d(no,{bucket:ye.get(ee.column),column:ee.column,onClose:W,resolveUrl:ye.has(ee.column)?U:void 0,value:ee.value}),ft&&M!==null&&d(io,{columns:y.columns.filter(F=>y.editableColumn(F)),onApply:y.bulkPatch,onClose:Qe,shardKey:y.queryShardKey,table:M,total:y.total,uniqueColumns:gl(g.data?.indexesByTable[M])}),ze&&M!==null&&Pe!==void 0&&d(Ts,{columns:Pe,fkPools:He,onClose:Ie,onInsertRows:ut,table:M})]})};export{Yl as DataBrowser};
@@ -0,0 +1 @@
1
+ const m=e=>{let t="";for(let o=0;o<e.length;o+=32768)t+=String.fromCharCode(...e.subarray(o,o+32768));return btoa(t)},l=e=>{const t=atob(e),y=new Uint8Array(t.length);for(let o=0;o<t.length;o+=1)y[o]=t.codePointAt(o)??0;return y},i="$lunora.wire$";const w="__proto__",g={BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int8Array,Int16Array,Int32Array,Uint8Array,Uint8ClampedArray,Uint16Array,Uint32Array},A={Error,EvalError,RangeError,ReferenceError,SyntaxError,TypeError,URIError},p=e=>{if(e===null||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype},u=(e,t=0)=>{if(t>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(e===void 0)return[i,"undefined"];if(e===null)return null;const y=typeof e;if(y==="bigint")return[i,"bigint",e.toString()];if(y==="number"){const r=e;return Number.isNaN(r)?[i,"nan"]:r===1/0?[i,"inf"]:r===-1/0?[i,"-inf"]:r}if(y!=="object")return e;if(e instanceof Date)return[i,"date",u(e.getTime(),t+1)];if(e instanceof Error){const r=e,n={};for(const s of Object.keys(r))r[s]!==void 0&&(n[s]=u(r[s],t+1));const c=[i,"error",r.name,r.message,n];return r.cause!==void 0&&c.push(u(r.cause,t+1)),c}if(e instanceof URL)return[i,"url",e.href];if(e instanceof Map)return[i,"map",[...e.entries()].map(([r,n])=>[u(r,t+1),u(n,t+1)])];if(e instanceof Set)return[i,"set",[...e].map(r=>u(r,t+1))];if(e instanceof ArrayBuffer)return[i,"bytes",m(new Uint8Array(e)),"ArrayBuffer"];if(ArrayBuffer.isView(e)){const r=e,n=r.constructor.name,c=new Uint8Array(r.buffer,r.byteOffset,r.byteLength);return n==="Uint8Array"?[i,"bytes",m(c)]:[i,"bytes",m(c),n]}if(Array.isArray(e)){const r=e.map(n=>u(n,t+1));return r.length>0&&r[0]===i?[i,"arr",r]:r}if(!p(e)){const r=e.constructor?.name??"value";throw new TypeError(`wire-codec: cannot encode a ${r} over the Lunora wire — only plain objects, arrays, and the supported built-ins (Date, Error, URL, Map, Set, ArrayBuffer/typed arrays, bigint) round-trip`)}const o=e,a={};for(const r of Object.keys(o)){const n=o[r];if(n===void 0)continue;const c=u(n,t+1);r===w?Object.defineProperty(a,r,{configurable:!0,enumerable:!0,value:c,writable:!0}):a[r]=c}return a},f=(e,t=0)=>{if(t>64)throw new RangeError("wire-codec: value nesting exceeds the 64-level limit");if(e===null||typeof e!="object")return e;if(Array.isArray(e)){if(e[0]===i)switch(e[1]){case"-inf":return-1/0;case"arr":return e[2].map(r=>f(r,t+1));case"bigint":{const r=e[2];if(typeof r!="string"||r.length>1024||!/^-?\d+$/.test(r))throw new RangeError("wire-codec: invalid or over-long bigint (max 1024 digits)");return BigInt(r)}case"date":{const r=f(e[2],t+1);if(typeof r!="number")throw new TypeError("wire-codec: malformed date — epoch must be a number");return new Date(r)}case"map":{const r=e[2];return new Map(r.map(n=>{if(!Array.isArray(n)||n.length!==2)throw new TypeError("wire-codec: malformed map entry — expected a [key, value] pair");return[f(n[0],t+1),f(n[1],t+1)]}))}case"set":return new Set(e[2].map(r=>f(r,t+1)));case"url":{const r=e[2];if(typeof r!="string")throw new TypeError("wire-codec: malformed url — href must be a string");return new URL(r)}case"error":{const r=e[2],n=e[3],c=(Object.hasOwn(A,r)?A[r]:void 0)??Error,s=new c(n);s.name!==r&&Object.defineProperty(s,"name",{configurable:!0,value:r,writable:!0});const b=f(e[4],t+1);if(b===null||typeof b!="object"||Array.isArray(b))throw new TypeError("wire-codec: malformed error — props must be an object");for(const d of Object.keys(b))d===w?Object.defineProperty(s,d,{configurable:!0,enumerable:!0,value:b[d],writable:!0}):s[d]=b[d];return e.length>5&&Object.defineProperty(s,"cause",{configurable:!0,value:f(e[5],t+1),writable:!0}),s}case"bytes":{const r=e[2];if(typeof r!="string")throw new TypeError("wire-codec: malformed bytes — payload must be a base64 string");const n=l(r),c=e[3]??"Uint8Array";if(c==="ArrayBuffer")return n.buffer.byteLength===n.byteLength?n.buffer:n.slice().buffer;const s=Object.hasOwn(g,c)?g[c]:void 0;return s?new s(n.slice().buffer):n}case"inf":return 1/0;case"nan":return Number.NaN;case"undefined":return;default:return e.map(r=>f(r,t+1))}return e.map(a=>f(a,t+1))}const y=e,o={};for(const a of Object.keys(y)){const r=f(y[a],t+1);a===w?Object.defineProperty(o,a,{configurable:!0,enumerable:!0,value:r,writable:!0}):o[a]=r}return o},E=e=>{try{const t=f(JSON.parse(e));return p(t)?t:void 0}catch{return}};export{E as a,f as d,u as e,p as i};
@@ -1 +1 @@
1
- import{b as me}from"./chunk-SUDJTC4S.js";import{a as $}from"./chunk-LJYUUOBB.js";import{a as ue}from"./chunk-BOTGXX4H.js";import"./chunk-JAKYTDUH.js";import"./chunk-5JDWLCSH.js";import"./chunk-PYT4RZJH.js";import{a as de}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as D}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import"./chunk-35DM4JJG.js";import{a as M}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-KQFH6FFC.js";import{f as ne,g as oe}from"./chunk-XZCNX7YU.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as A}from"./chunk-WUWBZPUK.js";import{d as T,f as j,g as Q,h as W,o as _,r as ie}from"./chunk-FODLDLE2.js";import{a as p,d as I,e as Ee,f as ae,g as le,i as E}from"./chunk-YKXDMIHQ.js";var Y=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var B=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},he=p(()=>{let t=(0,fe.c)(16),e=T(),a=oe(),s;e:switch(a){case"connected":{let o;t[0]!==e?(o=e("Connected"),t[0]=e,t[1]=o):o=t[1],s=o;break e}case"connecting":{let o;t[2]!==e?(o=e("Connecting\u2026"),t[2]=e,t[3]=o):o=t[3],s=o;break e}case"idle":{let o;t[4]!==e?(o=e("Idle"),t[4]=e,t[5]=o):o=t[5],s=o;break e}case"offline":{let o;t[6]!==e?(o=e("Offline"),t[6]=e,t[7]=o):o=t[7],s=o;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=E("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let i;t[10]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=i):i=t[11];let n;return t[12]!==a||t[13]!==i||t[14]!==s?(n=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[12]=a,t[13]=i,t[14]=s,t[15]=n):n=t[15],n},"T");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=p((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=p((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","Q"),xe=.01,ve=.05,je=p(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=T(),n;e[0]!==i?(n=i("Functions by error rate"),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==n?(o=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=o):o=e[3];let h;e[4]!==i||e[5]!==c?(h=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(D,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=h):h=e[6];let g;e[7]!==o||e[8]!==h?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[o,h]}),e[7]=o,e[8]=h,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(D,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let y;return e[33]!==N||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=y):y=e[35],y},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}p(Ce,"Te");var pe={completed:0,failed:2,in_progress:1},Ie=p(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:n}of t){if(n===null){l+=1;continue}s+=1,e+=n.requests,a+=n.errors,i.push(...n.history??[]),c||=n.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,_e=5,$e=.1,Be=.3,He=1,Ue=50,Ge=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ke=p(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=p(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=p((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=p(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=p(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,n=be[l],o;e[0]!==n?(o=E("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=o):o=e[1];let h;e[2]!==o?(h=(0,r.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=h):h=e[3];let g;e[4]!==s||e[5]!==h?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[h,s]}),e[4]=s,e[5]=h,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"U"),Xe=p(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,n,o]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),h=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(h),b=s[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(h.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?W(b.reason):null,migrations:De(h.map(d=>d.migrations)),scheduler:o.status==="fulfilled"?o.value:null,totals:g}},"$e"),Ye=p(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=p(({initialShardKey:t})=>{let e=ne(),a=T(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[n,o]=(0,f.useState)(null),[h,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Xe(e,P,me(P,N));if(!w.current){y.current=!1;return}o(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,N,P]);(0,f.useEffect)(()=>{_(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=p(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),_(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),_(F())},ge-m))},"ue");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:Z,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{Z!==void 0&&we()},[Z]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Ke(n?.history),te=Ye(u),Se=b.filter(m=>m.calls>0).toSorted((m,J)=>J.errors/J.calls-m.errors/m.calls||J.calls-m.calls).slice(0,_e),K=Ve(S),qe=n===null||n.requests===0?0:n.errors/n.requests,V=X(qe,xe,ve),re=u===null?"ok":X(u.failureRate,$e,Be),se=v===null?"ok":Ge(v.backlog,He,Ue),R=We([V,re,se,K.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[V]),"data-testid":"hl-error-rate",children:n===null?"\u2014":U(n.errors,n.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(he,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),h!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:h}),h===null&&n?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:V,testId:"hl-slo-errorrate",value:n===null?"\u2014":U(n.errors,n.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:K.level,testId:"hl-slo-migrations",value:Je(K,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(D,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(D,{variant:"secondary",children:m})},m))})]})]})},"ut");export{xt as HealthPanel};
1
+ import{b as me}from"./chunk-SUDJTC4S.js";import{a as $}from"./chunk-LJYUUOBB.js";import{a as ue}from"./chunk-BOTGXX4H.js";import"./chunk-JAKYTDUH.js";import"./chunk-5JDWLCSH.js";import"./chunk-PYT4RZJH.js";import{a as de}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as D}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import"./chunk-35DM4JJG.js";import{a as M}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-ZXRRPWQV.js";import{f as ne,g as oe}from"./chunk-XTLR2A7C.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as A}from"./chunk-WUWBZPUK.js";import{d as T,f as j,g as Q,h as W,o as _,r as ie}from"./chunk-FODLDLE2.js";import{a as p,d as I,e as Ee,f as ae,g as le,i as E}from"./chunk-YKXDMIHQ.js";var Y=I(ae(),1);var f=I(Ee(),1);var fe=I(ae(),1);var B=I(le(),1);var Me={connected:"bg-success",connecting:"bg-warning",idle:"bg-muted-foreground",offline:"bg-destructive"},he=p(()=>{let t=(0,fe.c)(16),e=T(),a=oe(),s;e:switch(a){case"connected":{let o;t[0]!==e?(o=e("Connected"),t[0]=e,t[1]=o):o=t[1],s=o;break e}case"connecting":{let o;t[2]!==e?(o=e("Connecting\u2026"),t[2]=e,t[3]=o):o=t[3],s=o;break e}case"idle":{let o;t[4]!==e?(o=e("Idle"),t[4]=e,t[5]=o):o=t[5],s=o;break e}case"offline":{let o;t[6]!==e?(o=e("Offline"),t[6]=e,t[7]=o):o=t[7],s=o;break e}default:s=a}let l=Me[a],c;t[8]!==l?(c=E("size-2 rounded-full",l),t[8]=l,t[9]=c):c=t[9];let i;t[10]!==c?(i=(0,B.jsx)("span",{"aria-hidden":"true",className:c}),t[10]=c,t[11]=i):i=t[11];let n;return t[12]!==a||t[13]!==i||t[14]!==s?(n=(0,B.jsxs)("span",{"aria-live":"polite",className:"inline-flex items-center gap-1.5 text-xs text-muted-foreground","data-status":a,"data-testid":"dash-connection",role:"status",children:[i,s]}),t[12]=a,t[13]=i,t[14]=s,t[15]=n):n=t[15],n},"T");var r=I(le(),1);var Ae={crit:"destructive",ok:"secondary",warn:"default"},U=p((t,e)=>e===0?"\u2014":`${(t/e*100).toFixed(1)}%`,"P"),X=p((t,e,a)=>Number.isNaN(t)?"ok":t>=a?"crit":t>=e?"warn":"ok","Q"),xe=.01,ve=.05,je=p(t=>{let e=(0,Y.c)(36),{errorCount:a,logsError:s,topErrors:l,worstFunctions:c}=t,i=T(),n;e[0]!==i?(n=i("Functions by error rate"),e[0]=i,e[1]=n):n=e[1];let o;e[2]!==n?(o=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n})}),e[2]=n,e[3]=o):o=e[3];let h;e[4]!==i||e[5]!==c?(h=c.length===0?(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-functions-empty",children:i("No function activity yet.")}):(0,r.jsx)("ul",{className:"divide-y divide-border",children:c.map(w=>(0,r.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2 text-xs","data-testid":"hl-fn-row",children:[(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:w.path}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:i("{count} calls",{count:w.calls.toString()})}),(0,r.jsx)(D,{variant:Ae[X(w.errors/w.calls,xe,ve)],children:U(w.errors,w.calls)})]})]},w.path))}),e[4]=i,e[5]=c,e[6]=h):h=e[6];let g;e[7]!==o||e[8]!==h?(g=(0,r.jsxs)(A,{className:"gap-0 py-0","data-testid":"hl-functions",children:[o,h]}),e[7]=o,e[8]=h,e[9]=g):g=e[9];let b;e[10]!==i?(b=i("Recent errors"),e[10]=i,e[11]=b):b=e[11];let d;e[12]!==b?(d=(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:b}),e[12]=b,e[13]=d):d=e[13];let u=a>0?"destructive":"outline",x;e[14]!==a||e[15]!==u?(x=(0,r.jsx)(D,{"data-testid":"hl-error-count",variant:u,children:a}),e[14]=a,e[15]=u,e[16]=x):x=e[16];let v;e[17]!==d||e[18]!==x?(v=(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[d,x]}),e[17]=d,e[18]=x,e[19]=v):v=e[19];let k;e[20]!==s?(k=s!==null&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"hl-logs-error",role:"alert",children:s}),e[20]=s,e[21]=k):k=e[21];let S;e[22]!==s||e[23]!==i||e[24]!==l.length?(S=s===null&&l.length===0&&(0,r.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"hl-errors-empty",children:i("No recent errors.")}),e[22]=s,e[23]=i,e[24]=l.length,e[25]=S):S=e[25];let q;e[26]!==l?(q=l.length>0&&(0,r.jsx)("ul",{className:"divide-y divide-border",children:l.map(Ce)}),e[26]=l,e[27]=q):q=e[27];let N;e[28]!==k||e[29]!==S||e[30]!==q||e[31]!==v?(N=(0,r.jsxs)(A,{className:"gap-0 py-0",children:[v,k,S,q]}),e[28]=k,e[29]=S,e[30]=q,e[31]=v,e[32]=N):N=e[32];let y;return e[33]!==N||e[34]!==g?(y=(0,r.jsxs)("div",{className:"grid gap-3 lg:grid-cols-2",children:[g,N]}),e[33]=N,e[34]=g,e[35]=y):y=e[35],y},"ye");function Ce(t,e){return(0,r.jsxs)("li",{className:"flex flex-col gap-0.5 px-4 py-2 text-xs","data-testid":"hl-error-row",children:[(0,r.jsxs)("span",{className:"flex items-center gap-2",children:[(0,r.jsx)("time",{className:"shrink-0 text-muted-foreground",children:ie(t.timestamp)}),t.functionPath!==void 0&&(0,r.jsx)("span",{className:"truncate font-mono text-foreground",children:t.functionPath})]}),(0,r.jsx)("span",{className:"text-destructive",children:t.message})]},`${t.timestamp.toString()}-${e.toString()}`)}p(Ce,"Te");var pe={completed:0,failed:2,in_progress:1},Ie=p(t=>{let e=0,a=0,s=0,l=0,c=!1,i=[];for(let{metrics:n}of t){if(n===null){l+=1;continue}s+=1,e+=n.requests,a+=n.errors,i.push(...n.history??[]),c||=n.historyTruncated===!0}return{errors:a,failed:l,history:i,historyTruncated:c,reachable:s,requests:e}},"Ae"),Te=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.path);if(l===void 0){e.set(s.path,{...s});continue}l.calls+=s.calls,l.errors+=s.errors,l.totalDurationMs+=s.totalDurationMs,l.scans=(l.scans??0)+(s.scans??0),l.maxDurationMs=Math.max(l.maxDurationMs,s.maxDurationMs),l.lastCalledAt=Math.max(l.lastCalledAt,s.lastCalledAt),(s.lastErrorAt??0)>(l.lastErrorAt??0)&&(l.lastErrorAt=s.lastErrorAt,l.lastErrorMessage=s.lastErrorMessage)}return[...e.values()]},"ke"),De=p(t=>{let e=new Map;for(let a of t)for(let s of a){let l=e.get(s.id);if(l===void 0){e.set(s.id,s);continue}let c=pe[s.status]-pe[l.status];(c>0||c===0&&(s.updatedAt??0)>(l.updatedAt??0))&&e.set(s.id,s)}return[...e.values()]},"Re"),Pe=j(M.getAuthMetrics),Fe=j(M.getFunctionStats),Le=j(M.getLogs),Re=j(M.getMetrics),ze=j(M.migrationStatus),Oe=5,ge=2e3,_e=5,$e=.1,Be=.3,He=1,Ue=50,Ge=p((t,e,a)=>t>=a?"crit":t>=e?"warn":"ok","Pe"),Ke=p(t=>{let e=new Map;for(let s of t??[]){let l=e.get(s.bucketMs)??{calls:0,errors:0};l.calls+=s.calls,l.errors+=s.errors,e.set(s.bucketMs,l)}let a=[...e.entries()].toSorted((s,l)=>s[0]-l[0]);return{errors:a.map(([,s])=>s.errors),requests:a.map(([,s])=>s.calls)}},"Ge"),Ve=p(t=>{let e=0,a=0;for(let l of t)l.status==="failed"?e+=1:l.status==="in_progress"&&(a+=1);let s="ok";return e>0?s="crit":a>0&&(s="warn"),{failed:e,level:s,running:a}},"Ve"),Je=p((t,e)=>t.failed>0?e("{count} failed",{count:t.failed.toString()}):t.running>0?e("{count} running",{count:t.running.toString()}):e("OK"),"Be"),be={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},Ne={crit:"text-destructive",ok:"text-foreground",warn:"text-warning"},Qe={crit:"bg-destructive/10 text-destructive",ok:"bg-success/10 text-success",warn:"bg-warning/10 text-warning"},We=p(t=>t.includes("crit")?"crit":t.includes("warn")?"warn":"ok","Ke"),H=p(t=>{let e=(0,Y.c)(19),{chart:a,label:s,level:l,testId:c,value:i}=t,n=be[l],o;e[0]!==n?(o=E("size-1.5 shrink-0 rounded-full",n),e[0]=n,e[1]=o):o=e[1];let h;e[2]!==o?(h=(0,r.jsx)("span",{"aria-hidden":"true",className:o}),e[2]=o,e[3]=h):h=e[3];let g;e[4]!==s||e[5]!==h?(g=(0,r.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[h,s]}),e[4]=s,e[5]=h,e[6]=g):g=e[6];let b=Ne[l],d;e[7]!==b?(d=E("truncate text-2xl font-semibold tabular-nums",b),e[7]=b,e[8]=d):d=e[8];let u;e[9]!==d||e[10]!==c||e[11]!==i?(u=(0,r.jsx)("span",{className:d,"data-testid":c,children:i}),e[9]=d,e[10]=c,e[11]=i,e[12]=u):u=e[12];let x;e[13]!==a||e[14]!==u?(x=(0,r.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[u,a]}),e[13]=a,e[14]=u,e[15]=x):x=e[15];let v;return e[16]!==g||e[17]!==x?(v=(0,r.jsx)(A,{className:"gap-0 py-0",children:(0,r.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[g,x]})}),e[16]=g,e[17]=x,e[18]=v):v=e[18],v},"U"),Xe=p(async(t,e,a)=>{let s=await Promise.all(a.map(d=>{let u=Q(d);return Promise.allSettled([t.query(Re,{},u),t.query(Fe,{},u),t.query(ze,{},u)])})),l=Q(e),c=typeof t.schedulerStatus=="function"?t.schedulerStatus():Promise.reject(new Error("scheduler status unavailable")),[i,n,o]=await Promise.allSettled([t.query(Le,{},l),t.query(Pe,{},l),c]),h=s.map(([d,u,x])=>({functions:u.status==="fulfilled"?u.value.functions:[],metrics:d.status==="fulfilled"?d.value:null,migrations:x.status==="fulfilled"?x.value.migrations:[]})),g=Ie(h),b=s[0]?.[0];return{auth:n.status==="fulfilled"?n.value:null,entries:i.status==="fulfilled"?i.value.entries:[],functions:Te(h.map(d=>d.functions)),logsError:i.status==="rejected"?W(i.reason):null,metricsError:g.reachable===0&&b?.status==="rejected"?W(b.reason):null,migrations:De(h.map(d=>d.migrations)),scheduler:o.status==="fulfilled"?o.value:null,totals:g}},"$e"),Ye=p(t=>{let e=t?.history??[];return{attempts:e.map(a=>a.attempts),failures:e.map(a=>a.failures)}},"ze"),xt=p(({initialShardKey:t})=>{let e=ne(),a=T(),[s,l]=(0,f.useState)([]),[c,i]=(0,f.useState)(null),[n,o]=(0,f.useState)(null),[h,g]=(0,f.useState)(null),[b,d]=(0,f.useState)([]),[u,x]=(0,f.useState)(null),[v,k]=(0,f.useState)(null),[S,q]=(0,f.useState)([]),[N]=(0,f.useState)(de),y=(0,f.useRef)(!1),w=(0,f.useRef)(!0);(0,f.useEffect)(()=>(w.current=!0,()=>{w.current=!1}),[]);let P=t??"",F=(0,f.useCallback)(async()=>{if(y.current)return;y.current=!0;let m=await Xe(e,P,me(P,N));if(!w.current){y.current=!1;return}o(m.totals),g(m.metricsError),d(m.functions),q(m.migrations),l(m.entries),i(m.logsError),x(m.auth),k(m.scheduler),y.current=!1},[e,N,P]);(0,f.useEffect)(()=>{_(F())},[F]);let G=(0,f.useRef)(0),C=(0,f.useRef)(null),we=p(()=>{let m=Date.now()-G.current;if(m>=ge){G.current=Date.now(),_(F());return}C.current===null&&(C.current=setTimeout(()=>{C.current=null,G.current=Date.now(),_(F())},ge-m))},"ue");(0,f.useEffect)(()=>()=>{C.current!==null&&clearTimeout(C.current)},[]);let{data:Z,liveError:ye}=ce(M.getMetrics,{},{live:!0,shardKey:P});(0,f.useEffect)(()=>{Z!==void 0&&we()},[Z]);let ee=s.filter(m=>m.level==="error"),ke=ee.slice(0,Oe),L=Ke(n?.history),te=Ye(u),Se=b.filter(m=>m.calls>0).toSorted((m,J)=>J.errors/J.calls-m.errors/m.calls||J.calls-m.calls).slice(0,_e),K=Ve(S),qe=n===null||n.requests===0?0:n.errors/n.requests,V=X(qe,xe,ve),re=u===null?"ok":X(u.failureRate,$e,Be),se=v===null?"ok":Ge(v.backlog,He,Ue),R=We([V,re,se,K.level]),z,O;return R==="crit"?(z=a("Critical"),O=a("One or more service levels are breached.")):R==="warn"?(z=a("Degraded"),O=a("Some service levels need attention.")):(z=a("All systems healthy"),O=a("All service levels are within target.")),(0,r.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-health",children:[(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[(0,r.jsxs)("div",{className:"flex items-center gap-3",children:[(0,r.jsx)("span",{"aria-hidden":"true",className:E("flex size-10 shrink-0 items-center justify-center rounded-full",Qe[R]),children:(0,r.jsx)("span",{className:E("size-3 rounded-full",be[R])})}),(0,r.jsxs)("div",{className:"grid leading-tight",children:[(0,r.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"hl-status",children:z}),(0,r.jsx)("span",{className:"text-[13px] text-muted-foreground",children:O})]})]}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-4",children:[(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Requests")}),(0,r.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[L.requests.length>=2&&(0,r.jsx)($,{ariaLabel:a("Requests over time"),className:"h-6 w-20 text-foreground",series:L.requests,testId:"hl-spark-requests"}),(0,r.jsx)("span",{className:"text-lg font-semibold tabular-nums text-foreground","data-testid":"hl-requests",children:(n?.requests??0).toString()})]})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"text-end",children:[(0,r.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:a("Error rate")}),(0,r.jsx)("div",{className:E("text-lg font-semibold tabular-nums",Ne[V]),"data-testid":"hl-error-rate",children:n===null?"\u2014":U(n.errors,n.requests)})]}),(0,r.jsx)("span",{"aria-hidden":"true",className:"h-9 w-px bg-border"}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(he,{}),(0,r.jsx)(ue,{message:ye,prefix:"hl"})]})]})]}),h!==null&&(0,r.jsx)("div",{className:"border-t border-border bg-destructive/5 px-4 py-2 text-sm text-destructive","data-testid":"hl-metrics-error",role:"alert",children:h}),h===null&&n?.historyTruncated===!0&&(0,r.jsx)("div",{className:"border-t border-border bg-warning/5 px-4 py-2 text-sm text-muted-foreground","data-testid":"hl-history-truncated",children:a("Showing a partial request/error history \u2014 one or more shards have more data than the trend chart can display.")})]}),(0,r.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2 xl:grid-cols-4","data-testid":"hl-slo",children:[(0,r.jsx)(H,{chart:L.errors.length>=2?(0,r.jsx)($,{ariaLabel:a("Errors over time"),className:"h-7 w-20 text-destructive",series:L.errors,testId:"hl-spark-errors"}):void 0,label:a("Error rate"),level:V,testId:"hl-slo-errorrate",value:n===null?"\u2014":U(n.errors,n.requests)}),(0,r.jsx)(H,{chart:te.failures.length>=2?(0,r.jsx)($,{ariaLabel:a("Auth failures over time"),className:"h-7 w-20 text-destructive",series:te.failures,testId:"hl-spark-auth"}):void 0,label:a("Auth failures"),level:re,testId:"hl-slo-auth",value:u===null?"\u2014":U(u.failures,u.attempts)}),(0,r.jsx)(H,{label:a("Scheduler backlog"),level:se,testId:"hl-slo-backlog",value:v===null?"\u2014":v.backlog.toString()}),(0,r.jsx)(H,{label:a("Migrations"),level:K.level,testId:"hl-slo-migrations",value:Je(K,a)})]}),(0,r.jsx)(je,{errorCount:ee.length,logsError:c,topErrors:ke,worstFunctions:Se}),(0,r.jsxs)(A,{className:"gap-0 py-0",children:[(0,r.jsxs)("header",{className:"flex items-center justify-between gap-2 border-b border-border px-4 py-3",children:[(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:a("Shards seen")}),(0,r.jsx)(D,{"data-testid":"hl-shard-count",variant:"outline",children:N.length})]}),N.length>0&&(0,r.jsx)("ul",{className:"flex flex-wrap gap-1.5 p-4",children:N.map(m=>(0,r.jsx)("li",{"data-testid":"hl-shard",children:(0,r.jsx)(D,{variant:"secondary",children:m})},m))})]})]})},"ut");export{xt as HealthPanel};
@@ -1 +1 @@
1
- import{b as we}from"./chunk-EHSU2WDS.js";import{a as Ne}from"./chunk-RPQL45FL.js";import{b as ve,c as ye}from"./chunk-4GTO7FL5.js";import{a as ge}from"./chunk-VVOVVU53.js";import{a as xe}from"./chunk-BOTGXX4H.js";import"./chunk-SB35BJ7A.js";import"./chunk-FO26ZU7E.js";import{a as fe}from"./chunk-S3CRZLGS.js";import{a as he}from"./chunk-IABM4BFJ.js";import{b as pe}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{P as me}from"./chunk-46ZJ3TM4.js";import"./chunk-4L4WTGN5.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import{b as oe}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import{a as be}from"./chunk-5K2UDZLN.js";import"./chunk-ULIQFBZU.js";import"./chunk-GWW7SJR6.js";import"./chunk-35DM4JJG.js";import{a as ce}from"./chunk-4ZEL6BYL.js";import{c as ie}from"./chunk-KQFH6FFC.js";import"./chunk-XZCNX7YU.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as ue}from"./chunk-FKVZRPV5.js";import{d as U,r as de}from"./chunk-FODLDLE2.js";import{a as m,d as le,e as $e,f as Ce,g as Le,i as te}from"./chunk-YKXDMIHQ.js";var B=le(Ce(),1),O=le($e(),1);var s=le(Le(),1);var Te=.5,Me=4,Ie=m(n=>Math.min(100,Math.max(0,n)),"ce"),Pe=m((n,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=Ie(n.offsetMs/e*100),a=n.durationMs/e*100,l=Math.max(Te,Math.min(Ie(a),100-t));return{leftPercent:t,widthPercent:l}},"Le"),Ke=m((n,e,t=!1)=>{let a=e.trim().toLowerCase(),l=t?n.filter(r=>!r.ok):n;return a===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(a)||r.functionPath.toLowerCase().includes(a)||r.traceId.toLowerCase().includes(a)||r.spans.some(o=>o.name.toLowerCase().includes(a)||o.spanId.toLowerCase().includes(a)))},"Ce"),G=m(n=>Number.isFinite(n)?n>0&&n<1?`${n.toFixed(2)}ms`:`${String(Math.round(n))}ms`:"\u2014","q"),De=m(n=>!Number.isFinite(n)||n<=0?[]:Array.from({length:Me},(e,t)=>{let a=(t+1)/Me;return{label:G(n*a),percent:a*100}}),"Ee"),Se=m(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}},"ue"),ee=m(n=>{let e=(0,B.c)(7),{label:t,value:a}=n,l;e[0]!==t?(l=(0,s.jsx)("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==a?(r=(0,s.jsx)("dd",{className:"min-w-0 break-all",children:a}),e[2]=a,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=(0,s.jsxs)("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},"Y"),Fe=m(n=>{let e=(0,B.c)(68),{span:t}=n,a=U(),l,r,o,d,i,u;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==a){let $=Object.entries(t.attributes??{}),_;e[15]!==t.events?(_=t.events??[],e[15]=t.events,e[16]=_):_=e[16],l=_,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let y;e[17]!==a?(y=a("Span ID"),e[17]=a,e[18]=y):y=e[18];let w;e[19]!==t.spanId||e[20]!==y?(w=(0,s.jsx)(ee,{label:y,value:t.spanId}),e[19]=t.spanId,e[20]=y,e[21]=w):w=e[21];let M;e[22]!==a?(M=a("Parent span ID"),e[22]=a,e[23]=M):M=e[23];let p;e[24]!==t.parentSpanId||e[25]!==a?(p=t.parentSpanId===""?a("\u2014 (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=a,e[26]=p):p=e[26];let h;e[27]!==p||e[28]!==M?(h=(0,s.jsx)(ee,{label:M,value:p}),e[27]=p,e[28]=M,e[29]=h):h=e[29];let b;e[30]!==a?(b=a("Kind"),e[30]=a,e[31]=b):b=e[31];let C=t.kind??"internal",S;e[32]!==b||e[33]!==C?(S=(0,s.jsx)(ee,{label:b,value:C}),e[32]=b,e[33]=C,e[34]=S):S=e[34];let I;e[35]!==a?(I=a("Started at"),e[35]=a,e[36]=I):I=e[36];let g;e[37]!==t.offsetMs||e[38]!==a?(g=a("+{offset}",{offset:G(t.offsetMs)}),e[37]=t.offsetMs,e[38]=a,e[39]=g):g=e[39];let x;e[40]!==I||e[41]!==g?(x=(0,s.jsx)(ee,{label:I,value:g}),e[40]=I,e[41]=g,e[42]=x):x=e[42];let k;e[43]!==a?(k=a("Duration"),e[43]=a,e[44]=k):k=e[44];let f;e[45]!==t.durationMs?(f=G(t.durationMs),e[45]=t.durationMs,e[46]=f):f=e[46];let N;e[47]!==k||e[48]!==f?(N=(0,s.jsx)(ee,{label:k,value:f}),e[47]=k,e[48]=f,e[49]=N):N=e[49],e[50]!==h||e[51]!==S||e[52]!==x||e[53]!==N||e[54]!==w?(d=(0,s.jsxs)("dl",{className:"flex flex-col gap-1",children:[w,h,S,x,N]}),e[50]=h,e[51]=S,e[52]=x,e[53]=N,e[54]=w,e[55]=d):d=e[55],e[56]!==t.error?(i=t.error!==void 0&&(0,s.jsxs)("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[(0,s.jsx)("span",{className:"font-semibold text-destructive",children:t.error.type}),(0,s.jsx)("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=i):i=e[57],u=$.length>0&&(0,s.jsxs)("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[(0,s.jsx)("p",{className:"mb-1 text-muted-foreground",children:a("Attributes")}),(0,s.jsx)("dl",{className:"flex flex-col gap-1",children:$.map(je)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=a,e[9]=l,e[10]=r,e[11]=o,e[12]=d,e[13]=i,e[14]=u}else l=e[9],r=e[10],o=e[11],d=e[12],i=e[13],u=e[14];let c;e[58]!==l||e[59]!==a?(c=l.length>0&&(0,s.jsxs)("div",{className:"mt-2","data-testid":"tr-detail-events",children:[(0,s.jsx)("p",{className:"mb-1 text-muted-foreground",children:a("Events")}),(0,s.jsx)("ul",{className:"flex flex-col gap-1",children:l.map(Oe)})]}),e[58]=l,e[59]=a,e[60]=c):c=e[60];let v;return e[61]!==r||e[62]!==o||e[63]!==d||e[64]!==i||e[65]!==u||e[66]!==c?(v=(0,s.jsxs)("div",{className:r,"data-testid":o,children:[d,i,u,c]}),e[61]=r,e[62]=o,e[63]=d,e[64]=i,e[65]=u,e[66]=c,e[67]=v):v=e[67],v},"Pe");function je(n){let[e,t]=n;return(0,s.jsx)(ee,{label:e,value:Se(t)},e)}m(je,"Fe");function Ee(n){let[e,t]=n;return`${e}=${Se(t)}`}m(Ee,"Ke");function Oe(n){return(0,s.jsxs)("li",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:de(n.ts)}),(0,s.jsx)(oe,{variant:"secondary",children:n.name}),(0,s.jsx)("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(n.attributes??{}).map(Ee).join(" ")})]},`${n.name}:${String(n.ts)}`)}m(Oe,"Ae");var Be=14,ke="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",Re=m(n=>{let e=(0,B.c)(17),{traceDurationMs:t}=n,a,l,r,o,d,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{let v=De(t);if(v.length===0){i=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=te(ke,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)("span",{}),e[8]=d):d=e[8],a="relative h-3",l=v.map(ze)}e[0]=t,e[1]=a,e[2]=l,e[3]=r,e[4]=o,e[5]=d,e[6]=i}else a=e[1],l=e[2],r=e[3],o=e[4],d=e[5],i=e[6];if(i!==Symbol.for("react.early_return_sentinel"))return i;let u;e[9]!==a||e[10]!==l?(u=(0,s.jsx)("span",{className:a,children:l}),e[9]=a,e[10]=l,e[11]=u):u=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==d||e[15]!==u?(c=(0,s.jsxs)("div",{className:r,"data-testid":o,children:[d,u]}),e[12]=r,e[13]=o,e[14]=d,e[15]=u,e[16]=c):c=e[16],c},"Re"),We=m(n=>{let e=(0,B.c)(60),{span:t,traceDurationMs:a}=n,l=U(),[r,o]=(0,O.useState)(!1),d;e[0]!==t||e[1]!==a?(d=Pe(t,a),e[0]=t,e[1]=a,e[2]=d):d=e[2];let{leftPercent:i,widthPercent:u}=d,c;e[3]!==t.attributes?(c=Ne(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];let v=c,$=t.depth*Be,_;e[5]!==$?(_={paddingLeft:$},e[5]=$,e[6]=_):_=e[6];let y=_,w=`${String(i)}%`,M=`${String(u)}%`,p;e[7]!==w||e[8]!==M?(p={left:w,width:M},e[7]=w,e[8]=M,e[9]=p):p=e[9];let h=p,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=m(()=>{o(Je)},"h"),e[10]=b):b=e[10];let C=b,S=t.depth,I=`tr-span-detail-${t.spanId}`,g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:G(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:G(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=te(ke,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=x):x=e[17];let k=`tr-span-toggle-${t.spanId}`,f;e[18]!==t.ok?(f=t.ok?null:(0,s.jsx)("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"\u25CF"}),e[18]=t.ok,e[19]=f):f=e[19];let N;e[20]!==y||e[21]!==t.name||e[22]!==f?(N=(0,s.jsxs)("span",{className:"truncate",style:y,title:t.name,children:[f,t.name]}),e[20]=y,e[21]=t.name,e[22]=f,e[23]=N):N=e[23];let R=t.ok?"bg-primary/70":"bg-destructive",L;e[24]!==R?(L=te("absolute inset-y-0 rounded-sm",R),e[24]=R,e[25]=L):L=e[25];let E;e[26]!==h||e[27]!==i||e[28]!==L||e[29]!==u?(E=(0,s.jsx)("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:(0,s.jsx)("span",{className:L,"data-left":i,"data-testid":"tr-span-bar","data-width":u,style:h})}),e[26]=h,e[27]=i,e[28]=L,e[29]=u,e[30]=E):E=e[30];let W;e[31]!==t.durationMs?(W=G(t.durationMs),e[31]=t.durationMs,e[32]=W):W=e[32];let D;e[33]!==W?(D=(0,s.jsx)("span",{className:"text-right tabular-nums text-muted-foreground",children:W}),e[33]=W,e[34]=D):D=e[34];let q;e[35]!==t.error?(q=t.error===void 0?null:(0,s.jsx)("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=q):q=e[36];let T;e[37]!==q?(T=(0,s.jsx)("span",{className:"truncate text-muted-foreground",children:q}),e[37]=q,e[38]=T):T=e[38];let z;e[39]!==v?(z=v===""?null:(0,s.jsx)("span",{"data-testid":"tr-span-attributes",title:v,children:v}),e[39]=v,e[40]=z):z=e[40];let P;e[41]!==z?(P=(0,s.jsx)("span",{className:"truncate text-muted-foreground",children:z}),e[41]=z,e[42]=P):P=e[42];let J;e[43]!==r||e[44]!==I||e[45]!==g||e[46]!==k||e[47]!==N||e[48]!==E||e[49]!==D||e[50]!==T||e[51]!==P?(J=(0,s.jsxs)("button",{"aria-controls":I,"aria-expanded":r,"aria-label":g,className:x,"data-testid":k,onClick:C,type:"button",children:[N,E,D,T,P]}),e[43]=r,e[44]=I,e[45]=g,e[46]=k,e[47]=N,e[48]=E,e[49]=D,e[50]=T,e[51]=P,e[52]=J):J=e[52];let F;e[53]!==r||e[54]!==t?(F=r&&(0,s.jsx)("div",{id:`tr-span-detail-${t.spanId}`,children:(0,s.jsx)(Fe,{span:t})}),e[53]=r,e[54]=t,e[55]=F):F=e[55];let K;return e[56]!==t.depth||e[57]!==J||e[58]!==F?(K=(0,s.jsxs)("li",{"data-depth":S,"data-testid":"tr-span-row",children:[J,F]}),e[56]=t.depth,e[57]=J,e[58]=F,e[59]=K):K=e[59],K},"Be"),qe=m(n=>{let e=(0,B.c)(15),{durationMs:t,spans:a}=n,l=U(),r;e[0]!==t?(r=(0,s.jsx)(Re,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let d;if(e[4]!==t||e[5]!==a){let c;e[7]!==t?(c=m(v=>(0,s.jsx)(We,{span:v,traceDurationMs:t},v.spanId),"c"),e[7]=t,e[8]=c):c=e[8],d=a.map(c),e[4]=t,e[5]=a,e[6]=d}else d=e[6];let i;e[9]!==o||e[10]!==d?(i=(0,s.jsx)("ul",{"aria-label":o,children:d}),e[9]=o,e[10]=d,e[11]=i):i=e[11];let u;return e[12]!==r||e[13]!==i?(u=(0,s.jsxs)(s.Fragment,{children:[r,i]}),e[12]=r,e[13]=i,e[14]=u):u=e[14],u},"Oe");function ze(n){return(0,s.jsx)("span",{className:te("absolute inset-y-0 border-l border-border/70",n.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(n.percent)}%`},children:n.label},n.percent)}m(ze,"je");function Je(n){return!n}m(Je,"We");var Ue=m(n=>Array.isArray(n?.traces)?n.traces:[],"Ue"),Ge=m(n=>{let e=(0,B.c)(12),{entries:t}=n,a=U(),l;e[0]!==t.length||e[1]!==a?(l=a("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=a,e[2]=l):l=e[2];let r;e[3]!==l?(r=(0,s.jsx)("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(Qe),e[5]=t,e[6]=o):o=e[6];let d;e[7]!==o?(d=(0,s.jsx)("div",{role:"grid",children:o}),e[7]=o,e[8]=d):d=e[8];let i;return e[9]!==r||e[10]!==d?(i=(0,s.jsxs)("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,d]}),e[9]=r,e[10]=d,e[11]=i):i=e[11],i},"qe"),He=m(n=>{let e=(0,B.c)(50),{expanded:t,logs:a,onToggle:l,trace:r}=n,o=U(),d;e[0]!==l||e[1]!==r.traceId?(d=m(()=>{l(r.traceId)},"i"),e[0]=l,e[1]=r.traceId,e[2]=d):d=e[2];let i=d,u=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,v=`tr-toggle-${r.traceId}`,$=t?"\u25BE":"\u25B8",_;e[3]!==$?(_=(0,s.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=_):_=e[4];let y;e[5]!==r.rootName?(y=(0,s.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=y):y=e[6];let w;e[7]!==r.functionPath?(w=(0,s.jsx)("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let M;e[9]!==r.durationMs?(M=G(r.durationMs),e[9]=r.durationMs,e[10]=M):M=e[10];let p;e[11]!==M?(p=(0,s.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:M}),e[11]=M,e[12]=p):p=e[12];let h;e[13]!==o||e[14]!==r.spans.length?(h=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=h):h=e[15];let b;e[16]!==h?(b=(0,s.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:h}),e[16]=h,e[17]=b):b=e[17];let C=r.ok?"secondary":"destructive",S;e[18]!==o||e[19]!==r.ok?(S=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=S):S=e[20];let I;e[21]!==C||e[22]!==S?(I=(0,s.jsx)("span",{className:"shrink-0",children:(0,s.jsx)(oe,{variant:C,children:S})}),e[21]=C,e[22]=S,e[23]=I):I=e[23];let g;e[24]!==r.startTs?(g=de(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let x;e[26]!==g?(x=(0,s.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=x):x=e[27];let k;e[28]!==t||e[29]!==i||e[30]!==p||e[31]!==b||e[32]!==I||e[33]!==x||e[34]!==c||e[35]!==v||e[36]!==_||e[37]!==y||e[38]!==w?(k=(0,s.jsxs)("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":v,onClick:i,type:"button",children:[_,y,w,p,b,I,x]}),e[28]=t,e[29]=i,e[30]=p,e[31]=b,e[32]=I,e[33]=x,e[34]=c,e[35]=v,e[36]=_,e[37]=y,e[38]=w,e[39]=k):k=e[39];let f;e[40]!==t||e[41]!==a||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(f=t&&(0,s.jsxs)("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[(0,s.jsx)(qe,{durationMs:r.durationMs,spans:r.spans}),a.length>0&&(0,s.jsx)(Ge,{entries:a})]}),e[40]=t,e[41]=a,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=f):f=e[45];let N;return e[46]!==k||e[47]!==f||e[48]!==u?(N=(0,s.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":u,children:[k,f]}),e[46]=k,e[47]=f,e[48]=u,e[49]=N):N=e[49],N},"ze"),ft=m(n=>{let e=(0,B.c)(58),{initialShardKey:t}=n,a=U(),[l]=(0,O.useState)(ve),{queryShardKey:r,setShardKey:o,shardKey:d}=fe(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[i,u]=(0,O.useState)(l?.traceId??""),[c,v]=(0,O.useState)(!1),[$,_]=(0,O.useState)(Ae),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],(0,O.useEffect)(Ve,y);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={},e[1]=w):w=e[1];let M;e[2]!==r?(M={live:!0,shardKey:r},e[2]=r,e[3]=M):M=e[3];let{data:p,error:h,errorSource:b,isLoading:C,liveError:S}=ie(ce.getTraces,w,M),I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I={},e[4]=I):I=e[4];let g=$.size>0,x;e[5]!==r||e[6]!==g?(x={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=x):x=e[7];let{data:k}=ie(ce.getLogs,I,x),f,N;e[8]!==p||e[9]!==r?(f=m(()=>{p!==void 0&&pe(r)},"p"),N=[p,r],e[8]=p,e[9]=r,e[10]=f,e[11]=N):(f=e[10],N=e[11]),(0,O.useEffect)(f,N);let R;if(e[12]!==p||e[13]!==h||e[14]!==b||e[15]!==$||e[16]!==C||e[17]!==S||e[18]!==k?.entries||e[19]!==c||e[20]!==i||e[21]!==o||e[22]!==d||e[23]!==a){let L=Ue(p),E=p?.total??L.length,W=E>L.length,D=Ke(L,i,c),q=Map.groupBy((k?.entries??[]).toReversed(),Xe),T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=m(j=>{u(j.target.value)},"C"),e[25]=T):T=e[25];let z=T,P;e[26]===Symbol.for("react.memo_cache_sentinel")?(P=m(j=>{_(_e=>{let ne=new Set(_e);return ne.has(j)?ne.delete(j):ne.add(j),ne})},"E"),e[26]=P):P=e[26];let J=P,F=h===null&&D.length===0&&!C,K;e[27]!==o||e[28]!==d?(K=(0,s.jsx)(he,{onChange:o,testId:"tr-shard-input",value:d}),e[27]=o,e[28]=d,e[29]=K):K=e[29];let H;e[30]!==a?(H=a("Search traces"),e[30]=a,e[31]=H):H=e[31];let Q;e[32]!==a?(Q=a("search trace, span, or function"),e[32]=a,e[33]=Q):Q=e[33];let A;e[34]!==i||e[35]!==H||e[36]!==Q?(A=(0,s.jsx)(me,{"aria-label":H,className:"h-8 w-56","data-testid":"tr-search",onChange:z,placeholder:Q,value:i}),e[34]=i,e[35]=H,e[36]=Q,e[37]=A):A=e[37];let V;e[38]!==c?(V=(0,s.jsx)(ge,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:v}),e[38]=c,e[39]=V):V=e[39];let X;e[40]!==a?(X=a("Errors only"),e[40]=a,e[41]=X):X=e[41];let Y;e[42]!==V||e[43]!==X?(Y=(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[V,X]}),e[42]=V,e[43]=X,e[44]=Y):Y=e[44];let Z;e[45]!==S?(Z=(0,s.jsx)(xe,{message:S,prefix:"tr"}),e[45]=S,e[46]=Z):Z=e[46];let re;e[47]!==K||e[48]!==A||e[49]!==Y||e[50]!==Z?(re=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[K,A,Y,Z]}),e[47]=K,e[48]=A,e[49]=Y,e[50]=Z,e[51]=re):re=e[51];let ae;e[52]!==h||e[53]!==b?(ae=h!==null&&(0,s.jsx)(be,{error:b,testId:"tr-error"}),e[52]=h,e[53]=b,e[54]=ae):ae=e[54];let se;e[55]!==F||e[56]!==a?(se=F&&(0,s.jsx)(ue,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[55]=F,e[56]=a,e[57]=se):se=e[57],R=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[re,ae,se,h===null&&W&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:a("Showing the {shown} most recent of {total} traces in the buffer.",{shown:L.length,total:E})}),h===null&&D.length>0&&(0,s.jsx)("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:D.map(j=>(0,s.jsx)(He,{expanded:$.has(j.traceId),logs:q.get(j.traceId)??[],onToggle:J,trace:j},j.traceId))})]}),e[12]=p,e[13]=h,e[14]=b,e[15]=$,e[16]=C,e[17]=S,e[18]=k?.entries,e[19]=c,e[20]=i,e[21]=o,e[22]=d,e[23]=a,e[24]=R}else R=e[24];return R},"gt");function Qe(n,e){return(0,s.jsx)("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:(0,s.jsx)(we,{entry:n})},`${String(e)}:${String(n.timestamp)}`)}m(Qe,"Ge");function Ae(){return new Set}m(Ae,"He");function Ve(){ye()}m(Ve,"Je");function Xe(n){return n.traceId}m(Xe,"Qe");export{ft as default};
1
+ import{b as we}from"./chunk-EHSU2WDS.js";import{a as Ne}from"./chunk-RPQL45FL.js";import{b as ve,c as ye}from"./chunk-4GTO7FL5.js";import{a as ge}from"./chunk-VVOVVU53.js";import{a as xe}from"./chunk-BOTGXX4H.js";import"./chunk-SB35BJ7A.js";import"./chunk-FO26ZU7E.js";import{a as fe}from"./chunk-S3CRZLGS.js";import{a as he}from"./chunk-IABM4BFJ.js";import{b as pe}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{P as me}from"./chunk-46ZJ3TM4.js";import"./chunk-4L4WTGN5.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import{b as oe}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import{a as be}from"./chunk-XJDQG6VV.js";import"./chunk-ULIQFBZU.js";import"./chunk-7ROGUMLR.js";import"./chunk-35DM4JJG.js";import{a as ce}from"./chunk-4ZEL6BYL.js";import{c as ie}from"./chunk-ZXRRPWQV.js";import"./chunk-XTLR2A7C.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as ue}from"./chunk-FKVZRPV5.js";import{d as U,r as de}from"./chunk-FODLDLE2.js";import{a as m,d as le,e as $e,f as Ce,g as Le,i as te}from"./chunk-YKXDMIHQ.js";var B=le(Ce(),1),O=le($e(),1);var s=le(Le(),1);var Te=.5,Me=4,Ie=m(n=>Math.min(100,Math.max(0,n)),"ce"),Pe=m((n,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};let t=Ie(n.offsetMs/e*100),a=n.durationMs/e*100,l=Math.max(Te,Math.min(Ie(a),100-t));return{leftPercent:t,widthPercent:l}},"Le"),Ke=m((n,e,t=!1)=>{let a=e.trim().toLowerCase(),l=t?n.filter(r=>!r.ok):n;return a===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(a)||r.functionPath.toLowerCase().includes(a)||r.traceId.toLowerCase().includes(a)||r.spans.some(o=>o.name.toLowerCase().includes(a)||o.spanId.toLowerCase().includes(a)))},"Ce"),G=m(n=>Number.isFinite(n)?n>0&&n<1?`${n.toFixed(2)}ms`:`${String(Math.round(n))}ms`:"\u2014","q"),De=m(n=>!Number.isFinite(n)||n<=0?[]:Array.from({length:Me},(e,t)=>{let a=(t+1)/Me;return{label:G(n*a),percent:a*100}}),"Ee"),Se=m(n=>{if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}},"ue"),ee=m(n=>{let e=(0,B.c)(7),{label:t,value:a}=n,l;e[0]!==t?(l=(0,s.jsx)("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==a?(r=(0,s.jsx)("dd",{className:"min-w-0 break-all",children:a}),e[2]=a,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=(0,s.jsxs)("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},"Y"),Fe=m(n=>{let e=(0,B.c)(68),{span:t}=n,a=U(),l,r,o,d,i,u;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==a){let $=Object.entries(t.attributes??{}),_;e[15]!==t.events?(_=t.events??[],e[15]=t.events,e[16]=_):_=e[16],l=_,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let y;e[17]!==a?(y=a("Span ID"),e[17]=a,e[18]=y):y=e[18];let w;e[19]!==t.spanId||e[20]!==y?(w=(0,s.jsx)(ee,{label:y,value:t.spanId}),e[19]=t.spanId,e[20]=y,e[21]=w):w=e[21];let M;e[22]!==a?(M=a("Parent span ID"),e[22]=a,e[23]=M):M=e[23];let p;e[24]!==t.parentSpanId||e[25]!==a?(p=t.parentSpanId===""?a("\u2014 (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=a,e[26]=p):p=e[26];let h;e[27]!==p||e[28]!==M?(h=(0,s.jsx)(ee,{label:M,value:p}),e[27]=p,e[28]=M,e[29]=h):h=e[29];let b;e[30]!==a?(b=a("Kind"),e[30]=a,e[31]=b):b=e[31];let C=t.kind??"internal",S;e[32]!==b||e[33]!==C?(S=(0,s.jsx)(ee,{label:b,value:C}),e[32]=b,e[33]=C,e[34]=S):S=e[34];let I;e[35]!==a?(I=a("Started at"),e[35]=a,e[36]=I):I=e[36];let g;e[37]!==t.offsetMs||e[38]!==a?(g=a("+{offset}",{offset:G(t.offsetMs)}),e[37]=t.offsetMs,e[38]=a,e[39]=g):g=e[39];let x;e[40]!==I||e[41]!==g?(x=(0,s.jsx)(ee,{label:I,value:g}),e[40]=I,e[41]=g,e[42]=x):x=e[42];let k;e[43]!==a?(k=a("Duration"),e[43]=a,e[44]=k):k=e[44];let f;e[45]!==t.durationMs?(f=G(t.durationMs),e[45]=t.durationMs,e[46]=f):f=e[46];let N;e[47]!==k||e[48]!==f?(N=(0,s.jsx)(ee,{label:k,value:f}),e[47]=k,e[48]=f,e[49]=N):N=e[49],e[50]!==h||e[51]!==S||e[52]!==x||e[53]!==N||e[54]!==w?(d=(0,s.jsxs)("dl",{className:"flex flex-col gap-1",children:[w,h,S,x,N]}),e[50]=h,e[51]=S,e[52]=x,e[53]=N,e[54]=w,e[55]=d):d=e[55],e[56]!==t.error?(i=t.error!==void 0&&(0,s.jsxs)("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[(0,s.jsx)("span",{className:"font-semibold text-destructive",children:t.error.type}),(0,s.jsx)("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=i):i=e[57],u=$.length>0&&(0,s.jsxs)("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[(0,s.jsx)("p",{className:"mb-1 text-muted-foreground",children:a("Attributes")}),(0,s.jsx)("dl",{className:"flex flex-col gap-1",children:$.map(je)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=a,e[9]=l,e[10]=r,e[11]=o,e[12]=d,e[13]=i,e[14]=u}else l=e[9],r=e[10],o=e[11],d=e[12],i=e[13],u=e[14];let c;e[58]!==l||e[59]!==a?(c=l.length>0&&(0,s.jsxs)("div",{className:"mt-2","data-testid":"tr-detail-events",children:[(0,s.jsx)("p",{className:"mb-1 text-muted-foreground",children:a("Events")}),(0,s.jsx)("ul",{className:"flex flex-col gap-1",children:l.map(Oe)})]}),e[58]=l,e[59]=a,e[60]=c):c=e[60];let v;return e[61]!==r||e[62]!==o||e[63]!==d||e[64]!==i||e[65]!==u||e[66]!==c?(v=(0,s.jsxs)("div",{className:r,"data-testid":o,children:[d,i,u,c]}),e[61]=r,e[62]=o,e[63]=d,e[64]=i,e[65]=u,e[66]=c,e[67]=v):v=e[67],v},"Pe");function je(n){let[e,t]=n;return(0,s.jsx)(ee,{label:e,value:Se(t)},e)}m(je,"Fe");function Ee(n){let[e,t]=n;return`${e}=${Se(t)}`}m(Ee,"Ke");function Oe(n){return(0,s.jsxs)("li",{className:"flex gap-2",children:[(0,s.jsx)("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:de(n.ts)}),(0,s.jsx)(oe,{variant:"secondary",children:n.name}),(0,s.jsx)("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(n.attributes??{}).map(Ee).join(" ")})]},`${n.name}:${String(n.ts)}`)}m(Oe,"Ae");var Be=14,ke="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",Re=m(n=>{let e=(0,B.c)(17),{traceDurationMs:t}=n,a,l,r,o,d,i;if(e[0]!==t){i=Symbol.for("react.early_return_sentinel");e:{let v=De(t);if(v.length===0){i=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=te(ke,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(d=(0,s.jsx)("span",{}),e[8]=d):d=e[8],a="relative h-3",l=v.map(ze)}e[0]=t,e[1]=a,e[2]=l,e[3]=r,e[4]=o,e[5]=d,e[6]=i}else a=e[1],l=e[2],r=e[3],o=e[4],d=e[5],i=e[6];if(i!==Symbol.for("react.early_return_sentinel"))return i;let u;e[9]!==a||e[10]!==l?(u=(0,s.jsx)("span",{className:a,children:l}),e[9]=a,e[10]=l,e[11]=u):u=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==d||e[15]!==u?(c=(0,s.jsxs)("div",{className:r,"data-testid":o,children:[d,u]}),e[12]=r,e[13]=o,e[14]=d,e[15]=u,e[16]=c):c=e[16],c},"Re"),We=m(n=>{let e=(0,B.c)(60),{span:t,traceDurationMs:a}=n,l=U(),[r,o]=(0,O.useState)(!1),d;e[0]!==t||e[1]!==a?(d=Pe(t,a),e[0]=t,e[1]=a,e[2]=d):d=e[2];let{leftPercent:i,widthPercent:u}=d,c;e[3]!==t.attributes?(c=Ne(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];let v=c,$=t.depth*Be,_;e[5]!==$?(_={paddingLeft:$},e[5]=$,e[6]=_):_=e[6];let y=_,w=`${String(i)}%`,M=`${String(u)}%`,p;e[7]!==w||e[8]!==M?(p={left:w,width:M},e[7]=w,e[8]=M,e[9]=p):p=e[9];let h=p,b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=m(()=>{o(Je)},"h"),e[10]=b):b=e[10];let C=b,S=t.depth,I=`tr-span-detail-${t.spanId}`,g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:G(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:G(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let x;e[17]===Symbol.for("react.memo_cache_sentinel")?(x=te(ke,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=x):x=e[17];let k=`tr-span-toggle-${t.spanId}`,f;e[18]!==t.ok?(f=t.ok?null:(0,s.jsx)("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"\u25CF"}),e[18]=t.ok,e[19]=f):f=e[19];let N;e[20]!==y||e[21]!==t.name||e[22]!==f?(N=(0,s.jsxs)("span",{className:"truncate",style:y,title:t.name,children:[f,t.name]}),e[20]=y,e[21]=t.name,e[22]=f,e[23]=N):N=e[23];let R=t.ok?"bg-primary/70":"bg-destructive",L;e[24]!==R?(L=te("absolute inset-y-0 rounded-sm",R),e[24]=R,e[25]=L):L=e[25];let E;e[26]!==h||e[27]!==i||e[28]!==L||e[29]!==u?(E=(0,s.jsx)("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:(0,s.jsx)("span",{className:L,"data-left":i,"data-testid":"tr-span-bar","data-width":u,style:h})}),e[26]=h,e[27]=i,e[28]=L,e[29]=u,e[30]=E):E=e[30];let W;e[31]!==t.durationMs?(W=G(t.durationMs),e[31]=t.durationMs,e[32]=W):W=e[32];let D;e[33]!==W?(D=(0,s.jsx)("span",{className:"text-right tabular-nums text-muted-foreground",children:W}),e[33]=W,e[34]=D):D=e[34];let q;e[35]!==t.error?(q=t.error===void 0?null:(0,s.jsx)("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=q):q=e[36];let T;e[37]!==q?(T=(0,s.jsx)("span",{className:"truncate text-muted-foreground",children:q}),e[37]=q,e[38]=T):T=e[38];let z;e[39]!==v?(z=v===""?null:(0,s.jsx)("span",{"data-testid":"tr-span-attributes",title:v,children:v}),e[39]=v,e[40]=z):z=e[40];let P;e[41]!==z?(P=(0,s.jsx)("span",{className:"truncate text-muted-foreground",children:z}),e[41]=z,e[42]=P):P=e[42];let J;e[43]!==r||e[44]!==I||e[45]!==g||e[46]!==k||e[47]!==N||e[48]!==E||e[49]!==D||e[50]!==T||e[51]!==P?(J=(0,s.jsxs)("button",{"aria-controls":I,"aria-expanded":r,"aria-label":g,className:x,"data-testid":k,onClick:C,type:"button",children:[N,E,D,T,P]}),e[43]=r,e[44]=I,e[45]=g,e[46]=k,e[47]=N,e[48]=E,e[49]=D,e[50]=T,e[51]=P,e[52]=J):J=e[52];let F;e[53]!==r||e[54]!==t?(F=r&&(0,s.jsx)("div",{id:`tr-span-detail-${t.spanId}`,children:(0,s.jsx)(Fe,{span:t})}),e[53]=r,e[54]=t,e[55]=F):F=e[55];let K;return e[56]!==t.depth||e[57]!==J||e[58]!==F?(K=(0,s.jsxs)("li",{"data-depth":S,"data-testid":"tr-span-row",children:[J,F]}),e[56]=t.depth,e[57]=J,e[58]=F,e[59]=K):K=e[59],K},"Be"),qe=m(n=>{let e=(0,B.c)(15),{durationMs:t,spans:a}=n,l=U(),r;e[0]!==t?(r=(0,s.jsx)(Re,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let d;if(e[4]!==t||e[5]!==a){let c;e[7]!==t?(c=m(v=>(0,s.jsx)(We,{span:v,traceDurationMs:t},v.spanId),"c"),e[7]=t,e[8]=c):c=e[8],d=a.map(c),e[4]=t,e[5]=a,e[6]=d}else d=e[6];let i;e[9]!==o||e[10]!==d?(i=(0,s.jsx)("ul",{"aria-label":o,children:d}),e[9]=o,e[10]=d,e[11]=i):i=e[11];let u;return e[12]!==r||e[13]!==i?(u=(0,s.jsxs)(s.Fragment,{children:[r,i]}),e[12]=r,e[13]=i,e[14]=u):u=e[14],u},"Oe");function ze(n){return(0,s.jsx)("span",{className:te("absolute inset-y-0 border-l border-border/70",n.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(n.percent)}%`},children:n.label},n.percent)}m(ze,"je");function Je(n){return!n}m(Je,"We");var Ue=m(n=>Array.isArray(n?.traces)?n.traces:[],"Ue"),Ge=m(n=>{let e=(0,B.c)(12),{entries:t}=n,a=U(),l;e[0]!==t.length||e[1]!==a?(l=a("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=a,e[2]=l):l=e[2];let r;e[3]!==l?(r=(0,s.jsx)("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(Qe),e[5]=t,e[6]=o):o=e[6];let d;e[7]!==o?(d=(0,s.jsx)("div",{role:"grid",children:o}),e[7]=o,e[8]=d):d=e[8];let i;return e[9]!==r||e[10]!==d?(i=(0,s.jsxs)("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,d]}),e[9]=r,e[10]=d,e[11]=i):i=e[11],i},"qe"),He=m(n=>{let e=(0,B.c)(50),{expanded:t,logs:a,onToggle:l,trace:r}=n,o=U(),d;e[0]!==l||e[1]!==r.traceId?(d=m(()=>{l(r.traceId)},"i"),e[0]=l,e[1]=r.traceId,e[2]=d):d=e[2];let i=d,u=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,v=`tr-toggle-${r.traceId}`,$=t?"\u25BE":"\u25B8",_;e[3]!==$?(_=(0,s.jsx)("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=_):_=e[4];let y;e[5]!==r.rootName?(y=(0,s.jsx)("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=y):y=e[6];let w;e[7]!==r.functionPath?(w=(0,s.jsx)("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=w):w=e[8];let M;e[9]!==r.durationMs?(M=G(r.durationMs),e[9]=r.durationMs,e[10]=M):M=e[10];let p;e[11]!==M?(p=(0,s.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:M}),e[11]=M,e[12]=p):p=e[12];let h;e[13]!==o||e[14]!==r.spans.length?(h=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=h):h=e[15];let b;e[16]!==h?(b=(0,s.jsx)("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:h}),e[16]=h,e[17]=b):b=e[17];let C=r.ok?"secondary":"destructive",S;e[18]!==o||e[19]!==r.ok?(S=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=S):S=e[20];let I;e[21]!==C||e[22]!==S?(I=(0,s.jsx)("span",{className:"shrink-0",children:(0,s.jsx)(oe,{variant:C,children:S})}),e[21]=C,e[22]=S,e[23]=I):I=e[23];let g;e[24]!==r.startTs?(g=de(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let x;e[26]!==g?(x=(0,s.jsx)("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=x):x=e[27];let k;e[28]!==t||e[29]!==i||e[30]!==p||e[31]!==b||e[32]!==I||e[33]!==x||e[34]!==c||e[35]!==v||e[36]!==_||e[37]!==y||e[38]!==w?(k=(0,s.jsxs)("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":v,onClick:i,type:"button",children:[_,y,w,p,b,I,x]}),e[28]=t,e[29]=i,e[30]=p,e[31]=b,e[32]=I,e[33]=x,e[34]=c,e[35]=v,e[36]=_,e[37]=y,e[38]=w,e[39]=k):k=e[39];let f;e[40]!==t||e[41]!==a||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(f=t&&(0,s.jsxs)("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[(0,s.jsx)(qe,{durationMs:r.durationMs,spans:r.spans}),a.length>0&&(0,s.jsx)(Ge,{entries:a})]}),e[40]=t,e[41]=a,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=f):f=e[45];let N;return e[46]!==k||e[47]!==f||e[48]!==u?(N=(0,s.jsxs)("div",{className:"border-b border-border last:border-b-0","data-testid":u,children:[k,f]}),e[46]=k,e[47]=f,e[48]=u,e[49]=N):N=e[49],N},"ze"),ft=m(n=>{let e=(0,B.c)(58),{initialShardKey:t}=n,a=U(),[l]=(0,O.useState)(ve),{queryShardKey:r,setShardKey:o,shardKey:d}=fe(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[i,u]=(0,O.useState)(l?.traceId??""),[c,v]=(0,O.useState)(!1),[$,_]=(0,O.useState)(Ae),y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],(0,O.useEffect)(Ve,y);let w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w={},e[1]=w):w=e[1];let M;e[2]!==r?(M={live:!0,shardKey:r},e[2]=r,e[3]=M):M=e[3];let{data:p,error:h,errorSource:b,isLoading:C,liveError:S}=ie(ce.getTraces,w,M),I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I={},e[4]=I):I=e[4];let g=$.size>0,x;e[5]!==r||e[6]!==g?(x={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=x):x=e[7];let{data:k}=ie(ce.getLogs,I,x),f,N;e[8]!==p||e[9]!==r?(f=m(()=>{p!==void 0&&pe(r)},"p"),N=[p,r],e[8]=p,e[9]=r,e[10]=f,e[11]=N):(f=e[10],N=e[11]),(0,O.useEffect)(f,N);let R;if(e[12]!==p||e[13]!==h||e[14]!==b||e[15]!==$||e[16]!==C||e[17]!==S||e[18]!==k?.entries||e[19]!==c||e[20]!==i||e[21]!==o||e[22]!==d||e[23]!==a){let L=Ue(p),E=p?.total??L.length,W=E>L.length,D=Ke(L,i,c),q=Map.groupBy((k?.entries??[]).toReversed(),Xe),T;e[25]===Symbol.for("react.memo_cache_sentinel")?(T=m(j=>{u(j.target.value)},"C"),e[25]=T):T=e[25];let z=T,P;e[26]===Symbol.for("react.memo_cache_sentinel")?(P=m(j=>{_(_e=>{let ne=new Set(_e);return ne.has(j)?ne.delete(j):ne.add(j),ne})},"E"),e[26]=P):P=e[26];let J=P,F=h===null&&D.length===0&&!C,K;e[27]!==o||e[28]!==d?(K=(0,s.jsx)(he,{onChange:o,testId:"tr-shard-input",value:d}),e[27]=o,e[28]=d,e[29]=K):K=e[29];let H;e[30]!==a?(H=a("Search traces"),e[30]=a,e[31]=H):H=e[31];let Q;e[32]!==a?(Q=a("search trace, span, or function"),e[32]=a,e[33]=Q):Q=e[33];let A;e[34]!==i||e[35]!==H||e[36]!==Q?(A=(0,s.jsx)(me,{"aria-label":H,className:"h-8 w-56","data-testid":"tr-search",onChange:z,placeholder:Q,value:i}),e[34]=i,e[35]=H,e[36]=Q,e[37]=A):A=e[37];let V;e[38]!==c?(V=(0,s.jsx)(ge,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:v}),e[38]=c,e[39]=V):V=e[39];let X;e[40]!==a?(X=a("Errors only"),e[40]=a,e[41]=X):X=e[41];let Y;e[42]!==V||e[43]!==X?(Y=(0,s.jsxs)("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[V,X]}),e[42]=V,e[43]=X,e[44]=Y):Y=e[44];let Z;e[45]!==S?(Z=(0,s.jsx)(xe,{message:S,prefix:"tr"}),e[45]=S,e[46]=Z):Z=e[46];let re;e[47]!==K||e[48]!==A||e[49]!==Y||e[50]!==Z?(re=(0,s.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[K,A,Y,Z]}),e[47]=K,e[48]=A,e[49]=Y,e[50]=Z,e[51]=re):re=e[51];let ae;e[52]!==h||e[53]!==b?(ae=h!==null&&(0,s.jsx)(be,{error:b,testId:"tr-error"}),e[52]=h,e[53]=b,e[54]=ae):ae=e[54];let se;e[55]!==F||e[56]!==a?(se=F&&(0,s.jsx)(ue,{description:a("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),icon:(0,s.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,s.jsx)("path",{d:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:a("No traces")}),e[55]=F,e[56]=a,e[57]=se):se=e[57],R=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[re,ae,se,h===null&&W&&(0,s.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:a("Showing the {shown} most recent of {total} traces in the buffer.",{shown:L.length,total:E})}),h===null&&D.length>0&&(0,s.jsx)("div",{"aria-label":a("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:D.map(j=>(0,s.jsx)(He,{expanded:$.has(j.traceId),logs:q.get(j.traceId)??[],onToggle:J,trace:j},j.traceId))})]}),e[12]=p,e[13]=h,e[14]=b,e[15]=$,e[16]=C,e[17]=S,e[18]=k?.entries,e[19]=c,e[20]=i,e[21]=o,e[22]=d,e[23]=a,e[24]=R}else R=e[24];return R},"gt");function Qe(n,e){return(0,s.jsx)("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:(0,s.jsx)(we,{entry:n})},`${String(e)}:${String(n.timestamp)}`)}m(Qe,"Ge");function Ae(){return new Set}m(Ae,"He");function Ve(){ye()}m(Ve,"Je");function Xe(n){return n.traceId}m(Xe,"Qe");export{ft as default};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-KQFH6FFC.js";import"./chunk-XZCNX7YU.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as I}from"./chunk-FKVZRPV5.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-HEAQVSNS.js";import{a as b,e as S}from"./chunk-WUWBZPUK.js";import{d as w}from"./chunk-FODLDLE2.js";import{a as f,d as y,f as _,g as j}from"./chunk-YKXDMIHQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
1
+ import{a as D}from"./chunk-BOTGXX4H.js";import{b as C}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import"./chunk-35DM4JJG.js";import{a as L}from"./chunk-4ZEL6BYL.js";import{c as $}from"./chunk-ZXRRPWQV.js";import"./chunk-XTLR2A7C.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as I}from"./chunk-FKVZRPV5.js";import{a as T,b as k,c as A,d as g,e as c,f as l}from"./chunk-HEAQVSNS.js";import{a as b,e as S}from"./chunk-WUWBZPUK.js";import{d as w}from"./chunk-FODLDLE2.js";import{a as f,d as y,f as _,g as j}from"./chunk-YKXDMIHQ.js";var O=y(_(),1);var t=y(j(),1);var E="container:",M={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=f(e=>{let n=e.indexOf(":");if(n===-1)return{event:e.trim()};let r=e.slice(n+1).trim(),a=e.slice(0,n).trim();return r===""?{event:a}:{detail:r,event:a}},"B"),P=f(e=>{let n=new Map;for(let r of e){let a=r.functionPath??"";if(!a.startsWith(E))continue;let i=a.slice(E.length);if(i==="")continue;let s=JSON.stringify([i,r.instance??""]),o=n.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;let{detail:p,event:d}=B(r.message);n.set(s,{detail:p,event:d,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:M[d]??"unknown",timestamp:r.timestamp})}return[...n.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},"D"),W={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},q=f(e=>{let{entries:n}=e??{};return Array.isArray(n)?n:[]},"P"),V=f(()=>{let e=(0,O.c)(19),n=w(),r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);let{data:i,error:s,liveError:o}=$(L.getLogs,r,a),p=i!==void 0,d;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==n){let N=P(q(i)),x;e[8]!==s?(x=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let m;e[10]!==n?(m=n("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance \u2014 ports and health checks aren't carried in that stream."),e[10]=n,e[11]=m):m=e[11];let u;e[12]!==m?(u=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=u):u=e[13];let h;e[14]!==o?(h=(0,t.jsx)(D,{message:o,prefix:"containers"}),e[14]=o,e[15]=h):h=e[15];let v;e[16]!==u||e[17]!==h?(v=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,h]}),e[16]=u,e[17]=h,e[18]=v):v=e[18],d=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&N.length===0?(0,t.jsx)(I,{description:n("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:n("No container activity")}):(0,t.jsx)(b,{className:"overflow-hidden py-0",children:(0,t.jsx)(S,{className:"px-0",children:(0,t.jsxs)(T,{"data-testid":"containers-table",children:[(0,t.jsx)(k,{children:(0,t.jsxs)(g,{children:[(0,t.jsx)(c,{children:n("Container")}),(0,t.jsx)(c,{children:n("Instance")}),(0,t.jsx)(c,{children:n("State")}),(0,t.jsx)(c,{children:n("Last event")}),(0,t.jsx)(c,{children:n("Detail")}),(0,t.jsx)(c,{children:n("Exit")}),(0,t.jsx)(c,{children:n("When")})]})}),(0,t.jsx)(A,{children:N.map(F)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=n,e[7]=d}else d=e[7];return d},"q");function F(e){return(0,t.jsxs)(g,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[(0,t.jsx)(l,{className:"font-mono text-xs",children:e.name}),(0,t.jsx)(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"\u2014"}),(0,t.jsx)(l,{children:(0,t.jsx)(C,{variant:W[e.state],children:e.state})}),(0,t.jsx)(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),(0,t.jsx)(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"\u2014"}),(0,t.jsx)(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"\u2014"}),(0,t.jsx)(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}f(F,"j");export{V as default};
@@ -1 +1 @@
1
- import{a as E}from"./chunk-66UGPQVC.js";import{a as w}from"./chunk-EBWXFG4H.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import"./chunk-25NFR6EB.js";import{b as T}from"./chunk-KQFH6FFC.js";import{f as A}from"./chunk-XZCNX7YU.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as j}from"./chunk-FKVZRPV5.js";import{a as _,b as $,c as C,d as g,e as o,f as l}from"./chunk-HEAQVSNS.js";import{a as I,e as S}from"./chunk-WUWBZPUK.js";import{d as k,o as B,r as R}from"./chunk-FODLDLE2.js";import{a as h,d as y,f as K,g as L}from"./chunk-YKXDMIHQ.js";var H=y(K(),1);var s=y(L(),1);var z=200,U=h(()=>{let e=(0,H.c)(21),n=A(),t=k(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-auth-sessions",z],e[0]=u):u=e[0];let p;e[1]!==n?(p=h(()=>n.listAuthSessions({limit:z}),"u"),e[1]=n,e[2]=p):p=e[2];let a=T(u,p),{error:f}=a,i=a.data?.rows??null,x;e[3]!==a?(x=h(()=>{a.refetch()},"p"),e[3]=a,e[4]=x):x=e[4],E(x,!0);let N;e[5]!==n||e[6]!==a?(N=h(r=>{B((async()=>{await n.revokeAuthSession({sessionId:r}),a.refetch()})())},"x"),e[5]=n,e[6]=a,e[7]=N):N=e[7];let v=N,d;e[8]!==f?(d=f!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=d):d=e[9];let c;e[10]!==i||e[11]!==t?(c=i!==null&&i.length===0&&(0,s.jsx)(j,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=i,e[11]=t,e[12]=c):c=e[12];let m;e[13]!==v||e[14]!==i||e[15]!==t?(m=i!==null&&i.length>0&&(0,s.jsx)(I,{className:"overflow-hidden py-0",children:(0,s.jsx)(S,{className:"px-0",children:(0,s.jsxs)(_,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)($,{children:(0,s.jsxs)(g,{children:[(0,s.jsx)(o,{children:t("user")}),(0,s.jsx)(o,{children:t("expires")}),(0,s.jsx)(o,{children:t("ip")}),(0,s.jsx)(o,{children:t("user agent")}),(0,s.jsx)(o,{children:t("impersonated by")}),(0,s.jsx)(o,{"aria-label":t("Actions")})]})}),(0,s.jsx)(C,{children:i.map(r=>(0,s.jsxs)(g,{"data-testid":`auth-session-${r.id}`,children:[(0,s.jsx)(l,{className:"font-mono text-xs",children:r.userId}),(0,s.jsx)(l,{className:"text-muted-foreground tabular-nums",children:R(r.expiresAt)}),(0,s.jsx)(l,{children:r.ipAddress??""}),(0,s.jsx)(l,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,s.jsx)(l,{className:"font-mono text-xs",children:r.impersonatedBy??""}),(0,s.jsx)(l,{children:(0,s.jsx)(w,{"data-testid":`auth-session-revoke-${r.id}`,onClick:h(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},r.id))})]})})}),e[13]=v,e[14]=i,e[15]=t,e[16]=m):m=e[16];let b;return e[17]!==d||e[18]!==c||e[19]!==m?(b=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[d,c,m]}),e[17]=d,e[18]=c,e[19]=m,e[20]=b):b=e[20],b},"K");export{U as default};
1
+ import{a as E}from"./chunk-66UGPQVC.js";import{a as w}from"./chunk-EBWXFG4H.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import"./chunk-25NFR6EB.js";import{b as T}from"./chunk-ZXRRPWQV.js";import{f as A}from"./chunk-XTLR2A7C.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as j}from"./chunk-FKVZRPV5.js";import{a as _,b as $,c as C,d as g,e as o,f as l}from"./chunk-HEAQVSNS.js";import{a as I,e as S}from"./chunk-WUWBZPUK.js";import{d as k,o as B,r as R}from"./chunk-FODLDLE2.js";import{a as h,d as y,f as K,g as L}from"./chunk-YKXDMIHQ.js";var H=y(K(),1);var s=y(L(),1);var z=200,U=h(()=>{let e=(0,H.c)(21),n=A(),t=k(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=["lunora-auth-sessions",z],e[0]=u):u=e[0];let p;e[1]!==n?(p=h(()=>n.listAuthSessions({limit:z}),"u"),e[1]=n,e[2]=p):p=e[2];let a=T(u,p),{error:f}=a,i=a.data?.rows??null,x;e[3]!==a?(x=h(()=>{a.refetch()},"p"),e[3]=a,e[4]=x):x=e[4],E(x,!0);let N;e[5]!==n||e[6]!==a?(N=h(r=>{B((async()=>{await n.revokeAuthSession({sessionId:r}),a.refetch()})())},"x"),e[5]=n,e[6]=a,e[7]=N):N=e[7];let v=N,d;e[8]!==f?(d=f!==null&&(0,s.jsx)("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=d):d=e[9];let c;e[10]!==i||e[11]!==t?(c=i!==null&&i.length===0&&(0,s.jsx)(j,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=i,e[11]=t,e[12]=c):c=e[12];let m;e[13]!==v||e[14]!==i||e[15]!==t?(m=i!==null&&i.length>0&&(0,s.jsx)(I,{className:"overflow-hidden py-0",children:(0,s.jsx)(S,{className:"px-0",children:(0,s.jsxs)(_,{"data-testid":"auth-sessions-table",children:[(0,s.jsx)($,{children:(0,s.jsxs)(g,{children:[(0,s.jsx)(o,{children:t("user")}),(0,s.jsx)(o,{children:t("expires")}),(0,s.jsx)(o,{children:t("ip")}),(0,s.jsx)(o,{children:t("user agent")}),(0,s.jsx)(o,{children:t("impersonated by")}),(0,s.jsx)(o,{"aria-label":t("Actions")})]})}),(0,s.jsx)(C,{children:i.map(r=>(0,s.jsxs)(g,{"data-testid":`auth-session-${r.id}`,children:[(0,s.jsx)(l,{className:"font-mono text-xs",children:r.userId}),(0,s.jsx)(l,{className:"text-muted-foreground tabular-nums",children:R(r.expiresAt)}),(0,s.jsx)(l,{children:r.ipAddress??""}),(0,s.jsx)(l,{className:"max-w-40 truncate",children:r.userAgent??""}),(0,s.jsx)(l,{className:"font-mono text-xs",children:r.impersonatedBy??""}),(0,s.jsx)(l,{children:(0,s.jsx)(w,{"data-testid":`auth-session-revoke-${r.id}`,onClick:h(()=>{v(r.id)},"onClick"),size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},r.id))})]})})}),e[13]=v,e[14]=i,e[15]=t,e[16]=m):m=e[16];let b;return e[17]!==d||e[18]!==c||e[19]!==m?(b=(0,s.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[d,c,m]}),e[17]=d,e[18]=c,e[19]=m,e[20]=b):b=e[20],b},"K");export{U as default};