@lunora/studio 1.0.0-alpha.7 → 1.0.0-alpha.71

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 (295) hide show
  1. package/LICENSE.md +6 -0
  2. package/dist/index.d.ts +762 -779
  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/ApiTab.js +1 -0
  7. package/dist/packem_chunks/AuditPanel.js +1 -0
  8. package/dist/packem_chunks/DeploymentHealthPanel.js +1 -0
  9. package/dist/packem_chunks/ExportImportPanel.js +3 -0
  10. package/dist/packem_chunks/FileBrowser.js +4 -0
  11. package/dist/packem_chunks/FunctionRunner.js +1 -0
  12. package/dist/packem_chunks/FunctionStatsPanel.js +1 -0
  13. package/dist/packem_chunks/HealthPanel.js +1 -0
  14. package/dist/packem_chunks/InsightsPanel.js +1 -0
  15. package/dist/packem_chunks/LogsPanel.js +1 -0
  16. package/dist/packem_chunks/MailPanel.js +2 -0
  17. package/dist/packem_chunks/MetricsPanel.js +1 -0
  18. package/dist/packem_chunks/MigrationsPanel.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 +2 -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 +4 -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/organizations-panel.js +1 -0
  39. package/dist/packem_chunks/payments-panel.js +1 -0
  40. package/dist/packem_chunks/permissions-panel.js +1 -0
  41. package/dist/packem_chunks/queues-panel.js +1 -0
  42. package/dist/packem_chunks/rls-panel.js +1 -0
  43. package/dist/packem_chunks/schedule-panel.js +1 -0
  44. package/dist/packem_chunks/sparkline.js +1 -0
  45. package/dist/packem_chunks/storage-rules-panel.js +1 -0
  46. package/dist/packem_chunks/subscriptions-panel.js +1 -0
  47. package/dist/packem_chunks/sync-client-panel.js +1 -0
  48. package/dist/packem_chunks/traces-panel.js +1 -0
  49. package/dist/packem_chunks/users-panel.js +1 -0
  50. package/dist/packem_chunks/vector-browser.js +1 -0
  51. package/dist/packem_chunks/workflows-panel.js +1 -0
  52. package/dist/packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js +1 -0
  53. package/dist/packem_shared/ApiDocsPanel-eJYZlylw.js +2 -0
  54. package/dist/packem_shared/ApiReferencePanel-C42v1jr6.js +1 -0
  55. package/dist/packem_shared/CommandPalette-CVIaY3j8.js +1 -0
  56. package/dist/packem_shared/ConfirmButton-CTL3f3kr.js +1 -0
  57. package/dist/packem_shared/ConnectionBadge-DOk0CQWo.js +1 -0
  58. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js +1 -0
  59. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-B-hcFVoi.js +1 -0
  60. package/dist/packem_shared/DEFAULT_LOCALE-BZ4NojpD.js +1 -0
  61. package/dist/packem_shared/DataBrowser-B8J5lHjP.js +1 -0
  62. package/dist/packem_shared/DataFilters-Csb30F0C.js +1 -0
  63. package/dist/packem_shared/ErrorBoundary-DvzYskH7.js +1 -0
  64. package/dist/packem_shared/GlobalDataBrowser-RLJ6NvOs.js +1 -0
  65. package/dist/packem_shared/HomePanel-DL1HupAN.js +1 -0
  66. package/dist/packem_shared/OpenRpcReferencePanel-sGsIgYWj.js +1 -0
  67. package/dist/packem_shared/STUDIO_ROOT_CLASS-C6MccdVk.js +1 -0
  68. package/dist/packem_shared/ScheduledJobs-DUbo6epc.js +1 -0
  69. package/dist/packem_shared/ShardInput-BVn2iCU0.js +1 -0
  70. package/dist/packem_shared/Studio-BWBclm_C.js +1 -0
  71. package/dist/packem_shared/StudioApp-BFm73yVr.js +1 -0
  72. package/dist/packem_shared/StudioI18nProvider-CZ5h4nrV.js +1 -0
  73. package/dist/packem_shared/advisor-view-DaCX9Jy5.js +1 -0
  74. package/dist/packem_shared/aggregateMetrics-BNfajLa2.js +1 -0
  75. package/dist/packem_shared/alert-CVcOFuDR.js +1 -0
  76. package/dist/packem_shared/app.d-bRPJhby-.d.ts +254 -0
  77. package/dist/packem_shared/badge-BbuuAio7.js +1 -0
  78. package/dist/packem_shared/bar-chart-AryFCeoa.js +9 -0
  79. package/dist/packem_shared/browser-storage-xjTyMKY0.js +1 -0
  80. package/dist/packem_shared/button-BkCrNcAs.js +1 -0
  81. package/dist/packem_shared/card-CIDGUN6K.js +1 -0
  82. package/dist/packem_shared/cf-links-gbDy51nR.js +1 -0
  83. package/dist/packem_shared/checkbox-StT4Gob6.js +1 -0
  84. package/dist/packem_shared/data-grid-BMBKzMEJ.js +1 -0
  85. package/dist/packem_shared/data-view-params-C8T3bW1z.js +1 -0
  86. package/dist/packem_shared/dropdown-menu-C3RQ_HlW.js +2 -0
  87. package/dist/packem_shared/empty-state-Cg7t_8qu.js +1 -0
  88. package/dist/packem_shared/error-alert-B59DnrDI.js +1 -0
  89. package/dist/packem_shared/grid-features-uZCUj955.js +6 -0
  90. package/dist/packem_shared/home-panel-B-8BCffw.js +3 -0
  91. package/dist/packem_shared/input-JHu63lTv.js +1 -0
  92. package/dist/packem_shared/internal-AtZ4bTal.js +2 -0
  93. package/dist/packem_shared/label-6uP1obNF.js +1 -0
  94. package/dist/packem_shared/live-status-CGW2JHf_.js +1 -0
  95. package/dist/packem_shared/log-fields-CoL3hsIQ.js +1 -0
  96. package/dist/packem_shared/modal-shell-CUwwWC2o.js +1 -0
  97. package/dist/packem_shared/reference-view-KvhektwF.js +12 -0
  98. package/dist/packem_shared/result-chart-CwKhhKM0.js +1 -0
  99. package/dist/packem_shared/scroll-area-DTEq6Jec.js +2 -0
  100. package/dist/packem_shared/select-Bul-DeII.js +2 -0
  101. package/dist/packem_shared/shard-history-DMEW5VBE.js +1 -0
  102. package/dist/packem_shared/skeleton-C1wQ9M5t.js +1 -0
  103. package/dist/packem_shared/sparkline-DtcZoU48.js +1 -0
  104. package/dist/packem_shared/storage-tier-DznqOf-q.js +1 -0
  105. package/dist/packem_shared/studio-BHA7hnI3.js +2 -0
  106. package/dist/packem_shared/table-DdJBrClo.js +2 -0
  107. package/dist/packem_shared/table-list-sidebar-CMCcNALK.js +1 -0
  108. package/dist/packem_shared/textarea-Bu2-jKAs.js +1 -0
  109. package/dist/packem_shared/trace-handoff-Dw7mwjxu.js +1 -0
  110. package/dist/packem_shared/use-admin-query-Di3fLE8H.js +1 -0
  111. package/dist/packem_shared/use-async-submit-H68GHPz8.js +1 -0
  112. package/dist/packem_shared/useDebounced-Ihdiid_k.js +1 -0
  113. package/dist/packem_shared/utils-bhneXptQ.js +1 -0
  114. package/dist/packem_shared/virtual-rect-1o1veP7R.js +1 -0
  115. package/dist/standalone/chunk-2F7G7IWQ.js +1 -0
  116. package/dist/standalone/chunk-2OUPA2WJ.js +1 -0
  117. package/dist/standalone/chunk-2PJNAWB3.js +1 -0
  118. package/dist/standalone/chunk-2Y36BVVM.js +4 -0
  119. package/dist/standalone/chunk-34UVAASH.js +1 -0
  120. package/dist/standalone/chunk-35II7U25.js +11 -0
  121. package/dist/standalone/chunk-3FUFEZ65.js +1 -0
  122. package/dist/standalone/chunk-3QRTYSSX.js +1 -0
  123. package/dist/standalone/chunk-3RTTXLMU.js +1 -0
  124. package/dist/standalone/chunk-3XIESWL4.js +1 -0
  125. package/dist/standalone/chunk-4CGALXS3.js +19 -0
  126. package/dist/standalone/chunk-4UOFSGUS.js +1 -0
  127. package/dist/standalone/chunk-4WLYA3XE.js +1 -0
  128. package/dist/standalone/chunk-54MMVNPT.js +1 -0
  129. package/dist/standalone/chunk-5L2MD6F6.js +1 -0
  130. package/dist/standalone/chunk-5OWIOACV.js +13 -0
  131. package/dist/standalone/chunk-5RF4QDDA.js +6 -0
  132. package/dist/standalone/chunk-5U2THBI7.js +1 -0
  133. package/dist/standalone/chunk-5Y3QLNWX.js +1 -0
  134. package/dist/standalone/chunk-65OTWFS3.js +1 -0
  135. package/dist/standalone/chunk-6DWCIIHE.js +1 -0
  136. package/dist/standalone/chunk-6ST5ECQA.js +1 -0
  137. package/dist/standalone/chunk-7J5N6DGQ.js +1 -0
  138. package/dist/standalone/chunk-7LQWFOEU.js +1 -0
  139. package/dist/standalone/chunk-7QIFDWQV.js +1 -0
  140. package/dist/standalone/chunk-7RXOPYR5.js +1 -0
  141. package/dist/standalone/chunk-7T7UOTYK.js +1 -0
  142. package/dist/standalone/chunk-7YEFOSPH.js +1 -0
  143. package/dist/standalone/chunk-AVAC26HJ.js +1 -0
  144. package/dist/standalone/chunk-B43FTQJ7.js +1 -0
  145. package/dist/standalone/chunk-BEH5N5ZA.js +1 -0
  146. package/dist/standalone/chunk-BGBLQ563.js +1 -0
  147. package/dist/standalone/chunk-BNUJ7QMG.js +3 -0
  148. package/dist/standalone/chunk-C43X4M5U.js +1 -0
  149. package/dist/standalone/chunk-CFPZYHPY.js +2 -0
  150. package/dist/standalone/chunk-D7XXWV4E.js +1 -0
  151. package/dist/standalone/chunk-DVOBKIUX.js +1 -0
  152. package/dist/standalone/chunk-EKRN4ZQM.js +1 -0
  153. package/dist/standalone/chunk-ESVP44Y3.js +1 -0
  154. package/dist/standalone/chunk-EVN46TVV.js +1 -0
  155. package/dist/standalone/chunk-EXFBIISG.js +2 -0
  156. package/dist/standalone/chunk-F5QWLENA.js +1 -0
  157. package/dist/standalone/chunk-F6GOKFMU.js +3 -0
  158. package/dist/standalone/chunk-FGTK44LR.js +1 -0
  159. package/dist/standalone/chunk-FXCBF4XT.js +1 -0
  160. package/dist/standalone/chunk-GMR677FL.js +1 -0
  161. package/dist/standalone/chunk-GRL5MG3Z.js +1 -0
  162. package/dist/standalone/chunk-GSPTEMYN.js +1 -0
  163. package/dist/standalone/chunk-GXZAXNZI.js +1 -0
  164. package/dist/standalone/chunk-H7NIIBHH.js +1 -0
  165. package/dist/standalone/chunk-HP2UCWND.js +1 -0
  166. package/dist/standalone/chunk-HPFLBYRI.js +1 -0
  167. package/dist/standalone/chunk-IC4L6G56.js +1 -0
  168. package/dist/standalone/chunk-IDNNI63H.js +1 -0
  169. package/dist/standalone/chunk-ILNELDFC.js +1 -0
  170. package/dist/standalone/chunk-IVFHIQOT.js +1 -0
  171. package/dist/standalone/chunk-JN2Y24PY.js +1 -0
  172. package/dist/standalone/chunk-KDOC2DP5.js +1 -0
  173. package/dist/standalone/chunk-KUVMORDQ.js +1 -0
  174. package/dist/standalone/chunk-KYF2E5CJ.js +1 -0
  175. package/dist/standalone/chunk-L7N7F3DA.js +1 -0
  176. package/dist/standalone/chunk-LE56LPNH.js +13 -0
  177. package/dist/standalone/chunk-LEDWUPXM.js +1 -0
  178. package/dist/standalone/chunk-LFKCLLPT.js +1 -0
  179. package/dist/standalone/chunk-LFXFP4IF.js +1 -0
  180. package/dist/standalone/chunk-LJDP7NRB.js +1 -0
  181. package/dist/standalone/chunk-LLXFYRGQ.js +1 -0
  182. package/dist/standalone/chunk-M536Y2KX.js +1 -0
  183. package/dist/standalone/chunk-MIQTKZAR.js +1 -0
  184. package/dist/standalone/chunk-OHKRN65U.js +1 -0
  185. package/dist/standalone/chunk-P24JBHEZ.js +4 -0
  186. package/dist/standalone/chunk-PF7V3G2Z.js +62 -0
  187. package/dist/standalone/chunk-PWWHP76O.js +1 -0
  188. package/dist/standalone/chunk-QBWRC5YX.js +1 -0
  189. package/dist/standalone/chunk-QGKAJTQQ.js +1 -0
  190. package/dist/standalone/chunk-QLJJ5YYZ.js +1 -0
  191. package/dist/standalone/chunk-QVEHPYA5.js +1 -0
  192. package/dist/standalone/chunk-QWGT25SE.js +1 -0
  193. package/dist/standalone/chunk-QWJ3NPE3.js +1 -0
  194. package/dist/standalone/chunk-RAA2RGG6.js +1 -0
  195. package/dist/standalone/chunk-RBU52M5T.js +1 -0
  196. package/dist/standalone/chunk-SA3MDZC3.js +1 -0
  197. package/dist/standalone/chunk-SD4BERSA.js +1 -0
  198. package/dist/standalone/chunk-SFDOII3B.js +1 -0
  199. package/dist/standalone/chunk-SKHEGARW.js +1 -0
  200. package/dist/standalone/chunk-SMIESS7P.js +1 -0
  201. package/dist/standalone/chunk-T2JIUFOD.js +4 -0
  202. package/dist/standalone/chunk-T6VMSOBB.js +1 -0
  203. package/dist/standalone/chunk-THIXMMZD.js +1 -0
  204. package/dist/standalone/chunk-TJ2WZ5OP.js +1 -0
  205. package/dist/standalone/chunk-TLHJRWNK.js +1 -0
  206. package/dist/standalone/chunk-UIS34ZPB.js +8 -0
  207. package/dist/standalone/chunk-UNUU7CJJ.js +1 -0
  208. package/dist/standalone/chunk-UZERI5YC.js +1 -0
  209. package/dist/standalone/chunk-V53KNYRN.js +1 -0
  210. package/dist/standalone/chunk-VPAXCQ2Y.js +4 -0
  211. package/dist/standalone/chunk-X2FQ6B5V.js +1 -0
  212. package/dist/standalone/chunk-XBDKZZ67.js +1 -0
  213. package/dist/standalone/chunk-XEDU5FO4.js +1 -0
  214. package/dist/standalone/chunk-XQBTNJUQ.js +1 -0
  215. package/dist/standalone/chunk-XQCVZAGU.js +1 -0
  216. package/dist/standalone/chunk-XQGANNLS.js +1 -0
  217. package/dist/standalone/chunk-XSD4Y6SQ.js +1 -0
  218. package/dist/standalone/chunk-XXQUMVWH.js +1 -0
  219. package/dist/standalone/chunk-YD5NF6UT.js +1 -0
  220. package/dist/standalone/chunk-YI3WYUXK.js +1 -0
  221. package/dist/standalone/chunk-ZJGP6EKR.js +1 -0
  222. package/dist/standalone/chunk-ZNNAGR6N.js +1 -0
  223. package/dist/standalone/studio.js +9 -356
  224. package/dist/styles.css +2 -2
  225. package/package.json +17 -15
  226. package/dist/packem_shared/ADMIN_FUNCTIONS-DmBqMZ-z.js +0 -45
  227. package/dist/packem_shared/ApiDocsPanel-C5-yJ1p7.js +0 -842
  228. package/dist/packem_shared/ApiReferencePanel-1vubqG5s.js +0 -229
  229. package/dist/packem_shared/ApiTab-W3no0KOj.js +0 -251
  230. package/dist/packem_shared/AuditPanel-Bq4o_IqT.js +0 -212
  231. package/dist/packem_shared/CommandPalette-BtgkBzZI.js +0 -373
  232. package/dist/packem_shared/ConfirmButton-C2eVi2Qv.js +0 -59
  233. package/dist/packem_shared/ConnectionBadge-B2DDM2Tn.js +0 -111
  234. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-Vxwaxx51.js +0 -50
  235. package/dist/packem_shared/DEFAULT_INSIGHT_THRESHOLDS-DjF0h-gA.js +0 -89
  236. package/dist/packem_shared/DEFAULT_LOCALE-CiX4W7Kr.js +0 -27
  237. package/dist/packem_shared/DataBrowser-CtBe1So9.js +0 -4542
  238. package/dist/packem_shared/DataFilters-FNquMaiu.js +0 -249
  239. package/dist/packem_shared/ErrorBoundary-BzAApI7J.js +0 -66
  240. package/dist/packem_shared/ExportImportPanel-dxY56TDF.js +0 -193
  241. package/dist/packem_shared/FileBrowser-Dhy4zES8.js +0 -2932
  242. package/dist/packem_shared/FunctionRunner--fQJRPAD.js +0 -343
  243. package/dist/packem_shared/FunctionStatsPanel-BjRUA_G3.js +0 -432
  244. package/dist/packem_shared/GlobalDataBrowser-BTEmGrph.js +0 -318
  245. package/dist/packem_shared/HealthPanel-PxclMWmA.js +0 -640
  246. package/dist/packem_shared/HomePanel-Cw16stjq.js +0 -1273
  247. package/dist/packem_shared/InsightsPanel-CWS_C-xW.js +0 -423
  248. package/dist/packem_shared/LogsPanel-CTW8CFcM.js +0 -839
  249. package/dist/packem_shared/MailPanel-BwkvfIHF.js +0 -447
  250. package/dist/packem_shared/MetricsPanel-BLuOhZQ4.js +0 -1625
  251. package/dist/packem_shared/MigrationsPanel-DT3lnwHF.js +0 -246
  252. package/dist/packem_shared/OpenRpcReferencePanel-vbcYbv3V.js +0 -191
  253. package/dist/packem_shared/PitrPanel-CdErL7EJ.js +0 -252
  254. package/dist/packem_shared/STUDIO_ROOT_CLASS-D12gX2dV.js +0 -3
  255. package/dist/packem_shared/ScheduledJobs-CabfKbyM.js +0 -159
  256. package/dist/packem_shared/SchemaViewer-LJDcmNIO.js +0 -2512
  257. package/dist/packem_shared/SecurityAdvisorPanel-C_ETsPih.js +0 -79
  258. package/dist/packem_shared/SettingsPanel-C0uLRf5P.js +0 -176
  259. package/dist/packem_shared/ShardInput-gx_DZXXn.js +0 -107
  260. package/dist/packem_shared/SqlEditorPanel-CguV7otm.js +0 -13
  261. package/dist/packem_shared/Studio-BmSGSIuY.js +0 -33
  262. package/dist/packem_shared/StudioApp-D4azxYBu.js +0 -657
  263. package/dist/packem_shared/StudioI18nProvider-B-tDCZIi.js +0 -48
  264. package/dist/packem_shared/TableEditor-ChfUOZec.js +0 -371
  265. package/dist/packem_shared/advisor-view-CGcfMiPq.js +0 -159
  266. package/dist/packem_shared/aggregateMetrics-D4nUHEKU.js +0 -108
  267. package/dist/packem_shared/app.d-CCmwDEVs.d.ts +0 -300
  268. package/dist/packem_shared/badge-B2PKA1-5.js +0 -49
  269. package/dist/packem_shared/bar-chart-CzJAgqkp.js +0 -3245
  270. package/dist/packem_shared/button-BhsN2uZH.js +0 -49
  271. package/dist/packem_shared/card-DURq3ElK.js +0 -175
  272. package/dist/packem_shared/cf-links-2cktDedA.js +0 -8
  273. package/dist/packem_shared/checkbox-UNkzAxl-.js +0 -63
  274. package/dist/packem_shared/data-grid-B5CaV3wS.js +0 -183
  275. package/dist/packem_shared/dropdown-menu-WY4B_eJO.js +0 -280
  276. package/dist/packem_shared/empty-state-DY_oe0k6.js +0 -98
  277. package/dist/packem_shared/grid-features-CzUfqgsM.js +0 -840
  278. package/dist/packem_shared/input-XH4r1Pt1.js +0 -53
  279. package/dist/packem_shared/internal-rXJEAhXS.js +0 -68
  280. package/dist/packem_shared/label-D8ykjn5J.js +0 -46
  281. package/dist/packem_shared/live-status-FZ0psC1z.js +0 -44
  282. package/dist/packem_shared/reference-view-B4E49Lip.js +0 -2180
  283. package/dist/packem_shared/shard-history-DyebH1R5.js +0 -38
  284. package/dist/packem_shared/sparkline-10dG-_f0.js +0 -93
  285. package/dist/packem_shared/sql-editor-panel-BFRpzj6r.js +0 -2562
  286. package/dist/packem_shared/storage-tier-CL98eOvn.js +0 -85
  287. package/dist/packem_shared/studio-H9fuQgSj.js +0 -10303
  288. package/dist/packem_shared/table-_RzNvy3R.js +0 -246
  289. package/dist/packem_shared/table-list-sidebar-Bg7uzbvC.js +0 -832
  290. package/dist/packem_shared/textarea-D3gaCU_-.js +0 -46
  291. package/dist/packem_shared/use-live-admin-Dq6g3daN.js +0 -73
  292. package/dist/packem_shared/use-live-shard-seed-Cuk3dnH0.js +0 -76
  293. package/dist/packem_shared/useDebounced-Dxncpg6z.js +0 -32
  294. package/dist/packem_shared/utils-B05Dmz_H.js +0 -8
  295. package/dist/packem_shared/virtual-rect-CVMUskSm.js +0 -10
@@ -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-BYNSbBVE.js";import{c as u,e as y,f as p,a as S}from"../packem_shared/internal-AtZ4bTal.js";import{jsxs as a,jsx as r}from"react/jsx-runtime";const N=S(B.getPitrBookmark),Q=S(B.pitrRestore),de=({initialShardKey:T})=>{const m=E(),t=J(),l=T??"",[O,f]=s(null),[i,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),k=H(async()=>{d(!0),n(null);try{const e=await m.query(N,{},u(l));f(e.current)}catch(e){n(y(e))}finally{d(!1)}},[m,l]);W(()=>{p(k())},[k]),G(()=>{p((async()=>{try{const e=await m.query(N,{},u(l));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=()=>{i.trim()!==""&&p((async()=>{d(!0),n(null);try{const e=await m.query(N,{time:i.trim()},u(l));w(e.forTime??null),f(e.current)}catch(e){w(null),n(y(e))}finally{d(!1)}})())},R=e=>{p((async()=>{d(!0),n(null);try{const b=await m.mutation(Q,e,u(l));L(b),await k()}catch(b){n(y(b))}finally{d(!1)}})())},K=c.trim()!==""||i.trim()!=="",$=()=>{const e=h?{restart:!0}:{};c.trim()===""?e.time=i.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:l===""?t("root"):l})]})}),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:i}),r(_,{"data-testid":"pitr-preview",disabled:x||i.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,2 @@
1
+ 'use client';
2
+ import{c as Y}from"react/compiler-runtime";import{useLunora as At}from"@lunora/react";import{useState as v,useRef as Ct,useEffect as Ge}from"react";import{ShardInput as qt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as ct,d as be}from"../packem_shared/storage-tier-DznqOf-q.js";import{g as we}from"../packem_shared/badge-BbuuAio7.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as mt,n as ut,f as pt,m as ht,u as gt}from"../packem_shared/card-CIDGUN6K.js";import{E as Ut}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as Ae}from"../packem_shared/input-JHu63lTv.js";import Bt from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Ue}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as tt}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{f as M,c as Qe,e as Ye,a as at}from"../packem_shared/internal-AtZ4bTal.js";import{r as Gt}from"../packem_shared/shard-history-DMEW5VBE.js";import{c as Ke}from"../packem_shared/utils-bhneXptQ.js";import{Download01Icon as Kt}from"@hugeicons/core-free-icons";import{HugeiconsIcon as Dt}from"@hugeicons/react";import{Handle as vt,Position as yt,getNodesBounds as Ht,getViewportForBounds as Jt,useNodesState as Vt,useEdgesState as Wt,Background as Xt,Panel as ft,Controls as Zt,MiniMap as Qt,ReactFlow as Yt,useNodes as ea,useReactFlow as ta}from"@xyflow/react";import{h as aa,$ as la,b as na,N as dt}from"../packem_shared/dropdown-menu-C3RQ_HlW.js";import{jsx as n,jsxs as u}from"react/jsx-runtime";import{LunoraError as sa}from"@lunora/errors";import{toBlob as ra,toSvg as oa}from"html-to-image";import{useNavigate as ia}from"@tanstack/react-router";import{p as Ne}from"../packem_shared/label-6uP1obNF.js";function da(a){const e=Y(10);let t,o,r;e[0]!==a?({className:t,selected:r,...o}=a,e[0]=a,e[1]=t,e[2]=o,e[3]=r):(t=e[1],o=e[2],r=e[3]);const s=r===!0?"":void 0;let l;e[4]!==t?(l=Ke("rounded-md border border-border bg-card text-card-foreground shadow-sm transition-colors","data-[selected]:border-ring data-[selected]:ring-[3px] data-[selected]:ring-ring/30",t),e[4]=t,e[5]=l):l=e[5];let i;return e[6]!==o||e[7]!==s||e[8]!==l?(i=n("div",{"data-slot":"base-node","data-selected":s,className:l,...o}),e[6]=o,e[7]=s,e[8]=l,e[9]=i):i=e[9],i}function ca(a){const e=Y(8);let t,o;e[0]!==a?({className:t,...o}=a,e[0]=a,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let r;e[3]!==t?(r=Ke("flex items-center gap-2 rounded-t-md bg-muted/50 px-3 py-1.5",t),e[3]=t,e[4]=r):r=e[4];let s;return e[5]!==o||e[6]!==r?(s=n("div",{"data-slot":"base-node-header",className:r,...o}),e[5]=o,e[6]=r,e[7]=s):s=e[7],s}function ma(a){const e=Y(8);let t,o;e[0]!==a?({className:t,...o}=a,e[0]=a,e[1]=t,e[2]=o):(t=e[1],o=e[2]);let r;e[3]!==t?(r=Ke("flex flex-col",t),e[3]=t,e[4]=r):r=e[4];let s;return e[5]!==o||e[6]!==r?(s=n("div",{"data-slot":"base-node-content",className:r,...o}),e[5]=o,e[6]=r,e[7]=s):s=e[7],s}const Nt=a=>{const e=a.ref===void 0?a.type:`${a.type} → ${a.ref}`;return a.optional===!0?`${e}?`:e},ua=a=>{const e=Y(22),{data:t,selected:o}=a,r=Ue();let s;e[0]!==t.label||e[1]!==t.loadError||e[2]!==r?(s=t.loadError===!0?n("span",{className:"px-3 py-1.5 text-xs text-destructive","data-testid":`sd-node-${t.label}-error`,children:r("Columns unavailable")}):n("span",{className:"px-3 py-1.5 text-xs text-muted-foreground",children:"—"}),e[0]=t.label,e[1]=t.loadError,e[2]=r,e[3]=s):s=e[3];const l=s,i=`sd-node-${t.label}`;let m;e[4]!==t.label?(m=n("span",{className:"truncate font-mono text-xs font-semibold",title:t.label,children:t.label}),e[4]=t.label,e[5]=m):m=e[5];let d;e[6]!==t.tier?(d=n("span",{className:"ms-auto",children:n(ct,{tier:t.tier})}),e[6]=t.tier,e[7]=d):d=e[7];let f;e[8]!==m||e[9]!==d?(f=u(ca,{children:[m,d]}),e[8]=m,e[9]=d,e[10]=f):f=e[10];let g;e[11]!==t.columns||e[12]!==t.label||e[13]!==l?(g=t.columns.length===0?l:t.columns.map(x=>u("div",{className:Ke("relative flex items-center gap-2 border-t border-border px-3 py-1.5 text-xs first:border-t-0",x.pk===!0&&"bg-muted/30"),"data-testid":`sd-col-${t.label}-${x.name}`,children:[n(vt,{className:"!h-2 !w-2 !-left-1 !border-border !bg-muted-foreground/70",id:x.name,isConnectable:!1,position:yt.Left,type:"target"}),n("span",{className:"truncate font-mono",title:x.name,children:x.name}),x.pk===!0&&n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),x.ref!==void 0&&n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),n("span",{className:"ms-auto truncate text-muted-foreground",title:Nt(x),children:Nt(x)}),n(vt,{className:"!h-2 !w-2 !-right-1 !border-border !bg-muted-foreground/70",id:x.name,isConnectable:!1,position:yt.Right,type:"source"})]},x.name)),e[11]=t.columns,e[12]=t.label,e[13]=l,e[14]=g):g=e[14];let b;e[15]!==g?(b=n(ma,{children:g}),e[15]=g,e[16]=b):b=e[16];let p;return e[17]!==o||e[18]!==i||e[19]!==f||e[20]!==b?(p=u(da,{className:"w-64 overflow-hidden","data-testid":i,selected:o,children:[f,b]}),e[17]=o,e[18]=i,e[19]=f,e[20]=b,e[21]=p):p=e[21],p},qe=1920,et=1080,Tt=32,bt=(a,e)=>{const t=globalThis.document.createElement("a");t.href=a,t.download=e,globalThis.document.body.append(t),t.click(),t.remove()},pa=(a,e,t="schema-diagram.json")=>{const o={edges:e,exportedAt:new Date().toISOString(),nodes:a},r=JSON.stringify(o,void 0,2),s=globalThis.URL.createObjectURL(new globalThis.Blob([r],{type:"application/json"}));bt(s,t),globalThis.setTimeout(()=>{globalThis.URL.revokeObjectURL(s)},0)},_t=(a,e,t,o)=>{const r=Ht(a),{x:s,y:l,zoom:i}=Jt(r,e,t,.1,2,o);return{transform:[s,l,i],zoom:i}},ha=async(a,e,t="schema-diagram.png")=>{const{transform:o}=_t(e,qe,et,Tt),[r,s,l]=o,i=await ra(a,{backgroundColor:"#ffffff",height:et,style:{transform:`translate(${r.toString()}px, ${s.toString()}px) scale(${l.toString()})`,transformOrigin:"top left",width:`${qe.toString()}px`},width:qe});if(i===null)throw new sa("INTERNAL","html-to-image produced no blob");const m=globalThis.URL.createObjectURL(i);bt(m,t),globalThis.setTimeout(()=>{globalThis.URL.revokeObjectURL(m)},0)},ga=async(a,e,t="schema-diagram.svg")=>{const{transform:o}=_t(e,qe,et,Tt),[r,s,l]=o,i=await oa(a,{backgroundColor:"#ffffff",height:et,style:{transform:`translate(${r.toString()}px, ${s.toString()}px) scale(${l.toString()})`,transformOrigin:"top left",width:`${qe.toString()}px`},width:qe});bt(i,t)},fa=a=>38+Math.max(1,a)*28,ba=(a,e)=>{const t=new Map;for(const l of a)t.set(l,[]);for(const l of e)l.to!==l.from&&t.has(l.from)&&t.has(l.to)&&t.get(l.from)?.push(l.to);const o=new Map,r=new Set,s=l=>{const i=o.get(l);if(i!==void 0)return i;if(r.has(l))return 0;r.add(l);let m=0;for(const d of t.get(l)??[])m=Math.max(m,s(d)+1);return r.delete(l),o.set(l,m),m};for(const l of a)s(l);return o},xa=(a,e,t)=>{const o=ba(a,e),r=new Map,s=[];for(const l of a){const i=o.get(l)??0,m=r.get(i)??24;s.push({name:l,x:24+i*368,y:m}),r.set(i,m+fa(t.get(l)??0)+36)}return s},va={databaseSchema:ua},It={backgroundColor:be.shard.color},zt={backgroundColor:be.global.color},ya={global:!0,shard:!0},Na=a=>{const e=a.find(t=>t.pk===!0)?.name;return e!==void 0?e:a.some(t=>t.name==="_id")?"_id":a.some(t=>t.name==="id")?"id":a[0]?.name??"_id"},Et=a=>a.flatMap(e=>e.columns.filter(t=>t.ref!==void 0).map(t=>({column:t.name,from:e.name,to:t.ref}))),wa=(a,e)=>{const t=a.map(l=>l.name),o=new Map(a.map(l=>[l.name,l.columns.length])),r=xa(t,Et(a),o),s=new Map(a.map(l=>[l.name,l]));return r.flatMap(({name:l,x:i,y:m})=>{const d=s.get(l);return d===void 0?[]:[{data:{columns:d.columns,label:l,loadError:e,tier:d.tier},id:l,position:{x:i,y:m},type:"databaseSchema"}]})},Sa=a=>{const e=new Map(a.map(t=>[t.name,t.columns]));return Et(a).flatMap(t=>{const o=e.get(t.to)??[],r=e.get(t.from)??[],s=Na(o);return!o.some(l=>l.name===s)||!r.some(l=>l.name===t.column)?[]:[{id:`${t.from}.${t.column}->${t.to}`,source:t.to,sourceHandle:s,target:t.from,targetHandle:t.column}]})},$a=()=>{const a=Y(15),e=Ue();let t;a[0]===Symbol.for("react.memo_cache_sentinel")?(t=u("span",{className:"flex items-center gap-1",children:[n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:It}),be.shard.label]}),a[0]=t):t=a[0];let o;a[1]===Symbol.for("react.memo_cache_sentinel")?(o=u("span",{className:"flex items-center gap-1",children:[n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:zt}),be.global.label]}),a[1]=o):o=a[1];let r;a[2]===Symbol.for("react.memo_cache_sentinel")?(r=n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"secondary",children:"PK"}),a[2]=r):r=a[2];let s;a[3]!==e?(s=e("Primary key"),a[3]=e,a[4]=s):s=a[4];let l;a[5]!==s?(l=u("span",{className:"flex items-center gap-1",children:[r,s]}),a[5]=s,a[6]=l):l=a[6];let i;a[7]===Symbol.for("react.memo_cache_sentinel")?(i=n(we,{className:"px-1 py-0 text-[10px] leading-tight",variant:"outline",children:"FK"}),a[7]=i):i=a[7];let m;a[8]!==e?(m=e("Foreign key"),a[8]=e,a[9]=m):m=a[9];let d;a[10]!==m?(d=u("span",{className:"flex items-center gap-1",children:[i,m]}),a[10]=m,a[11]=d):d=a[11];let f;return a[12]!==l||a[13]!==d?(f=u("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 rounded-xl border border-border bg-card/95 px-2.5 py-1.5 text-[11px] text-muted-foreground shadow-xs",children:[t,o,l,d]}),a[12]=l,a[13]=d,a[14]=f):f=a[14],f},ka=({containerRef:a,testIdPrefix:e})=>{const t=Ue(),o=ea(),{getEdges:r}=ta(),[s,l]=v(null),i=async()=>{const b=a.current?.querySelector(".react-flow__viewport");if(b){l("png");try{await ha(b,o,`${e}-schema-diagram.png`)}finally{l(null)}}},m=async()=>{const b=a.current?.querySelector(".react-flow__viewport");if(b){l("svg");try{await ga(b,o,`${e}-schema-diagram.svg`)}finally{l(null)}}},d=()=>{l("json");try{pa(o,r(),`${e}-schema-diagram.json`)}finally{l(null)}},f=()=>{M(i())},g=()=>{M(m())};return n(ft,{position:"top-right",children:u(aa,{children:[u(la,{className:"group/button inline-flex shrink-0 cursor-pointer items-center justify-center gap-1 rounded-md border border-border bg-background px-2 text-xs font-medium whitespace-nowrap hover:bg-muted disabled:pointer-events-none disabled:opacity-50","data-testid":`${e}-export-trigger`,disabled:s!==null,children:[n(Dt,{className:"size-3.5",icon:Kt,strokeWidth:2}),t("Export")]}),u(na,{align:"end",children:[n(dt,{"data-testid":`${e}-export-png`,disabled:s!==null,onClick:f,children:t("PNG")}),n(dt,{"data-testid":`${e}-export-svg`,disabled:s!==null,onClick:g,children:t("SVG")}),n(dt,{"data-testid":`${e}-export-json`,disabled:s!==null,onClick:d,children:t("JSON")})]})]})})},Ca=a=>{const e=Y(75),{columnsError:t,tables:o,testIdPrefix:r}=a,s=Ue(),[l,i]=v(ya),[m,d]=v("");let f;if(e[0]!==m||e[1]!==o||e[2]!==l){const k=m.trim().toLowerCase();f=o.filter(X=>l[X.tier]&&X.name.toLowerCase().includes(k)),e[0]=m,e[1]=o,e[2]=l,e[3]=f}else f=e[3];const g=f,b=t??!1;let p;e[4]!==b||e[5]!==g?(p=wa(g,b),e[4]=b,e[5]=g,e[6]=p):p=e[6];const x=p;let C;e[7]!==g?(C=Sa(g),e[7]=g,e[8]=C):C=e[8];const T=C,[ee,_,re]=Vt(x),[R,B,oe]=Wt(T),P=Ct(null);let O,F;e[9]!==x||e[10]!==_?(O=()=>{_(x)},F=[x,_],e[9]=x,e[10]=_,e[11]=O,e[12]=F):(O=e[11],F=e[12]),Ge(O,F);let A,ie;e[13]!==T||e[14]!==B?(A=()=>{B(T)},ie=[T,B],e[13]=T,e[14]=B,e[15]=A,e[16]=ie):(A=e[15],ie=e[16]),Ge(A,ie);let G;e[17]===Symbol.for("react.memo_cache_sentinel")?(G=k=>{d(k.target.value)},e[17]=G):G=e[17];const Se=G;let de;e[18]===Symbol.for("react.memo_cache_sentinel")?(de=()=>{i(Ta)},e[18]=de):de=e[18];const w=de;let ce;e[19]===Symbol.for("react.memo_cache_sentinel")?(ce=()=>{i(_a)},e[19]=ce):ce=e[19];const S=ce;if(o.length===0){const k=`${r}-section`,X=`${r}-empty`;let ne;e[20]!==s?(ne=s("No tables to graph."),e[20]=s,e[21]=ne):ne=e[21];let Z;e[22]!==X||e[23]!==ne?(Z=n("p",{className:"text-sm text-muted-foreground","data-testid":X,children:ne}),e[22]=X,e[23]=ne,e[24]=Z):Z=e[24];let Q;return e[25]!==k||e[26]!==Z?(Q=n("section",{className:"flex flex-col gap-2","data-testid":k,children:Z}),e[25]=k,e[26]=Z,e[27]=Q):Q=e[27],Q}const me=`${r}-section`,te=`${r}-canvas`;let E;e[28]===Symbol.for("react.memo_cache_sentinel")?(E=n(Xt,{}),e[28]=E):E=e[28];let ae;e[29]!==s?(ae=s("Find table…"),e[29]=s,e[30]=ae):ae=e[30];const q=`${r}-find`;let K;e[31]!==s?(K=s("Find table…"),e[31]=s,e[32]=K):K=e[32];let L;e[33]!==m||e[34]!==ae||e[35]!==q||e[36]!==K?(L=n(Ae,{"aria-label":ae,className:"h-7 w-44 text-xs","data-testid":q,onChange:Se,placeholder:K,value:m}),e[33]=m,e[34]=ae,e[35]=q,e[36]=K,e[37]=L):L=e[37];let h;e[38]!==s?(h=s("Storage tiers"),e[38]=s,e[39]=h):h=e[39];const $=`${r}-tier-shard`,xe=l.shard?"default":"outline";let ue;e[40]===Symbol.for("react.memo_cache_sentinel")?(ue=n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:It}),e[40]=ue):ue=e[40];let D;e[41]!==$||e[42]!==xe||e[43]!==l.shard?(D=u(z,{"aria-pressed":l.shard,className:"gap-1.5","data-testid":$,onClick:w,size:"xs",type:"button",variant:xe,children:[ue,be.shard.label]}),e[41]=$,e[42]=xe,e[43]=l.shard,e[44]=D):D=e[44];const ve=`${r}-tier-global`,ye=l.global?"default":"outline";let pe;e[45]===Symbol.for("react.memo_cache_sentinel")?(pe=n("span",{"aria-hidden":"true",className:"size-1.5 rounded-full",style:zt}),e[45]=pe):pe=e[45];let j;e[46]!==ve||e[47]!==ye||e[48]!==l.global?(j=u(z,{"aria-pressed":l.global,className:"gap-1.5","data-testid":ve,onClick:S,size:"xs",type:"button",variant:ye,children:[pe,be.global.label]}),e[46]=ve,e[47]=ye,e[48]=l.global,e[49]=j):j=e[49];let H;e[50]!==h||e[51]!==D||e[52]!==j?(H=u("div",{"aria-label":h,className:"flex items-center gap-1.5",role:"group",children:[D,j]}),e[50]=h,e[51]=D,e[52]=j,e[53]=H):H=e[53];let le;e[54]!==L||e[55]!==H?(le=n(ft,{position:"top-left",children:u("div",{className:"flex flex-col gap-2 rounded-xl border border-border bg-card/95 p-2 shadow-xs",children:[L,H]})}),e[54]=L,e[55]=H,e[56]=le):le=e[56];let $e,he,ge;e[57]===Symbol.for("react.memo_cache_sentinel")?($e=n(ft,{position:"bottom-left",children:n($a,{})}),he=n(Zt,{showInteractive:!1}),ge=n(Qt,{pannable:!0,zoomable:!0}),e[57]=$e,e[58]=he,e[59]=ge):($e=e[57],he=e[58],ge=e[59]);let J;e[60]!==r?(J=n(ka,{containerRef:P,testIdPrefix:r}),e[60]=r,e[61]=J):J=e[61];let V;e[62]!==R||e[63]!==ee||e[64]!==oe||e[65]!==re||e[66]!==le||e[67]!==J?(V=u(Yt,{edges:R,elementsSelectable:!0,fitView:!0,minZoom:.2,nodes:ee,nodesConnectable:!1,nodeTypes:va,onEdgesChange:oe,onNodesChange:re,children:[E,le,$e,he,ge,J]}),e[62]=R,e[63]=ee,e[64]=oe,e[65]=re,e[66]=le,e[67]=J,e[68]=V):V=e[68];let W;e[69]!==te||e[70]!==V?(W=n("div",{className:"h-[560px] w-full overflow-hidden rounded-xl border border-border bg-muted/20 shadow-xs","data-testid":te,ref:P,children:V}),e[69]=te,e[70]=V,e[71]=W):W=e[71];let fe;return e[72]!==me||e[73]!==W?(fe=n("section",{className:"flex flex-col gap-2","data-testid":me,children:W}),e[72]=me,e[73]=W,e[74]=fe):fe=e[74],fe};function Ta(a){return{...a,shard:!a.shard}}function _a(a){return{...a,global:!a.global}}const Ia="/__lunora/schema-edit",za=async a=>{const e=await fetch(Ia,{body:JSON.stringify(a),headers:{"Content-Type":"application/json","X-Lunora-Studio":"1"},method:"POST"}),t=await e.json();return t.needsMigration===!0?{kind:"needs-migration",message:t.message??"This edit needs a migration."}:e.ok&&t.tables!==void 0?{diagnostics:t.diagnostics??[],kind:"ok",tables:t.tables}:{kind:"error",message:t.error??`schema edit failed (${String(e.status)})`}},Ea=[{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()"}],ja="v.string()",Oa=a=>a.split(",").map(e=>e.trim()).filter(e=>e!==""),Fa=({onApplied:a,tableNames:e})=>{const t=Ue(),o=ia(),[r,s]=v(null),[l,i]=v(!1),[m,d]=v(null),[f,g]=v(""),[b,p]=v(""),[x,C]=v(ja),[T,ee]=v(e[0]??""),[_,re]=v(""),[R,B]=v(""),[oe,P]=v(!1),O=()=>{s(null),g(""),p(""),re(""),B(""),P(!1)},F=async h=>{i(!0),d(null);try{const $=await za(h);d($),$.kind==="ok"&&(a($.tables),O())}catch($){d({kind:"error",message:$ instanceof Error?$.message:String($)})}finally{i(!1)}},A=()=>{M(F({kind:"addTable",table:f.trim()}))},ie=()=>{M(F({column:b.trim(),kind:"addOptionalColumn",table:T,validator:x}))},G=()=>{M(F({fields:Oa(R),kind:"addIndex",name:_.trim(),table:T,unique:oe}))},Se=()=>{d(null),s("addTable")},de=()=>{d(null),s("addColumn")},w=()=>{d(null),s("addIndex")},ce=()=>{s("destructive"),d({kind:"needs-migration",message:t("This edit changes stored data and must go through a migration. Review the migration before applying.")})},S=h=>{g(h.target.value)},me=h=>{p(h.target.value)},te=h=>{C(h.target.value)},E=h=>{ee(h.target.value)},ae=h=>{re(h.target.value)},q=h=>{B(h.target.value)},K=h=>{P(h.target.checked)},L=()=>{M(o({to:"/migrations"}))};return u(mt,{"data-testid":"sc-editor",size:"sm",children:[u(ut,{children:[n(pt,{children:t("Edit schema")}),n(ht,{children:t("Adds a table, column, or index to lunora/schema.ts and reruns codegen.")})]}),u(gt,{children:[u("div",{className:"flex flex-wrap gap-2",children:[n(z,{"data-testid":"sc-editor-add-table",onClick:Se,size:"xs",type:"button",variant:r==="addTable"?"default":"outline",children:t("Add table")}),n(z,{"data-testid":"sc-editor-add-column",disabled:e.length===0,onClick:de,size:"xs",type:"button",variant:r==="addColumn"?"default":"outline",children:t("Add column")}),n(z,{"data-testid":"sc-editor-add-index",disabled:e.length===0,onClick:w,size:"xs",type:"button",variant:r==="addIndex"?"default":"outline",children:t("Add index")}),n(z,{"data-testid":"sc-editor-destructive",disabled:e.length===0,onClick:ce,size:"xs",type:"button",variant:r==="destructive"?"default":"ghost",children:t("Rename / drop / change type…")})]}),r==="addTable"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-table-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-table-name",children:t("Table name")}),n(Ae,{"data-testid":"sc-editor-table-name",id:"sc-editor-table-name",onChange:S,value:f})]}),n(z,{"data-testid":"sc-editor-table-apply",disabled:l||f.trim()==="",onClick:A,size:"xs",type:"button",children:t(l?"Applying…":"Apply")}),n(z,{onClick:O,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),r==="addColumn"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-column-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-column-table",children:t("Table name")}),n("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:E,value:T,children:e.map(h=>n("option",{value:h,children:h},h))})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-column-name",children:t("Column name")}),n(Ae,{"data-testid":"sc-editor-column-name",id:"sc-editor-column-name",onChange:me,value:b})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-column-type",children:t("Column type")}),n("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:te,value:x,children:Ea.map(h=>n("option",{value:h.validator,children:h.label},h.validator))})]}),n("span",{className:"text-[11px] text-muted-foreground",children:t("Optional")}),n(z,{"data-testid":"sc-editor-column-apply",disabled:l||b.trim()===""||T==="",onClick:ie,size:"xs",type:"button",children:t(l?"Applying…":"Apply")}),n(z,{onClick:O,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),r==="addIndex"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"sc-editor-index-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-index-table",children:t("Table name")}),n("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:E,value:T,children:e.map(h=>n("option",{value:h,children:h},h))})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-index-name",children:t("Index name")}),n(Ae,{"data-testid":"sc-editor-index-name",id:"sc-editor-index-name",onChange:ae,value:_})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[n(Ne,{htmlFor:"sc-editor-index-fields",children:t("Index fields (comma-separated)")}),n(Ae,{"data-testid":"sc-editor-index-fields",id:"sc-editor-index-fields",onChange:q,value:R})]}),u(Ne,{className:"flex items-center gap-1 text-xs",htmlFor:"sc-editor-index-unique",children:[n("input",{checked:oe,"data-testid":"sc-editor-index-unique",id:"sc-editor-index-unique",onChange:K,type:"checkbox"}),n("span",{className:"text-muted-foreground",children:t("Unique")})]}),n(z,{"data-testid":"sc-editor-index-apply",disabled:l||_.trim()===""||R.trim()==="",onClick:G,size:"xs",type:"button",children:t(l?"Applying…":"Apply")}),n(z,{onClick:O,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),m?.kind==="error"&&n("p",{className:"mt-3 text-sm text-destructive","data-testid":"sc-editor-error",role:"alert",children:m.message}),m?.kind==="needs-migration"&&u("div",{className:"mt-3 flex flex-col gap-2","data-testid":"sc-editor-needs-migration",children:[n("p",{className:"text-sm text-warning",role:"alert",children:t("This edit changes stored data and must go through a migration. Review the migration before applying.")}),n(z,{className:"self-start","data-testid":"sc-editor-open-migrations",onClick:L,size:"xs",type:"button",variant:"outline",children:t("Open Migrations")})]}),m?.kind==="ok"&&m.diagnostics.length>0&&u("div",{className:"mt-3 flex flex-col gap-1","data-testid":"sc-editor-diagnostics",children:[n("p",{className:"text-sm text-destructive",role:"alert",children:t("Codegen reported diagnostics:")}),n("ul",{className:"flex flex-col gap-0.5",children:m.diagnostics.map(h=>n("li",{className:"font-mono text-[11px] text-destructive",children:h},h))})]})]})]})},La=at(tt.listTables),Ma=at(tt.listTableIndexes),Ra=at(tt.readTablePage),Pa=at(tt.describeTables),Aa={},wt=[],St=[],qa=a=>{const e=Y(5),{open:t}=a,o=t&&"rotate-90";let r;e[0]!==o?(r=Ke("size-3.5 shrink-0 text-muted-foreground transition-transform duration-150",o),e[0]=o,e[1]=r):r=e[1];let s;e[2]===Symbol.for("react.memo_cache_sentinel")?(s=n("path",{d:"m9 6 6 6-6 6"}),e[2]=s):s=e[2];let l;return e[3]!==r?(l=n("svg",{"aria-hidden":"true",className:r,fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.8,viewBox:"0 0 24 24",children:s}),e[3]=r,e[4]=l):l=e[4],l},$t=a=>{const e=Y(20),{children:t,expanded:o,name:r,onToggle:s,rowCount:l,rowTestId:i,toggleTestId:m}=a;let d;e[0]!==o?(d=n(qa,{open:o}),e[0]=o,e[1]=d):d=e[1];let f;e[2]!==r?(f=n("span",{className:"truncate font-mono text-xs text-foreground",title:r,children:r}),e[2]=r,e[3]=f):f=e[3];let g;e[4]!==l?(g=u("span",{className:"ms-auto shrink-0 text-xs text-muted-foreground tabular-nums",children:["(",l,")"]}),e[4]=l,e[5]=g):g=e[5];let b;e[6]!==o||e[7]!==s||e[8]!==d||e[9]!==f||e[10]!==g||e[11]!==m?(b=u("button",{"aria-expanded":o,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":m,onClick:s,type:"button",children:[d,f," ",g]}),e[6]=o,e[7]=s,e[8]=d,e[9]=f,e[10]=g,e[11]=m,e[12]=b):b=e[12];let p;e[13]!==t||e[14]!==o?(p=o&&n("div",{className:"px-3 pb-3 ps-8",children:t}),e[13]=t,e[14]=o,e[15]=p):p=e[15];let x;return e[16]!==i||e[17]!==b||e[18]!==p?(x=u("li",{className:"border-t border-border/60 first:border-t-0","data-testid":i,children:[b,p]}),e[16]=i,e[17]=b,e[18]=p,e[19]=x):x=e[19],x},kt=a=>{const e=Y(5),{columns:t,testId:o}=a;let r;e[0]!==t?(r=t.map(Ba),e[0]=t,e[1]=r):r=e[1];let s;return e[2]!==r||e[3]!==o?(s=n("ul",{className:"flex flex-wrap gap-1.5 pt-1","data-testid":o,children:r}),e[2]=r,e[3]=o,e[4]=s):s=e[4],s},Ua=a=>{const e=Y(10),{heading:t,indexes:o,testId:r}=a;let s;e[0]!==t?(s=n("p",{className:"mb-1.5 font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:t}),e[0]=t,e[1]=s):s=e[1];let l;e[2]!==o?(l=o.map(Ga),e[2]=o,e[3]=l):l=e[3];let i;e[4]!==l||e[5]!==r?(i=n("ul",{className:"flex flex-col gap-1","data-testid":r,children:l}),e[4]=l,e[5]=r,e[6]=i):i=e[6];let m;return e[7]!==s||e[8]!==i?(m=u("div",{className:"pt-3",children:[s,i]}),e[7]=s,e[8]=i,e[9]=m):m=e[9],m},vl=a=>{const e=Y(126),{initialShardKey:t,initialTable:o,schemaEditable:r}=a,s=At(),l=Ue(),[i,m]=v("list"),[d,f]=v(t??""),[g,b]=v(""),[p,x]=v(null),[C,T]=v(null);let ee;e[0]===Symbol.for("react.memo_cache_sentinel")?(ee={},e[0]=ee):ee=e[0];const[_,re]=v(ee);let R;e[1]===Symbol.for("react.memo_cache_sentinel")?(R={},e[1]=R):R=e[1];const[B,oe]=v(R),[P,O]=v(null);let F;e[2]===Symbol.for("react.memo_cache_sentinel")?(F={},e[2]=F):F=e[2];const[A,ie]=v(F);let G;e[3]===Symbol.for("react.memo_cache_sentinel")?(G={},e[3]=G):G=e[3];const[Se,de]=v(G),[w,ce]=v(null),[S,me]=v(null);let te;e[4]===Symbol.for("react.memo_cache_sentinel")?(te={},e[4]=te):te=e[4];const[E,ae]=v(te),[q,K]=v(null);let L;e[5]!==s?(L=async c=>{T(null);try{const y=await s.query(La,{},Qe(c));Gt(c),x(y),re({}),oe({}),O(null),ie(N=>Object.fromEntries(Object.entries(N).filter(U=>{const[I]=U;return I!==c}))),de(N=>Object.fromEntries(Object.entries(N).filter(U=>{const[I]=U;return I!==c})))}catch(y){const N=y;x(null),T(Ye(N))}},e[5]=s,e[6]=L):L=e[6];const h=L;let $;e[7]!==s?($=async()=>{me(null);try{ce(await s.listGlobalTables())}catch(c){const y=c;ce(null),me(Ye(y))}},e[7]=s,e[8]=$):$=e[8];const xe=$;let ue;e[9]!==d?(ue=d.trim(),e[9]=d,e[10]=ue):ue=e[10];const D=Bt(ue,400);let ve,ye;e[11]!==D||e[12]!==h||e[13]!==xe?(ye=()=>{M(h(D)),M(xe())},ve=[h,xe,D],e[11]=D,e[12]=h,e[13]=xe,e[14]=ve,e[15]=ye):(ve=e[14],ye=e[15]),Ge(ye,ve);let pe;e[16]!==s||e[17]!==_||e[18]!==P||e[19]!==d?(pe=async c=>{if(P===c){O(null);return}O(c);const y=`${d}:${c}`;if(_[y]!==void 0)return;const[N,U]=await Promise.allSettled([s.query(Ra,{limit:1,offset:0,table:c},Qe(d)),s.query(Ma,{table:c},Qe(d))]);N.status==="fulfilled"?re(I=>({...I,[y]:N.value.columns})):T(Ye(N.reason)),U.status==="fulfilled"&&oe(I=>({...I,[y]:U.value.indexes}))},e[16]=s,e[17]=_,e[18]=P,e[19]=d,e[20]=pe):pe=e[20];const j=pe;let H;e[21]!==s||e[22]!==E||e[23]!==q?(H=async c=>{if(q===c){K(null);return}if(K(c),E[c]===void 0)try{const y=await s.readGlobalTablePage({limit:1,offset:0,table:c});ae(N=>({...N,[c]:y.columns}))}catch(y){me(Ye(y))}},e[21]=s,e[22]=E,e[23]=q,e[24]=H):H=e[24];const le=H,$e=Ct(void 0);let he,ge;e[25]!==o||e[26]!==p||e[27]!==j?(he=()=>{o===void 0||p===null||$e.current===o||p.some(c=>c.name===o)&&($e.current=o,M(j(o)))},ge=[o,p,j],e[25]=o,e[26]=p,e[27]=j,e[28]=he,e[29]=ge):(he=e[28],ge=e[29]),Ge(he,ge);let J;e[30]!==s?(J=async(c,y,N)=>{const[U,I]=await Promise.all([Promise.allSettled([s.query(Pa,{tables:[...y,...N]},Qe(c))]),Promise.all(N.map(async se=>{const Be=await Promise.allSettled([s.readGlobalTablePage({limit:1,offset:0,table:se})]),xt=Be[0].status==="fulfilled"?Be[0].value:void 0;return{columns:xt?.columns??[],refs:xt?.refs??{},table:se}}))]),Lt=U[0].status==="fulfilled"?U[0].value?.columnsByTable??{}:{},Mt=U[0].status==="rejected",Rt=new Map(I.map(Ka)),Pt=[...y,...N].map(se=>{const Be=Lt[se]??[];return[se,Be.length>0?Be:Rt.get(se)??[]]});ie(se=>({...se,[c]:Object.fromEntries(Pt)})),de(se=>({...se,[c]:Mt}))},e[30]=s,e[31]=J):J=e[31];const V=J;let W,fe;e[32]!==S||e[33]!==w||e[34]!==V||e[35]!==A||e[36]!==d||e[37]!==p||e[38]!==i?(W=()=>{i!=="graph"||p===null||w===null&&S===null||A[d]!==void 0||M(V(d,p.map(Da),(w??[]).map(Ha)))},fe=[i,p,w,S,d,A,V],e[32]=S,e[33]=w,e[34]=V,e[35]=A,e[36]=d,e[37]=p,e[38]=i,e[39]=W,e[40]=fe):(W=e[39],fe=e[40]),Ge(W,fe);const k=A[d]??Aa;let X;if(e[41]!==k||e[42]!==w||e[43]!==p){let c;e[45]!==k?(c=I=>({columns:k[I.name]??St,name:I.name,tier:"shard"}),e[45]=k,e[46]=c):c=e[46];const y=(p??[]).map(c);let N;e[47]!==k?(N=I=>({columns:k[I.name]??St,name:I.name,tier:"global"}),e[47]=k,e[48]=N):N=e[48];const U=(w??[]).map(N);X=[...y,...U],e[41]=k,e[42]=w,e[43]=p,e[44]=X}else X=e[44];const ne=X;let Z;if(e[49]!==g||e[50]!==p){const c=g.trim().toLowerCase();Z=(p??[]).filter(y=>y.name.toLowerCase().includes(c)),e[49]=g,e[50]=p,e[51]=Z}else Z=e[51];const Q=Z;let De;if(e[52]!==w||e[53]!==g){const c=g.trim().toLowerCase();De=(w??[]).filter(y=>y.name.toLowerCase().includes(c)),e[52]=w,e[53]=g,e[54]=De}else De=e[54];const ke=De;let He;e[55]===Symbol.for("react.memo_cache_sentinel")?(He=()=>{m("list")},e[55]=He):He=e[55];const jt=He;let Je;e[56]===Symbol.for("react.memo_cache_sentinel")?(Je=()=>{m("graph")},e[56]=Je):Je=e[56];const Ot=Je;let Ve;e[57]===Symbol.for("react.memo_cache_sentinel")?(Ve=c=>{b(c.target.value)},e[57]=Ve):Ve=e[57];const Ft=Ve;let We;e[58]!==h||e[59]!==d?(We=c=>{M(h(d))},e[58]=h,e[59]=d,e[60]=We):We=e[60];const lt=We;let Ce;e[61]!==p?(Ce=p??[],e[61]=p,e[62]=Ce):Ce=e[62];let Xe;e[63]!==Ce?(Xe=Ce.map(Ja),e[63]=Ce,e[64]=Xe):Xe=e[64];const nt=Xe;let Te;e[65]!==d?(Te=n(qt,{onChange:f,testId:"sc-shard-input",value:d}),e[65]=d,e[66]=Te):Te=e[66];let _e;e[67]!==l?(_e=l("Schema view"),e[67]=l,e[68]=_e):_e=e[68];const st=i==="list",rt=i==="list"?"default":"outline";let Ie;e[69]!==l?(Ie=l("Table list"),e[69]=l,e[70]=Ie):Ie=e[70];let ze;e[71]!==st||e[72]!==rt||e[73]!==Ie?(ze=n(z,{"aria-pressed":st,"data-testid":"sc-view-list",onClick:jt,size:"xs",type:"button",variant:rt,children:Ie}),e[71]=st,e[72]=rt,e[73]=Ie,e[74]=ze):ze=e[74];const ot=i==="graph",it=i==="graph"?"default":"outline";let Ee;e[75]!==l?(Ee=l("Graph"),e[75]=l,e[76]=Ee):Ee=e[76];let je;e[77]!==ot||e[78]!==it||e[79]!==Ee?(je=n(z,{"aria-pressed":ot,"data-testid":"sc-view-graph",onClick:Ot,size:"xs",type:"button",variant:it,children:Ee}),e[77]=ot,e[78]=it,e[79]=Ee,e[80]=je):je=e[80];let Oe;e[81]!==_e||e[82]!==ze||e[83]!==je?(Oe=u("div",{"aria-label":_e,className:"flex gap-1.5","data-testid":"sc-view-toggle",role:"group",children:[ze,je]}),e[81]=_e,e[82]=ze,e[83]=je,e[84]=Oe):Oe=e[84];let Fe;e[85]!==Te||e[86]!==Oe?(Fe=u("div",{className:"flex flex-wrap items-center gap-3",children:[Te,Oe]}),e[85]=Te,e[86]=Oe,e[87]=Fe):Fe=e[87];let Le;e[88]!==lt||e[89]!==r||e[90]!==nt?(Le=r===!0&&n(Fa,{onApplied:lt,tableNames:nt}),e[88]=lt,e[89]=r,e[90]=nt,e[91]=Le):Le=e[91];let Me;e[92]!==l||e[93]!==g||e[94]!==i?(Me=i==="list"&&n(Ae,{"aria-label":l("Filter tables"),className:"h-8 max-w-xs","data-testid":"sc-filter",onChange:Ft,placeholder:l("Filter tables"),value:g}),e[92]=l,e[93]=g,e[94]=i,e[95]=Me):Me=e[95];let Re;e[96]!==ne||e[97]!==C||e[98]!==S||e[99]!==Se||e[100]!==d||e[101]!==i?(Re=i==="graph"&&u("div",{className:"flex flex-col gap-2","data-testid":"sc-graph-view",children:[C!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:C}),S!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:S}),n(Ca,{columnsError:Se[d]===!0,tables:ne,testIdPrefix:"sc-graph"})]}),e[96]=ne,e[97]=C,e[98]=S,e[99]=Se,e[100]=d,e[101]=i,e[102]=Re):Re=e[102];let Pe;e[103]!==_||e[104]!==C||e[105]!==P||e[106]!==ke||e[107]!==Q||e[108]!==E||e[109]!==S||e[110]!==q||e[111]!==w||e[112]!==B||e[113]!==d||e[114]!==l||e[115]!==p||e[116]!==j||e[117]!==le||e[118]!==i?(Pe=i==="list"&&u("div",{className:"flex flex-col gap-4",children:[u(mt,{"data-testid":"sc-shard-section",size:"sm",children:[u(ut,{children:[u("div",{className:"flex items-center gap-2",children:[n(ct,{tier:"shard"}),n(pt,{children:l("Shard tables")}),p!==null&&n(we,{className:"ms-auto tabular-nums",variant:"outline",children:Q.length})]}),n(ht,{children:be.shard.hint})]}),u(gt,{children:[C!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-error",role:"alert",children:C}),p!==null&&p.length===0&&n("p",{className:"text-sm text-muted-foreground","data-testid":"sc-empty",children:l("No tables in this shard.")}),p!==null&&p.length>0&&Q.length===0&&n("p",{className:"text-sm text-muted-foreground","data-testid":"sc-no-match",children:l("No tables match your filter.")}),Q.length>0&&n("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-table-list",children:Q.map(c=>{const y=`${d}:${c.name}`,N=B[y]??[];return u($t,{expanded:P===c.name,name:c.name,onToggle:()=>{M(j(c.name))},rowCount:c.rowCount,rowTestId:`sc-table-${c.name}`,toggleTestId:`sc-toggle-${c.name}`,children:[n(kt,{columns:_[y]??wt,testId:`sc-columns-${c.name}`}),N.length>0&&n(Ua,{heading:l("Indexes"),indexes:N,testId:`sc-indexes-${c.name}`})]},c.name)})})]})]}),u(mt,{"data-testid":"sc-global-section",size:"sm",children:[u(ut,{children:[u("div",{className:"flex items-center gap-2",children:[n(ct,{tier:"global"}),n(pt,{children:l("Global tables (D1)")}),w!==null&&n(we,{className:"ms-auto tabular-nums",variant:"outline",children:ke.length})]}),n(ht,{children:be.global.hint})]}),u(gt,{children:[S!==null&&n("p",{className:"text-sm text-destructive","data-testid":"sc-global-error",role:"alert",children:S}),w!==null&&w.length===0&&n(Ut,{description:be.global.hint,testId:"sc-global-empty",title:l("No global tables.")}),w!==null&&w.length>0&&ke.length===0&&n("p",{className:"text-sm text-muted-foreground","data-testid":"sc-global-no-match",children:l("No tables match your filter.")}),ke.length>0&&n("ul",{className:"-mx-3 overflow-hidden border-t border-border","data-testid":"sc-global-table-list",children:ke.map(c=>n($t,{expanded:q===c.name,name:c.name,onToggle:()=>{M(le(c.name))},rowCount:c.rowCount,rowTestId:`sc-global-table-${c.name}`,toggleTestId:`sc-global-toggle-${c.name}`,children:n(kt,{columns:E[c.name]??wt,testId:`sc-global-columns-${c.name}`})},c.name))})]})]})]}),e[103]=_,e[104]=C,e[105]=P,e[106]=ke,e[107]=Q,e[108]=E,e[109]=S,e[110]=q,e[111]=w,e[112]=B,e[113]=d,e[114]=l,e[115]=p,e[116]=j,e[117]=le,e[118]=i,e[119]=Pe):Pe=e[119];let Ze;return e[120]!==Fe||e[121]!==Le||e[122]!==Me||e[123]!==Re||e[124]!==Pe?(Ze=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-schema",children:[Fe,Le,Me,Re,Pe]}),e[120]=Fe,e[121]=Le,e[122]=Me,e[123]=Re,e[124]=Pe,e[125]=Ze):Ze=e[125],Ze};function Ba(a){return n("li",{className:"rounded bg-muted px-1.5 py-0.5 font-mono text-[11px] text-muted-foreground",children:a},a)}function Ga(a){return u("li",{className:"flex flex-wrap items-center gap-1.5 text-xs",children:[n("span",{className:"font-mono",children:a.name}),n(we,{variant:"outline",children:a.type}),a.unique===!0&&n(we,{variant:"secondary",children:"unique"}),n("span",{className:"text-muted-foreground",children:a.fields.join(", ")})]},`${a.type}:${a.name}`)}function Ka(a){const{columns:e,refs:t,table:o}=a;return[o,e.map(r=>{const s=t[r];return s===void 0?{name:r,optional:!1,type:""}:{name:r,optional:!1,ref:s,type:"id"}})]}function Da(a){return a.name}function Ha(a){return a.name}function Ja(a){return a.name}export{vl as SchemaViewer};
@@ -0,0 +1 @@
1
+ import{c as u}from"react/compiler-runtime";import{K as m}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as h}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as f}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{A as g}from"../packem_shared/advisor-view-DaCX9Jy5.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 A}from"react/compiler-runtime";import"react";import{E as F}from"../packem_shared/error-alert-B59DnrDI.js";import{g as V}from"../packem_shared/badge-BbuuAio7.js";import{c as D,u as K}from"../packem_shared/card-CIDGUN6K.js";import{n as z,d as G,m as O,p as C,f as J,u as L}from"../packem_shared/table-DdJBrClo.js";import{K as M}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as P}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{a as q}from"../packem_shared/cf-links-gbDy51nR.js";import{jsx as l,jsxs as s}from"react/jsx-runtime";const B={binding:"outline",secret:"destructive",var:"secondary"},de=o=>{const e=A(68),{initialShardKey:j}=o,t=P();let k;e[0]===Symbol.for("react.memo_cache_sentinel")?(k={},e[0]=k):k=e[0];const S=j??"";let w;e[1]!==S?(w={shardKey:S},e[1]=S,e[2]=w):w=e[2];const{data:U,error:m,errorSource:E,isLoading:$}=M(W.getSettings,k,w);let R;e:{const n=U?.deploy;if(n===void 0){let r;e[3]===Symbol.for("react.memo_cache_sentinel")?(r=[],e[3]=r):r=e[3],R=r;break e}let i;if(e[4]!==n.deploymentId||e[5]!==n.environment||e[6]!==n.versionTag||e[7]!==n.workerUrl||e[8]!==t){if(i=[],n.workerUrl!==void 0){let r;e[10]!==t?(r=t("URL"),e[10]=t,e[11]=r):r=e[11];let a;e[12]!==n.workerUrl||e[13]!==r?(a={label:r,value:n.workerUrl},e[12]=n.workerUrl,e[13]=r,e[14]=a):a=e[14],i.push(a)}if(n.environment!==void 0){let r;e[15]!==t?(r=t("Environment"),e[15]=t,e[16]=r):r=e[16];let a;e[17]!==n.environment||e[18]!==r?(a={label:r,value:n.environment},e[17]=n.environment,e[18]=r,e[19]=a):a=e[19],i.push(a)}if(n.deploymentId!==void 0){let r;e[20]!==t?(r=t("Deployment"),e[20]=t,e[21]=r):r=e[21];let a;e[22]!==n.deploymentId||e[23]!==r?(a={label:r,value:n.deploymentId},e[22]=n.deploymentId,e[23]=r,e[24]=a):a=e[24],i.push(a)}if(n.versionTag!==void 0){let r;e[25]!==t?(r=t("Version"),e[25]=t,e[26]=r):r=e[26];let a;e[27]!==n.versionTag||e[28]!==r?(a={label:r,value:n.versionTag},e[27]=n.versionTag,e[28]=r,e[29]=a):a=e[29],i.push(a)}e[4]=n.deploymentId,e[5]=n.environment,e[6]=n.versionTag,e[7]=n.workerUrl,e[8]=t,e[9]=i}else i=e[9];R=i}const I=R;let T;e[30]!==U?.settings?(T=U?.settings??[],e[30]=U?.settings,e[31]=T):T=e[31];const d=T;let c;e[32]!==t?(c=t("Open in Cloudflare"),e[32]=t,e[33]=c):c=e[33];let p;e[34]!==c?(p=l("div",{className:"flex flex-wrap items-center gap-3",children:l("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"set-cf-link",href:q,rel:"noreferrer",target:"_blank",children:c})}),e[34]=c,e[35]=p):p=e[35];let u;e[36]!==t?(u=t("View-only — values are masked. Edit vars, secrets, and bindings in wrangler or the Cloudflare dashboard."),e[36]=t,e[37]=u):u=e[37];let h;e[38]!==u?(h=l("p",{className:"text-sm text-muted-foreground","data-testid":"set-readonly-note",children:u}),e[38]=u,e[39]=h):h=e[39];let f;e[40]!==m||e[41]!==E?(f=m!==null&&l(F,{error:E,testId:"set-error"}),e[40]=m,e[41]=E,e[42]=f):f=e[42];let g;e[43]!==I||e[44]!==t?(g=I.length>0&&s(D,{className:"py-0","data-testid":"set-deploy",children:[l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Deployment")})}),l(K,{className:"py-3",children:l("dl",{className:"grid grid-cols-[8rem_minmax(0,1fr)] gap-x-4 gap-y-1 text-sm",children:I.map(H)})})]}),e[43]=I,e[44]=t,e[45]=g):g=e[45];let v;e[46]!==t?(v=t("Environment & bindings"),e[46]=t,e[47]=v):v=e[47];let x;e[48]!==v?(x=l("header",{className:"border-b border-border px-4 py-3",children:l("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:v})}),e[48]=v,e[49]=x):x=e[49];let y;e[50]!==m||e[51]!==$||e[52]!==d.length||e[53]!==t?(y=m===null&&!$&&d.length===0&&l("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"set-empty",children:t("No environment variables or bindings.")}),e[50]=m,e[51]=$,e[52]=d.length,e[53]=t,e[54]=y):y=e[54];let b;e[55]!==d||e[56]!==t?(b=d.length>0&&l(K,{className:"px-0 py-0",children:s(z,{"data-testid":"set-table",children:[l(G,{children:s(O,{children:[l(C,{children:t("name")}),l(C,{children:t("kind")}),l(C,{children:t("value")})]})}),l(J,{children:d.map(Q)})]})}),e[55]=d,e[56]=t,e[57]=b):b=e[57];let N;e[58]!==x||e[59]!==y||e[60]!==b?(N=s(D,{className:"py-0",children:[x,y,b]}),e[58]=x,e[59]=y,e[60]=b,e[61]=N):N=e[61];let _;return e[62]!==f||e[63]!==g||e[64]!==N||e[65]!==p||e[66]!==h?(_=s("div",{className:"flex flex-col gap-4","data-testid":"lunora-settings",children:[p,h,f,g,N]}),e[62]=f,e[63]=g,e[64]=N,e[65]=p,e[66]=h,e[67]=_):_=e[67],_};function H(o){return s("div",{className:"contents","data-testid":"set-deploy-row",children:[l("dt",{className:"text-muted-foreground",children:o.label}),l("dd",{className:"truncate font-mono text-xs",title:o.value,children:o.value})]},o.label)}function Q(o){return s(O,{"data-testid":"set-row",children:[l(L,{className:"font-mono text-xs font-medium",children:o.name}),l(L,{children:l(V,{variant:B[o.kind],children:o.bindingType??o.kind})}),l(L,{className:"max-w-[28ch] truncate font-mono text-xs text-muted-foreground",children:o.value??l("span",{className:"text-muted-foreground",children:"—"})})]},o.name)}export{de as SettingsPanel};
@@ -0,0 +1,4 @@
1
+ import{c as K}from"react/compiler-runtime";import{useLunora as Ie}from"@lunora/react";import{useState as J,useRef as X,useEffect as fe,useId as gt}from"react";import{j as vt}from"../packem_shared/result-chart-CwKhhKM0.js";import{ShardInput as yt}from"../packem_shared/ShardInput-BVn2iCU0.js";import{A as Nt}from"../packem_shared/alert-CVcOFuDR.js";import{d as kt,m as we,f as wt,n as qt,p as Ct,u as St}from"../packem_shared/table-DdJBrClo.js";import{useT as V}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as be}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{u as ue,n as $e,b as Ee}from"../packem_shared/browser-storage-xjTyMKY0.js";import{f as Z,c as me,a as he,e as It}from"../packem_shared/internal-AtZ4bTal.js";import{r as $t}from"../packem_shared/shard-history-DMEW5VBE.js";import{y as Et}from"../packem_shared/data-grid-BMBKzMEJ.js";import{J as Tt}from"../packem_shared/grid-features-uZCUj955.js";import{c as xe}from"../packem_shared/utils-bhneXptQ.js";import{jsx as a,jsxs as w,Fragment as qe}from"react/jsx-runtime";const Lt=["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"],Rt=["FROM","WHERE","ORDER BY","GROUP BY","HAVING","LIMIT","OFFSET","UNION","JOIN","LEFT JOIN","RIGHT JOIN","INNER JOIN","OUTER JOIN","CROSS JOIN"],ne=String.fromCodePoint(0),Ot=new RegExp(`${ne}${String.raw`(\d+)`}${ne}`,"gu"),Dt=Lt.map(r=>({pattern:new RegExp(String.raw`\b${r.replaceAll(" ",String.raw`\s+`)}\b`,"giu"),replacement:r})),Mt=Rt.map(r=>({pattern:new RegExp(String.raw`\s+${r.replaceAll(" ",String.raw`\s+`)}\b`,"gu"),replacement:`
2
+ ${r}`})),_t=r=>{const e=[];let t=r.replaceAll(/'(?:[^']|'')*'/gu,n=>(e.push(n),`${ne}${(e.length-1).toString()}${ne}`)).replaceAll(/\s+/gu," ").trim();for(const{pattern:n,replacement:l}of Dt)t=t.replaceAll(n,l);for(const{pattern:n,replacement:l}of Mt)t=t.replaceAll(n,l);return t=t.replaceAll(Ot,(n,l)=>e[Number(l)]??""),t},At=["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"],zt=new Set(["AND","BY","HAVING","ON","OR","SELECT","WHERE"]),jt=/[\w$]/,Te=r=>r!==void 0&&jt.test(r),Le=r=>{let e=r.length;for(;e>0&&Te(r[e-1]);)e-=1;return r.slice(e)},Re=(r,e)=>{let t=e;for(;t>0&&Te(r[t-1]);)t-=1;return{end:e,start:t,text:r.slice(t,e)}},Ce=(r,e)=>{const t=r.slice(0,e).trimEnd();return t.endsWith(".")||zt.has(Le(t).toUpperCase())},Bt=(r,e)=>{const t=r.slice(0,e);if(!t.endsWith("."))return;const n=Le(t.slice(0,-1));return n===""?void 0:n},ge=(r,e)=>r.toLowerCase().startsWith(e.toLowerCase()),Se=(r,e,t,n)=>{const l=[];for(const s of r)if(ge(s,e)&&(l.push(n(s)),l.length>=t))break;return l},Wt=(r,e,t)=>{const n=new Map;for(const[l,s]of Object.entries(r.columns))for(const c of s)if(ge(c,e)&&!n.has(c)&&(n.set(c,l),n.size>=t))return[...n].map(([m,i])=>({detail:i,kind:"column",label:m}));return[...n].map(([l,s])=>({detail:s,kind:"column",label:l}))},Ft=(r,e,t)=>{const n=Re(r,e),l=Bt(r,n.start);if(l!==void 0){const i=t.columns[l]??t.columns[l.toLowerCase()]??[];return Se(i,n.text,8,u=>({detail:l,kind:"column",label:u}))}if(n.text===""&&!Ce(r,n.start))return[];const s=Se(t.tables,n.text,8,i=>({kind:"table",label:i})),c=Wt(t,n.text,8),m=At.filter(i=>n.text!==""&&ge(i,n.text)&&i.toLowerCase()!==n.text.toLowerCase()).map(i=>({kind:"keyword",label:i}));return(Ce(r,n.start)?[...c,...s,...m]:[...s,...c,...m]).slice(0,8)},Ht=(r,e,t)=>{const n=Re(r,e),l=r.slice(0,n.start)+t.label+r.slice(n.end);return{caret:n.start+t.label.length,value:l}},Pt=["boxSizing","borderBottomWidth","borderLeftWidth","borderRightWidth","borderTopWidth","fontFamily","fontSize","fontStyle","fontWeight","letterSpacing","lineHeight","paddingBottom","paddingLeft","paddingRight","paddingTop","tabSize","textIndent","textTransform","width","wordSpacing"],Ut=(r,e)=>{const t=globalThis.getComputedStyle(r),n=globalThis.document.createElement("div"),{style:l}=n;l.position="absolute",l.visibility="hidden",l.whiteSpace="pre-wrap",l.overflowWrap="break-word";for(const i of Pt)l[i]=t[i];n.textContent=r.value.slice(0,Math.max(0,e));const s=globalThis.document.createElement("span");s.textContent=r.value.slice(Math.max(0,e))||".",n.append(s),globalThis.document.body.append(n);const c=s.offsetLeft-r.scrollLeft,m=s.offsetTop-r.scrollTop;return n.remove(),{left:c,top:m}},Jt=(r,e,t)=>{const n=K(13),[l,s]=J(null);let c;n[0]!==r||n[1]!==e?(c=(v,g)=>{const y=Ft(v,g,r);if(y.length===0){s(null);return}const b=e.current,{left:C,top:q}=b===null?{left:0,top:0}:Ut(b,g);s($=>$!==null&&$.active===0&&$.left===C&&$.top===q&&$.suggestions.length===y.length&&$.suggestions.every((S,O)=>{const L=y.at(O);return S.kind===L?.kind&&S.label===L.label&&S.detail===L.detail})?$:{active:0,left:C,suggestions:y,top:q})},n[0]=r,n[1]=e,n[2]=c):c=n[2];const m=c;let i;n[3]===Symbol.for("react.memo_cache_sentinel")?(i=()=>{s(null)},n[3]=i):i=n[3];const u=i;let N;n[4]===Symbol.for("react.memo_cache_sentinel")?(N=v=>{s(g=>{if(g===null)return g;const y=g.suggestions.length,b=(g.active+v+y)%y;return{...g,active:b}})},n[4]=N):N=n[4];const x=N;let h;n[5]!==t||n[6]!==l||n[7]!==e?(h=()=>{const v=e.current;if(l===null||v===null)return!1;const g=l.suggestions[l.active];if(g===void 0)return!1;const y=Ht(v.value,v.selectionStart,g);return t(y.value),s(null),requestAnimationFrame(()=>{const b=e.current;b!==null&&(b.focus(),b.setSelectionRange(y.caret,y.caret))}),!0},n[5]=t,n[6]=l,n[7]=e,n[8]=h):h=n[8];const p=h;let d;return n[9]!==p||n[10]!==m||n[11]!==l?(d={close:u,commit:p,move:x,refresh:m,state:l},n[9]=p,n[10]=m,n[11]=l,n[12]=d):d=n[12],d},Kt={column:"column",keyword:"keyword",table:"table"},Yt=20,Vt=r=>{const e=K(17),{listboxId:t,onPick:n,state:l}=r,s=V();let c;e[0]!==l?(c=l===null?void 0:{left:l.left,top:l.top+Yt},e[0]=l,e[1]=c):c=e[1];const m=c;if(l===null)return null;let i;if(e[2]!==t||e[3]!==n||e[4]!==l.active||e[5]!==l.suggestions||e[6]!==s){let N;e[8]!==t||e[9]!==n||e[10]!==l.active||e[11]!==s?(N=(x,h)=>w("li",{"aria-selected":h===l.active,className:xe("flex cursor-pointer items-center gap-2 px-2 py-1 text-[13px]",h===l.active?"bg-accent text-accent-foreground":"text-foreground"),"data-testid":"sql-autocomplete-item",id:`${t}-opt-${h.toString()}`,onMouseDown:p=>{p.preventDefault(),n(h)},role:"option",children:[a("span",{className:"truncate font-mono",children:x.label}),x.detail!==void 0&&a("span",{className:"ms-auto truncate text-xs text-muted-foreground",children:x.detail}),a("span",{className:"shrink-0 font-mono text-[10px] tracking-wide text-muted-foreground/70 uppercase",children:s(Kt[x.kind])})]},`${x.kind}:${x.label}`),e[8]=t,e[9]=n,e[10]=l.active,e[11]=s,e[12]=N):N=e[12],i=l.suggestions.map(N),e[2]=t,e[3]=n,e[4]=l.active,e[5]=l.suggestions,e[6]=s,e[7]=i}else i=e[7];let u;return e[13]!==t||e[14]!==m||e[15]!==i?(u=a("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:m,children:i}),e[13]=t,e[14]=m,e[15]=i,e[16]=u):u=e[16],u},Oe=[{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;"}],Gt=r=>{const e=K(29),{active:t,onDelete:n,onSelect:l,query:s}=r,c=V();let m;e[0]!==l||e[1]!==s.id?(m=()=>{l(s.id)},e[0]=l,e[1]=s.id,e[2]=m):m=e[2];const i=m;let u;e[3]!==n||e[4]!==s.id?(u=S=>{S.stopPropagation(),n(s.id)},e[3]=n,e[4]=s.id,e[5]=u):u=e[5];const N=u,x=t?"bg-sidebar-accent font-medium text-foreground":"text-muted-foreground";let h;e[6]!==x?(h=xe("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",x),e[6]=x,e[7]=h):h=e[7];const p=`sql-query-${s.id}`;let d;e[8]===Symbol.for("react.memo_cache_sentinel")?(d=a("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:a("path",{d:"M4 6h16M4 12h10M4 18h7"})}),e[8]=d):d=e[8];let v;e[9]!==s.name?(v=a("span",{className:"truncate",children:s.name}),e[9]=s.name,e[10]=v):v=e[10];let g;e[11]!==t||e[12]!==i||e[13]!==h||e[14]!==p||e[15]!==v?(g=w("button",{"aria-pressed":t,className:h,"data-testid":p,onClick:i,type:"button",children:[d,v]}),e[11]=t,e[12]=i,e[13]=h,e[14]=p,e[15]=v,e[16]=g):g=e[16];let y;e[17]!==c?(y=c("Delete query"),e[17]=c,e[18]=y):y=e[18];let b;e[19]!==c?(b=c("Delete query"),e[19]=c,e[20]=b):b=e[20];let C;e[21]===Symbol.for("react.memo_cache_sentinel")?(C=a("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:a("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[21]=C):C=e[21];let q;e[22]!==N||e[23]!==b||e[24]!==y?(q=a("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:N,title:b,type:"button",children:C}),e[22]=N,e[23]=b,e[24]=y,e[25]=q):q=e[25];let $;return e[26]!==q||e[27]!==g?($=w("li",{className:"group/q flex items-center",children:[g,q]}),e[26]=q,e[27]=g,e[28]=$):$=e[28],$},Qt=r=>{const e=K(58),{activeId:t,history:n,listRef:l,onClearHistory:s,onDelete:c,onLoadHistory:m,onLoadTemplate:i,onNew:u,onSearchChange:N,onSelect:x,queries:h,search:p}=r,d=V();let v;if(e[0]!==h||e[1]!==p){const I=p.trim().toLowerCase();v=I===""?[...h]:h.filter(T=>T.name.toLowerCase().includes(I)),e[0]=h,e[1]=p,e[2]=v}else v=e[2];const g=v;let y;e[3]!==d?(y=d("Search queries…"),e[3]=d,e[4]=y):y=e[4];let b;e[5]!==N||e[6]!==p||e[7]!==y?(b=a("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:N,placeholder:y,type:"text",value:p}),e[5]=N,e[6]=p,e[7]=y,e[8]=b):b=e[8];let C;e[9]!==d?(C=d("New query"),e[9]=d,e[10]=C):C=e[10];let q;e[11]!==d?(q=d("New query"),e[11]=d,e[12]=q):q=e[12];let $;e[13]===Symbol.for("react.memo_cache_sentinel")?($=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:a("path",{d:"M12 5v14M5 12h14"})}),e[13]=$):$=e[13];let S;e[14]!==u||e[15]!==C||e[16]!==q?(S=a("button",{"aria-label":C,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:u,title:q,type:"button",children:$}),e[14]=u,e[15]=C,e[16]=q,e[17]=S):S=e[17];let O;e[18]!==b||e[19]!==S?(O=w("div",{className:"flex shrink-0 items-center gap-2 border-b border-border p-2",children:[b,S]}),e[18]=b,e[19]=S,e[20]=O):O=e[20];let L;e[21]!==d?(L=d("Private"),e[21]=d,e[22]=L):L=e[22];let D;e[23]!==L?(D=a("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:L}),e[23]=L,e[24]=D):D=e[24];let M;e[25]!==t||e[26]!==g||e[27]!==l||e[28]!==c||e[29]!==x||e[30]!==d?(M=g.length===0?a("p",{className:"px-1 py-2 text-xs text-muted-foreground","data-testid":"sql-private-empty",children:d("No saved queries yet — they save to this browser as you type.")}):a("ul",{className:"flex flex-col gap-px","data-testid":"sql-private",ref:l,children:g.map(I=>a(Gt,{active:t===I.id,onDelete:c,onSelect:x,query:I},I.id))}),e[25]=t,e[26]=g,e[27]=l,e[28]=c,e[29]=x,e[30]=d,e[31]=M):M=e[31];let A;e[32]!==D||e[33]!==M?(A=w("div",{children:[D,M]}),e[32]=D,e[33]=M,e[34]=A):A=e[34];let z;e[35]!==d?(z=d("Reference"),e[35]=d,e[36]=z):z=e[36];let H;e[37]!==z?(H=a("p",{className:"px-1 pb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:z}),e[37]=z,e[38]=H):H=e[38];let W;e[39]!==i?(W=Oe.map(I=>a("li",{children:w("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,onClick:i,type:"button",children:[a("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:a("path",{d:"M7 4h7l4 4v12H7zM14 4v4h4"})}),I.label]})},I.label)),e[39]=i,e[40]=W):W=e[40];let _;e[41]!==W?(_=a("ul",{className:"flex flex-col gap-px",children:W}),e[41]=W,e[42]=_):_=e[42];let E;e[43]!==H||e[44]!==_?(E=w("div",{children:[H,_]}),e[43]=H,e[44]=_,e[45]=E):E=e[45];let R;e[46]!==n||e[47]!==s||e[48]!==m||e[49]!==d?(R=n.length>0&&w("div",{children:[w("div",{className:"flex items-center justify-between px-1 pb-1",children:[a("p",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("History")}),a("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:s,type:"button",children:d("Clear history")})]}),a("ul",{className:"flex flex-col gap-px","data-testid":"sql-history",children:n.map(I=>a("li",{children:w("button",{className:"flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-start text-[13px] text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-foreground focus-visible:bg-sidebar-accent","data-sql":I.sql,"data-testid":"sql-history-item",onClick:m,title:I.sql,type:"button",children:[a("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:a("path",{d:"M12 8v4l3 2M12 21a9 9 0 1 1 0-18 9 9 0 0 1 0 18Z"})}),a("span",{className:"truncate font-mono",children:I.sql})]})},`${I.at.toString()}:${I.sql}`))})]}),e[46]=n,e[47]=s,e[48]=m,e[49]=d,e[50]=R):R=e[50];let j;e[51]!==A||e[52]!==E||e[53]!==R?(j=w("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-2",children:[A,E,R]}),e[51]=A,e[52]=E,e[53]=R,e[54]=j):j=e[54];let B;return e[55]!==j||e[56]!==O?(B=w("aside",{className:"flex h-full w-64 shrink-0 flex-col border-e border-border bg-sidebar",children:[O,j]}),e[55]=j,e[56]=O,e[57]=B):B=e[57],B},Xt=he(be.listTables),Zt=he(be.readTablePage),en=r=>{const e=K(16),t=Ie();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=[],e[0]=n):n=e[0];const[l,s]=J(n);let c;e[1]===Symbol.for("react.memo_cache_sentinel")?(c={},e[1]=c):c=e[1];const[m,i]=J(c);let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=new Set,e[2]=u):u=e[2];const N=X(u);let x,h;e[3]!==t||e[4]!==r?(x=()=>{const b={cancelled:!1};return Z((async()=>{try{const C=await t.query(Xt,{},me(r));b.cancelled||(s(C.map(nn)),i({}),N.current=new Set)}catch{b.cancelled||(s([]),i({}),N.current=new Set)}})()),()=>{b.cancelled=!0}},h=[t,r],e[3]=t,e[4]=r,e[5]=x,e[6]=h):(x=e[5],h=e[6]),fe(x,h);let p;e[7]!==t||e[8]!==r?(p=b=>{N.current.has(b)||(N.current.add(b),Z((async()=>{try{const C=await t.query(Zt,{limit:1,offset:0,table:b},me(r));i(q=>({...q,[b]:C.columns}))}catch{N.current.delete(b)}})()))},e[7]=t,e[8]=r,e[9]=p):p=e[9];const d=p;let v;e[10]!==m||e[11]!==l?(v={columns:m,tables:l},e[10]=m,e[11]=l,e[12]=v):v=e[12];const g=v;let y;return e[13]!==d||e[14]!==g?(y={probe:d,schema:g},e[13]=d,e[14]=g,e[15]=y):y=e[15],y},ce=/\b(?:from|join|update|into)\s+([a-z_][\w$]*)|\b([a-z_][\w$]*)\s*\./gi,tn=r=>{const e=new Set;ce.lastIndex=0;let t=ce.exec(r);for(;t!==null;)e.add(t[1]??t[2]),t=ce.exec(r);return[...e]};function nn(r){return r.name}const rn="lunora-studio-sql-tabs",ln="lunora-studio-sql-active-tab",pe=12,Q=(r="",e="")=>({activeId:null,id:$e("tab"),name:e,sql:r}),on=()=>Ee(ln,""),sn=r=>{const[e,t]=ue(rn),[n,l]=on(),s=X(null);e.length===0&&s.current===null&&(s.current=r()),fe(()=>{if(e.length===0&&s.current!==null){const m=s.current;t([m])}},[t,e.length]);const c=e.length===0&&s.current!==null?[s.current]:e;return{activeId:c.some(m=>m.id===n)?n:c[0]?.id??"",setActiveId:l,setTabs:t,tabs:c}},De=r=>r.activeId===null&&r.sql.trim()!=="",an=(r,e)=>[...r,e].slice(-pe),cn=(r,e,t)=>{const n=r.findIndex(s=>s.id===e);if(n===-1)return{activeId:r[0]?.id??"",tabs:[...r]};const l=r.filter(s=>s.id!==e);if(l.length===0){const s=t();return{activeId:s.id,tabs:[s]}}return{activeId:l[Math.min(n,l.length-1)].id,tabs:l}},dn=(r,e)=>{const t=r.filter(n=>n.id===e);return t.length===0?{activeId:r[0]?.id??"",tabs:[...r]}:{activeId:e,tabs:t}},un=(r,e,t)=>{const n=r.findIndex(s=>s.id===e);if(n===-1)return{activeId:t,tabs:[...r]};const l=r.slice(0,n+1);return{activeId:l.some(s=>s.id===t)?t:e,tabs:l}},mn=r=>{const e=r();return{activeId:e.id,tabs:[e]}},pn=(r,e,t)=>{if(r==="others")return e.filter(n=>n.id!==t);if(r==="right"){const n=e.findIndex(l=>l.id===t);return n===-1?[]:e.slice(n+1)}return[...e]},fn=(r,e)=>r.trim()===""?e:(r.split(`
3
+ `)[0]??r).slice(0,24),bn=r=>{const e=K(14),{initial:t,onCancel:n,onCommit:l,placeholder:s,testId:c}=r,m=V(),i=gn;let u;e[0]!==l?(u=v=>{l(v.currentTarget.value.trim())},e[0]=l,e[1]=u):u=e[1];const N=u;let x;e[2]!==n||e[3]!==l?(x=v=>{v.key==="Enter"?l(v.currentTarget.value.trim()):v.key==="Escape"&&n()},e[2]=n,e[3]=l,e[4]=x):x=e[4];const h=x;let p;e[5]!==m?(p=m("Tab title"),e[5]=m,e[6]=p):p=e[6];let d;return e[7]!==t||e[8]!==N||e[9]!==h||e[10]!==s||e[11]!==p||e[12]!==c?(d=a("input",{"aria-label":p,className:"w-40 rounded border border-ring bg-background px-1 py-0.5 text-xs outline-none","data-testid":c,defaultValue:t,onBlur:N,onKeyDown:h,placeholder:s,ref:i,type:"text"}),e[7]=t,e[8]=N,e[9]=h,e[10]=s,e[11]=p,e[12]=c,e[13]=d):d=e[13],d},hn=r=>{const e=K(29),{idBase:t,onDiscard:n,onKeep:l}=r,s=V(),c=`sql-tab-close-prompt-${t}`;let m;e[0]!==s?(m=s("Discard?"),e[0]=s,e[1]=m):m=e[1];let i;e[2]!==m?(i=a("span",{className:"text-[11px] text-muted-foreground",children:m}),e[2]=m,e[3]=i):i=e[3];let u;e[4]!==s?(u=s("Discard changes"),e[4]=s,e[5]=u):u=e[5];const N=`sql-tab-close-confirm-${t}`;let x;e[6]!==s?(x=s("Discard changes"),e[6]=s,e[7]=x):x=e[7];let h;e[8]===Symbol.for("react.memo_cache_sentinel")?(h=a("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:a("path",{d:"M5 13l4 4L19 7"})}),e[8]=h):h=e[8];let p;e[9]!==n||e[10]!==u||e[11]!==N||e[12]!==x?(p=a("button",{"aria-label":u,className:"flex size-5 items-center justify-center rounded text-destructive hover:bg-destructive/10","data-testid":N,onClick:n,title:x,type:"button",children:h}),e[9]=n,e[10]=u,e[11]=N,e[12]=x,e[13]=p):p=e[13];let d;e[14]!==s?(d=s("Keep editing"),e[14]=s,e[15]=d):d=e[15];const v=`sql-tab-close-cancel-${t}`;let g;e[16]!==s?(g=s("Keep editing"),e[16]=s,e[17]=g):g=e[17];let y;e[18]===Symbol.for("react.memo_cache_sentinel")?(y=a("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2.4,viewBox:"0 0 24 24",children:a("path",{d:"M6 6l12 12M18 6 6 18"})}),e[18]=y):y=e[18];let b;e[19]!==l||e[20]!==v||e[21]!==g||e[22]!==d?(b=a("button",{"aria-label":d,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-accent","data-testid":v,onClick:l,title:g,type:"button",children:y}),e[19]=l,e[20]=v,e[21]=g,e[22]=d,e[23]=b):b=e[23];let C;return e[24]!==c||e[25]!==b||e[26]!==i||e[27]!==p?(C=w("span",{className:"flex shrink-0 items-center gap-1","data-testid":c,role:"group",children:[i,p,b]}),e[24]=c,e[25]=b,e[26]=i,e[27]=p,e[28]=C):C=e[28],C},xn=r=>{const e=K(47),{active:t,canClose:n,onClose:l,onMenu:s,onRename:c,onSelect:m,tab:i}=r,u=V(),[N,x]=J(!1),[h,p]=J(!1);let d;e[0]!==s||e[1]!==i.id?(d=F=>{s(i.id,F)},e[0]=s,e[1]=i.id,e[2]=d):d=e[2];const v=d;let g;e[3]!==m||e[4]!==i.id?(g=()=>{m(i.id)},e[3]=m,e[4]=i.id,e[5]=g):g=e[5];const y=g;let b;e[6]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{x(!0)},e[6]=b):b=e[6];const C=b;let q;e[7]!==l||e[8]!==i?(q=F=>{F.stopPropagation(),De(i)?p(!0):l(i.id)},e[7]=l,e[8]=i,e[9]=q):q=e[9];const $=q;let S;e[10]!==l||e[11]!==i.id?(S=F=>{F.stopPropagation(),p(!1),l(i.id)},e[10]=l,e[11]=i.id,e[12]=S):S=e[12];const O=S;let L;e[13]===Symbol.for("react.memo_cache_sentinel")?(L=F=>{F.stopPropagation(),p(!1)},e[13]=L):L=e[13];const D=L;let M;e[14]!==c||e[15]!==i.id?(M=F=>{c(i.id,F),x(!1)},e[14]=c,e[15]=i.id,e[16]=M):M=e[16];const A=M;let z;e[17]===Symbol.for("react.memo_cache_sentinel")?(z=()=>{x(!1)},e[17]=z):z=e[17];const H=z;let W;e[18]!==i.name?(W=i.name.trim(),e[18]=i.name,e[19]=W):W=e[19];const _=W;let E;e[20]!==u||e[21]!==i.sql?(E=fn(i.sql,u("Untitled")),e[20]=u,e[21]=i.sql,e[22]=E):E=e[22];const R=E,j=t?"bg-background text-foreground":"bg-muted/40 text-muted-foreground hover:text-foreground";let B;e[23]!==j?(B=xe("group/tab flex shrink-0 items-center gap-1 border-e border-border ps-3 pe-1.5 text-xs",j),e[23]=j,e[24]=B):B=e[24];const I=`sql-tab-${i.id}`;let T;e[25]!==t||e[26]!==A||e[27]!==_||e[28]!==R||e[29]!==N||e[30]!==y||e[31]!==u||e[32]!==i.id?(T=N?a(bn,{initial:_,onCancel:H,onCommit:A,placeholder:R,testId:`sql-tab-rename-${i.id}`}):a("button",{"aria-pressed":t,className:"max-w-40 truncate py-1.5 outline-none","data-testid":`sql-tab-select-${i.id}`,onClick:y,onDoubleClick:C,title:u("Double-click to rename"),type:"button",children:_===""?R:_}),e[25]=t,e[26]=A,e[27]=_,e[28]=R,e[29]=N,e[30]=y,e[31]=u,e[32]=i.id,e[33]=T):T=e[33];let P;e[34]!==n||e[35]!==O||e[36]!==h||e[37]!==$||e[38]!==u||e[39]!==i.id?(P=n&&(h?a(hn,{idBase:i.id,onDiscard:O,onKeep:D}):a("button",{"aria-label":u("Close tab"),className:"flex size-5 shrink-0 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive","data-testid":`sql-tab-close-${i.id}`,onClick:$,title:u("Close tab"),type:"button",children:a("svg",{"aria-hidden":"true",className:"size-3",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24",children:a("path",{d:"M6 6l12 12M18 6 6 18"})})})),e[34]=n,e[35]=O,e[36]=h,e[37]=$,e[38]=u,e[39]=i.id,e[40]=P):P=e[40];let G;return e[41]!==v||e[42]!==B||e[43]!==I||e[44]!==T||e[45]!==P?(G=w("div",{className:B,"data-testid":I,onContextMenu:v,children:[T,P]}),e[41]=v,e[42]=B,e[43]=I,e[44]=T,e[45]=P,e[46]=G):G=e[46],G};function gn(r){r?.focus(),r?.select()}const vn=he(be.runSql),yn="lunora-studio-sql-queries",Nn="lunora-studio-sql-history",kn="lunora-studio-sql-split-view",wn=25,qn={minWidth:"2.75rem",paddingInline:"0.5rem"},de={error:null,pane:"results",result:null},Cn=r=>{const e=K(16),{result:t}=r;if(t.columns.length===0){const i=t.rowCount===0?"0 rows":"";let u;return e[0]!==i?(u=a("p",{className:"p-4 text-sm text-muted-foreground",children:i}),e[0]=i,e[1]=u):u=e[1],u}let n;e[2]!==t.columns?(n=t.columns.map(Sn),e[2]=t.columns,e[3]=n):n=e[3];let l;e[4]!==n?(l=a(kt,{className:"sticky top-0 z-10 bg-muted",children:a(we,{children:n})}),e[4]=n,e[5]=l):l=e[5];let s;if(e[6]!==t.columns||e[7]!==t.rows){let i;e[9]!==t.columns?(i=(u,N)=>a(we,{"data-testid":"sql-row",children:t.columns.map(x=>a(St,{className:"max-w-md truncate font-mono text-xs",children:a(Et,{value:u[x]})},x))},N),e[9]=t.columns,e[10]=i):i=e[10],s=t.rows.map(i),e[6]=t.columns,e[7]=t.rows,e[8]=s}else s=e[8];let c;e[11]!==s?(c=a(wt,{children:s}),e[11]=s,e[12]=c):c=e[12];let m;return e[13]!==l||e[14]!==c?(m=w(qt,{"data-testid":"sql-rows",children:[l,c]}),e[13]=l,e[14]=c,e[15]=m):m=e[15],m},Hn=({initialShardKey:r})=>{const e=Ie(),t=V(),[n,l]=ue(yn),[s,c]=ue(Nn),[m,i]=J(""),u=()=>Q(Oe[0]?.sql??""),{activeId:N,setActiveId:x,setTabs:h,tabs:p}=sn(u),[d,v]=J({}),[g,y]=J(r??""),[b,C]=J(!1),[q,$]=Ee(kn,!1),[S,O]=J(null),[L,D]=J(null),M=X(null),A=X(null),z=X(null),H=gt(),{probe:W,schema:_}=en(g),E=p.find(o=>o.id===N)??p[0]??Q(),R=E.sql,{activeId:j}=E,B=d[E.id]??de,{error:I,result:T}=B,P=B.pane,G=o=>{h(f=>f.map(k=>k.id===E.id?{...k,...o}:k))},F=o=>{v(f=>{const k=f[E.id]??de;return{...f,[E.id]:{error:o.error,pane:o.pane??k.pane,result:o.result}}})},ve=o=>{v(f=>{const k=f[E.id]??de;return{...f,[E.id]:{...k,pane:o}}})},re=o=>{G({sql:o}),j!==null&&l(f=>f.map(k=>k.id===j?{...k,sql:o}:k))},Me=Jt(_,A,re),{close:le,commit:ye,move:oe,refresh:ee,state:Y}=Me,_e=o=>{oe(o-(Y?.active??0)),ye()};fe(()=>{const o=A.current;o!==null&&o===document.activeElement&&ee(o.value,o.selectionStart)},[ee,_]);const Ae=o=>{c(f=>f[0]?.sql===o?f:[{at:Date.now(),sql:o},...f.filter(k=>k.sql!==o)].slice(0,wn))},se=async o=>{if(R.trim()==="")return;C(!0);const f=o==="explain"?`EXPLAIN QUERY PLAN ${R}`:R;try{const k=await e.query(vn,{sql:f},me(g));F({error:null,pane:o,result:k}),$t(g),Ae(f)}catch(k){F({error:It(k),pane:o,result:null})}finally{C(!1)}},ze=()=>{Z(se("results"))},je=o=>{const{selectionStart:f,value:k}=o.target;re(k);for(const U of tn(k))W(U);ee(k,f)},Be=o=>{const f=o.currentTarget;ee(f.value,f.selectionStart)},We=o=>{if(Y!==null){if(o.key==="ArrowDown"){o.preventDefault(),oe(1);return}if(o.key==="ArrowUp"){o.preventDefault(),oe(-1);return}if(o.key==="Escape"){o.preventDefault(),le();return}if((o.key==="Enter"||o.key==="Tab")&&!o.metaKey&&!o.ctrlKey&&ye()){o.preventDefault();return}}(o.metaKey||o.ctrlKey)&&o.key==="Enter"&&(o.preventDefault(),Z(se(P)))},Fe=()=>{requestAnimationFrame(()=>{le()})},He=o=>{M.current!==null&&(M.current.scrollTop=o.currentTarget.scrollTop)},te=(o,f)=>{h(k=>k.map(U=>U.id===E.id?{...U,activeId:f,sql:o}:U)),F({error:null,result:null})},Pe=()=>{const o={id:$e("q"),name:t("Untitled query"),sql:""};l(f=>[o,...f]),te("",o.id)},Ue=o=>{const f=n.find(k=>k.id===o);f!==void 0&&(te(f.sql,o),z.current?.querySelector(`[data-testid="sql-query-${o}"]`)?.scrollIntoView({block:"nearest"}))},Je=o=>{l(f=>f.filter(k=>k.id!==o)),h(f=>f.map(k=>k.activeId===o?{...k,activeId:null}:k))},Ke=o=>{te(o.currentTarget.dataset.sql??"",null)},Ye=o=>{te(o.currentTarget.dataset.sql??"",null)},Ve=()=>{c([])},Ge=()=>{re(_t(R))},Qe=()=>{if(p.length>=pe)return;const o=Q();h(f=>an(f,o)),x(o.id)},Ne=o=>{O(null),D(null),h(o.tabs),x(o.activeId);const f=new Set(o.tabs.map(k=>k.id));v(k=>Object.fromEntries(Object.entries(k).filter(([U])=>f.has(U))))},Xe=o=>{Ne(cn(p,o,Q))},ke=(o,f)=>{Ne(o==="others"?dn(p,f):o==="right"?un(p,f,N):mn(Q))},ie=o=>{S!==null&&(pn(o,p,S.id).some(f=>De(f))?D(o):ke(o,S.id))},Ze=(o,f)=>{f.preventDefault(),D(null),O({id:o,x:f.clientX,y:f.clientY})},et=()=>{O(null),D(null)},tt=o=>{o.preventDefault(),O(null),D(null)},nt=()=>{ie("others")},rt=()=>{ie("right")},lt=()=>{ie("all")},ot=()=>{S!==null&&L!==null&&ke(L,S.id),D(null)},st=()=>{D(null)},it=S===null?void 0:{left:S.x,top:S.y},at=o=>{le(),x(o)},ct=(o,f)=>{h(k=>k.map(U=>U.id===o?{...U,name:f}:U))},dt=()=>{ve("results")},ut=()=>{Z(se("explain"))},mt=()=>{ve("chart")},pt=()=>{$(!q)},ft=R.split(`
4
+ `).length,bt=o=>{i(o.target.value)},ae=o=>`border-b-2 px-3 py-2 text-sm outline-none transition-colors ${o?"border-foreground font-medium text-foreground":"border-transparent text-muted-foreground hover:text-foreground"}`,ht=q?"flex min-h-0 flex-1 flex-row":"flex min-h-0 flex-1 flex-col",xt=q?"flex w-2/5 min-h-0 min-w-0 shrink-0 flex-col border-s border-border":"flex h-2/5 min-h-0 shrink-0 flex-col border-t border-border";return w("div",{className:"flex h-full min-w-0","data-testid":"lunora-sql-editor",children:[a(Qt,{activeId:j,history:s,listRef:z,onClearHistory:Ve,onDelete:Je,onLoadHistory:Ye,onLoadTemplate:Ke,onNew:Pe,onSearchChange:bt,onSelect:Ue,queries:n,search:m}),w("div",{className:"flex min-w-0 flex-1 flex-col",children:[w("div",{className:"flex shrink-0 items-stretch overflow-x-auto border-b border-border bg-muted/30","data-testid":"sql-tab-strip",role:"tablist",children:[p.map(o=>a(xn,{active:o.id===E.id,canClose:p.length>1,onClose:Xe,onMenu:Ze,onRename:ct,onSelect:at,tab:o},o.id)),a("button",{"aria-label":t("New tab"),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:p.length>=pe,onClick:Qe,title:t("New tab"),type:"button",children: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:a("path",{d:"M12 5v14M5 12h14"})})})]}),S!==null&&w(qe,{children:[a("div",{className:"fixed inset-0 z-40","data-testid":"sql-tab-menu-backdrop",onClick:et,onContextMenu:tt,role:"presentation"}),a("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:it,children:L===null?w(qe,{children:[a("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:p.length<=1,onClick:nt,role:"menuitem",type:"button",children:t("Close other tabs")}),a("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:p.findIndex(o=>o.id===S.id)>=p.length-1,onClick:rt,role:"menuitem",type:"button",children:t("Close tabs to the right")}),a("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:lt,role:"menuitem",type:"button",children:t("Close all tabs")})]}):w("div",{className:"px-3 py-1.5","data-testid":"sql-tab-menu-confirm",children:[a("p",{className:"pb-1.5 text-xs text-muted-foreground",children:t("Discard unsaved tabs?")}),w("div",{className:"flex items-center gap-1.5",children:[a("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:ot,type:"button",children:t("Discard")}),a("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:st,type:"button",children:t("Cancel")})]})]})})]}),w("div",{className:ht,children:[w("div",{className:"flex min-h-0 min-w-0 flex-1",children:[a("div",{"aria-hidden":"true",className:"shrink-0 select-none overflow-hidden border-e border-border bg-muted/30 py-3 text-end font-mono text-xs leading-5 text-muted-foreground/60",ref:M,style:qn,children:Array.from({length:ft},(o,f)=>a("div",{children:f+1},f))}),w("div",{className:"relative min-w-0 flex-1",children:[a("textarea",{"aria-activedescendant":Y===null?void 0:`${H}-opt-${Y.active.toString()}`,"aria-autocomplete":"list","aria-controls":Y===null?void 0:H,"aria-expanded":Y!==null,"aria-label":t("SQL query"),className:"size-full resize-none bg-background p-3 font-mono text-xs leading-5 outline-none","data-testid":"sql-input",onBlur:Fe,onChange:je,onKeyDown:We,onScroll:He,onSelect:Be,placeholder:"SELECT * FROM …",ref:A,role:"combobox",spellCheck:!1,value:R}),a(Vt,{listboxId:H,onPick:_e,state:Y})]})]}),w("div",{className:xt,children:[w("div",{className:"flex shrink-0 items-center gap-2 border-b border-border pe-2",children:[a("button",{className:ae(P==="results"),"data-testid":"sql-tab-results",onClick:dt,type:"button",children:t("Results")}),a("button",{className:ae(P==="chart"),"data-testid":"sql-tab-chart",onClick:mt,type:"button",children:t("Chart")}),a("button",{className:ae(P==="explain"),"data-testid":"sql-tab-explain",onClick:ut,type:"button",children:t("Explain")}),w("div",{className:"ms-auto flex items-center gap-2",children:[a("button",{"aria-label":t("Split editor and results"),"aria-pressed":q,className:`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 ${q?"bg-accent text-foreground":"text-muted-foreground"}`,"data-testid":"sql-split-toggle",onClick:pt,title:t("Split editor and results"),type:"button",children:w("svg",{"aria-hidden":"true",className:"size-4",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.7,viewBox:"0 0 24 24",children:[a("rect",{height:"16",rx:"2",width:"18",x:"3",y:"4"}),a("path",{d:"M12 4v16"})]})}),T!==null&&T.columns.length>0&&a(Tt,{columns:T.columns,name:"query-result",rows:T.rows}),a("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:b,onClick:Ge,type:"button",children:t("Format")}),a(yt,{onChange:y,testId:"sql-shard-input",value:g}),w("button",{className:"inline-flex items-center gap-1.5 rounded-md bg-primary px-3 py-1.5 text-xs font-medium text-primary-foreground outline-none transition-colors hover:bg-primary/90 focus-visible:bg-primary/90 disabled:pointer-events-none disabled:opacity-50","data-testid":"sql-run",disabled:b,onClick:ze,type:"button",children:[t(b?"Running…":"Run"),a("kbd",{className:"rounded border border-primary-foreground/30 px-1 font-sans text-[10px]",children:"⌘↵"})]})]})]}),w("div",{className:"min-h-0 flex-1 overflow-auto",children:[I!==null&&a(Nt,{className:"m-3 font-mono text-xs",testId:"sql-error",variant:"destructive",children:I}),I===null&&T===null&&a("p",{className:"p-4 text-sm text-muted-foreground","data-testid":"sql-empty",children:t("Click Run to execute your query.")}),I===null&&T!==null&&w("div",{"data-testid":"sql-result",children:[P==="chart"?a(vt,{result:T}):a(Cn,{result:T}),a("p",{className:"border-t border-border px-3 py-1.5 text-xs text-muted-foreground","data-testid":"sql-count",children:T.truncated?t("Showing the first {max} of {count} rows.",{count:T.rowCount,max:T.rows.length}):t("{count} rows",{count:T.rowCount})})]})]})]})]})]})]})};function Sn(r){return a(Ct,{children:r},r)}export{Hn 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{useRef as K,useState as N,useEffect as B}from"react";import{d as S}from"../packem_shared/storage-tier-DznqOf-q.js";import{useT as R}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{s as _,d as C}from"../packem_shared/data-view-params-C8T3bW1z.js";import{f}from"../packem_shared/internal-AtZ4bTal.js";import{l as O,s as P}from"../packem_shared/browser-storage-xjTyMKY0.js";import{DataBrowser as z}from"../packem_shared/DataBrowser-B8J5lHjP.js";import{GlobalDataBrowser as H}from"../packem_shared/GlobalDataBrowser-RLJ6NvOs.js";import{jsx as v,jsxs as $}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=()=>O(j).filter(M),k=r=>{P(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=R();let h;e[0]!==l?(h=y=>{l(y.target.value)},e[0]=l,e[1]=h):h=e[1];const s=h;let c;e[2]!==u?(c=u("Storage tier"),e[2]=u,e[3]=c):c=e[3];let n;e[4]!==c?(n=v("span",{className:"font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:c}),e[4]=c,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 d;e[8]!==s||e[9]!==m.title||e[10]!==o?(d=$("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]=d):d=e[11];let b;return e[12]!==n||e[13]!==d?(b=$("label",{className:"flex w-full flex-col gap-1",htmlFor:"table-editor-schema",children:[n,d]}),e[12]=n,e[13]=d,e[14]=b):b=e[14],b},de=({editable:r=!1,initialShardKey:e})=>{const l=L(),o=Q(),u=q(),h=J({strict:!1}),s=_(h),c=K(h);c.current=h;const n=()=>u.state.location.pathname.split("/").findLast(Boolean)==="data",m=s.tier??"shard",i=s.table,[g,d]=N(()=>w()),[b,y]=N(()=>new Set);B(()=>{f((async()=>{try{const t=await l.listGlobalTables();y(new Set(t.map(a=>a.name)))}catch{}})())},[l]),B(()=>{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=C(t),{current:p}=c;(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=C(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:()=>{try{f(globalThis.navigator.clipboard.writeText(globalThis.location.href))}catch{}},onDeleteQuery:t=>{d(W(t))},onSaveQuery:(t,a)=>{d(U(t,a))},saved:g},x=v(X,{onChange:D,tier:m});return m==="global"?v(H,{initialTable:i,onSelectTable:T,schemaSwitch:x}):v(z,{editable:r,globalTableNames:b,initialFilters:s.filters,initialOrderBy:s.orderBy,initialSearch:s.search,initialShardKey:s.shard??e,onNavigateToGlobal:V,onSelectTable:T,onViewChange:A,queryBar:E,schemaSwitch:x,tableParam:i})};export{de as TableEditor};
@@ -0,0 +1 @@
1
+ import{useState as J}from"react";import{E as S}from"../packem_shared/error-alert-B59DnrDI.js";import{g as C}from"../packem_shared/badge-BbuuAio7.js";import{u as K}from"../packem_shared/button-BkCrNcAs.js";import{c as j,u as I}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{K as y}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as R}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as N}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{i as V}from"../packem_shared/internal-AtZ4bTal.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(j,{className:"overflow-hidden py-0",children:e(I,{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(K,{"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(j,{className:"overflow-hidden py-0","data-testid":"agents-thread-detail",children:n(I,{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(K,{"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{e as Y,f as w,h as B}from"../packem_shared/internal-AtZ4bTal.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-B59DnrDI.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 K}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as M}from"../packem_shared/input-JHu63lTv.js";import{n as O,d as R,m as T,p as w,f as U,u as $}from"../packem_shared/table-DdJBrClo.js";import{K as W}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as B}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as G}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{i as J}from"../packem_shared/internal-AtZ4bTal.js";import{jsx as r,jsxs as i}from"react/jsx-runtime";const ce=()=>{const e=P(39),t=B(),[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}=W(G.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(M,{"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(K,{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(O,{"data-testid":"aa-table",children:[r(R,{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(U,{children:o.map(a=>i(T,{"data-testid":"aa-row",children:[r($,{className:"text-muted-foreground tabular-nums",children:J(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{T as S}from"../packem_shared/use-admin-query-Di3fLE8H.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 T,d as j,m as g,p as c,f as E,u as m}from"../packem_shared/table-DdJBrClo.js";import{T as R}from"../packem_shared/use-admin-query-Di3fLE8H.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-AtZ4bTal.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=R(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(T,{"data-testid":"auth-sessions-table",children:[s(j,{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(E,{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 C}from"react/compiler-runtime";import"react";import{L as S}from"../packem_shared/live-status-CGW2JHf_.js";import{g as b}from"../packem_shared/badge-BbuuAio7.js";import{c as E,u as I}from"../packem_shared/card-CIDGUN6K.js";import{E as L}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as k,d as A,m as w,p as c,f as D,u as l}from"../packem_shared/table-DdJBrClo.js";import{K as M}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as T}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{jsx as n,jsxs as g}from"react/jsx-runtime";const $="container:",_={error:"error",sleep:"sleeping",start:"running",stop:"stopped"},j=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}},K=e=>{const t=new Map;for(const r of e){const a=r.functionPath??"";if(!a.startsWith($))continue;const s=a.slice($.length);if(s==="")continue;const i=JSON.stringify([s,r.instance??""]),m=t.get(i);if(m!==void 0&&m.timestamp>=r.timestamp)continue;const{detail:v,event:o}=j(r.message);t.set(i,{detail:v,event:o,exitCode:r.exitCode,instance:r.instance,level:r.level,name:s,state:_[o]??"unknown",timestamp:r.timestamp})}return[...t.values()].toSorted((r,a)=>r.name.localeCompare(a.name)||(r.instance??"").localeCompare(a.instance??""))},P={error:"destructive",running:"success",sleeping:"info",stopped:"outline",unknown:"secondary"},W=e=>{const{entries:t}=e??{};return Array.isArray(t)?t:[]},Y=()=>{const e=C(23),t=O();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:s,error:i,liveError:m}=M(T.getLogs,r,a),v=s!==void 0;let o;e[2]!==s?(o=K(W(s)),e[2]=s,e[3]=o):o=e[3];const N=o;let d;e[4]!==i?(d=i!==null&&n("p",{className:"text-sm text-destructive","data-testid":"containers-error",role:"alert",children:i}),e[4]=i,e[5]=d):d=e[5];let p;e[6]!==t?(p=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[6]=t,e[7]=p):p=e[7];let u;e[8]!==p?(u=n("p",{className:"text-sm text-muted-foreground",children:p}),e[8]=p,e[9]=u):u=e[9];let f;e[10]!==m?(f=n(S,{message:m,prefix:"containers"}),e[10]=m,e[11]=f):f=e[11];let h;e[12]!==u||e[13]!==f?(h=g("div",{className:"flex flex-wrap items-center gap-2",children:[u,f]}),e[12]=u,e[13]=f,e[14]=h):h=e[14];let x;e[15]!==v||e[16]!==N||e[17]!==t?(x=v&&N.length===0?n(L,{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(E,{className:"overflow-hidden py-0",children:n(I,{className:"px-0",children:g(k,{"data-testid":"containers-table",children:[n(A,{children:g(w,{children:[n(c,{children:t("Container")}),n(c,{children:t("Instance")}),n(c,{children:t("State")}),n(c,{children:t("Last event")}),n(c,{children:t("Detail")}),n(c,{children:t("Exit")}),n(c,{children:t("When")})]})}),n(D,{children:N.map(B)})]})})}),e[15]=v,e[16]=N,e[17]=t,e[18]=x):x=e[18];let y;return e[19]!==d||e[20]!==h||e[21]!==x?(y=g("div",{className:"flex flex-col gap-6","data-testid":"lunora-containers-panel",children:[d,h,x]}),e[19]=d,e[20]=h,e[21]=x,e[22]=y):y=e[22],y};function B(e){return g(w,{"data-testid":`containers-row-${e.name}${e.instance===void 0?"":`-${e.instance}`}`,children:[n(l,{className:"font-mono text-xs",children:e.name}),n(l,{className:"max-w-40 truncate font-mono text-xs text-muted-foreground",title:e.instance,children:e.instance??"—"}),n(l,{children:n(b,{variant:P[e.state],children:e.state})}),n(l,{className:"font-mono text-xs text-muted-foreground",children:e.event}),n(l,{className:"max-w-64 truncate text-xs text-muted-foreground",title:e.detail,children:e.detail??"—"}),n(l,{className:"font-mono text-xs tabular-nums text-muted-foreground",children:e.exitCode??"—"}),n(l,{className:"text-xs tabular-nums text-muted-foreground",children:new Date(e.timestamp).toLocaleString()})]},`${e.name}/${e.instance??""}`)}export{Y as ContainersPanel};
@@ -0,0 +1 @@
1
+ import{c as O}from"react/compiler-runtime";import{useState as j,useCallback as V,useEffect as B}from"react";import{j as D}from"../packem_shared/result-chart-CwKhhKM0.js";import{A as U}from"../packem_shared/alert-CVcOFuDR.js";import{u as z}from"../packem_shared/button-BkCrNcAs.js";import{c as F,u as Q,f as Z,n as H}from"../packem_shared/card-CIDGUN6K.js";import{E as J}from"../packem_shared/empty-state-Cg7t_8qu.js";import{useT as T}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{u as P,n as X}from"../packem_shared/browser-storage-xjTyMKY0.js";import{useLunora as G}from"@lunora/react";import{ADMIN_FUNCTIONS as Y}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{c as ee,e as te,f as le,a as de}from"../packem_shared/internal-AtZ4bTal.js";import{jsx as c,jsxs as _}from"react/jsx-runtime";const re=de(Y.runSql),ie=(M,e)=>{const l=G(),[m,t]=j(void 0),[d,i]=j(void 0),[r,n]=j(!0),C=V(async s=>{n(!0);try{const w=await l.query(re,{sql:M},ee(e));s.cancelled||(t(w),i(void 0))}catch(w){s.cancelled||(t(void 0),i(te(w)))}finally{s.cancelled||n(!1)}},[l,M,e]);return B(()=>{const s={cancelled:!1};return le(C(s)),()=>{s.cancelled=!0}},[C]),{error:d,loading:r,result:m}},se="lunora-studio-dashboards",I={shardKey:"",sql:"",title:""},ae=M=>{const e=O(54),{onEdit:l,onRemove:m,widget:t}=M,d=T(),{error:i,loading:r,result:n}=ie(t.sql,t.shardKey??"");let C;e[0]!==l||e[1]!==t.id?(C=()=>{l(t.id)},e[0]=l,e[1]=t.id,e[2]=C):C=e[2];const s=C;let w;e[3]!==m||e[4]!==t.id?(w=()=>{m(t.id)},e[3]=m,e[4]=t.id,e[5]=w):w=e[5];const $=w,R=`dashboards-widget-${t.id}`;let q;e[6]!==t.title?(q=c(Z,{className:"min-w-0 truncate",title:t.title,children:t.title}),e[6]=t.title,e[7]=q):q=e[7];let K;e[8]!==d?(K=d("Edit widget"),e[8]=d,e[9]=K):K=e[9];const L=`dashboards-widget-edit-${t.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=c("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:c("path",{d:"M4 20h4L18 10l-4-4L4 16v4ZM14 6l4 4"})}),e[12]=k):k=e[12];let x;e[13]!==s||e[14]!==K||e[15]!==L||e[16]!==E?(x=c(z,{"aria-label":K,"data-testid":L,onClick:s,size:"icon-xs",title:E,type:"button",variant:"ghost",children:k}),e[13]=s,e[14]=K,e[15]=L,e[16]=E,e[17]=x):x=e[17];let p;e[18]!==d?(p=d("Remove widget"),e[18]=d,e[19]=p):p=e[19];const S=`dashboards-widget-remove-${t.id}`;let h;e[20]!==d?(h=d("Remove widget"),e[20]=d,e[21]=h):h=e[21];let v;e[22]===Symbol.for("react.memo_cache_sentinel")?(v=c("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:c("path",{d:"M5 7h14M9 7V5h6v2m-1 0v12H10V7M7 7v13h10V7"})}),e[22]=v):v=e[22];let u;e[23]!==$||e[24]!==p||e[25]!==S||e[26]!==h?(u=c(z,{"aria-label":p,"data-testid":S,onClick:$,size:"icon-xs",title:h,type:"button",variant:"ghost",children:v}),e[23]=$,e[24]=p,e[25]=S,e[26]=h,e[27]=u):u=e[27];let f;e[28]!==u||e[29]!==x?(f=_("div",{className:"flex shrink-0 items-center gap-1",children:[x,u]}),e[28]=u,e[29]=x,e[30]=f):f=e[30];let g;e[31]!==f||e[32]!==q?(g=_(H,{className:"flex flex-row items-start justify-between gap-2 border-b pb-3",children:[q,f]}),e[31]=f,e[32]=q,e[33]=g):g=e[33];let b;e[34]!==i||e[35]!==t.id?(b=i!==void 0&&c(U,{className:"font-mono text-xs",testId:`dashboards-widget-error-${t.id}`,variant:"destructive",children:i}),e[34]=i,e[35]=t.id,e[36]=b):b=e[36];let N;e[37]!==i||e[38]!==r||e[39]!==n||e[40]!==d||e[41]!==t.id?(N=i===void 0&&r&&n===void 0&&c("p",{className:"p-4 text-sm text-muted-foreground","data-testid":`dashboards-widget-loading-${t.id}`,children:d("Running…")}),e[37]=i,e[38]=r,e[39]=n,e[40]=d,e[41]=t.id,e[42]=N):N=e[42];let a;e[43]!==i||e[44]!==n?(a=i===void 0&&n!==void 0&&c(D,{result:n}),e[43]=i,e[44]=n,e[45]=a):a=e[45];let o;e[46]!==b||e[47]!==N||e[48]!==a?(o=_(Q,{className:"min-h-32 py-2",children:[b,N,a]}),e[46]=b,e[47]=N,e[48]=a,e[49]=o):o=e[49];let y;return e[50]!==g||e[51]!==o||e[52]!==R?(y=_(F,{"data-testid":R,children:[g,o]}),e[50]=g,e[51]=o,e[52]=R,e[53]=y):y=e[53],y},oe=M=>{const e=O(58),{draft:l,editing:m,onCancel:t,onChange:d,onSubmit:i}=M,r=T();let n;e[0]!==l||e[1]!==d?(n=A=>{d({...l,title:A.target.value})},e[0]=l,e[1]=d,e[2]=n):n=e[2];const C=n;let s;e[3]!==l||e[4]!==d?(s=A=>{d({...l,sql:A.target.value})},e[3]=l,e[4]=d,e[5]=s):s=e[5];const w=s;let $;e[6]!==l||e[7]!==d?($=A=>{d({...l,shardKey:A.target.value})},e[6]=l,e[7]=d,e[8]=$):$=e[8];const R=$;let q;e[9]!==i?(q=()=>{i()},e[9]=i,e[10]=q):q=e[10];const K=q;let L;e[11]!==l.sql||e[12]!==l.title?(L=l.title.trim()!==""&&l.sql.trim()!=="",e[11]=l.sql,e[12]=l.title,e[13]=L):L=e[13];const E=L;let k;e[14]!==r?(k=r("Widget title"),e[14]=r,e[15]=k):k=e[15];let x;e[16]!==r?(x=r("Widget title"),e[16]=r,e[17]=x):x=e[17];let p;e[18]!==l.title||e[19]!==C||e[20]!==k||e[21]!==x?(p=c("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:C,placeholder:x,type:"text",value:l.title}),e[18]=l.title,e[19]=C,e[20]=k,e[21]=x,e[22]=p):p=e[22];let S;e[23]!==r?(S=r("SQL query"),e[23]=r,e[24]=S):S=e[24];let h;e[25]!==l.sql||e[26]!==w||e[27]!==S?(h=c("textarea",{"aria-label":S,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:w,placeholder:"SELECT author, COUNT(*) AS messages FROM …",spellCheck:!1,value:l.sql}),e[25]=l.sql,e[26]=w,e[27]=S,e[28]=h):h=e[28];let v;e[29]!==r?(v=r("Shard key (optional)"),e[29]=r,e[30]=v):v=e[30];let u;e[31]!==r?(u=r("Shard key (optional)"),e[31]=r,e[32]=u):u=e[32];let f;e[33]!==l.shardKey||e[34]!==R||e[35]!==v||e[36]!==u?(f=c("input",{"aria-label":v,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:R,placeholder:u,type:"text",value:l.shardKey}),e[33]=l.shardKey,e[34]=R,e[35]=v,e[36]=u,e[37]=f):f=e[37];let g;e[38]!==r?(g=r("Cancel"),e[38]=r,e[39]=g):g=e[39];let b;e[40]!==t||e[41]!==g?(b=c(z,{"data-testid":"dashboards-form-cancel",onClick:t,size:"sm",type:"button",variant:"outline",children:g}),e[40]=t,e[41]=g,e[42]=b):b=e[42];const N=!E;let a;e[43]!==m||e[44]!==r?(a=r(m?"Save widget":"Add widget"),e[43]=m,e[44]=r,e[45]=a):a=e[45];let o;e[46]!==K||e[47]!==N||e[48]!==a?(o=c(z,{"data-testid":"dashboards-form-save",disabled:N,onClick:K,size:"sm",type:"button",children:a}),e[46]=K,e[47]=N,e[48]=a,e[49]=o):o=e[49];let y;e[50]!==b||e[51]!==o?(y=_("div",{className:"flex items-center justify-end gap-2",children:[b,o]}),e[50]=b,e[51]=o,e[52]=y):y=e[52];let W;return e[53]!==h||e[54]!==f||e[55]!==y||e[56]!==p?(W=c(F,{"data-testid":"dashboards-form",children:_(Q,{className:"flex flex-col gap-3 py-4",children:[p,h,f,y]})}),e[53]=h,e[54]=f,e[55]=y,e[56]=p,e[57]=W):W=e[57],W},qe=M=>{const e=O(39),{initialShardKey:l}=M,m=T(),[t,d]=P(se),[i,r]=j(I),[n,C]=j(null),[s,w]=j(!1);let $;e[0]!==l?($=()=>{C(null),r({...I,shardKey:l??""}),w(!0)},e[0]=l,e[1]=$):$=e[1];const R=$;let q;e[2]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{w(!1),C(null),r(I)},e[2]=q):q=e[2];const K=q;let L;e[3]!==t?(L=a=>{const o=t.find(y=>y.id===a);o!==void 0&&(C(a),r({shardKey:o.shardKey??"",sql:o.sql,title:o.title}),w(!0))},e[3]=t,e[4]=L):L=e[4];const E=L;let k;e[5]!==d?(k=a=>{d(o=>o.filter(y=>y.id!==a))},e[5]=d,e[6]=k):k=e[6];const x=k;let p;e[7]!==i.shardKey||e[8]!==i.sql||e[9]!==i.title||e[10]!==n||e[11]!==d?(p=()=>{const a=i.title.trim(),o=i.sql.trim();if(a===""||o==="")return;const y=i.shardKey.trim();d(n===null?W=>[...W,{id:X("w"),shardKey:y,sql:o,title:a}]:W=>W.map(A=>A.id===n?{...A,shardKey:y,sql:o,title:a}:A)),K()},e[7]=i.shardKey,e[8]=i.sql,e[9]=i.title,e[10]=n,e[11]=d,e[12]=p):p=e[12];const S=p;let h;e[13]!==m?(h=m("Chart widgets backed by saved read-only SQL queries."),e[13]=m,e[14]=h):h=e[14];let v;e[15]!==h?(v=c("p",{className:"text-sm text-muted-foreground",children:h}),e[15]=h,e[16]=v):v=e[16];let u;e[17]!==s||e[18]!==R||e[19]!==m?(u=!s&&c(z,{"data-testid":"dashboards-add",onClick:R,size:"sm",type:"button",children:m("Add widget")}),e[17]=s,e[18]=R,e[19]=m,e[20]=u):u=e[20];let f;e[21]!==v||e[22]!==u?(f=_("div",{className:"flex items-center justify-between",children:[v,u]}),e[21]=v,e[22]=u,e[23]=f):f=e[23];let g;e[24]!==i||e[25]!==n||e[26]!==s||e[27]!==S?(g=s&&c(oe,{draft:i,editing:n!==null,onCancel:K,onChange:r,onSubmit:S}),e[24]=i,e[25]=n,e[26]=s,e[27]=S,e[28]=g):g=e[28];let b;e[29]!==s||e[30]!==E||e[31]!==x||e[32]!==m||e[33]!==t?(b=t.length===0&&!s?c(J,{description:m("Add a widget to chart a saved SQL query on this browser."),testId:"dashboards-empty",title:m("No widgets yet")}):c("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-3","data-testid":"dashboards-grid",children:t.map(a=>c(ae,{onEdit:E,onRemove:x,widget:a},a.id))}),e[29]=s,e[30]=E,e[31]=x,e[32]=m,e[33]=t,e[34]=b):b=e[34];let N;return e[35]!==g||e[36]!==b||e[37]!==f?(N=_("div",{className:"flex flex-col gap-4","data-testid":"lunora-dashboards",children:[f,g,b]}),e[35]=g,e[36]=b,e[37]=f,e[38]=N):N=e[38],N};export{qe as default};
@@ -0,0 +1 @@
1
+ import{c as P}from"react/compiler-runtime";import{useState as j}from"react";import{E as A}from"../packem_shared/error-alert-B59DnrDI.js";import{ShardInput as L}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as M}from"../packem_shared/badge-BbuuAio7.js";import{c as K}from"../packem_shared/card-CIDGUN6K.js";import{E as W}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as B,d as H,m as _,p as T,f as O,u as D}from"../packem_shared/table-DdJBrClo.js";import{K as U}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-BCC8_4BQ.js";import X from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{jsx as s,jsxs as x,Fragment as z}from"react/jsx-runtime";const E=i=>`${i.toString()} ms`,G=i=>i.totalConnections===0&&i.shapePoke.passes===0&&i.whisper.passes===0,R=i=>{const e=P(8),{label:r,testId:t,value:l}=i;let o;e[0]!==r?(o=s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:r}),e[0]=r,e[1]=o):o=e[1];let n;e[2]!==t||e[3]!==l?(n=s("span",{className:"truncate text-2xl font-semibold tabular-nums text-foreground","data-testid":t,children:l}),e[2]=t,e[3]=l,e[4]=n):n=e[4];let h;return e[5]!==o||e[6]!==n?(h=s(K,{className:"gap-0 py-0",children:x("div",{className:"flex flex-col gap-2.5 p-4",children:[o,n]})}),e[5]=o,e[6]=n,e[7]=h):h=e[7],h},F=i=>{const e=P(48),{counters:r,includeTiming:t,prefix:l,t:o,title:n}=i,h=`${l}-section`;let g;e[0]!==n?(g=s("h3",{className:"text-sm font-medium text-foreground",children:n}),e[0]=n,e[1]=g):g=e[1];const N=`${l}-stats`;let a;e[2]!==o?(a=o("Passes"),e[2]=o,e[3]=a):a=e[3];const c=`${l}-passes`;let v;e[4]!==r.passes||e[5]!==a||e[6]!==c?(v=s(R,{label:a,testId:c,value:r.passes}),e[4]=r.passes,e[5]=a,e[6]=c,e[7]=v):v=e[7];let $;e[8]!==o?($=o("Sockets iterated"),e[8]=o,e[9]=$):$=e[9];const I=`${l}-iterated`;let d;e[10]!==r.socketsIterated||e[11]!==$||e[12]!==I?(d=s(R,{label:$,testId:I,value:r.socketsIterated}),e[10]=r.socketsIterated,e[11]=$,e[12]=I,e[13]=d):d=e[13];let m;e[14]!==o?(m=o("Delivered"),e[14]=o,e[15]=m):m=e[15];const y=`${l}-delivered`;let u;e[16]!==r.socketsDelivered||e[17]!==m||e[18]!==y?(u=s(R,{label:m,testId:y,value:r.socketsDelivered}),e[16]=r.socketsDelivered,e[17]=m,e[18]=y,e[19]=u):u=e[19];let p;e[20]!==o?(p=o("Peak width"),e[20]=o,e[21]=p):p=e[21];const b=`${l}-peak`;let f;e[22]!==r.peakSocketsIterated||e[23]!==p||e[24]!==b?(f=s(R,{label:p,testId:b,value:r.peakSocketsIterated}),e[22]=r.peakSocketsIterated,e[23]=p,e[24]=b,e[25]=f):f=e[25];let k;e[26]!==r.totalMs||e[27]!==t||e[28]!==l||e[29]!==o?(k=t&&s(R,{label:o("Total time"),testId:`${l}-total-ms`,value:E(r.totalMs)}),e[26]=r.totalMs,e[27]=t,e[28]=l,e[29]=o,e[30]=k):k=e[30];let S;e[31]!==r.maxMs||e[32]!==t||e[33]!==l||e[34]!==o?(S=t&&s(R,{label:o("Max time"),testId:`${l}-max-ms`,value:E(r.maxMs)}),e[31]=r.maxMs,e[32]=t,e[33]=l,e[34]=o,e[35]=S):S=e[35];let C;e[36]!==u||e[37]!==f||e[38]!==k||e[39]!==S||e[40]!==N||e[41]!==v||e[42]!==d?(C=x("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":N,children:[v,d,u,f,k,S]}),e[36]=u,e[37]=f,e[38]=k,e[39]=S,e[40]=N,e[41]=v,e[42]=d,e[43]=C):C=e[43];let w;return e[44]!==h||e[45]!==C||e[46]!==g?(w=x("section",{className:"flex flex-col gap-2","data-testid":h,children:[g,C]}),e[44]=h,e[45]=C,e[46]=g,e[47]=w):w=e[47],w},ue=i=>{const e=P(32),{initialShardKey:r}=i,t=Y(),[l,o]=j(r??"");let n;e[0]!==l?(n=l.trim(),e[0]=l,e[1]=n):n=e[1];const h=X(n,400);let g;e[2]===Symbol.for("react.memo_cache_sentinel")?(g={},e[2]=g):g=e[2];let N;e[3]!==h?(N={keepPreviousData:!0,shardKey:h},e[3]=h,e[4]=N):N=e[4];const{data:a,error:c,errorSource:v,refetch:$}=U(q.getFanoutMetrics,g,N);V($,!0);let I;e[5]!==a?(I=a!==void 0&&G(a),e[5]=a,e[6]=I):I=e[6];const d=I;let m;e[7]!==l?(m=s(L,{onChange:o,testId:"fanout-shard-input",value:l}),e[7]=l,e[8]=m):m=e[8];let y;e[9]!==a||e[10]!==t?(y=a!==void 0&&x("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"fanout-count",children:[a.promoted&&s(M,{"data-testid":"fanout-promoted",variant:a.relayCount>=a.maxRelays?"destructive":"default",children:a.relayCount>=a.maxRelays?t("auto-scaled: {relayCount}/{maxRelays} relays (at ceiling)",{maxRelays:a.maxRelays,relayCount:a.relayCount}):t("auto-scaled: {relayCount}/{maxRelays} relays",{maxRelays:a.maxRelays,relayCount:a.relayCount})}),s(M,{variant:"secondary",children:t("{count} connections",{count:a.totalConnections})}),s(M,{variant:"secondary",children:t("peak {count} subscribers",{count:a.peakSubscribers})})]}),e[9]=a,e[10]=t,e[11]=y):y=e[11];let u;e[12]!==m||e[13]!==y?(u=x("div",{className:"flex flex-wrap items-center gap-2",children:[m,y]}),e[12]=m,e[13]=y,e[14]=u):u=e[14];let p;e[15]!==c||e[16]!==v?(p=c!==null&&s(A,{error:v,testId:"fanout-error"}),e[15]=c,e[16]=v,e[17]=p):p=e[17];let b;e[18]!==c||e[19]!==d||e[20]!==t?(b=c===null&&d&&s(W,{description:t("Realtime fan-out cost and per-topic subscriber counts for this shard."),icon:s("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:s("path",{d:"M4 12h4l3 7 4-14 3 7h2"})}),testId:"fanout-empty",title:t("No fan-out activity yet.")}),e[18]=c,e[19]=d,e[20]=t,e[21]=b):b=e[21];let f;e[22]!==c||e[23]!==d||e[24]!==a||e[25]!==t?(f=c===null&&a!==void 0&&!d&&x(z,{children:[a.topics.length>0&&x("section",{className:"flex flex-col gap-2","data-testid":"fanout-topics-section",children:[s("h3",{className:"text-sm font-medium text-foreground",children:t("Hot topics")}),s(K,{className:"overflow-hidden py-0",children:x(B,{"data-testid":"fanout-topics-table",children:[s(H,{children:x(_,{children:[s(T,{children:t("Topic")}),s(T,{children:t("Kind")}),s(T,{className:"text-right",children:t("Subscribers")})]})}),s(O,{children:a.topics.map(J)})]})})]}),x("section",{className:"flex flex-col gap-3","data-testid":"fanout-cost",children:[s("h2",{className:"text-sm font-medium text-muted-foreground",children:t("Fan-out cost since this instance woke")}),s(F,{counters:a.shapePoke,includeTiming:!0,prefix:"fanout-poke",t,title:t("Shape pokes")}),s(F,{counters:a.whisper,includeTiming:!1,prefix:"fanout-whisper",t,title:t("Whisper broadcasts")})]})]}),e[22]=c,e[23]=d,e[24]=a,e[25]=t,e[26]=f):f=e[26];let k;return e[27]!==f||e[28]!==u||e[29]!==p||e[30]!==b?(k=x("div",{className:"flex flex-col gap-4","data-testid":"fanout-panel",children:[u,p,b,f]}),e[27]=f,e[28]=u,e[29]=p,e[30]=b,e[31]=k):k=e[31],k};function J(i){return x(_,{"data-testid":"fanout-topic-row",children:[s(D,{className:"font-mono text-xs",children:i.topic}),s(D,{children:s(M,{variant:"outline",children:i.kind})}),s(D,{className:"text-right font-medium tabular-nums",children:i.subscribers})]},`${i.kind}:${i.topic}`)}export{ue as default};
@@ -0,0 +1 @@
1
+ import{useState as k,useMemo as u}from"react";import{E as w}from"../packem_shared/error-alert-B59DnrDI.js";import{g as A}from"../packem_shared/badge-BbuuAio7.js";import{c as T,u as F}from"../packem_shared/card-CIDGUN6K.js";import{E as p}from"../packem_shared/empty-state-Cg7t_8qu.js";import{p as O}from"../packem_shared/label-6uP1obNF.js";import{n as C,d as j,m as h,p as n,f as E,u as i}from"../packem_shared/table-DdJBrClo.js";import{l as I}from"../packem_shared/textarea-Bu2-jKAs.js";import{K as J}from"../packem_shared/use-admin-query-Di3fLE8H.js";import{useT as K}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as V}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{jsx as e,jsxs as s}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."}}},M='{ "targetingKey": "user-123", "plan": "premium" }',_=a=>a.type==="object"?JSON.stringify(a.value):String(a.value),Y=({initialShardKey:a=""})=>{const t=K(),[o,x]=k(""),{context:c,error:f}=L(o),v=u(()=>c===void 0?{}:{context:c},[c]),{data:l,error:y,errorSource:N,liveError:b}=J(V.listFlags,v,{live:!0,shardKey:a}),g=l!==void 0,S=l?.configured??!1,m=u(()=>Array.isArray(l?.flags)?[...l.flags].toSorted((r,$)=>r.key.localeCompare($.key)):[],[l]);let d;return g&&!S?d=e(p,{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(p,{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(T,{className:"overflow-hidden py-0",children:e(F,{className:"px-0",children:s(C,{"data-testid":"flags-table",children:[e(j,{children:s(h,{children:[e(n,{children:t("Key")}),e(n,{children:t("Type")}),e(n,{children:t("Value")}),e(n,{children:t("Reason")}),e(n,{children:t("Variant")})]})}),e(E,{children:m.map(r=>s(h,{"data-testid":`flags-row-${r.key}`,children:[e(i,{className:"font-mono text-xs",children:r.key}),e(i,{className:"font-mono text-xs text-muted-foreground",children:r.type}),e(i,{className:"font-mono text-xs",children:_(r)}),e(i,{children:r.errorCode===void 0?e("span",{className:"font-mono text-xs text-muted-foreground",children:r.reason??"—"}):e(A,{"data-testid":`flags-error-${r.key}`,variant:"destructive",children:r.errorCode})}),e(i,{className:"font-mono text-xs text-muted-foreground",children:r.variant??"—"})]},r.key))})]})})}),s("div",{className:"flex flex-col gap-6","data-testid":"lunora-flags-panel",children:[y!==null&&e(w,{error:N,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.')}),s("div",{className:"flex flex-col gap-2",children:[e(O,{htmlFor:"flags-targeting-context",children:t("Targeting context (JSON)")}),e(I,{className:"font-mono text-xs","data-testid":"flags-context-input",id:"flags-targeting-context",onChange:r=>{x(r.target.value)},placeholder:M,rows:3,value:o}),f!==null&&e("p",{className:"text-xs text-destructive","data-testid":"flags-context-error",role:"alert",children:t(f)}),b!==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{Y as FlagsPanel};
@@ -0,0 +1 @@
1
+ import{c as ae}from"react/compiler-runtime";import{useLunora as te}from"@lunora/react";import{useState as F}from"react";import{L as ie}from"../packem_shared/live-status-CGW2JHf_.js";import{ShardInput as le}from"../packem_shared/ShardInput-BVn2iCU0.js";import{g as q}from"../packem_shared/badge-BbuuAio7.js";import{u as L}from"../packem_shared/button-BkCrNcAs.js";import{c as ne,u as oe}from"../packem_shared/card-CIDGUN6K.js";import{E as de}from"../packem_shared/empty-state-Cg7t_8qu.js";import{u as ce}from"../packem_shared/input-JHu63lTv.js";import{w as he,y as ue,N as me,_ as pe,k as Z}from"../packem_shared/select-Bul-DeII.js";import{n as fe,d as ge,m as X,p,f as ve,u as f}from"../packem_shared/table-DdJBrClo.js";import{K as xe}from"../packem_shared/use-admin-query-Di3fLE8H.js";import ye from"../packem_shared/useDebounced-Ihdiid_k.js";import{useT as Ne}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{ADMIN_FUNCTIONS as S}from"../packem_shared/ADMIN_FUNCTIONS-BYNSbBVE.js";import{i as $e,f as I,a as U,c as we,e as Ie}from"../packem_shared/internal-AtZ4bTal.js";import{jsx as r,jsxs as c}from"react/jsx-runtime";const P="none",Se=["all","open","resolved","ignored"],be=["critical","high","medium","low"],Ae=U(S.resolveIssue),Ce=U(S.ignoreIssue),Y=U(S.assignIssue),ke=U(S.setIssueSeverity),Ee=t=>Array.isArray(t?.issues)?t.issues:[],Ke=t=>t==="resolved"?"success":t==="ignored"?"secondary":"warning",Me=t=>t==="critical"?"destructive":t==="high"?"warning":t==="medium"?"info":"secondary",Qe=t=>{const e=ae(42),{initialShardKey:H}=t,a=Ne(),$=te(),[h,J]=F(H??""),[l,Q]=F("all"),[V,W]=F(Re),[j,B]=F(Te);let b;e[0]!==h?(b=h.trim(),e[0]=h,e[1]=b):b=e[1];const u=ye(b,400);let A;e[2]!==l?(A=l==="all"?{}:{status:l},e[2]=l,e[3]=A):A=e[3];let C;e[4]!==u?(C={live:!0,shardKey:u},e[4]=u,e[5]=C):C=e[5];const{data:k,error:g,liveError:w}=xe(S.getIssues,A,C),D=k!==void 0;let E;if(e[6]!==j||e[7]!==V||e[8]!==$||e[9]!==k||e[10]!==u||e[11]!==g||e[12]!==w||e[13]!==D||e[14]!==h||e[15]!==l||e[16]!==a){const G=Ee(k);let K;e[18]!==$||e[19]!==u?(K=async(s,i,o)=>{B(d=>{if(!d.has(s))return d;const m=new Map(d);return m.delete(s),m}),W(d=>new Set(d).add(s));try{await $.query(i,{...o,hash:s},we(u))}catch(d){const m=Ie(d);B(re=>new Map(re).set(s,m))}W(d=>{const m=new Set(d);return m.delete(s),m})},e[18]=$,e[19]=u,e[20]=K):K=e[20];const n=K;let M;e[21]!==n?(M=s=>i=>{if(i.key!=="Enter")return;const o=i.currentTarget.value.trim();I(n(s.hash,Y,{assignee:o===""?null:o}))},e[21]=n,e[22]=M):M=e[22];const ee=M;let R;e[23]!==n?(R=s=>i=>{const o=i===null||i===P?null:i;I(n(s.hash,ke,{severity:o}))},e[23]=n,e[24]=R):R=e[24];const se=R;let T;e[25]!==a?(T=s=>a(s==="all"?"All":s==="open"?"Open":s==="resolved"?"Resolved":"Ignored"),e[25]=a,e[26]=T):T=e[26];const _=T;let z;e[27]!==g?(z=g!==null&&r("p",{className:"text-sm text-destructive","data-testid":"issues-error",role:"alert",children:g}),e[27]=g,e[28]=z):z=e[28];let v;e[29]!==h?(v=r(le,{onChange:J,testId:"issues-shard-input",value:h}),e[29]=h,e[30]=v):v=e[30];let x;e[31]!==w?(x=r(ie,{message:w,prefix:"issues"}),e[31]=w,e[32]=x):x=e[32];let y;e[33]!==l||e[34]!==_?(y=Se.map(s=>r(L,{"data-active":l===s?"":void 0,"data-testid":`issues-filter-${s}`,onClick:()=>{Q(s)},size:"xs",variant:l===s?"default":"outline",children:_(s)},s)),e[33]=l,e[34]=_,e[35]=y):y=e[35];let N;e[36]!==y?(N=r("div",{className:"ms-auto flex items-center gap-1","data-testid":"issues-status-filter",role:"group",children:y}),e[36]=y,e[37]=N):N=e[37];let O;e[38]!==v||e[39]!==x||e[40]!==N?(O=c("div",{className:"flex flex-wrap items-center gap-2",children:[v,x,N]}),e[38]=v,e[39]=x,e[40]=N,e[41]=O):O=e[41],E=c("div",{className:"flex flex-col gap-6","data-testid":"lunora-issues-panel",children:[z,O,D&&G.length===0?r(de,{description:a("No grouped errors yet. When a function throws or a container crashes, matching errors fold into a single issue here."),testId:"issues-empty",title:a("No issues")}):r(ne,{className:"overflow-hidden py-0",children:r(oe,{className:"px-0",children:c(fe,{"data-testid":"issues-table",children:[r(ge,{children:c(X,{children:[r(p,{children:a("Issue")}),r(p,{children:a("Status")}),r(p,{children:a("Severity")}),r(p,{children:a("Assignee")}),r(p,{className:"text-right",children:a("Events")}),r(p,{children:a("Last seen")}),r(p,{className:"text-right",children:a("Actions")})]})}),r(ve,{children:G.map(s=>{const i=V.has(s.hash),o=j.get(s.hash);return c(X,{"data-testid":`issues-row-${s.hash}`,children:[c(f,{className:"max-w-80",children:[r("div",{className:"truncate font-medium",title:s.title,children:s.title}),r("div",{className:"truncate font-mono text-xs text-muted-foreground",title:s.culprit,children:s.culprit}),o!==void 0&&r("p",{className:"text-xs text-destructive","data-testid":`issues-action-error-${s.hash}`,role:"alert",children:o})]}),r(f,{children:r(q,{"data-testid":`issues-status-${s.hash}`,variant:Ke(s.status),children:s.status})}),r(f,{children:c(he,{disabled:i,onValueChange:se(s),value:s.severity??P,children:[r(ue,{"aria-label":a("Set severity"),className:"h-7 w-[110px]","data-testid":`issues-severity-${s.hash}`,children:r(me,{placeholder:a("—"),children:s.severity===void 0?r("span",{className:"text-muted-foreground",children:a("—")}):r(q,{variant:Me(s.severity),children:s.severity})})}),c(pe,{children:[be.map(ze),r(Z,{value:P,children:a("Clear")})]})]})}),r(f,{children:r(ce,{"aria-label":a("Assignee"),className:"h-7 w-32","data-testid":`issues-assignee-${s.hash}`,defaultValue:s.assignee??"",disabled:i,onKeyDown:ee(s),placeholder:a("Unassigned")},s.assignee??"")}),r(f,{className:"text-right",children:r(q,{variant:"secondary",children:s.count})}),r(f,{className:"text-xs tabular-nums text-muted-foreground",children:$e(s.lastSeen)}),r(f,{className:"text-right",children:c("div",{className:"flex justify-end gap-1",children:[s.status!=="resolved"&&r(L,{"data-testid":`issues-resolve-${s.hash}`,disabled:i,onClick:()=>{I(n(s.hash,Ae,{}))},size:"xs",variant:"outline",children:a("Resolve")}),s.status!=="ignored"&&r(L,{"data-testid":`issues-ignore-${s.hash}`,disabled:i,onClick:()=>{I(n(s.hash,Ce,{}))},size:"xs",variant:"ghost",children:a("Ignore")}),s.status!=="open"&&r(L,{"data-testid":`issues-reopen-${s.hash}`,disabled:i,onClick:()=>{I(n(s.hash,Y,{assignee:s.assignee??null}))},size:"xs",variant:"ghost",children:a("Reopen")})]})})]},s.hash)})})]})})})]}),e[6]=j,e[7]=V,e[8]=$,e[9]=k,e[10]=u,e[11]=g,e[12]=w,e[13]=D,e[14]=h,e[15]=l,e[16]=a,e[17]=E}else E=e[17];return E};function Re(){return new Set}function Te(){return new Map}function ze(t){return r(Z,{value:t,children:t},t)}export{Qe as IssuesPanel};
@@ -0,0 +1 @@
1
+ import{useLunora as ee}from"@lunora/react";import{useState as Z,useReducer as ae,useEffect as le}from"react";import{c as ve,u as pe}from"../packem_shared/card-CIDGUN6K.js";import{E as Fe}from"../packem_shared/empty-state-Cg7t_8qu.js";import{n as ye,d as he,m as X,p as Y,f as ke,u as Q}from"../packem_shared/table-DdJBrClo.js";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{f as z,e as H,k as Ke,g as ne}from"../packem_shared/internal-AtZ4bTal.js";import{u as B}from"../packem_shared/button-BkCrNcAs.js";import{f as de}from"../packem_shared/checkbox-StT4Gob6.js";import{u as re}from"../packem_shared/input-JHu63lTv.js";import{g as se,c as ie,N as oe,v as ce}from"../packem_shared/studio-BHA7hnI3.js";import{c as te}from"react/compiler-runtime";import{p as q}from"../packem_shared/label-6uP1obNF.js";import{l as fe}from"../packem_shared/textarea-Bu2-jKAs.js";import{N as Ee,y as Ve,k as Me,_ as Te,w as Ie}from"../packem_shared/select-Bul-DeII.js";import{jsx as r,jsxs as $,Fragment as be}from"react/jsx-runtime";import{g as Oe}from"../packem_shared/badge-BbuuAio7.js";const _e=l=>{const e=l.trim();if(e==="")return;const n=Number(e);return Number.isFinite(n)&&n>0?Math.floor(n):void 0},Je=l=>l===void 0?"—":new Date(l*1e3).toISOString(),De=l=>new TextEncoder().encode(l).length,ge=l=>{if(l.trim()!=="")try{return JSON.stringify(JSON.parse(l),void 0,2)}catch{return}},xe=l=>{if(l.trim()==="")return!0;try{return JSON.parse(l),!0}catch{return!1}},Ne=[{key:"seconds",seconds:1},{key:"minutes",seconds:60},{key:"hours",seconds:3600},{key:"days",seconds:86400}],ue=(l,e)=>{const n=l.trim();if(n==="")return"";const c=Number(n),s=Ne.find(v=>v.key===e)?.seconds??1;return Number.isFinite(c)&&c>0?String(Math.round(c*s)):n},Ce=l=>{const e=l.trim();if(e==="")return!0;const n=Number(e);return Number.isInteger(n)&&n>=60},we=(l,e,n,c)=>{const s=_e(l.ttl);return{expiration:s===void 0?c:void 0,expirationTtl:s,key:e,metadata:l.metadata.trim()===""?void 0:JSON.parse(l.metadata),namespace:n,value:l.value}},$e=l=>{const e=te(60),{helper:n,id:c,invalid:s,onChange:v,testId:i}=l,t=G(),[a,p]=Z(""),[o,g]=Z("seconds");let f;e[0]!==v||e[1]!==o?(f=b=>{p(b.target.value),v(ue(b.target.value,o))},e[0]=v,e[1]=o,e[2]=f):f=e[2];const I=f;let V;e[3]!==a||e[4]!==v?(V=b=>{b!==null&&(g(b),v(ue(a,b)))},e[3]=a,e[4]=v,e[5]=V):V=e[5];const O=V;let y;e[6]!==t?(y=t("days"),e[6]=t,e[7]=y):y=e[7];let m;e[8]!==t?(m=t("hours"),e[8]=t,e[9]=m):m=e[9];let h;e[10]!==t?(h=t("minutes"),e[10]=t,e[11]=h):h=e[11];let x;e[12]!==t?(x=t("seconds"),e[12]=t,e[13]=x):x=e[13];let N;e[14]!==y||e[15]!==m||e[16]!==h||e[17]!==x?(N={days:y,hours:m,minutes:h,seconds:x},e[14]=y,e[15]=m,e[16]=h,e[17]=x,e[18]=N):N=e[18];const C=N;let k;e[19]!==t?(k=t("Expires after"),e[19]=t,e[20]=k):k=e[20];let w;e[21]!==c||e[22]!==k?(w=r(q,{className:"text-xs",htmlFor:c,children:k}),e[21]=c,e[22]=k,e[23]=w):w=e[23];let F;e[24]!==t?(F=t("No expiration"),e[24]=t,e[25]=F):F=e[25];let _;e[26]!==a||e[27]!==c||e[28]!==s||e[29]!==I||e[30]!==F||e[31]!==i?(_=r(re,{"aria-invalid":s,className:"flex-1","data-testid":i,id:c,inputMode:"numeric",onChange:I,placeholder:F,value:a}),e[26]=a,e[27]=c,e[28]=s,e[29]=I,e[30]=F,e[31]=i,e[32]=_):_=e[32];let M;e[33]!==t?(M=t("TTL unit"),e[33]=t,e[34]=M):M=e[34];const D=`${i}-unit`;let J;e[35]===Symbol.for("react.memo_cache_sentinel")?(J=r(Ee,{}),e[35]=J):J=e[35];let d;e[36]!==M||e[37]!==D?(d=r(Ve,{"aria-label":M,className:"w-[7.5rem]","data-testid":D,children:J}),e[36]=M,e[37]=D,e[38]=d):d=e[38];let u;e[39]!==C?(u=Ne.map(b=>r(Me,{value:b.key,children:C[b.key]},b.key)),e[39]=C,e[40]=u):u=e[40];let E;e[41]!==u?(E=r(Te,{children:u}),e[41]=u,e[42]=E):E=e[42];let S;e[43]!==O||e[44]!==d||e[45]!==E||e[46]!==o?(S=$(Ie,{onValueChange:O,value:o,children:[d,E]}),e[43]=O,e[44]=d,e[45]=E,e[46]=o,e[47]=S):S=e[47];let T;e[48]!==_||e[49]!==S?(T=$("div",{className:"flex gap-2",children:[_,S]}),e[48]=_,e[49]=S,e[50]=T):T=e[50];let K;e[51]!==n||e[52]!==s||e[53]!==t||e[54]!==i?(K=s?r("p",{className:"text-xs text-destructive","data-testid":`${i}-invalid`,children:t("TTL must be at least 60 seconds.")}):n!==void 0&&r("p",{className:"text-xs text-muted-foreground",children:n}),e[51]=n,e[52]=s,e[53]=t,e[54]=i,e[55]=K):K=e[55];let L;return e[56]!==T||e[57]!==K||e[58]!==w?(L=$("div",{className:"mb-3 grid gap-1",children:[w,T,K]}),e[56]=T,e[57]=K,e[58]=w,e[59]=L):L=e[59],L},Se=l=>{const e=te(36),{id:n,invalidTestId:c,onChange:s,testId:v,valid:i,value:t}=l,a=G();let p;e[0]!==t?(p=ge(t),e[0]=t,e[1]=p):p=e[1];const o=p;let g;e[2]!==a?(g=a("Metadata (JSON)"),e[2]=a,e[3]=g):g=e[3];let f;e[4]!==n||e[5]!==g?(f=r(q,{className:"text-xs",htmlFor:n,children:g}),e[4]=n,e[5]=g,e[6]=f):f=e[6];const I=`${v}-format`,V=o===void 0;let O;e[7]!==o||e[8]!==s?(O=()=>{o!==void 0&&s(o)},e[7]=o,e[8]=s,e[9]=O):O=e[9];let y;e[10]!==a?(y=a("Format JSON"),e[10]=a,e[11]=y):y=e[11];let m;e[12]!==I||e[13]!==V||e[14]!==O||e[15]!==y?(m=r(B,{"data-testid":I,disabled:V,onClick:O,size:"sm",variant:"outline",children:y}),e[12]=I,e[13]=V,e[14]=O,e[15]=y,e[16]=m):m=e[16];let h;e[17]!==f||e[18]!==m?(h=$("div",{className:"flex items-center justify-between gap-2",children:[f,m]}),e[17]=f,e[18]=m,e[19]=h):h=e[19];const x=!i;let N;e[20]!==s?(N=F=>{s(F.target.value)},e[20]=s,e[21]=N):N=e[21];let C;e[22]!==n||e[23]!==x||e[24]!==N||e[25]!==v||e[26]!==t?(C=r(fe,{"aria-invalid":x,className:"min-h-[4rem] font-mono text-xs","data-testid":v,id:n,onChange:N,value:t}),e[22]=n,e[23]=x,e[24]=N,e[25]=v,e[26]=t,e[27]=C):C=e[27];let k;e[28]!==c||e[29]!==a||e[30]!==i?(k=!i&&r("p",{className:"text-xs text-destructive","data-testid":c,children:a("Metadata must be valid JSON.")}),e[28]=c,e[29]=a,e[30]=i,e[31]=k):k=e[31];let w;return e[32]!==C||e[33]!==k||e[34]!==h?(w=$("div",{className:"mb-3 grid gap-1",children:[h,C,k]}),e[32]=C,e[33]=k,e[34]=h,e[35]=w):w=e[35],w},Le={busy:!1,error:null,metadata:"",name:"",ttl:"",value:""},Be=(l,e)=>{switch(e.type){case"setField":return{...l,[e.field]:e.value};case"submitFailed":return{...l,busy:!1,error:e.error};case"submitStart":return{...l,busy:!0,error:null};default:return l}},Pe=l=>{const e=te(73),{namespace:n,onCancel:c,onCreated:s}=l,v=ee(),i=G(),[t,a]=ae(Be,Le);let p;e[0]!==t.metadata?(p=xe(t.metadata),e[0]=t.metadata,e[1]=p):p=e[1];const o=p;let g;e[2]!==t.ttl?(g=Ce(t.ttl),e[2]=t.ttl,e[3]=g):g=e[3];const f=g;let I;e[4]!==o||e[5]!==t.busy||e[6]!==t.name||e[7]!==f?(I=t.name.trim()!==""&&o&&f&&!t.busy,e[4]=o,e[5]=t.busy,e[6]=t.name,e[7]=f,e[8]=I):I=e[8];const V=I;let O;e[9]!==V||e[10]!==v||e[11]!==n||e[12]!==s||e[13]!==t.metadata||e[14]!==t.name||e[15]!==t.ttl||e[16]!==t.value?(O=()=>{V&&(a({type:"submitStart"}),z((async()=>{try{await v.putKvValue(we({metadata:t.metadata,ttl:t.ttl,value:t.value},t.name,n)),s()}catch(j){a({error:H(j),type:"submitFailed"})}})()))},e[9]=V,e[10]=v,e[11]=n,e[12]=s,e[13]=t.metadata,e[14]=t.name,e[15]=t.ttl,e[16]=t.value,e[17]=O):O=e[17];const y=O;let m;e[18]!==i?(m=i("Key name"),e[18]=i,e[19]=m):m=e[19];let h;e[20]!==m?(h=r(q,{className:"text-xs",htmlFor:"kv-create-name",children:m}),e[20]=m,e[21]=h):h=e[21];let x;e[22]===Symbol.for("react.memo_cache_sentinel")?(x=j=>{a({field:"name",type:"setField",value:j.target.value})},e[22]=x):x=e[22];let N;e[23]!==i?(N=i("Key name"),e[23]=i,e[24]=N):N=e[24];let C;e[25]!==t.name||e[26]!==N?(C=r(re,{autoFocus:!0,"data-testid":"kv-create-name",id:"kv-create-name",onChange:x,placeholder:N,value:t.name}),e[25]=t.name,e[26]=N,e[27]=C):C=e[27];let k;e[28]!==h||e[29]!==C?(k=$("div",{className:"grid gap-1",children:[h,C]}),e[28]=h,e[29]=C,e[30]=k):k=e[30];let w;e[31]!==i?(w=i("Value"),e[31]=i,e[32]=w):w=e[32];let F;e[33]!==w?(F=r(q,{className:"text-xs",htmlFor:"kv-create-value",children:w}),e[33]=w,e[34]=F):F=e[34];let _;e[35]===Symbol.for("react.memo_cache_sentinel")?(_=j=>{a({field:"value",type:"setField",value:j.target.value})},e[35]=_):_=e[35];let M;e[36]!==t.value?(M=r(fe,{className:"min-h-[6rem] font-mono text-xs","data-testid":"kv-create-value",id:"kv-create-value",onChange:_,value:t.value}),e[36]=t.value,e[37]=M):M=e[37];let D;e[38]!==F||e[39]!==M?(D=$("div",{className:"grid gap-1",children:[F,M]}),e[38]=F,e[39]=M,e[40]=D):D=e[40];const J=!f;let d;e[41]===Symbol.for("react.memo_cache_sentinel")?(d=j=>{a({field:"ttl",type:"setField",value:j})},e[41]=d):d=e[41];let u;e[42]!==J?(u=r($e,{id:"kv-create-ttl",invalid:J,onChange:d,testId:"kv-create-ttl"}),e[42]=J,e[43]=u):u=e[43];let E;e[44]===Symbol.for("react.memo_cache_sentinel")?(E=j=>{a({field:"metadata",type:"setField",value:j})},e[44]=E):E=e[44];let S;e[45]!==o||e[46]!==t.metadata?(S=r(Se,{id:"kv-create-metadata",invalidTestId:"kv-create-metadata-invalid",onChange:E,testId:"kv-create-metadata",valid:o,value:t.metadata}),e[45]=o,e[46]=t.metadata,e[47]=S):S=e[47];const T=!V;let K;e[48]!==t.busy||e[49]!==i?(K=t.busy?i("Creating…"):i("Create key"),e[48]=t.busy,e[49]=i,e[50]=K):K=e[50];let L;e[51]!==y||e[52]!==T||e[53]!==K?(L=r(B,{"data-testid":"kv-create-submit",disabled:T,onClick:y,children:K}),e[51]=y,e[52]=T,e[53]=K,e[54]=L):L=e[54];const b=t.busy;let P;e[55]!==i?(P=i("Cancel"),e[55]=i,e[56]=P):P=e[56];let A;e[57]!==c||e[58]!==t.busy||e[59]!==P?(A=r(B,{"data-testid":"kv-create-cancel",disabled:b,onClick:c,variant:"outline",children:P}),e[57]=c,e[58]=t.busy,e[59]=P,e[60]=A):A=e[60];let R;e[61]!==L||e[62]!==A?(R=$("div",{className:"flex flex-wrap gap-2",children:[L,A]}),e[61]=L,e[62]=A,e[63]=R):R=e[63];let U;e[64]!==t.error?(U=t.error!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-create-error",role:"alert",children:t.error}),e[64]=t.error,e[65]=U):U=e[65];let W;return e[66]!==k||e[67]!==D||e[68]!==u||e[69]!==S||e[70]!==R||e[71]!==U?(W=$("div",{className:"grid gap-3 px-4 pb-4","data-testid":"kv-create-form",children:[k,D,u,S,R,U]}),e[66]=k,e[67]=D,e[68]=u,e[69]=S,e[70]=R,e[71]=U,e[72]=W):W=e[72],W},je={busy:"",editedMetadata:"",editedTtl:"",editedValue:"",loadError:null,loading:!0,value:null,writeError:null},Ae=(l,e)=>{switch(e.type){case"deleteStart":return{...l,busy:"deleting",writeError:null};case"editMetadata":return{...l,editedMetadata:e.value};case"editTtl":return{...l,editedTtl:e.value};case"editValue":return{...l,editedValue:e.value};case"loaded":return{...l,editedMetadata:e.metadata===null||e.metadata===void 0?"":JSON.stringify(e.metadata,null,2),editedValue:e.value??"",loading:!1,value:e.value};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"saveOk":return{...l,busy:"",value:l.editedValue};case"saveStart":return{...l,busy:"saving",writeError:null};case"writeFailed":return{...l,busy:"",writeError:e.error};default:return l}},ze=l=>{const e=te(67),{expiration:n,keyName:c,namespace:s,onDeleted:v}=l,i=ee(),t=G(),[a,p]=ae(Ae,je);let o,g;e[0]!==i||e[1]!==c||e[2]!==s?(o=()=>{const b={cancelled:!1};return z((async()=>{try{const P=await i.getKvValue({key:c,namespace:s});b.cancelled||p({metadata:P.metadata,type:"loaded",value:P.value})}catch(P){const A=P;b.cancelled||p({error:H(A),type:"loadFailed"})}})()),()=>{b.cancelled=!0}},g=[i,s,c],e[0]=i,e[1]=c,e[2]=s,e[3]=o,e[4]=g):(o=e[3],g=e[4]),le(o,g);let f;e[5]===Symbol.for("react.memo_cache_sentinel")?(f=b=>{p({type:"editValue",value:b.target.value})},e[5]=f):f=e[5];const I=f;let V;e[6]===Symbol.for("react.memo_cache_sentinel")?(V=b=>{p({type:"editMetadata",value:b})},e[6]=V):V=e[6];const O=V;let y;e[7]!==a.editedValue?(y=ge(a.editedValue),e[7]=a.editedValue,e[8]=y):y=e[8];const m=y;let h;e[9]!==a.editedMetadata?(h=xe(a.editedMetadata),e[9]=a.editedMetadata,e[10]=h):h=e[10];const x=h;let N;e[11]!==a.editedTtl?(N=Ce(a.editedTtl),e[11]=a.editedTtl,e[12]=N):N=e[12];const C=N;let k;e[13]!==m?(k=()=>{m!==void 0&&p({type:"editValue",value:m})},e[13]=m,e[14]=k):k=e[14];const w=k;let F;e[15]!==i||e[16]!==n||e[17]!==c||e[18]!==x||e[19]!==s||e[20]!==a.editedMetadata||e[21]!==a.editedTtl||e[22]!==a.editedValue||e[23]!==t?(F=()=>{if(!x){p({error:t("Metadata must be valid JSON."),type:"writeFailed"});return}p({type:"saveStart"}),z((async()=>{try{await i.putKvValue(we({metadata:a.editedMetadata,ttl:a.editedTtl,value:a.editedValue},c,s,n)),p({type:"saveOk"})}catch(b){p({error:H(b),type:"writeFailed"})}})())},e[15]=i,e[16]=n,e[17]=c,e[18]=x,e[19]=s,e[20]=a.editedMetadata,e[21]=a.editedTtl,e[22]=a.editedValue,e[23]=t,e[24]=F):F=e[24];const _=F;let M;e[25]!==i||e[26]!==c||e[27]!==s||e[28]!==v?(M=()=>{p({type:"deleteStart"}),z((async()=>{try{await i.deleteKvKey({key:c,namespace:s}),v(c)}catch(b){p({error:H(b),type:"writeFailed"})}})())},e[25]=i,e[26]=c,e[27]=s,e[28]=v,e[29]=M):M=e[29];const D=M;let J;e[30]!==c?(J=()=>{ne(c)},e[30]=c,e[31]=J):J=e[31];let d;e[32]!==t?(d=t("Copy key"),e[32]=t,e[33]=d):d=e[33];let u;e[34]!==J||e[35]!==d?(u=r("div",{className:"mb-2 flex justify-end",children:r(B,{"data-testid":"kv-copy-key-btn",onClick:J,size:"sm",variant:"outline",children:d})}),e[34]=J,e[35]=d,e[36]=u):u=e[36];let E;e[37]!==a.loadError?(E=a.loadError!==null&&r("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-value-error",role:"alert",children:a.loadError}),e[37]=a.loadError,e[38]=E):E=e[38];let S;e[39]!==a.loading||e[40]!==t?(S=a.loading&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-value-loading",children:t("Loading…")}),e[39]=a.loading,e[40]=t,e[41]=S):S=e[41];let T;e[42]!==m||e[43]!==x||e[44]!==D||e[45]!==w||e[46]!==_||e[47]!==a.busy||e[48]!==a.editedMetadata||e[49]!==a.editedValue||e[50]!==a.loading||e[51]!==a.value||e[52]!==a.writeError||e[53]!==t||e[54]!==C?(T=!a.loading&&a.value!==null&&$(be,{children:[$("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[r(q,{className:"text-xs",htmlFor:"kv-value-editor",children:t("Value")}),m!==void 0&&r(Oe,{variant:"secondary",children:t("JSON")}),r("span",{className:"ml-auto text-xs tabular-nums text-muted-foreground","data-testid":"kv-value-size",children:Ke(De(a.editedValue))})]}),r("textarea",{"aria-label":t("KV value"),className:"mb-2 min-h-[8rem] w-full rounded border border-border bg-muted/30 p-2 font-mono text-xs","data-testid":"kv-value-editor",id:"kv-value-editor",onChange:I,value:a.editedValue}),$("div",{className:"mb-3 flex flex-wrap gap-2",children:[r(B,{"data-testid":"kv-format-btn",disabled:m===void 0,onClick:w,size:"sm",variant:"outline",children:t("Format JSON")}),r(B,{"data-testid":"kv-copy-value-btn",onClick:()=>{ne(a.editedValue)},size:"sm",variant:"outline",children:t("Copy value")})]}),r($e,{helper:t("Leave blank to keep the current expiration."),id:"kv-ttl-input",invalid:!C,onChange:b=>{p({type:"editTtl",value:b})},testId:"kv-ttl-input"}),r(Se,{id:"kv-metadata-editor",invalidTestId:"kv-metadata-invalid",onChange:O,testId:"kv-metadata-editor",valid:x,value:a.editedMetadata}),$("div",{className:"flex flex-wrap gap-2",children:[r(B,{"data-testid":"kv-save-btn",disabled:a.busy!==""||!x||!C,onClick:_,children:a.busy==="saving"?t("Saving…"):t("Save")}),r(B,{"data-testid":"kv-delete-btn",disabled:a.busy!=="",onClick:D,variant:"destructive",children:a.busy==="deleting"?t("Deleting…"):t("Delete")})]}),a.writeError!==null&&r("p",{className:"mt-2 text-sm text-destructive","data-testid":"kv-save-error",role:"alert",children:a.writeError})]}),e[42]=m,e[43]=x,e[44]=D,e[45]=w,e[46]=_,e[47]=a.busy,e[48]=a.editedMetadata,e[49]=a.editedValue,e[50]=a.loading,e[51]=a.value,e[52]=a.writeError,e[53]=t,e[54]=C,e[55]=T):T=e[55];let K;e[56]!==a.loadError||e[57]!==a.loading||e[58]!==a.value||e[59]!==t?(K=!a.loading&&a.value===null&&a.loadError===null&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-absent",children:t("Key is absent or has no value.")}),e[56]=a.loadError,e[57]=a.loading,e[58]=a.value,e[59]=t,e[60]=K):K=e[60];let L;return e[61]!==u||e[62]!==E||e[63]!==S||e[64]!==T||e[65]!==K?(L=$("div",{className:"px-4 pb-4","data-testid":"kv-value-section",children:[u,E,S,T,K]}),e[61]=u,e[62]=E,e[63]=S,e[64]=T,e[65]=K,e[66]=L):L=e[66],L},me=100,He={appliedPrefix:"",bulk:[],bulkBusy:!1,bulkError:null,cursor:null,keys:null,listComplete:!1,loadError:null,loading:!1,prefixInput:"",reloadNonce:0,selectedKey:null},Re=(l,e)=>{switch(e.type){case"appendPage":return{...l,cursor:e.cursor,keys:[...l.keys??[],...e.keys],listComplete:e.listComplete,loading:!1};case"applyFilter":return{...l,appliedPrefix:l.prefixInput,bulk:[],bulkError:null,cursor:null,keys:null,listComplete:!1,selectedKey:null};case"bulkDeleted":{const n=new Set(e.deleted);return{...l,bulk:l.bulk.filter(c=>!n.has(c)),bulkBusy:!1,bulkError:e.error,keys:l.keys===null?null:l.keys.filter(c=>!n.has(c.name)),selectedKey:l.selectedKey!==null&&n.has(l.selectedKey)?null:l.selectedKey}}case"bulkDeleteStart":return{...l,bulkBusy:!0,bulkError:null};case"firstPage":return{...l,cursor:e.cursor,keys:e.keys,listComplete:e.listComplete,loading:!1};case"keyDeleted":return{...l,bulk:l.bulk.filter(n=>n!==e.name),keys:l.keys===null?null:l.keys.filter(n=>n.name!==e.name),selectedKey:null};case"loadFailed":return{...l,loadError:e.error,loading:!1};case"loadStart":return{...l,loadError:null,loading:!0};case"prefixInput":return{...l,prefixInput:e.value};case"reload":return{...l,bulk:[],bulkError:null,reloadNonce:l.reloadNonce+1,selectedKey:null};case"selectKey":return{...l,selectedKey:e.name};case"toggleAllBulk":return{...l,bulk:e.names};case"toggleBulk":return{...l,bulk:l.bulk.includes(e.name)?l.bulk.filter(n=>n!==e.name):[...l.bulk,e.name]};default:return l}},Ue=({namespace:l})=>{const e=ee(),n=G(),[c,s]=ae(Re,He),{appliedPrefix:v,bulk:i,bulkBusy:t,bulkError:a,cursor:p,keys:o,listComplete:g,loadError:f,loading:I,prefixInput:V,reloadNonce:O,selectedKey:y}=c,[m,h]=Z(!1);le(()=>{const d={cancelled:!1};return z((async()=>{s({type:"loadStart"});try{const u=await e.listKvKeys({limit:me,namespace:l,prefix:v===""?void 0:v});d.cancelled||s({cursor:u.cursor??null,keys:u.keys,listComplete:u.listComplete,type:"firstPage"})}catch(u){d.cancelled||s({error:H(u),type:"loadFailed"})}})()),()=>{d.cancelled=!0}},[e,l,v,O]);const x=d=>{s({type:"prefixInput",value:d.target.value})},N=()=>{s({type:"applyFilter"})},C=d=>{s({name:d.currentTarget.dataset.key??null,type:"selectKey"})},k=()=>{p!==null&&(s({type:"loadStart"}),z((async()=>{try{const d=await e.listKvKeys({cursor:p,limit:me,namespace:l,prefix:v===""?void 0:v});s({cursor:d.cursor??null,keys:d.keys,listComplete:d.listComplete,type:"appendPage"})}catch(d){s({error:H(d),type:"loadFailed"})}})()))},w=d=>{s({name:d,type:"keyDeleted"})},F=d=>{s({name:d,type:"toggleBulk"})},_=d=>{s({names:d&&o!==null?o.map(u=>u.name):[],type:"toggleAllBulk"})},M=()=>{if(i.length===0)return;const d=[...i];s({type:"bulkDeleteStart"}),z((async()=>{const u=await Promise.allSettled(d.map(T=>e.deleteKvKey({key:T,namespace:l}))),E=d.filter((T,K)=>u[K]?.status==="fulfilled"),S=d.length-E.length;s({deleted:E,error:S>0?n("Failed to delete {count} keys.",{count:S}):null,type:"bulkDeleted"})})())},D=()=>{h(!1),s({type:"reload"})},J=o!==null&&o.length>0&&i.length===o.length;return $(be,{children:[$("section",{className:"border border-border bg-card p-3","data-testid":"kv-keys-section",children:[$("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[r(re,{"aria-label":n("Filter keys by prefix"),className:"min-w-[16rem] flex-1","data-testid":"kv-prefix-input",onChange:x,placeholder:n("Filter by prefix…"),value:V}),r(B,{"data-testid":"kv-filter-btn",disabled:I,onClick:N,children:n("Filter")}),r(B,{"data-testid":"kv-new-key-btn",onClick:()=>{h(d=>!d)},variant:"outline",children:n("New key")}),i.length>0&&r(B,{"data-testid":"kv-bulk-delete-btn",disabled:t,onClick:M,variant:"destructive",children:t?n("Deleting…"):n("Delete {count}",{count:i.length})})]}),a!==null&&r("p",{className:"mb-2 text-sm text-destructive","data-testid":"kv-bulk-error",role:"alert",children:a}),f!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-keys-error",role:"alert",children:f}),o!==null&&o.length===0&&!I&&r("p",{className:"text-sm text-muted-foreground","data-testid":"kv-no-keys",children:n("No keys.")}),o!==null&&o.length>0&&r(ve,{className:"overflow-hidden py-0",children:r(pe,{className:"px-0",children:$(ye,{"data-testid":"kv-key-table",children:[r(he,{children:$(X,{children:[r(Y,{className:"w-10",children:r(de,{"aria-label":n("Select all"),checked:J,"data-testid":"kv-select-all",onCheckedChange:_})}),r(Y,{children:n("Key")}),r(Y,{children:n("Expiration")})]})}),r(ke,{children:o.map(d=>$(X,{className:d.name===y?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-key":d.name,"data-testid":`kv-key-row-${d.name}`,onClick:C,children:[r(Q,{onClick:u=>{u.stopPropagation()},children:r(de,{"aria-label":n("Select {name}",{name:d.name}),checked:i.includes(d.name),"data-testid":`kv-select-${d.name}`,onCheckedChange:()=>{F(d.name)}})}),r(Q,{className:"font-mono text-xs",children:d.name}),r(Q,{className:"tabular-nums text-xs",children:Je(d.expiration)})]},d.name))})]})})}),!g&&p!==null&&r("div",{className:"mt-2",children:r(B,{"data-testid":"kv-load-more",disabled:I,onClick:k,variant:"outline",children:n(I?"Loading…":"Load more")})})]}),r(se,{onOpenChange:d=>{d||h(!1)},open:m,children:$(ie,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-create-sheet",side:"right",children:[r(oe,{children:r(ce,{children:n("New key")})}),r(Pe,{namespace:l,onCancel:()=>{h(!1)},onCreated:D})]})}),r(se,{onOpenChange:d=>{d||s({name:null,type:"selectKey"})},open:y!==null,children:$(ie,{className:"w-full gap-0 overflow-y-auto sm:max-w-md","data-testid":"kv-editor-sheet",side:"right",children:[r(oe,{children:r(ce,{className:"truncate font-mono text-xs",children:y})}),y!==null&&r(ze,{expiration:o?.find(d=>d.name===y)?.expiration,keyName:y,namespace:l,onDeleted:w},`${l}:${y}`)]})})]})},ct=({loadNamespaces:l}={})=>{const e=ee(),n=G(),[c,s]=Z(null),[v,i]=Z(null),[t,a]=Z(null);le(()=>{const o={cancelled:!1};return z((async()=>{try{const g=await(l??(()=>e.listKvNamespaces()))();o.cancelled||(s(g),i(null),a(f=>f??g[0]?.binding??null))}catch(g){o.cancelled||(s(null),i(H(g)))}})()),()=>{o.cancelled=!0}},[e,l]);const p=o=>{a(o.currentTarget.dataset.ns??null)};return $("div",{className:"flex flex-col gap-4","data-testid":"lunora-kv-browser",children:[v!==null&&r("p",{className:"text-sm text-destructive","data-testid":"kv-ns-error",role:"alert",children:v}),c!==null&&c.length===0&&r(Fe,{description:n("Add a kv_namespaces binding to wrangler.jsonc — it appears here automatically, no wiring needed."),icon:r("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:r("path",{d:"M5 5h14v4H5V5Zm0 5h14v4H5v-4Zm0 5h14v4H5v-4Z"})}),testId:"kv-empty",title:n("No KV namespaces.")}),c!==null&&c.length>0&&r(ve,{className:"overflow-hidden py-0",children:r(pe,{className:"px-0",children:$(ye,{"data-testid":"kv-namespace-table",children:[r(he,{children:r(X,{children:r(Y,{children:n("Namespace")})})}),r(ke,{children:c.map(o=>r(X,{className:o.binding===t?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-ns":o.binding,"data-testid":`kv-ns-row-${o.binding}`,onClick:p,children:r(Q,{className:"font-mono text-xs",children:o.binding})},o.binding))})]})})}),t!==null&&r(Ue,{namespace:t},t)]})};export{ct as KvBrowser};
@@ -0,0 +1,4 @@
1
+ import{c as N}from"react/compiler-runtime";import{useState as y}from"react";import{u as b}from"../packem_shared/button-BkCrNcAs.js";import{c as k,u as v}from"../packem_shared/card-CIDGUN6K.js";import{u as C}from"../packem_shared/input-JHu63lTv.js";import{useT as w}from"../packem_shared/DEFAULT_LOCALE-BZ4NojpD.js";import{b as S}from"../packem_shared/cf-links-gbDy51nR.js";import{f as L,e as T,g as j}from"../packem_shared/internal-AtZ4bTal.js";import{jsxs as p,jsx as r}from"react/jsx-runtime";const $=t=>{const e=N(23),{destination:s}=t,h=w();let m;e[0]!==s.snippet?(m=()=>{j(s.snippet)},e[0]=s.snippet,e[1]=m):m=e[1];const u=m;let a;e[2]!==s.title?(a=r("h4",{className:"text-sm font-semibold",children:s.title}),e[2]=s.title,e[3]=a):a=e[3];let o;e[4]!==s.description?(o=r("p",{className:"text-sm text-muted-foreground",children:s.description}),e[4]=s.description,e[5]=o):o=e[5];let l;e[6]!==a||e[7]!==o?(l=p("div",{children:[a,o]}),e[6]=a,e[7]=o,e[8]=l):l=e[8];const g=`drain-copy-${s.id}`;let d;e[9]!==h?(d=h("Copy"),e[9]=h,e[10]=d):d=e[10];let i;e[11]!==u||e[12]!==g||e[13]!==d?(i=r(b,{"data-testid":g,onClick:u,size:"sm",variant:"outline",children:d}),e[11]=u,e[12]=g,e[13]=d,e[14]=i):i=e[14];let n;e[15]!==l||e[16]!==i?(n=p("div",{className:"flex items-start justify-between gap-3",children:[l,i]}),e[15]=l,e[16]=i,e[17]=n):n=e[17];let c;e[18]!==s.snippet?(c=r("pre",{className:"mt-2 overflow-x-auto rounded bg-muted p-2 font-mono text-xs",children:s.snippet}),e[18]=s.snippet,e[19]=c):c=e[19];let f;return e[20]!==n||e[21]!==c?(f=r(k,{className:"py-0","data-testid":"drain-card",children:p(v,{className:"p-3",children:[n,c]})}),e[20]=n,e[21]=c,e[22]=f):f=e[22],f},E=()=>{const t=w(),e=[{description:t("Stream every request log to R2, a SIEM, or a third-party log service."),id:"logpush",snippet:["{",' "logpush": true',"}"].join(`
2
+ `),title:t("Logpush")},{description:t("Send logs programmatically to a Worker for custom capture and forwarding."),id:"tail-worker",snippet:["{",' "tail_consumers": [{ "service": "my-log-forwarder" }]',"}"].join(`
3
+ `),title:t("Tail Workers")},{description:t("Retain and query recent request logs directly in Cloudflare's dashboard."),id:"workers-logs",snippet:["{",' "observability": { "enabled": true }',"}"].join(`
4
+ `),title:t("Workers Logs")}],[s,h]=y(""),[m,u]=y(!1),[a,o]=y(null),l=async()=>{const i=s.trim();if(i==="")return;const n="fetch"in globalThis?globalThis.fetch:void 0;if(n===void 0){o({kind:"error",message:t("fetch is unavailable in this environment.")});return}const c={durationMs:12,function:"messages:list",outcome:"ok",shard:"root",source:"lunora",tablesRead:["messages"],tablesWritten:[],ts:new Date().toISOString(),type:"request"};u(!0),o(null);const f=performance.now();try{const x=await n(i,{body:JSON.stringify(c),headers:{"Content-Type":"application/json"},method:"POST"});o({kind:"success",latencyMs:Math.round(performance.now()-f),status:x.status})}catch(x){o({kind:"error",message:T(x)})}finally{u(!1)}},g=()=>{L(l())},d=i=>{h(i.target.value)};return p("div",{className:"flex flex-col gap-4","data-testid":"log-drains",children:[r("div",{className:"flex flex-wrap items-center gap-3",children:r("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"drain-cf-link",href:S,rel:"noreferrer",target:"_blank",children:t("Open in Cloudflare")})}),r("p",{className:"text-sm text-muted-foreground","data-testid":"drain-readonly-note",children:t("Lunora does not ship logs itself — forwarding is handled by Cloudflare. Configure a destination below, then test your collector.")}),p("section",{className:"flex flex-col gap-3","data-testid":"drain-destinations",children:[r("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Cloudflare destinations")}),e.map(i=>r($,{destination:i},i.id))]}),r(k,{className:"py-0",children:r(v,{className:"p-3",children:p("section",{"data-testid":"drain-webhook",children:[r("h3",{className:"mb-1 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:t("Webhook test")}),r("p",{className:"mb-2 text-sm text-muted-foreground",children:t("POST a sample Lunora request-log envelope to your collector to confirm it is reachable.")}),p("div",{className:"flex flex-wrap items-center gap-2",children:[r(C,{className:"min-w-[20rem] flex-1","data-testid":"drain-webhook-url",onChange:d,placeholder:t("https://example.com/logs"),type:"url",value:s}),r(b,{"data-testid":"drain-webhook-test",disabled:m||s.trim()==="",onClick:g,children:t(m?"Sending…":"Send test event")})]}),a!==null&&r("p",{className:a.kind==="success"?"mt-2 text-sm text-muted-foreground":"mt-2 text-sm text-destructive","data-testid":"drain-webhook-result",role:a.kind==="error"?"alert":void 0,children:a.kind==="success"?t("Delivered — status {status} in {latency}ms",{latency:a.latencyMs,status:a.status}):t("Failed: {message}",{message:a.message})})]})})})]})};export{E as LogDrainsPanel};