@lunora/studio 1.0.0-alpha.145 → 1.0.0-alpha.147
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/mount.mjs +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ApiTab.mjs +1 -1
- package/dist/packem_chunks/AuditPanel.mjs +1 -1
- package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
- package/dist/packem_chunks/ExportImportPanel.mjs +3 -3
- package/dist/packem_chunks/FileBrowser.mjs +1 -1
- package/dist/packem_chunks/FunctionRunner.mjs +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
- package/dist/packem_chunks/HealthPanel.mjs +1 -1
- package/dist/packem_chunks/InsightsPanel.mjs +1 -1
- package/dist/packem_chunks/LogsPanel.mjs +1 -1
- package/dist/packem_chunks/MailPanel.mjs +1 -1
- package/dist/packem_chunks/MetricsPanel.mjs +1 -1
- package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
- package/dist/packem_chunks/PitrPanel.mjs +1 -1
- package/dist/packem_chunks/SchemaViewer.mjs +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
- package/dist/packem_chunks/SettingsPanel.mjs +1 -1
- package/dist/packem_chunks/SqlEditorPanel.mjs +7 -8
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/agents-panel.mjs +1 -1
- package/dist/packem_chunks/analytics-panel.mjs +1 -1
- package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
- package/dist/packem_chunks/auth-config-panel.mjs +1 -1
- package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
- package/dist/packem_chunks/containers-panel.mjs +1 -1
- package/dist/packem_chunks/dashboards-panel.mjs +1 -1
- package/dist/packem_chunks/evals-panel.mjs +1 -1
- package/dist/packem_chunks/fanout-panel.mjs +1 -1
- package/dist/packem_chunks/flags-panel.mjs +1 -1
- package/dist/packem_chunks/issues-panel.mjs +1 -1
- package/dist/packem_chunks/kv-browser.mjs +1 -1
- package/dist/packem_chunks/log-drains-panel.mjs +1 -1
- package/dist/packem_chunks/migrations-route.mjs +1 -1
- package/dist/packem_chunks/organizations-panel.mjs +1 -1
- package/dist/packem_chunks/payments-panel.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/queues-panel.mjs +1 -1
- package/dist/packem_chunks/reactors-panel.mjs +1 -1
- package/dist/packem_chunks/rls-panel.mjs +1 -1
- package/dist/packem_chunks/schedule-panel.mjs +1 -1
- package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
- package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
- package/dist/packem_chunks/sync-client-panel.mjs +1 -1
- package/dist/packem_chunks/traces-panel.mjs +1 -1
- package/dist/packem_chunks/users-panel.mjs +1 -1
- package/dist/packem_chunks/vector-browser.mjs +1 -1
- package/dist/packem_chunks/workflows-panel.mjs +1 -1
- package/dist/packem_shared/{ApiDocsPanel-CHCIjzZu.mjs → ApiDocsPanel-BImfQhyJ.mjs} +1 -1
- package/dist/packem_shared/{ApiReferencePanel-Cqy9Z7mO.mjs → ApiReferencePanel-B4i-KeOf.mjs} +1 -1
- package/dist/packem_shared/{CommandPalette-DtLEYVhX.mjs → CommandPalette-CSdz9zax.mjs} +1 -1
- package/dist/packem_shared/DataBrowser-Bpj-0P1G.mjs +4 -0
- package/dist/packem_shared/{GlobalDataBrowser-CDpzXZxj.mjs → GlobalDataBrowser-BTbqR6Wc.mjs} +1 -1
- package/dist/packem_shared/{HomePanel-4gpRjcch.mjs → HomePanel-_BwLI4TQ.mjs} +1 -1
- package/dist/packem_shared/{MigrationsPanel-Cz0x3Pv6.mjs → MigrationsPanel-BPWzFdxC.mjs} +1 -1
- package/dist/packem_shared/{OpenRpcReferencePanel-DZicbIOf.mjs → OpenRpcReferencePanel-BKJEX7we.mjs} +1 -1
- package/dist/packem_shared/{ScheduledJobs-BWziDVZO.mjs → ScheduledJobs-B4DPADwk.mjs} +1 -1
- package/dist/packem_shared/{Studio-C_yEjXcG.mjs → Studio-CcWQdYrV.mjs} +1 -1
- package/dist/packem_shared/{StudioApp-BQAxVB3v.mjs → StudioApp-B5jLGbeH.mjs} +1 -1
- package/dist/packem_shared/{advisor-view-DyXQCN4y.mjs → advisor-view-CPgOok_h.mjs} +1 -1
- package/dist/packem_shared/{data-grid-B8WGnT-5.mjs → data-grid-DTBAKZlm.mjs} +1 -1
- package/dist/packem_shared/{error-alert-ClpDVYvo.mjs → error-alert-tf5zvSLV.mjs} +1 -1
- package/dist/packem_shared/{grid-features-CGs2pKcr.mjs → grid-features-Dl7bCGRN.mjs} +4 -4
- package/dist/packem_shared/{home-panel-CHtt8k50.mjs → home-panel-DCUKd8Uk.mjs} +1 -1
- package/dist/packem_shared/internal-B6haJbiP.mjs +2 -0
- package/dist/packem_shared/{log-line-DpRfHaVQ.mjs → log-line-BoObzuue.mjs} +1 -1
- package/dist/packem_shared/{recording-client-CMvFFEC0.mjs → recording-client-BXUIyBL4.mjs} +1 -1
- package/dist/packem_shared/{reference-view-DS7FFPpP.mjs → reference-view-AC9FgXSz.mjs} +1 -1
- package/dist/packem_shared/{schema-diagram-C27ETi10.mjs → schema-diagram-CDj_69jF.mjs} +1 -1
- package/dist/packem_shared/{sql-result-table-BLIMecXM.mjs → sql-result-table-C5y0jwaK.mjs} +1 -1
- package/dist/packem_shared/{studio-DF0GqQBP.mjs → studio-OqNyRY1N.mjs} +1 -1
- package/dist/packem_shared/table-list-sidebar-DHG1UJC4.mjs +1 -0
- package/dist/packem_shared/{use-admin-query-BvZH4unR.mjs → use-admin-query-BKXiqLci.mjs} +1 -1
- package/dist/packem_shared/{use-async-submit-C1A11ka9.mjs → use-async-submit-BTr3w2-K.mjs} +1 -1
- package/dist/packem_shared/{use-auth-config-DocoJ5uQ.mjs → use-auth-config-BQKGdSFh.mjs} +1 -1
- package/dist/packem_shared/{use-open-trace-CTQIPjo9.mjs → use-open-trace-BCW0c9qq.mjs} +1 -1
- package/dist/packem_shared/{use-sql-assistant-BGoWYcGL.mjs → use-sql-assistant-BhIMDQHV.mjs} +1 -1
- package/dist/packem_shared/{wire-codec-BE-vgg1L.mjs → wire-codec-C0jSa3ZC.mjs} +1 -1
- package/dist/standalone/{chunk-6T3STPM7.js → chunk-2ES4GR4C.js} +1 -1
- package/dist/standalone/{chunk-HLE46T7J.js → chunk-2GPQJLCR.js} +1 -1
- package/dist/standalone/chunk-2GZVY7CX.js +1 -0
- package/dist/standalone/chunk-2LN3T5HY.js +15 -0
- package/dist/standalone/{chunk-5L3SHBMK.js → chunk-2LOBQ4CX.js} +1 -1
- package/dist/standalone/{chunk-E6LDY3TC.js → chunk-2Z5PSAHC.js} +1 -1
- package/dist/standalone/{chunk-3BFUVYWS.js → chunk-3CGQYQDZ.js} +1 -1
- package/dist/standalone/{chunk-UZ5QI3PB.js → chunk-3KDC7UYQ.js} +1 -1
- package/dist/standalone/{chunk-HQPQTWW4.js → chunk-4R6AMNIM.js} +1 -1
- package/dist/standalone/{chunk-XABVLLMA.js → chunk-4XIC6MLF.js} +1 -1
- package/dist/standalone/{chunk-RFTFYKFL.js → chunk-5EWLJXES.js} +1 -1
- package/dist/standalone/{chunk-PWHV7BUN.js → chunk-5K2UDZLN.js} +1 -1
- package/dist/standalone/{chunk-MHLBCDVW.js → chunk-5OFSVXDU.js} +1 -1
- package/dist/standalone/chunk-6DQKYWZI.js +1 -0
- package/dist/standalone/{chunk-6NO6WOSN.js → chunk-6UG4S7I7.js} +1 -1
- package/dist/standalone/chunk-7BRTPMJO.js +1 -0
- package/dist/standalone/{chunk-EDYGNYP2.js → chunk-7IY5BR52.js} +1 -1
- package/dist/standalone/{chunk-KLQEN4KA.js → chunk-A4UOWQOI.js} +1 -1
- package/dist/standalone/{chunk-5JEYBOS6.js → chunk-BOTGXX4H.js} +1 -1
- package/dist/standalone/{chunk-2KAH7DVZ.js → chunk-BVRZVNKL.js} +1 -1
- package/dist/standalone/{chunk-PEEGF7YA.js → chunk-CZY6LNTK.js} +2 -2
- package/dist/standalone/{chunk-CZU3LZ2O.js → chunk-DLT5B4TL.js} +1 -1
- package/dist/standalone/{chunk-L3JA4OKZ.js → chunk-DX6FAHR2.js} +1 -1
- package/dist/standalone/{chunk-IAWCSJRR.js → chunk-EERTS7JH.js} +1 -1
- package/dist/standalone/{chunk-SMVAE2AQ.js → chunk-EHSU2WDS.js} +1 -1
- package/dist/standalone/chunk-FIACUWE5.js +1 -0
- package/dist/standalone/{chunk-NXKPFGOP.js → chunk-FODLDLE2.js} +8 -8
- package/dist/standalone/{chunk-DDI4VSJH.js → chunk-GDB2JX2H.js} +1 -1
- package/dist/standalone/{chunk-MDVH5C5A.js → chunk-GIOZAYBS.js} +1 -1
- package/dist/standalone/{chunk-DMPVOWA7.js → chunk-GWW7SJR6.js} +1 -1
- package/dist/standalone/{chunk-IYYZMNOB.js → chunk-HR42URDR.js} +1 -1
- package/dist/standalone/{chunk-H3UCYGKY.js → chunk-HRYPE4NU.js} +1 -1
- package/dist/standalone/{chunk-E723DEAW.js → chunk-IABM4BFJ.js} +1 -1
- package/dist/standalone/{chunk-ZZENQM5W.js → chunk-INWAISDG.js} +4 -4
- package/dist/standalone/{chunk-VSHZE77Y.js → chunk-JAKYTDUH.js} +1 -1
- package/dist/standalone/chunk-JOYK6ITY.js +1 -0
- package/dist/standalone/{chunk-CIQRB2ET.js → chunk-JWPJS6AI.js} +1 -1
- package/dist/standalone/{chunk-JOQUDV7F.js → chunk-JY4ANRPG.js} +1 -1
- package/dist/standalone/{chunk-YL7OENDU.js → chunk-KCEVLJ65.js} +1 -1
- package/dist/standalone/{chunk-H5PZ7JXM.js → chunk-KJ4YYMID.js} +1 -1
- package/dist/standalone/{chunk-BQ4P3PLU.js → chunk-KQFH6FFC.js} +1 -1
- package/dist/standalone/{chunk-7B3OQXWL.js → chunk-LFDP6ANM.js} +1 -1
- package/dist/standalone/{chunk-MJG6GTPL.js → chunk-LJYUUOBB.js} +1 -1
- package/dist/standalone/{chunk-BN5TOI5O.js → chunk-LK4TLRSU.js} +1 -1
- package/dist/standalone/{chunk-AJQKSUVQ.js → chunk-MNGNHBOS.js} +1 -1
- package/dist/standalone/chunk-N74RUMRA.js +7 -0
- package/dist/standalone/{chunk-447V2Q3F.js → chunk-NZ57KZSG.js} +1 -1
- package/dist/standalone/{chunk-VXWAQW3F.js → chunk-OEVYSTUL.js} +1 -1
- package/dist/standalone/{chunk-JRN7SEJN.js → chunk-OSLV4PT6.js} +1 -1
- package/dist/standalone/chunk-PIGJKRDD.js +3 -0
- package/dist/standalone/{chunk-OUD7BAWE.js → chunk-PL664H45.js} +1 -1
- package/dist/standalone/{chunk-YWYJLVEP.js → chunk-QNSRFASE.js} +1 -1
- package/dist/standalone/{chunk-2IUHQB2Q.js → chunk-QYEQOTRN.js} +7 -8
- package/dist/standalone/{chunk-B5WPIRI3.js → chunk-R5QR5EZZ.js} +1 -1
- package/dist/standalone/{chunk-HDWOQTDN.js → chunk-RDYIEOYN.js} +1 -1
- package/dist/standalone/{chunk-GMEE5NFG.js → chunk-SLFPZM2C.js} +1 -1
- package/dist/standalone/{chunk-TWXJF4C2.js → chunk-SU737V7V.js} +1 -1
- package/dist/standalone/{chunk-EX33M5EE.js → chunk-T3VYCKM7.js} +1 -1
- package/dist/standalone/{chunk-3JV5F5SY.js → chunk-TIUMFAN2.js} +1 -1
- package/dist/standalone/{chunk-7MJY23GU.js → chunk-VGJ6HFCF.js} +1 -1
- package/dist/standalone/{chunk-JSXJND3V.js → chunk-VLCHF5SE.js} +1 -1
- package/dist/standalone/{chunk-CKKZCUAV.js → chunk-VWFNJLMK.js} +1 -1
- package/dist/standalone/{chunk-V5M356X3.js → chunk-VWXU7LIX.js} +1 -1
- package/dist/standalone/{chunk-2IRZXHAZ.js → chunk-WWXSQVPE.js} +1 -1
- package/dist/standalone/{chunk-RNZ7XXND.js → chunk-WXRI2LBR.js} +1 -1
- package/dist/standalone/{chunk-XGPF7VOP.js → chunk-XHM5CP2I.js} +1 -1
- package/dist/standalone/{chunk-IDB7SMQU.js → chunk-XVX3KH35.js} +1 -1
- package/dist/standalone/chunk-XZCNX7YU.js +11 -0
- package/dist/standalone/{chunk-VHMOFAJT.js → chunk-YCEVUCMI.js} +1 -1
- package/dist/standalone/{chunk-3DL3MLWV.js → chunk-ZLPC3XZF.js} +1 -1
- package/dist/standalone/chunk-ZTDD3M5D.js +1 -0
- package/dist/standalone/{chunk-46XX646F.js → chunk-ZYCM7BV2.js} +1 -1
- package/dist/standalone/studio.js +1 -1
- package/package.json +6 -6
- package/dist/packem_shared/DataBrowser-Bf32rBcr.mjs +0 -4
- package/dist/packem_shared/internal-D4gBuklE.mjs +0 -2
- package/dist/packem_shared/quote-identifier-CGiYFBvY.mjs +0 -1
- package/dist/packem_shared/table-list-sidebar-DKpSAP6p.mjs +0 -1
- package/dist/standalone/chunk-2L64LHIR.js +0 -1
- package/dist/standalone/chunk-3HEXTCWR.js +0 -1
- package/dist/standalone/chunk-5AUOM7FK.js +0 -1
- package/dist/standalone/chunk-FZKQX74O.js +0 -1
- package/dist/standalone/chunk-IB3MWLG4.js +0 -1
- package/dist/standalone/chunk-JMNCMGSE.js +0 -1
- package/dist/standalone/chunk-L2OWXMYF.js +0 -1
- package/dist/standalone/chunk-QPVND4TE.js +0 -3
- package/dist/standalone/chunk-RIO2HPN7.js +0 -15
- package/dist/standalone/chunk-UKQTCLDK.js +0 -7
- package/dist/standalone/chunk-W3Q32C24.js +0 -11
- /package/dist/standalone/{chunk-7AU5QSY7.js → chunk-LSWAITBZ.js} +0 -0
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import{a as rt,b as ot}from"./chunk-
|
|
2
|
-
|
|
3
|
-
`;)n+=1;return n},"qt"),Et=l((s,e)=>{let n=s.indexOf("*/",e+2);return n===-1?-1:n+2},"At"),ct=l(s=>{let e=s.split(""),n=0;for(;n<s.length;){let t=s[n]??"",o=It[t];if(t==="-"&&s[n+1]==="-"){let r=Rt(s,n);e.fill(je,n,r),n=r}else if(t==="/"&&s[n+1]==="*"){let r=Et(s,n);if(r===-1)return;e.fill(je,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(je,n,r+1),n=r+1}else n+=1}for(let t=0;t<s.length;t+=1)s[t]===`
|
|
1
|
+
import{a as rt,b as ot}from"./chunk-KCEVLJ65.js";import{c as nt}from"./chunk-INWAISDG.js";import{a as tt}from"./chunk-DLT5B4TL.js";import"./chunk-TJRQUJFS.js";import"./chunk-TWTNWOJU.js";import"./chunk-WQYWA7U6.js";import"./chunk-XZMOZFE6.js";import"./chunk-7RIRJD2P.js";import"./chunk-C3TOZ4LG.js";import"./chunk-D27D4UUI.js";import{a as et}from"./chunk-QKEJLVC5.js";import"./chunk-SB35BJ7A.js";import"./chunk-FO26ZU7E.js";import"./chunk-JAKYTDUH.js";import"./chunk-5JDWLCSH.js";import"./chunk-PYT4RZJH.js";import"./chunk-SU737V7V.js";import{a as Je}from"./chunk-IABM4BFJ.js";import{b as Xe}from"./chunk-OGUKYRFM.js";import{c as Ve,d as qe,e as Le,f as _e,g as Pe}from"./chunk-OKG3HWSJ.js";import{P as Ge}from"./chunk-46ZJ3TM4.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import"./chunk-EBWXFG4H.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import"./chunk-25NFR6EB.js";import{a as Ze}from"./chunk-ULIQFBZU.js";import{a as Ne}from"./chunk-4ZEL6BYL.js";import"./chunk-KQFH6FFC.js";import{f as Ee}from"./chunk-XZCNX7YU.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import"./chunk-HEAQVSNS.js";import{d as ce,f as we,g as ke,h as Ke,o as ue}from"./chunk-FODLDLE2.js";import{a as l,d as We,e as wt,f as kt,g as Nt,i as me}from"./chunk-YKXDMIHQ.js";var G=We(kt(),1);var z=We(wt(),1);var c=We(Nt(),1);var je="x",qt={'"':'"',"'":"'","[":"]","`":"`"},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=qt[t];if(t==="-"&&s[n+1]==="-"){let r=ct(s,n);e.fill(je,n,r),n=r}else if(t==="/"&&s[n+1]==="*"){let r=dt(s,n);if(r===-1)return;e.fill(je,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(je,n,r+1),n=r+1}else n+=1}for(let t=0;t<s.length;t+=1)s[t]===`
|
|
4
3
|
`&&(e[t]=`
|
|
5
|
-
`);return e.join("")},"
|
|
6
|
-
|
|
7
|
-
`,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},"zt"),zt=l(s=>{let e="",n=0;for(;n<s.length;){let t=Ft(s,n);t===-1?(e+=s.slice(n,n+1),n+=1):(e+=s.slice(n,t).replaceAll(Qt," "),n=t)}return e},"Yt"),Ut=l(s=>{let e=new Set;for(let n of s.matchAll(Pt))e.add((n[1]??"").toLowerCase());return e},"Kt"),Yt=l((s,e)=>{let n=new Map;for(let t of s.matchAll(Wt)){let o=(t[1]??"").toLowerCase(),r=(t[2]??"").toLowerCase();e.has(o)&&(n.set(o,o),r!==""&&!jt.has(r)&&n.set(r,o))}return n},"Gt"),ut=l((s,e)=>{let n=zt(s),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:Ut(n),masked:n,targets:Yt(n,t)}},"st"),Gt=/^(?:__lunora|sqlite_)/iu,Kt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Vt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Xt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Jt=l((s,e,n)=>{let t=[];for(let o of s.matchAll(Kt)){let r=o[1]??"",a=r.toLowerCase();!e.has(a)&&!n.has(a)&&!Xt.has(a)&&!Gt.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},"en"),Zt=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(d=>d.toLowerCase())));for(let r of s.matchAll(Vt)){let a=(r[1]??"").toLowerCase(),d=r[2]??"",i=n.get(a),u=i===void 0?void 0:o.get(i);u!==void 0&&!u.has(d.toLowerCase())&&t.push({length:d.length,message:`\`${i??""}\` has no column \`${d}\``,offset:r.index+r[0].length-d.length,severity:"error",source:"schema"})}return t},"tn"),en=l((s,e)=>{if(s.trim()==="")return[];let n=dt(s),t=new Set(e.tables.map(r=>r.toLowerCase())),o=[];for(let r of n){let{offset:a,rejection:d}=r;if(d!==void 0){d.code!=="SQL_EMPTY"&&o.push({length:d.length,message:d.message,offset:d.offset===void 0?a:a+d.offset,severity:"error",source:"gate"});continue}let{ctes:i,masked:u,targets:p}=ut(r.sql,e.tables);o.push(...[...Jt(u,t,i),...Zt(u,e,p)].map(h=>({...h,offset:h.offset===void 0?a:a+h.offset})))}return o},"nn"),tn=we(Ne.lintSql),nn=600,rn=l((s,e,n)=>{let t=Ee(),[o,r]=(0,z.useState)([]),a=(0,z.useMemo)(()=>en(s,e),[s,e]),d=et(s,nn),i=a.some(h=>h.source==="gate")||d.trim()==="",u=(0,z.useCallback)(async h=>{try{let g=await t.query(tn,{sql:d},ke(n));h.cancelled||r(g.diagnostics??[])}catch{h.cancelled||r([])}},[t,d,n]);(0,z.useEffect)(()=>{if(i){r([]);return}let h={cancelled:!1};return ue(u(h)),()=>{h.cancelled=!0}},[u,i]);let p=d===s;return(0,z.useMemo)(()=>p?[...a,...o]:a,[a,o,p])},"ln"),Oe=8,on=["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"],sn=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),ln=/[\w$]/,mt=l(s=>s!==void 0&&ln.test(s),"ot"),ft=l(s=>{let e=s.length;for(;e>0&&mt(s[e-1]);)e-=1;return s.slice(e)},"lt"),ht=l((s,e)=>{let n=e;for(;n>0&&mt(s[n-1]);)n-=1;return{end:e,start:n,text:s.slice(n,e)}},"rt"),st=l((s,e)=>{let n=s.slice(0,e).trimEnd();return n.endsWith(".")||sn.has(ft(n).toUpperCase())},"Je"),an=l((s,e,n)=>{let t=s.slice(0,e);if(!t.endsWith("."))return;let o=ft(t.slice(0,-1));if(o!=="")return ut(s,n).targets.get(o.toLowerCase())??o},"dn"),ze=l((s,e)=>s.toLowerCase().startsWith(e.toLowerCase()),"ze"),lt=l((s,e,n,t)=>{let o=[];for(let r of s)if(ze(r,e)&&(o.push(t(r)),o.length>=n))break;return o},"Ve"),cn=l((s,e,n)=>{let t=new Map;for(let[o,r]of Object.entries(s.columns))for(let a of r)if(ze(a,e)&&!t.has(a)&&(t.set(a,o),t.size>=n))return[...t].map(([d,i])=>({detail:i,kind:"column",label:d}));return[...t].map(([o,r])=>({detail:r,kind:"column",label:o}))},"un"),dn=l((s,e,n)=>{let t=ht(s,e),o=an(s,t.start,n.tables);if(o!==void 0){let i=n.columns[o]??n.columns[o.toLowerCase()]??[];return lt(i,t.text,Oe,u=>({detail:o,kind:"column",label:u}))}if(t.text===""&&!st(s,t.start))return[];let r=lt(n.tables,t.text,Oe,i=>({kind:"table",label:i})),a=cn(n,t.text,Oe),d=on.flatMap(i=>t.text!==""&&ze(i,t.text)&&i.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:i}]:[]);return(st(s,t.start)?[...a,...r,...d]:[...r,...a,...d]).slice(0,Oe)},"fn"),un=l((s,e,n)=>{let t=ht(s,e),o=s.slice(0,t.start)+n.label+s.slice(t.end);return{caret:t.start+n.label.length,value:o}},"mn"),mn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],fn=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 mn)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,d=r.offsetTop-s.scrollTop;return t.remove(),{left:a,top:d}},"pn"),hn=l((s,e,n)=>{let t=(0,G.c)(16),[o,r]=(0,z.useState)(null),a;t[0]!==s||t[1]!==e?(a=l((v,b)=>{let k=dn(v,b,s);if(k.length===0){r(null);return}let S=e.current,{left:x,top:q}=S===null?{left:0,top:0}:fn(S,b);r(C=>C!==null&&C.active===0&&C.left===x&&C.top===q&&C.suggestions.length===k.length&&C.suggestions.every((R,T)=>{let _=k.at(T);return R.kind===_?.kind&&R.label===_.label&&R.detail===_.detail})?C:{active:0,left:x,suggestions:k,top:q})},"r"),t[0]=s,t[1]=e,t[2]=a):a=t[2];let d=a,i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=l(()=>{r(null)},"c"),t[3]=i):i=t[3];let u=i,p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=l(v=>{r(b=>{if(b===null)return b;let k=b.suggestions.length,S=(b.active+v+k)%k;return{...b,active:S}})},"m"),t[4]=p):p=t[4];let h=p,g;t[5]!==n||t[6]!==o||t[7]!==e?(g=l(v=>{let b=e.current;if(o===null||b===null)return!1;let k=o.suggestions[v??o.active];if(k===void 0)return!1;let S=un(b.value,b.selectionStart,k);return n(S.value),r(null),requestAnimationFrame(()=>{let x=e.current;x!==null&&(x.focus(),x.setSelectionRange(S.caret,S.caret))}),!0},"f"),t[5]=n,t[6]=o,t[7]=e,t[8]=g):g=t[8];let y=g,m;t[9]!==y?(m=l(()=>y(),"d"),t[9]=y,t[10]=m):m=t[10];let w=m,f;return t[11]!==w||t[12]!==y||t[13]!==d||t[14]!==o?(f={close:u,commit:w,commitAt:y,move:h,refresh:d,state:o},t[11]=w,t[12]=y,t[13]=d,t[14]=o,t[15]=f):f=t[15],f},"bn"),pn={column:"column",keyword:"keyword",table:"table"},bn=20,gn=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+bn},e[0]=o,e[1]=a):a=e[1];let d=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 p;e[8]!==n||e[9]!==t||e[10]!==o.active||e[11]!==r?(p=l((h,g)=>(0,c.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(y=>{y.preventDefault(),t(g)},"onMouseDown"),role:"option",children:[(0,c.jsx)("span",{className:"truncate font-mono",children:h.label}),h.detail!==void 0&&(0,c.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:h.detail}),(0,c.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:r(pn[h.kind])})]},`${h.kind}:${h.label}`),"m"),e[8]=n,e[9]=t,e[10]=o.active,e[11]=r,e[12]=p):p=e[12],i=o.suggestions.map(p),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 u;return e[13]!==n||e[14]!==d||e[15]!==i?(u=(0,c.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:d,children:i}),e[13]=n,e[14]=d,e[15]=i,e[16]=u):u=e[16],u},"yn"),xn=we(Ne.listTables),vn=we(Ne.readTablePage),yn=l(s=>{let e=(0,G.c)(16),n=Ee(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];let[o,r]=(0,z.useState)(t),a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={},e[1]=a):a=e[1];let[d,i]=(0,z.useState)(a),u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[2]=u):u=e[2];let p=(0,z.useRef)(u),h,g;e[3]!==n||e[4]!==s?(h=l(()=>{let b={cancelled:!1};return ue((async()=>{try{let k=await n.query(xn,{},ke(s));b.cancelled||(r(k.map(wn)),i({}),p.current=new Set)}catch{b.cancelled||(r([]),i({}),p.current=new Set)}})()),()=>{b.cancelled=!0}},"g"),g=[n,s],e[3]=n,e[4]=s,e[5]=h,e[6]=g):(h=e[5],g=e[6]),(0,z.useEffect)(h,g);let y;e[7]!==n||e[8]!==s?(y=l(b=>{p.current.has(b)||(p.current.add(b),ue((async()=>{try{let k=await n.query(vn,{limit:1,offset:0,table:b},ke(s));i(S=>({...S,[b]:k.columns}))}catch{p.current.delete(b)}})()))},"y"),e[7]=n,e[8]=s,e[9]=y):y=e[9];let m=y,w;e[10]!==d||e[11]!==o?(w={columns:d,tables:o},e[10]=d,e[11]=o,e[12]=w):w=e[12];let f=w,v;return e[13]!==m||e[14]!==f?(v={probe:m,schema:f},e[13]=m,e[14]=f,e[15]=v):v=e[15],v},"wn"),Qe=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,Sn=l(s=>{let e=new Set;Qe.lastIndex=0;let n=Qe.exec(s);for(;n!==null;)e.add(n[1]??n[2]),n=Qe.exec(s);return[...e]},"Cn");function wn(s){return s.name}l(wn,"Nn");var kn=l(s=>{let e=(0,G.c)(34),{onSubmit:n,probe:t,schema:o,setDraft:r}=s,a=(0,z.useId)(),d=(0,z.useRef)(null),i=(0,z.useRef)(null),u=(0,z.useRef)(null),p=hn(o,u,r),{close:h,commit:g,commitAt:y,move:m,refresh:w,state:f}=p,v;e[0]!==y?(v=l(N=>{y(N)},"x"),e[0]=y,e[1]=v):v=e[1];let b=v,k;e[2]!==w?(k=l(()=>{let N=u.current;N!==null&&N===document.activeElement&&w(N.value,N.selectionStart)},"C"),e[2]=w,e[3]=k):k=e[3];let S;e[4]!==w||e[5]!==o?(S=[w,o],e[4]=w,e[5]=o,e[6]=S):S=e[6],(0,z.useEffect)(k,S);let x;e[7]!==t||e[8]!==w||e[9]!==r?(x=l(N=>{let{selectionStart:j,value:I}=N.target;r(I);for(let $ of Sn(I))t($);w(I,j)},"p"),e[7]=t,e[8]=w,e[9]=r,e[10]=x):x=e[10];let q=x,C;e[11]!==w?(C=l(N=>{let j=N.currentTarget;w(j.value,j.selectionStart)},"N"),e[11]=w,e[12]=C):C=e[12];let R=C,T;e[13]!==f||e[14]!==h||e[15]!==g||e[16]!==m||e[17]!==n?(T=l(N=>{if(f!==null){if(N.key==="ArrowDown"){N.preventDefault(),m(1);return}if(N.key==="ArrowUp"){N.preventDefault(),m(-1);return}if(N.key==="Escape"){N.preventDefault(),h();return}if((N.key==="Enter"||N.key==="Tab")&&!N.metaKey&&!N.ctrlKey&&g()){N.preventDefault();return}}(N.metaKey||N.ctrlKey)&&N.key==="Enter"&&(N.preventDefault(),n())},"E"),e[13]=f,e[14]=h,e[15]=g,e[16]=m,e[17]=n,e[18]=T):T=e[18];let _=T,E;e[19]!==h?(E=l(()=>{requestAnimationFrame(()=>{h()})},"T"),e[19]=h,e[20]=E):E=e[20];let O=E,D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=l(N=>{let{scrollLeft:j,scrollTop:I}=N.currentTarget;d.current!==null&&(d.current.scrollTop=I),i.current!==null&&(i.current.scrollTop=I,i.current.scrollLeft=j)},"_"),e[21]=D):D=e[21];let L=D,B;e[22]===Symbol.for("react.memo_cache_sentinel")?(B=l(N=>{let j=u.current;j===null||N.offset===void 0||(j.focus(),j.setSelectionRange(N.offset,N.offset+(N.length??0)))},"B"),e[22]=B):B=e[22];let A=B,P;e[23]!==q||e[24]!==O||e[25]!==_||e[26]!==R?(P={onBlur:O,onChange:q,onKeyDown:_,onScroll:L,onSelect:R},e[23]=q,e[24]=O,e[25]=_,e[26]=R,e[27]=P):P=e[27];let M;return e[28]!==f||e[29]!==h||e[30]!==a||e[31]!==b||e[32]!==P?(M={autocompleteState:f,closeAutocomplete:h,handlers:P,listboxId:a,onPickSuggestion:b,editorRef:u,gutterRef:d,overlayRef:i,revealDiagnostic:A},e[28]=f,e[29]=h,e[30]=a,e[31]=b,e[32]=P,e[33]=M):M=e[33],M},"kn"),Nn="lunora-studio-sql-tabs",qn="lunora-studio-sql-active-tab",Ue=12,Ce=l((s="",e="")=>({activeId:null,id:Pe("tab"),name:e,sql:s}),"we"),Cn=l(()=>_e(qn,""),"Rn"),Tn=l(s=>{let e=(0,G.c)(16),[n,t]=Le(Nn),[o,r]=Cn(),[a]=(0,z.useState)(s),d,i;e[0]!==a||e[1]!==t||e[2]!==n.length?(d=l(()=>{n.length===0&&t([a])},"i"),i=[a,t,n.length],e[0]=a,e[1]=t,e[2]=n.length,e[3]=d,e[4]=i):(d=e[3],i=e[4]),(0,z.useEffect)(d,i);let u;e[5]!==a||e[6]!==n?(u=n.length===0?[a]:n,e[5]=a,e[6]=n,e[7]=u):u=e[7];let p=u,h;e[8]!==o||e[9]!==p?(h=p.some(m=>m.id===o)?o:p[0]?.id??"",e[8]=o,e[9]=p,e[10]=h):h=e[10];let g=h,y;return e[11]!==g||e[12]!==r||e[13]!==t||e[14]!==p?(y={activeId:g,setActiveId:r,setTabs:t,tabs:p},e[11]=g,e[12]=r,e[13]=t,e[14]=p,e[15]=y):y=e[15],y},"Ln"),pt=l(s=>s.activeId===null&&s.sql.trim()!=="","it"),In=l((s,e)=>[...s,e].slice(-Ue),"In"),Rn=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}},"qn"),En=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}},"An"),Ln=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"),_n=l(s=>{let e=s();return{activeId:e.id,tabs:[e]}},"On"),On=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]},"Dn"),at={error:null,pane:"results",result:null,running:!1},Dn=l(s=>{let e=(0,G.c)(66),{activeId:n,setActiveId:t,setTabs:o,tabs:r}=Tn(s),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let[d,i]=(0,z.useState)(a),[u,p]=(0,z.useState)(null),[h,g]=(0,z.useState)(null),y;e[1]!==n||e[2]!==r?(y=r.find(W=>W.id===n)??r[0]??Ce(),e[1]=n,e[2]=r,e[3]=y):y=e[3];let m=y,w=d[m.id]??at,f;e[4]!==m.id||e[5]!==o?(f=l(W=>{o(U=>U.map(Y=>Y.id===m.id?{...Y,...W}:Y))},"u"),e[4]=m.id,e[5]=o,e[6]=f):f=e[6];let v=f,b;e[7]!==m.id?(b=l(W=>{i(U=>{let Y=U[m.id]??at;return{...U,[m.id]:{...Y,...W}}})},"h"),e[7]=m.id,e[8]=b):b=e[8];let k=b,S;e[9]!==t||e[10]!==o||e[11]!==r.length?(S=l(()=>{if(r.length>=Ue)return;let W=Ce();o(U=>In(U,W)),t(W.id)},"v"),e[9]=t,e[10]=o,e[11]=r.length,e[12]=S):S=e[12];let x=S,q;e[13]!==t||e[14]!==o?(q=l(W=>{p(null),g(null),o(W.tabs),t(W.activeId);let U=new Set(W.tabs.map(Mn));i(Y=>Object.fromEntries(Object.entries(Y).filter(X=>{let[fe]=X;return U.has(fe)})))},"k"),e[13]=t,e[14]=o,e[15]=q):q=e[15];let C=q,R;e[16]!==C||e[17]!==r?(R=l(W=>{C(Rn(r,W,Ce))},"L"),e[16]=C,e[17]=r,e[18]=R):R=e[18];let T=R,_;e[19]!==n||e[20]!==C||e[21]!==r?(_=l((W,U)=>{C(W==="others"?En(r,U):W==="right"?Ln(r,U,n):_n(Ce))},"q"),e[19]=n,e[20]=C,e[21]=r,e[22]=_):_=e[22];let E=_,O;e[23]!==E||e[24]!==u||e[25]!==r?(O=l(W=>{u!==null&&(On(W,r,u.id).some(An)?g(W):E(W,u.id))},"A"),e[23]=E,e[24]=u,e[25]=r,e[26]=O):O=e[26];let D=O,L;e[27]===Symbol.for("react.memo_cache_sentinel")?(L=l((W,U)=>{U.preventDefault(),g(null),p({id:W,x:U.clientX,y:U.clientY})},"I"),e[27]=L):L=e[27];let B=L,A;e[28]===Symbol.for("react.memo_cache_sentinel")?(A=l(()=>{p(null),g(null)},"D"),e[28]=A):A=e[28];let P=A,M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=l(W=>{W.preventDefault(),p(null),g(null)},"O"),e[29]=M):M=e[29];let N=M,j;e[30]!==D?(j=l(()=>{D("others")},"W"),e[30]=D,e[31]=j):j=e[31];let I=j,$;e[32]!==D?($=l(()=>{D("right")},"M"),e[32]=D,e[33]=$):$=e[33];let F=$,H;e[34]!==D?(H=l(()=>{D("all")},"$"),e[34]=D,e[35]=H):H=e[35];let J=H,Z;e[36]!==E||e[37]!==h||e[38]!==u?(Z=l(()=>{u!==null&&h!==null&&E(h,u.id),g(null)},"Z"),e[36]=E,e[37]=h,e[38]=u,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]!==u?(V=u===null?void 0:{left:u.x,top:u.y},e[41]=u,e[42]=V):V=e[42];let Q=V,ne;e[43]!==o?(ne=l(W=>{o(U=>U.map(Y=>Y.activeId===W?{...Y,activeId:null}:Y))},"ne"),e[43]=o,e[44]=ne):ne=e[44];let re=ne,oe;e[45]!==o?(oe=l((W,U)=>{o(Y=>Y.map(X=>X.id===W?{...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]!==x||e[50]!==T||e[51]!==ee||e[52]!==J||e[53]!==I||e[54]!==F||e[55]!==w||e[56]!==k||e[57]!==v||e[58]!==h||e[59]!==se||e[60]!==t||e[61]!==u||e[62]!==Q||e[63]!==r||e[64]!==re?(le={activeTab:m,activeTabId:n,addEditorTab:x,cancelBulk:ie,closeEditorTab:T,closeTabMenu:P,confirmBulk:ee,menuStyle:Q,onBackdropContextMenu:N,onCloseAll:J,onCloseOthers:I,onCloseToRight:F,openTabMenu:B,output:w,patchActiveOutput:k,patchActiveTab:v,pendingBulk:h,renameTab:se,setActiveTabId:t,tabMenu:u,tabs:r,unlinkQuery:re},e[47]=m,e[48]=n,e[49]=x,e[50]=T,e[51]=ee,e[52]=J,e[53]=I,e[54]=F,e[55]=w,e[56]=k,e[57]=v,e[58]=h,e[59]=se,e[60]=t,e[61]=u,e[62]=Q,e[63]=r,e[64]=re,e[65]=le):le=e[65],le},"Mn");function Mn(s){return s.id}l(Mn,"$n");function An(s){return pt(s)}l(An,"Bn");var $n="lunora-studio-sql-queries",Se="lunora-studio-sql-history",Bn="lunora-studio-sql-remember-history",Hn=25,Wn=l(s=>{let e=(0,G.c)(41),{loadIntoActiveTab:n,unlinkQuery:t}=s,o=ce(),[r,a]=Le($n),[d,i]=_e(Bn,!1),[u,p]=Le(Se,d?"local":"session"),h,g;e[0]!==d?(h=l(()=>{d||qe(Se,"local")},"g"),g=[d],e[0]=d,e[1]=h,e[2]=g):(h=e[1],g=e[2]),(0,z.useEffect)(h,g);let[y,m]=(0,z.useState)(""),w=(0,z.useRef)(null),f;e[3]!==p?(f=l(I=>{p($=>$[0]?.sql===I?$:[{at:Date.now(),sql:I},...$.filter(F=>F.sql!==I)].slice(0,Hn))},"u"),e[3]=p,e[4]=f):f=e[4];let v=f,b;e[5]!==n||e[6]!==a||e[7]!==o?(b=l(()=>{let I={id:Pe("q"),name:o("Untitled query"),sql:""};a($=>[I,...$]),n("",I.id)},"h"),e[5]=n,e[6]=a,e[7]=o,e[8]=b):b=e[8];let k=b,S;e[9]!==n||e[10]!==r?(S=l(I=>{let $=r.find(F=>F.id===I);$!==void 0&&(n($.sql,I),w.current?.querySelector(`[data-testid="sql-query-${I}"]`)?.scrollIntoView({block:"nearest"}))},"v"),e[9]=n,e[10]=r,e[11]=S):S=e[11];let x=S,q;e[12]!==a||e[13]!==t?(q=l(I=>{a($=>$.filter(F=>F.id!==I)),t(I)},"k"),e[12]=a,e[13]=t,e[14]=q):q=e[14];let C=q,R;e[15]!==n?(R=l(I=>{n(I.currentTarget.dataset.sql??"",null)},"L"),e[15]=n,e[16]=R):R=e[16];let T=R,_;e[17]!==n?(_=l(I=>{n(I.currentTarget.dataset.sql??"",null)},"q"),e[17]=n,e[18]=_):_=e[18];let E=_,O;e[19]!==p?(O=l(()=>{p([]),qe(Se,"local"),qe(Se,"session")},"A"),e[19]=p,e[20]=O):O=e[20];let D=O,L;e[21]!==u||e[22]!==i?(L=l(I=>{Ve(Se,u,I?"local":"session"),I||qe(Se,"local"),i(I)},"I"),e[21]=u,e[22]=i,e[23]=L):L=e[23];let B=L,A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=l(I=>{m(I.target.value)},"D"),e[24]=A):A=e[24];let P=A,M;e[25]!==a?(M=l((I,$)=>{a(F=>F.map(H=>H.id===I?{...H,sql:$}:H))},"O"),e[25]=a,e[26]=M):M=e[26];let N=M,j;return e[27]!==D||e[28]!==C||e[29]!==u||e[30]!==E||e[31]!==T||e[32]!==k||e[33]!==r||e[34]!==v||e[35]!==d||e[36]!==y||e[37]!==x||e[38]!==B||e[39]!==N?(j={clearHistory:D,deleteQuery:C,history:u,listRef:w,loadFromHistory:E,loadTemplate:T,newQuery:k,onSearchChange:P,queries:r,recordHistory:v,rememberHistory:d,search:y,selectQuery:x,setRememberHistory:B,updateQuerySql:N},e[27]=D,e[28]=C,e[29]=u,e[30]=E,e[31]=T,e[32]=k,e[33]=r,e[34]=v,e[35]=d,e[36]=y,e[37]=x,e[38]=B,e[39]=N,e[40]=j):j=e[40],j},"Fn"),bt="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Pn=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},"Qn"),jn=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.","Un"),Qn=l(s=>{let e=(0,G.c)(51),{assistant:n,failed:t,onGenerated:o}=s,r=ce(),[a,d]=(0,z.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 u=i,p;if(e[2]!==n||e[3]!==t||e[4]!==o||e[5]!==u||e[6]!==a||e[7]!==r){let h=n.reason("sql"),g;e[9]!==n||e[10]!==t||e[11]!==o||e[12]!==a?(g=l(E=>{let O=a.trim();O===""&&!E||ue((async()=>{let D=await n.generate(O===""?"fix the failing statement":O,E?t:void 0);D!==void 0&&o(D)})())},"f"),e[9]=n,e[10]=t,e[11]=o,e[12]=a,e[13]=g):g=e[13];let y=g,m;e[14]!==r?(m=r("Describe the query you want"),e[14]=r,e[15]=m):m=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=l(E=>{d(E.target.value)},"S"),e[16]=w):w=e[16];let f;e[17]!==y?(f=l(E=>{E.key==="Enter"&&(E.preventDefault(),y(!1))},"u"),e[17]=y,e[18]=f):f=e[18];let v;e[19]!==r?(v=r("Describe the query you want"),e[19]=r,e[20]=v):v=e[20];let b;e[21]!==u||e[22]!==a||e[23]!==m||e[24]!==f||e[25]!==v?(b=(0,c.jsx)(Ge,{"aria-label":m,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:u,onChange:w,onKeyDown:f,placeholder:v,value:a}),e[21]=u,e[22]=a,e[23]=m,e[24]=f,e[25]=v,e[26]=b):b=e[26];let k=u&&"opacity-60",S;e[27]!==k?(S=me("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",k),e[27]=k,e[28]=S):S=e[28];let x;e[29]!==u||e[30]!==a?(x=u||a.trim()==="",e[29]=u,e[30]=a,e[31]=x):x=e[31];let q;e[32]!==y?(q=l(()=>{y(!1)},"k"),e[32]=y,e[33]=q):q=e[33];let C;e[34]!==u||e[35]!==r?(C=r(u?"Thinking\u2026":"Draft SQL"),e[34]=u,e[35]=r,e[36]=C):C=e[36];let R;e[37]!==S||e[38]!==x||e[39]!==q||e[40]!==C?(R=(0,c.jsx)("button",{className:S,"data-testid":"sql-assistant-generate",disabled:x,onClick:q,type:"button",children:C}),e[37]=S,e[38]=x,e[39]=q,e[40]=C,e[41]=R):R=e[41];let T;e[42]!==t||e[43]!==u||e[44]!==y||e[45]!==r?(T=t!==void 0&&(0,c.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:u,onClick:l(()=>{y(!0)},"onClick"),type:"button",children:r("Fix this")}),e[42]=t,e[43]=u,e[44]=y,e[45]=r,e[46]=T):T=e[46];let _;e[47]!==R||e[48]!==T||e[49]!==b?(_=(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[b,R,T]}),e[47]=R,e[48]=T,e[49]=b,e[50]=_):_=e[50],p=(0,c.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[_,h!==void 0&&(0,c.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:jn(h)})]}),e[2]=n,e[3]=t,e[4]=o,e[5]=u,e[6]=a,e[7]=r,e[8]=p}else p=e[8];return p},"jn"),Fn=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 u=Pn(n,t.length);if(u.length===0){a=null;break e}r=[];let p=0;for(let[h,g]of u.entries())g.start>p&&r.push(t.slice(p,g.start)),r.push((0,c.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()}-${h.toString()}`)),p=g.end;r.push(t.slice(p))}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 d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=me("pointer-events-none absolute inset-0 overflow-hidden text-transparent",bt),e[4]=d):d=e[4];let i;return e[5]!==r||e[6]!==o?(i=(0,c.jsx)("div",{"aria-hidden":"true",className:d,"data-testid":"sql-diagnostics-overlay",ref:o,children:r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i},"zn"),zn={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Un=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((u,p)=>(0,c.jsx)("li",{children:(0,c.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(u)},"onClick"),type:"button",children:[(0,c.jsx)("span",{className:me("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",u.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:zn[u.source]}),(0,c.jsx)("span",{className:"min-w-0 text-muted-foreground",children:u.message})]})},`${u.source}-${(u.offset??p).toString()}-${p.toString()}`),"c"),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 d;return e[7]!==r||e[8]!==a?(d=(0,c.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]=d):d=e[9],d},"Kn"),Yn={minWidth:"2.75rem",paddingInline:"0.5rem"},Gn=l(s=>{let e=(0,G.c)(64),{assistant:n,autocomplete:t,diagnostics:o,draft:r,failed:a,handlers:d,editorRef:i,gutterRef:u,listboxId:p,onGenerated:h,onPickSuggestion:g,onRevealDiagnostic:y,overlayRef:m}=s,w=ce(),f,v,b,k,S,x,q,C;if(e[0]!==n||e[1]!==r||e[2]!==a||e[3]!==u||e[4]!==h){let j=r.split(`
|
|
8
|
-
`).length;q="flex min-h-0 min-w-0 flex-1 flex-col",e[13]!==n||e[14]!==a||e[15]!==h?(C=(0,c.jsx)(Qn,{assistant:n,failed:a,onGenerated:h}),e[13]=n,e[14]=a,e[15]=h,e[16]=C):C=e[16],x="flex min-h-0 min-w-0 flex-1",f="true",v="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",b=u,k=Yn,S=Array.from({length:j},Kn),e[0]=n,e[1]=r,e[2]=a,e[3]=u,e[4]=h,e[5]=f,e[6]=v,e[7]=b,e[8]=k,e[9]=S,e[10]=x,e[11]=q,e[12]=C}else f=e[5],v=e[6],b=e[7],k=e[8],S=e[9],x=e[10],q=e[11],C=e[12];let R;e[17]!==f||e[18]!==v||e[19]!==b||e[20]!==k||e[21]!==S?(R=(0,c.jsx)("div",{"aria-hidden":f,className:v,ref:b,style:k,children:S}),e[17]=f,e[18]=v,e[19]=b,e[20]=k,e[21]=S,e[22]=R):R=e[22];let T;e[23]!==o||e[24]!==r||e[25]!==m?(T=(0,c.jsx)(Fn,{diagnostics:o,draft:r,scrollRef:m}),e[23]=o,e[24]=r,e[25]=m,e[26]=T):T=e[26];let _;e[27]!==t||e[28]!==p?(_=t===null?void 0:`${p}-opt-${t.active.toString()}`,e[27]=t,e[28]=p,e[29]=_):_=e[29];let E=t===null?void 0:p,O=t!==null,D;e[30]!==w?(D=w("SQL query"),e[30]=w,e[31]=D):D=e[31];let L;e[32]!==r||e[33]!==i||e[34]!==d.onBlur||e[35]!==d.onChange||e[36]!==d.onKeyDown||e[37]!==d.onScroll||e[38]!==d.onSelect||e[39]!==_||e[40]!==E||e[41]!==O||e[42]!==D?(L=(0,c.jsx)("textarea",{"aria-activedescendant":_,"aria-autocomplete":"list","aria-controls":E,"aria-expanded":O,"aria-label":D,className:`relative size-full resize-none bg-transparent outline-none ${bt}`,"data-testid":"sql-input",onBlur:d.onBlur,onChange:d.onChange,onKeyDown:d.onKeyDown,onScroll:d.onScroll,onSelect:d.onSelect,placeholder:"SELECT * FROM \u2026",ref:i,role:"combobox",spellCheck:!1,value:r}),e[32]=r,e[33]=i,e[34]=d.onBlur,e[35]=d.onChange,e[36]=d.onKeyDown,e[37]=d.onScroll,e[38]=d.onSelect,e[39]=_,e[40]=E,e[41]=O,e[42]=D,e[43]=L):L=e[43];let B;e[44]!==t||e[45]!==p||e[46]!==g?(B=(0,c.jsx)(gn,{listboxId:p,onPick:g,state:t}),e[44]=t,e[45]=p,e[46]=g,e[47]=B):B=e[47];let A;e[48]!==T||e[49]!==L||e[50]!==B?(A=(0,c.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[T,L,B]}),e[48]=T,e[49]=L,e[50]=B,e[51]=A):A=e[51];let P;e[52]!==A||e[53]!==x||e[54]!==R?(P=(0,c.jsxs)("div",{className:x,children:[R,A]}),e[52]=A,e[53]=x,e[54]=R,e[55]=P):P=e[55];let M;e[56]!==o||e[57]!==y?(M=(0,c.jsx)(Un,{diagnostics:o,onSelect:y}),e[56]=o,e[57]=y,e[58]=M):M=e[58];let N;return e[59]!==P||e[60]!==M||e[61]!==q||e[62]!==C?(N=(0,c.jsxs)("div",{className:q,children:[C,P,M]}),e[59]=P,e[60]=M,e[61]=q,e[62]=C,e[63]=N):N=e[63],N},"Jn");function Kn(s,e){return(0,c.jsx)("div",{children:e+1},e)}l(Kn,"Vn");var gt=[{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;"}],Vn=l(s=>{let e=(0,G.c)(29),{active:n,onDelete:t,onSelect:o,query:r}=s,a=ce(),d;e[0]!==o||e[1]!==r.id?(d=l(()=>{o(r.id)},"i"),e[0]=o,e[1]=r.id,e[2]=d):d=e[2];let i=d,u;e[3]!==t||e[4]!==r.id?(u=l(q=>{q.stopPropagation(),t(r.id)},"a"),e[3]=t,e[4]=r.id,e[5]=u):u=e[5];let p=u,h=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",g;e[6]!==h?(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",h),e[6]=h,e[7]=g):g=e[7];let y=`sql-query-${r.id}`,m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=(0,c.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,c.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=m):m=e[8];let w;e[9]!==r.name?(w=(0,c.jsx)("span",{className:"truncate",children:r.name}),e[9]=r.name,e[10]=w):w=e[10];let f;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==y||e[15]!==w?(f=(0,c.jsxs)("button",{"aria-pressed":n,className:g,"data-testid":y,onClick:i,type:"button",children:[m,w]}),e[11]=n,e[12]=i,e[13]=g,e[14]=y,e[15]=w,e[16]=f):f=e[16];let v;e[17]!==a?(v=a("Delete query"),e[17]=a,e[18]=v):v=e[18];let b;e[19]!==a?(b=a("Delete query"),e[19]=a,e[20]=b):b=e[20];let k;e[21]===Symbol.for("react.memo_cache_sentinel")?(k=(0,c.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,c.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=k):k=e[21];let S;e[22]!==p||e[23]!==b||e[24]!==v?(S=(0,c.jsx)("button",{"aria-label":v,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:p,title:b,type:"button",children:k}),e[22]=p,e[23]=b,e[24]=v,e[25]=S):S=e[25];let x;return e[26]!==S||e[27]!==f?(x=(0,c.jsxs)("li",{className:"group/q flex items-center",children:[f,S]}),e[26]=S,e[27]=f,e[28]=x):x=e[28],x},"Xn"),it="sql-history-remember",Xn=l((s,e)=>{let n=e.trim().toLowerCase();return n===""?[...s]:s.filter(t=>t.name.toLowerCase().includes(n))},"Zn"),Jn=l(s=>{let e=(0,G.c)(66),{activeId:n,history:t,listRef:o,onClearHistory:r,onDelete:a,onLoadHistory:d,onLoadTemplate:i,onNew:u,onSearchChange:p,onSelect:h,onToggleRememberHistory:g,queries:y,rememberHistory:m,search:w}=s,f=ce(),v,b,k,S,x;if(e[0]!==n||e[1]!==o||e[2]!==a||e[3]!==u||e[4]!==p||e[5]!==h||e[6]!==g||e[7]!==y||e[8]!==w||e[9]!==f){let L=Xn(y,w),B;e[15]!==g?(B=l(H=>{g(H.target.checked)},"B"),e[15]=g,e[16]=B):B=e[16],v=B,k="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let A;e[17]!==f?(A=f("Search queries\u2026"),e[17]=f,e[18]=A):A=e[18];let P;e[19]!==p||e[20]!==w||e[21]!==A?(P=(0,c.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:p,placeholder:A,type:"text",value:w}),e[19]=p,e[20]=w,e[21]=A,e[22]=P):P=e[22];let M;e[23]!==f?(M=f("New query"),e[23]=f,e[24]=M):M=e[24];let N;e[25]!==f?(N=f("New query"),e[25]=f,e[26]=N):N=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=(0,c.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,c.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[27]=j):j=e[27];let I;e[28]!==u||e[29]!==M||e[30]!==N?(I=(0,c.jsx)("button",{"aria-label":M,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:u,title:N,type:"button",children:j}),e[28]=u,e[29]=M,e[30]=N,e[31]=I):I=e[31],e[32]!==I||e[33]!==P?(S=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[P,I]}),e[32]=I,e[33]=P,e[34]=S):S=e[34],b="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 F;e[37]!==$?(F=(0,c.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),e[37]=$,e[38]=F):F=e[38],x=(0,c.jsxs)("div",{children:[F,L.length===0?(0,c.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,c.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:L.map(H=>(0,c.jsx)(Vn,{active:n===H.id,onDelete:a,onSelect:h,query:H},H.id))})]}),e[0]=n,e[1]=o,e[2]=a,e[3]=u,e[4]=p,e[5]=h,e[6]=g,e[7]=y,e[8]=w,e[9]=f,e[10]=v,e[11]=b,e[12]=k,e[13]=S,e[14]=x}else v=e[10],b=e[11],k=e[12],S=e[13],x=e[14];let q;e[39]!==f?(q=f("Reference"),e[39]=f,e[40]=q):q=e[40];let C;e[41]!==q?(C=(0,c.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:q}),e[41]=q,e[42]=C):C=e[42];let R;e[43]!==i?(R=gt.map(L=>(0,c.jsx)("li",{children:(0,c.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,c.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,c.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,c.jsx)("ul",{className:"flex flex-col gap-px",children:R}),e[45]=R,e[46]=T):T=e[46];let _;e[47]!==C||e[48]!==T?(_=(0,c.jsxs)("div",{children:[C,T]}),e[47]=C,e[48]=T,e[49]=_):_=e[49];let E;e[50]!==t||e[51]!==r||e[52]!==d||e[53]!==v||e[54]!==m||e[55]!==f?(E=t.length>0&&(0,c.jsxs)("div",{children:[(0,c.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,c.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f("History")}),(0,c.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,c.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,c.jsx)("input",{checked:m,"data-testid":"sql-history-remember",id:it,onChange:v,type:"checkbox"}),f("Keep history on this browser")]}),(0,c.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(L=>(0,c.jsx)("li",{children:(0,c.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:d,title:L.sql,type:"button",children:[(0,c.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,c.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,c.jsx)("span",{className:"truncate font-mono",children:L.sql})]})},`${L.at.toString()}:${L.sql}`))})]}),e[50]=t,e[51]=r,e[52]=d,e[53]=v,e[54]=m,e[55]=f,e[56]=E):E=e[56];let O;e[57]!==b||e[58]!==E||e[59]!==x||e[60]!==_?(O=(0,c.jsxs)("div",{className:b,children:[x,_,E]}),e[57]=b,e[58]=E,e[59]=x,e[60]=_,e[61]=O):O=e[61];let D;return e[62]!==O||e[63]!==k||e[64]!==S?(D=(0,c.jsxs)("aside",{className:k,children:[S,O]}),e[62]=O,e[63]=k,e[64]=S,e[65]=D):D=e[65],D},"es"),De=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"),Zn=l(s=>{let e=(0,G.c)(96),{assistant:n,chart:t,className:o,error:r,onFormat:a,onInferChart:d,onRun:i,onSelectStatement:u,onShardKeyChange:p,onShowChart:h,onShowExplain:g,onShowResults:y,onToggleSplit:m,pane:w,result:f,running:v,script:b,shardKey:k,splitView:S}=s,x=ce(),q=w==="results",C;e[0]!==q?(C=De(q),e[0]=q,e[1]=C):C=e[1];let R;e[2]!==x?(R=x("Results"),e[2]=x,e[3]=R):R=e[3];let T;e[4]!==y||e[5]!==C||e[6]!==R?(T=(0,c.jsx)("button",{className:C,"data-testid":"sql-tab-results",onClick:y,type:"button",children:R}),e[4]=y,e[5]=C,e[6]=R,e[7]=T):T=e[7];let _=w==="chart",E;e[8]!==_?(E=De(_),e[8]=_,e[9]=E):E=e[9];let O;e[10]!==x?(O=x("Chart"),e[10]=x,e[11]=O):O=e[11];let D;e[12]!==h||e[13]!==E||e[14]!==O?(D=(0,c.jsx)("button",{className:E,"data-testid":"sql-tab-chart",onClick:h,type:"button",children:O}),e[12]=h,e[13]=E,e[14]=O,e[15]=D):D=e[15];let L;e[16]!==n||e[17]!==d||e[18]!==w||e[19]!==f||e[20]!==x?(L=!n.unavailable&&w==="chart"&&f!==null&&(0,c.jsx)("button",{className:De(!1),"data-testid":"sql-infer-chart",disabled:n.pending("chart"),onClick:d,type:"button",children:n.pending("chart")?x("Thinking\u2026"):x("Suggest chart")}),e[16]=n,e[17]=d,e[18]=w,e[19]=f,e[20]=x,e[21]=L):L=e[21];let B=w==="explain",A;e[22]!==B?(A=De(B),e[22]=B,e[23]=A):A=e[23];let P;e[24]!==x?(P=x("Explain"),e[24]=x,e[25]=P):P=e[25];let M;e[26]!==g||e[27]!==A||e[28]!==P?(M=(0,c.jsx)("button",{className:A,"data-testid":"sql-tab-explain",onClick:g,type:"button",children:P}),e[26]=g,e[27]=A,e[28]=P,e[29]=M):M=e[29];let N;e[30]!==x?(N=x("Split editor and results"),e[30]=x,e[31]=N):N=e[31];let j=`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 ${S?"bg-accent text-foreground":"text-muted-foreground"}`,I;e[32]!==x?(I=x("Split editor and results"),e[32]=x,e[33]=I):I=e[33];let $;e[34]===Symbol.for("react.memo_cache_sentinel")?($=(0,c.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,c.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,c.jsx)("path",{d:"M12 4v16"})]}),e[34]=$):$=e[34];let F;e[35]!==m||e[36]!==S||e[37]!==N||e[38]!==j||e[39]!==I?(F=(0,c.jsx)("button",{"aria-label":N,"aria-pressed":S,className:j,"data-testid":"sql-split-toggle",onClick:m,title:I,type:"button",children:$}),e[35]=m,e[36]=S,e[37]=N,e[38]=j,e[39]=I,e[40]=F):F=e[40];let H;e[41]!==f?(H=f!==null&&f.columns.length>0&&(0,c.jsx)(nt,{columns:f.columns,name:"query-result",rows:f.rows}),e[41]=f,e[42]=H):H=e[42];let J;e[43]!==x?(J=x("Format"),e[43]=x,e[44]=J):J=e[44];let Z;e[45]!==a||e[46]!==v||e[47]!==J?(Z=(0,c.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:v,onClick:a,type:"button",children:J}),e[45]=a,e[46]=v,e[47]=J,e[48]=Z):Z=e[48];let ee;e[49]!==p||e[50]!==k?(ee=(0,c.jsx)(Je,{onChange:p,testId:"sql-shard-input",value:k}),e[49]=p,e[50]=k,e[51]=ee):ee=e[51];let te;e[52]!==v||e[53]!==x?(te=x(v?"Running\u2026":"Run"),e[52]=v,e[53]=x,e[54]=te):te=e[54];let ie;e[55]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,c.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]!==v||e[58]!==te?(V=(0,c.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:v,onClick:i,type:"button",children:[te,ie]}),e[56]=i,e[57]=v,e[58]=te,e[59]=V):V=e[59];let Q;e[60]!==F||e[61]!==H||e[62]!==Z||e[63]!==ee||e[64]!==V?(Q=(0,c.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[F,H,Z,ee,V]}),e[60]=F,e[61]=H,e[62]=Z,e[63]=ee,e[64]=V,e[65]=Q):Q=e[65];let ne;e[66]!==M||e[67]!==Q||e[68]!==T||e[69]!==D||e[70]!==L?(ne=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[T,D,L,M,Q]}),e[66]=M,e[67]=Q,e[68]=T,e[69]=D,e[70]=L,e[71]=ne):ne=e[71];let re;e[72]!==u||e[73]!==b?(re=b!==void 0&&(0,c.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:b.runs.map((Y,X)=>(0,c.jsx)("button",{"aria-pressed":X===b.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${X===b.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(()=>{u(X)},"onClick"),title:Y.sql,type:"button",children:X+1},`${X.toString()}:${Y.sql}`))}),e[72]=u,e[73]=b,e[74]=re):re=e[74];let oe;e[75]!==r?(oe=r!==null&&(0,c.jsx)(Ze,{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]!==x?(se=r===null&&f===null&&(0,c.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:x("Click Run to execute your query.")}),e[77]=r,e[78]=f,e[79]=x,e[80]=se):se=e[80];let le;e[81]!==t||e[82]!==r||e[83]!==w||e[84]!==f||e[85]!==x?(le=r===null&&f!==null&&(0,c.jsxs)("div",{"data-testid":"sql-result",children:[w==="chart"?(0,c.jsx)(rt,{axes:t,result:f}):(0,c.jsx)(ot,{result:f}),(0,c.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:f.truncated?x("Showing the first {max} of {count} rows.",{count:f.rowCount,max:f.rows.length}):x("{count} rows",{count:f.rowCount})})]}),e[81]=t,e[82]=r,e[83]=w,e[84]=f,e[85]=x,e[86]=le):le=e[86];let W;e[87]!==oe||e[88]!==se||e[89]!==le?(W=(0,c.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]=W):W=e[90];let U;return e[91]!==o||e[92]!==ne||e[93]!==re||e[94]!==W?(U=(0,c.jsxs)("div",{className:o,children:[ne,re,W]}),e[91]=o,e[92]=ne,e[93]=re,e[94]=W,e[95]=U):U=e[95],U},"ts"),er=l((s,e)=>s.trim()===""?e:(s.split(`
|
|
9
|
-
`)[0]??s).slice(0,24),"ns"),tr=l(s=>{s?.focus(),s?.select()},"ss"),nr=l(s=>{let e=(0,G.c)(14),{initial:n,onCancel:t,onCommit:o,placeholder:r,testId:a}=s,d=ce(),i;e[0]!==o?(i=l(m=>{o(m.currentTarget.value.trim())},"c"),e[0]=o,e[1]=i):i=e[1];let u=i,p;e[2]!==t||e[3]!==o?(p=l(m=>{m.key==="Enter"?o(m.currentTarget.value.trim()):m.key==="Escape"&&t()},"m"),e[2]=t,e[3]=o,e[4]=p):p=e[4];let h=p,g;e[5]!==d?(g=d("Tab title"),e[5]=d,e[6]=g):g=e[6];let y;return e[7]!==n||e[8]!==u||e[9]!==h||e[10]!==r||e[11]!==g||e[12]!==a?(y=(0,c.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:u,onKeyDown:h,placeholder:r,ref:tr,type:"text"}),e[7]=n,e[8]=u,e[9]=h,e[10]=r,e[11]=g,e[12]=a,e[13]=y):y=e[13],y},"os"),rr=l(s=>{let e=(0,G.c)(29),{idBase:n,onDiscard:t,onKeep:o}=s,r=ce(),a=`sql-tab-close-prompt-${n}`,d;e[0]!==r?(d=r("Discard?"),e[0]=r,e[1]=d):d=e[1];let i;e[2]!==d?(i=(0,c.jsx)("span",{className:"text-[11px] text-muted-foreground",children:d}),e[2]=d,e[3]=i):i=e[3];let u;e[4]!==r?(u=r("Discard changes"),e[4]=r,e[5]=u):u=e[5];let p=`sql-tab-close-confirm-${n}`,h;e[6]!==r?(h=r("Discard changes"),e[6]=r,e[7]=h):h=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=(0,c.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,c.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=g):g=e[8];let y;e[9]!==t||e[10]!==u||e[11]!==p||e[12]!==h?(y=(0,c.jsx)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":p,onClick:t,title:h,type:"button",children:g}),e[9]=t,e[10]=u,e[11]=p,e[12]=h,e[13]=y):y=e[13];let m;e[14]!==r?(m=r("Keep editing"),e[14]=r,e[15]=m):m=e[15];let w=`sql-tab-close-cancel-${n}`,f;e[16]!==r?(f=r("Keep editing"),e[16]=r,e[17]=f):f=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=(0,c.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,c.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=v):v=e[18];let b;e[19]!==o||e[20]!==w||e[21]!==f||e[22]!==m?(b=(0,c.jsx)("button",{"aria-label":m,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":w,onClick:o,title:f,type:"button",children:v}),e[19]=o,e[20]=w,e[21]=f,e[22]=m,e[23]=b):b=e[23];let k;return e[24]!==a||e[25]!==b||e[26]!==i||e[27]!==y?(k=(0,c.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":a,role:"group",children:[i,y,b]}),e[24]=a,e[25]=b,e[26]=i,e[27]=y,e[28]=k):k=e[28],k},"ls"),or=l(s=>{let e=(0,G.c)(47),{active:n,canClose:t,onClose:o,onMenu:r,onRename:a,onSelect:d,tab:i}=s,u=ce(),[p,h]=(0,z.useState)(!1),[g,y]=(0,z.useState)(!1),m;e[0]!==r||e[1]!==i.id?(m=l(H=>{r(i.id,H)},"d"),e[0]=r,e[1]=i.id,e[2]=m):m=e[2];let w=m,f;e[3]!==d||e[4]!==i.id?(f=l(()=>{d(i.id)},"u"),e[3]=d,e[4]=i.id,e[5]=f):f=e[5];let v=f,b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=l(()=>{h(!0)},"h"),e[6]=b):b=e[6];let k=b,S;e[7]!==o||e[8]!==i?(S=l(H=>{H.stopPropagation(),pt(i)?y(!0):o(i.id)},"v"),e[7]=o,e[8]=i,e[9]=S):S=e[9];let x=S,q;e[10]!==o||e[11]!==i.id?(q=l(H=>{H.stopPropagation(),y(!1),o(i.id)},"k"),e[10]=o,e[11]=i.id,e[12]=q):q=e[12];let C=q,R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=l(H=>{H.stopPropagation(),y(!1)},"L"),e[13]=R):R=e[13];let T=R,_;e[14]!==a||e[15]!==i.id?(_=l(H=>{a(i.id,H),h(!1)},"q"),e[14]=a,e[15]=i.id,e[16]=_):_=e[16];let E=_,O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O=l(()=>{h(!1)},"A"),e[17]=O):O=e[17];let D=O,L;e[18]!==i.name?(L=i.name.trim(),e[18]=i.name,e[19]=L):L=e[19];let B=L,A;e[20]!==u||e[21]!==i.sql?(A=er(i.sql,u("Untitled")),e[20]=u,e[21]=i.sql,e[22]=A):A=e[22];let P=A,M=n?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",N;e[23]!==M?(N=me("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",M),e[23]=M,e[24]=N):N=e[24];let j=`sql-tab-${i.id}`,I;e[25]!==n||e[26]!==E||e[27]!==B||e[28]!==P||e[29]!==p||e[30]!==v||e[31]!==u||e[32]!==i.id?(I=p?(0,c.jsx)(nr,{initial:B,onCancel:D,onCommit:E,placeholder:P,testId:`sql-tab-rename-${i.id}`}):(0,c.jsx)("button",{"aria-pressed":n,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${i.id}`,onClick:v,onDoubleClick:k,title:u("Double-click to rename"),type:"button",children:B===""?P:B}),e[25]=n,e[26]=E,e[27]=B,e[28]=P,e[29]=p,e[30]=v,e[31]=u,e[32]=i.id,e[33]=I):I=e[33];let $;e[34]!==t||e[35]!==C||e[36]!==g||e[37]!==x||e[38]!==u||e[39]!==i.id?($=t&&(g?(0,c.jsx)(rr,{idBase:i.id,onDiscard:C,onKeep:T}):(0,c.jsx)("button",{"aria-label":u("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:x,title:u("Close tab"),type:"button",children:(0,c.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,c.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=C,e[36]=g,e[37]=x,e[38]=u,e[39]=i.id,e[40]=$):$=e[40];let F;return e[41]!==w||e[42]!==N||e[43]!==j||e[44]!==I||e[45]!==$?(F=(0,c.jsxs)("div",{className:N,"data-testid":j,onContextMenu:w,children:[I,$]}),e[41]=w,e[42]=N,e[43]=j,e[44]=I,e[45]=$,e[46]=F):F=e[46],F},"rs"),sr=l(s=>{let e=(0,G.c)(43),{model:n,onSelect:t}=s,o=ce(),{activeTab:r,addEditorTab:a,cancelBulk:d,closeEditorTab:i,closeTabMenu:u,confirmBulk:p,menuStyle:h,onBackdropContextMenu:g,onCloseAll:y,onCloseOthers:m,onCloseToRight:w,openTabMenu:f,pendingBulk:v,renameTab:b,tabMenu:k,tabs:S}=n,x;if(e[0]!==r||e[1]!==i||e[2]!==t||e[3]!==f||e[4]!==b||e[5]!==S){let L;e[7]!==r||e[8]!==i||e[9]!==t||e[10]!==f||e[11]!==b||e[12]!==S.length?(L=l(B=>(0,c.jsx)(or,{active:B.id===r.id,canClose:S.length>1,onClose:i,onMenu:f,onRename:b,onSelect:t,tab:B},B.id),"I"),e[7]=r,e[8]=i,e[9]=t,e[10]=f,e[11]=b,e[12]=S.length,e[13]=L):L=e[13],x=S.map(L),e[0]=r,e[1]=i,e[2]=t,e[3]=f,e[4]=b,e[5]=S,e[6]=x}else x=e[6];let q;e[14]!==o?(q=o("New tab"),e[14]=o,e[15]=q):q=e[15];let C=S.length>=Ue,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,c.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,c.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[18]=T):T=e[18];let _;e[19]!==a||e[20]!==q||e[21]!==C||e[22]!==R?(_=(0,c.jsx)("button",{"aria-label":q,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:C,onClick:a,title:R,type:"button",children:T}),e[19]=a,e[20]=q,e[21]=C,e[22]=R,e[23]=_):_=e[23];let E;e[24]!==x||e[25]!==_?(E=(0,c.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:[x,_]}),e[24]=x,e[25]=_,e[26]=E):E=e[26];let O;e[27]!==d||e[28]!==u||e[29]!==p||e[30]!==h||e[31]!==g||e[32]!==y||e[33]!==m||e[34]!==w||e[35]!==v||e[36]!==o||e[37]!==k||e[38]!==S?(O=k!==null&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:u,onContextMenu:g,role:"presentation"}),(0,c.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:h,children:v===null?(0,c.jsxs)(c.Fragment,{children:[(0,c.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:S.length<=1,onClick:m,role:"menuitem",type:"button",children:o("Close other tabs")}),(0,c.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:S.findIndex(L=>L.id===k.id)>=S.length-1,onClick:w,role:"menuitem",type:"button",children:o("Close tabs to the right")}),(0,c.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:y,role:"menuitem",type:"button",children:o("Close all tabs")})]}):(0,c.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,c.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")}),(0,c.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,c.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:p,type:"button",children:o("Discard")}),(0,c.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:d,type:"button",children:o("Cancel")})]})]})})]}),e[27]=d,e[28]=u,e[29]=p,e[30]=h,e[31]=g,e[32]=y,e[33]=m,e[34]=w,e[35]=v,e[36]=o,e[37]=k,e[38]=S,e[39]=O):O=e[39];let D;return e[40]!==E||e[41]!==O?(D=(0,c.jsxs)(c.Fragment,{children:[E,O]}),e[40]=E,e[41]=O,e[42]=D):D=e[42],D},"is"),lr=we(Ne.runSql),ar="lunora-studio-sql-split-view",ir=l(()=>Ce(gt[0]?.sql??""),"ds"),kr=l(s=>{let e=(0,G.c)(112),{initialShardKey:n}=s,t=Ee(),o=Dn(ir),{activeTab:r,output:a,patchActiveOutput:d,patchActiveTab:i,setActiveTabId:u,unlinkQuery:p}=o,h;e[0]!==d||e[1]!==i?(h=l((K,ae)=>{i({activeId:ae,sql:K}),d({chart:void 0,error:null,failed:void 0,result:null,script:void 0})},"g"),e[0]=d,e[1]=i,e[2]=h):h=e[2];let g=h,y;e[3]!==g||e[4]!==p?(y={loadIntoActiveTab:g,unlinkQuery:p},e[3]=g,e[4]=p,e[5]=y):y=e[5];let m=Wn(y),{recordHistory:w,updateQuerySql:f}=m,v=r.sql,{activeId:b}=r,{chart:k,error:S,failed:x,result:q,running:C}=a,R=a.pane,[T,_]=(0,z.useState)(n??""),[E,O]=_e(ar,!1),{probe:D,schema:L}=yn(T),B;e[6]!==b||e[7]!==i||e[8]!==f?(B=l(K=>{i({sql:K}),b!==null&&f(b,K)},"B"),e[6]=b,e[7]=i,e[8]=f,e[9]=B):B=e[9];let A=B,P=rn(v,L,T),M=tt(T),N;e[10]!==M||e[11]!==d||e[12]!==q?(N=l(()=>{q!==null&&ue((async()=>{let K=await M.inferChart({columns:q.columns,rowCount:q.rowCount,types:Object.fromEntries(q.columns.map(ae=>[ae,typeof(q.rows[0]?.[ae]??"")]))});d({chart:K})})())},"w"),e[10]=M,e[11]=d,e[12]=q,e[13]=N):N=e[13];let j=N,I;e[14]!==t||e[15]!==w||e[16]!==T?(I=l(async K=>{try{let ae=await t.query(lr,{sql:K},ke(T));return w(K),{error:null,result:ae,sql:K}}catch(ae){return{error:Ke(ae),result:null,sql:K}}},"R"),e[14]=t,e[15]=w,e[16]=T,e[17]=I):I=e[17];let $=I,F;e[18]!==v||e[19]!==d||e[20]!==$||e[21]!==T?(F=l(async K=>{if(v.trim()==="")return;d({running:!0});let ae=K==="explain"?Fe(`EXPLAIN QUERY PLAN ${v}`,0):dt(v),de=[];for(let Re of ae){let xt={error:Re.rejection?.message??"",result:null,sql:Re.sql};de.push(Re.rejection===void 0?await $(Re.sql):xt)}Xe(T);let Ye=Math.max(de.length-1,0),ye=de[Ye];d({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:Ye}:void 0})},"U"),e[18]=v,e[19]=d,e[20]=$,e[21]=T,e[22]=F):F=e[22];let H=F,J;e[23]!==a.script?.runs||e[24]!==d?(J=l(K=>{let ae=a.script?.runs,de=ae?.[K];ae===void 0||de===void 0||d({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]=d,e[25]=J):J=e[25];let Z=J,ee;e[26]!==H?(ee=l(()=>{ue(H("results"))},"ee"),e[26]=H,e[27]=ee):ee=e[27];let te=ee,ie;e[28]!==a.pane||e[29]!==H?(ie=l(()=>{ue(H(a.pane))},"ie"),e[28]=a.pane,e[29]=H,e[30]=ie):ie=e[30];let V;e[31]!==D||e[32]!==L||e[33]!==A||e[34]!==ie?(V={onSubmit:ie,probe:D,schema:L,setDraft:A},e[31]=D,e[32]=L,e[33]=A,e[34]=ie,e[35]=V):V=e[35];let Q=kn(V),{closeAutocomplete:ne}=Q,re;e[36]!==v||e[37]!==A?(re=l(()=>{A(Tt(v))},"se"),e[36]=v,e[37]=A,e[38]=re):re=e[38];let oe=re,se;e[39]!==ne||e[40]!==u?(se=l(K=>{ne(),u(K)},"le"),e[39]=ne,e[40]=u,e[41]=se):se=e[41];let le=se,W;e[42]!==d?(W=l(()=>{d({pane:"results"})},"H"),e[42]=d,e[43]=W):W=e[43];let U=W,Y;e[44]!==H?(Y=l(()=>{ue(H("explain"))},"z"),e[44]=H,e[45]=Y):Y=e[45];let X=Y,fe;e[46]!==d?(fe=l(()=>{d({pane:"chart"})},"me"),e[46]=d,e[47]=fe):fe=e[47];let Ae=fe,Te;e[48]!==O||e[49]!==E?(Te=l(()=>{O(!E)},"ke"),e[48]=O,e[49]=E,e[50]=Te):Te=e[50];let $e=Te,Be=E?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",He=E?"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]!==b||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,c.jsx)(Jn,{activeId:b,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]=b,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,c.jsx)(sr,{model:o,onSelect:le}),e[66]=o,e[67]=le,e[68]=pe):pe=e[68];let be;e[69]!==M||e[70]!==P||e[71]!==v||e[72]!==x||e[73]!==A||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,c.jsx)(Gn,{assistant:M,autocomplete:Q.autocompleteState,diagnostics:P,draft:v,editorRef:Q.editorRef,failed:x,gutterRef:Q.gutterRef,handlers:Q.handlers,listboxId:Q.listboxId,onGenerated:A,onPickSuggestion:Q.onPickSuggestion,onRevealDiagnostic:Q.revealDiagnostic,overlayRef:Q.overlayRef}),e[69]=M,e[70]=P,e[71]=v,e[72]=x,e[73]=A,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]!==M||e[84]!==S||e[85]!==oe||e[86]!==j||e[87]!==k||e[88]!==te||e[89]!==Z||e[90]!==a.script||e[91]!==q||e[92]!==He||e[93]!==C||e[94]!==T||e[95]!==Ae||e[96]!==X||e[97]!==U||e[98]!==E||e[99]!==R||e[100]!==$e?(ge=(0,c.jsx)(Zn,{assistant:M,chart:k,className:He,error:S,onFormat:oe,onInferChart:j,onRun:te,onSelectStatement:Z,onShardKeyChange:_,onShowChart:Ae,onShowExplain:X,onShowResults:U,onToggleSplit:$e,pane:R,result:q,running:C,script:a.script,shardKey:T,splitView:E}),e[83]=M,e[84]=S,e[85]=oe,e[86]=j,e[87]=k,e[88]=te,e[89]=Z,e[90]=a.script,e[91]=q,e[92]=He,e[93]=C,e[94]=T,e[95]=Ae,e[96]=X,e[97]=U,e[98]=E,e[99]=R,e[100]=$e,e[101]=ge):ge=e[101];let xe;e[102]!==be||e[103]!==ge||e[104]!==Be?(xe=(0,c.jsxs)("div",{className:Be,children:[be,ge]}),e[102]=be,e[103]=ge,e[104]=Be,e[105]=xe):xe=e[105];let ve;e[106]!==pe||e[107]!==xe?(ve=(0,c.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 Ie;return e[109]!==he||e[110]!==ve?(Ie=(0,c.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]=Ie):Ie=e[111],Ie},"Rs");export{kr as SqlEditorPanel};
|
|
4
|
+
`);return e.join("")},"st"),Ct=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,Tt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|replace|truncate|update|vacuum)\b/iu,It=/^\w+/u,Rt=/;\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=n.replace(Rt,""),o=(ut(t)??t).indexOf(";");if(o!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+o};let r="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!Ct.test(t))return{code:"SQL_NOT_READONLY",length:It.exec(t)?.[0].length??1,message:r,offset:e};let a=Tt.exec(t);if(a!==null)return{code:"SQL_NOT_READONLY",length:a[0].length,message:`${r} (\`${a[0].toUpperCase()}\` is not allowed)`,offset:e+a.index}},"_t"),_t=/^explain\b/iu,Ot=l(s=>_t.test(s.slice(mt(s)))?s:`EXPLAIN QUERY PLAN ${s}`,"Dt"),Fe=l((s,e)=>{let n=s.trim();if(n==="")return[];let t=e+s.indexOf(n),o=Lt(n);return[o===void 0?{offset:t,sql:n}:{offset:t,rejection:o,sql:n}]},"Qe"),ft=l(s=>{let e=ut(s);if(e===void 0)return Fe(s,0);let n=[],t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(n.push(...Fe(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"],Me=String.fromCodePoint(0),At=new RegExp(`${Me}${String.raw`(\d+)`}${Me}`,"gu"),$t=Dt.map(s=>({pattern:new RegExp(String.raw`\b${s.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:s})),Bt=Mt.map(s=>({pattern:new RegExp(String.raw`\s+${s.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
5
|
+
${s}`})),Ht=l(s=>{let e=[],n=s.replaceAll(/'(?:[^']|'')*'/gu,t=>(e.push(t),`${Me}${(e.length-1).toString()}${Me}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:t,replacement:o}of $t)n=n.replaceAll(t,o);for(let{pattern:t,replacement:o}of Bt)n=n.replaceAll(t,o);return n=n.replaceAll(At,(t,o)=>e[Number(o)]??""),n},"Wt"),Wt=/\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,jt=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),Qt=/[^\n]/gu,Ft=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},"zt"),zt=l(s=>{let e="",n=0;for(;n<s.length;){let t=Ft(s,n);t===-1?(e+=s.slice(n,n+1),n+=1):(e+=s.slice(n,t).replaceAll(Qt," "),n=t)}return e},"Yt"),Ut=l(s=>{let e=new Set;for(let n of s.matchAll(Pt))e.add((n[1]??"").toLowerCase());return e},"Kt"),Yt=l((s,e)=>{let n=new Map;for(let t of s.matchAll(Wt)){let o=(t[1]??"").toLowerCase(),r=(t[2]??"").toLowerCase();e.has(o)&&(n.set(o,o),r!==""&&!jt.has(r)&&n.set(r,o))}return n},"Gt"),ht=l((s,e)=>{let n=zt(s),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:Ut(n),masked:n,targets:Yt(n,t)}},"rt"),Gt=/^(?:__lunora|sqlite_)/iu,Kt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Vt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Xt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Jt=l((s,e,n)=>{let t=[];for(let o of s.matchAll(Kt)){let r=o[1]??"",a=r.toLowerCase();!e.has(a)&&!n.has(a)&&!Xt.has(a)&&!Gt.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},"en"),Zt=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(d=>d.toLowerCase())));for(let r of s.matchAll(Vt)){let a=(r[1]??"").toLowerCase(),d=r[2]??"",i=n.get(a),u=i===void 0?void 0:o.get(i);u!==void 0&&!u.has(d.toLowerCase())&&t.push({length:d.length,message:`\`${i??""}\` has no column \`${d}\``,offset:r.index+r[0].length-d.length,severity:"error",source:"schema"})}return t},"tn"),en=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:d}=r;if(d!==void 0){d.code!=="SQL_EMPTY"&&o.push({length:d.length,message:d.message,offset:d.offset===void 0?a:a+d.offset,severity:"error",source:"gate"});continue}let{ctes:i,masked:u,targets:p}=ht(r.sql,e.tables);o.push(...[...Jt(u,t,i),...Zt(u,e,p)].map(h=>({...h,offset:h.offset===void 0?a:a+h.offset})))}return o},"nn"),tn=we(Ne.lintSql),nn=600,rn=l((s,e,n)=>{let t=Ee(),[o,r]=(0,z.useState)([]),a=(0,z.useMemo)(()=>en(s,e),[s,e]),d=et(s,nn),i=a.some(h=>h.source==="gate")||d.trim()==="",u=(0,z.useCallback)(async h=>{try{let g=await t.query(tn,{sql:d},ke(n));h.cancelled||r(g.diagnostics??[])}catch{h.cancelled||r([])}},[t,d,n]);(0,z.useEffect)(()=>{if(i){r([]);return}let h={cancelled:!1};return ue(u(h)),()=>{h.cancelled=!0}},[u,i]);let p=d===s;return(0,z.useMemo)(()=>p?[...a,...o]:a,[a,o,p])},"ln"),Oe=8,on=["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"],sn=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),ln=/[\w$]/,pt=l(s=>s!==void 0&&ln.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(".")||sn.has(bt(n).toUpperCase())},"Je"),an=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},"dn"),ze=l((s,e)=>s.toLowerCase().startsWith(e.toLowerCase()),"ze"),lt=l((s,e,n,t)=>{let o=[];for(let r of s)if(ze(r,e)&&(o.push(t(r)),o.length>=n))break;return o},"Ve"),cn=l((s,e,n)=>{let t=new Map;for(let[o,r]of Object.entries(s.columns))for(let a of r)if(ze(a,e)&&!t.has(a)&&(t.set(a,o),t.size>=n))return[...t].map(([d,i])=>({detail:i,kind:"column",label:d}));return[...t].map(([o,r])=>({detail:r,kind:"column",label:o}))},"un"),dn=l((s,e,n)=>{let t=gt(s,e),o=an(s,t.start,n.tables);if(o!==void 0){let i=n.columns[o]??n.columns[o.toLowerCase()]??[];return lt(i,t.text,Oe,u=>({detail:o,kind:"column",label:u}))}if(t.text===""&&!st(s,t.start))return[];let r=lt(n.tables,t.text,Oe,i=>({kind:"table",label:i})),a=cn(n,t.text,Oe),d=on.flatMap(i=>t.text!==""&&ze(i,t.text)&&i.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:i}]:[]);return(st(s,t.start)?[...a,...r,...d]:[...r,...a,...d]).slice(0,Oe)},"fn"),un=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}},"mn"),mn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],fn=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 mn)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,d=r.offsetTop-s.scrollTop;return t.remove(),{left:a,top:d}},"pn"),hn=l((s,e,n)=>{let t=(0,G.c)(16),[o,r]=(0,z.useState)(null),a;t[0]!==s||t[1]!==e?(a=l((v,b)=>{let k=dn(v,b,s);if(k.length===0){r(null);return}let S=e.current,{left:x,top:q}=S===null?{left:0,top:0}:fn(S,b);r(C=>C!==null&&C.active===0&&C.left===x&&C.top===q&&C.suggestions.length===k.length&&C.suggestions.every((R,T)=>{let _=k.at(T);return R.kind===_?.kind&&R.label===_.label&&R.detail===_.detail})?C:{active:0,left:x,suggestions:k,top:q})},"r"),t[0]=s,t[1]=e,t[2]=a):a=t[2];let d=a,i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=l(()=>{r(null)},"c"),t[3]=i):i=t[3];let u=i,p;t[4]===Symbol.for("react.memo_cache_sentinel")?(p=l(v=>{r(b=>{if(b===null)return b;let k=b.suggestions.length,S=(b.active+v+k)%k;return{...b,active:S}})},"m"),t[4]=p):p=t[4];let h=p,g;t[5]!==n||t[6]!==o||t[7]!==e?(g=l(v=>{let b=e.current;if(o===null||b===null)return!1;let k=o.suggestions[v??o.active];if(k===void 0)return!1;let S=un(b.value,b.selectionStart,k);return n(S.value),r(null),requestAnimationFrame(()=>{let x=e.current;x!==null&&(x.focus(),x.setSelectionRange(S.caret,S.caret))}),!0},"f"),t[5]=n,t[6]=o,t[7]=e,t[8]=g):g=t[8];let y=g,m;t[9]!==y?(m=l(()=>y(),"d"),t[9]=y,t[10]=m):m=t[10];let w=m,f;return t[11]!==w||t[12]!==y||t[13]!==d||t[14]!==o?(f={close:u,commit:w,commitAt:y,move:h,refresh:d,state:o},t[11]=w,t[12]=y,t[13]=d,t[14]=o,t[15]=f):f=t[15],f},"bn"),pn={column:"column",keyword:"keyword",table:"table"},bn=20,gn=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+bn},e[0]=o,e[1]=a):a=e[1];let d=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 p;e[8]!==n||e[9]!==t||e[10]!==o.active||e[11]!==r?(p=l((h,g)=>(0,c.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(y=>{y.preventDefault(),t(g)},"onMouseDown"),role:"option",children:[(0,c.jsx)("span",{className:"truncate font-mono",children:h.label}),h.detail!==void 0&&(0,c.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:h.detail}),(0,c.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:r(pn[h.kind])})]},`${h.kind}:${h.label}`),"m"),e[8]=n,e[9]=t,e[10]=o.active,e[11]=r,e[12]=p):p=e[12],i=o.suggestions.map(p),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 u;return e[13]!==n||e[14]!==d||e[15]!==i?(u=(0,c.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:d,children:i}),e[13]=n,e[14]=d,e[15]=i,e[16]=u):u=e[16],u},"vn"),xn=we(Ne.listTables),vn=we(Ne.readTablePage),yn=l(s=>{let e=(0,G.c)(16),n=Ee(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];let[o,r]=(0,z.useState)(t),a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={},e[1]=a):a=e[1];let[d,i]=(0,z.useState)(a),u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[2]=u):u=e[2];let p=(0,z.useRef)(u),h,g;e[3]!==n||e[4]!==s?(h=l(()=>{let b={cancelled:!1};return ue((async()=>{try{let k=await n.query(xn,{},ke(s));b.cancelled||(r(k.map(wn)),i({}),p.current=new Set)}catch{b.cancelled||(r([]),i({}),p.current=new Set)}})()),()=>{b.cancelled=!0}},"g"),g=[n,s],e[3]=n,e[4]=s,e[5]=h,e[6]=g):(h=e[5],g=e[6]),(0,z.useEffect)(h,g);let y;e[7]!==n||e[8]!==s?(y=l(b=>{p.current.has(b)||(p.current.add(b),ue((async()=>{try{let k=await n.query(vn,{limit:1,offset:0,table:b},ke(s));i(S=>({...S,[b]:k.columns}))}catch{p.current.delete(b)}})()))},"v"),e[7]=n,e[8]=s,e[9]=y):y=e[9];let m=y,w;e[10]!==d||e[11]!==o?(w={columns:d,tables:o},e[10]=d,e[11]=o,e[12]=w):w=e[12];let f=w,v;return e[13]!==m||e[14]!==f?(v={probe:m,schema:f},e[13]=m,e[14]=f,e[15]=v):v=e[15],v},"wn"),Qe=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,Sn=l(s=>{let e=new Set;Qe.lastIndex=0;let n=Qe.exec(s);for(;n!==null;)e.add(n[1]??n[2]),n=Qe.exec(s);return[...e]},"Cn");function wn(s){return s.name}l(wn,"Nn");var kn=l(s=>{let e=(0,G.c)(34),{onSubmit:n,probe:t,schema:o,setDraft:r}=s,a=(0,z.useId)(),d=(0,z.useRef)(null),i=(0,z.useRef)(null),u=(0,z.useRef)(null),p=hn(o,u,r),{close:h,commit:g,commitAt:y,move:m,refresh:w,state:f}=p,v;e[0]!==y?(v=l(N=>{y(N)},"x"),e[0]=y,e[1]=v):v=e[1];let b=v,k;e[2]!==w?(k=l(()=>{let N=u.current;N!==null&&N===document.activeElement&&w(N.value,N.selectionStart)},"C"),e[2]=w,e[3]=k):k=e[3];let S;e[4]!==w||e[5]!==o?(S=[w,o],e[4]=w,e[5]=o,e[6]=S):S=e[6],(0,z.useEffect)(k,S);let x;e[7]!==t||e[8]!==w||e[9]!==r?(x=l(N=>{let{selectionStart:j,value:I}=N.target;r(I);for(let $ of Sn(I))t($);w(I,j)},"p"),e[7]=t,e[8]=w,e[9]=r,e[10]=x):x=e[10];let q=x,C;e[11]!==w?(C=l(N=>{let j=N.currentTarget;w(j.value,j.selectionStart)},"N"),e[11]=w,e[12]=C):C=e[12];let R=C,T;e[13]!==f||e[14]!==h||e[15]!==g||e[16]!==m||e[17]!==n?(T=l(N=>{if(f!==null){if(N.key==="ArrowDown"){N.preventDefault(),m(1);return}if(N.key==="ArrowUp"){N.preventDefault(),m(-1);return}if(N.key==="Escape"){N.preventDefault(),h();return}if((N.key==="Enter"||N.key==="Tab")&&!N.metaKey&&!N.ctrlKey&&g()){N.preventDefault();return}}(N.metaKey||N.ctrlKey)&&N.key==="Enter"&&(N.preventDefault(),n())},"T"),e[13]=f,e[14]=h,e[15]=g,e[16]=m,e[17]=n,e[18]=T):T=e[18];let _=T,E;e[19]!==h?(E=l(()=>{requestAnimationFrame(()=>{h()})},"E"),e[19]=h,e[20]=E):E=e[20];let O=E,D;e[21]===Symbol.for("react.memo_cache_sentinel")?(D=l(N=>{let{scrollLeft:j,scrollTop:I}=N.currentTarget;d.current!==null&&(d.current.scrollTop=I),i.current!==null&&(i.current.scrollTop=I,i.current.scrollLeft=j)},"_"),e[21]=D):D=e[21];let L=D,B;e[22]===Symbol.for("react.memo_cache_sentinel")?(B=l(N=>{let j=u.current;j===null||N.offset===void 0||(j.focus(),j.setSelectionRange(N.offset,N.offset+(N.length??0)))},"B"),e[22]=B):B=e[22];let A=B,P;e[23]!==q||e[24]!==O||e[25]!==_||e[26]!==R?(P={onBlur:O,onChange:q,onKeyDown:_,onScroll:L,onSelect:R},e[23]=q,e[24]=O,e[25]=_,e[26]=R,e[27]=P):P=e[27];let M;return e[28]!==f||e[29]!==h||e[30]!==a||e[31]!==b||e[32]!==P?(M={autocompleteState:f,closeAutocomplete:h,handlers:P,listboxId:a,onPickSuggestion:b,editorRef:u,gutterRef:d,overlayRef:i,revealDiagnostic:A},e[28]=f,e[29]=h,e[30]=a,e[31]=b,e[32]=P,e[33]=M):M=e[33],M},"kn"),Nn="lunora-studio-sql-tabs",qn="lunora-studio-sql-active-tab",Ue=12,Ce=l((s="",e="")=>({activeId:null,id:Pe("tab"),name:e,sql:s}),"we"),Cn=l(()=>_e(qn,""),"Rn"),Tn=l(s=>{let e=(0,G.c)(16),[n,t]=Le(Nn),[o,r]=Cn(),[a]=(0,z.useState)(s),d,i;e[0]!==a||e[1]!==t||e[2]!==n.length?(d=l(()=>{n.length===0&&t([a])},"i"),i=[a,t,n.length],e[0]=a,e[1]=t,e[2]=n.length,e[3]=d,e[4]=i):(d=e[3],i=e[4]),(0,z.useEffect)(d,i);let u;e[5]!==a||e[6]!==n?(u=n.length===0?[a]:n,e[5]=a,e[6]=n,e[7]=u):u=e[7];let p=u,h;e[8]!==o||e[9]!==p?(h=p.some(m=>m.id===o)?o:p[0]?.id??"",e[8]=o,e[9]=p,e[10]=h):h=e[10];let g=h,y;return e[11]!==g||e[12]!==r||e[13]!==t||e[14]!==p?(y={activeId:g,setActiveId:r,setTabs:t,tabs:p},e[11]=g,e[12]=r,e[13]=t,e[14]=p,e[15]=y):y=e[15],y},"Ln"),xt=l(s=>s.activeId===null&&s.sql.trim()!=="","dt"),In=l((s,e)=>[...s,e].slice(-Ue),"In"),Rn=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}},"qn"),En=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}},"An"),Ln=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"),_n=l(s=>{let e=s();return{activeId:e.id,tabs:[e]}},"On"),On=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]},"Dn"),at={error:null,pane:"results",result:null,running:!1},Dn=l(s=>{let e=(0,G.c)(66),{activeId:n,setActiveId:t,setTabs:o,tabs:r}=Tn(s),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let[d,i]=(0,z.useState)(a),[u,p]=(0,z.useState)(null),[h,g]=(0,z.useState)(null),y;e[1]!==n||e[2]!==r?(y=r.find(W=>W.id===n)??r[0]??Ce(),e[1]=n,e[2]=r,e[3]=y):y=e[3];let m=y,w=d[m.id]??at,f;e[4]!==m.id||e[5]!==o?(f=l(W=>{o(U=>U.map(Y=>Y.id===m.id?{...Y,...W}:Y))},"u"),e[4]=m.id,e[5]=o,e[6]=f):f=e[6];let v=f,b;e[7]!==m.id?(b=l(W=>{i(U=>{let Y=U[m.id]??at;return{...U,[m.id]:{...Y,...W}}})},"h"),e[7]=m.id,e[8]=b):b=e[8];let k=b,S;e[9]!==t||e[10]!==o||e[11]!==r.length?(S=l(()=>{if(r.length>=Ue)return;let W=Ce();o(U=>In(U,W)),t(W.id)},"y"),e[9]=t,e[10]=o,e[11]=r.length,e[12]=S):S=e[12];let x=S,q;e[13]!==t||e[14]!==o?(q=l(W=>{p(null),g(null),o(W.tabs),t(W.activeId);let U=new Set(W.tabs.map(Mn));i(Y=>Object.fromEntries(Object.entries(Y).filter(X=>{let[fe]=X;return U.has(fe)})))},"k"),e[13]=t,e[14]=o,e[15]=q):q=e[15];let C=q,R;e[16]!==C||e[17]!==r?(R=l(W=>{C(Rn(r,W,Ce))},"L"),e[16]=C,e[17]=r,e[18]=R):R=e[18];let T=R,_;e[19]!==n||e[20]!==C||e[21]!==r?(_=l((W,U)=>{C(W==="others"?En(r,U):W==="right"?Ln(r,U,n):_n(Ce))},"q"),e[19]=n,e[20]=C,e[21]=r,e[22]=_):_=e[22];let E=_,O;e[23]!==E||e[24]!==u||e[25]!==r?(O=l(W=>{u!==null&&(On(W,r,u.id).some(An)?g(W):E(W,u.id))},"A"),e[23]=E,e[24]=u,e[25]=r,e[26]=O):O=e[26];let D=O,L;e[27]===Symbol.for("react.memo_cache_sentinel")?(L=l((W,U)=>{U.preventDefault(),g(null),p({id:W,x:U.clientX,y:U.clientY})},"I"),e[27]=L):L=e[27];let B=L,A;e[28]===Symbol.for("react.memo_cache_sentinel")?(A=l(()=>{p(null),g(null)},"D"),e[28]=A):A=e[28];let P=A,M;e[29]===Symbol.for("react.memo_cache_sentinel")?(M=l(W=>{W.preventDefault(),p(null),g(null)},"O"),e[29]=M):M=e[29];let N=M,j;e[30]!==D?(j=l(()=>{D("others")},"W"),e[30]=D,e[31]=j):j=e[31];let I=j,$;e[32]!==D?($=l(()=>{D("right")},"M"),e[32]=D,e[33]=$):$=e[33];let F=$,H;e[34]!==D?(H=l(()=>{D("all")},"$"),e[34]=D,e[35]=H):H=e[35];let J=H,Z;e[36]!==E||e[37]!==h||e[38]!==u?(Z=l(()=>{u!==null&&h!==null&&E(h,u.id),g(null)},"Z"),e[36]=E,e[37]=h,e[38]=u,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]!==u?(V=u===null?void 0:{left:u.x,top:u.y},e[41]=u,e[42]=V):V=e[42];let Q=V,ne;e[43]!==o?(ne=l(W=>{o(U=>U.map(Y=>Y.activeId===W?{...Y,activeId:null}:Y))},"ne"),e[43]=o,e[44]=ne):ne=e[44];let re=ne,oe;e[45]!==o?(oe=l((W,U)=>{o(Y=>Y.map(X=>X.id===W?{...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]!==x||e[50]!==T||e[51]!==ee||e[52]!==J||e[53]!==I||e[54]!==F||e[55]!==w||e[56]!==k||e[57]!==v||e[58]!==h||e[59]!==se||e[60]!==t||e[61]!==u||e[62]!==Q||e[63]!==r||e[64]!==re?(le={activeTab:m,activeTabId:n,addEditorTab:x,cancelBulk:ie,closeEditorTab:T,closeTabMenu:P,confirmBulk:ee,menuStyle:Q,onBackdropContextMenu:N,onCloseAll:J,onCloseOthers:I,onCloseToRight:F,openTabMenu:B,output:w,patchActiveOutput:k,patchActiveTab:v,pendingBulk:h,renameTab:se,setActiveTabId:t,tabMenu:u,tabs:r,unlinkQuery:re},e[47]=m,e[48]=n,e[49]=x,e[50]=T,e[51]=ee,e[52]=J,e[53]=I,e[54]=F,e[55]=w,e[56]=k,e[57]=v,e[58]=h,e[59]=se,e[60]=t,e[61]=u,e[62]=Q,e[63]=r,e[64]=re,e[65]=le):le=e[65],le},"Mn");function Mn(s){return s.id}l(Mn,"$n");function An(s){return xt(s)}l(An,"Bn");var $n="lunora-studio-sql-queries",Se="lunora-studio-sql-history",Bn="lunora-studio-sql-remember-history",Hn=25,Wn=l(s=>{let e=(0,G.c)(41),{loadIntoActiveTab:n,unlinkQuery:t}=s,o=ce(),[r,a]=Le($n),[d,i]=_e(Bn,!1),[u,p]=Le(Se,d?"local":"session"),h,g;e[0]!==d?(h=l(()=>{d||qe(Se,"local")},"g"),g=[d],e[0]=d,e[1]=h,e[2]=g):(h=e[1],g=e[2]),(0,z.useEffect)(h,g);let[y,m]=(0,z.useState)(""),w=(0,z.useRef)(null),f;e[3]!==p?(f=l(I=>{p($=>$[0]?.sql===I?$:[{at:Date.now(),sql:I},...$.filter(F=>F.sql!==I)].slice(0,Hn))},"u"),e[3]=p,e[4]=f):f=e[4];let v=f,b;e[5]!==n||e[6]!==a||e[7]!==o?(b=l(()=>{let I={id:Pe("q"),name:o("Untitled query"),sql:""};a($=>[I,...$]),n("",I.id)},"h"),e[5]=n,e[6]=a,e[7]=o,e[8]=b):b=e[8];let k=b,S;e[9]!==n||e[10]!==r?(S=l(I=>{let $=r.find(F=>F.id===I);$!==void 0&&(n($.sql,I),w.current?.querySelector(`[data-testid="sql-query-${I}"]`)?.scrollIntoView({block:"nearest"}))},"y"),e[9]=n,e[10]=r,e[11]=S):S=e[11];let x=S,q;e[12]!==a||e[13]!==t?(q=l(I=>{a($=>$.filter(F=>F.id!==I)),t(I)},"k"),e[12]=a,e[13]=t,e[14]=q):q=e[14];let C=q,R;e[15]!==n?(R=l(I=>{n(I.currentTarget.dataset.sql??"",null)},"L"),e[15]=n,e[16]=R):R=e[16];let T=R,_;e[17]!==n?(_=l(I=>{n(I.currentTarget.dataset.sql??"",null)},"q"),e[17]=n,e[18]=_):_=e[18];let E=_,O;e[19]!==p?(O=l(()=>{p([]),qe(Se,"local"),qe(Se,"session")},"A"),e[19]=p,e[20]=O):O=e[20];let D=O,L;e[21]!==u||e[22]!==i?(L=l(I=>{Ve(Se,u,I?"local":"session"),I||qe(Se,"local"),i(I)},"I"),e[21]=u,e[22]=i,e[23]=L):L=e[23];let B=L,A;e[24]===Symbol.for("react.memo_cache_sentinel")?(A=l(I=>{m(I.target.value)},"D"),e[24]=A):A=e[24];let P=A,M;e[25]!==a?(M=l((I,$)=>{a(F=>F.map(H=>H.id===I?{...H,sql:$}:H))},"O"),e[25]=a,e[26]=M):M=e[26];let N=M,j;return e[27]!==D||e[28]!==C||e[29]!==u||e[30]!==E||e[31]!==T||e[32]!==k||e[33]!==r||e[34]!==v||e[35]!==d||e[36]!==y||e[37]!==x||e[38]!==B||e[39]!==N?(j={clearHistory:D,deleteQuery:C,history:u,listRef:w,loadFromHistory:E,loadTemplate:T,newQuery:k,onSearchChange:P,queries:r,recordHistory:v,rememberHistory:d,search:y,selectQuery:x,setRememberHistory:B,updateQuerySql:N},e[27]=D,e[28]=C,e[29]=u,e[30]=E,e[31]=T,e[32]=k,e[33]=r,e[34]=v,e[35]=d,e[36]=y,e[37]=x,e[38]=B,e[39]=N,e[40]=j):j=e[40],j},"Fn"),vt="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Pn=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},"Qn"),jn=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.","Un"),Qn=l(s=>{let e=(0,G.c)(51),{assistant:n,failed:t,onGenerated:o}=s,r=ce(),[a,d]=(0,z.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 u=i,p;if(e[2]!==n||e[3]!==t||e[4]!==o||e[5]!==u||e[6]!==a||e[7]!==r){let h=n.reason("sql"),g;e[9]!==n||e[10]!==t||e[11]!==o||e[12]!==a?(g=l(E=>{let O=a.trim();O===""&&!E||ue((async()=>{let D=await n.generate(O===""?"fix the failing statement":O,E?t:void 0);D!==void 0&&o(D)})())},"f"),e[9]=n,e[10]=t,e[11]=o,e[12]=a,e[13]=g):g=e[13];let y=g,m;e[14]!==r?(m=r("Describe the query you want"),e[14]=r,e[15]=m):m=e[15];let w;e[16]===Symbol.for("react.memo_cache_sentinel")?(w=l(E=>{d(E.target.value)},"S"),e[16]=w):w=e[16];let f;e[17]!==y?(f=l(E=>{E.key==="Enter"&&(E.preventDefault(),y(!1))},"u"),e[17]=y,e[18]=f):f=e[18];let v;e[19]!==r?(v=r("Describe the query you want"),e[19]=r,e[20]=v):v=e[20];let b;e[21]!==u||e[22]!==a||e[23]!==m||e[24]!==f||e[25]!==v?(b=(0,c.jsx)(Ge,{"aria-label":m,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:u,onChange:w,onKeyDown:f,placeholder:v,value:a}),e[21]=u,e[22]=a,e[23]=m,e[24]=f,e[25]=v,e[26]=b):b=e[26];let k=u&&"opacity-60",S;e[27]!==k?(S=me("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",k),e[27]=k,e[28]=S):S=e[28];let x;e[29]!==u||e[30]!==a?(x=u||a.trim()==="",e[29]=u,e[30]=a,e[31]=x):x=e[31];let q;e[32]!==y?(q=l(()=>{y(!1)},"k"),e[32]=y,e[33]=q):q=e[33];let C;e[34]!==u||e[35]!==r?(C=r(u?"Thinking\u2026":"Draft SQL"),e[34]=u,e[35]=r,e[36]=C):C=e[36];let R;e[37]!==S||e[38]!==x||e[39]!==q||e[40]!==C?(R=(0,c.jsx)("button",{className:S,"data-testid":"sql-assistant-generate",disabled:x,onClick:q,type:"button",children:C}),e[37]=S,e[38]=x,e[39]=q,e[40]=C,e[41]=R):R=e[41];let T;e[42]!==t||e[43]!==u||e[44]!==y||e[45]!==r?(T=t!==void 0&&(0,c.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:u,onClick:l(()=>{y(!0)},"onClick"),type:"button",children:r("Fix this")}),e[42]=t,e[43]=u,e[44]=y,e[45]=r,e[46]=T):T=e[46];let _;e[47]!==R||e[48]!==T||e[49]!==b?(_=(0,c.jsxs)("div",{className:"flex items-center gap-2",children:[b,R,T]}),e[47]=R,e[48]=T,e[49]=b,e[50]=_):_=e[50],p=(0,c.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[_,h!==void 0&&(0,c.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:jn(h)})]}),e[2]=n,e[3]=t,e[4]=o,e[5]=u,e[6]=a,e[7]=r,e[8]=p}else p=e[8];return p},"jn"),Fn=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 u=Pn(n,t.length);if(u.length===0){a=null;break e}r=[];let p=0;for(let[h,g]of u.entries())g.start>p&&r.push(t.slice(p,g.start)),r.push((0,c.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()}-${h.toString()}`)),p=g.end;r.push(t.slice(p))}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 d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=me("pointer-events-none absolute inset-0 overflow-hidden text-transparent",vt),e[4]=d):d=e[4];let i;return e[5]!==r||e[6]!==o?(i=(0,c.jsx)("div",{"aria-hidden":"true",className:d,"data-testid":"sql-diagnostics-overlay",ref:o,children:r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i},"zn"),zn={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Un=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((u,p)=>(0,c.jsx)("li",{children:(0,c.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(u)},"onClick"),type:"button",children:[(0,c.jsx)("span",{className:me("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",u.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:zn[u.source]}),(0,c.jsx)("span",{className:"min-w-0 text-muted-foreground",children:u.message})]})},`${u.source}-${(u.offset??p).toString()}-${p.toString()}`),"c"),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 d;return e[7]!==r||e[8]!==a?(d=(0,c.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]=d):d=e[9],d},"Kn"),Yn={minWidth:"2.75rem",paddingInline:"0.5rem"},Gn=l(s=>{let e=(0,G.c)(64),{assistant:n,autocomplete:t,diagnostics:o,draft:r,failed:a,handlers:d,editorRef:i,gutterRef:u,listboxId:p,onGenerated:h,onPickSuggestion:g,onRevealDiagnostic:y,overlayRef:m}=s,w=ce(),f,v,b,k,S,x,q,C;if(e[0]!==n||e[1]!==r||e[2]!==a||e[3]!==u||e[4]!==h){let j=r.split(`
|
|
7
|
+
`).length;q="flex min-h-0 min-w-0 flex-1 flex-col",e[13]!==n||e[14]!==a||e[15]!==h?(C=(0,c.jsx)(Qn,{assistant:n,failed:a,onGenerated:h}),e[13]=n,e[14]=a,e[15]=h,e[16]=C):C=e[16],x="flex min-h-0 min-w-0 flex-1",f="true",v="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",b=u,k=Yn,S=Array.from({length:j},Kn),e[0]=n,e[1]=r,e[2]=a,e[3]=u,e[4]=h,e[5]=f,e[6]=v,e[7]=b,e[8]=k,e[9]=S,e[10]=x,e[11]=q,e[12]=C}else f=e[5],v=e[6],b=e[7],k=e[8],S=e[9],x=e[10],q=e[11],C=e[12];let R;e[17]!==f||e[18]!==v||e[19]!==b||e[20]!==k||e[21]!==S?(R=(0,c.jsx)("div",{"aria-hidden":f,className:v,ref:b,style:k,children:S}),e[17]=f,e[18]=v,e[19]=b,e[20]=k,e[21]=S,e[22]=R):R=e[22];let T;e[23]!==o||e[24]!==r||e[25]!==m?(T=(0,c.jsx)(Fn,{diagnostics:o,draft:r,scrollRef:m}),e[23]=o,e[24]=r,e[25]=m,e[26]=T):T=e[26];let _;e[27]!==t||e[28]!==p?(_=t===null?void 0:`${p}-opt-${t.active.toString()}`,e[27]=t,e[28]=p,e[29]=_):_=e[29];let E=t===null?void 0:p,O=t!==null,D;e[30]!==w?(D=w("SQL query"),e[30]=w,e[31]=D):D=e[31];let L;e[32]!==r||e[33]!==i||e[34]!==d.onBlur||e[35]!==d.onChange||e[36]!==d.onKeyDown||e[37]!==d.onScroll||e[38]!==d.onSelect||e[39]!==_||e[40]!==E||e[41]!==O||e[42]!==D?(L=(0,c.jsx)("textarea",{"aria-activedescendant":_,"aria-autocomplete":"list","aria-controls":E,"aria-expanded":O,"aria-label":D,className:`relative size-full resize-none bg-transparent outline-none ${vt}`,"data-testid":"sql-input",onBlur:d.onBlur,onChange:d.onChange,onKeyDown:d.onKeyDown,onScroll:d.onScroll,onSelect:d.onSelect,placeholder:"SELECT * FROM \u2026",ref:i,role:"combobox",spellCheck:!1,value:r}),e[32]=r,e[33]=i,e[34]=d.onBlur,e[35]=d.onChange,e[36]=d.onKeyDown,e[37]=d.onScroll,e[38]=d.onSelect,e[39]=_,e[40]=E,e[41]=O,e[42]=D,e[43]=L):L=e[43];let B;e[44]!==t||e[45]!==p||e[46]!==g?(B=(0,c.jsx)(gn,{listboxId:p,onPick:g,state:t}),e[44]=t,e[45]=p,e[46]=g,e[47]=B):B=e[47];let A;e[48]!==T||e[49]!==L||e[50]!==B?(A=(0,c.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[T,L,B]}),e[48]=T,e[49]=L,e[50]=B,e[51]=A):A=e[51];let P;e[52]!==A||e[53]!==x||e[54]!==R?(P=(0,c.jsxs)("div",{className:x,children:[R,A]}),e[52]=A,e[53]=x,e[54]=R,e[55]=P):P=e[55];let M;e[56]!==o||e[57]!==y?(M=(0,c.jsx)(Un,{diagnostics:o,onSelect:y}),e[56]=o,e[57]=y,e[58]=M):M=e[58];let N;return e[59]!==P||e[60]!==M||e[61]!==q||e[62]!==C?(N=(0,c.jsxs)("div",{className:q,children:[C,P,M]}),e[59]=P,e[60]=M,e[61]=q,e[62]=C,e[63]=N):N=e[63],N},"Jn");function Kn(s,e){return(0,c.jsx)("div",{children:e+1},e)}l(Kn,"Vn");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;"}],Vn=l(s=>{let e=(0,G.c)(29),{active:n,onDelete:t,onSelect:o,query:r}=s,a=ce(),d;e[0]!==o||e[1]!==r.id?(d=l(()=>{o(r.id)},"i"),e[0]=o,e[1]=r.id,e[2]=d):d=e[2];let i=d,u;e[3]!==t||e[4]!==r.id?(u=l(q=>{q.stopPropagation(),t(r.id)},"a"),e[3]=t,e[4]=r.id,e[5]=u):u=e[5];let p=u,h=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",g;e[6]!==h?(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",h),e[6]=h,e[7]=g):g=e[7];let y=`sql-query-${r.id}`,m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=(0,c.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,c.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=m):m=e[8];let w;e[9]!==r.name?(w=(0,c.jsx)("span",{className:"truncate",children:r.name}),e[9]=r.name,e[10]=w):w=e[10];let f;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==y||e[15]!==w?(f=(0,c.jsxs)("button",{"aria-pressed":n,className:g,"data-testid":y,onClick:i,type:"button",children:[m,w]}),e[11]=n,e[12]=i,e[13]=g,e[14]=y,e[15]=w,e[16]=f):f=e[16];let v;e[17]!==a?(v=a("Delete query"),e[17]=a,e[18]=v):v=e[18];let b;e[19]!==a?(b=a("Delete query"),e[19]=a,e[20]=b):b=e[20];let k;e[21]===Symbol.for("react.memo_cache_sentinel")?(k=(0,c.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,c.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=k):k=e[21];let S;e[22]!==p||e[23]!==b||e[24]!==v?(S=(0,c.jsx)("button",{"aria-label":v,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:p,title:b,type:"button",children:k}),e[22]=p,e[23]=b,e[24]=v,e[25]=S):S=e[25];let x;return e[26]!==S||e[27]!==f?(x=(0,c.jsxs)("li",{className:"group/q flex items-center",children:[f,S]}),e[26]=S,e[27]=f,e[28]=x):x=e[28],x},"Xn"),it="sql-history-remember",Xn=l((s,e)=>{let n=e.trim().toLowerCase();return n===""?[...s]:s.filter(t=>t.name.toLowerCase().includes(n))},"Zn"),Jn=l(s=>{let e=(0,G.c)(66),{activeId:n,history:t,listRef:o,onClearHistory:r,onDelete:a,onLoadHistory:d,onLoadTemplate:i,onNew:u,onSearchChange:p,onSelect:h,onToggleRememberHistory:g,queries:y,rememberHistory:m,search:w}=s,f=ce(),v,b,k,S,x;if(e[0]!==n||e[1]!==o||e[2]!==a||e[3]!==u||e[4]!==p||e[5]!==h||e[6]!==g||e[7]!==y||e[8]!==w||e[9]!==f){let L=Xn(y,w),B;e[15]!==g?(B=l(H=>{g(H.target.checked)},"B"),e[15]=g,e[16]=B):B=e[16],v=B,k="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let A;e[17]!==f?(A=f("Search queries\u2026"),e[17]=f,e[18]=A):A=e[18];let P;e[19]!==p||e[20]!==w||e[21]!==A?(P=(0,c.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:p,placeholder:A,type:"text",value:w}),e[19]=p,e[20]=w,e[21]=A,e[22]=P):P=e[22];let M;e[23]!==f?(M=f("New query"),e[23]=f,e[24]=M):M=e[24];let N;e[25]!==f?(N=f("New query"),e[25]=f,e[26]=N):N=e[26];let j;e[27]===Symbol.for("react.memo_cache_sentinel")?(j=(0,c.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,c.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[27]=j):j=e[27];let I;e[28]!==u||e[29]!==M||e[30]!==N?(I=(0,c.jsx)("button",{"aria-label":M,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:u,title:N,type:"button",children:j}),e[28]=u,e[29]=M,e[30]=N,e[31]=I):I=e[31],e[32]!==I||e[33]!==P?(S=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[P,I]}),e[32]=I,e[33]=P,e[34]=S):S=e[34],b="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 F;e[37]!==$?(F=(0,c.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),e[37]=$,e[38]=F):F=e[38],x=(0,c.jsxs)("div",{children:[F,L.length===0?(0,c.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,c.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:L.map(H=>(0,c.jsx)(Vn,{active:n===H.id,onDelete:a,onSelect:h,query:H},H.id))})]}),e[0]=n,e[1]=o,e[2]=a,e[3]=u,e[4]=p,e[5]=h,e[6]=g,e[7]=y,e[8]=w,e[9]=f,e[10]=v,e[11]=b,e[12]=k,e[13]=S,e[14]=x}else v=e[10],b=e[11],k=e[12],S=e[13],x=e[14];let q;e[39]!==f?(q=f("Reference"),e[39]=f,e[40]=q):q=e[40];let C;e[41]!==q?(C=(0,c.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:q}),e[41]=q,e[42]=C):C=e[42];let R;e[43]!==i?(R=yt.map(L=>(0,c.jsx)("li",{children:(0,c.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,c.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,c.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,c.jsx)("ul",{className:"flex flex-col gap-px",children:R}),e[45]=R,e[46]=T):T=e[46];let _;e[47]!==C||e[48]!==T?(_=(0,c.jsxs)("div",{children:[C,T]}),e[47]=C,e[48]=T,e[49]=_):_=e[49];let E;e[50]!==t||e[51]!==r||e[52]!==d||e[53]!==v||e[54]!==m||e[55]!==f?(E=t.length>0&&(0,c.jsxs)("div",{children:[(0,c.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,c.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f("History")}),(0,c.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,c.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,c.jsx)("input",{checked:m,"data-testid":"sql-history-remember",id:it,onChange:v,type:"checkbox"}),f("Keep history on this browser")]}),(0,c.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(L=>(0,c.jsx)("li",{children:(0,c.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:d,title:L.sql,type:"button",children:[(0,c.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,c.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,c.jsx)("span",{className:"truncate font-mono",children:L.sql})]})},`${L.at.toString()}:${L.sql}`))})]}),e[50]=t,e[51]=r,e[52]=d,e[53]=v,e[54]=m,e[55]=f,e[56]=E):E=e[56];let O;e[57]!==b||e[58]!==E||e[59]!==x||e[60]!==_?(O=(0,c.jsxs)("div",{className:b,children:[x,_,E]}),e[57]=b,e[58]=E,e[59]=x,e[60]=_,e[61]=O):O=e[61];let D;return e[62]!==O||e[63]!==k||e[64]!==S?(D=(0,c.jsxs)("aside",{className:k,children:[S,O]}),e[62]=O,e[63]=k,e[64]=S,e[65]=D):D=e[65],D},"es"),De=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"),Zn=l(s=>{let e=(0,G.c)(96),{assistant:n,chart:t,className:o,error:r,onFormat:a,onInferChart:d,onRun:i,onSelectStatement:u,onShardKeyChange:p,onShowChart:h,onShowExplain:g,onShowResults:y,onToggleSplit:m,pane:w,result:f,running:v,script:b,shardKey:k,splitView:S}=s,x=ce(),q=w==="results",C;e[0]!==q?(C=De(q),e[0]=q,e[1]=C):C=e[1];let R;e[2]!==x?(R=x("Results"),e[2]=x,e[3]=R):R=e[3];let T;e[4]!==y||e[5]!==C||e[6]!==R?(T=(0,c.jsx)("button",{className:C,"data-testid":"sql-tab-results",onClick:y,type:"button",children:R}),e[4]=y,e[5]=C,e[6]=R,e[7]=T):T=e[7];let _=w==="chart",E;e[8]!==_?(E=De(_),e[8]=_,e[9]=E):E=e[9];let O;e[10]!==x?(O=x("Chart"),e[10]=x,e[11]=O):O=e[11];let D;e[12]!==h||e[13]!==E||e[14]!==O?(D=(0,c.jsx)("button",{className:E,"data-testid":"sql-tab-chart",onClick:h,type:"button",children:O}),e[12]=h,e[13]=E,e[14]=O,e[15]=D):D=e[15];let L;e[16]!==n||e[17]!==d||e[18]!==w||e[19]!==f||e[20]!==x?(L=!n.unavailable&&w==="chart"&&f!==null&&(0,c.jsx)("button",{className:De(!1),"data-testid":"sql-infer-chart",disabled:n.pending("chart"),onClick:d,type:"button",children:n.pending("chart")?x("Thinking\u2026"):x("Suggest chart")}),e[16]=n,e[17]=d,e[18]=w,e[19]=f,e[20]=x,e[21]=L):L=e[21];let B=w==="explain",A;e[22]!==B?(A=De(B),e[22]=B,e[23]=A):A=e[23];let P;e[24]!==x?(P=x("Explain"),e[24]=x,e[25]=P):P=e[25];let M;e[26]!==g||e[27]!==A||e[28]!==P?(M=(0,c.jsx)("button",{className:A,"data-testid":"sql-tab-explain",onClick:g,type:"button",children:P}),e[26]=g,e[27]=A,e[28]=P,e[29]=M):M=e[29];let N;e[30]!==x?(N=x("Split editor and results"),e[30]=x,e[31]=N):N=e[31];let j=`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 ${S?"bg-accent text-foreground":"text-muted-foreground"}`,I;e[32]!==x?(I=x("Split editor and results"),e[32]=x,e[33]=I):I=e[33];let $;e[34]===Symbol.for("react.memo_cache_sentinel")?($=(0,c.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,c.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,c.jsx)("path",{d:"M12 4v16"})]}),e[34]=$):$=e[34];let F;e[35]!==m||e[36]!==S||e[37]!==N||e[38]!==j||e[39]!==I?(F=(0,c.jsx)("button",{"aria-label":N,"aria-pressed":S,className:j,"data-testid":"sql-split-toggle",onClick:m,title:I,type:"button",children:$}),e[35]=m,e[36]=S,e[37]=N,e[38]=j,e[39]=I,e[40]=F):F=e[40];let H;e[41]!==f?(H=f!==null&&f.columns.length>0&&(0,c.jsx)(nt,{columns:f.columns,name:"query-result",rows:f.rows}),e[41]=f,e[42]=H):H=e[42];let J;e[43]!==x?(J=x("Format"),e[43]=x,e[44]=J):J=e[44];let Z;e[45]!==a||e[46]!==v||e[47]!==J?(Z=(0,c.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:v,onClick:a,type:"button",children:J}),e[45]=a,e[46]=v,e[47]=J,e[48]=Z):Z=e[48];let ee;e[49]!==p||e[50]!==k?(ee=(0,c.jsx)(Je,{onChange:p,testId:"sql-shard-input",value:k}),e[49]=p,e[50]=k,e[51]=ee):ee=e[51];let te;e[52]!==v||e[53]!==x?(te=x(v?"Running\u2026":"Run"),e[52]=v,e[53]=x,e[54]=te):te=e[54];let ie;e[55]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,c.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]!==v||e[58]!==te?(V=(0,c.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:v,onClick:i,type:"button",children:[te,ie]}),e[56]=i,e[57]=v,e[58]=te,e[59]=V):V=e[59];let Q;e[60]!==F||e[61]!==H||e[62]!==Z||e[63]!==ee||e[64]!==V?(Q=(0,c.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[F,H,Z,ee,V]}),e[60]=F,e[61]=H,e[62]=Z,e[63]=ee,e[64]=V,e[65]=Q):Q=e[65];let ne;e[66]!==M||e[67]!==Q||e[68]!==T||e[69]!==D||e[70]!==L?(ne=(0,c.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[T,D,L,M,Q]}),e[66]=M,e[67]=Q,e[68]=T,e[69]=D,e[70]=L,e[71]=ne):ne=e[71];let re;e[72]!==u||e[73]!==b?(re=b!==void 0&&(0,c.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:b.runs.map((Y,X)=>(0,c.jsx)("button",{"aria-pressed":X===b.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${X===b.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(()=>{u(X)},"onClick"),title:Y.sql,type:"button",children:X+1},`${X.toString()}:${Y.sql}`))}),e[72]=u,e[73]=b,e[74]=re):re=e[74];let oe;e[75]!==r?(oe=r!==null&&(0,c.jsx)(Ze,{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]!==x?(se=r===null&&f===null&&(0,c.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:x("Click Run to execute your query.")}),e[77]=r,e[78]=f,e[79]=x,e[80]=se):se=e[80];let le;e[81]!==t||e[82]!==r||e[83]!==w||e[84]!==f||e[85]!==x?(le=r===null&&f!==null&&(0,c.jsxs)("div",{"data-testid":"sql-result",children:[w==="chart"?(0,c.jsx)(rt,{axes:t,result:f}):(0,c.jsx)(ot,{result:f}),(0,c.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:f.truncated?x("Showing the first {max} of {count} rows.",{count:f.rowCount,max:f.rows.length}):x("{count} rows",{count:f.rowCount})})]}),e[81]=t,e[82]=r,e[83]=w,e[84]=f,e[85]=x,e[86]=le):le=e[86];let W;e[87]!==oe||e[88]!==se||e[89]!==le?(W=(0,c.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]=W):W=e[90];let U;return e[91]!==o||e[92]!==ne||e[93]!==re||e[94]!==W?(U=(0,c.jsxs)("div",{className:o,children:[ne,re,W]}),e[91]=o,e[92]=ne,e[93]=re,e[94]=W,e[95]=U):U=e[95],U},"ts"),er=l((s,e)=>s.trim()===""?e:(s.split(`
|
|
8
|
+
`)[0]??s).slice(0,24),"ns"),tr=l(s=>{s?.focus(),s?.select()},"ss"),nr=l(s=>{let e=(0,G.c)(14),{initial:n,onCancel:t,onCommit:o,placeholder:r,testId:a}=s,d=ce(),i;e[0]!==o?(i=l(m=>{o(m.currentTarget.value.trim())},"c"),e[0]=o,e[1]=i):i=e[1];let u=i,p;e[2]!==t||e[3]!==o?(p=l(m=>{m.key==="Enter"?o(m.currentTarget.value.trim()):m.key==="Escape"&&t()},"m"),e[2]=t,e[3]=o,e[4]=p):p=e[4];let h=p,g;e[5]!==d?(g=d("Tab title"),e[5]=d,e[6]=g):g=e[6];let y;return e[7]!==n||e[8]!==u||e[9]!==h||e[10]!==r||e[11]!==g||e[12]!==a?(y=(0,c.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:u,onKeyDown:h,placeholder:r,ref:tr,type:"text"}),e[7]=n,e[8]=u,e[9]=h,e[10]=r,e[11]=g,e[12]=a,e[13]=y):y=e[13],y},"os"),rr=l(s=>{let e=(0,G.c)(29),{idBase:n,onDiscard:t,onKeep:o}=s,r=ce(),a=`sql-tab-close-prompt-${n}`,d;e[0]!==r?(d=r("Discard?"),e[0]=r,e[1]=d):d=e[1];let i;e[2]!==d?(i=(0,c.jsx)("span",{className:"text-[11px] text-muted-foreground",children:d}),e[2]=d,e[3]=i):i=e[3];let u;e[4]!==r?(u=r("Discard changes"),e[4]=r,e[5]=u):u=e[5];let p=`sql-tab-close-confirm-${n}`,h;e[6]!==r?(h=r("Discard changes"),e[6]=r,e[7]=h):h=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=(0,c.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,c.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=g):g=e[8];let y;e[9]!==t||e[10]!==u||e[11]!==p||e[12]!==h?(y=(0,c.jsx)("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":p,onClick:t,title:h,type:"button",children:g}),e[9]=t,e[10]=u,e[11]=p,e[12]=h,e[13]=y):y=e[13];let m;e[14]!==r?(m=r("Keep editing"),e[14]=r,e[15]=m):m=e[15];let w=`sql-tab-close-cancel-${n}`,f;e[16]!==r?(f=r("Keep editing"),e[16]=r,e[17]=f):f=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=(0,c.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,c.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=v):v=e[18];let b;e[19]!==o||e[20]!==w||e[21]!==f||e[22]!==m?(b=(0,c.jsx)("button",{"aria-label":m,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":w,onClick:o,title:f,type:"button",children:v}),e[19]=o,e[20]=w,e[21]=f,e[22]=m,e[23]=b):b=e[23];let k;return e[24]!==a||e[25]!==b||e[26]!==i||e[27]!==y?(k=(0,c.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":a,role:"group",children:[i,y,b]}),e[24]=a,e[25]=b,e[26]=i,e[27]=y,e[28]=k):k=e[28],k},"ls"),or=l(s=>{let e=(0,G.c)(47),{active:n,canClose:t,onClose:o,onMenu:r,onRename:a,onSelect:d,tab:i}=s,u=ce(),[p,h]=(0,z.useState)(!1),[g,y]=(0,z.useState)(!1),m;e[0]!==r||e[1]!==i.id?(m=l(H=>{r(i.id,H)},"d"),e[0]=r,e[1]=i.id,e[2]=m):m=e[2];let w=m,f;e[3]!==d||e[4]!==i.id?(f=l(()=>{d(i.id)},"u"),e[3]=d,e[4]=i.id,e[5]=f):f=e[5];let v=f,b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=l(()=>{h(!0)},"h"),e[6]=b):b=e[6];let k=b,S;e[7]!==o||e[8]!==i?(S=l(H=>{H.stopPropagation(),xt(i)?y(!0):o(i.id)},"y"),e[7]=o,e[8]=i,e[9]=S):S=e[9];let x=S,q;e[10]!==o||e[11]!==i.id?(q=l(H=>{H.stopPropagation(),y(!1),o(i.id)},"k"),e[10]=o,e[11]=i.id,e[12]=q):q=e[12];let C=q,R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=l(H=>{H.stopPropagation(),y(!1)},"L"),e[13]=R):R=e[13];let T=R,_;e[14]!==a||e[15]!==i.id?(_=l(H=>{a(i.id,H),h(!1)},"q"),e[14]=a,e[15]=i.id,e[16]=_):_=e[16];let E=_,O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O=l(()=>{h(!1)},"A"),e[17]=O):O=e[17];let D=O,L;e[18]!==i.name?(L=i.name.trim(),e[18]=i.name,e[19]=L):L=e[19];let B=L,A;e[20]!==u||e[21]!==i.sql?(A=er(i.sql,u("Untitled")),e[20]=u,e[21]=i.sql,e[22]=A):A=e[22];let P=A,M=n?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",N;e[23]!==M?(N=me("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",M),e[23]=M,e[24]=N):N=e[24];let j=`sql-tab-${i.id}`,I;e[25]!==n||e[26]!==E||e[27]!==B||e[28]!==P||e[29]!==p||e[30]!==v||e[31]!==u||e[32]!==i.id?(I=p?(0,c.jsx)(nr,{initial:B,onCancel:D,onCommit:E,placeholder:P,testId:`sql-tab-rename-${i.id}`}):(0,c.jsx)("button",{"aria-pressed":n,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${i.id}`,onClick:v,onDoubleClick:k,title:u("Double-click to rename"),type:"button",children:B===""?P:B}),e[25]=n,e[26]=E,e[27]=B,e[28]=P,e[29]=p,e[30]=v,e[31]=u,e[32]=i.id,e[33]=I):I=e[33];let $;e[34]!==t||e[35]!==C||e[36]!==g||e[37]!==x||e[38]!==u||e[39]!==i.id?($=t&&(g?(0,c.jsx)(rr,{idBase:i.id,onDiscard:C,onKeep:T}):(0,c.jsx)("button",{"aria-label":u("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:x,title:u("Close tab"),type:"button",children:(0,c.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,c.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=C,e[36]=g,e[37]=x,e[38]=u,e[39]=i.id,e[40]=$):$=e[40];let F;return e[41]!==w||e[42]!==N||e[43]!==j||e[44]!==I||e[45]!==$?(F=(0,c.jsxs)("div",{className:N,"data-testid":j,onContextMenu:w,children:[I,$]}),e[41]=w,e[42]=N,e[43]=j,e[44]=I,e[45]=$,e[46]=F):F=e[46],F},"rs"),sr=l(s=>{let e=(0,G.c)(43),{model:n,onSelect:t}=s,o=ce(),{activeTab:r,addEditorTab:a,cancelBulk:d,closeEditorTab:i,closeTabMenu:u,confirmBulk:p,menuStyle:h,onBackdropContextMenu:g,onCloseAll:y,onCloseOthers:m,onCloseToRight:w,openTabMenu:f,pendingBulk:v,renameTab:b,tabMenu:k,tabs:S}=n,x;if(e[0]!==r||e[1]!==i||e[2]!==t||e[3]!==f||e[4]!==b||e[5]!==S){let L;e[7]!==r||e[8]!==i||e[9]!==t||e[10]!==f||e[11]!==b||e[12]!==S.length?(L=l(B=>(0,c.jsx)(or,{active:B.id===r.id,canClose:S.length>1,onClose:i,onMenu:f,onRename:b,onSelect:t,tab:B},B.id),"I"),e[7]=r,e[8]=i,e[9]=t,e[10]=f,e[11]=b,e[12]=S.length,e[13]=L):L=e[13],x=S.map(L),e[0]=r,e[1]=i,e[2]=t,e[3]=f,e[4]=b,e[5]=S,e[6]=x}else x=e[6];let q;e[14]!==o?(q=o("New tab"),e[14]=o,e[15]=q):q=e[15];let C=S.length>=Ue,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,c.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,c.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[18]=T):T=e[18];let _;e[19]!==a||e[20]!==q||e[21]!==C||e[22]!==R?(_=(0,c.jsx)("button",{"aria-label":q,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:C,onClick:a,title:R,type:"button",children:T}),e[19]=a,e[20]=q,e[21]=C,e[22]=R,e[23]=_):_=e[23];let E;e[24]!==x||e[25]!==_?(E=(0,c.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:[x,_]}),e[24]=x,e[25]=_,e[26]=E):E=e[26];let O;e[27]!==d||e[28]!==u||e[29]!==p||e[30]!==h||e[31]!==g||e[32]!==y||e[33]!==m||e[34]!==w||e[35]!==v||e[36]!==o||e[37]!==k||e[38]!==S?(O=k!==null&&(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:u,onContextMenu:g,role:"presentation"}),(0,c.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:h,children:v===null?(0,c.jsxs)(c.Fragment,{children:[(0,c.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:S.length<=1,onClick:m,role:"menuitem",type:"button",children:o("Close other tabs")}),(0,c.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:S.findIndex(L=>L.id===k.id)>=S.length-1,onClick:w,role:"menuitem",type:"button",children:o("Close tabs to the right")}),(0,c.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:y,role:"menuitem",type:"button",children:o("Close all tabs")})]}):(0,c.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,c.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")}),(0,c.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,c.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:p,type:"button",children:o("Discard")}),(0,c.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:d,type:"button",children:o("Cancel")})]})]})})]}),e[27]=d,e[28]=u,e[29]=p,e[30]=h,e[31]=g,e[32]=y,e[33]=m,e[34]=w,e[35]=v,e[36]=o,e[37]=k,e[38]=S,e[39]=O):O=e[39];let D;return e[40]!==E||e[41]!==O?(D=(0,c.jsxs)(c.Fragment,{children:[E,O]}),e[40]=E,e[41]=O,e[42]=D):D=e[42],D},"is"),lr=we(Ne.runSql),ar="lunora-studio-sql-split-view",ir=l(()=>Ce(yt[0]?.sql??""),"ds"),kr=l(s=>{let e=(0,G.c)(112),{initialShardKey:n}=s,t=Ee(),o=Dn(ir),{activeTab:r,output:a,patchActiveOutput:d,patchActiveTab:i,setActiveTabId:u,unlinkQuery:p}=o,h;e[0]!==d||e[1]!==i?(h=l((K,ae)=>{i({activeId:ae,sql:K}),d({chart:void 0,error:null,failed:void 0,result:null,script:void 0})},"g"),e[0]=d,e[1]=i,e[2]=h):h=e[2];let g=h,y;e[3]!==g||e[4]!==p?(y={loadIntoActiveTab:g,unlinkQuery:p},e[3]=g,e[4]=p,e[5]=y):y=e[5];let m=Wn(y),{recordHistory:w,updateQuerySql:f}=m,v=r.sql,{activeId:b}=r,{chart:k,error:S,failed:x,result:q,running:C}=a,R=a.pane,[T,_]=(0,z.useState)(n??""),[E,O]=_e(ar,!1),{probe:D,schema:L}=yn(T),B;e[6]!==b||e[7]!==i||e[8]!==f?(B=l(K=>{i({sql:K}),b!==null&&f(b,K)},"B"),e[6]=b,e[7]=i,e[8]=f,e[9]=B):B=e[9];let A=B,P=rn(v,L,T),M=tt(T),N;e[10]!==M||e[11]!==d||e[12]!==q?(N=l(()=>{q!==null&&ue((async()=>{let K=await M.inferChart({columns:q.columns,rowCount:q.rowCount,types:Object.fromEntries(q.columns.map(ae=>[ae,typeof(q.rows[0]?.[ae]??"")]))});d({chart:K})})())},"w"),e[10]=M,e[11]=d,e[12]=q,e[13]=N):N=e[13];let j=N,I;e[14]!==t||e[15]!==w||e[16]!==T?(I=l(async K=>{try{let ae=await t.query(lr,{sql:K},ke(T));return w(K),{error:null,result:ae,sql:K}}catch(ae){return{error:Ke(ae),result:null,sql:K}}},"R"),e[14]=t,e[15]=w,e[16]=T,e[17]=I):I=e[17];let $=I,F;e[18]!==v||e[19]!==d||e[20]!==$||e[21]!==T?(F=l(async K=>{if(v.trim()==="")return;d({running:!0});let ae=K==="explain"?Fe(Ot(v),0):ft(v),de=[];for(let Re of ae){let St={error:Re.rejection?.message??"",result:null,sql:Re.sql};de.push(Re.rejection===void 0?await $(Re.sql):St)}Xe(T);let Ye=Math.max(de.length-1,0),ye=de[Ye];d({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:Ye}:void 0})},"U"),e[18]=v,e[19]=d,e[20]=$,e[21]=T,e[22]=F):F=e[22];let H=F,J;e[23]!==a.script?.runs||e[24]!==d?(J=l(K=>{let ae=a.script?.runs,de=ae?.[K];ae===void 0||de===void 0||d({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]=d,e[25]=J):J=e[25];let Z=J,ee;e[26]!==H?(ee=l(()=>{ue(H("results"))},"ee"),e[26]=H,e[27]=ee):ee=e[27];let te=ee,ie;e[28]!==a.pane||e[29]!==H?(ie=l(()=>{ue(H(a.pane))},"ie"),e[28]=a.pane,e[29]=H,e[30]=ie):ie=e[30];let V;e[31]!==D||e[32]!==L||e[33]!==A||e[34]!==ie?(V={onSubmit:ie,probe:D,schema:L,setDraft:A},e[31]=D,e[32]=L,e[33]=A,e[34]=ie,e[35]=V):V=e[35];let Q=kn(V),{closeAutocomplete:ne}=Q,re;e[36]!==v||e[37]!==A?(re=l(()=>{A(Ht(v))},"se"),e[36]=v,e[37]=A,e[38]=re):re=e[38];let oe=re,se;e[39]!==ne||e[40]!==u?(se=l(K=>{ne(),u(K)},"le"),e[39]=ne,e[40]=u,e[41]=se):se=e[41];let le=se,W;e[42]!==d?(W=l(()=>{d({pane:"results"})},"H"),e[42]=d,e[43]=W):W=e[43];let U=W,Y;e[44]!==H?(Y=l(()=>{ue(H("explain"))},"z"),e[44]=H,e[45]=Y):Y=e[45];let X=Y,fe;e[46]!==d?(fe=l(()=>{d({pane:"chart"})},"me"),e[46]=d,e[47]=fe):fe=e[47];let Ae=fe,Te;e[48]!==O||e[49]!==E?(Te=l(()=>{O(!E)},"ke"),e[48]=O,e[49]=E,e[50]=Te):Te=e[50];let $e=Te,Be=E?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",He=E?"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]!==b||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,c.jsx)(Jn,{activeId:b,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]=b,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,c.jsx)(sr,{model:o,onSelect:le}),e[66]=o,e[67]=le,e[68]=pe):pe=e[68];let be;e[69]!==M||e[70]!==P||e[71]!==v||e[72]!==x||e[73]!==A||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,c.jsx)(Gn,{assistant:M,autocomplete:Q.autocompleteState,diagnostics:P,draft:v,editorRef:Q.editorRef,failed:x,gutterRef:Q.gutterRef,handlers:Q.handlers,listboxId:Q.listboxId,onGenerated:A,onPickSuggestion:Q.onPickSuggestion,onRevealDiagnostic:Q.revealDiagnostic,overlayRef:Q.overlayRef}),e[69]=M,e[70]=P,e[71]=v,e[72]=x,e[73]=A,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]!==M||e[84]!==S||e[85]!==oe||e[86]!==j||e[87]!==k||e[88]!==te||e[89]!==Z||e[90]!==a.script||e[91]!==q||e[92]!==He||e[93]!==C||e[94]!==T||e[95]!==Ae||e[96]!==X||e[97]!==U||e[98]!==E||e[99]!==R||e[100]!==$e?(ge=(0,c.jsx)(Zn,{assistant:M,chart:k,className:He,error:S,onFormat:oe,onInferChart:j,onRun:te,onSelectStatement:Z,onShardKeyChange:_,onShowChart:Ae,onShowExplain:X,onShowResults:U,onToggleSplit:$e,pane:R,result:q,running:C,script:a.script,shardKey:T,splitView:E}),e[83]=M,e[84]=S,e[85]=oe,e[86]=j,e[87]=k,e[88]=te,e[89]=Z,e[90]=a.script,e[91]=q,e[92]=He,e[93]=C,e[94]=T,e[95]=Ae,e[96]=X,e[97]=U,e[98]=E,e[99]=R,e[100]=$e,e[101]=ge):ge=e[101];let xe;e[102]!==be||e[103]!==ge||e[104]!==Be?(xe=(0,c.jsxs)("div",{className:Be,children:[be,ge]}),e[102]=be,e[103]=ge,e[104]=Be,e[105]=xe):xe=e[105];let ve;e[106]!==pe||e[107]!==xe?(ve=(0,c.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 Ie;return e[109]!==he||e[110]!==ve?(Ie=(0,c.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]=Ie):Ie=e[111],Ie},"Rs");export{kr as SqlEditorPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as G}from"./chunk-EA2JKR5D.js";import{a as x}from"./chunk-IMOHEGMV.js";import{a as U}from"./chunk-
|
|
1
|
+
import{a as G}from"./chunk-EA2JKR5D.js";import{a as x}from"./chunk-IMOHEGMV.js";import{a as U}from"./chunk-IABM4BFJ.js";import{b as M}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{P as O}from"./chunk-46ZJ3TM4.js";import"./chunk-4L4WTGN5.js";import{a as p}from"./chunk-EBWXFG4H.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import{b as w}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import{a as E}from"./chunk-4ZEL6BYL.js";import{f as D}from"./chunk-XZCNX7YU.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{d as K,e as _,f as z,h as B,o as P,r as q}from"./chunk-FODLDLE2.js";import{a as s,d as J,e as ie,g as oe}from"./chunk-YKXDMIHQ.js";var i=J(ie(),1);var e=J(oe(),1);var de=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"oe"),le=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${de(o)}`).join(", ")})`,"ie"),ce=s(r=>{switch(r){case"array":return[];case"bigint":case"number":return 0;case"boolean":return!1;case"object":case"record":return{};default:return""}},"de"),ue=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=ce(a.kind));return JSON.stringify(o,void 0,2)},"le"),me=z(E.runAs),fe=10,he=s(r=>r===void 0?"undefined":JSON.stringify(r,null,2),"me"),Fe=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),u=D(),[H,Q]=(0,i.useState)(null),[k,V]=(0,i.useState)(null),g=r??H??[],[I,S]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[c,F]=(0,i.useState)(""),[f,W]=(0,i.useState)(""),[v,h]=(0,i.useState)("idle"),[X,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[$,Y]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return u.listFunctions().then(d=>(t||Q(d),d)).catch(d=>{t||V(B(d))}),()=>{t=!0}},[u,r]);let A=I===""?g[0]?.path??"":I,n=g.find(t=>t.path===A),Z=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:JSON.parse(m)}catch(l){h("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},R=c.trim()===""?{}:{shardKey:c.trim()},j=o?f.trim():"",L=s(l=>{Y(T=>[{argsText:m,at:Date.now(),id:(T[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:c,status:l},...T].slice(0,fe))},"$");h("running"),N(null);try{let l=j===""?await _(u,n.kind,d,t,R):await u.query(me,{args:t,functionPath:n.path,userId:j},R);M(c),y(l),h("success"),L("success")}catch(l){y(void 0),N(l.message),h("error"),L("error")}},"J"),ee=s(t=>{S(t.path),b(t.argsText),F(t.shardKey)},"M"),te=s(t=>{S(t.target.value)},"P"),re=s(t=>{b(t.target.value)},"z"),ae=s(t=>{W(t.target.value)},"q"),se=s(()=>{P(Z())},"H"),ne=s(()=>{b(ue(n?.args))},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:k}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(x,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:te,value:A,children:g.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:le(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(x,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(p,{"data-testid":"prefill-button",disabled:n===void 0,onClick:ne,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(G,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:re,value:m})]}),(0,e.jsx)(U,{onChange:F,testId:"shard-input",value:c}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(x,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(O,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ae,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(p,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:se,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:he(X)}),$.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:$.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:q(t.at)})," ",(0,e.jsx)(p,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ee(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"Ae");export{Fe as FunctionRunner};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-Q4CAKBWN.js";import"./chunk-OKG3HWSJ.js";import{b as Y}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import{a as ae}from"./chunk-
|
|
1
|
+
import{b as de}from"./chunk-UYEZR3BI.js";import{a as te,b as re,c as ne}from"./chunk-Q4CAKBWN.js";import"./chunk-OKG3HWSJ.js";import{b as Y}from"./chunk-NCCAMFB6.js";import"./chunk-25NFR6EB.js";import{a as ae}from"./chunk-5K2UDZLN.js";import"./chunk-ULIQFBZU.js";import"./chunk-GWW7SJR6.js";import"./chunk-35DM4JJG.js";import{a as ee}from"./chunk-4ZEL6BYL.js";import{c as Z}from"./chunk-KQFH6FFC.js";import"./chunk-XZCNX7YU.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as le,b as oe,c as se,d as H,e as z,f as G}from"./chunk-HEAQVSNS.js";import{a as P,e as q}from"./chunk-WUWBZPUK.js";import{d as X}from"./chunk-FODLDLE2.js";import{a as g,d as W,f as ce,g as me}from"./chunk-YKXDMIHQ.js";var J=W(ce(),1);var t=W(me(),1);var ue={binding:"outline",secret:"destructive",var:"secondary"},pe=g((n,e)=>{if(n===void 0)return[];let u=[];return n.workerUrl!==void 0&&u.push({label:e("URL"),value:n.workerUrl}),n.environment!==void 0&&u.push({label:e("Environment"),value:n.environment}),n.deploymentId!==void 0&&u.push({label:e("Deployment"),value:n.deploymentId}),n.versionTag!==void 0&&u.push({label:e("Version"),value:n.versionTag}),u},"ce"),ie=g(n=>{let e=(0,J.c)(18),{modifier:u,name:r,label:p}=n,A=te(),x;e[0]!==r?(x=g(o=>{if(!["Escape","Tab"].includes(o.key)){if(o.shiftKey){o.preventDefault();return}o.preventDefault(),re(r,o.key)}},"b"),e[0]=r,e[1]=x):x=e[1];let i=x,c=`set-shortcut-${r}`,m;e[2]!==p?(m=(0,t.jsx)("dt",{className:"text-muted-foreground",children:p}),e[2]=p,e[3]=m):m=e[3];let h;e[4]!==u?(h=(0,t.jsx)("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:u}),e[4]=u,e[5]=h):h=e[5];let l=`set-shortcut-input-${r}`,f=A[r],s;e[6]!==p||e[7]!==i||e[8]!==l||e[9]!==f?(s=(0,t.jsx)("input",{"aria-label":p,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":l,onKeyDown:i,readOnly:!0,value:f}),e[6]=p,e[7]=i,e[8]=l,e[9]=f,e[10]=s):s=e[10];let a;e[11]!==h||e[12]!==s?(a=(0,t.jsxs)("dd",{className:"flex items-center gap-1.5",children:[h,s]}),e[11]=h,e[12]=s,e[13]=a):a=e[13];let d;return e[14]!==c||e[15]!==m||e[16]!==a?(d=(0,t.jsxs)("div",{className:"contents","data-testid":c,children:[m,a]}),e[14]=c,e[15]=m,e[16]=a,e[17]=d):d=e[17],d},"z"),Se=g(n=>{let e=(0,J.c)(85),{initialShardKey:u}=n,r=X(),p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let A=u??"",x;e[1]!==A?(x={shardKey:A},e[1]=A,e[2]=x):x=e[2];let{data:i,error:c,errorSource:m,isLoading:h}=Z(ee.getSettings,p,x),l,f,s,a,d,o,b;if(e[3]!==c||e[4]!==m||e[5]!==i?.deploy||e[6]!==i?.settings||e[7]!==r){let Q=pe(i?.deploy,r),M;e[15]!==i?.settings?(M=i?.settings??[],e[15]=i?.settings,e[16]=M):M=e[16],l=M,f="flex flex-col gap-4",s="lunora-settings";let V;e[17]!==r?(V=r("Open in Cloudflare"),e[17]=r,e[18]=V):V=e[18],e[19]!==V?(a=(0,t.jsx)("div",{className:"flex flex-wrap items-center gap-3",children:(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:de,rel:"noreferrer",target:"_blank",children:V})}),e[19]=V,e[20]=a):a=e[20];let $;e[21]!==r?($=r("View-only \u2014 values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=r,e[22]=$):$=e[22],e[23]!==$?(d=(0,t.jsx)("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:$}),e[23]=$,e[24]=d):d=e[24],e[25]!==c||e[26]!==m?(o=c!==null&&(0,t.jsx)(ae,{error:m,testId:"set-error"}),e[25]=c,e[26]=m,e[27]=o):o=e[27],b=Q.length>0&&(0,t.jsxs)(P,{className:"py-0","data-testid":"set-deploy",children:[(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r("Deployment")})}),(0,t.jsx)(q,{className:"py-3",children:(0,t.jsx)("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:Q.map(he)})})]}),e[3]=c,e[4]=m,e[5]=i?.deploy,e[6]=i?.settings,e[7]=r,e[8]=l,e[9]=f,e[10]=s,e[11]=a,e[12]=d,e[13]=o,e[14]=b}else l=e[8],f=e[9],s=e[10],a=e[11],d=e[12],o=e[13],b=e[14];let y;e[28]!==r?(y=r("Keyboard shortcuts"),e[28]=r,e[29]=y):y=e[29];let v;e[30]!==y?(v=(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y}),e[30]=y,e[31]=v):v=e[31];let N;e[32]!==r?(N=r("Reset"),e[32]=r,e[33]=N):N=e[33];let k;e[34]!==N?(k=(0,t.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ne,type:"button",children:N}),e[34]=N,e[35]=k):k=e[35];let w;e[36]!==v||e[37]!==k?(w=(0,t.jsxs)("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[v,k]}),e[36]=v,e[37]=k,e[38]=w):w=e[38];let C;e[39]!==r?(C=r("Command palette"),e[39]=r,e[40]=C):C=e[40];let S;e[41]!==C?(S=(0,t.jsx)(ie,{label:C,modifier:"\u2318/Ctrl",name:"palette"}),e[41]=C,e[42]=S):S=e[42];let T;e[43]!==r?(T=r("Operation console"),e[43]=r,e[44]=T):T=e[44];let D;e[45]!==T?(D=(0,t.jsx)(ie,{label:T,modifier:"Ctrl",name:"console"}),e[45]=T,e[46]=D):D=e[46];let _;e[47]!==S||e[48]!==D?(_=(0,t.jsxs)("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[S,D]}),e[47]=S,e[48]=D,e[49]=_):_=e[49];let E;e[50]!==r?(E=r("Stored in this browser. Focus a box and press a key to rebind it."),e[50]=r,e[51]=E):E=e[51];let I;e[52]!==E?(I=(0,t.jsx)("p",{className:"pt-3 text-xs text-muted-foreground",children:E}),e[52]=E,e[53]=I):I=e[53];let K;e[54]!==_||e[55]!==I?(K=(0,t.jsxs)(q,{className:"py-3",children:[_,I]}),e[54]=_,e[55]=I,e[56]=K):K=e[56];let O;e[57]!==w||e[58]!==K?(O=(0,t.jsxs)(P,{className:"py-0","data-testid":"set-preferences",children:[w,K]}),e[57]=w,e[58]=K,e[59]=O):O=e[59];let U;e[60]!==r?(U=r("Environment & bindings"),e[60]=r,e[61]=U):U=e[61];let j;e[62]!==U?(j=(0,t.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,t.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:U})}),e[62]=U,e[63]=j):j=e[63];let F;e[64]!==c||e[65]!==h||e[66]!==l.length||e[67]!==r?(F=c===null&&!h&&l.length===0&&(0,t.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:r("No environment variables or bindings.")}),e[64]=c,e[65]=h,e[66]=l.length,e[67]=r,e[68]=F):F=e[68];let L;e[69]!==l||e[70]!==r?(L=l.length>0&&(0,t.jsx)(q,{className:"px-0 py-0",children:(0,t.jsxs)(le,{"data-testid":"set-table",children:[(0,t.jsx)(oe,{children:(0,t.jsxs)(H,{children:[(0,t.jsx)(z,{children:r("name")}),(0,t.jsx)(z,{children:r("kind")}),(0,t.jsx)(z,{children:r("value")})]})}),(0,t.jsx)(se,{children:l.map(fe)})]})}),e[69]=l,e[70]=r,e[71]=L):L=e[71];let R;e[72]!==j||e[73]!==F||e[74]!==L?(R=(0,t.jsxs)(P,{className:"py-0",children:[j,F,L]}),e[72]=j,e[73]=F,e[74]=L,e[75]=R):R=e[75];let B;return e[76]!==O||e[77]!==R||e[78]!==f||e[79]!==s||e[80]!==a||e[81]!==d||e[82]!==o||e[83]!==b?(B=(0,t.jsxs)("div",{className:f,"data-testid":s,children:[a,d,o,b,O,R]}),e[76]=O,e[77]=R,e[78]=f,e[79]=s,e[80]=a,e[81]=d,e[82]=o,e[83]=b,e[84]=B):B=e[84],B},"Ce");function he(n){return(0,t.jsxs)("div",{className:"contents","data-testid":"set-deploy-row",children:[(0,t.jsx)("dt",{className:"text-muted-foreground",children:n.label}),(0,t.jsx)("dd",{className:"truncate font-mono text-xs",title:n.value,children:n.value})]},n.label)}g(he,"me");function fe(n){return(0,t.jsxs)(H,{"data-testid":"set-row",children:[(0,t.jsx)(G,{className:"font-mono text-xs font-medium",children:n.name}),(0,t.jsx)(G,{children:(0,t.jsx)(Y,{variant:ue[n.kind],children:n.bindingType??n.kind})}),(0,t.jsx)(G,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:n.value??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},n.name)}g(fe,"fe");export{Se as SettingsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as te}from"./chunk-EA2JKR5D.js";import{P as Z}from"./chunk-46ZJ3TM4.js";import"./chunk-4L4WTGN5.js";import{a as O}from"./chunk-EBWXFG4H.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import"./chunk-25NFR6EB.js";import{a as K}from"./chunk-4ZEL6BYL.js";import{c as ee}from"./chunk-BQ4P3PLU.js";import{f as M}from"./chunk-W3Q32C24.js";import"./chunk-FSRSK4LY.js";import"./chunk-RIO2HPN7.js";import{a as P}from"./chunk-FKVZRPV5.js";import{a as D,b as F,c as L,d as h,e as o,f as i}from"./chunk-HEAQVSNS.js";import{a as E,e as _}from"./chunk-WUWBZPUK.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-NXKPFGOP.js";import{a as n,d as Y,e as ne,g as le}from"./chunk-YKXDMIHQ.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:j,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[v,z]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,I]=(0,c.useState)(!1),[R,U]=(0,c.useState)(null),x=l??(a=>A.getWorkflowInstance(a)),w=N?void 0:j??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),T=n(async()=>{f(null),I(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),I(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?I(!0):f(W(d))}},"L");(0,c.useEffect)(()=>{C(null),$(T())},[g,v]);let q=n(async a=>{f(null);try{C(await x({id:a,name:g}))}catch(d){f(W(d))}},"K"),B=n(async(a,d)=>{if(w!==void 0){U(a),f(null);try{await w({action:d,id:a,name:g}),await T()}catch(G){f(W(G))}U(null)}},"q");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{z(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(P,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(P,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(L,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(O,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(q(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),w!==void 0&&ie.map(d=>(0,e.jsx)(O,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:R===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(E,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(O,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{C(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(D,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(L,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),xe=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:j}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[C,v]=(0,c.useState)(!1),[z,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[I,R]=(0,c.useState)(null),U=N!==void 0,x=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=xe(x,g),T=x.find(t=>t.exportName===w),q=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"C"),B=n(async()=>{let t=w;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));q({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"L"),a=n(()=>{$(B())},"K"),d=n(async(t,u)=>{R(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));q({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}R(null)},"q"),G=n(t=>{A(t.target.value)},"r"),ae=n(t=>{p(t.target.value)},"l"),re=n(t=>{S(t.target.value)},"G"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[j!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:j}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),U&&x.length===0?(0,e.jsx)(P,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(L,{children:x.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),x.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),z!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:z}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:w,children:x.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(O,{"data-testid":"workflows-start-button",disabled:C||w==="",onClick:a,children:r(C?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(L,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(O,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:I===t.id,onClick:se,size:"xs",variant:"outline",children:I===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),T!==void 0&&(0,e.jsx)(ue,{workflowName:T.name})]})},"Te");export{We as default};
|
|
1
|
+
import{a as te}from"./chunk-EA2JKR5D.js";import{P as Z}from"./chunk-46ZJ3TM4.js";import"./chunk-4L4WTGN5.js";import{a as O}from"./chunk-EBWXFG4H.js";import"./chunk-TGHH7ZFA.js";import"./chunk-5GFSKIB2.js";import"./chunk-25NFR6EB.js";import{a as K}from"./chunk-4ZEL6BYL.js";import{c as ee}from"./chunk-KQFH6FFC.js";import{f as M}from"./chunk-XZCNX7YU.js";import"./chunk-FSRSK4LY.js";import"./chunk-2LN3T5HY.js";import{a as P}from"./chunk-FKVZRPV5.js";import{a as D,b as F,c as L,d as h,e as o,f as i}from"./chunk-HEAQVSNS.js";import{a as E,e as _}from"./chunk-WUWBZPUK.js";import{d as H,f as Q,g as V,h as W,o as $}from"./chunk-FODLDLE2.js";import{a as n,d as Y,e as ne,g as le}from"./chunk-YKXDMIHQ.js";var c=Y(ne(),1);var e=Y(le(),1);var oe=["queued","running","paused","waiting","complete","errored","terminated"],ie=["pause","resume","terminate"],de="WORKFLOWS_NOT_CONFIGURED",ce=n(l=>typeof l=="object"&&l!==null&&l.code===de,"ie"),me=n(l=>{let r=l.error??l.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r)}catch{return"(unserializable)"}},"de"),ue=n(({loadDetail:l,loadInstances:r,readOnly:N,runAction:j,workflowName:g})=>{let A=M(),s=H(),[p,k]=(0,c.useState)(null),[S,C]=(0,c.useState)(null),[v,z]=(0,c.useState)(""),[b,f]=(0,c.useState)(null),[J,I]=(0,c.useState)(!1),[R,U]=(0,c.useState)(null),x=l??(a=>A.getWorkflowInstance(a)),w=N?void 0:j??(r===void 0?a=>A.setWorkflowInstanceStatus(a):void 0),T=n(async()=>{f(null),I(!1);let a=v===""?void 0:v;try{if(r===void 0){let d=await A.listWorkflowInstances({name:g,status:a});if(d.configured===!1){k(null),I(!0);return}k(d.instances);return}k(await r({name:g,status:a}))}catch(d){k(null),ce(d)?I(!0):f(W(d))}},"L");(0,c.useEffect)(()=>{C(null),$(T())},[g,v]);let q=n(async a=>{f(null);try{C(await x({id:a,name:g}))}catch(d){f(W(d))}},"K"),B=n(async(a,d)=>{if(w!==void 0){U(a),f(null);try{await w({action:d,id:a,name:g}),await T()}catch(G){f(W(G))}U(null)}},"q");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:s("Instance history")}),(0,e.jsxs)("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n(a=>{z(a.target.value)},"onChange"),value:v,children:[(0,e.jsx)("option",{value:"",children:s("All statuses")}),oe.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),b!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:b}),J&&(0,e.jsx)(P,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!J&&p!==null&&p.length===0&&(0,e.jsx)(P,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Instance id")}),(0,e.jsx)(o,{children:s("Status")}),(0,e.jsx)(o,{children:s("Created")}),(0,e.jsx)(o,{children:s("Ended")}),(0,e.jsx)(o,{"aria-label":s("Actions")})]})}),(0,e.jsx)(L,{children:p.map(a=>(0,e.jsxs)(h,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(O,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:n(()=>{$(q(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:s("Steps")}),w!==void 0&&ie.map(d=>(0,e.jsx)(O,{"data-testid":`workflow-instance-${d}-${a.id}`,disabled:R===a.id,onClick:n(()=>{$(B(a.id,d))},"onClick"),size:"sm",type:"button",variant:"ghost",children:s(d)},d))]})})]},a.id))})]})})}),S!==null&&(0,e.jsx)(E,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[s("Steps")," \xB7 ",S.id]}),(0,e.jsx)(O,{"data-testid":"workflow-instance-detail-close",onClick:n(()=>{C(null)},"onClick"),size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),S.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):(0,e.jsxs)(D,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:s("Step")}),(0,e.jsx)(o,{children:s("Type")}),(0,e.jsx)(o,{children:s("Attempts")}),(0,e.jsx)(o,{children:s("Started")}),(0,e.jsx)(o,{children:s("Output")})]})}),(0,e.jsx)(L,{children:S.steps.map((a,d)=>(0,e.jsxs)(h,{"data-testid":`workflow-step-${String(d)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(a)})]},`${a.name}:${String(d)}`))})]})]})})]})},"ce"),fe=Q(K.createWorkflowInstance),he=Q(K.getWorkflowInstanceStatus),pe=n(l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"\u2014";try{return JSON.stringify(l.output)}catch{return"(unserializable)"}},"fe"),xe=n((l,r)=>l.some(N=>N.exportName===r)?r:l[0]?.exportName??"","he"),We=n(()=>{let l=M(),r=H(),{data:N,error:j}=ee(K.listWorkflows,{}),[g,A]=(0,c.useState)(""),[s,p]=(0,c.useState)(""),[k,S]=(0,c.useState)(""),[C,v]=(0,c.useState)(!1),[z,b]=(0,c.useState)(null),[f,J]=(0,c.useState)([]),[I,R]=(0,c.useState)(null),U=N!==void 0,x=Array.isArray(N?.workflows)?[...N.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],w=xe(x,g),T=x.find(t=>t.exportName===w),q=n(t=>{J(u=>{let m=u.filter(y=>!(y.exportName===t.exportName&&y.id===t.id));return[t,...m]})},"C"),B=n(async()=>{let t=w;if(t==="")return;let u,m=k.trim();if(m!=="")try{u=JSON.parse(m)}catch{b(r("Params must be valid JSON"));return}v(!0),b(null);try{let y=s.trim(),X=await l.query(fe,{exportName:t,id:y===""?void 0:y,params:u},V(""));q({exportName:t,id:X.id,status:X.status}),p("")}catch(y){b(W(y))}v(!1)},"L"),a=n(()=>{$(B())},"K"),d=n(async(t,u)=>{R(u);try{let m=await l.query(he,{exportName:t,id:u},V(""));q({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){b(W(m))}R(null)},"q"),G=n(t=>{A(t.target.value)},"r"),ae=n(t=>{p(t.target.value)},"l"),re=n(t=>{S(t.target.value)},"G"),se=n(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&$(d(u,m))},"ee");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[j!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:j}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),U&&x.length===0?(0,e.jsx)(P,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Export")}),(0,e.jsx)(o,{children:r("Name")}),(0,e.jsx)(o,{children:r("Class")}),(0,e.jsx)(o,{children:r("Binding")})]})}),(0,e.jsx)(L,{children:x.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),x.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),z!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:z}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:G,value:w,children:x.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(Z,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:ae,placeholder:r("Instance id (optional)"),value:s}),(0,e.jsx)(O,{"data-testid":"workflows-start-button",disabled:C||w==="",onClick:a,children:r(C?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(te,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:re,placeholder:r("Params (JSON, optional)"),value:k})]}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(D,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(F,{children:(0,e.jsxs)(h,{children:[(0,e.jsx)(o,{children:r("Workflow")}),(0,e.jsx)(o,{children:r("Instance id")}),(0,e.jsx)(o,{children:r("Status")}),(0,e.jsx)(o,{children:r("Output")}),(0,e.jsx)(o,{})]})}),(0,e.jsx)(L,{children:f.map(t=>(0,e.jsxs)(h,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:pe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(O,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:I===t.id,onClick:se,size:"xs",variant:"outline",children:I===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),T!==void 0&&(0,e.jsx)(ue,{workflowName:T.name})]})},"Te");export{We as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s}from"./chunk-EBWXFG4H.js";import{d}from"./chunk-
|
|
1
|
+
import{a as s}from"./chunk-EBWXFG4H.js";import{d}from"./chunk-FODLDLE2.js";import{a as e,d as r,e as h,g as k}from"./chunk-YKXDMIHQ.js";var l=r(h(),1);var t=r(k(),1);var g=e(({children:m,confirmLabel:c,disabled:a=!1,onConfirm:p,testId:i})=>{let o=d(),[f,n]=(0,l.useState)(!1),u=e(()=>{n(!0)},"f"),C=e(()=>{n(!1)},"l"),b=e(()=>{n(!1),p()},"p");return f?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1","data-testid":`${i}-prompt`,role:"group",children:[(0,t.jsx)(s,{"data-testid":`${i}-confirm`,disabled:a,onClick:b,size:"sm",type:"button",variant:"destructive",children:c??o("Confirm")}),(0,t.jsx)(s,{"data-testid":`${i}-cancel`,onClick:C,size:"sm",type:"button",variant:"ghost",children:o("Cancel")})]}):(0,t.jsx)(s,{"data-testid":i,disabled:a,onClick:u,size:"sm",type:"button",variant:"outline",children:m})},"k");export{g as a};
|