@lunora/studio 1.0.0-alpha.37 → 1.0.0-alpha.371

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (489) hide show
  1. package/README.md +4 -4
  2. package/dist/index.d.mts +1629 -0
  3. package/dist/index.d.ts +1021 -809
  4. package/dist/index.mjs +1 -0
  5. package/dist/mount.d.mts +23 -0
  6. package/dist/mount.d.ts +13 -11
  7. package/dist/mount.mjs +1 -0
  8. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -0
  9. package/dist/packem_chunks/ApiTab.mjs +1 -0
  10. package/dist/packem_chunks/AuditPanel.mjs +1 -0
  11. package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -0
  12. package/dist/packem_chunks/ExportImportPanel.mjs +10 -0
  13. package/dist/packem_chunks/FileBrowser.mjs +4 -0
  14. package/dist/packem_chunks/FunctionRunner.mjs +1 -0
  15. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -0
  16. package/dist/packem_chunks/HealthPanel.mjs +1 -0
  17. package/dist/packem_chunks/InsightsPanel.mjs +1 -0
  18. package/dist/packem_chunks/LogsPanel.mjs +1 -0
  19. package/dist/packem_chunks/MailPanel.mjs +2 -0
  20. package/dist/packem_chunks/MetricsPanel.mjs +1 -0
  21. package/dist/packem_chunks/NotificationsPanel.mjs +1 -0
  22. package/dist/packem_chunks/PitrPanel.mjs +1 -0
  23. package/dist/packem_chunks/SchemaViewer.mjs +1 -0
  24. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -0
  25. package/dist/packem_chunks/SettingsPanel.mjs +1 -0
  26. package/dist/packem_chunks/SqlEditorPanel.mjs +25 -0
  27. package/dist/packem_chunks/TableEditor.mjs +1 -0
  28. package/dist/packem_chunks/agents-panel.mjs +1 -0
  29. package/dist/packem_chunks/ai-knowledge.mjs +1 -0
  30. package/dist/packem_chunks/ai-usage-panel.mjs +1 -0
  31. package/dist/packem_chunks/analytics-panel.mjs +1 -0
  32. package/dist/packem_chunks/architecture-panel.mjs +1 -0
  33. package/dist/packem_chunks/assistant-panel.mjs +3 -0
  34. package/dist/packem_chunks/auth-audit-panel.mjs +1 -0
  35. package/dist/packem_chunks/auth-config-panel.mjs +1 -0
  36. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -0
  37. package/dist/packem_chunks/containers-panel.mjs +1 -0
  38. package/dist/packem_chunks/dashboards-panel.mjs +1 -0
  39. package/dist/packem_chunks/evals-panel.mjs +1 -0
  40. package/dist/packem_chunks/fanout-panel.mjs +1 -0
  41. package/dist/packem_chunks/flags-panel.mjs +1 -0
  42. package/dist/packem_chunks/issues-panel.mjs +1 -0
  43. package/dist/packem_chunks/kv-browser.mjs +1 -0
  44. package/dist/packem_chunks/log-drains-panel.mjs +4 -0
  45. package/dist/packem_chunks/migrations-route.mjs +1 -0
  46. package/dist/packem_chunks/organizations-panel.mjs +1 -0
  47. package/dist/packem_chunks/payments-panel.mjs +1 -0
  48. package/dist/packem_chunks/permissions-panel.mjs +1 -0
  49. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -0
  50. package/dist/packem_chunks/queues-panel.mjs +1 -0
  51. package/dist/packem_chunks/reactors-panel.mjs +1 -0
  52. package/dist/packem_chunks/rls-panel.mjs +1 -0
  53. package/dist/packem_chunks/schedule-panel.mjs +1 -0
  54. package/dist/packem_chunks/storage-rules-panel.mjs +1 -0
  55. package/dist/packem_chunks/subscriptions-panel.mjs +1 -0
  56. package/dist/packem_chunks/sync-client-panel.mjs +1 -0
  57. package/dist/packem_chunks/theme-indicator.mjs +1 -0
  58. package/dist/packem_chunks/traces-panel.mjs +1 -0
  59. package/dist/packem_chunks/users-panel.mjs +1 -0
  60. package/dist/packem_chunks/vector-browser.mjs +1 -0
  61. package/dist/packem_chunks/workflows-panel.mjs +1 -0
  62. package/dist/packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs +1 -0
  63. package/dist/packem_shared/ApiDocsPanel-xqgxgYCy.mjs +2 -0
  64. package/dist/packem_shared/ApiReferencePanel-CQxU1Ocx.mjs +1 -0
  65. package/dist/packem_shared/CommandPalette-BZCHLpst.mjs +1 -0
  66. package/dist/packem_shared/ConfirmButton-CIXYF6Mg.mjs +1 -0
  67. package/dist/packem_shared/ConnectionBadge-BfcoN-VE.mjs +1 -0
  68. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs +1 -0
  69. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs +1 -0
  70. package/dist/packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs +1 -0
  71. package/dist/packem_shared/DataBrowser-BrRWqnCr.mjs +4 -0
  72. package/dist/packem_shared/DataFilters--ocFTVT2.mjs +1 -0
  73. package/dist/packem_shared/ErrorBoundary-BWNF98VF.mjs +1 -0
  74. package/dist/packem_shared/GlobalDataBrowser-D8ZheGwm.mjs +1 -0
  75. package/dist/packem_shared/HomePanel-CHq9VBrh.mjs +1 -0
  76. package/dist/packem_shared/MigrationsPanel-BWGgOwmX.mjs +1 -0
  77. package/dist/packem_shared/OpenRpcReferencePanel-BFDG91tn.mjs +1 -0
  78. package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.mjs +1 -0
  79. package/dist/packem_shared/ScheduledJobs-QCTRdugp.mjs +1 -0
  80. package/dist/packem_shared/ShardInput-CoySruKZ.mjs +1 -0
  81. package/dist/packem_shared/Studio-pDEG4JTx.mjs +1 -0
  82. package/dist/packem_shared/StudioApp-C4IOJPR6.mjs +1 -0
  83. package/dist/packem_shared/StudioI18nProvider-CGXCPnQn.mjs +1 -0
  84. package/dist/packem_shared/advisor-view-Dj-mZPAq.mjs +5 -0
  85. package/dist/packem_shared/aggregateMetrics-DKFJc-o5.mjs +1 -0
  86. package/dist/packem_shared/alert-PB5W11MM.mjs +1 -0
  87. package/dist/packem_shared/app.d-BXrVLb99.d.mts +360 -0
  88. package/dist/packem_shared/app.d-BXrVLb99.d.ts +360 -0
  89. package/dist/packem_shared/assistant-provider-BQG7QZAu.mjs +1 -0
  90. package/dist/packem_shared/assistant-reason-D6EwMCxT.mjs +1 -0
  91. package/dist/packem_shared/auth-pager-DW77WeZw.mjs +1 -0
  92. package/dist/packem_shared/badge-r_5B4LHP.mjs +1 -0
  93. package/dist/packem_shared/bar-chart-BCsEIQoQ.mjs +6 -0
  94. package/dist/packem_shared/browser-storage-BH1MxLZs.mjs +1 -0
  95. package/dist/packem_shared/button-q0UYSmrn.mjs +1 -0
  96. package/dist/packem_shared/card-By2O8ULa.mjs +1 -0
  97. package/dist/packem_shared/cf-links-C4DVTr8A.mjs +1 -0
  98. package/dist/packem_shared/checkbox-CnS9cyCz.mjs +1 -0
  99. package/dist/packem_shared/control-button-BOZ5K-FC.mjs +1 -0
  100. package/dist/packem_shared/data-grid-B5m1OosL.mjs +1 -0
  101. package/dist/packem_shared/data-view-params-C-_G-biH.mjs +1 -0
  102. package/dist/packem_shared/diagram-export-panel-Vdt-DZnO.mjs +2 -0
  103. package/dist/packem_shared/dropdown-menu-jLZenfWH.mjs +2 -0
  104. package/dist/packem_shared/empty-state-D7jEML_T.mjs +1 -0
  105. package/dist/packem_shared/error-alert-BzZfqmf4.mjs +6 -0
  106. package/dist/packem_shared/grid-features-Drvfswwy.mjs +6 -0
  107. package/dist/packem_shared/grid-pagination-DY2erU65.mjs +1 -0
  108. package/dist/packem_shared/home-panel-DTWHlX5S.mjs +3 -0
  109. package/dist/packem_shared/input-CXhxesPC.mjs +1 -0
  110. package/dist/packem_shared/internal-hIuTpSbx.mjs +2 -0
  111. package/dist/packem_shared/label-DKFzyHq6.mjs +1 -0
  112. package/dist/packem_shared/live-status-D1GasNsH.mjs +1 -0
  113. package/dist/packem_shared/log-fields-BolUoZ9g.mjs +1 -0
  114. package/dist/packem_shared/log-line-BH0iWiBv.mjs +1 -0
  115. package/dist/packem_shared/metrics-format-1sNGG47R.mjs +1 -0
  116. package/dist/packem_shared/modal-shell-CDztwLnv.mjs +1 -0
  117. package/dist/packem_shared/operation-console-provider-DoloEvon.mjs +1 -0
  118. package/dist/packem_shared/recording-client-z4CBi0y8.mjs +1 -0
  119. package/dist/packem_shared/reference-view-DENugPcj.mjs +13 -0
  120. package/dist/packem_shared/schema-diagram-CtVPhOGj.mjs +2 -0
  121. package/dist/packem_shared/scroll-area-CXCQH7VT.mjs +2 -0
  122. package/dist/packem_shared/select-DPyS18Vy.mjs +2 -0
  123. package/dist/packem_shared/shard-history-CaO3C4KQ.mjs +1 -0
  124. package/dist/packem_shared/shortcuts-B9gDaXmw.mjs +1 -0
  125. package/dist/packem_shared/skeleton-DX1gfixl.mjs +1 -0
  126. package/dist/packem_shared/sparkline-B_sPPO_8.mjs +1 -0
  127. package/dist/packem_shared/sql-result-table-DCwooMGW.mjs +1 -0
  128. package/dist/packem_shared/stat-card-BAv73QtB.mjs +1 -0
  129. package/dist/packem_shared/storage-tier-C2mKwYRj.mjs +1 -0
  130. package/dist/packem_shared/studio-DE7i2--m.mjs +2 -0
  131. package/dist/packem_shared/table-D0SBiDu-.mjs +2 -0
  132. package/dist/packem_shared/table-list-sidebar-DUnCjFL7.mjs +1 -0
  133. package/dist/packem_shared/textarea--40GKAyz.mjs +1 -0
  134. package/dist/packem_shared/trace-handoff-BV3EWqy_.mjs +1 -0
  135. package/dist/packem_shared/use-admin-query-CaOm4JS3.mjs +1 -0
  136. package/dist/packem_shared/use-admin-spec-CK7mk3Ui.mjs +1 -0
  137. package/dist/packem_shared/use-assistant-rpc-DCC6ph2u.mjs +1 -0
  138. package/dist/packem_shared/use-async-submit-D0r7-m2J.mjs +1 -0
  139. package/dist/packem_shared/use-auth-config-CG7VvAvQ.mjs +1 -0
  140. package/dist/packem_shared/use-mirrored-ref-CVDf2z1M.mjs +1 -0
  141. package/dist/packem_shared/use-open-trace-BJKMJjeS.mjs +1 -0
  142. package/dist/packem_shared/use-shard-key-BsP3o5wT.mjs +1 -0
  143. package/dist/packem_shared/use-studio-client-DCA50tF2.mjs +1 -0
  144. package/dist/packem_shared/useDebounced-DVeQ5-oW.mjs +1 -0
  145. package/dist/packem_shared/utils-bhneXptQ.mjs +1 -0
  146. package/dist/packem_shared/virtual-rect-D_j7aLxX.mjs +1 -0
  147. package/dist/standalone/chunk-23TGXTY3.js +1 -0
  148. package/dist/standalone/chunk-2BN5NW34.js +1 -0
  149. package/dist/standalone/chunk-2DT3QG6Q.js +1 -0
  150. package/dist/standalone/chunk-2EB7FN5S.js +1 -0
  151. package/dist/standalone/chunk-2STFVRP6.js +1 -0
  152. package/dist/standalone/chunk-2WELEPUX.js +14 -0
  153. package/dist/standalone/chunk-34E6NNQZ.js +1 -0
  154. package/dist/standalone/chunk-35IQT6SS.js +7 -0
  155. package/dist/standalone/chunk-3D67ZJRW.js +1 -0
  156. package/dist/standalone/chunk-3HR74V73.js +1 -0
  157. package/dist/standalone/chunk-3NC6JA7A.js +1 -0
  158. package/dist/standalone/chunk-43VARWUD.js +1 -0
  159. package/dist/standalone/chunk-4AJML27P.js +1 -0
  160. package/dist/standalone/chunk-4EPW63HS.js +1 -0
  161. package/dist/standalone/chunk-4M223MUW.js +1 -0
  162. package/dist/standalone/chunk-4NKJV7YX.js +1 -0
  163. package/dist/standalone/chunk-4PI2OSSP.js +1 -0
  164. package/dist/standalone/chunk-5IXKYP7I.js +1 -0
  165. package/dist/standalone/chunk-5PEAXTYQ.js +1 -0
  166. package/dist/standalone/chunk-5REEK2HD.js +1 -0
  167. package/dist/standalone/chunk-5W5XLOZO.js +1 -0
  168. package/dist/standalone/chunk-5Y67VCSW.js +1 -0
  169. package/dist/standalone/chunk-64WVI7AU.js +1 -0
  170. package/dist/standalone/chunk-6A6AELDJ.js +1 -0
  171. package/dist/standalone/chunk-6DU2UW57.js +33 -0
  172. package/dist/standalone/chunk-6FPV3EK2.js +1 -0
  173. package/dist/standalone/chunk-6G3E4PJ2.js +1 -0
  174. package/dist/standalone/chunk-72PNA5CK.js +1 -0
  175. package/dist/standalone/chunk-73GEDGFE.js +1 -0
  176. package/dist/standalone/chunk-74WS3GUC.js +3 -0
  177. package/dist/standalone/chunk-A2Q3TGIQ.js +1 -0
  178. package/dist/standalone/chunk-AHANHVFC.js +1 -0
  179. package/dist/standalone/chunk-ALXTADCX.js +10 -0
  180. package/dist/standalone/chunk-AXKOMM2J.js +1 -0
  181. package/dist/standalone/chunk-BG2CJOVS.js +1 -0
  182. package/dist/standalone/chunk-BKI3JMXQ.js +1 -0
  183. package/dist/standalone/chunk-BO35TSLE.js +1 -0
  184. package/dist/standalone/chunk-BWT5ANXC.js +1 -0
  185. package/dist/standalone/chunk-C724GMPR.js +1 -0
  186. package/dist/standalone/chunk-CHJYRPLL.js +6 -0
  187. package/dist/standalone/chunk-CKK227GJ.js +1 -0
  188. package/dist/standalone/chunk-CL3JOU6F.js +1 -0
  189. package/dist/standalone/chunk-CVSIFPI5.js +1 -0
  190. package/dist/standalone/chunk-D65UVZIA.js +1 -0
  191. package/dist/standalone/chunk-DA2CAFXI.js +1 -0
  192. package/dist/standalone/chunk-DFOIQN5E.js +1 -0
  193. package/dist/standalone/chunk-EDN4JTLK.js +1 -0
  194. package/dist/standalone/chunk-FVITJ4Q4.js +1 -0
  195. package/dist/standalone/chunk-FWJ7VSGQ.js +1 -0
  196. package/dist/standalone/chunk-FWM5Z6CH.js +1 -0
  197. package/dist/standalone/chunk-G2BUKFAD.js +1 -0
  198. package/dist/standalone/chunk-G6IFVCSL.js +1 -0
  199. package/dist/standalone/chunk-GN3GGVCY.js +1 -0
  200. package/dist/standalone/chunk-GWNGVKLG.js +1 -0
  201. package/dist/standalone/chunk-GXTSE66Z.js +1 -0
  202. package/dist/standalone/chunk-HAVIBMMB.js +1 -0
  203. package/dist/standalone/chunk-HCOF7HOM.js +1 -0
  204. package/dist/standalone/chunk-HDBRX5CX.js +1 -0
  205. package/dist/standalone/chunk-HFBSWKJS.js +1 -0
  206. package/dist/standalone/chunk-HG3MXWXT.js +1 -0
  207. package/dist/standalone/chunk-HRH5FYV6.js +1 -0
  208. package/dist/standalone/chunk-I2EFWZXX.js +3 -0
  209. package/dist/standalone/chunk-IJAZY2M7.js +1 -0
  210. package/dist/standalone/chunk-IOMK34E4.js +1 -0
  211. package/dist/standalone/chunk-J45HAKBU.js +1 -0
  212. package/dist/standalone/chunk-J4KHSWXK.js +1 -0
  213. package/dist/standalone/chunk-J7NEJGZW.js +1 -0
  214. package/dist/standalone/chunk-JMZT3CEW.js +1 -0
  215. package/dist/standalone/chunk-JW3TXMEF.js +59 -0
  216. package/dist/standalone/chunk-K3LRNI56.js +4 -0
  217. package/dist/standalone/chunk-KGLIQIZU.js +1 -0
  218. package/dist/standalone/chunk-KGURUUEC.js +1 -0
  219. package/dist/standalone/chunk-KQQOOBL5.js +1 -0
  220. package/dist/standalone/chunk-KRWSRKJ3.js +1 -0
  221. package/dist/standalone/chunk-KSFVO6OB.js +1 -0
  222. package/dist/standalone/chunk-KSLMSLWZ.js +30 -0
  223. package/dist/standalone/chunk-KTK4NDWQ.js +1 -0
  224. package/dist/standalone/chunk-LHAYLYCA.js +1 -0
  225. package/dist/standalone/chunk-LRQTVCUX.js +1 -0
  226. package/dist/standalone/chunk-MY7J2X2Y.js +1 -0
  227. package/dist/standalone/chunk-MYRTLPF5.js +1 -0
  228. package/dist/standalone/chunk-N77FOL5Q.js +1 -0
  229. package/dist/standalone/chunk-NGVP66OH.js +1 -0
  230. package/dist/standalone/chunk-O3AZ7JKE.js +1 -0
  231. package/dist/standalone/chunk-O4D6HJOQ.js +1 -0
  232. package/dist/standalone/chunk-OLI3R5ZJ.js +1 -0
  233. package/dist/standalone/chunk-ONTGYVAN.js +1 -0
  234. package/dist/standalone/chunk-OYBBHQRO.js +1 -0
  235. package/dist/standalone/chunk-P2JJ33X3.js +1 -0
  236. package/dist/standalone/chunk-P6VNMPWR.js +1 -0
  237. package/dist/standalone/chunk-PD56UWVC.js +1 -0
  238. package/dist/standalone/chunk-PDBW6GTJ.js +1 -0
  239. package/dist/standalone/chunk-PLLNOYT6.js +1 -0
  240. package/dist/standalone/chunk-PRTIYJFL.js +1 -0
  241. package/dist/standalone/chunk-PYK4VXG6.js +1 -0
  242. package/dist/standalone/chunk-QAOZXPLU.js +1 -0
  243. package/dist/standalone/chunk-QCWPTLPV.js +2 -0
  244. package/dist/standalone/chunk-QK46WKIS.js +1 -0
  245. package/dist/standalone/chunk-QNJJIVLQ.js +1 -0
  246. package/dist/standalone/chunk-QRA7AKYO.js +1 -0
  247. package/dist/standalone/chunk-QTEJHIZD.js +1 -0
  248. package/dist/standalone/chunk-QY5JC5H6.js +1 -0
  249. package/dist/standalone/chunk-RIAOZECW.js +1 -0
  250. package/dist/standalone/chunk-RLSKEGNK.js +1 -0
  251. package/dist/standalone/chunk-RPHIAYMR.js +1 -0
  252. package/dist/standalone/chunk-RPKPLAT2.js +1 -0
  253. package/dist/standalone/chunk-RTS5G3ET.js +2 -0
  254. package/dist/standalone/chunk-RXGN7E4K.js +1 -0
  255. package/dist/standalone/chunk-S36FVTKK.js +1 -0
  256. package/dist/standalone/chunk-S6RKBBI5.js +1 -0
  257. package/dist/standalone/chunk-SEPNNN6O.js +1 -0
  258. package/dist/standalone/chunk-STHN562E.js +1 -0
  259. package/dist/standalone/chunk-SY7AVD6C.js +1 -0
  260. package/dist/standalone/chunk-TDYA6E3G.js +1 -0
  261. package/dist/standalone/chunk-TW4O2BA5.js +159 -0
  262. package/dist/standalone/chunk-U2E36H6V.js +5 -0
  263. package/dist/standalone/chunk-U4X2I55T.js +1 -0
  264. package/dist/standalone/chunk-UBX5ZPLV.js +1 -0
  265. package/dist/standalone/chunk-UMDBJGZH.js +1 -0
  266. package/dist/standalone/chunk-UQZUK6MO.js +1 -0
  267. package/dist/standalone/chunk-URNEEX2Q.js +1 -0
  268. package/dist/standalone/chunk-UTE2SZQY.js +1 -0
  269. package/dist/standalone/chunk-VCLCELNQ.js +8 -0
  270. package/dist/standalone/chunk-VHRWGZVT.js +1 -0
  271. package/dist/standalone/chunk-VNH4OBJS.js +1 -0
  272. package/dist/standalone/chunk-VUOEJJUH.js +1 -0
  273. package/dist/standalone/chunk-WMF3KFRB.js +1 -0
  274. package/dist/standalone/chunk-WUJWIBTQ.js +1 -0
  275. package/dist/standalone/chunk-X7TFLK6L.js +5 -0
  276. package/dist/standalone/chunk-XAI64L2D.js +1 -0
  277. package/dist/standalone/chunk-XIJQY7MK.js +4 -0
  278. package/dist/standalone/chunk-XLYFGUEF.js +1 -0
  279. package/dist/standalone/chunk-Y23CK77V.js +1 -0
  280. package/dist/standalone/{chunk-BJGBHGK3.js → chunk-Y2YLTUMD.js} +1 -1
  281. package/dist/standalone/chunk-YEMTJB7N.js +1 -0
  282. package/dist/standalone/chunk-YORPLSI5.js +1 -0
  283. package/dist/standalone/chunk-YUVGMKHG.js +1 -0
  284. package/dist/standalone/chunk-Z4VISCXI.js +1 -0
  285. package/dist/standalone/chunk-ZN6LJWXV.js +6 -0
  286. package/dist/standalone/chunk-ZPQBVYNN.js +1 -0
  287. package/dist/standalone/chunk-ZSWW2UGP.js +1 -0
  288. package/dist/standalone/chunk-ZYARVDS6.js +1 -0
  289. package/dist/standalone/chunk-ZYGPKYEU.js +3 -0
  290. package/dist/standalone/studio.js +9 -214
  291. package/dist/styles.css +2 -2
  292. package/package.json +27 -22
  293. package/dist/index.js +0 -41
  294. package/dist/mount.js +0 -27
  295. package/dist/packem_chunks/ApiTab.js +0 -251
  296. package/dist/packem_chunks/AuditPanel.js +0 -200
  297. package/dist/packem_chunks/ExportImportPanel.js +0 -198
  298. package/dist/packem_chunks/FileBrowser.js +0 -2932
  299. package/dist/packem_chunks/FunctionRunner.js +0 -343
  300. package/dist/packem_chunks/FunctionStatsPanel.js +0 -377
  301. package/dist/packem_chunks/HealthPanel.js +0 -648
  302. package/dist/packem_chunks/InsightsPanel.js +0 -462
  303. package/dist/packem_chunks/LogsPanel.js +0 -827
  304. package/dist/packem_chunks/MailPanel.js +0 -353
  305. package/dist/packem_chunks/MetricsPanel.js +0 -1344
  306. package/dist/packem_chunks/MigrationsPanel.js +0 -239
  307. package/dist/packem_chunks/PitrPanel.js +0 -252
  308. package/dist/packem_chunks/SchemaViewer.js +0 -2513
  309. package/dist/packem_chunks/SecurityAdvisorPanel.js +0 -95
  310. package/dist/packem_chunks/SettingsPanel.js +0 -391
  311. package/dist/packem_chunks/SqlEditorPanel.js +0 -2323
  312. package/dist/packem_chunks/TableEditor.js +0 -313
  313. package/dist/packem_chunks/analytics-panel.js +0 -261
  314. package/dist/packem_chunks/auth-config-panel.js +0 -179
  315. package/dist/packem_chunks/auth-sessions-panel.js +0 -175
  316. package/dist/packem_chunks/containers-panel.js +0 -247
  317. package/dist/packem_chunks/dashboards-panel.js +0 -780
  318. package/dist/packem_chunks/fanout-panel.js +0 -482
  319. package/dist/packem_chunks/flags-panel.js +0 -176
  320. package/dist/packem_chunks/kv-browser.js +0 -1896
  321. package/dist/packem_chunks/log-drains-panel.js +0 -273
  322. package/dist/packem_chunks/organizations-panel.js +0 -670
  323. package/dist/packem_chunks/payments-panel.js +0 -186
  324. package/dist/packem_chunks/permissions-panel.js +0 -805
  325. package/dist/packem_chunks/queues-panel.js +0 -1052
  326. package/dist/packem_chunks/rls-panel.js +0 -315
  327. package/dist/packem_chunks/schedule-panel.js +0 -831
  328. package/dist/packem_chunks/sparkline.js +0 -79
  329. package/dist/packem_chunks/storage-rules-panel.js +0 -140
  330. package/dist/packem_chunks/subscriptions-panel.js +0 -238
  331. package/dist/packem_chunks/users-panel.js +0 -1265
  332. package/dist/packem_chunks/vector-browser.js +0 -281
  333. package/dist/packem_chunks/workflows-panel.js +0 -562
  334. package/dist/packem_shared/ADMIN_FUNCTIONS-BHHJi3Gb.js +0 -52
  335. package/dist/packem_shared/ApiDocsPanel-D4CJf2ad.js +0 -842
  336. package/dist/packem_shared/ApiReferencePanel-Co_wpRF2.js +0 -230
  337. package/dist/packem_shared/CommandPalette-BUPpbpMc.js +0 -373
  338. package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
  339. package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
  340. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
  341. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
  342. package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
  343. package/dist/packem_shared/DataBrowser-BeVNxSVm.js +0 -4493
  344. package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
  345. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
  346. package/dist/packem_shared/GlobalDataBrowser-ErfvIs1S.js +0 -289
  347. package/dist/packem_shared/HomePanel-D9MQk8I7.js +0 -14
  348. package/dist/packem_shared/OpenRpcReferencePanel-DLWzrIx9.js +0 -192
  349. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
  350. package/dist/packem_shared/ScheduledJobs-ClaNpZsg.js +0 -262
  351. package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
  352. package/dist/packem_shared/Studio-C48P1K5W.js +0 -16
  353. package/dist/packem_shared/StudioApp-Cqh-SYm2.js +0 -657
  354. package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
  355. package/dist/packem_shared/advisor-view-D3-U4kRR.js +0 -159
  356. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
  357. package/dist/packem_shared/alert-CdAET2K_.js +0 -68
  358. package/dist/packem_shared/app.d-CNLRTrWw.d.ts +0 -300
  359. package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
  360. package/dist/packem_shared/bar-chart-DSwcWIRy.js +0 -3246
  361. package/dist/packem_shared/browser-storage-tLOxkIHd.js +0 -185
  362. package/dist/packem_shared/button-BhsN2uZH.js +0 -49
  363. package/dist/packem_shared/card-DURq3ElK.js +0 -175
  364. package/dist/packem_shared/cf-links-BZfRdxSE.js +0 -8
  365. package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
  366. package/dist/packem_shared/data-grid-Jz8FqQ2C.js +0 -183
  367. package/dist/packem_shared/data-view-params-Cd6yRVbv.js +0 -96
  368. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
  369. package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
  370. package/dist/packem_shared/error-alert-BBT6D22d.js +0 -114
  371. package/dist/packem_shared/grid-features-CUr8Z1_O.js +0 -745
  372. package/dist/packem_shared/home-panel-CoGxi-oj.js +0 -1639
  373. package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
  374. package/dist/packem_shared/internal-DTsYVn-g.js +0 -97
  375. package/dist/packem_shared/label-D8ykjn5J.js +0 -46
  376. package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
  377. package/dist/packem_shared/modal-shell-hyaJvIJ6.js +0 -100
  378. package/dist/packem_shared/reference-view-CSKyUyPl.js +0 -2141
  379. package/dist/packem_shared/scroll-area-DLhcy-ml.js +0 -93
  380. package/dist/packem_shared/select-UkNYCT3s.js +0 -273
  381. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  382. package/dist/packem_shared/skeleton-CGhL0p20.js +0 -45
  383. package/dist/packem_shared/sparkline-BnA1kC9X.js +0 -93
  384. package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
  385. package/dist/packem_shared/studio-CPHA_-3I.js +0 -4015
  386. package/dist/packem_shared/table-DsCa9Qp9.js +0 -246
  387. package/dist/packem_shared/table-list-sidebar-B5psdSV1.js +0 -832
  388. package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
  389. package/dist/packem_shared/use-admin-query-BHPKmPuj.js +0 -106
  390. package/dist/packem_shared/use-auth-capabilities-C-VH0oJJ.js +0 -32
  391. package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
  392. package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
  393. package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
  394. package/dist/standalone/chunk-22W5VKZ6.js +0 -1
  395. package/dist/standalone/chunk-2GGMGPEP.js +0 -1
  396. package/dist/standalone/chunk-2K47A3P6.js +0 -1
  397. package/dist/standalone/chunk-2NGUNNGW.js +0 -1
  398. package/dist/standalone/chunk-2THHW7BC.js +0 -1
  399. package/dist/standalone/chunk-3CJW6NWG.js +0 -4
  400. package/dist/standalone/chunk-3OA7PECS.js +0 -6
  401. package/dist/standalone/chunk-46K3NKPA.js +0 -1
  402. package/dist/standalone/chunk-4QHKBC77.js +0 -1
  403. package/dist/standalone/chunk-5OH3VPZF.js +0 -1
  404. package/dist/standalone/chunk-5OIBXYZM.js +0 -1
  405. package/dist/standalone/chunk-6GFEVKJP.js +0 -1
  406. package/dist/standalone/chunk-6WRZP62V.js +0 -1
  407. package/dist/standalone/chunk-764T6X6X.js +0 -1
  408. package/dist/standalone/chunk-7SLSB2TS.js +0 -4
  409. package/dist/standalone/chunk-7TJJXVSE.js +0 -1
  410. package/dist/standalone/chunk-7VF3IAAW.js +0 -2
  411. package/dist/standalone/chunk-AHILM3ZP.js +0 -1
  412. package/dist/standalone/chunk-AJIUI7DD.js +0 -1
  413. package/dist/standalone/chunk-ATYUMPDM.js +0 -1
  414. package/dist/standalone/chunk-BACPICH6.js +0 -1
  415. package/dist/standalone/chunk-BI35RXKQ.js +0 -1
  416. package/dist/standalone/chunk-BOXSWNXZ.js +0 -1
  417. package/dist/standalone/chunk-BQUQS7QN.js +0 -1
  418. package/dist/standalone/chunk-CKSHCYGC.js +0 -2
  419. package/dist/standalone/chunk-DC72CQY4.js +0 -76
  420. package/dist/standalone/chunk-DORBUITF.js +0 -1
  421. package/dist/standalone/chunk-DVC6YWVP.js +0 -1
  422. package/dist/standalone/chunk-DVKPRFIJ.js +0 -1
  423. package/dist/standalone/chunk-DWDILV2E.js +0 -1
  424. package/dist/standalone/chunk-DWTBY343.js +0 -1
  425. package/dist/standalone/chunk-EUIHTPKI.js +0 -1
  426. package/dist/standalone/chunk-FCSPAJW4.js +0 -1
  427. package/dist/standalone/chunk-GMSGZDDH.js +0 -13
  428. package/dist/standalone/chunk-GTM65MVX.js +0 -1
  429. package/dist/standalone/chunk-HV7G6DFP.js +0 -5
  430. package/dist/standalone/chunk-ILCTSAOB.js +0 -1
  431. package/dist/standalone/chunk-IOFMK4D7.js +0 -1
  432. package/dist/standalone/chunk-J6J54MBP.js +0 -1
  433. package/dist/standalone/chunk-JE2YOAB7.js +0 -4
  434. package/dist/standalone/chunk-JSEXCW5Q.js +0 -1
  435. package/dist/standalone/chunk-K3GNLVYK.js +0 -1
  436. package/dist/standalone/chunk-KEGAWN6Y.js +0 -1
  437. package/dist/standalone/chunk-KJJ3WM6H.js +0 -4
  438. package/dist/standalone/chunk-KZ6INM5M.js +0 -1
  439. package/dist/standalone/chunk-LAK5VSPI.js +0 -1
  440. package/dist/standalone/chunk-LD2R263D.js +0 -1
  441. package/dist/standalone/chunk-LI43EKM6.js +0 -1
  442. package/dist/standalone/chunk-M55U7NHO.js +0 -1
  443. package/dist/standalone/chunk-MPTM7ZU3.js +0 -3
  444. package/dist/standalone/chunk-MPYFGAOW.js +0 -1
  445. package/dist/standalone/chunk-NKJDGOM3.js +0 -1
  446. package/dist/standalone/chunk-O3NAGRTR.js +0 -1
  447. package/dist/standalone/chunk-OCHNCAXJ.js +0 -1
  448. package/dist/standalone/chunk-OIZ4CHPN.js +0 -8
  449. package/dist/standalone/chunk-OY3GVYS7.js +0 -4
  450. package/dist/standalone/chunk-PACH5AHG.js +0 -1
  451. package/dist/standalone/chunk-PN5NCZDX.js +0 -1
  452. package/dist/standalone/chunk-PVZI3CXP.js +0 -19
  453. package/dist/standalone/chunk-PZ7HD5T2.js +0 -1
  454. package/dist/standalone/chunk-Q52CHOSY.js +0 -1
  455. package/dist/standalone/chunk-QAFAJBAW.js +0 -1
  456. package/dist/standalone/chunk-QBAT52GB.js +0 -1
  457. package/dist/standalone/chunk-QLM6FYZW.js +0 -2
  458. package/dist/standalone/chunk-RRAFQ5G2.js +0 -1
  459. package/dist/standalone/chunk-RRCPZMC2.js +0 -22
  460. package/dist/standalone/chunk-RSEEHNFI.js +0 -1
  461. package/dist/standalone/chunk-SEU5V7I6.js +0 -1
  462. package/dist/standalone/chunk-SG3ALJJU.js +0 -1
  463. package/dist/standalone/chunk-SLKF2L74.js +0 -1
  464. package/dist/standalone/chunk-TAD43CG5.js +0 -1
  465. package/dist/standalone/chunk-TBMYIZIO.js +0 -1
  466. package/dist/standalone/chunk-TDL7NEWA.js +0 -1
  467. package/dist/standalone/chunk-TO4JQX7W.js +0 -1
  468. package/dist/standalone/chunk-TOJ3TC35.js +0 -1
  469. package/dist/standalone/chunk-TQ36RWOP.js +0 -1
  470. package/dist/standalone/chunk-U4OAQPBT.js +0 -1
  471. package/dist/standalone/chunk-UK64ZSUW.js +0 -1
  472. package/dist/standalone/chunk-VLXV72QE.js +0 -1
  473. package/dist/standalone/chunk-VTGBPW24.js +0 -1
  474. package/dist/standalone/chunk-WI7GWFEG.js +0 -1
  475. package/dist/standalone/chunk-WXPWVBIY.js +0 -1
  476. package/dist/standalone/chunk-X5P2WRYI.js +0 -1
  477. package/dist/standalone/chunk-X7MMBSNW.js +0 -1
  478. package/dist/standalone/chunk-XLQ4BHBD.js +0 -1
  479. package/dist/standalone/chunk-XNJNSCLM.js +0 -1
  480. package/dist/standalone/chunk-XUGSA2NG.js +0 -1
  481. package/dist/standalone/chunk-Y2ZPNDL7.js +0 -4
  482. package/dist/standalone/chunk-YAECF5LW.js +0 -1
  483. package/dist/standalone/chunk-YEVCU7TB.js +0 -13
  484. package/dist/standalone/chunk-ZHVTQ37P.js +0 -1
  485. package/dist/standalone/chunk-ZIGWVHCS.js +0 -1
  486. package/dist/standalone/chunk-ZPP2KOR4.js +0 -1
  487. package/dist/standalone/chunk-ZPUO7FNI.js +0 -1
  488. package/dist/standalone/chunk-ZU4DZ6NK.js +0 -1
  489. package/dist/standalone/chunk-ZYRGPDZB.js +0 -1
@@ -0,0 +1 @@
1
+ import{c as me}from"react/compiler-runtime";import{useState as be,useRef as Je,useEffect as We}from"react";import{L as gt}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as pt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as tt}from"../packem_shared/button-q0UYSmrn.mjs";import{u as je}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as xt}from"../packem_shared/use-open-trace-BJKMJjeS.mjs";import{u as bt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as vt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as ge}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Fe}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{c as yt}from"../packem_shared/cf-links-C4DVTr8A.mjs";import{j as Nt,n as Xe,f as St,d as wt,b as Tt,c as qt}from"../packem_shared/internal-hIuTpSbx.mjs";import{l as _t,r as Ct}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{f as Rt}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{B as et}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as pe,a as xe,b as Be,d as Mt,c as Qe}from"../packem_shared/card-By2O8ULa.mjs";import{b as Ve,e as ie,T as ct,c as oe,a as dt,d as mt}from"../packem_shared/table-D0SBiDu-.mjs";import{stableStringify as kt}from"@lunora/wire";import{S as ft}from"../packem_shared/sparkline-B_sPPO_8.mjs";import{jsxs as f,jsx as s,Fragment as Ze}from"react/jsx-runtime";import{aggregateMetrics as At,enrichQueryStats as It,shardsToAggregate as $t,computeLatencyPercentiles as Dt}from"../packem_shared/aggregateMetrics-DKFJc-o5.mjs";import{S as ce}from"../packem_shared/stat-card-BAv73QtB.mjs";import{b as st,c as Et,h as Lt}from"../packem_shared/metrics-format-1sNGG47R.mjs";import{ResponsiveContainer as rt,AreaChart as Ft,CartesianGrid as lt,XAxis as at,YAxis as it,Tooltip as nt,Area as Ot,LineChart as zt,Line as Kt}from"recharts";import{E as Pt}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as Bt}from"../packem_shared/utils-bhneXptQ.mjs";import{S as Qt,a as Ht,c as He,b as Ut,d as jt}from"../packem_shared/select-DPyS18Vy.mjs";const ut=(i,e,l)=>`${i}:${e}:${kt(l??{})}`,ht=(i,e)=>i==="gauge"?e.last:i==="histogram"?e.sum/Math.max(1,e.count):e.sum,Vt=(i,e)=>ht(i,e),Gt=i=>ht(i.kind,i),Ye=i=>Number.isInteger(i)?i.toLocaleString():i.toLocaleString(void 0,{maximumFractionDigits:2}),Yt=i=>Array.isArray(i?.series)?i.series:[],Jt="FUNCTION_NOT_FOUND",Wt=i=>{const e=new Map;if(!Array.isArray(i?.series))return e;for(const l of i.series)e.set(ut(l.kind,l.name,l.attributes),l.points);return e},Xt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=i=>{const e=me(18),{name:l,onOpenTrace:r,traceId:t}=i,o=ge();if(t===void 0){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=s("span",{className:"text-muted-foreground",children:"—"}),e[0]=d):d=e[0],d}let n;e[1]!==t?(n=t.slice(0,8),e[1]=t,e[2]=n):n=e[2];const a=n;if(r===void 0){const d=`mt-instrument-trace-${l}`;let c;return e[3]!==a||e[4]!==d||e[5]!==t?(c=s("span",{className:"text-muted-foreground","data-testid":d,title:t,children:a}),e[3]=a,e[4]=d,e[5]=t,e[6]=c):c=e[6],c}const m=`mt-instrument-trace-${l}`;let p;e[7]!==r||e[8]!==t?(p=()=>{r(t)},e[7]=r,e[8]=t,e[9]=p):p=e[9];let h;e[10]!==o||e[11]!==t?(h=o("Open the exemplar trace {trace}",{trace:t}),e[10]=o,e[11]=t,e[12]=h):h=e[12];let u;return e[13]!==a||e[14]!==m||e[15]!==p||e[16]!==h?(u=s("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":m,onClick:p,title:h,type:"button",children:a}),e[13]=a,e[14]=m,e[15]=p,e[16]=h,e[17]=u):u=e[17],u},es=i=>{const e=me(105),{onOpenTrace:l,shardKey:r}=i,t=ge();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];let n;e[1]!==r?(n={live:!0,shardKey:r},e[1]=r,e[2]=n):n=e[2];const{data:a,error:m,errorSource:p}=je(Fe.getMetricSeries,o,n);let h;e[3]===Symbol.for("react.memo_cache_sentinel")?(h={},e[3]=h):h=e[3];let u;e[4]!==r?(u={live:!0,shardKey:r},e[4]=r,e[5]=u):u=e[5];const{data:d}=je(Fe.getMetricHistory,h,u);let c,x,g,v,b,S,y,w,M,_,N,$,q;if(e[6]!==a||e[7]!==m||e[8]!==p||e[9]!==d||e[10]!==l||e[11]!==t){w=Symbol.for("react.early_return_sentinel");e:{const E=Yt(a),L=Nt(p)===Jt;if(m!==null&&!L){let T;e[25]!==t?(T=t("Instruments"),e[25]=t,e[26]=T):T=e[26];let O;e[27]!==T?(O=s("h3",{className:"text-sm font-semibold text-foreground",children:T}),e[27]=T,e[28]=O):O=e[28];let z;e[29]!==m||e[30]!==t?(z=t("Instruments unavailable: {error}",{error:m}),e[29]=m,e[30]=t,e[31]=z):z=e[31];let K;e[32]!==z?(K=s("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:z}),e[32]=z,e[33]=K):K=e[33];let P;e[34]!==O||e[35]!==K?(P=f("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[O,K]}),e[34]=O,e[35]=K,e[36]=P):P=e[36],w=P;break e}if(E.length===0){w=null;break e}const F=Wt(d);let de;e[37]!==t?(de=T=>t(T==="counter"?"Counter":T==="gauge"?"Gauge":"Histogram"),e[37]=t,e[38]=de):de=e[38];const fe=de;b="flex flex-col gap-2",S="mt-instruments";let Q;e[39]!==t?(Q=t("Instruments"),e[39]=t,e[40]=Q):Q=e[40],e[41]!==Q?(y=s("h3",{className:"text-sm font-semibold text-foreground",children:Q}),e[41]=Q,e[42]=y):y=e[42],v=pe,q="overflow-hidden py-0",g=xe,$="px-0",x=ct,_="mt-instruments-table";let H;e[43]!==t?(H=t("name"),e[43]=t,e[44]=H):H=e[44];let U;e[45]!==H?(U=s(oe,{children:H}),e[45]=H,e[46]=U):U=e[46];let j;e[47]!==t?(j=t("kind"),e[47]=t,e[48]=j):j=e[48];let V;e[49]!==j?(V=s(oe,{children:j}),e[49]=j,e[50]=V):V=e[50];let G;e[51]!==t?(G=t("value"),e[51]=t,e[52]=G):G=e[52];let Y;e[53]!==G?(Y=s(oe,{className:"text-right",children:G}),e[53]=G,e[54]=Y):Y=e[54];let J;e[55]!==t?(J=t("count"),e[55]=t,e[56]=J):J=e[56];let W;e[57]!==J?(W=s(oe,{className:"text-right",children:J}),e[57]=J,e[58]=W):W=e[58];let X;e[59]!==t?(X=t("range"),e[59]=t,e[60]=X):X=e[60];let Z;e[61]!==X?(Z=s(oe,{className:"text-right",children:X}),e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==t?(ee=t("trend"),e[63]=t,e[64]=ee):ee=e[64];let te;e[65]!==ee?(te=s(oe,{children:ee}),e[65]=ee,e[66]=te):te=e[66];let se;e[67]!==t?(se=t("trace"),e[67]=t,e[68]=se):se=e[68];let re;e[69]!==se?(re=s(oe,{children:se}),e[69]=se,e[70]=re):re=e[70];let le;e[71]!==t?(le=t("dimensions"),e[71]=t,e[72]=le):le=e[72];let ae;e[73]!==le?(ae=s(oe,{children:le}),e[73]=le,e[74]=ae):ae=e[74],e[75]!==U||e[76]!==V||e[77]!==Y||e[78]!==W||e[79]!==Z||e[80]!==te||e[81]!==re||e[82]!==ae?(N=s(dt,{children:f(Ve,{children:[U,V,Y,W,Z,te,re,ae]})}),e[75]=U,e[76]=V,e[77]=Y,e[78]=W,e[79]=Z,e[80]=te,e[81]=re,e[82]=ae,e[83]=N):N=e[83],c=mt,M=E.map(T=>{const O=Rt(T.attributes),z=ut(T.kind,T.name,T.attributes),P=(F.get(z)??[]).map(ue=>Vt(T.kind,ue));return f(Ve,{"data-testid":`mt-instrument-${T.name}`,children:[s(ie,{className:"font-mono text-xs",title:T.functionPath,children:T.name}),s(ie,{children:s(et,{variant:Xt[T.kind],children:fe(T.kind)})}),s(ie,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${T.name}`,children:Ye(Gt(T))}),s(ie,{className:"text-right tabular-nums text-muted-foreground",children:T.count.toLocaleString()}),s(ie,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:T.min===T.max?"—":`${Ye(T.min)}–${Ye(T.max)}`}),s(ie,{children:P.length>=2?s(ft,{ariaLabel:t("{name} trend",{name:T.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${T.name}`}):s("span",{className:"text-xs text-muted-foreground",children:"—"})}),s(ie,{className:"font-mono text-xs",children:s(Zt,{name:T.name,onOpenTrace:l,traceId:T.exemplarTraceId})}),s(ie,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:O,children:O===""?"—":O})]},z)})}e[6]=a,e[7]=m,e[8]=p,e[9]=d,e[10]=l,e[11]=t,e[12]=c,e[13]=x,e[14]=g,e[15]=v,e[16]=b,e[17]=S,e[18]=y,e[19]=w,e[20]=M,e[21]=_,e[22]=N,e[23]=$,e[24]=q}else c=e[12],x=e[13],g=e[14],v=e[15],b=e[16],S=e[17],y=e[18],w=e[19],M=e[20],_=e[21],N=e[22],$=e[23],q=e[24];if(w!==Symbol.for("react.early_return_sentinel"))return w;let C;e[84]!==c||e[85]!==M?(C=s(c,{children:M}),e[84]=c,e[85]=M,e[86]=C):C=e[86];let k;e[87]!==x||e[88]!==C||e[89]!==_||e[90]!==N?(k=f(x,{"data-testid":_,children:[N,C]}),e[87]=x,e[88]=C,e[89]=_,e[90]=N,e[91]=k):k=e[91];let R;e[92]!==g||e[93]!==k||e[94]!==$?(R=s(g,{className:$,children:k}),e[92]=g,e[93]=k,e[94]=$,e[95]=R):R=e[95];let A;e[96]!==v||e[97]!==R||e[98]!==q?(A=s(v,{className:q,children:R}),e[96]=v,e[97]=R,e[98]=q,e[99]=A):A=e[99];let I;return e[100]!==b||e[101]!==S||e[102]!==y||e[103]!==A?(I=f("section",{className:b,"data-testid":S,children:[y,A]}),e[100]=b,e[101]=S,e[102]=y,e[103]=A,e[104]=I):I=e[104],I},ts=i=>{const e=me(74),{aggregate:l,shardResults:r}=i,t=ge();let o;e[0]!==t?(o=t("Shards"),e[0]=t,e[1]=o):o=e[1];let n;e[2]!==l.failed||e[3]!==l.reachable||e[4]!==t?(n=l.failed>0?t("{reachable} reachable, {failed} unreachable",{failed:l.failed,reachable:l.reachable}):t("{reachable} reachable",{reachable:l.reachable}),e[2]=l.failed,e[3]=l.reachable,e[4]=t,e[5]=n):n=e[5];let a;e[6]!==o||e[7]!==n?(a=s(ce,{label:o,testId:"mt-agg-shards",value:n}),e[6]=o,e[7]=n,e[8]=a):a=e[8];let m;e[9]!==t?(m=t("Total requests"),e[9]=t,e[10]=m):m=e[10];let p;e[11]!==l.totalRequests||e[12]!==m?(p=s(ce,{label:m,testId:"mt-agg-requests",value:l.totalRequests}),e[11]=l.totalRequests,e[12]=m,e[13]=p):p=e[13];let h;e[14]!==t?(h=t("Total errors"),e[14]=t,e[15]=h):h=e[15];let u;e[16]!==l.totalErrors||e[17]!==h?(u=s(ce,{label:h,testId:"mt-agg-errors",value:l.totalErrors}),e[16]=l.totalErrors,e[17]=h,e[18]=u):u=e[18];let d;e[19]!==t?(d=t("Total database size"),e[19]=t,e[20]=d):d=e[20];let c;e[21]!==l.totalDatabaseSize?(c=Xe(l.totalDatabaseSize),e[21]=l.totalDatabaseSize,e[22]=c):c=e[22];let x;e[23]!==d||e[24]!==c?(x=s(ce,{label:d,testId:"mt-agg-db-size",value:c}),e[23]=d,e[24]=c,e[25]=x):x=e[25];let g;e[26]!==t?(g=t("Combined cache hit rate"),e[26]=t,e[27]=g):g=e[27];let v;e[28]!==l.hitRate||e[29]!==t?(v=l.hitRate===null?t("no cache configured"):`${(l.hitRate*100).toFixed(1)}%`,e[28]=l.hitRate,e[29]=t,e[30]=v):v=e[30];let b;e[31]!==g||e[32]!==v?(b=s(ce,{label:g,testId:"mt-agg-cache",value:v}),e[31]=g,e[32]=v,e[33]=b):b=e[33];let S;e[34]!==x||e[35]!==b||e[36]!==a||e[37]!==p||e[38]!==u?(S=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[a,p,u,x,b]}),e[34]=x,e[35]=b,e[36]=a,e[37]=p,e[38]=u,e[39]=S):S=e[39];let y;e[40]!==t?(y=t("shard"),e[40]=t,e[41]=y):y=e[41];let w;e[42]!==y?(w=s(oe,{children:y}),e[42]=y,e[43]=w):w=e[43];let M;e[44]!==t?(M=t("requests"),e[44]=t,e[45]=M):M=e[45];let _;e[46]!==M?(_=s(oe,{children:M}),e[46]=M,e[47]=_):_=e[47];let N;e[48]!==t?(N=t("errors"),e[48]=t,e[49]=N):N=e[49];let $;e[50]!==N?($=s(oe,{children:N}),e[50]=N,e[51]=$):$=e[51];let q;e[52]!==t?(q=t("db size"),e[52]=t,e[53]=q):q=e[53];let C;e[54]!==q?(C=s(oe,{children:q}),e[54]=q,e[55]=C):C=e[55];let k;e[56]!==w||e[57]!==_||e[58]!==$||e[59]!==C?(k=s(dt,{children:f(Ve,{children:[w,_,$,C]})}),e[56]=w,e[57]=_,e[58]=$,e[59]=C,e[60]=k):k=e[60];let R;if(e[61]!==r||e[62]!==t){let L;e[64]!==t?(L=F=>f(Ve,{"data-testid":`mt-agg-row-${F.shard}`,children:[s(ie,{children:F.shard}),F.metrics===null?s(ie,{className:"text-destructive",colSpan:3,children:F.error??t("unreachable")}):f(Ze,{children:[s(ie,{className:"tabular-nums",children:F.metrics.requests}),s(ie,{className:"tabular-nums",children:F.metrics.errors}),s(ie,{className:"tabular-nums",children:Xe(F.metrics.databaseSize)})]})]},F.shard),e[64]=t,e[65]=L):L=e[65],R=r.map(L),e[61]=r,e[62]=t,e[63]=R}else R=e[63];let A;e[66]!==R?(A=s(mt,{children:R}),e[66]=R,e[67]=A):A=e[67];let I;e[68]!==k||e[69]!==A?(I=s(pe,{className:"overflow-hidden py-0",children:s(xe,{className:"px-0",children:f(ct,{"data-testid":"mt-agg-table",children:[k,A]})})}),e[68]=k,e[69]=A,e[70]=I):I=e[70];let E;return e[71]!==S||e[72]!==I?(E=f("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[S,I]}),e[71]=S,e[72]=I,e[73]=E):E=e[73],E},ss=i=>{const e=me(75),{currentDelta:l,errorRate:r,history:t,latencyPercentiles:o,metrics:n}=i,a=ge(),{cache:m}=n;let p;e[0]!==t||e[1]!==a?(p=t.length>=2?s(ft,{ariaLabel:a("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:t,testId:"mt-sparkline"}):void 0,e[0]=t,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==l||e[4]!==t.length||e[5]!==a?(h=t.length>=2?f(Ze,{children:[s("span",{className:"font-semibold text-foreground",children:`+${l.toLocaleString()}`})," ",a("last interval")]}):s("span",{"data-testid":"mt-sparkline-empty",children:a("collecting samples…")}),e[3]=l,e[4]=t.length,e[5]=a,e[6]=h):h=e[6];let u;e[7]!==a?(u=a("Requests"),e[7]=a,e[8]=u):u=e[8];let d;e[9]!==n.requests||e[10]!==p||e[11]!==h||e[12]!==u?(d=s(ce,{chart:p,footer:h,label:u,testId:"mt-requests",value:n.requests}),e[9]=n.requests,e[10]=p,e[11]=h,e[12]=u,e[13]=d):d=e[13];let c;e[14]!==r||e[15]!==a?(c=a("{rate} error rate",{rate:r}),e[14]=r,e[15]=a,e[16]=c):c=e[16];let x;e[17]!==a?(x=a("Errors"),e[17]=a,e[18]=x):x=e[18];let g;e[19]!==r||e[20]!==n.errors?(g=f(Ze,{children:[n.errors," (",r,")"]}),e[19]=r,e[20]=n.errors,e[21]=g):g=e[21];let v;e[22]!==c||e[23]!==x||e[24]!==g?(v=s(ce,{footer:c,label:x,testId:"mt-errors",value:g}),e[22]=c,e[23]=x,e[24]=g,e[25]=v):v=e[25];let b;e[26]!==o.p90?(b=o.p90>0?`P90 ${st(o.p90)}`:void 0,e[26]=o.p90,e[27]=b):b=e[27];let S;e[28]!==a?(S=a("P95 latency"),e[28]=a,e[29]=S):S=e[29];let y;e[30]!==o.p95?(y=o.p95>0?st(o.p95):"—",e[30]=o.p95,e[31]=y):y=e[31];let w;e[32]!==S||e[33]!==y||e[34]!==b?(w=s(ce,{footer:b,label:S,testId:"mt-p95",value:y}),e[32]=S,e[33]=y,e[34]=b,e[35]=w):w=e[35];let M;e[36]!==m||e[37]!==a?(M=m?`${m.entries.toLocaleString()} ${a("cache entries")}`:void 0,e[36]=m,e[37]=a,e[38]=M):M=e[38];let _;e[39]!==a?(_=a("Database size"),e[39]=a,e[40]=_):_=e[40];let N;e[41]!==n.databaseSize?(N=Xe(n.databaseSize),e[41]=n.databaseSize,e[42]=N):N=e[42];let $;e[43]!==M||e[44]!==_||e[45]!==N?($=s(ce,{footer:M,label:_,testId:"mt-db-size",value:N}),e[43]=M,e[44]=_,e[45]=N,e[46]=$):$=e[46];let q;e[47]!==a?(q=a("Shard"),e[47]=a,e[48]=q):q=e[48];let C;e[49]!==n.shard||e[50]!==q?(C=s(ce,{label:q,testId:"mt-shard",value:n.shard}),e[49]=n.shard,e[50]=q,e[51]=C):C=e[51];let k;e[52]!==a?(k=a("Uptime"),e[52]=a,e[53]=k):k=e[53];let R;e[54]!==n.uptimeMs?(R=Et(n.uptimeMs),e[54]=n.uptimeMs,e[55]=R):R=e[55];let A;e[56]!==k||e[57]!==R?(A=s(ce,{label:k,testId:"mt-uptime",value:R}),e[56]=k,e[57]=R,e[58]=A):A=e[58];let I;e[59]!==a?(I=a("Cache hit rate"),e[59]=a,e[60]=I):I=e[60];let E;e[61]!==m||e[62]!==a?(E=m?a("{rate} ({count} entries)",{count:m.entries,rate:Lt(m.hits,m.misses)}):a("no cache configured"),e[61]=m,e[62]=a,e[63]=E):E=e[63];let L;e[64]!==I||e[65]!==E?(L=s(ce,{label:I,testId:"mt-cache",value:E}),e[64]=I,e[65]=E,e[66]=L):L=e[66];let F;return e[67]!==w||e[68]!==$||e[69]!==C||e[70]!==A||e[71]!==L||e[72]!==d||e[73]!==v?(F=f("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[d,v,w,$,C,A,L]}),e[67]=w,e[68]=$,e[69]=C,e[70]=A,e[71]=L,e[72]=d,e[73]=v,e[74]=F):F=e[74],F},Ge=i=>i>=100?"critical":i>=50?"warning":"good",Le=i=>i<1?`${(i*1e3).toFixed(0)}μs`:i<1e3?`${i.toFixed(1)}ms`:`${(i/1e3).toFixed(2)}s`,Ue=i=>i>=1e9?`${(i/1e9).toFixed(1)}B`:i>=1e6?`${(i/1e6).toFixed(1)}M`:i>=1e3?`${(i/1e3).toFixed(1)}K`:i.toLocaleString(),rs=i=>{const e=me(3),{level:l}=i;if(l==="critical"){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=s(et,{variant:"destructive",children:"Slow"}),e[0]=t):t=e[0],t}if(l==="warning"){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=s("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=t):t=e[1],t}let r;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=s("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=r):r=e[2],r},ls=(i,e)=>{const l=[...i];return l.sort((r,t)=>{switch(e){case"avgTime":return t.avgDurationMs-r.avgDurationMs;case"execCount":return t.execCount-r.execCount;case"rowsRead":return t.rowsRead-r.rowsRead;default:return t.totalDurationMs-r.totalDurationMs}}),l},as=i=>{const e=me(161),{queryStats:l}=i,r=ge(),[t,o]=be("totalTime");let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=new Set,e[0]=n):n=e[0];const[a,m]=be(n);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=q=>{q!==null&&o(q)},e[1]=p):p=e[1];const h=p;let u,d,c,x,g,v,b,S,y,w;if(e[2]!==a||e[3]!==l||e[4]!==t||e[5]!==r){c=Symbol.for("react.early_return_sentinel");e:{const q=ls(l,t);let C;e[16]!==l?(C=l.filter(is),e[16]=l,e[17]=C):C=e[17];const k=C.length;let R;e[18]!==l?(R=l.filter(ns),e[18]=l,e[19]=R):R=e[19];const A=R.length;let I;e[20]!==l?(I=l.filter(os),e[20]=l,e[21]=I):I=e[21];const E=I.length;let L;e[22]===Symbol.for("react.memo_cache_sentinel")?(L=D=>{m(ne=>{const B=new Set(ne);return B.has(D)?B.delete(D):B.add(D),B})},e[22]=L):L=e[22];const F=L;if(l.length===0){let D;e[23]!==r?(D=r("No query insights yet"),e[23]=r,e[24]=D):D=e[24];let ne;e[25]!==D?(ne=s("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:D}),e[25]=D,e[26]=ne):ne=e[26];let B;e[27]!==r?(B=r("Query insights appear once statements are executed against this shard."),e[27]=r,e[28]=B):B=e[28];let he;e[29]!==B?(he=s("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=he):he=e[30];let Pe;e[31]!==ne||e[32]!==he?(Pe=s(pe,{children:s(xe,{className:"py-12",children:f("div",{className:"text-center text-muted-foreground",children:[ne,he]})})}),e[31]=ne,e[32]=he,e[33]=Pe):Pe=e[33],c=Pe;break e}b="space-y-4",S="qi-root";let de;e[34]!==r?(de=r("Critical queries"),e[34]=r,e[35]=de):de=e[35];let fe;e[36]!==de?(fe=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:de})}),e[36]=de,e[37]=fe):fe=e[37];let Q;e[38]!==k?(Q=s("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:k}),e[38]=k,e[39]=Q):Q=e[39];let H;e[40]!==r?(H=r(">100ms avg execution"),e[40]=r,e[41]=H):H=e[41];let U;e[42]!==H?(U=s("p",{className:"text-xs text-muted-foreground",children:H}),e[42]=H,e[43]=U):U=e[43];let j;e[44]!==Q||e[45]!==U?(j=f(xe,{children:[Q,U]}),e[44]=Q,e[45]=U,e[46]=j):j=e[46];let V;e[47]!==fe||e[48]!==j?(V=f(pe,{children:[fe,j]}),e[47]=fe,e[48]=j,e[49]=V):V=e[49];let G;e[50]!==r?(G=r("Moderate queries"),e[50]=r,e[51]=G):G=e[51];let Y;e[52]!==G?(Y=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:G})}),e[52]=G,e[53]=Y):Y=e[53];let J;e[54]!==A?(J=s("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:A}),e[54]=A,e[55]=J):J=e[55];let W;e[56]!==r?(W=r("50–100ms avg execution"),e[56]=r,e[57]=W):W=e[57];let X;e[58]!==W?(X=s("p",{className:"text-xs text-muted-foreground",children:W}),e[58]=W,e[59]=X):X=e[59];let Z;e[60]!==J||e[61]!==X?(Z=f(xe,{children:[J,X]}),e[60]=J,e[61]=X,e[62]=Z):Z=e[62];let ee;e[63]!==Y||e[64]!==Z?(ee=f(pe,{children:[Y,Z]}),e[63]=Y,e[64]=Z,e[65]=ee):ee=e[65];let te;e[66]!==r?(te=r("Fast queries"),e[66]=r,e[67]=te):te=e[67];let se;e[68]!==te?(se=s(Be,{className:"pb-2",children:s(Qe,{className:"text-sm font-medium",children:te})}),e[68]=te,e[69]=se):se=e[69];let re;e[70]!==E?(re=s("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:E}),e[70]=E,e[71]=re):re=e[71];let le;e[72]!==r?(le=r("<50ms avg execution"),e[72]=r,e[73]=le):le=e[73];let ae;e[74]!==le?(ae=s("p",{className:"text-xs text-muted-foreground",children:le}),e[74]=le,e[75]=ae):ae=e[75];let T;e[76]!==re||e[77]!==ae?(T=f(xe,{children:[re,ae]}),e[76]=re,e[77]=ae,e[78]=T):T=e[78];let O;e[79]!==se||e[80]!==T?(O=f(pe,{children:[se,T]}),e[79]=se,e[80]=T,e[81]=O):O=e[81],e[82]!==V||e[83]!==ee||e[84]!==O?(y=f("div",{className:"grid gap-4 md:grid-cols-3",children:[V,ee,O]}),e[82]=V,e[83]=ee,e[84]=O,e[85]=y):y=e[85];let z;e[86]!==r?(z=r("Query leaderboard"),e[86]=r,e[87]=z):z=e[87];let K;e[88]!==z?(K=s("h3",{className:"text-lg font-semibold",children:z}),e[88]=z,e[89]=K):K=e[89];let P;e[90]!==t||e[91]!==r?(P=r("Slow queries sorted by {sortField}",{sortField:r(t)}),e[90]=t,e[91]=r,e[92]=P):P=e[92];let ue;e[93]!==P?(ue=s("p",{className:"text-sm text-muted-foreground",children:P}),e[93]=P,e[94]=ue):ue=e[94];let ve;e[95]!==K||e[96]!==ue?(ve=f("div",{children:[K,ue]}),e[95]=K,e[96]=ue,e[97]=ve):ve=e[97];let ye;e[98]!==r?(ye=r("Sort by"),e[98]=r,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=s("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let Se;e[102]!==r?(Se=r("Sort queries by"),e[102]=r,e[103]=Se):Se=e[103];let Oe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Oe=s(Qt,{}),e[104]=Oe):Oe=e[104];let we;e[105]!==Se?(we=s(Ht,{"aria-label":Se,className:"w-[140px]","data-testid":"qi-sort",children:Oe}),e[105]=Se,e[106]=we):we=e[106];let Te;e[107]!==r?(Te=r("Total time"),e[107]=r,e[108]=Te):Te=e[108];let qe;e[109]!==Te?(qe=s(He,{value:"totalTime",children:Te}),e[109]=Te,e[110]=qe):qe=e[110];let _e;e[111]!==r?(_e=r("Avg time"),e[111]=r,e[112]=_e):_e=e[112];let Ce;e[113]!==_e?(Ce=s(He,{value:"avgTime",children:_e}),e[113]=_e,e[114]=Ce):Ce=e[114];let Re;e[115]!==r?(Re=r("Execution count"),e[115]=r,e[116]=Re):Re=e[116];let Me;e[117]!==Re?(Me=s(He,{value:"execCount",children:Re}),e[117]=Re,e[118]=Me):Me=e[118];let ke;e[119]!==r?(ke=r("Rows read"),e[119]=r,e[120]=ke):ke=e[120];let Ae;e[121]!==ke?(Ae=s(He,{value:"rowsRead",children:ke}),e[121]=ke,e[122]=Ae):Ae=e[122];let Ie;e[123]!==qe||e[124]!==Ce||e[125]!==Me||e[126]!==Ae?(Ie=f(Ut,{children:[qe,Ce,Me,Ae]}),e[123]=qe,e[124]=Ce,e[125]=Me,e[126]=Ae,e[127]=Ie):Ie=e[127];let $e;e[128]!==t||e[129]!==we||e[130]!==Ie?($e=f(jt,{onValueChange:h,value:t,children:[we,Ie]}),e[128]=t,e[129]=we,e[130]=Ie,e[131]=$e):$e=e[131];let De;e[132]!==Ne||e[133]!==$e?(De=f("div",{className:"flex items-center gap-2",children:[Ne,$e]}),e[132]=Ne,e[133]=$e,e[134]=De):De=e[134],e[135]!==ve||e[136]!==De?(w=f("div",{className:"flex items-center justify-between",children:[ve,De]}),e[135]=ve,e[136]=De,e[137]=w):w=e[137],d=pe;let Ee;e[138]!==r?(Ee=r("Statements"),e[138]=r,e[139]=Ee):Ee=e[139];let ze;e[140]!==Ee?(ze=s(Qe,{children:Ee}),e[140]=Ee,e[141]=ze):ze=e[141],v=f(Be,{children:[ze,s(Mt,{children:r("{count} tracked statements",{count:q.length})})]}),u=xe,x="space-y-2";let Ke;e[142]!==a||e[143]!==r?(Ke=D=>{const ne=D.normalizedSql,B=a.has(ne),he=Ge(D.avgDurationMs);return f("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[f("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{F(ne)},type:"button",children:[f("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[s(rs,{level:he}),s("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:D.normalizedSql})]}),f("div",{className:"flex shrink-0 items-center gap-4",children:[f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.totalDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("total")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.avgDurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("avg")})]}),D.p95DurationMs!==void 0&&f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Le(D.p95DurationMs)}),s("div",{className:"text-xs text-muted-foreground",children:r("p95")})]}),f("div",{className:"text-right",children:[s("div",{className:"text-sm font-medium",children:Ue(D.execCount)}),s("div",{className:"text-xs text-muted-foreground",children:r("calls")})]})]})]}),B&&f("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[f("div",{children:[s("p",{className:"mb-2 text-sm font-medium",children:r("Full statement")}),s("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:D.normalizedSql})]}),f("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[D.p50DurationMs!==void 0&&f("div",{children:[s("span",{className:"text-muted-foreground",children:r("p50")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.p50DurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Exec count")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.execCount)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Total time")}),s("span",{className:"block font-medium tabular-nums",children:Le(D.totalDurationMs)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows read")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsRead)})]}),f("div",{children:[s("span",{className:"text-muted-foreground",children:r("Rows written")}),s("span",{className:"block font-medium tabular-nums",children:Ue(D.rowsWritten)})]})]})]})]},ne)},e[142]=a,e[143]=r,e[144]=Ke):Ke=e[144],g=q.map(Ke)}e[2]=a,e[3]=l,e[4]=t,e[5]=r,e[6]=u,e[7]=d,e[8]=c,e[9]=x,e[10]=g,e[11]=v,e[12]=b,e[13]=S,e[14]=y,e[15]=w}else u=e[6],d=e[7],c=e[8],x=e[9],g=e[10],v=e[11],b=e[12],S=e[13],y=e[14],w=e[15];if(c!==Symbol.for("react.early_return_sentinel"))return c;let M;e[145]!==x||e[146]!==g?(M=s("div",{className:x,children:g}),e[145]=x,e[146]=g,e[147]=M):M=e[147];let _;e[148]!==u||e[149]!==M?(_=s(u,{children:M}),e[148]=u,e[149]=M,e[150]=_):_=e[150];let N;e[151]!==d||e[152]!==_||e[153]!==v?(N=f(d,{children:[v,_]}),e[151]=d,e[152]=_,e[153]=v,e[154]=N):N=e[154];let $;return e[155]!==N||e[156]!==b||e[157]!==S||e[158]!==y||e[159]!==w?($=f("div",{className:b,"data-testid":S,children:[y,w,N]}),e[155]=N,e[156]=b,e[157]=S,e[158]=y,e[159]=w,e[160]=$):$=e[160],$};function is(i){return Ge(i.avgDurationMs)==="critical"}function ns(i){return Ge(i.avgDurationMs)==="warning"}function os(i){return Ge(i.avgDurationMs)==="good"}const cs=["1m","5m","15m","1h"],ds=i=>new Date(i).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),ms=i=>i.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ds(e.bucketMs)})),fs=({shardKey:i=""})=>{const e=ge(),[l,r]=be("15m"),o=je(Fe.getQueryInsights,{range:l},{live:!0,shardKey:i}).data,n=ms(o?.buckets??[]);return f("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[f("div",{className:"flex flex-wrap items-center gap-2",children:[s("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:cs.map(a=>s("button",{"aria-pressed":a===l,className:Bt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",a===l&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${a}`,onClick:()=>{r(a)},type:"button",children:a},a))}),o?.capped===!0&&s(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),n.length===0?s(Pt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):f("div",{className:"grid gap-4 lg:grid-cols-2",children:[f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),s(rt,{height:140,width:"100%",children:f(Ft,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Ot,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),f("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[s("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),s(rt,{height:140,width:"100%",children:f(zt,{data:n,children:[s(lt,{strokeDasharray:"3 3",vertical:!1}),s(at,{dataKey:"label",fontSize:10,tickLine:!1}),s(it,{fontSize:10,tickLine:!1,width:32}),s(nt,{}),s(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),s(as,{queryStats:o?.entries??[]})]})},us=qt(Fe.getMetrics),hs=[],gs=(i,e)=>i?e:"overview",ps=i=>{const e=me(14);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];let r;e[1]!==i?(r={live:!0,shardKey:i},e[1]=i,e[2]=r):r=e[2];const t=je(Fe.getMetrics,l,r),{data:o}=t;let n;e[3]===Symbol.for("react.memo_cache_sentinel")?(n={points:[],shard:null},e[3]=n):n=e[3];const[a,m]=be(n),p=Je(null),h=Je(null);let u,d;e[4]!==o||e[5]!==i?(u=()=>{o!==void 0&&Ct(i)},d=[o,i],e[4]=o,e[5]=i,e[6]=u,e[7]=d):(u=e[6],d=e[7]),We(u,d);let c,x;e[8]!==o?(c=()=>{if(o===void 0)return;const b=o,S=h.current!==null&&h.current!==b.shard,y=h.current===b.shard?p.current:null;if(h.current=b.shard,p.current=b.requests,S){m({points:[],shard:b.shard});return}y!==null&&b.requests>=y&&m(w=>({points:[...w.shard===b.shard?w.points:[],b.requests-y].slice(-30),shard:b.shard}))},x=[o],e[8]=o,e[9]=c,e[10]=x):(c=e[9],x=e[10]),We(c,x);const g=a.shard!==null&&a.shard===o?.shard?a.points:hs;let v;return e[11]!==t||e[12]!==g?(v={...t,history:g},e[11]=t,e[12]=g,e[13]=v):v=e[13],v},xs=i=>{const e=vt(),l=Je(!0);We(()=>(l.current=!0,()=>{l.current=!1}),[]);const[r,t]=be(null),[o,n]=be(!1),a=async()=>{n(!0);const p=i,h=$t(p,_t());try{const u=await Promise.all(h.map(async d=>{try{const c=await e.query(us,{},wt(d));return{error:null,metrics:c,shard:d===""?c.shard:d}}catch(c){return{error:Tt(c),metrics:null,shard:d===""?"__root__":d}}}));l.current&&t({results:u,shard:p})}finally{l.current&&n(!1)}},m=r?.shard===i?r.results:null;return{aggregate:m===null?null:At(m),aggregating:o,clearAggregate:()=>{t(null)},runAggregate:()=>{St(a())},shardResults:m}},bs=i=>{if(!i||!("queryStats"in i))return;const e=i.queryStats;if(!(!e||!Array.isArray(e)))return It(e)},ot=i=>`pb-2 text-sm font-medium transition-colors ${i?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,vs=i=>{const e=me(26),{activeTab:l,onSelect:r,queryCount:t}=i,o=ge();let n;e[0]!==r?(n=()=>{r("overview")},e[0]=r,e[1]=n):n=e[1];const a=n;let m;e[2]!==r?(m=()=>{r("query-insights")},e[2]=r,e[3]=m):m=e[3];const p=m,h=l==="overview";let u;e[4]!==h?(u=ot(h),e[4]=h,e[5]=u):u=e[5];let d;e[6]!==o?(d=o("Overview"),e[6]=o,e[7]=d):d=e[7];let c;e[8]!==a||e[9]!==u||e[10]!==d?(c=s("button",{className:u,"data-testid":"mt-tab-overview",onClick:a,type:"button",children:d}),e[8]=a,e[9]=u,e[10]=d,e[11]=c):c=e[11];const x=l==="query-insights";let g;e[12]!==x?(g=ot(x),e[12]=x,e[13]=g):g=e[13];let v;e[14]!==o?(v=o("Query insights"),e[14]=o,e[15]=v):v=e[15];let b;e[16]!==t?(b=t>0&&s("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:t}),e[16]=t,e[17]=b):b=e[17];let S;e[18]!==p||e[19]!==b||e[20]!==g||e[21]!==v?(S=f("button",{className:g,"data-testid":"mt-tab-query-insights",onClick:p,type:"button",children:[v,b]}),e[18]=p,e[19]=b,e[20]=g,e[21]=v,e[22]=S):S=e[22];let y;return e[23]!==S||e[24]!==c?(y=f("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[c,S]}),e[23]=S,e[24]=c,e[25]=y):y=e[25],y},ys=i=>{const e=me(13),{history:l,metrics:r}=i;let t;e[0]!==l?(t=l.at(-1)??0,e[0]=l,e[1]=t):t=e[1];let o;e[2]!==r.errors||e[3]!==r.requests?(o=r.requests===0?"—":`${(r.errors/r.requests*100).toFixed(1)}%`,e[2]=r.errors,e[3]=r.requests,e[4]=o):o=e[4];let n;e[5]!==r?(n=Dt(r),e[5]=r,e[6]=n):n=e[6];let a;return e[7]!==l||e[8]!==r||e[9]!==t||e[10]!==o||e[11]!==n?(a=s(ss,{currentDelta:t,errorRate:o,history:l,latencyPercentiles:n,metrics:r}),e[7]=l,e[8]=r,e[9]=t,e[10]=o,e[11]=n,e[12]=a):a=e[12],a},Ns=i=>{const e=me(25),{aggregating:l,liveError:r,onAggregate:t,onClearAggregate:o,onShardKeyChange:n,shardKey:a}=i,m=ge();let p;e[0]!==n||e[1]!==a?(p=s(pt,{onChange:n,testId:"mt-shard-input",value:a}),e[0]=n,e[1]=a,e[2]=p):p=e[2];let h;e[3]!==r?(h=s(gt,{message:r,prefix:"mt"}),e[3]=r,e[4]=h):h=e[4];let u;e[5]!==l||e[6]!==m?(u=m(l?"Aggregating…":"All shards"),e[5]=l,e[6]=m,e[7]=u):u=e[7];let d;e[8]!==l||e[9]!==t||e[10]!==u?(d=s(tt,{"data-testid":"mt-aggregate",disabled:l,onClick:t,size:"sm",type:"button",variant:"secondary",children:u}),e[8]=l,e[9]=t,e[10]=u,e[11]=d):d=e[11];let c;e[12]!==o||e[13]!==m?(c=o!==void 0&&s(tt,{"data-testid":"mt-aggregate-clear",onClick:o,size:"sm",type:"button",variant:"ghost",children:m("Hide")}),e[12]=o,e[13]=m,e[14]=c):c=e[14];let x;e[15]!==m?(x=m("Open in Cloudflare"),e[15]=m,e[16]=x):x=e[16];let g;e[17]!==x?(g=s("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:yt,rel:"noreferrer",target:"_blank",children:x}),e[17]=x,e[18]=g):g=e[18];let v;return e[19]!==p||e[20]!==h||e[21]!==d||e[22]!==c||e[23]!==g?(v=f("div",{className:"flex flex-wrap items-center gap-2",children:[p,h,d,c,g]}),e[19]=p,e[20]=h,e[21]=d,e[22]=c,e[23]=g,e[24]=v):v=e[24],v},Js=i=>{const e=me(41),{initialShardKey:l}=i,{queryShardKey:r,setShardKey:t,shardKey:o}=bt(l),[n,a]=be("overview"),m=xt(r),{data:p,error:h,history:u,liveError:d}=ps(r),c=p??null,{aggregate:x,aggregating:g,clearAggregate:v,runAggregate:b,shardResults:S}=xs(o);let y;e[0]!==c?(y=bs(c),e[0]=c,e[1]=y):y=e[1];const w=y,M=w!==void 0;let _;e[2]!==n||e[3]!==M?(_=gs(M,n),e[2]=n,e[3]=M,e[4]=_):_=e[4];const N=_,$=S===null?void 0:v;let q;e[5]!==g||e[6]!==d||e[7]!==b||e[8]!==t||e[9]!==o||e[10]!==$?(q=s(Ns,{aggregating:g,liveError:d,onAggregate:b,onClearAggregate:$,onShardKeyChange:t,shardKey:o}),e[5]=g,e[6]=d,e[7]=b,e[8]=t,e[9]=o,e[10]=$,e[11]=q):q=e[11];let C;e[12]!==h?(C=h!==null&&s("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:h}),e[12]=h,e[13]=C):C=e[13];let k;e[14]!==N||e[15]!==w?(k=w!==void 0&&s(vs,{activeTab:N,onSelect:a,queryCount:w.length}),e[14]=N,e[15]=w,e[16]=k):k=e[16];let R;e[17]!==N||e[18]!==r||e[19]!==w?(R=N==="query-insights"&&w!==void 0&&s(fs,{shardKey:r}),e[17]=N,e[18]=r,e[19]=w,e[20]=R):R=e[20];let A;e[21]!==N||e[22]!==u||e[23]!==c?(A=N==="overview"&&c!==null&&s(ys,{history:u,metrics:c}),e[21]=N,e[22]=u,e[23]=c,e[24]=A):A=e[24];let I;e[25]!==N||e[26]!==m||e[27]!==r?(I=N==="overview"&&s(es,{onOpenTrace:m,shardKey:r}),e[25]=N,e[26]=m,e[27]=r,e[28]=I):I=e[28];let E;e[29]!==x||e[30]!==N||e[31]!==S?(E=N==="overview"&&x!==null&&S!==null&&s(ts,{aggregate:x,shardResults:S}),e[29]=x,e[30]=N,e[31]=S,e[32]=E):E=e[32];let L;return e[33]!==I||e[34]!==E||e[35]!==q||e[36]!==C||e[37]!==k||e[38]!==R||e[39]!==A?(L=f("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[q,C,k,R,A,I,E]}),e[33]=I,e[34]=E,e[35]=q,e[36]=C,e[37]=k,e[38]=R,e[39]=A,e[40]=L):L=e[40],L};export{Js as MetricsPanel};
@@ -0,0 +1 @@
1
+ import{c as D}from"react/compiler-runtime";import{useState as j}from"react";import{E as K}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as L}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as F}from"../packem_shared/button-q0UYSmrn.mjs";import{C as O,a as Q}from"../packem_shared/card-By2O8ULa.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as q}from"../packem_shared/input-CXhxesPC.mjs";import{T as G,a as J,b as H,c as h,d as X,e as u}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Y}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as _}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{h as ee}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",M=e=>e.endpoint??e.id,ge=()=>{const e=D(38),r=Z(),[a,P]=j("all"),[n,V]=j("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const{data:T,error:i,errorSource:p,isLoading:v,refetch:g}=Y(_.listPushSubscriptions,b);let N;if(e[1]!==T?.subscriptions||e[2]!==i||e[3]!==p||e[4]!==v||e[5]!==a||e[6]!==g||e[7]!==n||e[8]!==r){const I=T?.subscriptions??[],$=n.trim().toLowerCase(),A=I.filter(s=>a!=="all"&&s.kind!==a?!1:$===""?!0:`${M(s)} ${s.userId??""}`.toLowerCase().includes($));let w;e[10]===Symbol.for("react.memo_cache_sentinel")?(w=s=>{V(s.target.value)},e[10]=w):w=e[10];const z=w;let y;e[11]!==g?(y=()=>{g()},e[11]=g,e[12]=y):y=e[12];const B=y;let C;e[13]===Symbol.for("react.memo_cache_sentinel")?(C=["all","web-push","fcm"],e[13]=C):C=e[13];const W=C;let o;e[14]!==a||e[15]!==r?(o=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:W.map(s=>t(F,{"aria-selected":a===s,"data-testid":`nt-kind-${s}`,onClick:()=>{P(s)},role:"tab",size:"sm",type:"button",variant:a===s?"secondary":"ghost",children:s==="all"?r("All"):s},s))}),e[14]=a,e[15]=r,e[16]=o):o=e[16];let l;e[17]!==r?(l=r("Filter devices"),e[17]=r,e[18]=l):l=e[18];let d;e[19]!==r?(d=r("filter endpoint, user"),e[19]=r,e[20]=d):d=e[20];let c;e[21]!==n||e[22]!==l||e[23]!==d?(c=t(q,{"aria-label":l,className:"h-8 w-56","data-testid":"nt-search",onChange:z,placeholder:d,value:n}),e[21]=n,e[22]=l,e[23]=d,e[24]=c):c=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let f;e[27]!==B||e[28]!==m?(f=t(F,{className:"ml-auto","data-testid":"nt-refresh",onClick:B,size:"sm",type:"button",variant:"outline",children:m}),e[27]=B,e[28]=m,e[29]=f):f=e[29];const E=I.length>0&&t(L,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:I.length})});let k;e[30]!==f||e[31]!==E||e[32]!==o||e[33]!==c?(k=x("div",{className:"flex flex-wrap items-center gap-2",children:[o,c,f,E]}),e[30]=f,e[31]=E,e[32]=o,e[33]=c,e[34]=k):k=e[34];let S;e[35]!==i||e[36]!==p?(S=i!==null&&t(K,{error:p,testId:"nt-error"}),e[35]=i,e[36]=p,e[37]=S):S=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[k,S,i===null&&!v&&A.length===0&&t(U,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),A.length>0&&t(O,{className:"overflow-hidden py-0",children:t(Q,{className:"max-h-[30rem] overflow-auto px-0",children:x(G,{"data-testid":"nt-table",children:[t(J,{children:x(H,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(X,{children:A.map(s=>{const R=M(s);return x(H,{"data-testid":"nt-row",children:[t(u,{children:t(L,{variant:"outline",children:s.kind})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs",title:R,children:R}),t(u,{className:"max-w-[16ch] truncate font-mono text-xs",children:s.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(u,{className:"text-muted-foreground tabular-nums",children:ee(s.lastSeenAt,"—")}),t(u,{children:t(L,{"data-testid":`nt-status-${s.id}`,variant:te(s.lastStatus),children:s.lastStatus??r("n/a")})}),t(u,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:s.lastError??void 0,children:s.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},s.id)})})]})})})]}),e[1]=T?.subscriptions,e[2]=i,e[3]=p,e[4]=v,e[5]=a,e[6]=g,e[7]=n,e[8]=r,e[9]=N}else N=e[9];return N};export{ge as default};
@@ -0,0 +1 @@
1
+ import{c as Ke}from"react/compiler-runtime";import{useState as k,useEffect as We}from"react";import{ConfirmButton as Le}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as Xe}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Ye}from"../packem_shared/button-q0UYSmrn.mjs";import{I as Ue}from"../packem_shared/input-CXhxesPC.mjs";import{L as Se}from"../packem_shared/label-DKFzyHq6.mjs";import{useAutoRefresh as et}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{u as tt}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as rt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as je}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as qe}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{c as ze,d as _e,j as Fe,b as Pe,f as Ae}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as i,jsx as s}from"react/jsx-runtime";const Me=ze(qe.getPitrBookmark),st=ze(qe.pitrRestore),ot=/^\d+$/u,De=ne=>{const e=ne.trim(),u=ot.test(e)?Number(e):Date.parse(e),l=new Date(u);return Number.isNaN(l.getTime())?void 0:{epochMs:u,iso:l.toISOString()}},lt=ne=>{const e=Ke(9),{text:u}=ne,l=je();if(u.trim()==="")return null;let t,r,f;if(e[0]!==l||e[1]!==u){const y=De(u);t="font-mono text-xs text-muted-foreground",r="pitr-time-resolved",f=y===void 0?l("Not a time — use epoch-ms or ISO 8601."):l("Resolves to {instant} (a date-time without an offset is read in this browser's time zone; a bare date is UTC)",{instant:y.iso}),e[0]=l,e[1]=u,e[2]=t,e[3]=r,e[4]=f}else t=e[2],r=e[3],f=e[4];let v;return e[5]!==t||e[6]!==r||e[7]!==f?(v=s("p",{className:t,"data-testid":r,children:f}),e[5]=t,e[6]=r,e[7]=f,e[8]=v):v=e[8],v},Nt=ne=>{const e=Ke(140),{initialShardKey:u}=ne,l=rt(),t=je(),r=u??"",f=tt(r),[v,y]=k(null),[p,$e]=k(""),[de,Oe]=k(null),[d,He]=k(""),[h,Ve]=k(!1),[n,Ge]=k(null),[me,R]=k(null),[ce,_]=k(!1),[w,Ee]=k(!1);let fe;e[0]!==l||e[1]!==r?(fe=async o=>{_(!0),R(null);let c;try{c={current:(await l.query(Me,{},_e(r))).current,error:null,unavailable:!1}}catch(a){const N=a;c={current:null,error:Pe(N),unavailable:Fe(N)==="PITR_UNAVAILABLE"}}o?.aborted!==!0&&(c.error===null?y(c.current):R(c.error),Ee(c.unavailable),_(!1))},e[0]=l,e[1]=r,e[2]=fe):fe=e[2];const b=fe;let ue,pe;e[3]!==b?(ue=()=>{const o=new AbortController;return Ae(b(o.signal)),()=>{o.abort()}},pe=[b],e[3]=b,e[4]=ue,e[5]=pe):(ue=e[4],pe=e[5]),We(ue,pe);let he;e[6]!==l||e[7]!==r?(he=async()=>{const o=await l.query(Me,{},_e(r));y(o.current)},e[6]=l,e[7]=r,e[8]=he):he=e[8],et(he,!w);let be;e[9]===Symbol.for("react.memo_cache_sentinel")?(be=o=>{$e(o.target.value)},e[9]=be):be=e[9];const Ze=be;let xe;e[10]===Symbol.for("react.memo_cache_sentinel")?(xe=o=>{He(o.target.value)},e[10]=xe):xe=e[10];const Je=xe;let ke;e[11]===Symbol.for("react.memo_cache_sentinel")?(ke=o=>{Ve(o.target.checked)},e[11]=ke):ke=e[11];const Qe=ke;let ve,C,m,x,g,ge;if(e[12]!==d||e[13]!==l||e[14]!==de||e[15]!==b||e[16]!==r||e[17]!==f||e[18]!==t||e[19]!==p){m=De(p),C=()=>{if(m===void 0)return;const c=r;Ae((async()=>{_(!0),R(null);let a;try{a={result:await l.query(Me,{time:m.epochMs},_e(c))}}catch(N){a={error:Pe(N)}}f.current===c&&("result"in a?(Oe(a.result.forTime===void 0?null:{bookmark:a.result.forTime,shard:c}),y(a.result.current)):(Oe(null),R(a.error)),_(!1))})())},g=de?.shard===r?de.bookmark:null;let o;e[26]!==l||e[27]!==b||e[28]!==r?(o=c=>{Ae((async()=>{_(!0),R(null);try{const a=await l.mutation(st,c,_e(r));Ge(a),await b()}catch(a){const N=a;R(Pe(N)),Fe(N)==="PITR_UNAVAILABLE"&&Ee(!0)}_(!1)})())},e[26]=l,e[27]=b,e[28]=r,e[29]=o):o=e[29],x=o,ve=d.trim()!==""||m!==void 0,ge=t("Restore {shard} to {target}?",{shard:r===""?t("root"):r,target:d.trim()===""?m?.iso??"":t("the given bookmark")}),e[12]=d,e[13]=l,e[14]=de,e[15]=b,e[16]=r,e[17]=f,e[18]=t,e[19]=p,e[20]=ve,e[21]=C,e[22]=m,e[23]=x,e[24]=g,e[25]=ge}else ve=e[20],C=e[21],m=e[22],x=e[23],g=e[24],ge=e[25];const we=ge;let Ne;e[30]!==d||e[31]!==m?.epochMs||e[32]!==h||e[33]!==x?(Ne=()=>{const o=h?{restart:!0}:{};d.trim()===""?o.time=m?.epochMs:o.bookmark=d.trim(),x(o)},e[30]=d,e[31]=m?.epochMs,e[32]=h,e[33]=x,e[34]=Ne):Ne=e[34];const Ce=Ne;let ye;e[35]!==h||e[36]!==n||e[37]!==x?(ye=()=>{n!==null&&x(h?{bookmark:n.undoBookmark,restart:!0}:{bookmark:n.undoBookmark})},e[35]=h,e[36]=n,e[37]=x,e[38]=ye):ye=e[38];const Te=ye;let T;e[39]!==t?(T=t("Shard"),e[39]=t,e[40]=T):T=e[40];let B;e[41]!==r||e[42]!==t?(B=r===""?t("root"):r,e[41]=r,e[42]=t,e[43]=B):B=e[43];let I;e[44]!==B?(I=s("span",{className:"font-mono",children:B}),e[44]=B,e[45]=I):I=e[45];let S;e[46]!==T||e[47]!==I?(S=s("div",{className:"flex flex-wrap items-center gap-3",children:i("span",{className:"text-xs text-muted-foreground",children:[T,": ",I]})}),e[46]=T,e[47]=I,e[48]=S):S=e[48];let P;e[49]!==t?(P=t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier."),e[49]=t,e[50]=P):P=e[50];let A;e[51]!==P?(A=s("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:P}),e[51]=P,e[52]=A):A=e[52];let M;e[53]!==me?(M=me!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:me}),e[53]=me,e[54]=M):M=e[54];let O;e[55]!==t?(O=t("Current bookmark"),e[55]=t,e[56]=O):O=e[56];let E;e[57]!==O?(E=s("h3",{className:"mb-2 text-sm font-semibold",children:O}),e[57]=O,e[58]=E):E=e[58];let L;e[59]!==v?(L=v??s("span",{className:"text-muted-foreground",children:"—"}),e[59]=v,e[60]=L):L=e[60];let U;e[61]!==L?(U=s("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:L}),e[61]=L,e[62]=U):U=e[62];let F;e[63]!==E||e[64]!==U?(F=i("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[E,U]}),e[63]=E,e[64]=U,e[65]=F):F=e[65];let K;e[66]!==t?(K=t("Restore"),e[66]=t,e[67]=K):K=e[67];let j;e[68]!==K?(j=s("h3",{className:"text-sm font-semibold",children:K}),e[68]=K,e[69]=j):j=e[69];let q;e[70]!==t?(q=t("Time (ISO or epoch-ms, last 30 days)"),e[70]=t,e[71]=q):q=e[71];let z;e[72]!==q?(z=s(Se,{htmlFor:"pitr-time",children:q}),e[72]=q,e[73]=z):z=e[73];let D;e[74]!==p?(D=s(Ue,{"data-testid":"pitr-time",id:"pitr-time",onChange:Ze,placeholder:"2026-06-01T00:00:00.000Z",value:p}),e[74]=p,e[75]=D):D=e[75];const Be=ce||w||m===void 0;let $;e[76]!==t?($=t("Preview"),e[76]=t,e[77]=$):$=e[77];let H;e[78]!==C||e[79]!==Be||e[80]!==$?(H=s(Ye,{"data-testid":"pitr-preview",disabled:Be,onClick:C,size:"sm",type:"button",variant:"outline",children:$}),e[78]=C,e[79]=Be,e[80]=$,e[81]=H):H=e[81];let V;e[82]!==D||e[83]!==H?(V=i("div",{className:"flex items-center gap-2",children:[D,H]}),e[82]=D,e[83]=H,e[84]=V):V=e[84];let G;e[85]!==p?(G=s(lt,{text:p}),e[85]=p,e[86]=G):G=e[86];let Z;e[87]!==g||e[88]!==t?(Z=g!==null&&i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",g]}),e[87]=g,e[88]=t,e[89]=Z):Z=e[89];let J;e[90]!==z||e[91]!==V||e[92]!==G||e[93]!==Z?(J=i("div",{className:"flex flex-col gap-1",children:[z,V,G,Z]}),e[90]=z,e[91]=V,e[92]=G,e[93]=Z,e[94]=J):J=e[94];let Q;e[95]!==t?(Q=t("Or an explicit bookmark (wins over time)"),e[95]=t,e[96]=Q):Q=e[96];let W;e[97]!==Q?(W=s(Se,{htmlFor:"pitr-bookmark",children:Q}),e[97]=Q,e[98]=W):W=e[98];let X;e[99]!==t?(X=t("bookmark string"),e[99]=t,e[100]=X):X=e[100];let Y;e[101]!==d||e[102]!==X?(Y=s(Ue,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:Je,placeholder:X,value:d}),e[101]=d,e[102]=X,e[103]=Y):Y=e[103];let ee;e[104]!==W||e[105]!==Y?(ee=i("div",{className:"flex flex-col gap-1",children:[W,Y]}),e[104]=W,e[105]=Y,e[106]=ee):ee=e[106];let te;e[107]!==h?(te=s("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:Qe,type:"checkbox"}),e[107]=h,e[108]=te):te=e[108];let re;e[109]!==t?(re=t("Restart the shard now so recovery applies immediately"),e[109]=t,e[110]=re):re=e[110];let se;e[111]!==te||e[112]!==re?(se=i(Se,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[te,re]}),e[111]=te,e[112]=re,e[113]=se):se=e[113];const Ie=ce||w||!ve;let oe;e[114]!==t?(oe=t("Restore"),e[114]=t,e[115]=oe):oe=e[115];let le;e[116]!==we||e[117]!==Ce||e[118]!==Ie||e[119]!==oe?(le=s("div",{children:s(Le,{confirmLabel:we,disabled:Ie,onConfirm:Ce,testId:"pitr-restore",children:oe})}),e[116]=we,e[117]=Ce,e[118]=Ie,e[119]=oe,e[120]=le):le=e[120];let ae;e[121]!==j||e[122]!==J||e[123]!==ee||e[124]!==se||e[125]!==le?(ae=i("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[j,J,ee,se,le]}),e[121]=j,e[122]=J,e[123]=ee,e[124]=se,e[125]=le,e[126]=ae):ae=e[126];let ie;e[127]!==ce||e[128]!==Te||e[129]!==n||e[130]!==t||e[131]!==w?(ie=n!==null&&i("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[i("div",{className:"flex items-center gap-2",children:[s("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),s(Xe,{variant:n.restarted?"destructive":"secondary",children:n.restarted?t("restarted now"):t("on next restart")})]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",n.restoredTo]}),i("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",n.undoBookmark]}),s("div",{children:s(Le,{confirmLabel:t("Confirm undo"),disabled:ce||w,onConfirm:Te,testId:"pitr-undo",children:t("Undo restore")})})]}),e[127]=ce,e[128]=Te,e[129]=n,e[130]=t,e[131]=w,e[132]=ie):ie=e[132];let Re;return e[133]!==S||e[134]!==A||e[135]!==M||e[136]!==F||e[137]!==ae||e[138]!==ie?(Re=i("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[S,A,M,F,ae,ie]}),e[133]=S,e[134]=A,e[135]=M,e[136]=F,e[137]=ae,e[138]=ie,e[139]=Re):Re=e[139],Re};export{Nt as PitrPanel};
@@ -0,0 +1 @@
1
+ import{c as we}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{S as Ke,T as Pe}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{B as Fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{c as Ge,d as ze,b as Be,a as De,C as je}from"../packem_shared/card-By2O8ULa.mjs";import{E as et}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ke}from"../packem_shared/input-CXhxesPC.mjs";import{useT as Oe}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as Le,d as Ae,b as $e,f as Ce}from"../packem_shared/internal-hIuTpSbx.mjs";import{c as Qe}from"../packem_shared/utils-bhneXptQ.mjs";import{useState as _,useRef as Ue,useEffect as qe}from"react";import{u as tt}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{ADMIN_FUNCTIONS as Me}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{r as st}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{S as at}from"../packem_shared/schema-diagram-CtVPhOGj.mjs";import{useNavigate as nt}from"@tanstack/react-router";import{B as ye}from"../packem_shared/button-q0UYSmrn.mjs";import{L as Ee}from"../packem_shared/label-DKFzyHq6.mjs";import{jsx as l,jsxs as p,Fragment as Ve}from"react/jsx-runtime";const ot=Le(Me.listTables),it=Le(Me.listTableIndexes),rt=Le(Me.readTablePage),dt=Le(Me.describeTables),ct={},Ye=[],mt=n=>{const e=we(74),{initialShardKey:m,initialTable:a}=n,t=lt(),[s,c]=_("graph"),{queryShardKey:d,setShardKey:r,shardKey:g}=tt(m),[o,u]=_(""),[i,v]=_(null),[f,O]=_(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[G,y]=_(S);let L;e[1]===Symbol.for("react.memo_cache_sentinel")?(L={},e[1]=L):L=e[1];const[$,z]=_(L),[T,C]=_(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[F,pe]=_(A);let te;e[3]===Symbol.for("react.memo_cache_sentinel")?(te={},e[3]=te):te=e[3];const[E,M]=_(te),[w,ge]=_(null),[B,ce]=_(null);let le;e[4]===Symbol.for("react.memo_cache_sentinel")?(le={},e[4]=le):le=e[4];const[J,Ne]=_(le),[W,me]=_(null),be=Ue(0);let D;e[5]!==t?(D=async h=>{be.current=be.current+1;const x=be.current;O(null);try{const N=await t.query(ot,{},Ae(h));if(x!==be.current)return;st(h),v(N),y({}),z({}),C(null),pe(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h}))),M(k=>Object.fromEntries(Object.entries(k).filter(I=>{const[he]=I;return he!==h})))}catch(N){const k=N;if(x!==be.current)return;v(null),O($e(k))}},e[5]=t,e[6]=D):D=e[6];const j=D;let se;e[7]!==t?(se=async()=>{ce(null);try{ge(await t.listGlobalTables())}catch(h){const x=h;ge(null),ce($e(x))}},e[7]=t,e[8]=se):se=e[8];const ue=se;let R,ae;e[9]!==d||e[10]!==j||e[11]!==ue?(R=()=>{Ce(j(d)),Ce(ue())},ae=[j,ue,d],e[9]=d,e[10]=j,e[11]=ue,e[12]=R,e[13]=ae):(R=e[12],ae=e[13]),qe(R,ae);let K;e[14]!==t||e[15]!==G||e[16]!==T||e[17]!==d?(K=async h=>{if(T===h){C(null);return}C(h);const x=`${d}:${h}`;if(G[x]!==void 0)return;const[N,k]=await Promise.allSettled([t.query(rt,{limit:1,offset:0,table:h},Ae(d)),t.query(it,{table:h},Ae(d))]);N.status==="fulfilled"?y(I=>({...I,[x]:N.value.columns})):O($e(N.reason)),k.status==="fulfilled"&&z(I=>({...I,[x]:k.value.indexes}))},e[14]=t,e[15]=G,e[16]=T,e[17]=d,e[18]=K):K=e[18];const ne=K;let oe;e[19]!==t||e[20]!==J||e[21]!==W?(oe=async h=>{if(W===h){me(null);return}if(me(h),J[h]===void 0)try{const x=await t.readGlobalTablePage({limit:1,offset:0,table:h});Ne(N=>({...N,[h]:x.columns}))}catch(x){ce($e(x))}},e[19]=t,e[20]=J,e[21]=W,e[22]=oe):oe=e[22];const fe=oe,X=Ue(void 0);let Q,U;e[23]!==a||e[24]!==i||e[25]!==ne?(Q=()=>{a===void 0||i===null||X.current===a||i.some(h=>h.name===a)&&(X.current=a,Ce(ne(a)))},U=[a,i,ne],e[23]=a,e[24]=i,e[25]=ne,e[26]=Q,e[27]=U):(Q=e[26],U=e[27]),qe(Q,U);let ie;e[28]!==t?(ie=async(h,x,N)=>{const[k,I]=await Promise.all([Promise.allSettled([t.query(dt,{tables:[...x,...N]},Ae(h))]),Promise.all(N.map(async H=>{const Se=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:H})]),Re=Se[0].status==="fulfilled"?Se[0].value:void 0;return{columns:Re?.columns??[],refs:Re?.refs??{},table:H}}))]),he=k[0].status==="fulfilled"?k[0].value?.columnsByTable??{}:{},_e=k[0].status==="rejected",Ie=new Map(I.map(ut)),q=[...x,...N].map(H=>{const Se=he[H]??[];return[H,Se.length>0?Se:Ie.get(H)??[]]});pe(H=>({...H,[h]:Object.fromEntries(q)})),M(H=>({...H,[h]:_e}))},e[28]=t,e[29]=ie):ie=e[29];const V=ie;let re,Y;e[30]!==B||e[31]!==w||e[32]!==V||e[33]!==d||e[34]!==F||e[35]!==i||e[36]!==s?(re=()=>{s!=="graph"||i===null||w===null&&B===null||F[d]!==void 0||Ce(V(d,i.map(ft),(w??[]).map(ht)))},Y=[s,i,w,B,d,F,V],e[30]=B,e[31]=w,e[32]=V,e[33]=d,e[34]=F,e[35]=i,e[36]=s,e[37]=re,e[38]=Y):(re=e[37],Y=e[38]),qe(re,Y);const P=F[d]??ct;let Z;if(e[39]!==P||e[40]!==w||e[41]!==i){let h;e[43]!==P?(h=I=>({columns:P[I.name]??Ye,name:I.name,tier:"shard"}),e[43]=P,e[44]=h):h=e[44];const x=(i??[]).map(h);let N;e[45]!==P?(N=I=>({columns:P[I.name]??Ye,name:I.name,tier:"global"}),e[45]=P,e[46]=N):N=e[46];const k=(w??[]).map(N);Z=[...x,...k],e[39]=P,e[40]=w,e[41]=i,e[42]=Z}else Z=e[42];const b=Z;let ee;if(e[47]!==o||e[48]!==i){const h=o.trim().toLowerCase();ee=(i??[]).filter(x=>x.name.toLowerCase().includes(h)),e[47]=o,e[48]=i,e[49]=ee}else ee=e[49];const de=ee;let xe;if(e[50]!==w||e[51]!==o){const h=o.trim().toLowerCase();xe=(w??[]).filter(x=>x.name.toLowerCase().includes(h)),e[50]=w,e[51]=o,e[52]=xe}else xe=e[52];const Te=xe;let ve;return e[53]!==G||e[54]!==b||e[55]!==f||e[56]!==T||e[57]!==Te||e[58]!==de||e[59]!==J||e[60]!==B||e[61]!==W||e[62]!==w||e[63]!==$||e[64]!==j||e[65]!==r||e[66]!==E||e[67]!==g||e[68]!==o||e[69]!==i||e[70]!==ne||e[71]!==fe||e[72]!==s?(ve={columns:G,diagramTables:b,error:f,expanded:T,filteredGlobalTables:Te,filteredTables:de,globalColumns:J,globalError:B,globalExpanded:W,globalTables:w,indexes:$,refresh:j,setShardKey:r,setTableFilter:u,setView:c,shardColumnsError:E,shardKey:g,tableFilter:o,tables:i,toggle:ne,toggleGlobal:fe,view:s},e[53]=G,e[54]=b,e[55]=f,e[56]=T,e[57]=Te,e[58]=de,e[59]=J,e[60]=B,e[61]=W,e[62]=w,e[63]=$,e[64]=j,e[65]=r,e[66]=E,e[67]=g,e[68]=o,e[69]=i,e[70]=ne,e[71]=fe,e[72]=s,e[73]=ve):ve=e[73],ve};function ut(n){const{columns:e,refs:m,table:a}=n;return[a,e.map(t=>{const s=m[t];return s===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:s,type:"id"}})]}function ft(n){return n.name}function ht(n){return n.name}const pt="/__lunora/schema-edit",gt=async n=>{const e=await fetch(pt,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=n=>{const e=we(32),{hasTables:m,mode:a,onAddColumn:t,onAddIndex:s,onAddTable:c,onDestructive:d}=n,r=Oe(),g=a==="addTable"?"default":"outline";let o;e[0]!==r?(o=r("Add table"),e[0]=r,e[1]=o):o=e[1];let u;e[2]!==c||e[3]!==g||e[4]!==o?(u=l(ye,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:g,children:o}),e[2]=c,e[3]=g,e[4]=o,e[5]=u):u=e[5];const i=!m,v=a==="addColumn"?"default":"outline";let f;e[6]!==r?(f=r("Add column"),e[6]=r,e[7]=f):f=e[7];let O;e[8]!==t||e[9]!==i||e[10]!==v||e[11]!==f?(O=l(ye,{"data-testid":"sc-editor-add-column",disabled:i,onClick:t,size:"xs",type:"button",variant:v,children:f}),e[8]=t,e[9]=i,e[10]=v,e[11]=f,e[12]=O):O=e[12];const S=!m,G=a==="addIndex"?"default":"outline";let y;e[13]!==r?(y=r("Add index"),e[13]=r,e[14]=y):y=e[14];let L;e[15]!==s||e[16]!==y||e[17]!==S||e[18]!==G?(L=l(ye,{"data-testid":"sc-editor-add-index",disabled:S,onClick:s,size:"xs",type:"button",variant:G,children:y}),e[15]=s,e[16]=y,e[17]=S,e[18]=G,e[19]=L):L=e[19];const $=!m,z=a==="destructive"?"default":"ghost";let T;e[20]!==r?(T=r("Rename / drop / change type…"),e[20]=r,e[21]=T):T=e[21];let C;e[22]!==d||e[23]!==$||e[24]!==z||e[25]!==T?(C=l(ye,{"data-testid":"sc-editor-destructive",disabled:$,onClick:d,size:"xs",type:"button",variant:z,children:T}),e[22]=d,e[23]=$,e[24]=z,e[25]=T,e[26]=C):C=e[26];let A;return e[27]!==L||e[28]!==C||e[29]!==u||e[30]!==O?(A=p("div",{className:"flex flex-wrap gap-2",children:[u,O,L,C]}),e[27]=L,e[28]=C,e[29]=u,e[30]=O,e[31]=A):A=e[31],A},xt=n=>{const e=we(28),{onOpenMigrations:m,result:a}=n,t=Oe();if(a===null){let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[0]=o):o=e[0],o}if(a.kind==="error"){let o;return e[1]!==a.message?(o=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:a.message}),e[1]=a.message,e[2]=o):o=e[2],o}if(a.kind==="needs-migration"){let o;e[3]!==a.message||e[4]!==t?(o=a.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):a.message,e[3]=a.message,e[4]=t,e[5]=o):o=e[5];let u;e[6]!==o?(u=l("p",{className:"text-sm text-warning",role:"alert",children:o}),e[6]=o,e[7]=u):u=e[7];let i;e[8]!==t?(i=t("Open Migrations"),e[8]=t,e[9]=i):i=e[9];let v;e[10]!==m||e[11]!==i?(v=l(ye,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:i}),e[10]=m,e[11]=i,e[12]=v):v=e[12];let f;return e[13]!==u||e[14]!==v?(f=p("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[u,v]}),e[13]=u,e[14]=v,e[15]=f):f=e[15],f}if(a.diagnostics.length===0){let o;return e[16]===Symbol.for("react.memo_cache_sentinel")?(o=l(Ve,{}),e[16]=o):o=e[16],o}let s;e[17]!==t?(s=t("Codegen reported diagnostics:"),e[17]=t,e[18]=s):s=e[18];let c;e[19]!==s?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:s}),e[19]=s,e[20]=c):c=e[20];let d;e[21]!==a.diagnostics?(d=a.diagnostics.map(vt),e[21]=a.diagnostics,e[22]=d):d=e[22];let r;e[23]!==d?(r=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=r):r=e[24];let g;return e[25]!==c||e[26]!==r?(g=p("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,r]}),e[25]=c,e[26]=r,e[27]=g):g=e[27],g};function vt(n){return l("li",{className:"font-mono text-[11px] text-destructive",children:n},n)}const yt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.bigint()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],Ct="v.string()",Nt=n=>n.split(",").map(e=>e.trim()).filter(e=>e!==""),Tt=n=>{const e=we(83),{onApplied:m,tableNames:a}=n,t=Oe(),s=nt(),[c,d]=_(null),[r,g]=_(!1),[o,u]=_(null),[i,v]=_(""),[f,O]=_(""),[S,G]=_(Ct),[y,L]=_(a[0]??""),[$,z]=_(""),[T,C]=_(""),[A,F]=_(!1);let pe;e[0]===Symbol.for("react.memo_cache_sentinel")?(pe=()=>{d(null),v(""),O(""),z(""),C(""),F(!1)},e[0]=pe):pe=e[0];const te=pe;let E;e[1]!==m?(E=async q=>{g(!0),u(null);try{const H=await gt(q);u(H),H.kind==="ok"&&(m(H.tables),te())}catch(H){const Se=H;u({kind:"error",message:Se instanceof Error?Se.message:String(Se)})}g(!1)},e[1]=m,e[2]=E):E=e[2];const M=E;let w;e[3]!==M||e[4]!==i?(w=()=>{Ce(M({kind:"addTable",table:i.trim()}))},e[3]=M,e[4]=i,e[5]=w):w=e[5];const ge=w;let B;e[6]!==f||e[7]!==M||e[8]!==y||e[9]!==S?(B=()=>{Ce(M({column:f.trim(),kind:"addOptionalColumn",table:y,validator:S}))},e[6]=f,e[7]=M,e[8]=y,e[9]=S,e[10]=B):B=e[10];const ce=B;let le;e[11]!==T||e[12]!==$||e[13]!==M||e[14]!==y||e[15]!==A?(le=()=>{Ce(M({fields:Nt(T),kind:"addIndex",name:$.trim(),table:y,unique:A}))},e[11]=T,e[12]=$,e[13]=M,e[14]=y,e[15]=A,e[16]=le):le=e[16];const J=le;let Ne;e[17]===Symbol.for("react.memo_cache_sentinel")?(Ne=()=>{u(null),d("addTable")},e[17]=Ne):Ne=e[17];const W=Ne;let me;e[18]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{u(null),d("addColumn")},e[18]=me):me=e[18];const be=me;let D;e[19]===Symbol.for("react.memo_cache_sentinel")?(D=()=>{u(null),d("addIndex")},e[19]=D):D=e[19];const j=D;let se;e[20]!==t?(se=()=>{d("destructive"),u({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=se):se=e[21];const ue=se;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=q=>{v(q.target.value)},e[22]=R):R=e[22];const ae=R;let K;e[23]===Symbol.for("react.memo_cache_sentinel")?(K=q=>{O(q.target.value)},e[23]=K):K=e[23];const ne=K;let oe;e[24]===Symbol.for("react.memo_cache_sentinel")?(oe=q=>{G(q.target.value)},e[24]=oe):oe=e[24];const fe=oe;let X;e[25]===Symbol.for("react.memo_cache_sentinel")?(X=q=>{L(q.target.value)},e[25]=X):X=e[25];const Q=X;let U;e[26]===Symbol.for("react.memo_cache_sentinel")?(U=q=>{z(q.target.value)},e[26]=U):U=e[26];const ie=U;let V;e[27]===Symbol.for("react.memo_cache_sentinel")?(V=q=>{C(q.target.value)},e[27]=V):V=e[27];const re=V;let Y;e[28]===Symbol.for("react.memo_cache_sentinel")?(Y=q=>{F(q.target.checked)},e[28]=Y):Y=e[28];const P=Y;let Z;e[29]!==s?(Z=()=>{Ce(s({to:"/migrations"}))},e[29]=s,e[30]=Z):Z=e[30];const b=Z;let ee;e[31]!==t?(ee=t("Edit schema"),e[31]=t,e[32]=ee):ee=e[32];let de;e[33]!==ee?(de=l(Ge,{children:ee}),e[33]=ee,e[34]=de):de=e[34];let xe;e[35]!==t?(xe=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=xe):xe=e[36];let Te;e[37]!==xe?(Te=l(ze,{children:xe}),e[37]=xe,e[38]=Te):Te=e[38];let ve;e[39]!==de||e[40]!==Te?(ve=p(Be,{children:[de,Te]}),e[39]=de,e[40]=Te,e[41]=ve):ve=e[41];const h=a.length>0;let x;e[42]!==c||e[43]!==ue||e[44]!==h?(x=l(bt,{hasTables:h,mode:c,onAddColumn:be,onAddIndex:j,onAddTable:W,onDestructive:ue}),e[42]=c,e[43]=ue,e[44]=h,e[45]=x):x=e[45];let N;e[46]!==r||e[47]!==c||e[48]!==ge||e[49]!==t||e[50]!==i?(N=c==="addTable"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(ke,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:ae,value:i})]}),l(ye,{"data-testid":"sc-editor-table-apply",disabled:r||i.trim()==="",onClick:ge,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=r,e[47]=c,e[48]=ge,e[49]=t,e[50]=i,e[51]=N):N=e[51];let k;e[52]!==r||e[53]!==f||e[54]!==c||e[55]!==ce||e[56]!==t||e[57]!==a||e[58]!==y||e[59]!==S?(k=c==="addColumn"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:Q,value:y,children:a.map(St)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(ke,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ne,value:f})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:fe,value:S,children:yt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(ye,{"data-testid":"sc-editor-column-apply",disabled:r||f.trim()===""||y==="",onClick:ce,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=r,e[53]=f,e[54]=c,e[55]=ce,e[56]=t,e[57]=a,e[58]=y,e[59]=S,e[60]=k):k=e[60];let I;e[61]!==r||e[62]!==T||e[63]!==$||e[64]!==c||e[65]!==J||e[66]!==t||e[67]!==a||e[68]!==y||e[69]!==A?(I=c==="addIndex"&&p("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:Q,value:y,children:a.map(_t)})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(ke,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ie,value:$})]}),p("div",{className:"flex flex-col gap-1 text-xs",children:[l(Ee,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(ke,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:re,value:T})]}),p(Ee,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:P,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(ye,{"data-testid":"sc-editor-index-apply",disabled:r||$.trim()===""||T.trim()==="",onClick:J,size:"xs",type:"button",children:t(r?"Applying…":"Apply")}),l(ye,{onClick:te,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=r,e[62]=T,e[63]=$,e[64]=c,e[65]=J,e[66]=t,e[67]=a,e[68]=y,e[69]=A,e[70]=I):I=e[70];let he;e[71]!==b||e[72]!==o?(he=l(xt,{onOpenMigrations:b,result:o}),e[71]=b,e[72]=o,e[73]=he):he=e[73];let _e;e[74]!==x||e[75]!==N||e[76]!==k||e[77]!==I||e[78]!==he?(_e=p(De,{children:[x,N,k,I,he]}),e[74]=x,e[75]=N,e[76]=k,e[77]=I,e[78]=he,e[79]=_e):_e=e[79];let Ie;return e[80]!==ve||e[81]!==_e?(Ie=p(je,{"data-testid":"sc-editor",size:"sm",children:[ve,_e]}),e[80]=ve,e[81]=_e,e[82]=Ie):Ie=e[82],Ie};function St(n){return l("option",{value:n,children:n},n)}function wt(n){return l("option",{value:n.validator,children:n.label},n.validator)}function _t(n){return l("option",{value:n,children:n},n)}const He=[],Et=n=>{const e=we(5),{open:m}=n,a=m&&"rotate-90";let t;e[0]!==a?(t=Qe("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",a),e[0]=a,e[1]=t):t=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=l("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=t,e[4]=c):c=e[4],c},Je=n=>{const e=we(20),{children:m,expanded:a,name:t,onToggle:s,rowCount:c,rowTestId:d,toggleTestId:r}=n;let g;e[0]!==a?(g=l(Et,{open:a}),e[0]=a,e[1]=g):g=e[1];let o;e[2]!==t?(o=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=o):o=e[3];let u;e[4]!==c?(u=p("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=u):u=e[5];let i;e[6]!==a||e[7]!==s||e[8]!==g||e[9]!==o||e[10]!==u||e[11]!==r?(i=p("button",{"aria-expanded":a,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":r,onClick:s,type:"button",children:[g,o," ",u]}),e[6]=a,e[7]=s,e[8]=g,e[9]=o,e[10]=u,e[11]=r,e[12]=i):i=e[12];let v;e[13]!==m||e[14]!==a?(v=a&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=a,e[15]=v):v=e[15];let f;return e[16]!==d||e[17]!==i||e[18]!==v?(f=p("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[i,v]}),e[16]=d,e[17]=i,e[18]=v,e[19]=f):f=e[19],f},We=n=>{const e=we(5),{columns:m,testId:a}=n;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let s;return e[2]!==t||e[3]!==a?(s=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":a,children:t}),e[2]=t,e[3]=a,e[4]=s):s=e[4],s},It=n=>{const e=we(10),{heading:m,indexes:a,testId:t}=n;let s;e[0]!==m?(s=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=s):s=e[1];let c;e[2]!==a?(c=a.map(At),e[2]=a,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let r;return e[7]!==s||e[8]!==d?(r=p("div",{className:"pt-3",children:[s,d]}),e[7]=s,e[8]=d,e[9]=r):r=e[9],r},Xe=n=>Qe("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",n?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Qt=n=>{const e=we(85),{initialShardKey:m,initialTable:a,schemaEditable:t}=n,s=Oe();let c;e[0]!==m||e[1]!==a?(c={initialShardKey:m,initialTable:a},e[0]=m,e[1]=a,e[2]=c):c=e[2];const{columns:d,diagramTables:r,error:g,expanded:o,filteredGlobalTables:u,filteredTables:i,globalColumns:v,globalError:f,globalExpanded:O,globalTables:S,indexes:G,refresh:y,setShardKey:L,setTableFilter:$,setView:z,shardColumnsError:T,shardKey:C,tableFilter:A,tables:F,toggle:pe,toggleGlobal:te,view:E}=mt(c);let M;e[3]!==z?(M=()=>{z("list")},e[3]=z,e[4]=M):M=e[4];const w=M;let ge;e[5]!==z?(ge=()=>{z("graph")},e[5]=z,e[6]=ge):ge=e[6];const B=ge;let ce;e[7]!==$?(ce=b=>{$(b.target.value)},e[7]=$,e[8]=ce):ce=e[8];const le=ce;let J;e[9]!==y||e[10]!==C?(J=b=>{Ce(y(C))},e[9]=y,e[10]=C,e[11]=J):J=e[11];const Ne=J;let W;e[12]!==F?(W=F??[],e[12]=F,e[13]=W):W=e[13];let me;e[14]!==W?(me=W.map($t),e[14]=W,e[15]=me):me=e[15];const be=me;let D;e[16]!==L||e[17]!==C?(D=l(Ze,{onChange:L,testId:"sc-shard-input",value:C}),e[16]=L,e[17]=C,e[18]=D):D=e[18];let j;e[19]!==s?(j=s("Schema view"),e[19]=s,e[20]=j):j=e[20];const se=E==="graph",ue=E==="graph";let R;e[21]!==ue?(R=Xe(ue),e[21]=ue,e[22]=R):R=e[22];let ae;e[23]!==s?(ae=s("Graph"),e[23]=s,e[24]=ae):ae=e[24];let K;e[25]!==B||e[26]!==se||e[27]!==R||e[28]!==ae?(K=l("button",{"aria-selected":se,className:R,"data-testid":"sc-view-graph",onClick:B,role:"tab",type:"button",children:ae}),e[25]=B,e[26]=se,e[27]=R,e[28]=ae,e[29]=K):K=e[29];const ne=E==="list",oe=E==="list";let fe;e[30]!==oe?(fe=Xe(oe),e[30]=oe,e[31]=fe):fe=e[31];let X;e[32]!==s?(X=s("Table list"),e[32]=s,e[33]=X):X=e[33];let Q;e[34]!==w||e[35]!==ne||e[36]!==fe||e[37]!==X?(Q=l("button",{"aria-selected":ne,className:fe,"data-testid":"sc-view-list",onClick:w,role:"tab",type:"button",children:X}),e[34]=w,e[35]=ne,e[36]=fe,e[37]=X,e[38]=Q):Q=e[38];let U;e[39]!==K||e[40]!==Q||e[41]!==j?(U=p("div",{"aria-label":j,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[K,Q]}),e[39]=K,e[40]=Q,e[41]=j,e[42]=U):U=e[42];let ie;e[43]!==U||e[44]!==D?(ie=p("div",{className:"flex flex-wrap items-center gap-3",children:[D,U]}),e[43]=U,e[44]=D,e[45]=ie):ie=e[45];let V;e[46]!==Ne||e[47]!==t||e[48]!==be?(V=t===!0&&l(Tt,{onApplied:Ne,tableNames:be}),e[46]=Ne,e[47]=t,e[48]=be,e[49]=V):V=e[49];let re;e[50]!==le||e[51]!==s||e[52]!==A||e[53]!==E?(re=E==="list"&&l(ke,{"aria-label":s("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:le,placeholder:s("Filter tables"),value:A}),e[50]=le,e[51]=s,e[52]=A,e[53]=E,e[54]=re):re=e[54];let Y;e[55]!==r||e[56]!==g||e[57]!==f||e[58]!==T||e[59]!==C||e[60]!==E?(Y=E==="graph"&&p("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),l(at,{columnsError:T[C]===!0,tables:r,testIdPrefix:"sc-graph"})]}),e[55]=r,e[56]=g,e[57]=f,e[58]=T,e[59]=C,e[60]=E,e[61]=Y):Y=e[61];let P;e[62]!==d||e[63]!==g||e[64]!==o||e[65]!==u||e[66]!==i||e[67]!==v||e[68]!==f||e[69]!==O||e[70]!==S||e[71]!==G||e[72]!==C||e[73]!==s||e[74]!==F||e[75]!==pe||e[76]!==te||e[77]!==E?(P=E==="list"&&p("div",{className:"flex flex-col gap-4",children:[p(je,{"data-testid":"sc-shard-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"shard"}),l(Ge,{children:s("Shard tables")}),F!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:i.length})]}),l(ze,{children:Pe.shard.hint})]}),p(De,{children:[g!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:g}),F!==null&&F.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:s("No tables in this shard.")}),F!==null&&F.length>0&&i.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:s("No tables match your filter.")}),i.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:i.map(b=>{const ee=`${C}:${b.name}`,de=G[ee]??[];return p(Je,{expanded:o===b.name,name:b.name,onToggle:()=>{Ce(pe(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(We,{columns:d[ee]??He,testId:`sc-columns-${b.name}`}),de.length>0&&l(It,{heading:s("Indexes"),indexes:de,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),p(je,{"data-testid":"sc-global-section",size:"sm",children:[p(Be,{children:[p("div",{className:"flex items-center gap-2",children:[l(Ke,{tier:"global"}),l(Ge,{children:s("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:u.length})]}),l(ze,{children:Pe.global.hint})]}),p(De,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:f}),S!==null&&S.length===0&&l(et,{description:Pe.global.hint,testId:"sc-global-empty",title:s("No global tables.")}),S!==null&&S.length>0&&u.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:s("No tables match your filter.")}),u.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:u.map(b=>l(Je,{expanded:O===b.name,name:b.name,onToggle:()=>{Ce(te(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(We,{columns:v[b.name]??He,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=g,e[64]=o,e[65]=u,e[66]=i,e[67]=v,e[68]=f,e[69]=O,e[70]=S,e[71]=G,e[72]=C,e[73]=s,e[74]=F,e[75]=pe,e[76]=te,e[77]=E,e[78]=P):P=e[78];let Z;return e[79]!==ie||e[80]!==V||e[81]!==re||e[82]!==Y||e[83]!==P?(Z=p("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[ie,V,re,Y,P]}),e[79]=ie,e[80]=V,e[81]=re,e[82]=Y,e[83]=P,e[84]=Z):Z=e[84],Z};function kt(n){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:n},n)}function At(n){return p("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:n.name}),l(Fe,{variant:"outline",children:n.type}),n.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:n.fields.join(", ")})]},`${n.type}:${n.name}`)}function $t(n){return n.name}export{Qt as SchemaViewer};
@@ -0,0 +1 @@
1
+ import{c as u}from"react/compiler-runtime";import{u as h}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as m}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as p}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{A as f}from"../packem_shared/advisor-view-Dj-mZPAq.mjs";import{jsx as R}from"react/jsx-runtime";const k=(e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("User subscriptions are ungated")})[s.kind],g=e=>Array.isArray(e.findings)?e.findings:[],S=e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: anyone who can reach the worker can open a socket and run ordinary user subscriptions. Admin subscriptions are unaffected — they need the admin token. Set it if subscribers should present a shared credential.")})[s.kind],T=()=>{const e=u(8),s=m();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:o,errorSource:d}=h(p.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:g(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:k(s,r),key:r.kind,level:r.level})),e[1]=i,e[2]=s,e[3]=a}else a=e[3];const c=a;let n;return e[4]!==o||e[5]!==d||e[6]!==c?(n=R(f,{error:o,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=o,e[5]=d,e[6]=c,e[7]=n):n=e[7],n};export{T as default};
@@ -0,0 +1 @@
1
+ import{c as Y}from"react/compiler-runtime";import{E as le}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as X}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as H,a as q}from"../packem_shared/card-By2O8ULa.mjs";import{T as ae,a as re,b as Z,c as Q,d as ne,e as W}from"../packem_shared/table-D0SBiDu-.mjs";import{u as ee}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as te}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as se}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{a as oe}from"../packem_shared/cf-links-C4DVTr8A.mjs";import{r as ie,u as de,s as ce}from"../packem_shared/shortcuts-B9gDaXmw.mjs";import{jsxs as u,jsx as l}from"react/jsx-runtime";const G=["disabled","schema","schema_and_log","schema_and_log_and_data"],me={describeTables:"schema",readAdvisors:"schema",readLogs:"schema_and_log",readPolicies:"schema",runSql:"schema_and_log_and_data"},fe={binding:"outline",secret:"destructive",var:"secondary"},ue=(t,e)=>{if(t===void 0)return[];const m=[];return t.workerUrl!==void 0&&m.push({label:e("URL"),value:t.workerUrl}),t.environment!==void 0&&m.push({label:e("Environment"),value:t.environment}),t.deploymentId!==void 0&&m.push({label:e("Deployment"),value:t.deploymentId}),t.versionTag!==void 0&&m.push({label:e("Version"),value:t.versionTag}),m},he={disabled:"The assistant is off. Nothing about this deployment is sent to a model.",schema:"Table and column names.",schema_and_log:"Table and column names, plus recent log lines.",schema_and_log_and_data:"Table and column names, log lines, and rows read with SELECT."},pe=t=>{const e=[];for(const[m,s]of Object.entries(me))s===t&&e.push(m);return e},xe=()=>{const t=Y(29),e=te();let m,s;t[0]===Symbol.for("react.memo_cache_sentinel")?(m={},s={shardKey:""},t[0]=m,t[1]=s):(m=t[0],s=t[1]);const{data:b}=ee(se.aiAvailable,m,s),f=b?.level;let g;t[2]!==f?(g=f===void 0?-1:G.indexOf(f),t[2]=f,t[3]=g):g=t[3];const x=g;let d;t[4]!==e?(d=e("AI assistant data sharing"),t[4]=e,t[5]=d):d=t[5];let c;t[6]!==d?(c=l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d}),t[6]=d,t[7]=c):c=t[7];let h;t[8]!==f?(h=f!==void 0&&l(X,{"data-testid":"set-ai-level",variant:f==="disabled"?"outline":"secondary",children:f}),t[8]=f,t[9]=h):h=t[9];let r;t[10]!==c||t[11]!==h?(r=u("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[c,h]}),t[10]=c,t[11]=h,t[12]=r):r=t[12];let p;t[13]!==x||t[14]!==f||t[15]!==e?(p=G.map((v,T)=>{const y=x>=T,_=pe(v);return u("li",{className:y?"flex flex-col gap-0.5":"flex flex-col gap-0.5 opacity-50","data-granted":String(y),"data-testid":`set-ai-tier-${v}`,children:[u("span",{className:"flex items-center gap-2",children:[l("span",{className:"font-mono text-xs",children:v}),v===f&&l("span",{className:"text-[11px] text-primary",children:e("current")})]}),l("span",{className:"text-xs text-muted-foreground",children:e(he[v])}),_.length>0&&l("span",{className:"font-mono text-[11px] text-muted-foreground",children:_.join(", ")})]},v)}),t[13]=x,t[14]=f,t[15]=e,t[16]=p):p=t[16];let o;t[17]!==p?(o=l("ul",{className:"flex flex-col gap-1.5 text-sm",children:p}),t[17]=p,t[18]=o):o=t[18];let a;t[19]!==e?(a=e("Set LUNORA_AI_OPT_IN in wrangler.jsonc and redeploy to change this. The Studio can read this level but never raise it."),t[19]=e,t[20]=a):a=t[20];let i;t[21]!==a?(i=l("p",{className:"text-xs text-muted-foreground","data-testid":"set-ai-howto",children:a}),t[21]=a,t[22]=i):i=t[22];let n;t[23]!==i||t[24]!==o?(n=u(q,{className:"flex flex-col gap-3 py-3",children:[o,i]}),t[23]=i,t[24]=o,t[25]=n):n=t[25];let N;return t[26]!==n||t[27]!==r?(N=u(H,{className:"py-0","data-testid":"set-ai-sharing",children:[r,n]}),t[26]=n,t[27]=r,t[28]=N):N=t[28],N},J=t=>{const e=Y(18),{modifier:m,name:s,label:b}=t,f=de();let g;e[0]!==s?(g=n=>{if(!["Escape","Tab"].includes(n.key)){if(n.shiftKey){n.preventDefault();return}n.preventDefault(),ce(s,n.key)}},e[0]=s,e[1]=g):g=e[1];const x=g,d=`set-shortcut-${s}`;let c;e[2]!==b?(c=l("dt",{className:"text-muted-foreground",children:b}),e[2]=b,e[3]=c):c=e[3];let h;e[4]!==m?(h=l("kbd",{className:"rounded border border-border px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:m}),e[4]=m,e[5]=h):h=e[5];const r=`set-shortcut-input-${s}`,p=f[s];let o;e[6]!==b||e[7]!==x||e[8]!==r||e[9]!==p?(o=l("input",{"aria-label":b,className:"h-7 w-12 rounded-md border border-border bg-background text-center font-mono text-xs uppercase outline-none focus-visible:border-ring","data-testid":r,onKeyDown:x,readOnly:!0,value:p}),e[6]=b,e[7]=x,e[8]=r,e[9]=p,e[10]=o):o=e[10];let a;e[11]!==h||e[12]!==o?(a=u("dd",{className:"flex items-center gap-1.5",children:[h,o]}),e[11]=h,e[12]=o,e[13]=a):a=e[13];let i;return e[14]!==d||e[15]!==c||e[16]!==a?(i=u("div",{className:"contents","data-testid":d,children:[c,a]}),e[14]=d,e[15]=c,e[16]=a,e[17]=i):i=e[17],i},Le=t=>{const e=Y(86),{initialShardKey:m}=t,s=te();let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const f=m??"";let g;e[1]!==f?(g={shardKey:f},e[1]=f,e[2]=g):g=e[2];const{data:x,error:d,errorSource:c,isLoading:h}=ee(se.getSettings,b,g);let r,p,o,a,i,n,N;if(e[3]!==d||e[4]!==c||e[5]!==x?.deploy||e[6]!==x?.settings||e[7]!==s){const z=ue(x?.deploy,s);let M;e[15]!==x?.settings?(M=x?.settings??[],e[15]=x?.settings,e[16]=M):M=e[16],r=M,p="flex flex-col gap-4",o="lunora-settings";let P;e[17]!==s?(P=s("Open in Cloudflare"),e[17]=s,e[18]=P):P=e[18],e[19]!==P?(a=l("div",{className:"flex flex-wrap items-center gap-3",children:l("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:oe,rel:"noreferrer",target:"_blank",children:P})}),e[19]=P,e[20]=a):a=e[20];let B;e[21]!==s?(B=s("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=s,e[22]=B):B=e[22],e[23]!==B?(i=l("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:B}),e[23]=B,e[24]=i):i=e[24],e[25]!==d||e[26]!==c?(n=d!==null&&l(le,{error:c,testId:"set-error"}),e[25]=d,e[26]=c,e[27]=n):n=e[27],N=z.length>0&&u(H,{className:"py-0","data-testid":"set-deploy",children:[l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Deployment")})}),l(q,{className:"py-3",children:l("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:z.map(ge)})})]}),e[3]=d,e[4]=c,e[5]=x?.deploy,e[6]=x?.settings,e[7]=s,e[8]=r,e[9]=p,e[10]=o,e[11]=a,e[12]=i,e[13]=n,e[14]=N}else r=e[8],p=e[9],o=e[10],a=e[11],i=e[12],n=e[13],N=e[14];let v;e[28]===Symbol.for("react.memo_cache_sentinel")?(v=l(xe,{}),e[28]=v):v=e[28];let T;e[29]!==s?(T=s("Keyboard shortcuts"),e[29]=s,e[30]=T):T=e[30];let y;e[31]!==T?(y=l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:T}),e[31]=T,e[32]=y):y=e[32];let _;e[33]!==s?(_=s("Reset"),e[33]=s,e[34]=_):_=e[34];let w;e[35]!==_?(w=l("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"set-shortcut-reset",onClick:ie,type:"button",children:_}),e[35]=_,e[36]=w):w=e[36];let S;e[37]!==y||e[38]!==w?(S=u("header",{className:"flex items-center justify-between border-b border-border px-4 py-3",children:[y,w]}),e[37]=y,e[38]=w,e[39]=S):S=e[39];let k;e[40]!==s?(k=s("Command palette"),e[40]=s,e[41]=k):k=e[41];let C;e[42]!==k?(C=l(J,{label:k,modifier:"⌘/Ctrl",name:"palette"}),e[42]=k,e[43]=C):C=e[43];let E;e[44]!==s?(E=s("Operation console"),e[44]=s,e[45]=E):E=e[45];let A;e[46]!==E?(A=l(J,{label:E,modifier:"Ctrl",name:"console"}),e[46]=E,e[47]=A):A=e[47];let L;e[48]!==C||e[49]!==A?(L=u("dl",{className:"grid grid-cols-[10rem_minmax(0,1fr)] items-center gap-x-4 gap-y-2 text-sm",children:[C,A]}),e[48]=C,e[49]=A,e[50]=L):L=e[50];let R;e[51]!==s?(R=s("Stored in this browser. Focus a box and press a key to rebind it."),e[51]=s,e[52]=R):R=e[52];let O;e[53]!==R?(O=l("p",{className:"pt-3 text-xs text-muted-foreground",children:R}),e[53]=R,e[54]=O):O=e[54];let D;e[55]!==L||e[56]!==O?(D=u(q,{className:"py-3",children:[L,O]}),e[55]=L,e[56]=O,e[57]=D):D=e[57];let I;e[58]!==S||e[59]!==D?(I=u(H,{className:"py-0","data-testid":"set-preferences",children:[S,D]}),e[58]=S,e[59]=D,e[60]=I):I=e[60];let K;e[61]!==s?(K=s("Environment & bindings"),e[61]=s,e[62]=K):K=e[62];let U;e[63]!==K?(U=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K})}),e[63]=K,e[64]=U):U=e[64];let j;e[65]!==d||e[66]!==h||e[67]!==r.length||e[68]!==s?(j=d===null&&!h&&r.length===0&&l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:s("No environment variables or bindings.")}),e[65]=d,e[66]=h,e[67]=r.length,e[68]=s,e[69]=j):j=e[69];let $;e[70]!==r||e[71]!==s?($=r.length>0&&l(q,{className:"px-0 py-0",children:u(ae,{"data-testid":"set-table",children:[l(re,{children:u(Z,{children:[l(Q,{children:s("name")}),l(Q,{children:s("kind")}),l(Q,{children:s("value")})]})}),l(ne,{children:r.map(be)})]})}),e[70]=r,e[71]=s,e[72]=$):$=e[72];let V;e[73]!==U||e[74]!==j||e[75]!==$?(V=u(H,{className:"py-0",children:[U,j,$]}),e[73]=U,e[74]=j,e[75]=$,e[76]=V):V=e[76];let F;return e[77]!==I||e[78]!==V||e[79]!==p||e[80]!==o||e[81]!==a||e[82]!==i||e[83]!==n||e[84]!==N?(F=u("div",{className:p,"data-testid":o,children:[a,i,n,N,v,I,V]}),e[77]=I,e[78]=V,e[79]=p,e[80]=o,e[81]=a,e[82]=i,e[83]=n,e[84]=N,e[85]=F):F=e[85],F};function ge(t){return u("div",{className:"contents","data-testid":"set-deploy-row",children:[l("dt",{className:"text-muted-foreground",children:t.label}),l("dd",{className:"truncate font-mono text-xs",title:t.value,children:t.value})]},t.label)}function be(t){return u(Z,{"data-testid":"set-row",children:[l(W,{className:"font-mono text-xs font-medium",children:t.name}),l(W,{children:l(X,{variant:fe[t.kind],children:t.bindingType??t.kind})}),l(W,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:t.value??l("span",{className:"text-muted-foreground",children:"—"})})]},t.name)}export{Le as SettingsPanel};
@@ -0,0 +1,25 @@
1
+ import{c as G}from"react/compiler-runtime";import{useState as te,useMemo as Fe,useCallback as Ye,useEffect as ue,useRef as de,useId as ct}from"react";import{u as dt}from"../packem_shared/assistant-provider-BQG7QZAu.mjs";import{u as ut}from"../packem_shared/use-assistant-rpc-DCC6ph2u.mjs";import{u as Me}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as Le}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{u as De,n as Ge,b as $e,r as Ce,s as ft}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{d as qe,f as ie,c as Ae,l as mt,b as pt}from"../packem_shared/internal-hIuTpSbx.mjs";import{r as ht}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import bt from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{c as ae}from"../packem_shared/utils-bhneXptQ.mjs";import{jsxs as W,jsx as u,Fragment as xe}from"react/jsx-runtime";import{I as Re}from"../packem_shared/input-CXhxesPC.mjs";import{a as Ve}from"../packem_shared/assistant-reason-D6EwMCxT.mjs";import{diffLines as gt}from"diff";import{S as xt,a as vt}from"../packem_shared/sql-result-table-DCwooMGW.mjs";import{ShardInput as yt}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{A as St}from"../packem_shared/alert-PB5W11MM.mjs";import{E as wt}from"../packem_shared/grid-features-Drvfswwy.mjs";const Ct="x",Qe=" ",kt={'"':'"',"'":"'","[":"]","`":"`"},Je=(r,e)=>{let s=e+2;for(;s<r.length&&r[s]!==`
2
+ `;)s+=1;return s},Xe=(r,e)=>{const s=r.indexOf("*/",e+2);return s===-1?-1:s+2},Ze=r=>{const e=r.split("");let s=0;for(;s<r.length;){const t=r[s]??"",o=kt[t];if(t==="-"&&r[s+1]==="-"){const n=Je(r,s);e.fill(Qe,s,n),s=n}else if(t==="/"&&r[s+1]==="*"){const n=Xe(r,s);if(n===-1)return;e.fill(Qe,s,n),s=n}else if(o!==void 0){let n=s+1;for(;n<r.length;)if(r[n]!==o)n+=1;else if(o!=="]"&&r[n+1]===o)n+=2;else break;if(n>=r.length)return;e.fill(Ct,s,n+1),s=n+1}else s+=1}for(let t=0;t<r.length;t+=1)r[t]===`
3
+ `&&(e[t]=`
4
+ `);return e.join("")},Nt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,Et=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,Tt=/^\w+/u,qt=/;\s*$/u,Rt=/\s/u,et=r=>{let e=0;for(;e<r.length;){const s=r[e];if(s!==void 0&&Rt.test(s))e+=1;else if(s==="-"&&r[e+1]==="-")e=Je(r,e);else if(s==="/"&&r[e+1]==="*"){const t=Xe(r,e);if(t===-1)break;e=t}else break}return e},It=r=>{const e=et(r),s=r.slice(e).trimEnd();if(s==="")return{code:"SQL_EMPTY",message:"the query is empty"};const o=(Ze(s)??s).replace(qt,""),n=s.slice(0,o.length),l=o.indexOf(";");if(l!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+l};const i="the SQL editor is read-only — only SELECT / WITH / EXPLAIN queries are allowed";if(!Nt.test(n))return{code:"SQL_NOT_READONLY",length:Tt.exec(n)?.[0].length??1,message:i,offset:e};const c=Et.exec(n);if(c!==null)return{code:"SQL_NOT_READONLY",length:c[0].length,message:`${i} (\`${c[0].toUpperCase()}\` is not allowed)`,offset:e+c.index}},Lt=/^explain\b/iu,At=r=>Lt.test(r.slice(et(r)))?r:`EXPLAIN QUERY PLAN ${r}`,Oe=(r,e)=>{const s=r.trim();if(s==="")return[];const t=e+r.indexOf(s),o=It(s);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:s}:{offset:t,rejection:o,sql:s}]},tt=r=>{const e=Ze(r);if(e===void 0)return Oe(r,0);const s=[];let t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(s.push(...Oe(r.slice(t,o),t)),t=o+1);return s},_t=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],Dt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ie=String.fromCodePoint(0),Ot=new RegExp(`${Ie}${String.raw`(\d+)`}${Ie}`,"gu"),Mt=_t.map(r=>({pattern:new RegExp(String.raw`\b${r.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:r})),$t=Dt.map(r=>({pattern:new RegExp(String.raw`\s+${r.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
5
+ ${r}`})),Bt=r=>{const e=[];let t=r.replaceAll(/'(?:[^']|'')*'/gu,o=>(e.push(o),`${Ie}${(e.length-1).toString()}${Ie}`)).replaceAll(/\s+/gu," ").trim();for(const{pattern:o,replacement:n}of Mt)t=t.replaceAll(o,n);for(const{pattern:o,replacement:n}of $t)t=t.replaceAll(o,n);return t=t.replaceAll(Ot,(o,n)=>e[Number(n)]??""),t},Pt=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Wt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Ht=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),Ft=/[^\n]/gu,Qt=(r,e)=>{const s=r[e];if(s==="'"){let t=e+1;for(;t<r.length&&r[t]!=="'";)t+=1;return Math.min(t+1,r.length)}if(s==="-"&&r[e+1]==="-"){const t=r.indexOf(`
6
+ `,e);return t===-1?r.length:t}if(s==="/"&&r[e+1]==="*"){const t=r.indexOf("*/",e+2);return t===-1?r.length:t+2}return-1},jt=r=>{let e="",s=0;for(;s<r.length;){const t=Qt(r,s);t===-1?(e+=r.slice(s,s+1),s+=1):(e+=r.slice(s,t).replaceAll(Ft," "),s=t)}return e},zt=r=>{const e=new Set;for(const s of r.matchAll(Wt))e.add((s[1]??"").toLowerCase());return e},Kt=(r,e)=>{const s=new Map;for(const t of r.matchAll(Pt)){const o=(t[1]??"").toLowerCase(),n=(t[2]??"").toLowerCase();e.has(o)&&(s.set(o,o),n!==""&&!Ht.has(n)&&s.set(n,o))}return s},nt=(r,e)=>{const s=jt(r),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:zt(s),masked:s,targets:Kt(s,t)}},Ut=/^(?:__lunora|sqlite_)/iu,Yt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Gt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Vt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Jt=(r,e,s)=>{const t=[];for(const o of r.matchAll(Yt)){const n=o[1]??"",l=n.toLowerCase();!e.has(l)&&!s.has(l)&&!Vt.has(l)&&!Ut.test(n)&&t.push({length:n.length,message:`unknown table \`${n}\``,offset:o.index+o[0].length-n.length,severity:"error",source:"schema"})}return t},Xt=(r,e,s)=>{const t=[],o=new Map;for(const[n,l]of Object.entries(e.columns))o.set(n.toLowerCase(),new Set(l.map(i=>i.toLowerCase())));for(const n of r.matchAll(Gt)){const l=(n[1]??"").toLowerCase(),i=n[2]??"",c=s.get(l),a=c===void 0?void 0:o.get(c);a!==void 0&&!a.has(i.toLowerCase())&&t.push({length:i.length,message:`\`${c??""}\` has no column \`${i}\``,offset:n.index+n[0].length-i.length,severity:"error",source:"schema"})}return t},Zt=/(?<![\w$."])(?:"([a-z_][\w$]*)"|([a-z_][\w$]*))(?![.(])/giu,en=/\bas\s+"?([a-z_][\w$]*)"?/giu,tn=(r,e,s,t)=>{const o=[...new Set(s.values())],n=new Map,l=new Set;for(const a of o){for(const d of e.columns[a]??[])l.add(d.toLowerCase());for(const d of e.docFields?.[a]??[])n.set(d.toLowerCase(),d)}if(n.size===0)return[];const i=new Set([...r.matchAll(en)].map(a=>(a[1]??"").toLowerCase())),c=[];for(const a of r.matchAll(Zt)){const d=a[1],m=d??a[2]??"",f=m.toLowerCase(),h=n.get(f);h===void 0||l.has(f)||i.has(f)||t.has(f)||s.has(f)||c.push({length:m.length,message:`\`${h}\` is a \`__doc__\` field, not a column — use \`json_extract(__doc__, '$.${h}')\``,offset:a.index+(d===void 0?0:1),severity:"error",source:"schema"})}return c},nn=(r,e)=>{if(r.trim()==="")return[];const s=tt(r),t=new Set(e.tables.map(n=>n.toLowerCase())),o=[];for(const n of s){const{offset:l,rejection:i}=n;if(i!==void 0){o.push({length:i.length,message:i.message,offset:i.offset===void 0?l:l+i.offset,severity:"error",source:"gate"});continue}const{ctes:c,masked:a,targets:d}=nt(n.sql,e.tables);o.push(...[...Jt(a,t,c),...Xt(a,e,d),...tn(a,e,d,c)].map(m=>({...m,offset:m.offset===void 0?l:l+m.offset})))}return o},sn=Ae(Le.lintSql),on=600,ln=(r,e,s)=>{const t=Me(),[o,n]=te([]),l=Fe(()=>nn(r,e),[r,e]),i=bt(r,on),a=l.some(f=>f.source==="gate")||i.trim()==="",d=Ye(async f=>{try{const h=await t.query(sn,{sql:i},qe(s));f.cancelled||n(h.diagnostics??[])}catch{f.cancelled||n([])}},[t,i,s]);ue(()=>{if(a){n([]);return}const f={cancelled:!1};return ie(d(f)),()=>{f.cancelled=!0}},[d,a]);const m=i===r;return Fe(()=>m?[...l,...o]:l,[l,o,m])},ke=8,rn=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],an=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),cn=/[\w$]/,st=r=>r!==void 0&&cn.test(r),ot=r=>{let e=r.length;for(;e>0&&st(r[e-1]);)e-=1;return r.slice(e)},lt=(r,e)=>{let s=e;for(;s>0&&st(r[s-1]);)s-=1;return{end:e,start:s,text:r.slice(s,e)}},je=(r,e)=>{const s=r.slice(0,e).trimEnd();return s.endsWith(".")||an.has(ot(s).toUpperCase())},dn=(r,e,s)=>{const t=r.slice(0,e);if(!t.endsWith("."))return;const o=ot(t.slice(0,-1));if(o!=="")return nt(r,s).targets.get(o.toLowerCase())??o},Be=(r,e)=>r.toLowerCase().startsWith(e.toLowerCase()),ze=(r,e,s,t)=>{const o=[];for(const n of r)if(Be(n,e)&&(o.push(t(n)),o.length>=s))break;return o},un=(r,e,s)=>{const t=new Map;for(const[o,n]of Object.entries(r.columns))for(const l of n)if(Be(l,e)&&!t.has(l)&&(t.set(l,o),t.size>=s))return[...t].map(([i,c])=>({detail:c,kind:"column",label:i}));return[...t].map(([o,n])=>({detail:n,kind:"column",label:o}))},fn=(r,e,s)=>{const t=lt(r,e),o=dn(r,t.start,s.tables);if(o!==void 0){const a=s.columns[o]??s.columns[o.toLowerCase()]??[];return ze(a,t.text,ke,d=>({detail:o,kind:"column",label:d}))}if(t.text===""&&!je(r,t.start))return[];const n=ze(s.tables,t.text,ke,a=>({kind:"table",label:a})),l=un(s,t.text,ke),i=rn.flatMap(a=>t.text!==""&&Be(a,t.text)&&a.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(je(r,t.start)?[...l,...n,...i]:[...n,...l,...i]).slice(0,ke)},mn=(r,e,s)=>{const t=lt(r,e),o=r.slice(0,t.start)+s.label+r.slice(t.end);return{caret:t.start+s.label.length,value:o}},pn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],hn=(r,e)=>{const s=globalThis.getComputedStyle(r),t=globalThis.document.createElement("div"),{style:o}=t;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(const c of pn)o[c]=s[c];t.textContent=r.value.slice(0,Math.max(0,e));const n=globalThis.document.createElement("span");n.textContent=r.value.slice(Math.max(0,e))||".",t.append(n),globalThis.document.body.append(t);const l=n.offsetLeft-r.scrollLeft,i=n.offsetTop-r.scrollTop;return t.remove(),{left:l,top:i}},bn=(r,e,s)=>{const t=G(16),[o,n]=te(null);let l;t[0]!==r||t[1]!==e?(l=(S,p)=>{const N=fn(S,p,r);if(N.length===0){n(null);return}const x=e.current,{left:b,top:y}=x===null?{left:0,top:0}:hn(x,p);n(C=>C!==null&&C.active===0&&C.left===b&&C.top===y&&C.suggestions.length===N.length&&C.suggestions.every((I,q)=>{const T=N.at(q);return I.kind===T?.kind&&I.label===T.label&&I.detail===T.detail})?C:{active:0,left:b,suggestions:N,top:y})},t[0]=r,t[1]=e,t[2]=l):l=t[2];const i=l;let c;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=()=>{n(null)},t[3]=c):c=t[3];const a=c;let d;t[4]===Symbol.for("react.memo_cache_sentinel")?(d=S=>{n(p=>{if(p===null)return p;const N=p.suggestions.length,x=(p.active+S+N)%N;return{...p,active:x}})},t[4]=d):d=t[4];const m=d;let f;t[5]!==s||t[6]!==o||t[7]!==e?(f=S=>{const p=e.current;if(o===null||p===null)return!1;const N=o.suggestions[S??o.active];if(N===void 0)return!1;const x=mn(p.value,p.selectionStart,N);return s(x.value),n(null),requestAnimationFrame(()=>{const b=e.current;b!==null&&(b.focus(),b.setSelectionRange(x.caret,x.caret))}),!0},t[5]=s,t[6]=o,t[7]=e,t[8]=f):f=t[8];const h=f;let g;t[9]!==h?(g=()=>h(),t[9]=h,t[10]=g):g=t[10];const R=g;let v;return t[11]!==R||t[12]!==h||t[13]!==i||t[14]!==o?(v={close:a,commit:R,commitAt:h,move:m,refresh:i,state:o},t[11]=R,t[12]=h,t[13]=i,t[14]=o,t[15]=v):v=t[15],v},gn={column:"column",keyword:"keyword",table:"table"},xn=20,vn=r=>{const e=G(17),{listboxId:s,onPick:t,state:o}=r,n=Z();let l;e[0]!==o?(l=o===null?void 0:{left:o.left,top:o.top+xn},e[0]=o,e[1]=l):l=e[1];const i=l;if(o===null)return null;let c;if(e[2]!==s||e[3]!==t||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==n){let d;e[8]!==s||e[9]!==t||e[10]!==o.active||e[11]!==n?(d=(m,f)=>W("li",{"aria-selected":f===o.active,className:ae("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",f===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${s}-opt-${f.toString()}`,onMouseDown:h=>{h.preventDefault(),t(f)},role:"option",children:[u("span",{className:"truncate font-mono",children:m.label}),m.detail!==void 0&&u("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:m.detail}),u("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:n(gn[m.kind])})]},`${m.kind}:${m.label}`),e[8]=s,e[9]=t,e[10]=o.active,e[11]=n,e[12]=d):d=e[12],c=o.suggestions.map(d),e[2]=s,e[3]=t,e[4]=o.active,e[5]=o.suggestions,e[6]=n,e[7]=c}else c=e[7];let a;return e[13]!==s||e[14]!==i||e[15]!==c?(a=u("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:s,role:"listbox",style:i,children:c}),e[13]=s,e[14]=i,e[15]=c,e[16]=a):a=e[16],a},yn=Ae(Le.listTables),Sn=Ae(Le.readTablePage),wn=r=>{const e=G(18),s=Me();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[o,n]=te(t);let l;e[1]===Symbol.for("react.memo_cache_sentinel")?(l={},e[1]=l):l=e[1];const[i,c]=te(l);let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a={},e[2]=a):a=e[2];const[d,m]=te(a);let f;e[3]===Symbol.for("react.memo_cache_sentinel")?(f=new Set,e[3]=f):f=e[3];const h=de(f);let g,R;e[4]!==s||e[5]!==r?(g=()=>{const b={cancelled:!1};return ie((async()=>{try{const C=await s.query(yn,{},qe(r));b.cancelled||(n(C.map(kn)),c({}),m({}),h.current=new Set)}catch{b.cancelled||(n([]),c({}),m({}),h.current=new Set)}})()),()=>{b.cancelled=!0}},R=[s,r],e[4]=s,e[5]=r,e[6]=g,e[7]=R):(g=e[6],R=e[7]),ue(g,R);let v;e[8]!==s||e[9]!==r?(v=b=>{if(h.current.has(b))return;h.current.add(b),ie((async()=>{try{const C=await s.query(Sn,{limit:1,offset:0,table:b},qe(r)),{sqlColumns:w}=C;if(w===void 0){h.current.delete(b);return}const I=new Set(w),q=C.columns.filter(T=>!I.has(T));c(T=>({...T,[b]:w})),m(T=>({...T,[b]:q}))}catch{h.current.delete(b)}})())},e[8]=s,e[9]=r,e[10]=v):v=e[10];const S=v;let p;e[11]!==i||e[12]!==d||e[13]!==o?(p={columns:i,docFields:d,tables:o},e[11]=i,e[12]=d,e[13]=o,e[14]=p):p=e[14];const N=p;let x;return e[15]!==S||e[16]!==N?(x={probe:S,schema:N},e[15]=S,e[16]=N,e[17]=x):x=e[17],x},_e=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,Cn=r=>{const e=new Set;_e.lastIndex=0;let s=_e.exec(r);for(;s!==null;)e.add(s[1]??s[2]),s=_e.exec(r);return[...e]};function kn(r){return r.name}const Nn=r=>(r.metaKey||r.ctrlKey)&&!r.shiftKey&&!r.altKey&&r.key.toLowerCase()==="i",En=r=>{const e=G(44),{inlineEditEnabled:s,onSubmit:t,probe:o,schema:n,setDraft:l}=r,i=ct(),[c,a]=te(null),d=de(null),m=de(null),f=de(null),h=bn(n,f,l),{close:g,commit:R,commitAt:v,move:S,refresh:p,state:N}=h;let x;e[0]!==v?(x=O=>{v(O)},e[0]=v,e[1]=x):x=e[1];const b=x;let y;e[2]!==p?(y=()=>{const O=f.current;O!==null&&O===document.activeElement&&p(O.value,O.selectionStart)},e[2]=p,e[3]=y):y=e[3];let C;e[4]!==p||e[5]!==n?(C=[p,n],e[4]=p,e[5]=n,e[6]=C):C=e[6],ue(y,C);let w;e[7]!==o||e[8]!==p||e[9]!==l?(w=O=>{const{selectionStart:U,value:X}=O.target;l(X),a(null);for(const Y of Cn(X))o(Y);p(X,U)},e[7]=o,e[8]=p,e[9]=l,e[10]=w):w=e[10];const I=w;let q;e[11]!==p?(q=O=>{const U=O.currentTarget;p(U.value,U.selectionStart)},e[11]=p,e[12]=q):q=e[12];const T=q;let E;e[13]!==g||e[14]!==R||e[15]!==S?(E=O=>O.key==="ArrowDown"?(O.preventDefault(),S(1),!0):O.key==="ArrowUp"?(O.preventDefault(),S(-1),!0):O.key==="Escape"?(O.preventDefault(),g(),!0):(O.key==="Enter"||O.key==="Tab")&&!O.metaKey&&!O.ctrlKey&&R()?(O.preventDefault(),!0):!1,e[13]=g,e[14]=R,e[15]=S,e[16]=E):E=e[16];const k=E;let L;e[17]!==N||e[18]!==g||e[19]!==s||e[20]!==k||e[21]!==t?(L=O=>{if(!(N!==null&&k(O))){if((O.metaKey||O.ctrlKey)&&O.key==="Enter"){O.preventDefault(),t();return}if(s&&Nn(O)){O.preventDefault(),g();const{selectionEnd:U,selectionStart:X,value:Y}=O.currentTarget,[oe,re]=X===U?[0,Y.length]:[X,U];a({end:re,start:oe,text:Y.slice(oe,re)})}}},e[17]=N,e[18]=g,e[19]=s,e[20]=k,e[21]=t,e[22]=L):L=e[22];const _=L;let $;e[23]!==g?($=()=>{requestAnimationFrame(()=>{g()})},e[23]=g,e[24]=$):$=e[24];const F=$;let B;e[25]===Symbol.for("react.memo_cache_sentinel")?(B=O=>{const{scrollLeft:U,scrollTop:X}=O.currentTarget;d.current!==null&&(d.current.scrollTop=X),m.current!==null&&(m.current.scrollTop=X,m.current.scrollLeft=U)},e[25]=B):B=e[25];const H=B;let P;e[26]===Symbol.for("react.memo_cache_sentinel")?(P=O=>{const U=f.current;U===null||O.offset===void 0||(U.focus(),U.setSelectionRange(O.offset,O.offset+(O.length??0)))},e[26]=P):P=e[26];const Q=P;let M;e[27]===Symbol.for("react.memo_cache_sentinel")?(M=()=>{a(null),f.current?.focus()},e[27]=M):M=e[27];const A=M;let D;e[28]!==c||e[29]!==l?(D=O=>{const U=f.current;if(c===null||U===null)return;const{end:X,start:Y,text:oe}=c;if(U.value.slice(Y,X)!==oe){a(null);return}l(U.value.slice(0,Y)+O+U.value.slice(X)),a(null),U.focus(),requestAnimationFrame(()=>{U.setSelectionRange(Y,Y+O.length)})},e[28]=c,e[29]=l,e[30]=D):D=e[30];const z=D;let j;e[31]!==I||e[32]!==F||e[33]!==_||e[34]!==T?(j={onBlur:F,onChange:I,onKeyDown:_,onScroll:H,onSelect:T},e[31]=I,e[32]=F,e[33]=_,e[34]=T,e[35]=j):j=e[35];let K;return e[36]!==z||e[37]!==N||e[38]!==g||e[39]!==c||e[40]!==i||e[41]!==b||e[42]!==j?(K={acceptInlineEdit:z,autocompleteState:N,closeAutocomplete:g,closeInlineEdit:A,inlineEdit:c,handlers:j,listboxId:i,onPickSuggestion:b,editorRef:f,gutterRef:d,overlayRef:m,revealDiagnostic:Q},e[36]=z,e[37]=N,e[38]=g,e[39]=c,e[40]=i,e[41]=b,e[42]=j,e[43]=K):K=e[43],K},Tn="lunora-studio-sql-tabs",qn="lunora-studio-sql-active-tab",Pe=12,Se=(r="",e="")=>({activeId:null,id:Ge("tab"),name:e,sql:r}),Rn=()=>$e(qn,""),In=r=>{const e=G(16),[s,t]=De(Tn),[o,n]=Rn(),[l]=te(r);let i,c;e[0]!==l||e[1]!==t||e[2]!==s.length?(i=()=>{s.length===0&&t([l])},c=[l,t,s.length],e[0]=l,e[1]=t,e[2]=s.length,e[3]=i,e[4]=c):(i=e[3],c=e[4]),ue(i,c);let a;e[5]!==l||e[6]!==s?(a=s.length===0?[l]:s,e[5]=l,e[6]=s,e[7]=a):a=e[7];const d=a;let m;e[8]!==o||e[9]!==d?(m=d.some(g=>g.id===o)?o:d[0]?.id??"",e[8]=o,e[9]=d,e[10]=m):m=e[10];const f=m;let h;return e[11]!==f||e[12]!==n||e[13]!==t||e[14]!==d?(h={activeId:f,setActiveId:n,setTabs:t,tabs:d},e[11]=f,e[12]=n,e[13]=t,e[14]=d,e[15]=h):h=e[15],h},rt=r=>r.activeId===null&&r.sql.trim()!=="",Ln=(r,e)=>[...r,e].slice(-Pe),An=(r,e,s)=>{const t=r.findIndex(l=>l.id===e);if(t===-1)return{activeId:r[0]?.id??"",tabs:[...r]};const o=r.filter(l=>l.id!==e);if(o.length===0){const l=s();return{activeId:l.id,tabs:[l]}}return{activeId:o[Math.min(t,o.length-1)].id,tabs:o}},_n=(r,e)=>{const s=r.filter(t=>t.id===e);return s.length===0?{activeId:r[0]?.id??"",tabs:[...r]}:{activeId:e,tabs:s}},Dn=(r,e,s)=>{const t=r.findIndex(n=>n.id===e);if(t===-1)return{activeId:s,tabs:[...r]};const o=r.slice(0,t+1);return{activeId:o.some(n=>n.id===s)?s:e,tabs:o}},On=r=>{const e=r();return{activeId:e.id,tabs:[e]}},Mn=(r,e,s)=>{if(r==="others")return e.filter(t=>t.id!==s);if(r==="right"){const t=e.findIndex(o=>o.id===s);return t===-1?[]:e.slice(t+1)}return[...e]},Ke={error:null,pane:"results",result:null,running:!1},$n=r=>{const e=G(69),{activeId:s,setActiveId:t,setTabs:o,tabs:n}=In(r);let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l={},e[0]=l):l=e[0];const[i,c]=te(l),[a,d]=te(null),[m,f]=te(null);let h;e[1]!==s||e[2]!==n?(h=n.find(V=>V.id===s)??n[0]??Se(),e[1]=s,e[2]=n,e[3]=h):h=e[3];const g=h,R=i[g.id]??Ke;let v;e[4]!==g.id||e[5]!==o?(v=V=>{o(ee=>ee.map(se=>se.id===g.id?{...se,...V}:se))},e[4]=g.id,e[5]=o,e[6]=v):v=e[6];const S=v;let p;e[7]!==g.id?(p=V=>{c(ee=>{const se=ee[g.id]??Ke;return{...ee,[g.id]:{...se,...V}}})},e[7]=g.id,e[8]=p):p=e[8];const N=p;let x;e[9]!==t||e[10]!==o||e[11]!==n.length?(x=V=>{if(n.length>=Pe)return!1;const ee=Se(V);return o(se=>Ln(se,ee)),t(ee.id),!0},e[9]=t,e[10]=o,e[11]=n.length,e[12]=x):x=e[12];const b=x;let y;e[13]!==b?(y=()=>{b("")},e[13]=b,e[14]=y):y=e[14];const C=y;let w;e[15]!==t||e[16]!==o?(w=V=>{d(null),f(null),o(V.tabs),t(V.activeId);const ee=new Set(V.tabs.map(Bn));c(se=>Object.fromEntries(Object.entries(se).filter(fe=>{const[J]=fe;return ee.has(J)})))},e[15]=t,e[16]=o,e[17]=w):w=e[17];const I=w;let q;e[18]!==I||e[19]!==n?(q=V=>{I(An(n,V,Se))},e[18]=I,e[19]=n,e[20]=q):q=e[20];const T=q;let E;e[21]!==s||e[22]!==I||e[23]!==n?(E=(V,ee)=>{I(V==="others"?_n(n,ee):V==="right"?Dn(n,ee,s):On(Se))},e[21]=s,e[22]=I,e[23]=n,e[24]=E):E=e[24];const k=E;let L;e[25]!==k||e[26]!==a||e[27]!==n?(L=V=>{a!==null&&(Mn(V,n,a.id).some(Pn)?f(V):k(V,a.id))},e[25]=k,e[26]=a,e[27]=n,e[28]=L):L=e[28];const _=L;let $;e[29]===Symbol.for("react.memo_cache_sentinel")?($=(V,ee)=>{ee.preventDefault(),f(null),d({id:V,x:ee.clientX,y:ee.clientY})},e[29]=$):$=e[29];const F=$;let B;e[30]===Symbol.for("react.memo_cache_sentinel")?(B=()=>{d(null),f(null)},e[30]=B):B=e[30];const H=B;let P;e[31]===Symbol.for("react.memo_cache_sentinel")?(P=V=>{V.preventDefault(),d(null),f(null)},e[31]=P):P=e[31];const Q=P;let M;e[32]!==_?(M=()=>{_("others")},e[32]=_,e[33]=M):M=e[33];const A=M;let D;e[34]!==_?(D=()=>{_("right")},e[34]=_,e[35]=D):D=e[35];const z=D;let j;e[36]!==_?(j=()=>{_("all")},e[36]=_,e[37]=j):j=e[37];const K=j;let O;e[38]!==k||e[39]!==m||e[40]!==a?(O=()=>{a!==null&&m!==null&&k(m,a.id),f(null)},e[38]=k,e[39]=m,e[40]=a,e[41]=O):O=e[41];const U=O;let X;e[42]===Symbol.for("react.memo_cache_sentinel")?(X=()=>{f(null)},e[42]=X):X=e[42];const Y=X;let oe;e[43]!==a?(oe=a===null?void 0:{left:a.x,top:a.y},e[43]=a,e[44]=oe):oe=e[44];const re=oe;let pe;e[45]!==o?(pe=V=>{o(ee=>ee.map(se=>se.activeId===V?{...se,activeId:null}:se))},e[45]=o,e[46]=pe):pe=e[46];const ve=pe;let he;e[47]!==o?(he=(V,ee)=>{o(se=>se.map(fe=>fe.id===V?{...fe,name:ee}:fe))},e[47]=o,e[48]=he):he=e[48];const ye=he;let be;return e[49]!==g||e[50]!==s||e[51]!==C||e[52]!==T||e[53]!==U||e[54]!==K||e[55]!==A||e[56]!==z||e[57]!==b||e[58]!==R||e[59]!==N||e[60]!==S||e[61]!==m||e[62]!==ye||e[63]!==t||e[64]!==a||e[65]!==re||e[66]!==n||e[67]!==ve?(be={activeTab:g,activeTabId:s,addEditorTab:C,cancelBulk:Y,closeEditorTab:T,closeTabMenu:H,confirmBulk:U,menuStyle:re,onBackdropContextMenu:Q,onCloseAll:K,onCloseOthers:A,onCloseToRight:z,openEditorTab:b,openTabMenu:F,output:R,patchActiveOutput:N,patchActiveTab:S,pendingBulk:m,renameTab:ye,setActiveTabId:t,tabMenu:a,tabs:n,unlinkQuery:ve},e[49]=g,e[50]=s,e[51]=C,e[52]=T,e[53]=U,e[54]=K,e[55]=A,e[56]=z,e[57]=b,e[58]=R,e[59]=N,e[60]=S,e[61]=m,e[62]=ye,e[63]=t,e[64]=a,e[65]=re,e[66]=n,e[67]=ve,e[68]=be):be=e[68],be};function Bn(r){return r.id}function Pn(r){return rt(r)}const Wn="lunora-studio-sql-queries",ge="lunora-studio-sql-history",Hn="lunora-studio-sql-remember-history",Fn=25,Qn=r=>{const e=G(44),{loadIntoActiveTab:s,unlinkQuery:t}=r,o=Z(),[n,l]=De(Wn),[i,c]=$e(Hn,!1),[a,d]=De(ge,i?"local":"session");let m,f;e[0]!==i?(m=()=>{i||Ce(ge,"local")},f=[i],e[0]=i,e[1]=m,e[2]=f):(m=e[1],f=e[2]),ue(m,f);const[h,g]=te(""),R=de(null);let v;e[3]!==d?(v=A=>{d(D=>D[0]?.sql===A?D:[{at:Date.now(),sql:A},...D.filter(j=>j.sql!==A)].slice(0,Fn))},e[3]=d,e[4]=v):v=e[4];const S=v;let p;e[5]!==s||e[6]!==l||e[7]!==o?(p=()=>{const A={id:Ge("q"),name:o("Untitled query"),sql:""};l(D=>[A,...D]),s("",A.id)},e[5]=s,e[6]=l,e[7]=o,e[8]=p):p=e[8];const N=p;let x;e[9]!==s||e[10]!==n?(x=A=>{const D=n.find(z=>z.id===A);D!==void 0&&(s(D.sql,A),R.current?.querySelector(`[data-testid="sql-query-${A}"]`)?.scrollIntoView({block:"nearest"}))},e[9]=s,e[10]=n,e[11]=x):x=e[11];const b=x;let y;e[12]!==l||e[13]!==t?(y=A=>{l(D=>D.filter(z=>z.id!==A)),t(A)},e[12]=l,e[13]=t,e[14]=y):y=e[14];const C=y;let w;e[15]!==s?(w=A=>{s(A.currentTarget.dataset.sql??"",null)},e[15]=s,e[16]=w):w=e[16];const I=w;let q;e[17]!==s?(q=A=>{s(A.currentTarget.dataset.sql??"",null)},e[17]=s,e[18]=q):q=e[18];const T=q;let E;e[19]!==d?(E=()=>{d([]),Ce(ge,"local"),Ce(ge,"session")},e[19]=d,e[20]=E):E=e[20];const k=E;let L;e[21]!==a||e[22]!==c?(L=A=>{ft(ge,a,A?"local":"session"),A||Ce(ge,"local"),c(A)},e[21]=a,e[22]=c,e[23]=L):L=e[23];const _=L;let $;e[24]===Symbol.for("react.memo_cache_sentinel")?($=A=>{g(A.target.value)},e[24]=$):$=e[24];const F=$;let B;e[25]!==l?(B=(A,D,z)=>{l(j=>j.map(K=>K.id===A?{id:K.id,name:D,sql:K.sql,...z===""?{}:{description:z}}:K))},e[25]=l,e[26]=B):B=e[26];const H=B;let P;e[27]!==l?(P=(A,D)=>{l(z=>z.map(j=>j.id===A?{...j,sql:D}:j))},e[27]=l,e[28]=P):P=e[28];const Q=P;let M;return e[29]!==k||e[30]!==C||e[31]!==a||e[32]!==T||e[33]!==I||e[34]!==N||e[35]!==n||e[36]!==S||e[37]!==i||e[38]!==H||e[39]!==h||e[40]!==b||e[41]!==_||e[42]!==Q?(M={clearHistory:k,deleteQuery:C,history:a,listRef:R,loadFromHistory:T,loadTemplate:I,newQuery:N,onSearchChange:F,queries:n,recordHistory:S,rememberHistory:i,renameQuery:H,search:h,selectQuery:b,setRememberHistory:_,updateQuerySql:Q},e[29]=k,e[30]=C,e[31]=a,e[32]=T,e[33]=I,e[34]=N,e[35]=n,e[36]=S,e[37]=i,e[38]=H,e[39]=h,e[40]=b,e[41]=_,e[42]=Q,e[43]=M):M=e[43],M},We="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",jn=(r,e)=>{const s=[];for(const o of r){if(o.offset===void 0||o.length===void 0||o.length<=0)continue;const n=Math.max(0,Math.min(o.offset,e)),l=Math.max(n,Math.min(o.offset+o.length,e));n!==l&&s.push({end:l,severity:o.severity,start:n})}s.sort((o,n)=>o.start-n.start);const t=[];for(const o of s)o.start>=(t.at(-1)?.end??0)&&t.push(o);return t},zn=r=>{const e=G(51),{rpc:s,failed:t,onGenerated:o}=r,n=Z(),[l,i]=te("");if(s.unavailable)return null;let c;e[0]!==s?(c=s.pending("sql"),e[0]=s,e[1]=c):c=e[1];const a=c;let d;if(e[2]!==t||e[3]!==o||e[4]!==a||e[5]!==l||e[6]!==s||e[7]!==n){const m=s.reason("sql");let f;e[9]!==t||e[10]!==o||e[11]!==l||e[12]!==s?(f=T=>{const E=l.trim();if(E===""&&!T)return;ie((async()=>{const L=await s.generate(E===""?"fix the failing statement":E,T?t:void 0);L!==void 0&&o(L)})())},e[9]=t,e[10]=o,e[11]=l,e[12]=s,e[13]=f):f=e[13];const h=f;let g;e[14]!==n?(g=n("Describe the query you want"),e[14]=n,e[15]=g):g=e[15];let R;e[16]===Symbol.for("react.memo_cache_sentinel")?(R=T=>{i(T.target.value)},e[16]=R):R=e[16];let v;e[17]!==h?(v=T=>{T.key==="Enter"&&(T.preventDefault(),h(!1))},e[17]=h,e[18]=v):v=e[18];let S;e[19]!==n?(S=n("Describe the query you want"),e[19]=n,e[20]=S):S=e[20];let p;e[21]!==a||e[22]!==l||e[23]!==g||e[24]!==v||e[25]!==S?(p=u(Re,{"aria-label":g,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:a,onChange:R,onKeyDown:v,placeholder:S,value:l}),e[21]=a,e[22]=l,e[23]=g,e[24]=v,e[25]=S,e[26]=p):p=e[26];const N=a&&"opacity-60";let x;e[27]!==N?(x=ae("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",N),e[27]=N,e[28]=x):x=e[28];let b;e[29]!==a||e[30]!==l?(b=a||l.trim()==="",e[29]=a,e[30]=l,e[31]=b):b=e[31];let y;e[32]!==h?(y=()=>{h(!1)},e[32]=h,e[33]=y):y=e[33];let C;e[34]!==a||e[35]!==n?(C=n(a?"Thinking…":"Draft SQL"),e[34]=a,e[35]=n,e[36]=C):C=e[36];let w;e[37]!==x||e[38]!==b||e[39]!==y||e[40]!==C?(w=u("button",{className:x,"data-testid":"sql-assistant-generate",disabled:b,onClick:y,type:"button",children:C}),e[37]=x,e[38]=b,e[39]=y,e[40]=C,e[41]=w):w=e[41];let I;e[42]!==t||e[43]!==a||e[44]!==h||e[45]!==n?(I=t!==void 0&&u("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:a,onClick:()=>{h(!0)},type:"button",children:n("Fix this")}),e[42]=t,e[43]=a,e[44]=h,e[45]=n,e[46]=I):I=e[46];let q;e[47]!==w||e[48]!==I||e[49]!==p?(q=W("div",{className:"flex items-center gap-2",children:[p,w,I]}),e[47]=w,e[48]=I,e[49]=p,e[50]=q):q=e[50],d=W("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[q,m!==void 0&&u("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ve(m,n)})]}),e[2]=t,e[3]=o,e[4]=a,e[5]=l,e[6]=s,e[7]=n,e[8]=d}else d=e[8];return d},Kn=r=>{const e=G(8),{diagnostics:s,draft:t,scrollRef:o}=r;let n,l;if(e[0]!==s||e[1]!==t){l=Symbol.for("react.early_return_sentinel");e:{const a=jn(s,t.length);if(a.length===0){l=null;break e}n=[];let d=0;for(const[m,f]of a.entries())f.start>d&&n.push(t.slice(d,f.start)),n.push(u("span",{className:ae("decoration-wavy underline underline-offset-4",f.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(f.start,f.end)},`${f.start.toString()}-${m.toString()}`)),d=f.end;n.push(t.slice(d))}e[0]=s,e[1]=t,e[2]=n,e[3]=l}else n=e[2],l=e[3];if(l!==Symbol.for("react.early_return_sentinel"))return l;let i;e[4]===Symbol.for("react.memo_cache_sentinel")?(i=ae("pointer-events-none absolute inset-0 overflow-hidden text-transparent",We),e[4]=i):i=e[4];let c;return e[5]!==n||e[6]!==o?(c=u("div",{"aria-hidden":"true",className:i,"data-testid":"sql-diagnostics-overlay",ref:o,children:n}),e[5]=n,e[6]=o,e[7]=c):c=e[7],c},Un={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Yn=r=>{const e=G(10),{diagnostics:s,onSelect:t}=r,o=Z();if(s.length===0)return null;let n;e[0]!==o?(n=o("SQL problems"),e[0]=o,e[1]=n):n=e[1];let l;if(e[2]!==s||e[3]!==t){let c;e[5]!==t?(c=(a,d)=>u("li",{children:W("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:()=>{t(a)},type:"button",children:[u("span",{className:ae("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",a.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:Un[a.source]}),u("span",{className:"min-w-0 text-muted-foreground",children:a.message})]})},`${a.source}-${(a.offset??d).toString()}-${d.toString()}`),e[5]=t,e[6]=c):c=e[6],l=s.map(c),e[2]=s,e[3]=t,e[4]=l}else l=e[4];let i;return e[7]!==n||e[8]!==l?(i=u("ul",{"aria-label":n,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:l}),e[7]=n,e[8]=l,e[9]=i):i=e[9],i},Gn=r=>(r.endsWith(`
7
+ `)?r.slice(0,-1):r).split(`
8
+ `),Vn=(r,e)=>{const s=[];let t=1,o=1;for(const n of gt(r,e,{ignoreNewlineAtEof:!0}))for(const l of Gn(n.value))n.added?(s.push({after:o,kind:"added",text:l}),o+=1):n.removed?(s.push({before:t,kind:"removed",text:l}),t+=1):(s.push({after:o,before:t,kind:"context",text:l}),t+=1,o+=1);return s},Jn={added:"bg-emerald-500/10 text-emerald-700 dark:text-emerald-400",context:"text-muted-foreground",removed:"bg-destructive/10 text-destructive"},Xn={added:"+",context:" ",removed:"-"},Zn=r=>{const e=G(11),{lines:s}=r,t=Z();let o;e[0]!==t?(o=t("Proposed edit"),e[0]=t,e[1]=o):o=e[1];let n;e[2]===Symbol.for("react.memo_cache_sentinel")?(n=ae("max-h-48 overflow-auto rounded-md border border-border bg-background",We),e[2]=n):n=e[2];let l;if(e[3]!==s||e[4]!==t){let c;e[6]!==t?(c=a=>W("li",{className:ae("flex gap-2",Jn[a.kind]),"data-kind":a.kind,children:[u("span",{"aria-hidden":"true",className:"shrink-0 select-none opacity-60",children:Xn[a.kind]}),a.kind!=="context"&&u("span",{className:"sr-only",children:a.kind==="added"?t("Added"):t("Removed")}),u("span",{className:"min-w-0",children:a.text===""?" ":a.text})]},`${String(a.before)}:${String(a.after)}`),e[6]=t,e[7]=c):c=e[7],l=s.map(c),e[3]=s,e[4]=t,e[5]=l}else l=e[5];let i;return e[8]!==o||e[9]!==l?(i=u("ul",{"aria-label":o,className:n,"data-testid":"sql-inline-diff",children:l}),e[8]=o,e[9]=l,e[10]=i):i=e[10],i},Ne="rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",es=r=>{const e=G(41),{onAccept:s,onCancel:t,rpc:o,source:n,whole:l}=r,i=Z(),c=de(null),a=de(null),[d,m]=te(""),[f,h]=te(null);let g,R;if(e[0]!==f?(g=()=>{f===null?c.current?.focus():a.current?.focus()},R=[f],e[0]=f,e[1]=g,e[2]=R):(g=e[1],R=e[2]),ue(g,R),o.unavailable)return null;let v;e[3]!==o?(v=o.pending("sql"),e[3]=o,e[4]=v):v=e[4];const S=v;let p;if(e[5]!==d||e[6]!==s||e[7]!==t||e[8]!==S||e[9]!==f||e[10]!==o||e[11]!==n||e[12]!==i||e[13]!==l){const N=o.reason("sql");let x;e[15]!==d||e[16]!==o||e[17]!==n?(x=()=>{const k=d.trim();if(k===""||n.trim()==="")return;ie((async()=>{const _=await o.rewrite(k,n);_!==void 0&&h(_)})())},e[15]=d,e[16]=o,e[17]=n,e[18]=x):x=e[18];const b=x;let y;e[19]!==t?(y=k=>{k.key==="Escape"&&(k.preventDefault(),t())},e[19]=t,e[20]=y):y=e[20];const C=y;let w;e[21]!==i||e[22]!==l?(w=i(l?"Whole query":"Selection"),e[21]=i,e[22]=l,e[23]=w):w=e[23];let I;e[24]!==w?(I=u("span",{className:"shrink-0 rounded bg-muted px-1 font-mono text-[10px] uppercase text-muted-foreground","data-testid":"sql-inline-edit-scope",children:w}),e[24]=w,e[25]=I):I=e[25];let q;e[26]!==d||e[27]!==s||e[28]!==t||e[29]!==C||e[30]!==S||e[31]!==f||e[32]!==b||e[33]!==i?(q=f===null?W(xe,{children:[u(Re,{"aria-label":i("Tell the model what to change"),className:"h-7 flex-1 text-xs","data-testid":"sql-inline-edit-prompt",disabled:S,onChange:k=>{m(k.target.value)},onKeyDown:k=>{if(k.key==="Enter"){k.preventDefault(),b();return}C(k)},placeholder:i("Tell the model what to change"),ref:c,value:d}),u("button",{className:ae(Ne,S&&"opacity-60"),"data-testid":"sql-inline-edit-submit",disabled:S||d.trim()==="",onClick:b,onKeyDown:C,type:"button",children:i(S?"Thinking…":"Rewrite")}),u("button",{className:Ne,"data-testid":"sql-inline-edit-cancel",onClick:t,onKeyDown:C,type:"button",children:i("Cancel")})]}):W(xe,{children:[u("span",{className:"flex-1 text-xs text-muted-foreground",children:i("Proposed edit")}),u("button",{className:Ne,"data-testid":"sql-inline-edit-accept",onClick:()=>{s(f)},onKeyDown:C,ref:a,type:"button",children:i("Accept")}),u("button",{className:Ne,"data-testid":"sql-inline-edit-reject",onClick:()=>{h(null)},onKeyDown:C,type:"button",children:i("Reject")})]}),e[26]=d,e[27]=s,e[28]=t,e[29]=C,e[30]=S,e[31]=f,e[32]=b,e[33]=i,e[34]=q):q=e[34];let T;e[35]!==I||e[36]!==q?(T=W("div",{className:"flex items-center gap-2",children:[I,q]}),e[35]=I,e[36]=q,e[37]=T):T=e[37];let E;e[38]!==f||e[39]!==n?(E=f!==null&&u(Zn,{lines:Vn(n,f)}),e[38]=f,e[39]=n,e[40]=E):E=e[40],p=W("div",{className:"flex flex-col gap-1 border-b border-border bg-muted/20 px-3 py-2","data-testid":"sql-inline-edit",children:[T,E,N!==void 0&&u("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-inline-edit-reason",role:"status",children:Ve(N,i)})]}),e[5]=d,e[6]=s,e[7]=t,e[8]=S,e[9]=f,e[10]=o,e[11]=n,e[12]=i,e[13]=l,e[14]=p}else p=e[14];return p},ts={minWidth:"2.75rem",paddingInline:"0.5rem"},ns=r=>{const e=G(75),{rpc:s,autocomplete:t,diagnostics:o,draft:n,failed:l,handlers:i,editorRef:c,gutterRef:a,inlineEdit:d,listboxId:m,onAcceptInlineEdit:f,onCancelInlineEdit:h,onGenerated:g,onPickSuggestion:R,onRevealDiagnostic:v,overlayRef:S}=r,p=Z();let N,x,b,y,C,w,I,q,T;if(e[0]!==n||e[1]!==l||e[2]!==a||e[3]!==d||e[4]!==f||e[5]!==h||e[6]!==g||e[7]!==s){const D=n.split(`
9
+ `).length;I="flex min-h-0 min-w-0 flex-1 flex-col",e[17]!==l||e[18]!==g||e[19]!==s?(q=u(zn,{failed:l,onGenerated:g,rpc:s}),e[17]=l,e[18]=g,e[19]=s,e[20]=q):q=e[20],e[21]!==n.length||e[22]!==d||e[23]!==f||e[24]!==h||e[25]!==s?(T=d!==null&&u(es,{onAccept:f,onCancel:h,rpc:s,source:d.text,whole:d.start===0&&d.end===n.length},`${d.start.toString()}-${d.end.toString()}`),e[21]=n.length,e[22]=d,e[23]=f,e[24]=h,e[25]=s,e[26]=T):T=e[26],w="flex min-h-0 min-w-0 flex-1",N="true",x="shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",b=a,y=ts,C=Array.from({length:D},ss),e[0]=n,e[1]=l,e[2]=a,e[3]=d,e[4]=f,e[5]=h,e[6]=g,e[7]=s,e[8]=N,e[9]=x,e[10]=b,e[11]=y,e[12]=C,e[13]=w,e[14]=I,e[15]=q,e[16]=T}else N=e[8],x=e[9],b=e[10],y=e[11],C=e[12],w=e[13],I=e[14],q=e[15],T=e[16];let E;e[27]!==N||e[28]!==x||e[29]!==b||e[30]!==y||e[31]!==C?(E=u("div",{"aria-hidden":N,className:x,ref:b,style:y,children:C}),e[27]=N,e[28]=x,e[29]=b,e[30]=y,e[31]=C,e[32]=E):E=e[32];let k;e[33]!==o||e[34]!==n||e[35]!==S?(k=u(Kn,{diagnostics:o,draft:n,scrollRef:S}),e[33]=o,e[34]=n,e[35]=S,e[36]=k):k=e[36];let L;e[37]!==t||e[38]!==m?(L=t===null?void 0:`${m}-opt-${t.active.toString()}`,e[37]=t,e[38]=m,e[39]=L):L=e[39];const _=t===null?void 0:m,$=t!==null;let F;e[40]!==p?(F=p("SQL query"),e[40]=p,e[41]=F):F=e[41];let B;e[42]!==n||e[43]!==c||e[44]!==i.onBlur||e[45]!==i.onChange||e[46]!==i.onKeyDown||e[47]!==i.onScroll||e[48]!==i.onSelect||e[49]!==L||e[50]!==_||e[51]!==$||e[52]!==F?(B=u("textarea",{"aria-activedescendant":L,"aria-autocomplete":"list","aria-controls":_,"aria-expanded":$,"aria-label":F,className:`relative size-full resize-none bg-transparent outline-none ${We}`,"data-testid":"sql-input",onBlur:i.onBlur,onChange:i.onChange,onKeyDown:i.onKeyDown,onScroll:i.onScroll,onSelect:i.onSelect,placeholder:"SELECT * FROM …",ref:c,role:"combobox",spellCheck:!1,value:n}),e[42]=n,e[43]=c,e[44]=i.onBlur,e[45]=i.onChange,e[46]=i.onKeyDown,e[47]=i.onScroll,e[48]=i.onSelect,e[49]=L,e[50]=_,e[51]=$,e[52]=F,e[53]=B):B=e[53];let H;e[54]!==t||e[55]!==m||e[56]!==R?(H=u(vn,{listboxId:m,onPick:R,state:t}),e[54]=t,e[55]=m,e[56]=R,e[57]=H):H=e[57];let P;e[58]!==k||e[59]!==B||e[60]!==H?(P=W("div",{className:"relative min-w-0 flex-1 bg-background",children:[k,B,H]}),e[58]=k,e[59]=B,e[60]=H,e[61]=P):P=e[61];let Q;e[62]!==E||e[63]!==P||e[64]!==w?(Q=W("div",{className:w,children:[E,P]}),e[62]=E,e[63]=P,e[64]=w,e[65]=Q):Q=e[65];let M;e[66]!==o||e[67]!==v?(M=u(Yn,{diagnostics:o,onSelect:v}),e[66]=o,e[67]=v,e[68]=M):M=e[68];let A;return e[69]!==Q||e[70]!==M||e[71]!==I||e[72]!==q||e[73]!==T?(A=W("div",{className:I,children:[q,T,Q,M]}),e[69]=Q,e[70]=M,e[71]=I,e[72]=q,e[73]=T,e[74]=A):A=e[74],A};function ss(r,e){return u("div",{children:e+1},e)}const os=r=>{const e=G(62),{onCancel:s,onSave:t,query:o,rpc:n}=r,l=Z(),[i,c]=te(o.name),[a,d]=te(o.description??"");let m;e[0]!==o.sql||e[1]!==n?(m=n!==void 0&&!n.unavailable&&o.sql.trim()!=="",e[0]=o.sql,e[1]=n,e[2]=m):m=e[2];const f=m;let h;e[3]!==n?(h=n?.pending("name"),e[3]=n,e[4]=h):h=e[4];const g=h===!0;let R;e[5]!==n?(R=n?.reason("name"),e[5]=n,e[6]=R):R=e[6];const v=R;let S;e[7]!==a||e[8]!==i||e[9]!==o.sql||e[10]!==n?(S=()=>{if(n===void 0)return;const M=i,A=a;ie((async()=>{const z=await n.nameQuery(o.sql);z!==void 0&&(c(j=>j===M?z.title:j),d(j=>j===A?z.description:j))})())},e[7]=a,e[8]=i,e[9]=o.sql,e[10]=n,e[11]=S):S=e[11];const p=S;let N;e[12]!==a||e[13]!==i||e[14]!==t?(N=M=>{M.preventDefault();const A=i.trim();A!==""&&t(A,a.trim())},e[12]=a,e[13]=i,e[14]=t,e[15]=N):N=e[15];const x=N,b=`sql-query-rename-${o.id}`;let y;e[16]!==l?(y=l("Query name"),e[16]=l,e[17]=y):y=e[17];let C;e[18]===Symbol.for("react.memo_cache_sentinel")?(C=M=>{c(M.target.value)},e[18]=C):C=e[18];let w;e[19]!==l?(w=l("Query name"),e[19]=l,e[20]=w):w=e[20];let I;e[21]!==i||e[22]!==y||e[23]!==w?(I=u(Re,{"aria-label":y,autoFocus:!0,className:"h-7 text-xs","data-testid":"sql-query-name",onChange:C,placeholder:w,value:i}),e[21]=i,e[22]=y,e[23]=w,e[24]=I):I=e[24];let q;e[25]!==l?(q=l("Query description"),e[25]=l,e[26]=q):q=e[26];let T;e[27]===Symbol.for("react.memo_cache_sentinel")?(T=M=>{d(M.target.value)},e[27]=T):T=e[27];let E;e[28]!==l?(E=l("Query description"),e[28]=l,e[29]=E):E=e[29];let k;e[30]!==a||e[31]!==q||e[32]!==E?(k=u(Re,{"aria-label":q,className:"h-7 text-xs","data-testid":"sql-query-description",onChange:T,placeholder:E,value:a}),e[30]=a,e[31]=q,e[32]=E,e[33]=k):k=e[33];let L;e[34]!==l?(L=l("Save"),e[34]=l,e[35]=L):L=e[35];let _;e[36]!==L?(_=u("button",{className:"rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-query-rename-save",type:"submit",children:L}),e[36]=L,e[37]=_):_=e[37];let $;e[38]!==l?($=l("Cancel"),e[38]=l,e[39]=$):$=e[39];let F;e[40]!==s||e[41]!==$?(F=u("button",{className:"rounded-md px-2 py-0.5 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-query-rename-cancel",onClick:s,type:"button",children:$}),e[40]=s,e[41]=$,e[42]=F):F=e[42];let B;e[43]!==f||e[44]!==g||e[45]!==p||e[46]!==l?(B=f&&u("button",{className:"ms-auto rounded-md border border-border px-2 py-0.5 text-[11px] outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-query-suggest-name",disabled:g,onClick:p,type:"button",children:l(g?"Thinking…":"Suggest")}),e[43]=f,e[44]=g,e[45]=p,e[46]=l,e[47]=B):B=e[47];let H;e[48]!==_||e[49]!==F||e[50]!==B?(H=W("div",{className:"flex items-center gap-1",children:[_,F,B]}),e[48]=_,e[49]=F,e[50]=B,e[51]=H):H=e[51];let P;e[52]!==v||e[53]!==l?(P=v!==void 0&&u("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-query-name-reason",role:"status",children:l(v==="ai-error"?"The model could not be reached.":"The model returned nothing usable.")}),e[52]=v,e[53]=l,e[54]=P):P=e[54];let Q;return e[55]!==x||e[56]!==I||e[57]!==k||e[58]!==H||e[59]!==P||e[60]!==b?(Q=W("form",{className:"flex flex-col gap-1 rounded-md bg-sidebar-accent p-1.5","data-testid":b,onSubmit:x,children:[I,k,H,P]}),e[55]=x,e[56]=I,e[57]=k,e[58]=H,e[59]=P,e[60]=b,e[61]=Q):Q=e[61],Q},it=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],ls=r=>{const e=G(44),{active:s,onDelete:t,onRename:o,onSelect:n,query:l}=r,i=Z();let c;e[0]!==n||e[1]!==l.id?(c=()=>{n(l.id)},e[0]=n,e[1]=l.id,e[2]=c):c=e[2];const a=c;let d;e[3]!==t||e[4]!==l.id?(d=L=>{L.stopPropagation(),t(l.id)},e[3]=t,e[4]=l.id,e[5]=d):d=e[5];const m=d;let f;e[6]!==o||e[7]!==l.id?(f=L=>{L.stopPropagation(),o(l.id)},e[6]=o,e[7]=l.id,e[8]=f):f=e[8];const h=f,g=s?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground";let R;e[9]!==g?(R=ae("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",g),e[9]=g,e[10]=R):R=e[10];const v=`sql-query-${l.id}`;let S;e[11]===Symbol.for("react.memo_cache_sentinel")?(S=u("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[11]=S):S=e[11];let p;e[12]!==l.name?(p=u("span",{className:"truncate",children:l.name}),e[12]=l.name,e[13]=p):p=e[13];let N;e[14]!==s||e[15]!==a||e[16]!==l.description||e[17]!==R||e[18]!==v||e[19]!==p?(N=W("button",{"aria-pressed":s,className:R,"data-testid":v,onClick:a,title:l.description,type:"button",children:[S,p]}),e[14]=s,e[15]=a,e[16]=l.description,e[17]=R,e[18]=v,e[19]=p,e[20]=N):N=e[20];let x;e[21]!==i?(x=i("Rename query"),e[21]=i,e[22]=x):x=e[22];const b=`sql-query-rename-open-${l.id}`;let y;e[23]!==i?(y=i("Rename query"),e[23]=i,e[24]=y):y=e[24];let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=u("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M4 20h4L19 9l-4-4L4 16zM14 6l4 4"})}),e[25]=C):C=e[25];let w;e[26]!==h||e[27]!==x||e[28]!==b||e[29]!==y?(w=u("button",{"aria-label":x,className:"hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-accent hover:text-foreground group-hover/q:flex","data-testid":b,onClick:h,title:y,type:"button",children:C}),e[26]=h,e[27]=x,e[28]=b,e[29]=y,e[30]=w):w=e[30];let I;e[31]!==i?(I=i("Delete query"),e[31]=i,e[32]=I):I=e[32];let q;e[33]!==i?(q=i("Delete query"),e[33]=i,e[34]=q):q=e[34];let T;e[35]===Symbol.for("react.memo_cache_sentinel")?(T=u("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[35]=T):T=e[35];let E;e[36]!==m||e[37]!==I||e[38]!==q?(E=u("button",{"aria-label":I,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:m,title:q,type:"button",children:T}),e[36]=m,e[37]=I,e[38]=q,e[39]=E):E=e[39];let k;return e[40]!==w||e[41]!==E||e[42]!==N?(k=W("li",{className:"group/q flex items-center",children:[N,w,E]}),e[40]=w,e[41]=E,e[42]=N,e[43]=k):k=e[43],k},Ue="sql-history-remember",rs=(r,e)=>{const s=e.trim().toLowerCase();return s===""?[...r]:r.filter(t=>t.name.toLowerCase().includes(s))},is=r=>{const e=G(53),{activeId:s,history:t,listRef:o,onClearHistory:n,onDelete:l,onLoadHistory:i,onLoadTemplate:c,onNew:a,onRename:d,onSearchChange:m,onSelect:f,onToggleRememberHistory:h,queries:g,rememberHistory:R,rpc:v,search:S}=r,p=Z(),N=rs(g,S),[x,b]=te(null);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=()=>{b(null)},e[0]=y):y=e[0];const C=y;let w;e[1]!==h?(w=Y=>{h(Y.target.checked)},e[1]=h,e[2]=w):w=e[2];const I=w,q="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let T;e[3]!==p?(T=p("Search queries…"),e[3]=p,e[4]=T):T=e[4];let E;e[5]!==m||e[6]!==S||e[7]!==T?(E=u("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:m,placeholder:T,type:"text",value:S}),e[5]=m,e[6]=S,e[7]=T,e[8]=E):E=e[8];let k;e[9]!==p?(k=p("New query"),e[9]=p,e[10]=k):k=e[10];let L;e[11]!==p?(L=p("New query"),e[11]=p,e[12]=L):L=e[12];let _;e[13]===Symbol.for("react.memo_cache_sentinel")?(_=u("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:u("path",{d:"M12 5v14M5 12h14"})}),e[13]=_):_=e[13];let $;e[14]!==a||e[15]!==k||e[16]!==L?($=u("button",{"aria-label":k,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:a,title:L,type:"button",children:_}),e[14]=a,e[15]=k,e[16]=L,e[17]=$):$=e[17];let F;e[18]!==E||e[19]!==$?(F=W("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[E,$]}),e[18]=E,e[19]=$,e[20]=F):F=e[20];const B="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let H;e[21]!==p?(H=p("Private"),e[21]=p,e[22]=H):H=e[22];let P;e[23]!==H?(P=u("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:H}),e[23]=H,e[24]=P):P=e[24];const Q=N.length===0?u("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:p("No saved queries yet — they save to this browser as you type.")}):u("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:N.map(Y=>x===Y.id?u("li",{children:u(os,{onCancel:C,onSave:(oe,re)=>{d(Y.id,oe,re),C()},query:Y,rpc:v})},Y.id):u(ls,{active:s===Y.id,onDelete:l,onRename:b,onSelect:f,query:Y},Y.id))});let M;e[25]!==P||e[26]!==Q?(M=W("div",{children:[P,Q]}),e[25]=P,e[26]=Q,e[27]=M):M=e[27];let A;e[28]!==p?(A=p("Reference"),e[28]=p,e[29]=A):A=e[29];let D;e[30]!==A?(D=u("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:A}),e[30]=A,e[31]=D):D=e[31];let z;e[32]!==c?(z=it.map(Y=>u("li",{children:W("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":Y.sql,onClick:c,type:"button",children:[u("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),Y.label]})},Y.label)),e[32]=c,e[33]=z):z=e[33];let j;e[34]!==z?(j=u("ul",{className:"flex flex-col gap-px",children:z}),e[34]=z,e[35]=j):j=e[35];let K;e[36]!==D||e[37]!==j?(K=W("div",{children:[D,j]}),e[36]=D,e[37]=j,e[38]=K):K=e[38];let O;e[39]!==t||e[40]!==n||e[41]!==i||e[42]!==I||e[43]!==R||e[44]!==p?(O=t.length>0&&W("div",{children:[W("div",{className:"flex items-center justify-between px-1 pb-1",children:[u("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:p("History")}),u("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:n,type:"button",children:p("Clear history")})]}),W("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 pb-1.5 text-[11px] text-muted-foreground",htmlFor:Ue,children:[u("input",{checked:R,"data-testid":"sql-history-remember",id:Ue,onChange:I,type:"checkbox"}),p("Keep history on this browser")]}),u("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(Y=>u("li",{children:W("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":Y.sql,"data-testid":"sql-history-item",onClick:i,title:Y.sql,type:"button",children:[u("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),u("span",{className:"truncate font-mono",children:Y.sql})]})},`${Y.at.toString()}:${Y.sql}`))})]}),e[39]=t,e[40]=n,e[41]=i,e[42]=I,e[43]=R,e[44]=p,e[45]=O):O=e[45];let U;e[46]!==M||e[47]!==K||e[48]!==O?(U=W("div",{className:B,children:[M,K,O]}),e[46]=M,e[47]=K,e[48]=O,e[49]=U):U=e[49];let X;return e[50]!==F||e[51]!==U?(X=W("aside",{className:q,children:[F,U]}),e[50]=F,e[51]=U,e[52]=X):X=e[52],X},Ee=r=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${r?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,as=r=>{const e=G(16),{chatOpen:s,onToggle:t}=r,o=Z();let n;e[0]!==o?(n=o("Ask about your data"),e[0]=o,e[1]=n):n=e[1];const l=`inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${s?"bg-accent text-foreground":"text-muted-foreground"}`;let i;e[2]!==o?(i=o("Ask about your data"),e[2]=o,e[3]=i):i=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=u("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M21 12a8 8 0 0 1-8 8H7l-4 3 1.2-4.2A8 8 0 1 1 21 12Z"})}),e[4]=c):c=e[4];let a;e[5]!==o?(a=o("Assistant"),e[5]=o,e[6]=a):a=e[6];let d;e[7]!==a?(d=u("span",{className:"text-xs",children:a}),e[7]=a,e[8]=d):d=e[8];let m;return e[9]!==s||e[10]!==t||e[11]!==n||e[12]!==l||e[13]!==i||e[14]!==d?(m=W("button",{"aria-label":n,"aria-pressed":s,className:l,"data-testid":"sql-chat-toggle",onClick:t,title:i,type:"button",children:[c,d]}),e[9]=s,e[10]=t,e[11]=n,e[12]=l,e[13]=i,e[14]=d,e[15]=m):m=e[15],m},cs=r=>{const e=G(11),{onToggle:s,splitView:t}=r,o=Z();let n;e[0]!==o?(n=o("Split editor and results"),e[0]=o,e[1]=n):n=e[1];const l=`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${t?"bg-accent text-foreground":"text-muted-foreground"}`;let i;e[2]!==o?(i=o("Split editor and results"),e[2]=o,e[3]=i):i=e[3];let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=W("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[u("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),u("path",{d:"M12 4v16"})]}),e[4]=c):c=e[4];let a;return e[5]!==s||e[6]!==t||e[7]!==n||e[8]!==l||e[9]!==i?(a=u("button",{"aria-label":n,"aria-pressed":t,className:l,"data-testid":"sql-split-toggle",onClick:s,title:i,type:"button",children:c}),e[5]=s,e[6]=t,e[7]=n,e[8]=l,e[9]=i,e[10]=a):a=e[10],a},ds=r=>{const e=G(8),{disabled:s,onExplainPlan:t,onExplainSql:o,pane:n}=r,l=Z();if(n==="explain"){let c;return e[0]!==s||e[1]!==t||e[2]!==l?(c=t===void 0?null:u("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-explain-plan",disabled:s,onClick:t,type:"button",children:l("Read this plan")}),e[0]=s,e[1]=t,e[2]=l,e[3]=c):c=e[3],c}let i;return e[4]!==s||e[5]!==o||e[6]!==l?(i=o===void 0?null:u("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-explain-query",disabled:s,onClick:o,type:"button",children:l("Explain this query")}),e[4]=s,e[5]=o,e[6]=l,e[7]=i):i=e[7],i},us=r=>{const e=G(8),{onRun:s,running:t}=r,o=Z();let n;e[0]!==t||e[1]!==o?(n=o(t?"Running…":"Run"),e[0]=t,e[1]=o,e[2]=n):n=e[2];let l;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=u("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"⌘↵"}),e[3]=l):l=e[3];let i;return e[4]!==s||e[5]!==t||e[6]!==n?(i=W("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:t,onClick:s,type:"button",children:[n,l]}),e[4]=s,e[5]=t,e[6]=n,e[7]=i):i=e[7],i},fs=r=>{const e=G(35),{onInferChart:s,onShowChart:t,onShowExplain:o,onShowResults:n,pane:l,result:i,rpc:c}=r,a=Z(),d=l==="results";let m;e[0]!==d?(m=Ee(d),e[0]=d,e[1]=m):m=e[1];let f;e[2]!==a?(f=a("Results"),e[2]=a,e[3]=f):f=e[3];let h;e[4]!==n||e[5]!==m||e[6]!==f?(h=u("button",{className:m,"data-testid":"sql-tab-results",onClick:n,type:"button",children:f}),e[4]=n,e[5]=m,e[6]=f,e[7]=h):h=e[7];const g=l==="chart";let R;e[8]!==g?(R=Ee(g),e[8]=g,e[9]=R):R=e[9];let v;e[10]!==a?(v=a("Chart"),e[10]=a,e[11]=v):v=e[11];let S;e[12]!==t||e[13]!==R||e[14]!==v?(S=u("button",{className:R,"data-testid":"sql-tab-chart",onClick:t,type:"button",children:v}),e[12]=t,e[13]=R,e[14]=v,e[15]=S):S=e[15];let p;e[16]!==s||e[17]!==l||e[18]!==i||e[19]!==c||e[20]!==a?(p=!c.unavailable&&l==="chart"&&i!==null&&u("button",{className:Ee(!1),"data-testid":"sql-infer-chart",disabled:c.pending("chart"),onClick:s,type:"button",children:c.pending("chart")?a("Thinking…"):a("Suggest chart")}),e[16]=s,e[17]=l,e[18]=i,e[19]=c,e[20]=a,e[21]=p):p=e[21];const N=l==="explain";let x;e[22]!==N?(x=Ee(N),e[22]=N,e[23]=x):x=e[23];let b;e[24]!==a?(b=a("Explain"),e[24]=a,e[25]=b):b=e[25];let y;e[26]!==o||e[27]!==x||e[28]!==b?(y=u("button",{className:x,"data-testid":"sql-tab-explain",onClick:o,type:"button",children:b}),e[26]=o,e[27]=x,e[28]=b,e[29]=y):y=e[29];let C;return e[30]!==y||e[31]!==h||e[32]!==S||e[33]!==p?(C=W(xe,{children:[h,S,p,y]}),e[30]=y,e[31]=h,e[32]=S,e[33]=p,e[34]=C):C=e[34],C},ms=r=>{const e=G(9),{onSelectStatement:s,script:t}=r;let o;if(e[0]!==s||e[1]!==t.runs||e[2]!==t.selected){let l;e[4]!==s||e[5]!==t.selected?(l=(i,c)=>u("button",{"aria-pressed":c===t.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${c===t.selected?"border-foreground text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${i.error===null?"":"border-destructive/50 text-destructive"}`,"data-testid":`sql-statement-${c.toString()}`,onClick:()=>{s(c)},title:i.sql,type:"button",children:c+1},`${c.toString()}:${i.sql}`),e[4]=s,e[5]=t.selected,e[6]=l):l=e[6],o=t.runs.map(l),e[0]=s,e[1]=t.runs,e[2]=t.selected,e[3]=o}else o=e[3];let n;return e[7]!==o?(n=u("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-border px-3 py-1.5","data-testid":"sql-statements",children:o}),e[7]=o,e[8]=n):n=e[8],n},ps=r=>{const e=G(9),{error:s,onDebugError:t,rpc:o}=r,n=Z();let l;e[0]!==s?(l=u(St,{className:"w-full font-mono text-xs",testId:"sql-error",variant:"destructive",children:s}),e[0]=s,e[1]=l):l=e[1];let i;e[2]!==t||e[3]!==o||e[4]!==n?(i=!o.unavailable&&t!==void 0&&W("button",{className:"inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-debug-error",disabled:o.pending("chat"),onClick:t,type:"button",children:[u("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M21 12a8 8 0 0 1-8 8H7l-4 3 1.2-4.2A8 8 0 1 1 21 12Z"})}),o.pending("chat")?n("Thinking…"):n("Debug with AI")]}),e[2]=t,e[3]=o,e[4]=n,e[5]=i):i=e[5];let c;return e[6]!==l||e[7]!==i?(c=W("div",{className:"m-3 flex flex-col items-start gap-2",children:[l,i]}),e[6]=l,e[7]=i,e[8]=c):c=e[8],c},hs=r=>{const e=G(18),{chart:s,durationMs:t,pane:o,result:n}=r,l=Z();let i;e[0]!==s||e[1]!==o||e[2]!==n?(i=o==="chart"?u(xt,{axes:s,result:n}):u(vt,{result:n}),e[0]=s,e[1]=o,e[2]=n,e[3]=i):i=e[3];let c;e[4]!==n.rowCount||e[5]!==n.rows||e[6]!==n.truncated||e[7]!==l?(c=n.truncated?l("Showing the first {max} rows.",{max:n.rows.length}):l("{count} rows",{count:n.rowCount}),e[4]=n.rowCount,e[5]=n.rows,e[6]=n.truncated,e[7]=l,e[8]=c):c=e[8];let a;e[9]!==t||e[10]!==l?(a=t!==void 0&&` · ${l("{ms} ms",{ms:Math.round(t)})}`,e[9]=t,e[10]=l,e[11]=a):a=e[11];let d;e[12]!==c||e[13]!==a?(d=W("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:[c,a]}),e[12]=c,e[13]=a,e[14]=d):d=e[14];let m;return e[15]!==i||e[16]!==d?(m=W("div",{"data-testid":"sql-result",children:[i,d]}),e[15]=i,e[16]=d,e[17]=m):m=e[17],m},bs=r=>{const e=G(13),{chart:s,durationMs:t,error:o,onDebugError:n,pane:l,result:i,rpc:c}=r,a=Z();if(o!==null){let m;return e[0]!==o||e[1]!==n||e[2]!==c?(m=u(ps,{error:o,onDebugError:n,rpc:c}),e[0]=o,e[1]=n,e[2]=c,e[3]=m):m=e[3],m}if(i===null){let m;e[4]!==a?(m=a("Click Run to execute your query."),e[4]=a,e[5]=m):m=e[5];let f;return e[6]!==m?(f=u("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:m}),e[6]=m,e[7]=f):f=e[7],f}let d;return e[8]!==s||e[9]!==t||e[10]!==l||e[11]!==i?(d=u(hs,{chart:s,durationMs:t,pane:l,result:i}),e[8]=s,e[9]=t,e[10]=l,e[11]=i,e[12]=d):d=e[12],d},gs=r=>{const e=G(63),{rpc:s,chart:t,className:o,durationMs:n,error:l,onFormat:i,onInferChart:c,onRun:a,onSelectStatement:d,onShardKeyChange:m,onShowChart:f,onShowExplain:h,onShowResults:g,chatOpen:R,onDebugError:v,onExplainPlan:S,onExplainSql:p,onToggleChat:N,onToggleSplit:x,pane:b,result:y,running:C,script:w,shardKey:I,splitView:q}=r,T=Z();let E;e[0]!==c||e[1]!==f||e[2]!==h||e[3]!==g||e[4]!==b||e[5]!==y||e[6]!==s?(E=u(fs,{onInferChart:c,onShowChart:f,onShowExplain:h,onShowResults:g,pane:b,result:y,rpc:s}),e[0]=c,e[1]=f,e[2]=h,e[3]=g,e[4]=b,e[5]=y,e[6]=s,e[7]=E):E=e[7];let k;e[8]!==R||e[9]!==N?(k=N!==void 0&&u(as,{chatOpen:R,onToggle:N}),e[8]=R,e[9]=N,e[10]=k):k=e[10];let L;e[11]!==x||e[12]!==q?(L=u(cs,{onToggle:x,splitView:q}),e[11]=x,e[12]=q,e[13]=L):L=e[13];let _;e[14]!==y?(_=y!==null&&y.columns.length>0&&u(wt,{columns:y.columns,name:"query-result",rows:y.rows}),e[14]=y,e[15]=_):_=e[15];let $;e[16]!==T?($=T("Format"),e[16]=T,e[17]=$):$=e[17];let F;e[18]!==i||e[19]!==C||e[20]!==$?(F=u("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:C,onClick:i,type:"button",children:$}),e[18]=i,e[19]=C,e[20]=$,e[21]=F):F=e[21];let B;e[22]!==s||e[23]!==C?(B=C||s.pending("chat"),e[22]=s,e[23]=C,e[24]=B):B=e[24];let H;e[25]!==S||e[26]!==p||e[27]!==b||e[28]!==B?(H=u(ds,{disabled:B,onExplainPlan:S,onExplainSql:p,pane:b}),e[25]=S,e[26]=p,e[27]=b,e[28]=B,e[29]=H):H=e[29];let P;e[30]!==m||e[31]!==I?(P=u(yt,{onChange:m,testId:"sql-shard-input",value:I}),e[30]=m,e[31]=I,e[32]=P):P=e[32];let Q;e[33]!==a||e[34]!==C?(Q=u(us,{onRun:a,running:C}),e[33]=a,e[34]=C,e[35]=Q):Q=e[35];let M;e[36]!==Q||e[37]!==k||e[38]!==L||e[39]!==_||e[40]!==F||e[41]!==H||e[42]!==P?(M=W("div",{className:"ms-auto flex items-center gap-2",children:[k,L,_,F,H,P,Q]}),e[36]=Q,e[37]=k,e[38]=L,e[39]=_,e[40]=F,e[41]=H,e[42]=P,e[43]=M):M=e[43];let A;e[44]!==E||e[45]!==M?(A=W("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[E,M]}),e[44]=E,e[45]=M,e[46]=A):A=e[46];let D;e[47]!==d||e[48]!==w?(D=w!==void 0&&u(ms,{onSelectStatement:d,script:w}),e[47]=d,e[48]=w,e[49]=D):D=e[49];let z;e[50]!==t||e[51]!==n||e[52]!==l||e[53]!==v||e[54]!==b||e[55]!==y||e[56]!==s?(z=u("div",{className:"min-h-0 flex-1 overflow-auto",children:u(bs,{chart:t,durationMs:n,error:l,onDebugError:v,pane:b,result:y,rpc:s})}),e[50]=t,e[51]=n,e[52]=l,e[53]=v,e[54]=b,e[55]=y,e[56]=s,e[57]=z):z=e[57];let j;return e[58]!==o||e[59]!==A||e[60]!==D||e[61]!==z?(j=W("div",{className:o,children:[A,D,z]}),e[58]=o,e[59]=A,e[60]=D,e[61]=z,e[62]=j):j=e[62],j},xs=(r,e)=>r.trim()===""?e:(r.split(`
10
+ `)[0]??r).slice(0,24),vs=r=>{r?.focus(),r?.select()},ys=r=>{const e=G(14),{initial:s,onCancel:t,onCommit:o,placeholder:n,testId:l}=r,i=Z();let c;e[0]!==o?(c=g=>{o(g.currentTarget.value.trim())},e[0]=o,e[1]=c):c=e[1];const a=c;let d;e[2]!==t||e[3]!==o?(d=g=>{g.key==="Enter"?o(g.currentTarget.value.trim()):g.key==="Escape"&&t()},e[2]=t,e[3]=o,e[4]=d):d=e[4];const m=d;let f;e[5]!==i?(f=i("Tab title"),e[5]=i,e[6]=f):f=e[6];let h;return e[7]!==s||e[8]!==a||e[9]!==m||e[10]!==n||e[11]!==f||e[12]!==l?(h=u("input",{"aria-label":f,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":l,defaultValue:s,onBlur:a,onKeyDown:m,placeholder:n,ref:vs,type:"text"}),e[7]=s,e[8]=a,e[9]=m,e[10]=n,e[11]=f,e[12]=l,e[13]=h):h=e[13],h},Ss=r=>{const e=G(29),{idBase:s,onDiscard:t,onKeep:o}=r,n=Z(),l=`sql-tab-close-prompt-${s}`;let i;e[0]!==n?(i=n("Discard?"),e[0]=n,e[1]=i):i=e[1];let c;e[2]!==i?(c=u("span",{className:"text-[11px] text-muted-foreground",children:i}),e[2]=i,e[3]=c):c=e[3];let a;e[4]!==n?(a=n("Discard changes"),e[4]=n,e[5]=a):a=e[5];const d=`sql-tab-close-confirm-${s}`;let m;e[6]!==n?(m=n("Discard changes"),e[6]=n,e[7]=m):m=e[7];let f;e[8]===Symbol.for("react.memo_cache_sentinel")?(f=u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:u("path",{d:"M5 13l4 4L19 7"})}),e[8]=f):f=e[8];let h;e[9]!==t||e[10]!==a||e[11]!==d||e[12]!==m?(h=u("button",{"aria-label":a,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":d,onClick:t,title:m,type:"button",children:f}),e[9]=t,e[10]=a,e[11]=d,e[12]=m,e[13]=h):h=e[13];let g;e[14]!==n?(g=n("Keep editing"),e[14]=n,e[15]=g):g=e[15];const R=`sql-tab-close-cancel-${s}`;let v;e[16]!==n?(v=n("Keep editing"),e[16]=n,e[17]=v):v=e[17];let S;e[18]===Symbol.for("react.memo_cache_sentinel")?(S=u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:u("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=S):S=e[18];let p;e[19]!==o||e[20]!==R||e[21]!==v||e[22]!==g?(p=u("button",{"aria-label":g,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":R,onClick:o,title:v,type:"button",children:S}),e[19]=o,e[20]=R,e[21]=v,e[22]=g,e[23]=p):p=e[23];let N;return e[24]!==l||e[25]!==p||e[26]!==c||e[27]!==h?(N=W("span",{className:"flex shrink-0 items-center gap-1","data-testid":l,role:"group",children:[c,h,p]}),e[24]=l,e[25]=p,e[26]=c,e[27]=h,e[28]=N):N=e[28],N},ws=r=>{const e=G(47),{active:s,canClose:t,onClose:o,onMenu:n,onRename:l,onSelect:i,tab:c}=r,a=Z(),[d,m]=te(!1),[f,h]=te(!1);let g;e[0]!==n||e[1]!==c.id?(g=D=>{n(c.id,D)},e[0]=n,e[1]=c.id,e[2]=g):g=e[2];const R=g;let v;e[3]!==i||e[4]!==c.id?(v=()=>{i(c.id)},e[3]=i,e[4]=c.id,e[5]=v):v=e[5];const S=v;let p;e[6]===Symbol.for("react.memo_cache_sentinel")?(p=()=>{m(!0)},e[6]=p):p=e[6];const N=p;let x;e[7]!==o||e[8]!==c?(x=D=>{D.stopPropagation(),rt(c)?h(!0):o(c.id)},e[7]=o,e[8]=c,e[9]=x):x=e[9];const b=x;let y;e[10]!==o||e[11]!==c.id?(y=D=>{D.stopPropagation(),h(!1),o(c.id)},e[10]=o,e[11]=c.id,e[12]=y):y=e[12];const C=y;let w;e[13]===Symbol.for("react.memo_cache_sentinel")?(w=D=>{D.stopPropagation(),h(!1)},e[13]=w):w=e[13];const I=w;let q;e[14]!==l||e[15]!==c.id?(q=D=>{l(c.id,D),m(!1)},e[14]=l,e[15]=c.id,e[16]=q):q=e[16];const T=q;let E;e[17]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{m(!1)},e[17]=E):E=e[17];const k=E;let L;e[18]!==c.name?(L=c.name.trim(),e[18]=c.name,e[19]=L):L=e[19];const _=L;let $;e[20]!==a||e[21]!==c.sql?($=xs(c.sql,a("Untitled")),e[20]=a,e[21]=c.sql,e[22]=$):$=e[22];const F=$,B=s?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground";let H;e[23]!==B?(H=ae("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",B),e[23]=B,e[24]=H):H=e[24];const P=`sql-tab-${c.id}`;let Q;e[25]!==s||e[26]!==T||e[27]!==_||e[28]!==F||e[29]!==d||e[30]!==S||e[31]!==a||e[32]!==c.id?(Q=d?u(ys,{initial:_,onCancel:k,onCommit:T,placeholder:F,testId:`sql-tab-rename-${c.id}`}):u("button",{"aria-pressed":s,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${c.id}`,onClick:S,onDoubleClick:N,title:a("Double-click to rename"),type:"button",children:_===""?F:_}),e[25]=s,e[26]=T,e[27]=_,e[28]=F,e[29]=d,e[30]=S,e[31]=a,e[32]=c.id,e[33]=Q):Q=e[33];let M;e[34]!==t||e[35]!==C||e[36]!==f||e[37]!==b||e[38]!==a||e[39]!==c.id?(M=t&&(f?u(Ss,{idBase:c.id,onDiscard:C,onKeep:I}):u("button",{"aria-label":a("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${c.id}`,onClick:b,title:a("Close tab"),type:"button",children:u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:u("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=C,e[36]=f,e[37]=b,e[38]=a,e[39]=c.id,e[40]=M):M=e[40];let A;return e[41]!==R||e[42]!==H||e[43]!==P||e[44]!==Q||e[45]!==M?(A=W("div",{className:H,"data-testid":P,onContextMenu:R,children:[Q,M]}),e[41]=R,e[42]=H,e[43]=P,e[44]=Q,e[45]=M,e[46]=A):A=e[46],A},Cs=r=>{const e=G(43),{model:s,onSelect:t}=r,o=Z(),{activeTab:n,addEditorTab:l,cancelBulk:i,closeEditorTab:c,closeTabMenu:a,confirmBulk:d,menuStyle:m,onBackdropContextMenu:f,onCloseAll:h,onCloseOthers:g,onCloseToRight:R,openTabMenu:v,pendingBulk:S,renameTab:p,tabMenu:N,tabs:x}=s;let b;if(e[0]!==n||e[1]!==c||e[2]!==t||e[3]!==v||e[4]!==p||e[5]!==x){let L;e[7]!==n||e[8]!==c||e[9]!==t||e[10]!==v||e[11]!==p||e[12]!==x.length?(L=_=>u(ws,{active:_.id===n.id,canClose:x.length>1,onClose:c,onMenu:v,onRename:p,onSelect:t,tab:_},_.id),e[7]=n,e[8]=c,e[9]=t,e[10]=v,e[11]=p,e[12]=x.length,e[13]=L):L=e[13],b=x.map(L),e[0]=n,e[1]=c,e[2]=t,e[3]=v,e[4]=p,e[5]=x,e[6]=b}else b=e[6];let y;e[14]!==o?(y=o("New tab"),e[14]=o,e[15]=y):y=e[15];const C=x.length>=Pe;let w;e[16]!==o?(w=o("New tab"),e[16]=o,e[17]=w):w=e[17];let I;e[18]===Symbol.for("react.memo_cache_sentinel")?(I=u("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:u("path",{d:"M12 5v14M5 12h14"})}),e[18]=I):I=e[18];let q;e[19]!==l||e[20]!==y||e[21]!==C||e[22]!==w?(q=u("button",{"aria-label":y,className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:C,onClick:l,title:w,type:"button",children:I}),e[19]=l,e[20]=y,e[21]=C,e[22]=w,e[23]=q):q=e[23];let T;e[24]!==b||e[25]!==q?(T=W("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[b,q]}),e[24]=b,e[25]=q,e[26]=T):T=e[26];let E;e[27]!==i||e[28]!==a||e[29]!==d||e[30]!==m||e[31]!==f||e[32]!==h||e[33]!==g||e[34]!==R||e[35]!==S||e[36]!==o||e[37]!==N||e[38]!==x?(E=N!==null&&W(xe,{children:[u("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:a,onContextMenu:f,role:"presentation"}),u("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:m,children:S===null?W(xe,{children:[u("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:x.length<=1,onClick:g,role:"menuitem",type:"button",children:o("Close other tabs")}),u("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:x.findIndex(L=>L.id===N.id)>=x.length-1,onClick:R,role:"menuitem",type:"button",children:o("Close tabs to the right")}),u("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:h,role:"menuitem",type:"button",children:o("Close all tabs")})]}):W("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[u("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")}),W("div",{className:"flex items-center gap-1.5",children:[u("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:d,type:"button",children:o("Discard")}),u("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:i,type:"button",children:o("Cancel")})]})]})})]}),e[27]=i,e[28]=a,e[29]=d,e[30]=m,e[31]=f,e[32]=h,e[33]=g,e[34]=R,e[35]=S,e[36]=o,e[37]=N,e[38]=x,e[39]=E):E=e[39];let k;return e[40]!==T||e[41]!==E?(k=W(xe,{children:[T,E]}),e[40]=T,e[41]=E,e[42]=k):k=e[42],k},ks=Ae(Le.runSql),Ns="lunora-studio-sql-split-view",Es=()=>Se(it[0]?.sql??""),Ts=()=>performance.now(),qs=()=>{const r=G(2);let e;r[0]===Symbol.for("react.memo_cache_sentinel")?(e=new Map,r[0]=e):e=r[0];const s=de(e);let t;return r[1]===Symbol.for("react.memo_cache_sentinel")?(t={advance:o=>{s.current.set(o,(s.current.get(o)??0)+1)},begin:o=>{const n=s.current.get(o)??0;return()=>(s.current.get(o)??0)===n}},r[1]=t):t=r[1],t},Rs=(r,e)=>{const s=r.tables[0];return s===void 0?[e("What tables does this app have?")]:[e("What tables does this app have?"),e("Show me the most recent rows in {table}",{table:s}),e("Is anything wrong with my schema?")]},Te=r=>r.tables.map(e=>({columns:[...r.columns[e]??[]],table:e})),Vs=({initialShardKey:r,now:e=Ts})=>{const s=Me(),t=$n(Es),{activeTab:o,openEditorTab:n,output:l,patchActiveOutput:i,patchActiveTab:c,setActiveTabId:a,unlinkQuery:d}=t,m=qs(),h=Qn({loadIntoActiveTab:(J,le)=>{m.advance(o.id),c({activeId:le,sql:J}),i({chart:void 0,durationMs:void 0,error:null,failed:void 0,result:null,running:!1,script:void 0})},unlinkQuery:d}),{recordHistory:g,updateQuerySql:R}=h,v=o.sql,{activeId:S}=o,{chart:p,error:N,failed:x,result:b,running:y}=l,C=l.pane,[w,I]=te(r??""),[q,T]=$e(Ns,!1),E=Z(),k=dt(),{probe:L,schema:_}=wn(w),$=Ye(J=>{c({sql:J}),S!==null&&R(S,J)},[S,c,R]),F=k?.setHasEditor;ue(()=>{if(F!==void 0)return F(!0),()=>{F(!1)}},[F]);const B=k?.insertRequest,H=k?.takeInsert;ue(()=>{B===void 0||H===void 0||(H(B.id),v.trim()===""&&S===null?$(B.sql):n(B.sql)||c({activeId:null,sql:v.trim()===""?B.sql:`${v.trimEnd()}
11
+
12
+ ${B.sql}`}))},[S,v,B,n,c,H,$]);const P=ln(v,_,w),Q=ut(w),M=()=>{if(b===null)return;ie((async()=>{const le=await Q.inferChart({columns:b.columns,rowCount:b.rowCount,types:Object.fromEntries(b.columns.map(ne=>[ne,typeof(b.rows[0]?.[ne]??"")]))});i({chart:le})})())},A=async J=>{const le=e();try{const ne=await s.query(ks,{sql:J},qe(w)),ce=e()-le;return g(J),{durationMs:ce,error:null,result:ne,sql:J}}catch(ne){return{error:pt(ne),result:null,sql:J}}},D=async J=>{if(v.trim()==="")return;const le=m.begin(o.id);i({running:!0,...J==="explain"?{explained:v.trim()}:{}});const ne=J==="explain"?Oe(At(v),0):tt(v),ce=[];for(const we of ne){const at={error:we.rejection?.message??"",result:null,sql:we.sql};ce.push(we.rejection===void 0?await A(we.sql):at)}if(ht(w),!le())return;const He=Math.max(ce.length-1,0),me=ce[He];i({chart:void 0,durationMs:me?.durationMs,error:me?.error??null,failed:me?.error===null||me===void 0?void 0:{error:me.error,sql:me.sql},pane:J,result:me?.result??null,running:!1,script:ce.length>1?{runs:ce,selected:He}:void 0})},z=J=>{const le=l.script?.runs,ne=le?.[J];le===void 0||ne===void 0||i({chart:void 0,durationMs:ne.durationMs,error:ne.error,failed:ne.error===null?void 0:{error:ne.error,sql:ne.sql},result:ne.result,script:{runs:le,selected:J}})},j=()=>{ie(D("results"))},K=En({inlineEditEnabled:!Q.unavailable,onSubmit:()=>{ie(D(l.pane))},probe:L,schema:_,setDraft:$}),{closeAutocomplete:O,closeInlineEdit:U}=K,X=()=>{$(Bt(v))},Y=J=>{O(),U(),a(J)},oe=()=>{i({pane:"results"})},re=()=>{ie(D("explain"))},pe=()=>{i({pane:"chart"})},ve=()=>{T(!q)},he=()=>{if(k!==void 0){if(k.open){k.close();return}k.openAssistant({schema:Te(_),shardKey:w,suggestions:Rs(_,E),title:E("SQL console")})}},ye=J=>{k?.rebindShard(w,J),I(J)},be=()=>{x!==void 0&&k?.openAssistant({ask:E(`This statement failed:
13
+ {sql}
14
+
15
+ The database said: {error}
16
+
17
+ Why, and what should it be?`,{error:x.error,sql:x.sql}),schema:Te(_),shardKey:w,title:E("Debug query")})},V=()=>{const J=v.trim();J!==""&&k?.openAssistant({ask:E(`Explain what this query does, step by step:
18
+ {statement}`,{statement:J}),schema:Te(_),shardKey:w,title:E("Explain query")})},ee=()=>{const J=l.explained;if(b===null||b.rows.length===0||J===void 0)return;const le=b.rows.map(ne=>b.columns.map(ce=>mt(ne[ce])).join(" | ")).join(`
19
+ `);k?.openAssistant({ask:E(`SQLite planned this query:
20
+ {statement}
21
+
22
+ as:
23
+ {plan}
24
+
25
+ What is it doing, and is anything here slow?`,{plan:le,statement:J}),schema:Te(_),shardKey:w,title:E("Read plan")})},se=q?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",fe=q?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";return W("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[u(is,{activeId:S,history:h.history,listRef:h.listRef,onClearHistory:h.clearHistory,onDelete:h.deleteQuery,onLoadHistory:h.loadFromHistory,onLoadTemplate:h.loadTemplate,onNew:h.newQuery,onRename:h.renameQuery,onSearchChange:h.onSearchChange,onSelect:h.selectQuery,onToggleRememberHistory:h.setRememberHistory,queries:h.queries,rememberHistory:h.rememberHistory,rpc:Q,search:h.search}),W("div",{className:"flex min-w-0 flex-1 flex-col",children:[u(Cs,{model:t,onSelect:Y}),W("div",{className:se,children:[u(ns,{autocomplete:K.autocompleteState,diagnostics:P,draft:v,editorRef:K.editorRef,failed:x,gutterRef:K.gutterRef,handlers:K.handlers,inlineEdit:K.inlineEdit,listboxId:K.listboxId,onAcceptInlineEdit:K.acceptInlineEdit,onCancelInlineEdit:K.closeInlineEdit,onGenerated:$,onPickSuggestion:K.onPickSuggestion,onRevealDiagnostic:K.revealDiagnostic,overlayRef:K.overlayRef,rpc:Q}),u(gs,{chart:p,chatOpen:k?.open===!0,className:fe,durationMs:l.durationMs,error:N,onDebugError:x===void 0?void 0:be,onExplainPlan:k===void 0||k.unavailable||C!=="explain"?void 0:ee,onExplainSql:k===void 0||k.unavailable?void 0:V,onFormat:X,onInferChart:M,onRun:j,onSelectStatement:z,onShardKeyChange:ye,onShowChart:pe,onShowExplain:re,onShowResults:oe,onToggleChat:k===void 0||k.unavailable?void 0:he,onToggleSplit:ve,pane:C,result:b,rpc:Q,running:y,script:l.script,shardKey:w,splitView:q})]})]})]})};export{Vs as SqlEditorPanel};
@@ -0,0 +1 @@
1
+ import{c as k}from"react/compiler-runtime";import{useNavigate as F,useRouter as M,useSearch as P}from"@tanstack/react-router";import{useState as Q,useEffect as A}from"react";import{T as w}from"../packem_shared/storage-tier-C2mKwYRj.mjs";import{u as q}from"../packem_shared/use-mirrored-ref-CVDf2z1M.mjs";import{u as J}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{s as L,d as D}from"../packem_shared/data-view-params-C-_G-biH.mjs";import{f as m}from"../packem_shared/internal-hIuTpSbx.mjs";import{l as O,s as I}from"../packem_shared/browser-storage-BH1MxLZs.mjs";import{DataBrowser as X}from"../packem_shared/DataBrowser-BrRWqnCr.mjs";import{GlobalDataBrowser as Y}from"../packem_shared/GlobalDataBrowser-D8ZheGwm.mjs";import{jsx as v,jsxs as E}from"react/jsx-runtime";const N="lunora-studio-saved-queries",$=50,z=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,y=()=>O(N).filter(z),B=r=>{I(N,r)},H=(r,e)=>{const l=r.trim();if(l==="")return y();const n=[{name:l,view:e},...y().filter(o=>o.name!==l)].slice(0,$);return B(n),n},U=r=>{const e=y().filter(l=>l.name!==r);return B(e),e},W=r=>{const e=k(15),{onChange:l,tier:n}=r,o=K();let p;e[0]!==l?(p=S=>{l(S.target.value)},e[0]=l,e[1]=p):p=e[1];const u=p;let s;e[2]!==o?(s=o("Storage tier"),e[2]=o,e[3]=s):s=e[3];let d;e[4]!==s?(d=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:s}),e[4]=s,e[5]=d):d=e[5];const g=w[n];let c,i;e[6]===Symbol.for("react.memo_cache_sentinel")?(c=v("option",{value:"shard",children:w.shard.label}),i=v("option",{value:"global",children:w.global.label}),e[6]=c,e[7]=i):(c=e[6],i=e[7]);let h;e[8]!==u||e[9]!==g.title||e[10]!==n?(h=E("select",{className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus-visible:border-ring","data-testid":"table-editor-schema",id:"table-editor-schema",onChange:u,title:g.title,value:n,children:[c,i]}),e[8]=u,e[9]=g.title,e[10]=n,e[11]=h):h=e[11];let f;return e[12]!==d||e[13]!==h?(f=E("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[d,h]}),e[12]=d,e[13]=h,e[14]=f):f=e[14],f},Z=()=>{try{m(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},ge=({canGenerateRows:r=!1,editable:e=!1,initialShardKey:l})=>{const n=J(),o=F(),p=M(),u=P({strict:!1}),s=L(u),d=q(u),g=()=>p.state.location.pathname.split("/").findLast(Boolean)==="data",c=s.tier??"shard",i=s.table,[h,f]=Q(()=>y()),[S,C]=Q(()=>new Set);A(()=>{m((async()=>{try{const a=await n.listGlobalTables();C(new Set(a.map(t=>t.name)))}catch{}})())},[n]),A(()=>{c==="shard"&&i!==void 0&&S.has(i)&&m(o({replace:!0,search:a=>({...a,schema:"global"}),to:"/data"}))},[S,o,i,c]);const R=a=>{m(o({search:t=>({...t,schema:a==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(a,t)=>{g()&&m(o({search:b=>({schema:b.schema,search:t?.search,shard:b.shard,table:a}),to:"/data"}))},G=a=>{m(o({search:t=>({...t,schema:"global",table:a}),to:"/data"}))},_=a=>{const t=D(a),{current:b}=d;(b.filters??void 0)===t.filters&&(b.order??void 0)===t.order&&(b.search??void 0)===t.search&&(b.shard??void 0)===t.shard||!g()||m(o({replace:!0,search:V=>({...V,filters:t.filters,order:t.order,search:t.search,shard:t.shard}),to:"/data"}))},j={onApplyQuery:a=>{const t=D(a.view);m(o({search:()=>({filters:t.filters,order:t.order,schema:t.schema,search:t.search,shard:t.shard,table:t.table}),to:"/data"}))},onCopyLink:Z,onDeleteQuery:a=>{f(U(a))},onSaveQuery:(a,t)=>{f(H(a,t))},saved:h},x=v(W,{onChange:R,tier:c});return c==="global"?v(Y,{initialTable:i,onSelectTable:T,schemaSwitch:x}):v(X,{canGenerateRows:r,editable:e,globalTableNames:S,initialFilters:s.filters,initialOrderBy:s.orderBy,initialPins:u.pins,initialSearch:s.search,initialShardKey:s.shard??l,onNavigateToGlobal:G,onSelectTable:T,onViewChange:_,queryBar:j,schemaSwitch:x,tableParam:i})};export{ge as TableEditor};
@@ -0,0 +1 @@
1
+ import{c as te}from"react/compiler-runtime";import{useState as se}from"react";import{E as q}from"../packem_shared/error-alert-BzZfqmf4.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as $}from"../packem_shared/button-q0UYSmrn.mjs";import{C as M,a as j}from"../packem_shared/card-By2O8ULa.mjs";import{E as K}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as L,a as P,b as f,c as o,d as U,e as d}from"../packem_shared/table-D0SBiDu-.mjs";import{u as x}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-C6U-ugro.mjs";import{h as ae}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsx as e,jsxs as l}from"react/jsx-runtime";const Q="agent_threads",re="agent_messages",D="agent_run_queue",_=100,y=250,ne={},oe={filters:[],limit:_,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:Q},c=(r,t)=>{const s=r[t];return typeof s=="string"?s:void 0},E=(r,t)=>{const s=r[t];return typeof s=="number"?s:void 0},H=r=>{const{usage:t}=r;if(t===null||typeof t!="object")return;const{totalTokens:s}=t;return typeof s=="number"?s:void 0},de=r=>{const{toolCalls:t}=r;return Array.isArray(t)?t.map(s=>s!==null&&typeof s=="object"?s.name:void 0).filter(s=>typeof s=="string"):[]},le=r=>{switch(r){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},ie=r=>{switch(r){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},ce=r=>{const t=te(3),{fetched:s}=r,u=G();let i;return t[0]!==s||t[1]!==u?(i=s<=y?null:e("p",{className:"text-xs text-muted-foreground","data-testid":"agents-messages-truncated",children:u("Showing the latest {count} messages; older ones are not shown.",{count:y})}),t[0]=s,t[1]=u,t[2]=i):i=t[2],i},Ee=({initialShardKey:r=""})=>{const t=G(),[s,u]=se(void 0),{data:i}=x(v.listTables,ne,{live:!0,shardKey:r}),z=i!==void 0,h=Array.isArray(i)&&i.some(a=>a.name===Q),O=Array.isArray(i)&&i.some(a=>a.name===D),{data:S,error:V,errorSource:F,liveError:J}=x(v.readTablePage,oe,{enabled:h,live:!0,shardKey:r}),W={filters:[{column:"threadKey",operator:"eq",value:s??""}],limit:y+1,offset:0,orderBy:{column:"seq",direction:"desc"},skipCount:!0,table:re},{data:w}=x(v.readTablePage,{limit:_,offset:0,orderBy:{column:"position",direction:"asc"},skipCount:!0,table:D},{enabled:O,live:!0,shardKey:r}),{data:k,error:X,errorSource:Y}=x(v.readTablePage,W,{enabled:h&&s!==void 0,live:!0,shardKey:r}),b=Array.isArray(S?.rows)?S.rows:[],Z=Array.isArray(w?.rows)?w.rows:[],C=a=>Z.filter(n=>c(n,"threadKey")===a).length,B=Array.isArray(k?.rows)?k.rows:[],I=B.slice(0,y).toReversed(),R=b.find(a=>c(a,"key")===s);let g;return z&&!h?g=e(K,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):h&&b.length===0?g=e(K,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):g=l("div",{className:"flex flex-col gap-6",children:[e(M,{className:"overflow-hidden py-0",children:e(j,{className:"px-0",children:l(L,{"data-testid":"agents-threads-table",children:[e(P,{children:l(f,{children:[e(o,{children:t("Agent")}),e(o,{children:t("Key")}),e(o,{children:t("Status")}),e(o,{children:t("Queued")}),e(o,{children:t("Messages")}),e(o,{children:t("Tokens")}),e(o,{children:t("Updated")}),e(o,{"aria-label":t("Actions")})]})}),e(U,{children:b.map(a=>{const n=c(a,"key")??"",m=c(a,"status"),p=H(a);return l(f,{"data-active":n===s?"":void 0,"data-testid":`agents-thread-${n}`,children:[e(d,{className:"font-mono text-xs",children:c(a,"agent")??"—"}),e(d,{className:"font-mono text-xs text-muted-foreground",children:n}),e(d,{children:e(A,{"data-testid":`agents-thread-status-${n}`,variant:le(m),children:m??"—"})}),e(d,{className:"tabular-nums",children:C(n)===0?e("span",{className:"text-muted-foreground",children:"—"}):e(A,{"data-testid":`agents-thread-queued-${n}`,variant:"warning",children:C(n)})}),e(d,{className:"tabular-nums",children:E(a,"messageCount")??"—"}),e(d,{className:"tabular-nums text-muted-foreground",children:p??"—"}),e(d,{className:"text-muted-foreground tabular-nums",children:ae(E(a,"updatedAt"),"—")}),e(d,{className:"text-right",children:e($,{"data-testid":`agents-thread-open-${n}`,onClick:()=>{u(n)},size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},n)})})]})})}),X!==null&&e(q,{error:Y,shardKey:r,testId:"agents-messages-error"}),s!==void 0&&e(M,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:l(j,{className:"flex flex-col gap-3 px-4 py-3",children:[l("div",{className:"flex items-center justify-between gap-2",children:[l("span",{className:"font-mono text-xs",children:[t("Timeline")," · ",s,R!==void 0&&l("span",{className:"text-muted-foreground",children:[" · ",t("Usage"),": ",H(R)??0," ",t("Tokens")]})]}),e($,{"data-testid":"agents-thread-detail-close",onClick:()=>{u(void 0)},size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),e(ce,{fetched:B.length}),I.length===0?e("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):l(L,{"data-testid":"agents-messages-table",children:[e(P,{children:l(f,{children:[e(o,{children:t("Role")}),e(o,{children:t("Content")}),e(o,{children:t("Tool")}),e(o,{children:t("Approval")})]})}),e(U,{children:I.map((a,n)=>{const m=c(a,"role")??"—",p=de(a),ee=c(a,"toolName"),N=c(a,"status"),T=E(a,"seq")??n;return l(f,{"data-testid":`agents-message-${String(T)}`,children:[e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:m}),e(d,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:c(a,"content")??"—"}),e(d,{className:"font-mono text-xs align-top text-muted-foreground",children:ee??(p.length>0?p.join(", "):"—")}),e(d,{className:"align-top",children:N===void 0?e("span",{className:"text-xs text-muted-foreground",children:"—"}):e(A,{"data-testid":`agents-message-approval-${String(T)}`,variant:ie(N),children:N})})]},c(a,"messageKey")??`${m}:${String(T)}`)})})]})]})})]}),l("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[V!==null&&e(q,{error:F,shardKey:r,testId:"agents-error"}),e("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),J!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),g]})};export{Ee as default};