@lunora/studio 1.0.0-alpha.178 → 1.0.0-alpha.180
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +40 -1
- package/dist/index.d.ts +40 -1
- package/dist/index.mjs +1 -1
- package/dist/packem_chunks/FileBrowser.mjs +1 -1
- package/dist/packem_chunks/SqlEditorPanel.mjs +6 -6
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/queues-panel.mjs +1 -1
- package/dist/packem_shared/DataBrowser-BUFMFvNX.mjs +4 -0
- package/dist/packem_shared/DataFilters-Cocu-WWE.mjs +1 -0
- package/dist/packem_shared/grid-features-CE8kcqsK.mjs +6 -0
- package/dist/standalone/{chunk-2W365SXI.js → chunk-3PZNTIBM.js} +1 -1
- package/dist/standalone/{chunk-TXLWUHAU.js → chunk-3TXB4AKZ.js} +1 -1
- package/dist/standalone/{chunk-U7A2W7UG.js → chunk-4PRXEO3C.js} +1 -1
- package/dist/standalone/{chunk-P4V5VRUR.js → chunk-5B6TTEP6.js} +1 -1
- package/dist/standalone/{chunk-QCFJKKLX.js → chunk-5LZJ5JBB.js} +1 -1
- package/dist/standalone/{chunk-E366YQXO.js → chunk-5MKG6RW3.js} +1 -1
- package/dist/standalone/{chunk-PHYKYBCE.js → chunk-66Z7ZIZZ.js} +1 -1
- package/dist/standalone/{chunk-MOYNBJNW.js → chunk-A6S4TULR.js} +1 -1
- package/dist/standalone/{chunk-KIEUFC6E.js → chunk-A7EWHGFT.js} +1 -1
- package/dist/standalone/{chunk-ANXXWNJG.js → chunk-AFSPF2R4.js} +1 -1
- package/dist/standalone/{chunk-AKG3SL2Z.js → chunk-AODYDAXY.js} +1 -1
- package/dist/standalone/{chunk-NLHKRU3D.js → chunk-AULH6SZB.js} +1 -1
- package/dist/standalone/{chunk-YRZFU7OM.js → chunk-AX24JD2G.js} +1 -1
- package/dist/standalone/chunk-B3JY36UV.js +5 -0
- package/dist/standalone/chunk-B6RRRJP5.js +11 -0
- package/dist/standalone/{chunk-VR3OL4A6.js → chunk-BAAPQWFF.js} +1 -1
- package/dist/standalone/{chunk-I3OOVU3O.js → chunk-D4ZGY3II.js} +1 -1
- package/dist/standalone/{chunk-D7PVLNBP.js → chunk-DAD33Q2T.js} +1 -1
- package/dist/standalone/{chunk-ZTA7WN4R.js → chunk-DI34YDBW.js} +1 -1
- package/dist/standalone/{chunk-BR64TOG4.js → chunk-E2X625P3.js} +1 -1
- package/dist/standalone/{chunk-5PBVNSPQ.js → chunk-EBU3TTYR.js} +1 -1
- package/dist/standalone/{chunk-MWUR2KP6.js → chunk-FI6N7XWP.js} +1 -1
- package/dist/standalone/{chunk-IUKHT5XV.js → chunk-GAPFZFIL.js} +1 -1
- package/dist/standalone/{chunk-D2SSRZG5.js → chunk-GP2GJRJ3.js} +1 -1
- package/dist/standalone/{chunk-MNQSYFV6.js → chunk-GZ6GAFM2.js} +1 -1
- package/dist/standalone/chunk-GZAXFXZE.js +1 -0
- package/dist/standalone/{chunk-WV2AW6IT.js → chunk-H43JNQM6.js} +1 -1
- package/dist/standalone/{chunk-V5FOHTRB.js → chunk-HGT5U6GD.js} +1 -1
- package/dist/standalone/{chunk-P6F4CNT5.js → chunk-I6FR5UAK.js} +1 -1
- package/dist/standalone/{chunk-7HFDITXH.js → chunk-INXSZE5I.js} +1 -1
- package/dist/standalone/{chunk-FTR6JAWG.js → chunk-IP7YCJUN.js} +1 -1
- package/dist/standalone/{chunk-KZDIKRZ3.js → chunk-ITMXIPQ7.js} +1 -1
- package/dist/standalone/{chunk-M7QQYXU4.js → chunk-IXNOQYEE.js} +1 -1
- package/dist/standalone/{chunk-LKKZMIZK.js → chunk-JYT34NQM.js} +1 -1
- package/dist/standalone/{chunk-2NYASBOP.js → chunk-L2CWAQUO.js} +1 -1
- package/dist/standalone/{chunk-QY4V5UOY.js → chunk-M4POCI2J.js} +1 -1
- package/dist/standalone/{chunk-RSULZ5QU.js → chunk-MH2NGGUC.js} +1 -1
- package/dist/standalone/{chunk-WHPKXZN2.js → chunk-PGMASM2T.js} +1 -1
- package/dist/standalone/{chunk-2ADU5FA5.js → chunk-PZVVEPIN.js} +1 -1
- package/dist/standalone/{chunk-GDYRC6T6.js → chunk-QDHXQ56K.js} +1 -1
- package/dist/standalone/{chunk-KQMWK6QZ.js → chunk-QQ3CS3FX.js} +1 -1
- package/dist/standalone/chunk-QWJQUQY3.js +8 -0
- package/dist/standalone/{chunk-YK7JO7NP.js → chunk-RM4TNBYG.js} +1 -1
- package/dist/standalone/{chunk-MBP4SZYB.js → chunk-SDHFSBNM.js} +1 -1
- package/dist/standalone/{chunk-N2VWHDGA.js → chunk-SLI7DPVW.js} +1 -1
- package/dist/standalone/{chunk-CXGPKEDJ.js → chunk-TIIEZS24.js} +1 -1
- package/dist/standalone/{chunk-MOMBFDIA.js → chunk-TK6AEV4N.js} +1 -1
- package/dist/standalone/{chunk-U2YJ64UT.js → chunk-TTIBDOV6.js} +1 -1
- package/dist/standalone/{chunk-WX6MJS7P.js → chunk-V56XORNF.js} +1 -1
- package/dist/standalone/{chunk-IBM6X4XI.js → chunk-V7G6YTQ5.js} +1 -1
- package/dist/standalone/{chunk-U3T6FYYZ.js → chunk-VWXJAY7R.js} +1 -1
- package/dist/standalone/{chunk-6HVFOKP5.js → chunk-WD4WHTAV.js} +1 -1
- package/dist/standalone/{chunk-G22LSAIH.js → chunk-WIXX2VWE.js} +1 -1
- package/dist/standalone/{chunk-3JDH25N2.js → chunk-WRZTTZFV.js} +1 -1
- package/dist/standalone/{chunk-Y5IE2W4U.js → chunk-Y2I6GYEG.js} +1 -1
- package/dist/standalone/{chunk-I5V3IHPF.js → chunk-YONJDNSM.js} +1 -1
- package/dist/standalone/chunk-Z2XS4ZOO.js +1 -0
- package/dist/standalone/studio.js +1 -1
- package/package.json +5 -5
- package/dist/packem_shared/DataBrowser-B_zcf3a_.mjs +0 -4
- package/dist/packem_shared/DataFilters-3nbW0uax.mjs +0 -1
- package/dist/packem_shared/grid-features-Dl7bCGRN.mjs +0 -6
- package/dist/standalone/chunk-KYMUE3MZ.js +0 -5
- package/dist/standalone/chunk-RY66ZJJQ.js +0 -1
- package/dist/standalone/chunk-SA5SGD3V.js +0 -8
- package/dist/standalone/chunk-YAAM5IKA.js +0 -1
- package/dist/standalone/chunk-Z7WCKAUJ.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ee}from"./chunk-5WJXVZMZ.js";import{b as Z}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{d as se,f as X}from"./chunk-
|
|
1
|
+
import{a as ee}from"./chunk-5WJXVZMZ.js";import{b as Z}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{d as se,f as X}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as re}from"./chunk-FKVZRPV5.js";import{a as O}from"./chunk-WUWBZPUK.js";import{d as le,r as ne}from"./chunk-FODLDLE2.js";import{a as k,d as ae,f as ce,g as me,i as Y}from"./chunk-YKXDMIHQ.js";var te=ae(ce(),1);var a=ae(me(),1);var pe="/_lunora/health",he="/_lunora/health/ready",ue=k((r,e)=>(r.endsWith("/")?r.slice(0,-1):r)+e,"me"),fe=k(()=>{let r=X();return async e=>{let w=e==="ready"?he:pe,t=r.getAuthToken(),y=ue(r.url,w);try{let i=await fetch(y,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),p=null;try{p=await i.json()}catch{p=null}return{body:p,ok:i.ok,status:i.status}}catch(i){return{body:null,error:i instanceof Error?i.message:String(i),ok:!1,status:0}}}},"pe"),ge={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ye=k(r=>r==="unhealthy"?"crit":r==="degraded"?"warn":"ok","fe"),ie=k(r=>{let e=(0,te.c)(13),{label:w,level:t,testId:y,value:i}=r,p=ge[t],d;e[0]!==p?(d=Y("size-1.5 shrink-0 rounded-full",p),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==d?(o=(0,a.jsx)("span",{"aria-hidden":"true",className:d}),e[2]=d,e[3]=o):o=e[3];let c;e[4]!==w||e[5]!==o?(c=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[o,w]}),e[4]=w,e[5]=o,e[6]=c):c=e[6];let h;e[7]!==y||e[8]!==i?(h=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":y,children:i}),e[7]=y,e[8]=i,e[9]=h):h=e[9];let C;return e[10]!==c||e[11]!==h?(C=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[c,h]})}),e[10]=c,e[11]=h,e[12]=C):C=e[12],C},"Z"),Pe=k(r=>{let e=(0,te.c)(107),{probe:w}=r,t=le(),y=X(),i=fe(),p=w??i,d;e[0]!==p?(d=k(async()=>{let[s,n]=await Promise.all([p("live"),p("ready")]);return{live:s,ready:n}},"o"),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==y?(o=y.clientIdentifier(),e[2]=y,e[3]=o):o=e[3];let c;e[4]!==o?(c=["deployment-health",o],e[4]=o,e[5]=c):c=e[5];let h;e[6]!==d||e[7]!==c?(h={queryFn:d,queryKey:c},e[6]=d,e[7]=c,e[8]=h):h=e[8];let{data:C,isPending:de}=se(h),Q=C?.live??null,oe=C?.ready??null;if(de){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(ee,{className:"h-16 w-full"}),(0,a.jsx)(ee,{className:"h-40 w-full"})]}),e[9]=s):s=e[9],s}let l=Q?.body??null;if(l===null){let s=Q?.status===403,n;e[10]!==s||e[11]!==Q?.error||e[12]!==t?(n=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:Q?.error??t("no response")}),e[10]=s,e[11]=Q?.error,e[12]=t,e[13]=n):n=e[13];let m;e[14]!==t?(m=t("Health endpoint unavailable"),e[14]=t,e[15]=m):m=e[15];let f;return e[16]!==n||e[17]!==m?(f=(0,a.jsx)(re,{description:n,testId:"deployment-health-error",title:m}),e[16]=n,e[17]=m,e[18]=f):f=e[18],f}let J;e[19]!==l.status?(J=ye(l.status),e[19]=l.status,e[20]=J):J=e[20];let W=J,u;if(l.status==="unhealthy"){let s;e[21]!==t?(s=t("Unhealthy"),e[21]=t,e[22]=s):s=e[22],u=s}else if(l.status==="degraded"){let s;e[23]!==t?(s=t("Degraded"),e[23]=t,e[24]=s):s=e[24],u=s}else{let s;e[25]!==t?(s=t("Healthy"),e[25]=t,e[26]=s):s=e[26],u=s}let j=oe?.ok??!1,G=j?"ok":"crit",H,I,P,x,N,v,S,V,b,_;if(e[27]!==l.appName||e[28]!==l.appVersion||e[29]!==l.checks||e[30]!==l.timestamp||e[31]!==W||e[32]!==G||e[33]!==j||e[34]!==u||e[35]!==t){let s=[...l.checks].toSorted(xe);I="flex flex-col gap-6",P="deployment-health";let n;e[46]!==t?(n=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[46]=t,e[47]=n):n=e[47],e[48]!==n?(x=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:n}),e[48]=n,e[49]=x):x=e[49];let m;e[50]!==u?(m=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:u}),e[50]=u,e[51]=m):m=e[51];let f;e[52]!==l.appName||e[53]!==l.appVersion?(f=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[l.appName," \xB7 ",l.appVersion]}),e[52]=l.appName,e[53]=l.appVersion,e[54]=f):f=e[54];let D;e[55]!==m||e[56]!==f?(D=(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"grid leading-tight",children:[m,f]})}),e[55]=m,e[56]=f,e[57]=D):D=e[57];let L;e[58]!==t?(L=t("Checked"),e[58]=t,e[59]=L):L=e[59];let T;e[60]!==L?(T=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:L}),e[60]=L,e[61]=T):T=e[61];let $;e[62]!==l.timestamp?($=ne(l.timestamp),e[62]=l.timestamp,e[63]=$):$=e[63];let q;e[64]!==$?(q=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:$}),e[64]=$,e[65]=q):q=e[65];let B;e[66]!==T||e[67]!==q?(B=(0,a.jsxs)("div",{className:"text-end",children:[T,q]}),e[66]=T,e[67]=q,e[68]=B):B=e[68],e[69]!==D||e[70]!==B?(N=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[D,B]})}),e[69]=D,e[70]=B,e[71]=N):N=e[71];let E;e[72]!==t?(E=t("Liveness"),e[72]=t,e[73]=E):E=e[73];let R;e[74]!==W||e[75]!==u||e[76]!==E?(R=(0,a.jsx)(ie,{label:E,level:W,testId:"dh-liveness",value:u}),e[74]=W,e[75]=u,e[76]=E,e[77]=R):R=e[77];let U;e[78]!==t?(U=t("Readiness"),e[78]=t,e[79]=U):U=e[79];let A;e[80]!==j||e[81]!==t?(A=t(j?"Ready":"Not ready"),e[80]=j,e[81]=t,e[82]=A):A=e[82];let F;e[83]!==G||e[84]!==U||e[85]!==A?(F=(0,a.jsx)(ie,{label:U,level:G,testId:"dh-readiness",value:A}),e[83]=G,e[84]=U,e[85]=A,e[86]=F):F=e[86],e[87]!==R||e[88]!==F?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[R,F]}),e[87]=R,e[88]=F,e[89]=v):v=e[89],H=O,S="gap-0 py-0",V="dh-checks";let K;e[90]!==t?(K=t("Subsystem checks"),e[90]=t,e[91]=K):K=e[91],e[92]!==K?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K})}),e[92]=K,e[93]=b):b=e[93],_=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(g=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${g.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Y("size-1.5 shrink-0 rounded-full",g.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:g.name}),g.critical&&(0,a.jsx)(Z,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[g.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:g.message}),(0,a.jsx)(Z,{"data-testid":`dh-check-status-${g.name}`,variant:g.status==="up"?"secondary":"destructive",children:g.status==="up"?t("Up"):t("Down")})]})]},g.name))}),e[27]=l.appName,e[28]=l.appVersion,e[29]=l.checks,e[30]=l.timestamp,e[31]=W,e[32]=G,e[33]=j,e[34]=u,e[35]=t,e[36]=H,e[37]=I,e[38]=P,e[39]=x,e[40]=N,e[41]=v,e[42]=S,e[43]=V,e[44]=b,e[45]=_}else H=e[36],I=e[37],P=e[38],x=e[39],N=e[40],v=e[41],S=e[42],V=e[43],b=e[44],_=e[45];let z;e[94]!==H||e[95]!==S||e[96]!==V||e[97]!==b||e[98]!==_?(z=(0,a.jsxs)(H,{className:S,"data-testid":V,children:[b,_]}),e[94]=H,e[95]=S,e[96]=V,e[97]=b,e[98]=_,e[99]=z):z=e[99];let M;return e[100]!==I||e[101]!==P||e[102]!==x||e[103]!==N||e[104]!==v||e[105]!==z?(M=(0,a.jsxs)("div",{className:I,"data-testid":P,children:[x,N,v,z]}),e[100]=I,e[101]=P,e[102]=x,e[103]=N,e[104]=v,e[105]=z,e[106]=M):M=e[106],M},"Pe");function xe(r,e){return r.name.localeCompare(e.name)}k(xe,"he");export{Pe as DeploymentHealthPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Qe}from"./chunk-5XRNQ732.js";import{a as Me,b as Re}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as we}from"./chunk-IMOHEGMV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as He}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as We}from"./chunk-OGUKYRFM.js";import{e as Ue}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as me}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ze}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{f as Ve}from"./chunk-Z7WCKAUJ.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as Je}from"./chunk-FKVZRPV5.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-WUWBZPUK.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-FODLDLE2.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-YKXDMIHQ.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,b]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[p,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,be]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[J,xe]=(0,x.useState)(Y),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{be(await l.listGlobalTables())}catch(h){let w=h;be(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,pe=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||pe.current===n||i.some(h=>h.name===n)&&(pe.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(bt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:p,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:B,globalExpanded:W,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:b,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=S,e[57]=Ne,e[58]=re,e[59]=J,e[60]=B,e[61]=W,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function bt(s){return s.name}r(bt,"ft");var pt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let b;e[2]!==m||e[3]!==g||e[4]!==o?(b=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=b):b=e[5];let i=!u,v=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==p?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:p}),e[8]=l,e[9]=i,e[10]=v,e[11]=p,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==b||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[b,P,G,C]}),e[27]=G,e[28]=C,e[29]=b,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let b;e[6]!==o?(b=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=b):b=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let p;return e[13]!==b||e[14]!==v?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[b,v]}),e[13]=b,e[14]=v,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,b]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[p,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),b(null);try{let ge=await ft(T);b(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;b({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let be=k,B;e[6]!==p||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:p.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=p,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let J=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{b(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{b(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{b(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),b({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let pe=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==be||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:be,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=be,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:pe,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let b;e[4]!==m?(b=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=b):b=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==b||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",b]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=b,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==v?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=p):p=e[19],p},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:b,filteredTables:i,globalColumns:v,globalError:p,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,be;e[5]!==M?(be=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=be):be=e[6];let B=be,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==$?(W=$??[],e[12]=$,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",pe;e[30]!==ce?(pe=lt(ce),e[30]=ce,e[31]=pe):pe=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==pe||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:pe,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=pe,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==p||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=p,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==b||e[66]!==i||e[67]!==v||e[68]!==p||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:b.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&b.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),b.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:b.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=b,e[66]=i,e[67]=v,e[68]=p,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Xt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
1
|
+
import{a as Qe}from"./chunk-5XRNQ732.js";import{a as Me,b as Re}from"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as we}from"./chunk-IMOHEGMV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as He}from"./chunk-S3CRZLGS.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as We}from"./chunk-OGUKYRFM.js";import{e as Ue}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ae}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as me}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as ze}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as je}from"./chunk-4ZEL6BYL.js";import{f as Ve}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as Je}from"./chunk-FKVZRPV5.js";import{a as qe,b as Pe,c as Ge,d as Ke,e as Le}from"./chunk-WUWBZPUK.js";import{d as Fe,f as Ee,g as $e,h as Oe,o as ue}from"./chunk-FODLDLE2.js";import{a as r,d as Be,e as at,f as nt,g as st,i as De}from"./chunk-YKXDMIHQ.js";var Ce=Be(nt(),1);var x=Be(at(),1);var t=Be(st(),1);var rt=Ee(je.listTables),ot=Ee(je.listTableIndexes),it=Ee(je.readTablePage),dt=Ee(je.describeTables),ct={},Ye=[],mt=r(s=>{let e=(0,Ce.c)(74),{initialShardKey:u,initialTable:n}=s,l=Ve(),[a,m]=(0,x.useState)("graph"),{queryShardKey:c,setShardKey:d,shardKey:g}=He(u),[o,b]=(0,x.useState)(""),[i,v]=(0,x.useState)(null),[p,P]=(0,x.useState)(null),_;e[0]===Symbol.for("react.memo_cache_sentinel")?(_={},e[0]=_):_=e[0];let[L,y]=(0,x.useState)(_),G;e[1]===Symbol.for("react.memo_cache_sentinel")?(G={},e[1]=G):G=e[1];let[E,M]=(0,x.useState)(G),[S,C]=(0,x.useState)(null),F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];let[$,he]=(0,x.useState)(F),Q;e[3]===Symbol.for("react.memo_cache_sentinel")?(Q={},e[3]=Q):Q=e[3];let[I,K]=(0,x.useState)(Q),[k,be]=(0,x.useState)(null),[B,oe]=(0,x.useState)(null),Y;e[4]===Symbol.for("react.memo_cache_sentinel")?(Y={},e[4]=Y):Y=e[4];let[J,xe]=(0,x.useState)(Y),[W,ie]=(0,x.useState)(null),ve;e[5]!==l?(ve=r(async h=>{P(null);try{let w=await l.query(rt,{},$e(h));We(h),v(w),y({}),M({}),C(null),he(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h}))),K(N=>Object.fromEntries(Object.entries(N).filter(q=>{let[A]=q;return A!==h})))}catch(w){let N=w;v(null),P(Oe(N))}},"ve"),e[5]=l,e[6]=ve):ve=e[6];let O=ve,Z;e[7]!==l?(Z=r(async()=>{oe(null);try{be(await l.listGlobalTables())}catch(h){let w=h;be(null),oe(Oe(w))}},"Z"),e[7]=l,e[8]=Z):Z=e[8];let ee=Z,de,D;e[9]!==c||e[10]!==O||e[11]!==ee?(de=r(()=>{ue(O(c)),ue(ee())},"de"),D=[O,ee,c],e[9]=c,e[10]=O,e[11]=ee,e[12]=de,e[13]=D):(de=e[12],D=e[13]),(0,x.useEffect)(de,D);let te;e[14]!==l||e[15]!==L||e[16]!==S||e[17]!==c?(te=r(async h=>{if(S===h){C(null);return}C(h);let w=`${c}:${h}`;if(L[w]!==void 0)return;let[N,q]=await Promise.allSettled([l.query(it,{limit:1,offset:0,table:h},$e(c)),l.query(ot,{table:h},$e(c))]);N.status==="fulfilled"?y(A=>({...A,[w]:N.value.columns})):P(Oe(N.reason)),q.status==="fulfilled"&&M(A=>({...A,[w]:q.value.indexes}))},"te"),e[14]=l,e[15]=L,e[16]=S,e[17]=c,e[18]=te):te=e[18];let j=te,ye;e[19]!==l||e[20]!==J||e[21]!==W?(ye=r(async h=>{if(W===h){ie(null);return}if(ie(h),J[h]===void 0)try{let w=await l.readGlobalTablePage({limit:1,offset:0,table:h});xe(N=>({...N,[h]:w.columns}))}catch(w){oe(Oe(w))}},"ye"),e[19]=l,e[20]=J,e[21]=W,e[22]=ye):ye=e[22];let ce=ye,pe=(0,x.useRef)(void 0),R,X;e[23]!==n||e[24]!==i||e[25]!==j?(R=r(()=>{n===void 0||i===null||pe.current===n||i.some(h=>h.name===n)&&(pe.current=n,ue(j(n)))},"K"),X=[n,i,j],e[23]=n,e[24]=i,e[25]=j,e[26]=R,e[27]=X):(R=e[26],X=e[27]),(0,x.useEffect)(R,X);let V;e[28]!==l?(V=r(async(h,w,N)=>{let[q,A]=await Promise.all([Promise.allSettled([l.query(dt,{tables:[...w,...N]},$e(h))]),Promise.all(N.map(async T=>{let ge=await Promise.allSettled([l.readGlobalTablePage({limit:1,offset:0,table:T})]),Ie=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:Ie?.columns??[],refs:Ie?.refs??{},table:T}}))]),Te=q[0].status==="fulfilled"?q[0].value?.columnsByTable??{}:{},Se=q[0].status==="rejected",_e=new Map(A.map(ut)),ke=[...w,...N].map(T=>{let ge=Te[T]??[];return[T,ge.length>0?ge:_e.get(T)??[]]});he(T=>({...T,[h]:Object.fromEntries(ke)})),K(T=>({...T,[h]:Se}))},"U"),e[28]=l,e[29]=V):V=e[29];let le=V,U,ae;e[30]!==B||e[31]!==k||e[32]!==le||e[33]!==c||e[34]!==$||e[35]!==i||e[36]!==a?(U=r(()=>{a!=="graph"||i===null||k===null&&B===null||$[c]!==void 0||ue(le(c,i.map(ht),(k??[]).map(bt)))},"V"),ae=[a,i,k,B,c,$,le],e[30]=B,e[31]=k,e[32]=le,e[33]=c,e[34]=$,e[35]=i,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),(0,x.useEffect)(U,ae);let z=$[c]??ct,ne;if(e[39]!==z||e[40]!==k||e[41]!==i){let h;e[43]!==z?(h=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"shard"}),"u"),e[43]=z,e[44]=h):h=e[44];let w=(i??[]).map(h),N;e[45]!==z?(N=r(A=>({columns:z[A.name]??Ye,name:A.name,tier:"global"}),"x"),e[45]=z,e[46]=N):N=e[46];let q=(k??[]).map(N);ne=[...w,...q],e[39]=z,e[40]=k,e[41]=i,e[42]=ne}else ne=e[42];let se=ne,f;if(e[47]!==o||e[48]!==i){let h=o.trim().toLowerCase();f=(i??[]).filter(w=>w.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=f}else f=e[49];let re=f,H;if(e[50]!==k||e[51]!==o){let h=o.trim().toLowerCase();H=(k??[]).filter(w=>w.name.toLowerCase().includes(h)),e[50]=k,e[51]=o,e[52]=H}else H=e[52];let Ne=H,fe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==S||e[57]!==Ne||e[58]!==re||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==k||e[63]!==E||e[64]!==O||e[65]!==d||e[66]!==I||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==j||e[71]!==ce||e[72]!==a?(fe={columns:L,diagramTables:se,error:p,expanded:S,filteredGlobalTables:Ne,filteredTables:re,globalColumns:J,globalError:B,globalExpanded:W,globalTables:k,indexes:E,refresh:O,setShardKey:d,setTableFilter:b,setView:m,shardColumnsError:I,shardKey:g,tableFilter:o,tables:i,toggle:j,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=S,e[57]=Ne,e[58]=re,e[59]=J,e[60]=B,e[61]=W,e[62]=k,e[63]=E,e[64]=O,e[65]=d,e[66]=I,e[67]=g,e[68]=o,e[69]=i,e[70]=j,e[71]=ce,e[72]=a,e[73]=fe):fe=e[73],fe},"ct");function ut(s){let{columns:e,refs:u,table:n}=s;return[n,e.map(l=>{let a=u[l];return a===void 0?{name:l,optional:!1,type:""}:{name:l,optional:!1,ref:a,type:"id"}})]}r(ut,"mt");function ht(s){return s.name}r(ht,"ut");function bt(s){return s.name}r(bt,"ft");var pt="/__lunora/schema-edit",ft=r(async s=>{let e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json"},method:"POST"}),u=await e.json();return u.needsMigration===!0?{kind:"needs-migration",message:u.message??"This edit needs a migration."}:e.ok&&u.tables!==void 0?{diagnostics:u.diagnostics??[],kind:"ok",tables:u.tables}:{kind:"error",message:u.error??`schema edit failed (${String(e.status)})`}},"pt"),gt=r(s=>{let e=(0,Ce.c)(32),{hasTables:u,mode:n,onAddColumn:l,onAddIndex:a,onAddTable:m,onDestructive:c}=s,d=Fe(),g=n==="addTable"?"default":"outline",o;e[0]!==d?(o=d("Add table"),e[0]=d,e[1]=o):o=e[1];let b;e[2]!==m||e[3]!==g||e[4]!==o?(b=(0,t.jsx)(me,{"data-testid":"sc-editor-add-table",onClick:m,size:"xs",type:"button",variant:g,children:o}),e[2]=m,e[3]=g,e[4]=o,e[5]=b):b=e[5];let i=!u,v=n==="addColumn"?"default":"outline",p;e[6]!==d?(p=d("Add column"),e[6]=d,e[7]=p):p=e[7];let P;e[8]!==l||e[9]!==i||e[10]!==v||e[11]!==p?(P=(0,t.jsx)(me,{"data-testid":"sc-editor-add-column",disabled:i,onClick:l,size:"xs",type:"button",variant:v,children:p}),e[8]=l,e[9]=i,e[10]=v,e[11]=p,e[12]=P):P=e[12];let _=!u,L=n==="addIndex"?"default":"outline",y;e[13]!==d?(y=d("Add index"),e[13]=d,e[14]=y):y=e[14];let G;e[15]!==a||e[16]!==y||e[17]!==_||e[18]!==L?(G=(0,t.jsx)(me,{"data-testid":"sc-editor-add-index",disabled:_,onClick:a,size:"xs",type:"button",variant:L,children:y}),e[15]=a,e[16]=y,e[17]=_,e[18]=L,e[19]=G):G=e[19];let E=!u,M=n==="destructive"?"default":"ghost",S;e[20]!==d?(S=d("Rename / drop / change type\u2026"),e[20]=d,e[21]=S):S=e[21];let C;e[22]!==c||e[23]!==E||e[24]!==M||e[25]!==S?(C=(0,t.jsx)(me,{"data-testid":"sc-editor-destructive",disabled:E,onClick:c,size:"xs",type:"button",variant:M,children:S}),e[22]=c,e[23]=E,e[24]=M,e[25]=S,e[26]=C):C=e[26];let F;return e[27]!==G||e[28]!==C||e[29]!==b||e[30]!==P?(F=(0,t.jsxs)("div",{className:"flex flex-wrap gap-2",children:[b,P,G,C]}),e[27]=G,e[28]=C,e[29]=b,e[30]=P,e[31]=F):F=e[31],F},"gt"),xt=r(s=>{let e=(0,Ce.c)(28),{onOpenMigrations:u,result:n}=s,l=Fe();if(n===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[0]=o):o=e[0],o}if(n.kind==="error"){let o;return e[1]!==n.message?(o=(0,t.jsx)("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=o):o=e[2],o}if(n.kind==="needs-migration"){let o;e[3]!==n.message||e[4]!==l?(o=n.message===""?l("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=l,e[5]=o):o=e[5];let b;e[6]!==o?(b=(0,t.jsx)("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=b):b=e[7];let i;e[8]!==l?(i=l("Open Migrations"),e[8]=l,e[9]=i):i=e[9];let v;e[10]!==u||e[11]!==i?(v=(0,t.jsx)(me,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:u,size:"xs",type:"button",variant:"outline",children:i}),e[10]=u,e[11]=i,e[12]=v):v=e[12];let p;return e[13]!==b||e[14]!==v?(p=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[b,v]}),e[13]=b,e[14]=v,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=(0,t.jsx)(t.Fragment,{}),e[16]=o):o=e[16],o}let a;e[17]!==l?(a=l("Codegen reported diagnostics:"),e[17]=l,e[18]=a):a=e[18];let m;e[19]!==a?(m=(0,t.jsx)("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=m):m=e[20];let c;e[21]!==n.diagnostics?(c=n.diagnostics.map(vt),e[21]=n.diagnostics,e[22]=c):c=e[22];let d;e[23]!==c?(d=(0,t.jsx)("ul",{className:"flex flex-col gap-0.5",children:c}),e[23]=c,e[24]=d):d=e[24];let g;return e[25]!==m||e[26]!==d?(g=(0,t.jsxs)("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[m,d]}),e[25]=m,e[26]=d,e[27]=g):g=e[27],g},"bt");function vt(s){return(0,t.jsx)("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}r(vt,"xt");var yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Nt="v.string()",Ct=r(s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),"Ct"),wt=r(s=>{let e=(0,Ce.c)(83),{onApplied:u,tableNames:n}=s,l=Fe(),a=Ue(),[m,c]=(0,x.useState)(null),[d,g]=(0,x.useState)(!1),[o,b]=(0,x.useState)(null),[i,v]=(0,x.useState)(""),[p,P]=(0,x.useState)(""),[_,L]=(0,x.useState)(Nt),[y,G]=(0,x.useState)(n[0]??""),[E,M]=(0,x.useState)(""),[S,C]=(0,x.useState)(""),[F,$]=(0,x.useState)(!1),he;e[0]===Symbol.for("react.memo_cache_sentinel")?(he=r(()=>{c(null),v(""),P(""),M(""),C(""),$(!1)},"me"),e[0]=he):he=e[0];let Q=he,I;e[1]!==u?(I=r(async T=>{g(!0),b(null);try{let ge=await ft(T);b(ge),ge.kind==="ok"&&(u(ge.tables),Q())}catch(ge){let Ie=ge;b({kind:"error",message:Ie instanceof Error?Ie.message:String(Ie)})}g(!1)},"I"),e[1]=u,e[2]=I):I=e[2];let K=I,k;e[3]!==K||e[4]!==i?(k=r(()=>{ue(K({kind:"addTable",table:i.trim()}))},"_"),e[3]=K,e[4]=i,e[5]=k):k=e[5];let be=k,B;e[6]!==p||e[7]!==K||e[8]!==y||e[9]!==_?(B=r(()=>{ue(K({column:p.trim(),kind:"addOptionalColumn",table:y,validator:_}))},"j"),e[6]=p,e[7]=K,e[8]=y,e[9]=_,e[10]=B):B=e[10];let oe=B,Y;e[11]!==S||e[12]!==E||e[13]!==K||e[14]!==y||e[15]!==F?(Y=r(()=>{ue(K({fields:Ct(S),kind:"addIndex",name:E.trim(),table:y,unique:F}))},"Q"),e[11]=S,e[12]=E,e[13]=K,e[14]=y,e[15]=F,e[16]=Y):Y=e[16];let J=Y,xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=r(()=>{b(null),c("addTable")},"xe"),e[17]=xe):xe=e[17];let W=xe,ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=r(()=>{b(null),c("addColumn")},"re"),e[18]=ie):ie=e[18];let ve=ie,O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=r(()=>{b(null),c("addIndex")},"O"),e[19]=O):O=e[19];let Z=O,ee;e[20]!==l?(ee=r(()=>{c("destructive"),b({kind:"needs-migration",message:l("This edit changes stored data and must go through a migration. Review the migration before applying.")})},"ee"),e[20]=l,e[21]=ee):ee=e[21];let de=ee,D;e[22]===Symbol.for("react.memo_cache_sentinel")?(D=r(T=>{v(T.target.value)},"R"),e[22]=D):D=e[22];let te=D,j;e[23]===Symbol.for("react.memo_cache_sentinel")?(j=r(T=>{P(T.target.value)},"M"),e[23]=j):j=e[23];let ye=j,ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=r(T=>{L(T.target.value)},"ce"),e[24]=ce):ce=e[24];let pe=ce,R;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=r(T=>{G(T.target.value)},"K"),e[25]=R):R=e[25];let X=R,V;e[26]===Symbol.for("react.memo_cache_sentinel")?(V=r(T=>{M(T.target.value)},"U"),e[26]=V):V=e[26];let le=V,U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=r(T=>{C(T.target.value)},"V"),e[27]=U):U=e[27];let ae=U,z;e[28]===Symbol.for("react.memo_cache_sentinel")?(z=r(T=>{$(T.target.checked)},"$"),e[28]=z):z=e[28];let ne=z,se;e[29]!==a?(se=r(()=>{ue(a({to:"/migrations"}))},"ne"),e[29]=a,e[30]=se):se=e[30];let f=se,re;e[31]!==l?(re=l("Edit schema"),e[31]=l,e[32]=re):re=e[32];let H;e[33]!==re?(H=(0,t.jsx)(Ge,{children:re}),e[33]=re,e[34]=H):H=e[34];let Ne;e[35]!==l?(Ne=l("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=l,e[36]=Ne):Ne=e[36];let fe;e[37]!==Ne?(fe=(0,t.jsx)(Ke,{children:Ne}),e[37]=Ne,e[38]=fe):fe=e[38];let h;e[39]!==H||e[40]!==fe?(h=(0,t.jsxs)(Pe,{children:[H,fe]}),e[39]=H,e[40]=fe,e[41]=h):h=e[41];let w=n.length>0,N;e[42]!==m||e[43]!==de||e[44]!==w?(N=(0,t.jsx)(gt,{hasTables:w,mode:m,onAddColumn:ve,onAddIndex:Z,onAddTable:W,onDestructive:de}),e[42]=m,e[43]=de,e[44]=w,e[45]=N):N=e[45];let q;e[46]!==d||e[47]!==m||e[48]!==be||e[49]!==l||e[50]!==i?(q=m==="addTable"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-table-name",children:l("Table name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:i})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-table-apply",disabled:d||i.trim()==="",onClick:be,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[46]=d,e[47]=m,e[48]=be,e[49]=l,e[50]=i,e[51]=q):q=e[51];let A;e[52]!==d||e[53]!==p||e[54]!==m||e[55]!==oe||e[56]!==l||e[57]!==n||e[58]!==y||e[59]!==_?(A=m==="addColumn"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:X,value:y,children:n.map(Tt)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-name",children:l("Column name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-column-type",children:l("Column type")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:pe,value:_,children:yt.map(St)})]}),(0,t.jsx)("span",{className:"text-[11px] text-muted-foreground",children:l("Optional")}),(0,t.jsx)(me,{"data-testid":"sc-editor-column-apply",disabled:d||p.trim()===""||y==="",onClick:oe,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[52]=d,e[53]=p,e[54]=m,e[55]=oe,e[56]=l,e[57]=n,e[58]=y,e[59]=_,e[60]=A):A=e[60];let Te;e[61]!==d||e[62]!==S||e[63]!==E||e[64]!==m||e[65]!==J||e[66]!==l||e[67]!==n||e[68]!==y||e[69]!==F?(Te=m==="addIndex"&&(0,t.jsxs)("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-table",children:l("Table name")}),(0,t.jsx)("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:X,value:y,children:n.map(_t)})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-name",children:l("Index name")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:E})]}),(0,t.jsxs)("div",{className:"flex flex-col gap-1 text-xs",children:[(0,t.jsx)(we,{htmlFor:"sc-editor-index-fields",children:l("Index fields (comma-separated)")}),(0,t.jsx)(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:S})]}),(0,t.jsxs)(we,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[(0,t.jsx)("input",{checked:F,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:l("Unique")})]}),(0,t.jsx)(me,{"data-testid":"sc-editor-index-apply",disabled:d||E.trim()===""||S.trim()==="",onClick:J,size:"xs",type:"button",children:l(d?"Applying\u2026":"Apply")}),(0,t.jsx)(me,{onClick:Q,size:"xs",type:"button",variant:"ghost",children:l("Cancel")})]}),e[61]=d,e[62]=S,e[63]=E,e[64]=m,e[65]=J,e[66]=l,e[67]=n,e[68]=y,e[69]=F,e[70]=Te):Te=e[70];let Se;e[71]!==f||e[72]!==o?(Se=(0,t.jsx)(xt,{onOpenMigrations:f,result:o}),e[71]=f,e[72]=o,e[73]=Se):Se=e[73];let _e;e[74]!==N||e[75]!==q||e[76]!==A||e[77]!==Te||e[78]!==Se?(_e=(0,t.jsxs)(Le,{children:[N,q,A,Te,Se]}),e[74]=N,e[75]=q,e[76]=A,e[77]=Te,e[78]=Se,e[79]=_e):_e=e[79];let ke;return e[80]!==h||e[81]!==_e?(ke=(0,t.jsxs)(qe,{"data-testid":"sc-editor",size:"sm",children:[h,_e]}),e[80]=h,e[81]=_e,e[82]=ke):ke=e[82],ke},"Nt");function Tt(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(Tt,"Tt");function St(s){return(0,t.jsx)("option",{value:s.validator,children:s.label},s.validator)}r(St,"St");function _t(s){return(0,t.jsx)("option",{value:s,children:s},s)}r(_t,"wt");var Ze=[],kt=r(s=>{let e=(0,Ce.c)(5),{open:u}=s,n=u&&"rotate-90",l;e[0]!==n?(l=De("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=l):l=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let m;return e[3]!==l?(m=(0,t.jsx)("svg",{"aria-hidden":"true",className:l,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=l,e[4]=m):m=e[4],m},"_t"),et=r(s=>{let e=(0,Ce.c)(20),{children:u,expanded:n,name:l,onToggle:a,rowCount:m,rowTestId:c,toggleTestId:d}=s,g;e[0]!==n?(g=(0,t.jsx)(kt,{open:n}),e[0]=n,e[1]=g):g=e[1];let o;e[2]!==l?(o=(0,t.jsx)("span",{className:"truncate font-mono text-xs text-foreground",title:l,children:l}),e[2]=l,e[3]=o):o=e[3];let b;e[4]!==m?(b=(0,t.jsxs)("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",m,")"]}),e[4]=m,e[5]=b):b=e[5];let i;e[6]!==n||e[7]!==a||e[8]!==g||e[9]!==o||e[10]!==b||e[11]!==d?(i=(0,t.jsxs)("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":d,onClick:a,type:"button",children:[g,o," ",b]}),e[6]=n,e[7]=a,e[8]=g,e[9]=o,e[10]=b,e[11]=d,e[12]=i):i=e[12];let v;e[13]!==u||e[14]!==n?(v=n&&(0,t.jsx)("div",{className:"px-3 pb-3 ps-8",children:u}),e[13]=u,e[14]=n,e[15]=v):v=e[15];let p;return e[16]!==c||e[17]!==i||e[18]!==v?(p=(0,t.jsxs)("li",{className:"border-t border-border/60 first:border-t-0","data-testid":c,children:[i,v]}),e[16]=c,e[17]=i,e[18]=v,e[19]=p):p=e[19],p},"Ye"),tt=r(s=>{let e=(0,Ce.c)(5),{columns:u,testId:n}=s,l;e[0]!==u?(l=u.map(At),e[0]=u,e[1]=l):l=e[1];let a;return e[2]!==l||e[3]!==n?(a=(0,t.jsx)("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:l}),e[2]=l,e[3]=n,e[4]=a):a=e[4],a},"He"),It=r(s=>{let e=(0,Ce.c)(10),{heading:u,indexes:n,testId:l}=s,a;e[0]!==u?(a=(0,t.jsx)("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:u}),e[0]=u,e[1]=a):a=e[1];let m;e[2]!==n?(m=n.map(Ft),e[2]=n,e[3]=m):m=e[3];let c;e[4]!==m||e[5]!==l?(c=(0,t.jsx)("ul",{className:"flex flex-col gap-1","data-testid":l,children:m}),e[4]=m,e[5]=l,e[6]=c):c=e[6];let d;return e[7]!==a||e[8]!==c?(d=(0,t.jsxs)("div",{className:"pt-3",children:[a,c]}),e[7]=a,e[8]=c,e[9]=d):d=e[9],d},"Et"),lt=r(s=>De("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Je"),Xt=r(s=>{let e=(0,Ce.c)(85),{initialShardKey:u,initialTable:n,schemaEditable:l}=s,a=Fe(),m;e[0]!==u||e[1]!==n?(m={initialShardKey:u,initialTable:n},e[0]=u,e[1]=n,e[2]=m):m=e[2];let{columns:c,diagramTables:d,error:g,expanded:o,filteredGlobalTables:b,filteredTables:i,globalColumns:v,globalError:p,globalExpanded:P,globalTables:_,indexes:L,refresh:y,setShardKey:G,setTableFilter:E,setView:M,shardColumnsError:S,shardKey:C,tableFilter:F,tables:$,toggle:he,toggleGlobal:Q,view:I}=mt(m),K;e[3]!==M?(K=r(()=>{M("list")},"q"),e[3]=M,e[4]=K):K=e[4];let k=K,be;e[5]!==M?(be=r(()=>{M("graph")},"ue"),e[5]=M,e[6]=be):be=e[6];let B=be,oe;e[7]!==E?(oe=r(f=>{E(f.target.value)},"ie"),e[7]=E,e[8]=oe):oe=e[8];let Y=oe,J;e[9]!==y||e[10]!==C?(J=r(f=>{ue(y(C))},"Y"),e[9]=y,e[10]=C,e[11]=J):J=e[11];let xe=J,W;e[12]!==$?(W=$??[],e[12]=$,e[13]=W):W=e[13];let ie;e[14]!==W?(ie=W.map(zt),e[14]=W,e[15]=ie):ie=e[15];let ve=ie,O;e[16]!==G||e[17]!==C?(O=(0,t.jsx)(Xe,{onChange:G,testId:"sc-shard-input",value:C}),e[16]=G,e[17]=C,e[18]=O):O=e[18];let Z;e[19]!==a?(Z=a("Schema view"),e[19]=a,e[20]=Z):Z=e[20];let ee=I==="graph",de=I==="graph",D;e[21]!==de?(D=lt(de),e[21]=de,e[22]=D):D=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let j;e[25]!==B||e[26]!==ee||e[27]!==D||e[28]!==te?(j=(0,t.jsx)("button",{"aria-selected":ee,className:D,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:te}),e[25]=B,e[26]=ee,e[27]=D,e[28]=te,e[29]=j):j=e[29];let ye=I==="list",ce=I==="list",pe;e[30]!==ce?(pe=lt(ce),e[30]=ce,e[31]=pe):pe=e[31];let R;e[32]!==a?(R=a("Table list"),e[32]=a,e[33]=R):R=e[33];let X;e[34]!==k||e[35]!==ye||e[36]!==pe||e[37]!==R?(X=(0,t.jsx)("button",{"aria-selected":ye,className:pe,"data-testid":"sc-view-list",onClick:k,role:"tab",type:"button",children:R}),e[34]=k,e[35]=ye,e[36]=pe,e[37]=R,e[38]=X):X=e[38];let V;e[39]!==j||e[40]!==X||e[41]!==Z?(V=(0,t.jsxs)("div",{"aria-label":Z,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[j,X]}),e[39]=j,e[40]=X,e[41]=Z,e[42]=V):V=e[42];let le;e[43]!==V||e[44]!==O?(le=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-3",children:[O,V]}),e[43]=V,e[44]=O,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==l||e[48]!==ve?(U=l===!0&&(0,t.jsx)(wt,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=l,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==Y||e[51]!==a||e[52]!==F||e[53]!==I?(ae=I==="list"&&(0,t.jsx)(Ae,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Y,placeholder:a("Filter tables"),value:F}),e[50]=Y,e[51]=a,e[52]=F,e[53]=I,e[54]=ae):ae=e[54];let z;e[55]!==d||e[56]!==g||e[57]!==p||e[58]!==S||e[59]!==C||e[60]!==I?(z=I==="graph"&&(0,t.jsxs)("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),(0,t.jsx)(Qe,{columnsError:S[C]===!0,tables:d,testIdPrefix:"sc-graph"})]}),e[55]=d,e[56]=g,e[57]=p,e[58]=S,e[59]=C,e[60]=I,e[61]=z):z=e[61];let ne;e[62]!==c||e[63]!==g||e[64]!==o||e[65]!==b||e[66]!==i||e[67]!==v||e[68]!==p||e[69]!==P||e[70]!==_||e[71]!==L||e[72]!==C||e[73]!==a||e[74]!==$||e[75]!==he||e[76]!==Q||e[77]!==I?(ne=I==="list"&&(0,t.jsxs)("div",{className:"flex flex-col gap-4",children:[(0,t.jsxs)(qe,{"data-testid":"sc-shard-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"shard"}),(0,t.jsx)(Ge,{children:a("Shard tables")}),$!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),(0,t.jsx)(Ke,{children:Me.shard.hint})]}),(0,t.jsxs)(Le,{children:[g!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),$!==null&&$.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),$!==null&&$.length>0&&i.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),i.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(f=>{let re=`${C}:${f.name}`,H=L[re]??[];return(0,t.jsxs)(et,{expanded:o===f.name,name:f.name,onToggle:r(()=>{ue(he(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-table-${f.name}`,toggleTestId:`sc-toggle-${f.name}`,children:[(0,t.jsx)(tt,{columns:c[re]??Ze,testId:`sc-columns-${f.name}`}),H.length>0&&(0,t.jsx)(It,{heading:a("Indexes"),indexes:H,testId:`sc-indexes-${f.name}`})]},f.name)})})]})]}),(0,t.jsxs)(qe,{"data-testid":"sc-global-section",size:"sm",children:[(0,t.jsxs)(Pe,{children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(Re,{tier:"global"}),(0,t.jsx)(Ge,{children:a("Global tables (D1)")}),_!==null&&(0,t.jsx)(ze,{className:"ms-auto tabular-nums",variant:"outline",children:b.length})]}),(0,t.jsx)(Ke,{children:Me.global.hint})]}),(0,t.jsxs)(Le,{children:[p!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),_!==null&&_.length===0&&(0,t.jsx)(Je,{description:Me.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),_!==null&&_.length>0&&b.length===0&&(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),b.length>0&&(0,t.jsx)("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:b.map(f=>(0,t.jsx)(et,{expanded:P===f.name,name:f.name,onToggle:r(()=>{ue(Q(f.name))},"onToggle"),rowCount:f.rowCount,rowTestId:`sc-global-table-${f.name}`,toggleTestId:`sc-global-toggle-${f.name}`,children:(0,t.jsx)(tt,{columns:v[f.name]??Ze,testId:`sc-global-columns-${f.name}`})},f.name))})]})]})]}),e[62]=c,e[63]=g,e[64]=o,e[65]=b,e[66]=i,e[67]=v,e[68]=p,e[69]=P,e[70]=_,e[71]=L,e[72]=C,e[73]=a,e[74]=$,e[75]=he,e[76]=Q,e[77]=I,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==z||e[83]!==ne?(se=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,z,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=z,e[83]=ne,e[84]=se):se=e[84],se},"Xt");function At(s){return(0,t.jsx)("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}r(At,"It");function Ft(s){return(0,t.jsxs)("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[(0,t.jsx)("span",{className:"font-mono",children:s.name}),(0,t.jsx)(ze,{variant:"outline",children:s.type}),s.unique===!0&&(0,t.jsx)(ze,{variant:"secondary",children:"unique"}),(0,t.jsx)("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}r(Ft,"kt");function zt(s){return s.name}r(zt,"At");export{Xt as SchemaViewer};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{a as nt,b as rt}from"./chunk-5B6TTEP6.js";import{c as tt}from"./chunk-M4POCI2J.js";import{a as et}from"./chunk-PZVVEPIN.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import"./chunk-XZMOZFE6.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-URBHAYYZ.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import"./chunk-PD6WIDY6.js";import{a as Xe}from"./chunk-2DX5MROH.js";import{b as Ve}from"./chunk-OGUKYRFM.js";import{c as Ke,d as Ce,e as Ee,f as Le,g as He}from"./chunk-OKG3HWSJ.js";import{W as Ye}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as Je}from"./chunk-ULIQFBZU.js";import{a as qe}from"./chunk-4ZEL6BYL.js";import"./chunk-SDHFSBNM.js";import{f as Ie}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import"./chunk-HEAQVSNS.js";import{d as ce,f as Se,g as Ne,h as Ge,o as ue}from"./chunk-FODLDLE2.js";import{a as l,d as Be,e as St,f as Nt,g as qt,i as me}from"./chunk-YKXDMIHQ.js";var G=Be(Nt(),1);var j=Be(St(),1);var u=Be(qt(),1);var Ct="x",ot=" ",kt={'"':'"',"'":"'","[":"]","`":"`"},ct=l((s,e)=>{let n=e+2;for(;n<s.length&&s[n]!==`
|
|
2
|
+
`;)n+=1;return n},"tt"),dt=l((s,e)=>{let n=s.indexOf("*/",e+2);return n===-1?-1:n+2},"nt"),ut=l(s=>{let e=s.split(""),n=0;for(;n<s.length;){let t=s[n]??"",o=kt[t];if(t==="-"&&s[n+1]==="-"){let r=ct(s,n);e.fill(ot,n,r),n=r}else if(t==="/"&&s[n+1]==="*"){let r=dt(s,n);if(r===-1)return;e.fill(ot,n,r),n=r}else if(o!==void 0){let r=n+1;for(;r<s.length;)if(s[r]!==o)r+=1;else if(o!=="]"&&s[r+1]===o)r+=2;else break;if(r>=s.length)return;e.fill(Ct,n,r+1),n=r+1}else n+=1}for(let t=0;t<s.length;t+=1)s[t]===`
|
|
3
|
+
`&&(e[t]=`
|
|
4
|
+
`);return e.join("")},"st"),Tt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,Rt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,_t=/^\w+/u,It=/;\s*$/u,Et=/\s/u,mt=l(s=>{let e=0;for(;e<s.length;){let n=s[e];if(n!==void 0&&Et.test(n))e+=1;else if(n==="-"&&s[e+1]==="-")e=ct(s,e);else if(n==="/"&&s[e+1]==="*"){let t=dt(s,e);if(t===-1)break;e=t}else break}return e},"ot"),Lt=l(s=>{let e=mt(s),n=s.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};let t=(ut(n)??n).replace(It,""),o=n.slice(0,t.length),r=t.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let a="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!Tt.test(o))return{code:"SQL_NOT_READONLY",length:_t.exec(o)?.[0].length??1,message:a,offset:e};let c=Rt.exec(o);if(c!==null)return{code:"SQL_NOT_READONLY",length:c[0].length,message:`${a} (\`${c[0].toUpperCase()}\` is not allowed)`,offset:e+c.index}},"Ot"),Ot=/^explain\b/iu,At=l(s=>Ot.test(s.slice(mt(s)))?s:`EXPLAIN QUERY PLAN ${s}`,"Mt"),Qe=l((s,e)=>{let n=s.trim();if(n==="")return[];let t=e+s.indexOf(n),o=Lt(n);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:n}:{offset:t,rejection:o,sql:n}]},"We"),ft=l(s=>{let e=ut(s);if(e===void 0)return Qe(s,0);let n=[],t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(n.push(...Qe(s.slice(t,o),t)),t=o+1);return n},"lt"),Dt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Mt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],De=String.fromCodePoint(0),$t=new RegExp(`${De}${String.raw`(\d+)`}${De}`,"gu"),Ft=Dt.map(s=>({pattern:new RegExp(String.raw`\b${s.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:s})),zt=Mt.map(s=>({pattern:new RegExp(String.raw`\s+${s.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
5
|
+
${s}`})),Bt=l(s=>{let e=[],n=s.replaceAll(/'(?:[^']|'')*'/gu,t=>(e.push(t),`${De}${(e.length-1).toString()}${De}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:t,replacement:o}of Ft)n=n.replaceAll(t,o);for(let{pattern:t,replacement:o}of zt)n=n.replaceAll(t,o);return n=n.replaceAll($t,(t,o)=>e[Number(o)]??""),n},"Wt"),Ht=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Pt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Qt=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),jt=/[^\n]/gu,Wt=l((s,e)=>{let n=s[e];if(n==="'"){let t=e+1;for(;t<s.length&&s[t]!=="'";)t+=1;return Math.min(t+1,s.length)}if(n==="-"&&s[e+1]==="-"){let t=s.indexOf(`
|
|
6
|
+
`,e);return t===-1?s.length:t}if(n==="/"&&s[e+1]==="*"){let t=s.indexOf("*/",e+2);return t===-1?s.length:t+2}return-1},"Yt"),Ut=l(s=>{let e="",n=0;for(;n<s.length;){let t=Wt(s,n);t===-1?(e+=s.slice(n,n+1),n+=1):(e+=s.slice(n,t).replaceAll(jt," "),n=t)}return e},"Kt"),Yt=l(s=>{let e=new Set;for(let n of s.matchAll(Pt))e.add((n[1]??"").toLowerCase());return e},"Gt"),Gt=l((s,e)=>{let n=new Map;for(let t of s.matchAll(Ht)){let o=(t[1]??"").toLowerCase(),r=(t[2]??"").toLowerCase();e.has(o)&&(n.set(o,o),r!==""&&!Qt.has(r)&&n.set(r,o))}return n},"Jt"),ht=l((s,e)=>{let n=Ut(s),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:Yt(n),masked:n,targets:Gt(n,t)}},"rt"),Kt=/^(?:__lunora|sqlite_)/iu,Vt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Xt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Jt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Zt=l((s,e,n)=>{let t=[];for(let o of s.matchAll(Vt)){let r=o[1]??"",a=r.toLowerCase();!e.has(a)&&!n.has(a)&&!Jt.has(a)&&!Kt.test(r)&&t.push({length:r.length,message:`unknown table \`${r}\``,offset:o.index+o[0].length-r.length,severity:"error",source:"schema"})}return t},"tn"),en=l((s,e,n)=>{let t=[],o=new Map;for(let[r,a]of Object.entries(e.columns))o.set(r.toLowerCase(),new Set(a.map(c=>c.toLowerCase())));for(let r of s.matchAll(Xt)){let a=(r[1]??"").toLowerCase(),c=r[2]??"",i=n.get(a),d=i===void 0?void 0:o.get(i);d!==void 0&&!d.has(c.toLowerCase())&&t.push({length:c.length,message:`\`${i??""}\` has no column \`${c}\``,offset:r.index+r[0].length-c.length,severity:"error",source:"schema"})}return t},"nn"),tn=/(?<![\w$."])(?:"([a-z_][\w$]*)"|([a-z_][\w$]*))(?![.(])/giu,nn=/\bas\s+"?([a-z_][\w$]*)"?/giu,rn=l((s,e,n,t)=>{let o=[...new Set(n.values())],r=new Map,a=new Set;for(let d of o){for(let h of e.columns[d]??[])a.add(h.toLowerCase());for(let h of e.docFields?.[d]??[])r.set(h.toLowerCase(),h)}if(r.size===0)return[];let c=new Set([...s.matchAll(nn)].map(d=>(d[1]??"").toLowerCase())),i=[];for(let d of s.matchAll(tn)){let h=d[1],b=h??d[2]??"",g=b.toLowerCase(),v=r.get(g);v===void 0||a.has(g)||c.has(g)||t.has(g)||n.has(g)||i.push({length:b.length,message:`\`${v}\` is a \`__doc__\` field, not a column \u2014 use \`json_extract(__doc__, '$.${v}')\``,offset:d.index+(h===void 0?0:1),severity:"error",source:"schema"})}return i},"ln"),on=l((s,e)=>{if(s.trim()==="")return[];let n=ft(s),t=new Set(e.tables.map(r=>r.toLowerCase())),o=[];for(let r of n){let{offset:a,rejection:c}=r;if(c!==void 0){o.push({length:c.length,message:c.message,offset:c.offset===void 0?a:a+c.offset,severity:"error",source:"gate"});continue}let{ctes:i,masked:d,targets:h}=ht(r.sql,e.tables);o.push(...[...Zt(d,t,i),...en(d,e,h),...rn(d,e,h,i)].map(b=>({...b,offset:b.offset===void 0?a:a+b.offset})))}return o},"rn"),sn=Se(qe.lintSql),ln=600,an=l((s,e,n)=>{let t=Ie(),[o,r]=(0,j.useState)([]),a=(0,j.useMemo)(()=>on(s,e),[s,e]),c=Ze(s,ln),i=a.some(b=>b.source==="gate")||c.trim()==="",d=(0,j.useCallback)(async b=>{try{let g=await t.query(sn,{sql:c},Ne(n));b.cancelled||r(g.diagnostics??[])}catch{b.cancelled||r([])}},[t,c,n]);(0,j.useEffect)(()=>{if(i){r([]);return}let b={cancelled:!1};return ue(d(b)),()=>{b.cancelled=!0}},[d,i]);let h=c===s;return(0,j.useMemo)(()=>h?[...a,...o]:a,[a,o,h])},"dn"),Oe=8,cn=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],dn=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),un=/[\w$]/,pt=l(s=>s!==void 0&&un.test(s),"it"),bt=l(s=>{let e=s.length;for(;e>0&&pt(s[e-1]);)e-=1;return s.slice(e)},"at"),gt=l((s,e)=>{let n=e;for(;n>0&&pt(s[n-1]);)n-=1;return{end:e,start:n,text:s.slice(n,e)}},"ct"),st=l((s,e)=>{let n=s.slice(0,e).trimEnd();return n.endsWith(".")||dn.has(bt(n).toUpperCase())},"Je"),mn=l((s,e,n)=>{let t=s.slice(0,e);if(!t.endsWith("."))return;let o=bt(t.slice(0,-1));if(o!=="")return ht(s,n).targets.get(o.toLowerCase())??o},"hn"),je=l((s,e)=>s.toLowerCase().startsWith(e.toLowerCase()),"Ue"),lt=l((s,e,n,t)=>{let o=[];for(let r of s)if(je(r,e)&&(o.push(t(r)),o.length>=n))break;return o},"Ve"),fn=l((s,e,n)=>{let t=new Map;for(let[o,r]of Object.entries(s.columns))for(let a of r)if(je(a,e)&&!t.has(a)&&(t.set(a,o),t.size>=n))return[...t].map(([c,i])=>({detail:i,kind:"column",label:c}));return[...t].map(([o,r])=>({detail:r,kind:"column",label:o}))},"pn"),hn=l((s,e,n)=>{let t=gt(s,e),o=mn(s,t.start,n.tables);if(o!==void 0){let i=n.columns[o]??n.columns[o.toLowerCase()]??[];return lt(i,t.text,Oe,d=>({detail:o,kind:"column",label:d}))}if(t.text===""&&!st(s,t.start))return[];let r=lt(n.tables,t.text,Oe,i=>({kind:"table",label:i})),a=fn(n,t.text,Oe),c=cn.flatMap(i=>t.text!==""&&je(i,t.text)&&i.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:i}]:[]);return(st(s,t.start)?[...a,...r,...c]:[...r,...a,...c]).slice(0,Oe)},"bn"),pn=l((s,e,n)=>{let t=gt(s,e),o=s.slice(0,t.start)+n.label+s.slice(t.end);return{caret:t.start+n.label.length,value:o}},"gn"),bn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],gn=l((s,e)=>{let n=globalThis.getComputedStyle(s),t=globalThis.document.createElement("div"),{style:o}=t;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(let i of bn)o[i]=n[i];t.textContent=s.value.slice(0,Math.max(0,e));let r=globalThis.document.createElement("span");r.textContent=s.value.slice(Math.max(0,e))||".",t.append(r),globalThis.document.body.append(t);let a=r.offsetLeft-s.scrollLeft,c=r.offsetTop-s.scrollTop;return t.remove(),{left:a,top:c}},"vn"),xn=l((s,e,n)=>{let t=(0,G.c)(16),[o,r]=(0,j.useState)(null),a;t[0]!==s||t[1]!==e?(a=l((y,x)=>{let q=hn(y,x,s);if(q.length===0){r(null);return}let w=e.current,{left:p,top:N}=w===null?{left:0,top:0}:gn(w,x);r(k=>k!==null&&k.active===0&&k.left===p&&k.top===N&&k.suggestions.length===q.length&&k.suggestions.every((R,T)=>{let E=q.at(T);return R.kind===E?.kind&&R.label===E.label&&R.detail===E.detail})?k:{active:0,left:p,suggestions:q,top:N})},"r"),t[0]=s,t[1]=e,t[2]=a):a=t[2];let c=a,i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=l(()=>{r(null)},"a"),t[3]=i):i=t[3];let d=i,h;t[4]===Symbol.for("react.memo_cache_sentinel")?(h=l(y=>{r(x=>{if(x===null)return x;let q=x.suggestions.length,w=(x.active+y+q)%q;return{...x,active:w}})},"f"),t[4]=h):h=t[4];let b=h,g;t[5]!==n||t[6]!==o||t[7]!==e?(g=l(y=>{let x=e.current;if(o===null||x===null)return!1;let q=o.suggestions[y??o.active];if(q===void 0)return!1;let w=pn(x.value,x.selectionStart,q);return n(w.value),r(null),requestAnimationFrame(()=>{let p=e.current;p!==null&&(p.focus(),p.setSelectionRange(w.caret,w.caret))}),!0},"m"),t[5]=n,t[6]=o,t[7]=e,t[8]=g):g=t[8];let v=g,m;t[9]!==v?(m=l(()=>v(),"d"),t[9]=v,t[10]=m):m=t[10];let S=m,f;return t[11]!==S||t[12]!==v||t[13]!==c||t[14]!==o?(f={close:d,commit:S,commitAt:v,move:b,refresh:c,state:o},t[11]=S,t[12]=v,t[13]=c,t[14]=o,t[15]=f):f=t[15],f},"yn"),vn={column:"column",keyword:"keyword",table:"table"},yn=20,wn=l(s=>{let e=(0,G.c)(17),{listboxId:n,onPick:t,state:o}=s,r=ce(),a;e[0]!==o?(a=o===null?void 0:{left:o.left,top:o.top+yn},e[0]=o,e[1]=a):a=e[1];let c=a;if(o===null)return null;let i;if(e[2]!==n||e[3]!==t||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==r){let h;e[8]!==n||e[9]!==t||e[10]!==o.active||e[11]!==r?(h=l((b,g)=>(0,u.jsxs)("li",{"aria-selected":g===o.active,className:me("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",g===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${n}-opt-${g.toString()}`,onMouseDown:l(v=>{v.preventDefault(),t(g)},"onMouseDown"),role:"option",children:[(0,u.jsx)("span",{className:"truncate font-mono",children:b.label}),b.detail!==void 0&&(0,u.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:b.detail}),(0,u.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:r(vn[b.kind])})]},`${b.kind}:${b.label}`),"f"),e[8]=n,e[9]=t,e[10]=o.active,e[11]=r,e[12]=h):h=e[12],i=o.suggestions.map(h),e[2]=n,e[3]=t,e[4]=o.active,e[5]=o.suggestions,e[6]=r,e[7]=i}else i=e[7];let d;return e[13]!==n||e[14]!==c||e[15]!==i?(d=(0,u.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:n,role:"listbox",style:c,children:i}),e[13]=n,e[14]=c,e[15]=i,e[16]=d):d=e[16],d},"Cn"),Sn=Se(qe.listTables),Nn=Se(qe.readTablePage),qn=l(s=>{let e=(0,G.c)(18),n=Ie(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];let[o,r]=(0,j.useState)(t),a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={},e[1]=a):a=e[1];let[c,i]=(0,j.useState)(a),d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={},e[2]=d):d=e[2];let[h,b]=(0,j.useState)(d),g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=new Set,e[3]=g):g=e[3];let v=(0,j.useRef)(g),m,S;e[4]!==n||e[5]!==s?(m=l(()=>{let p={cancelled:!1};return ue((async()=>{try{let N=await n.query(Sn,{},Ne(s));p.cancelled||(r(N.map(kn)),i({}),b({}),v.current=new Set)}catch{p.cancelled||(r([]),i({}),b({}),v.current=new Set)}})()),()=>{p.cancelled=!0}},"d"),S=[n,s],e[4]=n,e[5]=s,e[6]=m,e[7]=S):(m=e[6],S=e[7]),(0,j.useEffect)(m,S);let f;e[8]!==n||e[9]!==s?(f=l(p=>{v.current.has(p)||(v.current.add(p),ue((async()=>{try{let N=await n.query(Nn,{limit:1,offset:0,table:p},Ne(s)),{sqlColumns:k}=N;if(k===void 0){v.current.delete(p);return}let R=new Set(k),T=N.columns.filter(E=>!R.has(E));i(E=>({...E,[p]:k})),b(E=>({...E,[p]:T}))}catch{v.current.delete(p)}})()))},"u"),e[8]=n,e[9]=s,e[10]=f):f=e[10];let y=f,x;e[11]!==c||e[12]!==h||e[13]!==o?(x={columns:c,docFields:h,tables:o},e[11]=c,e[12]=h,e[13]=o,e[14]=x):x=e[14];let q=x,w;return e[15]!==y||e[16]!==q?(w={probe:y,schema:q},e[15]=y,e[16]=q,e[17]=w):w=e[17],w},"En"),Pe=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,Cn=l(s=>{let e=new Set;Pe.lastIndex=0;let n=Pe.exec(s);for(;n!==null;)e.add(n[1]??n[2]),n=Pe.exec(s);return[...e]},"Tn");function kn(s){return s.name}l(kn,"Rn");var Tn=l(s=>{let e=(0,G.c)(34),{onSubmit:n,probe:t,schema:o,setDraft:r}=s,a=(0,j.useId)(),c=(0,j.useRef)(null),i=(0,j.useRef)(null),d=(0,j.useRef)(null),h=xn(o,d,r),{close:b,commit:g,commitAt:v,move:m,refresh:S,state:f}=h,y;e[0]!==v?(y=l(C=>{v(C)},"v"),e[0]=v,e[1]=y):y=e[1];let x=y,q;e[2]!==S?(q=l(()=>{let C=d.current;C!==null&&C===document.activeElement&&S(C.value,C.selectionStart)},"N"),e[2]=S,e[3]=q):q=e[3];let w;e[4]!==S||e[5]!==o?(w=[S,o],e[4]=S,e[5]=o,e[6]=w):w=e[6],(0,j.useEffect)(q,w);let p;e[7]!==t||e[8]!==S||e[9]!==r?(p=l(C=>{let{selectionStart:P,value:_}=C.target;r(_);for(let $ of Cn(_))t($);S(_,P)},"h"),e[7]=t,e[8]=S,e[9]=r,e[10]=p):p=e[10];let N=p,k;e[11]!==S?(k=l(C=>{let P=C.currentTarget;S(P.value,P.selectionStart)},"w"),e[11]=S,e[12]=k):k=e[12];let R=k,T;e[13]!==f||e[14]!==b||e[15]!==g||e[16]!==m||e[17]!==n?(T=l(C=>{if(f!==null){if(C.key==="ArrowDown"){C.preventDefault(),m(1);return}if(C.key==="ArrowUp"){C.preventDefault(),m(-1);return}if(C.key==="Escape"){C.preventDefault(),b();return}if((C.key==="Enter"||C.key==="Tab")&&!C.metaKey&&!C.ctrlKey&&g()){C.preventDefault();return}}(C.metaKey||C.ctrlKey)&&C.key==="Enter"&&(C.preventDefault(),n())},"T"),e[13]=f,e[14]=b,e[15]=g,e[16]=m,e[17]=n,e[18]=T):T=e[18];let E=T,I;e[19]!==b?(I=l(()=>{requestAnimationFrame(()=>{b()})},"C"),e[19]=b,e[20]=I):I=e[20];let O=I,A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=l(C=>{let{scrollLeft:P,scrollTop:_}=C.currentTarget;c.current!==null&&(c.current.scrollTop=_),i.current!==null&&(i.current.scrollTop=_,i.current.scrollLeft=P)},"q"),e[21]=A):A=e[21];let L=A,F;e[22]===Symbol.for("react.memo_cache_sentinel")?(F=l(C=>{let P=d.current;P===null||C.offset===void 0||(P.focus(),P.setSelectionRange(C.offset,C.offset+(C.length??0)))},"B"),e[22]=F):F=e[22];let M=F,H;e[23]!==N||e[24]!==O||e[25]!==E||e[26]!==R?(H={onBlur:O,onChange:N,onKeyDown:E,onScroll:L,onSelect:R},e[23]=N,e[24]=O,e[25]=E,e[26]=R,e[27]=H):H=e[27];let D;return e[28]!==f||e[29]!==b||e[30]!==a||e[31]!==x||e[32]!==H?(D={autocompleteState:f,closeAutocomplete:b,handlers:H,listboxId:a,onPickSuggestion:x,editorRef:d,gutterRef:c,overlayRef:i,revealDiagnostic:M},e[28]=f,e[29]=b,e[30]=a,e[31]=x,e[32]=H,e[33]=D):D=e[33],D},"Ln"),Rn="lunora-studio-sql-tabs",_n="lunora-studio-sql-active-tab",We=12,ke=l((s="",e="")=>({activeId:null,id:He("tab"),name:e,sql:s}),"we"),In=l(()=>Le(_n,""),"An"),En=l(s=>{let e=(0,G.c)(16),[n,t]=Ee(Rn),[o,r]=In(),[a]=(0,j.useState)(s),c,i;e[0]!==a||e[1]!==t||e[2]!==n.length?(c=l(()=>{n.length===0&&t([a])},"c"),i=[a,t,n.length],e[0]=a,e[1]=t,e[2]=n.length,e[3]=c,e[4]=i):(c=e[3],i=e[4]),(0,j.useEffect)(c,i);let d;e[5]!==a||e[6]!==n?(d=n.length===0?[a]:n,e[5]=a,e[6]=n,e[7]=d):d=e[7];let h=d,b;e[8]!==o||e[9]!==h?(b=h.some(m=>m.id===o)?o:h[0]?.id??"",e[8]=o,e[9]=h,e[10]=b):b=e[10];let g=b,v;return e[11]!==g||e[12]!==r||e[13]!==t||e[14]!==h?(v={activeId:g,setActiveId:r,setTabs:t,tabs:h},e[11]=g,e[12]=r,e[13]=t,e[14]=h,e[15]=v):v=e[15],v},"qn"),xt=l(s=>s.activeId===null&&s.sql.trim()!=="","dt"),Ln=l((s,e)=>[...s,e].slice(-We),"On"),On=l((s,e,n)=>{let t=s.findIndex(r=>r.id===e);if(t===-1)return{activeId:s[0]?.id??"",tabs:[...s]};let o=s.filter(r=>r.id!==e);if(o.length===0){let r=n();return{activeId:r.id,tabs:[r]}}return{activeId:o[Math.min(t,o.length-1)].id,tabs:o}},"Dn"),An=l((s,e)=>{let n=s.filter(t=>t.id===e);return n.length===0?{activeId:s[0]?.id??"",tabs:[...s]}:{activeId:e,tabs:n}},"Mn"),Dn=l((s,e,n)=>{let t=s.findIndex(r=>r.id===e);if(t===-1)return{activeId:n,tabs:[...s]};let o=s.slice(0,t+1);return{activeId:o.some(r=>r.id===n)?n:e,tabs:o}},"$n"),Mn=l(s=>{let e=s();return{activeId:e.id,tabs:[e]}},"Bn"),$n=l((s,e,n)=>{if(s==="others")return e.filter(t=>t.id!==n);if(s==="right"){let t=e.findIndex(o=>o.id===n);return t===-1?[]:e.slice(t+1)}return[...e]},"Hn"),at={error:null,pane:"results",result:null,running:!1},Fn=l(s=>{let e=(0,G.c)(66),{activeId:n,setActiveId:t,setTabs:o,tabs:r}=En(s),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let[c,i]=(0,j.useState)(a),[d,h]=(0,j.useState)(null),[b,g]=(0,j.useState)(null),v;e[1]!==n||e[2]!==r?(v=r.find(B=>B.id===n)??r[0]??ke(),e[1]=n,e[2]=r,e[3]=v):v=e[3];let m=v,S=c[m.id]??at,f;e[4]!==m.id||e[5]!==o?(f=l(B=>{o(U=>U.map(Y=>Y.id===m.id?{...Y,...B}:Y))},"u"),e[4]=m.id,e[5]=o,e[6]=f):f=e[6];let y=f,x;e[7]!==m.id?(x=l(B=>{i(U=>{let Y=U[m.id]??at;return{...U,[m.id]:{...Y,...B}}})},"g"),e[7]=m.id,e[8]=x):x=e[8];let q=x,w;e[9]!==t||e[10]!==o||e[11]!==r.length?(w=l(()=>{if(r.length>=We)return;let B=ke();o(U=>Ln(U,B)),t(B.id)},"y"),e[9]=t,e[10]=o,e[11]=r.length,e[12]=w):w=e[12];let p=w,N;e[13]!==t||e[14]!==o?(N=l(B=>{h(null),g(null),o(B.tabs),t(B.activeId);let U=new Set(B.tabs.map(zn));i(Y=>Object.fromEntries(Object.entries(Y).filter(X=>{let[fe]=X;return U.has(fe)})))},"E"),e[13]=t,e[14]=o,e[15]=N):N=e[15];let k=N,R;e[16]!==k||e[17]!==r?(R=l(B=>{k(On(r,B,ke))},"R"),e[16]=k,e[17]=r,e[18]=R):R=e[18];let T=R,E;e[19]!==n||e[20]!==k||e[21]!==r?(E=l((B,U)=>{k(B==="others"?An(r,U):B==="right"?Dn(r,U,n):Mn(ke))},"_"),e[19]=n,e[20]=k,e[21]=r,e[22]=E):E=e[22];let I=E,O;e[23]!==I||e[24]!==d||e[25]!==r?(O=l(B=>{d!==null&&($n(B,r,d.id).some(Bn)?g(B):I(B,d.id))},"A"),e[23]=I,e[24]=d,e[25]=r,e[26]=O):O=e[26];let A=O,L;e[27]===Symbol.for("react.memo_cache_sentinel")?(L=l((B,U)=>{U.preventDefault(),g(null),h({id:B,x:U.clientX,y:U.clientY})},"I"),e[27]=L):L=e[27];let F=L,M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=l(()=>{h(null),g(null)},"D"),e[28]=M):M=e[28];let H=M,D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=l(B=>{B.preventDefault(),h(null),g(null)},"O"),e[29]=D):D=e[29];let C=D,P;e[30]!==A?(P=l(()=>{A("others")},"F"),e[30]=A,e[31]=P):P=e[31];let _=P,$;e[32]!==A?($=l(()=>{A("right")},"M"),e[32]=A,e[33]=$):$=e[33];let W=$,z;e[34]!==A?(z=l(()=>{A("all")},"$"),e[34]=A,e[35]=z):z=e[35];let J=z,Z;e[36]!==I||e[37]!==b||e[38]!==d?(Z=l(()=>{d!==null&&b!==null&&I(b,d.id),g(null)},"Z"),e[36]=I,e[37]=b,e[38]=d,e[39]=Z):Z=e[39];let ee=Z,te;e[40]===Symbol.for("react.memo_cache_sentinel")?(te=l(()=>{g(null)},"te"),e[40]=te):te=e[40];let ie=te,V;e[41]!==d?(V=d===null?void 0:{left:d.x,top:d.y},e[41]=d,e[42]=V):V=e[42];let Q=V,ne;e[43]!==o?(ne=l(B=>{o(U=>U.map(Y=>Y.activeId===B?{...Y,activeId:null}:Y))},"ne"),e[43]=o,e[44]=ne):ne=e[44];let re=ne,oe;e[45]!==o?(oe=l((B,U)=>{o(Y=>Y.map(X=>X.id===B?{...X,name:U}:X))},"oe"),e[45]=o,e[46]=oe):oe=e[46];let se=oe,le;return e[47]!==m||e[48]!==n||e[49]!==p||e[50]!==T||e[51]!==ee||e[52]!==J||e[53]!==_||e[54]!==W||e[55]!==S||e[56]!==q||e[57]!==y||e[58]!==b||e[59]!==se||e[60]!==t||e[61]!==d||e[62]!==Q||e[63]!==r||e[64]!==re?(le={activeTab:m,activeTabId:n,addEditorTab:p,cancelBulk:ie,closeEditorTab:T,closeTabMenu:H,confirmBulk:ee,menuStyle:Q,onBackdropContextMenu:C,onCloseAll:J,onCloseOthers:_,onCloseToRight:W,openTabMenu:F,output:S,patchActiveOutput:q,patchActiveTab:y,pendingBulk:b,renameTab:se,setActiveTabId:t,tabMenu:d,tabs:r,unlinkQuery:re},e[47]=m,e[48]=n,e[49]=p,e[50]=T,e[51]=ee,e[52]=J,e[53]=_,e[54]=W,e[55]=S,e[56]=q,e[57]=y,e[58]=b,e[59]=se,e[60]=t,e[61]=d,e[62]=Q,e[63]=r,e[64]=re,e[65]=le):le=e[65],le},"Pn");function zn(s){return s.id}l(zn,"Fn");function Bn(s){return xt(s)}l(Bn,"Wn");var Hn="lunora-studio-sql-queries",we="lunora-studio-sql-history",Pn="lunora-studio-sql-remember-history",Qn=25,jn=l(s=>{let e=(0,G.c)(41),{loadIntoActiveTab:n,unlinkQuery:t}=s,o=ce(),[r,a]=Ee(Hn),[c,i]=Le(Pn,!1),[d,h]=Ee(we,c?"local":"session"),b,g;e[0]!==c?(b=l(()=>{c||Ce(we,"local")},"p"),g=[c],e[0]=c,e[1]=b,e[2]=g):(b=e[1],g=e[2]),(0,j.useEffect)(b,g);let[v,m]=(0,j.useState)(""),S=(0,j.useRef)(null),f;e[3]!==h?(f=l(_=>{h($=>$[0]?.sql===_?$:[{at:Date.now(),sql:_},...$.filter(W=>W.sql!==_)].slice(0,Qn))},"u"),e[3]=h,e[4]=f):f=e[4];let y=f,x;e[5]!==n||e[6]!==a||e[7]!==o?(x=l(()=>{let _={id:He("q"),name:o("Untitled query"),sql:""};a($=>[_,...$]),n("",_.id)},"g"),e[5]=n,e[6]=a,e[7]=o,e[8]=x):x=e[8];let q=x,w;e[9]!==n||e[10]!==r?(w=l(_=>{let $=r.find(W=>W.id===_);$!==void 0&&(n($.sql,_),S.current?.querySelector(`[data-testid="sql-query-${_}"]`)?.scrollIntoView({block:"nearest"}))},"y"),e[9]=n,e[10]=r,e[11]=w):w=e[11];let p=w,N;e[12]!==a||e[13]!==t?(N=l(_=>{a($=>$.filter(W=>W.id!==_)),t(_)},"E"),e[12]=a,e[13]=t,e[14]=N):N=e[14];let k=N,R;e[15]!==n?(R=l(_=>{n(_.currentTarget.dataset.sql??"",null)},"R"),e[15]=n,e[16]=R):R=e[16];let T=R,E;e[17]!==n?(E=l(_=>{n(_.currentTarget.dataset.sql??"",null)},"_"),e[17]=n,e[18]=E):E=e[18];let I=E,O;e[19]!==h?(O=l(()=>{h([]),Ce(we,"local"),Ce(we,"session")},"A"),e[19]=h,e[20]=O):O=e[20];let A=O,L;e[21]!==d||e[22]!==i?(L=l(_=>{Ke(we,d,_?"local":"session"),_||Ce(we,"local"),i(_)},"I"),e[21]=d,e[22]=i,e[23]=L):L=e[23];let F=L,M;e[24]===Symbol.for("react.memo_cache_sentinel")?(M=l(_=>{m(_.target.value)},"D"),e[24]=M):M=e[24];let H=M,D;e[25]!==a?(D=l((_,$)=>{a(W=>W.map(z=>z.id===_?{...z,sql:$}:z))},"O"),e[25]=a,e[26]=D):D=e[26];let C=D,P;return e[27]!==A||e[28]!==k||e[29]!==d||e[30]!==I||e[31]!==T||e[32]!==q||e[33]!==r||e[34]!==y||e[35]!==c||e[36]!==v||e[37]!==p||e[38]!==F||e[39]!==C?(P={clearHistory:A,deleteQuery:k,history:d,listRef:S,loadFromHistory:I,loadTemplate:T,newQuery:q,onSearchChange:H,queries:r,recordHistory:y,rememberHistory:c,search:v,selectQuery:p,setRememberHistory:F,updateQuerySql:C},e[27]=A,e[28]=k,e[29]=d,e[30]=I,e[31]=T,e[32]=q,e[33]=r,e[34]=y,e[35]=c,e[36]=v,e[37]=p,e[38]=F,e[39]=C,e[40]=P):P=e[40],P},"jn"),vt="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Wn=l((s,e)=>{let n=[];for(let o of s){if(o.offset===void 0||o.length===void 0||o.length<=0)continue;let r=Math.max(0,Math.min(o.offset,e)),a=Math.max(r,Math.min(o.offset+o.length,e));r!==a&&n.push({end:a,severity:o.severity,start:r})}n.sort((o,r)=>o.start-r.start);let t=[];for(let o of n)o.start>=(t.at(-1)?.end??0)&&t.push(o);return t},"Yn"),Un=l(s=>s==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":s==="empty-response"?"The model returned nothing usable.":"The model could not be reached.","Kn"),Yn=l(s=>{let e=(0,G.c)(51),{assistant:n,failed:t,onGenerated:o}=s,r=ce(),[a,c]=(0,j.useState)("");if(n.unavailable)return null;let i;e[0]!==n?(i=n.pending("sql"),e[0]=n,e[1]=i):i=e[1];let d=i,h;if(e[2]!==n||e[3]!==t||e[4]!==o||e[5]!==d||e[6]!==a||e[7]!==r){let b=n.reason("sql"),g;e[9]!==n||e[10]!==t||e[11]!==o||e[12]!==a?(g=l(I=>{let O=a.trim();O===""&&!I||ue((async()=>{let A=await n.generate(O===""?"fix the failing statement":O,I?t:void 0);A!==void 0&&o(A)})())},"m"),e[9]=n,e[10]=t,e[11]=o,e[12]=a,e[13]=g):g=e[13];let v=g,m;e[14]!==r?(m=r("Describe the query you want"),e[14]=r,e[15]=m):m=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=l(I=>{c(I.target.value)},"S"),e[16]=S):S=e[16];let f;e[17]!==v?(f=l(I=>{I.key==="Enter"&&(I.preventDefault(),v(!1))},"u"),e[17]=v,e[18]=f):f=e[18];let y;e[19]!==r?(y=r("Describe the query you want"),e[19]=r,e[20]=y):y=e[20];let x;e[21]!==d||e[22]!==a||e[23]!==m||e[24]!==f||e[25]!==y?(x=(0,u.jsx)(Ye,{"aria-label":m,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:d,onChange:S,onKeyDown:f,placeholder:y,value:a}),e[21]=d,e[22]=a,e[23]=m,e[24]=f,e[25]=y,e[26]=x):x=e[26];let q=d&&"opacity-60",w;e[27]!==q?(w=me("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",q),e[27]=q,e[28]=w):w=e[28];let p;e[29]!==d||e[30]!==a?(p=d||a.trim()==="",e[29]=d,e[30]=a,e[31]=p):p=e[31];let N;e[32]!==v?(N=l(()=>{v(!1)},"E"),e[32]=v,e[33]=N):N=e[33];let k;e[34]!==d||e[35]!==r?(k=r(d?"Thinking\u2026":"Draft SQL"),e[34]=d,e[35]=r,e[36]=k):k=e[36];let R;e[37]!==w||e[38]!==p||e[39]!==N||e[40]!==k?(R=(0,u.jsx)("button",{className:w,"data-testid":"sql-assistant-generate",disabled:p,onClick:N,type:"button",children:k}),e[37]=w,e[38]=p,e[39]=N,e[40]=k,e[41]=R):R=e[41];let T;e[42]!==t||e[43]!==d||e[44]!==v||e[45]!==r?(T=t!==void 0&&(0,u.jsx)("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:d,onClick:l(()=>{v(!0)},"onClick"),type:"button",children:r("Fix this")}),e[42]=t,e[43]=d,e[44]=v,e[45]=r,e[46]=T):T=e[46];let E;e[47]!==R||e[48]!==T||e[49]!==x?(E=(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[x,R,T]}),e[47]=R,e[48]=T,e[49]=x,e[50]=E):E=e[50],h=(0,u.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[E,b!==void 0&&(0,u.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Un(b)})]}),e[2]=n,e[3]=t,e[4]=o,e[5]=d,e[6]=a,e[7]=r,e[8]=h}else h=e[8];return h},"Gn"),Gn=l(s=>{let e=(0,G.c)(8),{diagnostics:n,draft:t,scrollRef:o}=s,r,a;if(e[0]!==n||e[1]!==t){a=Symbol.for("react.early_return_sentinel");e:{let d=Wn(n,t.length);if(d.length===0){a=null;break e}r=[];let h=0;for(let[b,g]of d.entries())g.start>h&&r.push(t.slice(h,g.start)),r.push((0,u.jsx)("span",{className:me("decoration-wavy underline underline-offset-4",g.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(g.start,g.end)},`${g.start.toString()}-${b.toString()}`)),h=g.end;r.push(t.slice(h))}e[0]=n,e[1]=t,e[2]=r,e[3]=a}else r=e[2],a=e[3];if(a!==Symbol.for("react.early_return_sentinel"))return a;let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=me("pointer-events-none absolute inset-0 overflow-hidden text-transparent",vt),e[4]=c):c=e[4];let i;return e[5]!==r||e[6]!==o?(i=(0,u.jsx)("div",{"aria-hidden":"true",className:c,"data-testid":"sql-diagnostics-overlay",ref:o,children:r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i},"Jn"),Kn={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Vn=l(s=>{let e=(0,G.c)(10),{diagnostics:n,onSelect:t}=s,o=ce();if(n.length===0)return null;let r;e[0]!==o?(r=o("SQL problems"),e[0]=o,e[1]=r):r=e[1];let a;if(e[2]!==n||e[3]!==t){let i;e[5]!==t?(i=l((d,h)=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:l(()=>{t(d)},"onClick"),type:"button",children:[(0,u.jsx)("span",{className:me("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",d.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:Kn[d.source]}),(0,u.jsx)("span",{className:"min-w-0 text-muted-foreground",children:d.message})]})},`${d.source}-${(d.offset??h).toString()}-${h.toString()}`),"a"),e[5]=t,e[6]=i):i=e[6],a=n.map(i),e[2]=n,e[3]=t,e[4]=a}else a=e[4];let c;return e[7]!==r||e[8]!==a?(c=(0,u.jsx)("ul",{"aria-label":r,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:a}),e[7]=r,e[8]=a,e[9]=c):c=e[9],c},"Xn"),Xn={minWidth:"2.75rem",paddingInline:"0.5rem"},Jn=l(s=>{let e=(0,G.c)(64),{assistant:n,autocomplete:t,diagnostics:o,draft:r,failed:a,handlers:c,editorRef:i,gutterRef:d,listboxId:h,onGenerated:b,onPickSuggestion:g,onRevealDiagnostic:v,overlayRef:m}=s,S=ce(),f,y,x,q,w,p,N,k;if(e[0]!==n||e[1]!==r||e[2]!==a||e[3]!==d||e[4]!==b){let P=r.split(`
|
|
7
|
+
`).length;N="flex min-h-0 min-w-0 flex-1 flex-col",e[13]!==n||e[14]!==a||e[15]!==b?(k=(0,u.jsx)(Yn,{assistant:n,failed:a,onGenerated:b}),e[13]=n,e[14]=a,e[15]=b,e[16]=k):k=e[16],p="flex min-h-0 min-w-0 flex-1",f="true",y="shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",x=d,q=Xn,w=Array.from({length:P},Zn),e[0]=n,e[1]=r,e[2]=a,e[3]=d,e[4]=b,e[5]=f,e[6]=y,e[7]=x,e[8]=q,e[9]=w,e[10]=p,e[11]=N,e[12]=k}else f=e[5],y=e[6],x=e[7],q=e[8],w=e[9],p=e[10],N=e[11],k=e[12];let R;e[17]!==f||e[18]!==y||e[19]!==x||e[20]!==q||e[21]!==w?(R=(0,u.jsx)("div",{"aria-hidden":f,className:y,ref:x,style:q,children:w}),e[17]=f,e[18]=y,e[19]=x,e[20]=q,e[21]=w,e[22]=R):R=e[22];let T;e[23]!==o||e[24]!==r||e[25]!==m?(T=(0,u.jsx)(Gn,{diagnostics:o,draft:r,scrollRef:m}),e[23]=o,e[24]=r,e[25]=m,e[26]=T):T=e[26];let E;e[27]!==t||e[28]!==h?(E=t===null?void 0:`${h}-opt-${t.active.toString()}`,e[27]=t,e[28]=h,e[29]=E):E=e[29];let I=t===null?void 0:h,O=t!==null,A;e[30]!==S?(A=S("SQL query"),e[30]=S,e[31]=A):A=e[31];let L;e[32]!==r||e[33]!==i||e[34]!==c.onBlur||e[35]!==c.onChange||e[36]!==c.onKeyDown||e[37]!==c.onScroll||e[38]!==c.onSelect||e[39]!==E||e[40]!==I||e[41]!==O||e[42]!==A?(L=(0,u.jsx)("textarea",{"aria-activedescendant":E,"aria-autocomplete":"list","aria-controls":I,"aria-expanded":O,"aria-label":A,className:`relative size-full resize-none bg-transparent outline-none ${vt}`,"data-testid":"sql-input",onBlur:c.onBlur,onChange:c.onChange,onKeyDown:c.onKeyDown,onScroll:c.onScroll,onSelect:c.onSelect,placeholder:"SELECT * FROM \u2026",ref:i,role:"combobox",spellCheck:!1,value:r}),e[32]=r,e[33]=i,e[34]=c.onBlur,e[35]=c.onChange,e[36]=c.onKeyDown,e[37]=c.onScroll,e[38]=c.onSelect,e[39]=E,e[40]=I,e[41]=O,e[42]=A,e[43]=L):L=e[43];let F;e[44]!==t||e[45]!==h||e[46]!==g?(F=(0,u.jsx)(wn,{listboxId:h,onPick:g,state:t}),e[44]=t,e[45]=h,e[46]=g,e[47]=F):F=e[47];let M;e[48]!==T||e[49]!==L||e[50]!==F?(M=(0,u.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[T,L,F]}),e[48]=T,e[49]=L,e[50]=F,e[51]=M):M=e[51];let H;e[52]!==M||e[53]!==p||e[54]!==R?(H=(0,u.jsxs)("div",{className:p,children:[R,M]}),e[52]=M,e[53]=p,e[54]=R,e[55]=H):H=e[55];let D;e[56]!==o||e[57]!==v?(D=(0,u.jsx)(Vn,{diagnostics:o,onSelect:v}),e[56]=o,e[57]=v,e[58]=D):D=e[58];let C;return e[59]!==H||e[60]!==D||e[61]!==N||e[62]!==k?(C=(0,u.jsxs)("div",{className:N,children:[k,H,D]}),e[59]=H,e[60]=D,e[61]=N,e[62]=k,e[63]=C):C=e[63],C},"es");function Zn(s,e){return(0,u.jsx)("div",{children:e+1},e)}l(Zn,"ts");var yt=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],er=l(s=>{let e=(0,G.c)(29),{active:n,onDelete:t,onSelect:o,query:r}=s,a=ce(),c;e[0]!==o||e[1]!==r.id?(c=l(()=>{o(r.id)},"c"),e[0]=o,e[1]=r.id,e[2]=c):c=e[2];let i=c,d;e[3]!==t||e[4]!==r.id?(d=l(N=>{N.stopPropagation(),t(r.id)},"i"),e[3]=t,e[4]=r.id,e[5]=d):d=e[5];let h=d,b=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",g;e[6]!==b?(g=me("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",b),e[6]=b,e[7]=g):g=e[7];let v=`sql-query-${r.id}`,m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=m):m=e[8];let S;e[9]!==r.name?(S=(0,u.jsx)("span",{className:"truncate",children:r.name}),e[9]=r.name,e[10]=S):S=e[10];let f;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==v||e[15]!==S?(f=(0,u.jsxs)("button",{"aria-pressed":n,className:g,"data-testid":v,onClick:i,type:"button",children:[m,S]}),e[11]=n,e[12]=i,e[13]=g,e[14]=v,e[15]=S,e[16]=f):f=e[16];let y;e[17]!==a?(y=a("Delete query"),e[17]=a,e[18]=y):y=e[18];let x;e[19]!==a?(x=a("Delete query"),e[19]=a,e[20]=x):x=e[20];let q;e[21]===Symbol.for("react.memo_cache_sentinel")?(q=(0,u.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,u.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=q):q=e[21];let w;e[22]!==h||e[23]!==x||e[24]!==y?(w=(0,u.jsx)("button",{"aria-label":y,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:h,title:x,type:"button",children:q}),e[22]=h,e[23]=x,e[24]=y,e[25]=w):w=e[25];let p;return e[26]!==w||e[27]!==f?(p=(0,u.jsxs)("li",{className:"group/q flex items-center",children:[f,w]}),e[26]=w,e[27]=f,e[28]=p):p=e[28],p},"ns"),it="sql-history-remember",tr=l((s,e)=>{let n=e.trim().toLowerCase();return n===""?[...s]:s.filter(t=>t.name.toLowerCase().includes(n))},"ss"),nr=l(s=>{let e=(0,G.c)(66),{activeId:n,history:t,listRef:o,onClearHistory:r,onDelete:a,onLoadHistory:c,onLoadTemplate:i,onNew:d,onSearchChange:h,onSelect:b,onToggleRememberHistory:g,queries:v,rememberHistory:m,search:S}=s,f=ce(),y,x,q,w,p;if(e[0]!==n||e[1]!==o||e[2]!==a||e[3]!==d||e[4]!==h||e[5]!==b||e[6]!==g||e[7]!==v||e[8]!==S||e[9]!==f){let L=tr(v,S),F;e[15]!==g?(F=l(z=>{g(z.target.checked)},"B"),e[15]=g,e[16]=F):F=e[16],y=F,q="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let M;e[17]!==f?(M=f("Search queries\u2026"),e[17]=f,e[18]=M):M=e[18];let H;e[19]!==h||e[20]!==S||e[21]!==M?(H=(0,u.jsx)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:h,placeholder:M,type:"text",value:S}),e[19]=h,e[20]=S,e[21]=M,e[22]=H):H=e[22];let D;e[23]!==f?(D=f("New query"),e[23]=f,e[24]=D):D=e[24];let C;e[25]!==f?(C=f("New query"),e[25]=f,e[26]=C):C=e[26];let P;e[27]===Symbol.for("react.memo_cache_sentinel")?(P=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[27]=P):P=e[27];let _;e[28]!==d||e[29]!==D||e[30]!==C?(_=(0,u.jsx)("button",{"aria-label":D,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:d,title:C,type:"button",children:P}),e[28]=d,e[29]=D,e[30]=C,e[31]=_):_=e[31],e[32]!==_||e[33]!==H?(w=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[H,_]}),e[32]=_,e[33]=H,e[34]=w):w=e[34],x="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let $;e[35]!==f?($=f("Private"),e[35]=f,e[36]=$):$=e[36];let W;e[37]!==$?(W=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),e[37]=$,e[38]=W):W=e[38],p=(0,u.jsxs)("div",{children:[W,L.length===0?(0,u.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:f("No saved queries yet \u2014 they save to this browser as you type.")}):(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:L.map(z=>(0,u.jsx)(er,{active:n===z.id,onDelete:a,onSelect:b,query:z},z.id))})]}),e[0]=n,e[1]=o,e[2]=a,e[3]=d,e[4]=h,e[5]=b,e[6]=g,e[7]=v,e[8]=S,e[9]=f,e[10]=y,e[11]=x,e[12]=q,e[13]=w,e[14]=p}else y=e[10],x=e[11],q=e[12],w=e[13],p=e[14];let N;e[39]!==f?(N=f("Reference"),e[39]=f,e[40]=N):N=e[40];let k;e[41]!==N?(k=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[41]=N,e[42]=k):k=e[42];let R;e[43]!==i?(R=yt.map(L=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":L.sql,onClick:i,type:"button",children:[(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),L.label]})},L.label)),e[43]=i,e[44]=R):R=e[44];let T;e[45]!==R?(T=(0,u.jsx)("ul",{className:"flex flex-col gap-px",children:R}),e[45]=R,e[46]=T):T=e[46];let E;e[47]!==k||e[48]!==T?(E=(0,u.jsxs)("div",{children:[k,T]}),e[47]=k,e[48]=T,e[49]=E):E=e[49];let I;e[50]!==t||e[51]!==r||e[52]!==c||e[53]!==y||e[54]!==m||e[55]!==f?(I=t.length>0&&(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,u.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f("History")}),(0,u.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:r,type:"button",children:f("Clear history")})]}),(0,u.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 pb-1.5 text-[11px] text-muted-foreground",htmlFor:it,children:[(0,u.jsx)("input",{checked:m,"data-testid":"sql-history-remember",id:it,onChange:y,type:"checkbox"}),f("Keep history on this browser")]}),(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(L=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":L.sql,"data-testid":"sql-history-item",onClick:c,title:L.sql,type:"button",children:[(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,u.jsx)("span",{className:"truncate font-mono",children:L.sql})]})},`${L.at.toString()}:${L.sql}`))})]}),e[50]=t,e[51]=r,e[52]=c,e[53]=y,e[54]=m,e[55]=f,e[56]=I):I=e[56];let O;e[57]!==x||e[58]!==I||e[59]!==p||e[60]!==E?(O=(0,u.jsxs)("div",{className:x,children:[p,E,I]}),e[57]=x,e[58]=I,e[59]=p,e[60]=E,e[61]=O):O=e[61];let A;return e[62]!==O||e[63]!==q||e[64]!==w?(A=(0,u.jsxs)("aside",{className:q,children:[w,O]}),e[62]=O,e[63]=q,e[64]=w,e[65]=A):A=e[65],A},"os"),Ae=l(s=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${s?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"Ie"),rr=l(s=>{let e=(0,G.c)(96),{assistant:n,chart:t,className:o,error:r,onFormat:a,onInferChart:c,onRun:i,onSelectStatement:d,onShardKeyChange:h,onShowChart:b,onShowExplain:g,onShowResults:v,onToggleSplit:m,pane:S,result:f,running:y,script:x,shardKey:q,splitView:w}=s,p=ce(),N=S==="results",k;e[0]!==N?(k=Ae(N),e[0]=N,e[1]=k):k=e[1];let R;e[2]!==p?(R=p("Results"),e[2]=p,e[3]=R):R=e[3];let T;e[4]!==v||e[5]!==k||e[6]!==R?(T=(0,u.jsx)("button",{className:k,"data-testid":"sql-tab-results",onClick:v,type:"button",children:R}),e[4]=v,e[5]=k,e[6]=R,e[7]=T):T=e[7];let E=S==="chart",I;e[8]!==E?(I=Ae(E),e[8]=E,e[9]=I):I=e[9];let O;e[10]!==p?(O=p("Chart"),e[10]=p,e[11]=O):O=e[11];let A;e[12]!==b||e[13]!==I||e[14]!==O?(A=(0,u.jsx)("button",{className:I,"data-testid":"sql-tab-chart",onClick:b,type:"button",children:O}),e[12]=b,e[13]=I,e[14]=O,e[15]=A):A=e[15];let L;e[16]!==n||e[17]!==c||e[18]!==S||e[19]!==f||e[20]!==p?(L=!n.unavailable&&S==="chart"&&f!==null&&(0,u.jsx)("button",{className:Ae(!1),"data-testid":"sql-infer-chart",disabled:n.pending("chart"),onClick:c,type:"button",children:n.pending("chart")?p("Thinking\u2026"):p("Suggest chart")}),e[16]=n,e[17]=c,e[18]=S,e[19]=f,e[20]=p,e[21]=L):L=e[21];let F=S==="explain",M;e[22]!==F?(M=Ae(F),e[22]=F,e[23]=M):M=e[23];let H;e[24]!==p?(H=p("Explain"),e[24]=p,e[25]=H):H=e[25];let D;e[26]!==g||e[27]!==M||e[28]!==H?(D=(0,u.jsx)("button",{className:M,"data-testid":"sql-tab-explain",onClick:g,type:"button",children:H}),e[26]=g,e[27]=M,e[28]=H,e[29]=D):D=e[29];let C;e[30]!==p?(C=p("Split editor and results"),e[30]=p,e[31]=C):C=e[31];let P=`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${w?"bg-accent text-foreground":"text-muted-foreground"}`,_;e[32]!==p?(_=p("Split editor and results"),e[32]=p,e[33]=_):_=e[33];let $;e[34]===Symbol.for("react.memo_cache_sentinel")?($=(0,u.jsxs)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[(0,u.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,u.jsx)("path",{d:"M12 4v16"})]}),e[34]=$):$=e[34];let W;e[35]!==m||e[36]!==w||e[37]!==C||e[38]!==P||e[39]!==_?(W=(0,u.jsx)("button",{"aria-label":C,"aria-pressed":w,className:P,"data-testid":"sql-split-toggle",onClick:m,title:_,type:"button",children:$}),e[35]=m,e[36]=w,e[37]=C,e[38]=P,e[39]=_,e[40]=W):W=e[40];let z;e[41]!==f?(z=f!==null&&f.columns.length>0&&(0,u.jsx)(tt,{columns:f.columns,name:"query-result",rows:f.rows}),e[41]=f,e[42]=z):z=e[42];let J;e[43]!==p?(J=p("Format"),e[43]=p,e[44]=J):J=e[44];let Z;e[45]!==a||e[46]!==y||e[47]!==J?(Z=(0,u.jsx)("button",{className:"inline-flex items-center 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","data-testid":"sql-format",disabled:y,onClick:a,type:"button",children:J}),e[45]=a,e[46]=y,e[47]=J,e[48]=Z):Z=e[48];let ee;e[49]!==h||e[50]!==q?(ee=(0,u.jsx)(Xe,{onChange:h,testId:"sql-shard-input",value:q}),e[49]=h,e[50]=q,e[51]=ee):ee=e[51];let te;e[52]!==y||e[53]!==p?(te=p(y?"Running\u2026":"Run"),e[52]=y,e[53]=p,e[54]=te):te=e[54];let ie;e[55]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,u.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"}),e[55]=ie):ie=e[55];let V;e[56]!==i||e[57]!==y||e[58]!==te?(V=(0,u.jsxs)("button",{className:"inline-flex items-center gap-1.5 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","data-testid":"sql-run",disabled:y,onClick:i,type:"button",children:[te,ie]}),e[56]=i,e[57]=y,e[58]=te,e[59]=V):V=e[59];let Q;e[60]!==W||e[61]!==z||e[62]!==Z||e[63]!==ee||e[64]!==V?(Q=(0,u.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[W,z,Z,ee,V]}),e[60]=W,e[61]=z,e[62]=Z,e[63]=ee,e[64]=V,e[65]=Q):Q=e[65];let ne;e[66]!==D||e[67]!==Q||e[68]!==T||e[69]!==A||e[70]!==L?(ne=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[T,A,L,D,Q]}),e[66]=D,e[67]=Q,e[68]=T,e[69]=A,e[70]=L,e[71]=ne):ne=e[71];let re;e[72]!==d||e[73]!==x?(re=x!==void 0&&(0,u.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-border px-3 py-1.5","data-testid":"sql-statements",children:x.runs.map((Y,X)=>(0,u.jsx)("button",{"aria-pressed":X===x.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${X===x.selected?"border-foreground text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${Y.error===null?"":"border-destructive/50 text-destructive"}`,"data-testid":`sql-statement-${X.toString()}`,onClick:l(()=>{d(X)},"onClick"),title:Y.sql,type:"button",children:X+1},`${X.toString()}:${Y.sql}`))}),e[72]=d,e[73]=x,e[74]=re):re=e[74];let oe;e[75]!==r?(oe=r!==null&&(0,u.jsx)(Je,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:r}),e[75]=r,e[76]=oe):oe=e[76];let se;e[77]!==r||e[78]!==f||e[79]!==p?(se=r===null&&f===null&&(0,u.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:p("Click Run to execute your query.")}),e[77]=r,e[78]=f,e[79]=p,e[80]=se):se=e[80];let le;e[81]!==t||e[82]!==r||e[83]!==S||e[84]!==f||e[85]!==p?(le=r===null&&f!==null&&(0,u.jsxs)("div",{"data-testid":"sql-result",children:[S==="chart"?(0,u.jsx)(nt,{axes:t,result:f}):(0,u.jsx)(rt,{result:f}),(0,u.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:f.truncated?p("Showing the first {max} of {count} rows.",{count:f.rowCount,max:f.rows.length}):p("{count} rows",{count:f.rowCount})})]}),e[81]=t,e[82]=r,e[83]=S,e[84]=f,e[85]=p,e[86]=le):le=e[86];let B;e[87]!==oe||e[88]!==se||e[89]!==le?(B=(0,u.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[oe,se,le]}),e[87]=oe,e[88]=se,e[89]=le,e[90]=B):B=e[90];let U;return e[91]!==o||e[92]!==ne||e[93]!==re||e[94]!==B?(U=(0,u.jsxs)("div",{className:o,children:[ne,re,B]}),e[91]=o,e[92]=ne,e[93]=re,e[94]=B,e[95]=U):U=e[95],U},"ls"),or=l((s,e)=>s.trim()===""?e:(s.split(`
|
|
8
|
+
`)[0]??s).slice(0,24),"rs"),sr=l(s=>{s?.focus(),s?.select()},"is"),lr=l(s=>{let e=(0,G.c)(14),{initial:n,onCancel:t,onCommit:o,placeholder:r,testId:a}=s,c=ce(),i;e[0]!==o?(i=l(m=>{o(m.currentTarget.value.trim())},"a"),e[0]=o,e[1]=i):i=e[1];let d=i,h;e[2]!==t||e[3]!==o?(h=l(m=>{m.key==="Enter"?o(m.currentTarget.value.trim()):m.key==="Escape"&&t()},"f"),e[2]=t,e[3]=o,e[4]=h):h=e[4];let b=h,g;e[5]!==c?(g=c("Tab title"),e[5]=c,e[6]=g):g=e[6];let v;return e[7]!==n||e[8]!==d||e[9]!==b||e[10]!==r||e[11]!==g||e[12]!==a?(v=(0,u.jsx)("input",{"aria-label":g,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":a,defaultValue:n,onBlur:d,onKeyDown:b,placeholder:r,ref:sr,type:"text"}),e[7]=n,e[8]=d,e[9]=b,e[10]=r,e[11]=g,e[12]=a,e[13]=v):v=e[13],v},"as"),ar=l(s=>{let e=(0,G.c)(29),{idBase:n,onDiscard:t,onKeep:o}=s,r=ce(),a=`sql-tab-close-prompt-${n}`,c;e[0]!==r?(c=r("Discard?"),e[0]=r,e[1]=c):c=e[1];let i;e[2]!==c?(i=(0,u.jsx)("span",{className:"text-[11px] text-muted-foreground",children:c}),e[2]=c,e[3]=i):i=e[3];let d;e[4]!==r?(d=r("Discard changes"),e[4]=r,e[5]=d):d=e[5];let h=`sql-tab-close-confirm-${n}`,b;e[6]!==r?(b=r("Discard changes"),e[6]=r,e[7]=b):b=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=g):g=e[8];let v;e[9]!==t||e[10]!==d||e[11]!==h||e[12]!==b?(v=(0,u.jsx)("button",{"aria-label":d,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":h,onClick:t,title:b,type:"button",children:g}),e[9]=t,e[10]=d,e[11]=h,e[12]=b,e[13]=v):v=e[13];let m;e[14]!==r?(m=r("Keep editing"),e[14]=r,e[15]=m):m=e[15];let S=`sql-tab-close-cancel-${n}`,f;e[16]!==r?(f=r("Keep editing"),e[16]=r,e[17]=f):f=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=y):y=e[18];let x;e[19]!==o||e[20]!==S||e[21]!==f||e[22]!==m?(x=(0,u.jsx)("button",{"aria-label":m,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":S,onClick:o,title:f,type:"button",children:y}),e[19]=o,e[20]=S,e[21]=f,e[22]=m,e[23]=x):x=e[23];let q;return e[24]!==a||e[25]!==x||e[26]!==i||e[27]!==v?(q=(0,u.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":a,role:"group",children:[i,v,x]}),e[24]=a,e[25]=x,e[26]=i,e[27]=v,e[28]=q):q=e[28],q},"cs"),ir=l(s=>{let e=(0,G.c)(47),{active:n,canClose:t,onClose:o,onMenu:r,onRename:a,onSelect:c,tab:i}=s,d=ce(),[h,b]=(0,j.useState)(!1),[g,v]=(0,j.useState)(!1),m;e[0]!==r||e[1]!==i.id?(m=l(z=>{r(i.id,z)},"d"),e[0]=r,e[1]=i.id,e[2]=m):m=e[2];let S=m,f;e[3]!==c||e[4]!==i.id?(f=l(()=>{c(i.id)},"u"),e[3]=c,e[4]=i.id,e[5]=f):f=e[5];let y=f,x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=l(()=>{b(!0)},"g"),e[6]=x):x=e[6];let q=x,w;e[7]!==o||e[8]!==i?(w=l(z=>{z.stopPropagation(),xt(i)?v(!0):o(i.id)},"y"),e[7]=o,e[8]=i,e[9]=w):w=e[9];let p=w,N;e[10]!==o||e[11]!==i.id?(N=l(z=>{z.stopPropagation(),v(!1),o(i.id)},"E"),e[10]=o,e[11]=i.id,e[12]=N):N=e[12];let k=N,R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=l(z=>{z.stopPropagation(),v(!1)},"R"),e[13]=R):R=e[13];let T=R,E;e[14]!==a||e[15]!==i.id?(E=l(z=>{a(i.id,z),b(!1)},"_"),e[14]=a,e[15]=i.id,e[16]=E):E=e[16];let I=E,O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O=l(()=>{b(!1)},"A"),e[17]=O):O=e[17];let A=O,L;e[18]!==i.name?(L=i.name.trim(),e[18]=i.name,e[19]=L):L=e[19];let F=L,M;e[20]!==d||e[21]!==i.sql?(M=or(i.sql,d("Untitled")),e[20]=d,e[21]=i.sql,e[22]=M):M=e[22];let H=M,D=n?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",C;e[23]!==D?(C=me("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",D),e[23]=D,e[24]=C):C=e[24];let P=`sql-tab-${i.id}`,_;e[25]!==n||e[26]!==I||e[27]!==F||e[28]!==H||e[29]!==h||e[30]!==y||e[31]!==d||e[32]!==i.id?(_=h?(0,u.jsx)(lr,{initial:F,onCancel:A,onCommit:I,placeholder:H,testId:`sql-tab-rename-${i.id}`}):(0,u.jsx)("button",{"aria-pressed":n,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${i.id}`,onClick:y,onDoubleClick:q,title:d("Double-click to rename"),type:"button",children:F===""?H:F}),e[25]=n,e[26]=I,e[27]=F,e[28]=H,e[29]=h,e[30]=y,e[31]=d,e[32]=i.id,e[33]=_):_=e[33];let $;e[34]!==t||e[35]!==k||e[36]!==g||e[37]!==p||e[38]!==d||e[39]!==i.id?($=t&&(g?(0,u.jsx)(ar,{idBase:i.id,onDiscard:k,onKeep:T}):(0,u.jsx)("button",{"aria-label":d("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${i.id}`,onClick:p,title:d("Close tab"),type:"button",children:(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=k,e[36]=g,e[37]=p,e[38]=d,e[39]=i.id,e[40]=$):$=e[40];let W;return e[41]!==S||e[42]!==C||e[43]!==P||e[44]!==_||e[45]!==$?(W=(0,u.jsxs)("div",{className:C,"data-testid":P,onContextMenu:S,children:[_,$]}),e[41]=S,e[42]=C,e[43]=P,e[44]=_,e[45]=$,e[46]=W):W=e[46],W},"ds"),cr=l(s=>{let e=(0,G.c)(43),{model:n,onSelect:t}=s,o=ce(),{activeTab:r,addEditorTab:a,cancelBulk:c,closeEditorTab:i,closeTabMenu:d,confirmBulk:h,menuStyle:b,onBackdropContextMenu:g,onCloseAll:v,onCloseOthers:m,onCloseToRight:S,openTabMenu:f,pendingBulk:y,renameTab:x,tabMenu:q,tabs:w}=n,p;if(e[0]!==r||e[1]!==i||e[2]!==t||e[3]!==f||e[4]!==x||e[5]!==w){let L;e[7]!==r||e[8]!==i||e[9]!==t||e[10]!==f||e[11]!==x||e[12]!==w.length?(L=l(F=>(0,u.jsx)(ir,{active:F.id===r.id,canClose:w.length>1,onClose:i,onMenu:f,onRename:x,onSelect:t,tab:F},F.id),"I"),e[7]=r,e[8]=i,e[9]=t,e[10]=f,e[11]=x,e[12]=w.length,e[13]=L):L=e[13],p=w.map(L),e[0]=r,e[1]=i,e[2]=t,e[3]=f,e[4]=x,e[5]=w,e[6]=p}else p=e[6];let N;e[14]!==o?(N=o("New tab"),e[14]=o,e[15]=N):N=e[15];let k=w.length>=We,R;e[16]!==o?(R=o("New tab"),e[16]=o,e[17]=R):R=e[17];let T;e[18]===Symbol.for("react.memo_cache_sentinel")?(T=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[18]=T):T=e[18];let E;e[19]!==a||e[20]!==N||e[21]!==k||e[22]!==R?(E=(0,u.jsx)("button",{"aria-label":N,className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:k,onClick:a,title:R,type:"button",children:T}),e[19]=a,e[20]=N,e[21]=k,e[22]=R,e[23]=E):E=e[23];let I;e[24]!==p||e[25]!==E?(I=(0,u.jsxs)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[p,E]}),e[24]=p,e[25]=E,e[26]=I):I=e[26];let O;e[27]!==c||e[28]!==d||e[29]!==h||e[30]!==b||e[31]!==g||e[32]!==v||e[33]!==m||e[34]!==S||e[35]!==y||e[36]!==o||e[37]!==q||e[38]!==w?(O=q!==null&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:d,onContextMenu:g,role:"presentation"}),(0,u.jsx)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:b,children:y===null?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:w.length<=1,onClick:m,role:"menuitem",type:"button",children:o("Close other tabs")}),(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:w.findIndex(L=>L.id===q.id)>=w.length-1,onClick:S,role:"menuitem",type:"button",children:o("Close tabs to the right")}),(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:v,role:"menuitem",type:"button",children:o("Close all tabs")})]}):(0,u.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,u.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")}),(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,u.jsx)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:h,type:"button",children:o("Discard")}),(0,u.jsx)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:c,type:"button",children:o("Cancel")})]})]})})]}),e[27]=c,e[28]=d,e[29]=h,e[30]=b,e[31]=g,e[32]=v,e[33]=m,e[34]=S,e[35]=y,e[36]=o,e[37]=q,e[38]=w,e[39]=O):O=e[39];let A;return e[40]!==I||e[41]!==O?(A=(0,u.jsxs)(u.Fragment,{children:[I,O]}),e[40]=I,e[41]=O,e[42]=A):A=e[42],A},"us"),dr=Se(qe.runSql),ur="lunora-studio-sql-split-view",mr=l(()=>ke(yt[0]?.sql??""),"hs"),Tr=l(s=>{let e=(0,G.c)(112),{initialShardKey:n}=s,t=Ie(),o=Fn(mr),{activeTab:r,output:a,patchActiveOutput:c,patchActiveTab:i,setActiveTabId:d,unlinkQuery:h}=o,b;e[0]!==c||e[1]!==i?(b=l((K,ae)=>{i({activeId:ae,sql:K}),c({chart:void 0,error:null,failed:void 0,result:null,script:void 0})},"p"),e[0]=c,e[1]=i,e[2]=b):b=e[2];let g=b,v;e[3]!==g||e[4]!==h?(v={loadIntoActiveTab:g,unlinkQuery:h},e[3]=g,e[4]=h,e[5]=v):v=e[5];let m=jn(v),{recordHistory:S,updateQuerySql:f}=m,y=r.sql,{activeId:x}=r,{chart:q,error:w,failed:p,result:N,running:k}=a,R=a.pane,[T,E]=(0,j.useState)(n??""),[I,O]=Le(ur,!1),{probe:A,schema:L}=qn(T),F;e[6]!==x||e[7]!==i||e[8]!==f?(F=l(K=>{i({sql:K}),x!==null&&f(x,K)},"B"),e[6]=x,e[7]=i,e[8]=f,e[9]=F):F=e[9];let M=F,H=an(y,L,T),D=et(T),C;e[10]!==D||e[11]!==c||e[12]!==N?(C=l(()=>{N!==null&&ue((async()=>{let K=await D.inferChart({columns:N.columns,rowCount:N.rowCount,types:Object.fromEntries(N.columns.map(ae=>[ae,typeof(N.rows[0]?.[ae]??"")]))});c({chart:K})})())},"k"),e[10]=D,e[11]=c,e[12]=N,e[13]=C):C=e[13];let P=C,_;e[14]!==t||e[15]!==S||e[16]!==T?(_=l(async K=>{try{let ae=await t.query(dr,{sql:K},Ne(T));return S(K),{error:null,result:ae,sql:K}}catch(ae){return{error:Ge(ae),result:null,sql:K}}},"L"),e[14]=t,e[15]=S,e[16]=T,e[17]=_):_=e[17];let $=_,W;e[18]!==y||e[19]!==c||e[20]!==$||e[21]!==T?(W=l(async K=>{if(y.trim()==="")return;c({running:!0});let ae=K==="explain"?Qe(At(y),0):ft(y),de=[];for(let _e of ae){let wt={error:_e.rejection?.message??"",result:null,sql:_e.sql};de.push(_e.rejection===void 0?await $(_e.sql):wt)}Ve(T);let Ue=Math.max(de.length-1,0),ye=de[Ue];c({chart:void 0,error:ye?.error??null,failed:ye?.error===null||ye===void 0?void 0:{error:ye.error,sql:ye.sql},pane:K,result:ye?.result??null,running:!1,script:de.length>1?{runs:de,selected:Ue}:void 0})},"z"),e[18]=y,e[19]=c,e[20]=$,e[21]=T,e[22]=W):W=e[22];let z=W,J;e[23]!==a.script?.runs||e[24]!==c?(J=l(K=>{let ae=a.script?.runs,de=ae?.[K];ae===void 0||de===void 0||c({chart:void 0,error:de.error,failed:de.error===null?void 0:{error:de.error,sql:de.sql},result:de.result,script:{runs:ae,selected:K}})},"X"),e[23]=a.script?.runs,e[24]=c,e[25]=J):J=e[25];let Z=J,ee;e[26]!==z?(ee=l(()=>{ue(z("results"))},"ee"),e[26]=z,e[27]=ee):ee=e[27];let te=ee,ie;e[28]!==a.pane||e[29]!==z?(ie=l(()=>{ue(z(a.pane))},"ae"),e[28]=a.pane,e[29]=z,e[30]=ie):ie=e[30];let V;e[31]!==A||e[32]!==L||e[33]!==M||e[34]!==ie?(V={onSubmit:ie,probe:A,schema:L,setDraft:M},e[31]=A,e[32]=L,e[33]=M,e[34]=ie,e[35]=V):V=e[35];let Q=Tn(V),{closeAutocomplete:ne}=Q,re;e[36]!==y||e[37]!==M?(re=l(()=>{M(Bt(y))},"se"),e[36]=y,e[37]=M,e[38]=re):re=e[38];let oe=re,se;e[39]!==ne||e[40]!==d?(se=l(K=>{ne(),d(K)},"le"),e[39]=ne,e[40]=d,e[41]=se):se=e[41];let le=se,B;e[42]!==c?(B=l(()=>{c({pane:"results"})},"H"),e[42]=c,e[43]=B):B=e[43];let U=B,Y;e[44]!==z?(Y=l(()=>{ue(z("explain"))},"j"),e[44]=z,e[45]=Y):Y=e[45];let X=Y,fe;e[46]!==c?(fe=l(()=>{c({pane:"chart"})},"me"),e[46]=c,e[47]=fe):fe=e[47];let Me=fe,Te;e[48]!==O||e[49]!==I?(Te=l(()=>{O(!I)},"ke"),e[48]=O,e[49]=I,e[50]=Te):Te=e[50];let $e=Te,Fe=I?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",ze=I?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border",he;e[51]!==x||e[52]!==m.clearHistory||e[53]!==m.deleteQuery||e[54]!==m.history||e[55]!==m.listRef||e[56]!==m.loadFromHistory||e[57]!==m.loadTemplate||e[58]!==m.newQuery||e[59]!==m.onSearchChange||e[60]!==m.queries||e[61]!==m.rememberHistory||e[62]!==m.search||e[63]!==m.selectQuery||e[64]!==m.setRememberHistory?(he=(0,u.jsx)(nr,{activeId:x,history:m.history,listRef:m.listRef,onClearHistory:m.clearHistory,onDelete:m.deleteQuery,onLoadHistory:m.loadFromHistory,onLoadTemplate:m.loadTemplate,onNew:m.newQuery,onSearchChange:m.onSearchChange,onSelect:m.selectQuery,onToggleRememberHistory:m.setRememberHistory,queries:m.queries,rememberHistory:m.rememberHistory,search:m.search}),e[51]=x,e[52]=m.clearHistory,e[53]=m.deleteQuery,e[54]=m.history,e[55]=m.listRef,e[56]=m.loadFromHistory,e[57]=m.loadTemplate,e[58]=m.newQuery,e[59]=m.onSearchChange,e[60]=m.queries,e[61]=m.rememberHistory,e[62]=m.search,e[63]=m.selectQuery,e[64]=m.setRememberHistory,e[65]=he):he=e[65];let pe;e[66]!==o||e[67]!==le?(pe=(0,u.jsx)(cr,{model:o,onSelect:le}),e[66]=o,e[67]=le,e[68]=pe):pe=e[68];let be;e[69]!==D||e[70]!==H||e[71]!==y||e[72]!==p||e[73]!==M||e[74]!==Q.autocompleteState||e[75]!==Q.editorRef||e[76]!==Q.gutterRef||e[77]!==Q.handlers||e[78]!==Q.listboxId||e[79]!==Q.onPickSuggestion||e[80]!==Q.overlayRef||e[81]!==Q.revealDiagnostic?(be=(0,u.jsx)(Jn,{assistant:D,autocomplete:Q.autocompleteState,diagnostics:H,draft:y,editorRef:Q.editorRef,failed:p,gutterRef:Q.gutterRef,handlers:Q.handlers,listboxId:Q.listboxId,onGenerated:M,onPickSuggestion:Q.onPickSuggestion,onRevealDiagnostic:Q.revealDiagnostic,overlayRef:Q.overlayRef}),e[69]=D,e[70]=H,e[71]=y,e[72]=p,e[73]=M,e[74]=Q.autocompleteState,e[75]=Q.editorRef,e[76]=Q.gutterRef,e[77]=Q.handlers,e[78]=Q.listboxId,e[79]=Q.onPickSuggestion,e[80]=Q.overlayRef,e[81]=Q.revealDiagnostic,e[82]=be):be=e[82];let ge;e[83]!==D||e[84]!==w||e[85]!==oe||e[86]!==P||e[87]!==q||e[88]!==te||e[89]!==Z||e[90]!==a.script||e[91]!==N||e[92]!==ze||e[93]!==k||e[94]!==T||e[95]!==Me||e[96]!==X||e[97]!==U||e[98]!==I||e[99]!==R||e[100]!==$e?(ge=(0,u.jsx)(rr,{assistant:D,chart:q,className:ze,error:w,onFormat:oe,onInferChart:P,onRun:te,onSelectStatement:Z,onShardKeyChange:E,onShowChart:Me,onShowExplain:X,onShowResults:U,onToggleSplit:$e,pane:R,result:N,running:k,script:a.script,shardKey:T,splitView:I}),e[83]=D,e[84]=w,e[85]=oe,e[86]=P,e[87]=q,e[88]=te,e[89]=Z,e[90]=a.script,e[91]=N,e[92]=ze,e[93]=k,e[94]=T,e[95]=Me,e[96]=X,e[97]=U,e[98]=I,e[99]=R,e[100]=$e,e[101]=ge):ge=e[101];let xe;e[102]!==be||e[103]!==ge||e[104]!==Fe?(xe=(0,u.jsxs)("div",{className:Fe,children:[be,ge]}),e[102]=be,e[103]=ge,e[104]=Fe,e[105]=xe):xe=e[105];let ve;e[106]!==pe||e[107]!==xe?(ve=(0,u.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[pe,xe]}),e[106]=pe,e[107]=xe,e[108]=ve):ve=e[108];let Re;return e[109]!==he||e[110]!==ve?(Re=(0,u.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[he,ve]}),e[109]=he,e[110]=ve,e[111]=Re):Re=e[111],Re},"As");export{Tr as SqlEditorPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f}from"./chunk-IMOHEGMV.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as C}from"./chunk-PD6WIDY6.js";import{W as v}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as q}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as w}from"./chunk-4ZEL6BYL.js";import{f as L}from"./chunk-
|
|
1
|
+
import{a as f}from"./chunk-IMOHEGMV.js";import{a as j}from"./chunk-66UGPQVC.js";import{a as C}from"./chunk-PD6WIDY6.js";import{W as v}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as U}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as q}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as w}from"./chunk-4ZEL6BYL.js";import{f as L}from"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{d as P,f as y,g as p,h,o as u}from"./chunk-FODLDLE2.js";import{a as s,d as S,e as W,g as X}from"./chunk-YKXDMIHQ.js";var a=S(W(),1);var e=S(X(),1);var B=y(w.getPitrBookmark),Y=y(w.pitrRestore),de=s(({initialShardKey:z})=>{let m=L(),t=P(),o=z??"",[A,x]=(0,a.useState)(null),[l,O]=(0,a.useState)(""),[R,I]=(0,a.useState)(null),[c,D]=(0,a.useState)(""),[k,E]=(0,a.useState)(!1),[i,K]=(0,a.useState)(null),[T,n]=(0,a.useState)(null),[b,d]=(0,a.useState)(!1),g=(0,a.useCallback)(async()=>{d(!0),n(null);try{let r=await m.query(B,{},p(o));x(r.current)}catch(r){n(h(r))}d(!1)},[m,o]);(0,a.useEffect)(()=>{u(g())},[g]),j(()=>{u((async()=>{try{let r=await m.query(B,{},p(o));x(r.current)}catch{}})())},!0);let M=s(r=>{O(r.target.value)},"A"),Z=s(r=>{D(r.target.value)},"U"),_=s(r=>{E(r.target.checked)},"q"),G=s(()=>{l.trim()!==""&&u((async()=>{d(!0),n(null);try{let r=await m.query(B,{time:l.trim()},p(o));I(r.forTime??null),x(r.current)}catch(r){I(null),n(h(r))}d(!1)})())},"K"),F=s(r=>{u((async()=>{d(!0),n(null);try{let N=await m.mutation(Y,r,p(o));K(N),await g()}catch(N){n(h(N))}d(!1)})())},"C"),H=c.trim()!==""||l.trim()!=="",J=t("Restore {shard} to {target}?",{shard:o===""?t("root"):o,target:c.trim()===""?l.trim():t("the given bookmark")}),Q=s(()=>{let r=k?{restart:!0}:{};c.trim()===""?r.time=l.trim():r.bookmark=c.trim(),F(r)},"z"),V=s(()=>{i!==null&&F(k?{bookmark:i.undoBookmark,restart:!0}:{bookmark:i.undoBookmark})},"D");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[(0,e.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,e.jsxs)("span",{className:"text-xs text-muted-foreground",children:[t("Shard"),": ",(0,e.jsx)("span",{className:"font-mono",children:o===""?t("root"):o})]})}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),T!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:T}),(0,e.jsxs)("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"mb-2 text-sm font-semibold",children:t("Current bookmark")}),(0,e.jsx)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:A??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]}),(0,e.jsxs)("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:t("Restore")}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-time",children:t("Time (ISO or epoch-ms, last 30 days)")}),(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)(v,{"data-testid":"pitr-time",id:"pitr-time",onChange:M,placeholder:"2026-06-01T00:00:00.000Z",value:l}),(0,e.jsx)(U,{"data-testid":"pitr-preview",disabled:b||l.trim()==="",onClick:G,size:"sm",type:"button",variant:"outline",children:t("Preview")})]}),R!==null&&(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",R]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,e.jsx)(f,{htmlFor:"pitr-bookmark",children:t("Or an explicit bookmark (wins over time)")}),(0,e.jsx)(v,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Z,placeholder:t("bookmark string"),value:c})]}),(0,e.jsxs)(f,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[(0,e.jsx)("input",{checked:k,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:_,type:"checkbox"}),t("Restart the shard now so recovery applies immediately")]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:J,disabled:b||!H,onConfirm:Q,testId:"pitr-restore",children:t("Restore")})})]}),i!==null&&(0,e.jsxs)("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),(0,e.jsx)(q,{variant:i.restarted?"destructive":"secondary",children:i.restarted?t("restarted now"):t("on next restart")})]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",i.restoredTo]}),(0,e.jsxs)("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",i.undoBookmark]}),(0,e.jsx)("div",{children:(0,e.jsx)(C,{confirmLabel:t("Confirm undo"),disabled:b,onConfirm:V,testId:"pitr-undo",children:t("Undo restore")})})]})]})},"ce");export{de as PitrPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as j,c as v,d as D,f as g}from"./chunk-
|
|
1
|
+
import{b as j,c as v,d as D,f as g}from"./chunk-B6RRRJP5.js";import{f as S,g as w,h as P,o as q}from"./chunk-FODLDLE2.js";import{a as i,d as A,e as x,f as M}from"./chunk-YKXDMIHQ.js";var E=A(M(),1);var p=A(x(),1);var I=300,l=i(t=>typeof t=="string"?t===""?void 0:t:typeof t=="number"||typeof t=="boolean"?String(t):void 0,"a"),u=i(t=>t.filter(r=>r!==void 0).join(" "),"c"),T=i(t=>{let r=Array.isArray(t.filters)?t.filters.length:0,e=typeof t.search=="string"&&t.search!=="";return r===0&&!e?"no predicate":u([r===0?void 0:`${String(r)} filters`,e?"search":void 0])},"q"),N={clearTable:i(t=>u([l(t.table),"whole table"]),"clearTable"),deleteRows:i(t=>u([l(t.table),T(t)]),"deleteRows"),facetColumn:i(t=>u([l(t.table),l(t.column)]),"facetColumn"),importShard:i(t=>{if(!Array.isArray(t.rows))return"";let r=[...new Set(t.rows.filter(e=>typeof e=="object"&&e!==null).map(e=>e.table).filter(e=>typeof e=="string"))].toSorted((e,s)=>e.localeCompare(s));return u([`${String(t.rows.length)} rows`,r.length===0?void 0:`into ${r.join(", ")}`])},"importShard"),lintSql:i(()=>"sql","lintSql"),patchRows:i(t=>u([l(t.table),typeof t.doc=="object"&&t.doc!==null?`set ${Object.keys(t.doc).join(", ")}`:void 0,T(t)]),"patchRows"),pitrRestore:i(t=>u([l(t.time)===void 0?void 0:`to ${String(t.time)}`,typeof t.bookmark=="string"&&t.bookmark!==""?"from bookmark":void 0,t.restart===!0?"restart now":void 0]),"pitrRestore"),readTablePage:i(t=>u([l(t.table),Array.isArray(t.filters)&&t.filters.length>0?`${String(t.filters.length)} filters`:void 0,typeof t.search=="string"&&t.search!==""?"search":void 0,typeof t.limit=="number"?`limit ${String(t.limit)}`:void 0]),"readTablePage"),runMigration:i(t=>u([l(t.id),l(t.direction),t.dryRun===!0?"dry-run":void 0]),"runMigration"),runSql:i(t=>typeof t.sql=="string"?`${String(t.sql.length)} chars`:"","runSql"),schemaVersion:i(t=>typeof t.hash=="string"?t.hash.slice(0,8):"","schemaVersion"),writeRow:i(t=>u([l(t.table),"1 row"]),"writeRow")},$="__lunora_admin__:",F=i((t,r)=>{let e=t.startsWith($)?t.slice($.length):t,s=N[e];if(s!==void 0)return s(r);let n=Object.keys(r);return n.length===0?"":n.join(", ")},"M"),V=i(t=>{if(Array.isArray(t))return t.length;if(!(typeof t!="object"||t===null)){for(let r of Object.values(t))if(Array.isArray(r))return r.length}},"K"),k=class{static{i(this,"x")}entries=[];listeners=new Set;nextSeq=1;getSnapshot=i(()=>this.entries,"getSnapshot");subscribe=i(r=>(this.listeners.add(r),()=>{this.listeners.delete(r)}),"subscribe");start(r,e,s){return this.append(r,e,s,"call","pending")}startSubscription(r,e,s){return this.append(r,e,s,"subscription","live")}recordPush(r){if(this.listeners.size===0){let e=this.entries.find(s=>s.seq===r);e!==void 0&&(e.pushes=(e.pushes??0)+1);return}this.patch(r,e=>({...e,pushes:(e.pushes??0)+1}))}failSubscription(r,e){this.patch(r,s=>({...s,error:e,status:"error"}))}endSubscription(r){this.patch(r,e=>e.status==="error"?e:{...e,durationMs:Date.now()-e.startedAt,status:"closed"})}lastErrorSeq(){return this.entries.findLast(r=>r.status==="error")?.seq}settle(r,e){this.patch(r,s=>({...s,durationMs:Date.now()-s.startedAt,...e.error===void 0?{resultCount:V(e.result),status:"ok"}:{error:e.error,status:"error"}}))}clear(){this.entries=[],this.emit()}append(r,e,s,n,a){let d=this.nextSeq;this.nextSeq+=1;let c={functionPath:r,kind:n,seq:d,shardKey:s,startedAt:Date.now(),status:a,summary:F(r,e),...n==="subscription"?{pushes:0}:{}},o=[...this.entries,c];return this.entries=o.length>I?o.slice(o.length-I):o,this.emit(),d}patch(r,e){let s=this.entries.findIndex(n=>n.seq===r);s!==-1&&(this.entries=this.entries.with(s,e(this.entries[s])),this.emit())}emit(){for(let r of this.listeners)r()}},f=new k,_=i((t,r,e)=>["lunora-admin",t,r,e.trim()],"j"),O=i((t,r)=>[...t,r],"E");function W(t,r,e={}){let s=g(),{enabled:n=!0,keepPreviousData:a=!1,staleTime:d=0}=e,c=O(t,s.clientIdentifier()),o=D({enabled:n,queryFn:r,placeholderData:a?j:void 0,queryKey:c,staleTime:d});return{data:o.data,error:o.error?P(o.error):o.error,errorSource:o.error??void 0,isLoading:o.isLoading,liveError:void 0,refetch:i(()=>{q(o.refetch())},"refetch")}}i(W,"F");function Y(t,r,e={}){let s=g(),n=v(),{enabled:a=!0,keepPreviousData:d=!1,live:c=!1,shardKey:o="",staleTime:R}=e,m=_(t,r,o),C=W(m,()=>s.query(S(t),r,w(o)),{enabled:a,keepPreviousData:d,staleTime:R??(c?Number.POSITIVE_INFINITY:0)}),[K,b]=(0,p.useState)(void 0),L=JSON.stringify(m);return(0,p.useEffect)(()=>{if(!a||!c)return;b(void 0);let y=f.startSubscription(t,r,o),Q=s.subscribe(S(t),r,h=>{f.recordPush(y),b(void 0),n.setQueryData(O(m,s.clientIdentifier()),h)},{...w(o),onError:i(h=>{f.failSubscription(y,h.message),b(h.message)},"onError")});return()=>{f.endSubscription(y),Q()}},[s,L,a,c]),{...C,liveError:a&&c?K:void 0}}i(Y,"U");var B=i(()=>{let t=(0,E.c)(2),r=v(),e;return t[0]!==r?(e=i((s,n,a)=>{let d=n===void 0?["lunora-admin",s]:_(s,n,a??"");q(r.invalidateQueries({queryKey:d}))},"r"),t[0]=r,t[1]=e):e=t[1],e},"W");export{f as a,W as b,Y as c,B as d};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as $}from"./chunk-SDMSOWVM.js";import{a as b}from"./chunk-
|
|
1
|
+
import{a as $}from"./chunk-SDMSOWVM.js";import{a as b}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as u}from"./chunk-4ZEL6BYL.js";import{c as p}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as y,b as w,c as j,d as h,e as c,f as i}from"./chunk-HEAQVSNS.js";import{a as d,e as l}from"./chunk-WUWBZPUK.js";import{d as k}from"./chunk-FODLDLE2.js";import{a as o,d as I,g as T,i as x}from"./chunk-YKXDMIHQ.js";var e=I(T(),1);var m={clean:"text-emerald-600 dark:text-emerald-400",exempt:"text-muted-foreground",failing:"text-red-600 dark:text-red-400",warned:"text-amber-600 dark:text-amber-400"},A={"at-risk":"text-red-600 dark:text-red-400",excellent:"text-emerald-600 dark:text-emerald-400",good:"text-emerald-600 dark:text-emerald-400","needs-work":"text-amber-600 dark:text-amber-400"},C=o((r,a)=>`exempt: ${r.exemptReason===void 0||r.exemptReason===""?a:r.exemptReason}`,"E"),E=o(r=>r.toSorted((a,n)=>a.coverage==="clean"&&n.coverage!=="clean"?1:n.coverage==="clean"&&a.coverage!=="clean"?-1:a.score-n.score),"S"),Y=o(({testId:r="advisor-health"})=>{let a=k(),n=p(u.getAdvisories,{},{live:!0}),g=p(u.getAdvisorProcedures,{},{live:!0}),f=n.data?.advisories??null,N=g.data?.procedures??null,t=f===null||N===null?null:$(N,f),v=g.error??n.error;if(v!==null)return(0,e.jsx)(b,{error:v,testId:`${r}-error`});if(t===null)return(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"py-8 text-center text-muted-foreground","data-testid":`${r}-loading`,children:a("Loading\u2026")})});let R=E(t.procedures);return(0,e.jsxs)("div",{className:"space-y-4","data-testid":r,children:[(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"flex flex-wrap items-baseline gap-x-6 gap-y-2 py-6",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("span",{className:x("text-4xl font-semibold tabular-nums",A[t.grade]),"data-testid":`${r}-score`,children:t.score}),(0,e.jsx)("span",{className:"text-muted-foreground text-lg",children:"/100"})]}),(0,e.jsx)("span",{className:x("text-sm font-medium uppercase tracking-wide",A[t.grade]),"data-testid":`${r}-grade`,children:t.grade}),(0,e.jsxs)("div",{className:"text-muted-foreground flex gap-4 text-sm tabular-nums","data-testid":`${r}-summary`,children:[(0,e.jsxs)("span",{className:m.clean,children:[t.summary.clean," ",a("clean")]}),(0,e.jsxs)("span",{className:m.warned,children:[t.summary.warned," ",a("warned")]}),(0,e.jsxs)("span",{className:m.failing,children:[t.summary.failing," ",a("failing")]}),(0,e.jsxs)("span",{className:m.exempt,children:[t.summary.exempt," ",a("exempt")]})]})]})}),t.project.checks.length>0&&(0,e.jsx)(d,{children:(0,e.jsxs)(l,{className:"py-4 text-sm","data-testid":`${r}-project`,children:[(0,e.jsxs)("span",{className:"font-medium",children:[a("Schema & config")," ",t.project.score,"/100"]}),(0,e.jsxs)("span",{className:"text-muted-foreground",children:[" \u2014 ",t.project.checks.map(s=>s.name).join(", ")]})]})}),(0,e.jsx)(d,{children:(0,e.jsx)(l,{className:"p-0",children:(0,e.jsxs)(y,{children:[(0,e.jsx)(w,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(c,{className:"w-20",children:a("Score")}),(0,e.jsx)(c,{children:a("Procedure")}),(0,e.jsx)(c,{className:"w-32",children:a("Kind")}),(0,e.jsx)(c,{children:a("Rules fired")})]})}),(0,e.jsx)(j,{children:R.map(s=>(0,e.jsxs)(h,{"data-testid":`${r}-row`,children:[(0,e.jsx)(i,{className:x("tabular-nums font-medium",m[s.coverage]),children:s.coverage==="exempt"?"\u2014":s.score}),(0,e.jsx)(i,{className:"font-mono text-xs",children:s.id}),(0,e.jsxs)(i,{className:"text-muted-foreground text-xs",children:[s.visibility," ",s.kind,s.sensitivity.level==="high"&&(0,e.jsx)("span",{className:"ml-1 text-amber-600 dark:text-amber-400",children:a("sensitive")})]}),(0,e.jsx)(i,{className:"text-muted-foreground text-xs",children:s.coverage==="exempt"?C(s,a("no reason given")):s.checks.map(S=>S.name).join(", ")})]},s.id))})]})})})]})},"Y");export{Y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as J}from"./chunk-
|
|
1
|
+
import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as J}from"./chunk-ITMXIPQ7.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PZNTIBM.js";import"./chunk-35DM4JJG.js";import{a as H}from"./chunk-4ZEL6BYL.js";import{c as z}from"./chunk-SDHFSBNM.js";import"./chunk-B6RRRJP5.js";import"./chunk-FSRSK4LY.js";import"./chunk-2Y6PXGIS.js";import{a as E}from"./chunk-FKVZRPV5.js";import{a as G,b as M,c as U,d as P,e as d,f as c}from"./chunk-HEAQVSNS.js";import{a as D,e as _}from"./chunk-WUWBZPUK.js";import{d as q}from"./chunk-FODLDLE2.js";import{a as S,d as O,f as Q,g as V}from"./chunk-YKXDMIHQ.js";var L=O(Q(),1);var r=O(V(),1);var K=["read","insert","update","delete"],B=S((e,s)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[s],"z"),W=S(e=>{let s=new Map;for(let a of e){let t=s.get(a.table)??{operations:new Set,procedures:new Set,table:a.table};t.operations.add(a.on),t.procedures.add(a.procedure),s.set(a.table,t)}return[...s.values()].toSorted((a,t)=>a.table.localeCompare(t.table))},"J"),ie=S(()=>{let e=(0,L.c)(49),s=q(),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let{data:t,error:R,errorSource:k}=z(H.rlsPolicies,a),p=t!==void 0,m,n,h,l,f,u,x,b,o;if(e[1]!==t||e[2]!==R||e[3]!==k||e[4]!==p||e[5]!==s){let $=W(Array.isArray(t?.policies)?t.policies:[]),j;e[15]!==t?(j=Array.isArray(t?.roles)?t.roles:[],e[15]=t,e[16]=j):j=e[16],n=j,x="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==R||e[18]!==k?(o=R!==null&&(0,r.jsx)(J,{error:k,testId:"rls-error"}),e[17]=R,e[18]=k,e[19]=o):o=e[19],u="flex flex-col gap-2",m=D,h="overflow-hidden py-0";let I;e[20]!==s?(I=s("Policies"),e[20]=s,e[21]=I):I=e[21],e[22]!==I?(l=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:I})}),e[22]=I,e[23]=l):l=e[23],f=p&&$.length===0?(0,r.jsx)(E,{description:s("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:s("No policies defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-policies-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Table")}),K.map(i=>(0,r.jsx)(d,{children:B(s,i)},i)),(0,r.jsx)(d,{children:s("Guarded by")})]})}),(0,r.jsx)(U,{children:$.map(i=>(0,r.jsxs)(P,{"data-testid":`rls-table-${i.table}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:i.table}),K.map(F=>(0,r.jsx)(c,{children:i.operations.has(F)?(0,r.jsx)(C,{variant:"secondary",children:s("Guarded")}):(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"})},F)),(0,r.jsx)(c,{className:"font-mono text-xs text-muted-foreground",children:[...i.procedures].join(", ")})]},i.table))})]})}),e[1]=t,e[2]=R,e[3]=k,e[4]=p,e[5]=s,e[6]=m,e[7]=n,e[8]=h,e[9]=l,e[10]=f,e[11]=u,e[12]=x,e[13]=b,e[14]=o}else m=e[6],n=e[7],h=e[8],l=e[9],f=e[10],u=e[11],x=e[12],b=e[13],o=e[14];let N;e[24]!==m||e[25]!==h||e[26]!==l||e[27]!==f?(N=(0,r.jsxs)(m,{className:h,children:[l,f]}),e[24]=m,e[25]=h,e[26]=l,e[27]=f,e[28]=N):N=e[28];let g;e[29]!==u||e[30]!==N?(g=(0,r.jsx)("section",{className:u,children:N}),e[29]=u,e[30]=N,e[31]=g):g=e[31];let y;e[32]!==s?(y=s("Roles"),e[32]=s,e[33]=y):y=e[33];let w;e[34]!==y?(w=(0,r.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,r.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=w):w=e[35];let v;e[36]!==p||e[37]!==n||e[38]!==s?(v=p&&n.length===0?(0,r.jsx)(E,{description:s("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:s("No roles defined")}):(0,r.jsx)(_,{className:"px-0",children:(0,r.jsxs)(G,{"data-testid":"rls-roles-table",children:[(0,r.jsx)(M,{children:(0,r.jsxs)(P,{children:[(0,r.jsx)(d,{children:s("Role")}),(0,r.jsx)(d,{children:s("Description")}),(0,r.jsx)(d,{children:s("Permissions")})]})}),(0,r.jsx)(U,{children:n.map(Y)})]})}),e[36]=p,e[37]=n,e[38]=s,e[39]=v):v=e[39];let A;e[40]!==w||e[41]!==v?(A=(0,r.jsx)("section",{className:"flex flex-col gap-2",children:(0,r.jsxs)(D,{className:"overflow-hidden py-0",children:[w,v]})}),e[40]=w,e[41]=v,e[42]=A):A=e[42];let T;return e[43]!==A||e[44]!==x||e[45]!==b||e[46]!==o||e[47]!==g?(T=(0,r.jsxs)("div",{className:x,"data-testid":b,children:[o,g,A]}),e[43]=A,e[44]=x,e[45]=b,e[46]=o,e[47]=g,e[48]=T):T=e[48],T},"oe");function X(e){return(0,r.jsx)(C,{variant:"outline",children:e},e)}S(X,"K");function Y(e){return(0,r.jsxs)(P,{"data-testid":`rls-role-${e.name}`,children:[(0,r.jsx)(c,{className:"font-mono text-xs",children:e.name}),(0,r.jsx)(c,{className:"text-muted-foreground",children:e.description??""}),(0,r.jsx)(c,{children:e.permissions.length===0?(0,r.jsx)("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"\u2014"}):(0,r.jsx)("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(X)})})]},e.name)}S(Y,"V");export{ie as default};
|