@lunora/studio 1.0.0-alpha.349 → 1.0.0-alpha.350

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 (319) hide show
  1. package/README.md +3 -3
  2. package/dist/index.d.mts +9 -8
  3. package/dist/index.d.ts +9 -8
  4. package/dist/index.mjs +1 -1
  5. package/dist/mount.d.mts +3 -2
  6. package/dist/mount.d.ts +3 -2
  7. package/dist/mount.mjs +1 -1
  8. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  9. package/dist/packem_chunks/ApiTab.mjs +1 -1
  10. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  11. package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
  12. package/dist/packem_chunks/ExportImportPanel.mjs +5 -5
  13. package/dist/packem_chunks/FileBrowser.mjs +3 -3
  14. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  15. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  16. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  17. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  18. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  19. package/dist/packem_chunks/MailPanel.mjs +1 -1
  20. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  21. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  22. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  23. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  24. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  25. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  26. package/dist/packem_chunks/SqlEditorPanel.mjs +7 -7
  27. package/dist/packem_chunks/TableEditor.mjs +1 -1
  28. package/dist/packem_chunks/agents-panel.mjs +1 -1
  29. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  30. package/dist/packem_chunks/analytics-panel.mjs +1 -1
  31. package/dist/packem_chunks/architecture-panel.mjs +1 -1
  32. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  33. package/dist/packem_chunks/auth-config-panel.mjs +1 -1
  34. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  35. package/dist/packem_chunks/containers-panel.mjs +1 -1
  36. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  37. package/dist/packem_chunks/evals-panel.mjs +1 -1
  38. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  39. package/dist/packem_chunks/flags-panel.mjs +1 -1
  40. package/dist/packem_chunks/issues-panel.mjs +1 -1
  41. package/dist/packem_chunks/kv-browser.mjs +1 -1
  42. package/dist/packem_chunks/log-drains-panel.mjs +1 -1
  43. package/dist/packem_chunks/migrations-route.mjs +1 -1
  44. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  45. package/dist/packem_chunks/payments-panel.mjs +1 -1
  46. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  47. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  48. package/dist/packem_chunks/queues-panel.mjs +1 -1
  49. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  50. package/dist/packem_chunks/rls-panel.mjs +1 -1
  51. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  52. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  53. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  54. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  55. package/dist/packem_chunks/theme-indicator.mjs +1 -0
  56. package/dist/packem_chunks/traces-panel.mjs +1 -1
  57. package/dist/packem_chunks/users-panel.mjs +1 -1
  58. package/dist/packem_chunks/vector-browser.mjs +1 -1
  59. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  60. package/dist/packem_shared/{ApiDocsPanel-Py7C4ibM.mjs → ApiDocsPanel-B_RaW7Br.mjs} +2 -2
  61. package/dist/packem_shared/ApiReferencePanel-u9Rrljdf.mjs +1 -0
  62. package/dist/packem_shared/{CommandPalette-CM1hqAOD.mjs → CommandPalette-5OsK8PNe.mjs} +1 -1
  63. package/dist/packem_shared/{ConfirmButton-DU4p72Er.mjs → ConfirmButton-CIXYF6Mg.mjs} +1 -1
  64. package/dist/packem_shared/{ConnectionBadge-B8Hj5DaE.mjs → ConnectionBadge-BfcoN-VE.mjs} +1 -1
  65. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs +1 -0
  66. package/dist/packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs +1 -0
  67. package/dist/packem_shared/{DataBrowser-DFjQeYYF.mjs → DataBrowser-Cc1qZX-4.mjs} +1 -1
  68. package/dist/packem_shared/{DataFilters-faurWYyX.mjs → DataFilters--ocFTVT2.mjs} +1 -1
  69. package/dist/packem_shared/GlobalDataBrowser-Hq6gTlkb.mjs +1 -0
  70. package/dist/packem_shared/{HomePanel-C8sb1fFJ.mjs → HomePanel-DeyYLVxc.mjs} +1 -1
  71. package/dist/packem_shared/MigrationsPanel-CMZYYcQ5.mjs +1 -0
  72. package/dist/packem_shared/OpenRpcReferencePanel-E9cDfHRv.mjs +1 -0
  73. package/dist/packem_shared/ScheduledJobs-D4CUj7aX.mjs +1 -0
  74. package/dist/packem_shared/{ShardInput-C6mjgAh4.mjs → ShardInput-CoySruKZ.mjs} +1 -1
  75. package/dist/packem_shared/Studio-BhTqTeGb.mjs +1 -0
  76. package/dist/packem_shared/StudioApp-B1d0beD4.mjs +1 -0
  77. package/dist/packem_shared/{StudioI18nProvider-fVsCSs5L.mjs → StudioI18nProvider-CGXCPnQn.mjs} +1 -1
  78. package/dist/packem_shared/{advisor-view-B8oIluyS.mjs → advisor-view-fNcNYW2Q.mjs} +1 -1
  79. package/dist/packem_shared/{app.d-D45VvUTx.d.mts → app.d-D425h1XO.d.mts} +4 -3
  80. package/dist/packem_shared/{app.d-D45VvUTx.d.ts → app.d-D425h1XO.d.ts} +4 -3
  81. package/dist/packem_shared/{auth-pager-DiDnXsfe.mjs → auth-pager-DW77WeZw.mjs} +1 -1
  82. package/dist/packem_shared/{data-grid-BHTuvSI7.mjs → data-grid-r3isM8Nq.mjs} +1 -1
  83. package/dist/packem_shared/{diagram-export-panel-BMLzao0Y.mjs → diagram-export-panel-aBDQdX4e.mjs} +1 -1
  84. package/dist/packem_shared/{error-alert-CNQjdAhi.mjs → error-alert-54TiaMvZ.mjs} +1 -1
  85. package/dist/packem_shared/{grid-features-8DoaKdS1.mjs → grid-features-2c5SaBtH.mjs} +1 -1
  86. package/dist/packem_shared/{grid-pagination-DgzyzfBh.mjs → grid-pagination-DY2erU65.mjs} +1 -1
  87. package/dist/packem_shared/home-panel-0XMGe1hP.mjs +3 -0
  88. package/dist/packem_shared/{live-status-BuJdUZFU.mjs → live-status-D1GasNsH.mjs} +1 -1
  89. package/dist/packem_shared/{recording-client-neIRrUNz.mjs → recording-client-MbGZ28I0.mjs} +1 -1
  90. package/dist/packem_shared/{reference-view-BrsL8UGn.mjs → reference-view-DCEC5kjY.mjs} +4 -4
  91. package/dist/packem_shared/{schema-diagram-ghsOCED7.mjs → schema-diagram-k7cFl7Wp.mjs} +1 -1
  92. package/dist/packem_shared/{sql-result-table-COsfUSGc.mjs → sql-result-table-CatgdmMh.mjs} +1 -1
  93. package/dist/packem_shared/studio-CA3ZKwVK.mjs +2 -0
  94. package/dist/packem_shared/{table-list-sidebar-B7IOSxLN.mjs → table-list-sidebar-nA7g7uSk.mjs} +1 -1
  95. package/dist/packem_shared/use-admin-query-BW9IuacC.mjs +1 -0
  96. package/dist/packem_shared/use-auth-config-KO9tnI39.mjs +1 -0
  97. package/dist/packem_shared/use-sql-assistant-DXnqbBs-.mjs +1 -0
  98. package/dist/packem_shared/use-studio-client-DCA50tF2.mjs +1 -0
  99. package/dist/standalone/chunk-26OKWFLO.js +1 -0
  100. package/dist/standalone/chunk-2EL4EMYZ.js +1 -0
  101. package/dist/standalone/chunk-2O6KKVH2.js +1 -0
  102. package/dist/standalone/{chunk-WX647YQ7.js → chunk-2WNL74MI.js} +3 -3
  103. package/dist/standalone/chunk-2X6O33OX.js +1 -0
  104. package/dist/standalone/chunk-2ZO7XY3Z.js +1 -0
  105. package/dist/standalone/{chunk-Y3AYVFTK.js → chunk-3GXPALXG.js} +1 -1
  106. package/dist/standalone/chunk-3Y5K3IQO.js +1 -0
  107. package/dist/standalone/{chunk-BOMPSVRC.js → chunk-4C4THJUD.js} +1 -1
  108. package/dist/standalone/{chunk-WVWCUB4S.js → chunk-4IEMXFUB.js} +1 -1
  109. package/dist/standalone/{chunk-5B2RTXBS.js → chunk-4SQBAPY6.js} +1 -1
  110. package/dist/standalone/{chunk-R6U22RSY.js → chunk-5DNGK3NT.js} +1 -1
  111. package/dist/standalone/{chunk-WOEHFC4J.js → chunk-5J32EGHF.js} +1 -1
  112. package/dist/standalone/chunk-5NZWQEEJ.js +1 -0
  113. package/dist/standalone/chunk-6I42AM75.js +1 -0
  114. package/dist/standalone/{chunk-RGMVGZV4.js → chunk-6M7FLLMT.js} +1 -1
  115. package/dist/standalone/{chunk-IWZ7GVQO.js → chunk-6QEXGYWH.js} +1 -1
  116. package/dist/standalone/chunk-7AZYREIY.js +1 -0
  117. package/dist/standalone/{chunk-G43F7LYA.js → chunk-7F3S5OQT.js} +1 -1
  118. package/dist/standalone/chunk-7MN724WR.js +1 -0
  119. package/dist/standalone/{chunk-Q6IT6ZD7.js → chunk-7RGYCU6F.js} +1 -1
  120. package/dist/standalone/{chunk-NRP22GKC.js → chunk-A566HCBX.js} +1 -1
  121. package/dist/standalone/{chunk-253UHWDX.js → chunk-AOHKAKKL.js} +1 -1
  122. package/dist/standalone/{chunk-OYCUPD3Q.js → chunk-AP4PC2M4.js} +1 -1
  123. package/dist/standalone/chunk-B3AXFXAD.js +1 -0
  124. package/dist/standalone/chunk-B7MHW3A5.js +1 -0
  125. package/dist/standalone/{chunk-CWPBPBWJ.js → chunk-BHOLL76W.js} +6 -6
  126. package/dist/standalone/{chunk-I57ZVLUB.js → chunk-BTRYFPZH.js} +1 -1
  127. package/dist/standalone/chunk-BVKQA5OL.js +1 -0
  128. package/dist/standalone/chunk-CGZVMM3P.js +1 -0
  129. package/dist/standalone/chunk-CIVMATZK.js +3 -0
  130. package/dist/standalone/chunk-CLINNLLE.js +1 -0
  131. package/dist/standalone/chunk-CTE6RPXC.js +1 -0
  132. package/dist/standalone/chunk-CW57Q264.js +1 -0
  133. package/dist/standalone/chunk-D7JK65OK.js +1 -0
  134. package/dist/standalone/{chunk-FUYEZFBP.js → chunk-DBVJ5VLI.js} +1 -1
  135. package/dist/standalone/{chunk-XCYFP44W.js → chunk-DS7HZKZ2.js} +1 -1
  136. package/dist/standalone/{chunk-2WDKJ74A.js → chunk-DX55P3KZ.js} +1 -1
  137. package/dist/standalone/{chunk-55UGUCQ6.js → chunk-E26OT26O.js} +1 -1
  138. package/dist/standalone/{chunk-YUPEDAX3.js → chunk-E32FS6PE.js} +2 -2
  139. package/dist/standalone/chunk-E3VSRIQU.js +1 -0
  140. package/dist/standalone/chunk-EDGOSJXL.js +1 -0
  141. package/dist/standalone/chunk-EOR73TZZ.js +1 -0
  142. package/dist/standalone/chunk-F5LTDUMB.js +1 -0
  143. package/dist/standalone/chunk-FLVDICZL.js +1 -0
  144. package/dist/standalone/{chunk-5J4FLDJH.js → chunk-FPIUVV7Q.js} +1 -1
  145. package/dist/standalone/chunk-GMW2DYFU.js +1 -0
  146. package/dist/standalone/{chunk-VFFW3ANI.js → chunk-GPOSJNMV.js} +5 -5
  147. package/dist/standalone/chunk-GQYA5W5T.js +1 -0
  148. package/dist/standalone/chunk-HFYFYNSX.js +1 -0
  149. package/dist/standalone/chunk-HKLF627N.js +1 -0
  150. package/dist/standalone/{chunk-PSMQQV6S.js → chunk-HKPDPKXD.js} +1 -1
  151. package/dist/standalone/chunk-HLAAOW33.js +1 -0
  152. package/dist/standalone/{chunk-75M6ZLLS.js → chunk-HOPAJ5F6.js} +2 -2
  153. package/dist/standalone/{chunk-7Y3SY37W.js → chunk-IBJVVHV5.js} +1 -1
  154. package/dist/standalone/{chunk-VESGIGMQ.js → chunk-IH2CJZF2.js} +1 -1
  155. package/dist/standalone/chunk-JAHK7RRJ.js +1 -0
  156. package/dist/standalone/chunk-JG2C7SS2.js +1 -0
  157. package/dist/standalone/chunk-JGMQQ3S7.js +1 -0
  158. package/dist/standalone/{chunk-3YXASVTP.js → chunk-JTGGWF7R.js} +1 -1
  159. package/dist/standalone/chunk-KFNDET5D.js +1 -0
  160. package/dist/standalone/{chunk-NXQW5E6W.js → chunk-KRPXOSBL.js} +1 -1
  161. package/dist/standalone/{chunk-7Q256NLI.js → chunk-KYONGQQ4.js} +1 -1
  162. package/dist/standalone/{chunk-OPM7ESDV.js → chunk-LIGOLZND.js} +1 -1
  163. package/dist/standalone/{chunk-VQRCJJXS.js → chunk-LKCO3E2B.js} +1 -1
  164. package/dist/standalone/chunk-LOV52GLG.js +1 -0
  165. package/dist/standalone/chunk-LPINY2IJ.js +19 -0
  166. package/dist/standalone/{chunk-XKISL2CG.js → chunk-LRXCL6IA.js} +1 -1
  167. package/dist/standalone/{chunk-OQ6I6OXT.js → chunk-LUHXNZI4.js} +1 -1
  168. package/dist/standalone/chunk-MD67S53Z.js +1 -0
  169. package/dist/standalone/{chunk-HIJGQX6F.js → chunk-MDAXV2XH.js} +1 -1
  170. package/dist/standalone/{chunk-ZN7TURF4.js → chunk-MFNO5BFR.js} +1 -1
  171. package/dist/standalone/chunk-MMJTKSHL.js +1 -0
  172. package/dist/standalone/chunk-NMVFSJM7.js +1 -0
  173. package/dist/standalone/chunk-NVHHB5EV.js +2 -0
  174. package/dist/standalone/chunk-O3FDK56W.js +1 -0
  175. package/dist/standalone/{chunk-C7FJ2JKY.js → chunk-OECMBE6Q.js} +1 -1
  176. package/dist/standalone/chunk-OSJ7HV7B.js +1 -0
  177. package/dist/standalone/chunk-OUFWXYEF.js +1 -0
  178. package/dist/standalone/chunk-OXFKZ4BM.js +1 -0
  179. package/dist/standalone/{chunk-63QLK2KW.js → chunk-P5GAJKDW.js} +1 -1
  180. package/dist/standalone/chunk-P6L6ABWO.js +1 -0
  181. package/dist/standalone/chunk-PZZWUL5U.js +1 -0
  182. package/dist/standalone/chunk-QAQVT4FS.js +1 -0
  183. package/dist/standalone/{chunk-VCFEO3RI.js → chunk-R36QXQZX.js} +1 -1
  184. package/dist/standalone/chunk-R3KLR5EP.js +1 -0
  185. package/dist/standalone/chunk-RXVXXRYD.js +1 -0
  186. package/dist/standalone/chunk-S7XAAH7U.js +1 -0
  187. package/dist/standalone/{chunk-E4PXACVL.js → chunk-SDQH4HR6.js} +1 -1
  188. package/dist/standalone/chunk-SFY646MC.js +1 -0
  189. package/dist/standalone/{chunk-VDC6JP4A.js → chunk-SJLEEYCR.js} +1 -1
  190. package/dist/standalone/{chunk-ZKJS6EBE.js → chunk-SLIDAWNX.js} +1 -1
  191. package/dist/standalone/chunk-SOO2HXV6.js +1 -0
  192. package/dist/standalone/chunk-SXD6JQXF.js +1 -0
  193. package/dist/standalone/{chunk-AUGKHAMQ.js → chunk-SYGCASPT.js} +1 -1
  194. package/dist/standalone/{chunk-2I4NHEKA.js → chunk-TDVDZ7XQ.js} +1 -1
  195. package/dist/standalone/chunk-TRZTGE4R.js +1 -0
  196. package/dist/standalone/chunk-TWMS2TMF.js +1 -0
  197. package/dist/standalone/chunk-U76DVXTR.js +21 -0
  198. package/dist/standalone/chunk-UTX6IBA3.js +1 -0
  199. package/dist/standalone/chunk-UZIBQZ2F.js +1 -0
  200. package/dist/standalone/chunk-VB6YJKPA.js +1 -0
  201. package/dist/standalone/{chunk-CVXNHIQW.js → chunk-VEWQWS3J.js} +1 -1
  202. package/dist/standalone/{chunk-UC7MNI2F.js → chunk-W2BCSK5S.js} +1 -1
  203. package/dist/standalone/chunk-W2XSKODB.js +1 -0
  204. package/dist/standalone/{chunk-MVWZMWPD.js → chunk-W7MRISE3.js} +1 -1
  205. package/dist/standalone/chunk-W7Z35E2E.js +1 -0
  206. package/dist/standalone/chunk-WIET27J3.js +1 -0
  207. package/dist/standalone/chunk-WQGT24W6.js +1 -0
  208. package/dist/standalone/{chunk-GZEWLX7U.js → chunk-WS36BO4R.js} +1 -1
  209. package/dist/standalone/chunk-WZTY3ZYI.js +1 -0
  210. package/dist/standalone/chunk-X5KWBDTF.js +1 -0
  211. package/dist/standalone/chunk-X74GEPSG.js +1 -0
  212. package/dist/standalone/chunk-XBZUJDHD.js +1 -0
  213. package/dist/standalone/chunk-XMEVNOCA.js +1 -0
  214. package/dist/standalone/chunk-XWEDIIIT.js +1 -0
  215. package/dist/standalone/{chunk-GHQ2VDI2.js → chunk-XYR5NST4.js} +1 -1
  216. package/dist/standalone/{chunk-XGCIDUJF.js → chunk-YHTHRYP5.js} +1 -1
  217. package/dist/standalone/{chunk-RX755NMO.js → chunk-YJ2WHOGO.js} +1 -1
  218. package/dist/standalone/chunk-YJWR6ZWC.js +1 -0
  219. package/dist/standalone/{chunk-CGQMJYCW.js → chunk-Z5EV64KS.js} +1 -1
  220. package/dist/standalone/{chunk-LVIL2SFA.js → chunk-ZBFWT34B.js} +1 -1
  221. package/dist/standalone/{chunk-AUAECCXB.js → chunk-ZBON5T5A.js} +1 -1
  222. package/dist/standalone/chunk-ZGSL4DPP.js +1 -0
  223. package/dist/standalone/chunk-ZMQ6PKLN.js +1 -0
  224. package/dist/standalone/{chunk-SJQERRSZ.js → chunk-ZTOREMGH.js} +1 -1
  225. package/dist/standalone/chunk-ZTOXQK4V.js +1 -0
  226. package/dist/standalone/chunk-ZWDORIZY.js +1 -0
  227. package/dist/standalone/chunk-ZZAJHNZ6.js +1 -0
  228. package/dist/standalone/studio.js +1 -1
  229. package/package.json +5 -5
  230. package/dist/packem_chunks/sparkline.mjs +0 -1
  231. package/dist/packem_shared/ApiReferencePanel-DlYVADAy.mjs +0 -1
  232. package/dist/packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs +0 -1
  233. package/dist/packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs +0 -1
  234. package/dist/packem_shared/GlobalDataBrowser-CPfjubP_.mjs +0 -1
  235. package/dist/packem_shared/MigrationsPanel-Dzjf42y8.mjs +0 -1
  236. package/dist/packem_shared/OpenRpcReferencePanel-nYyfjjse.mjs +0 -1
  237. package/dist/packem_shared/ScheduledJobs-BJ1uZW1U.mjs +0 -1
  238. package/dist/packem_shared/Studio-CgqntIfx.mjs +0 -1
  239. package/dist/packem_shared/StudioApp-DfFjQPGJ.mjs +0 -1
  240. package/dist/packem_shared/home-panel-BJXZsAaD.mjs +0 -3
  241. package/dist/packem_shared/studio-CFSjGWyw.mjs +0 -2
  242. package/dist/packem_shared/use-admin-query-CLStXJ7v.mjs +0 -1
  243. package/dist/packem_shared/use-auth-config-DtZeS_qf.mjs +0 -1
  244. package/dist/packem_shared/use-sql-assistant-DxNeNdCs.mjs +0 -1
  245. package/dist/standalone/chunk-2IKDEUCX.js +0 -1
  246. package/dist/standalone/chunk-37WYCOQ2.js +0 -1
  247. package/dist/standalone/chunk-4H5PBJNF.js +0 -1
  248. package/dist/standalone/chunk-4UBF7HMZ.js +0 -1
  249. package/dist/standalone/chunk-533J6WYA.js +0 -1
  250. package/dist/standalone/chunk-5QR2SQIS.js +0 -1
  251. package/dist/standalone/chunk-5ZNIQENA.js +0 -1
  252. package/dist/standalone/chunk-63Z6OJ6G.js +0 -1
  253. package/dist/standalone/chunk-74IYYDDI.js +0 -19
  254. package/dist/standalone/chunk-7EHAUFJY.js +0 -2
  255. package/dist/standalone/chunk-7G4Z6Q7X.js +0 -1
  256. package/dist/standalone/chunk-7RKB5KS7.js +0 -1
  257. package/dist/standalone/chunk-7TN6VTTF.js +0 -1
  258. package/dist/standalone/chunk-AWWECTQT.js +0 -1
  259. package/dist/standalone/chunk-AXL4YZJR.js +0 -1
  260. package/dist/standalone/chunk-COK5BCWN.js +0 -1
  261. package/dist/standalone/chunk-CULVXE3K.js +0 -1
  262. package/dist/standalone/chunk-E4BAGQ53.js +0 -1
  263. package/dist/standalone/chunk-EBTYSPZB.js +0 -1
  264. package/dist/standalone/chunk-EC5PMSQ6.js +0 -1
  265. package/dist/standalone/chunk-ECY2JC5F.js +0 -1
  266. package/dist/standalone/chunk-EWMBX5N2.js +0 -1
  267. package/dist/standalone/chunk-FPI7AMQJ.js +0 -1
  268. package/dist/standalone/chunk-GC5UHRDR.js +0 -1
  269. package/dist/standalone/chunk-GRHO2IUN.js +0 -1
  270. package/dist/standalone/chunk-GUDC24NJ.js +0 -1
  271. package/dist/standalone/chunk-H467GBSD.js +0 -1
  272. package/dist/standalone/chunk-HBO4SMAO.js +0 -15
  273. package/dist/standalone/chunk-HBTGWHTW.js +0 -1
  274. package/dist/standalone/chunk-HCTJKP5J.js +0 -1
  275. package/dist/standalone/chunk-HZTJLEIJ.js +0 -1
  276. package/dist/standalone/chunk-I26MS5PJ.js +0 -1
  277. package/dist/standalone/chunk-IRKWOUXO.js +0 -1
  278. package/dist/standalone/chunk-IUSKFS3B.js +0 -1
  279. package/dist/standalone/chunk-K2EHRNYW.js +0 -1
  280. package/dist/standalone/chunk-L5MI4PTP.js +0 -1
  281. package/dist/standalone/chunk-LXCVA5SP.js +0 -1
  282. package/dist/standalone/chunk-LYQZERWS.js +0 -1
  283. package/dist/standalone/chunk-MPEIBWCJ.js +0 -1
  284. package/dist/standalone/chunk-NCFYQR4L.js +0 -1
  285. package/dist/standalone/chunk-NCPW7WHO.js +0 -1
  286. package/dist/standalone/chunk-NOS2OC45.js +0 -1
  287. package/dist/standalone/chunk-NQZALRU3.js +0 -1
  288. package/dist/standalone/chunk-OQ2ORNN6.js +0 -1
  289. package/dist/standalone/chunk-OVBYLXPD.js +0 -1
  290. package/dist/standalone/chunk-OWQHP4KI.js +0 -1
  291. package/dist/standalone/chunk-PKSRXFSZ.js +0 -1
  292. package/dist/standalone/chunk-Q6ED4KUL.js +0 -1
  293. package/dist/standalone/chunk-QAQDMS6R.js +0 -1
  294. package/dist/standalone/chunk-QC2GLF3I.js +0 -1
  295. package/dist/standalone/chunk-QFK4UI4Q.js +0 -1
  296. package/dist/standalone/chunk-QJ4AALXU.js +0 -1
  297. package/dist/standalone/chunk-QJLHH3ET.js +0 -1
  298. package/dist/standalone/chunk-R3RBUT32.js +0 -1
  299. package/dist/standalone/chunk-RNYOBPQA.js +0 -1
  300. package/dist/standalone/chunk-RWVIV3U7.js +0 -1
  301. package/dist/standalone/chunk-RYBLB23Z.js +0 -1
  302. package/dist/standalone/chunk-S3EWTSAN.js +0 -1
  303. package/dist/standalone/chunk-S4AR74DJ.js +0 -3
  304. package/dist/standalone/chunk-S4Z7K55A.js +0 -1
  305. package/dist/standalone/chunk-SA2OGF3F.js +0 -1
  306. package/dist/standalone/chunk-SFMIR4YV.js +0 -1
  307. package/dist/standalone/chunk-SROQCZ3P.js +0 -1
  308. package/dist/standalone/chunk-T4SIZOJG.js +0 -1
  309. package/dist/standalone/chunk-U37BPX5J.js +0 -1
  310. package/dist/standalone/chunk-UFZVSXRW.js +0 -1
  311. package/dist/standalone/chunk-UQWGBWQ3.js +0 -1
  312. package/dist/standalone/chunk-V6LPISRQ.js +0 -1
  313. package/dist/standalone/chunk-WEPM5G3R.js +0 -1
  314. package/dist/standalone/chunk-WGBAHXMK.js +0 -1
  315. package/dist/standalone/chunk-WGUN4FNJ.js +0 -1
  316. package/dist/standalone/chunk-WJRYEML4.js +0 -1
  317. package/dist/standalone/chunk-WNMY5ZKL.js +0 -1
  318. package/dist/standalone/chunk-YBDF3DET.js +0 -7
  319. package/dist/standalone/chunk-YJI56OCF.js +0 -1
@@ -1 +1 @@
1
- import{useState as h,useRef as le,useEffect as oe}from"react";import{c as xe,d as ye,b as be,a as de,C as me}from"../packem_shared/card-By2O8ULa.mjs";import{useT as ee}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{c as fe}from"react/compiler-runtime";import{E as ge}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{L as ve}from"../packem_shared/live-status-BuJdUZFU.mjs";import{B as Q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as j}from"../packem_shared/button-q0UYSmrn.mjs";import{E as pe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Ne,a as ke,b as ie,c as te,d as Ce,e as ae}from"../packem_shared/table-D0SBiDu-.mjs";import{u as re}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{ADMIN_FUNCTIONS as X}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as o,jsx as a}from"react/jsx-runtime";import{useLunora as ue}from"@lunora/react";import{decodeWire as Se}from"@lunora/wire";import{ConfirmButton as we}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{ShardInput as Pe}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{I as G}from"../packem_shared/input-CXhxesPC.mjs";import{L as O}from"../packem_shared/label-DKFzyHq6.mjs";import{T as Ie}from"../packem_shared/textarea--40GKAyz.mjs";import{d as Te,c as Ae,b as Ee,f as se,k as Re}from"../packem_shared/internal-BXEjuLPN.mjs";const ne=["read","insert","update","delete"],_e=(e,t)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[t],Fe=e=>e.file===""?e.procedure:`${e.file}:${e.procedure}`,Oe=e=>{const t=new Set;for(const i of e?.advisories??[])if(i.name==="rls_uncovered_table"){const{table:d}=i.metadata;typeof d=="string"&&d!==""&&t.add(d)}return t},De=(e,t,i)=>{const d=new Map,r=c=>{const n=d.get(c);if(n!==void 0)return n;const f={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:c,uncovered:i.has(c)};return d.set(c,f),f};for(const c of e)r(c.table).cells[c.on]={path:Fe(c),procedure:c.procedure};for(const c of t)r(c.table).maskedColumns.add(c.column);for(const c of i)r(c);return[...d.values()].toSorted((c,n)=>c.table.localeCompare(n.table))},Le=e=>{const t=fe(17);let i;t[0]!==e?(i=e===void 0?{}:e,t[0]=e,t[1]=i):i=t[1];const{onProbe:d}=i,r=ee();let c,n;t[2]===Symbol.for("react.memo_cache_sentinel")?(c={},n={live:!0},t[2]=c,t[3]=n):(c=t[2],n=t[3]);const f=re(X.rlsPolicies,c,n);let s;t[4]===Symbol.for("react.memo_cache_sentinel")?(s={},t[4]=s):s=t[4];const k=re(X.maskPolicies,s);let u;t[5]===Symbol.for("react.memo_cache_sentinel")?(u={},t[5]=u):u=t[5];const y=re(X.getAdvisories,u);let b;if(t[6]!==y.data||t[7]!==k.data||t[8]!==d||t[9]!==f||t[10]!==r){let C=null;f.data!==void 0&&(C=Array.isArray(f.data.policies)?f.data.policies:[]);const D=Array.isArray(k.data?.columns)?k.data.columns:[],H=y.data??null,{error:P,errorSource:g,liveError:I}=f,T=C===null?[]:De(C,D,Oe(H));let S;t[12]!==I?(S=a("div",{className:"flex items-center justify-end",children:a(ve,{message:I,prefix:"pm"})}),t[12]=I,t[13]=S):S=t[13];let p;t[14]!==P||t[15]!==g?(p=P!==null&&a(ge,{error:g,testId:"pm-error"}),t[14]=P,t[15]=g,t[16]=p):p=t[16],b=o("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[S,p,C!==null&&T.length===0?a(pe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):o(Ne,{"data-testid":"pm-table",children:[a(ke,{children:o(ie,{children:[a(te,{children:r("Table")}),ne.map(m=>a(te,{children:_e(r,m)},m)),a(te,{children:r("Masked columns")})]})}),a(Ce,{children:T.map(m=>o(ie,{"data-testid":`pm-row-${m.table}`,children:[a(ae,{className:"font-mono text-xs",children:o("span",{className:"flex items-center gap-1.5",children:[m.table,m.uncovered&&a(Q,{"data-testid":`pm-uncovered-${m.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),ne.map(A=>{const v=m.cells[A];return a(ae,{"data-testid":`pm-cell-${m.table}-${A}`,children:v.procedure===void 0?a("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):o("span",{className:"flex flex-col gap-1",children:[a(Q,{variant:"secondary",children:r("Covered by {procedure}",{procedure:v.procedure})}),d!==void 0&&a(j,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${m.table}-${A}`,onClick:()=>{d(m.table,A,v.path??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},A)}),a(ae,{children:m.maskedColumns.size===0?a("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):a("span",{className:"flex flex-wrap gap-1",children:[...m.maskedColumns].map($e)})})]},m.table))})]})]}),t[6]=y.data,t[7]=k.data,t[8]=d,t[9]=f,t[10]=r,t[11]=b}else b=t[11];return b};function $e(e){return a(Q,{variant:"outline",children:e},e)}const Ue=Ae(X.runAs),Me=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),We=e=>{const t=e?.code;return typeof t=="string"?t:void 0},ze=()=>{const e=ue();return async({args:t,functionPath:i,shardKey:d="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};const c=Ue;try{return{kind:"allowed",value:await e.query(c,{args:t,functionPath:i,userId:r},Te(d))}}catch(n){const f=n instanceof Error?n.message:String(n),s=We(n);return s!==void 0&&Me.has(s)?{kind:"denied",message:f}:{kind:"errored",message:f}}}},qe=e=>e===void 0?"undefined":JSON.stringify(e,Re,2),Be=({functions:e,prefill:t,runAsIdentity:i=!1}={})=>{const d=ue(),r=ee(),c=ze(),[n,f]=h(null),[s,k]=h(null),u=e??n??[],[y,b]=h(""),[C,D]=h("{}"),[H,P]=h(""),[g,I]=h(""),[T,S]=h(!1),[p,m]=h(null),[A,v]=h(null),[E,L]=h(!1),R=le(-1),w=le(0);oe(()=>{if(e!==void 0)return;let l=!1;return d.listFunctions().then(N=>(l||f(N),N)).catch(N=>{l||k(Ee(N))}),()=>{l=!0}},[d,e]),oe(()=>{if(t===void 0||R.current===t.nonce)return;R.current=t.nonce,w.current+=1;const l=t.functionPath;queueMicrotask(()=>{b(l),m(null)})},[t]);const J=E?u:u.filter(l=>l.kind==="query"||l.path===y),x=y===""?J[0]?.path??"":y,$=u.find(l=>l.path===x),K=x!==""&&$?.kind!=="query",U=async()=>{if(x==="")return;let l;try{l=C.trim()===""?{}:Se(JSON.parse(C))}catch(B){v(r("Invalid JSON args: {message}",{message:B.message})),m(null);return}w.current+=1;const N=w.current;v(null),S(!0);try{const B=await c({args:l,functionPath:x,shardKey:H.trim(),userId:g.trim()});N===w.current&&m(B)}finally{S(!1)}},_=()=>{se(U())},M=l=>{b(l.target.value)},W=l=>{D(l.target.value)},z=l=>{I(l.target.value)},q=l=>{L(l.target.checked),!l.target.checked&&K&&b("")},F=!i||T||x==="";return o("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[s!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:s}),!i&&a(pe,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),o("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[o("div",{className:"flex flex-col gap-1.5",children:[a(O,{htmlFor:"pp-function",children:r("Function")}),a("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:M,value:x,children:J.map(l=>o("option",{value:l.path,children:[l.path," (",l.kind,")"]},l.path))}),o(O,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[a("input",{checked:E,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:q,type:"checkbox"}),r("Include mutations and actions")]})]}),o("div",{className:"flex flex-col gap-1.5",children:[a(O,{htmlFor:"pp-args",children:r("Arguments")}),a(Ie,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:C})]}),a(Pe,{onChange:P,testId:"pp-shard",value:H}),o("div",{className:"flex flex-col gap-1.5",children:[a(O,{htmlFor:"pp-user",children:r("Run as (userId)")}),a(G,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:z,placeholder:r("Required — the identity to probe as"),value:g})]}),o("div",{className:"flex items-center gap-2",children:[K?a(we,{confirmLabel:r("This will execute `{functionPath}` as user `{userId}`.",{functionPath:x,userId:g.trim()}),disabled:F,onConfirm:_,testId:"pp-run",children:r(T?"Probing…":"Run probe")}):a(j,{"data-testid":"pp-run",disabled:F,onClick:_,type:"button",children:r(T?"Probing…":"Run probe")}),g.trim()!==""&&a(Q,{"data-testid":"pp-as-badge",variant:"secondary",children:r("as {userId}",{userId:g.trim()})})]})]}),A!==null&&a("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:A}),p!==null&&p.kind==="allowed"&&o("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[a(Q,{variant:"secondary",children:r("Allowed")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:qe(p.value)})]}),p!==null&&p.kind==="invalid"&&o("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[a(Q,{variant:"outline",children:r("Not run")}),a("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:p.message})]}),p!==null&&p.kind==="errored"&&o("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[a(Q,{variant:"outline",children:r("Errored")}),a("p",{className:"text-sm text-muted-foreground",children:r("The call failed for a reason that is not an access verdict, so it says nothing about the policy.")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:p.message})]}),p!==null&&p.kind==="denied"&&o("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[a(Q,{variant:"destructive",children:r("Denied")}),a("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:p.message})]})]})},je="/__lunora/policy-scaffold",Qe={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists — pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({…}) form — convert it to the builder form (c.use(…).query(…)) before wiring RLS."},He=async e=>{const t=await fetch(je,{body:JSON.stringify(e),headers:{"Content-Type":"application/json"},method:"POST"}),i=await t.json();if(i.needsManualEdit===!0)return{kind:"needs-manual-edit",message:i.message??"This change must be made by hand."};if(t.ok)return{diagnostics:i.diagnostics??[],kind:"ok",label:i.fileName??i.exportName??""};const d=i.error;return{kind:"error",message:d===void 0?`policy scaffold failed (${String(t.status)})`:Qe[d]??d}},ce={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Je=()=>{const e=fe(69),t=ee(),[i,d]=h(null),[r,c]=h(!1),[n,f]=h(null),[s,k]=h(ce);let u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u=Z=>{const Y=Z.target.name,{value:V}=Z.target;k(he=>({...he,[Y]:V}))},e[0]=u):u=e[0];const y=u;let b;e[1]===Symbol.for("react.memo_cache_sentinel")?(b=()=>{d(null),k(ce)},e[1]=b):b=e[1];const C=b;let D;e[2]===Symbol.for("react.memo_cache_sentinel")?(D=async Z=>{c(!0),f(null);try{const Y=await He(Z);f(Y),Y.kind==="ok"&&C()}catch(Y){const V=Y;f({kind:"error",message:V instanceof Error?V.message:String(V)})}c(!1)},e[2]=D):D=e[2];const H=D;let P;e[3]!==s.policyName||e[4]!==s.tableName?(P=()=>{se(H({kind:"scaffoldPolicy",name:s.policyName.trim(),table:s.tableName.trim()}))},e[3]=s.policyName,e[4]=s.tableName,e[5]=P):P=e[5];const g=P;let I;e[6]!==s.exportName||e[7]!==s.filePath||e[8]!==s.policies?(I=()=>{se(H({exportName:s.exportName.trim(),filePath:s.filePath.trim(),kind:"wireRls",policies:s.policies.trim()}))},e[6]=s.exportName,e[7]=s.filePath,e[8]=s.policies,e[9]=I):I=e[9];const T=I;let S;e[10]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{f(null),d("scaffold")},e[10]=S):S=e[10];const p=S;let m;e[11]===Symbol.for("react.memo_cache_sentinel")?(m=()=>{f(null),d("wire")},e[11]=m):m=e[11];const A=m;let v;e[12]!==t?(v=t("Scaffold access rules"),e[12]=t,e[13]=v):v=e[13];let E;e[14]!==v?(E=a(xe,{children:v}),e[14]=v,e[15]=E):E=e[15];let L;e[16]!==t?(L=t("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),e[16]=t,e[17]=L):L=e[17];let R;e[18]!==L?(R=a(ye,{children:L}),e[18]=L,e[19]=R):R=e[19];let w;e[20]!==R||e[21]!==E?(w=o(be,{children:[E,R]}),e[20]=R,e[21]=E,e[22]=w):w=e[22];const J=i==="scaffold"?"default":"outline";let x;e[23]!==t?(x=t("New policy file"),e[23]=t,e[24]=x):x=e[24];let $;e[25]!==J||e[26]!==x?($=a(j,{"data-testid":"policy-scaffolder-new",onClick:p,size:"xs",type:"button",variant:J,children:x}),e[25]=J,e[26]=x,e[27]=$):$=e[27];const K=i==="wire"?"default":"outline";let U;e[28]!==t?(U=t("Wire into a procedure"),e[28]=t,e[29]=U):U=e[29];let _;e[30]!==K||e[31]!==U?(_=a(j,{"data-testid":"policy-scaffolder-wire",onClick:A,size:"xs",type:"button",variant:K,children:U}),e[30]=K,e[31]=U,e[32]=_):_=e[32];let M;e[33]!==$||e[34]!==_?(M=o("div",{className:"flex flex-wrap gap-2",children:[$,_]}),e[33]=$,e[34]=_,e[35]=M):M=e[35];let W;e[36]!==r||e[37]!==s.policyName||e[38]!==s.tableName||e[39]!==i||e[40]!==g||e[41]!==t?(W=i==="scaffold"&&o("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[o("div",{className:"flex flex-col gap-1 text-xs",children:[a(O,{htmlFor:"policy-scaffolder-name",children:t("Policy name")}),a(G,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:y,value:s.policyName})]}),o("div",{className:"flex flex-col gap-1 text-xs",children:[a(O,{htmlFor:"policy-scaffolder-table",children:t("Table name")}),a(G,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:y,value:s.tableName})]}),a(j,{"data-testid":"policy-scaffolder-create",disabled:r||s.policyName.trim()===""||s.tableName.trim()==="",onClick:g,size:"xs",type:"button",children:t(r?"Creating…":"Create policy file")}),a(j,{onClick:C,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[36]=r,e[37]=s.policyName,e[38]=s.tableName,e[39]=i,e[40]=g,e[41]=t,e[42]=W):W=e[42];let z;e[43]!==r||e[44]!==s.exportName||e[45]!==s.filePath||e[46]!==s.policies||e[47]!==i||e[48]!==T||e[49]!==t?(z=i==="wire"&&o("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[o("div",{className:"flex flex-col gap-1 text-xs",children:[a(O,{htmlFor:"policy-scaffolder-file",children:t("Procedure file path")}),a(G,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:y,value:s.filePath})]}),o("div",{className:"flex flex-col gap-1 text-xs",children:[a(O,{htmlFor:"policy-scaffolder-export",children:t("Exported procedure")}),a(G,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:y,value:s.exportName})]}),o("div",{className:"flex flex-col gap-1 text-xs",children:[a(O,{htmlFor:"policy-scaffolder-policies",children:t("Policy set identifier")}),a(G,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:y,value:s.policies})]}),a(j,{"data-testid":"policy-scaffolder-apply",disabled:r||s.filePath.trim()===""||s.exportName.trim()===""||s.policies.trim()==="",onClick:T,size:"xs",type:"button",children:t(r?"Wiring…":"Wire RLS")}),a(j,{onClick:C,size:"xs",type:"button",variant:"ghost",children:t("Cancel")})]}),e[43]=r,e[44]=s.exportName,e[45]=s.filePath,e[46]=s.policies,e[47]=i,e[48]=T,e[49]=t,e[50]=z):z=e[50];let q;e[51]!==n?(q=n?.kind==="error"&&a("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:n.message}),e[51]=n,e[52]=q):q=e[52];let F;e[53]!==n?.kind||e[54]!==t?(F=n?.kind==="needs-manual-edit"&&a("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:t("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),e[53]=n?.kind,e[54]=t,e[55]=F):F=e[55];let l;e[56]!==n||e[57]!==t?(l=n?.kind==="ok"&&o("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[a("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:t("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:n.label})}),n.diagnostics.length>0&&a("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:n.diagnostics.map(Ke)})]}),e[56]=n,e[57]=t,e[58]=l):l=e[58];let N;e[59]!==M||e[60]!==W||e[61]!==z||e[62]!==q||e[63]!==F||e[64]!==l?(N=o(de,{children:[M,W,z,q,F,l]}),e[59]=M,e[60]=W,e[61]=z,e[62]=q,e[63]=F,e[64]=l,e[65]=N):N=e[65];let B;return e[66]!==w||e[67]!==N?(B=o(me,{"data-testid":"policy-scaffolder",size:"sm",children:[w,N]}),e[66]=w,e[67]=N,e[68]=B):B=e[68],B};function Ke(e){return a("li",{className:"font-mono text-[11px] text-destructive",children:e},e)}const xt=({functions:e,runAsIdentity:t=!1,schemaEditable:i=!1}={})=>{const d=ee(),[r,c]=h(void 0),n=(f,s,k)=>{k!==""&&c(u=>({functionPath:k,nonce:(u?.nonce??0)+1}))};return o("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[o("section",{className:"flex flex-col gap-3",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Permissions")})}),a(Le,{onProbe:n})]}),a("section",{className:"flex flex-col gap-3",children:o(me,{className:"gap-0 py-0",children:[a("header",{className:"border-b border-border px-4 py-3",children:a("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:d("Probe")})}),o(de,{className:"px-4 py-4",children:[a("p",{className:"mb-3 text-sm text-muted-foreground",children:d("Pick a function and an identity, then run it to see the access outcome.")}),a(Be,{functions:e,prefill:r,runAsIdentity:t})]})]})}),i&&a("section",{className:"flex flex-col gap-2",children:a(Je,{})})]})};export{xt as PermissionsPanel};
1
+ import{useState as b,useRef as oe,useEffect as ie}from"react";import{c as xe,d as ge,b as be,a as fe,C as me}from"../packem_shared/card-By2O8ULa.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{c as te}from"react/compiler-runtime";import{E as ye}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{L as ve}from"../packem_shared/live-status-D1GasNsH.mjs";import{B as Q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as j}from"../packem_shared/button-q0UYSmrn.mjs";import{E as pe}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Ne,a as ke,b as ne,c as ae,d as Ce,e as se}from"../packem_shared/table-D0SBiDu-.mjs";import{u as le}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{ADMIN_FUNCTIONS as ee}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as u,jsx as s}from"react/jsx-runtime";import{decodeWire as Se}from"@lunora/wire";import{ConfirmButton as we}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{ShardInput as Pe}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{I as Y}from"../packem_shared/input-CXhxesPC.mjs";import{L as _}from"../packem_shared/label-DKFzyHq6.mjs";import{T as Ie}from"../packem_shared/textarea--40GKAyz.mjs";import{u as ue}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{d as Re,c as Te,b as Ae,f as re,k as Ee}from"../packem_shared/internal-BXEjuLPN.mjs";const ce=["read","insert","update","delete"],_e=(t,e)=>({delete:t("Delete"),insert:t("Insert"),read:t("Read"),update:t("Update")})[e],Fe=t=>t.file===""?t.procedure:`${t.file}:${t.procedure}`,Oe=t=>{const e=new Set;for(const l of t?.advisories??[])if(l.name==="rls_uncovered_table"){const{table:o}=l.metadata;typeof o=="string"&&o!==""&&e.add(o)}return e},De=(t,e,l)=>{const o=new Map,r=n=>{const i=o.get(n);if(i!==void 0)return i;const m={cells:{delete:{},insert:{},read:{},update:{}},maskedColumns:new Set,table:n,uncovered:l.has(n)};return o.set(n,m),m};for(const n of t)r(n.table).cells[n.on]={path:Fe(n),procedure:n.procedure};for(const n of e)r(n.table).maskedColumns.add(n.column);for(const n of l)r(n);return[...o.values()].toSorted((n,i)=>n.table.localeCompare(i.table))},Le=t=>{const e=te(17);let l;e[0]!==t?(l=t===void 0?{}:t,e[0]=t,e[1]=l):l=e[1];const{onProbe:o}=l,r=G();let n,i;e[2]===Symbol.for("react.memo_cache_sentinel")?(n={},i={live:!0},e[2]=n,e[3]=i):(n=e[2],i=e[3]);const m=le(ee.rlsPolicies,n,i);let a;e[4]===Symbol.for("react.memo_cache_sentinel")?(a={},e[4]=a):a=e[4];const f=le(ee.maskPolicies,a);let c;e[5]===Symbol.for("react.memo_cache_sentinel")?(c={},e[5]=c):c=e[5];const d=le(ee.getAdvisories,c);let h;if(e[6]!==d.data||e[7]!==f.data||e[8]!==o||e[9]!==m||e[10]!==r){let g=null;m.data!==void 0&&(g=Array.isArray(m.data.policies)?m.data.policies:[]);const F=Array.isArray(f.data?.columns)?f.data.columns:[],H=d.data??null,{error:w,errorSource:C,liveError:P}=m,R=g===null?[]:De(g,F,Oe(H));let k;e[12]!==P?(k=s("div",{className:"flex items-center justify-end",children:s(ve,{message:P,prefix:"pm"})}),e[12]=P,e[13]=k):k=e[13];let T;e[14]!==w||e[15]!==C?(T=w!==null&&s(ye,{error:C,testId:"pm-error"}),e[14]=w,e[15]=C,e[16]=T):T=e[16],h=u("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-matrix",children:[k,T,g!==null&&R.length===0?s(pe,{description:r("Add a `definePolicy` and wire it through `.use(rls(...))` to populate this matrix."),testId:"pm-empty",title:r("No policy")}):u(Ne,{"data-testid":"pm-table",children:[s(ke,{children:u(ne,{children:[s(ae,{children:r("Table")}),ce.map(x=>s(ae,{children:_e(r,x)},x)),s(ae,{children:r("Masked columns")})]})}),s(Ce,{children:R.map(x=>u(ne,{"data-testid":`pm-row-${x.table}`,children:[s(se,{className:"font-mono text-xs",children:u("span",{className:"flex items-center gap-1.5",children:[x.table,x.uncovered&&s(Q,{"data-testid":`pm-uncovered-${x.table}`,title:r("Uncovered — reachable without a policy"),variant:"destructive",children:r("Uncovered — reachable without a policy")})]})}),ce.map(I=>{const v=x.cells[I];return s(se,{"data-testid":`pm-cell-${x.table}-${I}`,children:v.procedure===void 0?s("span",{className:"text-xs text-muted-foreground",children:r("No policy")}):u("span",{className:"flex flex-col gap-1",children:[s(Q,{variant:"secondary",children:r("Covered by {procedure}",{procedure:v.procedure})}),o!==void 0&&s(j,{className:"h-auto justify-start p-0 text-[11px]","data-testid":`pm-probe-${x.table}-${I}`,onClick:()=>{o(x.table,I,v.path??"")},size:"xs",type:"button",variant:"ghost",children:r("Probe this")})]})},I)}),s(se,{children:x.maskedColumns.size===0?s("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):s("span",{className:"flex flex-wrap gap-1",children:[...x.maskedColumns].map($e)})})]},x.table))})]})]}),e[6]=d.data,e[7]=f.data,e[8]=o,e[9]=m,e[10]=r,e[11]=h}else h=e[11];return h};function $e(t){return s(Q,{variant:"outline",children:t},t)}const Ue=Te(ee.runAs),We=new Set(["FORBIDDEN","RLS_REQUIRED","UNAUTHORIZED"]),Me=t=>{const e=t?.code;return typeof e=="string"?e:void 0},ze=()=>{const t=ue();return async({args:e,functionPath:l,shardKey:o="",userId:r})=>{if(r.trim()==="")return{kind:"invalid",message:"No identity to probe: enter the userId whose access you want to test."};const n=Ue;try{return{kind:"allowed",value:await t.query(n,{args:e,functionPath:l,userId:r},Re(o))}}catch(i){const m=i instanceof Error?i.message:String(i),a=Me(i);return a!==void 0&&We.has(a)?{kind:"denied",message:m}:{kind:"errored",message:m}}}},qe=t=>t===void 0?"undefined":JSON.stringify(t,Ee,2),Be=t=>{const e=te(43),{outcome:l}=t,o=G();if(l.kind==="allowed"){let a;e[0]!==o?(a=o("Allowed"),e[0]=o,e[1]=a):a=e[1];let f;e[2]!==a?(f=s(Q,{variant:"secondary",children:a}),e[2]=a,e[3]=f):f=e[3];let c;e[4]!==l.value?(c=qe(l.value),e[4]=l.value,e[5]=c):c=e[5];let d;e[6]!==c?(d=s("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-result",children:c}),e[6]=c,e[7]=d):d=e[7];let h;return e[8]!==f||e[9]!==d?(h=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-allowed",children:[f,d]}),e[8]=f,e[9]=d,e[10]=h):h=e[10],h}if(l.kind==="denied"){let a;e[11]!==o?(a=o("Denied"),e[11]=o,e[12]=a):a=e[12];let f;e[13]!==a?(f=s(Q,{variant:"destructive",children:a}),e[13]=a,e[14]=f):f=e[14];let c;e[15]!==l.message?(c=s("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs text-destructive","data-testid":"pp-denied",role:"alert",children:l.message}),e[15]=l.message,e[16]=c):c=e[16];let d;return e[17]!==f||e[18]!==c?(d=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-denied",children:[f,c]}),e[17]=f,e[18]=c,e[19]=d):d=e[19],d}if(l.kind==="errored"){let a;e[20]!==o?(a=o("Errored"),e[20]=o,e[21]=a):a=e[21];let f;e[22]!==a?(f=s(Q,{variant:"outline",children:a}),e[22]=a,e[23]=f):f=e[23];let c;e[24]!==o?(c=o("The call failed for a reason that is not an access verdict, so it says nothing about the policy."),e[24]=o,e[25]=c):c=e[25];let d;e[26]!==c?(d=s("p",{className:"text-sm text-muted-foreground",children:c}),e[26]=c,e[27]=d):d=e[27];let h;e[28]!==l.message?(h=s("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":"pp-errored",role:"alert",children:l.message}),e[28]=l.message,e[29]=h):h=e[29];let g;return e[30]!==f||e[31]!==d||e[32]!==h?(g=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-errored",children:[f,d,h]}),e[30]=f,e[31]=d,e[32]=h,e[33]=g):g=e[33],g}let r;e[34]!==o?(r=o("Not run"),e[34]=o,e[35]=r):r=e[35];let n;e[36]!==r?(n=s(Q,{variant:"outline",children:r}),e[36]=r,e[37]=n):n=e[37];let i;e[38]!==l.message?(i=s("p",{className:"text-sm text-muted-foreground","data-testid":"pp-invalid",role:"status",children:l.message}),e[38]=l.message,e[39]=i):i=e[39];let m;return e[40]!==n||e[41]!==i?(m=u("div",{className:"flex flex-col gap-2","data-testid":"pp-outcome-invalid",children:[n,i]}),e[40]=n,e[41]=i,e[42]=m):m=e[42],m},je=t=>{const e=te(17),{disabled:l,executesWrites:o,functionPath:r,onRun:n,running:i,userId:m}=t,a=G();let f;e[0]!==i||e[1]!==a?(f=a(i?"Probing…":"Run probe"),e[0]=i,e[1]=a,e[2]=f):f=e[2];const c=f;let d;e[3]!==l||e[4]!==o||e[5]!==r||e[6]!==c||e[7]!==n||e[8]!==a||e[9]!==m?(d=o?s(we,{confirmLabel:a("This will execute `{functionPath}` as user `{userId}`.",{functionPath:r,userId:m}),disabled:l,onConfirm:n,testId:"pp-run",children:c}):s(j,{"data-testid":"pp-run",disabled:l,onClick:n,type:"button",children:c}),e[3]=l,e[4]=o,e[5]=r,e[6]=c,e[7]=n,e[8]=a,e[9]=m,e[10]=d):d=e[10];let h;e[11]!==a||e[12]!==m?(h=m!==""&&s(Q,{"data-testid":"pp-as-badge",variant:"secondary",children:a("as {userId}",{userId:m})}),e[11]=a,e[12]=m,e[13]=h):h=e[13];let g;return e[14]!==d||e[15]!==h?(g=u("div",{className:"flex items-center gap-2",children:[d,h]}),e[14]=d,e[15]=h,e[16]=g):g=e[16],g},Qe=({functions:t,prefill:e,runAsIdentity:l=!1}={})=>{const o=ue(),r=G(),n=ze(),[i,m]=b(null),[a,f]=b(null),c=t??i??[],[d,h]=b(""),[g,F]=b("{}"),[H,w]=b(""),[C,P]=b(""),[R,k]=b(!1),[T,x]=b(null),[I,v]=b(null),[A,O]=b(!1),E=oe(-1),S=oe(0);ie(()=>{if(t!==void 0)return;let p=!1;return o.listFunctions().then(N=>(p||m(N),N)).catch(N=>{p||f(Ae(N))}),()=>{p=!0}},[o,t]),ie(()=>{if(e===void 0||E.current===e.nonce)return;E.current=e.nonce,S.current+=1;const p=e.functionPath;queueMicrotask(()=>{h(p),x(null)})},[e]);const J=A?c:c.filter(p=>p.kind==="query"||p.path===d),y=d===""?J[0]?.path??"":d,D=c.find(p=>p.path===y),K=y!==""&&D?.kind!=="query",L=async()=>{if(y==="")return;let p;try{p=g.trim()===""?{}:Se(JSON.parse(g))}catch(B){v(r("Invalid JSON args: {message}",{message:B.message})),x(null);return}S.current+=1;const N=S.current;v(null),k(!0);try{const B=await n({args:p,functionPath:y,shardKey:H.trim(),userId:C.trim()});N===S.current&&x(B)}finally{k(!1)}},$=()=>{re(L())},U=p=>{h(p.target.value)},W=p=>{F(p.target.value)},M=p=>{P(p.target.value)},z=p=>{O(p.target.checked),!p.target.checked&&K&&h("")},q=!l||R||y==="";return u("div",{className:"flex flex-col gap-3","data-testid":"lunora-permissions-playground",children:[a!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pp-discover-error",role:"alert",children:a}),!l&&s(pe,{description:r("Dev only: runs the selected function as this user over the admin gate so you can test auth and RLS."),testId:"pp-gate",title:r("Set `runAsIdentity` to forge an identity and probe access.")}),u("div",{className:"flex flex-col gap-3 rounded-md border border-border p-3",children:[u("div",{className:"flex flex-col gap-1.5",children:[s(_,{htmlFor:"pp-function",children:r("Function")}),s("select",{"aria-label":r("Function"),className:"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-xs outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50","data-testid":"pp-function",id:"pp-function",onChange:U,value:y,children:J.map(p=>u("option",{value:p.path,children:[p.path," (",p.kind,")"]},p.path))}),u(_,{className:"flex items-center gap-1.5 text-xs font-normal",htmlFor:"pp-include-writes",children:[s("input",{checked:A,className:"size-4 accent-primary","data-testid":"pp-include-writes",id:"pp-include-writes",onChange:z,type:"checkbox"}),r("Include mutations and actions")]})]}),u("div",{className:"flex flex-col gap-1.5",children:[s(_,{htmlFor:"pp-args",children:r("Arguments")}),s(Ie,{"aria-label":r("Arguments"),className:"font-mono text-xs","data-testid":"pp-args",id:"pp-args",onChange:W,value:g})]}),s(Pe,{onChange:w,testId:"pp-shard",value:H}),u("div",{className:"flex flex-col gap-1.5",children:[s(_,{htmlFor:"pp-user",children:r("Run as (userId)")}),s(Y,{"aria-label":r("Identity (userId) to run as"),className:"font-mono text-xs","data-testid":"pp-user",id:"pp-user",onChange:M,placeholder:r("Required — the identity to probe as"),value:C})]}),s(je,{disabled:q,executesWrites:K,functionPath:y,onRun:$,running:R,userId:C.trim()})]}),I!==null&&s("p",{className:"text-sm text-destructive","data-testid":"pp-args-error",role:"alert",children:I}),T!==null&&s(Be,{outcome:T})]})},He="/__lunora/policy-scaffold",Je={"already-wired":"That procedure already has an rls(...) policy wired in.","file-exists":"A policy file with that name already exists — pick another name or edit it by hand.","invalid-identifier":"Name, table, and policy-set must be plain identifiers (letters, digits, _ or $).","unknown-procedure":"No exported procedure was found at that file path.","unsupported-procedure-shape":"That procedure uses the bare query({…}) form — convert it to the builder form (c.use(…).query(…)) before wiring RLS."},Ke=async t=>{const e=await fetch(He,{body:JSON.stringify(t),headers:{"Content-Type":"application/json"},method:"POST"}),l=await e.json();if(l.needsManualEdit===!0)return{kind:"needs-manual-edit",message:l.message??"This change must be made by hand."};if(e.ok)return{diagnostics:l.diagnostics??[],kind:"ok",label:l.fileName??l.exportName??""};const o=l.error;return{kind:"error",message:o===void 0?`policy scaffold failed (${String(e.status)})`:Je[o]??o}},de={exportName:"",filePath:"",policyName:"",policies:"",tableName:""},Ve=()=>{const t=te(69),e=G(),[l,o]=b(null),[r,n]=b(!1),[i,m]=b(null),[a,f]=b(de);let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=X=>{const V=X.target.name,{value:Z}=X.target;f(he=>({...he,[V]:Z}))},t[0]=c):c=t[0];const d=c;let h;t[1]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(null),f(de)},t[1]=h):h=t[1];const g=h;let F;t[2]===Symbol.for("react.memo_cache_sentinel")?(F=async X=>{n(!0),m(null);try{const V=await Ke(X);m(V),V.kind==="ok"&&g()}catch(V){const Z=V;m({kind:"error",message:Z instanceof Error?Z.message:String(Z)})}n(!1)},t[2]=F):F=t[2];const H=F;let w;t[3]!==a.policyName||t[4]!==a.tableName?(w=()=>{re(H({kind:"scaffoldPolicy",name:a.policyName.trim(),table:a.tableName.trim()}))},t[3]=a.policyName,t[4]=a.tableName,t[5]=w):w=t[5];const C=w;let P;t[6]!==a.exportName||t[7]!==a.filePath||t[8]!==a.policies?(P=()=>{re(H({exportName:a.exportName.trim(),filePath:a.filePath.trim(),kind:"wireRls",policies:a.policies.trim()}))},t[6]=a.exportName,t[7]=a.filePath,t[8]=a.policies,t[9]=P):P=t[9];const R=P;let k;t[10]===Symbol.for("react.memo_cache_sentinel")?(k=()=>{m(null),o("scaffold")},t[10]=k):k=t[10];const T=k;let x;t[11]===Symbol.for("react.memo_cache_sentinel")?(x=()=>{m(null),o("wire")},t[11]=x):x=t[11];const I=x;let v;t[12]!==e?(v=e("Scaffold access rules"),t[12]=e,t[13]=v):v=t[13];let A;t[14]!==v?(A=s(xe,{children:v}),t[14]=v,t[15]=A):A=t[15];let O;t[16]!==e?(O=e("Writes a new deny-by-default policy file under lunora/, or wires one into a procedure, then reruns codegen. Local dev only."),t[16]=e,t[17]=O):O=t[17];let E;t[18]!==O?(E=s(ge,{children:O}),t[18]=O,t[19]=E):E=t[19];let S;t[20]!==E||t[21]!==A?(S=u(be,{children:[A,E]}),t[20]=E,t[21]=A,t[22]=S):S=t[22];const J=l==="scaffold"?"default":"outline";let y;t[23]!==e?(y=e("New policy file"),t[23]=e,t[24]=y):y=t[24];let D;t[25]!==J||t[26]!==y?(D=s(j,{"data-testid":"policy-scaffolder-new",onClick:T,size:"xs",type:"button",variant:J,children:y}),t[25]=J,t[26]=y,t[27]=D):D=t[27];const K=l==="wire"?"default":"outline";let L;t[28]!==e?(L=e("Wire into a procedure"),t[28]=e,t[29]=L):L=t[29];let $;t[30]!==K||t[31]!==L?($=s(j,{"data-testid":"policy-scaffolder-wire",onClick:I,size:"xs",type:"button",variant:K,children:L}),t[30]=K,t[31]=L,t[32]=$):$=t[32];let U;t[33]!==D||t[34]!==$?(U=u("div",{className:"flex flex-wrap gap-2",children:[D,$]}),t[33]=D,t[34]=$,t[35]=U):U=t[35];let W;t[36]!==r||t[37]!==a.policyName||t[38]!==a.tableName||t[39]!==l||t[40]!==C||t[41]!==e?(W=l==="scaffold"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-new-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-name",children:e("Policy name")}),s(Y,{"data-testid":"policy-scaffolder-name",id:"policy-scaffolder-name",name:"policyName",onChange:d,value:a.policyName})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-table",children:e("Table name")}),s(Y,{"data-testid":"policy-scaffolder-table",id:"policy-scaffolder-table",name:"tableName",onChange:d,value:a.tableName})]}),s(j,{"data-testid":"policy-scaffolder-create",disabled:r||a.policyName.trim()===""||a.tableName.trim()==="",onClick:C,size:"xs",type:"button",children:e(r?"Creating…":"Create policy file")}),s(j,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[36]=r,t[37]=a.policyName,t[38]=a.tableName,t[39]=l,t[40]=C,t[41]=e,t[42]=W):W=t[42];let M;t[43]!==r||t[44]!==a.exportName||t[45]!==a.filePath||t[46]!==a.policies||t[47]!==l||t[48]!==R||t[49]!==e?(M=l==="wire"&&u("div",{className:"mt-3 flex flex-wrap items-end gap-2","data-testid":"policy-scaffolder-wire-form",children:[u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-file",children:e("Procedure file path")}),s(Y,{"data-testid":"policy-scaffolder-file",id:"policy-scaffolder-file",name:"filePath",onChange:d,value:a.filePath})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-export",children:e("Exported procedure")}),s(Y,{"data-testid":"policy-scaffolder-export",id:"policy-scaffolder-export",name:"exportName",onChange:d,value:a.exportName})]}),u("div",{className:"flex flex-col gap-1 text-xs",children:[s(_,{htmlFor:"policy-scaffolder-policies",children:e("Policy set identifier")}),s(Y,{"data-testid":"policy-scaffolder-policies",id:"policy-scaffolder-policies",name:"policies",onChange:d,value:a.policies})]}),s(j,{"data-testid":"policy-scaffolder-apply",disabled:r||a.filePath.trim()===""||a.exportName.trim()===""||a.policies.trim()==="",onClick:R,size:"xs",type:"button",children:e(r?"Wiring…":"Wire RLS")}),s(j,{onClick:g,size:"xs",type:"button",variant:"ghost",children:e("Cancel")})]}),t[43]=r,t[44]=a.exportName,t[45]=a.filePath,t[46]=a.policies,t[47]=l,t[48]=R,t[49]=e,t[50]=M):M=t[50];let z;t[51]!==i?(z=i?.kind==="error"&&s("p",{className:"mt-3 text-sm text-destructive","data-testid":"policy-scaffolder-error",role:"alert",children:i.message}),t[51]=i,t[52]=z):z=t[52];let q;t[53]!==i?.kind||t[54]!==e?(q=i?.kind==="needs-manual-edit"&&s("p",{className:"mt-3 text-sm text-amber-600 dark:text-amber-500","data-testid":"policy-scaffolder-manual",role:"alert",children:e("This change must be made by hand — the scaffolder only adds new, deny-by-default rules.")}),t[53]=i?.kind,t[54]=e,t[55]=q):q=t[55];let p;t[56]!==i||t[57]!==e?(p=i?.kind==="ok"&&u("div",{className:"mt-3 flex flex-col gap-1","data-testid":"policy-scaffolder-ok",children:[s("p",{className:"text-sm text-emerald-600 dark:text-emerald-500",children:e("Scaffolded {label} and reran codegen. Fill in the `when` predicates before relying on it.",{label:i.label})}),i.diagnostics.length>0&&s("ul",{className:"flex flex-col gap-0.5","data-testid":"policy-scaffolder-diagnostics",children:i.diagnostics.map(Ye)})]}),t[56]=i,t[57]=e,t[58]=p):p=t[58];let N;t[59]!==U||t[60]!==W||t[61]!==M||t[62]!==z||t[63]!==q||t[64]!==p?(N=u(fe,{children:[U,W,M,z,q,p]}),t[59]=U,t[60]=W,t[61]=M,t[62]=z,t[63]=q,t[64]=p,t[65]=N):N=t[65];let B;return t[66]!==S||t[67]!==N?(B=u(me,{"data-testid":"policy-scaffolder",size:"sm",children:[S,N]}),t[66]=S,t[67]=N,t[68]=B):B=t[68],B};function Ye(t){return s("li",{className:"font-mono text-[11px] text-destructive",children:t},t)}const bt=({functions:t,runAsIdentity:e=!1,schemaEditable:l=!1}={})=>{const o=G(),[r,n]=b(void 0),i=(m,a,f)=>{f!==""&&n(c=>({functionPath:f,nonce:(c?.nonce??0)+1}))};return u("div",{className:"flex flex-col gap-8","data-testid":"lunora-permissions",children:[u("section",{className:"flex flex-col gap-3",children:[s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Permissions")})}),s(Le,{onProbe:i})]}),s("section",{className:"flex flex-col gap-3",children:u(me,{className:"gap-0 py-0",children:[s("header",{className:"border-b border-border px-4 py-3",children:s("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:o("Probe")})}),u(fe,{className:"px-4 py-4",children:[s("p",{className:"mb-3 text-sm text-muted-foreground",children:o("Pick a function and an identity, then run it to see the access outcome.")}),s(Qe,{functions:t,prefill:r,runAsIdentity:e})]})]})}),l&&s("section",{className:"flex flex-col gap-2",children:s(Ve,{})})]})};export{bt as PermissionsPanel};
@@ -1 +1 @@
1
- import{c as W}from"react/compiler-runtime";import{useQueryClient as se,useQuery as ie,useMutation as re}from"@tanstack/react-query";import{useId as le}from"react";import{E as Z}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as ne}from"../packem_shared/button-q0UYSmrn.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as w,a as ae,b as te,d as de,T as ce,e as O}from"../packem_shared/table-D0SBiDu-.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{h as J}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as oe}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as i,jsxs as z}from"react/jsx-runtime";const ue=new Set(["cancelled","completed","expired"]),fe=r=>ue.has(r),me=r=>r.extendedDueAt??r.dueAt,ve=r=>!fe(r)&&r!=="ready",pe=(r,e)=>ve(r.status)&&e.getTime()>me(r).getTime(),ye=(r,e)=>pe({dueAt:new Date(r.dueAt),status:r.status,...r.extendedDueAt===void 0||r.extendedDueAt===null?{}:{extendedDueAt:new Date(r.extendedDueAt)}},new Date(e)),he=["studio","privacy-requests"],xe={cancelled:"outline",completed:"success",expired:"outline",failed:"destructive",grace:"secondary",processing:"warning",ready:"success",received:"info"},Ae=r=>J(r??void 0,"—"),ge=r=>{const e=W(55),{asOf:o,retrying:t,row:s,onRetry:q}=r,a=X();let d,c,D;e[0]!==o||e[1]!==s?(c=ye(s,o),d=te,D=oe(c&&"bg-destructive/5"),e[0]=o,e[1]=s,e[2]=d,e[3]=c,e[4]=D):(d=e[2],c=e[3],D=e[4]);const S=c?"true":"false";let u;e[5]!==s.id?(u=i(O,{className:"font-mono text-xs",children:s.id}),e[5]=s.id,e[6]=u):u=e[6];let f;e[7]!==s.type||e[8]!==a?(f=s.type==="export"?a("Export"):a("Erasure"),e[7]=s.type,e[8]=a,e[9]=f):f=e[9];let E;e[10]!==f?(E=i(O,{children:i(G,{variant:"secondary",children:f})}),e[10]=f,e[11]=E):E=e[11];let n;e[12]!==s.subjectId?(n=i(O,{className:"font-mono text-xs",children:s.subjectId}),e[12]=s.subjectId,e[13]=n):n=e[13];const N=xe[s.status];let b;e[14]!==s.status||e[15]!==N?(b=i(O,{children:i(G,{variant:N,children:s.status})}),e[14]=s.status,e[15]=N,e[16]=b):b=e[16];let R;e[17]!==s.receivedAt?(R=J(s.receivedAt),e[17]=s.receivedAt,e[18]=R):R=e[18];let P;e[19]!==R?(P=i(O,{children:R}),e[19]=R,e[20]=P):P=e[20];let m;e[21]!==s.dueAt?(m=J(s.dueAt),e[21]=s.dueAt,e[22]=m):m=e[22];let v;e[23]!==m?(v=i(O,{children:m}),e[23]=m,e[24]=v):v=e[24];let p;e[25]!==s.extendedDueAt?(p=Ae(s.extendedDueAt),e[25]=s.extendedDueAt,e[26]=p):p=e[26];let y;e[27]!==p?(y=i(O,{children:p}),e[27]=p,e[28]=y):y=e[28];let h;e[29]!==c||e[30]!==a?(h=c&&i(G,{"data-testid":"privacy-overdue",variant:"destructive",children:a("Overdue")}),e[29]=c,e[30]=a,e[31]=h):h=e[31];let x;e[32]!==h?(x=i(O,{children:h}),e[32]=h,e[33]=x):x=e[33];let A;e[34]!==q||e[35]!==t||e[36]!==s.id||e[37]!==s.status||e[38]!==a?(A=s.status==="failed"&&i(ne,{disabled:t,onClick:()=>{q(s.id)},size:"xs",variant:"outline",children:a("Retry")}),e[34]=q,e[35]=t,e[36]=s.id,e[37]=s.status,e[38]=a,e[39]=A):A=e[39];let g;e[40]!==A?(g=i(O,{children:A}),e[40]=A,e[41]=g):g=e[41];let I;return e[42]!==d||e[43]!==D||e[44]!==P||e[45]!==v||e[46]!==y||e[47]!==x||e[48]!==g||e[49]!==S||e[50]!==u||e[51]!==E||e[52]!==n||e[53]!==b?(I=z(d,{className:D,"data-overdue":S,"data-testid":"privacy-request-row",children:[u,E,n,b,P,v,y,x,g]}),e[42]=d,e[43]=D,e[44]=P,e[45]=v,e[46]=y,e[47]=x,e[48]=g,e[49]=S,e[50]=u,e[51]=E,e[52]=n,e[53]=b,e[54]=I):I=e[54],I},Te=r=>{const e=W(95),{source:o}=r,t=X(),s=se(),q=le();let a;e[0]!==q?(a=[...he,q],e[0]=q,e[1]=a):a=e[1];const d=a;let c;e[2]!==o?(c=async()=>({asOf:Date.now(),requests:await o.listOpenPrivacyRequests()}),e[2]=o,e[3]=c):c=e[3];let D;e[4]!==d||e[5]!==c?(D={queryKey:d,refetchInterval:6e4,queryFn:c,staleTime:0},e[4]=d,e[5]=c,e[6]=D):D=e[6];const S=ie(D);let u;e[7]!==o?(u=l=>o.retryPrivacyRequest(l),e[7]=o,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==d?(f=async()=>{await s.invalidateQueries({queryKey:d})},e[9]=s,e[10]=d,e[11]=f):f=e[11];let E;e[12]!==u||e[13]!==f?(E={mutationFn:u,onSuccess:f},e[12]=u,e[13]=f,e[14]=E):E=e[14];const n=re(E);let N;e[15]!==n?(N=l=>{n.mutate(l)},e[15]=n,e[16]=N):N=e[16];const b=N;if(S.isPending){let l;e[17]!==t?(l=t("Loading privacy requests…"),e[17]=t,e[18]=l):l=e[18];let T;return e[19]!==l?(T=i("p",{className:"text-sm text-muted-foreground","data-testid":"privacy-requests-loading",role:"status",children:l}),e[19]=l,e[20]=T):T=e[20],T}if(S.isError){let l;return e[21]!==S.error?(l=i(Z,{error:S.error,testId:"privacy-requests-error"}),e[21]=S.error,e[22]=l):l=e[22],l}const{asOf:R,requests:P}=S.data;if(P.length===0){let l;e[23]!==t?(l=t("No open privacy requests."),e[23]=t,e[24]=l):l=e[24];let T;return e[25]!==l?(T=i(ee,{testId:"privacy-requests-empty",title:l}),e[25]=l,e[26]=T):T=e[26],T}let m;e[27]!==n.error||e[28]!==n.isError?(m=n.isError&&i(Z,{error:n.error,testId:"privacy-retry-error"}),e[27]=n.error,e[28]=n.isError,e[29]=m):m=e[29];let v;e[30]!==t?(v=t("ID"),e[30]=t,e[31]=v):v=e[31];let p;e[32]!==v?(p=i(w,{children:v}),e[32]=v,e[33]=p):p=e[33];let y;e[34]!==t?(y=t("Type"),e[34]=t,e[35]=y):y=e[35];let h;e[36]!==y?(h=i(w,{children:y}),e[36]=y,e[37]=h):h=e[37];let x;e[38]!==t?(x=t("Subject"),e[38]=t,e[39]=x):x=e[39];let A;e[40]!==x?(A=i(w,{children:x}),e[40]=x,e[41]=A):A=e[41];let g;e[42]!==t?(g=t("Status"),e[42]=t,e[43]=g):g=e[43];let I;e[44]!==g?(I=i(w,{children:g}),e[44]=g,e[45]=I):I=e[45];let j;e[46]!==t?(j=t("Received"),e[46]=t,e[47]=j):j=e[47];let B;e[48]!==j?(B=i(w,{children:j}),e[48]=j,e[49]=B):B=e[49];let C;e[50]!==t?(C=t("Due"),e[50]=t,e[51]=C):C=e[51];let Q;e[52]!==C?(Q=i(w,{children:C}),e[52]=C,e[53]=Q):Q=e[53];let U;e[54]!==t?(U=t("Extended due"),e[54]=t,e[55]=U):U=e[55];let V;e[56]!==U?(V=i(w,{children:U}),e[56]=U,e[57]=V):V=e[57];let _;e[58]!==t?(_=t("Overdue"),e[58]=t,e[59]=_):_=e[59];let $;e[60]!==_?($=i(w,{children:_}),e[60]=_,e[61]=$):$=e[61];let F;e[62]!==t?(F=t("Actions"),e[62]=t,e[63]=F):F=e[63];let H;e[64]!==F?(H=i(w,{children:F}),e[64]=F,e[65]=H):H=e[65];let K;e[66]!==p||e[67]!==h||e[68]!==A||e[69]!==I||e[70]!==B||e[71]!==Q||e[72]!==V||e[73]!==$||e[74]!==H?(K=i(ae,{children:z(te,{children:[p,h,A,I,B,Q,V,$,H]})}),e[66]=p,e[67]=h,e[68]=A,e[69]=I,e[70]=B,e[71]=Q,e[72]=V,e[73]=$,e[74]=H,e[75]=K):K=e[75];let L;if(e[76]!==R||e[77]!==b||e[78]!==P||e[79]!==n.isPending||e[80]!==n.variables){let l;e[82]!==R||e[83]!==b||e[84]!==n.isPending||e[85]!==n.variables?(l=T=>i(ge,{asOf:R,onRetry:b,retrying:n.isPending&&n.variables===T.id,row:T},T.id),e[82]=R,e[83]=b,e[84]=n.isPending,e[85]=n.variables,e[86]=l):l=e[86],L=P.map(l),e[76]=R,e[77]=b,e[78]=P,e[79]=n.isPending,e[80]=n.variables,e[81]=L}else L=e[81];let M;e[87]!==L?(M=i(de,{children:L}),e[87]=L,e[88]=M):M=e[88];let Y;e[89]!==K||e[90]!==M?(Y=z(ce,{children:[K,M]}),e[89]=K,e[90]=M,e[91]=Y):Y=e[91];let k;return e[92]!==Y||e[93]!==m?(k=z("div",{className:"flex flex-col gap-3",children:[m,Y]}),e[92]=Y,e[93]=m,e[94]=k):k=e[94],k},Be=r=>{const e=W(11);let o;e[0]!==r?(o=r===void 0?{}:r,e[0]=r,e[1]=o):o=e[1];const{source:t}=o,s=X();if(t===void 0){let a;e[2]!==s?(a=s("Pass privacyRequests to the Studio to list and retry data-subject requests."),e[2]=s,e[3]=a):a=e[3];let d;e[4]!==s?(d=s("Privacy requests not configured"),e[4]=s,e[5]=d):d=e[5];let c;return e[6]!==a||e[7]!==d?(c=i(ee,{description:a,testId:"privacy-requests-not-configured",title:d}),e[6]=a,e[7]=d,e[8]=c):c=e[8],c}let q;return e[9]!==t?(q=i(Te,{source:t}),e[9]=t,e[10]=q):q=e[10],q};export{Be as PrivacyRequestsPanel};
1
+ import{c as W}from"react/compiler-runtime";import{useQueryClient as se,useQuery as ie,useMutation as re}from"@tanstack/react-query";import{useId as le}from"react";import{E as Z}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as ne}from"../packem_shared/button-q0UYSmrn.mjs";import{E as ee}from"../packem_shared/empty-state-D7jEML_T.mjs";import{c as w,a as ae,b as te,d as de,T as ce,e as O}from"../packem_shared/table-D0SBiDu-.mjs";import{useT as X}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{h as J}from"../packem_shared/internal-BXEjuLPN.mjs";import{c as oe}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as i,jsxs as z}from"react/jsx-runtime";const ue=new Set(["cancelled","completed","expired"]),fe=r=>ue.has(r),me=r=>r.extendedDueAt??r.dueAt,ve=r=>!fe(r)&&r!=="ready",pe=(r,e)=>ve(r.status)&&e.getTime()>me(r).getTime(),ye=(r,e)=>pe({dueAt:new Date(r.dueAt),status:r.status,...r.extendedDueAt===void 0||r.extendedDueAt===null?{}:{extendedDueAt:new Date(r.extendedDueAt)}},new Date(e)),he=["studio","privacy-requests"],xe={cancelled:"outline",completed:"success",expired:"outline",failed:"destructive",grace:"secondary",processing:"warning",ready:"success",received:"info"},Ae=r=>J(r??void 0,"—"),ge=r=>{const e=W(55),{asOf:o,retrying:t,row:s,onRetry:q}=r,a=X();let d,c,D;e[0]!==o||e[1]!==s?(c=ye(s,o),d=te,D=oe(c&&"bg-destructive/5"),e[0]=o,e[1]=s,e[2]=d,e[3]=c,e[4]=D):(d=e[2],c=e[3],D=e[4]);const S=c?"true":"false";let u;e[5]!==s.id?(u=i(O,{className:"font-mono text-xs",children:s.id}),e[5]=s.id,e[6]=u):u=e[6];let f;e[7]!==s.type||e[8]!==a?(f=s.type==="export"?a("Export"):a("Erasure"),e[7]=s.type,e[8]=a,e[9]=f):f=e[9];let E;e[10]!==f?(E=i(O,{children:i(G,{variant:"secondary",children:f})}),e[10]=f,e[11]=E):E=e[11];let n;e[12]!==s.subjectId?(n=i(O,{className:"font-mono text-xs",children:s.subjectId}),e[12]=s.subjectId,e[13]=n):n=e[13];const N=xe[s.status];let b;e[14]!==s.status||e[15]!==N?(b=i(O,{children:i(G,{variant:N,children:s.status})}),e[14]=s.status,e[15]=N,e[16]=b):b=e[16];let R;e[17]!==s.receivedAt?(R=J(s.receivedAt),e[17]=s.receivedAt,e[18]=R):R=e[18];let P;e[19]!==R?(P=i(O,{children:R}),e[19]=R,e[20]=P):P=e[20];let m;e[21]!==s.dueAt?(m=J(s.dueAt),e[21]=s.dueAt,e[22]=m):m=e[22];let v;e[23]!==m?(v=i(O,{children:m}),e[23]=m,e[24]=v):v=e[24];let p;e[25]!==s.extendedDueAt?(p=Ae(s.extendedDueAt),e[25]=s.extendedDueAt,e[26]=p):p=e[26];let y;e[27]!==p?(y=i(O,{children:p}),e[27]=p,e[28]=y):y=e[28];let h;e[29]!==c||e[30]!==a?(h=c&&i(G,{"data-testid":"privacy-overdue",variant:"destructive",children:a("Overdue")}),e[29]=c,e[30]=a,e[31]=h):h=e[31];let x;e[32]!==h?(x=i(O,{children:h}),e[32]=h,e[33]=x):x=e[33];let A;e[34]!==q||e[35]!==t||e[36]!==s.id||e[37]!==s.status||e[38]!==a?(A=s.status==="failed"&&i(ne,{disabled:t,onClick:()=>{q(s.id)},size:"xs",variant:"outline",children:a("Retry")}),e[34]=q,e[35]=t,e[36]=s.id,e[37]=s.status,e[38]=a,e[39]=A):A=e[39];let g;e[40]!==A?(g=i(O,{children:A}),e[40]=A,e[41]=g):g=e[41];let I;return e[42]!==d||e[43]!==D||e[44]!==P||e[45]!==v||e[46]!==y||e[47]!==x||e[48]!==g||e[49]!==S||e[50]!==u||e[51]!==E||e[52]!==n||e[53]!==b?(I=z(d,{className:D,"data-overdue":S,"data-testid":"privacy-request-row",children:[u,E,n,b,P,v,y,x,g]}),e[42]=d,e[43]=D,e[44]=P,e[45]=v,e[46]=y,e[47]=x,e[48]=g,e[49]=S,e[50]=u,e[51]=E,e[52]=n,e[53]=b,e[54]=I):I=e[54],I},Te=r=>{const e=W(95),{source:o}=r,t=X(),s=se(),q=le();let a;e[0]!==q?(a=[...he,q],e[0]=q,e[1]=a):a=e[1];const d=a;let c;e[2]!==o?(c=async()=>({asOf:Date.now(),requests:await o.listOpenPrivacyRequests()}),e[2]=o,e[3]=c):c=e[3];let D;e[4]!==d||e[5]!==c?(D={queryKey:d,refetchInterval:6e4,queryFn:c,staleTime:0},e[4]=d,e[5]=c,e[6]=D):D=e[6];const S=ie(D);let u;e[7]!==o?(u=l=>o.retryPrivacyRequest(l),e[7]=o,e[8]=u):u=e[8];let f;e[9]!==s||e[10]!==d?(f=async()=>{await s.invalidateQueries({queryKey:d})},e[9]=s,e[10]=d,e[11]=f):f=e[11];let E;e[12]!==u||e[13]!==f?(E={mutationFn:u,onSuccess:f},e[12]=u,e[13]=f,e[14]=E):E=e[14];const n=re(E);let N;e[15]!==n?(N=l=>{n.mutate(l)},e[15]=n,e[16]=N):N=e[16];const b=N;if(S.isPending){let l;e[17]!==t?(l=t("Loading privacy requests…"),e[17]=t,e[18]=l):l=e[18];let T;return e[19]!==l?(T=i("p",{className:"text-sm text-muted-foreground","data-testid":"privacy-requests-loading",role:"status",children:l}),e[19]=l,e[20]=T):T=e[20],T}if(S.isError){let l;return e[21]!==S.error?(l=i(Z,{error:S.error,testId:"privacy-requests-error"}),e[21]=S.error,e[22]=l):l=e[22],l}const{asOf:R,requests:P}=S.data;if(P.length===0){let l;e[23]!==t?(l=t("No open privacy requests."),e[23]=t,e[24]=l):l=e[24];let T;return e[25]!==l?(T=i(ee,{testId:"privacy-requests-empty",title:l}),e[25]=l,e[26]=T):T=e[26],T}let m;e[27]!==n.error||e[28]!==n.isError?(m=n.isError&&i(Z,{error:n.error,testId:"privacy-retry-error"}),e[27]=n.error,e[28]=n.isError,e[29]=m):m=e[29];let v;e[30]!==t?(v=t("ID"),e[30]=t,e[31]=v):v=e[31];let p;e[32]!==v?(p=i(w,{children:v}),e[32]=v,e[33]=p):p=e[33];let y;e[34]!==t?(y=t("Type"),e[34]=t,e[35]=y):y=e[35];let h;e[36]!==y?(h=i(w,{children:y}),e[36]=y,e[37]=h):h=e[37];let x;e[38]!==t?(x=t("Subject"),e[38]=t,e[39]=x):x=e[39];let A;e[40]!==x?(A=i(w,{children:x}),e[40]=x,e[41]=A):A=e[41];let g;e[42]!==t?(g=t("Status"),e[42]=t,e[43]=g):g=e[43];let I;e[44]!==g?(I=i(w,{children:g}),e[44]=g,e[45]=I):I=e[45];let j;e[46]!==t?(j=t("Received"),e[46]=t,e[47]=j):j=e[47];let B;e[48]!==j?(B=i(w,{children:j}),e[48]=j,e[49]=B):B=e[49];let C;e[50]!==t?(C=t("Due"),e[50]=t,e[51]=C):C=e[51];let Q;e[52]!==C?(Q=i(w,{children:C}),e[52]=C,e[53]=Q):Q=e[53];let U;e[54]!==t?(U=t("Extended due"),e[54]=t,e[55]=U):U=e[55];let V;e[56]!==U?(V=i(w,{children:U}),e[56]=U,e[57]=V):V=e[57];let _;e[58]!==t?(_=t("Overdue"),e[58]=t,e[59]=_):_=e[59];let $;e[60]!==_?($=i(w,{children:_}),e[60]=_,e[61]=$):$=e[61];let F;e[62]!==t?(F=t("Actions"),e[62]=t,e[63]=F):F=e[63];let H;e[64]!==F?(H=i(w,{children:F}),e[64]=F,e[65]=H):H=e[65];let K;e[66]!==p||e[67]!==h||e[68]!==A||e[69]!==I||e[70]!==B||e[71]!==Q||e[72]!==V||e[73]!==$||e[74]!==H?(K=i(ae,{children:z(te,{children:[p,h,A,I,B,Q,V,$,H]})}),e[66]=p,e[67]=h,e[68]=A,e[69]=I,e[70]=B,e[71]=Q,e[72]=V,e[73]=$,e[74]=H,e[75]=K):K=e[75];let L;if(e[76]!==R||e[77]!==b||e[78]!==P||e[79]!==n.isPending||e[80]!==n.variables){let l;e[82]!==R||e[83]!==b||e[84]!==n.isPending||e[85]!==n.variables?(l=T=>i(ge,{asOf:R,onRetry:b,retrying:n.isPending&&n.variables===T.id,row:T},T.id),e[82]=R,e[83]=b,e[84]=n.isPending,e[85]=n.variables,e[86]=l):l=e[86],L=P.map(l),e[76]=R,e[77]=b,e[78]=P,e[79]=n.isPending,e[80]=n.variables,e[81]=L}else L=e[81];let M;e[87]!==L?(M=i(de,{children:L}),e[87]=L,e[88]=M):M=e[88];let Y;e[89]!==K||e[90]!==M?(Y=z(ce,{children:[K,M]}),e[89]=K,e[90]=M,e[91]=Y):Y=e[91];let k;return e[92]!==Y||e[93]!==m?(k=z("div",{className:"flex flex-col gap-3",children:[m,Y]}),e[92]=Y,e[93]=m,e[94]=k):k=e[94],k},Be=r=>{const e=W(11);let o;e[0]!==r?(o=r===void 0?{}:r,e[0]=r,e[1]=o):o=e[1];const{source:t}=o,s=X();if(t===void 0){let a;e[2]!==s?(a=s("Pass privacyRequests to the Studio to list and retry data-subject requests."),e[2]=s,e[3]=a):a=e[3];let d;e[4]!==s?(d=s("Privacy requests not configured"),e[4]=s,e[5]=d):d=e[5];let c;return e[6]!==a||e[7]!==d?(c=i(ee,{description:a,testId:"privacy-requests-not-configured",title:d}),e[6]=a,e[7]=d,e[8]=c):c=e[8],c}let q;return e[9]!==t?(q=i(Te,{source:t}),e[9]=t,e[10]=q):q=e[10],q};export{Be as PrivacyRequestsPanel};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{useLunora as et}from"@lunora/react";import{useState as R,Fragment as tt}from"react";import{ConfirmButton as st}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{E as at}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{A as rt}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Ee}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Ce}from"../packem_shared/button-q0UYSmrn.mjs";import{C as Oe,a as ke}from"../packem_shared/card-By2O8ULa.mjs";import{E as ve}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as nt}from"../packem_shared/input-CXhxesPC.mjs";import{S as ot}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Fe,a as Ue,b as j,c as C,d as Je,e as _}from"../packem_shared/table-D0SBiDu-.mjs";import{T as lt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as De}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useAutoRefresh as ct}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{f as Se,b as ne,d as Te,c as we,h as it,k as dt}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsx as s,jsxs as b,Fragment as Pe}from"react/jsx-runtime";const ut=(a,e)=>{const t=new Set(a.map(r=>r.deadLetterQueue).filter(r=>typeof r=="string"&&r!=="")),c=a.filter(r=>(r.deadLetterQueue===void 0||r.deadLetterQueue==="")&&!t.has(r.name)),o=e.filter(r=>r.deadLettered).length;return{deadLetteredCount:o,queuesWithoutDlq:c,showReliabilityWarning:c.length>0||o>0}},_e="topic:",Qe=a=>{const e=[],t=new Map;for(const c of a)c.topic===void 0?e.push(c):t.set(c.topic,[...t.get(c.topic)??[],c]);return{plain:e,topics:t}},je=a=>`${_e}${a}`,mt=(a,e)=>a.startsWith(_e)?(e.get(a.slice(_e.length))??[]).map(t=>t.exportName):[a],pt=200,ft=we(W.sendQueueMessage),ht=async(a,e,t)=>{const o=(await Promise.allSettled(e.map(async n=>a.query(ft,n,Te(""))))).flatMap((n,l)=>n.status==="rejected"?[{exportName:e[l]?.exportName??"",message:ne(n.reason)}]:[]),[r]=o;return r===void 0?null:e.length===1?r.message:t("Not sent to {failed}",{failed:o.map(n=>`${n.exportName}: ${n.message}`).join("; ")})},gt=we(W.replayQueueMessage),xt=we(W.clearQueueMessages),$e=96,yt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},bt=a=>a.length>$e?`${a.slice(0,$e)}…`:a,Nt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",qt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),We=a=>{const e=U(17),{queue:t}=a,c=`queues-row-${t.exportName}`;let o;e[0]!==t.exportName?(o=s(_,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=o):o=e[1];let r;e[2]!==t.name?(r=s(_,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=r):r=e[3];let n;e[4]!==t.mode?(n=s(_,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=n):n=e[5];let l;e[6]!==t.binding?(l=s(_,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const u=t.deadLetterQueue??"—";let i;e[8]!==u?(i=s(_,{className:"font-mono text-xs text-muted-foreground",children:u}),e[8]=u,e[9]=i):i=e[9];let m;return e[10]!==c||e[11]!==o||e[12]!==r||e[13]!==n||e[14]!==l||e[15]!==i?(m=b(j,{"data-testid":c,children:[o,r,n,l,i]}),e[10]=c,e[11]=o,e[12]=r,e[13]=n,e[14]=l,e[15]=i,e[16]=m):m=e[16],m},St=a=>{const e=U(8),{loaded:t,queues:c}=a,o=G();let r;if(e[0]!==t||e[1]!==c||e[2]!==o){const{plain:n,topics:l}=Qe(c);let u;e[4]!==o?(u=o("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=o,e[5]=u):u=e[5];let i;e[6]!==u?(i=s("p",{className:"text-sm text-muted-foreground",children:u}),e[6]=u,e[7]=i):i=e[7],r=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[i,t&&c.length===0?s(ve,{description:o("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:o("No queues defined")}):s(Oe,{className:"overflow-hidden py-0",children:s(ke,{className:"px-0",children:b(Fe,{"data-testid":"queues-table",children:[s(Ue,{children:b(j,{children:[s(C,{children:o("Export")}),s(C,{children:o("Queue")}),s(C,{children:o("Mode")}),s(C,{children:o("Binding")}),s(C,{children:o("Dead-letter")})]})}),b(Je,{children:[n.map(Ct),[...l].map(m=>{const[h,g]=m;return b(tt,{children:[s(j,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(_,{className:"text-xs font-medium",colSpan:5,children:o("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(vt)]},h)})]})]})})})]}),e[0]=t,e[1]=c,e[2]=o,e[3]=r}else r=e[3];return r},Et=a=>{const e=U(67),{message:t,onReplay:c,replayingId:o}=a,r=G();let n,l,u,i,m,h,g,d,p,y;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==r){const z=yt(t.body);l=j,h=`queues-message-${t.id}`;const B=t.exportName??t.queue;e[19]!==B?(g=s(_,{className:"font-mono text-xs",children:B}),e[19]=B,e[20]=g):g=e[20],e[21]!==t.messageId?(d=s(_,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=d):d=e[22],e[23]!==t.attempts?(p=s(_,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const J=`queues-outcome-${t.id}`;let w;e[25]!==t.outcome?(w=Nt(t.outcome),e[25]=t.outcome,e[26]=w):w=e[26];let M;e[27]!==t.outcome||e[28]!==J||e[29]!==w?(M=s(Ee,{"data-testid":J,variant:w,children:t.outcome}),e[27]=t.outcome,e[28]=J,e[29]=w,e[30]=M):M=e[30];let Q;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==r?(Q=t.deadLettered&&s(Ee,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:r("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=r,e[34]=Q):Q=e[34],e[35]!==M||e[36]!==Q?(y=s(_,{children:b("span",{className:"inline-flex items-center gap-1",children:[M,Q]})}),e[35]=M,e[36]=Q,e[37]=y):y=e[37],n=_,u="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",i=z,m=bt(z),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=r,e[9]=n,e[10]=l,e[11]=u,e[12]=i,e[13]=m,e[14]=h,e[15]=g,e[16]=d,e[17]=p,e[18]=y}else n=e[9],l=e[10],u=e[11],i=e[12],m=e[13],h=e[14],g=e[15],d=e[16],p=e[17],y=e[18];let x;e[38]!==n||e[39]!==u||e[40]!==i||e[41]!==m?(x=s(n,{className:u,title:i,children:m}),e[38]=n,e[39]=u,e[40]=i,e[41]=m,e[42]=x):x=e[42];let N;e[43]!==t.capturedAt?(N=it(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let T;e[45]!==N?(T=s(_,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=T):T=e[46];const q=`queues-replay-${t.id}`,S=o!==null;let v;e[47]!==t.id||e[48]!==o||e[49]!==r?(v=o===t.id?r("Replaying…"):r("Replay"),e[47]=t.id,e[48]=o,e[49]=r,e[50]=v):v=e[50];let A;e[51]!==t.id||e[52]!==c||e[53]!==q||e[54]!==S||e[55]!==v?(A=s(_,{children:s(Ce,{"data-id":t.id,"data-testid":q,disabled:S,onClick:c,size:"xs",type:"button",variant:"outline",children:v})}),e[51]=t.id,e[52]=c,e[53]=q,e[54]=S,e[55]=v,e[56]=A):A=e[56];let I;return e[57]!==l||e[58]!==T||e[59]!==A||e[60]!==h||e[61]!==g||e[62]!==d||e[63]!==p||e[64]!==y||e[65]!==x?(I=b(l,{"data-testid":h,children:[g,d,p,y,x,T,A]}),e[57]=l,e[58]=T,e[59]=A,e[60]=h,e[61]=g,e[62]=d,e[63]=p,e[64]=y,e[65]=x,e[66]=I):I=e[66],I},Tt=a=>{const e=U(29),{hasError:t,messages:c,onClear:o,onReplay:r,replayingId:n}=a,l=G();let u;e[0]!==l?(u=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=u):u=e[1];let i;e[2]!==u?(i=s("p",{className:"text-sm text-muted-foreground",children:u}),e[2]=u,e[3]=i):i=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=c.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let d;e[8]!==o||e[9]!==m||e[10]!==h||e[11]!==g?(d=s("div",{className:"ml-auto",children:s(st,{confirmLabel:m,disabled:h,onConfirm:o,testId:"queues-clear",children:g})}),e[8]=o,e[9]=m,e[10]=h,e[11]=g,e[12]=d):d=e[12];let p;e[13]!==c.length||e[14]!==l?(p=c.length>0&&s(Ee,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:c.length})}),e[13]=c.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==i||e[17]!==d||e[18]!==p?(y=b("div",{className:"flex flex-wrap items-center gap-2",children:[i,d,p]}),e[16]=i,e[17]=d,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==c||e[22]!==r||e[23]!==n||e[24]!==l?(x=!t&&c.length===0?s(ve,{description:l("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:l("No consumed messages yet.")}):s(Oe,{className:"overflow-hidden py-0",children:s(ke,{className:"px-0",children:s(ot,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Fe,{"data-testid":"queues-messages-table",children:[s(Ue,{children:b(j,{children:[s(C,{children:l("Export")}),s(C,{children:l("Message")}),s(C,{children:l("Attempts")}),s(C,{children:l("Outcome")}),s(C,{children:l("Body")}),s(C,{children:l("Captured")}),s(C,{})]})}),s(Je,{children:c.map(T=>s(Et,{message:T,onReplay:r,replayingId:n},T.id))})]})})})}),e[20]=t,e[21]=c,e[22]=r,e[23]=n,e[24]=l,e[25]=x):x=e[25];let N;return e[26]!==y||e[27]!==x?(N=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=N):N=e[28],N},_t=a=>{const e=U(20),{batchMode:t,bodyText:c,delayText:o,onBatchModeChange:r,onBodyChange:n,onDelayChange:l,onSelectExport:u,onSend:i,queues:m,selectedExportName:h,sending:g}=a,d=G();let p;e[0]!==d?(p=d("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=d,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==c||e[6]!==o||e[7]!==r||e[8]!==n||e[9]!==l||e[10]!==u||e[11]!==i||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==d?(x=m.length===0?s(ve,{description:d("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:d("No queues to send to")}):b(Pe,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[b("select",{"aria-label":d("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:u,value:h,children:[m.map(wt),[...Qe(m).topics].map(T=>{const[q,S]=T;return s("option",{value:je(q),children:d("{topic} (topic → {count} subscriptions)",{count:S.length,topic:q})},q)})]}),s(nt,{"aria-label":d("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:d("Delay (s)"),type:"number",value:o}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:r,type:"checkbox"}),d("Send as batch (JSON array)")]}),s(Ce,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:i,type:"button",children:d(g?"Sending…":"Send message")})]}),s(lt,{"aria-label":d("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:n,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:c})]}),e[4]=t,e[5]=c,e[6]=o,e[7]=r,e[8]=n,e[9]=l,e[10]=u,e[11]=i,e[12]=m,e[13]=h,e[14]=g,e[15]=d,e[16]=x):x=e[16];let N;return e[17]!==y||e[18]!==x?(N=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=N):N=e[19],N},es=a=>{const e=U(55),{limit:t}=a,c=t??pt,o=et(),r=G(),[n,l]=R("declared"),[u,i]=R(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:d}=De(W.listQueues,m);let p;e[1]!==c?(p={limit:c},e[1]=c,e[2]=p):p=e[2];const{data:y,error:x,errorSource:N,poll:T,refetch:q}=De(W.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(Qt):[],v=y?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:I,showReliabilityWarning:z}=ut(S,v),[B,J]=R(""),[w,M]=R(""),[Q,Ge]=R(""),[P,ze]=R(!1),[oe,Ae]=R(!1),[le,Ie]=R(null),{topics:Me}=Qe(S),Le=[...S.map(At),...[...Me.keys()].map(It)],H=Le.includes(B)?B:Le[0]??"",Re=n==="messages"?x:g,He=n==="messages"?N:d,ce=Re??u,ie=Re===null?u:He;ct(T,n==="messages");const Ve=async()=>{i(null);const f=H;if(f==="")return;let E=null;const Ne=w.trim();if(Ne!=="")try{E=JSON.parse(Ne)}catch{i(r("Body must be valid JSON."));return}let qe;const Be=Q.trim();if(Be!==""){const L=Number(Be);if(!Number.isFinite(L)||L<0){i(r("Delay must be a non-negative number of seconds."));return}qe=L}if(P&&!Array.isArray(E)){i(r("Batch mode needs a JSON array body — each element is enqueued as one message."));return}Ae(!0);const Ze=mt(f,Me).map(L=>P?{batch:E,delaySeconds:qe,exportName:L}:{body:E,delaySeconds:qe,exportName:L});try{i(await ht(o,Ze,r)),q()}catch(L){i(ne(L))}Ae(!1)};let V;e[3]!==o||e[4]!==q?(V=async f=>{i(null),Ie(f);try{await o.query(gt,{id:f},Te("")),q()}catch(E){i(ne(E))}Ie(null)},e[3]=o,e[4]=q,e[5]=V):V=e[5];const de=V;let X;e[6]!==o||e[7]!==q?(X=async()=>{i(null);try{await o.query(xt,{},Te("")),q()}catch(f){i(ne(f))}},e[6]=o,e[7]=q,e[8]=X):X=e[8];const ue=X;let Y;e[9]===Symbol.for("react.memo_cache_sentinel")?(Y=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[9]=Y):Y=e[9];const Xe=Y;let K;e[10]===Symbol.for("react.memo_cache_sentinel")?(K=f=>{J(f.currentTarget.value)},e[10]=K):K=e[10];const me=K;let Z;e[11]===Symbol.for("react.memo_cache_sentinel")?(Z=f=>{M(f.currentTarget.value)},e[11]=Z):Z=e[11];const pe=Z;let ee;e[12]===Symbol.for("react.memo_cache_sentinel")?(ee=f=>{Ge(f.currentTarget.value)},e[12]=ee):ee=e[12];const fe=ee;let te;e[13]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{ze(f.currentTarget.checked)},e[13]=te):te=e[13];const he=te,ge=()=>{Se(Ve())};let se;e[14]!==de?(se=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Se(de(E))},e[14]=de,e[15]=se):se=e[15];const xe=se;let ae;e[16]!==ue?(ae=()=>{Se(ue())},e[16]=ue,e[17]=ae):ae=e[17];const ye=ae,Ye="flex flex-col gap-6",Ke="lunora-queues-panel";let D;e[18]!==r||e[19]!==n?(D=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(Ce,{"aria-selected":n===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Xe,role:"tab",size:"sm",type:"button",variant:n===f?"secondary":"ghost",children:qt(f,r)},f))}),e[18]=r,e[19]=n,e[20]=D):D=e[20];let $;e[21]!==ce||e[22]!==ie?($=ce!==null&&s(at,{error:ie,testId:"queues-error"}),e[21]=ce,e[22]=ie,e[23]=$):$=e[23];const be=z&&s(rt,{icon:s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[I.length>0&&b(Pe,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:I.map(Mt).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),A>0&&s("p",{className:I.length>0?"text-muted-foreground":"font-medium",children:A===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:A})})]})});let O;e[24]!==S||e[25]!==h||e[26]!==n?(O=n==="declared"&&s(St,{loaded:h!==void 0,queues:S}),e[24]=S,e[25]=h,e[26]=n,e[27]=O):O=e[27];let k;e[28]!==v||e[29]!==x||e[30]!==ye||e[31]!==xe||e[32]!==le||e[33]!==n?(k=n==="messages"&&s(Tt,{hasError:x!==null,messages:v,onClear:ye,onReplay:xe,replayingId:le}),e[28]=v,e[29]=x,e[30]=ye,e[31]=xe,e[32]=le,e[33]=n,e[34]=k):k=e[34];let F;e[35]!==P||e[36]!==w||e[37]!==Q||e[38]!==he||e[39]!==pe||e[40]!==fe||e[41]!==me||e[42]!==ge||e[43]!==S||e[44]!==H||e[45]!==oe||e[46]!==n?(F=n==="send"&&s(_t,{batchMode:P,bodyText:w,delayText:Q,onBatchModeChange:he,onBodyChange:pe,onDelayChange:fe,onSelectExport:me,onSend:ge,queues:S,selectedExportName:H,sending:oe}),e[35]=P,e[36]=w,e[37]=Q,e[38]=he,e[39]=pe,e[40]=fe,e[41]=me,e[42]=ge,e[43]=S,e[44]=H,e[45]=oe,e[46]=n,e[47]=F):F=e[47];let re;return e[48]!==D||e[49]!==$||e[50]!==be||e[51]!==O||e[52]!==k||e[53]!==F?(re=b("div",{className:Ye,"data-testid":Ke,children:[D,$,be,O,k,F]}),e[48]=D,e[49]=$,e[50]=be,e[51]=O,e[52]=k,e[53]=F,e[54]=re):re=e[54],re};function Ct(a){return s(We,{queue:a},a.exportName)}function vt(a){return s(We,{queue:a},a.exportName)}function wt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function Qt(a,e){return a.exportName.localeCompare(e.exportName)}function At(a){return a.exportName}function It(a){return je(a)}function Mt(a){return a.name}export{es as default};
1
+ import{c as B}from"react/compiler-runtime";import{useState as L,Fragment as Ze}from"react";import{ConfirmButton as et}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{E as tt}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{A as st}from"../packem_shared/alert-PB5W11MM.mjs";import{B as Ae}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as Le}from"../packem_shared/button-q0UYSmrn.mjs";import{C as We,a as Je}from"../packem_shared/card-By2O8ULa.mjs";import{E as Re}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as rt}from"../packem_shared/input-CXhxesPC.mjs";import{S as at}from"../packem_shared/scroll-area-CXCQH7VT.mjs";import{T as Pe,a as je,b as z,c as w,d as Ge,e as v}from"../packem_shared/table-D0SBiDu-.mjs";import{T as nt}from"../packem_shared/textarea--40GKAyz.mjs";import{u as Fe}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useAutoRefresh as ot}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{u as lt}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as G}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as H}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{c as De,b as ue,d as Ie,f as Qe,h as it,k as dt}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsx as s,jsxs as b,Fragment as ze}from"react/jsx-runtime";const ct=(a,e)=>{const t=new Set(a.map(n=>n.deadLetterQueue).filter(n=>typeof n=="string"&&n!=="")),i=a.filter(n=>(n.deadLetterQueue===void 0||n.deadLetterQueue==="")&&!t.has(n.name)),r=e.filter(n=>n.deadLettered).length;return{deadLetteredCount:r,queuesWithoutDlq:i,showReliabilityWarning:i.length>0||r>0}},Me="topic:",Be=a=>{const e=[],t=new Map;for(const i of a)i.topic===void 0?e.push(i):t.set(i.topic,[...t.get(i.topic)??[],i]);return{plain:e,topics:t}},He=a=>`${Me}${a}`,ut=(a,e)=>a.startsWith(Me)?(e.get(a.slice(Me.length))??[]).map(t=>t.exportName):[a],mt=200,pt=De(H.sendQueueMessage),ft=async(a,e,t)=>{const r=(await Promise.allSettled(e.map(async o=>a.query(pt,o,Ie(""))))).flatMap((o,l)=>o.status==="rejected"?[{exportName:e[l]?.exportName??"",message:ue(o.reason)}]:[]),[n]=r;return n===void 0?null:e.length===1?n.message:t("Not sent to {failed}",{failed:r.map(o=>`${o.exportName}: ${o.message}`).join("; ")})},ht=De(H.replayQueueMessage),gt=De(H.clearQueueMessages),Ue=96,xt=a=>{if(a===void 0)return"—";try{return JSON.stringify(a,dt)}catch{return"[unserializable]"}},yt=a=>a.length>Ue?`${a.slice(0,Ue)}…`:a,bt=a=>a==="error"?"destructive":a==="retry"?"outline":"secondary",Nt=(a,e)=>e(a==="messages"?"Messages":a==="send"?"Send":"Declared"),Ve=a=>{const e=B(17),{queue:t}=a,i=`queues-row-${t.exportName}`;let r;e[0]!==t.exportName?(r=s(v,{className:"font-mono text-xs",children:t.exportName}),e[0]=t.exportName,e[1]=r):r=e[1];let n;e[2]!==t.name?(n=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.name}),e[2]=t.name,e[3]=n):n=e[3];let o;e[4]!==t.mode?(o=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.mode}),e[4]=t.mode,e[5]=o):o=e[5];let l;e[6]!==t.binding?(l=s(v,{className:"font-mono text-xs text-muted-foreground",children:t.binding}),e[6]=t.binding,e[7]=l):l=e[7];const d=t.deadLetterQueue??"—";let c;e[8]!==d?(c=s(v,{className:"font-mono text-xs text-muted-foreground",children:d}),e[8]=d,e[9]=c):c=e[9];let m;return e[10]!==i||e[11]!==r||e[12]!==n||e[13]!==o||e[14]!==l||e[15]!==c?(m=b(z,{"data-testid":i,children:[r,n,o,l,c]}),e[10]=i,e[11]=r,e[12]=n,e[13]=o,e[14]=l,e[15]=c,e[16]=m):m=e[16],m},qt=a=>{const e=B(8),{loaded:t,queues:i}=a,r=G();let n;if(e[0]!==t||e[1]!==i||e[2]!==r){const{plain:o,topics:l}=Be(i);let d;e[4]!==r?(d=r("Queues are declared in code with defineQueue. Enqueue from a mutation or action with ctx.queues.<name>.send(...); push consumers process batches in the worker."),e[4]=r,e[5]=d):d=e[5];let c;e[6]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[6]=d,e[7]=c):c=e[7],n=b("div",{className:"flex flex-col gap-4","data-testid":"queues-declared",children:[c,t&&i.length===0?s(Re,{description:r("No defineQueue is declared in lunora/queues.ts in this deployment. Add one to offload async work to a Cloudflare Queue."),testId:"queues-empty",title:r("No queues defined")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:b(Pe,{"data-testid":"queues-table",children:[s(je,{children:b(z,{children:[s(w,{children:r("Export")}),s(w,{children:r("Queue")}),s(w,{children:r("Mode")}),s(w,{children:r("Binding")}),s(w,{children:r("Dead-letter")})]})}),b(Ge,{children:[o.map(vt),[...l].map(m=>{const[h,g]=m;return b(Ze,{children:[s(z,{className:"bg-muted/40","data-testid":`queues-topic-${h}`,children:s(v,{className:"text-xs font-medium",colSpan:5,children:r("Topic {topic} · {count} subscriptions",{count:g.length,topic:h})})}),g.map(wt)]},h)})]})]})})})]}),e[0]=t,e[1]=i,e[2]=r,e[3]=n}else n=e[3];return n},St=a=>{const e=B(67),{message:t,onReplay:i,replayingId:r}=a,n=G();let o,l,d,c,m,h,g,u,p,y;if(e[0]!==t.attempts||e[1]!==t.body||e[2]!==t.deadLettered||e[3]!==t.exportName||e[4]!==t.id||e[5]!==t.messageId||e[6]!==t.outcome||e[7]!==t.queue||e[8]!==n){const $=xt(t.body);l=z,h=`queues-message-${t.id}`;const O=t.exportName??t.queue;e[19]!==O?(g=s(v,{className:"font-mono text-xs",children:O}),e[19]=O,e[20]=g):g=e[20],e[21]!==t.messageId?(u=s(v,{className:"max-w-[16ch] truncate font-mono text-xs text-muted-foreground",title:t.messageId,children:t.messageId}),e[21]=t.messageId,e[22]=u):u=e[22],e[23]!==t.attempts?(p=s(v,{className:"font-mono text-xs tabular-nums",children:t.attempts}),e[23]=t.attempts,e[24]=p):p=e[24];const R=`queues-outcome-${t.id}`;let C;e[25]!==t.outcome?(C=bt(t.outcome),e[25]=t.outcome,e[26]=C):C=e[26];let I;e[27]!==t.outcome||e[28]!==R||e[29]!==C?(I=s(Ae,{"data-testid":R,variant:C,children:t.outcome}),e[27]=t.outcome,e[28]=R,e[29]=C,e[30]=I):I=e[30];let _;e[31]!==t.deadLettered||e[32]!==t.id||e[33]!==n?(_=t.deadLettered&&s(Ae,{"data-testid":`queues-dlq-${t.id}`,variant:"destructive",children:n("DLQ")}),e[31]=t.deadLettered,e[32]=t.id,e[33]=n,e[34]=_):_=e[34],e[35]!==I||e[36]!==_?(y=s(v,{children:b("span",{className:"inline-flex items-center gap-1",children:[I,_]})}),e[35]=I,e[36]=_,e[37]=y):y=e[37],o=v,d="max-w-[32ch] truncate font-mono text-xs text-muted-foreground",c=$,m=yt($),e[0]=t.attempts,e[1]=t.body,e[2]=t.deadLettered,e[3]=t.exportName,e[4]=t.id,e[5]=t.messageId,e[6]=t.outcome,e[7]=t.queue,e[8]=n,e[9]=o,e[10]=l,e[11]=d,e[12]=c,e[13]=m,e[14]=h,e[15]=g,e[16]=u,e[17]=p,e[18]=y}else o=e[9],l=e[10],d=e[11],c=e[12],m=e[13],h=e[14],g=e[15],u=e[16],p=e[17],y=e[18];let x;e[38]!==o||e[39]!==d||e[40]!==c||e[41]!==m?(x=s(o,{className:d,title:c,children:m}),e[38]=o,e[39]=d,e[40]=c,e[41]=m,e[42]=x):x=e[42];let N;e[43]!==t.capturedAt?(N=it(t.capturedAt,"—"),e[43]=t.capturedAt,e[44]=N):N=e[44];let T;e[45]!==N?(T=s(v,{className:"text-xs text-muted-foreground tabular-nums",children:N}),e[45]=N,e[46]=T):T=e[46];const q=`queues-replay-${t.id}`,S=r!==null;let Q;e[47]!==t.id||e[48]!==r||e[49]!==n?(Q=r===t.id?n("Replaying…"):n("Replay"),e[47]=t.id,e[48]=r,e[49]=n,e[50]=Q):Q=e[50];let A;e[51]!==t.id||e[52]!==i||e[53]!==q||e[54]!==S||e[55]!==Q?(A=s(v,{children:s(Le,{"data-id":t.id,"data-testid":q,disabled:S,onClick:i,size:"xs",type:"button",variant:"outline",children:Q})}),e[51]=t.id,e[52]=i,e[53]=q,e[54]=S,e[55]=Q,e[56]=A):A=e[56];let M;return e[57]!==l||e[58]!==T||e[59]!==A||e[60]!==h||e[61]!==g||e[62]!==u||e[63]!==p||e[64]!==y||e[65]!==x?(M=b(l,{"data-testid":h,children:[g,u,p,y,x,T,A]}),e[57]=l,e[58]=T,e[59]=A,e[60]=h,e[61]=g,e[62]=u,e[63]=p,e[64]=y,e[65]=x,e[66]=M):M=e[66],M},Et=a=>{const e=B(29),{hasError:t,messages:i,onClear:r,onReplay:n,replayingId:o}=a,l=G();let d;e[0]!==l?(d=l("Cloudflare Queues have no peek API, so this is what push consumers actually processed — not pending depth."),e[0]=l,e[1]=d):d=e[1];let c;e[2]!==d?(c=s("p",{className:"text-sm text-muted-foreground",children:d}),e[2]=d,e[3]=c):c=e[3];let m;e[4]!==l?(m=l("Clear the whole message log?"),e[4]=l,e[5]=m):m=e[5];const h=i.length===0;let g;e[6]!==l?(g=l("Clear log"),e[6]=l,e[7]=g):g=e[7];let u;e[8]!==r||e[9]!==m||e[10]!==h||e[11]!==g?(u=s("div",{className:"ml-auto",children:s(et,{confirmLabel:m,disabled:h,onConfirm:r,testId:"queues-clear",children:g})}),e[8]=r,e[9]=m,e[10]=h,e[11]=g,e[12]=u):u=e[12];let p;e[13]!==i.length||e[14]!==l?(p=i.length>0&&s(Ae,{"data-testid":"queues-count",variant:"secondary",children:l("{count} messages",{count:i.length})}),e[13]=i.length,e[14]=l,e[15]=p):p=e[15];let y;e[16]!==c||e[17]!==u||e[18]!==p?(y=b("div",{className:"flex flex-wrap items-center gap-2",children:[c,u,p]}),e[16]=c,e[17]=u,e[18]=p,e[19]=y):y=e[19];let x;e[20]!==t||e[21]!==i||e[22]!==n||e[23]!==o||e[24]!==l?(x=!t&&i.length===0?s(Re,{description:l("Consumed messages appear here once a push consumer processes a batch in dev. Send one from the Send tab to see it captured."),testId:"queues-messages-empty",title:l("No consumed messages yet.")}):s(We,{className:"overflow-hidden py-0",children:s(Je,{className:"px-0",children:s(at,{className:"max-h-[32rem]","data-testid":"queues-messages-scroll",children:b(Pe,{"data-testid":"queues-messages-table",children:[s(je,{children:b(z,{children:[s(w,{children:l("Export")}),s(w,{children:l("Message")}),s(w,{children:l("Attempts")}),s(w,{children:l("Outcome")}),s(w,{children:l("Body")}),s(w,{children:l("Captured")}),s(w,{})]})}),s(Ge,{children:i.map(T=>s(St,{message:T,onReplay:n,replayingId:o},T.id))})]})})})}),e[20]=t,e[21]=i,e[22]=n,e[23]=o,e[24]=l,e[25]=x):x=e[25];let N;return e[26]!==y||e[27]!==x?(N=b("div",{className:"flex flex-col gap-4","data-testid":"queues-messages",children:[y,x]}),e[26]=y,e[27]=x,e[28]=N):N=e[28],N},Tt=a=>{const e=B(20),{batchMode:t,bodyText:i,delayText:r,onBatchModeChange:n,onBodyChange:o,onDelayChange:l,onSelectExport:d,onSend:c,queues:m,selectedExportName:h,sending:g}=a,u=G();let p;e[0]!==u?(p=u("Enqueue a JSON message to a declared producer to exercise its consumer. Nothing is captured until the consumer processes it."),e[0]=u,e[1]=p):p=e[1];let y;e[2]!==p?(y=s("p",{className:"text-sm text-muted-foreground",children:p}),e[2]=p,e[3]=y):y=e[3];let x;e[4]!==t||e[5]!==i||e[6]!==r||e[7]!==n||e[8]!==o||e[9]!==l||e[10]!==d||e[11]!==c||e[12]!==m||e[13]!==h||e[14]!==g||e[15]!==u?(x=m.length===0?s(Re,{description:u("Declare a queue with defineQueue in lunora/queues.ts to enqueue a test message."),testId:"queues-send-empty",title:u("No queues to send to")}):b(ze,{children:[b("div",{className:"flex flex-wrap items-center gap-2",children:[b("select",{"aria-label":u("Queue"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"queues-send-select",onChange:d,value:h,children:[m.map(Qt),[...Be(m).topics].map(T=>{const[q,S]=T;return s("option",{value:He(q),children:u("{topic} (topic → {count} subscriptions)",{count:S.length,topic:q})},q)})]}),s(rt,{"aria-label":u("Delay (seconds)"),className:"max-w-36","data-testid":"queues-send-delay",min:0,onChange:l,placeholder:u("Delay (s)"),type:"number",value:r}),b("label",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",htmlFor:"queues-send-batch",children:[s("input",{checked:t,"data-testid":"queues-send-batch",id:"queues-send-batch",onChange:n,type:"checkbox"}),u("Send as batch (JSON array)")]}),s(Le,{className:"ml-auto","data-testid":"queues-send-button",disabled:g||h==="",onClick:c,type:"button",children:u(g?"Sending…":"Send message")})]}),s(nt,{"aria-label":u("Message body (JSON)"),className:"font-mono","data-testid":"queues-send-body",onChange:o,placeholder:t?'[ { "hello": "world" } ]':'{ "hello": "world" }',value:i})]}),e[4]=t,e[5]=i,e[6]=r,e[7]=n,e[8]=o,e[9]=l,e[10]=d,e[11]=c,e[12]=m,e[13]=h,e[14]=g,e[15]=u,e[16]=x):x=e[16];let N;return e[17]!==y||e[18]!==x?(N=b("div",{className:"flex flex-col gap-3","data-testid":"queues-send",children:[y,x]}),e[17]=y,e[18]=x,e[19]=N):N=e[19],N},Ct=(a,e,t,i)=>{let r=null;const n=a.trim();if(n!=="")try{r=JSON.parse(n)}catch{return{error:i("Body must be valid JSON.")}}let o;const l=e.trim();if(l!==""){const d=Number(l);if(!Number.isFinite(d)||d<0)return{error:i("Delay must be a non-negative number of seconds.")};o=d}return t&&!Array.isArray(r)?{error:i("Batch mode needs a JSON array body — each element is enqueued as one message.")}:{body:r,delaySeconds:o}},_t=a=>{const e=B(11),{deadLetteredCount:t,queuesWithoutDlq:i}=a,r=G();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=s("span",{"aria-hidden":"true",className:"text-base leading-none",children:"⚠"}),e[0]=n):n=e[0];let o;e[1]!==i||e[2]!==r?(o=i.length>0&&b(ze,{children:[s("p",{className:"font-medium",children:r("No dead-letter queue on {queues}.",{queues:i.map(At).join(", ")})}),s("p",{className:"text-muted-foreground",children:r("Exhausted messages are dropped after retries. Add a deadLetterQueue to capture them.")})]}),e[1]=i,e[2]=r,e[3]=o):o=e[3];let l;e[4]!==t||e[5]!==i.length||e[6]!==r?(l=t>0&&s("p",{className:i.length>0?"text-muted-foreground":"font-medium",children:t===1?r("1 message was recently dead-lettered."):r("{count} messages were recently dead-lettered.",{count:t})}),e[4]=t,e[5]=i.length,e[6]=r,e[7]=l):l=e[7];let d;return e[8]!==o||e[9]!==l?(d=s(st,{icon:n,testId:"queues-dlq-warning",variant:"warning",children:b("div",{className:"flex flex-col gap-1",children:[o,l]})}),e[8]=o,e[9]=l,e[10]=d):d=e[10],d},ts=a=>{const e=B(76),{limit:t}=a,i=t??mt,r=lt(),n=G(),[o,l]=L("declared"),[d,c]=L(null);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m={},e[0]=m):m=e[0];const{data:h,error:g,errorSource:u}=Fe(H.listQueues,m);let p;e[1]!==i?(p={limit:i},e[1]=i,e[2]=p):p=e[2];const{data:y,error:x,errorSource:N,poll:T,refetch:q}=Fe(H.getQueueMessages,p),S=Array.isArray(h?.queues)?[...h.queues].toSorted(It):[],Q=y?.entries??[],{deadLetteredCount:A,queuesWithoutDlq:M,showReliabilityWarning:$}=ct(S,Q),[O,R]=L(""),[C,I]=L(""),[_,me]=L(""),[D,pe]=L(!1),[fe,V]=L(!1),[he,X]=L(null),{topics:Y}=Be(S),$e=[...S.map(Mt),...[...Y.keys()].map(Lt)],k=$e.includes(O)?O:$e[0]??"",Oe=o==="messages"?x:g,Xe=o==="messages"?N:u,ge=Oe??d,xe=Oe===null?d:Xe;ot(T,o==="messages");let K;e[3]!==D||e[4]!==C||e[5]!==r||e[6]!==_||e[7]!==q||e[8]!==k||e[9]!==V||e[10]!==n||e[11]!==Y?(K=async()=>{c(null);const f=k;if(f==="")return;const E=Ct(C,_,D,n);if("error"in E){c(E.error);return}const{body:we,delaySeconds:ke}=E;V(!0);const Ke=ut(f,Y).map(ce=>D?{batch:we,delaySeconds:ke,exportName:ce}:{body:we,delaySeconds:ke,exportName:ce});try{c(await ft(r,Ke,n)),q()}catch(ce){c(ue(ce))}V(!1)},e[3]=D,e[4]=C,e[5]=r,e[6]=_,e[7]=q,e[8]=k,e[9]=V,e[10]=n,e[11]=Y,e[12]=K):K=e[12];const ye=K;let Z;e[13]!==r||e[14]!==q||e[15]!==X?(Z=async f=>{c(null),X(f);try{await r.query(ht,{id:f},Ie("")),q()}catch(E){c(ue(E))}X(null)},e[13]=r,e[14]=q,e[15]=X,e[16]=Z):Z=e[16];const be=Z;let ee;e[17]!==r||e[18]!==q?(ee=async()=>{c(null);try{await r.query(gt,{},Ie("")),q()}catch(f){c(ue(f))}},e[17]=r,e[18]=q,e[19]=ee):ee=e[19];const Ne=ee;let te;e[20]===Symbol.for("react.memo_cache_sentinel")?(te=f=>{const E=f.currentTarget.dataset.tab;(E==="declared"||E==="messages"||E==="send")&&l(E)},e[20]=te):te=e[20];const Ye=te;let se;e[21]!==R?(se=f=>{R(f.currentTarget.value)},e[21]=R,e[22]=se):se=e[22];const qe=se;let re;e[23]!==I?(re=f=>{I(f.currentTarget.value)},e[23]=I,e[24]=re):re=e[24];const Se=re;let ae;e[25]!==me?(ae=f=>{me(f.currentTarget.value)},e[25]=me,e[26]=ae):ae=e[26];const Ee=ae;let ne;e[27]!==pe?(ne=f=>{pe(f.currentTarget.checked)},e[27]=pe,e[28]=ne):ne=e[28];const Te=ne;let oe;e[29]!==ye?(oe=()=>{Qe(ye())},e[29]=ye,e[30]=oe):oe=e[30];const Ce=oe;let le;e[31]!==be?(le=f=>{const{id:E}=f.currentTarget.dataset;E!==void 0&&Qe(be(E))},e[31]=be,e[32]=le):le=e[32];const _e=le;let ie;e[33]!==Ne?(ie=()=>{Qe(Ne())},e[33]=Ne,e[34]=ie):ie=e[34];const ve=ie;let F;e[35]!==n||e[36]!==o?(F=s("div",{className:"flex items-center gap-1","data-testid":"queues-tabs",role:"tablist",children:["declared","messages","send"].map(f=>s(Le,{"aria-selected":o===f,"data-tab":f,"data-testid":`queues-tab-${f}`,onClick:Ye,role:"tab",size:"sm",type:"button",variant:o===f?"secondary":"ghost",children:Nt(f,n)},f))}),e[35]=n,e[36]=o,e[37]=F):F=e[37];let U;e[38]!==ge||e[39]!==xe?(U=ge!==null&&s(tt,{error:xe,testId:"queues-error"}),e[38]=ge,e[39]=xe,e[40]=U):U=e[40];let W;e[41]!==A||e[42]!==M||e[43]!==$?(W=$&&s(_t,{deadLetteredCount:A,queuesWithoutDlq:M}),e[41]=A,e[42]=M,e[43]=$,e[44]=W):W=e[44];let J;e[45]!==S||e[46]!==h||e[47]!==o?(J=o==="declared"&&s(qt,{loaded:h!==void 0,queues:S}),e[45]=S,e[46]=h,e[47]=o,e[48]=J):J=e[48];let P;e[49]!==Q||e[50]!==x||e[51]!==ve||e[52]!==_e||e[53]!==he||e[54]!==o?(P=o==="messages"&&s(Et,{hasError:x!==null,messages:Q,onClear:ve,onReplay:_e,replayingId:he}),e[49]=Q,e[50]=x,e[51]=ve,e[52]=_e,e[53]=he,e[54]=o,e[55]=P):P=e[55];let j;e[56]!==D||e[57]!==C||e[58]!==_||e[59]!==Te||e[60]!==Se||e[61]!==Ee||e[62]!==qe||e[63]!==Ce||e[64]!==S||e[65]!==k||e[66]!==fe||e[67]!==o?(j=o==="send"&&s(Tt,{batchMode:D,bodyText:C,delayText:_,onBatchModeChange:Te,onBodyChange:Se,onDelayChange:Ee,onSelectExport:qe,onSend:Ce,queues:S,selectedExportName:k,sending:fe}),e[56]=D,e[57]=C,e[58]=_,e[59]=Te,e[60]=Se,e[61]=Ee,e[62]=qe,e[63]=Ce,e[64]=S,e[65]=k,e[66]=fe,e[67]=o,e[68]=j):j=e[68];let de;return e[69]!==F||e[70]!==U||e[71]!==W||e[72]!==J||e[73]!==P||e[74]!==j?(de=b("div",{className:"flex flex-col gap-6","data-testid":"lunora-queues-panel",children:[F,U,W,J,P,j]}),e[69]=F,e[70]=U,e[71]=W,e[72]=J,e[73]=P,e[74]=j,e[75]=de):de=e[75],de};function vt(a){return s(Ve,{queue:a},a.exportName)}function wt(a){return s(Ve,{queue:a},a.exportName)}function Qt(a){return s("option",{value:a.exportName,children:a.exportName},a.exportName)}function At(a){return a.name}function It(a,e){return a.exportName.localeCompare(e.exportName)}function Mt(a){return a.exportName}function Lt(a){return He(a)}export{ts as default};
@@ -1 +1 @@
1
- import{E as g}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{B as N}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as v,a as b}from"../packem_shared/card-By2O8ULa.mjs";import{E as y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T,a as w,b as m,c as s,d as S,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as e,jsxs as o}from"react/jsx-runtime";const R={active:"default",failing:"destructive",idle:"secondary"},I=a=>a===void 0?"—":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,$=a=>{const r=a.runs+a.suppressed;return r===0?void 0:Math.round(a.suppressed/r*100)},U=({initialShardKey:a=""})=>{const r=E(),{data:l,error:p,errorSource:u,liveError:f}=A(C.listReactors,{},{live:!0,shardKey:a}),x=l!==void 0,d=Array.isArray(l?.reactors)?l.reactors:[];let i;x&&d.length===0?i=e(y,{description:r("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:r("No reactors declared")}):i=e(v,{className:"overflow-hidden py-0",children:e(b,{className:"px-0",children:o(T,{"data-testid":"reactors-table",children:[e(w,{children:o(m,{children:[e(s,{children:r("Reactor")}),e(s,{children:r("State")}),e(s,{children:r("Ran")}),e(s,{children:r("Suppressed")}),e(s,{children:r("Errors")}),e(s,{children:r("Watches")}),e(s,{children:r("Last dispatch")})]})}),e(S,{children:d.map(t=>{const h=$(t);return o(m,{"data-testid":`reactors-row-${t.path}`,children:[e(n,{className:"font-mono text-xs",children:t.path}),e(n,{children:e(N,{"data-testid":`reactors-state-${t.path}`,variant:R[t.state],children:t.state})}),e(n,{className:"font-mono text-xs",children:t.runs}),o(n,{className:"font-mono text-xs text-muted-foreground",children:[t.suppressed,h===void 0?"":` (${String(h)}%)`]}),e(n,{className:"font-mono text-xs",children:t.errors===0?e("span",{className:"text-muted-foreground",children:"0"}):e("span",{className:"text-destructive",children:t.errors})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:t.tables===void 0||t.tables.length===0?"—":t.tables.join(", ")}),e(n,{className:"font-mono text-xs text-muted-foreground",children:I(t.lastRanAt)})]},t.path)})})]})})});const c=d.filter(t=>t.state==="failing");return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[p!==null&&e(g,{error:u,testId:"reactors-error"}),e("p",{className:"text-sm text-muted-foreground",children:r("A reactor runs after a write flush, but only when the result of the query it watches actually changed — a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),c.length>0&&e("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:c.map(t=>o("p",{className:"text-xs text-destructive",role:"alert",children:[e("span",{className:"font-mono",children:t.path}),": ",t.lastError??r("last dispatch failed")]},t.path))}),f!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:r("Live updates unavailable; showing the last reading.")}),i]})};export{U as default};
1
+ import{E as g}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as N}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as v,a as b}from"../packem_shared/card-By2O8ULa.mjs";import{E as y}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T,a as w,b as m,c as s,d as S,e as n}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as e,jsxs as o}from"react/jsx-runtime";const R={active:"default",failing:"destructive",idle:"secondary"},I=a=>a===void 0?"—":`${new Date(a).toISOString().slice(0,19).replace("T"," ")} UTC`,$=a=>{const r=a.runs+a.suppressed;return r===0?void 0:Math.round(a.suppressed/r*100)},U=({initialShardKey:a=""})=>{const r=E(),{data:l,error:p,errorSource:u,liveError:f}=A(C.listReactors,{},{live:!0,shardKey:a}),x=l!==void 0,d=Array.isArray(l?.reactors)?l.reactors:[];let i;x&&d.length===0?i=e(y,{description:r("No reactor is declared in this deployment. Export an onQueryChange(select, handler) from lunora/ to run server-side logic when a query's result changes."),testId:"reactors-empty",title:r("No reactors declared")}):i=e(v,{className:"overflow-hidden py-0",children:e(b,{className:"px-0",children:o(T,{"data-testid":"reactors-table",children:[e(w,{children:o(m,{children:[e(s,{children:r("Reactor")}),e(s,{children:r("State")}),e(s,{children:r("Ran")}),e(s,{children:r("Suppressed")}),e(s,{children:r("Errors")}),e(s,{children:r("Watches")}),e(s,{children:r("Last dispatch")})]})}),e(S,{children:d.map(t=>{const h=$(t);return o(m,{"data-testid":`reactors-row-${t.path}`,children:[e(n,{className:"font-mono text-xs",children:t.path}),e(n,{children:e(N,{"data-testid":`reactors-state-${t.path}`,variant:R[t.state],children:t.state})}),e(n,{className:"font-mono text-xs",children:t.runs}),o(n,{className:"font-mono text-xs text-muted-foreground",children:[t.suppressed,h===void 0?"":` (${String(h)}%)`]}),e(n,{className:"font-mono text-xs",children:t.errors===0?e("span",{className:"text-muted-foreground",children:"0"}):e("span",{className:"text-destructive",children:t.errors})}),e(n,{className:"font-mono text-xs text-muted-foreground",children:t.tables===void 0||t.tables.length===0?"—":t.tables.join(", ")}),e(n,{className:"font-mono text-xs text-muted-foreground",children:I(t.lastRanAt)})]},t.path)})})]})})});const c=d.filter(t=>t.state==="failing");return o("div",{className:"flex flex-col gap-6","data-testid":"lunora-reactors-panel",children:[p!==null&&e(g,{error:u,testId:"reactors-error"}),e("p",{className:"text-sm text-muted-foreground",children:r("A reactor runs after a write flush, but only when the result of the query it watches actually changed — a trigger fires on a row write, a reactor fires on a result changing. Suppressed dispatches are the ones where the read re-ran and nothing had moved.")}),c.length>0&&e("div",{className:"flex flex-col gap-2","data-testid":"reactors-failing",children:c.map(t=>o("p",{className:"text-xs text-destructive",role:"alert",children:[e("span",{className:"font-mono",children:t.path}),": ",t.lastError??r("last dispatch failed")]},t.path))}),f!==void 0&&e("p",{className:"text-xs text-amber-600 dark:text-amber-500","data-testid":"reactors-live-error",role:"alert",children:r("Live updates unavailable; showing the last reading.")}),i]})};export{U as default};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as _,C as j}from"../packem_shared/card-By2O8ULa.mjs";import{E as D}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as O,a as $,b as E,c as R,d as G,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as L}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as t,jsxs as a}from"react/jsx-runtime";const H=["read","insert","update","delete"],z=(e,r)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[r],J=e=>{const r=new Map;for(const s of e){const l=r.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),r.set(s.table,l)}return[...r.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},oe=()=>{const e=U(49),r=Q();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:C,errorSource:I}=L(q.rlsPolicies,s),c=l!==void 0;let p,n,m,o,f,h,u,b,i;if(e[1]!==l||e[2]!==C||e[3]!==I||e[4]!==c||e[5]!==r){const k=J(Array.isArray(l?.policies)?l.policies:[]);let v;e[15]!==l?(v=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=v):v=e[16],n=v,u="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(i=C!==null&&t(F,{error:I,testId:"rls-error"}),e[17]=C,e[18]=I,e[19]=i):i=e[19],h="flex flex-col gap-2",p=j,m="overflow-hidden py-0";let A;e[20]!==r?(A=r("Policies"),e[20]=r,e[21]=A):A=e[21],e[22]!==A?(o=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:A})}),e[22]=A,e[23]=o):o=e[23],f=c&&k.length===0?t(D,{description:r("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:r("No policies defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-policies-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Table")}),H.map(d=>t(R,{children:z(r,d)},d)),t(R,{children:r("Guarded by")})]})}),t(G,{children:k.map(d=>a(E,{"data-testid":`rls-table-${d.table}`,children:[t(S,{className:"font-mono text-xs",children:d.table}),H.map(B=>t(S,{children:d.operations.has(B)?t(M,{variant:"secondary",children:r("Guarded")}):t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},B)),t(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=C,e[3]=I,e[4]=c,e[5]=r,e[6]=p,e[7]=n,e[8]=m,e[9]=o,e[10]=f,e[11]=h,e[12]=u,e[13]=b,e[14]=i}else p=e[6],n=e[7],m=e[8],o=e[9],f=e[10],h=e[11],u=e[12],b=e[13],i=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==o||e[27]!==f?(x=a(p,{className:m,children:[o,f]}),e[24]=p,e[25]=m,e[26]=o,e[27]=f,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=t("section",{className:h,children:x}),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==r?(y=r("Roles"),e[32]=r,e[33]=y):y=e[33];let g;e[34]!==y?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==c||e[37]!==n||e[38]!==r?(T=c&&n.length===0?t(D,{description:r("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:r("No roles defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-roles-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Role")}),t(R,{children:r("Description")}),t(R,{children:r("Permissions")})]})}),t(G,{children:n.map(V)})]})}),e[36]=c,e[37]=n,e[38]=r,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=t("section",{className:"flex flex-col gap-2",children:a(j,{className:"overflow-hidden py-0",children:[g,T]})}),e[40]=g,e[41]=T,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==b||e[46]!==i||e[47]!==N?(P=a("div",{className:u,"data-testid":b,children:[i,N,w]}),e[43]=w,e[44]=u,e[45]=b,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function K(e){return t(M,{variant:"outline",children:e},e)}function V(e){return a(E,{"data-testid":`rls-role-${e.name}`,children:[t(S,{className:"font-mono text-xs",children:e.name}),t(S,{className:"text-muted-foreground",children:e.description??""}),t(S,{children:e.permissions.length===0?t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):t("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(K)})})]},e.name)}export{oe as default};
1
+ import{c as U}from"react/compiler-runtime";import{E as F}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as M}from"../packem_shared/badge-r_5B4LHP.mjs";import{a as _,C as j}from"../packem_shared/card-By2O8ULa.mjs";import{E as D}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as O,a as $,b as E,c as R,d as G,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as L}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsx as t,jsxs as a}from"react/jsx-runtime";const H=["read","insert","update","delete"],z=(e,r)=>({delete:e("Delete"),insert:e("Insert"),read:e("Read"),update:e("Update")})[r],J=e=>{const r=new Map;for(const s of e){const l=r.get(s.table)??{operations:new Set,procedures:new Set,table:s.table};l.operations.add(s.on),l.procedures.add(s.procedure),r.set(s.table,l)}return[...r.values()].toSorted((s,l)=>s.table.localeCompare(l.table))},oe=()=>{const e=U(49),r=Q();let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s={},e[0]=s):s=e[0];const{data:l,error:C,errorSource:I}=L(q.rlsPolicies,s),c=l!==void 0;let p,n,m,o,f,h,u,b,i;if(e[1]!==l||e[2]!==C||e[3]!==I||e[4]!==c||e[5]!==r){const k=J(Array.isArray(l?.policies)?l.policies:[]);let v;e[15]!==l?(v=Array.isArray(l?.roles)?l.roles:[],e[15]=l,e[16]=v):v=e[16],n=v,u="flex flex-col gap-6",b="lunora-rls-panel",e[17]!==C||e[18]!==I?(i=C!==null&&t(F,{error:I,testId:"rls-error"}),e[17]=C,e[18]=I,e[19]=i):i=e[19],h="flex flex-col gap-2",p=j,m="overflow-hidden py-0";let A;e[20]!==r?(A=r("Policies"),e[20]=r,e[21]=A):A=e[21],e[22]!==A?(o=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:A})}),e[22]=A,e[23]=o):o=e[23],f=c&&k.length===0?t(D,{description:r("No `definePolicy` is wired through `.use(rls(...))` in this deployment. Add one to guard a table's rows."),testId:"rls-policies-empty",title:r("No policies defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-policies-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Table")}),H.map(d=>t(R,{children:z(r,d)},d)),t(R,{children:r("Guarded by")})]})}),t(G,{children:k.map(d=>a(E,{"data-testid":`rls-table-${d.table}`,children:[t(S,{className:"font-mono text-xs",children:d.table}),H.map(B=>t(S,{children:d.operations.has(B)?t(M,{variant:"secondary",children:r("Guarded")}):t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"})},B)),t(S,{className:"font-mono text-xs text-muted-foreground",children:[...d.procedures].join(", ")})]},d.table))})]})}),e[1]=l,e[2]=C,e[3]=I,e[4]=c,e[5]=r,e[6]=p,e[7]=n,e[8]=m,e[9]=o,e[10]=f,e[11]=h,e[12]=u,e[13]=b,e[14]=i}else p=e[6],n=e[7],m=e[8],o=e[9],f=e[10],h=e[11],u=e[12],b=e[13],i=e[14];let x;e[24]!==p||e[25]!==m||e[26]!==o||e[27]!==f?(x=a(p,{className:m,children:[o,f]}),e[24]=p,e[25]=m,e[26]=o,e[27]=f,e[28]=x):x=e[28];let N;e[29]!==h||e[30]!==x?(N=t("section",{className:h,children:x}),e[29]=h,e[30]=x,e[31]=N):N=e[31];let y;e[32]!==r?(y=r("Roles"),e[32]=r,e[33]=y):y=e[33];let g;e[34]!==y?(g=t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:y})}),e[34]=y,e[35]=g):g=e[35];let T;e[36]!==c||e[37]!==n||e[38]!==r?(T=c&&n.length===0?t(D,{description:r("No `defineRole` is registered via `rls(policies, { roles })`. Roles back `ctx.auth.can(...)` permission checks."),testId:"rls-roles-empty",title:r("No roles defined")}):t(_,{className:"px-0",children:a(O,{"data-testid":"rls-roles-table",children:[t($,{children:a(E,{children:[t(R,{children:r("Role")}),t(R,{children:r("Description")}),t(R,{children:r("Permissions")})]})}),t(G,{children:n.map(V)})]})}),e[36]=c,e[37]=n,e[38]=r,e[39]=T):T=e[39];let w;e[40]!==g||e[41]!==T?(w=t("section",{className:"flex flex-col gap-2",children:a(j,{className:"overflow-hidden py-0",children:[g,T]})}),e[40]=g,e[41]=T,e[42]=w):w=e[42];let P;return e[43]!==w||e[44]!==u||e[45]!==b||e[46]!==i||e[47]!==N?(P=a("div",{className:u,"data-testid":b,children:[i,N,w]}),e[43]=w,e[44]=u,e[45]=b,e[46]=i,e[47]=N,e[48]=P):P=e[48],P};function K(e){return t(M,{variant:"outline",children:e},e)}function V(e){return a(E,{"data-testid":`rls-role-${e.name}`,children:[t(S,{className:"font-mono text-xs",children:e.name}),t(S,{className:"text-muted-foreground",children:e.description??""}),t(S,{children:e.permissions.length===0?t("span",{"aria-hidden":"true",className:"text-muted-foreground",children:"—"}):t("span",{className:"flex flex-wrap gap-1",children:e.permissions.map(K)})})]},e.name)}export{oe as default};
@@ -1 +1 @@
1
- import{c as D}from"react/compiler-runtime";import{useState as F}from"react";import{B as Y}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{useLunora as V}from"@lunora/react";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-DU4p72Er.mjs";import{B as O}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as P,a as R}from"../packem_shared/card-By2O8ULa.mjs";import{E as W}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as Q,a as K,b as q,c as x,d as z,e as b}from"../packem_shared/table-D0SBiDu-.mjs";import{a as H}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{f as A,b as U,h as j}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as m,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as X}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-BJ1uZW1U.mjs";const te={kind:"idle"},re=(n,e,c)=>c!==void 0?c:e===void 0?a=>n.runCronJob(a):void 0,le=({loadCronJobs:n,runCronJob:e}={})=>{const c=V(),a=M(),[p,o]=F({}),s=H(["lunora-cron-jobs",n?"custom":"default"],()=>(n??(()=>c.getCronJobs()))()),{data:r,error:y}=s,h=re(c,n,e),i=async l=>{if(h!==void 0){o(d=>({...d,[l]:{kind:"running"}}));try{await h(l),o(d=>({...d,[l]:{kind:"ok"}})),s.refetch()}catch(d){o(g=>({...g,[l]:{kind:"error",message:U(d)}}))}}};return m("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:y}),r?.length===0&&t(W,{description:a("Triggers declared with the cronJobs() builder appear here."),icon:m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:a("No cron triggers.")}),r!==void 0&&r.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"cron-table",children:[t(K,{children:m(q,{children:[t(x,{children:a("name")}),t(x,{children:a("schedule")}),t(x,{children:a("target")}),t(x,{children:a("shard")}),h!==void 0&&t(x,{"aria-label":a("Actions")})]})}),t(z,{children:r.map(l=>{const d=p[l.name]??te;return m(q,{"data-testid":`cron-row-${l.name}`,children:[t(b,{children:l.name}),t(b,{className:"font-mono text-xs tabular-nums",children:l.cron}),t(b,{children:m("span",{className:"flex items-center gap-2",children:[l.workflow===void 0?t(O,{variant:"outline",children:a("function")}):t(O,{variant:"secondary",children:a("workflow")}),t("span",{className:"font-mono text-xs",children:l.workflow??l.functionPath})]})}),t(b,{children:l.shardKey??""}),h!==void 0&&t(b,{className:"text-right",children:m("span",{className:"flex items-center justify-end gap-2",children:[d.kind==="ok"&&t("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${l.name}`,children:a("ran")}),d.kind==="error"&&t("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${l.name}`,role:"alert",children:d.message}),t(G,{confirmLabel:a("Run now?"),disabled:d.kind==="running",onConfirm:()=>{A(i(l.name))},testId:`cron-run-${l.name}`,children:d.kind==="running"?a("Running…"):a("Run now")})]})})]},`${l.cron}:${l.name}`)})})]})})})]})},se=n=>Number.isFinite(n)?j(n,"—"):"—",ne=n=>{const e=D(34);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadJobs:a,removeJob:p,retryJob:o}=c,s=V(),r=M();let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-dead-jobs"],e[2]=y):y=e[2];let h;e[3]!==s||e[4]!==a?(h=async()=>(await(a??(()=>s.listDeadJobs()))()).toSorted(oe),e[3]=s,e[4]=a,e[5]=h):h=e[5];const i=H(y,h),l=i.data,[d,g]=F(void 0),N=i.error??d,f=a===void 0;let C;e[6]!==s||e[7]!==f||e[8]!==o?(C=o??(f?u=>s.retryDeadJob(u):void 0),e[6]=s,e[7]=f,e[8]=o,e[9]=C):C=e[9];const v=C;let k;e[10]!==s||e[11]!==f||e[12]!==p?(k=p??(f?u=>s.removeDeadJob(u):void 0),e[10]=s,e[11]=f,e[12]=p,e[13]=k):k=e[13];const S=k;let $;e[14]!==i?($=()=>i.poll(),e[14]=i,e[15]=$):$=e[15],X($,!0);let I;e[16]!==i?(I=async u=>{g(void 0);try{await u,i.refetch()}catch(Z){g(U(Z))}},e[16]=i,e[17]=I):I=e[17];const L=I,T=v!==void 0||S!==void 0;let J;e[18]!==N?(J=N!==void 0&&t("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:N}),e[18]=N,e[19]=J):J=e[19];let w;e[20]!==l?.length||e[21]!==r?(w=l?.length===0&&t(W,{description:r("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:r("No dead-letter jobs.")}),e[20]=l?.length,e[21]=r,e[22]=w):w=e[22];let _;e[23]!==L||e[24]!==T||e[25]!==l||e[26]!==S||e[27]!==v||e[28]!==r?(_=l!==void 0&&l.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"dlq-table",children:[t(K,{children:m(q,{children:[t(x,{children:r("function")}),t(x,{children:r("attempts")}),t(x,{children:r("last tried")}),t(x,{children:r("pool")}),t(x,{children:r("shard")}),t(x,{children:r("id")}),T&&t(x,{"aria-label":r("Actions")})]})}),t(z,{children:l.map(u=>m(q,{"data-testid":`dlq-row-${u.id}`,children:[t(b,{className:"font-mono text-xs",children:u.workflow??u.functionPath}),t(b,{className:"tabular-nums",children:u.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:se(u.scheduledFor)}),t(b,{className:"font-mono text-xs",children:u.pool??""}),t(b,{children:u.shardKey??""}),t(b,{className:"font-mono text-xs",children:u.id}),T&&t(b,{className:"text-right",children:m("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&t(Y,{"data-testid":`dlq-retry-${u.id}`,onClick:()=>{A(L(v(u.id)))},size:"sm",type:"button",variant:"outline",children:r("Retry")}),S!==void 0&&t(G,{confirmLabel:r("Drop job?"),onConfirm:()=>{A(L(S(u.id)))},testId:`dlq-remove-${u.id}`,children:r("Drop")})]})})]},u.id))})]})})}),e[23]=L,e[24]=T,e[25]=l,e[26]=S,e[27]=v,e[28]=r,e[29]=_):_=e[29];let B;return e[30]!==_||e[31]!==J||e[32]!==w?(B=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[J,w,_]}),e[30]=_,e[31]=J,e[32]=w,e[33]=B):B=e[33],B};function oe(n,e){return(e.attempts??0)-(n.attempts??0)}const E=n=>{const e=D(8),{label:c,testId:a,value:p}=n;let o;e[0]!==c?(o=t("span",{className:"text-xs text-muted-foreground",children:c}),e[0]=c,e[1]=o):o=e[1];let s;e[2]!==a||e[3]!==p?(s=t("span",{className:"text-2xl font-semibold tabular-nums","data-testid":a,children:p}),e[2]=a,e[3]=p,e[4]=s):s=e[4];let r;return e[5]!==o||e[6]!==s?(r=t(P,{className:"flex-1 py-0",children:m(R,{className:"flex flex-col gap-1 p-4",children:[o,s]})}),e[5]=o,e[6]=s,e[7]=r):r=e[7],r},ae=n=>{const e=D(25);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadStatus:a}=c,p=V(),o=M(),s=a===void 0;let r;e[2]!==s?(r=["lunora-scheduler-status",s],e[2]=s,e[3]=r):r=e[3];let y;e[4]!==p||e[5]!==a?(y=async()=>{const k=await(a??(()=>p.schedulerStatus()))();return{...k,pools:k.pools.toSorted(ie)}},e[4]=p,e[5]=a,e[6]=y):y=e[6];const h=H(r,y),{data:i,error:l}=h;let d;e[7]!==h?(d=()=>h.poll(),e[7]=h,e[8]=d):d=e[8],X(d,!0);let g;e[9]!==l?(g=l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:l}),e[9]=l,e[10]=g):g=e[10];let N;e[11]!==i||e[12]!==o?(N=i!==void 0&&m("div",{className:"flex gap-3","data-testid":"pools-totals",children:[t(E,{label:o("backlog"),testId:"pools-backlog",value:i.backlog}),t(E,{label:o("in flight"),testId:"pools-inflight",value:i.inFlight}),t(E,{label:o("pools"),testId:"pools-count",value:i.pools.length})]}),e[11]=i,e[12]=o,e[13]=N):N=e[13];let f;e[14]!==i?.pools.length||e[15]!==o?(f=i?.pools.length===0&&t(W,{description:o("Pools created with createWorkpool appear here once they have activity."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:o("No workpools.")}),e[14]=i?.pools.length,e[15]=o,e[16]=f):f=e[16];let C;e[17]!==i||e[18]!==o?(C=i!==void 0&&i.pools.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(Q,{"data-testid":"pools-table",children:[t(K,{children:m(q,{children:[t(x,{children:o("pool")}),t(x,{children:o("queued")}),t(x,{children:o("in flight")}),t(x,{children:o("max concurrency")})]})}),t(z,{children:i.pools.map(de)})]})})}),e[17]=i,e[18]=o,e[19]=C):C=e[19];let v;return e[20]!==g||e[21]!==N||e[22]!==f||e[23]!==C?(v=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[g,N,f,C]}),e[20]=g,e[21]=N,e[22]=f,e[23]=C,e[24]=v):v=e[24],v};function ie(n,e){return e.queued-n.queued}function de(n){return m(q,{"data-testid":`pools-row-${n.name}`,children:[t(b,{className:"font-mono text-xs",children:n.name}),t(b,{className:"tabular-nums",children:n.queued}),m(b,{className:"tabular-nums",children:[n.inFlight," / ",n.maxConcurrency]}),t(b,{className:"tabular-nums",children:n.maxConcurrency})]},n.name)}const ce=["jobs","dead","pools","cron"],Ie=n=>{const e=D(41);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadCronJobs:a,scheduledCancel:p,scheduledLoad:o}=c,s=M(),[r,y]=F("jobs");let h;e[2]!==s?(h=s("Cron triggers"),e[2]=s,e[3]=h):h=e[3];let i;e[4]!==s?(i=s("Dead letter"),e[4]=s,e[5]=i):i=e[5];let l;e[6]!==s?(l=s("Scheduled jobs"),e[6]=s,e[7]=l):l=e[7];let d;e[8]!==s?(d=s("Pools"),e[8]=s,e[9]=d):d=e[9];let g;e[10]!==h||e[11]!==i||e[12]!==l||e[13]!==d?(g={cron:h,dead:i,jobs:l,pools:d},e[10]=h,e[11]=i,e[12]=l,e[13]=d,e[14]=g):g=e[14];const N=g;let f;e[15]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{y(w.currentTarget.dataset.view)},e[15]=f):f=e[15];const C=f;let v;e[16]!==s?(v=s("Schedule view"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==r||e[19]!==N?(k=ce.map(w=>t(Y,{"aria-selected":r===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:C,role:"tab",size:"sm",type:"button",variant:r===w?"default":"outline",children:N[w]},w)),e[18]=r,e[19]=N,e[20]=k):k=e[20];let S;e[21]!==v||e[22]!==k?(S=t("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:k}),e[21]=v,e[22]=k,e[23]=S):S=e[23];let $;e[24]!==p||e[25]!==o||e[26]!==r?($=r==="jobs"&&t(ee,{cancelJob:p,loadJobs:o}),e[24]=p,e[25]=o,e[26]=r,e[27]=$):$=e[27];let I;e[28]!==r?(I=r==="dead"&&t(ne,{}),e[28]=r,e[29]=I):I=e[29];let L;e[30]!==r?(L=r==="pools"&&t(ae,{}),e[30]=r,e[31]=L):L=e[31];let T;e[32]!==a||e[33]!==r?(T=r==="cron"&&t(le,{loadCronJobs:a}),e[32]=a,e[33]=r,e[34]=T):T=e[34];let J;return e[35]!==S||e[36]!==$||e[37]!==I||e[38]!==L||e[39]!==T?(J=m("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,$,I,L,T]}),e[35]=S,e[36]=$,e[37]=I,e[38]=L,e[39]=T,e[40]=J):J=e[40],J};export{Ie as SchedulePanel};
1
+ import{c as D}from"react/compiler-runtime";import{useState as F}from"react";import{B as Y}from"../packem_shared/button-q0UYSmrn.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ConfirmButton as G}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{B as O}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as P,a as R}from"../packem_shared/card-By2O8ULa.mjs";import{E as V}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as W,a as Q,b as q,c as x,d as K,e as b}from"../packem_shared/table-D0SBiDu-.mjs";import{a as z}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as H}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{f as A,b as U,h as j}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as m,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as X}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-D4CUj7aX.mjs";const te={kind:"idle"},re=(n,e,c)=>c!==void 0?c:e===void 0?a=>n.runCronJob(a):void 0,le=({loadCronJobs:n,runCronJob:e}={})=>{const c=H(),a=M(),[p,o]=F({}),s=z(["lunora-cron-jobs",n?"custom":"default"],()=>(n??(()=>c.getCronJobs()))()),{data:r,error:y}=s,h=re(c,n,e),i=async l=>{if(h!==void 0){o(d=>({...d,[l]:{kind:"running"}}));try{await h(l),o(d=>({...d,[l]:{kind:"ok"}})),s.refetch()}catch(d){o(g=>({...g,[l]:{kind:"error",message:U(d)}}))}}};return m("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:y}),r?.length===0&&t(V,{description:a("Triggers declared with the cronJobs() builder appear here."),icon:m("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[t("circle",{cx:"12",cy:"12",r:"9"}),t("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:a("No cron triggers.")}),r!==void 0&&r.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(W,{"data-testid":"cron-table",children:[t(Q,{children:m(q,{children:[t(x,{children:a("name")}),t(x,{children:a("schedule")}),t(x,{children:a("target")}),t(x,{children:a("shard")}),h!==void 0&&t(x,{"aria-label":a("Actions")})]})}),t(K,{children:r.map(l=>{const d=p[l.name]??te;return m(q,{"data-testid":`cron-row-${l.name}`,children:[t(b,{children:l.name}),t(b,{className:"font-mono text-xs tabular-nums",children:l.cron}),t(b,{children:m("span",{className:"flex items-center gap-2",children:[l.workflow===void 0?t(O,{variant:"outline",children:a("function")}):t(O,{variant:"secondary",children:a("workflow")}),t("span",{className:"font-mono text-xs",children:l.workflow??l.functionPath})]})}),t(b,{children:l.shardKey??""}),h!==void 0&&t(b,{className:"text-right",children:m("span",{className:"flex items-center justify-end gap-2",children:[d.kind==="ok"&&t("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${l.name}`,children:a("ran")}),d.kind==="error"&&t("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${l.name}`,role:"alert",children:d.message}),t(G,{confirmLabel:a("Run now?"),disabled:d.kind==="running",onConfirm:()=>{A(i(l.name))},testId:`cron-run-${l.name}`,children:d.kind==="running"?a("Running…"):a("Run now")})]})})]},`${l.cron}:${l.name}`)})})]})})})]})},se=n=>Number.isFinite(n)?j(n,"—"):"—",ne=n=>{const e=D(34);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadJobs:a,removeJob:p,retryJob:o}=c,s=H(),r=M();let y;e[2]===Symbol.for("react.memo_cache_sentinel")?(y=["lunora-dead-jobs"],e[2]=y):y=e[2];let h;e[3]!==s||e[4]!==a?(h=async()=>(await(a??(()=>s.listDeadJobs()))()).toSorted(oe),e[3]=s,e[4]=a,e[5]=h):h=e[5];const i=z(y,h),l=i.data,[d,g]=F(void 0),N=i.error??d,f=a===void 0;let C;e[6]!==s||e[7]!==f||e[8]!==o?(C=o??(f?u=>s.retryDeadJob(u):void 0),e[6]=s,e[7]=f,e[8]=o,e[9]=C):C=e[9];const v=C;let k;e[10]!==s||e[11]!==f||e[12]!==p?(k=p??(f?u=>s.removeDeadJob(u):void 0),e[10]=s,e[11]=f,e[12]=p,e[13]=k):k=e[13];const S=k;let $;e[14]!==i?($=()=>i.poll(),e[14]=i,e[15]=$):$=e[15],X($,!0);let I;e[16]!==i?(I=async u=>{g(void 0);try{await u,i.refetch()}catch(Z){g(U(Z))}},e[16]=i,e[17]=I):I=e[17];const T=I,J=v!==void 0||S!==void 0;let L;e[18]!==N?(L=N!==void 0&&t("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:N}),e[18]=N,e[19]=L):L=e[19];let w;e[20]!==l?.length||e[21]!==r?(w=l?.length===0&&t(V,{description:r("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:r("No dead-letter jobs.")}),e[20]=l?.length,e[21]=r,e[22]=w):w=e[22];let _;e[23]!==T||e[24]!==J||e[25]!==l||e[26]!==S||e[27]!==v||e[28]!==r?(_=l!==void 0&&l.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(W,{"data-testid":"dlq-table",children:[t(Q,{children:m(q,{children:[t(x,{children:r("function")}),t(x,{children:r("attempts")}),t(x,{children:r("last tried")}),t(x,{children:r("pool")}),t(x,{children:r("shard")}),t(x,{children:r("id")}),J&&t(x,{"aria-label":r("Actions")})]})}),t(K,{children:l.map(u=>m(q,{"data-testid":`dlq-row-${u.id}`,children:[t(b,{className:"font-mono text-xs",children:u.workflow??u.functionPath}),t(b,{className:"tabular-nums",children:u.attempts??0}),t(b,{className:"text-muted-foreground tabular-nums",children:se(u.scheduledFor)}),t(b,{className:"font-mono text-xs",children:u.pool??""}),t(b,{children:u.shardKey??""}),t(b,{className:"font-mono text-xs",children:u.id}),J&&t(b,{className:"text-right",children:m("div",{className:"flex justify-end gap-1.5",children:[v!==void 0&&t(Y,{"data-testid":`dlq-retry-${u.id}`,onClick:()=>{A(T(v(u.id)))},size:"sm",type:"button",variant:"outline",children:r("Retry")}),S!==void 0&&t(G,{confirmLabel:r("Drop job?"),onConfirm:()=>{A(T(S(u.id)))},testId:`dlq-remove-${u.id}`,children:r("Drop")})]})})]},u.id))})]})})}),e[23]=T,e[24]=J,e[25]=l,e[26]=S,e[27]=v,e[28]=r,e[29]=_):_=e[29];let B;return e[30]!==_||e[31]!==L||e[32]!==w?(B=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[L,w,_]}),e[30]=_,e[31]=L,e[32]=w,e[33]=B):B=e[33],B};function oe(n,e){return(e.attempts??0)-(n.attempts??0)}const E=n=>{const e=D(8),{label:c,testId:a,value:p}=n;let o;e[0]!==c?(o=t("span",{className:"text-xs text-muted-foreground",children:c}),e[0]=c,e[1]=o):o=e[1];let s;e[2]!==a||e[3]!==p?(s=t("span",{className:"text-2xl font-semibold tabular-nums","data-testid":a,children:p}),e[2]=a,e[3]=p,e[4]=s):s=e[4];let r;return e[5]!==o||e[6]!==s?(r=t(P,{className:"flex-1 py-0",children:m(R,{className:"flex flex-col gap-1 p-4",children:[o,s]})}),e[5]=o,e[6]=s,e[7]=r):r=e[7],r},ae=n=>{const e=D(25);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadStatus:a}=c,p=H(),o=M(),s=a===void 0;let r;e[2]!==s?(r=["lunora-scheduler-status",s],e[2]=s,e[3]=r):r=e[3];let y;e[4]!==p||e[5]!==a?(y=async()=>{const k=await(a??(()=>p.schedulerStatus()))();return{...k,pools:k.pools.toSorted(ie)}},e[4]=p,e[5]=a,e[6]=y):y=e[6];const h=z(r,y),{data:i,error:l}=h;let d;e[7]!==h?(d=()=>h.poll(),e[7]=h,e[8]=d):d=e[8],X(d,!0);let g;e[9]!==l?(g=l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:l}),e[9]=l,e[10]=g):g=e[10];let N;e[11]!==i||e[12]!==o?(N=i!==void 0&&m("div",{className:"flex gap-3","data-testid":"pools-totals",children:[t(E,{label:o("backlog"),testId:"pools-backlog",value:i.backlog}),t(E,{label:o("in flight"),testId:"pools-inflight",value:i.inFlight}),t(E,{label:o("pools"),testId:"pools-count",value:i.pools.length})]}),e[11]=i,e[12]=o,e[13]=N):N=e[13];let f;e[14]!==i?.pools.length||e[15]!==o?(f=i?.pools.length===0&&t(V,{description:o("Pools created with createWorkpool appear here once they have activity."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:o("No workpools.")}),e[14]=i?.pools.length,e[15]=o,e[16]=f):f=e[16];let C;e[17]!==i||e[18]!==o?(C=i!==void 0&&i.pools.length>0&&t(P,{className:"overflow-hidden py-0",children:t(R,{className:"px-0",children:m(W,{"data-testid":"pools-table",children:[t(Q,{children:m(q,{children:[t(x,{children:o("pool")}),t(x,{children:o("queued")}),t(x,{children:o("in flight")}),t(x,{children:o("max concurrency")})]})}),t(K,{children:i.pools.map(de)})]})})}),e[17]=i,e[18]=o,e[19]=C):C=e[19];let v;return e[20]!==g||e[21]!==N||e[22]!==f||e[23]!==C?(v=m("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[g,N,f,C]}),e[20]=g,e[21]=N,e[22]=f,e[23]=C,e[24]=v):v=e[24],v};function ie(n,e){return e.queued-n.queued}function de(n){return m(q,{"data-testid":`pools-row-${n.name}`,children:[t(b,{className:"font-mono text-xs",children:n.name}),t(b,{className:"tabular-nums",children:n.queued}),m(b,{className:"tabular-nums",children:[n.inFlight," / ",n.maxConcurrency]}),t(b,{className:"tabular-nums",children:n.maxConcurrency})]},n.name)}const ce=["jobs","dead","pools","cron"],Ie=n=>{const e=D(41);let c;e[0]!==n?(c=n===void 0?{}:n,e[0]=n,e[1]=c):c=e[1];const{loadCronJobs:a,scheduledCancel:p,scheduledLoad:o}=c,s=M(),[r,y]=F("jobs");let h;e[2]!==s?(h=s("Cron triggers"),e[2]=s,e[3]=h):h=e[3];let i;e[4]!==s?(i=s("Dead letter"),e[4]=s,e[5]=i):i=e[5];let l;e[6]!==s?(l=s("Scheduled jobs"),e[6]=s,e[7]=l):l=e[7];let d;e[8]!==s?(d=s("Pools"),e[8]=s,e[9]=d):d=e[9];let g;e[10]!==h||e[11]!==i||e[12]!==l||e[13]!==d?(g={cron:h,dead:i,jobs:l,pools:d},e[10]=h,e[11]=i,e[12]=l,e[13]=d,e[14]=g):g=e[14];const N=g;let f;e[15]===Symbol.for("react.memo_cache_sentinel")?(f=w=>{y(w.currentTarget.dataset.view)},e[15]=f):f=e[15];const C=f;let v;e[16]!==s?(v=s("Schedule view"),e[16]=s,e[17]=v):v=e[17];let k;e[18]!==r||e[19]!==N?(k=ce.map(w=>t(Y,{"aria-selected":r===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:C,role:"tab",size:"sm",type:"button",variant:r===w?"default":"outline",children:N[w]},w)),e[18]=r,e[19]=N,e[20]=k):k=e[20];let S;e[21]!==v||e[22]!==k?(S=t("div",{"aria-label":v,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:k}),e[21]=v,e[22]=k,e[23]=S):S=e[23];let $;e[24]!==p||e[25]!==o||e[26]!==r?($=r==="jobs"&&t(ee,{cancelJob:p,loadJobs:o}),e[24]=p,e[25]=o,e[26]=r,e[27]=$):$=e[27];let I;e[28]!==r?(I=r==="dead"&&t(ne,{}),e[28]=r,e[29]=I):I=e[29];let T;e[30]!==r?(T=r==="pools"&&t(ae,{}),e[30]=r,e[31]=T):T=e[31];let J;e[32]!==a||e[33]!==r?(J=r==="cron"&&t(le,{loadCronJobs:a}),e[32]=a,e[33]=r,e[34]=J):J=e[34];let L;return e[35]!==S||e[36]!==$||e[37]!==I||e[38]!==T||e[39]!==J?(L=m("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[S,$,I,T,J]}),e[35]=S,e[36]=$,e[37]=I,e[38]=T,e[39]=J,e[40]=L):L=e[40],L};export{Ie as SchedulePanel};
@@ -1 +1 @@
1
- import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{B as R}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as T,a as k}from"../packem_shared/card-By2O8ULa.mjs";import{E as S}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as u,jsx as r}from"react/jsx-runtime";const I=(e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],b={delete:2,list:3,read:0,write:1},O=e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||b[t.on]-b[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),M=()=>{const e=y(14),t=E();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const{data:l,error:d,errorSource:i}=A(v.storageRules,a),h=l!==void 0;let n;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==t){const x=O(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==d||e[8]!==i?(c=d!==null&&r(N,{error:i,testId:"storage-rules-error"}),e[7]=d,e[8]=i,e[9]=c):c=e[9];let s;e[10]!==t?(s=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=s):s=e[11];let m;e[12]!==s?(m=r("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s}),e[12]=s,e[13]=m):m=e[13],n=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&x.length===0?r(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):r(T,{className:"overflow-hidden py-0",children:r(k,{className:"px-0",children:u(w,{"data-testid":"storage-rules-table",children:[r(C,{children:u(g,{children:[r(f,{children:t("Bucket")}),r(f,{children:t("Operation")}),r(f,{children:t("Key prefix")}),r(f,{children:t("Guarded by")})]})}),r($,{children:x.map(o=>u(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[r(p,{className:"font-mono text-xs",children:o.bucket}),r(p,{children:r(R,{variant:"secondary",children:I(t,o.on)})}),r(p,{className:"font-mono text-xs",children:o.prefix??r("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),r(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=t,e[6]=n}else n=e[6];return n};export{M as default};
1
+ import{c as y}from"react/compiler-runtime";import{E as N}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{B as R}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as T,a as k}from"../packem_shared/card-By2O8ULa.mjs";import{E as S}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as w,a as C,b as g,c as f,d as $,e as p}from"../packem_shared/table-D0SBiDu-.mjs";import{u as A}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{jsxs as u,jsx as r}from"react/jsx-runtime";const I=(e,t)=>({delete:e("Delete"),list:e("List"),read:e("Read"),write:e("Write")})[t],b={delete:2,list:3,read:0,write:1},O=e=>[...e].toSorted((t,a)=>t.bucket.localeCompare(a.bucket)||b[t.on]-b[a.on]||(t.prefix??"").localeCompare(a.prefix??"")),M=()=>{const e=y(14),t=E();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const{data:l,error:d,errorSource:i}=A(v.storageRules,a),h=l!==void 0;let n;if(e[1]!==l||e[2]!==d||e[3]!==i||e[4]!==h||e[5]!==t){const x=O(Array.isArray(l?.rules)?l.rules:[]);let c;e[7]!==d||e[8]!==i?(c=d!==null&&r(N,{error:i,testId:"storage-rules-error"}),e[7]=d,e[8]=i,e[9]=c):c=e[9];let s;e[10]!==t?(s=t("Storage rules are declared in code with defineStorageRule and gate ctx.storage access per bucket. This view is read-only."),e[10]=t,e[11]=s):s=e[11];let m;e[12]!==s?(m=r("p",{className:"text-sm text-muted-foreground","data-testid":"storage-rules-note",children:s}),e[12]=s,e[13]=m):m=e[13],n=u("div",{className:"flex flex-col gap-4","data-testid":"lunora-storage-rules-panel",children:[c,m,h&&x.length===0?r(S,{description:t("No defineStorageRule is wired through .use(storageRules(...)) in this deployment. Add one to gate object access by key prefix."),testId:"storage-rules-empty",title:t("No storage rules defined")}):r(T,{className:"overflow-hidden py-0",children:r(k,{className:"px-0",children:u(w,{"data-testid":"storage-rules-table",children:[r(C,{children:u(g,{children:[r(f,{children:t("Bucket")}),r(f,{children:t("Operation")}),r(f,{children:t("Key prefix")}),r(f,{children:t("Guarded by")})]})}),r($,{children:x.map(o=>u(g,{"data-testid":`storage-rule-${o.bucket}-${o.on}-${o.prefix??""}`,children:[r(p,{className:"font-mono text-xs",children:o.bucket}),r(p,{children:r(R,{variant:"secondary",children:I(t,o.on)})}),r(p,{className:"font-mono text-xs",children:o.prefix??r("span",{className:"text-muted-foreground",children:t("(whole bucket)")})}),r(p,{className:"font-mono text-xs text-muted-foreground",children:o.procedure})]},`${o.bucket}:${o.on}:${o.prefix??""}:${o.procedure}`))})]})})})]}),e[1]=l,e[2]=d,e[3]=i,e[4]=h,e[5]=t,e[6]=n}else n=e[6];return n};export{M as default};
@@ -1 +1 @@
1
- import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as T,c as y,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{k as q}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as a,jsx as t}from"react/jsx-runtime";const w=80,G=c=>{if(c===void 0)return"";const e=JSON.stringify(c,q);return e.length>w?`${e.slice(0,w)}…`:e},J=c=>{const e=[];for(const o of c){const n=o.id.toString();if(o.subscriptions.length===0){e.push({admin:o.admin,connectionId:o.id,key:`c${n}`,subscription:null});continue}o.subscriptions.forEach((u,r)=>{e.push({admin:o.admin,connectionId:o.id,key:`c${n}-s${r.toString()}`,subscription:u})})}return e},C=t("span",{className:"text-muted-foreground",children:"—"}),ae=c=>{const e=R(22),{initialShardKey:o}=c,n=O(),{queryShardKey:u,setShardKey:r,shardKey:m}=L(o);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==u?(f={keepPreviousData:!0,shardKey:u},e[1]=u,e[2]=f):f=e[2];const{data:s,error:i,errorSource:h,poll:K}=P(W.listSubscriptions,p,f);F(K,!0);let b;if(e[3]!==i||e[4]!==h||e[5]!==s||e[6]!==r||e[7]!==m||e[8]!==n){const N=s===void 0?[]:J(s.connections);let l;e[10]!==r||e[11]!==m?(l=t(E,{onChange:r,testId:"subs-shard-input",value:m}),e[10]=r,e[11]=m,e[12]=l):l=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&a("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(A,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),t(A,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==l||e[17]!==d?(g=a("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]}),e[16]=l,e[17]=d,e[18]=g):g=e[18];let x;e[19]!==i||e[20]!==h?(x=i!==null&&t(j,{error:h,testId:"subs-error"}),e[19]=i,e[20]=h,e[21]=x):x=e[21],b=a("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,i===null&&s!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:a(_,{"data-testid":"subs-table",children:[t(D,{children:a(T,{children:[t(y,{children:n("Connection")}),t(y,{children:n("Function path")}),t(y,{children:n("Table")}),t(y,{children:n("Arguments")})]})}),t(H,{children:N.map(v=>{const{subscription:k}=v,I=G(k?.args);return a(T,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:a("span",{className:"inline-flex items-center gap-1.5",children:["#",v.connectionId,v.admin&&t(A,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:k?.functionPath??C}),t(S,{children:k?.table??C}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:I||void 0,children:I||C})]},v.key)})})]})})})]}),e[3]=i,e[4]=h,e[5]=s,e[6]=r,e[7]=m,e[8]=n,e[9]=b}else b=e[9];return b};export{ae as default};
1
+ import{c as R}from"react/compiler-runtime";import{E as j}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{ShardInput as E}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as A}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as M,a as $}from"../packem_shared/card-By2O8ULa.mjs";import{E as B}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as _,a as D,b as T,c as y,d as H,e as S}from"../packem_shared/table-D0SBiDu-.mjs";import{u as P}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{u as L}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as O}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as W}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{k as q}from"../packem_shared/internal-BXEjuLPN.mjs";import{jsxs as a,jsx as t}from"react/jsx-runtime";const w=80,G=c=>{if(c===void 0)return"";const e=JSON.stringify(c,q);return e.length>w?`${e.slice(0,w)}…`:e},J=c=>{const e=[];for(const o of c){const n=o.id.toString();if(o.subscriptions.length===0){e.push({admin:o.admin,connectionId:o.id,key:`c${n}`,subscription:null});continue}o.subscriptions.forEach((u,r)=>{e.push({admin:o.admin,connectionId:o.id,key:`c${n}-s${r.toString()}`,subscription:u})})}return e},C=t("span",{className:"text-muted-foreground",children:"—"}),ae=c=>{const e=R(22),{initialShardKey:o}=c,n=O(),{queryShardKey:u,setShardKey:r,shardKey:m}=L(o);let p;e[0]===Symbol.for("react.memo_cache_sentinel")?(p={},e[0]=p):p=e[0];let f;e[1]!==u?(f={keepPreviousData:!0,shardKey:u},e[1]=u,e[2]=f):f=e[2];const{data:s,error:i,errorSource:h,poll:K}=P(W.listSubscriptions,p,f);F(K,!0);let b;if(e[3]!==i||e[4]!==h||e[5]!==s||e[6]!==r||e[7]!==m||e[8]!==n){const N=s===void 0?[]:J(s.connections);let l;e[10]!==r||e[11]!==m?(l=t(E,{onChange:r,testId:"subs-shard-input",value:m}),e[10]=r,e[11]=m,e[12]=l):l=e[12];let d;e[13]!==s||e[14]!==n?(d=s!==void 0&&a("div",{className:"ml-auto flex items-center gap-2 text-sm text-muted-foreground","data-testid":"subs-count",children:[t(A,{variant:"secondary",children:n("{count} connections",{count:s.totalConnections})}),t(A,{variant:"secondary",children:n("{count} subscriptions",{count:s.totalSubscriptions})})]}),e[13]=s,e[14]=n,e[15]=d):d=e[15];let g;e[16]!==l||e[17]!==d?(g=a("div",{className:"flex flex-wrap items-center gap-2",children:[l,d]}),e[16]=l,e[17]=d,e[18]=g):g=e[18];let x;e[19]!==i||e[20]!==h?(x=i!==null&&t(j,{error:h,testId:"subs-error"}),e[19]=i,e[20]=h,e[21]=x):x=e[21],b=a("div",{className:"flex flex-col gap-4","data-testid":"subs-panel",children:[g,x,i===null&&s!==void 0&&N.length===0&&t(B,{description:n("Active WebSocket subscriptions on this shard."),icon:t("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:t("path",{d:"M5 12a7 7 0 0 1 14 0M8 12a4 4 0 0 1 8 0M12 12v8m0-8a1 1 0 1 0 0-2 1 1 0 0 0 0 2Z"})}),testId:"subs-empty",title:n("No active subscriptions.")}),i===null&&N.length>0&&t(M,{className:"overflow-hidden py-0",children:t($,{className:"px-0",children:a(_,{"data-testid":"subs-table",children:[t(D,{children:a(T,{children:[t(y,{children:n("Connection")}),t(y,{children:n("Function path")}),t(y,{children:n("Table")}),t(y,{children:n("Arguments")})]})}),t(H,{children:N.map(v=>{const{subscription:k}=v,I=G(k?.args);return a(T,{"data-testid":"subs-row",children:[t(S,{className:"font-medium tabular-nums",children:a("span",{className:"inline-flex items-center gap-1.5",children:["#",v.connectionId,v.admin&&t(A,{variant:"outline",children:n("admin")})]})}),t(S,{className:"font-mono text-xs",children:k?.functionPath??C}),t(S,{children:k?.table??C}),t(S,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:I||void 0,children:I||C})]},v.key)})})]})})})]}),e[3]=i,e[4]=h,e[5]=s,e[6]=r,e[7]=m,e[8]=n,e[9]=b}else b=e[9];return b};export{ae as default};
@@ -1 +1 @@
1
- import{c as q}from"react/compiler-runtime";import{useLunora as I}from"@lunora/react";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card-By2O8ULa.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as r}from"../packem_shared/table-D0SBiDu-.mjs";import{a as Q}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{useAutoRefresh as V}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-DvhNw0BI.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{jsx as n,jsxs as s}from"react/jsx-runtime";const $=2e3,z=new Set(["open"]),ie=W=>{const e=q(41),{read:S}=W,t=Y(),L=I();let T;e[0]!==L||e[1]!==S?(T=()=>Promise.resolve(S?S():L.debug()),e[0]=L,e[1]=S,e[2]=T):T=e[2];const M=T,A=S?"injected":"live";let x;e[3]!==A?(x=["lunora-studio","sync-client-debug",A],e[3]=A,e[4]=x):x=e[4];const{data:c,poll:O}=Q(x,M);if(V(O,!0,$),!c){let i;e[5]!==t?(i=t("Reading the sync client's state…"),e[5]=t,e[6]=i):i=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let k;return e[9]!==i||e[10]!==g?(k=n(R,{children:n(H,{children:n(P,{description:i,title:g})})}),e[9]=i,e[10]=g,e[11]=k):k=e[11],k}const{pendingWrites:v,shards:C,subscriptions:b}=c;let a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let o;e[14]!==a?(o=n("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=o):o=e[15];const E=c.connectionStatus==="connected"?"default":"secondary";let d;e[16]!==c.connectionStatus||e[17]!==E?(d=n(_,{variant:E,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=E,e[18]=d):d=e[18];let h;e[19]!==v||e[20]!==t?(h=v>0?n(_,{variant:"secondary",children:t("{count} pending writes",{count:v})}):null,e[19]=v,e[20]=t,e[21]=h):h=e[21];let f;e[22]!==o||e[23]!==d||e[24]!==h?(f=s("div",{className:"flex flex-wrap items-center gap-2",children:[o,d,h]}),e[22]=o,e[23]=d,e[24]=h,e[25]=f):f=e[25];let m;e[26]!==t?(m=t("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=m):m=e[27];let u;e[28]!==m?(u=n("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=u):u=e[29];let p;e[30]!==C||e[31]!==t?(p=C.length===0?n(P,{description:t("No shard connection has been opened yet."),title:t("No shards")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Shard")}),n(l,{children:t("Socket")}),n(l,{children:t("Confirmed watermark")})]})}),n(K,{children:C.map(i=>s(w,{children:[n(r,{children:i.shardKey??t("(default)")}),n(r,{children:n(_,{variant:z.has(i.wsState)?"default":"secondary",children:i.wsState})}),n(r,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=C,e[31]=t,e[32]=p):p=e[32];let y;e[33]!==b||e[34]!==t?(y=b.length===0?n(P,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):s(j,{children:[n(B,{children:s(w,{children:[n(l,{children:t("Subscription")}),n(l,{children:t("Kind")}),n(l,{children:t("Acked")}),n(l,{children:t("Cursor")}),n(l,{children:t("Pending overlays")})]})}),n(K,{children:b.map(i=>s(w,{children:[n(r,{className:"font-mono text-xs",children:i.functionPath}),n(r,{children:i.kind}),n(r,{children:n(_,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),n(r,{children:i.serverCursor??"—"}),n(r,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=b,e[34]=t,e[35]=y):y=e[35];let N;return e[36]!==u||e[37]!==p||e[38]!==y||e[39]!==f?(N=n(R,{children:s(H,{className:"flex flex-col gap-4",children:[f,u,p,y]})}),e[36]=u,e[37]=p,e[38]=y,e[39]=f,e[40]=N):N=e[40],N};export{ie as default};
1
+ import{c as q}from"react/compiler-runtime";import{B as _}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as R,a as H}from"../packem_shared/card-By2O8ULa.mjs";import{E as P}from"../packem_shared/empty-state-D7jEML_T.mjs";import{T as j,a as B,b as w,c as l,d as K,e as s}from"../packem_shared/table-D0SBiDu-.mjs";import{a as I}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{useAutoRefresh as Q}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import{u as V}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as Y}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{jsx as n,jsxs as r}from"react/jsx-runtime";const $=2e3,z=new Set(["open"]),ie=W=>{const e=q(41),{read:g}=W,t=Y(),A=V();let T;e[0]!==A||e[1]!==g?(T=()=>Promise.resolve(g?g():A.debug()),e[0]=A,e[1]=g,e[2]=T):T=e[2];const M=T,E=g?"injected":"live";let x;e[3]!==E?(x=["lunora-studio","sync-client-debug",E],e[3]=E,e[4]=x):x=e[4];const{data:c,poll:O}=I(x,M);if(Q(O,!0,$),!c){let i;e[5]!==t?(i=t("Reading the sync client's state…"),e[5]=t,e[6]=i):i=e[6];let S;e[7]!==t?(S=t("Sync client"),e[7]=t,e[8]=S):S=e[8];let k;return e[9]!==i||e[10]!==S?(k=n(R,{children:n(H,{children:n(P,{description:i,title:S})})}),e[9]=i,e[10]=S,e[11]=k):k=e[11],k}const{pendingWrites:C,shards:v,subscriptions:b}=c;let a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let o;e[14]!==a?(o=n("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=o):o=e[15];const L=c.connectionStatus==="connected"?"default":"secondary";let d;e[16]!==c.connectionStatus||e[17]!==L?(d=n(_,{variant:L,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=L,e[18]=d):d=e[18];let h;e[19]!==C||e[20]!==t?(h=C>0?n(_,{variant:"secondary",children:t("{count} pending writes",{count:C})}):null,e[19]=C,e[20]=t,e[21]=h):h=e[21];let f;e[22]!==o||e[23]!==d||e[24]!==h?(f=r("div",{className:"flex flex-wrap items-center gap-2",children:[o,d,h]}),e[22]=o,e[23]=d,e[24]=h,e[25]=f):f=e[25];let m;e[26]!==t?(m=t("Reads client.debug() for the client running in this page — not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=m):m=e[27];let u;e[28]!==m?(u=n("p",{className:"text-muted-foreground text-xs",children:m}),e[28]=m,e[29]=u):u=e[29];let p;e[30]!==v||e[31]!==t?(p=v.length===0?n(P,{description:t("No shard connection has been opened yet."),title:t("No shards")}):r(j,{children:[n(B,{children:r(w,{children:[n(l,{children:t("Shard")}),n(l,{children:t("Socket")}),n(l,{children:t("Confirmed watermark")})]})}),n(K,{children:v.map(i=>r(w,{children:[n(s,{children:i.shardKey??t("(default)")}),n(s,{children:n(_,{variant:z.has(i.wsState)?"default":"secondary",children:i.wsState})}),n(s,{children:i.confirmedMutationWatermark})]},i.shardKey??"__default__"))})]}),e[30]=v,e[31]=t,e[32]=p):p=e[32];let y;e[33]!==b||e[34]!==t?(y=b.length===0?n(P,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):r(j,{children:[n(B,{children:r(w,{children:[n(l,{children:t("Subscription")}),n(l,{children:t("Kind")}),n(l,{children:t("Acked")}),n(l,{children:t("Cursor")}),n(l,{children:t("Pending overlays")})]})}),n(K,{children:b.map(i=>r(w,{children:[n(s,{className:"font-mono text-xs",children:i.functionPath}),n(s,{children:i.kind}),n(s,{children:n(_,{variant:i.acked?"default":"secondary",children:i.acked?t("yes"):t("no")})}),n(s,{children:i.serverCursor??"—"}),n(s,{children:i.pendingOptimisticLayers})]},i.id))})]}),e[33]=b,e[34]=t,e[35]=y):y=e[35];let N;return e[36]!==u||e[37]!==p||e[38]!==y||e[39]!==f?(N=n(R,{children:r(H,{className:"flex flex-col gap-4",children:[f,u,p,y]})}),e[36]=u,e[37]=p,e[38]=y,e[39]=f,e[40]=N):N=e[40],N};export{ie as default};
@@ -0,0 +1 @@
1
+ import{c as r}from"react/compiler-runtime";import{motion as s}from"motion/react";import{jsx as i}from"react/jsx-runtime";const a={bounce:.1,duration:.45,type:"spring"},u=n=>{const t=r(2),{className:e}=n;let o;return t[0]!==e?(o=i(s.span,{className:e,layoutId:"studio-theme-active",transition:a}),t[0]=e,t[1]=o):o=t[1],o};export{u as default};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{useState as ee,useEffect as le}from"react";import{E as ge}from"../packem_shared/error-alert-CNQjdAhi.mjs";import{L as be}from"../packem_shared/live-status-BuJdUZFU.mjs";import{ShardInput as xe}from"../packem_shared/ShardInput-C6mjgAh4.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as ye}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{E as Ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ve}from"../packem_shared/input-CXhxesPC.mjs";import{u as oe}from"../packem_shared/use-admin-query-CLStXJ7v.mjs";import{u as we}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-A1Yg5ORA.mjs";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as me,k as Se}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as _e}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{p as Ie,c as ke}from"../packem_shared/trace-handoff-BV3EWqy_.mjs";import{L as Me}from"../packem_shared/log-line-BWDt_F56.mjs";import{f as $e}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{c as ne}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as n,jsxs as k,Fragment as Te}from"react/jsx-runtime";const Le=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Ce=(a,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=ce(a.offsetMs/e*100),s=a.durationMs/e*100,l=Math.max(Le,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ee=(a,e,t=!1)=>{const s=e.trim().toLowerCase(),l=t?a.filter(r=>!r.ok):a;return s===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(s)||r.functionPath.toLowerCase().includes(s)||r.traceId.toLowerCase().includes(s)||r.spans.some(o=>o.name.toLowerCase().includes(s)||o.spanId.toLowerCase().includes(s)))},q=a=>Number.isFinite(a)?a>0&&a<1?`${a.toFixed(2)}ms`:`${String(Math.round(a))}ms`:"—",Pe=a=>!Number.isFinite(a)||a<=0?[]:Array.from({length:de},(e,t)=>{const s=(t+1)/de;return{label:q(a*s),percent:s*100}}),ue=a=>{if(typeof a=="string")return a;try{return JSON.stringify(a,Se)}catch{return String(a)}},Y=a=>{const e=U(7),{label:t,value:s}=a;let l;e[0]!==t?(l=n("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==s?(r=n("dd",{className:"min-w-0 break-all",children:s}),e[2]=s,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=k("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Fe=a=>{const e=U(68),{span:t}=a,s=Z();let l,r,o,i,d,f;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==s){const $=Object.entries(t.attributes??{});let M;e[15]!==t.events?(M=t.events??[],e[15]=t.events,e[16]=M):M=e[16],l=M,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let N;e[17]!==s?(N=s("Span ID"),e[17]=s,e[18]=N):N=e[18];let v;e[19]!==t.spanId||e[20]!==N?(v=n(Y,{label:N,value:t.spanId}),e[19]=t.spanId,e[20]=N,e[21]=v):v=e[21];let w;e[22]!==s?(w=s("Parent span ID"),e[22]=s,e[23]=w):w=e[23];let m;e[24]!==t.parentSpanId||e[25]!==s?(m=t.parentSpanId===""?s("— (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=s,e[26]=m):m=e[26];let u;e[27]!==m||e[28]!==w?(u=n(Y,{label:w,value:m}),e[27]=m,e[28]=w,e[29]=u):u=e[29];let h;e[30]!==s?(h=s("Kind"),e[30]=s,e[31]=h):h=e[31];const T=t.kind??"internal";let _;e[32]!==h||e[33]!==T?(_=n(Y,{label:h,value:T}),e[32]=h,e[33]=T,e[34]=_):_=e[34];let S;e[35]!==s?(S=s("Started at"),e[35]=s,e[36]=S):S=e[36];let g;e[37]!==t.offsetMs||e[38]!==s?(g=s("+{offset}",{offset:q(t.offsetMs)}),e[37]=t.offsetMs,e[38]=s,e[39]=g):g=e[39];let b;e[40]!==S||e[41]!==g?(b=n(Y,{label:S,value:g}),e[40]=S,e[41]=g,e[42]=b):b=e[42];let I;e[43]!==s?(I=s("Duration"),e[43]=s,e[44]=I):I=e[44];let p;e[45]!==t.durationMs?(p=q(t.durationMs),e[45]=t.durationMs,e[46]=p):p=e[46];let x;e[47]!==I||e[48]!==p?(x=n(Y,{label:I,value:p}),e[47]=I,e[48]=p,e[49]=x):x=e[49],e[50]!==u||e[51]!==_||e[52]!==b||e[53]!==x||e[54]!==v?(i=k("dl",{className:"flex flex-col gap-1",children:[v,u,_,b,x]}),e[50]=u,e[51]=_,e[52]=b,e[53]=x,e[54]=v,e[55]=i):i=e[55],e[56]!==t.error?(d=t.error!==void 0&&k("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[n("span",{className:"font-semibold text-destructive",children:t.error.type}),n("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=d):d=e[57],f=$.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Attributes")}),n("dl",{className:"flex flex-col gap-1",children:$.map(Ke)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=s,e[9]=l,e[10]=r,e[11]=o,e[12]=i,e[13]=d,e[14]=f}else l=e[9],r=e[10],o=e[11],i=e[12],d=e[13],f=e[14];let c;e[58]!==l||e[59]!==s?(c=l.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-events",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Events")}),n("ul",{className:"flex flex-col gap-1",children:l.map(Ae)})]}),e[58]=l,e[59]=s,e[60]=c):c=e[60];let y;return e[61]!==r||e[62]!==o||e[63]!==i||e[64]!==d||e[65]!==f||e[66]!==c?(y=k("div",{className:r,"data-testid":o,children:[i,d,f,c]}),e[61]=r,e[62]=o,e[63]=i,e[64]=d,e[65]=f,e[66]=c,e[67]=y):y=e[67],y};function Ke(a){const[e,t]=a;return n(Y,{label:e,value:ue(t)},e)}function Re(a){const[e,t]=a;return`${e}=${ue(t)}`}function Ae(a){return k("li",{className:"flex gap-2",children:[n("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:me(a.ts)}),n(fe,{variant:"secondary",children:a.name}),n("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(a.attributes??{}).map(Re).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",je=a=>{const e=U(17),{traceDurationMs:t}=a;let s,l,r,o,i,d;if(e[0]!==t){d=Symbol.for("react.early_return_sentinel");e:{const y=Pe(t);if(y.length===0){d=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=ne(pe,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(i=n("span",{}),e[8]=i):i=e[8],s="relative h-3",l=y.map(We)}e[0]=t,e[1]=s,e[2]=l,e[3]=r,e[4]=o,e[5]=i,e[6]=d}else s=e[1],l=e[2],r=e[3],o=e[4],i=e[5],d=e[6];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;e[9]!==s||e[10]!==l?(f=n("span",{className:s,children:l}),e[9]=s,e[10]=l,e[11]=f):f=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==i||e[15]!==f?(c=k("div",{className:r,"data-testid":o,children:[i,f]}),e[12]=r,e[13]=o,e[14]=i,e[15]=f,e[16]=c):c=e[16],c},Be=a=>{const e=U(60),{span:t,traceDurationMs:s}=a,l=Z(),[r,o]=ee(!1);let i;e[0]!==t||e[1]!==s?(i=Ce(t,s),e[0]=t,e[1]=s,e[2]=i):i=e[2];const{leftPercent:d,widthPercent:f}=i;let c;e[3]!==t.attributes?(c=$e(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];const y=c,$=t.depth*De;let M;e[5]!==$?(M={paddingLeft:$},e[5]=$,e[6]=M):M=e[6];const N=M,v=`${String(d)}%`,w=`${String(f)}%`;let m;e[7]!==v||e[8]!==w?(m={left:v,width:w},e[7]=v,e[8]=w,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(Ue)},e[10]=h):h=e[10];const T=h,_=t.depth,S=`tr-span-detail-${t.spanId}`;let g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:q(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:q(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=ne(pe,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=b):b=e[17];const I=`tr-span-toggle-${t.spanId}`;let p;e[18]!==t.ok?(p=t.ok?null:n("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"●"}),e[18]=t.ok,e[19]=p):p=e[19];let x;e[20]!==N||e[21]!==t.name||e[22]!==p?(x=k("span",{className:"truncate",style:N,title:t.name,children:[p,t.name]}),e[20]=N,e[21]=t.name,e[22]=p,e[23]=x):x=e[23];const D=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==D?(L=ne("absolute inset-y-0 rounded-sm",D),e[24]=D,e[25]=L):L=e[25];let A;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(A=n("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:n("span",{className:L,"data-left":d,"data-testid":"tr-span-bar","data-width":f,style:u})}),e[26]=u,e[27]=d,e[28]=L,e[29]=f,e[30]=A):A=e[30];let j;e[31]!==t.durationMs?(j=q(t.durationMs),e[31]=t.durationMs,e[32]=j):j=e[32];let F;e[33]!==j?(F=n("span",{className:"text-right tabular-nums text-muted-foreground",children:j}),e[33]=j,e[34]=F):F=e[34];let B;e[35]!==t.error?(B=t.error===void 0?null:n("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=B):B=e[36];let C;e[37]!==B?(C=n("span",{className:"truncate text-muted-foreground",children:B}),e[37]=B,e[38]=C):C=e[38];let O;e[39]!==y?(O=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=O):O=e[40];let E;e[41]!==O?(E=n("span",{className:"truncate text-muted-foreground",children:O}),e[41]=O,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==S||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==A||e[49]!==F||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":S,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,A,F,C,E]}),e[43]=r,e[44]=S,e[45]=g,e[46]=I,e[47]=x,e[48]=A,e[49]=F,e[50]=C,e[51]=E,e[52]=W):W=e[52];let K;e[53]!==r||e[54]!==t?(K=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Fe,{span:t})}),e[53]=r,e[54]=t,e[55]=K):K=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==K?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,K]}),e[56]=t.depth,e[57]=W,e[58]=K,e[59]=P):P=e[59],P},Oe=a=>{const e=U(15),{durationMs:t,spans:s}=a,l=Z();let r;e[0]!==t?(r=n(je,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let i;if(e[4]!==t||e[5]!==s){let c;e[7]!==t?(c=y=>n(Be,{span:y,traceDurationMs:t},y.spanId),e[7]=t,e[8]=c):c=e[8],i=s.map(c),e[4]=t,e[5]=s,e[6]=i}else i=e[6];let d;e[9]!==o||e[10]!==i?(d=n("ul",{"aria-label":o,children:i}),e[9]=o,e[10]=i,e[11]=d):d=e[11];let f;return e[12]!==r||e[13]!==d?(f=k(Te,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function We(a){return n("span",{className:ne("absolute inset-y-0 border-l border-border/70",a.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(a.percent)}%`},children:a.label},a.percent)}function Ue(a){return!a}const qe=a=>Array.isArray(a?.traces)?a.traces:[],ze=a=>{const e=U(12),{entries:t}=a,s=Z();let l;e[0]!==t.length||e[1]!==s?(l=s("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=s,e[2]=l):l=e[2];let r;e[3]!==l?(r=n("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(He),e[5]=t,e[6]=o):o=e[6];let i;e[7]!==o?(i=n("div",{role:"grid",children:o}),e[7]=o,e[8]=i):i=e[8];let d;return e[9]!==r||e[10]!==i?(d=k("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,i]}),e[9]=r,e[10]=i,e[11]=d):d=e[11],d},Ge=a=>{const e=U(50),{expanded:t,logs:s,onToggle:l,trace:r}=a,o=Z();let i;e[0]!==l||e[1]!==r.traceId?(i=()=>{l(r.traceId)},e[0]=l,e[1]=r.traceId,e[2]=i):i=e[2];const d=i,f=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,y=`tr-toggle-${r.traceId}`,$=t?"▾":"▸";let M;e[3]!==$?(M=n("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=M):M=e[4];let N;e[5]!==r.rootName?(N=n("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=N):N=e[6];let v;e[7]!==r.functionPath?(v=n("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=v):v=e[8];let w;e[9]!==r.durationMs?(w=q(r.durationMs),e[9]=r.durationMs,e[10]=w):w=e[10];let m;e[11]!==w?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:w}),e[11]=w,e[12]=m):m=e[12];let u;e[13]!==o||e[14]!==r.spans.length?(u=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=u):u=e[15];let h;e[16]!==u?(h=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:u}),e[16]=u,e[17]=h):h=e[17];const T=r.ok?"secondary":"destructive";let _;e[18]!==o||e[19]!==r.ok?(_=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=_):_=e[20];let S;e[21]!==T||e[22]!==_?(S=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=S):S=e[23];let g;e[24]!==r.startTs?(g=me(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let b;e[26]!==g?(b=n("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=b):b=e[27];let I;e[28]!==t||e[29]!==d||e[30]!==m||e[31]!==h||e[32]!==S||e[33]!==b||e[34]!==c||e[35]!==y||e[36]!==M||e[37]!==N||e[38]!==v?(I=k("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":y,onClick:d,type:"button",children:[M,N,v,m,h,S,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=S,e[33]=b,e[34]=c,e[35]=y,e[36]=M,e[37]=N,e[38]=v,e[39]=I):I=e[39];let p;e[40]!==t||e[41]!==s||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(p=t&&k("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[n(Oe,{durationMs:r.durationMs,spans:r.spans}),s.length>0&&n(ze,{entries:s})]}),e[40]=t,e[41]=s,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=p):p=e[45];let x;return e[46]!==I||e[47]!==p||e[48]!==f?(x=k("div",{className:"border-b border-border last:border-b-0","data-testid":f,children:[I,p]}),e[46]=I,e[47]=p,e[48]=f,e[49]=x):x=e[49],x},bt=a=>{const e=U(58),{initialShardKey:t}=a,s=Z(),[l]=ee(Ie),{queryShardKey:r,setShardKey:o,shardKey:i}=we(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(Je);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Qe,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let w;e[2]!==r?(w={live:!0,shardKey:r},e[2]=r,e[3]=w):w=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,w);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S={},e[4]=S):S=e[4];const g=$.size>0;let b;e[5]!==r||e[6]!==g?(b={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=b):b=e[7];const{data:I}=oe(ie.getLogs,S,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&_e(r)},x=[m,r],e[8]=m,e[9]=r,e[10]=p,e[11]=x):(p=e[10],x=e[11]),le(p,x);let D;if(e[12]!==m||e[13]!==u||e[14]!==h||e[15]!==$||e[16]!==T||e[17]!==_||e[18]!==I?.entries||e[19]!==c||e[20]!==d||e[21]!==o||e[22]!==i||e[23]!==s){const L=qe(m),A=m?.total??L.length,j=A>L.length,F=Ee(L,d,c),B=Map.groupBy((I?.entries??[]).toReversed(),Ve);let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{f(R.target.value)},e[25]=C):C=e[25];const O=C;let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=R=>{M(he=>{const ae=new Set(he);return ae.has(R)?ae.delete(R):ae.add(R),ae})},e[26]=E):E=e[26];const W=E,K=u===null&&F.length===0&&!T;let P;e[27]!==o||e[28]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[27]=o,e[28]=i,e[29]=P):P=e[29];let z;e[30]!==s?(z=s("Search traces"),e[30]=s,e[31]=z):z=e[31];let G;e[32]!==s?(G=s("search trace, span, or function"),e[32]=s,e[33]=G):G=e[33];let H;e[34]!==d||e[35]!==z||e[36]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:O,placeholder:G,value:d}),e[34]=d,e[35]=z,e[36]=G,e[37]=H):H=e[37];let J;e[38]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[38]=c,e[39]=J):J=e[39];let Q;e[40]!==s?(Q=s("Errors only"),e[40]=s,e[41]=Q):Q=e[41];let V;e[42]!==J||e[43]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[42]=J,e[43]=Q,e[44]=V):V=e[44];let X;e[45]!==_?(X=n(be,{message:_,prefix:"tr"}),e[45]=_,e[46]=X):X=e[46];let te;e[47]!==P||e[48]!==H||e[49]!==V||e[50]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[47]=P,e[48]=H,e[49]=V,e[50]=X,e[51]=te):te=e[51];let re;e[52]!==u||e[53]!==h?(re=u!==null&&n(ge,{error:h,testId:"tr-error"}),e[52]=u,e[53]=h,e[54]=re):re=e[54];let se;e[55]!==K||e[56]!==s?(se=K&&n(Ne,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),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:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[55]=K,e[56]=s,e[57]=se):se=e[57],D=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&j&&n("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:L.length,total:A})}),u===null&&F.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:F.map(R=>n(Ge,{expanded:$.has(R.traceId),logs:B.get(R.traceId)??[],onToggle:W,trace:R},R.traceId))})]}),e[12]=m,e[13]=u,e[14]=h,e[15]=$,e[16]=T,e[17]=_,e[18]=I?.entries,e[19]=c,e[20]=d,e[21]=o,e[22]=i,e[23]=s,e[24]=D}else D=e[24];return D};function He(a,e){return n("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:n(Me,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function Je(){return new Set}function Qe(){ke()}function Ve(a){return a.traceId}export{bt as default};
1
+ import{c as U}from"react/compiler-runtime";import{useState as ee,useEffect as le}from"react";import{E as ge}from"../packem_shared/error-alert-54TiaMvZ.mjs";import{L as be}from"../packem_shared/live-status-D1GasNsH.mjs";import{ShardInput as xe}from"../packem_shared/ShardInput-CoySruKZ.mjs";import{B as fe}from"../packem_shared/badge-r_5B4LHP.mjs";import{C as ye}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{E as Ne}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ve}from"../packem_shared/input-CXhxesPC.mjs";import{u as oe}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{u as we}from"../packem_shared/use-shard-key-BsP3o5wT.mjs";import{useT as Z}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as ie}from"../packem_shared/ADMIN_FUNCTIONS-B8yyk5BX.mjs";import{h as me,k as Se}from"../packem_shared/internal-BXEjuLPN.mjs";import{r as _e}from"../packem_shared/shard-history-CaO3C4KQ.mjs";import{p as Ie,c as ke}from"../packem_shared/trace-handoff-BV3EWqy_.mjs";import{L as Me}from"../packem_shared/log-line-BWDt_F56.mjs";import{f as $e}from"../packem_shared/log-fields-BolUoZ9g.mjs";import{c as ne}from"../packem_shared/utils-bhneXptQ.mjs";import{jsx as n,jsxs as k,Fragment as Te}from"react/jsx-runtime";const Le=.5,de=4,ce=a=>Math.min(100,Math.max(0,a)),Ce=(a,e)=>{if(!Number.isFinite(e)||e<=0)return{leftPercent:0,widthPercent:100};const t=ce(a.offsetMs/e*100),s=a.durationMs/e*100,l=Math.max(Le,Math.min(ce(s),100-t));return{leftPercent:t,widthPercent:l}},Ee=(a,e,t=!1)=>{const s=e.trim().toLowerCase(),l=t?a.filter(r=>!r.ok):a;return s===""?[...l]:l.filter(r=>r.rootName.toLowerCase().includes(s)||r.functionPath.toLowerCase().includes(s)||r.traceId.toLowerCase().includes(s)||r.spans.some(o=>o.name.toLowerCase().includes(s)||o.spanId.toLowerCase().includes(s)))},q=a=>Number.isFinite(a)?a>0&&a<1?`${a.toFixed(2)}ms`:`${String(Math.round(a))}ms`:"—",Pe=a=>!Number.isFinite(a)||a<=0?[]:Array.from({length:de},(e,t)=>{const s=(t+1)/de;return{label:q(a*s),percent:s*100}}),ue=a=>{if(typeof a=="string")return a;try{return JSON.stringify(a,Se)}catch{return String(a)}},Y=a=>{const e=U(7),{label:t,value:s}=a;let l;e[0]!==t?(l=n("dt",{className:"w-40 shrink-0 text-muted-foreground",children:t}),e[0]=t,e[1]=l):l=e[1];let r;e[2]!==s?(r=n("dd",{className:"min-w-0 break-all",children:s}),e[2]=s,e[3]=r):r=e[3];let o;return e[4]!==l||e[5]!==r?(o=k("div",{className:"flex gap-2",children:[l,r]}),e[4]=l,e[5]=r,e[6]=o):o=e[6],o},Fe=a=>{const e=U(68),{span:t}=a,s=Z();let l,r,o,i,d,f;if(e[0]!==t.attributes||e[1]!==t.durationMs||e[2]!==t.error||e[3]!==t.events||e[4]!==t.kind||e[5]!==t.offsetMs||e[6]!==t.parentSpanId||e[7]!==t.spanId||e[8]!==s){const $=Object.entries(t.attributes??{});let M;e[15]!==t.events?(M=t.events??[],e[15]=t.events,e[16]=M):M=e[16],l=M,r="border-t border-border bg-background/60 px-3 py-2 font-mono text-xs",o="tr-span-detail";let N;e[17]!==s?(N=s("Span ID"),e[17]=s,e[18]=N):N=e[18];let v;e[19]!==t.spanId||e[20]!==N?(v=n(Y,{label:N,value:t.spanId}),e[19]=t.spanId,e[20]=N,e[21]=v):v=e[21];let w;e[22]!==s?(w=s("Parent span ID"),e[22]=s,e[23]=w):w=e[23];let m;e[24]!==t.parentSpanId||e[25]!==s?(m=t.parentSpanId===""?s("— (trace root)"):t.parentSpanId,e[24]=t.parentSpanId,e[25]=s,e[26]=m):m=e[26];let u;e[27]!==m||e[28]!==w?(u=n(Y,{label:w,value:m}),e[27]=m,e[28]=w,e[29]=u):u=e[29];let h;e[30]!==s?(h=s("Kind"),e[30]=s,e[31]=h):h=e[31];const T=t.kind??"internal";let _;e[32]!==h||e[33]!==T?(_=n(Y,{label:h,value:T}),e[32]=h,e[33]=T,e[34]=_):_=e[34];let S;e[35]!==s?(S=s("Started at"),e[35]=s,e[36]=S):S=e[36];let g;e[37]!==t.offsetMs||e[38]!==s?(g=s("+{offset}",{offset:q(t.offsetMs)}),e[37]=t.offsetMs,e[38]=s,e[39]=g):g=e[39];let b;e[40]!==S||e[41]!==g?(b=n(Y,{label:S,value:g}),e[40]=S,e[41]=g,e[42]=b):b=e[42];let I;e[43]!==s?(I=s("Duration"),e[43]=s,e[44]=I):I=e[44];let p;e[45]!==t.durationMs?(p=q(t.durationMs),e[45]=t.durationMs,e[46]=p):p=e[46];let x;e[47]!==I||e[48]!==p?(x=n(Y,{label:I,value:p}),e[47]=I,e[48]=p,e[49]=x):x=e[49],e[50]!==u||e[51]!==_||e[52]!==b||e[53]!==x||e[54]!==v?(i=k("dl",{className:"flex flex-col gap-1",children:[v,u,_,b,x]}),e[50]=u,e[51]=_,e[52]=b,e[53]=x,e[54]=v,e[55]=i):i=e[55],e[56]!==t.error?(d=t.error!==void 0&&k("div",{className:"mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1.5","data-testid":"tr-detail-error",children:[n("span",{className:"font-semibold text-destructive",children:t.error.type}),n("p",{className:"whitespace-pre-wrap break-all text-destructive",children:t.error.message})]}),e[56]=t.error,e[57]=d):d=e[57],f=$.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-attributes",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Attributes")}),n("dl",{className:"flex flex-col gap-1",children:$.map(Ke)})]}),e[0]=t.attributes,e[1]=t.durationMs,e[2]=t.error,e[3]=t.events,e[4]=t.kind,e[5]=t.offsetMs,e[6]=t.parentSpanId,e[7]=t.spanId,e[8]=s,e[9]=l,e[10]=r,e[11]=o,e[12]=i,e[13]=d,e[14]=f}else l=e[9],r=e[10],o=e[11],i=e[12],d=e[13],f=e[14];let c;e[58]!==l||e[59]!==s?(c=l.length>0&&k("div",{className:"mt-2","data-testid":"tr-detail-events",children:[n("p",{className:"mb-1 text-muted-foreground",children:s("Events")}),n("ul",{className:"flex flex-col gap-1",children:l.map(Ae)})]}),e[58]=l,e[59]=s,e[60]=c):c=e[60];let y;return e[61]!==r||e[62]!==o||e[63]!==i||e[64]!==d||e[65]!==f||e[66]!==c?(y=k("div",{className:r,"data-testid":o,children:[i,d,f,c]}),e[61]=r,e[62]=o,e[63]=i,e[64]=d,e[65]=f,e[66]=c,e[67]=y):y=e[67],y};function Ke(a){const[e,t]=a;return n(Y,{label:e,value:ue(t)},e)}function Re(a){const[e,t]=a;return`${e}=${ue(t)}`}function Ae(a){return k("li",{className:"flex gap-2",children:[n("span",{className:"shrink-0 tabular-nums text-muted-foreground",children:me(a.ts)}),n(fe,{variant:"secondary",children:a.name}),n("span",{className:"min-w-0 break-all text-muted-foreground",children:Object.entries(a.attributes??{}).map(Re).join(" ")})]},`${a.name}:${String(a.ts)}`)}const De=14,pe="grid grid-cols-[14rem_1fr_4rem_16rem_16rem] items-center gap-2 px-3",je=a=>{const e=U(17),{traceDurationMs:t}=a;let s,l,r,o,i,d;if(e[0]!==t){d=Symbol.for("react.early_return_sentinel");e:{const y=Pe(t);if(y.length===0){d=null;break e}e[7]===Symbol.for("react.memo_cache_sentinel")?(r=ne(pe,"border-b border-border py-1 font-mono text-[10px] text-muted-foreground"),e[7]=r):r=e[7],o="tr-ruler",e[8]===Symbol.for("react.memo_cache_sentinel")?(i=n("span",{}),e[8]=i):i=e[8],s="relative h-3",l=y.map(We)}e[0]=t,e[1]=s,e[2]=l,e[3]=r,e[4]=o,e[5]=i,e[6]=d}else s=e[1],l=e[2],r=e[3],o=e[4],i=e[5],d=e[6];if(d!==Symbol.for("react.early_return_sentinel"))return d;let f;e[9]!==s||e[10]!==l?(f=n("span",{className:s,children:l}),e[9]=s,e[10]=l,e[11]=f):f=e[11];let c;return e[12]!==r||e[13]!==o||e[14]!==i||e[15]!==f?(c=k("div",{className:r,"data-testid":o,children:[i,f]}),e[12]=r,e[13]=o,e[14]=i,e[15]=f,e[16]=c):c=e[16],c},Be=a=>{const e=U(60),{span:t,traceDurationMs:s}=a,l=Z(),[r,o]=ee(!1);let i;e[0]!==t||e[1]!==s?(i=Ce(t,s),e[0]=t,e[1]=s,e[2]=i):i=e[2];const{leftPercent:d,widthPercent:f}=i;let c;e[3]!==t.attributes?(c=$e(t.attributes),e[3]=t.attributes,e[4]=c):c=e[4];const y=c,$=t.depth*De;let M;e[5]!==$?(M={paddingLeft:$},e[5]=$,e[6]=M):M=e[6];const N=M,v=`${String(d)}%`,w=`${String(f)}%`;let m;e[7]!==v||e[8]!==w?(m={left:v,width:w},e[7]=v,e[8]=w,e[9]=m):m=e[9];const u=m;let h;e[10]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{o(Ue)},e[10]=h):h=e[10];const T=h,_=t.depth,S=`tr-span-detail-${t.spanId}`;let g;e[11]!==t.durationMs||e[12]!==t.error||e[13]!==t.name||e[14]!==t.offsetMs||e[15]!==l?(g=l("{name}, {duration}, starts {offset} in{failure}",{duration:q(t.durationMs),failure:t.error===void 0?"":l(", failed: {message}",{message:t.error.message}),name:t.name,offset:q(t.offsetMs)}),e[11]=t.durationMs,e[12]=t.error,e[13]=t.name,e[14]=t.offsetMs,e[15]=l,e[16]=g):g=e[16];let b;e[17]===Symbol.for("react.memo_cache_sentinel")?(b=ne(pe,"w-full border-b border-border py-1.5 text-left font-mono text-xs hover:bg-muted/50"),e[17]=b):b=e[17];const I=`tr-span-toggle-${t.spanId}`;let p;e[18]!==t.ok?(p=t.ok?null:n("span",{"aria-hidden":"true",className:"mr-1 text-destructive","data-testid":"tr-span-error",children:"●"}),e[18]=t.ok,e[19]=p):p=e[19];let x;e[20]!==N||e[21]!==t.name||e[22]!==p?(x=k("span",{className:"truncate",style:N,title:t.name,children:[p,t.name]}),e[20]=N,e[21]=t.name,e[22]=p,e[23]=x):x=e[23];const D=t.ok?"bg-primary/70":"bg-destructive";let L;e[24]!==D?(L=ne("absolute inset-y-0 rounded-sm",D),e[24]=D,e[25]=L):L=e[25];let A;e[26]!==u||e[27]!==d||e[28]!==L||e[29]!==f?(A=n("span",{"aria-hidden":"true",className:"relative h-3 overflow-hidden rounded-sm bg-muted",children:n("span",{className:L,"data-left":d,"data-testid":"tr-span-bar","data-width":f,style:u})}),e[26]=u,e[27]=d,e[28]=L,e[29]=f,e[30]=A):A=e[30];let j;e[31]!==t.durationMs?(j=q(t.durationMs),e[31]=t.durationMs,e[32]=j):j=e[32];let F;e[33]!==j?(F=n("span",{className:"text-right tabular-nums text-muted-foreground",children:j}),e[33]=j,e[34]=F):F=e[34];let B;e[35]!==t.error?(B=t.error===void 0?null:n("span",{className:"text-destructive","data-testid":"tr-span-error-message",title:t.error.message,children:`${t.error.type}: ${t.error.message}`}),e[35]=t.error,e[36]=B):B=e[36];let C;e[37]!==B?(C=n("span",{className:"truncate text-muted-foreground",children:B}),e[37]=B,e[38]=C):C=e[38];let O;e[39]!==y?(O=y===""?null:n("span",{"data-testid":"tr-span-attributes",title:y,children:y}),e[39]=y,e[40]=O):O=e[40];let E;e[41]!==O?(E=n("span",{className:"truncate text-muted-foreground",children:O}),e[41]=O,e[42]=E):E=e[42];let W;e[43]!==r||e[44]!==S||e[45]!==g||e[46]!==I||e[47]!==x||e[48]!==A||e[49]!==F||e[50]!==C||e[51]!==E?(W=k("button",{"aria-controls":S,"aria-expanded":r,"aria-label":g,className:b,"data-testid":I,onClick:T,type:"button",children:[x,A,F,C,E]}),e[43]=r,e[44]=S,e[45]=g,e[46]=I,e[47]=x,e[48]=A,e[49]=F,e[50]=C,e[51]=E,e[52]=W):W=e[52];let K;e[53]!==r||e[54]!==t?(K=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Fe,{span:t})}),e[53]=r,e[54]=t,e[55]=K):K=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==K?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,K]}),e[56]=t.depth,e[57]=W,e[58]=K,e[59]=P):P=e[59],P},Oe=a=>{const e=U(15),{durationMs:t,spans:s}=a,l=Z();let r;e[0]!==t?(r=n(je,{traceDurationMs:t}),e[0]=t,e[1]=r):r=e[1];let o;e[2]!==l?(o=l("Trace waterfall"),e[2]=l,e[3]=o):o=e[3];let i;if(e[4]!==t||e[5]!==s){let c;e[7]!==t?(c=y=>n(Be,{span:y,traceDurationMs:t},y.spanId),e[7]=t,e[8]=c):c=e[8],i=s.map(c),e[4]=t,e[5]=s,e[6]=i}else i=e[6];let d;e[9]!==o||e[10]!==i?(d=n("ul",{"aria-label":o,children:i}),e[9]=o,e[10]=i,e[11]=d):d=e[11];let f;return e[12]!==r||e[13]!==d?(f=k(Te,{children:[r,d]}),e[12]=r,e[13]=d,e[14]=f):f=e[14],f};function We(a){return n("span",{className:ne("absolute inset-y-0 border-l border-border/70",a.percent===100?"-translate-x-full pr-1":"pl-1"),style:{left:`${String(a.percent)}%`},children:a.label},a.percent)}function Ue(a){return!a}const qe=a=>Array.isArray(a?.traces)?a.traces:[],ze=a=>{const e=U(12),{entries:t}=a,s=Z();let l;e[0]!==t.length||e[1]!==s?(l=s("Logs ({count})",{count:t.length}),e[0]=t.length,e[1]=s,e[2]=l):l=e[2];let r;e[3]!==l?(r=n("p",{className:"mb-1 font-mono text-xs text-muted-foreground",children:l}),e[3]=l,e[4]=r):r=e[4];let o;e[5]!==t?(o=t.map(He),e[5]=t,e[6]=o):o=e[6];let i;e[7]!==o?(i=n("div",{role:"grid",children:o}),e[7]=o,e[8]=i):i=e[8];let d;return e[9]!==r||e[10]!==i?(d=k("div",{className:"border-t border-border px-3 py-2","data-testid":"tr-logs",children:[r,i]}),e[9]=r,e[10]=i,e[11]=d):d=e[11],d},Ge=a=>{const e=U(50),{expanded:t,logs:s,onToggle:l,trace:r}=a,o=Z();let i;e[0]!==l||e[1]!==r.traceId?(i=()=>{l(r.traceId)},e[0]=l,e[1]=r.traceId,e[2]=i):i=e[2];const d=i,f=`tr-row-${r.traceId}`,c=`tr-waterfall-${r.traceId}`,y=`tr-toggle-${r.traceId}`,$=t?"▾":"▸";let M;e[3]!==$?(M=n("span",{"aria-hidden":"true",className:"w-3 shrink-0 text-xs text-muted-foreground",children:$}),e[3]=$,e[4]=M):M=e[4];let N;e[5]!==r.rootName?(N=n("span",{className:"w-56 shrink-0 truncate text-sm font-medium",title:r.rootName,children:r.rootName}),e[5]=r.rootName,e[6]=N):N=e[6];let v;e[7]!==r.functionPath?(v=n("span",{className:"w-48 shrink-0 truncate font-mono text-xs text-muted-foreground",title:r.functionPath,children:r.functionPath}),e[7]=r.functionPath,e[8]=v):v=e[8];let w;e[9]!==r.durationMs?(w=q(r.durationMs),e[9]=r.durationMs,e[10]=w):w=e[10];let m;e[11]!==w?(m=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:w}),e[11]=w,e[12]=m):m=e[12];let u;e[13]!==o||e[14]!==r.spans.length?(u=o("{count} spans",{count:r.spans.length}),e[13]=o,e[14]=r.spans.length,e[15]=u):u=e[15];let h;e[16]!==u?(h=n("span",{className:"w-20 shrink-0 text-right font-mono text-xs tabular-nums text-muted-foreground",children:u}),e[16]=u,e[17]=h):h=e[17];const T=r.ok?"secondary":"destructive";let _;e[18]!==o||e[19]!==r.ok?(_=r.ok?o("ok"):o("error"),e[18]=o,e[19]=r.ok,e[20]=_):_=e[20];let S;e[21]!==T||e[22]!==_?(S=n("span",{className:"shrink-0",children:n(fe,{variant:T,children:_})}),e[21]=T,e[22]=_,e[23]=S):S=e[23];let g;e[24]!==r.startTs?(g=me(r.startTs),e[24]=r.startTs,e[25]=g):g=e[25];let b;e[26]!==g?(b=n("span",{className:"flex-1 truncate text-right font-mono text-xs tabular-nums text-muted-foreground",children:g}),e[26]=g,e[27]=b):b=e[27];let I;e[28]!==t||e[29]!==d||e[30]!==m||e[31]!==h||e[32]!==S||e[33]!==b||e[34]!==c||e[35]!==y||e[36]!==M||e[37]!==N||e[38]!==v?(I=k("button",{"aria-controls":c,"aria-expanded":t,className:"flex w-full items-center gap-3 px-3 py-2 text-left hover:bg-muted/50","data-testid":y,onClick:d,type:"button",children:[M,N,v,m,h,S,b]}),e[28]=t,e[29]=d,e[30]=m,e[31]=h,e[32]=S,e[33]=b,e[34]=c,e[35]=y,e[36]=M,e[37]=N,e[38]=v,e[39]=I):I=e[39];let p;e[40]!==t||e[41]!==s||e[42]!==r.durationMs||e[43]!==r.spans||e[44]!==r.traceId?(p=t&&k("div",{className:"bg-muted/20","data-testid":`tr-waterfall-${r.traceId}`,id:`tr-waterfall-${r.traceId}`,children:[n(Oe,{durationMs:r.durationMs,spans:r.spans}),s.length>0&&n(ze,{entries:s})]}),e[40]=t,e[41]=s,e[42]=r.durationMs,e[43]=r.spans,e[44]=r.traceId,e[45]=p):p=e[45];let x;return e[46]!==I||e[47]!==p||e[48]!==f?(x=k("div",{className:"border-b border-border last:border-b-0","data-testid":f,children:[I,p]}),e[46]=I,e[47]=p,e[48]=f,e[49]=x):x=e[49],x},bt=a=>{const e=U(58),{initialShardKey:t}=a,s=Z(),[l]=ee(Ie),{queryShardKey:r,setShardKey:o,shardKey:i}=we(l?.shardKey!==void 0&&l.shardKey!==""?l.shardKey:t??""),[d,f]=ee(l?.traceId??""),[c,y]=ee(!1),[$,M]=ee(Je);let N;e[0]===Symbol.for("react.memo_cache_sentinel")?(N=[],e[0]=N):N=e[0],le(Qe,N);let v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v={},e[1]=v):v=e[1];let w;e[2]!==r?(w={live:!0,shardKey:r},e[2]=r,e[3]=w):w=e[3];const{data:m,error:u,errorSource:h,isLoading:T,liveError:_}=oe(ie.getTraces,v,w);let S;e[4]===Symbol.for("react.memo_cache_sentinel")?(S={},e[4]=S):S=e[4];const g=$.size>0;let b;e[5]!==r||e[6]!==g?(b={enabled:g,live:!0,shardKey:r},e[5]=r,e[6]=g,e[7]=b):b=e[7];const{data:I}=oe(ie.getLogs,S,b);let p,x;e[8]!==m||e[9]!==r?(p=()=>{m!==void 0&&_e(r)},x=[m,r],e[8]=m,e[9]=r,e[10]=p,e[11]=x):(p=e[10],x=e[11]),le(p,x);let D;if(e[12]!==m||e[13]!==u||e[14]!==h||e[15]!==$||e[16]!==T||e[17]!==_||e[18]!==I?.entries||e[19]!==c||e[20]!==d||e[21]!==o||e[22]!==i||e[23]!==s){const L=qe(m),A=m?.total??L.length,j=A>L.length,F=Ee(L,d,c),B=Map.groupBy((I?.entries??[]).toReversed(),Ve);let C;e[25]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{f(R.target.value)},e[25]=C):C=e[25];const O=C;let E;e[26]===Symbol.for("react.memo_cache_sentinel")?(E=R=>{M(he=>{const ae=new Set(he);return ae.has(R)?ae.delete(R):ae.add(R),ae})},e[26]=E):E=e[26];const W=E,K=u===null&&F.length===0&&!T;let P;e[27]!==o||e[28]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[27]=o,e[28]=i,e[29]=P):P=e[29];let z;e[30]!==s?(z=s("Search traces"),e[30]=s,e[31]=z):z=e[31];let G;e[32]!==s?(G=s("search trace, span, or function"),e[32]=s,e[33]=G):G=e[33];let H;e[34]!==d||e[35]!==z||e[36]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:O,placeholder:G,value:d}),e[34]=d,e[35]=z,e[36]=G,e[37]=H):H=e[37];let J;e[38]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[38]=c,e[39]=J):J=e[39];let Q;e[40]!==s?(Q=s("Errors only"),e[40]=s,e[41]=Q):Q=e[41];let V;e[42]!==J||e[43]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[42]=J,e[43]=Q,e[44]=V):V=e[44];let X;e[45]!==_?(X=n(be,{message:_,prefix:"tr"}),e[45]=_,e[46]=X):X=e[46];let te;e[47]!==P||e[48]!==H||e[49]!==V||e[50]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[47]=P,e[48]=H,e[49]=V,e[50]=X,e[51]=te):te=e[51];let re;e[52]!==u||e[53]!==h?(re=u!==null&&n(ge,{error:h,testId:"tr-error"}),e[52]=u,e[53]=h,e[54]=re):re=e[54];let se;e[55]!==K||e[56]!==s?(se=K&&n(Ne,{description:s("Traces recorded with ctx.trace show up here as your app handles traffic. The span buffer resets when the shard hibernates."),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:"M4 6h10M7 12h13M10 18h7"})}),testId:"tr-empty",title:s("No traces")}),e[55]=K,e[56]=s,e[57]=se):se=e[57],D=k("div",{className:"flex flex-col gap-4","data-testid":"lunora-traces-panel",children:[te,re,se,u===null&&j&&n("p",{className:"text-xs text-muted-foreground","data-testid":"tr-truncated",children:s("Showing the {shown} most recent of {total} traces in the buffer.",{shown:L.length,total:A})}),u===null&&F.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:F.map(R=>n(Ge,{expanded:$.has(R.traceId),logs:B.get(R.traceId)??[],onToggle:W,trace:R},R.traceId))})]}),e[12]=m,e[13]=u,e[14]=h,e[15]=$,e[16]=T,e[17]=_,e[18]=I?.entries,e[19]=c,e[20]=d,e[21]=o,e[22]=i,e[23]=s,e[24]=D}else D=e[24];return D};function He(a,e){return n("div",{className:"flex items-center border-b border-border py-1 font-mono text-xs last:border-b-0","data-testid":"tr-log-row",role:"row",children:n(Me,{entry:a})},`${String(e)}:${String(a.timestamp)}`)}function Je(){return new Set}function Qe(){ke()}function Ve(a){return a.traceId}export{bt as default};