@lunora/studio 1.0.0-alpha.360 → 1.0.0-alpha.362
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 +4 -1
- package/dist/index.d.ts +4 -1
- 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/ExportImportPanel.mjs +1 -1
- 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 +24 -9
- package/dist/packem_chunks/TableEditor.mjs +1 -1
- package/dist/packem_chunks/agents-panel.mjs +1 -1
- package/dist/packem_chunks/ai-knowledge.mjs +1 -0
- package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
- package/dist/packem_chunks/assistant-panel.mjs +3 -0
- package/dist/packem_chunks/auth-audit-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/payments-panel.mjs +1 -1
- package/dist/packem_chunks/permissions-panel.mjs +1 -1
- package/dist/packem_chunks/privacy-requests-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/traces-panel.mjs +1 -1
- package/dist/packem_chunks/workflows-panel.mjs +1 -1
- package/dist/packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs +1 -0
- package/dist/packem_shared/{ApiDocsPanel-DD2Uns6b.mjs → ApiDocsPanel-B9S9l1Ce.mjs} +1 -1
- package/dist/packem_shared/{DataBrowser-CVRWnNWu.mjs → DataBrowser-Dm-jhIUP.mjs} +2 -2
- package/dist/packem_shared/{GlobalDataBrowser-DC47T6Zl.mjs → GlobalDataBrowser-C1Y8GUhe.mjs} +1 -1
- package/dist/packem_shared/{HomePanel-D12HxHQo.mjs → HomePanel-B5ytwPIo.mjs} +1 -1
- package/dist/packem_shared/{MigrationsPanel-DMkxSXNl.mjs → MigrationsPanel-CwLikxDT.mjs} +1 -1
- package/dist/packem_shared/Studio-B89ZNMOD.mjs +1 -0
- package/dist/packem_shared/{StudioApp-isdWpF9P.mjs → StudioApp-C9l1a3A8.mjs} +1 -1
- package/dist/packem_shared/advisor-view-CzieqKMe.mjs +5 -0
- package/dist/packem_shared/assistant-provider-Bp72uWsq.mjs +1 -0
- package/dist/packem_shared/assistant-reason-D6EwMCxT.mjs +1 -0
- package/dist/packem_shared/{cf-links-CBJ5SywP.mjs → cf-links-C4DVTr8A.mjs} +1 -1
- package/dist/packem_shared/error-alert-DKXm5h19.mjs +6 -0
- package/dist/packem_shared/{home-panel-CDVTuTF8.mjs → home-panel-5fGktYeD.mjs} +1 -1
- package/dist/packem_shared/recording-client-z4CBi0y8.mjs +1 -0
- package/dist/packem_shared/studio-gZfpz1wC.mjs +2 -0
- package/dist/packem_shared/{table-list-sidebar-CNadcIgG.mjs → table-list-sidebar-kpHaDWjy.mjs} +1 -1
- package/dist/packem_shared/use-assistant-rpc-GCUK2zPa.mjs +1 -0
- package/dist/standalone/chunk-2DT3QG6Q.js +1 -0
- package/dist/standalone/chunk-2EB7FN5S.js +1 -0
- package/dist/standalone/chunk-2FTGLXYA.js +1 -0
- package/dist/standalone/chunk-2H6VLY2M.js +1 -0
- package/dist/standalone/chunk-2NGKUO32.js +1 -0
- package/dist/standalone/chunk-2SNHKJXK.js +1 -0
- package/dist/standalone/chunk-2W4UO5BC.js +1 -0
- package/dist/standalone/{chunk-SLIDAWNX.js → chunk-3D67ZJRW.js} +1 -1
- package/dist/standalone/chunk-3RZD6VJ7.js +1 -0
- package/dist/standalone/chunk-3X3NXJBR.js +1 -0
- package/dist/standalone/chunk-4EPW63HS.js +1 -0
- package/dist/standalone/{chunk-WS36BO4R.js → chunk-4NKJV7YX.js} +1 -1
- package/dist/standalone/chunk-4PI2OSSP.js +1 -0
- package/dist/standalone/chunk-53CGUTRT.js +1 -0
- package/dist/standalone/chunk-5EWIOOBI.js +1 -0
- package/dist/standalone/chunk-5GYHGDIF.js +8 -0
- package/dist/standalone/chunk-5NIQHOPN.js +1 -0
- package/dist/standalone/chunk-5O7ICPWV.js +1 -0
- package/dist/standalone/chunk-5PEAXTYQ.js +1 -0
- package/dist/standalone/{chunk-O2NMPIV2.js → chunk-5WNGRT7N.js} +1 -1
- package/dist/standalone/chunk-66BMMNUR.js +1 -0
- package/dist/standalone/chunk-66LYVBXB.js +1 -0
- package/dist/standalone/chunk-6FPV3EK2.js +1 -0
- package/dist/standalone/chunk-6G3E4PJ2.js +1 -0
- package/dist/standalone/chunk-6KE7ILEZ.js +1 -0
- package/dist/standalone/chunk-7KJCRT4B.js +1 -0
- package/dist/standalone/chunk-7O5SGABV.js +1 -0
- package/dist/standalone/chunk-7QEZ2SFW.js +1 -0
- package/dist/standalone/chunk-7WV3EPE6.js +1 -0
- package/dist/standalone/chunk-A2Q3TGIQ.js +1 -0
- package/dist/standalone/chunk-ABMHWBYA.js +1 -0
- package/dist/standalone/chunk-AEU3EF4T.js +1 -0
- package/dist/standalone/chunk-ALQHMFOC.js +1 -0
- package/dist/standalone/chunk-AZIKM5BA.js +1 -0
- package/dist/standalone/chunk-BCUOQNI2.js +1 -0
- package/dist/standalone/chunk-BG2CJOVS.js +1 -0
- package/dist/standalone/chunk-BKI3JMXQ.js +1 -0
- package/dist/standalone/chunk-BO5NNWMO.js +1 -0
- package/dist/standalone/chunk-BX7TFVCC.js +1 -0
- package/dist/standalone/chunk-CKEQX655.js +1 -0
- package/dist/standalone/{chunk-DX55P3KZ.js → chunk-CL3JOU6F.js} +1 -1
- package/dist/standalone/chunk-COLSZPCE.js +1 -0
- package/dist/standalone/chunk-CVSIFPI5.js +1 -0
- package/dist/standalone/chunk-D65UVZIA.js +1 -0
- package/dist/standalone/{chunk-DBVJ5VLI.js → chunk-DA2CAFXI.js} +1 -1
- package/dist/standalone/chunk-DB6QX4X6.js +1 -0
- package/dist/standalone/{chunk-7ZIYHKLX.js → chunk-E2FFHKGI.js} +3 -3
- package/dist/standalone/chunk-EE2COWFF.js +1 -0
- package/dist/standalone/chunk-ELSQ4FVH.js +1 -0
- package/dist/standalone/chunk-EXFERMUT.js +1 -0
- package/dist/standalone/chunk-FACXM2UB.js +7 -0
- package/dist/standalone/chunk-FBDIQ67D.js +1 -0
- package/dist/standalone/chunk-FHLODLBC.js +1 -0
- package/dist/standalone/chunk-FQEZUQ36.js +1 -0
- package/dist/standalone/{chunk-VEWQWS3J.js → chunk-FWM5Z6CH.js} +1 -1
- package/dist/standalone/chunk-GC3GKGWD.js +1 -0
- package/dist/standalone/chunk-GJXCPZDN.js +1 -0
- package/dist/standalone/chunk-GNI37YCV.js +33 -0
- package/dist/standalone/chunk-GVZ3VFGG.js +1 -0
- package/dist/standalone/chunk-GWNGVKLG.js +1 -0
- package/dist/standalone/chunk-GXTSE66Z.js +1 -0
- package/dist/standalone/chunk-H7BQUL7D.js +1 -0
- package/dist/standalone/chunk-HCCQTUHS.js +1 -0
- package/dist/standalone/chunk-HCOF7HOM.js +1 -0
- package/dist/standalone/chunk-HZDLUAWS.js +1 -0
- package/dist/standalone/chunk-IDZLHZIA.js +1 -0
- package/dist/standalone/{chunk-SU5DTRGK.js → chunk-IHGRWY3Y.js} +1 -1
- package/dist/standalone/chunk-IUGNIG6L.js +6 -0
- package/dist/standalone/chunk-J3BZWYJQ.js +1 -0
- package/dist/standalone/chunk-J45HAKBU.js +1 -0
- package/dist/standalone/chunk-J4PQAVOF.js +1 -0
- package/dist/standalone/chunk-J6FR2B77.js +1 -0
- package/dist/standalone/chunk-J6XQKD2F.js +1 -0
- package/dist/standalone/chunk-JCRFMCNP.js +1 -0
- package/dist/standalone/chunk-JD6PRRFO.js +1 -0
- package/dist/standalone/chunk-JENPPZFV.js +1 -0
- package/dist/standalone/chunk-JHTL3QHW.js +1 -0
- package/dist/standalone/chunk-JOPNP4EO.js +1 -0
- package/dist/standalone/chunk-JVP3TR3A.js +1 -0
- package/dist/standalone/chunk-KGLIQIZU.js +1 -0
- package/dist/standalone/{chunk-ONWGX5Y4.js → chunk-KH6OXCG3.js} +1 -1
- package/dist/standalone/{chunk-3FS22LNI.js → chunk-L26RMC2W.js} +3 -3
- package/dist/standalone/chunk-L2FYX4FN.js +1 -0
- package/dist/standalone/{chunk-XIRKBJPD.js → chunk-LPFUEJZ4.js} +5 -5
- package/dist/standalone/chunk-LSEUUZN4.js +1 -0
- package/dist/standalone/{chunk-BYOGQ2IV.js → chunk-MJTVTUNI.js} +2 -2
- package/dist/standalone/chunk-MQTI3STP.js +1 -0
- package/dist/standalone/chunk-N7WQJPOM.js +1 -0
- package/dist/standalone/chunk-NF2Q75WM.js +1 -0
- package/dist/standalone/chunk-NGZNXNRD.js +1 -0
- package/dist/standalone/chunk-O3AZ7JKE.js +1 -0
- package/dist/standalone/chunk-OK2QU2EV.js +1 -0
- package/dist/standalone/{chunk-IH2CJZF2.js → chunk-ONTGYVAN.js} +1 -1
- package/dist/standalone/chunk-OP4QEV27.js +1 -0
- package/dist/standalone/chunk-OPIMGKWU.js +1 -0
- package/dist/standalone/chunk-OWRKSQPE.js +1 -0
- package/dist/standalone/chunk-P5EVJEGC.js +1 -0
- package/dist/standalone/chunk-PAZKX7I6.js +1 -0
- package/dist/standalone/chunk-PDBW6GTJ.js +1 -0
- package/dist/standalone/chunk-PJUVJTDR.js +1 -0
- package/dist/standalone/chunk-Q2J73V2C.js +2 -0
- package/dist/standalone/chunk-Q2KL457J.js +1 -0
- package/dist/standalone/chunk-QAOZXPLU.js +1 -0
- package/dist/standalone/{chunk-3PAYDWHN.js → chunk-QEFLZBT7.js} +2 -2
- package/dist/standalone/chunk-QKUVJIRX.js +1 -0
- package/dist/standalone/chunk-QNM2J7MG.js +1 -0
- package/dist/standalone/chunk-QRA7AKYO.js +1 -0
- package/dist/standalone/chunk-RCXNYW7P.js +1 -0
- package/dist/standalone/chunk-RE7GRXBM.js +1 -0
- package/dist/standalone/{chunk-TDVDZ7XQ.js → chunk-RIAOZECW.js} +1 -1
- package/dist/standalone/{chunk-LUHXNZI4.js → chunk-RTS5G3ET.js} +1 -1
- package/dist/standalone/chunk-S36FVTKK.js +1 -0
- package/dist/standalone/chunk-SR6CPTRT.js +1 -0
- package/dist/standalone/chunk-T3ZCW3RG.js +1 -0
- package/dist/standalone/chunk-TKBTZX4K.js +1 -0
- package/dist/standalone/chunk-TMWKF4XM.js +5 -0
- package/dist/standalone/chunk-TW4O2BA5.js +159 -0
- package/dist/standalone/chunk-UD5REVU2.js +1 -0
- package/dist/standalone/{chunk-PQH2LSJX.js → chunk-UQA2AJGI.js} +1 -1
- package/dist/standalone/chunk-UW6QNC74.js +3 -0
- package/dist/standalone/chunk-UXBNXITB.js +1 -0
- package/dist/standalone/chunk-UZ2ZXB74.js +1 -0
- package/dist/standalone/chunk-V3BE427M.js +1 -0
- package/dist/standalone/chunk-VHPTPEZ4.js +1 -0
- package/dist/standalone/chunk-W4LJQYCI.js +1 -0
- package/dist/standalone/chunk-WADY55J2.js +30 -0
- package/dist/standalone/chunk-WCWP4EAW.js +1 -0
- package/dist/standalone/chunk-X54WR7FF.js +1 -0
- package/dist/standalone/chunk-XWWQIAF6.js +1 -0
- package/dist/standalone/{chunk-SYGCASPT.js → chunk-Y2YLTUMD.js} +1 -1
- package/dist/standalone/chunk-YEVTA35E.js +1 -0
- package/dist/standalone/{chunk-R36QXQZX.js → chunk-YORPLSI5.js} +1 -1
- package/dist/standalone/chunk-YX2N5PJW.js +1 -0
- package/dist/standalone/chunk-Z57KMMOK.js +1 -0
- package/dist/standalone/chunk-ZFQ253FX.js +1 -0
- package/dist/standalone/chunk-ZG3IUVQ2.js +1 -0
- package/dist/standalone/chunk-ZKEYRU5C.js +1 -0
- package/dist/standalone/{chunk-5R2YO7HF.js → chunk-ZOKSVUID.js} +4 -4
- package/dist/standalone/{chunk-H7HZ42JY.js → chunk-ZPQBVYNN.js} +1 -1
- package/dist/standalone/chunk-ZSLKFLWE.js +1 -0
- package/dist/standalone/chunk-ZSWW2UGP.js +1 -0
- package/dist/standalone/studio.js +2 -2
- package/dist/styles.css +1 -1
- package/package.json +7 -6
- package/dist/packem_shared/ADMIN_FUNCTIONS-4aGsMs95.mjs +0 -1
- package/dist/packem_shared/Studio-MA8kKZLu.mjs +0 -1
- package/dist/packem_shared/advisor-view-tBumWci_.mjs +0 -1
- package/dist/packem_shared/error-alert-C0R39DO1.mjs +0 -1
- package/dist/packem_shared/recording-client-DAipTA_n.mjs +0 -1
- package/dist/packem_shared/studio-UhUrPz5J.mjs +0 -2
- package/dist/packem_shared/use-sql-assistant-rZPs3LC3.mjs +0 -1
- package/dist/standalone/chunk-2AH4ABE5.js +0 -1
- package/dist/standalone/chunk-2G57ENH5.js +0 -1
- package/dist/standalone/chunk-3GXPALXG.js +0 -1
- package/dist/standalone/chunk-3GYLOE4V.js +0 -1
- package/dist/standalone/chunk-473JK2PQ.js +0 -1
- package/dist/standalone/chunk-4C4THJUD.js +0 -1
- package/dist/standalone/chunk-4DAKKAK7.js +0 -1
- package/dist/standalone/chunk-4M57OYFX.js +0 -1
- package/dist/standalone/chunk-4SQBAPY6.js +0 -1
- package/dist/standalone/chunk-5DNGK3NT.js +0 -1
- package/dist/standalone/chunk-5GIQ6C5N.js +0 -1
- package/dist/standalone/chunk-5WJG7FMH.js +0 -1
- package/dist/standalone/chunk-63KDHS3H.js +0 -1
- package/dist/standalone/chunk-6B6ARRMI.js +0 -1
- package/dist/standalone/chunk-6LMO2D54.js +0 -1
- package/dist/standalone/chunk-6M7FLLMT.js +0 -1
- package/dist/standalone/chunk-6QEXGYWH.js +0 -1
- package/dist/standalone/chunk-6UTZXEW3.js +0 -1
- package/dist/standalone/chunk-6VAY6L4J.js +0 -1
- package/dist/standalone/chunk-7PADVGQX.js +0 -1
- package/dist/standalone/chunk-7RGYCU6F.js +0 -1
- package/dist/standalone/chunk-7UM5ROG6.js +0 -1
- package/dist/standalone/chunk-A566HCBX.js +0 -1
- package/dist/standalone/chunk-A5JISKHE.js +0 -1
- package/dist/standalone/chunk-ADNRFCMZ.js +0 -1
- package/dist/standalone/chunk-AP4PC2M4.js +0 -1
- package/dist/standalone/chunk-BFE2DRP6.js +0 -33
- package/dist/standalone/chunk-BPEB4KFE.js +0 -1
- package/dist/standalone/chunk-BVX45MU5.js +0 -7
- package/dist/standalone/chunk-C6GN7ZXJ.js +0 -1
- package/dist/standalone/chunk-CL2VZNDI.js +0 -1
- package/dist/standalone/chunk-CNA3TVUK.js +0 -1
- package/dist/standalone/chunk-CZ6HBDIL.js +0 -1
- package/dist/standalone/chunk-D6S7MXW4.js +0 -1
- package/dist/standalone/chunk-E26OT26O.js +0 -1
- package/dist/standalone/chunk-FCAXVYAX.js +0 -1
- package/dist/standalone/chunk-FXPAJDES.js +0 -1
- package/dist/standalone/chunk-HHRYM6UW.js +0 -1
- package/dist/standalone/chunk-HPRF5LMA.js +0 -1
- package/dist/standalone/chunk-IB22LETR.js +0 -1
- package/dist/standalone/chunk-IBJVVHV5.js +0 -1
- package/dist/standalone/chunk-IENQRRQT.js +0 -1
- package/dist/standalone/chunk-IQ4TTHQT.js +0 -1
- package/dist/standalone/chunk-ITH5LRWM.js +0 -1
- package/dist/standalone/chunk-J6VFG6M5.js +0 -1
- package/dist/standalone/chunk-JSDKOE4U.js +0 -1
- package/dist/standalone/chunk-JTGGWF7R.js +0 -1
- package/dist/standalone/chunk-JZD7ZN3F.js +0 -1
- package/dist/standalone/chunk-K3CWB3AM.js +0 -1
- package/dist/standalone/chunk-KNFB3FGW.js +0 -1
- package/dist/standalone/chunk-KNXWDE4N.js +0 -1
- package/dist/standalone/chunk-KRPXOSBL.js +0 -1
- package/dist/standalone/chunk-KRY7BYHT.js +0 -1
- package/dist/standalone/chunk-KYAG2YMF.js +0 -1
- package/dist/standalone/chunk-KZCEJFZF.js +0 -1
- package/dist/standalone/chunk-KZILJQX3.js +0 -8
- package/dist/standalone/chunk-LEYUH5TS.js +0 -1
- package/dist/standalone/chunk-LFM672WN.js +0 -1
- package/dist/standalone/chunk-LIGOLZND.js +0 -1
- package/dist/standalone/chunk-LPU6YTSU.js +0 -1
- package/dist/standalone/chunk-MWJC3S62.js +0 -1
- package/dist/standalone/chunk-NP2AQOLE.js +0 -1
- package/dist/standalone/chunk-NVKLYDOH.js +0 -1
- package/dist/standalone/chunk-O2X2XYCM.js +0 -1
- package/dist/standalone/chunk-O3MDWYXF.js +0 -1
- package/dist/standalone/chunk-ONG4JEZD.js +0 -1
- package/dist/standalone/chunk-OS26JXYA.js +0 -1
- package/dist/standalone/chunk-OXFKZ4BM.js +0 -1
- package/dist/standalone/chunk-PGTEGUAB.js +0 -1
- package/dist/standalone/chunk-PTBUWRBY.js +0 -1
- package/dist/standalone/chunk-Q6HA3L2H.js +0 -1
- package/dist/standalone/chunk-QGV5ARD2.js +0 -1
- package/dist/standalone/chunk-QWRK4ESB.js +0 -1
- package/dist/standalone/chunk-RL2ITK2N.js +0 -1
- package/dist/standalone/chunk-RTJO3AR4.js +0 -1
- package/dist/standalone/chunk-SFY646MC.js +0 -1
- package/dist/standalone/chunk-T5UMHPAB.js +0 -1
- package/dist/standalone/chunk-T6HV2FQP.js +0 -2
- package/dist/standalone/chunk-T7ZKNNGX.js +0 -1
- package/dist/standalone/chunk-TCYPNSTV.js +0 -1
- package/dist/standalone/chunk-TQM6XHBA.js +0 -1
- package/dist/standalone/chunk-TRMWBRRU.js +0 -1
- package/dist/standalone/chunk-TW7KJSMR.js +0 -15
- package/dist/standalone/chunk-TYD3V4NB.js +0 -1
- package/dist/standalone/chunk-TZKLK52W.js +0 -1
- package/dist/standalone/chunk-U4RXQSQ7.js +0 -1
- package/dist/standalone/chunk-UNZ2UBVL.js +0 -1
- package/dist/standalone/chunk-VJRNOSRY.js +0 -1
- package/dist/standalone/chunk-W2BCSK5S.js +0 -1
- package/dist/standalone/chunk-W7MRISE3.js +0 -1
- package/dist/standalone/chunk-WM72PRE3.js +0 -1
- package/dist/standalone/chunk-X4WHMCOZ.js +0 -1
- package/dist/standalone/chunk-X74GEPSG.js +0 -1
- package/dist/standalone/chunk-XKPD4SFN.js +0 -1
- package/dist/standalone/chunk-XMSNLMWU.js +0 -1
- package/dist/standalone/chunk-XOPFDWXX.js +0 -1
- package/dist/standalone/chunk-XQLOVFPP.js +0 -1
- package/dist/standalone/chunk-XSHYZPGF.js +0 -1
- package/dist/standalone/chunk-XST3UEHU.js +0 -1
- package/dist/standalone/chunk-XYR5NST4.js +0 -1
- package/dist/standalone/chunk-Y74LIFSL.js +0 -1
- package/dist/standalone/chunk-YHTHRYP5.js +0 -1
- package/dist/standalone/chunk-YMEKCV27.js +0 -1
- package/dist/standalone/chunk-Z5EV64KS.js +0 -1
- package/dist/standalone/chunk-ZBON5T5A.js +0 -1
- package/dist/standalone/chunk-ZGSL4DPP.js +0 -1
- package/dist/standalone/chunk-ZOQTXWPK.js +0 -1
- package/dist/standalone/chunk-ZTOREMGH.js +0 -1
- package/dist/standalone/chunk-ZZ5GICTF.js +0 -1
- /package/dist/standalone/{chunk-UYEZR3BI.js → chunk-P6VNMPWR.js} +0 -0
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
import{c as
|
|
2
|
-
`;)
|
|
1
|
+
import{c as G}from"react/compiler-runtime";import{useState as te,useMemo as Fe,useCallback as Ye,useEffect as ue,useRef as de,useId as ct}from"react";import{u as dt}from"../packem_shared/assistant-provider-Bp72uWsq.mjs";import{u as ut}from"../packem_shared/use-assistant-rpc-GCUK2zPa.mjs";import{u as Me}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Le}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{u as De,n as Ge,b as $e,r as Ce,s as ft}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{d as qe,f as ie,c as Ae,l as mt,b as pt}from"../packem_shared/internal-hIuTpSbx.mjs";import{r as ht}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import bt from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{c as ae}from"../packem_shared/utils-bhneXptQ.mjs";import{jsxs as W,jsx as u,Fragment as xe}from"react/jsx-runtime";import{I as Re}from"../packem_shared/input-CXhxesPC.mjs";import{a as Ve}from"../packem_shared/assistant-reason-D6EwMCxT.mjs";import{diffLines as gt}from"diff";import{S as xt,a as vt}from"../packem_shared/sql-result-table-DCwooMGW.mjs";import{ShardInput as yt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{A as St}from"../packem_shared/alert-PB5W11MM.mjs";import{E as wt}from"../packem_shared/grid-features-Drvfswwy.mjs";const Ct="x",Qe=" ",kt={'"':'"',"'":"'","[":"]","`":"`"},Je=(r,e)=>{let s=e+2;for(;s<r.length&&r[s]!==`
|
|
2
|
+
`;)s+=1;return s},Xe=(r,e)=>{const s=r.indexOf("*/",e+2);return s===-1?-1:s+2},Ze=r=>{const e=r.split("");let s=0;for(;s<r.length;){const t=r[s]??"",o=kt[t];if(t==="-"&&r[s+1]==="-"){const n=Je(r,s);e.fill(Qe,s,n),s=n}else if(t==="/"&&r[s+1]==="*"){const n=Xe(r,s);if(n===-1)return;e.fill(Qe,s,n),s=n}else if(o!==void 0){let n=s+1;for(;n<r.length;)if(r[n]!==o)n+=1;else if(o!=="]"&&r[n+1]===o)n+=2;else break;if(n>=r.length)return;e.fill(Ct,s,n+1),s=n+1}else s+=1}for(let t=0;t<r.length;t+=1)r[t]===`
|
|
3
3
|
`&&(e[t]=`
|
|
4
|
-
`);return e.join("")},
|
|
5
|
-
${
|
|
6
|
-
`,e);return t===-1?l.length:t}if(n==="/"&&l[e+1]==="*"){const t=l.indexOf("*/",e+2);return t===-1?l.length:t+2}return-1},At=l=>{let e="",n=0;for(;n<l.length;){const t=_t(l,n);t===-1?(e+=l.slice(n,n+1),n+=1):(e+=l.slice(n,t).replaceAll(Lt," "),n=t)}return e},qt=l=>{const e=new Set;for(const n of l.matchAll(Rt))e.add((n[1]??"").toLowerCase());return e},Dt=(l,e)=>{const n=new Map;for(const t of l.matchAll(Tt)){const o=(t[1]??"").toLowerCase(),s=(t[2]??"").toLowerCase();e.has(o)&&(n.set(o,o),s!==""&&!It.has(s)&&n.set(s,o))}return n},Ue=(l,e)=>{const n=At(l),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:qt(n),masked:n,targets:Dt(n,t)}},Ot=/^(?:__lunora|sqlite_)/iu,Mt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,$t=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Bt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Pt=(l,e,n)=>{const t=[];for(const o of l.matchAll(Mt)){const s=o[1]??"",r=s.toLowerCase();!e.has(r)&&!n.has(r)&&!Bt.has(r)&&!Ot.test(s)&&t.push({length:s.length,message:`unknown table \`${s}\``,offset:o.index+o[0].length-s.length,severity:"error",source:"schema"})}return t},Ht=(l,e,n)=>{const t=[],o=new Map;for(const[s,r]of Object.entries(e.columns))o.set(s.toLowerCase(),new Set(r.map(c=>c.toLowerCase())));for(const s of l.matchAll($t)){const r=(s[1]??"").toLowerCase(),c=s[2]??"",a=n.get(r),i=a===void 0?void 0:o.get(a);i!==void 0&&!i.has(c.toLowerCase())&&t.push({length:c.length,message:`\`${a??""}\` has no column \`${c}\``,offset:s.index+s[0].length-c.length,severity:"error",source:"schema"})}return t},Ft=/(?<![\w$."])(?:"([a-z_][\w$]*)"|([a-z_][\w$]*))(?![.(])/giu,Wt=/\bas\s+"?([a-z_][\w$]*)"?/giu,Kt=(l,e,n,t)=>{const o=[...new Set(n.values())],s=new Map,r=new Set;for(const i of o){for(const u of e.columns[i]??[])r.add(u.toLowerCase());for(const u of e.docFields?.[i]??[])s.set(u.toLowerCase(),u)}if(s.size===0)return[];const c=new Set([...l.matchAll(Wt)].map(i=>(i[1]??"").toLowerCase())),a=[];for(const i of l.matchAll(Ft)){const u=i[1],g=u??i[2]??"",d=g.toLowerCase(),y=s.get(d);y===void 0||r.has(d)||c.has(d)||t.has(d)||n.has(d)||a.push({length:g.length,message:`\`${y}\` is a \`__doc__\` field, not a column — use \`json_extract(__doc__, '$.${y}')\``,offset:i.index+(u===void 0?0:1),severity:"error",source:"schema"})}return a},zt=(l,e)=>{if(l.trim()==="")return[];const n=ze(l),t=new Set(e.tables.map(s=>s.toLowerCase())),o=[];for(const s of n){const{offset:r,rejection:c}=s;if(c!==void 0){o.push({length:c.length,message:c.message,offset:c.offset===void 0?r:r+c.offset,severity:"error",source:"gate"});continue}const{ctes:a,masked:i,targets:u}=Ue(s.sql,e.tables);o.push(...[...Pt(i,t,a),...Ht(i,e,u),...Kt(i,e,u,a)].map(g=>({...g,offset:g.offset===void 0?r:r+g.offset})))}return o},Ut=Ce(we.lintSql),jt=600,Qt=(l,e,n)=>{const t=Te(),[o,s]=se([]),r=Ae(()=>zt(l,e),[l,e]),c=ot(l,jt),i=r.some(d=>d.source==="gate")||c.trim()==="",u=Xe(async d=>{try{const y=await t.query(Ut,{sql:c},ye(n));d.cancelled||s(y.diagnostics??[])}catch{d.cancelled||s([])}},[t,c,n]);me(()=>{if(i){s([]);return}const d={cancelled:!1};return ce(u(d)),()=>{d.cancelled=!0}},[u,i]);const g=c===l;return Ae(()=>g?[...r,...o]:r,[r,o,g])},ge=8,Yt=["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"],Gt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Jt=/[\w$]/,je=l=>l!==void 0&&Jt.test(l),Qe=l=>{let e=l.length;for(;e>0&&je(l[e-1]);)e-=1;return l.slice(e)},Ye=(l,e)=>{let n=e;for(;n>0&&je(l[n-1]);)n-=1;return{end:e,start:n,text:l.slice(n,e)}},De=(l,e)=>{const n=l.slice(0,e).trimEnd();return n.endsWith(".")||Gt.has(Qe(n).toUpperCase())},Vt=(l,e,n)=>{const t=l.slice(0,e);if(!t.endsWith("."))return;const o=Qe(t.slice(0,-1));if(o!=="")return Ue(l,n).targets.get(o.toLowerCase())??o},Ie=(l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),Oe=(l,e,n,t)=>{const o=[];for(const s of l)if(Ie(s,e)&&(o.push(t(s)),o.length>=n))break;return o},Xt=(l,e,n)=>{const t=new Map;for(const[o,s]of Object.entries(l.columns))for(const r of s)if(Ie(r,e)&&!t.has(r)&&(t.set(r,o),t.size>=n))return[...t].map(([c,a])=>({detail:a,kind:"column",label:c}));return[...t].map(([o,s])=>({detail:s,kind:"column",label:o}))},Zt=(l,e,n)=>{const t=Ye(l,e),o=Vt(l,t.start,n.tables);if(o!==void 0){const i=n.columns[o]??n.columns[o.toLowerCase()]??[];return Oe(i,t.text,ge,u=>({detail:o,kind:"column",label:u}))}if(t.text===""&&!De(l,t.start))return[];const s=Oe(n.tables,t.text,ge,i=>({kind:"table",label:i})),r=Xt(n,t.text,ge),c=Yt.flatMap(i=>t.text!==""&&Ie(i,t.text)&&i.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:i}]:[]);return(De(l,t.start)?[...r,...s,...c]:[...s,...r,...c]).slice(0,ge)},en=(l,e,n)=>{const t=Ye(l,e),o=l.slice(0,t.start)+n.label+l.slice(t.end);return{caret:t.start+n.label.length,value:o}},tn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],nn=(l,e)=>{const n=globalThis.getComputedStyle(l),t=globalThis.document.createElement("div"),{style:o}=t;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(const a of tn)o[a]=n[a];t.textContent=l.value.slice(0,Math.max(0,e));const s=globalThis.document.createElement("span");s.textContent=l.value.slice(Math.max(0,e))||".",t.append(s),globalThis.document.body.append(t);const r=s.offsetLeft-l.scrollLeft,c=s.offsetTop-l.scrollTop;return t.remove(),{left:r,top:c}},sn=(l,e,n)=>{const t=X(16),[o,s]=se(null);let r;t[0]!==l||t[1]!==e?(r=(x,p)=>{const C=Zt(x,p,l);if(C.length===0){s(null);return}const v=e.current,{left:S,top:h}=v===null?{left:0,top:0}:nn(v,p);s(w=>w!==null&&w.active===0&&w.left===S&&w.top===h&&w.suggestions.length===C.length&&w.suggestions.every((I,R)=>{const E=C.at(R);return I.kind===E?.kind&&I.label===E.label&&I.detail===E.detail})?w:{active:0,left:S,suggestions:C,top:h})},t[0]=l,t[1]=e,t[2]=r):r=t[2];const c=r;let a;t[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{s(null)},t[3]=a):a=t[3];const i=a;let u;t[4]===Symbol.for("react.memo_cache_sentinel")?(u=x=>{s(p=>{if(p===null)return p;const C=p.suggestions.length,v=(p.active+x+C)%C;return{...p,active:v}})},t[4]=u):u=t[4];const g=u;let d;t[5]!==n||t[6]!==o||t[7]!==e?(d=x=>{const p=e.current;if(o===null||p===null)return!1;const C=o.suggestions[x??o.active];if(C===void 0)return!1;const v=en(p.value,p.selectionStart,C);return n(v.value),s(null),requestAnimationFrame(()=>{const S=e.current;S!==null&&(S.focus(),S.setSelectionRange(v.caret,v.caret))}),!0},t[5]=n,t[6]=o,t[7]=e,t[8]=d):d=t[8];const y=d;let b;t[9]!==y?(b=()=>y(),t[9]=y,t[10]=b):b=t[10];const N=b;let m;return t[11]!==N||t[12]!==y||t[13]!==c||t[14]!==o?(m={close:i,commit:N,commitAt:y,move:g,refresh:c,state:o},t[11]=N,t[12]=y,t[13]=c,t[14]=o,t[15]=m):m=t[15],m},on={column:"column",keyword:"keyword",table:"table"},ln=20,rn=l=>{const e=X(17),{listboxId:n,onPick:t,state:o}=l,s=re();let r;e[0]!==o?(r=o===null?void 0:{left:o.left,top:o.top+ln},e[0]=o,e[1]=r):r=e[1];const c=r;if(o===null)return null;let a;if(e[2]!==n||e[3]!==t||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==s){let u;e[8]!==n||e[9]!==t||e[10]!==o.active||e[11]!==s?(u=(g,d)=>B("li",{"aria-selected":d===o.active,className:ie("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",d===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${n}-opt-${d.toString()}`,onMouseDown:y=>{y.preventDefault(),t(d)},role:"option",children:[f("span",{className:"truncate font-mono",children:g.label}),g.detail!==void 0&&f("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:g.detail}),f("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:s(on[g.kind])})]},`${g.kind}:${g.label}`),e[8]=n,e[9]=t,e[10]=o.active,e[11]=s,e[12]=u):u=e[12],a=o.suggestions.map(u),e[2]=n,e[3]=t,e[4]=o.active,e[5]=o.suggestions,e[6]=s,e[7]=a}else a=e[7];let i;return e[13]!==n||e[14]!==c||e[15]!==a?(i=f("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:n,role:"listbox",style:c,children:a}),e[13]=n,e[14]=c,e[15]=a,e[16]=i):i=e[16],i},an=Ce(we.listTables),cn=Ce(we.readTablePage),dn=l=>{const e=X(18),n=Te();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[o,s]=se(t);let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r={},e[1]=r):r=e[1];const[c,a]=se(r);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i={},e[2]=i):i=e[2];const[u,g]=se(i);let d;e[3]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,e[3]=d):d=e[3];const y=ue(d);let b,N;e[4]!==n||e[5]!==l?(b=()=>{const S={cancelled:!1};return ce((async()=>{try{const w=await n.query(an,{},ye(l));S.cancelled||(s(w.map(fn)),a({}),g({}),y.current=new Set)}catch{S.cancelled||(s([]),a({}),g({}),y.current=new Set)}})()),()=>{S.cancelled=!0}},N=[n,l],e[4]=n,e[5]=l,e[6]=b,e[7]=N):(b=e[6],N=e[7]),me(b,N);let m;e[8]!==n||e[9]!==l?(m=S=>{if(y.current.has(S))return;y.current.add(S),ce((async()=>{try{const w=await n.query(cn,{limit:1,offset:0,table:S},ye(l)),{sqlColumns:T}=w;if(T===void 0){y.current.delete(S);return}const I=new Set(T),R=w.columns.filter(E=>!I.has(E));a(E=>({...E,[S]:T})),g(E=>({...E,[S]:R}))}catch{y.current.delete(S)}})())},e[8]=n,e[9]=l,e[10]=m):m=e[10];const x=m;let p;e[11]!==c||e[12]!==u||e[13]!==o?(p={columns:c,docFields:u,tables:o},e[11]=c,e[12]=u,e[13]=o,e[14]=p):p=e[14];const C=p;let v;return e[15]!==x||e[16]!==C?(v={probe:x,schema:C},e[15]=x,e[16]=C,e[17]=v):v=e[17],v},Ne=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,un=l=>{const e=new Set;Ne.lastIndex=0;let n=Ne.exec(l);for(;n!==null;)e.add(n[1]??n[2]),n=Ne.exec(l);return[...e]};function fn(l){return l.name}const mn=l=>(l.metaKey||l.ctrlKey)&&!l.shiftKey&&!l.altKey&&l.key.toLowerCase()==="i",pn=l=>{const e=X(44),{inlineEditEnabled:n,onSubmit:t,probe:o,schema:s,setDraft:r}=l,c=Ze(),[a,i]=se(null),u=ue(null),g=ue(null),d=ue(null),y=sn(s,d,r),{close:b,commit:N,commitAt:m,move:x,refresh:p,state:C}=y;let v;e[0]!==m?(v=q=>{m(q)},e[0]=m,e[1]=v):v=e[1];const S=v;let h;e[2]!==p?(h=()=>{const q=d.current;q!==null&&q===document.activeElement&&p(q.value,q.selectionStart)},e[2]=p,e[3]=h):h=e[3];let w;e[4]!==p||e[5]!==s?(w=[p,s],e[4]=p,e[5]=s,e[6]=w):w=e[6],me(h,w);let T;e[7]!==o||e[8]!==p||e[9]!==r?(T=q=>{const{selectionStart:j,value:J}=q.target;r(J),i(null);for(const V of un(J))o(V);p(J,j)},e[7]=o,e[8]=p,e[9]=r,e[10]=T):T=e[10];const I=T;let R;e[11]!==p?(R=q=>{const j=q.currentTarget;p(j.value,j.selectionStart)},e[11]=p,e[12]=R):R=e[12];const E=R;let _;e[13]!==b||e[14]!==N||e[15]!==x?(_=q=>q.key==="ArrowDown"?(q.preventDefault(),x(1),!0):q.key==="ArrowUp"?(q.preventDefault(),x(-1),!0):q.key==="Escape"?(q.preventDefault(),b(),!0):(q.key==="Enter"||q.key==="Tab")&&!q.metaKey&&!q.ctrlKey&&N()?(q.preventDefault(),!0):!1,e[13]=b,e[14]=N,e[15]=x,e[16]=_):_=e[16];const L=_;let A;e[17]!==C||e[18]!==b||e[19]!==n||e[20]!==L||e[21]!==t?(A=q=>{if(!(C!==null&&L(q))){if((q.metaKey||q.ctrlKey)&&q.key==="Enter"){q.preventDefault(),t();return}if(n&&mn(q)){q.preventDefault(),b();const{selectionEnd:j,selectionStart:J,value:V}=q.currentTarget,[U,G]=J===j?[0,V.length]:[J,j];i({end:G,start:U,text:V.slice(U,G)})}}},e[17]=C,e[18]=b,e[19]=n,e[20]=L,e[21]=t,e[22]=A):A=e[22];const M=A;let W;e[23]!==b?(W=()=>{requestAnimationFrame(()=>{b()})},e[23]=b,e[24]=W):W=e[24];const K=W;let $;e[25]===Symbol.for("react.memo_cache_sentinel")?($=q=>{const{scrollLeft:j,scrollTop:J}=q.currentTarget;u.current!==null&&(u.current.scrollTop=J),g.current!==null&&(g.current.scrollTop=J,g.current.scrollLeft=j)},e[25]=$):$=e[25];const F=$;let H;e[26]===Symbol.for("react.memo_cache_sentinel")?(H=q=>{const j=d.current;j===null||q.offset===void 0||(j.focus(),j.setSelectionRange(q.offset,q.offset+(q.length??0)))},e[26]=H):H=e[26];const k=H;let D;e[27]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{i(null),d.current?.focus()},e[27]=D):D=e[27];const z=D;let P;e[28]!==a||e[29]!==r?(P=q=>{const j=d.current;if(a===null||j===null)return;const{end:J,start:V,text:U}=a;if(j.value.slice(V,J)!==U){z();return}r(j.value.slice(0,V)+q+j.value.slice(J)),i(null),j.focus(),requestAnimationFrame(()=>{j.setSelectionRange(V,V+q.length)})},e[28]=a,e[29]=r,e[30]=P):P=e[30];const oe=P;let Z;e[31]!==I||e[32]!==K||e[33]!==M||e[34]!==E?(Z={onBlur:K,onChange:I,onKeyDown:M,onScroll:F,onSelect:E},e[31]=I,e[32]=K,e[33]=M,e[34]=E,e[35]=Z):Z=e[35];let ne;return e[36]!==oe||e[37]!==C||e[38]!==b||e[39]!==a||e[40]!==c||e[41]!==S||e[42]!==Z?(ne={acceptInlineEdit:oe,autocompleteState:C,closeAutocomplete:b,closeInlineEdit:z,inlineEdit:a,handlers:Z,listboxId:c,onPickSuggestion:S,editorRef:d,gutterRef:u,overlayRef:g,revealDiagnostic:k},e[36]=oe,e[37]=C,e[38]=b,e[39]=a,e[40]=c,e[41]=S,e[42]=Z,e[43]=ne):ne=e[43],ne},hn="lunora-studio-sql-tabs",bn="lunora-studio-sql-active-tab",Le=12,pe=(l="",e="")=>({activeId:null,id:Be("tab"),name:e,sql:l}),gn=()=>Re(bn,""),xn=l=>{const e=X(16),[n,t]=Ee(hn),[o,s]=gn(),[r]=se(l);let c,a;e[0]!==r||e[1]!==t||e[2]!==n.length?(c=()=>{n.length===0&&t([r])},a=[r,t,n.length],e[0]=r,e[1]=t,e[2]=n.length,e[3]=c,e[4]=a):(c=e[3],a=e[4]),me(c,a);let i;e[5]!==r||e[6]!==n?(i=n.length===0?[r]:n,e[5]=r,e[6]=n,e[7]=i):i=e[7];const u=i;let g;e[8]!==o||e[9]!==u?(g=u.some(b=>b.id===o)?o:u[0]?.id??"",e[8]=o,e[9]=u,e[10]=g):g=e[10];const d=g;let y;return e[11]!==d||e[12]!==s||e[13]!==t||e[14]!==u?(y={activeId:d,setActiveId:s,setTabs:t,tabs:u},e[11]=d,e[12]=s,e[13]=t,e[14]=u,e[15]=y):y=e[15],y},Ge=l=>l.activeId===null&&l.sql.trim()!=="",vn=(l,e)=>[...l,e].slice(-Le),yn=(l,e,n)=>{const t=l.findIndex(r=>r.id===e);if(t===-1)return{activeId:l[0]?.id??"",tabs:[...l]};const o=l.filter(r=>r.id!==e);if(o.length===0){const r=n();return{activeId:r.id,tabs:[r]}}return{activeId:o[Math.min(t,o.length-1)].id,tabs:o}},Sn=(l,e)=>{const n=l.filter(t=>t.id===e);return n.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:n}},wn=(l,e,n)=>{const t=l.findIndex(s=>s.id===e);if(t===-1)return{activeId:n,tabs:[...l]};const o=l.slice(0,t+1);return{activeId:o.some(s=>s.id===n)?n:e,tabs:o}},Cn=l=>{const e=l();return{activeId:e.id,tabs:[e]}},Nn=(l,e,n)=>{if(l==="others")return e.filter(t=>t.id!==n);if(l==="right"){const t=e.findIndex(o=>o.id===n);return t===-1?[]:e.slice(t+1)}return[...e]},Me={error:null,pane:"results",result:null,running:!1},En=l=>{const e=X(66),{activeId:n,setActiveId:t,setTabs:o,tabs:s}=xn(l);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];const[c,a]=se(r),[i,u]=se(null),[g,d]=se(null);let y;e[1]!==n||e[2]!==s?(y=s.find(O=>O.id===n)??s[0]??pe(),e[1]=n,e[2]=s,e[3]=y):y=e[3];const b=y,N=c[b.id]??Me;let m;e[4]!==b.id||e[5]!==o?(m=O=>{o(Q=>Q.map(ee=>ee.id===b.id?{...ee,...O}:ee))},e[4]=b.id,e[5]=o,e[6]=m):m=e[6];const x=m;let p;e[7]!==b.id?(p=O=>{a(Q=>{const ee=Q[b.id]??Me;return{...Q,[b.id]:{...ee,...O}}})},e[7]=b.id,e[8]=p):p=e[8];const C=p;let v;e[9]!==t||e[10]!==o||e[11]!==s.length?(v=()=>{if(s.length>=Le)return;const O=pe();o(Q=>vn(Q,O)),t(O.id)},e[9]=t,e[10]=o,e[11]=s.length,e[12]=v):v=e[12];const S=v;let h;e[13]!==t||e[14]!==o?(h=O=>{u(null),d(null),o(O.tabs),t(O.activeId);const Q=new Set(O.tabs.map(kn));a(ee=>Object.fromEntries(Object.entries(ee).filter(ae=>{const[de]=ae;return Q.has(de)})))},e[13]=t,e[14]=o,e[15]=h):h=e[15];const w=h;let T;e[16]!==w||e[17]!==s?(T=O=>{w(yn(s,O,pe))},e[16]=w,e[17]=s,e[18]=T):T=e[18];const I=T;let R;e[19]!==n||e[20]!==w||e[21]!==s?(R=(O,Q)=>{w(O==="others"?Sn(s,Q):O==="right"?wn(s,Q,n):Cn(pe))},e[19]=n,e[20]=w,e[21]=s,e[22]=R):R=e[22];const E=R;let _;e[23]!==E||e[24]!==i||e[25]!==s?(_=O=>{i!==null&&(Nn(O,s,i.id).some(Tn)?d(O):E(O,i.id))},e[23]=E,e[24]=i,e[25]=s,e[26]=_):_=e[26];const L=_;let A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=(O,Q)=>{Q.preventDefault(),d(null),u({id:O,x:Q.clientX,y:Q.clientY})},e[27]=A):A=e[27];const M=A;let W;e[28]===Symbol.for("react.memo_cache_sentinel")?(W=()=>{u(null),d(null)},e[28]=W):W=e[28];const K=W;let $;e[29]===Symbol.for("react.memo_cache_sentinel")?($=O=>{O.preventDefault(),u(null),d(null)},e[29]=$):$=e[29];const F=$;let H;e[30]!==L?(H=()=>{L("others")},e[30]=L,e[31]=H):H=e[31];const k=H;let D;e[32]!==L?(D=()=>{L("right")},e[32]=L,e[33]=D):D=e[33];const z=D;let P;e[34]!==L?(P=()=>{L("all")},e[34]=L,e[35]=P):P=e[35];const oe=P;let Z;e[36]!==E||e[37]!==g||e[38]!==i?(Z=()=>{i!==null&&g!==null&&E(g,i.id),d(null)},e[36]=E,e[37]=g,e[38]=i,e[39]=Z):Z=e[39];const ne=Z;let q;e[40]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{d(null)},e[40]=q):q=e[40];const j=q;let J;e[41]!==i?(J=i===null?void 0:{left:i.x,top:i.y},e[41]=i,e[42]=J):J=e[42];const V=J;let U;e[43]!==o?(U=O=>{o(Q=>Q.map(ee=>ee.activeId===O?{...ee,activeId:null}:ee))},e[43]=o,e[44]=U):U=e[44];const G=U;let Y;e[45]!==o?(Y=(O,Q)=>{o(ee=>ee.map(ae=>ae.id===O?{...ae,name:Q}:ae))},e[45]=o,e[46]=Y):Y=e[46];const te=Y;let le;return e[47]!==b||e[48]!==n||e[49]!==S||e[50]!==I||e[51]!==ne||e[52]!==oe||e[53]!==k||e[54]!==z||e[55]!==N||e[56]!==C||e[57]!==x||e[58]!==g||e[59]!==te||e[60]!==t||e[61]!==i||e[62]!==V||e[63]!==s||e[64]!==G?(le={activeTab:b,activeTabId:n,addEditorTab:S,cancelBulk:j,closeEditorTab:I,closeTabMenu:K,confirmBulk:ne,menuStyle:V,onBackdropContextMenu:F,onCloseAll:oe,onCloseOthers:k,onCloseToRight:z,openTabMenu:M,output:N,patchActiveOutput:C,patchActiveTab:x,pendingBulk:g,renameTab:te,setActiveTabId:t,tabMenu:i,tabs:s,unlinkQuery:G},e[47]=b,e[48]=n,e[49]=S,e[50]=I,e[51]=ne,e[52]=oe,e[53]=k,e[54]=z,e[55]=N,e[56]=C,e[57]=x,e[58]=g,e[59]=te,e[60]=t,e[61]=i,e[62]=V,e[63]=s,e[64]=G,e[65]=le):le=e[65],le};function kn(l){return l.id}function Tn(l){return Ge(l)}const Rn="lunora-studio-sql-queries",fe="lunora-studio-sql-history",In="lunora-studio-sql-remember-history",Ln=25,_n=l=>{const e=X(41),{loadIntoActiveTab:n,unlinkQuery:t}=l,o=re(),[s,r]=Ee(Rn),[c,a]=Re(In,!1),[i,u]=Ee(fe,c?"local":"session");let g,d;e[0]!==c?(g=()=>{c||be(fe,"local")},d=[c],e[0]=c,e[1]=g,e[2]=d):(g=e[1],d=e[2]),me(g,d);const[y,b]=se(""),N=ue(null);let m;e[3]!==u?(m=k=>{u(D=>D[0]?.sql===k?D:[{at:Date.now(),sql:k},...D.filter(P=>P.sql!==k)].slice(0,Ln))},e[3]=u,e[4]=m):m=e[4];const x=m;let p;e[5]!==n||e[6]!==r||e[7]!==o?(p=()=>{const k={id:Be("q"),name:o("Untitled query"),sql:""};r(D=>[k,...D]),n("",k.id)},e[5]=n,e[6]=r,e[7]=o,e[8]=p):p=e[8];const C=p;let v;e[9]!==n||e[10]!==s?(v=k=>{const D=s.find(z=>z.id===k);D!==void 0&&(n(D.sql,k),N.current?.querySelector(`[data-testid="sql-query-${k}"]`)?.scrollIntoView({block:"nearest"}))},e[9]=n,e[10]=s,e[11]=v):v=e[11];const S=v;let h;e[12]!==r||e[13]!==t?(h=k=>{r(D=>D.filter(z=>z.id!==k)),t(k)},e[12]=r,e[13]=t,e[14]=h):h=e[14];const w=h;let T;e[15]!==n?(T=k=>{n(k.currentTarget.dataset.sql??"",null)},e[15]=n,e[16]=T):T=e[16];const I=T;let R;e[17]!==n?(R=k=>{n(k.currentTarget.dataset.sql??"",null)},e[17]=n,e[18]=R):R=e[18];const E=R;let _;e[19]!==u?(_=()=>{u([]),be(fe,"local"),be(fe,"session")},e[19]=u,e[20]=_):_=e[20];const L=_;let A;e[21]!==i||e[22]!==a?(A=k=>{et(fe,i,k?"local":"session"),k||be(fe,"local"),a(k)},e[21]=i,e[22]=a,e[23]=A):A=e[23];const M=A;let W;e[24]===Symbol.for("react.memo_cache_sentinel")?(W=k=>{b(k.target.value)},e[24]=W):W=e[24];const K=W;let $;e[25]!==r?($=(k,D)=>{r(z=>z.map(P=>P.id===k?{...P,sql:D}:P))},e[25]=r,e[26]=$):$=e[26];const F=$;let H;return e[27]!==L||e[28]!==w||e[29]!==i||e[30]!==E||e[31]!==I||e[32]!==C||e[33]!==s||e[34]!==x||e[35]!==c||e[36]!==y||e[37]!==S||e[38]!==M||e[39]!==F?(H={clearHistory:L,deleteQuery:w,history:i,listRef:N,loadFromHistory:E,loadTemplate:I,newQuery:C,onSearchChange:K,queries:s,recordHistory:x,rememberHistory:c,search:y,selectQuery:S,setRememberHistory:M,updateQuerySql:F},e[27]=L,e[28]=w,e[29]=i,e[30]=E,e[31]=I,e[32]=C,e[33]=s,e[34]=x,e[35]=c,e[36]=y,e[37]=S,e[38]=M,e[39]=F,e[40]=H):H=e[40],H},_e="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",An=(l,e)=>{const n=[];for(const o of l){if(o.offset===void 0||o.length===void 0||o.length<=0)continue;const s=Math.max(0,Math.min(o.offset,e)),r=Math.max(s,Math.min(o.offset+o.length,e));s!==r&&n.push({end:r,severity:o.severity,start:s})}n.sort((o,s)=>o.start-s.start);const t=[];for(const o of n)o.start>=(t.at(-1)?.end??0)&&t.push(o);return t},Je=(l,e)=>e(l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="too-long"?"The statement is too long to rewrite. Select a shorter part of it.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached."),qn=l=>{const e=X(51),{assistant:n,failed:t,onGenerated:o}=l,s=re(),[r,c]=se("");if(n.unavailable)return null;let a;e[0]!==n?(a=n.pending("sql"),e[0]=n,e[1]=a):a=e[1];const i=a;let u;if(e[2]!==n||e[3]!==t||e[4]!==o||e[5]!==i||e[6]!==r||e[7]!==s){const g=n.reason("sql");let d;e[9]!==n||e[10]!==t||e[11]!==o||e[12]!==r?(d=E=>{const _=r.trim();if(_===""&&!E)return;ce((async()=>{const A=await n.generate(_===""?"fix the failing statement":_,E?t:void 0);A!==void 0&&o(A)})())},e[9]=n,e[10]=t,e[11]=o,e[12]=r,e[13]=d):d=e[13];const y=d;let b;e[14]!==s?(b=s("Describe the query you want"),e[14]=s,e[15]=b):b=e[15];let N;e[16]===Symbol.for("react.memo_cache_sentinel")?(N=E=>{c(E.target.value)},e[16]=N):N=e[16];let m;e[17]!==y?(m=E=>{E.key==="Enter"&&(E.preventDefault(),y(!1))},e[17]=y,e[18]=m):m=e[18];let x;e[19]!==s?(x=s("Describe the query you want"),e[19]=s,e[20]=x):x=e[20];let p;e[21]!==i||e[22]!==r||e[23]!==b||e[24]!==m||e[25]!==x?(p=f(Pe,{"aria-label":b,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:i,onChange:N,onKeyDown:m,placeholder:x,value:r}),e[21]=i,e[22]=r,e[23]=b,e[24]=m,e[25]=x,e[26]=p):p=e[26];const C=i&&"opacity-60";let v;e[27]!==C?(v=ie("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",C),e[27]=C,e[28]=v):v=e[28];let S;e[29]!==i||e[30]!==r?(S=i||r.trim()==="",e[29]=i,e[30]=r,e[31]=S):S=e[31];let h;e[32]!==y?(h=()=>{y(!1)},e[32]=y,e[33]=h):h=e[33];let w;e[34]!==i||e[35]!==s?(w=s(i?"Thinking…":"Draft SQL"),e[34]=i,e[35]=s,e[36]=w):w=e[36];let T;e[37]!==v||e[38]!==S||e[39]!==h||e[40]!==w?(T=f("button",{className:v,"data-testid":"sql-assistant-generate",disabled:S,onClick:h,type:"button",children:w}),e[37]=v,e[38]=S,e[39]=h,e[40]=w,e[41]=T):T=e[41];let I;e[42]!==t||e[43]!==i||e[44]!==y||e[45]!==s?(I=t!==void 0&&f("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:i,onClick:()=>{y(!0)},type:"button",children:s("Fix this")}),e[42]=t,e[43]=i,e[44]=y,e[45]=s,e[46]=I):I=e[46];let R;e[47]!==T||e[48]!==I||e[49]!==p?(R=B("div",{className:"flex items-center gap-2",children:[p,T,I]}),e[47]=T,e[48]=I,e[49]=p,e[50]=R):R=e[50],u=B("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[R,g!==void 0&&f("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Je(g,s)})]}),e[2]=n,e[3]=t,e[4]=o,e[5]=i,e[6]=r,e[7]=s,e[8]=u}else u=e[8];return u},Dn=l=>{const e=X(8),{diagnostics:n,draft:t,scrollRef:o}=l;let s,r;if(e[0]!==n||e[1]!==t){r=Symbol.for("react.early_return_sentinel");e:{const i=An(n,t.length);if(i.length===0){r=null;break e}s=[];let u=0;for(const[g,d]of i.entries())d.start>u&&s.push(t.slice(u,d.start)),s.push(f("span",{className:ie("decoration-wavy underline underline-offset-4",d.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(d.start,d.end)},`${d.start.toString()}-${g.toString()}`)),u=d.end;s.push(t.slice(u))}e[0]=n,e[1]=t,e[2]=s,e[3]=r}else s=e[2],r=e[3];if(r!==Symbol.for("react.early_return_sentinel"))return r;let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=ie("pointer-events-none absolute inset-0 overflow-hidden text-transparent",_e),e[4]=c):c=e[4];let a;return e[5]!==s||e[6]!==o?(a=f("div",{"aria-hidden":"true",className:c,"data-testid":"sql-diagnostics-overlay",ref:o,children:s}),e[5]=s,e[6]=o,e[7]=a):a=e[7],a},On={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Mn=l=>{const e=X(10),{diagnostics:n,onSelect:t}=l,o=re();if(n.length===0)return null;let s;e[0]!==o?(s=o("SQL problems"),e[0]=o,e[1]=s):s=e[1];let r;if(e[2]!==n||e[3]!==t){let a;e[5]!==t?(a=(i,u)=>f("li",{children:B("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:()=>{t(i)},type:"button",children:[f("span",{className:ie("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",i.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:On[i.source]}),f("span",{className:"min-w-0 text-muted-foreground",children:i.message})]})},`${i.source}-${(i.offset??u).toString()}-${u.toString()}`),e[5]=t,e[6]=a):a=e[6],r=n.map(a),e[2]=n,e[3]=t,e[4]=r}else r=e[4];let c;return e[7]!==s||e[8]!==r?(c=f("ul",{"aria-label":s,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:r}),e[7]=s,e[8]=r,e[9]=c):c=e[9],c},$n=l=>(l.endsWith(`
|
|
7
|
-
`)?
|
|
8
|
-
`),
|
|
9
|
-
`).length;I="flex min-h-0 min-w-0 flex-1 flex-col",e[17]!==n||e[18]!==r||e[19]!==b?(R=f(qn,{assistant:n,failed:r,onGenerated:b}),e[17]=n,e[18]=r,e[19]=b,e[20]=R):R=e[20],e[21]!==n||e[22]!==s.length||e[23]!==u||e[24]!==d||e[25]!==y?(E=u!==null&&f(Wn,{onAccept:d,onCancel:y,rpc:n,source:u.text,whole:u.start===0&&u.end===s.length},`${u.start.toString()}-${u.end.toString()}`),e[21]=n,e[22]=s.length,e[23]=u,e[24]=d,e[25]=y,e[26]=E):E=e[26],T="flex min-h-0 min-w-0 flex-1",C="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",S=i,h=Kn,w=Array.from({length:P},Un),e[0]=n,e[1]=s,e[2]=r,e[3]=i,e[4]=u,e[5]=d,e[6]=y,e[7]=b,e[8]=C,e[9]=v,e[10]=S,e[11]=h,e[12]=w,e[13]=T,e[14]=I,e[15]=R,e[16]=E}else C=e[8],v=e[9],S=e[10],h=e[11],w=e[12],T=e[13],I=e[14],R=e[15],E=e[16];let _;e[27]!==C||e[28]!==v||e[29]!==S||e[30]!==h||e[31]!==w?(_=f("div",{"aria-hidden":C,className:v,ref:S,style:h,children:w}),e[27]=C,e[28]=v,e[29]=S,e[30]=h,e[31]=w,e[32]=_):_=e[32];let L;e[33]!==o||e[34]!==s||e[35]!==x?(L=f(Dn,{diagnostics:o,draft:s,scrollRef:x}),e[33]=o,e[34]=s,e[35]=x,e[36]=L):L=e[36];let A;e[37]!==t||e[38]!==g?(A=t===null?void 0:`${g}-opt-${t.active.toString()}`,e[37]=t,e[38]=g,e[39]=A):A=e[39];const M=t===null?void 0:g,W=t!==null;let K;e[40]!==p?(K=p("SQL query"),e[40]=p,e[41]=K):K=e[41];let $;e[42]!==s||e[43]!==a||e[44]!==c.onBlur||e[45]!==c.onChange||e[46]!==c.onKeyDown||e[47]!==c.onScroll||e[48]!==c.onSelect||e[49]!==A||e[50]!==M||e[51]!==W||e[52]!==K?($=f("textarea",{"aria-activedescendant":A,"aria-autocomplete":"list","aria-controls":M,"aria-expanded":W,"aria-label":K,className:`relative size-full resize-none bg-transparent outline-none ${_e}`,"data-testid":"sql-input",onBlur:c.onBlur,onChange:c.onChange,onKeyDown:c.onKeyDown,onScroll:c.onScroll,onSelect:c.onSelect,placeholder:"SELECT * FROM …",ref:a,role:"combobox",spellCheck:!1,value:s}),e[42]=s,e[43]=a,e[44]=c.onBlur,e[45]=c.onChange,e[46]=c.onKeyDown,e[47]=c.onScroll,e[48]=c.onSelect,e[49]=A,e[50]=M,e[51]=W,e[52]=K,e[53]=$):$=e[53];let F;e[54]!==t||e[55]!==g||e[56]!==N?(F=f(rn,{listboxId:g,onPick:N,state:t}),e[54]=t,e[55]=g,e[56]=N,e[57]=F):F=e[57];let H;e[58]!==L||e[59]!==$||e[60]!==F?(H=B("div",{className:"relative min-w-0 flex-1 bg-background",children:[L,$,F]}),e[58]=L,e[59]=$,e[60]=F,e[61]=H):H=e[61];let k;e[62]!==_||e[63]!==H||e[64]!==T?(k=B("div",{className:T,children:[_,H]}),e[62]=_,e[63]=H,e[64]=T,e[65]=k):k=e[65];let D;e[66]!==o||e[67]!==m?(D=f(Mn,{diagnostics:o,onSelect:m}),e[66]=o,e[67]=m,e[68]=D):D=e[68];let z;return e[69]!==k||e[70]!==D||e[71]!==I||e[72]!==R||e[73]!==E?(z=B("div",{className:I,children:[R,E,k,D]}),e[69]=k,e[70]=D,e[71]=I,e[72]=R,e[73]=E,e[74]=z):z=e[74],z};function Un(l,e){return f("div",{children:e+1},e)}const Ve=[{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;"}],jn=l=>{const e=X(29),{active:n,onDelete:t,onSelect:o,query:s}=l,r=re();let c;e[0]!==o||e[1]!==s.id?(c=()=>{o(s.id)},e[0]=o,e[1]=s.id,e[2]=c):c=e[2];const a=c;let i;e[3]!==t||e[4]!==s.id?(i=h=>{h.stopPropagation(),t(s.id)},e[3]=t,e[4]=s.id,e[5]=i):i=e[5];const u=i,g=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground";let d;e[6]!==g?(d=ie("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",g),e[6]=g,e[7]=d):d=e[7];const y=`sql-query-${s.id}`;let b;e[8]===Symbol.for("react.memo_cache_sentinel")?(b=f("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:f("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=b):b=e[8];let N;e[9]!==s.name?(N=f("span",{className:"truncate",children:s.name}),e[9]=s.name,e[10]=N):N=e[10];let m;e[11]!==n||e[12]!==a||e[13]!==d||e[14]!==y||e[15]!==N?(m=B("button",{"aria-pressed":n,className:d,"data-testid":y,onClick:a,type:"button",children:[b,N]}),e[11]=n,e[12]=a,e[13]=d,e[14]=y,e[15]=N,e[16]=m):m=e[16];let x;e[17]!==r?(x=r("Delete query"),e[17]=r,e[18]=x):x=e[18];let p;e[19]!==r?(p=r("Delete query"),e[19]=r,e[20]=p):p=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=f("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:f("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=C):C=e[21];let v;e[22]!==u||e[23]!==p||e[24]!==x?(v=f("button",{"aria-label":x,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:u,title:p,type:"button",children:C}),e[22]=u,e[23]=p,e[24]=x,e[25]=v):v=e[25];let S;return e[26]!==v||e[27]!==m?(S=B("li",{className:"group/q flex items-center",children:[m,v]}),e[26]=v,e[27]=m,e[28]=S):S=e[28],S},$e="sql-history-remember",Qn=(l,e)=>{const n=e.trim().toLowerCase();return n===""?[...l]:l.filter(t=>t.name.toLowerCase().includes(n))},Yn=l=>{const e=X(66),{activeId:n,history:t,listRef:o,onClearHistory:s,onDelete:r,onLoadHistory:c,onLoadTemplate:a,onNew:i,onSearchChange:u,onSelect:g,onToggleRememberHistory:d,queries:y,rememberHistory:b,search:N}=l,m=re();let x,p,C,v,S;if(e[0]!==n||e[1]!==o||e[2]!==r||e[3]!==i||e[4]!==u||e[5]!==g||e[6]!==d||e[7]!==y||e[8]!==N||e[9]!==m){const A=Qn(y,N);let M;e[15]!==d?(M=P=>{d(P.target.checked)},e[15]=d,e[16]=M):M=e[16],x=M,C="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let W;e[17]!==m?(W=m("Search queries…"),e[17]=m,e[18]=W):W=e[18];let K;e[19]!==u||e[20]!==N||e[21]!==W?(K=f("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:u,placeholder:W,type:"text",value:N}),e[19]=u,e[20]=N,e[21]=W,e[22]=K):K=e[22];let $;e[23]!==m?($=m("New query"),e[23]=m,e[24]=$):$=e[24];let F;e[25]!==m?(F=m("New query"),e[25]=m,e[26]=F):F=e[26];let H;e[27]===Symbol.for("react.memo_cache_sentinel")?(H=f("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:f("path",{d:"M12 5v14M5 12h14"})}),e[27]=H):H=e[27];let k;e[28]!==i||e[29]!==$||e[30]!==F?(k=f("button",{"aria-label":$,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:i,title:F,type:"button",children:H}),e[28]=i,e[29]=$,e[30]=F,e[31]=k):k=e[31],e[32]!==k||e[33]!==K?(v=B("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[K,k]}),e[32]=k,e[33]=K,e[34]=v):v=e[34],p="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let D;e[35]!==m?(D=m("Private"),e[35]=m,e[36]=D):D=e[36];let z;e[37]!==D?(z=f("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:D}),e[37]=D,e[38]=z):z=e[38],S=B("div",{children:[z,A.length===0?f("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:m("No saved queries yet — they save to this browser as you type.")}):f("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:A.map(P=>f(jn,{active:n===P.id,onDelete:r,onSelect:g,query:P},P.id))})]}),e[0]=n,e[1]=o,e[2]=r,e[3]=i,e[4]=u,e[5]=g,e[6]=d,e[7]=y,e[8]=N,e[9]=m,e[10]=x,e[11]=p,e[12]=C,e[13]=v,e[14]=S}else x=e[10],p=e[11],C=e[12],v=e[13],S=e[14];let h;e[39]!==m?(h=m("Reference"),e[39]=m,e[40]=h):h=e[40];let w;e[41]!==h?(w=f("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[41]=h,e[42]=w):w=e[42];let T;e[43]!==a?(T=Ve.map(A=>f("li",{children:B("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":A.sql,onClick:a,type:"button",children:[f("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:f("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),A.label]})},A.label)),e[43]=a,e[44]=T):T=e[44];let I;e[45]!==T?(I=f("ul",{className:"flex flex-col gap-px",children:T}),e[45]=T,e[46]=I):I=e[46];let R;e[47]!==w||e[48]!==I?(R=B("div",{children:[w,I]}),e[47]=w,e[48]=I,e[49]=R):R=e[49];let E;e[50]!==t||e[51]!==s||e[52]!==c||e[53]!==x||e[54]!==b||e[55]!==m?(E=t.length>0&&B("div",{children:[B("div",{className:"flex items-center justify-between px-1 pb-1",children:[f("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m("History")}),f("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:s,type:"button",children:m("Clear history")})]}),B("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 pb-1.5 text-[11px] text-muted-foreground",htmlFor:$e,children:[f("input",{checked:b,"data-testid":"sql-history-remember",id:$e,onChange:x,type:"checkbox"}),m("Keep history on this browser")]}),f("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(A=>f("li",{children:B("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":A.sql,"data-testid":"sql-history-item",onClick:c,title:A.sql,type:"button",children:[f("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:f("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),f("span",{className:"truncate font-mono",children:A.sql})]})},`${A.at.toString()}:${A.sql}`))})]}),e[50]=t,e[51]=s,e[52]=c,e[53]=x,e[54]=b,e[55]=m,e[56]=E):E=e[56];let _;e[57]!==p||e[58]!==E||e[59]!==S||e[60]!==R?(_=B("div",{className:p,children:[S,R,E]}),e[57]=p,e[58]=E,e[59]=S,e[60]=R,e[61]=_):_=e[61];let L;return e[62]!==_||e[63]!==C||e[64]!==v?(L=B("aside",{className:C,children:[v,_]}),e[62]=_,e[63]=C,e[64]=v,e[65]=L):L=e[65],L},ve=l=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${l?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,Gn=l=>{const e=X(97),{assistant:n,chart:t,className:o,durationMs:s,error:r,onFormat:c,onInferChart:a,onRun:i,onSelectStatement:u,onShardKeyChange:g,onShowChart:d,onShowExplain:y,onShowResults:b,onToggleSplit:N,pane:m,result:x,running:p,script:C,shardKey:v,splitView:S}=l,h=re(),w=m==="results";let T;e[0]!==w?(T=ve(w),e[0]=w,e[1]=T):T=e[1];let I;e[2]!==h?(I=h("Results"),e[2]=h,e[3]=I):I=e[3];let R;e[4]!==b||e[5]!==T||e[6]!==I?(R=f("button",{className:T,"data-testid":"sql-tab-results",onClick:b,type:"button",children:I}),e[4]=b,e[5]=T,e[6]=I,e[7]=R):R=e[7];const E=m==="chart";let _;e[8]!==E?(_=ve(E),e[8]=E,e[9]=_):_=e[9];let L;e[10]!==h?(L=h("Chart"),e[10]=h,e[11]=L):L=e[11];let A;e[12]!==d||e[13]!==_||e[14]!==L?(A=f("button",{className:_,"data-testid":"sql-tab-chart",onClick:d,type:"button",children:L}),e[12]=d,e[13]=_,e[14]=L,e[15]=A):A=e[15];let M;e[16]!==n||e[17]!==a||e[18]!==m||e[19]!==x||e[20]!==h?(M=!n.unavailable&&m==="chart"&&x!==null&&f("button",{className:ve(!1),"data-testid":"sql-infer-chart",disabled:n.pending("chart"),onClick:a,type:"button",children:n.pending("chart")?h("Thinking…"):h("Suggest chart")}),e[16]=n,e[17]=a,e[18]=m,e[19]=x,e[20]=h,e[21]=M):M=e[21];const W=m==="explain";let K;e[22]!==W?(K=ve(W),e[22]=W,e[23]=K):K=e[23];let $;e[24]!==h?($=h("Explain"),e[24]=h,e[25]=$):$=e[25];let F;e[26]!==y||e[27]!==K||e[28]!==$?(F=f("button",{className:K,"data-testid":"sql-tab-explain",onClick:y,type:"button",children:$}),e[26]=y,e[27]=K,e[28]=$,e[29]=F):F=e[29];let H;e[30]!==h?(H=h("Split editor and results"),e[30]=h,e[31]=H):H=e[31];const k=`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"}`;let D;e[32]!==h?(D=h("Split editor and results"),e[32]=h,e[33]=D):D=e[33];let z;e[34]===Symbol.for("react.memo_cache_sentinel")?(z=B("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[f("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),f("path",{d:"M12 4v16"})]}),e[34]=z):z=e[34];let P;e[35]!==N||e[36]!==S||e[37]!==H||e[38]!==k||e[39]!==D?(P=f("button",{"aria-label":H,"aria-pressed":S,className:k,"data-testid":"sql-split-toggle",onClick:N,title:D,type:"button",children:z}),e[35]=N,e[36]=S,e[37]=H,e[38]=k,e[39]=D,e[40]=P):P=e[40];let oe;e[41]!==x?(oe=x!==null&&x.columns.length>0&&f(dt,{columns:x.columns,name:"query-result",rows:x.rows}),e[41]=x,e[42]=oe):oe=e[42];let Z;e[43]!==h?(Z=h("Format"),e[43]=h,e[44]=Z):Z=e[44];let ne;e[45]!==c||e[46]!==p||e[47]!==Z?(ne=f("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:p,onClick:c,type:"button",children:Z}),e[45]=c,e[46]=p,e[47]=Z,e[48]=ne):ne=e[48];let q;e[49]!==g||e[50]!==v?(q=f(at,{onChange:g,testId:"sql-shard-input",value:v}),e[49]=g,e[50]=v,e[51]=q):q=e[51];let j;e[52]!==p||e[53]!==h?(j=h(p?"Running…":"Run"),e[52]=p,e[53]=h,e[54]=j):j=e[54];let J;e[55]===Symbol.for("react.memo_cache_sentinel")?(J=f("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"⌘↵"}),e[55]=J):J=e[55];let V;e[56]!==i||e[57]!==p||e[58]!==j?(V=B("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:p,onClick:i,type:"button",children:[j,J]}),e[56]=i,e[57]=p,e[58]=j,e[59]=V):V=e[59];let U;e[60]!==P||e[61]!==oe||e[62]!==ne||e[63]!==q||e[64]!==V?(U=B("div",{className:"ms-auto flex items-center gap-2",children:[P,oe,ne,q,V]}),e[60]=P,e[61]=oe,e[62]=ne,e[63]=q,e[64]=V,e[65]=U):U=e[65];let G;e[66]!==F||e[67]!==U||e[68]!==R||e[69]!==A||e[70]!==M?(G=B("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[R,A,M,F,U]}),e[66]=F,e[67]=U,e[68]=R,e[69]=A,e[70]=M,e[71]=G):G=e[71];let Y;e[72]!==u||e[73]!==C?(Y=C!==void 0&&f("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:C.runs.map((ae,de)=>f("button",{"aria-pressed":de===C.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${de===C.selected?"border-foreground text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${ae.error===null?"":"border-destructive/50 text-destructive"}`,"data-testid":`sql-statement-${de.toString()}`,onClick:()=>{u(de)},title:ae.sql,type:"button",children:de+1},`${de.toString()}:${ae.sql}`))}),e[72]=u,e[73]=C,e[74]=Y):Y=e[74];let te;e[75]!==r?(te=r!==null&&f(ct,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:r}),e[75]=r,e[76]=te):te=e[76];let le;e[77]!==r||e[78]!==x||e[79]!==h?(le=r===null&&x===null&&f("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:h("Click Run to execute your query.")}),e[77]=r,e[78]=x,e[79]=h,e[80]=le):le=e[80];let O;e[81]!==t||e[82]!==s||e[83]!==r||e[84]!==m||e[85]!==x||e[86]!==h?(O=r===null&&x!==null&&B("div",{"data-testid":"sql-result",children:[m==="chart"?f(rt,{axes:t,result:x}):f(it,{result:x}),B("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:[x.truncated?h("Showing the first {max} rows.",{max:x.rows.length}):h("{count} rows",{count:x.rowCount}),s!==void 0&&` · ${h("{ms} ms",{ms:Math.round(s)})}`]})]}),e[81]=t,e[82]=s,e[83]=r,e[84]=m,e[85]=x,e[86]=h,e[87]=O):O=e[87];let Q;e[88]!==te||e[89]!==le||e[90]!==O?(Q=B("div",{className:"min-h-0 flex-1 overflow-auto",children:[te,le,O]}),e[88]=te,e[89]=le,e[90]=O,e[91]=Q):Q=e[91];let ee;return e[92]!==o||e[93]!==G||e[94]!==Y||e[95]!==Q?(ee=B("div",{className:o,children:[G,Y,Q]}),e[92]=o,e[93]=G,e[94]=Y,e[95]=Q,e[96]=ee):ee=e[96],ee},Jn=(l,e)=>l.trim()===""?e:(l.split(`
|
|
10
|
-
`)[0]??l).slice(0,24),Vn=l=>{l?.focus(),l?.select()},Xn=l=>{const e=X(14),{initial:n,onCancel:t,onCommit:o,placeholder:s,testId:r}=l,c=re();let a;e[0]!==o?(a=b=>{o(b.currentTarget.value.trim())},e[0]=o,e[1]=a):a=e[1];const i=a;let u;e[2]!==t||e[3]!==o?(u=b=>{b.key==="Enter"?o(b.currentTarget.value.trim()):b.key==="Escape"&&t()},e[2]=t,e[3]=o,e[4]=u):u=e[4];const g=u;let d;e[5]!==c?(d=c("Tab title"),e[5]=c,e[6]=d):d=e[6];let y;return e[7]!==n||e[8]!==i||e[9]!==g||e[10]!==s||e[11]!==d||e[12]!==r?(y=f("input",{"aria-label":d,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":r,defaultValue:n,onBlur:i,onKeyDown:g,placeholder:s,ref:Vn,type:"text"}),e[7]=n,e[8]=i,e[9]=g,e[10]=s,e[11]=d,e[12]=r,e[13]=y):y=e[13],y},Zn=l=>{const e=X(29),{idBase:n,onDiscard:t,onKeep:o}=l,s=re(),r=`sql-tab-close-prompt-${n}`;let c;e[0]!==s?(c=s("Discard?"),e[0]=s,e[1]=c):c=e[1];let a;e[2]!==c?(a=f("span",{className:"text-[11px] text-muted-foreground",children:c}),e[2]=c,e[3]=a):a=e[3];let i;e[4]!==s?(i=s("Discard changes"),e[4]=s,e[5]=i):i=e[5];const u=`sql-tab-close-confirm-${n}`;let g;e[6]!==s?(g=s("Discard changes"),e[6]=s,e[7]=g):g=e[7];let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=f("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:f("path",{d:"M5 13l4 4L19 7"})}),e[8]=d):d=e[8];let y;e[9]!==t||e[10]!==i||e[11]!==u||e[12]!==g?(y=f("button",{"aria-label":i,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":u,onClick:t,title:g,type:"button",children:d}),e[9]=t,e[10]=i,e[11]=u,e[12]=g,e[13]=y):y=e[13];let b;e[14]!==s?(b=s("Keep editing"),e[14]=s,e[15]=b):b=e[15];const N=`sql-tab-close-cancel-${n}`;let m;e[16]!==s?(m=s("Keep editing"),e[16]=s,e[17]=m):m=e[17];let x;e[18]===Symbol.for("react.memo_cache_sentinel")?(x=f("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:f("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=x):x=e[18];let p;e[19]!==o||e[20]!==N||e[21]!==m||e[22]!==b?(p=f("button",{"aria-label":b,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":N,onClick:o,title:m,type:"button",children:x}),e[19]=o,e[20]=N,e[21]=m,e[22]=b,e[23]=p):p=e[23];let C;return e[24]!==r||e[25]!==p||e[26]!==a||e[27]!==y?(C=B("span",{className:"flex shrink-0 items-center gap-1","data-testid":r,role:"group",children:[a,y,p]}),e[24]=r,e[25]=p,e[26]=a,e[27]=y,e[28]=C):C=e[28],C},es=l=>{const e=X(47),{active:n,canClose:t,onClose:o,onMenu:s,onRename:r,onSelect:c,tab:a}=l,i=re(),[u,g]=se(!1),[d,y]=se(!1);let b;e[0]!==s||e[1]!==a.id?(b=P=>{s(a.id,P)},e[0]=s,e[1]=a.id,e[2]=b):b=e[2];const N=b;let m;e[3]!==c||e[4]!==a.id?(m=()=>{c(a.id)},e[3]=c,e[4]=a.id,e[5]=m):m=e[5];const x=m;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{g(!0)},e[6]=p):p=e[6];const C=p;let v;e[7]!==o||e[8]!==a?(v=P=>{P.stopPropagation(),Ge(a)?y(!0):o(a.id)},e[7]=o,e[8]=a,e[9]=v):v=e[9];const S=v;let h;e[10]!==o||e[11]!==a.id?(h=P=>{P.stopPropagation(),y(!1),o(a.id)},e[10]=o,e[11]=a.id,e[12]=h):h=e[12];const w=h;let T;e[13]===Symbol.for("react.memo_cache_sentinel")?(T=P=>{P.stopPropagation(),y(!1)},e[13]=T):T=e[13];const I=T;let R;e[14]!==r||e[15]!==a.id?(R=P=>{r(a.id,P),g(!1)},e[14]=r,e[15]=a.id,e[16]=R):R=e[16];const E=R;let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{g(!1)},e[17]=_):_=e[17];const L=_;let A;e[18]!==a.name?(A=a.name.trim(),e[18]=a.name,e[19]=A):A=e[19];const M=A;let W;e[20]!==i||e[21]!==a.sql?(W=Jn(a.sql,i("Untitled")),e[20]=i,e[21]=a.sql,e[22]=W):W=e[22];const K=W,$=n?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground";let F;e[23]!==$?(F=ie("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",$),e[23]=$,e[24]=F):F=e[24];const H=`sql-tab-${a.id}`;let k;e[25]!==n||e[26]!==E||e[27]!==M||e[28]!==K||e[29]!==u||e[30]!==x||e[31]!==i||e[32]!==a.id?(k=u?f(Xn,{initial:M,onCancel:L,onCommit:E,placeholder:K,testId:`sql-tab-rename-${a.id}`}):f("button",{"aria-pressed":n,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${a.id}`,onClick:x,onDoubleClick:C,title:i("Double-click to rename"),type:"button",children:M===""?K:M}),e[25]=n,e[26]=E,e[27]=M,e[28]=K,e[29]=u,e[30]=x,e[31]=i,e[32]=a.id,e[33]=k):k=e[33];let D;e[34]!==t||e[35]!==w||e[36]!==d||e[37]!==S||e[38]!==i||e[39]!==a.id?(D=t&&(d?f(Zn,{idBase:a.id,onDiscard:w,onKeep:I}):f("button",{"aria-label":i("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-${a.id}`,onClick:S,title:i("Close tab"),type:"button",children:f("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:f("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=w,e[36]=d,e[37]=S,e[38]=i,e[39]=a.id,e[40]=D):D=e[40];let z;return e[41]!==N||e[42]!==F||e[43]!==H||e[44]!==k||e[45]!==D?(z=B("div",{className:F,"data-testid":H,onContextMenu:N,children:[k,D]}),e[41]=N,e[42]=F,e[43]=H,e[44]=k,e[45]=D,e[46]=z):z=e[46],z},ts=l=>{const e=X(43),{model:n,onSelect:t}=l,o=re(),{activeTab:s,addEditorTab:r,cancelBulk:c,closeEditorTab:a,closeTabMenu:i,confirmBulk:u,menuStyle:g,onBackdropContextMenu:d,onCloseAll:y,onCloseOthers:b,onCloseToRight:N,openTabMenu:m,pendingBulk:x,renameTab:p,tabMenu:C,tabs:v}=n;let S;if(e[0]!==s||e[1]!==a||e[2]!==t||e[3]!==m||e[4]!==p||e[5]!==v){let A;e[7]!==s||e[8]!==a||e[9]!==t||e[10]!==m||e[11]!==p||e[12]!==v.length?(A=M=>f(es,{active:M.id===s.id,canClose:v.length>1,onClose:a,onMenu:m,onRename:p,onSelect:t,tab:M},M.id),e[7]=s,e[8]=a,e[9]=t,e[10]=m,e[11]=p,e[12]=v.length,e[13]=A):A=e[13],S=v.map(A),e[0]=s,e[1]=a,e[2]=t,e[3]=m,e[4]=p,e[5]=v,e[6]=S}else S=e[6];let h;e[14]!==o?(h=o("New tab"),e[14]=o,e[15]=h):h=e[15];const w=v.length>=Le;let T;e[16]!==o?(T=o("New tab"),e[16]=o,e[17]=T):T=e[17];let I;e[18]===Symbol.for("react.memo_cache_sentinel")?(I=f("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:f("path",{d:"M12 5v14M5 12h14"})}),e[18]=I):I=e[18];let R;e[19]!==r||e[20]!==h||e[21]!==w||e[22]!==T?(R=f("button",{"aria-label":h,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:w,onClick:r,title:T,type:"button",children:I}),e[19]=r,e[20]=h,e[21]=w,e[22]=T,e[23]=R):R=e[23];let E;e[24]!==S||e[25]!==R?(E=B("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:[S,R]}),e[24]=S,e[25]=R,e[26]=E):E=e[26];let _;e[27]!==c||e[28]!==i||e[29]!==u||e[30]!==g||e[31]!==d||e[32]!==y||e[33]!==b||e[34]!==N||e[35]!==x||e[36]!==o||e[37]!==C||e[38]!==v?(_=C!==null&&B(he,{children:[f("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:i,onContextMenu:d,role:"presentation"}),f("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:g,children:x===null?B(he,{children:[f("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:v.length<=1,onClick:b,role:"menuitem",type:"button",children:o("Close other tabs")}),f("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:v.findIndex(A=>A.id===C.id)>=v.length-1,onClick:N,role:"menuitem",type:"button",children:o("Close tabs to the right")}),f("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")})]}):B("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[f("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")}),B("div",{className:"flex items-center gap-1.5",children:[f("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:u,type:"button",children:o("Discard")}),f("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:c,type:"button",children:o("Cancel")})]})]})})]}),e[27]=c,e[28]=i,e[29]=u,e[30]=g,e[31]=d,e[32]=y,e[33]=b,e[34]=N,e[35]=x,e[36]=o,e[37]=C,e[38]=v,e[39]=_):_=e[39];let L;return e[40]!==E||e[41]!==_?(L=B(he,{children:[E,_]}),e[40]=E,e[41]=_,e[42]=L):L=e[42],L},ns=Ce(we.runSql),ss="lunora-studio-sql-split-view",os=()=>pe(Ve[0]?.sql??""),ls=()=>performance.now(),rs=()=>{const l=X(2);let e;l[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,l[0]=e):e=l[0];const n=ue(e);let t;return l[1]===Symbol.for("react.memo_cache_sentinel")?(t={advance:o=>{n.current.set(o,(n.current.get(o)??0)+1)},begin:o=>{const s=n.current.get(o)??0;return()=>(n.current.get(o)??0)===s}},l[1]=t):t=l[1],t},Es=({initialShardKey:l,now:e=ls})=>{const n=Te(),t=En(os),{activeTab:o,output:s,patchActiveOutput:r,patchActiveTab:c,setActiveTabId:a,unlinkQuery:i}=t,u=rs(),d=_n({loadIntoActiveTab:(U,G)=>{u.advance(o.id),c({activeId:G,sql:U}),r({chart:void 0,durationMs:void 0,error:null,failed:void 0,result:null,running:!1,script:void 0})},unlinkQuery:i}),{recordHistory:y,updateQuerySql:b}=d,N=o.sql,{activeId:m}=o,{chart:x,error:p,failed:C,result:v,running:S}=s,h=s.pane,[w,T]=se(l??""),[I,R]=Re(ss,!1),{probe:E,schema:_}=dn(w),L=U=>{c({sql:U}),m!==null&&b(m,U)},A=Qt(N,_,w),M=st(w),W=()=>{if(v===null)return;ce((async()=>{const G=await M.inferChart({columns:v.columns,rowCount:v.rowCount,types:Object.fromEntries(v.columns.map(Y=>[Y,typeof(v.rows[0]?.[Y]??"")]))});r({chart:G})})())},K=async U=>{const G=e();try{const Y=await n.query(ns,{sql:U},ye(w)),te=e()-G;return y(U),{durationMs:te,error:null,result:Y,sql:U}}catch(Y){return{error:tt(Y),result:null,sql:U}}},$=async U=>{if(N.trim()==="")return;const G=u.begin(o.id);r({running:!0});const Y=U==="explain"?ke(yt(N),0):ze(N),te=[];for(const Q of Y){const ee={error:Q.rejection?.message??"",result:null,sql:Q.sql};te.push(Q.rejection===void 0?await K(Q.sql):ee)}if(nt(w),!G())return;const le=Math.max(te.length-1,0),O=te[le];r({chart:void 0,durationMs:O?.durationMs,error:O?.error??null,failed:O?.error===null||O===void 0?void 0:{error:O.error,sql:O.sql},pane:U,result:O?.result??null,running:!1,script:te.length>1?{runs:te,selected:le}:void 0})},F=U=>{const G=s.script?.runs,Y=G?.[U];G===void 0||Y===void 0||r({chart:void 0,durationMs:Y.durationMs,error:Y.error,failed:Y.error===null?void 0:{error:Y.error,sql:Y.sql},result:Y.result,script:{runs:G,selected:U}})},H=()=>{ce($("results"))},k=pn({inlineEditEnabled:!M.unavailable,onSubmit:()=>{ce($(s.pane))},probe:E,schema:_,setDraft:L}),{closeAutocomplete:D,closeInlineEdit:z}=k,P=()=>{L(kt(N))},oe=U=>{D(),z(),a(U)},Z=()=>{r({pane:"results"})},ne=()=>{ce($("explain"))},q=()=>{r({pane:"chart"})},j=()=>{R(!I)},J=I?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",V=I?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";return B("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[f(Yn,{activeId:m,history:d.history,listRef:d.listRef,onClearHistory:d.clearHistory,onDelete:d.deleteQuery,onLoadHistory:d.loadFromHistory,onLoadTemplate:d.loadTemplate,onNew:d.newQuery,onSearchChange:d.onSearchChange,onSelect:d.selectQuery,onToggleRememberHistory:d.setRememberHistory,queries:d.queries,rememberHistory:d.rememberHistory,search:d.search}),B("div",{className:"flex min-w-0 flex-1 flex-col",children:[f(ts,{model:t,onSelect:oe}),B("div",{className:J,children:[f(zn,{assistant:M,autocomplete:k.autocompleteState,diagnostics:A,draft:N,editorRef:k.editorRef,failed:C,gutterRef:k.gutterRef,handlers:k.handlers,inlineEdit:k.inlineEdit,listboxId:k.listboxId,onAcceptInlineEdit:k.acceptInlineEdit,onCancelInlineEdit:k.closeInlineEdit,onGenerated:L,onPickSuggestion:k.onPickSuggestion,onRevealDiagnostic:k.revealDiagnostic,overlayRef:k.overlayRef}),f(Gn,{assistant:M,chart:x,className:V,durationMs:s.durationMs,error:p,onFormat:P,onInferChart:W,onRun:H,onSelectStatement:F,onShardKeyChange:T,onShowChart:q,onShowExplain:ne,onShowResults:Z,onToggleSplit:j,pane:h,result:v,running:S,script:s.script,shardKey:w,splitView:I})]})]})]})};export{Es as SqlEditorPanel};
|
|
4
|
+
`);return e.join("")},Nt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,Et=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,Tt=/^\w+/u,qt=/;\s*$/u,Rt=/\s/u,et=r=>{let e=0;for(;e<r.length;){const s=r[e];if(s!==void 0&&Rt.test(s))e+=1;else if(s==="-"&&r[e+1]==="-")e=Je(r,e);else if(s==="/"&&r[e+1]==="*"){const t=Xe(r,e);if(t===-1)break;e=t}else break}return e},It=r=>{const e=et(r),s=r.slice(e).trimEnd();if(s==="")return{code:"SQL_EMPTY",message:"the query is empty"};const o=(Ze(s)??s).replace(qt,""),n=s.slice(0,o.length),l=o.indexOf(";");if(l!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+l};const i="the SQL editor is read-only — only SELECT / WITH / EXPLAIN queries are allowed";if(!Nt.test(n))return{code:"SQL_NOT_READONLY",length:Tt.exec(n)?.[0].length??1,message:i,offset:e};const c=Et.exec(n);if(c!==null)return{code:"SQL_NOT_READONLY",length:c[0].length,message:`${i} (\`${c[0].toUpperCase()}\` is not allowed)`,offset:e+c.index}},Lt=/^explain\b/iu,At=r=>Lt.test(r.slice(et(r)))?r:`EXPLAIN QUERY PLAN ${r}`,Oe=(r,e)=>{const s=r.trim();if(s==="")return[];const t=e+r.indexOf(s),o=It(s);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:s}:{offset:t,rejection:o,sql:s}]},tt=r=>{const e=Ze(r);if(e===void 0)return Oe(r,0);const s=[];let t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(s.push(...Oe(r.slice(t,o),t)),t=o+1);return s},_t=["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"],Dt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ie=String.fromCodePoint(0),Ot=new RegExp(`${Ie}${String.raw`(\d+)`}${Ie}`,"gu"),Mt=_t.map(r=>({pattern:new RegExp(String.raw`\b${r.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:r})),$t=Dt.map(r=>({pattern:new RegExp(String.raw`\s+${r.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
5
|
+
${r}`})),Bt=r=>{const e=[];let t=r.replaceAll(/'(?:[^']|'')*'/gu,o=>(e.push(o),`${Ie}${(e.length-1).toString()}${Ie}`)).replaceAll(/\s+/gu," ").trim();for(const{pattern:o,replacement:n}of Mt)t=t.replaceAll(o,n);for(const{pattern:o,replacement:n}of $t)t=t.replaceAll(o,n);return t=t.replaceAll(Ot,(o,n)=>e[Number(n)]??""),t},Pt=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Wt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Ht=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),Ft=/[^\n]/gu,Qt=(r,e)=>{const s=r[e];if(s==="'"){let t=e+1;for(;t<r.length&&r[t]!=="'";)t+=1;return Math.min(t+1,r.length)}if(s==="-"&&r[e+1]==="-"){const t=r.indexOf(`
|
|
6
|
+
`,e);return t===-1?r.length:t}if(s==="/"&&r[e+1]==="*"){const t=r.indexOf("*/",e+2);return t===-1?r.length:t+2}return-1},jt=r=>{let e="",s=0;for(;s<r.length;){const t=Qt(r,s);t===-1?(e+=r.slice(s,s+1),s+=1):(e+=r.slice(s,t).replaceAll(Ft," "),s=t)}return e},zt=r=>{const e=new Set;for(const s of r.matchAll(Wt))e.add((s[1]??"").toLowerCase());return e},Kt=(r,e)=>{const s=new Map;for(const t of r.matchAll(Pt)){const o=(t[1]??"").toLowerCase(),n=(t[2]??"").toLowerCase();e.has(o)&&(s.set(o,o),n!==""&&!Ht.has(n)&&s.set(n,o))}return s},nt=(r,e)=>{const s=jt(r),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:zt(s),masked:s,targets:Kt(s,t)}},Ut=/^(?:__lunora|sqlite_)/iu,Yt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Gt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Vt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Jt=(r,e,s)=>{const t=[];for(const o of r.matchAll(Yt)){const n=o[1]??"",l=n.toLowerCase();!e.has(l)&&!s.has(l)&&!Vt.has(l)&&!Ut.test(n)&&t.push({length:n.length,message:`unknown table \`${n}\``,offset:o.index+o[0].length-n.length,severity:"error",source:"schema"})}return t},Xt=(r,e,s)=>{const t=[],o=new Map;for(const[n,l]of Object.entries(e.columns))o.set(n.toLowerCase(),new Set(l.map(i=>i.toLowerCase())));for(const n of r.matchAll(Gt)){const l=(n[1]??"").toLowerCase(),i=n[2]??"",c=s.get(l),a=c===void 0?void 0:o.get(c);a!==void 0&&!a.has(i.toLowerCase())&&t.push({length:i.length,message:`\`${c??""}\` has no column \`${i}\``,offset:n.index+n[0].length-i.length,severity:"error",source:"schema"})}return t},Zt=/(?<![\w$."])(?:"([a-z_][\w$]*)"|([a-z_][\w$]*))(?![.(])/giu,en=/\bas\s+"?([a-z_][\w$]*)"?/giu,tn=(r,e,s,t)=>{const o=[...new Set(s.values())],n=new Map,l=new Set;for(const a of o){for(const d of e.columns[a]??[])l.add(d.toLowerCase());for(const d of e.docFields?.[a]??[])n.set(d.toLowerCase(),d)}if(n.size===0)return[];const i=new Set([...r.matchAll(en)].map(a=>(a[1]??"").toLowerCase())),c=[];for(const a of r.matchAll(Zt)){const d=a[1],m=d??a[2]??"",f=m.toLowerCase(),h=n.get(f);h===void 0||l.has(f)||i.has(f)||t.has(f)||s.has(f)||c.push({length:m.length,message:`\`${h}\` is a \`__doc__\` field, not a column — use \`json_extract(__doc__, '$.${h}')\``,offset:a.index+(d===void 0?0:1),severity:"error",source:"schema"})}return c},nn=(r,e)=>{if(r.trim()==="")return[];const s=tt(r),t=new Set(e.tables.map(n=>n.toLowerCase())),o=[];for(const n of s){const{offset:l,rejection:i}=n;if(i!==void 0){o.push({length:i.length,message:i.message,offset:i.offset===void 0?l:l+i.offset,severity:"error",source:"gate"});continue}const{ctes:c,masked:a,targets:d}=nt(n.sql,e.tables);o.push(...[...Jt(a,t,c),...Xt(a,e,d),...tn(a,e,d,c)].map(m=>({...m,offset:m.offset===void 0?l:l+m.offset})))}return o},sn=Ae(Le.lintSql),on=600,ln=(r,e,s)=>{const t=Me(),[o,n]=te([]),l=Fe(()=>nn(r,e),[r,e]),i=bt(r,on),a=l.some(f=>f.source==="gate")||i.trim()==="",d=Ye(async f=>{try{const h=await t.query(sn,{sql:i},qe(s));f.cancelled||n(h.diagnostics??[])}catch{f.cancelled||n([])}},[t,i,s]);ue(()=>{if(a){n([]);return}const f={cancelled:!1};return ie(d(f)),()=>{f.cancelled=!0}},[d,a]);const m=i===r;return Fe(()=>m?[...l,...o]:l,[l,o,m])},ke=8,rn=["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"],an=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),cn=/[\w$]/,st=r=>r!==void 0&&cn.test(r),ot=r=>{let e=r.length;for(;e>0&&st(r[e-1]);)e-=1;return r.slice(e)},lt=(r,e)=>{let s=e;for(;s>0&&st(r[s-1]);)s-=1;return{end:e,start:s,text:r.slice(s,e)}},je=(r,e)=>{const s=r.slice(0,e).trimEnd();return s.endsWith(".")||an.has(ot(s).toUpperCase())},dn=(r,e,s)=>{const t=r.slice(0,e);if(!t.endsWith("."))return;const o=ot(t.slice(0,-1));if(o!=="")return nt(r,s).targets.get(o.toLowerCase())??o},Be=(r,e)=>r.toLowerCase().startsWith(e.toLowerCase()),ze=(r,e,s,t)=>{const o=[];for(const n of r)if(Be(n,e)&&(o.push(t(n)),o.length>=s))break;return o},un=(r,e,s)=>{const t=new Map;for(const[o,n]of Object.entries(r.columns))for(const l of n)if(Be(l,e)&&!t.has(l)&&(t.set(l,o),t.size>=s))return[...t].map(([i,c])=>({detail:c,kind:"column",label:i}));return[...t].map(([o,n])=>({detail:n,kind:"column",label:o}))},fn=(r,e,s)=>{const t=lt(r,e),o=dn(r,t.start,s.tables);if(o!==void 0){const a=s.columns[o]??s.columns[o.toLowerCase()]??[];return ze(a,t.text,ke,d=>({detail:o,kind:"column",label:d}))}if(t.text===""&&!je(r,t.start))return[];const n=ze(s.tables,t.text,ke,a=>({kind:"table",label:a})),l=un(s,t.text,ke),i=rn.flatMap(a=>t.text!==""&&Be(a,t.text)&&a.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(je(r,t.start)?[...l,...n,...i]:[...n,...l,...i]).slice(0,ke)},mn=(r,e,s)=>{const t=lt(r,e),o=r.slice(0,t.start)+s.label+r.slice(t.end);return{caret:t.start+s.label.length,value:o}},pn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],hn=(r,e)=>{const s=globalThis.getComputedStyle(r),t=globalThis.document.createElement("div"),{style:o}=t;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(const c of pn)o[c]=s[c];t.textContent=r.value.slice(0,Math.max(0,e));const n=globalThis.document.createElement("span");n.textContent=r.value.slice(Math.max(0,e))||".",t.append(n),globalThis.document.body.append(t);const l=n.offsetLeft-r.scrollLeft,i=n.offsetTop-r.scrollTop;return t.remove(),{left:l,top:i}},bn=(r,e,s)=>{const t=G(16),[o,n]=te(null);let l;t[0]!==r||t[1]!==e?(l=(S,p)=>{const N=fn(S,p,r);if(N.length===0){n(null);return}const x=e.current,{left:b,top:y}=x===null?{left:0,top:0}:hn(x,p);n(C=>C!==null&&C.active===0&&C.left===b&&C.top===y&&C.suggestions.length===N.length&&C.suggestions.every((I,q)=>{const T=N.at(q);return I.kind===T?.kind&&I.label===T.label&&I.detail===T.detail})?C:{active:0,left:b,suggestions:N,top:y})},t[0]=r,t[1]=e,t[2]=l):l=t[2];const i=l;let c;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{n(null)},t[3]=c):c=t[3];const a=c;let d;t[4]===Symbol.for("react.memo_cache_sentinel")?(d=S=>{n(p=>{if(p===null)return p;const N=p.suggestions.length,x=(p.active+S+N)%N;return{...p,active:x}})},t[4]=d):d=t[4];const m=d;let f;t[5]!==s||t[6]!==o||t[7]!==e?(f=S=>{const p=e.current;if(o===null||p===null)return!1;const N=o.suggestions[S??o.active];if(N===void 0)return!1;const x=mn(p.value,p.selectionStart,N);return s(x.value),n(null),requestAnimationFrame(()=>{const b=e.current;b!==null&&(b.focus(),b.setSelectionRange(x.caret,x.caret))}),!0},t[5]=s,t[6]=o,t[7]=e,t[8]=f):f=t[8];const h=f;let g;t[9]!==h?(g=()=>h(),t[9]=h,t[10]=g):g=t[10];const R=g;let v;return t[11]!==R||t[12]!==h||t[13]!==i||t[14]!==o?(v={close:a,commit:R,commitAt:h,move:m,refresh:i,state:o},t[11]=R,t[12]=h,t[13]=i,t[14]=o,t[15]=v):v=t[15],v},gn={column:"column",keyword:"keyword",table:"table"},xn=20,vn=r=>{const e=G(17),{listboxId:s,onPick:t,state:o}=r,n=Z();let l;e[0]!==o?(l=o===null?void 0:{left:o.left,top:o.top+xn},e[0]=o,e[1]=l):l=e[1];const i=l;if(o===null)return null;let c;if(e[2]!==s||e[3]!==t||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==n){let d;e[8]!==s||e[9]!==t||e[10]!==o.active||e[11]!==n?(d=(m,f)=>W("li",{"aria-selected":f===o.active,className:ae("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",f===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${s}-opt-${f.toString()}`,onMouseDown:h=>{h.preventDefault(),t(f)},role:"option",children:[u("span",{className:"truncate font-mono",children:m.label}),m.detail!==void 0&&u("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:m.detail}),u("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:n(gn[m.kind])})]},`${m.kind}:${m.label}`),e[8]=s,e[9]=t,e[10]=o.active,e[11]=n,e[12]=d):d=e[12],c=o.suggestions.map(d),e[2]=s,e[3]=t,e[4]=o.active,e[5]=o.suggestions,e[6]=n,e[7]=c}else c=e[7];let a;return e[13]!==s||e[14]!==i||e[15]!==c?(a=u("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:s,role:"listbox",style:i,children:c}),e[13]=s,e[14]=i,e[15]=c,e[16]=a):a=e[16],a},yn=Ae(Le.listTables),Sn=Ae(Le.readTablePage),wn=r=>{const e=G(18),s=Me();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[o,n]=te(t);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l={},e[1]=l):l=e[1];const[i,c]=te(l);let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={},e[2]=a):a=e[2];const[d,m]=te(a);let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,e[3]=f):f=e[3];const h=de(f);let g,R;e[4]!==s||e[5]!==r?(g=()=>{const b={cancelled:!1};return ie((async()=>{try{const C=await s.query(yn,{},qe(r));b.cancelled||(n(C.map(kn)),c({}),m({}),h.current=new Set)}catch{b.cancelled||(n([]),c({}),m({}),h.current=new Set)}})()),()=>{b.cancelled=!0}},R=[s,r],e[4]=s,e[5]=r,e[6]=g,e[7]=R):(g=e[6],R=e[7]),ue(g,R);let v;e[8]!==s||e[9]!==r?(v=b=>{if(h.current.has(b))return;h.current.add(b),ie((async()=>{try{const C=await s.query(Sn,{limit:1,offset:0,table:b},qe(r)),{sqlColumns:w}=C;if(w===void 0){h.current.delete(b);return}const I=new Set(w),q=C.columns.filter(T=>!I.has(T));c(T=>({...T,[b]:w})),m(T=>({...T,[b]:q}))}catch{h.current.delete(b)}})())},e[8]=s,e[9]=r,e[10]=v):v=e[10];const S=v;let p;e[11]!==i||e[12]!==d||e[13]!==o?(p={columns:i,docFields:d,tables:o},e[11]=i,e[12]=d,e[13]=o,e[14]=p):p=e[14];const N=p;let x;return e[15]!==S||e[16]!==N?(x={probe:S,schema:N},e[15]=S,e[16]=N,e[17]=x):x=e[17],x},_e=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,Cn=r=>{const e=new Set;_e.lastIndex=0;let s=_e.exec(r);for(;s!==null;)e.add(s[1]??s[2]),s=_e.exec(r);return[...e]};function kn(r){return r.name}const Nn=r=>(r.metaKey||r.ctrlKey)&&!r.shiftKey&&!r.altKey&&r.key.toLowerCase()==="i",En=r=>{const e=G(44),{inlineEditEnabled:s,onSubmit:t,probe:o,schema:n,setDraft:l}=r,i=ct(),[c,a]=te(null),d=de(null),m=de(null),f=de(null),h=bn(n,f,l),{close:g,commit:R,commitAt:v,move:S,refresh:p,state:N}=h;let x;e[0]!==v?(x=O=>{v(O)},e[0]=v,e[1]=x):x=e[1];const b=x;let y;e[2]!==p?(y=()=>{const O=f.current;O!==null&&O===document.activeElement&&p(O.value,O.selectionStart)},e[2]=p,e[3]=y):y=e[3];let C;e[4]!==p||e[5]!==n?(C=[p,n],e[4]=p,e[5]=n,e[6]=C):C=e[6],ue(y,C);let w;e[7]!==o||e[8]!==p||e[9]!==l?(w=O=>{const{selectionStart:U,value:X}=O.target;l(X),a(null);for(const Y of Cn(X))o(Y);p(X,U)},e[7]=o,e[8]=p,e[9]=l,e[10]=w):w=e[10];const I=w;let q;e[11]!==p?(q=O=>{const U=O.currentTarget;p(U.value,U.selectionStart)},e[11]=p,e[12]=q):q=e[12];const T=q;let E;e[13]!==g||e[14]!==R||e[15]!==S?(E=O=>O.key==="ArrowDown"?(O.preventDefault(),S(1),!0):O.key==="ArrowUp"?(O.preventDefault(),S(-1),!0):O.key==="Escape"?(O.preventDefault(),g(),!0):(O.key==="Enter"||O.key==="Tab")&&!O.metaKey&&!O.ctrlKey&&R()?(O.preventDefault(),!0):!1,e[13]=g,e[14]=R,e[15]=S,e[16]=E):E=e[16];const k=E;let L;e[17]!==N||e[18]!==g||e[19]!==s||e[20]!==k||e[21]!==t?(L=O=>{if(!(N!==null&&k(O))){if((O.metaKey||O.ctrlKey)&&O.key==="Enter"){O.preventDefault(),t();return}if(s&&Nn(O)){O.preventDefault(),g();const{selectionEnd:U,selectionStart:X,value:Y}=O.currentTarget,[oe,re]=X===U?[0,Y.length]:[X,U];a({end:re,start:oe,text:Y.slice(oe,re)})}}},e[17]=N,e[18]=g,e[19]=s,e[20]=k,e[21]=t,e[22]=L):L=e[22];const _=L;let $;e[23]!==g?($=()=>{requestAnimationFrame(()=>{g()})},e[23]=g,e[24]=$):$=e[24];const F=$;let B;e[25]===Symbol.for("react.memo_cache_sentinel")?(B=O=>{const{scrollLeft:U,scrollTop:X}=O.currentTarget;d.current!==null&&(d.current.scrollTop=X),m.current!==null&&(m.current.scrollTop=X,m.current.scrollLeft=U)},e[25]=B):B=e[25];const H=B;let P;e[26]===Symbol.for("react.memo_cache_sentinel")?(P=O=>{const U=f.current;U===null||O.offset===void 0||(U.focus(),U.setSelectionRange(O.offset,O.offset+(O.length??0)))},e[26]=P):P=e[26];const Q=P;let M;e[27]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{a(null),f.current?.focus()},e[27]=M):M=e[27];const A=M;let D;e[28]!==c||e[29]!==l?(D=O=>{const U=f.current;if(c===null||U===null)return;const{end:X,start:Y,text:oe}=c;if(U.value.slice(Y,X)!==oe){a(null);return}l(U.value.slice(0,Y)+O+U.value.slice(X)),a(null),U.focus(),requestAnimationFrame(()=>{U.setSelectionRange(Y,Y+O.length)})},e[28]=c,e[29]=l,e[30]=D):D=e[30];const z=D;let j;e[31]!==I||e[32]!==F||e[33]!==_||e[34]!==T?(j={onBlur:F,onChange:I,onKeyDown:_,onScroll:H,onSelect:T},e[31]=I,e[32]=F,e[33]=_,e[34]=T,e[35]=j):j=e[35];let K;return e[36]!==z||e[37]!==N||e[38]!==g||e[39]!==c||e[40]!==i||e[41]!==b||e[42]!==j?(K={acceptInlineEdit:z,autocompleteState:N,closeAutocomplete:g,closeInlineEdit:A,inlineEdit:c,handlers:j,listboxId:i,onPickSuggestion:b,editorRef:f,gutterRef:d,overlayRef:m,revealDiagnostic:Q},e[36]=z,e[37]=N,e[38]=g,e[39]=c,e[40]=i,e[41]=b,e[42]=j,e[43]=K):K=e[43],K},Tn="lunora-studio-sql-tabs",qn="lunora-studio-sql-active-tab",Pe=12,Se=(r="",e="")=>({activeId:null,id:Ge("tab"),name:e,sql:r}),Rn=()=>$e(qn,""),In=r=>{const e=G(16),[s,t]=De(Tn),[o,n]=Rn(),[l]=te(r);let i,c;e[0]!==l||e[1]!==t||e[2]!==s.length?(i=()=>{s.length===0&&t([l])},c=[l,t,s.length],e[0]=l,e[1]=t,e[2]=s.length,e[3]=i,e[4]=c):(i=e[3],c=e[4]),ue(i,c);let a;e[5]!==l||e[6]!==s?(a=s.length===0?[l]:s,e[5]=l,e[6]=s,e[7]=a):a=e[7];const d=a;let m;e[8]!==o||e[9]!==d?(m=d.some(g=>g.id===o)?o:d[0]?.id??"",e[8]=o,e[9]=d,e[10]=m):m=e[10];const f=m;let h;return e[11]!==f||e[12]!==n||e[13]!==t||e[14]!==d?(h={activeId:f,setActiveId:n,setTabs:t,tabs:d},e[11]=f,e[12]=n,e[13]=t,e[14]=d,e[15]=h):h=e[15],h},rt=r=>r.activeId===null&&r.sql.trim()!=="",Ln=(r,e)=>[...r,e].slice(-Pe),An=(r,e,s)=>{const t=r.findIndex(l=>l.id===e);if(t===-1)return{activeId:r[0]?.id??"",tabs:[...r]};const o=r.filter(l=>l.id!==e);if(o.length===0){const l=s();return{activeId:l.id,tabs:[l]}}return{activeId:o[Math.min(t,o.length-1)].id,tabs:o}},_n=(r,e)=>{const s=r.filter(t=>t.id===e);return s.length===0?{activeId:r[0]?.id??"",tabs:[...r]}:{activeId:e,tabs:s}},Dn=(r,e,s)=>{const t=r.findIndex(n=>n.id===e);if(t===-1)return{activeId:s,tabs:[...r]};const o=r.slice(0,t+1);return{activeId:o.some(n=>n.id===s)?s:e,tabs:o}},On=r=>{const e=r();return{activeId:e.id,tabs:[e]}},Mn=(r,e,s)=>{if(r==="others")return e.filter(t=>t.id!==s);if(r==="right"){const t=e.findIndex(o=>o.id===s);return t===-1?[]:e.slice(t+1)}return[...e]},Ke={error:null,pane:"results",result:null,running:!1},$n=r=>{const e=G(69),{activeId:s,setActiveId:t,setTabs:o,tabs:n}=In(r);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[i,c]=te(l),[a,d]=te(null),[m,f]=te(null);let h;e[1]!==s||e[2]!==n?(h=n.find(V=>V.id===s)??n[0]??Se(),e[1]=s,e[2]=n,e[3]=h):h=e[3];const g=h,R=i[g.id]??Ke;let v;e[4]!==g.id||e[5]!==o?(v=V=>{o(ee=>ee.map(se=>se.id===g.id?{...se,...V}:se))},e[4]=g.id,e[5]=o,e[6]=v):v=e[6];const S=v;let p;e[7]!==g.id?(p=V=>{c(ee=>{const se=ee[g.id]??Ke;return{...ee,[g.id]:{...se,...V}}})},e[7]=g.id,e[8]=p):p=e[8];const N=p;let x;e[9]!==t||e[10]!==o||e[11]!==n.length?(x=V=>{if(n.length>=Pe)return!1;const ee=Se(V);return o(se=>Ln(se,ee)),t(ee.id),!0},e[9]=t,e[10]=o,e[11]=n.length,e[12]=x):x=e[12];const b=x;let y;e[13]!==b?(y=()=>{b("")},e[13]=b,e[14]=y):y=e[14];const C=y;let w;e[15]!==t||e[16]!==o?(w=V=>{d(null),f(null),o(V.tabs),t(V.activeId);const ee=new Set(V.tabs.map(Bn));c(se=>Object.fromEntries(Object.entries(se).filter(fe=>{const[J]=fe;return ee.has(J)})))},e[15]=t,e[16]=o,e[17]=w):w=e[17];const I=w;let q;e[18]!==I||e[19]!==n?(q=V=>{I(An(n,V,Se))},e[18]=I,e[19]=n,e[20]=q):q=e[20];const T=q;let E;e[21]!==s||e[22]!==I||e[23]!==n?(E=(V,ee)=>{I(V==="others"?_n(n,ee):V==="right"?Dn(n,ee,s):On(Se))},e[21]=s,e[22]=I,e[23]=n,e[24]=E):E=e[24];const k=E;let L;e[25]!==k||e[26]!==a||e[27]!==n?(L=V=>{a!==null&&(Mn(V,n,a.id).some(Pn)?f(V):k(V,a.id))},e[25]=k,e[26]=a,e[27]=n,e[28]=L):L=e[28];const _=L;let $;e[29]===Symbol.for("react.memo_cache_sentinel")?($=(V,ee)=>{ee.preventDefault(),f(null),d({id:V,x:ee.clientX,y:ee.clientY})},e[29]=$):$=e[29];const F=$;let B;e[30]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{d(null),f(null)},e[30]=B):B=e[30];const H=B;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=V=>{V.preventDefault(),d(null),f(null)},e[31]=P):P=e[31];const Q=P;let M;e[32]!==_?(M=()=>{_("others")},e[32]=_,e[33]=M):M=e[33];const A=M;let D;e[34]!==_?(D=()=>{_("right")},e[34]=_,e[35]=D):D=e[35];const z=D;let j;e[36]!==_?(j=()=>{_("all")},e[36]=_,e[37]=j):j=e[37];const K=j;let O;e[38]!==k||e[39]!==m||e[40]!==a?(O=()=>{a!==null&&m!==null&&k(m,a.id),f(null)},e[38]=k,e[39]=m,e[40]=a,e[41]=O):O=e[41];const U=O;let X;e[42]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{f(null)},e[42]=X):X=e[42];const Y=X;let oe;e[43]!==a?(oe=a===null?void 0:{left:a.x,top:a.y},e[43]=a,e[44]=oe):oe=e[44];const re=oe;let pe;e[45]!==o?(pe=V=>{o(ee=>ee.map(se=>se.activeId===V?{...se,activeId:null}:se))},e[45]=o,e[46]=pe):pe=e[46];const ve=pe;let he;e[47]!==o?(he=(V,ee)=>{o(se=>se.map(fe=>fe.id===V?{...fe,name:ee}:fe))},e[47]=o,e[48]=he):he=e[48];const ye=he;let be;return e[49]!==g||e[50]!==s||e[51]!==C||e[52]!==T||e[53]!==U||e[54]!==K||e[55]!==A||e[56]!==z||e[57]!==b||e[58]!==R||e[59]!==N||e[60]!==S||e[61]!==m||e[62]!==ye||e[63]!==t||e[64]!==a||e[65]!==re||e[66]!==n||e[67]!==ve?(be={activeTab:g,activeTabId:s,addEditorTab:C,cancelBulk:Y,closeEditorTab:T,closeTabMenu:H,confirmBulk:U,menuStyle:re,onBackdropContextMenu:Q,onCloseAll:K,onCloseOthers:A,onCloseToRight:z,openEditorTab:b,openTabMenu:F,output:R,patchActiveOutput:N,patchActiveTab:S,pendingBulk:m,renameTab:ye,setActiveTabId:t,tabMenu:a,tabs:n,unlinkQuery:ve},e[49]=g,e[50]=s,e[51]=C,e[52]=T,e[53]=U,e[54]=K,e[55]=A,e[56]=z,e[57]=b,e[58]=R,e[59]=N,e[60]=S,e[61]=m,e[62]=ye,e[63]=t,e[64]=a,e[65]=re,e[66]=n,e[67]=ve,e[68]=be):be=e[68],be};function Bn(r){return r.id}function Pn(r){return rt(r)}const Wn="lunora-studio-sql-queries",ge="lunora-studio-sql-history",Hn="lunora-studio-sql-remember-history",Fn=25,Qn=r=>{const e=G(44),{loadIntoActiveTab:s,unlinkQuery:t}=r,o=Z(),[n,l]=De(Wn),[i,c]=$e(Hn,!1),[a,d]=De(ge,i?"local":"session");let m,f;e[0]!==i?(m=()=>{i||Ce(ge,"local")},f=[i],e[0]=i,e[1]=m,e[2]=f):(m=e[1],f=e[2]),ue(m,f);const[h,g]=te(""),R=de(null);let v;e[3]!==d?(v=A=>{d(D=>D[0]?.sql===A?D:[{at:Date.now(),sql:A},...D.filter(j=>j.sql!==A)].slice(0,Fn))},e[3]=d,e[4]=v):v=e[4];const S=v;let p;e[5]!==s||e[6]!==l||e[7]!==o?(p=()=>{const A={id:Ge("q"),name:o("Untitled query"),sql:""};l(D=>[A,...D]),s("",A.id)},e[5]=s,e[6]=l,e[7]=o,e[8]=p):p=e[8];const N=p;let x;e[9]!==s||e[10]!==n?(x=A=>{const D=n.find(z=>z.id===A);D!==void 0&&(s(D.sql,A),R.current?.querySelector(`[data-testid="sql-query-${A}"]`)?.scrollIntoView({block:"nearest"}))},e[9]=s,e[10]=n,e[11]=x):x=e[11];const b=x;let y;e[12]!==l||e[13]!==t?(y=A=>{l(D=>D.filter(z=>z.id!==A)),t(A)},e[12]=l,e[13]=t,e[14]=y):y=e[14];const C=y;let w;e[15]!==s?(w=A=>{s(A.currentTarget.dataset.sql??"",null)},e[15]=s,e[16]=w):w=e[16];const I=w;let q;e[17]!==s?(q=A=>{s(A.currentTarget.dataset.sql??"",null)},e[17]=s,e[18]=q):q=e[18];const T=q;let E;e[19]!==d?(E=()=>{d([]),Ce(ge,"local"),Ce(ge,"session")},e[19]=d,e[20]=E):E=e[20];const k=E;let L;e[21]!==a||e[22]!==c?(L=A=>{ft(ge,a,A?"local":"session"),A||Ce(ge,"local"),c(A)},e[21]=a,e[22]=c,e[23]=L):L=e[23];const _=L;let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=A=>{g(A.target.value)},e[24]=$):$=e[24];const F=$;let B;e[25]!==l?(B=(A,D,z)=>{l(j=>j.map(K=>K.id===A?{id:K.id,name:D,sql:K.sql,...z===""?{}:{description:z}}:K))},e[25]=l,e[26]=B):B=e[26];const H=B;let P;e[27]!==l?(P=(A,D)=>{l(z=>z.map(j=>j.id===A?{...j,sql:D}:j))},e[27]=l,e[28]=P):P=e[28];const Q=P;let M;return e[29]!==k||e[30]!==C||e[31]!==a||e[32]!==T||e[33]!==I||e[34]!==N||e[35]!==n||e[36]!==S||e[37]!==i||e[38]!==H||e[39]!==h||e[40]!==b||e[41]!==_||e[42]!==Q?(M={clearHistory:k,deleteQuery:C,history:a,listRef:R,loadFromHistory:T,loadTemplate:I,newQuery:N,onSearchChange:F,queries:n,recordHistory:S,rememberHistory:i,renameQuery:H,search:h,selectQuery:b,setRememberHistory:_,updateQuerySql:Q},e[29]=k,e[30]=C,e[31]=a,e[32]=T,e[33]=I,e[34]=N,e[35]=n,e[36]=S,e[37]=i,e[38]=H,e[39]=h,e[40]=b,e[41]=_,e[42]=Q,e[43]=M):M=e[43],M},We="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",jn=(r,e)=>{const s=[];for(const o of r){if(o.offset===void 0||o.length===void 0||o.length<=0)continue;const n=Math.max(0,Math.min(o.offset,e)),l=Math.max(n,Math.min(o.offset+o.length,e));n!==l&&s.push({end:l,severity:o.severity,start:n})}s.sort((o,n)=>o.start-n.start);const t=[];for(const o of s)o.start>=(t.at(-1)?.end??0)&&t.push(o);return t},zn=r=>{const e=G(51),{rpc:s,failed:t,onGenerated:o}=r,n=Z(),[l,i]=te("");if(s.unavailable)return null;let c;e[0]!==s?(c=s.pending("sql"),e[0]=s,e[1]=c):c=e[1];const a=c;let d;if(e[2]!==t||e[3]!==o||e[4]!==a||e[5]!==l||e[6]!==s||e[7]!==n){const m=s.reason("sql");let f;e[9]!==t||e[10]!==o||e[11]!==l||e[12]!==s?(f=T=>{const E=l.trim();if(E===""&&!T)return;ie((async()=>{const L=await s.generate(E===""?"fix the failing statement":E,T?t:void 0);L!==void 0&&o(L)})())},e[9]=t,e[10]=o,e[11]=l,e[12]=s,e[13]=f):f=e[13];const h=f;let g;e[14]!==n?(g=n("Describe the query you want"),e[14]=n,e[15]=g):g=e[15];let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=T=>{i(T.target.value)},e[16]=R):R=e[16];let v;e[17]!==h?(v=T=>{T.key==="Enter"&&(T.preventDefault(),h(!1))},e[17]=h,e[18]=v):v=e[18];let S;e[19]!==n?(S=n("Describe the query you want"),e[19]=n,e[20]=S):S=e[20];let p;e[21]!==a||e[22]!==l||e[23]!==g||e[24]!==v||e[25]!==S?(p=u(Re,{"aria-label":g,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:a,onChange:R,onKeyDown:v,placeholder:S,value:l}),e[21]=a,e[22]=l,e[23]=g,e[24]=v,e[25]=S,e[26]=p):p=e[26];const N=a&&"opacity-60";let x;e[27]!==N?(x=ae("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",N),e[27]=N,e[28]=x):x=e[28];let b;e[29]!==a||e[30]!==l?(b=a||l.trim()==="",e[29]=a,e[30]=l,e[31]=b):b=e[31];let y;e[32]!==h?(y=()=>{h(!1)},e[32]=h,e[33]=y):y=e[33];let C;e[34]!==a||e[35]!==n?(C=n(a?"Thinking…":"Draft SQL"),e[34]=a,e[35]=n,e[36]=C):C=e[36];let w;e[37]!==x||e[38]!==b||e[39]!==y||e[40]!==C?(w=u("button",{className:x,"data-testid":"sql-assistant-generate",disabled:b,onClick:y,type:"button",children:C}),e[37]=x,e[38]=b,e[39]=y,e[40]=C,e[41]=w):w=e[41];let I;e[42]!==t||e[43]!==a||e[44]!==h||e[45]!==n?(I=t!==void 0&&u("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:a,onClick:()=>{h(!0)},type:"button",children:n("Fix this")}),e[42]=t,e[43]=a,e[44]=h,e[45]=n,e[46]=I):I=e[46];let q;e[47]!==w||e[48]!==I||e[49]!==p?(q=W("div",{className:"flex items-center gap-2",children:[p,w,I]}),e[47]=w,e[48]=I,e[49]=p,e[50]=q):q=e[50],d=W("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[q,m!==void 0&&u("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ve(m,n)})]}),e[2]=t,e[3]=o,e[4]=a,e[5]=l,e[6]=s,e[7]=n,e[8]=d}else d=e[8];return d},Kn=r=>{const e=G(8),{diagnostics:s,draft:t,scrollRef:o}=r;let n,l;if(e[0]!==s||e[1]!==t){l=Symbol.for("react.early_return_sentinel");e:{const a=jn(s,t.length);if(a.length===0){l=null;break e}n=[];let d=0;for(const[m,f]of a.entries())f.start>d&&n.push(t.slice(d,f.start)),n.push(u("span",{className:ae("decoration-wavy underline underline-offset-4",f.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(f.start,f.end)},`${f.start.toString()}-${m.toString()}`)),d=f.end;n.push(t.slice(d))}e[0]=s,e[1]=t,e[2]=n,e[3]=l}else n=e[2],l=e[3];if(l!==Symbol.for("react.early_return_sentinel"))return l;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=ae("pointer-events-none absolute inset-0 overflow-hidden text-transparent",We),e[4]=i):i=e[4];let c;return e[5]!==n||e[6]!==o?(c=u("div",{"aria-hidden":"true",className:i,"data-testid":"sql-diagnostics-overlay",ref:o,children:n}),e[5]=n,e[6]=o,e[7]=c):c=e[7],c},Un={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Yn=r=>{const e=G(10),{diagnostics:s,onSelect:t}=r,o=Z();if(s.length===0)return null;let n;e[0]!==o?(n=o("SQL problems"),e[0]=o,e[1]=n):n=e[1];let l;if(e[2]!==s||e[3]!==t){let c;e[5]!==t?(c=(a,d)=>u("li",{children:W("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:()=>{t(a)},type:"button",children:[u("span",{className:ae("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",a.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:Un[a.source]}),u("span",{className:"min-w-0 text-muted-foreground",children:a.message})]})},`${a.source}-${(a.offset??d).toString()}-${d.toString()}`),e[5]=t,e[6]=c):c=e[6],l=s.map(c),e[2]=s,e[3]=t,e[4]=l}else l=e[4];let i;return e[7]!==n||e[8]!==l?(i=u("ul",{"aria-label":n,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:l}),e[7]=n,e[8]=l,e[9]=i):i=e[9],i},Gn=r=>(r.endsWith(`
|
|
7
|
+
`)?r.slice(0,-1):r).split(`
|
|
8
|
+
`),Vn=(r,e)=>{const s=[];let t=1,o=1;for(const n of gt(r,e,{ignoreNewlineAtEof:!0}))for(const l of Gn(n.value))n.added?(s.push({after:o,kind:"added",text:l}),o+=1):n.removed?(s.push({before:t,kind:"removed",text:l}),t+=1):(s.push({after:o,before:t,kind:"context",text:l}),t+=1,o+=1);return s},Jn={added:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400",context:"text-muted-foreground",removed:"bg-destructive/10 text-destructive"},Xn={added:"+",context:" ",removed:"-"},Zn=r=>{const e=G(11),{lines:s}=r,t=Z();let o;e[0]!==t?(o=t("Proposed edit"),e[0]=t,e[1]=o):o=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=ae("max-h-48 overflow-auto rounded-md border border-border bg-background",We),e[2]=n):n=e[2];let l;if(e[3]!==s||e[4]!==t){let c;e[6]!==t?(c=a=>W("li",{className:ae("flex gap-2",Jn[a.kind]),"data-kind":a.kind,children:[u("span",{"aria-hidden":"true",className:"shrink-0 select-none opacity-60",children:Xn[a.kind]}),a.kind!=="context"&&u("span",{className:"sr-only",children:a.kind==="added"?t("Added"):t("Removed")}),u("span",{className:"min-w-0",children:a.text===""?" ":a.text})]},`${String(a.before)}:${String(a.after)}`),e[6]=t,e[7]=c):c=e[7],l=s.map(c),e[3]=s,e[4]=t,e[5]=l}else l=e[5];let i;return e[8]!==o||e[9]!==l?(i=u("ul",{"aria-label":o,className:n,"data-testid":"sql-inline-diff",children:l}),e[8]=o,e[9]=l,e[10]=i):i=e[10],i},Ne="rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",es=r=>{const e=G(41),{onAccept:s,onCancel:t,rpc:o,source:n,whole:l}=r,i=Z(),c=de(null),a=de(null),[d,m]=te(""),[f,h]=te(null);let g,R;if(e[0]!==f?(g=()=>{f===null?c.current?.focus():a.current?.focus()},R=[f],e[0]=f,e[1]=g,e[2]=R):(g=e[1],R=e[2]),ue(g,R),o.unavailable)return null;let v;e[3]!==o?(v=o.pending("sql"),e[3]=o,e[4]=v):v=e[4];const S=v;let p;if(e[5]!==d||e[6]!==s||e[7]!==t||e[8]!==S||e[9]!==f||e[10]!==o||e[11]!==n||e[12]!==i||e[13]!==l){const N=o.reason("sql");let x;e[15]!==d||e[16]!==o||e[17]!==n?(x=()=>{const k=d.trim();if(k===""||n.trim()==="")return;ie((async()=>{const _=await o.rewrite(k,n);_!==void 0&&h(_)})())},e[15]=d,e[16]=o,e[17]=n,e[18]=x):x=e[18];const b=x;let y;e[19]!==t?(y=k=>{k.key==="Escape"&&(k.preventDefault(),t())},e[19]=t,e[20]=y):y=e[20];const C=y;let w;e[21]!==i||e[22]!==l?(w=i(l?"Whole query":"Selection"),e[21]=i,e[22]=l,e[23]=w):w=e[23];let I;e[24]!==w?(I=u("span",{className:"shrink-0 rounded bg-muted px-1 font-mono text-[10px] uppercase text-muted-foreground","data-testid":"sql-inline-edit-scope",children:w}),e[24]=w,e[25]=I):I=e[25];let q;e[26]!==d||e[27]!==s||e[28]!==t||e[29]!==C||e[30]!==S||e[31]!==f||e[32]!==b||e[33]!==i?(q=f===null?W(xe,{children:[u(Re,{"aria-label":i("Tell the model what to change"),className:"h-7 flex-1 text-xs","data-testid":"sql-inline-edit-prompt",disabled:S,onChange:k=>{m(k.target.value)},onKeyDown:k=>{if(k.key==="Enter"){k.preventDefault(),b();return}C(k)},placeholder:i("Tell the model what to change"),ref:c,value:d}),u("button",{className:ae(Ne,S&&"opacity-60"),"data-testid":"sql-inline-edit-submit",disabled:S||d.trim()==="",onClick:b,onKeyDown:C,type:"button",children:i(S?"Thinking…":"Rewrite")}),u("button",{className:Ne,"data-testid":"sql-inline-edit-cancel",onClick:t,onKeyDown:C,type:"button",children:i("Cancel")})]}):W(xe,{children:[u("span",{className:"flex-1 text-xs text-muted-foreground",children:i("Proposed edit")}),u("button",{className:Ne,"data-testid":"sql-inline-edit-accept",onClick:()=>{s(f)},onKeyDown:C,ref:a,type:"button",children:i("Accept")}),u("button",{className:Ne,"data-testid":"sql-inline-edit-reject",onClick:()=>{h(null)},onKeyDown:C,type:"button",children:i("Reject")})]}),e[26]=d,e[27]=s,e[28]=t,e[29]=C,e[30]=S,e[31]=f,e[32]=b,e[33]=i,e[34]=q):q=e[34];let T;e[35]!==I||e[36]!==q?(T=W("div",{className:"flex items-center gap-2",children:[I,q]}),e[35]=I,e[36]=q,e[37]=T):T=e[37];let E;e[38]!==f||e[39]!==n?(E=f!==null&&u(Zn,{lines:Vn(n,f)}),e[38]=f,e[39]=n,e[40]=E):E=e[40],p=W("div",{className:"flex flex-col gap-1 border-b border-border bg-muted/20 px-3 py-2","data-testid":"sql-inline-edit",children:[T,E,N!==void 0&&u("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-inline-edit-reason",role:"status",children:Ve(N,i)})]}),e[5]=d,e[6]=s,e[7]=t,e[8]=S,e[9]=f,e[10]=o,e[11]=n,e[12]=i,e[13]=l,e[14]=p}else p=e[14];return p},ts={minWidth:"2.75rem",paddingInline:"0.5rem"},ns=r=>{const e=G(75),{rpc:s,autocomplete:t,diagnostics:o,draft:n,failed:l,handlers:i,editorRef:c,gutterRef:a,inlineEdit:d,listboxId:m,onAcceptInlineEdit:f,onCancelInlineEdit:h,onGenerated:g,onPickSuggestion:R,onRevealDiagnostic:v,overlayRef:S}=r,p=Z();let N,x,b,y,C,w,I,q,T;if(e[0]!==n||e[1]!==l||e[2]!==a||e[3]!==d||e[4]!==f||e[5]!==h||e[6]!==g||e[7]!==s){const D=n.split(`
|
|
9
|
+
`).length;I="flex min-h-0 min-w-0 flex-1 flex-col",e[17]!==l||e[18]!==g||e[19]!==s?(q=u(zn,{failed:l,onGenerated:g,rpc:s}),e[17]=l,e[18]=g,e[19]=s,e[20]=q):q=e[20],e[21]!==n.length||e[22]!==d||e[23]!==f||e[24]!==h||e[25]!==s?(T=d!==null&&u(es,{onAccept:f,onCancel:h,rpc:s,source:d.text,whole:d.start===0&&d.end===n.length},`${d.start.toString()}-${d.end.toString()}`),e[21]=n.length,e[22]=d,e[23]=f,e[24]=h,e[25]=s,e[26]=T):T=e[26],w="flex min-h-0 min-w-0 flex-1",N="true",x="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=a,y=ts,C=Array.from({length:D},ss),e[0]=n,e[1]=l,e[2]=a,e[3]=d,e[4]=f,e[5]=h,e[6]=g,e[7]=s,e[8]=N,e[9]=x,e[10]=b,e[11]=y,e[12]=C,e[13]=w,e[14]=I,e[15]=q,e[16]=T}else N=e[8],x=e[9],b=e[10],y=e[11],C=e[12],w=e[13],I=e[14],q=e[15],T=e[16];let E;e[27]!==N||e[28]!==x||e[29]!==b||e[30]!==y||e[31]!==C?(E=u("div",{"aria-hidden":N,className:x,ref:b,style:y,children:C}),e[27]=N,e[28]=x,e[29]=b,e[30]=y,e[31]=C,e[32]=E):E=e[32];let k;e[33]!==o||e[34]!==n||e[35]!==S?(k=u(Kn,{diagnostics:o,draft:n,scrollRef:S}),e[33]=o,e[34]=n,e[35]=S,e[36]=k):k=e[36];let L;e[37]!==t||e[38]!==m?(L=t===null?void 0:`${m}-opt-${t.active.toString()}`,e[37]=t,e[38]=m,e[39]=L):L=e[39];const _=t===null?void 0:m,$=t!==null;let F;e[40]!==p?(F=p("SQL query"),e[40]=p,e[41]=F):F=e[41];let B;e[42]!==n||e[43]!==c||e[44]!==i.onBlur||e[45]!==i.onChange||e[46]!==i.onKeyDown||e[47]!==i.onScroll||e[48]!==i.onSelect||e[49]!==L||e[50]!==_||e[51]!==$||e[52]!==F?(B=u("textarea",{"aria-activedescendant":L,"aria-autocomplete":"list","aria-controls":_,"aria-expanded":$,"aria-label":F,className:`relative size-full resize-none bg-transparent outline-none ${We}`,"data-testid":"sql-input",onBlur:i.onBlur,onChange:i.onChange,onKeyDown:i.onKeyDown,onScroll:i.onScroll,onSelect:i.onSelect,placeholder:"SELECT * FROM …",ref:c,role:"combobox",spellCheck:!1,value:n}),e[42]=n,e[43]=c,e[44]=i.onBlur,e[45]=i.onChange,e[46]=i.onKeyDown,e[47]=i.onScroll,e[48]=i.onSelect,e[49]=L,e[50]=_,e[51]=$,e[52]=F,e[53]=B):B=e[53];let H;e[54]!==t||e[55]!==m||e[56]!==R?(H=u(vn,{listboxId:m,onPick:R,state:t}),e[54]=t,e[55]=m,e[56]=R,e[57]=H):H=e[57];let P;e[58]!==k||e[59]!==B||e[60]!==H?(P=W("div",{className:"relative min-w-0 flex-1 bg-background",children:[k,B,H]}),e[58]=k,e[59]=B,e[60]=H,e[61]=P):P=e[61];let Q;e[62]!==E||e[63]!==P||e[64]!==w?(Q=W("div",{className:w,children:[E,P]}),e[62]=E,e[63]=P,e[64]=w,e[65]=Q):Q=e[65];let M;e[66]!==o||e[67]!==v?(M=u(Yn,{diagnostics:o,onSelect:v}),e[66]=o,e[67]=v,e[68]=M):M=e[68];let A;return e[69]!==Q||e[70]!==M||e[71]!==I||e[72]!==q||e[73]!==T?(A=W("div",{className:I,children:[q,T,Q,M]}),e[69]=Q,e[70]=M,e[71]=I,e[72]=q,e[73]=T,e[74]=A):A=e[74],A};function ss(r,e){return u("div",{children:e+1},e)}const os=r=>{const e=G(62),{onCancel:s,onSave:t,query:o,rpc:n}=r,l=Z(),[i,c]=te(o.name),[a,d]=te(o.description??"");let m;e[0]!==o.sql||e[1]!==n?(m=n!==void 0&&!n.unavailable&&o.sql.trim()!=="",e[0]=o.sql,e[1]=n,e[2]=m):m=e[2];const f=m;let h;e[3]!==n?(h=n?.pending("name"),e[3]=n,e[4]=h):h=e[4];const g=h===!0;let R;e[5]!==n?(R=n?.reason("name"),e[5]=n,e[6]=R):R=e[6];const v=R;let S;e[7]!==a||e[8]!==i||e[9]!==o.sql||e[10]!==n?(S=()=>{if(n===void 0)return;const M=i,A=a;ie((async()=>{const z=await n.nameQuery(o.sql);z!==void 0&&(c(j=>j===M?z.title:j),d(j=>j===A?z.description:j))})())},e[7]=a,e[8]=i,e[9]=o.sql,e[10]=n,e[11]=S):S=e[11];const p=S;let N;e[12]!==a||e[13]!==i||e[14]!==t?(N=M=>{M.preventDefault();const A=i.trim();A!==""&&t(A,a.trim())},e[12]=a,e[13]=i,e[14]=t,e[15]=N):N=e[15];const x=N,b=`sql-query-rename-${o.id}`;let y;e[16]!==l?(y=l("Query name"),e[16]=l,e[17]=y):y=e[17];let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=M=>{c(M.target.value)},e[18]=C):C=e[18];let w;e[19]!==l?(w=l("Query name"),e[19]=l,e[20]=w):w=e[20];let I;e[21]!==i||e[22]!==y||e[23]!==w?(I=u(Re,{"aria-label":y,autoFocus:!0,className:"h-7 text-xs","data-testid":"sql-query-name",onChange:C,placeholder:w,value:i}),e[21]=i,e[22]=y,e[23]=w,e[24]=I):I=e[24];let q;e[25]!==l?(q=l("Query description"),e[25]=l,e[26]=q):q=e[26];let T;e[27]===Symbol.for("react.memo_cache_sentinel")?(T=M=>{d(M.target.value)},e[27]=T):T=e[27];let E;e[28]!==l?(E=l("Query description"),e[28]=l,e[29]=E):E=e[29];let k;e[30]!==a||e[31]!==q||e[32]!==E?(k=u(Re,{"aria-label":q,className:"h-7 text-xs","data-testid":"sql-query-description",onChange:T,placeholder:E,value:a}),e[30]=a,e[31]=q,e[32]=E,e[33]=k):k=e[33];let L;e[34]!==l?(L=l("Save"),e[34]=l,e[35]=L):L=e[35];let _;e[36]!==L?(_=u("button",{className:"rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-query-rename-save",type:"submit",children:L}),e[36]=L,e[37]=_):_=e[37];let $;e[38]!==l?($=l("Cancel"),e[38]=l,e[39]=$):$=e[39];let F;e[40]!==s||e[41]!==$?(F=u("button",{className:"rounded-md px-2 py-0.5 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-query-rename-cancel",onClick:s,type:"button",children:$}),e[40]=s,e[41]=$,e[42]=F):F=e[42];let B;e[43]!==f||e[44]!==g||e[45]!==p||e[46]!==l?(B=f&&u("button",{className:"ms-auto rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-query-suggest-name",disabled:g,onClick:p,type:"button",children:l(g?"Thinking…":"Suggest")}),e[43]=f,e[44]=g,e[45]=p,e[46]=l,e[47]=B):B=e[47];let H;e[48]!==_||e[49]!==F||e[50]!==B?(H=W("div",{className:"flex items-center gap-1",children:[_,F,B]}),e[48]=_,e[49]=F,e[50]=B,e[51]=H):H=e[51];let P;e[52]!==v||e[53]!==l?(P=v!==void 0&&u("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-query-name-reason",role:"status",children:l(v==="ai-error"?"The model could not be reached.":"The model returned nothing usable.")}),e[52]=v,e[53]=l,e[54]=P):P=e[54];let Q;return e[55]!==x||e[56]!==I||e[57]!==k||e[58]!==H||e[59]!==P||e[60]!==b?(Q=W("form",{className:"flex flex-col gap-1 rounded-md bg-sidebar-accent p-1.5","data-testid":b,onSubmit:x,children:[I,k,H,P]}),e[55]=x,e[56]=I,e[57]=k,e[58]=H,e[59]=P,e[60]=b,e[61]=Q):Q=e[61],Q},it=[{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;"}],ls=r=>{const e=G(44),{active:s,onDelete:t,onRename:o,onSelect:n,query:l}=r,i=Z();let c;e[0]!==n||e[1]!==l.id?(c=()=>{n(l.id)},e[0]=n,e[1]=l.id,e[2]=c):c=e[2];const a=c;let d;e[3]!==t||e[4]!==l.id?(d=L=>{L.stopPropagation(),t(l.id)},e[3]=t,e[4]=l.id,e[5]=d):d=e[5];const m=d;let f;e[6]!==o||e[7]!==l.id?(f=L=>{L.stopPropagation(),o(l.id)},e[6]=o,e[7]=l.id,e[8]=f):f=e[8];const h=f,g=s?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground";let R;e[9]!==g?(R=ae("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",g),e[9]=g,e[10]=R):R=e[10];const v=`sql-query-${l.id}`;let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=u("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:u("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[11]=S):S=e[11];let p;e[12]!==l.name?(p=u("span",{className:"truncate",children:l.name}),e[12]=l.name,e[13]=p):p=e[13];let N;e[14]!==s||e[15]!==a||e[16]!==l.description||e[17]!==R||e[18]!==v||e[19]!==p?(N=W("button",{"aria-pressed":s,className:R,"data-testid":v,onClick:a,title:l.description,type:"button",children:[S,p]}),e[14]=s,e[15]=a,e[16]=l.description,e[17]=R,e[18]=v,e[19]=p,e[20]=N):N=e[20];let x;e[21]!==i?(x=i("Rename query"),e[21]=i,e[22]=x):x=e[22];const b=`sql-query-rename-open-${l.id}`;let y;e[23]!==i?(y=i("Rename query"),e[23]=i,e[24]=y):y=e[24];let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=u("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:u("path",{d:"M4 20h4L19 9l-4-4L4 16zM14 6l4 4"})}),e[25]=C):C=e[25];let w;e[26]!==h||e[27]!==x||e[28]!==b||e[29]!==y?(w=u("button",{"aria-label":x,className:"hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground group-hover/q:flex","data-testid":b,onClick:h,title:y,type:"button",children:C}),e[26]=h,e[27]=x,e[28]=b,e[29]=y,e[30]=w):w=e[30];let I;e[31]!==i?(I=i("Delete query"),e[31]=i,e[32]=I):I=e[32];let q;e[33]!==i?(q=i("Delete query"),e[33]=i,e[34]=q):q=e[34];let T;e[35]===Symbol.for("react.memo_cache_sentinel")?(T=u("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:u("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[35]=T):T=e[35];let E;e[36]!==m||e[37]!==I||e[38]!==q?(E=u("button",{"aria-label":I,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:m,title:q,type:"button",children:T}),e[36]=m,e[37]=I,e[38]=q,e[39]=E):E=e[39];let k;return e[40]!==w||e[41]!==E||e[42]!==N?(k=W("li",{className:"group/q flex items-center",children:[N,w,E]}),e[40]=w,e[41]=E,e[42]=N,e[43]=k):k=e[43],k},Ue="sql-history-remember",rs=(r,e)=>{const s=e.trim().toLowerCase();return s===""?[...r]:r.filter(t=>t.name.toLowerCase().includes(s))},is=r=>{const e=G(53),{activeId:s,history:t,listRef:o,onClearHistory:n,onDelete:l,onLoadHistory:i,onLoadTemplate:c,onNew:a,onRename:d,onSearchChange:m,onSelect:f,onToggleRememberHistory:h,queries:g,rememberHistory:R,rpc:v,search:S}=r,p=Z(),N=rs(g,S),[x,b]=te(null);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{b(null)},e[0]=y):y=e[0];const C=y;let w;e[1]!==h?(w=Y=>{h(Y.target.checked)},e[1]=h,e[2]=w):w=e[2];const I=w,q="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let T;e[3]!==p?(T=p("Search queries…"),e[3]=p,e[4]=T):T=e[4];let E;e[5]!==m||e[6]!==S||e[7]!==T?(E=u("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:m,placeholder:T,type:"text",value:S}),e[5]=m,e[6]=S,e[7]=T,e[8]=E):E=e[8];let k;e[9]!==p?(k=p("New query"),e[9]=p,e[10]=k):k=e[10];let L;e[11]!==p?(L=p("New query"),e[11]=p,e[12]=L):L=e[12];let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=u("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:u("path",{d:"M12 5v14M5 12h14"})}),e[13]=_):_=e[13];let $;e[14]!==a||e[15]!==k||e[16]!==L?($=u("button",{"aria-label":k,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:a,title:L,type:"button",children:_}),e[14]=a,e[15]=k,e[16]=L,e[17]=$):$=e[17];let F;e[18]!==E||e[19]!==$?(F=W("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[E,$]}),e[18]=E,e[19]=$,e[20]=F):F=e[20];const B="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let H;e[21]!==p?(H=p("Private"),e[21]=p,e[22]=H):H=e[22];let P;e[23]!==H?(P=u("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:H}),e[23]=H,e[24]=P):P=e[24];const Q=N.length===0?u("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:p("No saved queries yet — they save to this browser as you type.")}):u("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:N.map(Y=>x===Y.id?u("li",{children:u(os,{onCancel:C,onSave:(oe,re)=>{d(Y.id,oe,re),C()},query:Y,rpc:v})},Y.id):u(ls,{active:s===Y.id,onDelete:l,onRename:b,onSelect:f,query:Y},Y.id))});let M;e[25]!==P||e[26]!==Q?(M=W("div",{children:[P,Q]}),e[25]=P,e[26]=Q,e[27]=M):M=e[27];let A;e[28]!==p?(A=p("Reference"),e[28]=p,e[29]=A):A=e[29];let D;e[30]!==A?(D=u("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A}),e[30]=A,e[31]=D):D=e[31];let z;e[32]!==c?(z=it.map(Y=>u("li",{children:W("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":Y.sql,onClick:c,type:"button",children:[u("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:u("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),Y.label]})},Y.label)),e[32]=c,e[33]=z):z=e[33];let j;e[34]!==z?(j=u("ul",{className:"flex flex-col gap-px",children:z}),e[34]=z,e[35]=j):j=e[35];let K;e[36]!==D||e[37]!==j?(K=W("div",{children:[D,j]}),e[36]=D,e[37]=j,e[38]=K):K=e[38];let O;e[39]!==t||e[40]!==n||e[41]!==i||e[42]!==I||e[43]!==R||e[44]!==p?(O=t.length>0&&W("div",{children:[W("div",{className:"flex items-center justify-between px-1 pb-1",children:[u("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:p("History")}),u("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:n,type:"button",children:p("Clear history")})]}),W("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 pb-1.5 text-[11px] text-muted-foreground",htmlFor:Ue,children:[u("input",{checked:R,"data-testid":"sql-history-remember",id:Ue,onChange:I,type:"checkbox"}),p("Keep history on this browser")]}),u("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(Y=>u("li",{children:W("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":Y.sql,"data-testid":"sql-history-item",onClick:i,title:Y.sql,type:"button",children:[u("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:u("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),u("span",{className:"truncate font-mono",children:Y.sql})]})},`${Y.at.toString()}:${Y.sql}`))})]}),e[39]=t,e[40]=n,e[41]=i,e[42]=I,e[43]=R,e[44]=p,e[45]=O):O=e[45];let U;e[46]!==M||e[47]!==K||e[48]!==O?(U=W("div",{className:B,children:[M,K,O]}),e[46]=M,e[47]=K,e[48]=O,e[49]=U):U=e[49];let X;return e[50]!==F||e[51]!==U?(X=W("aside",{className:q,children:[F,U]}),e[50]=F,e[51]=U,e[52]=X):X=e[52],X},Ee=r=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${r?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,as=r=>{const e=G(16),{chatOpen:s,onToggle:t}=r,o=Z();let n;e[0]!==o?(n=o("Ask about your data"),e[0]=o,e[1]=n):n=e[1];const l=`inline-flex items-center gap-1.5 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"}`;let i;e[2]!==o?(i=o("Ask about your data"),e[2]=o,e[3]=i):i=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=u("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M21 12a8 8 0 0 1-8 8H7l-4 3 1.2-4.2A8 8 0 1 1 21 12Z"})}),e[4]=c):c=e[4];let a;e[5]!==o?(a=o("Assistant"),e[5]=o,e[6]=a):a=e[6];let d;e[7]!==a?(d=u("span",{className:"text-xs",children:a}),e[7]=a,e[8]=d):d=e[8];let m;return e[9]!==s||e[10]!==t||e[11]!==n||e[12]!==l||e[13]!==i||e[14]!==d?(m=W("button",{"aria-label":n,"aria-pressed":s,className:l,"data-testid":"sql-chat-toggle",onClick:t,title:i,type:"button",children:[c,d]}),e[9]=s,e[10]=t,e[11]=n,e[12]=l,e[13]=i,e[14]=d,e[15]=m):m=e[15],m},cs=r=>{const e=G(11),{onToggle:s,splitView:t}=r,o=Z();let n;e[0]!==o?(n=o("Split editor and results"),e[0]=o,e[1]=n):n=e[1];const l=`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 ${t?"bg-accent text-foreground":"text-muted-foreground"}`;let i;e[2]!==o?(i=o("Split editor and results"),e[2]=o,e[3]=i):i=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=W("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[u("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),u("path",{d:"M12 4v16"})]}),e[4]=c):c=e[4];let a;return e[5]!==s||e[6]!==t||e[7]!==n||e[8]!==l||e[9]!==i?(a=u("button",{"aria-label":n,"aria-pressed":t,className:l,"data-testid":"sql-split-toggle",onClick:s,title:i,type:"button",children:c}),e[5]=s,e[6]=t,e[7]=n,e[8]=l,e[9]=i,e[10]=a):a=e[10],a},ds=r=>{const e=G(8),{disabled:s,onExplainPlan:t,onExplainSql:o,pane:n}=r,l=Z();if(n==="explain"){let c;return e[0]!==s||e[1]!==t||e[2]!==l?(c=t===void 0?null:u("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-explain-plan",disabled:s,onClick:t,type:"button",children:l("Read this plan")}),e[0]=s,e[1]=t,e[2]=l,e[3]=c):c=e[3],c}let i;return e[4]!==s||e[5]!==o||e[6]!==l?(i=o===void 0?null:u("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-explain-query",disabled:s,onClick:o,type:"button",children:l("Explain this query")}),e[4]=s,e[5]=o,e[6]=l,e[7]=i):i=e[7],i},us=r=>{const e=G(8),{onRun:s,running:t}=r,o=Z();let n;e[0]!==t||e[1]!==o?(n=o(t?"Running…":"Run"),e[0]=t,e[1]=o,e[2]=n):n=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=u("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"⌘↵"}),e[3]=l):l=e[3];let i;return e[4]!==s||e[5]!==t||e[6]!==n?(i=W("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:t,onClick:s,type:"button",children:[n,l]}),e[4]=s,e[5]=t,e[6]=n,e[7]=i):i=e[7],i},fs=r=>{const e=G(35),{onInferChart:s,onShowChart:t,onShowExplain:o,onShowResults:n,pane:l,result:i,rpc:c}=r,a=Z(),d=l==="results";let m;e[0]!==d?(m=Ee(d),e[0]=d,e[1]=m):m=e[1];let f;e[2]!==a?(f=a("Results"),e[2]=a,e[3]=f):f=e[3];let h;e[4]!==n||e[5]!==m||e[6]!==f?(h=u("button",{className:m,"data-testid":"sql-tab-results",onClick:n,type:"button",children:f}),e[4]=n,e[5]=m,e[6]=f,e[7]=h):h=e[7];const g=l==="chart";let R;e[8]!==g?(R=Ee(g),e[8]=g,e[9]=R):R=e[9];let v;e[10]!==a?(v=a("Chart"),e[10]=a,e[11]=v):v=e[11];let S;e[12]!==t||e[13]!==R||e[14]!==v?(S=u("button",{className:R,"data-testid":"sql-tab-chart",onClick:t,type:"button",children:v}),e[12]=t,e[13]=R,e[14]=v,e[15]=S):S=e[15];let p;e[16]!==s||e[17]!==l||e[18]!==i||e[19]!==c||e[20]!==a?(p=!c.unavailable&&l==="chart"&&i!==null&&u("button",{className:Ee(!1),"data-testid":"sql-infer-chart",disabled:c.pending("chart"),onClick:s,type:"button",children:c.pending("chart")?a("Thinking…"):a("Suggest chart")}),e[16]=s,e[17]=l,e[18]=i,e[19]=c,e[20]=a,e[21]=p):p=e[21];const N=l==="explain";let x;e[22]!==N?(x=Ee(N),e[22]=N,e[23]=x):x=e[23];let b;e[24]!==a?(b=a("Explain"),e[24]=a,e[25]=b):b=e[25];let y;e[26]!==o||e[27]!==x||e[28]!==b?(y=u("button",{className:x,"data-testid":"sql-tab-explain",onClick:o,type:"button",children:b}),e[26]=o,e[27]=x,e[28]=b,e[29]=y):y=e[29];let C;return e[30]!==y||e[31]!==h||e[32]!==S||e[33]!==p?(C=W(xe,{children:[h,S,p,y]}),e[30]=y,e[31]=h,e[32]=S,e[33]=p,e[34]=C):C=e[34],C},ms=r=>{const e=G(9),{onSelectStatement:s,script:t}=r;let o;if(e[0]!==s||e[1]!==t.runs||e[2]!==t.selected){let l;e[4]!==s||e[5]!==t.selected?(l=(i,c)=>u("button",{"aria-pressed":c===t.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${c===t.selected?"border-foreground text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${i.error===null?"":"border-destructive/50 text-destructive"}`,"data-testid":`sql-statement-${c.toString()}`,onClick:()=>{s(c)},title:i.sql,type:"button",children:c+1},`${c.toString()}:${i.sql}`),e[4]=s,e[5]=t.selected,e[6]=l):l=e[6],o=t.runs.map(l),e[0]=s,e[1]=t.runs,e[2]=t.selected,e[3]=o}else o=e[3];let n;return e[7]!==o?(n=u("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:o}),e[7]=o,e[8]=n):n=e[8],n},ps=r=>{const e=G(9),{error:s,onDebugError:t,rpc:o}=r,n=Z();let l;e[0]!==s?(l=u(St,{className:"w-full font-mono text-xs",testId:"sql-error",variant:"destructive",children:s}),e[0]=s,e[1]=l):l=e[1];let i;e[2]!==t||e[3]!==o||e[4]!==n?(i=!o.unavailable&&t!==void 0&&W("button",{className:"inline-flex items-center gap-1.5 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-debug-error",disabled:o.pending("chat"),onClick:t,type:"button",children:[u("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:u("path",{d:"M21 12a8 8 0 0 1-8 8H7l-4 3 1.2-4.2A8 8 0 1 1 21 12Z"})}),o.pending("chat")?n("Thinking…"):n("Debug with AI")]}),e[2]=t,e[3]=o,e[4]=n,e[5]=i):i=e[5];let c;return e[6]!==l||e[7]!==i?(c=W("div",{className:"m-3 flex flex-col items-start gap-2",children:[l,i]}),e[6]=l,e[7]=i,e[8]=c):c=e[8],c},hs=r=>{const e=G(18),{chart:s,durationMs:t,pane:o,result:n}=r,l=Z();let i;e[0]!==s||e[1]!==o||e[2]!==n?(i=o==="chart"?u(xt,{axes:s,result:n}):u(vt,{result:n}),e[0]=s,e[1]=o,e[2]=n,e[3]=i):i=e[3];let c;e[4]!==n.rowCount||e[5]!==n.rows||e[6]!==n.truncated||e[7]!==l?(c=n.truncated?l("Showing the first {max} rows.",{max:n.rows.length}):l("{count} rows",{count:n.rowCount}),e[4]=n.rowCount,e[5]=n.rows,e[6]=n.truncated,e[7]=l,e[8]=c):c=e[8];let a;e[9]!==t||e[10]!==l?(a=t!==void 0&&` · ${l("{ms} ms",{ms:Math.round(t)})}`,e[9]=t,e[10]=l,e[11]=a):a=e[11];let d;e[12]!==c||e[13]!==a?(d=W("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:[c,a]}),e[12]=c,e[13]=a,e[14]=d):d=e[14];let m;return e[15]!==i||e[16]!==d?(m=W("div",{"data-testid":"sql-result",children:[i,d]}),e[15]=i,e[16]=d,e[17]=m):m=e[17],m},bs=r=>{const e=G(13),{chart:s,durationMs:t,error:o,onDebugError:n,pane:l,result:i,rpc:c}=r,a=Z();if(o!==null){let m;return e[0]!==o||e[1]!==n||e[2]!==c?(m=u(ps,{error:o,onDebugError:n,rpc:c}),e[0]=o,e[1]=n,e[2]=c,e[3]=m):m=e[3],m}if(i===null){let m;e[4]!==a?(m=a("Click Run to execute your query."),e[4]=a,e[5]=m):m=e[5];let f;return e[6]!==m?(f=u("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:m}),e[6]=m,e[7]=f):f=e[7],f}let d;return e[8]!==s||e[9]!==t||e[10]!==l||e[11]!==i?(d=u(hs,{chart:s,durationMs:t,pane:l,result:i}),e[8]=s,e[9]=t,e[10]=l,e[11]=i,e[12]=d):d=e[12],d},gs=r=>{const e=G(63),{rpc:s,chart:t,className:o,durationMs:n,error:l,onFormat:i,onInferChart:c,onRun:a,onSelectStatement:d,onShardKeyChange:m,onShowChart:f,onShowExplain:h,onShowResults:g,chatOpen:R,onDebugError:v,onExplainPlan:S,onExplainSql:p,onToggleChat:N,onToggleSplit:x,pane:b,result:y,running:C,script:w,shardKey:I,splitView:q}=r,T=Z();let E;e[0]!==c||e[1]!==f||e[2]!==h||e[3]!==g||e[4]!==b||e[5]!==y||e[6]!==s?(E=u(fs,{onInferChart:c,onShowChart:f,onShowExplain:h,onShowResults:g,pane:b,result:y,rpc:s}),e[0]=c,e[1]=f,e[2]=h,e[3]=g,e[4]=b,e[5]=y,e[6]=s,e[7]=E):E=e[7];let k;e[8]!==R||e[9]!==N?(k=N!==void 0&&u(as,{chatOpen:R,onToggle:N}),e[8]=R,e[9]=N,e[10]=k):k=e[10];let L;e[11]!==x||e[12]!==q?(L=u(cs,{onToggle:x,splitView:q}),e[11]=x,e[12]=q,e[13]=L):L=e[13];let _;e[14]!==y?(_=y!==null&&y.columns.length>0&&u(wt,{columns:y.columns,name:"query-result",rows:y.rows}),e[14]=y,e[15]=_):_=e[15];let $;e[16]!==T?($=T("Format"),e[16]=T,e[17]=$):$=e[17];let F;e[18]!==i||e[19]!==C||e[20]!==$?(F=u("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:C,onClick:i,type:"button",children:$}),e[18]=i,e[19]=C,e[20]=$,e[21]=F):F=e[21];let B;e[22]!==s||e[23]!==C?(B=C||s.pending("chat"),e[22]=s,e[23]=C,e[24]=B):B=e[24];let H;e[25]!==S||e[26]!==p||e[27]!==b||e[28]!==B?(H=u(ds,{disabled:B,onExplainPlan:S,onExplainSql:p,pane:b}),e[25]=S,e[26]=p,e[27]=b,e[28]=B,e[29]=H):H=e[29];let P;e[30]!==m||e[31]!==I?(P=u(yt,{onChange:m,testId:"sql-shard-input",value:I}),e[30]=m,e[31]=I,e[32]=P):P=e[32];let Q;e[33]!==a||e[34]!==C?(Q=u(us,{onRun:a,running:C}),e[33]=a,e[34]=C,e[35]=Q):Q=e[35];let M;e[36]!==Q||e[37]!==k||e[38]!==L||e[39]!==_||e[40]!==F||e[41]!==H||e[42]!==P?(M=W("div",{className:"ms-auto flex items-center gap-2",children:[k,L,_,F,H,P,Q]}),e[36]=Q,e[37]=k,e[38]=L,e[39]=_,e[40]=F,e[41]=H,e[42]=P,e[43]=M):M=e[43];let A;e[44]!==E||e[45]!==M?(A=W("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[E,M]}),e[44]=E,e[45]=M,e[46]=A):A=e[46];let D;e[47]!==d||e[48]!==w?(D=w!==void 0&&u(ms,{onSelectStatement:d,script:w}),e[47]=d,e[48]=w,e[49]=D):D=e[49];let z;e[50]!==t||e[51]!==n||e[52]!==l||e[53]!==v||e[54]!==b||e[55]!==y||e[56]!==s?(z=u("div",{className:"min-h-0 flex-1 overflow-auto",children:u(bs,{chart:t,durationMs:n,error:l,onDebugError:v,pane:b,result:y,rpc:s})}),e[50]=t,e[51]=n,e[52]=l,e[53]=v,e[54]=b,e[55]=y,e[56]=s,e[57]=z):z=e[57];let j;return e[58]!==o||e[59]!==A||e[60]!==D||e[61]!==z?(j=W("div",{className:o,children:[A,D,z]}),e[58]=o,e[59]=A,e[60]=D,e[61]=z,e[62]=j):j=e[62],j},xs=(r,e)=>r.trim()===""?e:(r.split(`
|
|
10
|
+
`)[0]??r).slice(0,24),vs=r=>{r?.focus(),r?.select()},ys=r=>{const e=G(14),{initial:s,onCancel:t,onCommit:o,placeholder:n,testId:l}=r,i=Z();let c;e[0]!==o?(c=g=>{o(g.currentTarget.value.trim())},e[0]=o,e[1]=c):c=e[1];const a=c;let d;e[2]!==t||e[3]!==o?(d=g=>{g.key==="Enter"?o(g.currentTarget.value.trim()):g.key==="Escape"&&t()},e[2]=t,e[3]=o,e[4]=d):d=e[4];const m=d;let f;e[5]!==i?(f=i("Tab title"),e[5]=i,e[6]=f):f=e[6];let h;return e[7]!==s||e[8]!==a||e[9]!==m||e[10]!==n||e[11]!==f||e[12]!==l?(h=u("input",{"aria-label":f,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":l,defaultValue:s,onBlur:a,onKeyDown:m,placeholder:n,ref:vs,type:"text"}),e[7]=s,e[8]=a,e[9]=m,e[10]=n,e[11]=f,e[12]=l,e[13]=h):h=e[13],h},Ss=r=>{const e=G(29),{idBase:s,onDiscard:t,onKeep:o}=r,n=Z(),l=`sql-tab-close-prompt-${s}`;let i;e[0]!==n?(i=n("Discard?"),e[0]=n,e[1]=i):i=e[1];let c;e[2]!==i?(c=u("span",{className:"text-[11px] text-muted-foreground",children:i}),e[2]=i,e[3]=c):c=e[3];let a;e[4]!==n?(a=n("Discard changes"),e[4]=n,e[5]=a):a=e[5];const d=`sql-tab-close-confirm-${s}`;let m;e[6]!==n?(m=n("Discard changes"),e[6]=n,e[7]=m):m=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:u("path",{d:"M5 13l4 4L19 7"})}),e[8]=f):f=e[8];let h;e[9]!==t||e[10]!==a||e[11]!==d||e[12]!==m?(h=u("button",{"aria-label":a,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":d,onClick:t,title:m,type:"button",children:f}),e[9]=t,e[10]=a,e[11]=d,e[12]=m,e[13]=h):h=e[13];let g;e[14]!==n?(g=n("Keep editing"),e[14]=n,e[15]=g):g=e[15];const R=`sql-tab-close-cancel-${s}`;let v;e[16]!==n?(v=n("Keep editing"),e[16]=n,e[17]=v):v=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:u("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=S):S=e[18];let p;e[19]!==o||e[20]!==R||e[21]!==v||e[22]!==g?(p=u("button",{"aria-label":g,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":R,onClick:o,title:v,type:"button",children:S}),e[19]=o,e[20]=R,e[21]=v,e[22]=g,e[23]=p):p=e[23];let N;return e[24]!==l||e[25]!==p||e[26]!==c||e[27]!==h?(N=W("span",{className:"flex shrink-0 items-center gap-1","data-testid":l,role:"group",children:[c,h,p]}),e[24]=l,e[25]=p,e[26]=c,e[27]=h,e[28]=N):N=e[28],N},ws=r=>{const e=G(47),{active:s,canClose:t,onClose:o,onMenu:n,onRename:l,onSelect:i,tab:c}=r,a=Z(),[d,m]=te(!1),[f,h]=te(!1);let g;e[0]!==n||e[1]!==c.id?(g=D=>{n(c.id,D)},e[0]=n,e[1]=c.id,e[2]=g):g=e[2];const R=g;let v;e[3]!==i||e[4]!==c.id?(v=()=>{i(c.id)},e[3]=i,e[4]=c.id,e[5]=v):v=e[5];const S=v;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{m(!0)},e[6]=p):p=e[6];const N=p;let x;e[7]!==o||e[8]!==c?(x=D=>{D.stopPropagation(),rt(c)?h(!0):o(c.id)},e[7]=o,e[8]=c,e[9]=x):x=e[9];const b=x;let y;e[10]!==o||e[11]!==c.id?(y=D=>{D.stopPropagation(),h(!1),o(c.id)},e[10]=o,e[11]=c.id,e[12]=y):y=e[12];const C=y;let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=D=>{D.stopPropagation(),h(!1)},e[13]=w):w=e[13];const I=w;let q;e[14]!==l||e[15]!==c.id?(q=D=>{l(c.id,D),m(!1)},e[14]=l,e[15]=c.id,e[16]=q):q=e[16];const T=q;let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{m(!1)},e[17]=E):E=e[17];const k=E;let L;e[18]!==c.name?(L=c.name.trim(),e[18]=c.name,e[19]=L):L=e[19];const _=L;let $;e[20]!==a||e[21]!==c.sql?($=xs(c.sql,a("Untitled")),e[20]=a,e[21]=c.sql,e[22]=$):$=e[22];const F=$,B=s?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground";let H;e[23]!==B?(H=ae("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",B),e[23]=B,e[24]=H):H=e[24];const P=`sql-tab-${c.id}`;let Q;e[25]!==s||e[26]!==T||e[27]!==_||e[28]!==F||e[29]!==d||e[30]!==S||e[31]!==a||e[32]!==c.id?(Q=d?u(ys,{initial:_,onCancel:k,onCommit:T,placeholder:F,testId:`sql-tab-rename-${c.id}`}):u("button",{"aria-pressed":s,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:S,onDoubleClick:N,title:a("Double-click to rename"),type:"button",children:_===""?F:_}),e[25]=s,e[26]=T,e[27]=_,e[28]=F,e[29]=d,e[30]=S,e[31]=a,e[32]=c.id,e[33]=Q):Q=e[33];let M;e[34]!==t||e[35]!==C||e[36]!==f||e[37]!==b||e[38]!==a||e[39]!==c.id?(M=t&&(f?u(Ss,{idBase:c.id,onDiscard:C,onKeep:I}):u("button",{"aria-label":a("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-${c.id}`,onClick:b,title:a("Close tab"),type:"button",children:u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:u("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=C,e[36]=f,e[37]=b,e[38]=a,e[39]=c.id,e[40]=M):M=e[40];let A;return e[41]!==R||e[42]!==H||e[43]!==P||e[44]!==Q||e[45]!==M?(A=W("div",{className:H,"data-testid":P,onContextMenu:R,children:[Q,M]}),e[41]=R,e[42]=H,e[43]=P,e[44]=Q,e[45]=M,e[46]=A):A=e[46],A},Cs=r=>{const e=G(43),{model:s,onSelect:t}=r,o=Z(),{activeTab:n,addEditorTab:l,cancelBulk:i,closeEditorTab:c,closeTabMenu:a,confirmBulk:d,menuStyle:m,onBackdropContextMenu:f,onCloseAll:h,onCloseOthers:g,onCloseToRight:R,openTabMenu:v,pendingBulk:S,renameTab:p,tabMenu:N,tabs:x}=s;let b;if(e[0]!==n||e[1]!==c||e[2]!==t||e[3]!==v||e[4]!==p||e[5]!==x){let L;e[7]!==n||e[8]!==c||e[9]!==t||e[10]!==v||e[11]!==p||e[12]!==x.length?(L=_=>u(ws,{active:_.id===n.id,canClose:x.length>1,onClose:c,onMenu:v,onRename:p,onSelect:t,tab:_},_.id),e[7]=n,e[8]=c,e[9]=t,e[10]=v,e[11]=p,e[12]=x.length,e[13]=L):L=e[13],b=x.map(L),e[0]=n,e[1]=c,e[2]=t,e[3]=v,e[4]=p,e[5]=x,e[6]=b}else b=e[6];let y;e[14]!==o?(y=o("New tab"),e[14]=o,e[15]=y):y=e[15];const C=x.length>=Pe;let w;e[16]!==o?(w=o("New tab"),e[16]=o,e[17]=w):w=e[17];let I;e[18]===Symbol.for("react.memo_cache_sentinel")?(I=u("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:u("path",{d:"M12 5v14M5 12h14"})}),e[18]=I):I=e[18];let q;e[19]!==l||e[20]!==y||e[21]!==C||e[22]!==w?(q=u("button",{"aria-label":y,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:l,title:w,type:"button",children:I}),e[19]=l,e[20]=y,e[21]=C,e[22]=w,e[23]=q):q=e[23];let T;e[24]!==b||e[25]!==q?(T=W("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:[b,q]}),e[24]=b,e[25]=q,e[26]=T):T=e[26];let E;e[27]!==i||e[28]!==a||e[29]!==d||e[30]!==m||e[31]!==f||e[32]!==h||e[33]!==g||e[34]!==R||e[35]!==S||e[36]!==o||e[37]!==N||e[38]!==x?(E=N!==null&&W(xe,{children:[u("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:a,onContextMenu:f,role:"presentation"}),u("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:m,children:S===null?W(xe,{children:[u("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:x.length<=1,onClick:g,role:"menuitem",type:"button",children:o("Close other tabs")}),u("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:x.findIndex(L=>L.id===N.id)>=x.length-1,onClick:R,role:"menuitem",type:"button",children:o("Close tabs to the right")}),u("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:h,role:"menuitem",type:"button",children:o("Close all tabs")})]}):W("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[u("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")}),W("div",{className:"flex items-center gap-1.5",children:[u("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:d,type:"button",children:o("Discard")}),u("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:i,type:"button",children:o("Cancel")})]})]})})]}),e[27]=i,e[28]=a,e[29]=d,e[30]=m,e[31]=f,e[32]=h,e[33]=g,e[34]=R,e[35]=S,e[36]=o,e[37]=N,e[38]=x,e[39]=E):E=e[39];let k;return e[40]!==T||e[41]!==E?(k=W(xe,{children:[T,E]}),e[40]=T,e[41]=E,e[42]=k):k=e[42],k},ks=Ae(Le.runSql),Ns="lunora-studio-sql-split-view",Es=()=>Se(it[0]?.sql??""),Ts=()=>performance.now(),qs=()=>{const r=G(2);let e;r[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,r[0]=e):e=r[0];const s=de(e);let t;return r[1]===Symbol.for("react.memo_cache_sentinel")?(t={advance:o=>{s.current.set(o,(s.current.get(o)??0)+1)},begin:o=>{const n=s.current.get(o)??0;return()=>(s.current.get(o)??0)===n}},r[1]=t):t=r[1],t},Rs=(r,e)=>{const s=r.tables[0];return s===void 0?[e("What tables does this app have?")]:[e("What tables does this app have?"),e("Show me the most recent rows in {table}",{table:s}),e("Is anything wrong with my schema?")]},Te=r=>r.tables.map(e=>({columns:[...r.columns[e]??[]],table:e})),Vs=({initialShardKey:r,now:e=Ts})=>{const s=Me(),t=$n(Es),{activeTab:o,openEditorTab:n,output:l,patchActiveOutput:i,patchActiveTab:c,setActiveTabId:a,unlinkQuery:d}=t,m=qs(),h=Qn({loadIntoActiveTab:(J,le)=>{m.advance(o.id),c({activeId:le,sql:J}),i({chart:void 0,durationMs:void 0,error:null,failed:void 0,result:null,running:!1,script:void 0})},unlinkQuery:d}),{recordHistory:g,updateQuerySql:R}=h,v=o.sql,{activeId:S}=o,{chart:p,error:N,failed:x,result:b,running:y}=l,C=l.pane,[w,I]=te(r??""),[q,T]=$e(Ns,!1),E=Z(),k=dt(),{probe:L,schema:_}=wn(w),$=Ye(J=>{c({sql:J}),S!==null&&R(S,J)},[S,c,R]),F=k?.setHasEditor;ue(()=>{if(F!==void 0)return F(!0),()=>{F(!1)}},[F]);const B=k?.insertRequest,H=k?.takeInsert;ue(()=>{B===void 0||H===void 0||(H(B.id),v.trim()===""&&S===null?$(B.sql):n(B.sql)||c({activeId:null,sql:v.trim()===""?B.sql:`${v.trimEnd()}
|
|
11
|
+
|
|
12
|
+
${B.sql}`}))},[S,v,B,n,c,H,$]);const P=ln(v,_,w),Q=ut(w),M=()=>{if(b===null)return;ie((async()=>{const le=await Q.inferChart({columns:b.columns,rowCount:b.rowCount,types:Object.fromEntries(b.columns.map(ne=>[ne,typeof(b.rows[0]?.[ne]??"")]))});i({chart:le})})())},A=async J=>{const le=e();try{const ne=await s.query(ks,{sql:J},qe(w)),ce=e()-le;return g(J),{durationMs:ce,error:null,result:ne,sql:J}}catch(ne){return{error:pt(ne),result:null,sql:J}}},D=async J=>{if(v.trim()==="")return;const le=m.begin(o.id);i({running:!0,...J==="explain"?{explained:v.trim()}:{}});const ne=J==="explain"?Oe(At(v),0):tt(v),ce=[];for(const we of ne){const at={error:we.rejection?.message??"",result:null,sql:we.sql};ce.push(we.rejection===void 0?await A(we.sql):at)}if(ht(w),!le())return;const He=Math.max(ce.length-1,0),me=ce[He];i({chart:void 0,durationMs:me?.durationMs,error:me?.error??null,failed:me?.error===null||me===void 0?void 0:{error:me.error,sql:me.sql},pane:J,result:me?.result??null,running:!1,script:ce.length>1?{runs:ce,selected:He}:void 0})},z=J=>{const le=l.script?.runs,ne=le?.[J];le===void 0||ne===void 0||i({chart:void 0,durationMs:ne.durationMs,error:ne.error,failed:ne.error===null?void 0:{error:ne.error,sql:ne.sql},result:ne.result,script:{runs:le,selected:J}})},j=()=>{ie(D("results"))},K=En({inlineEditEnabled:!Q.unavailable,onSubmit:()=>{ie(D(l.pane))},probe:L,schema:_,setDraft:$}),{closeAutocomplete:O,closeInlineEdit:U}=K,X=()=>{$(Bt(v))},Y=J=>{O(),U(),a(J)},oe=()=>{i({pane:"results"})},re=()=>{ie(D("explain"))},pe=()=>{i({pane:"chart"})},ve=()=>{T(!q)},he=()=>{if(k!==void 0){if(k.open){k.close();return}k.openAssistant({schema:Te(_),shardKey:w,suggestions:Rs(_,E),title:E("SQL console")})}},ye=J=>{k?.rebindShard(w,J),I(J)},be=()=>{x!==void 0&&k?.openAssistant({ask:E(`This statement failed:
|
|
13
|
+
{sql}
|
|
14
|
+
|
|
15
|
+
The database said: {error}
|
|
16
|
+
|
|
17
|
+
Why, and what should it be?`,{error:x.error,sql:x.sql}),schema:Te(_),shardKey:w,title:E("Debug query")})},V=()=>{const J=v.trim();J!==""&&k?.openAssistant({ask:E(`Explain what this query does, step by step:
|
|
18
|
+
{statement}`,{statement:J}),schema:Te(_),shardKey:w,title:E("Explain query")})},ee=()=>{const J=l.explained;if(b===null||b.rows.length===0||J===void 0)return;const le=b.rows.map(ne=>b.columns.map(ce=>mt(ne[ce])).join(" | ")).join(`
|
|
19
|
+
`);k?.openAssistant({ask:E(`SQLite planned this query:
|
|
20
|
+
{statement}
|
|
21
|
+
|
|
22
|
+
as:
|
|
23
|
+
{plan}
|
|
24
|
+
|
|
25
|
+
What is it doing, and is anything here slow?`,{plan:le,statement:J}),schema:Te(_),shardKey:w,title:E("Read plan")})},se=q?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",fe=q?"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";return W("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[u(is,{activeId:S,history:h.history,listRef:h.listRef,onClearHistory:h.clearHistory,onDelete:h.deleteQuery,onLoadHistory:h.loadFromHistory,onLoadTemplate:h.loadTemplate,onNew:h.newQuery,onRename:h.renameQuery,onSearchChange:h.onSearchChange,onSelect:h.selectQuery,onToggleRememberHistory:h.setRememberHistory,queries:h.queries,rememberHistory:h.rememberHistory,rpc:Q,search:h.search}),W("div",{className:"flex min-w-0 flex-1 flex-col",children:[u(Cs,{model:t,onSelect:Y}),W("div",{className:se,children:[u(ns,{autocomplete:K.autocompleteState,diagnostics:P,draft:v,editorRef:K.editorRef,failed:x,gutterRef:K.gutterRef,handlers:K.handlers,inlineEdit:K.inlineEdit,listboxId:K.listboxId,onAcceptInlineEdit:K.acceptInlineEdit,onCancelInlineEdit:K.closeInlineEdit,onGenerated:$,onPickSuggestion:K.onPickSuggestion,onRevealDiagnostic:K.revealDiagnostic,overlayRef:K.overlayRef,rpc:Q}),u(gs,{chart:p,chatOpen:k?.open===!0,className:fe,durationMs:l.durationMs,error:N,onDebugError:x===void 0?void 0:be,onExplainPlan:k===void 0||k.unavailable||C!=="explain"?void 0:ee,onExplainSql:k===void 0||k.unavailable?void 0:V,onFormat:X,onInferChart:M,onRun:j,onSelectStatement:z,onShardKeyChange:ye,onShowChart:pe,onShowExplain:re,onShowResults:oe,onToggleChat:k===void 0||k.unavailable?void 0:he,onToggleSplit:ve,pane:C,result:b,rpc:Q,running:y,script:l.script,shardKey:w,splitView:q})]})]})]})};export{Vs as SqlEditorPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as k}from"react/compiler-runtime";import{useNavigate as F,useRouter as M,useSearch as P}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{u as q}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as J}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{s as L,d as D}from"../packem_shared/data-view-params-C-_G-biH.mjs";import{f as m}from"../packem_shared/internal-hIuTpSbx.mjs";import{l as O,s as I}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{DataBrowser as X}from"../packem_shared/DataBrowser-
|
|
1
|
+
import{c as k}from"react/compiler-runtime";import{useNavigate as F,useRouter as M,useSearch as P}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{u as q}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as J}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{s as L,d as D}from"../packem_shared/data-view-params-C-_G-biH.mjs";import{f as m}from"../packem_shared/internal-hIuTpSbx.mjs";import{l as O,s as I}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{DataBrowser as X}from"../packem_shared/DataBrowser-Dm-jhIUP.mjs";import{GlobalDataBrowser as Y}from"../packem_shared/GlobalDataBrowser-C1Y8GUhe.mjs";import{jsx as v,jsxs as E}from"react/jsx-runtime";const N="lunora-studio-saved-queries",$=50,z=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,y=()=>O(N).filter(z),B=r=>{I(N,r)},H=(r,e)=>{const l=r.trim();if(l==="")return y();const n=[{name:l,view:e},...y().filter(o=>o.name!==l)].slice(0,$);return B(n),n},U=r=>{const e=y().filter(l=>l.name!==r);return B(e),e},W=r=>{const e=k(15),{onChange:l,tier:n}=r,o=K();let p;e[0]!==l?(p=S=>{l(S.target.value)},e[0]=l,e[1]=p):p=e[1];const u=p;let s;e[2]!==o?(s=o("Storage tier"),e[2]=o,e[3]=s):s=e[3];let d;e[4]!==s?(d=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];const g=w[n];let c,i;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=v("option",{value:"shard",children:w.shard.label}),i=v("option",{value:"global",children:w.global.label}),e[6]=c,e[7]=i):(c=e[6],i=e[7]);let h;e[8]!==u||e[9]!==g.title||e[10]!==n?(h=E("select",{className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus-visible:border-ring","data-testid":"table-editor-schema",id:"table-editor-schema",onChange:u,title:g.title,value:n,children:[c,i]}),e[8]=u,e[9]=g.title,e[10]=n,e[11]=h):h=e[11];let f;return e[12]!==d||e[13]!==h?(f=E("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[d,h]}),e[12]=d,e[13]=h,e[14]=f):f=e[14],f},Z=()=>{try{m(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},ge=({canGenerateRows:r=!1,editable:e=!1,initialShardKey:l})=>{const n=J(),o=F(),p=M(),u=P({strict:!1}),s=L(u),d=q(u),g=()=>p.state.location.pathname.split("/").findLast(Boolean)==="data",c=s.tier??"shard",i=s.table,[h,f]=Q(()=>y()),[S,C]=Q(()=>new Set);A(()=>{m((async()=>{try{const a=await n.listGlobalTables();C(new Set(a.map(t=>t.name)))}catch{}})())},[n]),A(()=>{c==="shard"&&i!==void 0&&S.has(i)&&m(o({replace:!0,search:a=>({...a,schema:"global"}),to:"/data"}))},[S,o,i,c]);const R=a=>{m(o({search:t=>({...t,schema:a==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(a,t)=>{g()&&m(o({search:b=>({schema:b.schema,search:t?.search,shard:b.shard,table:a}),to:"/data"}))},G=a=>{m(o({search:t=>({...t,schema:"global",table:a}),to:"/data"}))},_=a=>{const t=D(a),{current:b}=d;(b.filters??void 0)===t.filters&&(b.order??void 0)===t.order&&(b.search??void 0)===t.search&&(b.shard??void 0)===t.shard||!g()||m(o({replace:!0,search:V=>({...V,filters:t.filters,order:t.order,search:t.search,shard:t.shard}),to:"/data"}))},j={onApplyQuery:a=>{const t=D(a.view);m(o({search:()=>({filters:t.filters,order:t.order,schema:t.schema,search:t.search,shard:t.shard,table:t.table}),to:"/data"}))},onCopyLink:Z,onDeleteQuery:a=>{f(U(a))},onSaveQuery:(a,t)=>{f(H(a,t))},saved:h},x=v(W,{onChange:R,tier:c});return c==="global"?v(Y,{initialTable:i,onSelectTable:T,schemaSwitch:x}):v(X,{canGenerateRows:r,editable:e,globalTableNames:S,initialFilters:s.filters,initialOrderBy:s.orderBy,initialPins:u.pins,initialSearch:s.search,initialShardKey:s.shard??l,onNavigateToGlobal:G,onSelectTable:T,onViewChange:_,queryBar:j,schemaSwitch:x,tableParam:i})};export{ge as TableEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as te}from"react/compiler-runtime";import{useState as
|
|
1
|
+
import{c as te}from"react/compiler-runtime";import{useState as se}from"react";import{E as q}from"../packem_shared/error-alert-DKXm5h19.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as $}from"../packem_shared/button-q0UYSmrn.mjs";import{C as M,a as j}from"../packem_shared/card-By2O8ULa.mjs";import{E as K}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as L,a as P,b as f,c as o,d as U,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{u as x}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-DUXsXId1.mjs";import{h as ae}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as e,jsxs as l}from"react/jsx-runtime";const Q="agent_threads",re="agent_messages",D="agent_run_queue",_=100,y=250,ne={},oe={filters:[],limit:_,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:Q},c=(r,t)=>{const s=r[t];return typeof s=="string"?s:void 0},E=(r,t)=>{const s=r[t];return typeof s=="number"?s:void 0},H=r=>{const{usage:t}=r;if(t===null||typeof t!="object")return;const{totalTokens:s}=t;return typeof s=="number"?s:void 0},de=r=>{const{toolCalls:t}=r;return Array.isArray(t)?t.map(s=>s!==null&&typeof s=="object"?s.name:void 0).filter(s=>typeof s=="string"):[]},le=r=>{switch(r){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},ie=r=>{switch(r){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},ce=r=>{const t=te(3),{fetched:s}=r,u=G();let i;return t[0]!==s||t[1]!==u?(i=s<=y?null:e("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:u("Showing the latest {count} messages; older ones are not shown.",{count:y})}),t[0]=s,t[1]=u,t[2]=i):i=t[2],i},Ee=({initialShardKey:r=""})=>{const t=G(),[s,u]=se(void 0),{data:i}=x(v.listTables,ne,{live:!0,shardKey:r}),z=i!==void 0,h=Array.isArray(i)&&i.some(a=>a.name===Q),O=Array.isArray(i)&&i.some(a=>a.name===D),{data:S,error:V,errorSource:F,liveError:J}=x(v.readTablePage,oe,{enabled:h,live:!0,shardKey:r}),W={filters:[{column:"threadKey",operator:"eq",value:s??""}],limit:y+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:re},{data:w}=x(v.readTablePage,{limit:_,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:D},{enabled:O,live:!0,shardKey:r}),{data:k,error:X,errorSource:Y}=x(v.readTablePage,W,{enabled:h&&s!==void 0,live:!0,shardKey:r}),b=Array.isArray(S?.rows)?S.rows:[],Z=Array.isArray(w?.rows)?w.rows:[],C=a=>Z.filter(n=>c(n,"threadKey")===a).length,B=Array.isArray(k?.rows)?k.rows:[],I=B.slice(0,y).toReversed(),R=b.find(a=>c(a,"key")===s);let g;return z&&!h?g=e(K,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):h&&b.length===0?g=e(K,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):g=l("div",{className:"flex flex-col gap-6",children:[e(M,{className:"overflow-hidden py-0",children:e(j,{className:"px-0",children:l(L,{"data-testid":"agents-threads-table",children:[e(P,{children:l(f,{children:[e(o,{children:t("Agent")}),e(o,{children:t("Key")}),e(o,{children:t("Status")}),e(o,{children:t("Queued")}),e(o,{children:t("Messages")}),e(o,{children:t("Tokens")}),e(o,{children:t("Updated")}),e(o,{"aria-label":t("Actions")})]})}),e(U,{children:b.map(a=>{const n=c(a,"key")??"",m=c(a,"status"),p=H(a);return l(f,{"data-active":n===s?"":void 0,"data-testid":`agents-thread-${n}`,children:[e(d,{className:"font-mono text-xs",children:c(a,"agent")??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:n}),e(d,{children:e(A,{"data-testid":`agents-thread-status-${n}`,variant:le(m),children:m??"—"})}),e(d,{className:"tabular-nums",children:C(n)===0?e("span",{className:"text-muted-foreground",children:"—"}):e(A,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:C(n)})}),e(d,{className:"tabular-nums",children:E(a,"messageCount")??"—"}),e(d,{className:"tabular-nums text-muted-foreground",children:p??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:ae(E(a,"updatedAt"),"—")}),e(d,{className:"text-right",children:e($,{"data-testid":`agents-thread-open-${n}`,onClick:()=>{u(n)},size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),X!==null&&e(q,{error:Y,shardKey:r,testId:"agents-messages-error"}),s!==void 0&&e(M,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:l(j,{className:"flex flex-col gap-3 px-4 py-3",children:[l("div",{className:"flex items-center justify-between gap-2",children:[l("span",{className:"font-mono text-xs",children:[t("Timeline")," · ",s,R!==void 0&&l("span",{className:"text-muted-foreground",children:[" · ",t("Usage"),": ",H(R)??0," ",t("Tokens")]})]}),e($,{"data-testid":"agents-thread-detail-close",onClick:()=>{u(void 0)},size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),e(ce,{fetched:B.length}),I.length===0?e("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):l(L,{"data-testid":"agents-messages-table",children:[e(P,{children:l(f,{children:[e(o,{children:t("Role")}),e(o,{children:t("Content")}),e(o,{children:t("Tool")}),e(o,{children:t("Approval")})]})}),e(U,{children:I.map((a,n)=>{const m=c(a,"role")??"—",p=de(a),ee=c(a,"toolName"),N=c(a,"status"),T=E(a,"seq")??n;return l(f,{"data-testid":`agents-message-${String(T)}`,children:[e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:m}),e(d,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(a,"content")??"—"}),e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:ee??(p.length>0?p.join(", "):"—")}),e(d,{className:"align-top",children:N===void 0?e("span",{className:"text-xs text-muted-foreground",children:"—"}):e(A,{"data-testid":`agents-message-approval-${String(T)}`,variant:ie(N),children:N})})]},c(a,"messageKey")??`${m}:${String(T)}`)})})]})]})})]}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[V!==null&&e(q,{error:F,shardKey:r,testId:"agents-error"}),e("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),J!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),g]})};export{Ee as default};
|