@lunora/studio 1.0.0-alpha.323 → 1.0.0-alpha.325

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/standalone/{chunk-WP2AS7SZ.js → chunk-3S4PZ7KQ.js} +1 -1
  2. package/dist/standalone/{chunk-ESSG4L6C.js → chunk-3T4K7XUT.js} +1 -1
  3. package/dist/standalone/{chunk-EXYBVVHU.js → chunk-4HBHTD3A.js} +1 -1
  4. package/dist/standalone/{chunk-NDGHCEE3.js → chunk-4UKHYUNB.js} +1 -1
  5. package/dist/standalone/{chunk-6YQ3RTCB.js → chunk-5BLNLZXF.js} +1 -1
  6. package/dist/standalone/{chunk-2QLSWJDL.js → chunk-5LBBEWDQ.js} +1 -1
  7. package/dist/standalone/{chunk-WFNUMMDF.js → chunk-5QYM3MYE.js} +2 -2
  8. package/dist/standalone/{chunk-SB4443ME.js → chunk-7PER26LF.js} +1 -1
  9. package/dist/standalone/{chunk-U4YBJ4OW.js → chunk-7Q6GOHAD.js} +1 -1
  10. package/dist/standalone/{chunk-NYHYH5Z5.js → chunk-7UQC3B6P.js} +1 -1
  11. package/dist/standalone/{chunk-3YH5TM3G.js → chunk-7VJPXCOU.js} +1 -1
  12. package/dist/standalone/{chunk-DL6TTBE6.js → chunk-A5U37V2S.js} +1 -1
  13. package/dist/standalone/{chunk-R4ILI46D.js → chunk-ASA7UJIH.js} +1 -1
  14. package/dist/standalone/chunk-BWKZ6FFW.js +9 -0
  15. package/dist/standalone/{chunk-QZRKA2E4.js → chunk-CDB3QQA6.js} +1 -1
  16. package/dist/standalone/{chunk-2JH7ZYVY.js → chunk-CGYVHQAD.js} +1 -1
  17. package/dist/standalone/{chunk-4Y5AFETG.js → chunk-CQ23LQGY.js} +1 -1
  18. package/dist/standalone/{chunk-4K6CXILB.js → chunk-CVBWPFHY.js} +1 -1
  19. package/dist/standalone/{chunk-MTGFTTXO.js → chunk-CY7FSXYX.js} +1 -1
  20. package/dist/standalone/{chunk-Z6THFOLU.js → chunk-CZKN2SRN.js} +1 -1
  21. package/dist/standalone/{chunk-N7LJO732.js → chunk-DYR23C3V.js} +2 -2
  22. package/dist/standalone/{chunk-HER5A45F.js → chunk-EOE2E73Q.js} +1 -1
  23. package/dist/standalone/{chunk-QSUWAGXH.js → chunk-FSXPV7YQ.js} +1 -1
  24. package/dist/standalone/{chunk-SQ2LCZBH.js → chunk-HXR3HVAR.js} +1 -1
  25. package/dist/standalone/{chunk-JNBWPXNV.js → chunk-HY7DUJVI.js} +1 -1
  26. package/dist/standalone/{chunk-SNJ5HRZO.js → chunk-IZ3OOKZL.js} +1 -1
  27. package/dist/standalone/{chunk-XTQR2C6N.js → chunk-JN2DUGT5.js} +1 -1
  28. package/dist/standalone/{chunk-JL6LEVHQ.js → chunk-JSGD6M6E.js} +1 -1
  29. package/dist/standalone/{chunk-MB5JGSN6.js → chunk-KHCM76LG.js} +1 -1
  30. package/dist/standalone/{chunk-7AF3FZCB.js → chunk-LJIMLABC.js} +1 -1
  31. package/dist/standalone/{chunk-ICU56FBP.js → chunk-LLN6LEHZ.js} +1 -1
  32. package/dist/standalone/{chunk-NW6FNJ4L.js → chunk-LU6UOZWK.js} +1 -1
  33. package/dist/standalone/{chunk-3OHVDOV5.js → chunk-MK4H5D3L.js} +1 -1
  34. package/dist/standalone/{chunk-POKVFO6Q.js → chunk-NTZX6RJQ.js} +1 -1
  35. package/dist/standalone/{chunk-OM3B3V47.js → chunk-P2OIRN2O.js} +1 -1
  36. package/dist/standalone/{chunk-5WOMOENH.js → chunk-PLPA2F6L.js} +1 -1
  37. package/dist/standalone/{chunk-MJ3SSK6L.js → chunk-QLKZIBWQ.js} +1 -1
  38. package/dist/standalone/{chunk-OK35SLOW.js → chunk-QPZG3NV6.js} +1 -1
  39. package/dist/standalone/{chunk-DSIY2CMT.js → chunk-QUXXMJPZ.js} +1 -1
  40. package/dist/standalone/{chunk-UDMY3BMT.js → chunk-QZRACAES.js} +1 -1
  41. package/dist/standalone/{chunk-ZJQI4C3A.js → chunk-R2GYDPPC.js} +1 -1
  42. package/dist/standalone/{chunk-7RAYXTNN.js → chunk-R73OPTTE.js} +1 -1
  43. package/dist/standalone/{chunk-KU3IXE36.js → chunk-RI6LCPJQ.js} +1 -1
  44. package/dist/standalone/{chunk-RBAD4SMG.js → chunk-SMCCFWX3.js} +1 -1
  45. package/dist/standalone/{chunk-RDJCY5PQ.js → chunk-SR2FQOVJ.js} +1 -1
  46. package/dist/standalone/{chunk-22TUDRBR.js → chunk-SUTA66KR.js} +1 -1
  47. package/dist/standalone/{chunk-6MFVEI7C.js → chunk-SYPUVLW6.js} +1 -1
  48. package/dist/standalone/{chunk-F3UUFO2C.js → chunk-U6IDPJGC.js} +1 -1
  49. package/dist/standalone/{chunk-HM57YJY5.js → chunk-UMHLRQOR.js} +1 -1
  50. package/dist/standalone/{chunk-VFL7VJWF.js → chunk-UPO3FC7D.js} +1 -1
  51. package/dist/standalone/{chunk-HOGQLP3J.js → chunk-VBUNOAPR.js} +1 -1
  52. package/dist/standalone/{chunk-VKURTWDH.js → chunk-VNHJSWBS.js} +1 -1
  53. package/dist/standalone/{chunk-KLTGKTSL.js → chunk-VRG5BACA.js} +1 -1
  54. package/dist/standalone/{chunk-TIQ7OBZJ.js → chunk-WHDFMKYB.js} +1 -1
  55. package/dist/standalone/{chunk-MRJB4FPI.js → chunk-WHJDJ4OD.js} +1 -1
  56. package/dist/standalone/{chunk-MGEACGEE.js → chunk-WTNHJS56.js} +1 -1
  57. package/dist/standalone/{chunk-CUJGTNYR.js → chunk-WY5WGFM3.js} +1 -1
  58. package/dist/standalone/{chunk-WAX5WY6F.js → chunk-X4JXFRIZ.js} +1 -1
  59. package/dist/standalone/{chunk-WJHMDTV2.js → chunk-XEKXUZWX.js} +1 -1
  60. package/dist/standalone/{chunk-OX6JWCPF.js → chunk-XXMXVSAN.js} +1 -1
  61. package/dist/standalone/{chunk-W3LXMSGC.js → chunk-Y2DTPEO4.js} +1 -1
  62. package/dist/standalone/{chunk-2H5IXFGR.js → chunk-Y2O72Z46.js} +1 -1
  63. package/dist/standalone/{chunk-OH7DVC7S.js → chunk-ZCQJFVF2.js} +1 -1
  64. package/dist/standalone/{chunk-R6PJYMJT.js → chunk-ZNVNSNDU.js} +1 -1
  65. package/dist/standalone/{chunk-EEDIMNRC.js → chunk-ZRB4HPDU.js} +1 -1
  66. package/dist/standalone/studio.js +1 -1
  67. package/package.json +5 -5
  68. package/dist/standalone/chunk-BOYS4DOC.js +0 -9
@@ -1,4 +1,4 @@
1
- import{a as gn,b as $e,e as Vr,f as zr}from"./chunk-NDTQTKDX.js";import{a as Tr,b as pt,c as Er,d as fn}from"./chunk-R6PJYMJT.js";import{a as mn}from"./chunk-S4Z7K55A.js";import{b as dn}from"./chunk-5B2RTXBS.js";import{d as $r}from"./chunk-UYEZR3BI.js";import{a as un}from"./chunk-Q6IT6ZD7.js";import{a as Le}from"./chunk-CGQMJYCW.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as cn}from"./chunk-7RKB5KS7.js";import{a as Ht}from"./chunk-QJLHH3ET.js";import{a as so}from"./chunk-37WYCOQ2.js";import{a as sn}from"./chunk-Z22BDS6N.js";import{a as Or}from"./chunk-JQXA2OYK.js";import{b as yr,c as oo}from"./chunk-CCDX5RYT.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import{a as io}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as ao}from"./chunk-XHRKNCCI.js";import{a as Mr}from"./chunk-YVR4SEPU.js";import{a as Ir,b as Fr}from"./chunk-ZKJS6EBE.js";import{b as vr,c as Rr,f as ro}from"./chunk-RGMVGZV4.js";import{c as br,d as hr,e as wr,f as it,g as on,h as xr,i as Sr}from"./chunk-OQ6I6OXT.js";import{i as _r}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as rn}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as _e}from"./chunk-4ZEL6BYL.js";import{b as no,c as ct}from"./chunk-DSIY2CMT.js";import{b as Zn,c as eo,d as nn,e as pr,l as nt}from"./chunk-BOYS4DOC.js";import"./chunk-QAQDMS6R.js";import"./chunk-N7LJO732.js";import{a as ln}from"./chunk-RWVIV3U7.js";import{a as kr,b as Pr,c as Nr,d as lo,e as Dr,f as Ar}from"./chunk-HCTJKP5J.js";import{d as oe,f as Ve,g as ze,h as $t,m as to,n as an,o as Te,p as re,t as Cr}from"./chunk-HJHSQPHW.js";import{a as o,d as Me,e as gt,f as Vt,g as zt,i as ft}from"./chunk-I26MS5PJ.js";var Os=Me(Vt(),1);var Ot=Me(gt(),1);var q=Me(Vt(),1);var D=Me(gt(),1);var Rt=Me(Vt(),1);var Y=Me(zt(),1),ot=Me(gt(),1);var mi=2166136261,gi=16777619,fi=o((t,e=mi)=>{let n=e;for(let l=0;l<t.length;l+=1)n^=t.charCodeAt(l),n=Math.imul(n,gi);return(n>>>0).toString(16).padStart(8,"0")},"I"),pi=/([a-z\d])([A-Z])/gu,bi=/[\s_-]+/u,hi=new Set(["access_token","api_key","apikey","card_number","client_secret","credit_card","cvv","passwd","password","private_key","pwd","refresh_token","secret","ssn","token"]),wi=o(t=>{let e=t.replaceAll(pi,"$1 $2").split(bi).map(l=>l.toLowerCase()).filter(l=>l.length>0),n=new Set(e);for(let l=0;l<e.length-1;l+=1){let r=e[l],a=e[l+1];r===void 0||a===void 0||(n.add(`${r}${a}`),n.add(`${r}_${a}`))}return[...n]},"le"),Hr="\u2022\u2022\u2022",Kr=o((t,e)=>{try{return e==="redact"?null:e==="hash"?t==null?t:fi(typeof t=="bigint"?t.toString():typeof t=="string"?t:JSON.stringify(t)):Hr}catch{return Hr}},"W"),Lr=o((t,e)=>{let n=new Map;for(let l of t)l.table===e&&n.set(l.column,l.strategy);return n},"j"),xi=o(t=>{for(let e of wi(t))if(hi.has(e))return!0;return!1},"ae"),jr=o((t,e)=>{let n=e.filter(r=>!t.has(r)&&xi(r));if(n.length===0)return t;let l=new Map(t);for(let r of n)l.set(r,"redact");return l},"z"),Lt=o((t,e,n)=>{if(!n.enabled)return t;let l=n.columns.get(e);return l===void 0?t:Kr(t,l)},"Ce"),pn=o((t,e)=>{if(!e.enabled||e.columns.size===0)return t;let n={...t};for(let[l,r]of e.columns)l in n&&(n[l]=Kr(n[l],r));return n},"ce"),bn=o((t,e)=>!e.enabled||e.columns.size===0?t:t.map(n=>pn(n,e)),"Fe"),Br=o(t=>t==null?"\u2205":t===""?"(empty)":Te(t),"B"),Si=o(t=>{let e=(0,Rt.c)(32),{column:n,onFacetFilter:l,state:r}=t,a=oe(),s;e[0]!==n||e[1]!==l||e[2]!==r.result?.values?(s=o(w=>{let _=Number(w.currentTarget.dataset.index),S=r.result?.values[_];S!==void 0&&l(n,S.value)},"x"),e[0]=n,e[1]=l,e[2]=r.result?.values,e[3]=s):s=e[3];let i=s,c=`db-facet-${n}`,u;e[4]!==n?(u=(0,Y.jsx)("span",{className:"font-medium text-foreground",children:n}),e[4]=n,e[5]=u):u=e[5];let d;e[6]!==r.loading||e[7]!==r.result||e[8]!==a?(d=r.loading&&r.result===null&&(0,Y.jsx)("span",{className:"text-muted-foreground",children:a("Loading\u2026")}),e[6]=r.loading,e[7]=r.result,e[8]=a,e[9]=d):d=e[9];let g;e[10]!==r.error?(g=r.error!==null&&(0,Y.jsx)("span",{className:"text-destructive",role:"alert",children:r.error}),e[10]=r.error,e[11]=g):g=e[11];let m;e[12]!==r.result?.values?(m=r.result?.values??[],e[12]=r.result?.values,e[13]=m):m=e[13];let h;if(e[14]!==n||e[15]!==i||e[16]!==m){let w;e[18]!==n||e[19]!==i?(w=o((_,S)=>(0,Y.jsxs)("button",{className:"flex items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground","data-index":S,"data-testid":`db-facet-value-${n}`,onClick:i,type:"button",children:[(0,Y.jsx)("span",{className:"truncate",children:Br(_.value)}),(0,Y.jsx)("span",{className:"shrink-0 tabular-nums text-foreground/70",children:_.count})]},Br(_.value)),"c"),e[18]=n,e[19]=i,e[20]=w):w=e[20],h=m.map(w),e[14]=n,e[15]=i,e[16]=m,e[17]=h}else h=e[17];let p;e[21]!==n||e[22]!==r.result||e[23]!==a?(p=r.result?.truncated===!0&&(0,Y.jsx)("span",{className:"text-muted-foreground","data-testid":`db-facet-truncated-${n}`,children:a("Showing the {n} most common values.",{n:r.result.values.length})}),e[21]=n,e[22]=r.result,e[23]=a,e[24]=p):p=e[24];let b;return e[25]!==c||e[26]!==u||e[27]!==d||e[28]!==g||e[29]!==h||e[30]!==p?(b=(0,Y.jsxs)("section",{className:"flex flex-col gap-1","data-testid":c,children:[u,d,g,h,p]}),e[25]=c,e[26]=u,e[27]=d,e[28]=g,e[29]=h,e[30]=p,e[31]=b):b=e[31],b},"ie"),hn=o(t=>{let e=(0,Rt.c)(44),{columns:n,facets:l,mask:r,onFacetFilter:a,onToggleFacet:s}=t,i=oe(),c;e[0]!==s?(c=o(y=>{let{column:M}=y.currentTarget.dataset;M!==void 0&&s(M)},"o"),e[0]=s,e[1]=c):c=e[1];let u=c,d;e[2]!==r?(d=o(y=>r.enabled&&r.columns.has(y),"a"),e[2]=r,e[3]=d):d=e[3];let g=d,m,h,p,b,w,_,S,v;if(e[4]!==n||e[5]!==l||e[6]!==g||e[7]!==i||e[8]!==u){v=Symbol.for("react.early_return_sentinel");e:{let y;e[17]!==g?(y=o(N=>!g(N),"y"),e[17]=g,e[18]=y):y=e[18];let M=n.filter(y),F;if(e[19]!==l||e[20]!==g?(F=Object.entries(l).filter(N=>{let[A]=N;return!g(A)}),e[19]=l,e[20]=g,e[21]=F):F=e[21],m=F,M.length===0){v=null;break e}_="flex w-56 shrink-0 flex-col gap-3 overflow-auto border-l border-border p-3 text-xs",S="db-facets",b="flex flex-col gap-1.5";let P;e[22]!==i?(P=i("Facets"),e[22]=i,e[23]=P):P=e[23],e[24]!==P?(w=(0,Y.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:P}),e[24]=P,e[25]=w):w=e[25],h="flex flex-wrap gap-1";let k;e[26]!==l||e[27]!==u?(k=o(N=>(0,Y.jsx)("button",{"aria-pressed":N in l,className:"rounded border border-border px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-column":N,"data-testid":`db-facet-toggle-${N}`,onClick:u,type:"button",children:N},N),"A"),e[26]=l,e[27]=u,e[28]=k):k=e[28],p=M.map(k)}e[4]=n,e[5]=l,e[6]=g,e[7]=i,e[8]=u,e[9]=m,e[10]=h,e[11]=p,e[12]=b,e[13]=w,e[14]=_,e[15]=S,e[16]=v}else m=e[9],h=e[10],p=e[11],b=e[12],w=e[13],_=e[14],S=e[15],v=e[16];if(v!==Symbol.for("react.early_return_sentinel"))return v;let I;e[29]!==h||e[30]!==p?(I=(0,Y.jsx)("div",{className:h,children:p}),e[29]=h,e[30]=p,e[31]=I):I=e[31];let C;e[32]!==I||e[33]!==b||e[34]!==w?(C=(0,Y.jsxs)("div",{className:b,children:[w,I]}),e[32]=I,e[33]=b,e[34]=w,e[35]=C):C=e[35];let R;e[36]!==a||e[37]!==m?(R=m.map(y=>{let[M,F]=y;return(0,Y.jsx)(Si,{column:M,onFacetFilter:a,state:F},M)}),e[36]=a,e[37]=m,e[38]=R):R=e[38];let x;return e[39]!==C||e[40]!==R||e[41]!==_||e[42]!==S?(x=(0,Y.jsxs)("aside",{className:_,"data-testid":S,children:[C,R]}),e[39]=C,e[40]=R,e[41]=_,e[42]=S,e[43]=x):x=e[43],x},"_e"),wn=o(()=>{let[t,e]=(0,ot.useState)({}),n=Le(t),l=(0,ot.useRef)({}),r=o(async(a,s)=>{let i=(l.current[a]??0)+1;l.current[a]=i,e(c=>a in c?{...c,[a]:{error:null,loading:!0,result:c[a]?.result??null}}:c);try{let c=await s(a);if(l.current[a]!==i)return;e(u=>a in u?{...u,[a]:{error:null,loading:!1,result:c}}:u)}catch(c){if(l.current[a]!==i)return;e(u=>a in u?{...u,[a]:{error:$t(c),loading:!1,result:null}}:u)}},"n");return{clearFacets:o(()=>{e({})},"clearFacets"),facets:t,facetsRef:n,refetchFacets:o(a=>{for(let s of Object.keys(n.current))re(r(s,a))},"refetchFacets"),toggleFacet:o((a,s)=>{if(a in n.current){e(i=>Object.fromEntries(Object.entries(i).filter(([c])=>c!==a)));return}e(i=>({...i,[a]:{error:null,loading:!0,result:null}})),s!==null&&re(r(a,s))},"toggleFacet")}},"Me"),_i=[],Ci=o(()=>{let t=(0,Rt.c)(1),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={},t[0]=e):e=t[0];let{data:n}=ct(_e.maskPolicies,e);return Array.isArray(n?.columns)?n.columns:_i},"de"),xn=o(t=>{let e=(0,Rt.c)(16),{columns:n,selectedTable:l}=t,r=Ci(),[a,s]=(0,ot.useState)(!0),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o(()=>{s(yi)},"g"),e[0]=i):i=e[0];let c=i,u;if(e[1]!==n||e[2]!==r||e[3]!==l){let b=Lr(r,l??"");u=jr(b,n),e[1]=n,e[2]=r,e[3]=l,e[4]=u}else u=e[4];let d=u,g;e[5]!==a||e[6]!==r?(g=o((b,w)=>({columns:jr(Lr(r,b),w),enabled:a}),"l"),e[5]=a,e[6]=r,e[7]=g):g=e[7];let m=g,h;e[8]!==d||e[9]!==a?(h={columns:d,enabled:a},e[8]=d,e[9]=a,e[10]=h):h=e[10];let p;return e[11]!==d||e[12]!==a||e[13]!==m||e[14]!==h?(p={maskColumns:d,maskOn:a,maskView:h,maskViewFor:m,onToggleMask:c},e[11]=d,e[12]=a,e[13]=m,e[14]=h,e[15]=p):p=e[15],p},"Te");function yi(t){return!t}o(yi,"fe");var Gr=34,qr=600,vi=o(t=>{let e=(0,Rt.c)(21),{item:n,onSelect:l,prefix:r,selected:a,start:s}=t,i;e[0]!==n.name||e[1]!==l?(i=o(()=>{l(n.name)},"g"),e[0]=n.name,e[1]=l,e[2]=i):i=e[2];let c=i,u=`translateY(${String(s)}px)`,d;e[3]!==u?(d={insetInline:0,position:"absolute",top:0,transform:u},e[3]=u,e[4]=d):d=e[4];let g=d,m=a?"bg-accent font-medium text-accent-foreground":"text-foreground",h;e[5]!==m?(h=ft("flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-start text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent",m),e[5]=m,e[6]=h):h=e[6];let p=`${r}-table-${n.name}`,b;e[7]!==n.name?(b=(0,Y.jsx)("span",{className:"truncate",children:n.name}),e[7]=n.name,e[8]=b):b=e[8];let w;e[9]!==n.rowCount?(w=(0,Y.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 text-xs tabular-nums text-muted-foreground",children:n.rowCount}),e[9]=n.rowCount,e[10]=w):w=e[10];let _;e[11]!==c||e[12]!==a||e[13]!==h||e[14]!==p||e[15]!==b||e[16]!==w?(_=(0,Y.jsxs)("button",{"aria-pressed":a,className:h,"data-testid":p,onClick:c,type:"button",children:[b,w]}),e[11]=c,e[12]=a,e[13]=h,e[14]=p,e[15]=b,e[16]=w,e[17]=_):_=e[17];let S;return e[18]!==g||e[19]!==_?(S=(0,Y.jsx)("li",{style:g,children:_}),e[18]=g,e[19]=_,e[20]=S):S=e[20],S},"me"),Sn=o(({header:t,onReload:e,onSelect:n,prefix:l,reloadLabel:r,selected:a,tables:s})=>{let i=oe(),[c,u]=(0,ot.useState)(""),d=(0,ot.useRef)(null),g=o(b=>{u(b.target.value)},"l"),m=(0,ot.useMemo)(()=>{let b=c.trim().toLowerCase();return b===""?s:s.filter(w=>w.name.toLowerCase().includes(b))},[c,s]),h=dn({count:m.length,estimateSize:o(()=>Gr,"estimateSize"),getScrollElement:o(()=>d.current,"getScrollElement"),initialRect:{height:qr,width:240},observeElementRect:o((b,w)=>mn(b,w,qr),"observeElementRect"),overscan:12}).getVirtualItems(),p={height:m.length*Gr};return(0,Y.jsxs)("aside",{className:"flex h-full w-60 shrink-0 flex-col border-e border-border bg-sidebar","data-testid":`${l}-table-list`,children:[t,(0,Y.jsxs)("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border px-3",children:[(0,Y.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:i("Tables")}),e!==void 0&&(0,Y.jsx)("button",{"aria-label":r??i("Refresh"),className:"flex size-6 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent","data-testid":`${l}-load-tables`,onClick:e,title:r??i("Refresh"),type:"button",children:(0,Y.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,Y.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})})})]}),(0,Y.jsx)("div",{className:"shrink-0 border-b border-border p-2",children:(0,Y.jsx)("input",{className:"h-7 w-full rounded-md border border-border bg-background px-2 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring","data-testid":`${l}-table-search`,onChange:g,placeholder:i("search table\u2026"),type:"search",value:c})}),(0,Y.jsxs)("ul",{className:"relative flex-1 overflow-y-auto p-1.5","data-testid":`${l}-table-list-rows`,ref:d,children:[(0,Y.jsx)("li",{"aria-hidden":"true",style:p}),h.map(b=>{let w=m[b.index];return w===void 0?null:(0,Y.jsx)(vi,{item:w,onSelect:n,prefix:l,selected:a===w.name,start:b.start},w.name)})]})]})},"$e");var f=Me(zt(),1);var Ur=Me(gt(),1);function Ri(t){return Ii(t)||typeof t=="function"||Fi(t)}o(Ri,"isReactComponent");function Ii(t){return typeof t=="function"&&(()=>{let e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}o(Ii,"isClassComponent");function Fi(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}o(Fi,"isExoticComponent");function bt(t,e){return t==null?null:Ri(t)?Ur.default.createElement(t,e):t}o(bt,"flexRender");function co(t){if("cell"in t&&t.cell){let e=t.cell,n=e.column.columnDef,l=e,r=n;return l.getIsAggregated?.()?bt(r.aggregatedCell??n.cell,e.getContext()):l.getIsPlaceholder?.()?null:bt(n.cell,e.getContext())}return"header"in t&&t.header?bt(t.header.column.columnDef.header,t.header.getContext()):"footer"in t&&t.footer?bt(t.footer.column.columnDef.footer,t.footer.getContext()):null}o(co,"FlexRender");function Jr(t){let e=on(t.source,t.selector,{compare:it});return typeof t.children=="function"?t.children(e):t.children}o(Jr,"Subscribe");function Wr(t){let e=t;return Object.defineProperty(t,"state",{get(){return t.get()}}),"set"in t&&(e.setState=t.set.bind(t)),e}o(Wr,"atomToStore");function uo(t){let{createAtom:e,batch:n}=t,l=e(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:o(()=>{throw new Error("Feature not supported in current reactivity implementation")},"addSubscription"),unmount:o(()=>{throw new Error("Feature not supported in current reactivity implementation")},"unmount"),schedule:t.schedule??(r=>queueMicrotask(r)),batch:n,untrack:o(r=>r(),"untrack"),createReadonlyAtom:o((r,a)=>{let s=a?.compare??Object.is,i=!1,c,u=o(()=>{let g=r();return(!i||!s(c,g))&&(c=g,i=!0),c},"getSnapshot"),d=e(()=>(l.get(),u()),{compare:s});return{get:u,subscribe:d.subscribe.bind(d)}},"createReadonlyAtom"),createWritableAtom:o((r,a)=>e(r,{compare:a?.compare}),"createWritableAtom"),commit:o(()=>{l.set(r=>r+1)},"commit")}}o(uo,"renderPhaseReactivity");function mo(t,e=Object.is){let n=!1,l;return{get:t.get,markCommitted:o(r=>{l=r,n=!0},"markCommitted"),subscribe:o(r=>t.subscribe(a=>{(!n||!e(l,a))&&r(a)}),"subscribe")}}o(mo,"createRenderPhaseSource");function Qr(){return uo({createAtom:wr,batch:hr})}o(Qr,"reactReactivity");function It(t,e){return typeof t=="function"?t(e):t}o(It,"functionalUpdate");function ie(t){if(Array.isArray(t))return t.map(ie);if(t&&typeof t=="object"){let e=Object.getPrototypeOf(t);if(e!==Object.prototype&&e!==null)return t;let n=e===null?H():{},l=Object.keys(t);for(let r=0;r<l.length;r++){let a=l[r];Object.defineProperty(n,a,{configurable:!0,enumerable:!0,value:ie(t[a]),writable:!0})}return n}return t}o(ie,"cloneState");function _n(t,e){let n=Object.keys(e),l=t;for(let r=0;r<n.length;r++){let a=n[r];!a.startsWith("_memo_")&&a!=="_cellsCache"&&(l[a]=e[a])}return t}o(_n,"copyInstancePropertiesWithoutMemos");function H(){return Object.create(null)}o(H,"makeObjectMap");function je(t,e){return Object.prototype.hasOwnProperty.call(t,e)}o(je,"hasOwn");function Be(t,e){return n=>{(e.options.atoms?.[t]??e.baseAtoms[t]).set(l=>It(n,l))}}o(Be,"makeStateUpdater");function Xr(t){if(typeof t!="object"||t===null)return!1;if(Array.isArray(t))return!0;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}o(Xr,"isPlainContainer");function Yr(t){return Reflect.ownKeys(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}o(Yr,"getEnumerableOwnKeys");var Mi=3;function ki(t,e){return Zr(t,e,Mi)}o(ki,"stateSlicesEqual");function Zr(t,e,n){if(Object.is(t,e))return!0;if(n<=0||!Xr(t)||!Xr(e)||(Array.isArray(t)||Array.isArray(e))&&(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length))return!1;let l=Yr(t),r=Yr(e);if(l.length!==r.length)return!1;let a=t,s=e;for(let i=0;i<l.length;i++){let c=l[i];if(!Object.prototype.propertyIsEnumerable.call(e,c)||!Zr(a[c],s[c],n-1))return!1}return!0}o(Zr,"stateSlicesEqualAtDepth");function He(t,e,n,l=ki){let r=`on${e.charAt(0).toUpperCase()}${e.slice(1)}Change`,a=t.options[r];a&&a(s=>{let i=It(n,s);return l(s,i)?s:i})}o(He,"setStateSlice");function el(t){return t instanceof Function}o(el,"isFunction");function tl(t,e){let n=[],l=o(r=>{r.forEach(a=>{n.push(a);let s=e(a);s.length&&l(s)})},"recurse");return l(t),n}o(tl,"flattenBy");var Pi=o(({fn:t,memoDeps:e,onAfterCompare:n,onAfterUpdate:l,onBeforeCompare:r,onBeforeUpdate:a})=>{let s=[],i;return o(u=>{r?.();let d=e?.(u),g=!d||d.length!==s?.length;if(!g&&d){for(let m=0;m<d.length;m++)if(d[m]!==s[m]){g=!0;break}}return n?.(g),g&&(s=d,a?.(),i=t(...d??[]),l?.(i)),i},"memoizedFn")},"memo");function Cn(t){let e=!1;return()=>{if(!e){e=!0;return}t()}}o(Cn,"skipFirstRun");var Ni=o((t,e)=>{for(t=String(t);t.length<e;)t=" "+t;return t},"pad");function Ft({feature:t,fnName:e,objectId:n,onAfterUpdate:l,table:r,...a}){let s,i,c=0,u;function d(h,p){let b=c===0?"(1st run)":p?"(rerun #"+c+")":"(cache)";c++,console.groupCollapsed(`%c\u23F1 ${Ni(`${h.toFixed(1)} ms`,12)} %c${b}%c ${e}%c ${n?`(${e.split(".")[0]}Id: ${n})`:""}`,`font-size: .6rem; font-weight: bold; ${p?`color: hsl(
1
+ import{a as gn,b as $e,e as Vr,f as zr}from"./chunk-NDTQTKDX.js";import{a as Tr,b as pt,c as Er,d as fn}from"./chunk-ZNVNSNDU.js";import{a as mn}from"./chunk-S4Z7K55A.js";import{b as dn}from"./chunk-5B2RTXBS.js";import{d as $r}from"./chunk-UYEZR3BI.js";import{a as un}from"./chunk-Q6IT6ZD7.js";import{a as Le}from"./chunk-CGQMJYCW.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as cn}from"./chunk-7RKB5KS7.js";import{a as Ht}from"./chunk-QJLHH3ET.js";import{a as so}from"./chunk-37WYCOQ2.js";import{a as sn}from"./chunk-Z22BDS6N.js";import{a as Or}from"./chunk-JQXA2OYK.js";import{b as yr,c as oo}from"./chunk-CCDX5RYT.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import{a as io}from"./chunk-IWZ7GVQO.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as ao}from"./chunk-XHRKNCCI.js";import{a as Mr}from"./chunk-YVR4SEPU.js";import{a as Ir,b as Fr}from"./chunk-ZKJS6EBE.js";import{b as vr,c as Rr,f as ro}from"./chunk-RGMVGZV4.js";import{c as br,d as hr,e as wr,f as it,g as on,h as xr,i as Sr}from"./chunk-OQ6I6OXT.js";import{i as _r}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as rn}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as _e}from"./chunk-4ZEL6BYL.js";import{b as no,c as ct}from"./chunk-QUXXMJPZ.js";import{b as Zn,c as eo,d as nn,e as pr,l as nt}from"./chunk-BWKZ6FFW.js";import"./chunk-QAQDMS6R.js";import"./chunk-DYR23C3V.js";import{a as ln}from"./chunk-RWVIV3U7.js";import{a as kr,b as Pr,c as Nr,d as lo,e as Dr,f as Ar}from"./chunk-HCTJKP5J.js";import{d as oe,f as Ve,g as ze,h as $t,m as to,n as an,o as Te,p as re,t as Cr}from"./chunk-HJHSQPHW.js";import{a as o,d as Me,e as gt,f as Vt,g as zt,i as ft}from"./chunk-I26MS5PJ.js";var Os=Me(Vt(),1);var Ot=Me(gt(),1);var q=Me(Vt(),1);var D=Me(gt(),1);var Rt=Me(Vt(),1);var Y=Me(zt(),1),ot=Me(gt(),1);var mi=2166136261,gi=16777619,fi=o((t,e=mi)=>{let n=e;for(let l=0;l<t.length;l+=1)n^=t.charCodeAt(l),n=Math.imul(n,gi);return(n>>>0).toString(16).padStart(8,"0")},"I"),pi=/([a-z\d])([A-Z])/gu,bi=/[\s_-]+/u,hi=new Set(["access_token","api_key","apikey","card_number","client_secret","credit_card","cvv","passwd","password","private_key","pwd","refresh_token","secret","ssn","token"]),wi=o(t=>{let e=t.replaceAll(pi,"$1 $2").split(bi).map(l=>l.toLowerCase()).filter(l=>l.length>0),n=new Set(e);for(let l=0;l<e.length-1;l+=1){let r=e[l],a=e[l+1];r===void 0||a===void 0||(n.add(`${r}${a}`),n.add(`${r}_${a}`))}return[...n]},"le"),Hr="\u2022\u2022\u2022",Kr=o((t,e)=>{try{return e==="redact"?null:e==="hash"?t==null?t:fi(typeof t=="bigint"?t.toString():typeof t=="string"?t:JSON.stringify(t)):Hr}catch{return Hr}},"W"),Lr=o((t,e)=>{let n=new Map;for(let l of t)l.table===e&&n.set(l.column,l.strategy);return n},"j"),xi=o(t=>{for(let e of wi(t))if(hi.has(e))return!0;return!1},"ae"),jr=o((t,e)=>{let n=e.filter(r=>!t.has(r)&&xi(r));if(n.length===0)return t;let l=new Map(t);for(let r of n)l.set(r,"redact");return l},"z"),Lt=o((t,e,n)=>{if(!n.enabled)return t;let l=n.columns.get(e);return l===void 0?t:Kr(t,l)},"Ce"),pn=o((t,e)=>{if(!e.enabled||e.columns.size===0)return t;let n={...t};for(let[l,r]of e.columns)l in n&&(n[l]=Kr(n[l],r));return n},"ce"),bn=o((t,e)=>!e.enabled||e.columns.size===0?t:t.map(n=>pn(n,e)),"Fe"),Br=o(t=>t==null?"\u2205":t===""?"(empty)":Te(t),"B"),Si=o(t=>{let e=(0,Rt.c)(32),{column:n,onFacetFilter:l,state:r}=t,a=oe(),s;e[0]!==n||e[1]!==l||e[2]!==r.result?.values?(s=o(w=>{let _=Number(w.currentTarget.dataset.index),S=r.result?.values[_];S!==void 0&&l(n,S.value)},"x"),e[0]=n,e[1]=l,e[2]=r.result?.values,e[3]=s):s=e[3];let i=s,c=`db-facet-${n}`,u;e[4]!==n?(u=(0,Y.jsx)("span",{className:"font-medium text-foreground",children:n}),e[4]=n,e[5]=u):u=e[5];let d;e[6]!==r.loading||e[7]!==r.result||e[8]!==a?(d=r.loading&&r.result===null&&(0,Y.jsx)("span",{className:"text-muted-foreground",children:a("Loading\u2026")}),e[6]=r.loading,e[7]=r.result,e[8]=a,e[9]=d):d=e[9];let g;e[10]!==r.error?(g=r.error!==null&&(0,Y.jsx)("span",{className:"text-destructive",role:"alert",children:r.error}),e[10]=r.error,e[11]=g):g=e[11];let m;e[12]!==r.result?.values?(m=r.result?.values??[],e[12]=r.result?.values,e[13]=m):m=e[13];let h;if(e[14]!==n||e[15]!==i||e[16]!==m){let w;e[18]!==n||e[19]!==i?(w=o((_,S)=>(0,Y.jsxs)("button",{className:"flex items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground","data-index":S,"data-testid":`db-facet-value-${n}`,onClick:i,type:"button",children:[(0,Y.jsx)("span",{className:"truncate",children:Br(_.value)}),(0,Y.jsx)("span",{className:"shrink-0 tabular-nums text-foreground/70",children:_.count})]},Br(_.value)),"c"),e[18]=n,e[19]=i,e[20]=w):w=e[20],h=m.map(w),e[14]=n,e[15]=i,e[16]=m,e[17]=h}else h=e[17];let p;e[21]!==n||e[22]!==r.result||e[23]!==a?(p=r.result?.truncated===!0&&(0,Y.jsx)("span",{className:"text-muted-foreground","data-testid":`db-facet-truncated-${n}`,children:a("Showing the {n} most common values.",{n:r.result.values.length})}),e[21]=n,e[22]=r.result,e[23]=a,e[24]=p):p=e[24];let b;return e[25]!==c||e[26]!==u||e[27]!==d||e[28]!==g||e[29]!==h||e[30]!==p?(b=(0,Y.jsxs)("section",{className:"flex flex-col gap-1","data-testid":c,children:[u,d,g,h,p]}),e[25]=c,e[26]=u,e[27]=d,e[28]=g,e[29]=h,e[30]=p,e[31]=b):b=e[31],b},"ie"),hn=o(t=>{let e=(0,Rt.c)(44),{columns:n,facets:l,mask:r,onFacetFilter:a,onToggleFacet:s}=t,i=oe(),c;e[0]!==s?(c=o(y=>{let{column:M}=y.currentTarget.dataset;M!==void 0&&s(M)},"o"),e[0]=s,e[1]=c):c=e[1];let u=c,d;e[2]!==r?(d=o(y=>r.enabled&&r.columns.has(y),"a"),e[2]=r,e[3]=d):d=e[3];let g=d,m,h,p,b,w,_,S,v;if(e[4]!==n||e[5]!==l||e[6]!==g||e[7]!==i||e[8]!==u){v=Symbol.for("react.early_return_sentinel");e:{let y;e[17]!==g?(y=o(N=>!g(N),"y"),e[17]=g,e[18]=y):y=e[18];let M=n.filter(y),F;if(e[19]!==l||e[20]!==g?(F=Object.entries(l).filter(N=>{let[A]=N;return!g(A)}),e[19]=l,e[20]=g,e[21]=F):F=e[21],m=F,M.length===0){v=null;break e}_="flex w-56 shrink-0 flex-col gap-3 overflow-auto border-l border-border p-3 text-xs",S="db-facets",b="flex flex-col gap-1.5";let P;e[22]!==i?(P=i("Facets"),e[22]=i,e[23]=P):P=e[23],e[24]!==P?(w=(0,Y.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:P}),e[24]=P,e[25]=w):w=e[25],h="flex flex-wrap gap-1";let k;e[26]!==l||e[27]!==u?(k=o(N=>(0,Y.jsx)("button",{"aria-pressed":N in l,className:"rounded border border-border px-1.5 py-0.5 text-muted-foreground transition-colors hover:bg-accent aria-pressed:bg-accent aria-pressed:text-accent-foreground","data-column":N,"data-testid":`db-facet-toggle-${N}`,onClick:u,type:"button",children:N},N),"A"),e[26]=l,e[27]=u,e[28]=k):k=e[28],p=M.map(k)}e[4]=n,e[5]=l,e[6]=g,e[7]=i,e[8]=u,e[9]=m,e[10]=h,e[11]=p,e[12]=b,e[13]=w,e[14]=_,e[15]=S,e[16]=v}else m=e[9],h=e[10],p=e[11],b=e[12],w=e[13],_=e[14],S=e[15],v=e[16];if(v!==Symbol.for("react.early_return_sentinel"))return v;let I;e[29]!==h||e[30]!==p?(I=(0,Y.jsx)("div",{className:h,children:p}),e[29]=h,e[30]=p,e[31]=I):I=e[31];let C;e[32]!==I||e[33]!==b||e[34]!==w?(C=(0,Y.jsxs)("div",{className:b,children:[w,I]}),e[32]=I,e[33]=b,e[34]=w,e[35]=C):C=e[35];let R;e[36]!==a||e[37]!==m?(R=m.map(y=>{let[M,F]=y;return(0,Y.jsx)(Si,{column:M,onFacetFilter:a,state:F},M)}),e[36]=a,e[37]=m,e[38]=R):R=e[38];let x;return e[39]!==C||e[40]!==R||e[41]!==_||e[42]!==S?(x=(0,Y.jsxs)("aside",{className:_,"data-testid":S,children:[C,R]}),e[39]=C,e[40]=R,e[41]=_,e[42]=S,e[43]=x):x=e[43],x},"_e"),wn=o(()=>{let[t,e]=(0,ot.useState)({}),n=Le(t),l=(0,ot.useRef)({}),r=o(async(a,s)=>{let i=(l.current[a]??0)+1;l.current[a]=i,e(c=>a in c?{...c,[a]:{error:null,loading:!0,result:c[a]?.result??null}}:c);try{let c=await s(a);if(l.current[a]!==i)return;e(u=>a in u?{...u,[a]:{error:null,loading:!1,result:c}}:u)}catch(c){if(l.current[a]!==i)return;e(u=>a in u?{...u,[a]:{error:$t(c),loading:!1,result:null}}:u)}},"n");return{clearFacets:o(()=>{e({})},"clearFacets"),facets:t,facetsRef:n,refetchFacets:o(a=>{for(let s of Object.keys(n.current))re(r(s,a))},"refetchFacets"),toggleFacet:o((a,s)=>{if(a in n.current){e(i=>Object.fromEntries(Object.entries(i).filter(([c])=>c!==a)));return}e(i=>({...i,[a]:{error:null,loading:!0,result:null}})),s!==null&&re(r(a,s))},"toggleFacet")}},"Me"),_i=[],Ci=o(()=>{let t=(0,Rt.c)(1),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={},t[0]=e):e=t[0];let{data:n}=ct(_e.maskPolicies,e);return Array.isArray(n?.columns)?n.columns:_i},"de"),xn=o(t=>{let e=(0,Rt.c)(16),{columns:n,selectedTable:l}=t,r=Ci(),[a,s]=(0,ot.useState)(!0),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=o(()=>{s(yi)},"g"),e[0]=i):i=e[0];let c=i,u;if(e[1]!==n||e[2]!==r||e[3]!==l){let b=Lr(r,l??"");u=jr(b,n),e[1]=n,e[2]=r,e[3]=l,e[4]=u}else u=e[4];let d=u,g;e[5]!==a||e[6]!==r?(g=o((b,w)=>({columns:jr(Lr(r,b),w),enabled:a}),"l"),e[5]=a,e[6]=r,e[7]=g):g=e[7];let m=g,h;e[8]!==d||e[9]!==a?(h={columns:d,enabled:a},e[8]=d,e[9]=a,e[10]=h):h=e[10];let p;return e[11]!==d||e[12]!==a||e[13]!==m||e[14]!==h?(p={maskColumns:d,maskOn:a,maskView:h,maskViewFor:m,onToggleMask:c},e[11]=d,e[12]=a,e[13]=m,e[14]=h,e[15]=p):p=e[15],p},"Te");function yi(t){return!t}o(yi,"fe");var Gr=34,qr=600,vi=o(t=>{let e=(0,Rt.c)(21),{item:n,onSelect:l,prefix:r,selected:a,start:s}=t,i;e[0]!==n.name||e[1]!==l?(i=o(()=>{l(n.name)},"g"),e[0]=n.name,e[1]=l,e[2]=i):i=e[2];let c=i,u=`translateY(${String(s)}px)`,d;e[3]!==u?(d={insetInline:0,position:"absolute",top:0,transform:u},e[3]=u,e[4]=d):d=e[4];let g=d,m=a?"bg-accent font-medium text-accent-foreground":"text-foreground",h;e[5]!==m?(h=ft("flex w-full items-center justify-between gap-2 rounded-md px-2 py-1.5 text-start text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent",m),e[5]=m,e[6]=h):h=e[6];let p=`${r}-table-${n.name}`,b;e[7]!==n.name?(b=(0,Y.jsx)("span",{className:"truncate",children:n.name}),e[7]=n.name,e[8]=b):b=e[8];let w;e[9]!==n.rowCount?(w=(0,Y.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 text-xs tabular-nums text-muted-foreground",children:n.rowCount}),e[9]=n.rowCount,e[10]=w):w=e[10];let _;e[11]!==c||e[12]!==a||e[13]!==h||e[14]!==p||e[15]!==b||e[16]!==w?(_=(0,Y.jsxs)("button",{"aria-pressed":a,className:h,"data-testid":p,onClick:c,type:"button",children:[b,w]}),e[11]=c,e[12]=a,e[13]=h,e[14]=p,e[15]=b,e[16]=w,e[17]=_):_=e[17];let S;return e[18]!==g||e[19]!==_?(S=(0,Y.jsx)("li",{style:g,children:_}),e[18]=g,e[19]=_,e[20]=S):S=e[20],S},"me"),Sn=o(({header:t,onReload:e,onSelect:n,prefix:l,reloadLabel:r,selected:a,tables:s})=>{let i=oe(),[c,u]=(0,ot.useState)(""),d=(0,ot.useRef)(null),g=o(b=>{u(b.target.value)},"l"),m=(0,ot.useMemo)(()=>{let b=c.trim().toLowerCase();return b===""?s:s.filter(w=>w.name.toLowerCase().includes(b))},[c,s]),h=dn({count:m.length,estimateSize:o(()=>Gr,"estimateSize"),getScrollElement:o(()=>d.current,"getScrollElement"),initialRect:{height:qr,width:240},observeElementRect:o((b,w)=>mn(b,w,qr),"observeElementRect"),overscan:12}).getVirtualItems(),p={height:m.length*Gr};return(0,Y.jsxs)("aside",{className:"flex h-full w-60 shrink-0 flex-col border-e border-border bg-sidebar","data-testid":`${l}-table-list`,children:[t,(0,Y.jsxs)("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border px-3",children:[(0,Y.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:i("Tables")}),e!==void 0&&(0,Y.jsx)("button",{"aria-label":r??i("Refresh"),className:"flex size-6 items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent","data-testid":`${l}-load-tables`,onClick:e,title:r??i("Refresh"),type:"button",children:(0,Y.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,Y.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})})})]}),(0,Y.jsx)("div",{className:"shrink-0 border-b border-border p-2",children:(0,Y.jsx)("input",{className:"h-7 w-full rounded-md border border-border bg-background px-2 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring","data-testid":`${l}-table-search`,onChange:g,placeholder:i("search table\u2026"),type:"search",value:c})}),(0,Y.jsxs)("ul",{className:"relative flex-1 overflow-y-auto p-1.5","data-testid":`${l}-table-list-rows`,ref:d,children:[(0,Y.jsx)("li",{"aria-hidden":"true",style:p}),h.map(b=>{let w=m[b.index];return w===void 0?null:(0,Y.jsx)(vi,{item:w,onSelect:n,prefix:l,selected:a===w.name,start:b.start},w.name)})]})]})},"$e");var f=Me(zt(),1);var Ur=Me(gt(),1);function Ri(t){return Ii(t)||typeof t=="function"||Fi(t)}o(Ri,"isReactComponent");function Ii(t){return typeof t=="function"&&(()=>{let e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}o(Ii,"isClassComponent");function Fi(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}o(Fi,"isExoticComponent");function bt(t,e){return t==null?null:Ri(t)?Ur.default.createElement(t,e):t}o(bt,"flexRender");function co(t){if("cell"in t&&t.cell){let e=t.cell,n=e.column.columnDef,l=e,r=n;return l.getIsAggregated?.()?bt(r.aggregatedCell??n.cell,e.getContext()):l.getIsPlaceholder?.()?null:bt(n.cell,e.getContext())}return"header"in t&&t.header?bt(t.header.column.columnDef.header,t.header.getContext()):"footer"in t&&t.footer?bt(t.footer.column.columnDef.footer,t.footer.getContext()):null}o(co,"FlexRender");function Jr(t){let e=on(t.source,t.selector,{compare:it});return typeof t.children=="function"?t.children(e):t.children}o(Jr,"Subscribe");function Wr(t){let e=t;return Object.defineProperty(t,"state",{get(){return t.get()}}),"set"in t&&(e.setState=t.set.bind(t)),e}o(Wr,"atomToStore");function uo(t){let{createAtom:e,batch:n}=t,l=e(0);return{createOptionsStore:!1,wrapExternalAtoms:!1,addSubscription:o(()=>{throw new Error("Feature not supported in current reactivity implementation")},"addSubscription"),unmount:o(()=>{throw new Error("Feature not supported in current reactivity implementation")},"unmount"),schedule:t.schedule??(r=>queueMicrotask(r)),batch:n,untrack:o(r=>r(),"untrack"),createReadonlyAtom:o((r,a)=>{let s=a?.compare??Object.is,i=!1,c,u=o(()=>{let g=r();return(!i||!s(c,g))&&(c=g,i=!0),c},"getSnapshot"),d=e(()=>(l.get(),u()),{compare:s});return{get:u,subscribe:d.subscribe.bind(d)}},"createReadonlyAtom"),createWritableAtom:o((r,a)=>e(r,{compare:a?.compare}),"createWritableAtom"),commit:o(()=>{l.set(r=>r+1)},"commit")}}o(uo,"renderPhaseReactivity");function mo(t,e=Object.is){let n=!1,l;return{get:t.get,markCommitted:o(r=>{l=r,n=!0},"markCommitted"),subscribe:o(r=>t.subscribe(a=>{(!n||!e(l,a))&&r(a)}),"subscribe")}}o(mo,"createRenderPhaseSource");function Qr(){return uo({createAtom:wr,batch:hr})}o(Qr,"reactReactivity");function It(t,e){return typeof t=="function"?t(e):t}o(It,"functionalUpdate");function ie(t){if(Array.isArray(t))return t.map(ie);if(t&&typeof t=="object"){let e=Object.getPrototypeOf(t);if(e!==Object.prototype&&e!==null)return t;let n=e===null?H():{},l=Object.keys(t);for(let r=0;r<l.length;r++){let a=l[r];Object.defineProperty(n,a,{configurable:!0,enumerable:!0,value:ie(t[a]),writable:!0})}return n}return t}o(ie,"cloneState");function _n(t,e){let n=Object.keys(e),l=t;for(let r=0;r<n.length;r++){let a=n[r];!a.startsWith("_memo_")&&a!=="_cellsCache"&&(l[a]=e[a])}return t}o(_n,"copyInstancePropertiesWithoutMemos");function H(){return Object.create(null)}o(H,"makeObjectMap");function je(t,e){return Object.prototype.hasOwnProperty.call(t,e)}o(je,"hasOwn");function Be(t,e){return n=>{(e.options.atoms?.[t]??e.baseAtoms[t]).set(l=>It(n,l))}}o(Be,"makeStateUpdater");function Xr(t){if(typeof t!="object"||t===null)return!1;if(Array.isArray(t))return!0;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}o(Xr,"isPlainContainer");function Yr(t){return Reflect.ownKeys(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}o(Yr,"getEnumerableOwnKeys");var Mi=3;function ki(t,e){return Zr(t,e,Mi)}o(ki,"stateSlicesEqual");function Zr(t,e,n){if(Object.is(t,e))return!0;if(n<=0||!Xr(t)||!Xr(e)||(Array.isArray(t)||Array.isArray(e))&&(!Array.isArray(t)||!Array.isArray(e)||t.length!==e.length))return!1;let l=Yr(t),r=Yr(e);if(l.length!==r.length)return!1;let a=t,s=e;for(let i=0;i<l.length;i++){let c=l[i];if(!Object.prototype.propertyIsEnumerable.call(e,c)||!Zr(a[c],s[c],n-1))return!1}return!0}o(Zr,"stateSlicesEqualAtDepth");function He(t,e,n,l=ki){let r=`on${e.charAt(0).toUpperCase()}${e.slice(1)}Change`,a=t.options[r];a&&a(s=>{let i=It(n,s);return l(s,i)?s:i})}o(He,"setStateSlice");function el(t){return t instanceof Function}o(el,"isFunction");function tl(t,e){let n=[],l=o(r=>{r.forEach(a=>{n.push(a);let s=e(a);s.length&&l(s)})},"recurse");return l(t),n}o(tl,"flattenBy");var Pi=o(({fn:t,memoDeps:e,onAfterCompare:n,onAfterUpdate:l,onBeforeCompare:r,onBeforeUpdate:a})=>{let s=[],i;return o(u=>{r?.();let d=e?.(u),g=!d||d.length!==s?.length;if(!g&&d){for(let m=0;m<d.length;m++)if(d[m]!==s[m]){g=!0;break}}return n?.(g),g&&(s=d,a?.(),i=t(...d??[]),l?.(i)),i},"memoizedFn")},"memo");function Cn(t){let e=!1;return()=>{if(!e){e=!0;return}t()}}o(Cn,"skipFirstRun");var Ni=o((t,e)=>{for(t=String(t);t.length<e;)t=" "+t;return t},"pad");function Ft({feature:t,fnName:e,objectId:n,onAfterUpdate:l,table:r,...a}){let s,i,c=0,u;function d(h,p){let b=c===0?"(1st run)":p?"(rerun #"+c+")":"(cache)";c++,console.groupCollapsed(`%c\u23F1 ${Ni(`${h.toFixed(1)} ms`,12)} %c${b}%c ${e}%c ${n?`(${e.split(".")[0]}Id: ${n})`:""}`,`font-size: .6rem; font-weight: bold; ${p?`color: hsl(
2
2
  ${Math.max(0,Math.min(120-Math.log10(h)*60,120))}deg 100% 31%);`:""} `,`color: ${c<2?"#FF00FF":"#FF1493"}`,"color: #666","color: #87CEEB"),console.info({feature:t,state:r.store.state,deps:a.memoDeps?.toString()}),console.trace(),console.groupEnd()}o(d,"logTime");let g=o(()=>{if(!l)return;let{schedule:h,untrack:p}=r._reactivity;h(()=>p(()=>l()))},"onAfterUpdateHandler");return Pi({...a,...{onAfterUpdate:o(()=>{g()},"onAfterUpdate")}})}o(Ft,"tableMemo");function nl(t,e="_"){let[n,l]=t.split(e);return{fnKey:l,fnName:`${n}.${l}`,parentName:n}}o(nl,"getFunctionNameInfo");function fe(t,e,n){for(let[l,{fn:r,memoDeps:a}]of Object.entries(n)){let{fnKey:s,fnName:i}=nl(l);e[s]=a?Ft({memoDeps:a,fn:r,fnName:i,table:e,feature:t}):r}}o(fe,"assignTableAPIs");function ce(t,e,n,l){for(let[r,{fn:a,memoDeps:s}]of Object.entries(l)){let{fnKey:i,fnName:c}=nl(r);if(s){let u=`_memo_${i}`;e[i]=function(...d){if(!this[u]){let g=this;this[u]=Ft({memoDeps:o(m=>s(g,m),"memoDeps"),fn:o((...m)=>a(g,...m),"fn"),fnName:c,objectId:g.id,table:n,feature:t})}return this[u](...d)}}else e[i]=function(...u){return a(this,...u)}}}o(ce,"assignPrototypeAPIs");function V(t,e,n,...l){return t[e]?.(...l)??n(t,...l)}o(V,"callMemoOrStaticFn");function ol(t){return t.row.getValue(t.column.id)}o(ol,"cell_getValue");function rl(t){return t.getValue()??t.table.options.renderFallbackValue}o(rl,"cell_renderValue");function ll(t){return{table:t.table,column:t.column,row:t.row,cell:t,getValue:o(()=>t.getValue(),"getValue"),renderValue:o(()=>t.renderValue(),"renderValue")}}o(ll,"cell_getContext");var al={assignCellPrototype:o((t,e)=>{ce("coreCellsFeature",t,e,{cell_getValue:{fn:o(n=>ol(n),"fn")},cell_renderValue:{fn:o(n=>rl(n),"fn")},cell_getContext:{fn:o(n=>ll(n),"fn"),memoDeps:o(n=>[n],"memoDeps")}})},"assignCellPrototype")};function Di(t){if(!t._headerPrototype){t._headerPrototype={table:t};let e=Object.values(t._features);for(let n=0;n<e.length;n++)e[n].assignHeaderPrototype?.(t._headerPrototype,t)}return t._headerPrototype}o(Di,"getHeaderPrototype");function go(t,e,n){let l=Di(t),r=Object.create(l);r.colSpan=0,r.column=e,r.depth=n.depth,r.headerGroup=null,r.id=n.id??e.id,r.index=n.index,r.isPlaceholder=!!n.isPlaceholder,r.placeholderId=n.placeholderId,r.rowSpan=0,r.subHeaders=[];let a=t._headerInstanceInitFns;for(let s=0;s<a.length;s++)a[s](r);return r}o(go,"constructHeader");function Qe(){return{start:[],end:[]}}o(Qe,"getDefaultColumnPinningState");function sl(t){let e=t.getAllColumns(),n=t.getAllLeafColumnsById(),{start:l}=t.atoms.columnPinning?.get()??Qe(),r=[];for(let a=0;a<l.length;a++){let s=n[l[a]];s&&V(s,"getIsVisible",ue)&&r.push(s)}return wt(e,r,t,"start")}o(sl,"table_getStartHeaderGroups");function il(t){let e=t.getAllColumns(),n=t.getAllLeafColumnsById(),{end:l}=t.atoms.columnPinning?.get()??Qe(),r=[];for(let a=0;a<l.length;a++){let s=n[l[a]];s&&V(s,"getIsVisible",ue)&&r.push(s)}return wt(e,r,t,"end")}o(il,"table_getEndHeaderGroups");function cl(t){let e=t.getAllColumns(),n=V(t,"getVisibleLeafColumns",ht),{start:l,end:r}=t.atoms.columnPinning?.get()??Qe();if(l.length||r.length){let a=[...l,...r];n=n.filter(s=>!a.includes(s.id))}return wt(e,n,t,"center")}o(cl,"table_getCenterHeaderGroups");function Ai(t){let{start:e}=t.atoms.columnPinning?.get()??Qe(),n=t.getAllLeafColumnsById(),l=[];for(let r=0;r<e.length;r++){let a=n[e[r]];a&&l.push(a)}return l}o(Ai,"table_getStartLeafColumns");function Oi(t){let{end:e}=t.atoms.columnPinning?.get()??Qe(),n=t.getAllLeafColumnsById(),l=[];for(let r=0;r<e.length;r++){let a=n[e[r]];a&&l.push(a)}return l}o(Oi,"table_getEndLeafColumns");function Ti(t){let{start:e,end:n}=t.atoms.columnPinning?.get()??Qe();if(!e.length&&!n.length)return t.getAllLeafColumns();let l=[...e,...n];return t.getAllLeafColumns().filter(r=>!l.includes(r.id))}o(Ti,"table_getCenterLeafColumns");function Ei(t){return V(t,"getStartLeafColumns",Ai).filter(e=>V(e,"getIsVisible",ue))}o(Ei,"table_getStartVisibleLeafColumns");function Vi(t){return V(t,"getEndLeafColumns",Oi).filter(e=>V(e,"getIsVisible",ue))}o(Vi,"table_getEndVisibleLeafColumns");function zi(t){return V(t,"getCenterLeafColumns",Ti).filter(e=>V(e,"getIsVisible",ue))}o(zi,"table_getCenterVisibleLeafColumns");function Ge(t,e){return e?e==="start"?V(t,"getStartVisibleLeafColumns",Ei):e==="end"?V(t,"getEndVisibleLeafColumns",Vi):V(t,"getCenterVisibleLeafColumns",zi):V(t,"getVisibleLeafColumns",ht)}o(Ge,"table_getPinnedVisibleLeafColumns");function ul(){return H()}o(ul,"getDefaultColumnVisibilityState");function po(t,e){jt(t)&&Bt(t.table,n=>{let l=Object.assign(H(),n),r=e??!V(t,"getIsVisible",ue),a=t.getLeafColumns();for(let s=0;s<a.length;s++){let i=a[s];jt(i)&&(l[i.id]=r)}return l})}o(po,"column_toggleVisibility");function ue(t){let e=t.table.atoms.columnVisibility?.get();if(!e)return!0;let n=t.columns;return n.length?n.some(l=>V(l,"getIsVisible",ue)):(je(e,t.id)?e[t.id]:void 0)??!0}o(ue,"column_getIsVisible");function jt(t){return(t.columnDef.enableHiding??!0)&&(t.table.options.enableHiding??!0)}o(jt,"column_getCanHide");function dl(t){return e=>{po(t,e.target.checked)}}o(dl,"column_getToggleVisibilityHandler");function fo(t){let e=t.getAllCells(),n=[];for(let u=0;u<e.length;u++){let d=e[u];V(d.column,"getIsVisible",ue)&&n.push(d)}let{start:l,end:r}=t.table.atoms.columnPinning?.get()??Qe();if(!l.length&&!r.length)return n;let a=V(t,"getVisibleCellsByColumnId",yn),s=[];for(let u=0;u<l.length;u++){let d=a[l[u]];d&&s.push(d)}let i=[];for(let u=0;u<r.length;u++){let d=a[r[u]];d&&i.push(d)}let c=[];for(let u=0;u<n.length;u++){let d=n[u],g=d.column.id;!l.includes(g)&&!r.includes(g)&&c.push(d)}return[...s,...c,...i]}o(fo,"row_getVisibleCells");function yn(t){let e=H(),n=t.getAllCells();for(let l=0;l<n.length;l++){let r=n[l];V(r.column,"getIsVisible",ue)&&(e[r.column.id]=r)}return e}o(yn,"row_getVisibleCellsByColumnId");function ml(t){return t.getAllFlatColumns().filter(e=>V(e,"getIsVisible",ue))}o(ml,"table_getVisibleFlatColumns");function ht(t){return t.getAllLeafColumns().filter(e=>V(e,"getIsVisible",ue))}o(ht,"table_getVisibleLeafColumns");function Bt(t,e){He(t,"columnVisibility",e)}o(Bt,"table_setColumnVisibility");function gl(t,e){Bt(t,e?H():Object.assign(H(),ie(t.initialState.columnVisibility??{})))}o(gl,"table_resetColumnVisibility");function bo(t,e){e=e??!ho(t);let n=H(),l=t.getAllLeafColumns();for(let r=0;r<l.length;r++){let a=l[r];n[a.id]=e||!jt(a)}Bt(t,n)}o(bo,"table_toggleAllColumnsVisible");function ho(t){return!t.getAllLeafColumns().some(e=>!V(e,"getIsVisible",ue))}o(ho,"table_getIsAllColumnsVisible");function fl(t){return t.getAllLeafColumns().some(e=>V(e,"getIsVisible",ue))}o(fl,"table_getIsSomeColumnsVisible");function pl(t){return e=>{bo(t,e.target.checked)}}o(pl,"table_getToggleAllColumnsVisibilityHandler");function bl(t,e=1){let n=e;for(let l=0;l<t.length;l++){let r=t[l];V(r,"getIsVisible",ue)&&r.columns.length&&(n=Math.max(n,bl(r.columns,e+1)))}return n}o(bl,"getMaxHeaderDepth");function $i(t,e){return t?`${t}_${e}`:String(e)}o($i,"formatHeaderGroupId");function Hi(t,e,n,l){let r=t??"";return e&&(r=r?`${r}_${e}`:String(e)),n&&(r=r?`${r}_${n}`:n),l&&(r=r?`${r}_${l}`:l),r}o(Hi,"formatHeaderId");function Li(t,e){let n=0;for(let l=0;l<t.length;l++)t[l].column===e&&n++;return n}o(Li,"countPendingHeadersForColumn");function hl(t,e,n,l,r,a){let s={depth:e,id:$i(l,e),headers:[]},i=[];for(let c=0;c<t.length;c++){if(!(c in t))continue;let u=t[c],d=i[i.length-1],g=u.column.depth===s.depth,m,h=!1;if(g&&u.column.parent?m=u.column.parent:(m=u.column,h=!0),d&&d.column===m)d.subHeaders.push(u);else{let p=go(n,m,{id:Hi(l,e,m.id,u.id),isPlaceholder:h,placeholderId:h?String(Li(i,m)):void 0,depth:e,index:i.length});p.subHeaders.push(u),i.push(p)}s.headers.push(u),u.headerGroup=s}for(let c=0;c<a.length;c++)a[c](s);r.push(s),e>0&&hl(i,e-1,n,l,r,a)}o(hl,"constructHeaderGroup");function wl(t){for(let e=0;e<t.length;e++){let n=t[e];if(!V(n.column,"getIsVisible",ue))continue;let l=0;if(n.subHeaders.length){wl(n.subHeaders);for(let r=0;r<n.subHeaders.length;r++){let a=n.subHeaders[r];V(a.column,"getIsVisible",ue)&&(l+=a.colSpan)}}else l=1;if(n.colSpan=l,n.isPlaceholder&&n.subHeaders.length===1&&n.subHeaders[0].column===n.column){let r=1,a=n.subHeaders[0];for(;a;)a.rowSpan=0,r++,a=a.subHeaders.length===1&&a.subHeaders[0].column===n.column?a.subHeaders[0]:void 0;n.rowSpan=r}else n.rowSpan=1}}o(wl,"updateHeaderSpans");function wt(t,e,n,l){let r=bl(t),a=[],s=n._headerGroupInstanceInitFns,i=new Array(e.length);for(let c=0;c<e.length;c++)c in e&&(i[c]=go(n,e[c],{depth:r,index:c}));return hl(i,r-1,n,l,a,s),a.reverse(),wl(a[0]?.headers??[]),a}o(wt,"buildHeaderGroups");function ji(t){if(!t._columnPrototype){t._columnPrototype={table:t};let e=Object.values(t._features);for(let n=0;n<e.length;n++)e[n].assignColumnPrototype?.(t._columnPrototype,t)}return t._columnPrototype}o(ji,"getColumnPrototype");function xl(t,e,n,l){let r={...t.getDefaultColumnDef(),...e},a=r.accessorKey,s=a===void 0?void 0:String(a),i=r.id??s?.replaceAll(".","_")??(typeof r.header=="string"?r.header:void 0),c;if(r.accessorFn)c=r.accessorFn;else if(a!==void 0)if(typeof a=="string"&&a.includes(".")){let m=a.split(".");c=o(h=>{let p=h;for(let b=0;b<m.length;b++){let w=m[b];p=p?.[w]}return p},"accessorFn")}else c=o(m=>m[r.accessorKey],"accessorFn");if(!i)throw new Error;let u=ji(t),d=Object.create(u);d.accessorFn=c,d.columnDef=r,d.columns=[],d.depth=n,d.id=`${String(i)}`,d.parent=l;let g=t._columnInstanceInitFns;for(let m=0;m<g.length;m++)g[m](d);return d}o(xl,"constructColumn");function Sl(){return[]}o(Sl,"getDefaultColumnOrderState");function wo(t){let e=o(n=>{let l=H();for(let r=0;r<n.length;r++)l[n[r].id]=r;return l},"buildIndexes");return{all:e(Ge(t)),center:e(Ge(t,"center")),start:e(Ge(t,"start")),end:e(Ge(t,"end"))}}o(wo,"table_getColumnIndexes");function _l(t,e){return V(t.table,"getColumnIndexes",wo)[e==="start"?"start":e==="end"?"end":e==="center"?"center":"all"][t.id]??-1}o(_l,"column_getIndex");function Cl(t,e){return Ge(t.table,e)[0]?.id===t.id}o(Cl,"column_getIsFirstColumn");function yl(t,e){let n=Ge(t.table,e);return n[n.length-1]?.id===t.id}o(yl,"column_getIsLastColumn");function xo(t,e){He(t,"columnOrder",e)}o(xo,"table_setColumnOrder");function vl(t,e){xo(t,e?[]:ie(t.initialState.columnOrder??[]))}o(vl,"table_resetColumnOrder");function Gt(t){let e=t.atoms.columnOrder?.get();return n=>{let l=[];if(!e?.length)l=n;else{let r=new Map;for(let a=0;a<n.length;a++){let s=n[a];r.set(s.id,s)}for(let a=0;a<e.length;a++){let s=e[a],i=r.get(s);i&&(l.push(i),r.delete(s))}for(let a=0;a<n.length;a++){let s=n[a];r.has(s.id)&&l.push(s)}}return Bi(t,l)}}o(Gt,"table_getOrderColumnsFn");function Bi(t,e){let n=t.atoms.grouping?.get()??[],{groupedColumnMode:l}=t.options;if(!n.length||!l)return e;let r=e.filter(i=>!n.includes(i.id));if(l==="remove")return r;let a=new Map;for(let i=0;i<e.length;i++){let c=e[i];a.set(c.id,c)}let s=[];for(let i=0;i<n.length;i++){let c=a.get(n[i]);c&&s.push(c)}return[...s,...r]}o(Bi,"orderColumns");function Rl(t){return[t,...t.columns.flatMap(e=>e.getFlatColumns())]}o(Rl,"column_getFlatColumns");function Il(t){if(t.columns.length){let e=t.columns.flatMap(n=>n.getLeafColumns());return V(t.table,"getOrderColumns",Gt)(e)}return[t]}o(Il,"column_getLeafColumns");function Fl(t){return{header:o(e=>{let n=e.header.column.columnDef;return n.accessorKey?n.accessorKey:n.accessorFn?n.id:null},"header"),cell:o(e=>e.renderValue()?.toString?.()??null,"cell"),...Object.values(t._features).reduce((e,n)=>Object.assign(e,n.getDefaultColumnDef?.()),{}),...t.options.defaultColumn}}o(Fl,"table_getDefaultColumnDef");function Ml(t,e,n,l=0){let r=new Array(e.length);for(let a=0;a<e.length;a++){if(!(a in e))continue;let s=e[a],i=xl(t,s,l,n),c=s;i.columns=c.columns?Ml(t,c.columns,i,l+1):[],r[a]=i}return r}o(Ml,"constructColumns");function kl(t){return Ml(t,t.options.columns)}o(kl,"table_getAllColumns");function Pl(t){return t.getAllColumns().flatMap(e=>e.getFlatColumns())}o(Pl,"table_getAllFlatColumns");function Nl(t){let e=H(),n=t.getAllFlatColumns();for(let l=0;l<n.length;l++){let r=n[l];e[r.id]=r}return e}o(Nl,"table_getAllFlatColumnsById");function Dl(t){let e=t.getAllColumns().flatMap(n=>n.getLeafColumns());return V(t,"getOrderColumns",Gt)(e)}o(Dl,"table_getAllLeafColumns");function Al(t){let e=H(),n=t.getAllLeafColumns();for(let l=0;l<n.length;l++){let r=n[l];e[r.id]=r}return e}o(Al,"table_getAllLeafColumnsById");function Ol(t,e){return t.getAllFlatColumnsById()[e]}o(Ol,"table_getColumn");var Tl={assignColumnPrototype:o((t,e)=>{ce("coreColumnsFeature",t,e,{column_getFlatColumns:{fn:o(n=>Rl(n),"fn"),memoDeps:o(n=>[n.table.options.columns],"memoDeps")},column_getLeafColumns:{fn:o(n=>Il(n),"fn"),memoDeps:o(n=>[n.table.atoms.columnOrder?.get(),n.table.atoms.grouping?.get(),n.table.options.columns,n.table.options.groupedColumnMode],"memoDeps")}})},"assignColumnPrototype"),constructTableAPIs:o(t=>{fe("coreColumnsFeature",t,{table_getDefaultColumnDef:{fn:o(()=>Fl(t),"fn"),memoDeps:o(()=>[t.options.defaultColumn],"memoDeps")},table_getAllColumns:{fn:o(()=>kl(t),"fn"),memoDeps:o(()=>[t.options.columns],"memoDeps")},table_getAllFlatColumns:{fn:o(()=>Pl(t),"fn"),memoDeps:o(()=>[t.options.columns],"memoDeps")},table_getAllFlatColumnsById:{fn:o(()=>Nl(t),"fn"),memoDeps:o(()=>[t.options.columns],"memoDeps")},table_getAllLeafColumns:{fn:o(()=>Dl(t),"fn"),memoDeps:o(()=>[t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.options.columns,t.options.groupedColumnMode],"memoDeps")},table_getAllLeafColumnsById:{fn:o(()=>Al(t),"fn"),memoDeps:o(()=>[t.getAllLeafColumns()],"memoDeps")},table_getColumn:{fn:o(e=>Ol(t,e),"fn")}})},"constructTableAPIs")};function El(t,e){for(let n=0;n<t.subHeaders.length;n++)El(t.subHeaders[n],e);e.push(t)}o(El,"collectLeafHeaders");function Vl(t){let e=[];return El(t,e),e}o(Vl,"header_getLeafHeaders");function zl(t){return{column:t.column,header:t,table:t.column.table}}o(zl,"header_getContext");function $l(t){let{start:e,end:n}=t.atoms.columnPinning?.get()??Qe(),l=t.getAllColumns(),r=V(t,"getVisibleLeafColumns",ht);if(!e.length&&!n.length)return wt(l,r,t);let a=t.getAllLeafColumnsById(),s=[];for(let u=0;u<e.length;u++){let d=a[e[u]];d&&V(d,"getIsVisible",ue)&&s.push(d)}let i=[];for(let u=0;u<n.length;u++){let d=a[n[u]];d&&V(d,"getIsVisible",ue)&&i.push(d)}let c=r.filter(u=>!e.includes(u.id)&&!n.includes(u.id));return wt(l,[...s,...c,...i],t)}o($l,"table_getHeaderGroups");function Hl(t){return[...t.getHeaderGroups()].reverse()}o(Hl,"table_getFooterGroups");function Ll(t){let e=t.getHeaderGroups(),n=[];for(let l=0;l<e.length;l++){let r=e[l].headers;for(let a=0;a<r.length;a++)n.push(r[a])}return n}o(Ll,"table_getFlatHeaders");function jl(t){let e=t.getHeaderGroups()[0]?.headers??[],n=[];for(let l=0;l<e.length;l++){let r=e[l].getLeafHeaders();for(let a=0;a<r.length;a++)n.push(r[a])}return n}o(jl,"table_getLeafHeaders");var Bl={assignHeaderPrototype:o((t,e)=>{ce("coreHeadersFeature",t,e,{header_getLeafHeaders:{fn:o(n=>Vl(n),"fn"),memoDeps:o(n=>[n.column.table.options.columns],"memoDeps")},header_getContext:{fn:o(n=>zl(n),"fn"),memoDeps:o(n=>[n.column.table.options.columns],"memoDeps")}})},"assignHeaderPrototype"),constructTableAPIs:o(t=>{fe("coreHeadersFeature",t,{table_getHeaderGroups:{fn:o(()=>$l(t),"fn"),memoDeps:o(()=>[t.options.columns,t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.atoms.columnPinning?.get(),t.atoms.columnVisibility?.get(),t.options.groupedColumnMode],"memoDeps")},table_getFooterGroups:{fn:o(()=>Hl(t),"fn"),memoDeps:o(()=>[t.getHeaderGroups()],"memoDeps")},table_getFlatHeaders:{fn:o(()=>Ll(t),"fn"),memoDeps:o(()=>[t.getHeaderGroups()],"memoDeps")},table_getLeafHeaders:{fn:o(()=>jl(t),"fn"),memoDeps:o(()=>[t.getHeaderGroups()],"memoDeps")}})},"constructTableAPIs")};function Gi(t){if(!t._rowPrototype){t._rowPrototype={table:t};let e=Object.values(t._features);for(let n=0;n<e.length;n++)e[n].assignRowPrototype?.(t._rowPrototype,t)}return t._rowPrototype}o(Gi,"getRowPrototype");var Gl=o((t,e,n,l,r,a,s)=>{let i=Gi(t),c=Object.create(i);c._displayIndexCache=-1,c._uniqueValuesCache=H(),c._valuesCache=H(),c.depth=r,c.id=e,c.index=l,c.original=n,c.parentId=s,c.subRows=a??[];let u=t._rowInstanceInitFns;for(let d=0;d<u.length;d++)u[d](c);return c},"constructRow");var _o=/([0-9]+)/gm;function xt(t){let e=Object.assign((n,l,r)=>{let a=n.getValue(r),s=l.getValue(r),i=e.resolveDataValue;return i&&(a=i(a),s=i(s)),e.sort(a,s,n,l,r)},t);return e}o(xt,"constructSortFn");var Co=xt({resolveDataValue:o(t=>Rn(t).toLowerCase(),"resolveDataValue"),sort:o((t,e)=>Ul(t,e),"sort")}),qi=xt({resolveDataValue:o(t=>Rn(t),"resolveDataValue"),sort:o((t,e)=>Ul(t,e),"sort")}),yo=xt({resolveDataValue:o(t=>Rn(t).toLowerCase(),"resolveDataValue"),sort:o((t,e)=>Ro(t,e),"sort")}),Ki=xt({resolveDataValue:o(t=>Rn(t),"resolveDataValue"),sort:o((t,e)=>Ro(t,e),"sort")}),vo=xt({resolveDataValue:o(t=>Ui(t),"resolveDataValue"),sort:o((t,e)=>t>e?1:t<e?-1:0,"sort")}),Mt=xt({sort:o((t,e)=>Ro(t,e),"sort")});function Ro(t,e){return t===e?0:t>e?1:-1}o(Ro,"compareBasic");function Ui(t){return t instanceof Date?t.getTime():t}o(Ui,"toDateSortValue");function Rn(t){return typeof t=="number"?isNaN(t)||t===1/0||t===-1/0?"":String(t):typeof t=="string"?t:""}o(Rn,"toString");function Ul(t,e){let n=0,l=0,r=t.length,a=e.length;for(;n<r&&l<a;){let s=vn(t.charCodeAt(n)),i=vn(e.charCodeAt(l)),c=So(t,n,s),u=So(e,l,i);if(!s&&!i){let g=Ji(t,n,c,e,l,u);if(g)return g;n=c,l=u;continue}if(s!==i)return s?1:-1;let d=Wi(t,n,c,e,l,u);if(d)return d;n=c,l=u}return Kl(t,n)-Kl(e,l)}o(Ul,"compareAlphanumeric");function vn(t){return t>=48&&t<=57}o(vn,"isDigit");function So(t,e,n){let l=e+1;for(;l<t.length&&vn(t.charCodeAt(l))===n;)l++;return l}o(So,"findChunkEnd");function Ji(t,e,n,l,r,a){let s=n-e,i=a-r,c=s<i?s:i;for(let u=0;u<c;u++){let d=t.charCodeAt(e+u),g=l.charCodeAt(r+u);if(d>g)return 1;if(g>d)return-1}return s>i?1:i>s?-1:0}o(Ji,"compareStringChunks");function Wi(t,e,n,l,r,a){let s=e;for(;s<n&&t.charCodeAt(s)===48;)s++;let i=r;for(;i<a&&l.charCodeAt(i)===48;)i++;let c=n-s,u=a-i;if(c===0&&u===0)return 0;if(c<=15&&u<=15){let m=ql(t,s,n),h=ql(l,i,a);return m>h?1:h>m?-1:0}let d=parseInt(t.slice(e,n),10),g=parseInt(l.slice(r,a),10);return d>g?1:g>d?-1:0}o(Wi,"compareNumericChunks");function ql(t,e,n){let l=0;for(let r=e;r<n;r++)l=l*10+t.charCodeAt(r)-48;return l}o(ql,"parseSmallInt");function Kl(t,e){let n=0,l=e;for(;l<t.length;)n++,l=So(t,l,vn(t.charCodeAt(l)));return n}o(Kl,"countRemainingChunks");function Jl(){return[]}o(Jl,"getDefaultCellSelectionState");function Qi(t,e){He(t,"cellSelection",e?Jl():ie(t.initialState.cellSelection)??Jl())}o(Qi,"table_resetCellSelection");function Wl(t){t.atoms.cellSelection&&(t.options.autoResetAll??t.options.autoResetCellSelection??!0)&&t._reactivity.schedule(()=>Qi(t))}o(Wl,"table_autoResetCellSelection");function Ql(t){t.atoms.expanded&&(t.options.autoResetAll??t.options.autoResetExpanded??!t.options.manualExpanding)&&t._reactivity.schedule(()=>Xi(t))}o(Ql,"table_autoResetExpanded");function Xi(t,e){let n=t.initialState.expanded;He(t,"expanded",e?H():n===!0?!0:Object.assign(H(),ie(n??{})))}o(Xi,"table_resetExpanded");var In=0;function Fn(t){if(t.options.autoResetAll??t.options.autoResetPageIndex??!t.options.manualPagination){if((t.atoms.pagination?.get()?.pageIndex??In)===In)return;ec(t,!0)}}o(Fn,"table_autoResetPageIndex");function Yi(t,e){He(t,"pagination",e)}o(Yi,"table_setPagination");function Zi(t,e){Yi(t,n=>{let l=It(e,n.pageIndex),r=typeof t.options.pageCount>"u"||t.options.pageCount===-1?Number.MAX_SAFE_INTEGER:t.options.pageCount-1;return l=Math.max(0,Math.min(l,r)),{...n,pageIndex:l}})}o(Zi,"table_setPageIndex");function ec(t,e){Zi(t,e?In:t.initialState.pagination?.pageIndex??In)}o(ec,"table_resetPageIndex");function Xl(){return[]}o(Xl,"getDefaultSortingState");function Kt(t,e){He(t,"sorting",e)}o(Kt,"table_setSorting");function Io(t,e){Kt(t,e?[]:ie(t.initialState.sorting??[]))}o(Io,"table_resetSorting");function Yl(t){t.atoms.sorting&&(t.options.autoResetAll??t.options.autoResetSorting??!1)&&Io(t)}o(Yl,"table_autoResetSorting");function Fo(t){let e=t.table._rowModelFns.sortFns,n=t.table.getFilteredRowModel().flatRows.slice(0,10),l,r=!1;for(let a=0;a<n.length;a++){let s=n[a].getValue(t.id);if(Object.prototype.toString.call(s)==="[object Date]"){l="datetime";break}if(typeof s=="string"&&(r=!0,s.split(_o).length>1)){l="alphanumeric";break}}if(!l&&r&&(l="text"),l){let a=e?.[l];if(a||l==="alphanumeric"&&(a=e?.text),a)return a}return Mt}o(Fo,"column_getAutoSortFn");function Mo(t){let e=t.table.getFilteredRowModel().flatRows.slice(0,10);for(let n=0;n<e.length;n++){let l=e[n].getValue(t.id);if(l!=null)return typeof l=="string"?"asc":"desc"}return"desc"}o(Mo,"column_getAutoSortDir");function Mn(t){let e=t.table._rowModelFns.sortFns;return el(t.columnDef.sortFn)?t.columnDef.sortFn:t.columnDef.sortFn==="auto"?Fo(t):e?.[t.columnDef.sortFn]??Mt}o(Mn,"column_getSortFn");function ko(t,e,n){let l=No(t,n&&qt(t)),r=typeof e<"u";Kt(t.table,a=>{let s=a.findIndex(m=>m.id===t.id),i=s===-1?void 0:a[s],c=[],u,d=r?e:l==="desc",g=!!(a.length&&qt(t)&&n);return g?i?u="toggle":u="add":i?u="toggle":u="replace",u==="toggle"&&(r||l||(u="remove")),u==="add"?(c=[...a,{id:t.id,desc:d}],c.splice(0,c.length-(t.table.options.maxMultiSortColCount??Number.MAX_SAFE_INTEGER))):u==="toggle"?c=g?a.map(m=>m.id===t.id?{...m,desc:d}:m):[{id:t.id,desc:d}]:u==="remove"?c=g?a.filter(m=>m.id!==t.id):[]:c=[{id:t.id,desc:d}],c})}o(ko,"column_toggleSorting");function Po(t){return t.columnDef.sortDescFirst??t.table.options.sortDescFirst??Mo(t)==="desc"?"desc":"asc"}o(Po,"column_getFirstSortDir");function No(t,e){let n=Po(t),l=Do(t);return l?l!==n&&(t.table.options.enableSortingRemoval??!0)&&(!e||(t.table.options.enableMultiRemove??!0))?!1:l==="desc"?"asc":"desc":n}o(No,"column_getNextSortingOrder");function Ut(t){return(t.columnDef.enableSorting??!0)&&(t.table.options.enableSorting??!0)&&!!t.accessorFn}o(Ut,"column_getCanSort");function qt(t){return t.columnDef.enableMultiSort??t.table.options.enableMultiSort??!!t.accessorFn}o(qt,"column_getCanMultiSort");function Do(t){let e=t.table.atoms.sorting?.get()?.find(n=>n.id===t.id);return e?e.desc?"desc":"asc":!1}o(Do,"column_getIsSorted");function Zl(t){return t.table.atoms.sorting?.get()?.findIndex(e=>e.id===t.id)??-1}o(Zl,"column_getSortIndex");function ea(t){Kt(t.table,e=>e.length?e.filter(n=>n.id!==t.id):[])}o(ea,"column_clearSorting");function ta(t){let e=Ut(t);return n=>{e&&ko(t,void 0,qt(t)?t.table.options.isMultiSortEvent?.(n):!1)}}o(ta,"column_getToggleSortingHandler");function na(){return t=>Ft({feature:"coreRowModelsFeature",table:t,fnName:"table.getCoreRowModel",memoDeps:o(()=>[t.options.data],"memoDeps"),fn:o(()=>tc(t,t.options.data),"fn"),onAfterUpdate:Cn(()=>{Ql(t),Fn(t),Yl(t),Wl(t)})})}o(na,"createCoreRowModel");function oa(t,e,n,l=0,r){let a=[];for(let s=0;s<n.length;s++){let i=n[s],c=Gl(t,t.getRowId(i,s,r),i,s,l,void 0,r?.id);e.flatRows.push(c),e.rowsById[c.id]=c,a.push(c),t.options.getSubRows&&(c.originalSubRows=t.options.getSubRows(i,s),c.originalSubRows?.length&&(c.subRows=oa(t,e,c.originalSubRows,l+1,c)))}return a}o(oa,"accessRows");function tc(t,e){let n={rows:[],flatRows:[],rowsById:H()};return n.rows=oa(t,n,e),n}o(tc,"_createCoreRowModel");function ra(t){return t._rowModels.coreRowModel||(t._rowModels.coreRowModel=t.options.features.coreRowModel?.(t)??na()(t)),t._rowModels.coreRowModel()}o(ra,"table_getCoreRowModel");function la(t){return t.getCoreRowModel()}o(la,"table_getPreFilteredRowModel");function aa(t){return t._rowModels.filteredRowModel||(t._rowModels.filteredRowModel=t.options.features.filteredRowModel?.(t)),t.options.manualFiltering||!t._rowModels.filteredRowModel?t.getPreFilteredRowModel():t._rowModels.filteredRowModel()}o(aa,"table_getFilteredRowModel");function sa(t){return t.getFilteredRowModel()}o(sa,"table_getPreGroupedRowModel");function ia(t){return t._rowModels.groupedRowModel||(t._rowModels.groupedRowModel=t.options.features.groupedRowModel?.(t)),t.options.manualGrouping||!t._rowModels.groupedRowModel?t.getPreGroupedRowModel():t._rowModels.groupedRowModel()}o(ia,"table_getGroupedRowModel");function ca(t){return t.getGroupedRowModel()}o(ca,"table_getPreSortedRowModel");function ua(t){return t._rowModels.sortedRowModel||(t._rowModels.sortedRowModel=t.options.features.sortedRowModel?.(t)),t.options.manualSorting||!t._rowModels.sortedRowModel?t.getPreSortedRowModel():t._rowModels.sortedRowModel()}o(ua,"table_getSortedRowModel");function da(t){return t.getSortedRowModel()}o(da,"table_getPreExpandedRowModel");function ma(t){return t._rowModels.expandedRowModel||(t._rowModels.expandedRowModel=t.options.features.expandedRowModel?.(t)),t.options.manualExpanding||!t._rowModels.expandedRowModel?t.getPreExpandedRowModel():t._rowModels.expandedRowModel()}o(ma,"table_getExpandedRowModel");function ga(t){return t.getExpandedRowModel()}o(ga,"table_getPrePaginatedRowModel");function fa(t){return t._rowModels.paginatedRowModel||(t._rowModels.paginatedRowModel=t.options.features.paginatedRowModel?.(t)),t.options.manualPagination||!t._rowModels.paginatedRowModel?t.getPrePaginatedRowModel():t._rowModels.paginatedRowModel()}o(fa,"table_getPaginatedRowModel");function pa(t){return t.getPaginatedRowModel()}o(pa,"table_getRowModel");var ba={constructTableAPIs:o(t=>{fe("coreRowModelsFeature",t,{table_getCoreRowModel:{fn:o(()=>ra(t),"fn")},table_getPreFilteredRowModel:{fn:o(()=>la(t),"fn")},table_getFilteredRowModel:{fn:o(()=>aa(t),"fn")},table_getPreGroupedRowModel:{fn:o(()=>sa(t),"fn")},table_getGroupedRowModel:{fn:o(()=>ia(t),"fn")},table_getPreSortedRowModel:{fn:o(()=>ca(t),"fn")},table_getSortedRowModel:{fn:o(()=>ua(t),"fn")},table_getPreExpandedRowModel:{fn:o(()=>da(t),"fn")},table_getExpandedRowModel:{fn:o(()=>ma(t),"fn")},table_getPrePaginatedRowModel:{fn:o(()=>ga(t),"fn")},table_getPaginatedRowModel:{fn:o(()=>fa(t),"fn")},table_getRowModel:{fn:o(()=>pa(t),"fn")}})},"constructTableAPIs")};function nc(t){if(!t._cellPrototype){t._cellPrototype={table:t};let e=Object.values(t._features);for(let n=0;n<e.length;n++)e[n].assignCellPrototype?.(t._cellPrototype,t)}return t._cellPrototype}o(nc,"getCellPrototype");function ha(t,e,n){let l=nc(n),r=Object.create(l);r.column=t,r.id=`${e.id}_${t.id}`,r.row=e;let a=n._cellInstanceInitFns;for(let s=0;s<a.length;s++)a[s](r);return r}o(ha,"constructCell");function wa(t){let e=t.table.getRowsInDisplayOrder(),n=t._displayIndexCache;return e[n]===t?n:-1}o(wa,"row_getDisplayIndex");function xa(t){let e=t.getPrePaginatedRowModel().rows;if(t.options.paginateExpandedRows===!1){let n=[],l=o(r=>{r._displayIndexCache=n.length,n.push(r),r.subRows.length&&r.getIsExpanded?.()&&r.subRows.forEach(l)},"handleRow");return e.forEach(l),n}for(let n=0;n<e.length;n++)e[n]._displayIndexCache=n;return e}o(xa,"table_getRowsInDisplayOrder");function Sa(t,e){if(je(t._valuesCache,e))return t._valuesCache[e];let n=t.table.getColumn(e);if(n?.accessorFn)return t._valuesCache[e]=n.accessorFn(t.original,t.index),t._valuesCache[e]}o(Sa,"row_getValue");function _a(t,e){if(je(t._uniqueValuesCache,e))return t._uniqueValuesCache[e];let n=t.table.getColumn(e);if(n?.accessorFn)return n.columnDef.getUniqueValues?(t._uniqueValuesCache[e]=n.columnDef.getUniqueValues(t.original,t.index),t._uniqueValuesCache[e]):(t._uniqueValuesCache[e]=[t.getValue(e)],t._uniqueValuesCache[e])}o(_a,"row_getUniqueValues");function Ca(t,e){return t.getValue(e)??t.table.options.renderFallbackValue}o(Ca,"row_renderValue");function ya(t){return tl(t.subRows,e=>e.subRows)}o(ya,"row_getLeafRows");function va(t){let e=t.getCoreRowModel().flatRows,n=0;for(let l=0;l<e.length;l++)n=Math.max(n,e[l].depth);return n}o(va,"table_getMaxSubRowDepth");function Ra(t){if(t.parentId)return t.table.getCoreRowModel().rowsById[t.parentId]??t.table.getRow(t.parentId,!0)}o(Ra,"row_getParentRow");function Ia(t){let e=[],n=t;for(;;){let l=n.getParentRow();if(!l)break;e.push(l),n=l}return e.reverse()}o(Ia,"row_getParentRows");function Fa(t){let e=t.table.getAllLeafColumns(),n=t._cellsCache;n||(n=t._cellsCache=new WeakMap);let l=new Array(e.length);for(let r=0;r<e.length;r++){let a=e[r],s=n.get(a);s||(s=ha(a,t,t.table),n.set(a,s)),l[r]=s}return l}o(Fa,"row_getAllCells");function Ma(t){let e=H(),n=t.getAllCells();for(let l=0;l<n.length;l++){let r=n[l];e[r.column.id]=r}return e}o(Ma,"row_getAllCellsByColumnId");function ka(t,e,n,l){return e.options.getRowId?.(t,n,l)??(l?`${l.id}.${n}`:String(n))}o(ka,"table_getRowId");function Pa(t,e,n){let l=(n?t.getPrePaginatedRowModel():t.getRowModel()).rowsById[e];if(!l&&(l=t.getCoreRowModel().rowsById[e],!l))throw new Error;return l}o(Pa,"table_getRow");var Na={assignRowPrototype:o((t,e)=>{ce("coreRowsFeature",t,e,{row_getDisplayIndex:{fn:o(n=>wa(n),"fn")},row_getAllCellsByColumnId:{fn:o(n=>Ma(n),"fn"),memoDeps:o(n=>[n.getAllCells()],"memoDeps")},row_getAllCells:{fn:o(n=>Fa(n),"fn"),memoDeps:o(n=>[n.table.getAllLeafColumns()],"memoDeps")},row_getLeafRows:{fn:o(n=>ya(n),"fn"),memoDeps:o(n=>[n.subRows],"memoDeps")},row_getParentRow:{fn:o(n=>Ra(n),"fn")},row_getParentRows:{fn:o(n=>Ia(n),"fn")},row_getUniqueValues:{fn:o((n,l)=>_a(n,l),"fn")},row_getValue:{fn:o((n,l)=>Sa(n,l),"fn")},row_renderValue:{fn:o((n,l)=>Ca(n,l),"fn")}})},"assignRowPrototype"),constructTableAPIs:o(t=>{fe("coreRowsFeature",t,{table_getRowsInDisplayOrder:{fn:o(()=>xa(t),"fn"),memoDeps:o(()=>[t.getPrePaginatedRowModel().rows,t.options.paginateExpandedRows,t.options.paginateExpandedRows===!1?t.atoms.expanded?.get():void 0],"memoDeps")},table_getRowId:{fn:o((e,n,l)=>ka(e,t,n,l),"fn")},table_getRow:{fn:o((e,n)=>Pa(t,e,n),"fn")},table_getMaxSubRowDepth:{fn:o(()=>va(t),"fn"),memoDeps:o(()=>[t.getCoreRowModel()],"memoDeps")}})},"constructTableAPIs")};function kn(t,e,n=(l,r)=>l===r){let l=e===void 0?t.options.state:e;t._reactivity.batch(()=>{if(l)for(let r in l){let a=t.baseAtoms[r];if(!a)continue;let s=l[r],i=s===void 0?t.initialState[r]:s;n(t._reactivity.untrack(()=>a.get()),i)||a.set(()=>i)}})}o(kn,"table_syncExternalStateToBaseAtoms");function Pn(t,e,n=(l,r)=>l===r){t._reactivity.batch(()=>{kn(t,e,n),t._reactivity.commit?.()})}o(Pn,"table_publishExternalState");function Ao(t){let e=ie(t.initialState);t._reactivity.batch(()=>{let l=Object.keys(e);for(let r=0;r<l.length;r++){let a=l[r];t.baseAtoms[a].set(e[a])}});let n=Object.values(t._features);for(let l=0;l<n.length;l++)n[l].resetTableInstanceData?.(t)}o(Ao,"table_reset");function Da(t,e){let{features:n,atoms:l,initialState:r}=t.options;if(!t.options.mergeOptions)return{...t.options,...e,features:n,atoms:l,initialState:r};let a=t.options.mergeOptions(t.options,e),s={...Object.getOwnPropertyDescriptors(a)};return Object.defineProperties(Object.create(Object.getPrototypeOf(a)),{...s,features:{value:n,enumerable:!0,configurable:!0,writable:!0},atoms:{value:l,enumerable:!0,configurable:!0,writable:!0},initialState:{value:r,enumerable:!0,configurable:!0,writable:!0}})}o(Da,"table_mergeOptions");function Jt(t,e,n){let l=Da(t,It(e,t.options));t.optionsStore?t.optionsStore.set(()=>l):t.options=l,n?.syncExternalState!==!1&&Pn(t,l.state??null)}o(Jt,"table_setOptions");var Aa={constructTableAPIs:o(t=>{fe("coreTablesFeature",t,{table_reset:{fn:o(()=>Ao(t),"fn")},table_setOptions:{fn:o(e=>Jt(t,e),"fn")}})},"constructTableAPIs")};var Oa={coreCellsFeature:al,coreColumnsFeature:Tl,coreHeadersFeature:Bl,coreRowModelsFeature:ba,coreRowsFeature:Na,coreTablesFeature:Aa};function Ta(t,e={}){return Object.values(t).forEach(n=>{e=n.getInitialState?.(e)??e}),ie(e)}o(Ta,"getInitialTableState");function Oo(t){let e=t.features.coreReactivityFeature,{aggregationFns:n,columnMeta:l,coreRowModel:r,expandedRowModel:a,facetedMinMaxValues:s,facetedRowModel:i,facetedUniqueValues:c,filterFns:u,filterMeta:d,filteredRowModel:g,groupedRowModel:m,paginatedRowModel:h,sortFns:p,sortedRowModel:b,tableMeta:w,..._}=t.features,S={_cellInstanceInitFns:[],_columnInstanceInitFns:[],_features:{...Oa,..._},_headerGroupInstanceInitFns:[],_headerInstanceInitFns:[],_reactivity:e,_rowInstanceInitFns:[],_rowModelFns:{aggregationFns:n,filterFns:u,sortFns:p},_rowModels:{},atoms:{},baseAtoms:{}},v=Object.values(S._features),I={...v.reduce((R,x)=>Object.assign(R,x.getDefaultTableOptions?.(S)),{}),...t};if(e.wrapExternalAtoms&&I.atoms)for(let[R,x]of Object.entries(I.atoms)){let y=x,M=e.createWritableAtom(y.get(),{debugName:`externalAtom/${R}`});I.atoms[R]=M;let F=!1,P=y.subscribe(N=>{F||M.set(N)}),k=M.subscribe(N=>{F=!0,y.set(N),F=!1});e.addSubscription(P),e.addSubscription(k)}e.createOptionsStore?(S.optionsStore=e.createWritableAtom(I,{debugName:"table/optionsStore"}),Object.defineProperty(S,"options",{configurable:!0,enumerable:!0,get(){return S.optionsStore.get()},set(R){S.optionsStore.set(()=>R)}})):S.options=I,S.initialState=Ta(S._features,S.options.initialState);let C=Object.keys(S.initialState);for(let R=0;R<C.length;R++){let x=C[R];S.baseAtoms[x]=e.createWritableAtom(S.initialState[x],{debugName:`table/baseAtoms/${x}`}),S.atoms[x]=e.createReadonlyAtom(()=>{let y=S.options,M=y.atoms?.[x],F=M?M.get():S.baseAtoms[x].get();if(M)return F;let P=y.state;if(P&&je(P,x)){let k=P[x];return k===void 0?S.initialState[x]:k}return F},{debugName:`table/atoms/${x}`})}kn(S),S.store=Wr(e.createReadonlyAtom(()=>{let R={};for(let x=0;x<C.length;x++){let y=C[x];R[y]=S.atoms[y].get()}return R},{compare:it,debugName:"table/store"}));for(let R=0;R<v.length;R++){let x=v[R];x.initTableInstanceData?.(S),x.initCellInstanceData&&S._cellInstanceInitFns.push(x.initCellInstanceData.bind(x)),x.initColumnInstanceData&&S._columnInstanceInitFns.push(x.initColumnInstanceData.bind(x)),x.initHeaderGroupInstanceData&&S._headerGroupInstanceInitFns.push(x.initHeaderGroupInstanceData.bind(x)),x.initHeaderInstanceData&&S._headerInstanceInitFns.push(x.initHeaderInstanceData.bind(x)),x.initRowInstanceData&&S._rowInstanceInitFns.push(x.initRowInstanceData.bind(x)),x.constructTableAPIs?.(S)}return S}o(Oo,"constructTable");var To={getInitialState:o(t=>({columnOrder:Sl(),...t}),"getInitialState"),getDefaultTableOptions:o(t=>({onColumnOrderChange:Be("columnOrder",t)}),"getDefaultTableOptions"),assignColumnPrototype:o((t,e)=>{ce("columnOrderingFeature",t,e,{column_getIndex:{fn:o((n,l)=>_l(n,l),"fn")},column_getIsFirstColumn:{fn:o((n,l)=>Cl(n,l),"fn")},column_getIsLastColumn:{fn:o((n,l)=>yl(n,l),"fn")}})},"assignColumnPrototype"),constructTableAPIs:o(t=>{fe("columnOrderingFeature",t,{table_getColumnIndexes:{fn:o(()=>wo(t),"fn"),memoDeps:o(()=>[t.options.columns,t.atoms.columnOrder?.get(),t.atoms.columnPinning?.get(),t.atoms.columnVisibility?.get(),t.atoms.grouping?.get(),t.options.groupedColumnMode],"memoDeps")},table_setColumnOrder:{fn:o(e=>xo(t,e),"fn")},table_resetColumnOrder:{fn:o(e=>vl(t,e),"fn")},table_getOrderColumnsFn:{fn:o(()=>Gt(t),"fn"),memoDeps:o(()=>[t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.options.groupedColumnMode],"memoDeps")}})},"constructTableAPIs")};function Ea(){return H()}o(Ea,"getDefaultColumnSizingState");function Eo(){return{size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER}}o(Eo,"getDefaultColumnSizingColumnDef");function kt(t){let e=Eo(),n=t.table.atoms.columnSizing?.get(),l=n&&je(n,t.id)?n[t.id]:void 0;return Math.min(Math.max(t.columnDef.minSize??e.minSize,l??t.columnDef.size??e.size),t.columnDef.maxSize??e.maxSize)}o(kt,"column_getSize");function Nn(t){let e=H(),n=H(),l=new Array(t.length),r=0;for(let s=0;s<t.length;s++){let i=t[s],c=V(i,"getSize",kt);l[s]=c,e[i.id]=r,r+=c}let a=0;for(let s=t.length-1;s>=0;s--)n[t[s].id]=a,a+=l[s];return{starts:e,afters:n}}o(Nn,"buildColumnOffsets");function Dn(t){return{all:Nn(Ge(t)),center:Nn(Ge(t,"center")),start:Nn(Ge(t,"start")),end:Nn(Ge(t,"end"))}}o(Dn,"table_getColumnOffsets");function Va(t){return t==="start"?"start":t==="end"?"end":t==="center"?"center":"all"}o(Va,"toOffsetsKey");function za(t,e){return V(t.table,"getColumnOffsets",Dn)[Va(e)].starts[t.id]??0}o(za,"column_getStart");function $a(t,e){return V(t.table,"getColumnOffsets",Dn)[Va(e)].afters[t.id]??0}o($a,"column_getAfter");function Ha(t){Pt(t.table,e=>{let n=H(),l=Object.keys(e);for(let r=0;r<l.length;r++){let a=l[r];a!==t.id&&(n[a]=e[a])}return n})}o(Ha,"column_resetSize");function La(t){if(!t.subHeaders.length)return kt(t.column);let e=0;for(let n=0;n<t.subHeaders.length;n++)e+=La(t.subHeaders[n]);return e}o(La,"sumHeaderSize");function rt(t){return La(t)}o(rt,"header_getSize");function Vo(t){if(t.index>0){let e=t.headerGroup?.headers[t.index-1];if(e)return V(e,"getStart",Vo)+V(e,"getSize",rt)}return 0}o(Vo,"header_getStart");function Pt(t,e){t.options.onColumnSizingChange?.(e)}o(Pt,"table_setColumnSizing");function ja(t,e){Pt(t,e?H():Object.assign(H(),ie(t.initialState.columnSizing??{})))}o(ja,"table_resetColumnSizing");function Ba(t){return t.getHeaderGroups()[0]?.headers.reduce((e,n)=>e+rt(n),0)??0}o(Ba,"table_getTotalSize");function Ga(t){return V(t,"getStartHeaderGroups",sl)[0]?.headers.reduce((e,n)=>e+rt(n),0)??0}o(Ga,"table_getStartTotalSize");function qa(t){return V(t,"getCenterHeaderGroups",cl)[0]?.headers.reduce((e,n)=>e+rt(n),0)??0}o(qa,"table_getCenterTotalSize");function Ka(t){return V(t,"getEndHeaderGroups",il)[0]?.headers.reduce((e,n)=>e+rt(n),0)??0}o(Ka,"table_getEndTotalSize");function On(){return{startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}}o(On,"getDefaultColumnResizingState");function $o(t){return(t.columnDef.enableResizing??!0)&&(t.table.options.enableColumnResizing??!0)}o($o,"column_getCanResize");function Ua(t){return t.table.atoms.columnResizing?.get()?.isResizingColumn===t.id}o(Ua,"column_getIsResizing");function Ja(t,e){let n=t.table.getColumn(t.column.id),l=$o(n);return r=>{if(!l||zo(r)&&r.touches.length>1)return;let a=rt(t),s=t.getLeafHeaders().map(C=>[C.column.id,kt(C.column)]),i=zo(r)?Math.round(r.touches[0].clientX):r.clientX,c=H(),u=o((C,R)=>{if(typeof R!="number")return;let x=n.table,y=x.options.columnResizeMode==="onChange"||C==="end";x._reactivity.batch(()=>{Nt(x,M=>{let F=x.options.columnResizeDirection==="rtl"?-1:1,P=(R-(M.startOffset??0))*F,k=M.startSize??0,N=Math.max(k>0?P/k:0,-.999999);if(y){let A=M.columnSizingStart;for(let z=0;z<A.length;z++){let O=A[z],$=O[1];c[O[0]]=Math.round(Math.max($>0?$+$*N:P/A.length,0)*100)/100}}return{...M,deltaOffset:P,deltaPercentage:N}}),y&&Pt(x,M=>Object.assign(H(),M,c))})},"updateOffset"),d=null,g=!1,m,h=o(()=>{g?(g=!1,u("move",m),d=requestAnimationFrame(h)):d=null},"flushMove"),p=o(C=>{if(m=C,typeof requestAnimationFrame!="function"){u("move",C);return}if(d!==null){g=!0;return}u("move",C),d=requestAnimationFrame(h)},"onMove"),b=o(C=>{d!==null&&(cancelAnimationFrame(d),d=null,g=!1),n.table._reactivity.batch(()=>{u("end",C??m),Nt(n.table,R=>({...R,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))})},"onEnd"),w=e||(typeof document<"u"?document:null),_={moveHandler:o(C=>p(C.clientX),"moveHandler"),upHandler:o(C=>{w?.removeEventListener("mousemove",_.moveHandler),w?.removeEventListener("mouseup",_.upHandler),b(C.clientX)},"upHandler")},S={moveHandler:o(C=>(C.cancelable&&(C.preventDefault(),C.stopPropagation()),p(C.touches[0].clientX),!1),"moveHandler"),upHandler:o(C=>{v(),C.cancelable&&(C.preventDefault(),C.stopPropagation()),b(C.touches[0]?.clientX)},"upHandler"),cancelHandler:o(()=>{v(),b()},"cancelHandler")},v=o(()=>{w?.removeEventListener("touchmove",S.moveHandler),w?.removeEventListener("touchend",S.upHandler),w?.removeEventListener("touchcancel",S.cancelHandler)},"removeTouchEvents"),I=oc()?{passive:!1}:!1;zo(r)?(w?.addEventListener("touchmove",S.moveHandler,I),w?.addEventListener("touchend",S.upHandler,I),w?.addEventListener("touchcancel",S.cancelHandler,I)):(w?.addEventListener("mousemove",_.moveHandler,I),w?.addEventListener("mouseup",_.upHandler,I)),Nt(n.table,C=>({...C,startOffset:i,startSize:a,deltaOffset:0,deltaPercentage:0,columnSizingStart:s,isResizingColumn:n.id}))}}o(Ja,"header_getResizeHandler");function Nt(t,e){t.options.onColumnResizingChange?.(e)}o(Nt,"table_setColumnResizing");function Wa(t,e){Nt(t,e?On():ie(t.initialState.columnResizing??On()))}o(Wa,"table_resetHeaderSizeInfo");var An=null;function oc(){if(typeof An=="boolean")return An;let t=!1;try{let e={get passive(){return t=!0,!1}},n=o(()=>{},"noop");window.addEventListener("test",n,e),window.removeEventListener("test",n)}catch{t=!1}return An=t,An}o(oc,"passiveEventSupported");function zo(t){return t.type==="touchstart"}o(zo,"isTouchStartEvent");var Ho={getInitialState:o(t=>({columnResizing:On(),...t}),"getInitialState"),getDefaultTableOptions:o(t=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnResizingChange:Be("columnResizing",t)}),"getDefaultTableOptions"),assignColumnPrototype:o((t,e)=>{ce("columnResizingFeature",t,e,{column_getCanResize:{fn:o(n=>$o(n),"fn")},column_getIsResizing:{fn:o(n=>Ua(n),"fn")}})},"assignColumnPrototype"),assignHeaderPrototype:o((t,e)=>{ce("columnResizingFeature",t,e,{header_getResizeHandler:{fn:o((n,l)=>Ja(n,l),"fn")}})},"assignHeaderPrototype"),constructTableAPIs:o(t=>{fe("columnResizingFeature",t,{table_setColumnResizing:{fn:o(e=>Nt(t,e),"fn")},table_resetHeaderSizeInfo:{fn:o(e=>Wa(t,e),"fn")}})},"constructTableAPIs")};var Lo={getInitialState:o(t=>({columnSizing:Ea(),...t}),"getInitialState"),getDefaultColumnDef:o(()=>Eo(),"getDefaultColumnDef"),getDefaultTableOptions:o(t=>({onColumnSizingChange:Be("columnSizing",t)}),"getDefaultTableOptions"),assignColumnPrototype:o((t,e)=>{ce("columnSizingFeature",t,e,{column_getSize:{fn:o(n=>kt(n),"fn"),memoDeps:o(n=>[e.options.columns,e.atoms.columnSizing?.get()?.[n.id]],"memoDeps")},column_getStart:{fn:o((n,l)=>za(n,l),"fn")},column_getAfter:{fn:o((n,l)=>$a(n,l),"fn")},column_resetSize:{fn:o(n=>Ha(n),"fn")}})},"assignColumnPrototype"),assignHeaderPrototype:o((t,e)=>{ce("columnSizingFeature",t,e,{header_getSize:{fn:o(n=>rt(n),"fn"),memoDeps:o(n=>[e.options.columns,n.column.columns.length>0?e.atoms.columnSizing?.get():e.atoms.columnSizing?.get()?.[n.column.id]],"memoDeps")},header_getStart:{fn:o(n=>Vo(n),"fn"),memoDeps:o(()=>[e.options.columns,e.atoms.columnSizing?.get(),e.atoms.columnOrder?.get(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get(),e.atoms.grouping?.get(),e.options.groupedColumnMode],"memoDeps")}})},"assignHeaderPrototype"),constructTableAPIs:o(t=>{fe("columnSizingFeature",t,{table_getColumnOffsets:{fn:o(()=>Dn(t),"fn"),memoDeps:o(()=>[t.options.columns,t.atoms.columnSizing?.get(),t.atoms.columnOrder?.get(),t.atoms.columnPinning?.get(),t.atoms.columnVisibility?.get(),t.atoms.grouping?.get(),t.options.groupedColumnMode],"memoDeps")},table_setColumnSizing:{fn:o(e=>Pt(t,e),"fn")},table_resetColumnSizing:{fn:o(e=>ja(t,e),"fn")},table_getTotalSize:{fn:o(()=>Ba(t),"fn"),memoDeps:o(()=>[t.atoms.columnSizing?.get(),t.getHeaderGroups()],"memoDeps")},table_getStartTotalSize:{fn:o(()=>Ga(t),"fn"),memoDeps:o(()=>[t.atoms.columnSizing?.get(),t.getHeaderGroups()],"memoDeps")},table_getCenterTotalSize:{fn:o(()=>qa(t),"fn"),memoDeps:o(()=>[t.atoms.columnSizing?.get(),t.getHeaderGroups()],"memoDeps")},table_getEndTotalSize:{fn:o(()=>Ka(t),"fn"),memoDeps:o(()=>[t.atoms.columnSizing?.get(),t.getHeaderGroups()],"memoDeps")}})},"constructTableAPIs")};var jo={getInitialState:o(t=>({columnVisibility:ul(),...t}),"getInitialState"),getDefaultTableOptions:o(t=>({onColumnVisibilityChange:Be("columnVisibility",t)}),"getDefaultTableOptions"),assignColumnPrototype:o((t,e)=>{ce("columnVisibilityFeature",t,e,{column_getIsVisible:{fn:o(n=>ue(n),"fn"),memoDeps:o(n=>[e.options.columns,e.atoms.columnVisibility?.get(),n.columns],"memoDeps")},column_getCanHide:{fn:o(n=>jt(n),"fn")},column_getToggleVisibilityHandler:{fn:o(n=>dl(n),"fn")},column_toggleVisibility:{fn:o((n,l)=>po(n,l),"fn")}})},"assignColumnPrototype"),assignRowPrototype:o((t,e)=>{ce("columnVisibilityFeature",t,e,{row_getVisibleCells:{fn:o(n=>fo(n),"fn"),memoDeps:o(n=>[n.getAllCells(),e.atoms.columnPinning?.get(),e.atoms.columnVisibility?.get()],"memoDeps")},row_getVisibleCellsByColumnId:{fn:o(n=>yn(n),"fn"),memoDeps:o(n=>[n.getAllCells(),e.atoms.columnVisibility?.get()],"memoDeps")}})},"assignRowPrototype"),constructTableAPIs:o(t=>{fe("columnVisibilityFeature",t,{table_getVisibleFlatColumns:{fn:o(()=>ml(t),"fn"),memoDeps:o(()=>[t.atoms.columnVisibility?.get(),t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.options.columns,t.options.groupedColumnMode],"memoDeps")},table_getVisibleLeafColumns:{fn:o(()=>ht(t),"fn"),memoDeps:o(()=>[t.atoms.columnVisibility?.get(),t.atoms.columnOrder?.get(),t.atoms.grouping?.get(),t.options.columns,t.options.groupedColumnMode],"memoDeps")},table_setColumnVisibility:{fn:o(e=>Bt(t,e),"fn")},table_resetColumnVisibility:{fn:o(e=>gl(t,e),"fn")},table_toggleAllColumnsVisible:{fn:o(e=>bo(t,e),"fn")},table_getIsAllColumnsVisible:{fn:o(()=>ho(t),"fn")},table_getIsSomeColumnsVisible:{fn:o(()=>fl(t),"fn")},table_getToggleAllColumnsVisibilityHandler:{fn:o(()=>pl(t),"fn")}})},"constructTableAPIs")};function Qa(){return H()}o(Qa,"getDefaultRowSelectionState");function St(t,e){t.options.onRowSelectionChange?.(e)}o(St,"table_setRowSelection");function Xa(t,e){t._lastSelectedRowId=null,St(t,e?H():Object.assign(H(),ie(t.initialState.rowSelection??{})))}o(Xa,"table_resetRowSelection");function Bo(t,e,n){t._lastSelectedRowId=null,St(t,l=>{if(e=typeof e<"u"?e:!V(t,"getIsAllRowsSelected",Ko),n?.deselectAll&&!e)return H();let r=Object.assign(H(),l),a=t.getPreGroupedRowModel().flatRows;if(e){let s=new Map;a.forEach(i=>{Tn(i,s)&&(r[i.id]=!0)})}else a.forEach(s=>{Xe(s)&&delete r[s.id]});return r})}o(Bo,"table_toggleAllRowsSelected");function Go(t,e,n){t._lastSelectedRowId=null,St(t,l=>{let r=typeof e<"u"?e:!V(t,"getIsAllPageRowsSelected",Uo);if(n?.deselectAll&&!r)return H();let a=Object.assign(H(),l);return t.getRowModel().rows.forEach(s=>{zn(a,s.id,r,!0,t,!0)}),a})}o(Go,"table_toggleAllPageRowsSelected");function Ya(t){return t.getCoreRowModel()}o(Ya,"table_getPreSelectedRowModel");function Za(t){let e=t.getCoreRowModel();return V(t,"getIsSomeRowsSelected",Wt)?Qo(e,t):{rows:[],flatRows:[],rowsById:H()}}o(Za,"table_getSelectedRowModel");function es(t){let e=t.getFilteredRowModel();return V(t,"getIsSomeRowsSelected",Wt)?Qo(e,t):{rows:[],flatRows:[],rowsById:H()}}o(es,"table_getFilteredSelectedRowModel");function ts(t){let e=t.getSortedRowModel();return V(t,"getIsSomeRowsSelected",Wt)?Qo(e,t):{rows:[],flatRows:[],rowsById:H()}}o(ts,"table_getGroupedSelectedRowModel");function qo(t){return Object.keys(t.atoms.rowSelection?.get()??{})}o(qo,"table_getSelectedRowIds");function Ko(t){let e=t.getFilteredRowModel().flatRows,n=t.atoms.rowSelection?.get()??{},l=!!(e.length&&Object.keys(n).length);if(l){let r=new Map;e.some(a=>!Qt(a,n)&&Tn(a,r))&&(l=!1)}return l}o(Ko,"table_getIsAllRowsSelected");function Uo(t){let e=t.getPaginatedRowModel().flatRows,n=t.atoms.rowSelection?.get()??{},l=new Map,r=!1;for(let a=0;a<e.length;a++){let s=e[a];if(Qt(s,n))!r&&Tn(s,l)&&(r=!0);else if(Tn(s,l))return!1}return r}o(Uo,"table_getIsAllPageRowsSelected");function Wt(t){return V(t,"getSelectedRowIds",qo).length>0}o(Wt,"table_getIsSomeRowsSelected");function ns(t){return t.getPaginatedRowModel().flatRows.filter(e=>Xe(e)).some(e=>En(e)||V(e,"getIsSomeSelected",Wo))}o(ns,"table_getIsSomePageRowsSelected");function os(t){return e=>{Bo(t,e.target.checked)}}o(os,"table_getToggleAllRowsSelectedHandler");function rs(t){return e=>{Go(t,e.target.checked)}}o(rs,"table_getToggleAllPageRowsSelectedHandler");function Jo(t,e,n){let l=En(t);St(t.table,r=>{e=typeof e<"u"?e:!l;let a=Object.assign(H(),r);return zn(a,t.id,e,(n?.selectChildren??!0)&&ut(t),t.table),!e&&n?.deselectParents&&ss(a,t),a})}o(Jo,"row_toggleSelected");function En(t){return Qt(t,t.table.atoms.rowSelection?.get()??{})}o(En,"row_getIsSelected");function Wo(t){return Xo(t)==="some"}o(Wo,"row_getIsSomeSelected");function ls(t){return Xo(t)==="all"}o(ls,"row_getIsAllSubRowsSelected");function Xe(t){let e=t.table.options;return typeof e.enableRowSelection=="function"?e.enableRowSelection(t):e.enableRowSelection??!0}o(Xe,"row_getCanSelect");function Vn(t){let e=t.table.options;return typeof e.enableSubRowSelection=="function"?e.enableSubRowSelection(t):e.enableSubRowSelection??!0}o(Vn,"row_getCanSelectSubRows");function ut(t){let e=t.table.options;return typeof e.enableMultiRowSelection=="function"?e.enableMultiRowSelection(t):e.enableMultiRowSelection??!0}o(ut,"row_getCanMultiSelect");function as(t,e){let n=Xe(t);return l=>{if(!n)return;let r=l,a=t.table,s=r.target.checked,i=a._lastSelectedRowId;(!(a.options.enableRowRangeSelection!==!1&&i!==null&&ut(t)&&(a.options.isRowRangeSelectionEvent?.(l)??!1))||!rc(t,i,s,e))&&Jo(t,s,e),a._lastSelectedRowId=t.id}}o(as,"row_getToggleSelectedHandler");function rc(t,e,n,l){let r=l?.selectChildren??!0,a=t.table,s=a.getRowsInDisplayOrder(),i=a.getPrePaginatedRowModel().rowsById[e]??a.getCoreRowModel().rowsById[e];if(!i)return!1;let c=i.getDisplayIndex(),u=t.getDisplayIndex(),d=s[c],g=s[u];if(c<0||u<0||c>=s.length||u>=s.length||d?.id!==i.id||g?.id!==t.id||!ut(i)||!ut(t))return!1;let m=Math.min(c,u),h=Math.max(c,u);return St(a,p=>{let b=Object.assign(H(),p);for(let w=m;w<=h;w++){let _=s[w];!Xe(_)||!ut(_)||(zn(b,_.id,n,r,a),!n&&l?.deselectParents&&ss(b,_))}return b}),!0}o(rc,"selectRowRange");function zn(t,e,n,l,r,a){let s=r.getRow(e,!0);n?(ut(s)||Object.keys(t).forEach(i=>delete t[i]),Xe(s)&&(t[e]=!0)):(!a||Xe(s))&&delete t[e],l&&s.subRows.length&&Vn(s)&&s.subRows.forEach(i=>zn(t,i.id,n,l,r,a))}o(zn,"mutateRowIsSelected");function Tn(t,e){if(!Xe(t))return!1;let n=t.table;if(n.options.enableSubRowSelection===!0)return!0;let l=t.parentId;if(l===void 0)return!0;let r=e.get(l);if(r!==void 0)return r;let a=n.getCoreRowModel().rowsById,s=[],i=!0,c=l;for(;c!==void 0;){let u=e.get(c);if(u!==void 0){i=u;break}s.push(c);let d=a[c]??n.getRow(c,!0);if(!Vn(d)){i=!1;break}c=d.parentId}return s.forEach(u=>e.set(u,i)),i}o(Tn,"isRowSelectableInSelectAll");function ss(t,e){let n=e.table.getCoreRowModel().rowsById,l=e.parentId;for(;l!==void 0;)delete t[l],l=(n[l]??e.table.getRow(l,!0)).parentId}o(ss,"pruneAncestorRowIds");function is(t,e,n,l){let r=[];for(let a=0;a<t.length;a++){let s=t[a],i=Qt(s,e);if(i&&(n.push(s),l[s.id]=s),s.subRows.length){let c=is(s.subRows,e,n,l);if(i){let u=Object.create(Object.getPrototypeOf(s));_n(u,s),u.subRows=c,r.push(u)}}else i&&r.push(s)}return r}o(is,"selectRowsRecursively");function Qo(t,e){let n=[],l=H(),r=e.atoms.rowSelection?.get()??{};return{rows:is(t.rows,r,n,l),flatRows:n,rowsById:l}}o(Qo,"selectRowsFn");function Qt(t,e){return!!(je(e,t.id)&&e[t.id])}o(Qt,"isRowSelected");function Xo(t){if(!t.subRows.length)return!1;let e=t.table.atoms.rowSelection?.get()??{},n=!1,l=!0,r=!1;for(let a=0;a<t.subRows.length;a++){let s=t.subRows[a];if(n&&!l)break;if(Xe(s)&&(r=!0,Qt(s,e)?n=!0:l=!1),s.subRows.length){let i=Xo(s);i==="all"?(n=!0,r=!0):i==="some"?(n=!0,l=!1,r=!0):l=!1}}return r?l?"all":n?"some":!1:!1}o(Xo,"isSubRowSelected");var Yo={initTableInstanceData:o(t=>{t._lastSelectedRowId=null},"initTableInstanceData"),resetTableInstanceData:o(t=>{t._lastSelectedRowId=null},"resetTableInstanceData"),getInitialState:o(t=>({rowSelection:Qa(),...t}),"getInitialState"),getDefaultTableOptions:o(t=>({onRowSelectionChange:Be("rowSelection",t),enableRowSelection:!0,enableMultiRowSelection:!0,enableRowRangeSelection:!0,enableSubRowSelection:!0,isRowRangeSelectionEvent:o(e=>{let n=e;return!!(n.shiftKey||n.nativeEvent?.shiftKey)},"isRowRangeSelectionEvent")}),"getDefaultTableOptions"),assignRowPrototype:o((t,e)=>{ce("rowSelectionFeature",t,e,{row_toggleSelected:{fn:o((n,l,r)=>Jo(n,l,r),"fn")},row_getIsSelected:{fn:o(n=>En(n),"fn")},row_getIsSomeSelected:{fn:o(n=>Wo(n),"fn"),memoDeps:o(n=>[n.subRows,n.table.atoms.rowSelection?.get(),n.table.options.enableRowSelection],"memoDeps")},row_getIsAllSubRowsSelected:{fn:o(n=>ls(n),"fn"),memoDeps:o(n=>[n.subRows,n.table.atoms.rowSelection?.get(),n.table.options.enableRowSelection],"memoDeps")},row_getCanSelect:{fn:o(n=>Xe(n),"fn")},row_getCanSelectSubRows:{fn:o(n=>Vn(n),"fn")},row_getCanMultiSelect:{fn:o(n=>ut(n),"fn")},row_getToggleSelectedHandler:{fn:o((n,l)=>as(n,l),"fn")}})},"assignRowPrototype"),constructTableAPIs:o(t=>{fe("rowSelectionFeature",t,{table_setRowSelection:{fn:o(e=>St(t,e),"fn")},table_resetRowSelection:{fn:o(e=>Xa(t,e),"fn")},table_toggleAllRowsSelected:{fn:o((e,n)=>Bo(t,e,n),"fn")},table_toggleAllPageRowsSelected:{fn:o((e,n)=>Go(t,e,n),"fn")},table_getPreSelectedRowModel:{fn:o(()=>Ya(t),"fn")},table_getSelectedRowModel:{fn:o(()=>Za(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getCoreRowModel()],"memoDeps")},table_getFilteredSelectedRowModel:{fn:o(()=>es(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getFilteredRowModel()],"memoDeps")},table_getGroupedSelectedRowModel:{fn:o(()=>ts(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getSortedRowModel()],"memoDeps")},table_getSelectedRowIds:{fn:o(()=>qo(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get()],"memoDeps")},table_getIsAllRowsSelected:{fn:o(()=>Ko(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getFilteredRowModel(),t.options.enableRowSelection,t.options.enableSubRowSelection],"memoDeps")},table_getIsAllPageRowsSelected:{fn:o(()=>Uo(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getPaginatedRowModel(),t.options.enableRowSelection,t.options.enableSubRowSelection],"memoDeps")},table_getIsSomeRowsSelected:{fn:o(()=>Wt(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get()],"memoDeps")},table_getIsSomePageRowsSelected:{fn:o(()=>ns(t),"fn"),memoDeps:o(()=>[t.atoms.rowSelection?.get(),t.getPaginatedRowModel(),t.options.enableRowSelection],"memoDeps")},table_getToggleAllRowsSelectedHandler:{fn:o(()=>os(t),"fn")},table_getToggleAllPageRowsSelectedHandler:{fn:o(()=>rs(t),"fn")}})},"constructTableAPIs")};var Zo={getInitialState(t){return{sorting:Xl(),...t}},getDefaultColumnDef(){return{sortFn:"auto",sortUndefined:1}},getDefaultTableOptions(t){return{autoResetSorting:!1,onSortingChange:Be("sorting",t),isMultiSortEvent:o(e=>e.shiftKey,"isMultiSortEvent")}},assignColumnPrototype(t,e){ce("rowSortingFeature",t,e,{column_getAutoSortFn:{fn:o(n=>Fo(n),"fn")},column_getAutoSortDir:{fn:o(n=>Mo(n),"fn")},column_getSortFn:{fn:o(n=>Mn(n),"fn")},column_toggleSorting:{fn:o((n,l,r)=>ko(n,l,r),"fn")},column_getFirstSortDir:{fn:o(n=>Po(n),"fn")},column_getNextSortingOrder:{fn:o((n,l)=>No(n,l),"fn")},column_getCanSort:{fn:o(n=>Ut(n),"fn")},column_getCanMultiSort:{fn:o(n=>qt(n),"fn")},column_getIsSorted:{fn:o(n=>Do(n),"fn")},column_getSortIndex:{fn:o(n=>Zl(n),"fn")},column_clearSorting:{fn:o(n=>ea(n),"fn")},column_getToggleSortingHandler:{fn:o(n=>ta(n),"fn")}})},constructTableAPIs(t){fe("rowSortingFeature",t,{table_setSorting:{fn:o(e=>Kt(t,e),"fn")},table_resetSorting:{fn:o(e=>Io(t,e),"fn")}})}};function er(){return t=>{let e=t;return Ft({feature:"rowSortingFeature",table:e,fnName:"table.getSortedRowModel",memoDeps:o(()=>[e.atoms.sorting?.get(),e.getPreSortedRowModel()],"memoDeps"),fn:o(()=>lc(e),"fn"),onAfterUpdate:Cn(()=>Fn(e))})}}o(er,"createSortedRowModel");function lc(t){let e=t.getPreSortedRowModel(),n=t.atoms.sorting?.get();if(!e.rows.length||!n?.length)return e;let l=[],r=n.filter(c=>{let u=t.getColumn(c.id);return u?Ut(u):!1});if(!r.length)return e;let a=[];for(let c=0;c<r.length;c++){let u=r[c],d=t.getColumn(u.id);d&&a.push({id:u.id,desc:u.desc,sortUndefined:d.columnDef.sortUndefined,invertSorting:d.columnDef.invertSorting,sortFn:Mn(d)})}let s=o((c,u)=>{for(let d=0;d<a.length;d++){let g=a[d],m=g.sortUndefined,h=g.desc,p=0;if(m){let b=c.getValue(g.id),w=u.getValue(g.id),_=b===void 0,S=w===void 0;if(_&&S)continue;if(_||S){if(m==="first")return _?-1:1;if(m==="last")return _?1:-1;p=_?m:-m}}if(p===0&&(p=g.sortFn(c,u,g.id)),p!==0)return h&&(p*=-1),g.invertSorting&&(p*=-1),p}return c.index-u.index},"compareRows"),i=o(c=>{let u=c.slice();u.sort(s);let d=!1;for(let g=0;g<u.length;g++){let m=u[g];m!==c[g]&&(d=!0);let h=l.length;if(l.push(m),m.subRows.length){let p=i(m.subRows);if(p.changed){let b=Object.create(Object.getPrototypeOf(m));_n(b,m),b.subRows=p.rows,u[g]=b,l[h]=b,d=!0}}}return{rows:u,changed:d}},"sortData");return{rows:i(e.rows).rows,flatRows:l,rowsById:e.rowsById}}o(lc,"_createSortedRowModel");var dt=Me(gt(),1);var ac=typeof window>"u"?dt.useEffect:dt.useLayoutEffect;function tr(t,e){let[{table:n,rootSource:l}]=(0,dt.useState)(()=>{let c=Oo({...t,features:{coreReactivityFeature:Qr(),...t.features}});return c.Subscribe=(u=>Jr({...u,source:u.source??c.store})),c.FlexRender=co,{table:c,rootSource:mo(c.store,it)}}),r=n;Jt(r,c=>({...c,...t}),{syncExternalState:!1});let a=r.options.state,s=l.get(),i=on(l,e,{compare:it});return ac(()=>{l.markCommitted(s),Pn(r,a??null,it)}),(0,dt.useMemo)(()=>({...n,options:t,state:i}),[n,t,i])}o(tr,"useTable");var us=Me(Vt(),1),ds=Me(gt(),1),Ie=Me(zt(),1);var sc=[{label:"=",value:"eq"},{label:"\u2260",value:"ne"},{label:"<",value:"lt"},{label:"\u2264",value:"lte"},{label:">",value:"gt"},{label:"\u2265",value:"gte"},{label:"contains",value:"contains"}],ic=o(t=>{let e=t.trim(),n=Number(e);return e!==""&&Number.isFinite(n)&&String(n)===e?n:t},"$"),cc=o(t=>t.operator==="contains"?t.value==="":t.operator!=="eq"&&t.operator!=="ne"&&t.literal===void 0&&t.value.trim()==="","z"),Ye=o(t=>t.filter(e=>e.column!==""&&!cc(e)).map(e=>e.operator==="contains"?{column:e.column,operator:e.operator,value:e.value}:{column:e.column,operator:e.operator,value:e.literal===void 0?ic(e.value):e.literal[0]}),"L"),cs=o((t,e)=>({column:t.column,operator:t.operator,value:t.value,...e}),"P"),ms=o(t=>{let e=(0,us.c)(44),{columns:n,filters:l,onAskAi:r,onFiltersChange:a,onSearchChange:s,search:i}=t,[c,u]=(0,ds.useState)(""),d;e[0]!==n[0]||e[1]!==l||e[2]!==a?(d=o(()=>{a([...l,{column:n[0]??"",operator:"eq",value:""}])},"N"),e[0]=n[0],e[1]=l,e[2]=a,e[3]=d):d=e[3];let g=d,m;e[4]!==l||e[5]!==a?(m=o(F=>{let P=Number(F.currentTarget.dataset.index);a(l.filter((k,N)=>N!==P))},"T"),e[4]=l,e[5]=a,e[6]=m):m=e[6];let h=m,p;e[7]!==l||e[8]!==a?(p=o(F=>{let P=Number(F.currentTarget.dataset.index),k=F.currentTarget.value;a(l.map((N,A)=>A===P?cs(N,{column:k}):N))},"y"),e[7]=l,e[8]=a,e[9]=p):p=e[9];let b=p,w;e[10]!==l||e[11]!==a?(w=o(F=>{let P=Number(F.currentTarget.dataset.index),k=F.currentTarget.value;a(l.map((N,A)=>A===P?{...N,operator:k}:N))},"S"),e[10]=l,e[11]=a,e[12]=w):w=e[12];let _=w,S;e[13]!==l||e[14]!==a?(S=o(F=>{let P=Number(F.currentTarget.dataset.index),k=F.currentTarget.value;a(l.map((N,A)=>A===P?cs(N,{value:k}):N))},"k"),e[13]=l,e[14]=a,e[15]=S):S=e[15];let v=S,I;e[16]!==s||e[17]!==i?(I=(0,Ie.jsx)("input",{"aria-label":"Search rows","data-testid":"db-filter",onChange:s,placeholder:"search table\u2026",value:i}),e[16]=s,e[17]=i,e[18]=I):I=e[18];let C;e[19]!==g?(C=(0,Ie.jsx)("button",{"data-testid":"db-add-filter",onClick:g,type:"button",children:"Add filter"}),e[19]=g,e[20]=C):C=e[20];let R;e[21]!==c||e[22]!==r?(R=r!==void 0&&(0,Ie.jsxs)(Ie.Fragment,{children:[(0,Ie.jsx)("input",{"aria-label":"Describe a filter","data-testid":"db-ai-prompt",onChange:o(F=>{u(F.target.value)},"onChange"),onKeyDown:o(F=>{F.key==="Enter"&&c.trim()!==""&&(F.preventDefault(),r(c.trim()))},"onKeyDown"),placeholder:"describe a filter\u2026",value:c}),(0,Ie.jsx)("button",{"data-testid":"db-ai-filter",disabled:c.trim()==="",onClick:o(()=>{r(c.trim())},"onClick"),type:"button",children:"Suggest"})]}),e[21]=c,e[22]=r,e[23]=R):R=e[23];let x;e[24]!==I||e[25]!==C||e[26]!==R?(x=(0,Ie.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[I,C,R]}),e[24]=I,e[25]=C,e[26]=R,e[27]=x):x=e[27];let y;if(e[28]!==b||e[29]!==_||e[30]!==v||e[31]!==n||e[32]!==l||e[33]!==h){let F;e[35]!==b||e[36]!==_||e[37]!==v||e[38]!==n||e[39]!==h?(F=o((P,k)=>(0,Ie.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-filter-row",children:[(0,Ie.jsx)("select",{"aria-label":"Filter column","data-index":k,"data-testid":"db-filter-column",onChange:b,value:P.column,children:n.map(uc)}),(0,Ie.jsx)("select",{"aria-label":"Filter operator","data-index":k,"data-testid":"db-filter-operator",onChange:_,value:P.operator,children:sc.map(dc)}),(0,Ie.jsx)("input",{"aria-label":"Filter value","data-index":k,"data-testid":"db-filter-value",onChange:v,placeholder:"value",value:P.value}),(0,Ie.jsx)("button",{"aria-label":"Remove filter","data-index":k,"data-testid":"db-filter-remove",onClick:h,type:"button",children:"\u2715"})]},k),"a"),e[35]=b,e[36]=_,e[37]=v,e[38]=n,e[39]=h,e[40]=F):F=e[40],y=l.map(F),e[28]=b,e[29]=_,e[30]=v,e[31]=n,e[32]=l,e[33]=h,e[34]=y}else y=e[34];let M;return e[41]!==y||e[42]!==x?(M=(0,Ie.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"db-filters",children:[x,y]}),e[41]=y,e[42]=x,e[43]=M):M=e[43],M},"M");function uc(t){return(0,Ie.jsx)("option",{value:t,children:t},t)}o(uc,"B");function dc(t){return(0,Ie.jsx)("option",{value:t.value,children:t.label},t.value)}o(dc,"G");var mc=o(t=>({tables:Object.entries(t).map(([e,n])=>({fields:n.map(l=>l.name),indexes:[],name:e,relations:n.filter(l=>l.ref!==void 0).map(l=>({field:l.name,kind:"one",name:l.name,onDelete:l.onDelete,references:l.ref,table:e}))}))}),"_o"),gc=o(t=>{let e=new Map,n=new Set;for(let l of t.tables)for(let r of l.relations){if(r.kind!=="one"||r.onDelete==="set null")continue;let a=r.references,s=`${a}\0${l.name}\0${r.field}`;if(n.has(s))continue;n.add(s);let i=e.get(a)??[];i.push({...r,table:l.name}),e.set(a,i)}return e},"Ro"),fc=o((t,e)=>{let n=[],l=[t];for(;l.length>0;){let r=l.shift();if(r===void 0)break;e(r)&&n.push(r);for(let a of r.children)l.push(a)}return n},"$o"),gs=o((t,e)=>{let n=[];for(let[l,r]of Object.entries(e))for(let a of r)a.ref===t&&n.push({column:a.name,table:l});return n.sort((l,r)=>l.table.localeCompare(r.table)||l.column.localeCompare(r.column)),n},"Jt"),ar=o(t=>`${t.table}.${t.column}`,"It"),pc=o(t=>{let e=(0,q.c)(111),{columns:n,onApply:l,onClose:r,shardKey:a,table:s,total:i,uniqueColumns:c}=t,u=oe(),[d,g]=(0,D.useState)(n[0]??""),[m,h]=(0,D.useState)(""),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p=o(be=>{g(be.target.value)},"u"),e[0]=p):p=e[0];let b=p,w;e[1]===Symbol.for("react.memo_cache_sentinel")?(w=o(be=>{h(be.target.value)},"h"),e[1]=w):w=e[1];let _=w,S;e[2]!==m?(S=m.trim(),e[2]=m,e[3]=S):S=e[3];let v=S==="",I,C;if(e[4]!==v||e[5]!==u||e[6]!==m){if(!v)try{C=nn(JSON.parse(m))}catch(be){I=u("Invalid JSON: {message}",{message:be.message})}e[4]=v,e[5]=u,e[6]=m,e[7]=I,e[8]=C}else I=e[7],C=e[8];let R;e[9]!==d||e[10]!==i||e[11]!==c?(R=c.has(d)&&i>1,e[9]=d,e[10]=i,e[11]=c,e[12]=R):R=e[12];let x=R,y=d!==""&&!v&&I===void 0&&!x,M;e[13]!==y||e[14]!==d||e[15]!==l||e[16]!==r||e[17]!==C?(M=o(()=>{y&&(l({[d]:C}),r())},"T"),e[13]=y,e[14]=d,e[15]=l,e[16]=r,e[17]=C,e[18]=M):M=e[18];let F=M,P;e[19]!==u?(P=u("Set a column on matching rows"),e[19]=u,e[20]=P):P=e[20];let k;e[21]!==u?(k=u("Set a column on matching rows"),e[21]=u,e[22]=k):k=e[22];let N;e[23]!==k?(N=(0,f.jsx)("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:k}),e[23]=k,e[24]=N):N=e[24];let A;e[25]!==u||e[26]!==s||e[27]!==i?(A=u("Writes {total} rows of {table} through the schema-aware writer \u2014 validators and indexes apply, exactly like a mutation.",{table:s,total:i.toString()}),e[25]=u,e[26]=s,e[27]=i,e[28]=A):A=e[28];let z;e[29]!==A?(z=(0,f.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:A}),e[29]=A,e[30]=z):z=e[30];let O;e[31]!==a||e[32]!==u?(O=a===""?u("Shard: root"):u("Shard: {shardKey} \u2014 rows in other shards are not touched.",{shardKey:a}),e[31]=a,e[32]=u,e[33]=O):O=e[33];let $;e[34]!==O?($=(0,f.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:O}),e[34]=O,e[35]=$):$=e[35];let K;e[36]!==z||e[37]!==$||e[38]!==N?(K=(0,f.jsxs)("div",{className:"flex flex-col gap-0.5",children:[N,z,$]}),e[36]=z,e[37]=$,e[38]=N,e[39]=K):K=e[39];let U;e[40]!==u?(U=u("Close"),e[40]=u,e[41]=U):U=e[41];let T;e[42]!==r||e[43]!==U?(T=(0,f.jsx)(rn,{"data-testid":"bulk-patch-close",onClick:r,size:"xs",variant:"ghost",children:U}),e[42]=r,e[43]=U,e[44]=T):T=e[44];let Q;e[45]!==K||e[46]!==T?(Q=(0,f.jsxs)("div",{className:"flex items-start justify-between",children:[K,T]}),e[45]=K,e[46]=T,e[47]=Q):Q=e[47];let J;e[48]!==u?(J=u("Column"),e[48]=u,e[49]=J):J=e[49];let Z;e[50]!==J?(Z=(0,f.jsx)(so,{htmlFor:"bulk-patch-column",children:J}),e[50]=J,e[51]=Z):Z=e[51];let ne;e[52]!==u?(ne=u("Column"),e[52]=u,e[53]=ne):ne=e[53];let te;e[54]!==n?(te=n.map(bc),e[54]=n,e[55]=te):te=e[55];let ae;e[56]!==d||e[57]!==ne||e[58]!==te?(ae=(0,f.jsx)("select",{"aria-label":ne,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:b,value:d,children:te}),e[56]=d,e[57]=ne,e[58]=te,e[59]=ae):ae=e[59];let de;e[60]!==u?(de=u("Value"),e[60]=u,e[61]=de):de=e[61];let pe;e[62]!==de?(pe=(0,f.jsx)(so,{htmlFor:"bulk-patch-value",children:de}),e[62]=de,e[63]=pe):pe=e[63];let Ce;e[64]!==m?(Ce=(0,f.jsx)(_r,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:_,placeholder:"true",value:m}),e[64]=m,e[65]=Ce):Ce=e[65];let xe;e[66]!==Z||e[67]!==ae||e[68]!==pe||e[69]!==Ce?(xe=(0,f.jsxs)("div",{className:"flex items-center gap-2",children:[Z,ae,pe,Ce]}),e[66]=Z,e[67]=ae,e[68]=pe,e[69]=Ce,e[70]=xe):xe=e[70];let Se;e[71]!==I?(Se=I!==void 0&&(0,f.jsx)("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:I}),e[71]=I,e[72]=Se):Se=e[72];let ye;e[73]!==d||e[74]!==u||e[75]!==i||e[76]!==x?(ye=x&&(0,f.jsx)("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:u("{column} has a unique index \u2014 the same value cannot be set on {total} rows.",{column:d,total:i.toString()})}),e[73]=d,e[74]=u,e[75]=i,e[76]=x,e[77]=ye):ye=e[77];let L;e[78]!==v||e[79]!==u||e[80]!==x?(L=v&&!x&&(0,f.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:u('Enter a JSON value \u2014 for example true, 0, null, or "done".')}),e[78]=v,e[79]=u,e[80]=x,e[81]=L):L=e[81];let X;e[82]!==y||e[83]!==d||e[84]!==m?(X=y&&(0,f.jsx)("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${d} = ${m.trim()}`}),e[82]=y,e[83]=d,e[84]=m,e[85]=X):X=e[85];let le;e[86]!==u?(le=u("Cancel"),e[86]=u,e[87]=le):le=e[87];let Fe;e[88]!==r||e[89]!==le?(Fe=(0,f.jsx)(rn,{"data-testid":"bulk-patch-cancel",onClick:r,size:"xs",variant:"outline",children:le}),e[88]=r,e[89]=le,e[90]=Fe):Fe=e[90];let Ne=!y,se;e[91]!==u||e[92]!==i?(se=u("Set on {total} rows",{total:i.toString()}),e[91]=u,e[92]=i,e[93]=se):se=e[93];let ee;e[94]!==F||e[95]!==Ne||e[96]!==se?(ee=(0,f.jsx)(rn,{"data-testid":"bulk-patch-apply",disabled:Ne,onClick:F,size:"xs",children:se}),e[94]=F,e[95]=Ne,e[96]=se,e[97]=ee):ee=e[97];let G;e[98]!==Fe||e[99]!==ee?(G=(0,f.jsxs)("div",{className:"flex justify-end gap-2",children:[Fe,ee]}),e[98]=Fe,e[99]=ee,e[100]=G):G=e[100];let De;return e[101]!==r||e[102]!==Q||e[103]!==xe||e[104]!==Se||e[105]!==ye||e[106]!==L||e[107]!==X||e[108]!==G||e[109]!==P?(De=(0,f.jsxs)(Ht,{label:P,onClose:r,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[Q,xe,Se,ye,L,X,G]}),e[101]=r,e[102]=Q,e[103]=xe,e[104]=Se,e[105]=ye,e[106]=L,e[107]=X,e[108]=G,e[109]=P,e[110]=De):De=e[110],De},"Do");function bc(t){return(0,f.jsx)("option",{value:t,children:t},t)}o(bc,"Ao");var fs=6,Hn=100,hc=o(t=>({paddingLeft:t*16}),"Po"),wc=o(t=>{let e=(0,q.c)(2),{table:n}=t,l=`cascade-restrict-${n}`,r;return e[0]!==l?(r=(0,f.jsx)("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":l,children:"restrict \u2014 will block delete"}),e[0]=l,e[1]=r):r=e[1],r},"Io"),xc=o(t=>{let e=(0,q.c)(2),{table:n}=t,l=`cascade-cascade-${n}`,r;return e[0]!==l?(r=(0,f.jsx)("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":l,children:"cascade"}),e[0]=l,e[1]=r):r=e[1],r},"Fo"),Sc=o(t=>{let e=(0,q.c)(2),{table:n}=t,l=`cascade-undeclared-${n}`,r;return e[0]!==l?(r=(0,f.jsx)("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":l,children:"references \u2014 no delete action declared"}),e[0]=l,e[1]=r):r=e[1],r},"Oo"),_c=o(t=>t.relation===void 0||t.relation.onDelete==="cascade"?(0,f.jsx)(xc,{table:t.table}):t.isRestrict?(0,f.jsx)(wc,{table:t.table}):(0,f.jsx)(Sc,{table:t.table}),"Mo"),ys=o(t=>{let e=(0,q.c)(35),{depth:n,node:l}=t,r=`cascade-row-${l.table}`,a;e[0]!==n?(a=hc(n),e[0]=n,e[1]=a):a=e[1];let s;e[2]!==n?(s=n>0&&(0,f.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2514"}),e[2]=n,e[3]=s):s=e[3];let i;e[4]!==l.table?(i=(0,f.jsx)("span",{className:"font-medium text-foreground",children:l.table}),e[4]=l.table,e[5]=i):i=e[5];let c;e[6]!==l.relation||e[7]!==l.table?(c=l.relation!==void 0&&(0,f.jsxs)("span",{className:"text-muted-foreground","data-testid":`cascade-col-${l.table}-${l.relation.field}`,children:["via ",l.relation.field]}),e[6]=l.relation,e[7]=l.table,e[8]=c):c=e[8];let u;e[9]!==l.rowCount?(u=l.rowCount.toString(),e[9]=l.rowCount,e[10]=u):u=e[10];let d;e[11]!==u?(d=(0,f.jsxs)("span",{className:"text-muted-foreground",children:["(",u," rows)"]}),e[11]=u,e[12]=d):d=e[12];let g;e[13]!==l?(g=_c(l),e[13]=l,e[14]=g):g=e[14];let m;e[15]!==l.capNote||e[16]!==l.table?(m=l.capNote!==void 0&&(0,f.jsxs)("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${l.table}`,children:["(",l.capNote,")"]}),e[15]=l.capNote,e[16]=l.table,e[17]=m):m=e[17];let h;e[18]!==r||e[19]!==a||e[20]!==s||e[21]!==i||e[22]!==c||e[23]!==d||e[24]!==g||e[25]!==m?(h=(0,f.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":r,style:a,children:[s,i,c,d,g,m]}),e[18]=r,e[19]=a,e[20]=s,e[21]=i,e[22]=c,e[23]=d,e[24]=g,e[25]=m,e[26]=h):h=e[26];let p;if(e[27]!==n||e[28]!==l.children){let w;e[30]!==n?(w=o((_,S)=>(0,f.jsx)(ys,{depth:n+1,node:_},`${_.table}-${_.relation?.field??"root"}-${S.toString()}`),"h"),e[30]=n,e[31]=w):w=e[31],p=l.children.map(w),e[27]=n,e[28]=l.children,e[29]=p}else p=e[29];let b;return e[32]!==h||e[33]!==p?(b=(0,f.jsxs)(f.Fragment,{children:[h,p]}),e[32]=h,e[33]=p,e[34]=b):b=e[34],b},"an"),Cc=o(t=>{let e=t._id??t.id??t.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},"Lo"),yc=o(async(t,e,n,l)=>{try{let r=await l(t,e,n),a=r.rows.flatMap(i=>Cc(i)||[]).slice(0,Hn),s=r.total??0;return{capNote:s>Hn?`showing first ${Hn.toString()} of ${s.toString()}`:void 0,rowCount:s,rowIds:a}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},"Vo"),vs=o(async(t,e,n,l,r,a,s)=>{let{capNote:i,rowCount:c,rowIds:u}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await yc(t,n.field,e,s),d=n?.onDelete==="restrict",g=[],m=`${t}:${e}`,h=a>=fs;if(!r.has(m)&&!h){r.add(m);let b=l.get(t)??[];for(let w of b)for(let _ of u.slice(0,10)){let S=await vs(w.table,_,w,l,r,a+1,s);(S.rowCount>0||a===0)&&g.push(S)}r.delete(m)}let p=i;if(h){let b=`depth capped at ${fs.toString()}`;p=i===void 0?b:`${i}; ${b}`}return{capNote:p,children:g,isRestrict:d,relation:n,rowCount:c,rowIds:u,table:t}},"cn"),vc=o(({onClose:t,onConfirm:e,readPage:n,rowId:l,schema:r,table:a})=>{let s=oe(),[i,c]=(0,D.useState)(!0),[u,d]=(0,D.useState)(null),[g,m]=(0,D.useState)(null);(0,D.useEffect)(()=>{let b=!1;return re((async()=>{try{c(!0),m(null);let w=gc(r);if(!((w.get(a)??[]).length>0)){b||(d({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[l],table:a}),c(!1));return}let _=await vs(a,l,void 0,w,new Set,0,n);b||(d(_),c(!1))}catch(w){b||(m(w.message),c(!1))}})()),()=>{b=!0}},[l,a]);let h=u!==null&&fc(u,b=>b.isRestrict).length>0,p=o(()=>{e(),t()},"u");return(0,f.jsxs)(Ht,{label:"Cascade impact preview",onClose:t,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[(0,f.jsxs)("div",{className:"flex items-start justify-between",children:[(0,f.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,f.jsx)("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:s("Cascade impact")}),(0,f.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:s("Delete preview \u2014 rows that would cascade or be blocked")})]}),(0,f.jsx)("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:t,type:"button",children:s("Close")})]}),i&&(0,f.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:s("Loading\u2026")}),g!==null&&(0,f.jsx)("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:g}),!i&&u!==null&&(0,f.jsx)("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:(0,f.jsx)(ys,{depth:0,node:u})}),!i&&u!==null&&u.children.length===0&&(0,f.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:s("No related rows found.")}),h&&(0,f.jsx)("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:s("Restrict relations will block this delete.")}),(0,f.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,f.jsx)("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:t,type:"button",children:s("Cancel")}),(0,f.jsx)("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:i,onClick:p,type:"button",children:s("Delete")})]})]})},"Bo"),Rc=o((t,e,n,l,r=300)=>{if(l<=0)return{ids:new Set(t.map(g=>g.id)),leadPx:0,tailPx:0};let a=n-r,s=n+l+r,i=new Set,c=0,u=0,d=0;for(let g of t){let m=g.getSize(),h=e.has(g.id),p=c+m>a&&c<s;h||p?i.add(g.id):c<a?u+=m:d+=m,c+=m}return{ids:i,leadPx:u,tailPx:d}},"jo"),Ic=o((t,e)=>{let n=new Map,l=0;for(let r of t)e.has(r.id)&&(n.set(r.id,l),l+=r.getSize());return n},"zo"),Fc={columnOrderingFeature:To,columnResizingFeature:Ho,columnSizingFeature:Lo,columnVisibilityFeature:jo,rowSelectionFeature:Yo,rowSortingFeature:Zo,sortedRowModel:er(),sortFns:{alphanumeric:Co,basic:Mt,datetime:vo,text:yo}},Mc=o(()=>{let t=(0,q.c)(12),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={},t[0]=e):e=t[0];let[n,l]=(0,D.useState)(e),r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=o((b,w,_)=>{l(S=>({...S,[b]:{...S[b],[w]:_}}))},"t"),t[1]=r):r=t[1];let a=r,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=o(()=>{l({})},"l"),t[2]=s):s=t[2];let i=s,c;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=o((b,w)=>{l(_=>{let S=_[b];if(S===void 0)return _;let v=Object.fromEntries(Object.entries(S).filter(I=>{let[C,R]=I;return!(C in w)||!Object.is(R,w[C])}));return Object.keys(v).length===0?Object.fromEntries(Object.entries(_).filter(I=>{let[C]=I;return C!==b})):{..._,[b]:v}})},"a"),t[3]=c):c=t[3];let u=c,d;t[4]!==n?(d=o((b,w)=>{let _=n[b];return _!==void 0&&w in _?{value:_[w]}:void 0},"f"),t[4]=n,t[5]=d):d=t[5];let g=d,m;t[6]!==n?(m=Object.values(n).reduce(Pc,0),t[6]=n,t[7]=m):m=t[7];let h=m,p;return t[8]!==h||t[9]!==n||t[10]!==g?(p={clear:i,count:h,drop:u,stage:a,staged:n,stagedValue:g},t[8]=h,t[9]=n,t[10]=g,t[11]=p):p=t[11],p},"Ko"),Rs=o((t,e)=>{if(typeof e=="number"){let n=Number(t);return t.trim()===""||Number.isNaN(n)?t:n}if(typeof e=="boolean"){if(t==="true")return!0;if(t==="false")return!1}return t},"dn"),kc=o(t=>{let e=(0,q.c)(29),{changes:n,committing:l,onCommit:r,onDiscard:a}=t,s=oe(),i;e[0]!==n.length||e[1]!==s?(i=s("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=s,e[2]=i):i=e[2];let c;e[3]!==i?(c=(0,f.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:i}),e[3]=i,e[4]=c):c=e[4];let u;e[5]!==l||e[6]!==s?(u=s(l?"Committing\u2026":"Commit"),e[5]=l,e[6]=s,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==r||e[10]!==u?(d=(0,f.jsx)("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:l,onClick:r,type:"button",children:u}),e[8]=l,e[9]=r,e[10]=u,e[11]=d):d=e[11];let g;e[12]!==s?(g=s("Discard"),e[12]=s,e[13]=g):g=e[13];let m;e[14]!==l||e[15]!==a||e[16]!==g?(m=(0,f.jsx)("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:l,onClick:a,type:"button",children:g}),e[14]=l,e[15]=a,e[16]=g,e[17]=m):m=e[17];let h;e[18]!==c||e[19]!==d||e[20]!==m?(h=(0,f.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d,m]}),e[18]=c,e[19]=d,e[20]=m,e[21]=h):h=e[21];let p;e[22]!==n?(p=n.map(Nc),e[22]=n,e[23]=p):p=e[23];let b;e[24]!==p?(b=(0,f.jsx)("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:p}),e[24]=p,e[25]=b):b=e[25];let w;return e[26]!==h||e[27]!==b?(w=(0,f.jsxs)("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[h,b]}),e[26]=h,e[27]=b,e[28]=w):w=e[28],w},"Go");function Pc(t,e){return t+Object.keys(e).length}o(Pc,"Jo");function Nc(t){return(0,f.jsxs)("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[(0,f.jsxs)("span",{className:"text-muted-foreground",children:[t.rowId,".",t.column]}),(0,f.jsx)("span",{className:"text-destructive line-through",children:Te(t.oldValue)}),(0,f.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2192"}),(0,f.jsx)("span",{className:"text-foreground",children:Te(t.newValue)})]},`${t.rowId}:${t.column}`)}o(Nc,"Wo");var ps=400,Dc=36,Ac={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},Oc={width:"100%"},Tc=/\n$/u,Ec={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Vc={display:"flex",width:"100%"},bs={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},zc="2.5rem",Is={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},sr=o(t=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${t.toString()}px`}),"Ft"),Fs=o((t,e)=>({...sr(t),left:`calc(${zc} + ${e.toString()}px)`,position:"sticky",zIndex:2}),"fn"),nr="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",$c=o((t,e,n)=>e.enabled&&e.columns.has(n)?void 0:t,"ts"),lr="__back__:",Hc=o(t=>`${lr}${t.table}.${t.column}`,"ns"),Lc=o(t=>{let e=(0,q.c)(3),{counts:n,rowId:l}=t;if(n===void 0){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,f.jsx)("span",{className:"text-muted-foreground/50",children:"\u2014"}),e[0]=s):s=e[0],s}let r=n[l]??0,a;return e[1]!==r?(a=(0,f.jsx)("span",{className:"tabular-nums",children:r}),e[1]=r,e[2]=a):a=e[2],a},"os"),Ze=o(t=>{for(let e of["id","__id__","_id"]){let n=t[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},"Pe"),jc=o((t,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(t)||t===""&&e.nullable===!0?{value:t===""?null:t}:void 0;if(e.type==="boolean")return t==="true"||t==="false"?{value:t==="true"}:void 0;if(e.type==="number"){let n=Number(t);return t.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:t}},"ss"),Bc=o((t,e,n)=>{if(n!==void 0&&n.type!=="any")return jc(t,n);let l=Rs(t,e);return typeof e=="number"&&typeof l!="number"?void 0:{value:l}},"ls"),Gc=o(({anchor:t,columnIds:e,columnMeta:n,editableColumn:l,rows:r,text:a})=>{let s=a.replaceAll(`\r
3
3
  `,`
4
4
  `).replace(Tc,"").split(`
@@ -1 +1 @@
1
- import{a as ot}from"./chunk-MJ3SSK6L.js";import"./chunk-Q6IT6ZD7.js";import"./chunk-MTGFTTXO.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as Re}from"./chunk-37WYCOQ2.js";import{a as it}from"./chunk-SV764LKQ.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-AUGKHAMQ.js";import{a as et}from"./chunk-R6U22RSY.js";import{a as nt}from"./chunk-XHRKNCCI.js";import{a as Ze}from"./chunk-YVR4SEPU.js";import{b as Ye}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{h as Pe,i as Be}from"./chunk-OQ6I6OXT.js";import{i as Ue}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as ze}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as We}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as Oe}from"./chunk-3YH5TM3G.js";import"./chunk-NCPW7WHO.js";import"./chunk-WP2AS7SZ.js";import"./chunk-55UGUCQ6.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-DSIY2CMT.js";import{l as Je}from"./chunk-BOYS4DOC.js";import"./chunk-QAQDMS6R.js";import"./chunk-N7LJO732.js";import{a as $e}from"./chunk-RWVIV3U7.js";import{a as tt,b as at,c as rt,d as Fe,e as q,f as T}from"./chunk-HCTJKP5J.js";import{a as He,e as Qe}from"./chunk-2IKDEUCX.js";import{d as le,f as Ve,g as Ge,h as Xe,p as Ne,t as Se}from"./chunk-HJHSQPHW.js";import{a as o,d as se,e as De,f as Ee,g as Ae,i as de}from"./chunk-I26MS5PJ.js";var pe=se(Ee(),1),ue=se(De(),1);var st=se(Ee(),1);var S=se(De(),1);var c=se(Ae(),1);var Nt=Ve(F.runMigration),dt=o(t=>{let e=(0,st.c)(98),{initialShardKey:r}=t,n=Je(),a=le(),{queryShardKey:s,setShardKey:i,shardKey:d}=et(r),[u,b]=(0,S.useState)(""),[h,y]=(0,S.useState)("up"),[p,g]=(0,S.useState)(!0),[f,x]=(0,S.useState)(!1),[v,m]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===s,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==s?(M={live:!0,shardKey:s},e[3]=s,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Te=$.error,{errorSource:Ce,liveError:Me}=$,fe,ge;e[5]!==s||e[6]!==$.data?(fe=o(()=>{$.data!==void 0&&Ye(s)},"W"),ge=[$.data,s],e[5]=s,e[6]=$.data,e[7]=fe,e[8]=ge):(fe=e[7],ge=e[8]),(0,S.useEffect)(fe,ge);let be;if(e[9]!==n||e[10]!==h||e[11]!==p||e[12]!==u||e[13]!==d||e[14]!==$||e[15]!==a){let I=o(async()=>{let Ke=u.trim();if(Ke===""){k(a("Enter a migration id")),m(null);return}x(!0),k(null);try{let Ie=await n.query(Nt,{direction:h,dryRun:p,id:Ke},Ge(d));m(Ie),$.refetch()}catch(Ie){let $t=Ie;m(null),k(Xe($t))}x(!1)},"m");be=o(()=>{Ne(I())},"V"),e[9]=n,e[10]=h,e[11]=p,e[12]=u,e[13]=d,e[14]=$,e[15]=a,e[16]=be}else be=e[16];let ye=be,ve;e[17]===Symbol.for("react.memo_cache_sentinel")?(ve=o(I=>{b(I.target.value)},"Y"),e[17]=ve):ve=e[17];let xt=ve,xe;e[18]===Symbol.for("react.memo_cache_sentinel")?(xe=o(I=>{y(I.target.value==="down"?"down":"up")},"Z"),e[18]=xe):xe=e[18];let kt=xe,ke;e[19]===Symbol.for("react.memo_cache_sentinel")?(ke=o(I=>{g(I.target.checked)},"ee"),e[19]=ke):ke=e[19];let wt=ke,_;e[20]!==i||e[21]!==d?(_=(0,c.jsx)(Ze,{onChange:i,testId:"mg-shard-input",value:d}),e[20]=i,e[21]=d,e[22]=_):_=e[22];let K;e[23]!==Me?(K=(0,c.jsx)(it,{message:Me,prefix:"mg"}),e[23]=Me,e[24]=K):K=e[24];let D;e[25]!==_||e[26]!==K?(D=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,K]}),e[25]=_,e[26]=K,e[27]=D):D=e[27];let E;e[28]!==Te||e[29]!==Ce?(E=Te!==null&&(0,c.jsx)(Oe,{error:Ce,testId:"mg-status-error"}),e[28]=Te,e[29]=Ce,e[30]=E):E=e[30];let A;e[31]!==N||e[32]!==a?(A=N!==null&&N.length===0&&(0,c.jsx)($e,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,c.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,c.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=A):A=e[33];let J;e[34]!==N||e[35]!==a?(J=N!==null&&N.length>0&&(0,c.jsx)(He,{className:"overflow-hidden py-0",children:(0,c.jsx)(Qe,{className:"px-0",children:(0,c.jsxs)(tt,{"data-testid":"mg-table",children:[(0,c.jsx)(at,{children:(0,c.jsxs)(Fe,{children:[(0,c.jsx)(q,{children:a("id")}),(0,c.jsx)(q,{children:a("direction")}),(0,c.jsx)(q,{children:a("status")}),(0,c.jsx)(q,{children:a("processed")}),(0,c.jsx)(q,{children:a("changed")}),(0,c.jsx)(q,{children:a("updated")}),(0,c.jsx)(q,{children:a("error")})]})}),(0,c.jsx)(rt,{children:N.map(St)})]})})}),e[34]=N,e[35]=a,e[36]=J):J=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,c.jsx)(Re,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==u||e[46]!==W||e[47]!==U?(z=(0,c.jsx)(Ue,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:xt,placeholder:U,value:u}),e[45]=u,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,c.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,c.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,c.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:kt,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,c.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:wt,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,c.jsxs)(Re,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ye||e[73]!==f||e[74]!==C||e[75]!==a?(ae=p?(0,c.jsx)(ze,{"data-testid":"mg-run",disabled:f||!C,onClick:ye,type:"button",children:a(f?"Running\u2026":"Run")}):(0,c.jsx)(nt,{confirmLabel:a(f?"Running\u2026":"Run migration?"),disabled:f||!C,onConfirm:ye,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ye,e[73]=f,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ne;e[82]!==B||e[83]!==re?(ne=(0,c.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ne):ne=e[84];let ie;e[85]!==w?(ie=w!==null&&(0,c.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ie):ie=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,c.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let we;return e[90]!==D||e[91]!==E||e[92]!==A||e[93]!==J||e[94]!==ne||e[95]!==ie||e[96]!==oe?(we=(0,c.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[D,E,A,J,ne,ie,oe]}),e[90]=D,e[91]=E,e[92]=A,e[93]=J,e[94]=ne,e[95]=ie,e[96]=oe,e[97]=we):we=e[97],we},"yt");function St(t){return(0,c.jsxs)(Fe,{"data-testid":`mg-row-${t.id}`,children:[(0,c.jsx)(T,{children:t.id}),(0,c.jsx)(T,{children:t.direction}),(0,c.jsx)(T,{children:(0,c.jsx)(We,{variant:"secondary",children:t.status})}),(0,c.jsx)(T,{children:t.processed}),(0,c.jsx)(T,{children:t.changed}),(0,c.jsx)(T,{children:Se(t.updatedAt)}),(0,c.jsx)(T,{children:t.error??""})]},t.id)}o(St,"Je");var l=se(Ae(),1);var Le=1;function Ot(t){let e={},r=Object.keys(t);r.sort();for(let n of r)e[n]=t[n];return e}o(Ot,"re");var me=o(t=>typeof t=="object"&&t!==null,"O"),jt=o(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","de"),qt=o(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Le||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Le)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!jt(n))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Le},status:"ok"}},"le"),Tt=o((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,n)=>r===e.fields[n]),"ce"),lt=o(t=>t.unique!==void 0,"J"),_e=o(({nullable:t,optional:e,refined:r,unique:n,...a})=>JSON.stringify(Ot(a)),"D"),ct=o(t=>({form:JSON.stringify([_e(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"H"),mt=o(t=>t.kind==="union"&&t.members?t.members.map(e=>ct(e)):[ct({...t,nullable:!1,optional:!1})],"V"),Ct=o((t,e)=>{if(e.kind!=="union")return!1;let r=mt(e);return mt(t).every(n=>r.some(a=>a.form===n.form&&(n.refined||!a.refined)))},"me"),O=o(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),he=o((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"T"),qe=o((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"q"),Mt=o((t,e,r,n,a)=>{if(!(r.kind===n.kind&&(!a||_e(r)===_e(n))))return a&&Ct(r,n)?qe(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(r)} \u2192 ${O(n)} \u2014 every stored value stays valid`):r.kind!==n.kind?he(t,"changedFieldKind",`field ${t}.${e} changed type: ${r.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`):he(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(r)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"he"),It=o((t,e,r,n)=>{let a=[];return r.unique!==n.unique&&a.push(n.unique===!0?he(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==n.nullable&&a.push(n.nullable===!0?qe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):he(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==n.refined&&a.push(n.refined===!0?he(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"fe"),yt=o((t,e,r,n)=>{let a=[],s=lt(r)&&lt(n),i=Mt(t,e,r,n,s);return i&&a.push(i),s&&a.push(...It(t,e,r,n)),r.optional&&!n.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"Y"),Ft=o((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ue"),Rt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.fields)){let i=e.fields[a];i===void 0?n.push(Ft(t,a,s)):n.push(...yt(t,a,i,s))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&n.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"pe"),Lt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.indexes)){let i=e.indexes[a];if(i===void 0){n.push(s.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Tt(i,s)||n.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&n.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ge"),_t=o((t,e,r,n)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&n.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"be"),ut="shardBy:_unknown_",je="global",Kt=o((t,e)=>t===je&&e.startsWith(`${je}:`)||e===je&&t.startsWith(`${je}:`),"ye"),Dt=o((t,e,r)=>{if(e===r)return r!==ut?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${ut}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Kt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"ve"),ht=o(t=>t.memory!==void 0,"Q"),pt=o(t=>t.after??0,"W"),R=o(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Et=o((t,e,r)=>{if(e===void 0&&r===void 0)return;let n=o(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"n"),a=o(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"s");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return n(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return n(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let s=pt(e),i=pt(r);return i<s?n(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):i>s?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"xe"),At=o((t,e,r)=>{let n=[];return e.memory!==r.memory&&n.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&n.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),n},"ke"),Jt=o((t,e,r,n)=>{let a=Dt(t,e.shardMode,r.shardMode);if(a&&n.push(a),ht(e)&&ht(r)){n.push(...At(t,e,r));let s=Et(t,e.ttl,r.ttl);s&&n.push(s)}Rt(t,e,r,n),Lt(t,e,r,n),_t(t,e,r,n)},"$e"),Pt=o((t,e)=>{let r=[],n=t?.tables??{};for(let[a,s]of Object.entries(e.tables)){let i=n[a];if(i===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}Jt(a,i,s,r)}for(let a of Object.keys(n))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",s=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${s} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"we"),ft=o(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:O(r)})),"B"),gt=o((t,e,r)=>{let n={},a=e?.fields??{},s=r?.fields??{};for(let[i,d]of Object.entries(s)){let u=a[i];u===void 0?n[i]=e===void 0?"unchanged":"added":n[i]=yt(t,i,u,d).length===0?"unchanged":"changed"}for(let i of Object.keys(a))s[i]===void 0&&(n[i]="removed");return n},"U"),Bt=o((t,e)=>{let{changes:r}=Pt(t,e),n=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),a=[],s=o((i,d)=>i?"added":n.has(d)?"changed":"context","a");for(let[i,d]of Object.entries(e.tables)){let u=t?.tables[i],b=s(u===void 0,i);a.push({columns:ft(d),fieldStatus:gt(i,u,d),name:i,shardMode:d.shardMode,status:b})}for(let[i,d]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&a.push({columns:ft(d),fieldStatus:gt(i,d,void 0),name:i,shardMode:d.shardMode,status:"removed"});return a.sort((i,d)=>i.name.localeCompare(d.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:a}},"Oe"),bt=o(t=>{let e=qt(t);return e.status==="ok"?e.snapshot:void 0},"K"),Wt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Ut=o(t=>t==="global"||t.startsWith("global:")?"global":"shard","Te"),zt=o(t=>{let e=(0,pe.c)(24),{appliedAt:r,hash:n,onSelect:a,selected:s,seq:i}=t,d=s?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==d?(u=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=u):u=e[1];let b=`sh-version-${n}`,h;e[2]!==n||e[3]!==a?(h=o(()=>{a(n)},"u"),e[2]=n,e[3]=a,e[4]=h):h=e[4];let y;e[5]!==i?(y=(0,l.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=y):y=e[6];let p;e[7]!==n?(p=n.slice(0,7),e[7]=n,e[8]=p):p=e[8];let g;e[9]!==p?(g=(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=g):g=e[10];let f;e[11]!==y||e[12]!==g?(f=(0,l.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[y,g]}),e[11]=y,e[12]=g,e[13]=f):f=e[13];let x;e[14]!==r?(x=Se(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,l.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let m;return e[18]!==v||e[19]!==u||e[20]!==b||e[21]!==h||e[22]!==f?(m=(0,l.jsx)("li",{children:(0,l.jsxs)("button",{className:u,"data-testid":b,onClick:h,type:"button",children:[f,v]})}),e[18]=v,e[19]=u,e[20]=b,e[21]=h,e[22]=f,e[23]=m):m=e[23],m},"je"),Ht=o(t=>{let e=(0,pe.c)(26),{breaking:r,count:n,first:a}=t,s=le();if(a){let g;e[0]!==n?(g=(0,l.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=g):g=e[1];let f;e[2]!==s?(f=s("tables"),e[2]=s,e[3]=f):f=e[3];let x;e[4]!==f?(x=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=x):x=e[5];let v;return e[6]!==g||e[7]!==x?(v=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[g,x]}),e[6]=g,e[7]=x,e[8]=v):v=e[8],v}let i=r>0&&"text-destructive",d;e[9]!==i?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=d):d=e[10];let u;e[11]!==n||e[12]!==d?(u=(0,l.jsx)("span",{className:d,children:n}),e[11]=n,e[12]=d,e[13]=u):u=e[13];let b;e[14]!==n||e[15]!==s?(b=s(n===1?"change":"changes"),e[14]=n,e[15]=s,e[16]=b):b=e[16];let h;e[17]!==b?(h=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:b}),e[17]=b,e[18]=h):h=e[18];let y;e[19]!==r||e[20]!==s?(y=r>0&&(0,l.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",s("{count} breaking",{count:r})]}),e[19]=r,e[20]=s,e[21]=y):y=e[21];let p;return e[22]!==u||e[23]!==h||e[24]!==y?(p=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,h,y]}),e[22]=u,e[23]=h,e[24]=y,e[25]=p):p=e[25],p},"Fe"),vt={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Qt=o((t,e)=>{let r=`${vt[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"qe"),Vt=o(t=>{let e=new Map;for(let n of t){let a=n.table??"",s=e.get(a);s===void 0?e.set(a,[n]):s.push(n)}let r=[...e].map(([n,a])=>({changes:a,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"Ce"),Gt=o(t=>{let e=(0,pe.c)(2),{children:r}=t,n;return e[0]!==r?(n=(0,l.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=n):n=e[1],n},"Me"),Xt=o(({pane:t,shardKey:e=""})=>{let r=le(),n=Be(),a=Pe({strict:!1}).version,s=o(m=>{Ne(n({search:{version:m},to:"/migrations"}))},"o"),i=ce(F.schemaHistory,{},{shardKey:e}),d=i.data?.versions??[],u=a!==void 0&&d.some(m=>m.hash===a)?a:d[0]?.hash,b=d.findIndex(m=>m.hash===u),h=b===-1?void 0:d[b+1]?.hash,y=ce(F.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),g=(0,ue.useMemo)(()=>{let m=bt(y.data?.version?.snapshotJson);if(m!==void 0)return Bt(bt(p.data?.version?.snapshotJson),m)},[y.data,p.data]),f=(0,ue.useMemo)(()=>(g?.tables??[]).map(m=>({columns:m.columns,name:m.name,tier:Ut(m.shardMode)})),[g]),x=(0,ue.useMemo)(()=>{let m={};for(let w of g?.tables??[])m[w.name]=Wt[w.status];return m},[g]);if(i.error!==null)return(0,l.jsx)(Oe,{error:i.errorSource,testId:"sh-error"});if(d.length===0)return(0,l.jsx)($e,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=g?.changes??[];return(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,l.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,l.jsx)(Gt,{children:r("Schema versions")}),(0,l.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(m=>(0,l.jsx)(zt,{appliedAt:m.appliedAt,hash:m.hash,onSelect:s,selected:m.hash===u,seq:m.seq},m.hash))})]}),(0,l.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,l.jsx)(Ht,{breaking:g?.breakingCount??0,count:h===void 0?f.length:v.length,first:h===void 0}),t==="diagram"?(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,l.jsx)(ot,{fill:!0,nodeClasses:x,tables:f,testIdPrefix:"sh"})}):(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Vt(v).map(m=>{let w=(g?.tables??[]).find(k=>k.name===m.table);return(0,l.jsxs)("section",{className:"mb-6",children:[(0,l.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,l.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:m.table===""?r("schema"):m.table}),w!==void 0&&(0,l.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),m.changes.length>1&&(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:m.changes.length})]}),(0,l.jsx)("ul",{children:m.changes.map(k=>{let{action:L,kind:C}=vt[k.type],j=k.severity==="breaking",M=Qt(k,C);return(0,l.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,l.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,l.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==m.table&&(0,l.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,l.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},m.table)})})]})]})},"Ie"),Yt=o(t=>de("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Re"),Ta=o(t=>{let e=(0,pe.c)(11),{initialShardKey:r}=t,n=le(),[a,s]=(0,ue.useState)("diagram"),i;e[0]!==a?(i=o((y,p,g,f)=>(0,l.jsxs)("button",{"aria-selected":a===y,className:Yt(a===y),"data-testid":g,onClick:o(()=>{s(y)},"onClick"),role:"tab",type:"button",children:[p,f!==void 0&&(0,l.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),"o"),e[0]=a,e[1]=i):i=e[1];let d=i,u;e[2]!==n||e[3]!==d?(u=(0,l.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",n("Diagram"),"mg-pane-diagram"),d("changes",n("Changes"),"mg-pane-changes"),d("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=d,e[4]=u):u=e[4];let b;e[5]!==r||e[6]!==a?(b=(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,l.jsx)(dt,{initialShardKey:r})}):(0,l.jsx)(Xt,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=b):b=e[7];let h;return e[8]!==u||e[9]!==b?(h=(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,b]}),e[8]=u,e[9]=b,e[10]=h):h=e[10],h},"Ue");export{Ta as default};
1
+ import{a as ot}from"./chunk-QLKZIBWQ.js";import"./chunk-Q6IT6ZD7.js";import"./chunk-CY7FSXYX.js";import"./chunk-NQZALRU3.js";import"./chunk-OPM7ESDV.js";import"./chunk-Y3AYVFTK.js";import{a as Re}from"./chunk-37WYCOQ2.js";import{a as it}from"./chunk-SV764LKQ.js";import"./chunk-OYCUPD3Q.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import"./chunk-AUGKHAMQ.js";import{a as et}from"./chunk-R6U22RSY.js";import{a as nt}from"./chunk-XHRKNCCI.js";import{a as Ze}from"./chunk-YVR4SEPU.js";import{b as Ye}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{h as Pe,i as Be}from"./chunk-OQ6I6OXT.js";import{i as Ue}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as ze}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as We}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as Oe}from"./chunk-7VJPXCOU.js";import"./chunk-NCPW7WHO.js";import"./chunk-3S4PZ7KQ.js";import"./chunk-55UGUCQ6.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-QUXXMJPZ.js";import{l as Je}from"./chunk-BWKZ6FFW.js";import"./chunk-QAQDMS6R.js";import"./chunk-DYR23C3V.js";import{a as $e}from"./chunk-RWVIV3U7.js";import{a as tt,b as at,c as rt,d as Fe,e as q,f as T}from"./chunk-HCTJKP5J.js";import{a as He,e as Qe}from"./chunk-2IKDEUCX.js";import{d as le,f as Ve,g as Ge,h as Xe,p as Ne,t as Se}from"./chunk-HJHSQPHW.js";import{a as o,d as se,e as De,f as Ee,g as Ae,i as de}from"./chunk-I26MS5PJ.js";var pe=se(Ee(),1),ue=se(De(),1);var st=se(Ee(),1);var S=se(De(),1);var c=se(Ae(),1);var Nt=Ve(F.runMigration),dt=o(t=>{let e=(0,st.c)(98),{initialShardKey:r}=t,n=Je(),a=le(),{queryShardKey:s,setShardKey:i,shardKey:d}=et(r),[u,b]=(0,S.useState)(""),[h,y]=(0,S.useState)("up"),[p,g]=(0,S.useState)(!0),[f,x]=(0,S.useState)(!1),[v,m]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===s,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==s?(M={live:!0,shardKey:s},e[3]=s,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Te=$.error,{errorSource:Ce,liveError:Me}=$,fe,ge;e[5]!==s||e[6]!==$.data?(fe=o(()=>{$.data!==void 0&&Ye(s)},"W"),ge=[$.data,s],e[5]=s,e[6]=$.data,e[7]=fe,e[8]=ge):(fe=e[7],ge=e[8]),(0,S.useEffect)(fe,ge);let be;if(e[9]!==n||e[10]!==h||e[11]!==p||e[12]!==u||e[13]!==d||e[14]!==$||e[15]!==a){let I=o(async()=>{let Ke=u.trim();if(Ke===""){k(a("Enter a migration id")),m(null);return}x(!0),k(null);try{let Ie=await n.query(Nt,{direction:h,dryRun:p,id:Ke},Ge(d));m(Ie),$.refetch()}catch(Ie){let $t=Ie;m(null),k(Xe($t))}x(!1)},"m");be=o(()=>{Ne(I())},"V"),e[9]=n,e[10]=h,e[11]=p,e[12]=u,e[13]=d,e[14]=$,e[15]=a,e[16]=be}else be=e[16];let ye=be,ve;e[17]===Symbol.for("react.memo_cache_sentinel")?(ve=o(I=>{b(I.target.value)},"Y"),e[17]=ve):ve=e[17];let xt=ve,xe;e[18]===Symbol.for("react.memo_cache_sentinel")?(xe=o(I=>{y(I.target.value==="down"?"down":"up")},"Z"),e[18]=xe):xe=e[18];let kt=xe,ke;e[19]===Symbol.for("react.memo_cache_sentinel")?(ke=o(I=>{g(I.target.checked)},"ee"),e[19]=ke):ke=e[19];let wt=ke,_;e[20]!==i||e[21]!==d?(_=(0,c.jsx)(Ze,{onChange:i,testId:"mg-shard-input",value:d}),e[20]=i,e[21]=d,e[22]=_):_=e[22];let K;e[23]!==Me?(K=(0,c.jsx)(it,{message:Me,prefix:"mg"}),e[23]=Me,e[24]=K):K=e[24];let D;e[25]!==_||e[26]!==K?(D=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,K]}),e[25]=_,e[26]=K,e[27]=D):D=e[27];let E;e[28]!==Te||e[29]!==Ce?(E=Te!==null&&(0,c.jsx)(Oe,{error:Ce,testId:"mg-status-error"}),e[28]=Te,e[29]=Ce,e[30]=E):E=e[30];let A;e[31]!==N||e[32]!==a?(A=N!==null&&N.length===0&&(0,c.jsx)($e,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,c.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,c.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=A):A=e[33];let J;e[34]!==N||e[35]!==a?(J=N!==null&&N.length>0&&(0,c.jsx)(He,{className:"overflow-hidden py-0",children:(0,c.jsx)(Qe,{className:"px-0",children:(0,c.jsxs)(tt,{"data-testid":"mg-table",children:[(0,c.jsx)(at,{children:(0,c.jsxs)(Fe,{children:[(0,c.jsx)(q,{children:a("id")}),(0,c.jsx)(q,{children:a("direction")}),(0,c.jsx)(q,{children:a("status")}),(0,c.jsx)(q,{children:a("processed")}),(0,c.jsx)(q,{children:a("changed")}),(0,c.jsx)(q,{children:a("updated")}),(0,c.jsx)(q,{children:a("error")})]})}),(0,c.jsx)(rt,{children:N.map(St)})]})})}),e[34]=N,e[35]=a,e[36]=J):J=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,c.jsx)(Re,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==u||e[46]!==W||e[47]!==U?(z=(0,c.jsx)(Ue,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:xt,placeholder:U,value:u}),e[45]=u,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,c.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,c.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,c.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:kt,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,c.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:wt,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,c.jsxs)(Re,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ye||e[73]!==f||e[74]!==C||e[75]!==a?(ae=p?(0,c.jsx)(ze,{"data-testid":"mg-run",disabled:f||!C,onClick:ye,type:"button",children:a(f?"Running\u2026":"Run")}):(0,c.jsx)(nt,{confirmLabel:a(f?"Running\u2026":"Run migration?"),disabled:f||!C,onConfirm:ye,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ye,e[73]=f,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ne;e[82]!==B||e[83]!==re?(ne=(0,c.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ne):ne=e[84];let ie;e[85]!==w?(ie=w!==null&&(0,c.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ie):ie=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,c.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let we;return e[90]!==D||e[91]!==E||e[92]!==A||e[93]!==J||e[94]!==ne||e[95]!==ie||e[96]!==oe?(we=(0,c.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[D,E,A,J,ne,ie,oe]}),e[90]=D,e[91]=E,e[92]=A,e[93]=J,e[94]=ne,e[95]=ie,e[96]=oe,e[97]=we):we=e[97],we},"yt");function St(t){return(0,c.jsxs)(Fe,{"data-testid":`mg-row-${t.id}`,children:[(0,c.jsx)(T,{children:t.id}),(0,c.jsx)(T,{children:t.direction}),(0,c.jsx)(T,{children:(0,c.jsx)(We,{variant:"secondary",children:t.status})}),(0,c.jsx)(T,{children:t.processed}),(0,c.jsx)(T,{children:t.changed}),(0,c.jsx)(T,{children:Se(t.updatedAt)}),(0,c.jsx)(T,{children:t.error??""})]},t.id)}o(St,"Je");var l=se(Ae(),1);var Le=1;function Ot(t){let e={},r=Object.keys(t);r.sort();for(let n of r)e[n]=t[n];return e}o(Ot,"re");var me=o(t=>typeof t=="object"&&t!==null,"O"),jt=o(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","de"),qt=o(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Le||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Le)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!jt(n))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Le},status:"ok"}},"le"),Tt=o((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,n)=>r===e.fields[n]),"ce"),lt=o(t=>t.unique!==void 0,"J"),_e=o(({nullable:t,optional:e,refined:r,unique:n,...a})=>JSON.stringify(Ot(a)),"D"),ct=o(t=>({form:JSON.stringify([_e(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"H"),mt=o(t=>t.kind==="union"&&t.members?t.members.map(e=>ct(e)):[ct({...t,nullable:!1,optional:!1})],"V"),Ct=o((t,e)=>{if(e.kind!=="union")return!1;let r=mt(e);return mt(t).every(n=>r.some(a=>a.form===n.form&&(n.refined||!a.refined)))},"me"),O=o(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),he=o((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"T"),qe=o((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"q"),Mt=o((t,e,r,n,a)=>{if(!(r.kind===n.kind&&(!a||_e(r)===_e(n))))return a&&Ct(r,n)?qe(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(r)} \u2192 ${O(n)} \u2014 every stored value stays valid`):r.kind!==n.kind?he(t,"changedFieldKind",`field ${t}.${e} changed type: ${r.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`):he(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(r)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"he"),It=o((t,e,r,n)=>{let a=[];return r.unique!==n.unique&&a.push(n.unique===!0?he(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==n.nullable&&a.push(n.nullable===!0?qe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):he(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==n.refined&&a.push(n.refined===!0?he(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"fe"),yt=o((t,e,r,n)=>{let a=[],s=lt(r)&&lt(n),i=Mt(t,e,r,n,s);return i&&a.push(i),s&&a.push(...It(t,e,r,n)),r.optional&&!n.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"Y"),Ft=o((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ue"),Rt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.fields)){let i=e.fields[a];i===void 0?n.push(Ft(t,a,s)):n.push(...yt(t,a,i,s))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&n.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"pe"),Lt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.indexes)){let i=e.indexes[a];if(i===void 0){n.push(s.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Tt(i,s)||n.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&n.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ge"),_t=o((t,e,r,n)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&n.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"be"),ut="shardBy:_unknown_",je="global",Kt=o((t,e)=>t===je&&e.startsWith(`${je}:`)||e===je&&t.startsWith(`${je}:`),"ye"),Dt=o((t,e,r)=>{if(e===r)return r!==ut?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${ut}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Kt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"ve"),ht=o(t=>t.memory!==void 0,"Q"),pt=o(t=>t.after??0,"W"),R=o(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Et=o((t,e,r)=>{if(e===void 0&&r===void 0)return;let n=o(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"n"),a=o(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"s");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return n(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return n(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let s=pt(e),i=pt(r);return i<s?n(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):i>s?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"xe"),At=o((t,e,r)=>{let n=[];return e.memory!==r.memory&&n.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&n.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),n},"ke"),Jt=o((t,e,r,n)=>{let a=Dt(t,e.shardMode,r.shardMode);if(a&&n.push(a),ht(e)&&ht(r)){n.push(...At(t,e,r));let s=Et(t,e.ttl,r.ttl);s&&n.push(s)}Rt(t,e,r,n),Lt(t,e,r,n),_t(t,e,r,n)},"$e"),Pt=o((t,e)=>{let r=[],n=t?.tables??{};for(let[a,s]of Object.entries(e.tables)){let i=n[a];if(i===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}Jt(a,i,s,r)}for(let a of Object.keys(n))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",s=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${s} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"we"),ft=o(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:O(r)})),"B"),gt=o((t,e,r)=>{let n={},a=e?.fields??{},s=r?.fields??{};for(let[i,d]of Object.entries(s)){let u=a[i];u===void 0?n[i]=e===void 0?"unchanged":"added":n[i]=yt(t,i,u,d).length===0?"unchanged":"changed"}for(let i of Object.keys(a))s[i]===void 0&&(n[i]="removed");return n},"U"),Bt=o((t,e)=>{let{changes:r}=Pt(t,e),n=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),a=[],s=o((i,d)=>i?"added":n.has(d)?"changed":"context","a");for(let[i,d]of Object.entries(e.tables)){let u=t?.tables[i],b=s(u===void 0,i);a.push({columns:ft(d),fieldStatus:gt(i,u,d),name:i,shardMode:d.shardMode,status:b})}for(let[i,d]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&a.push({columns:ft(d),fieldStatus:gt(i,d,void 0),name:i,shardMode:d.shardMode,status:"removed"});return a.sort((i,d)=>i.name.localeCompare(d.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:a}},"Oe"),bt=o(t=>{let e=qt(t);return e.status==="ok"?e.snapshot:void 0},"K"),Wt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Ut=o(t=>t==="global"||t.startsWith("global:")?"global":"shard","Te"),zt=o(t=>{let e=(0,pe.c)(24),{appliedAt:r,hash:n,onSelect:a,selected:s,seq:i}=t,d=s?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==d?(u=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=u):u=e[1];let b=`sh-version-${n}`,h;e[2]!==n||e[3]!==a?(h=o(()=>{a(n)},"u"),e[2]=n,e[3]=a,e[4]=h):h=e[4];let y;e[5]!==i?(y=(0,l.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=y):y=e[6];let p;e[7]!==n?(p=n.slice(0,7),e[7]=n,e[8]=p):p=e[8];let g;e[9]!==p?(g=(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=g):g=e[10];let f;e[11]!==y||e[12]!==g?(f=(0,l.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[y,g]}),e[11]=y,e[12]=g,e[13]=f):f=e[13];let x;e[14]!==r?(x=Se(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,l.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let m;return e[18]!==v||e[19]!==u||e[20]!==b||e[21]!==h||e[22]!==f?(m=(0,l.jsx)("li",{children:(0,l.jsxs)("button",{className:u,"data-testid":b,onClick:h,type:"button",children:[f,v]})}),e[18]=v,e[19]=u,e[20]=b,e[21]=h,e[22]=f,e[23]=m):m=e[23],m},"je"),Ht=o(t=>{let e=(0,pe.c)(26),{breaking:r,count:n,first:a}=t,s=le();if(a){let g;e[0]!==n?(g=(0,l.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=g):g=e[1];let f;e[2]!==s?(f=s("tables"),e[2]=s,e[3]=f):f=e[3];let x;e[4]!==f?(x=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=x):x=e[5];let v;return e[6]!==g||e[7]!==x?(v=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[g,x]}),e[6]=g,e[7]=x,e[8]=v):v=e[8],v}let i=r>0&&"text-destructive",d;e[9]!==i?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=d):d=e[10];let u;e[11]!==n||e[12]!==d?(u=(0,l.jsx)("span",{className:d,children:n}),e[11]=n,e[12]=d,e[13]=u):u=e[13];let b;e[14]!==n||e[15]!==s?(b=s(n===1?"change":"changes"),e[14]=n,e[15]=s,e[16]=b):b=e[16];let h;e[17]!==b?(h=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:b}),e[17]=b,e[18]=h):h=e[18];let y;e[19]!==r||e[20]!==s?(y=r>0&&(0,l.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",s("{count} breaking",{count:r})]}),e[19]=r,e[20]=s,e[21]=y):y=e[21];let p;return e[22]!==u||e[23]!==h||e[24]!==y?(p=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,h,y]}),e[22]=u,e[23]=h,e[24]=y,e[25]=p):p=e[25],p},"Fe"),vt={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Qt=o((t,e)=>{let r=`${vt[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"qe"),Vt=o(t=>{let e=new Map;for(let n of t){let a=n.table??"",s=e.get(a);s===void 0?e.set(a,[n]):s.push(n)}let r=[...e].map(([n,a])=>({changes:a,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"Ce"),Gt=o(t=>{let e=(0,pe.c)(2),{children:r}=t,n;return e[0]!==r?(n=(0,l.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=n):n=e[1],n},"Me"),Xt=o(({pane:t,shardKey:e=""})=>{let r=le(),n=Be(),a=Pe({strict:!1}).version,s=o(m=>{Ne(n({search:{version:m},to:"/migrations"}))},"o"),i=ce(F.schemaHistory,{},{shardKey:e}),d=i.data?.versions??[],u=a!==void 0&&d.some(m=>m.hash===a)?a:d[0]?.hash,b=d.findIndex(m=>m.hash===u),h=b===-1?void 0:d[b+1]?.hash,y=ce(F.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),g=(0,ue.useMemo)(()=>{let m=bt(y.data?.version?.snapshotJson);if(m!==void 0)return Bt(bt(p.data?.version?.snapshotJson),m)},[y.data,p.data]),f=(0,ue.useMemo)(()=>(g?.tables??[]).map(m=>({columns:m.columns,name:m.name,tier:Ut(m.shardMode)})),[g]),x=(0,ue.useMemo)(()=>{let m={};for(let w of g?.tables??[])m[w.name]=Wt[w.status];return m},[g]);if(i.error!==null)return(0,l.jsx)(Oe,{error:i.errorSource,testId:"sh-error"});if(d.length===0)return(0,l.jsx)($e,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=g?.changes??[];return(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,l.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,l.jsx)(Gt,{children:r("Schema versions")}),(0,l.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(m=>(0,l.jsx)(zt,{appliedAt:m.appliedAt,hash:m.hash,onSelect:s,selected:m.hash===u,seq:m.seq},m.hash))})]}),(0,l.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,l.jsx)(Ht,{breaking:g?.breakingCount??0,count:h===void 0?f.length:v.length,first:h===void 0}),t==="diagram"?(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,l.jsx)(ot,{fill:!0,nodeClasses:x,tables:f,testIdPrefix:"sh"})}):(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Vt(v).map(m=>{let w=(g?.tables??[]).find(k=>k.name===m.table);return(0,l.jsxs)("section",{className:"mb-6",children:[(0,l.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,l.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:m.table===""?r("schema"):m.table}),w!==void 0&&(0,l.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),m.changes.length>1&&(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:m.changes.length})]}),(0,l.jsx)("ul",{children:m.changes.map(k=>{let{action:L,kind:C}=vt[k.type],j=k.severity==="breaking",M=Qt(k,C);return(0,l.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,l.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,l.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==m.table&&(0,l.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,l.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},m.table)})})]})]})},"Ie"),Yt=o(t=>de("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Re"),Ta=o(t=>{let e=(0,pe.c)(11),{initialShardKey:r}=t,n=le(),[a,s]=(0,ue.useState)("diagram"),i;e[0]!==a?(i=o((y,p,g,f)=>(0,l.jsxs)("button",{"aria-selected":a===y,className:Yt(a===y),"data-testid":g,onClick:o(()=>{s(y)},"onClick"),role:"tab",type:"button",children:[p,f!==void 0&&(0,l.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),"o"),e[0]=a,e[1]=i):i=e[1];let d=i,u;e[2]!==n||e[3]!==d?(u=(0,l.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",n("Diagram"),"mg-pane-diagram"),d("changes",n("Changes"),"mg-pane-changes"),d("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=d,e[4]=u):u=e[4];let b;e[5]!==r||e[6]!==a?(b=(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,l.jsx)(dt,{initialShardKey:r})}):(0,l.jsx)(Xt,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=b):b=e[7];let h;return e[8]!==u||e[9]!==b?(h=(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,b]}),e[8]=u,e[9]=b,e[10]=h):h=e[10],h},"Ue");export{Ta as default};
@@ -1 +1 @@
1
- import{a as g}from"./chunk-4ZEL6BYL.js";import{c as k}from"./chunk-DSIY2CMT.js";import{l as S}from"./chunk-BOYS4DOC.js";import{d as _,f as y,g as v,o as C}from"./chunk-HJHSQPHW.js";import{a as i,d as N,e as L,f as T,g as F}from"./chunk-I26MS5PJ.js";var w=N(L(),1);var j={},A=y(g.aiGenerateSql),I=y(g.aiTableFilter),O=y(g.aiChartConfig),Q=i(s=>{let e=S(),[l,d]=(0,w.useState)({}),[n,t]=(0,w.useState)({}),a=k(g.aiAvailable,j,{shardKey:s}),[u,c]=(0,w.useState)(!1),x=u||a.data?.available===!1,p=i(o=>{d(r=>({...r,[o]:!0})),t(r=>({...r,[o]:void 0}))},"i"),h=i((o,r)=>{d(b=>({...b,[o]:!1})),r!==void 0&&t(b=>({...b,[o]:r})),r==="no-ai-binding"&&c(!0)},"a"),f=i(async o=>{p("sql");try{let{result:r}=await e.query(A,o,v(s));return h("sql",r.degraded?r.reason:void 0),r.degraded?void 0:r.sql}catch{h("sql","ai-error");return}},"f");return{generate:i(async(o,r)=>f({failedError:r?.error,failedSql:r?.sql,prompt:o}),"generate"),inferChart:i(async o=>{p("chart");try{let{result:r}=await e.query(O,o,v(s));return h("chart",r.degraded?r.reason:void 0),r.degraded?void 0:r.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:i(o=>l[o]===!0,"pending"),reason:i(o=>n[o],"reason"),rewrite:i(async(o,r)=>f({editSql:r,prompt:o}),"rewrite"),suggestFilter:i(async(o,r)=>{p("filter");try{let{result:b}=await e.query(I,{prompt:o,table:r},v(s));return h("filter",b.degraded?b.reason:void 0),b.degraded?void 0:b.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:x}},"Q");var q=N(T(),1);var m=N(F(),1);var G=i((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let l=[],d=s.toLowerCase(),n=e.toLowerCase(),t=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,t))a>t&&l.push({match:!1,offset:t,text:s.slice(t,a)}),l.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),t=a+e.length;return t<s.length&&l.push({match:!1,offset:t,text:s.slice(t)}),l},"N"),U=i(s=>{let e=(0,q.c)(9),{highlight:l,value:d}=s;if(d==null){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=c):c=e[0],c}let n,t,a;if(e[1]!==l||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let c=C(d);if(l===void 0||l===""){a=(0,m.jsx)("span",{title:c,children:c});break e}n=c,t=G(c,l).map(z)}e[1]=l,e[2]=d,e[3]=n,e[4]=t,e[5]=a}else n=e[3],t=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let u;return e[6]!==n||e[7]!==t?(u=(0,m.jsx)("span",{title:n,children:t}),e[6]=n,e[7]=t,e[8]=u):u=e[8],u},"v"),P=i(s=>{let e=(0,q.c)(22),{columns:l,rows:d}=s,n=_(),t;e[0]!==n?(t=n("Field"),e[0]=n,e[1]=t):t=e[1];let a;e[2]!==t?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:t}),e[2]=t,e[3]=a):a=e[3];let u;if(e[4]!==d||e[5]!==n){let f;e[7]!==n?(f=i((o,r)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:r+1})},r),"c"),e[7]=n,e[8]=f):f=e[8],u=d.map(f),e[4]=d,e[5]=n,e[6]=u}else u=e[6];let c;e[9]!==a||e[10]!==u?(c=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,u]})}),e[9]=a,e[10]=u,e[11]=c):c=e[11];let x;if(e[12]!==l||e[13]!==d){let f;e[15]!==d?(f=i(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((r,b)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(U,{value:r[o]})},b))]},o),"c"),e[15]=d,e[16]=f):f=e[16],x=l.map(f),e[12]=l,e[13]=d,e[14]=x}else x=e[14];let p;e[17]!==x?(p=(0,m.jsx)("tbody",{children:x}),e[17]=x,e[18]=p):p=e[18];let h;return e[19]!==c||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[c,p]})}),e[19]=c,e[20]=p,e[21]=h):h=e[21],h},"T"),V=i(({children:s,layout:e="card",testId:l})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":l,children:s}),"j");function z(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}i(z,"_");export{Q as a,U as b,P as c,V as d};
1
+ import{a as g}from"./chunk-4ZEL6BYL.js";import{c as k}from"./chunk-QUXXMJPZ.js";import{l as S}from"./chunk-BWKZ6FFW.js";import{d as _,f as y,g as v,o as C}from"./chunk-HJHSQPHW.js";import{a as i,d as N,e as L,f as T,g as F}from"./chunk-I26MS5PJ.js";var w=N(L(),1);var j={},A=y(g.aiGenerateSql),I=y(g.aiTableFilter),O=y(g.aiChartConfig),Q=i(s=>{let e=S(),[l,d]=(0,w.useState)({}),[n,t]=(0,w.useState)({}),a=k(g.aiAvailable,j,{shardKey:s}),[u,c]=(0,w.useState)(!1),x=u||a.data?.available===!1,p=i(o=>{d(r=>({...r,[o]:!0})),t(r=>({...r,[o]:void 0}))},"i"),h=i((o,r)=>{d(b=>({...b,[o]:!1})),r!==void 0&&t(b=>({...b,[o]:r})),r==="no-ai-binding"&&c(!0)},"a"),f=i(async o=>{p("sql");try{let{result:r}=await e.query(A,o,v(s));return h("sql",r.degraded?r.reason:void 0),r.degraded?void 0:r.sql}catch{h("sql","ai-error");return}},"f");return{generate:i(async(o,r)=>f({failedError:r?.error,failedSql:r?.sql,prompt:o}),"generate"),inferChart:i(async o=>{p("chart");try{let{result:r}=await e.query(O,o,v(s));return h("chart",r.degraded?r.reason:void 0),r.degraded?void 0:r.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:i(o=>l[o]===!0,"pending"),reason:i(o=>n[o],"reason"),rewrite:i(async(o,r)=>f({editSql:r,prompt:o}),"rewrite"),suggestFilter:i(async(o,r)=>{p("filter");try{let{result:b}=await e.query(I,{prompt:o,table:r},v(s));return h("filter",b.degraded?b.reason:void 0),b.degraded?void 0:b.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:x}},"Q");var q=N(T(),1);var m=N(F(),1);var G=i((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let l=[],d=s.toLowerCase(),n=e.toLowerCase(),t=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,t))a>t&&l.push({match:!1,offset:t,text:s.slice(t,a)}),l.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),t=a+e.length;return t<s.length&&l.push({match:!1,offset:t,text:s.slice(t)}),l},"N"),U=i(s=>{let e=(0,q.c)(9),{highlight:l,value:d}=s;if(d==null){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=c):c=e[0],c}let n,t,a;if(e[1]!==l||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let c=C(d);if(l===void 0||l===""){a=(0,m.jsx)("span",{title:c,children:c});break e}n=c,t=G(c,l).map(z)}e[1]=l,e[2]=d,e[3]=n,e[4]=t,e[5]=a}else n=e[3],t=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let u;return e[6]!==n||e[7]!==t?(u=(0,m.jsx)("span",{title:n,children:t}),e[6]=n,e[7]=t,e[8]=u):u=e[8],u},"v"),P=i(s=>{let e=(0,q.c)(22),{columns:l,rows:d}=s,n=_(),t;e[0]!==n?(t=n("Field"),e[0]=n,e[1]=t):t=e[1];let a;e[2]!==t?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:t}),e[2]=t,e[3]=a):a=e[3];let u;if(e[4]!==d||e[5]!==n){let f;e[7]!==n?(f=i((o,r)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:r+1})},r),"c"),e[7]=n,e[8]=f):f=e[8],u=d.map(f),e[4]=d,e[5]=n,e[6]=u}else u=e[6];let c;e[9]!==a||e[10]!==u?(c=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,u]})}),e[9]=a,e[10]=u,e[11]=c):c=e[11];let x;if(e[12]!==l||e[13]!==d){let f;e[15]!==d?(f=i(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((r,b)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(U,{value:r[o]})},b))]},o),"c"),e[15]=d,e[16]=f):f=e[16],x=l.map(f),e[12]=l,e[13]=d,e[14]=x}else x=e[14];let p;e[17]!==x?(p=(0,m.jsx)("tbody",{children:x}),e[17]=x,e[18]=p):p=e[18];let h;return e[19]!==c||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[c,p]})}),e[19]=c,e[20]=p,e[21]=h):h=e[21],h},"T"),V=i(({children:s,layout:e="card",testId:l})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":l,children:s}),"j");function z(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}i(z,"_");export{Q as a,U as b,P as c,V as d};
@@ -1 +1 @@
1
- import{b as P}from"./chunk-R6PJYMJT.js";import{c as K,d as X,e as z,f as L,h as B,i as E,j as G,k as q,l as A,m as O,n as W,o as $,p as D}from"./chunk-TIQ7OBZJ.js";import{a as F,b as H,c as I,d as S,e as J,f as M}from"./chunk-HCTJKP5J.js";import{d as C,o as j}from"./chunk-HJHSQPHW.js";import{a as f,d as T,f as U,g as V}from"./chunk-I26MS5PJ.js";var N=T(U(),1);var t=T(V(),1);var _=50,R={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},Q=f(r=>{let a=r.columns.find(e=>r.rows.length>0&&r.rows.every(n=>typeof n[e]=="number"))??null;return{label:r.columns.find(e=>e!==a)??null,value:a}},"D"),Y=f(r=>{let a=(0,N.c)(3),{data:e,kind:n}=r,l;return a[0]!==e||a[1]!==n?(l=(0,t.jsx)(G,{className:"h-full w-full",config:R,children:n==="area"?(0,t.jsxs)(E,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(z,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,t.jsxs)(B,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(X,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=e,a[1]=n,a[2]=l):l=a[2],l},"J"),na=f(r=>{let a=(0,N.c)(21),{axes:e,kind:n,result:l}=r,u=C(),o;a[0]!==l?(o=Q(l),a[0]=l,a[1]=o):o=a[1];let d=o,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let s=m,c=e!==void 0&&s.has(e.x)?e.x:d.label,p;a[4]!==e?.y||a[5]!==s?(p=e?.y.find(i=>s.has(i)),a[4]=e?.y,a[5]=s,a[6]=p):p=a[6];let x=p,y=x??d.value,b;a[7]!==c||a[8]!==l.rows||a[9]!==y?(b=y===null?[]:l.rows.slice(0,_).map((i,w)=>({label:c===null?`#${(w+1).toString()}`:j(i[c]),value:Number(i[y])||0})),a[7]=c,a[8]=l.rows,a[9]=y,a[10]=b):b=a[10];let k=b;if(y===null){let i;a[11]!==u?(i=u("No numeric column to chart."),a[11]=u,a[12]=i):i=a[12];let w;return a[13]!==i?(w=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:i}),a[13]=i,a[14]=w):w=a[14],w}let h=n??(e!==void 0&&x!==void 0?e.kind:"bar"),v;a[15]!==k||a[16]!==h?(v=h==="bar"?(0,t.jsxs)(O,{className:"h-full w-full",config:R,data:k,children:[(0,t.jsx)($,{dataKey:"label"}),(0,t.jsx)(W,{dataKey:"value"}),(0,t.jsx)(D,{})]}):(0,t.jsx)(Y,{data:k,kind:h}),a[15]=k,a[16]=h,a[17]=v):v=a[17];let g;return a[18]!==h||a[19]!==v?(g=(0,t.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":h,"data-testid":"sql-chart",children:v}),a[18]=h,a[19]=v,a[20]=g):g=a[20],g},"oe"),oa=f(r=>{let a=(0,N.c)(19),{result:e}=r,n=C();if(e.columns.length===0){let s;a[0]!==e.rowCount||a[1]!==n?(s=n("{count} rows",{count:e.rowCount}),a[0]=e.rowCount,a[1]=n,a[2]=s):s=a[2];let c;return a[3]!==s?(c=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:s}),a[3]=s,a[4]=c):c=a[4],c}let l;a[5]!==e.columns?(l=e.columns.map(Z),a[5]=e.columns,a[6]=l):l=a[6];let u;a[7]!==l?(u=(0,t.jsx)(H,{className:"sticky top-0 z-10 bg-muted",children:(0,t.jsx)(S,{children:l})}),a[7]=l,a[8]=u):u=a[8];let o;if(a[9]!==e.columns||a[10]!==e.rows){let s;a[12]!==e.columns?(s=f((c,p)=>(0,t.jsx)(S,{"data-testid":"sql-row",children:e.columns.map(x=>(0,t.jsx)(M,{className:"max-w-md truncate font-mono text-xs",children:(0,t.jsx)(P,{value:c[x]})},x))},p),"s"),a[12]=e.columns,a[13]=s):s=a[13],o=e.rows.map(s),a[9]=e.columns,a[10]=e.rows,a[11]=o}else o=a[11];let d;a[14]!==o?(d=(0,t.jsx)(I,{children:o}),a[14]=o,a[15]=d):d=a[15];let m;return a[16]!==u||a[17]!==d?(m=(0,t.jsxs)(F,{"data-testid":"sql-rows",children:[u,d]}),a[16]=u,a[17]=d,a[18]=m):m=a[18],m},"ne");function Z(r){return(0,t.jsx)(J,{children:r},r)}f(Z,"P");export{na as a,oa as b};
1
+ import{b as P}from"./chunk-ZNVNSNDU.js";import{c as K,d as X,e as z,f as L,h as B,i as E,j as G,k as q,l as A,m as O,n as W,o as $,p as D}from"./chunk-WHDFMKYB.js";import{a as F,b as H,c as I,d as S,e as J,f as M}from"./chunk-HCTJKP5J.js";import{d as C,o as j}from"./chunk-HJHSQPHW.js";import{a as f,d as T,f as U,g as V}from"./chunk-I26MS5PJ.js";var N=T(U(),1);var t=T(V(),1);var _=50,R={value:{colors:{dark:["var(--chart-1)"],light:["var(--chart-1)"]},label:"value"}},Q=f(r=>{let a=r.columns.find(e=>r.rows.length>0&&r.rows.every(n=>typeof n[e]=="number"))??null;return{label:r.columns.find(e=>e!==a)??null,value:a}},"D"),Y=f(r=>{let a=(0,N.c)(3),{data:e,kind:n}=r,l;return a[0]!==e||a[1]!==n?(l=(0,t.jsx)(G,{className:"h-full w-full",config:R,children:n==="area"?(0,t.jsxs)(E,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(z,{dataKey:"value",fill:"var(--color-value-0)",fillOpacity:.2,stroke:"var(--color-value-0)",type:"monotone"})]}):(0,t.jsxs)(B,{data:e,children:[(0,t.jsx)(K,{vertical:!1}),(0,t.jsx)(L,{axisLine:!1,dataKey:"label",tickLine:!1}),(0,t.jsx)(A,{content:(0,t.jsx)(q,{})}),(0,t.jsx)(X,{dataKey:"value",dot:!1,stroke:"var(--color-value-0)",strokeWidth:2,type:"monotone"})]})}),a[0]=e,a[1]=n,a[2]=l):l=a[2],l},"J"),na=f(r=>{let a=(0,N.c)(21),{axes:e,kind:n,result:l}=r,u=C(),o;a[0]!==l?(o=Q(l),a[0]=l,a[1]=o):o=a[1];let d=o,m;a[2]!==l.columns?(m=new Set(l.columns),a[2]=l.columns,a[3]=m):m=a[3];let s=m,c=e!==void 0&&s.has(e.x)?e.x:d.label,p;a[4]!==e?.y||a[5]!==s?(p=e?.y.find(i=>s.has(i)),a[4]=e?.y,a[5]=s,a[6]=p):p=a[6];let x=p,y=x??d.value,b;a[7]!==c||a[8]!==l.rows||a[9]!==y?(b=y===null?[]:l.rows.slice(0,_).map((i,w)=>({label:c===null?`#${(w+1).toString()}`:j(i[c]),value:Number(i[y])||0})),a[7]=c,a[8]=l.rows,a[9]=y,a[10]=b):b=a[10];let k=b;if(y===null){let i;a[11]!==u?(i=u("No numeric column to chart."),a[11]=u,a[12]=i):i=a[12];let w;return a[13]!==i?(w=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-chart-empty",children:i}),a[13]=i,a[14]=w):w=a[14],w}let h=n??(e!==void 0&&x!==void 0?e.kind:"bar"),v;a[15]!==k||a[16]!==h?(v=h==="bar"?(0,t.jsxs)(O,{className:"h-full w-full",config:R,data:k,children:[(0,t.jsx)($,{dataKey:"label"}),(0,t.jsx)(W,{dataKey:"value"}),(0,t.jsx)(D,{})]}):(0,t.jsx)(Y,{data:k,kind:h}),a[15]=k,a[16]=h,a[17]=v):v=a[17];let g;return a[18]!==h||a[19]!==v?(g=(0,t.jsx)("div",{className:"h-80 w-full p-3","data-chart-kind":h,"data-testid":"sql-chart",children:v}),a[18]=h,a[19]=v,a[20]=g):g=a[20],g},"oe"),oa=f(r=>{let a=(0,N.c)(19),{result:e}=r,n=C();if(e.columns.length===0){let s;a[0]!==e.rowCount||a[1]!==n?(s=n("{count} rows",{count:e.rowCount}),a[0]=e.rowCount,a[1]=n,a[2]=s):s=a[2];let c;return a[3]!==s?(c=(0,t.jsx)("p",{className:"p-4 text-sm text-muted-foreground",children:s}),a[3]=s,a[4]=c):c=a[4],c}let l;a[5]!==e.columns?(l=e.columns.map(Z),a[5]=e.columns,a[6]=l):l=a[6];let u;a[7]!==l?(u=(0,t.jsx)(H,{className:"sticky top-0 z-10 bg-muted",children:(0,t.jsx)(S,{children:l})}),a[7]=l,a[8]=u):u=a[8];let o;if(a[9]!==e.columns||a[10]!==e.rows){let s;a[12]!==e.columns?(s=f((c,p)=>(0,t.jsx)(S,{"data-testid":"sql-row",children:e.columns.map(x=>(0,t.jsx)(M,{className:"max-w-md truncate font-mono text-xs",children:(0,t.jsx)(P,{value:c[x]})},x))},p),"s"),a[12]=e.columns,a[13]=s):s=a[13],o=e.rows.map(s),a[9]=e.columns,a[10]=e.rows,a[11]=o}else o=a[11];let d;a[14]!==o?(d=(0,t.jsx)(I,{children:o}),a[14]=o,a[15]=d):d=a[15];let m;return a[16]!==u||a[17]!==d?(m=(0,t.jsxs)(F,{"data-testid":"sql-rows",children:[u,d]}),a[16]=u,a[17]=d,a[18]=m):m=a[18],m},"ne");function Z(r){return(0,t.jsx)(J,{children:r},r)}f(Z,"P");export{na as a,oa as b};