@lunora/studio 1.0.0-alpha.9 → 1.0.0-alpha.90

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 (312) hide show
  1. package/LICENSE.md +6 -0
  2. package/dist/index.d.ts +822 -781
  3. package/dist/index.js +1 -41
  4. package/dist/mount.d.ts +10 -10
  5. package/dist/mount.js +1 -26
  6. package/dist/packem_chunks/AdvisorHealthPanel.js +1 -0
  7. package/dist/packem_chunks/ApiTab.js +1 -0
  8. package/dist/packem_chunks/AuditPanel.js +1 -0
  9. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -0
  10. package/dist/packem_chunks/ExportImportPanel.js +3 -0
  11. package/dist/packem_chunks/FileBrowser.js +4 -0
  12. package/dist/packem_chunks/FunctionRunner.js +1 -0
  13. package/dist/packem_chunks/FunctionStatsPanel.js +1 -0
  14. package/dist/packem_chunks/HealthPanel.js +1 -0
  15. package/dist/packem_chunks/InsightsPanel.js +1 -0
  16. package/dist/packem_chunks/LogsPanel.js +1 -0
  17. package/dist/packem_chunks/MailPanel.js +2 -0
  18. package/dist/packem_chunks/MetricsPanel.js +1 -0
  19. package/dist/packem_chunks/NotificationsPanel.js +1 -0
  20. package/dist/packem_chunks/PitrPanel.js +1 -0
  21. package/dist/packem_chunks/SchemaViewer.js +1 -0
  22. package/dist/packem_chunks/SecurityAdvisorPanel.js +1 -0
  23. package/dist/packem_chunks/SettingsPanel.js +1 -0
  24. package/dist/packem_chunks/SqlEditorPanel.js +6 -0
  25. package/dist/packem_chunks/TableEditor.js +1 -0
  26. package/dist/packem_chunks/agents-panel.js +1 -0
  27. package/dist/packem_chunks/analytics-panel.js +1 -0
  28. package/dist/packem_chunks/auth-audit-panel.js +1 -0
  29. package/dist/packem_chunks/auth-config-panel.js +1 -0
  30. package/dist/packem_chunks/auth-sessions-panel.js +1 -0
  31. package/dist/packem_chunks/containers-panel.js +1 -0
  32. package/dist/packem_chunks/dashboards-panel.js +1 -0
  33. package/dist/packem_chunks/fanout-panel.js +1 -0
  34. package/dist/packem_chunks/flags-panel.js +1 -0
  35. package/dist/packem_chunks/issues-panel.js +1 -0
  36. package/dist/packem_chunks/kv-browser.js +1 -0
  37. package/dist/packem_chunks/log-drains-panel.js +4 -0
  38. package/dist/packem_chunks/migrations-route.js +1 -0
  39. package/dist/packem_chunks/organizations-panel.js +1 -0
  40. package/dist/packem_chunks/payments-panel.js +1 -0
  41. package/dist/packem_chunks/permissions-panel.js +1 -0
  42. package/dist/packem_chunks/queues-panel.js +1 -0
  43. package/dist/packem_chunks/rls-panel.js +1 -0
  44. package/dist/packem_chunks/schedule-panel.js +1 -0
  45. package/dist/packem_chunks/sparkline.js +1 -0
  46. package/dist/packem_chunks/storage-rules-panel.js +1 -0
  47. package/dist/packem_chunks/subscriptions-panel.js +1 -0
  48. package/dist/packem_chunks/sync-client-panel.js +1 -0
  49. package/dist/packem_chunks/traces-panel.js +1 -0
  50. package/dist/packem_chunks/users-panel.js +1 -0
  51. package/dist/packem_chunks/vector-browser.js +1 -0
  52. package/dist/packem_chunks/workflows-panel.js +1 -0
  53. package/dist/packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js +1 -0
  54. package/dist/packem_shared/ApiDocsPanel-DLMeLZ5-.js +2 -0
  55. package/dist/packem_shared/ApiReferencePanel-9q8BbJl-.js +1 -0
  56. package/dist/packem_shared/CommandPalette--SQwfTW1.js +1 -0
  57. package/dist/packem_shared/ConfirmButton-CTL3f3kr.js +1 -0
  58. package/dist/packem_shared/ConnectionBadge-DOk0CQWo.js +1 -0
  59. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js +1 -0
  60. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js +1 -0
  61. package/dist/packem_shared/DEFAULT_LOCALE-BZ4NojpD.js +1 -0
  62. package/dist/packem_shared/DataBrowser-CZZ_WkJ-.js +1 -0
  63. package/dist/packem_shared/DataFilters-B26ZeqBZ.js +1 -0
  64. package/dist/packem_shared/ErrorBoundary-DvzYskH7.js +1 -0
  65. package/dist/packem_shared/GlobalDataBrowser-DpkjHfDg.js +1 -0
  66. package/dist/packem_shared/HomePanel-3baDsDBU.js +1 -0
  67. package/dist/packem_shared/MigrationsPanel-dygzHUvg.js +1 -0
  68. package/dist/packem_shared/OpenRpcReferencePanel-qOZcWXMs.js +1 -0
  69. package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.js +1 -0
  70. package/dist/packem_shared/ScheduledJobs-D8kBZWBu.js +1 -0
  71. package/dist/packem_shared/ShardInput-BVn2iCU0.js +1 -0
  72. package/dist/packem_shared/Studio-forQt-PC.js +1 -0
  73. package/dist/packem_shared/StudioApp-B1AWsBzi.js +1 -0
  74. package/dist/packem_shared/StudioI18nProvider-CZ5h4nrV.js +1 -0
  75. package/dist/packem_shared/advisor-view-Pa8HLtBv.js +1 -0
  76. package/dist/packem_shared/aggregateMetrics-BNfajLa2.js +1 -0
  77. package/dist/packem_shared/alert-CVcOFuDR.js +1 -0
  78. package/dist/packem_shared/app.d-DW7yZsfu.d.ts +252 -0
  79. package/dist/packem_shared/badge-BbuuAio7.js +1 -0
  80. package/dist/packem_shared/bar-chart-DraN_srt.js +9 -0
  81. package/dist/packem_shared/browser-storage-xjTyMKY0.js +1 -0
  82. package/dist/packem_shared/button-BkCrNcAs.js +1 -0
  83. package/dist/packem_shared/card-CIDGUN6K.js +1 -0
  84. package/dist/packem_shared/cf-links-Dmg86v1D.js +1 -0
  85. package/dist/packem_shared/checkbox-StT4Gob6.js +1 -0
  86. package/dist/packem_shared/data-grid-DcxyIXwG.js +1 -0
  87. package/dist/packem_shared/data-view-params-ClrV7XgF.js +1 -0
  88. package/dist/packem_shared/dropdown-menu-C3RQ_HlW.js +2 -0
  89. package/dist/packem_shared/empty-state-Cg7t_8qu.js +1 -0
  90. package/dist/packem_shared/error-alert-t6cpEi0z.js +1 -0
  91. package/dist/packem_shared/grid-features-jnrD0SpX.js +6 -0
  92. package/dist/packem_shared/home-panel-CeeqqV0z.js +3 -0
  93. package/dist/packem_shared/input-JHu63lTv.js +1 -0
  94. package/dist/packem_shared/internal-BSIsQVC6.js +2 -0
  95. package/dist/packem_shared/label-6uP1obNF.js +1 -0
  96. package/dist/packem_shared/live-status-CmuRLFKf.js +1 -0
  97. package/dist/packem_shared/log-fields-CoL3hsIQ.js +1 -0
  98. package/dist/packem_shared/modal-shell-CUwwWC2o.js +1 -0
  99. package/dist/packem_shared/operation-console-provider-BMJNtiyB.js +1 -0
  100. package/dist/packem_shared/recording-client-DRAZEmzE.js +1 -0
  101. package/dist/packem_shared/reference-view-DnYYWr7I.js +12 -0
  102. package/dist/packem_shared/result-chart-DzJOVsaw.js +1 -0
  103. package/dist/packem_shared/schema-diagram-cg-bz_VL.js +2 -0
  104. package/dist/packem_shared/scroll-area-DTEq6Jec.js +2 -0
  105. package/dist/packem_shared/select-Bul-DeII.js +2 -0
  106. package/dist/packem_shared/shard-history-DMEW5VBE.js +1 -0
  107. package/dist/packem_shared/skeleton-C1wQ9M5t.js +1 -0
  108. package/dist/packem_shared/sparkline-CgjeUU2I.js +1 -0
  109. package/dist/packem_shared/stat-card-fm_TF1mo.js +1 -0
  110. package/dist/packem_shared/storage-tier-DznqOf-q.js +1 -0
  111. package/dist/packem_shared/studio-BtC7WPbz.js +2 -0
  112. package/dist/packem_shared/table-DdJBrClo.js +2 -0
  113. package/dist/packem_shared/table-list-sidebar-D9Bd4qgi.js +1 -0
  114. package/dist/packem_shared/textarea-Bu2-jKAs.js +1 -0
  115. package/dist/packem_shared/trace-handoff-Dw7mwjxu.js +1 -0
  116. package/dist/packem_shared/use-admin-query-QJ-ibl5u.js +1 -0
  117. package/dist/packem_shared/use-async-submit-q3ymBJkD.js +1 -0
  118. package/dist/packem_shared/use-auth-config-BObBpdsi.js +1 -0
  119. package/dist/packem_shared/use-shard-key-B2JtNa5m.js +1 -0
  120. package/dist/packem_shared/use-sql-assistant-C6dl2_Ty.js +1 -0
  121. package/dist/packem_shared/useDebounced-CU-uftxO.js +1 -0
  122. package/dist/packem_shared/utils-bhneXptQ.js +1 -0
  123. package/dist/packem_shared/virtual-rect-1o1veP7R.js +1 -0
  124. package/dist/standalone/chunk-24JLZ2Z5.js +1 -0
  125. package/dist/standalone/chunk-2OUPA2WJ.js +1 -0
  126. package/dist/standalone/chunk-2PJNAWB3.js +1 -0
  127. package/dist/standalone/chunk-2QSHLBCO.js +1 -0
  128. package/dist/standalone/chunk-3AV5CV6K.js +1 -0
  129. package/dist/standalone/chunk-3C3CG7ZK.js +1 -0
  130. package/dist/standalone/chunk-3CWGJYBB.js +1 -0
  131. package/dist/standalone/chunk-3XIESWL4.js +1 -0
  132. package/dist/standalone/chunk-4COKHD2C.js +1 -0
  133. package/dist/standalone/chunk-4LCY5XUR.js +1 -0
  134. package/dist/standalone/chunk-4UOFSGUS.js +1 -0
  135. package/dist/standalone/chunk-53KJRSHE.js +1 -0
  136. package/dist/standalone/chunk-54MMVNPT.js +1 -0
  137. package/dist/standalone/chunk-5Y3QLNWX.js +1 -0
  138. package/dist/standalone/chunk-5ZXDB6LB.js +13 -0
  139. package/dist/standalone/chunk-62EKHKTS.js +1 -0
  140. package/dist/standalone/chunk-67DKQC23.js +1 -0
  141. package/dist/standalone/chunk-6MKDYZ7A.js +1 -0
  142. package/dist/standalone/chunk-6ST5ECQA.js +1 -0
  143. package/dist/standalone/chunk-6VTLIGVX.js +1 -0
  144. package/dist/standalone/chunk-7H7LZRLP.js +1 -0
  145. package/dist/standalone/chunk-7QIFDWQV.js +1 -0
  146. package/dist/standalone/chunk-7T7UOTYK.js +1 -0
  147. package/dist/standalone/chunk-AQX2QFCN.js +1 -0
  148. package/dist/standalone/chunk-ARP36PTE.js +1 -0
  149. package/dist/standalone/chunk-AUQKJYHL.js +1 -0
  150. package/dist/standalone/chunk-AVAC26HJ.js +1 -0
  151. package/dist/standalone/chunk-AZAGCJVI.js +1 -0
  152. package/dist/standalone/chunk-BGBLQ563.js +1 -0
  153. package/dist/standalone/chunk-BL6NO3U3.js +1 -0
  154. package/dist/standalone/chunk-BRQMMGOS.js +1 -0
  155. package/dist/standalone/chunk-BUTBQGUU.js +1 -0
  156. package/dist/standalone/chunk-C3HXK3A5.js +3 -0
  157. package/dist/standalone/chunk-CFPZYHPY.js +2 -0
  158. package/dist/standalone/chunk-CT6ZDXLL.js +1 -0
  159. package/dist/standalone/chunk-CTNB2KIA.js +1 -0
  160. package/dist/standalone/chunk-D3HXVA33.js +1 -0
  161. package/dist/standalone/chunk-DG7YINFM.js +1 -0
  162. package/dist/standalone/chunk-DMCYISRF.js +1 -0
  163. package/dist/standalone/chunk-E7TB4USI.js +1 -0
  164. package/dist/standalone/chunk-EQZTSISX.js +1 -0
  165. package/dist/standalone/chunk-ESVP44Y3.js +1 -0
  166. package/dist/standalone/chunk-FURI47Z2.js +1 -0
  167. package/dist/standalone/chunk-FW75RYZU.js +1 -0
  168. package/dist/standalone/chunk-FXCBF4XT.js +1 -0
  169. package/dist/standalone/chunk-GKSRVABT.js +1 -0
  170. package/dist/standalone/chunk-GMR677FL.js +1 -0
  171. package/dist/standalone/chunk-GRL5MG3Z.js +1 -0
  172. package/dist/standalone/chunk-GSKOAKQ2.js +1 -0
  173. package/dist/standalone/chunk-HPFLBYRI.js +1 -0
  174. package/dist/standalone/chunk-I6A5C46N.js +1 -0
  175. package/dist/standalone/chunk-IAKPXGTQ.js +8 -0
  176. package/dist/standalone/chunk-IC4L6G56.js +1 -0
  177. package/dist/standalone/chunk-IC64YIX5.js +1 -0
  178. package/dist/standalone/chunk-ILNELDFC.js +1 -0
  179. package/dist/standalone/chunk-IVFHIQOT.js +1 -0
  180. package/dist/standalone/chunk-JFW3YNVQ.js +1 -0
  181. package/dist/standalone/chunk-JN2Y24PY.js +1 -0
  182. package/dist/standalone/chunk-KUVMORDQ.js +1 -0
  183. package/dist/standalone/chunk-LAHYLAT4.js +1 -0
  184. package/dist/standalone/chunk-LEDWUPXM.js +1 -0
  185. package/dist/standalone/chunk-LJIFMW67.js +1 -0
  186. package/dist/standalone/chunk-LJISXTZJ.js +1 -0
  187. package/dist/standalone/chunk-LQAKPCFX.js +1 -0
  188. package/dist/standalone/chunk-MHAXZQVO.js +1 -0
  189. package/dist/standalone/chunk-MIQTKZAR.js +1 -0
  190. package/dist/standalone/chunk-MV4A2PAK.js +1 -0
  191. package/dist/standalone/chunk-OG2AMGOC.js +1 -0
  192. package/dist/standalone/chunk-OG4N2XHD.js +19 -0
  193. package/dist/standalone/chunk-PB7FNRDB.js +1 -0
  194. package/dist/standalone/chunk-PGC523I2.js +1 -0
  195. package/dist/standalone/chunk-PM37X2V3.js +1 -0
  196. package/dist/standalone/chunk-QBWRC5YX.js +1 -0
  197. package/dist/standalone/chunk-QLQADHFE.js +1 -0
  198. package/dist/standalone/chunk-QP7IQOKF.js +1 -0
  199. package/dist/standalone/chunk-QV6KV4SD.js +1 -0
  200. package/dist/standalone/chunk-QWBRD6PX.js +1 -0
  201. package/dist/standalone/chunk-QWGT25SE.js +1 -0
  202. package/dist/standalone/chunk-QXXIJAD5.js +1 -0
  203. package/dist/standalone/chunk-QYIOW7CD.js +4 -0
  204. package/dist/standalone/chunk-S3DWUXGY.js +62 -0
  205. package/dist/standalone/chunk-S4ILMYP5.js +4 -0
  206. package/dist/standalone/chunk-SD4BERSA.js +1 -0
  207. package/dist/standalone/chunk-SF4MF2FT.js +1 -0
  208. package/dist/standalone/chunk-SFDOII3B.js +1 -0
  209. package/dist/standalone/chunk-SHMNA6UL.js +1 -0
  210. package/dist/standalone/chunk-SMIESS7P.js +1 -0
  211. package/dist/standalone/chunk-SP5SBO2W.js +3 -0
  212. package/dist/standalone/chunk-T6OAYQTX.js +1 -0
  213. package/dist/standalone/chunk-T6VMSOBB.js +1 -0
  214. package/dist/standalone/chunk-TBBJPPZ3.js +2 -0
  215. package/dist/standalone/chunk-THIXMMZD.js +1 -0
  216. package/dist/standalone/chunk-U6TNNM5U.js +1 -0
  217. package/dist/standalone/chunk-ULCZDGWQ.js +1 -0
  218. package/dist/standalone/chunk-UU2QJMGJ.js +1 -0
  219. package/dist/standalone/chunk-UZERI5YC.js +1 -0
  220. package/dist/standalone/chunk-V2U5CL3S.js +11 -0
  221. package/dist/standalone/chunk-V53KNYRN.js +1 -0
  222. package/dist/standalone/chunk-VDW32UET.js +1 -0
  223. package/dist/standalone/chunk-VFQDHG7I.js +4 -0
  224. package/dist/standalone/chunk-WB5IUUUU.js +1 -0
  225. package/dist/standalone/chunk-WLZ7YPBH.js +6 -0
  226. package/dist/standalone/chunk-X665E2HU.js +1 -0
  227. package/dist/standalone/chunk-XBDKZZ67.js +1 -0
  228. package/dist/standalone/chunk-XF2B7P5A.js +1 -0
  229. package/dist/standalone/chunk-XNGYYOLS.js +14 -0
  230. package/dist/standalone/chunk-XQCVZAGU.js +1 -0
  231. package/dist/standalone/chunk-XR7RBXKA.js +1 -0
  232. package/dist/standalone/chunk-XXQUMVWH.js +1 -0
  233. package/dist/standalone/chunk-XZSGE5ST.js +1 -0
  234. package/dist/standalone/chunk-Y7JXGNXD.js +1 -0
  235. package/dist/standalone/chunk-YOUKADZH.js +1 -0
  236. package/dist/standalone/chunk-YU5CI2FD.js +6 -0
  237. package/dist/standalone/chunk-Z7G74IH4.js +1 -0
  238. package/dist/standalone/chunk-ZJGP6EKR.js +1 -0
  239. package/dist/standalone/chunk-ZPLWCC4I.js +1 -0
  240. package/dist/standalone/studio.js +9 -356
  241. package/dist/styles.css +2 -2
  242. package/package.json +16 -14
  243. package/dist/packem_shared/ADMIN_FUNCTIONS-DjXgvJb6.js +0 -46
  244. package/dist/packem_shared/ApiDocsPanel-yVSGHK3H.js +0 -842
  245. package/dist/packem_shared/ApiReferencePanel-1vubqG5s.js +0 -229
  246. package/dist/packem_shared/ApiTab-rwttyQ1-.js +0 -251
  247. package/dist/packem_shared/AuditPanel-BqXZAsu_.js +0 -212
  248. package/dist/packem_shared/CommandPalette-BtgkBzZI.js +0 -373
  249. package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
  250. package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
  251. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
  252. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
  253. package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
  254. package/dist/packem_shared/DataBrowser-BtT2NYcR.js +0 -4542
  255. package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
  256. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
  257. package/dist/packem_shared/ExportImportPanel-Dq6rj0tI.js +0 -193
  258. package/dist/packem_shared/FileBrowser-0pCpdKPE.js +0 -2932
  259. package/dist/packem_shared/FunctionRunner-7NH3KcTg.js +0 -343
  260. package/dist/packem_shared/FunctionStatsPanel-Cn_EBpDy.js +0 -432
  261. package/dist/packem_shared/GlobalDataBrowser-BTEmGrph.js +0 -318
  262. package/dist/packem_shared/HealthPanel-CQ4LzVET.js +0 -640
  263. package/dist/packem_shared/HomePanel-CP0lN1eF.js +0 -1273
  264. package/dist/packem_shared/InsightsPanel-B1BaHaPL.js +0 -431
  265. package/dist/packem_shared/LogsPanel-C3W0mabf.js +0 -839
  266. package/dist/packem_shared/MailPanel-DozizrvV.js +0 -447
  267. package/dist/packem_shared/MetricsPanel-CujtUfpl.js +0 -1625
  268. package/dist/packem_shared/MigrationsPanel-RX5qIFSr.js +0 -246
  269. package/dist/packem_shared/OpenRpcReferencePanel-vbcYbv3V.js +0 -191
  270. package/dist/packem_shared/PitrPanel-LJGNP_IX.js +0 -252
  271. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
  272. package/dist/packem_shared/ScheduledJobs-CabfKbyM.js +0 -159
  273. package/dist/packem_shared/SchemaViewer-Bam6ylvw.js +0 -2512
  274. package/dist/packem_shared/SecurityAdvisorPanel-Bn2yq05G.js +0 -79
  275. package/dist/packem_shared/SettingsPanel-CBXQpYQA.js +0 -176
  276. package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
  277. package/dist/packem_shared/SqlEditorPanel-D5wMIxcg.js +0 -13
  278. package/dist/packem_shared/Studio-CccqZ-J1.js +0 -33
  279. package/dist/packem_shared/StudioApp-CQbULfaH.js +0 -657
  280. package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
  281. package/dist/packem_shared/TableEditor-Df_5NPaF.js +0 -371
  282. package/dist/packem_shared/advisor-view-CGcfMiPq.js +0 -159
  283. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
  284. package/dist/packem_shared/app.d-Nbhpihxv.d.ts +0 -300
  285. package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
  286. package/dist/packem_shared/bar-chart-CzJAgqkp.js +0 -3245
  287. package/dist/packem_shared/button-BhsN2uZH.js +0 -49
  288. package/dist/packem_shared/card-DURq3ElK.js +0 -175
  289. package/dist/packem_shared/cf-links-2cktDedA.js +0 -8
  290. package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
  291. package/dist/packem_shared/data-grid-B5CaV3wS.js +0 -183
  292. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
  293. package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
  294. package/dist/packem_shared/grid-features-CzUfqgsM.js +0 -840
  295. package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
  296. package/dist/packem_shared/internal-rXJEAhXS.js +0 -68
  297. package/dist/packem_shared/label-D8ykjn5J.js +0 -46
  298. package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
  299. package/dist/packem_shared/reference-view-B4E49Lip.js +0 -2180
  300. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  301. package/dist/packem_shared/sparkline-10dG-_f0.js +0 -93
  302. package/dist/packem_shared/sql-editor-panel-Smfl_FDF.js +0 -2562
  303. package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
  304. package/dist/packem_shared/studio-D93XGB-i.js +0 -10413
  305. package/dist/packem_shared/table-_RzNvy3R.js +0 -246
  306. package/dist/packem_shared/table-list-sidebar-Bg7uzbvC.js +0 -832
  307. package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
  308. package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
  309. package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
  310. package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
  311. package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
  312. package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
@@ -0,0 +1 @@
1
+ import{useLunora as pt}from"@lunora/react";import{useNavigate as xt}from"@tanstack/react-router";import{useState as fe,useRef as We,useEffect as tt,useMemo as bt}from"react";import{L as vt}from"../packem_shared/live-status-CmuRLFKf.js";import{ShardInput as yt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{u as rt}from"../packem_shared/button-BkCrNcAs.js";import{N as Je}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{S as Nt}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as pe}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{c as St}from"../packem_shared/cf-links-Dmg86v1D.js";import{l as $t,k as Ye,f as at,d as wt,b as qt,g as kt}from"../packem_shared/internal-BSIsQVC6.js";import{r as Mt,l as _t}from"../packem_shared/shard-history-DMEW5VBE.js";import{w as It}from"../packem_shared/trace-handoff-Dw7mwjxu.js";import{c as Le}from"react/compiler-runtime";import{f as Ct}from"../packem_shared/log-fields-CoL3hsIQ.js";import{g as et}from"../packem_shared/badge-BbuuAio7.js";import{c as he,u as ge,n as Pe,f as Qe,m as Rt}from"../packem_shared/card-CIDGUN6K.js";import{p as de,d as dt,m as He,u as oe,n as mt,f as ut}from"../packem_shared/table-DdJBrClo.js";import{S as ht}from"../packem_shared/sparkline-CgjeUU2I.js";import{jsx as r,jsxs as o,Fragment as Ve}from"react/jsx-runtime";import{aggregateMetrics as Dt,computeLatencyPercentiles as Ft,enrichQueryStats as Tt,shardsToAggregate as Lt}from"../packem_shared/aggregateMetrics-BNfajLa2.js";import{g as me}from"../packem_shared/stat-card-fm_TF1mo.js";import{ResponsiveContainer as lt,AreaChart as Ot,CartesianGrid as st,XAxis as nt,YAxis as it,Tooltip as ot,Area as zt,LineChart as At,Line as Kt}from"recharts";import{E as Et}from"../packem_shared/empty-state-Cg7t_8qu.js";import{c as jt}from"../packem_shared/utils-bhneXptQ.js";import{N as Pt,y as Qt,k as Ue,_ as Ut,w as Bt}from"../packem_shared/select-Bul-DeII.js";const Jt=(l,e)=>l<e?-1:l>e?1:0,Ze=l=>{if(l===void 0)return"null";if(typeof l=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key — pass it as a string, or use stableWireKey");if(l===null||typeof l!="object")return JSON.stringify(l);if(Array.isArray(l))return`[${l.map(d=>Ze(d)).join(",")}]`;const e=Object.getPrototypeOf(l);if(e!==null&&e!==Object.prototype){const d=l.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${d} in a stable JSON cache key — only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}const s=l,a=Object.keys(s).toSorted(Jt),t=[];for(const d of a){const i=s[d];i!==void 0&&t.push(`${JSON.stringify(d)}:${Ze(i)}`)}return`{${t.join(",")}}`},gt=(l,e,s)=>`${l}:${e}:${Ze(s??{})}`,ft=(l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,Ht=(l,e)=>ft(l,e),Gt=l=>ft(l.kind,l),Xe=l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),Wt=l=>Array.isArray(l?.series)?l.series:[],Xt="FUNCTION_NOT_FOUND",Yt=l=>{const e=new Map;if(!Array.isArray(l?.series))return e;for(const s of l.series)e.set(gt(s.kind,s.name,s.attributes),s.points);return e},Vt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=l=>{const e=Le(18),{name:s,onOpenTrace:a,traceId:t}=l,d=pe();if(t===void 0){let u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(u=r("span",{className:"text-muted-foreground",children:"—"}),e[0]=u):u=e[0],u}let i;e[1]!==t?(i=t.slice(0,8),e[1]=t,e[2]=i):i=e[2];const n=i;if(a===void 0){const u=`mt-instrument-trace-${s}`;let h;return e[3]!==n||e[4]!==u||e[5]!==t?(h=r("span",{className:"text-muted-foreground","data-testid":u,title:t,children:n}),e[3]=n,e[4]=u,e[5]=t,e[6]=h):h=e[6],h}const k=`mt-instrument-trace-${s}`;let f;e[7]!==a||e[8]!==t?(f=()=>{a(t)},e[7]=a,e[8]=t,e[9]=f):f=e[9];let S;e[10]!==d||e[11]!==t?(S=d("Open the exemplar trace {trace}",{trace:t}),e[10]=d,e[11]=t,e[12]=S):S=e[12];let p;return e[13]!==n||e[14]!==k||e[15]!==f||e[16]!==S?(p=r("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":k,onClick:f,title:S,type:"button",children:n}),e[13]=n,e[14]=k,e[15]=f,e[16]=S,e[17]=p):p=e[17],p},er=l=>{const e=Le(105),{onOpenTrace:s,shardKey:a}=l,t=pe();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d={},e[0]=d):d=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];const{data:n,error:k,errorSource:f}=Je(ze.getMetricSeries,d,i);let S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let p;e[4]!==a?(p={live:!0,shardKey:a},e[4]=a,e[5]=p):p=e[5];const{data:u}=Je(ze.getMetricHistory,S,p);let h,M,b,$,_,c,g,x,w,q,y,I,C;if(e[6]!==n||e[7]!==k||e[8]!==f||e[9]!==u||e[10]!==s||e[11]!==t){x=Symbol.for("react.early_return_sentinel");e:{const z=Wt(n),K=$t(f)===Xt;if(k!==null&&!K){let m;e[25]!==t?(m=t("Instruments"),e[25]=t,e[26]=m):m=e[26];let E;e[27]!==m?(E=r("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=E):E=e[28];let j;e[29]!==k||e[30]!==t?(j=t("Instruments unavailable: {error}",{error:k}),e[29]=k,e[30]=t,e[31]=j):j=e[31];let P;e[32]!==j?(P=r("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:j}),e[32]=j,e[33]=P):P=e[33];let ie;e[34]!==E||e[35]!==P?(ie=o("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[E,P]}),e[34]=E,e[35]=P,e[36]=ie):ie=e[36],x=ie;break e}if(z.length===0){x=null;break e}const Q=Yt(u);let L;e[37]!==t?(L=m=>t(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),e[37]=t,e[38]=L):L=e[38];const U=L;_="flex flex-col gap-2",c="mt-instruments";let O;e[39]!==t?(O=t("Instruments"),e[39]=t,e[40]=O):O=e[40],e[41]!==O?(g=r("h3",{className:"text-sm font-semibold text-foreground",children:O}),e[41]=O,e[42]=g):g=e[42],$=he,C="overflow-hidden py-0",b=ge,I="px-0",M=mt,q="mt-instruments-table";let A;e[43]!==t?(A=t("name"),e[43]=t,e[44]=A):A=e[44];let J;e[45]!==A?(J=r(de,{children:A}),e[45]=A,e[46]=J):J=e[46];let H;e[47]!==t?(H=t("kind"),e[47]=t,e[48]=H):H=e[48];let G;e[49]!==H?(G=r(de,{children:H}),e[49]=H,e[50]=G):G=e[50];let W;e[51]!==t?(W=t("value"),e[51]=t,e[52]=W):W=e[52];let X;e[53]!==W?(X=r(de,{className:"text-right",children:W}),e[53]=W,e[54]=X):X=e[54];let Y;e[55]!==t?(Y=t("count"),e[55]=t,e[56]=Y):Y=e[56];let V;e[57]!==Y?(V=r(de,{className:"text-right",children:Y}),e[57]=Y,e[58]=V):V=e[58];let Z;e[59]!==t?(Z=t("range"),e[59]=t,e[60]=Z):Z=e[60];let ee;e[61]!==Z?(ee=r(de,{className:"text-right",children:Z}),e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==t?(te=t("trend"),e[63]=t,e[64]=te):te=e[64];let re;e[65]!==te?(re=r(de,{children:te}),e[65]=te,e[66]=re):re=e[66];let ae;e[67]!==t?(ae=t("trace"),e[67]=t,e[68]=ae):ae=e[68];let le;e[69]!==ae?(le=r(de,{children:ae}),e[69]=ae,e[70]=le):le=e[70];let se;e[71]!==t?(se=t("dimensions"),e[71]=t,e[72]=se):se=e[72];let ne;e[73]!==se?(ne=r(de,{children:se}),e[73]=se,e[74]=ne):ne=e[74],e[75]!==J||e[76]!==G||e[77]!==X||e[78]!==V||e[79]!==ee||e[80]!==re||e[81]!==le||e[82]!==ne?(y=r(dt,{children:o(He,{children:[J,G,X,V,ee,re,le,ne]})}),e[75]=J,e[76]=G,e[77]=X,e[78]=V,e[79]=ee,e[80]=re,e[81]=le,e[82]=ne,e[83]=y):y=e[83],h=ut,w=z.map(m=>{const E=Ct(m.attributes),j=gt(m.kind,m.name,m.attributes),P=(Q.get(j)??[]).map(ie=>Ht(m.kind,ie));return o(He,{"data-testid":`mt-instrument-${m.name}`,children:[r(oe,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),r(oe,{children:r(et,{variant:Vt[m.kind],children:U(m.kind)})}),r(oe,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:Xe(Gt(m))}),r(oe,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),r(oe,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"—":`${Xe(m.min)}–${Xe(m.max)}`}),r(oe,{children:P.length>=2?r(ht,{ariaLabel:t("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:P,testId:`mt-instrument-trend-${m.name}`}):r("span",{className:"text-xs text-muted-foreground",children:"—"})}),r(oe,{className:"font-mono text-xs",children:r(Zt,{name:m.name,onOpenTrace:s,traceId:m.exemplarTraceId})}),r(oe,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:E,children:E===""?"—":E})]},j)})}e[6]=n,e[7]=k,e[8]=f,e[9]=u,e[10]=s,e[11]=t,e[12]=h,e[13]=M,e[14]=b,e[15]=$,e[16]=_,e[17]=c,e[18]=g,e[19]=x,e[20]=w,e[21]=q,e[22]=y,e[23]=I,e[24]=C}else h=e[12],M=e[13],b=e[14],$=e[15],_=e[16],c=e[17],g=e[18],x=e[19],w=e[20],q=e[21],y=e[22],I=e[23],C=e[24];if(x!==Symbol.for("react.early_return_sentinel"))return x;let R;e[84]!==h||e[85]!==w?(R=r(h,{children:w}),e[84]=h,e[85]=w,e[86]=R):R=e[86];let D;e[87]!==M||e[88]!==R||e[89]!==q||e[90]!==y?(D=o(M,{"data-testid":q,children:[y,R]}),e[87]=M,e[88]=R,e[89]=q,e[90]=y,e[91]=D):D=e[91];let N;e[92]!==b||e[93]!==D||e[94]!==I?(N=r(b,{className:I,children:D}),e[92]=b,e[93]=D,e[94]=I,e[95]=N):N=e[95];let v;e[96]!==$||e[97]!==N||e[98]!==C?(v=r($,{className:C,children:N}),e[96]=$,e[97]=N,e[98]=C,e[99]=v):v=e[99];let T;return e[100]!==_||e[101]!==c||e[102]!==g||e[103]!==v?(T=o("section",{className:_,"data-testid":c,children:[g,v]}),e[100]=_,e[101]=c,e[102]=g,e[103]=v,e[104]=T):T=e[104],T},tr=l=>{const e=Le(74),{aggregate:s,shardResults:a}=l,t=pe();let d;e[0]!==t?(d=t("Shards"),e[0]=t,e[1]=d):d=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==t?(i=s.failed>0?t("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):t("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=t,e[5]=i):i=e[5];let n;e[6]!==d||e[7]!==i?(n=r(me,{label:d,testId:"mt-agg-shards",value:i}),e[6]=d,e[7]=i,e[8]=n):n=e[8];let k;e[9]!==t?(k=t("Total requests"),e[9]=t,e[10]=k):k=e[10];let f;e[11]!==s.totalRequests||e[12]!==k?(f=r(me,{label:k,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=k,e[13]=f):f=e[13];let S;e[14]!==t?(S=t("Total errors"),e[14]=t,e[15]=S):S=e[15];let p;e[16]!==s.totalErrors||e[17]!==S?(p=r(me,{label:S,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=S,e[18]=p):p=e[18];let u;e[19]!==t?(u=t("Total database size"),e[19]=t,e[20]=u):u=e[20];let h;e[21]!==s.totalDatabaseSize?(h=Ye(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=h):h=e[22];let M;e[23]!==u||e[24]!==h?(M=r(me,{label:u,testId:"mt-agg-db-size",value:h}),e[23]=u,e[24]=h,e[25]=M):M=e[25];let b;e[26]!==t?(b=t("Combined cache hit rate"),e[26]=t,e[27]=b):b=e[27];let $;e[28]!==s.hitRate||e[29]!==t?($=s.hitRate===null?t("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=t,e[30]=$):$=e[30];let _;e[31]!==b||e[32]!==$?(_=r(me,{label:b,testId:"mt-agg-cache",value:$}),e[31]=b,e[32]=$,e[33]=_):_=e[33];let c;e[34]!==M||e[35]!==_||e[36]!==n||e[37]!==f||e[38]!==p?(c=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,f,p,M,_]}),e[34]=M,e[35]=_,e[36]=n,e[37]=f,e[38]=p,e[39]=c):c=e[39];let g;e[40]!==t?(g=t("shard"),e[40]=t,e[41]=g):g=e[41];let x;e[42]!==g?(x=r(de,{children:g}),e[42]=g,e[43]=x):x=e[43];let w;e[44]!==t?(w=t("requests"),e[44]=t,e[45]=w):w=e[45];let q;e[46]!==w?(q=r(de,{children:w}),e[46]=w,e[47]=q):q=e[47];let y;e[48]!==t?(y=t("errors"),e[48]=t,e[49]=y):y=e[49];let I;e[50]!==y?(I=r(de,{children:y}),e[50]=y,e[51]=I):I=e[51];let C;e[52]!==t?(C=t("db size"),e[52]=t,e[53]=C):C=e[53];let R;e[54]!==C?(R=r(de,{children:C}),e[54]=C,e[55]=R):R=e[55];let D;e[56]!==x||e[57]!==q||e[58]!==I||e[59]!==R?(D=r(dt,{children:o(He,{children:[x,q,I,R]})}),e[56]=x,e[57]=q,e[58]=I,e[59]=R,e[60]=D):D=e[60];let N;if(e[61]!==a||e[62]!==t){let K;e[64]!==t?(K=Q=>o(He,{"data-testid":`mt-agg-row-${Q.shard}`,children:[r(oe,{children:Q.shard}),Q.metrics===null?r(oe,{className:"text-destructive",colSpan:3,children:Q.error??t("unreachable")}):o(Ve,{children:[r(oe,{className:"tabular-nums",children:Q.metrics.requests}),r(oe,{className:"tabular-nums",children:Q.metrics.errors}),r(oe,{className:"tabular-nums",children:Ye(Q.metrics.databaseSize)})]})]},Q.shard),e[64]=t,e[65]=K):K=e[65],N=a.map(K),e[61]=a,e[62]=t,e[63]=N}else N=e[63];let v;e[66]!==N?(v=r(ut,{children:N}),e[66]=N,e[67]=v):v=e[67];let T;e[68]!==D||e[69]!==v?(T=r(he,{className:"overflow-hidden py-0",children:r(ge,{className:"px-0",children:o(mt,{"data-testid":"mt-agg-table",children:[D,v]})})}),e[68]=D,e[69]=v,e[70]=T):T=e[70];let z;return e[71]!==c||e[72]!==T?(z=o("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[c,T]}),e[71]=c,e[72]=T,e[73]=z):z=e[73],z},rr=l=>{const e=Math.floor(l/1e3),s=Math.floor(e/3600),a=Math.floor(e%3600/60),t=e%60;return s>0?`${s.toString()}h ${a.toString()}m`:a>0?`${a.toString()}m ${t.toString()}s`:`${t.toString()}s`},ar=(l,e)=>{const s=l+e;return s===0?"—":`${(l/s*100).toFixed(1)}%`},ct=l=>l<=0?"—":l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,lr=l=>{const e=Le(75),{currentDelta:s,errorRate:a,history:t,latencyPercentiles:d,metrics:i}=l,n=pe();let k;e[0]!==t||e[1]!==n?(k=t.length>=2?r(ht,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:t,testId:"mt-sparkline"}):void 0,e[0]=t,e[1]=n,e[2]=k):k=e[2];let f;e[3]!==s||e[4]!==t.length||e[5]!==n?(f=t.length>=2?o(Ve,{children:[r("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):r("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples…")}),e[3]=s,e[4]=t.length,e[5]=n,e[6]=f):f=e[6];let S;e[7]!==n?(S=n("Requests"),e[7]=n,e[8]=S):S=e[8];let p;e[9]!==i.requests||e[10]!==k||e[11]!==f||e[12]!==S?(p=r(me,{chart:k,footer:f,label:S,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=k,e[11]=f,e[12]=S,e[13]=p):p=e[13];let u;e[14]!==a||e[15]!==n?(u=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=u):u=e[16];let h;e[17]!==n?(h=n("Errors"),e[17]=n,e[18]=h):h=e[18];let M;e[19]!==a||e[20]!==i.errors?(M=o(Ve,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=M):M=e[21];let b;e[22]!==u||e[23]!==h||e[24]!==M?(b=r(me,{footer:u,label:h,testId:"mt-errors",value:M}),e[22]=u,e[23]=h,e[24]=M,e[25]=b):b=e[25];let $;e[26]!==d.p90?($=d.p90>0?`P90 ${ct(d.p90)}`:void 0,e[26]=d.p90,e[27]=$):$=e[27];let _;e[28]!==n?(_=n("P95 latency"),e[28]=n,e[29]=_):_=e[29];let c;e[30]!==d.p95?(c=d.p95>0?ct(d.p95):"—",e[30]=d.p95,e[31]=c):c=e[31];let g;e[32]!==_||e[33]!==c||e[34]!==$?(g=r(me,{footer:$,label:_,testId:"mt-p95",value:c}),e[32]=_,e[33]=c,e[34]=$,e[35]=g):g=e[35];let x;e[36]!==i.cache||e[37]!==n?(x=i.cache===null?void 0:`${i.cache.entries.toLocaleString()} ${n("cache entries")}`,e[36]=i.cache,e[37]=n,e[38]=x):x=e[38];let w;e[39]!==n?(w=n("Database size"),e[39]=n,e[40]=w):w=e[40];let q;e[41]!==i.databaseSize?(q=Ye(i.databaseSize),e[41]=i.databaseSize,e[42]=q):q=e[42];let y;e[43]!==x||e[44]!==w||e[45]!==q?(y=r(me,{footer:x,label:w,testId:"mt-db-size",value:q}),e[43]=x,e[44]=w,e[45]=q,e[46]=y):y=e[46];let I;e[47]!==n?(I=n("Shard"),e[47]=n,e[48]=I):I=e[48];let C;e[49]!==i.shard||e[50]!==I?(C=r(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=C):C=e[51];let R;e[52]!==n?(R=n("Uptime"),e[52]=n,e[53]=R):R=e[53];let D;e[54]!==i.uptimeMs?(D=rr(i.uptimeMs),e[54]=i.uptimeMs,e[55]=D):D=e[55];let N;e[56]!==R||e[57]!==D?(N=r(me,{label:R,testId:"mt-uptime",value:D}),e[56]=R,e[57]=D,e[58]=N):N=e[58];let v;e[59]!==n?(v=n("Cache hit rate"),e[59]=n,e[60]=v):v=e[60];let T;e[61]!==i.cache||e[62]!==n?(T=i.cache===null?n("no cache configured"):n("{rate} ({count} entries)",{count:i.cache.entries,rate:ar(i.cache.hits,i.cache.misses)}),e[61]=i.cache,e[62]=n,e[63]=T):T=e[63];let z;e[64]!==v||e[65]!==T?(z=r(me,{label:v,testId:"mt-cache",value:T}),e[64]=v,e[65]=T,e[66]=z):z=e[66];let K;return e[67]!==g||e[68]!==y||e[69]!==C||e[70]!==N||e[71]!==z||e[72]!==p||e[73]!==b?(K=o("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[p,b,g,y,C,N,z]}),e[67]=g,e[68]=y,e[69]=C,e[70]=N,e[71]=z,e[72]=p,e[73]=b,e[74]=K):K=e[74],K},Ge=l=>l>=100?"critical":l>=50?"warning":"good",Oe=l=>l<1?`${(l*1e3).toFixed(0)}μs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,Be=l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),sr=l=>{const e=Le(3),{level:s}=l;if(s==="critical"){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=r(et,{variant:"destructive",children:"Slow"}),e[0]=t):t=e[0],t}if(s==="warning"){let t;return e[1]===Symbol.for("react.memo_cache_sentinel")?(t=r("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=t):t=e[1],t}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=r("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=a):a=e[2],a},nr=(l,e)=>{const s=[...l];return s.sort((a,t)=>{switch(e){case"avgTime":return t.avgDurationMs-a.avgDurationMs;case"execCount":return t.execCount-a.execCount;case"rowsRead":return t.rowsRead-a.rowsRead;default:return t.totalDurationMs-a.totalDurationMs}}),s},ir=l=>{const e=Le(161),{queryStats:s}=l,a=pe(),[t,d]=fe("totalTime");let i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];const[n,k]=fe(i);let f;e[1]===Symbol.for("react.memo_cache_sentinel")?(f=C=>{C!==null&&d(C)},e[1]=f):f=e[1];const S=f;let p,u,h,M,b,$,_,c,g,x;if(e[2]!==n||e[3]!==s||e[4]!==t||e[5]!==a){h=Symbol.for("react.early_return_sentinel");e:{const C=nr(s,t);let R;e[16]!==s?(R=s.filter(or),e[16]=s,e[17]=R):R=e[17];const D=R.length;let N;e[18]!==s?(N=s.filter(cr),e[18]=s,e[19]=N):N=e[19];const v=N.length;let T;e[20]!==s?(T=s.filter(dr),e[20]=s,e[21]=T):T=e[21];const z=T.length;let K;e[22]===Symbol.for("react.memo_cache_sentinel")?(K=F=>{k(ce=>{const B=new Set(ce);return B.has(F)?B.delete(F):B.add(F),B})},e[22]=K):K=e[22];const Q=K;if(s.length===0){let F;e[23]!==a?(F=a("No query insights yet"),e[23]=a,e[24]=F):F=e[24];let ce;e[25]!==F?(ce=r("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:F}),e[25]=F,e[26]=ce):ce=e[26];let B;e[27]!==a?(B=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=B):B=e[28];let ue;e[29]!==B?(ue=r("p",{className:"mt-1 text-sm",children:B}),e[29]=B,e[30]=ue):ue=e[30];let je;e[31]!==ce||e[32]!==ue?(je=r(he,{children:r(ge,{className:"py-12",children:o("div",{className:"text-center text-muted-foreground",children:[ce,ue]})})}),e[31]=ce,e[32]=ue,e[33]=je):je=e[33],h=je;break e}_="space-y-4",c="qi-root";let L;e[34]!==a?(L=a("Critical queries"),e[34]=a,e[35]=L):L=e[35];let U;e[36]!==L?(U=r(Pe,{className:"pb-2",children:r(Qe,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=U):U=e[37];let O;e[38]!==D?(O=r("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:D}),e[38]=D,e[39]=O):O=e[39];let A;e[40]!==a?(A=a(">100ms avg execution"),e[40]=a,e[41]=A):A=e[41];let J;e[42]!==A?(J=r("p",{className:"text-xs text-muted-foreground",children:A}),e[42]=A,e[43]=J):J=e[43];let H;e[44]!==O||e[45]!==J?(H=o(ge,{children:[O,J]}),e[44]=O,e[45]=J,e[46]=H):H=e[46];let G;e[47]!==U||e[48]!==H?(G=o(he,{children:[U,H]}),e[47]=U,e[48]=H,e[49]=G):G=e[49];let W;e[50]!==a?(W=a("Moderate queries"),e[50]=a,e[51]=W):W=e[51];let X;e[52]!==W?(X=r(Pe,{className:"pb-2",children:r(Qe,{className:"text-sm font-medium",children:W})}),e[52]=W,e[53]=X):X=e[53];let Y;e[54]!==v?(Y=r("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:v}),e[54]=v,e[55]=Y):Y=e[55];let V;e[56]!==a?(V=a("50–100ms avg execution"),e[56]=a,e[57]=V):V=e[57];let Z;e[58]!==V?(Z=r("p",{className:"text-xs text-muted-foreground",children:V}),e[58]=V,e[59]=Z):Z=e[59];let ee;e[60]!==Y||e[61]!==Z?(ee=o(ge,{children:[Y,Z]}),e[60]=Y,e[61]=Z,e[62]=ee):ee=e[62];let te;e[63]!==X||e[64]!==ee?(te=o(he,{children:[X,ee]}),e[63]=X,e[64]=ee,e[65]=te):te=e[65];let re;e[66]!==a?(re=a("Fast queries"),e[66]=a,e[67]=re):re=e[67];let ae;e[68]!==re?(ae=r(Pe,{className:"pb-2",children:r(Qe,{className:"text-sm font-medium",children:re})}),e[68]=re,e[69]=ae):ae=e[69];let le;e[70]!==z?(le=r("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:z}),e[70]=z,e[71]=le):le=e[71];let se;e[72]!==a?(se=a("<50ms avg execution"),e[72]=a,e[73]=se):se=e[73];let ne;e[74]!==se?(ne=r("p",{className:"text-xs text-muted-foreground",children:se}),e[74]=se,e[75]=ne):ne=e[75];let m;e[76]!==le||e[77]!==ne?(m=o(ge,{children:[le,ne]}),e[76]=le,e[77]=ne,e[78]=m):m=e[78];let E;e[79]!==ae||e[80]!==m?(E=o(he,{children:[ae,m]}),e[79]=ae,e[80]=m,e[81]=E):E=e[81],e[82]!==G||e[83]!==te||e[84]!==E?(g=o("div",{className:"grid gap-4 md:grid-cols-3",children:[G,te,E]}),e[82]=G,e[83]=te,e[84]=E,e[85]=g):g=e[85];let j;e[86]!==a?(j=a("Query leaderboard"),e[86]=a,e[87]=j):j=e[87];let P;e[88]!==j?(P=r("h3",{className:"text-lg font-semibold",children:j}),e[88]=j,e[89]=P):P=e[89];let ie;e[90]!==t||e[91]!==a?(ie=a("Slow queries sorted by {sortField}",{sortField:a(t)}),e[90]=t,e[91]=a,e[92]=ie):ie=e[92];let xe;e[93]!==ie?(xe=r("p",{className:"text-sm text-muted-foreground",children:ie}),e[93]=ie,e[94]=xe):xe=e[94];let be;e[95]!==P||e[96]!==xe?(be=o("div",{children:[P,xe]}),e[95]=P,e[96]=xe,e[97]=be):be=e[97];let ve;e[98]!==a?(ve=a("Sort by"),e[98]=a,e[99]=ve):ve=e[99];let ye;e[100]!==ve?(ye=r("span",{className:"text-sm text-muted-foreground",children:ve}),e[100]=ve,e[101]=ye):ye=e[101];let Ne;e[102]!==a?(Ne=a("Sort queries by"),e[102]=a,e[103]=Ne):Ne=e[103];let Ae;e[104]===Symbol.for("react.memo_cache_sentinel")?(Ae=r(Pt,{}),e[104]=Ae):Ae=e[104];let Se;e[105]!==Ne?(Se=r(Qt,{"aria-label":Ne,className:"w-[140px]","data-testid":"qi-sort",children:Ae}),e[105]=Ne,e[106]=Se):Se=e[106];let $e;e[107]!==a?($e=a("Total time"),e[107]=a,e[108]=$e):$e=e[108];let we;e[109]!==$e?(we=r(Ue,{value:"totalTime",children:$e}),e[109]=$e,e[110]=we):we=e[110];let qe;e[111]!==a?(qe=a("Avg time"),e[111]=a,e[112]=qe):qe=e[112];let ke;e[113]!==qe?(ke=r(Ue,{value:"avgTime",children:qe}),e[113]=qe,e[114]=ke):ke=e[114];let Me;e[115]!==a?(Me=a("Execution count"),e[115]=a,e[116]=Me):Me=e[116];let _e;e[117]!==Me?(_e=r(Ue,{value:"execCount",children:Me}),e[117]=Me,e[118]=_e):_e=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Ce;e[121]!==Ie?(Ce=r(Ue,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Ce):Ce=e[122];let Re;e[123]!==we||e[124]!==ke||e[125]!==_e||e[126]!==Ce?(Re=o(Ut,{children:[we,ke,_e,Ce]}),e[123]=we,e[124]=ke,e[125]=_e,e[126]=Ce,e[127]=Re):Re=e[127];let De;e[128]!==t||e[129]!==Se||e[130]!==Re?(De=o(Bt,{onValueChange:S,value:t,children:[Se,Re]}),e[128]=t,e[129]=Se,e[130]=Re,e[131]=De):De=e[131];let Fe;e[132]!==ye||e[133]!==De?(Fe=o("div",{className:"flex items-center gap-2",children:[ye,De]}),e[132]=ye,e[133]=De,e[134]=Fe):Fe=e[134],e[135]!==be||e[136]!==Fe?(x=o("div",{className:"flex items-center justify-between",children:[be,Fe]}),e[135]=be,e[136]=Fe,e[137]=x):x=e[137],u=he;let Te;e[138]!==a?(Te=a("Statements"),e[138]=a,e[139]=Te):Te=e[139];let Ke;e[140]!==Te?(Ke=r(Qe,{children:Te}),e[140]=Te,e[141]=Ke):Ke=e[141],$=o(Pe,{children:[Ke,r(Rt,{children:a("{count} tracked statements",{count:C.length})})]}),p=ge,M="space-y-2";let Ee;e[142]!==n||e[143]!==a?(Ee=F=>{const ce=F.normalizedSql,B=n.has(ce),ue=Ge(F.avgDurationMs);return o("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[o("button",{"aria-expanded":B,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:()=>{Q(ce)},type:"button",children:[o("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[r(sr,{level:ue}),r("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:F.normalizedSql})]}),o("div",{className:"flex shrink-0 items-center gap-4",children:[o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.totalDurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.avgDurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),F.p95DurationMs!==void 0&&o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Oe(F.p95DurationMs)}),r("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),o("div",{className:"text-right",children:[r("div",{className:"text-sm font-medium",children:Be(F.execCount)}),r("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),B&&o("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[o("div",{children:[r("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),r("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:F.normalizedSql})]}),o("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[F.p50DurationMs!==void 0&&o("div",{children:[r("span",{className:"text-muted-foreground",children:a("p50")}),r("span",{className:"block font-medium tabular-nums",children:Oe(F.p50DurationMs)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Exec count")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.execCount)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Total time")}),r("span",{className:"block font-medium tabular-nums",children:Oe(F.totalDurationMs)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Rows read")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.rowsRead)})]}),o("div",{children:[r("span",{className:"text-muted-foreground",children:a("Rows written")}),r("span",{className:"block font-medium tabular-nums",children:Be(F.rowsWritten)})]})]})]})]},ce)},e[142]=n,e[143]=a,e[144]=Ee):Ee=e[144],b=C.map(Ee)}e[2]=n,e[3]=s,e[4]=t,e[5]=a,e[6]=p,e[7]=u,e[8]=h,e[9]=M,e[10]=b,e[11]=$,e[12]=_,e[13]=c,e[14]=g,e[15]=x}else p=e[6],u=e[7],h=e[8],M=e[9],b=e[10],$=e[11],_=e[12],c=e[13],g=e[14],x=e[15];if(h!==Symbol.for("react.early_return_sentinel"))return h;let w;e[145]!==M||e[146]!==b?(w=r("div",{className:M,children:b}),e[145]=M,e[146]=b,e[147]=w):w=e[147];let q;e[148]!==p||e[149]!==w?(q=r(p,{children:w}),e[148]=p,e[149]=w,e[150]=q):q=e[150];let y;e[151]!==u||e[152]!==q||e[153]!==$?(y=o(u,{children:[$,q]}),e[151]=u,e[152]=q,e[153]=$,e[154]=y):y=e[154];let I;return e[155]!==y||e[156]!==_||e[157]!==c||e[158]!==g||e[159]!==x?(I=o("div",{className:_,"data-testid":c,children:[g,x,y]}),e[155]=y,e[156]=_,e[157]=c,e[158]=g,e[159]=x,e[160]=I):I=e[160],I};function or(l){return Ge(l.avgDurationMs)==="critical"}function cr(l){return Ge(l.avgDurationMs)==="warning"}function dr(l){return Ge(l.avgDurationMs)==="good"}const mr=["1m","5m","15m","1h"],ur=l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),hr=l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),gr=({shardKey:l=""})=>{const e=pe(),[s,a]=fe("15m"),t=Je(ze.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,d=hr(t?.buckets??[]);return o("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[r("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:mr.map(i=>r("button",{"aria-pressed":i===s,className:jt("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:()=>{a(i)},type:"button",children:i},i))}),t?.capped===!0&&r(et,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),d.length===0?r(Et,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):o("div",{className:"grid gap-4 lg:grid-cols-2",children:[o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[r("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),r(lt,{height:140,width:"100%",children:o(Ot,{data:d,children:[r(st,{strokeDasharray:"3 3",vertical:!1}),r(nt,{dataKey:"label",fontSize:10,tickLine:!1}),r(it,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),r(ot,{}),r(zt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),o("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[r("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),r(lt,{height:140,width:"100%",children:o(At,{data:d,children:[r(st,{strokeDasharray:"3 3",vertical:!1}),r(nt,{dataKey:"label",fontSize:10,tickLine:!1}),r(it,{fontSize:10,tickLine:!1,width:32}),r(ot,{}),r(Kt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),r(ir,{queryStats:t?.entries??[]})]})},fr=kt(ze.getMetrics),pr=(l,e)=>l?e:"overview",Ur=({initialShardKey:l})=>{const e=pt(),s=pe(),a=xt(),{queryShardKey:t,setShardKey:d,shardKey:i}=Nt(l),[n,k]=fe("overview"),[f,S]=fe([]),p=We(null),u=We(null),h=We(!0);tt(()=>(h.current=!0,()=>{h.current=!1}),[]);const M=L=>{It({shardKey:t,traceId:L}),at(a({to:"/traces"}))},{data:b,error:$,liveError:_}=Je(ze.getMetrics,{},{live:!0,shardKey:t}),c=b??null;tt(()=>{if(b===void 0)return;Mt(t);const L=b,U=p.current,O=u.current!==null&&u.current!==L.shard;if(u.current=L.shard,p.current=L.requests,O){S([]);return}U!==null&&L.requests>=U&&S(A=>[...A,L.requests-U].slice(-30))},[b,t]);const[g,x]=fe(null),[w,q]=fe(!1),y=async()=>{q(!0);const L=Lt(i,_t());try{const U=await Promise.all(L.map(async O=>{try{const A=await e.query(fr,{},wt(O));return{error:null,metrics:A,shard:O===""?A.shard:O}}catch(A){return{error:qt(A),metrics:null,shard:O===""?"__root__":O}}}));h.current&&x(U)}finally{h.current&&q(!1)}},I=g===null?null:Dt(g),C=c===null||c.requests===0?"—":`${(c.errors/c.requests*100).toFixed(1)}%`,R=f.length>0?f.at(-1):0,D=c?Ft(c):{p90:0,p95:0},N=bt(()=>{if(!c||!("queryStats"in c))return;const L=c.queryStats;if(!(!L||!Array.isArray(L)))return Tt(L)},[c]),v=pr(N!==void 0,n),T=()=>{at(y())},z=()=>{x(null)},K=()=>{k("overview")},Q=()=>{k("query-insights")};return o("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[o("div",{className:"flex flex-wrap items-center gap-2",children:[r(yt,{onChange:d,testId:"mt-shard-input",value:i}),r(vt,{message:_,prefix:"mt"}),r(rt,{"data-testid":"mt-aggregate",disabled:w,onClick:T,size:"sm",type:"button",variant:"secondary",children:s(w?"Aggregating…":"All shards")}),g!==null&&r(rt,{"data-testid":"mt-aggregate-clear",onClick:z,size:"sm",type:"button",variant:"ghost",children:s("Hide")}),r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:St,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")})]}),$!==null&&r("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:$}),N!==void 0&&o("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[r("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:K,type:"button",children:s("Overview")}),o("button",{className:`pb-2 text-sm font-medium transition-colors ${v==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:Q,type:"button",children:[s("Query insights"),N.length>0&&r("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:N.length})]})]}),v==="query-insights"&&N!==void 0&&r(gr,{shardKey:t}),v==="overview"&&c!==null&&r(lr,{currentDelta:R,errorRate:C,history:f,latencyPercentiles:D,metrics:c}),v==="overview"&&c===null&&null,v==="overview"&&r(er,{onOpenTrace:M,shardKey:t}),v==="overview"&&I!==null&&g!==null&&r(tr,{aggregate:I,shardResults:g})]})};export{Ur as MetricsPanel};
@@ -0,0 +1 @@
1
+ import{c as W}from"react/compiler-runtime";import{useState as T}from"react";import{E as B}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as _}from"../packem_shared/badge-BbuuAio7.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as O,u as U}from"../packem_shared/card-CIDGUN6K.js";import{E as q}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as G}from"../packem_shared/input-JHu63lTv.js";import{n as J,d as K,m as F,p as h,f as Q,u as f}from"../packem_shared/table-DdJBrClo.js";import{N as X}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as Z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as ee}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as t,jsxs as x}from"react/jsx-runtime";const te=e=>e==="ok"?"success":e==="failed"?"destructive":e==="expired"?"warning":"secondary",P=e=>e.endpoint??e.id,ve=()=>{const e=W(38),r=Y(),[i,R]=T("all"),[s,V]=T("");let g;e[0]===Symbol.for("react.memo_cache_sentinel")?(g={},e[0]=g):g=e[0];const{data:S,error:o,errorSource:p,isLoading:C,refetch:v}=X(Z.listPushSubscriptions,g);let N;if(e[1]!==S?.subscriptions||e[2]!==o||e[3]!==p||e[4]!==C||e[5]!==i||e[6]!==v||e[7]!==s||e[8]!==r){const A=S?.subscriptions??[],j=s.trim().toLowerCase(),E=A.filter(a=>i!=="all"&&a.kind!==i?!1:j===""?!0:`${P(a)} ${a.userId??""}`.toLowerCase().includes(j));let b;e[10]===Symbol.for("react.memo_cache_sentinel")?(b=a=>{V(a.target.value)},e[10]=b):b=e[10];const D=b;let w;e[11]!==v?(w=()=>{v()},e[11]=v,e[12]=w):w=e[12];const I=w;let y;e[13]===Symbol.for("react.memo_cache_sentinel")?(y=["all","web-push","fcm"],e[13]=y):y=e[13];const H=y;let l;e[14]!==i||e[15]!==r?(l=t("div",{className:"flex items-center gap-1","data-testid":"nt-kind-filter",role:"tablist",children:H.map(a=>t(z,{"aria-selected":i===a,"data-testid":`nt-kind-${a}`,onClick:()=>{R(a)},role:"tab",size:"sm",type:"button",variant:i===a?"secondary":"ghost",children:a==="all"?r("All"):a},a))}),e[14]=i,e[15]=r,e[16]=l):l=e[16];let n;e[17]!==r?(n=r("Filter devices"),e[17]=r,e[18]=n):n=e[18];let c;e[19]!==r?(c=r("filter endpoint, user"),e[19]=r,e[20]=c):c=e[20];let d;e[21]!==s||e[22]!==n||e[23]!==c?(d=t(G,{"aria-label":n,className:"h-8 w-56","data-testid":"nt-search",onChange:D,placeholder:c,value:s}),e[21]=s,e[22]=n,e[23]=c,e[24]=d):d=e[24];let m;e[25]!==r?(m=r("Refresh"),e[25]=r,e[26]=m):m=e[26];let u;e[27]!==I||e[28]!==m?(u=t(z,{className:"ml-auto","data-testid":"nt-refresh",onClick:I,size:"sm",type:"button",variant:"outline",children:m}),e[27]=I,e[28]=m,e[29]=u):u=e[29];const L=A.length>0&&t(_,{"data-testid":"nt-count",variant:"secondary",children:r("{count} devices",{count:A.length})});let $;e[30]!==u||e[31]!==L||e[32]!==l||e[33]!==d?($=x("div",{className:"flex flex-wrap items-center gap-2",children:[l,d,u,L]}),e[30]=u,e[31]=L,e[32]=l,e[33]=d,e[34]=$):$=e[34];let k;e[35]!==o||e[36]!==p?(k=o!==null&&t(B,{error:p,testId:"nt-error"}),e[35]=o,e[36]=p,e[37]=k):k=e[37],N=x("div",{className:"flex flex-col gap-4","data-testid":"lunora-notifications",children:[$,k,o===null&&!C&&E.length===0&&t(q,{description:r("Registered Web Push / FCM devices appear here. Configure lunora/notify.ts with defineNotify({ store }) and register a device with ctx.push.register(...)."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M15 17h5l-1.4-1.4A2 2 0 0 1 18 14.2V11a6 6 0 0 0-4-5.7V5a2 2 0 1 0-4 0v.3A6 6 0 0 0 6 11v3.2a2 2 0 0 1-.6 1.4L4 17h5m6 0v1a3 3 0 1 1-6 0v-1m6 0H9"})}),testId:"nt-empty",title:r("No registered devices.")}),E.length>0&&t(O,{className:"overflow-hidden py-0",children:t(U,{className:"max-h-[30rem] overflow-auto px-0",children:x(J,{"data-testid":"nt-table",children:[t(K,{children:x(F,{children:[t(h,{children:r("kind")}),t(h,{children:r("endpoint")}),t(h,{children:r("user")}),t(h,{children:r("last seen")}),t(h,{children:r("status")}),t(h,{children:r("error")})]})}),t(Q,{children:E.map(a=>{const M=P(a);return x(F,{"data-testid":"nt-row",children:[t(f,{children:t(_,{variant:"outline",children:a.kind})}),t(f,{className:"max-w-[28ch] truncate font-mono text-xs",title:M,children:M}),t(f,{className:"max-w-[16ch] truncate font-mono text-xs",children:a.userId??t("span",{className:"text-muted-foreground",children:"—"})}),t(f,{className:"text-muted-foreground tabular-nums",children:ee(a.lastSeenAt,"—")}),t(f,{children:t(_,{"data-testid":`nt-status-${a.id}`,variant:te(a.lastStatus),children:a.lastStatus??r("n/a")})}),t(f,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",title:a.lastError??void 0,children:a.lastError??t("span",{className:"text-muted-foreground",children:"—"})})]},a.id)})})]})})})]}),e[1]=S?.subscriptions,e[2]=o,e[3]=p,e[4]=C,e[5]=i,e[6]=v,e[7]=s,e[8]=r,e[9]=N}else N=e[9];return N};export{ve as NotificationsPanel};
@@ -0,0 +1 @@
1
+ import{useLunora as E}from"@lunora/react";import{useState as s,useCallback as H,useEffect as W}from"react";import{ConfirmButton as F}from"../packem_shared/ConfirmButton-CTL3f3kr.js";import{g as Z}from"../packem_shared/badge-BbuuAio7.js";import{u as _}from"../packem_shared/button-BkCrNcAs.js";import{u as I}from"../packem_shared/input-JHu63lTv.js";import{p as g}from"../packem_shared/label-6uP1obNF.js";import{useAutoRefresh as G}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as J}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as B}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{d as u,b as N,f as p,g as S}from"../packem_shared/internal-BSIsQVC6.js";import{jsxs as a,jsx as r}from"react/jsx-runtime";const y=S(B.getPitrBookmark),Q=S(B.pitrRestore),de=({initialShardKey:T})=>{const m=E(),t=J(),i=T??"",[O,f]=s(null),[l,P]=s(""),[v,w]=s(null),[c,q]=s(""),[h,A]=s(!1),[o,L]=s(null),[C,n]=s(null),[x,d]=s(!1),b=H(async()=>{d(!0),n(null);try{const e=await m.query(y,{},u(i));f(e.current)}catch(e){n(N(e))}d(!1)},[m,i]);W(()=>{p(b())},[b]),G(()=>{p((async()=>{try{const e=await m.query(y,{},u(i));f(e.current)}catch{}})())},!0);const U=e=>{P(e.target.value)},j=e=>{q(e.target.value)},M=e=>{A(e.target.checked)},z=()=>{l.trim()!==""&&p((async()=>{d(!0),n(null);try{const e=await m.query(y,{time:l.trim()},u(i));w(e.forTime??null),f(e.current)}catch(e){w(null),n(N(e))}d(!1)})())},R=e=>{p((async()=>{d(!0),n(null);try{const k=await m.mutation(Q,e,u(i));L(k),await b()}catch(k){n(N(k))}d(!1)})())},K=c.trim()!==""||l.trim()!=="",$=()=>{const e=h?{restart:!0}:{};c.trim()===""?e.time=l.trim():e.bookmark=c.trim(),R(e)},D=()=>{o!==null&&R(h?{bookmark:o.undoBookmark,restart:!0}:{bookmark:o.undoBookmark})};return a("div",{className:"flex flex-col gap-4","data-testid":"lunora-pitr",children:[r("div",{className:"flex flex-wrap items-center gap-3",children:a("span",{className:"text-xs text-muted-foreground",children:[t("Shard"),": ",r("span",{className:"font-mono",children:i===""?t("root"):i})]})}),r("p",{className:"text-sm text-muted-foreground","data-testid":"pitr-note",children:t("In-place recovery to any moment in the last 30 days. For older or portable recovery, use the snapshot backup tier.")}),C!==null&&r("p",{className:"text-sm text-destructive","data-testid":"pitr-error",role:"alert",children:C}),a("section",{className:"rounded-xl border border-border bg-card p-3 shadow-xs",children:[r("h3",{className:"mb-2 text-sm font-semibold",children:t("Current bookmark")}),r("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-current",children:O??r("span",{className:"text-muted-foreground",children:"—"})})]}),a("section",{className:"flex flex-col gap-3 rounded-xl border border-border bg-card p-3 shadow-xs",children:[r("h3",{className:"text-sm font-semibold",children:t("Restore")}),a("div",{className:"flex flex-col gap-1",children:[r(g,{htmlFor:"pitr-time",children:t("Time (ISO or epoch-ms, last 30 days)")}),a("div",{className:"flex items-center gap-2",children:[r(I,{"data-testid":"pitr-time",id:"pitr-time",onChange:U,placeholder:"2026-06-01T00:00:00.000Z",value:l}),r(_,{"data-testid":"pitr-preview",disabled:x||l.trim()==="",onClick:z,size:"sm",type:"button",variant:"outline",children:t("Preview")})]}),v!==null&&a("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-preview-bookmark",children:[t("Bookmark for that time"),": ",v]})]}),a("div",{className:"flex flex-col gap-1",children:[r(g,{htmlFor:"pitr-bookmark",children:t("Or an explicit bookmark (wins over time)")}),r(I,{"data-testid":"pitr-bookmark",id:"pitr-bookmark",onChange:j,placeholder:t("bookmark string"),value:c})]}),a(g,{className:"flex items-center gap-2 text-xs font-normal text-muted-foreground",htmlFor:"pitr-restart",children:[r("input",{checked:h,className:"size-4 accent-primary","data-testid":"pitr-restart",id:"pitr-restart",onChange:M,type:"checkbox"}),t("Restart the shard now so recovery applies immediately")]}),r("div",{children:r(F,{confirmLabel:t("Confirm restore"),disabled:x||!K,onConfirm:$,testId:"pitr-restore",children:t("Restore")})})]}),o!==null&&a("section",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card p-3 shadow-xs","data-testid":"pitr-result",children:[a("div",{className:"flex items-center gap-2",children:[r("h3",{className:"text-sm font-semibold",children:t("Restore armed")}),r(Z,{variant:o.restarted?"destructive":"secondary",children:o.restarted?t("restarted now"):t("on next restart")})]}),a("p",{className:"font-mono text-xs break-all text-muted-foreground",children:[t("Restored to"),": ",o.restoredTo]}),a("p",{className:"font-mono text-xs break-all text-muted-foreground","data-testid":"pitr-undo-bookmark",children:[t("Undo bookmark"),": ",o.undoBookmark]}),r("div",{children:r(F,{confirmLabel:t("Confirm undo"),disabled:x,onConfirm:D,testId:"pitr-undo",children:t("Undo restore")})})]})]})};export{de as PitrPanel};
@@ -0,0 +1 @@
1
+ import{c as Ce}from"react/compiler-runtime";import{ShardInput as Ze}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as Re,d as Oe}from"../packem_shared/storage-tier-DznqOf-q.js";import{g as Fe}from"../packem_shared/badge-BbuuAio7.js";import{f as Ke,m as Ge,n as Le,u as Me,c as De}from"../packem_shared/card-CIDGUN6K.js";import{E as He}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ie}from"../packem_shared/input-JHu63lTv.js";import{useT as je}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{d as Ae,b as Ee,f as fe,g as qe}from"../packem_shared/internal-BSIsQVC6.js";import{c as We}from"../packem_shared/utils-bhneXptQ.js";import{useLunora as Qe}from"@lunora/react";import{useState as $,useEffect as Pe,useRef as et}from"react";import{S as tt}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{ADMIN_FUNCTIONS as ze}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{r as lt}from"../packem_shared/shard-history-DMEW5VBE.js";import{S as at}from"../packem_shared/schema-diagram-cg-bz_VL.js";import{useNavigate as nt}from"@tanstack/react-router";import{u as be}from"../packem_shared/button-BkCrNcAs.js";import{p as _e}from"../packem_shared/label-6uP1obNF.js";import{jsx as l,jsxs as g,Fragment as Ve}from"react/jsx-runtime";const st=qe(ze.listTables),rt=qe(ze.listTableIndexes),ot=qe(ze.readTablePage),it=qe(ze.describeTables),dt={},Be=[],ct=s=>{const e=Ce(74),{initialShardKey:m,initialTable:n}=s,t=Qe(),[a,c]=$("graph"),{queryShardKey:d,setShardKey:i,shardKey:f}=tt(m),[r,h]=$(""),[o,x]=$(null),[p,P]=$(null);let S;e[0]===Symbol.for("react.memo_cache_sentinel")?(S={},e[0]=S):S=e[0];const[L,v]=$(S);let K;e[1]===Symbol.for("react.memo_cache_sentinel")?(K={},e[1]=K):K=e[1];const[F,M]=$(K),[w,N]=$(null);let A;e[2]===Symbol.for("react.memo_cache_sentinel")?(A={},e[2]=A):A=e[2];const[j,me]=$(A);let Z;e[3]===Symbol.for("react.memo_cache_sentinel")?(Z={},e[3]=Z):Z=e[3];const[k,G]=$(Z),[_,ue]=$(null),[D,oe]=$(null);let H;e[4]===Symbol.for("react.memo_cache_sentinel")?(H={},e[4]=H):H=e[4];const[X,xe]=$(H),[Y,ie]=$(null);let ve;e[5]!==t?(ve=async u=>{P(null);try{const C=await t.query(st,{},Ae(u));lt(u),x(C),v({}),M({}),N(null),me(y=>Object.fromEntries(Object.entries(y).filter(O=>{const[I]=O;return I!==u}))),G(y=>Object.fromEntries(Object.entries(y).filter(O=>{const[I]=O;return I!==u})))}catch(C){const y=C;x(null),P(Ee(y))}},e[5]=t,e[6]=ve):ve=e[6];const q=ve;let Q;e[7]!==t?(Q=async()=>{oe(null);try{ue(await t.listGlobalTables())}catch(u){const C=u;ue(null),oe(Ee(C))}},e[7]=t,e[8]=Q):Q=e[8];const ee=Q;let de,R;e[9]!==d||e[10]!==q||e[11]!==ee?(de=()=>{fe(q(d)),fe(ee())},R=[q,ee,d],e[9]=d,e[10]=q,e[11]=ee,e[12]=de,e[13]=R):(de=e[12],R=e[13]),Pe(de,R);let te;e[14]!==t||e[15]!==L||e[16]!==w||e[17]!==d?(te=async u=>{if(w===u){N(null);return}N(u);const C=`${d}:${u}`;if(L[C]!==void 0)return;const[y,O]=await Promise.allSettled([t.query(ot,{limit:1,offset:0,table:u},Ae(d)),t.query(rt,{table:u},Ae(d))]);y.status==="fulfilled"?v(I=>({...I,[C]:y.value.columns})):P(Ee(y.reason)),O.status==="fulfilled"&&M(I=>({...I,[C]:O.value.indexes}))},e[14]=t,e[15]=L,e[16]=w,e[17]=d,e[18]=te):te=e[18];const z=te;let ye;e[19]!==t||e[20]!==X||e[21]!==Y?(ye=async u=>{if(Y===u){ie(null);return}if(ie(u),X[u]===void 0)try{const C=await t.readGlobalTablePage({limit:1,offset:0,table:u});xe(y=>({...y,[u]:C.columns}))}catch(C){oe(Ee(C))}},e[19]=t,e[20]=X,e[21]=Y,e[22]=ye):ye=e[22];const ce=ye,he=et(void 0);let V,J;e[23]!==n||e[24]!==o||e[25]!==z?(V=()=>{n===void 0||o===null||he.current===n||o.some(u=>u.name===n)&&(he.current=n,fe(z(n)))},J=[n,o,z],e[23]=n,e[24]=o,e[25]=z,e[26]=V,e[27]=J):(V=e[26],J=e[27]),Pe(V,J);let B;e[28]!==t?(B=async(u,C,y)=>{const[O,I]=await Promise.all([Promise.allSettled([t.query(it,{tables:[...C,...y]},Ae(u))]),Promise.all(y.map(async T=>{const ge=await Promise.allSettled([t.readGlobalTablePage({limit:1,offset:0,table:T})]),ke=ge[0].status==="fulfilled"?ge[0].value:void 0;return{columns:ke?.columns??[],refs:ke?.refs??{},table:T}}))]),Te=O[0].status==="fulfilled"?O[0].value?.columnsByTable??{}:{},we=O[0].status==="rejected",Se=new Map(I.map(mt)),$e=[...C,...y].map(T=>{const ge=Te[T]??[];return[T,ge.length>0?ge:Se.get(T)??[]]});me(T=>({...T,[u]:Object.fromEntries($e)})),G(T=>({...T,[u]:we}))},e[28]=t,e[29]=B):B=e[29];const le=B;let U,ae;e[30]!==D||e[31]!==_||e[32]!==le||e[33]!==d||e[34]!==j||e[35]!==o||e[36]!==a?(U=()=>{a!=="graph"||o===null||_===null&&D===null||j[d]!==void 0||fe(le(d,o.map(ut),(_??[]).map(ht)))},ae=[a,o,_,D,d,j,le],e[30]=D,e[31]=_,e[32]=le,e[33]=d,e[34]=j,e[35]=o,e[36]=a,e[37]=U,e[38]=ae):(U=e[37],ae=e[38]),Pe(U,ae);const E=j[d]??dt;let ne;if(e[39]!==E||e[40]!==_||e[41]!==o){let u;e[43]!==E?(u=I=>({columns:E[I.name]??Be,name:I.name,tier:"shard"}),e[43]=E,e[44]=u):u=e[44];const C=(o??[]).map(u);let y;e[45]!==E?(y=I=>({columns:E[I.name]??Be,name:I.name,tier:"global"}),e[45]=E,e[46]=y):y=e[46];const O=(_??[]).map(y);ne=[...C,...O],e[39]=E,e[40]=_,e[41]=o,e[42]=ne}else ne=e[42];const se=ne;let b;if(e[47]!==r||e[48]!==o){const u=r.trim().toLowerCase();b=(o??[]).filter(C=>C.name.toLowerCase().includes(u)),e[47]=r,e[48]=o,e[49]=b}else b=e[49];const re=b;let W;if(e[50]!==_||e[51]!==r){const u=r.trim().toLowerCase();W=(_??[]).filter(C=>C.name.toLowerCase().includes(u)),e[50]=_,e[51]=r,e[52]=W}else W=e[52];const Ne=W;let pe;return e[53]!==L||e[54]!==se||e[55]!==p||e[56]!==w||e[57]!==Ne||e[58]!==re||e[59]!==X||e[60]!==D||e[61]!==Y||e[62]!==_||e[63]!==F||e[64]!==q||e[65]!==i||e[66]!==k||e[67]!==f||e[68]!==r||e[69]!==o||e[70]!==z||e[71]!==ce||e[72]!==a?(pe={columns:L,diagramTables:se,error:p,expanded:w,filteredGlobalTables:Ne,filteredTables:re,globalColumns:X,globalError:D,globalExpanded:Y,globalTables:_,indexes:F,refresh:q,setShardKey:i,setTableFilter:h,setView:c,shardColumnsError:k,shardKey:f,tableFilter:r,tables:o,toggle:z,toggleGlobal:ce,view:a},e[53]=L,e[54]=se,e[55]=p,e[56]=w,e[57]=Ne,e[58]=re,e[59]=X,e[60]=D,e[61]=Y,e[62]=_,e[63]=F,e[64]=q,e[65]=i,e[66]=k,e[67]=f,e[68]=r,e[69]=o,e[70]=z,e[71]=ce,e[72]=a,e[73]=pe):pe=e[73],pe};function mt(s){const{columns:e,refs:m,table:n}=s;return[n,e.map(t=>{const a=m[t];return a===void 0?{name:t,optional:!1,type:""}:{name:t,optional:!1,ref:a,type:"id"}})]}function ut(s){return s.name}function ht(s){return s.name}const pt="/__lunora/schema-edit",gt=async s=>{const e=await fetch(pt,{body:JSON.stringify(s),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),m=await e.json();return m.needsMigration===!0?{kind:"needs-migration",message:m.message??"This edit needs a migration."}:e.ok&&m.tables!==void 0?{diagnostics:m.diagnostics??[],kind:"ok",tables:m.tables}:{kind:"error",message:m.error??`schema edit failed (${String(e.status)})`}},bt=s=>{const e=Ce(32),{hasTables:m,mode:n,onAddColumn:t,onAddIndex:a,onAddTable:c,onDestructive:d}=s,i=je(),f=n==="addTable"?"default":"outline";let r;e[0]!==i?(r=i("Add table"),e[0]=i,e[1]=r):r=e[1];let h;e[2]!==c||e[3]!==f||e[4]!==r?(h=l(be,{"data-testid":"sc-editor-add-table",onClick:c,size:"xs",type:"button",variant:f,children:r}),e[2]=c,e[3]=f,e[4]=r,e[5]=h):h=e[5];const o=!m,x=n==="addColumn"?"default":"outline";let p;e[6]!==i?(p=i("Add column"),e[6]=i,e[7]=p):p=e[7];let P;e[8]!==t||e[9]!==o||e[10]!==x||e[11]!==p?(P=l(be,{"data-testid":"sc-editor-add-column",disabled:o,onClick:t,size:"xs",type:"button",variant:x,children:p}),e[8]=t,e[9]=o,e[10]=x,e[11]=p,e[12]=P):P=e[12];const S=!m,L=n==="addIndex"?"default":"outline";let v;e[13]!==i?(v=i("Add index"),e[13]=i,e[14]=v):v=e[14];let K;e[15]!==a||e[16]!==v||e[17]!==S||e[18]!==L?(K=l(be,{"data-testid":"sc-editor-add-index",disabled:S,onClick:a,size:"xs",type:"button",variant:L,children:v}),e[15]=a,e[16]=v,e[17]=S,e[18]=L,e[19]=K):K=e[19];const F=!m,M=n==="destructive"?"default":"ghost";let w;e[20]!==i?(w=i("Rename / drop / change type…"),e[20]=i,e[21]=w):w=e[21];let N;e[22]!==d||e[23]!==F||e[24]!==M||e[25]!==w?(N=l(be,{"data-testid":"sc-editor-destructive",disabled:F,onClick:d,size:"xs",type:"button",variant:M,children:w}),e[22]=d,e[23]=F,e[24]=M,e[25]=w,e[26]=N):N=e[26];let A;return e[27]!==K||e[28]!==N||e[29]!==h||e[30]!==P?(A=g("div",{className:"flex flex-wrap gap-2",children:[h,P,K,N]}),e[27]=K,e[28]=N,e[29]=h,e[30]=P,e[31]=A):A=e[31],A},ft=s=>{const e=Ce(28),{onOpenMigrations:m,result:n}=s,t=je();if(n===null){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=l(Ve,{}),e[0]=r):r=e[0],r}if(n.kind==="error"){let r;return e[1]!==n.message?(r=l("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:n.message}),e[1]=n.message,e[2]=r):r=e[2],r}if(n.kind==="needs-migration"){let r;e[3]!==n.message||e[4]!==t?(r=n.message===""?t("This edit changes stored data and must go through a migration. Review the migration before applying."):n.message,e[3]=n.message,e[4]=t,e[5]=r):r=e[5];let h;e[6]!==r?(h=l("p",{className:"text-sm text-warning",role:"alert",children:r}),e[6]=r,e[7]=h):h=e[7];let o;e[8]!==t?(o=t("Open Migrations"),e[8]=t,e[9]=o):o=e[9];let x;e[10]!==m||e[11]!==o?(x=l(be,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:m,size:"xs",type:"button",variant:"outline",children:o}),e[10]=m,e[11]=o,e[12]=x):x=e[12];let p;return e[13]!==h||e[14]!==x?(p=g("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[h,x]}),e[13]=h,e[14]=x,e[15]=p):p=e[15],p}if(n.diagnostics.length===0){let r;return e[16]===Symbol.for("react.memo_cache_sentinel")?(r=l(Ve,{}),e[16]=r):r=e[16],r}let a;e[17]!==t?(a=t("Codegen reported diagnostics:"),e[17]=t,e[18]=a):a=e[18];let c;e[19]!==a?(c=l("p",{className:"text-sm text-destructive",role:"alert",children:a}),e[19]=a,e[20]=c):c=e[20];let d;e[21]!==n.diagnostics?(d=n.diagnostics.map(xt),e[21]=n.diagnostics,e[22]=d):d=e[22];let i;e[23]!==d?(i=l("ul",{className:"flex flex-col gap-0.5",children:d}),e[23]=d,e[24]=i):i=e[24];let f;return e[25]!==c||e[26]!==i?(f=g("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[c,i]}),e[25]=c,e[26]=i,e[27]=f):f=e[27],f};function xt(s){return l("li",{className:"font-mono text-[11px] text-destructive",children:s},s)}const vt=[{label:"string",validator:"v.string()"},{label:"number",validator:"v.number()"},{label:"boolean",validator:"v.boolean()"},{label:"bigint",validator:"v.int64()"},{label:"bytes",validator:"v.bytes()"},{label:"any",validator:"v.any()"}],yt="v.string()",Nt=s=>s.split(",").map(e=>e.trim()).filter(e=>e!==""),Ct=s=>{const e=Ce(83),{onApplied:m,tableNames:n}=s,t=je(),a=nt(),[c,d]=$(null),[i,f]=$(!1),[r,h]=$(null),[o,x]=$(""),[p,P]=$(""),[S,L]=$(yt),[v,K]=$(n[0]??""),[F,M]=$(""),[w,N]=$(""),[A,j]=$(!1);let me;e[0]===Symbol.for("react.memo_cache_sentinel")?(me=()=>{d(null),x(""),P(""),M(""),N(""),j(!1)},e[0]=me):me=e[0];const Z=me;let k;e[1]!==m?(k=async T=>{f(!0),h(null);try{const ge=await gt(T);h(ge),ge.kind==="ok"&&(m(ge.tables),Z())}catch(ge){const ke=ge;h({kind:"error",message:ke instanceof Error?ke.message:String(ke)})}f(!1)},e[1]=m,e[2]=k):k=e[2];const G=k;let _;e[3]!==G||e[4]!==o?(_=()=>{fe(G({kind:"addTable",table:o.trim()}))},e[3]=G,e[4]=o,e[5]=_):_=e[5];const ue=_;let D;e[6]!==p||e[7]!==G||e[8]!==v||e[9]!==S?(D=()=>{fe(G({column:p.trim(),kind:"addOptionalColumn",table:v,validator:S}))},e[6]=p,e[7]=G,e[8]=v,e[9]=S,e[10]=D):D=e[10];const oe=D;let H;e[11]!==w||e[12]!==F||e[13]!==G||e[14]!==v||e[15]!==A?(H=()=>{fe(G({fields:Nt(w),kind:"addIndex",name:F.trim(),table:v,unique:A}))},e[11]=w,e[12]=F,e[13]=G,e[14]=v,e[15]=A,e[16]=H):H=e[16];const X=H;let xe;e[17]===Symbol.for("react.memo_cache_sentinel")?(xe=()=>{h(null),d("addTable")},e[17]=xe):xe=e[17];const Y=xe;let ie;e[18]===Symbol.for("react.memo_cache_sentinel")?(ie=()=>{h(null),d("addColumn")},e[18]=ie):ie=e[18];const ve=ie;let q;e[19]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{h(null),d("addIndex")},e[19]=q):q=e[19];const Q=q;let ee;e[20]!==t?(ee=()=>{d("destructive"),h({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},e[20]=t,e[21]=ee):ee=e[21];const de=ee;let R;e[22]===Symbol.for("react.memo_cache_sentinel")?(R=T=>{x(T.target.value)},e[22]=R):R=e[22];const te=R;let z;e[23]===Symbol.for("react.memo_cache_sentinel")?(z=T=>{P(T.target.value)},e[23]=z):z=e[23];const ye=z;let ce;e[24]===Symbol.for("react.memo_cache_sentinel")?(ce=T=>{L(T.target.value)},e[24]=ce):ce=e[24];const he=ce;let V;e[25]===Symbol.for("react.memo_cache_sentinel")?(V=T=>{K(T.target.value)},e[25]=V):V=e[25];const J=V;let B;e[26]===Symbol.for("react.memo_cache_sentinel")?(B=T=>{M(T.target.value)},e[26]=B):B=e[26];const le=B;let U;e[27]===Symbol.for("react.memo_cache_sentinel")?(U=T=>{N(T.target.value)},e[27]=U):U=e[27];const ae=U;let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=T=>{j(T.target.checked)},e[28]=E):E=e[28];const ne=E;let se;e[29]!==a?(se=()=>{fe(a({to:"/migrations"}))},e[29]=a,e[30]=se):se=e[30];const b=se;let re;e[31]!==t?(re=t("Edit schema"),e[31]=t,e[32]=re):re=e[32];let W;e[33]!==re?(W=l(Ke,{children:re}),e[33]=re,e[34]=W):W=e[34];let Ne;e[35]!==t?(Ne=t("Adds a table, column, or index to lunora/schema.ts and reruns codegen."),e[35]=t,e[36]=Ne):Ne=e[36];let pe;e[37]!==Ne?(pe=l(Ge,{children:Ne}),e[37]=Ne,e[38]=pe):pe=e[38];let u;e[39]!==W||e[40]!==pe?(u=g(Le,{children:[W,pe]}),e[39]=W,e[40]=pe,e[41]=u):u=e[41];const C=n.length>0;let y;e[42]!==c||e[43]!==de||e[44]!==C?(y=l(bt,{hasTables:C,mode:c,onAddColumn:ve,onAddIndex:Q,onAddTable:Y,onDestructive:de}),e[42]=c,e[43]=de,e[44]=C,e[45]=y):y=e[45];let O;e[46]!==i||e[47]!==c||e[48]!==ue||e[49]!==t||e[50]!==o?(O=c==="addTable"&&g("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-table-name",children:t("Table name")}),l(Ie,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:te,value:o})]}),l(be,{"data-testid":"sc-editor-table-apply",disabled:i||o.trim()==="",onClick:ue,size:"xs",type:"button",children:t(i?"Applying…":"Apply")}),l(be,{onClick:Z,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[46]=i,e[47]=c,e[48]=ue,e[49]=t,e[50]=o,e[51]=O):O=e[51];let I;e[52]!==i||e[53]!==p||e[54]!==c||e[55]!==oe||e[56]!==t||e[57]!==n||e[58]!==v||e[59]!==S?(I=c==="addColumn"&&g("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-table",id:"sc-editor-column-table",onChange:J,value:v,children:n.map(Tt)})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-name",children:t("Column name")}),l(Ie,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:ye,value:p})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-column-type",children:t("Column type")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-column-type",id:"sc-editor-column-type",onChange:he,value:S,children:vt.map(wt)})]}),l("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),l(be,{"data-testid":"sc-editor-column-apply",disabled:i||p.trim()===""||v==="",onClick:oe,size:"xs",type:"button",children:t(i?"Applying…":"Apply")}),l(be,{onClick:Z,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[52]=i,e[53]=p,e[54]=c,e[55]=oe,e[56]=t,e[57]=n,e[58]=v,e[59]=S,e[60]=I):I=e[60];let Te;e[61]!==i||e[62]!==w||e[63]!==F||e[64]!==c||e[65]!==X||e[66]!==t||e[67]!==n||e[68]!==v||e[69]!==A?(Te=c==="addIndex"&&g("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-table",children:t("Table name")}),l("select",{className:"h-8 rounded-md border border-input bg-transparent px-2 text-xs","data-testid":"sc-editor-index-table",id:"sc-editor-index-table",onChange:J,value:v,children:n.map(St)})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-name",children:t("Index name")}),l(Ie,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:le,value:F})]}),g("div",{className:"flex flex-col gap-1 text-xs",children:[l(_e,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),l(Ie,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:ae,value:w})]}),g(_e,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[l("input",{checked:A,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:ne,type:"checkbox"}),l("span",{className:"text-muted-foreground",children:t("Unique")})]}),l(be,{"data-testid":"sc-editor-index-apply",disabled:i||F.trim()===""||w.trim()==="",onClick:X,size:"xs",type:"button",children:t(i?"Applying…":"Apply")}),l(be,{onClick:Z,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[61]=i,e[62]=w,e[63]=F,e[64]=c,e[65]=X,e[66]=t,e[67]=n,e[68]=v,e[69]=A,e[70]=Te):Te=e[70];let we;e[71]!==b||e[72]!==r?(we=l(ft,{onOpenMigrations:b,result:r}),e[71]=b,e[72]=r,e[73]=we):we=e[73];let Se;e[74]!==y||e[75]!==O||e[76]!==I||e[77]!==Te||e[78]!==we?(Se=g(Me,{children:[y,O,I,Te,we]}),e[74]=y,e[75]=O,e[76]=I,e[77]=Te,e[78]=we,e[79]=Se):Se=e[79];let $e;return e[80]!==u||e[81]!==Se?($e=g(De,{"data-testid":"sc-editor",size:"sm",children:[u,Se]}),e[80]=u,e[81]=Se,e[82]=$e):$e=e[82],$e};function Tt(s){return l("option",{value:s,children:s},s)}function wt(s){return l("option",{value:s.validator,children:s.label},s.validator)}function St(s){return l("option",{value:s,children:s},s)}const Ue=[],_t=s=>{const e=Ce(5),{open:m}=s,n=m&&"rotate-90";let t;e[0]!==n?(t=We("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",n),e[0]=n,e[1]=t):t=e[1];let a;e[2]===Symbol.for("react.memo_cache_sentinel")?(a=l("path",{d:"m9 6 6 6-6 6"}),e[2]=a):a=e[2];let c;return e[3]!==t?(c=l("svg",{"aria-hidden":"true",className:t,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:a}),e[3]=t,e[4]=c):c=e[4],c},Xe=s=>{const e=Ce(20),{children:m,expanded:n,name:t,onToggle:a,rowCount:c,rowTestId:d,toggleTestId:i}=s;let f;e[0]!==n?(f=l(_t,{open:n}),e[0]=n,e[1]=f):f=e[1];let r;e[2]!==t?(r=l("span",{className:"truncate font-mono text-xs text-foreground",title:t,children:t}),e[2]=t,e[3]=r):r=e[3];let h;e[4]!==c?(h=g("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",c,")"]}),e[4]=c,e[5]=h):h=e[5];let o;e[6]!==n||e[7]!==a||e[8]!==f||e[9]!==r||e[10]!==h||e[11]!==i?(o=g("button",{"aria-expanded":n,className:"flex w-full items-center gap-2 px-3 py-2 text-start transition-colors hover:bg-muted/50 aria-expanded:bg-muted/40","data-testid":i,onClick:a,type:"button",children:[f,r," ",h]}),e[6]=n,e[7]=a,e[8]=f,e[9]=r,e[10]=h,e[11]=i,e[12]=o):o=e[12];let x;e[13]!==m||e[14]!==n?(x=n&&l("div",{className:"px-3 pb-3 ps-8",children:m}),e[13]=m,e[14]=n,e[15]=x):x=e[15];let p;return e[16]!==d||e[17]!==o||e[18]!==x?(p=g("li",{className:"border-t border-border/60 first:border-t-0","data-testid":d,children:[o,x]}),e[16]=d,e[17]=o,e[18]=x,e[19]=p):p=e[19],p},Ye=s=>{const e=Ce(5),{columns:m,testId:n}=s;let t;e[0]!==m?(t=m.map(kt),e[0]=m,e[1]=t):t=e[1];let a;return e[2]!==t||e[3]!==n?(a=l("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":n,children:t}),e[2]=t,e[3]=n,e[4]=a):a=e[4],a},$t=s=>{const e=Ce(10),{heading:m,indexes:n,testId:t}=s;let a;e[0]!==m?(a=l("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:m}),e[0]=m,e[1]=a):a=e[1];let c;e[2]!==n?(c=n.map(It),e[2]=n,e[3]=c):c=e[3];let d;e[4]!==c||e[5]!==t?(d=l("ul",{className:"flex flex-col gap-1","data-testid":t,children:c}),e[4]=c,e[5]=t,e[6]=d):d=e[6];let i;return e[7]!==a||e[8]!==d?(i=g("div",{className:"pt-3",children:[a,d]}),e[7]=a,e[8]=d,e[9]=i):i=e[9],i},Je=s=>We("border-b-2 px-3 py-2 font-mono text-[11px] tracking-widest uppercase outline-none transition-colors",s?"border-foreground text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),Zt=s=>{const e=Ce(85),{initialShardKey:m,initialTable:n,schemaEditable:t}=s,a=je();let c;e[0]!==m||e[1]!==n?(c={initialShardKey:m,initialTable:n},e[0]=m,e[1]=n,e[2]=c):c=e[2];const{columns:d,diagramTables:i,error:f,expanded:r,filteredGlobalTables:h,filteredTables:o,globalColumns:x,globalError:p,globalExpanded:P,globalTables:S,indexes:L,refresh:v,setShardKey:K,setTableFilter:F,setView:M,shardColumnsError:w,shardKey:N,tableFilter:A,tables:j,toggle:me,toggleGlobal:Z,view:k}=ct(c);let G;e[3]!==M?(G=()=>{M("list")},e[3]=M,e[4]=G):G=e[4];const _=G;let ue;e[5]!==M?(ue=()=>{M("graph")},e[5]=M,e[6]=ue):ue=e[6];const D=ue;let oe;e[7]!==F?(oe=b=>{F(b.target.value)},e[7]=F,e[8]=oe):oe=e[8];const H=oe;let X;e[9]!==v||e[10]!==N?(X=b=>{fe(v(N))},e[9]=v,e[10]=N,e[11]=X):X=e[11];const xe=X;let Y;e[12]!==j?(Y=j??[],e[12]=j,e[13]=Y):Y=e[13];let ie;e[14]!==Y?(ie=Y.map(At),e[14]=Y,e[15]=ie):ie=e[15];const ve=ie;let q;e[16]!==K||e[17]!==N?(q=l(Ze,{onChange:K,testId:"sc-shard-input",value:N}),e[16]=K,e[17]=N,e[18]=q):q=e[18];let Q;e[19]!==a?(Q=a("Schema view"),e[19]=a,e[20]=Q):Q=e[20];const ee=k==="graph",de=k==="graph";let R;e[21]!==de?(R=Je(de),e[21]=de,e[22]=R):R=e[22];let te;e[23]!==a?(te=a("Graph"),e[23]=a,e[24]=te):te=e[24];let z;e[25]!==D||e[26]!==ee||e[27]!==R||e[28]!==te?(z=l("button",{"aria-selected":ee,className:R,"data-testid":"sc-view-graph",onClick:D,role:"tab",type:"button",children:te}),e[25]=D,e[26]=ee,e[27]=R,e[28]=te,e[29]=z):z=e[29];const ye=k==="list",ce=k==="list";let he;e[30]!==ce?(he=Je(ce),e[30]=ce,e[31]=he):he=e[31];let V;e[32]!==a?(V=a("Table list"),e[32]=a,e[33]=V):V=e[33];let J;e[34]!==_||e[35]!==ye||e[36]!==he||e[37]!==V?(J=l("button",{"aria-selected":ye,className:he,"data-testid":"sc-view-list",onClick:_,role:"tab",type:"button",children:V}),e[34]=_,e[35]=ye,e[36]=he,e[37]=V,e[38]=J):J=e[38];let B;e[39]!==z||e[40]!==J||e[41]!==Q?(B=g("div",{"aria-label":Q,className:"flex items-center gap-1","data-testid":"sc-view-toggle",role:"tablist",children:[z,J]}),e[39]=z,e[40]=J,e[41]=Q,e[42]=B):B=e[42];let le;e[43]!==B||e[44]!==q?(le=g("div",{className:"flex flex-wrap items-center gap-3",children:[q,B]}),e[43]=B,e[44]=q,e[45]=le):le=e[45];let U;e[46]!==xe||e[47]!==t||e[48]!==ve?(U=t===!0&&l(Ct,{onApplied:xe,tableNames:ve}),e[46]=xe,e[47]=t,e[48]=ve,e[49]=U):U=e[49];let ae;e[50]!==H||e[51]!==a||e[52]!==A||e[53]!==k?(ae=k==="list"&&l(Ie,{"aria-label":a("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:H,placeholder:a("Filter tables"),value:A}),e[50]=H,e[51]=a,e[52]=A,e[53]=k,e[54]=ae):ae=e[54];let E;e[55]!==i||e[56]!==f||e[57]!==p||e[58]!==w||e[59]!==N||e[60]!==k?(E=k==="graph"&&g("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:f}),p!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),l(at,{columnsError:w[N]===!0,tables:i,testIdPrefix:"sc-graph"})]}),e[55]=i,e[56]=f,e[57]=p,e[58]=w,e[59]=N,e[60]=k,e[61]=E):E=e[61];let ne;e[62]!==d||e[63]!==f||e[64]!==r||e[65]!==h||e[66]!==o||e[67]!==x||e[68]!==p||e[69]!==P||e[70]!==S||e[71]!==L||e[72]!==N||e[73]!==a||e[74]!==j||e[75]!==me||e[76]!==Z||e[77]!==k?(ne=k==="list"&&g("div",{className:"flex flex-col gap-4",children:[g(De,{"data-testid":"sc-shard-section",size:"sm",children:[g(Le,{children:[g("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"shard"}),l(Ke,{children:a("Shard tables")}),j!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:o.length})]}),l(Ge,{children:Oe.shard.hint})]}),g(Me,{children:[f!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:f}),j!==null&&j.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:a("No tables in this shard.")}),j!==null&&j.length>0&&o.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:a("No tables match your filter.")}),o.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:o.map(b=>{const re=`${N}:${b.name}`,W=L[re]??[];return g(Xe,{expanded:r===b.name,name:b.name,onToggle:()=>{fe(me(b.name))},rowCount:b.rowCount,rowTestId:`sc-table-${b.name}`,toggleTestId:`sc-toggle-${b.name}`,children:[l(Ye,{columns:d[re]??Ue,testId:`sc-columns-${b.name}`}),W.length>0&&l($t,{heading:a("Indexes"),indexes:W,testId:`sc-indexes-${b.name}`})]},b.name)})})]})]}),g(De,{"data-testid":"sc-global-section",size:"sm",children:[g(Le,{children:[g("div",{className:"flex items-center gap-2",children:[l(Re,{tier:"global"}),l(Ke,{children:a("Global tables (D1)")}),S!==null&&l(Fe,{className:"ms-auto tabular-nums",variant:"outline",children:h.length})]}),l(Ge,{children:Oe.global.hint})]}),g(Me,{children:[p!==null&&l("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:p}),S!==null&&S.length===0&&l(He,{description:Oe.global.hint,testId:"sc-global-empty",title:a("No global tables.")}),S!==null&&S.length>0&&h.length===0&&l("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:a("No tables match your filter.")}),h.length>0&&l("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:h.map(b=>l(Xe,{expanded:P===b.name,name:b.name,onToggle:()=>{fe(Z(b.name))},rowCount:b.rowCount,rowTestId:`sc-global-table-${b.name}`,toggleTestId:`sc-global-toggle-${b.name}`,children:l(Ye,{columns:x[b.name]??Ue,testId:`sc-global-columns-${b.name}`})},b.name))})]})]})]}),e[62]=d,e[63]=f,e[64]=r,e[65]=h,e[66]=o,e[67]=x,e[68]=p,e[69]=P,e[70]=S,e[71]=L,e[72]=N,e[73]=a,e[74]=j,e[75]=me,e[76]=Z,e[77]=k,e[78]=ne):ne=e[78];let se;return e[79]!==le||e[80]!==U||e[81]!==ae||e[82]!==E||e[83]!==ne?(se=g("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[le,U,ae,E,ne]}),e[79]=le,e[80]=U,e[81]=ae,e[82]=E,e[83]=ne,e[84]=se):se=e[84],se};function kt(s){return l("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:s},s)}function It(s){return g("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[l("span",{className:"font-mono",children:s.name}),l(Fe,{variant:"outline",children:s.type}),s.unique===!0&&l(Fe,{variant:"secondary",children:"unique"}),l("span",{className:"text-muted-foreground",children:s.fields.join(", ")})]},`${s.type}:${s.name}`)}function At(s){return s.name}export{Zt as SchemaViewer};
@@ -0,0 +1 @@
1
+ import{c as u}from"react/compiler-runtime";import{N as m}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as f}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{A as g}from"../packem_shared/advisor-view-Pa8HLtBv.js";import{jsx as p}from"react/jsx-runtime";const R=(e,s)=>({"admin-token-weak":e("Weak admin token"),"auth-secret-weak":e("Weak auth secret"),"cookies-insecure":e("Session cookies are not Secure"),"cors-wildcard-credentials":e("Wildcard CORS with credentials"),"csrf-disabled":e("CSRF/origin guard is off"),"dev-args-unredacted":e("Request log keeps un-redacted args"),"security-headers-disabled":e("Security headers are off"),"ws-gate-open":e("Live admin subscriptions are ungated")})[s.kind],k=e=>Array.isArray(e.findings)?e.findings:[],S=e=>({"admin-token-weak":"LUNORA_ADMIN_TOKEN","auth-secret-weak":"AUTH_SECRET","cookies-insecure":"BETTER_AUTH_URL","cors-wildcard-credentials":"LUNORA_ALLOWED_ORIGINS","csrf-disabled":"LUNORA_SECURITY_CSRF","dev-args-unredacted":"request log","security-headers-disabled":"LUNORA_SECURITY_HEADERS","ws-gate-open":"LUNORA_WS_BEARER"})[e.kind],A=(e,s)=>({"admin-token-weak":e("Your admin token is {length} characters — use at least {min} for a brute-force-resistant secret.",{length:s.detail?.length,min:s.detail?.min}),"auth-secret-weak":e("Your auth secret is {length} characters — use at least {min} (e.g. `openssl rand -hex 32`) to sign sessions safely.",{length:s.detail?.length,min:s.detail?.min}),"cookies-insecure":e("BETTER_AUTH_URL is a plaintext http:// origin, so session cookies cannot be Secure and ride in cleartext. Serve auth over https:// in production."),"cors-wildcard-credentials":e("LUNORA_ALLOWED_ORIGINS includes a wildcard while credentials are allowed — browsers reject this and it defeats the allowlist. Name explicit origins instead of *."),"csrf-disabled":e("LUNORA_SECURITY_CSRF is off, so cross-origin state-changing cookie requests are not blocked. Re-enable it in production to keep mutations un-forgeable."),"dev-args-unredacted":e("This worker reports a development environment, so the request log stores raw args and identity. Confirm it isn't a mislabeled production deploy."),"security-headers-disabled":e("LUNORA_SECURITY_HEADERS is off, so HSTS, CSP, nosniff, and frame-options are not applied. Re-enable the baseline headers in production."),"ws-gate-open":e("LUNORA_WS_BEARER is unset, so the WebSocket upgrade gate is open: live admin subscriptions need no credential. Set it to gate them like the HTTP admin RPCs.")})[s.kind],N=()=>{const e=u(8),s=h();let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t={},e[0]=t):t=e[0];const{data:i,error:n,errorSource:d}=m(f.getSecurityAudit,t);let a;if(e[1]!==i||e[2]!==s){const l=i===void 0?null:k(i);a=l===null?null:l.map(r=>({description:A(s,r),entity:S(r),issueType:R(s,r),key:r.kind,level:r.level})),e[1]=i,e[2]=s,e[3]=a}else a=e[3];const c=a;let o;return e[4]!==n||e[5]!==d||e[6]!==c?(o=p(g,{error:n,errorSource:d,rows:c,testId:"lunora-security-advisor"}),e[4]=n,e[5]=d,e[6]=c,e[7]=o):o=e[7],o};export{N as default};
@@ -0,0 +1 @@
1
+ import{c as O}from"react/compiler-runtime";import{E as A}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as K}from"../packem_shared/badge-BbuuAio7.js";import{c as D,u as I}from"../packem_shared/card-CIDGUN6K.js";import{n as j,d as F,m as L,p as T,f as V,u as U}from"../packem_shared/table-DdJBrClo.js";import{N as W}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as q}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as z}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{C as M}from"../packem_shared/cf-links-Dmg86v1D.js";import{jsx as t,jsxs as m}from"react/jsx-runtime";const P={binding:"outline",secret:"destructive",var:"secondary"},B=(r,e)=>{if(r===void 0)return[];const c=[];return r.workerUrl!==void 0&&c.push({label:e("URL"),value:r.workerUrl}),r.environment!==void 0&&c.push({label:e("Environment"),value:r.environment}),r.deploymentId!==void 0&&c.push({label:e("Deployment"),value:r.deploymentId}),r.versionTag!==void 0&&c.push({label:e("Version"),value:r.versionTag}),c},le=r=>{const e=O(52),{initialShardKey:c}=r,n=q();let w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];const _=c??"";let $;e[1]!==_?($={shardKey:_},e[1]=_,e[2]=$):$=e[2];const{data:l,error:s,errorSource:k,isLoading:R}=W(z.getSettings,w,$);let a,p,u,d,o,i,h;if(e[3]!==s||e[4]!==k||e[5]!==l?.deploy||e[6]!==l?.settings||e[7]!==n){const C=B(l?.deploy,n);let S;e[15]!==l?.settings?(S=l?.settings??[],e[15]=l?.settings,e[16]=S):S=e[16],a=S,p="flex flex-col gap-4",u="lunora-settings";let N;e[17]!==n?(N=n("Open in Cloudflare"),e[17]=n,e[18]=N):N=e[18],e[19]!==N?(d=t("div",{className:"flex flex-wrap items-center gap-3",children:t("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:M,rel:"noreferrer",target:"_blank",children:N})}),e[19]=N,e[20]=d):d=e[20];let b;e[21]!==n?(b=n("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[21]=n,e[22]=b):b=e[22],e[23]!==b?(o=t("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:b}),e[23]=b,e[24]=o):o=e[24],e[25]!==s||e[26]!==k?(i=s!==null&&t(A,{error:k,testId:"set-error"}),e[25]=s,e[26]=k,e[27]=i):i=e[27],h=C.length>0&&m(D,{className:"py-0","data-testid":"set-deploy",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:n("Deployment")})}),t(I,{className:"py-3",children:t("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:C.map(G)})})]}),e[3]=s,e[4]=k,e[5]=l?.deploy,e[6]=l?.settings,e[7]=n,e[8]=a,e[9]=p,e[10]=u,e[11]=d,e[12]=o,e[13]=i,e[14]=h}else a=e[8],p=e[9],u=e[10],d=e[11],o=e[12],i=e[13],h=e[14];let f;e[28]!==n?(f=n("Environment & bindings"),e[28]=n,e[29]=f):f=e[29];let g;e[30]!==f?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:f})}),e[30]=f,e[31]=g):g=e[31];let x;e[32]!==s||e[33]!==R||e[34]!==a.length||e[35]!==n?(x=s===null&&!R&&a.length===0&&t("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:n("No environment variables or bindings.")}),e[32]=s,e[33]=R,e[34]=a.length,e[35]=n,e[36]=x):x=e[36];let v;e[37]!==a||e[38]!==n?(v=a.length>0&&t(I,{className:"px-0 py-0",children:m(j,{"data-testid":"set-table",children:[t(F,{children:m(L,{children:[t(T,{children:n("name")}),t(T,{children:n("kind")}),t(T,{children:n("value")})]})}),t(V,{children:a.map(H)})]})}),e[37]=a,e[38]=n,e[39]=v):v=e[39];let y;e[40]!==g||e[41]!==x||e[42]!==v?(y=m(D,{className:"py-0",children:[g,x,v]}),e[40]=g,e[41]=x,e[42]=v,e[43]=y):y=e[43];let E;return e[44]!==y||e[45]!==p||e[46]!==u||e[47]!==d||e[48]!==o||e[49]!==i||e[50]!==h?(E=m("div",{className:p,"data-testid":u,children:[d,o,i,h,y]}),e[44]=y,e[45]=p,e[46]=u,e[47]=d,e[48]=o,e[49]=i,e[50]=h,e[51]=E):E=e[51],E};function G(r){return m("div",{className:"contents","data-testid":"set-deploy-row",children:[t("dt",{className:"text-muted-foreground",children:r.label}),t("dd",{className:"truncate font-mono text-xs",title:r.value,children:r.value})]},r.label)}function H(r){return m(L,{"data-testid":"set-row",children:[t(U,{className:"font-mono text-xs font-medium",children:r.name}),t(U,{children:t(K,{variant:P[r.kind],children:r.bindingType??r.kind})}),t(U,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:r.value??t("span",{className:"text-muted-foreground",children:"—"})})]},r.name)}export{le as SettingsPanel};
@@ -0,0 +1,6 @@
1
+ import{c as K}from"react/compiler-runtime";import{useLunora as Oe}from"@lunora/react";import{useState as re,useMemo as Be,useCallback as Ze,useEffect as qe,useRef as ye,useId as et}from"react";import{ADMIN_FUNCTIONS as $e}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{u as _e,n as je,b as We}from"../packem_shared/browser-storage-xjTyMKY0.js";import{d as ke,f as de,g as Te,b as ze}from"../packem_shared/internal-BSIsQVC6.js";import{r as tt}from"../packem_shared/shard-history-DMEW5VBE.js";import{k as nt}from"../packem_shared/use-sql-assistant-C6dl2_Ty.js";import ot from"../packem_shared/useDebounced-CU-uftxO.js";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{c as ue}from"../packem_shared/utils-bhneXptQ.js";import{jsx as u,jsxs as A,Fragment as Ee}from"react/jsx-runtime";import{u as rt}from"../packem_shared/input-JHu63lTv.js";import{I as lt}from"../packem_shared/result-chart-DzJOVsaw.js";import{ShardInput as st}from"../packem_shared/ShardInput-BVn2iCU0.js";import{A as at}from"../packem_shared/alert-CVcOFuDR.js";import{K as it}from"../packem_shared/grid-features-jnrD0SpX.js";import{d as ct,m as He,f as dt,n as ut,p as mt,u as ft}from"../packem_shared/table-DdJBrClo.js";import{g as ht}from"../packem_shared/data-grid-DcxyIXwG.js";const pt=["ORDER BY","GROUP BY","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN","EXPLAIN QUERY PLAN","SELECT","DISTINCT","FROM","WHERE","HAVING","LIMIT","OFFSET","JOIN","ON","AND","OR","AS","ASC","DESC","WITH","UNION","EXPLAIN"],bt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],Ce=String.fromCodePoint(0),gt=new RegExp(`${Ce}${String.raw`(\d+)`}${Ce}`,"gu"),xt=pt.map(l=>({pattern:new RegExp(String.raw`\b${l.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:l})),vt=bt.map(l=>({pattern:new RegExp(String.raw`\s+${l.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
2
+ ${l}`})),yt=l=>{const e=[];let t=l.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${Ce}${(e.length-1).toString()}${Ce}`)).replaceAll(/\s+/gu," ").trim();for(const{pattern:n,replacement:r}of xt)t=t.replaceAll(n,r);for(const{pattern:n,replacement:r}of vt)t=t.replaceAll(n,r);return t=t.replaceAll(gt,(n,r)=>e[Number(r)]??""),t},wt=/^(?:explain\s+(?:query\s+plan\s+)?)?(?:select|with)\b/iu,St=/\b(?:alter|attach|create|delete|detach|drop|insert|pragma|reindex|replace|truncate|update|vacuum)\b/iu,Nt=/^\w+/u,kt=/;\s*$/u,Ct=/\s/u,qt=(l,e)=>{let t=e+2;for(;t<l.length&&l[t]!==`
3
+ `;)t+=1;return t},$t=(l,e)=>{const t=l.indexOf("*/",e+2);return t===-1?-1:t+2},Tt=l=>{let e=0;for(;e<l.length;){const t=l[e];if(t!==void 0&&Ct.test(t))e+=1;else if(t==="-"&&l[e+1]==="-")e=qt(l,e);else if(t==="/"&&l[e+1]==="*"){const n=$t(l,e);if(n===-1)break;e=n}else break}return e},Rt=l=>{const e=Tt(l),t=l.slice(e).trimEnd();if(t==="")return{code:"SQL_EMPTY",message:"the query is empty"};const n=t.replace(kt,""),r=n.indexOf(";");if(r!==-1)return{code:"SQL_MULTIPLE_STATEMENTS",length:1,message:"only a single statement may be run",offset:e+r};const o="the SQL editor is read-only — only SELECT / WITH / EXPLAIN queries are allowed";if(!wt.test(n))return{code:"SQL_NOT_READONLY",length:Nt.exec(n)?.[0].length??1,message:o,offset:e};const s=St.exec(n);if(s!==null)return{code:"SQL_NOT_READONLY",length:s[0].length,message:`${o} (\`${s[0].toUpperCase()}\` is not allowed)`,offset:e+s.index}},It=/\b(?:from|join)\s+([a-z_][\w$]*)(?:\s+(?:as\s+)?([a-z_][\w$]*))?/giu,Et=/(?:\bwith\s+(?:recursive\s+)?|,\s*)([a-z_][\w$]*)\s+as\s*\(/giu,Lt=new Set(["cross","full","group","having","inner","join","left","limit","offset","on","order","right","union","using","where","window"]),_t=/[^\n]/gu,Ot=(l,e)=>{const t=l[e];if(t==="'"){let n=e+1;for(;n<l.length&&l[n]!=="'";)n+=1;return Math.min(n+1,l.length)}if(t==="-"&&l[e+1]==="-"){const n=l.indexOf(`
4
+ `,e);return n===-1?l.length:n}if(t==="/"&&l[e+1]==="*"){const n=l.indexOf("*/",e+2);return n===-1?l.length:n+2}return-1},Mt=l=>{let e="",t=0;for(;t<l.length;){const n=Ot(l,t);n===-1?(e+=l.slice(t,t+1),t+=1):(e+=l.slice(t,n).replaceAll(_t," "),t=n)}return e},Dt=l=>{const e=new Set;for(const t of l.matchAll(Et))e.add((t[1]??"").toLowerCase());return e},At=(l,e)=>{const t=new Map;for(const n of l.matchAll(It)){const r=(n[1]??"").toLowerCase(),o=(n[2]??"").toLowerCase();e.has(r)&&(t.set(r,r),o!==""&&!Lt.has(o)&&t.set(o,r))}return t},Ke=(l,e)=>{const t=Mt(l),n=new Set(e.map(r=>r.toLowerCase()));return{ctes:Dt(t),masked:t,targets:At(t,n)}},Bt=/^(?:__lunora|sqlite_)/iu,zt=/\b(?:from|join)\s+([a-z_][\w$]*)/giu,Ht=/\b([a-z_][\w$]*)\.([a-z_][\w$]*)/giu,Pt=new Set(["cross","full","group","having","inner","join","lateral","left","limit","offset","order","right","select","union","where","window"]),Ft=(l,e,t)=>{const n=[];for(const r of l.matchAll(zt)){const o=r[1]??"",s=o.toLowerCase();!e.has(s)&&!t.has(s)&&!Pt.has(s)&&!Bt.test(o)&&n.push({length:o.length,message:`unknown table \`${o}\``,offset:r.index+r[0].length-o.length,severity:"error",source:"schema"})}return n},Qt=(l,e,t)=>{const n=[],r=new Map;for(const[o,s]of Object.entries(e.columns))r.set(o.toLowerCase(),new Set(s.map(d=>d.toLowerCase())));for(const o of l.matchAll(Ht)){const s=(o[1]??"").toLowerCase(),d=o[2]??"",a=t.get(s),i=a===void 0?void 0:r.get(a);i!==void 0&&!i.has(d.toLowerCase())&&n.push({length:d.length,message:`\`${a??""}\` has no column \`${d}\``,offset:o.index+o[0].length-d.length,severity:"error",source:"schema"})}return n},jt=(l,e)=>{if(l.trim()==="")return[];const t=Rt(l);if(t!==void 0)return t.code==="SQL_EMPTY"?[]:[{length:t.length,message:t.message,offset:t.offset,severity:"error",source:"gate"}];const{ctes:n,masked:r,targets:o}=Ke(l,e.tables),s=new Set(e.tables.map(d=>d.toLowerCase()));return[...Ft(r,s,n),...Qt(r,e,o)]},Wt=Te($e.lintSql),Kt=600,Ut=(l,e,t)=>{const n=Oe(),[r,o]=re([]),s=Be(()=>jt(l,e),[l,e]),d=ot(l,Kt),a=s.some(h=>h.source==="gate")||d.trim()==="",i=Ze(async h=>{try{const p=await n.query(Wt,{sql:d},ke(t));h.cancelled||o(p.diagnostics??[])}catch{h.cancelled||o([])}},[n,d,t]);qe(()=>{if(a){o([]);return}const h={cancelled:!1};return de(i(h)),()=>{h.cancelled=!0}},[i,a]);const f=d===l;return Be(()=>f?[...s,...r]:s,[s,r,f])},Se=8,Yt=["AND","ASC","AS","BY","COUNT","DESC","DISTINCT","EXPLAIN","FROM","GROUP","HAVING","INNER","JOIN","LEFT","LIKE","LIMIT","NOT","NULL","OFFSET","ON","ORDER","OR","QUERY","SELECT","WHERE","WITH"],Jt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),Gt=/[\w$]/,Ue=l=>l!==void 0&&Gt.test(l),Ye=l=>{let e=l.length;for(;e>0&&Ue(l[e-1]);)e-=1;return l.slice(e)},Je=(l,e)=>{let t=e;for(;t>0&&Ue(l[t-1]);)t-=1;return{end:e,start:t,text:l.slice(t,e)}},Pe=(l,e)=>{const t=l.slice(0,e).trimEnd();return t.endsWith(".")||Jt.has(Ye(t).toUpperCase())},Vt=(l,e,t)=>{const n=l.slice(0,e);if(!n.endsWith("."))return;const r=Ye(n.slice(0,-1));if(r!=="")return Ke(l,t).targets.get(r.toLowerCase())??r},Me=(l,e)=>l.toLowerCase().startsWith(e.toLowerCase()),Fe=(l,e,t,n)=>{const r=[];for(const o of l)if(Me(o,e)&&(r.push(n(o)),r.length>=t))break;return r},Xt=(l,e,t)=>{const n=new Map;for(const[r,o]of Object.entries(l.columns))for(const s of o)if(Me(s,e)&&!n.has(s)&&(n.set(s,r),n.size>=t))return[...n].map(([d,a])=>({detail:a,kind:"column",label:d}));return[...n].map(([r,o])=>({detail:o,kind:"column",label:r}))},Zt=(l,e,t)=>{const n=Je(l,e),r=Vt(l,n.start,t.tables);if(r!==void 0){const a=t.columns[r]??t.columns[r.toLowerCase()]??[];return Fe(a,n.text,Se,i=>({detail:r,kind:"column",label:i}))}if(n.text===""&&!Pe(l,n.start))return[];const o=Fe(t.tables,n.text,Se,a=>({kind:"table",label:a})),s=Xt(t,n.text,Se),d=Yt.flatMap(a=>n.text!==""&&Me(a,n.text)&&a.toLowerCase()!==n.text.toLowerCase()?[{kind:"keyword",label:a}]:[]);return(Pe(l,n.start)?[...s,...o,...d]:[...o,...s,...d]).slice(0,Se)},en=(l,e,t)=>{const n=Je(l,e),r=l.slice(0,n.start)+t.label+l.slice(n.end);return{caret:n.start+t.label.length,value:r}},tn=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],nn=(l,e)=>{const t=globalThis.getComputedStyle(l),n=globalThis.document.createElement("div"),{style:r}=n;r.position="absolute",r.visibility="hidden",r.whiteSpace="pre-wrap",r.overflowWrap="break-word";for(const a of tn)r[a]=t[a];n.textContent=l.value.slice(0,Math.max(0,e));const o=globalThis.document.createElement("span");o.textContent=l.value.slice(Math.max(0,e))||".",n.append(o),globalThis.document.body.append(n);const s=o.offsetLeft-l.scrollLeft,d=o.offsetTop-l.scrollTop;return n.remove(),{left:s,top:d}},on=(l,e,t)=>{const n=K(16),[r,o]=re(null);let s;n[0]!==l||n[1]!==e?(s=(y,b)=>{const m=Zt(y,b,l);if(m.length===0){o(null);return}const w=e.current,{left:N,top:S}=w===null?{left:0,top:0}:nn(w,b);o(k=>k!==null&&k.active===0&&k.left===N&&k.top===S&&k.suggestions.length===m.length&&k.suggestions.every((R,T)=>{const I=m.at(T);return R.kind===I?.kind&&R.label===I.label&&R.detail===I.detail})?k:{active:0,left:N,suggestions:m,top:S})},n[0]=l,n[1]=e,n[2]=s):s=n[2];const d=s;let a;n[3]===Symbol.for("react.memo_cache_sentinel")?(a=()=>{o(null)},n[3]=a):a=n[3];const i=a;let f;n[4]===Symbol.for("react.memo_cache_sentinel")?(f=y=>{o(b=>{if(b===null)return b;const m=b.suggestions.length,w=(b.active+y+m)%m;return{...b,active:w}})},n[4]=f):f=n[4];const h=f;let p;n[5]!==t||n[6]!==r||n[7]!==e?(p=y=>{const b=e.current;if(r===null||b===null)return!1;const m=r.suggestions[y??r.active];if(m===void 0)return!1;const w=en(b.value,b.selectionStart,m);return t(w.value),o(null),requestAnimationFrame(()=>{const N=e.current;N!==null&&(N.focus(),N.setSelectionRange(w.caret,w.caret))}),!0},n[5]=t,n[6]=r,n[7]=e,n[8]=p):p=n[8];const x=p;let c;n[9]!==x?(c=()=>x(),n[9]=x,n[10]=c):c=n[10];const g=c;let v;return n[11]!==g||n[12]!==x||n[13]!==d||n[14]!==r?(v={close:i,commit:g,commitAt:x,move:h,refresh:d,state:r},n[11]=g,n[12]=x,n[13]=d,n[14]=r,n[15]=v):v=n[15],v},rn={column:"column",keyword:"keyword",table:"table"},ln=20,sn=l=>{const e=K(17),{listboxId:t,onPick:n,state:r}=l,o=le();let s;e[0]!==r?(s=r===null?void 0:{left:r.left,top:r.top+ln},e[0]=r,e[1]=s):s=e[1];const d=s;if(r===null)return null;let a;if(e[2]!==t||e[3]!==n||e[4]!==r.active||e[5]!==r.suggestions||e[6]!==o){let f;e[8]!==t||e[9]!==n||e[10]!==r.active||e[11]!==o?(f=(h,p)=>A("li",{"aria-selected":p===r.active,className:ue("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",p===r.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${p.toString()}`,onMouseDown:x=>{x.preventDefault(),n(p)},role:"option",children:[u("span",{className:"truncate font-mono",children:h.label}),h.detail!==void 0&&u("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:h.detail}),u("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:o(rn[h.kind])})]},`${h.kind}:${h.label}`),e[8]=t,e[9]=n,e[10]=r.active,e[11]=o,e[12]=f):f=e[12],a=r.suggestions.map(f),e[2]=t,e[3]=n,e[4]=r.active,e[5]=r.suggestions,e[6]=o,e[7]=a}else a=e[7];let i;return e[13]!==t||e[14]!==d||e[15]!==a?(i=u("ul",{className:"absolute z-30 max-h-56 w-72 overflow-auto rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-autocomplete",id:t,role:"listbox",style:d,children:a}),e[13]=t,e[14]=d,e[15]=a,e[16]=i):i=e[16],i},an=Te($e.listTables),cn=Te($e.readTablePage),dn=l=>{const e=K(16),t=Oe();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];const[r,o]=re(n);let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s={},e[1]=s):s=e[1];const[d,a]=re(s);let i;e[2]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[2]=i):i=e[2];const f=ye(i);let h,p;e[3]!==t||e[4]!==l?(h=()=>{const b={cancelled:!1};return de((async()=>{try{const m=await t.query(an,{},ke(l));b.cancelled||(o(m.map(mn)),a({}),f.current=new Set)}catch{b.cancelled||(o([]),a({}),f.current=new Set)}})()),()=>{b.cancelled=!0}},p=[t,l],e[3]=t,e[4]=l,e[5]=h,e[6]=p):(h=e[5],p=e[6]),qe(h,p);let x;e[7]!==t||e[8]!==l?(x=b=>{f.current.has(b)||(f.current.add(b),de((async()=>{try{const m=await t.query(cn,{limit:1,offset:0,table:b},ke(l));a(w=>({...w,[b]:m.columns}))}catch{f.current.delete(b)}})()))},e[7]=t,e[8]=l,e[9]=x):x=e[9];const c=x;let g;e[10]!==d||e[11]!==r?(g={columns:d,tables:r},e[10]=d,e[11]=r,e[12]=g):g=e[12];const v=g;let y;return e[13]!==c||e[14]!==v?(y={probe:c,schema:v},e[13]=c,e[14]=v,e[15]=y):y=e[15],y},Le=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,un=l=>{const e=new Set;Le.lastIndex=0;let t=Le.exec(l);for(;t!==null;)e.add(t[1]??t[2]),t=Le.exec(l);return[...e]};function mn(l){return l.name}const fn=l=>{const e=K(34),{onSubmit:t,probe:n,schema:r,setDraft:o}=l,s=et(),d=ye(null),a=ye(null),i=ye(null),f=on(r,i,o),{close:h,commit:p,commitAt:x,move:c,refresh:g,state:v}=f;let y;e[0]!==x?(y=$=>{x($)},e[0]=x,e[1]=y):y=e[1];const b=y;let m;e[2]!==g?(m=()=>{const $=i.current;$!==null&&$===document.activeElement&&g($.value,$.selectionStart)},e[2]=g,e[3]=m):m=e[3];let w;e[4]!==g||e[5]!==r?(w=[g,r],e[4]=g,e[5]=r,e[6]=w):w=e[6],qe(m,w);let N;e[7]!==n||e[8]!==g||e[9]!==o?(N=$=>{const{selectionStart:B,value:F}=$.target;o(F);for(const P of un(F))n(P);g(F,B)},e[7]=n,e[8]=g,e[9]=o,e[10]=N):N=e[10];const S=N;let k;e[11]!==g?(k=$=>{const B=$.currentTarget;g(B.value,B.selectionStart)},e[11]=g,e[12]=k):k=e[12];const R=k;let T;e[13]!==v||e[14]!==h||e[15]!==p||e[16]!==c||e[17]!==t?(T=$=>{if(v!==null){if($.key==="ArrowDown"){$.preventDefault(),c(1);return}if($.key==="ArrowUp"){$.preventDefault(),c(-1);return}if($.key==="Escape"){$.preventDefault(),h();return}if(($.key==="Enter"||$.key==="Tab")&&!$.metaKey&&!$.ctrlKey&&p()){$.preventDefault();return}}($.metaKey||$.ctrlKey)&&$.key==="Enter"&&($.preventDefault(),t())},e[13]=v,e[14]=h,e[15]=p,e[16]=c,e[17]=t,e[18]=T):T=e[18];const I=T;let C;e[19]!==h?(C=()=>{requestAnimationFrame(()=>{h()})},e[19]=h,e[20]=C):C=e[20];const L=C;let _;e[21]===Symbol.for("react.memo_cache_sentinel")?(_=$=>{const{scrollLeft:B,scrollTop:F}=$.currentTarget;d.current!==null&&(d.current.scrollTop=F),a.current!==null&&(a.current.scrollTop=F,a.current.scrollLeft=B)},e[21]=_):_=e[21];const O=_;let q;e[22]===Symbol.for("react.memo_cache_sentinel")?(q=$=>{const B=i.current;B===null||$.offset===void 0||(B.focus(),B.setSelectionRange($.offset,$.offset+($.length??0)))},e[22]=q):q=e[22];const E=q;let M;e[23]!==S||e[24]!==L||e[25]!==I||e[26]!==R?(M={onBlur:L,onChange:S,onKeyDown:I,onScroll:O,onSelect:R},e[23]=S,e[24]=L,e[25]=I,e[26]=R,e[27]=M):M=e[27];let D;return e[28]!==v||e[29]!==h||e[30]!==s||e[31]!==b||e[32]!==M?(D={autocompleteState:v,closeAutocomplete:h,handlers:M,listboxId:s,onPickSuggestion:b,editorRef:i,gutterRef:d,overlayRef:a,revealDiagnostic:E},e[28]=v,e[29]=h,e[30]=s,e[31]=b,e[32]=M,e[33]=D):D=e[33],D},hn="lunora-studio-sql-tabs",pn="lunora-studio-sql-active-tab",De=12,ve=(l="",e="")=>({activeId:null,id:je("tab"),name:e,sql:l}),bn=()=>We(pn,""),gn=l=>{const e=K(16),[t,n]=_e(hn),[r,o]=bn(),[s]=re(l);let d,a;e[0]!==s||e[1]!==n||e[2]!==t.length?(d=()=>{t.length===0&&n([s])},a=[s,n,t.length],e[0]=s,e[1]=n,e[2]=t.length,e[3]=d,e[4]=a):(d=e[3],a=e[4]),qe(d,a);let i;e[5]!==s||e[6]!==t?(i=t.length===0?[s]:t,e[5]=s,e[6]=t,e[7]=i):i=e[7];const f=i;let h;e[8]!==r||e[9]!==f?(h=f.some(c=>c.id===r)?r:f[0]?.id??"",e[8]=r,e[9]=f,e[10]=h):h=e[10];const p=h;let x;return e[11]!==p||e[12]!==o||e[13]!==n||e[14]!==f?(x={activeId:p,setActiveId:o,setTabs:n,tabs:f},e[11]=p,e[12]=o,e[13]=n,e[14]=f,e[15]=x):x=e[15],x},Ge=l=>l.activeId===null&&l.sql.trim()!=="",xn=(l,e)=>[...l,e].slice(-De),vn=(l,e,t)=>{const n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:l[0]?.id??"",tabs:[...l]};const r=l.filter(o=>o.id!==e);if(r.length===0){const o=t();return{activeId:o.id,tabs:[o]}}return{activeId:r[Math.min(n,r.length-1)].id,tabs:r}},yn=(l,e)=>{const t=l.filter(n=>n.id===e);return t.length===0?{activeId:l[0]?.id??"",tabs:[...l]}:{activeId:e,tabs:t}},wn=(l,e,t)=>{const n=l.findIndex(o=>o.id===e);if(n===-1)return{activeId:t,tabs:[...l]};const r=l.slice(0,n+1);return{activeId:r.some(o=>o.id===t)?t:e,tabs:r}},Sn=l=>{const e=l();return{activeId:e.id,tabs:[e]}},Nn=(l,e,t)=>{if(l==="others")return e.filter(n=>n.id!==t);if(l==="right"){const n=e.findIndex(r=>r.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},Qe={error:null,pane:"results",result:null,running:!1},kn=l=>{const e=K(66),{activeId:t,setActiveId:n,setTabs:r,tabs:o}=gn(l);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const[d,a]=re(s),[i,f]=re(null),[h,p]=re(null);let x;e[1]!==t||e[2]!==o?(x=o.find(H=>H.id===t)??o[0]??ve(),e[1]=t,e[2]=o,e[3]=x):x=e[3];const c=x,g=d[c.id]??Qe;let v;e[4]!==c.id||e[5]!==r?(v=H=>{r(j=>j.map(U=>U.id===c.id?{...U,...H}:U))},e[4]=c.id,e[5]=r,e[6]=v):v=e[6];const y=v;let b;e[7]!==c.id?(b=H=>{a(j=>{const U=j[c.id]??Qe;return{...j,[c.id]:{...U,...H}}})},e[7]=c.id,e[8]=b):b=e[8];const m=b;let w;e[9]!==n||e[10]!==r||e[11]!==o.length?(w=()=>{if(o.length>=De)return;const H=ve();r(j=>xn(j,H)),n(H.id)},e[9]=n,e[10]=r,e[11]=o.length,e[12]=w):w=e[12];const N=w;let S;e[13]!==n||e[14]!==r?(S=H=>{f(null),p(null),r(H.tabs),n(H.activeId);const j=new Set(H.tabs.map(Cn));a(U=>Object.fromEntries(Object.entries(U).filter(ae=>{const[xe]=ae;return j.has(xe)})))},e[13]=n,e[14]=r,e[15]=S):S=e[15];const k=S;let R;e[16]!==k||e[17]!==o?(R=H=>{k(vn(o,H,ve))},e[16]=k,e[17]=o,e[18]=R):R=e[18];const T=R;let I;e[19]!==t||e[20]!==k||e[21]!==o?(I=(H,j)=>{k(H==="others"?yn(o,j):H==="right"?wn(o,j,t):Sn(ve))},e[19]=t,e[20]=k,e[21]=o,e[22]=I):I=e[22];const C=I;let L;e[23]!==C||e[24]!==i||e[25]!==o?(L=H=>{i!==null&&(Nn(H,o,i.id).some(qn)?p(H):C(H,i.id))},e[23]=C,e[24]=i,e[25]=o,e[26]=L):L=e[26];const _=L;let O;e[27]===Symbol.for("react.memo_cache_sentinel")?(O=(H,j)=>{j.preventDefault(),p(null),f({id:H,x:j.clientX,y:j.clientY})},e[27]=O):O=e[27];const q=O;let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=()=>{f(null),p(null)},e[28]=E):E=e[28];const M=E;let D;e[29]===Symbol.for("react.memo_cache_sentinel")?(D=H=>{H.preventDefault(),f(null),p(null)},e[29]=D):D=e[29];const $=D;let B;e[30]!==_?(B=()=>{_("others")},e[30]=_,e[31]=B):B=e[31];const F=B;let P;e[32]!==_?(P=()=>{_("right")},e[32]=_,e[33]=P):P=e[33];const W=P;let Q;e[34]!==_?(Q=()=>{_("all")},e[34]=_,e[35]=Q):Q=e[35];const Y=Q;let J;e[36]!==C||e[37]!==h||e[38]!==i?(J=()=>{i!==null&&h!==null&&C(h,i.id),p(null)},e[36]=C,e[37]=h,e[38]=i,e[39]=J):J=e[39];const z=J;let G;e[40]===Symbol.for("react.memo_cache_sentinel")?(G=()=>{p(null)},e[40]=G):G=e[40];const ne=G;let V;e[41]!==i?(V=i===null?void 0:{left:i.x,top:i.y},e[41]=i,e[42]=V):V=e[42];const X=V;let Z;e[43]!==r?(Z=H=>{r(j=>j.map(U=>U.activeId===H?{...U,activeId:null}:U))},e[43]=r,e[44]=Z):Z=e[44];const ee=Z;let te;e[45]!==r?(te=(H,j)=>{r(U=>U.map(ae=>ae.id===H?{...ae,name:j}:ae))},e[45]=r,e[46]=te):te=e[46];const oe=te;let ie;return e[47]!==c||e[48]!==t||e[49]!==N||e[50]!==T||e[51]!==z||e[52]!==Y||e[53]!==F||e[54]!==W||e[55]!==g||e[56]!==m||e[57]!==y||e[58]!==h||e[59]!==oe||e[60]!==n||e[61]!==i||e[62]!==X||e[63]!==o||e[64]!==ee?(ie={activeTab:c,activeTabId:t,addEditorTab:N,cancelBulk:ne,closeEditorTab:T,closeTabMenu:M,confirmBulk:z,menuStyle:X,onBackdropContextMenu:$,onCloseAll:Y,onCloseOthers:F,onCloseToRight:W,openTabMenu:q,output:g,patchActiveOutput:m,patchActiveTab:y,pendingBulk:h,renameTab:oe,setActiveTabId:n,tabMenu:i,tabs:o,unlinkQuery:ee},e[47]=c,e[48]=t,e[49]=N,e[50]=T,e[51]=z,e[52]=Y,e[53]=F,e[54]=W,e[55]=g,e[56]=m,e[57]=y,e[58]=h,e[59]=oe,e[60]=n,e[61]=i,e[62]=X,e[63]=o,e[64]=ee,e[65]=ie):ie=e[65],ie};function Cn(l){return l.id}function qn(l){return Ge(l)}const $n="lunora-studio-sql-queries",Tn="lunora-studio-sql-history",Rn=25,In=l=>{const e=K(33),{loadIntoActiveTab:t,unlinkQuery:n}=l,r=le(),[o,s]=_e($n),[d,a]=_e(Tn),[i,f]=re(""),h=ye(null);let p;e[0]!==a?(p=q=>{a(E=>E[0]?.sql===q?E:[{at:Date.now(),sql:q},...E.filter(M=>M.sql!==q)].slice(0,Rn))},e[0]=a,e[1]=p):p=e[1];const x=p;let c;e[2]!==t||e[3]!==s||e[4]!==r?(c=()=>{const q={id:je("q"),name:r("Untitled query"),sql:""};s(E=>[q,...E]),t("",q.id)},e[2]=t,e[3]=s,e[4]=r,e[5]=c):c=e[5];const g=c;let v;e[6]!==t||e[7]!==o?(v=q=>{const E=o.find(M=>M.id===q);E!==void 0&&(t(E.sql,q),h.current?.querySelector(`[data-testid="sql-query-${q}"]`)?.scrollIntoView({block:"nearest"}))},e[6]=t,e[7]=o,e[8]=v):v=e[8];const y=v;let b;e[9]!==s||e[10]!==n?(b=q=>{s(E=>E.filter(M=>M.id!==q)),n(q)},e[9]=s,e[10]=n,e[11]=b):b=e[11];const m=b;let w;e[12]!==t?(w=q=>{t(q.currentTarget.dataset.sql??"",null)},e[12]=t,e[13]=w):w=e[13];const N=w;let S;e[14]!==t?(S=q=>{t(q.currentTarget.dataset.sql??"",null)},e[14]=t,e[15]=S):S=e[15];const k=S;let R;e[16]!==a?(R=()=>{a([])},e[16]=a,e[17]=R):R=e[17];const T=R;let I;e[18]===Symbol.for("react.memo_cache_sentinel")?(I=q=>{f(q.target.value)},e[18]=I):I=e[18];const C=I;let L;e[19]!==s?(L=(q,E)=>{s(M=>M.map(D=>D.id===q?{...D,sql:E}:D))},e[19]=s,e[20]=L):L=e[20];const _=L;let O;return e[21]!==T||e[22]!==m||e[23]!==d||e[24]!==k||e[25]!==N||e[26]!==g||e[27]!==o||e[28]!==x||e[29]!==i||e[30]!==y||e[31]!==_?(O={clearHistory:T,deleteQuery:m,history:d,listRef:h,loadFromHistory:k,loadTemplate:N,newQuery:g,onSearchChange:C,queries:o,recordHistory:x,search:i,selectQuery:y,updateQuerySql:_},e[21]=T,e[22]=m,e[23]=d,e[24]=k,e[25]=N,e[26]=g,e[27]=o,e[28]=x,e[29]=i,e[30]=y,e[31]=_,e[32]=O):O=e[32],O},Ve="p-3 font-mono text-xs leading-5 whitespace-pre-wrap break-words",En=(l,e)=>{const t=[];for(const r of l){if(r.offset===void 0||r.length===void 0||r.length<=0)continue;const o=Math.max(0,Math.min(r.offset,e)),s=Math.max(o,Math.min(r.offset+r.length,e));o!==s&&t.push({end:s,severity:r.severity,start:o})}t.sort((r,o)=>r.start-o.start);const n=[];for(const r of t)r.start>=(n.at(-1)?.end??0)&&n.push(r);return n},Ln=l=>l==="unsafe-response"?"The model returned a statement that is not read-only, so it was discarded.":l==="empty-response"?"The model returned nothing usable.":"The model could not be reached.",_n=l=>{const e=K(51),{assistant:t,failed:n,onGenerated:r}=l,o=le(),[s,d]=re("");if(t.unavailable)return null;let a;e[0]!==t?(a=t.pending("sql"),e[0]=t,e[1]=a):a=e[1];const i=a;let f;if(e[2]!==t||e[3]!==n||e[4]!==r||e[5]!==i||e[6]!==s||e[7]!==o){const h=t.reason("sql");let p;e[9]!==t||e[10]!==n||e[11]!==r||e[12]!==s?(p=C=>{const L=s.trim();L===""&&!C||de((async()=>{const _=await t.generate(L===""?"fix the failing statement":L,C?n:void 0);_!==void 0&&r(_)})())},e[9]=t,e[10]=n,e[11]=r,e[12]=s,e[13]=p):p=e[13];const x=p;let c;e[14]!==o?(c=o("Describe the query you want"),e[14]=o,e[15]=c):c=e[15];let g;e[16]===Symbol.for("react.memo_cache_sentinel")?(g=C=>{d(C.target.value)},e[16]=g):g=e[16];let v;e[17]!==x?(v=C=>{C.key==="Enter"&&(C.preventDefault(),x(!1))},e[17]=x,e[18]=v):v=e[18];let y;e[19]!==o?(y=o("Describe the query you want"),e[19]=o,e[20]=y):y=e[20];let b;e[21]!==i||e[22]!==s||e[23]!==c||e[24]!==v||e[25]!==y?(b=u(rt,{"aria-label":c,className:"h-7 flex-1 text-xs","data-testid":"sql-assistant-prompt",disabled:i,onChange:g,onKeyDown:v,placeholder:y,value:s}),e[21]=i,e[22]=s,e[23]=c,e[24]=v,e[25]=y,e[26]=b):b=e[26];const m=i&&"opacity-60";let w;e[27]!==m?(w=ue("rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",m),e[27]=m,e[28]=w):w=e[28];let N;e[29]!==i||e[30]!==s?(N=i||s.trim()==="",e[29]=i,e[30]=s,e[31]=N):N=e[31];let S;e[32]!==x?(S=()=>{x(!1)},e[32]=x,e[33]=S):S=e[33];let k;e[34]!==i||e[35]!==o?(k=o(i?"Thinking…":"Draft SQL"),e[34]=i,e[35]=o,e[36]=k):k=e[36];let R;e[37]!==w||e[38]!==N||e[39]!==S||e[40]!==k?(R=u("button",{className:w,"data-testid":"sql-assistant-generate",disabled:N,onClick:S,type:"button",children:k}),e[37]=w,e[38]=N,e[39]=S,e[40]=k,e[41]=R):R=e[41];let T;e[42]!==n||e[43]!==i||e[44]!==x||e[45]!==o?(T=n!==void 0&&u("button",{className:"rounded-md border border-border px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-assistant-fix",disabled:i,onClick:()=>{x(!0)},type:"button",children:o("Fix this")}),e[42]=n,e[43]=i,e[44]=x,e[45]=o,e[46]=T):T=e[46];let I;e[47]!==R||e[48]!==T||e[49]!==b?(I=A("div",{className:"flex items-center gap-2",children:[b,R,T]}),e[47]=R,e[48]=T,e[49]=b,e[50]=I):I=e[50],f=A("div",{className:"flex flex-col gap-1 border-b border-border px-3 py-2","data-testid":"sql-assistant",children:[I,h!==void 0&&u("p",{className:"text-[11px] text-muted-foreground","data-testid":"sql-assistant-reason",role:"status",children:Ln(h)})]}),e[2]=t,e[3]=n,e[4]=r,e[5]=i,e[6]=s,e[7]=o,e[8]=f}else f=e[8];return f},On=l=>{const e=K(8),{diagnostics:t,draft:n,scrollRef:r}=l;let o,s;if(e[0]!==t||e[1]!==n){s=Symbol.for("react.early_return_sentinel");e:{const i=En(t,n.length);if(i.length===0){s=null;break e}o=[];let f=0;for(const[h,p]of i.entries())p.start>f&&o.push(n.slice(f,p.start)),o.push(u("span",{className:ue("decoration-wavy underline underline-offset-4",p.severity==="error"?"decoration-destructive":"decoration-amber-500"),children:n.slice(p.start,p.end)},`${p.start.toString()}-${h.toString()}`)),f=p.end;o.push(n.slice(f))}e[0]=t,e[1]=n,e[2]=o,e[3]=s}else o=e[2],s=e[3];if(s!==Symbol.for("react.early_return_sentinel"))return s;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=ue("pointer-events-none absolute inset-0 overflow-hidden text-transparent",Ve),e[4]=d):d=e[4];let a;return e[5]!==o||e[6]!==r?(a=u("div",{"aria-hidden":"true",className:d,"data-testid":"sql-diagnostics-overlay",ref:r,children:o}),e[5]=o,e[6]=r,e[7]=a):a=e[7],a},Mn={gate:"read-only",plan:"plan",schema:"schema",syntax:"syntax"},Dn=l=>{const e=K(10),{diagnostics:t,onSelect:n}=l,r=le();if(t.length===0)return null;let o;e[0]!==r?(o=r("SQL problems"),e[0]=r,e[1]=o):o=e[1];let s;if(e[2]!==t||e[3]!==n){let a;e[5]!==n?(a=(i,f)=>u("li",{children:A("button",{className:"flex w-full items-start gap-2 px-3 py-1 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-problem",onClick:()=>{n(i)},type:"button",children:[u("span",{className:ue("mt-px shrink-0 rounded px-1 font-mono text-[10px] uppercase",i.severity==="error"?"bg-destructive/15 text-destructive":"bg-amber-500/15 text-amber-600"),children:Mn[i.source]}),u("span",{className:"min-w-0 text-muted-foreground",children:i.message})]})},`${i.source}-${(i.offset??f).toString()}-${f.toString()}`),e[5]=n,e[6]=a):a=e[6],s=t.map(a),e[2]=t,e[3]=n,e[4]=s}else s=e[4];let d;return e[7]!==o||e[8]!==s?(d=u("ul",{"aria-label":o,className:"max-h-24 shrink-0 overflow-y-auto border-t border-border bg-muted/30","data-testid":"sql-problems",children:s}),e[7]=o,e[8]=s,e[9]=d):d=e[9],d},An={minWidth:"2.75rem",paddingInline:"0.5rem"},Bn=l=>{const e=K(64),{assistant:t,autocomplete:n,diagnostics:r,draft:o,failed:s,handlers:d,editorRef:a,gutterRef:i,listboxId:f,onGenerated:h,onPickSuggestion:p,onRevealDiagnostic:x,overlayRef:c}=l,g=le();let v,y,b,m,w,N,S,k;if(e[0]!==t||e[1]!==o||e[2]!==s||e[3]!==i||e[4]!==h){const B=o.split(`
5
+ `).length;S="flex min-h-0 min-w-0 flex-1 flex-col",e[13]!==t||e[14]!==s||e[15]!==h?(k=u(_n,{assistant:t,failed:s,onGenerated:h}),e[13]=t,e[14]=s,e[15]=h,e[16]=k):k=e[16],N="flex min-h-0 min-w-0 flex-1",v="true",y="shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",b=i,m=An,w=Array.from({length:B},zn),e[0]=t,e[1]=o,e[2]=s,e[3]=i,e[4]=h,e[5]=v,e[6]=y,e[7]=b,e[8]=m,e[9]=w,e[10]=N,e[11]=S,e[12]=k}else v=e[5],y=e[6],b=e[7],m=e[8],w=e[9],N=e[10],S=e[11],k=e[12];let R;e[17]!==v||e[18]!==y||e[19]!==b||e[20]!==m||e[21]!==w?(R=u("div",{"aria-hidden":v,className:y,ref:b,style:m,children:w}),e[17]=v,e[18]=y,e[19]=b,e[20]=m,e[21]=w,e[22]=R):R=e[22];let T;e[23]!==r||e[24]!==o||e[25]!==c?(T=u(On,{diagnostics:r,draft:o,scrollRef:c}),e[23]=r,e[24]=o,e[25]=c,e[26]=T):T=e[26];let I;e[27]!==n||e[28]!==f?(I=n===null?void 0:`${f}-opt-${n.active.toString()}`,e[27]=n,e[28]=f,e[29]=I):I=e[29];const C=n===null?void 0:f,L=n!==null;let _;e[30]!==g?(_=g("SQL query"),e[30]=g,e[31]=_):_=e[31];let O;e[32]!==o||e[33]!==a||e[34]!==d.onBlur||e[35]!==d.onChange||e[36]!==d.onKeyDown||e[37]!==d.onScroll||e[38]!==d.onSelect||e[39]!==I||e[40]!==C||e[41]!==L||e[42]!==_?(O=u("textarea",{"aria-activedescendant":I,"aria-autocomplete":"list","aria-controls":C,"aria-expanded":L,"aria-label":_,className:`relative size-full resize-none bg-transparent outline-none ${Ve}`,"data-testid":"sql-input",onBlur:d.onBlur,onChange:d.onChange,onKeyDown:d.onKeyDown,onScroll:d.onScroll,onSelect:d.onSelect,placeholder:"SELECT * FROM …",ref:a,role:"combobox",spellCheck:!1,value:o}),e[32]=o,e[33]=a,e[34]=d.onBlur,e[35]=d.onChange,e[36]=d.onKeyDown,e[37]=d.onScroll,e[38]=d.onSelect,e[39]=I,e[40]=C,e[41]=L,e[42]=_,e[43]=O):O=e[43];let q;e[44]!==n||e[45]!==f||e[46]!==p?(q=u(sn,{listboxId:f,onPick:p,state:n}),e[44]=n,e[45]=f,e[46]=p,e[47]=q):q=e[47];let E;e[48]!==T||e[49]!==O||e[50]!==q?(E=A("div",{className:"relative min-w-0 flex-1 bg-background",children:[T,O,q]}),e[48]=T,e[49]=O,e[50]=q,e[51]=E):E=e[51];let M;e[52]!==E||e[53]!==N||e[54]!==R?(M=A("div",{className:N,children:[R,E]}),e[52]=E,e[53]=N,e[54]=R,e[55]=M):M=e[55];let D;e[56]!==r||e[57]!==x?(D=u(Dn,{diagnostics:r,onSelect:x}),e[56]=r,e[57]=x,e[58]=D):D=e[58];let $;return e[59]!==M||e[60]!==D||e[61]!==S||e[62]!==k?($=A("div",{className:S,children:[k,M,D]}),e[59]=M,e[60]=D,e[61]=S,e[62]=k,e[63]=$):$=e[63],$};function zn(l,e){return u("div",{children:e+1},e)}const Xe=[{label:"List tables",sql:"SELECT name FROM sqlite_master WHERE type = 'table' ORDER BY name;"},{label:"Table row count",sql:"SELECT COUNT(*) AS rows FROM messages;"},{label:"Recent rows",sql:"SELECT id, _creationTime, __doc__ FROM messages ORDER BY _creationTime DESC LIMIT 50;"},{label:"Index list",sql:"SELECT name, tbl_name FROM sqlite_master WHERE type = 'index' ORDER BY tbl_name;"}],Hn=l=>{const e=K(29),{active:t,onDelete:n,onSelect:r,query:o}=l,s=le();let d;e[0]!==r||e[1]!==o.id?(d=()=>{r(o.id)},e[0]=r,e[1]=o.id,e[2]=d):d=e[2];const a=d;let i;e[3]!==n||e[4]!==o.id?(i=S=>{S.stopPropagation(),n(o.id)},e[3]=n,e[4]=o.id,e[5]=i):i=e[5];const f=i,h=t?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground";let p;e[6]!==h?(p=ue("flex min-w-0 flex-1 items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] outline-none transition-colors hover:bg-sidebar-accent focus-visible:bg-sidebar-accent",h),e[6]=h,e[7]=p):p=e[7];const x=`sql-query-${o.id}`;let c;e[8]===Symbol.for("react.memo_cache_sentinel")?(c=u("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=c):c=e[8];let g;e[9]!==o.name?(g=u("span",{className:"truncate",children:o.name}),e[9]=o.name,e[10]=g):g=e[10];let v;e[11]!==t||e[12]!==a||e[13]!==p||e[14]!==x||e[15]!==g?(v=A("button",{"aria-pressed":t,className:p,"data-testid":x,onClick:a,type:"button",children:[c,g]}),e[11]=t,e[12]=a,e[13]=p,e[14]=x,e[15]=g,e[16]=v):v=e[16];let y;e[17]!==s?(y=s("Delete query"),e[17]=s,e[18]=y):y=e[18];let b;e[19]!==s?(b=s("Delete query"),e[19]=s,e[20]=b):b=e[20];let m;e[21]===Symbol.for("react.memo_cache_sentinel")?(m=u("svg",{"aria-hidden":"true",className:"size-3.5",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=m):m=e[21];let w;e[22]!==f||e[23]!==b||e[24]!==y?(w=u("button",{"aria-label":y,className:"me-1 hidden size-6 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive group-hover/q:flex",onClick:f,title:b,type:"button",children:m}),e[22]=f,e[23]=b,e[24]=y,e[25]=w):w=e[25];let N;return e[26]!==w||e[27]!==v?(N=A("li",{className:"group/q flex items-center",children:[v,w]}),e[26]=w,e[27]=v,e[28]=N):N=e[28],N},Pn=(l,e)=>{const t=e.trim().toLowerCase();return t===""?[...l]:l.filter(n=>n.name.toLowerCase().includes(t))},Fn=l=>{const e=K(60),{activeId:t,history:n,listRef:r,onClearHistory:o,onDelete:s,onLoadHistory:d,onLoadTemplate:a,onNew:i,onSearchChange:f,onSelect:h,queries:p,search:x}=l,c=le();let g,v,y,b;if(e[0]!==t||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==f||e[5]!==h||e[6]!==p||e[7]!==x||e[8]!==c){const C=Pn(p,x);v="flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar";let L;e[13]!==c?(L=c("Search queries…"),e[13]=c,e[14]=L):L=e[14];let _;e[15]!==f||e[16]!==x||e[17]!==L?(_=u("input",{className:"h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-xs outline-none focus-visible:border-ring","data-testid":"sql-search",onChange:f,placeholder:L,type:"text",value:x}),e[15]=f,e[16]=x,e[17]=L,e[18]=_):_=e[18];let O;e[19]!==c?(O=c("New query"),e[19]=c,e[20]=O):O=e[20];let q;e[21]!==c?(q=c("New query"),e[21]=c,e[22]=q):q=e[22];let E;e[23]===Symbol.for("react.memo_cache_sentinel")?(E=u("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:u("path",{d:"M12 5v14M5 12h14"})}),e[23]=E):E=e[23];let M;e[24]!==i||e[25]!==O||e[26]!==q?(M=u("button",{"aria-label":O,className:"flex size-8 shrink-0 items-center justify-center rounded-md border border-border text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent","data-testid":"sql-new",onClick:i,title:q,type:"button",children:E}),e[24]=i,e[25]=O,e[26]=q,e[27]=M):M=e[27],e[28]!==M||e[29]!==_?(y=A("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[_,M]}),e[28]=M,e[29]=_,e[30]=y):y=e[30],g="flex flex-1 flex-col gap-4 overflow-y-auto p-2";let D;e[31]!==c?(D=c("Private"),e[31]=c,e[32]=D):D=e[32];let $;e[33]!==D?($=u("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:D}),e[33]=D,e[34]=$):$=e[34],b=A("div",{children:[$,C.length===0?u("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:c("No saved queries yet — they save to this browser as you type.")}):u("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:r,children:C.map(B=>u(Hn,{active:t===B.id,onDelete:s,onSelect:h,query:B},B.id))})]}),e[0]=t,e[1]=r,e[2]=s,e[3]=i,e[4]=f,e[5]=h,e[6]=p,e[7]=x,e[8]=c,e[9]=g,e[10]=v,e[11]=y,e[12]=b}else g=e[9],v=e[10],y=e[11],b=e[12];let m;e[35]!==c?(m=c("Reference"),e[35]=c,e[36]=m):m=e[36];let w;e[37]!==m?(w=u("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:m}),e[37]=m,e[38]=w):w=e[38];let N;e[39]!==a?(N=Xe.map(C=>u("li",{children:A("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":C.sql,onClick:a,type:"button",children:[u("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),C.label]})},C.label)),e[39]=a,e[40]=N):N=e[40];let S;e[41]!==N?(S=u("ul",{className:"flex flex-col gap-px",children:N}),e[41]=N,e[42]=S):S=e[42];let k;e[43]!==w||e[44]!==S?(k=A("div",{children:[w,S]}),e[43]=w,e[44]=S,e[45]=k):k=e[45];let R;e[46]!==n||e[47]!==o||e[48]!==d||e[49]!==c?(R=n.length>0&&A("div",{children:[A("div",{className:"flex items-center justify-between px-1 pb-1",children:[u("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:c("History")}),u("button",{className:"rounded px-1 text-[11px] text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:text-foreground","data-testid":"sql-history-clear",onClick:o,type:"button",children:c("Clear history")})]}),u("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:n.map(C=>u("li",{children:A("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":C.sql,"data-testid":"sql-history-item",onClick:d,title:C.sql,type:"button",children:[u("svg",{"aria-hidden":"true",className:"size-3.5 shrink-0 opacity-70",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:u("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),u("span",{className:"truncate font-mono",children:C.sql})]})},`${C.at.toString()}:${C.sql}`))})]}),e[46]=n,e[47]=o,e[48]=d,e[49]=c,e[50]=R):R=e[50];let T;e[51]!==g||e[52]!==R||e[53]!==b||e[54]!==k?(T=A("div",{className:g,children:[b,k,R]}),e[51]=g,e[52]=R,e[53]=b,e[54]=k,e[55]=T):T=e[55];let I;return e[56]!==T||e[57]!==v||e[58]!==y?(I=A("aside",{className:v,children:[y,T]}),e[56]=T,e[57]=v,e[58]=y,e[59]=I):I=e[59],I},Qn=l=>{const e=K(19),{result:t}=l,n=le();if(t.columns.length===0){let i;e[0]!==t.rowCount||e[1]!==n?(i=n("{count} rows",{count:t.rowCount}),e[0]=t.rowCount,e[1]=n,e[2]=i):i=e[2];let f;return e[3]!==i?(f=u("p",{className:"p-4 text-sm text-muted-foreground",children:i}),e[3]=i,e[4]=f):f=e[4],f}let r;e[5]!==t.columns?(r=t.columns.map(jn),e[5]=t.columns,e[6]=r):r=e[6];let o;e[7]!==r?(o=u(ct,{className:"sticky top-0 z-10 bg-muted",children:u(He,{children:r})}),e[7]=r,e[8]=o):o=e[8];let s;if(e[9]!==t.columns||e[10]!==t.rows){let i;e[12]!==t.columns?(i=(f,h)=>u(He,{"data-testid":"sql-row",children:t.columns.map(p=>u(ft,{className:"max-w-md truncate font-mono text-xs",children:u(ht,{value:f[p]})},p))},h),e[12]=t.columns,e[13]=i):i=e[13],s=t.rows.map(i),e[9]=t.columns,e[10]=t.rows,e[11]=s}else s=e[11];let d;e[14]!==s?(d=u(dt,{children:s}),e[14]=s,e[15]=d):d=e[15];let a;return e[16]!==o||e[17]!==d?(a=A(ut,{"data-testid":"sql-rows",children:[o,d]}),e[16]=o,e[17]=d,e[18]=a):a=e[18],a};function jn(l){return u(mt,{children:l},l)}const Ne=l=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${l?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,Wn=l=>{const e=K(92),{assistant:t,chart:n,className:r,error:o,onFormat:s,onInferChart:d,onRun:a,onShardKeyChange:i,onShowChart:f,onShowExplain:h,onShowResults:p,onToggleSplit:x,pane:c,result:g,running:v,shardKey:y,splitView:b}=l,m=le(),w=c==="results";let N;e[0]!==w?(N=Ne(w),e[0]=w,e[1]=N):N=e[1];let S;e[2]!==m?(S=m("Results"),e[2]=m,e[3]=S):S=e[3];let k;e[4]!==p||e[5]!==N||e[6]!==S?(k=u("button",{className:N,"data-testid":"sql-tab-results",onClick:p,type:"button",children:S}),e[4]=p,e[5]=N,e[6]=S,e[7]=k):k=e[7];const R=c==="chart";let T;e[8]!==R?(T=Ne(R),e[8]=R,e[9]=T):T=e[9];let I;e[10]!==m?(I=m("Chart"),e[10]=m,e[11]=I):I=e[11];let C;e[12]!==f||e[13]!==T||e[14]!==I?(C=u("button",{className:T,"data-testid":"sql-tab-chart",onClick:f,type:"button",children:I}),e[12]=f,e[13]=T,e[14]=I,e[15]=C):C=e[15];let L;e[16]!==t||e[17]!==d||e[18]!==c||e[19]!==g||e[20]!==m?(L=!t.unavailable&&c==="chart"&&g!==null&&u("button",{className:Ne(!1),"data-testid":"sql-infer-chart",disabled:t.pending("chart"),onClick:d,type:"button",children:t.pending("chart")?m("Thinking…"):m("Suggest chart")}),e[16]=t,e[17]=d,e[18]=c,e[19]=g,e[20]=m,e[21]=L):L=e[21];const _=c==="explain";let O;e[22]!==_?(O=Ne(_),e[22]=_,e[23]=O):O=e[23];let q;e[24]!==m?(q=m("Explain"),e[24]=m,e[25]=q):q=e[25];let E;e[26]!==h||e[27]!==O||e[28]!==q?(E=u("button",{className:O,"data-testid":"sql-tab-explain",onClick:h,type:"button",children:q}),e[26]=h,e[27]=O,e[28]=q,e[29]=E):E=e[29];let M;e[30]!==m?(M=m("Split editor and results"),e[30]=m,e[31]=M):M=e[31];const D=`inline-flex items-center rounded-md border border-border px-2 py-1.5 outline-none transition-colors hover:bg-accent focus-visible:bg-accent ${b?"bg-accent text-foreground":"text-muted-foreground"}`;let $;e[32]!==m?($=m("Split editor and results"),e[32]=m,e[33]=$):$=e[33];let B;e[34]===Symbol.for("react.memo_cache_sentinel")?(B=A("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[u("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),u("path",{d:"M12 4v16"})]}),e[34]=B):B=e[34];let F;e[35]!==x||e[36]!==b||e[37]!==M||e[38]!==D||e[39]!==$?(F=u("button",{"aria-label":M,"aria-pressed":b,className:D,"data-testid":"sql-split-toggle",onClick:x,title:$,type:"button",children:B}),e[35]=x,e[36]=b,e[37]=M,e[38]=D,e[39]=$,e[40]=F):F=e[40];let P;e[41]!==g?(P=g!==null&&g.columns.length>0&&u(it,{columns:g.columns,name:"query-result",rows:g.rows}),e[41]=g,e[42]=P):P=e[42];let W;e[43]!==m?(W=m("Format"),e[43]=m,e[44]=W):W=e[44];let Q;e[45]!==s||e[46]!==v||e[47]!==W?(Q=u("button",{className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-foreground outline-none transition-colors hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-format",disabled:v,onClick:s,type:"button",children:W}),e[45]=s,e[46]=v,e[47]=W,e[48]=Q):Q=e[48];let Y;e[49]!==i||e[50]!==y?(Y=u(st,{onChange:i,testId:"sql-shard-input",value:y}),e[49]=i,e[50]=y,e[51]=Y):Y=e[51];let J;e[52]!==v||e[53]!==m?(J=m(v?"Running…":"Run"),e[52]=v,e[53]=m,e[54]=J):J=e[54];let z;e[55]===Symbol.for("react.memo_cache_sentinel")?(z=u("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"⌘↵"}),e[55]=z):z=e[55];let G;e[56]!==a||e[57]!==v||e[58]!==J?(G=A("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:v,onClick:a,type:"button",children:[J,z]}),e[56]=a,e[57]=v,e[58]=J,e[59]=G):G=e[59];let ne;e[60]!==F||e[61]!==P||e[62]!==Q||e[63]!==Y||e[64]!==G?(ne=A("div",{className:"ms-auto flex items-center gap-2",children:[F,P,Q,Y,G]}),e[60]=F,e[61]=P,e[62]=Q,e[63]=Y,e[64]=G,e[65]=ne):ne=e[65];let V;e[66]!==E||e[67]!==ne||e[68]!==k||e[69]!==C||e[70]!==L?(V=A("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[k,C,L,E,ne]}),e[66]=E,e[67]=ne,e[68]=k,e[69]=C,e[70]=L,e[71]=V):V=e[71];let X;e[72]!==o?(X=o!==null&&u(at,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:o}),e[72]=o,e[73]=X):X=e[73];let Z;e[74]!==o||e[75]!==g||e[76]!==m?(Z=o===null&&g===null&&u("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:m("Click Run to execute your query.")}),e[74]=o,e[75]=g,e[76]=m,e[77]=Z):Z=e[77];let ee;e[78]!==n||e[79]!==o||e[80]!==c||e[81]!==g||e[82]!==m?(ee=o===null&&g!==null&&A("div",{"data-testid":"sql-result",children:[c==="chart"?u(lt,{axes:n,result:g}):u(Qn,{result:g}),u("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:g.truncated?m("Showing the first {max} of {count} rows.",{count:g.rowCount,max:g.rows.length}):m("{count} rows",{count:g.rowCount})})]}),e[78]=n,e[79]=o,e[80]=c,e[81]=g,e[82]=m,e[83]=ee):ee=e[83];let te;e[84]!==X||e[85]!==Z||e[86]!==ee?(te=A("div",{className:"min-h-0 flex-1 overflow-auto",children:[X,Z,ee]}),e[84]=X,e[85]=Z,e[86]=ee,e[87]=te):te=e[87];let oe;return e[88]!==r||e[89]!==V||e[90]!==te?(oe=A("div",{className:r,children:[V,te]}),e[88]=r,e[89]=V,e[90]=te,e[91]=oe):oe=e[91],oe},Kn=(l,e)=>l.trim()===""?e:(l.split(`
6
+ `)[0]??l).slice(0,24),Un=l=>{l?.focus(),l?.select()},Yn=l=>{const e=K(14),{initial:t,onCancel:n,onCommit:r,placeholder:o,testId:s}=l,d=le();let a;e[0]!==r?(a=c=>{r(c.currentTarget.value.trim())},e[0]=r,e[1]=a):a=e[1];const i=a;let f;e[2]!==n||e[3]!==r?(f=c=>{c.key==="Enter"?r(c.currentTarget.value.trim()):c.key==="Escape"&&n()},e[2]=n,e[3]=r,e[4]=f):f=e[4];const h=f;let p;e[5]!==d?(p=d("Tab title"),e[5]=d,e[6]=p):p=e[6];let x;return e[7]!==t||e[8]!==i||e[9]!==h||e[10]!==o||e[11]!==p||e[12]!==s?(x=u("input",{"aria-label":p,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":s,defaultValue:t,onBlur:i,onKeyDown:h,placeholder:o,ref:Un,type:"text"}),e[7]=t,e[8]=i,e[9]=h,e[10]=o,e[11]=p,e[12]=s,e[13]=x):x=e[13],x},Jn=l=>{const e=K(29),{idBase:t,onDiscard:n,onKeep:r}=l,o=le(),s=`sql-tab-close-prompt-${t}`;let d;e[0]!==o?(d=o("Discard?"),e[0]=o,e[1]=d):d=e[1];let a;e[2]!==d?(a=u("span",{className:"text-[11px] text-muted-foreground",children:d}),e[2]=d,e[3]=a):a=e[3];let i;e[4]!==o?(i=o("Discard changes"),e[4]=o,e[5]=i):i=e[5];const f=`sql-tab-close-confirm-${t}`;let h;e[6]!==o?(h=o("Discard changes"),e[6]=o,e[7]=h):h=e[7];let p;e[8]===Symbol.for("react.memo_cache_sentinel")?(p=u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:u("path",{d:"M5 13l4 4L19 7"})}),e[8]=p):p=e[8];let x;e[9]!==n||e[10]!==i||e[11]!==f||e[12]!==h?(x=u("button",{"aria-label":i,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":f,onClick:n,title:h,type:"button",children:p}),e[9]=n,e[10]=i,e[11]=f,e[12]=h,e[13]=x):x=e[13];let c;e[14]!==o?(c=o("Keep editing"),e[14]=o,e[15]=c):c=e[15];const g=`sql-tab-close-cancel-${t}`;let v;e[16]!==o?(v=o("Keep editing"),e[16]=o,e[17]=v):v=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:u("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=y):y=e[18];let b;e[19]!==r||e[20]!==g||e[21]!==v||e[22]!==c?(b=u("button",{"aria-label":c,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":g,onClick:r,title:v,type:"button",children:y}),e[19]=r,e[20]=g,e[21]=v,e[22]=c,e[23]=b):b=e[23];let m;return e[24]!==s||e[25]!==b||e[26]!==a||e[27]!==x?(m=A("span",{className:"flex shrink-0 items-center gap-1","data-testid":s,role:"group",children:[a,x,b]}),e[24]=s,e[25]=b,e[26]=a,e[27]=x,e[28]=m):m=e[28],m},Gn=l=>{const e=K(47),{active:t,canClose:n,onClose:r,onMenu:o,onRename:s,onSelect:d,tab:a}=l,i=le(),[f,h]=re(!1),[p,x]=re(!1);let c;e[0]!==o||e[1]!==a.id?(c=Q=>{o(a.id,Q)},e[0]=o,e[1]=a.id,e[2]=c):c=e[2];const g=c;let v;e[3]!==d||e[4]!==a.id?(v=()=>{d(a.id)},e[3]=d,e[4]=a.id,e[5]=v):v=e[5];const y=v;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{h(!0)},e[6]=b):b=e[6];const m=b;let w;e[7]!==r||e[8]!==a?(w=Q=>{Q.stopPropagation(),Ge(a)?x(!0):r(a.id)},e[7]=r,e[8]=a,e[9]=w):w=e[9];const N=w;let S;e[10]!==r||e[11]!==a.id?(S=Q=>{Q.stopPropagation(),x(!1),r(a.id)},e[10]=r,e[11]=a.id,e[12]=S):S=e[12];const k=S;let R;e[13]===Symbol.for("react.memo_cache_sentinel")?(R=Q=>{Q.stopPropagation(),x(!1)},e[13]=R):R=e[13];const T=R;let I;e[14]!==s||e[15]!==a.id?(I=Q=>{s(a.id,Q),h(!1)},e[14]=s,e[15]=a.id,e[16]=I):I=e[16];const C=I;let L;e[17]===Symbol.for("react.memo_cache_sentinel")?(L=()=>{h(!1)},e[17]=L):L=e[17];const _=L;let O;e[18]!==a.name?(O=a.name.trim(),e[18]=a.name,e[19]=O):O=e[19];const q=O;let E;e[20]!==i||e[21]!==a.sql?(E=Kn(a.sql,i("Untitled")),e[20]=i,e[21]=a.sql,e[22]=E):E=e[22];const M=E,D=t?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground";let $;e[23]!==D?($=ue("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",D),e[23]=D,e[24]=$):$=e[24];const B=`sql-tab-${a.id}`;let F;e[25]!==t||e[26]!==C||e[27]!==q||e[28]!==M||e[29]!==f||e[30]!==y||e[31]!==i||e[32]!==a.id?(F=f?u(Yn,{initial:q,onCancel:_,onCommit:C,placeholder:M,testId:`sql-tab-rename-${a.id}`}):u("button",{"aria-pressed":t,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${a.id}`,onClick:y,onDoubleClick:m,title:i("Double-click to rename"),type:"button",children:q===""?M:q}),e[25]=t,e[26]=C,e[27]=q,e[28]=M,e[29]=f,e[30]=y,e[31]=i,e[32]=a.id,e[33]=F):F=e[33];let P;e[34]!==n||e[35]!==k||e[36]!==p||e[37]!==N||e[38]!==i||e[39]!==a.id?(P=n&&(p?u(Jn,{idBase:a.id,onDiscard:k,onKeep:T}):u("button",{"aria-label":i("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${a.id}`,onClick:N,title:i("Close tab"),type:"button",children:u("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:u("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=n,e[35]=k,e[36]=p,e[37]=N,e[38]=i,e[39]=a.id,e[40]=P):P=e[40];let W;return e[41]!==g||e[42]!==$||e[43]!==B||e[44]!==F||e[45]!==P?(W=A("div",{className:$,"data-testid":B,onContextMenu:g,children:[F,P]}),e[41]=g,e[42]=$,e[43]=B,e[44]=F,e[45]=P,e[46]=W):W=e[46],W},Vn=l=>{const e=K(43),{model:t,onSelect:n}=l,r=le(),{activeTab:o,addEditorTab:s,cancelBulk:d,closeEditorTab:a,closeTabMenu:i,confirmBulk:f,menuStyle:h,onBackdropContextMenu:p,onCloseAll:x,onCloseOthers:c,onCloseToRight:g,openTabMenu:v,pendingBulk:y,renameTab:b,tabMenu:m,tabs:w}=t;let N;if(e[0]!==o||e[1]!==a||e[2]!==n||e[3]!==v||e[4]!==b||e[5]!==w){let O;e[7]!==o||e[8]!==a||e[9]!==n||e[10]!==v||e[11]!==b||e[12]!==w.length?(O=q=>u(Gn,{active:q.id===o.id,canClose:w.length>1,onClose:a,onMenu:v,onRename:b,onSelect:n,tab:q},q.id),e[7]=o,e[8]=a,e[9]=n,e[10]=v,e[11]=b,e[12]=w.length,e[13]=O):O=e[13],N=w.map(O),e[0]=o,e[1]=a,e[2]=n,e[3]=v,e[4]=b,e[5]=w,e[6]=N}else N=e[6];let S;e[14]!==r?(S=r("New tab"),e[14]=r,e[15]=S):S=e[15];const k=w.length>=De;let R;e[16]!==r?(R=r("New tab"),e[16]=r,e[17]=R):R=e[17];let T;e[18]===Symbol.for("react.memo_cache_sentinel")?(T=u("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:u("path",{d:"M12 5v14M5 12h14"})}),e[18]=T):T=e[18];let I;e[19]!==s||e[20]!==S||e[21]!==k||e[22]!==R?(I=u("button",{"aria-label":S,className:"flex size-8 shrink-0 items-center justify-center text-muted-foreground outline-none transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-add",disabled:k,onClick:s,title:R,type:"button",children:T}),e[19]=s,e[20]=S,e[21]=k,e[22]=R,e[23]=I):I=e[23];let C;e[24]!==N||e[25]!==I?(C=A("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[N,I]}),e[24]=N,e[25]=I,e[26]=C):C=e[26];let L;e[27]!==d||e[28]!==i||e[29]!==f||e[30]!==h||e[31]!==p||e[32]!==x||e[33]!==c||e[34]!==g||e[35]!==y||e[36]!==r||e[37]!==m||e[38]!==w?(L=m!==null&&A(Ee,{children:[u("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:i,onContextMenu:p,role:"presentation"}),u("div",{className:"fixed z-50 min-w-44 rounded-md border border-border bg-popover py-1 text-popover-foreground shadow-md","data-testid":"sql-tab-menu",role:"menu",style:h,children:y===null?A(Ee,{children:[u("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-others",disabled:w.length<=1,onClick:c,role:"menuitem",type:"button",children:r("Close other tabs")}),u("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent disabled:pointer-events-none disabled:opacity-40","data-testid":"sql-tab-menu-close-right",disabled:w.findIndex(O=>O.id===m.id)>=w.length-1,onClick:g,role:"menuitem",type:"button",children:r("Close tabs to the right")}),u("button",{className:"flex w-full items-center px-3 py-1.5 text-start text-xs outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-close-all",onClick:x,role:"menuitem",type:"button",children:r("Close all tabs")})]}):A("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[u("p",{className:"pb-1.5 text-xs text-muted-foreground",children:r("Discard unsaved tabs?")}),A("div",{className:"flex items-center gap-1.5",children:[u("button",{className:"rounded px-2 py-1 text-xs font-medium text-destructive outline-none hover:bg-destructive/10 focus-visible:bg-destructive/10","data-testid":"sql-tab-menu-confirm-discard",onClick:f,type:"button",children:r("Discard")}),u("button",{className:"rounded px-2 py-1 text-xs text-muted-foreground outline-none hover:bg-accent focus-visible:bg-accent","data-testid":"sql-tab-menu-confirm-cancel",onClick:d,type:"button",children:r("Cancel")})]})]})})]}),e[27]=d,e[28]=i,e[29]=f,e[30]=h,e[31]=p,e[32]=x,e[33]=c,e[34]=g,e[35]=y,e[36]=r,e[37]=m,e[38]=w,e[39]=L):L=e[39];let _;return e[40]!==C||e[41]!==L?(_=A(Ee,{children:[C,L]}),e[40]=C,e[41]=L,e[42]=_):_=e[42],_},Xn=Te($e.runSql),Zn="lunora-studio-sql-split-view",eo=()=>ve(Xe[0]?.sql??""),wo=l=>{const e=K(102),{initialShardKey:t}=l,n=Oe(),r=kn(eo),{activeTab:o,output:s,patchActiveOutput:d,patchActiveTab:a,setActiveTabId:i,unlinkQuery:f}=r;let h;e[0]!==d||e[1]!==a?(h=(se,ce)=>{a({activeId:ce,sql:se}),d({chart:void 0,error:null,failed:void 0,result:null})},e[0]=d,e[1]=a,e[2]=h):h=e[2];const p=h;let x;e[3]!==p||e[4]!==f?(x={loadIntoActiveTab:p,unlinkQuery:f},e[3]=p,e[4]=f,e[5]=x):x=e[5];const c=In(x),{recordHistory:g,updateQuerySql:v}=c,y=o.sql,{activeId:b}=o,{chart:m,error:w,failed:N,result:S,running:k}=s,R=s.pane,[T,I]=re(t??""),[C,L]=We(Zn,!1),{probe:_,schema:O}=dn(T);let q;e[6]!==b||e[7]!==a||e[8]!==v?(q=se=>{a({sql:se}),b!==null&&v(b,se)},e[6]=b,e[7]=a,e[8]=v,e[9]=q):q=e[9];const E=q,M=Ut(y,O,T),D=nt(T);let $;e[10]!==D||e[11]!==d||e[12]!==S?($=()=>{S!==null&&de((async()=>{const se=await D.inferChart({columns:S.columns,rowCount:S.rowCount,types:Object.fromEntries(S.columns.map(ce=>[ce,typeof(S.rows[0]?.[ce]??"")]))});d({chart:se})})())},e[10]=D,e[11]=d,e[12]=S,e[13]=$):$=e[13];const B=$;let F;e[14]!==n||e[15]!==y||e[16]!==d||e[17]!==g||e[18]!==T?(F=async se=>{if(y.trim()==="")return;d({running:!0});const ce=se==="explain"?`EXPLAIN QUERY PLAN ${y}`:y;try{const Ie=await n.query(Xn,{sql:ce},ke(T));d({chart:void 0,error:null,failed:void 0,pane:se,result:Ie,running:!1}),tt(T),g(ce)}catch(Ie){const Ae=Ie;d({chart:void 0,error:ze(Ae),failed:{error:ze(Ae),sql:ce},pane:se,result:null,running:!1})}},e[14]=n,e[15]=y,e[16]=d,e[17]=g,e[18]=T,e[19]=F):F=e[19];const P=F;let W;e[20]!==P?(W=()=>{de(P("results"))},e[20]=P,e[21]=W):W=e[21];const Q=W;let Y;e[22]!==s.pane||e[23]!==P?(Y=()=>{de(P(s.pane))},e[22]=s.pane,e[23]=P,e[24]=Y):Y=e[24];let J;e[25]!==_||e[26]!==O||e[27]!==E||e[28]!==Y?(J={onSubmit:Y,probe:_,schema:O,setDraft:E},e[25]=_,e[26]=O,e[27]=E,e[28]=Y,e[29]=J):J=e[29];const z=fn(J),{closeAutocomplete:G}=z;let ne;e[30]!==y||e[31]!==E?(ne=()=>{E(yt(y))},e[30]=y,e[31]=E,e[32]=ne):ne=e[32];const V=ne;let X;e[33]!==G||e[34]!==i?(X=se=>{G(),i(se)},e[33]=G,e[34]=i,e[35]=X):X=e[35];const Z=X;let ee;e[36]!==d?(ee=()=>{d({pane:"results"})},e[36]=d,e[37]=ee):ee=e[37];const te=ee;let oe;e[38]!==P?(oe=()=>{de(P("explain"))},e[38]=P,e[39]=oe):oe=e[39];const ie=oe;let H;e[40]!==d?(H=()=>{d({pane:"chart"})},e[40]=d,e[41]=H):H=e[41];const j=H;let U;e[42]!==L||e[43]!==C?(U=()=>{L(!C)},e[42]=L,e[43]=C,e[44]=U):U=e[44];const ae=U,xe=C?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",Re=C?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";let me;e[45]!==b||e[46]!==c.clearHistory||e[47]!==c.deleteQuery||e[48]!==c.history||e[49]!==c.listRef||e[50]!==c.loadFromHistory||e[51]!==c.loadTemplate||e[52]!==c.newQuery||e[53]!==c.onSearchChange||e[54]!==c.queries||e[55]!==c.search||e[56]!==c.selectQuery?(me=u(Fn,{activeId:b,history:c.history,listRef:c.listRef,onClearHistory:c.clearHistory,onDelete:c.deleteQuery,onLoadHistory:c.loadFromHistory,onLoadTemplate:c.loadTemplate,onNew:c.newQuery,onSearchChange:c.onSearchChange,onSelect:c.selectQuery,queries:c.queries,search:c.search}),e[45]=b,e[46]=c.clearHistory,e[47]=c.deleteQuery,e[48]=c.history,e[49]=c.listRef,e[50]=c.loadFromHistory,e[51]=c.loadTemplate,e[52]=c.newQuery,e[53]=c.onSearchChange,e[54]=c.queries,e[55]=c.search,e[56]=c.selectQuery,e[57]=me):me=e[57];let fe;e[58]!==r||e[59]!==Z?(fe=u(Vn,{model:r,onSelect:Z}),e[58]=r,e[59]=Z,e[60]=fe):fe=e[60];let he;e[61]!==D||e[62]!==M||e[63]!==y||e[64]!==N||e[65]!==E||e[66]!==z.autocompleteState||e[67]!==z.editorRef||e[68]!==z.gutterRef||e[69]!==z.handlers||e[70]!==z.listboxId||e[71]!==z.onPickSuggestion||e[72]!==z.overlayRef||e[73]!==z.revealDiagnostic?(he=u(Bn,{assistant:D,autocomplete:z.autocompleteState,diagnostics:M,draft:y,editorRef:z.editorRef,failed:N,gutterRef:z.gutterRef,handlers:z.handlers,listboxId:z.listboxId,onGenerated:E,onPickSuggestion:z.onPickSuggestion,onRevealDiagnostic:z.revealDiagnostic,overlayRef:z.overlayRef}),e[61]=D,e[62]=M,e[63]=y,e[64]=N,e[65]=E,e[66]=z.autocompleteState,e[67]=z.editorRef,e[68]=z.gutterRef,e[69]=z.handlers,e[70]=z.listboxId,e[71]=z.onPickSuggestion,e[72]=z.overlayRef,e[73]=z.revealDiagnostic,e[74]=he):he=e[74];let pe;e[75]!==D||e[76]!==w||e[77]!==V||e[78]!==B||e[79]!==m||e[80]!==Q||e[81]!==S||e[82]!==Re||e[83]!==k||e[84]!==T||e[85]!==j||e[86]!==ie||e[87]!==te||e[88]!==C||e[89]!==R||e[90]!==ae?(pe=u(Wn,{assistant:D,chart:m,className:Re,error:w,onFormat:V,onInferChart:B,onRun:Q,onShardKeyChange:I,onShowChart:j,onShowExplain:ie,onShowResults:te,onToggleSplit:ae,pane:R,result:S,running:k,shardKey:T,splitView:C}),e[75]=D,e[76]=w,e[77]=V,e[78]=B,e[79]=m,e[80]=Q,e[81]=S,e[82]=Re,e[83]=k,e[84]=T,e[85]=j,e[86]=ie,e[87]=te,e[88]=C,e[89]=R,e[90]=ae,e[91]=pe):pe=e[91];let be;e[92]!==he||e[93]!==pe||e[94]!==xe?(be=A("div",{className:xe,children:[he,pe]}),e[92]=he,e[93]=pe,e[94]=xe,e[95]=be):be=e[95];let ge;e[96]!==fe||e[97]!==be?(ge=A("div",{className:"flex min-w-0 flex-1 flex-col",children:[fe,be]}),e[96]=fe,e[97]=be,e[98]=ge):ge=e[98];let we;return e[99]!==me||e[100]!==ge?(we=A("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[me,ge]}),e[99]=me,e[100]=ge,e[101]=we):we=e[101],we};export{wo as SqlEditorPanel};
@@ -0,0 +1 @@
1
+ import{c as G}from"react/compiler-runtime";import{useLunora as L}from"@lunora/react";import{useNavigate as Q,useRouter as q,useSearch as J}from"@tanstack/react-router";import{useState as N,useEffect as $}from"react";import{d as S}from"../packem_shared/storage-tier-DznqOf-q.js";import{i as K}from"../packem_shared/table-list-sidebar-D9Bd4qgi.js";import{useT as P}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{s as _,d as B}from"../packem_shared/data-view-params-ClrV7XgF.js";import{f}from"../packem_shared/internal-BSIsQVC6.js";import{l as z,s as O}from"../packem_shared/browser-storage-xjTyMKY0.js";import{DataBrowser as R}from"../packem_shared/DataBrowser-CZZ_WkJ-.js";import{GlobalDataBrowser as H}from"../packem_shared/GlobalDataBrowser-DpkjHfDg.js";import{jsx as v,jsxs as C}from"react/jsx-runtime";const j="lunora-studio-saved-queries",I=50,M=r=>r!==null&&typeof r=="object"&&typeof r.name=="string"&&typeof r.view=="object"&&r.view!==null,w=()=>z(j).filter(M),k=r=>{O(j,r)},U=(r,e)=>{const l=r.trim();if(l==="")return w();const o=[{name:l,view:e},...w().filter(u=>u.name!==l)].slice(0,I);return k(o),o},W=r=>{const e=w().filter(l=>l.name!==r);return k(e),e},X=r=>{const e=G(15),{onChange:l,tier:o}=r,u=P();let d;e[0]!==l?(d=y=>{l(y.target.value)},e[0]=l,e[1]=d):d=e[1];const s=d;let h;e[2]!==u?(h=u("Storage tier"),e[2]=u,e[3]=h):h=e[3];let n;e[4]!==h?(n=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:h}),e[4]=h,e[5]=n):n=e[5];const m=S[o];let i,g;e[6]===Symbol.for("react.memo_cache_sentinel")?(i=v("option",{value:"shard",children:S.shard.label}),g=v("option",{value:"global",children:S.global.label}),e[6]=i,e[7]=g):(i=e[6],g=e[7]);let c;e[8]!==s||e[9]!==m.title||e[10]!==o?(c=C("select",{className:"h-8 w-full rounded-md border border-border bg-background px-2 text-sm outline-none focus-visible:border-ring","data-testid":"table-editor-schema",id:"table-editor-schema",onChange:s,title:m.title,value:o,children:[i,g]}),e[8]=s,e[9]=m.title,e[10]=o,e[11]=c):c=e[11];let b;return e[12]!==n||e[13]!==c?(b=C("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[n,c]}),e[12]=n,e[13]=c,e[14]=b):b=e[14],b},Y=()=>{try{f(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},me=({editable:r=!1,initialShardKey:e})=>{const l=L(),o=Q(),u=q(),d=J({strict:!1}),s=_(d),h=K(d),n=()=>u.state.location.pathname.split("/").findLast(Boolean)==="data",m=s.tier??"shard",i=s.table,[g,c]=N(()=>w()),[b,y]=N(()=>new Set);$(()=>{f((async()=>{try{const t=await l.listGlobalTables();y(new Set(t.map(a=>a.name)))}catch{}})())},[l]),$(()=>{m==="shard"&&i!==void 0&&b.has(i)&&f(o({replace:!0,search:t=>({...t,schema:"global"}),to:"/data"}))},[b,o,i,m]);const D=t=>{f(o({search:a=>({...a,schema:t==="global"?"global":void 0,table:void 0}),to:"/data"}))},T=(t,a)=>{n()&&f(o({search:p=>({schema:p.schema,search:a?.search,shard:p.shard,table:t}),to:"/data"}))},V=t=>{f(o({search:a=>({...a,schema:"global",table:t}),to:"/data"}))},A=t=>{const a=B(t),{current:p}=h;(p.filters??void 0)===a.filters&&(p.order??void 0)===a.order&&(p.search??void 0)===a.search&&(p.shard??void 0)===a.shard||!n()||f(o({replace:!0,search:F=>({...F,filters:a.filters,order:a.order,search:a.search,shard:a.shard}),to:"/data"}))},E={onApplyQuery:t=>{const a=B(t.view);f(o({search:()=>({filters:a.filters,order:a.order,schema:a.schema,search:a.search,shard:a.shard,table:a.table}),to:"/data"}))},onCopyLink:Y,onDeleteQuery:t=>{c(W(t))},onSaveQuery:(t,a)=>{c(U(t,a))},saved:g},x=v(X,{onChange:D,tier:m});return m==="global"?v(H,{initialTable:i,onSelectTable:T,schemaSwitch:x}):v(R,{editable:r,globalTableNames:b,initialFilters:s.filters,initialOrderBy:s.orderBy,initialPins:d.pins,initialSearch:s.search,initialShardKey:s.shard??e,onNavigateToGlobal:V,onSelectTable:T,onViewChange:A,queryBar:E,schemaSwitch:x,tableParam:i})};export{me as TableEditor};
@@ -0,0 +1 @@
1
+ import{useState as J}from"react";import{E as S}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as C}from"../packem_shared/badge-BbuuAio7.js";import{u as j}from"../packem_shared/button-BkCrNcAs.js";import{c as I,u as K}from"../packem_shared/card-CIDGUN6K.js";import{E}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as q,d as U,m as g,p as o,f as _,u as i}from"../packem_shared/table-DdJBrClo.js";import{N as y}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as R}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as N}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as V}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as e,jsxs as n}from"react/jsx-runtime";const M="agent_threads",W="agent_messages",X=100,Y=250,Z={},Q={filters:[],limit:X,offset:0,orderBy:{column:"updatedAt",direction:"desc"},skipCount:!0,table:M},d=(s,t)=>{const a=s[t];return typeof a=="string"?a:void 0},b=(s,t)=>{const a=s[t];return typeof a=="number"?a:void 0},z=s=>{const{usage:t}=s;if(t===null||typeof t!="object")return;const{totalTokens:a}=t;return typeof a=="number"?a:void 0},ee=s=>{const{toolCalls:t}=s;return Array.isArray(t)?t.map(a=>a!==null&&typeof a=="object"?a.name:void 0).filter(a=>typeof a=="string"):[]},te=s=>{switch(s){case"awaiting_input":return"warning";case"cancelled":return"warning";case"error":return"destructive";case"running":return"info";default:return"outline"}},ae=s=>{switch(s){case"approved":return"success";case"rejected":return"destructive";default:return"warning"}},pe=({initialShardKey:s=""})=>{const t=R(),[a,w]=J(void 0),{data:p}=y(N.listTables,Z,{live:!0,shardKey:s}),P=p!==void 0,m=Array.isArray(p)&&p.some(r=>r.name===M),{data:A,error:B,errorSource:D,liveError:L}=y(N.readTablePage,Q,{enabled:m,live:!0,shardKey:s}),O={filters:[{column:"threadKey",operator:"eq",value:a??""}],limit:Y,offset:0,orderBy:{column:"seq",direction:"asc"},skipCount:!0,table:W},{data:$,error:F,errorSource:G}=y(N.readTablePage,O,{enabled:m&&a!==void 0,live:!0,shardKey:s}),f=Array.isArray(A?.rows)?A.rows:[],k=Array.isArray($?.rows)?$.rows:[],T=f.find(r=>d(r,"key")===a);let u;return P&&!m?u=e(E,{description:t("No @lunora/agent tables found in this deployment. Add lunora/agents.ts with defineAgent(...) and merge the agent schema extension to run durable AI agents."),testId:"agents-unconfigured",title:t("No agents configured")}):m&&f.length===0?u=e(E,{description:t("No agent has run yet. Start a run with ctx.agents.<name>.run(...) and its thread appears here."),testId:"agents-empty",title:t("No agent threads yet")}):u=n("div",{className:"flex flex-col gap-6",children:[e(I,{className:"overflow-hidden py-0",children:e(K,{className:"px-0",children:n(q,{"data-testid":"agents-threads-table",children:[e(U,{children:n(g,{children:[e(o,{children:t("Agent")}),e(o,{children:t("Key")}),e(o,{children:t("Status")}),e(o,{children:t("Messages")}),e(o,{children:t("Tokens")}),e(o,{children:t("Updated")}),e(o,{"aria-label":t("Actions")})]})}),e(_,{children:f.map(r=>{const l=d(r,"key")??"",c=d(r,"status"),h=z(r);return n(g,{"data-active":l===a?"":void 0,"data-testid":`agents-thread-${l}`,children:[e(i,{className:"font-mono text-xs",children:d(r,"agent")??"—"}),e(i,{className:"font-mono text-xs text-muted-foreground",children:l}),e(i,{children:e(C,{"data-testid":`agents-thread-status-${l}`,variant:te(c),children:c??"—"})}),e(i,{className:"tabular-nums",children:b(r,"messageCount")??"—"}),e(i,{className:"tabular-nums text-muted-foreground",children:h??"—"}),e(i,{className:"text-muted-foreground tabular-nums",children:V(b(r,"updatedAt"),"—")}),e(i,{className:"text-right",children:e(j,{"data-testid":`agents-thread-open-${l}`,onClick:()=>{w(l)},size:"sm",type:"button",variant:"outline",children:t("Timeline")})})]},l)})})]})})}),F!==null&&e(S,{error:G,testId:"agents-messages-error"}),a!==void 0&&e(I,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:n(K,{className:"flex flex-col gap-3 px-4 py-3",children:[n("div",{className:"flex items-center justify-between gap-2",children:[n("span",{className:"font-mono text-xs",children:[t("Timeline")," · ",a,T!==void 0&&n("span",{className:"text-muted-foreground",children:[" · ",t("Usage"),": ",z(T)??0," ",t("Tokens")]})]}),e(j,{"data-testid":"agents-thread-detail-close",onClick:()=>{w(void 0)},size:"xs",type:"button",variant:"ghost",children:t("Close")})]}),k.length===0?e("p",{className:"text-xs text-muted-foreground",children:t("This thread has no messages yet.")}):n(q,{"data-testid":"agents-messages-table",children:[e(U,{children:n(g,{children:[e(o,{children:t("Role")}),e(o,{children:t("Content")}),e(o,{children:t("Tool")}),e(o,{children:t("Approval")})]})}),e(_,{children:k.map((r,l)=>{const c=d(r,"role")??"—",h=ee(r),H=d(r,"toolName"),x=d(r,"status"),v=b(r,"seq")??l;return n(g,{"data-testid":`agents-message-${String(v)}`,children:[e(i,{className:"font-mono text-xs align-top text-muted-foreground",children:c}),e(i,{className:"max-w-md font-mono text-xs whitespace-pre-wrap break-words",children:d(r,"content")??"—"}),e(i,{className:"font-mono text-xs align-top text-muted-foreground",children:H??(h.length>0?h.join(", "):"—")}),e(i,{className:"align-top",children:x===void 0?e("span",{className:"text-xs text-muted-foreground",children:"—"}):e(C,{"data-testid":`agents-message-approval-${String(v)}`,variant:ae(x),children:x})})]},d(r,"messageKey")??`${c}:${String(v)}`)})})]})]})})]}),n("div",{className:"flex flex-col gap-6","data-testid":"lunora-agents-panel",children:[B!==null&&e(S,{error:D,testId:"agents-error"}),e("p",{className:"text-sm text-muted-foreground",children:t("Agents run as durable workflows. Each run persists a thread of assistant and tool messages; select a thread to inspect its timeline, tool calls, approvals, and token usage.")}),L!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"agents-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")}),u]})};export{pe as AgentsPanel};
@@ -0,0 +1 @@
1
+ import{c as k}from"react/compiler-runtime";import{createAnalyticsSqlClient as C}from"@lunora/bindings/analytics";import{useState as L,useMemo as v,useCallback as O,useEffect as I}from"react";import{c as N}from"../packem_shared/card-CIDGUN6K.js";import{E as T}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as M,d as _,m as x,f as q,u as D,p as $}from"../packem_shared/table-DdJBrClo.js";import{useT as R}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{b as Y,f as w,h as B}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as n,jsxs as E}from"react/jsx-runtime";const F="ANALYTICS",b=[{key:"volume",sql:a=>`SELECT blob2 AS fn, count() AS calls FROM ${a} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY calls DESC LIMIT 25`,title:"Request volume per function"},{key:"latency",sql:a=>`SELECT blob2 AS fn, quantileWeighted(0.50)(double1, _sample_interval) AS p50, quantileWeighted(0.95)(double1, _sample_interval) AS p95 FROM ${a} WHERE blob1 = 'function_call' GROUP BY fn ORDER BY p95 DESC LIMIT 25`,title:"Latency p50 / p95 per function"},{key:"hotShards",sql:a=>`SELECT blob3 AS shard, count() AS calls FROM ${a} WHERE blob1 = 'function_call' GROUP BY shard ORDER BY calls DESC LIMIT 25`,title:"Hot shards"}],W={error:null,loading:!0,result:null},U=a=>{const e=k(27),{state:y,title:u}=a,c=R(),{error:r,loading:t,result:o}=y,l=`analytics-panel-${u}`;let s;e[0]!==c||e[1]!==u?(s=c(u),e[0]=c,e[1]=u,e[2]=s):s=e[2];let i;e[3]!==s?(i=n("header",{className:"border-b border-border px-4 py-3",children:n("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s})}),e[3]=s,e[4]=i):i=e[4];let d;e[5]!==t||e[6]!==c?(d=t&&n("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-loading",children:c("Loading…")}),e[5]=t,e[6]=c,e[7]=d):d=e[7];let m;e[8]!==r||e[9]!==t?(m=!t&&r!==null&&n("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"analytics-error",role:"alert",children:r}),e[8]=r,e[9]=t,e[10]=m):m=e[10];let p;e[11]!==r||e[12]!==t||e[13]!==o||e[14]!==c?(p=!t&&r===null&&o!==null&&o.rows.length===0&&n("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"analytics-empty-rows",children:c("No data points yet.")}),e[11]=r,e[12]=t,e[13]=o,e[14]=c,e[15]=p):p=e[15];let f;e[16]!==r||e[17]!==t||e[18]!==o?(f=!t&&r===null&&o!==null&&o.rows.length>0&&E(M,{children:[n(_,{children:n(x,{children:o.columns.map(H)})}),n(q,{children:o.rows.map((S,A)=>n(x,{children:o.columns.map(g=>n(D,{className:"font-mono text-xs",children:B(S[g.name])},g.name))},A))})]}),e[16]=r,e[17]=t,e[18]=o,e[19]=f):f=e[19];let h;return e[20]!==l||e[21]!==i||e[22]!==d||e[23]!==m||e[24]!==p||e[25]!==f?(h=E(N,{className:"gap-0 py-0","data-testid":l,children:[i,d,m,p,f]}),e[20]=l,e[21]=i,e[22]=d,e[23]=m,e[24]=p,e[25]=f,e[26]=h):h=e[26],h},Z=({config:a,dataset:e=F,runQuery:y}={})=>{const u=R(),[c,r]=L({}),t=v(()=>{if(y!==void 0)return y;if(a===void 0)return null;const l=C({accountId:a.accountId,apiToken:a.apiToken});return s=>l.query(s)},[a,y]),o=O(async l=>{if(t!==null)for(const s of b){if(l.cancelled)return;r(i=>({...i,[s.key]:{error:null,loading:!0,result:null}}));try{const i=await t(s.sql(e));l.cancelled||r(d=>({...d,[s.key]:{error:null,loading:!1,result:i}}))}catch(i){l.cancelled||r(d=>({...d,[s.key]:{error:Y(i),loading:!1,result:null}}))}}},[t,e]);return I(()=>{const l={cancelled:!1};return w(o(l)),()=>{l.cancelled=!0}},[o]),t===null?n(T,{description:u("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN (Analytics Read) in your .dev.vars to enable usage panels."),icon:n("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:n("path",{d:"M5 20V10m6.5 10V4M18 20v-7M3 20h18"})}),testId:"analytics-not-configured",title:u("Analytics is not configured.")}):n("div",{className:"flex flex-col gap-4","data-testid":"lunora-analytics-panel",children:b.map(l=>n(U,{state:c[l.key]??W,title:l.title},l.key))})};function H(a){return n($,{children:a.name},a.name)}export{Z as AnalyticsPanel};
@@ -0,0 +1 @@
1
+ import{c as P}from"react/compiler-runtime";import{useState as k}from"react";import{E as q}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as _}from"../packem_shared/badge-BbuuAio7.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as D,u as H}from"../packem_shared/card-CIDGUN6K.js";import{E as M}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as O}from"../packem_shared/input-JHu63lTv.js";import{n as R,d as U,m as T,p as w,f as W,u as $}from"../packem_shared/table-DdJBrClo.js";import{N as B}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as J}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{i as K}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";const ce=()=>{const e=P(39),t=G(),[l,j]=k("");let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y={},e[0]=y):y=e[0];const{data:b,error:s,errorSource:E,isLoading:S,refetch:A}=B(J.getAuthAuditLog,y);let C;if(e[1]!==b?.entries||e[2]!==l){const a=b?.entries??[],x=l.trim().toLowerCase();C=x===""?a:a.filter(N=>N.event.toLowerCase().includes(x)||(N.actorId??"").toLowerCase().includes(x)||(N.actorEmail??"").toLowerCase().includes(x)||(N.ip??"").toLowerCase().includes(x)||N.outcome.toLowerCase().includes(x)),e[1]=b?.entries,e[2]=l,e[3]=C}else C=e[3];const o=C;let I;e[4]===Symbol.for("react.memo_cache_sentinel")?(I=a=>{j(a.target.value)},e[4]=I):I=e[4];const F=I;let n;e[5]!==t?(n=t("Filter security events"),e[5]=t,e[6]=n):n=e[6];let c;e[7]!==t?(c=t("filter event, actor, IP"),e[7]=t,e[8]=c):c=e[8];let d;e[9]!==l||e[10]!==n||e[11]!==c?(d=r(O,{"aria-label":n,className:"h-8 w-56","data-testid":"aa-search",onChange:F,placeholder:c,value:l}),e[9]=l,e[10]=n,e[11]=c,e[12]=d):d=e[12];let m;e[13]!==A?(m=()=>{A()},e[13]=A,e[14]=m):m=e[14];let u;e[15]!==t?(u=t("Refresh"),e[15]=t,e[16]=u):u=e[16];let h;e[17]!==m||e[18]!==u?(h=r(z,{"data-testid":"aa-refresh",onClick:m,size:"xs",type:"button",variant:"ghost",children:u}),e[17]=m,e[18]=u,e[19]=h):h=e[19];let f;e[20]!==d||e[21]!==h?(f=i("div",{className:"flex flex-wrap items-center gap-2",children:[d,h]}),e[20]=d,e[21]=h,e[22]=f):f=e[22];let p;e[23]!==s||e[24]!==E?(p=s!==null&&r(q,{error:E,testId:"aa-error"}),e[23]=s,e[24]=E,e[25]=p):p=e[25];let g;e[26]!==s||e[27]!==o.length||e[28]!==S||e[29]!==t?(g=s===null&&!S&&o.length===0&&r(M,{description:t("Authentication and security events are recorded here."),testId:"aa-empty",title:t("No security events.")}),e[26]=s,e[27]=o.length,e[28]=S,e[29]=t,e[30]=g):g=e[30];let v;e[31]!==o||e[32]!==t?(v=o.length>0&&r(D,{className:"overflow-hidden py-0",children:r(H,{className:"max-h-[30rem] overflow-auto px-0",children:i(R,{"data-testid":"aa-table",children:[r(U,{children:i(T,{children:[r(w,{children:t("time")}),r(w,{children:t("event")}),r(w,{children:t("actor")}),r(w,{children:t("ip / user agent")}),r(w,{children:t("outcome")})]})}),r(W,{children:o.map(a=>i(T,{"data-testid":"aa-row",children:[r($,{className:"text-muted-foreground tabular-nums",children:K(a.ts,"—")}),r($,{children:r(_,{variant:"secondary",children:a.event})}),r($,{className:"max-w-[24ch] truncate font-mono text-xs",title:a.actorId??void 0,children:a.actorEmail??a.actorId??r("span",{className:"text-muted-foreground",children:"—"})}),i($,{className:"max-w-[28ch] truncate text-xs text-muted-foreground",title:a.userAgent??void 0,children:[a.ip??r("span",{className:"text-muted-foreground",children:"—"}),a.userAgent!==void 0&&i("span",{className:"ml-1 opacity-70",children:["· ",a.userAgent]})]}),r($,{children:r(_,{variant:a.outcome==="failure"?"destructive":"outline",children:t(a.outcome)})})]},a.seq))})]})})}),e[31]=o,e[32]=t,e[33]=v):v=e[33];let L;return e[34]!==p||e[35]!==g||e[36]!==v||e[37]!==f?(L=i("div",{className:"flex flex-col gap-4","data-testid":"lunora-auth-audit",children:[f,p,g,v]}),e[34]=p,e[35]=g,e[36]=v,e[37]=f,e[38]=L):L=e[38],L};export{ce as AuthAuditPanel};
@@ -0,0 +1 @@
1
+ import{c as N}from"react/compiler-runtime";import{useLunora as $}from"@lunora/react";import{g as x}from"../packem_shared/badge-BbuuAio7.js";import{c as w,u as I}from"../packem_shared/card-CIDGUN6K.js";import{O as S}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as A}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{jsx as t,jsxs as o,Fragment as y}from"react/jsx-runtime";const j=[{key:"accounts",label:"Accounts"},{key:"admin",label:"Admin"},{key:"organization",label:"Organizations"},{key:"passkey",label:"Passkeys"},{key:"twoFactor",label:"Two-factor"}],v=e=>{if(e===void 0)return"—";const i=[[86400,"d"],[3600,"h"],[60,"m"]];for(const[a,d]of i)if(e>=a&&e%a===0)return`${String(e/a)}${d}`;return`${String(e)}s`},h=e=>{const i=N(8),{children:a,heading:d,testId:s}=e;let l;i[0]!==d?(l=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d})}),i[0]=d,i[1]=l):l=i[1];let n;i[2]!==a?(n=t(I,{className:"p-3",children:a}),i[2]=a,i[3]=n):n=i[3];let u;return i[4]!==l||i[5]!==n||i[6]!==s?(u=o(w,{className:"gap-0 py-0","data-testid":s,children:[l,n]}),i[4]=l,i[5]=n,i[6]=s,i[7]=u):u=i[7],u},c=e=>{const i=N(7),{label:a,value:d}=e;let s;i[0]!==a?(s=t("span",{className:"text-sm",children:a}),i[0]=a,i[1]=s):s=i[1];let l;i[2]!==d?(l=t("span",{className:"text-sm text-muted-foreground tabular-nums",children:d}),i[2]=d,i[3]=l):l=i[3];let n;return i[4]!==s||i[5]!==l?(n=o("div",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs",children:[s,l]}),i[4]=s,i[5]=l,i[6]=n):n=i[6],n},M=()=>{const e=N(20),i=$(),a=A();let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=["lunora-auth-config"],e[0]=d):d=e[0];let s;e[1]!==i?(s=()=>i.getAuthConfig(),e[1]=i,e[2]=s):s=e[2];const{data:l,error:n}=S(d,s);let u;e[3]!==a?(u=r=>t(x,{variant:r?"success":"outline",children:a(r?"Enabled":"Disabled")}),e[3]=a,e[4]=u):u=e[4];const m=u;let g;e[5]!==n?(g=n!==null&&t("p",{className:"px-4 py-8 text-center text-sm text-destructive","data-testid":"auth-config-error",role:"alert",children:n}),e[5]=n,e[6]=g):g=e[6];let p;e[7]!==l||e[8]!==n||e[9]!==a?(p=n===null&&l===void 0&&t("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"auth-config-loading",children:a("Loading auth configuration…")}),e[7]=l,e[8]=n,e[9]=a,e[10]=p):p=e[10];let f;e[11]!==l||e[12]!==n||e[13]!==m||e[14]!==a?(f=n===null&&l!==void 0&&o(y,{children:[t(h,{heading:a("Enabled capabilities"),testId:"auth-config-capabilities",children:t("ul",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:j.map(r=>{const k=l.capabilities[r.key];return o("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-cap-${r.key}`,children:[t("span",{className:"text-sm",children:a(r.label)}),m(k)]},r.key)})})}),t(h,{heading:a("Plugins"),testId:"auth-config-plugins",children:l.plugins.length===0?t("p",{className:"text-sm text-muted-foreground",children:a("No plugins enabled.")}):t("div",{className:"flex flex-wrap gap-2",children:l.plugins.map(P)})}),t(h,{heading:a("Sign-in methods"),testId:"auth-config-signin",children:o("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Email & password"),value:m(l.emailAndPassword)}),t(c,{label:a("Social providers"),value:l.socialProviders.length===0?a("None"):t("span",{className:"flex flex-wrap justify-end gap-1",children:l.socialProviders.map(z)})})]})}),l.organization.enabled&&t(h,{heading:a("Organizations"),testId:"auth-config-org",children:o("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Teams"),value:m(l.organization.teams)}),t(c,{label:a("Custom roles"),value:m(l.organization.roles)})]})}),t(h,{heading:a("Session policy"),testId:"auth-config-session",children:o("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Expires in"),value:v(l.session.expiresIn)}),t(c,{label:a("Refresh after"),value:v(l.session.updateAge)}),t(c,{label:a("Fresh window"),value:v(l.session.freshAge)}),t(c,{label:a("Cookie cache"),value:m(l.session.cookieCache===!0)})]})}),t(h,{heading:a("Rate limit"),testId:"auth-config-ratelimit",children:o("div",{className:"flex flex-col gap-2",children:[t(c,{label:a("Status"),value:m(l.rateLimit.enabled)}),l.rateLimit.enabled&&o(y,{children:[t(c,{label:a("Max requests"),value:l.rateLimit.max??"—"}),t(c,{label:a("Window"),value:v(l.rateLimit.window)})]})]})}),l.userFields.length>0&&t(h,{heading:a("Plugin user fields"),testId:"auth-config-user-fields",children:t("ul",{className:"flex flex-col gap-2",children:l.userFields.map(r=>o("li",{className:"flex items-center justify-between gap-2 rounded-xl border border-border bg-card p-2 shadow-xs","data-testid":`auth-config-user-field-${r.name}`,children:[o("span",{className:"flex flex-col",children:[t("span",{className:"font-mono text-xs",children:r.name}),r.plugin!==void 0&&t("span",{className:"text-[11px] text-muted-foreground",children:r.plugin})]}),o("span",{className:"flex items-center gap-1",children:[t(x,{variant:"outline",children:r.type}),r.required&&t(x,{variant:"secondary",children:a("required")}),r.unique&&t(x,{variant:"secondary",children:a("unique")})]})]},r.name))})}),t(w,{className:"gap-0 py-0",children:t("p",{className:"px-4 py-3 text-xs text-muted-foreground","data-testid":"auth-config-note",children:a("OAuth providers, email templates, and rate limits are configured at deploy time in the better-auth setup and aren't editable here. See the Mail tab for email output.")})})]}),e[11]=l,e[12]=n,e[13]=m,e[14]=a,e[15]=f):f=e[15];let b;return e[16]!==g||e[17]!==p||e[18]!==f?(b=o("div",{className:"flex flex-col gap-4","data-testid":"auth-config",children:[g,p,f]}),e[16]=g,e[17]=p,e[18]=f,e[19]=b):b=e[19],b};function P(e){return t(x,{"data-testid":`auth-config-plugin-${e}`,variant:"outline",children:e},e)}function z(e){return t(x,{"data-testid":`auth-config-provider-${e}`,variant:"outline",children:e},e)}export{M as AuthConfigPanel};
@@ -0,0 +1 @@
1
+ import{c as y}from"react/compiler-runtime";import{useLunora as b}from"@lunora/react";import{u as S}from"../packem_shared/button-BkCrNcAs.js";import{c as k,u as w}from"../packem_shared/card-CIDGUN6K.js";import{E as I}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as j,d as E,m as g,p as c,f as R,u as m}from"../packem_shared/table-DdJBrClo.js";import{O as T}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as _}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{useT as z}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{i as B,f as C}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as s,jsxs as A}from"react/jsx-runtime";const v=200,Q=()=>{const e=y(21),a=b(),t=z();let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=["lunora-auth-sessions",v],e[0]=h):h=e[0];let u;e[1]!==a?(u=()=>a.listAuthSessions({limit:v}),e[1]=a,e[2]=u):u=e[2];const o=T(h,u),{error:p}=o,r=o.data?.rows??null;let f;e[3]!==o?(f=()=>{o.refetch()},e[3]=o,e[4]=f):f=e[4],_(f,!0);let x;e[5]!==a||e[6]!==o?(x=i=>{C((async()=>{await a.revokeAuthSession({sessionId:i}),o.refetch()})())},e[5]=a,e[6]=o,e[7]=x):x=e[7];const N=x;let n;e[8]!==p?(n=p!==null&&s("p",{className:"text-sm text-destructive","data-testid":"auth-sessions-error",role:"alert",children:p}),e[8]=p,e[9]=n):n=e[9];let l;e[10]!==r||e[11]!==t?(l=r!==null&&r.length===0&&s(I,{testId:"auth-sessions-empty",title:t("No active sessions.")}),e[10]=r,e[11]=t,e[12]=l):l=e[12];let d;e[13]!==N||e[14]!==r||e[15]!==t?(d=r!==null&&r.length>0&&s(k,{className:"overflow-hidden py-0",children:s(w,{className:"px-0",children:A(j,{"data-testid":"auth-sessions-table",children:[s(E,{children:A(g,{children:[s(c,{children:t("user")}),s(c,{children:t("expires")}),s(c,{children:t("ip")}),s(c,{children:t("user agent")}),s(c,{children:t("impersonated by")}),s(c,{"aria-label":t("Actions")})]})}),s(R,{children:r.map(i=>A(g,{"data-testid":`auth-session-${i.id}`,children:[s(m,{className:"font-mono text-xs",children:i.userId}),s(m,{className:"text-muted-foreground tabular-nums",children:B(i.expiresAt)}),s(m,{children:i.ipAddress??""}),s(m,{className:"max-w-40 truncate",children:i.userAgent??""}),s(m,{className:"font-mono text-xs",children:i.impersonatedBy??""}),s(m,{children:s(S,{"data-testid":`auth-session-revoke-${i.id}`,onClick:()=>{N(i.id)},size:"xs",type:"button",variant:"ghost",children:t("Revoke")})})]},i.id))})]})})}),e[13]=N,e[14]=r,e[15]=t,e[16]=d):d=e[16];let $;return e[17]!==n||e[18]!==l||e[19]!==d?($=A("div",{className:"flex flex-col gap-4","data-testid":"auth-sessions",children:[n,l,d]}),e[17]=n,e[18]=l,e[19]=d,e[20]=$):$=e[20],$};export{Q as AuthSessionsPanel};
@@ -0,0 +1 @@
1
+ import{c as $}from"react/compiler-runtime";import{L as w}from"../packem_shared/live-status-CmuRLFKf.js";import{g as C}from"../packem_shared/badge-BbuuAio7.js";import{c as S,u as b}from"../packem_shared/card-CIDGUN6K.js";import{E}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as I,d as L,m as y,p as l,f as D,u as m}from"../packem_shared/table-DdJBrClo.js";import{N as k}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as A}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as O}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as n,jsxs as h}from"react/jsx-runtime";const N="container:",T={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},_=e=>{const t=e.indexOf(":");if(t===-1)return{event:e.trim()};const r=e.slice(t+1).trim(),a=e.slice(0,t).trim();return r===""?{event:a}:{detail:r,event:a}},j=e=>{const t=new Map;for(const r of e){const a=r.functionPath??"";if(!a.startsWith(N))continue;const i=a.slice(N.length);if(i==="")continue;const s=JSON.stringify([i,r.instance??""]),o=t.get(s);if(o!==void 0&&o.timestamp>=r.timestamp)continue;const{detail:p,event:c}=_(r.message);t.set(s,{detail:p,event:c,exitCode:r.exitCode,instance:r.instance,level:r.level,name:i,state:T[c]??"unknown",timestamp:r.timestamp})}return[...t.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},M={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},P=e=>{const{entries:t}=e??{};return Array.isArray(t)?t:[]},H=()=>{const e=$(19),t=A();let r,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={},a={live:!0,shardKey:""},e[0]=r,e[1]=a):(r=e[0],a=e[1]);const{data:i,error:s,liveError:o}=k(O.getLogs,r,a),p=i!==void 0;let c;if(e[2]!==i||e[3]!==s||e[4]!==o||e[5]!==p||e[6]!==t){const g=j(P(i));let x;e[8]!==s?(x=s!==null&&n("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:s}),e[8]=s,e[9]=x):x=e[9];let d;e[10]!==t?(d=t("Cloudflare Containers are observed from their lifecycle log stream. This shows the current state per instance — ports and health checks aren't carried in that stream."),e[10]=t,e[11]=d):d=e[11];let u;e[12]!==d?(u=n("p",{className:"text-sm text-muted-foreground",children:d}),e[12]=d,e[13]=u):u=e[13];let f;e[14]!==o?(f=n(w,{message:o,prefix:"containers"}),e[14]=o,e[15]=f):f=e[15];let v;e[16]!==u||e[17]!==f?(v=h("div",{className:"flex flex-wrap items-center gap-2",children:[u,f]}),e[16]=u,e[17]=f,e[18]=v):v=e[18],c=h("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[x,v,p&&g.length===0?n(E,{description:t("No container lifecycle activity yet. Instances declared with defineContainer show up here once they start, sleep, stop, or error."),testId:"containers-empty",title:t("No container activity")}):n(S,{className:"overflow-hidden py-0",children:n(b,{className:"px-0",children:h(I,{"data-testid":"containers-table",children:[n(L,{children:h(y,{children:[n(l,{children:t("Container")}),n(l,{children:t("Instance")}),n(l,{children:t("State")}),n(l,{children:t("Last event")}),n(l,{children:t("Detail")}),n(l,{children:t("Exit")}),n(l,{children:t("When")})]})}),n(D,{children:g.map(W)})]})})})]}),e[2]=i,e[3]=s,e[4]=o,e[5]=p,e[6]=t,e[7]=c}else c=e[7];return c};function W(e){return h(y,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[n(m,{className:"font-mono text-xs",children:e.name}),n(m,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"—"}),n(m,{children:n(C,{variant:M[e.state],children:e.state})}),n(m,{className:"font-mono text-xs text-muted-foreground",children:e.event}),n(m,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"—"}),n(m,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"—"}),n(m,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}export{H as ContainersPanel};
@@ -0,0 +1 @@
1
+ import{c as j}from"react/compiler-runtime";import{useState as z,useEffect as V}from"react";import{I as B}from"../packem_shared/result-chart-DzJOVsaw.js";import{A as D}from"../packem_shared/alert-CVcOFuDR.js";import{u as I}from"../packem_shared/button-BkCrNcAs.js";import{c as F,u as Q,f as U,n as Z}from"../packem_shared/card-CIDGUN6K.js";import{E as H}from"../packem_shared/empty-state-Cg7t_8qu.js";import{useT as T}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{u as J,n as P}from"../packem_shared/browser-storage-xjTyMKY0.js";import{useLunora as X}from"@lunora/react";import{ADMIN_FUNCTIONS as G}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{d as Y,b as ee,f as te,g as le}from"../packem_shared/internal-BSIsQVC6.js";import{jsx as m,jsxs as _}from"react/jsx-runtime";const de=le(G.runSql),re=(A,e)=>{const t=j(11),c=X(),[l,d]=z(void 0),[s,r]=z(void 0),[a,$]=z(!0);let n;t[0]!==c||t[1]!==e||t[2]!==A?(n=async u=>{$(!0);try{const C=await c.query(de,{sql:A},Y(e));u.cancelled||(d(C),r(void 0))}catch(C){const E=C;u.cancelled||(d(void 0),r(ee(E)))}u.cancelled||$(!1)},t[0]=c,t[1]=e,t[2]=A,t[3]=n):n=t[3];const k=n;let y,S;t[4]!==k?(y=()=>{const u={cancelled:!1};return te(k(u)),()=>{u.cancelled=!0}},S=[k],t[4]=k,t[5]=y,t[6]=S):(y=t[5],S=t[6]),V(y,S);let h;return t[7]!==s||t[8]!==a||t[9]!==l?(h={error:s,loading:a,result:l},t[7]=s,t[8]=a,t[9]=l,t[10]=h):h=t[10],h},se="lunora-studio-dashboards",O={shardKey:"",sql:"",title:""},ie=A=>{const e=j(54),{onEdit:t,onRemove:c,widget:l}=A,d=T(),{error:s,loading:r,result:a}=re(l.sql,l.shardKey??"");let $;e[0]!==t||e[1]!==l.id?($=()=>{t(l.id)},e[0]=t,e[1]=l.id,e[2]=$):$=e[2];const n=$;let k;e[3]!==c||e[4]!==l.id?(k=()=>{c(l.id)},e[3]=c,e[4]=l.id,e[5]=k):k=e[5];const y=k,S=`dashboards-widget-${l.id}`;let h;e[6]!==l.title?(h=m(U,{className:"min-w-0 truncate",title:l.title,children:l.title}),e[6]=l.title,e[7]=h):h=e[7];let u;e[8]!==d?(u=d("Edit widget"),e[8]=d,e[9]=u):u=e[9];const C=`dashboards-widget-edit-${l.id}`;let E;e[10]!==d?(E=d("Edit widget"),e[10]=d,e[11]=E):E=e[11];let K;e[12]===Symbol.for("react.memo_cache_sentinel")?(K=m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:m("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=K):K=e[12];let N;e[13]!==n||e[14]!==u||e[15]!==C||e[16]!==E?(N=m(I,{"aria-label":u,"data-testid":C,onClick:n,size:"icon-xs",title:E,type:"button",variant:"ghost",children:K}),e[13]=n,e[14]=u,e[15]=C,e[16]=E,e[17]=N):N=e[17];let x;e[18]!==d?(x=d("Remove widget"),e[18]=d,e[19]=x):x=e[19];const R=`dashboards-widget-remove-${l.id}`;let g;e[20]!==d?(g=d("Remove widget"),e[20]=d,e[21]=g):g=e[21];let w;e[22]===Symbol.for("react.memo_cache_sentinel")?(w=m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:m("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=w):w=e[22];let f;e[23]!==y||e[24]!==x||e[25]!==R||e[26]!==g?(f=m(I,{"aria-label":x,"data-testid":R,onClick:y,size:"icon-xs",title:g,type:"button",variant:"ghost",children:w}),e[23]=y,e[24]=x,e[25]=R,e[26]=g,e[27]=f):f=e[27];let b;e[28]!==f||e[29]!==N?(b=_("div",{className:"flex shrink-0 items-center gap-1",children:[N,f]}),e[28]=f,e[29]=N,e[30]=b):b=e[30];let p;e[31]!==b||e[32]!==h?(p=_(Z,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[h,b]}),e[31]=b,e[32]=h,e[33]=p):p=e[33];let v;e[34]!==s||e[35]!==l.id?(v=s!==void 0&&m(D,{className:"font-mono text-xs",testId:`dashboards-widget-error-${l.id}`,variant:"destructive",children:s}),e[34]=s,e[35]=l.id,e[36]=v):v=e[36];let L;e[37]!==s||e[38]!==r||e[39]!==a||e[40]!==d||e[41]!==l.id?(L=s===void 0&&r&&a===void 0&&m("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${l.id}`,children:d("Running…")}),e[37]=s,e[38]=r,e[39]=a,e[40]=d,e[41]=l.id,e[42]=L):L=e[42];let i;e[43]!==s||e[44]!==a?(i=s===void 0&&a!==void 0&&m(B,{result:a}),e[43]=s,e[44]=a,e[45]=i):i=e[45];let o;e[46]!==v||e[47]!==L||e[48]!==i?(o=_(Q,{className:"min-h-32 py-2",children:[v,L,i]}),e[46]=v,e[47]=L,e[48]=i,e[49]=o):o=e[49];let q;return e[50]!==p||e[51]!==o||e[52]!==S?(q=_(F,{"data-testid":S,children:[p,o]}),e[50]=p,e[51]=o,e[52]=S,e[53]=q):q=e[53],q},ae=A=>{const e=j(58),{draft:t,editing:c,onCancel:l,onChange:d,onSubmit:s}=A,r=T();let a;e[0]!==t||e[1]!==d?(a=M=>{d({...t,title:M.target.value})},e[0]=t,e[1]=d,e[2]=a):a=e[2];const $=a;let n;e[3]!==t||e[4]!==d?(n=M=>{d({...t,sql:M.target.value})},e[3]=t,e[4]=d,e[5]=n):n=e[5];const k=n;let y;e[6]!==t||e[7]!==d?(y=M=>{d({...t,shardKey:M.target.value})},e[6]=t,e[7]=d,e[8]=y):y=e[8];const S=y;let h;e[9]!==s?(h=()=>{s()},e[9]=s,e[10]=h):h=e[10];const u=h;let C;e[11]!==t.sql||e[12]!==t.title?(C=t.title.trim()!==""&&t.sql.trim()!=="",e[11]=t.sql,e[12]=t.title,e[13]=C):C=e[13];const E=C;let K;e[14]!==r?(K=r("Widget title"),e[14]=r,e[15]=K):K=e[15];let N;e[16]!==r?(N=r("Widget title"),e[16]=r,e[17]=N):N=e[17];let x;e[18]!==t.title||e[19]!==$||e[20]!==K||e[21]!==N?(x=m("input",{"aria-label":K,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:$,placeholder:N,type:"text",value:t.title}),e[18]=t.title,e[19]=$,e[20]=K,e[21]=N,e[22]=x):x=e[22];let R;e[23]!==r?(R=r("SQL query"),e[23]=r,e[24]=R):R=e[24];let g;e[25]!==t.sql||e[26]!==k||e[27]!==R?(g=m("textarea",{"aria-label":R,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:k,placeholder:"SELECT author, COUNT(*) AS messages FROM …",spellCheck:!1,value:t.sql}),e[25]=t.sql,e[26]=k,e[27]=R,e[28]=g):g=e[28];let w;e[29]!==r?(w=r("Shard key (optional)"),e[29]=r,e[30]=w):w=e[30];let f;e[31]!==r?(f=r("Shard key (optional)"),e[31]=r,e[32]=f):f=e[32];let b;e[33]!==t.shardKey||e[34]!==S||e[35]!==w||e[36]!==f?(b=m("input",{"aria-label":w,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:S,placeholder:f,type:"text",value:t.shardKey}),e[33]=t.shardKey,e[34]=S,e[35]=w,e[36]=f,e[37]=b):b=e[37];let p;e[38]!==r?(p=r("Cancel"),e[38]=r,e[39]=p):p=e[39];let v;e[40]!==l||e[41]!==p?(v=m(I,{"data-testid":"dashboards-form-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:p}),e[40]=l,e[41]=p,e[42]=v):v=e[42];const L=!E;let i;e[43]!==c||e[44]!==r?(i=r(c?"Save widget":"Add widget"),e[43]=c,e[44]=r,e[45]=i):i=e[45];let o;e[46]!==u||e[47]!==L||e[48]!==i?(o=m(I,{"data-testid":"dashboards-form-save",disabled:L,onClick:u,size:"sm",type:"button",children:i}),e[46]=u,e[47]=L,e[48]=i,e[49]=o):o=e[49];let q;e[50]!==v||e[51]!==o?(q=_("div",{className:"flex items-center justify-end gap-2",children:[v,o]}),e[50]=v,e[51]=o,e[52]=q):q=e[52];let W;return e[53]!==g||e[54]!==b||e[55]!==q||e[56]!==x?(W=m(F,{"data-testid":"dashboards-form",children:_(Q,{className:"flex flex-col gap-3 py-4",children:[x,g,b,q]})}),e[53]=g,e[54]=b,e[55]=q,e[56]=x,e[57]=W):W=e[57],W},we=A=>{const e=j(39),{initialShardKey:t}=A,c=T(),[l,d]=J(se),[s,r]=z(O),[a,$]=z(null),[n,k]=z(!1);let y;e[0]!==t?(y=()=>{$(null),r({...O,shardKey:t??""}),k(!0)},e[0]=t,e[1]=y):y=e[1];const S=y;let h;e[2]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{k(!1),$(null),r(O)},e[2]=h):h=e[2];const u=h;let C;e[3]!==l?(C=i=>{const o=l.find(q=>q.id===i);o!==void 0&&($(i),r({shardKey:o.shardKey??"",sql:o.sql,title:o.title}),k(!0))},e[3]=l,e[4]=C):C=e[4];const E=C;let K;e[5]!==d?(K=i=>{d(o=>o.filter(q=>q.id!==i))},e[5]=d,e[6]=K):K=e[6];const N=K;let x;e[7]!==s.shardKey||e[8]!==s.sql||e[9]!==s.title||e[10]!==a||e[11]!==d?(x=()=>{const i=s.title.trim(),o=s.sql.trim();if(i===""||o==="")return;const q=s.shardKey.trim();d(a===null?W=>[...W,{id:P("w"),shardKey:q,sql:o,title:i}]:W=>W.map(M=>M.id===a?{...M,shardKey:q,sql:o,title:i}:M)),u()},e[7]=s.shardKey,e[8]=s.sql,e[9]=s.title,e[10]=a,e[11]=d,e[12]=x):x=e[12];const R=x;let g;e[13]!==c?(g=c("Chart widgets backed by saved read-only SQL queries."),e[13]=c,e[14]=g):g=e[14];let w;e[15]!==g?(w=m("p",{className:"text-sm text-muted-foreground",children:g}),e[15]=g,e[16]=w):w=e[16];let f;e[17]!==n||e[18]!==S||e[19]!==c?(f=!n&&m(I,{"data-testid":"dashboards-add",onClick:S,size:"sm",type:"button",children:c("Add widget")}),e[17]=n,e[18]=S,e[19]=c,e[20]=f):f=e[20];let b;e[21]!==w||e[22]!==f?(b=_("div",{className:"flex items-center justify-between",children:[w,f]}),e[21]=w,e[22]=f,e[23]=b):b=e[23];let p;e[24]!==s||e[25]!==a||e[26]!==n||e[27]!==R?(p=n&&m(ae,{draft:s,editing:a!==null,onCancel:u,onChange:r,onSubmit:R}),e[24]=s,e[25]=a,e[26]=n,e[27]=R,e[28]=p):p=e[28];let v;e[29]!==n||e[30]!==E||e[31]!==N||e[32]!==c||e[33]!==l?(v=l.length===0&&!n?m(H,{description:c("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:c("No widgets yet")}):m("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:l.map(i=>m(ie,{onEdit:E,onRemove:N,widget:i},i.id))}),e[29]=n,e[30]=E,e[31]=N,e[32]=c,e[33]=l,e[34]=v):v=e[34];let L;return e[35]!==p||e[36]!==v||e[37]!==b?(L=_("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[b,p,v]}),e[35]=p,e[36]=v,e[37]=b,e[38]=L):L=e[38],L};export{we as default};
@@ -0,0 +1 @@
1
+ import{c as P}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-t6cpEi0z.js";import{ShardInput as A}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as R}from"../packem_shared/stat-card-fm_TF1mo.js";import{g as M}from"../packem_shared/badge-BbuuAio7.js";import{c as _}from"../packem_shared/card-CIDGUN6K.js";import{E as L}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as W,d as q,m as E,p as K,f as B,u as T}from"../packem_shared/table-DdJBrClo.js";import{N as H}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useAutoRefresh as J}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import{S as O}from"../packem_shared/use-shard-key-B2JtNa5m.js";import{useT as U}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as V}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as a,jsxs as x,Fragment as X}from"react/jsx-runtime";const D=n=>`${n.toString()} ms`,z=n=>n.totalConnections===0&&n.shapePoke.passes===0&&n.whisper.passes===0,F=n=>{const e=P(48),{counters:r,includeTiming:s,prefix:l,t:o,title:$}=n,v=`${l}-section`;let p;e[0]!==$?(p=a("h3",{className:"text-sm font-medium text-foreground",children:$}),e[0]=$,e[1]=p):p=e[1];const t=`${l}-stats`;let i;e[2]!==o?(i=o("Passes"),e[2]=o,e[3]=i):i=e[3];const I=`${l}-passes`;let b;e[4]!==r.passes||e[5]!==i||e[6]!==I?(b=a(R,{label:i,testId:I,value:r.passes}),e[4]=r.passes,e[5]=i,e[6]=I,e[7]=b):b=e[7];let f;e[8]!==o?(f=o("Sockets iterated"),e[8]=o,e[9]=f):f=e[9];const y=`${l}-iterated`;let c;e[10]!==r.socketsIterated||e[11]!==f||e[12]!==y?(c=a(R,{label:f,testId:y,value:r.socketsIterated}),e[10]=r.socketsIterated,e[11]=f,e[12]=y,e[13]=c):c=e[13];let d;e[14]!==o?(d=o("Delivered"),e[14]=o,e[15]=d):d=e[15];const g=`${l}-delivered`;let m;e[16]!==r.socketsDelivered||e[17]!==d||e[18]!==g?(m=a(R,{label:d,testId:g,value:r.socketsDelivered}),e[16]=r.socketsDelivered,e[17]=d,e[18]=g,e[19]=m):m=e[19];let u;e[20]!==o?(u=o("Peak width"),e[20]=o,e[21]=u):u=e[21];const k=`${l}-peak`;let h;e[22]!==r.peakSocketsIterated||e[23]!==u||e[24]!==k?(h=a(R,{label:u,testId:k,value:r.peakSocketsIterated}),e[22]=r.peakSocketsIterated,e[23]=u,e[24]=k,e[25]=h):h=e[25];let N;e[26]!==r.totalMs||e[27]!==s||e[28]!==l||e[29]!==o?(N=s&&a(R,{label:o("Total time"),testId:`${l}-total-ms`,value:D(r.totalMs)}),e[26]=r.totalMs,e[27]=s,e[28]=l,e[29]=o,e[30]=N):N=e[30];let S;e[31]!==r.maxMs||e[32]!==s||e[33]!==l||e[34]!==o?(S=s&&a(R,{label:o("Max time"),testId:`${l}-max-ms`,value:D(r.maxMs)}),e[31]=r.maxMs,e[32]=s,e[33]=l,e[34]=o,e[35]=S):S=e[35];let C;e[36]!==m||e[37]!==h||e[38]!==N||e[39]!==S||e[40]!==t||e[41]!==b||e[42]!==c?(C=x("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":t,children:[b,c,m,h,N,S]}),e[36]=m,e[37]=h,e[38]=N,e[39]=S,e[40]=t,e[41]=b,e[42]=c,e[43]=C):C=e[43];let w;return e[44]!==v||e[45]!==C||e[46]!==p?(w=x("section",{className:"flex flex-col gap-2","data-testid":v,children:[p,C]}),e[44]=v,e[45]=C,e[46]=p,e[47]=w):w=e[47],w},me=n=>{const e=P(31),{initialShardKey:r}=n,s=U(),{queryShardKey:l,setShardKey:o,shardKey:$}=O(r);let v;e[0]===Symbol.for("react.memo_cache_sentinel")?(v={},e[0]=v):v=e[0];let p;e[1]!==l?(p={keepPreviousData:!0,shardKey:l},e[1]=l,e[2]=p):p=e[2];const{data:t,error:i,errorSource:I,refetch:b}=H(V.getFanoutMetrics,v,p);J(b,!0);let f;e[3]!==t?(f=t!==void 0&&z(t),e[3]=t,e[4]=f):f=e[4];const y=f;let c;e[5]!==o||e[6]!==$?(c=a(A,{onChange:o,testId:"fanout-shard-input",value:$}),e[5]=o,e[6]=$,e[7]=c):c=e[7];let d;e[8]!==t||e[9]!==s?(d=t!==void 0&&x("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[t.promoted&&a(M,{"data-testid":"fanout-promoted",variant:t.relayCount>=t.maxRelays?"destructive":"default",children:t.relayCount>=t.maxRelays?s("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:t.maxRelays,relayCount:t.relayCount}):s("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:t.maxRelays,relayCount:t.relayCount})}),a(M,{variant:"secondary",children:s("{count} connections",{count:t.totalConnections})}),a(M,{variant:"secondary",children:s("peak {count} subscribers",{count:t.peakSubscribers})})]}),e[8]=t,e[9]=s,e[10]=d):d=e[10];let g;e[11]!==c||e[12]!==d?(g=x("div",{className:"flex flex-wrap items-center gap-2",children:[c,d]}),e[11]=c,e[12]=d,e[13]=g):g=e[13];let m;e[14]!==i||e[15]!==I?(m=i!==null&&a(j,{error:I,testId:"fanout-error"}),e[14]=i,e[15]=I,e[16]=m):m=e[16];let u;e[17]!==i||e[18]!==y||e[19]!==s?(u=i===null&&y&&a(L,{description:s("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:a("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:a("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:s("No fan-out activity yet.")}),e[17]=i,e[18]=y,e[19]=s,e[20]=u):u=e[20];let k;e[21]!==i||e[22]!==y||e[23]!==t||e[24]!==s?(k=i===null&&t!==void 0&&!y&&x(X,{children:[t.topics.length>0&&x("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[a("h3",{className:"text-sm font-medium text-foreground",children:s("Hot topics")}),a(_,{className:"overflow-hidden py-0",children:x(W,{"data-testid":"fanout-topics-table",children:[a(q,{children:x(E,{children:[a(K,{children:s("Topic")}),a(K,{children:s("Kind")}),a(K,{className:"text-right",children:s("Subscribers")})]})}),a(B,{children:t.topics.map(G)})]})})]}),x("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[a("h2",{className:"text-sm font-medium text-muted-foreground",children:s("Fan-out cost since this instance woke")}),a(F,{counters:t.shapePoke,includeTiming:!0,prefix:"fanout-poke",t:s,title:s("Shape pokes")}),a(F,{counters:t.whisper,includeTiming:!1,prefix:"fanout-whisper",t:s,title:s("Whisper broadcasts")})]})]}),e[21]=i,e[22]=y,e[23]=t,e[24]=s,e[25]=k):k=e[25];let h;return e[26]!==g||e[27]!==m||e[28]!==u||e[29]!==k?(h=x("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[g,m,u,k]}),e[26]=g,e[27]=m,e[28]=u,e[29]=k,e[30]=h):h=e[30],h};function G(n){return x(E,{"data-testid":"fanout-topic-row",children:[a(T,{className:"font-mono text-xs",children:n.topic}),a(T,{children:a(M,{variant:"outline",children:n.kind})}),a(T,{className:"text-right font-medium tabular-nums",children:n.subscribers})]},`${n.kind}:${n.topic}`)}export{me as default};
@@ -0,0 +1 @@
1
+ import{useState as $}from"react";import{E as k}from"../packem_shared/error-alert-t6cpEi0z.js";import{g as w}from"../packem_shared/badge-BbuuAio7.js";import{c as A,u as F}from"../packem_shared/card-CIDGUN6K.js";import{E as u}from"../packem_shared/empty-state-Cg7t_8qu.js";import{p as O}from"../packem_shared/label-6uP1obNF.js";import{n as T,d as C,m as p,p as l,f as j,u as n}from"../packem_shared/table-DdJBrClo.js";import{l as E}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as I}from"../packem_shared/use-admin-query-QJ-ibl5u.js";import{useT as J}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as K}from"../packem_shared/ADMIN_FUNCTIONS-4aE59aDq.js";import{jsx as e,jsxs as i}from"react/jsx-runtime";const L=a=>{const t=a.trim();if(t.length===0)return{context:void 0,error:null};try{const o=JSON.parse(t);return o===null||typeof o!="object"||Array.isArray(o)?{context:void 0,error:"Targeting context must be a JSON object."}:{context:o,error:null}}catch{return{context:void 0,error:"Targeting context is not valid JSON."}}},V='{ "targetingKey": "user-123", "plan": "premium" }',_=a=>a.type==="object"?JSON.stringify(a.value):String(a.value),X=({initialShardKey:a=""})=>{const t=J(),[o,h]=$(""),{context:c,error:f}=L(o),x=c===void 0?{}:{context:c},{data:s,error:v,errorSource:y,liveError:N}=I(K.listFlags,x,{live:!0,shardKey:a}),g=s!==void 0,b=s?.configured??!1,m=Array.isArray(s?.flags)?[...s.flags].toSorted((r,S)=>r.key.localeCompare(S.key)):[];let d;return g&&!b?d=e(u,{description:t("No @lunora/flags provider is wired in this deployment. Add lunora/flags.ts with defineFlags({ provider }) to gate code paths on feature flags."),testId:"flags-unconfigured",title:t("No flags provider configured")}):g&&m.length===0?d=e(u,{description:t('A flags provider is configured, but no handler reads a flag yet. Call ctx.flags.boolean("key", false) in a query, mutation, or action.'),testId:"flags-empty",title:t("No flags read")}):d=e(A,{className:"overflow-hidden py-0",children:e(F,{className:"px-0",children:i(T,{"data-testid":"flags-table",children:[e(C,{children:i(p,{children:[e(l,{children:t("Key")}),e(l,{children:t("Type")}),e(l,{children:t("Value")}),e(l,{children:t("Reason")}),e(l,{children:t("Variant")})]})}),e(j,{children:m.map(r=>i(p,{"data-testid":`flags-row-${r.key}`,children:[e(n,{className:"font-mono text-xs",children:r.key}),e(n,{className:"font-mono text-xs text-muted-foreground",children:r.type}),e(n,{className:"font-mono text-xs",children:_(r)}),e(n,{children:r.errorCode===void 0?e("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"—"}):e(w,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"—"})]},r.key))})]})})}),i("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[v!==null&&e(k,{error:y,testId:"flags-error"}),e("p",{className:"text-sm text-muted-foreground",children:t('Feature flags are read in code with ctx.flags.<type>("key", default). They evaluate through the OpenFeature provider configured in lunora/flags.ts; edit the targeting context below to see how each flag resolves for a given audience.')}),i("div",{className:"flex flex-col gap-2",children:[e(O,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),e(E,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:r=>{h(r.target.value)},placeholder:V,rows:3,value:o}),f!==null&&e("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(f)}),N!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"flags-live-error",role:"alert",children:t("Live updates unavailable; showing the last evaluation.")})]}),d]})};export{X as FlagsPanel};