@lunora/studio 1.0.0-alpha.30 → 1.0.0-alpha.301

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