@lunora/studio 1.0.0-alpha.146 → 1.0.0-alpha.147
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.
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/mount.mjs +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ApiTab.mjs +1 -1
- package/dist/packem_chunks/AuditPanel.mjs +1 -1
- package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ExportImportPanel.mjs +3 -3
- package/dist/packem_chunks/FileBrowser.mjs +1 -1
- package/dist/packem_chunks/FunctionRunner.mjs +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
- package/dist/packem_chunks/HealthPanel.mjs +1 -1
- package/dist/packem_chunks/InsightsPanel.mjs +1 -1
- package/dist/packem_chunks/LogsPanel.mjs +1 -1
- package/dist/packem_chunks/MailPanel.mjs +1 -1
- package/dist/packem_chunks/MetricsPanel.mjs +1 -1
- package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
- package/dist/packem_chunks/PitrPanel.mjs +1 -1
- package/dist/packem_chunks/SchemaViewer.mjs +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
- package/dist/packem_chunks/SettingsPanel.mjs +1 -1
- package/dist/packem_chunks/SqlEditorPanel.mjs +7 -8
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/agents-panel.mjs +1 -1
- package/dist/packem_chunks/analytics-panel.mjs +1 -1
- package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
- package/dist/packem_chunks/auth-config-panel.mjs +1 -1
- package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
- package/dist/packem_chunks/containers-panel.mjs +1 -1
- package/dist/packem_chunks/dashboards-panel.mjs +1 -1
- package/dist/packem_chunks/evals-panel.mjs +1 -1
- package/dist/packem_chunks/fanout-panel.mjs +1 -1
- package/dist/packem_chunks/flags-panel.mjs +1 -1
- package/dist/packem_chunks/issues-panel.mjs +1 -1
- package/dist/packem_chunks/kv-browser.mjs +1 -1
- package/dist/packem_chunks/log-drains-panel.mjs +1 -1
- package/dist/packem_chunks/migrations-route.mjs +1 -1
- package/dist/packem_chunks/organizations-panel.mjs +1 -1
- package/dist/packem_chunks/payments-panel.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/queues-panel.mjs +1 -1
- package/dist/packem_chunks/reactors-panel.mjs +1 -1
- package/dist/packem_chunks/rls-panel.mjs +1 -1
- package/dist/packem_chunks/schedule-panel.mjs +1 -1
- package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
- package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
- package/dist/packem_chunks/sync-client-panel.mjs +1 -1
- package/dist/packem_chunks/traces-panel.mjs +1 -1
- package/dist/packem_chunks/users-panel.mjs +1 -1
- package/dist/packem_chunks/vector-browser.mjs +1 -1
- package/dist/packem_chunks/workflows-panel.mjs +1 -1
- package/dist/packem_shared/{ApiDocsPanel-CHCIjzZu.mjs → ApiDocsPanel-BImfQhyJ.mjs} +1 -1
- package/dist/packem_shared/{ApiReferencePanel-Cqy9Z7mO.mjs → ApiReferencePanel-B4i-KeOf.mjs} +1 -1
- package/dist/packem_shared/{CommandPalette-DtLEYVhX.mjs → CommandPalette-CSdz9zax.mjs} +1 -1
- package/dist/packem_shared/DataBrowser-Bpj-0P1G.mjs +4 -0
- package/dist/packem_shared/{GlobalDataBrowser-CDpzXZxj.mjs → GlobalDataBrowser-BTbqR6Wc.mjs} +1 -1
- package/dist/packem_shared/{HomePanel-4gpRjcch.mjs → HomePanel-_BwLI4TQ.mjs} +1 -1
- package/dist/packem_shared/{MigrationsPanel-Cz0x3Pv6.mjs → MigrationsPanel-BPWzFdxC.mjs} +1 -1
- package/dist/packem_shared/{OpenRpcReferencePanel-DZicbIOf.mjs → OpenRpcReferencePanel-BKJEX7we.mjs} +1 -1
- package/dist/packem_shared/{ScheduledJobs-BWziDVZO.mjs → ScheduledJobs-B4DPADwk.mjs} +1 -1
- package/dist/packem_shared/{Studio-C_yEjXcG.mjs → Studio-CcWQdYrV.mjs} +1 -1
- package/dist/packem_shared/{StudioApp-BQAxVB3v.mjs → StudioApp-B5jLGbeH.mjs} +1 -1
- package/dist/packem_shared/{advisor-view-DyXQCN4y.mjs → advisor-view-CPgOok_h.mjs} +1 -1
- package/dist/packem_shared/{data-grid-B8WGnT-5.mjs → data-grid-DTBAKZlm.mjs} +1 -1
- package/dist/packem_shared/{error-alert-ClpDVYvo.mjs → error-alert-tf5zvSLV.mjs} +1 -1
- package/dist/packem_shared/{grid-features-CGs2pKcr.mjs → grid-features-Dl7bCGRN.mjs} +4 -4
- package/dist/packem_shared/{home-panel-CHtt8k50.mjs → home-panel-DCUKd8Uk.mjs} +1 -1
- package/dist/packem_shared/internal-B6haJbiP.mjs +2 -0
- package/dist/packem_shared/{log-line-DpRfHaVQ.mjs → log-line-BoObzuue.mjs} +1 -1
- package/dist/packem_shared/{recording-client-CMvFFEC0.mjs → recording-client-BXUIyBL4.mjs} +1 -1
- package/dist/packem_shared/{reference-view-DS7FFPpP.mjs → reference-view-AC9FgXSz.mjs} +1 -1
- package/dist/packem_shared/{schema-diagram-C27ETi10.mjs → schema-diagram-CDj_69jF.mjs} +1 -1
- package/dist/packem_shared/{sql-result-table-BLIMecXM.mjs → sql-result-table-C5y0jwaK.mjs} +1 -1
- package/dist/packem_shared/{studio-DF0GqQBP.mjs → studio-OqNyRY1N.mjs} +1 -1
- package/dist/packem_shared/table-list-sidebar-DHG1UJC4.mjs +1 -0
- package/dist/packem_shared/{use-admin-query-BvZH4unR.mjs → use-admin-query-BKXiqLci.mjs} +1 -1
- package/dist/packem_shared/{use-async-submit-C1A11ka9.mjs → use-async-submit-BTr3w2-K.mjs} +1 -1
- package/dist/packem_shared/{use-auth-config-DocoJ5uQ.mjs → use-auth-config-BQKGdSFh.mjs} +1 -1
- package/dist/packem_shared/{use-open-trace-CTQIPjo9.mjs → use-open-trace-BCW0c9qq.mjs} +1 -1
- package/dist/packem_shared/{use-sql-assistant-BGoWYcGL.mjs → use-sql-assistant-BhIMDQHV.mjs} +1 -1
- package/dist/packem_shared/{wire-codec-BE-vgg1L.mjs → wire-codec-C0jSa3ZC.mjs} +1 -1
- package/dist/standalone/{chunk-6T3STPM7.js → chunk-2ES4GR4C.js} +1 -1
- package/dist/standalone/{chunk-HLE46T7J.js → chunk-2GPQJLCR.js} +1 -1
- package/dist/standalone/chunk-2GZVY7CX.js +1 -0
- package/dist/standalone/chunk-2LN3T5HY.js +15 -0
- package/dist/standalone/{chunk-5L3SHBMK.js → chunk-2LOBQ4CX.js} +1 -1
- package/dist/standalone/{chunk-E6LDY3TC.js → chunk-2Z5PSAHC.js} +1 -1
- package/dist/standalone/{chunk-3BFUVYWS.js → chunk-3CGQYQDZ.js} +1 -1
- package/dist/standalone/{chunk-UZ5QI3PB.js → chunk-3KDC7UYQ.js} +1 -1
- package/dist/standalone/{chunk-HQPQTWW4.js → chunk-4R6AMNIM.js} +1 -1
- package/dist/standalone/{chunk-XABVLLMA.js → chunk-4XIC6MLF.js} +1 -1
- package/dist/standalone/{chunk-RFTFYKFL.js → chunk-5EWLJXES.js} +1 -1
- package/dist/standalone/{chunk-PWHV7BUN.js → chunk-5K2UDZLN.js} +1 -1
- package/dist/standalone/{chunk-MHLBCDVW.js → chunk-5OFSVXDU.js} +1 -1
- package/dist/standalone/chunk-6DQKYWZI.js +1 -0
- package/dist/standalone/{chunk-6NO6WOSN.js → chunk-6UG4S7I7.js} +1 -1
- package/dist/standalone/chunk-7BRTPMJO.js +1 -0
- package/dist/standalone/{chunk-EDYGNYP2.js → chunk-7IY5BR52.js} +1 -1
- package/dist/standalone/{chunk-KLQEN4KA.js → chunk-A4UOWQOI.js} +1 -1
- package/dist/standalone/{chunk-5JEYBOS6.js → chunk-BOTGXX4H.js} +1 -1
- package/dist/standalone/{chunk-2KAH7DVZ.js → chunk-BVRZVNKL.js} +1 -1
- package/dist/standalone/{chunk-PEEGF7YA.js → chunk-CZY6LNTK.js} +2 -2
- package/dist/standalone/{chunk-CZU3LZ2O.js → chunk-DLT5B4TL.js} +1 -1
- package/dist/standalone/{chunk-L3JA4OKZ.js → chunk-DX6FAHR2.js} +1 -1
- package/dist/standalone/{chunk-IAWCSJRR.js → chunk-EERTS7JH.js} +1 -1
- package/dist/standalone/{chunk-SMVAE2AQ.js → chunk-EHSU2WDS.js} +1 -1
- package/dist/standalone/chunk-FIACUWE5.js +1 -0
- package/dist/standalone/{chunk-NXKPFGOP.js → chunk-FODLDLE2.js} +8 -8
- package/dist/standalone/{chunk-DDI4VSJH.js → chunk-GDB2JX2H.js} +1 -1
- package/dist/standalone/{chunk-MDVH5C5A.js → chunk-GIOZAYBS.js} +1 -1
- package/dist/standalone/{chunk-DMPVOWA7.js → chunk-GWW7SJR6.js} +1 -1
- package/dist/standalone/{chunk-IYYZMNOB.js → chunk-HR42URDR.js} +1 -1
- package/dist/standalone/{chunk-H3UCYGKY.js → chunk-HRYPE4NU.js} +1 -1
- package/dist/standalone/{chunk-E723DEAW.js → chunk-IABM4BFJ.js} +1 -1
- package/dist/standalone/{chunk-ZZENQM5W.js → chunk-INWAISDG.js} +4 -4
- package/dist/standalone/{chunk-VSHZE77Y.js → chunk-JAKYTDUH.js} +1 -1
- package/dist/standalone/chunk-JOYK6ITY.js +1 -0
- package/dist/standalone/{chunk-CIQRB2ET.js → chunk-JWPJS6AI.js} +1 -1
- package/dist/standalone/{chunk-JOQUDV7F.js → chunk-JY4ANRPG.js} +1 -1
- package/dist/standalone/{chunk-YL7OENDU.js → chunk-KCEVLJ65.js} +1 -1
- package/dist/standalone/{chunk-H5PZ7JXM.js → chunk-KJ4YYMID.js} +1 -1
- package/dist/standalone/{chunk-BQ4P3PLU.js → chunk-KQFH6FFC.js} +1 -1
- package/dist/standalone/{chunk-7B3OQXWL.js → chunk-LFDP6ANM.js} +1 -1
- package/dist/standalone/{chunk-MJG6GTPL.js → chunk-LJYUUOBB.js} +1 -1
- package/dist/standalone/{chunk-BN5TOI5O.js → chunk-LK4TLRSU.js} +1 -1
- package/dist/standalone/{chunk-AJQKSUVQ.js → chunk-MNGNHBOS.js} +1 -1
- package/dist/standalone/chunk-N74RUMRA.js +7 -0
- package/dist/standalone/{chunk-447V2Q3F.js → chunk-NZ57KZSG.js} +1 -1
- package/dist/standalone/{chunk-VXWAQW3F.js → chunk-OEVYSTUL.js} +1 -1
- package/dist/standalone/{chunk-JRN7SEJN.js → chunk-OSLV4PT6.js} +1 -1
- package/dist/standalone/chunk-PIGJKRDD.js +3 -0
- package/dist/standalone/{chunk-OUD7BAWE.js → chunk-PL664H45.js} +1 -1
- package/dist/standalone/{chunk-YWYJLVEP.js → chunk-QNSRFASE.js} +1 -1
- package/dist/standalone/{chunk-2IUHQB2Q.js → chunk-QYEQOTRN.js} +7 -8
- package/dist/standalone/{chunk-B5WPIRI3.js → chunk-R5QR5EZZ.js} +1 -1
- package/dist/standalone/{chunk-HDWOQTDN.js → chunk-RDYIEOYN.js} +1 -1
- package/dist/standalone/{chunk-GMEE5NFG.js → chunk-SLFPZM2C.js} +1 -1
- package/dist/standalone/{chunk-TWXJF4C2.js → chunk-SU737V7V.js} +1 -1
- package/dist/standalone/{chunk-EX33M5EE.js → chunk-T3VYCKM7.js} +1 -1
- package/dist/standalone/{chunk-3JV5F5SY.js → chunk-TIUMFAN2.js} +1 -1
- package/dist/standalone/{chunk-7MJY23GU.js → chunk-VGJ6HFCF.js} +1 -1
- package/dist/standalone/{chunk-JSXJND3V.js → chunk-VLCHF5SE.js} +1 -1
- package/dist/standalone/{chunk-CKKZCUAV.js → chunk-VWFNJLMK.js} +1 -1
- package/dist/standalone/{chunk-V5M356X3.js → chunk-VWXU7LIX.js} +1 -1
- package/dist/standalone/{chunk-2IRZXHAZ.js → chunk-WWXSQVPE.js} +1 -1
- package/dist/standalone/{chunk-RNZ7XXND.js → chunk-WXRI2LBR.js} +1 -1
- package/dist/standalone/{chunk-XGPF7VOP.js → chunk-XHM5CP2I.js} +1 -1
- package/dist/standalone/{chunk-IDB7SMQU.js → chunk-XVX3KH35.js} +1 -1
- package/dist/standalone/chunk-XZCNX7YU.js +11 -0
- package/dist/standalone/{chunk-VHMOFAJT.js → chunk-YCEVUCMI.js} +1 -1
- package/dist/standalone/{chunk-3DL3MLWV.js → chunk-ZLPC3XZF.js} +1 -1
- package/dist/standalone/chunk-ZTDD3M5D.js +1 -0
- package/dist/standalone/{chunk-46XX646F.js → chunk-ZYCM7BV2.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/DataBrowser-Bf32rBcr.mjs +0 -4
- package/dist/packem_shared/internal-D4gBuklE.mjs +0 -2
- package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +0 -1
- package/dist/packem_shared/table-list-sidebar-DKpSAP6p.mjs +0 -1
- package/dist/standalone/chunk-2L64LHIR.js +0 -1
- package/dist/standalone/chunk-3HEXTCWR.js +0 -1
- package/dist/standalone/chunk-5AUOM7FK.js +0 -1
- package/dist/standalone/chunk-FZKQX74O.js +0 -1
- package/dist/standalone/chunk-IB3MWLG4.js +0 -1
- package/dist/standalone/chunk-JMNCMGSE.js +0 -1
- package/dist/standalone/chunk-L2OWXMYF.js +0 -1
- package/dist/standalone/chunk-QPVND4TE.js +0 -3
- package/dist/standalone/chunk-RIO2HPN7.js +0 -15
- package/dist/standalone/chunk-UKQTCLDK.js +0 -7
- package/dist/standalone/chunk-W3Q32C24.js +0 -11
- /package/dist/standalone/{chunk-7AU5QSY7.js → chunk-LSWAITBZ.js} +0 -0
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import{c as B}from"react/compiler-runtime";import{useLunora as ct}from"@lunora/react";import{useState as $,useEffect as Be,useMemo as Tt,useRef as Je,useCallback as at}from"react";import{ShardInput as Dn}from"./ShardInput-C6mjgAh4.mjs";import{u as Xe}from"./use-admin-query-BvZH4unR.mjs";import{ADMIN_FUNCTIONS as pe}from"./ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{b as Wt}from"./browser-storage-BH1MxLZs.mjs";import{f as Ce,h as ze,j as In,c as Te,d as ke,i as Pn}from"./internal-D4gBuklE.mjs";import{m as An,c as Ht,d as vt,G as Mn,a as On,u as wt,b as Fn,T as Ln,D as Vn}from"./table-list-sidebar-DKpSAP6p.mjs";import{u as Bn}from"./use-sql-assistant-BGoWYcGL.mjs";import{a as Ut,e as Qt,i as zn,d as jn}from"./wire-codec-BE-vgg1L.mjs";import{B as yt}from"./button-q0UYSmrn.mjs";import{I as qn}from"./input-CXhxesPC.mjs";import{L as At}from"./label-DKFzyHq6.mjs";import{M as dt}from"./modal-shell-CDztwLnv.mjs";import{useT as he}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as d,jsxs as T,Fragment as Ze}from"react/jsx-runtime";import{ConfirmButton as Mt}from"./ConfirmButton-DU4p72Er.mjs";import{E as Gn}from"./empty-state-D7jEML_T.mjs";import{C as Et,a as De}from"./control-button-BOZ5K-FC.mjs";import{useReactTable as Kn,getSortedRowModel as Jn,getCoreRowModel as Wn,flexRender as Hn}from"@tanstack/react-table";import{useVirtualizer as Un}from"@tanstack/react-virtual";import{C as Rt}from"./checkbox-CnS9cyCz.mjs";import{c as it}from"./utils-bhneXptQ.mjs";import{f as Qn}from"./virtual-rect-D_j7aLxX.mjs";import{C as Ct,G as Yn,T as Xn}from"./data-grid-B8WGnT-5.mjs";import{DataFilters as Zn,toFilterClauses as Ve}from"./DataFilters-3nbW0uax.mjs";import{G as eo,C as to}from"./grid-features-CGs2pKcr.mjs";import Ot from"./useDebounced-DVeQ5-oW.mjs";import{r as no,l as oo}from"./shard-history-CaO3C4KQ.mjs";const so=s=>({tables:Object.entries(s).map(([e,n])=>({fields:n.map(o=>o.name),indexes:[],name:e,relations:n.filter(o=>o.ref!==void 0).map(o=>({field:o.name,kind:"one",name:o.name,references:o.ref,table:e}))}))}),lo=s=>{const e=new Map,n=new Set;for(const o of s.tables)for(const t of o.relations){if(t.kind!=="one"||t.onDelete==="set null")continue;const c=t.references,l=`${c}\0${o.name}\0${t.field}`;if(n.has(l))continue;n.add(l);const r=e.get(c)??[];r.push({...t,table:o.name}),e.set(c,r)}return e},ro=(s,e)=>{const n=[],o=[s];for(;o.length>0;){const t=o.shift();if(t===void 0)break;e(t)&&n.push(t);for(const c of t.children)o.push(c)}return n},Ft=(s,e)=>{const n=[];for(const[o,t]of Object.entries(e))for(const c of t)c.ref===s&&n.push({column:c.name,table:o});return n.sort((o,t)=>o.table.localeCompare(t.table)||o.column.localeCompare(t.column)),n},$t=s=>`${s.table}.${s.column}`,ao=s=>{const e=B(111),{columns:n,onApply:o,onClose:t,shardKey:c,table:l,total:r,uniqueColumns:i}=s,a=he(),[f,m]=$(n[0]??""),[p,b]=$("");let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=ee=>{m(ee.target.value)},e[0]=u):u=e[0];const g=u;let h;e[1]===Symbol.for("react.memo_cache_sentinel")?(h=ee=>{b(ee.target.value)},e[1]=h):h=e[1];const w=h;let v;e[2]!==p?(v=p.trim(),e[2]=p,e[3]=v):v=e[3];const y=v==="";let x,S;if(e[4]!==y||e[5]!==a||e[6]!==p){if(!y)try{S=Ut(JSON.parse(p))}catch(ee){x=a("Invalid JSON: {message}",{message:ee.message})}e[4]=y,e[5]=a,e[6]=p,e[7]=x,e[8]=S}else x=e[7],S=e[8];let E;e[9]!==f||e[10]!==r||e[11]!==i?(E=i.has(f)&&r>1,e[9]=f,e[10]=r,e[11]=i,e[12]=E):E=e[12];const C=E,N=f!==""&&!y&&x===void 0&&!C;let k;e[13]!==N||e[14]!==f||e[15]!==o||e[16]!==t||e[17]!==S?(k=()=>{N&&(o({[f]:S}),t())},e[13]=N,e[14]=f,e[15]=o,e[16]=t,e[17]=S,e[18]=k):k=e[18];const M=k;let R;e[19]!==a?(R=a("Set a column on matching rows"),e[19]=a,e[20]=R):R=e[20];let _;e[21]!==a?(_=a("Set a column on matching rows"),e[21]=a,e[22]=_):_=e[22];let D;e[23]!==_?(D=d("h3",{className:"text-base text-foreground","data-testid":"bulk-patch-title",children:_}),e[23]=_,e[24]=D):D=e[24];let I;e[25]!==a||e[26]!==l||e[27]!==r?(I=a("Writes {total} rows of {table} through the schema-aware writer — validators and indexes apply, exactly like a mutation.",{table:l,total:r.toString()}),e[25]=a,e[26]=l,e[27]=r,e[28]=I):I=e[28];let F;e[29]!==I?(F=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-desc",children:I}),e[29]=I,e[30]=F):F=e[30];let A;e[31]!==c||e[32]!==a?(A=c===""?a("Shard: root"):a("Shard: {shardKey} — rows in other shards are not touched.",{shardKey:c}),e[31]=c,e[32]=a,e[33]=A):A=e[33];let z;e[34]!==A?(z=d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-shard",children:A}),e[34]=A,e[35]=z):z=e[35];let j;e[36]!==F||e[37]!==z||e[38]!==D?(j=T("div",{className:"flex flex-col gap-0.5",children:[D,F,z]}),e[36]=F,e[37]=z,e[38]=D,e[39]=j):j=e[39];let O;e[40]!==a?(O=a("Close"),e[40]=a,e[41]=O):O=e[41];let V;e[42]!==t||e[43]!==O?(V=d(yt,{"data-testid":"bulk-patch-close",onClick:t,size:"xs",variant:"ghost",children:O}),e[42]=t,e[43]=O,e[44]=V):V=e[44];let J;e[45]!==j||e[46]!==V?(J=T("div",{className:"flex items-start justify-between",children:[j,V]}),e[45]=j,e[46]=V,e[47]=J):J=e[47];let q;e[48]!==a?(q=a("Column"),e[48]=a,e[49]=q):q=e[49];let X;e[50]!==q?(X=d(At,{htmlFor:"bulk-patch-column",children:q}),e[50]=q,e[51]=X):X=e[51];let Q;e[52]!==a?(Q=a("Column"),e[52]=a,e[53]=Q):Q=e[53];let Z;e[54]!==n?(Z=n.map(io),e[54]=n,e[55]=Z):Z=e[55];let fe;e[56]!==f||e[57]!==Q||e[58]!==Z?(fe=d("select",{"aria-label":Q,className:"h-8 rounded-md border border-input bg-transparent px-2 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"bulk-patch-column",id:"bulk-patch-column",onChange:g,value:f,children:Z}),e[56]=f,e[57]=Q,e[58]=Z,e[59]=fe):fe=e[59];let ne;e[60]!==a?(ne=a("Value"),e[60]=a,e[61]=ne):ne=e[61];let ce;e[62]!==ne?(ce=d(At,{htmlFor:"bulk-patch-value",children:ne}),e[62]=ne,e[63]=ce):ce=e[63];let de;e[64]!==p?(de=d(qn,{className:"flex-1 font-mono","data-testid":"bulk-patch-value",id:"bulk-patch-value",onChange:w,placeholder:"true",value:p}),e[64]=p,e[65]=de):de=e[65];let me;e[66]!==X||e[67]!==fe||e[68]!==ce||e[69]!==de?(me=T("div",{className:"flex items-center gap-2",children:[X,fe,ce,de]}),e[66]=X,e[67]=fe,e[68]=ce,e[69]=de,e[70]=me):me=e[70];let le;e[71]!==x?(le=x!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-error",role:"alert",children:x}),e[71]=x,e[72]=le):le=e[72];let ue;e[73]!==f||e[74]!==a||e[75]!==r||e[76]!==C?(ue=C&&d("p",{className:"text-xs text-destructive","data-testid":"bulk-patch-unique",role:"alert",children:a("{column} has a unique index — the same value cannot be set on {total} rows.",{column:f,total:r.toString()})}),e[73]=f,e[74]=a,e[75]=r,e[76]=C,e[77]=ue):ue=e[77];let re;e[78]!==y||e[79]!==a||e[80]!==C?(re=y&&!C&&d("p",{className:"text-xs text-muted-foreground","data-testid":"bulk-patch-hint",children:a('Enter a JSON value — for example true, 0, null, or "done".')}),e[78]=y,e[79]=a,e[80]=C,e[81]=re):re=e[81];let Y;e[82]!==N||e[83]!==f||e[84]!==p?(Y=N&&d("p",{className:"font-mono text-xs text-muted-foreground","data-testid":"bulk-patch-preview",children:`${f} = ${p.trim()}`}),e[82]=N,e[83]=f,e[84]=p,e[85]=Y):Y=e[85];let be;e[86]!==a?(be=a("Cancel"),e[86]=a,e[87]=be):be=e[87];let te;e[88]!==t||e[89]!==be?(te=d(yt,{"data-testid":"bulk-patch-cancel",onClick:t,size:"xs",variant:"outline",children:be}),e[88]=t,e[89]=be,e[90]=te):te=e[90];const xe=!N;let ae;e[91]!==a||e[92]!==r?(ae=a("Set on {total} rows",{total:r.toString()}),e[91]=a,e[92]=r,e[93]=ae):ae=e[93];let ie;e[94]!==M||e[95]!==xe||e[96]!==ae?(ie=d(yt,{"data-testid":"bulk-patch-apply",disabled:xe,onClick:M,size:"xs",children:ae}),e[94]=M,e[95]=xe,e[96]=ae,e[97]=ie):ie=e[97];let W;e[98]!==te||e[99]!==ie?(W=T("div",{className:"flex justify-end gap-2",children:[te,ie]}),e[98]=te,e[99]=ie,e[100]=W):W=e[100];let K;return e[101]!==t||e[102]!==J||e[103]!==me||e[104]!==le||e[105]!==ue||e[106]!==re||e[107]!==Y||e[108]!==W||e[109]!==R?(K=T(dt,{label:R,onClose:t,panelTestId:"bulk-patch-panel",testId:"bulk-patch-overlay",variant:"dialog",children:[J,me,le,ue,re,Y,W]}),e[101]=t,e[102]=J,e[103]=me,e[104]=le,e[105]=ue,e[106]=re,e[107]=Y,e[108]=W,e[109]=R,e[110]=K):K=e[110],K};function io(s){return d("option",{value:s,children:s},s)}const Lt=6,lt=100,co=s=>({paddingLeft:s*16}),uo=s=>{const e=B(2),{table:n}=s,o=`cascade-restrict-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-destructive/10 px-1 text-destructive","data-testid":o,children:"restrict — will block delete"}),e[0]=o,e[1]=t):t=e[1],t},fo=s=>{const e=B(2),{table:n}=s,o=`cascade-cascade-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-warning/10 px-1 text-warning","data-testid":o,children:"cascade"}),e[0]=o,e[1]=t):t=e[1],t},mo=s=>{const e=B(2),{table:n}=s,o=`cascade-undeclared-${n}`;let t;return e[0]!==o?(t=d("span",{className:"rounded bg-muted px-1 text-muted-foreground","data-testid":o,children:"references — no delete action declared"}),e[0]=o,e[1]=t):t=e[1],t},go=s=>s.relation===void 0||s.relation.onDelete==="cascade"?d(fo,{table:s.table}):s.isRestrict?d(uo,{table:s.table}):d(mo,{table:s.table}),Yt=s=>{const e=B(35),{depth:n,node:o}=s,t=`cascade-row-${o.table}`;let c;e[0]!==n?(c=co(n),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==n?(l=n>0&&d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"└"}),e[2]=n,e[3]=l):l=e[3];let r;e[4]!==o.table?(r=d("span",{className:"font-medium text-foreground",children:o.table}),e[4]=o.table,e[5]=r):r=e[5];let i;e[6]!==o.relation||e[7]!==o.table?(i=o.relation!==void 0&&T("span",{className:"text-muted-foreground","data-testid":`cascade-col-${o.table}-${o.relation.field}`,children:["via ",o.relation.field]}),e[6]=o.relation,e[7]=o.table,e[8]=i):i=e[8];let a;e[9]!==o.rowCount?(a=o.rowCount.toString(),e[9]=o.rowCount,e[10]=a):a=e[10];let f;e[11]!==a?(f=T("span",{className:"text-muted-foreground",children:["(",a," rows)"]}),e[11]=a,e[12]=f):f=e[12];let m;e[13]!==o?(m=go(o),e[13]=o,e[14]=m):m=e[14];let p;e[15]!==o.capNote||e[16]!==o.table?(p=o.capNote!==void 0&&T("span",{className:"italic text-muted-foreground","data-testid":`cascade-cap-${o.table}`,children:["(",o.capNote,")"]}),e[15]=o.capNote,e[16]=o.table,e[17]=p):p=e[17];let b;e[18]!==t||e[19]!==c||e[20]!==l||e[21]!==r||e[22]!==i||e[23]!==f||e[24]!==m||e[25]!==p?(b=T("li",{className:"flex flex-wrap items-center gap-1.5 py-1 font-mono text-xs","data-testid":t,style:c,children:[l,r,i,f,m,p]}),e[18]=t,e[19]=c,e[20]=l,e[21]=r,e[22]=i,e[23]=f,e[24]=m,e[25]=p,e[26]=b):b=e[26];let u;if(e[27]!==n||e[28]!==o.children){let h;e[30]!==n?(h=(w,v)=>d(Yt,{depth:n+1,node:w},`${w.table}-${w.relation?.field??"root"}-${v.toString()}`),e[30]=n,e[31]=h):h=e[31],u=o.children.map(h),e[27]=n,e[28]=o.children,e[29]=u}else u=e[29];let g;return e[32]!==b||e[33]!==u?(g=T(Ze,{children:[b,u]}),e[32]=b,e[33]=u,e[34]=g):g=e[34],g},po=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?e.toString():""},bo=async(s,e,n,o)=>{try{const t=await o(s,e,n),c=t.rows.flatMap(i=>po(i)||[]).slice(0,lt),l=t.total??0;return{capNote:l>lt?`showing first ${lt.toString()} of ${l.toString()}`:void 0,rowCount:l,rowIds:c}}catch{return{capNote:"count unavailable",rowCount:0,rowIds:[]}}},Xt=async(s,e,n,o,t,c,l)=>{const{capNote:r,rowCount:i,rowIds:a}=n===void 0?{capNote:void 0,rowCount:1,rowIds:[e]}:await bo(s,n.field,e,l),f=n?.onDelete==="restrict",m=[],p=`${s}:${e}`,b=c>=Lt;if(!t.has(p)&&!b){t.add(p);const g=o.get(s)??[];for(const h of g)for(const w of a.slice(0,10)){const v=await Xt(h.table,w,h,o,t,c+1,l);(v.rowCount>0||c===0)&&m.push(v)}t.delete(p)}let u=r;if(b){const g=`depth capped at ${Lt.toString()}`;u=r===void 0?g:`${r}; ${g}`}return{capNote:u,children:m,isRestrict:f,relation:n,rowCount:i,rowIds:a,table:s}},ho=({onClose:s,onConfirm:e,readPage:n,rowId:o,schema:t,table:c})=>{const l=he(),[r,i]=$(!0),[a,f]=$(null),[m,p]=$(null);Be(()=>{let g=!1;return Ce((async()=>{try{i(!0),p(null);const w=lo(t);if(!((w.get(c)??[]).length>0)){g||(f({capNote:void 0,children:[],isRestrict:!1,relation:void 0,rowCount:1,rowIds:[o],table:c}),i(!1));return}const y=await Xt(c,o,void 0,w,new Set,0,n);g||(f(y),i(!1))}catch(w){g||(p(w.message),i(!1))}})()),()=>{g=!0}},[o,c]);const b=a!==null&&ro(a,g=>g.isRestrict).length>0,u=()=>{e(),s()};return T(dt,{label:"Cascade impact preview",onClose:s,panelTestId:"cascade-panel",testId:"cascade-overlay",variant:"dialog",children:[T("div",{className:"flex items-start justify-between",children:[T("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"cascade-title",children:l("Cascade impact")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-desc",children:l("Delete preview — rows that would cascade or be blocked")})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"cascade-close",onClick:s,type:"button",children:l("Close")})]}),r&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-loading",children:l("Loading…")}),m!==null&&d("p",{className:"text-xs text-destructive","data-testid":"cascade-error",role:"alert",children:m}),!r&&a!==null&&d("ul",{className:"flex flex-col","data-testid":"cascade-tree",children:d(Yt,{depth:0,node:a})}),!r&&a!==null&&a.children.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"cascade-no-impact",children:l("No related rows found.")}),b&&d("p",{className:"text-sm font-medium text-destructive","data-testid":"cascade-blocker-warning",role:"alert",children:l("Restrict relations will block this delete.")}),T("div",{className:"flex justify-end gap-2",children:[d("button",{className:"rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"cascade-cancel",onClick:s,type:"button",children:l("Cancel")}),d("button",{className:"rounded-md bg-destructive px-3 py-1.5 text-xs font-medium text-destructive-foreground outline-none transition-colors hover:bg-destructive/90 focus-visible:bg-destructive/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"cascade-confirm",disabled:r,onClick:u,type:"button",children:l("Delete")})]})]})},xo=(s,e,n,o,t=300)=>{if(o<=0)return{ids:new Set(s.map(m=>m.id)),leadPx:0,tailPx:0};const c=n-t,l=n+o+t,r=new Set;let i=0,a=0,f=0;for(const m of s){const p=m.getSize(),b=e.has(m.id),u=i+p>c&&i<l;b||u?r.add(m.id):i<c?a+=p:f+=p,i+=p}return{ids:r,leadPx:a,tailPx:f}},vo=(s,e)=>{const n=new Map;let o=0;for(const t of s)e.has(t.id)&&(n.set(t.id,o),o+=t.getSize());return n},wo=()=>{const s=B(11);let e;s[0]===Symbol.for("react.memo_cache_sentinel")?(e={},s[0]=e):e=s[0];const[n,o]=$(e);let t;s[1]===Symbol.for("react.memo_cache_sentinel")?(t=(b,u,g)=>{o(h=>({...h,[b]:{...h[b],[u]:g}}))},s[1]=t):t=s[1];const c=t;let l;s[2]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{o({})},s[2]=l):l=s[2];const r=l;let i;s[3]!==n?(i=(b,u)=>{const g=n[b];return g!==void 0&&u in g?{value:g[u]}:void 0},s[3]=n,s[4]=i):i=s[4];const a=i;let f;s[5]!==n?(f=Object.values(n).reduce(Co,0),s[5]=n,s[6]=f):f=s[6];const m=f;let p;return s[7]!==m||s[8]!==n||s[9]!==a?(p={clear:r,count:m,stage:c,staged:n,stagedValue:a},s[7]=m,s[8]=n,s[9]=a,s[10]=p):p=s[10],p},Zt=(s,e)=>{if(typeof e=="number"){const n=Number(s);return s.trim()===""||Number.isNaN(n)?s:n}if(typeof e=="boolean"){if(s==="true")return!0;if(s==="false")return!1}return s},yo=s=>{const e=B(29),{changes:n,committing:o,onCommit:t,onDiscard:c}=s,l=he();let r;e[0]!==n.length||e[1]!==l?(r=l("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=l,e[2]=r):r=e[2];let i;e[3]!==r?(i=d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:r}),e[3]=r,e[4]=i):i=e[4];let a;e[5]!==o||e[6]!==l?(a=l(o?"Committing…":"Commit"),e[5]=o,e[6]=l,e[7]=a):a=e[7];let f;e[8]!==o||e[9]!==t||e[10]!==a?(f=d("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:t,type:"button",children:a}),e[8]=o,e[9]=t,e[10]=a,e[11]=f):f=e[11];let m;e[12]!==l?(m=l("Discard"),e[12]=l,e[13]=m):m=e[13];let p;e[14]!==o||e[15]!==c||e[16]!==m?(p=d("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:c,type:"button",children:m}),e[14]=o,e[15]=c,e[16]=m,e[17]=p):p=e[17];let b;e[18]!==i||e[19]!==f||e[20]!==p?(b=T("div",{className:"flex flex-wrap items-center gap-2",children:[i,f,p]}),e[18]=i,e[19]=f,e[20]=p,e[21]=b):b=e[21];let u;e[22]!==n?(u=n.map(No),e[22]=n,e[23]=u):u=e[23];let g;e[24]!==u?(g=d("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:u}),e[24]=u,e[25]=g):g=e[25];let h;return e[26]!==b||e[27]!==g?(h=T("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[b,g]}),e[26]=b,e[27]=g,e[28]=h):h=e[28],h};function Co(s,e){return s+Object.keys(e).length}function No(s){return T("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[T("span",{className:"text-muted-foreground",children:[s.rowId,".",s.column]}),d("span",{className:"text-destructive line-through",children:ze(s.oldValue)}),d("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"→"}),d("span",{className:"text-foreground",children:ze(s.newValue)})]},`${s.rowId}:${s.column}`)}const Vt=400,So=36,ko={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},To={width:"100%"},Eo=/\n$/u,_o={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},Ro={display:"flex",width:"100%"},Bt={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},$o="2.5rem",en={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},Dt=s=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${s.toString()}px`}),tn=(s,e)=>({...Dt(s),left:`calc(${$o} + ${e.toString()}px)`,position:"sticky",zIndex:2}),Nt="rounded-md px-2 py-0.5 text-xs font-medium text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",Do=(s,e,n)=>e.enabled&&e.columns.has(n)?void 0:s,_t="__back__:",Io=s=>`${_t}${s.table}.${s.column}`,Po=s=>{const e=B(3),{counts:n,rowId:o}=s;if(n===void 0){let l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(l=d("span",{className:"text-muted-foreground/50",children:"—"}),e[0]=l):l=e[0],l}const t=n[o]??0;let c;return e[1]!==t?(c=d("span",{className:"tabular-nums",children:t}),e[1]=t,e[2]=c):c=e[2],c},Ie=s=>{for(const e of["id","__id__","_id"]){const n=s[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},Ao=(s,e)=>{if(e.enumValues!==void 0&&e.enumValues.length>0)return e.enumValues.includes(s)||s===""&&e.nullable===!0?{value:s===""?null:s}:void 0;if(e.type==="boolean")return s==="true"||s==="false"?{value:s==="true"}:void 0;if(e.type==="number"){const n=Number(s);return s.trim()===""||!Number.isFinite(n)?void 0:{value:n}}return{value:s}},Mo=(s,e,n)=>{if(n!==void 0&&n.type!=="any")return Ao(s,n);const o=Zt(s,e);return typeof e=="number"&&typeof o!="number"?void 0:{value:o}},Oo=({anchor:s,columnIds:e,columnMeta:n,editableColumn:o,rows:t,text:c})=>{const l=c.replaceAll(`\r
|
|
2
|
-
`,`
|
|
3
|
-
`).replace(Eo,"").split(`
|
|
4
|
-
`),r=[];let i=0;for(const[a,f]of l.entries()){const m=t[s.row+a],p=m===void 0?null:Ie(m),b=f.split(" ");if(m===void 0||p===null){i+=b.length;continue}for(const[u,g]of b.entries()){const h=e[s.col+u],w=h===void 0||!o(h)?void 0:Mo(g,m[h],n?.[h]);h===void 0||w===void 0?i+=1:r.push({column:h,rowId:p,value:w.value})}}return{edits:r,skipped:i}},nn=(s,e)=>Ie(s)??`row-${e.toString()}`,Fo=8,Lo=s=>{const e=B(17),{anchor:n,mask:o,state:t}=s,c=he();let l;e[0]!==n.left||e[1]!==n.top?(l={left:n.left,position:"fixed",top:n.top,zIndex:50},e[0]=n.left,e[1]=n.top,e[2]=l):l=e[2];const r=l;let i;if(t==="loading"){let f;e[3]!==c?(f=c("Loading…"),e[3]=c,e[4]=f):f=e[4];let m;e[5]!==f?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:f}),e[5]=f,e[6]=m):m=e[6],i=m}else if(t.row===null){let f;e[7]!==c?(f=c("No matching row."),e[7]=c,e[8]=f):f=e[8];let m;e[9]!==f?(m=d("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:f}),e[9]=f,e[10]=m):m=e[10],i=m}else{let f;if(e[11]!==o||e[12]!==t.row){const m=Object.entries(Ht(t.row,o)).slice(0,Fo);f=d("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:m.map(Qo)}),e[11]=o,e[12]=t.row,e[13]=f}else f=e[13];i=f}let a;return e[14]!==i||e[15]!==r?(a=d("div",{className:"pointer-events-none w-72 overflow-hidden rounded-md border border-border bg-popover text-popover-foreground","data-testid":"db-ref-preview",role:"tooltip",style:r,children:i}),e[14]=i,e[15]=r,e[16]=a):a=e[16],a},Vo=s=>{const e=B(24),{column:n,id:o,maskViewFor:t,onNavigate:c,onPreview:l,target:r}=s,[i,a]=$(null),[f,m]=$("idle");let p;e[0]!==o||e[1]!==c||e[2]!==r?(p=()=>{c(r,o)},e[0]=o,e[1]=c,e[2]=r,e[3]=p):p=e[3];const b=p;let u;e[4]!==o||e[5]!==l||e[6]!==f||e[7]!==r?(u=C=>{const N=C.currentTarget.getBoundingClientRect();if(a({left:N.left,top:N.bottom+4}),f!=="idle")return;m("loading"),Ce((async()=>{try{m({row:await l(r,o)})}catch{m({row:null})}})())},e[4]=o,e[5]=l,e[6]=f,e[7]=r,e[8]=u):u=e[8];const g=u;let h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{a(null)},e[9]=h):h=e[9];const w=h,v=`db-ref-${n}`,y=`Open ${r} ${o}`;let x;e[10]!==o||e[11]!==b||e[12]!==g||e[13]!==v||e[14]!==y?(x=T("button",{"data-testid":v,onBlur:w,onClick:b,onFocus:g,onMouseEnter:g,onMouseLeave:w,title:y,type:"button",children:[o," ↗"]}),e[10]=o,e[11]=b,e[12]=g,e[13]=v,e[14]=y,e[15]=x):x=e[15];let S;e[16]!==i||e[17]!==t||e[18]!==f||e[19]!==r?(S=i!==null&&f!=="idle"&&d(Lo,{anchor:i,mask:t(r,f==="loading"||f.row===null?[]:Object.keys(f.row)),state:f}),e[16]=i,e[17]=t,e[18]=f,e[19]=r,e[20]=S):S=e[20];let E;return e[21]!==x||e[22]!==S?(E=T(Ze,{children:[x,S]}),e[21]=x,e[22]=S,e[23]=E):E=e[23],E},Bo=s=>s==="asc"?" ▲":s==="desc"?" ▼":"",zo="absolute end-1 top-1/2 hidden -translate-y-1/2 items-center justify-center rounded text-muted-foreground outline-none group-hover/cell:flex hover:text-foreground focus-visible:flex",zt=s=>{const e=B(8),{column:n,onExpand:o,value:t}=s;let c;e[0]!==n||e[1]!==o||e[2]!==t?(c=()=>{o(n,t)},e[0]=n,e[1]=o,e[2]=t,e[3]=c):c=e[3];const l=c,r=`db-expand-${n}`;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=d("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:d("path",{d:"M9 21H5a2 2 0 0 1-2-2v-4m18 0v4a2 2 0 0 1-2 2h-4M3 9V5a2 2 0 0 1 2-2h4m6 0h4a2 2 0 0 1 2 2v4"})}),e[4]=i):i=e[4];let a;return e[5]!==l||e[6]!==r?(a=d("button",{"aria-label":"Expand cell",className:zo,"data-testid":r,onClick:l,type:"button",children:i}),e[5]=l,e[6]=r,e[7]=a):a=e[7],a},jo=s=>{const e=B(15),{column:n,initial:o,onCancel:t,onCommit:c,recordId:l}=s,r=Je(null);let i,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{r.current?.select()},a=[],e[0]=i,e[1]=a):(i=e[0],a=e[1]),Be(i,a);let f;e[2]!==t||e[3]!==c?(f=w=>{w.key==="Enter"?(w.preventDefault(),c(w.currentTarget.value)):w.key==="Escape"&&(w.preventDefault(),t())},e[2]=t,e[3]=c,e[4]=f):f=e[4];const m=f;let p;e[5]!==c?(p=w=>{c(w.currentTarget.value)},e[5]=c,e[6]=p):p=e[6];const b=p,u=`db-cell-input-${l}-${n}`;let g;e[7]!==o?(g=ze(o),e[7]=o,e[8]=g):g=e[8];let h;return e[9]!==n||e[10]!==b||e[11]!==m||e[12]!==u||e[13]!==g?(h=d("input",{"aria-label":n,className:"w-full rounded border border-ring bg-background px-1 py-0.5 font-mono text-xs outline-none","data-testid":u,defaultValue:g,onBlur:b,onKeyDown:m,ref:r}),e[9]=n,e[10]=b,e[11]=m,e[12]=u,e[13]=g,e[14]=h):h=e[14],h},qo=s=>{const e=B(70),{cell:n,edit:o,highlight:t,mask:c,refs:l}=s,r=n.column.id;let i,a,f,m;if(e[0]!==n||e[1]!==r||e[2]!==o||e[3]!==c||e[4]!==l.columns||e[5]!==l.maskViewFor||e[6]!==l.onNavigate||e[7]!==l.onPreview){m=Symbol.for("react.early_return_sentinel");e:{a=n.getValue(),i=Ie(n.row.original);const R=l.columns?.[r];if(c.enabled&&c.columns.has(r)){const _=`db-masked-${r}`,D=d(Ct,{value:An(a,r,c)});let I;e[12]!==_||e[13]!==D?(I=d("span",{className:"text-muted-foreground italic","data-testid":_,title:"Masked (preview)",children:D}),e[12]=_,e[13]=D,e[14]=I):I=e[14],m=I;break e}if(R!==void 0&&(typeof a=="string"||typeof a=="number")&&String(a)!==""){const _=String(a),D=`${R}:${String(a)}`;let I;e[15]!==r||e[16]!==l.maskViewFor||e[17]!==l.onNavigate||e[18]!==l.onPreview||e[19]!==_||e[20]!==D||e[21]!==R?(I=d(Vo,{column:r,id:_,maskViewFor:l.maskViewFor,onNavigate:l.onNavigate,onPreview:l.onPreview,target:R},D),e[15]=r,e[16]=l.maskViewFor,e[17]=l.onNavigate,e[18]=l.onPreview,e[19]=_,e[20]=D,e[21]=R,e[22]=I):I=e[22],m=I;break e}if(i===null){let _;e[23]!==a?(_=d(Ct,{value:a}),e[23]=a,e[24]=_):_=e[24];let D;e[25]!==r||e[26]!==o.onExpandCell||e[27]!==a?(D=d(zt,{column:r,onExpand:o.onExpandCell,value:a}),e[25]=r,e[26]=o.onExpandCell,e[27]=a,e[28]=D):D=e[28];let I;e[29]!==_||e[30]!==D?(I=T(Ze,{children:[_,D]}),e[29]=_,e[30]=D,e[31]=I):I=e[31],m=I;break e}f=o.stagedValue(i,r)}e[0]=n,e[1]=r,e[2]=o,e[3]=c,e[4]=l.columns,e[5]=l.maskViewFor,e[6]=l.onNavigate,e[7]=l.onPreview,e[8]=i,e[9]=a,e[10]=f,e[11]=m}else i=e[8],a=e[9],f=e[10],m=e[11];if(m!==Symbol.for("react.early_return_sentinel"))return m;const p=f,b=p===void 0?a:p.value;let u;e[32]!==r||e[33]!==o?(u=o.editable&&o.editableColumn(r),e[32]=r,e[33]=o,e[34]=u):u=e[34];const g=u;if(o.editingCell!==null&&o.editingCell.rowId===i&&o.editingCell.column===r){let R;e[35]!==r||e[36]!==o||e[37]!==i||e[38]!==a?(R=D=>{o.stage(i,r,Zt(D,a)),o.cancelEdit()},e[35]=r,e[36]=o,e[37]=i,e[38]=a,e[39]=R):R=e[39];let _;return e[40]!==r||e[41]!==b||e[42]!==o.cancelEdit||e[43]!==i||e[44]!==R?(_=d(jo,{column:r,initial:b,onCancel:o.cancelEdit,onCommit:R,recordId:i}),e[40]=r,e[41]=b,e[42]=o.cancelEdit,e[43]=i,e[44]=R,e[45]=_):_=e[45],_}let w;p!==void 0?w="rounded bg-warning/15 px-1":g&&(w="cursor-text");let v;e[46]!==g||e[47]!==r||e[48]!==o||e[49]!==i?(v=g?()=>{o.startEdit(i,r)}:void 0,e[46]=g,e[47]=r,e[48]=o,e[49]=i,e[50]=v):v=e[50];const y=v,x=w,S=`db-cell-${i}-${r}`;let E;e[51]!==r||e[52]!==t||e[53]!==c?(E=Do(t,c,r),e[51]=r,e[52]=t,e[53]=c,e[54]=E):E=e[54];let C;e[55]!==b||e[56]!==E?(C=d(Ct,{highlight:E,value:b}),e[55]=b,e[56]=E,e[57]=C):C=e[57];let N;e[58]!==w||e[59]!==y||e[60]!==S||e[61]!==C?(N=d("span",{className:x,"data-testid":S,onDoubleClick:y,children:C}),e[58]=w,e[59]=y,e[60]=S,e[61]=C,e[62]=N):N=e[62];let k;e[63]!==r||e[64]!==b||e[65]!==o.onExpandCell?(k=d(zt,{column:r,onExpand:o.onExpandCell,value:b}),e[63]=r,e[64]=b,e[65]=o.onExpandCell,e[66]=k):k=e[66];let M;return e[67]!==k||e[68]!==N?(M=T(Ze,{children:[N,k]}),e[67]=k,e[68]=N,e[69]=M):M=e[69],M},Go=s=>{s.preventDefault()},jt={any:"?",array:"[]",bigint:"#",boolean:"01",bytes:"0x",id:"→",number:"#",object:"{}",storage:"◫",string:"T",union:"|"},Ko=({declaredType:s,draggedRef:e,header:n,masked:o=!1,onTogglePin:t,pinnedOffset:c,table:l})=>{const r=()=>{e.current=n.column.id},i=()=>{const a=e.current,f=n.column.id;if(e.current=null,a===null||a===f)return;const m=l.getState().columnOrder,b=(m.length>0?m:l.getAllLeafColumns().map(g=>g.id)).filter(g=>g!==a),u=b.indexOf(f);b.splice(u===-1?b.length:u,0,a),l.setColumnOrder(b)};return T("th",{className:it("group/head text-start text-xs font-medium text-muted-foreground",c!==void 0&&"border-e border-border bg-muted"),draggable:!0,onDragOver:Go,onDragStart:r,onDrop:i,style:c===void 0?Dt(n.getSize()):tn(n.getSize(),c),children:[T("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${n.column.id}`,onClick:n.column.getToggleSortingHandler(),type:"button",children:[Hn(n.column.columnDef.header,n.getContext()),Bo(n.column.getIsSorted())]}),s!==void 0&&jt[s]!==void 0&&d("span",{className:"ms-1 font-mono text-[0.625rem] text-muted-foreground/70","data-testid":`db-type-${n.column.id}`,title:s,children:jt[s]}),o&&d("span",{className:"ms-1 inline-flex items-center rounded-sm bg-warning/15 px-1 text-[0.625rem] font-medium uppercase text-warning","data-testid":`db-mask-chip-${n.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),d("button",{"aria-label":c===void 0?`Pin ${n.column.id}`:`Unpin ${n.column.id}`,"aria-pressed":c!==void 0,className:it("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",c===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${n.column.id}`,onClick:()=>{t(n.column.id)},type:"button",children:"📌"}),d("span",{"aria-hidden":"true",className:"absolute inset-y-0 end-0 w-1 cursor-col-resize touch-none select-none hover:bg-ring/60 data-[resizing=true]:bg-ring","data-resizing":n.column.getIsResizing(),"data-testid":`db-resize-${n.column.id}`,onMouseDown:n.getResizeHandler(),onTouchStart:n.getResizeHandler()})]})},Jo=s=>{const e=B(13),{table:n}=s,o=he();let t;e[0]!==n?(t=f=>{n.toggleAllRowsSelected(f)},e[0]=n,e[1]=t):t=e[1];const c=t;let l;e[2]!==o?(l=o("Select all rows"),e[2]=o,e[3]=l):l=e[3];let r;e[4]!==n?(r=n.getIsAllRowsSelected(),e[4]=n,e[5]=r):r=e[5];let i;e[6]!==n?(i=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=i):i=e[7];let a;return e[8]!==c||e[9]!==l||e[10]!==r||e[11]!==i?(a=d("th",{className:"bg-muted",style:en,children:d(Rt,{"aria-label":l,checked:r,"data-testid":"db-select-all",indeterminate:i,onCheckedChange:c})}),e[8]=c,e[9]=l,e[10]=r,e[11]=i,e[12]=a):a=e[12],a},Wo=s=>{const e=B(17),{row:n}=s,o=he();let t;e[0]!==n.original?(t=Ie(n.original),e[0]=n.original,e[1]=t):t=e[1];const c=t;let l;e[2]!==n?(l=u=>{n.toggleSelected(u)},e[2]=n,e[3]=l):l=e[3];const r=l;let i;e[4]!==o?(i=o("Select row"),e[4]=o,e[5]=i):i=e[5];let a;e[6]!==n?(a=n.getIsSelected(),e[6]=n,e[7]=a):a=e[7];let f;e[8]!==n.index||e[9]!==n.original?(f=nn(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=f):f=e[10];const m=`db-select-${f}`,p=c===null;let b;return e[11]!==r||e[12]!==i||e[13]!==a||e[14]!==m||e[15]!==p?(b=d("td",{className:"bg-background",style:en,children:d(Rt,{"aria-label":i,checked:a,"data-testid":m,disabled:p,onCheckedChange:r})}),e[11]=r,e[12]=i,e[13]=a,e[14]=m,e[15]=p,e[16]=b):b=e[16],b},Ho=s=>{const e=B(91),{columnMeta:n,edit:o,editable:t,mask:c,onDelete:l,onEdit:r,onInspect:i,highlight:a,backRelationCounts:f,onTogglePin:m,pinnedColumns:p,refs:b,tableModel:u}=s,g=he(),{attachScroll:h,scrollLeft:w,scrollToIndex:v,table:y,tableRows:x,tbodyStyle:S,viewportWidth:E,virtualRows:C}=u,N=Je(null),[k,M]=$(null);let R;e[0]===Symbol.for("react.memo_cache_sentinel")?(R={columns:"",count:0},e[0]=R):R=e[0];const[_,D]=$(R);let I;e[1]!==y?(I=y.getVisibleLeafColumns(),e[1]=y,e[2]=I):I=e[2];const F=I.length;let A;e[3]!==k||e[4]!==F||e[5]!==o||e[6]!==y||e[7]!==x?(A=ee=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(ee.key))return;ee.preventDefault();const H=k??{col:0,row:0};if(ee.key==="Enter"){const we=x[H.row],ye=y.getVisibleLeafColumns()[H.col];if(we!==void 0&&ye!==void 0){const U=Ie(we.original);U!==null&&o.editableColumn(ye.id)&&o.startEdit(U,ye.id)}M(H);return}let{col:ve,row:ge}=H;e:switch(ee.key){case"ArrowDown":{ge=Math.min(ge+1,x.length-1);break e}case"ArrowRight":{ve=Math.min(ve+1,F-1);break e}case"ArrowUp":{ge=Math.max(ge-1,0);break e}default:ve=Math.max(ve-1,0)}M({col:ve,row:ge})},e[3]=k,e[4]=F,e[5]=o,e[6]=y,e[7]=x,e[8]=A):A=e[8];const z=A;let j;e[9]!==k||e[10]!==n||e[11]!==o||e[12]!==y||e[13]!==x?(j=ee=>{const H=o.editable?ee.clipboardData.getData("text/plain"):"";if(H==="")return;ee.preventDefault();const ve=y.getVisibleLeafColumns().map(Yo),ge=Oo({anchor:k??{col:0,row:0},columnIds:ve,columnMeta:n,editableColumn:o.editableColumn,rows:x.map(Xo),text:H});for(const we of ge.edits)o.stage(we.rowId,we.column,we.value);D({columns:ve.join("\0"),count:ge.skipped})},e[9]=k,e[10]=n,e[11]=o,e[12]=y,e[13]=x,e[14]=j):j=e[14];const O=j;let V,J;e[15]!==k||e[16]!==v?(V=()=>{k!==null&&v(k.row)},J=[k,v],e[15]=k,e[16]=v,e[17]=V,e[18]=J):(V=e[17],J=e[18]),Be(V,J);let q,X,Q,Z,fe,ne,ce,de,me,le,ue,re,Y,be,te,xe;if(e[19]!==k||e[20]!==h||e[21]!==f||e[22]!==n||e[23]!==o||e[24]!==t||e[25]!==a||e[26]!==c||e[27]!==l||e[28]!==r||e[29]!==z||e[30]!==O||e[31]!==i||e[32]!==m||e[33]!==_.columns||e[34]!==_.count||e[35]!==p||e[36]!==b||e[37]!==w||e[38]!==g||e[39]!==y||e[40]!==x||e[41]!==S||e[42]!==E||e[43]!==C){const ee=y.getVisibleLeafColumns().map(Zo),H=xo(ee,p,w,E),ve=vo(y.getVisibleLeafColumns().map(es),p),ge=U=>{const oe=x[U.index],{original:Me}=oe,Pe=Ie(Me),Ae=nn(Me,U.index),He={..._o,height:`${U.size.toString()}px`,transform:`translateY(${U.start.toString()}px)`};return T("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:He,children:[d(Wo,{row:oe}),H.leadPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${H.leadPx.toString()}px`}}),oe.getVisibleCells().map((Se,je)=>{if(!H.ids.has(Se.column.id))return null;const Oe=ve.get(Se.column.id),Ue=k!==null&&k.row===U.index&&k.col===je?" ring-1 ring-ring ring-inset":"";return d("td",{className:it("group/cell truncate font-mono text-muted-foreground",Oe!==void 0&&"border-e border-border bg-background",Ue),onPointerDown:()=>{M({col:je,row:U.index})},style:Oe===void 0?Dt(Se.column.getSize()):tn(Se.column.getSize(),Oe),children:Se.column.id.startsWith(_t)?d(Po,{counts:f[Se.column.id.slice(_t.length)],rowId:Ae}):d(qo,{cell:Se,edit:o,highlight:a,mask:c,refs:b})},Se.id)}),H.tailPx>0&&d("td",{"aria-hidden":"true",style:{flex:`0 0 ${H.tailPx.toString()}px`}}),T("td",{className:"flex items-center gap-1",style:Bt,children:[d("button",{className:Nt,"data-testid":`db-inspect-${Ae}`,onClick:()=>{i(Me)},type:"button",children:"Details"}),t&&T(Ze,{children:[d("button",{className:Nt,"data-testid":`db-edit-${Ae}`,disabled:Pe===null,onClick:()=>{r(Pe,Me)},type:"button",children:"Edit"}),d("button",{className:Nt,"data-testid":`db-delete-${Ae}`,disabled:Pe===null,onClick:()=>{l(Pe)},type:"button",children:"Delete"})]})]})]},oe.id)};q=Yn,re="fill",e[60]!==_.columns||e[61]!==_.count||e[62]!==g||e[63]!==y?(Y=_.count>0&&_.columns===y.getVisibleLeafColumns().map(ts).join("\0")&&d("p",{className:"border-b border-warning/40 bg-warning/5 px-3 py-1.5 text-xs text-warning","data-testid":"db-paste-skipped",children:g("{count} pasted cells were skipped",{count:_.count})}),e[60]=_.columns,e[61]=_.count,e[62]=g,e[63]=y,e[64]=Y):Y=e[64],fe="db-scroll",ne=z,ce=O,de=h,me="grid",le=ko,ue=0,xe="w-full text-xs",X="db-rows",Q=To;let we;e[65]!==y?(we=d(Jo,{table:y}),e[65]=y,e[66]=we):we=e[66];let ye;e[67]===Symbol.for("react.memo_cache_sentinel")?(ye=d("th",{"aria-label":"Row actions",style:Bt}),e[67]=ye):ye=e[67],Z=d("thead",{className:"bg-muted/50",children:T("tr",{className:"border-b border-border",style:Ro,children:[we,H.leadPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${H.leadPx.toString()}px`}}),y.getFlatHeaders().map(U=>H.ids.has(U.column.id)?d(Ko,{declaredType:n?.[U.column.id]?.type,draggedRef:N,header:U,masked:c.columns.has(U.column.id),onTogglePin:m,pinnedOffset:ve.get(U.column.id),table:y},U.id):null),H.tailPx>0&&d("th",{"aria-hidden":"true",style:{flex:`0 0 ${H.tailPx.toString()}px`}}),ye]})}),be=S,te=C.map(U=>ge(U)),e[19]=k,e[20]=h,e[21]=f,e[22]=n,e[23]=o,e[24]=t,e[25]=a,e[26]=c,e[27]=l,e[28]=r,e[29]=z,e[30]=O,e[31]=i,e[32]=m,e[33]=_.columns,e[34]=_.count,e[35]=p,e[36]=b,e[37]=w,e[38]=g,e[39]=y,e[40]=x,e[41]=S,e[42]=E,e[43]=C,e[44]=q,e[45]=X,e[46]=Q,e[47]=Z,e[48]=fe,e[49]=ne,e[50]=ce,e[51]=de,e[52]=me,e[53]=le,e[54]=ue,e[55]=re,e[56]=Y,e[57]=be,e[58]=te,e[59]=xe}else q=e[44],X=e[45],Q=e[46],Z=e[47],fe=e[48],ne=e[49],ce=e[50],de=e[51],me=e[52],le=e[53],ue=e[54],re=e[55],Y=e[56],be=e[57],te=e[58],xe=e[59];let ae;e[68]!==be||e[69]!==te?(ae=d("tbody",{style:be,children:te}),e[68]=be,e[69]=te,e[70]=ae):ae=e[70];let ie;e[71]!==X||e[72]!==Q||e[73]!==Z||e[74]!==ae||e[75]!==xe?(ie=T("table",{className:xe,"data-testid":X,style:Q,children:[Z,ae]}),e[71]=X,e[72]=Q,e[73]=Z,e[74]=ae,e[75]=xe,e[76]=ie):ie=e[76];let W;e[77]!==fe||e[78]!==ne||e[79]!==ce||e[80]!==de||e[81]!==me||e[82]!==le||e[83]!==ue||e[84]!==ie?(W=d("div",{"data-testid":fe,onKeyDown:ne,onPaste:ce,ref:de,role:me,style:le,tabIndex:ue,children:ie}),e[77]=fe,e[78]=ne,e[79]=ce,e[80]=de,e[81]=me,e[82]=le,e[83]=ue,e[84]=ie,e[85]=W):W=e[85];let K;return e[86]!==q||e[87]!==re||e[88]!==Y||e[89]!==W?(K=T(q,{layout:re,children:[Y,W]}),e[86]=q,e[87]=re,e[88]=Y,e[89]=W,e[90]=K):K=e[90],K},Uo=(s,e,n,o=[])=>{const t=s?.columns,c=s?.rows,l=s?.refs,r=Tt(()=>{if(t===void 0)return[];const N=t.map(k=>({accessorFn:M=>M[k],header:l?.[k]===void 0?k:`${k} →`,id:k}));for(const k of o)N.push({accessorFn:()=>{},enableSorting:!1,header:`← ${k.table}`,id:Io(k)});return N},[o,t,l]),i=Tt(()=>c??[],[c]),[a,f]=$({}),[m,p]=$({}),b=Kn({columnResizeMode:"onChange",columns:r,data:i,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:N=>Ie(N.original)!==null,getCoreRowModel:Wn(),getRowId:(N,k)=>Ie(N)??`row-${k.toString()}`,getSortedRowModel:Jn(),manualSorting:!0,onColumnVisibilityChange:p,onRowSelectionChange:f,onSortingChange:n,state:{columnVisibility:m,rowSelection:a,sorting:e}}),u=b.getRowModel().rows,g=Je(null),h=Un({count:u.length,estimateSize:()=>So,getScrollElement:()=>g.current,initialRect:{height:Vt,width:0},observeElementRect:(N,k)=>Qn(N,k,Vt),overscan:8}),w=at(N=>{h.scrollToIndex(N)},[h]),[v,y]=$({left:0,width:0}),x=at(N=>{if(g.current=N,N===null)return;const k=()=>{y(R=>R.left===N.scrollLeft&&R.width===N.clientWidth?R:{left:N.scrollLeft,width:N.clientWidth})};N.addEventListener("scroll",k,{passive:!0});const M=new ResizeObserver(k);return M.observe(N),()=>{N.removeEventListener("scroll",k),M.disconnect(),g.current=null}},[]),S=h.getVirtualItems(),C={display:"block",height:`${h.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:x,scrollLeft:v.left,scrollToIndex:w,table:b,tableRows:u,tbodyStyle:C,viewportWidth:v.width,virtualRows:S}};function Qo(s){const[e,n]=s;return T("div",{className:"contents",children:[d("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),d("dd",{className:"truncate font-mono text-[11px] text-foreground",title:ze(n),children:ze(n)})]},e)}function Yo(s){return s.id}function Xo(s){return s.original}function Zo(s){return{getSize:()=>s.getSize(),id:s.id}}function es(s){return{getSize:()=>s.getSize(),id:s.id}}function ts(s){return s.id}const ns=s=>{const e=B(22),{onCommit:n}=s,o=he(),[t,c]=$(""),l=Je(null);let r,i;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=()=>{l.current?.focus()},i=[],e[0]=r,e[1]=i):(r=e[0],i=e[1]),Be(r,i);let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=y=>{c(y.target.value)},e[2]=a):a=e[2];const f=a;let m;e[3]!==t||e[4]!==n?(m=()=>{const y=t.trim();y!==""&&n(y)},e[3]=t,e[4]=n,e[5]=m):m=e[5];const p=m;let b;e[6]!==o?(b=o("Query name"),e[6]=o,e[7]=b):b=e[7];let u;e[8]!==o?(u=o("Query name"),e[8]=o,e[9]=u):u=e[9];let g;e[10]!==t||e[11]!==b||e[12]!==u?(g=d("input",{"aria-label":b,className:"h-7 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"db-save-query-name",onChange:f,placeholder:u,ref:l,value:t}),e[10]=t,e[11]=b,e[12]=u,e[13]=g):g=e[13];let h;e[14]!==o?(h=o("Save"),e[14]=o,e[15]=h):h=e[15];let w;e[16]!==p||e[17]!==h?(w=d("button",{className:Et,"data-testid":"db-save-query-confirm",onClick:p,type:"button",children:h}),e[16]=p,e[17]=h,e[18]=w):w=e[18];let v;return e[19]!==g||e[20]!==w?(v=T("span",{className:"inline-flex items-center gap-1",children:[g,w]}),e[19]=g,e[20]=w,e[21]=v):v=e[21],v},os=s=>{const e=B(27),{onApply:n,onCopyLink:o,onDelete:t,onSave:c,saved:l}=s,r=he(),[i,a]=$(!1);let f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f=()=>{a(!0)},e[0]=f):f=e[0];const m=f;let p;e[1]!==c?(p=C=>{c(C),a(!1)},e[1]=c,e[2]=p):p=e[2];const b=p;let u;e[3]!==n||e[4]!==l?(u=C=>{const N=l[Number(C.currentTarget.dataset.index)];N!==void 0&&n(N)},e[3]=n,e[4]=l,e[5]=u):u=e[5];const g=u;let h;e[6]!==t||e[7]!==l?(h=C=>{const N=l[Number(C.currentTarget.dataset.index)];N!==void 0&&t(N.name)},e[6]=t,e[7]=l,e[8]=h):h=e[8];const w=h;let v;e[9]!==r?(v=r("Copy link"),e[9]=r,e[10]=v):v=e[10];let y;e[11]!==o||e[12]!==v?(y=d("button",{className:Et,"data-testid":"db-copy-link",onClick:o,type:"button",children:v}),e[11]=o,e[12]=v,e[13]=y):y=e[13];let x;e[14]!==b||e[15]!==i||e[16]!==r?(x=i?d(ns,{onCommit:b}):d("button",{className:Et,"data-testid":"db-save-query",onClick:m,type:"button",children:r("Save query")}),e[14]=b,e[15]=i,e[16]=r,e[17]=x):x=e[17];let S;e[18]!==g||e[19]!==w||e[20]!==l||e[21]!==r?(S=l.length>0&&T("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[d("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:r("Saved")}),l.map((C,N)=>T("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[d("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":N,"data-testid":`db-saved-query-${C.name}`,onClick:g,type:"button",children:C.name}),d("button",{"aria-label":r("Delete saved query {name}",{name:C.name}),className:"border-l border-border px-1 py-0.5 text-xs text-muted-foreground transition-colors hover:bg-destructive/10 hover:text-destructive","data-index":N,"data-testid":`db-saved-query-delete-${C.name}`,onClick:w,type:"button",children:"✕"})]},C.name))]}),e[18]=g,e[19]=w,e[20]=l,e[21]=r,e[22]=S):S=e[22];let E;return e[23]!==y||e[24]!==x||e[25]!==S?(E=T("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[y,x,S]}),e[23]=y,e[24]=x,e[25]=S,e[26]=E):E=e[26],E},We="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",on=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,qt=(s,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?on.test(s)?"date":"number":e!==null&&typeof e=="object"?"json":"text",ss=(s,e,n)=>n===void 0?qt(s,e):n.enumValues!==void 0&&n.enumValues.length>0?"enum":n.type==="boolean"?"boolean":n.type==="number"?on.test(s)?"date":"number":qt(s,e),ls=s=>{try{const e=JSON.parse(s);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},rs=s=>{const e=new Date(s),n=o=>String(o).padStart(2,"0");return`${e.getFullYear().toString()}-${n(e.getMonth()+1)}-${n(e.getDate())}T${n(e.getHours())}:${n(e.getMinutes())}`},Ke="\0clear",as=s=>{const e=B(23),{column:n,nullable:o,onChange:t,value:c}=s,l=he();let r;e[0]!==n||e[1]!==t?(r=v=>{t(n,v)},e[0]=n,e[1]=t,e[2]=r):r=e[2];const i=r;let a;e[3]!==n||e[4]!==t?(a=v=>{t(n,v.target.value===Ke?null:v.target.value==="true")},e[3]=n,e[4]=t,e[5]=a):a=e[5];const f=a;if(!o&&c!==null){const v=c===!0,y=`db-field-${n}`;let x;return e[6]!==n||e[7]!==i||e[8]!==v||e[9]!==y?(x=d(Rt,{"aria-label":n,checked:v,"data-testid":y,onCheckedChange:i}),e[6]=n,e[7]=i,e[8]=v,e[9]=y,e[10]=x):x=e[10],x}const m=`db-field-${n}`,p=c===!0||c===!1?String(c):Ke;let b;e[11]!==l?(b=l("(none)"),e[11]=l,e[12]=b):b=e[12];let u;e[13]!==b?(u=d("option",{value:Ke,children:b}),e[13]=b,e[14]=u):u=e[14];let g,h;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=d("option",{value:"true",children:"true"}),h=d("option",{value:"false",children:"false"}),e[15]=g,e[16]=h):(g=e[15],h=e[16]);let w;return e[17]!==n||e[18]!==f||e[19]!==m||e[20]!==p||e[21]!==u?(w=T("select",{"aria-label":n,className:We,"data-testid":m,onChange:f,value:p,children:[u,g,h]}),e[17]=n,e[18]=f,e[19]=m,e[20]=p,e[21]=u,e[22]=w):w=e[22],w},is=s=>{const e=B(23),{column:n,nullable:o,onChange:t,options:c,value:l}=s,r=he(),i=typeof l=="string"?l:null;let a;e[0]!==c||e[1]!==i?(a=i!==null&&!c.includes(i),e[0]=c,e[1]=i,e[2]=a):a=e[2];const f=a;let m;e[3]!==n||e[4]!==t?(m=y=>{t(n,y.target.value===Ke?null:y.target.value)},e[3]=n,e[4]=t,e[5]=m):m=e[5];const p=m,b=`db-field-${n}`,u=i??Ke;let g;e[6]!==o||e[7]!==i||e[8]!==r?(g=(o||i===null)&&d("option",{value:Ke,children:r("(none)")}),e[6]=o,e[7]=i,e[8]=r,e[9]=g):g=e[9];let h;e[10]!==i||e[11]!==f?(h=f&&d("option",{value:i,children:i}),e[10]=i,e[11]=f,e[12]=h):h=e[12];let w;e[13]!==c?(w=c.map(ps),e[13]=c,e[14]=w):w=e[14];let v;return e[15]!==n||e[16]!==p||e[17]!==b||e[18]!==u||e[19]!==g||e[20]!==h||e[21]!==w?(v=T("select",{"aria-label":n,className:We,"data-testid":b,onChange:p,value:u,children:[g,h,w]}),e[15]=n,e[16]=p,e[17]=b,e[18]=u,e[19]=g,e[20]=h,e[21]=w,e[22]=v):v=e[22],v},cs=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=f=>{const m=Number(f.target.value);f.target.value!==""&&!Number.isNaN(m)&&o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,i=typeof t=="number"?t:"";let a;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==i?(a=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"number",value:i}),e[3]=n,e[4]=l,e[5]=r,e[6]=i,e[7]=a):a=e[7],a},ds=s=>{const e=B(10),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=f=>{const m=new Date(f.target.value).getTime();Number.isNaN(m)||o(n,m)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`;let i;e[3]!==t?(i=typeof t=="number"?rs(t):"",e[3]=t,e[4]=i):i=e[4];let a;return e[5]!==n||e[6]!==l||e[7]!==r||e[8]!==i?(a=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"datetime-local",value:i}),e[5]=n,e[6]=l,e[7]=r,e[8]=i,e[9]=a):a=e[9],a},us=s=>{const e=B(8),{column:n,onChange:o,value:t}=s;let c;e[0]!==n||e[1]!==o?(c=f=>{o(n,f.target.value)},e[0]=n,e[1]=o,e[2]=c):c=e[2];const l=c,r=`db-field-${n}`,i=typeof t=="string"?t:"";let a;return e[3]!==n||e[4]!==l||e[5]!==r||e[6]!==i?(a=d("input",{"aria-label":n,className:We,"data-testid":r,onChange:l,type:"text",value:i}),e[3]=n,e[4]=l,e[5]=r,e[6]=i,e[7]=a):a=e[7],a},fs=s=>{const e=B(20),{column:n,onChange:o,value:t}=s,c=he();let l;e[0]!==t?(l=()=>JSON.stringify(t,null,2),e[0]=t,e[1]=l):l=e[1];const[r,i]=$(l),[a,f]=$(!1);let m;e[2]!==n||e[3]!==o?(m=y=>{const x=y.target.value;i(x);try{o(n,JSON.parse(x)),f(!1)}catch{f(!0)}},e[2]=n,e[3]=o,e[4]=m):m=e[4];const p=m,b=a&&"border-destructive";let u;e[5]!==b?(u=it(We,"min-h-16",b),e[5]=b,e[6]=u):u=e[6];const g=`db-field-${n}`;let h;e[7]!==n||e[8]!==p||e[9]!==u||e[10]!==g||e[11]!==r?(h=d("textarea",{"aria-label":n,className:u,"data-testid":g,onChange:p,value:r}),e[7]=n,e[8]=p,e[9]=u,e[10]=g,e[11]=r,e[12]=h):h=e[12];let w;e[13]!==n||e[14]!==a||e[15]!==c?(w=a&&d("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:c("Invalid JSON")}),e[13]=n,e[14]=a,e[15]=c,e[16]=w):w=e[16];let v;return e[17]!==h||e[18]!==w?(v=T("div",{className:"flex flex-col gap-1",children:[h,w]}),e[17]=h,e[18]=w,e[19]=v):v=e[19],v},ms=s=>{const e=B(56),{column:n,meta:o,onChange:t,target:c,value:l}=s;let r;e[0]!==n||e[1]!==o||e[2]!==l?(r=ss(n,l,o),e[0]=n,e[1]=o,e[2]=l,e[3]=r):r=e[3];const i=r,a=`db-field-${n}`;let f;e[4]!==n?(f=d("span",{className:"font-mono",children:n}),e[4]=n,e[5]=f):f=e[5];let m;e[6]!==n||e[7]!==o?(m=o!==void 0&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide","data-testid":`db-field-type-${n}`,children:o.type}),e[6]=n,e[7]=o,e[8]=m):m=e[8];let p;e[9]!==c?(p=c!==void 0&&T("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["→ ",c]}),e[9]=c,e[10]=p):p=e[10];let b;e[11]!==f||e[12]!==m||e[13]!==p?(b=T("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[f,m,p]}),e[11]=f,e[12]=m,e[13]=p,e[14]=b):b=e[14];let u;e[15]!==n||e[16]!==i||e[17]!==o?.nullable||e[18]!==t||e[19]!==l?(u=i==="boolean"&&d(as,{column:n,nullable:o?.nullable===!0,onChange:t,value:l}),e[15]=n,e[16]=i,e[17]=o?.nullable,e[18]=t,e[19]=l,e[20]=u):u=e[20];let g;e[21]!==n||e[22]!==i||e[23]!==o||e[24]!==t||e[25]!==l?(g=i==="enum"&&o?.enumValues!==void 0&&d(is,{column:n,nullable:o.nullable===!0,onChange:t,options:o.enumValues,value:l}),e[21]=n,e[22]=i,e[23]=o,e[24]=t,e[25]=l,e[26]=g):g=e[26];let h;e[27]!==n||e[28]!==i||e[29]!==t||e[30]!==l?(h=i==="number"&&d(cs,{column:n,onChange:t,value:l}),e[27]=n,e[28]=i,e[29]=t,e[30]=l,e[31]=h):h=e[31];let w;e[32]!==n||e[33]!==i||e[34]!==t||e[35]!==l?(w=i==="date"&&d(ds,{column:n,onChange:t,value:l}),e[32]=n,e[33]=i,e[34]=t,e[35]=l,e[36]=w):w=e[36];let v;e[37]!==n||e[38]!==i||e[39]!==t||e[40]!==l?(v=i==="json"&&d(fs,{column:n,onChange:t,value:l}),e[37]=n,e[38]=i,e[39]=t,e[40]=l,e[41]=v):v=e[41];let y;e[42]!==n||e[43]!==i||e[44]!==t||e[45]!==l?(y=i==="text"&&d(us,{column:n,onChange:t,value:l}),e[42]=n,e[43]=i,e[44]=t,e[45]=l,e[46]=y):y=e[46];let x;return e[47]!==w||e[48]!==v||e[49]!==y||e[50]!==a||e[51]!==b||e[52]!==u||e[53]!==g||e[54]!==h?(x=T("label",{className:"flex flex-col gap-1 text-xs",htmlFor:a,children:[b,u,g,h,w,v,y]}),e[47]=w,e[48]=v,e[49]=y,e[50]=a,e[51]=b,e[52]=u,e[53]=g,e[54]=h,e[55]=x):x=e[55],x},gs=s=>{const e=B(49),{columnMeta:n,documentText:o,onCancel:t,onDocumentTextChange:c,onSave:l,refs:r}=s,i=he();let a;e[0]!==o?(a=ls(o),e[0]=o,e[1]=a):a=e[1];const f=a,[m,p]=$(!1),b=!m&&f!==null;let u;e[2]!==f||e[3]!==c?(u=(V,J)=>{c(JSON.stringify({...f,[V]:J},null,2))},e[2]=f,e[3]=c,e[4]=u):u=e[4];const g=u;let h;e[5]!==c?(h=V=>{c(V.target.value)},e[5]=c,e[6]=h):h=e[6];const w=h;let v;e[7]===Symbol.for("react.memo_cache_sentinel")?(v=()=>{p(!1)},e[7]=v):v=e[7];const y=v;let x;e[8]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{p(!0)},e[8]=x):x=e[8];const S=x,E=f===null;let C;e[9]!==i?(C=i("Form"),e[9]=i,e[10]=C):C=e[10];let N;e[11]!==b||e[12]!==E||e[13]!==C?(N=d("button",{"aria-pressed":b,className:De,"data-testid":"db-editor-form",disabled:E,onClick:y,type:"button",children:C}),e[11]=b,e[12]=E,e[13]=C,e[14]=N):N=e[14];const k=!b;let M;e[15]!==i?(M=i("JSON"),e[15]=i,e[16]=M):M=e[16];let R;e[17]!==M||e[18]!==k?(R=d("button",{"aria-pressed":k,className:De,"data-testid":"db-editor-json",onClick:S,type:"button",children:M}),e[17]=M,e[18]=k,e[19]=R):R=e[19];let _;e[20]!==R||e[21]!==N?(_=T("div",{className:"flex items-center gap-1.5",children:[N,R]}),e[20]=R,e[21]=N,e[22]=_):_=e[22];let D;e[23]!==n||e[24]!==o||e[25]!==f||e[26]!==g||e[27]!==w||e[28]!==r||e[29]!==b||e[30]!==i?(D=b?d("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(f).map(V=>{const[J,q]=V;return d(ms,{column:J,meta:n?.[J],onChange:g,target:r?.[J],value:q},J)})}):d("textarea",{"aria-label":i("Row document JSON"),className:"min-h-28 w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"db-editor-doc",onChange:w,value:o}),e[23]=n,e[24]=o,e[25]=f,e[26]=g,e[27]=w,e[28]=r,e[29]=b,e[30]=i,e[31]=D):D=e[31];let I;e[32]!==i?(I=i("Save"),e[32]=i,e[33]=I):I=e[33];let F;e[34]!==l||e[35]!==I?(F=d("button",{className:De,"data-testid":"db-editor-save",onClick:l,type:"button",children:I}),e[34]=l,e[35]=I,e[36]=F):F=e[36];let A;e[37]!==i?(A=i("Cancel"),e[37]=i,e[38]=A):A=e[38];let z;e[39]!==t||e[40]!==A?(z=d("button",{className:De,"data-testid":"db-editor-cancel",onClick:t,type:"button",children:A}),e[39]=t,e[40]=A,e[41]=z):z=e[41];let j;e[42]!==F||e[43]!==z?(j=T("div",{className:"flex items-center gap-1.5",children:[F,z]}),e[42]=F,e[43]=z,e[44]=j):j=e[44];let O;return e[45]!==_||e[46]!==D||e[47]!==j?(O=T("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[_,D,j]}),e[45]=_,e[46]=D,e[47]=j,e[48]=O):O=e[48],O};function ps(s){return d("option",{value:s,children:s},s)}const bs=s=>{const e=B(66),{columns:n,editable:o,filter:t,filters:c,hasMaskedColumns:l,hasPredicate:r,liveError:i,maskOn:a,onAddRow:f,onBulkDelete:m,onBulkPatch:p,onAskAiFilter:b,onClearTable:u,onFilterChange:g,onFiltersChange:h,onGenerateRows:w,onShowJson:v,onShowTable:y,onToggleMask:x,total:S,viewMode:E}=s,C=he(),N=E==="table";let k;e[0]!==y||e[1]!==N?(k=d("button",{"aria-pressed":N,className:De,"data-testid":"db-view-table",onClick:y,type:"button",children:"Table"}),e[0]=y,e[1]=N,e[2]=k):k=e[2];const M=E==="json";let R;e[3]!==v||e[4]!==M?(R=d("button",{"aria-pressed":M,className:De,"data-testid":"db-view-json",onClick:v,type:"button",children:"JSON"}),e[3]=v,e[4]=M,e[5]=R):R=e[5];let _;e[6]!==i||e[7]!==C?(_=i===void 0?C("Live — changes stream in automatically"):C("Live unavailable: {liveError}",{liveError:i}),e[6]=i,e[7]=C,e[8]=_):_=e[8];const D=`size-1.5 rounded-full ${i===void 0?"bg-success":"bg-muted-foreground/50"}`;let I;e[9]!==D?(I=d("span",{"aria-hidden":"true",className:D}),e[9]=D,e[10]=I):I=e[10];let F;e[11]!==i||e[12]!==C?(F=C(i===void 0?"Live":"Live unavailable"),e[11]=i,e[12]=C,e[13]=F):F=e[13];let A;e[14]!==_||e[15]!==I||e[16]!==F?(A=T("span",{className:"inline-flex items-center gap-1.5 px-1 text-xs font-medium text-muted-foreground","data-testid":"db-live-indicator",role:"status",title:_,children:[I,F]}),e[14]=_,e[15]=I,e[16]=F,e[17]=A):A=e[17];let z;e[18]!==l||e[19]!==a||e[20]!==x||e[21]!==C?(z=l&&d("button",{"aria-pressed":a,className:De,"data-testid":"db-mask-toggle",onClick:x,type:"button",children:C("Mask sensitive columns")}),e[18]=l,e[19]=a,e[20]=x,e[21]=C,e[22]=z):z=e[22];let j;e[23]!==o||e[24]!==f?(j=o&&d("button",{className:De,"data-testid":"db-add-row",onClick:f,type:"button",children:"Add row"}),e[23]=o,e[24]=f,e[25]=j):j=e[25];let O;e[26]!==o||e[27]!==w||e[28]!==C?(O=o&&d("button",{className:De,"data-testid":"db-generate-rows",onClick:w,type:"button",children:C("Generate rows")}),e[26]=o,e[27]=w,e[28]=C,e[29]=O):O=e[29];let V;e[30]!==o||e[31]!==r||e[32]!==m||e[33]!==S?(V=o&&S>0&&r&&d(Mt,{confirmLabel:`Delete ${S.toString()} matching?`,onConfirm:m,testId:"db-bulk-delete",children:`Delete ${S.toString()} matching`}),e[30]=o,e[31]=r,e[32]=m,e[33]=S,e[34]=V):V=e[34];let J;e[35]!==o||e[36]!==r||e[37]!==p||e[38]!==C||e[39]!==S?(J=o&&S>0&&r&&d("button",{className:De,"data-testid":"db-bulk-patch",onClick:p,type:"button",children:C("Set column on {total} matching",{total:S.toString()})}),e[35]=o,e[36]=r,e[37]=p,e[38]=C,e[39]=S,e[40]=J):J=e[40];let q;e[41]!==o||e[42]!==r||e[43]!==u||e[44]!==S?(q=o&&S>0&&!r&&d(Mt,{confirmLabel:`Clear all ${S.toString()} rows?`,onConfirm:u,testId:"db-clear-table",children:`Clear table (${S.toString()})`}),e[41]=o,e[42]=r,e[43]=u,e[44]=S,e[45]=q):q=e[45];let X;e[46]!==z||e[47]!==j||e[48]!==O||e[49]!==V||e[50]!==J||e[51]!==q||e[52]!==k||e[53]!==R||e[54]!==A?(X=T("div",{className:"flex flex-wrap items-center gap-1.5",children:[k,R,A,z,j,O,V,J,q]}),e[46]=z,e[47]=j,e[48]=O,e[49]=V,e[50]=J,e[51]=q,e[52]=k,e[53]=R,e[54]=A,e[55]=X):X=e[55];let Q;e[56]!==n||e[57]!==t||e[58]!==c||e[59]!==b||e[60]!==g||e[61]!==h?(Q=d(Zn,{columns:n,filters:c,onAskAi:b,onFiltersChange:h,onSearchChange:g,search:t}),e[56]=n,e[57]=t,e[58]=c,e[59]=b,e[60]=g,e[61]=h,e[62]=Q):Q=e[62];let Z;return e[63]!==X||e[64]!==Q?(Z=T("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[X,Q]}),e[63]=X,e[64]=Q,e[65]=Z):Z=e[65],Z},hs=s=>{const e=B(109),{assistant:n,backRelations:o,browser:t,columnMeta:c,edit:l,editable:r,onAskAiFilter:i,onInspect:a,onOpenBulkPatch:f,onOpenGenerateRows:m,onRowDelete:p,onSaveQuery:b,page:u,preferences:g,queryBar:h,references:w}=s,v=g.maskColumns.size>0,y=n.unavailable?void 0:i;let x;e[0]!==t.addRow||e[1]!==t.bulkDelete||e[2]!==t.clearTable||e[3]!==t.columns||e[4]!==t.filter||e[5]!==t.filters||e[6]!==t.hasPredicate||e[7]!==t.liveError||e[8]!==t.onFilterChange||e[9]!==t.onFiltersChange||e[10]!==t.showJson||e[11]!==t.showTable||e[12]!==t.total||e[13]!==t.viewMode||e[14]!==r||e[15]!==f||e[16]!==m||e[17]!==g.maskOn||e[18]!==g.onToggleMask||e[19]!==v||e[20]!==y?(x=d(bs,{columns:t.columns,editable:r,filter:t.filter,filters:t.filters,hasMaskedColumns:v,hasPredicate:t.hasPredicate,liveError:t.liveError,maskOn:g.maskOn,onAddRow:t.addRow,onAskAiFilter:y,onBulkDelete:t.bulkDelete,onBulkPatch:f,onClearTable:t.clearTable,onFilterChange:t.onFilterChange,onFiltersChange:t.onFiltersChange,onGenerateRows:m,onShowJson:t.showJson,onShowTable:t.showTable,onToggleMask:g.onToggleMask,total:t.total,viewMode:t.viewMode}),e[0]=t.addRow,e[1]=t.bulkDelete,e[2]=t.clearTable,e[3]=t.columns,e[4]=t.filter,e[5]=t.filters,e[6]=t.hasPredicate,e[7]=t.liveError,e[8]=t.onFilterChange,e[9]=t.onFiltersChange,e[10]=t.showJson,e[11]=t.showTable,e[12]=t.total,e[13]=t.viewMode,e[14]=r,e[15]=f,e[16]=m,e[17]=g.maskOn,e[18]=g.onToggleMask,e[19]=v,e[20]=y,e[21]=x):x=e[21];let S;e[22]!==b||e[23]!==h?(S=h!==void 0&&d(os,{onApply:h.onApplyQuery,onCopyLink:h.onCopyLink,onDelete:h.onDeleteQuery,onSave:b,saved:h.saved}),e[22]=b,e[23]=h,e[24]=S):S=e[24];let E;e[25]!==o||e[26]!==t.onBulkDeleteSelected||e[27]!==t.selectedTable||e[28]!==t.table||e[29]!==t.viewMode||e[30]!==r||e[31]!==u||e[32]!==g.maskView||e[33]!==g.onToggleTranspose||e[34]!==g.transposed?(E=t.viewMode==="table"&&u.rows.length>0&&d(eo,{backRelations:o.available,columns:u.columns,editable:r,enabledBackRelations:o.enabled,name:t.selectedTable??"export",onBulkDelete:t.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:g.onToggleTranspose,rows:vt(u.rows,g.maskView),table:t.table.table,transposed:g.transposed}),e[25]=o,e[26]=t.onBulkDeleteSelected,e[27]=t.selectedTable,e[28]=t.table,e[29]=t.viewMode,e[30]=r,e[31]=u,e[32]=g.maskView,e[33]=g.onToggleTranspose,e[34]=g.transposed,e[35]=E):E=e[35];let C;e[36]!==t.cancelEdit||e[37]!==t.editing||e[38]!==t.saveEdit||e[39]!==t.setEditorDocumentText||e[40]!==c||e[41]!==r||e[42]!==u?(C=r&&t.editing!==null&&d(gs,{columnMeta:c,documentText:t.editing.docText,onCancel:t.cancelEdit,onDocumentTextChange:t.setEditorDocumentText,onSave:t.saveEdit,refs:u.refs}),e[36]=t.cancelEdit,e[37]=t.editing,e[38]=t.saveEdit,e[39]=t.setEditorDocumentText,e[40]=c,e[41]=r,e[42]=u,e[43]=C):C=e[43];let N;e[44]!==t.committing||e[45]!==t.discardStaged||e[46]!==t.onCommitStaged||e[47]!==t.stagedChanges||e[48]!==r?(N=r&&t.stagedChanges.length>0&&d(yo,{changes:t.stagedChanges,committing:t.committing,onCommit:t.onCommitStaged,onDiscard:t.discardStaged}),e[44]=t.committing,e[45]=t.discardStaged,e[46]=t.onCommitStaged,e[47]=t.stagedChanges,e[48]=r,e[49]=N):N=e[49];let k;e[50]!==t.writeError?(k=t.writeError!==null&&d("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:t.writeError}),e[50]=t.writeError,e[51]=k):k=e[51];let M;e[52]!==t.writeNotice?(M=t.writeNotice!==null&&d("p",{className:"text-sm text-muted-foreground","data-testid":"db-write-notice",role:"status",children:t.writeNotice}),e[52]=t.writeNotice,e[53]=M):M=e[53];let R;e[54]!==x||e[55]!==S||e[56]!==E||e[57]!==C||e[58]!==N||e[59]!==k||e[60]!==M?(R=T("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[x,S,E,C,N,k,M]}),e[54]=x,e[55]=S,e[56]=E,e[57]=C,e[58]=N,e[59]=k,e[60]=M,e[61]=R):R=e[61];let _;e[62]!==t.viewMode||e[63]!==u?(_=t.viewMode==="table"&&u.rows.length===0&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d(Gn,{description:"Rows you insert into this table will show up here.",icon:d("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:d("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[62]=t.viewMode,e[63]=u,e[64]=_):_=e[64];let D;e[65]!==t.viewMode||e[66]!==u||e[67]!==g.maskView||e[68]!==g.transposed?(D=t.viewMode==="table"&&u.rows.length>0&&g.transposed&&d(Xn,{columns:u.columns,rows:vt(u.rows,g.maskView)}),e[65]=t.viewMode,e[66]=u,e[67]=g.maskView,e[68]=g.transposed,e[69]=D):D=e[69];let I;e[70]!==o||e[71]!==t.filter||e[72]!==t.onRowEdit||e[73]!==t.table||e[74]!==t.viewMode||e[75]!==c||e[76]!==l||e[77]!==r||e[78]!==a||e[79]!==p||e[80]!==u||e[81]!==g.maskView||e[82]!==g.onTogglePin||e[83]!==g.pinnedColumns||e[84]!==g.transposed||e[85]!==w?(I=t.viewMode==="table"&&u.rows.length>0&&!g.transposed&&d(Ho,{backRelationCounts:o.counts,columnMeta:c,edit:l,editable:r,highlight:t.filter,mask:g.maskView,onDelete:p,onEdit:t.onRowEdit,onInspect:a,onTogglePin:g.onTogglePin,pinnedColumns:g.pinnedColumns,refs:w,tableModel:t.table}),e[70]=o,e[71]=t.filter,e[72]=t.onRowEdit,e[73]=t.table,e[74]=t.viewMode,e[75]=c,e[76]=l,e[77]=r,e[78]=a,e[79]=p,e[80]=u,e[81]=g.maskView,e[82]=g.onTogglePin,e[83]=g.pinnedColumns,e[84]=g.transposed,e[85]=w,e[86]=I):I=e[86];let F;e[87]!==t.viewMode||e[88]!==u||e[89]!==g.maskView?(F=t.viewMode==="json"&&d("pre",{className:"min-h-0 flex-1 overflow-auto border-t border-border bg-muted/30 p-3 text-xs","data-testid":"db-json",children:JSON.stringify(vt(u.rows,g.maskView),In,2)}),e[87]=t.viewMode,e[88]=u,e[89]=g.maskView,e[90]=F):F=e[90];let A;e[91]!==t.changePageSize||e[92]!==t.goNext||e[93]!==t.goPrevious||e[94]!==t.hasNext||e[95]!==t.hasPrevious||e[96]!==t.jumpToPage||e[97]!==t.pageSize||e[98]!==t.rangeEnd||e[99]!==t.rangeStart||e[100]!==t.total?(A=d("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:d(Mn,{hasNext:t.hasNext,hasPrevious:t.hasPrevious,onJumpToPage:t.jumpToPage,onNext:t.goNext,onPageSizeChange:t.changePageSize,onPrevious:t.goPrevious,pageSize:t.pageSize,prefix:"db",rangeEnd:t.rangeEnd,rangeStart:t.rangeStart,total:t.total})}),e[91]=t.changePageSize,e[92]=t.goNext,e[93]=t.goPrevious,e[94]=t.hasNext,e[95]=t.hasPrevious,e[96]=t.jumpToPage,e[97]=t.pageSize,e[98]=t.rangeEnd,e[99]=t.rangeStart,e[100]=t.total,e[101]=A):A=e[101];let z;return e[102]!==R||e[103]!==_||e[104]!==D||e[105]!==I||e[106]!==F||e[107]!==A?(z=T("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[R,_,D,I,F,A]}),e[102]=R,e[103]=_,e[104]=D,e[105]=I,e[106]=F,e[107]=A,e[108]=z):z=e[108],z},xs="/__lunora/seed",St=200,vs=50,ws=(s,e)=>{const n=[];for(const o of s)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},ys=async s=>{const e=await fetch(xs,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),n=await e.json();return e.ok&&n.rows!==void 0?{kind:"ok",rows:n.rows}:{kind:"error",message:n.error??`seed request failed (${String(e.status)})`}},Cs="rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50",Ns="rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50",Ss=({columns:s,fkPools:e,onClose:n,onInsertRows:o,table:t})=>{const c=he(),[l,r]=$(10),[i,a]=$(!1),[f,m]=$(void 0),[p,b]=$(void 0),[u,g]=$(0),h=x=>{const S=Number(x.target.value);!Number.isNaN(S)&&S>=1&&r(Math.min(S,St))},w=async()=>{m(void 0),b(void 0),g(0),a(!0);try{const x=await ys({count:l,existingIds:e,seed:Date.now(),table:t});if(x.kind==="error"){m(x.message);return}const{rows:S}=x;if(S.length===0){m(c("No rows generated — all columns were skipped."));return}const E=await o(S);if(E.error!==void 0){m(E.error);return}b(E.inserted),g(E.conflicts);const C=ws(s,e);C.length>0&&m(c("Inserted {count} rows. Skipped FK columns: {cols}",{cols:C.join(", "),count:E.inserted.toString()}))}finally{a(!1)}},v=()=>{Ce(w())},y=s.filter(x=>x.pk!==!0);return T(dt,{label:c("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[T("div",{className:"flex items-start justify-between",children:[T("div",{className:"flex flex-col gap-0.5",children:[d("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:c("Generate dummy rows")}),d("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:c("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:t})})]}),d("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:c("Close")})]}),T("div",{className:"flex items-center gap-2",children:[d("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:c("Row count")}),d("input",{className:"w-20 rounded-md border border-border bg-background px-2 py-1 text-xs outline-none focus-visible:border-ring","data-testid":"gen-rows-count",id:"gen-rows-count",max:St,min:1,onChange:h,type:"number",value:l}),d("span",{className:"text-xs text-muted-foreground",children:c("(max {max})",{max:St.toString()})})]}),y.length>0&&T("div",{className:"flex flex-col gap-1",children:[d("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c("Columns to seed")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:y.map(x=>{const S=x.ref!==void 0&&x.type==="id",E=S&&(e[x.ref??""]??[]).length===0,C=E?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",N=E?`gen-rows-fk-empty-${x.name}`:`gen-rows-fk-ok-${x.name}`,k=E?c("FK: no rows in {ref} — will skip",{ref:x.ref??""}):c("→ {ref}",{ref:x.ref??""});return T("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[d("span",{className:"text-foreground",children:x.name}),T("span",{className:"text-muted-foreground",children:["(",x.type,")"]}),x.optional&&d("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),S&&d("span",{className:C,"data-testid":N,children:k})]},x.name)})})]}),f!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:f}),p!==void 0&&f===void 0&&d("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:u>0?c("Inserted {inserted} of {total} rows — {conflicts} skipped as id conflicts.",{conflicts:u.toString(),inserted:p.toString(),total:(p+u).toString()}):c("Inserted {count} rows successfully.",{count:p.toString()})}),T("div",{className:"flex justify-end gap-2",children:[d("button",{className:Cs,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:c("Cancel")}),d("button",{className:Ns,"data-testid":"gen-rows-generate",disabled:i,onClick:v,type:"button",children:c(i?"Inserting…":"Generate & insert")})]})]})},ks=Te(pe.backRelationCounts),Ts=(s,e,n,o)=>{const t=B(16),c=ct();let l;t[0]===Symbol.for("react.memo_cache_sentinel")?(l={},t[0]=l):l=t[0];const[r,i]=$(l);let a;if(t[1]!==s||t[2]!==e){let w;t[4]!==s?(w=v=>s.has($t(v)),t[4]=s,t[5]=w):w=t[5],a=e.filter(w),t[1]=s,t[2]=e,t[3]=a}else a=t[3];const f=a;let m;t[6]!==n||t[7]!==f?(m=JSON.stringify([f,n]),t[6]=n,t[7]=f,t[8]=m):m=t[8];const p=m;let b;t[9]!==c||t[10]!==o||t[11]!==p?(b=async w=>{const[v,y]=JSON.parse(p);if(v.length===0||y.length===0){w.cancelled||i({});return}try{const x=await c.query(ks,{ids:y,relations:v},ke(o));w.cancelled||i(Object.fromEntries(x.relations.map(Es)))}catch{}},t[9]=c,t[10]=o,t[11]=p,t[12]=b):b=t[12];const u=b;let g,h;return t[13]!==u?(g=()=>{const w={cancelled:!1};return Ce(u(w)),()=>{w.cancelled=!0}},h=[u],t[13]=u,t[14]=g,t[15]=h):(g=t[14],h=t[15]),Be(g,h),r};function Es(s){return[$t(s),s.counts]}const _s=async s=>{const{args:e,maxBatches:n,openCursor:o,query:t}=s;let c=o,l=0,r="cap-hit";for(let i=0;i<n;i+=1){const a=await t({...e,after:c});if(l+=a.count,c=a.cursor,!a.hasMore){r="completed";break}}return{cursor:r==="cap-hit"?c:void 0,outcome:r,written:l}},rt=s=>{const e=s[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},sn=s=>s==null?"":typeof s=="object"?JSON.stringify(s):String(s),Gt=s=>s.map(e=>({column:e.column,operator:e.operator,value:e.value===void 0?"":sn(e.value)})),Kt=s=>s===void 0?[]:[{desc:s.direction==="desc",id:s.column}],Rs=s=>[s.column,s.operator,s.value],st=(s,e,n,o)=>JSON.stringify([s??"",e??"",(n??[]).map(t=>Rs(t)),o===void 0?null:[o.column,o.direction]]),It=200,$s=20,Ds=Te(pe.readTablePage),Is=Te(pe.facetColumn),kt=Te(pe.writeRow),Ps=Te(pe.deleteRows),As=Te(pe.clearTable),Ms=Te(pe.patchRows),Os={},Pt=new Set(["__doc__","__id__","_creationTime","_id","id"]),Fs=s=>{const e=s.__doc__;if(typeof e=="string"){const o=jn(e);if(o!==void 0)return o}const n={};for(const[o,t]of Object.entries(s))Pt.has(o)||(n[o]=t);return n},Ls=(s,e,n)=>JSON.stringify([s.__lunoraRef,n,Qt(e)]),Vs=({filters:s,offset:e,pageSize:n,search:o,sorting:t,table:c})=>({filters:Ve(s),limit:n,offset:e,orderBy:rt(t),search:o,skipCount:!0,table:c}),Bs=({filters:s,search:e,table:n})=>({filters:Ve(s),limit:1,search:e,table:n}),zs=(s,e)=>{const n=new Map;for(const t of s?.rows??[]){const c=Ie(t);c!==null&&n.set(c,t)}const o=[];for(const[t,c]of Object.entries(e))for(const[l,r]of Object.entries(c))o.push({column:l,newValue:r,oldValue:n.get(t)?.[l],rowId:t});return o},js=s=>!Pt.has(s),qs=`Stopped after ${It.toString()} batches — rows still match. Run it again to remove the rest.`,Gs=`Stopped after ${It.toString()} batches — rows still match. Run it again to set the rest.`,Jt={resumable:!1,truncated:qs,verb:"deleted"},Ks={resumable:!0,truncated:Gs,verb:"written"},Js=({initialFilters:s,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:t,onViewChange:c,pageSize:l,resolveBackRelations:r,tableParam:i})=>{const a=ct(),[f,m]=$(l),[p,b]=$(o??""),u=i===void 0||i===""?null:i,[g,h]=$(0),[w,v]=$("table"),[y,x]=$(()=>Kt(e)),[S,E]=$(n??""),[C,N]=$(()=>Gt(s??[])),{clearFacets:k,facets:M,refetchFacets:R,toggleFacet:_}=On(),[D,I]=$(null),[F,A]=$(null),[z,j]=$(null),O=Je(null),V=wo(),[J,q]=$(null),[X,Q]=$(!1),[Z,fe]=$(i),[ne,ce]=$(()=>st(o,n,s,e)),[de,me]=$(0),[le,ue]=$(()=>st(o,n,s,e)),re=i!==Z,Y=st(o,n,s,e),te=re||!re&&Y!==ne&&Y!==le;if(te){fe(i),ce(Y),me(G=>G+1),x(Kt(e)),E(n??"");const P=Gt(s??[]);N(P),b(o??""),k(),V.clear(),q(null),h(0),A(null),j(null),O.current=null}else Y!==ne&&ce(Y);const xe=te?n??"":S,ae=te?o??"":p,ie=`${i??""}:${de.toString()}`,W=Ot(xe.trim(),300,ie),K=Ot(ae.trim(),400,ie),ee=st(K,W,Ve(C),rt(y));ee!==le&&ue(ee);const H=Xe(pe.listTables,Os,{live:!0,shardKey:K}),ve=H.data??null,ge=H.error,we=Vs({filters:C,offset:g,pageSize:f,search:W,sorting:y,table:u??""}),ye=Bs({filters:C,search:W,table:u??""}),U=Xe(pe.readTablePage,we,{enabled:u!==null,keepPreviousData:!1,live:!0,shardKey:K}),oe=U.data??null,Me=U.error,{liveError:Pe}=U,Ae=Xe(pe.readTablePage,ye,{enabled:u!==null,live:!0,shardKey:K});Be(()=>{H.data!==void 0&&no(K)},[H.data,K]);const He=P=>{t?.(P)},Se=(P,G)=>{t?.(P,{search:G})},je=async(P,G)=>{try{return(await a.query(Ds,{filters:[],limit:$s,offset:0,search:G,table:P},ke(K))).rows.find(_e=>Ie(_e)===G)??null}catch{return null}},Oe=(P,G,Ne,_e)=>$e=>a.query(Is,{column:$e,filters:Ve(Ne),search:_e,table:G},ke(P)),Ue=P=>{_(P,u===null?null:Oe(K,u,C,W))},ut=(P,G)=>{const Ne=sn(G);N(_e=>[..._e.filter($e=>$e.column!==P),{column:P,operator:"eq",value:Ne}]),h(0)},ft=wt(Oe),et=wt(R),tt=wt(c);Be(()=>{u!==null&&et.current(ft.current(K,u,C,W))},[K,u,C,W]),Be(()=>{u===null||tt.current===void 0||Z!==i||ne!==Y||tt.current({filters:Ve(C),orderBy:rt(y),search:W,shard:K})},[u,i,Z,ne,Y,C,y,W,K]);const Qe=P=>{u!==null&&h(Math.max(0,P))},nt=(P,G)=>{q({column:G,rowId:P})},mt=()=>{q(null)},gt=async()=>{if(u!==null){A(null),Q(!0);try{for(const[P,G]of Object.entries(V.staged))await a.query(kt,{doc:G,id:P,op:"patch",table:u},ke(K));V.clear(),q(null),U.refetch()}catch(P){A(P.message)}Q(!1)}},pt=()=>{V.clear(),q(null)},bt=zs(oe,V.staged),ot=async(P,G,Ne)=>{if(u===null)return;A(null);let _e;if(P!=="delete"){let $e;try{$e=Ne===void 0||Ne.trim()===""?{}:JSON.parse(Ne)}catch(Le){A(`Invalid JSON: ${Le.message}`);return}try{const Le=Ut($e);if(!zn(Le)){A("The document must be a JSON object.");return}_e=Le}catch(Le){A(`Invalid document: ${Le.message}`);return}}try{await a.query(kt,{doc:_e,id:G??void 0,op:P,table:u},ke(K)),I(null),U.refetch()}catch($e){A($e.message)}},Ye=async(P,G,Ne)=>{if(u===null)return 0;A(null),j(null);const _e=Ls(P,G,K),$e=O.current?.key===_e?O.current.after:void 0,Le=Ne.resumable?$e??"":void 0;let qe=0;try{const Ge=await _s({args:G,maxBatches:It,openCursor:Le,query:async $n=>await a.query(P,$n,ke(K))});return qe=Ge.written,O.current=Ge.cursor===void 0?null:{after:Ge.cursor,key:_e},Ge.outcome==="cap-hit"&&A(Ne.truncated),j(`${qe.toString()} ${qe===1?"row":"rows"} ${Ne.verb}.`),qe}catch(Ge){return A(`${Ge.message} (at least ${qe.toString()} rows were already ${Ne.verb})`),O.current=null,qe}finally{h(0),U.refetch()}},ht=P=>{x(P),h(0)},L=Tt(()=>u===null?[]:r?.(u)??[],[r,u]),se=Uo(oe,y,ht,L),Ee={filters:Ve(C),orderBy:rt(y),search:W,shard:p,table:u??void 0},Re=Ae.data?.total??(oe===null?0:g+oe.rows.length),Fe=g>0,xt=W!==""||C.length>0,ln=oe!==null&&g+oe.rows.length<Re,rn=oe===null||oe.rows.length===0?0:g+1,an=oe===null?0:g+oe.rows.length,cn=()=>{H.refetch()},dn=()=>{v("table")},un=()=>{v("json")},fn=()=>{Ce(Ye(Ps,{filters:Ve(C),search:W,table:u},Jt))},mn=()=>{Ce(Ye(As,{table:u},Jt))},gn=P=>{Ce(Ye(Ms,{doc:P,filters:Ve(C),search:W,table:u},Ks))},pn=P=>{E(P.target.value),h(0)},bn=P=>{N(P),h(0)},hn=()=>{A(null);const P={};for(const G of oe?.columns??[])Pt.has(G)||(P[G]="");I({docText:JSON.stringify(P,null,2),id:""})},xn=P=>{I(G=>G===null?G:{docText:P,id:G.id})},vn=()=>{D!==null&&Ce(ot(D.id===""?"insert":"patch",D.id===""?null:D.id,D.docText))},wn=()=>{I(null),A(null)},yn=()=>{Qe(g-f)},Cn=()=>{Qe(g+f)},Nn=P=>{Qe(Math.max(0,(P-1)*f))},Sn=P=>{m(P),h(0)},kn=(P,G)=>{A(null),I({docText:JSON.stringify(Qt(Fs(G)),null,2),id:P})},Tn=P=>{Ce(ot("delete",P))},En=async P=>{if(!(u===null||P.length===0)){A(null);try{for(const G of P)await a.query(kt,{id:G,op:"delete",table:u},ke(K));U.refetch()}catch(G){A(G.message)}}},_n=P=>{Ce(En(P))},Rn=()=>{Ce(gt())};return{addRow:hn,bulkDelete:fn,bulkPatch:gn,cancelCellEdit:mt,cancelEdit:wn,changePageSize:Sn,clearTable:mn,columns:oe?.columns??[],committing:X,currentView:Ee,discardStaged:pt,editableColumn:js,editing:D,editingCell:J,facetFilter:ut,facets:M,filter:S,filters:C,goNext:Cn,goPrevious:yn,hasNext:ln,hasPredicate:xt,hasPrevious:Fe,jumpToPage:Nn,liveError:Pe,loadTables:cn,navigateToRef:Se,onBulkDeleteSelected:_n,onCommitStaged:Rn,onFilterChange:pn,onFiltersChange:bn,onRowDelete:Tn,onRowEdit:kn,page:oe,previewRef:je,pageError:Me,pageSize:f,rangeEnd:an,rangeStart:rn,queryShardKey:K,saveEdit:vn,selectedTable:u,selectTable:He,setEditorDocumentText:xn,setShardKey:b,shardKey:p,showJson:un,showTable:dn,stage:V.stage,stagedChanges:bt,stagedValue:V.stagedValue,startCellEdit:nt,table:se,tables:ve,tablesError:ge,toggleFacet:Ue,total:Re,viewMode:w,writeError:F,writeNotice:z}},Ws="lunora-studio-pinned-columns",Hs=s=>{const e=B(21),{columns:n,initialPins:o,selectedTable:t}=s;let c;e[0]===Symbol.for("react.memo_cache_sentinel")?(c={},e[0]=c):c=e[0];const[l,r]=Wt(Ws,c),i=t??"",a=l[i];let f;e[1]!==o||e[2]!==a?(f=a===void 0?new Set((o??"").split(",").filter(Us)):new Set(a),e[1]=o,e[2]=a,e[3]=f):f=e[3];const m=f;let p;e[4]!==i||e[5]!==m||e[6]!==r?(p=k=>{r(M=>{const R=M[i]??[...m],_=R.includes(k)?R.filter(D=>D!==k):[...R,k];return{...M,[i]:_}})},e[4]=i,e[5]=m,e[6]=r,e[7]=p):p=e[7];const b=p,[u,g]=$(!1);let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{g(Qs)},e[8]=h):h=e[8];const w=h;let v;e[9]!==n||e[10]!==t?(v={columns:n,selectedTable:t},e[9]=n,e[10]=t,e[11]=v):v=e[11];const{maskColumns:y,maskOn:x,maskView:S,maskViewFor:E,onToggleMask:C}=Fn(v);let N;return e[12]!==y||e[13]!==x||e[14]!==S||e[15]!==E||e[16]!==C||e[17]!==b||e[18]!==m||e[19]!==u?(N={maskColumns:y,maskOn:x,maskView:S,maskViewFor:E,onToggleMask:C,onTogglePin:b,onToggleTranspose:w,pinnedColumns:m,transposed:u},e[12]=y,e[13]=x,e[14]=S,e[15]=E,e[16]=C,e[17]=b,e[18]=m,e[19]=u,e[20]=N):N=e[20],N};function Us(s){return s!==""}function Qs(s){return!s}const Ys=Te(pe.describeTable),Xs=Te(pe.readTablePage),Zs=Te(pe.importShard),el=s=>{const e=s._id??s.id??s.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},tl=s=>{const e=Object.values(s.inserted).reduce((i,a)=>i+a,0),[n]=s.errors;if(n===void 0)return{conflicts:s.conflicts,error:void 0,inserted:e};const o=s.errors.length-1,t=e+s.conflicts+s.errors.length,c=o===1?"error":"errors",l=o>0?` (+${o.toString()} more ${c})`:"",r=`Inserted ${e.toString()} of ${t.toString()} rows — row ${n.line.toString()} (${n.table}): ${n.message}${l}`;return{conflicts:s.conflicts,error:r,inserted:e}},nl=s=>{const e=ct(),[n,o]=$(!1),[t,c]=$(void 0),[l,r]=$(void 0),[i,a]=$(void 0),[f,m]=$({}),[p,b]=$(!1),[u,g]=$(void 0),h=async(x,S)=>{o(!0),c(x),r(S),a(void 0),m({}),g(void 0),b(!0);try{const E=await e.query(Ys,{table:x},ke(S)),{columns:C}=E;a(C);const N={},k=C.filter(M=>M.ref!==void 0&&M.type==="id"&&M.pk!==!0);for(const M of k){if(M.ref===void 0)continue;const{ref:R}=M;if(N[R]===void 0)try{const _=await e.query(Xs,{filters:[],limit:vs,offset:0,search:"",table:R},ke(S));N[R]=_.rows.flatMap(D=>el(D)||[])}catch{N[R]=[]}}m(N)}catch(E){g(E.message)}b(!1)};return{closeDialog:()=>{o(!1),c(void 0),r(void 0),a(void 0),m({}),g(void 0)},columnMeta:i,error:u,fkPools:f,insertBatch:async(x,S)=>{if(t===void 0||l===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{const E=await e.query(Zs,{rows:x.map(N=>({doc:N,table:t}))},ke(l)),C=tl(E);return C.error!==void 0||(S(),s()),C}catch(E){return{conflicts:0,error:E.message,inserted:0}}},loading:p,open:n,openDialog:(x,S)=>{Ce(h(x,S))},shardKey:l,table:t}},ol=()=>{const s=B(6),[e,n]=$(null);let o;s[0]===Symbol.for("react.memo_cache_sentinel")?(o=()=>{n(null)},s[0]=o):o=s[0];const t=o,[c,l]=$(null);let r;s[1]===Symbol.for("react.memo_cache_sentinel")?(r=(p,b)=>{l({column:p,value:b})},s[1]=r):r=s[1];const i=r;let a;s[2]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{l(null)},s[2]=a):a=s[2];const f=a;let m;return s[3]!==c||s[4]!==e?(m={closeExpandedCell:f,closeInspect:t,expandedCell:c,inspecting:e,onExpandCell:i,onInspect:n},s[3]=c,s[4]=e,s[5]=m):m=s[5],m},sl=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,ll=(s,e)=>typeof e=="number"&&sl.test(s),rl=s=>{const e=B(31),{column:n,masked:o,onNavigate:t,target:c,value:l}=s;let r;e[0]!==t||e[1]!==c||e[2]!==l?(r=()=>{c!==void 0&&t(c,String(l))},e[0]=t,e[1]=c,e[2]=l,e[3]=r):r=e[3];const i=r;if(l==null){let m;return e[4]===Symbol.for("react.memo_cache_sentinel")?(m=d("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=m):m=e[4],m}if(o){const m=`rd-masked-${n}`;let p;e[5]!==l?(p=ze(l),e[5]=l,e[6]=p):p=e[6];let b;return e[7]!==m||e[8]!==p?(b=d("span",{className:"italic text-muted-foreground","data-testid":m,title:"Masked (preview)",children:p}),e[7]=m,e[8]=p,e[9]=b):b=e[9],b}if(c!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){const m=`rd-ref-${n}`,p=`Open ${c} ${String(l)}`,b=String(l);let u;return e[10]!==i||e[11]!==m||e[12]!==p||e[13]!==b?(u=T("button",{"data-testid":m,onClick:i,title:p,type:"button",children:[b," ↗"]}),e[10]=i,e[11]=m,e[12]=p,e[13]=b,e[14]=u):u=e[14],u}if(ll(n,l)){const m=`rd-ts-${n}`;let p;e[15]!==l?(p=l.toString(),e[15]=l,e[16]=p):p=e[16];let b;e[17]!==l?(b=Pn(l),e[17]=l,e[18]=b):b=e[18];let u;return e[19]!==m||e[20]!==p||e[21]!==b?(u=d("span",{"data-testid":m,title:p,children:b}),e[19]=m,e[20]=p,e[21]=b,e[22]=u):u=e[22],u}if(typeof l=="object"){let m;e[23]!==l?(m=JSON.stringify(l,null,2),e[23]=l,e[24]=m):m=e[24];let p;return e[25]!==m?(p=d("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:m}),e[25]=m,e[26]=p):p=e[26],p}let a;e[27]!==l?(a=ze(l),e[27]=l,e[28]=a):a=e[28];let f;return e[29]!==a?(f=d("span",{children:a}),e[29]=a,e[30]=f):f=e[30],f},al=s=>{const e=B(23),{columns:n,mask:o,onClose:t,onNavigate:c,refs:l,row:r}=s;let i;e[0]!==t||e[1]!==c?(i=(g,h)=>{c(g,h),t()},e[0]=t,e[1]=c,e[2]=i):i=e[2];const a=i;let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=d("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=f):f=e[3];let m;e[4]!==t?(m=T("div",{className:"mb-3 flex items-center justify-between",children:[f,d("button",{"data-testid":"rd-close",onClick:t,type:"button",children:"Close"})]}),e[4]=t,e[5]=m):m=e[5];let p;if(e[6]!==n||e[7]!==o||e[8]!==a||e[9]!==l||e[10]!==r){let g;e[12]!==o||e[13]!==a||e[14]!==l||e[15]!==r?(g=h=>T("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${h}`,children:[d("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:h}),d("dd",{className:"m-0",children:d(rl,{column:h,masked:o.enabled&&o.columns.has(h),onNavigate:a,target:l?.[h],value:r[h]})})]},h),e[12]=o,e[13]=a,e[14]=l,e[15]=r,e[16]=g):g=e[16],p=n.map(g),e[6]=n,e[7]=o,e[8]=a,e[9]=l,e[10]=r,e[11]=p}else p=e[11];let b;e[17]!==p?(b=d("dl",{"data-testid":"rd-fields",children:p}),e[17]=p,e[18]=b):b=e[18];let u;return e[19]!==t||e[20]!==m||e[21]!==b?(u=T(dt,{label:"Row detail",onClose:t,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[m,b]}),e[19]=t,e[20]=m,e[21]=b,e[22]=u):u=e[22],u},il=50,cl=s=>{const e=B(8),{active:n,onPick:o,shard:t}=s;let c;e[0]!==o||e[1]!==t?(c=()=>{o(t)},e[0]=o,e[1]=t,e[2]=c):c=e[2];const l=c,r=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,i=`shard-explorer-item-${t}`;let a;return e[3]!==l||e[4]!==t||e[5]!==r||e[6]!==i?(a=d("button",{className:r,"data-testid":i,onClick:l,type:"button",children:t}),e[3]=l,e[4]=t,e[5]=r,e[6]=i,e[7]=a):a=e[7],a},dl=({onFetchTables:s,onSelect:e})=>{const n=he(),[o]=$(()=>oo()),[t,c]=$(!1),[l,r]=$(void 0),[i,a]=$(void 0),[f,m]=$(!1),[p,b]=$(void 0),u=Je(0),g=()=>{c(v=>!v)},h=async v=>{e(v),r(v),a(void 0),b(void 0),m(!0),u.current+=1;const y=u.current;try{const x=await s(v);u.current===y&&a(x?.slice(0,il))}catch(x){u.current===y&&b(x.message)}u.current===y&&m(!1)},w=v=>{Ce(h(v))};return o.length===0?null:T("div",{"data-testid":"shard-explorer",children:[T("button",{"aria-controls":"shard-explorer-panel","aria-expanded":t,className:"inline-flex items-center gap-1 rounded-md border border-border px-2 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"shard-explorer-toggle",onClick:g,type:"button",children:[n("Shards seen"),d("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${t?"rotate-180":""}`,children:"▾"})]}),t&&T("div",{className:"mt-1 flex flex-col gap-1 rounded-md border border-border bg-popover p-2","data-testid":"shard-explorer-panel",id:"shard-explorer-panel",children:[d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards — click to switch")}),d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(v=>d("li",{children:d(cl,{active:l===v,onPick:w,shard:v})},v))}),l!==void 0&&T("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[d("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:l})}),f&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading…")}),p!==void 0&&d("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:p}),!f&&p===void 0&&i?.length===0&&d("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!f&&p===void 0&&i!==void 0&&i.length>0&&d("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:i.map(v=>T("li",{className:"flex items-center justify-between text-xs",children:[d("span",{"data-testid":`shard-explorer-table-${v.name}`,children:v.name}),d("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${v.name}`,children:v.rowCount})]},v.name))})]})]})]})},ul="lunora-studio-back-relations",fl=s=>new Set((s??[]).filter(e=>e.unique===!0&&e.fields.length===1).map(e=>e.fields[0]??"")),ml={},gl=50,pl=[],bl=Te(pe.listTables),hl=Te(pe.readTablePage),xl=s=>{const e=B(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:t,shardKey:c}=s;let l;e[0]!==o||e[1]!==c?(l=d(Dn,{onChange:o,testId:"db-shard-input",value:c}),e[0]=o,e[1]=c,e[2]=l):l=e[2];let r;e[3]!==n||e[4]!==o?(r=d(dl,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=r):r=e[5];let i;return e[6]!==t||e[7]!==l||e[8]!==r?(i=T("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[t,l,r]}),e[6]=t,e[7]=l,e[8]=r,e[9]=i):i=e[9],i},Ul=({editable:s=!1,globalTableNames:e,initialFilters:n,initialOrderBy:o,initialPins:t,initialSearch:c,initialShardKey:l,onNavigateToGlobal:r,onSelectTable:i,onViewChange:a,pageSize:f=gl,queryBar:m,schemaSwitch:p,tableParam:b})=>{const u=Xe(pe.describeTables,{},{shardKey:l??""}),g=Xe(pe.listTablesIndexes,{},{shardKey:l??""}),h=u.data?.columnsByTable??ml,[w,v]=Wt(ul,{}),y=at(L=>{const se=new Set(w[L]);return Ft(L,h).filter(Ee=>se.has($t(Ee)))},[w,h]),x=Js({initialFilters:n,initialOrderBy:o,initialSearch:c,initialShardKey:l,onSelectTable:i,onViewChange:a,pageSize:f,resolveBackRelations:y,tableParam:b}),{cancelCellEdit:S,columns:E,currentView:C,editableColumn:N,editingCell:k,facetFilter:M,facets:R,loadTables:_,navigateToRef:D,onFiltersChange:I,page:F,pageError:A,previewRef:z,queryShardKey:j,selectedTable:O,selectTable:V,setShardKey:J,shardKey:q,stage:X,stagedValue:Q,startCellEdit:Z,tables:fe,tablesError:ne,toggleFacet:ce}=x,de=Bn(q),me=L=>{Ce((async()=>{const Ee=await de.suggestFilter(L,O??"");Ee!==void 0&&I(Ee.map(Re=>{const Fe=Re.value,xt=typeof Fe=="string"||typeof Fe=="number"||typeof Fe=="boolean"?String(Fe):"";return{column:Re.column,operator:Re.operator,value:xt}}))})())},le=O===null?[]:Ft(O,h),ue=new Set(w[O??""]),re=[];for(const L of F?.rows??[]){const se=L._id??L.id;typeof se=="string"&&se!==""&&re.push(se)}const Y=Ts(ue,le,re,j),be=L=>{v(se=>{const Ee=O??"",Re=se[Ee]??[];return{...se,[Ee]:Re.includes(L)?Re.filter(Fe=>Fe!==L):[...Re,L]}})},te=Hs({columns:E,initialPins:t,selectedTable:O}),xe=ol(),[ae,ie]=$(null),{closeExpandedCell:W,closeInspect:K,expandedCell:ee,inspecting:H,onExpandCell:ve}=xe,ge=ct(),we=Object.fromEntries((h[O??""]??[]).map(L=>[L.name,L])),ye=new Map;for(const L of h[O??""]??[])L.isStorage===!0&&ye.set(L.name,L.bucket);const U=at(async(L,se)=>ge.signedStorageUrl(L,se===void 0?{}:{bucket:se}),[ge]),oe=async L=>await ge.query(bl,{},ke(L)),Me=()=>{O!==null&&V(O)},{closeDialog:Pe,columnMeta:Ae,fkPools:He,insertBatch:Se,open:je,openDialog:Oe}=nl(Me),Ue=()=>{O!==null&&Oe(O,q)},ut=L=>Se(L,Pe),[ft,et]=$(!1),tt=()=>{et(!0)},Qe=()=>{et(!1)},nt=(L,se)=>{if(r!==void 0&&e?.has(L)===!0){r(L,se);return}D(L,se)},mt=m?.onSaveQuery,gt=L=>{mt?.(L,C)},pt={cancelEdit:S,editable:s,editableColumn:N,editingCell:k,onExpandCell:ve,stage:X,stagedValue:Q,startEdit:Z},bt=L=>{L!==null&&ie(L)},ot=()=>{x.onRowDelete(ae)},Ye=async(L,se,Ee)=>await ge.query(hl,{filters:[{column:se,operator:"eq",value:Ee}],limit:lt,offset:0,orderBy:[],table:L},ke(j)),ht={columns:F?.refs,maskViewFor:te.maskViewFor,onNavigate:nt,onPreview:z};return T("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[d(Ln,{header:d(xl,{onFetchShardTables:oe,onShardChange:J,schemaSwitch:p,shardKey:q}),onReload:_,onSelect:V,prefix:"db",selected:O,tables:fe??pl}),T("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[ne!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:ne}),F===null&&A===null&&d("div",{className:"flex flex-1 items-center justify-center p-6",children:d("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),A!==null&&d("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:A}),F!==null&&d(hs,{assistant:de,backRelations:{available:le,counts:Y,enabled:ue,onToggle:be},browser:x,columnMeta:we,edit:pt,editable:s,onAskAiFilter:me,onInspect:xe.onInspect,onOpenBulkPatch:tt,onOpenGenerateRows:Ue,onRowDelete:bt,onSaveQuery:gt,page:F,preferences:te,queryBar:m,references:ht})]}),F!==null&&d(Vn,{columns:E,facets:R,mask:te.maskView,onFacetFilter:M,onToggleFacet:ce}),H!==null&&F!==null&&d(al,{columns:F.columns,mask:te.maskView,onClose:K,onNavigate:nt,refs:F.refs,row:Ht(H,te.maskView)}),ae!==null&&O!==null&&d(ho,{onClose:()=>{ie(null)},onConfirm:ot,readPage:Ye,rowId:ae,schema:so(h),table:O}),ee!==null&&d(to,{bucket:ye.get(ee.column),column:ee.column,onClose:W,resolveUrl:ye.has(ee.column)?U:void 0,value:ee.value}),ft&&O!==null&&d(ao,{columns:x.columns.filter(L=>x.editableColumn(L)),onApply:x.bulkPatch,onClose:Qe,shardKey:x.queryShardKey,table:O,total:x.total,uniqueColumns:fl(g.data?.indexesByTable[O])}),je&&O!==null&&Ae!==void 0&&d(Ss,{columns:Ae,fkPools:He,onClose:Pe,onInsertRows:ut,table:O})]})};export{Ul as DataBrowser};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const a=(t,n,r,o,i)=>{switch(n){case"action":return t.action(r,o,i);case"mutation":return t.mutation(r,o,i);default:return t.query(r,o,i)}},f=t=>({__lunoraRef:t}),u=t=>{const n=t.trim();return n===""?{}:{shardKey:n}},d=t=>t instanceof Error?t.message:String(t),l=t=>{if(t===null||typeof t!="object"||!("code"in t))return;const{code:n}=t;return typeof n=="string"?n:void 0},g=t=>{if(t===null||typeof t!="object"||!("hint"in t))return;const{hint:n}=t;return typeof n=="string"?n:Array.isArray(n)?n.filter(r=>typeof r=="string").join(`
|
|
2
|
-
`):void 0},y=t=>{if(t===null||typeof t!="object"||!("docsUrl"in t))return;const n=t.docsUrl;if(typeof n=="string")try{const{protocol:r}=new URL(n);return r==="http:"||r==="https:"?n:void 0}catch{return}},s=t=>{if(t==null)return"—";if(t<1024)return`${t.toString()} B`;const n=["KB","MB","GB","TB"];let r=t/1024,o=0;for(;r>=1024&&o<n.length-1;)r/=1024,o+=1;return`${r.toFixed(1)} ${n[o]??"TB"}`},e=t=>{if(t==null)return"";switch(typeof t){case"bigint":case"boolean":case"number":return t.toString();case"string":return t;case"symbol":return t.toString();default:return t instanceof ArrayBuffer||ArrayBuffer.isView(t)?`<bytes: ${s(t.byteLength)}>`:JSON.stringify(t)}},h=(t,n)=>typeof n=="bigint"||n instanceof ArrayBuffer||ArrayBuffer.isView(n)?e(n):n,c=(t,n)=>{t.catch(r=>{n?.(r)})},m=t=>{if(t!==void 0&&t!=="")return t;const n=globalThis.location;return n?.origin!==void 0&&n.origin!==""?n.origin:"http://localhost:5173"},p=t=>{const n="navigator"in globalThis?globalThis.navigator.clipboard:void 0;return n===void 0?!1:(c(n.writeText(t)),!0)},b=(t,n="")=>{if(t==null||t==="")return n;const r=new Date(t);return Number.isNaN(r.getTime())?String(t):r.toLocaleString()};export{y as a,d as b,f as c,u as d,g as e,c as f,p as g,e as h,b as i,h as j,a as k,s as l,l as m,m as r};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const t=e=>`"${e.replaceAll('"','""')}"`;export{t as q};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{c as C}from"react/compiler-runtime";import{useT as E}from"./DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsxs as k,jsx as x}from"react/jsx-runtime";import{useRef as A,useEffect as W,useState as I,useMemo as q}from"react";import{f as L,b as H}from"./internal-D4gBuklE.mjs";import{u as Q}from"./use-admin-query-BvZH4unR.mjs";import{ADMIN_FUNCTIONS as K}from"./ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{useVirtualizer as Y}from"@tanstack/react-virtual";import{c as Z}from"./utils-bhneXptQ.mjs";import{f as X}from"./virtual-rect-D_j7aLxX.mjs";const ee=2166136261,te=16777619,j=(n,e=ee)=>{let t=e;for(let s=0;s<n.length;s+=1)t^=n.codePointAt(s)??0,t=Math.imul(t,te);return(t>>>0).toString(16).padStart(8,"0")},se=/([a-z\d])([A-Z])/gu,ne=/[\s_-]+/u,re=new Set(["access_token","api_key","apikey","card_number","client_secret","credit_card","cvv","passwd","password","private_key","pwd","refresh_token","secret","ssn","token"]),oe=n=>{const e=n.replaceAll(se,"$1 $2").split(ne).map(s=>s.toLowerCase()).filter(s=>s.length>0),t=new Set(e);for(let s=0;s<e.length-1;s+=1){const r=e[s],m=e[s+1];r===void 0||m===void 0||(t.add(`${r}${m}`),t.add(`${r}_${m}`))}return[...t]},P="•••",G=(n,e)=>{try{return e==="redact"?null:e==="hash"?n==null?n:j(typeof n=="bigint"?n.toString():typeof n=="string"?n:JSON.stringify(n)):P}catch{return P}},V=(n,e)=>{const t=new Map;for(const s of n)s.table===e&&t.set(s.column,s.strategy);return t},ae=n=>{for(const e of oe(n))if(re.has(e))return!0;return!1},B=(n,e)=>{const t=e.filter(r=>!n.has(r)&&ae(r));if(t.length===0)return n;const s=new Map(n);for(const r of t)s.set(r,"redact");return s},_e=(n,e,t)=>{if(!t.enabled)return n;const s=t.columns.get(e);return s===void 0?n:G(n,s)},le=(n,e)=>{if(!e.enabled||e.columns.size===0)return n;const t={...n};for(const[s,r]of e.columns)s in t&&(t[s]=G(t[s],r));return t},Fe=(n,e)=>!e.enabled||e.columns.size===0?n:n.map(t=>le(t,e)),ce=[25,50,100,250],ie=n=>{const e=C(18),{onChange:t,options:s,prefix:r,value:m}=n,u=E();let g;e[0]!==t?(g=p=>{t(Number.parseInt(p.target.value,10))},e[0]=t,e[1]=g):g=e[1];const o=g,f=`${r}-page-size`;let l;e[2]!==u?(l=u("Rows per page"),e[2]=u,e[3]=l):l=e[3];let a;e[4]!==l?(a=x("span",{children:l}),e[4]=l,e[5]=a):a=e[5];const c=`${r}-page-size`,d=`${r}-page-size`;let b;e[6]!==s?(b=s.map(ue),e[6]=s,e[7]=b):b=e[7];let h;e[8]!==o||e[9]!==c||e[10]!==d||e[11]!==b||e[12]!==m?(h=x("select",{className:"h-6 rounded-md border border-border bg-background px-1 tabular-nums outline-none focus-visible:border-ring","data-testid":c,id:d,onChange:o,value:m,children:b}),e[8]=o,e[9]=c,e[10]=d,e[11]=b,e[12]=m,e[13]=h):h=e[13];let i;return e[14]!==f||e[15]!==a||e[16]!==h?(i=k("label",{className:"flex items-center gap-1.5",htmlFor:f,children:[a,h]}),e[14]=f,e[15]=a,e[16]=h,e[17]=i):i=e[17],i},de=n=>{const e=C(25),{onJump:t,page:s,pages:r,prefix:m}=n,u=E();let g;e[0]!==t||e[1]!==r?(g=v=>{const S=Number.parseInt(v,10);Number.isNaN(S)||t(Math.min(Math.max(1,S),Math.max(1,r)))},e[0]=t,e[1]=r,e[2]=g):g=e[2];const o=g;let f;e[3]!==o?(f=v=>{v.key==="Enter"&&o(v.currentTarget.value)},e[3]=o,e[4]=f):f=e[4];const l=f;let a;e[5]!==o?(a=v=>{o(v.currentTarget.value)},e[5]=o,e[6]=a):a=e[6];const c=a;let d;e[7]!==u?(d=u("Page"),e[7]=u,e[8]=d):d=e[8];let b;e[9]!==u?(b=u("Page"),e[9]=u,e[10]=b):b=e[10];const h=`${m}-page-jump`,i=Math.max(1,r);let p;e[11]!==c||e[12]!==l||e[13]!==s||e[14]!==b||e[15]!==h||e[16]!==i?(p=x("input",{"aria-label":b,className:"h-6 w-12 rounded-md border border-border bg-background px-1 text-center tabular-nums outline-none focus-visible:border-ring","data-testid":h,defaultValue:s,max:i,min:1,onBlur:c,onKeyDown:l,type:"number"},s),e[11]=c,e[12]=l,e[13]=s,e[14]=b,e[15]=h,e[16]=i,e[17]=p):p=e[17];let N;e[18]!==r||e[19]!==u?(N=u("of {pages}",{pages:r}),e[18]=r,e[19]=u,e[20]=N):N=e[20];let y;return e[21]!==d||e[22]!==p||e[23]!==N?(y=k("span",{className:"flex items-center gap-1.5 tabular-nums",children:[d,p,N]}),e[21]=d,e[22]=p,e[23]=N,e[24]=y):y=e[24],y},Te=({hasNext:n,hasPrevious:e,onJumpToPage:t,onNext:s,onPageSizeChange:r,onPrevious:m,pageSize:u,pageSizeOptions:g=ce,prefix:o,rangeEnd:f,rangeStart:l,total:a})=>{const c=E(),d="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",b=u!==void 0&&u>0?Math.max(1,Math.ceil(a/u)):1,h=u!==void 0&&u>0?Math.floor(Math.max(0,l-1)/u)+1:1;return k("div",{className:"flex w-full items-center justify-between gap-3 text-xs text-muted-foreground",children:[k("div",{className:"flex items-center gap-3",children:[u!==void 0&&r!==void 0&&x(ie,{onChange:r,options:g,prefix:o,value:u}),x("span",{className:"tabular-nums","data-testid":`${o}-page-info`,children:c("{rangeStart}-{rangeEnd} of {total}",{rangeEnd:f,rangeStart:l,total:a})})]}),k("div",{className:"flex items-center gap-3",children:[x("button",{className:d,"data-testid":`${o}-prev`,disabled:!e,onClick:m,type:"button",children:c("Previous")}),u!==void 0&&t!==void 0&&x(de,{onJump:t,page:h,pages:b,prefix:o}),x("button",{className:d,"data-testid":`${o}-next`,disabled:!n,onClick:s,type:"button",children:c("Next")})]})]})};function ue(n){return x("option",{value:n,children:n},n)}const D=n=>n==null?"∅":n===""?"(empty)":typeof n=="object"?JSON.stringify(n):String(n),fe=n=>{const e=C(32),{column:t,onFacetFilter:s,state:r}=n,m=E();let u;e[0]!==t||e[1]!==s||e[2]!==r.result?.values?(u=i=>{const p=Number(i.currentTarget.dataset.index),N=r.result?.values[p];N!==void 0&&s(t,N.value)},e[0]=t,e[1]=s,e[2]=r.result?.values,e[3]=u):u=e[3];const g=u,o=`db-facet-${t}`;let f;e[4]!==t?(f=x("span",{className:"font-medium text-foreground",children:t}),e[4]=t,e[5]=f):f=e[5];let l;e[6]!==r.loading||e[7]!==r.result||e[8]!==m?(l=r.loading&&r.result===null&&x("span",{className:"text-muted-foreground",children:m("Loading…")}),e[6]=r.loading,e[7]=r.result,e[8]=m,e[9]=l):l=e[9];let a;e[10]!==r.error?(a=r.error!==null&&x("span",{className:"text-destructive",role:"alert",children:r.error}),e[10]=r.error,e[11]=a):a=e[11];let c;e[12]!==r.result?.values?(c=r.result?.values??[],e[12]=r.result?.values,e[13]=c):c=e[13];let d;if(e[14]!==t||e[15]!==g||e[16]!==c){let i;e[18]!==t||e[19]!==g?(i=(p,N)=>k("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":N,"data-testid":`db-facet-value-${t}`,onClick:g,type:"button",children:[x("span",{className:"truncate",children:D(p.value)}),x("span",{className:"shrink-0 tabular-nums text-foreground/70",children:p.count})]},D(p.value)),e[18]=t,e[19]=g,e[20]=i):i=e[20],d=c.map(i),e[14]=t,e[15]=g,e[16]=c,e[17]=d}else d=e[17];let b;e[21]!==t||e[22]!==r.result||e[23]!==m?(b=r.result?.truncated===!0&&x("span",{className:"text-muted-foreground","data-testid":`db-facet-truncated-${t}`,children:m("Showing the {n} most common values.",{n:r.result.values.length})}),e[21]=t,e[22]=r.result,e[23]=m,e[24]=b):b=e[24];let h;return e[25]!==o||e[26]!==f||e[27]!==l||e[28]!==a||e[29]!==d||e[30]!==b?(h=k("section",{className:"flex flex-col gap-1","data-testid":o,children:[f,l,a,d,b]}),e[25]=o,e[26]=f,e[27]=l,e[28]=a,e[29]=d,e[30]=b,e[31]=h):h=e[31],h},Ee=n=>{const e=C(44),{columns:t,facets:s,mask:r,onFacetFilter:m,onToggleFacet:u}=n,g=E();let o;e[0]!==u?(o=w=>{const{column:M}=w.currentTarget.dataset;M!==void 0&&u(M)},e[0]=u,e[1]=o):o=e[1];const f=o;let l;e[2]!==r?(l=w=>r.enabled&&r.columns.has(w),e[2]=r,e[3]=l):l=e[3];const a=l;let c,d,b,h,i,p,N,y;if(e[4]!==t||e[5]!==s||e[6]!==a||e[7]!==g||e[8]!==f){y=Symbol.for("react.early_return_sentinel");e:{let w;e[17]!==a?(w=$=>!a($),e[17]=a,e[18]=w):w=e[18];const M=t.filter(w);let F;if(e[19]!==s||e[20]!==a?(F=Object.entries(s).filter($=>{const[J]=$;return!a(J)}),e[19]=s,e[20]=a,e[21]=F):F=e[21],c=F,M.length===0){y=null;break e}p="flex w-56 shrink-0 flex-col gap-3 overflow-auto border-l border-border p-3 text-xs",N="db-facets",h="flex flex-col gap-1.5";let T;e[22]!==g?(T=g("Facets"),e[22]=g,e[23]=T):T=e[23],e[24]!==T?(i=x("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:T}),e[24]=T,e[25]=i):i=e[25],d="flex flex-wrap gap-1";let R;e[26]!==s||e[27]!==f?(R=$=>x("button",{"aria-pressed":$ in s,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":$,"data-testid":`db-facet-toggle-${$}`,onClick:f,type:"button",children:$},$),e[26]=s,e[27]=f,e[28]=R):R=e[28],b=M.map(R)}e[4]=t,e[5]=s,e[6]=a,e[7]=g,e[8]=f,e[9]=c,e[10]=d,e[11]=b,e[12]=h,e[13]=i,e[14]=p,e[15]=N,e[16]=y}else c=e[9],d=e[10],b=e[11],h=e[12],i=e[13],p=e[14],N=e[15],y=e[16];if(y!==Symbol.for("react.early_return_sentinel"))return y;let v;e[29]!==d||e[30]!==b?(v=x("div",{className:d,children:b}),e[29]=d,e[30]=b,e[31]=v):v=e[31];let S;e[32]!==v||e[33]!==h||e[34]!==i?(S=k("div",{className:h,children:[i,v]}),e[32]=v,e[33]=h,e[34]=i,e[35]=S):S=e[35];let _;e[36]!==m||e[37]!==c?(_=c.map(w=>{const[M,F]=w;return x(fe,{column:M,onFacetFilter:m,state:F},M)}),e[36]=m,e[37]=c,e[38]=_):_=e[38];let O;return e[39]!==S||e[40]!==_||e[41]!==p||e[42]!==N?(O=k("aside",{className:p,"data-testid":N,children:[S,_]}),e[39]=S,e[40]=_,e[41]=p,e[42]=N,e[43]=O):O=e[43],O};function me(n){const e=C(2),t=A(n);let s;return e[0]!==n?(s=()=>{t.current=n},e[0]=n,e[1]=s):s=e[1],W(s),t}const Oe=()=>{const[n,e]=I({}),t=me(n),s=A({}),r=async(o,f)=>{const l=(s.current[o]??0)+1;s.current[o]=l,e(a=>o in a?{...a,[o]:{error:null,loading:!0,result:a[o]?.result??null}}:a);try{const a=await f(o);if(s.current[o]!==l)return;e(c=>o in c?{...c,[o]:{error:null,loading:!1,result:a}}:c)}catch(a){if(s.current[o]!==l)return;e(c=>o in c?{...c,[o]:{error:H(a),loading:!1,result:null}}:c)}};return{clearFacets:()=>{e({})},facets:n,facetsRef:t,refetchFacets:o=>{for(const f of Object.keys(t.current))L(r(f,o))},toggleFacet:(o,f)=>{if(o in t.current){e(l=>Object.fromEntries(Object.entries(l).filter(([a])=>a!==o)));return}e(l=>({...l,[o]:{error:null,loading:!0,result:null}})),f!==null&&L(r(o,f))}}},be=[],ge=()=>{const n=C(1);let e;n[0]===Symbol.for("react.memo_cache_sentinel")?(e={},n[0]=e):e=n[0];const{data:t}=Q(K.maskPolicies,e);return Array.isArray(t?.columns)?t.columns:be},Re=n=>{const e=C(16),{columns:t,selectedTable:s}=n,r=ge(),[m,u]=I(!0);let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=()=>{u(he)},e[0]=g):g=e[0];const o=g;let f;if(e[1]!==t||e[2]!==r||e[3]!==s){const h=V(r,s??"");f=B(h,t),e[1]=t,e[2]=r,e[3]=s,e[4]=f}else f=e[4];const l=f;let a;e[5]!==m||e[6]!==r?(a=(h,i)=>({columns:B(V(r,h),i),enabled:m}),e[5]=m,e[6]=r,e[7]=a):a=e[7];const c=a;let d;e[8]!==l||e[9]!==m?(d={columns:l,enabled:m},e[8]=l,e[9]=m,e[10]=d):d=e[10];let b;return e[11]!==l||e[12]!==m||e[13]!==c||e[14]!==d?(b={maskColumns:l,maskOn:m,maskView:d,maskViewFor:c,onToggleMask:o},e[11]=l,e[12]=m,e[13]=c,e[14]=d,e[15]=b):b=e[15],b};function he(n){return!n}const z=34,U=600,pe=n=>{const e=C(21),{item:t,onSelect:s,prefix:r,selected:m,start:u}=n;let g;e[0]!==t.name||e[1]!==s?(g=()=>{s(t.name)},e[0]=t.name,e[1]=s,e[2]=g):g=e[2];const o=g,f=`translateY(${String(u)}px)`;let l;e[3]!==f?(l={insetInline:0,position:"absolute",top:0,transform:f},e[3]=f,e[4]=l):l=e[4];const a=l,c=m?"bg-accent font-medium text-accent-foreground":"text-foreground";let d;e[5]!==c?(d=Z("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",c),e[5]=c,e[6]=d):d=e[6];const b=`${r}-table-${t.name}`;let h;e[7]!==t.name?(h=x("span",{className:"truncate",children:t.name}),e[7]=t.name,e[8]=h):h=e[8];let i;e[9]!==t.rowCount?(i=x("span",{className:"shrink-0 rounded bg-muted px-1.5 text-xs tabular-nums text-muted-foreground",children:t.rowCount}),e[9]=t.rowCount,e[10]=i):i=e[10];let p;e[11]!==o||e[12]!==m||e[13]!==d||e[14]!==b||e[15]!==h||e[16]!==i?(p=k("button",{"aria-pressed":m,className:d,"data-testid":b,onClick:o,type:"button",children:[h,i]}),e[11]=o,e[12]=m,e[13]=d,e[14]=b,e[15]=h,e[16]=i,e[17]=p):p=e[17];let N;return e[18]!==a||e[19]!==p?(N=x("li",{style:a,children:p}),e[18]=a,e[19]=p,e[20]=N):N=e[20],N},Ae=({header:n,onReload:e,onSelect:t,prefix:s,reloadLabel:r,selected:m,tables:u})=>{const g=E(),[o,f]=I(""),l=A(null),a=i=>{f(i.target.value)},c=q(()=>{const i=o.trim().toLowerCase();return i===""?u:u.filter(p=>p.name.toLowerCase().includes(i))},[o,u]),b=Y({count:c.length,estimateSize:()=>z,getScrollElement:()=>l.current,initialRect:{height:U,width:240},observeElementRect:(i,p)=>X(i,p,U),overscan:12}).getVirtualItems(),h={height:c.length*z};return k("aside",{className:"flex h-full w-60 shrink-0 flex-col border-e border-border bg-sidebar","data-testid":`${s}-table-list`,children:[n,k("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border px-3",children:[x("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:g("Tables")}),e!==void 0&&x("button",{"aria-label":r??g("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":`${s}-load-tables`,onClick:e,title:r??g("Refresh"),type:"button",children:x("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:x("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"})})})]}),x("div",{className:"shrink-0 border-b border-border p-2",children:x("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":`${s}-table-search`,onChange:a,placeholder:g("search table…"),type:"search",value:o})}),k("ul",{className:"relative flex-1 overflow-y-auto p-1.5","data-testid":`${s}-table-list-rows`,ref:l,children:[x("li",{"aria-hidden":"true",style:h}),b.map(i=>{const p=c[i.index];return p===void 0?null:x(pe,{item:p,onSelect:t,prefix:s,selected:m===p.name,start:i.start},p.name)})]})]})};export{Ee as D,Te as G,Ae as T,Oe as a,Re as b,le as c,Fe as d,_e as m,me as u};
|