@lunora/studio 1.0.0-alpha.358 → 1.0.0-alpha.359

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 (191) hide show
  1. package/dist/index.mjs +1 -1
  2. package/dist/mount.mjs +1 -1
  3. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  4. package/dist/packem_chunks/ApiTab.mjs +1 -1
  5. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  6. package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
  7. package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
  8. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  9. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  10. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  11. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  12. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  13. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  14. package/dist/packem_chunks/MailPanel.mjs +1 -1
  15. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  16. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  17. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  18. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  19. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  20. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  21. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  22. package/dist/packem_chunks/TableEditor.mjs +1 -1
  23. package/dist/packem_chunks/agents-panel.mjs +1 -1
  24. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  25. package/dist/packem_chunks/analytics-panel.mjs +1 -1
  26. package/dist/packem_chunks/architecture-panel.mjs +1 -1
  27. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  28. package/dist/packem_chunks/auth-config-panel.mjs +1 -1
  29. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  30. package/dist/packem_chunks/containers-panel.mjs +1 -1
  31. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  32. package/dist/packem_chunks/evals-panel.mjs +1 -1
  33. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  34. package/dist/packem_chunks/flags-panel.mjs +1 -1
  35. package/dist/packem_chunks/issues-panel.mjs +1 -1
  36. package/dist/packem_chunks/kv-browser.mjs +1 -1
  37. package/dist/packem_chunks/log-drains-panel.mjs +1 -1
  38. package/dist/packem_chunks/migrations-route.mjs +1 -1
  39. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  40. package/dist/packem_chunks/payments-panel.mjs +1 -1
  41. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  42. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  43. package/dist/packem_chunks/queues-panel.mjs +1 -1
  44. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  45. package/dist/packem_chunks/rls-panel.mjs +1 -1
  46. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  47. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  48. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  49. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  50. package/dist/packem_chunks/traces-panel.mjs +1 -1
  51. package/dist/packem_chunks/users-panel.mjs +1 -1
  52. package/dist/packem_chunks/vector-browser.mjs +1 -1
  53. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  54. package/dist/packem_shared/{ApiDocsPanel-E4Vr-8zW.mjs → ApiDocsPanel-DD2Uns6b.mjs} +1 -1
  55. package/dist/packem_shared/{ApiReferencePanel-u9Rrljdf.mjs → ApiReferencePanel-CQxU1Ocx.mjs} +1 -1
  56. package/dist/packem_shared/{CommandPalette-5OsK8PNe.mjs → CommandPalette-BZCHLpst.mjs} +1 -1
  57. package/dist/packem_shared/{DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs → DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs} +1 -1
  58. package/dist/packem_shared/{DataBrowser-C5HbI4TH.mjs → DataBrowser-CVRWnNWu.mjs} +1 -1
  59. package/dist/packem_shared/{GlobalDataBrowser-D0H2yJSl.mjs → GlobalDataBrowser-DC47T6Zl.mjs} +1 -1
  60. package/dist/packem_shared/{HomePanel-CcYkDlR-.mjs → HomePanel-D12HxHQo.mjs} +1 -1
  61. package/dist/packem_shared/{MigrationsPanel-YyCO_T-3.mjs → MigrationsPanel-DMkxSXNl.mjs} +1 -1
  62. package/dist/packem_shared/{OpenRpcReferencePanel-E9cDfHRv.mjs → OpenRpcReferencePanel-BFDG91tn.mjs} +1 -1
  63. package/dist/packem_shared/{ScheduledJobs-D4CUj7aX.mjs → ScheduledJobs-QCTRdugp.mjs} +1 -1
  64. package/dist/packem_shared/{Studio-4vJzwwNa.mjs → Studio-MA8kKZLu.mjs} +1 -1
  65. package/dist/packem_shared/{StudioApp-px2FMPDS.mjs → StudioApp-isdWpF9P.mjs} +1 -1
  66. package/dist/packem_shared/{advisor-view-fNcNYW2Q.mjs → advisor-view-tBumWci_.mjs} +1 -1
  67. package/dist/packem_shared/{data-grid-r3isM8Nq.mjs → data-grid-B5m1OosL.mjs} +1 -1
  68. package/dist/packem_shared/{diagram-export-panel-aBDQdX4e.mjs → diagram-export-panel-Vdt-DZnO.mjs} +1 -1
  69. package/dist/packem_shared/{error-alert-54TiaMvZ.mjs → error-alert-C0R39DO1.mjs} +1 -1
  70. package/dist/packem_shared/{grid-features-2c5SaBtH.mjs → grid-features-Drvfswwy.mjs} +1 -1
  71. package/dist/packem_shared/{home-panel-DPiMVQZ2.mjs → home-panel-CDVTuTF8.mjs} +1 -1
  72. package/dist/packem_shared/internal-hIuTpSbx.mjs +2 -0
  73. package/dist/packem_shared/{log-line-BWDt_F56.mjs → log-line-BH0iWiBv.mjs} +1 -1
  74. package/dist/packem_shared/{recording-client-MbGZ28I0.mjs → recording-client-DAipTA_n.mjs} +1 -1
  75. package/dist/packem_shared/{reference-view-DCEC5kjY.mjs → reference-view-DENugPcj.mjs} +1 -1
  76. package/dist/packem_shared/{schema-diagram-k7cFl7Wp.mjs → schema-diagram-CtVPhOGj.mjs} +1 -1
  77. package/dist/packem_shared/{sql-result-table-CatgdmMh.mjs → sql-result-table-DCwooMGW.mjs} +1 -1
  78. package/dist/packem_shared/{studio-DIUgH7k0.mjs → studio-UhUrPz5J.mjs} +1 -1
  79. package/dist/packem_shared/{table-list-sidebar-CCRB_iYz.mjs → table-list-sidebar-CNadcIgG.mjs} +1 -1
  80. package/dist/packem_shared/{use-admin-query-BW9IuacC.mjs → use-admin-query-CaOm4JS3.mjs} +1 -1
  81. package/dist/packem_shared/{use-admin-spec-BdNLZbTO.mjs → use-admin-spec-CK7mk3Ui.mjs} +1 -1
  82. package/dist/packem_shared/{use-async-submit-2eBBD0-m.mjs → use-async-submit-D0r7-m2J.mjs} +1 -1
  83. package/dist/packem_shared/{use-auth-config-KO9tnI39.mjs → use-auth-config-CG7VvAvQ.mjs} +1 -1
  84. package/dist/packem_shared/{use-open-trace-B_0LbTD7.mjs → use-open-trace-BJKMJjeS.mjs} +1 -1
  85. package/dist/packem_shared/{use-sql-assistant-BMVlguKF.mjs → use-sql-assistant-rZPs3LC3.mjs} +1 -1
  86. package/dist/standalone/{chunk-UFPN44MP.js → chunk-2AH4ABE5.js} +1 -1
  87. package/dist/standalone/{chunk-FYWZRJCT.js → chunk-2G57ENH5.js} +1 -1
  88. package/dist/standalone/{chunk-CVUNFP54.js → chunk-3FS22LNI.js} +1 -1
  89. package/dist/standalone/{chunk-2CPBNLFU.js → chunk-3GYLOE4V.js} +1 -1
  90. package/dist/standalone/{chunk-XZKWGTLI.js → chunk-3PAYDWHN.js} +1 -1
  91. package/dist/standalone/{chunk-FACE2CFY.js → chunk-473JK2PQ.js} +1 -1
  92. package/dist/standalone/chunk-4DAKKAK7.js +1 -0
  93. package/dist/standalone/{chunk-FRN6D6MP.js → chunk-4M57OYFX.js} +1 -1
  94. package/dist/standalone/{chunk-KRDWV6YM.js → chunk-5GIQ6C5N.js} +1 -1
  95. package/dist/standalone/{chunk-MDAXV2XH.js → chunk-5R2YO7HF.js} +1 -1
  96. package/dist/standalone/{chunk-SUOVLXY6.js → chunk-5WJG7FMH.js} +1 -1
  97. package/dist/standalone/{chunk-4FZYH76L.js → chunk-63KDHS3H.js} +1 -1
  98. package/dist/standalone/{chunk-HGT4YHTI.js → chunk-6B6ARRMI.js} +1 -1
  99. package/dist/standalone/{chunk-NSUOMZWM.js → chunk-6LMO2D54.js} +1 -1
  100. package/dist/standalone/{chunk-2O6KKVH2.js → chunk-6VAY6L4J.js} +1 -1
  101. package/dist/standalone/{chunk-HKLF627N.js → chunk-7PADVGQX.js} +1 -1
  102. package/dist/standalone/{chunk-IIJXS3KP.js → chunk-7UM5ROG6.js} +1 -1
  103. package/dist/standalone/{chunk-XIVWJUD3.js → chunk-7ZIYHKLX.js} +1 -1
  104. package/dist/standalone/{chunk-NEZRBBPI.js → chunk-A5JISKHE.js} +1 -1
  105. package/dist/standalone/{chunk-MI7DM536.js → chunk-ADNRFCMZ.js} +1 -1
  106. package/dist/standalone/chunk-BFE2DRP6.js +33 -0
  107. package/dist/standalone/{chunk-OIBN6KMM.js → chunk-BPEB4KFE.js} +1 -1
  108. package/dist/standalone/chunk-BVX45MU5.js +7 -0
  109. package/dist/standalone/{chunk-5IGDDSST.js → chunk-BYOGQ2IV.js} +1 -1
  110. package/dist/standalone/{chunk-AKGGWCWW.js → chunk-C6GN7ZXJ.js} +1 -1
  111. package/dist/standalone/{chunk-ZD53YB3L.js → chunk-CL2VZNDI.js} +1 -1
  112. package/dist/standalone/{chunk-P6L6ABWO.js → chunk-CNA3TVUK.js} +1 -1
  113. package/dist/standalone/chunk-CZ6HBDIL.js +1 -0
  114. package/dist/standalone/{chunk-MY7ZGJOD.js → chunk-D6S7MXW4.js} +1 -1
  115. package/dist/standalone/{chunk-LKCO3E2B.js → chunk-FCAXVYAX.js} +1 -1
  116. package/dist/standalone/{chunk-ZWDORIZY.js → chunk-FXPAJDES.js} +1 -1
  117. package/dist/standalone/{chunk-WZTY3ZYI.js → chunk-H7HZ42JY.js} +1 -1
  118. package/dist/standalone/{chunk-CW57Q264.js → chunk-HHRYM6UW.js} +1 -1
  119. package/dist/standalone/{chunk-PMGNJZYE.js → chunk-HPRF5LMA.js} +1 -1
  120. package/dist/standalone/{chunk-PBKTGB7B.js → chunk-IB22LETR.js} +1 -1
  121. package/dist/standalone/chunk-IENQRRQT.js +1 -0
  122. package/dist/standalone/{chunk-LRXCL6IA.js → chunk-IQ4TTHQT.js} +1 -1
  123. package/dist/standalone/{chunk-TA3DCQUA.js → chunk-ITH5LRWM.js} +1 -1
  124. package/dist/standalone/{chunk-B4BK5Q5O.js → chunk-J6VFG6M5.js} +1 -1
  125. package/dist/standalone/{chunk-MD67S53Z.js → chunk-JSDKOE4U.js} +1 -1
  126. package/dist/standalone/{chunk-EAZXULX6.js → chunk-JZD7ZN3F.js} +1 -1
  127. package/dist/standalone/chunk-K3CWB3AM.js +1 -0
  128. package/dist/standalone/{chunk-FCRSF54M.js → chunk-KNFB3FGW.js} +1 -1
  129. package/dist/standalone/{chunk-WOGVVXGF.js → chunk-KNXWDE4N.js} +1 -1
  130. package/dist/standalone/{chunk-DPESH5MT.js → chunk-KRY7BYHT.js} +1 -1
  131. package/dist/standalone/chunk-KYAG2YMF.js +1 -0
  132. package/dist/standalone/{chunk-OUFWXYEF.js → chunk-KZCEJFZF.js} +1 -1
  133. package/dist/standalone/{chunk-F4VO76XV.js → chunk-KZILJQX3.js} +1 -1
  134. package/dist/standalone/{chunk-OSQYIZAV.js → chunk-LEYUH5TS.js} +1 -1
  135. package/dist/standalone/{chunk-AN2L3XHC.js → chunk-LFM672WN.js} +1 -1
  136. package/dist/standalone/{chunk-FHGTI6PR.js → chunk-LPU6YTSU.js} +1 -1
  137. package/dist/standalone/{chunk-TRZTGE4R.js → chunk-MWJC3S62.js} +1 -1
  138. package/dist/standalone/{chunk-OX7I5YHU.js → chunk-NP2AQOLE.js} +1 -1
  139. package/dist/standalone/{chunk-5SYMAYUA.js → chunk-NVKLYDOH.js} +1 -1
  140. package/dist/standalone/{chunk-ZFFZWSDJ.js → chunk-O2NMPIV2.js} +1 -1
  141. package/dist/standalone/{chunk-BCP3MEB3.js → chunk-O2X2XYCM.js} +1 -1
  142. package/dist/standalone/{chunk-XZ6B5XNN.js → chunk-O3MDWYXF.js} +1 -1
  143. package/dist/standalone/chunk-ONG4JEZD.js +1 -0
  144. package/dist/standalone/{chunk-DS7HZKZ2.js → chunk-ONWGX5Y4.js} +1 -1
  145. package/dist/standalone/{chunk-X5KWBDTF.js → chunk-OS26JXYA.js} +1 -1
  146. package/dist/standalone/{chunk-N4AWDORA.js → chunk-PGTEGUAB.js} +1 -1
  147. package/dist/standalone/{chunk-6I42AM75.js → chunk-PQH2LSJX.js} +1 -1
  148. package/dist/standalone/{chunk-7KPRMBD6.js → chunk-PTBUWRBY.js} +1 -1
  149. package/dist/standalone/{chunk-4IEMXFUB.js → chunk-Q6HA3L2H.js} +1 -1
  150. package/dist/standalone/{chunk-KRH6UDVU.js → chunk-QGV5ARD2.js} +1 -1
  151. package/dist/standalone/{chunk-YJWR6ZWC.js → chunk-QWRK4ESB.js} +1 -1
  152. package/dist/standalone/{chunk-WC5QFZYZ.js → chunk-RL2ITK2N.js} +1 -1
  153. package/dist/standalone/{chunk-ZQOPXQIT.js → chunk-RTJO3AR4.js} +1 -1
  154. package/dist/standalone/{chunk-SDQH4HR6.js → chunk-SU5DTRGK.js} +1 -1
  155. package/dist/standalone/{chunk-OSJ7HV7B.js → chunk-T5UMHPAB.js} +1 -1
  156. package/dist/standalone/{chunk-QXHMVPS3.js → chunk-T6HV2FQP.js} +1 -1
  157. package/dist/standalone/{chunk-FNUPPZKJ.js → chunk-T7ZKNNGX.js} +1 -1
  158. package/dist/standalone/{chunk-FLVDICZL.js → chunk-TCYPNSTV.js} +1 -1
  159. package/dist/standalone/{chunk-MHJNM7VT.js → chunk-TQM6XHBA.js} +1 -1
  160. package/dist/standalone/{chunk-IWG2D7QS.js → chunk-TRMWBRRU.js} +1 -1
  161. package/dist/standalone/{chunk-FSWWDMW2.js → chunk-TW7KJSMR.js} +1 -1
  162. package/dist/standalone/{chunk-NMVFSJM7.js → chunk-TYD3V4NB.js} +1 -1
  163. package/dist/standalone/{chunk-3HX723U6.js → chunk-TZKLK52W.js} +1 -1
  164. package/dist/standalone/{chunk-B6OTKSMY.js → chunk-U4RXQSQ7.js} +1 -1
  165. package/dist/standalone/{chunk-MC577GI5.js → chunk-UNZ2UBVL.js} +1 -1
  166. package/dist/standalone/{chunk-SJLEEYCR.js → chunk-VJRNOSRY.js} +1 -1
  167. package/dist/standalone/{chunk-HKPDPKXD.js → chunk-WM72PRE3.js} +1 -1
  168. package/dist/standalone/{chunk-HSLO46OW.js → chunk-X4WHMCOZ.js} +1 -1
  169. package/dist/standalone/{chunk-PCMV6S7K.js → chunk-XIRKBJPD.js} +1 -1
  170. package/dist/standalone/{chunk-WCWSMX3N.js → chunk-XKPD4SFN.js} +1 -1
  171. package/dist/standalone/chunk-XMSNLMWU.js +1 -0
  172. package/dist/standalone/{chunk-JYCRY3LM.js → chunk-XOPFDWXX.js} +1 -1
  173. package/dist/standalone/{chunk-V6SVNLUM.js → chunk-XQLOVFPP.js} +1 -1
  174. package/dist/standalone/{chunk-HONLEKH5.js → chunk-XSHYZPGF.js} +1 -1
  175. package/dist/standalone/{chunk-KYONGQQ4.js → chunk-XST3UEHU.js} +1 -1
  176. package/dist/standalone/{chunk-AOHKAKKL.js → chunk-Y74LIFSL.js} +1 -1
  177. package/dist/standalone/{chunk-CTE6RPXC.js → chunk-YMEKCV27.js} +1 -1
  178. package/dist/standalone/{chunk-CZACJYDC.js → chunk-ZOQTXWPK.js} +1 -1
  179. package/dist/standalone/{chunk-FMQ72AKG.js → chunk-ZZ5GICTF.js} +1 -1
  180. package/dist/standalone/studio.js +1 -1
  181. package/package.json +6 -6
  182. package/dist/packem_shared/internal-BXEjuLPN.mjs +0 -2
  183. package/dist/standalone/chunk-3Y5K3IQO.js +0 -1
  184. package/dist/standalone/chunk-GMO7IUXO.js +0 -1
  185. package/dist/standalone/chunk-LPINY2IJ.js +0 -19
  186. package/dist/standalone/chunk-LVNPLZDL.js +0 -1
  187. package/dist/standalone/chunk-PTCC45P7.js +0 -1
  188. package/dist/standalone/chunk-PZZWUL5U.js +0 -1
  189. package/dist/standalone/chunk-SDSQIQJG.js +0 -21
  190. package/dist/standalone/chunk-W37HRJGQ.js +0 -1
  191. package/dist/standalone/chunk-XBZUJDHD.js +0 -1
@@ -1 +1 @@
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-4aGsMs95.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
+ 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-C0R39DO1.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-CaOm4JS3.mjs";import{useAutoRefresh as ot}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.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-4aGsMs95.mjs";import{c as De,b as ue,d as Ie,f as Qe,h as it,k as dt}from"../packem_shared/internal-hIuTpSbx.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-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-4aGsMs95.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-C0R39DO1.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-CaOm4JS3.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as C}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.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-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-4aGsMs95.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-C0R39DO1.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-CaOm4JS3.mjs";import{useT as Q}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as q}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.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-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
+ 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-CaOm4JS3.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-hIuTpSbx.mjs";import{jsxs as m,jsx as t}from"react/jsx-runtime";import{useAutoRefresh as X}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import{ScheduledJobs as ee}from"../packem_shared/ScheduledJobs-QCTRdugp.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-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-4aGsMs95.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-C0R39DO1.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-CaOm4JS3.mjs";import{useT as E}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as v}from"../packem_shared/ADMIN_FUNCTIONS-4aGsMs95.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-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-4aGsMs95.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-C0R39DO1.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-CaOm4JS3.mjs";import{useAutoRefresh as F}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.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-4aGsMs95.mjs";import{k as q}from"../packem_shared/internal-hIuTpSbx.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{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};
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-CaOm4JS3.mjs";import{useAutoRefresh as Q}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.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};
@@ -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-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-4aGsMs95.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-C0R39DO1.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-CaOm4JS3.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-4aGsMs95.mjs";import{h as me,k as Se}from"../packem_shared/internal-hIuTpSbx.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-BH0iWiBv.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 +1 @@
1
- import{useState as I,useEffect as Me}from"react";import{B as q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as R}from"../packem_shared/button-q0UYSmrn.mjs";import{C as K,a as X}from"../packem_shared/card-By2O8ULa.mjs";import{E as Ye}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as B}from"../packem_shared/input-CXhxesPC.mjs";import{T as Ee,a as Re,b as Q,c as U,d as Te,e as P}from"../packem_shared/table-D0SBiDu-.mjs";import{a as qe}from"../packem_shared/use-admin-query-BW9IuacC.mjs";import{c as Z}from"react/compiler-runtime";import{u as Qe}from"../packem_shared/use-auth-config-KO9tnI39.mjs";import{useAutoRefresh as Ge}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-CG7Q45ZS.mjs";import Je from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{u as ee}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{w as Ke,h as Fe,f as J,l as Pe,b as Ve}from"../packem_shared/internal-BXEjuLPN.mjs";import{A as Xe}from"../packem_shared/auth-pager-DW77WeZw.mjs";import{jsxs as u,jsx as t,Fragment as et}from"react/jsx-runtime";import{C as tt}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{L as _}from"../packem_shared/label-DKFzyHq6.mjs";import{M as We}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{u as st}from"../packem_shared/use-async-submit-2eBBD0-m.mjs";const nt=()=>{const h=Z(3),{config:e,ready:l}=Qe();let n;return h[0]!==e.capabilities||h[1]!==l?(n={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=n):n=h[2],n},lt=(h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending",He=500,at=(h,e)=>{if(!URL.canParse(h.trim()))return null;const l=new URL(h.trim());return l.searchParams.set("email",e.email),l.searchParams.set("invite",e.token),l.toString()},it=h=>{const e=Z(34),{issued:l,onSignUpPageChange:n,signUpPage:o}=h,s=W(),[f,a]=I(null);let c;e[0]!==l||e[1]!==o?(c=at(o,l),e[0]=l,e[1]=o,e[2]=c):c=e[2];const d=c;let y;e[3]!==d?(y=()=>{const T="navigator"in globalThis?globalThis.navigator.clipboard:void 0;d===null||T===void 0||J(T.writeText(d).then(()=>(a(d),!0)))},e[3]=d,e[4]=y):y=e[4];const C=y;let g;e[5]!==s?(g=s("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=s,e[6]=g):g=e[6];let w;e[7]!==g?(w=t("p",{className:"text-sm",children:g}),e[7]=g,e[8]=w):w=e[8];const k=d===null;let v;e[9]!==s?(v=s("Your app's sign-up page"),e[9]=s,e[10]=v):v=e[10];let r;e[11]!==n?(r=T=>{n(T.target.value)},e[11]=n,e[12]=r):r=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==r?(m=t(B,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:r,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=r,e[17]=m):m=e[17];const b=d??"";let x;e[18]!==b?(x=t(B,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==f||e[21]!==d||e[22]!==s?(N=s(f!==null&&f===d?"Copied":"Copy"),e[20]=f,e[21]=d,e[22]=s,e[23]=N):N=e[23];let p;e[24]!==C||e[25]!==N?(p=t(R,{"data-testid":"sign-up-invitation-copy",onClick:C,type:"button",children:N}),e[24]=C,e[25]=N,e[26]=p):p=e[26];let i;e[27]!==x||e[28]!==p?(i=u("div",{className:"flex gap-2",children:[x,p]}),e[27]=x,e[28]=p,e[29]=i):i=e[29];let S;return e[30]!==i||e[31]!==w||e[32]!==m?(S=t(K,{children:u(X,{className:"flex flex-col gap-2 p-4",children:[w,m,i]})}),e[30]=i,e[31]=w,e[32]=m,e[33]=S):S=e[33],S},rt=()=>{const h=ee(),e=W(),[l,n]=I(""),[o,s]=I(null),[f,a]=I(null),[c,d]=I(()=>`${Ke(h.url)}/sign-up`),y=qe(["lunora-auth-sign-up-invitations",He],()=>h.listAuthSignUpInvitations({limit:He})),C=y.data?.rows??null,g=y.data?.total??0,w=()=>{const v=l.trim();v!==""&&(s(null),J((async()=>{try{const r=await h.createAuthSignUpInvitation({email:v}),m=typeof r.token=="string"?r.token:void 0;a(m===void 0?null:{email:v,token:m}),n(""),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})()))},k=v=>{s(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})())};return u("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[u("div",{children:[t("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),t("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed — send the invitee the one-time link yourself.")})]}),u("div",{className:"flex gap-2",children:[t(B,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:v=>{n(v.target.value)},placeholder:e("ada@example.com"),type:"email",value:l}),t(R,{"data-testid":"sign-up-invitation-submit",onClick:w,type:"button",children:e("Invite")})]}),f!==null&&t(it,{issued:f,onSignUpPageChange:d,signUpPage:c},f.token),(o??y.error)!==null&&t("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),C!==null&&C.length===0&&t(Ye,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&g>C.length&&t("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),C!==null&&C.length>0&&t(K,{children:t(X,{className:"p-0",children:u(Ee,{children:[t(Re,{children:u(Q,{children:[t(U,{children:e("Email")}),t(U,{children:e("Status")}),t(U,{children:e("Expires")}),t(U,{children:e("Invited by")}),t(U,{})]})}),t(Te,{children:C.map(v=>{const r=lt(v,Date.now()),m=v.email??"";return u(Q,{"data-testid":`sign-up-invitation-${m}`,children:[t(P,{children:m}),u(P,{"data-testid":`sign-up-invitation-status-${m}`,children:[r==="spent"&&e("Accepted"),r==="expired"&&e("Expired"),r==="pending"&&e("Pending")]}),t(P,{children:typeof v.expiresAt=="number"?Fe(v.expiresAt):"—"}),t(P,{children:v.invitedBy??"—"}),t(P,{className:"text-right",children:t(R,{onClick:()=>{k(m)},type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},ot={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=(h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),ct=(h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;const l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){const n=Number(l);return Number.isNaN(n)?void 0:{value:n}}return{value:l}}},ut=h=>{const e=Z(105),{onClose:l,onCreated:n}=h,o=ee(),s=W(),{config:f}=Qe(),{busy:a,error:c,run:d}=st(),[y,C]=I(""),[g,w]=I(""),[k,v]=I(""),[r,m]=I("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[x,N]=I(b);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=A=>{C(A.target.value)},e[1]=p):p=e[1];const i=p;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=A=>{w(A.target.value)},e[2]=S):S=e[2];const T=S;let z;e[3]===Symbol.for("react.memo_cache_sentinel")?(z=A=>{v(A.target.value)},e[3]=z):z=e[3];const j=z;let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=A=>{m(A.target.value)},e[4]=M):M=e[4];const H=M;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=(A,D)=>{N(G=>({...G,[A]:D}))},e[5]=L):L=e[5];const V=L;let Y;e[6]!==x?(Y=A=>x[A.name]??(A.type==="boolean"?!1:""),e[6]=x,e[7]=Y):Y=e[7];const E=Y;let O;if(e[8]!==f.userFields||e[9]!==E){let A;e[11]!==E?(A=D=>!D.required||dt(D,E(D)),e[11]=E,e[12]=A):A=e[12],O=f.userFields.every(A),e[8]=f.userFields,e[9]=E,e[10]=O}else O=e[10];const F=O;let $;e[13]!==a||e[14]!==y||e[15]!==g||e[16]!==F?($=!a&&y.trim()!==""&&g.trim()!==""&&F,e[13]=a,e[14]=y,e[15]=g,e[16]=F,e[17]=$):$=e[17];const Ue=$;let te;e[18]!==f.userFields||e[19]!==E?(te=()=>{const A={};for(const D of f.userFields){const G=ct(D,E(D));G!==void 0&&(A[D.name]=G.value)}return Object.keys(A).length===0?void 0:A},e[18]=f.userFields,e[19]=E,e[20]=te):te=e[20];const Be=te;let De;e[21]!==Be||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==l||e[26]!==n||e[27]!==k||e[28]!==r||e[29]!==d?(De=()=>{d(async()=>{await o.createAuthUser({data:Be(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:r.trim()===""?void 0:r.trim()}),n(),l()})},e[21]=Be,e[22]=o,e[23]=y,e[24]=g,e[25]=l,e[26]=n,e[27]=k,e[28]=r,e[29]=d,e[30]=De):De=e[30];const ze=De;let se;e[31]!==s?(se=s("Create user"),e[31]=s,e[32]=se):se=e[32];let ne;e[33]!==s?(ne=s("Create user"),e[33]=s,e[34]=ne):ne=e[34];let le;e[35]!==ne?(le=t("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=le):le=e[36];let ae;e[37]!==s?(ae=s("email"),e[37]=s,e[38]=ae):ae=e[38];let ie;e[39]!==ae?(ie=t(_,{htmlFor:"uc-email",children:ae}),e[39]=ae,e[40]=ie):ie=e[40];let re;e[41]!==y?(re=t(B,{"data-testid":"uc-email",id:"uc-email",onChange:i,type:"email",value:y}),e[41]=y,e[42]=re):re=e[42];let oe;e[43]!==ie||e[44]!==re?(oe=u("div",{className:"flex flex-col gap-1",children:[ie,re]}),e[43]=ie,e[44]=re,e[45]=oe):oe=e[45];let de;e[46]!==s?(de=s("name"),e[46]=s,e[47]=de):de=e[47];let ce;e[48]!==de?(ce=t(_,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=ce):ce=e[49];let ue;e[50]!==g?(ue=t(B,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:g}),e[50]=g,e[51]=ue):ue=e[51];let me;e[52]!==ce||e[53]!==ue?(me=u("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[52]=ce,e[53]=ue,e[54]=me):me=e[54];let he;e[55]!==s?(he=s("Password (optional)"),e[55]=s,e[56]=he):he=e[56];let fe;e[57]!==he?(fe=t(_,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=fe):fe=e[58];let pe;e[59]!==k?(pe=t(B,{"data-testid":"uc-password",id:"uc-password",onChange:j,type:"password",value:k}),e[59]=k,e[60]=pe):pe=e[60];let ve;e[61]!==fe||e[62]!==pe?(ve=u("div",{className:"flex flex-col gap-1",children:[fe,pe]}),e[61]=fe,e[62]=pe,e[63]=ve):ve=e[63];let ge;e[64]!==s?(ge=s("Role (optional)"),e[64]=s,e[65]=ge):ge=e[65];let be;e[66]!==ge?(be=t(_,{htmlFor:"uc-role",children:ge}),e[66]=ge,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=t(B,{"data-testid":"uc-role",id:"uc-role",onChange:H,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=u("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let Ne;e[73]!==f.userFields||e[74]!==E||e[75]!==s?(Ne=f.userFields.length>0&&u("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")}),f.userFields.map(A=>{const D=`uc-field-${A.name}`,G=A.required?"":` (${s("optional")})`;if(A.type==="boolean"){const Oe=E(A)===!0;return u("label",{className:"flex items-center gap-2",htmlFor:D,children:[t(tt,{checked:Oe,"data-testid":D,id:D,onCheckedChange:Ze=>{V(A.name,Ze)}}),u("span",{className:"text-sm",children:[A.name,G]})]},A.name)}const je=E(A);return u("div",{className:"flex flex-col gap-1",children:[u(_,{htmlFor:D,children:[A.name,G]}),t(B,{"data-testid":D,id:D,onChange:Oe=>{V(A.name,Oe.target.value)},type:ot[A.type],value:typeof je=="string"?je:""})]},A.name)})]}),e[73]=f.userFields,e[74]=E,e[75]=s,e[76]=Ne):Ne=e[76];let ke;e[77]!==c?(ke=c!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:c}),e[77]=c,e[78]=ke):ke=e[78];let Ce;e[79]!==s?(Ce=s("Cancel"),e[79]=s,e[80]=Ce):Ce=e[80];let we;e[81]!==l||e[82]!==Ce?(we=t(R,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=l,e[82]=Ce,e[83]=we):we=e[83];const Le=!Ue;let Ae;e[84]!==a||e[85]!==s?(Ae=s(a?"Creating…":"Create"),e[84]=a,e[85]=s,e[86]=Ae):Ae=e[86];let Se;e[87]!==ze||e[88]!==Le||e[89]!==Ae?(Se=t(R,{"data-testid":"uc-submit",disabled:Le,onClick:ze,size:"sm",type:"button",children:Ae}),e[87]=ze,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Ie;e[91]!==we||e[92]!==Se?(Ie=u("div",{className:"flex justify-end gap-2 pt-1",children:[we,Se]}),e[91]=we,e[92]=Se,e[93]=Ie):Ie=e[93];let $e;return e[94]!==l||e[95]!==se||e[96]!==le||e[97]!==oe||e[98]!==me||e[99]!==ve||e[100]!==ye||e[101]!==Ne||e[102]!==ke||e[103]!==Ie?($e=u(We,{label:se,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[le,oe,me,ve,ye,Ne,ke,Ie]}),e[94]=l,e[95]=se,e[96]=le,e[97]=oe,e[98]=me,e[99]=ve,e[100]=ye,e[101]=Ne,e[102]=ke,e[103]=Ie,e[104]=$e):$e=e[104],$e},_e=h=>{const e=Z(2),{children:l}=h;let n;return e[0]!==l?(n=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=n):n=e[1],n},mt=h=>{const e=Z(29),{busy:l,runAction:n,userId:o,version:s}=h,f=ee(),a=W(),[c,d]=I(null),[y,C]=I(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{const i=await f.listAuthSessions({limit:50,userId:o});d(i.rows)}catch(i){const S=i;d(null),C(Ve(S))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n?(k=i=>{n(()=>f.revokeAuthSession({sessionId:i}))},e[7]=f,e[8]=n,e[9]=k):k=e[9];const v=k;let r;e[10]!==a?(r=a("Sessions"),e[10]=a,e[11]=r):r=e[11];let m;e[12]!==r?(m=t(_e,{children:r}),e[12]=r,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==c||e[17]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:a("No active sessions.")}),e[16]=c,e[17]=a,e[18]=x):x=e[18];let N;e[19]!==l||e[20]!==v||e[21]!==c||e[22]!==a?(N=c!==null&&c.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-sessions-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("expires")}),t(U,{children:a("ip")}),t(U,{children:a("user agent")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>u(Q,{"data-testid":`ud-session-${i.id}`,children:[t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.expiresAt)}),t(P,{children:i.ipAddress??""}),t(P,{className:"max-w-40 truncate",children:i.userAgent??""}),t(P,{children:t(R,{"data-testid":`ud-revoke-${i.id}`,disabled:l,onClick:()=>{v(i.id)},size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[19]=l,e[20]=v,e[21]=c,e[22]=a,e[23]=N):N=e[23];let p;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=p):p=e[28],p},ht=h=>{const e=Z(30),{busy:l,runAction:n,userId:o,version:s}=h,f=ee(),a=W(),[c,d]=I(null),[y,C]=I(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{d(await f.listAuthAccounts({userId:o}))}catch(i){const S=i;d(null),C(Ve(S))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n||e[9]!==o?(k=i=>{n(()=>f.unlinkAuthAccount({accountId:i,userId:o}))},e[7]=f,e[8]=n,e[9]=o,e[10]=k):k=e[10];const v=k;let r;e[11]!==a?(r=a("Linked accounts"),e[11]=a,e[12]=r):r=e[12];let m;e[13]!==r?(m=t(_e,{children:r}),e[13]=r,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==c||e[18]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No linked accounts.")}),e[17]=c,e[18]=a,e[19]=x):x=e[19];let N;e[20]!==c||e[21]!==l||e[22]!==v||e[23]!==a?(N=c!==null&&c.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-accounts-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("provider")}),t(U,{children:a("created")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>{const S=Pe(i.id);return u(Q,{"data-testid":`ud-account-${S}`,children:[t(P,{children:Pe(i.providerId)}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-unlink-${S}`,disabled:l,onClick:()=>{v(S)},size:"xs",type:"button",variant:"ghost",children:a("Unlink")})})]},S)})})]})})}),e[20]=c,e[21]=l,e[22]=v,e[23]=a,e[24]=N):N=e[24];let p;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=p):p=e[29],p},ft=h=>{const e=Z(40),{busy:l,capabilities:n,runAction:o,userId:s,version:f}=h,a=ee(),c=W(),[d,y]=I(null);let C;e[0]!==n.passkey||e[1]!==a||e[2]!==s?(C=()=>{n.passkey&&J((async()=>{try{y(await a.listAuthPasskeys({userId:s}))}catch{y(null)}})())},e[0]=n.passkey,e[1]=a,e[2]=s,e[3]=C):C=e[3];let g;e[4]!==n.passkey||e[5]!==a||e[6]!==s||e[7]!==f?(g=[n.passkey,a,s,f],e[4]=n.passkey,e[5]=a,e[6]=s,e[7]=f,e[8]=g):g=e[8],Me(C,g);let w;e[9]!==a||e[10]!==o||e[11]!==s?(w=()=>{o(()=>a.disableAuthTwoFactor({userId:s}))},e[9]=a,e[10]=o,e[11]=s,e[12]=w):w=e[12];const k=w;let v;e[13]!==a||e[14]!==o?(v=S=>{o(()=>a.deleteAuthPasskey({passkeyId:S}))},e[13]=a,e[14]=o,e[15]=v):v=e[15];const r=v;let m;e[16]!==c?(m=c("Security"),e[16]=c,e[17]=m):m=e[17];let b;e[18]!==m?(b=t(_e,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==l||e[21]!==n.twoFactor||e[22]!==k||e[23]!==c?(x=n.twoFactor&&t(R,{"data-testid":"ud-disable-2fa",disabled:l,onClick:k,size:"sm",type:"button",variant:"outline",children:c("Disable two-factor")}),e[20]=l,e[21]=n.twoFactor,e[22]=k,e[23]=c,e[24]=x):x=e[24];let N;e[25]!==n.passkey||e[26]!==d||e[27]!==c?(N=n.passkey&&d!==null&&d.length===0&&t("p",{className:"text-sm text-muted-foreground",children:c("No passkeys.")}),e[25]=n.passkey,e[26]=d,e[27]=c,e[28]=N):N=e[28];let p;e[29]!==l||e[30]!==n.passkey||e[31]!==r||e[32]!==d||e[33]!==c?(p=n.passkey&&d!==null&&d.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-passkeys-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:c("name")}),t(U,{children:c("created")}),t(U,{"aria-label":c("Actions")})]})}),t(Te,{children:d.map(S=>{const T=Pe(S.id);return u(Q,{"data-testid":`ud-passkey-${T}`,children:[t(P,{children:Pe(S.name)||T}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(S.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-delete-passkey-${T}`,disabled:l,onClick:()=>{r(T)},size:"xs",type:"button",variant:"ghost",children:c("Delete")})})]},T)})})]})})}),e[29]=l,e[30]=n.passkey,e[31]=r,e[32]=d,e[33]=c,e[34]=p):p=e[34];let i;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==p?(i=u("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,p]}),e[35]=b,e[36]=x,e[37]=N,e[38]=p,e[39]=i):i=e[39],i},pt=/(?:at|expires)$/iu,vt=/^[1-9]\d*$/u,gt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),bt=h=>{const e=Z(51),{busy:l,onBan:n}=h,o=W(),[s,f]=I(""),[a,c]=I(""),[d,y]=I(!1);let C;e[0]!==a?(C=vt.test(a.trim())&&Number.isSafeInteger(Number(a.trim())*86400)?Number(a.trim()):void 0,e[0]=a,e[1]=C):C=e[1];const g=C,w=d||g!==void 0;let k;e[2]!==n||e[3]!==d||e[4]!==s||e[5]!==g?(k=()=>{n({expiresInSeconds:d||g===void 0?void 0:g*86400,reason:s.trim()===""?void 0:s.trim()})},e[2]=n,e[3]=d,e[4]=s,e[5]=g,e[6]=k):k=e[6];const v=k;let r;e[7]!==o?(r=o("Ban reason (optional)"),e[7]=o,e[8]=r):r=e[8];let m;e[9]!==r?(m=t(_,{htmlFor:"ud-ban-reason",children:r}),e[9]=r,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=$=>{f($.target.value)},e[11]=b):b=e[11];let x;e[12]!==s?(x=t(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:s}),e[12]=s,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=u("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let p;e[17]!==o?(p=o("Days"),e[17]=o,e[18]=p):p=e[18];let i;e[19]!==p?(i=t(_,{htmlFor:"ud-ban-days",children:p}),e[19]=p,e[20]=i):i=e[20];let S;e[21]!==a||e[22]!==g?(S=a.trim()!==""&&g===void 0,e[21]=a,e[22]=g,e[23]=S):S=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=$=>{c($.target.value)},e[24]=T):T=e[24];let z;e[25]!==a||e[26]!==d||e[27]!==S?(z=t(B,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:d,id:"ud-ban-days",min:1,onChange:T,step:1,type:"number",value:a}),e[25]=a,e[26]=d,e[27]=S,e[28]=z):z=e[28];let j;e[29]!==z||e[30]!==i?(j=u("div",{className:"flex w-24 flex-col gap-1",children:[i,z]}),e[29]=z,e[30]=i,e[31]=j):j=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=$=>{y($.target.checked)},e[32]=M):M=e[32];let H;e[33]!==d?(H=t("input",{checked:d,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=d,e[34]=H):H=e[34];let L;e[35]!==o?(L=o("Permanent"),e[35]=o,e[36]=L):L=e[36];let V;e[37]!==H||e[38]!==L?(V=u(_,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[H,L]}),e[37]=H,e[38]=L,e[39]=V):V=e[39];const Y=l||!w;let E;e[40]!==o?(E=o("Ban user"),e[40]=o,e[41]=E):E=e[41];let O;e[42]!==v||e[43]!==Y||e[44]!==E?(O=t(R,{"data-testid":"ud-ban",disabled:Y,onClick:v,size:"sm",type:"button",variant:"destructive",children:E}),e[42]=v,e[43]=Y,e[44]=E,e[45]=O):O=e[45];let F;return e[46]!==j||e[47]!==V||e[48]!==O||e[49]!==N?(F=u("div",{className:"flex items-end gap-2",children:[N,j,V,O]}),e[46]=j,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},xt=(h,e)=>typeof e=="number"&&pt.test(h)?Fe(e):Pe(e),yt=({capabilities:h,onChanged:e,onClose:l,user:n})=>{const o=ee(),s=W(),f=n.banned===!0,[a,c]=I(null),[d,y]=I(!1),[C,g]=I(0),[w,k]=I(typeof n.role=="string"?n.role:""),[v,r]=I(""),[m,b]=I(null),[x,N]=I(!1),p=(F,$)=>{J((async()=>{y(!0),c(null);try{const Ue=await F();$?.refresh!==!1&&(g(te=>te+1),e()),$?.onResult?.(Ue)}catch(Ue){c(Ve(Ue))}y(!1)})())},i=F=>{k(F.target.value)},S=F=>{r(F.target.value)},T=()=>{const F=w.trim();F!==""&&p(async()=>{await o.setAuthUserRole({role:F,userId:n.id})})},z=F=>{p(async()=>{await o.banAuthUser({...F,userId:n.id})})},j=()=>{p(async()=>{await o.unbanAuthUser({userId:n.id})})},M=()=>{p(async()=>{await o.setAuthUserPassword({newPassword:v,userId:n.id}),r("")})},H=()=>{p(()=>o.impersonateAuthUser({userId:n.id}),{onResult:F=>{b(F.token)},refresh:!1})},L=()=>{p(async()=>{await o.revokeAuthUserSessions({userId:n.id})})},V=()=>{p(async()=>{await o.removeAuthUser({userId:n.id}),l()})},Y=()=>{N(!0)},E=()=>{N(!1)},O=Object.entries(n).filter(([F])=>!gt.has(F));return u(We,{label:s("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[u("div",{className:"flex items-start justify-between gap-2",children:[u("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:n.name??n.email??n.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:n.id}),u("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof n.role=="string"&&n.role!==""&&t(q,{variant:"secondary",children:n.role}),f?t(q,{variant:"destructive",children:s("Banned")}):t(q,{variant:"outline",children:s("Active")}),n.emailVerified===!0?t(q,{variant:"secondary",children:s("verified")}):t(q,{variant:"outline",children:s("unverified")})]})]}),t(R,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:a}),h.admin&&u(K,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")})}),u(X,{className:"flex flex-col gap-3 p-3",children:[u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-role",children:s("Role")}),t(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:i,value:w})]}),t(R,{"data-testid":"ud-set-role",disabled:d||w.trim()==="",onClick:T,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),f?t(R,{"data-testid":"ud-unban",disabled:d,onClick:j,size:"sm",type:"button",variant:"outline",children:s("Unban")}):t(bt,{busy:d,onBan:z}),u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-password",children:s("New password")}),t(B,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),t(R,{"data-testid":"ud-set-password",disabled:d||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:s("Set password")})]}),u("div",{className:"flex flex-wrap gap-2",children:[t(R,{"data-testid":"ud-impersonate",disabled:d,onClick:H,size:"sm",type:"button",variant:"outline",children:s("Impersonate")}),t(R,{"data-testid":"ud-revoke-all",disabled:d,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),x?u(et,{children:[t(R,{"data-testid":"ud-delete-confirm",disabled:d,onClick:V,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(R,{"data-testid":"ud-delete-cancel",onClick:E,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(R,{"data-testid":"ud-delete",disabled:d,onClick:Y,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),m!==null&&u("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(_,{htmlFor:"ud-token",children:s("Impersonation token")}),t(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),t(mt,{busy:d,runAction:p,userId:n.id,version:C}),h.accounts&&t(ht,{busy:d,runAction:p,userId:n.id,version:C}),(h.twoFactor||h.passkey)&&t(ft,{busy:d,capabilities:h,runAction:p,userId:n.id,version:C}),u("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")}),t("dl",{className:"flex flex-col",children:O.map(([F,$])=>u("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),t("dd",{className:"m-0 font-mono text-xs break-words",children:xt(F,$)})]},F))})]})]})},Nt=50,jt=({pageSize:h=Nt}={})=>{const e=ee(),l=W(),[n,o]=I(""),[s,f]=I(""),[a,c]=I(0),d=Je(n),[y,C]=I(null),[g,w]=I(!1),{capabilities:k}=nt(),v=d.trim(),r=s.trim(),m=qe(["lunora-auth-users",v,r,h,a],()=>e.listAuthUsers({filterField:r===""?void 0:"role",filterValue:r===""?void 0:r,limit:h,offset:a,search:v===""?void 0:v}).then(i=>({...i,offset:a})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=()=>{m.refetch()};Ge(()=>m.poll(),!0);const p=y===null?null:b?.find(i=>i.id===y)??null;return u("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[u("div",{className:"flex flex-wrap items-center gap-2",children:[t(B,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:i=>{o(i.target.value),c(0)},placeholder:l("Search by email or name…"),value:n}),t(B,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i=>{f(i.target.value),c(0)},placeholder:l("Filter by role"),value:s}),t(R,{"data-testid":"us-new",onClick:()=>{w(!0)},size:"sm",type:"button",children:l("New user")})]}),x!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&t(Ye,{description:l("Users who sign up to your app will appear here."),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:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),b!==null&&b.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"us-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:l("id")}),t(U,{children:l("email")}),t(U,{children:l("name")}),t(U,{children:l("role")}),t(U,{children:l("status")}),t(U,{children:l("verified")}),t(U,{children:l("created")}),t(U,{"aria-label":l("Actions")})]})}),t(Te,{children:b.map(i=>u(Q,{"data-testid":`us-row-${i.id}`,children:[t(P,{className:"font-mono text-xs",children:i.id}),t(P,{children:i.email??""}),t(P,{children:i.name??""}),t(P,{children:typeof i.role=="string"&&i.role!==""?t(q,{variant:"secondary",children:i.role}):""}),t(P,{children:i.banned===!0?t(q,{variant:"destructive",children:l("Banned")}):t(q,{variant:"success",children:l("Active")})}),t(P,{children:i.emailVerified===!0?t(q,{variant:"success",children:l("yes")}):t(q,{variant:"outline",children:l("no")})}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`us-manage-${i.id}`,onClick:()=>{C(i.id)},size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},i.id))})]})})}),b!==null&&t(Xe,{count:b.length,offset:m.data?.offset??0,onOffsetChange:c,pageSize:h,prefix:"us",total:m.data?.total}),p!==null&&t(yt,{capabilities:k,onChanged:N,onClose:()=>{C(null)},user:p}),g&&t(ut,{onClose:()=>{w(!1)},onCreated:N}),k.inviteOnly&&t(rt,{})]})};export{jt as UsersPanel};
1
+ import{useState as I,useEffect as Me}from"react";import{B as q}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as R}from"../packem_shared/button-q0UYSmrn.mjs";import{C as K,a as X}from"../packem_shared/card-By2O8ULa.mjs";import{E as Ye}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as B}from"../packem_shared/input-CXhxesPC.mjs";import{T as Ee,a as Re,b as Q,c as U,d as Te,e as P}from"../packem_shared/table-D0SBiDu-.mjs";import{a as qe}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{c as Z}from"react/compiler-runtime";import{u as Qe}from"../packem_shared/use-auth-config-CG7VvAvQ.mjs";import{useAutoRefresh as Ge}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-Py5Yx7rP.mjs";import Je from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{u as ee}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as W}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{w as Ke,h as Fe,f as J,l as Pe,b as Ve}from"../packem_shared/internal-hIuTpSbx.mjs";import{A as Xe}from"../packem_shared/auth-pager-DW77WeZw.mjs";import{jsxs as u,jsx as t,Fragment as et}from"react/jsx-runtime";import{C as tt}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{L as _}from"../packem_shared/label-DKFzyHq6.mjs";import{M as We}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{u as st}from"../packem_shared/use-async-submit-D0r7-m2J.mjs";const nt=()=>{const h=Z(3),{config:e,ready:l}=Qe();let n;return h[0]!==e.capabilities||h[1]!==l?(n={capabilities:e.capabilities,ready:l},h[0]=e.capabilities,h[1]=l,h[2]=n):n=h[2],n},lt=(h,e)=>typeof h.acceptedAt=="number"?"spent":typeof h.expiresAt=="number"&&h.expiresAt<=e?"expired":"pending",He=500,at=(h,e)=>{if(!URL.canParse(h.trim()))return null;const l=new URL(h.trim());return l.searchParams.set("email",e.email),l.searchParams.set("invite",e.token),l.toString()},it=h=>{const e=Z(34),{issued:l,onSignUpPageChange:n,signUpPage:o}=h,s=W(),[f,a]=I(null);let c;e[0]!==l||e[1]!==o?(c=at(o,l),e[0]=l,e[1]=o,e[2]=c):c=e[2];const d=c;let y;e[3]!==d?(y=()=>{const T="navigator"in globalThis?globalThis.navigator.clipboard:void 0;d===null||T===void 0||J(T.writeText(d).then(()=>(a(d),!0)))},e[3]=d,e[4]=y):y=e[4];const C=y;let g;e[5]!==s?(g=s("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=s,e[6]=g):g=e[6];let w;e[7]!==g?(w=t("p",{className:"text-sm",children:g}),e[7]=g,e[8]=w):w=e[8];const k=d===null;let v;e[9]!==s?(v=s("Your app's sign-up page"),e[9]=s,e[10]=v):v=e[10];let r;e[11]!==n?(r=T=>{n(T.target.value)},e[11]=n,e[12]=r):r=e[12];let m;e[13]!==o||e[14]!==k||e[15]!==v||e[16]!==r?(m=t(B,{"aria-invalid":k,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:r,value:o}),e[13]=o,e[14]=k,e[15]=v,e[16]=r,e[17]=m):m=e[17];const b=d??"";let x;e[18]!==b?(x=t(B,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:b}),e[18]=b,e[19]=x):x=e[19];let N;e[20]!==f||e[21]!==d||e[22]!==s?(N=s(f!==null&&f===d?"Copied":"Copy"),e[20]=f,e[21]=d,e[22]=s,e[23]=N):N=e[23];let p;e[24]!==C||e[25]!==N?(p=t(R,{"data-testid":"sign-up-invitation-copy",onClick:C,type:"button",children:N}),e[24]=C,e[25]=N,e[26]=p):p=e[26];let i;e[27]!==x||e[28]!==p?(i=u("div",{className:"flex gap-2",children:[x,p]}),e[27]=x,e[28]=p,e[29]=i):i=e[29];let S;return e[30]!==i||e[31]!==w||e[32]!==m?(S=t(K,{children:u(X,{className:"flex flex-col gap-2 p-4",children:[w,m,i]})}),e[30]=i,e[31]=w,e[32]=m,e[33]=S):S=e[33],S},rt=()=>{const h=ee(),e=W(),[l,n]=I(""),[o,s]=I(null),[f,a]=I(null),[c,d]=I(()=>`${Ke(h.url)}/sign-up`),y=qe(["lunora-auth-sign-up-invitations",He],()=>h.listAuthSignUpInvitations({limit:He})),C=y.data?.rows??null,g=y.data?.total??0,w=()=>{const v=l.trim();v!==""&&(s(null),J((async()=>{try{const r=await h.createAuthSignUpInvitation({email:v}),m=typeof r.token=="string"?r.token:void 0;a(m===void 0?null:{email:v,token:m}),n(""),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})()))},k=v=>{s(null),J((async()=>{try{await h.revokeAuthSignUpInvitation({email:v}),y.refetch()}catch(r){s(r instanceof Error?r.message:String(r))}})())};return u("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[u("div",{children:[t("h2",{className:"text-base font-medium",children:e("Sign-up invitations")}),t("p",{className:"text-sm text-muted-foreground",children:e("Only invited addresses can create an account. Nothing is emailed — send the invitee the one-time link yourself.")})]}),u("div",{className:"flex gap-2",children:[t(B,{"aria-label":e("Email address to invite"),"data-testid":"sign-up-invitation-email",onChange:v=>{n(v.target.value)},placeholder:e("ada@example.com"),type:"email",value:l}),t(R,{"data-testid":"sign-up-invitation-submit",onClick:w,type:"button",children:e("Invite")})]}),f!==null&&t(it,{issued:f,onSignUpPageChange:d,signUpPage:c},f.token),(o??y.error)!==null&&t("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:o??y.error}),C!==null&&C.length===0&&t(Ye,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),C!==null&&g>C.length&&t("p",{className:"text-sm text-muted-foreground","data-testid":"sign-up-invitations-truncated",children:e("Showing the most recent invitations. Query the signUpInvitation table directly to see the rest.")}),C!==null&&C.length>0&&t(K,{children:t(X,{className:"p-0",children:u(Ee,{children:[t(Re,{children:u(Q,{children:[t(U,{children:e("Email")}),t(U,{children:e("Status")}),t(U,{children:e("Expires")}),t(U,{children:e("Invited by")}),t(U,{})]})}),t(Te,{children:C.map(v=>{const r=lt(v,Date.now()),m=v.email??"";return u(Q,{"data-testid":`sign-up-invitation-${m}`,children:[t(P,{children:m}),u(P,{"data-testid":`sign-up-invitation-status-${m}`,children:[r==="spent"&&e("Accepted"),r==="expired"&&e("Expired"),r==="pending"&&e("Pending")]}),t(P,{children:typeof v.expiresAt=="number"?Fe(v.expiresAt):"—"}),t(P,{children:v.invitedBy??"—"}),t(P,{className:"text-right",children:t(R,{onClick:()=>{k(m)},type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},ot={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},dt=(h,e)=>h.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:h.type!=="number"||!Number.isNaN(Number(e.trim())),ct=(h,e)=>{if(h.type==="boolean")return e===!0?{value:!0}:h.required?{value:!1}:void 0;const l=typeof e=="string"?e.trim():"";if(l!==""){if(h.type==="number"){const n=Number(l);return Number.isNaN(n)?void 0:{value:n}}return{value:l}}},ut=h=>{const e=Z(105),{onClose:l,onCreated:n}=h,o=ee(),s=W(),{config:f}=Qe(),{busy:a,error:c,run:d}=st(),[y,C]=I(""),[g,w]=I(""),[k,v]=I(""),[r,m]=I("");let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b={},e[0]=b):b=e[0];const[x,N]=I(b);let p;e[1]===Symbol.for("react.memo_cache_sentinel")?(p=A=>{C(A.target.value)},e[1]=p):p=e[1];const i=p;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=A=>{w(A.target.value)},e[2]=S):S=e[2];const T=S;let z;e[3]===Symbol.for("react.memo_cache_sentinel")?(z=A=>{v(A.target.value)},e[3]=z):z=e[3];const j=z;let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=A=>{m(A.target.value)},e[4]=M):M=e[4];const H=M;let L;e[5]===Symbol.for("react.memo_cache_sentinel")?(L=(A,D)=>{N(G=>({...G,[A]:D}))},e[5]=L):L=e[5];const V=L;let Y;e[6]!==x?(Y=A=>x[A.name]??(A.type==="boolean"?!1:""),e[6]=x,e[7]=Y):Y=e[7];const E=Y;let O;if(e[8]!==f.userFields||e[9]!==E){let A;e[11]!==E?(A=D=>!D.required||dt(D,E(D)),e[11]=E,e[12]=A):A=e[12],O=f.userFields.every(A),e[8]=f.userFields,e[9]=E,e[10]=O}else O=e[10];const F=O;let $;e[13]!==a||e[14]!==y||e[15]!==g||e[16]!==F?($=!a&&y.trim()!==""&&g.trim()!==""&&F,e[13]=a,e[14]=y,e[15]=g,e[16]=F,e[17]=$):$=e[17];const Ue=$;let te;e[18]!==f.userFields||e[19]!==E?(te=()=>{const A={};for(const D of f.userFields){const G=ct(D,E(D));G!==void 0&&(A[D.name]=G.value)}return Object.keys(A).length===0?void 0:A},e[18]=f.userFields,e[19]=E,e[20]=te):te=e[20];const Be=te;let De;e[21]!==Be||e[22]!==o||e[23]!==y||e[24]!==g||e[25]!==l||e[26]!==n||e[27]!==k||e[28]!==r||e[29]!==d?(De=()=>{d(async()=>{await o.createAuthUser({data:Be(),email:y.trim(),name:g.trim(),password:k===""?void 0:k,role:r.trim()===""?void 0:r.trim()}),n(),l()})},e[21]=Be,e[22]=o,e[23]=y,e[24]=g,e[25]=l,e[26]=n,e[27]=k,e[28]=r,e[29]=d,e[30]=De):De=e[30];const ze=De;let se;e[31]!==s?(se=s("Create user"),e[31]=s,e[32]=se):se=e[32];let ne;e[33]!==s?(ne=s("Create user"),e[33]=s,e[34]=ne):ne=e[34];let le;e[35]!==ne?(le=t("h2",{className:"text-sm font-semibold text-foreground",children:ne}),e[35]=ne,e[36]=le):le=e[36];let ae;e[37]!==s?(ae=s("email"),e[37]=s,e[38]=ae):ae=e[38];let ie;e[39]!==ae?(ie=t(_,{htmlFor:"uc-email",children:ae}),e[39]=ae,e[40]=ie):ie=e[40];let re;e[41]!==y?(re=t(B,{"data-testid":"uc-email",id:"uc-email",onChange:i,type:"email",value:y}),e[41]=y,e[42]=re):re=e[42];let oe;e[43]!==ie||e[44]!==re?(oe=u("div",{className:"flex flex-col gap-1",children:[ie,re]}),e[43]=ie,e[44]=re,e[45]=oe):oe=e[45];let de;e[46]!==s?(de=s("name"),e[46]=s,e[47]=de):de=e[47];let ce;e[48]!==de?(ce=t(_,{htmlFor:"uc-name",children:de}),e[48]=de,e[49]=ce):ce=e[49];let ue;e[50]!==g?(ue=t(B,{"data-testid":"uc-name",id:"uc-name",onChange:T,value:g}),e[50]=g,e[51]=ue):ue=e[51];let me;e[52]!==ce||e[53]!==ue?(me=u("div",{className:"flex flex-col gap-1",children:[ce,ue]}),e[52]=ce,e[53]=ue,e[54]=me):me=e[54];let he;e[55]!==s?(he=s("Password (optional)"),e[55]=s,e[56]=he):he=e[56];let fe;e[57]!==he?(fe=t(_,{htmlFor:"uc-password",children:he}),e[57]=he,e[58]=fe):fe=e[58];let pe;e[59]!==k?(pe=t(B,{"data-testid":"uc-password",id:"uc-password",onChange:j,type:"password",value:k}),e[59]=k,e[60]=pe):pe=e[60];let ve;e[61]!==fe||e[62]!==pe?(ve=u("div",{className:"flex flex-col gap-1",children:[fe,pe]}),e[61]=fe,e[62]=pe,e[63]=ve):ve=e[63];let ge;e[64]!==s?(ge=s("Role (optional)"),e[64]=s,e[65]=ge):ge=e[65];let be;e[66]!==ge?(be=t(_,{htmlFor:"uc-role",children:ge}),e[66]=ge,e[67]=be):be=e[67];let xe;e[68]!==r?(xe=t(B,{"data-testid":"uc-role",id:"uc-role",onChange:H,value:r}),e[68]=r,e[69]=xe):xe=e[69];let ye;e[70]!==be||e[71]!==xe?(ye=u("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[70]=be,e[71]=xe,e[72]=ye):ye=e[72];let Ne;e[73]!==f.userFields||e[74]!==E||e[75]!==s?(Ne=f.userFields.length>0&&u("div",{className:"flex flex-col gap-3 border-t border-border pt-3","data-testid":"uc-plugin-fields",children:[t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Plugin fields")}),f.userFields.map(A=>{const D=`uc-field-${A.name}`,G=A.required?"":` (${s("optional")})`;if(A.type==="boolean"){const Oe=E(A)===!0;return u("label",{className:"flex items-center gap-2",htmlFor:D,children:[t(tt,{checked:Oe,"data-testid":D,id:D,onCheckedChange:Ze=>{V(A.name,Ze)}}),u("span",{className:"text-sm",children:[A.name,G]})]},A.name)}const je=E(A);return u("div",{className:"flex flex-col gap-1",children:[u(_,{htmlFor:D,children:[A.name,G]}),t(B,{"data-testid":D,id:D,onChange:Oe=>{V(A.name,Oe.target.value)},type:ot[A.type],value:typeof je=="string"?je:""})]},A.name)})]}),e[73]=f.userFields,e[74]=E,e[75]=s,e[76]=Ne):Ne=e[76];let ke;e[77]!==c?(ke=c!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:c}),e[77]=c,e[78]=ke):ke=e[78];let Ce;e[79]!==s?(Ce=s("Cancel"),e[79]=s,e[80]=Ce):Ce=e[80];let we;e[81]!==l||e[82]!==Ce?(we=t(R,{"data-testid":"uc-cancel",onClick:l,size:"sm",type:"button",variant:"outline",children:Ce}),e[81]=l,e[82]=Ce,e[83]=we):we=e[83];const Le=!Ue;let Ae;e[84]!==a||e[85]!==s?(Ae=s(a?"Creating…":"Create"),e[84]=a,e[85]=s,e[86]=Ae):Ae=e[86];let Se;e[87]!==ze||e[88]!==Le||e[89]!==Ae?(Se=t(R,{"data-testid":"uc-submit",disabled:Le,onClick:ze,size:"sm",type:"button",children:Ae}),e[87]=ze,e[88]=Le,e[89]=Ae,e[90]=Se):Se=e[90];let Ie;e[91]!==we||e[92]!==Se?(Ie=u("div",{className:"flex justify-end gap-2 pt-1",children:[we,Se]}),e[91]=we,e[92]=Se,e[93]=Ie):Ie=e[93];let $e;return e[94]!==l||e[95]!==se||e[96]!==le||e[97]!==oe||e[98]!==me||e[99]!==ve||e[100]!==ye||e[101]!==Ne||e[102]!==ke||e[103]!==Ie?($e=u(We,{label:se,onClose:l,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[le,oe,me,ve,ye,Ne,ke,Ie]}),e[94]=l,e[95]=se,e[96]=le,e[97]=oe,e[98]=me,e[99]=ve,e[100]=ye,e[101]=Ne,e[102]=ke,e[103]=Ie,e[104]=$e):$e=e[104],$e},_e=h=>{const e=Z(2),{children:l}=h;let n;return e[0]!==l?(n=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l}),e[0]=l,e[1]=n):n=e[1],n},mt=h=>{const e=Z(29),{busy:l,runAction:n,userId:o,version:s}=h,f=ee(),a=W(),[c,d]=I(null),[y,C]=I(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{const i=await f.listAuthSessions({limit:50,userId:o});d(i.rows)}catch(i){const S=i;d(null),C(Ve(S))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n?(k=i=>{n(()=>f.revokeAuthSession({sessionId:i}))},e[7]=f,e[8]=n,e[9]=k):k=e[9];const v=k;let r;e[10]!==a?(r=a("Sessions"),e[10]=a,e[11]=r):r=e[11];let m;e[12]!==r?(m=t(_e,{children:r}),e[12]=r,e[13]=m):m=e[13];let b;e[14]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:y}),e[14]=y,e[15]=b):b=e[15];let x;e[16]!==c||e[17]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:a("No active sessions.")}),e[16]=c,e[17]=a,e[18]=x):x=e[18];let N;e[19]!==l||e[20]!==v||e[21]!==c||e[22]!==a?(N=c!==null&&c.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-sessions-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("expires")}),t(U,{children:a("ip")}),t(U,{children:a("user agent")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>u(Q,{"data-testid":`ud-session-${i.id}`,children:[t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.expiresAt)}),t(P,{children:i.ipAddress??""}),t(P,{className:"max-w-40 truncate",children:i.userAgent??""}),t(P,{children:t(R,{"data-testid":`ud-revoke-${i.id}`,disabled:l,onClick:()=>{v(i.id)},size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},i.id))})]})})}),e[19]=l,e[20]=v,e[21]=c,e[22]=a,e[23]=N):N=e[23];let p;return e[24]!==m||e[25]!==b||e[26]!==x||e[27]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[m,b,x,N]}),e[24]=m,e[25]=b,e[26]=x,e[27]=N,e[28]=p):p=e[28],p},ht=h=>{const e=Z(30),{busy:l,runAction:n,userId:o,version:s}=h,f=ee(),a=W(),[c,d]=I(null),[y,C]=I(null);let g;e[0]!==f||e[1]!==o?(g=()=>{J((async()=>{C(null);try{d(await f.listAuthAccounts({userId:o}))}catch(i){const S=i;d(null),C(Ve(S))}})())},e[0]=f,e[1]=o,e[2]=g):g=e[2];let w;e[3]!==f||e[4]!==o||e[5]!==s?(w=[f,o,s],e[3]=f,e[4]=o,e[5]=s,e[6]=w):w=e[6],Me(g,w);let k;e[7]!==f||e[8]!==n||e[9]!==o?(k=i=>{n(()=>f.unlinkAuthAccount({accountId:i,userId:o}))},e[7]=f,e[8]=n,e[9]=o,e[10]=k):k=e[10];const v=k;let r;e[11]!==a?(r=a("Linked accounts"),e[11]=a,e[12]=r):r=e[12];let m;e[13]!==r?(m=t(_e,{children:r}),e[13]=r,e[14]=m):m=e[14];let b;e[15]!==y?(b=y!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:y}),e[15]=y,e[16]=b):b=e[16];let x;e[17]!==c||e[18]!==a?(x=c!==null&&c.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No linked accounts.")}),e[17]=c,e[18]=a,e[19]=x):x=e[19];let N;e[20]!==c||e[21]!==l||e[22]!==v||e[23]!==a?(N=c!==null&&c.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-accounts-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:a("provider")}),t(U,{children:a("created")}),t(U,{"aria-label":a("Actions")})]})}),t(Te,{children:c.map(i=>{const S=Pe(i.id);return u(Q,{"data-testid":`ud-account-${S}`,children:[t(P,{children:Pe(i.providerId)}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-unlink-${S}`,disabled:l,onClick:()=>{v(S)},size:"xs",type:"button",variant:"ghost",children:a("Unlink")})})]},S)})})]})})}),e[20]=c,e[21]=l,e[22]=v,e[23]=a,e[24]=N):N=e[24];let p;return e[25]!==m||e[26]!==b||e[27]!==x||e[28]!==N?(p=u("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[m,b,x,N]}),e[25]=m,e[26]=b,e[27]=x,e[28]=N,e[29]=p):p=e[29],p},ft=h=>{const e=Z(40),{busy:l,capabilities:n,runAction:o,userId:s,version:f}=h,a=ee(),c=W(),[d,y]=I(null);let C;e[0]!==n.passkey||e[1]!==a||e[2]!==s?(C=()=>{n.passkey&&J((async()=>{try{y(await a.listAuthPasskeys({userId:s}))}catch{y(null)}})())},e[0]=n.passkey,e[1]=a,e[2]=s,e[3]=C):C=e[3];let g;e[4]!==n.passkey||e[5]!==a||e[6]!==s||e[7]!==f?(g=[n.passkey,a,s,f],e[4]=n.passkey,e[5]=a,e[6]=s,e[7]=f,e[8]=g):g=e[8],Me(C,g);let w;e[9]!==a||e[10]!==o||e[11]!==s?(w=()=>{o(()=>a.disableAuthTwoFactor({userId:s}))},e[9]=a,e[10]=o,e[11]=s,e[12]=w):w=e[12];const k=w;let v;e[13]!==a||e[14]!==o?(v=S=>{o(()=>a.deleteAuthPasskey({passkeyId:S}))},e[13]=a,e[14]=o,e[15]=v):v=e[15];const r=v;let m;e[16]!==c?(m=c("Security"),e[16]=c,e[17]=m):m=e[17];let b;e[18]!==m?(b=t(_e,{children:m}),e[18]=m,e[19]=b):b=e[19];let x;e[20]!==l||e[21]!==n.twoFactor||e[22]!==k||e[23]!==c?(x=n.twoFactor&&t(R,{"data-testid":"ud-disable-2fa",disabled:l,onClick:k,size:"sm",type:"button",variant:"outline",children:c("Disable two-factor")}),e[20]=l,e[21]=n.twoFactor,e[22]=k,e[23]=c,e[24]=x):x=e[24];let N;e[25]!==n.passkey||e[26]!==d||e[27]!==c?(N=n.passkey&&d!==null&&d.length===0&&t("p",{className:"text-sm text-muted-foreground",children:c("No passkeys.")}),e[25]=n.passkey,e[26]=d,e[27]=c,e[28]=N):N=e[28];let p;e[29]!==l||e[30]!==n.passkey||e[31]!==r||e[32]!==d||e[33]!==c?(p=n.passkey&&d!==null&&d.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"ud-passkeys-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:c("name")}),t(U,{children:c("created")}),t(U,{"aria-label":c("Actions")})]})}),t(Te,{children:d.map(S=>{const T=Pe(S.id);return u(Q,{"data-testid":`ud-passkey-${T}`,children:[t(P,{children:Pe(S.name)||T}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(S.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-delete-passkey-${T}`,disabled:l,onClick:()=>{r(T)},size:"xs",type:"button",variant:"ghost",children:c("Delete")})})]},T)})})]})})}),e[29]=l,e[30]=n.passkey,e[31]=r,e[32]=d,e[33]=c,e[34]=p):p=e[34];let i;return e[35]!==b||e[36]!==x||e[37]!==N||e[38]!==p?(i=u("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[b,x,N,p]}),e[35]=b,e[36]=x,e[37]=N,e[38]=p,e[39]=i):i=e[39],i},pt=/(?:at|expires)$/iu,vt=/^[1-9]\d*$/u,gt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),bt=h=>{const e=Z(51),{busy:l,onBan:n}=h,o=W(),[s,f]=I(""),[a,c]=I(""),[d,y]=I(!1);let C;e[0]!==a?(C=vt.test(a.trim())&&Number.isSafeInteger(Number(a.trim())*86400)?Number(a.trim()):void 0,e[0]=a,e[1]=C):C=e[1];const g=C,w=d||g!==void 0;let k;e[2]!==n||e[3]!==d||e[4]!==s||e[5]!==g?(k=()=>{n({expiresInSeconds:d||g===void 0?void 0:g*86400,reason:s.trim()===""?void 0:s.trim()})},e[2]=n,e[3]=d,e[4]=s,e[5]=g,e[6]=k):k=e[6];const v=k;let r;e[7]!==o?(r=o("Ban reason (optional)"),e[7]=o,e[8]=r):r=e[8];let m;e[9]!==r?(m=t(_,{htmlFor:"ud-ban-reason",children:r}),e[9]=r,e[10]=m):m=e[10];let b;e[11]===Symbol.for("react.memo_cache_sentinel")?(b=$=>{f($.target.value)},e[11]=b):b=e[11];let x;e[12]!==s?(x=t(B,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:b,value:s}),e[12]=s,e[13]=x):x=e[13];let N;e[14]!==m||e[15]!==x?(N=u("div",{className:"flex flex-1 flex-col gap-1",children:[m,x]}),e[14]=m,e[15]=x,e[16]=N):N=e[16];let p;e[17]!==o?(p=o("Days"),e[17]=o,e[18]=p):p=e[18];let i;e[19]!==p?(i=t(_,{htmlFor:"ud-ban-days",children:p}),e[19]=p,e[20]=i):i=e[20];let S;e[21]!==a||e[22]!==g?(S=a.trim()!==""&&g===void 0,e[21]=a,e[22]=g,e[23]=S):S=e[23];let T;e[24]===Symbol.for("react.memo_cache_sentinel")?(T=$=>{c($.target.value)},e[24]=T):T=e[24];let z;e[25]!==a||e[26]!==d||e[27]!==S?(z=t(B,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:d,id:"ud-ban-days",min:1,onChange:T,step:1,type:"number",value:a}),e[25]=a,e[26]=d,e[27]=S,e[28]=z):z=e[28];let j;e[29]!==z||e[30]!==i?(j=u("div",{className:"flex w-24 flex-col gap-1",children:[i,z]}),e[29]=z,e[30]=i,e[31]=j):j=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=$=>{y($.target.checked)},e[32]=M):M=e[32];let H;e[33]!==d?(H=t("input",{checked:d,className:"size-4 accent-destructive","data-testid":"ud-ban-permanent",id:"ud-ban-permanent",onChange:M,type:"checkbox"}),e[33]=d,e[34]=H):H=e[34];let L;e[35]!==o?(L=o("Permanent"),e[35]=o,e[36]=L):L=e[36];let V;e[37]!==H||e[38]!==L?(V=u(_,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[H,L]}),e[37]=H,e[38]=L,e[39]=V):V=e[39];const Y=l||!w;let E;e[40]!==o?(E=o("Ban user"),e[40]=o,e[41]=E):E=e[41];let O;e[42]!==v||e[43]!==Y||e[44]!==E?(O=t(R,{"data-testid":"ud-ban",disabled:Y,onClick:v,size:"sm",type:"button",variant:"destructive",children:E}),e[42]=v,e[43]=Y,e[44]=E,e[45]=O):O=e[45];let F;return e[46]!==j||e[47]!==V||e[48]!==O||e[49]!==N?(F=u("div",{className:"flex items-end gap-2",children:[N,j,V,O]}),e[46]=j,e[47]=V,e[48]=O,e[49]=N,e[50]=F):F=e[50],F},xt=(h,e)=>typeof e=="number"&&pt.test(h)?Fe(e):Pe(e),yt=({capabilities:h,onChanged:e,onClose:l,user:n})=>{const o=ee(),s=W(),f=n.banned===!0,[a,c]=I(null),[d,y]=I(!1),[C,g]=I(0),[w,k]=I(typeof n.role=="string"?n.role:""),[v,r]=I(""),[m,b]=I(null),[x,N]=I(!1),p=(F,$)=>{J((async()=>{y(!0),c(null);try{const Ue=await F();$?.refresh!==!1&&(g(te=>te+1),e()),$?.onResult?.(Ue)}catch(Ue){c(Ve(Ue))}y(!1)})())},i=F=>{k(F.target.value)},S=F=>{r(F.target.value)},T=()=>{const F=w.trim();F!==""&&p(async()=>{await o.setAuthUserRole({role:F,userId:n.id})})},z=F=>{p(async()=>{await o.banAuthUser({...F,userId:n.id})})},j=()=>{p(async()=>{await o.unbanAuthUser({userId:n.id})})},M=()=>{p(async()=>{await o.setAuthUserPassword({newPassword:v,userId:n.id}),r("")})},H=()=>{p(()=>o.impersonateAuthUser({userId:n.id}),{onResult:F=>{b(F.token)},refresh:!1})},L=()=>{p(async()=>{await o.revokeAuthUserSessions({userId:n.id})})},V=()=>{p(async()=>{await o.removeAuthUser({userId:n.id}),l()})},Y=()=>{N(!0)},E=()=>{N(!1)},O=Object.entries(n).filter(([F])=>!gt.has(F));return u(We,{label:s("User details"),onClose:l,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[u("div",{className:"flex items-start justify-between gap-2",children:[u("div",{className:"flex flex-col gap-1",children:[t("h2",{className:"text-sm font-semibold text-foreground",children:n.name??n.email??n.id}),t("p",{className:"font-mono text-xs text-muted-foreground",children:n.id}),u("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof n.role=="string"&&n.role!==""&&t(q,{variant:"secondary",children:n.role}),f?t(q,{variant:"destructive",children:s("Banned")}):t(q,{variant:"outline",children:s("Active")}),n.emailVerified===!0?t(q,{variant:"secondary",children:s("verified")}):t(q,{variant:"outline",children:s("unverified")})]})]}),t(R,{"data-testid":"ud-close",onClick:l,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:a}),h.admin&&u(K,{className:"gap-0 py-0",children:[t("header",{className:"border-b border-border px-4 py-3",children:t("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Actions")})}),u(X,{className:"flex flex-col gap-3 p-3",children:[u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-role",children:s("Role")}),t(B,{"data-testid":"ud-role-input",id:"ud-role",onChange:i,value:w})]}),t(R,{"data-testid":"ud-set-role",disabled:d||w.trim()==="",onClick:T,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),f?t(R,{"data-testid":"ud-unban",disabled:d,onClick:j,size:"sm",type:"button",variant:"outline",children:s("Unban")}):t(bt,{busy:d,onBan:z}),u("div",{className:"flex items-end gap-2",children:[u("div",{className:"flex flex-1 flex-col gap-1",children:[t(_,{htmlFor:"ud-password",children:s("New password")}),t(B,{"data-testid":"ud-password",id:"ud-password",onChange:S,type:"password",value:v})]}),t(R,{"data-testid":"ud-set-password",disabled:d||v==="",onClick:M,size:"sm",type:"button",variant:"outline",children:s("Set password")})]}),u("div",{className:"flex flex-wrap gap-2",children:[t(R,{"data-testid":"ud-impersonate",disabled:d,onClick:H,size:"sm",type:"button",variant:"outline",children:s("Impersonate")}),t(R,{"data-testid":"ud-revoke-all",disabled:d,onClick:L,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),x?u(et,{children:[t(R,{"data-testid":"ud-delete-confirm",disabled:d,onClick:V,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(R,{"data-testid":"ud-delete-cancel",onClick:E,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(R,{"data-testid":"ud-delete",disabled:d,onClick:Y,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),m!==null&&u("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(_,{htmlFor:"ud-token",children:s("Impersonation token")}),t(B,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:m})]})]})]}),t(mt,{busy:d,runAction:p,userId:n.id,version:C}),h.accounts&&t(ht,{busy:d,runAction:p,userId:n.id,version:C}),(h.twoFactor||h.passkey)&&t(ft,{busy:d,capabilities:h,runAction:p,userId:n.id,version:C}),u("div",{className:"flex flex-col gap-1","data-testid":"ud-fields",children:[t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:s("Fields")}),t("dl",{className:"flex flex-col",children:O.map(([F,$])=>u("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:F}),t("dd",{className:"m-0 font-mono text-xs break-words",children:xt(F,$)})]},F))})]})]})},Nt=50,jt=({pageSize:h=Nt}={})=>{const e=ee(),l=W(),[n,o]=I(""),[s,f]=I(""),[a,c]=I(0),d=Je(n),[y,C]=I(null),[g,w]=I(!1),{capabilities:k}=nt(),v=d.trim(),r=s.trim(),m=qe(["lunora-auth-users",v,r,h,a],()=>e.listAuthUsers({filterField:r===""?void 0:"role",filterValue:r===""?void 0:r,limit:h,offset:a,search:v===""?void 0:v}).then(i=>({...i,offset:a})),{keepPreviousData:!0}),b=m.data?.rows??null,x=m.error,N=()=>{m.refetch()};Ge(()=>m.poll(),!0);const p=y===null?null:b?.find(i=>i.id===y)??null;return u("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[u("div",{className:"flex flex-wrap items-center gap-2",children:[t(B,{"aria-label":l("Search users"),className:"w-56","data-testid":"us-search",onChange:i=>{o(i.target.value),c(0)},placeholder:l("Search by email or name…"),value:n}),t(B,{"aria-label":l("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:i=>{f(i.target.value),c(0)},placeholder:l("Filter by role"),value:s}),t(R,{"data-testid":"us-new",onClick:()=>{w(!0)},size:"sm",type:"button",children:l("New user")})]}),x!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:x}),b!==null&&b.length===0&&t(Ye,{description:l("Users who sign up to your app will appear here."),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:"M16 20v-2a4 4 0 0 0-4-4H7a4 4 0 0 0-4 4v2M9.5 10a3.5 3.5 0 1 0 0-7 3.5 3.5 0 0 0 0 7Zm11.5 10v-2a4 4 0 0 0-3-3.85"})}),testId:"us-empty",title:l("No users.")}),b!==null&&b.length>0&&t(K,{className:"overflow-hidden py-0",children:t(X,{className:"px-0",children:u(Ee,{"data-testid":"us-table",children:[t(Re,{children:u(Q,{children:[t(U,{children:l("id")}),t(U,{children:l("email")}),t(U,{children:l("name")}),t(U,{children:l("role")}),t(U,{children:l("status")}),t(U,{children:l("verified")}),t(U,{children:l("created")}),t(U,{"aria-label":l("Actions")})]})}),t(Te,{children:b.map(i=>u(Q,{"data-testid":`us-row-${i.id}`,children:[t(P,{className:"font-mono text-xs",children:i.id}),t(P,{children:i.email??""}),t(P,{children:i.name??""}),t(P,{children:typeof i.role=="string"&&i.role!==""?t(q,{variant:"secondary",children:i.role}):""}),t(P,{children:i.banned===!0?t(q,{variant:"destructive",children:l("Banned")}):t(q,{variant:"success",children:l("Active")})}),t(P,{children:i.emailVerified===!0?t(q,{variant:"success",children:l("yes")}):t(q,{variant:"outline",children:l("no")})}),t(P,{className:"text-muted-foreground tabular-nums",children:Fe(i.createdAt)}),t(P,{children:t(R,{"data-testid":`us-manage-${i.id}`,onClick:()=>{C(i.id)},size:"xs",type:"button",variant:"ghost",children:l("Manage")})})]},i.id))})]})})}),b!==null&&t(Xe,{count:b.length,offset:m.data?.offset??0,onOffsetChange:c,pageSize:h,prefix:"us",total:m.data?.total}),p!==null&&t(yt,{capabilities:k,onChanged:N,onClose:()=>{C(null)},user:p}),g&&t(ut,{onClose:()=>{w(!1)},onCreated:N}),k.inviteOnly&&t(rt,{})]})};export{jt as UsersPanel};