@lunora/studio 1.0.0-alpha.23 → 1.0.0-alpha.230

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 (339) 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 +976 -803
  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 +8 -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/analytics-panel.mjs +1 -0
  31. package/dist/packem_chunks/auth-audit-panel.mjs +1 -0
  32. package/dist/packem_chunks/auth-config-panel.mjs +1 -0
  33. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -0
  34. package/dist/packem_chunks/containers-panel.mjs +1 -0
  35. package/dist/packem_chunks/dashboards-panel.mjs +1 -0
  36. package/dist/packem_chunks/evals-panel.mjs +1 -0
  37. package/dist/packem_chunks/fanout-panel.mjs +1 -0
  38. package/dist/packem_chunks/flags-panel.mjs +1 -0
  39. package/dist/packem_chunks/issues-panel.mjs +1 -0
  40. package/dist/packem_chunks/kv-browser.mjs +1 -0
  41. package/dist/packem_chunks/log-drains-panel.mjs +4 -0
  42. package/dist/packem_chunks/migrations-route.mjs +1 -0
  43. package/dist/packem_chunks/organizations-panel.mjs +1 -0
  44. package/dist/packem_chunks/payments-panel.mjs +1 -0
  45. package/dist/packem_chunks/permissions-panel.mjs +1 -0
  46. package/dist/packem_chunks/queues-panel.mjs +1 -0
  47. package/dist/packem_chunks/reactors-panel.mjs +1 -0
  48. package/dist/packem_chunks/rls-panel.mjs +1 -0
  49. package/dist/packem_chunks/schedule-panel.mjs +1 -0
  50. package/dist/packem_chunks/sparkline.mjs +1 -0
  51. package/dist/packem_chunks/storage-rules-panel.mjs +1 -0
  52. package/dist/packem_chunks/subscriptions-panel.mjs +1 -0
  53. package/dist/packem_chunks/sync-client-panel.mjs +1 -0
  54. package/dist/packem_chunks/traces-panel.mjs +1 -0
  55. package/dist/packem_chunks/users-panel.mjs +1 -0
  56. package/dist/packem_chunks/vector-browser.mjs +1 -0
  57. package/dist/packem_chunks/workflows-panel.mjs +1 -0
  58. package/dist/packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs +1 -0
  59. package/dist/packem_shared/ApiDocsPanel-fhDlZGE4.mjs +2 -0
  60. package/dist/packem_shared/ApiReferencePanel-CHoHM5ME.mjs +1 -0
  61. package/dist/packem_shared/CommandPalette-D9ZY-qQd.mjs +1 -0
  62. package/dist/packem_shared/ConfirmButton-DU4p72Er.mjs +1 -0
  63. package/dist/packem_shared/ConnectionBadge-B8Hj5DaE.mjs +1 -0
  64. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-DuULO4XM.mjs +1 -0
  65. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-D5YMT0gM.mjs +1 -0
  66. package/dist/packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs +1 -0
  67. package/dist/packem_shared/DataBrowser-YscAF4OI.mjs +4 -0
  68. package/dist/packem_shared/DataFilters-CYZFt2EK.mjs +1 -0
  69. package/dist/packem_shared/ErrorBoundary-BWNF98VF.mjs +1 -0
  70. package/dist/packem_shared/GlobalDataBrowser-DhObcZDY.mjs +1 -0
  71. package/dist/packem_shared/HomePanel-fJZRA0b0.mjs +1 -0
  72. package/dist/packem_shared/MigrationsPanel-QjQ4Gp9s.mjs +1 -0
  73. package/dist/packem_shared/OpenRpcReferencePanel-C8ctFJVm.mjs +1 -0
  74. package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.mjs +1 -0
  75. package/dist/packem_shared/ScheduledJobs-nPx7NmOE.mjs +1 -0
  76. package/dist/packem_shared/ShardInput-C6mjgAh4.mjs +1 -0
  77. package/dist/packem_shared/Studio-DQq17PO6.mjs +1 -0
  78. package/dist/packem_shared/StudioApp-DikgPBVJ.mjs +1 -0
  79. package/dist/packem_shared/StudioI18nProvider-fVsCSs5L.mjs +1 -0
  80. package/dist/packem_shared/advisor-view-BzzJg9D_.mjs +1 -0
  81. package/dist/packem_shared/aggregateMetrics-5zEJC6Ju.mjs +1 -0
  82. package/dist/packem_shared/alert-PB5W11MM.mjs +1 -0
  83. package/dist/packem_shared/app.d-BbmO2HA2.d.mts +301 -0
  84. package/dist/packem_shared/app.d-BbmO2HA2.d.ts +301 -0
  85. package/dist/packem_shared/auth-pager-DiDnXsfe.mjs +1 -0
  86. package/dist/packem_shared/badge-r_5B4LHP.mjs +1 -0
  87. package/dist/packem_shared/bar-chart-BCsEIQoQ.mjs +6 -0
  88. package/dist/packem_shared/browser-storage-BH1MxLZs.mjs +1 -0
  89. package/dist/packem_shared/button-q0UYSmrn.mjs +1 -0
  90. package/dist/packem_shared/card--2hKx4L2.mjs +1 -0
  91. package/dist/packem_shared/cf-links-CBJ5SywP.mjs +1 -0
  92. package/dist/packem_shared/checkbox-CnS9cyCz.mjs +1 -0
  93. package/dist/packem_shared/control-button-BOZ5K-FC.mjs +1 -0
  94. package/dist/packem_shared/data-grid-DIiNmDR9.mjs +1 -0
  95. package/dist/packem_shared/data-view-params-DhYmAkcj.mjs +1 -0
  96. package/dist/packem_shared/dropdown-menu-jLZenfWH.mjs +2 -0
  97. package/dist/packem_shared/empty-state-D7jEML_T.mjs +1 -0
  98. package/dist/packem_shared/error-alert-DueSEkt-.mjs +1 -0
  99. package/dist/packem_shared/grid-features-OVIMIQan.mjs +6 -0
  100. package/dist/packem_shared/grid-pagination-DgzyzfBh.mjs +1 -0
  101. package/dist/packem_shared/home-panel-DBSHjxil.mjs +3 -0
  102. package/dist/packem_shared/input-CXhxesPC.mjs +1 -0
  103. package/dist/packem_shared/internal-Df43vQI0.mjs +2 -0
  104. package/dist/packem_shared/label-DKFzyHq6.mjs +1 -0
  105. package/dist/packem_shared/live-status-BuJdUZFU.mjs +1 -0
  106. package/dist/packem_shared/log-fields-SBxKyBug.mjs +1 -0
  107. package/dist/packem_shared/log-line-BHWXobrl.mjs +1 -0
  108. package/dist/packem_shared/modal-shell-CDztwLnv.mjs +1 -0
  109. package/dist/packem_shared/operation-console-provider-DoloEvon.mjs +1 -0
  110. package/dist/packem_shared/recording-client-CyFiAE2l.mjs +1 -0
  111. package/dist/packem_shared/reference-view-DSeKRrUU.mjs +13 -0
  112. package/dist/packem_shared/schema-diagram-CQ4vn0CN.mjs +2 -0
  113. package/dist/packem_shared/scroll-area-CXCQH7VT.mjs +2 -0
  114. package/dist/packem_shared/select-DPyS18Vy.mjs +2 -0
  115. package/dist/packem_shared/shard-history-CaO3C4KQ.mjs +1 -0
  116. package/dist/packem_shared/shortcuts-B9gDaXmw.mjs +1 -0
  117. package/dist/packem_shared/skeleton-DX1gfixl.mjs +1 -0
  118. package/dist/packem_shared/sparkline-B_sPPO_8.mjs +1 -0
  119. package/dist/packem_shared/sql-result-table-DyK762_A.mjs +1 -0
  120. package/dist/packem_shared/stat-card-D0Fe04cX.mjs +1 -0
  121. package/dist/packem_shared/storage-tier-C2mKwYRj.mjs +1 -0
  122. package/dist/packem_shared/studio-ajWxPNfI.mjs +2 -0
  123. package/dist/packem_shared/table-D0SBiDu-.mjs +2 -0
  124. package/dist/packem_shared/table-list-sidebar-DkPO_Qtz.mjs +1 -0
  125. package/dist/packem_shared/textarea--40GKAyz.mjs +1 -0
  126. package/dist/packem_shared/trace-handoff-BV3EWqy_.mjs +1 -0
  127. package/dist/packem_shared/use-admin-query-tlBof8Yg.mjs +1 -0
  128. package/dist/packem_shared/use-async-submit-CZqCMTJ_.mjs +1 -0
  129. package/dist/packem_shared/use-auth-config-B9hH2tQa.mjs +1 -0
  130. package/dist/packem_shared/use-mirrored-ref-CVDf2z1M.mjs +1 -0
  131. package/dist/packem_shared/use-open-trace-DMVhpnyG.mjs +1 -0
  132. package/dist/packem_shared/use-shard-key-BsP3o5wT.mjs +1 -0
  133. package/dist/packem_shared/use-sql-assistant-pjfGp-Ol.mjs +1 -0
  134. package/dist/packem_shared/useDebounced-DVeQ5-oW.mjs +1 -0
  135. package/dist/packem_shared/utils-bhneXptQ.mjs +1 -0
  136. package/dist/packem_shared/virtual-rect-D_j7aLxX.mjs +1 -0
  137. package/dist/packem_shared/wire-codec-Bk4XZGE4.mjs +1 -0
  138. package/dist/standalone/chunk-225VJ77I.js +1 -0
  139. package/dist/standalone/chunk-23SFT2CI.js +1 -0
  140. package/dist/standalone/chunk-2QSGCPIS.js +1 -0
  141. package/dist/standalone/chunk-2URQKGWU.js +1 -0
  142. package/dist/standalone/chunk-2V35H4JV.js +3 -0
  143. package/dist/standalone/chunk-35DM4JJG.js +1 -0
  144. package/dist/standalone/chunk-3EQVJ5SQ.js +1 -0
  145. package/dist/standalone/chunk-3EYROC6C.js +4 -0
  146. package/dist/standalone/chunk-3FBLWUXD.js +1 -0
  147. package/dist/standalone/chunk-3PWB52UO.js +1 -0
  148. package/dist/standalone/chunk-3Q2P62UR.js +1 -0
  149. package/dist/standalone/chunk-4GTO7FL5.js +1 -0
  150. package/dist/standalone/chunk-4JLGLPWV.js +1 -0
  151. package/dist/standalone/chunk-4L4WTGN5.js +1 -0
  152. package/dist/standalone/chunk-4PBNO4Q3.js +1 -0
  153. package/dist/standalone/chunk-4ZEL6BYL.js +1 -0
  154. package/dist/standalone/chunk-53KDWFYV.js +1 -0
  155. package/dist/standalone/chunk-55754F6H.js +1 -0
  156. package/dist/standalone/chunk-56GQRRBV.js +1 -0
  157. package/dist/standalone/chunk-57L2DM4H.js +1 -0
  158. package/dist/standalone/chunk-57XP5MZR.js +1 -0
  159. package/dist/standalone/chunk-5JDWLCSH.js +1 -0
  160. package/dist/standalone/chunk-5WJXVZMZ.js +1 -0
  161. package/dist/standalone/chunk-66UGPQVC.js +1 -0
  162. package/dist/standalone/chunk-6D6Z2KXU.js +1 -0
  163. package/dist/standalone/chunk-6DAD3RFX.js +1 -0
  164. package/dist/standalone/chunk-7BJGFDVG.js +1 -0
  165. package/dist/standalone/chunk-A3G6E5U2.js +1 -0
  166. package/dist/standalone/chunk-AANB526D.js +6 -0
  167. package/dist/standalone/chunk-AAVLPU5Q.js +1 -0
  168. package/dist/standalone/chunk-AWHXPIXU.js +1 -0
  169. package/dist/standalone/chunk-AZ4CIFUE.js +1 -0
  170. package/dist/standalone/chunk-B2HYHTIX.js +1 -0
  171. package/dist/standalone/chunk-BSNHEJP3.js +1 -0
  172. package/dist/standalone/chunk-C2WGWVPO.js +1 -0
  173. package/dist/standalone/chunk-C5CNJIVE.js +1 -0
  174. package/dist/standalone/chunk-CBTT4FMH.js +1 -0
  175. package/dist/standalone/chunk-CMA4PTV7.js +1 -0
  176. package/dist/standalone/chunk-CSUROWL2.js +1 -0
  177. package/dist/standalone/chunk-D3GIXGIJ.js +1 -0
  178. package/dist/standalone/chunk-DAFY42M2.js +1 -0
  179. package/dist/standalone/chunk-DCDNW7DR.js +3 -0
  180. package/dist/standalone/chunk-DTTTM3CW.js +4 -0
  181. package/dist/standalone/chunk-EA2JKR5D.js +1 -0
  182. package/dist/standalone/chunk-EIISOYGA.js +1 -0
  183. package/dist/standalone/chunk-EJSI4PMU.js +1 -0
  184. package/dist/standalone/chunk-ELWVLXCM.js +1 -0
  185. package/dist/standalone/chunk-ERHFRNCL.js +1 -0
  186. package/dist/standalone/chunk-EVTM6Q43.js +1 -0
  187. package/dist/standalone/chunk-EY6WHXDO.js +1 -0
  188. package/dist/standalone/chunk-F2RMCBTB.js +1 -0
  189. package/dist/standalone/chunk-F7UC63UN.js +1 -0
  190. package/dist/standalone/chunk-FEWMAPNI.js +1 -0
  191. package/dist/standalone/chunk-FKVZRPV5.js +1 -0
  192. package/dist/standalone/chunk-FSRSK4LY.js +1 -0
  193. package/dist/standalone/chunk-FZ5SSAZU.js +8 -0
  194. package/dist/standalone/chunk-GCHHYR6O.js +1 -0
  195. package/dist/standalone/chunk-GMS77BZD.js +1 -0
  196. package/dist/standalone/chunk-GOSWKLMM.js +1 -0
  197. package/dist/standalone/chunk-HEAQVSNS.js +1 -0
  198. package/dist/standalone/chunk-HGP7GH2M.js +1 -0
  199. package/dist/standalone/chunk-ICOTONE3.js +1 -0
  200. package/dist/standalone/chunk-IGPZHAPG.js +1 -0
  201. package/dist/standalone/chunk-IHMGCHAA.js +1 -0
  202. package/dist/standalone/chunk-IMOHEGMV.js +1 -0
  203. package/dist/standalone/chunk-IS6LVJ6L.js +1 -0
  204. package/dist/standalone/chunk-JTAVWGVE.js +1 -0
  205. package/dist/standalone/chunk-K7AJEMKE.js +1 -0
  206. package/dist/standalone/chunk-KCEEZ6OU.js +1 -0
  207. package/dist/standalone/chunk-KDR232YC.js +1 -0
  208. package/dist/standalone/chunk-KNCDRWAO.js +1 -0
  209. package/dist/standalone/chunk-L5XAH44R.js +1 -0
  210. package/dist/standalone/chunk-LCRAEP3B.js +1 -0
  211. package/dist/standalone/chunk-LCXKALTS.js +15 -0
  212. package/dist/standalone/chunk-MRAMNVDG.js +1 -0
  213. package/dist/standalone/chunk-MU3P2FI7.js +1 -0
  214. package/dist/standalone/chunk-MXLAOCAN.js +1 -0
  215. package/dist/standalone/chunk-MZ3WS2FG.js +1 -0
  216. package/dist/standalone/chunk-N2WM74AE.js +1 -0
  217. package/dist/standalone/chunk-N3CF7TGX.js +5 -0
  218. package/dist/standalone/chunk-NCFRIHLB.js +1 -0
  219. package/dist/standalone/chunk-NFS7FTAR.js +1 -0
  220. package/dist/standalone/chunk-NOCFO4AL.js +1 -0
  221. package/dist/standalone/chunk-O6AGWZVF.js +1 -0
  222. package/dist/standalone/chunk-OGUKYRFM.js +1 -0
  223. package/dist/standalone/chunk-OKG3HWSJ.js +1 -0
  224. package/dist/standalone/chunk-ONIGWNXT.js +1 -0
  225. package/dist/standalone/chunk-PLHA3OWK.js +3 -0
  226. package/dist/standalone/chunk-PPKKM57M.js +1 -0
  227. package/dist/standalone/chunk-PTZD7RUZ.js +19 -0
  228. package/dist/standalone/chunk-Q4CAKBWN.js +1 -0
  229. package/dist/standalone/chunk-QKEJLVC5.js +1 -0
  230. package/dist/standalone/chunk-QKZ2JCH3.js +1 -0
  231. package/dist/standalone/chunk-QNXB7FVQ.js +1 -0
  232. package/dist/standalone/chunk-R4WRHIAN.js +9 -0
  233. package/dist/standalone/chunk-RBWXVBJ2.js +1 -0
  234. package/dist/standalone/chunk-RFNGDE33.js +1 -0
  235. package/dist/standalone/chunk-RPQL45FL.js +1 -0
  236. package/dist/standalone/chunk-RRYVQMU5.js +1 -0
  237. package/dist/standalone/chunk-S2MXXVBU.js +8 -0
  238. package/dist/standalone/chunk-S3CRZLGS.js +1 -0
  239. package/dist/standalone/chunk-SI7I47IC.js +1 -0
  240. package/dist/standalone/chunk-SSPIY6CR.js +1 -0
  241. package/dist/standalone/chunk-SXDNBAX2.js +1 -0
  242. package/dist/standalone/chunk-T6GZ5GL5.js +1 -0
  243. package/dist/standalone/chunk-T7QKUVSO.js +1 -0
  244. package/dist/standalone/chunk-TKKZSWPP.js +1 -0
  245. package/dist/standalone/chunk-TVCRAKIF.js +1 -0
  246. package/dist/standalone/chunk-U7KL6DNA.js +1 -0
  247. package/dist/standalone/chunk-ULIQFBZU.js +1 -0
  248. package/dist/standalone/chunk-USB6LW3F.js +1 -0
  249. package/dist/standalone/chunk-UXXDN6Z3.js +1 -0
  250. package/dist/standalone/chunk-UYEZR3BI.js +1 -0
  251. package/dist/standalone/chunk-V3CZW3JB.js +1 -0
  252. package/dist/standalone/chunk-V3VJAA4D.js +1 -0
  253. package/dist/standalone/chunk-VEDBBYTH.js +1 -0
  254. package/dist/standalone/chunk-WUWBZPUK.js +1 -0
  255. package/dist/standalone/chunk-WYI7FXBH.js +14 -0
  256. package/dist/standalone/chunk-X32ZF36V.js +1 -0
  257. package/dist/standalone/chunk-XKMLLTFP.js +59 -0
  258. package/dist/standalone/chunk-XZMOZFE6.js +1 -0
  259. package/dist/standalone/chunk-Y6CXU7T4.js +1 -0
  260. package/dist/standalone/chunk-YKW7BL5H.js +2 -0
  261. package/dist/standalone/chunk-YKXDMIHQ.js +1 -0
  262. package/dist/standalone/chunk-YOB2X3FZ.js +1 -0
  263. package/dist/standalone/chunk-YPRQLCKF.js +1 -0
  264. package/dist/standalone/chunk-Z5O2NQAV.js +1 -0
  265. package/dist/standalone/studio.js +9 -378
  266. package/dist/styles.css +2 -2
  267. package/package.json +23 -20
  268. package/dist/index.js +0 -41
  269. package/dist/mount.js +0 -26
  270. package/dist/packem_shared/ADMIN_FUNCTIONS-CdaxLGkE.js +0 -48
  271. package/dist/packem_shared/ApiDocsPanel-BgrN4kml.js +0 -842
  272. package/dist/packem_shared/ApiReferencePanel-1vubqG5s.js +0 -229
  273. package/dist/packem_shared/ApiTab-CHkX49o_.js +0 -251
  274. package/dist/packem_shared/AuditPanel-CP9HM9nq.js +0 -200
  275. package/dist/packem_shared/CommandPalette-BtgkBzZI.js +0 -373
  276. package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
  277. package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
  278. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
  279. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
  280. package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
  281. package/dist/packem_shared/DataBrowser-Bb1gTQ6c.js +0 -4475
  282. package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
  283. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
  284. package/dist/packem_shared/ExportImportPanel-Dj87tRa5.js +0 -197
  285. package/dist/packem_shared/FileBrowser-CWvxp_is.js +0 -2932
  286. package/dist/packem_shared/FunctionRunner-DlWApMCH.js +0 -343
  287. package/dist/packem_shared/FunctionStatsPanel-CuO2Tmw-.js +0 -375
  288. package/dist/packem_shared/GlobalDataBrowser-3X9uRfdO.js +0 -289
  289. package/dist/packem_shared/HealthPanel-Dj0GRo5P.js +0 -648
  290. package/dist/packem_shared/HomePanel-BewOCuag.js +0 -1334
  291. package/dist/packem_shared/InsightsPanel-y_Q-xdPY.js +0 -461
  292. package/dist/packem_shared/LogsPanel-C7crgYoS.js +0 -827
  293. package/dist/packem_shared/MailPanel-PILidruz.js +0 -440
  294. package/dist/packem_shared/MetricsPanel-DioILzgf.js +0 -1611
  295. package/dist/packem_shared/MigrationsPanel-DkIcRoE5.js +0 -239
  296. package/dist/packem_shared/OpenRpcReferencePanel-vbcYbv3V.js +0 -191
  297. package/dist/packem_shared/PitrPanel-yKJ1JPPk.js +0 -252
  298. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
  299. package/dist/packem_shared/ScheduledJobs-BWNwIN3I.js +0 -262
  300. package/dist/packem_shared/SchemaViewer-CNr8Wame.js +0 -2512
  301. package/dist/packem_shared/SecurityAdvisorPanel-BBzv7L3c.js +0 -92
  302. package/dist/packem_shared/SettingsPanel-BKSKl8tl.js +0 -390
  303. package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
  304. package/dist/packem_shared/SqlEditorPanel-CkemCQvy.js +0 -13
  305. package/dist/packem_shared/Studio-QkOjc2NS.js +0 -33
  306. package/dist/packem_shared/StudioApp-TEElspKL.js +0 -657
  307. package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
  308. package/dist/packem_shared/TableEditor-JS3sXYgS.js +0 -11
  309. package/dist/packem_shared/advisor-view-CGcfMiPq.js +0 -159
  310. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
  311. package/dist/packem_shared/app.d-Cnij4Zp5.d.ts +0 -300
  312. package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
  313. package/dist/packem_shared/bar-chart-CzJAgqkp.js +0 -3245
  314. package/dist/packem_shared/button-BhsN2uZH.js +0 -49
  315. package/dist/packem_shared/card-DURq3ElK.js +0 -175
  316. package/dist/packem_shared/cf-links-2cktDedA.js +0 -8
  317. package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
  318. package/dist/packem_shared/data-grid-B5CaV3wS.js +0 -183
  319. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
  320. package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
  321. package/dist/packem_shared/grid-features-CzUfqgsM.js +0 -840
  322. package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
  323. package/dist/packem_shared/internal-rXJEAhXS.js +0 -68
  324. package/dist/packem_shared/label-D8ykjn5J.js +0 -46
  325. package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
  326. package/dist/packem_shared/reference-view-B4E49Lip.js +0 -2180
  327. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  328. package/dist/packem_shared/sparkline-10dG-_f0.js +0 -93
  329. package/dist/packem_shared/sql-editor-panel-CUJoYF1Z.js +0 -2562
  330. package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
  331. package/dist/packem_shared/studio-c5Vf7kSh.js +0 -11532
  332. package/dist/packem_shared/table-_RzNvy3R.js +0 -246
  333. package/dist/packem_shared/table-editor-9fhJ4hMJ.js +0 -407
  334. package/dist/packem_shared/table-list-sidebar-Bg7uzbvC.js +0 -832
  335. package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
  336. package/dist/packem_shared/use-admin-query-BkbdNFNz.js +0 -105
  337. package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
  338. package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
  339. package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
@@ -0,0 +1,8 @@
1
+ import{a as nt,b as rt}from"./chunk-3EQVJ5SQ.js";import{c as tt}from"./chunk-AANB526D.js";import{a as et}from"./chunk-EY6WHXDO.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import"./chunk-XZMOZFE6.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import{a as Ze}from"./chunk-QKEJLVC5.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-XKMLLTFP.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import"./chunk-NFS7FTAR.js";import{a as Xe}from"./chunk-EJSI4PMU.js";import{b as Ve}from"./chunk-OGUKYRFM.js";import{c as Ke,d as Ce,e as Ee,f as Le,g as He}from"./chunk-OKG3HWSJ.js";import{W as Ye}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as Je}from"./chunk-ULIQFBZU.js";import{a as qe}from"./chunk-4ZEL6BYL.js";import"./chunk-ERHFRNCL.js";import{f as Ie}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import"./chunk-LCXKALTS.js";import"./chunk-HEAQVSNS.js";import{d as ce,f as Se,g as Ne,h as Ge,p as ue}from"./chunk-PTZD7RUZ.js";import{a as l,d as Be,e as St,f as Nt,g as qt,i as me}from"./chunk-YKXDMIHQ.js";var G=Be(Nt(),1);var j=Be(St(),1);var u=Be(qt(),1);var Ct="x",ot=" ",kt={'"':'"',"'":"'","[":"]","`":"`"},ct=l((s,e)=>{let n=e+2;for(;n<s.length&&s[n]!==`
2
+ `;)n+=1;return n},"tt"),dt=l((s,e)=>{let n=s.indexOf("*/",e+2);return n===-1?-1:n+2},"nt"),ut=l(s=>{let e=s.split(""),n=0;for(;n<s.length;){let t=s[n]??"",o=kt[t];if(t==="-"&&s[n+1]==="-"){let r=ct(s,n);e.fill(ot,n,r),n=r}else if(t==="/"&&s[n+1]==="*"){let r=dt(s,n);if(r===-1)return;e.fill(ot,n,r),n=r}else if(o!==void 0){let r=n+1;for(;r<s.length;)if(s[r]!==o)r+=1;else if(o!=="]"&&s[r+1]===o)r+=2;else break;if(r>=s.length)return;e.fill(Ct,n,r+1),n=r+1}else n+=1}for(let t=0;t<s.length;t+=1)s[t]===`
3
+ `&&(e[t]=`
4
+ `);return e.join("")},"st"),Tt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,Rt=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|truncate|update|vacuum)\b|\breplace\b(?!\s*\()/iu,_t=/^\w+/u,It=/;\s*$/u,Et=/\s/u,mt=l(s=>{let e=0;for(;e<s.length;){let n=s[e];if(n!==void 0&&Et.test(n))e+=1;else if(n==="-"&&s[e+1]==="-")e=ct(s,e);else if(n==="/"&&s[e+1]==="*"){let t=dt(s,e);if(t===-1)break;e=t}else break}return e},"ot"),Lt=l(s=>{let e=mt(s),n=s.slice(e).trimEnd();if(n==="")return{code:"SQL_EMPTY",message:"the query is empty"};let t=(ut(n)??n).replace(It,""),o=n.slice(0,t.length),r=t.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};let a="the SQL editor is read-only \u2014 only SELECT / WITH / EXPLAIN queries are allowed";if(!Tt.test(o))return{code:"SQL_NOT_READONLY",length:_t.exec(o)?.[0].length??1,message:a,offset:e};let c=Rt.exec(o);if(c!==null)return{code:"SQL_NOT_READONLY",length:c[0].length,message:`${a} (\`${c[0].toUpperCase()}\` is not allowed)`,offset:e+c.index}},"Ot"),Ot=/^explain\b/iu,At=l(s=>Ot.test(s.slice(mt(s)))?s:`EXPLAIN QUERY PLAN ${s}`,"Mt"),Qe=l((s,e)=>{let n=s.trim();if(n==="")return[];let t=e+s.indexOf(n),o=Lt(n);return o?.code==="SQL_EMPTY"?[]:[o===void 0?{offset:t,sql:n}:{offset:t,rejection:o,sql:n}]},"We"),ft=l(s=>{let e=ut(s);if(e===void 0)return Qe(s,0);let n=[],t=0;for(let o=0;o<=e.length;o+=1)o!==e.length&&e[o]!==";"||(n.push(...Qe(s.slice(t,o),t)),t=o+1);return n},"lt"),Dt=["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"],Mt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],De=String.fromCodePoint(0),$t=new RegExp(`${De}${String.raw`(\d+)`}${De}`,"gu"),Ft=Dt.map(s=>({pattern:new RegExp(String.raw`\b${s.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:s})),zt=Mt.map(s=>({pattern:new RegExp(String.raw`\s+${s.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
5
+ ${s}`})),Bt=l(s=>{let e=[],n=s.replaceAll(/'(?:[^']|'')*'/gu,t=>(e.push(t),`${De}${(e.length-1).toString()}${De}`)).replaceAll(/\s+/gu," ").trim();for(let{pattern:t,replacement:o}of Ft)n=n.replaceAll(t,o);for(let{pattern:t,replacement:o}of zt)n=n.replaceAll(t,o);return n=n.replaceAll($t,(t,o)=>e[Number(o)]??""),n},"Wt"),Ht=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Pt=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Qt=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),jt=/[^\n]/gu,Wt=l((s,e)=>{let n=s[e];if(n==="'"){let t=e+1;for(;t<s.length&&s[t]!=="'";)t+=1;return Math.min(t+1,s.length)}if(n==="-"&&s[e+1]==="-"){let t=s.indexOf(`
6
+ `,e);return t===-1?s.length:t}if(n==="/"&&s[e+1]==="*"){let t=s.indexOf("*/",e+2);return t===-1?s.length:t+2}return-1},"Yt"),Ut=l(s=>{let e="",n=0;for(;n<s.length;){let t=Wt(s,n);t===-1?(e+=s.slice(n,n+1),n+=1):(e+=s.slice(n,t).replaceAll(jt," "),n=t)}return e},"Kt"),Yt=l(s=>{let e=new Set;for(let n of s.matchAll(Pt))e.add((n[1]??"").toLowerCase());return e},"Gt"),Gt=l((s,e)=>{let n=new Map;for(let t of s.matchAll(Ht)){let o=(t[1]??"").toLowerCase(),r=(t[2]??"").toLowerCase();e.has(o)&&(n.set(o,o),r!==""&&!Qt.has(r)&&n.set(r,o))}return n},"Jt"),ht=l((s,e)=>{let n=Ut(s),t=new Set(e.map(o=>o.toLowerCase()));return{ctes:Yt(n),masked:n,targets:Gt(n,t)}},"rt"),Kt=/^(?:__lunora|sqlite_)/iu,Vt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Xt=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Jt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Zt=l((s,e,n)=>{let t=[];for(let o of s.matchAll(Vt)){let r=o[1]??"",a=r.toLowerCase();!e.has(a)&&!n.has(a)&&!Jt.has(a)&&!Kt.test(r)&&t.push({length:r.length,message:`unknown table \`${r}\``,offset:o.index+o[0].length-r.length,severity:"error",source:"schema"})}return t},"tn"),en=l((s,e,n)=>{let t=[],o=new Map;for(let[r,a]of Object.entries(e.columns))o.set(r.toLowerCase(),new Set(a.map(c=>c.toLowerCase())));for(let r of s.matchAll(Xt)){let a=(r[1]??"").toLowerCase(),c=r[2]??"",i=n.get(a),d=i===void 0?void 0:o.get(i);d!==void 0&&!d.has(c.toLowerCase())&&t.push({length:c.length,message:`\`${i??""}\` has no column \`${c}\``,offset:r.index+r[0].length-c.length,severity:"error",source:"schema"})}return t},"nn"),tn=/(?<![\w$."])(?:"([a-z_][\w$]*)"|([a-z_][\w$]*))(?![.(])/giu,nn=/\bas\s+"?([a-z_][\w$]*)"?/giu,rn=l((s,e,n,t)=>{let o=[...new Set(n.values())],r=new Map,a=new Set;for(let d of o){for(let h of e.columns[d]??[])a.add(h.toLowerCase());for(let h of e.docFields?.[d]??[])r.set(h.toLowerCase(),h)}if(r.size===0)return[];let c=new Set([...s.matchAll(nn)].map(d=>(d[1]??"").toLowerCase())),i=[];for(let d of s.matchAll(tn)){let h=d[1],b=h??d[2]??"",g=b.toLowerCase(),v=r.get(g);v===void 0||a.has(g)||c.has(g)||t.has(g)||n.has(g)||i.push({length:b.length,message:`\`${v}\` is a \`__doc__\` field, not a column \u2014 use \`json_extract(__doc__, '$.${v}')\``,offset:d.index+(h===void 0?0:1),severity:"error",source:"schema"})}return i},"ln"),on=l((s,e)=>{if(s.trim()==="")return[];let n=ft(s),t=new Set(e.tables.map(r=>r.toLowerCase())),o=[];for(let r of n){let{offset:a,rejection:c}=r;if(c!==void 0){o.push({length:c.length,message:c.message,offset:c.offset===void 0?a:a+c.offset,severity:"error",source:"gate"});continue}let{ctes:i,masked:d,targets:h}=ht(r.sql,e.tables);o.push(...[...Zt(d,t,i),...en(d,e,h),...rn(d,e,h,i)].map(b=>({...b,offset:b.offset===void 0?a:a+b.offset})))}return o},"rn"),sn=Se(qe.lintSql),ln=600,an=l((s,e,n)=>{let t=Ie(),[o,r]=(0,j.useState)([]),a=(0,j.useMemo)(()=>on(s,e),[s,e]),c=Ze(s,ln),i=a.some(b=>b.source==="gate")||c.trim()==="",d=(0,j.useCallback)(async b=>{try{let g=await t.query(sn,{sql:c},Ne(n));b.cancelled||r(g.diagnostics??[])}catch{b.cancelled||r([])}},[t,c,n]);(0,j.useEffect)(()=>{if(i){r([]);return}let b={cancelled:!1};return ue(d(b)),()=>{b.cancelled=!0}},[d,i]);let h=c===s;return(0,j.useMemo)(()=>h?[...a,...o]:a,[a,o,h])},"dn"),Oe=8,cn=["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"],dn=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),un=/[\w$]/,pt=l(s=>s!==void 0&&un.test(s),"it"),bt=l(s=>{let e=s.length;for(;e>0&&pt(s[e-1]);)e-=1;return s.slice(e)},"at"),gt=l((s,e)=>{let n=e;for(;n>0&&pt(s[n-1]);)n-=1;return{end:e,start:n,text:s.slice(n,e)}},"ct"),st=l((s,e)=>{let n=s.slice(0,e).trimEnd();return n.endsWith(".")||dn.has(bt(n).toUpperCase())},"Je"),mn=l((s,e,n)=>{let t=s.slice(0,e);if(!t.endsWith("."))return;let o=bt(t.slice(0,-1));if(o!=="")return ht(s,n).targets.get(o.toLowerCase())??o},"hn"),je=l((s,e)=>s.toLowerCase().startsWith(e.toLowerCase()),"Ue"),lt=l((s,e,n,t)=>{let o=[];for(let r of s)if(je(r,e)&&(o.push(t(r)),o.length>=n))break;return o},"Ve"),fn=l((s,e,n)=>{let t=new Map;for(let[o,r]of Object.entries(s.columns))for(let a of r)if(je(a,e)&&!t.has(a)&&(t.set(a,o),t.size>=n))return[...t].map(([c,i])=>({detail:i,kind:"column",label:c}));return[...t].map(([o,r])=>({detail:r,kind:"column",label:o}))},"pn"),hn=l((s,e,n)=>{let t=gt(s,e),o=mn(s,t.start,n.tables);if(o!==void 0){let i=n.columns[o]??n.columns[o.toLowerCase()]??[];return lt(i,t.text,Oe,d=>({detail:o,kind:"column",label:d}))}if(t.text===""&&!st(s,t.start))return[];let r=lt(n.tables,t.text,Oe,i=>({kind:"table",label:i})),a=fn(n,t.text,Oe),c=cn.flatMap(i=>t.text!==""&&je(i,t.text)&&i.toLowerCase()!==t.text.toLowerCase()?[{kind:"keyword",label:i}]:[]);return(st(s,t.start)?[...a,...r,...c]:[...r,...a,...c]).slice(0,Oe)},"bn"),pn=l((s,e,n)=>{let t=gt(s,e),o=s.slice(0,t.start)+n.label+s.slice(t.end);return{caret:t.start+n.label.length,value:o}},"gn"),bn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],gn=l((s,e)=>{let n=globalThis.getComputedStyle(s),t=globalThis.document.createElement("div"),{style:o}=t;o.position="absolute",o.visibility="hidden",o.whiteSpace="pre-wrap",o.overflowWrap="break-word";for(let i of bn)o[i]=n[i];t.textContent=s.value.slice(0,Math.max(0,e));let r=globalThis.document.createElement("span");r.textContent=s.value.slice(Math.max(0,e))||".",t.append(r),globalThis.document.body.append(t);let a=r.offsetLeft-s.scrollLeft,c=r.offsetTop-s.scrollTop;return t.remove(),{left:a,top:c}},"vn"),xn=l((s,e,n)=>{let t=(0,G.c)(16),[o,r]=(0,j.useState)(null),a;t[0]!==s||t[1]!==e?(a=l((y,x)=>{let q=hn(y,x,s);if(q.length===0){r(null);return}let w=e.current,{left:p,top:N}=w===null?{left:0,top:0}:gn(w,x);r(k=>k!==null&&k.active===0&&k.left===p&&k.top===N&&k.suggestions.length===q.length&&k.suggestions.every((R,T)=>{let E=q.at(T);return R.kind===E?.kind&&R.label===E.label&&R.detail===E.detail})?k:{active:0,left:p,suggestions:q,top:N})},"r"),t[0]=s,t[1]=e,t[2]=a):a=t[2];let c=a,i;t[3]===Symbol.for("react.memo_cache_sentinel")?(i=l(()=>{r(null)},"a"),t[3]=i):i=t[3];let d=i,h;t[4]===Symbol.for("react.memo_cache_sentinel")?(h=l(y=>{r(x=>{if(x===null)return x;let q=x.suggestions.length,w=(x.active+y+q)%q;return{...x,active:w}})},"f"),t[4]=h):h=t[4];let b=h,g;t[5]!==n||t[6]!==o||t[7]!==e?(g=l(y=>{let x=e.current;if(o===null||x===null)return!1;let q=o.suggestions[y??o.active];if(q===void 0)return!1;let w=pn(x.value,x.selectionStart,q);return n(w.value),r(null),requestAnimationFrame(()=>{let p=e.current;p!==null&&(p.focus(),p.setSelectionRange(w.caret,w.caret))}),!0},"m"),t[5]=n,t[6]=o,t[7]=e,t[8]=g):g=t[8];let v=g,m;t[9]!==v?(m=l(()=>v(),"d"),t[9]=v,t[10]=m):m=t[10];let S=m,f;return t[11]!==S||t[12]!==v||t[13]!==c||t[14]!==o?(f={close:d,commit:S,commitAt:v,move:b,refresh:c,state:o},t[11]=S,t[12]=v,t[13]=c,t[14]=o,t[15]=f):f=t[15],f},"yn"),vn={column:"column",keyword:"keyword",table:"table"},yn=20,wn=l(s=>{let e=(0,G.c)(17),{listboxId:n,onPick:t,state:o}=s,r=ce(),a;e[0]!==o?(a=o===null?void 0:{left:o.left,top:o.top+yn},e[0]=o,e[1]=a):a=e[1];let c=a;if(o===null)return null;let i;if(e[2]!==n||e[3]!==t||e[4]!==o.active||e[5]!==o.suggestions||e[6]!==r){let h;e[8]!==n||e[9]!==t||e[10]!==o.active||e[11]!==r?(h=l((b,g)=>(0,u.jsxs)("li",{"aria-selected":g===o.active,className:me("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",g===o.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${n}-opt-${g.toString()}`,onMouseDown:l(v=>{v.preventDefault(),t(g)},"onMouseDown"),role:"option",children:[(0,u.jsx)("span",{className:"truncate font-mono",children:b.label}),b.detail!==void 0&&(0,u.jsx)("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:b.detail}),(0,u.jsx)("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:r(vn[b.kind])})]},`${b.kind}:${b.label}`),"f"),e[8]=n,e[9]=t,e[10]=o.active,e[11]=r,e[12]=h):h=e[12],i=o.suggestions.map(h),e[2]=n,e[3]=t,e[4]=o.active,e[5]=o.suggestions,e[6]=r,e[7]=i}else i=e[7];let d;return e[13]!==n||e[14]!==c||e[15]!==i?(d=(0,u.jsx)("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:n,role:"listbox",style:c,children:i}),e[13]=n,e[14]=c,e[15]=i,e[16]=d):d=e[16],d},"Cn"),Sn=Se(qe.listTables),Nn=Se(qe.readTablePage),qn=l(s=>{let e=(0,G.c)(18),n=Ie(),t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];let[o,r]=(0,j.useState)(t),a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a={},e[1]=a):a=e[1];let[c,i]=(0,j.useState)(a),d;e[2]===Symbol.for("react.memo_cache_sentinel")?(d={},e[2]=d):d=e[2];let[h,b]=(0,j.useState)(d),g;e[3]===Symbol.for("react.memo_cache_sentinel")?(g=new Set,e[3]=g):g=e[3];let v=(0,j.useRef)(g),m,S;e[4]!==n||e[5]!==s?(m=l(()=>{let p={cancelled:!1};return ue((async()=>{try{let N=await n.query(Sn,{},Ne(s));p.cancelled||(r(N.map(kn)),i({}),b({}),v.current=new Set)}catch{p.cancelled||(r([]),i({}),b({}),v.current=new Set)}})()),()=>{p.cancelled=!0}},"d"),S=[n,s],e[4]=n,e[5]=s,e[6]=m,e[7]=S):(m=e[6],S=e[7]),(0,j.useEffect)(m,S);let f;e[8]!==n||e[9]!==s?(f=l(p=>{v.current.has(p)||(v.current.add(p),ue((async()=>{try{let N=await n.query(Nn,{limit:1,offset:0,table:p},Ne(s)),{sqlColumns:k}=N;if(k===void 0){v.current.delete(p);return}let R=new Set(k),T=N.columns.filter(E=>!R.has(E));i(E=>({...E,[p]:k})),b(E=>({...E,[p]:T}))}catch{v.current.delete(p)}})()))},"u"),e[8]=n,e[9]=s,e[10]=f):f=e[10];let y=f,x;e[11]!==c||e[12]!==h||e[13]!==o?(x={columns:c,docFields:h,tables:o},e[11]=c,e[12]=h,e[13]=o,e[14]=x):x=e[14];let q=x,w;return e[15]!==y||e[16]!==q?(w={probe:y,schema:q},e[15]=y,e[16]=q,e[17]=w):w=e[17],w},"En"),Pe=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,Cn=l(s=>{let e=new Set;Pe.lastIndex=0;let n=Pe.exec(s);for(;n!==null;)e.add(n[1]??n[2]),n=Pe.exec(s);return[...e]},"Tn");function kn(s){return s.name}l(kn,"Rn");var Tn=l(s=>{let e=(0,G.c)(34),{onSubmit:n,probe:t,schema:o,setDraft:r}=s,a=(0,j.useId)(),c=(0,j.useRef)(null),i=(0,j.useRef)(null),d=(0,j.useRef)(null),h=xn(o,d,r),{close:b,commit:g,commitAt:v,move:m,refresh:S,state:f}=h,y;e[0]!==v?(y=l(C=>{v(C)},"v"),e[0]=v,e[1]=y):y=e[1];let x=y,q;e[2]!==S?(q=l(()=>{let C=d.current;C!==null&&C===document.activeElement&&S(C.value,C.selectionStart)},"N"),e[2]=S,e[3]=q):q=e[3];let w;e[4]!==S||e[5]!==o?(w=[S,o],e[4]=S,e[5]=o,e[6]=w):w=e[6],(0,j.useEffect)(q,w);let p;e[7]!==t||e[8]!==S||e[9]!==r?(p=l(C=>{let{selectionStart:P,value:_}=C.target;r(_);for(let $ of Cn(_))t($);S(_,P)},"h"),e[7]=t,e[8]=S,e[9]=r,e[10]=p):p=e[10];let N=p,k;e[11]!==S?(k=l(C=>{let P=C.currentTarget;S(P.value,P.selectionStart)},"w"),e[11]=S,e[12]=k):k=e[12];let R=k,T;e[13]!==f||e[14]!==b||e[15]!==g||e[16]!==m||e[17]!==n?(T=l(C=>{if(f!==null){if(C.key==="ArrowDown"){C.preventDefault(),m(1);return}if(C.key==="ArrowUp"){C.preventDefault(),m(-1);return}if(C.key==="Escape"){C.preventDefault(),b();return}if((C.key==="Enter"||C.key==="Tab")&&!C.metaKey&&!C.ctrlKey&&g()){C.preventDefault();return}}(C.metaKey||C.ctrlKey)&&C.key==="Enter"&&(C.preventDefault(),n())},"T"),e[13]=f,e[14]=b,e[15]=g,e[16]=m,e[17]=n,e[18]=T):T=e[18];let E=T,I;e[19]!==b?(I=l(()=>{requestAnimationFrame(()=>{b()})},"C"),e[19]=b,e[20]=I):I=e[20];let O=I,A;e[21]===Symbol.for("react.memo_cache_sentinel")?(A=l(C=>{let{scrollLeft:P,scrollTop:_}=C.currentTarget;c.current!==null&&(c.current.scrollTop=_),i.current!==null&&(i.current.scrollTop=_,i.current.scrollLeft=P)},"q"),e[21]=A):A=e[21];let L=A,F;e[22]===Symbol.for("react.memo_cache_sentinel")?(F=l(C=>{let P=d.current;P===null||C.offset===void 0||(P.focus(),P.setSelectionRange(C.offset,C.offset+(C.length??0)))},"B"),e[22]=F):F=e[22];let M=F,H;e[23]!==N||e[24]!==O||e[25]!==E||e[26]!==R?(H={onBlur:O,onChange:N,onKeyDown:E,onScroll:L,onSelect:R},e[23]=N,e[24]=O,e[25]=E,e[26]=R,e[27]=H):H=e[27];let D;return e[28]!==f||e[29]!==b||e[30]!==a||e[31]!==x||e[32]!==H?(D={autocompleteState:f,closeAutocomplete:b,handlers:H,listboxId:a,onPickSuggestion:x,editorRef:d,gutterRef:c,overlayRef:i,revealDiagnostic:M},e[28]=f,e[29]=b,e[30]=a,e[31]=x,e[32]=H,e[33]=D):D=e[33],D},"Ln"),Rn="lunora-studio-sql-tabs",_n="lunora-studio-sql-active-tab",We=12,ke=l((s="",e="")=>({activeId:null,id:He("tab"),name:e,sql:s}),"we"),In=l(()=>Le(_n,""),"An"),En=l(s=>{let e=(0,G.c)(16),[n,t]=Ee(Rn),[o,r]=In(),[a]=(0,j.useState)(s),c,i;e[0]!==a||e[1]!==t||e[2]!==n.length?(c=l(()=>{n.length===0&&t([a])},"c"),i=[a,t,n.length],e[0]=a,e[1]=t,e[2]=n.length,e[3]=c,e[4]=i):(c=e[3],i=e[4]),(0,j.useEffect)(c,i);let d;e[5]!==a||e[6]!==n?(d=n.length===0?[a]:n,e[5]=a,e[6]=n,e[7]=d):d=e[7];let h=d,b;e[8]!==o||e[9]!==h?(b=h.some(m=>m.id===o)?o:h[0]?.id??"",e[8]=o,e[9]=h,e[10]=b):b=e[10];let g=b,v;return e[11]!==g||e[12]!==r||e[13]!==t||e[14]!==h?(v={activeId:g,setActiveId:r,setTabs:t,tabs:h},e[11]=g,e[12]=r,e[13]=t,e[14]=h,e[15]=v):v=e[15],v},"qn"),xt=l(s=>s.activeId===null&&s.sql.trim()!=="","dt"),Ln=l((s,e)=>[...s,e].slice(-We),"On"),On=l((s,e,n)=>{let t=s.findIndex(r=>r.id===e);if(t===-1)return{activeId:s[0]?.id??"",tabs:[...s]};let o=s.filter(r=>r.id!==e);if(o.length===0){let r=n();return{activeId:r.id,tabs:[r]}}return{activeId:o[Math.min(t,o.length-1)].id,tabs:o}},"Dn"),An=l((s,e)=>{let n=s.filter(t=>t.id===e);return n.length===0?{activeId:s[0]?.id??"",tabs:[...s]}:{activeId:e,tabs:n}},"Mn"),Dn=l((s,e,n)=>{let t=s.findIndex(r=>r.id===e);if(t===-1)return{activeId:n,tabs:[...s]};let o=s.slice(0,t+1);return{activeId:o.some(r=>r.id===n)?n:e,tabs:o}},"$n"),Mn=l(s=>{let e=s();return{activeId:e.id,tabs:[e]}},"Bn"),$n=l((s,e,n)=>{if(s==="others")return e.filter(t=>t.id!==n);if(s==="right"){let t=e.findIndex(o=>o.id===n);return t===-1?[]:e.slice(t+1)}return[...e]},"Hn"),at={error:null,pane:"results",result:null,running:!1},Fn=l(s=>{let e=(0,G.c)(66),{activeId:n,setActiveId:t,setTabs:o,tabs:r}=En(s),a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];let[c,i]=(0,j.useState)(a),[d,h]=(0,j.useState)(null),[b,g]=(0,j.useState)(null),v;e[1]!==n||e[2]!==r?(v=r.find(B=>B.id===n)??r[0]??ke(),e[1]=n,e[2]=r,e[3]=v):v=e[3];let m=v,S=c[m.id]??at,f;e[4]!==m.id||e[5]!==o?(f=l(B=>{o(U=>U.map(Y=>Y.id===m.id?{...Y,...B}:Y))},"u"),e[4]=m.id,e[5]=o,e[6]=f):f=e[6];let y=f,x;e[7]!==m.id?(x=l(B=>{i(U=>{let Y=U[m.id]??at;return{...U,[m.id]:{...Y,...B}}})},"g"),e[7]=m.id,e[8]=x):x=e[8];let q=x,w;e[9]!==t||e[10]!==o||e[11]!==r.length?(w=l(()=>{if(r.length>=We)return;let B=ke();o(U=>Ln(U,B)),t(B.id)},"y"),e[9]=t,e[10]=o,e[11]=r.length,e[12]=w):w=e[12];let p=w,N;e[13]!==t||e[14]!==o?(N=l(B=>{h(null),g(null),o(B.tabs),t(B.activeId);let U=new Set(B.tabs.map(zn));i(Y=>Object.fromEntries(Object.entries(Y).filter(X=>{let[fe]=X;return U.has(fe)})))},"E"),e[13]=t,e[14]=o,e[15]=N):N=e[15];let k=N,R;e[16]!==k||e[17]!==r?(R=l(B=>{k(On(r,B,ke))},"R"),e[16]=k,e[17]=r,e[18]=R):R=e[18];let T=R,E;e[19]!==n||e[20]!==k||e[21]!==r?(E=l((B,U)=>{k(B==="others"?An(r,U):B==="right"?Dn(r,U,n):Mn(ke))},"_"),e[19]=n,e[20]=k,e[21]=r,e[22]=E):E=e[22];let I=E,O;e[23]!==I||e[24]!==d||e[25]!==r?(O=l(B=>{d!==null&&($n(B,r,d.id).some(Bn)?g(B):I(B,d.id))},"A"),e[23]=I,e[24]=d,e[25]=r,e[26]=O):O=e[26];let A=O,L;e[27]===Symbol.for("react.memo_cache_sentinel")?(L=l((B,U)=>{U.preventDefault(),g(null),h({id:B,x:U.clientX,y:U.clientY})},"I"),e[27]=L):L=e[27];let F=L,M;e[28]===Symbol.for("react.memo_cache_sentinel")?(M=l(()=>{h(null),g(null)},"D"),e[28]=M):M=e[28];let H=M,D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=l(B=>{B.preventDefault(),h(null),g(null)},"O"),e[29]=D):D=e[29];let C=D,P;e[30]!==A?(P=l(()=>{A("others")},"F"),e[30]=A,e[31]=P):P=e[31];let _=P,$;e[32]!==A?($=l(()=>{A("right")},"M"),e[32]=A,e[33]=$):$=e[33];let W=$,z;e[34]!==A?(z=l(()=>{A("all")},"$"),e[34]=A,e[35]=z):z=e[35];let J=z,Z;e[36]!==I||e[37]!==b||e[38]!==d?(Z=l(()=>{d!==null&&b!==null&&I(b,d.id),g(null)},"Z"),e[36]=I,e[37]=b,e[38]=d,e[39]=Z):Z=e[39];let ee=Z,te;e[40]===Symbol.for("react.memo_cache_sentinel")?(te=l(()=>{g(null)},"te"),e[40]=te):te=e[40];let ie=te,V;e[41]!==d?(V=d===null?void 0:{left:d.x,top:d.y},e[41]=d,e[42]=V):V=e[42];let Q=V,ne;e[43]!==o?(ne=l(B=>{o(U=>U.map(Y=>Y.activeId===B?{...Y,activeId:null}:Y))},"ne"),e[43]=o,e[44]=ne):ne=e[44];let re=ne,oe;e[45]!==o?(oe=l((B,U)=>{o(Y=>Y.map(X=>X.id===B?{...X,name:U}:X))},"oe"),e[45]=o,e[46]=oe):oe=e[46];let se=oe,le;return e[47]!==m||e[48]!==n||e[49]!==p||e[50]!==T||e[51]!==ee||e[52]!==J||e[53]!==_||e[54]!==W||e[55]!==S||e[56]!==q||e[57]!==y||e[58]!==b||e[59]!==se||e[60]!==t||e[61]!==d||e[62]!==Q||e[63]!==r||e[64]!==re?(le={activeTab:m,activeTabId:n,addEditorTab:p,cancelBulk:ie,closeEditorTab:T,closeTabMenu:H,confirmBulk:ee,menuStyle:Q,onBackdropContextMenu:C,onCloseAll:J,onCloseOthers:_,onCloseToRight:W,openTabMenu:F,output:S,patchActiveOutput:q,patchActiveTab:y,pendingBulk:b,renameTab:se,setActiveTabId:t,tabMenu:d,tabs:r,unlinkQuery:re},e[47]=m,e[48]=n,e[49]=p,e[50]=T,e[51]=ee,e[52]=J,e[53]=_,e[54]=W,e[55]=S,e[56]=q,e[57]=y,e[58]=b,e[59]=se,e[60]=t,e[61]=d,e[62]=Q,e[63]=r,e[64]=re,e[65]=le):le=e[65],le},"Pn");function zn(s){return s.id}l(zn,"Fn");function Bn(s){return xt(s)}l(Bn,"Wn");var Hn="lunora-studio-sql-queries",we="lunora-studio-sql-history",Pn="lunora-studio-sql-remember-history",Qn=25,jn=l(s=>{let e=(0,G.c)(41),{loadIntoActiveTab:n,unlinkQuery:t}=s,o=ce(),[r,a]=Ee(Hn),[c,i]=Le(Pn,!1),[d,h]=Ee(we,c?"local":"session"),b,g;e[0]!==c?(b=l(()=>{c||Ce(we,"local")},"p"),g=[c],e[0]=c,e[1]=b,e[2]=g):(b=e[1],g=e[2]),(0,j.useEffect)(b,g);let[v,m]=(0,j.useState)(""),S=(0,j.useRef)(null),f;e[3]!==h?(f=l(_=>{h($=>$[0]?.sql===_?$:[{at:Date.now(),sql:_},...$.filter(W=>W.sql!==_)].slice(0,Qn))},"u"),e[3]=h,e[4]=f):f=e[4];let y=f,x;e[5]!==n||e[6]!==a||e[7]!==o?(x=l(()=>{let _={id:He("q"),name:o("Untitled query"),sql:""};a($=>[_,...$]),n("",_.id)},"g"),e[5]=n,e[6]=a,e[7]=o,e[8]=x):x=e[8];let q=x,w;e[9]!==n||e[10]!==r?(w=l(_=>{let $=r.find(W=>W.id===_);$!==void 0&&(n($.sql,_),S.current?.querySelector(`[data-testid="sql-query-${_}"]`)?.scrollIntoView({block:"nearest"}))},"y"),e[9]=n,e[10]=r,e[11]=w):w=e[11];let p=w,N;e[12]!==a||e[13]!==t?(N=l(_=>{a($=>$.filter(W=>W.id!==_)),t(_)},"E"),e[12]=a,e[13]=t,e[14]=N):N=e[14];let k=N,R;e[15]!==n?(R=l(_=>{n(_.currentTarget.dataset.sql??"",null)},"R"),e[15]=n,e[16]=R):R=e[16];let T=R,E;e[17]!==n?(E=l(_=>{n(_.currentTarget.dataset.sql??"",null)},"_"),e[17]=n,e[18]=E):E=e[18];let I=E,O;e[19]!==h?(O=l(()=>{h([]),Ce(we,"local"),Ce(we,"session")},"A"),e[19]=h,e[20]=O):O=e[20];let A=O,L;e[21]!==d||e[22]!==i?(L=l(_=>{Ke(we,d,_?"local":"session"),_||Ce(we,"local"),i(_)},"I"),e[21]=d,e[22]=i,e[23]=L):L=e[23];let F=L,M;e[24]===Symbol.for("react.memo_cache_sentinel")?(M=l(_=>{m(_.target.value)},"D"),e[24]=M):M=e[24];let H=M,D;e[25]!==a?(D=l((_,$)=>{a(W=>W.map(z=>z.id===_?{...z,sql:$}:z))},"O"),e[25]=a,e[26]=D):D=e[26];let C=D,P;return e[27]!==A||e[28]!==k||e[29]!==d||e[30]!==I||e[31]!==T||e[32]!==q||e[33]!==r||e[34]!==y||e[35]!==c||e[36]!==v||e[37]!==p||e[38]!==F||e[39]!==C?(P={clearHistory:A,deleteQuery:k,history:d,listRef:S,loadFromHistory:I,loadTemplate:T,newQuery:q,onSearchChange:H,queries:r,recordHistory:y,rememberHistory:c,search:v,selectQuery:p,setRememberHistory:F,updateQuerySql:C},e[27]=A,e[28]=k,e[29]=d,e[30]=I,e[31]=T,e[32]=q,e[33]=r,e[34]=y,e[35]=c,e[36]=v,e[37]=p,e[38]=F,e[39]=C,e[40]=P):P=e[40],P},"jn"),vt="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",Wn=l((s,e)=>{let n=[];for(let o of s){if(o.offset===void 0||o.length===void 0||o.length<=0)continue;let r=Math.max(0,Math.min(o.offset,e)),a=Math.max(r,Math.min(o.offset+o.length,e));r!==a&&n.push({end:a,severity:o.severity,start:r})}n.sort((o,r)=>o.start-r.start);let t=[];for(let o of n)o.start>=(t.at(-1)?.end??0)&&t.push(o);return t},"Yn"),Un=l(s=>s==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":s==="empty-response"?"The model returned nothing usable.":"The model could not be reached.","Kn"),Yn=l(s=>{let e=(0,G.c)(51),{assistant:n,failed:t,onGenerated:o}=s,r=ce(),[a,c]=(0,j.useState)("");if(n.unavailable)return null;let i;e[0]!==n?(i=n.pending("sql"),e[0]=n,e[1]=i):i=e[1];let d=i,h;if(e[2]!==n||e[3]!==t||e[4]!==o||e[5]!==d||e[6]!==a||e[7]!==r){let b=n.reason("sql"),g;e[9]!==n||e[10]!==t||e[11]!==o||e[12]!==a?(g=l(I=>{let O=a.trim();O===""&&!I||ue((async()=>{let A=await n.generate(O===""?"fix the failing statement":O,I?t:void 0);A!==void 0&&o(A)})())},"m"),e[9]=n,e[10]=t,e[11]=o,e[12]=a,e[13]=g):g=e[13];let v=g,m;e[14]!==r?(m=r("Describe the query you want"),e[14]=r,e[15]=m):m=e[15];let S;e[16]===Symbol.for("react.memo_cache_sentinel")?(S=l(I=>{c(I.target.value)},"S"),e[16]=S):S=e[16];let f;e[17]!==v?(f=l(I=>{I.key==="Enter"&&(I.preventDefault(),v(!1))},"u"),e[17]=v,e[18]=f):f=e[18];let y;e[19]!==r?(y=r("Describe the query you want"),e[19]=r,e[20]=y):y=e[20];let x;e[21]!==d||e[22]!==a||e[23]!==m||e[24]!==f||e[25]!==y?(x=(0,u.jsx)(Ye,{"aria-label":m,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:d,onChange:S,onKeyDown:f,placeholder:y,value:a}),e[21]=d,e[22]=a,e[23]=m,e[24]=f,e[25]=y,e[26]=x):x=e[26];let q=d&&"opacity-60",w;e[27]!==q?(w=me("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",q),e[27]=q,e[28]=w):w=e[28];let p;e[29]!==d||e[30]!==a?(p=d||a.trim()==="",e[29]=d,e[30]=a,e[31]=p):p=e[31];let N;e[32]!==v?(N=l(()=>{v(!1)},"E"),e[32]=v,e[33]=N):N=e[33];let k;e[34]!==d||e[35]!==r?(k=r(d?"Thinking\u2026":"Draft SQL"),e[34]=d,e[35]=r,e[36]=k):k=e[36];let R;e[37]!==w||e[38]!==p||e[39]!==N||e[40]!==k?(R=(0,u.jsx)("button",{className:w,"data-testid":"sql-assistant-generate",disabled:p,onClick:N,type:"button",children:k}),e[37]=w,e[38]=p,e[39]=N,e[40]=k,e[41]=R):R=e[41];let T;e[42]!==t||e[43]!==d||e[44]!==v||e[45]!==r?(T=t!==void 0&&(0,u.jsx)("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:d,onClick:l(()=>{v(!0)},"onClick"),type:"button",children:r("Fix this")}),e[42]=t,e[43]=d,e[44]=v,e[45]=r,e[46]=T):T=e[46];let E;e[47]!==R||e[48]!==T||e[49]!==x?(E=(0,u.jsxs)("div",{className:"flex items-center gap-2",children:[x,R,T]}),e[47]=R,e[48]=T,e[49]=x,e[50]=E):E=e[50],h=(0,u.jsxs)("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[E,b!==void 0&&(0,u.jsx)("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Un(b)})]}),e[2]=n,e[3]=t,e[4]=o,e[5]=d,e[6]=a,e[7]=r,e[8]=h}else h=e[8];return h},"Gn"),Gn=l(s=>{let e=(0,G.c)(8),{diagnostics:n,draft:t,scrollRef:o}=s,r,a;if(e[0]!==n||e[1]!==t){a=Symbol.for("react.early_return_sentinel");e:{let d=Wn(n,t.length);if(d.length===0){a=null;break e}r=[];let h=0;for(let[b,g]of d.entries())g.start>h&&r.push(t.slice(h,g.start)),r.push((0,u.jsx)("span",{className:me("decoration-wavy underline underline-offset-4",g.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:t.slice(g.start,g.end)},`${g.start.toString()}-${b.toString()}`)),h=g.end;r.push(t.slice(h))}e[0]=n,e[1]=t,e[2]=r,e[3]=a}else r=e[2],a=e[3];if(a!==Symbol.for("react.early_return_sentinel"))return a;let c;e[4]===Symbol.for("react.memo_cache_sentinel")?(c=me("pointer-events-none absolute inset-0 overflow-hidden text-transparent",vt),e[4]=c):c=e[4];let i;return e[5]!==r||e[6]!==o?(i=(0,u.jsx)("div",{"aria-hidden":"true",className:c,"data-testid":"sql-diagnostics-overlay",ref:o,children:r}),e[5]=r,e[6]=o,e[7]=i):i=e[7],i},"Jn"),Kn={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Vn=l(s=>{let e=(0,G.c)(10),{diagnostics:n,onSelect:t}=s,o=ce();if(n.length===0)return null;let r;e[0]!==o?(r=o("SQL problems"),e[0]=o,e[1]=r):r=e[1];let a;if(e[2]!==n||e[3]!==t){let i;e[5]!==t?(i=l((d,h)=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:l(()=>{t(d)},"onClick"),type:"button",children:[(0,u.jsx)("span",{className:me("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",d.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:Kn[d.source]}),(0,u.jsx)("span",{className:"min-w-0 text-muted-foreground",children:d.message})]})},`${d.source}-${(d.offset??h).toString()}-${h.toString()}`),"a"),e[5]=t,e[6]=i):i=e[6],a=n.map(i),e[2]=n,e[3]=t,e[4]=a}else a=e[4];let c;return e[7]!==r||e[8]!==a?(c=(0,u.jsx)("ul",{"aria-label":r,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:a}),e[7]=r,e[8]=a,e[9]=c):c=e[9],c},"Xn"),Xn={minWidth:"2.75rem",paddingInline:"0.5rem"},Jn=l(s=>{let e=(0,G.c)(64),{assistant:n,autocomplete:t,diagnostics:o,draft:r,failed:a,handlers:c,editorRef:i,gutterRef:d,listboxId:h,onGenerated:b,onPickSuggestion:g,onRevealDiagnostic:v,overlayRef:m}=s,S=ce(),f,y,x,q,w,p,N,k;if(e[0]!==n||e[1]!==r||e[2]!==a||e[3]!==d||e[4]!==b){let P=r.split(`
7
+ `).length;N="flex min-h-0 min-w-0 flex-1 flex-col",e[13]!==n||e[14]!==a||e[15]!==b?(k=(0,u.jsx)(Yn,{assistant:n,failed:a,onGenerated:b}),e[13]=n,e[14]=a,e[15]=b,e[16]=k):k=e[16],p="flex min-h-0 min-w-0 flex-1",f="true",y="shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",x=d,q=Xn,w=Array.from({length:P},Zn),e[0]=n,e[1]=r,e[2]=a,e[3]=d,e[4]=b,e[5]=f,e[6]=y,e[7]=x,e[8]=q,e[9]=w,e[10]=p,e[11]=N,e[12]=k}else f=e[5],y=e[6],x=e[7],q=e[8],w=e[9],p=e[10],N=e[11],k=e[12];let R;e[17]!==f||e[18]!==y||e[19]!==x||e[20]!==q||e[21]!==w?(R=(0,u.jsx)("div",{"aria-hidden":f,className:y,ref:x,style:q,children:w}),e[17]=f,e[18]=y,e[19]=x,e[20]=q,e[21]=w,e[22]=R):R=e[22];let T;e[23]!==o||e[24]!==r||e[25]!==m?(T=(0,u.jsx)(Gn,{diagnostics:o,draft:r,scrollRef:m}),e[23]=o,e[24]=r,e[25]=m,e[26]=T):T=e[26];let E;e[27]!==t||e[28]!==h?(E=t===null?void 0:`${h}-opt-${t.active.toString()}`,e[27]=t,e[28]=h,e[29]=E):E=e[29];let I=t===null?void 0:h,O=t!==null,A;e[30]!==S?(A=S("SQL query"),e[30]=S,e[31]=A):A=e[31];let L;e[32]!==r||e[33]!==i||e[34]!==c.onBlur||e[35]!==c.onChange||e[36]!==c.onKeyDown||e[37]!==c.onScroll||e[38]!==c.onSelect||e[39]!==E||e[40]!==I||e[41]!==O||e[42]!==A?(L=(0,u.jsx)("textarea",{"aria-activedescendant":E,"aria-autocomplete":"list","aria-controls":I,"aria-expanded":O,"aria-label":A,className:`relative size-full resize-none bg-transparent outline-none ${vt}`,"data-testid":"sql-input",onBlur:c.onBlur,onChange:c.onChange,onKeyDown:c.onKeyDown,onScroll:c.onScroll,onSelect:c.onSelect,placeholder:"SELECT * FROM \u2026",ref:i,role:"combobox",spellCheck:!1,value:r}),e[32]=r,e[33]=i,e[34]=c.onBlur,e[35]=c.onChange,e[36]=c.onKeyDown,e[37]=c.onScroll,e[38]=c.onSelect,e[39]=E,e[40]=I,e[41]=O,e[42]=A,e[43]=L):L=e[43];let F;e[44]!==t||e[45]!==h||e[46]!==g?(F=(0,u.jsx)(wn,{listboxId:h,onPick:g,state:t}),e[44]=t,e[45]=h,e[46]=g,e[47]=F):F=e[47];let M;e[48]!==T||e[49]!==L||e[50]!==F?(M=(0,u.jsxs)("div",{className:"relative min-w-0 flex-1 bg-background",children:[T,L,F]}),e[48]=T,e[49]=L,e[50]=F,e[51]=M):M=e[51];let H;e[52]!==M||e[53]!==p||e[54]!==R?(H=(0,u.jsxs)("div",{className:p,children:[R,M]}),e[52]=M,e[53]=p,e[54]=R,e[55]=H):H=e[55];let D;e[56]!==o||e[57]!==v?(D=(0,u.jsx)(Vn,{diagnostics:o,onSelect:v}),e[56]=o,e[57]=v,e[58]=D):D=e[58];let C;return e[59]!==H||e[60]!==D||e[61]!==N||e[62]!==k?(C=(0,u.jsxs)("div",{className:N,children:[k,H,D]}),e[59]=H,e[60]=D,e[61]=N,e[62]=k,e[63]=C):C=e[63],C},"es");function Zn(s,e){return(0,u.jsx)("div",{children:e+1},e)}l(Zn,"ts");var yt=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],er=l(s=>{let e=(0,G.c)(29),{active:n,onDelete:t,onSelect:o,query:r}=s,a=ce(),c;e[0]!==o||e[1]!==r.id?(c=l(()=>{o(r.id)},"c"),e[0]=o,e[1]=r.id,e[2]=c):c=e[2];let i=c,d;e[3]!==t||e[4]!==r.id?(d=l(N=>{N.stopPropagation(),t(r.id)},"i"),e[3]=t,e[4]=r.id,e[5]=d):d=e[5];let h=d,b=n?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground",g;e[6]!==b?(g=me("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",b),e[6]=b,e[7]=g):g=e[7];let v=`sql-query-${r.id}`,m;e[8]===Symbol.for("react.memo_cache_sentinel")?(m=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=m):m=e[8];let S;e[9]!==r.name?(S=(0,u.jsx)("span",{className:"truncate",children:r.name}),e[9]=r.name,e[10]=S):S=e[10];let f;e[11]!==n||e[12]!==i||e[13]!==g||e[14]!==v||e[15]!==S?(f=(0,u.jsxs)("button",{"aria-pressed":n,className:g,"data-testid":v,onClick:i,type:"button",children:[m,S]}),e[11]=n,e[12]=i,e[13]=g,e[14]=v,e[15]=S,e[16]=f):f=e[16];let y;e[17]!==a?(y=a("Delete query"),e[17]=a,e[18]=y):y=e[18];let x;e[19]!==a?(x=a("Delete query"),e[19]=a,e[20]=x):x=e[20];let q;e[21]===Symbol.for("react.memo_cache_sentinel")?(q=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=q):q=e[21];let w;e[22]!==h||e[23]!==x||e[24]!==y?(w=(0,u.jsx)("button",{"aria-label":y,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:h,title:x,type:"button",children:q}),e[22]=h,e[23]=x,e[24]=y,e[25]=w):w=e[25];let p;return e[26]!==w||e[27]!==f?(p=(0,u.jsxs)("li",{className:"group/q flex items-center",children:[f,w]}),e[26]=w,e[27]=f,e[28]=p):p=e[28],p},"ns"),it="sql-history-remember",tr=l((s,e)=>{let n=e.trim().toLowerCase();return n===""?[...s]:s.filter(t=>t.name.toLowerCase().includes(n))},"ss"),nr=l(s=>{let e=(0,G.c)(66),{activeId:n,history:t,listRef:o,onClearHistory:r,onDelete:a,onLoadHistory:c,onLoadTemplate:i,onNew:d,onSearchChange:h,onSelect:b,onToggleRememberHistory:g,queries:v,rememberHistory:m,search:S}=s,f=ce(),y,x,q,w,p;if(e[0]!==n||e[1]!==o||e[2]!==a||e[3]!==d||e[4]!==h||e[5]!==b||e[6]!==g||e[7]!==v||e[8]!==S||e[9]!==f){let L=tr(v,S),F;e[15]!==g?(F=l(z=>{g(z.target.checked)},"B"),e[15]=g,e[16]=F):F=e[16],y=F,q="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let M;e[17]!==f?(M=f("Search queries\u2026"),e[17]=f,e[18]=M):M=e[18];let H;e[19]!==h||e[20]!==S||e[21]!==M?(H=(0,u.jsx)("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:h,placeholder:M,type:"text",value:S}),e[19]=h,e[20]=S,e[21]=M,e[22]=H):H=e[22];let D;e[23]!==f?(D=f("New query"),e[23]=f,e[24]=D):D=e[24];let C;e[25]!==f?(C=f("New query"),e[25]=f,e[26]=C):C=e[26];let P;e[27]===Symbol.for("react.memo_cache_sentinel")?(P=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[27]=P):P=e[27];let _;e[28]!==d||e[29]!==D||e[30]!==C?(_=(0,u.jsx)("button",{"aria-label":D,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:d,title:C,type:"button",children:P}),e[28]=d,e[29]=D,e[30]=C,e[31]=_):_=e[31],e[32]!==_||e[33]!==H?(w=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[H,_]}),e[32]=_,e[33]=H,e[34]=w):w=e[34],x="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let $;e[35]!==f?($=f("Private"),e[35]=f,e[36]=$):$=e[36];let W;e[37]!==$?(W=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:$}),e[37]=$,e[38]=W):W=e[38],p=(0,u.jsxs)("div",{children:[W,L.length===0?(0,u.jsx)("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:f("No saved queries yet \u2014 they save to this browser as you type.")}):(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:o,children:L.map(z=>(0,u.jsx)(er,{active:n===z.id,onDelete:a,onSelect:b,query:z},z.id))})]}),e[0]=n,e[1]=o,e[2]=a,e[3]=d,e[4]=h,e[5]=b,e[6]=g,e[7]=v,e[8]=S,e[9]=f,e[10]=y,e[11]=x,e[12]=q,e[13]=w,e[14]=p}else y=e[10],x=e[11],q=e[12],w=e[13],p=e[14];let N;e[39]!==f?(N=f("Reference"),e[39]=f,e[40]=N):N=e[40];let k;e[41]!==N?(k=(0,u.jsx)("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:N}),e[41]=N,e[42]=k):k=e[42];let R;e[43]!==i?(R=yt.map(L=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":L.sql,onClick:i,type:"button",children:[(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),L.label]})},L.label)),e[43]=i,e[44]=R):R=e[44];let T;e[45]!==R?(T=(0,u.jsx)("ul",{className:"flex flex-col gap-px",children:R}),e[45]=R,e[46]=T):T=e[46];let E;e[47]!==k||e[48]!==T?(E=(0,u.jsxs)("div",{children:[k,T]}),e[47]=k,e[48]=T,e[49]=E):E=e[49];let I;e[50]!==t||e[51]!==r||e[52]!==c||e[53]!==y||e[54]!==m||e[55]!==f?(I=t.length>0&&(0,u.jsxs)("div",{children:[(0,u.jsxs)("div",{className:"flex items-center justify-between px-1 pb-1",children:[(0,u.jsx)("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f("History")}),(0,u.jsx)("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:r,type:"button",children:f("Clear history")})]}),(0,u.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 px-1 pb-1.5 text-[11px] text-muted-foreground",htmlFor:it,children:[(0,u.jsx)("input",{checked:m,"data-testid":"sql-history-remember",id:it,onChange:y,type:"checkbox"}),f("Keep history on this browser")]}),(0,u.jsx)("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:t.map(L=>(0,u.jsx)("li",{children:(0,u.jsxs)("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":L.sql,"data-testid":"sql-history-item",onClick:c,title:L.sql,type:"button",children:[(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),(0,u.jsx)("span",{className:"truncate font-mono",children:L.sql})]})},`${L.at.toString()}:${L.sql}`))})]}),e[50]=t,e[51]=r,e[52]=c,e[53]=y,e[54]=m,e[55]=f,e[56]=I):I=e[56];let O;e[57]!==x||e[58]!==I||e[59]!==p||e[60]!==E?(O=(0,u.jsxs)("div",{className:x,children:[p,E,I]}),e[57]=x,e[58]=I,e[59]=p,e[60]=E,e[61]=O):O=e[61];let A;return e[62]!==O||e[63]!==q||e[64]!==w?(A=(0,u.jsxs)("aside",{className:q,children:[w,O]}),e[62]=O,e[63]=q,e[64]=w,e[65]=A):A=e[65],A},"os"),Ae=l(s=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${s?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,"Ie"),rr=l(s=>{let e=(0,G.c)(96),{assistant:n,chart:t,className:o,error:r,onFormat:a,onInferChart:c,onRun:i,onSelectStatement:d,onShardKeyChange:h,onShowChart:b,onShowExplain:g,onShowResults:v,onToggleSplit:m,pane:S,result:f,running:y,script:x,shardKey:q,splitView:w}=s,p=ce(),N=S==="results",k;e[0]!==N?(k=Ae(N),e[0]=N,e[1]=k):k=e[1];let R;e[2]!==p?(R=p("Results"),e[2]=p,e[3]=R):R=e[3];let T;e[4]!==v||e[5]!==k||e[6]!==R?(T=(0,u.jsx)("button",{className:k,"data-testid":"sql-tab-results",onClick:v,type:"button",children:R}),e[4]=v,e[5]=k,e[6]=R,e[7]=T):T=e[7];let E=S==="chart",I;e[8]!==E?(I=Ae(E),e[8]=E,e[9]=I):I=e[9];let O;e[10]!==p?(O=p("Chart"),e[10]=p,e[11]=O):O=e[11];let A;e[12]!==b||e[13]!==I||e[14]!==O?(A=(0,u.jsx)("button",{className:I,"data-testid":"sql-tab-chart",onClick:b,type:"button",children:O}),e[12]=b,e[13]=I,e[14]=O,e[15]=A):A=e[15];let L;e[16]!==n||e[17]!==c||e[18]!==S||e[19]!==f||e[20]!==p?(L=!n.unavailable&&S==="chart"&&f!==null&&(0,u.jsx)("button",{className:Ae(!1),"data-testid":"sql-infer-chart",disabled:n.pending("chart"),onClick:c,type:"button",children:n.pending("chart")?p("Thinking\u2026"):p("Suggest chart")}),e[16]=n,e[17]=c,e[18]=S,e[19]=f,e[20]=p,e[21]=L):L=e[21];let F=S==="explain",M;e[22]!==F?(M=Ae(F),e[22]=F,e[23]=M):M=e[23];let H;e[24]!==p?(H=p("Explain"),e[24]=p,e[25]=H):H=e[25];let D;e[26]!==g||e[27]!==M||e[28]!==H?(D=(0,u.jsx)("button",{className:M,"data-testid":"sql-tab-explain",onClick:g,type:"button",children:H}),e[26]=g,e[27]=M,e[28]=H,e[29]=D):D=e[29];let C;e[30]!==p?(C=p("Split editor and results"),e[30]=p,e[31]=C):C=e[31];let P=`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${w?"bg-accent text-foreground":"text-muted-foreground"}`,_;e[32]!==p?(_=p("Split editor and results"),e[32]=p,e[33]=_):_=e[33];let $;e[34]===Symbol.for("react.memo_cache_sentinel")?($=(0,u.jsxs)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[(0,u.jsx)("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),(0,u.jsx)("path",{d:"M12 4v16"})]}),e[34]=$):$=e[34];let W;e[35]!==m||e[36]!==w||e[37]!==C||e[38]!==P||e[39]!==_?(W=(0,u.jsx)("button",{"aria-label":C,"aria-pressed":w,className:P,"data-testid":"sql-split-toggle",onClick:m,title:_,type:"button",children:$}),e[35]=m,e[36]=w,e[37]=C,e[38]=P,e[39]=_,e[40]=W):W=e[40];let z;e[41]!==f?(z=f!==null&&f.columns.length>0&&(0,u.jsx)(tt,{columns:f.columns,name:"query-result",rows:f.rows}),e[41]=f,e[42]=z):z=e[42];let J;e[43]!==p?(J=p("Format"),e[43]=p,e[44]=J):J=e[44];let Z;e[45]!==a||e[46]!==y||e[47]!==J?(Z=(0,u.jsx)("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:y,onClick:a,type:"button",children:J}),e[45]=a,e[46]=y,e[47]=J,e[48]=Z):Z=e[48];let ee;e[49]!==h||e[50]!==q?(ee=(0,u.jsx)(Xe,{onChange:h,testId:"sql-shard-input",value:q}),e[49]=h,e[50]=q,e[51]=ee):ee=e[51];let te;e[52]!==y||e[53]!==p?(te=p(y?"Running\u2026":"Run"),e[52]=y,e[53]=p,e[54]=te):te=e[54];let ie;e[55]===Symbol.for("react.memo_cache_sentinel")?(ie=(0,u.jsx)("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"\u2318\u21B5"}),e[55]=ie):ie=e[55];let V;e[56]!==i||e[57]!==y||e[58]!==te?(V=(0,u.jsxs)("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:y,onClick:i,type:"button",children:[te,ie]}),e[56]=i,e[57]=y,e[58]=te,e[59]=V):V=e[59];let Q;e[60]!==W||e[61]!==z||e[62]!==Z||e[63]!==ee||e[64]!==V?(Q=(0,u.jsxs)("div",{className:"ms-auto flex items-center gap-2",children:[W,z,Z,ee,V]}),e[60]=W,e[61]=z,e[62]=Z,e[63]=ee,e[64]=V,e[65]=Q):Q=e[65];let ne;e[66]!==D||e[67]!==Q||e[68]!==T||e[69]!==A||e[70]!==L?(ne=(0,u.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[T,A,L,D,Q]}),e[66]=D,e[67]=Q,e[68]=T,e[69]=A,e[70]=L,e[71]=ne):ne=e[71];let re;e[72]!==d||e[73]!==x?(re=x!==void 0&&(0,u.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-1 border-b border-border px-3 py-1.5","data-testid":"sql-statements",children:x.runs.map((Y,X)=>(0,u.jsx)("button",{"aria-pressed":X===x.selected,className:`rounded-md border px-2 py-0.5 font-mono text-[11px] outline-none transition-colors ${X===x.selected?"border-foreground text-foreground":"border-border text-muted-foreground hover:text-foreground"} ${Y.error===null?"":"border-destructive/50 text-destructive"}`,"data-testid":`sql-statement-${X.toString()}`,onClick:l(()=>{d(X)},"onClick"),title:Y.sql,type:"button",children:X+1},`${X.toString()}:${Y.sql}`))}),e[72]=d,e[73]=x,e[74]=re):re=e[74];let oe;e[75]!==r?(oe=r!==null&&(0,u.jsx)(Je,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:r}),e[75]=r,e[76]=oe):oe=e[76];let se;e[77]!==r||e[78]!==f||e[79]!==p?(se=r===null&&f===null&&(0,u.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:p("Click Run to execute your query.")}),e[77]=r,e[78]=f,e[79]=p,e[80]=se):se=e[80];let le;e[81]!==t||e[82]!==r||e[83]!==S||e[84]!==f||e[85]!==p?(le=r===null&&f!==null&&(0,u.jsxs)("div",{"data-testid":"sql-result",children:[S==="chart"?(0,u.jsx)(nt,{axes:t,result:f}):(0,u.jsx)(rt,{result:f}),(0,u.jsx)("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:f.truncated?p("Showing the first {max} of {count} rows.",{count:f.rowCount,max:f.rows.length}):p("{count} rows",{count:f.rowCount})})]}),e[81]=t,e[82]=r,e[83]=S,e[84]=f,e[85]=p,e[86]=le):le=e[86];let B;e[87]!==oe||e[88]!==se||e[89]!==le?(B=(0,u.jsxs)("div",{className:"min-h-0 flex-1 overflow-auto",children:[oe,se,le]}),e[87]=oe,e[88]=se,e[89]=le,e[90]=B):B=e[90];let U;return e[91]!==o||e[92]!==ne||e[93]!==re||e[94]!==B?(U=(0,u.jsxs)("div",{className:o,children:[ne,re,B]}),e[91]=o,e[92]=ne,e[93]=re,e[94]=B,e[95]=U):U=e[95],U},"ls"),or=l((s,e)=>s.trim()===""?e:(s.split(`
8
+ `)[0]??s).slice(0,24),"rs"),sr=l(s=>{s?.focus(),s?.select()},"is"),lr=l(s=>{let e=(0,G.c)(14),{initial:n,onCancel:t,onCommit:o,placeholder:r,testId:a}=s,c=ce(),i;e[0]!==o?(i=l(m=>{o(m.currentTarget.value.trim())},"a"),e[0]=o,e[1]=i):i=e[1];let d=i,h;e[2]!==t||e[3]!==o?(h=l(m=>{m.key==="Enter"?o(m.currentTarget.value.trim()):m.key==="Escape"&&t()},"f"),e[2]=t,e[3]=o,e[4]=h):h=e[4];let b=h,g;e[5]!==c?(g=c("Tab title"),e[5]=c,e[6]=g):g=e[6];let v;return e[7]!==n||e[8]!==d||e[9]!==b||e[10]!==r||e[11]!==g||e[12]!==a?(v=(0,u.jsx)("input",{"aria-label":g,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":a,defaultValue:n,onBlur:d,onKeyDown:b,placeholder:r,ref:sr,type:"text"}),e[7]=n,e[8]=d,e[9]=b,e[10]=r,e[11]=g,e[12]=a,e[13]=v):v=e[13],v},"as"),ar=l(s=>{let e=(0,G.c)(29),{idBase:n,onDiscard:t,onKeep:o}=s,r=ce(),a=`sql-tab-close-prompt-${n}`,c;e[0]!==r?(c=r("Discard?"),e[0]=r,e[1]=c):c=e[1];let i;e[2]!==c?(i=(0,u.jsx)("span",{className:"text-[11px] text-muted-foreground",children:c}),e[2]=c,e[3]=i):i=e[3];let d;e[4]!==r?(d=r("Discard changes"),e[4]=r,e[5]=d):d=e[5];let h=`sql-tab-close-confirm-${n}`,b;e[6]!==r?(b=r("Discard changes"),e[6]=r,e[7]=b):b=e[7];let g;e[8]===Symbol.for("react.memo_cache_sentinel")?(g=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M5 13l4 4L19 7"})}),e[8]=g):g=e[8];let v;e[9]!==t||e[10]!==d||e[11]!==h||e[12]!==b?(v=(0,u.jsx)("button",{"aria-label":d,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":h,onClick:t,title:b,type:"button",children:g}),e[9]=t,e[10]=d,e[11]=h,e[12]=b,e[13]=v):v=e[13];let m;e[14]!==r?(m=r("Keep editing"),e[14]=r,e[15]=m):m=e[15];let S=`sql-tab-close-cancel-${n}`,f;e[16]!==r?(f=r("Keep editing"),e[16]=r,e[17]=f):f=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=y):y=e[18];let x;e[19]!==o||e[20]!==S||e[21]!==f||e[22]!==m?(x=(0,u.jsx)("button",{"aria-label":m,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":S,onClick:o,title:f,type:"button",children:y}),e[19]=o,e[20]=S,e[21]=f,e[22]=m,e[23]=x):x=e[23];let q;return e[24]!==a||e[25]!==x||e[26]!==i||e[27]!==v?(q=(0,u.jsxs)("span",{className:"flex shrink-0 items-center gap-1","data-testid":a,role:"group",children:[i,v,x]}),e[24]=a,e[25]=x,e[26]=i,e[27]=v,e[28]=q):q=e[28],q},"cs"),ir=l(s=>{let e=(0,G.c)(47),{active:n,canClose:t,onClose:o,onMenu:r,onRename:a,onSelect:c,tab:i}=s,d=ce(),[h,b]=(0,j.useState)(!1),[g,v]=(0,j.useState)(!1),m;e[0]!==r||e[1]!==i.id?(m=l(z=>{r(i.id,z)},"d"),e[0]=r,e[1]=i.id,e[2]=m):m=e[2];let S=m,f;e[3]!==c||e[4]!==i.id?(f=l(()=>{c(i.id)},"u"),e[3]=c,e[4]=i.id,e[5]=f):f=e[5];let y=f,x;e[6]===Symbol.for("react.memo_cache_sentinel")?(x=l(()=>{b(!0)},"g"),e[6]=x):x=e[6];let q=x,w;e[7]!==o||e[8]!==i?(w=l(z=>{z.stopPropagation(),xt(i)?v(!0):o(i.id)},"y"),e[7]=o,e[8]=i,e[9]=w):w=e[9];let p=w,N;e[10]!==o||e[11]!==i.id?(N=l(z=>{z.stopPropagation(),v(!1),o(i.id)},"E"),e[10]=o,e[11]=i.id,e[12]=N):N=e[12];let k=N,R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=l(z=>{z.stopPropagation(),v(!1)},"R"),e[13]=R):R=e[13];let T=R,E;e[14]!==a||e[15]!==i.id?(E=l(z=>{a(i.id,z),b(!1)},"_"),e[14]=a,e[15]=i.id,e[16]=E):E=e[16];let I=E,O;e[17]===Symbol.for("react.memo_cache_sentinel")?(O=l(()=>{b(!1)},"A"),e[17]=O):O=e[17];let A=O,L;e[18]!==i.name?(L=i.name.trim(),e[18]=i.name,e[19]=L):L=e[19];let F=L,M;e[20]!==d||e[21]!==i.sql?(M=or(i.sql,d("Untitled")),e[20]=d,e[21]=i.sql,e[22]=M):M=e[22];let H=M,D=n?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground",C;e[23]!==D?(C=me("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",D),e[23]=D,e[24]=C):C=e[24];let P=`sql-tab-${i.id}`,_;e[25]!==n||e[26]!==I||e[27]!==F||e[28]!==H||e[29]!==h||e[30]!==y||e[31]!==d||e[32]!==i.id?(_=h?(0,u.jsx)(lr,{initial:F,onCancel:A,onCommit:I,placeholder:H,testId:`sql-tab-rename-${i.id}`}):(0,u.jsx)("button",{"aria-pressed":n,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${i.id}`,onClick:y,onDoubleClick:q,title:d("Double-click to rename"),type:"button",children:F===""?H:F}),e[25]=n,e[26]=I,e[27]=F,e[28]=H,e[29]=h,e[30]=y,e[31]=d,e[32]=i.id,e[33]=_):_=e[33];let $;e[34]!==t||e[35]!==k||e[36]!==g||e[37]!==p||e[38]!==d||e[39]!==i.id?($=t&&(g?(0,u.jsx)(ar,{idBase:i.id,onDiscard:k,onKeep:T}):(0,u.jsx)("button",{"aria-label":d("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${i.id}`,onClick:p,title:d("Close tab"),type:"button",children:(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=t,e[35]=k,e[36]=g,e[37]=p,e[38]=d,e[39]=i.id,e[40]=$):$=e[40];let W;return e[41]!==S||e[42]!==C||e[43]!==P||e[44]!==_||e[45]!==$?(W=(0,u.jsxs)("div",{className:C,"data-testid":P,onContextMenu:S,children:[_,$]}),e[41]=S,e[42]=C,e[43]=P,e[44]=_,e[45]=$,e[46]=W):W=e[46],W},"ds"),cr=l(s=>{let e=(0,G.c)(43),{model:n,onSelect:t}=s,o=ce(),{activeTab:r,addEditorTab:a,cancelBulk:c,closeEditorTab:i,closeTabMenu:d,confirmBulk:h,menuStyle:b,onBackdropContextMenu:g,onCloseAll:v,onCloseOthers:m,onCloseToRight:S,openTabMenu:f,pendingBulk:y,renameTab:x,tabMenu:q,tabs:w}=n,p;if(e[0]!==r||e[1]!==i||e[2]!==t||e[3]!==f||e[4]!==x||e[5]!==w){let L;e[7]!==r||e[8]!==i||e[9]!==t||e[10]!==f||e[11]!==x||e[12]!==w.length?(L=l(F=>(0,u.jsx)(ir,{active:F.id===r.id,canClose:w.length>1,onClose:i,onMenu:f,onRename:x,onSelect:t,tab:F},F.id),"I"),e[7]=r,e[8]=i,e[9]=t,e[10]=f,e[11]=x,e[12]=w.length,e[13]=L):L=e[13],p=w.map(L),e[0]=r,e[1]=i,e[2]=t,e[3]=f,e[4]=x,e[5]=w,e[6]=p}else p=e[6];let N;e[14]!==o?(N=o("New tab"),e[14]=o,e[15]=N):N=e[15];let k=w.length>=We,R;e[16]!==o?(R=o("New tab"),e[16]=o,e[17]=R):R=e[17];let T;e[18]===Symbol.for("react.memo_cache_sentinel")?(T=(0,u.jsx)("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:(0,u.jsx)("path",{d:"M12 5v14M5 12h14"})}),e[18]=T):T=e[18];let E;e[19]!==a||e[20]!==N||e[21]!==k||e[22]!==R?(E=(0,u.jsx)("button",{"aria-label":N,className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:k,onClick:a,title:R,type:"button",children:T}),e[19]=a,e[20]=N,e[21]=k,e[22]=R,e[23]=E):E=e[23];let I;e[24]!==p||e[25]!==E?(I=(0,u.jsxs)("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[p,E]}),e[24]=p,e[25]=E,e[26]=I):I=e[26];let O;e[27]!==c||e[28]!==d||e[29]!==h||e[30]!==b||e[31]!==g||e[32]!==v||e[33]!==m||e[34]!==S||e[35]!==y||e[36]!==o||e[37]!==q||e[38]!==w?(O=q!==null&&(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:d,onContextMenu:g,role:"presentation"}),(0,u.jsx)("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:b,children:y===null?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:w.length<=1,onClick:m,role:"menuitem",type:"button",children:o("Close other tabs")}),(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:w.findIndex(L=>L.id===q.id)>=w.length-1,onClick:S,role:"menuitem",type:"button",children:o("Close tabs to the right")}),(0,u.jsx)("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:v,role:"menuitem",type:"button",children:o("Close all tabs")})]}):(0,u.jsxs)("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[(0,u.jsx)("p",{className:"pb-1.5 text-xs text-muted-foreground",children:o("Discard unsaved tabs?")}),(0,u.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,u.jsx)("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:h,type:"button",children:o("Discard")}),(0,u.jsx)("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:c,type:"button",children:o("Cancel")})]})]})})]}),e[27]=c,e[28]=d,e[29]=h,e[30]=b,e[31]=g,e[32]=v,e[33]=m,e[34]=S,e[35]=y,e[36]=o,e[37]=q,e[38]=w,e[39]=O):O=e[39];let A;return e[40]!==I||e[41]!==O?(A=(0,u.jsxs)(u.Fragment,{children:[I,O]}),e[40]=I,e[41]=O,e[42]=A):A=e[42],A},"us"),dr=Se(qe.runSql),ur="lunora-studio-sql-split-view",mr=l(()=>ke(yt[0]?.sql??""),"hs"),Tr=l(s=>{let e=(0,G.c)(112),{initialShardKey:n}=s,t=Ie(),o=Fn(mr),{activeTab:r,output:a,patchActiveOutput:c,patchActiveTab:i,setActiveTabId:d,unlinkQuery:h}=o,b;e[0]!==c||e[1]!==i?(b=l((K,ae)=>{i({activeId:ae,sql:K}),c({chart:void 0,error:null,failed:void 0,result:null,script:void 0})},"p"),e[0]=c,e[1]=i,e[2]=b):b=e[2];let g=b,v;e[3]!==g||e[4]!==h?(v={loadIntoActiveTab:g,unlinkQuery:h},e[3]=g,e[4]=h,e[5]=v):v=e[5];let m=jn(v),{recordHistory:S,updateQuerySql:f}=m,y=r.sql,{activeId:x}=r,{chart:q,error:w,failed:p,result:N,running:k}=a,R=a.pane,[T,E]=(0,j.useState)(n??""),[I,O]=Le(ur,!1),{probe:A,schema:L}=qn(T),F;e[6]!==x||e[7]!==i||e[8]!==f?(F=l(K=>{i({sql:K}),x!==null&&f(x,K)},"B"),e[6]=x,e[7]=i,e[8]=f,e[9]=F):F=e[9];let M=F,H=an(y,L,T),D=et(T),C;e[10]!==D||e[11]!==c||e[12]!==N?(C=l(()=>{N!==null&&ue((async()=>{let K=await D.inferChart({columns:N.columns,rowCount:N.rowCount,types:Object.fromEntries(N.columns.map(ae=>[ae,typeof(N.rows[0]?.[ae]??"")]))});c({chart:K})})())},"k"),e[10]=D,e[11]=c,e[12]=N,e[13]=C):C=e[13];let P=C,_;e[14]!==t||e[15]!==S||e[16]!==T?(_=l(async K=>{try{let ae=await t.query(dr,{sql:K},Ne(T));return S(K),{error:null,result:ae,sql:K}}catch(ae){return{error:Ge(ae),result:null,sql:K}}},"L"),e[14]=t,e[15]=S,e[16]=T,e[17]=_):_=e[17];let $=_,W;e[18]!==y||e[19]!==c||e[20]!==$||e[21]!==T?(W=l(async K=>{if(y.trim()==="")return;c({running:!0});let ae=K==="explain"?Qe(At(y),0):ft(y),de=[];for(let _e of ae){let wt={error:_e.rejection?.message??"",result:null,sql:_e.sql};de.push(_e.rejection===void 0?await $(_e.sql):wt)}Ve(T);let Ue=Math.max(de.length-1,0),ye=de[Ue];c({chart:void 0,error:ye?.error??null,failed:ye?.error===null||ye===void 0?void 0:{error:ye.error,sql:ye.sql},pane:K,result:ye?.result??null,running:!1,script:de.length>1?{runs:de,selected:Ue}:void 0})},"z"),e[18]=y,e[19]=c,e[20]=$,e[21]=T,e[22]=W):W=e[22];let z=W,J;e[23]!==a.script?.runs||e[24]!==c?(J=l(K=>{let ae=a.script?.runs,de=ae?.[K];ae===void 0||de===void 0||c({chart:void 0,error:de.error,failed:de.error===null?void 0:{error:de.error,sql:de.sql},result:de.result,script:{runs:ae,selected:K}})},"X"),e[23]=a.script?.runs,e[24]=c,e[25]=J):J=e[25];let Z=J,ee;e[26]!==z?(ee=l(()=>{ue(z("results"))},"ee"),e[26]=z,e[27]=ee):ee=e[27];let te=ee,ie;e[28]!==a.pane||e[29]!==z?(ie=l(()=>{ue(z(a.pane))},"ae"),e[28]=a.pane,e[29]=z,e[30]=ie):ie=e[30];let V;e[31]!==A||e[32]!==L||e[33]!==M||e[34]!==ie?(V={onSubmit:ie,probe:A,schema:L,setDraft:M},e[31]=A,e[32]=L,e[33]=M,e[34]=ie,e[35]=V):V=e[35];let Q=Tn(V),{closeAutocomplete:ne}=Q,re;e[36]!==y||e[37]!==M?(re=l(()=>{M(Bt(y))},"se"),e[36]=y,e[37]=M,e[38]=re):re=e[38];let oe=re,se;e[39]!==ne||e[40]!==d?(se=l(K=>{ne(),d(K)},"le"),e[39]=ne,e[40]=d,e[41]=se):se=e[41];let le=se,B;e[42]!==c?(B=l(()=>{c({pane:"results"})},"H"),e[42]=c,e[43]=B):B=e[43];let U=B,Y;e[44]!==z?(Y=l(()=>{ue(z("explain"))},"j"),e[44]=z,e[45]=Y):Y=e[45];let X=Y,fe;e[46]!==c?(fe=l(()=>{c({pane:"chart"})},"me"),e[46]=c,e[47]=fe):fe=e[47];let Me=fe,Te;e[48]!==O||e[49]!==I?(Te=l(()=>{O(!I)},"ke"),e[48]=O,e[49]=I,e[50]=Te):Te=e[50];let $e=Te,Fe=I?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",ze=I?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border",he;e[51]!==x||e[52]!==m.clearHistory||e[53]!==m.deleteQuery||e[54]!==m.history||e[55]!==m.listRef||e[56]!==m.loadFromHistory||e[57]!==m.loadTemplate||e[58]!==m.newQuery||e[59]!==m.onSearchChange||e[60]!==m.queries||e[61]!==m.rememberHistory||e[62]!==m.search||e[63]!==m.selectQuery||e[64]!==m.setRememberHistory?(he=(0,u.jsx)(nr,{activeId:x,history:m.history,listRef:m.listRef,onClearHistory:m.clearHistory,onDelete:m.deleteQuery,onLoadHistory:m.loadFromHistory,onLoadTemplate:m.loadTemplate,onNew:m.newQuery,onSearchChange:m.onSearchChange,onSelect:m.selectQuery,onToggleRememberHistory:m.setRememberHistory,queries:m.queries,rememberHistory:m.rememberHistory,search:m.search}),e[51]=x,e[52]=m.clearHistory,e[53]=m.deleteQuery,e[54]=m.history,e[55]=m.listRef,e[56]=m.loadFromHistory,e[57]=m.loadTemplate,e[58]=m.newQuery,e[59]=m.onSearchChange,e[60]=m.queries,e[61]=m.rememberHistory,e[62]=m.search,e[63]=m.selectQuery,e[64]=m.setRememberHistory,e[65]=he):he=e[65];let pe;e[66]!==o||e[67]!==le?(pe=(0,u.jsx)(cr,{model:o,onSelect:le}),e[66]=o,e[67]=le,e[68]=pe):pe=e[68];let be;e[69]!==D||e[70]!==H||e[71]!==y||e[72]!==p||e[73]!==M||e[74]!==Q.autocompleteState||e[75]!==Q.editorRef||e[76]!==Q.gutterRef||e[77]!==Q.handlers||e[78]!==Q.listboxId||e[79]!==Q.onPickSuggestion||e[80]!==Q.overlayRef||e[81]!==Q.revealDiagnostic?(be=(0,u.jsx)(Jn,{assistant:D,autocomplete:Q.autocompleteState,diagnostics:H,draft:y,editorRef:Q.editorRef,failed:p,gutterRef:Q.gutterRef,handlers:Q.handlers,listboxId:Q.listboxId,onGenerated:M,onPickSuggestion:Q.onPickSuggestion,onRevealDiagnostic:Q.revealDiagnostic,overlayRef:Q.overlayRef}),e[69]=D,e[70]=H,e[71]=y,e[72]=p,e[73]=M,e[74]=Q.autocompleteState,e[75]=Q.editorRef,e[76]=Q.gutterRef,e[77]=Q.handlers,e[78]=Q.listboxId,e[79]=Q.onPickSuggestion,e[80]=Q.overlayRef,e[81]=Q.revealDiagnostic,e[82]=be):be=e[82];let ge;e[83]!==D||e[84]!==w||e[85]!==oe||e[86]!==P||e[87]!==q||e[88]!==te||e[89]!==Z||e[90]!==a.script||e[91]!==N||e[92]!==ze||e[93]!==k||e[94]!==T||e[95]!==Me||e[96]!==X||e[97]!==U||e[98]!==I||e[99]!==R||e[100]!==$e?(ge=(0,u.jsx)(rr,{assistant:D,chart:q,className:ze,error:w,onFormat:oe,onInferChart:P,onRun:te,onSelectStatement:Z,onShardKeyChange:E,onShowChart:Me,onShowExplain:X,onShowResults:U,onToggleSplit:$e,pane:R,result:N,running:k,script:a.script,shardKey:T,splitView:I}),e[83]=D,e[84]=w,e[85]=oe,e[86]=P,e[87]=q,e[88]=te,e[89]=Z,e[90]=a.script,e[91]=N,e[92]=ze,e[93]=k,e[94]=T,e[95]=Me,e[96]=X,e[97]=U,e[98]=I,e[99]=R,e[100]=$e,e[101]=ge):ge=e[101];let xe;e[102]!==be||e[103]!==ge||e[104]!==Fe?(xe=(0,u.jsxs)("div",{className:Fe,children:[be,ge]}),e[102]=be,e[103]=ge,e[104]=Fe,e[105]=xe):xe=e[105];let ve;e[106]!==pe||e[107]!==xe?(ve=(0,u.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col",children:[pe,xe]}),e[106]=pe,e[107]=xe,e[108]=ve):ve=e[108];let Re;return e[109]!==he||e[110]!==ve?(Re=(0,u.jsxs)("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[he,ve]}),e[109]=he,e[110]=ve,e[111]=Re):Re=e[111],Re},"As");export{Tr as SqlEditorPanel};
@@ -0,0 +1 @@
1
+ import{a as u,d as y,e as d}from"./chunk-YKXDMIHQ.js";var t=y(d(),1);var S=u((r,a=400)=>{let e=(r??"").trim(),[o,c]=(0,t.useState)(e),[i,n]=(0,t.useState)(e),m=(0,t.useRef)(r);m.current!==r&&(m.current=r,c(e),n(e));let f=o.trim();return(0,t.useEffect)(()=>{let s=setTimeout(()=>{n(f)},a);return()=>{clearTimeout(s)}},[f,a]),{queryShardKey:i,setShardKey:u(s=>{c(s)},"setShardKey"),shardKey:o}},"f");export{S as a};
@@ -0,0 +1 @@
1
+ import{a as Be,b as Ue,c as We,d as De,e as we}from"./chunk-IHMGCHAA.js";import"./chunk-4JLGLPWV.js";import"./chunk-V3CZW3JB.js";import{a as Ve}from"./chunk-MRAMNVDG.js";import{a as qe}from"./chunk-Z5O2NQAV.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{a as Le}from"./chunk-S3CRZLGS.js";import{a as _e}from"./chunk-EJSI4PMU.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as ke}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as ie}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as me}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{c as Ee}from"./chunk-ERHFRNCL.js";import{f as Ne}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import{b as Ie,c as $e}from"./chunk-LCXKALTS.js";import{a as Ae}from"./chunk-FKVZRPV5.js";import{a as ze,b as Re,c as je,d as pe,e as B,f as z}from"./chunk-HEAQVSNS.js";import{a as Me,e as Ce}from"./chunk-WUWBZPUK.js";import{d as ue,f as re,g as be,h as Ke,p as le,t as Te}from"./chunk-PTZD7RUZ.js";import{a as d,d as ye,e as Oe,f as Ge,g as He}from"./chunk-YKXDMIHQ.js";var ge=ye(Ge(),1);var ne=ye(Oe(),1);var t=ye(He(),1);var Se="none",Je=["all","open","resolved","ignored"],Pe=["critical","high","medium","low"],Qe=re(U.resolveIssue),Xe=re(U.ignoreIssue),Fe=re(U.assignIssue),Ye=re(U.setIssueSeverity),Ze=re(U.explainIssue),es=d(n=>Array.isArray(n?.issues)?n.issues:[],"Xe"),ss=d(n=>n==="resolved"?"success":n==="ignored"?"secondary":"warning","Je"),ts=d(n=>n==="critical"?"destructive":n==="high"?"warning":n==="medium"?"info":"secondary","Ze"),as=d(n=>{let e=(0,ge.c)(44),{expanded:u,issue:s,shardKey:$}=n,i=Ne(),l=ue(),[a,o]=(0,ne.useState)(void 0),{busy:_,error:A,run:R}=Ve(),K;e[0]!==i||e[1]!==s||e[2]!==R||e[3]!==$?(K=d(()=>{o(void 0),R(async()=>{let g={culprit:s.culprit,sampleMessage:s.sampleMessage,title:s.title},I=await i.query(Ze,g,be($));o(I)})},"C"),e[0]=i,e[1]=s,e[2]=R,e[3]=$,e[4]=K):K=e[4];let L=K;if(!u)return null;let k;if(e[5]!==s.sampleMessage){let g=$e(s.sampleMessage);k=g===void 0?void 0:Ie(g.body),e[5]=s.sampleMessage,e[6]=k}else k=e[6];let T=k,E=`issues-detail-${s.hash}`,h;e[7]!==s.sampleMessage?(h=(0,t.jsx)("p",{className:"whitespace-pre-wrap font-mono text-xs text-muted-foreground",children:s.sampleMessage}),e[7]=s.sampleMessage,e[8]=h):h=e[8];let x;e[9]!==l?(x=l("Suggested fix"),e[9]=l,e[10]=x):x=e[10];let M;e[11]!==x?(M=(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:x}),e[11]=x,e[12]=M):M=e[12];let v;e[13]!==T||e[14]!==s.hash||e[15]!==l?(v=T===void 0?(0,t.jsx)("p",{className:"mt-1 text-sm text-muted-foreground","data-testid":`issues-hint-empty-${s.hash}`,children:l("No known fix for this error yet.")}):(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm","data-testid":`issues-hint-${s.hash}`,children:T}),e[13]=T,e[14]=s.hash,e[15]=l,e[16]=v):v=e[16];let y;e[17]!==M||e[18]!==v?(y=(0,t.jsxs)("div",{children:[M,v]}),e[17]=M,e[18]=v,e[19]=y):y=e[19];let b=`issues-explain-${s.hash}`,w;e[20]!==_||e[21]!==l?(w=l(_?"Explaining\u2026":"Explain in plain language"),e[20]=_,e[21]=l,e[22]=w):w=e[22];let m;e[23]!==_||e[24]!==L||e[25]!==w||e[26]!==b?(m=(0,t.jsx)("div",{children:(0,t.jsx)(ie,{"data-testid":b,disabled:_,onClick:L,size:"sm",type:"button",variant:"outline",children:w})}),e[23]=_,e[24]=L,e[25]=w,e[26]=b,e[27]=m):m=e[27];let f;e[28]!==A||e[29]!==s.hash?(f=A!==null&&(0,t.jsx)("p",{className:"text-xs text-destructive","data-testid":`issues-explain-error-${s.hash}`,role:"alert",children:A}),e[28]=A,e[29]=s.hash,e[30]=f):f=e[30];let p;e[31]!==a||e[32]!==s.hash||e[33]!==l?(p=a!==void 0&&(a.degraded?(0,t.jsx)("p",{className:"text-xs text-muted-foreground","data-testid":`issues-degraded-${s.hash}`,children:a.reason==="no-ai-binding"?l("No AI binding is configured. Wire an AI binding to enable plain-language explanations \u2014 the suggested fix above is always available."):l("The AI model could not explain this error right now. The suggested fix above still applies.")}):(0,t.jsxs)("div",{"data-testid":`issues-explanation-${s.hash}`,children:[(0,t.jsx)("div",{className:"text-xs font-medium text-muted-foreground",children:l("AI explanation")}),(0,t.jsx)("p",{className:"mt-1 whitespace-pre-wrap text-sm",children:a.explanation}),a.groundedId===void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-muted-foreground","data-testid":`issues-ungrounded-${s.hash}`,children:l("No catalog fix matched this error, so this explanation is the model's own reading of the message. Verify before acting on it.")}),(0,t.jsx)("p",{className:"mt-1 text-[0.7rem] text-muted-foreground",children:l("Generated by {model}",{model:a.model})})]})),e[31]=a,e[32]=s.hash,e[33]=l,e[34]=p):p=e[34];let c;e[35]!==m||e[36]!==f||e[37]!==p||e[38]!==h||e[39]!==y?(c=(0,t.jsx)(z,{className:"bg-muted/30",colSpan:7,children:(0,t.jsxs)("div",{className:"flex flex-col gap-3 py-1",children:[h,y,m,f,p]})}),e[35]=m,e[36]=f,e[37]=p,e[38]=h,e[39]=y,e[40]=c):c=e[40];let S;return e[41]!==c||e[42]!==E?(S=(0,t.jsx)(pe,{"data-testid":E,children:c}),e[41]=c,e[42]=E,e[43]=S):S=e[43],S},"et"),is=d(n=>{let e=(0,ge.c)(119),{busy:u,issue:s,rowError:$,runTriage:i,shardKey:l}=n,a=ue(),[o,_]=(0,ne.useState)(!1),A;e[0]===Symbol.for("react.memo_cache_sentinel")?(A=d(()=>{_(rs)},"A"),e[0]=A):A=e[0];let R=A,K;e[1]!==s.hash||e[2]!==i?(K=d(ae=>{let ce=ae===null||ae===Se?null:ae;le(i(s.hash,Ye,{severity:ce}))},"C"),e[1]=s.hash,e[2]=i,e[3]=K):K=e[3];let L=K,k;e[4]!==s.hash||e[5]!==i?(k=d(ae=>{if(ae.key!=="Enter")return;let ce=ae.currentTarget.value.trim();le(i(s.hash,Fe,{assignee:ce===""?null:ce}))},"T"),e[4]=s.hash,e[5]=i,e[6]=k):k=e[6];let T=k,E=`issues-row-${s.hash}`,h;e[7]!==a?(h=a("Toggle issue details"),e[7]=a,e[8]=h):h=e[8];let x=`issues-toggle-${s.hash}`,M=`mt-1 size-3 shrink-0 text-muted-foreground transition-transform ${o?"rotate-90":""}`,v;e[9]===Symbol.for("react.memo_cache_sentinel")?(v=(0,t.jsx)("path",{d:"m9 6 6 6-6 6"}),e[9]=v):v=e[9];let y;e[10]!==M?(y=(0,t.jsx)("svg",{"aria-hidden":"true",className:M,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:v}),e[10]=M,e[11]=y):y=e[11];let b;e[12]!==s.title?(b=(0,t.jsx)("span",{className:"block truncate font-medium",title:s.title,children:s.title}),e[12]=s.title,e[13]=b):b=e[13];let w;e[14]!==s.culprit?(w=(0,t.jsx)("span",{className:"block truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),e[14]=s.culprit,e[15]=w):w=e[15];let m;e[16]!==b||e[17]!==w?(m=(0,t.jsxs)("span",{className:"min-w-0",children:[b,w]}),e[16]=b,e[17]=w,e[18]=m):m=e[18];let f;e[19]!==o||e[20]!==m||e[21]!==h||e[22]!==x||e[23]!==y?(f=(0,t.jsxs)("button",{"aria-expanded":o,"aria-label":h,className:"flex w-full items-start gap-2 text-left","data-testid":x,onClick:R,type:"button",children:[y,m]}),e[19]=o,e[20]=m,e[21]=h,e[22]=x,e[23]=y,e[24]=f):f=e[24];let p;e[25]!==s.hash||e[26]!==$?(p=$!==void 0&&(0,t.jsx)("p",{className:"mt-1 text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:$}),e[25]=s.hash,e[26]=$,e[27]=p):p=e[27];let c;e[28]!==f||e[29]!==p?(c=(0,t.jsxs)(z,{className:"max-w-80",children:[f,p]}),e[28]=f,e[29]=p,e[30]=c):c=e[30];let S=`issues-status-${s.hash}`,g;e[31]!==s.status?(g=ss(s.status),e[31]=s.status,e[32]=g):g=e[32];let I;e[33]!==s.status||e[34]!==S||e[35]!==g?(I=(0,t.jsx)(z,{children:(0,t.jsx)(me,{"data-testid":S,variant:g,children:s.status})}),e[33]=s.status,e[34]=S,e[35]=g,e[36]=I):I=e[36];let j=s.severity??Se,r;e[37]!==a?(r=a("Set severity"),e[37]=a,e[38]=r):r=e[38];let oe=`issues-severity-${s.hash}`,V;e[39]!==a?(V=a("\u2014"),e[39]=a,e[40]=V):V=e[40];let N;e[41]!==s.severity||e[42]!==a?(N=s.severity===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:a("\u2014")}):(0,t.jsx)(me,{variant:ts(s.severity),children:s.severity}),e[41]=s.severity,e[42]=a,e[43]=N):N=e[43];let C;e[44]!==V||e[45]!==N?(C=(0,t.jsx)(Ue,{placeholder:V,children:N}),e[44]=V,e[45]=N,e[46]=C):C=e[46];let q;e[47]!==r||e[48]!==oe||e[49]!==C?(q=(0,t.jsx)(We,{"aria-label":r,className:"h-7 w-[110px]","data-testid":oe,children:C}),e[47]=r,e[48]=oe,e[49]=C,e[50]=q):q=e[50];let de;e[51]===Symbol.for("react.memo_cache_sentinel")?(de=Pe.map(ls),e[51]=de):de=e[51];let W;e[52]!==a?(W=a("Clear"),e[52]=a,e[53]=W):W=e[53];let D;e[54]!==W?(D=(0,t.jsxs)(De,{children:[de,(0,t.jsx)(we,{value:Se,children:W})]}),e[54]=W,e[55]=D):D=e[55];let F;e[56]!==u||e[57]!==L||e[58]!==j||e[59]!==q||e[60]!==D?(F=(0,t.jsx)(z,{children:(0,t.jsxs)(Be,{disabled:u,onValueChange:L,value:j,children:[q,D]})}),e[56]=u,e[57]=L,e[58]=j,e[59]=q,e[60]=D,e[61]=F):F=e[61];let O;e[62]!==a?(O=a("Assignee"),e[62]=a,e[63]=O):O=e[63];let fe=`issues-assignee-${s.hash}`,xe=s.assignee??"",ve=s.assignee??"",G;e[64]!==a?(G=a("Unassigned"),e[64]=a,e[65]=G):G=e[65];let H;e[66]!==u||e[67]!==T||e[68]!==O||e[69]!==fe||e[70]!==xe||e[71]!==ve||e[72]!==G?(H=(0,t.jsx)(z,{children:(0,t.jsx)(ke,{"aria-label":O,className:"h-7 w-32","data-testid":fe,defaultValue:xe,disabled:u,onKeyDown:T,placeholder:G},ve)}),e[66]=u,e[67]=T,e[68]=O,e[69]=fe,e[70]=xe,e[71]=ve,e[72]=G,e[73]=H):H=e[73];let J;e[74]!==s.count?(J=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsx)(me,{variant:"secondary",children:s.count})}),e[74]=s.count,e[75]=J):J=e[75];let P;e[76]!==s.lastSeen?(P=Te(s.lastSeen),e[76]=s.lastSeen,e[77]=P):P=e[77];let Q;e[78]!==P?(Q=(0,t.jsx)(z,{className:"text-xs tabular-nums text-muted-foreground",children:P}),e[78]=P,e[79]=Q):Q=e[79];let X;e[80]!==u||e[81]!==s.hash||e[82]!==s.status||e[83]!==i||e[84]!==a?(X=s.status!=="resolved"&&(0,t.jsx)(ie,{"data-testid":`issues-resolve-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Qe,{}))},"onClick"),size:"xs",variant:"outline",children:a("Resolve")}),e[80]=u,e[81]=s.hash,e[82]=s.status,e[83]=i,e[84]=a,e[85]=X):X=e[85];let Y;e[86]!==u||e[87]!==s.hash||e[88]!==s.status||e[89]!==i||e[90]!==a?(Y=s.status!=="ignored"&&(0,t.jsx)(ie,{"data-testid":`issues-ignore-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Xe,{}))},"onClick"),size:"xs",variant:"ghost",children:a("Ignore")}),e[86]=u,e[87]=s.hash,e[88]=s.status,e[89]=i,e[90]=a,e[91]=Y):Y=e[91];let Z;e[92]!==u||e[93]!==s.assignee||e[94]!==s.hash||e[95]!==s.status||e[96]!==i||e[97]!==a?(Z=s.status!=="open"&&(0,t.jsx)(ie,{"data-testid":`issues-reopen-${s.hash}`,disabled:u,onClick:d(()=>{le(i(s.hash,Fe,{assignee:s.assignee??null}))},"onClick"),size:"xs",variant:"ghost",children:a("Reopen")}),e[92]=u,e[93]=s.assignee,e[94]=s.hash,e[95]=s.status,e[96]=i,e[97]=a,e[98]=Z):Z=e[98];let ee;e[99]!==X||e[100]!==Y||e[101]!==Z?(ee=(0,t.jsx)(z,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1",children:[X,Y,Z]})}),e[99]=X,e[100]=Y,e[101]=Z,e[102]=ee):ee=e[102];let se;e[103]!==c||e[104]!==I||e[105]!==F||e[106]!==H||e[107]!==J||e[108]!==Q||e[109]!==E||e[110]!==ee?(se=(0,t.jsxs)(pe,{"data-testid":E,children:[c,I,F,H,J,Q,ee]}),e[103]=c,e[104]=I,e[105]=F,e[106]=H,e[107]=J,e[108]=Q,e[109]=E,e[110]=ee,e[111]=se):se=e[111];let te;e[112]!==o||e[113]!==s||e[114]!==l?(te=(0,t.jsx)(as,{expanded:o,issue:s,shardKey:l},s.sampleMessage),e[112]=o,e[113]=s,e[114]=l,e[115]=te):te=e[115];let he;return e[116]!==se||e[117]!==te?(he=(0,t.jsxs)(t.Fragment,{children:[se,te]}),e[116]=se,e[117]=te,e[118]=he):he=e[118],he},"tt"),ks=d(n=>{let e=(0,ge.c)(38),{initialShardKey:u}=n,s=ue(),$=Ne(),{queryShardKey:i,setShardKey:l,shardKey:a}=Le(u),[o,_]=(0,ne.useState)("all"),[A,R]=(0,ne.useState)(ns),[K,L]=(0,ne.useState)(os),k;e[0]!==o?(k=o==="all"?{}:{status:o},e[0]=o,e[1]=k):k=e[1];let T;e[2]!==i?(T={live:!0,shardKey:i},e[2]=i,e[3]=T):T=e[3];let{data:E,error:h,liveError:x}=Ee(U.getIssues,k,T),M=E!==void 0,v;if(e[4]!==K||e[5]!==A||e[6]!==$||e[7]!==E||e[8]!==h||e[9]!==x||e[10]!==M||e[11]!==i||e[12]!==l||e[13]!==a||e[14]!==o||e[15]!==s){let y=es(E),b;e[17]!==$||e[18]!==i?(b=d(async(r,oe,V)=>{L(N=>{if(!N.has(r))return N;let C=new Map(N);return C.delete(r),C}),R(N=>new Set(N).add(r));try{await $.query(oe,{...V,hash:r},be(i))}catch(N){let C=Ke(N);L(q=>new Map(q).set(r,C))}R(N=>{let C=new Set(N);return C.delete(r),C})},"S"),e[17]=$,e[18]=i,e[19]=b):b=e[19];let w=b,m;e[20]!==s?(m=d(r=>s(r==="all"?"All":r==="open"?"Open":r==="resolved"?"Resolved":"Ignored"),"u"),e[20]=s,e[21]=m):m=e[21];let f=m,p;e[22]!==h?(p=h!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:h}),e[22]=h,e[23]=p):p=e[23];let c;e[24]!==l||e[25]!==a?(c=(0,t.jsx)(_e,{onChange:l,testId:"issues-shard-input",value:a}),e[24]=l,e[25]=a,e[26]=c):c=e[26];let S;e[27]!==x?(S=(0,t.jsx)(qe,{message:x,prefix:"issues"}),e[27]=x,e[28]=S):S=e[28];let g;e[29]!==o||e[30]!==f?(g=Je.map(r=>(0,t.jsx)(ie,{"data-active":o===r?"":void 0,"data-testid":`issues-filter-${r}`,onClick:d(()=>{_(r)},"onClick"),size:"xs",variant:o===r?"default":"outline",children:f(r)},r)),e[29]=o,e[30]=f,e[31]=g):g=e[31];let I;e[32]!==g?(I=(0,t.jsx)("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:g}),e[32]=g,e[33]=I):I=e[33];let j;e[34]!==I||e[35]!==c||e[36]!==S?(j=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,S,I]}),e[34]=I,e[35]=c,e[36]=S,e[37]=j):j=e[37],v=(0,t.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[p,j,M&&y.length===0?(0,t.jsx)(Ae,{description:s("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:s("No issues")}):(0,t.jsx)(Me,{className:"overflow-hidden py-0",children:(0,t.jsx)(Ce,{className:"px-0",children:(0,t.jsxs)(ze,{"data-testid":"issues-table",children:[(0,t.jsx)(Re,{children:(0,t.jsxs)(pe,{children:[(0,t.jsx)(B,{children:s("Issue")}),(0,t.jsx)(B,{children:s("Status")}),(0,t.jsx)(B,{children:s("Severity")}),(0,t.jsx)(B,{children:s("Assignee")}),(0,t.jsx)(B,{className:"text-right",children:s("Events")}),(0,t.jsx)(B,{children:s("Last seen")}),(0,t.jsx)(B,{className:"text-right",children:s("Actions")})]})}),(0,t.jsx)(je,{children:y.map(r=>(0,t.jsx)(is,{busy:A.has(r.hash),issue:r,rowError:K.get(r.hash),runTriage:w,shardKey:i},r.hash))})]})})})]}),e[4]=K,e[5]=A,e[6]=$,e[7]=E,e[8]=h,e[9]=x,e[10]=M,e[11]=i,e[12]=l,e[13]=a,e[14]=o,e[15]=s,e[16]=v}else v=e[16];return v},"Tt");function rs(n){return!n}d(rs,"st");function ls(n){return(0,t.jsx)(we,{value:n,children:n},n)}d(ls,"at");function ns(){return new Set}d(ns,"it");function os(){return new Map}d(os,"lt");export{ks as default};
@@ -0,0 +1 @@
1
+ import{b as k,c as V}from"./chunk-YOB2X3FZ.js";import{a as Q}from"./chunk-EA2JKR5D.js";import{a as x}from"./chunk-IMOHEGMV.js";import{a as H}from"./chunk-EJSI4PMU.js";import{b as G}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{W as _}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as h}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as w}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as U}from"./chunk-4ZEL6BYL.js";import{f as D}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import"./chunk-LCXKALTS.js";import{d as K,e as z,f as B,h as P,m as q,p as E,t as M}from"./chunk-PTZD7RUZ.js";import{a as s,d as J,e as le,g as ce}from"./chunk-YKXDMIHQ.js";var i=J(le(),1);var e=J(ce(),1);var ue=s(r=>r.kind==="id"?r.table===void 0?"id":`id<${r.table}>`:r.kind==="array"?r.element===void 0?"array":`${r.element}[]`:r.kind,"le"),me=s(r=>r===void 0||r.length===0?"()":`(${r.map(o=>`${o.name}${o.optional?"?":""}: ${ue(o)}`).join(", ")})`,"ce"),fe=s(r=>{switch(r){case"array":return[];case"bigint":return k(0n);case"boolean":return!1;case"bytes":return k(new ArrayBuffer(0));case"number":return 0;case"object":case"record":return{};default:return""}},"ue"),pe=s(r=>{let o={};for(let a of r??[])a.optional||(o[a.name]=fe(a.kind));return JSON.stringify(o,void 0,2)},"me"),he=B(U.runAs),xe=10,ge=s(r=>r===void 0?"undefined":JSON.stringify(r,q,2),"pe"),Re=s(({functions:r,runAsIdentity:o=!1}={})=>{let a=K(),u=D(),[W,X]=(0,i.useState)(null),[I,Y]=(0,i.useState)(null),g=r??W??[],[S,F]=(0,i.useState)(""),[m,b]=(0,i.useState)("{}"),[c,$]=(0,i.useState)(""),[f,Z]=(0,i.useState)(""),[v,p]=(0,i.useState)("idle"),[ee,y]=(0,i.useState)(void 0),[C,N]=(0,i.useState)(null),[A,te]=(0,i.useState)([]);(0,i.useEffect)(()=>{if(r!==void 0)return;let t=!1;return u.listFunctions().then(d=>(t||X(d),d)).catch(d=>{t||Y(P(d))}),()=>{t=!0}},[u,r]);let R=S===""?g[0]?.path??"":S,n=g.find(t=>t.path===R),re=s(async()=>{if(!n)return;let t;try{t=m.trim()===""?{}:V(JSON.parse(m))}catch(l){p("error"),y(void 0),N(a("Invalid JSON args: {message}",{message:l.message}));return}let d={__lunoraRef:n.path},L=c.trim()===""?{}:{shardKey:c.trim()},O=o?f.trim():"",T=s(l=>{te(j=>[{argsText:m,at:Date.now(),id:(j[0]?.id??0)+1,kind:n.kind,path:n.path,shardKey:c,status:l},...j].slice(0,xe))},"$");p("running"),N(null);try{let l=O===""?await z(u,n.kind,d,t,L):await u.query(he,{args:t,functionPath:n.path,userId:O},L);G(c),y(l),p("success"),T("success")}catch(l){y(void 0),N(l.message),p("error"),T("error")}},"M"),ae=s(t=>{F(t.path),b(t.argsText),$(t.shardKey)},"P"),se=s(t=>{F(t.target.value)},"z"),ne=s(t=>{b(t.target.value)},"W"),ie=s(t=>{Z(t.target.value)},"q"),oe=s(()=>{E(re())},"H"),de=s(()=>{b(pe(n?.args))},"V");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-runner",children:[I!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"function-discover-error",role:"alert",children:I}),(0,e.jsxs)("div",{className:"flex flex-col gap-4 rounded-xl border border-border bg-card p-4",children:[(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsx)(x,{htmlFor:"function-select",children:a("Function")}),(0,e.jsx)("select",{"aria-label":a("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs transition-[color,box-shadow] outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50","data-testid":"function-select",id:"function-select",onChange:se,value:R,children:g.map(t=>(0,e.jsxs)("option",{value:t.path,children:[t.path," (",t.kind,")"]},t.path))}),n!==void 0&&(0,e.jsxs)("p",{className:"text-xs text-muted-foreground",children:[(0,e.jsx)("span",{className:"mr-1.5 font-medium",children:a("Signature")}),(0,e.jsx)("code",{className:"font-mono","data-testid":"function-signature",children:me(n.args)})]})]}),(0,e.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)(x,{htmlFor:"args-input",children:a("Arguments")}),(0,e.jsx)(h,{"data-testid":"prefill-button",disabled:n===void 0,onClick:de,size:"xs",type:"button",variant:"ghost",children:a("Prefill")})]}),(0,e.jsx)(Q,{"aria-label":a("Arguments"),className:"font-mono text-xs","data-testid":"args-input",id:"args-input",onChange:ne,value:m})]}),(0,e.jsx)(H,{onChange:$,testId:"shard-input",value:c}),o&&(0,e.jsxs)("div",{className:"flex flex-col gap-1.5","data-testid":"run-as-field",children:[(0,e.jsx)(x,{htmlFor:"run-as-input",children:a("Run as identity (userId)")}),(0,e.jsx)(_,{"aria-label":a("Run as identity (userId)"),className:"font-mono text-xs","data-testid":"run-as-input",id:"run-as-input",onChange:ie,placeholder:a("Leave empty to run as admin"),value:f}),(0,e.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("Dev only: runs the function as this user so you can test auth and RLS. Forged over the admin gate.")})]}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(h,{"data-testid":"run-button",disabled:v==="running"||n===void 0,onClick:oe,type:"button",children:a("Run")}),n!==void 0&&(0,e.jsx)(w,{variant:"outline",children:n.kind}),o&&f.trim()!==""&&(0,e.jsx)(w,{"data-testid":"run-as-badge",variant:"secondary",children:a("as {userId}",{userId:f.trim()})})]})]}),v==="error"&&C!==null&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"error",role:"alert",children:C}),v==="success"&&(0,e.jsx)("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"result",children:ge(ee)}),A.length>0&&(0,e.jsx)("ul",{className:"flex flex-col overflow-hidden rounded-xl border border-border","data-testid":"fn-history",children:A.map((t,d)=>(0,e.jsxs)("li",{className:"flex flex-wrap items-center gap-2 border-b border-border px-3 py-2 text-sm last:border-b-0","data-testid":"fn-history-row",children:[(0,e.jsx)("span",{className:t.status==="success"?"text-success":"text-destructive","data-testid":`fn-history-status-${d.toString()}`,children:t.status==="success"?"\u2713":"\u2717"})," ",(0,e.jsxs)("span",{className:"font-mono text-xs",children:[t.path," (",t.kind,")"]})," ",(0,e.jsx)("time",{className:"text-xs text-muted-foreground",children:M(t.at)})," ",(0,e.jsx)(h,{className:"ml-auto","data-testid":`fn-history-load-${d.toString()}`,onClick:s(()=>{ae(t)},"onClick"),size:"xs",type:"button",variant:"ghost",children:a("Load")})]},t.id))})]})},"$e");export{Re as FunctionRunner};
@@ -0,0 +1 @@
1
+ import{a as O}from"./chunk-66UGPQVC.js";import{a as H}from"./chunk-NFS7FTAR.js";import{a as ee}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as Z}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as E}from"./chunk-ERHFRNCL.js";import{f as R}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import"./chunk-LCXKALTS.js";import{a as _}from"./chunk-FKVZRPV5.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-HEAQVSNS.js";import{a as A,e as T}from"./chunk-WUWBZPUK.js";import{d as M,h as G,p as W,t as X}from"./chunk-PTZD7RUZ.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-YKXDMIHQ.js";var U=P(re(),1),Y=P(oe(),1);var t=P(ae(),1);var se=P(re(),1);var Q=P(oe(),1);var h=P(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","X"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"F"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"Y"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,f=R(),r=M(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let v=await(d??(()=>f.listScheduledJobs()))();return le(v)}),[x,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),y,k;e[1]!==f||e[2]!==l?(y=c(()=>{if(l)return f.subscribeScheduledJobs(v=>{m(void 0),n(le(v))})},"v"),k=[l,f],e[1]=f,e[2]=l,e[3]=y,e[4]=k):(y=e[3],k=e[4]),(0,Q.useEffect)(y,k);let g;e[5]!==N?(g=c(()=>{N.refetch()},"y"),e[5]=N,e[6]=g):g=e[6],O(g,!l);let J=ce(f,i,d),b=x??N.data,j=s??N.error,I=c(async v=>{if(J!==void 0){m(void 0);try{await J(v),l||N.refetch()}catch(D){m(G(D))}}},"A"),q="flex flex-col gap-3",B="lunora-scheduled-jobs",S;e[7]!==j?(S=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=S):S=e[8];let L;e[9]!==b?.length||e[10]!==r?(L=b?.length===0&&(0,h.jsx)(_,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=L):L=e[11];let $=b!==void 0&&b.length>0&&(0,h.jsx)(A,{className:"overflow-hidden py-0",children:(0,h.jsx)(T,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(F,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(v=>(0,h.jsxs)(F,{"data-testid":`sj-row-${v.id}`,children:[(0,h.jsx)(p,{className:"font-mono text-xs",children:v.workflow??v.functionPath}),(0,h.jsx)(p,{className:"text-muted-foreground tabular-nums",children:ie(v.scheduledFor)}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.pool??""}),(0,h.jsx)(p,{className:"tabular-nums",children:v.attempts??0}),(0,h.jsx)(p,{children:v.shardKey??""}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.id}),J!==void 0&&(0,h.jsx)(p,{className:"text-right",children:(0,h.jsx)(H,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{W(I(v.id))},"onConfirm"),testId:`sj-cancel-${v.id}`,children:r("Cancel")})})]},v.id))})]})})}),w;return e[12]!==$||e[13]!==S||e[14]!==L?(w=(0,h.jsxs)("div",{className:q,"data-testid":B,children:[S,L,$]}),e[12]=$,e[13]=S,e[14]=L,e[15]=w):w=e[15],w},"he");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"re"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=R(),d=M(),[f,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,x=me(i,a,e),n=c(async s=>{if(x!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await x(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(y=>({...y,[s]:{kind:"error",message:G(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(_,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),x!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=f[s.name]??he;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(p,{children:s.name}),(0,t.jsx)(p,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(p,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(p,{children:s.shardKey??""}),x!==void 0&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(H,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{W(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),pe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","se"),fe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:f,retryJob:r}=i,l=R(),o=M(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let x;e[3]!==l||e[4]!==d?(x=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=x):x=e[5];let n=E(N,x),s=n.data,[m,y]=(0,Y.useState)(void 0),k=n.error??m,g=d===void 0,J;e[6]!==l||e[7]!==g||e[8]!==r?(J=r??(g?C=>l.retryDeadJob(C):void 0),e[6]=l,e[7]=g,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==g||e[12]!==f?(j=f??(g?C=>l.removeDeadJob(C):void 0),e[10]=l,e[11]=g,e[12]=f,e[13]=j):j=e[13];let I=j,q;e[14]!==n?(q=c(()=>{n.refetch()},"$"),e[14]=n,e[15]=q):q=e[15],O(q,!0);let B;e[16]!==n?(B=c(async C=>{y(void 0);try{await C,n.refetch()}catch(ne){y(G(ne))}},"I"),e[16]=n,e[17]=B):B=e[17];let S=B,L=b!==void 0||I!==void 0,$;e[18]!==k?($=k!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:k}),e[18]=k,e[19]=$):$=e[19];let w;e[20]!==s?.length||e[21]!==o?(w=s?.length===0&&(0,t.jsx)(_,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=w):w=e[22];let v;e[23]!==S||e[24]!==L||e[25]!==s||e[26]!==I||e[27]!==b||e[28]!==o?(v=s!==void 0&&s.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),L&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(C=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${C.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:C.workflow??C.functionPath}),(0,t.jsx)(p,{className:"tabular-nums",children:C.attempts??0}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:pe(C.scheduledFor)}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.pool??""}),(0,t.jsx)(p,{children:C.shardKey??""}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.id}),L&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${C.id}`,onClick:c(()=>{W(S(b(C.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),I!==void 0&&(0,t.jsx)(H,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{W(S(I(C.id)))},"onConfirm"),testId:`dlq-remove-${C.id}`,children:o("Drop")})]})})]},C.id))})]})})}),e[23]=S,e[24]=L,e[25]=s,e[26]=I,e[27]=b,e[28]=o,e[29]=v):v=e[29];let D;return e[30]!==v||e[31]!==$||e[32]!==w?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,w,v]}),e[30]=v,e[31]=$,e[32]=w,e[33]=D):D=e[33],D},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"oe");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:f}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==f?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(A,{className:"flex-1 py-0",children:(0,t.jsxs)(T,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"E"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,f=R(),r=M(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==f||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>f.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"y"),e[4]=f,e[5]=d,e[6]=N):N=e[6];let x=E(o,N),{data:n,error:s}=x,m;e[7]!==x?(m=c(()=>{x.refetch()},"d"),e[7]=x,e[8]=m):m=e[8],O(m,!0);let y;e[9]!==s?(y=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=y):y=e[10];let k;e[11]!==n||e[12]!==r?(k=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=k):k=e[13];let g;e[14]!==n?.pools.length||e[15]!==r?(g=n?.pools.length===0&&(0,t.jsx)(_,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=g):g=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==y||e[21]!==k||e[22]!==g||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[y,k,g,J]}),e[20]=y,e[21]=k,e[22]=g,e[23]=J,e[24]=b):b=e[24],b},"ae");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(p,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(p,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(p,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"de");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:f,scheduledLoad:r}=i,l=M(),[o,N]=(0,Y.useState)("jobs"),x;e[2]!==l?(x=l("Cron triggers"),e[2]=l,e[3]=x):x=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let y;e[10]!==x||e[11]!==n||e[12]!==s||e[13]!==m?(y={cron:x,dead:n,jobs:s,pools:m},e[10]=x,e[11]=n,e[12]=s,e[13]=m,e[14]=y):y=e[14];let k=y,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c(w=>{N(w.currentTarget.dataset.view)},"f"),e[15]=g):g=e[15];let J=g,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==k?(j=Ne.map(w=>(0,t.jsx)(ee,{"aria-selected":o===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:J,role:"tab",size:"sm",type:"button",variant:o===w?"default":"outline",children:k[w]},w)),e[18]=o,e[19]=k,e[20]=j):j=e[20];let I;e[21]!==b||e[22]!==j?(I=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=I):I=e[23];let q;e[24]!==f||e[25]!==r||e[26]!==o?(q=o==="jobs"&&(0,t.jsx)(de,{cancelJob:f,loadJobs:r}),e[24]=f,e[25]=r,e[26]=o,e[27]=q):q=e[27];let B;e[28]!==o?(B=o==="dead"&&(0,t.jsx)(fe,{}),e[28]=o,e[29]=B):B=e[29];let S;e[30]!==o?(S=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=S):S=e[31];let L;e[32]!==d||e[33]!==o?(L=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=L):L=e[34];let $;return e[35]!==I||e[36]!==q||e[37]!==B||e[38]!==S||e[39]!==L?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[I,q,B,S,L]}),e[35]=I,e[36]=q,e[37]=B,e[38]=S,e[39]=L,e[40]=$):$=e[40],$},"Ie");export{Ve as SchedulePanel};
@@ -0,0 +1 @@
1
+ import{a as Ce,b as Ne}from"./chunk-3EQVJ5SQ.js";import{a as ye}from"./chunk-EY6WHXDO.js";import"./chunk-XKMLLTFP.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import{e as ke,g as we}from"./chunk-OKG3HWSJ.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as X}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as le}from"./chunk-ULIQFBZU.js";import{a as pe}from"./chunk-4ZEL6BYL.js";import"./chunk-ERHFRNCL.js";import{f as he}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import"./chunk-LCXKALTS.js";import{a as me}from"./chunk-FKVZRPV5.js";import"./chunk-HEAQVSNS.js";import{a as oe,b as ue,c as ge,e as ae}from"./chunk-WUWBZPUK.js";import{d as te,f as ve,g as be,h as fe,o as xe,p as ne}from"./chunk-PTZD7RUZ.js";import{a as g,d as ie,e as Se,f as Ke,g as Le}from"./chunk-YKXDMIHQ.js";var Y=ie(Ke(),1),G=ie(Se(),1);var a=ie(Le(),1);var Me=ve(pe.runSql),qe=g((f,e)=>{let t=(0,Y.c)(11),n=he(),[l,d]=(0,G.useState)(void 0),[s,i]=(0,G.useState)(void 0),[h,x]=(0,G.useState)(!0),m;t[0]!==n||t[1]!==e||t[2]!==f?(m=g(async u=>{x(!0);try{let C=await n.query(Me,{sql:f},be(e));u.cancelled||(d(C),i(void 0))}catch(C){let k=C;u.cancelled||(d(void 0),i(fe(k)))}u.cancelled||x(!1)},"h"),t[0]=n,t[1]=e,t[2]=f,t[3]=m):m=t[3];let r=m,o,v;t[4]!==r?(o=g(()=>{let u={cancelled:!1};return ne(r(u)),()=>{u.cancelled=!0}},"l"),v=[r],t[4]=r,t[5]=o,t[6]=v):(o=t[5],v=t[6]),(0,G.useEffect)(o,v);let S;return t[7]!==s||t[8]!==h||t[9]!==l?(S={error:s,loading:h,result:l},t[7]=s,t[8]=h,t[9]=l,t[10]=S):S=t[10],S},"Le"),Ee=g(f=>{f.preventDefault()},"Me"),ce=g(f=>f.kind??"chart","le"),Re=g(f=>{let e=(0,Y.c)(80),{actions:t,children:n,draggedRef:l,first:d,last:s,onEdit:i,onMove:h,onRemove:x,onReorder:m,widget:r}=f,o=te(),v;e[0]!==h||e[1]!==r.id?(v=g(()=>{h(r.id,-1)},"g"),e[0]=h,e[1]=r.id,e[2]=v):v=e[2];let S=v,u;e[3]!==h||e[4]!==r.id?(u=g(()=>{h(r.id,1)},"f"),e[3]=h,e[4]=r.id,e[5]=u):u=e[5];let C=u,k;e[6]!==i||e[7]!==r.id?(k=g(()=>{i(r.id)},"x"),e[6]=i,e[7]=r.id,e[8]=k):k=e[8];let E=k,O;e[9]!==x||e[10]!==r.id?(O=g(()=>{x(r.id)},"O"),e[9]=x,e[10]=r.id,e[11]=O):O=e[11];let j=O,T;e[12]!==l||e[13]!==r.id?(T=g(()=>{l.current=r.id},"z"),e[12]=l,e[13]=r.id,e[14]=T):T=e[14];let w=T,K;e[15]!==l||e[16]!==m||e[17]!==r.id?(K=g(()=>{let de=l.current;l.current=null,de!==null&&de!==r.id&&m(de,r.id)},"K"),e[15]=l,e[16]=m,e[17]=r.id,e[18]=K):K=e[18];let _=K,R=`dashboards-widget-${r.id}`,y;e[19]!==r.title?(y=(0,a.jsx)(ge,{className:"min-w-0 cursor-grab truncate",title:r.title,children:r.title}),e[19]=r.title,e[20]=y):y=e[20];let N;e[21]!==o?(N=o("Move widget up"),e[21]=o,e[22]=N):N=e[22];let F=`dashboards-move-up-${r.id}`,H;e[23]!==o?(H=o("Move widget up"),e[23]=o,e[24]=H):H=e[24];let D;e[25]===Symbol.for("react.memo_cache_sentinel")?(D=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 15 6-6 6 6"})}),e[25]=D):D=e[25];let W;e[26]!==d||e[27]!==S||e[28]!==F||e[29]!==H||e[30]!==N?(W=(0,a.jsx)(X,{"aria-label":N,"data-testid":F,disabled:d,onClick:S,size:"icon-xs",title:H,type:"button",variant:"ghost",children:D}),e[26]=d,e[27]=S,e[28]=F,e[29]=H,e[30]=N,e[31]=W):W=e[31];let L;e[32]!==o?(L=o("Move widget down"),e[32]=o,e[33]=L):L=e[33];let $=`dashboards-move-down-${r.id}`,M;e[34]!==o?(M=o("Move widget down"),e[34]=o,e[35]=M):M=e[35];let z;e[36]===Symbol.for("react.memo_cache_sentinel")?(z=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m6 9 6 6 6-6"})}),e[36]=z):z=e[36];let q;e[37]!==s||e[38]!==C||e[39]!==L||e[40]!==$||e[41]!==M?(q=(0,a.jsx)(X,{"aria-label":L,"data-testid":$,disabled:s,onClick:C,size:"icon-xs",title:M,type:"button",variant:"ghost",children:z}),e[37]=s,e[38]=C,e[39]=L,e[40]=$,e[41]=M,e[42]=q):q=e[42];let B;e[43]!==o?(B=o("Edit widget"),e[43]=o,e[44]=B):B=e[44];let I=`dashboards-widget-edit-${r.id}`,A;e[45]!==o?(A=o("Edit widget"),e[45]=o,e[46]=A):A=e[46];let p;e[47]===Symbol.for("react.memo_cache_sentinel")?(p=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[47]=p):p=e[47];let b;e[48]!==E||e[49]!==B||e[50]!==I||e[51]!==A?(b=(0,a.jsx)(X,{"aria-label":B,"data-testid":I,onClick:E,size:"icon-xs",title:A,type:"button",variant:"ghost",children:p}),e[48]=E,e[49]=B,e[50]=I,e[51]=A,e[52]=b):b=e[52];let c;e[53]!==o?(c=o("Remove widget"),e[53]=o,e[54]=c):c=e[54];let J=`dashboards-widget-remove-${r.id}`,V;e[55]!==o?(V=o("Remove widget"),e[55]=o,e[56]=V):V=e[56];let U;e[57]===Symbol.for("react.memo_cache_sentinel")?(U=(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[57]=U):U=e[57];let Q;e[58]!==j||e[59]!==c||e[60]!==J||e[61]!==V?(Q=(0,a.jsx)(X,{"aria-label":c,"data-testid":J,onClick:j,size:"icon-xs",title:V,type:"button",variant:"ghost",children:U}),e[58]=j,e[59]=c,e[60]=J,e[61]=V,e[62]=Q):Q=e[62];let Z;e[63]!==t||e[64]!==W||e[65]!==q||e[66]!==b||e[67]!==Q?(Z=(0,a.jsxs)("div",{className:"flex shrink-0 items-center gap-1",children:[t,W,q,b,Q]}),e[63]=t,e[64]=W,e[65]=q,e[66]=b,e[67]=Q,e[68]=Z):Z=e[68];let P;e[69]!==Z||e[70]!==y?(P=(0,a.jsxs)(ue,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[y,Z]}),e[69]=Z,e[70]=y,e[71]=P):P=e[71];let ee;e[72]!==n?(ee=(0,a.jsx)(ae,{className:"min-h-32 py-2",children:n}),e[72]=n,e[73]=ee):ee=e[73];let re;return e[74]!==w||e[75]!==_||e[76]!==P||e[77]!==ee||e[78]!==R?(re=(0,a.jsxs)(oe,{"data-testid":R,draggable:!0,onDragOver:Ee,onDragStart:w,onDrop:_,children:[P,ee]}),e[74]=w,e[75]=_,e[76]=P,e[77]=ee,e[78]=R,e[79]=re):re=e[79],re},"ce"),je=g(f=>{let e=(0,Y.c)(10),{result:t}=f,n=te(),l=t.columns[0],d=l===void 0?void 0:t.rows[0]?.[l],s;e[0]!==d||e[1]!==n?(s=d===void 0?n("\u2014"):xe(d),e[0]=d,e[1]=n,e[2]=s):s=e[2];let i;e[3]!==s?(i=(0,a.jsx)("p",{className:"truncate font-mono text-3xl font-semibold text-foreground",children:s}),e[3]=s,e[4]=i):i=e[4];let h;e[5]!==l?(h=l!==void 0&&(0,a.jsx)("p",{className:"truncate text-xs text-muted-foreground",children:l}),e[5]=l,e[6]=h):h=e[6];let x;return e[7]!==i||e[8]!==h?(x=(0,a.jsxs)("div",{className:"flex h-full flex-col justify-center gap-1 p-4","data-testid":"dashboards-kpi",children:[i,h]}),e[7]=i,e[8]=h,e[9]=x):x=e[9],x},"qe"),ze=g(f=>{let e=(0,Y.c)(12),{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x}=f,m=x.text??"",r;e[0]!==m?(r=(0,a.jsx)("p",{className:"p-2 text-sm whitespace-pre-wrap text-muted-foreground","data-testid":"dashboards-text",children:m}),e[0]=m,e[1]=r):r=e[1];let o;return e[2]!==t||e[3]!==n||e[4]!==l||e[5]!==d||e[6]!==s||e[7]!==i||e[8]!==h||e[9]!==r||e[10]!==x?(o=(0,a.jsx)(Re,{draggedRef:t,first:n,last:l,onEdit:d,onMove:s,onRemove:i,onReorder:h,widget:x,children:r}),e[2]=t,e[3]=n,e[4]=l,e[5]=d,e[6]=s,e[7]=i,e[8]=h,e[9]=r,e[10]=x,e[11]=o):o=e[11],o},"Ee"),Ae=g(f=>{let e=(0,Y.c)(52),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o=te(),{error:v,loading:S,result:u}=qe(r.sql,r.shardKey??""),C;e[0]!==r?(C=ce(r),e[0]=r,e[1]=C):C=e[1];let k=C,E;e[2]!==m||e[3]!==u||e[4]!==r.id?(E=g(()=>{u!==void 0&&m?.(r.id,u)},"q"),e[2]=m,e[3]=u,e[4]=r.id,e[5]=E):E=e[5];let O=E,j;e[6]!==l||e[7]!==k||e[8]!==m||e[9]!==O||e[10]!==u||e[11]!==o||e[12]!==r.id?(j=k==="chart"&&m!==void 0&&u!==void 0?(0,a.jsx)(X,{"aria-label":o("Suggest chart"),"data-testid":`dashboards-widget-suggest-${r.id}`,disabled:l,onClick:O,size:"icon-xs",title:o(l?"Suggesting\u2026":"Suggest chart"),type:"button",variant:"ghost",children:(0,a.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,a.jsx)("path",{d:"m12 3 1.9 4.6L18.5 9.5 13.9 11.4 12 16l-1.9-4.6L5.5 9.5l4.6-1.9L12 3ZM18 15l.9 2.1 2.1.9-2.1.9L18 21l-.9-2.1-2.1-.9 2.1-.9L18 15Z"})})}):void 0,e[6]=l,e[7]=k,e[8]=m,e[9]=O,e[10]=u,e[11]=o,e[12]=r.id,e[13]=j):j=e[13];let T=j,w;e[14]!==v||e[15]!==r.id?(w=v!==void 0&&(0,a.jsx)(le,{className:"font-mono text-xs",testId:`dashboards-widget-error-${r.id}`,variant:"destructive",children:v}),e[14]=v,e[15]=r.id,e[16]=w):w=e[16];let K;e[17]!==v||e[18]!==S||e[19]!==u||e[20]!==o||e[21]!==r.id?(K=v===void 0&&S&&u===void 0&&(0,a.jsx)("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${r.id}`,children:o("Running\u2026")}),e[17]=v,e[18]=S,e[19]=u,e[20]=o,e[21]=r.id,e[22]=K):K=e[22];let _;e[23]!==v||e[24]!==k||e[25]!==u||e[26]!==r.chartAxes||e[27]!==r.chartKind?(_=v===void 0&&u!==void 0&&k==="chart"&&(0,a.jsx)(Ce,{axes:r.chartAxes,kind:r.chartKind,result:u}),e[23]=v,e[24]=k,e[25]=u,e[26]=r.chartAxes,e[27]=r.chartKind,e[28]=_):_=e[28];let R;e[29]!==v||e[30]!==k||e[31]!==u?(R=v===void 0&&u!==void 0&&k==="kpi"&&(0,a.jsx)(je,{result:u}),e[29]=v,e[30]=k,e[31]=u,e[32]=R):R=e[32];let y;e[33]!==v||e[34]!==k||e[35]!==u?(y=v===void 0&&u!==void 0&&k==="table"&&(0,a.jsx)("div",{className:"max-h-72 overflow-auto",children:(0,a.jsx)(Ne,{result:u})}),e[33]=v,e[34]=k,e[35]=u,e[36]=y):y=e[36];let N;return e[37]!==t||e[38]!==n||e[39]!==d||e[40]!==s||e[41]!==i||e[42]!==h||e[43]!==x||e[44]!==T||e[45]!==w||e[46]!==K||e[47]!==_||e[48]!==R||e[49]!==y||e[50]!==r?(N=(0,a.jsxs)(Re,{actions:T,draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r,children:[w,K,_,R,y]}),e[37]=t,e[38]=n,e[39]=d,e[40]=s,e[41]=i,e[42]=h,e[43]=x,e[44]=T,e[45]=w,e[46]=K,e[47]=_,e[48]=R,e[49]=y,e[50]=r,e[51]=N):N=e[51],N},"Ae"),_e=g(f=>{let e=(0,Y.c)(11),{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}=f,o;return e[0]!==t||e[1]!==n||e[2]!==l||e[3]!==d||e[4]!==s||e[5]!==i||e[6]!==h||e[7]!==x||e[8]!==m||e[9]!==r?(o=ce(r)==="text"?(0,a.jsx)(ze,{draggedRef:t,first:n,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,widget:r}):(0,a.jsx)(Ae,{draggedRef:t,first:n,inferring:l,last:d,onEdit:s,onMove:i,onRemove:h,onReorder:x,onSuggest:m,widget:r}),e[0]=t,e[1]=n,e[2]=l,e[3]=d,e[4]=s,e[5]=i,e[6]=h,e[7]=x,e[8]=m,e[9]=r,e[10]=o):o=e[10],o},"Te"),We=["bar","line","area"],$e=["chart","kpi","table","text"],Be="lunora-studio-dashboards",se={chartKind:"bar",kind:"chart",shardKey:"",sql:"",text:"",title:""},Ie=g((f,e)=>t=>t.map(n=>n.id===f?{...n,chartAxes:e,chartKind:e.kind}:n),"De"),Te=g((f,e)=>t=>{let n=t.find(s=>s.id===f),l=t.filter(s=>s.id!==f),d=l.findIndex(s=>s.id===e);return n===void 0||d===-1?t:[...l.slice(0,d),n,...l.slice(d)]},"je"),De=g((f,e)=>e(f==="line"?"Line":f==="area"?"Area":"Bar"),"ze"),Oe=g((f,e)=>e(f==="kpi"?"Single value":f==="table"?"Table":f==="text"?"Text":"Chart"),"Be"),Fe=g(f=>{let e=(0,Y.c)(82),{draft:t,editing:n,onCancel:l,onChange:d,onSubmit:s}=f,i=te(),h;e[0]!==t||e[1]!==d?(h=g(c=>{d({...t,title:c.target.value})},"c"),e[0]=t,e[1]=d,e[2]=h):h=e[2];let x=h,m;e[3]!==t||e[4]!==d?(m=g(c=>{d({...t,sql:c.target.value})},"h"),e[3]=t,e[4]=d,e[5]=m):m=e[5];let r=m,o;e[6]!==t||e[7]!==d?(o=g(c=>{d({...t,text:c.target.value})},"l"),e[6]=t,e[7]=d,e[8]=o):o=e[8];let v=o,S;e[9]!==t||e[10]!==d?(S=g(c=>{d({...t,shardKey:c.target.value})},"N"),e[9]=t,e[10]=d,e[11]=S):S=e[11];let u=S,C;e[12]!==t||e[13]!==d?(C=g(c=>{d({...t,chartKind:c.target.value})},"y"),e[12]=t,e[13]=d,e[14]=C):C=e[14];let k=C,E;e[15]!==t||e[16]!==d?(E=g(c=>{d({...t,kind:c.target.value})},"q"),e[15]=t,e[16]=d,e[17]=E):E=e[17];let O=E,j;e[18]!==s?(j=g(()=>{s()},"E"),e[18]=s,e[19]=j):j=e[19];let T=j,w=t.kind==="text",K;e[20]!==t.sql||e[21]!==t.text||e[22]!==t.title||e[23]!==w?(K=t.title.trim()!==""&&(w?t.text.trim()!=="":t.sql.trim()!==""),e[20]=t.sql,e[21]=t.text,e[22]=t.title,e[23]=w,e[24]=K):K=e[24];let _=K,R;e[25]!==i?(R=i("Widget title"),e[25]=i,e[26]=R):R=e[26];let y;e[27]!==i?(y=i("Widget title"),e[27]=i,e[28]=y):y=e[28];let N;e[29]!==t.title||e[30]!==x||e[31]!==y||e[32]!==R?(N=(0,a.jsx)("input",{"aria-label":R,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-title",onChange:x,placeholder:y,type:"text",value:t.title}),e[29]=t.title,e[30]=x,e[31]=y,e[32]=R,e[33]=N):N=e[33];let F;e[34]!==i?(F=i("Widget type"),e[34]=i,e[35]=F):F=e[35];let H=t.kind,D;e[36]!==i?(D=$e.map(c=>(0,a.jsx)("option",{value:c,children:Oe(c,i)},c)),e[36]=i,e[37]=D):D=e[37];let W;e[38]!==t.kind||e[39]!==O||e[40]!==F||e[41]!==D?(W=(0,a.jsx)("select",{"aria-label":F,className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-widget-kind",onChange:O,value:H,children:D}),e[38]=t.kind,e[39]=O,e[40]=F,e[41]=D,e[42]=W):W=e[42];let L;e[43]!==t.sql||e[44]!==t.text||e[45]!==w||e[46]!==r||e[47]!==v||e[48]!==i?(L=w?(0,a.jsx)("textarea",{"aria-label":i("Text"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-text",onChange:v,placeholder:i("Notes for whoever reads this dashboard."),value:t.text}):(0,a.jsx)("textarea",{"aria-label":i("SQL query"),className:"min-h-24 resize-y rounded-md border border-border bg-background p-2 font-mono text-xs leading-5 outline-none focus-visible:border-ring","data-testid":"dashboards-form-sql",onChange:r,placeholder:"SELECT author, COUNT(*) AS messages FROM \u2026",spellCheck:!1,value:t.sql}),e[43]=t.sql,e[44]=t.text,e[45]=w,e[46]=r,e[47]=v,e[48]=i,e[49]=L):L=e[49];let $;e[50]!==t.chartKind||e[51]!==t.kind||e[52]!==k||e[53]!==i?($=t.kind==="chart"&&(0,a.jsx)("select",{"aria-label":i("Chart type"),className:"h-8 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-kind",onChange:k,value:t.chartKind,children:We.map(c=>(0,a.jsx)("option",{value:c,children:De(c,i)},c))}),e[50]=t.chartKind,e[51]=t.kind,e[52]=k,e[53]=i,e[54]=$):$=e[54];let M;e[55]!==t.shardKey||e[56]!==w||e[57]!==u||e[58]!==i?(M=!w&&(0,a.jsx)("input",{"aria-label":i("Shard key (optional)"),className:"h-8 rounded-md border border-border bg-background px-2 font-mono text-xs outline-none focus-visible:border-ring","data-testid":"dashboards-form-shard",onChange:u,placeholder:i("Shard key (optional)"),type:"text",value:t.shardKey}),e[55]=t.shardKey,e[56]=w,e[57]=u,e[58]=i,e[59]=M):M=e[59];let z;e[60]!==i?(z=i("Cancel"),e[60]=i,e[61]=z):z=e[61];let q;e[62]!==l||e[63]!==z?(q=(0,a.jsx)(X,{"data-testid":"dashboards-form-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:z}),e[62]=l,e[63]=z,e[64]=q):q=e[64];let B=!_,I;e[65]!==n||e[66]!==i?(I=i(n?"Save widget":"Add widget"),e[65]=n,e[66]=i,e[67]=I):I=e[67];let A;e[68]!==T||e[69]!==B||e[70]!==I?(A=(0,a.jsx)(X,{"data-testid":"dashboards-form-save",disabled:B,onClick:T,size:"sm",type:"button",children:I}),e[68]=T,e[69]=B,e[70]=I,e[71]=A):A=e[71];let p;e[72]!==q||e[73]!==A?(p=(0,a.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[q,A]}),e[72]=q,e[73]=A,e[74]=p):p=e[74];let b;return e[75]!==N||e[76]!==W||e[77]!==L||e[78]!==$||e[79]!==M||e[80]!==p?(b=(0,a.jsx)(oe,{"data-testid":"dashboards-form",children:(0,a.jsxs)(ae,{className:"flex flex-col gap-3 py-4",children:[N,W,L,$,M,p]})}),e[75]=N,e[76]=W,e[77]=L,e[78]=$,e[79]=M,e[80]=p,e[81]=b):b=e[81],b},"Fe"),tt=g(f=>{let e=(0,Y.c)(53),{initialShardKey:t}=f,n=te(),[l,d]=ke(Be),[s,i]=(0,G.useState)(se),[h,x]=(0,G.useState)(null),[m,r]=(0,G.useState)(!1),o=ye(t??""),[v,S]=(0,G.useState)(null),u=(0,G.useRef)(null),C;e[0]!==t?(C=g(()=>{x(null),i({...se,shardKey:t??""}),r(!0)},"y"),e[0]=t,e[1]=C):C=e[1];let k=C,E;e[2]===Symbol.for("react.memo_cache_sentinel")?(E=g(()=>{r(!1),x(null),i(se)},"q"),e[2]=E):E=e[2];let O=E,j;e[3]!==l?(j=g(p=>{let b=l.find(c=>c.id===p);b!==void 0&&(x(p),i({chartKind:b.chartKind??"bar",kind:ce(b),shardKey:b.shardKey??"",sql:b.sql,text:b.text??"",title:b.title}),r(!0))},"E"),e[3]=l,e[4]=j):j=e[4];let T=j,w;e[5]!==o||e[6]!==d?(w=g((p,b)=>{S(p),ne((async()=>{let c=await o.inferChart({columns:b.columns,rowCount:b.rowCount});c!==void 0&&d(Ie(p,c))})().finally(()=>{S(c=>c===p?null:c)}))},"C"),e[5]=o,e[6]=d,e[7]=w):w=e[7];let K=w,_;e[8]!==d?(_=g(p=>{d(b=>b.filter(c=>c.id!==p))},"W"),e[8]=d,e[9]=_):_=e[9];let R=_,y;e[10]!==d?(y=g((p,b)=>{d(Te(p,b))},"k"),e[10]=d,e[11]=y):y=e[11];let N=y,F;e[12]!==d?(F=g((p,b)=>{d(c=>{let J=c.findIndex(P=>P.id===p),V=J+b;if(J===-1||V<0||V>=c.length)return c;let U=[...c],Q=U[J],Z=U[V];return Q===void 0||Z===void 0?c:(U[J]=Z,U[V]=Q,U)})},"_"),e[12]=d,e[13]=F):F=e[13];let H=F,D;e[14]!==s||e[15]!==h||e[16]!==d?(D=g(()=>{let p=s.title.trim(),b=s.sql.trim(),c=s.text.trim(),{chartKind:J,kind:V}=s;if(p===""||(V==="text"?c==="":b===""))return;let U={chartKind:J,kind:V,shardKey:s.shardKey.trim(),sql:b,text:c,title:p};d(h===null?Q=>[...Q,{...U,id:we("w")}]:Q=>Q.map(Z=>Z.id===h?{...Z,...U}:Z)),O()},"B"),e[14]=s,e[15]=h,e[16]=d,e[17]=D):D=e[17];let W=D,L;e[18]!==n?(L=n("Charts, values, tables, and notes. Drag a tile to reorder."),e[18]=n,e[19]=L):L=e[19];let $;e[20]!==L?($=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:L}),e[20]=L,e[21]=$):$=e[21];let M;e[22]!==m||e[23]!==k||e[24]!==n?(M=!m&&(0,a.jsx)(X,{"data-testid":"dashboards-add",onClick:k,size:"sm",type:"button",children:n("Add widget")}),e[22]=m,e[23]=k,e[24]=n,e[25]=M):M=e[25];let z;e[26]!==$||e[27]!==M?(z=(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[$,M]}),e[26]=$,e[27]=M,e[28]=z):z=e[28];let q;e[29]!==o||e[30]!==n?(q=o.reason("chart")!==void 0&&(0,a.jsx)(le,{className:"text-xs",testId:"dashboards-suggest-error",variant:"destructive",children:n("Could not suggest a chart for that result.")}),e[29]=o,e[30]=n,e[31]=q):q=e[31];let B;e[32]!==s||e[33]!==h||e[34]!==m||e[35]!==W?(B=m&&(0,a.jsx)(Fe,{draft:s,editing:h!==null,onCancel:O,onChange:i,onSubmit:W}),e[32]=s,e[33]=h,e[34]=m,e[35]=W,e[36]=B):B=e[36];let I;e[37]!==o.unavailable||e[38]!==m||e[39]!==v||e[40]!==T||e[41]!==H||e[42]!==R||e[43]!==N||e[44]!==K||e[45]!==n||e[46]!==l?(I=l.length===0&&!m?(0,a.jsx)(me,{description:n("Add a chart, a single value, a table, or a note. Everything is saved on this browser."),testId:"dashboards-empty",title:n("No widgets yet")}):(0,a.jsx)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:l.map((p,b)=>(0,a.jsx)(_e,{draggedRef:u,first:b===0,inferring:v===p.id,last:b===l.length-1,onEdit:T,onMove:H,onRemove:R,onReorder:N,onSuggest:o.unavailable?void 0:K,widget:p},p.id))}),e[37]=o.unavailable,e[38]=m,e[39]=v,e[40]=T,e[41]=H,e[42]=R,e[43]=N,e[44]=K,e[45]=n,e[46]=l,e[47]=I):I=e[47];let A;return e[48]!==z||e[49]!==q||e[50]!==B||e[51]!==I?(A=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[z,q,B,I]}),e[48]=z,e[49]=q,e[50]=B,e[51]=I,e[52]=A):A=e[52],A},"it");export{tt as default};
@@ -0,0 +1 @@
1
+ import{a as ot}from"./chunk-FZ5SSAZU.js";import"./chunk-CSUROWL2.js";import"./chunk-RFNGDE33.js";import"./chunk-V3CZW3JB.js";import"./chunk-MU3P2FI7.js";import{a as Re}from"./chunk-IMOHEGMV.js";import{a as it}from"./chunk-Z5O2NQAV.js";import"./chunk-YPRQLCKF.js";import"./chunk-GMS77BZD.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import"./chunk-5JDWLCSH.js";import{a as nt}from"./chunk-NFS7FTAR.js";import{a as et}from"./chunk-S3CRZLGS.js";import{a as Ze}from"./chunk-EJSI4PMU.js";import{b as Ye}from"./chunk-OGUKYRFM.js";import{d as Pe,e as Be}from"./chunk-6D6Z2KXU.js";import"./chunk-OKG3HWSJ.js";import{W as Ue}from"./chunk-PLHA3OWK.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as ze}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as We}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Oe}from"./chunk-GOSWKLMM.js";import"./chunk-ULIQFBZU.js";import"./chunk-3PWB52UO.js";import"./chunk-35DM4JJG.js";import{a as F}from"./chunk-4ZEL6BYL.js";import{c as ce}from"./chunk-ERHFRNCL.js";import{f as Je}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import"./chunk-LCXKALTS.js";import{a as $e}from"./chunk-FKVZRPV5.js";import{a as tt,b as at,c as rt,d as Fe,e as q,f as T}from"./chunk-HEAQVSNS.js";import{a as He,e as Qe}from"./chunk-WUWBZPUK.js";import{d as le,f as Ve,g as Ge,h as Xe,p as Ne,t as Se}from"./chunk-PTZD7RUZ.js";import{a as o,d as se,e as De,f as Ee,g as Ae,i as de}from"./chunk-YKXDMIHQ.js";var pe=se(Ee(),1),ue=se(De(),1);var st=se(Ee(),1);var S=se(De(),1);var c=se(Ae(),1);var Nt=Ve(F.runMigration),dt=o(t=>{let e=(0,st.c)(98),{initialShardKey:r}=t,n=Je(),a=le(),{queryShardKey:s,setShardKey:i,shardKey:d}=et(r),[u,b]=(0,S.useState)(""),[h,y]=(0,S.useState)("up"),[p,g]=(0,S.useState)(!0),[f,x]=(0,S.useState)(!1),[v,m]=(0,S.useState)(null),[w,k]=(0,S.useState)(null),L;e[0]!==d?(L=d.trim(),e[0]=d,e[1]=L):L=e[1];let C=L===s,j;e[2]===Symbol.for("react.memo_cache_sentinel")?(j={},e[2]=j):j=e[2];let M;e[3]!==s?(M={live:!0,shardKey:s},e[3]=s,e[4]=M):M=e[4];let $=ce(F.migrationStatus,j,M),N=$.data?.migrations??null,Te=$.error,{errorSource:Ce,liveError:Me}=$,fe,ge;e[5]!==s||e[6]!==$.data?(fe=o(()=>{$.data!==void 0&&Ye(s)},"W"),ge=[$.data,s],e[5]=s,e[6]=$.data,e[7]=fe,e[8]=ge):(fe=e[7],ge=e[8]),(0,S.useEffect)(fe,ge);let be;if(e[9]!==n||e[10]!==h||e[11]!==p||e[12]!==u||e[13]!==d||e[14]!==$||e[15]!==a){let I=o(async()=>{let Ke=u.trim();if(Ke===""){k(a("Enter a migration id")),m(null);return}x(!0),k(null);try{let Ie=await n.query(Nt,{direction:h,dryRun:p,id:Ke},Ge(d));m(Ie),$.refetch()}catch(Ie){let $t=Ie;m(null),k(Xe($t))}x(!1)},"m");be=o(()=>{Ne(I())},"V"),e[9]=n,e[10]=h,e[11]=p,e[12]=u,e[13]=d,e[14]=$,e[15]=a,e[16]=be}else be=e[16];let ye=be,ve;e[17]===Symbol.for("react.memo_cache_sentinel")?(ve=o(I=>{b(I.target.value)},"Y"),e[17]=ve):ve=e[17];let xt=ve,xe;e[18]===Symbol.for("react.memo_cache_sentinel")?(xe=o(I=>{y(I.target.value==="down"?"down":"up")},"Z"),e[18]=xe):xe=e[18];let kt=xe,ke;e[19]===Symbol.for("react.memo_cache_sentinel")?(ke=o(I=>{g(I.target.checked)},"ee"),e[19]=ke):ke=e[19];let wt=ke,_;e[20]!==i||e[21]!==d?(_=(0,c.jsx)(Ze,{onChange:i,testId:"mg-shard-input",value:d}),e[20]=i,e[21]=d,e[22]=_):_=e[22];let K;e[23]!==Me?(K=(0,c.jsx)(it,{message:Me,prefix:"mg"}),e[23]=Me,e[24]=K):K=e[24];let D;e[25]!==_||e[26]!==K?(D=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[_,K]}),e[25]=_,e[26]=K,e[27]=D):D=e[27];let E;e[28]!==Te||e[29]!==Ce?(E=Te!==null&&(0,c.jsx)(Oe,{error:Ce,testId:"mg-status-error"}),e[28]=Te,e[29]=Ce,e[30]=E):E=e[30];let A;e[31]!==N||e[32]!==a?(A=N!==null&&N.length===0&&(0,c.jsx)($e,{description:a("Data migrations you run against this shard will be tracked here."),icon:(0,c.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,c.jsx)("path",{d:"M4 12a8 8 0 0 1 13.7-5.6L20 8M20 4v4h-4M20 12a8 8 0 0 1-13.7 5.6L4 16m0 4v-4h4"})}),testId:"mg-empty",title:a("No migrations have run on this shard.")}),e[31]=N,e[32]=a,e[33]=A):A=e[33];let J;e[34]!==N||e[35]!==a?(J=N!==null&&N.length>0&&(0,c.jsx)(He,{className:"overflow-hidden py-0",children:(0,c.jsx)(Qe,{className:"px-0",children:(0,c.jsxs)(tt,{"data-testid":"mg-table",children:[(0,c.jsx)(at,{children:(0,c.jsxs)(Fe,{children:[(0,c.jsx)(q,{children:a("id")}),(0,c.jsx)(q,{children:a("direction")}),(0,c.jsx)(q,{children:a("status")}),(0,c.jsx)(q,{children:a("processed")}),(0,c.jsx)(q,{children:a("changed")}),(0,c.jsx)(q,{children:a("updated")}),(0,c.jsx)(q,{children:a("error")})]})}),(0,c.jsx)(rt,{children:N.map(St)})]})})}),e[34]=N,e[35]=a,e[36]=J):J=e[36];let P;e[37]!==a?(P=a("Run migration"),e[37]=a,e[38]=P):P=e[38];let B;e[39]!==P?(B=(0,c.jsx)(Re,{children:P}),e[39]=P,e[40]=B):B=e[40];let W;e[41]!==a?(W=a("Migration id"),e[41]=a,e[42]=W):W=e[42];let U;e[43]!==a?(U=a("migration id"),e[43]=a,e[44]=U):U=e[44];let z;e[45]!==u||e[46]!==W||e[47]!==U?(z=(0,c.jsx)(Ue,{"aria-label":W,className:"w-auto","data-testid":"mg-id-input",onChange:xt,placeholder:U,value:u}),e[45]=u,e[46]=W,e[47]=U,e[48]=z):z=e[48];let H;e[49]!==a?(H=a("Direction"),e[49]=a,e[50]=H):H=e[50];let Q;e[51]!==a?(Q=a("up"),e[51]=a,e[52]=Q):Q=e[52];let V;e[53]!==Q?(V=(0,c.jsx)("option",{value:"up",children:Q}),e[53]=Q,e[54]=V):V=e[54];let G;e[55]!==a?(G=a("down"),e[55]=a,e[56]=G):G=e[56];let X;e[57]!==G?(X=(0,c.jsx)("option",{value:"down",children:G}),e[57]=G,e[58]=X):X=e[58];let Y;e[59]!==h||e[60]!==H||e[61]!==V||e[62]!==X?(Y=(0,c.jsxs)("select",{"aria-label":H,className:"flex h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 dark:bg-input/30","data-testid":"mg-direction",onChange:kt,value:h,children:[V,X]}),e[59]=h,e[60]=H,e[61]=V,e[62]=X,e[63]=Y):Y=e[63];let Z;e[64]!==p?(Z=(0,c.jsx)("input",{checked:p,className:"size-4 accent-primary","data-testid":"mg-dry-run",id:"mg-dry-run",onChange:wt,type:"checkbox"}),e[64]=p,e[65]=Z):Z=e[65];let ee;e[66]!==a?(ee=a("Dry run"),e[66]=a,e[67]=ee):ee=e[67];let te;e[68]!==Z||e[69]!==ee?(te=(0,c.jsxs)(Re,{className:"flex items-center gap-1.5",htmlFor:"mg-dry-run",children:[Z,ee]}),e[68]=Z,e[69]=ee,e[70]=te):te=e[70];let ae;e[71]!==p||e[72]!==ye||e[73]!==f||e[74]!==C||e[75]!==a?(ae=p?(0,c.jsx)(ze,{"data-testid":"mg-run",disabled:f||!C,onClick:ye,type:"button",children:a(f?"Running\u2026":"Run")}):(0,c.jsx)(nt,{confirmLabel:a(f?"Running\u2026":"Run migration?"),disabled:f||!C,onConfirm:ye,testId:"mg-run",children:a("Run")}),e[71]=p,e[72]=ye,e[73]=f,e[74]=C,e[75]=a,e[76]=ae):ae=e[76];let re;e[77]!==z||e[78]!==Y||e[79]!==te||e[80]!==ae?(re=(0,c.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[z,Y,te,ae]}),e[77]=z,e[78]=Y,e[79]=te,e[80]=ae,e[81]=re):re=e[81];let ne;e[82]!==B||e[83]!==re?(ne=(0,c.jsxs)("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs",children:[B,re]}),e[82]=B,e[83]=re,e[84]=ne):ne=e[84];let ie;e[85]!==w?(ie=w!==null&&(0,c.jsx)("pre",{className:"text-sm text-destructive whitespace-pre-wrap","data-testid":"mg-run-error",role:"alert",children:w}),e[85]=w,e[86]=ie):ie=e[86];let oe;e[87]!==v||e[88]!==a?(oe=v!==null&&(0,c.jsxs)("p",{className:"text-sm text-muted-foreground","data-testid":"mg-run-result",children:[v.dryRun?a("Dry run: "):"",a("{status} \u2014 processed",{status:v.status}),v.processed,a(", changed"),v.changed]}),e[87]=v,e[88]=a,e[89]=oe):oe=e[89];let we;return e[90]!==D||e[91]!==E||e[92]!==A||e[93]!==J||e[94]!==ne||e[95]!==ie||e[96]!==oe?(we=(0,c.jsxs)("div",{className:"flex flex-col gap-3 pt-4","data-testid":"lunora-migrations",children:[D,E,A,J,ne,ie,oe]}),e[90]=D,e[91]=E,e[92]=A,e[93]=J,e[94]=ne,e[95]=ie,e[96]=oe,e[97]=we):we=e[97],we},"yt");function St(t){return(0,c.jsxs)(Fe,{"data-testid":`mg-row-${t.id}`,children:[(0,c.jsx)(T,{children:t.id}),(0,c.jsx)(T,{children:t.direction}),(0,c.jsx)(T,{children:(0,c.jsx)(We,{variant:"secondary",children:t.status})}),(0,c.jsx)(T,{children:t.processed}),(0,c.jsx)(T,{children:t.changed}),(0,c.jsx)(T,{children:Se(t.updatedAt)}),(0,c.jsx)(T,{children:t.error??""})]},t.id)}o(St,"Je");var l=se(Ae(),1);var Le=1;function Ot(t){let e={},r=Object.keys(t);r.sort();for(let n of r)e[n]=t[n];return e}o(Ot,"re");var me=o(t=>typeof t=="object"&&t!==null,"O"),jt=o(t=>me(t)&&me(t.fields)&&me(t.indexes)&&me(t.relations)&&typeof t.shardMode=="string","de"),qt=o(t=>{if(t===void 0||t.trim()==="")return{status:"absent"};let e;try{e=JSON.parse(t)}catch(r){return{error:`baseline is not valid JSON: ${r instanceof Error?r.message:String(r)}`,status:"invalid"}}if(!me(e)||e.version!==Le||!me(e.tables))return{error:`baseline is malformed or written by an incompatible version (expected version ${String(Le)})`,status:"invalid"};for(let[r,n]of Object.entries(e.tables))if(!jt(n))return{error:`baseline table "${r}" has an invalid structure`,status:"invalid"};return{snapshot:{jurisdiction:typeof e.jurisdiction=="string"?e.jurisdiction:void 0,migrationIds:Array.isArray(e.migrationIds)?e.migrationIds:[],tables:e.tables,version:Le},status:"ok"}},"le"),Tt=o((t,e)=>t.unique===e.unique&&t.fields.length===e.fields.length&&t.fields.every((r,n)=>r===e.fields[n]),"ce"),lt=o(t=>t.unique!==void 0,"J"),_e=o(({nullable:t,optional:e,refined:r,unique:n,...a})=>JSON.stringify(Ot(a)),"D"),ct=o(t=>({form:JSON.stringify([_e(t),t.optional===!0,t.nullable===!0]),refined:t.refined===!0}),"H"),mt=o(t=>t.kind==="union"&&t.members?t.members.map(e=>ct(e)):[ct({...t,nullable:!1,optional:!1})],"V"),Ct=o((t,e)=>{if(e.kind!=="union")return!1;let r=mt(e);return mt(t).every(n=>r.some(a=>a.form===n.form&&(n.refined||!a.refined)))},"me"),O=o(t=>{switch(t.kind){case"array":return`array(${t.of?O(t.of):"?"})`;case"id":return`id(${t.ref??"?"})`;case"literal":return`literal(${t.literal??"?"})`;case"object":return`object({ ${Object.keys(t.fields??{}).join(", ")} })`;case"record":return`record(${t.key?O(t.key):"?"}, ${t.of?O(t.of):"?"})`;case"union":return(t.members??[]).map(e=>O(e)).join(" | ");default:return t.kind}},"x"),he=o((t,e,r)=>({remediation:"backfill",scope:"table",severity:"breaking",summary:r,table:t,type:e}),"T"),qe=o((t,e,r)=>({remediation:"none",scope:"table",severity:"safe",summary:r,table:t,type:e}),"q"),Mt=o((t,e,r,n,a)=>{if(!(r.kind===n.kind&&(!a||_e(r)===_e(n))))return a&&Ct(r,n)?qe(t,"widenedFieldShape",`field ${t}.${e} widened: ${O(r)} \u2192 ${O(n)} \u2014 every stored value stays valid`):r.kind!==n.kind?he(t,"changedFieldKind",`field ${t}.${e} changed type: ${r.kind} \u2192 ${n.kind} \u2014 add a data migration to convert existing values`):he(t,"changedFieldShape",`field ${t}.${e} changed shape: ${O(r)} \u2192 ${O(n)} \u2014 stored values were written against the old shape; add a data migration to convert them`)},"he"),It=o((t,e,r,n)=>{let a=[];return r.unique!==n.unique&&a.push(n.unique===!0?he(t,"addedFieldConstraint",`field ${t}.${e} became unique \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} is no longer unique`)),r.nullable!==n.nullable&&a.push(n.nullable===!0?qe(t,"relaxedFieldConstraint",`field ${t}.${e} became nullable`):he(t,"addedFieldConstraint",`field ${t}.${e} is no longer nullable \u2014 rows holding NULL would be invalid; add a data migration to backfill them`)),r.refined!==n.refined&&a.push(n.refined===!0?he(t,"addedFieldConstraint",`field ${t}.${e} gained a validation refinement \u2014 stored values were never checked against it; add a data migration if any could fail`):qe(t,"relaxedFieldConstraint",`field ${t}.${e} dropped its validation refinement`)),a},"fe"),yt=o((t,e,r,n)=>{let a=[],s=lt(r)&&lt(n),i=Mt(t,e,r,n,s);return i&&a.push(i),s&&a.push(...It(t,e,r,n)),r.optional&&!n.optional?a.push({remediation:"backfill",severity:"breaking",summary:`field ${t}.${e} became required \u2014 rows missing it would be invalid; add a data migration to backfill it`,table:t,scope:"table",type:"fieldOptionalToRequired"}):!r.optional&&n.optional&&a.push({remediation:"none",scope:"table",severity:"safe",summary:`field ${t}.${e} became optional`,table:t,type:"fieldRequiredToOptional"}),a},"Y"),Ft=o((t,e,r)=>r.optional?{remediation:"none",scope:"table",severity:"safe",summary:`added optional field ${t}.${e}`,table:t,type:"addedOptionalField"}:{remediation:"backfill",severity:"breaking",summary:`added required field ${t}.${e} \u2014 existing rows have no value; add a data migration to backfill it`,table:t,scope:"table",type:"addedRequiredField"},"ue"),Rt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.fields)){let i=e.fields[a];i===void 0?n.push(Ft(t,a,s)):n.push(...yt(t,a,i,s))}for(let a of Object.keys(e.fields))r.fields[a]===void 0&&n.push({remediation:"backfill",severity:"breaking",summary:`removed field ${t}.${a} \u2014 add a data migration if stored data must be cleaned up`,table:t,scope:"table",type:"removedField"})},"pe"),Lt=o((t,e,r,n)=>{for(let[a,s]of Object.entries(r.indexes)){let i=e.indexes[a];if(i===void 0){n.push(s.unique?{remediation:"backfill",scope:"table",severity:"breaking",summary:`added unique index ${a} on ${t} \u2014 existing duplicates would violate it; add a data migration to de-duplicate first`,table:t,type:"addedIndex"}:{remediation:"none",scope:"table",severity:"safe",summary:`added index ${a} on ${t}`,table:t,type:"addedIndex"});continue}Tt(i,s)||n.push({remediation:"code",severity:"breaking",summary:`index ${a} on ${t} changed shape \u2014 a query may have relied on the old index`,table:t,scope:"table",type:"changedIndex"})}for(let a of Object.keys(e.indexes))r.indexes[a]===void 0&&n.push({remediation:"code",severity:"breaking",summary:`removed index ${a} on ${t} \u2014 a query that used \`.withIndex("${a}")\` would break`,table:t,scope:"table",type:"removedIndex"})},"ge"),_t=o((t,e,r,n)=>{for(let a of Object.keys(r.relations))e.relations[a]===void 0&&n.push({remediation:"none",scope:"schema",severity:"safe",summary:`added relation ${t}.${a}`,table:t,type:"addedRelation"});for(let a of Object.keys(e.relations))r.relations[a]===void 0&&n.push({remediation:"code",scope:"schema",severity:"breaking",summary:`removed relation ${t}.${a}`,table:t,type:"removedRelation"})},"be"),ut="shardBy:_unknown_",je="global",Kt=o((t,e)=>t===je&&e.startsWith(`${je}:`)||e===je&&t.startsWith(`${je}:`),"ye"),Dt=o((t,e,r)=>{if(e===r)return r!==ut?void 0:{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} declares a non-literal .shardBy(...) key, so codegen cannot read which column partitions it \u2014 every such key records as "${ut}" and two DIFFERENT keys would compare equal. Pass the shard key as a string literal; until then this is reported on every run, because the alternative is a silent pass on a re-home that strands every row (export/import is the only way back).`,table:t,type:"changedShardMode"};if(!Kt(e,r))return{remediation:"rehome",severity:"breaking",summary:`table ${t} changed shard mode: ${e} \u2192 ${r} \u2014 its physical storage moves, and existing rows do NOT follow the schema; re-home them with an export/import round trip (https://lunora.sh/docs/concepts/sharding#migrating-a-populated-table)`,table:t,scope:"table",type:"changedShardMode"}},"ve"),ht=o(t=>t.memory!==void 0,"Q"),pt=o(t=>t.after??0,"W"),R=o(t=>t.after===void 0?`.ttl("${t.field}")`:`.ttl("${t.field}", { after: ${String(t.after)} })`,"w"),Et=o((t,e,r)=>{if(e===void 0&&r===void 0)return;let n=o(d=>({remediation:"backfill",scope:"table",severity:"breaking",summary:d,table:t,type:"changedTtlPolicy"}),"n"),a=o(d=>({remediation:"none",scope:"table",severity:"safe",summary:d,table:t,type:"changedTtlPolicy"}),"s");if(r===void 0)return a(`table ${t} dropped its TTL policy \u2014 its rows are no longer swept`);if(e===void 0)return n(`table ${t} gained a TTL policy ${R(r)} \u2014 every row already past the cutoff is deleted on the next alarm sweep; add a data migration to refresh or clear "${r.field}" on the rows written before it`);if(e.field!==r.field)return n(`table ${t} moved its TTL to a different column: ${R(e)} \u2192 ${R(r)} \u2014 rows are now expired by a column they were never written against; add a data migration to populate "${r.field}"`);let s=pt(e),i=pt(r);return i<s?n(`table ${t} shortened its TTL: ${R(e)} \u2192 ${R(r)} \u2014 rows that were not expired under the old offset are deleted on the next alarm sweep; add a data migration to refresh "${r.field}" on the rows that must survive`):i>s?a(`table ${t} lengthened its TTL: ${R(e)} \u2192 ${R(r)}`):void 0},"xe"),At=o((t,e,r)=>{let n=[];return e.memory!==r.memory&&n.push(r.memory===!0?{remediation:"rehome",scope:"table",severity:"breaking",summary:`table ${t} became a .memory() table \u2014 every row is deleted in every shard on the next Durable Object cold start, and no data migration survives that; export the rows first if they must be kept, or revert`,table:t,type:"changedMemoryMode"}:{remediation:"none",scope:"table",severity:"safe",summary:`table ${t} is no longer a .memory() table \u2014 its rows now survive a cold start`,table:t,type:"changedMemoryMode"}),e.commitOrdered!==r.commitOrdered&&n.push(r.commitOrdered===!0?{remediation:"backfill",scope:"table",severity:"breaking",summary:`table ${t} became .commitOrdered() \u2014 rows written before it carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed never offers them; add a data migration over the table to stamp them (the rewrite allocates a sequence)`,table:t,type:"changedCommitOrdering"}:{remediation:"code",scope:"table",severity:"breaking",summary:`table ${t} is no longer .commitOrdered() \u2014 new rows carry no _commitSeq, so a \`_commitSeq > cursor\` changefeed stops advancing without erroring; update the consumers before deploying`,table:t,type:"changedCommitOrdering"}),n},"ke"),Jt=o((t,e,r,n)=>{let a=Dt(t,e.shardMode,r.shardMode);if(a&&n.push(a),ht(e)&&ht(r)){n.push(...At(t,e,r));let s=Et(t,e.ttl,r.ttl);s&&n.push(s)}Rt(t,e,r,n),Lt(t,e,r,n),_t(t,e,r,n)},"$e"),Pt=o((t,e)=>{let r=[],n=t?.tables??{};for(let[a,s]of Object.entries(e.tables)){let i=n[a];if(i===void 0){r.push({remediation:"none",scope:"table",severity:"safe",summary:`added table ${a}`,table:a,type:"addedTable"});continue}Jt(a,i,s,r)}for(let a of Object.keys(n))e.tables[a]===void 0&&r.push({remediation:"rehome",scope:"table",severity:"breaking",summary:`removed table ${a} \u2014 its rows stay in each shard's SQLite, unreachable through the schema; export the shard first if the data must be kept`,table:a,type:"removedTable"});if(t!==void 0&&t.jurisdiction!==e.jurisdiction){let a=t.jurisdiction??"(none)",s=e.jurisdiction??"(none)";r.push({remediation:"rehome",scope:"schema",severity:"breaking",summary:`Durable Object jurisdiction changed from ${a} to ${s} \u2014 this re-homes every DO and strands all existing shard, scheduler, and session-DO data in the old region (no in-place migration; export then import to move it). Revert the change, or override the gate to proceed intentionally.`,type:"changedJurisdiction"})}return{changes:r}},"we"),ft=o(t=>Object.entries(t.fields).map(([e,r])=>({name:e,optional:r.optional,ref:Object.values(t.relations).find(n=>n.field===e&&n.kind==="one")?.table,type:O(r)})),"B"),gt=o((t,e,r)=>{let n={},a=e?.fields??{},s=r?.fields??{};for(let[i,d]of Object.entries(s)){let u=a[i];u===void 0?n[i]=e===void 0?"unchanged":"added":n[i]=yt(t,i,u,d).length===0?"unchanged":"changed"}for(let i of Object.keys(a))s[i]===void 0&&(n[i]="removed");return n},"U"),Bt=o((t,e)=>{let{changes:r}=Pt(t,e),n=new Set(r.filter(i=>i.scope==="table"&&i.table!==void 0).map(i=>i.table)),a=[],s=o((i,d)=>i?"added":n.has(d)?"changed":"context","a");for(let[i,d]of Object.entries(e.tables)){let u=t?.tables[i],b=s(u===void 0,i);a.push({columns:ft(d),fieldStatus:gt(i,u,d),name:i,shardMode:d.shardMode,status:b})}for(let[i,d]of Object.entries(t?.tables??{}))e.tables[i]===void 0&&a.push({columns:ft(d),fieldStatus:gt(i,d,void 0),name:i,shardMode:d.shardMode,status:"removed"});return a.sort((i,d)=>i.name.localeCompare(d.name)),{breakingCount:r.filter(i=>i.severity==="breaking").length,changes:r,tables:a}},"Oe"),bt=o(t=>{let e=qt(t);return e.status==="ok"?e.snapshot:void 0},"K"),Wt={added:"ring-2 ring-emerald-500/60",changed:"ring-2 ring-amber-500/70",context:"opacity-55",removed:"opacity-70 ring-2 ring-destructive/60"},Ut=o(t=>t==="global"||t.startsWith("global:")?"global":"shard","Te"),zt=o(t=>{let e=(0,pe.c)(24),{appliedAt:r,hash:n,onSelect:a,selected:s,seq:i}=t,d=s?"border-s-primary bg-accent/60 text-foreground":"border-s-transparent text-muted-foreground hover:bg-accent/30 hover:text-foreground",u;e[0]!==d?(u=de("flex w-full flex-col items-start gap-1 border-s-2 px-4 py-3 text-start outline-none transition-colors",d),e[0]=d,e[1]=u):u=e[1];let b=`sh-version-${n}`,h;e[2]!==n||e[3]!==a?(h=o(()=>{a(n)},"u"),e[2]=n,e[3]=a,e[4]=h):h=e[4];let y;e[5]!==i?(y=(0,l.jsxs)("span",{className:"font-mono text-[13px] tabular-nums",children:["v",i]}),e[5]=i,e[6]=y):y=e[6];let p;e[7]!==n?(p=n.slice(0,7),e[7]=n,e[8]=p):p=e[8];let g;e[9]!==p?(g=(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-wider text-muted-foreground/70 uppercase",children:p}),e[9]=p,e[10]=g):g=e[10];let f;e[11]!==y||e[12]!==g?(f=(0,l.jsxs)("span",{className:"flex w-full items-baseline gap-2",children:[y,g]}),e[11]=y,e[12]=g,e[13]=f):f=e[13];let x;e[14]!==r?(x=Se(r),e[14]=r,e[15]=x):x=e[15];let v;e[16]!==x?(v=(0,l.jsx)("span",{className:"font-mono text-[10px] tracking-wide text-muted-foreground/70",children:x}),e[16]=x,e[17]=v):v=e[17];let m;return e[18]!==v||e[19]!==u||e[20]!==b||e[21]!==h||e[22]!==f?(m=(0,l.jsx)("li",{children:(0,l.jsxs)("button",{className:u,"data-testid":b,onClick:h,type:"button",children:[f,v]})}),e[18]=v,e[19]=u,e[20]=b,e[21]=h,e[22]=f,e[23]=m):m=e[23],m},"je"),Ht=o(t=>{let e=(0,pe.c)(26),{breaking:r,count:n,first:a}=t,s=le();if(a){let g;e[0]!==n?(g=(0,l.jsx)("span",{className:"text-3xl leading-none font-light tracking-tight tabular-nums",children:n}),e[0]=n,e[1]=g):g=e[1];let f;e[2]!==s?(f=s("tables"),e[2]=s,e[3]=f):f=e[3];let x;e[4]!==f?(x=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:f}),e[4]=f,e[5]=x):x=e[5];let v;return e[6]!==g||e[7]!==x?(v=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[g,x]}),e[6]=g,e[7]=x,e[8]=v):v=e[8],v}let i=r>0&&"text-destructive",d;e[9]!==i?(d=de("text-3xl leading-none font-light tracking-tight tabular-nums",i),e[9]=i,e[10]=d):d=e[10];let u;e[11]!==n||e[12]!==d?(u=(0,l.jsx)("span",{className:d,children:n}),e[11]=n,e[12]=d,e[13]=u):u=e[13];let b;e[14]!==n||e[15]!==s?(b=s(n===1?"change":"changes"),e[14]=n,e[15]=s,e[16]=b):b=e[16];let h;e[17]!==b?(h=(0,l.jsx)("span",{className:"font-mono text-[11px] tracking-widest text-muted-foreground uppercase",children:b}),e[17]=b,e[18]=h):h=e[18];let y;e[19]!==r||e[20]!==s?(y=r>0&&(0,l.jsxs)("span",{className:"font-mono text-[11px] tracking-widest text-destructive uppercase",children:["\xB7 ",s("{count} breaking",{count:r})]}),e[19]=r,e[20]=s,e[21]=y):y=e[21];let p;return e[22]!==u||e[23]!==h||e[24]!==y?(p=(0,l.jsxs)("div",{className:"flex items-baseline gap-3","data-testid":"sh-summary",children:[u,h,y]}),e[22]=u,e[23]=h,e[24]=y,e[25]=p):p=e[25],p},"Fe"),vt={addedFieldConstraint:{action:"added",kind:"constraint"},addedIndex:{action:"added",kind:"index"},addedOptionalField:{action:"added",kind:"field?"},addedRelation:{action:"added",kind:"relation"},addedRequiredField:{action:"added",kind:"field"},addedTable:{action:"added",kind:"table"},changedCommitOrdering:{action:"changed",kind:"commit ordering"},changedFieldKind:{action:"changed",kind:"field kind"},changedFieldShape:{action:"changed",kind:"field shape"},changedIndex:{action:"changed",kind:"index"},changedJurisdiction:{action:"changed",kind:"jurisdiction"},changedMemoryMode:{action:"changed",kind:"memory mode"},changedShardMode:{action:"changed",kind:"shard mode"},changedTtlPolicy:{action:"changed",kind:"TTL policy"},fieldOptionalToRequired:{action:"changed",kind:"field \u2192 required"},fieldRequiredToOptional:{action:"changed",kind:"field \u2192 optional"},relaxedFieldConstraint:{action:"removed",kind:"constraint"},removedField:{action:"removed",kind:"field"},removedIndex:{action:"removed",kind:"index"},removedRelation:{action:"removed",kind:"relation"},removedTable:{action:"removed",kind:"table"},widenedFieldShape:{action:"changed",kind:"field \u2192 wider"}},Qt=o((t,e)=>{let r=`${vt[t.type].action} ${e} `;return t.summary.startsWith(r)?t.summary.slice(r.length):t.summary},"qe"),Vt=o(t=>{let e=new Map;for(let n of t){let a=n.table??"",s=e.get(a);s===void 0?e.set(a,[n]):s.push(n)}let r=[...e].map(([n,a])=>({changes:a,table:n}));return[...r.filter(n=>n.table!==""),...r.filter(n=>n.table==="")]},"Ce"),Gt=o(t=>{let e=(0,pe.c)(2),{children:r}=t,n;return e[0]!==r?(n=(0,l.jsx)("div",{className:"px-4 pt-4 pb-2 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:r}),e[0]=r,e[1]=n):n=e[1],n},"Me"),Xt=o(({pane:t,shardKey:e=""})=>{let r=le(),n=Be(),a=Pe({strict:!1}).version,s=o(m=>{Ne(n({search:{version:m},to:"/migrations"}))},"o"),i=ce(F.schemaHistory,{},{shardKey:e}),d=i.data?.versions??[],u=a!==void 0&&d.some(m=>m.hash===a)?a:d[0]?.hash,b=d.findIndex(m=>m.hash===u),h=b===-1?void 0:d[b+1]?.hash,y=ce(F.schemaVersion,{hash:u??""},{enabled:u!==void 0,shardKey:e}),p=ce(F.schemaVersion,{hash:h??""},{enabled:h!==void 0,shardKey:e}),g=(0,ue.useMemo)(()=>{let m=bt(y.data?.version?.snapshotJson);if(m!==void 0)return Bt(bt(p.data?.version?.snapshotJson),m)},[y.data,p.data]),f=(0,ue.useMemo)(()=>(g?.tables??[]).map(m=>({columns:m.columns,name:m.name,tier:Ut(m.shardMode)})),[g]),x=(0,ue.useMemo)(()=>{let m={};for(let w of g?.tables??[])m[w.name]=Wt[w.status];return m},[g]);if(i.error!==null)return(0,l.jsx)(Oe,{error:i.errorSource,testId:"sh-error"});if(d.length===0)return(0,l.jsx)($e,{description:r("Each distinct schema shape this shard runs is recorded here, so you can see what changed and when."),testId:"sh-empty",title:r("No schema versions recorded yet.")});let v=g?.changes??[];return(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 gap-4","data-testid":"lunora-schema-history",children:[(0,l.jsxs)("nav",{className:"flex w-56 shrink-0 flex-col overflow-hidden border-e border-border","data-testid":"sh-timeline-rail",children:[(0,l.jsx)(Gt,{children:r("Schema versions")}),(0,l.jsx)("ul",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-timeline",children:d.map(m=>(0,l.jsx)(zt,{appliedAt:m.appliedAt,hash:m.hash,onSelect:s,selected:m.hash===u,seq:m.seq},m.hash))})]}),(0,l.jsxs)("div",{className:"flex min-h-0 min-w-0 flex-1 flex-col gap-4 pe-1 pt-4",children:[(0,l.jsx)(Ht,{breaking:g?.breakingCount??0,count:h===void 0?f.length:v.length,first:h===void 0}),t==="diagram"?(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:(0,l.jsx)(ot,{fill:!0,nodeClasses:x,tables:f,testIdPrefix:"sh"})}):(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto","data-testid":"sh-changes",children:Vt(v).map(m=>{let w=(g?.tables??[]).find(k=>k.name===m.table);return(0,l.jsxs)("section",{className:"mb-6",children:[(0,l.jsxs)("div",{className:"flex items-baseline gap-3 border-b border-border/60 pb-1.5",children:[(0,l.jsx)("span",{className:"font-mono text-[13px] text-foreground",children:m.table===""?r("schema"):m.table}),w!==void 0&&(0,l.jsx)("span",{className:"font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums uppercase",children:r("{count} columns",{count:w.columns.length})}),m.changes.length>1&&(0,l.jsx)("span",{className:"ms-auto font-mono text-[10px] tracking-widest text-muted-foreground/70 tabular-nums",children:m.changes.length})]}),(0,l.jsx)("ul",{children:m.changes.map(k=>{let{action:L,kind:C}=vt[k.type],j=k.severity==="breaking",M=Qt(k,C);return(0,l.jsxs)("li",{className:"flex items-baseline gap-4 border-s-2 py-1.5 ps-3 transition-colors hover:bg-accent/30",children:[(0,l.jsx)("span",{"aria-hidden":"true",className:de("-ms-3 h-3 w-0.5 shrink-0 self-center",j?"bg-destructive":"bg-transparent")}),(0,l.jsxs)("span",{className:"w-44 shrink-0 font-mono text-[10px] tracking-widest text-muted-foreground/70 uppercase",children:[r(L)," ",C]}),M!==m.table&&(0,l.jsx)("span",{className:de("min-w-0 font-mono text-[13px]",j?"text-destructive":"text-foreground"),children:M}),j&&(0,l.jsx)("span",{className:"ms-auto shrink-0 font-mono text-[10px] tracking-widest text-destructive uppercase",children:r("breaking")})]},`${k.type}-${k.summary}`)})})]},m.table)})})]})]})},"Ie"),Yt=o(t=>de("-mb-px border-b-2 px-3 py-2.5 font-mono text-[11px] tracking-wider uppercase transition-colors outline-none","hover:bg-accent/40 focus-visible:bg-accent/40",t?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),"Re"),Ta=o(t=>{let e=(0,pe.c)(11),{initialShardKey:r}=t,n=le(),[a,s]=(0,ue.useState)("diagram"),i;e[0]!==a?(i=o((y,p,g,f)=>(0,l.jsxs)("button",{"aria-selected":a===y,className:Yt(a===y),"data-testid":g,onClick:o(()=>{s(y)},"onClick"),role:"tab",type:"button",children:[p,f!==void 0&&(0,l.jsx)("span",{className:"ms-2 tabular-nums text-muted-foreground/70",children:f})]}),"o"),e[0]=a,e[1]=i):i=e[1];let d=i,u;e[2]!==n||e[3]!==d?(u=(0,l.jsxs)("div",{className:"flex shrink-0 items-center gap-1 border-b border-border px-3","data-testid":"mg-panes",role:"tablist",children:[d("diagram",n("Diagram"),"mg-pane-diagram"),d("changes",n("Changes"),"mg-pane-changes"),d("data",n("Data migrations"),"mg-pane-data")]}),e[2]=n,e[3]=d,e[4]=u):u=e[4];let b;e[5]!==r||e[6]!==a?(b=(0,l.jsx)("div",{className:"flex min-h-0 flex-1 flex-col",children:a==="data"?(0,l.jsx)("div",{className:"min-h-0 flex-1 overflow-y-auto px-4",children:(0,l.jsx)(dt,{initialShardKey:r})}):(0,l.jsx)(Xt,{pane:a,shardKey:r})}),e[5]=r,e[6]=a,e[7]=b):b=e[7];let h;return e[8]!==u||e[9]!==b?(h=(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col pt-4","data-testid":"lunora-migrations-route",children:[u,b]}),e[8]=u,e[9]=b,e[10]=h):h=e[10],h},"Ue");export{Ta as default};
@@ -0,0 +1 @@
1
+ import{a as se}from"./chunk-EA2JKR5D.js";import{W as ae}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as W}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import{a as G}from"./chunk-4ZEL6BYL.js";import{c as ne}from"./chunk-ERHFRNCL.js";import{f as V}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import"./chunk-LCXKALTS.js";import{a as K}from"./chunk-FKVZRPV5.js";import{a as j,b as D,c as F,d as w,e as l,f as i}from"./chunk-HEAQVSNS.js";import{a as R,e as _}from"./chunk-WUWBZPUK.js";import{d as X,f as Y,g as Z,h as $,m as ee,p as A}from"./chunk-PTZD7RUZ.js";import{a as s,d as re,e as oe,g as le}from"./chunk-YKXDMIHQ.js";var d=re(oe(),1);var e=re(le(),1);var ie=["queued","running","paused","waiting","complete","errored","terminated"],de=["pause","resume","terminate"],ce="WORKFLOWS_NOT_CONFIGURED",ue=s(o=>typeof o=="object"&&o!==null&&o.code===ce,"ce"),me=s(o=>{let a=o.error??o.output;if(a===void 0)return"\u2014";try{return JSON.stringify(a,ee)}catch{return"(unserializable)"}},"ue"),fe=s(({loadDetail:o,loadInstances:a,readOnly:g,runAction:J,workflowName:k})=>{let T=V(),n=X(),[N,v]=(0,d.useState)(null),[C,I]=(0,d.useState)(null),[b,z]=(0,d.useState)(""),[y,p]=(0,d.useState)(null),[L,O]=(0,d.useState)(!1),[P,U]=(0,d.useState)(null),f=(0,d.useRef)(0),h=(0,d.useRef)(0),x=(0,d.useRef)(0),q=o??(r=>T.getWorkflowInstance(r)),E=g?void 0:J??(a===void 0?r=>T.setWorkflowInstanceStatus(r):void 0),B=s(async()=>{h.current+=1;let r=h.current;p(null),O(!1);let c=b===""?void 0:b;try{if(a===void 0){let u=await T.listWorkflowInstances({name:k,status:c});if(r!==h.current)return;if(u.configured===!1){v(null),O(!0);return}v(u.instances);return}let t=await a({name:k,status:c});r===h.current&&v(t)}catch(t){if(r!==h.current)return;v(null),ue(t)?O(!0):p($(t))}},"P");(0,d.useEffect)(()=>{f.current+=1,x.current+=1,I(null),A(B())},[k,b]);let M=s(async r=>{x.current+=1;let c=x.current;p(null);try{let t=await q({id:r,name:k});c===x.current&&I(t)}catch(t){c===x.current&&p($(t))}},"J"),H=s(()=>{x.current+=1,I(null)},"B"),Q=s(async(r,c)=>{if(E===void 0)return;let t=f.current;U(r),p(null);try{await E({action:c,id:r,name:k}),t===f.current&&await B()}catch(u){p($(u))}U(null)},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:n("Instance history")}),(0,e.jsxs)("select",{"aria-label":n("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:s(r=>{z(r.target.value)},"onChange"),value:b,children:[(0,e.jsx)("option",{value:"",children:n("All statuses")}),ie.map(r=>(0,e.jsx)("option",{value:r,children:r},r))]})]}),y!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:y}),L&&(0,e.jsx)(K,{description:n("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:n("Workflow inspection not configured")}),!L&&N!==null&&N.length===0&&(0,e.jsx)(K,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),N!==null&&N.length>0&&(0,e.jsx)(R,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(j,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(w,{children:[(0,e.jsx)(l,{children:n("Instance id")}),(0,e.jsx)(l,{children:n("Status")}),(0,e.jsx)(l,{children:n("Created")}),(0,e.jsx)(l,{children:n("Ended")}),(0,e.jsx)(l,{"aria-label":n("Actions")})]})}),(0,e.jsx)(F,{children:N.map(r=>(0,e.jsxs)(w,{"data-testid":`workflow-instance-${r.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:r.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:r.status}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:r.createdOn??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:r.endedOn??"\u2014"}),(0,e.jsx)(i,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(W,{"data-testid":`workflow-instance-steps-${r.id}`,onClick:s(()=>{A(M(r.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:n("Steps")}),E!==void 0&&de.map(c=>(0,e.jsx)(W,{"data-testid":`workflow-instance-${c}-${r.id}`,disabled:P===r.id,onClick:s(()=>{A(Q(r.id,c))},"onClick"),size:"sm",type:"button",variant:"ghost",children:n(c)},c))]})})]},r.id))})]})})}),C!==null&&(0,e.jsx)(R,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(_,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[n("Steps")," \xB7 ",C.id]}),(0,e.jsx)(W,{"data-testid":"workflow-instance-detail-close",onClick:H,size:"xs",type:"button",variant:"ghost",children:n("Close")})]}),C.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:n("This instance has no recorded steps yet.")}):(0,e.jsxs)(j,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(w,{children:[(0,e.jsx)(l,{children:n("Step")}),(0,e.jsx)(l,{children:n("Type")}),(0,e.jsx)(l,{children:n("Attempts")}),(0,e.jsx)(l,{children:n("Started")}),(0,e.jsx)(l,{children:n("Output")})]})}),(0,e.jsx)(F,{children:C.steps.map((r,c)=>(0,e.jsxs)(w,{"data-testid":`workflow-step-${String(c)}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:r.name}),(0,e.jsx)(i,{className:"text-xs text-muted-foreground",children:r.type??"\u2014"}),(0,e.jsx)(i,{className:"tabular-nums",children:r.attempts??"\u2014"}),(0,e.jsx)(i,{className:"text-muted-foreground tabular-nums",children:r.start??"\u2014"}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:me(r)})]},`${r.name}:${String(c)}`))})]})]})})]})},"me"),he=Y(G.createWorkflowInstance),pe=Y(G.getWorkflowInstanceStatus),xe=s(o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"\u2014";try{return JSON.stringify(o.output,ee)}catch{return"(unserializable)"}},"pe"),we=s((o,a)=>o.some(g=>g.exportName===a)?a:o[0]?.exportName??"","xe"),$e=s(()=>{let o=V(),a=X(),{data:g,error:J}=ne(G.listWorkflows,{}),[k,T]=(0,d.useState)(""),[n,N]=(0,d.useState)(""),[v,C]=(0,d.useState)(""),[I,b]=(0,d.useState)(!1),[z,y]=(0,d.useState)(null),[p,L]=(0,d.useState)([]),[O,P]=(0,d.useState)(null),U=g!==void 0,f=Array.isArray(g?.workflows)?[...g.workflows].toSorted((t,u)=>t.exportName.localeCompare(u.exportName)):[],h=we(f,k),x=f.find(t=>t.exportName===h),q=s(t=>{L(u=>{let m=u.filter(S=>!(S.exportName===t.exportName&&S.id===t.id));return[t,...m]})},"D"),E=s(async()=>{let t=h;if(t==="")return;let u,m=v.trim();if(m!=="")try{u=JSON.parse(m)}catch{y(a("Params must be valid JSON"));return}b(!0),y(null);try{let S=n.trim(),te=await o.query(he,{exportName:t,id:S===""?void 0:S,params:u},Z(""));q({exportName:t,id:te.id,status:te.status}),N("")}catch(S){y($(S))}b(!1)},"Q"),B=s(()=>{A(E())},"V"),M=s(async(t,u)=>{P(u);try{let m=await o.query(pe,{exportName:t,id:u},Z(""));q({error:m.error,exportName:t,id:m.id,output:m.output,status:m.status})}catch(m){y($(m))}P(null)},"O"),H=s(t=>{T(t.target.value)},"P"),Q=s(t=>{N(t.target.value)},"J"),r=s(t=>{C(t.target.value)},"B"),c=s(t=>{let{export:u,id:m}=t.currentTarget.dataset;u!==void 0&&m!==void 0&&A(M(u,m))},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[J!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:J}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:a("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),U&&f.length===0?(0,e.jsx)(K,{description:a("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:a("No workflows defined")}):(0,e.jsx)(R,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(j,{"data-testid":"workflows-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(w,{children:[(0,e.jsx)(l,{children:a("Export")}),(0,e.jsx)(l,{children:a("Name")}),(0,e.jsx)(l,{children:a("Class")}),(0,e.jsx)(l,{children:a("Binding")})]})}),(0,e.jsx)(F,{children:f.map(t=>(0,e.jsxs)(w,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.className}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.binding})]},t.exportName))})]})})}),f.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:a("Start instance")}),z!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:z}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":a("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:H,value:h,children:f.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(ae,{"aria-label":a("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:Q,placeholder:a("Instance id (optional)"),value:n}),(0,e.jsx)(W,{"data-testid":"workflows-start-button",disabled:I||h==="",onClick:B,children:a(I?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(se,{"aria-label":a("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:r,placeholder:a("Params (JSON, optional)"),value:v})]}),p.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:a("Instances")}),(0,e.jsx)(R,{className:"overflow-hidden py-0",children:(0,e.jsx)(_,{className:"px-0",children:(0,e.jsxs)(j,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(D,{children:(0,e.jsxs)(w,{children:[(0,e.jsx)(l,{children:a("Workflow")}),(0,e.jsx)(l,{children:a("Instance id")}),(0,e.jsx)(l,{children:a("Status")}),(0,e.jsx)(l,{children:a("Output")}),(0,e.jsx)(l,{})]})}),(0,e.jsx)(F,{children:p.map(t=>(0,e.jsxs)(w,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(i,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(i,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(i,{className:"font-mono text-xs text-muted-foreground",children:xe(t)}),(0,e.jsx)(i,{children:(0,e.jsx)(W,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:O===t.id,onClick:c,size:"xs",variant:"outline",children:O===t.id?a("Refreshing\u2026"):a("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),x!==void 0&&(0,e.jsx)(fe,{workflowName:x.name})]})},"We");export{$e as default};
@@ -0,0 +1 @@
1
+ import{a as Xe}from"./chunk-2URQKGWU.js";import"./chunk-4JLGLPWV.js";import{a as Ke}from"./chunk-EA2JKR5D.js";import{a as Ve}from"./chunk-66UGPQVC.js";import"./chunk-3Q2P62UR.js";import{a as He}from"./chunk-NFS7FTAR.js";import{W as We}from"./chunk-PLHA3OWK.js";import"./chunk-4L4WTGN5.js";import{a as le}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as de}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Ge}from"./chunk-GOSWKLMM.js";import{a as Pe}from"./chunk-ULIQFBZU.js";import"./chunk-3PWB52UO.js";import"./chunk-35DM4JJG.js";import{a as j}from"./chunk-4ZEL6BYL.js";import{c as Me}from"./chunk-ERHFRNCL.js";import{f as Fe}from"./chunk-R4WRHIAN.js";import"./chunk-FSRSK4LY.js";import"./chunk-LCXKALTS.js";import{a as ie}from"./chunk-FKVZRPV5.js";import{a as _e,b as Be,c as ke,d as G,e as C,f as w}from"./chunk-HEAQVSNS.js";import{a as Te,e as De}from"./chunk-WUWBZPUK.js";import{d as $,f as ue,g as ce,h as me,m as ze,p as he,t as Ue}from"./chunk-PTZD7RUZ.js";import{a as h,d as Ee,e as nt,f as ot,g as dt}from"./chunk-YKXDMIHQ.js";var F=Ee(ot(),1);var A=Ee(nt(),1);var t=Ee(dt(),1);var lt=h((n,e)=>{let a=new Set(n.map(s=>s.deadLetterQueue).filter(s=>typeof s=="string"&&s!=="")),i=n.filter(s=>(s.deadLetterQueue===void 0||s.deadLetterQueue==="")&&!a.has(s.name)),d=e.filter(s=>s.deadLettered).length;return{deadLetteredCount:d,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||d>0}},"nt"),it=200,ut=ue(j.sendQueueMessage),ct=ue(j.replayQueueMessage),mt=ue(j.clearQueueMessages),Ye=96,ht=h(n=>{if(n===void 0)return"\u2014";try{return JSON.stringify(n,ze)}catch{return"[unserializable]"}},"ct"),pt=h(n=>n.length>Ye?`${n.slice(0,Ye)}\u2026`:n,"ut"),gt=h(n=>n==="error"?"destructive":n==="retry"?"outline":"secondary","mt"),ft=h((n,e)=>e(n==="messages"?"Messages":n==="send"?"Send":"Declared"),"ft"),xt=h(n=>{let e=(0,F.c)(11),{loaded:a,queues:i}=n,d=$(),s;e[0]!==d?(s=d("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[0]=d,e[1]=s):s=e[1];let o;e[2]!==s?(o=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:s}),e[2]=s,e[3]=o):o=e[3];let r;e[4]!==a||e[5]!==i||e[6]!==d?(r=a&&i.length===0?(0,t.jsx)(ie,{description:d("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:d("No queues defined")}):(0,t.jsx)(Te,{className:"overflow-hidden py-0",children:(0,t.jsx)(De,{className:"px-0",children:(0,t.jsxs)(_e,{"data-testid":"queues-table",children:[(0,t.jsx)(Be,{children:(0,t.jsxs)(G,{children:[(0,t.jsx)(C,{children:d("Export")}),(0,t.jsx)(C,{children:d("Queue")}),(0,t.jsx)(C,{children:d("Mode")}),(0,t.jsx)(C,{children:d("Binding")}),(0,t.jsx)(C,{children:d("Dead-letter")})]})}),(0,t.jsx)(ke,{children:i.map(qt)})]})})}),e[4]=a,e[5]=i,e[6]=d,e[7]=r):r=e[7];let p;return e[8]!==o||e[9]!==r?(p=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[o,r]}),e[8]=o,e[9]=r,e[10]=p):p=e[10],p},"ht"),yt=h(n=>{let e=(0,F.c)(67),{message:a,onReplay:i,replayingId:d}=n,s=$(),o,r,p,c,x,N,y,l,m,f;if(e[0]!==a.attempts||e[1]!==a.body||e[2]!==a.deadLettered||e[3]!==a.exportName||e[4]!==a.id||e[5]!==a.messageId||e[6]!==a.outcome||e[7]!==a.queue||e[8]!==s){let W=ht(a.body);r=G,N=`queues-message-${a.id}`;let z=a.exportName??a.queue;e[19]!==z?(y=(0,t.jsx)(w,{className:"font-mono text-xs",children:z}),e[19]=z,e[20]=y):y=e[20],e[21]!==a.messageId?(l=(0,t.jsx)(w,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:a.messageId,children:a.messageId}),e[21]=a.messageId,e[22]=l):l=e[22],e[23]!==a.attempts?(m=(0,t.jsx)(w,{className:"font-mono text-xs tabular-nums",children:a.attempts}),e[23]=a.attempts,e[24]=m):m=e[24];let T=`queues-outcome-${a.id}`,D;e[25]!==a.outcome?(D=gt(a.outcome),e[25]=a.outcome,e[26]=D):D=e[26];let I;e[27]!==a.outcome||e[28]!==T||e[29]!==D?(I=(0,t.jsx)(de,{"data-testid":T,variant:D,children:a.outcome}),e[27]=a.outcome,e[28]=T,e[29]=D,e[30]=I):I=e[30];let M;e[31]!==a.deadLettered||e[32]!==a.id||e[33]!==s?(M=a.deadLettered&&(0,t.jsx)(de,{"data-testid":`queues-dlq-${a.id}`,variant:"destructive",children:s("DLQ")}),e[31]=a.deadLettered,e[32]=a.id,e[33]=s,e[34]=M):M=e[34],e[35]!==I||e[36]!==M?(f=(0,t.jsx)(w,{children:(0,t.jsxs)("span",{className:"inline-flex items-center gap-1",children:[I,M]})}),e[35]=I,e[36]=M,e[37]=f):f=e[37],o=w,p="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=W,x=pt(W),e[0]=a.attempts,e[1]=a.body,e[2]=a.deadLettered,e[3]=a.exportName,e[4]=a.id,e[5]=a.messageId,e[6]=a.outcome,e[7]=a.queue,e[8]=s,e[9]=o,e[10]=r,e[11]=p,e[12]=c,e[13]=x,e[14]=N,e[15]=y,e[16]=l,e[17]=m,e[18]=f}else o=e[9],r=e[10],p=e[11],c=e[12],x=e[13],N=e[14],y=e[15],l=e[16],m=e[17],f=e[18];let g;e[38]!==o||e[39]!==p||e[40]!==c||e[41]!==x?(g=(0,t.jsx)(o,{className:p,title:c,children:x}),e[38]=o,e[39]=p,e[40]=c,e[41]=x,e[42]=g):g=e[42];let q;e[43]!==a.capturedAt?(q=Ue(a.capturedAt,"\u2014"),e[43]=a.capturedAt,e[44]=q):q=e[44];let b;e[45]!==q?(b=(0,t.jsx)(w,{className:"text-xs text-muted-foreground tabular-nums",children:q}),e[45]=q,e[46]=b):b=e[46];let S=`queues-replay-${a.id}`,E=d!==null,Q;e[47]!==a.id||e[48]!==d||e[49]!==s?(Q=d===a.id?s("Replaying\u2026"):s("Replay"),e[47]=a.id,e[48]=d,e[49]=s,e[50]=Q):Q=e[50];let L;e[51]!==a.id||e[52]!==i||e[53]!==S||e[54]!==E||e[55]!==Q?(L=(0,t.jsx)(w,{children:(0,t.jsx)(le,{"data-id":a.id,"data-testid":S,disabled:E,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=a.id,e[52]=i,e[53]=S,e[54]=E,e[55]=Q,e[56]=L):L=e[56];let _;return e[57]!==r||e[58]!==b||e[59]!==L||e[60]!==N||e[61]!==y||e[62]!==l||e[63]!==m||e[64]!==f||e[65]!==g?(_=(0,t.jsxs)(r,{"data-testid":N,children:[y,l,m,f,g,b,L]}),e[57]=r,e[58]=b,e[59]=L,e[60]=N,e[61]=y,e[62]=l,e[63]=m,e[64]=f,e[65]=g,e[66]=_):_=e[66],_},"pt"),Nt=h(n=>{let e=(0,F.c)(29),{hasError:a,messages:i,onClear:d,onReplay:s,replayingId:o}=n,r=$(),p;e[0]!==r?(p=r("Cloudflare Queues have no peek API, so this is what push consumers actually processed \u2014 not pending depth."),e[0]=r,e[1]=p):p=e[1];let c;e[2]!==p?(c=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=c):c=e[3];let x;e[4]!==r?(x=r("Clear the whole message log?"),e[4]=r,e[5]=x):x=e[5];let N=i.length===0,y;e[6]!==r?(y=r("Clear log"),e[6]=r,e[7]=y):y=e[7];let l;e[8]!==d||e[9]!==x||e[10]!==N||e[11]!==y?(l=(0,t.jsx)("div",{className:"ml-auto",children:(0,t.jsx)(He,{confirmLabel:x,disabled:N,onConfirm:d,testId:"queues-clear",children:y})}),e[8]=d,e[9]=x,e[10]=N,e[11]=y,e[12]=l):l=e[12];let m;e[13]!==i.length||e[14]!==r?(m=i.length>0&&(0,t.jsx)(de,{"data-testid":"queues-count",variant:"secondary",children:r("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=r,e[15]=m):m=e[15];let f;e[16]!==c||e[17]!==l||e[18]!==m?(f=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[c,l,m]}),e[16]=c,e[17]=l,e[18]=m,e[19]=f):f=e[19];let g;e[20]!==a||e[21]!==i||e[22]!==s||e[23]!==o||e[24]!==r?(g=!a&&i.length===0?(0,t.jsx)(ie,{description:r("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:r("No consumed messages yet.")}):(0,t.jsx)(Te,{className:"overflow-hidden py-0",children:(0,t.jsx)(De,{className:"px-0",children:(0,t.jsx)(Xe,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:(0,t.jsxs)(_e,{"data-testid":"queues-messages-table",children:[(0,t.jsx)(Be,{children:(0,t.jsxs)(G,{children:[(0,t.jsx)(C,{children:r("Export")}),(0,t.jsx)(C,{children:r("Message")}),(0,t.jsx)(C,{children:r("Attempts")}),(0,t.jsx)(C,{children:r("Outcome")}),(0,t.jsx)(C,{children:r("Body")}),(0,t.jsx)(C,{children:r("Captured")}),(0,t.jsx)(C,{})]})}),(0,t.jsx)(ke,{children:i.map(b=>(0,t.jsx)(yt,{message:b,onReplay:s,replayingId:o},b.id))})]})})})}),e[20]=a,e[21]=i,e[22]=s,e[23]=o,e[24]=r,e[25]=g):g=e[25];let q;return e[26]!==f||e[27]!==g?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[f,g]}),e[26]=f,e[27]=g,e[28]=q):q=e[28],q},"gt"),bt=h(n=>{let e=(0,F.c)(20),{batchMode:a,bodyText:i,delayText:d,onBatchModeChange:s,onBodyChange:o,onDelayChange:r,onSelectExport:p,onSend:c,queues:x,selectedExportName:N,sending:y}=n,l=$(),m;e[0]!==l?(m=l("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=l,e[1]=m):m=e[1];let f;e[2]!==m?(f=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:m}),e[2]=m,e[3]=f):f=e[3];let g;e[4]!==a||e[5]!==i||e[6]!==d||e[7]!==s||e[8]!==o||e[9]!==r||e[10]!==p||e[11]!==c||e[12]!==x||e[13]!==N||e[14]!==y||e[15]!==l?(g=x.length===0?(0,t.jsx)(ie,{description:l("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:l("No queues to send to")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("select",{"aria-label":l("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:p,value:N,children:x.map(vt)}),(0,t.jsx)(We,{"aria-label":l("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:r,placeholder:l("Delay (s)"),type:"number",value:d}),(0,t.jsxs)("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[(0,t.jsx)("input",{checked:a,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:s,type:"checkbox"}),l("Send as batch (JSON array)")]}),(0,t.jsx)(le,{className:"ml-auto","data-testid":"queues-send-button",disabled:y||N==="",onClick:c,type:"button",children:l(y?"Sending\u2026":"Send message")})]}),(0,t.jsx)(Ke,{"aria-label":l("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:a?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=a,e[5]=i,e[6]=d,e[7]=s,e[8]=o,e[9]=r,e[10]=p,e[11]=c,e[12]=x,e[13]=N,e[14]=y,e[15]=l,e[16]=g):g=e[16];let q;return e[17]!==f||e[18]!==g?(q=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[f,g]}),e[17]=f,e[18]=g,e[19]=q):q=e[19],q},"xt"),Ft=h(n=>{let e=(0,F.c)(59),{limit:a}=n,i=a??it,d=Fe(),s=$(),[o,r]=(0,A.useState)("declared"),[p,c]=(0,A.useState)(null),x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];let{data:N,error:y,errorSource:l}=Me(j.listQueues,x),m;e[1]!==i?(m={limit:i},e[1]=i,e[2]=m):m=e[2];let{data:f,error:g,errorSource:q,refetch:b}=Me(j.getQueueMessages,m),S=Array.isArray(N?.queues)?[...N.queues].toSorted(St):[],E=f?.entries??[],{deadLetteredCount:Q,queuesWithoutDlq:L,showReliabilityWarning:_}=lt(S,E),[W,z]=(0,A.useState)(""),[T,D]=(0,A.useState)(""),[I,M]=(0,A.useState)(""),[U,Ze]=(0,A.useState)(!1),[pe,Oe]=(0,A.useState)(!1),[ge,Re]=(0,A.useState)(null),H=S.some(u=>u.exportName===W)?W:S[0]?.exportName??"",Je=o==="messages"?g:y,et=o==="messages"?q:l,fe=Je??p,xe=Je===null?p:et,K;e[3]!==b?(K=h(()=>{b()},"H"),e[3]=b,e[4]=K):K=e[4],Ve(K,o==="messages");let ye=h(async()=>{c(null);let u=H;if(u==="")return;let v=null,$e=T.trim();if($e!=="")try{v=JSON.parse($e)}catch{c(s("Body must be valid JSON."));return}let Ae,je=I.trim();if(je!==""){let P=Number(je);if(!Number.isFinite(P)||P<0){c(s("Delay must be a non-negative number of seconds."));return}Ae=P}if(U&&!Array.isArray(v)){c(s("Batch mode needs a JSON array body \u2014 each element is enqueued as one message."));return}Oe(!0);let rt=U?{batch:v,delaySeconds:Ae,exportName:u}:{body:v,delaySeconds:Ae,exportName:u};try{await d.query(ut,rt,ce("")),b()}catch(P){c(me(P))}Oe(!1)},"ue"),V;e[5]!==d||e[6]!==b?(V=h(async u=>{c(null),Re(u);try{await d.query(ct,{id:u},ce("")),b()}catch(v){c(me(v))}Re(null)},"V"),e[5]=d,e[6]=b,e[7]=V):V=e[7];let Ne=V,X;e[8]!==d||e[9]!==b?(X=h(async()=>{c(null);try{await d.query(mt,{},ce("")),b()}catch(u){c(me(u))}},"Y"),e[8]=d,e[9]=b,e[10]=X):X=e[10];let be=X,Y;e[11]===Symbol.for("react.memo_cache_sentinel")?(Y=h(u=>{let v=u.currentTarget.dataset.tab;(v==="declared"||v==="messages"||v==="send")&&r(v)},"X"),e[11]=Y):Y=e[11];let tt=Y,Z;e[12]===Symbol.for("react.memo_cache_sentinel")?(Z=h(u=>{z(u.currentTarget.value)},"K"),e[12]=Z):Z=e[12];let qe=Z,ee;e[13]===Symbol.for("react.memo_cache_sentinel")?(ee=h(u=>{D(u.currentTarget.value)},"Z"),e[13]=ee):ee=e[13];let ve=ee,te;e[14]===Symbol.for("react.memo_cache_sentinel")?(te=h(u=>{M(u.currentTarget.value)},"ee"),e[14]=te):te=e[14];let Se=te,ae;e[15]===Symbol.for("react.memo_cache_sentinel")?(ae=h(u=>{Ze(u.currentTarget.checked)},"te"),e[15]=ae):ae=e[15];let Ce=ae,se;e[16]!==ye?(se=h(()=>{he(ye())},"se"),e[16]=ye,e[17]=se):se=e[17];let we=se,re;e[18]!==Ne?(re=h(u=>{let{id:v}=u.currentTarget.dataset;v!==void 0&&he(Ne(v))},"ae"),e[18]=Ne,e[19]=re):re=e[19];let Ie=re,ne;e[20]!==be?(ne=h(()=>{he(be())},"re"),e[20]=be,e[21]=ne):ne=e[21];let Qe=ne,at="flex flex-col gap-6",st="lunora-queues-panel",B;e[22]!==s||e[23]!==o?(B=(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(u=>(0,t.jsx)(le,{"aria-selected":o===u,"data-tab":u,"data-testid":`queues-tab-${u}`,onClick:tt,role:"tab",size:"sm",type:"button",variant:o===u?"secondary":"ghost",children:ft(u,s)},u))}),e[22]=s,e[23]=o,e[24]=B):B=e[24];let k;e[25]!==fe||e[26]!==xe?(k=fe!==null&&(0,t.jsx)(Ge,{error:xe,testId:"queues-error"}),e[25]=fe,e[26]=xe,e[27]=k):k=e[27];let Le=_&&(0,t.jsx)(Pe,{icon:(0,t.jsx)("span",{"aria-hidden":"true",className:"text-base leading-none",children:"\u26A0"}),testId:"queues-dlq-warning",variant:"warning",children:(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[L.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"font-medium",children:s("No dead-letter queue on {queues}.",{queues:L.map(Ct).join(", ")})}),(0,t.jsx)("p",{className:"text-muted-foreground",children:s("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),Q>0&&(0,t.jsx)("p",{className:L.length>0?"text-muted-foreground":"font-medium",children:Q===1?s("1 message was recently dead-lettered."):s("{count} messages were recently dead-lettered.",{count:Q})})]})}),O;e[28]!==S||e[29]!==N||e[30]!==o?(O=o==="declared"&&(0,t.jsx)(xt,{loaded:N!==void 0,queues:S}),e[28]=S,e[29]=N,e[30]=o,e[31]=O):O=e[31];let R;e[32]!==E||e[33]!==g||e[34]!==Qe||e[35]!==Ie||e[36]!==ge||e[37]!==o?(R=o==="messages"&&(0,t.jsx)(Nt,{hasError:g!==null,messages:E,onClear:Qe,onReplay:Ie,replayingId:ge}),e[32]=E,e[33]=g,e[34]=Qe,e[35]=Ie,e[36]=ge,e[37]=o,e[38]=R):R=e[38];let J;e[39]!==U||e[40]!==T||e[41]!==I||e[42]!==Ce||e[43]!==ve||e[44]!==Se||e[45]!==qe||e[46]!==we||e[47]!==S||e[48]!==H||e[49]!==pe||e[50]!==o?(J=o==="send"&&(0,t.jsx)(bt,{batchMode:U,bodyText:T,delayText:I,onBatchModeChange:Ce,onBodyChange:ve,onDelayChange:Se,onSelectExport:qe,onSend:we,queues:S,selectedExportName:H,sending:pe}),e[39]=U,e[40]=T,e[41]=I,e[42]=Ce,e[43]=ve,e[44]=Se,e[45]=qe,e[46]=we,e[47]=S,e[48]=H,e[49]=pe,e[50]=o,e[51]=J):J=e[51];let oe;return e[52]!==B||e[53]!==k||e[54]!==Le||e[55]!==O||e[56]!==R||e[57]!==J?(oe=(0,t.jsxs)("div",{className:at,"data-testid":st,children:[B,k,Le,O,R,J]}),e[52]=B,e[53]=k,e[54]=Le,e[55]=O,e[56]=R,e[57]=J,e[58]=oe):oe=e[58],oe},"jt");function qt(n){return(0,t.jsxs)(G,{"data-testid":`queues-row-${n.exportName}`,children:[(0,t.jsx)(w,{className:"font-mono text-xs",children:n.exportName}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.name}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.mode}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.binding}),(0,t.jsx)(w,{className:"font-mono text-xs text-muted-foreground",children:n.deadLetterQueue??"\u2014"})]},n.exportName)}h(qt,"yt");function vt(n){return(0,t.jsx)("option",{value:n.exportName,children:n.exportName},n.exportName)}h(vt,"bt");function St(n,e){return n.exportName.localeCompare(e.exportName)}h(St,"Nt");function Ct(n){return n.name}h(Ct,"qt");export{Ft as default};