@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
@@ -1,2323 +0,0 @@
1
- import { c } from 'react/compiler-runtime';
2
- import { useLunora } from '@lunora/react';
3
- import { useState, useRef, useEffect, useId } from 'react';
4
- import { u as usePersistedList, n as newId, S as SqlResultChart } from '../packem_shared/browser-storage-tLOxkIHd.js';
5
- import { ShardInput } from '../packem_shared/ShardInput-gx_DZXXn.js';
6
- import { A as Alert } from '../packem_shared/alert-CdAET2K_.js';
7
- import { c as TableHead, a as TableHeader, b as TableRow, e as TableCell, d as TableBody, T as Table } from '../packem_shared/table-DsCa9Qp9.js';
8
- import { useT } from '../packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js';
9
- import { ADMIN_FUNCTIONS } from '../packem_shared/ADMIN_FUNCTIONS-BHHJi3Gb.js';
10
- import { f as fireAndForget, c as callOptions, a as adminRef, e as errorMessage } from '../packem_shared/internal-DTsYVn-g.js';
11
- import { r as recordShard } from '../packem_shared/shard-history-DyebH1R5.js';
12
- import { C as CellValue } from '../packem_shared/data-grid-Jz8FqQ2C.js';
13
- import { E as ExportMenu } from '../packem_shared/grid-features-CUr8Z1_O.js';
14
- import { c as cn } from '../packem_shared/utils-B05Dmz_H.js';
15
- import { jsxDEV, Fragment } from 'react/jsx-dev-runtime';
16
-
17
- const SQL_KEYWORDS = ["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"];
18
- const SQL_NEWLINE_CLAUSES = ["FROM", "WHERE", "ORDER BY", "GROUP BY", "HAVING", "LIMIT", "OFFSET", "UNION", "JOIN", "LEFT JOIN", "RIGHT JOIN", "INNER JOIN", "OUTER JOIN", "CROSS JOIN"];
19
- const SENTINEL = String.fromCodePoint(0);
20
- const RESTORE_RE = new RegExp(`${SENTINEL}${String.raw`(\d+)`}${SENTINEL}`, "gu");
21
- const KEYWORD_PATTERNS = SQL_KEYWORDS.map((keyword) => {
22
- return {
23
- pattern: new RegExp(String.raw`\b${keyword.replaceAll(" ", String.raw`\s+`)}\b`, "giu"),
24
- replacement: keyword
25
- };
26
- });
27
- const CLAUSE_PATTERNS = SQL_NEWLINE_CLAUSES.map((clause) => {
28
- return {
29
- pattern: new RegExp(String.raw`\s+${clause.replaceAll(" ", String.raw`\s+`)}\b`, "gu"),
30
- replacement: `
31
- ${clause}`
32
- };
33
- });
34
- const formatSql = (sql) => {
35
- const literals = [];
36
- const withPlaceholders = sql.replaceAll(/'(?:[^']|'')*'/gu, (match) => {
37
- literals.push(match);
38
- return `${SENTINEL}${(literals.length - 1).toString()}${SENTINEL}`;
39
- });
40
- let out = withPlaceholders.replaceAll(/\s+/gu, " ").trim();
41
- for (const {
42
- pattern,
43
- replacement
44
- } of KEYWORD_PATTERNS) {
45
- out = out.replaceAll(pattern, replacement);
46
- }
47
- for (const {
48
- pattern,
49
- replacement
50
- } of CLAUSE_PATTERNS) {
51
- out = out.replaceAll(pattern, replacement);
52
- }
53
- out = out.replaceAll(RESTORE_RE, (_match, index) => literals[Number(index)] ?? "");
54
- return out;
55
- };
56
-
57
- const MAX_SUGGESTIONS = 8;
58
- const KEYWORDS = ["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"];
59
- const COLUMN_CLAUSES = /* @__PURE__ */ new Set(["AND", "BY", "HAVING", "ON", "OR", "SELECT", "WHERE"]);
60
- const WORD_CHAR = /[\w$]/;
61
- const isWordChar = (char) => char !== void 0 && WORD_CHAR.test(char);
62
- const trailingWord = (text) => {
63
- let start = text.length;
64
- while (start > 0 && isWordChar(text[start - 1])) {
65
- start -= 1;
66
- }
67
- return text.slice(start);
68
- };
69
- const tokenAt = (value, caret) => {
70
- let start = caret;
71
- while (start > 0 && isWordChar(value[start - 1])) {
72
- start -= 1;
73
- }
74
- return {
75
- end: caret,
76
- start,
77
- text: value.slice(start, caret)
78
- };
79
- };
80
- const prefersColumns = (value, start) => {
81
- const before = value.slice(0, start).trimEnd();
82
- return before.endsWith(".") || COLUMN_CLAUSES.has(trailingWord(before).toUpperCase());
83
- };
84
- const qualifierTable = (value, start) => {
85
- const before = value.slice(0, start);
86
- if (!before.endsWith(".")) {
87
- return void 0;
88
- }
89
- const name = trailingWord(before.slice(0, -1));
90
- return name === "" ? void 0 : name;
91
- };
92
- const matches = (candidate, needle) => candidate.toLowerCase().startsWith(needle.toLowerCase());
93
- const takeMatches = (names, needle, max, make) => {
94
- const out = [];
95
- for (const name of names) {
96
- if (matches(name, needle)) {
97
- out.push(make(name));
98
- if (out.length >= max) {
99
- break;
100
- }
101
- }
102
- }
103
- return out;
104
- };
105
- const takeColumnMatches = (schema, needle, max) => {
106
- const seen = /* @__PURE__ */ new Map();
107
- for (const [table, columns] of Object.entries(schema.columns)) {
108
- for (const column of columns) {
109
- if (matches(column, needle) && !seen.has(column)) {
110
- seen.set(column, table);
111
- if (seen.size >= max) {
112
- return [...seen].map(([column_, table_]) => {
113
- return {
114
- detail: table_,
115
- kind: "column",
116
- label: column_
117
- };
118
- });
119
- }
120
- }
121
- }
122
- }
123
- return [...seen].map(([column, table]) => {
124
- return {
125
- detail: table,
126
- kind: "column",
127
- label: column
128
- };
129
- });
130
- };
131
- const suggestionsFor = (value, caret, schema) => {
132
- const span = tokenAt(value, caret);
133
- const qualifier = qualifierTable(value, span.start);
134
- if (qualifier !== void 0) {
135
- const owned = schema.columns[qualifier] ?? schema.columns[qualifier.toLowerCase()] ?? [];
136
- return takeMatches(owned, span.text, MAX_SUGGESTIONS, (column) => {
137
- return {
138
- detail: qualifier,
139
- kind: "column",
140
- label: column
141
- };
142
- });
143
- }
144
- if (span.text === "" && !prefersColumns(value, span.start)) {
145
- return [];
146
- }
147
- const tableHits = takeMatches(schema.tables, span.text, MAX_SUGGESTIONS, (table) => {
148
- return {
149
- kind: "table",
150
- label: table
151
- };
152
- });
153
- const columnHits = takeColumnMatches(schema, span.text, MAX_SUGGESTIONS);
154
- const keywordHits = KEYWORDS.filter((keyword) => span.text !== "" && matches(keyword, span.text) && keyword.toLowerCase() !== span.text.toLowerCase()).map((keyword) => {
155
- return {
156
- kind: "keyword",
157
- label: keyword
158
- };
159
- });
160
- const ordered = prefersColumns(value, span.start) ? [...columnHits, ...tableHits, ...keywordHits] : [...tableHits, ...columnHits, ...keywordHits];
161
- return ordered.slice(0, MAX_SUGGESTIONS);
162
- };
163
- const acceptSuggestion = (value, caret, suggestion) => {
164
- const span = tokenAt(value, caret);
165
- const next = value.slice(0, span.start) + suggestion.label + value.slice(span.end);
166
- return {
167
- caret: span.start + suggestion.label.length,
168
- value: next
169
- };
170
- };
171
-
172
- const MIRROR_PROPS = ["boxSizing", "borderBottomWidth", "borderLeftWidth", "borderRightWidth", "borderTopWidth", "fontFamily", "fontSize", "fontStyle", "fontWeight", "letterSpacing", "lineHeight", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "tabSize", "textIndent", "textTransform", "width", "wordSpacing"];
173
- const caretOffset = (textarea, caret) => {
174
- const computed = globalThis.getComputedStyle(textarea);
175
- const mirror = globalThis.document.createElement("div");
176
- const {
177
- style
178
- } = mirror;
179
- style.position = "absolute";
180
- style.visibility = "hidden";
181
- style.whiteSpace = "pre-wrap";
182
- style.overflowWrap = "break-word";
183
- for (const property of MIRROR_PROPS) {
184
- style[property] = computed[property];
185
- }
186
- mirror.textContent = textarea.value.slice(0, Math.max(0, caret));
187
- const marker = globalThis.document.createElement("span");
188
- marker.textContent = textarea.value.slice(Math.max(0, caret)) || ".";
189
- mirror.append(marker);
190
- globalThis.document.body.append(mirror);
191
- const left = marker.offsetLeft - textarea.scrollLeft;
192
- const top = marker.offsetTop - textarea.scrollTop;
193
- mirror.remove();
194
- return {
195
- left,
196
- top
197
- };
198
- };
199
- const useSqlAutocomplete = (schema, textareaRef, setValue) => {
200
- const $ = c(13);
201
- const [state, setState] = useState(null);
202
- let t0;
203
- if ($[0] !== schema || $[1] !== textareaRef) {
204
- t0 = (value, caret) => {
205
- const suggestions = suggestionsFor(value, caret, schema);
206
- if (suggestions.length === 0) {
207
- setState(null);
208
- return;
209
- }
210
- const node = textareaRef.current;
211
- const {
212
- left,
213
- top
214
- } = node === null ? {
215
- left: 0,
216
- top: 0
217
- } : caretOffset(node, caret);
218
- setState({
219
- active: 0,
220
- left,
221
- suggestions,
222
- top
223
- });
224
- };
225
- $[0] = schema;
226
- $[1] = textareaRef;
227
- $[2] = t0;
228
- } else {
229
- t0 = $[2];
230
- }
231
- const refresh = t0;
232
- let t1;
233
- if ($[3] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
234
- t1 = () => {
235
- setState(null);
236
- };
237
- $[3] = t1;
238
- } else {
239
- t1 = $[3];
240
- }
241
- const close = t1;
242
- let t2;
243
- if ($[4] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
244
- t2 = (delta) => {
245
- setState((current) => {
246
- if (current === null) {
247
- return current;
248
- }
249
- const count = current.suggestions.length;
250
- const active = (current.active + delta + count) % count;
251
- return {
252
- ...current,
253
- active
254
- };
255
- });
256
- };
257
- $[4] = t2;
258
- } else {
259
- t2 = $[4];
260
- }
261
- const move = t2;
262
- let t3;
263
- if ($[5] !== setValue || $[6] !== state || $[7] !== textareaRef) {
264
- t3 = () => {
265
- const textarea = textareaRef.current;
266
- if (state === null || textarea === null) {
267
- return false;
268
- }
269
- const chosen = state.suggestions[state.active];
270
- if (chosen === void 0) {
271
- return false;
272
- }
273
- const next = acceptSuggestion(textarea.value, textarea.selectionStart, chosen);
274
- setValue(next.value);
275
- setState(null);
276
- requestAnimationFrame(() => {
277
- const node_0 = textareaRef.current;
278
- if (node_0 !== null) {
279
- node_0.focus();
280
- node_0.setSelectionRange(next.caret, next.caret);
281
- }
282
- });
283
- return true;
284
- };
285
- $[5] = setValue;
286
- $[6] = state;
287
- $[7] = textareaRef;
288
- $[8] = t3;
289
- } else {
290
- t3 = $[8];
291
- }
292
- const commit = t3;
293
- let t4;
294
- if ($[9] !== commit || $[10] !== refresh || $[11] !== state) {
295
- t4 = {
296
- close,
297
- commit,
298
- move,
299
- refresh,
300
- state
301
- };
302
- $[9] = commit;
303
- $[10] = refresh;
304
- $[11] = state;
305
- $[12] = t4;
306
- } else {
307
- t4 = $[12];
308
- }
309
- return t4;
310
- };
311
- const KIND_LABEL = {
312
- column: "column",
313
- keyword: "keyword",
314
- table: "table"
315
- };
316
- const CARET_LINE_OFFSET = 20;
317
- const AutocompletePopover = (t0) => {
318
- const $ = c(17);
319
- const {
320
- listboxId,
321
- onPick,
322
- state
323
- } = t0;
324
- const t = useT();
325
- let t1;
326
- if ($[0] !== state) {
327
- t1 = state === null ? void 0 : {
328
- left: state.left,
329
- top: state.top + CARET_LINE_OFFSET
330
- };
331
- $[0] = state;
332
- $[1] = t1;
333
- } else {
334
- t1 = $[1];
335
- }
336
- const style = t1;
337
- if (state === null) {
338
- return null;
339
- }
340
- let t2;
341
- if ($[2] !== listboxId || $[3] !== onPick || $[4] !== state.active || $[5] !== state.suggestions || $[6] !== t) {
342
- let t32;
343
- if ($[8] !== listboxId || $[9] !== onPick || $[10] !== state.active || $[11] !== t) {
344
- t32 = (suggestion, index) => /* @__PURE__ */ jsxDEV("li", {
345
- "aria-selected": index === state.active,
346
- className: cn("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]", index === state.active ? "bg-accent text-accent-foreground" : "text-foreground"),
347
- "data-testid": "sql-autocomplete-item",
348
- id: `${listboxId}-opt-${index.toString()}`,
349
- onMouseDown: (event) => {
350
- event.preventDefault();
351
- onPick(index);
352
- },
353
- role: "option",
354
- children: [/* @__PURE__ */ jsxDEV("span", {
355
- className: "truncate font-mono",
356
- children: suggestion.label
357
- }, void 0, false), suggestion.detail !== void 0 && /* @__PURE__ */ jsxDEV("span", {
358
- className: "ms-auto truncate text-xs text-muted-foreground",
359
- children: suggestion.detail
360
- }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
361
- className: "shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",
362
- children: t(KIND_LABEL[suggestion.kind])
363
- }, void 0, false)]
364
- }, `${suggestion.kind}:${suggestion.label}`, true);
365
- $[8] = listboxId;
366
- $[9] = onPick;
367
- $[10] = state.active;
368
- $[11] = t;
369
- $[12] = t32;
370
- } else {
371
- t32 = $[12];
372
- }
373
- t2 = state.suggestions.map(t32);
374
- $[2] = listboxId;
375
- $[3] = onPick;
376
- $[4] = state.active;
377
- $[5] = state.suggestions;
378
- $[6] = t;
379
- $[7] = t2;
380
- } else {
381
- t2 = $[7];
382
- }
383
- let t3;
384
- if ($[13] !== listboxId || $[14] !== style || $[15] !== t2) {
385
- t3 = /* @__PURE__ */ jsxDEV("ul", {
386
- 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",
387
- "data-testid": "sql-autocomplete",
388
- id: listboxId,
389
- role: "listbox",
390
- style,
391
- children: t2
392
- }, void 0, false);
393
- $[13] = listboxId;
394
- $[14] = style;
395
- $[15] = t2;
396
- $[16] = t3;
397
- } else {
398
- t3 = $[16];
399
- }
400
- return t3;
401
- };
402
-
403
- const TEMPLATES = [{
404
- label: "List tables",
405
- sql: "SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"
406
- }, {
407
- label: "Table row count",
408
- sql: "SELECT COUNT(*) AS rows FROM messages;"
409
- }, {
410
- label: "Recent rows",
411
- sql: "SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"
412
- }, {
413
- label: "Index list",
414
- sql: "SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"
415
- }];
416
- const QueryRow = (t0) => {
417
- const $ = c(29);
418
- const {
419
- active,
420
- onDelete,
421
- onSelect,
422
- query
423
- } = t0;
424
- const t = useT();
425
- let t1;
426
- if ($[0] !== onSelect || $[1] !== query.id) {
427
- t1 = () => {
428
- onSelect(query.id);
429
- };
430
- $[0] = onSelect;
431
- $[1] = query.id;
432
- $[2] = t1;
433
- } else {
434
- t1 = $[2];
435
- }
436
- const onClick = t1;
437
- let t2;
438
- if ($[3] !== onDelete || $[4] !== query.id) {
439
- t2 = (event) => {
440
- event.stopPropagation();
441
- onDelete(query.id);
442
- };
443
- $[3] = onDelete;
444
- $[4] = query.id;
445
- $[5] = t2;
446
- } else {
447
- t2 = $[5];
448
- }
449
- const onDeleteClick = t2;
450
- const t3 = active ? "bg-sidebar-accent font-medium text-foreground" : "text-muted-foreground";
451
- let t4;
452
- if ($[6] !== t3) {
453
- t4 = cn("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", t3);
454
- $[6] = t3;
455
- $[7] = t4;
456
- } else {
457
- t4 = $[7];
458
- }
459
- const t5 = `sql-query-${query.id}`;
460
- let t6;
461
- if ($[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
462
- t6 = /* @__PURE__ */ jsxDEV("svg", {
463
- "aria-hidden": "true",
464
- className: "size-3.5 shrink-0 opacity-70",
465
- fill: "none",
466
- stroke: "currentColor",
467
- strokeLinecap: "round",
468
- strokeLinejoin: "round",
469
- strokeWidth: 1.6,
470
- viewBox: "0 0 24 24",
471
- children: /* @__PURE__ */ jsxDEV("path", {
472
- d: "M4 6h16M4 12h10M4 18h7"
473
- }, void 0, false)
474
- }, void 0, false);
475
- $[8] = t6;
476
- } else {
477
- t6 = $[8];
478
- }
479
- let t7;
480
- if ($[9] !== query.name) {
481
- t7 = /* @__PURE__ */ jsxDEV("span", {
482
- className: "truncate",
483
- children: query.name
484
- }, void 0, false);
485
- $[9] = query.name;
486
- $[10] = t7;
487
- } else {
488
- t7 = $[10];
489
- }
490
- let t8;
491
- if ($[11] !== active || $[12] !== onClick || $[13] !== t4 || $[14] !== t5 || $[15] !== t7) {
492
- t8 = /* @__PURE__ */ jsxDEV("button", {
493
- "aria-pressed": active,
494
- className: t4,
495
- "data-testid": t5,
496
- onClick,
497
- type: "button",
498
- children: [t6, t7]
499
- }, void 0, true);
500
- $[11] = active;
501
- $[12] = onClick;
502
- $[13] = t4;
503
- $[14] = t5;
504
- $[15] = t7;
505
- $[16] = t8;
506
- } else {
507
- t8 = $[16];
508
- }
509
- let t9;
510
- if ($[17] !== t) {
511
- t9 = t("Delete query");
512
- $[17] = t;
513
- $[18] = t9;
514
- } else {
515
- t9 = $[18];
516
- }
517
- let t10;
518
- if ($[19] !== t) {
519
- t10 = t("Delete query");
520
- $[19] = t;
521
- $[20] = t10;
522
- } else {
523
- t10 = $[20];
524
- }
525
- let t11;
526
- if ($[21] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
527
- t11 = /* @__PURE__ */ jsxDEV("svg", {
528
- "aria-hidden": "true",
529
- className: "size-3.5",
530
- fill: "none",
531
- stroke: "currentColor",
532
- strokeLinecap: "round",
533
- strokeLinejoin: "round",
534
- strokeWidth: 1.6,
535
- viewBox: "0 0 24 24",
536
- children: /* @__PURE__ */ jsxDEV("path", {
537
- d: "M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"
538
- }, void 0, false)
539
- }, void 0, false);
540
- $[21] = t11;
541
- } else {
542
- t11 = $[21];
543
- }
544
- let t12;
545
- if ($[22] !== onDeleteClick || $[23] !== t10 || $[24] !== t9) {
546
- t12 = /* @__PURE__ */ jsxDEV("button", {
547
- "aria-label": t9,
548
- 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",
549
- onClick: onDeleteClick,
550
- title: t10,
551
- type: "button",
552
- children: t11
553
- }, void 0, false);
554
- $[22] = onDeleteClick;
555
- $[23] = t10;
556
- $[24] = t9;
557
- $[25] = t12;
558
- } else {
559
- t12 = $[25];
560
- }
561
- let t13;
562
- if ($[26] !== t12 || $[27] !== t8) {
563
- t13 = /* @__PURE__ */ jsxDEV("li", {
564
- className: "group/q flex items-center",
565
- children: [t8, t12]
566
- }, void 0, true);
567
- $[26] = t12;
568
- $[27] = t8;
569
- $[28] = t13;
570
- } else {
571
- t13 = $[28];
572
- }
573
- return t13;
574
- };
575
- const SqlQuerySidebar = (t0) => {
576
- const $ = c(58);
577
- const {
578
- activeId,
579
- history,
580
- listRef,
581
- onClearHistory,
582
- onDelete,
583
- onLoadHistory,
584
- onLoadTemplate,
585
- onNew,
586
- onSearchChange,
587
- onSelect,
588
- queries,
589
- search
590
- } = t0;
591
- const t = useT();
592
- let t1;
593
- if ($[0] !== queries || $[1] !== search) {
594
- const needle = search.trim().toLowerCase();
595
- t1 = needle === "" ? [...queries] : queries.filter((query) => query.name.toLowerCase().includes(needle));
596
- $[0] = queries;
597
- $[1] = search;
598
- $[2] = t1;
599
- } else {
600
- t1 = $[2];
601
- }
602
- const filtered = t1;
603
- let t2;
604
- if ($[3] !== t) {
605
- t2 = t("Search queries…");
606
- $[3] = t;
607
- $[4] = t2;
608
- } else {
609
- t2 = $[4];
610
- }
611
- let t3;
612
- if ($[5] !== onSearchChange || $[6] !== search || $[7] !== t2) {
613
- t3 = /* @__PURE__ */ jsxDEV("input", {
614
- 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",
615
- "data-testid": "sql-search",
616
- onChange: onSearchChange,
617
- placeholder: t2,
618
- type: "text",
619
- value: search
620
- }, void 0, false);
621
- $[5] = onSearchChange;
622
- $[6] = search;
623
- $[7] = t2;
624
- $[8] = t3;
625
- } else {
626
- t3 = $[8];
627
- }
628
- let t4;
629
- if ($[9] !== t) {
630
- t4 = t("New query");
631
- $[9] = t;
632
- $[10] = t4;
633
- } else {
634
- t4 = $[10];
635
- }
636
- let t5;
637
- if ($[11] !== t) {
638
- t5 = t("New query");
639
- $[11] = t;
640
- $[12] = t5;
641
- } else {
642
- t5 = $[12];
643
- }
644
- let t6;
645
- if ($[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
646
- t6 = /* @__PURE__ */ jsxDEV("svg", {
647
- "aria-hidden": "true",
648
- className: "size-4",
649
- fill: "none",
650
- stroke: "currentColor",
651
- strokeLinecap: "round",
652
- strokeLinejoin: "round",
653
- strokeWidth: 1.7,
654
- viewBox: "0 0 24 24",
655
- children: /* @__PURE__ */ jsxDEV("path", {
656
- d: "M12 5v14M5 12h14"
657
- }, void 0, false)
658
- }, void 0, false);
659
- $[13] = t6;
660
- } else {
661
- t6 = $[13];
662
- }
663
- let t7;
664
- if ($[14] !== onNew || $[15] !== t4 || $[16] !== t5) {
665
- t7 = /* @__PURE__ */ jsxDEV("button", {
666
- "aria-label": t4,
667
- 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",
668
- "data-testid": "sql-new",
669
- onClick: onNew,
670
- title: t5,
671
- type: "button",
672
- children: t6
673
- }, void 0, false);
674
- $[14] = onNew;
675
- $[15] = t4;
676
- $[16] = t5;
677
- $[17] = t7;
678
- } else {
679
- t7 = $[17];
680
- }
681
- let t8;
682
- if ($[18] !== t3 || $[19] !== t7) {
683
- t8 = /* @__PURE__ */ jsxDEV("div", {
684
- className: "flex shrink-0 items-center gap-2 border-b border-border p-2",
685
- children: [t3, t7]
686
- }, void 0, true);
687
- $[18] = t3;
688
- $[19] = t7;
689
- $[20] = t8;
690
- } else {
691
- t8 = $[20];
692
- }
693
- let t9;
694
- if ($[21] !== t) {
695
- t9 = t("Private");
696
- $[21] = t;
697
- $[22] = t9;
698
- } else {
699
- t9 = $[22];
700
- }
701
- let t10;
702
- if ($[23] !== t9) {
703
- t10 = /* @__PURE__ */ jsxDEV("p", {
704
- className: "px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
705
- children: t9
706
- }, void 0, false);
707
- $[23] = t9;
708
- $[24] = t10;
709
- } else {
710
- t10 = $[24];
711
- }
712
- let t11;
713
- if ($[25] !== activeId || $[26] !== filtered || $[27] !== listRef || $[28] !== onDelete || $[29] !== onSelect || $[30] !== t) {
714
- t11 = filtered.length === 0 ? /* @__PURE__ */ jsxDEV("p", {
715
- className: "px-1 py-2 text-xs text-muted-foreground",
716
- "data-testid": "sql-private-empty",
717
- children: t("No saved queries yet — they save to this browser as you type.")
718
- }, void 0, false) : /* @__PURE__ */ jsxDEV("ul", {
719
- className: "flex flex-col gap-px",
720
- "data-testid": "sql-private",
721
- ref: listRef,
722
- children: filtered.map((query_0) => /* @__PURE__ */ jsxDEV(QueryRow, {
723
- active: activeId === query_0.id,
724
- onDelete,
725
- onSelect,
726
- query: query_0
727
- }, query_0.id, false))
728
- }, void 0, false);
729
- $[25] = activeId;
730
- $[26] = filtered;
731
- $[27] = listRef;
732
- $[28] = onDelete;
733
- $[29] = onSelect;
734
- $[30] = t;
735
- $[31] = t11;
736
- } else {
737
- t11 = $[31];
738
- }
739
- let t12;
740
- if ($[32] !== t10 || $[33] !== t11) {
741
- t12 = /* @__PURE__ */ jsxDEV("div", {
742
- children: [t10, t11]
743
- }, void 0, true);
744
- $[32] = t10;
745
- $[33] = t11;
746
- $[34] = t12;
747
- } else {
748
- t12 = $[34];
749
- }
750
- let t13;
751
- if ($[35] !== t) {
752
- t13 = t("Reference");
753
- $[35] = t;
754
- $[36] = t13;
755
- } else {
756
- t13 = $[36];
757
- }
758
- let t14;
759
- if ($[37] !== t13) {
760
- t14 = /* @__PURE__ */ jsxDEV("p", {
761
- className: "px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
762
- children: t13
763
- }, void 0, false);
764
- $[37] = t13;
765
- $[38] = t14;
766
- } else {
767
- t14 = $[38];
768
- }
769
- let t15;
770
- if ($[39] !== onLoadTemplate) {
771
- t15 = TEMPLATES.map((template) => /* @__PURE__ */ jsxDEV("li", {
772
- children: /* @__PURE__ */ jsxDEV("button", {
773
- 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",
774
- "data-sql": template.sql,
775
- onClick: onLoadTemplate,
776
- type: "button",
777
- children: [/* @__PURE__ */ jsxDEV("svg", {
778
- "aria-hidden": "true",
779
- className: "size-3.5 shrink-0 opacity-70",
780
- fill: "none",
781
- stroke: "currentColor",
782
- strokeLinecap: "round",
783
- strokeLinejoin: "round",
784
- strokeWidth: 1.6,
785
- viewBox: "0 0 24 24",
786
- children: /* @__PURE__ */ jsxDEV("path", {
787
- d: "M7 4h7l4 4v12H7zM14 4v4h4"
788
- }, void 0, false)
789
- }, void 0, false), template.label]
790
- }, void 0, true)
791
- }, template.label, false));
792
- $[39] = onLoadTemplate;
793
- $[40] = t15;
794
- } else {
795
- t15 = $[40];
796
- }
797
- let t16;
798
- if ($[41] !== t15) {
799
- t16 = /* @__PURE__ */ jsxDEV("ul", {
800
- className: "flex flex-col gap-px",
801
- children: t15
802
- }, void 0, false);
803
- $[41] = t15;
804
- $[42] = t16;
805
- } else {
806
- t16 = $[42];
807
- }
808
- let t17;
809
- if ($[43] !== t14 || $[44] !== t16) {
810
- t17 = /* @__PURE__ */ jsxDEV("div", {
811
- children: [t14, t16]
812
- }, void 0, true);
813
- $[43] = t14;
814
- $[44] = t16;
815
- $[45] = t17;
816
- } else {
817
- t17 = $[45];
818
- }
819
- let t18;
820
- if ($[46] !== history || $[47] !== onClearHistory || $[48] !== onLoadHistory || $[49] !== t) {
821
- t18 = history.length > 0 && /* @__PURE__ */ jsxDEV("div", {
822
- children: [/* @__PURE__ */ jsxDEV("div", {
823
- className: "flex items-center justify-between px-1 pb-1",
824
- children: [/* @__PURE__ */ jsxDEV("p", {
825
- className: "font-mono text-[11px] tracking-wide text-muted-foreground uppercase",
826
- children: t("History")
827
- }, void 0, false), /* @__PURE__ */ jsxDEV("button", {
828
- className: "rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground",
829
- "data-testid": "sql-history-clear",
830
- onClick: onClearHistory,
831
- type: "button",
832
- children: t("Clear history")
833
- }, void 0, false)]
834
- }, void 0, true), /* @__PURE__ */ jsxDEV("ul", {
835
- className: "flex flex-col gap-px",
836
- "data-testid": "sql-history",
837
- children: history.map((entry) => /* @__PURE__ */ jsxDEV("li", {
838
- children: /* @__PURE__ */ jsxDEV("button", {
839
- 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",
840
- "data-sql": entry.sql,
841
- "data-testid": "sql-history-item",
842
- onClick: onLoadHistory,
843
- title: entry.sql,
844
- type: "button",
845
- children: [/* @__PURE__ */ jsxDEV("svg", {
846
- "aria-hidden": "true",
847
- className: "size-3.5 shrink-0 opacity-70",
848
- fill: "none",
849
- stroke: "currentColor",
850
- strokeLinecap: "round",
851
- strokeLinejoin: "round",
852
- strokeWidth: 1.6,
853
- viewBox: "0 0 24 24",
854
- children: /* @__PURE__ */ jsxDEV("path", {
855
- d: "M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"
856
- }, void 0, false)
857
- }, void 0, false), /* @__PURE__ */ jsxDEV("span", {
858
- className: "truncate font-mono",
859
- children: entry.sql
860
- }, void 0, false)]
861
- }, void 0, true)
862
- }, `${entry.at.toString()}:${entry.sql}`, false))
863
- }, void 0, false)]
864
- }, void 0, true);
865
- $[46] = history;
866
- $[47] = onClearHistory;
867
- $[48] = onLoadHistory;
868
- $[49] = t;
869
- $[50] = t18;
870
- } else {
871
- t18 = $[50];
872
- }
873
- let t19;
874
- if ($[51] !== t12 || $[52] !== t17 || $[53] !== t18) {
875
- t19 = /* @__PURE__ */ jsxDEV("div", {
876
- className: "flex flex-1 flex-col gap-4 overflow-y-auto p-2",
877
- children: [t12, t17, t18]
878
- }, void 0, true);
879
- $[51] = t12;
880
- $[52] = t17;
881
- $[53] = t18;
882
- $[54] = t19;
883
- } else {
884
- t19 = $[54];
885
- }
886
- let t20;
887
- if ($[55] !== t19 || $[56] !== t8) {
888
- t20 = /* @__PURE__ */ jsxDEV("aside", {
889
- className: "flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar",
890
- children: [t8, t19]
891
- }, void 0, true);
892
- $[55] = t19;
893
- $[56] = t8;
894
- $[57] = t20;
895
- } else {
896
- t20 = $[57];
897
- }
898
- return t20;
899
- };
900
-
901
- const LIST_TABLES = adminRef(ADMIN_FUNCTIONS.listTables);
902
- const READ_TABLE_PAGE = adminRef(ADMIN_FUNCTIONS.readTablePage);
903
- const useSqlSchema = (shardKey) => {
904
- const $ = c(16);
905
- const client = useLunora();
906
- let t0;
907
- if ($[0] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
908
- t0 = [];
909
- $[0] = t0;
910
- } else {
911
- t0 = $[0];
912
- }
913
- const [tables, setTables] = useState(t0);
914
- let t1;
915
- if ($[1] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
916
- t1 = {};
917
- $[1] = t1;
918
- } else {
919
- t1 = $[1];
920
- }
921
- const [columns, setColumns] = useState(t1);
922
- let t2;
923
- if ($[2] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
924
- t2 = /* @__PURE__ */ new Set();
925
- $[2] = t2;
926
- } else {
927
- t2 = $[2];
928
- }
929
- const probed = useRef(t2);
930
- let t3;
931
- let t4;
932
- if ($[3] !== client || $[4] !== shardKey) {
933
- t3 = () => {
934
- const token = {
935
- cancelled: false
936
- };
937
- const load = async () => {
938
- try {
939
- const result = await client.query(LIST_TABLES, {}, callOptions(shardKey));
940
- if (!token.cancelled) {
941
- setTables(result.map(_temp$2));
942
- setColumns({});
943
- probed.current = /* @__PURE__ */ new Set();
944
- }
945
- } catch {
946
- if (!token.cancelled) {
947
- setTables([]);
948
- setColumns({});
949
- probed.current = /* @__PURE__ */ new Set();
950
- }
951
- }
952
- };
953
- fireAndForget(load());
954
- return () => {
955
- token.cancelled = true;
956
- };
957
- };
958
- t4 = [client, shardKey];
959
- $[3] = client;
960
- $[4] = shardKey;
961
- $[5] = t3;
962
- $[6] = t4;
963
- } else {
964
- t3 = $[5];
965
- t4 = $[6];
966
- }
967
- useEffect(t3, t4);
968
- let t5;
969
- if ($[7] !== client || $[8] !== shardKey) {
970
- t5 = (table_0) => {
971
- if (probed.current.has(table_0)) {
972
- return;
973
- }
974
- probed.current.add(table_0);
975
- const fetchColumns = async () => {
976
- try {
977
- const page = await client.query(READ_TABLE_PAGE, {
978
- limit: 1,
979
- offset: 0,
980
- table: table_0
981
- }, callOptions(shardKey));
982
- setColumns((previous) => ({
983
- ...previous,
984
- [table_0]: page.columns
985
- }));
986
- } catch {
987
- probed.current.delete(table_0);
988
- }
989
- };
990
- fireAndForget(fetchColumns());
991
- };
992
- $[7] = client;
993
- $[8] = shardKey;
994
- $[9] = t5;
995
- } else {
996
- t5 = $[9];
997
- }
998
- const probe = t5;
999
- let t6;
1000
- if ($[10] !== columns || $[11] !== tables) {
1001
- t6 = {
1002
- columns,
1003
- tables
1004
- };
1005
- $[10] = columns;
1006
- $[11] = tables;
1007
- $[12] = t6;
1008
- } else {
1009
- t6 = $[12];
1010
- }
1011
- const schema = t6;
1012
- let t7;
1013
- if ($[13] !== probe || $[14] !== schema) {
1014
- t7 = {
1015
- probe,
1016
- schema
1017
- };
1018
- $[13] = probe;
1019
- $[14] = schema;
1020
- $[15] = t7;
1021
- } else {
1022
- t7 = $[15];
1023
- }
1024
- return t7;
1025
- };
1026
- const TABLE_REF = /\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi;
1027
- const referencedTables = (sql) => {
1028
- const names = /* @__PURE__ */ new Set();
1029
- TABLE_REF.lastIndex = 0;
1030
- let match = TABLE_REF.exec(sql);
1031
- while (match !== null) {
1032
- names.add(match[1] ?? match[2]);
1033
- match = TABLE_REF.exec(sql);
1034
- }
1035
- return [...names];
1036
- };
1037
- function _temp$2(table) {
1038
- return table.name;
1039
- }
1040
-
1041
- const TABS_KEY = "lunora-studio-sql-tabs";
1042
- const ACTIVE_KEY = "lunora-studio-sql-active-tab";
1043
- const MAX_TABS = 12;
1044
- const makeTab = (sql = "", name = "") => {
1045
- return {
1046
- activeId: null,
1047
- id: newId("tab"),
1048
- name,
1049
- sql
1050
- };
1051
- };
1052
- const usePersistedActive = () => {
1053
- const $ = c(5);
1054
- const [list, setList] = usePersistedList(ACTIVE_KEY);
1055
- let t0;
1056
- if ($[0] !== setList) {
1057
- t0 = (action) => {
1058
- setList((current) => {
1059
- const previous = current[0] ?? "";
1060
- const next = typeof action === "function" ? action(previous) : action;
1061
- return [next];
1062
- });
1063
- };
1064
- $[0] = setList;
1065
- $[1] = t0;
1066
- } else {
1067
- t0 = $[1];
1068
- }
1069
- const setActive = t0;
1070
- const t1 = list[0] ?? "";
1071
- let t2;
1072
- if ($[2] !== setActive || $[3] !== t1) {
1073
- t2 = [t1, setActive];
1074
- $[2] = setActive;
1075
- $[3] = t1;
1076
- $[4] = t2;
1077
- } else {
1078
- t2 = $[4];
1079
- }
1080
- return t2;
1081
- };
1082
- const usePersistedTabs = (seed) => {
1083
- const [stored, setTabs] = usePersistedList(TABS_KEY);
1084
- const [activeRaw, setActiveId] = usePersistedActive();
1085
- const seedTab = useRef(null);
1086
- if (stored.length === 0 && seedTab.current === null) {
1087
- seedTab.current = seed();
1088
- }
1089
- useEffect(() => {
1090
- if (stored.length === 0 && seedTab.current !== null) {
1091
- const initial = seedTab.current;
1092
- setTabs([initial]);
1093
- }
1094
- }, [setTabs, stored.length]);
1095
- const tabs = stored.length === 0 && seedTab.current !== null ? [seedTab.current] : stored;
1096
- const activeId = tabs.some((tab) => tab.id === activeRaw) ? activeRaw : tabs[0]?.id ?? "";
1097
- return {
1098
- activeId,
1099
- setActiveId,
1100
- setTabs,
1101
- tabs
1102
- };
1103
- };
1104
- const isDirty = (tab) => tab.activeId === null && tab.sql.trim() !== "";
1105
- const addTab = (tabs, tab) => [...tabs, tab].slice(-MAX_TABS);
1106
- const closeTab = (tabs, id, makeEmpty) => {
1107
- const index = tabs.findIndex((tab) => tab.id === id);
1108
- if (index === -1) {
1109
- return {
1110
- activeId: tabs[0]?.id ?? "",
1111
- tabs: [...tabs]
1112
- };
1113
- }
1114
- const remaining = tabs.filter((tab) => tab.id !== id);
1115
- if (remaining.length === 0) {
1116
- const fresh = makeEmpty();
1117
- return {
1118
- activeId: fresh.id,
1119
- tabs: [fresh]
1120
- };
1121
- }
1122
- const neighbour = remaining[Math.min(index, remaining.length - 1)];
1123
- return {
1124
- activeId: neighbour.id,
1125
- tabs: remaining
1126
- };
1127
- };
1128
- const closeOtherTabs = (tabs, id) => {
1129
- const kept = tabs.filter((tab) => tab.id === id);
1130
- return kept.length === 0 ? {
1131
- activeId: tabs[0]?.id ?? "",
1132
- tabs: [...tabs]
1133
- } : {
1134
- activeId: id,
1135
- tabs: kept
1136
- };
1137
- };
1138
- const closeTabsToRight = (tabs, id, activeId) => {
1139
- const index = tabs.findIndex((tab) => tab.id === id);
1140
- if (index === -1) {
1141
- return {
1142
- activeId,
1143
- tabs: [...tabs]
1144
- };
1145
- }
1146
- const kept = tabs.slice(0, index + 1);
1147
- return {
1148
- activeId: kept.some((tab) => tab.id === activeId) ? activeId : id,
1149
- tabs: kept
1150
- };
1151
- };
1152
- const closeAllTabs = (makeEmpty) => {
1153
- const fresh = makeEmpty();
1154
- return {
1155
- activeId: fresh.id,
1156
- tabs: [fresh]
1157
- };
1158
- };
1159
- const tabsClosedBy = (op, tabs, id) => {
1160
- if (op === "others") {
1161
- return tabs.filter((tab) => tab.id !== id);
1162
- }
1163
- if (op === "right") {
1164
- const index = tabs.findIndex((tab) => tab.id === id);
1165
- return index === -1 ? [] : tabs.slice(index + 1);
1166
- }
1167
- return [...tabs];
1168
- };
1169
-
1170
- const derivedTabLabel = (sql, untitled) => sql.trim() === "" ? untitled : (sql.split("\n")[0] ?? sql).slice(0, 24);
1171
- const TabRenameInput = (t0) => {
1172
- const $ = c(14);
1173
- const {
1174
- initial,
1175
- onCancel,
1176
- onCommit,
1177
- placeholder,
1178
- testId
1179
- } = t0;
1180
- const t = useT();
1181
- const focusOnMount = _temp$1;
1182
- let t1;
1183
- if ($[0] !== onCommit) {
1184
- t1 = (event) => {
1185
- onCommit(event.currentTarget.value.trim());
1186
- };
1187
- $[0] = onCommit;
1188
- $[1] = t1;
1189
- } else {
1190
- t1 = $[1];
1191
- }
1192
- const onBlur = t1;
1193
- let t2;
1194
- if ($[2] !== onCancel || $[3] !== onCommit) {
1195
- t2 = (event_0) => {
1196
- if (event_0.key === "Enter") {
1197
- onCommit(event_0.currentTarget.value.trim());
1198
- } else {
1199
- if (event_0.key === "Escape") {
1200
- onCancel();
1201
- }
1202
- }
1203
- };
1204
- $[2] = onCancel;
1205
- $[3] = onCommit;
1206
- $[4] = t2;
1207
- } else {
1208
- t2 = $[4];
1209
- }
1210
- const onKeyDown = t2;
1211
- let t3;
1212
- if ($[5] !== t) {
1213
- t3 = t("Tab title");
1214
- $[5] = t;
1215
- $[6] = t3;
1216
- } else {
1217
- t3 = $[6];
1218
- }
1219
- let t4;
1220
- if ($[7] !== initial || $[8] !== onBlur || $[9] !== onKeyDown || $[10] !== placeholder || $[11] !== t3 || $[12] !== testId) {
1221
- t4 = /* @__PURE__ */ jsxDEV("input", {
1222
- "aria-label": t3,
1223
- className: "w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none",
1224
- "data-testid": testId,
1225
- defaultValue: initial,
1226
- onBlur,
1227
- onKeyDown,
1228
- placeholder,
1229
- ref: focusOnMount,
1230
- type: "text"
1231
- }, void 0, false);
1232
- $[7] = initial;
1233
- $[8] = onBlur;
1234
- $[9] = onKeyDown;
1235
- $[10] = placeholder;
1236
- $[11] = t3;
1237
- $[12] = testId;
1238
- $[13] = t4;
1239
- } else {
1240
- t4 = $[13];
1241
- }
1242
- return t4;
1243
- };
1244
- const TabCloseConfirm = (t0) => {
1245
- const $ = c(29);
1246
- const {
1247
- idBase,
1248
- onDiscard,
1249
- onKeep
1250
- } = t0;
1251
- const t = useT();
1252
- const t1 = `sql-tab-close-prompt-${idBase}`;
1253
- let t2;
1254
- if ($[0] !== t) {
1255
- t2 = t("Discard?");
1256
- $[0] = t;
1257
- $[1] = t2;
1258
- } else {
1259
- t2 = $[1];
1260
- }
1261
- let t3;
1262
- if ($[2] !== t2) {
1263
- t3 = /* @__PURE__ */ jsxDEV("span", {
1264
- className: "text-[11px] text-muted-foreground",
1265
- children: t2
1266
- }, void 0, false);
1267
- $[2] = t2;
1268
- $[3] = t3;
1269
- } else {
1270
- t3 = $[3];
1271
- }
1272
- let t4;
1273
- if ($[4] !== t) {
1274
- t4 = t("Discard changes");
1275
- $[4] = t;
1276
- $[5] = t4;
1277
- } else {
1278
- t4 = $[5];
1279
- }
1280
- const t5 = `sql-tab-close-confirm-${idBase}`;
1281
- let t6;
1282
- if ($[6] !== t) {
1283
- t6 = t("Discard changes");
1284
- $[6] = t;
1285
- $[7] = t6;
1286
- } else {
1287
- t6 = $[7];
1288
- }
1289
- let t7;
1290
- if ($[8] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1291
- t7 = /* @__PURE__ */ jsxDEV("svg", {
1292
- "aria-hidden": "true",
1293
- className: "size-3",
1294
- fill: "none",
1295
- stroke: "currentColor",
1296
- strokeLinecap: "round",
1297
- strokeLinejoin: "round",
1298
- strokeWidth: 2.4,
1299
- viewBox: "0 0 24 24",
1300
- children: /* @__PURE__ */ jsxDEV("path", {
1301
- d: "M5 13l4 4L19 7"
1302
- }, void 0, false)
1303
- }, void 0, false);
1304
- $[8] = t7;
1305
- } else {
1306
- t7 = $[8];
1307
- }
1308
- let t8;
1309
- if ($[9] !== onDiscard || $[10] !== t4 || $[11] !== t5 || $[12] !== t6) {
1310
- t8 = /* @__PURE__ */ jsxDEV("button", {
1311
- "aria-label": t4,
1312
- className: "flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10",
1313
- "data-testid": t5,
1314
- onClick: onDiscard,
1315
- title: t6,
1316
- type: "button",
1317
- children: t7
1318
- }, void 0, false);
1319
- $[9] = onDiscard;
1320
- $[10] = t4;
1321
- $[11] = t5;
1322
- $[12] = t6;
1323
- $[13] = t8;
1324
- } else {
1325
- t8 = $[13];
1326
- }
1327
- let t9;
1328
- if ($[14] !== t) {
1329
- t9 = t("Keep editing");
1330
- $[14] = t;
1331
- $[15] = t9;
1332
- } else {
1333
- t9 = $[15];
1334
- }
1335
- const t10 = `sql-tab-close-cancel-${idBase}`;
1336
- let t11;
1337
- if ($[16] !== t) {
1338
- t11 = t("Keep editing");
1339
- $[16] = t;
1340
- $[17] = t11;
1341
- } else {
1342
- t11 = $[17];
1343
- }
1344
- let t12;
1345
- if ($[18] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1346
- t12 = /* @__PURE__ */ jsxDEV("svg", {
1347
- "aria-hidden": "true",
1348
- className: "size-3",
1349
- fill: "none",
1350
- stroke: "currentColor",
1351
- strokeLinecap: "round",
1352
- strokeLinejoin: "round",
1353
- strokeWidth: 2.4,
1354
- viewBox: "0 0 24 24",
1355
- children: /* @__PURE__ */ jsxDEV("path", {
1356
- d: "M6 6l12 12M18 6 6 18"
1357
- }, void 0, false)
1358
- }, void 0, false);
1359
- $[18] = t12;
1360
- } else {
1361
- t12 = $[18];
1362
- }
1363
- let t13;
1364
- if ($[19] !== onKeep || $[20] !== t10 || $[21] !== t11 || $[22] !== t9) {
1365
- t13 = /* @__PURE__ */ jsxDEV("button", {
1366
- "aria-label": t9,
1367
- className: "flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent",
1368
- "data-testid": t10,
1369
- onClick: onKeep,
1370
- title: t11,
1371
- type: "button",
1372
- children: t12
1373
- }, void 0, false);
1374
- $[19] = onKeep;
1375
- $[20] = t10;
1376
- $[21] = t11;
1377
- $[22] = t9;
1378
- $[23] = t13;
1379
- } else {
1380
- t13 = $[23];
1381
- }
1382
- let t14;
1383
- if ($[24] !== t1 || $[25] !== t13 || $[26] !== t3 || $[27] !== t8) {
1384
- t14 = /* @__PURE__ */ jsxDEV("span", {
1385
- className: "flex shrink-0 items-center gap-1",
1386
- "data-testid": t1,
1387
- role: "group",
1388
- children: [t3, t8, t13]
1389
- }, void 0, true);
1390
- $[24] = t1;
1391
- $[25] = t13;
1392
- $[26] = t3;
1393
- $[27] = t8;
1394
- $[28] = t14;
1395
- } else {
1396
- t14 = $[28];
1397
- }
1398
- return t14;
1399
- };
1400
- const TabButton = (t0) => {
1401
- const $ = c(47);
1402
- const {
1403
- active,
1404
- canClose,
1405
- onClose,
1406
- onMenu,
1407
- onRename,
1408
- onSelect,
1409
- tab
1410
- } = t0;
1411
- const t = useT();
1412
- const [editing, setEditing] = useState(false);
1413
- const [confirmingClose, setConfirmingClose] = useState(false);
1414
- let t1;
1415
- if ($[0] !== onMenu || $[1] !== tab.id) {
1416
- t1 = (event) => {
1417
- onMenu(tab.id, event);
1418
- };
1419
- $[0] = onMenu;
1420
- $[1] = tab.id;
1421
- $[2] = t1;
1422
- } else {
1423
- t1 = $[2];
1424
- }
1425
- const onContextMenu = t1;
1426
- let t2;
1427
- if ($[3] !== onSelect || $[4] !== tab.id) {
1428
- t2 = () => {
1429
- onSelect(tab.id);
1430
- };
1431
- $[3] = onSelect;
1432
- $[4] = tab.id;
1433
- $[5] = t2;
1434
- } else {
1435
- t2 = $[5];
1436
- }
1437
- const onClick = t2;
1438
- let t3;
1439
- if ($[6] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1440
- t3 = () => {
1441
- setEditing(true);
1442
- };
1443
- $[6] = t3;
1444
- } else {
1445
- t3 = $[6];
1446
- }
1447
- const startEditing = t3;
1448
- let t4;
1449
- if ($[7] !== onClose || $[8] !== tab) {
1450
- t4 = (event_0) => {
1451
- event_0.stopPropagation();
1452
- if (isDirty(tab)) {
1453
- setConfirmingClose(true);
1454
- } else {
1455
- onClose(tab.id);
1456
- }
1457
- };
1458
- $[7] = onClose;
1459
- $[8] = tab;
1460
- $[9] = t4;
1461
- } else {
1462
- t4 = $[9];
1463
- }
1464
- const onCloseClick = t4;
1465
- let t5;
1466
- if ($[10] !== onClose || $[11] !== tab.id) {
1467
- t5 = (event_1) => {
1468
- event_1.stopPropagation();
1469
- setConfirmingClose(false);
1470
- onClose(tab.id);
1471
- };
1472
- $[10] = onClose;
1473
- $[11] = tab.id;
1474
- $[12] = t5;
1475
- } else {
1476
- t5 = $[12];
1477
- }
1478
- const confirmClose = t5;
1479
- let t6;
1480
- if ($[13] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1481
- t6 = (event_2) => {
1482
- event_2.stopPropagation();
1483
- setConfirmingClose(false);
1484
- };
1485
- $[13] = t6;
1486
- } else {
1487
- t6 = $[13];
1488
- }
1489
- const cancelClose = t6;
1490
- let t7;
1491
- if ($[14] !== onRename || $[15] !== tab.id) {
1492
- t7 = (name) => {
1493
- onRename(tab.id, name);
1494
- setEditing(false);
1495
- };
1496
- $[14] = onRename;
1497
- $[15] = tab.id;
1498
- $[16] = t7;
1499
- } else {
1500
- t7 = $[16];
1501
- }
1502
- const commitRename = t7;
1503
- let t8;
1504
- if ($[17] === /* @__PURE__ */ Symbol.for("react.memo_cache_sentinel")) {
1505
- t8 = () => {
1506
- setEditing(false);
1507
- };
1508
- $[17] = t8;
1509
- } else {
1510
- t8 = $[17];
1511
- }
1512
- const cancelRename = t8;
1513
- let t9;
1514
- if ($[18] !== tab.name) {
1515
- t9 = tab.name.trim();
1516
- $[18] = tab.name;
1517
- $[19] = t9;
1518
- } else {
1519
- t9 = $[19];
1520
- }
1521
- const custom = t9;
1522
- let t10;
1523
- if ($[20] !== t || $[21] !== tab.sql) {
1524
- t10 = derivedTabLabel(tab.sql, t("Untitled"));
1525
- $[20] = t;
1526
- $[21] = tab.sql;
1527
- $[22] = t10;
1528
- } else {
1529
- t10 = $[22];
1530
- }
1531
- const derived = t10;
1532
- const t11 = active ? "bg-background text-foreground" : "bg-muted/40 text-muted-foreground hover:text-foreground";
1533
- let t12;
1534
- if ($[23] !== t11) {
1535
- t12 = cn("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs", t11);
1536
- $[23] = t11;
1537
- $[24] = t12;
1538
- } else {
1539
- t12 = $[24];
1540
- }
1541
- const t13 = `sql-tab-${tab.id}`;
1542
- let t14;
1543
- if ($[25] !== active || $[26] !== commitRename || $[27] !== custom || $[28] !== derived || $[29] !== editing || $[30] !== onClick || $[31] !== t || $[32] !== tab.id) {
1544
- t14 = editing ? /* @__PURE__ */ jsxDEV(TabRenameInput, {
1545
- initial: custom,
1546
- onCancel: cancelRename,
1547
- onCommit: commitRename,
1548
- placeholder: derived,
1549
- testId: `sql-tab-rename-${tab.id}`
1550
- }, void 0, false) : /* @__PURE__ */ jsxDEV("button", {
1551
- "aria-pressed": active,
1552
- className: "max-w-40 truncate py-1.5 outline-none",
1553
- "data-testid": `sql-tab-select-${tab.id}`,
1554
- onClick,
1555
- onDoubleClick: startEditing,
1556
- title: t("Double-click to rename"),
1557
- type: "button",
1558
- children: custom === "" ? derived : custom
1559
- }, void 0, false);
1560
- $[25] = active;
1561
- $[26] = commitRename;
1562
- $[27] = custom;
1563
- $[28] = derived;
1564
- $[29] = editing;
1565
- $[30] = onClick;
1566
- $[31] = t;
1567
- $[32] = tab.id;
1568
- $[33] = t14;
1569
- } else {
1570
- t14 = $[33];
1571
- }
1572
- let t15;
1573
- if ($[34] !== canClose || $[35] !== confirmClose || $[36] !== confirmingClose || $[37] !== onCloseClick || $[38] !== t || $[39] !== tab.id) {
1574
- t15 = canClose && (confirmingClose ? /* @__PURE__ */ jsxDEV(TabCloseConfirm, {
1575
- idBase: tab.id,
1576
- onDiscard: confirmClose,
1577
- onKeep: cancelClose
1578
- }, void 0, false) : /* @__PURE__ */ jsxDEV("button", {
1579
- "aria-label": t("Close tab"),
1580
- className: "flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive",
1581
- "data-testid": `sql-tab-close-${tab.id}`,
1582
- onClick: onCloseClick,
1583
- title: t("Close tab"),
1584
- type: "button",
1585
- children: /* @__PURE__ */ jsxDEV("svg", {
1586
- "aria-hidden": "true",
1587
- className: "size-3",
1588
- fill: "none",
1589
- stroke: "currentColor",
1590
- strokeLinecap: "round",
1591
- strokeLinejoin: "round",
1592
- strokeWidth: 2,
1593
- viewBox: "0 0 24 24",
1594
- children: /* @__PURE__ */ jsxDEV("path", {
1595
- d: "M6 6l12 12M18 6 6 18"
1596
- }, void 0, false)
1597
- }, void 0, false)
1598
- }, void 0, false));
1599
- $[34] = canClose;
1600
- $[35] = confirmClose;
1601
- $[36] = confirmingClose;
1602
- $[37] = onCloseClick;
1603
- $[38] = t;
1604
- $[39] = tab.id;
1605
- $[40] = t15;
1606
- } else {
1607
- t15 = $[40];
1608
- }
1609
- let t16;
1610
- if ($[41] !== onContextMenu || $[42] !== t12 || $[43] !== t13 || $[44] !== t14 || $[45] !== t15) {
1611
- t16 = /* @__PURE__ */ jsxDEV("div", {
1612
- className: t12,
1613
- "data-testid": t13,
1614
- onContextMenu,
1615
- children: [t14, t15]
1616
- }, void 0, true);
1617
- $[41] = onContextMenu;
1618
- $[42] = t12;
1619
- $[43] = t13;
1620
- $[44] = t14;
1621
- $[45] = t15;
1622
- $[46] = t16;
1623
- } else {
1624
- t16 = $[46];
1625
- }
1626
- return t16;
1627
- };
1628
- function _temp$1(node) {
1629
- node?.focus();
1630
- node?.select();
1631
- }
1632
-
1633
- const RUN_SQL = adminRef(ADMIN_FUNCTIONS.runSql);
1634
- const STORAGE_KEY = "lunora-studio-sql-queries";
1635
- const HISTORY_KEY = "lunora-studio-sql-history";
1636
- const HISTORY_LIMIT = 25;
1637
- const GUTTER_STYLE = {
1638
- minWidth: "2.75rem",
1639
- paddingInline: "0.5rem"
1640
- };
1641
- const DEFAULT_TAB_OUTPUT = {
1642
- error: null,
1643
- pane: "results",
1644
- result: null
1645
- };
1646
- const SqlResultTable = (t0) => {
1647
- const $ = c(16);
1648
- const {
1649
- result
1650
- } = t0;
1651
- if (result.columns.length === 0) {
1652
- const t12 = result.rowCount === 0 ? "0 rows" : "";
1653
- let t22;
1654
- if ($[0] !== t12) {
1655
- t22 = /* @__PURE__ */ jsxDEV("p", {
1656
- className: "p-4 text-sm text-muted-foreground",
1657
- children: t12
1658
- }, void 0, false);
1659
- $[0] = t12;
1660
- $[1] = t22;
1661
- } else {
1662
- t22 = $[1];
1663
- }
1664
- return t22;
1665
- }
1666
- let t1;
1667
- if ($[2] !== result.columns) {
1668
- t1 = result.columns.map(_temp);
1669
- $[2] = result.columns;
1670
- $[3] = t1;
1671
- } else {
1672
- t1 = $[3];
1673
- }
1674
- let t2;
1675
- if ($[4] !== t1) {
1676
- t2 = /* @__PURE__ */ jsxDEV(TableHeader, {
1677
- className: "sticky top-0 z-10 bg-muted",
1678
- children: /* @__PURE__ */ jsxDEV(TableRow, {
1679
- children: t1
1680
- }, void 0, false)
1681
- }, void 0, false);
1682
- $[4] = t1;
1683
- $[5] = t2;
1684
- } else {
1685
- t2 = $[5];
1686
- }
1687
- let t3;
1688
- if ($[6] !== result.columns || $[7] !== result.rows) {
1689
- let t42;
1690
- if ($[9] !== result.columns) {
1691
- t42 = (row, rowIndex) => /* @__PURE__ */ jsxDEV(TableRow, {
1692
- "data-testid": "sql-row",
1693
- children: result.columns.map((column_0) => /* @__PURE__ */ jsxDEV(TableCell, {
1694
- className: "max-w-md truncate font-mono text-xs",
1695
- children: /* @__PURE__ */ jsxDEV(CellValue, {
1696
- value: row[column_0]
1697
- }, void 0, false)
1698
- }, column_0, false))
1699
- }, rowIndex, false);
1700
- $[9] = result.columns;
1701
- $[10] = t42;
1702
- } else {
1703
- t42 = $[10];
1704
- }
1705
- t3 = result.rows.map(t42);
1706
- $[6] = result.columns;
1707
- $[7] = result.rows;
1708
- $[8] = t3;
1709
- } else {
1710
- t3 = $[8];
1711
- }
1712
- let t4;
1713
- if ($[11] !== t3) {
1714
- t4 = /* @__PURE__ */ jsxDEV(TableBody, {
1715
- children: t3
1716
- }, void 0, false);
1717
- $[11] = t3;
1718
- $[12] = t4;
1719
- } else {
1720
- t4 = $[12];
1721
- }
1722
- let t5;
1723
- if ($[13] !== t2 || $[14] !== t4) {
1724
- t5 = /* @__PURE__ */ jsxDEV(Table, {
1725
- "data-testid": "sql-rows",
1726
- children: [t2, t4]
1727
- }, void 0, true);
1728
- $[13] = t2;
1729
- $[14] = t4;
1730
- $[15] = t5;
1731
- } else {
1732
- t5 = $[15];
1733
- }
1734
- return t5;
1735
- };
1736
- const SqlEditorPanel = ({
1737
- initialShardKey
1738
- }) => {
1739
- const client = useLunora();
1740
- const t = useT();
1741
- const [queries, setQueries] = usePersistedList(STORAGE_KEY);
1742
- const [history, setHistory] = usePersistedList(HISTORY_KEY);
1743
- const [search, setSearch] = useState("");
1744
- const seedTab = () => makeTab(TEMPLATES[0]?.sql ?? "");
1745
- const {
1746
- activeId: activeTabId,
1747
- setActiveId: setActiveTabId,
1748
- setTabs,
1749
- tabs
1750
- } = usePersistedTabs(seedTab);
1751
- const [outputs, setOutputs] = useState({});
1752
- const [shardKey, setShardKey] = useState(initialShardKey ?? "");
1753
- const [running, setRunning] = useState(false);
1754
- const [tabMenu, setTabMenu] = useState(null);
1755
- const [pendingBulk, setPendingBulk] = useState(null);
1756
- const gutterRef = useRef(null);
1757
- const editorRef = useRef(null);
1758
- const privateListRef = useRef(null);
1759
- const listboxId = useId();
1760
- const {
1761
- probe,
1762
- schema
1763
- } = useSqlSchema(shardKey);
1764
- const activeTab = tabs.find((each) => each.id === activeTabId) ?? tabs[0] ?? makeTab();
1765
- const draft = activeTab.sql;
1766
- const {
1767
- activeId
1768
- } = activeTab;
1769
- const output = outputs[activeTab.id] ?? DEFAULT_TAB_OUTPUT;
1770
- const {
1771
- error,
1772
- result
1773
- } = output;
1774
- const tab = output.pane;
1775
- const patchActiveTab = (patch) => {
1776
- setTabs((current) => current.map((each_0) => each_0.id === activeTab.id ? {
1777
- ...each_0,
1778
- ...patch
1779
- } : each_0));
1780
- };
1781
- const setActiveOutput = (next) => {
1782
- setOutputs((current_0) => {
1783
- const previous = current_0[activeTab.id] ?? DEFAULT_TAB_OUTPUT;
1784
- return {
1785
- ...current_0,
1786
- [activeTab.id]: {
1787
- error: next.error,
1788
- pane: next.pane ?? previous.pane,
1789
- result: next.result
1790
- }
1791
- };
1792
- });
1793
- };
1794
- const setActivePane = (pane) => {
1795
- setOutputs((current_1) => {
1796
- const previous_0 = current_1[activeTab.id] ?? DEFAULT_TAB_OUTPUT;
1797
- return {
1798
- ...current_1,
1799
- [activeTab.id]: {
1800
- ...previous_0,
1801
- pane
1802
- }
1803
- };
1804
- });
1805
- };
1806
- const setDraft = (value) => {
1807
- patchActiveTab({
1808
- sql: value
1809
- });
1810
- if (activeId !== null) {
1811
- setQueries((current_2) => current_2.map((query) => query.id === activeId ? {
1812
- ...query,
1813
- sql: value
1814
- } : query));
1815
- }
1816
- };
1817
- const autocomplete = useSqlAutocomplete(schema, editorRef, setDraft);
1818
- const {
1819
- close: closeAutocomplete,
1820
- commit: commitAutocomplete,
1821
- move: moveAutocomplete,
1822
- refresh: refreshAutocomplete,
1823
- state: autocompleteState
1824
- } = autocomplete;
1825
- const onPickSuggestion = (index) => {
1826
- moveAutocomplete(index - (autocompleteState?.active ?? 0));
1827
- commitAutocomplete();
1828
- };
1829
- useEffect(() => {
1830
- const node = editorRef.current;
1831
- if (node !== null && node === document.activeElement) {
1832
- refreshAutocomplete(node.value, node.selectionStart);
1833
- }
1834
- }, [refreshAutocomplete, schema]);
1835
- const recordHistory = (sql) => {
1836
- setHistory((current_3) => {
1837
- if (current_3[0]?.sql === sql) {
1838
- return current_3;
1839
- }
1840
- const next_0 = [{
1841
- at: Date.now(),
1842
- sql
1843
- }, ...current_3.filter((entry) => entry.sql !== sql)];
1844
- return next_0.slice(0, HISTORY_LIMIT);
1845
- });
1846
- };
1847
- const run = async (mode) => {
1848
- if (draft.trim() === "") {
1849
- return;
1850
- }
1851
- setRunning(true);
1852
- const sql_0 = mode === "explain" ? `EXPLAIN QUERY PLAN ${draft}` : draft;
1853
- try {
1854
- const next_1 = await client.query(RUN_SQL, {
1855
- sql: sql_0
1856
- }, callOptions(shardKey));
1857
- setActiveOutput({
1858
- error: null,
1859
- pane: mode,
1860
- result: next_1
1861
- });
1862
- recordShard(shardKey);
1863
- recordHistory(sql_0);
1864
- } catch (error_) {
1865
- setActiveOutput({
1866
- error: errorMessage(error_),
1867
- pane: mode,
1868
- result: null
1869
- });
1870
- } finally {
1871
- setRunning(false);
1872
- }
1873
- };
1874
- const onRun = () => {
1875
- fireAndForget(run("results"));
1876
- };
1877
- const onDraftChange = (event) => {
1878
- const {
1879
- selectionStart,
1880
- value: value_0
1881
- } = event.target;
1882
- setDraft(value_0);
1883
- for (const table of referencedTables(value_0)) {
1884
- probe(table);
1885
- }
1886
- refreshAutocomplete(value_0, selectionStart);
1887
- };
1888
- const onEditorSelect = (event_0) => {
1889
- const node_0 = event_0.currentTarget;
1890
- refreshAutocomplete(node_0.value, node_0.selectionStart);
1891
- };
1892
- const onEditorKeyDown = (event_1) => {
1893
- if (autocompleteState !== null) {
1894
- if (event_1.key === "ArrowDown") {
1895
- event_1.preventDefault();
1896
- moveAutocomplete(1);
1897
- return;
1898
- }
1899
- if (event_1.key === "ArrowUp") {
1900
- event_1.preventDefault();
1901
- moveAutocomplete(-1);
1902
- return;
1903
- }
1904
- if (event_1.key === "Escape") {
1905
- event_1.preventDefault();
1906
- closeAutocomplete();
1907
- return;
1908
- }
1909
- if ((event_1.key === "Enter" || event_1.key === "Tab") && !event_1.metaKey && !event_1.ctrlKey && commitAutocomplete()) {
1910
- event_1.preventDefault();
1911
- return;
1912
- }
1913
- }
1914
- if ((event_1.metaKey || event_1.ctrlKey) && event_1.key === "Enter") {
1915
- event_1.preventDefault();
1916
- fireAndForget(run(tab));
1917
- }
1918
- };
1919
- const onEditorBlur = () => {
1920
- requestAnimationFrame(() => {
1921
- closeAutocomplete();
1922
- });
1923
- };
1924
- const onEditorScroll = (event_2) => {
1925
- if (gutterRef.current !== null) {
1926
- gutterRef.current.scrollTop = event_2.currentTarget.scrollTop;
1927
- }
1928
- };
1929
- const loadIntoActiveTab = (sql_1, savedId) => {
1930
- setTabs((current_4) => current_4.map((each_1) => each_1.id === activeTab.id ? {
1931
- ...each_1,
1932
- activeId: savedId,
1933
- sql: sql_1
1934
- } : each_1));
1935
- setActiveOutput({
1936
- error: null,
1937
- result: null
1938
- });
1939
- };
1940
- const newQuery = () => {
1941
- const query_0 = {
1942
- id: newId("q"),
1943
- name: t("Untitled query"),
1944
- sql: ""
1945
- };
1946
- setQueries((current_5) => [query_0, ...current_5]);
1947
- loadIntoActiveTab("", query_0.id);
1948
- };
1949
- const selectQuery = (id) => {
1950
- const found = queries.find((query_1) => query_1.id === id);
1951
- if (found !== void 0) {
1952
- loadIntoActiveTab(found.sql, id);
1953
- privateListRef.current?.querySelector(`[data-testid="sql-query-${id}"]`)?.scrollIntoView({
1954
- block: "nearest"
1955
- });
1956
- }
1957
- };
1958
- const deleteQuery = (id_0) => {
1959
- setQueries((current_6) => current_6.filter((query_2) => query_2.id !== id_0));
1960
- setTabs((current_7) => current_7.map((each_2) => each_2.activeId === id_0 ? {
1961
- ...each_2,
1962
- activeId: null
1963
- } : each_2));
1964
- };
1965
- const loadTemplate = (event_3) => {
1966
- loadIntoActiveTab(event_3.currentTarget.dataset.sql ?? "", null);
1967
- };
1968
- const loadFromHistory = (event_4) => {
1969
- loadIntoActiveTab(event_4.currentTarget.dataset.sql ?? "", null);
1970
- };
1971
- const clearHistory = () => {
1972
- setHistory([]);
1973
- };
1974
- const formatDraft = () => {
1975
- setDraft(formatSql(draft));
1976
- };
1977
- const addEditorTab = () => {
1978
- if (tabs.length >= MAX_TABS) {
1979
- return;
1980
- }
1981
- const fresh = makeTab();
1982
- setTabs((current_8) => addTab(current_8, fresh));
1983
- setActiveTabId(fresh.id);
1984
- };
1985
- const commitTabs = (next_2) => {
1986
- setTabMenu(null);
1987
- setPendingBulk(null);
1988
- setTabs(next_2.tabs);
1989
- setActiveTabId(next_2.activeId);
1990
- const openIds = new Set(next_2.tabs.map((each_3) => each_3.id));
1991
- setOutputs((current_9) => Object.fromEntries(Object.entries(current_9).filter(([key]) => openIds.has(key))));
1992
- };
1993
- const closeEditorTab = (id_1) => {
1994
- commitTabs(closeTab(tabs, id_1, makeTab));
1995
- };
1996
- const applyBulk = (op, id_2) => {
1997
- if (op === "others") {
1998
- commitTabs(closeOtherTabs(tabs, id_2));
1999
- } else if (op === "right") {
2000
- commitTabs(closeTabsToRight(tabs, id_2, activeTabId));
2001
- } else {
2002
- commitTabs(closeAllTabs(makeTab));
2003
- }
2004
- };
2005
- const requestBulk = (op_0) => {
2006
- if (tabMenu === null) {
2007
- return;
2008
- }
2009
- if (tabsClosedBy(op_0, tabs, tabMenu.id).some((each_4) => isDirty(each_4))) {
2010
- setPendingBulk(op_0);
2011
- } else {
2012
- applyBulk(op_0, tabMenu.id);
2013
- }
2014
- };
2015
- const openTabMenu = (id_3, event_5) => {
2016
- event_5.preventDefault();
2017
- setPendingBulk(null);
2018
- setTabMenu({
2019
- id: id_3,
2020
- x: event_5.clientX,
2021
- y: event_5.clientY
2022
- });
2023
- };
2024
- const closeTabMenu = () => {
2025
- setTabMenu(null);
2026
- setPendingBulk(null);
2027
- };
2028
- const onBackdropContextMenu = (event_6) => {
2029
- event_6.preventDefault();
2030
- setTabMenu(null);
2031
- setPendingBulk(null);
2032
- };
2033
- const onCloseOthers = () => {
2034
- requestBulk("others");
2035
- };
2036
- const onCloseToRight = () => {
2037
- requestBulk("right");
2038
- };
2039
- const onCloseAll = () => {
2040
- requestBulk("all");
2041
- };
2042
- const confirmBulk = () => {
2043
- if (tabMenu !== null && pendingBulk !== null) {
2044
- applyBulk(pendingBulk, tabMenu.id);
2045
- }
2046
- setPendingBulk(null);
2047
- };
2048
- const cancelBulk = () => {
2049
- setPendingBulk(null);
2050
- };
2051
- const tabMenuStyle = tabMenu === null ? void 0 : {
2052
- left: tabMenu.x,
2053
- top: tabMenu.y
2054
- };
2055
- const selectTab = (id_4) => {
2056
- closeAutocomplete();
2057
- setActiveTabId(id_4);
2058
- };
2059
- const renameTab = (id_5, name) => {
2060
- setTabs((current_10) => current_10.map((each_5) => each_5.id === id_5 ? {
2061
- ...each_5,
2062
- name
2063
- } : each_5));
2064
- };
2065
- const showResults = () => {
2066
- setActivePane("results");
2067
- };
2068
- const showExplain = () => {
2069
- fireAndForget(run("explain"));
2070
- };
2071
- const showChart = () => {
2072
- setActivePane("chart");
2073
- };
2074
- const lineCount = draft.split("\n").length;
2075
- const onSearchChange = (event_7) => {
2076
- setSearch(event_7.target.value);
2077
- };
2078
- const tabClass = (selected) => `border-b-2 px-3 py-2 text-sm outline-none transition-colors ${selected ? "border-foreground font-medium text-foreground" : "border-transparent text-muted-foreground hover:text-foreground"}`;
2079
- return /* @__PURE__ */ jsxDEV("div", {
2080
- className: "flex h-full min-w-0",
2081
- "data-testid": "lunora-sql-editor",
2082
- children: [/* @__PURE__ */ jsxDEV(SqlQuerySidebar, {
2083
- activeId,
2084
- history,
2085
- listRef: privateListRef,
2086
- onClearHistory: clearHistory,
2087
- onDelete: deleteQuery,
2088
- onLoadHistory: loadFromHistory,
2089
- onLoadTemplate: loadTemplate,
2090
- onNew: newQuery,
2091
- onSearchChange,
2092
- onSelect: selectQuery,
2093
- queries,
2094
- search
2095
- }, void 0, false), /* @__PURE__ */ jsxDEV("div", {
2096
- className: "flex min-w-0 flex-1 flex-col",
2097
- children: [/* @__PURE__ */ jsxDEV("div", {
2098
- className: "flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30",
2099
- "data-testid": "sql-tab-strip",
2100
- role: "tablist",
2101
- children: [tabs.map((each_6) => /* @__PURE__ */ jsxDEV(TabButton, {
2102
- active: each_6.id === activeTab.id,
2103
- canClose: tabs.length > 1,
2104
- onClose: closeEditorTab,
2105
- onMenu: openTabMenu,
2106
- onRename: renameTab,
2107
- onSelect: selectTab,
2108
- tab: each_6
2109
- }, each_6.id, false)), /* @__PURE__ */ jsxDEV("button", {
2110
- "aria-label": t("New tab"),
2111
- 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",
2112
- "data-testid": "sql-tab-add",
2113
- disabled: tabs.length >= MAX_TABS,
2114
- onClick: addEditorTab,
2115
- title: t("New tab"),
2116
- type: "button",
2117
- children: /* @__PURE__ */ jsxDEV("svg", {
2118
- "aria-hidden": "true",
2119
- className: "size-4",
2120
- fill: "none",
2121
- stroke: "currentColor",
2122
- strokeLinecap: "round",
2123
- strokeLinejoin: "round",
2124
- strokeWidth: 1.7,
2125
- viewBox: "0 0 24 24",
2126
- children: /* @__PURE__ */ jsxDEV("path", {
2127
- d: "M12 5v14M5 12h14"
2128
- }, void 0, false)
2129
- }, void 0, false)
2130
- }, void 0, false)]
2131
- }, void 0, true), tabMenu !== null && /* @__PURE__ */ jsxDEV(Fragment, {
2132
- children: [/* @__PURE__ */ jsxDEV("div", {
2133
- className: "fixed inset-0 z-40",
2134
- "data-testid": "sql-tab-menu-backdrop",
2135
- onClick: closeTabMenu,
2136
- onContextMenu: onBackdropContextMenu,
2137
- role: "presentation"
2138
- }, void 0, false), /* @__PURE__ */ jsxDEV("div", {
2139
- className: "fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md",
2140
- "data-testid": "sql-tab-menu",
2141
- role: "menu",
2142
- style: tabMenuStyle,
2143
- children: pendingBulk === null ? /* @__PURE__ */ jsxDEV(Fragment, {
2144
- children: [/* @__PURE__ */ jsxDEV("button", {
2145
- 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",
2146
- "data-testid": "sql-tab-menu-close-others",
2147
- disabled: tabs.length <= 1,
2148
- onClick: onCloseOthers,
2149
- role: "menuitem",
2150
- type: "button",
2151
- children: t("Close other tabs")
2152
- }, void 0, false), /* @__PURE__ */ jsxDEV("button", {
2153
- 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",
2154
- "data-testid": "sql-tab-menu-close-right",
2155
- disabled: tabs.findIndex((each_7) => each_7.id === tabMenu.id) >= tabs.length - 1,
2156
- onClick: onCloseToRight,
2157
- role: "menuitem",
2158
- type: "button",
2159
- children: t("Close tabs to the right")
2160
- }, void 0, false), /* @__PURE__ */ jsxDEV("button", {
2161
- className: "flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent",
2162
- "data-testid": "sql-tab-menu-close-all",
2163
- onClick: onCloseAll,
2164
- role: "menuitem",
2165
- type: "button",
2166
- children: t("Close all tabs")
2167
- }, void 0, false)]
2168
- }, void 0, true) : (
2169
- // Discard confirm: the chosen bulk close would drop a tab with unsaved work.
2170
- /* @__PURE__ */ jsxDEV("div", {
2171
- className: "px-3 py-1.5",
2172
- "data-testid": "sql-tab-menu-confirm",
2173
- children: [/* @__PURE__ */ jsxDEV("p", {
2174
- className: "pb-1.5 text-xs text-muted-foreground",
2175
- children: t("Discard unsaved tabs?")
2176
- }, void 0, false), /* @__PURE__ */ jsxDEV("div", {
2177
- className: "flex items-center gap-1.5",
2178
- children: [/* @__PURE__ */ jsxDEV("button", {
2179
- className: "rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10",
2180
- "data-testid": "sql-tab-menu-confirm-discard",
2181
- onClick: confirmBulk,
2182
- type: "button",
2183
- children: t("Discard")
2184
- }, void 0, false), /* @__PURE__ */ jsxDEV("button", {
2185
- className: "rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent",
2186
- "data-testid": "sql-tab-menu-confirm-cancel",
2187
- onClick: cancelBulk,
2188
- type: "button",
2189
- children: t("Cancel")
2190
- }, void 0, false)]
2191
- }, void 0, true)]
2192
- }, void 0, true)
2193
- )
2194
- }, void 0, false)]
2195
- }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
2196
- className: "flex min-h-0 flex-1",
2197
- children: [/* @__PURE__ */ jsxDEV("div", {
2198
- "aria-hidden": "true",
2199
- className: "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",
2200
- ref: gutterRef,
2201
- style: GUTTER_STYLE,
2202
- children: Array.from({
2203
- length: lineCount
2204
- }, (_, index_0) => /* @__PURE__ */ jsxDEV("div", {
2205
- children: index_0 + 1
2206
- }, index_0, false))
2207
- }, void 0, false), /* @__PURE__ */ jsxDEV("div", {
2208
- className: "relative min-w-0 flex-1",
2209
- children: [/* @__PURE__ */ jsxDEV("textarea", {
2210
- "aria-activedescendant": autocompleteState === null ? void 0 : `${listboxId}-opt-${autocompleteState.active.toString()}`,
2211
- "aria-autocomplete": "list",
2212
- "aria-controls": autocompleteState === null ? void 0 : listboxId,
2213
- "aria-expanded": autocompleteState !== null,
2214
- "aria-label": t("SQL query"),
2215
- className: "size-full resize-none bg-background p-3 font-mono text-xs leading-5 outline-none",
2216
- "data-testid": "sql-input",
2217
- onBlur: onEditorBlur,
2218
- onChange: onDraftChange,
2219
- onKeyDown: onEditorKeyDown,
2220
- onScroll: onEditorScroll,
2221
- onSelect: onEditorSelect,
2222
- placeholder: "SELECT * FROM …",
2223
- ref: editorRef,
2224
- role: "combobox",
2225
- spellCheck: false,
2226
- value: draft
2227
- }, void 0, false), /* @__PURE__ */ jsxDEV(AutocompletePopover, {
2228
- listboxId,
2229
- onPick: onPickSuggestion,
2230
- state: autocompleteState
2231
- }, void 0, false)]
2232
- }, void 0, true)]
2233
- }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
2234
- className: "flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border",
2235
- children: [/* @__PURE__ */ jsxDEV("div", {
2236
- className: "flex shrink-0 items-center gap-2 border-b border-border pe-2",
2237
- children: [/* @__PURE__ */ jsxDEV("button", {
2238
- className: tabClass(tab === "results"),
2239
- "data-testid": "sql-tab-results",
2240
- onClick: showResults,
2241
- type: "button",
2242
- children: t("Results")
2243
- }, void 0, false), /* @__PURE__ */ jsxDEV("button", {
2244
- className: tabClass(tab === "chart"),
2245
- "data-testid": "sql-tab-chart",
2246
- onClick: showChart,
2247
- type: "button",
2248
- children: t("Chart")
2249
- }, void 0, false), /* @__PURE__ */ jsxDEV("button", {
2250
- className: tabClass(tab === "explain"),
2251
- "data-testid": "sql-tab-explain",
2252
- onClick: showExplain,
2253
- type: "button",
2254
- children: t("Explain")
2255
- }, void 0, false), /* @__PURE__ */ jsxDEV("div", {
2256
- className: "ms-auto flex items-center gap-2",
2257
- children: [result !== null && result.columns.length > 0 && /* @__PURE__ */ jsxDEV(ExportMenu, {
2258
- columns: result.columns,
2259
- name: "query-result",
2260
- rows: result.rows
2261
- }, void 0, false), /* @__PURE__ */ jsxDEV("button", {
2262
- 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",
2263
- "data-testid": "sql-format",
2264
- disabled: running,
2265
- onClick: formatDraft,
2266
- type: "button",
2267
- children: t("Format")
2268
- }, void 0, false), /* @__PURE__ */ jsxDEV(ShardInput, {
2269
- onChange: setShardKey,
2270
- testId: "sql-shard-input",
2271
- value: shardKey
2272
- }, void 0, false), /* @__PURE__ */ jsxDEV("button", {
2273
- 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",
2274
- "data-testid": "sql-run",
2275
- disabled: running,
2276
- onClick: onRun,
2277
- type: "button",
2278
- children: [running ? t("Running…") : t("Run"), /* @__PURE__ */ jsxDEV("kbd", {
2279
- className: "rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",
2280
- children: "⌘↵"
2281
- }, void 0, false)]
2282
- }, void 0, true)]
2283
- }, void 0, true)]
2284
- }, void 0, true), /* @__PURE__ */ jsxDEV("div", {
2285
- className: "min-h-0 flex-1 overflow-auto",
2286
- children: [error !== null && /* @__PURE__ */ jsxDEV(Alert, {
2287
- className: "m-3 font-mono text-xs",
2288
- testId: "sql-error",
2289
- variant: "destructive",
2290
- children: error
2291
- }, void 0, false), error === null && result === null && /* @__PURE__ */ jsxDEV("p", {
2292
- className: "p-4 text-sm text-muted-foreground",
2293
- "data-testid": "sql-empty",
2294
- children: t("Click Run to execute your query.")
2295
- }, void 0, false), error === null && result !== null && /* @__PURE__ */ jsxDEV("div", {
2296
- "data-testid": "sql-result",
2297
- children: [tab === "chart" ? /* @__PURE__ */ jsxDEV(SqlResultChart, {
2298
- result
2299
- }, void 0, false) : /* @__PURE__ */ jsxDEV(SqlResultTable, {
2300
- result
2301
- }, void 0, false), /* @__PURE__ */ jsxDEV("p", {
2302
- className: "border-t border-border px-3 py-1.5 text-xs text-muted-foreground",
2303
- "data-testid": "sql-count",
2304
- children: result.truncated ? t("Showing the first {max} of {count} rows.", {
2305
- count: result.rowCount,
2306
- max: result.rows.length
2307
- }) : t("{count} rows", {
2308
- count: result.rowCount
2309
- })
2310
- }, void 0, false)]
2311
- }, void 0, true)]
2312
- }, void 0, true)]
2313
- }, void 0, true)]
2314
- }, void 0, true)]
2315
- }, void 0, true);
2316
- };
2317
- function _temp(column) {
2318
- return /* @__PURE__ */ jsxDEV(TableHead, {
2319
- children: column
2320
- }, column, false);
2321
- }
2322
-
2323
- export { SqlEditorPanel };