@lunora/studio 1.0.0-alpha.102 → 1.0.0-alpha.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/dist/standalone/{chunk-GSQDZMV5.js → chunk-2POO335F.js} +1 -1
  2. package/dist/standalone/{chunk-6C6FRIYD.js → chunk-3JJIZ5GZ.js} +1 -1
  3. package/dist/standalone/{chunk-YZ7OINPX.js → chunk-44W6IDID.js} +1 -1
  4. package/dist/standalone/{chunk-ZNNKWEH5.js → chunk-56Q3NCCQ.js} +1 -1
  5. package/dist/standalone/{chunk-U62QRT34.js → chunk-5BKFMQKO.js} +1 -1
  6. package/dist/standalone/{chunk-ORNIQZ2P.js → chunk-5VYZCZNH.js} +1 -1
  7. package/dist/standalone/{chunk-ELI5HREQ.js → chunk-6VTX32BC.js} +1 -1
  8. package/dist/standalone/{chunk-4PDTGZDC.js → chunk-6ZVSFYWY.js} +2 -2
  9. package/dist/standalone/{chunk-3RC2X4I2.js → chunk-76XT6OKR.js} +1 -1
  10. package/dist/standalone/{chunk-BB7WLC24.js → chunk-AAU2LQP2.js} +1 -1
  11. package/dist/standalone/{chunk-A3DCTWSA.js → chunk-AB5HDI3T.js} +1 -1
  12. package/dist/standalone/{chunk-LPBWDHKM.js → chunk-AI5UNHBF.js} +1 -1
  13. package/dist/standalone/chunk-BR5GIQWK.js +15 -0
  14. package/dist/standalone/{chunk-NLHEYDAA.js → chunk-C2W6YSI7.js} +1 -1
  15. package/dist/standalone/{chunk-W3VOX7VR.js → chunk-DUFBHFX6.js} +1 -1
  16. package/dist/standalone/{chunk-5BEGIQM7.js → chunk-EAGPIRHK.js} +1 -1
  17. package/dist/standalone/{chunk-ELJZNBBJ.js → chunk-EP5VOTNC.js} +1 -1
  18. package/dist/standalone/{chunk-ZMDNTTAC.js → chunk-EVPGUJH7.js} +1 -1
  19. package/dist/standalone/{chunk-4KPBTODU.js → chunk-FGMDIASJ.js} +1 -1
  20. package/dist/standalone/{chunk-U4THUBUT.js → chunk-FSPXSK4F.js} +1 -1
  21. package/dist/standalone/{chunk-GRRBUXEI.js → chunk-GCIAXZBG.js} +1 -1
  22. package/dist/standalone/{chunk-MRK53LUL.js → chunk-GPXYZOOF.js} +1 -1
  23. package/dist/standalone/{chunk-NH4HJFG3.js → chunk-GY66QQZJ.js} +1 -1
  24. package/dist/standalone/{chunk-T6YGEL6X.js → chunk-ICUATQ6I.js} +1 -1
  25. package/dist/standalone/{chunk-DSDJ3QRD.js → chunk-ILQLRPP6.js} +1 -1
  26. package/dist/standalone/{chunk-TFSGDOCG.js → chunk-IN6NPKXV.js} +1 -1
  27. package/dist/standalone/{chunk-BCMLQ3LV.js → chunk-J6IUJLIJ.js} +1 -1
  28. package/dist/standalone/{chunk-6THGMZNI.js → chunk-K5463KGW.js} +1 -1
  29. package/dist/standalone/{chunk-WMBDXCYL.js → chunk-KHZFULUH.js} +1 -1
  30. package/dist/standalone/{chunk-RTXAZLAE.js → chunk-KMGVTPH2.js} +1 -1
  31. package/dist/standalone/{chunk-UP7OTXKF.js → chunk-KMT6UDR7.js} +1 -1
  32. package/dist/standalone/{chunk-W3XKLUWQ.js → chunk-L6ZL7C6I.js} +1 -1
  33. package/dist/standalone/{chunk-LKBKYLWK.js → chunk-LFOT3KUL.js} +1 -1
  34. package/dist/standalone/{chunk-UALL2OBT.js → chunk-LFYM72CD.js} +1 -1
  35. package/dist/standalone/{chunk-BIVP5DZB.js → chunk-LMZCWLYL.js} +1 -1
  36. package/dist/standalone/{chunk-5HMBKUFH.js → chunk-NLANS7IB.js} +1 -1
  37. package/dist/standalone/{chunk-IID7VT2A.js → chunk-NVY2U3IB.js} +1 -1
  38. package/dist/standalone/{chunk-4V4RO52I.js → chunk-OJDJMESX.js} +1 -1
  39. package/dist/standalone/{chunk-7AY2447G.js → chunk-OXGSORBK.js} +1 -1
  40. package/dist/standalone/{chunk-7MT6C3FS.js → chunk-P6U7JNSA.js} +1 -1
  41. package/dist/standalone/{chunk-RO6LEET3.js → chunk-Q5LK5ZBG.js} +1 -1
  42. package/dist/standalone/{chunk-QJW2Z3SI.js → chunk-QM4IZJHK.js} +1 -1
  43. package/dist/standalone/{chunk-OHOWUEQ3.js → chunk-RPGUPO5I.js} +1 -1
  44. package/dist/standalone/{chunk-35SAF2LS.js → chunk-TWF72RNA.js} +1 -1
  45. package/dist/standalone/{chunk-APBWFKW5.js → chunk-VA5RUELS.js} +1 -1
  46. package/dist/standalone/{chunk-22SUVVIR.js → chunk-WE4LGWB4.js} +1 -1
  47. package/dist/standalone/{chunk-DBAMCESO.js → chunk-WEOEKMJN.js} +1 -1
  48. package/dist/standalone/{chunk-EWGPDRH3.js → chunk-WNCBCYI4.js} +1 -1
  49. package/dist/standalone/{chunk-LYVP5PT6.js → chunk-WVU7GHTG.js} +3 -3
  50. package/dist/standalone/{chunk-TQEVFVNP.js → chunk-WVXS24SB.js} +1 -1
  51. package/dist/standalone/{chunk-IRXDBOOU.js → chunk-WWOB5XZT.js} +1 -1
  52. package/dist/standalone/{chunk-G6VZTEGG.js → chunk-WXALMQCU.js} +1 -1
  53. package/dist/standalone/{chunk-B5FMYLVA.js → chunk-X3W5GATZ.js} +1 -1
  54. package/dist/standalone/{chunk-NLWDTGEP.js → chunk-XOIXFWZS.js} +1 -1
  55. package/dist/standalone/{chunk-DC23USXJ.js → chunk-YPQISHBM.js} +1 -1
  56. package/dist/standalone/{chunk-6IZBFC3G.js → chunk-ZBVGZ4YA.js} +1 -1
  57. package/dist/standalone/{chunk-DY34ZZ5K.js → chunk-ZD3CL42S.js} +1 -1
  58. package/dist/standalone/{chunk-PCAI3G4M.js → chunk-ZKDSO2VL.js} +1 -1
  59. package/dist/standalone/{chunk-37PXYIVK.js → chunk-ZMNCF2DE.js} +1 -1
  60. package/dist/standalone/{chunk-7GNNMMT4.js → chunk-ZU6JSCBE.js} +1 -1
  61. package/dist/standalone/studio.js +1 -1
  62. package/package.json +6 -6
  63. package/dist/standalone/chunk-X7B6PLEW.js +0 -14
@@ -1 +1 @@
1
- import{a as W}from"./chunk-54MMVNPT.js";import{a as F}from"./chunk-3CWGJYBB.js";import{a as E}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as L}from"./chunk-6IZBFC3G.js";import"./chunk-XXQUMVWH.js";import"./chunk-ZNNKWEH5.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-VDW32UET.js";import{c as _}from"./chunk-UP7OTXKF.js";import"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as O,b as P,c as U,d as w,e as h,f as p}from"./chunk-WJQLNYGX.js";import{a as $,e as j}from"./chunk-WQH3LT2P.js";import{d as M}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as S,e as A,g as R,h as Z}from"./chunk-3XIESWL4.js";var B=A(R(),1);var t=A(Z(),1);var q=80,z=S(a=>{if(a===void 0)return"";let e=JSON.stringify(a);return e.length>q?`${e.slice(0,q)}\u2026`:e},"W"),G=S(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((l,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:l})})}return e},"B"),C=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),oe=S(a=>{let e=(0,B.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:l,setShardKey:i,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==l?(b={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=b):b=e[2];let{data:s,error:o,errorSource:u,refetch:J}=_(D.listSubscriptions,f,b);W(J,!0);let x;if(e[3]!==o||e[4]!==u||e[5]!==s||e[6]!==i||e[7]!==m||e[8]!==n){let k=s===void 0?[]:G(s.connections),c;e[10]!==i||e[11]!==m?(c=(0,t.jsx)(E,{onChange:i,testId:"subs-shard-input",value:m}),e[10]=i,e[11]=m,e[12]=c):c=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(y,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(y,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==c||e[17]!==d?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[16]=c,e[17]=d,e[18]=g):g=e[18];let v;e[19]!==o||e[20]!==u?(v=o!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=o,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,o===null&&s!==void 0&&k.length===0&&(0,t.jsx)(T,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),o===null&&k.length>0&&(0,t.jsx)($,{className:"overflow-hidden py-0",children:(0,t.jsx)(j,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(w,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(U,{children:k.map(N=>{let{subscription:I}=N,K=z(I?.args);return(0,t.jsxs)(w,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",N.connectionId,N.admin&&(0,t.jsx)(y,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??C}),(0,t.jsx)(p,{children:I?.table??C}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||C})]},N.key)})})]})})})]}),e[3]=o,e[4]=u,e[5]=s,e[6]=i,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"oe");export{oe as default};
1
+ import{a as W}from"./chunk-54MMVNPT.js";import{a as F}from"./chunk-3CWGJYBB.js";import{a as E}from"./chunk-RMN2JN4S.js";import"./chunk-GRL5MG3Z.js";import"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-7QIFDWQV.js";import"./chunk-2OUPA2WJ.js";import{b as y}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as L}from"./chunk-ZBVGZ4YA.js";import"./chunk-XXQUMVWH.js";import"./chunk-56Q3NCCQ.js";import"./chunk-QLQADHFE.js";import{a as D}from"./chunk-VDW32UET.js";import{c as _}from"./chunk-KMT6UDR7.js";import"./chunk-WVU7GHTG.js";import"./chunk-XBDKZZ67.js";import{a as T}from"./chunk-XQCVZAGU.js";import{a as O,b as P,c as U,d as w,e as h,f as p}from"./chunk-WJQLNYGX.js";import{a as $,e as j}from"./chunk-WQH3LT2P.js";import{d as M}from"./chunk-IUYFXK4X.js";import"./chunk-BR5GIQWK.js";import{a as S,e as A,g as R,h as Z}from"./chunk-3XIESWL4.js";var B=A(R(),1);var t=A(Z(),1);var q=80,z=S(a=>{if(a===void 0)return"";let e=JSON.stringify(a);return e.length>q?`${e.slice(0,q)}\u2026`:e},"W"),G=S(a=>{let e=[];for(let r of a){let n=r.id.toString();if(r.subscriptions.length===0){e.push({admin:r.admin,connectionId:r.id,key:`c${n}`,subscription:null});continue}r.subscriptions.forEach((l,i)=>{e.push({admin:r.admin,connectionId:r.id,key:`c${n}-s${i.toString()}`,subscription:l})})}return e},"B"),C=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),oe=S(a=>{let e=(0,B.c)(22),{initialShardKey:r}=a,n=M(),{queryShardKey:l,setShardKey:i,shardKey:m}=F(r),f;e[0]===Symbol.for("react.memo_cache_sentinel")?(f={},e[0]=f):f=e[0];let b;e[1]!==l?(b={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=b):b=e[2];let{data:s,error:o,errorSource:u,refetch:J}=_(D.listSubscriptions,f,b);W(J,!0);let x;if(e[3]!==o||e[4]!==u||e[5]!==s||e[6]!==i||e[7]!==m||e[8]!==n){let k=s===void 0?[]:G(s.connections),c;e[10]!==i||e[11]!==m?(c=(0,t.jsx)(E,{onChange:i,testId:"subs-shard-input",value:m}),e[10]=i,e[11]=m,e[12]=c):c=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&(0,t.jsxs)("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[(0,t.jsx)(y,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),(0,t.jsx)(y,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==c||e[17]!==d?(g=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[16]=c,e[17]=d,e[18]=g):g=e[18];let v;e[19]!==o||e[20]!==u?(v=o!==null&&(0,t.jsx)(L,{error:u,testId:"subs-error"}),e[19]=o,e[20]=u,e[21]=v):v=e[21],x=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,v,o===null&&s!==void 0&&k.length===0&&(0,t.jsx)(T,{description:n("Active WebSocket subscriptions on this shard."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),o===null&&k.length>0&&(0,t.jsx)($,{className:"overflow-hidden py-0",children:(0,t.jsx)(j,{className:"px-0",children:(0,t.jsxs)(O,{"data-testid":"subs-table",children:[(0,t.jsx)(P,{children:(0,t.jsxs)(w,{children:[(0,t.jsx)(h,{children:n("Connection")}),(0,t.jsx)(h,{children:n("Function path")}),(0,t.jsx)(h,{children:n("Table")}),(0,t.jsx)(h,{children:n("Arguments")})]})}),(0,t.jsx)(U,{children:k.map(N=>{let{subscription:I}=N,K=z(I?.args);return(0,t.jsxs)(w,{"data-testid":"subs-row",children:[(0,t.jsx)(p,{className:"font-medium tabular-nums",children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1.5",children:["#",N.connectionId,N.admin&&(0,t.jsx)(y,{variant:"outline",children:n("admin")})]})}),(0,t.jsx)(p,{className:"font-mono text-xs",children:I?.functionPath??C}),(0,t.jsx)(p,{children:I?.table??C}),(0,t.jsx)(p,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:K||void 0,children:K||C})]},N.key)})})]})})})]}),e[3]=o,e[4]=u,e[5]=s,e[6]=i,e[7]=m,e[8]=n,e[9]=x}else x=e[9];return x},"oe");export{oe as default};
@@ -0,0 +1,15 @@
1
+ import{a}from"./chunk-3XIESWL4.js";var s="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/",n="https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-1xxx-errors/",_=/string or blob too big/iu,l={BAD_REQUEST:{status:400,title:"Bad request"},UNAUTHORIZED:{status:401,title:"Unauthorized"},FORBIDDEN:{status:403,title:"Forbidden"},NOT_FOUND:{status:404,title:"Not found"},CONFLICT:{hint:["Another write changed this row while your mutation was running (optimistic concurrency conflict).","","Re-read the row and retry the mutation with the fresh value. Lunora serializes a DO's mutations, so a persistent conflict usually means the handler conflicts **with itself** (e.g. a trigger or cascade touching the same row) \u2014 split that work rather than adding a retry loop."],status:409,title:"Conflict"},NOT_UNIQUE:{hint:["`.unique()` matched more than one document \u2014 it expects the query to identify at most one row.","","- If several matches are legitimate, use `.first()` (take one) or `.collect()` (take all) instead.","- Otherwise tighten the query (e.g. filter on a unique/indexed field) so it can only match one row."],status:400,title:"Query matched more than one document"},VALIDATION_ERROR:{status:400,title:"Validation failed"},TOO_MANY_REQUESTS:{status:429,title:"Too many requests"},UNPROCESSABLE:{status:422,title:"Unprocessable"},NOT_IMPLEMENTED:{status:501,title:"Not implemented"},FUNCTION_NOT_FOUND:{status:404,title:"Function not found"},METHOD_NOT_ALLOWED:{status:405,title:"Method not allowed"},PAYLOAD_TOO_LARGE:{status:413,title:"Payload too large"},INTERNAL:{internal:!0,status:500,title:"Internal error"},INTERNAL_SERVER_ERROR:{internal:!0,status:500,title:"Internal error"},RPC_FAILED:{internal:!0,status:500,title:"Internal error"},COUNT_RLS_UNSUPPORTED:{status:422,title:"count() is unsupported under an RLS policy"},MASK_UNSUPPORTED:{status:422,title:"Aggregation over a masked column is unsupported"},RELATION_PREDICATE_UNSUPPORTED:{status:422,title:"Relation predicate is unsupported in a write policy"},RLS_REQUIRED:{hint:["This table is secure-by-default: it has no `.public()` marker and no RLS policy resolved for the caller, so the read fails closed.","","Add a read policy with `.rls(...)`, or mark the table `.public()` if it is intentionally world-readable."],status:403,title:"RLS policy required"},RUN_DEPTH_EXCEEDED:{internal:!0,status:500,title:"Run depth exceeded"},TRANSACTION_LIMIT_EXCEEDED:{hint:["A single mutation may only read and write a bounded amount before it is stopped.","","Narrow the read with an index (`.withIndex(...)`) instead of scanning the table, or split the write across several mutations \u2014 for a large backfill use `defineMigration` + `lunora migrate up`, which batches and checkpoints for you.","","The ceilings are deliberately conservative \u2014 they exist to stop one request taking down the whole shard. A deployment that genuinely needs bigger transactions can raise them by overriding the `transactionLimits()` seam on its generated shard class."],status:413,title:"Transaction limit exceeded"},MIGRATION_NOT_FOUND:{status:404,title:"Data migration not found"},UNKNOWN_TABLE:{status:404,title:"Unknown table"},GLOBAL_TABLE_NOT_EDITABLE:{status:400,title:"Global table is not editable"},SHARD_ERROR:{status:503,title:"Shard error"},SHARD_UNAVAILABLE:{status:503,title:"Shard unavailable"},OFFLINE_IDENTITY_CHANGED:{status:409,title:"Offline identity changed"},CODEGEN_DIAGNOSTIC:{status:500,title:"Codegen diagnostic"},SCHEMA_SNAPSHOT_PARSE:{status:500,title:"Schema snapshot parse error"},ENV_INVALID:{internal:!0,status:500,title:"Invalid environment"},AUTH_HEADERS_MISSING:{internal:!0,status:500,title:"Auth headers missing"},EMAIL_DOMAIN_BLOCKED:{hint:["This address's domain is on the disposable/throwaway blocklist (or your configured deny-list).","","Sign up with a permanent mailbox. To tune the policy, pass `blockDisposable` / `allowDomains` / `denyDomains` to `emailGate(...)` (`@lunora/auth/email-guard`)."],status:400,title:"Email domain not allowed"},EMAIL_UNDELIVERABLE:{hint:["The address's domain publishes no MX (or fallback A/AAAA) records, so it can't receive mail.","","Check for a typo in the domain. MX verification is opt-in (`mx: true`) and needs DNS \u2014 leave it off on the edge path if DNS is unavailable."],status:400,title:"Email domain cannot receive mail"},ANALYTICS_SQL_ERROR:{status:502,title:"Analytics Engine SQL API error"},R2_SQL_ERROR:{status:502,title:"R2 SQL API error"},WORKFLOWS_REST_ERROR:{status:502,title:"Cloudflare Workflows REST API error"},ADMIN_FORBIDDEN:{status:403,title:"Admin access forbidden"},ADMIN_TOKEN_NOT_CONFIGURED:{status:400,title:"Admin token not configured"},AUTH_NOT_CONFIGURED:{status:400,title:"Auth admin not configured"},AUTH_OP_NOT_SUPPORTED:{status:400,title:"Auth admin operation not supported"},BACKUP_NOT_CONFIGURED:{status:500,title:"Scheduled backup not configured"},BACKUP_RETENTION_NOT_CONFIGURED:{hint:["`lunora backup prune` removes snapshots past the retention window, and this worker has no window: set `backupRetain` (how many to keep) and `backupCron` (which decides whose snapshots retention owns) on `createWorker`.","","Nothing was deleted. A default is deliberately not invented here \u2014 retention deleting on its own is exactly what this command exists to replace."],status:400,title:"Backup retention window not configured"},BACKUP_TOO_LARGE:{hint:["The scheduled backup is assembled inside the Worker isolate, so it caps the snapshot it will build. Nothing was written.","","The cap is on the NDJSON, not on peak memory: the export fan-out resolves every shard's rows before the first row is encoded, so a snapshot under the cap can still exhaust the isolate. It is set well below the isolate's limit for that reason.","","Narrow the snapshot with `backupTables`, or take this backup off-platform with `lunora backup create --bucket`, which runs on a machine rather than in an isolate. Backing up more often does not help \u2014 every run is a full snapshot."],status:507,title:"Backup too large to assemble in a Worker"},CRON_JOBS_NOT_CONFIGURED:{status:400,title:"Cron jobs not configured"},CRON_JOB_NOT_FOUND:{status:404,title:"Cron job not found"},EXPORT_TAP_NOT_CONFIGURED:{status:400,title:"Export tap not configured"},FUNCTIONS_NOT_CONFIGURED:{status:400,title:"Functions registry not configured"},GLOBALS_NOT_CONFIGURED:{status:400,title:"Global-table introspector not configured"},KV_NOT_CONFIGURED:{status:400,title:"KV introspector not configured"},MIGRATION_ID_REQUIRED:{status:400,title:"Migration id required"},PITR_UNAVAILABLE:{status:409,title:"Point-in-time recovery unavailable"},SCHEDULER_NOT_CONFIGURED:{status:400,title:"Scheduler not configured"},STORAGE_CHECKSUM_MISMATCH:{hint:["The upload body did not match the declared `expectedSize` or `expectedSha256`, so nothing was written \u2014 this check fails closed.","","Re-read the bytes from the source export and retry the transfer. A persistent mismatch means the source blob is corrupt or truncated; fix the export rather than bypassing the check."],status:400,title:"Storage checksum mismatch"},STORAGE_DELETE_NOT_CONFIGURED:{status:400,title:"Storage delete not configured"},STORAGE_DOWNLOAD_NOT_CONFIGURED:{hint:["`GET /_lunora/admin/storage/object` needs a `storageDownload` function on the worker. The generated app worker wires it up; a hand-written `createWorker({ ... })` has to pass `(key, opts) => pick(opts?.bucket).download(key)` \u2014 forwarding `opts.bucket` to the right bucket, and wrapping rather than passing `createStorage(...).download` itself, whose second parameter is a byte range.","","Without it a bucket-backed `lunora backup restore --bucket` cannot read the snapshot. The object is still readable out of band with `wrangler r2 object get`."],status:400,title:"Storage download not configured"},STORAGE_NOT_CONFIGURED:{status:400,title:"Storage not configured"},STORAGE_OBJECT_NOT_FOUND:{status:404,title:"Storage object not found"},STORAGE_UPLOAD_NOT_CONFIGURED:{status:400,title:"Storage upload not configured"},STORAGE_URL_NOT_CONFIGURED:{status:400,title:"Storage signed URL not configured"},VECTORS_NOT_CONFIGURED:{status:400,title:"Vector index introspector not configured"},VECTOR_QUERY_UNSUPPORTED:{status:400,title:"Vector index querying not enabled"},WORKFLOWS_NOT_CONFIGURED:{status:501,title:"Workflows not configured"},AUTH_AUDIT_NOT_CONFIGURED:{status:400,title:"Auth audit reader not configured"},AUTH_AUDIT_READ_FAILED:{internal:!0,status:500,title:"Auth audit read failed"},CRON_EXPR_INVALID:{status:500,title:"Invalid cron expression"},CRON_EXPR_NOT_STATIC:{status:500,title:"Cron expression is not statically analyzable"},CRON_JOB_FAILED:{internal:!0,status:500,title:"Cron job failed"},CRON_NAME_NOT_STATIC:{status:500,title:"Cron job name is not statically analyzable"},CRON_NON_STATIC_FN:{status:500,title:"Cron function reference is not statically analyzable"},CRON_NON_STATIC_VALUE:{status:500,title:"Cron value is not statically analyzable"},CRON_SCHEDULE_INVALID:{status:500,title:"Invalid cron schedule"},CRON_SCHEDULE_NOT_STATIC:{status:500,title:"Cron schedule is not statically analyzable"},DUPLICATE_CRON_NAME:{status:500,title:"Duplicate cron job name"},DUPLICATE_AGENT_BINDING:{status:500,title:"Duplicate agent binding"},DUPLICATE_AGENT_CLASS:{status:500,title:"Duplicate agent generated class name"},DUPLICATE_AGENT_NAME:{status:500,title:"Duplicate agent name"},DUPLICATE_MIGRATION_ID:{status:500,title:"Duplicate migration id"},DUPLICATE_QUEUE_BINDING:{status:500,title:"Duplicate queue binding"},DUPLICATE_QUEUE_NAME:{status:500,title:"Duplicate queue name"},DUPLICATE_WORKFLOW_CLASS:{status:500,title:"Duplicate workflow generated class name"},MIGRATION_ID_NOT_STATIC:{status:500,title:"Migration id is not statically analyzable"},NAMESPACE_COLLISION:{status:500,title:"Function namespace collision"},BAD_ROW:{status:400,title:"Malformed import row"},BAD_SUBSCRIPTION_ARGS:{status:400,title:"Invalid subscription arguments"},BATCH_LIMIT_EXCEEDED:{status:400,title:"Batch limit exceeded"},CROSS_SHARD_RANK_UNSUPPORTED:{status:400,title:"Cross-shard rank() is unsupported"},FORBIDDEN_FANOUT:{status:403,title:"Fan-out forbidden"},FORBIDDEN_ORIGIN:{status:403,title:"Origin forbidden"},FORBIDDEN_SHARD:{status:403,title:"Shard access forbidden"},GLOBAL_NOT_CONFIGURED:{status:400,title:"Global table import not configured"},INVALID_INPUT:{status:400,title:"Invalid input"},RATE_LIMITED:{status:429,title:"Rate limited"},REPLICA_NOT_READY:{status:421,title:"Replica not caught up"},REPLICA_READ_ONLY:{status:421,title:"Replica is read-only"},SERVICE_UNAVAILABLE:{status:503,title:"Service unavailable"},SHAPE_CROSS_SHARD_JOIN:{status:400,title:"Shape cross-shard join is unsupported"},UNAUTHENTICATED:{status:401,title:"Unauthenticated"},UNKNOWN_COLUMN:{status:404,title:"Unknown column"},EXPIRED:{status:404,title:"Session expired"},NESTED_TRANSACTION:{internal:!0,status:500,title:"Nested transaction"},OUT_OF_ORDER:{status:409,title:"Out-of-order mutation"},SHAPE_GLOBAL_TOO_LARGE:{status:413,title:"Global shape too large"},SHAPE_NOT_FOUND:{status:404,title:"Shape not found"},SQL_UNAVAILABLE:{internal:!0,status:500,title:"SQL storage unavailable"},TOKEN_EXPIRED:{status:401,title:"Authentication token expired"},TOO_MANY_STREAMS:{status:429,title:"Too many streams"},UNKNOWN_ADMIN_OP:{status:404,title:"Unknown admin operation"},SOCKET_TAG_BUDGET_EXCEEDED:{status:400,title:"Socket tag budget exceeded"},RELAY_CANNOT_SEED:{status:500,title:"Relay cannot seed"},RELAY_MISCONFIGURED:{status:500,title:"Relay misconfigured"},RELAY_SEED_FAILED:{status:502,title:"Relay seed failed"},MISCONFIGURED:{internal:!0,status:500,title:"Worker misconfigured"},LUNORA_RUNTIME_UNAVAILABLE:{status:500,title:"Lunora runtime unavailable"},INTERNAL_ERROR:{internal:!0,status:500,title:"Internal error"},BROWSER_TIMEOUT:{status:504,title:"Browser operation timed out"},CLIENT_CLOSED:{status:400,title:"Client is closed"},HTTP_STREAM_BAD_CHUNK:{status:502,title:"Malformed HTTP stream chunk"},HTTP_STREAM_INTERRUPTED:{status:502,title:"HTTP stream interrupted"},HTTP_STREAM_MISSING_PARAM:{status:400,title:"HTTP stream missing path parameter"},HTTP_STREAM_NO_BODY:{status:502,title:"HTTP stream response has no body"},HTTP_STREAM_STATUS:{status:502,title:"HTTP stream request failed"},HTTP_STREAM_TRANSPORT:{status:502,title:"HTTP stream transport error"},STREAM_BACKPRESSURE:{status:429,title:"Stream backpressure"},STREAM_DISCONNECTED:{status:503,title:"Stream disconnected"},STREAM_QUEUE_OVERFLOW:{status:429,title:"Stream queue overflow"},UNKNOWN_MUTATION_FN:{status:404,title:"Unknown mutation function"}},f=a(e=>Object.hasOwn(l,e)?l[e]:void 0,"h");var m=[{body:["A single row exceeded the storage engine's per-row ceiling \u2014 2 MB on a Durable Object's SQLite, and 2,000,000 bytes on D1.","","The limit is on the STORED bytes, which are UTF-8: a document of multi-byte text (CJK, emoji) costs up to 3x its character count. `v.bytes()` and `v.bigint()` columns cost more again on a shard-local table, where the row stores both a SQL-comparable projection and the original.","","Keep the large payload out of the row and store a reference to it:","","```ts","const key = `uploads/${crypto.randomUUID()}`;","await ctx.storage.uploads.put(key, bytes);",'await ctx.db.insert("documents", { storageKey: key, title });',"```","","R2 has no practical object-size ceiling, and the row stays small enough to read, index, and replicate."].join(`
2
+ `),header:"Row too large for the storage engine",id:"lunora-row-too-big",test:a(e=>_.test(e),"test")},{body:["Lunora codegen couldn't find a schema to generate from.","","Create `lunora/schema.ts` exporting a `defineSchema(...)` call:","","```ts",'import { defineSchema, defineTable, v } from "@lunora/server";',"","export default defineSchema({"," messages: defineTable({ body: v.string() }),","});","```","","Or run `lunora init` to scaffold Lunora (a sample `lunora/schema.ts` included) into your app."].join(`
3
+ `),header:"No Lunora schema found",id:"lunora-schema-missing",test:a(e=>e.includes("defineSchema() not found")||e.includes("schema.ts not found at"),"test")},{body:["`defineSchema(...)` must be called with an **inline object literal** mapping table names to `defineTable(...)`:","","```ts","export default defineSchema({"," todos: defineTable({ title: v.string(), done: v.boolean() }),","});","```","","Codegen reads the schema statically, so it can't follow a variable or a spread \u2014 pass the object literal directly."].join(`
4
+ `),header:"`defineSchema()` needs an inline object literal",id:"lunora-schema-not-object-literal",test:a(e=>e.includes("defineSchema() expects an object literal"),"test")},{body:["This table name collides with a built-in `ctx.db` member, so the generated client can't expose it.","","Rename the table to anything that isn't a reserved name (the error lists them) \u2014 e.g. `userAccounts` instead of `insert`."].join(`
5
+ `),header:"Table name is reserved",id:"lunora-table-reserved",test:a(e=>e.includes("is reserved")&&e.includes("ctx.db"),"test")},{body:["Two tables resolve to the same name \u2014 usually a base table and a schema **extension** both defining it.","","Rename one of them, or drop the duplicate from the extension. Each table name must be unique across `defineSchema(...)` and every `.extend(...)`."].join(`
6
+ `),header:"Duplicate table name",id:"lunora-table-duplicate",test:a(e=>e.includes("already exists")&&e.includes(".extend("),"test")},{body:['`.jurisdiction(...)` accepts only a **string literal** of `"eu"`, `"us"`, or `"fedramp"`:',"","```ts",'defineSchema({ /* \u2026 */ }).jurisdiction("eu");',"```"].join(`
7
+ `),header:"Invalid `.jurisdiction(...)` value",id:"lunora-jurisdiction",test:a(e=>e.includes("unknown jurisdiction")||e.includes("jurisdiction")&&e.includes('"eu", "us", or "fedramp"'),"test")},{body:["The `unique` flag on an index must be a **literal** `true` or `false`, not a computed value \u2014 codegen needs to read it statically:","","```ts",'defineTable({ email: v.string() }).index("by_email", ["email"], { unique: true });',"```"].join(`
8
+ `),header:"`unique` must be a literal",id:"lunora-unique-literal",test:a(e=>e.includes("must be a literal")&&e.includes("unique"),"test")},{body:["A declared container/workflow class isn't re-exported by your worker entry, so `wrangler deploy` would reject it.","","Add the generated re-export shown in the error to your worker entry (e.g. `src/index.ts`):","","```ts",'export * from "./lunora/_generated/containers";',"```"].join(`
9
+ `),header:"Binding not exported by your worker entry",id:"lunora-worker-entry-export-gap",test:a(e=>e.includes("not exported by your worker entry"),"test")},{body:["A row with the same value already exists in a `unique` index.","","- If you meant to upsert, use `ctx.db.<table>().upsert(...)` (or `.patch(...)` an existing row) instead of `.insert(...)`.",`- Otherwise pick a value that isn't already taken, and consider surfacing a friendly "already exists" message to the user.`].join(`
10
+ `),header:"Unique constraint violation",id:"lunora-runtime-unique",test:a(e=>e.includes("unique constraint violation on"),"test")},{body:l.CONFLICT.hint.join(`
11
+ `),header:"Optimistic concurrency conflict",id:"lunora-runtime-occ",test:a(e=>e.includes("optimistic concurrency conflict"),"test")}],d=[{causes:"the origin returned an empty, unknown, or malformed response Cloudflare couldn't interpret (often an origin crash or an oversized response header)",code:"520",docsUrl:s,family:"5xx",fix:"check your origin's logs for a crash, ensure it returns a valid HTTP response, and keep response headers under the size limit",summary:"Cloudflare got an unknown/empty response from your origin web server.",title:"Web server returns an unknown error"},{causes:"the origin refused the connection \u2014 the web server is down, or a firewall is blocking Cloudflare's IP ranges",code:"521",docsUrl:s,family:"5xx",fix:"confirm the origin process is running and allowlist Cloudflare's published IP ranges in your firewall/security groups",summary:"Cloudflare could not connect to your origin because it refused the connection.",title:"Web server is down"},{causes:"Cloudflare could not establish a TCP connection to the origin in time \u2014 the origin is overloaded, a firewall is dropping packets, or the origin IP is wrong",code:"522",docsUrl:s,family:"5xx",fix:"verify the origin is reachable and not overloaded, and that the DNS record points at the correct origin IP",summary:"The connection to your origin timed out before it was established.",title:"Connection timed out"},{causes:"Cloudflare cannot route to the origin at all \u2014 a bad DNS record, an origin IP that changed, or invalid routing",code:"523",docsUrl:s,family:"5xx",fix:"verify the DNS A/AAAA record points at a reachable origin IP and that no upstream network is blocking Cloudflare",summary:"Cloudflare could not reach your origin server.",title:"Origin is unreachable"},{causes:"Cloudflare made a TCP connection but the origin did not return an HTTP response within 100 seconds \u2014 a slow handler or long-running request",code:"524",docsUrl:s,family:"5xx",fix:"speed up the slow origin handler, or move long work off the request path into a background job (a Durable Object, Queue, or Workflow)",summary:"Cloudflare connected to your origin but it did not respond in time.",title:"A timeout occurred"},{causes:"the TLS handshake between Cloudflare and the origin failed \u2014 a missing/invalid origin certificate, or a cipher/SNI mismatch under Full (Strict) SSL",code:"525",docsUrl:s,family:"5xx",fix:"install a valid certificate on the origin and align your Cloudflare SSL/TLS mode with the origin's certificate setup",summary:"The SSL handshake with your origin failed.",title:"SSL handshake failed"},{causes:"Cloudflare could not validate the origin's certificate under Full (Strict) SSL \u2014 it is expired, self-signed, or issued for the wrong hostname",code:"526",docsUrl:s,family:"5xx",fix:"install a valid, publicly-trusted certificate on the origin (or use a Cloudflare Origin CA cert), matching the request hostname",summary:"Cloudflare could not validate your origin's SSL certificate.",title:"Invalid SSL certificate"},{causes:"a DNS record points at a Cloudflare IP or another prohibited address instead of your real origin",code:"1000",docsUrl:n,family:"1xxx",fix:"point the DNS record at your real origin IP, not a Cloudflare-owned or loopback address",summary:"DNS points to a prohibited IP.",title:"DNS points to prohibited IP"},{causes:"Cloudflare could not resolve the requested hostname \u2014 a Worker fetched an unresolvable host, or a DNS record is misconfigured",code:"1001",docsUrl:n,family:"1xxx",fix:"check the hostname you're requesting and the DNS records for the zone resolve to a valid origin",summary:"Cloudflare could not resolve the origin DNS.",title:"DNS resolution error"},{causes:"a Worker or DNS record targets a restricted IP (for example a Cloudflare-owned or loopback address)",code:"1002",docsUrl:n,family:"1xxx",fix:"change the Worker fetch target or DNS record to a valid, non-restricted origin address",summary:"DNS points to a prohibited IP (Worker/restricted).",title:"DNS points to a prohibited IP"},{causes:"the visitor's IP was blocked by an IP Access Rule, WAF rule, or security configuration on the zone",code:"1006",docsUrl:n,family:"1xxx",fix:"review the zone's Firewall/WAF and IP Access Rules to see why the address was banned, and adjust if it was blocked in error",summary:"Access denied: the visitor's IP has been banned.",title:"Access denied: your IP has been banned"},{causes:"your Worker threw an unhandled JavaScript exception during the request",code:"1101",docsUrl:n,family:"1xxx",fix:"reproduce with `wrangler tail` (or the Workers Logs / Studio Logs panel) to get the stack trace, then handle the throwing code path",summary:"A Worker threw a JavaScript exception.",title:"Worker threw a JavaScript exception"},{causes:"the Worker used more CPU time than a single invocation is allowed \u2014 usually a hot loop or heavy synchronous work",code:"1102",docsUrl:n,family:"1xxx",fix:"reduce per-request CPU (optimize hot loops, avoid heavy synchronous work) or offload the heavy work to a Durable Object, Queue, or Workflow",summary:"A Worker exceeded its CPU-time resource limit.",title:"Worker exceeded resource limits"}],u=a(e=>e!==void 0&&e>="0"&&e<="9","l"),T=a((e,t)=>{for(let i=e.indexOf(t);i!==-1;i=e.indexOf(t,i+t.length))if(!u(e[i-1])&&!u(e[i+t.length]))return!0;return!1},"p"),g=a((e,t)=>{for(let i of[`error ${t}`,`error: ${t}`])for(let o=e.indexOf(i);o!==-1;o=e.indexOf(i,o+i.length))if(!u(e[o+i.length]))return!0;return!1},"_"),O=/error|cloudflare/iu,h=a(e=>({body:[e.summary,"",`**Likely cause:** ${e.causes}.`,"",`**Fix:** ${e.fix}.`,"",`See [Cloudflare's ${e.family} error docs](${e.docsUrl}).`].join(`
12
+ `),header:`Cloudflare Error ${e.code}: ${e.title}`,id:`cloudflare-error-${e.code}`}),"c"),p=a(e=>{if(!O.test(e))return;let t=e.toLowerCase(),i=t.includes("error"),o=t.includes("cloudflare");if(i){for(let r of d)if(g(t,r.code))return h(r)}if(o){for(let r of d)if(T(t,r.code))return h(r)}},"E"),N=a(e=>(typeof e=="string"?e:e.join(`
13
+ `)).split(`
14
+ `).filter(t=>!t.startsWith("```")).join(`
15
+ `).replaceAll(/\*\*(.+?)\*\*/gu,"$1").replaceAll(/`([^`]+)`/gu,"$1"),"N"),E=a(e=>{for(let t of m)if(t.test(e))return{body:t.body,header:t.header,id:t.id}},"u"),A=a(e=>E(e)??p(e),"O");var c=class extends Error{static{a(this,"c")}type="VisulimaError";hint;title;loc;code;status;docsUrl;data;constructor(t,i,o={}){let r=f(t);super(i??t,o.cause===void 0?void 0:{cause:o.cause}),this.name=o.name??"LunoraError",this.hint=o.hint??r?.hint,this.title=o.title??r?.title,this.loc=o.location,this.code=t,this.status=o.status??r?.status??500,this.docsUrl=o.docsUrl??r?.docsUrl,this.data=o.data}};export{N as a,A as b,c};
@@ -1 +1 @@
1
- import{d as k}from"./chunk-MLT5MMMY.js";import{a as j}from"./chunk-54MMVNPT.js";import{a as T}from"./chunk-4PDTGZDC.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as E}from"./chunk-6IZBFC3G.js";import"./chunk-XXQUMVWH.js";import"./chunk-ZNNKWEH5.js";import"./chunk-QLQADHFE.js";import{a as y}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-UP7OTXKF.js";import"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-WJQLNYGX.js";import{a as u,e as N}from"./chunk-WQH3LT2P.js";import{d as _,r as S}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as c,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],$={},D=new Set(["active","trialing"]),q=new Set(["past_due","unpaid"]),a=c((s,t)=>{if(s[t]!==void 0)return s[t];let m=s.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"i"),i=c(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","s"),z=c(s=>D.has(s)?"default":q.has(s)?"destructive":"outline","L"),ae=c(({limit:s=100})=>{let t=_(),m=T(),{data:g}=b(y.listTables,$,{live:!0}),O=g!==void 0,B=Array.isArray(g)&&H.every(r=>g.some(d=>d.name===r)),p=m.payments&&B,o=b(y.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),f=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),f.refetch())},!0);let h=o.data?.rows??[],U=f.data?.rows??[],C=o.error??f.error,F=o.error===null?f.errorSource:o.errorSource,P=h.filter(r=>D.has(i(a(r,"state")))).length,L=U.toSorted((r,d)=>Number(a(d,"processedAt")??0)-Number(a(r,"processedAt")??0));return O&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(u,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:h.length})})]})}),C===null?void 0:(0,e.jsx)(E,{error:F}),h.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(u,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(A,{children:h.map(r=>{let d=i(a(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{children:i(a(r,"referenceId"))}),(0,e.jsx)(n,{children:i(a(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(x,{variant:z(d),children:d})}),(0,e.jsx)(n,{children:S(a(r,"currentPeriodEnd"))})]},i(a(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(u,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:L.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(a(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(a(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(a(r,"processedAt"))})]},i(a(r,"providerEventId"))))})})})]})]})},"ae");export{ae as PaymentsPanel};
1
+ import{d as k}from"./chunk-MLT5MMMY.js";import{a as j}from"./chunk-54MMVNPT.js";import{a as T}from"./chunk-6ZVSFYWY.js";import"./chunk-SFDOII3B.js";import"./chunk-SMIESS7P.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import{b as x}from"./chunk-THIXMMZD.js";import"./chunk-6ST5ECQA.js";import{a as E}from"./chunk-ZBVGZ4YA.js";import"./chunk-XXQUMVWH.js";import"./chunk-56Q3NCCQ.js";import"./chunk-QLQADHFE.js";import{a as y}from"./chunk-VDW32UET.js";import{c as b}from"./chunk-KMT6UDR7.js";import"./chunk-WVU7GHTG.js";import"./chunk-XBDKZZ67.js";import{a as w}from"./chunk-XQCVZAGU.js";import{a as I,b as R,c as A,d as v,e as l,f as n}from"./chunk-WJQLNYGX.js";import{a as u,e as N}from"./chunk-WQH3LT2P.js";import{d as _,r as S}from"./chunk-IUYFXK4X.js";import"./chunk-BR5GIQWK.js";import{a as c,e as M,h as G}from"./chunk-3XIESWL4.js";var e=M(G(),1);var H=["subscriptions","events"],$={},D=new Set(["active","trialing"]),q=new Set(["past_due","unpaid"]),a=c((s,t)=>{if(s[t]!==void 0)return s[t];let m=s.__doc__;return typeof m=="string"?k(m)?.[t]:void 0},"i"),i=c(s=>typeof s=="string"?s:typeof s=="number"||typeof s=="bigint"||typeof s=="boolean"?String(s):"","s"),z=c(s=>D.has(s)?"default":q.has(s)?"destructive":"outline","L"),ae=c(({limit:s=100})=>{let t=_(),m=T(),{data:g}=b(y.listTables,$,{live:!0}),O=g!==void 0,B=Array.isArray(g)&&H.every(r=>g.some(d=>d.name===r)),p=m.payments&&B,o=b(y.readTablePage,{filters:[],limit:s,offset:0,orderBy:[],search:"",table:"subscriptions"},{enabled:p}),f=b(y.readTablePage,{filters:[],limit:25,offset:0,orderBy:[],search:"",table:"events"},{enabled:p});j(()=>{p&&(o.refetch(),f.refetch())},!0);let h=o.data?.rows??[],U=f.data?.rows??[],C=o.error??f.error,F=o.error===null?f.errorSource:o.errorSource,P=h.filter(r=>D.has(i(a(r,"state")))).length,L=U.toSorted((r,d)=>Number(a(d,"processedAt")??0)-Number(a(r,"processedAt")??0));return O&&!p?(0,e.jsx)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:(0,e.jsx)(w,{description:t("No @lunora/payment tables found in this deployment. Declare the store tables (subscriptions, events, \u2026) in lunora/schema.ts and wire `payment` on createShardDO() to sync customers and subscriptions."),testId:"payments-unconfigured",title:t("No payments configured")})}):(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"payments-panel",children:[(0,e.jsx)("div",{className:"flex items-center gap-2","data-testid":"payments-summary",children:(0,e.jsxs)(u,{className:"justify-between gap-0 py-0",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Subscriptions")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("span",{className:"text-2xl font-semibold tabular-nums text-foreground",children:P}),(0,e.jsx)(x,{variant:"default",children:t("{count} active",{count:P})})]})]}),(0,e.jsx)("div",{className:"border-t border-border bg-muted/50 px-4 py-2.5 text-[11px] text-muted-foreground",children:t("{total} total",{total:h.length})})]})}),C===null?void 0:(0,e.jsx)(E,{error:F}),h.length===0&&!o.isLoading?(0,e.jsx)(w,{testId:"payments-empty",title:t("No subscriptions yet")}):(0,e.jsx)(u,{className:"overflow-hidden py-0",children:(0,e.jsx)(N,{className:"px-0",children:(0,e.jsxs)(I,{children:[(0,e.jsx)(R,{children:(0,e.jsxs)(v,{children:[(0,e.jsx)(l,{children:t("Provider")}),(0,e.jsx)(l,{children:t("Reference")}),(0,e.jsx)(l,{children:t("Plan")}),(0,e.jsx)(l,{children:t("State")}),(0,e.jsx)(l,{children:t("Renews")})]})}),(0,e.jsx)(A,{children:h.map(r=>{let d=i(a(r,"state"));return(0,e.jsxs)(v,{"data-testid":"payment-subscription-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{children:i(a(r,"referenceId"))}),(0,e.jsx)(n,{children:i(a(r,"priceId"))}),(0,e.jsx)(n,{children:(0,e.jsx)(x,{variant:z(d),children:d})}),(0,e.jsx)(n,{children:S(a(r,"currentPeriodEnd"))})]},i(a(r,"providerSubscriptionId")))})})]})})}),(0,e.jsxs)(u,{className:"overflow-hidden py-0",children:[(0,e.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,e.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Recent webhook events")})}),(0,e.jsx)(N,{className:"px-0",children:(0,e.jsx)(I,{children:(0,e.jsx)(A,{children:L.map(r=>(0,e.jsxs)(v,{"data-testid":"payment-event-row",children:[(0,e.jsx)(n,{children:i(a(r,"provider"))}),(0,e.jsx)(n,{className:"font-medium",children:i(a(r,"type"))}),(0,e.jsx)(n,{className:"text-muted-foreground",children:i(a(r,"providerEventId"))}),(0,e.jsx)(n,{children:S(a(r,"processedAt"))})]},i(a(r,"providerEventId"))))})})})]})]})},"ae");export{ae as PaymentsPanel};
@@ -1,4 +1,4 @@
1
- import{a as In,b as Ze,c as Dn,d as ht}from"./chunk-MRK53LUL.js";import{c as Tn,d as zn}from"./chunk-WPK2Q33V.js";import{a as Ln,b as On,c as An,d as Gn}from"./chunk-MLT5MMMY.js";import{a as pt}from"./chunk-ZJGP6EKR.js";import{b as mt}from"./chunk-AVAC26HJ.js";import{d as Hn}from"./chunk-XF2B7P5A.js";import{a as ft}from"./chunk-GMR677FL.js";import"./chunk-GG6PIGQO.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as gt}from"./chunk-3DH35OZ5.js";import{a as Gt}from"./chunk-ESVP44Y3.js";import{a as En}from"./chunk-54MMVNPT.js";import{b as Cn,c as Lt}from"./chunk-3C3CG7ZK.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import{a as Ht}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as ct}from"./chunk-Y32QIKBS.js";import{a as $n}from"./chunk-RMN2JN4S.js";import{a as _n,b as Fn}from"./chunk-GRL5MG3Z.js";import{c as hn,d as vn,e as bn}from"./chunk-SMIESS7P.js";import{b as yn,c as Rn,e as Ot}from"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as ue}from"./chunk-VDW32UET.js";import{b as zt,c as Xe}from"./chunk-UP7OTXKF.js";import{f as Ee}from"./chunk-LYVP5PT6.js";import"./chunk-XBDKZZ67.js";import{a as dt}from"./chunk-XQCVZAGU.js";import{a as Nn,b as Mn,c as Pn,d as At,e as kn,f as Vn}from"./chunk-WJQLNYGX.js";import{d as X,f as ye,g as Ce,h as wn,m as Je,n as xn,o as Z,r as Sn}from"./chunk-IUYFXK4X.js";import"./chunk-X7B6PLEW.js";import{a as i,e as ae,f as We,g as rt,h as lt,j as Ue}from"./chunk-3XIESWL4.js";var Po=ae(rt(),1);var Ye=ae(We(),1);var Ke=ae(rt(),1);var z=ae(lt(),1),Re=ae(We(),1);var ur=[25,50,100,250],dr=i(t=>{let e=(0,Ke.c)(18),{onChange:n,options:o,prefix:r,value:l}=t,s=X(),a;e[0]!==n?(a=i(b=>{n(Number.parseInt(b.target.value,10))},"i"),e[0]=n,e[1]=a):a=e[1];let u=a,d=`${r}-page-size`,g;e[2]!==s?(g=s("Rows per page"),e[2]=s,e[3]=g):g=e[3];let m;e[4]!==g?(m=(0,z.jsx)("span",{children:g}),e[4]=g,e[5]=m):m=e[5];let c=`${r}-page-size`,f=`${r}-page-size`,p;e[6]!==o?(p=o.map(gr),e[6]=o,e[7]=p):p=e[7];let h;e[8]!==u||e[9]!==c||e[10]!==f||e[11]!==p||e[12]!==l?(h=(0,z.jsx)("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:f,onChange:u,value:l,children:p}),e[8]=u,e[9]=c,e[10]=f,e[11]=p,e[12]=l,e[13]=h):h=e[13];let w;return e[14]!==d||e[15]!==m||e[16]!==h?(w=(0,z.jsxs)("label",{className:"flex items-center gap-1.5",htmlFor:d,children:[m,h]}),e[14]=d,e[15]=m,e[16]=h,e[17]=w):w=e[17],w},"V"),cr=i(t=>{let e=(0,Ke.c)(25),{onJump:n,page:o,pages:r,prefix:l}=t,s=X(),a;e[0]!==n||e[1]!==r?(a=i(R=>{let y=Number.parseInt(R,10);Number.isNaN(y)||n(Math.min(Math.max(1,y),Math.max(1,r)))},"i"),e[0]=n,e[1]=r,e[2]=a):a=e[2];let u=a,d;e[3]!==u?(d=i(R=>{R.key==="Enter"&&u(R.currentTarget.value)},"c"),e[3]=u,e[4]=d):d=e[4];let g=d,m;e[5]!==u?(m=i(R=>{u(R.currentTarget.value)},"g"),e[5]=u,e[6]=m):m=e[6];let c=m,f;e[7]!==s?(f=s("Page"),e[7]=s,e[8]=f):f=e[8];let p;e[9]!==s?(p=s("Page"),e[9]=s,e[10]=p):p=e[10];let h=`${l}-page-jump`,w=Math.max(1,r),b;e[11]!==c||e[12]!==g||e[13]!==o||e[14]!==p||e[15]!==h||e[16]!==w?(b=(0,z.jsx)("input",{"aria-label":p,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:o,max:w,min:1,onBlur:c,onKeyDown:g,type:"number"},o),e[11]=c,e[12]=g,e[13]=o,e[14]=p,e[15]=h,e[16]=w,e[17]=b):b=e[17];let x;e[18]!==r||e[19]!==s?(x=s("of {pages}",{pages:r}),e[18]=r,e[19]=s,e[20]=x):x=e[20];let C;return e[21]!==f||e[22]!==b||e[23]!==x?(C=(0,z.jsxs)("span",{className:"flex items-center gap-1.5 tabular-nums",children:[f,b,x]}),e[21]=f,e[22]=b,e[23]=x,e[24]=C):C=e[24],C},"_"),vt=i(({hasNext:t,hasPrevious:e,onJumpToPage:n,onNext:o,onPageSizeChange:r,onPrevious:l,pageSize:s,pageSizeOptions:a=ur,prefix:u,rangeEnd:d,rangeStart:g,total:m})=>{let c=X(),f="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",p=s!==void 0&&s>0?Math.max(1,Math.ceil(m/s)):1,h=s!==void 0&&s>0?Math.floor(Math.max(0,g-1)/s)+1:1;return(0,z.jsxs)("div",{className:"flex w-full items-center justify-between gap-3 text-xs text-muted-foreground",children:[(0,z.jsxs)("div",{className:"flex items-center gap-3",children:[s!==void 0&&r!==void 0&&(0,z.jsx)(dr,{onChange:r,options:a,prefix:u,value:s}),(0,z.jsx)("span",{className:"tabular-nums","data-testid":`${u}-page-info`,children:c("{rangeStart}-{rangeEnd} of {total}",{rangeEnd:d,rangeStart:g,total:m})})]}),(0,z.jsxs)("div",{className:"flex items-center gap-3",children:[(0,z.jsx)("button",{className:f,"data-testid":`${u}-prev`,disabled:!e,onClick:l,type:"button",children:c("Previous")}),s!==void 0&&n!==void 0&&(0,z.jsx)(cr,{onJump:n,page:h,pages:p,prefix:u}),(0,z.jsx)("button",{className:f,"data-testid":`${u}-next`,disabled:!t,onClick:o,type:"button",children:c("Next")})]})]})},"Z");function gr(t){return(0,z.jsx)("option",{value:t,children:t},t)}i(gr,"B");var Bn=i(t=>t==null?"\u2205":t===""?"(empty)":typeof t=="object"?JSON.stringify(t):String(t),"S"),fr=i(t=>{let e=(0,Ke.c)(32),{column:n,onFacetFilter:o,state:r}=t,l=X(),s;e[0]!==n||e[1]!==o||e[2]!==r.result?.values?(s=i(w=>{let b=Number(w.currentTarget.dataset.index),x=r.result?.values[b];x!==void 0&&o(n,x.value)},"n"),e[0]=n,e[1]=o,e[2]=r.result?.values,e[3]=s):s=e[3];let a=s,u=`db-facet-${n}`,d;e[4]!==n?(d=(0,z.jsx)("span",{className:"font-medium text-foreground",children:n}),e[4]=n,e[5]=d):d=e[5];let g;e[6]!==r.loading||e[7]!==r.result||e[8]!==l?(g=r.loading&&r.result===null&&(0,z.jsx)("span",{className:"text-muted-foreground",children:l("Loading\u2026")}),e[6]=r.loading,e[7]=r.result,e[8]=l,e[9]=g):g=e[9];let m;e[10]!==r.error?(m=r.error!==null&&(0,z.jsx)("span",{className:"text-destructive",role:"alert",children:r.error}),e[10]=r.error,e[11]=m):m=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 f;if(e[14]!==n||e[15]!==a||e[16]!==c){let w;e[18]!==n||e[19]!==a?(w=i((b,x)=>(0,z.jsxs)("button",{className:"flex items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground","data-index":x,"data-testid":`db-facet-value-${n}`,onClick:a,type:"button",children:[(0,z.jsx)("span",{className:"truncate",children:Bn(b.value)}),(0,z.jsx)("span",{className:"shrink-0 tabular-nums text-foreground/70",children:b.count})]},Bn(b.value)),"u"),e[18]=n,e[19]=a,e[20]=w):w=e[20],f=c.map(w),e[14]=n,e[15]=a,e[16]=c,e[17]=f}else f=e[17];let p;e[21]!==n||e[22]!==r.result||e[23]!==l?(p=r.result?.truncated===!0&&(0,z.jsx)("span",{className:"text-muted-foreground","data-testid":`db-facet-truncated-${n}`,children:l("Showing the {n} most common values.",{n:r.result.values.length})}),e[21]=n,e[22]=r.result,e[23]=l,e[24]=p):p=e[24];let h;return e[25]!==u||e[26]!==d||e[27]!==g||e[28]!==m||e[29]!==f||e[30]!==p?(h=(0,z.jsxs)("section",{className:"flex flex-col gap-1","data-testid":u,children:[d,g,m,f,p]}),e[25]=u,e[26]=d,e[27]=g,e[28]=m,e[29]=f,e[30]=p,e[31]=h):h=e[31],h},"A"),bt=i(t=>{let e=(0,Ke.c)(26),{columns:n,facets:o,onFacetFilter:r,onToggleFacet:l}=t,s=X(),a;e[0]!==l?(a=i(b=>{let{column:x}=b.currentTarget.dataset;x!==void 0&&l(x)},"i"),e[0]=l,e[1]=a):a=e[1];let u=a;if(n.length===0)return null;let d;e[2]!==s?(d=s("Facets"),e[2]=s,e[3]=d):d=e[3];let g;e[4]!==d?(g=(0,z.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:d}),e[4]=d,e[5]=g):g=e[5];let m;if(e[6]!==n||e[7]!==o||e[8]!==u){let b;e[10]!==o||e[11]!==u?(b=i(x=>(0,z.jsx)("button",{"aria-pressed":x in o,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":x,"data-testid":`db-facet-toggle-${x}`,onClick:u,type:"button",children:x},x),"h"),e[10]=o,e[11]=u,e[12]=b):b=e[12],m=n.map(b),e[6]=n,e[7]=o,e[8]=u,e[9]=m}else m=e[9];let c;e[13]!==m?(c=(0,z.jsx)("div",{className:"flex flex-wrap gap-1",children:m}),e[13]=m,e[14]=c):c=e[14];let f;e[15]!==g||e[16]!==c?(f=(0,z.jsxs)("div",{className:"flex flex-col gap-1.5",children:[g,c]}),e[15]=g,e[16]=c,e[17]=f):f=e[17];let p;e[18]!==o?(p=Object.entries(o),e[18]=o,e[19]=p):p=e[19];let h;e[20]!==r||e[21]!==p?(h=p.map(b=>{let[x,C]=b;return(0,z.jsx)(fr,{column:x,onFacetFilter:r,state:C},x)}),e[20]=r,e[21]=p,e[22]=h):h=e[22];let w;return e[23]!==f||e[24]!==h?(w=(0,z.jsxs)("aside",{className:"flex w-56 shrink-0 flex-col gap-3 overflow-auto border-l border-border p-3 text-xs","data-testid":"db-facets",children:[f,h]}),e[23]=f,e[24]=h,e[25]=w):w=e[25],w},"ee");function Ie(t){let e=(0,Ke.c)(2),n=(0,Re.useRef)(t),o;return e[0]!==t?(o=i(()=>{n.current=t},"l"),e[0]=t,e[1]=o):o=e[1],(0,Re.useEffect)(o),n}i(Ie,"D");var wt=i(()=>{let[t,e]=(0,Re.useState)({}),n=Ie(t),o=(0,Re.useRef)({}),r=i(async(l,s)=>{let a=(o.current[l]??0)+1;o.current[l]=a,e(u=>l in u?{...u,[l]:{error:null,loading:!0,result:u[l]?.result??null}}:u);try{let u=await s(l);if(o.current[l]!==a)return;e(d=>l in d?{...d,[l]:{error:null,loading:!1,result:u}}:d)}catch(u){if(o.current[l]!==a)return;e(d=>l in d?{...d,[l]:{error:wn(u),loading:!1,result:null}}:d)}},"r");return{clearFacets:i(()=>{e({})},"clearFacets"),facets:t,facetsRef:n,refetchFacets:i(l=>{for(let s of Object.keys(n.current))Z(r(s,l))},"refetchFacets"),toggleFacet:i((l,s)=>{if(l in n.current){e(a=>Object.fromEntries(Object.entries(a).filter(([u])=>u!==l)));return}e(a=>({...a,[l]:{error:null,loading:!0,result:null}})),s!==null&&Z(r(l,s))},"toggleFacet")}},"te"),jn=34,qn=600,mr=i(t=>{let e=(0,Ke.c)(21),{item:n,onSelect:o,prefix:r,selected:l,start:s}=t,a;e[0]!==n.name||e[1]!==o?(a=i(()=>{o(n.name)},"i"),e[0]=n.name,e[1]=o,e[2]=a):a=e[2];let u=a,d=`translateY(${String(s)}px)`,g;e[3]!==d?(g={insetInline:0,position:"absolute",top:0,transform:d},e[3]=d,e[4]=g):g=e[4];let m=g,c=l?"bg-accent font-medium text-accent-foreground":"text-foreground",f;e[5]!==c?(f=Ue("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]=f):f=e[6];let p=`${r}-table-${n.name}`,h;e[7]!==n.name?(h=(0,z.jsx)("span",{className:"truncate",children:n.name}),e[7]=n.name,e[8]=h):h=e[8];let w;e[9]!==n.rowCount?(w=(0,z.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 text-xs tabular-nums text-muted-foreground",children:n.rowCount}),e[9]=n.rowCount,e[10]=w):w=e[10];let b;e[11]!==u||e[12]!==l||e[13]!==f||e[14]!==p||e[15]!==h||e[16]!==w?(b=(0,z.jsxs)("button",{"aria-pressed":l,className:f,"data-testid":p,onClick:u,type:"button",children:[h,w]}),e[11]=u,e[12]=l,e[13]=f,e[14]=p,e[15]=h,e[16]=w,e[17]=b):b=e[17];let x;return e[18]!==m||e[19]!==b?(x=(0,z.jsx)("li",{style:m,children:b}),e[18]=m,e[19]=b,e[20]=x):x=e[20],x},"K"),xt=i(({header:t,onReload:e,onSelect:n,prefix:o,reloadLabel:r,selected:l,tables:s})=>{let a=X(),[u,d]=(0,Re.useState)(""),g=(0,Re.useRef)(null),m=i(h=>{d(h.target.value)},"g"),c=(0,Re.useMemo)(()=>{let h=u.trim().toLowerCase();return h===""?s:s.filter(w=>w.name.toLowerCase().includes(h))},[u,s]),f=mt({count:c.length,estimateSize:i(()=>jn,"estimateSize"),getScrollElement:i(()=>g.current,"getScrollElement"),initialRect:{height:qn,width:240},observeElementRect:i((h,w)=>pt(h,w,qn),"observeElementRect"),overscan:12}).getVirtualItems(),p={height:c.length*jn};return(0,z.jsxs)("aside",{className:"flex h-full w-60 shrink-0 flex-col border-e border-border bg-sidebar","data-testid":`${o}-table-list`,children:[t,(0,z.jsxs)("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border px-3",children:[(0,z.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:a("Tables")}),e!==void 0&&(0,z.jsx)("button",{"aria-label":r??a("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":`${o}-load-tables`,onClick:e,title:r??a("Refresh"),type:"button",children:(0,z.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,z.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})})})]}),(0,z.jsx)("div",{className:"shrink-0 border-b border-border p-2",children:(0,z.jsx)("input",{className:"h-7 w-full rounded-md border border-border bg-background px-2 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring","data-testid":`${o}-table-search`,onChange:m,placeholder:a("search table\u2026"),type:"search",value:u})}),(0,z.jsxs)("ul",{className:"relative flex-1 overflow-y-auto p-1.5","data-testid":`${o}-table-list-rows`,ref:g,children:[(0,z.jsx)("li",{"aria-hidden":"true",style:p}),f.map(h=>{let w=c[h.index];return w===void 0?null:(0,z.jsx)(mr,{item:w,onSelect:n,prefix:o,selected:l===w.name,start:h.start},w.name)})]})]})},"re");var B=ae(rt(),1);var N=ae(We(),1);var at=ae(We(),1);function He(t,e){return typeof t=="function"?t(e):t}i(He,"functionalUpdate");function be(t,e){return n=>{e.setState(o=>({...o,[t]:He(n,o[t])}))}}i(be,"makeStateUpdater");function Rt(t){return t instanceof Function}i(Rt,"isFunction");function pr(t){return Array.isArray(t)&&t.every(e=>typeof e=="number")}i(pr,"isNumberArray");function hr(t,e){let n=[],o=i(r=>{r.forEach(l=>{n.push(l);let s=e(l);s!=null&&s.length&&o(s)})},"recurse");return o(t),n}i(hr,"flattenBy");function I(t,e,n){let o=[],r;return l=>{let s;n.key&&n.debug&&(s=Date.now());let a=t(l);if(!(a.length!==o.length||a.some((g,m)=>o[m]!==g)))return r;o=a;let d;if(n.key&&n.debug&&(d=Date.now()),r=e(...a),n==null||n.onChange==null||n.onChange(r),n.key&&n.debug&&n!=null&&n.debug()){let g=Math.round((Date.now()-s)*100)/100,m=Math.round((Date.now()-d)*100)/100,c=m/16,f=i((p,h)=>{for(p=String(p);p.length<h;)p=" "+p;return p},"pad");console.info(`%c\u23F1 ${f(m,5)} /${f(g,5)} ms`,`
1
+ import{a as In,b as Ze,c as Dn,d as ht}from"./chunk-GPXYZOOF.js";import{c as Tn,d as zn}from"./chunk-WPK2Q33V.js";import{a as Ln,b as On,c as An,d as Gn}from"./chunk-MLT5MMMY.js";import{a as pt}from"./chunk-ZJGP6EKR.js";import{b as mt}from"./chunk-AVAC26HJ.js";import{d as Hn}from"./chunk-XF2B7P5A.js";import{a as ft}from"./chunk-GMR677FL.js";import"./chunk-GG6PIGQO.js";import"./chunk-SD4BERSA.js";import"./chunk-IC4L6G56.js";import{a as gt}from"./chunk-3DH35OZ5.js";import{a as Gt}from"./chunk-ESVP44Y3.js";import{a as En}from"./chunk-54MMVNPT.js";import{b as Cn,c as Lt}from"./chunk-3C3CG7ZK.js";import"./chunk-I6A5C46N.js";import"./chunk-2QSHLBCO.js";import"./chunk-BGBLQ563.js";import{a as Ht}from"./chunk-FURI47Z2.js";import"./chunk-IVFHIQOT.js";import"./chunk-QBWRC5YX.js";import{a as ct}from"./chunk-Y32QIKBS.js";import{a as $n}from"./chunk-RMN2JN4S.js";import{a as _n,b as Fn}from"./chunk-GRL5MG3Z.js";import{c as hn,d as vn,e as bn}from"./chunk-SMIESS7P.js";import{b as yn,c as Rn,e as Ot}from"./chunk-7T7UOTYK.js";import"./chunk-CFPZYHPY.js";import"./chunk-T6VMSOBB.js";import"./chunk-7QIFDWQV.js";import"./chunk-MWIKAR7F.js";import"./chunk-DJZYD5I5.js";import"./chunk-2OUPA2WJ.js";import"./chunk-6ST5ECQA.js";import{a as ue}from"./chunk-VDW32UET.js";import{b as zt,c as Xe}from"./chunk-KMT6UDR7.js";import{f as Ee}from"./chunk-WVU7GHTG.js";import"./chunk-XBDKZZ67.js";import{a as dt}from"./chunk-XQCVZAGU.js";import{a as Nn,b as Mn,c as Pn,d as At,e as kn,f as Vn}from"./chunk-WJQLNYGX.js";import{d as X,f as ye,g as Ce,h as wn,m as Je,n as xn,o as Z,r as Sn}from"./chunk-IUYFXK4X.js";import"./chunk-BR5GIQWK.js";import{a as i,e as ae,f as We,g as rt,h as lt,j as Ue}from"./chunk-3XIESWL4.js";var Po=ae(rt(),1);var Ye=ae(We(),1);var Ke=ae(rt(),1);var z=ae(lt(),1),Re=ae(We(),1);var ur=[25,50,100,250],dr=i(t=>{let e=(0,Ke.c)(18),{onChange:n,options:o,prefix:r,value:l}=t,s=X(),a;e[0]!==n?(a=i(b=>{n(Number.parseInt(b.target.value,10))},"i"),e[0]=n,e[1]=a):a=e[1];let u=a,d=`${r}-page-size`,g;e[2]!==s?(g=s("Rows per page"),e[2]=s,e[3]=g):g=e[3];let m;e[4]!==g?(m=(0,z.jsx)("span",{children:g}),e[4]=g,e[5]=m):m=e[5];let c=`${r}-page-size`,f=`${r}-page-size`,p;e[6]!==o?(p=o.map(gr),e[6]=o,e[7]=p):p=e[7];let h;e[8]!==u||e[9]!==c||e[10]!==f||e[11]!==p||e[12]!==l?(h=(0,z.jsx)("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:f,onChange:u,value:l,children:p}),e[8]=u,e[9]=c,e[10]=f,e[11]=p,e[12]=l,e[13]=h):h=e[13];let w;return e[14]!==d||e[15]!==m||e[16]!==h?(w=(0,z.jsxs)("label",{className:"flex items-center gap-1.5",htmlFor:d,children:[m,h]}),e[14]=d,e[15]=m,e[16]=h,e[17]=w):w=e[17],w},"V"),cr=i(t=>{let e=(0,Ke.c)(25),{onJump:n,page:o,pages:r,prefix:l}=t,s=X(),a;e[0]!==n||e[1]!==r?(a=i(R=>{let y=Number.parseInt(R,10);Number.isNaN(y)||n(Math.min(Math.max(1,y),Math.max(1,r)))},"i"),e[0]=n,e[1]=r,e[2]=a):a=e[2];let u=a,d;e[3]!==u?(d=i(R=>{R.key==="Enter"&&u(R.currentTarget.value)},"c"),e[3]=u,e[4]=d):d=e[4];let g=d,m;e[5]!==u?(m=i(R=>{u(R.currentTarget.value)},"g"),e[5]=u,e[6]=m):m=e[6];let c=m,f;e[7]!==s?(f=s("Page"),e[7]=s,e[8]=f):f=e[8];let p;e[9]!==s?(p=s("Page"),e[9]=s,e[10]=p):p=e[10];let h=`${l}-page-jump`,w=Math.max(1,r),b;e[11]!==c||e[12]!==g||e[13]!==o||e[14]!==p||e[15]!==h||e[16]!==w?(b=(0,z.jsx)("input",{"aria-label":p,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:o,max:w,min:1,onBlur:c,onKeyDown:g,type:"number"},o),e[11]=c,e[12]=g,e[13]=o,e[14]=p,e[15]=h,e[16]=w,e[17]=b):b=e[17];let x;e[18]!==r||e[19]!==s?(x=s("of {pages}",{pages:r}),e[18]=r,e[19]=s,e[20]=x):x=e[20];let C;return e[21]!==f||e[22]!==b||e[23]!==x?(C=(0,z.jsxs)("span",{className:"flex items-center gap-1.5 tabular-nums",children:[f,b,x]}),e[21]=f,e[22]=b,e[23]=x,e[24]=C):C=e[24],C},"_"),vt=i(({hasNext:t,hasPrevious:e,onJumpToPage:n,onNext:o,onPageSizeChange:r,onPrevious:l,pageSize:s,pageSizeOptions:a=ur,prefix:u,rangeEnd:d,rangeStart:g,total:m})=>{let c=X(),f="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",p=s!==void 0&&s>0?Math.max(1,Math.ceil(m/s)):1,h=s!==void 0&&s>0?Math.floor(Math.max(0,g-1)/s)+1:1;return(0,z.jsxs)("div",{className:"flex w-full items-center justify-between gap-3 text-xs text-muted-foreground",children:[(0,z.jsxs)("div",{className:"flex items-center gap-3",children:[s!==void 0&&r!==void 0&&(0,z.jsx)(dr,{onChange:r,options:a,prefix:u,value:s}),(0,z.jsx)("span",{className:"tabular-nums","data-testid":`${u}-page-info`,children:c("{rangeStart}-{rangeEnd} of {total}",{rangeEnd:d,rangeStart:g,total:m})})]}),(0,z.jsxs)("div",{className:"flex items-center gap-3",children:[(0,z.jsx)("button",{className:f,"data-testid":`${u}-prev`,disabled:!e,onClick:l,type:"button",children:c("Previous")}),s!==void 0&&n!==void 0&&(0,z.jsx)(cr,{onJump:n,page:h,pages:p,prefix:u}),(0,z.jsx)("button",{className:f,"data-testid":`${u}-next`,disabled:!t,onClick:o,type:"button",children:c("Next")})]})]})},"Z");function gr(t){return(0,z.jsx)("option",{value:t,children:t},t)}i(gr,"B");var Bn=i(t=>t==null?"\u2205":t===""?"(empty)":typeof t=="object"?JSON.stringify(t):String(t),"S"),fr=i(t=>{let e=(0,Ke.c)(32),{column:n,onFacetFilter:o,state:r}=t,l=X(),s;e[0]!==n||e[1]!==o||e[2]!==r.result?.values?(s=i(w=>{let b=Number(w.currentTarget.dataset.index),x=r.result?.values[b];x!==void 0&&o(n,x.value)},"n"),e[0]=n,e[1]=o,e[2]=r.result?.values,e[3]=s):s=e[3];let a=s,u=`db-facet-${n}`,d;e[4]!==n?(d=(0,z.jsx)("span",{className:"font-medium text-foreground",children:n}),e[4]=n,e[5]=d):d=e[5];let g;e[6]!==r.loading||e[7]!==r.result||e[8]!==l?(g=r.loading&&r.result===null&&(0,z.jsx)("span",{className:"text-muted-foreground",children:l("Loading\u2026")}),e[6]=r.loading,e[7]=r.result,e[8]=l,e[9]=g):g=e[9];let m;e[10]!==r.error?(m=r.error!==null&&(0,z.jsx)("span",{className:"text-destructive",role:"alert",children:r.error}),e[10]=r.error,e[11]=m):m=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 f;if(e[14]!==n||e[15]!==a||e[16]!==c){let w;e[18]!==n||e[19]!==a?(w=i((b,x)=>(0,z.jsxs)("button",{className:"flex items-center justify-between gap-2 rounded px-1 py-0.5 text-left text-muted-foreground transition-colors hover:bg-accent hover:text-accent-foreground","data-index":x,"data-testid":`db-facet-value-${n}`,onClick:a,type:"button",children:[(0,z.jsx)("span",{className:"truncate",children:Bn(b.value)}),(0,z.jsx)("span",{className:"shrink-0 tabular-nums text-foreground/70",children:b.count})]},Bn(b.value)),"u"),e[18]=n,e[19]=a,e[20]=w):w=e[20],f=c.map(w),e[14]=n,e[15]=a,e[16]=c,e[17]=f}else f=e[17];let p;e[21]!==n||e[22]!==r.result||e[23]!==l?(p=r.result?.truncated===!0&&(0,z.jsx)("span",{className:"text-muted-foreground","data-testid":`db-facet-truncated-${n}`,children:l("Showing the {n} most common values.",{n:r.result.values.length})}),e[21]=n,e[22]=r.result,e[23]=l,e[24]=p):p=e[24];let h;return e[25]!==u||e[26]!==d||e[27]!==g||e[28]!==m||e[29]!==f||e[30]!==p?(h=(0,z.jsxs)("section",{className:"flex flex-col gap-1","data-testid":u,children:[d,g,m,f,p]}),e[25]=u,e[26]=d,e[27]=g,e[28]=m,e[29]=f,e[30]=p,e[31]=h):h=e[31],h},"A"),bt=i(t=>{let e=(0,Ke.c)(26),{columns:n,facets:o,onFacetFilter:r,onToggleFacet:l}=t,s=X(),a;e[0]!==l?(a=i(b=>{let{column:x}=b.currentTarget.dataset;x!==void 0&&l(x)},"i"),e[0]=l,e[1]=a):a=e[1];let u=a;if(n.length===0)return null;let d;e[2]!==s?(d=s("Facets"),e[2]=s,e[3]=d):d=e[3];let g;e[4]!==d?(g=(0,z.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:d}),e[4]=d,e[5]=g):g=e[5];let m;if(e[6]!==n||e[7]!==o||e[8]!==u){let b;e[10]!==o||e[11]!==u?(b=i(x=>(0,z.jsx)("button",{"aria-pressed":x in o,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":x,"data-testid":`db-facet-toggle-${x}`,onClick:u,type:"button",children:x},x),"h"),e[10]=o,e[11]=u,e[12]=b):b=e[12],m=n.map(b),e[6]=n,e[7]=o,e[8]=u,e[9]=m}else m=e[9];let c;e[13]!==m?(c=(0,z.jsx)("div",{className:"flex flex-wrap gap-1",children:m}),e[13]=m,e[14]=c):c=e[14];let f;e[15]!==g||e[16]!==c?(f=(0,z.jsxs)("div",{className:"flex flex-col gap-1.5",children:[g,c]}),e[15]=g,e[16]=c,e[17]=f):f=e[17];let p;e[18]!==o?(p=Object.entries(o),e[18]=o,e[19]=p):p=e[19];let h;e[20]!==r||e[21]!==p?(h=p.map(b=>{let[x,C]=b;return(0,z.jsx)(fr,{column:x,onFacetFilter:r,state:C},x)}),e[20]=r,e[21]=p,e[22]=h):h=e[22];let w;return e[23]!==f||e[24]!==h?(w=(0,z.jsxs)("aside",{className:"flex w-56 shrink-0 flex-col gap-3 overflow-auto border-l border-border p-3 text-xs","data-testid":"db-facets",children:[f,h]}),e[23]=f,e[24]=h,e[25]=w):w=e[25],w},"ee");function Ie(t){let e=(0,Ke.c)(2),n=(0,Re.useRef)(t),o;return e[0]!==t?(o=i(()=>{n.current=t},"l"),e[0]=t,e[1]=o):o=e[1],(0,Re.useEffect)(o),n}i(Ie,"D");var wt=i(()=>{let[t,e]=(0,Re.useState)({}),n=Ie(t),o=(0,Re.useRef)({}),r=i(async(l,s)=>{let a=(o.current[l]??0)+1;o.current[l]=a,e(u=>l in u?{...u,[l]:{error:null,loading:!0,result:u[l]?.result??null}}:u);try{let u=await s(l);if(o.current[l]!==a)return;e(d=>l in d?{...d,[l]:{error:null,loading:!1,result:u}}:d)}catch(u){if(o.current[l]!==a)return;e(d=>l in d?{...d,[l]:{error:wn(u),loading:!1,result:null}}:d)}},"r");return{clearFacets:i(()=>{e({})},"clearFacets"),facets:t,facetsRef:n,refetchFacets:i(l=>{for(let s of Object.keys(n.current))Z(r(s,l))},"refetchFacets"),toggleFacet:i((l,s)=>{if(l in n.current){e(a=>Object.fromEntries(Object.entries(a).filter(([u])=>u!==l)));return}e(a=>({...a,[l]:{error:null,loading:!0,result:null}})),s!==null&&Z(r(l,s))},"toggleFacet")}},"te"),jn=34,qn=600,mr=i(t=>{let e=(0,Ke.c)(21),{item:n,onSelect:o,prefix:r,selected:l,start:s}=t,a;e[0]!==n.name||e[1]!==o?(a=i(()=>{o(n.name)},"i"),e[0]=n.name,e[1]=o,e[2]=a):a=e[2];let u=a,d=`translateY(${String(s)}px)`,g;e[3]!==d?(g={insetInline:0,position:"absolute",top:0,transform:d},e[3]=d,e[4]=g):g=e[4];let m=g,c=l?"bg-accent font-medium text-accent-foreground":"text-foreground",f;e[5]!==c?(f=Ue("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]=f):f=e[6];let p=`${r}-table-${n.name}`,h;e[7]!==n.name?(h=(0,z.jsx)("span",{className:"truncate",children:n.name}),e[7]=n.name,e[8]=h):h=e[8];let w;e[9]!==n.rowCount?(w=(0,z.jsx)("span",{className:"shrink-0 rounded bg-muted px-1.5 text-xs tabular-nums text-muted-foreground",children:n.rowCount}),e[9]=n.rowCount,e[10]=w):w=e[10];let b;e[11]!==u||e[12]!==l||e[13]!==f||e[14]!==p||e[15]!==h||e[16]!==w?(b=(0,z.jsxs)("button",{"aria-pressed":l,className:f,"data-testid":p,onClick:u,type:"button",children:[h,w]}),e[11]=u,e[12]=l,e[13]=f,e[14]=p,e[15]=h,e[16]=w,e[17]=b):b=e[17];let x;return e[18]!==m||e[19]!==b?(x=(0,z.jsx)("li",{style:m,children:b}),e[18]=m,e[19]=b,e[20]=x):x=e[20],x},"K"),xt=i(({header:t,onReload:e,onSelect:n,prefix:o,reloadLabel:r,selected:l,tables:s})=>{let a=X(),[u,d]=(0,Re.useState)(""),g=(0,Re.useRef)(null),m=i(h=>{d(h.target.value)},"g"),c=(0,Re.useMemo)(()=>{let h=u.trim().toLowerCase();return h===""?s:s.filter(w=>w.name.toLowerCase().includes(h))},[u,s]),f=mt({count:c.length,estimateSize:i(()=>jn,"estimateSize"),getScrollElement:i(()=>g.current,"getScrollElement"),initialRect:{height:qn,width:240},observeElementRect:i((h,w)=>pt(h,w,qn),"observeElementRect"),overscan:12}).getVirtualItems(),p={height:c.length*jn};return(0,z.jsxs)("aside",{className:"flex h-full w-60 shrink-0 flex-col border-e border-border bg-sidebar","data-testid":`${o}-table-list`,children:[t,(0,z.jsxs)("div",{className:"flex h-9 shrink-0 items-center justify-between gap-2 border-b border-border px-3",children:[(0,z.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:a("Tables")}),e!==void 0&&(0,z.jsx)("button",{"aria-label":r??a("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":`${o}-load-tables`,onClick:e,title:r??a("Refresh"),type:"button",children:(0,z.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,z.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})})})]}),(0,z.jsx)("div",{className:"shrink-0 border-b border-border p-2",children:(0,z.jsx)("input",{className:"h-7 w-full rounded-md border border-border bg-background px-2 text-xs outline-none placeholder:text-muted-foreground focus-visible:border-ring","data-testid":`${o}-table-search`,onChange:m,placeholder:a("search table\u2026"),type:"search",value:u})}),(0,z.jsxs)("ul",{className:"relative flex-1 overflow-y-auto p-1.5","data-testid":`${o}-table-list-rows`,ref:g,children:[(0,z.jsx)("li",{"aria-hidden":"true",style:p}),f.map(h=>{let w=c[h.index];return w===void 0?null:(0,z.jsx)(mr,{item:w,onSelect:n,prefix:o,selected:l===w.name,start:h.start},w.name)})]})]})},"re");var B=ae(rt(),1);var N=ae(We(),1);var at=ae(We(),1);function He(t,e){return typeof t=="function"?t(e):t}i(He,"functionalUpdate");function be(t,e){return n=>{e.setState(o=>({...o,[t]:He(n,o[t])}))}}i(be,"makeStateUpdater");function Rt(t){return t instanceof Function}i(Rt,"isFunction");function pr(t){return Array.isArray(t)&&t.every(e=>typeof e=="number")}i(pr,"isNumberArray");function hr(t,e){let n=[],o=i(r=>{r.forEach(l=>{n.push(l);let s=e(l);s!=null&&s.length&&o(s)})},"recurse");return o(t),n}i(hr,"flattenBy");function I(t,e,n){let o=[],r;return l=>{let s;n.key&&n.debug&&(s=Date.now());let a=t(l);if(!(a.length!==o.length||a.some((g,m)=>o[m]!==g)))return r;o=a;let d;if(n.key&&n.debug&&(d=Date.now()),r=e(...a),n==null||n.onChange==null||n.onChange(r),n.key&&n.debug&&n!=null&&n.debug()){let g=Math.round((Date.now()-s)*100)/100,m=Math.round((Date.now()-d)*100)/100,c=m/16,f=i((p,h)=>{for(p=String(p);p.length<h;)p=" "+p;return p},"pad");console.info(`%c\u23F1 ${f(m,5)} /${f(g,5)} ms`,`
2
2
  font-size: .6rem;
3
3
  font-weight: bold;
4
4
  color: hsl(${Math.max(0,Math.min(120-120*c,120))}deg 100% 31%);`,n?.key)}return r}}i(I,"memo");function D(t,e,n,o){return{debug:i(()=>{var r;return(r=t?.debugAll)!=null?r:t[e]},"debug"),key:!1,onChange:o}}i(D,"getMemoOptions");function vr(t,e,n,o){let r=i(()=>{var s;return(s=l.getValue())!=null?s:t.options.renderFallbackValue},"getRenderValue"),l={id:`${e.id}_${n.id}`,row:e,column:n,getValue:i(()=>e.getValue(o),"getValue"),renderValue:r,getContext:I(()=>[t,n,e,l],(s,a,u,d)=>({table:s,column:a,row:u,cell:d,getValue:d.getValue,renderValue:d.renderValue}),D(t.options,"debugCells","cell.getContext"))};return t._features.forEach(s=>{s.createCell==null||s.createCell(l,n,e,t)},{}),l}i(vr,"createCell");function br(t,e,n,o){var r,l;let a={...t._getDefaultColumnDef(),...e},u=a.accessorKey,d=(r=(l=a.id)!=null?l:u?typeof String.prototype.replaceAll=="function"?u.replaceAll(".","_"):u.replace(/\./g,"_"):void 0)!=null?r:typeof a.header=="string"?a.header:void 0,g;if(a.accessorFn?g=a.accessorFn:u&&(u.includes(".")?g=i(c=>{let f=c;for(let h of u.split(".")){var p;f=(p=f)==null?void 0:p[h]}return f},"accessorFn"):g=i(c=>c[a.accessorKey],"accessorFn")),!d)throw new Error;let m={id:`${String(d)}`,accessorFn:g,parent:o,depth:n,columnDef:a,columns:[],getFlatColumns:I(()=>[!0],()=>{var c;return[m,...(c=m.columns)==null?void 0:c.flatMap(f=>f.getFlatColumns())]},D(t.options,"debugColumns","column.getFlatColumns")),getLeafColumns:I(()=>[t._getOrderColumnsFn()],c=>{var f;if((f=m.columns)!=null&&f.length){let p=m.columns.flatMap(h=>h.getLeafColumns());return c(p)}return[m]},D(t.options,"debugColumns","column.getLeafColumns"))};for(let c of t._features)c.createColumn==null||c.createColumn(m,t);return m}i(br,"createColumn");var de="debugHeaders";function Un(t,e,n){var o;let l={id:(o=n.id)!=null?o:e.id,column:e,index:n.index,isPlaceholder:!!n.isPlaceholder,placeholderId:n.placeholderId,depth:n.depth,subHeaders:[],colSpan:0,rowSpan:0,headerGroup:null,getLeafHeaders:i(()=>{let s=[],a=i(u=>{u.subHeaders&&u.subHeaders.length&&u.subHeaders.map(a),s.push(u)},"recurseHeader");return a(l),s},"getLeafHeaders"),getContext:i(()=>({table:t,header:l,column:e}),"getContext")};return t._features.forEach(s=>{s.createHeader==null||s.createHeader(l,t)}),l}i(Un,"createHeader");var wr={createTable:i(t=>{t.getHeaderGroups=I(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,o,r)=>{var l,s;let a=(l=o?.map(m=>n.find(c=>c.id===m)).filter(Boolean))!=null?l:[],u=(s=r?.map(m=>n.find(c=>c.id===m)).filter(Boolean))!=null?s:[],d=n.filter(m=>!(o!=null&&o.includes(m.id))&&!(r!=null&&r.includes(m.id)));return St(e,[...a,...d,...u],t)},D(t.options,de,"getHeaderGroups")),t.getCenterHeaderGroups=I(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,o,r)=>(n=n.filter(l=>!(o!=null&&o.includes(l.id))&&!(r!=null&&r.includes(l.id))),St(e,n,t,"center")),D(t.options,de,"getCenterHeaderGroups")),t.getLeftHeaderGroups=I(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.left],(e,n,o)=>{var r;let l=(r=o?.map(s=>n.find(a=>a.id===s)).filter(Boolean))!=null?r:[];return St(e,l,t,"left")},D(t.options,de,"getLeftHeaderGroups")),t.getRightHeaderGroups=I(()=>[t.getAllColumns(),t.getVisibleLeafColumns(),t.getState().columnPinning.right],(e,n,o)=>{var r;let l=(r=o?.map(s=>n.find(a=>a.id===s)).filter(Boolean))!=null?r:[];return St(e,l,t,"right")},D(t.options,de,"getRightHeaderGroups")),t.getFooterGroups=I(()=>[t.getHeaderGroups()],e=>[...e].reverse(),D(t.options,de,"getFooterGroups")),t.getLeftFooterGroups=I(()=>[t.getLeftHeaderGroups()],e=>[...e].reverse(),D(t.options,de,"getLeftFooterGroups")),t.getCenterFooterGroups=I(()=>[t.getCenterHeaderGroups()],e=>[...e].reverse(),D(t.options,de,"getCenterFooterGroups")),t.getRightFooterGroups=I(()=>[t.getRightHeaderGroups()],e=>[...e].reverse(),D(t.options,de,"getRightFooterGroups")),t.getFlatHeaders=I(()=>[t.getHeaderGroups()],e=>e.map(n=>n.headers).flat(),D(t.options,de,"getFlatHeaders")),t.getLeftFlatHeaders=I(()=>[t.getLeftHeaderGroups()],e=>e.map(n=>n.headers).flat(),D(t.options,de,"getLeftFlatHeaders")),t.getCenterFlatHeaders=I(()=>[t.getCenterHeaderGroups()],e=>e.map(n=>n.headers).flat(),D(t.options,de,"getCenterFlatHeaders")),t.getRightFlatHeaders=I(()=>[t.getRightHeaderGroups()],e=>e.map(n=>n.headers).flat(),D(t.options,de,"getRightFlatHeaders")),t.getCenterLeafHeaders=I(()=>[t.getCenterFlatHeaders()],e=>e.filter(n=>{var o;return!((o=n.subHeaders)!=null&&o.length)}),D(t.options,de,"getCenterLeafHeaders")),t.getLeftLeafHeaders=I(()=>[t.getLeftFlatHeaders()],e=>e.filter(n=>{var o;return!((o=n.subHeaders)!=null&&o.length)}),D(t.options,de,"getLeftLeafHeaders")),t.getRightLeafHeaders=I(()=>[t.getRightFlatHeaders()],e=>e.filter(n=>{var o;return!((o=n.subHeaders)!=null&&o.length)}),D(t.options,de,"getRightLeafHeaders")),t.getLeafHeaders=I(()=>[t.getLeftHeaderGroups(),t.getCenterHeaderGroups(),t.getRightHeaderGroups()],(e,n,o)=>{var r,l,s,a,u,d;return[...(r=(l=e[0])==null?void 0:l.headers)!=null?r:[],...(s=(a=n[0])==null?void 0:a.headers)!=null?s:[],...(u=(d=o[0])==null?void 0:d.headers)!=null?u:[]].map(g=>g.getLeafHeaders()).flat()},D(t.options,de,"getLeafHeaders"))},"createTable")};function St(t,e,n,o){var r,l;let s=0,a=i(function(c,f){f===void 0&&(f=1),s=Math.max(s,f),c.filter(p=>p.getIsVisible()).forEach(p=>{var h;(h=p.columns)!=null&&h.length&&a(p.columns,f+1)},0)},"findMaxDepth");a(t);let u=[],d=i((c,f)=>{let p={depth:f,id:[o,`${f}`].filter(Boolean).join("_"),headers:[]},h=[];c.forEach(w=>{let b=[...h].reverse()[0],x=w.column.depth===p.depth,C,R=!1;if(x&&w.column.parent?C=w.column.parent:(C=w.column,R=!0),b&&b?.column===C)b.subHeaders.push(w);else{let y=Un(n,C,{id:[o,f,C.id,w?.id].filter(Boolean).join("_"),isPlaceholder:R,placeholderId:R?`${h.filter(_=>_.column===C).length}`:void 0,depth:f,index:h.length});y.subHeaders.push(w),h.push(y)}p.headers.push(w),w.headerGroup=p}),u.push(p),f>0&&d(h,f-1)},"createHeaderGroup"),g=e.map((c,f)=>Un(n,c,{depth:s,index:f}));d(g,s-1),u.reverse();let m=i(c=>c.filter(p=>p.column.getIsVisible()).map(p=>{let h=0,w=0,b=[0];p.subHeaders&&p.subHeaders.length?(b=[],m(p.subHeaders).forEach(C=>{let{colSpan:R,rowSpan:y}=C;h+=R,b.push(y)})):h=1;let x=Math.min(...b);return w=w+x,p.colSpan=h,p.rowSpan=w,{colSpan:h,rowSpan:w}}),"recurseHeadersForSpans");return m((r=(l=u[0])==null?void 0:l.headers)!=null?r:[]),u}i(St,"buildHeaderGroups");var xr=i((t,e,n,o,r,l,s)=>{let a={id:e,index:o,original:n,depth:r,parentId:s,_valuesCache:{},_uniqueValuesCache:{},getValue:i(u=>{if(a._valuesCache.hasOwnProperty(u))return a._valuesCache[u];let d=t.getColumn(u);if(d!=null&&d.accessorFn)return a._valuesCache[u]=d.accessorFn(a.original,o),a._valuesCache[u]},"getValue"),getUniqueValues:i(u=>{if(a._uniqueValuesCache.hasOwnProperty(u))return a._uniqueValuesCache[u];let d=t.getColumn(u);if(d!=null&&d.accessorFn)return d.columnDef.getUniqueValues?(a._uniqueValuesCache[u]=d.columnDef.getUniqueValues(a.original,o),a._uniqueValuesCache[u]):(a._uniqueValuesCache[u]=[a.getValue(u)],a._uniqueValuesCache[u])},"getUniqueValues"),renderValue:i(u=>{var d;return(d=a.getValue(u))!=null?d:t.options.renderFallbackValue},"renderValue"),subRows:l??[],getLeafRows:i(()=>hr(a.subRows,u=>u.subRows),"getLeafRows"),getParentRow:i(()=>a.parentId?t.getRow(a.parentId,!0):void 0,"getParentRow"),getParentRows:i(()=>{let u=[],d=a;for(;;){let g=d.getParentRow();if(!g)break;u.push(g),d=g}return u.reverse()},"getParentRows"),getAllCells:I(()=>[t.getAllLeafColumns()],u=>u.map(d=>vr(t,a,d,d.id)),D(t.options,"debugRows","getAllCells")),_getAllCellsByColumnId:I(()=>[a.getAllCells()],u=>u.reduce((d,g)=>(d[g.column.id]=g,d),{}),D(t.options,"debugRows","getAllCellsByColumnId"))};for(let u=0;u<t._features.length;u++){let d=t._features[u];d==null||d.createRow==null||d.createRow(a,t)}return a},"createRow"),Sr={createColumn:i((t,e)=>{t._getFacetedRowModel=e.options.getFacetedRowModel&&e.options.getFacetedRowModel(e,t.id),t.getFacetedRowModel=()=>t._getFacetedRowModel?t._getFacetedRowModel():e.getPreFilteredRowModel(),t._getFacetedUniqueValues=e.options.getFacetedUniqueValues&&e.options.getFacetedUniqueValues(e,t.id),t.getFacetedUniqueValues=()=>t._getFacetedUniqueValues?t._getFacetedUniqueValues():new Map,t._getFacetedMinMaxValues=e.options.getFacetedMinMaxValues&&e.options.getFacetedMinMaxValues(e,t.id),t.getFacetedMinMaxValues=()=>{if(t._getFacetedMinMaxValues)return t._getFacetedMinMaxValues()}},"createColumn")},Kn=i((t,e,n)=>{var o,r;let l=n==null||(o=n.toString())==null?void 0:o.toLowerCase();return!!(!((r=t.getValue(e))==null||(r=r.toString())==null||(r=r.toLowerCase())==null)&&r.includes(l))},"includesString");Kn.autoRemove=t=>_e(t);var Qn=i((t,e,n)=>{var o;return!!(!((o=t.getValue(e))==null||(o=o.toString())==null)&&o.includes(n))},"includesStringSensitive");Qn.autoRemove=t=>_e(t);var Wn=i((t,e,n)=>{var o;return((o=t.getValue(e))==null||(o=o.toString())==null?void 0:o.toLowerCase())===n?.toLowerCase()},"equalsString");Wn.autoRemove=t=>_e(t);var Xn=i((t,e,n)=>{var o;return(o=t.getValue(e))==null?void 0:o.includes(n)},"arrIncludes");Xn.autoRemove=t=>_e(t);var Zn=i((t,e,n)=>!n.some(o=>{var r;return!((r=t.getValue(e))!=null&&r.includes(o))}),"arrIncludesAll");Zn.autoRemove=t=>_e(t)||!(t!=null&&t.length);var Yn=i((t,e,n)=>n.some(o=>{var r;return(r=t.getValue(e))==null?void 0:r.includes(o)}),"arrIncludesSome");Yn.autoRemove=t=>_e(t)||!(t!=null&&t.length);var eo=i((t,e,n)=>t.getValue(e)===n,"equals");eo.autoRemove=t=>_e(t);var to=i((t,e,n)=>t.getValue(e)==n,"weakEquals");to.autoRemove=t=>_e(t);var tn=i((t,e,n)=>{let[o,r]=n,l=t.getValue(e);return l>=o&&l<=r},"inNumberRange");tn.resolveFilterValue=t=>{let[e,n]=t,o=typeof e!="number"?parseFloat(e):e,r=typeof n!="number"?parseFloat(n):n,l=e===null||Number.isNaN(o)?-1/0:o,s=n===null||Number.isNaN(r)?1/0:r;if(l>s){let a=l;l=s,s=a}return[l,s]};tn.autoRemove=t=>_e(t)||_e(t[0])&&_e(t[1]);var De={includesString:Kn,includesStringSensitive:Qn,equalsString:Wn,arrIncludes:Xn,arrIncludesAll:Zn,arrIncludesSome:Yn,equals:eo,weakEquals:to,inNumberRange:tn};function _e(t){return t==null||t===""}i(_e,"testFalsey");var Cr={getDefaultColumnDef:i(()=>({filterFn:"auto"}),"getDefaultColumnDef"),getInitialState:i(t=>({columnFilters:[],...t}),"getInitialState"),getDefaultOptions:i(t=>({onColumnFiltersChange:be("columnFilters",t),filterFromLeafRows:!1,maxLeafRowFilterDepth:100}),"getDefaultOptions"),createColumn:i((t,e)=>{t.getAutoFilterFn=()=>{let n=e.getCoreRowModel().flatRows[0],o=n?.getValue(t.id);return typeof o=="string"?De.includesString:typeof o=="number"?De.inNumberRange:typeof o=="boolean"||o!==null&&typeof o=="object"?De.equals:Array.isArray(o)?De.arrIncludes:De.weakEquals},t.getFilterFn=()=>{var n,o;return Rt(t.columnDef.filterFn)?t.columnDef.filterFn:t.columnDef.filterFn==="auto"?t.getAutoFilterFn():(n=(o=e.options.filterFns)==null?void 0:o[t.columnDef.filterFn])!=null?n:De[t.columnDef.filterFn]},t.getCanFilter=()=>{var n,o,r;return((n=t.columnDef.enableColumnFilter)!=null?n:!0)&&((o=e.options.enableColumnFilters)!=null?o:!0)&&((r=e.options.enableFilters)!=null?r:!0)&&!!t.accessorFn},t.getIsFiltered=()=>t.getFilterIndex()>-1,t.getFilterValue=()=>{var n;return(n=e.getState().columnFilters)==null||(n=n.find(o=>o.id===t.id))==null?void 0:n.value},t.getFilterIndex=()=>{var n,o;return(n=(o=e.getState().columnFilters)==null?void 0:o.findIndex(r=>r.id===t.id))!=null?n:-1},t.setFilterValue=n=>{e.setColumnFilters(o=>{let r=t.getFilterFn(),l=o?.find(g=>g.id===t.id),s=He(n,l?l.value:void 0);if(Jn(r,s,t)){var a;return(a=o?.filter(g=>g.id!==t.id))!=null?a:[]}let u={id:t.id,value:s};if(l){var d;return(d=o?.map(g=>g.id===t.id?u:g))!=null?d:[]}return o!=null&&o.length?[...o,u]:[u]})}},"createColumn"),createRow:i((t,e)=>{t.columnFilters={},t.columnFiltersMeta={}},"createRow"),createTable:i(t=>{t.setColumnFilters=e=>{let n=t.getAllLeafColumns(),o=i(r=>{var l;return(l=He(e,r))==null?void 0:l.filter(s=>{let a=n.find(u=>u.id===s.id);if(a){let u=a.getFilterFn();if(Jn(u,s.value,a))return!1}return!0})},"updateFn");t.options.onColumnFiltersChange==null||t.options.onColumnFiltersChange(o)},t.resetColumnFilters=e=>{var n,o;t.setColumnFilters(e?[]:(n=(o=t.initialState)==null?void 0:o.columnFilters)!=null?n:[])},t.getPreFilteredRowModel=()=>t.getCoreRowModel(),t.getFilteredRowModel=()=>(!t._getFilteredRowModel&&t.options.getFilteredRowModel&&(t._getFilteredRowModel=t.options.getFilteredRowModel(t)),t.options.manualFiltering||!t._getFilteredRowModel?t.getPreFilteredRowModel():t._getFilteredRowModel())},"createTable")};function Jn(t,e,n){return(t&&t.autoRemove?t.autoRemove(e,n):!1)||typeof e>"u"||typeof e=="string"&&!e}i(Jn,"shouldAutoRemoveFilter");var yr=i((t,e,n)=>n.reduce((o,r)=>{let l=r.getValue(t);return o+(typeof l=="number"?l:0)},0),"sum"),Rr=i((t,e,n)=>{let o;return n.forEach(r=>{let l=r.getValue(t);l!=null&&(o>l||o===void 0&&l>=l)&&(o=l)}),o},"min"),_r=i((t,e,n)=>{let o;return n.forEach(r=>{let l=r.getValue(t);l!=null&&(o<l||o===void 0&&l>=l)&&(o=l)}),o},"max"),Fr=i((t,e,n)=>{let o,r;return n.forEach(l=>{let s=l.getValue(t);s!=null&&(o===void 0?s>=s&&(o=r=s):(o>s&&(o=s),r<s&&(r=s)))}),[o,r]},"extent"),$r=i((t,e)=>{let n=0,o=0;if(e.forEach(r=>{let l=r.getValue(t);l!=null&&(l=+l)>=l&&(++n,o+=l)}),n)return o/n},"mean"),Nr=i((t,e)=>{if(!e.length)return;let n=e.map(l=>l.getValue(t));if(!pr(n))return;if(n.length===1)return n[0];let o=Math.floor(n.length/2),r=n.sort((l,s)=>l-s);return n.length%2!==0?r[o]:(r[o-1]+r[o])/2},"median"),Mr=i((t,e)=>Array.from(new Set(e.map(n=>n.getValue(t))).values()),"unique"),Pr=i((t,e)=>new Set(e.map(n=>n.getValue(t))).size,"uniqueCount"),kr=i((t,e)=>e.length,"count"),Bt={sum:yr,min:Rr,max:_r,extent:Fr,mean:$r,median:Nr,unique:Mr,uniqueCount:Pr,count:kr},Vr={getDefaultColumnDef:i(()=>({aggregatedCell:i(t=>{var e,n;return(e=(n=t.getValue())==null||n.toString==null?void 0:n.toString())!=null?e:null},"aggregatedCell"),aggregationFn:"auto"}),"getDefaultColumnDef"),getInitialState:i(t=>({grouping:[],...t}),"getInitialState"),getDefaultOptions:i(t=>({onGroupingChange:be("grouping",t),groupedColumnMode:"reorder"}),"getDefaultOptions"),createColumn:i((t,e)=>{t.toggleGrouping=()=>{e.setGrouping(n=>n!=null&&n.includes(t.id)?n.filter(o=>o!==t.id):[...n??[],t.id])},t.getCanGroup=()=>{var n,o;return((n=t.columnDef.enableGrouping)!=null?n:!0)&&((o=e.options.enableGrouping)!=null?o:!0)&&(!!t.accessorFn||!!t.columnDef.getGroupingValue)},t.getIsGrouped=()=>{var n;return(n=e.getState().grouping)==null?void 0:n.includes(t.id)},t.getGroupedIndex=()=>{var n;return(n=e.getState().grouping)==null?void 0:n.indexOf(t.id)},t.getToggleGroupingHandler=()=>{let n=t.getCanGroup();return()=>{n&&t.toggleGrouping()}},t.getAutoAggregationFn=()=>{let n=e.getCoreRowModel().flatRows[0],o=n?.getValue(t.id);if(typeof o=="number")return Bt.sum;if(Object.prototype.toString.call(o)==="[object Date]")return Bt.extent},t.getAggregationFn=()=>{var n,o;if(!t)throw new Error;return Rt(t.columnDef.aggregationFn)?t.columnDef.aggregationFn:t.columnDef.aggregationFn==="auto"?t.getAutoAggregationFn():(n=(o=e.options.aggregationFns)==null?void 0:o[t.columnDef.aggregationFn])!=null?n:Bt[t.columnDef.aggregationFn]}},"createColumn"),createTable:i(t=>{t.setGrouping=e=>t.options.onGroupingChange==null?void 0:t.options.onGroupingChange(e),t.resetGrouping=e=>{var n,o;t.setGrouping(e?[]:(n=(o=t.initialState)==null?void 0:o.grouping)!=null?n:[])},t.getPreGroupedRowModel=()=>t.getFilteredRowModel(),t.getGroupedRowModel=()=>(!t._getGroupedRowModel&&t.options.getGroupedRowModel&&(t._getGroupedRowModel=t.options.getGroupedRowModel(t)),t.options.manualGrouping||!t._getGroupedRowModel?t.getPreGroupedRowModel():t._getGroupedRowModel())},"createTable"),createRow:i((t,e)=>{t.getIsGrouped=()=>!!t.groupingColumnId,t.getGroupingValue=n=>{if(t._groupingValuesCache.hasOwnProperty(n))return t._groupingValuesCache[n];let o=e.getColumn(n);return o!=null&&o.columnDef.getGroupingValue?(t._groupingValuesCache[n]=o.columnDef.getGroupingValue(t.original),t._groupingValuesCache[n]):t.getValue(n)},t._groupingValuesCache={}},"createRow"),createCell:i((t,e,n,o)=>{t.getIsGrouped=()=>e.getIsGrouped()&&e.id===n.groupingColumnId,t.getIsPlaceholder=()=>!t.getIsGrouped()&&e.getIsGrouped(),t.getIsAggregated=()=>{var r;return!t.getIsGrouped()&&!t.getIsPlaceholder()&&!!((r=n.subRows)!=null&&r.length)}},"createCell")};function Er(t,e,n){if(!(e!=null&&e.length)||!n)return t;let o=t.filter(l=>!e.includes(l.id));return n==="remove"?o:[...e.map(l=>t.find(s=>s.id===l)).filter(Boolean),...o]}i(Er,"orderColumns");var Ir={getInitialState:i(t=>({columnOrder:[],...t}),"getInitialState"),getDefaultOptions:i(t=>({onColumnOrderChange:be("columnOrder",t)}),"getDefaultOptions"),createColumn:i((t,e)=>{t.getIndex=I(n=>[st(e,n)],n=>n.findIndex(o=>o.id===t.id),D(e.options,"debugColumns","getIndex")),t.getIsFirstColumn=n=>{var o;return((o=st(e,n)[0])==null?void 0:o.id)===t.id},t.getIsLastColumn=n=>{var o;let r=st(e,n);return((o=r[r.length-1])==null?void 0:o.id)===t.id}},"createColumn"),createTable:i(t=>{t.setColumnOrder=e=>t.options.onColumnOrderChange==null?void 0:t.options.onColumnOrderChange(e),t.resetColumnOrder=e=>{var n;t.setColumnOrder(e?[]:(n=t.initialState.columnOrder)!=null?n:[])},t._getOrderColumnsFn=I(()=>[t.getState().columnOrder,t.getState().grouping,t.options.groupedColumnMode],(e,n,o)=>r=>{let l=[];if(!(e!=null&&e.length))l=r;else{let s=[...e],a=[...r];for(;a.length&&s.length;){let u=s.shift(),d=a.findIndex(g=>g.id===u);d>-1&&l.push(a.splice(d,1)[0])}l=[...l,...a]}return Er(l,n,o)},D(t.options,"debugTable","_getOrderColumnsFn"))},"createTable")},jt=i(()=>({left:[],right:[]}),"getDefaultColumnPinningState"),Dr={getInitialState:i(t=>({columnPinning:jt(),...t}),"getInitialState"),getDefaultOptions:i(t=>({onColumnPinningChange:be("columnPinning",t)}),"getDefaultOptions"),createColumn:i((t,e)=>{t.pin=n=>{let o=t.getLeafColumns().map(r=>r.id).filter(Boolean);e.setColumnPinning(r=>{var l,s;if(n==="right"){var a,u;return{left:((a=r?.left)!=null?a:[]).filter(m=>!(o!=null&&o.includes(m))),right:[...((u=r?.right)!=null?u:[]).filter(m=>!(o!=null&&o.includes(m))),...o]}}if(n==="left"){var d,g;return{left:[...((d=r?.left)!=null?d:[]).filter(m=>!(o!=null&&o.includes(m))),...o],right:((g=r?.right)!=null?g:[]).filter(m=>!(o!=null&&o.includes(m)))}}return{left:((l=r?.left)!=null?l:[]).filter(m=>!(o!=null&&o.includes(m))),right:((s=r?.right)!=null?s:[]).filter(m=>!(o!=null&&o.includes(m)))}})},t.getCanPin=()=>t.getLeafColumns().some(o=>{var r,l,s;return((r=o.columnDef.enablePinning)!=null?r:!0)&&((l=(s=e.options.enableColumnPinning)!=null?s:e.options.enablePinning)!=null?l:!0)}),t.getIsPinned=()=>{let n=t.getLeafColumns().map(a=>a.id),{left:o,right:r}=e.getState().columnPinning,l=n.some(a=>o?.includes(a)),s=n.some(a=>r?.includes(a));return l?"left":s?"right":!1},t.getPinnedIndex=()=>{var n,o;let r=t.getIsPinned();return r?(n=(o=e.getState().columnPinning)==null||(o=o[r])==null?void 0:o.indexOf(t.id))!=null?n:-1:0}},"createColumn"),createRow:i((t,e)=>{t.getCenterVisibleCells=I(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left,e.getState().columnPinning.right],(n,o,r)=>{let l=[...o??[],...r??[]];return n.filter(s=>!l.includes(s.column.id))},D(e.options,"debugRows","getCenterVisibleCells")),t.getLeftVisibleCells=I(()=>[t._getAllVisibleCells(),e.getState().columnPinning.left],(n,o)=>(o??[]).map(l=>n.find(s=>s.column.id===l)).filter(Boolean).map(l=>({...l,position:"left"})),D(e.options,"debugRows","getLeftVisibleCells")),t.getRightVisibleCells=I(()=>[t._getAllVisibleCells(),e.getState().columnPinning.right],(n,o)=>(o??[]).map(l=>n.find(s=>s.column.id===l)).filter(Boolean).map(l=>({...l,position:"right"})),D(e.options,"debugRows","getRightVisibleCells"))},"createRow"),createTable:i(t=>{t.setColumnPinning=e=>t.options.onColumnPinningChange==null?void 0:t.options.onColumnPinningChange(e),t.resetColumnPinning=e=>{var n,o;return t.setColumnPinning(e?jt():(n=(o=t.initialState)==null?void 0:o.columnPinning)!=null?n:jt())},t.getIsSomeColumnsPinned=e=>{var n;let o=t.getState().columnPinning;if(!e){var r,l;return!!((r=o.left)!=null&&r.length||(l=o.right)!=null&&l.length)}return!!((n=o[e])!=null&&n.length)},t.getLeftLeafColumns=I(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left],(e,n)=>(n??[]).map(o=>e.find(r=>r.id===o)).filter(Boolean),D(t.options,"debugColumns","getLeftLeafColumns")),t.getRightLeafColumns=I(()=>[t.getAllLeafColumns(),t.getState().columnPinning.right],(e,n)=>(n??[]).map(o=>e.find(r=>r.id===o)).filter(Boolean),D(t.options,"debugColumns","getRightLeafColumns")),t.getCenterLeafColumns=I(()=>[t.getAllLeafColumns(),t.getState().columnPinning.left,t.getState().columnPinning.right],(e,n,o)=>{let r=[...n??[],...o??[]];return e.filter(l=>!r.includes(l.id))},D(t.options,"debugColumns","getCenterLeafColumns"))},"createTable")};function Tr(t){return t||(typeof document<"u"?document:null)}i(Tr,"safelyAccessDocument");var Ct={size:150,minSize:20,maxSize:Number.MAX_SAFE_INTEGER},qt=i(()=>({startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,isResizingColumn:!1,columnSizingStart:[]}),"getDefaultColumnSizingInfoState"),zr={getDefaultColumnDef:i(()=>Ct,"getDefaultColumnDef"),getInitialState:i(t=>({columnSizing:{},columnSizingInfo:qt(),...t}),"getInitialState"),getDefaultOptions:i(t=>({columnResizeMode:"onEnd",columnResizeDirection:"ltr",onColumnSizingChange:be("columnSizing",t),onColumnSizingInfoChange:be("columnSizingInfo",t)}),"getDefaultOptions"),createColumn:i((t,e)=>{t.getSize=()=>{var n,o,r;let l=e.getState().columnSizing[t.id];return Math.min(Math.max((n=t.columnDef.minSize)!=null?n:Ct.minSize,(o=l??t.columnDef.size)!=null?o:Ct.size),(r=t.columnDef.maxSize)!=null?r:Ct.maxSize)},t.getStart=I(n=>[n,st(e,n),e.getState().columnSizing],(n,o)=>o.slice(0,t.getIndex(n)).reduce((r,l)=>r+l.getSize(),0),D(e.options,"debugColumns","getStart")),t.getAfter=I(n=>[n,st(e,n),e.getState().columnSizing],(n,o)=>o.slice(t.getIndex(n)+1).reduce((r,l)=>r+l.getSize(),0),D(e.options,"debugColumns","getAfter")),t.resetSize=()=>{e.setColumnSizing(n=>{let{[t.id]:o,...r}=n;return r})},t.getCanResize=()=>{var n,o;return((n=t.columnDef.enableResizing)!=null?n:!0)&&((o=e.options.enableColumnResizing)!=null?o:!0)},t.getIsResizing=()=>e.getState().columnSizingInfo.isResizingColumn===t.id},"createColumn"),createHeader:i((t,e)=>{t.getSize=()=>{let n=0,o=i(r=>{if(r.subHeaders.length)r.subHeaders.forEach(o);else{var l;n+=(l=r.column.getSize())!=null?l:0}},"recurse");return o(t),n},t.getStart=()=>{if(t.index>0){let n=t.headerGroup.headers[t.index-1];return n.getStart()+n.getSize()}return 0},t.getResizeHandler=n=>{let o=e.getColumn(t.column.id),r=o?.getCanResize();return l=>{if(!o||!r||(l.persist==null||l.persist(),Ut(l)&&l.touches&&l.touches.length>1))return;let s=t.getSize(),a=t?t.getLeafHeaders().map(b=>[b.column.id,b.column.getSize()]):[[o.id,o.getSize()]],u=Ut(l)?Math.round(l.touches[0].clientX):l.clientX,d={},g=i((b,x)=>{typeof x=="number"&&(e.setColumnSizingInfo(C=>{var R,y;let _=e.options.columnResizeDirection==="rtl"?-1:1,S=(x-((R=C?.startOffset)!=null?R:0))*_,F=Math.max(S/((y=C?.startSize)!=null?y:0),-.999999);return C.columnSizingStart.forEach(V=>{let[$,M]=V;d[$]=Math.round(Math.max(M+M*F,0)*100)/100}),{...C,deltaOffset:S,deltaPercentage:F}}),(e.options.columnResizeMode==="onChange"||b==="end")&&e.setColumnSizing(C=>({...C,...d})))},"updateOffset"),m=i(b=>g("move",b),"onMove"),c=i(b=>{g("end",b),e.setColumnSizingInfo(x=>({...x,isResizingColumn:!1,startOffset:null,startSize:null,deltaOffset:null,deltaPercentage:null,columnSizingStart:[]}))},"onEnd"),f=Tr(n),p={moveHandler:i(b=>m(b.clientX),"moveHandler"),upHandler:i(b=>{f?.removeEventListener("mousemove",p.moveHandler),f?.removeEventListener("mouseup",p.upHandler),c(b.clientX)},"upHandler")},h={moveHandler:i(b=>(b.cancelable&&(b.preventDefault(),b.stopPropagation()),m(b.touches[0].clientX),!1),"moveHandler"),upHandler:i(b=>{var x;f?.removeEventListener("touchmove",h.moveHandler),f?.removeEventListener("touchend",h.upHandler),b.cancelable&&(b.preventDefault(),b.stopPropagation()),c((x=b.touches[0])==null?void 0:x.clientX)},"upHandler")},w=Lr()?{passive:!1}:!1;Ut(l)?(f?.addEventListener("touchmove",h.moveHandler,w),f?.addEventListener("touchend",h.upHandler,w)):(f?.addEventListener("mousemove",p.moveHandler,w),f?.addEventListener("mouseup",p.upHandler,w)),e.setColumnSizingInfo(b=>({...b,startOffset:u,startSize:s,deltaOffset:0,deltaPercentage:0,columnSizingStart:a,isResizingColumn:o.id}))}}},"createHeader"),createTable:i(t=>{t.setColumnSizing=e=>t.options.onColumnSizingChange==null?void 0:t.options.onColumnSizingChange(e),t.setColumnSizingInfo=e=>t.options.onColumnSizingInfoChange==null?void 0:t.options.onColumnSizingInfoChange(e),t.resetColumnSizing=e=>{var n;t.setColumnSizing(e?{}:(n=t.initialState.columnSizing)!=null?n:{})},t.resetHeaderSizeInfo=e=>{var n;t.setColumnSizingInfo(e?qt():(n=t.initialState.columnSizingInfo)!=null?n:qt())},t.getTotalSize=()=>{var e,n;return(e=(n=t.getHeaderGroups()[0])==null?void 0:n.headers.reduce((o,r)=>o+r.getSize(),0))!=null?e:0},t.getLeftTotalSize=()=>{var e,n;return(e=(n=t.getLeftHeaderGroups()[0])==null?void 0:n.headers.reduce((o,r)=>o+r.getSize(),0))!=null?e:0},t.getCenterTotalSize=()=>{var e,n;return(e=(n=t.getCenterHeaderGroups()[0])==null?void 0:n.headers.reduce((o,r)=>o+r.getSize(),0))!=null?e:0},t.getRightTotalSize=()=>{var e,n;return(e=(n=t.getRightHeaderGroups()[0])==null?void 0:n.headers.reduce((o,r)=>o+r.getSize(),0))!=null?e:0}},"createTable")},yt=null;function Lr(){if(typeof yt=="boolean")return yt;let t=!1;try{let e={get passive(){return t=!0,!1}},n=i(()=>{},"noop");window.addEventListener("test",n,e),window.removeEventListener("test",n)}catch{t=!1}return yt=t,yt}i(Lr,"passiveEventSupported");function Ut(t){return t.type==="touchstart"}i(Ut,"isTouchStartEvent");var Or={getInitialState:i(t=>({columnVisibility:{},...t}),"getInitialState"),getDefaultOptions:i(t=>({onColumnVisibilityChange:be("columnVisibility",t)}),"getDefaultOptions"),createColumn:i((t,e)=>{t.toggleVisibility=n=>{t.getCanHide()&&e.setColumnVisibility(o=>({...o,[t.id]:n??!t.getIsVisible()}))},t.getIsVisible=()=>{var n,o;let r=t.columns;return(n=r.length?r.some(l=>l.getIsVisible()):(o=e.getState().columnVisibility)==null?void 0:o[t.id])!=null?n:!0},t.getCanHide=()=>{var n,o;return((n=t.columnDef.enableHiding)!=null?n:!0)&&((o=e.options.enableHiding)!=null?o:!0)},t.getToggleVisibilityHandler=()=>n=>{t.toggleVisibility==null||t.toggleVisibility(n.target.checked)}},"createColumn"),createRow:i((t,e)=>{t._getAllVisibleCells=I(()=>[t.getAllCells(),e.getState().columnVisibility],n=>n.filter(o=>o.column.getIsVisible()),D(e.options,"debugRows","_getAllVisibleCells")),t.getVisibleCells=I(()=>[t.getLeftVisibleCells(),t.getCenterVisibleCells(),t.getRightVisibleCells()],(n,o,r)=>[...n,...o,...r],D(e.options,"debugRows","getVisibleCells"))},"createRow"),createTable:i(t=>{let e=i((n,o)=>I(()=>[o(),o().filter(r=>r.getIsVisible()).map(r=>r.id).join("_")],r=>r.filter(l=>l.getIsVisible==null?void 0:l.getIsVisible()),D(t.options,"debugColumns",n)),"makeVisibleColumnsMethod");t.getVisibleFlatColumns=e("getVisibleFlatColumns",()=>t.getAllFlatColumns()),t.getVisibleLeafColumns=e("getVisibleLeafColumns",()=>t.getAllLeafColumns()),t.getLeftVisibleLeafColumns=e("getLeftVisibleLeafColumns",()=>t.getLeftLeafColumns()),t.getRightVisibleLeafColumns=e("getRightVisibleLeafColumns",()=>t.getRightLeafColumns()),t.getCenterVisibleLeafColumns=e("getCenterVisibleLeafColumns",()=>t.getCenterLeafColumns()),t.setColumnVisibility=n=>t.options.onColumnVisibilityChange==null?void 0:t.options.onColumnVisibilityChange(n),t.resetColumnVisibility=n=>{var o;t.setColumnVisibility(n?{}:(o=t.initialState.columnVisibility)!=null?o:{})},t.toggleAllColumnsVisible=n=>{var o;n=(o=n)!=null?o:!t.getIsAllColumnsVisible(),t.setColumnVisibility(t.getAllLeafColumns().reduce((r,l)=>({...r,[l.id]:n||!(l.getCanHide!=null&&l.getCanHide())}),{}))},t.getIsAllColumnsVisible=()=>!t.getAllLeafColumns().some(n=>!(n.getIsVisible!=null&&n.getIsVisible())),t.getIsSomeColumnsVisible=()=>t.getAllLeafColumns().some(n=>n.getIsVisible==null?void 0:n.getIsVisible()),t.getToggleAllColumnsVisibilityHandler=()=>n=>{var o;t.toggleAllColumnsVisible((o=n.target)==null?void 0:o.checked)}},"createTable")};function st(t,e){return e?e==="center"?t.getCenterVisibleLeafColumns():e==="left"?t.getLeftVisibleLeafColumns():t.getRightVisibleLeafColumns():t.getVisibleLeafColumns()}i(st,"_getVisibleLeafColumns");var Ar={createTable:i(t=>{t._getGlobalFacetedRowModel=t.options.getFacetedRowModel&&t.options.getFacetedRowModel(t,"__global__"),t.getGlobalFacetedRowModel=()=>t.options.manualFiltering||!t._getGlobalFacetedRowModel?t.getPreFilteredRowModel():t._getGlobalFacetedRowModel(),t._getGlobalFacetedUniqueValues=t.options.getFacetedUniqueValues&&t.options.getFacetedUniqueValues(t,"__global__"),t.getGlobalFacetedUniqueValues=()=>t._getGlobalFacetedUniqueValues?t._getGlobalFacetedUniqueValues():new Map,t._getGlobalFacetedMinMaxValues=t.options.getFacetedMinMaxValues&&t.options.getFacetedMinMaxValues(t,"__global__"),t.getGlobalFacetedMinMaxValues=()=>{if(t._getGlobalFacetedMinMaxValues)return t._getGlobalFacetedMinMaxValues()}},"createTable")},Gr={getInitialState:i(t=>({globalFilter:void 0,...t}),"getInitialState"),getDefaultOptions:i(t=>({onGlobalFilterChange:be("globalFilter",t),globalFilterFn:"auto",getColumnCanGlobalFilter:i(e=>{var n;let o=(n=t.getCoreRowModel().flatRows[0])==null||(n=n._getAllCellsByColumnId()[e.id])==null?void 0:n.getValue();return typeof o=="string"||typeof o=="number"},"getColumnCanGlobalFilter")}),"getDefaultOptions"),createColumn:i((t,e)=>{t.getCanGlobalFilter=()=>{var n,o,r,l;return((n=t.columnDef.enableGlobalFilter)!=null?n:!0)&&((o=e.options.enableGlobalFilter)!=null?o:!0)&&((r=e.options.enableFilters)!=null?r:!0)&&((l=e.options.getColumnCanGlobalFilter==null?void 0:e.options.getColumnCanGlobalFilter(t))!=null?l:!0)&&!!t.accessorFn}},"createColumn"),createTable:i(t=>{t.getGlobalAutoFilterFn=()=>De.includesString,t.getGlobalFilterFn=()=>{var e,n;let{globalFilterFn:o}=t.options;return Rt(o)?o:o==="auto"?t.getGlobalAutoFilterFn():(e=(n=t.options.filterFns)==null?void 0:n[o])!=null?e:De[o]},t.setGlobalFilter=e=>{t.options.onGlobalFilterChange==null||t.options.onGlobalFilterChange(e)},t.resetGlobalFilter=e=>{t.setGlobalFilter(e?void 0:t.initialState.globalFilter)}},"createTable")},Hr={getInitialState:i(t=>({expanded:{},...t}),"getInitialState"),getDefaultOptions:i(t=>({onExpandedChange:be("expanded",t),paginateExpandedRows:!0}),"getDefaultOptions"),createTable:i(t=>{let e=!1,n=!1;t._autoResetExpanded=()=>{var o,r;if(!e){t._queue(()=>{e=!0});return}if((o=(r=t.options.autoResetAll)!=null?r:t.options.autoResetExpanded)!=null?o:!t.options.manualExpanding){if(n)return;n=!0,t._queue(()=>{t.resetExpanded(),n=!1})}},t.setExpanded=o=>t.options.onExpandedChange==null?void 0:t.options.onExpandedChange(o),t.toggleAllRowsExpanded=o=>{o??!t.getIsAllRowsExpanded()?t.setExpanded(!0):t.setExpanded({})},t.resetExpanded=o=>{var r,l;t.setExpanded(o?{}:(r=(l=t.initialState)==null?void 0:l.expanded)!=null?r:{})},t.getCanSomeRowsExpand=()=>t.getPrePaginationRowModel().flatRows.some(o=>o.getCanExpand()),t.getToggleAllRowsExpandedHandler=()=>o=>{o.persist==null||o.persist(),t.toggleAllRowsExpanded()},t.getIsSomeRowsExpanded=()=>{let o=t.getState().expanded;return o===!0||Object.values(o).some(Boolean)},t.getIsAllRowsExpanded=()=>{let o=t.getState().expanded;return typeof o=="boolean"?o===!0:!(!Object.keys(o).length||t.getRowModel().flatRows.some(r=>!r.getIsExpanded()))},t.getExpandedDepth=()=>{let o=0;return(t.getState().expanded===!0?Object.keys(t.getRowModel().rowsById):Object.keys(t.getState().expanded)).forEach(l=>{let s=l.split(".");o=Math.max(o,s.length)}),o},t.getPreExpandedRowModel=()=>t.getSortedRowModel(),t.getExpandedRowModel=()=>(!t._getExpandedRowModel&&t.options.getExpandedRowModel&&(t._getExpandedRowModel=t.options.getExpandedRowModel(t)),t.options.manualExpanding||!t._getExpandedRowModel?t.getPreExpandedRowModel():t._getExpandedRowModel())},"createTable"),createRow:i((t,e)=>{t.toggleExpanded=n=>{e.setExpanded(o=>{var r;let l=o===!0?!0:!!(o!=null&&o[t.id]),s={};if(o===!0?Object.keys(e.getRowModel().rowsById).forEach(a=>{s[a]=!0}):s=o,n=(r=n)!=null?r:!l,!l&&n)return{...s,[t.id]:!0};if(l&&!n){let{[t.id]:a,...u}=s;return u}return o})},t.getIsExpanded=()=>{var n;let o=e.getState().expanded;return!!((n=e.options.getIsRowExpanded==null?void 0:e.options.getIsRowExpanded(t))!=null?n:o===!0||o?.[t.id])},t.getCanExpand=()=>{var n,o,r;return(n=e.options.getRowCanExpand==null?void 0:e.options.getRowCanExpand(t))!=null?n:((o=e.options.enableExpanding)!=null?o:!0)&&!!((r=t.subRows)!=null&&r.length)},t.getIsAllParentsExpanded=()=>{let n=!0,o=t;for(;n&&o.parentId;)o=e.getRow(o.parentId,!0),n=o.getIsExpanded();return n},t.getToggleExpandedHandler=()=>{let n=t.getCanExpand();return()=>{n&&t.toggleExpanded()}}},"createRow")},Wt=0,Xt=10,Jt=i(()=>({pageIndex:Wt,pageSize:Xt}),"getDefaultPaginationState"),Br={getInitialState:i(t=>({...t,pagination:{...Jt(),...t?.pagination}}),"getInitialState"),getDefaultOptions:i(t=>({onPaginationChange:be("pagination",t)}),"getDefaultOptions"),createTable:i(t=>{let e=!1,n=!1;t._autoResetPageIndex=()=>{var o,r;if(!e){t._queue(()=>{e=!0});return}if((o=(r=t.options.autoResetAll)!=null?r:t.options.autoResetPageIndex)!=null?o:!t.options.manualPagination){if(n)return;n=!0,t._queue(()=>{t.resetPageIndex(),n=!1})}},t.setPagination=o=>{let r=i(l=>He(o,l),"safeUpdater");return t.options.onPaginationChange==null?void 0:t.options.onPaginationChange(r)},t.resetPagination=o=>{var r;t.setPagination(o?Jt():(r=t.initialState.pagination)!=null?r:Jt())},t.setPageIndex=o=>{t.setPagination(r=>{let l=He(o,r.pageIndex),s=typeof t.options.pageCount>"u"||t.options.pageCount===-1?Number.MAX_SAFE_INTEGER:t.options.pageCount-1;return l=Math.max(0,Math.min(l,s)),{...r,pageIndex:l}})},t.resetPageIndex=o=>{var r,l;t.setPageIndex(o?Wt:(r=(l=t.initialState)==null||(l=l.pagination)==null?void 0:l.pageIndex)!=null?r:Wt)},t.resetPageSize=o=>{var r,l;t.setPageSize(o?Xt:(r=(l=t.initialState)==null||(l=l.pagination)==null?void 0:l.pageSize)!=null?r:Xt)},t.setPageSize=o=>{t.setPagination(r=>{let l=Math.max(1,He(o,r.pageSize)),s=r.pageSize*r.pageIndex,a=Math.floor(s/l);return{...r,pageIndex:a,pageSize:l}})},t.setPageCount=o=>t.setPagination(r=>{var l;let s=He(o,(l=t.options.pageCount)!=null?l:-1);return typeof s=="number"&&(s=Math.max(-1,s)),{...r,pageCount:s}}),t.getPageOptions=I(()=>[t.getPageCount()],o=>{let r=[];return o&&o>0&&(r=[...new Array(o)].fill(null).map((l,s)=>s)),r},D(t.options,"debugTable","getPageOptions")),t.getCanPreviousPage=()=>t.getState().pagination.pageIndex>0,t.getCanNextPage=()=>{let{pageIndex:o}=t.getState().pagination,r=t.getPageCount();return r===-1?!0:r===0?!1:o<r-1},t.previousPage=()=>t.setPageIndex(o=>o-1),t.nextPage=()=>t.setPageIndex(o=>o+1),t.firstPage=()=>t.setPageIndex(0),t.lastPage=()=>t.setPageIndex(t.getPageCount()-1),t.getPrePaginationRowModel=()=>t.getExpandedRowModel(),t.getPaginationRowModel=()=>(!t._getPaginationRowModel&&t.options.getPaginationRowModel&&(t._getPaginationRowModel=t.options.getPaginationRowModel(t)),t.options.manualPagination||!t._getPaginationRowModel?t.getPrePaginationRowModel():t._getPaginationRowModel()),t.getPageCount=()=>{var o;return(o=t.options.pageCount)!=null?o:Math.ceil(t.getRowCount()/t.getState().pagination.pageSize)},t.getRowCount=()=>{var o;return(o=t.options.rowCount)!=null?o:t.getPrePaginationRowModel().rows.length}},"createTable")},Kt=i(()=>({top:[],bottom:[]}),"getDefaultRowPinningState"),jr={getInitialState:i(t=>({rowPinning:Kt(),...t}),"getInitialState"),getDefaultOptions:i(t=>({onRowPinningChange:be("rowPinning",t)}),"getDefaultOptions"),createRow:i((t,e)=>{t.pin=(n,o,r)=>{let l=o?t.getLeafRows().map(u=>{let{id:d}=u;return d}):[],s=r?t.getParentRows().map(u=>{let{id:d}=u;return d}):[],a=new Set([...s,t.id,...l]);e.setRowPinning(u=>{var d,g;if(n==="bottom"){var m,c;return{top:((m=u?.top)!=null?m:[]).filter(h=>!(a!=null&&a.has(h))),bottom:[...((c=u?.bottom)!=null?c:[]).filter(h=>!(a!=null&&a.has(h))),...Array.from(a)]}}if(n==="top"){var f,p;return{top:[...((f=u?.top)!=null?f:[]).filter(h=>!(a!=null&&a.has(h))),...Array.from(a)],bottom:((p=u?.bottom)!=null?p:[]).filter(h=>!(a!=null&&a.has(h)))}}return{top:((d=u?.top)!=null?d:[]).filter(h=>!(a!=null&&a.has(h))),bottom:((g=u?.bottom)!=null?g:[]).filter(h=>!(a!=null&&a.has(h)))}})},t.getCanPin=()=>{var n;let{enableRowPinning:o,enablePinning:r}=e.options;return typeof o=="function"?o(t):(n=o??r)!=null?n:!0},t.getIsPinned=()=>{let n=[t.id],{top:o,bottom:r}=e.getState().rowPinning,l=n.some(a=>o?.includes(a)),s=n.some(a=>r?.includes(a));return l?"top":s?"bottom":!1},t.getPinnedIndex=()=>{var n,o;let r=t.getIsPinned();if(!r)return-1;let l=(n=r==="top"?e.getTopRows():e.getBottomRows())==null?void 0:n.map(s=>{let{id:a}=s;return a});return(o=l?.indexOf(t.id))!=null?o:-1}},"createRow"),createTable:i(t=>{t.setRowPinning=e=>t.options.onRowPinningChange==null?void 0:t.options.onRowPinningChange(e),t.resetRowPinning=e=>{var n,o;return t.setRowPinning(e?Kt():(n=(o=t.initialState)==null?void 0:o.rowPinning)!=null?n:Kt())},t.getIsSomeRowsPinned=e=>{var n;let o=t.getState().rowPinning;if(!e){var r,l;return!!((r=o.top)!=null&&r.length||(l=o.bottom)!=null&&l.length)}return!!((n=o[e])!=null&&n.length)},t._getPinnedRows=(e,n,o)=>{var r;return((r=t.options.keepPinnedRows)==null||r?(n??[]).map(s=>{let a=t.getRow(s,!0);return a.getIsAllParentsExpanded()?a:null}):(n??[]).map(s=>e.find(a=>a.id===s))).filter(Boolean).map(s=>({...s,position:o}))},t.getTopRows=I(()=>[t.getRowModel().rows,t.getState().rowPinning.top],(e,n)=>t._getPinnedRows(e,n,"top"),D(t.options,"debugRows","getTopRows")),t.getBottomRows=I(()=>[t.getRowModel().rows,t.getState().rowPinning.bottom],(e,n)=>t._getPinnedRows(e,n,"bottom"),D(t.options,"debugRows","getBottomRows")),t.getCenterRows=I(()=>[t.getRowModel().rows,t.getState().rowPinning.top,t.getState().rowPinning.bottom],(e,n,o)=>{let r=new Set([...n??[],...o??[]]);return e.filter(l=>!r.has(l.id))},D(t.options,"debugRows","getCenterRows"))},"createTable")},qr={getInitialState:i(t=>({rowSelection:{},...t}),"getInitialState"),getDefaultOptions:i(t=>({onRowSelectionChange:be("rowSelection",t),enableRowSelection:!0,enableMultiRowSelection:!0,enableSubRowSelection:!0}),"getDefaultOptions"),createTable:i(t=>{t.setRowSelection=e=>t.options.onRowSelectionChange==null?void 0:t.options.onRowSelectionChange(e),t.resetRowSelection=e=>{var n;return t.setRowSelection(e?{}:(n=t.initialState.rowSelection)!=null?n:{})},t.toggleAllRowsSelected=e=>{t.setRowSelection(n=>{e=typeof e<"u"?e:!t.getIsAllRowsSelected();let o={...n},r=t.getPreGroupedRowModel().flatRows;return e?r.forEach(l=>{l.getCanSelect()&&(o[l.id]=!0)}):r.forEach(l=>{delete o[l.id]}),o})},t.toggleAllPageRowsSelected=e=>t.setRowSelection(n=>{let o=typeof e<"u"?e:!t.getIsAllPageRowsSelected(),r={...n};return t.getRowModel().rows.forEach(l=>{Zt(r,l.id,o,!0,t)}),r}),t.getPreSelectedRowModel=()=>t.getCoreRowModel(),t.getSelectedRowModel=I(()=>[t.getState().rowSelection,t.getCoreRowModel()],(e,n)=>Object.keys(e).length?Qt(t,n):{rows:[],flatRows:[],rowsById:{}},D(t.options,"debugTable","getSelectedRowModel")),t.getFilteredSelectedRowModel=I(()=>[t.getState().rowSelection,t.getFilteredRowModel()],(e,n)=>Object.keys(e).length?Qt(t,n):{rows:[],flatRows:[],rowsById:{}},D(t.options,"debugTable","getFilteredSelectedRowModel")),t.getGroupedSelectedRowModel=I(()=>[t.getState().rowSelection,t.getSortedRowModel()],(e,n)=>Object.keys(e).length?Qt(t,n):{rows:[],flatRows:[],rowsById:{}},D(t.options,"debugTable","getGroupedSelectedRowModel")),t.getIsAllRowsSelected=()=>{let e=t.getFilteredRowModel().flatRows,{rowSelection:n}=t.getState(),o=!!(e.length&&Object.keys(n).length);return o&&e.some(r=>r.getCanSelect()&&!n[r.id])&&(o=!1),o},t.getIsAllPageRowsSelected=()=>{let e=t.getPaginationRowModel().flatRows.filter(r=>r.getCanSelect()),{rowSelection:n}=t.getState(),o=!!e.length;return o&&e.some(r=>!n[r.id])&&(o=!1),o},t.getIsSomeRowsSelected=()=>{var e;let n=Object.keys((e=t.getState().rowSelection)!=null?e:{}).length;return n>0&&n<t.getFilteredRowModel().flatRows.length},t.getIsSomePageRowsSelected=()=>{let e=t.getPaginationRowModel().flatRows;return t.getIsAllPageRowsSelected()?!1:e.filter(n=>n.getCanSelect()).some(n=>n.getIsSelected()||n.getIsSomeSelected())},t.getToggleAllRowsSelectedHandler=()=>e=>{t.toggleAllRowsSelected(e.target.checked)},t.getToggleAllPageRowsSelectedHandler=()=>e=>{t.toggleAllPageRowsSelected(e.target.checked)}},"createTable"),createRow:i((t,e)=>{t.toggleSelected=(n,o)=>{let r=t.getIsSelected();e.setRowSelection(l=>{var s;if(n=typeof n<"u"?n:!r,t.getCanSelect()&&r===n)return l;let a={...l};return Zt(a,t.id,n,(s=o?.selectChildren)!=null?s:!0,e),a})},t.getIsSelected=()=>{let{rowSelection:n}=e.getState();return nn(t,n)},t.getIsSomeSelected=()=>{let{rowSelection:n}=e.getState();return Yt(t,n)==="some"},t.getIsAllSubRowsSelected=()=>{let{rowSelection:n}=e.getState();return Yt(t,n)==="all"},t.getCanSelect=()=>{var n;return typeof e.options.enableRowSelection=="function"?e.options.enableRowSelection(t):(n=e.options.enableRowSelection)!=null?n:!0},t.getCanSelectSubRows=()=>{var n;return typeof e.options.enableSubRowSelection=="function"?e.options.enableSubRowSelection(t):(n=e.options.enableSubRowSelection)!=null?n:!0},t.getCanMultiSelect=()=>{var n;return typeof e.options.enableMultiRowSelection=="function"?e.options.enableMultiRowSelection(t):(n=e.options.enableMultiRowSelection)!=null?n:!0},t.getToggleSelectedHandler=()=>{let n=t.getCanSelect();return o=>{var r;n&&t.toggleSelected((r=o.target)==null?void 0:r.checked)}}},"createRow")},Zt=i((t,e,n,o,r)=>{var l;let s=r.getRow(e,!0);n?(s.getCanMultiSelect()||Object.keys(t).forEach(a=>delete t[a]),s.getCanSelect()&&(t[e]=!0)):delete t[e],o&&(l=s.subRows)!=null&&l.length&&s.getCanSelectSubRows()&&s.subRows.forEach(a=>Zt(t,a.id,n,o,r))},"mutateRowIsSelected");function Qt(t,e){let n=t.getState().rowSelection,o=[],r={},l=i(function(s,a){return s.map(u=>{var d;let g=nn(u,n);if(g&&(o.push(u),r[u.id]=u),(d=u.subRows)!=null&&d.length&&(u={...u,subRows:l(u.subRows)}),g)return u}).filter(Boolean)},"recurseRows");return{rows:l(e.rows),flatRows:o,rowsById:r}}i(Qt,"selectRowsFn");function nn(t,e){var n;return(n=e[t.id])!=null?n:!1}i(nn,"isRowSelected");function Yt(t,e,n){var o;if(!((o=t.subRows)!=null&&o.length))return!1;let r=!0,l=!1;return t.subRows.forEach(s=>{if(!(l&&!r)&&(s.getCanSelect()&&(nn(s,e)?l=!0:r=!1),s.subRows&&s.subRows.length)){let a=Yt(s,e);a==="all"?l=!0:(a==="some"&&(l=!0),r=!1)}}),r?"all":l?"some":!1}i(Yt,"isSubRowSelected");var en=/([0-9]+)/gm,Ur=i((t,e,n)=>no(Be(t.getValue(n)).toLowerCase(),Be(e.getValue(n)).toLowerCase()),"alphanumeric"),Jr=i((t,e,n)=>no(Be(t.getValue(n)),Be(e.getValue(n))),"alphanumericCaseSensitive"),Kr=i((t,e,n)=>on(Be(t.getValue(n)).toLowerCase(),Be(e.getValue(n)).toLowerCase()),"text"),Qr=i((t,e,n)=>on(Be(t.getValue(n)),Be(e.getValue(n))),"textCaseSensitive"),Wr=i((t,e,n)=>{let o=t.getValue(n),r=e.getValue(n);return o>r?1:o<r?-1:0},"datetime"),Xr=i((t,e,n)=>on(t.getValue(n),e.getValue(n)),"basic");function on(t,e){return t===e?0:t>e?1:-1}i(on,"compareBasic");function Be(t){return typeof t=="number"?isNaN(t)||t===1/0||t===-1/0?"":String(t):typeof t=="string"?t:""}i(Be,"toString");function no(t,e){let n=t.split(en).filter(Boolean),o=e.split(en).filter(Boolean);for(;n.length&&o.length;){let r=n.shift(),l=o.shift(),s=parseInt(r,10),a=parseInt(l,10),u=[s,a].sort();if(isNaN(u[0])){if(r>l)return 1;if(l>r)return-1;continue}if(isNaN(u[1]))return isNaN(s)?-1:1;if(s>a)return 1;if(a>s)return-1}return n.length-o.length}i(no,"compareAlphanumeric");var it={alphanumeric:Ur,alphanumericCaseSensitive:Jr,text:Kr,textCaseSensitive:Qr,datetime:Wr,basic:Xr},Zr={getInitialState:i(t=>({sorting:[],...t}),"getInitialState"),getDefaultColumnDef:i(()=>({sortingFn:"auto",sortUndefined:1}),"getDefaultColumnDef"),getDefaultOptions:i(t=>({onSortingChange:be("sorting",t),isMultiSortEvent:i(e=>e.shiftKey,"isMultiSortEvent")}),"getDefaultOptions"),createColumn:i((t,e)=>{t.getAutoSortingFn=()=>{let n=e.getFilteredRowModel().flatRows.slice(10),o=!1;for(let r of n){let l=r?.getValue(t.id);if(Object.prototype.toString.call(l)==="[object Date]")return it.datetime;if(typeof l=="string"&&(o=!0,l.split(en).length>1))return it.alphanumeric}return o?it.text:it.basic},t.getAutoSortDir=()=>{let n=e.getFilteredRowModel().flatRows[0];return typeof n?.getValue(t.id)=="string"?"asc":"desc"},t.getSortingFn=()=>{var n,o;if(!t)throw new Error;return Rt(t.columnDef.sortingFn)?t.columnDef.sortingFn:t.columnDef.sortingFn==="auto"?t.getAutoSortingFn():(n=(o=e.options.sortingFns)==null?void 0:o[t.columnDef.sortingFn])!=null?n:it[t.columnDef.sortingFn]},t.toggleSorting=(n,o)=>{let r=t.getNextSortingOrder(),l=typeof n<"u"&&n!==null;e.setSorting(s=>{let a=s?.find(f=>f.id===t.id),u=s?.findIndex(f=>f.id===t.id),d=[],g,m=l?n:r==="desc";if(s!=null&&s.length&&t.getCanMultiSort()&&o?a?g="toggle":g="add":s!=null&&s.length&&u!==s.length-1?g="replace":a?g="toggle":g="replace",g==="toggle"&&(l||r||(g="remove")),g==="add"){var c;d=[...s,{id:t.id,desc:m}],d.splice(0,d.length-((c=e.options.maxMultiSortColCount)!=null?c:Number.MAX_SAFE_INTEGER))}else g==="toggle"?d=s.map(f=>f.id===t.id?{...f,desc:m}:f):g==="remove"?d=s.filter(f=>f.id!==t.id):d=[{id:t.id,desc:m}];return d})},t.getFirstSortDir=()=>{var n,o;return((n=(o=t.columnDef.sortDescFirst)!=null?o:e.options.sortDescFirst)!=null?n:t.getAutoSortDir()==="desc")?"desc":"asc"},t.getNextSortingOrder=n=>{var o,r;let l=t.getFirstSortDir(),s=t.getIsSorted();return s?s!==l&&((o=e.options.enableSortingRemoval)==null||o)&&(!(n&&(r=e.options.enableMultiRemove)!=null)||r)?!1:s==="desc"?"asc":"desc":l},t.getCanSort=()=>{var n,o;return((n=t.columnDef.enableSorting)!=null?n:!0)&&((o=e.options.enableSorting)!=null?o:!0)&&!!t.accessorFn},t.getCanMultiSort=()=>{var n,o;return(n=(o=t.columnDef.enableMultiSort)!=null?o:e.options.enableMultiSort)!=null?n:!!t.accessorFn},t.getIsSorted=()=>{var n;let o=(n=e.getState().sorting)==null?void 0:n.find(r=>r.id===t.id);return o?o.desc?"desc":"asc":!1},t.getSortIndex=()=>{var n,o;return(n=(o=e.getState().sorting)==null?void 0:o.findIndex(r=>r.id===t.id))!=null?n:-1},t.clearSorting=()=>{e.setSorting(n=>n!=null&&n.length?n.filter(o=>o.id!==t.id):[])},t.getToggleSortingHandler=()=>{let n=t.getCanSort();return o=>{n&&(o.persist==null||o.persist(),t.toggleSorting==null||t.toggleSorting(void 0,t.getCanMultiSort()?e.options.isMultiSortEvent==null?void 0:e.options.isMultiSortEvent(o):!1))}}},"createColumn"),createTable:i(t=>{t.setSorting=e=>t.options.onSortingChange==null?void 0:t.options.onSortingChange(e),t.resetSorting=e=>{var n,o;t.setSorting(e?[]:(n=(o=t.initialState)==null?void 0:o.sorting)!=null?n:[])},t.getPreSortedRowModel=()=>t.getGroupedRowModel(),t.getSortedRowModel=()=>(!t._getSortedRowModel&&t.options.getSortedRowModel&&(t._getSortedRowModel=t.options.getSortedRowModel(t)),t.options.manualSorting||!t._getSortedRowModel?t.getPreSortedRowModel():t._getSortedRowModel())},"createTable")},Yr=[wr,Or,Ir,Dr,Sr,Cr,Ar,Gr,Zr,Vr,Hr,Br,jr,qr,zr];function oo(t){var e,n;let o=[...Yr,...(e=t._features)!=null?e:[]],r={_features:o},l=r._features.reduce((c,f)=>Object.assign(c,f.getDefaultOptions==null?void 0:f.getDefaultOptions(r)),{}),s=i(c=>r.options.mergeOptions?r.options.mergeOptions(l,c):{...l,...c},"mergeOptions"),u={...{},...(n=t.initialState)!=null?n:{}};r._features.forEach(c=>{var f;u=(f=c.getInitialState==null?void 0:c.getInitialState(u))!=null?f:u});let d=[],g=!1,m={_features:o,options:{...l,...t},initialState:u,_queue:i(c=>{d.push(c),g||(g=!0,Promise.resolve().then(()=>{for(;d.length;)d.shift()();g=!1}).catch(f=>setTimeout(()=>{throw f})))},"_queue"),reset:i(()=>{r.setState(r.initialState)},"reset"),setOptions:i(c=>{let f=He(c,r.options);r.options=s(f)},"setOptions"),getState:i(()=>r.options.state,"getState"),setState:i(c=>{r.options.onStateChange==null||r.options.onStateChange(c)},"setState"),_getRowId:i((c,f,p)=>{var h;return(h=r.options.getRowId==null?void 0:r.options.getRowId(c,f,p))!=null?h:`${p?[p.id,f].join("."):f}`},"_getRowId"),getCoreRowModel:i(()=>(r._getCoreRowModel||(r._getCoreRowModel=r.options.getCoreRowModel(r)),r._getCoreRowModel()),"getCoreRowModel"),getRowModel:i(()=>r.getPaginationRowModel(),"getRowModel"),getRow:i((c,f)=>{let p=(f?r.getPrePaginationRowModel():r.getRowModel()).rowsById[c];if(!p&&(p=r.getCoreRowModel().rowsById[c],!p))throw new Error;return p},"getRow"),_getDefaultColumnDef:I(()=>[r.options.defaultColumn],c=>{var f;return c=(f=c)!=null?f:{},{header:i(p=>{let h=p.header.column.columnDef;return h.accessorKey?h.accessorKey:h.accessorFn?h.id:null},"header"),cell:i(p=>{var h,w;return(h=(w=p.renderValue())==null||w.toString==null?void 0:w.toString())!=null?h:null},"cell"),...r._features.reduce((p,h)=>Object.assign(p,h.getDefaultColumnDef==null?void 0:h.getDefaultColumnDef()),{}),...c}},D(t,"debugColumns","_getDefaultColumnDef")),_getColumnDefs:i(()=>r.options.columns,"_getColumnDefs"),getAllColumns:I(()=>[r._getColumnDefs()],c=>{let f=i(function(p,h,w){return w===void 0&&(w=0),p.map(b=>{let x=br(r,b,w,h),C=b;return x.columns=C.columns?f(C.columns,x,w+1):[],x})},"recurseColumns");return f(c)},D(t,"debugColumns","getAllColumns")),getAllFlatColumns:I(()=>[r.getAllColumns()],c=>c.flatMap(f=>f.getFlatColumns()),D(t,"debugColumns","getAllFlatColumns")),_getAllFlatColumnsById:I(()=>[r.getAllFlatColumns()],c=>c.reduce((f,p)=>(f[p.id]=p,f),{}),D(t,"debugColumns","getAllFlatColumnsById")),getAllLeafColumns:I(()=>[r.getAllColumns(),r._getOrderColumnsFn()],(c,f)=>{let p=c.flatMap(h=>h.getLeafColumns());return f(p)},D(t,"debugColumns","getAllLeafColumns")),getColumn:i(c=>r._getAllFlatColumnsById()[c],"getColumn")};Object.assign(r,m);for(let c=0;c<r._features.length;c++){let f=r._features[c];f==null||f.createTable==null||f.createTable(r)}return r}i(oo,"createTable");function ro(){return t=>I(()=>[t.options.data],e=>{let n={rows:[],flatRows:[],rowsById:{}},o=i(function(r,l,s){l===void 0&&(l=0);let a=[];for(let d=0;d<r.length;d++){let g=xr(t,t._getRowId(r[d],d,s),r[d],d,l,void 0,s?.id);if(n.flatRows.push(g),n.rowsById[g.id]=g,a.push(g),t.options.getSubRows){var u;g.originalSubRows=t.options.getSubRows(r[d],d),(u=g.originalSubRows)!=null&&u.length&&(g.subRows=o(g.originalSubRows,l+1,g))}}return a},"accessRows");return n.rows=o(e),n},D(t.options,"debugTable","getRowModel",()=>t._autoResetPageIndex()))}i(ro,"getCoreRowModel");function lo(){return t=>I(()=>[t.getState().sorting,t.getPreSortedRowModel()],(e,n)=>{if(!n.rows.length||!(e!=null&&e.length))return n;let o=t.getState().sorting,r=[],l=o.filter(u=>{var d;return(d=t.getColumn(u.id))==null?void 0:d.getCanSort()}),s={};l.forEach(u=>{let d=t.getColumn(u.id);d&&(s[u.id]={sortUndefined:d.columnDef.sortUndefined,invertSorting:d.columnDef.invertSorting,sortingFn:d.getSortingFn()})});let a=i(u=>{let d=u.map(g=>({...g}));return d.sort((g,m)=>{for(let f=0;f<l.length;f+=1){var c;let p=l[f],h=s[p.id],w=h.sortUndefined,b=(c=p?.desc)!=null?c:!1,x=0;if(w){let C=g.getValue(p.id),R=m.getValue(p.id),y=C===void 0,_=R===void 0;if(y||_){if(w==="first")return y?-1:1;if(w==="last")return y?1:-1;x=y&&_?0:y?w:-w}}if(x===0&&(x=h.sortingFn(g,m,p.id)),x!==0)return b&&(x*=-1),h.invertSorting&&(x*=-1),x}return g.index-m.index}),d.forEach(g=>{var m;r.push(g),(m=g.subRows)!=null&&m.length&&(g.subRows=a(g.subRows))}),d},"sortData");return{rows:a(n.rows),flatRows:r,rowsById:n.rowsById}},D(t.options,"debugTable","getSortedRowModel",()=>t._autoResetPageIndex()))}i(lo,"getSortedRowModel");function io(t,e){return t?el(t)?at.createElement(t,e):t:null}i(io,"flexRender");function el(t){return tl(t)||typeof t=="function"||nl(t)}i(el,"isReactComponent");function tl(t){return typeof t=="function"&&(()=>{let e=Object.getPrototypeOf(t);return e.prototype&&e.prototype.isReactComponent})()}i(tl,"isClassComponent");function nl(t){return typeof t=="object"&&typeof t.$$typeof=="symbol"&&["react.memo","react.forward_ref"].includes(t.$$typeof.description)}i(nl,"isExoticComponent");function so(t){let e={state:{},onStateChange:i(()=>{},"onStateChange"),renderFallbackValue:null,...t},[n]=at.useState(()=>({current:oo(e)})),[o,r]=at.useState(()=>n.current.initialState);return n.current.setOptions(l=>({...l,...t,state:{...o,...t.state},onStateChange:i(s=>{r(s),t.onStateChange==null||t.onStateChange(s)},"onStateChange")})),n.current}i(so,"useReactTable");var v=ae(lt(),1);var ao=ae(rt(),1),uo=ae(We(),1),se=ae(lt(),1);var ol=[{label:"=",value:"eq"},{label:"\u2260",value:"ne"},{label:"<",value:"lt"},{label:"\u2264",value:"lte"},{label:">",value:"gt"},{label:"\u2265",value:"gte"},{label:"contains",value:"contains"}],rl=i(t=>{let e=t.trim(),n=Number(e);return e!==""&&Number.isFinite(n)&&String(n)===e?n:t},"O"),je=i(t=>t.filter(e=>e.column!=="").map(e=>({column:e.column,operator:e.operator,value:e.operator==="contains"?e.value:rl(e.value)})),"I"),co=i(t=>{let e=(0,ao.c)(44),{columns:n,filters:o,onAskAi:r,onFiltersChange:l,onSearchChange:s,search:a}=t,[u,d]=(0,uo.useState)(""),g;e[0]!==n[0]||e[1]!==o||e[2]!==l?(g=i(()=>{l([...o,{column:n[0]??"",operator:"eq",value:""}])},"F"),e[0]=n[0],e[1]=o,e[2]=l,e[3]=g):g=e[3];let m=g,c;e[4]!==o||e[5]!==l?(c=i($=>{let M=Number($.currentTarget.dataset.index);l(o.filter((P,k)=>k!==M))},"T"),e[4]=o,e[5]=l,e[6]=c):c=e[6];let f=c,p;e[7]!==o||e[8]!==l?(p=i($=>{let M=Number($.currentTarget.dataset.index),P=$.currentTarget.value;l(o.map((k,O)=>O===M?{...k,column:P}:k))},"k"),e[7]=o,e[8]=l,e[9]=p):p=e[9];let h=p,w;e[10]!==o||e[11]!==l?(w=i($=>{let M=Number($.currentTarget.dataset.index),P=$.currentTarget.value;l(o.map((k,O)=>O===M?{...k,operator:P}:k))},"w"),e[10]=o,e[11]=l,e[12]=w):w=e[12];let b=w,x;e[13]!==o||e[14]!==l?(x=i($=>{let M=Number($.currentTarget.dataset.index),P=$.currentTarget.value;l(o.map((k,O)=>O===M?{...k,value:P}:k))},"y"),e[13]=o,e[14]=l,e[15]=x):x=e[15];let C=x,R;e[16]!==s||e[17]!==a?(R=(0,se.jsx)("input",{"aria-label":"Search rows","data-testid":"db-filter",onChange:s,placeholder:"search table\u2026",value:a}),e[16]=s,e[17]=a,e[18]=R):R=e[18];let y;e[19]!==m?(y=(0,se.jsx)("button",{"data-testid":"db-add-filter",onClick:m,type:"button",children:"Add filter"}),e[19]=m,e[20]=y):y=e[20];let _;e[21]!==u||e[22]!==r?(_=r!==void 0&&(0,se.jsxs)(se.Fragment,{children:[(0,se.jsx)("input",{"aria-label":"Describe a filter","data-testid":"db-ai-prompt",onChange:i($=>{d($.target.value)},"onChange"),onKeyDown:i($=>{$.key==="Enter"&&u.trim()!==""&&($.preventDefault(),r(u.trim()))},"onKeyDown"),placeholder:"describe a filter\u2026",value:u}),(0,se.jsx)("button",{"data-testid":"db-ai-filter",disabled:u.trim()==="",onClick:i(()=>{r(u.trim())},"onClick"),type:"button",children:"Suggest"})]}),e[21]=u,e[22]=r,e[23]=_):_=e[23];let S;e[24]!==R||e[25]!==y||e[26]!==_?(S=(0,se.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[R,y,_]}),e[24]=R,e[25]=y,e[26]=_,e[27]=S):S=e[27];let F;if(e[28]!==h||e[29]!==b||e[30]!==C||e[31]!==n||e[32]!==o||e[33]!==f){let $;e[35]!==h||e[36]!==b||e[37]!==C||e[38]!==n||e[39]!==f?($=i((M,P)=>(0,se.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-filter-row",children:[(0,se.jsx)("select",{"aria-label":"Filter column","data-index":P,"data-testid":"db-filter-column",onChange:h,value:M.column,children:n.map(ll)}),(0,se.jsx)("select",{"aria-label":"Filter operator","data-index":P,"data-testid":"db-filter-operator",onChange:b,value:M.operator,children:ol.map(il)}),(0,se.jsx)("input",{"aria-label":"Filter value","data-index":P,"data-testid":"db-filter-value",onChange:C,placeholder:"value",value:M.value}),(0,se.jsx)("button",{"aria-label":"Remove filter","data-index":P,"data-testid":"db-filter-remove",onClick:f,type:"button",children:"\u2715"})]},P),"t"),e[35]=h,e[36]=b,e[37]=C,e[38]=n,e[39]=f,e[40]=$):$=e[40],F=o.map($),e[28]=h,e[29]=b,e[30]=C,e[31]=n,e[32]=o,e[33]=f,e[34]=F}else F=e[34];let V;return e[41]!==F||e[42]!==S?(V=(0,se.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"db-filters",children:[S,F]}),e[41]=F,e[42]=S,e[43]=V):V=e[43],V},"J");function ll(t){return(0,se.jsx)("option",{value:t,children:t},t)}i(ll,"R");function il(t){return(0,se.jsx)("option",{value:t.value,children:t.label},t.value)}i(il,"V");var go=i((t,e)=>{let n=[];for(let[o,r]of Object.entries(e))for(let l of r)l.ref===t&&n.push({column:l.name,table:o});return n.sort((o,r)=>o.table.localeCompare(r.table)||o.column.localeCompare(r.column)),n},"pt"),un=i(t=>`${t.table}.${t.column}`,"dt"),sl=/([a-z\d])([A-Z])/gu,al=/[\s_-]+/u,ul=new Set(["access_token","api_key","apikey","card_number","client_secret","credit_card","cvv","passwd","password","private_key","pwd","refresh_token","secret","ssn","token"]),dl=i(t=>{let e=t.replaceAll(sl,"$1 $2").split(al).map(o=>o.toLowerCase()).filter(o=>o.length>0),n=new Set(e);for(let o=0;o<e.length-1;o+=1){let r=e[o],l=e[o+1];r===void 0||l===void 0||(n.add(`${r}${l}`),n.add(`${r}_${l}`))}return[...n]},"An"),fo="\u2022\u2022\u2022",cl=i(t=>{let e=2166136261;for(let n=0;n<t.length;n+=1)e^=t.codePointAt(n)??0,e=Math.imul(e,16777619);return(e>>>0).toString(16).padStart(8,"0")},"Ln"),Co=i((t,e)=>{try{return e==="redact"?null:e==="hash"?t==null?t:cl(typeof t=="bigint"?t.toString():typeof t=="string"?t:JSON.stringify(t)):fo}catch{return fo}},"Et"),gl=i((t,e)=>{let n=new Map;for(let o of t)o.table===e&&n.set(o.column,o.strategy);return n},"Bn"),fl=i(t=>{for(let e of dl(t))if(ul.has(e))return!0;return!1},"Vn"),ml=i((t,e)=>{let n=e.filter(r=>!t.has(r)&&fl(r));if(n.length===0)return t;let o=new Map(t);for(let r of n)o.set(r,"redact");return o},"qn"),pl=i((t,e,n)=>{if(!n.enabled)return t;let o=n.columns.get(e);return o===void 0?t:Co(t,o)},"Jn"),mo=i((t,e)=>!e.enabled||e.columns.size===0?t:t.map(n=>{let o={...n};for(let[r,l]of e.columns)r in o&&(o[r]=Co(o[r],l));return o}),"xt"),hl=i((t,e,n,o,r=300)=>{if(o<=0)return{ids:new Set(t.map(m=>m.id)),leadPx:0,tailPx:0};let l=n-r,s=n+o+r,a=new Set,u=0,d=0,g=0;for(let m of t){let c=m.getSize(),f=e.has(m.id),p=u+c>l&&u<s;f||p?a.add(m.id):u<l?d+=c:g+=c,u+=c}return{ids:a,leadPx:d,tailPx:g}},"Kn"),vl=i((t,e)=>{let n=new Map,o=0;for(let r of t)e.has(r.id)&&(n.set(r.id,o),o+=r.getSize());return n},"Gn"),bl=i(()=>{let t=(0,B.c)(11),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={},t[0]=e):e=t[0];let[n,o]=(0,N.useState)(e),r;t[1]===Symbol.for("react.memo_cache_sentinel")?(r=i((f,p,h)=>{o(w=>({...w,[f]:{...w[f],[p]:h}}))},"t"),t[1]=r):r=t[1];let l=r,s;t[2]===Symbol.for("react.memo_cache_sentinel")?(s=i(()=>{o({})},"i"),t[2]=s):s=t[2];let a=s,u;t[3]!==n?(u=i((f,p)=>{let h=n[f];return h!==void 0&&p in h?{value:h[p]}:void 0},"d"),t[3]=n,t[4]=u):u=t[4];let d=u,g;t[5]!==n?(g=Object.values(n).reduce(Sl,0),t[5]=n,t[6]=g):g=t[6];let m=g,c;return t[7]!==m||t[8]!==n||t[9]!==d?(c={clear:a,count:m,stage:l,staged:n,stagedValue:d},t[7]=m,t[8]=n,t[9]=d,t[10]=c):c=t[10],c},"Hn"),wl=i((t,e)=>{if(typeof e=="number"){let n=Number(t);return t.trim()===""||Number.isNaN(n)?t:n}if(typeof e=="boolean"){if(t==="true")return!0;if(t==="false")return!1}return t},"Qn"),xl=i(t=>{let e=(0,B.c)(29),{changes:n,committing:o,onCommit:r,onDiscard:l}=t,s=X(),a;e[0]!==n.length||e[1]!==s?(a=s("{count} pending changes",{count:n.length}),e[0]=n.length,e[1]=s,e[2]=a):a=e[2];let u;e[3]!==a?(u=(0,v.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-warning","data-testid":"db-staged-count",children:a}),e[3]=a,e[4]=u):u=e[4];let d;e[5]!==o||e[6]!==s?(d=s(o?"Committing\u2026":"Commit"),e[5]=o,e[6]=s,e[7]=d):d=e[7];let g;e[8]!==o||e[9]!==r||e[10]!==d?(g=(0,v.jsx)("button",{className:"ms-auto rounded-md bg-primary px-2.5 py-1 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-commit",disabled:o,onClick:r,type:"button",children:d}),e[8]=o,e[9]=r,e[10]=d,e[11]=g):g=e[11];let m;e[12]!==s?(m=s("Discard"),e[12]=s,e[13]=m):m=e[13];let c;e[14]!==o||e[15]!==l||e[16]!==m?(c=(0,v.jsx)("button",{className:"rounded-md border border-border px-2.5 py-1 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"db-staged-discard",disabled:o,onClick:l,type:"button",children:m}),e[14]=o,e[15]=l,e[16]=m,e[17]=c):c=e[17];let f;e[18]!==u||e[19]!==g||e[20]!==c?(f=(0,v.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[u,g,c]}),e[18]=u,e[19]=g,e[20]=c,e[21]=f):f=e[21];let p;e[22]!==n?(p=n.map(Cl),e[22]=n,e[23]=p):p=e[23];let h;e[24]!==p?(h=(0,v.jsx)("ul",{className:"flex flex-col gap-1","data-testid":"db-staged-list",children:p}),e[24]=p,e[25]=h):h=e[25];let w;return e[26]!==f||e[27]!==h?(w=(0,v.jsxs)("div",{className:"flex flex-col gap-2 border border-warning/40 bg-warning/5 p-3","data-testid":"db-staged",children:[f,h]}),e[26]=f,e[27]=h,e[28]=w):w=e[28],w},"Wn");function Sl(t,e){return t+Object.keys(e).length}i(Sl,"Un");function Cl(t){return(0,v.jsxs)("li",{className:"flex flex-wrap items-center gap-2 font-mono text-xs",children:[(0,v.jsxs)("span",{className:"text-muted-foreground",children:[t.rowId,".",t.column]}),(0,v.jsx)("span",{className:"text-destructive line-through",children:Je(t.oldValue)}),(0,v.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2192"}),(0,v.jsx)("span",{className:"text-foreground",children:Je(t.newValue)})]},`${t.rowId}:${t.column}`)}i(Cl,"Zn");var po=400,yl=36,Rl={flex:"1 1 0%",minHeight:0,overflow:"auto",position:"relative"},_l={width:"100%"},Fl={alignItems:"center",display:"flex",left:0,position:"absolute",top:0,width:"100%"},$l={display:"flex",width:"100%"},ho={flex:"0 0 8.5rem",padding:"0.375rem 0.75rem"},Nl="2.5rem",yo={alignItems:"center",display:"flex",flex:"0 0 2.5rem",justifyContent:"center",left:0,padding:"0.375rem 0",position:"sticky",zIndex:2},dn=i(t=>({flex:"0 0 auto",overflow:"hidden",padding:"0.375rem 0.75rem",position:"relative",textOverflow:"ellipsis",whiteSpace:"nowrap",width:`${t.toString()}px`}),"ct"),Ro=i((t,e)=>({...dn(t),left:`calc(${Nl} + ${e.toString()}px)`,position:"sticky",zIndex:2}),"_t"),vo="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",Ml=i((t,e,n)=>e.enabled&&e.columns.has(n)?void 0:t,"ro"),sn="__back__:",Pl=i(t=>`${sn}${t.table}.${t.column}`,"lo"),kl=i(t=>{let e=(0,B.c)(3),{counts:n,rowId:o}=t;if(n===void 0){let s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(s=(0,v.jsx)("span",{className:"text-muted-foreground/50",children:"\u2014"}),e[0]=s):s=e[0],s}let r=n[o]??0,l;return e[1]!==r?(l=(0,v.jsx)("span",{className:"tabular-nums",children:r}),e[1]=r,e[2]=l):l=e[2],l},"ao"),Te=i(t=>{for(let e of["id","__id__","_id"]){let n=t[e];if(typeof n=="string"||typeof n=="number")return String(n)}return null},"ye"),_o=i((t,e)=>Te(t)??`row-${e.toString()}`,"Mt"),Vl=8,El=i(t=>{let e=(0,B.c)(16),{anchor:n,state:o}=t,r=X(),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];let s=l,a;if(o==="loading"){let d;e[3]!==r?(d=r("Loading\u2026"),e[3]=r,e[4]=d):d=e[4];let g;e[5]!==d?(g=(0,v.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:d}),e[5]=d,e[6]=g):g=e[6],a=g}else if(o.row===null){let d;e[7]!==r?(d=r("No matching row."),e[7]=r,e[8]=d):d=e[8];let g;e[9]!==d?(g=(0,v.jsx)("p",{className:"px-3 py-2 text-xs text-muted-foreground",children:d}),e[9]=d,e[10]=g):g=e[10],a=g}else{let d;if(e[11]!==o.row){let g=Object.entries(o.row).slice(0,Vl);d=(0,v.jsx)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-1 px-3 py-2",children:g.map(ql)}),e[11]=o.row,e[12]=d}else d=e[12];a=d}let u;return e[13]!==a||e[14]!==s?(u=(0,v.jsx)("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:s,children:a}),e[13]=a,e[14]=s,e[15]=u):u=e[15],u},"io"),Il=i(t=>{let e=(0,B.c)(22),{column:n,id:o,onNavigate:r,onPreview:l,target:s}=t,[a,u]=(0,N.useState)(null),[d,g]=(0,N.useState)("idle"),m;e[0]!==o||e[1]!==r||e[2]!==s?(m=i(()=>{r(s,o)},"c"),e[0]=o,e[1]=r,e[2]=s,e[3]=m):m=e[3];let c=m,f;e[4]!==o||e[5]!==l||e[6]!==d||e[7]!==s?(f=i(_=>{let S=_.currentTarget.getBoundingClientRect();u({left:S.left,top:S.bottom+4}),d==="idle"&&(g("loading"),Z((async()=>{try{g({row:await l(s,o)})}catch{g({row:null})}})()))},"b"),e[4]=o,e[5]=l,e[6]=d,e[7]=s,e[8]=f):f=e[8];let p=f,h;e[9]===Symbol.for("react.memo_cache_sentinel")?(h=i(()=>{u(null)},"p"),e[9]=h):h=e[9];let w=h,b=`db-ref-${n}`,x=`Open ${s} ${o}`,C;e[10]!==o||e[11]!==c||e[12]!==p||e[13]!==b||e[14]!==x?(C=(0,v.jsxs)("button",{"data-testid":b,onBlur:w,onClick:c,onFocus:p,onMouseEnter:p,onMouseLeave:w,title:x,type:"button",children:[o," \u2197"]}),e[10]=o,e[11]=c,e[12]=p,e[13]=b,e[14]=x,e[15]=C):C=e[15];let R;e[16]!==a||e[17]!==d?(R=a!==null&&d!=="idle"&&(0,v.jsx)(El,{anchor:a,state:d}),e[16]=a,e[17]=d,e[18]=R):R=e[18];let y;return e[19]!==C||e[20]!==R?(y=(0,v.jsxs)(v.Fragment,{children:[C,R]}),e[19]=C,e[20]=R,e[21]=y):y=e[21],y},"co"),Dl=i(t=>t==="asc"?" \u25B2":t==="desc"?" \u25BC":"","uo"),Tl="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",bo=i(t=>{let e=(0,B.c)(8),{column:n,onExpand:o,value:r}=t,l;e[0]!==n||e[1]!==o||e[2]!==r?(l=i(()=>{o(n,r)},"l"),e[0]=n,e[1]=o,e[2]=r,e[3]=l):l=e[3];let s=l,a=`db-expand-${n}`,u;e[4]===Symbol.for("react.memo_cache_sentinel")?(u=(0,v.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:(0,v.jsx)("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]=u):u=e[4];let d;return e[5]!==s||e[6]!==a?(d=(0,v.jsx)("button",{"aria-label":"Expand cell",className:Tl,"data-testid":a,onClick:s,type:"button",children:u}),e[5]=s,e[6]=a,e[7]=d):d=e[7],d},"St"),zl=i(t=>{let e=(0,B.c)(15),{column:n,initial:o,onCancel:r,onCommit:l,recordId:s}=t,a=(0,N.useRef)(null),u,d;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=i(()=>{a.current?.select()},"d"),d=[],e[0]=u,e[1]=d):(u=e[0],d=e[1]),(0,N.useEffect)(u,d);let g;e[2]!==r||e[3]!==l?(g=i(b=>{b.key==="Enter"?(b.preventDefault(),l(b.currentTarget.value)):b.key==="Escape"&&(b.preventDefault(),r())},"g"),e[2]=r,e[3]=l,e[4]=g):g=e[4];let m=g,c;e[5]!==l?(c=i(b=>{l(b.currentTarget.value)},"u"),e[5]=l,e[6]=c):c=e[6];let f=c,p=`db-cell-input-${s}-${n}`,h;e[7]!==o?(h=Je(o),e[7]=o,e[8]=h):h=e[8];let w;return e[9]!==n||e[10]!==f||e[11]!==m||e[12]!==p||e[13]!==h?(w=(0,v.jsx)("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":p,defaultValue:h,onBlur:f,onKeyDown:m,ref:a}),e[9]=n,e[10]=f,e[11]=m,e[12]=p,e[13]=h,e[14]=w):w=e[14],w},"go"),Ll=i(t=>{let e=(0,B.c)(68),{cell:n,edit:o,highlight:r,mask:l,refs:s}=t,a=n.column.id,u,d,g,m;if(e[0]!==n||e[1]!==a||e[2]!==o||e[3]!==l||e[4]!==s.columns||e[5]!==s.onNavigate||e[6]!==s.onPreview){m=Symbol.for("react.early_return_sentinel");e:{d=n.getValue(),u=Te(n.row.original);let $=s.columns?.[a];if(l.enabled&&l.columns.has(a)){let M=`db-masked-${a}`,P=(0,v.jsx)(Ze,{value:pl(d,a,l)}),k;e[11]!==M||e[12]!==P?(k=(0,v.jsx)("span",{className:"text-muted-foreground italic","data-testid":M,title:"Masked (preview)",children:P}),e[11]=M,e[12]=P,e[13]=k):k=e[13],m=k;break e}if($!==void 0&&(typeof d=="string"||typeof d=="number")&&String(d)!==""){let M=String(d),P=`${$}:${String(d)}`,k;e[14]!==a||e[15]!==s.onNavigate||e[16]!==s.onPreview||e[17]!==M||e[18]!==P||e[19]!==$?(k=(0,v.jsx)(Il,{column:a,id:M,onNavigate:s.onNavigate,onPreview:s.onPreview,target:$},P),e[14]=a,e[15]=s.onNavigate,e[16]=s.onPreview,e[17]=M,e[18]=P,e[19]=$,e[20]=k):k=e[20],m=k;break e}if(u===null){let M;e[21]!==d?(M=(0,v.jsx)(Ze,{value:d}),e[21]=d,e[22]=M):M=e[22];let P;e[23]!==a||e[24]!==o.onExpandCell||e[25]!==d?(P=(0,v.jsx)(bo,{column:a,onExpand:o.onExpandCell,value:d}),e[23]=a,e[24]=o.onExpandCell,e[25]=d,e[26]=P):P=e[26];let k;e[27]!==M||e[28]!==P?(k=(0,v.jsxs)(v.Fragment,{children:[M,P]}),e[27]=M,e[28]=P,e[29]=k):k=e[29],m=k;break e}g=o.stagedValue(u,a)}e[0]=n,e[1]=a,e[2]=o,e[3]=l,e[4]=s.columns,e[5]=s.onNavigate,e[6]=s.onPreview,e[7]=u,e[8]=d,e[9]=g,e[10]=m}else u=e[7],d=e[8],g=e[9],m=e[10];if(m!==Symbol.for("react.early_return_sentinel"))return m;let c=g,f=c===void 0?d:c.value,p;e[30]!==a||e[31]!==o?(p=o.editable&&o.editableColumn(a),e[30]=a,e[31]=o,e[32]=p):p=e[32];let h=p;if(o.editingCell!==null&&o.editingCell.rowId===u&&o.editingCell.column===a){let $;e[33]!==a||e[34]!==o||e[35]!==u||e[36]!==d?($=i(P=>{o.stage(u,a,wl(P,d)),o.cancelEdit()},"E"),e[33]=a,e[34]=o,e[35]=u,e[36]=d,e[37]=$):$=e[37];let M;return e[38]!==a||e[39]!==f||e[40]!==o.cancelEdit||e[41]!==u||e[42]!==$?(M=(0,v.jsx)(zl,{column:a,initial:f,onCancel:o.cancelEdit,onCommit:$,recordId:u}),e[38]=a,e[39]=f,e[40]=o.cancelEdit,e[41]=u,e[42]=$,e[43]=M):M=e[43],M}let w;c!==void 0?w="rounded bg-warning/15 px-1":h&&(w="cursor-text");let b;e[44]!==h||e[45]!==a||e[46]!==o||e[47]!==u?(b=h?()=>{o.startEdit(u,a)}:void 0,e[44]=h,e[45]=a,e[46]=o,e[47]=u,e[48]=b):b=e[48];let x=b,C=w,R=`db-cell-${u}-${a}`,y;e[49]!==a||e[50]!==r||e[51]!==l?(y=Ml(r,l,a),e[49]=a,e[50]=r,e[51]=l,e[52]=y):y=e[52];let _;e[53]!==f||e[54]!==y?(_=(0,v.jsx)(Ze,{highlight:y,value:f}),e[53]=f,e[54]=y,e[55]=_):_=e[55];let S;e[56]!==w||e[57]!==x||e[58]!==R||e[59]!==_?(S=(0,v.jsx)("span",{className:C,"data-testid":R,onDoubleClick:x,children:_}),e[56]=w,e[57]=x,e[58]=R,e[59]=_,e[60]=S):S=e[60];let F;e[61]!==a||e[62]!==f||e[63]!==o.onExpandCell?(F=(0,v.jsx)(bo,{column:a,onExpand:o.onExpandCell,value:f}),e[61]=a,e[62]=f,e[63]=o.onExpandCell,e[64]=F):F=e[64];let V;return e[65]!==F||e[66]!==S?(V=(0,v.jsxs)(v.Fragment,{children:[S,F]}),e[65]=F,e[66]=S,e[67]=V):V=e[67],V},"fo"),Ol=i(t=>{t.preventDefault()},"bo"),Al=i(({draggedRef:t,header:e,masked:n=!1,onTogglePin:o,pinnedOffset:r,table:l})=>{let s=i(()=>{t.current=e.column.id},"i"),a=i(()=>{let u=t.current,d=e.column.id;if(t.current=null,u===null||u===d)return;let g=l.getState().columnOrder,m=(g.length>0?g:l.getAllLeafColumns().map(f=>f.id)).filter(f=>f!==u),c=m.indexOf(d);m.splice(c===-1?m.length:c,0,u),l.setColumnOrder(m)},"a");return(0,v.jsxs)("th",{className:Ue("group/head text-start text-xs font-medium text-muted-foreground",r!==void 0&&"border-e border-border bg-muted"),draggable:!0,onDragOver:Ol,onDragStart:s,onDrop:a,style:r===void 0?dn(e.getSize()):Ro(e.getSize(),r),children:[(0,v.jsxs)("button",{className:"inline-flex max-w-full cursor-grab items-center gap-1 truncate outline-none hover:text-foreground","data-testid":`db-sort-${e.column.id}`,onClick:e.column.getToggleSortingHandler(),type:"button",children:[io(e.column.columnDef.header,e.getContext()),Dl(e.column.getIsSorted())]}),n&&(0,v.jsx)("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-${e.column.id}`,title:"This column is masked by a mask() policy",children:"masked"}),(0,v.jsx)("button",{"aria-label":r===void 0?`Pin ${e.column.id}`:`Unpin ${e.column.id}`,"aria-pressed":r!==void 0,className:Ue("ms-1 rounded-sm px-1 text-[0.625rem] outline-none transition-opacity hover:bg-accent focus-visible:bg-accent",r===void 0?"opacity-0 group-hover/head:opacity-100 focus-visible:opacity-100":"opacity-100 text-foreground"),"data-testid":`db-pin-${e.column.id}`,onClick:i(()=>{o(e.column.id)},"onClick"),type:"button",children:"\u{1F4CC}"}),(0,v.jsx)("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":e.column.getIsResizing(),"data-testid":`db-resize-${e.column.id}`,onMouseDown:e.getResizeHandler(),onTouchStart:e.getResizeHandler()})]})},"po"),Gl=i(t=>{let e=(0,B.c)(13),{table:n}=t,o=X(),r;e[0]!==n?(r=i(g=>{n.toggleAllRowsSelected(g)},"t"),e[0]=n,e[1]=r):r=e[1];let l=r,s;e[2]!==o?(s=o("Select all rows"),e[2]=o,e[3]=s):s=e[3];let a;e[4]!==n?(a=n.getIsAllRowsSelected(),e[4]=n,e[5]=a):a=e[5];let u;e[6]!==n?(u=n.getIsSomeRowsSelected()&&!n.getIsAllRowsSelected(),e[6]=n,e[7]=u):u=e[7];let d;return e[8]!==l||e[9]!==s||e[10]!==a||e[11]!==u?(d=(0,v.jsx)("th",{className:"bg-muted",style:yo,children:(0,v.jsx)(gt,{"aria-label":s,checked:a,"data-testid":"db-select-all",indeterminate:u,onCheckedChange:l})}),e[8]=l,e[9]=s,e[10]=a,e[11]=u,e[12]=d):d=e[12],d},"ho"),Hl=i(t=>{let e=(0,B.c)(17),{row:n}=t,o=X(),r;e[0]!==n.original?(r=Te(n.original),e[0]=n.original,e[1]=r):r=e[1];let l=r,s;e[2]!==n?(s=i(p=>{n.toggleSelected(p)},"i"),e[2]=n,e[3]=s):s=e[3];let a=s,u;e[4]!==o?(u=o("Select row"),e[4]=o,e[5]=u):u=e[5];let d;e[6]!==n?(d=n.getIsSelected(),e[6]=n,e[7]=d):d=e[7];let g;e[8]!==n.index||e[9]!==n.original?(g=_o(n.original,n.index),e[8]=n.index,e[9]=n.original,e[10]=g):g=e[10];let m=`db-select-${g}`,c=l===null,f;return e[11]!==a||e[12]!==u||e[13]!==d||e[14]!==m||e[15]!==c?(f=(0,v.jsx)("td",{className:"bg-background",style:yo,children:(0,v.jsx)(gt,{"aria-label":u,checked:d,"data-testid":m,disabled:c,onCheckedChange:a})}),e[11]=a,e[12]=u,e[13]=d,e[14]=m,e[15]=c,e[16]=f):f=e[16],f},"xo"),Bl=i(t=>{let e=(0,B.c)(70),{edit:n,editable:o,mask:r,onDelete:l,onEdit:s,onInspect:a,highlight:u,backRelationCounts:d,onTogglePin:g,pinnedColumns:m,refs:c,tableModel:f}=t,{attachScroll:p,scrollLeft:h,scrollToIndex:w,table:b,tableRows:x,tbodyStyle:C,viewportWidth:R,virtualRows:y}=f,_=(0,N.useRef)(null),[S,F]=(0,N.useState)(null),V;e[0]!==b?(V=b.getVisibleLeafColumns(),e[0]=b,e[1]=V):V=e[1];let $=V.length,M;e[2]!==S||e[3]!==$||e[4]!==n||e[5]!==b||e[6]!==x?(M=i(Ne=>{if(!["ArrowDown","ArrowLeft","ArrowRight","ArrowUp","Enter"].includes(Ne.key))return;Ne.preventDefault();let le=S??{col:0,row:0};if(Ne.key==="Enter"){let K=x[le.row],ge=b.getVisibleLeafColumns()[le.col];if(K!==void 0&&ge!==void 0){let Q=Te(K.original);Q!==null&&n.editableColumn(ge.id)&&n.startEdit(Q,ge.id)}F(le);return}let{col:me,row:ne}=le;e:switch(Ne.key){case"ArrowDown":{ne=Math.min(ne+1,x.length-1);break e}case"ArrowRight":{me=Math.min(me+1,$-1);break e}case"ArrowUp":{ne=Math.max(ne-1,0);break e}default:me=Math.max(me-1,0)}F({col:me,row:ne})},"R"),e[2]=S,e[3]=$,e[4]=n,e[5]=b,e[6]=x,e[7]=M):M=e[7];let P=M,k,O;e[8]!==S||e[9]!==w?(k=i(()=>{S!==null&&w(S.row)},"k"),O=[S,w],e[8]=S,e[9]=w,e[10]=k,e[11]=O):(k=e[10],O=e[11]),(0,N.useEffect)(k,O);let q,L,T,U,j,J,te,oe,we,ce,fe,xe,he,ve;if(e[12]!==S||e[13]!==p||e[14]!==d||e[15]!==n||e[16]!==o||e[17]!==u||e[18]!==r||e[19]!==l||e[20]!==s||e[21]!==P||e[22]!==a||e[23]!==g||e[24]!==m||e[25]!==c||e[26]!==h||e[27]!==b||e[28]!==x||e[29]!==C||e[30]!==R||e[31]!==y){let Ne=b.getVisibleLeafColumns().map(Ul),le=hl(Ne,m,h,R),me=vl(b.getVisibleLeafColumns().map(Jl),m),ne=i(Q=>{let ze=x[Q.index],{original:Le}=ze,Oe=Te(Le),Ae=_o(Le,Q.index),Se={...Fl,height:`${Q.size.toString()}px`,transform:`translateY(${Q.start.toString()}px)`};return(0,v.jsxs)("tr",{className:"border-b border-border text-xs transition-colors hover:bg-muted/50","data-testid":"db-row",style:Se,children:[(0,v.jsx)(Hl,{row:ze}),le.leadPx>0&&(0,v.jsx)("td",{"aria-hidden":"true",style:{flex:`0 0 ${le.leadPx.toString()}px`}}),ze.getVisibleCells().map((W,et)=>{if(!le.ids.has(W.column.id))return null;let qe=me.get(W.column.id),tt=S!==null&&S.row===Q.index&&S.col===et?" ring-1 ring-ring ring-inset":"";return(0,v.jsx)("td",{className:Ue("group/cell truncate font-mono text-muted-foreground",qe!==void 0&&"border-e border-border bg-background",tt),style:qe===void 0?dn(W.column.getSize()):Ro(W.column.getSize(),qe),children:W.column.id.startsWith(sn)?(0,v.jsx)(kl,{counts:d[W.column.id.slice(sn.length)],rowId:Ae}):(0,v.jsx)(Ll,{cell:W,edit:n,highlight:u,mask:r,refs:c})},W.id)}),le.tailPx>0&&(0,v.jsx)("td",{"aria-hidden":"true",style:{flex:`0 0 ${le.tailPx.toString()}px`}}),(0,v.jsxs)("td",{className:"flex items-center gap-1",style:ho,children:[(0,v.jsx)("button",{className:vo,"data-testid":`db-inspect-${Ae}`,onClick:i(()=>{a(Le)},"onClick"),type:"button",children:"Details"}),o&&(0,v.jsxs)(v.Fragment,{children:[(0,v.jsx)("button",{className:vo,"data-testid":`db-edit-${Ae}`,disabled:Oe===null,onClick:i(()=>{s(Oe,Le)},"onClick"),type:"button",children:"Edit"}),(0,v.jsx)(ct,{confirmLabel:"Delete?",disabled:Oe===null,onConfirm:i(()=>{l(Oe)},"onConfirm"),testId:`db-delete-${Ae}`,children:"Delete"})]})]})]},ze.id)},"Q");q=ht,we="fill",T="db-scroll",U=P,j=p,J="grid",te=Rl,oe=0,xe="w-full text-xs",he="db-rows",ve=_l;let K;e[46]!==b?(K=(0,v.jsx)(Gl,{table:b}),e[46]=b,e[47]=K):K=e[47];let ge;e[48]===Symbol.for("react.memo_cache_sentinel")?(ge=(0,v.jsx)("th",{"aria-label":"Row actions",style:ho}),e[48]=ge):ge=e[48],L=(0,v.jsx)("thead",{className:"bg-muted/50",children:(0,v.jsxs)("tr",{className:"border-b border-border",style:$l,children:[K,le.leadPx>0&&(0,v.jsx)("th",{"aria-hidden":"true",style:{flex:`0 0 ${le.leadPx.toString()}px`}}),b.getFlatHeaders().map(Q=>le.ids.has(Q.column.id)?(0,v.jsx)(Al,{draggedRef:_,header:Q,masked:r.columns.has(Q.column.id),onTogglePin:g,pinnedOffset:me.get(Q.column.id),table:b},Q.id):null),le.tailPx>0&&(0,v.jsx)("th",{"aria-hidden":"true",style:{flex:`0 0 ${le.tailPx.toString()}px`}}),ge]})}),ce=C,fe=y.map(Q=>ne(Q)),e[12]=S,e[13]=p,e[14]=d,e[15]=n,e[16]=o,e[17]=u,e[18]=r,e[19]=l,e[20]=s,e[21]=P,e[22]=a,e[23]=g,e[24]=m,e[25]=c,e[26]=h,e[27]=b,e[28]=x,e[29]=C,e[30]=R,e[31]=y,e[32]=q,e[33]=L,e[34]=T,e[35]=U,e[36]=j,e[37]=J,e[38]=te,e[39]=oe,e[40]=we,e[41]=ce,e[42]=fe,e[43]=xe,e[44]=he,e[45]=ve}else q=e[32],L=e[33],T=e[34],U=e[35],j=e[36],J=e[37],te=e[38],oe=e[39],we=e[40],ce=e[41],fe=e[42],xe=e[43],he=e[44],ve=e[45];let A;e[49]!==ce||e[50]!==fe?(A=(0,v.jsx)("tbody",{style:ce,children:fe}),e[49]=ce,e[50]=fe,e[51]=A):A=e[51];let re;e[52]!==L||e[53]!==A||e[54]!==xe||e[55]!==he||e[56]!==ve?(re=(0,v.jsxs)("table",{className:xe,"data-testid":he,style:ve,children:[L,A]}),e[52]=L,e[53]=A,e[54]=xe,e[55]=he,e[56]=ve,e[57]=re):re=e[57];let ee;e[58]!==T||e[59]!==U||e[60]!==j||e[61]!==J||e[62]!==te||e[63]!==oe||e[64]!==re?(ee=(0,v.jsx)("div",{"data-testid":T,onKeyDown:U,ref:j,role:J,style:te,tabIndex:oe,children:re}),e[58]=T,e[59]=U,e[60]=j,e[61]=J,e[62]=te,e[63]=oe,e[64]=re,e[65]=ee):ee=e[65];let $e;return e[66]!==q||e[67]!==we||e[68]!==ee?($e=(0,v.jsx)(q,{layout:we,children:ee}),e[66]=q,e[67]=we,e[68]=ee,e[69]=$e):$e=e[69],$e},"vo"),jl=i((t,e,n,o=[])=>{let r=t?.columns,l=t?.rows,s=t?.refs,a=(0,N.useMemo)(()=>{if(r===void 0)return[];let S=r.map(F=>({accessorFn:i(V=>V[F],"accessorFn"),header:s?.[F]===void 0?F:`${F} \u2192`,id:F}));for(let F of o)S.push({accessorFn:i(()=>{},"accessorFn"),enableSorting:!1,header:`\u2190 ${F.table}`,id:Pl(F)});return S},[o,r,s]),u=(0,N.useMemo)(()=>l??[],[l]),[d,g]=(0,N.useState)({}),[m,c]=(0,N.useState)({}),f=so({columnResizeMode:"onChange",columns:a,data:u,defaultColumn:{minSize:80,size:200},enableColumnResizing:!0,enableRowSelection:i(S=>Te(S.original)!==null,"enableRowSelection"),getCoreRowModel:ro(),getRowId:i((S,F)=>Te(S)??`row-${F.toString()}`,"getRowId"),getSortedRowModel:lo(),manualSorting:!0,onColumnVisibilityChange:c,onRowSelectionChange:g,onSortingChange:n,state:{columnVisibility:m,rowSelection:d,sorting:e}}),p=f.getRowModel().rows,h=(0,N.useRef)(null),w=mt({count:p.length,estimateSize:i(()=>yl,"estimateSize"),getScrollElement:i(()=>h.current,"getScrollElement"),initialRect:{height:po,width:0},observeElementRect:i((S,F)=>pt(S,F,po),"observeElementRect"),overscan:8}),b=(0,N.useCallback)(S=>{w.scrollToIndex(S)},[w]),[x,C]=(0,N.useState)({left:0,width:0}),R=(0,N.useCallback)(S=>{if(h.current=S,S===null)return;let F=i(()=>{C($=>$.left===S.scrollLeft&&$.width===S.clientWidth?$:{left:S.scrollLeft,width:S.clientWidth})},"C");S.addEventListener("scroll",F,{passive:!0});let V=new ResizeObserver(F);return V.observe(S),()=>{S.removeEventListener("scroll",F),V.disconnect(),h.current=null}},[]),y=w.getVirtualItems(),_={display:"block",height:`${w.getTotalSize().toString()}px`,position:"relative"};return{attachScroll:R,scrollLeft:x.left,scrollToIndex:b,table:f,tableRows:p,tbodyStyle:_,viewportWidth:x.width,virtualRows:y}},"wo");function ql(t){let[e,n]=t;return(0,v.jsxs)("div",{className:"contents",children:[(0,v.jsx)("dt",{className:"truncate font-mono text-[11px] text-muted-foreground",children:e}),(0,v.jsx)("dd",{className:"truncate font-mono text-[11px] text-foreground",title:Je(n),children:Je(n)})]},e)}i(ql,"yo");function Ul(t){return{getSize:i(()=>t.getSize(),"getSize"),id:t.id}}i(Ul,"So");function Jl(t){return{getSize:i(()=>t.getSize(),"getSize"),id:t.id}}i(Jl,"No");var an="inline-flex items-center gap-1 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",Kl=i(t=>{let e=(0,B.c)(22),{onCommit:n}=t,o=X(),[r,l]=(0,N.useState)(""),s=(0,N.useRef)(null),a,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(a=i(()=>{s.current?.focus()},"a"),u=[],e[0]=a,e[1]=u):(a=e[0],u=e[1]),(0,N.useEffect)(a,u);let d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d=i(C=>{l(C.target.value)},"s"),e[2]=d):d=e[2];let g=d,m;e[3]!==r||e[4]!==n?(m=i(()=>{let C=r.trim();C!==""&&n(C)},"c"),e[3]=r,e[4]=n,e[5]=m):m=e[5];let c=m,f;e[6]!==o?(f=o("Query name"),e[6]=o,e[7]=f):f=e[7];let p;e[8]!==o?(p=o("Query name"),e[8]=o,e[9]=p):p=e[9];let h;e[10]!==r||e[11]!==f||e[12]!==p?(h=(0,v.jsx)("input",{"aria-label":f,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:g,placeholder:p,ref:s,value:r}),e[10]=r,e[11]=f,e[12]=p,e[13]=h):h=e[13];let w;e[14]!==o?(w=o("Save"),e[14]=o,e[15]=w):w=e[15];let b;e[16]!==c||e[17]!==w?(b=(0,v.jsx)("button",{className:an,"data-testid":"db-save-query-confirm",onClick:c,type:"button",children:w}),e[16]=c,e[17]=w,e[18]=b):b=e[18];let x;return e[19]!==h||e[20]!==b?(x=(0,v.jsxs)("span",{className:"inline-flex items-center gap-1",children:[h,b]}),e[19]=h,e[20]=b,e[21]=x):x=e[21],x},"Co"),Ql=i(t=>{let e=(0,B.c)(27),{onApply:n,onCopyLink:o,onDelete:r,onSave:l,saved:s}=t,a=X(),[u,d]=(0,N.useState)(!1),g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g=i(()=>{d(!0)},"g"),e[0]=g):g=e[0];let m=g,c;e[1]!==l?(c=i(S=>{l(S),d(!1)},"u"),e[1]=l,e[2]=c):c=e[2];let f=c,p;e[3]!==n||e[4]!==s?(p=i(S=>{let F=s[Number(S.currentTarget.dataset.index)];F!==void 0&&n(F)},"f"),e[3]=n,e[4]=s,e[5]=p):p=e[5];let h=p,w;e[6]!==r||e[7]!==s?(w=i(S=>{let F=s[Number(S.currentTarget.dataset.index)];F!==void 0&&r(F.name)},"v"),e[6]=r,e[7]=s,e[8]=w):w=e[8];let b=w,x;e[9]!==a?(x=a("Copy link"),e[9]=a,e[10]=x):x=e[10];let C;e[11]!==o||e[12]!==x?(C=(0,v.jsx)("button",{className:an,"data-testid":"db-copy-link",onClick:o,type:"button",children:x}),e[11]=o,e[12]=x,e[13]=C):C=e[13];let R;e[14]!==f||e[15]!==u||e[16]!==a?(R=u?(0,v.jsx)(Kl,{onCommit:f}):(0,v.jsx)("button",{className:an,"data-testid":"db-save-query",onClick:m,type:"button",children:a("Save query")}),e[14]=f,e[15]=u,e[16]=a,e[17]=R):R=e[17];let y;e[18]!==h||e[19]!==b||e[20]!==s||e[21]!==a?(y=s.length>0&&(0,v.jsxs)("div",{className:"flex flex-wrap items-center gap-1","data-testid":"db-saved-queries",children:[(0,v.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:a("Saved")}),s.map((S,F)=>(0,v.jsxs)("span",{className:"inline-flex items-center overflow-hidden rounded-md border border-border",children:[(0,v.jsx)("button",{className:"px-2 py-0.5 text-xs text-foreground transition-colors hover:bg-accent","data-index":F,"data-testid":`db-saved-query-${S.name}`,onClick:h,type:"button",children:S.name}),(0,v.jsx)("button",{"aria-label":a("Delete saved query {name}",{name:S.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":F,"data-testid":`db-saved-query-delete-${S.name}`,onClick:b,type:"button",children:"\u2715"})]},S.name))]}),e[18]=h,e[19]=b,e[20]=s,e[21]=a,e[22]=y):y=e[22];let _;return e[23]!==C||e[24]!==R||e[25]!==y?(_=(0,v.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5","data-testid":"db-query-bar",children:[C,R,y]}),e[23]=C,e[24]=R,e[25]=y,e[26]=_):_=e[26],_},"ko"),_t="inline-flex items-center gap-1 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 aria-pressed:bg-accent aria-pressed:text-accent-foreground disabled:pointer-events-none disabled:opacity-50",Nt="w-full rounded-md border border-border bg-background px-2 py-1 font-mono text-xs outline-none focus-visible:border-ring",Wl=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Xl=i((t,e)=>typeof e=="boolean"?"boolean":typeof e=="number"?Wl.test(t)?"date":"number":e!==null&&typeof e=="object"?"json":"text","To"),Zl=i(t=>{try{let e=JSON.parse(t);return e!==null&&typeof e=="object"&&!Array.isArray(e)?e:null}catch{return null}},"Eo"),Yl=i(t=>{let e=new Date(t),n=i(o=>String(o).padStart(2,"0"),"n");return`${e.getFullYear().toString()}-${n(e.getMonth()+1)}-${n(e.getDate())}T${n(e.getHours())}:${n(e.getMinutes())}`},"Ro"),ei=i(t=>{let e=(0,B.c)(8),{column:n,onChange:o,value:r}=t,l;e[0]!==n||e[1]!==o?(l=i(g=>{o(n,g)},"l"),e[0]=n,e[1]=o,e[2]=l):l=e[2];let s=l,a=r===!0,u=`db-field-${n}`,d;return e[3]!==n||e[4]!==s||e[5]!==a||e[6]!==u?(d=(0,v.jsx)(gt,{"aria-label":n,checked:a,"data-testid":u,onCheckedChange:s}),e[3]=n,e[4]=s,e[5]=a,e[6]=u,e[7]=d):d=e[7],d},"_o"),ti=i(t=>{let e=(0,B.c)(8),{column:n,onChange:o,value:r}=t,l;e[0]!==n||e[1]!==o?(l=i(g=>{let m=Number(g.target.value);g.target.value!==""&&!Number.isNaN(m)&&o(n,m)},"l"),e[0]=n,e[1]=o,e[2]=l):l=e[2];let s=l,a=`db-field-${n}`,u=typeof r=="number"?r:"",d;return e[3]!==n||e[4]!==s||e[5]!==a||e[6]!==u?(d=(0,v.jsx)("input",{"aria-label":n,className:Nt,"data-testid":a,onChange:s,type:"number",value:u}),e[3]=n,e[4]=s,e[5]=a,e[6]=u,e[7]=d):d=e[7],d},"Mo"),ni=i(t=>{let e=(0,B.c)(10),{column:n,onChange:o,value:r}=t,l;e[0]!==n||e[1]!==o?(l=i(g=>{let m=new Date(g.target.value).getTime();Number.isNaN(m)||o(n,m)},"l"),e[0]=n,e[1]=o,e[2]=l):l=e[2];let s=l,a=`db-field-${n}`,u;e[3]!==r?(u=typeof r=="number"?Yl(r):"",e[3]=r,e[4]=u):u=e[4];let d;return e[5]!==n||e[6]!==s||e[7]!==a||e[8]!==u?(d=(0,v.jsx)("input",{"aria-label":n,className:Nt,"data-testid":a,onChange:s,type:"datetime-local",value:u}),e[5]=n,e[6]=s,e[7]=a,e[8]=u,e[9]=d):d=e[9],d},"Po"),oi=i(t=>{let e=(0,B.c)(8),{column:n,onChange:o,value:r}=t,l;e[0]!==n||e[1]!==o?(l=i(g=>{o(n,g.target.value)},"l"),e[0]=n,e[1]=o,e[2]=l):l=e[2];let s=l,a=`db-field-${n}`,u=typeof r=="string"?r:"",d;return e[3]!==n||e[4]!==s||e[5]!==a||e[6]!==u?(d=(0,v.jsx)("input",{"aria-label":n,className:Nt,"data-testid":a,onChange:s,type:"text",value:u}),e[3]=n,e[4]=s,e[5]=a,e[6]=u,e[7]=d):d=e[7],d},"Do"),ri=i(t=>{let e=(0,B.c)(20),{column:n,onChange:o,value:r}=t,l=X(),s;e[0]!==r?(s=i(()=>JSON.stringify(r,null,2),"i"),e[0]=r,e[1]=s):s=e[1];let[a,u]=(0,N.useState)(s),[d,g]=(0,N.useState)(!1),m;e[2]!==n||e[3]!==o?(m=i(C=>{let R=C.target.value;u(R);try{o(n,JSON.parse(R)),g(!1)}catch{g(!0)}},"c"),e[2]=n,e[3]=o,e[4]=m):m=e[4];let c=m,f=d&&"border-destructive",p;e[5]!==f?(p=Ue(Nt,"min-h-16",f),e[5]=f,e[6]=p):p=e[6];let h=`db-field-${n}`,w;e[7]!==n||e[8]!==c||e[9]!==p||e[10]!==h||e[11]!==a?(w=(0,v.jsx)("textarea",{"aria-label":n,className:p,"data-testid":h,onChange:c,value:a}),e[7]=n,e[8]=c,e[9]=p,e[10]=h,e[11]=a,e[12]=w):w=e[12];let b;e[13]!==n||e[14]!==d||e[15]!==l?(b=d&&(0,v.jsx)("span",{className:"text-xs text-destructive","data-testid":`db-field-error-${n}`,children:l("Invalid JSON")}),e[13]=n,e[14]=d,e[15]=l,e[16]=b):b=e[16];let x;return e[17]!==w||e[18]!==b?(x=(0,v.jsxs)("div",{className:"flex flex-col gap-1",children:[w,b]}),e[17]=w,e[18]=b,e[19]=x):x=e[19],x},"Io"),li=i(t=>{let e=(0,B.c)(43),{column:n,onChange:o,target:r,value:l}=t,s;e[0]!==n||e[1]!==l?(s=Xl(n,l),e[0]=n,e[1]=l,e[2]=s):s=e[2];let a=s,u=`db-field-${n}`,d;e[3]!==n?(d=(0,v.jsx)("span",{className:"font-mono",children:n}),e[3]=n,e[4]=d):d=e[4];let g;e[5]!==r?(g=r!==void 0&&(0,v.jsxs)("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:["\u2192 ",r]}),e[5]=r,e[6]=g):g=e[6];let m;e[7]!==d||e[8]!==g?(m=(0,v.jsxs)("span",{className:"flex items-center gap-1.5 font-medium text-muted-foreground",children:[d,g]}),e[7]=d,e[8]=g,e[9]=m):m=e[9];let c;e[10]!==n||e[11]!==a||e[12]!==o||e[13]!==l?(c=a==="boolean"&&(0,v.jsx)(ei,{column:n,onChange:o,value:l}),e[10]=n,e[11]=a,e[12]=o,e[13]=l,e[14]=c):c=e[14];let f;e[15]!==n||e[16]!==a||e[17]!==o||e[18]!==l?(f=a==="number"&&(0,v.jsx)(ti,{column:n,onChange:o,value:l}),e[15]=n,e[16]=a,e[17]=o,e[18]=l,e[19]=f):f=e[19];let p;e[20]!==n||e[21]!==a||e[22]!==o||e[23]!==l?(p=a==="date"&&(0,v.jsx)(ni,{column:n,onChange:o,value:l}),e[20]=n,e[21]=a,e[22]=o,e[23]=l,e[24]=p):p=e[24];let h;e[25]!==n||e[26]!==a||e[27]!==o||e[28]!==l?(h=a==="json"&&(0,v.jsx)(ri,{column:n,onChange:o,value:l}),e[25]=n,e[26]=a,e[27]=o,e[28]=l,e[29]=h):h=e[29];let w;e[30]!==n||e[31]!==a||e[32]!==o||e[33]!==l?(w=a==="text"&&(0,v.jsx)(oi,{column:n,onChange:o,value:l}),e[30]=n,e[31]=a,e[32]=o,e[33]=l,e[34]=w):w=e[34];let b;return e[35]!==w||e[36]!==u||e[37]!==m||e[38]!==c||e[39]!==f||e[40]!==p||e[41]!==h?(b=(0,v.jsxs)("label",{className:"flex flex-col gap-1 text-xs",htmlFor:u,children:[m,c,f,p,h,w]}),e[35]=w,e[36]=u,e[37]=m,e[38]=c,e[39]=f,e[40]=p,e[41]=h,e[42]=b):b=e[42],b},"Oo"),ii=i(t=>{let e=(0,B.c)(48),{documentText:n,onCancel:o,onDocumentTextChange:r,onSave:l,refs:s}=t,a=X(),u;e[0]!==n?(u=Zl(n),e[0]=n,e[1]=u):u=e[1];let d=u,[g,m]=(0,N.useState)(!1),c=!g&&d!==null,f;e[2]!==d||e[3]!==r?(f=i((j,J)=>{r(JSON.stringify({...d,[j]:J},null,2))},"b"),e[2]=d,e[3]=r,e[4]=f):f=e[4];let p=f,h;e[5]!==r?(h=i(j=>{r(j.target.value)},"p"),e[5]=r,e[6]=h):h=e[6];let w=h,b;e[7]===Symbol.for("react.memo_cache_sentinel")?(b=i(()=>{m(!1)},"x"),e[7]=b):b=e[7];let x=b,C;e[8]===Symbol.for("react.memo_cache_sentinel")?(C=i(()=>{m(!0)},"y"),e[8]=C):C=e[8];let R=C,y=d===null,_;e[9]!==a?(_=a("Form"),e[9]=a,e[10]=_):_=e[10];let S;e[11]!==c||e[12]!==y||e[13]!==_?(S=(0,v.jsx)("button",{"aria-pressed":c,className:_t,"data-testid":"db-editor-form",disabled:y,onClick:x,type:"button",children:_}),e[11]=c,e[12]=y,e[13]=_,e[14]=S):S=e[14];let F=!c,V;e[15]!==a?(V=a("JSON"),e[15]=a,e[16]=V):V=e[16];let $;e[17]!==V||e[18]!==F?($=(0,v.jsx)("button",{"aria-pressed":F,className:_t,"data-testid":"db-editor-json",onClick:R,type:"button",children:V}),e[17]=V,e[18]=F,e[19]=$):$=e[19];let M;e[20]!==$||e[21]!==S?(M=(0,v.jsxs)("div",{className:"flex items-center gap-1.5",children:[S,$]}),e[20]=$,e[21]=S,e[22]=M):M=e[22];let P;e[23]!==n||e[24]!==d||e[25]!==p||e[26]!==w||e[27]!==s||e[28]!==c||e[29]!==a?(P=c?(0,v.jsx)("div",{className:"flex flex-col gap-3","data-testid":"db-editor-fields",children:Object.entries(d).map(j=>{let[J,te]=j;return(0,v.jsx)(li,{column:J,onChange:p,target:s?.[J],value:te},J)})}):(0,v.jsx)("textarea",{"aria-label":a("Row document JSON"),className:"min-h-28 w-full rounded-md border border-border bg-background px-2 py-1.5 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"db-editor-doc",onChange:w,value:n}),e[23]=n,e[24]=d,e[25]=p,e[26]=w,e[27]=s,e[28]=c,e[29]=a,e[30]=P):P=e[30];let k;e[31]!==a?(k=a("Save"),e[31]=a,e[32]=k):k=e[32];let O;e[33]!==l||e[34]!==k?(O=(0,v.jsx)("button",{className:_t,"data-testid":"db-editor-save",onClick:l,type:"button",children:k}),e[33]=l,e[34]=k,e[35]=O):O=e[35];let q;e[36]!==a?(q=a("Cancel"),e[36]=a,e[37]=q):q=e[37];let L;e[38]!==o||e[39]!==q?(L=(0,v.jsx)("button",{className:_t,"data-testid":"db-editor-cancel",onClick:o,type:"button",children:q}),e[38]=o,e[39]=q,e[40]=L):L=e[40];let T;e[41]!==O||e[42]!==L?(T=(0,v.jsxs)("div",{className:"flex items-center gap-1.5",children:[O,L]}),e[41]=O,e[42]=L,e[43]=T):T=e[43];let U;return e[44]!==M||e[45]!==P||e[46]!==T?(U=(0,v.jsxs)("div",{className:"flex flex-col gap-2 border border-border bg-card p-3","data-testid":"db-editor",children:[M,P,T]}),e[44]=M,e[45]=P,e[46]=T,e[47]=U):U=e[47],U},"Fo"),ut="inline-flex items-center gap-1 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 aria-pressed:bg-accent aria-pressed:text-accent-foreground",si=i(t=>{let e=(0,B.c)(61),{columns:n,editable:o,filter:r,filters:l,hasMaskedColumns:s,liveError:a,maskOn:u,onAddRow:d,onBulkDelete:g,onAskAiFilter:m,onClearTable:c,onFilterChange:f,onFiltersChange:p,onGenerateRows:h,onShowJson:w,onShowTable:b,onToggleMask:x,total:C,viewMode:R}=t,y=X(),_=R==="table",S;e[0]!==b||e[1]!==_?(S=(0,v.jsx)("button",{"aria-pressed":_,className:ut,"data-testid":"db-view-table",onClick:b,type:"button",children:"Table"}),e[0]=b,e[1]=_,e[2]=S):S=e[2];let F=R==="json",V;e[3]!==w||e[4]!==F?(V=(0,v.jsx)("button",{"aria-pressed":F,className:ut,"data-testid":"db-view-json",onClick:w,type:"button",children:"JSON"}),e[3]=w,e[4]=F,e[5]=V):V=e[5];let $;e[6]!==a||e[7]!==y?($=a===void 0?y("Live \u2014 changes stream in automatically"):y("Live unavailable: {liveError}",{liveError:a}),e[6]=a,e[7]=y,e[8]=$):$=e[8];let M=`size-1.5 rounded-full ${a===void 0?"bg-success":"bg-muted-foreground/50"}`,P;e[9]!==M?(P=(0,v.jsx)("span",{"aria-hidden":"true",className:M}),e[9]=M,e[10]=P):P=e[10];let k;e[11]!==a||e[12]!==y?(k=y(a===void 0?"Live":"Live unavailable"),e[11]=a,e[12]=y,e[13]=k):k=e[13];let O;e[14]!==$||e[15]!==P||e[16]!==k?(O=(0,v.jsxs)("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:[P,k]}),e[14]=$,e[15]=P,e[16]=k,e[17]=O):O=e[17];let q;e[18]!==s||e[19]!==u||e[20]!==x||e[21]!==y?(q=s&&(0,v.jsx)("button",{"aria-pressed":u,className:ut,"data-testid":"db-mask-toggle",onClick:x,type:"button",children:y("Mask sensitive columns")}),e[18]=s,e[19]=u,e[20]=x,e[21]=y,e[22]=q):q=e[22];let L;e[23]!==o||e[24]!==d?(L=o&&(0,v.jsx)("button",{className:ut,"data-testid":"db-add-row",onClick:d,type:"button",children:"Add row"}),e[23]=o,e[24]=d,e[25]=L):L=e[25];let T;e[26]!==o||e[27]!==h||e[28]!==y?(T=o&&(0,v.jsx)("button",{className:ut,"data-testid":"db-generate-rows",onClick:h,type:"button",children:y("Generate rows")}),e[26]=o,e[27]=h,e[28]=y,e[29]=T):T=e[29];let U;e[30]!==o||e[31]!==r||e[32]!==l||e[33]!==g||e[34]!==C?(U=o&&C>0&&(r!==""||l.length>0)&&(0,v.jsx)(ct,{confirmLabel:`Delete ${C.toString()} matching?`,onConfirm:g,testId:"db-bulk-delete",children:`Delete ${C.toString()} matching`}),e[30]=o,e[31]=r,e[32]=l,e[33]=g,e[34]=C,e[35]=U):U=e[35];let j;e[36]!==o||e[37]!==r||e[38]!==l||e[39]!==c||e[40]!==C?(j=o&&C>0&&r===""&&l.length===0&&(0,v.jsx)(ct,{confirmLabel:`Clear all ${C.toString()} rows?`,onConfirm:c,testId:"db-clear-table",children:`Clear table (${C.toString()})`}),e[36]=o,e[37]=r,e[38]=l,e[39]=c,e[40]=C,e[41]=j):j=e[41];let J;e[42]!==q||e[43]!==L||e[44]!==T||e[45]!==U||e[46]!==j||e[47]!==S||e[48]!==V||e[49]!==O?(J=(0,v.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[S,V,O,q,L,T,U,j]}),e[42]=q,e[43]=L,e[44]=T,e[45]=U,e[46]=j,e[47]=S,e[48]=V,e[49]=O,e[50]=J):J=e[50];let te;e[51]!==n||e[52]!==r||e[53]!==l||e[54]!==m||e[55]!==f||e[56]!==p?(te=(0,v.jsx)(co,{columns:n,filters:l,onAskAi:m,onFiltersChange:p,onSearchChange:f,search:r}),e[51]=n,e[52]=r,e[53]=l,e[54]=m,e[55]=f,e[56]=p,e[57]=te):te=e[57];let oe;return e[58]!==J||e[59]!==te?(oe=(0,v.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"db-view-toggle",children:[J,te]}),e[58]=J,e[59]=te,e[60]=oe):oe=e[60],oe},"zo"),ai=i(t=>{let e=(0,B.c)(101),{assistant:n,backRelations:o,browser:r,edit:l,editable:s,onAskAiFilter:a,onInspect:u,onOpenGenerateRows:d,onSaveQuery:g,page:m,preferences:c,queryBar:f,references:p}=t,h=c.maskColumns.size>0,w=n.unavailable?void 0:a,b;e[0]!==r.addRow||e[1]!==r.bulkDelete||e[2]!==r.clearTable||e[3]!==r.columns||e[4]!==r.filter||e[5]!==r.filters||e[6]!==r.liveError||e[7]!==r.onFilterChange||e[8]!==r.onFiltersChange||e[9]!==r.showJson||e[10]!==r.showTable||e[11]!==r.total||e[12]!==r.viewMode||e[13]!==s||e[14]!==d||e[15]!==c.maskOn||e[16]!==c.onToggleMask||e[17]!==h||e[18]!==w?(b=(0,v.jsx)(si,{columns:r.columns,editable:s,filter:r.filter,filters:r.filters,hasMaskedColumns:h,liveError:r.liveError,maskOn:c.maskOn,onAddRow:r.addRow,onAskAiFilter:w,onBulkDelete:r.bulkDelete,onClearTable:r.clearTable,onFilterChange:r.onFilterChange,onFiltersChange:r.onFiltersChange,onGenerateRows:d,onShowJson:r.showJson,onShowTable:r.showTable,onToggleMask:c.onToggleMask,total:r.total,viewMode:r.viewMode}),e[0]=r.addRow,e[1]=r.bulkDelete,e[2]=r.clearTable,e[3]=r.columns,e[4]=r.filter,e[5]=r.filters,e[6]=r.liveError,e[7]=r.onFilterChange,e[8]=r.onFiltersChange,e[9]=r.showJson,e[10]=r.showTable,e[11]=r.total,e[12]=r.viewMode,e[13]=s,e[14]=d,e[15]=c.maskOn,e[16]=c.onToggleMask,e[17]=h,e[18]=w,e[19]=b):b=e[19];let x;e[20]!==g||e[21]!==f?(x=f!==void 0&&(0,v.jsx)(Ql,{onApply:f.onApplyQuery,onCopyLink:f.onCopyLink,onDelete:f.onDeleteQuery,onSave:g,saved:f.saved}),e[20]=g,e[21]=f,e[22]=x):x=e[22];let C;e[23]!==o||e[24]!==r.onBulkDeleteSelected||e[25]!==r.selectedTable||e[26]!==r.table||e[27]!==r.viewMode||e[28]!==s||e[29]!==m||e[30]!==c.onToggleTranspose||e[31]!==c.transposed?(C=r.viewMode==="table"&&m.rows.length>0&&(0,v.jsx)(zn,{backRelations:o.available,columns:m.columns,editable:s,enabledBackRelations:o.enabled,name:r.selectedTable??"export",onBulkDelete:r.onBulkDeleteSelected,onToggleBackRelation:o.onToggle,onToggleTranspose:c.onToggleTranspose,rows:m.rows,table:r.table.table,transposed:c.transposed}),e[23]=o,e[24]=r.onBulkDeleteSelected,e[25]=r.selectedTable,e[26]=r.table,e[27]=r.viewMode,e[28]=s,e[29]=m,e[30]=c.onToggleTranspose,e[31]=c.transposed,e[32]=C):C=e[32];let R;e[33]!==r.cancelEdit||e[34]!==r.editing||e[35]!==r.saveEdit||e[36]!==r.setEditorDocumentText||e[37]!==s||e[38]!==m?(R=s&&r.editing!==null&&(0,v.jsx)(ii,{documentText:r.editing.docText,onCancel:r.cancelEdit,onDocumentTextChange:r.setEditorDocumentText,onSave:r.saveEdit,refs:m.refs}),e[33]=r.cancelEdit,e[34]=r.editing,e[35]=r.saveEdit,e[36]=r.setEditorDocumentText,e[37]=s,e[38]=m,e[39]=R):R=e[39];let y;e[40]!==r.committing||e[41]!==r.discardStaged||e[42]!==r.onCommitStaged||e[43]!==r.stagedChanges||e[44]!==s?(y=s&&r.stagedChanges.length>0&&(0,v.jsx)(xl,{changes:r.stagedChanges,committing:r.committing,onCommit:r.onCommitStaged,onDiscard:r.discardStaged}),e[40]=r.committing,e[41]=r.discardStaged,e[42]=r.onCommitStaged,e[43]=r.stagedChanges,e[44]=s,e[45]=y):y=e[45];let _;e[46]!==r.writeError?(_=r.writeError!==null&&(0,v.jsx)("p",{className:"text-sm text-destructive","data-testid":"db-write-error",role:"alert",children:r.writeError}),e[46]=r.writeError,e[47]=_):_=e[47];let S;e[48]!==b||e[49]!==x||e[50]!==C||e[51]!==R||e[52]!==y||e[53]!==_?(S=(0,v.jsxs)("div",{className:"flex shrink-0 flex-col gap-2 border-b border-border px-4 py-3",children:[b,x,C,R,y,_]}),e[48]=b,e[49]=x,e[50]=C,e[51]=R,e[52]=y,e[53]=_,e[54]=S):S=e[54];let F;e[55]!==r.viewMode||e[56]!==m?(F=r.viewMode==="table"&&m.rows.length===0&&(0,v.jsx)("div",{className:"flex flex-1 items-center justify-center p-6",children:(0,v.jsx)(dt,{description:"Rows you insert into this table will show up here.",icon:(0,v.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,v.jsx)("path",{d:"M4 5h16v14H4V5Zm0 5h16M10 10v9M4 14.5h16"})}),testId:"db-empty-rows",title:"This table is empty."})}),e[55]=r.viewMode,e[56]=m,e[57]=F):F=e[57];let V;e[58]!==r.viewMode||e[59]!==m||e[60]!==c.maskView||e[61]!==c.transposed?(V=r.viewMode==="table"&&m.rows.length>0&&c.transposed&&(0,v.jsx)(Dn,{columns:m.columns,rows:mo(m.rows,c.maskView)}),e[58]=r.viewMode,e[59]=m,e[60]=c.maskView,e[61]=c.transposed,e[62]=V):V=e[62];let $;e[63]!==o||e[64]!==r.filter||e[65]!==r.onRowDelete||e[66]!==r.onRowEdit||e[67]!==r.table||e[68]!==r.viewMode||e[69]!==l||e[70]!==s||e[71]!==u||e[72]!==m||e[73]!==c.maskView||e[74]!==c.onTogglePin||e[75]!==c.pinnedColumns||e[76]!==c.transposed||e[77]!==p?($=r.viewMode==="table"&&m.rows.length>0&&!c.transposed&&(0,v.jsx)(Bl,{backRelationCounts:o.counts,edit:l,editable:s,highlight:r.filter,mask:c.maskView,onDelete:r.onRowDelete,onEdit:r.onRowEdit,onInspect:u,onTogglePin:c.onTogglePin,pinnedColumns:c.pinnedColumns,refs:p,tableModel:r.table}),e[63]=o,e[64]=r.filter,e[65]=r.onRowDelete,e[66]=r.onRowEdit,e[67]=r.table,e[68]=r.viewMode,e[69]=l,e[70]=s,e[71]=u,e[72]=m,e[73]=c.maskView,e[74]=c.onTogglePin,e[75]=c.pinnedColumns,e[76]=c.transposed,e[77]=p,e[78]=$):$=e[78];let M;e[79]!==r.viewMode||e[80]!==m||e[81]!==c.maskView?(M=r.viewMode==="json"&&(0,v.jsx)("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(mo(m.rows,c.maskView),xn,2)}),e[79]=r.viewMode,e[80]=m,e[81]=c.maskView,e[82]=M):M=e[82];let P;e[83]!==r.changePageSize||e[84]!==r.goNext||e[85]!==r.goPrevious||e[86]!==r.hasNext||e[87]!==r.hasPrevious||e[88]!==r.jumpToPage||e[89]!==r.pageSize||e[90]!==r.rangeEnd||e[91]!==r.rangeStart||e[92]!==r.total?(P=(0,v.jsx)("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:(0,v.jsx)(vt,{hasNext:r.hasNext,hasPrevious:r.hasPrevious,onJumpToPage:r.jumpToPage,onNext:r.goNext,onPageSizeChange:r.changePageSize,onPrevious:r.goPrevious,pageSize:r.pageSize,prefix:"db",rangeEnd:r.rangeEnd,rangeStart:r.rangeStart,total:r.total})}),e[83]=r.changePageSize,e[84]=r.goNext,e[85]=r.goPrevious,e[86]=r.hasNext,e[87]=r.hasPrevious,e[88]=r.jumpToPage,e[89]=r.pageSize,e[90]=r.rangeEnd,e[91]=r.rangeStart,e[92]=r.total,e[93]=P):P=e[93];let k;return e[94]!==F||e[95]!==V||e[96]!==$||e[97]!==M||e[98]!==P||e[99]!==S?(k=(0,v.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"db-page",children:[S,F,V,$,M,P]}),e[94]=F,e[95]=V,e[96]=$,e[97]=M,e[98]=P,e[99]=S,e[100]=k):k=e[100],k},"jo"),ui="/__lunora/seed",rn=200,di=50,ci=i((t,e)=>{let n=[];for(let o of t)o.pk!==!0&&o.ref!==void 0&&o.type==="id"&&(e[o.ref]??[]).length===0&&n.push(o.name);return n},"Bo"),gi=i(async t=>{let e=await fetch(ui,{body:JSON.stringify(t),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)})`}},"Vo"),fi="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",mi="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",pi=i(({columns:t,fkPools:e,onClose:n,onInsertRows:o,table:r})=>{let l=X(),[s,a]=(0,N.useState)(10),[u,d]=(0,N.useState)(!1),[g,m]=(0,N.useState)(void 0),[c,f]=(0,N.useState)(void 0),[p,h]=(0,N.useState)(0),w=i(R=>{let y=Number(R.target.value);!Number.isNaN(y)&&y>=1&&a(Math.min(y,rn))},"v"),b=i(async()=>{m(void 0),f(void 0),h(0),d(!0);try{let R=await gi({count:s,existingIds:e,seed:Date.now(),table:r});if(R.kind==="error"){m(R.message);return}let{rows:y}=R;if(y.length===0){m(l("No rows generated \u2014 all columns were skipped."));return}let _=await o(y);if(_.error!==void 0){m(_.error);return}f(_.inserted),h(_.conflicts);let S=ci(t,e);S.length>0&&m(l("Inserted {count} rows. Skipped FK columns: {cols}",{cols:S.join(", "),count:_.inserted.toString()}))}finally{d(!1)}},"x"),x=i(()=>{Z(b())},"w"),C=t.filter(R=>R.pk!==!0);return(0,v.jsxs)(Gt,{label:l("Generate dummy rows"),onClose:n,panelTestId:"gen-rows-panel",testId:"gen-rows-overlay",variant:"dialog",children:[(0,v.jsxs)("div",{className:"flex items-start justify-between",children:[(0,v.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,v.jsx)("h3",{className:"text-base text-foreground","data-testid":"gen-rows-title",children:l("Generate dummy rows")}),(0,v.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"gen-rows-desc",children:l("Seed {table} with Faker-generated rows. Existing rows are not affected.",{table:r})})]}),(0,v.jsx)("button",{className:"text-xs text-muted-foreground hover:text-foreground","data-testid":"gen-rows-close",onClick:n,type:"button",children:l("Close")})]}),(0,v.jsxs)("div",{className:"flex items-center gap-2",children:[(0,v.jsx)("label",{className:"text-xs font-medium text-foreground",htmlFor:"gen-rows-count",children:l("Row count")}),(0,v.jsx)("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:rn,min:1,onChange:w,type:"number",value:s}),(0,v.jsx)("span",{className:"text-xs text-muted-foreground",children:l("(max {max})",{max:rn.toString()})})]}),C.length>0&&(0,v.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,v.jsx)("p",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:l("Columns to seed")}),(0,v.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"gen-rows-columns",children:C.map(R=>{let y=R.ref!==void 0&&R.type==="id",_=y&&(e[R.ref??""]??[]).length===0,S=_?"rounded bg-destructive/10 px-1 text-destructive":"rounded bg-muted px-1 text-muted-foreground",F=_?`gen-rows-fk-empty-${R.name}`:`gen-rows-fk-ok-${R.name}`,V=_?l("FK: no rows in {ref} \u2014 will skip",{ref:R.ref??""}):l("\u2192 {ref}",{ref:R.ref??""});return(0,v.jsxs)("li",{className:"flex items-center gap-1.5 font-mono text-xs",children:[(0,v.jsx)("span",{className:"text-foreground",children:R.name}),(0,v.jsxs)("span",{className:"text-muted-foreground",children:["(",R.type,")"]}),R.optional&&(0,v.jsx)("span",{className:"rounded bg-muted px-1 font-mono text-[10px] tracking-wide uppercase",children:"optional"}),y&&(0,v.jsx)("span",{className:S,"data-testid":F,children:V})]},R.name)})})]}),g!==void 0&&(0,v.jsx)("p",{className:"text-xs text-destructive","data-testid":"gen-rows-error",role:"alert",children:g}),c!==void 0&&g===void 0&&(0,v.jsx)("p",{className:"text-xs text-success","data-testid":"gen-rows-success",children:p>0?l("Inserted {inserted} of {total} rows \u2014 {conflicts} skipped as id conflicts.",{conflicts:p.toString(),inserted:c.toString(),total:(c+p).toString()}):l("Inserted {count} rows successfully.",{count:c.toString()})}),(0,v.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,v.jsx)("button",{className:fi,"data-testid":"gen-rows-cancel",onClick:n,type:"button",children:l("Cancel")}),(0,v.jsx)("button",{className:mi,"data-testid":"gen-rows-generate",disabled:u,onClick:x,type:"button",children:l(u?"Inserting\u2026":"Generate & insert")})]})]})},"Ko"),hi=ye(ue.backRelationCounts),vi=i((t,e,n,o)=>{let r=(0,B.c)(16),l=Ee(),s;r[0]===Symbol.for("react.memo_cache_sentinel")?(s={},r[0]=s):s=r[0];let[a,u]=(0,N.useState)(s),d;if(r[1]!==t||r[2]!==e){let b;r[4]!==t?(b=i(x=>t.has(un(x)),"x"),r[4]=t,r[5]=b):b=r[5],d=e.filter(b),r[1]=t,r[2]=e,r[3]=d}else d=r[3];let g=d,m;r[6]!==n||r[7]!==g?(m=JSON.stringify([g,n]),r[6]=n,r[7]=g,r[8]=m):m=r[8];let c=m,f;r[9]!==l||r[10]!==o||r[11]!==c?(f=i(async b=>{let[x,C]=JSON.parse(c);if(x.length===0||C.length===0){b.cancelled||u({});return}try{let R=await l.query(hi,{ids:C,relations:x},Ce(o));b.cancelled||u(Object.fromEntries(R.relations.map(bi)))}catch{}},"b"),r[9]=l,r[10]=o,r[11]=c,r[12]=f):f=r[12];let p=f,h,w;return r[13]!==p?(h=i(()=>{let b={cancelled:!1};return Z(p(b)),()=>{b.cancelled=!0}},"p"),w=[p],r[13]=p,r[14]=h,r[15]=w):(h=r[14],w=r[15]),(0,N.useEffect)(h,w),a},"Ho");function bi(t){return[un(t),t.counts]}i(bi,"Qo");var $t=i(t=>{let e=t[0];return e===void 0?void 0:{column:e.id,direction:e.desc?"desc":"asc"}},"Be"),Fo=i(t=>t==null?"":typeof t=="object"?JSON.stringify(t):String(t),"Pt"),wo=i(t=>t.map(e=>({column:e.column,operator:e.operator,value:e.value===void 0?"":Fo(e.value)})),"Nt"),xo=i(t=>t===void 0?[]:[{desc:t.direction==="desc",id:t.column}],"Ct"),wi=i(t=>[t.column,t.operator,t.value],"Wo"),Ft=i((t,e,n,o)=>JSON.stringify([t??"",e??"",(n??[]).map(r=>wi(r)),o===void 0?null:[o.column,o.direction]]),"Le"),So=200,xi=20,Si=ye(ue.readTablePage),Ci=ye(ue.facetColumn),ln=ye(ue.writeRow),yi=ye(ue.deleteRows),Ri=ye(ue.clearTable),_i={},cn=new Set(["__doc__","__id__","_creationTime","_id","id"]),Fi=i(t=>{let e=t.__doc__;if(typeof e=="string"){let o=Gn(e);if(o!==void 0)return o}let n={};for(let[o,r]of Object.entries(t))cn.has(o)||(n[o]=r);return n},"nr"),$i=i(({filters:t,offset:e,pageSize:n,search:o,sorting:r,table:l})=>({filters:je(t),limit:n,offset:e,orderBy:$t(r),search:o,skipCount:!0,table:l}),"or"),Ni=i(({filters:t,search:e,table:n})=>({filters:je(t),limit:1,search:e,table:n}),"rr"),Mi=i((t,e)=>{let n=new Map;for(let r of t?.rows??[]){let l=Te(r);l!==null&&n.set(l,r)}let o=[];for(let[r,l]of Object.entries(e))for(let[s,a]of Object.entries(l))o.push({column:s,newValue:a,oldValue:n.get(r)?.[s],rowId:r});return o},"lr"),Pi=i(t=>!cn.has(t),"ar"),ki=i(({initialFilters:t,initialOrderBy:e,initialSearch:n,initialShardKey:o,onSelectTable:r,onViewChange:l,pageSize:s,resolveBackRelations:a,tableParam:u})=>{let d=Ee(),[g,m]=(0,N.useState)(s),[c,f]=(0,N.useState)(o??""),p=u===void 0||u===""?null:u,[h,w]=(0,N.useState)(0),[b,x]=(0,N.useState)("table"),[C,R]=(0,N.useState)(()=>xo(e)),[y,_]=(0,N.useState)(n??""),[S,F]=(0,N.useState)(()=>wo(t??[])),{clearFacets:V,facets:$,refetchFacets:M,toggleFacet:P}=wt(),[k,O]=(0,N.useState)(null),[q,L]=(0,N.useState)(null),T=bl(),[U,j]=(0,N.useState)(null),[J,te]=(0,N.useState)(!1),[oe,we]=(0,N.useState)(u),[ce,fe]=(0,N.useState)(()=>Ft(o,n,t,e)),[xe,he]=(0,N.useState)(0),[ve,A]=(0,N.useState)(()=>Ft(o,n,t,e)),re=u!==oe,ee=Ft(o,n,t,e),$e=re||!re&&ee!==ce&&ee!==ve;if($e){we(u),fe(ee),he(H=>H+1),R(xo(e)),_(n??"");let E=wo(t??[]);F(E),f(o??""),V(),T.clear(),j(null),w(0)}else ee!==ce&&fe(ee);let Ne=$e?n??"":y,le=$e?o??"":c,me=`${u??""}:${xe.toString()}`,ne=Ht(Ne.trim(),300,me),K=Ht(le.trim(),400,me),ge=Ft(K,ne,je(S),$t(C));ge!==ve&&A(ge);let Q=Xe(ue.listTables,_i,{live:!0,shardKey:K}),ze=Q.data??null,Le=Q.error,Oe=$i({filters:S,offset:h,pageSize:g,search:ne,sorting:C,table:p??""}),Ae=Ni({filters:S,search:ne,table:p??""}),Se=Xe(ue.readTablePage,Oe,{enabled:p!==null,keepPreviousData:!1,live:!0,shardKey:K}),W=Se.data??null,et=Se.error,{liveError:qe}=Se,tt=Xe(ue.readTablePage,Ae,{enabled:p!==null,live:!0,shardKey:K});(0,N.useEffect)(()=>{Q.data!==void 0&&Fn(K)},[Q.data,K]);let Pt=i(E=>{r?.(E)},"Ge"),kt=i((E,H)=>{r?.(E,{search:H})},"He"),Vt=i(async(E,H)=>{try{return(await d.query(Si,{filters:[],limit:xi,offset:0,search:H,table:E},Ce(K))).rows.find(pe=>Te(pe)===H)??null}catch{return null}},"Qe"),nt=i((E,H,pe,Ve)=>Ge=>d.query(Ci,{column:Ge,filters:je(pe),search:Ve,table:H},Ce(E)),"Ie"),Et=i(E=>{P(E,p===null?null:nt(K,p,S,ne))},"We"),It=i((E,H)=>{let pe=Fo(H);F(Ve=>[...Ve.filter(Ge=>Ge.column!==E),{column:E,operator:"eq",value:pe}]),w(0)},"Ue"),Dt=Ie(nt),Tt=Ie(M),Y=Ie(l);(0,N.useEffect)(()=>{p!==null&&Tt.current(Dt.current(K,p,S,ne))},[K,p,S,ne]),(0,N.useEffect)(()=>{p===null||Y.current===void 0||oe!==u||ce!==ee||Y.current({filters:je(S),orderBy:$t(C),search:ne,shard:K})},[p,u,oe,ce,ee,S,C,ne,K]);let ie=i(E=>{p!==null&&w(Math.max(0,E))},"U"),Me=i((E,H)=>{j({column:H,rowId:E})},"he"),Pe=i(()=>{j(null)},"xe"),ot=i(async()=>{if(p!==null){L(null),te(!0);try{for(let[E,H]of Object.entries(T.staged))await d.query(ln,{doc:H,id:E,op:"patch",table:p},Ce(K));T.clear(),j(null),Se.refetch()}catch(E){L(E.message)}te(!1)}},"Oe"),Eo=i(()=>{T.clear(),j(null)},"Dt"),Io=Mi(W,T.staged),fn=i(async(E,H,pe)=>{if(p===null)return;L(null);let Ve;if(E!=="delete"){let Ge;try{Ge=pe===void 0||pe.trim()===""?{}:JSON.parse(pe)}catch(Qe){L(`Invalid JSON: ${Qe.message}`);return}try{let Qe=An(Ge);if(!Ln(Qe)){L("The document must be a JSON object.");return}Ve=Qe}catch(Qe){L(`Invalid document: ${Qe.message}`);return}}try{await d.query(ln,{doc:Ve,id:H??void 0,op:E,table:p},Ce(K)),O(null),Se.refetch()}catch(Ge){L(Ge.message)}},"mt"),mn=i(async(E,H)=>{if(p!==null){L(null);try{let pe="cap-hit";for(let Ve=0;Ve<So;Ve+=1)if(!(await d.query(E,H,Ce(K))).hasMore){pe="completed";break}w(0),Se.refetch(),pe==="cap-hit"&&L(`Stopped after ${So.toString()} batches \u2014 rows still match this delete. Run it again to remove the rest.`)}catch(pe){L(pe.message)}}},"gt"),Do=i(E=>{R(E),w(0)},"Ot"),To=(0,N.useMemo)(()=>p===null?[]:a?.(p)??[],[a,p]),zo=jl(W,C,Do,To),Lo={filters:je(S),orderBy:$t(C),search:ne,shard:c,table:p??void 0},pn=tt.data?.total??(W===null?0:h+W.rows.length),Oo=h>0,Ao=W!==null&&h+W.rows.length<pn,Go=W===null||W.rows.length===0?0:h+1,Ho=W===null?0:h+W.rows.length,Bo=i(()=>{Q.refetch()},"qt"),jo=i(()=>{x("table")},"Jt"),qo=i(()=>{x("json")},"Kt"),Uo=i(()=>{Z(mn(yi,{filters:je(S),search:ne,table:p}))},"Gt"),Jo=i(()=>{Z(mn(Ri,{table:p}))},"Ht"),Ko=i(E=>{_(E.target.value),w(0)},"Qt"),Qo=i(E=>{F(E),w(0)},"Wt"),Wo=i(()=>{L(null);let E={};for(let H of W?.columns??[])cn.has(H)||(E[H]="");O({docText:JSON.stringify(E,null,2),id:""})},"Ut"),Xo=i(E=>{O(H=>H===null?H:{docText:E,id:H.id})},"Zt"),Zo=i(()=>{k!==null&&Z(fn(k.id===""?"insert":"patch",k.id===""?null:k.id,k.docText))},"Xt"),Yo=i(()=>{O(null),L(null)},"Yt"),er=i(()=>{ie(h-g)},"en"),tr=i(()=>{ie(h+g)},"tn"),nr=i(E=>{ie(Math.max(0,(E-1)*g))},"nn"),or=i(E=>{m(E),w(0)},"on"),rr=i((E,H)=>{L(null),O({docText:JSON.stringify(On(Fi(H)),null,2),id:E})},"rn"),lr=i(E=>{Z(fn("delete",E))},"ln"),ir=i(async E=>{if(!(p===null||E.length===0)){L(null);try{for(let H of E)await d.query(ln,{id:H,op:"delete",table:p},Ce(K));Se.refetch()}catch(H){L(H.message)}}},"an"),sr=i(E=>{Z(ir(E))},"sn"),ar=i(()=>{Z(ot())},"dn");return{addRow:Wo,bulkDelete:Uo,cancelCellEdit:Pe,cancelEdit:Yo,changePageSize:or,clearTable:Jo,columns:W?.columns??[],committing:J,currentView:Lo,discardStaged:Eo,editableColumn:Pi,editing:k,editingCell:U,facetFilter:It,facets:$,filter:y,filters:S,goNext:tr,goPrevious:er,hasNext:Ao,hasPrevious:Oo,jumpToPage:nr,liveError:qe,loadTables:Bo,navigateToRef:kt,onBulkDeleteSelected:sr,onCommitStaged:ar,onFilterChange:Ko,onFiltersChange:Qo,onRowDelete:lr,onRowEdit:rr,page:W,previewRef:Vt,pageError:et,pageSize:g,rangeEnd:Ho,rangeStart:Go,queryShardKey:K,saveEdit:Zo,selectedTable:p,selectTable:Pt,setEditorDocumentText:Xo,setShardKey:f,shardKey:c,showJson:qo,showTable:jo,stage:T.stage,stagedChanges:Io,stagedValue:T.stagedValue,startCellEdit:Me,table:zo,tables:ze,tablesError:Le,toggleFacet:Et,total:pn,viewMode:b,writeError:q}},"sr"),Vi=[],Ei=i(()=>{let t=(0,B.c)(1),e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e={},t[0]=e):e=t[0];let{data:n}=Xe(ue.maskPolicies,e);return Array.isArray(n?.columns)?n.columns:Vi},"dr"),Ii="lunora-studio-pinned-columns",Di=i(t=>{let e=(0,B.c)(24),{columns:n,initialPins:o,selectedTable:r}=t,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let[s,a]=Ot(Ii,l),u=r??"",d=s[u],g;e[1]!==o||e[2]!==d?(g=d===void 0?new Set((o??"").split(",").filter(Ti)):new Set(d),e[1]=o,e[2]=d,e[3]=g):g=e[3];let m=g,c;e[4]!==u||e[5]!==m||e[6]!==a?(c=i(P=>{a(k=>{let O=k[u]??[...m],q=O.includes(P)?O.filter(L=>L!==P):[...O,P];return{...k,[u]:q}})},"u"),e[4]=u,e[5]=m,e[6]=a,e[7]=c):c=e[7];let f=c,[p,h]=(0,N.useState)(!1),w;e[8]===Symbol.for("react.memo_cache_sentinel")?(w=i(()=>{h(zi)},"v"),e[8]=w):w=e[8];let b=w,x=Ei(),[C,R]=(0,N.useState)(!0),y;e[9]===Symbol.for("react.memo_cache_sentinel")?(y=i(()=>{R(Li)},"N"),e[9]=y):y=e[9];let _=y,S;if(e[10]!==n||e[11]!==x||e[12]!==r){let P=gl(x,r??"");S=ml(P,n),e[10]=n,e[11]=x,e[12]=r,e[13]=S}else S=e[13];let F=S,V;e[14]!==F||e[15]!==C?(V={columns:F,enabled:C},e[14]=F,e[15]=C,e[16]=V):V=e[16];let $=V,M;return e[17]!==F||e[18]!==C||e[19]!==$||e[20]!==f||e[21]!==m||e[22]!==p?(M={maskColumns:F,maskOn:C,maskView:$,onToggleMask:_,onTogglePin:f,onToggleTranspose:b,pinnedColumns:m,transposed:p},e[17]=F,e[18]=C,e[19]=$,e[20]=f,e[21]=m,e[22]=p,e[23]=M):M=e[23],M},"ur");function Ti(t){return t!==""}i(Ti,"mr");function zi(t){return!t}i(zi,"gr");function Li(t){return!t}i(Li,"fr");var Oi=ye(ue.describeTable),Ai=ye(ue.readTablePage),Gi=ye(ue.importShard),Hi=i(t=>{let e=t._id??t.id??t.__id__??"";return typeof e=="string"?e:typeof e=="number"?String(e):""},"xr"),Bi=i(t=>{let e=Object.values(t.inserted).reduce((u,d)=>u+d,0),[n]=t.errors;if(n===void 0)return{conflicts:t.conflicts,error:void 0,inserted:e};let o=t.errors.length-1,r=e+t.conflicts+t.errors.length,l=o===1?"error":"errors",s=o>0?` (+${o.toString()} more ${l})`:"",a=`Inserted ${e.toString()} of ${r.toString()} rows \u2014 row ${n.line.toString()} (${n.table}): ${n.message}${s}`;return{conflicts:t.conflicts,error:a,inserted:e}},"vr"),ji=i(t=>{let e=Ee(),[n,o]=(0,N.useState)(!1),[r,l]=(0,N.useState)(void 0),[s,a]=(0,N.useState)(void 0),[u,d]=(0,N.useState)(void 0),[g,m]=(0,N.useState)({}),[c,f]=(0,N.useState)(!1),[p,h]=(0,N.useState)(void 0),w=i(async(b,x)=>{o(!0),l(b),a(x),d(void 0),m({}),h(void 0),f(!0);try{let C=await e.query(Oi,{table:b},Ce(x)),{columns:R}=C;d(R);let y={},_=R.filter(S=>S.ref!==void 0&&S.type==="id"&&S.pk!==!0);for(let S of _){if(S.ref===void 0)continue;let{ref:F}=S;if(y[F]===void 0)try{let V=await e.query(Ai,{filters:[],limit:di,offset:0,search:"",table:F},Ce(x));y[F]=V.rows.flatMap($=>Hi($)||[])}catch{y[F]=[]}}m(y)}catch(C){h(C.message)}f(!1)},"v");return{closeDialog:i(()=>{o(!1),l(void 0),a(void 0),d(void 0),m({}),h(void 0)},"closeDialog"),columnMeta:u,error:p,fkPools:g,insertBatch:i(async(b,x)=>{if(r===void 0||s===void 0)return{conflicts:0,error:"No table selected.",inserted:0};try{let C=await e.query(Gi,{rows:b.map(y=>({doc:y,table:r}))},Ce(s)),R=Bi(C);return R.error!==void 0||(x(),t()),R}catch(C){return{conflicts:0,error:C.message,inserted:0}}},"insertBatch"),loading:c,open:n,openDialog:i((b,x)=>{Z(w(b,x))},"openDialog"),shardKey:s,table:r}},"wr"),qi=i(()=>{let t=(0,B.c)(6),[e,n]=(0,N.useState)(null),o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=i(()=>{n(null)},"o"),t[0]=o):o=t[0];let r=o,[l,s]=(0,N.useState)(null),a;t[1]===Symbol.for("react.memo_cache_sentinel")?(a=i((c,f)=>{s({column:c,value:f})},"a"),t[1]=a):a=t[1];let u=a,d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=i(()=>{s(null)},"s"),t[2]=d):d=t[2];let g=d,m;return t[3]!==l||t[4]!==e?(m={closeExpandedCell:g,closeInspect:r,expandedCell:l,inspecting:e,onExpandCell:u,onInspect:n},t[3]=l,t[4]=e,t[5]=m):m=t[5],m},"yr"),Ui=/(?:_creationtime|(?:^|[a-z])(?:time|at))$/iu,Ji=i((t,e)=>typeof e=="number"&&Ui.test(t),"Nr"),Ki=i(t=>{let e=(0,B.c)(26),{column:n,onNavigate:o,target:r,value:l}=t,s;e[0]!==o||e[1]!==r||e[2]!==l?(s=i(()=>{r!==void 0&&o(r,String(l))},"i"),e[0]=o,e[1]=r,e[2]=l,e[3]=s):s=e[3];let a=s;if(l==null){let g;return e[4]===Symbol.for("react.memo_cache_sentinel")?(g=(0,v.jsx)("span",{className:"italic text-muted-foreground",children:"null"}),e[4]=g):g=e[4],g}if(r!==void 0&&(typeof l=="string"||typeof l=="number")&&String(l)!==""){let g=`rd-ref-${n}`,m=`Open ${r} ${String(l)}`,c=String(l),f;return e[5]!==a||e[6]!==g||e[7]!==m||e[8]!==c?(f=(0,v.jsxs)("button",{"data-testid":g,onClick:a,title:m,type:"button",children:[c," \u2197"]}),e[5]=a,e[6]=g,e[7]=m,e[8]=c,e[9]=f):f=e[9],f}if(Ji(n,l)){let g=`rd-ts-${n}`,m;e[10]!==l?(m=l.toString(),e[10]=l,e[11]=m):m=e[11];let c;e[12]!==l?(c=Sn(l),e[12]=l,e[13]=c):c=e[13];let f;return e[14]!==g||e[15]!==m||e[16]!==c?(f=(0,v.jsx)("span",{"data-testid":g,title:m,children:c}),e[14]=g,e[15]=m,e[16]=c,e[17]=f):f=e[17],f}if(typeof l=="object"){let g;e[18]!==l?(g=JSON.stringify(l,null,2),e[18]=l,e[19]=g):g=e[19];let m;return e[20]!==g?(m=(0,v.jsx)("pre",{className:"m-0 overflow-auto rounded-md bg-muted/50 p-2 text-xs",children:g}),e[20]=g,e[21]=m):m=e[21],m}let u;e[22]!==l?(u=Je(l),e[22]=l,e[23]=u):u=e[23];let d;return e[24]!==u?(d=(0,v.jsx)("span",{children:u}),e[24]=u,e[25]=d):d=e[25],d},"Cr"),Qi=i(t=>{let e=(0,B.c)(21),{columns:n,onClose:o,onNavigate:r,refs:l,row:s}=t,a;e[0]!==o||e[1]!==r?(a=i((p,h)=>{r(p,h),o()},"a"),e[0]=o,e[1]=r,e[2]=a):a=e[2];let u=a,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=(0,v.jsx)("h3",{className:"m-0 text-base text-foreground",children:"Row detail"}),e[3]=d):d=e[3];let g;e[4]!==o?(g=(0,v.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[d,(0,v.jsx)("button",{"data-testid":"rd-close",onClick:o,type:"button",children:"Close"})]}),e[4]=o,e[5]=g):g=e[5];let m;if(e[6]!==n||e[7]!==u||e[8]!==l||e[9]!==s){let p;e[11]!==u||e[12]!==l||e[13]!==s?(p=i(h=>(0,v.jsxs)("div",{className:"border-t border-border py-2 first:border-t-0","data-testid":`rd-field-${h}`,children:[(0,v.jsx)("dt",{className:"mb-0.5 text-xs font-semibold text-muted-foreground",children:h}),(0,v.jsx)("dd",{className:"m-0",children:(0,v.jsx)(Ki,{column:h,onNavigate:u,target:l?.[h],value:s[h]})})]},h),"f"),e[11]=u,e[12]=l,e[13]=s,e[14]=p):p=e[14],m=n.map(p),e[6]=n,e[7]=u,e[8]=l,e[9]=s,e[10]=m}else m=e[10];let c;e[15]!==m?(c=(0,v.jsx)("dl",{"data-testid":"rd-fields",children:m}),e[15]=m,e[16]=c):c=e[16];let f;return e[17]!==o||e[18]!==g||e[19]!==c?(f=(0,v.jsxs)(Gt,{label:"Row detail",onClose:o,panelTestId:"rd-panel",testId:"rd-overlay",variant:"drawer",children:[g,c]}),e[17]=o,e[18]=g,e[19]=c,e[20]=f):f=e[20],f},"kr"),Wi=50,Xi=i(t=>{let e=(0,B.c)(8),{active:n,onPick:o,shard:r}=t,l;e[0]!==o||e[1]!==r?(l=i(()=>{o(r)},"l"),e[0]=o,e[1]=r,e[2]=l):l=e[2];let s=l,a=`w-full rounded px-2 py-0.5 text-left text-xs transition-colors hover:bg-accent ${n?"bg-accent font-medium":""}`,u=`shard-explorer-item-${r}`,d;return e[3]!==s||e[4]!==r||e[5]!==a||e[6]!==u?(d=(0,v.jsx)("button",{className:a,"data-testid":u,onClick:s,type:"button",children:r}),e[3]=s,e[4]=r,e[5]=a,e[6]=u,e[7]=d):d=e[7],d},"Tr"),Zi=i(({onFetchTables:t,onSelect:e})=>{let n=X(),[o]=(0,N.useState)(()=>_n()),[r,l]=(0,N.useState)(!1),[s,a]=(0,N.useState)(void 0),[u,d]=(0,N.useState)(void 0),[g,m]=(0,N.useState)(!1),[c,f]=(0,N.useState)(void 0),p=(0,N.useRef)(0),h=i(()=>{l(x=>!x)},"p"),w=i(async x=>{e(x),a(x),d(void 0),f(void 0),m(!0),p.current+=1;let C=p.current;try{let R=await t(x);p.current===C&&d(R?.slice(0,Wi))}catch(R){p.current===C&&f(R.message)}p.current===C&&m(!1)},"v"),b=i(x=>{Z(w(x))},"x");return o.length===0?null:(0,v.jsxs)("div",{"data-testid":"shard-explorer",children:[(0,v.jsxs)("button",{"aria-controls":"shard-explorer-panel","aria-expanded":r,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:h,type:"button",children:[n("Shards seen"),(0,v.jsx)("span",{"aria-hidden":"true",className:`ml-0.5 transition-transform ${r?"rotate-180":""}`,children:"\u25BE"})]}),r&&(0,v.jsxs)("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:[(0,v.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-hint",children:n("Recently visited shards \u2014 click to switch")}),(0,v.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-list",children:o.map(x=>(0,v.jsx)("li",{children:(0,v.jsx)(Xi,{active:s===x,onPick:b,shard:x})},x))}),s!==void 0&&(0,v.jsxs)("div",{className:"mt-1 border-t border-border pt-1","data-testid":"shard-explorer-summary",children:[(0,v.jsx)("p",{className:"mb-1 text-xs font-medium text-foreground","data-testid":"shard-explorer-summary-title",children:n("{shard} tables",{shard:s})}),g&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-loading",children:n("Loading\u2026")}),c!==void 0&&(0,v.jsx)("p",{className:"text-xs text-destructive","data-testid":"shard-explorer-error",role:"alert",children:c}),!g&&c===void 0&&u?.length===0&&(0,v.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":"shard-explorer-empty",children:n("No tables in this shard.")}),!g&&c===void 0&&u!==void 0&&u.length>0&&(0,v.jsx)("ul",{className:"flex flex-col gap-0.5","data-testid":"shard-explorer-tables",children:u.map(x=>(0,v.jsxs)("li",{className:"flex items-center justify-between text-xs",children:[(0,v.jsx)("span",{"data-testid":`shard-explorer-table-${x.name}`,children:x.name}),(0,v.jsx)("span",{className:"text-muted-foreground","data-testid":`shard-explorer-rowcount-${x.name}`,children:x.rowCount})]},x.name))})]})]})]})},"Er"),Yi="lunora-studio-back-relations",es={},ts=50,ns=[],os=ye(ue.listTables),rs=i(t=>{let e=(0,B.c)(10),{onFetchShardTables:n,onShardChange:o,schemaSwitch:r,shardKey:l}=t,s;e[0]!==o||e[1]!==l?(s=(0,v.jsx)($n,{onChange:o,testId:"db-shard-input",value:l}),e[0]=o,e[1]=l,e[2]=s):s=e[2];let a;e[3]!==n||e[4]!==o?(a=(0,v.jsx)(Zi,{onFetchTables:n,onSelect:o}),e[3]=n,e[4]=o,e[5]=a):a=e[5];let u;return e[6]!==r||e[7]!==s||e[8]!==a?(u=(0,v.jsxs)("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[r,s,a]}),e[6]=r,e[7]=s,e[8]=a,e[9]=u):u=e[9],u},"Ir"),$o=i(({editable:t=!1,globalTableNames:e,initialFilters:n,initialOrderBy:o,initialPins:r,initialSearch:l,initialShardKey:s,onNavigateToGlobal:a,onSelectTable:u,onViewChange:d,pageSize:g=ts,queryBar:m,schemaSwitch:c,tableParam:f})=>{let p=Xe(ue.describeTables,{},{shardKey:s??""}).data?.columnsByTable??es,[h,w]=Ot(Yi,{}),b=(0,N.useCallback)(Y=>{let ie=new Set(h[Y]);return go(Y,p).filter(Me=>ie.has(un(Me)))},[h,p]),x=ki({initialFilters:n,initialOrderBy:o,initialSearch:l,initialShardKey:s,onSelectTable:u,onViewChange:d,pageSize:g,resolveBackRelations:b,tableParam:f}),{cancelCellEdit:C,columns:R,currentView:y,editableColumn:_,editingCell:S,facetFilter:F,facets:V,loadTables:$,navigateToRef:M,onFiltersChange:P,page:k,pageError:O,previewRef:q,queryShardKey:L,selectedTable:T,selectTable:U,setShardKey:j,shardKey:J,stage:te,stagedValue:oe,startCellEdit:we,tables:ce,tablesError:fe,toggleFacet:xe}=x,he=In(J),ve=i(Y=>{Z((async()=>{let ie=await he.suggestFilter(Y,T??"");ie!==void 0&&P(ie.map(Me=>{let Pe=Me.value,ot=typeof Pe=="string"||typeof Pe=="number"||typeof Pe=="boolean"?String(Pe):"";return{column:Me.column,operator:Me.operator,value:ot}}))})())},"de"),A=T===null?[]:go(T,p),re=new Set(h[T??""]),ee=[];for(let Y of k?.rows??[]){let ie=Y._id??Y.id;typeof ie=="string"&&ie!==""&&ee.push(ie)}let $e=vi(re,A,ee,L),Ne=i(Y=>{w(ie=>{let Me=T??"",Pe=ie[Me]??[];return{...ie,[Me]:Pe.includes(Y)?Pe.filter(ot=>ot!==Y):[...Pe,Y]}})},"pe"),le=Di({columns:R,initialPins:r,selectedTable:T}),me=qi(),{closeExpandedCell:ne,closeInspect:K,expandedCell:ge,inspecting:Q,onExpandCell:ze}=me,Le=Ee(),Oe=i(async Y=>await Le.query(os,{},Ce(Y)),"Ce"),Ae=i(()=>{T!==null&&U(T)},"ke"),{closeDialog:Se,columnMeta:W,fkPools:et,insertBatch:qe,open:tt,openDialog:Pt}=ji(Ae),kt=i(()=>{T!==null&&Pt(T,J)},"He"),Vt=i(Y=>qe(Y,Se),"Qe"),nt=i((Y,ie)=>{if(a!==void 0&&e?.has(Y)===!0){a(Y,ie);return}M(Y,ie)},"Ie"),Et=m?.onSaveQuery,It=i(Y=>{Et?.(Y,y)},"Ue"),Dt={cancelEdit:C,editable:t,editableColumn:_,editingCell:S,onExpandCell:ze,stage:te,stagedValue:oe,startEdit:we},Tt={columns:k?.refs,onNavigate:nt,onPreview:q};return(0,v.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-data-browser",children:[(0,v.jsx)(xt,{header:(0,v.jsx)(rs,{onFetchShardTables:Oe,onShardChange:j,schemaSwitch:c,shardKey:J}),onReload:$,onSelect:U,prefix:"db",selected:T,tables:ce??ns}),(0,v.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[fe!==null&&(0,v.jsx)("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-tables-error",role:"alert",children:fe}),k===null&&O===null&&(0,v.jsx)("div",{className:"flex flex-1 items-center justify-center p-6",children:(0,v.jsx)("p",{className:"text-sm text-muted-foreground",children:"Select a table to browse its rows."})}),O!==null&&(0,v.jsx)("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"db-page-error",role:"alert",children:O}),k!==null&&(0,v.jsx)(ai,{assistant:he,backRelations:{available:A,counts:$e,enabled:re,onToggle:Ne},browser:x,edit:Dt,editable:t,onAskAiFilter:ve,onInspect:me.onInspect,onOpenGenerateRows:kt,onSaveQuery:It,page:k,preferences:le,queryBar:m,references:Tt})]}),k!==null&&(0,v.jsx)(bt,{columns:R,facets:V,onFacetFilter:F,onToggleFacet:xe}),Q!==null&&k!==null&&(0,v.jsx)(Qi,{columns:k.columns,onClose:K,onNavigate:nt,refs:k.refs,row:Q}),ge!==null&&(0,v.jsx)(Tn,{column:ge.column,onClose:ne,value:ge.value}),tt&&T!==null&&W!==void 0&&(0,v.jsx)(pi,{columns:W,fkPools:et,onClose:Se,onInsertRows:Vt,table:T})]})},"sl");var Fe=ae(We(),1);var gn=ae(rt(),1);var G=ae(lt(),1);var ls=i((t,e)=>{let n=t._id;return typeof n=="string"||typeof n=="number"?String(n):`row-${e.toString()}`},"Ne"),No=i(t=>t==null?"\u2205":t===""?"(empty)":typeof t=="object"?JSON.stringify(t):String(t),"q"),is=i(t=>{let e=(0,gn.c)(33),{filters:n,onChangePageSize:o,onJumpToPage:r,onNext:l,onPrevious:s,onRemoveFilter:a,page:u,pageSize:d,pagination:g}=t,m=X(),{hasNext:c,hasPrevious:f,rangeEnd:p,rangeStart:h,total:w}=g,b;e[0]!==n||e[1]!==a||e[2]!==m?(b=n.length>0&&(0,G.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-1.5 border-b border-border px-4 py-2 text-xs","data-testid":"gdb-filters",children:n.map((V,$)=>(0,G.jsxs)("span",{className:"inline-flex items-center gap-1 rounded border border-border bg-muted px-1.5 py-0.5","data-testid":"gdb-filter-chip",children:[(0,G.jsx)("span",{className:"font-medium text-foreground",children:V.column}),(0,G.jsx)("span",{className:"text-muted-foreground",children:"="}),(0,G.jsx)("span",{className:"font-mono text-foreground",children:No(V.value)}),(0,G.jsx)("button",{"aria-label":m("Remove filter"),className:"ml-0.5 text-muted-foreground hover:text-foreground","data-testid":"gdb-filter-remove",onClick:i(()=>{a($)},"onClick"),type:"button",children:"\u2715"})]},`${V.column}:${No(V.value)}`))}),e[0]=n,e[1]=a,e[2]=m,e[3]=b):b=e[3];let x;e[4]!==u.columns?(x=u.columns.map(ss),e[4]=u.columns,e[5]=x):x=e[5];let C;e[6]!==x?(C=(0,G.jsx)(Mn,{children:(0,G.jsx)(At,{children:x})}),e[6]=x,e[7]=C):C=e[7];let R;if(e[8]!==u.columns||e[9]!==u.rows){let V;e[11]!==u.columns?(V=i(($,M)=>(0,G.jsx)(At,{"data-testid":"gdb-row",children:u.columns.map(P=>(0,G.jsx)(Vn,{className:"max-w-xs truncate font-mono text-xs",children:(0,G.jsx)(Ze,{value:$[P]})},P))},ls($,M)),"d"),e[11]=u.columns,e[12]=V):V=e[12],R=u.rows.map(V),e[8]=u.columns,e[9]=u.rows,e[10]=R}else R=e[10];let y;e[13]!==R?(y=(0,G.jsx)(Pn,{children:R}),e[13]=R,e[14]=y):y=e[14];let _;e[15]!==C||e[16]!==y?(_=(0,G.jsx)(ht,{layout:"fill",children:(0,G.jsx)("div",{className:"min-h-0 flex-1 overflow-auto",children:(0,G.jsxs)(Nn,{"data-testid":"gdb-rows",children:[C,y]})})}),e[15]=C,e[16]=y,e[17]=_):_=e[17];let S;e[18]!==c||e[19]!==f||e[20]!==o||e[21]!==r||e[22]!==l||e[23]!==s||e[24]!==d||e[25]!==p||e[26]!==h||e[27]!==w?(S=(0,G.jsx)("div",{className:"flex shrink-0 items-center border-t border-border px-4 py-2",children:(0,G.jsx)(vt,{hasNext:c,hasPrevious:f,onJumpToPage:r,onNext:l,onPageSizeChange:o,onPrevious:s,pageSize:d,prefix:"gdb",rangeEnd:p,rangeStart:h,total:w})}),e[18]=c,e[19]=f,e[20]=o,e[21]=r,e[22]=l,e[23]=s,e[24]=d,e[25]=p,e[26]=h,e[27]=w,e[28]=S):S=e[28];let F;return e[29]!==b||e[30]!==_||e[31]!==S?(F=(0,G.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col","data-testid":"gdb-page",children:[b,_,S]}),e[29]=b,e[30]=_,e[31]=S,e[32]=F):F=e[32],F},"we");function ss(t){return(0,G.jsx)(kn,{children:t},t)}i(ss,"Se");var as=i(()=>{let t=(0,gn.c)(8),e=X(),n;t[0]!==e?(n=e("Tables marked .global() (D1-backed, region-replicated) will appear here."),t[0]=e,t[1]=n):n=t[1];let o;t[2]===Symbol.for("react.memo_cache_sentinel")?(o=(0,G.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,G.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,G.jsx)("path",{d:"M3 12h18M12 3a14 14 0 0 1 0 18 14 14 0 0 1 0-18Z"})]}),t[2]=o):o=t[2];let r;t[3]!==e?(r=e("No global tables."),t[3]=e,t[4]=r):r=t[4];let l;return t[5]!==n||t[6]!==r?(l=(0,G.jsx)("div",{className:"flex flex-1 items-center justify-center p-6",children:(0,G.jsx)(dt,{description:n,icon:o,testId:"gdb-empty",title:r})}),t[5]=n,t[6]=r,t[7]=l):l=t[7],l},"ye"),us=50,ds=[],cs=[],Mo=i(({initialTable:t,onSelectTable:e,pageSize:n=us,schemaSwitch:o}={})=>{let r=Ee(),l=X(),[s,a]=(0,Fe.useState)(t??null),[u,d]=(0,Fe.useState)(0),[g,m]=(0,Fe.useState)(n),[c,f]=(0,Fe.useState)([]),p=Ie(c),{clearFacets:h,facets:w,refetchFacets:b,toggleFacet:x}=wt(),C=zt(["lunora-global-tables"],()=>r.listGlobalTables()),R=C.data??null,y=C.error,_=zt(["lunora-global-page",s??"",u,g,JSON.stringify(c)],()=>r.readGlobalTablePage({filters:c,limit:g,offset:u,table:s??""}),{enabled:s!==null,keepPreviousData:!1}),S=_.data??null,F=_.error,V=i((A,re)=>ee=>r.facetGlobalColumn({column:ee,filters:re,table:A}),"d"),$=i((A,re)=>{b(V(A,re))},"y");En(()=>{C.refetch(),s!==null&&(_.refetch(),$(s,p.current))},!0);let M=(0,Fe.useRef)(void 0),P=i(A=>{a(A),M.current=A,f([]),p.current=[],h(),d(0),e?.(A)},"P"),k=i(A=>{x(A,s===null?null:V(s,p.current))},"W"),O=i(A=>{f(A),p.current=A,d(0),s!==null&&$(s,A)},"M"),q=i((A,re)=>{O([...p.current.filter(ee=>ee.column!==A),{column:A,value:re}])},"Z"),L=i(A=>{O(p.current.filter((re,ee)=>ee!==A))},"H"),T=(0,Fe.useRef)(P);(0,Fe.useEffect)(()=>{T.current=P}),(0,Fe.useEffect)(()=>{if(t===void 0||t===""||M.current===t)return;M.current=t;let A=t;queueMicrotask(()=>{T.current(A)})},[t]);let U=i(A=>{s!==null&&d(Math.max(0,A))},"j"),j=S?.total??0,J=u>0,te=S!==null&&u+S.rows.length<j,oe=S===null||S.rows.length===0?0:u+1,we=S===null?0:u+S.rows.length,ce=i(()=>{C.refetch()},"Y"),fe=i(()=>{U(u-g)},"ee"),xe=i(()=>{U(u+g)},"te"),he=i(A=>{U(Math.max(0,(A-1)*g))},"re"),ve=i(A=>{m(A),d(0)},"le");return(0,G.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-global-data-browser",children:[(0,G.jsx)(xt,{header:(0,G.jsxs)("div",{className:"flex shrink-0 flex-col items-stretch gap-2 border-b border-border p-3",children:[o,(0,G.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"gdb-cf-link",href:Hn,rel:"noreferrer",target:"_blank",children:l("Open in Cloudflare")})]}),onReload:ce,onSelect:P,prefix:"gdb",selected:s,tables:R??ds}),(0,G.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col overflow-hidden",children:[y!==null&&(0,G.jsx)("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-tables-error",role:"alert",children:y}),R!==null&&R.length===0&&(0,G.jsx)(as,{}),F!==null&&(0,G.jsx)("p",{className:"shrink-0 border-b border-border px-4 py-2 text-sm text-destructive","data-testid":"gdb-page-error",role:"alert",children:F}),R!==null&&R.length>0&&S===null&&F===null&&(0,G.jsx)("div",{className:"flex flex-1 items-center justify-center p-6",children:(0,G.jsx)("p",{className:"text-sm text-muted-foreground",children:l("Select a table to browse its rows.")})}),S!==null&&(0,G.jsx)(is,{filters:c,onChangePageSize:ve,onJumpToPage:he,onNext:xe,onPrevious:fe,onRemoveFilter:L,page:S,pageSize:g,pagination:{hasNext:te,hasPrevious:J,rangeEnd:we,rangeStart:oe,total:j}})]}),(0,G.jsx)(bt,{columns:S?.columns??cs,facets:w,onFacetFilter:q,onToggleFacet:k})]})},"De");var ke=ae(lt(),1);var ko="lunora-studio-saved-queries",gs=50,fs=i(t=>t!==null&&typeof t=="object"&&typeof t.name=="string"&&typeof t.view=="object"&&t.view!==null,"M"),Mt=i(()=>yn(ko).filter(fs),"w"),Vo=i(t=>{Rn(ko,t)},"k"),ms=i((t,e)=>{let n=t.trim();if(n==="")return Mt();let o=[{name:n,view:e},...Mt().filter(r=>r.name!==n)].slice(0,gs);return Vo(o),o},"U"),ps=i(t=>{let e=Mt().filter(n=>n.name!==t);return Vo(e),e},"W"),hs=i(t=>{let e=(0,Po.c)(15),{onChange:n,tier:o}=t,r=X(),l;e[0]!==n?(l=i(p=>{n(p.target.value)},"d"),e[0]=n,e[1]=l):l=e[1];let s=l,a;e[2]!==r?(a=r("Storage tier"),e[2]=r,e[3]=a):a=e[3];let u;e[4]!==a?(u=(0,ke.jsx)("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:a}),e[4]=a,e[5]=u):u=e[5];let d=ft[o],g,m;e[6]===Symbol.for("react.memo_cache_sentinel")?(g=(0,ke.jsx)("option",{value:"shard",children:ft.shard.label}),m=(0,ke.jsx)("option",{value:"global",children:ft.global.label}),e[6]=g,e[7]=m):(g=e[6],m=e[7]);let c;e[8]!==s||e[9]!==d.title||e[10]!==o?(c=(0,ke.jsxs)("select",{className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus-visible:border-ring","data-testid":"table-editor-schema",id:"table-editor-schema",onChange:s,title:d.title,value:o,children:[g,m]}),e[8]=s,e[9]=d.title,e[10]=o,e[11]=c):c=e[11];let f;return e[12]!==u||e[13]!==c?(f=(0,ke.jsxs)("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[u,c]}),e[12]=u,e[13]=c,e[14]=f):f=e[14],f},"X"),vs=i(()=>{try{Z(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},"Y"),_a=i(({editable:t=!1,initialShardKey:e})=>{let n=Ee(),o=bn(),r=hn(),l=vn({strict:!1}),s=Cn(l),a=Ie(l),u=i(()=>r.state.location.pathname.split("/").findLast(Boolean)==="data","n"),d=s.tier??"shard",g=s.table,[m,c]=(0,Ye.useState)(()=>Mt()),[f,p]=(0,Ye.useState)(()=>new Set);(0,Ye.useEffect)(()=>{Z((async()=>{try{let y=await n.listGlobalTables();p(new Set(y.map(_=>_.name)))}catch{}})())},[n]),(0,Ye.useEffect)(()=>{d==="shard"&&g!==void 0&&f.has(g)&&Z(o({replace:!0,search:i(y=>({...y,schema:"global"}),"search"),to:"/data"}))},[f,o,g,d]);let h=i(y=>{Z(o({search:i(_=>({..._,schema:y==="global"?"global":void 0,table:void 0}),"search"),to:"/data"}))},"D"),w=i((y,_)=>{u()&&Z(o({search:i(S=>({schema:S.schema,search:_?.search,shard:S.shard,table:y}),"search"),to:"/data"}))},"T"),b=i(y=>{Z(o({search:i(_=>({..._,schema:"global",table:y}),"search"),to:"/data"}))},"V"),x=i(y=>{let _=Lt(y),{current:S}=a;(S.filters??void 0)===_.filters&&(S.order??void 0)===_.order&&(S.search??void 0)===_.search&&(S.shard??void 0)===_.shard||!u()||Z(o({replace:!0,search:i(F=>({...F,filters:_.filters,order:_.order,search:_.search,shard:_.shard}),"search"),to:"/data"}))},"A"),C={onApplyQuery:i(y=>{let _=Lt(y.view);Z(o({search:i(()=>({filters:_.filters,order:_.order,schema:_.schema,search:_.search,shard:_.shard,table:_.table}),"search"),to:"/data"}))},"onApplyQuery"),onCopyLink:vs,onDeleteQuery:i(y=>{c(ps(y))},"onDeleteQuery"),onSaveQuery:i((y,_)=>{c(ms(y,_))},"onSaveQuery"),saved:m},R=(0,ke.jsx)(hs,{onChange:h,tier:d});return d==="global"?(0,ke.jsx)(Mo,{initialTable:g,onSelectTable:w,schemaSwitch:R}):(0,ke.jsx)($o,{editable:t,globalTableNames:f,initialFilters:s.filters,initialOrderBy:s.orderBy,initialPins:l.pins,initialSearch:s.search,initialShardKey:s.shard??e,onNavigateToGlobal:b,onSelectTable:w,onViewChange:x,queryBar:C,schemaSwitch:R,tableParam:g})},"me");export{_a as TableEditor};