@lunora/studio 1.0.0-alpha.106 → 1.0.0-alpha.108
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.ts +15 -2
- package/dist/index.js +1 -1
- package/dist/mount.js +1 -1
- package/dist/packem_chunks/AdvisorHealthPanel.js +1 -1
- package/dist/packem_chunks/ApiTab.js +1 -1
- package/dist/packem_chunks/AuditPanel.js +1 -1
- package/dist/packem_chunks/DeploymentHealthPanel.js +1 -1
- package/dist/packem_chunks/ExportImportPanel.js +3 -3
- package/dist/packem_chunks/FileBrowser.js +4 -4
- package/dist/packem_chunks/FunctionRunner.js +1 -1
- package/dist/packem_chunks/FunctionStatsPanel.js +1 -1
- package/dist/packem_chunks/HealthPanel.js +1 -1
- package/dist/packem_chunks/InsightsPanel.js +1 -1
- package/dist/packem_chunks/LogsPanel.js +1 -1
- package/dist/packem_chunks/MailPanel.js +1 -1
- package/dist/packem_chunks/MetricsPanel.js +1 -1
- package/dist/packem_chunks/NotificationsPanel.js +1 -1
- package/dist/packem_chunks/PitrPanel.js +1 -1
- package/dist/packem_chunks/SchemaViewer.js +1 -1
- package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -1
- package/dist/packem_chunks/SettingsPanel.js +1 -1
- package/dist/packem_chunks/SqlEditorPanel.js +6 -6
- package/dist/packem_chunks/TableEditor.js +1 -1
- package/dist/packem_chunks/agents-panel.js +1 -1
- package/dist/packem_chunks/analytics-panel.js +1 -1
- package/dist/packem_chunks/auth-audit-panel.js +1 -1
- package/dist/packem_chunks/auth-config-panel.js +1 -1
- package/dist/packem_chunks/auth-sessions-panel.js +1 -1
- package/dist/packem_chunks/containers-panel.js +1 -1
- package/dist/packem_chunks/dashboards-panel.js +1 -1
- package/dist/packem_chunks/evals-panel.js +1 -1
- package/dist/packem_chunks/fanout-panel.js +1 -1
- package/dist/packem_chunks/flags-panel.js +1 -1
- package/dist/packem_chunks/issues-panel.js +1 -1
- package/dist/packem_chunks/kv-browser.js +1 -1
- package/dist/packem_chunks/log-drains-panel.js +4 -4
- package/dist/packem_chunks/migrations-route.js +1 -1
- package/dist/packem_chunks/organizations-panel.js +1 -1
- package/dist/packem_chunks/payments-panel.js +1 -1
- package/dist/packem_chunks/permissions-panel.js +1 -1
- package/dist/packem_chunks/queues-panel.js +1 -1
- package/dist/packem_chunks/rls-panel.js +1 -1
- package/dist/packem_chunks/schedule-panel.js +1 -1
- package/dist/packem_chunks/sparkline.js +1 -1
- package/dist/packem_chunks/storage-rules-panel.js +1 -1
- package/dist/packem_chunks/subscriptions-panel.js +1 -1
- package/dist/packem_chunks/sync-client-panel.js +1 -1
- package/dist/packem_chunks/traces-panel.js +1 -1
- package/dist/packem_chunks/users-panel.js +1 -1
- package/dist/packem_chunks/vector-browser.js +1 -1
- package/dist/packem_chunks/workflows-panel.js +1 -1
- package/dist/packem_shared/ApiDocsPanel-BQ79UVEg.js +2 -0
- package/dist/packem_shared/ApiReferencePanel-CkCFMCBb.js +1 -0
- package/dist/packem_shared/CommandPalette-B5yLEABs.js +1 -0
- package/dist/packem_shared/ConfirmButton-Cj2SOapE.js +1 -0
- package/dist/packem_shared/ConnectionBadge-Bh16X9-u.js +1 -0
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js +1 -0
- package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-1Lrg55IV.js +1 -0
- package/dist/packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js +1 -0
- package/dist/packem_shared/DataBrowser-BnDIFN-S.js +1 -0
- package/dist/packem_shared/DataFilters-3nbW0uax.js +1 -0
- package/dist/packem_shared/ErrorBoundary-BWNF98VF.js +1 -0
- package/dist/packem_shared/GlobalDataBrowser-DusjXzRF.js +1 -0
- package/dist/packem_shared/HomePanel-BcaHVBJh.js +1 -0
- package/dist/packem_shared/MigrationsPanel-CCOENX4X.js +1 -0
- package/dist/packem_shared/OpenRpcReferencePanel-21OWMH45.js +1 -0
- package/dist/packem_shared/ScheduledJobs-CiO3eXgI.js +1 -0
- package/dist/packem_shared/ShardInput-XumEzeT0.js +1 -0
- package/dist/packem_shared/Studio-CHmLCjBR.js +1 -0
- package/dist/packem_shared/StudioApp-DCdbsciH.js +1 -0
- package/dist/packem_shared/StudioI18nProvider-Bl547evf.js +1 -0
- package/dist/packem_shared/advisor-view-C1KFTXSH.js +1 -0
- package/dist/packem_shared/aggregateMetrics-A-Y7OH6R.js +1 -0
- package/dist/packem_shared/alert-C2SEhYS9.js +1 -0
- package/dist/packem_shared/{badge-BbuuAio7.js → badge-cAk9Di1Q.js} +1 -1
- package/dist/packem_shared/bar-chart-CCyO67Uf.js +6 -0
- package/dist/packem_shared/browser-storage-Br_bLeBt.js +1 -0
- package/dist/packem_shared/{button-BkCrNcAs.js → button-BOPLD1un.js} +1 -1
- package/dist/packem_shared/card-BGlQzQY-.js +1 -0
- package/dist/packem_shared/cf-links-CBJ5SywP.js +1 -0
- package/dist/packem_shared/{checkbox-StT4Gob6.js → checkbox-C5w53W-E.js} +1 -1
- package/dist/packem_shared/data-grid-BFTQnkXq.js +1 -0
- package/dist/packem_shared/data-view-params-qoSTqjAj.js +1 -0
- package/dist/packem_shared/dropdown-menu-D_ewqsUU.js +2 -0
- package/dist/packem_shared/empty-state-B939z6K2.js +1 -0
- package/dist/packem_shared/error-alert-TYdKetJd.js +1 -0
- package/dist/packem_shared/grid-features-C_yXlMc_.js +6 -0
- package/dist/packem_shared/home-panel-BiJHXeDC.js +3 -0
- package/dist/packem_shared/input-CY5W3wzv.js +1 -0
- package/dist/packem_shared/internal-CwaF9YNk.js +2 -0
- package/dist/packem_shared/label-BOUo-DP0.js +1 -0
- package/dist/packem_shared/live-status-Bf7rR8o8.js +1 -0
- package/dist/packem_shared/{log-fields-CoL3hsIQ.js → log-fields-SBxKyBug.js} +1 -1
- package/dist/packem_shared/log-line-UnE93Ovi.js +1 -0
- package/dist/packem_shared/modal-shell-wGW4CKEW.js +1 -0
- package/dist/packem_shared/operation-console-provider-DoloEvon.js +1 -0
- package/dist/packem_shared/recording-client-CKn4-vUx.js +1 -0
- package/dist/packem_shared/reference-view-CUIDzLf0.js +12 -0
- package/dist/packem_shared/result-chart-Ca3YLzt8.js +1 -0
- package/dist/packem_shared/schema-diagram-DHD13TjS.js +2 -0
- package/dist/packem_shared/scroll-area-DSJftwu_.js +2 -0
- package/dist/packem_shared/select-BPISLTcv.js +2 -0
- package/dist/packem_shared/shard-history-QcjcMnCA.js +1 -0
- package/dist/packem_shared/skeleton-DFBBaJU6.js +1 -0
- package/dist/packem_shared/sparkline-BreIqzDO.js +1 -0
- package/dist/packem_shared/stat-card-B9uIvAHg.js +1 -0
- package/dist/packem_shared/{storage-tier-DznqOf-q.js → storage-tier-C2mKwYRj.js} +1 -1
- package/dist/packem_shared/studio-B3eEcBK0.js +2 -0
- package/dist/packem_shared/table-BMsuYFhk.js +2 -0
- package/dist/packem_shared/table-list-sidebar-Bluzd1_2.js +1 -0
- package/dist/packem_shared/textarea-DpO3i-Qo.js +1 -0
- package/dist/packem_shared/{trace-handoff-Dw7mwjxu.js → trace-handoff-C0CFV2ix.js} +1 -1
- package/dist/packem_shared/use-admin-query-P0RJrjsD.js +1 -0
- package/dist/packem_shared/use-async-submit-DdLd0MdK.js +1 -0
- package/dist/packem_shared/use-auth-config-z3KRWAqD.js +1 -0
- package/dist/packem_shared/use-open-trace-4tIa0SXZ.js +1 -0
- package/dist/packem_shared/use-shard-key-BsP3o5wT.js +1 -0
- package/dist/packem_shared/use-sql-assistant-CP90nLLh.js +1 -0
- package/dist/packem_shared/useDebounced-DVeQ5-oW.js +1 -0
- package/dist/packem_shared/virtual-rect-D_j7aLxX.js +1 -0
- package/dist/packem_shared/wire-codec-Dl3VeNrd.js +1 -0
- package/dist/standalone/chunk-25OIGX2A.js +1 -0
- package/dist/standalone/{chunk-OBMNLQWG.js → chunk-26VREVWU.js} +1 -1
- package/dist/standalone/chunk-2BDM6HNL.js +1 -0
- package/dist/standalone/{chunk-6WB63KTN.js → chunk-2DC6F7NH.js} +1 -1
- package/dist/standalone/chunk-3F5I435D.js +1 -0
- package/dist/standalone/{chunk-RJS7UD5U.js → chunk-3QB5JI32.js} +1 -1
- package/dist/standalone/chunk-3RYEUXY2.js +1 -0
- package/dist/standalone/chunk-44WNSIGQ.js +1 -0
- package/dist/standalone/chunk-45YWYMD5.js +1 -0
- package/dist/standalone/chunk-4MAJFNON.js +1 -0
- package/dist/standalone/chunk-4YTSKL4R.js +1 -0
- package/dist/standalone/chunk-57VX76PR.js +1 -0
- package/dist/standalone/chunk-5JLIP2HH.js +1 -0
- package/dist/standalone/chunk-5NRQIDQA.js +1 -0
- package/dist/standalone/{chunk-2ZG23BA5.js → chunk-5T7KRUPX.js} +1 -1
- package/dist/standalone/chunk-6FWN26RH.js +1 -0
- package/dist/standalone/chunk-6JGXSMKV.js +1 -0
- package/dist/standalone/{chunk-HX7IXD7I.js → chunk-6NJAHOGO.js} +1 -1
- package/dist/standalone/chunk-6SAAMM4S.js +1 -0
- package/dist/standalone/{chunk-IUYFXK4X.js → chunk-6ZPTNC34.js} +6 -6
- package/dist/standalone/chunk-74ASA4WU.js +1 -0
- package/dist/standalone/{chunk-6ST5ECQA.js → chunk-7PIHTTND.js} +1 -1
- package/dist/standalone/{chunk-GMR677FL.js → chunk-7SROZWKL.js} +1 -1
- package/dist/standalone/chunk-AECDJKXB.js +1 -0
- package/dist/standalone/{chunk-2PJNAWB3.js → chunk-AFKLFS74.js} +1 -1
- package/dist/standalone/chunk-AOAJGSYZ.js +2 -0
- package/dist/standalone/chunk-AOE75NAT.js +1 -0
- package/dist/standalone/{chunk-HFRJMPXJ.js → chunk-APRVSWBH.js} +27 -27
- package/dist/standalone/{chunk-LWE6NWQX.js → chunk-BELLXCN7.js} +1 -1
- package/dist/standalone/chunk-BORG7WUC.js +1 -0
- package/dist/standalone/{chunk-AVAC26HJ.js → chunk-BQK2C2Z4.js} +1 -1
- package/dist/standalone/chunk-BRHTM6FU.js +1 -0
- package/dist/standalone/{chunk-MWIKAR7F.js → chunk-BWEXJENB.js} +1 -1
- package/dist/standalone/chunk-C5E5PLJT.js +4 -0
- package/dist/standalone/chunk-C7E4I7JZ.js +1 -0
- package/dist/standalone/{chunk-QWGT25SE.js → chunk-CAOUXOL7.js} +1 -1
- package/dist/standalone/chunk-CEPMQS24.js +6 -0
- package/dist/standalone/chunk-CKTKI4IY.js +1 -0
- package/dist/standalone/{chunk-IC4L6G56.js → chunk-CN2AINNY.js} +1 -1
- package/dist/standalone/chunk-CP4ZFBVW.js +1 -0
- package/dist/standalone/chunk-CYX3OHJ3.js +1 -0
- package/dist/standalone/{chunk-7P7NURTD.js → chunk-D7DUQS2Y.js} +1 -1
- package/dist/standalone/{chunk-QBWRC5YX.js → chunk-DKSLOJDQ.js} +1 -1
- package/dist/standalone/chunk-DL3UOEWN.js +1 -0
- package/dist/standalone/chunk-DPNEFSEC.js +1 -0
- package/dist/standalone/{chunk-BGBLQ563.js → chunk-DUDQV6XJ.js} +1 -1
- package/dist/standalone/chunk-EDHW2EEG.js +1 -0
- package/dist/standalone/chunk-EYGF6TQS.js +1 -0
- package/dist/standalone/chunk-F7JOSNAT.js +1 -0
- package/dist/standalone/{chunk-7QOXFLZB.js → chunk-FBAZHG35.js} +1 -1
- package/dist/standalone/chunk-FLCK2WWQ.js +1 -0
- package/dist/standalone/chunk-FSWPREH3.js +1 -0
- package/dist/standalone/{chunk-ZCNMXKF2.js → chunk-GIRZD3UB.js} +2 -2
- package/dist/standalone/chunk-GZMBMNL3.js +6 -0
- package/dist/standalone/chunk-HPX3IM45.js +13 -0
- package/dist/standalone/{chunk-KUVMORDQ.js → chunk-INBA3473.js} +1 -1
- package/dist/standalone/{chunk-T6VMSOBB.js → chunk-INQICZYC.js} +1 -1
- package/dist/standalone/chunk-IWNVQHF7.js +1 -0
- package/dist/standalone/chunk-IWOZGUI2.js +1 -0
- package/dist/standalone/chunk-IYWVSMAY.js +1 -0
- package/dist/standalone/chunk-JURAVSE7.js +1 -0
- package/dist/standalone/chunk-JUWOEHDD.js +1 -0
- package/dist/standalone/{chunk-4UOFSGUS.js → chunk-JV7KTJPY.js} +1 -1
- package/dist/standalone/{chunk-XVD7HWY7.js → chunk-JVAYDDMK.js} +1 -1
- package/dist/standalone/chunk-KEKIGANB.js +1 -0
- package/dist/standalone/chunk-KFZ37KQP.js +1 -0
- package/dist/standalone/chunk-KQIHXYE6.js +1 -0
- package/dist/standalone/chunk-L4EZAHCD.js +1 -0
- package/dist/standalone/chunk-L7CJ5PGH.js +1 -0
- package/dist/standalone/{chunk-5MJ3G4DY.js → chunk-LT4XQDD2.js} +1 -1
- package/dist/standalone/chunk-M3NNNOD5.js +1 -0
- package/dist/standalone/chunk-MBEIKVJH.js +1 -0
- package/dist/standalone/chunk-MCLM2QJI.js +1 -0
- package/dist/standalone/chunk-METRMDIQ.js +1 -0
- package/dist/standalone/{chunk-OKQ3NJOW.js → chunk-MGC6PRMV.js} +1 -1
- package/dist/standalone/chunk-MOUI44OT.js +1 -0
- package/dist/standalone/{chunk-DRR3KV5L.js → chunk-MSFUDXBA.js} +1 -1
- package/dist/standalone/chunk-NIX2QSSN.js +1 -0
- package/dist/standalone/chunk-NXXGISFB.js +1 -0
- package/dist/standalone/{chunk-SBZXUGZ7.js → chunk-OE4KGVJW.js} +4 -4
- package/dist/standalone/chunk-OG57FC7W.js +1 -0
- package/dist/standalone/chunk-OLQWBGKT.js +1 -0
- package/dist/standalone/{chunk-F2I4JLFR.js → chunk-OOBJFXYB.js} +1 -1
- package/dist/standalone/chunk-P52BY657.js +1 -0
- package/dist/standalone/chunk-PHHMPYEP.js +1 -0
- package/dist/standalone/{chunk-6KWKX3RH.js → chunk-PJDKRUWT.js} +1 -1
- package/dist/standalone/chunk-PZ4QDWTI.js +1 -0
- package/dist/standalone/chunk-QZ55OWAB.js +4 -0
- package/dist/standalone/chunk-R5ZTCHCE.js +1 -0
- package/dist/standalone/chunk-RBUVNO22.js +1 -0
- package/dist/standalone/{chunk-XBDKZZ67.js → chunk-RCZTUWG3.js} +1 -1
- package/dist/standalone/chunk-S77D4SHR.js +1 -0
- package/dist/standalone/chunk-SL5R7WBN.js +1 -0
- package/dist/standalone/chunk-SMKRXJUC.js +1 -0
- package/dist/standalone/{chunk-THIXMMZD.js → chunk-SPDZUX4P.js} +1 -1
- package/dist/standalone/chunk-T2LDA6WP.js +1 -0
- package/dist/standalone/{chunk-5UY7MLRC.js → chunk-T6HLABZW.js} +1 -1
- package/dist/standalone/{chunk-BDHAGUAY.js → chunk-TBXK3FKP.js} +4 -4
- package/dist/standalone/{chunk-7QIFDWQV.js → chunk-TFMQSCGC.js} +1 -1
- package/dist/standalone/chunk-TLPWZ5NI.js +3 -0
- package/dist/standalone/chunk-TNKECJW4.js +1 -0
- package/dist/standalone/{chunk-XQCVZAGU.js → chunk-UANVABQG.js} +1 -1
- package/dist/standalone/chunk-UIF57LBO.js +1 -0
- package/dist/standalone/chunk-V6QPVFDL.js +1 -0
- package/dist/standalone/chunk-VNTEQQPP.js +1 -0
- package/dist/standalone/chunk-VR3UJA7B.js +1 -0
- package/dist/standalone/{chunk-5DVJR52Z.js → chunk-VYW2PAWC.js} +3 -3
- package/dist/standalone/chunk-VZCS5GXZ.js +1 -0
- package/dist/standalone/{chunk-XYV7TMYI.js → chunk-WHRG6S5P.js} +1 -1
- package/dist/standalone/{chunk-CKG2DTZ2.js → chunk-WIG3HCUJ.js} +1 -1
- package/dist/standalone/chunk-WUW4ZHRL.js +1 -0
- package/dist/standalone/chunk-X6Q5DWLZ.js +1 -0
- package/dist/standalone/{chunk-Z2IF3TEX.js → chunk-XGIG4EDG.js} +4 -4
- package/dist/standalone/chunk-XJSWM47N.js +1 -0
- package/dist/standalone/chunk-XQS7KSHL.js +1 -0
- package/dist/standalone/chunk-YS7HEZC2.js +1 -0
- package/dist/standalone/chunk-YUWMB6EV.js +1 -0
- package/dist/standalone/{chunk-TMGHRD6W.js → chunk-ZPGNTTQ3.js} +1 -1
- package/dist/standalone/chunk-ZQLIKKIY.js +1 -0
- package/dist/standalone/chunk-ZSOLGJFC.js +1 -0
- package/dist/standalone/studio.js +6 -6
- package/package.json +9 -9
- package/dist/packem_shared/ApiDocsPanel-Cu_QmzO0.js +0 -2
- package/dist/packem_shared/ApiReferencePanel-DuIU1P8B.js +0 -1
- package/dist/packem_shared/CommandPalette-mPR8-vIm.js +0 -1
- package/dist/packem_shared/ConfirmButton-CTL3f3kr.js +0 -1
- package/dist/packem_shared/ConnectionBadge-DOk0CQWo.js +0 -1
- package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js +0 -1
- package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js +0 -1
- package/dist/packem_shared/DEFAULT_LOCALE-BZ4NojpD.js +0 -1
- package/dist/packem_shared/DataBrowser-CPNKM0KZ.js +0 -1
- package/dist/packem_shared/DataFilters-B26ZeqBZ.js +0 -1
- package/dist/packem_shared/ErrorBoundary-DvzYskH7.js +0 -1
- package/dist/packem_shared/GlobalDataBrowser-BSmyOO0n.js +0 -1
- package/dist/packem_shared/HomePanel-BUO6BcYQ.js +0 -1
- package/dist/packem_shared/MigrationsPanel-BAnvY79E.js +0 -1
- package/dist/packem_shared/OpenRpcReferencePanel-DXeffPFr.js +0 -1
- package/dist/packem_shared/ScheduledJobs-pHVlh2xU.js +0 -1
- package/dist/packem_shared/ShardInput-BVn2iCU0.js +0 -1
- package/dist/packem_shared/Studio-CD66AkL1.js +0 -1
- package/dist/packem_shared/StudioApp-0Vaayv2I.js +0 -1
- package/dist/packem_shared/StudioI18nProvider-CZ5h4nrV.js +0 -1
- package/dist/packem_shared/advisor-view-CGcwvlMo.js +0 -1
- package/dist/packem_shared/aggregateMetrics-BNfajLa2.js +0 -1
- package/dist/packem_shared/alert-CVcOFuDR.js +0 -1
- package/dist/packem_shared/bar-chart-B8oDHgnw.js +0 -6
- package/dist/packem_shared/browser-storage-xjTyMKY0.js +0 -1
- package/dist/packem_shared/card-BMKx5UdA.js +0 -1
- package/dist/packem_shared/cf-links-Dmg86v1D.js +0 -1
- package/dist/packem_shared/data-grid-Ci4-tZkk.js +0 -1
- package/dist/packem_shared/data-view-params-ClrV7XgF.js +0 -1
- package/dist/packem_shared/dropdown-menu-BgS2zw1i.js +0 -2
- package/dist/packem_shared/empty-state-Cg7t_8qu.js +0 -1
- package/dist/packem_shared/error-alert-_2q2VtVG.js +0 -1
- package/dist/packem_shared/grid-features-Y2YSjhCf.js +0 -6
- package/dist/packem_shared/home-panel-Ir3YHReO.js +0 -3
- package/dist/packem_shared/input-JHu63lTv.js +0 -1
- package/dist/packem_shared/internal-zkEvTqy8.js +0 -2
- package/dist/packem_shared/label-6uP1obNF.js +0 -1
- package/dist/packem_shared/live-status-CmuRLFKf.js +0 -1
- package/dist/packem_shared/log-line-BDI826X-.js +0 -1
- package/dist/packem_shared/modal-shell-CUwwWC2o.js +0 -1
- package/dist/packem_shared/operation-console-provider-BMJNtiyB.js +0 -1
- package/dist/packem_shared/recording-client-DtUxwVNY.js +0 -1
- package/dist/packem_shared/reference-view-DncEStdm.js +0 -12
- package/dist/packem_shared/result-chart-0VgP_3FP.js +0 -1
- package/dist/packem_shared/schema-diagram-GVgnLWTf.js +0 -2
- package/dist/packem_shared/scroll-area-DTEq6Jec.js +0 -2
- package/dist/packem_shared/select-BssZMiFY.js +0 -2
- package/dist/packem_shared/shard-history-DMEW5VBE.js +0 -1
- package/dist/packem_shared/skeleton-C1wQ9M5t.js +0 -1
- package/dist/packem_shared/sparkline-BNvxiJj_.js +0 -1
- package/dist/packem_shared/stat-card-BGJdhfm6.js +0 -1
- package/dist/packem_shared/studio-CUXq5VSB.js +0 -2
- package/dist/packem_shared/table-DZAB8cs3.js +0 -2
- package/dist/packem_shared/table-list-sidebar-fz0m_4I4.js +0 -1
- package/dist/packem_shared/textarea-Bu2-jKAs.js +0 -1
- package/dist/packem_shared/use-admin-query-CnnyWJXM.js +0 -1
- package/dist/packem_shared/use-async-submit-B32whHJO.js +0 -1
- package/dist/packem_shared/use-auth-config-0EnNCdLu.js +0 -1
- package/dist/packem_shared/use-open-trace-CniEgUdp.js +0 -1
- package/dist/packem_shared/use-shard-key-B2JtNa5m.js +0 -1
- package/dist/packem_shared/use-sql-assistant-Dtw55kKM.js +0 -1
- package/dist/packem_shared/useDebounced-CU-uftxO.js +0 -1
- package/dist/packem_shared/virtual-rect-1o1veP7R.js +0 -1
- package/dist/packem_shared/wire-codec-DkrdsFXO.js +0 -1
- package/dist/standalone/chunk-25IDU7IW.js +0 -1
- package/dist/standalone/chunk-2OUPA2WJ.js +0 -1
- package/dist/standalone/chunk-2QSHLBCO.js +0 -1
- package/dist/standalone/chunk-3C3CG7ZK.js +0 -1
- package/dist/standalone/chunk-3CWGJYBB.js +0 -1
- package/dist/standalone/chunk-3DH35OZ5.js +0 -1
- package/dist/standalone/chunk-3SCGCJYS.js +0 -1
- package/dist/standalone/chunk-3XIESWL4.js +0 -1
- package/dist/standalone/chunk-54MMVNPT.js +0 -1
- package/dist/standalone/chunk-5RIKPDDA.js +0 -1
- package/dist/standalone/chunk-5Y3QLNWX.js +0 -1
- package/dist/standalone/chunk-63D4ABMW.js +0 -1
- package/dist/standalone/chunk-6QBOXH2I.js +0 -1
- package/dist/standalone/chunk-7CZI2HNL.js +0 -1
- package/dist/standalone/chunk-7T7UOTYK.js +0 -1
- package/dist/standalone/chunk-7UP7OQJG.js +0 -1
- package/dist/standalone/chunk-AXQU7ULF.js +0 -1
- package/dist/standalone/chunk-BCOT3QRZ.js +0 -1
- package/dist/standalone/chunk-BG5ELOW6.js +0 -1
- package/dist/standalone/chunk-BXJPPINU.js +0 -1
- package/dist/standalone/chunk-BZDIRP7L.js +0 -1
- package/dist/standalone/chunk-C3YACIEE.js +0 -1
- package/dist/standalone/chunk-CAOA5AM4.js +0 -1
- package/dist/standalone/chunk-CFPZYHPY.js +0 -2
- package/dist/standalone/chunk-CZZWYUTR.js +0 -1
- package/dist/standalone/chunk-DJZYD5I5.js +0 -1
- package/dist/standalone/chunk-DNEIBTLL.js +0 -1
- package/dist/standalone/chunk-EF5J67J3.js +0 -1
- package/dist/standalone/chunk-EJWTF334.js +0 -1
- package/dist/standalone/chunk-EP4JQH5X.js +0 -1
- package/dist/standalone/chunk-ESVP44Y3.js +0 -1
- package/dist/standalone/chunk-EXL35M7T.js +0 -1
- package/dist/standalone/chunk-F3J6ER2V.js +0 -13
- package/dist/standalone/chunk-FURI47Z2.js +0 -1
- package/dist/standalone/chunk-FZ2N52BV.js +0 -1
- package/dist/standalone/chunk-GG6PIGQO.js +0 -1
- package/dist/standalone/chunk-GRL5MG3Z.js +0 -1
- package/dist/standalone/chunk-HBSEWNIR.js +0 -1
- package/dist/standalone/chunk-HLENOQDN.js +0 -1
- package/dist/standalone/chunk-HPFLBYRI.js +0 -1
- package/dist/standalone/chunk-HUF7RMS3.js +0 -1
- package/dist/standalone/chunk-I6A5C46N.js +0 -1
- package/dist/standalone/chunk-IBPWTHHW.js +0 -1
- package/dist/standalone/chunk-IGCNMZSB.js +0 -1
- package/dist/standalone/chunk-IVFHIQOT.js +0 -1
- package/dist/standalone/chunk-KZRWBSYQ.js +0 -1
- package/dist/standalone/chunk-LEDWUPXM.js +0 -1
- package/dist/standalone/chunk-MLT5MMMY.js +0 -1
- package/dist/standalone/chunk-OENUM3OW.js +0 -1
- package/dist/standalone/chunk-QLQADHFE.js +0 -1
- package/dist/standalone/chunk-RA5DW5MU.js +0 -1
- package/dist/standalone/chunk-RFSPHFKM.js +0 -1
- package/dist/standalone/chunk-RMN2JN4S.js +0 -1
- package/dist/standalone/chunk-S23KCFVU.js +0 -1
- package/dist/standalone/chunk-S4665UG5.js +0 -4
- package/dist/standalone/chunk-SD4BERSA.js +0 -1
- package/dist/standalone/chunk-SFDOII3B.js +0 -1
- package/dist/standalone/chunk-SMIESS7P.js +0 -1
- package/dist/standalone/chunk-SY6ANTKE.js +0 -1
- package/dist/standalone/chunk-TCV7MMYR.js +0 -1
- package/dist/standalone/chunk-UFESYXCE.js +0 -6
- package/dist/standalone/chunk-UKI2ZYB2.js +0 -1
- package/dist/standalone/chunk-UTK6JUTY.js +0 -1
- package/dist/standalone/chunk-V53KNYRN.js +0 -1
- package/dist/standalone/chunk-VIJLMIC3.js +0 -1
- package/dist/standalone/chunk-VOY5EALQ.js +0 -1
- package/dist/standalone/chunk-VR3OBMGZ.js +0 -1
- package/dist/standalone/chunk-WJCKVELA.js +0 -1
- package/dist/standalone/chunk-WJQLNYGX.js +0 -1
- package/dist/standalone/chunk-WPK2Q33V.js +0 -6
- package/dist/standalone/chunk-WQH3LT2P.js +0 -1
- package/dist/standalone/chunk-WZ65AZKA.js +0 -1
- package/dist/standalone/chunk-XEGWCG5S.js +0 -1
- package/dist/standalone/chunk-XFGE43TZ.js +0 -1
- package/dist/standalone/chunk-XNSCEAHM.js +0 -4
- package/dist/standalone/chunk-XXQUMVWH.js +0 -1
- package/dist/standalone/chunk-Y32QIKBS.js +0 -1
- package/dist/standalone/chunk-YJ25NVR2.js +0 -3
- package/dist/standalone/chunk-ZJGP6EKR.js +0 -1
- /package/dist/standalone/{chunk-XF2B7P5A.js → chunk-W2JBKQNU.js} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{c as
|
|
2
|
-
${l}`})),
|
|
3
|
-
`;)
|
|
4
|
-
`,e);return n===-1?l.length:n}if(t==="/"&&l[e+1]==="*"){const n=l.indexOf("*/",e+2);return n===-1?l.length:n+2}return-1},Mt=l=>{let e="",t=0;for(;t<l.length;){const n=Ot(l,t);n===-1?(e+=l.slice(t,t+1),t+=1):(e+=l.slice(t,n).replaceAll(_t," "),t=n)}return e},Dt=l=>{const e=new Set;for(const t of l.matchAll(Et))e.add((t[1]??"").toLowerCase());return e},At=(l,e)=>{const t=new Map;for(const n of l.matchAll(It)){const r=(n[1]??"").toLowerCase(),o=(n[2]??"").toLowerCase();e.has(r)&&(t.set(r,r),o!==""&&!Lt.has(o)&&t.set(o,r))}return t},Ke=(l,e)=>{const t=Mt(l),n=new Set(e.map(r=>r.toLowerCase()));return{ctes:Dt(t),masked:t,targets:At(t,n)}},Bt=/^(?:__lunora|sqlite_)/iu,zt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Ht=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Pt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Ft=(l,e,t)=>{const n=[];for(const r of l.matchAll(zt)){const o=r[1]??"",s=o.toLowerCase();!e.has(s)&&!t.has(s)&&!Pt.has(s)&&!Bt.test(o)&&n.push({length:o.length,message:`unknown table \`${o}\``,offset:r.index+r[0].length-o.length,severity:"error",source:"schema"})}return n},Qt=(l,e,t)=>{const n=[],r=new Map;for(const[o,s]of Object.entries(e.columns))r.set(o.toLowerCase(),new Set(s.map(d=>d.toLowerCase())));for(const o of l.matchAll(Ht)){const s=(o[1]??"").toLowerCase(),d=o[2]??"",a=t.get(s),i=a===void 0?void 0:r.get(a);i!==void 0&&!i.has(d.toLowerCase())&&n.push({length:d.length,message:`\`${a??""}\` has no column \`${d}\``,offset:o.index+o[0].length-d.length,severity:"error",source:"schema"})}return n},jt=(l,e)=>{if(l.trim()==="")return[];const t=Rt(l);if(t!==void 0)return t.code==="SQL_EMPTY"?[]:[{length:t.length,message:t.message,offset:t.offset,severity:"error",source:"gate"}];const{ctes:n,masked:r,targets:o}=Ke(l,e.tables),s=new Set(e.tables.map(d=>d.toLowerCase()));return[...Ft(r,s,n),...Qt(r,e,o)]},Wt=Te(qe.lintSql),Kt=600,Ut=(l,e,t)=>{const n=Oe(),[r,o]=re([]),s=Be(()=>jt(l,e),[l,e]),d=ot(l,Kt),a=s.some(h=>h.source==="gate")||d.trim()==="",i=Ze(async h=>{try{const p=await n.query(Wt,{sql:d},ke(t));h.cancelled||o(p.diagnostics??[])}catch{h.cancelled||o([])}},[n,d,t]);$e(()=>{if(a){o([]);return}const h={cancelled:!1};return de(i(h)),()=>{h.cancelled=!0}},[i,a]);const f=d===l;return Be(()=>f?[...s,...r]:s,[s,r,f])},Se=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"],Jt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Gt=/[\w$]/,Ue=l=>l!==void 0&&Gt.test(l),Ye=l=>{let e=l.length;for(;e>0&&Ue(l[e-1]);)e-=1;return l.slice(e)},Je=(l,e)=>{let t=e;for(;t>0&&Ue(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},Pe=(l,e)=>{const t=l.slice(0,e).trimEnd();return t.endsWith(".")||Jt.has(Ye(t).toUpperCase())},Vt=(l,e,t)=>{const n=l.slice(0,e);if(!n.endsWith("."))return;const r=Ye(n.slice(0,-1));if(r!=="")return Ke(l,t).targets.get(r.toLowerCase())??r},Me=(l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),Fe=(l,e,t,n)=>{const r=[];for(const o of l)if(Me(o,e)&&(r.push(n(o)),r.length>=t))break;return r},Xt=(l,e,t)=>{const n=new Map;for(const[r,o]of Object.entries(l.columns))for(const s of o)if(Me(s,e)&&!n.has(s)&&(n.set(s,r),n.size>=t))return[...n].map(([d,a])=>({detail:a,kind:"column",label:d}));return[...n].map(([r,o])=>({detail:o,kind:"column",label:r}))},Zt=(l,e,t)=>{const n=Je(l,e),r=Vt(l,n.start,t.tables);if(r!==void 0){const a=t.columns[r]??t.columns[r.toLowerCase()]??[];return Fe(a,n.text,Se,i=>({detail:r,kind:"column",label:i}))}if(n.text===""&&!Pe(l,n.start))return[];const o=Fe(t.tables,n.text,Se,a=>({kind:"table",label:a})),s=Xt(t,n.text,Se),d=Yt.flatMap(a=>n.text!==""&&Me(a,n.text)&&a.toLowerCase()!==n.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(Pe(l,n.start)?[...s,...o,...d]:[...o,...s,...d]).slice(0,Se)},en=(l,e,t)=>{const n=Je(l,e),r=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:r}},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 t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:r}=n;r.position="absolute",r.visibility="hidden",r.whiteSpace="pre-wrap",r.overflowWrap="break-word";for(const a of tn)r[a]=t[a];n.textContent=l.value.slice(0,Math.max(0,e));const o=globalThis.document.createElement("span");o.textContent=l.value.slice(Math.max(0,e))||".",n.append(o),globalThis.document.body.append(n);const s=o.offsetLeft-l.scrollLeft,d=o.offsetTop-l.scrollTop;return n.remove(),{left:s,top:d}},on=(l,e,t)=>{const n=K(16),[r,o]=re(null);let s;n[0]!==l||n[1]!==e?(s=(y,b)=>{const m=Zt(y,b,l);if(m.length===0){o(null);return}const w=e.current,{left:N,top:S}=w===null?{left:0,top:0}:nn(w,b);o(k=>k!==null&&k.active===0&&k.left===N&&k.top===S&&k.suggestions.length===m.length&&k.suggestions.every((R,T)=>{const I=m.at(T);return R.kind===I?.kind&&R.label===I.label&&R.detail===I.detail})?k:{active:0,left:N,suggestions:m,top:S})},n[0]=l,n[1]=e,n[2]=s):s=n[2];const d=s;let a;n[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{o(null)},n[3]=a):a=n[3];const i=a;let f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=y=>{o(b=>{if(b===null)return b;const m=b.suggestions.length,w=(b.active+y+m)%m;return{...b,active:w}})},n[4]=f):f=n[4];const h=f;let p;n[5]!==t||n[6]!==r||n[7]!==e?(p=y=>{const b=e.current;if(r===null||b===null)return!1;const m=r.suggestions[y??r.active];if(m===void 0)return!1;const w=en(b.value,b.selectionStart,m);return t(w.value),o(null),requestAnimationFrame(()=>{const N=e.current;N!==null&&(N.focus(),N.setSelectionRange(w.caret,w.caret))}),!0},n[5]=t,n[6]=r,n[7]=e,n[8]=p):p=n[8];const x=p;let c;n[9]!==x?(c=()=>x(),n[9]=x,n[10]=c):c=n[10];const g=c;let v;return n[11]!==g||n[12]!==x||n[13]!==d||n[14]!==r?(v={close:i,commit:g,commitAt:x,move:h,refresh:d,state:r},n[11]=g,n[12]=x,n[13]=d,n[14]=r,n[15]=v):v=n[15],v},rn={column:"column",keyword:"keyword",table:"table"},ln=20,sn=l=>{const e=K(17),{listboxId:t,onPick:n,state:r}=l,o=le();let s;e[0]!==r?(s=r===null?void 0:{left:r.left,top:r.top+ln},e[0]=r,e[1]=s):s=e[1];const d=s;if(r===null)return null;let a;if(e[2]!==t||e[3]!==n||e[4]!==r.active||e[5]!==r.suggestions||e[6]!==o){let f;e[8]!==t||e[9]!==n||e[10]!==r.active||e[11]!==o?(f=(h,p)=>A("li",{"aria-selected":p===r.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",p===r.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${p.toString()}`,onMouseDown:x=>{x.preventDefault(),n(p)},role:"option",children:[u("span",{className:"truncate font-mono",children:h.label}),h.detail!==void 0&&u("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:h.detail}),u("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:o(rn[h.kind])})]},`${h.kind}:${h.label}`),e[8]=t,e[9]=n,e[10]=r.active,e[11]=o,e[12]=f):f=e[12],a=r.suggestions.map(f),e[2]=t,e[3]=n,e[4]=r.active,e[5]=r.suggestions,e[6]=o,e[7]=a}else a=e[7];let i;return e[13]!==t||e[14]!==d||e[15]!==a?(i=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:t,role:"listbox",style:d,children:a}),e[13]=t,e[14]=d,e[15]=a,e[16]=i):i=e[16],i},an=Te(qe.listTables),cn=Te(qe.readTablePage),dn=l=>{const e=K(16),t=Oe();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];const[r,o]=re(n);let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s={},e[1]=s):s=e[1];const[d,a]=re(s);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[2]=i):i=e[2];const f=ye(i);let h,p;e[3]!==t||e[4]!==l?(h=()=>{const b={cancelled:!1};return de((async()=>{try{const m=await t.query(an,{},ke(l));b.cancelled||(o(m.map(mn)),a({}),f.current=new Set)}catch{b.cancelled||(o([]),a({}),f.current=new Set)}})()),()=>{b.cancelled=!0}},p=[t,l],e[3]=t,e[4]=l,e[5]=h,e[6]=p):(h=e[5],p=e[6]),$e(h,p);let x;e[7]!==t||e[8]!==l?(x=b=>{f.current.has(b)||(f.current.add(b),de((async()=>{try{const m=await t.query(cn,{limit:1,offset:0,table:b},ke(l));a(w=>({...w,[b]:m.columns}))}catch{f.current.delete(b)}})()))},e[7]=t,e[8]=l,e[9]=x):x=e[9];const c=x;let g;e[10]!==d||e[11]!==r?(g={columns:d,tables:r},e[10]=d,e[11]=r,e[12]=g):g=e[12];const v=g;let y;return e[13]!==c||e[14]!==v?(y={probe:c,schema:v},e[13]=c,e[14]=v,e[15]=y):y=e[15],y},Le=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,un=l=>{const e=new Set;Le.lastIndex=0;let t=Le.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=Le.exec(l);return[...e]};function mn(l){return l.name}const fn=l=>{const e=K(34),{onSubmit:t,probe:n,schema:r,setDraft:o}=l,s=et(),d=ye(null),a=ye(null),i=ye(null),f=on(r,i,o),{close:h,commit:p,commitAt:x,move:c,refresh:g,state:v}=f;let y;e[0]!==x?(y=q=>{x(q)},e[0]=x,e[1]=y):y=e[1];const b=y;let m;e[2]!==g?(m=()=>{const q=i.current;q!==null&&q===document.activeElement&&g(q.value,q.selectionStart)},e[2]=g,e[3]=m):m=e[3];let w;e[4]!==g||e[5]!==r?(w=[g,r],e[4]=g,e[5]=r,e[6]=w):w=e[6],$e(m,w);let N;e[7]!==n||e[8]!==g||e[9]!==o?(N=q=>{const{selectionStart:B,value:F}=q.target;o(F);for(const P of un(F))n(P);g(F,B)},e[7]=n,e[8]=g,e[9]=o,e[10]=N):N=e[10];const S=N;let k;e[11]!==g?(k=q=>{const B=q.currentTarget;g(B.value,B.selectionStart)},e[11]=g,e[12]=k):k=e[12];const R=k;let T;e[13]!==v||e[14]!==h||e[15]!==p||e[16]!==c||e[17]!==t?(T=q=>{if(v!==null){if(q.key==="ArrowDown"){q.preventDefault(),c(1);return}if(q.key==="ArrowUp"){q.preventDefault(),c(-1);return}if(q.key==="Escape"){q.preventDefault(),h();return}if((q.key==="Enter"||q.key==="Tab")&&!q.metaKey&&!q.ctrlKey&&p()){q.preventDefault();return}}(q.metaKey||q.ctrlKey)&&q.key==="Enter"&&(q.preventDefault(),t())},e[13]=v,e[14]=h,e[15]=p,e[16]=c,e[17]=t,e[18]=T):T=e[18];const I=T;let C;e[19]!==h?(C=()=>{requestAnimationFrame(()=>{h()})},e[19]=h,e[20]=C):C=e[20];const L=C;let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=q=>{const{scrollLeft:B,scrollTop:F}=q.currentTarget;d.current!==null&&(d.current.scrollTop=F),a.current!==null&&(a.current.scrollTop=F,a.current.scrollLeft=B)},e[21]=_):_=e[21];const O=_;let $;e[22]===Symbol.for("react.memo_cache_sentinel")?($=q=>{const B=i.current;B===null||q.offset===void 0||(B.focus(),B.setSelectionRange(q.offset,q.offset+(q.length??0)))},e[22]=$):$=e[22];const E=$;let M;e[23]!==S||e[24]!==L||e[25]!==I||e[26]!==R?(M={onBlur:L,onChange:S,onKeyDown:I,onScroll:O,onSelect:R},e[23]=S,e[24]=L,e[25]=I,e[26]=R,e[27]=M):M=e[27];let D;return e[28]!==v||e[29]!==h||e[30]!==s||e[31]!==b||e[32]!==M?(D={autocompleteState:v,closeAutocomplete:h,handlers:M,listboxId:s,onPickSuggestion:b,editorRef:i,gutterRef:d,overlayRef:a,revealDiagnostic:E},e[28]=v,e[29]=h,e[30]=s,e[31]=b,e[32]=M,e[33]=D):D=e[33],D},hn="lunora-studio-sql-tabs",pn="lunora-studio-sql-active-tab",De=12,ve=(l="",e="")=>({activeId:null,id:je("tab"),name:e,sql:l}),bn=()=>We(pn,""),gn=l=>{const e=K(16),[t,n]=_e(hn),[r,o]=bn(),[s]=re(l);let d,a;e[0]!==s||e[1]!==n||e[2]!==t.length?(d=()=>{t.length===0&&n([s])},a=[s,n,t.length],e[0]=s,e[1]=n,e[2]=t.length,e[3]=d,e[4]=a):(d=e[3],a=e[4]),$e(d,a);let i;e[5]!==s||e[6]!==t?(i=t.length===0?[s]:t,e[5]=s,e[6]=t,e[7]=i):i=e[7];const f=i;let h;e[8]!==r||e[9]!==f?(h=f.some(c=>c.id===r)?r:f[0]?.id??"",e[8]=r,e[9]=f,e[10]=h):h=e[10];const p=h;let x;return e[11]!==p||e[12]!==o||e[13]!==n||e[14]!==f?(x={activeId:p,setActiveId:o,setTabs:n,tabs:f},e[11]=p,e[12]=o,e[13]=n,e[14]=f,e[15]=x):x=e[15],x},Ge=l=>l.activeId===null&&l.sql.trim()!=="",xn=(l,e)=>[...l,e].slice(-De),vn=(l,e,t)=>{const n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};const r=l.filter(o=>o.id!==e);if(r.length===0){const o=t();return{activeId:o.id,tabs:[o]}}return{activeId:r[Math.min(n,r.length-1)].id,tabs:r}},yn=(l,e)=>{const t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},wn=(l,e,t)=>{const n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:t,tabs:[...l]};const r=l.slice(0,n+1);return{activeId:r.some(o=>o.id===t)?t:e,tabs:r}},Sn=l=>{const e=l();return{activeId:e.id,tabs:[e]}},Nn=(l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){const n=e.findIndex(r=>r.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},Qe={error:null,pane:"results",result:null,running:!1},kn=l=>{const e=K(66),{activeId:t,setActiveId:n,setTabs:r,tabs:o}=gn(l);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const[d,a]=re(s),[i,f]=re(null),[h,p]=re(null);let x;e[1]!==t||e[2]!==o?(x=o.find(H=>H.id===t)??o[0]??ve(),e[1]=t,e[2]=o,e[3]=x):x=e[3];const c=x,g=d[c.id]??Qe;let v;e[4]!==c.id||e[5]!==r?(v=H=>{r(j=>j.map(U=>U.id===c.id?{...U,...H}:U))},e[4]=c.id,e[5]=r,e[6]=v):v=e[6];const y=v;let b;e[7]!==c.id?(b=H=>{a(j=>{const U=j[c.id]??Qe;return{...j,[c.id]:{...U,...H}}})},e[7]=c.id,e[8]=b):b=e[8];const m=b;let w;e[9]!==n||e[10]!==r||e[11]!==o.length?(w=()=>{if(o.length>=De)return;const H=ve();r(j=>xn(j,H)),n(H.id)},e[9]=n,e[10]=r,e[11]=o.length,e[12]=w):w=e[12];const N=w;let S;e[13]!==n||e[14]!==r?(S=H=>{f(null),p(null),r(H.tabs),n(H.activeId);const j=new Set(H.tabs.map(Cn));a(U=>Object.fromEntries(Object.entries(U).filter(ae=>{const[xe]=ae;return j.has(xe)})))},e[13]=n,e[14]=r,e[15]=S):S=e[15];const k=S;let R;e[16]!==k||e[17]!==o?(R=H=>{k(vn(o,H,ve))},e[16]=k,e[17]=o,e[18]=R):R=e[18];const T=R;let I;e[19]!==t||e[20]!==k||e[21]!==o?(I=(H,j)=>{k(H==="others"?yn(o,j):H==="right"?wn(o,j,t):Sn(ve))},e[19]=t,e[20]=k,e[21]=o,e[22]=I):I=e[22];const C=I;let L;e[23]!==C||e[24]!==i||e[25]!==o?(L=H=>{i!==null&&(Nn(H,o,i.id).some($n)?p(H):C(H,i.id))},e[23]=C,e[24]=i,e[25]=o,e[26]=L):L=e[26];const _=L;let O;e[27]===Symbol.for("react.memo_cache_sentinel")?(O=(H,j)=>{j.preventDefault(),p(null),f({id:H,x:j.clientX,y:j.clientY})},e[27]=O):O=e[27];const $=O;let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{f(null),p(null)},e[28]=E):E=e[28];const M=E;let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=H=>{H.preventDefault(),f(null),p(null)},e[29]=D):D=e[29];const q=D;let B;e[30]!==_?(B=()=>{_("others")},e[30]=_,e[31]=B):B=e[31];const F=B;let P;e[32]!==_?(P=()=>{_("right")},e[32]=_,e[33]=P):P=e[33];const W=P;let Q;e[34]!==_?(Q=()=>{_("all")},e[34]=_,e[35]=Q):Q=e[35];const Y=Q;let J;e[36]!==C||e[37]!==h||e[38]!==i?(J=()=>{i!==null&&h!==null&&C(h,i.id),p(null)},e[36]=C,e[37]=h,e[38]=i,e[39]=J):J=e[39];const z=J;let G;e[40]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{p(null)},e[40]=G):G=e[40];const ne=G;let V;e[41]!==i?(V=i===null?void 0:{left:i.x,top:i.y},e[41]=i,e[42]=V):V=e[42];const X=V;let Z;e[43]!==r?(Z=H=>{r(j=>j.map(U=>U.activeId===H?{...U,activeId:null}:U))},e[43]=r,e[44]=Z):Z=e[44];const ee=Z;let te;e[45]!==r?(te=(H,j)=>{r(U=>U.map(ae=>ae.id===H?{...ae,name:j}:ae))},e[45]=r,e[46]=te):te=e[46];const oe=te;let ie;return e[47]!==c||e[48]!==t||e[49]!==N||e[50]!==T||e[51]!==z||e[52]!==Y||e[53]!==F||e[54]!==W||e[55]!==g||e[56]!==m||e[57]!==y||e[58]!==h||e[59]!==oe||e[60]!==n||e[61]!==i||e[62]!==X||e[63]!==o||e[64]!==ee?(ie={activeTab:c,activeTabId:t,addEditorTab:N,cancelBulk:ne,closeEditorTab:T,closeTabMenu:M,confirmBulk:z,menuStyle:X,onBackdropContextMenu:q,onCloseAll:Y,onCloseOthers:F,onCloseToRight:W,openTabMenu:$,output:g,patchActiveOutput:m,patchActiveTab:y,pendingBulk:h,renameTab:oe,setActiveTabId:n,tabMenu:i,tabs:o,unlinkQuery:ee},e[47]=c,e[48]=t,e[49]=N,e[50]=T,e[51]=z,e[52]=Y,e[53]=F,e[54]=W,e[55]=g,e[56]=m,e[57]=y,e[58]=h,e[59]=oe,e[60]=n,e[61]=i,e[62]=X,e[63]=o,e[64]=ee,e[65]=ie):ie=e[65],ie};function Cn(l){return l.id}function $n(l){return Ge(l)}const qn="lunora-studio-sql-queries",Tn="lunora-studio-sql-history",Rn=25,In=l=>{const e=K(33),{loadIntoActiveTab:t,unlinkQuery:n}=l,r=le(),[o,s]=_e(qn),[d,a]=_e(Tn),[i,f]=re(""),h=ye(null);let p;e[0]!==a?(p=$=>{a(E=>E[0]?.sql===$?E:[{at:Date.now(),sql:$},...E.filter(M=>M.sql!==$)].slice(0,Rn))},e[0]=a,e[1]=p):p=e[1];const x=p;let c;e[2]!==t||e[3]!==s||e[4]!==r?(c=()=>{const $={id:je("q"),name:r("Untitled query"),sql:""};s(E=>[$,...E]),t("",$.id)},e[2]=t,e[3]=s,e[4]=r,e[5]=c):c=e[5];const g=c;let v;e[6]!==t||e[7]!==o?(v=$=>{const E=o.find(M=>M.id===$);E!==void 0&&(t(E.sql,$),h.current?.querySelector(`[data-testid="sql-query-${$}"]`)?.scrollIntoView({block:"nearest"}))},e[6]=t,e[7]=o,e[8]=v):v=e[8];const y=v;let b;e[9]!==s||e[10]!==n?(b=$=>{s(E=>E.filter(M=>M.id!==$)),n($)},e[9]=s,e[10]=n,e[11]=b):b=e[11];const m=b;let w;e[12]!==t?(w=$=>{t($.currentTarget.dataset.sql??"",null)},e[12]=t,e[13]=w):w=e[13];const N=w;let S;e[14]!==t?(S=$=>{t($.currentTarget.dataset.sql??"",null)},e[14]=t,e[15]=S):S=e[15];const k=S;let R;e[16]!==a?(R=()=>{a([])},e[16]=a,e[17]=R):R=e[17];const T=R;let I;e[18]===Symbol.for("react.memo_cache_sentinel")?(I=$=>{f($.target.value)},e[18]=I):I=e[18];const C=I;let L;e[19]!==s?(L=($,E)=>{s(M=>M.map(D=>D.id===$?{...D,sql:E}:D))},e[19]=s,e[20]=L):L=e[20];const _=L;let O;return e[21]!==T||e[22]!==m||e[23]!==d||e[24]!==k||e[25]!==N||e[26]!==g||e[27]!==o||e[28]!==x||e[29]!==i||e[30]!==y||e[31]!==_?(O={clearHistory:T,deleteQuery:m,history:d,listRef:h,loadFromHistory:k,loadTemplate:N,newQuery:g,onSearchChange:C,queries:o,recordHistory:x,search:i,selectQuery:y,updateQuerySql:_},e[21]=T,e[22]=m,e[23]=d,e[24]=k,e[25]=N,e[26]=g,e[27]=o,e[28]=x,e[29]=i,e[30]=y,e[31]=_,e[32]=O):O=e[32],O},Ve="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",En=(l,e)=>{const t=[];for(const r of l){if(r.offset===void 0||r.length===void 0||r.length<=0)continue;const o=Math.max(0,Math.min(r.offset,e)),s=Math.max(o,Math.min(r.offset+r.length,e));o!==s&&t.push({end:s,severity:r.severity,start:o})}t.sort((r,o)=>r.start-o.start);const n=[];for(const r of t)r.start>=(n.at(-1)?.end??0)&&n.push(r);return n},Ln=l=>l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached.",_n=l=>{const e=K(51),{assistant:t,failed:n,onGenerated:r}=l,o=le(),[s,d]=re("");if(t.unavailable)return null;let a;e[0]!==t?(a=t.pending("sql"),e[0]=t,e[1]=a):a=e[1];const i=a;let f;if(e[2]!==t||e[3]!==n||e[4]!==r||e[5]!==i||e[6]!==s||e[7]!==o){const h=t.reason("sql");let p;e[9]!==t||e[10]!==n||e[11]!==r||e[12]!==s?(p=C=>{const L=s.trim();L===""&&!C||de((async()=>{const _=await t.generate(L===""?"fix the failing statement":L,C?n:void 0);_!==void 0&&r(_)})())},e[9]=t,e[10]=n,e[11]=r,e[12]=s,e[13]=p):p=e[13];const x=p;let c;e[14]!==o?(c=o("Describe the query you want"),e[14]=o,e[15]=c):c=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=C=>{d(C.target.value)},e[16]=g):g=e[16];let v;e[17]!==x?(v=C=>{C.key==="Enter"&&(C.preventDefault(),x(!1))},e[17]=x,e[18]=v):v=e[18];let y;e[19]!==o?(y=o("Describe the query you want"),e[19]=o,e[20]=y):y=e[20];let b;e[21]!==i||e[22]!==s||e[23]!==c||e[24]!==v||e[25]!==y?(b=u(rt,{"aria-label":c,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:i,onChange:g,onKeyDown:v,placeholder:y,value:s}),e[21]=i,e[22]=s,e[23]=c,e[24]=v,e[25]=y,e[26]=b):b=e[26];const m=i&&"opacity-60";let w;e[27]!==m?(w=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",m),e[27]=m,e[28]=w):w=e[28];let N;e[29]!==i||e[30]!==s?(N=i||s.trim()==="",e[29]=i,e[30]=s,e[31]=N):N=e[31];let S;e[32]!==x?(S=()=>{x(!1)},e[32]=x,e[33]=S):S=e[33];let k;e[34]!==i||e[35]!==o?(k=o(i?"Thinking…":"Draft SQL"),e[34]=i,e[35]=o,e[36]=k):k=e[36];let R;e[37]!==w||e[38]!==N||e[39]!==S||e[40]!==k?(R=u("button",{className:w,"data-testid":"sql-assistant-generate",disabled:N,onClick:S,type:"button",children:k}),e[37]=w,e[38]=N,e[39]=S,e[40]=k,e[41]=R):R=e[41];let T;e[42]!==n||e[43]!==i||e[44]!==x||e[45]!==o?(T=n!==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:i,onClick:()=>{x(!0)},type:"button",children:o("Fix this")}),e[42]=n,e[43]=i,e[44]=x,e[45]=o,e[46]=T):T=e[46];let I;e[47]!==R||e[48]!==T||e[49]!==b?(I=A("div",{className:"flex items-center gap-2",children:[b,R,T]}),e[47]=R,e[48]=T,e[49]=b,e[50]=I):I=e[50],f=A("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[I,h!==void 0&&u("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ln(h)})]}),e[2]=t,e[3]=n,e[4]=r,e[5]=i,e[6]=s,e[7]=o,e[8]=f}else f=e[8];return f},On=l=>{const e=K(8),{diagnostics:t,draft:n,scrollRef:r}=l;let o,s;if(e[0]!==t||e[1]!==n){s=Symbol.for("react.early_return_sentinel");e:{const i=En(t,n.length);if(i.length===0){s=null;break e}o=[];let f=0;for(const[h,p]of i.entries())p.start>f&&o.push(n.slice(f,p.start)),o.push(u("span",{className:ue("decoration-wavy underline underline-offset-4",p.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:n.slice(p.start,p.end)},`${p.start.toString()}-${h.toString()}`)),f=p.end;o.push(n.slice(f))}e[0]=t,e[1]=n,e[2]=o,e[3]=s}else o=e[2],s=e[3];if(s!==Symbol.for("react.early_return_sentinel"))return s;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",Ve),e[4]=d):d=e[4];let a;return e[5]!==o||e[6]!==r?(a=u("div",{"aria-hidden":"true",className:d,"data-testid":"sql-diagnostics-overlay",ref:r,children:o}),e[5]=o,e[6]=r,e[7]=a):a=e[7],a},Mn={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Dn=l=>{const e=K(10),{diagnostics:t,onSelect:n}=l,r=le();if(t.length===0)return null;let o;e[0]!==r?(o=r("SQL problems"),e[0]=r,e[1]=o):o=e[1];let s;if(e[2]!==t||e[3]!==n){let a;e[5]!==n?(a=(i,f)=>u("li",{children:A("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:()=>{n(i)},type:"button",children:[u("span",{className:ue("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:Mn[i.source]}),u("span",{className:"min-w-0 text-muted-foreground",children:i.message})]})},`${i.source}-${(i.offset??f).toString()}-${f.toString()}`),e[5]=n,e[6]=a):a=e[6],s=t.map(a),e[2]=t,e[3]=n,e[4]=s}else s=e[4];let d;return e[7]!==o||e[8]!==s?(d=u("ul",{"aria-label":o,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:s}),e[7]=o,e[8]=s,e[9]=d):d=e[9],d},An={minWidth:"2.75rem",paddingInline:"0.5rem"},Bn=l=>{const e=K(64),{assistant:t,autocomplete:n,diagnostics:r,draft:o,failed:s,handlers:d,editorRef:a,gutterRef:i,listboxId:f,onGenerated:h,onPickSuggestion:p,onRevealDiagnostic:x,overlayRef:c}=l,g=le();let v,y,b,m,w,N,S,k;if(e[0]!==t||e[1]!==o||e[2]!==s||e[3]!==i||e[4]!==h){const B=o.split(`
|
|
5
|
-
`).length;S="flex min-h-0 min-w-0 flex-1 flex-col",e[13]!==t||e[14]!==s||e[15]!==h?(k=u(_n,{assistant:t,failed:s,onGenerated:h}),e[13]=t,e[14]=s,e[15]=h,e[16]=k):k=e[16],N="flex min-h-0 min-w-0 flex-1",v="true",y="shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",b=i,m=An,w=Array.from({length:B},zn),e[0]=t,e[1]=o,e[2]=s,e[3]=i,e[4]=h,e[5]=v,e[6]=y,e[7]=b,e[8]=m,e[9]=w,e[10]=N,e[11]=S,e[12]=k}else v=e[5],y=e[6],b=e[7],m=e[8],w=e[9],N=e[10],S=e[11],k=e[12];let R;e[17]!==v||e[18]!==y||e[19]!==b||e[20]!==m||e[21]!==w?(R=u("div",{"aria-hidden":v,className:y,ref:b,style:m,children:w}),e[17]=v,e[18]=y,e[19]=b,e[20]=m,e[21]=w,e[22]=R):R=e[22];let T;e[23]!==r||e[24]!==o||e[25]!==c?(T=u(On,{diagnostics:r,draft:o,scrollRef:c}),e[23]=r,e[24]=o,e[25]=c,e[26]=T):T=e[26];let I;e[27]!==n||e[28]!==f?(I=n===null?void 0:`${f}-opt-${n.active.toString()}`,e[27]=n,e[28]=f,e[29]=I):I=e[29];const C=n===null?void 0:f,L=n!==null;let _;e[30]!==g?(_=g("SQL query"),e[30]=g,e[31]=_):_=e[31];let O;e[32]!==o||e[33]!==a||e[34]!==d.onBlur||e[35]!==d.onChange||e[36]!==d.onKeyDown||e[37]!==d.onScroll||e[38]!==d.onSelect||e[39]!==I||e[40]!==C||e[41]!==L||e[42]!==_?(O=u("textarea",{"aria-activedescendant":I,"aria-autocomplete":"list","aria-controls":C,"aria-expanded":L,"aria-label":_,className:`relative size-full resize-none bg-transparent outline-none ${Ve}`,"data-testid":"sql-input",onBlur:d.onBlur,onChange:d.onChange,onKeyDown:d.onKeyDown,onScroll:d.onScroll,onSelect:d.onSelect,placeholder:"SELECT * FROM …",ref:a,role:"combobox",spellCheck:!1,value:o}),e[32]=o,e[33]=a,e[34]=d.onBlur,e[35]=d.onChange,e[36]=d.onKeyDown,e[37]=d.onScroll,e[38]=d.onSelect,e[39]=I,e[40]=C,e[41]=L,e[42]=_,e[43]=O):O=e[43];let $;e[44]!==n||e[45]!==f||e[46]!==p?($=u(sn,{listboxId:f,onPick:p,state:n}),e[44]=n,e[45]=f,e[46]=p,e[47]=$):$=e[47];let E;e[48]!==T||e[49]!==O||e[50]!==$?(E=A("div",{className:"relative min-w-0 flex-1 bg-background",children:[T,O,$]}),e[48]=T,e[49]=O,e[50]=$,e[51]=E):E=e[51];let M;e[52]!==E||e[53]!==N||e[54]!==R?(M=A("div",{className:N,children:[R,E]}),e[52]=E,e[53]=N,e[54]=R,e[55]=M):M=e[55];let D;e[56]!==r||e[57]!==x?(D=u(Dn,{diagnostics:r,onSelect:x}),e[56]=r,e[57]=x,e[58]=D):D=e[58];let q;return e[59]!==M||e[60]!==D||e[61]!==S||e[62]!==k?(q=A("div",{className:S,children:[k,M,D]}),e[59]=M,e[60]=D,e[61]=S,e[62]=k,e[63]=q):q=e[63],q};function zn(l,e){return u("div",{children:e+1},e)}const Xe=[{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;"}],Hn=l=>{const e=K(29),{active:t,onDelete:n,onSelect:r,query:o}=l,s=le();let d;e[0]!==r||e[1]!==o.id?(d=()=>{r(o.id)},e[0]=r,e[1]=o.id,e[2]=d):d=e[2];const a=d;let i;e[3]!==n||e[4]!==o.id?(i=S=>{S.stopPropagation(),n(o.id)},e[3]=n,e[4]=o.id,e[5]=i):i=e[5];const f=i,h=t?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground";let p;e[6]!==h?(p=ue("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",h),e[6]=h,e[7]=p):p=e[7];const x=`sql-query-${o.id}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=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[8]=c):c=e[8];let g;e[9]!==o.name?(g=u("span",{className:"truncate",children:o.name}),e[9]=o.name,e[10]=g):g=e[10];let v;e[11]!==t||e[12]!==a||e[13]!==p||e[14]!==x||e[15]!==g?(v=A("button",{"aria-pressed":t,className:p,"data-testid":x,onClick:a,type:"button",children:[c,g]}),e[11]=t,e[12]=a,e[13]=p,e[14]=x,e[15]=g,e[16]=v):v=e[16];let y;e[17]!==s?(y=s("Delete query"),e[17]=s,e[18]=y):y=e[18];let b;e[19]!==s?(b=s("Delete query"),e[19]=s,e[20]=b):b=e[20];let m;e[21]===Symbol.for("react.memo_cache_sentinel")?(m=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[21]=m):m=e[21];let w;e[22]!==f||e[23]!==b||e[24]!==y?(w=u("button",{"aria-label":y,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:f,title:b,type:"button",children:m}),e[22]=f,e[23]=b,e[24]=y,e[25]=w):w=e[25];let N;return e[26]!==w||e[27]!==v?(N=A("li",{className:"group/q flex items-center",children:[v,w]}),e[26]=w,e[27]=v,e[28]=N):N=e[28],N},Pn=(l,e)=>{const t=e.trim().toLowerCase();return t===""?[...l]:l.filter(n=>n.name.toLowerCase().includes(t))},Fn=l=>{const e=K(60),{activeId:t,history:n,listRef:r,onClearHistory:o,onDelete:s,onLoadHistory:d,onLoadTemplate:a,onNew:i,onSearchChange:f,onSelect:h,queries:p,search:x}=l,c=le();let g,v,y,b;if(e[0]!==t||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==f||e[5]!==h||e[6]!==p||e[7]!==x||e[8]!==c){const C=Pn(p,x);v="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let L;e[13]!==c?(L=c("Search queries…"),e[13]=c,e[14]=L):L=e[14];let _;e[15]!==f||e[16]!==x||e[17]!==L?(_=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:f,placeholder:L,type:"text",value:x}),e[15]=f,e[16]=x,e[17]=L,e[18]=_):_=e[18];let O;e[19]!==c?(O=c("New query"),e[19]=c,e[20]=O):O=e[20];let $;e[21]!==c?($=c("New query"),e[21]=c,e[22]=$):$=e[22];let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=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[23]=E):E=e[23];let M;e[24]!==i||e[25]!==O||e[26]!==$?(M=u("button",{"aria-label":O,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:$,type:"button",children:E}),e[24]=i,e[25]=O,e[26]=$,e[27]=M):M=e[27],e[28]!==M||e[29]!==_?(y=A("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[_,M]}),e[28]=M,e[29]=_,e[30]=y):y=e[30],g="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let D;e[31]!==c?(D=c("Private"),e[31]=c,e[32]=D):D=e[32];let q;e[33]!==D?(q=u("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:D}),e[33]=D,e[34]=q):q=e[34],b=A("div",{children:[q,C.length===0?u("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:c("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:r,children:C.map(B=>u(Hn,{active:t===B.id,onDelete:s,onSelect:h,query:B},B.id))})]}),e[0]=t,e[1]=r,e[2]=s,e[3]=i,e[4]=f,e[5]=h,e[6]=p,e[7]=x,e[8]=c,e[9]=g,e[10]=v,e[11]=y,e[12]=b}else g=e[9],v=e[10],y=e[11],b=e[12];let m;e[35]!==c?(m=c("Reference"),e[35]=c,e[36]=m):m=e[36];let w;e[37]!==m?(w=u("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m}),e[37]=m,e[38]=w):w=e[38];let N;e[39]!==a?(N=Xe.map(C=>u("li",{children:A("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":C.sql,onClick:a,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"})}),C.label]})},C.label)),e[39]=a,e[40]=N):N=e[40];let S;e[41]!==N?(S=u("ul",{className:"flex flex-col gap-px",children:N}),e[41]=N,e[42]=S):S=e[42];let k;e[43]!==w||e[44]!==S?(k=A("div",{children:[w,S]}),e[43]=w,e[44]=S,e[45]=k):k=e[45];let R;e[46]!==n||e[47]!==o||e[48]!==d||e[49]!==c?(R=n.length>0&&A("div",{children:[A("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:c("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:o,type:"button",children:c("Clear history")})]}),u("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:n.map(C=>u("li",{children:A("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":C.sql,"data-testid":"sql-history-item",onClick:d,title:C.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:C.sql})]})},`${C.at.toString()}:${C.sql}`))})]}),e[46]=n,e[47]=o,e[48]=d,e[49]=c,e[50]=R):R=e[50];let T;e[51]!==g||e[52]!==R||e[53]!==b||e[54]!==k?(T=A("div",{className:g,children:[b,k,R]}),e[51]=g,e[52]=R,e[53]=b,e[54]=k,e[55]=T):T=e[55];let I;return e[56]!==T||e[57]!==v||e[58]!==y?(I=A("aside",{className:v,children:[y,T]}),e[56]=T,e[57]=v,e[58]=y,e[59]=I):I=e[59],I},Qn=l=>{const e=K(19),{result:t}=l,n=le();if(t.columns.length===0){let i;e[0]!==t.rowCount||e[1]!==n?(i=n("{count} rows",{count:t.rowCount}),e[0]=t.rowCount,e[1]=n,e[2]=i):i=e[2];let f;return e[3]!==i?(f=u("p",{className:"p-4 text-sm text-muted-foreground",children:i}),e[3]=i,e[4]=f):f=e[4],f}let r;e[5]!==t.columns?(r=t.columns.map(jn),e[5]=t.columns,e[6]=r):r=e[6];let o;e[7]!==r?(o=u(ct,{className:"sticky top-0 z-10 bg-muted",children:u(He,{children:r})}),e[7]=r,e[8]=o):o=e[8];let s;if(e[9]!==t.columns||e[10]!==t.rows){let i;e[12]!==t.columns?(i=(f,h)=>u(He,{"data-testid":"sql-row",children:t.columns.map(p=>u(ft,{className:"max-w-md truncate font-mono text-xs",children:u(ht,{value:f[p]})},p))},h),e[12]=t.columns,e[13]=i):i=e[13],s=t.rows.map(i),e[9]=t.columns,e[10]=t.rows,e[11]=s}else s=e[11];let d;e[14]!==s?(d=u(dt,{children:s}),e[14]=s,e[15]=d):d=e[15];let a;return e[16]!==o||e[17]!==d?(a=A(ut,{"data-testid":"sql-rows",children:[o,d]}),e[16]=o,e[17]=d,e[18]=a):a=e[18],a};function jn(l){return u(mt,{children:l},l)}const Ne=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"}`,Wn=l=>{const e=K(92),{assistant:t,chart:n,className:r,error:o,onFormat:s,onInferChart:d,onRun:a,onShardKeyChange:i,onShowChart:f,onShowExplain:h,onShowResults:p,onToggleSplit:x,pane:c,result:g,running:v,shardKey:y,splitView:b}=l,m=le(),w=c==="results";let N;e[0]!==w?(N=Ne(w),e[0]=w,e[1]=N):N=e[1];let S;e[2]!==m?(S=m("Results"),e[2]=m,e[3]=S):S=e[3];let k;e[4]!==p||e[5]!==N||e[6]!==S?(k=u("button",{className:N,"data-testid":"sql-tab-results",onClick:p,type:"button",children:S}),e[4]=p,e[5]=N,e[6]=S,e[7]=k):k=e[7];const R=c==="chart";let T;e[8]!==R?(T=Ne(R),e[8]=R,e[9]=T):T=e[9];let I;e[10]!==m?(I=m("Chart"),e[10]=m,e[11]=I):I=e[11];let C;e[12]!==f||e[13]!==T||e[14]!==I?(C=u("button",{className:T,"data-testid":"sql-tab-chart",onClick:f,type:"button",children:I}),e[12]=f,e[13]=T,e[14]=I,e[15]=C):C=e[15];let L;e[16]!==t||e[17]!==d||e[18]!==c||e[19]!==g||e[20]!==m?(L=!t.unavailable&&c==="chart"&&g!==null&&u("button",{className:Ne(!1),"data-testid":"sql-infer-chart",disabled:t.pending("chart"),onClick:d,type:"button",children:t.pending("chart")?m("Thinking…"):m("Suggest chart")}),e[16]=t,e[17]=d,e[18]=c,e[19]=g,e[20]=m,e[21]=L):L=e[21];const _=c==="explain";let O;e[22]!==_?(O=Ne(_),e[22]=_,e[23]=O):O=e[23];let $;e[24]!==m?($=m("Explain"),e[24]=m,e[25]=$):$=e[25];let E;e[26]!==h||e[27]!==O||e[28]!==$?(E=u("button",{className:O,"data-testid":"sql-tab-explain",onClick:h,type:"button",children:$}),e[26]=h,e[27]=O,e[28]=$,e[29]=E):E=e[29];let M;e[30]!==m?(M=m("Split editor and results"),e[30]=m,e[31]=M):M=e[31];const D=`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 ${b?"bg-accent text-foreground":"text-muted-foreground"}`;let q;e[32]!==m?(q=m("Split editor and results"),e[32]=m,e[33]=q):q=e[33];let B;e[34]===Symbol.for("react.memo_cache_sentinel")?(B=A("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[34]=B):B=e[34];let F;e[35]!==x||e[36]!==b||e[37]!==M||e[38]!==D||e[39]!==q?(F=u("button",{"aria-label":M,"aria-pressed":b,className:D,"data-testid":"sql-split-toggle",onClick:x,title:q,type:"button",children:B}),e[35]=x,e[36]=b,e[37]=M,e[38]=D,e[39]=q,e[40]=F):F=e[40];let P;e[41]!==g?(P=g!==null&&g.columns.length>0&&u(it,{columns:g.columns,name:"query-result",rows:g.rows}),e[41]=g,e[42]=P):P=e[42];let W;e[43]!==m?(W=m("Format"),e[43]=m,e[44]=W):W=e[44];let Q;e[45]!==s||e[46]!==v||e[47]!==W?(Q=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:v,onClick:s,type:"button",children:W}),e[45]=s,e[46]=v,e[47]=W,e[48]=Q):Q=e[48];let Y;e[49]!==i||e[50]!==y?(Y=u(st,{onChange:i,testId:"sql-shard-input",value:y}),e[49]=i,e[50]=y,e[51]=Y):Y=e[51];let J;e[52]!==v||e[53]!==m?(J=m(v?"Running…":"Run"),e[52]=v,e[53]=m,e[54]=J):J=e[54];let z;e[55]===Symbol.for("react.memo_cache_sentinel")?(z=u("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"⌘↵"}),e[55]=z):z=e[55];let G;e[56]!==a||e[57]!==v||e[58]!==J?(G=A("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:v,onClick:a,type:"button",children:[J,z]}),e[56]=a,e[57]=v,e[58]=J,e[59]=G):G=e[59];let ne;e[60]!==F||e[61]!==P||e[62]!==Q||e[63]!==Y||e[64]!==G?(ne=A("div",{className:"ms-auto flex items-center gap-2",children:[F,P,Q,Y,G]}),e[60]=F,e[61]=P,e[62]=Q,e[63]=Y,e[64]=G,e[65]=ne):ne=e[65];let V;e[66]!==E||e[67]!==ne||e[68]!==k||e[69]!==C||e[70]!==L?(V=A("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[k,C,L,E,ne]}),e[66]=E,e[67]=ne,e[68]=k,e[69]=C,e[70]=L,e[71]=V):V=e[71];let X;e[72]!==o?(X=o!==null&&u(at,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:o}),e[72]=o,e[73]=X):X=e[73];let Z;e[74]!==o||e[75]!==g||e[76]!==m?(Z=o===null&&g===null&&u("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:m("Click Run to execute your query.")}),e[74]=o,e[75]=g,e[76]=m,e[77]=Z):Z=e[77];let ee;e[78]!==n||e[79]!==o||e[80]!==c||e[81]!==g||e[82]!==m?(ee=o===null&&g!==null&&A("div",{"data-testid":"sql-result",children:[c==="chart"?u(lt,{axes:n,result:g}):u(Qn,{result:g}),u("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:g.truncated?m("Showing the first {max} of {count} rows.",{count:g.rowCount,max:g.rows.length}):m("{count} rows",{count:g.rowCount})})]}),e[78]=n,e[79]=o,e[80]=c,e[81]=g,e[82]=m,e[83]=ee):ee=e[83];let te;e[84]!==X||e[85]!==Z||e[86]!==ee?(te=A("div",{className:"min-h-0 flex-1 overflow-auto",children:[X,Z,ee]}),e[84]=X,e[85]=Z,e[86]=ee,e[87]=te):te=e[87];let oe;return e[88]!==r||e[89]!==V||e[90]!==te?(oe=A("div",{className:r,children:[V,te]}),e[88]=r,e[89]=V,e[90]=te,e[91]=oe):oe=e[91],oe},Kn=(l,e)=>l.trim()===""?e:(l.split(`
|
|
6
|
-
`)[0]??l).slice(0,24),Un=l=>{l?.focus(),l?.select()},Yn=l=>{const e=K(14),{initial:t,onCancel:n,onCommit:r,placeholder:o,testId:s}=l,d=le();let a;e[0]!==r?(a=c=>{r(c.currentTarget.value.trim())},e[0]=r,e[1]=a):a=e[1];const i=a;let f;e[2]!==n||e[3]!==r?(f=c=>{c.key==="Enter"?r(c.currentTarget.value.trim()):c.key==="Escape"&&n()},e[2]=n,e[3]=r,e[4]=f):f=e[4];const h=f;let p;e[5]!==d?(p=d("Tab title"),e[5]=d,e[6]=p):p=e[6];let x;return e[7]!==t||e[8]!==i||e[9]!==h||e[10]!==o||e[11]!==p||e[12]!==s?(x=u("input",{"aria-label":p,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":s,defaultValue:t,onBlur:i,onKeyDown:h,placeholder:o,ref:Un,type:"text"}),e[7]=t,e[8]=i,e[9]=h,e[10]=o,e[11]=p,e[12]=s,e[13]=x):x=e[13],x},Jn=l=>{const e=K(29),{idBase:t,onDiscard:n,onKeep:r}=l,o=le(),s=`sql-tab-close-prompt-${t}`;let d;e[0]!==o?(d=o("Discard?"),e[0]=o,e[1]=d):d=e[1];let a;e[2]!==d?(a=u("span",{className:"text-[11px] text-muted-foreground",children:d}),e[2]=d,e[3]=a):a=e[3];let i;e[4]!==o?(i=o("Discard changes"),e[4]=o,e[5]=i):i=e[5];const f=`sql-tab-close-confirm-${t}`;let h;e[6]!==o?(h=o("Discard changes"),e[6]=o,e[7]=h):h=e[7];let p;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=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]=p):p=e[8];let x;e[9]!==n||e[10]!==i||e[11]!==f||e[12]!==h?(x=u("button",{"aria-label":i,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":f,onClick:n,title:h,type:"button",children:p}),e[9]=n,e[10]=i,e[11]=f,e[12]=h,e[13]=x):x=e[13];let c;e[14]!==o?(c=o("Keep editing"),e[14]=o,e[15]=c):c=e[15];const g=`sql-tab-close-cancel-${t}`;let v;e[16]!==o?(v=o("Keep editing"),e[16]=o,e[17]=v):v=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=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]=y):y=e[18];let b;e[19]!==r||e[20]!==g||e[21]!==v||e[22]!==c?(b=u("button",{"aria-label":c,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":g,onClick:r,title:v,type:"button",children:y}),e[19]=r,e[20]=g,e[21]=v,e[22]=c,e[23]=b):b=e[23];let m;return e[24]!==s||e[25]!==b||e[26]!==a||e[27]!==x?(m=A("span",{className:"flex shrink-0 items-center gap-1","data-testid":s,role:"group",children:[a,x,b]}),e[24]=s,e[25]=b,e[26]=a,e[27]=x,e[28]=m):m=e[28],m},Gn=l=>{const e=K(47),{active:t,canClose:n,onClose:r,onMenu:o,onRename:s,onSelect:d,tab:a}=l,i=le(),[f,h]=re(!1),[p,x]=re(!1);let c;e[0]!==o||e[1]!==a.id?(c=Q=>{o(a.id,Q)},e[0]=o,e[1]=a.id,e[2]=c):c=e[2];const g=c;let v;e[3]!==d||e[4]!==a.id?(v=()=>{d(a.id)},e[3]=d,e[4]=a.id,e[5]=v):v=e[5];const y=v;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{h(!0)},e[6]=b):b=e[6];const m=b;let w;e[7]!==r||e[8]!==a?(w=Q=>{Q.stopPropagation(),Ge(a)?x(!0):r(a.id)},e[7]=r,e[8]=a,e[9]=w):w=e[9];const N=w;let S;e[10]!==r||e[11]!==a.id?(S=Q=>{Q.stopPropagation(),x(!1),r(a.id)},e[10]=r,e[11]=a.id,e[12]=S):S=e[12];const k=S;let R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=Q=>{Q.stopPropagation(),x(!1)},e[13]=R):R=e[13];const T=R;let I;e[14]!==s||e[15]!==a.id?(I=Q=>{s(a.id,Q),h(!1)},e[14]=s,e[15]=a.id,e[16]=I):I=e[16];const C=I;let L;e[17]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{h(!1)},e[17]=L):L=e[17];const _=L;let O;e[18]!==a.name?(O=a.name.trim(),e[18]=a.name,e[19]=O):O=e[19];const $=O;let E;e[20]!==i||e[21]!==a.sql?(E=Kn(a.sql,i("Untitled")),e[20]=i,e[21]=a.sql,e[22]=E):E=e[22];const M=E,D=t?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground";let q;e[23]!==D?(q=ue("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",D),e[23]=D,e[24]=q):q=e[24];const B=`sql-tab-${a.id}`;let F;e[25]!==t||e[26]!==C||e[27]!==$||e[28]!==M||e[29]!==f||e[30]!==y||e[31]!==i||e[32]!==a.id?(F=f?u(Yn,{initial:$,onCancel:_,onCommit:C,placeholder:M,testId:`sql-tab-rename-${a.id}`}):u("button",{"aria-pressed":t,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${a.id}`,onClick:y,onDoubleClick:m,title:i("Double-click to rename"),type:"button",children:$===""?M:$}),e[25]=t,e[26]=C,e[27]=$,e[28]=M,e[29]=f,e[30]=y,e[31]=i,e[32]=a.id,e[33]=F):F=e[33];let P;e[34]!==n||e[35]!==k||e[36]!==p||e[37]!==N||e[38]!==i||e[39]!==a.id?(P=n&&(p?u(Jn,{idBase:a.id,onDiscard:k,onKeep:T}):u("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:N,title:i("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]=n,e[35]=k,e[36]=p,e[37]=N,e[38]=i,e[39]=a.id,e[40]=P):P=e[40];let W;return e[41]!==g||e[42]!==q||e[43]!==B||e[44]!==F||e[45]!==P?(W=A("div",{className:q,"data-testid":B,onContextMenu:g,children:[F,P]}),e[41]=g,e[42]=q,e[43]=B,e[44]=F,e[45]=P,e[46]=W):W=e[46],W},Vn=l=>{const e=K(43),{model:t,onSelect:n}=l,r=le(),{activeTab:o,addEditorTab:s,cancelBulk:d,closeEditorTab:a,closeTabMenu:i,confirmBulk:f,menuStyle:h,onBackdropContextMenu:p,onCloseAll:x,onCloseOthers:c,onCloseToRight:g,openTabMenu:v,pendingBulk:y,renameTab:b,tabMenu:m,tabs:w}=t;let N;if(e[0]!==o||e[1]!==a||e[2]!==n||e[3]!==v||e[4]!==b||e[5]!==w){let O;e[7]!==o||e[8]!==a||e[9]!==n||e[10]!==v||e[11]!==b||e[12]!==w.length?(O=$=>u(Gn,{active:$.id===o.id,canClose:w.length>1,onClose:a,onMenu:v,onRename:b,onSelect:n,tab:$},$.id),e[7]=o,e[8]=a,e[9]=n,e[10]=v,e[11]=b,e[12]=w.length,e[13]=O):O=e[13],N=w.map(O),e[0]=o,e[1]=a,e[2]=n,e[3]=v,e[4]=b,e[5]=w,e[6]=N}else N=e[6];let S;e[14]!==r?(S=r("New tab"),e[14]=r,e[15]=S):S=e[15];const k=w.length>=De;let R;e[16]!==r?(R=r("New tab"),e[16]=r,e[17]=R):R=e[17];let T;e[18]===Symbol.for("react.memo_cache_sentinel")?(T=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]=T):T=e[18];let I;e[19]!==s||e[20]!==S||e[21]!==k||e[22]!==R?(I=u("button",{"aria-label":S,className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:k,onClick:s,title:R,type:"button",children:T}),e[19]=s,e[20]=S,e[21]=k,e[22]=R,e[23]=I):I=e[23];let C;e[24]!==N||e[25]!==I?(C=A("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:[N,I]}),e[24]=N,e[25]=I,e[26]=C):C=e[26];let L;e[27]!==d||e[28]!==i||e[29]!==f||e[30]!==h||e[31]!==p||e[32]!==x||e[33]!==c||e[34]!==g||e[35]!==y||e[36]!==r||e[37]!==m||e[38]!==w?(L=m!==null&&A(Ee,{children:[u("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:i,onContextMenu:p,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:h,children:y===null?A(Ee,{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:w.length<=1,onClick:c,role:"menuitem",type:"button",children:r("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:w.findIndex(O=>O.id===m.id)>=w.length-1,onClick:g,role:"menuitem",type:"button",children:r("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:x,role:"menuitem",type:"button",children:r("Close all tabs")})]}):A("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:r("Discard unsaved tabs?")}),A("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:f,type:"button",children:r("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:d,type:"button",children:r("Cancel")})]})]})})]}),e[27]=d,e[28]=i,e[29]=f,e[30]=h,e[31]=p,e[32]=x,e[33]=c,e[34]=g,e[35]=y,e[36]=r,e[37]=m,e[38]=w,e[39]=L):L=e[39];let _;return e[40]!==C||e[41]!==L?(_=A(Ee,{children:[C,L]}),e[40]=C,e[41]=L,e[42]=_):_=e[42],_},Xn=Te(qe.runSql),Zn="lunora-studio-sql-split-view",eo=()=>ve(Xe[0]?.sql??""),wo=l=>{const e=K(102),{initialShardKey:t}=l,n=Oe(),r=kn(eo),{activeTab:o,output:s,patchActiveOutput:d,patchActiveTab:a,setActiveTabId:i,unlinkQuery:f}=r;let h;e[0]!==d||e[1]!==a?(h=(se,ce)=>{a({activeId:ce,sql:se}),d({chart:void 0,error:null,failed:void 0,result:null})},e[0]=d,e[1]=a,e[2]=h):h=e[2];const p=h;let x;e[3]!==p||e[4]!==f?(x={loadIntoActiveTab:p,unlinkQuery:f},e[3]=p,e[4]=f,e[5]=x):x=e[5];const c=In(x),{recordHistory:g,updateQuerySql:v}=c,y=o.sql,{activeId:b}=o,{chart:m,error:w,failed:N,result:S,running:k}=s,R=s.pane,[T,I]=re(t??""),[C,L]=We(Zn,!1),{probe:_,schema:O}=dn(T);let $;e[6]!==b||e[7]!==a||e[8]!==v?($=se=>{a({sql:se}),b!==null&&v(b,se)},e[6]=b,e[7]=a,e[8]=v,e[9]=$):$=e[9];const E=$,M=Ut(y,O,T),D=nt(T);let q;e[10]!==D||e[11]!==d||e[12]!==S?(q=()=>{S!==null&&de((async()=>{const se=await D.inferChart({columns:S.columns,rowCount:S.rowCount,types:Object.fromEntries(S.columns.map(ce=>[ce,typeof(S.rows[0]?.[ce]??"")]))});d({chart:se})})())},e[10]=D,e[11]=d,e[12]=S,e[13]=q):q=e[13];const B=q;let F;e[14]!==n||e[15]!==y||e[16]!==d||e[17]!==g||e[18]!==T?(F=async se=>{if(y.trim()==="")return;d({running:!0});const ce=se==="explain"?`EXPLAIN QUERY PLAN ${y}`:y;try{const Ie=await n.query(Xn,{sql:ce},ke(T));d({chart:void 0,error:null,failed:void 0,pane:se,result:Ie,running:!1}),tt(T),g(ce)}catch(Ie){const Ae=Ie;d({chart:void 0,error:ze(Ae),failed:{error:ze(Ae),sql:ce},pane:se,result:null,running:!1})}},e[14]=n,e[15]=y,e[16]=d,e[17]=g,e[18]=T,e[19]=F):F=e[19];const P=F;let W;e[20]!==P?(W=()=>{de(P("results"))},e[20]=P,e[21]=W):W=e[21];const Q=W;let Y;e[22]!==s.pane||e[23]!==P?(Y=()=>{de(P(s.pane))},e[22]=s.pane,e[23]=P,e[24]=Y):Y=e[24];let J;e[25]!==_||e[26]!==O||e[27]!==E||e[28]!==Y?(J={onSubmit:Y,probe:_,schema:O,setDraft:E},e[25]=_,e[26]=O,e[27]=E,e[28]=Y,e[29]=J):J=e[29];const z=fn(J),{closeAutocomplete:G}=z;let ne;e[30]!==y||e[31]!==E?(ne=()=>{E(yt(y))},e[30]=y,e[31]=E,e[32]=ne):ne=e[32];const V=ne;let X;e[33]!==G||e[34]!==i?(X=se=>{G(),i(se)},e[33]=G,e[34]=i,e[35]=X):X=e[35];const Z=X;let ee;e[36]!==d?(ee=()=>{d({pane:"results"})},e[36]=d,e[37]=ee):ee=e[37];const te=ee;let oe;e[38]!==P?(oe=()=>{de(P("explain"))},e[38]=P,e[39]=oe):oe=e[39];const ie=oe;let H;e[40]!==d?(H=()=>{d({pane:"chart"})},e[40]=d,e[41]=H):H=e[41];const j=H;let U;e[42]!==L||e[43]!==C?(U=()=>{L(!C)},e[42]=L,e[43]=C,e[44]=U):U=e[44];const ae=U,xe=C?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",Re=C?"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";let me;e[45]!==b||e[46]!==c.clearHistory||e[47]!==c.deleteQuery||e[48]!==c.history||e[49]!==c.listRef||e[50]!==c.loadFromHistory||e[51]!==c.loadTemplate||e[52]!==c.newQuery||e[53]!==c.onSearchChange||e[54]!==c.queries||e[55]!==c.search||e[56]!==c.selectQuery?(me=u(Fn,{activeId:b,history:c.history,listRef:c.listRef,onClearHistory:c.clearHistory,onDelete:c.deleteQuery,onLoadHistory:c.loadFromHistory,onLoadTemplate:c.loadTemplate,onNew:c.newQuery,onSearchChange:c.onSearchChange,onSelect:c.selectQuery,queries:c.queries,search:c.search}),e[45]=b,e[46]=c.clearHistory,e[47]=c.deleteQuery,e[48]=c.history,e[49]=c.listRef,e[50]=c.loadFromHistory,e[51]=c.loadTemplate,e[52]=c.newQuery,e[53]=c.onSearchChange,e[54]=c.queries,e[55]=c.search,e[56]=c.selectQuery,e[57]=me):me=e[57];let fe;e[58]!==r||e[59]!==Z?(fe=u(Vn,{model:r,onSelect:Z}),e[58]=r,e[59]=Z,e[60]=fe):fe=e[60];let he;e[61]!==D||e[62]!==M||e[63]!==y||e[64]!==N||e[65]!==E||e[66]!==z.autocompleteState||e[67]!==z.editorRef||e[68]!==z.gutterRef||e[69]!==z.handlers||e[70]!==z.listboxId||e[71]!==z.onPickSuggestion||e[72]!==z.overlayRef||e[73]!==z.revealDiagnostic?(he=u(Bn,{assistant:D,autocomplete:z.autocompleteState,diagnostics:M,draft:y,editorRef:z.editorRef,failed:N,gutterRef:z.gutterRef,handlers:z.handlers,listboxId:z.listboxId,onGenerated:E,onPickSuggestion:z.onPickSuggestion,onRevealDiagnostic:z.revealDiagnostic,overlayRef:z.overlayRef}),e[61]=D,e[62]=M,e[63]=y,e[64]=N,e[65]=E,e[66]=z.autocompleteState,e[67]=z.editorRef,e[68]=z.gutterRef,e[69]=z.handlers,e[70]=z.listboxId,e[71]=z.onPickSuggestion,e[72]=z.overlayRef,e[73]=z.revealDiagnostic,e[74]=he):he=e[74];let pe;e[75]!==D||e[76]!==w||e[77]!==V||e[78]!==B||e[79]!==m||e[80]!==Q||e[81]!==S||e[82]!==Re||e[83]!==k||e[84]!==T||e[85]!==j||e[86]!==ie||e[87]!==te||e[88]!==C||e[89]!==R||e[90]!==ae?(pe=u(Wn,{assistant:D,chart:m,className:Re,error:w,onFormat:V,onInferChart:B,onRun:Q,onShardKeyChange:I,onShowChart:j,onShowExplain:ie,onShowResults:te,onToggleSplit:ae,pane:R,result:S,running:k,shardKey:T,splitView:C}),e[75]=D,e[76]=w,e[77]=V,e[78]=B,e[79]=m,e[80]=Q,e[81]=S,e[82]=Re,e[83]=k,e[84]=T,e[85]=j,e[86]=ie,e[87]=te,e[88]=C,e[89]=R,e[90]=ae,e[91]=pe):pe=e[91];let be;e[92]!==he||e[93]!==pe||e[94]!==xe?(be=A("div",{className:xe,children:[he,pe]}),e[92]=he,e[93]=pe,e[94]=xe,e[95]=be):be=e[95];let ge;e[96]!==fe||e[97]!==be?(ge=A("div",{className:"flex min-w-0 flex-1 flex-col",children:[fe,be]}),e[96]=fe,e[97]=be,e[98]=ge):ge=e[98];let we;return e[99]!==me||e[100]!==ge?(we=A("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[me,ge]}),e[99]=me,e[100]=ge,e[101]=we):we=e[101],we};export{wo as SqlEditorPanel};
|
|
1
|
+
import{c as Y}from"react/compiler-runtime";import{useLunora as Oe}from"@lunora/react";import{useState as oe,useMemo as Be,useCallback as Ze,useEffect as Ee,useRef as Se,useId as et}from"react";import{ADMIN_FUNCTIONS as Re}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{u as _e,n as ze,b as Ue}from"../packem_shared/browser-storage-Br_bLeBt.js";import{d as Te,f as ce,c as Le,b as Pe}from"../packem_shared/internal-CwaF9YNk.js";import{r as tt}from"../packem_shared/shard-history-QcjcMnCA.js";import{u as nt}from"../packem_shared/use-sql-assistant-CP90nLLh.js";import st from"../packem_shared/useDebounced-DVeQ5-oW.js";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{c as ue}from"../packem_shared/utils-bhneXptQ.js";import{jsxs as $,jsx as f,Fragment as qe}from"react/jsx-runtime";import{I as ot}from"../packem_shared/input-CY5W3wzv.js";import{S as lt}from"../packem_shared/result-chart-Ca3YLzt8.js";import{ShardInput as rt}from"../packem_shared/ShardInput-XumEzeT0.js";import{A as it}from"../packem_shared/alert-C2SEhYS9.js";import{E as at}from"../packem_shared/grid-features-C_yXlMc_.js";import{c as ct,a as dt,b as He,e as ut,d as ft,T as mt}from"../packem_shared/table-BMsuYFhk.js";import{C as ht}from"../packem_shared/data-grid-BFTQnkXq.js";const pt=["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"],bt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],ke=String.fromCodePoint(0),gt=new RegExp(`${ke}${String.raw`(\d+)`}${ke}`,"gu"),xt=pt.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),yt=bt.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
|
|
2
|
+
${l}`})),vt=l=>{const e=[];let t=l.replaceAll(/'(?:[^']|'')*'/gu,o=>(e.push(o),`${ke}${(e.length-1).toString()}${ke}`)).replaceAll(/\s+/gu," ").trim();for(const{pattern:o,replacement:s}of xt)t=t.replaceAll(o,s);for(const{pattern:o,replacement:s}of yt)t=t.replaceAll(o,s);return t=t.replaceAll(gt,(o,s)=>e[Number(s)]??""),t},St=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,wt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|replace|truncate|update|vacuum)\b/iu,Ct=/^\w+/u,Nt=/;\s*$/u,Tt=/\s/u,kt=(l,e)=>{let n=e+2;for(;n<l.length&&l[n]!==`
|
|
3
|
+
`;)n+=1;return n},Et=(l,e)=>{const n=l.indexOf("*/",e+2);return n===-1?-1:n+2},Rt=l=>{let e=0;for(;e<l.length;){const n=l[e];if(n!==void 0&&Tt.test(n))e+=1;else if(n==="-"&&l[e+1]==="-")e=kt(l,e);else if(n==="/"&&l[e+1]==="*"){const t=Et(l,e);if(t===-1)break;e=t}else break}return e},Lt=l=>{const e=Rt(l),n=l.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};const t=n.replace(Nt,""),o=t.indexOf(";");if(o!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+o};const s="the SQL editor is read-only — only SELECT / WITH / EXPLAIN queries are allowed";if(!St.test(t))return{code:"SQL_NOT_READONLY",length:Ct.exec(t)?.[0].length??1,message:s,offset:e};const r=wt.exec(t);if(r!==null)return{code:"SQL_NOT_READONLY",length:r[0].length,message:`${s} (\`${r[0].toUpperCase()}\` is not allowed)`,offset:e+r.index}},It=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,qt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,At=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),_t=/[^\n]/gu,Ot=(l,e)=>{const n=l[e];if(n==="'"){let t=e+1;for(;t<l.length&&l[t]!=="'";)t+=1;return Math.min(t+1,l.length)}if(n==="-"&&l[e+1]==="-"){const t=l.indexOf(`
|
|
4
|
+
`,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},Dt=l=>{let e="",n=0;for(;n<l.length;){const t=Ot(l,n);t===-1?(e+=l.slice(n,n+1),n+=1):(e+=l.slice(n,t).replaceAll(_t," "),n=t)}return e},Mt=l=>{const e=new Set;for(const n of l.matchAll(qt))e.add((n[1]??"").toLowerCase());return e},$t=(l,e)=>{const n=new Map;for(const t of l.matchAll(It)){const o=(t[1]??"").toLowerCase(),s=(t[2]??"").toLowerCase();e.has(o)&&(n.set(o,o),s!==""&&!At.has(s)&&n.set(s,o))}return n},Ye=(l,e)=>{const n=Dt(l),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:Mt(n),masked:n,targets:$t(n,t)}},Bt=/^(?:__lunora|sqlite_)/iu,Pt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Ht=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Wt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Ft=(l,e,n)=>{const t=[];for(const o of l.matchAll(Pt)){const s=o[1]??"",r=s.toLowerCase();!e.has(r)&&!n.has(r)&&!Wt.has(r)&&!Bt.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},Qt=(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(d=>d.toLowerCase())));for(const s of l.matchAll(Ht)){const r=(s[1]??"").toLowerCase(),d=s[2]??"",a=n.get(r),i=a===void 0?void 0:o.get(a);i!==void 0&&!i.has(d.toLowerCase())&&t.push({length:d.length,message:`\`${a??""}\` has no column \`${d}\``,offset:s.index+s[0].length-d.length,severity:"error",source:"schema"})}return t},zt=(l,e)=>{if(l.trim()==="")return[];const n=Lt(l);if(n!==void 0)return n.code==="SQL_EMPTY"?[]:[{length:n.length,message:n.message,offset:n.offset,severity:"error",source:"gate"}];const{ctes:t,masked:o,targets:s}=Ye(l,e.tables),r=new Set(e.tables.map(d=>d.toLowerCase()));return[...Ft(o,r,t),...Qt(o,e,s)]},Ut=Le(Re.lintSql),Yt=600,jt=(l,e,n)=>{const t=Oe(),[o,s]=oe([]),r=Be(()=>zt(l,e),[l,e]),d=st(l,Yt),i=r.some(u=>u.source==="gate")||d.trim()==="",m=Ze(async u=>{try{const x=await t.query(Ut,{sql:d},Te(n));u.cancelled||s(x.diagnostics??[])}catch{u.cancelled||s([])}},[t,d,n]);Ee(()=>{if(i){s([]);return}const u={cancelled:!1};return ce(m(u)),()=>{u.cancelled=!0}},[m,i]);const b=d===l;return Be(()=>b?[...r,...o]:r,[r,o,b])},Ce=8,Kt=["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"]),Vt=/[\w$]/,je=l=>l!==void 0&&Vt.test(l),Ke=l=>{let e=l.length;for(;e>0&&je(l[e-1]);)e-=1;return l.slice(e)},Ge=(l,e)=>{let n=e;for(;n>0&&je(l[n-1]);)n-=1;return{end:e,start:n,text:l.slice(n,e)}},We=(l,e)=>{const n=l.slice(0,e).trimEnd();return n.endsWith(".")||Gt.has(Ke(n).toUpperCase())},Jt=(l,e,n)=>{const t=l.slice(0,e);if(!t.endsWith("."))return;const o=Ke(t.slice(0,-1));if(o!=="")return Ye(l,n).targets.get(o.toLowerCase())??o},De=(l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),Fe=(l,e,n,t)=>{const o=[];for(const s of l)if(De(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(De(r,e)&&!t.has(r)&&(t.set(r,o),t.size>=n))return[...t].map(([d,a])=>({detail:a,kind:"column",label:d}));return[...t].map(([o,s])=>({detail:s,kind:"column",label:o}))},Zt=(l,e,n)=>{const t=Ge(l,e),o=Jt(l,t.start,n.tables);if(o!==void 0){const i=n.columns[o]??n.columns[o.toLowerCase()]??[];return Fe(i,t.text,Ce,m=>({detail:o,kind:"column",label:m}))}if(t.text===""&&!We(l,t.start))return[];const s=Fe(n.tables,t.text,Ce,i=>({kind:"table",label:i})),r=Xt(n,t.text,Ce),d=Kt.flatMap(i=>t.text!==""&&De(i,t.text)&&i.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:i}]:[]);return(We(l,t.start)?[...r,...s,...d]:[...s,...r,...d]).slice(0,Ce)},en=(l,e,n)=>{const t=Ge(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,d=s.offsetTop-l.scrollTop;return t.remove(),{left:r,top:d}},sn=(l,e,n)=>{const t=Y(16),[o,s]=oe(null);let r;t[0]!==l||t[1]!==e?(r=(v,p)=>{const h=Zt(v,p,l);if(h.length===0){s(null);return}const S=e.current,{left:w,top:C}=S===null?{left:0,top:0}:nn(S,p);s(T=>T!==null&&T.active===0&&T.left===w&&T.top===C&&T.suggestions.length===h.length&&T.suggestions.every((R,I)=>{const N=h.at(I);return R.kind===N?.kind&&R.label===N.label&&R.detail===N.detail})?T:{active:0,left:w,suggestions:h,top:C})},t[0]=l,t[1]=e,t[2]=r):r=t[2];const d=r;let a;t[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{s(null)},t[3]=a):a=t[3];const i=a;let m;t[4]===Symbol.for("react.memo_cache_sentinel")?(m=v=>{s(p=>{if(p===null)return p;const h=p.suggestions.length,S=(p.active+v+h)%h;return{...p,active:S}})},t[4]=m):m=t[4];const b=m;let u;t[5]!==n||t[6]!==o||t[7]!==e?(u=v=>{const p=e.current;if(o===null||p===null)return!1;const h=o.suggestions[v??o.active];if(h===void 0)return!1;const S=en(p.value,p.selectionStart,h);return n(S.value),s(null),requestAnimationFrame(()=>{const w=e.current;w!==null&&(w.focus(),w.setSelectionRange(S.caret,S.caret))}),!0},t[5]=n,t[6]=o,t[7]=e,t[8]=u):u=t[8];const x=u;let c;t[9]!==x?(c=()=>x(),t[9]=x,t[10]=c):c=t[10];const g=c;let y;return t[11]!==g||t[12]!==x||t[13]!==d||t[14]!==o?(y={close:i,commit:g,commitAt:x,move:b,refresh:d,state:o},t[11]=g,t[12]=x,t[13]=d,t[14]=o,t[15]=y):y=t[15],y},on={column:"column",keyword:"keyword",table:"table"},ln=20,rn=l=>{const e=Y(17),{listboxId:n,onPick:t,state:o}=l,s=le();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 d=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 m;e[8]!==n||e[9]!==t||e[10]!==o.active||e[11]!==s?(m=(b,u)=>$("li",{"aria-selected":u===o.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",u===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${n}-opt-${u.toString()}`,onMouseDown:x=>{x.preventDefault(),t(u)},role:"option",children:[f("span",{className:"truncate font-mono",children:b.label}),b.detail!==void 0&&f("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:b.detail}),f("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:s(on[b.kind])})]},`${b.kind}:${b.label}`),e[8]=n,e[9]=t,e[10]=o.active,e[11]=s,e[12]=m):m=e[12],a=o.suggestions.map(m),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]!==d||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:d,children:a}),e[13]=n,e[14]=d,e[15]=a,e[16]=i):i=e[16],i},an=Le(Re.listTables),cn=Le(Re.readTablePage),dn=l=>{const e=Y(16),n=Oe();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[o,s]=oe(t);let r;e[1]===Symbol.for("react.memo_cache_sentinel")?(r={},e[1]=r):r=e[1];const[d,a]=oe(r);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[2]=i):i=e[2];const m=Se(i);let b,u;e[3]!==n||e[4]!==l?(b=()=>{const p={cancelled:!1};return ce((async()=>{try{const S=await n.query(an,{},Te(l));p.cancelled||(s(S.map(fn)),a({}),m.current=new Set)}catch{p.cancelled||(s([]),a({}),m.current=new Set)}})()),()=>{p.cancelled=!0}},u=[n,l],e[3]=n,e[4]=l,e[5]=b,e[6]=u):(b=e[5],u=e[6]),Ee(b,u);let x;e[7]!==n||e[8]!==l?(x=p=>{if(m.current.has(p))return;m.current.add(p),ce((async()=>{try{const S=await n.query(cn,{limit:1,offset:0,table:p},Te(l));a(w=>({...w,[p]:S.columns}))}catch{m.current.delete(p)}})())},e[7]=n,e[8]=l,e[9]=x):x=e[9];const c=x;let g;e[10]!==d||e[11]!==o?(g={columns:d,tables:o},e[10]=d,e[11]=o,e[12]=g):g=e[12];const y=g;let v;return e[13]!==c||e[14]!==y?(v={probe:c,schema:y},e[13]=c,e[14]=y,e[15]=v):v=e[15],v},Ae=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,un=l=>{const e=new Set;Ae.lastIndex=0;let n=Ae.exec(l);for(;n!==null;)e.add(n[1]??n[2]),n=Ae.exec(l);return[...e]};function fn(l){return l.name}const mn=l=>{const e=Y(34),{onSubmit:n,probe:t,schema:o,setDraft:s}=l,r=et(),d=Se(null),a=Se(null),i=Se(null),m=sn(o,i,s),{close:b,commit:u,commitAt:x,move:c,refresh:g,state:y}=m;let v;e[0]!==x?(v=E=>{x(E)},e[0]=x,e[1]=v):v=e[1];const p=v;let h;e[2]!==g?(h=()=>{const E=i.current;E!==null&&E===document.activeElement&&g(E.value,E.selectionStart)},e[2]=g,e[3]=h):h=e[3];let S;e[4]!==g||e[5]!==o?(S=[g,o],e[4]=g,e[5]=o,e[6]=S):S=e[6],Ee(h,S);let w;e[7]!==t||e[8]!==g||e[9]!==s?(w=E=>{const{selectionStart:B,value:F}=E.target;s(F);for(const W of un(F))t(W);g(F,B)},e[7]=t,e[8]=g,e[9]=s,e[10]=w):w=e[10];const C=w;let T;e[11]!==g?(T=E=>{const B=E.currentTarget;g(B.value,B.selectionStart)},e[11]=g,e[12]=T):T=e[12];const L=T;let R;e[13]!==y||e[14]!==b||e[15]!==u||e[16]!==c||e[17]!==n?(R=E=>{if(y!==null){if(E.key==="ArrowDown"){E.preventDefault(),c(1);return}if(E.key==="ArrowUp"){E.preventDefault(),c(-1);return}if(E.key==="Escape"){E.preventDefault(),b();return}if((E.key==="Enter"||E.key==="Tab")&&!E.metaKey&&!E.ctrlKey&&u()){E.preventDefault();return}}(E.metaKey||E.ctrlKey)&&E.key==="Enter"&&(E.preventDefault(),n())},e[13]=y,e[14]=b,e[15]=u,e[16]=c,e[17]=n,e[18]=R):R=e[18];const I=R;let N;e[19]!==b?(N=()=>{requestAnimationFrame(()=>{b()})},e[19]=b,e[20]=N):N=e[20];const _=N;let O;e[21]===Symbol.for("react.memo_cache_sentinel")?(O=E=>{const{scrollLeft:B,scrollTop:F}=E.currentTarget;d.current!==null&&(d.current.scrollTop=F),a.current!==null&&(a.current.scrollTop=F,a.current.scrollLeft=B)},e[21]=O):O=e[21];const A=O;let k;e[22]===Symbol.for("react.memo_cache_sentinel")?(k=E=>{const B=i.current;B===null||E.offset===void 0||(B.focus(),B.setSelectionRange(E.offset,E.offset+(E.length??0)))},e[22]=k):k=e[22];const q=k;let M;e[23]!==C||e[24]!==_||e[25]!==I||e[26]!==L?(M={onBlur:_,onChange:C,onKeyDown:I,onScroll:A,onSelect:L},e[23]=C,e[24]=_,e[25]=I,e[26]=L,e[27]=M):M=e[27];let D;return e[28]!==y||e[29]!==b||e[30]!==r||e[31]!==p||e[32]!==M?(D={autocompleteState:y,closeAutocomplete:b,handlers:M,listboxId:r,onPickSuggestion:p,editorRef:i,gutterRef:d,overlayRef:a,revealDiagnostic:q},e[28]=y,e[29]=b,e[30]=r,e[31]=p,e[32]=M,e[33]=D):D=e[33],D},hn="lunora-studio-sql-tabs",pn="lunora-studio-sql-active-tab",Me=12,ve=(l="",e="")=>({activeId:null,id:ze("tab"),name:e,sql:l}),bn=()=>Ue(pn,""),gn=l=>{const e=Y(16),[n,t]=_e(hn),[o,s]=bn(),[r]=oe(l);let d,a;e[0]!==r||e[1]!==t||e[2]!==n.length?(d=()=>{n.length===0&&t([r])},a=[r,t,n.length],e[0]=r,e[1]=t,e[2]=n.length,e[3]=d,e[4]=a):(d=e[3],a=e[4]),Ee(d,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 m=i;let b;e[8]!==o||e[9]!==m?(b=m.some(c=>c.id===o)?o:m[0]?.id??"",e[8]=o,e[9]=m,e[10]=b):b=e[10];const u=b;let x;return e[11]!==u||e[12]!==s||e[13]!==t||e[14]!==m?(x={activeId:u,setActiveId:s,setTabs:t,tabs:m},e[11]=u,e[12]=s,e[13]=t,e[14]=m,e[15]=x):x=e[15],x},Ve=l=>l.activeId===null&&l.sql.trim()!=="",xn=(l,e)=>[...l,e].slice(-Me),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}},vn=(l,e)=>{const n=l.filter(t=>t.id===e);return n.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:n}},Sn=(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}},wn=l=>{const e=l();return{activeId:e.id,tabs:[e]}},Cn=(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]},Qe={error:null,pane:"results",result:null,running:!1},Nn=l=>{const e=Y(66),{activeId:n,setActiveId:t,setTabs:o,tabs:s}=gn(l);let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},e[0]=r):r=e[0];const[d,a]=oe(r),[i,m]=oe(null),[b,u]=oe(null);let x;e[1]!==n||e[2]!==s?(x=s.find(H=>H.id===n)??s[0]??ve(),e[1]=n,e[2]=s,e[3]=x):x=e[3];const c=x,g=d[c.id]??Qe;let y;e[4]!==c.id||e[5]!==o?(y=H=>{o(z=>z.map(j=>j.id===c.id?{...j,...H}:j))},e[4]=c.id,e[5]=o,e[6]=y):y=e[6];const v=y;let p;e[7]!==c.id?(p=H=>{a(z=>{const j=z[c.id]??Qe;return{...z,[c.id]:{...j,...H}}})},e[7]=c.id,e[8]=p):p=e[8];const h=p;let S;e[9]!==t||e[10]!==o||e[11]!==s.length?(S=()=>{if(s.length>=Me)return;const H=ve();o(z=>xn(z,H)),t(H.id)},e[9]=t,e[10]=o,e[11]=s.length,e[12]=S):S=e[12];const w=S;let C;e[13]!==t||e[14]!==o?(C=H=>{m(null),u(null),o(H.tabs),t(H.activeId);const z=new Set(H.tabs.map(Tn));a(j=>Object.fromEntries(Object.entries(j).filter(ie=>{const[ye]=ie;return z.has(ye)})))},e[13]=t,e[14]=o,e[15]=C):C=e[15];const T=C;let L;e[16]!==T||e[17]!==s?(L=H=>{T(yn(s,H,ve))},e[16]=T,e[17]=s,e[18]=L):L=e[18];const R=L;let I;e[19]!==n||e[20]!==T||e[21]!==s?(I=(H,z)=>{T(H==="others"?vn(s,z):H==="right"?Sn(s,z,n):wn(ve))},e[19]=n,e[20]=T,e[21]=s,e[22]=I):I=e[22];const N=I;let _;e[23]!==N||e[24]!==i||e[25]!==s?(_=H=>{i!==null&&(Cn(H,s,i.id).some(kn)?u(H):N(H,i.id))},e[23]=N,e[24]=i,e[25]=s,e[26]=_):_=e[26];const O=_;let A;e[27]===Symbol.for("react.memo_cache_sentinel")?(A=(H,z)=>{z.preventDefault(),u(null),m({id:H,x:z.clientX,y:z.clientY})},e[27]=A):A=e[27];const k=A;let q;e[28]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{m(null),u(null)},e[28]=q):q=e[28];const M=q;let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=H=>{H.preventDefault(),m(null),u(null)},e[29]=D):D=e[29];const E=D;let B;e[30]!==O?(B=()=>{O("others")},e[30]=O,e[31]=B):B=e[31];const F=B;let W;e[32]!==O?(W=()=>{O("right")},e[32]=O,e[33]=W):W=e[33];const U=W;let Q;e[34]!==O?(Q=()=>{O("all")},e[34]=O,e[35]=Q):Q=e[35];const K=Q;let G;e[36]!==N||e[37]!==b||e[38]!==i?(G=()=>{i!==null&&b!==null&&N(b,i.id),u(null)},e[36]=N,e[37]=b,e[38]=i,e[39]=G):G=e[39];const P=G;let V;e[40]===Symbol.for("react.memo_cache_sentinel")?(V=()=>{u(null)},e[40]=V):V=e[40];const ne=V;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 X=J;let Z;e[43]!==o?(Z=H=>{o(z=>z.map(j=>j.activeId===H?{...j,activeId:null}:j))},e[43]=o,e[44]=Z):Z=e[44];const ee=Z;let te;e[45]!==o?(te=(H,z)=>{o(j=>j.map(ie=>ie.id===H?{...ie,name:z}:ie))},e[45]=o,e[46]=te):te=e[46];const se=te;let ae;return e[47]!==c||e[48]!==n||e[49]!==w||e[50]!==R||e[51]!==P||e[52]!==K||e[53]!==F||e[54]!==U||e[55]!==g||e[56]!==h||e[57]!==v||e[58]!==b||e[59]!==se||e[60]!==t||e[61]!==i||e[62]!==X||e[63]!==s||e[64]!==ee?(ae={activeTab:c,activeTabId:n,addEditorTab:w,cancelBulk:ne,closeEditorTab:R,closeTabMenu:M,confirmBulk:P,menuStyle:X,onBackdropContextMenu:E,onCloseAll:K,onCloseOthers:F,onCloseToRight:U,openTabMenu:k,output:g,patchActiveOutput:h,patchActiveTab:v,pendingBulk:b,renameTab:se,setActiveTabId:t,tabMenu:i,tabs:s,unlinkQuery:ee},e[47]=c,e[48]=n,e[49]=w,e[50]=R,e[51]=P,e[52]=K,e[53]=F,e[54]=U,e[55]=g,e[56]=h,e[57]=v,e[58]=b,e[59]=se,e[60]=t,e[61]=i,e[62]=X,e[63]=s,e[64]=ee,e[65]=ae):ae=e[65],ae};function Tn(l){return l.id}function kn(l){return Ve(l)}const En="lunora-studio-sql-queries",Rn="lunora-studio-sql-history",Ln=25,In=l=>{const e=Y(33),{loadIntoActiveTab:n,unlinkQuery:t}=l,o=le(),[s,r]=_e(En),[d,a]=_e(Rn),[i,m]=oe(""),b=Se(null);let u;e[0]!==a?(u=k=>{a(q=>q[0]?.sql===k?q:[{at:Date.now(),sql:k},...q.filter(D=>D.sql!==k)].slice(0,Ln))},e[0]=a,e[1]=u):u=e[1];const x=u;let c;e[2]!==n||e[3]!==r||e[4]!==o?(c=()=>{const k={id:ze("q"),name:o("Untitled query"),sql:""};r(q=>[k,...q]),n("",k.id)},e[2]=n,e[3]=r,e[4]=o,e[5]=c):c=e[5];const g=c;let y;e[6]!==n||e[7]!==s?(y=k=>{const q=s.find(M=>M.id===k);q!==void 0&&(n(q.sql,k),b.current?.querySelector(`[data-testid="sql-query-${k}"]`)?.scrollIntoView({block:"nearest"}))},e[6]=n,e[7]=s,e[8]=y):y=e[8];const v=y;let p;e[9]!==r||e[10]!==t?(p=k=>{r(q=>q.filter(M=>M.id!==k)),t(k)},e[9]=r,e[10]=t,e[11]=p):p=e[11];const h=p;let S;e[12]!==n?(S=k=>{n(k.currentTarget.dataset.sql??"",null)},e[12]=n,e[13]=S):S=e[13];const w=S;let C;e[14]!==n?(C=k=>{n(k.currentTarget.dataset.sql??"",null)},e[14]=n,e[15]=C):C=e[15];const T=C;let L;e[16]!==a?(L=()=>{a([])},e[16]=a,e[17]=L):L=e[17];const R=L;let I;e[18]===Symbol.for("react.memo_cache_sentinel")?(I=k=>{m(k.target.value)},e[18]=I):I=e[18];const N=I;let _;e[19]!==r?(_=(k,q)=>{r(M=>M.map(D=>D.id===k?{...D,sql:q}:D))},e[19]=r,e[20]=_):_=e[20];const O=_;let A;return e[21]!==R||e[22]!==h||e[23]!==d||e[24]!==T||e[25]!==w||e[26]!==g||e[27]!==s||e[28]!==x||e[29]!==i||e[30]!==v||e[31]!==O?(A={clearHistory:R,deleteQuery:h,history:d,listRef:b,loadFromHistory:T,loadTemplate:w,newQuery:g,onSearchChange:N,queries:s,recordHistory:x,search:i,selectQuery:v,updateQuerySql:O},e[21]=R,e[22]=h,e[23]=d,e[24]=T,e[25]=w,e[26]=g,e[27]=s,e[28]=x,e[29]=i,e[30]=v,e[31]=O,e[32]=A):A=e[32],A},Je="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",qn=(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},An=l=>l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached.",_n=l=>{const e=Y(51),{assistant:n,failed:t,onGenerated:o}=l,s=le(),[r,d]=oe("");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 m;if(e[2]!==n||e[3]!==t||e[4]!==o||e[5]!==i||e[6]!==r||e[7]!==s){const b=n.reason("sql");let u;e[9]!==n||e[10]!==t||e[11]!==o||e[12]!==r?(u=N=>{const _=r.trim();if(_===""&&!N)return;ce((async()=>{const A=await n.generate(_===""?"fix the failing statement":_,N?t:void 0);A!==void 0&&o(A)})())},e[9]=n,e[10]=t,e[11]=o,e[12]=r,e[13]=u):u=e[13];const x=u;let c;e[14]!==s?(c=s("Describe the query you want"),e[14]=s,e[15]=c):c=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=N=>{d(N.target.value)},e[16]=g):g=e[16];let y;e[17]!==x?(y=N=>{N.key==="Enter"&&(N.preventDefault(),x(!1))},e[17]=x,e[18]=y):y=e[18];let v;e[19]!==s?(v=s("Describe the query you want"),e[19]=s,e[20]=v):v=e[20];let p;e[21]!==i||e[22]!==r||e[23]!==c||e[24]!==y||e[25]!==v?(p=f(ot,{"aria-label":c,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:i,onChange:g,onKeyDown:y,placeholder:v,value:r}),e[21]=i,e[22]=r,e[23]=c,e[24]=y,e[25]=v,e[26]=p):p=e[26];const h=i&&"opacity-60";let S;e[27]!==h?(S=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",h),e[27]=h,e[28]=S):S=e[28];let w;e[29]!==i||e[30]!==r?(w=i||r.trim()==="",e[29]=i,e[30]=r,e[31]=w):w=e[31];let C;e[32]!==x?(C=()=>{x(!1)},e[32]=x,e[33]=C):C=e[33];let T;e[34]!==i||e[35]!==s?(T=s(i?"Thinking…":"Draft SQL"),e[34]=i,e[35]=s,e[36]=T):T=e[36];let L;e[37]!==S||e[38]!==w||e[39]!==C||e[40]!==T?(L=f("button",{className:S,"data-testid":"sql-assistant-generate",disabled:w,onClick:C,type:"button",children:T}),e[37]=S,e[38]=w,e[39]=C,e[40]=T,e[41]=L):L=e[41];let R;e[42]!==t||e[43]!==i||e[44]!==x||e[45]!==s?(R=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:()=>{x(!0)},type:"button",children:s("Fix this")}),e[42]=t,e[43]=i,e[44]=x,e[45]=s,e[46]=R):R=e[46];let I;e[47]!==L||e[48]!==R||e[49]!==p?(I=$("div",{className:"flex items-center gap-2",children:[p,L,R]}),e[47]=L,e[48]=R,e[49]=p,e[50]=I):I=e[50],m=$("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[I,b!==void 0&&f("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:An(b)})]}),e[2]=n,e[3]=t,e[4]=o,e[5]=i,e[6]=r,e[7]=s,e[8]=m}else m=e[8];return m},On=l=>{const e=Y(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=qn(n,t.length);if(i.length===0){r=null;break e}s=[];let m=0;for(const[b,u]of i.entries())u.start>m&&s.push(t.slice(m,u.start)),s.push(f("span",{className:ue("decoration-wavy underline underline-offset-4",u.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(u.start,u.end)},`${u.start.toString()}-${b.toString()}`)),m=u.end;s.push(t.slice(m))}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 d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",Je),e[4]=d):d=e[4];let a;return e[5]!==s||e[6]!==o?(a=f("div",{"aria-hidden":"true",className:d,"data-testid":"sql-diagnostics-overlay",ref:o,children:s}),e[5]=s,e[6]=o,e[7]=a):a=e[7],a},Dn={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Mn=l=>{const e=Y(10),{diagnostics:n,onSelect:t}=l,o=le();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,m)=>f("li",{children:$("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:ue("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:Dn[i.source]}),f("span",{className:"min-w-0 text-muted-foreground",children:i.message})]})},`${i.source}-${(i.offset??m).toString()}-${m.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 d;return e[7]!==s||e[8]!==r?(d=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]=d):d=e[9],d},$n={minWidth:"2.75rem",paddingInline:"0.5rem"},Bn=l=>{const e=Y(64),{assistant:n,autocomplete:t,diagnostics:o,draft:s,failed:r,handlers:d,editorRef:a,gutterRef:i,listboxId:m,onGenerated:b,onPickSuggestion:u,onRevealDiagnostic:x,overlayRef:c}=l,g=le();let y,v,p,h,S,w,C,T;if(e[0]!==n||e[1]!==s||e[2]!==r||e[3]!==i||e[4]!==b){const B=s.split(`
|
|
5
|
+
`).length;C="flex min-h-0 min-w-0 flex-1 flex-col",e[13]!==n||e[14]!==r||e[15]!==b?(T=f(_n,{assistant:n,failed:r,onGenerated:b}),e[13]=n,e[14]=r,e[15]=b,e[16]=T):T=e[16],w="flex min-h-0 min-w-0 flex-1",y="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",p=i,h=$n,S=Array.from({length:B},Pn),e[0]=n,e[1]=s,e[2]=r,e[3]=i,e[4]=b,e[5]=y,e[6]=v,e[7]=p,e[8]=h,e[9]=S,e[10]=w,e[11]=C,e[12]=T}else y=e[5],v=e[6],p=e[7],h=e[8],S=e[9],w=e[10],C=e[11],T=e[12];let L;e[17]!==y||e[18]!==v||e[19]!==p||e[20]!==h||e[21]!==S?(L=f("div",{"aria-hidden":y,className:v,ref:p,style:h,children:S}),e[17]=y,e[18]=v,e[19]=p,e[20]=h,e[21]=S,e[22]=L):L=e[22];let R;e[23]!==o||e[24]!==s||e[25]!==c?(R=f(On,{diagnostics:o,draft:s,scrollRef:c}),e[23]=o,e[24]=s,e[25]=c,e[26]=R):R=e[26];let I;e[27]!==t||e[28]!==m?(I=t===null?void 0:`${m}-opt-${t.active.toString()}`,e[27]=t,e[28]=m,e[29]=I):I=e[29];const N=t===null?void 0:m,_=t!==null;let O;e[30]!==g?(O=g("SQL query"),e[30]=g,e[31]=O):O=e[31];let A;e[32]!==s||e[33]!==a||e[34]!==d.onBlur||e[35]!==d.onChange||e[36]!==d.onKeyDown||e[37]!==d.onScroll||e[38]!==d.onSelect||e[39]!==I||e[40]!==N||e[41]!==_||e[42]!==O?(A=f("textarea",{"aria-activedescendant":I,"aria-autocomplete":"list","aria-controls":N,"aria-expanded":_,"aria-label":O,className:`relative size-full resize-none bg-transparent outline-none ${Je}`,"data-testid":"sql-input",onBlur:d.onBlur,onChange:d.onChange,onKeyDown:d.onKeyDown,onScroll:d.onScroll,onSelect:d.onSelect,placeholder:"SELECT * FROM …",ref:a,role:"combobox",spellCheck:!1,value:s}),e[32]=s,e[33]=a,e[34]=d.onBlur,e[35]=d.onChange,e[36]=d.onKeyDown,e[37]=d.onScroll,e[38]=d.onSelect,e[39]=I,e[40]=N,e[41]=_,e[42]=O,e[43]=A):A=e[43];let k;e[44]!==t||e[45]!==m||e[46]!==u?(k=f(rn,{listboxId:m,onPick:u,state:t}),e[44]=t,e[45]=m,e[46]=u,e[47]=k):k=e[47];let q;e[48]!==R||e[49]!==A||e[50]!==k?(q=$("div",{className:"relative min-w-0 flex-1 bg-background",children:[R,A,k]}),e[48]=R,e[49]=A,e[50]=k,e[51]=q):q=e[51];let M;e[52]!==q||e[53]!==w||e[54]!==L?(M=$("div",{className:w,children:[L,q]}),e[52]=q,e[53]=w,e[54]=L,e[55]=M):M=e[55];let D;e[56]!==o||e[57]!==x?(D=f(Mn,{diagnostics:o,onSelect:x}),e[56]=o,e[57]=x,e[58]=D):D=e[58];let E;return e[59]!==M||e[60]!==D||e[61]!==C||e[62]!==T?(E=$("div",{className:C,children:[T,M,D]}),e[59]=M,e[60]=D,e[61]=C,e[62]=T,e[63]=E):E=e[63],E};function Pn(l,e){return f("div",{children:e+1},e)}const Xe=[{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;"}],Hn=l=>{const e=Y(29),{active:n,onDelete:t,onSelect:o,query:s}=l,r=le();let d;e[0]!==o||e[1]!==s.id?(d=()=>{o(s.id)},e[0]=o,e[1]=s.id,e[2]=d):d=e[2];const a=d;let i;e[3]!==t||e[4]!==s.id?(i=C=>{C.stopPropagation(),t(s.id)},e[3]=t,e[4]=s.id,e[5]=i):i=e[5];const m=i,b=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground";let u;e[6]!==b?(u=ue("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",b),e[6]=b,e[7]=u):u=e[7];const x=`sql-query-${s.id}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=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]=c):c=e[8];let g;e[9]!==s.name?(g=f("span",{className:"truncate",children:s.name}),e[9]=s.name,e[10]=g):g=e[10];let y;e[11]!==n||e[12]!==a||e[13]!==u||e[14]!==x||e[15]!==g?(y=$("button",{"aria-pressed":n,className:u,"data-testid":x,onClick:a,type:"button",children:[c,g]}),e[11]=n,e[12]=a,e[13]=u,e[14]=x,e[15]=g,e[16]=y):y=e[16];let v;e[17]!==r?(v=r("Delete query"),e[17]=r,e[18]=v):v=e[18];let p;e[19]!==r?(p=r("Delete query"),e[19]=r,e[20]=p):p=e[20];let h;e[21]===Symbol.for("react.memo_cache_sentinel")?(h=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]=h):h=e[21];let S;e[22]!==m||e[23]!==p||e[24]!==v?(S=f("button",{"aria-label":v,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:m,title:p,type:"button",children:h}),e[22]=m,e[23]=p,e[24]=v,e[25]=S):S=e[25];let w;return e[26]!==S||e[27]!==y?(w=$("li",{className:"group/q flex items-center",children:[y,S]}),e[26]=S,e[27]=y,e[28]=w):w=e[28],w},Wn=(l,e)=>{const n=e.trim().toLowerCase();return n===""?[...l]:l.filter(t=>t.name.toLowerCase().includes(n))},Fn=l=>{const e=Y(60),{activeId:n,history:t,listRef:o,onClearHistory:s,onDelete:r,onLoadHistory:d,onLoadTemplate:a,onNew:i,onSearchChange:m,onSelect:b,queries:u,search:x}=l,c=le();let g,y,v,p;if(e[0]!==n||e[1]!==o||e[2]!==r||e[3]!==i||e[4]!==m||e[5]!==b||e[6]!==u||e[7]!==x||e[8]!==c){const N=Wn(u,x);y="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let _;e[13]!==c?(_=c("Search queries…"),e[13]=c,e[14]=_):_=e[14];let O;e[15]!==m||e[16]!==x||e[17]!==_?(O=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:m,placeholder:_,type:"text",value:x}),e[15]=m,e[16]=x,e[17]=_,e[18]=O):O=e[18];let A;e[19]!==c?(A=c("New query"),e[19]=c,e[20]=A):A=e[20];let k;e[21]!==c?(k=c("New query"),e[21]=c,e[22]=k):k=e[22];let q;e[23]===Symbol.for("react.memo_cache_sentinel")?(q=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[23]=q):q=e[23];let M;e[24]!==i||e[25]!==A||e[26]!==k?(M=f("button",{"aria-label":A,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:k,type:"button",children:q}),e[24]=i,e[25]=A,e[26]=k,e[27]=M):M=e[27],e[28]!==M||e[29]!==O?(v=$("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[O,M]}),e[28]=M,e[29]=O,e[30]=v):v=e[30],g="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let D;e[31]!==c?(D=c("Private"),e[31]=c,e[32]=D):D=e[32];let E;e[33]!==D?(E=f("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:D}),e[33]=D,e[34]=E):E=e[34],p=$("div",{children:[E,N.length===0?f("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:c("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:N.map(B=>f(Hn,{active:n===B.id,onDelete:r,onSelect:b,query:B},B.id))})]}),e[0]=n,e[1]=o,e[2]=r,e[3]=i,e[4]=m,e[5]=b,e[6]=u,e[7]=x,e[8]=c,e[9]=g,e[10]=y,e[11]=v,e[12]=p}else g=e[9],y=e[10],v=e[11],p=e[12];let h;e[35]!==c?(h=c("Reference"),e[35]=c,e[36]=h):h=e[36];let S;e[37]!==h?(S=f("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:h}),e[37]=h,e[38]=S):S=e[38];let w;e[39]!==a?(w=Xe.map(N=>f("li",{children:$("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":N.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"})}),N.label]})},N.label)),e[39]=a,e[40]=w):w=e[40];let C;e[41]!==w?(C=f("ul",{className:"flex flex-col gap-px",children:w}),e[41]=w,e[42]=C):C=e[42];let T;e[43]!==S||e[44]!==C?(T=$("div",{children:[S,C]}),e[43]=S,e[44]=C,e[45]=T):T=e[45];let L;e[46]!==t||e[47]!==s||e[48]!==d||e[49]!==c?(L=t.length>0&&$("div",{children:[$("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:c("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:c("Clear history")})]}),f("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(N=>f("li",{children:$("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":N.sql,"data-testid":"sql-history-item",onClick:d,title:N.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:N.sql})]})},`${N.at.toString()}:${N.sql}`))})]}),e[46]=t,e[47]=s,e[48]=d,e[49]=c,e[50]=L):L=e[50];let R;e[51]!==g||e[52]!==L||e[53]!==p||e[54]!==T?(R=$("div",{className:g,children:[p,T,L]}),e[51]=g,e[52]=L,e[53]=p,e[54]=T,e[55]=R):R=e[55];let I;return e[56]!==R||e[57]!==y||e[58]!==v?(I=$("aside",{className:y,children:[v,R]}),e[56]=R,e[57]=y,e[58]=v,e[59]=I):I=e[59],I},Qn=l=>{const e=Y(19),{result:n}=l,t=le();if(n.columns.length===0){let i;e[0]!==n.rowCount||e[1]!==t?(i=t("{count} rows",{count:n.rowCount}),e[0]=n.rowCount,e[1]=t,e[2]=i):i=e[2];let m;return e[3]!==i?(m=f("p",{className:"p-4 text-sm text-muted-foreground",children:i}),e[3]=i,e[4]=m):m=e[4],m}let o;e[5]!==n.columns?(o=n.columns.map(zn),e[5]=n.columns,e[6]=o):o=e[6];let s;e[7]!==o?(s=f(dt,{className:"sticky top-0 z-10 bg-muted",children:f(He,{children:o})}),e[7]=o,e[8]=s):s=e[8];let r;if(e[9]!==n.columns||e[10]!==n.rows){let i;e[12]!==n.columns?(i=(m,b)=>f(He,{"data-testid":"sql-row",children:n.columns.map(u=>f(ut,{className:"max-w-md truncate font-mono text-xs",children:f(ht,{value:m[u]})},u))},b),e[12]=n.columns,e[13]=i):i=e[13],r=n.rows.map(i),e[9]=n.columns,e[10]=n.rows,e[11]=r}else r=e[11];let d;e[14]!==r?(d=f(ft,{children:r}),e[14]=r,e[15]=d):d=e[15];let a;return e[16]!==s||e[17]!==d?(a=$(mt,{"data-testid":"sql-rows",children:[s,d]}),e[16]=s,e[17]=d,e[18]=a):a=e[18],a};function zn(l){return f(ct,{children:l},l)}const Ne=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"}`,Un=l=>{const e=Y(92),{assistant:n,chart:t,className:o,error:s,onFormat:r,onInferChart:d,onRun:a,onShardKeyChange:i,onShowChart:m,onShowExplain:b,onShowResults:u,onToggleSplit:x,pane:c,result:g,running:y,shardKey:v,splitView:p}=l,h=le(),S=c==="results";let w;e[0]!==S?(w=Ne(S),e[0]=S,e[1]=w):w=e[1];let C;e[2]!==h?(C=h("Results"),e[2]=h,e[3]=C):C=e[3];let T;e[4]!==u||e[5]!==w||e[6]!==C?(T=f("button",{className:w,"data-testid":"sql-tab-results",onClick:u,type:"button",children:C}),e[4]=u,e[5]=w,e[6]=C,e[7]=T):T=e[7];const L=c==="chart";let R;e[8]!==L?(R=Ne(L),e[8]=L,e[9]=R):R=e[9];let I;e[10]!==h?(I=h("Chart"),e[10]=h,e[11]=I):I=e[11];let N;e[12]!==m||e[13]!==R||e[14]!==I?(N=f("button",{className:R,"data-testid":"sql-tab-chart",onClick:m,type:"button",children:I}),e[12]=m,e[13]=R,e[14]=I,e[15]=N):N=e[15];let _;e[16]!==n||e[17]!==d||e[18]!==c||e[19]!==g||e[20]!==h?(_=!n.unavailable&&c==="chart"&&g!==null&&f("button",{className:Ne(!1),"data-testid":"sql-infer-chart",disabled:n.pending("chart"),onClick:d,type:"button",children:n.pending("chart")?h("Thinking…"):h("Suggest chart")}),e[16]=n,e[17]=d,e[18]=c,e[19]=g,e[20]=h,e[21]=_):_=e[21];const O=c==="explain";let A;e[22]!==O?(A=Ne(O),e[22]=O,e[23]=A):A=e[23];let k;e[24]!==h?(k=h("Explain"),e[24]=h,e[25]=k):k=e[25];let q;e[26]!==b||e[27]!==A||e[28]!==k?(q=f("button",{className:A,"data-testid":"sql-tab-explain",onClick:b,type:"button",children:k}),e[26]=b,e[27]=A,e[28]=k,e[29]=q):q=e[29];let M;e[30]!==h?(M=h("Split editor and results"),e[30]=h,e[31]=M):M=e[31];const D=`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 ${p?"bg-accent text-foreground":"text-muted-foreground"}`;let E;e[32]!==h?(E=h("Split editor and results"),e[32]=h,e[33]=E):E=e[33];let B;e[34]===Symbol.for("react.memo_cache_sentinel")?(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]=B):B=e[34];let F;e[35]!==x||e[36]!==p||e[37]!==M||e[38]!==D||e[39]!==E?(F=f("button",{"aria-label":M,"aria-pressed":p,className:D,"data-testid":"sql-split-toggle",onClick:x,title:E,type:"button",children:B}),e[35]=x,e[36]=p,e[37]=M,e[38]=D,e[39]=E,e[40]=F):F=e[40];let W;e[41]!==g?(W=g!==null&&g.columns.length>0&&f(at,{columns:g.columns,name:"query-result",rows:g.rows}),e[41]=g,e[42]=W):W=e[42];let U;e[43]!==h?(U=h("Format"),e[43]=h,e[44]=U):U=e[44];let Q;e[45]!==r||e[46]!==y||e[47]!==U?(Q=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:y,onClick:r,type:"button",children:U}),e[45]=r,e[46]=y,e[47]=U,e[48]=Q):Q=e[48];let K;e[49]!==i||e[50]!==v?(K=f(rt,{onChange:i,testId:"sql-shard-input",value:v}),e[49]=i,e[50]=v,e[51]=K):K=e[51];let G;e[52]!==y||e[53]!==h?(G=h(y?"Running…":"Run"),e[52]=y,e[53]=h,e[54]=G):G=e[54];let P;e[55]===Symbol.for("react.memo_cache_sentinel")?(P=f("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"⌘↵"}),e[55]=P):P=e[55];let V;e[56]!==a||e[57]!==y||e[58]!==G?(V=$("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:y,onClick:a,type:"button",children:[G,P]}),e[56]=a,e[57]=y,e[58]=G,e[59]=V):V=e[59];let ne;e[60]!==F||e[61]!==W||e[62]!==Q||e[63]!==K||e[64]!==V?(ne=$("div",{className:"ms-auto flex items-center gap-2",children:[F,W,Q,K,V]}),e[60]=F,e[61]=W,e[62]=Q,e[63]=K,e[64]=V,e[65]=ne):ne=e[65];let J;e[66]!==q||e[67]!==ne||e[68]!==T||e[69]!==N||e[70]!==_?(J=$("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[T,N,_,q,ne]}),e[66]=q,e[67]=ne,e[68]=T,e[69]=N,e[70]=_,e[71]=J):J=e[71];let X;e[72]!==s?(X=s!==null&&f(it,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:s}),e[72]=s,e[73]=X):X=e[73];let Z;e[74]!==s||e[75]!==g||e[76]!==h?(Z=s===null&&g===null&&f("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:h("Click Run to execute your query.")}),e[74]=s,e[75]=g,e[76]=h,e[77]=Z):Z=e[77];let ee;e[78]!==t||e[79]!==s||e[80]!==c||e[81]!==g||e[82]!==h?(ee=s===null&&g!==null&&$("div",{"data-testid":"sql-result",children:[c==="chart"?f(lt,{axes:t,result:g}):f(Qn,{result:g}),f("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:g.truncated?h("Showing the first {max} of {count} rows.",{count:g.rowCount,max:g.rows.length}):h("{count} rows",{count:g.rowCount})})]}),e[78]=t,e[79]=s,e[80]=c,e[81]=g,e[82]=h,e[83]=ee):ee=e[83];let te;e[84]!==X||e[85]!==Z||e[86]!==ee?(te=$("div",{className:"min-h-0 flex-1 overflow-auto",children:[X,Z,ee]}),e[84]=X,e[85]=Z,e[86]=ee,e[87]=te):te=e[87];let se;return e[88]!==o||e[89]!==J||e[90]!==te?(se=$("div",{className:o,children:[J,te]}),e[88]=o,e[89]=J,e[90]=te,e[91]=se):se=e[91],se},Yn=(l,e)=>l.trim()===""?e:(l.split(`
|
|
6
|
+
`)[0]??l).slice(0,24),jn=l=>{l?.focus(),l?.select()},Kn=l=>{const e=Y(14),{initial:n,onCancel:t,onCommit:o,placeholder:s,testId:r}=l,d=le();let a;e[0]!==o?(a=c=>{o(c.currentTarget.value.trim())},e[0]=o,e[1]=a):a=e[1];const i=a;let m;e[2]!==t||e[3]!==o?(m=c=>{c.key==="Enter"?o(c.currentTarget.value.trim()):c.key==="Escape"&&t()},e[2]=t,e[3]=o,e[4]=m):m=e[4];const b=m;let u;e[5]!==d?(u=d("Tab title"),e[5]=d,e[6]=u):u=e[6];let x;return e[7]!==n||e[8]!==i||e[9]!==b||e[10]!==s||e[11]!==u||e[12]!==r?(x=f("input",{"aria-label":u,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:b,placeholder:s,ref:jn,type:"text"}),e[7]=n,e[8]=i,e[9]=b,e[10]=s,e[11]=u,e[12]=r,e[13]=x):x=e[13],x},Gn=l=>{const e=Y(29),{idBase:n,onDiscard:t,onKeep:o}=l,s=le(),r=`sql-tab-close-prompt-${n}`;let d;e[0]!==s?(d=s("Discard?"),e[0]=s,e[1]=d):d=e[1];let a;e[2]!==d?(a=f("span",{className:"text-[11px] text-muted-foreground",children:d}),e[2]=d,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 m=`sql-tab-close-confirm-${n}`;let b;e[6]!==s?(b=s("Discard changes"),e[6]=s,e[7]=b):b=e[7];let u;e[8]===Symbol.for("react.memo_cache_sentinel")?(u=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]=u):u=e[8];let x;e[9]!==t||e[10]!==i||e[11]!==m||e[12]!==b?(x=f("button",{"aria-label":i,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":m,onClick:t,title:b,type:"button",children:u}),e[9]=t,e[10]=i,e[11]=m,e[12]=b,e[13]=x):x=e[13];let c;e[14]!==s?(c=s("Keep editing"),e[14]=s,e[15]=c):c=e[15];const g=`sql-tab-close-cancel-${n}`;let y;e[16]!==s?(y=s("Keep editing"),e[16]=s,e[17]=y):y=e[17];let v;e[18]===Symbol.for("react.memo_cache_sentinel")?(v=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]=v):v=e[18];let p;e[19]!==o||e[20]!==g||e[21]!==y||e[22]!==c?(p=f("button",{"aria-label":c,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":g,onClick:o,title:y,type:"button",children:v}),e[19]=o,e[20]=g,e[21]=y,e[22]=c,e[23]=p):p=e[23];let h;return e[24]!==r||e[25]!==p||e[26]!==a||e[27]!==x?(h=$("span",{className:"flex shrink-0 items-center gap-1","data-testid":r,role:"group",children:[a,x,p]}),e[24]=r,e[25]=p,e[26]=a,e[27]=x,e[28]=h):h=e[28],h},Vn=l=>{const e=Y(47),{active:n,canClose:t,onClose:o,onMenu:s,onRename:r,onSelect:d,tab:a}=l,i=le(),[m,b]=oe(!1),[u,x]=oe(!1);let c;e[0]!==s||e[1]!==a.id?(c=Q=>{s(a.id,Q)},e[0]=s,e[1]=a.id,e[2]=c):c=e[2];const g=c;let y;e[3]!==d||e[4]!==a.id?(y=()=>{d(a.id)},e[3]=d,e[4]=a.id,e[5]=y):y=e[5];const v=y;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{b(!0)},e[6]=p):p=e[6];const h=p;let S;e[7]!==o||e[8]!==a?(S=Q=>{Q.stopPropagation(),Ve(a)?x(!0):o(a.id)},e[7]=o,e[8]=a,e[9]=S):S=e[9];const w=S;let C;e[10]!==o||e[11]!==a.id?(C=Q=>{Q.stopPropagation(),x(!1),o(a.id)},e[10]=o,e[11]=a.id,e[12]=C):C=e[12];const T=C;let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=Q=>{Q.stopPropagation(),x(!1)},e[13]=L):L=e[13];const R=L;let I;e[14]!==r||e[15]!==a.id?(I=Q=>{r(a.id,Q),b(!1)},e[14]=r,e[15]=a.id,e[16]=I):I=e[16];const N=I;let _;e[17]===Symbol.for("react.memo_cache_sentinel")?(_=()=>{b(!1)},e[17]=_):_=e[17];const O=_;let A;e[18]!==a.name?(A=a.name.trim(),e[18]=a.name,e[19]=A):A=e[19];const k=A;let q;e[20]!==i||e[21]!==a.sql?(q=Yn(a.sql,i("Untitled")),e[20]=i,e[21]=a.sql,e[22]=q):q=e[22];const M=q,D=n?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground";let E;e[23]!==D?(E=ue("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",D),e[23]=D,e[24]=E):E=e[24];const B=`sql-tab-${a.id}`;let F;e[25]!==n||e[26]!==N||e[27]!==k||e[28]!==M||e[29]!==m||e[30]!==v||e[31]!==i||e[32]!==a.id?(F=m?f(Kn,{initial:k,onCancel:O,onCommit:N,placeholder:M,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:v,onDoubleClick:h,title:i("Double-click to rename"),type:"button",children:k===""?M:k}),e[25]=n,e[26]=N,e[27]=k,e[28]=M,e[29]=m,e[30]=v,e[31]=i,e[32]=a.id,e[33]=F):F=e[33];let W;e[34]!==t||e[35]!==T||e[36]!==u||e[37]!==w||e[38]!==i||e[39]!==a.id?(W=t&&(u?f(Gn,{idBase:a.id,onDiscard:T,onKeep:R}):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:w,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]=T,e[36]=u,e[37]=w,e[38]=i,e[39]=a.id,e[40]=W):W=e[40];let U;return e[41]!==g||e[42]!==E||e[43]!==B||e[44]!==F||e[45]!==W?(U=$("div",{className:E,"data-testid":B,onContextMenu:g,children:[F,W]}),e[41]=g,e[42]=E,e[43]=B,e[44]=F,e[45]=W,e[46]=U):U=e[46],U},Jn=l=>{const e=Y(43),{model:n,onSelect:t}=l,o=le(),{activeTab:s,addEditorTab:r,cancelBulk:d,closeEditorTab:a,closeTabMenu:i,confirmBulk:m,menuStyle:b,onBackdropContextMenu:u,onCloseAll:x,onCloseOthers:c,onCloseToRight:g,openTabMenu:y,pendingBulk:v,renameTab:p,tabMenu:h,tabs:S}=n;let w;if(e[0]!==s||e[1]!==a||e[2]!==t||e[3]!==y||e[4]!==p||e[5]!==S){let A;e[7]!==s||e[8]!==a||e[9]!==t||e[10]!==y||e[11]!==p||e[12]!==S.length?(A=k=>f(Vn,{active:k.id===s.id,canClose:S.length>1,onClose:a,onMenu:y,onRename:p,onSelect:t,tab:k},k.id),e[7]=s,e[8]=a,e[9]=t,e[10]=y,e[11]=p,e[12]=S.length,e[13]=A):A=e[13],w=S.map(A),e[0]=s,e[1]=a,e[2]=t,e[3]=y,e[4]=p,e[5]=S,e[6]=w}else w=e[6];let C;e[14]!==o?(C=o("New tab"),e[14]=o,e[15]=C):C=e[15];const T=S.length>=Me;let L;e[16]!==o?(L=o("New tab"),e[16]=o,e[17]=L):L=e[17];let R;e[18]===Symbol.for("react.memo_cache_sentinel")?(R=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]=R):R=e[18];let I;e[19]!==r||e[20]!==C||e[21]!==T||e[22]!==L?(I=f("button",{"aria-label":C,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:T,onClick:r,title:L,type:"button",children:R}),e[19]=r,e[20]=C,e[21]=T,e[22]=L,e[23]=I):I=e[23];let N;e[24]!==w||e[25]!==I?(N=$("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:[w,I]}),e[24]=w,e[25]=I,e[26]=N):N=e[26];let _;e[27]!==d||e[28]!==i||e[29]!==m||e[30]!==b||e[31]!==u||e[32]!==x||e[33]!==c||e[34]!==g||e[35]!==v||e[36]!==o||e[37]!==h||e[38]!==S?(_=h!==null&&$(qe,{children:[f("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:i,onContextMenu:u,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:b,children:v===null?$(qe,{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:S.length<=1,onClick:c,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:S.findIndex(A=>A.id===h.id)>=S.length-1,onClick:g,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:x,role:"menuitem",type:"button",children:o("Close all tabs")})]}):$("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?")}),$("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:m,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:d,type:"button",children:o("Cancel")})]})]})})]}),e[27]=d,e[28]=i,e[29]=m,e[30]=b,e[31]=u,e[32]=x,e[33]=c,e[34]=g,e[35]=v,e[36]=o,e[37]=h,e[38]=S,e[39]=_):_=e[39];let O;return e[40]!==N||e[41]!==_?(O=$(qe,{children:[N,_]}),e[40]=N,e[41]=_,e[42]=O):O=e[42],O},Xn=Le(Re.runSql),Zn="lunora-studio-sql-split-view",es=()=>ve(Xe[0]?.sql??""),vs=l=>{const e=Y(102),{initialShardKey:n}=l,t=Oe(),o=Nn(es),{activeTab:s,output:r,patchActiveOutput:d,patchActiveTab:a,setActiveTabId:i,unlinkQuery:m}=o;let b;e[0]!==d||e[1]!==a?(b=(re,de)=>{a({activeId:de,sql:re}),d({chart:void 0,error:null,failed:void 0,result:null})},e[0]=d,e[1]=a,e[2]=b):b=e[2];const u=b;let x;e[3]!==u||e[4]!==m?(x={loadIntoActiveTab:u,unlinkQuery:m},e[3]=u,e[4]=m,e[5]=x):x=e[5];const c=In(x),{recordHistory:g,updateQuerySql:y}=c,v=s.sql,{activeId:p}=s,{chart:h,error:S,failed:w,result:C,running:T}=r,L=r.pane,[R,I]=oe(n??""),[N,_]=Ue(Zn,!1),{probe:O,schema:A}=dn(R);let k;e[6]!==p||e[7]!==a||e[8]!==y?(k=re=>{a({sql:re}),p!==null&&y(p,re)},e[6]=p,e[7]=a,e[8]=y,e[9]=k):k=e[9];const q=k,M=jt(v,A,R),D=nt(R);let E;e[10]!==D||e[11]!==d||e[12]!==C?(E=()=>{if(C===null)return;ce((async()=>{const de=await D.inferChart({columns:C.columns,rowCount:C.rowCount,types:Object.fromEntries(C.columns.map(xe=>[xe,typeof(C.rows[0]?.[xe]??"")]))});d({chart:de})})())},e[10]=D,e[11]=d,e[12]=C,e[13]=E):E=e[13];const B=E;let F;e[14]!==t||e[15]!==v||e[16]!==d||e[17]!==g||e[18]!==R?(F=async re=>{if(v.trim()==="")return;d({running:!0});const de=re==="explain"?`EXPLAIN QUERY PLAN ${v}`:v;try{const xe=await t.query(Xn,{sql:de},Te(R));d({chart:void 0,error:null,failed:void 0,pane:re,result:xe,running:!1}),tt(R),g(de)}catch(xe){const $e=xe;d({chart:void 0,error:Pe($e),failed:{error:Pe($e),sql:de},pane:re,result:null,running:!1})}},e[14]=t,e[15]=v,e[16]=d,e[17]=g,e[18]=R,e[19]=F):F=e[19];const W=F;let U;e[20]!==W?(U=()=>{ce(W("results"))},e[20]=W,e[21]=U):U=e[21];const Q=U;let K;e[22]!==r.pane||e[23]!==W?(K=()=>{ce(W(r.pane))},e[22]=r.pane,e[23]=W,e[24]=K):K=e[24];let G;e[25]!==O||e[26]!==A||e[27]!==q||e[28]!==K?(G={onSubmit:K,probe:O,schema:A,setDraft:q},e[25]=O,e[26]=A,e[27]=q,e[28]=K,e[29]=G):G=e[29];const P=mn(G),{closeAutocomplete:V}=P;let ne;e[30]!==v||e[31]!==q?(ne=()=>{q(vt(v))},e[30]=v,e[31]=q,e[32]=ne):ne=e[32];const J=ne;let X;e[33]!==V||e[34]!==i?(X=re=>{V(),i(re)},e[33]=V,e[34]=i,e[35]=X):X=e[35];const Z=X;let ee;e[36]!==d?(ee=()=>{d({pane:"results"})},e[36]=d,e[37]=ee):ee=e[37];const te=ee;let se;e[38]!==W?(se=()=>{ce(W("explain"))},e[38]=W,e[39]=se):se=e[39];const ae=se;let H;e[40]!==d?(H=()=>{d({pane:"chart"})},e[40]=d,e[41]=H):H=e[41];const z=H;let j;e[42]!==_||e[43]!==N?(j=()=>{_(!N)},e[42]=_,e[43]=N,e[44]=j):j=e[44];const ie=j,ye=N?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",Ie=N?"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";let fe;e[45]!==p||e[46]!==c.clearHistory||e[47]!==c.deleteQuery||e[48]!==c.history||e[49]!==c.listRef||e[50]!==c.loadFromHistory||e[51]!==c.loadTemplate||e[52]!==c.newQuery||e[53]!==c.onSearchChange||e[54]!==c.queries||e[55]!==c.search||e[56]!==c.selectQuery?(fe=f(Fn,{activeId:p,history:c.history,listRef:c.listRef,onClearHistory:c.clearHistory,onDelete:c.deleteQuery,onLoadHistory:c.loadFromHistory,onLoadTemplate:c.loadTemplate,onNew:c.newQuery,onSearchChange:c.onSearchChange,onSelect:c.selectQuery,queries:c.queries,search:c.search}),e[45]=p,e[46]=c.clearHistory,e[47]=c.deleteQuery,e[48]=c.history,e[49]=c.listRef,e[50]=c.loadFromHistory,e[51]=c.loadTemplate,e[52]=c.newQuery,e[53]=c.onSearchChange,e[54]=c.queries,e[55]=c.search,e[56]=c.selectQuery,e[57]=fe):fe=e[57];let me;e[58]!==o||e[59]!==Z?(me=f(Jn,{model:o,onSelect:Z}),e[58]=o,e[59]=Z,e[60]=me):me=e[60];let he;e[61]!==D||e[62]!==M||e[63]!==v||e[64]!==w||e[65]!==q||e[66]!==P.autocompleteState||e[67]!==P.editorRef||e[68]!==P.gutterRef||e[69]!==P.handlers||e[70]!==P.listboxId||e[71]!==P.onPickSuggestion||e[72]!==P.overlayRef||e[73]!==P.revealDiagnostic?(he=f(Bn,{assistant:D,autocomplete:P.autocompleteState,diagnostics:M,draft:v,editorRef:P.editorRef,failed:w,gutterRef:P.gutterRef,handlers:P.handlers,listboxId:P.listboxId,onGenerated:q,onPickSuggestion:P.onPickSuggestion,onRevealDiagnostic:P.revealDiagnostic,overlayRef:P.overlayRef}),e[61]=D,e[62]=M,e[63]=v,e[64]=w,e[65]=q,e[66]=P.autocompleteState,e[67]=P.editorRef,e[68]=P.gutterRef,e[69]=P.handlers,e[70]=P.listboxId,e[71]=P.onPickSuggestion,e[72]=P.overlayRef,e[73]=P.revealDiagnostic,e[74]=he):he=e[74];let pe;e[75]!==D||e[76]!==S||e[77]!==J||e[78]!==B||e[79]!==h||e[80]!==Q||e[81]!==C||e[82]!==Ie||e[83]!==T||e[84]!==R||e[85]!==z||e[86]!==ae||e[87]!==te||e[88]!==N||e[89]!==L||e[90]!==ie?(pe=f(Un,{assistant:D,chart:h,className:Ie,error:S,onFormat:J,onInferChart:B,onRun:Q,onShardKeyChange:I,onShowChart:z,onShowExplain:ae,onShowResults:te,onToggleSplit:ie,pane:L,result:C,running:T,shardKey:R,splitView:N}),e[75]=D,e[76]=S,e[77]=J,e[78]=B,e[79]=h,e[80]=Q,e[81]=C,e[82]=Ie,e[83]=T,e[84]=R,e[85]=z,e[86]=ae,e[87]=te,e[88]=N,e[89]=L,e[90]=ie,e[91]=pe):pe=e[91];let be;e[92]!==he||e[93]!==pe||e[94]!==ye?(be=$("div",{className:ye,children:[he,pe]}),e[92]=he,e[93]=pe,e[94]=ye,e[95]=be):be=e[95];let ge;e[96]!==me||e[97]!==be?(ge=$("div",{className:"flex min-w-0 flex-1 flex-col",children:[me,be]}),e[96]=me,e[97]=be,e[98]=ge):ge=e[98];let we;return e[99]!==fe||e[100]!==ge?(we=$("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[fe,ge]}),e[99]=fe,e[100]=ge,e[101]=we):we=e[101],we};export{vs as SqlEditorPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as V}from"react/compiler-runtime";import{useLunora as k}from"@lunora/react";import{useNavigate as F,useRouter as L,useSearch as M}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.js";import{u as P}from"../packem_shared/table-list-sidebar-Bluzd1_2.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{s as J,d as D}from"../packem_shared/data-view-params-qoSTqjAj.js";import{f}from"../packem_shared/internal-CwaF9YNk.js";import{l as K,s as O}from"../packem_shared/browser-storage-Br_bLeBt.js";import{DataBrowser as I}from"../packem_shared/DataBrowser-BnDIFN-S.js";import{GlobalDataBrowser as X}from"../packem_shared/GlobalDataBrowser-DusjXzRF.js";import{jsx as v,jsxs as E}from"react/jsx-runtime";const N="lunora-studio-saved-queries",Y=50,$=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,S=()=>K(N).filter($),B=r=>{O(N,r)},z=(r,e)=>{const s=r.trim();if(s==="")return S();const o=[{name:s,view:e},...S().filter(b=>b.name!==s)].slice(0,Y);return B(o),o},H=r=>{const e=S().filter(s=>s.name!==r);return B(e),e},U=r=>{const e=V(15),{onChange:s,tier:o}=r,b=q();let d;e[0]!==s?(d=y=>{s(y.target.value)},e[0]=s,e[1]=d):d=e[1];const l=d;let h;e[2]!==b?(h=b("Storage tier"),e[2]=b,e[3]=h):h=e[3];let i;e[4]!==h?(i=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:h}),e[4]=h,e[5]=i):i=e[5];const m=w[o];let n,g;e[6]===Symbol.for("react.memo_cache_sentinel")?(n=v("option",{value:"shard",children:w.shard.label}),g=v("option",{value:"global",children:w.global.label}),e[6]=n,e[7]=g):(n=e[6],g=e[7]);let c;e[8]!==l||e[9]!==m.title||e[10]!==o?(c=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:l,title:m.title,value:o,children:[n,g]}),e[8]=l,e[9]=m.title,e[10]=o,e[11]=c):c=e[11];let u;return e[12]!==i||e[13]!==c?(u=E("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[i,c]}),e[12]=i,e[13]=c,e[14]=u):u=e[14],u},W=()=>{try{f(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},pe=({editable:r=!1,initialShardKey:e})=>{const s=k(),o=F(),b=L(),d=M({strict:!1}),l=J(d),h=P(d),i=()=>b.state.location.pathname.split("/").findLast(Boolean)==="data",m=l.tier??"shard",n=l.table,[g,c]=Q(()=>S()),[u,y]=Q(()=>new Set);A(()=>{f((async()=>{try{const a=await s.listGlobalTables();y(new Set(a.map(t=>t.name)))}catch{}})())},[s]),A(()=>{m==="shard"&&n!==void 0&&u.has(n)&&f(o({replace:!0,search:a=>({...a,schema:"global"}),to:"/data"}))},[u,o,n,m]);const R=a=>{f(o({search:t=>({...t,schema:a==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(a,t)=>{i()&&f(o({search:p=>({schema:p.schema,search:t?.search,shard:p.shard,table:a}),to:"/data"}))},C=a=>{f(o({search:t=>({...t,schema:"global",table:a}),to:"/data"}))},G=a=>{const t=D(a),{current:p}=h;(p.filters??void 0)===t.filters&&(p.order??void 0)===t.order&&(p.search??void 0)===t.search&&(p.shard??void 0)===t.shard||!i()||f(o({replace:!0,search:j=>({...j,filters:t.filters,order:t.order,search:t.search,shard:t.shard}),to:"/data"}))},_={onApplyQuery:a=>{const t=D(a.view);f(o({search:()=>({filters:t.filters,order:t.order,schema:t.schema,search:t.search,shard:t.shard,table:t.table}),to:"/data"}))},onCopyLink:W,onDeleteQuery:a=>{c(H(a))},onSaveQuery:(a,t)=>{c(z(a,t))},saved:g},x=v(U,{onChange:R,tier:m});return m==="global"?v(X,{initialTable:n,onSelectTable:T,schemaSwitch:x}):v(I,{editable:r,globalTableNames:u,initialFilters:l.filters,initialOrderBy:l.orderBy,initialPins:d.pins,initialSearch:l.search,initialShardKey:l.shard??e,onNavigateToGlobal:C,onSelectTable:T,onViewChange:G,queryBar:_,schemaSwitch:x,tableParam:n})};export{pe as TableEditor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as Y}from"react";import{
|
|
1
|
+
import{useState as Y}from"react";import{E as I}from"../packem_shared/error-alert-TYdKetJd.js";import{B as N}from"../packem_shared/badge-cAk9Di1Q.js";import{B as q}from"../packem_shared/button-BOPLD1un.js";import{C as R,a as $}from"../packem_shared/card-BGlQzQY-.js";import{E as j}from"../packem_shared/empty-state-B939z6K2.js";import{T as K,a as L,b as p,c as o,d as P,e as d}from"../packem_shared/table-BMsuYFhk.js";import{u as f}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as x}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as ee}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as e,jsxs as l}from"react/jsx-runtime";const D="agent_threads",te="agent_messages",M="agent_run_queue",H=100,ae=250,se={},re={filters:[],limit:H,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:D},i=(r,t)=>{const s=r[t];return typeof s=="string"?s:void 0},A=(r,t)=>{const s=r[t];return typeof s=="number"?s:void 0},U=r=>{const{usage:t}=r;if(t===null||typeof t!="object")return;const{totalTokens:s}=t;return typeof s=="number"?s:void 0},ne=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"):[]},oe=r=>{switch(r){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},de=r=>{switch(r){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},be=({initialShardKey:r=""})=>{const t=Z(),[s,T]=Y(void 0),{data:c}=f(x.listTables,se,{live:!0,shardKey:r}),G=c!==void 0,m=Array.isArray(c)&&c.some(a=>a.name===D),Q=Array.isArray(c)&&c.some(a=>a.name===M),{data:E,error:_,errorSource:z,liveError:O}=f(x.readTablePage,re,{enabled:m,live:!0,shardKey:r}),V={filters:[{column:"threadKey",operator:"eq",value:s??""}],limit:ae,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:te},{data:S}=f(x.readTablePage,{limit:H,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:M},{enabled:Q,live:!0,shardKey:r}),{data:k,error:F,errorSource:J}=f(x.readTablePage,V,{enabled:m&&s!==void 0,live:!0,shardKey:r}),v=Array.isArray(E?.rows)?E.rows:[],W=Array.isArray(S?.rows)?S.rows:[],w=a=>W.filter(n=>i(n,"threadKey")===a).length,C=Array.isArray(k?.rows)?k.rows:[],B=v.find(a=>i(a,"key")===s);let h;return G&&!m?h=e(j,{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")}):m&&v.length===0?h=e(j,{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")}):h=l("div",{className:"flex flex-col gap-6",children:[e(R,{className:"overflow-hidden py-0",children:e($,{className:"px-0",children:l(K,{"data-testid":"agents-threads-table",children:[e(L,{children:l(p,{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(P,{children:v.map(a=>{const n=i(a,"key")??"",u=i(a,"status"),g=U(a);return l(p,{"data-active":n===s?"":void 0,"data-testid":`agents-thread-${n}`,children:[e(d,{className:"font-mono text-xs",children:i(a,"agent")??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:n}),e(d,{children:e(N,{"data-testid":`agents-thread-status-${n}`,variant:oe(u),children:u??"—"})}),e(d,{className:"tabular-nums",children:w(n)===0?e("span",{className:"text-muted-foreground",children:"—"}):e(N,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:w(n)})}),e(d,{className:"tabular-nums",children:A(a,"messageCount")??"—"}),e(d,{className:"tabular-nums text-muted-foreground",children:g??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:ee(A(a,"updatedAt"),"—")}),e(d,{className:"text-right",children:e(q,{"data-testid":`agents-thread-open-${n}`,onClick:()=>{T(n)},size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),F!==null&&e(I,{error:J,testId:"agents-messages-error"}),s!==void 0&&e(R,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:l($,{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,B!==void 0&&l("span",{className:"text-muted-foreground",children:[" · ",t("Usage"),": ",U(B)??0," ",t("Tokens")]})]}),e(q,{"data-testid":"agents-thread-detail-close",onClick:()=>{T(void 0)},size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),C.length===0?e("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):l(K,{"data-testid":"agents-messages-table",children:[e(L,{children:l(p,{children:[e(o,{children:t("Role")}),e(o,{children:t("Content")}),e(o,{children:t("Tool")}),e(o,{children:t("Approval")})]})}),e(P,{children:C.map((a,n)=>{const u=i(a,"role")??"—",g=ne(a),X=i(a,"toolName"),y=i(a,"status"),b=A(a,"seq")??n;return l(p,{"data-testid":`agents-message-${String(b)}`,children:[e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:u}),e(d,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:i(a,"content")??"—"}),e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:X??(g.length>0?g.join(", "):"—")}),e(d,{className:"align-top",children:y===void 0?e("span",{className:"text-xs text-muted-foreground",children:"—"}):e(N,{"data-testid":`agents-message-approval-${String(b)}`,variant:de(y),children:y})})]},i(a,"messageKey")??`${u}:${String(b)}`)})})]})]})})]}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[_!==null&&e(I,{error:z,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.")}),O!==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.")}),h]})};export{be as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as g}from"react/compiler-runtime";import{createAnalyticsSqlClient as L}from"@lunora/bindings/analytics";import{useState as C,useMemo as I,useCallback as k,useEffect as N}from"react";import{C as _}from"../packem_shared/card-BGlQzQY-.js";import{E as v}from"../packem_shared/empty-state-B939z6K2.js";import{T as O,a as D,b,d as M,e as q,c as w}from"../packem_shared/table-BMsuYFhk.js";import{useT as x}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{b as B,f as P,h as U}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as n,jsxs as A}from"react/jsx-runtime";const F="ANALYTICS",T=[{key:"volume",sql:r=>`SELECT blob2 AS fn, count() AS calls FROM ${r} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,title:"Request volume per function"},{key:"latency",sql:r=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${r} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,title:"Latency p50 / p95 per function"},{key:"hotShards",sql:r=>`SELECT blob3 AS shard, count() AS calls FROM ${r} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,title:"Hot shards"}],Y={error:null,loading:!0,result:null},H=r=>{const e=g(27),{state:h,title:u}=r,c=x(),{error:a,loading:t,result:s}=h,l=`analytics-panel-${u}`;let o;e[0]!==c||e[1]!==u?(o=c(u),e[0]=c,e[1]=u,e[2]=o):o=e[2];let i;e[3]!==o?(i=n("header",{className:"border-b border-border px-4 py-3",children:n("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),e[3]=o,e[4]=i):i=e[4];let d;e[5]!==t||e[6]!==c?(d=t&&n("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:c("Loading…")}),e[5]=t,e[6]=c,e[7]=d):d=e[7];let m;e[8]!==a||e[9]!==t?(m=!t&&a!==null&&n("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:a}),e[8]=a,e[9]=t,e[10]=m):m=e[10];let p;e[11]!==a||e[12]!==t||e[13]!==s||e[14]!==c?(p=!t&&a===null&&s!==null&&s.rows.length===0&&n("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:c("No data points yet.")}),e[11]=a,e[12]=t,e[13]=s,e[14]=c,e[15]=p):p=e[15];let f;e[16]!==a||e[17]!==t||e[18]!==s?(f=!t&&a===null&&s!==null&&s.rows.length>0&&A(O,{children:[n(D,{children:n(b,{children:s.columns.map(W)})}),n(M,{children:s.rows.map((S,R)=>n(b,{children:s.columns.map(E=>n(q,{className:"font-mono text-xs",children:U(S[E.name])},E.name))},R))})]}),e[16]=a,e[17]=t,e[18]=s,e[19]=f):f=e[19];let y;return e[20]!==l||e[21]!==i||e[22]!==d||e[23]!==m||e[24]!==p||e[25]!==f?(y=A(_,{className:"gap-0 py-0","data-testid":l,children:[i,d,m,p,f]}),e[20]=l,e[21]=i,e[22]=d,e[23]=m,e[24]=p,e[25]=f,e[26]=y):y=e[26],y},Q=({config:r,dataset:e=F,runQuery:h}={})=>{const u=x(),[c,a]=C({}),t=I(()=>{if(h!==void 0)return h;if(r===void 0)return null;const l=L({accountId:r.accountId,apiToken:r.apiToken});return o=>l.query(o)},[r,h]),s=k(async l=>{if(t!==null)for(const o of T){if(l.cancelled)return;a(i=>({...i,[o.key]:{error:null,loading:!0,result:null}}));try{const i=await t(o.sql(e));l.cancelled||a(d=>({...d,[o.key]:{error:null,loading:!1,result:i}}))}catch(i){l.cancelled||a(d=>({...d,[o.key]:{error:B(i),loading:!1,result:null}}))}}},[t,e]);return N(()=>{const l={cancelled:!1};return P(s(l)),()=>{l.cancelled=!0}},[s]),t===null?n(v,{description:u("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:n("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"})}),testId:"analytics-not-configured",title:u("Analytics is not configured.")}):n("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:T.map(l=>n(H,{state:c[l.key]??Y,title:l.title},l.key))})};function W(r){return n(w,{children:r.name},r.name)}export{Q as AnalyticsPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as R}from"react/compiler-runtime";import{useState as k}from"react";import{E as q}from"../packem_shared/error-alert-TYdKetJd.js";import{B as j}from"../packem_shared/badge-cAk9Di1Q.js";import{B as z}from"../packem_shared/button-BOPLD1un.js";import{C as D,a as M}from"../packem_shared/card-BGlQzQY-.js";import{E as O}from"../packem_shared/empty-state-B939z6K2.js";import{I as Q}from"../packem_shared/input-CY5W3wzv.js";import{T as U,a as $,b as F,c as N,d as G,e as w}from"../packem_shared/table-BMsuYFhk.js";import{u as J}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as V}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as W}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as a,jsxs as l}from"react/jsx-runtime";const ne=()=>{const e=R(39),t=K(),[o,H]=k("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:L,error:i,errorSource:S,isLoading:E,refetch:B}=J(V.getAuthAuditLog,b);let A;if(e[1]!==L?.entries||e[2]!==o){const r=L?.entries??[],x=o.trim().toLowerCase();A=x===""?r:r.filter(C=>C.event.toLowerCase().includes(x)||(C.actorId??"").toLowerCase().includes(x)||(C.actorEmail??"").toLowerCase().includes(x)||(C.ip??"").toLowerCase().includes(x)||C.outcome.toLowerCase().includes(x)),e[1]=L?.entries,e[2]=o,e[3]=A}else A=e[3];const s=A;let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=r=>{H(r.target.value)},e[4]=I):I=e[4];const P=I;let c;e[5]!==t?(c=t("Filter security events"),e[5]=t,e[6]=c):c=e[6];let n;e[7]!==t?(n=t("filter event, actor, IP"),e[7]=t,e[8]=n):n=e[8];let d;e[9]!==o||e[10]!==c||e[11]!==n?(d=a(Q,{"aria-label":c,className:"h-8 w-56","data-testid":"aa-search",onChange:P,placeholder:n,value:o}),e[9]=o,e[10]=c,e[11]=n,e[12]=d):d=e[12];let m;e[13]!==B?(m=()=>{B()},e[13]=B,e[14]=m):m=e[14];let u;e[15]!==t?(u=t("Refresh"),e[15]=t,e[16]=u):u=e[16];let h;e[17]!==m||e[18]!==u?(h=a(z,{"data-testid":"aa-refresh",onClick:m,size:"xs",type:"button",variant:"ghost",children:u}),e[17]=m,e[18]=u,e[19]=h):h=e[19];let f;e[20]!==d||e[21]!==h?(f=l("div",{className:"flex flex-wrap items-center gap-2",children:[d,h]}),e[20]=d,e[21]=h,e[22]=f):f=e[22];let p;e[23]!==i||e[24]!==S?(p=i!==null&&a(q,{error:S,testId:"aa-error"}),e[23]=i,e[24]=S,e[25]=p):p=e[25];let g;e[26]!==i||e[27]!==s.length||e[28]!==E||e[29]!==t?(g=i===null&&!E&&s.length===0&&a(O,{description:t("Authentication and security events are recorded here."),testId:"aa-empty",title:t("No security events.")}),e[26]=i,e[27]=s.length,e[28]=E,e[29]=t,e[30]=g):g=e[30];let v;e[31]!==s||e[32]!==t?(v=s.length>0&&a(D,{className:"overflow-hidden py-0",children:a(M,{className:"max-h-[30rem] overflow-auto px-0",children:l(U,{"data-testid":"aa-table",children:[a($,{children:l(F,{children:[a(N,{children:t("time")}),a(N,{children:t("event")}),a(N,{children:t("actor")}),a(N,{children:t("ip / user agent")}),a(N,{children:t("outcome")})]})}),a(G,{children:s.map(r=>l(F,{"data-testid":"aa-row",children:[a(w,{className:"text-muted-foreground tabular-nums",children:W(r.ts,"—")}),a(w,{children:a(j,{variant:"secondary",children:r.event})}),a(w,{className:"max-w-[24ch] truncate font-mono text-xs",title:r.actorId??void 0,children:r.actorEmail??r.actorId??a("span",{className:"text-muted-foreground",children:"—"})}),l(w,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:r.userAgent??void 0,children:[r.ip??a("span",{className:"text-muted-foreground",children:"—"}),r.userAgent!==void 0&&l("span",{className:"ml-1 opacity-70",children:["· ",r.userAgent]})]}),a(w,{children:a(j,{variant:r.outcome==="failure"?"destructive":"outline",children:t(r.outcome)})})]},r.seq))})]})})}),e[31]=s,e[32]=t,e[33]=v):v=e[33];let T;return e[34]!==p||e[35]!==g||e[36]!==v||e[37]!==f?(T=l("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[f,p,g,v]}),e[34]=p,e[35]=g,e[36]=v,e[37]=f,e[38]=T):T=e[38],T};export{ne as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as N}from"react/compiler-runtime";import{useLunora as
|
|
1
|
+
import{c as N}from"react/compiler-runtime";import{useLunora as C}from"@lunora/react";import{B as x}from"../packem_shared/badge-cAk9Di1Q.js";import{C as w,a as I}from"../packem_shared/card-BGlQzQY-.js";import{b as A}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{jsx as t,jsxs as d,Fragment as y}from"react/jsx-runtime";const S=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=e=>{if(e===void 0)return"—";const i=[[86400,"d"],[3600,"h"],[60,"m"]];for(const[a,o]of i)if(e>=a&&e%a===0)return`${String(e/a)}${o}`;return`${String(e)}s`},h=e=>{const i=N(8),{children:a,heading:o,testId:r}=e;let l;i[0]!==o?(l=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o})}),i[0]=o,i[1]=l):l=i[1];let s;i[2]!==a?(s=t(I,{className:"p-3",children:a}),i[2]=a,i[3]=s):s=i[3];let u;return i[4]!==l||i[5]!==s||i[6]!==r?(u=d(w,{className:"gap-0 py-0","data-testid":r,children:[l,s]}),i[4]=l,i[5]=s,i[6]=r,i[7]=u):u=i[7],u},c=e=>{const i=N(7),{label:a,value:o}=e;let r;i[0]!==a?(r=t("span",{className:"text-sm",children:a}),i[0]=a,i[1]=r):r=i[1];let l;i[2]!==o?(l=t("span",{className:"text-sm text-muted-foreground tabular-nums",children:o}),i[2]=o,i[3]=l):l=i[3];let s;return i[4]!==r||i[5]!==l?(s=d("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[r,l]}),i[4]=r,i[5]=l,i[6]=s):s=i[6],s},O=()=>{const e=N(20),i=C(),a=$();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-auth-config"],e[0]=o):o=e[0];let r;e[1]!==i?(r=()=>i.getAuthConfig(),e[1]=i,e[2]=r):r=e[2];const{data:l,error:s}=A(o,r);let u;e[3]!==a?(u=n=>t(x,{variant:n?"success":"outline",children:a(n?"Enabled":"Disabled")}),e[3]=a,e[4]=u):u=e[4];const m=u;let f;e[5]!==s?(f=s!==null&&t("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:s}),e[5]=s,e[6]=f):f=e[6];let g;e[7]!==l||e[8]!==s||e[9]!==a?(g=s===null&&l===void 0&&t("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:a("Loading auth configuration…")}),e[7]=l,e[8]=s,e[9]=a,e[10]=g):g=e[10];let p;e[11]!==l||e[12]!==s||e[13]!==m||e[14]!==a?(p=s===null&&l!==void 0&&d(y,{children:[t(h,{heading:a("Enabled capabilities"),testId:"auth-config-capabilities",children:t("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:S.map(n=>{const k=l.capabilities[n.key];return d("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${n.key}`,children:[t("span",{className:"text-sm",children:a(n.label)}),m(k)]},n.key)})})}),t(h,{heading:a("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?t("p",{className:"text-sm text-muted-foreground",children:a("No plugins enabled.")}):t("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(P)})}),t(h,{heading:a("Sign-in methods"),testId:"auth-config-signin",children:d("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Email & password"),value:m(l.emailAndPassword)}),t(c,{label:a("Social providers"),value:l.socialProviders.length===0?a("None"):t("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(z)})})]})}),l.organization.enabled&&t(h,{heading:a("Organizations"),testId:"auth-config-org",children:d("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Teams"),value:m(l.organization.teams)}),t(c,{label:a("Custom roles"),value:m(l.organization.roles)})]})}),t(h,{heading:a("Session policy"),testId:"auth-config-session",children:d("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Expires in"),value:v(l.session.expiresIn)}),t(c,{label:a("Refresh after"),value:v(l.session.updateAge)}),t(c,{label:a("Fresh window"),value:v(l.session.freshAge)}),t(c,{label:a("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),t(h,{heading:a("Rate limit"),testId:"auth-config-ratelimit",children:d("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&d(y,{children:[t(c,{label:a("Max requests"),value:l.rateLimit.max??"—"}),t(c,{label:a("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&t(h,{heading:a("Plugin user fields"),testId:"auth-config-user-fields",children:t("ul",{className:"flex flex-col gap-2",children:l.userFields.map(n=>d("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${n.name}`,children:[d("span",{className:"flex flex-col",children:[t("span",{className:"font-mono text-xs",children:n.name}),n.plugin!==void 0&&t("span",{className:"text-[11px] text-muted-foreground",children:n.plugin})]}),d("span",{className:"flex items-center gap-1",children:[t(x,{variant:"outline",children:n.type}),n.required&&t(x,{variant:"secondary",children:a("required")}),n.unique&&t(x,{variant:"secondary",children:a("unique")})]})]},n.name))})}),t(w,{className:"gap-0 py-0",children:t("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:a("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=s,e[13]=m,e[14]=a,e[15]=p):p=e[15];let b;return e[16]!==f||e[17]!==g||e[18]!==p?(b=d("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[f,g,p]}),e[16]=f,e[17]=g,e[18]=p,e[19]=b):b=e[19],b};function P(e){return t(x,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}function z(e){return t(x,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as A}from"react/compiler-runtime";import{useLunora as g}from"@lunora/react";import{B as S}from"../packem_shared/button-BOPLD1un.js";import{C,a as k}from"../packem_shared/card-BGlQzQY-.js";import{E as w}from"../packem_shared/empty-state-B939z6K2.js";import{T as I,a as B,b as T,c,d as R,e as m}from"../packem_shared/table-BMsuYFhk.js";import{b as E}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useAutoRefresh as _}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.js";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{i as j,f as H}from"../packem_shared/internal-CwaF9YNk.js";import{jsx as t,jsxs as y}from"react/jsx-runtime";const v=200,K=()=>{const e=A(21),i=g(),s=$();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=["lunora-auth-sessions",v],e[0]=h):h=e[0];let u;e[1]!==i?(u=()=>i.listAuthSessions({limit:v}),e[1]=i,e[2]=u):u=e[2];const l=E(h,u),{error:f}=l,r=l.data?.rows??null;let p;e[3]!==l?(p=()=>{l.refetch()},e[3]=l,e[4]=p):p=e[4],_(p,!0);let x;e[5]!==i||e[6]!==l?(x=a=>{H((async()=>{await i.revokeAuthSession({sessionId:a}),l.refetch()})())},e[5]=i,e[6]=l,e[7]=x):x=e[7];const N=x;let o;e[8]!==f?(o=f!==null&&t("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:f}),e[8]=f,e[9]=o):o=e[9];let n;e[10]!==r||e[11]!==s?(n=r!==null&&r.length===0&&t(w,{testId:"auth-sessions-empty",title:s("No active sessions.")}),e[10]=r,e[11]=s,e[12]=n):n=e[12];let d;e[13]!==N||e[14]!==r||e[15]!==s?(d=r!==null&&r.length>0&&t(C,{className:"overflow-hidden py-0",children:t(k,{className:"px-0",children:y(I,{"data-testid":"auth-sessions-table",children:[t(B,{children:y(T,{children:[t(c,{children:s("user")}),t(c,{children:s("expires")}),t(c,{children:s("ip")}),t(c,{children:s("user agent")}),t(c,{children:s("impersonated by")}),t(c,{"aria-label":s("Actions")})]})}),t(R,{children:r.map(a=>y(T,{"data-testid":`auth-session-${a.id}`,children:[t(m,{className:"font-mono text-xs",children:a.userId}),t(m,{className:"text-muted-foreground tabular-nums",children:j(a.expiresAt)}),t(m,{children:a.ipAddress??""}),t(m,{className:"max-w-40 truncate",children:a.userAgent??""}),t(m,{className:"font-mono text-xs",children:a.impersonatedBy??""}),t(m,{children:t(S,{"data-testid":`auth-session-revoke-${a.id}`,onClick:()=>{N(a.id)},size:"xs",type:"button",variant:"ghost",children:s("Revoke")})})]},a.id))})]})})}),e[13]=N,e[14]=r,e[15]=s,e[16]=d):d=e[16];let b;return e[17]!==o||e[18]!==n||e[19]!==d?(b=y("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[o,n,d]}),e[17]=o,e[18]=n,e[19]=d,e[20]=b):b=e[20],b};export{K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as
|
|
1
|
+
import{c as C}from"react/compiler-runtime";import{L as T}from"../packem_shared/live-status-Bf7rR8o8.js";import{B as b}from"../packem_shared/badge-cAk9Di1Q.js";import{C as E,a as A}from"../packem_shared/card-BGlQzQY-.js";import{E as I}from"../packem_shared/empty-state-B939z6K2.js";import{T as S,a as _,b as y,c as l,d as L,e as d}from"../packem_shared/table-BMsuYFhk.js";import{u as O}from"../packem_shared/use-admin-query-P0RJrjsD.js";import{useT as $}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.js";import{ADMIN_FUNCTIONS as k}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsxs as h,jsx as n}from"react/jsx-runtime";const g="container:",R={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},B=e=>{const t=e.indexOf(":");if(t===-1)return{event:e.trim()};const a=e.slice(t+1).trim(),s=e.slice(0,t).trim();return a===""?{event:s}:{detail:a,event:s}},D=e=>{const t=new Map;for(const a of e){const s=a.functionPath??"";if(!s.startsWith(g))continue;const i=s.slice(g.length);if(i==="")continue;const r=JSON.stringify([i,a.instance??""]),o=t.get(r);if(o!==void 0&&o.timestamp>=a.timestamp)continue;const{detail:u,event:c}=B(a.message);t.set(r,{detail:u,event:c,exitCode:a.exitCode,instance:a.instance,level:a.level,name:i,state:R[c]??"unknown",timestamp:a.timestamp})}return[...t.values()].toSorted((a,s)=>a.name.localeCompare(s.name)||(a.instance??"").localeCompare(s.instance??""))},M={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},P=e=>{const{entries:t}=e??{};return Array.isArray(t)?t:[]},q=()=>{const e=C(19),t=$();let a,s;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},s={live:!0,shardKey:""},e[0]=a,e[1]=s):(a=e[0],s=e[1]);const{data:i,error:r,liveError:o}=O(k.getLogs,a,s),u=i!==void 0;let c;if(e[2]!==i||e[3]!==r||e[4]!==o||e[5]!==u||e[6]!==t){const N=D(P(i));let x;e[8]!==r?(x=r!==null&&n("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:r}),e[8]=r,e[9]=x):x=e[9];let m;e[10]!==t?(m=t("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance — ports and health checks aren't carried in that stream."),e[10]=t,e[11]=m):m=e[11];let f;e[12]!==m?(f=n("p",{className:"text-sm text-muted-foreground",children:m}),e[12]=m,e[13]=f):f=e[13];let p;e[14]!==o?(p=n(T,{message:o,prefix:"containers"}),e[14]=o,e[15]=p):p=e[15];let v;e[16]!==f||e[17]!==p?(v=h("div",{className:"flex flex-wrap items-center gap-2",children:[f,p]}),e[16]=f,e[17]=p,e[18]=v):v=e[18],c=h("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,u&&N.length===0?n(I,{description:t("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:t("No container activity")}):n(E,{className:"overflow-hidden py-0",children:n(A,{className:"px-0",children:h(S,{"data-testid":"containers-table",children:[n(_,{children:h(y,{children:[n(l,{children:t("Container")}),n(l,{children:t("Instance")}),n(l,{children:t("State")}),n(l,{children:t("Last event")}),n(l,{children:t("Detail")}),n(l,{children:t("Exit")}),n(l,{children:t("When")})]})}),n(L,{children:N.map(j)})]})})})]}),e[2]=i,e[3]=r,e[4]=o,e[5]=u,e[6]=t,e[7]=c}else c=e[7];return c};function j(e){return h(y,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[n(d,{className:"font-mono text-xs",children:e.name}),n(d,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"—"}),n(d,{children:n(b,{variant:M[e.state],children:e.state})}),n(d,{className:"font-mono text-xs text-muted-foreground",children:e.event}),n(d,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"—"}),n(d,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"—"}),n(d,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}export{q as default};
|