@lunora/studio 1.0.0-alpha.381 → 1.0.0-alpha.383

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 (198) hide show
  1. package/dist/index.d.mts +2 -2
  2. package/dist/index.d.ts +2 -2
  3. package/dist/index.mjs +1 -1
  4. package/dist/mount.d.mts +1 -1
  5. package/dist/mount.d.ts +1 -1
  6. package/dist/mount.mjs +1 -1
  7. package/dist/packem_chunks/AdvisorHealthPanel.mjs +1 -1
  8. package/dist/packem_chunks/ApiTab.mjs +1 -1
  9. package/dist/packem_chunks/AuditPanel.mjs +1 -1
  10. package/dist/packem_chunks/DeploymentHealthPanel.mjs +1 -1
  11. package/dist/packem_chunks/ExportImportPanel.mjs +1 -1
  12. package/dist/packem_chunks/FileBrowser.mjs +1 -1
  13. package/dist/packem_chunks/FunctionRunner.mjs +1 -1
  14. package/dist/packem_chunks/FunctionStatsPanel.mjs +1 -1
  15. package/dist/packem_chunks/HealthPanel.mjs +1 -1
  16. package/dist/packem_chunks/InsightsPanel.mjs +1 -1
  17. package/dist/packem_chunks/LogsPanel.mjs +1 -1
  18. package/dist/packem_chunks/MailPanel.mjs +1 -1
  19. package/dist/packem_chunks/MetricsPanel.mjs +1 -1
  20. package/dist/packem_chunks/NotificationsPanel.mjs +1 -1
  21. package/dist/packem_chunks/PitrPanel.mjs +1 -1
  22. package/dist/packem_chunks/SchemaViewer.mjs +1 -1
  23. package/dist/packem_chunks/SecurityAdvisorPanel.mjs +1 -1
  24. package/dist/packem_chunks/SettingsPanel.mjs +1 -1
  25. package/dist/packem_chunks/SqlEditorPanel.mjs +1 -1
  26. package/dist/packem_chunks/TableEditor.mjs +1 -1
  27. package/dist/packem_chunks/agents-panel.mjs +1 -1
  28. package/dist/packem_chunks/ai-usage-panel.mjs +1 -1
  29. package/dist/packem_chunks/analytics-panel.mjs +1 -1
  30. package/dist/packem_chunks/architecture-panel.mjs +1 -1
  31. package/dist/packem_chunks/assistant-panel.mjs +2 -2
  32. package/dist/packem_chunks/auth-audit-panel.mjs +1 -1
  33. package/dist/packem_chunks/auth-config-panel.mjs +1 -1
  34. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  35. package/dist/packem_chunks/containers-panel.mjs +1 -1
  36. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  37. package/dist/packem_chunks/evals-panel.mjs +1 -1
  38. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  39. package/dist/packem_chunks/flags-panel.mjs +1 -1
  40. package/dist/packem_chunks/issues-panel.mjs +1 -1
  41. package/dist/packem_chunks/kv-browser.mjs +1 -1
  42. package/dist/packem_chunks/log-drains-panel.mjs +1 -1
  43. package/dist/packem_chunks/migrations-route.mjs +1 -1
  44. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  45. package/dist/packem_chunks/payments-panel.mjs +1 -1
  46. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  47. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  48. package/dist/packem_chunks/queues-panel.mjs +1 -1
  49. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  50. package/dist/packem_chunks/rls-panel.mjs +1 -1
  51. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  52. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  53. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  54. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  55. package/dist/packem_chunks/traces-panel.mjs +1 -1
  56. package/dist/packem_chunks/users-panel.mjs +1 -1
  57. package/dist/packem_chunks/vector-browser.mjs +1 -1
  58. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  59. package/dist/packem_shared/ApiDocsPanel-BZNuHTR8.mjs +2 -0
  60. package/dist/packem_shared/{ApiReferencePanel-CQxU1Ocx.mjs → ApiReferencePanel-DDvLw7c1.mjs} +1 -1
  61. package/dist/packem_shared/{CommandPalette-BZCHLpst.mjs → CommandPalette-BjHFgNA6.mjs} +1 -1
  62. package/dist/packem_shared/{DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs → DEFAULT_AUTO_REFRESH_MS-jK7srdI4.mjs} +1 -1
  63. package/dist/packem_shared/{DataBrowser-CkVOu6py.mjs → DataBrowser-Dp8ayK1S.mjs} +1 -1
  64. package/dist/packem_shared/{GlobalDataBrowser-l2ECwXCm.mjs → GlobalDataBrowser-VehUMwUK.mjs} +1 -1
  65. package/dist/packem_shared/{HomePanel-c7as4tvl.mjs → HomePanel-D5-wWLAj.mjs} +1 -1
  66. package/dist/packem_shared/{MigrationsPanel-BQol4Un1.mjs → MigrationsPanel-CTd2YSSk.mjs} +1 -1
  67. package/dist/packem_shared/{OpenRpcReferencePanel-BFDG91tn.mjs → OpenRpcReferencePanel-dXFl95w8.mjs} +1 -1
  68. package/dist/packem_shared/{ScheduledJobs-Du8ZGL7v.mjs → ScheduledJobs-DPQHuiy6.mjs} +1 -1
  69. package/dist/packem_shared/Studio-CrfDOmdv.mjs +1 -0
  70. package/dist/packem_shared/{StudioApp-CsyDnrg2.mjs → StudioApp-DKBDIF7N.mjs} +1 -1
  71. package/dist/packem_shared/{advisor-view-gtf_DhUU.mjs → advisor-view-y9c2z5w1.mjs} +1 -1
  72. package/dist/packem_shared/{app.d-DpxFQ0qO.d.mts → app.d-QqDN78r1.d.mts} +1 -1
  73. package/dist/packem_shared/{app.d-DpxFQ0qO.d.ts → app.d-QqDN78r1.d.ts} +1 -1
  74. package/dist/packem_shared/{assistant-provider-Dw0roZh3.mjs → assistant-provider-b2GtJb5K.mjs} +1 -1
  75. package/dist/packem_shared/{data-grid-B5m1OosL.mjs → data-grid-GQLHcpMI.mjs} +1 -1
  76. package/dist/packem_shared/{diagram-export-panel-Vdt-DZnO.mjs → diagram-export-panel-miFPsocM.mjs} +1 -1
  77. package/dist/packem_shared/{error-alert-3AR_-s_s.mjs → error-alert-BxCd81tw.mjs} +1 -1
  78. package/dist/packem_shared/{grid-features-Drvfswwy.mjs → grid-features-Cdy2nWxA.mjs} +2 -2
  79. package/dist/packem_shared/{home-panel-TpxiaHgB.mjs → home-panel-BlvQ0xK2.mjs} +1 -1
  80. package/dist/packem_shared/{internal-hIuTpSbx.mjs → internal-BT5tH08j.mjs} +1 -1
  81. package/dist/packem_shared/{log-line-CYJQf6P-.mjs → log-line-BmYn49u1.mjs} +1 -1
  82. package/dist/packem_shared/{recording-client-z4CBi0y8.mjs → recording-client-D_-eNapT.mjs} +1 -1
  83. package/dist/packem_shared/{reference-view-DENugPcj.mjs → reference-view-CRtrtDMy.mjs} +3 -3
  84. package/dist/packem_shared/{schema-diagram-CtVPhOGj.mjs → schema-diagram-Dbs7-jSJ.mjs} +1 -1
  85. package/dist/packem_shared/{sql-result-table-DCwooMGW.mjs → sql-result-table-BuOHHoFG.mjs} +1 -1
  86. package/dist/packem_shared/{studio-DZlpp4Vx.mjs → studio-CwelGawN.mjs} +1 -1
  87. package/dist/packem_shared/{table-list-sidebar-Bfmg04MD.mjs → table-list-sidebar-Cw7ll9yK.mjs} +1 -1
  88. package/dist/packem_shared/{use-admin-query-CaOm4JS3.mjs → use-admin-query-DMnTt_hg.mjs} +1 -1
  89. package/dist/packem_shared/{use-admin-spec-CK7mk3Ui.mjs → use-admin-spec-Cokw73Ks.mjs} +1 -1
  90. package/dist/packem_shared/use-assistant-rpc-DLsuqTPB.mjs +1 -0
  91. package/dist/packem_shared/{use-async-submit-D0r7-m2J.mjs → use-async-submit-CBFJevkc.mjs} +1 -1
  92. package/dist/packem_shared/{use-auth-config-DameIc6y.mjs → use-auth-config-xzSMjhOV.mjs} +1 -1
  93. package/dist/packem_shared/{use-open-trace-BJKMJjeS.mjs → use-open-trace-trRfFb77.mjs} +1 -1
  94. package/dist/standalone/{chunk-QOK2UU3L.js → chunk-2IYIVCPN.js} +1 -1
  95. package/dist/standalone/{chunk-QCG2G6IF.js → chunk-2LKJSQKF.js} +1 -1
  96. package/dist/standalone/{chunk-5MIJ3KEK.js → chunk-4AGOKKRZ.js} +1 -1
  97. package/dist/standalone/{chunk-WDR3BJ2C.js → chunk-4KVCH3A4.js} +1 -1
  98. package/dist/standalone/{chunk-NDIEUO4N.js → chunk-54X7HWI6.js} +1 -1
  99. package/dist/standalone/{chunk-MNXXIISC.js → chunk-5CHKXJYN.js} +1 -1
  100. package/dist/standalone/{chunk-EVUVQB4Q.js → chunk-5IOQXXYH.js} +1 -1
  101. package/dist/standalone/chunk-5KQSRLQP.js +7 -0
  102. package/dist/standalone/{chunk-I626YY7T.js → chunk-5LJYJ5SF.js} +1 -1
  103. package/dist/standalone/chunk-6NZOJI3N.js +14 -0
  104. package/dist/standalone/chunk-6OIS24US.js +1 -0
  105. package/dist/standalone/{chunk-O4SDDSDL.js → chunk-76CCNRPQ.js} +1 -1
  106. package/dist/standalone/{chunk-OJO6ERJ4.js → chunk-7HIZZYHW.js} +1 -1
  107. package/dist/standalone/{chunk-Z4BLDRDD.js → chunk-7JIVSWQM.js} +1 -1
  108. package/dist/standalone/{chunk-NYLSD5LR.js → chunk-7O6F7GJ2.js} +1 -1
  109. package/dist/standalone/{chunk-DELDS72W.js → chunk-7OMB6F3L.js} +1 -1
  110. package/dist/standalone/{chunk-5QK3ZHNZ.js → chunk-7YHT6DLF.js} +1 -1
  111. package/dist/standalone/{chunk-K7GU4AIX.js → chunk-ABY6J4SX.js} +1 -1
  112. package/dist/standalone/{chunk-I7PUGF3D.js → chunk-APYV4J3H.js} +1 -1
  113. package/dist/standalone/{chunk-AY4DPAPO.js → chunk-B2QIV4WC.js} +1 -1
  114. package/dist/standalone/{chunk-X474JV2D.js → chunk-BCD7WQYW.js} +1 -1
  115. package/dist/standalone/{chunk-2VGEYQJ5.js → chunk-BIEYPLQZ.js} +1 -1
  116. package/dist/standalone/{chunk-UOFMFYZ7.js → chunk-BWS7JUQV.js} +2 -2
  117. package/dist/standalone/{chunk-UFFUDDK7.js → chunk-C6NIFA7C.js} +1 -1
  118. package/dist/standalone/{chunk-AWFFXR6S.js → chunk-CJ2V577P.js} +1 -1
  119. package/dist/standalone/{chunk-WONKLAKW.js → chunk-CNALVIPZ.js} +1 -1
  120. package/dist/standalone/{chunk-JQBZDS6X.js → chunk-D3MLU3PX.js} +1 -1
  121. package/dist/standalone/{chunk-2DKLUTH2.js → chunk-DKTTK2SX.js} +1 -1
  122. package/dist/standalone/{chunk-MTBY4GXM.js → chunk-DWNWEMQK.js} +1 -1
  123. package/dist/standalone/{chunk-NPZG7XK5.js → chunk-E52THCJJ.js} +1 -1
  124. package/dist/standalone/{chunk-ELWBGGS7.js → chunk-EU3IVSBQ.js} +1 -1
  125. package/dist/standalone/{chunk-YTLKHICM.js → chunk-FFECJKHB.js} +1 -1
  126. package/dist/standalone/{chunk-OVPS52RO.js → chunk-FKY2ID3J.js} +1 -1
  127. package/dist/standalone/{chunk-OR4RO6V4.js → chunk-FYSSF7AJ.js} +1 -1
  128. package/dist/standalone/{chunk-ZHZHI6KX.js → chunk-G7GMOSDG.js} +1 -1
  129. package/dist/standalone/{chunk-ZPQFM3A7.js → chunk-G7KYDZGL.js} +1 -1
  130. package/dist/standalone/{chunk-HBEZGCPB.js → chunk-GB7MHA6L.js} +1 -1
  131. package/dist/standalone/{chunk-KVQ2GMJR.js → chunk-HB2FLDDU.js} +1 -1
  132. package/dist/standalone/{chunk-3QNDJXLL.js → chunk-HFPX37U7.js} +1 -1
  133. package/dist/standalone/{chunk-WU2ST74V.js → chunk-HI3U4W6T.js} +1 -1
  134. package/dist/standalone/{chunk-MICDQTTJ.js → chunk-HPTF52JF.js} +1 -1
  135. package/dist/standalone/{chunk-VTTS5L36.js → chunk-I33WWIBV.js} +1 -1
  136. package/dist/standalone/{chunk-UUOEHNMP.js → chunk-IEOOQ2NW.js} +1 -1
  137. package/dist/standalone/{chunk-66IUCD6W.js → chunk-ILPLYMU4.js} +1 -1
  138. package/dist/standalone/{chunk-FKOAI6VV.js → chunk-IPRJMLLL.js} +1 -1
  139. package/dist/standalone/{chunk-DJPK4PZV.js → chunk-IW5TW36H.js} +1 -1
  140. package/dist/standalone/{chunk-4TGALJHR.js → chunk-J3ZEO3PJ.js} +1 -1
  141. package/dist/standalone/{chunk-4W7SB3SF.js → chunk-J5SYXVIK.js} +1 -1
  142. package/dist/standalone/{chunk-WVURFBJS.js → chunk-JPBTM43K.js} +1 -1
  143. package/dist/standalone/{chunk-SADHW6WJ.js → chunk-LFVPR2JB.js} +1 -1
  144. package/dist/standalone/{chunk-KXUK7CSR.js → chunk-MMRSSV2C.js} +1 -1
  145. package/dist/standalone/{chunk-MGYRQPAY.js → chunk-MT3K66QU.js} +1 -1
  146. package/dist/standalone/{chunk-A2LKDNNA.js → chunk-MVRBX7HB.js} +1 -1
  147. package/dist/standalone/{chunk-4E6DQHFK.js → chunk-N2XUTYZJ.js} +1 -1
  148. package/dist/standalone/{chunk-GCYQOJYI.js → chunk-NIIWN6ZY.js} +1 -1
  149. package/dist/standalone/{chunk-VGKDC2OQ.js → chunk-NVMQPIRS.js} +1 -1
  150. package/dist/standalone/{chunk-5NPU6VPX.js → chunk-OEHBCBV4.js} +1 -1
  151. package/dist/standalone/{chunk-V4JKKAAZ.js → chunk-OKZINWBB.js} +1 -1
  152. package/dist/standalone/{chunk-SBQT2ZSX.js → chunk-OVMZ7DXR.js} +1 -1
  153. package/dist/standalone/{chunk-RAJ327CY.js → chunk-PAFHBQFL.js} +1 -1
  154. package/dist/standalone/{chunk-AE3ABYCE.js → chunk-PAGLAE5H.js} +1 -1
  155. package/dist/standalone/{chunk-VJQP4ARP.js → chunk-PN7JHEYW.js} +1 -1
  156. package/dist/standalone/{chunk-JXUU3BD2.js → chunk-PQB2QX4Q.js} +1 -1
  157. package/dist/standalone/chunk-PUQ3LURH.js +1 -0
  158. package/dist/standalone/{chunk-LHQFTCOS.js → chunk-PXDQGWZR.js} +1 -1
  159. package/dist/standalone/{chunk-XSFGXEYO.js → chunk-Q4SE33KY.js} +1 -1
  160. package/dist/standalone/{chunk-O65QTRXU.js → chunk-Q6MWEK4M.js} +1 -1
  161. package/dist/standalone/{chunk-GDAZWXQW.js → chunk-QAETUNZX.js} +1 -1
  162. package/dist/standalone/{chunk-D2LGOQ32.js → chunk-QK4NIT57.js} +1 -1
  163. package/dist/standalone/{chunk-2KREOMPV.js → chunk-RAJO2KOX.js} +1 -1
  164. package/dist/standalone/{chunk-MULFKWTQ.js → chunk-RDYGUTWW.js} +1 -1
  165. package/dist/standalone/{chunk-NQ727GVM.js → chunk-S3TDGFRE.js} +1 -1
  166. package/dist/standalone/{chunk-4YEGXH2V.js → chunk-S7NFUY75.js} +1 -1
  167. package/dist/standalone/{chunk-ZBLG4UAV.js → chunk-SBJ4LWXW.js} +1 -1
  168. package/dist/standalone/{chunk-LYNQHGQ4.js → chunk-SFZ6IAL2.js} +1 -1
  169. package/dist/standalone/{chunk-XEIJUQ4B.js → chunk-SI5L5HDG.js} +1 -1
  170. package/dist/standalone/{chunk-IMM6HPPD.js → chunk-SNJ3ZOV2.js} +1 -1
  171. package/dist/standalone/{chunk-OOUGGYHQ.js → chunk-SRNRWSMY.js} +1 -1
  172. package/dist/standalone/{chunk-7MQQPZQC.js → chunk-THRRRMIZ.js} +1 -1
  173. package/dist/standalone/{chunk-ZZ6ZCOD4.js → chunk-TN4Z3P6S.js} +1 -1
  174. package/dist/standalone/{chunk-XOLTLG4I.js → chunk-TQH2BN2P.js} +1 -1
  175. package/dist/standalone/{chunk-JELTLAEP.js → chunk-U5YP7MSK.js} +1 -1
  176. package/dist/standalone/{chunk-DWKKQ75U.js → chunk-UDBPUH63.js} +1 -1
  177. package/dist/standalone/{chunk-RPRNYCFT.js → chunk-UHF224OV.js} +1 -1
  178. package/dist/standalone/{chunk-YL5ZAR3P.js → chunk-UN3QTZ6X.js} +1 -1
  179. package/dist/standalone/{chunk-F2DVDJV6.js → chunk-UV6GPH2E.js} +1 -1
  180. package/dist/standalone/{chunk-RK3HQKPW.js → chunk-V3A3775O.js} +1 -1
  181. package/dist/standalone/{chunk-Q7KRCKCE.js → chunk-VKX7HSAS.js} +1 -1
  182. package/dist/standalone/{chunk-274SZA4F.js → chunk-WDQDRE4G.js} +1 -1
  183. package/dist/standalone/{chunk-ML6YSDEQ.js → chunk-WEZRVKSV.js} +1 -1
  184. package/dist/standalone/{chunk-ZZA6VQDG.js → chunk-WKRUXQXB.js} +1 -1
  185. package/dist/standalone/{chunk-76D454G5.js → chunk-WSJTPPUQ.js} +1 -1
  186. package/dist/standalone/{chunk-3NYU3CCO.js → chunk-XUSA5BXI.js} +1 -1
  187. package/dist/standalone/{chunk-FPODRWDZ.js → chunk-YDDMKWPI.js} +1 -1
  188. package/dist/standalone/{chunk-XBHRAFJA.js → chunk-YNYH4P7E.js} +1 -1
  189. package/dist/standalone/{chunk-337EJGCU.js → chunk-ZO6OZV4D.js} +1 -1
  190. package/dist/standalone/studio.js +1 -1
  191. package/package.json +3 -3
  192. package/dist/packem_shared/ApiDocsPanel-sEDqUNQq.mjs +0 -2
  193. package/dist/packem_shared/Studio-BmbkaUrx.mjs +0 -1
  194. package/dist/packem_shared/use-assistant-rpc-AKu8hvPm.mjs +0 -1
  195. package/dist/standalone/chunk-A4F3YMBV.js +0 -1
  196. package/dist/standalone/chunk-AQ6LY5RO.js +0 -14
  197. package/dist/standalone/chunk-KQVY73EU.js +0 -7
  198. package/dist/standalone/chunk-W3WGVJNJ.js +0 -1
@@ -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-3AR_-s_s.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-DAHZ35kM.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-CYJQf6P-.mjs";import{a as $e}from"../packem_shared/log-fields-CV-9O0nh.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},Ke=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(Fe)})]}),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 Fe(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 K;e[33]!==j?(K=n("span",{className:"text-right tabular-nums text-muted-foreground",children:j}),e[33]=j,e[34]=K):K=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]!==K||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,K,C,E]}),e[43]=r,e[44]=S,e[45]=g,e[46]=I,e[47]=x,e[48]=A,e[49]=K,e[50]=C,e[51]=E,e[52]=W):W=e[52];let F;e[53]!==r||e[54]!==t?(F=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Ke,{span:t})}),e[53]=r,e[54]=t,e[55]=F):F=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==F?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,F]}),e[56]=t.depth,e[57]=W,e[58]=F,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(60),{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]!==r||e[21]!==d||e[22]!==o||e[23]!==i||e[24]!==s){const L=qe(m),A=m?.total??L.length,j=A>L.length,K=Ee(L,d,c),B=Map.groupBy((I?.entries??[]).toReversed(),Ve);let C;e[26]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{f(R.target.value)},e[26]=C):C=e[26];const O=C;let E;e[27]===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[27]=E):E=e[27];const W=E,F=u===null&&K.length===0&&!T;let P;e[28]!==o||e[29]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[28]=o,e[29]=i,e[30]=P):P=e[30];let z;e[31]!==s?(z=s("Search traces"),e[31]=s,e[32]=z):z=e[32];let G;e[33]!==s?(G=s("search trace, span, or function"),e[33]=s,e[34]=G):G=e[34];let H;e[35]!==d||e[36]!==z||e[37]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:O,placeholder:G,value:d}),e[35]=d,e[36]=z,e[37]=G,e[38]=H):H=e[38];let J;e[39]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[39]=c,e[40]=J):J=e[40];let Q;e[41]!==s?(Q=s("Errors only"),e[41]=s,e[42]=Q):Q=e[42];let V;e[43]!==J||e[44]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[43]=J,e[44]=Q,e[45]=V):V=e[45];let X;e[46]!==_?(X=n(be,{message:_,prefix:"tr"}),e[46]=_,e[47]=X):X=e[47];let te;e[48]!==P||e[49]!==H||e[50]!==V||e[51]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[48]=P,e[49]=H,e[50]=V,e[51]=X,e[52]=te):te=e[52];let re;e[53]!==u||e[54]!==h||e[55]!==r?(re=u!==null&&n(ge,{error:h,shardKey:r,testId:"tr-error"}),e[53]=u,e[54]=h,e[55]=r,e[56]=re):re=e[56];let se;e[57]!==F||e[58]!==s?(se=F&&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[57]=F,e[58]=s,e[59]=se):se=e[59],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&&K.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:K.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]=r,e[21]=d,e[22]=o,e[23]=i,e[24]=s,e[25]=D}else D=e[25];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})},a.id??`${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-BxCd81tw.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-DMnTt_hg.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-DAHZ35kM.mjs";import{c as me,j as Se}from"../packem_shared/internal-BT5tH08j.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-BmYn49u1.mjs";import{a as $e}from"../packem_shared/log-fields-CV-9O0nh.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},Ke=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(Fe)})]}),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 Fe(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 K;e[33]!==j?(K=n("span",{className:"text-right tabular-nums text-muted-foreground",children:j}),e[33]=j,e[34]=K):K=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]!==K||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,K,C,E]}),e[43]=r,e[44]=S,e[45]=g,e[46]=I,e[47]=x,e[48]=A,e[49]=K,e[50]=C,e[51]=E,e[52]=W):W=e[52];let F;e[53]!==r||e[54]!==t?(F=r&&n("div",{id:`tr-span-detail-${t.spanId}`,children:n(Ke,{span:t})}),e[53]=r,e[54]=t,e[55]=F):F=e[55];let P;return e[56]!==t.depth||e[57]!==W||e[58]!==F?(P=k("li",{"data-depth":_,"data-testid":"tr-span-row",children:[W,F]}),e[56]=t.depth,e[57]=W,e[58]=F,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(60),{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]!==r||e[21]!==d||e[22]!==o||e[23]!==i||e[24]!==s){const L=qe(m),A=m?.total??L.length,j=A>L.length,K=Ee(L,d,c),B=Map.groupBy((I?.entries??[]).toReversed(),Ve);let C;e[26]===Symbol.for("react.memo_cache_sentinel")?(C=R=>{f(R.target.value)},e[26]=C):C=e[26];const O=C;let E;e[27]===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[27]=E):E=e[27];const W=E,F=u===null&&K.length===0&&!T;let P;e[28]!==o||e[29]!==i?(P=n(xe,{onChange:o,testId:"tr-shard-input",value:i}),e[28]=o,e[29]=i,e[30]=P):P=e[30];let z;e[31]!==s?(z=s("Search traces"),e[31]=s,e[32]=z):z=e[32];let G;e[33]!==s?(G=s("search trace, span, or function"),e[33]=s,e[34]=G):G=e[34];let H;e[35]!==d||e[36]!==z||e[37]!==G?(H=n(ve,{"aria-label":z,className:"h-8 w-56","data-testid":"tr-search",onChange:O,placeholder:G,value:d}),e[35]=d,e[36]=z,e[37]=G,e[38]=H):H=e[38];let J;e[39]!==c?(J=n(ye,{checked:c,"data-testid":"tr-only-errors",id:"tr-only-errors",onCheckedChange:y}),e[39]=c,e[40]=J):J=e[40];let Q;e[41]!==s?(Q=s("Errors only"),e[41]=s,e[42]=Q):Q=e[42];let V;e[43]!==J||e[44]!==Q?(V=k("label",{className:"flex items-center gap-2 text-xs text-muted-foreground",htmlFor:"tr-only-errors",children:[J,Q]}),e[43]=J,e[44]=Q,e[45]=V):V=e[45];let X;e[46]!==_?(X=n(be,{message:_,prefix:"tr"}),e[46]=_,e[47]=X):X=e[47];let te;e[48]!==P||e[49]!==H||e[50]!==V||e[51]!==X?(te=k("div",{className:"flex flex-wrap items-center gap-2",children:[P,H,V,X]}),e[48]=P,e[49]=H,e[50]=V,e[51]=X,e[52]=te):te=e[52];let re;e[53]!==u||e[54]!==h||e[55]!==r?(re=u!==null&&n(ge,{error:h,shardKey:r,testId:"tr-error"}),e[53]=u,e[54]=h,e[55]=r,e[56]=re):re=e[56];let se;e[57]!==F||e[58]!==s?(se=F&&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[57]=F,e[58]=s,e[59]=se):se=e[59],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&&K.length>0&&n("div",{"aria-label":s("Recent traces"),className:"overflow-hidden rounded-xl border border-border shadow-xs","data-testid":"tr-list",children:K.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]=r,e[21]=d,e[22]=o,e[23]=i,e[24]=s,e[25]=D}else D=e[25];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})},a.id??`${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 ze}from"react";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as R}from"../packem_shared/button-q0UYSmrn.mjs";import{C as le,a as ie}from"../packem_shared/card-By2O8ULa.mjs";import{E as He}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as j}from"../packem_shared/input-CXhxesPC.mjs";import{T as Te,a as $e,b as Z,c as T,d as De,e as P}from"../packem_shared/table-D0SBiDu-.mjs";import{a as Ye}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{c as X}from"react/compiler-runtime";import{u as Qe}from"../packem_shared/use-auth-config-DameIc6y.mjs";import{useAutoRefresh as Ge}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-B9kGlqXE.mjs";import Je from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as J}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{w as Xe,h as te,f as se,l as ee,b as Oe}from"../packem_shared/internal-hIuTpSbx.mjs";import{A as et}from"../packem_shared/auth-pager-DW77WeZw.mjs";import{jsxs as h,jsx as t,Fragment as tt}from"react/jsx-runtime";import{C as st}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{L as W}from"../packem_shared/label-DKFzyHq6.mjs";import{M as We}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{u as nt}from"../packem_shared/use-async-submit-D0r7-m2J.mjs";const lt=()=>{const m=X(3),{config:e,ready:i}=Qe();let n;return m[0]!==e.capabilities||m[1]!==i?(n={capabilities:e.capabilities,ready:i},m[0]=e.capabilities,m[1]=i,m[2]=n):n=m[2],n},it=(m,e)=>typeof m.acceptedAt=="number"?"spent":typeof m.expiresAt=="number"&&m.expiresAt<=e?"expired":"pending",je=500,at=(m,e)=>{if(!URL.canParse(m.trim()))return null;const i=new URL(m.trim());return i.searchParams.set("email",e.email),i.searchParams.set("invite",e.token),i.toString()},rt=m=>{const e=X(34),{issued:i,onSignUpPageChange:n,signUpPage:r}=m,s=J(),[c,l]=I(null);let a;e[0]!==i||e[1]!==r?(a=at(r,i),e[0]=i,e[1]=r,e[2]=a):a=e[2];const d=a;let p;e[3]!==d?(p=()=>{const _="navigator"in globalThis?globalThis.navigator.clipboard:void 0;d===null||_===void 0||se(_.writeText(d).then(()=>(l(d),!0)))},e[3]=d,e[4]=p):p=e[4];const N=p;let b;e[5]!==s?(b=s("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=s,e[6]=b):b=e[6];let F;e[7]!==b?(F=t("p",{className:"text-sm",children:b}),e[7]=b,e[8]=F):F=e[8];const C=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 u;e[11]!==n?(u=_=>{n(_.target.value)},e[11]=n,e[12]=u):u=e[12];let f;e[13]!==r||e[14]!==C||e[15]!==v||e[16]!==u?(f=t(j,{"aria-invalid":C,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:u,value:r}),e[13]=r,e[14]=C,e[15]=v,e[16]=u,e[17]=f):f=e[17];const x=d??"";let y;e[18]!==x?(y=t(j,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:x}),e[18]=x,e[19]=y):y=e[19];let k;e[20]!==c||e[21]!==d||e[22]!==s?(k=s(c!==null&&c===d?"Copied":"Copy"),e[20]=c,e[21]=d,e[22]=s,e[23]=k):k=e[23];let g;e[24]!==N||e[25]!==k?(g=t(R,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:k}),e[24]=N,e[25]=k,e[26]=g):g=e[26];let o;e[27]!==y||e[28]!==g?(o=h("div",{className:"flex gap-2",children:[y,g]}),e[27]=y,e[28]=g,e[29]=o):o=e[29];let S;return e[30]!==o||e[31]!==F||e[32]!==f?(S=t(le,{children:h(ie,{className:"flex flex-col gap-2 p-4",children:[F,f,o]})}),e[30]=o,e[31]=F,e[32]=f,e[33]=S):S=e[33],S},ot=()=>{const m=ae(),e=J(),[i,n]=I(""),[r,s]=I(null),[c,l]=I(null),[a,d]=I(()=>`${Xe(m.url)}/sign-up`),p=Ye(["lunora-auth-sign-up-invitations",je],()=>m.listAuthSignUpInvitations({limit:je})),N=p.data?.rows??null,b=p.data?.total??0,F=()=>{const v=i.trim();v!==""&&(s(null),se((async()=>{try{const u=await m.createAuthSignUpInvitation({email:v}),f=typeof u.token=="string"?u.token:void 0;l(f===void 0?null:{email:v,token:f}),n(""),p.refetch()}catch(u){s(u instanceof Error?u.message:String(u))}})()))},C=v=>{s(null),se((async()=>{try{await m.revokeAuthSignUpInvitation({email:v}),p.refetch()}catch(u){s(u instanceof Error?u.message:String(u))}})())};return h("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[h("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.")})]}),h("div",{className:"flex gap-2",children:[t(j,{"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:i}),t(R,{"data-testid":"sign-up-invitation-submit",onClick:F,type:"button",children:e("Invite")})]}),c!==null&&t(rt,{issued:c,onSignUpPageChange:d,signUpPage:a},c.token),(r??p.error)!==null&&t("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:r??p.error}),N!==null&&N.length===0&&t(He,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),N!==null&&b>N.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.")}),N!==null&&N.length>0&&t(le,{children:t(ie,{className:"p-0",children:h(Te,{children:[t($e,{children:h(Z,{children:[t(T,{children:e("Email")}),t(T,{children:e("Status")}),t(T,{children:e("Expires")}),t(T,{children:e("Invited by")}),t(T,{})]})}),t(De,{children:N.map(v=>{const u=it(v,Date.now()),f=v.email??"";return h(Z,{"data-testid":`sign-up-invitation-${f}`,children:[t(P,{children:f}),h(P,{"data-testid":`sign-up-invitation-status-${f}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),t(P,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"—"}),t(P,{children:v.invitedBy??"—"}),t(P,{className:"text-right",children:t(R,{onClick:()=>{C(f)},type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},dt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ct=(m,e)=>m.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:m.type!=="number"||!Number.isNaN(Number(e.trim())),ut=(m,e)=>{if(m.type==="boolean")return e===!0?{value:!0}:m.required?{value:!1}:void 0;const i=typeof e=="string"?e.trim():"";if(i!==""){if(m.type==="number"){const n=Number(i);return Number.isNaN(n)?void 0:{value:n}}return{value:i}}},mt=m=>{const e=X(105),{onClose:i,onCreated:n}=m,r=ae(),s=J(),{config:c}=Qe(),{busy:l,error:a,run:d}=nt(),[p,N]=I(""),[b,F]=I(""),[C,v]=I(""),[u,f]=I("");let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];const[y,k]=I(x);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=A=>{N(A.target.value)},e[1]=g):g=e[1];const o=g;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=A=>{F(A.target.value)},e[2]=S):S=e[2];const _=S;let z;e[3]===Symbol.for("react.memo_cache_sentinel")?(z=A=>{v(A.target.value)},e[3]=z):z=e[3];const q=z;let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=A=>{f(A.target.value)},e[4]=M):M=e[4];const H=M;let D;e[5]===Symbol.for("react.memo_cache_sentinel")?(D=(A,V)=>{k(ne=>({...ne,[A]:V}))},e[5]=D):D=e[5];const B=D;let O;e[6]!==y?(O=A=>y[A.name]??(A.type==="boolean"?!1:""),e[6]=y,e[7]=O):O=e[7];const U=O;let K;if(e[8]!==c.userFields||e[9]!==U){let A;e[11]!==U?(A=V=>!V.required||ct(V,U(V)),e[11]=U,e[12]=A):A=e[12],K=c.userFields.every(A),e[8]=c.userFields,e[9]=U,e[10]=K}else K=e[10];const w=K;let E;e[13]!==l||e[14]!==p||e[15]!==b||e[16]!==w?(E=!l&&p.trim()!==""&&b.trim()!==""&&w,e[13]=l,e[14]=p,e[15]=b,e[16]=w,e[17]=E):E=e[17];const Y=E;let Q;e[18]!==c.userFields||e[19]!==U?(Q=()=>{const A={};for(const V of c.userFields){const ne=ut(V,U(V));ne!==void 0&&(A[V.name]=ne.value)}return Object.keys(A).length===0?void 0:A},e[18]=c.userFields,e[19]=U,e[20]=Q):Q=e[20];const $=Q;let L;e[21]!==$||e[22]!==r||e[23]!==p||e[24]!==b||e[25]!==i||e[26]!==n||e[27]!==C||e[28]!==u||e[29]!==d?(L=()=>{d(async()=>{await r.createAuthUser({data:$(),email:p.trim(),name:b.trim(),password:C===""?void 0:C,role:u.trim()===""?void 0:u.trim()}),n(),i()})},e[21]=$,e[22]=r,e[23]=p,e[24]=b,e[25]=i,e[26]=n,e[27]=C,e[28]=u,e[29]=d,e[30]=L):L=e[30];const Be=L;let re;e[31]!==s?(re=s("Create user"),e[31]=s,e[32]=re):re=e[32];let oe;e[33]!==s?(oe=s("Create user"),e[33]=s,e[34]=oe):oe=e[34];let de;e[35]!==oe?(de=t("h2",{className:"text-sm font-semibold text-foreground",children:oe}),e[35]=oe,e[36]=de):de=e[36];let ce;e[37]!==s?(ce=s("email"),e[37]=s,e[38]=ce):ce=e[38];let ue;e[39]!==ce?(ue=t(W,{htmlFor:"uc-email",children:ce}),e[39]=ce,e[40]=ue):ue=e[40];let me;e[41]!==p?(me=t(j,{"data-testid":"uc-email",id:"uc-email",onChange:o,type:"email",value:p}),e[41]=p,e[42]=me):me=e[42];let he;e[43]!==ue||e[44]!==me?(he=h("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[43]=ue,e[44]=me,e[45]=he):he=e[45];let fe;e[46]!==s?(fe=s("name"),e[46]=s,e[47]=fe):fe=e[47];let pe;e[48]!==fe?(pe=t(W,{htmlFor:"uc-name",children:fe}),e[48]=fe,e[49]=pe):pe=e[49];let ve;e[50]!==b?(ve=t(j,{"data-testid":"uc-name",id:"uc-name",onChange:_,value:b}),e[50]=b,e[51]=ve):ve=e[51];let ge;e[52]!==pe||e[53]!==ve?(ge=h("div",{className:"flex flex-col gap-1",children:[pe,ve]}),e[52]=pe,e[53]=ve,e[54]=ge):ge=e[54];let ye;e[55]!==s?(ye=s("Password (optional)"),e[55]=s,e[56]=ye):ye=e[56];let be;e[57]!==ye?(be=t(W,{htmlFor:"uc-password",children:ye}),e[57]=ye,e[58]=be):be=e[58];let xe;e[59]!==C?(xe=t(j,{"data-testid":"uc-password",id:"uc-password",onChange:q,type:"password",value:C}),e[59]=C,e[60]=xe):xe=e[60];let Ne;e[61]!==be||e[62]!==xe?(Ne=h("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[61]=be,e[62]=xe,e[63]=Ne):Ne=e[63];let ke;e[64]!==s?(ke=s("Role (optional)"),e[64]=s,e[65]=ke):ke=e[65];let Ce;e[66]!==ke?(Ce=t(W,{htmlFor:"uc-role",children:ke}),e[66]=ke,e[67]=Ce):Ce=e[67];let we;e[68]!==u?(we=t(j,{"data-testid":"uc-role",id:"uc-role",onChange:H,value:u}),e[68]=u,e[69]=we):we=e[69];let Ae;e[70]!==Ce||e[71]!==we?(Ae=h("div",{className:"flex flex-col gap-1",children:[Ce,we]}),e[70]=Ce,e[71]=we,e[72]=Ae):Ae=e[72];let Ie;e[73]!==c.userFields||e[74]!==U||e[75]!==s?(Ie=c.userFields.length>0&&h("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")}),c.userFields.map(A=>{const V=`uc-field-${A.name}`,ne=A.required?"":` (${s("optional")})`;if(A.type==="boolean"){const _e=U(A)===!0;return h("label",{className:"flex items-center gap-2",htmlFor:V,children:[t(st,{checked:_e,"data-testid":V,id:V,onCheckedChange:Ze=>{B(A.name,Ze)}}),h("span",{className:"text-sm",children:[A.name,ne]})]},A.name)}const Ve=U(A);return h("div",{className:"flex flex-col gap-1",children:[h(W,{htmlFor:V,children:[A.name,ne]}),t(j,{"data-testid":V,id:V,onChange:_e=>{B(A.name,_e.target.value)},type:dt[A.type],value:typeof Ve=="string"?Ve:""})]},A.name)})]}),e[73]=c.userFields,e[74]=U,e[75]=s,e[76]=Ie):Ie=e[76];let Se;e[77]!==a?(Se=a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:a}),e[77]=a,e[78]=Se):Se=e[78];let Fe;e[79]!==s?(Fe=s("Cancel"),e[79]=s,e[80]=Fe):Fe=e[80];let Ue;e[81]!==i||e[82]!==Fe?(Ue=t(R,{"data-testid":"uc-cancel",onClick:i,size:"sm",type:"button",variant:"outline",children:Fe}),e[81]=i,e[82]=Fe,e[83]=Ue):Ue=e[83];const Le=!Y;let Pe;e[84]!==l||e[85]!==s?(Pe=s(l?"Creating…":"Create"),e[84]=l,e[85]=s,e[86]=Pe):Pe=e[86];let Re;e[87]!==Be||e[88]!==Le||e[89]!==Pe?(Re=t(R,{"data-testid":"uc-submit",disabled:Le,onClick:Be,size:"sm",type:"button",children:Pe}),e[87]=Be,e[88]=Le,e[89]=Pe,e[90]=Re):Re=e[90];let Ee;e[91]!==Ue||e[92]!==Re?(Ee=h("div",{className:"flex justify-end gap-2 pt-1",children:[Ue,Re]}),e[91]=Ue,e[92]=Re,e[93]=Ee):Ee=e[93];let Ke;return e[94]!==i||e[95]!==re||e[96]!==de||e[97]!==he||e[98]!==ge||e[99]!==Ne||e[100]!==Ae||e[101]!==Ie||e[102]!==Se||e[103]!==Ee?(Ke=h(We,{label:re,onClose:i,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[de,he,ge,Ne,Ae,Ie,Se,Ee]}),e[94]=i,e[95]=re,e[96]=de,e[97]=he,e[98]=ge,e[99]=Ne,e[100]=Ae,e[101]=Ie,e[102]=Se,e[103]=Ee,e[104]=Ke):Ke=e[104],Ke},Me=m=>{const e=X(2),{children:i}=m;let n;return e[0]!==i?(n=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i}),e[0]=i,e[1]=n):n=e[1],n},qe=m=>{const e=X(15),{children:i,columns:n,testId:r}=m,s=J();let c;e[0]!==n?(c=n.map(vt),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==s?(l=s("Actions"),e[2]=s,e[3]=l):l=e[3];let a;e[4]!==l?(a=t(T,{"aria-label":l}),e[4]=l,e[5]=a):a=e[5];let d;e[6]!==c||e[7]!==a?(d=t($e,{children:h(Z,{children:[c,a]})}),e[6]=c,e[7]=a,e[8]=d):d=e[8];let p;e[9]!==i?(p=t(De,{children:i}),e[9]=i,e[10]=p):p=e[10];let N;return e[11]!==d||e[12]!==p||e[13]!==r?(N=t(le,{className:"overflow-hidden py-0",children:t(ie,{className:"px-0",children:h(Te,{"data-testid":r,children:[d,p]})})}),e[11]=d,e[12]=p,e[13]=r,e[14]=N):N=e[14],N},ht=m=>{const e=X(29),{busy:i,runAction:n,userId:r,version:s}=m,c=ae(),l=J(),[a,d]=I(null),[p,N]=I(null);let b;e[0]!==c||e[1]!==r?(b=()=>{se((async()=>{N(null);try{const o=await c.listAuthSessions({limit:50,userId:r});d(o.rows)}catch(o){const S=o;d(null),N(Oe(S))}})())},e[0]=c,e[1]=r,e[2]=b):b=e[2];let F;e[3]!==c||e[4]!==r||e[5]!==s?(F=[c,r,s],e[3]=c,e[4]=r,e[5]=s,e[6]=F):F=e[6],ze(b,F);let C;e[7]!==c||e[8]!==n?(C=o=>{n(()=>c.revokeAuthSession({sessionId:o}))},e[7]=c,e[8]=n,e[9]=C):C=e[9];const v=C;let u;e[10]!==l?(u=l("Sessions"),e[10]=l,e[11]=u):u=e[11];let f;e[12]!==u?(f=t(Me,{children:u}),e[12]=u,e[13]=f):f=e[13];let x;e[14]!==p?(x=p!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:p}),e[14]=p,e[15]=x):x=e[15];let y;e[16]!==a||e[17]!==l?(y=a!==null&&a.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:l("No active sessions.")}),e[16]=a,e[17]=l,e[18]=y):y=e[18];let k;e[19]!==i||e[20]!==v||e[21]!==a||e[22]!==l?(k=a!==null&&a.length>0&&t(le,{className:"overflow-hidden py-0",children:t(ie,{className:"px-0",children:h(Te,{"data-testid":"ud-sessions-table",children:[t($e,{children:h(Z,{children:[t(T,{children:l("expires")}),t(T,{children:l("ip")}),t(T,{children:l("user agent")}),t(T,{"aria-label":l("Actions")})]})}),t(De,{children:a.map(o=>h(Z,{"data-testid":`ud-session-${o.id}`,children:[t(P,{className:"text-muted-foreground tabular-nums",children:te(o.expiresAt)}),t(P,{children:o.ipAddress??""}),t(P,{className:"max-w-40 truncate",children:o.userAgent??""}),t(P,{children:t(R,{"data-testid":`ud-revoke-${o.id}`,disabled:i,onClick:()=>{v(o.id)},size:"xs",type:"button",variant:"ghost",children:l("Revoke")})})]},o.id))})]})})}),e[19]=i,e[20]=v,e[21]=a,e[22]=l,e[23]=k):k=e[23];let g;return e[24]!==f||e[25]!==x||e[26]!==y||e[27]!==k?(g=h("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[f,x,y,k]}),e[24]=f,e[25]=x,e[26]=y,e[27]=k,e[28]=g):g=e[28],g},ft=m=>{const e=X(30),{busy:i,runAction:n,userId:r,version:s}=m,c=ae(),l=J(),[a,d]=I(null),[p,N]=I(null);let b;e[0]!==c||e[1]!==r?(b=()=>{se((async()=>{N(null);try{d(await c.listAuthAccounts({userId:r}))}catch(o){const S=o;d(null),N(Oe(S))}})())},e[0]=c,e[1]=r,e[2]=b):b=e[2];let F;e[3]!==c||e[4]!==r||e[5]!==s?(F=[c,r,s],e[3]=c,e[4]=r,e[5]=s,e[6]=F):F=e[6],ze(b,F);let C;e[7]!==c||e[8]!==n||e[9]!==r?(C=o=>{n(()=>c.unlinkAuthAccount({accountId:o,userId:r}))},e[7]=c,e[8]=n,e[9]=r,e[10]=C):C=e[10];const v=C;let u;e[11]!==l?(u=l("Linked accounts"),e[11]=l,e[12]=u):u=e[12];let f;e[13]!==u?(f=t(Me,{children:u}),e[13]=u,e[14]=f):f=e[14];let x;e[15]!==p?(x=p!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:p}),e[15]=p,e[16]=x):x=e[16];let y;e[17]!==a||e[18]!==l?(y=a!==null&&a.length===0&&t("p",{className:"text-sm text-muted-foreground",children:l("No linked accounts.")}),e[17]=a,e[18]=l,e[19]=y):y=e[19];let k;e[20]!==a||e[21]!==i||e[22]!==v||e[23]!==l?(k=a!==null&&a.length>0&&t(le,{className:"overflow-hidden py-0",children:t(ie,{className:"px-0",children:h(Te,{"data-testid":"ud-accounts-table",children:[t($e,{children:h(Z,{children:[t(T,{children:l("provider")}),t(T,{children:l("created")}),t(T,{"aria-label":l("Actions")})]})}),t(De,{children:a.map(o=>{const S=ee(o.id);return h(Z,{"data-testid":`ud-account-${S}`,children:[t(P,{children:ee(o.providerId)}),t(P,{className:"text-muted-foreground tabular-nums",children:te(o.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-unlink-${S}`,disabled:i,onClick:()=>{v(S)},size:"xs",type:"button",variant:"ghost",children:l("Unlink")})})]},S)})})]})})}),e[20]=a,e[21]=i,e[22]=v,e[23]=l,e[24]=k):k=e[24];let g;return e[25]!==f||e[26]!==x||e[27]!==y||e[28]!==k?(g=h("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[f,x,y,k]}),e[25]=f,e[26]=x,e[27]=y,e[28]=k,e[29]=g):g=e[29],g},pt=m=>{const e=X(71),{busy:i,capabilities:n,runAction:r,userId:s,version:c}=m,l=ae(),a=J(),[d,p]=I(null),[N,b]=I(null),[F,C]=I(null),[v,u]=I(0);let f;e[0]!==n.apiKey||e[1]!==l||e[2]!==s?(f=()=>{if(!n.apiKey)return;const $={live:!0};return se((async()=>{try{const L=await l.listAuthApiKeys({userId:s});$.live&&(b({rows:L,userId:s}),C(null))}catch{$.live&&C(s)}})()),()=>{$.live=!1}},e[0]=n.apiKey,e[1]=l,e[2]=s,e[3]=f):f=e[3];let x;e[4]!==v||e[5]!==n.apiKey||e[6]!==l||e[7]!==s||e[8]!==c?(x=[v,n.apiKey,l,s,c],e[4]=v,e[5]=n.apiKey,e[6]=l,e[7]=s,e[8]=c,e[9]=x):x=e[9],ze(f,x);const y=N?.userId===s?N.rows:null,k=F===s;let g;e[10]!==n.passkey||e[11]!==l||e[12]!==s?(g=()=>{n.passkey&&se((async()=>{try{p(await l.listAuthPasskeys({userId:s}))}catch{p(null)}})())},e[10]=n.passkey,e[11]=l,e[12]=s,e[13]=g):g=e[13];let o;e[14]!==n.passkey||e[15]!==l||e[16]!==s||e[17]!==c?(o=[n.passkey,l,s,c],e[14]=n.passkey,e[15]=l,e[16]=s,e[17]=c,e[18]=o):o=e[18],ze(g,o);let S;e[19]!==l||e[20]!==r||e[21]!==s?(S=()=>{r(()=>l.disableAuthTwoFactor({userId:s}))},e[19]=l,e[20]=r,e[21]=s,e[22]=S):S=e[22];const _=S;let z;e[23]!==l||e[24]!==r?(z=$=>{r(()=>l.deleteAuthPasskey({passkeyId:$}))},e[23]=l,e[24]=r,e[25]=z):z=e[25];const q=z;let M;e[26]!==l||e[27]!==r?(M=$=>{r(()=>l.deleteAuthApiKey({apiKeyId:$}))},e[26]=l,e[27]=r,e[28]=M):M=e[28];const H=M;let D;e[29]!==a?(D=a("Security"),e[29]=a,e[30]=D):D=e[30];let B;e[31]!==D?(B=t(Me,{children:D}),e[31]=D,e[32]=B):B=e[32];let O;e[33]!==i||e[34]!==n.twoFactor||e[35]!==_||e[36]!==a?(O=n.twoFactor&&t(R,{"data-testid":"ud-disable-2fa",disabled:i,onClick:_,size:"sm",type:"button",variant:"outline",children:a("Disable two-factor")}),e[33]=i,e[34]=n.twoFactor,e[35]=_,e[36]=a,e[37]=O):O=e[37];let U;e[38]!==n.passkey||e[39]!==d||e[40]!==a?(U=n.passkey&&d!==null&&d.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No passkeys.")}),e[38]=n.passkey,e[39]=d,e[40]=a,e[41]=U):U=e[41];let K;e[42]!==i||e[43]!==n.passkey||e[44]!==q||e[45]!==d||e[46]!==a?(K=n.passkey&&d!==null&&d.length>0&&t(qe,{columns:[a("name"),a("created")],testId:"ud-passkeys-table",children:d.map($=>{const L=ee($.id);return h(Z,{"data-testid":`ud-passkey-${L}`,children:[t(P,{children:ee($.name)||L}),t(P,{className:"text-muted-foreground tabular-nums",children:te($.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-delete-passkey-${L}`,disabled:i,onClick:()=>{q(L)},size:"xs",type:"button",variant:"ghost",children:a("Delete")})})]},L)})}),e[42]=i,e[43]=n.passkey,e[44]=q,e[45]=d,e[46]=a,e[47]=K):K=e[47];let w;e[48]!==k||e[49]!==i||e[50]!==n.apiKey||e[51]!==a?(w=n.apiKey&&k&&h("div",{className:"flex items-center gap-2",children:[t("p",{className:"text-sm text-muted-foreground",children:a("Could not load API keys.")}),t(R,{"data-testid":"ud-api-keys-retry",disabled:i,onClick:()=>{u(gt)},size:"xs",type:"button",variant:"outline",children:a("Retry")})]}),e[48]=k,e[49]=i,e[50]=n.apiKey,e[51]=a,e[52]=w):w=e[52];let E;e[53]!==n.apiKey||e[54]!==y||e[55]!==a?(E=n.apiKey&&y!==null&&y.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No API keys.")}),e[53]=n.apiKey,e[54]=y,e[55]=a,e[56]=E):E=e[56];let Y;e[57]!==i||e[58]!==n.apiKey||e[59]!==y||e[60]!==H||e[61]!==a?(Y=n.apiKey&&y!==null&&y.length>0&&t(qe,{columns:[a("name"),a("Key"),a("created"),a("Expires")],testId:"ud-api-keys-table",children:y.map($=>{const L=ee($.id);return h(Z,{"data-testid":`ud-api-key-${L}`,children:[t(P,{children:ee($.name)||L}),t(P,{className:"font-mono text-muted-foreground",children:ee($.start)||"—"}),t(P,{className:"text-muted-foreground tabular-nums",children:te($.createdAt)}),t(P,{className:"text-muted-foreground tabular-nums",children:te($.expiresAt,a("Never"))}),t(P,{children:t(R,{"data-testid":`ud-revoke-api-key-${L}`,disabled:i,onClick:()=>{H(L)},size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},L)})}),e[57]=i,e[58]=n.apiKey,e[59]=y,e[60]=H,e[61]=a,e[62]=Y):Y=e[62];let Q;return e[63]!==O||e[64]!==U||e[65]!==K||e[66]!==w||e[67]!==E||e[68]!==Y||e[69]!==B?(Q=h("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[B,O,U,K,w,E,Y]}),e[63]=O,e[64]=U,e[65]=K,e[66]=w,e[67]=E,e[68]=Y,e[69]=B,e[70]=Q):Q=e[70],Q};function vt(m){return t(T,{children:m},m)}function gt(m){return m+1}const yt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),Nt=m=>{const e=X(51),{busy:i,onBan:n}=m,r=J(),[s,c]=I(""),[l,a]=I(""),[d,p]=I(!1);let N;e[0]!==l?(N=bt.test(l.trim())&&Number.isSafeInteger(Number(l.trim())*86400)?Number(l.trim()):void 0,e[0]=l,e[1]=N):N=e[1];const b=N,F=d||b!==void 0;let C;e[2]!==n||e[3]!==d||e[4]!==s||e[5]!==b?(C=()=>{n({expiresInSeconds:d||b===void 0?void 0:b*86400,reason:s.trim()===""?void 0:s.trim()})},e[2]=n,e[3]=d,e[4]=s,e[5]=b,e[6]=C):C=e[6];const v=C;let u;e[7]!==r?(u=r("Ban reason (optional)"),e[7]=r,e[8]=u):u=e[8];let f;e[9]!==u?(f=t(W,{htmlFor:"ud-ban-reason",children:u}),e[9]=u,e[10]=f):f=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=E=>{c(E.target.value)},e[11]=x):x=e[11];let y;e[12]!==s?(y=t(j,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:x,value:s}),e[12]=s,e[13]=y):y=e[13];let k;e[14]!==f||e[15]!==y?(k=h("div",{className:"flex flex-1 flex-col gap-1",children:[f,y]}),e[14]=f,e[15]=y,e[16]=k):k=e[16];let g;e[17]!==r?(g=r("Days"),e[17]=r,e[18]=g):g=e[18];let o;e[19]!==g?(o=t(W,{htmlFor:"ud-ban-days",children:g}),e[19]=g,e[20]=o):o=e[20];let S;e[21]!==l||e[22]!==b?(S=l.trim()!==""&&b===void 0,e[21]=l,e[22]=b,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=E=>{a(E.target.value)},e[24]=_):_=e[24];let z;e[25]!==l||e[26]!==d||e[27]!==S?(z=t(j,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:d,id:"ud-ban-days",min:1,onChange:_,step:1,type:"number",value:l}),e[25]=l,e[26]=d,e[27]=S,e[28]=z):z=e[28];let q;e[29]!==z||e[30]!==o?(q=h("div",{className:"flex w-24 flex-col gap-1",children:[o,z]}),e[29]=z,e[30]=o,e[31]=q):q=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=E=>{p(E.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 D;e[35]!==r?(D=r("Permanent"),e[35]=r,e[36]=D):D=e[36];let B;e[37]!==H||e[38]!==D?(B=h(W,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[H,D]}),e[37]=H,e[38]=D,e[39]=B):B=e[39];const O=i||!F;let U;e[40]!==r?(U=r("Ban user"),e[40]=r,e[41]=U):U=e[41];let K;e[42]!==v||e[43]!==O||e[44]!==U?(K=t(R,{"data-testid":"ud-ban",disabled:O,onClick:v,size:"sm",type:"button",variant:"destructive",children:U}),e[42]=v,e[43]=O,e[44]=U,e[45]=K):K=e[45];let w;return e[46]!==q||e[47]!==B||e[48]!==K||e[49]!==k?(w=h("div",{className:"flex items-end gap-2",children:[k,q,B,K]}),e[46]=q,e[47]=B,e[48]=K,e[49]=k,e[50]=w):w=e[50],w},kt=(m,e)=>typeof e=="number"&&yt.test(m)?te(e):ee(e),Ct=({capabilities:m,onChanged:e,onClose:i,user:n})=>{const r=ae(),s=J(),c=n.banned===!0,[l,a]=I(null),[d,p]=I(!1),[N,b]=I(0),[F,C]=I(typeof n.role=="string"?n.role:""),[v,u]=I(""),[f,x]=I(null),[y,k]=I(!1),g=(w,E)=>{se((async()=>{p(!0),a(null);try{const Y=await w();E?.refresh!==!1&&(b(Q=>Q+1),e()),E?.onResult?.(Y)}catch(Y){a(Oe(Y))}p(!1)})())},o=w=>{C(w.target.value)},S=w=>{u(w.target.value)},_=()=>{const w=F.trim();w!==""&&g(async()=>{await r.setAuthUserRole({role:w,userId:n.id})})},z=w=>{g(async()=>{await r.banAuthUser({...w,userId:n.id})})},q=()=>{g(async()=>{await r.unbanAuthUser({userId:n.id})})},M=()=>{g(async()=>{await r.setAuthUserPassword({newPassword:v,userId:n.id}),u("")})},H=()=>{g(()=>r.impersonateAuthUser({userId:n.id}),{onResult:w=>{x(w.token)},refresh:!1})},D=()=>{g(async()=>{await r.revokeAuthUserSessions({userId:n.id})})},B=()=>{g(async()=>{await r.removeAuthUser({userId:n.id}),i()})},O=()=>{k(!0)},U=()=>{k(!1)},K=Object.entries(n).filter(([w])=>!xt.has(w));return h(We,{label:s("User details"),onClose:i,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[h("div",{className:"flex items-start justify-between gap-2",children:[h("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}),h("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof n.role=="string"&&n.role!==""&&t(G,{variant:"secondary",children:n.role}),c?t(G,{variant:"destructive",children:s("Banned")}):t(G,{variant:"outline",children:s("Active")}),n.emailVerified===!0?t(G,{variant:"secondary",children:s("verified")}):t(G,{variant:"outline",children:s("unverified")})]})]}),t(R,{"data-testid":"ud-close",onClick:i,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:l}),m.admin&&h(le,{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")})}),h(ie,{className:"flex flex-col gap-3 p-3",children:[h("div",{className:"flex items-end gap-2",children:[h("div",{className:"flex flex-1 flex-col gap-1",children:[t(W,{htmlFor:"ud-role",children:s("Role")}),t(j,{"data-testid":"ud-role-input",id:"ud-role",onChange:o,value:F})]}),t(R,{"data-testid":"ud-set-role",disabled:d||F.trim()==="",onClick:_,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),c?t(R,{"data-testid":"ud-unban",disabled:d,onClick:q,size:"sm",type:"button",variant:"outline",children:s("Unban")}):t(Nt,{busy:d,onBan:z}),h("div",{className:"flex items-end gap-2",children:[h("div",{className:"flex flex-1 flex-col gap-1",children:[t(W,{htmlFor:"ud-password",children:s("New password")}),t(j,{"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")})]}),h("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:D,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),y?h(tt,{children:[t(R,{"data-testid":"ud-delete-confirm",disabled:d,onClick:B,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(R,{"data-testid":"ud-delete-cancel",onClick:U,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(R,{"data-testid":"ud-delete",disabled:d,onClick:O,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),f!==null&&h("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(W,{htmlFor:"ud-token",children:s("Impersonation token")}),t(j,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:f})]})]})]}),t(ht,{busy:d,runAction:g,userId:n.id,version:N}),m.accounts&&t(ft,{busy:d,runAction:g,userId:n.id,version:N}),(m.twoFactor||m.passkey||m.apiKey)&&t(pt,{busy:d,capabilities:m,runAction:g,userId:n.id,version:N}),h("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:K.map(([w,E])=>h("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:w}),t("dd",{className:"m-0 font-mono text-xs break-words",children:kt(w,E)})]},w))})]})]})},wt=50,Ht=({pageSize:m=wt}={})=>{const e=ae(),i=J(),[n,r]=I(""),[s,c]=I(""),[l,a]=I(0),d=Je(n),[p,N]=I(null),[b,F]=I(!1),{capabilities:C}=lt(),v=d.trim(),u=s.trim(),f=Ye(["lunora-auth-users",v,u,m,l],()=>e.listAuthUsers({filterField:u===""?void 0:"role",filterValue:u===""?void 0:u,limit:m,offset:l,search:v===""?void 0:v}).then(o=>({...o,offset:l})),{keepPreviousData:!0}),x=f.data?.rows??null,y=f.error,k=()=>{f.refetch()};Ge(()=>f.poll(),!0);const g=p===null?null:x?.find(o=>o.id===p)??null;return h("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[h("div",{className:"flex flex-wrap items-center gap-2",children:[t(j,{"aria-label":i("Search users"),className:"w-56","data-testid":"us-search",onChange:o=>{r(o.target.value),a(0)},placeholder:i("Search by email or name…"),value:n}),t(j,{"aria-label":i("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:o=>{c(o.target.value),a(0)},placeholder:i("Filter by role"),value:s}),t(R,{"data-testid":"us-new",onClick:()=>{F(!0)},size:"sm",type:"button",children:i("New user")})]}),y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:y}),x!==null&&x.length===0&&t(He,{description:i("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:i("No users.")}),x!==null&&x.length>0&&t(le,{className:"overflow-hidden py-0",children:t(ie,{className:"px-0",children:h(Te,{"data-testid":"us-table",children:[t($e,{children:h(Z,{children:[t(T,{children:i("id")}),t(T,{children:i("email")}),t(T,{children:i("name")}),t(T,{children:i("role")}),t(T,{children:i("status")}),t(T,{children:i("verified")}),t(T,{children:i("created")}),t(T,{"aria-label":i("Actions")})]})}),t(De,{children:x.map(o=>h(Z,{"data-testid":`us-row-${o.id}`,children:[t(P,{className:"font-mono text-xs",children:o.id}),t(P,{children:o.email??""}),t(P,{children:o.name??""}),t(P,{children:typeof o.role=="string"&&o.role!==""?t(G,{variant:"secondary",children:o.role}):""}),t(P,{children:o.banned===!0?t(G,{variant:"destructive",children:i("Banned")}):t(G,{variant:"success",children:i("Active")})}),t(P,{children:o.emailVerified===!0?t(G,{variant:"success",children:i("yes")}):t(G,{variant:"outline",children:i("no")})}),t(P,{className:"text-muted-foreground tabular-nums",children:te(o.createdAt)}),t(P,{children:t(R,{"data-testid":`us-manage-${o.id}`,onClick:()=>{N(o.id)},size:"xs",type:"button",variant:"ghost",children:i("Manage")})})]},o.id))})]})})}),x!==null&&t(et,{count:x.length,offset:f.data?.offset??0,onOffsetChange:a,pageSize:m,prefix:"us",total:f.data?.total}),g!==null&&t(Ct,{capabilities:C,onChanged:k,onClose:()=>{N(null)},user:g}),b&&t(mt,{onClose:()=>{F(!1)},onCreated:k}),C.inviteOnly&&t(ot,{})]})};export{Ht as UsersPanel};
1
+ import{useState as I,useEffect as ze}from"react";import{B as G}from"../packem_shared/badge-r_5B4LHP.mjs";import{B as R}from"../packem_shared/button-q0UYSmrn.mjs";import{C as le,a as ie}from"../packem_shared/card-By2O8ULa.mjs";import{E as He}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as j}from"../packem_shared/input-CXhxesPC.mjs";import{T as Te,a as $e,b as Z,c as T,d as De,e as P}from"../packem_shared/table-D0SBiDu-.mjs";import{a as Ye}from"../packem_shared/use-admin-query-DMnTt_hg.mjs";import{c as X}from"react/compiler-runtime";import{u as Qe}from"../packem_shared/use-auth-config-xzSMjhOV.mjs";import{useAutoRefresh as Ge}from"../packem_shared/DEFAULT_AUTO_REFRESH_MS-jK7srdI4.mjs";import Je from"../packem_shared/useDebounced-DVeQ5-oW.mjs";import{u as ae}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as J}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{w as Xe,c as te,f as se,k as ee,b as Oe}from"../packem_shared/internal-BT5tH08j.mjs";import{A as et}from"../packem_shared/auth-pager-DW77WeZw.mjs";import{jsxs as h,jsx as t,Fragment as tt}from"react/jsx-runtime";import{C as st}from"../packem_shared/checkbox-CnS9cyCz.mjs";import{L as W}from"../packem_shared/label-DKFzyHq6.mjs";import{M as We}from"../packem_shared/modal-shell-CDztwLnv.mjs";import{u as nt}from"../packem_shared/use-async-submit-CBFJevkc.mjs";const lt=()=>{const m=X(3),{config:e,ready:i}=Qe();let n;return m[0]!==e.capabilities||m[1]!==i?(n={capabilities:e.capabilities,ready:i},m[0]=e.capabilities,m[1]=i,m[2]=n):n=m[2],n},it=(m,e)=>typeof m.acceptedAt=="number"?"spent":typeof m.expiresAt=="number"&&m.expiresAt<=e?"expired":"pending",je=500,at=(m,e)=>{if(!URL.canParse(m.trim()))return null;const i=new URL(m.trim());return i.searchParams.set("email",e.email),i.searchParams.set("invite",e.token),i.toString()},rt=m=>{const e=X(34),{issued:i,onSignUpPageChange:n,signUpPage:r}=m,s=J(),[c,l]=I(null);let a;e[0]!==i||e[1]!==r?(a=at(r,i),e[0]=i,e[1]=r,e[2]=a):a=e[2];const d=a;let p;e[3]!==d?(p=()=>{const _="navigator"in globalThis?globalThis.navigator.clipboard:void 0;d===null||_===void 0||se(_.writeText(d).then(()=>(l(d),!0)))},e[3]=d,e[4]=p):p=e[4];const N=p;let b;e[5]!==s?(b=s("Send this link to the invitee. It is shown once and cannot be recovered."),e[5]=s,e[6]=b):b=e[6];let F;e[7]!==b?(F=t("p",{className:"text-sm",children:b}),e[7]=b,e[8]=F):F=e[8];const C=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 u;e[11]!==n?(u=_=>{n(_.target.value)},e[11]=n,e[12]=u):u=e[12];let f;e[13]!==r||e[14]!==C||e[15]!==v||e[16]!==u?(f=t(j,{"aria-invalid":C,"aria-label":v,"data-testid":"sign-up-invitation-page",onChange:u,value:r}),e[13]=r,e[14]=C,e[15]=v,e[16]=u,e[17]=f):f=e[17];const x=d??"";let y;e[18]!==x?(y=t(j,{"data-testid":"sign-up-invitation-link",readOnly:!0,value:x}),e[18]=x,e[19]=y):y=e[19];let k;e[20]!==c||e[21]!==d||e[22]!==s?(k=s(c!==null&&c===d?"Copied":"Copy"),e[20]=c,e[21]=d,e[22]=s,e[23]=k):k=e[23];let g;e[24]!==N||e[25]!==k?(g=t(R,{"data-testid":"sign-up-invitation-copy",onClick:N,type:"button",children:k}),e[24]=N,e[25]=k,e[26]=g):g=e[26];let o;e[27]!==y||e[28]!==g?(o=h("div",{className:"flex gap-2",children:[y,g]}),e[27]=y,e[28]=g,e[29]=o):o=e[29];let S;return e[30]!==o||e[31]!==F||e[32]!==f?(S=t(le,{children:h(ie,{className:"flex flex-col gap-2 p-4",children:[F,f,o]})}),e[30]=o,e[31]=F,e[32]=f,e[33]=S):S=e[33],S},ot=()=>{const m=ae(),e=J(),[i,n]=I(""),[r,s]=I(null),[c,l]=I(null),[a,d]=I(()=>`${Xe(m.url)}/sign-up`),p=Ye(["lunora-auth-sign-up-invitations",je],()=>m.listAuthSignUpInvitations({limit:je})),N=p.data?.rows??null,b=p.data?.total??0,F=()=>{const v=i.trim();v!==""&&(s(null),se((async()=>{try{const u=await m.createAuthSignUpInvitation({email:v}),f=typeof u.token=="string"?u.token:void 0;l(f===void 0?null:{email:v,token:f}),n(""),p.refetch()}catch(u){s(u instanceof Error?u.message:String(u))}})()))},C=v=>{s(null),se((async()=>{try{await m.revokeAuthSignUpInvitation({email:v}),p.refetch()}catch(u){s(u instanceof Error?u.message:String(u))}})())};return h("div",{className:"flex flex-col gap-4","data-testid":"sign-up-invitations",children:[h("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.")})]}),h("div",{className:"flex gap-2",children:[t(j,{"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:i}),t(R,{"data-testid":"sign-up-invitation-submit",onClick:F,type:"button",children:e("Invite")})]}),c!==null&&t(rt,{issued:c,onSignUpPageChange:d,signUpPage:a},c.token),(r??p.error)!==null&&t("p",{className:"text-sm text-destructive","data-testid":"sign-up-invitations-error",role:"alert",children:r??p.error}),N!==null&&N.length===0&&t(He,{testId:"sign-up-invitations-empty",title:e("Nobody has been invited yet.")}),N!==null&&b>N.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.")}),N!==null&&N.length>0&&t(le,{children:t(ie,{className:"p-0",children:h(Te,{children:[t($e,{children:h(Z,{children:[t(T,{children:e("Email")}),t(T,{children:e("Status")}),t(T,{children:e("Expires")}),t(T,{children:e("Invited by")}),t(T,{})]})}),t(De,{children:N.map(v=>{const u=it(v,Date.now()),f=v.email??"";return h(Z,{"data-testid":`sign-up-invitation-${f}`,children:[t(P,{children:f}),h(P,{"data-testid":`sign-up-invitation-status-${f}`,children:[u==="spent"&&e("Accepted"),u==="expired"&&e("Expired"),u==="pending"&&e("Pending")]}),t(P,{children:typeof v.expiresAt=="number"?te(v.expiresAt):"—"}),t(P,{children:v.invitedBy??"—"}),t(P,{className:"text-right",children:t(R,{onClick:()=>{C(f)},type:"button",variant:"ghost",children:e("Revoke")})})]},v.id)})})]})})})]})},dt={boolean:"checkbox",date:"datetime-local",number:"number",string:"text"},ct=(m,e)=>m.type==="boolean"?!0:typeof e!="string"||e.trim()===""?!1:m.type!=="number"||!Number.isNaN(Number(e.trim())),ut=(m,e)=>{if(m.type==="boolean")return e===!0?{value:!0}:m.required?{value:!1}:void 0;const i=typeof e=="string"?e.trim():"";if(i!==""){if(m.type==="number"){const n=Number(i);return Number.isNaN(n)?void 0:{value:n}}return{value:i}}},mt=m=>{const e=X(105),{onClose:i,onCreated:n}=m,r=ae(),s=J(),{config:c}=Qe(),{busy:l,error:a,run:d}=nt(),[p,N]=I(""),[b,F]=I(""),[C,v]=I(""),[u,f]=I("");let x;e[0]===Symbol.for("react.memo_cache_sentinel")?(x={},e[0]=x):x=e[0];const[y,k]=I(x);let g;e[1]===Symbol.for("react.memo_cache_sentinel")?(g=A=>{N(A.target.value)},e[1]=g):g=e[1];const o=g;let S;e[2]===Symbol.for("react.memo_cache_sentinel")?(S=A=>{F(A.target.value)},e[2]=S):S=e[2];const _=S;let z;e[3]===Symbol.for("react.memo_cache_sentinel")?(z=A=>{v(A.target.value)},e[3]=z):z=e[3];const q=z;let M;e[4]===Symbol.for("react.memo_cache_sentinel")?(M=A=>{f(A.target.value)},e[4]=M):M=e[4];const H=M;let D;e[5]===Symbol.for("react.memo_cache_sentinel")?(D=(A,V)=>{k(ne=>({...ne,[A]:V}))},e[5]=D):D=e[5];const B=D;let O;e[6]!==y?(O=A=>y[A.name]??(A.type==="boolean"?!1:""),e[6]=y,e[7]=O):O=e[7];const U=O;let K;if(e[8]!==c.userFields||e[9]!==U){let A;e[11]!==U?(A=V=>!V.required||ct(V,U(V)),e[11]=U,e[12]=A):A=e[12],K=c.userFields.every(A),e[8]=c.userFields,e[9]=U,e[10]=K}else K=e[10];const w=K;let E;e[13]!==l||e[14]!==p||e[15]!==b||e[16]!==w?(E=!l&&p.trim()!==""&&b.trim()!==""&&w,e[13]=l,e[14]=p,e[15]=b,e[16]=w,e[17]=E):E=e[17];const Y=E;let Q;e[18]!==c.userFields||e[19]!==U?(Q=()=>{const A={};for(const V of c.userFields){const ne=ut(V,U(V));ne!==void 0&&(A[V.name]=ne.value)}return Object.keys(A).length===0?void 0:A},e[18]=c.userFields,e[19]=U,e[20]=Q):Q=e[20];const $=Q;let L;e[21]!==$||e[22]!==r||e[23]!==p||e[24]!==b||e[25]!==i||e[26]!==n||e[27]!==C||e[28]!==u||e[29]!==d?(L=()=>{d(async()=>{await r.createAuthUser({data:$(),email:p.trim(),name:b.trim(),password:C===""?void 0:C,role:u.trim()===""?void 0:u.trim()}),n(),i()})},e[21]=$,e[22]=r,e[23]=p,e[24]=b,e[25]=i,e[26]=n,e[27]=C,e[28]=u,e[29]=d,e[30]=L):L=e[30];const Be=L;let re;e[31]!==s?(re=s("Create user"),e[31]=s,e[32]=re):re=e[32];let oe;e[33]!==s?(oe=s("Create user"),e[33]=s,e[34]=oe):oe=e[34];let de;e[35]!==oe?(de=t("h2",{className:"text-sm font-semibold text-foreground",children:oe}),e[35]=oe,e[36]=de):de=e[36];let ce;e[37]!==s?(ce=s("email"),e[37]=s,e[38]=ce):ce=e[38];let ue;e[39]!==ce?(ue=t(W,{htmlFor:"uc-email",children:ce}),e[39]=ce,e[40]=ue):ue=e[40];let me;e[41]!==p?(me=t(j,{"data-testid":"uc-email",id:"uc-email",onChange:o,type:"email",value:p}),e[41]=p,e[42]=me):me=e[42];let he;e[43]!==ue||e[44]!==me?(he=h("div",{className:"flex flex-col gap-1",children:[ue,me]}),e[43]=ue,e[44]=me,e[45]=he):he=e[45];let fe;e[46]!==s?(fe=s("name"),e[46]=s,e[47]=fe):fe=e[47];let pe;e[48]!==fe?(pe=t(W,{htmlFor:"uc-name",children:fe}),e[48]=fe,e[49]=pe):pe=e[49];let ve;e[50]!==b?(ve=t(j,{"data-testid":"uc-name",id:"uc-name",onChange:_,value:b}),e[50]=b,e[51]=ve):ve=e[51];let ge;e[52]!==pe||e[53]!==ve?(ge=h("div",{className:"flex flex-col gap-1",children:[pe,ve]}),e[52]=pe,e[53]=ve,e[54]=ge):ge=e[54];let ye;e[55]!==s?(ye=s("Password (optional)"),e[55]=s,e[56]=ye):ye=e[56];let be;e[57]!==ye?(be=t(W,{htmlFor:"uc-password",children:ye}),e[57]=ye,e[58]=be):be=e[58];let xe;e[59]!==C?(xe=t(j,{"data-testid":"uc-password",id:"uc-password",onChange:q,type:"password",value:C}),e[59]=C,e[60]=xe):xe=e[60];let Ne;e[61]!==be||e[62]!==xe?(Ne=h("div",{className:"flex flex-col gap-1",children:[be,xe]}),e[61]=be,e[62]=xe,e[63]=Ne):Ne=e[63];let ke;e[64]!==s?(ke=s("Role (optional)"),e[64]=s,e[65]=ke):ke=e[65];let Ce;e[66]!==ke?(Ce=t(W,{htmlFor:"uc-role",children:ke}),e[66]=ke,e[67]=Ce):Ce=e[67];let we;e[68]!==u?(we=t(j,{"data-testid":"uc-role",id:"uc-role",onChange:H,value:u}),e[68]=u,e[69]=we):we=e[69];let Ae;e[70]!==Ce||e[71]!==we?(Ae=h("div",{className:"flex flex-col gap-1",children:[Ce,we]}),e[70]=Ce,e[71]=we,e[72]=Ae):Ae=e[72];let Ie;e[73]!==c.userFields||e[74]!==U||e[75]!==s?(Ie=c.userFields.length>0&&h("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")}),c.userFields.map(A=>{const V=`uc-field-${A.name}`,ne=A.required?"":` (${s("optional")})`;if(A.type==="boolean"){const _e=U(A)===!0;return h("label",{className:"flex items-center gap-2",htmlFor:V,children:[t(st,{checked:_e,"data-testid":V,id:V,onCheckedChange:Ze=>{B(A.name,Ze)}}),h("span",{className:"text-sm",children:[A.name,ne]})]},A.name)}const Ve=U(A);return h("div",{className:"flex flex-col gap-1",children:[h(W,{htmlFor:V,children:[A.name,ne]}),t(j,{"data-testid":V,id:V,onChange:_e=>{B(A.name,_e.target.value)},type:dt[A.type],value:typeof Ve=="string"?Ve:""})]},A.name)})]}),e[73]=c.userFields,e[74]=U,e[75]=s,e[76]=Ie):Ie=e[76];let Se;e[77]!==a?(Se=a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"uc-error",role:"alert",children:a}),e[77]=a,e[78]=Se):Se=e[78];let Fe;e[79]!==s?(Fe=s("Cancel"),e[79]=s,e[80]=Fe):Fe=e[80];let Ue;e[81]!==i||e[82]!==Fe?(Ue=t(R,{"data-testid":"uc-cancel",onClick:i,size:"sm",type:"button",variant:"outline",children:Fe}),e[81]=i,e[82]=Fe,e[83]=Ue):Ue=e[83];const Le=!Y;let Pe;e[84]!==l||e[85]!==s?(Pe=s(l?"Creating…":"Create"),e[84]=l,e[85]=s,e[86]=Pe):Pe=e[86];let Re;e[87]!==Be||e[88]!==Le||e[89]!==Pe?(Re=t(R,{"data-testid":"uc-submit",disabled:Le,onClick:Be,size:"sm",type:"button",children:Pe}),e[87]=Be,e[88]=Le,e[89]=Pe,e[90]=Re):Re=e[90];let Ee;e[91]!==Ue||e[92]!==Re?(Ee=h("div",{className:"flex justify-end gap-2 pt-1",children:[Ue,Re]}),e[91]=Ue,e[92]=Re,e[93]=Ee):Ee=e[93];let Ke;return e[94]!==i||e[95]!==re||e[96]!==de||e[97]!==he||e[98]!==ge||e[99]!==Ne||e[100]!==Ae||e[101]!==Ie||e[102]!==Se||e[103]!==Ee?(Ke=h(We,{label:re,onClose:i,panelTestId:"uc-dialog",testId:"uc-overlay",variant:"dialog",children:[de,he,ge,Ne,Ae,Ie,Se,Ee]}),e[94]=i,e[95]=re,e[96]=de,e[97]=he,e[98]=ge,e[99]=Ne,e[100]=Ae,e[101]=Ie,e[102]=Se,e[103]=Ee,e[104]=Ke):Ke=e[104],Ke},Me=m=>{const e=X(2),{children:i}=m;let n;return e[0]!==i?(n=t("h3",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:i}),e[0]=i,e[1]=n):n=e[1],n},qe=m=>{const e=X(15),{children:i,columns:n,testId:r}=m,s=J();let c;e[0]!==n?(c=n.map(vt),e[0]=n,e[1]=c):c=e[1];let l;e[2]!==s?(l=s("Actions"),e[2]=s,e[3]=l):l=e[3];let a;e[4]!==l?(a=t(T,{"aria-label":l}),e[4]=l,e[5]=a):a=e[5];let d;e[6]!==c||e[7]!==a?(d=t($e,{children:h(Z,{children:[c,a]})}),e[6]=c,e[7]=a,e[8]=d):d=e[8];let p;e[9]!==i?(p=t(De,{children:i}),e[9]=i,e[10]=p):p=e[10];let N;return e[11]!==d||e[12]!==p||e[13]!==r?(N=t(le,{className:"overflow-hidden py-0",children:t(ie,{className:"px-0",children:h(Te,{"data-testid":r,children:[d,p]})})}),e[11]=d,e[12]=p,e[13]=r,e[14]=N):N=e[14],N},ht=m=>{const e=X(29),{busy:i,runAction:n,userId:r,version:s}=m,c=ae(),l=J(),[a,d]=I(null),[p,N]=I(null);let b;e[0]!==c||e[1]!==r?(b=()=>{se((async()=>{N(null);try{const o=await c.listAuthSessions({limit:50,userId:r});d(o.rows)}catch(o){const S=o;d(null),N(Oe(S))}})())},e[0]=c,e[1]=r,e[2]=b):b=e[2];let F;e[3]!==c||e[4]!==r||e[5]!==s?(F=[c,r,s],e[3]=c,e[4]=r,e[5]=s,e[6]=F):F=e[6],ze(b,F);let C;e[7]!==c||e[8]!==n?(C=o=>{n(()=>c.revokeAuthSession({sessionId:o}))},e[7]=c,e[8]=n,e[9]=C):C=e[9];const v=C;let u;e[10]!==l?(u=l("Sessions"),e[10]=l,e[11]=u):u=e[11];let f;e[12]!==u?(f=t(Me,{children:u}),e[12]=u,e[13]=f):f=e[13];let x;e[14]!==p?(x=p!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-sessions-error",role:"alert",children:p}),e[14]=p,e[15]=x):x=e[15];let y;e[16]!==a||e[17]!==l?(y=a!==null&&a.length===0&&t("p",{className:"text-sm text-muted-foreground","data-testid":"ud-sessions-empty",children:l("No active sessions.")}),e[16]=a,e[17]=l,e[18]=y):y=e[18];let k;e[19]!==i||e[20]!==v||e[21]!==a||e[22]!==l?(k=a!==null&&a.length>0&&t(le,{className:"overflow-hidden py-0",children:t(ie,{className:"px-0",children:h(Te,{"data-testid":"ud-sessions-table",children:[t($e,{children:h(Z,{children:[t(T,{children:l("expires")}),t(T,{children:l("ip")}),t(T,{children:l("user agent")}),t(T,{"aria-label":l("Actions")})]})}),t(De,{children:a.map(o=>h(Z,{"data-testid":`ud-session-${o.id}`,children:[t(P,{className:"text-muted-foreground tabular-nums",children:te(o.expiresAt)}),t(P,{children:o.ipAddress??""}),t(P,{className:"max-w-40 truncate",children:o.userAgent??""}),t(P,{children:t(R,{"data-testid":`ud-revoke-${o.id}`,disabled:i,onClick:()=>{v(o.id)},size:"xs",type:"button",variant:"ghost",children:l("Revoke")})})]},o.id))})]})})}),e[19]=i,e[20]=v,e[21]=a,e[22]=l,e[23]=k):k=e[23];let g;return e[24]!==f||e[25]!==x||e[26]!==y||e[27]!==k?(g=h("div",{className:"flex flex-col gap-2","data-testid":"ud-sessions",children:[f,x,y,k]}),e[24]=f,e[25]=x,e[26]=y,e[27]=k,e[28]=g):g=e[28],g},ft=m=>{const e=X(30),{busy:i,runAction:n,userId:r,version:s}=m,c=ae(),l=J(),[a,d]=I(null),[p,N]=I(null);let b;e[0]!==c||e[1]!==r?(b=()=>{se((async()=>{N(null);try{d(await c.listAuthAccounts({userId:r}))}catch(o){const S=o;d(null),N(Oe(S))}})())},e[0]=c,e[1]=r,e[2]=b):b=e[2];let F;e[3]!==c||e[4]!==r||e[5]!==s?(F=[c,r,s],e[3]=c,e[4]=r,e[5]=s,e[6]=F):F=e[6],ze(b,F);let C;e[7]!==c||e[8]!==n||e[9]!==r?(C=o=>{n(()=>c.unlinkAuthAccount({accountId:o,userId:r}))},e[7]=c,e[8]=n,e[9]=r,e[10]=C):C=e[10];const v=C;let u;e[11]!==l?(u=l("Linked accounts"),e[11]=l,e[12]=u):u=e[12];let f;e[13]!==u?(f=t(Me,{children:u}),e[13]=u,e[14]=f):f=e[14];let x;e[15]!==p?(x=p!==null&&t("p",{className:"text-sm text-destructive",role:"alert",children:p}),e[15]=p,e[16]=x):x=e[16];let y;e[17]!==a||e[18]!==l?(y=a!==null&&a.length===0&&t("p",{className:"text-sm text-muted-foreground",children:l("No linked accounts.")}),e[17]=a,e[18]=l,e[19]=y):y=e[19];let k;e[20]!==a||e[21]!==i||e[22]!==v||e[23]!==l?(k=a!==null&&a.length>0&&t(le,{className:"overflow-hidden py-0",children:t(ie,{className:"px-0",children:h(Te,{"data-testid":"ud-accounts-table",children:[t($e,{children:h(Z,{children:[t(T,{children:l("provider")}),t(T,{children:l("created")}),t(T,{"aria-label":l("Actions")})]})}),t(De,{children:a.map(o=>{const S=ee(o.id);return h(Z,{"data-testid":`ud-account-${S}`,children:[t(P,{children:ee(o.providerId)}),t(P,{className:"text-muted-foreground tabular-nums",children:te(o.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-unlink-${S}`,disabled:i,onClick:()=>{v(S)},size:"xs",type:"button",variant:"ghost",children:l("Unlink")})})]},S)})})]})})}),e[20]=a,e[21]=i,e[22]=v,e[23]=l,e[24]=k):k=e[24];let g;return e[25]!==f||e[26]!==x||e[27]!==y||e[28]!==k?(g=h("div",{className:"flex flex-col gap-2","data-testid":"ud-accounts",children:[f,x,y,k]}),e[25]=f,e[26]=x,e[27]=y,e[28]=k,e[29]=g):g=e[29],g},pt=m=>{const e=X(71),{busy:i,capabilities:n,runAction:r,userId:s,version:c}=m,l=ae(),a=J(),[d,p]=I(null),[N,b]=I(null),[F,C]=I(null),[v,u]=I(0);let f;e[0]!==n.apiKey||e[1]!==l||e[2]!==s?(f=()=>{if(!n.apiKey)return;const $={live:!0};return se((async()=>{try{const L=await l.listAuthApiKeys({userId:s});$.live&&(b({rows:L,userId:s}),C(null))}catch{$.live&&C(s)}})()),()=>{$.live=!1}},e[0]=n.apiKey,e[1]=l,e[2]=s,e[3]=f):f=e[3];let x;e[4]!==v||e[5]!==n.apiKey||e[6]!==l||e[7]!==s||e[8]!==c?(x=[v,n.apiKey,l,s,c],e[4]=v,e[5]=n.apiKey,e[6]=l,e[7]=s,e[8]=c,e[9]=x):x=e[9],ze(f,x);const y=N?.userId===s?N.rows:null,k=F===s;let g;e[10]!==n.passkey||e[11]!==l||e[12]!==s?(g=()=>{n.passkey&&se((async()=>{try{p(await l.listAuthPasskeys({userId:s}))}catch{p(null)}})())},e[10]=n.passkey,e[11]=l,e[12]=s,e[13]=g):g=e[13];let o;e[14]!==n.passkey||e[15]!==l||e[16]!==s||e[17]!==c?(o=[n.passkey,l,s,c],e[14]=n.passkey,e[15]=l,e[16]=s,e[17]=c,e[18]=o):o=e[18],ze(g,o);let S;e[19]!==l||e[20]!==r||e[21]!==s?(S=()=>{r(()=>l.disableAuthTwoFactor({userId:s}))},e[19]=l,e[20]=r,e[21]=s,e[22]=S):S=e[22];const _=S;let z;e[23]!==l||e[24]!==r?(z=$=>{r(()=>l.deleteAuthPasskey({passkeyId:$}))},e[23]=l,e[24]=r,e[25]=z):z=e[25];const q=z;let M;e[26]!==l||e[27]!==r?(M=$=>{r(()=>l.deleteAuthApiKey({apiKeyId:$}))},e[26]=l,e[27]=r,e[28]=M):M=e[28];const H=M;let D;e[29]!==a?(D=a("Security"),e[29]=a,e[30]=D):D=e[30];let B;e[31]!==D?(B=t(Me,{children:D}),e[31]=D,e[32]=B):B=e[32];let O;e[33]!==i||e[34]!==n.twoFactor||e[35]!==_||e[36]!==a?(O=n.twoFactor&&t(R,{"data-testid":"ud-disable-2fa",disabled:i,onClick:_,size:"sm",type:"button",variant:"outline",children:a("Disable two-factor")}),e[33]=i,e[34]=n.twoFactor,e[35]=_,e[36]=a,e[37]=O):O=e[37];let U;e[38]!==n.passkey||e[39]!==d||e[40]!==a?(U=n.passkey&&d!==null&&d.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No passkeys.")}),e[38]=n.passkey,e[39]=d,e[40]=a,e[41]=U):U=e[41];let K;e[42]!==i||e[43]!==n.passkey||e[44]!==q||e[45]!==d||e[46]!==a?(K=n.passkey&&d!==null&&d.length>0&&t(qe,{columns:[a("name"),a("created")],testId:"ud-passkeys-table",children:d.map($=>{const L=ee($.id);return h(Z,{"data-testid":`ud-passkey-${L}`,children:[t(P,{children:ee($.name)||L}),t(P,{className:"text-muted-foreground tabular-nums",children:te($.createdAt)}),t(P,{children:t(R,{"data-testid":`ud-delete-passkey-${L}`,disabled:i,onClick:()=>{q(L)},size:"xs",type:"button",variant:"ghost",children:a("Delete")})})]},L)})}),e[42]=i,e[43]=n.passkey,e[44]=q,e[45]=d,e[46]=a,e[47]=K):K=e[47];let w;e[48]!==k||e[49]!==i||e[50]!==n.apiKey||e[51]!==a?(w=n.apiKey&&k&&h("div",{className:"flex items-center gap-2",children:[t("p",{className:"text-sm text-muted-foreground",children:a("Could not load API keys.")}),t(R,{"data-testid":"ud-api-keys-retry",disabled:i,onClick:()=>{u(gt)},size:"xs",type:"button",variant:"outline",children:a("Retry")})]}),e[48]=k,e[49]=i,e[50]=n.apiKey,e[51]=a,e[52]=w):w=e[52];let E;e[53]!==n.apiKey||e[54]!==y||e[55]!==a?(E=n.apiKey&&y!==null&&y.length===0&&t("p",{className:"text-sm text-muted-foreground",children:a("No API keys.")}),e[53]=n.apiKey,e[54]=y,e[55]=a,e[56]=E):E=e[56];let Y;e[57]!==i||e[58]!==n.apiKey||e[59]!==y||e[60]!==H||e[61]!==a?(Y=n.apiKey&&y!==null&&y.length>0&&t(qe,{columns:[a("name"),a("Key"),a("created"),a("Expires")],testId:"ud-api-keys-table",children:y.map($=>{const L=ee($.id);return h(Z,{"data-testid":`ud-api-key-${L}`,children:[t(P,{children:ee($.name)||L}),t(P,{className:"font-mono text-muted-foreground",children:ee($.start)||"—"}),t(P,{className:"text-muted-foreground tabular-nums",children:te($.createdAt)}),t(P,{className:"text-muted-foreground tabular-nums",children:te($.expiresAt,a("Never"))}),t(P,{children:t(R,{"data-testid":`ud-revoke-api-key-${L}`,disabled:i,onClick:()=>{H(L)},size:"xs",type:"button",variant:"ghost",children:a("Revoke")})})]},L)})}),e[57]=i,e[58]=n.apiKey,e[59]=y,e[60]=H,e[61]=a,e[62]=Y):Y=e[62];let Q;return e[63]!==O||e[64]!==U||e[65]!==K||e[66]!==w||e[67]!==E||e[68]!==Y||e[69]!==B?(Q=h("div",{className:"flex flex-col gap-2","data-testid":"ud-security",children:[B,O,U,K,w,E,Y]}),e[63]=O,e[64]=U,e[65]=K,e[66]=w,e[67]=E,e[68]=Y,e[69]=B,e[70]=Q):Q=e[70],Q};function vt(m){return t(T,{children:m},m)}function gt(m){return m+1}const yt=/(?:at|expires)$/iu,bt=/^[1-9]\d*$/u,xt=new Set(["banExpires","banned","banReason","email","emailVerified","id","name","role"]),Nt=m=>{const e=X(51),{busy:i,onBan:n}=m,r=J(),[s,c]=I(""),[l,a]=I(""),[d,p]=I(!1);let N;e[0]!==l?(N=bt.test(l.trim())&&Number.isSafeInteger(Number(l.trim())*86400)?Number(l.trim()):void 0,e[0]=l,e[1]=N):N=e[1];const b=N,F=d||b!==void 0;let C;e[2]!==n||e[3]!==d||e[4]!==s||e[5]!==b?(C=()=>{n({expiresInSeconds:d||b===void 0?void 0:b*86400,reason:s.trim()===""?void 0:s.trim()})},e[2]=n,e[3]=d,e[4]=s,e[5]=b,e[6]=C):C=e[6];const v=C;let u;e[7]!==r?(u=r("Ban reason (optional)"),e[7]=r,e[8]=u):u=e[8];let f;e[9]!==u?(f=t(W,{htmlFor:"ud-ban-reason",children:u}),e[9]=u,e[10]=f):f=e[10];let x;e[11]===Symbol.for("react.memo_cache_sentinel")?(x=E=>{c(E.target.value)},e[11]=x):x=e[11];let y;e[12]!==s?(y=t(j,{"data-testid":"ud-ban-reason",id:"ud-ban-reason",onChange:x,value:s}),e[12]=s,e[13]=y):y=e[13];let k;e[14]!==f||e[15]!==y?(k=h("div",{className:"flex flex-1 flex-col gap-1",children:[f,y]}),e[14]=f,e[15]=y,e[16]=k):k=e[16];let g;e[17]!==r?(g=r("Days"),e[17]=r,e[18]=g):g=e[18];let o;e[19]!==g?(o=t(W,{htmlFor:"ud-ban-days",children:g}),e[19]=g,e[20]=o):o=e[20];let S;e[21]!==l||e[22]!==b?(S=l.trim()!==""&&b===void 0,e[21]=l,e[22]=b,e[23]=S):S=e[23];let _;e[24]===Symbol.for("react.memo_cache_sentinel")?(_=E=>{a(E.target.value)},e[24]=_):_=e[24];let z;e[25]!==l||e[26]!==d||e[27]!==S?(z=t(j,{"aria-invalid":S,"data-testid":"ud-ban-days",disabled:d,id:"ud-ban-days",min:1,onChange:_,step:1,type:"number",value:l}),e[25]=l,e[26]=d,e[27]=S,e[28]=z):z=e[28];let q;e[29]!==z||e[30]!==o?(q=h("div",{className:"flex w-24 flex-col gap-1",children:[o,z]}),e[29]=z,e[30]=o,e[31]=q):q=e[31];let M;e[32]===Symbol.for("react.memo_cache_sentinel")?(M=E=>{p(E.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 D;e[35]!==r?(D=r("Permanent"),e[35]=r,e[36]=D):D=e[36];let B;e[37]!==H||e[38]!==D?(B=h(W,{className:"flex items-center gap-1.5 pb-2 text-xs font-normal",htmlFor:"ud-ban-permanent",children:[H,D]}),e[37]=H,e[38]=D,e[39]=B):B=e[39];const O=i||!F;let U;e[40]!==r?(U=r("Ban user"),e[40]=r,e[41]=U):U=e[41];let K;e[42]!==v||e[43]!==O||e[44]!==U?(K=t(R,{"data-testid":"ud-ban",disabled:O,onClick:v,size:"sm",type:"button",variant:"destructive",children:U}),e[42]=v,e[43]=O,e[44]=U,e[45]=K):K=e[45];let w;return e[46]!==q||e[47]!==B||e[48]!==K||e[49]!==k?(w=h("div",{className:"flex items-end gap-2",children:[k,q,B,K]}),e[46]=q,e[47]=B,e[48]=K,e[49]=k,e[50]=w):w=e[50],w},kt=(m,e)=>typeof e=="number"&&yt.test(m)?te(e):ee(e),Ct=({capabilities:m,onChanged:e,onClose:i,user:n})=>{const r=ae(),s=J(),c=n.banned===!0,[l,a]=I(null),[d,p]=I(!1),[N,b]=I(0),[F,C]=I(typeof n.role=="string"?n.role:""),[v,u]=I(""),[f,x]=I(null),[y,k]=I(!1),g=(w,E)=>{se((async()=>{p(!0),a(null);try{const Y=await w();E?.refresh!==!1&&(b(Q=>Q+1),e()),E?.onResult?.(Y)}catch(Y){a(Oe(Y))}p(!1)})())},o=w=>{C(w.target.value)},S=w=>{u(w.target.value)},_=()=>{const w=F.trim();w!==""&&g(async()=>{await r.setAuthUserRole({role:w,userId:n.id})})},z=w=>{g(async()=>{await r.banAuthUser({...w,userId:n.id})})},q=()=>{g(async()=>{await r.unbanAuthUser({userId:n.id})})},M=()=>{g(async()=>{await r.setAuthUserPassword({newPassword:v,userId:n.id}),u("")})},H=()=>{g(()=>r.impersonateAuthUser({userId:n.id}),{onResult:w=>{x(w.token)},refresh:!1})},D=()=>{g(async()=>{await r.revokeAuthUserSessions({userId:n.id})})},B=()=>{g(async()=>{await r.removeAuthUser({userId:n.id}),i()})},O=()=>{k(!0)},U=()=>{k(!1)},K=Object.entries(n).filter(([w])=>!xt.has(w));return h(We,{label:s("User details"),onClose:i,panelTestId:"ud-panel",testId:"ud-overlay",variant:"drawer",children:[h("div",{className:"flex items-start justify-between gap-2",children:[h("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}),h("div",{className:"flex flex-wrap items-center gap-1.5 pt-1",children:[typeof n.role=="string"&&n.role!==""&&t(G,{variant:"secondary",children:n.role}),c?t(G,{variant:"destructive",children:s("Banned")}):t(G,{variant:"outline",children:s("Active")}),n.emailVerified===!0?t(G,{variant:"secondary",children:s("verified")}):t(G,{variant:"outline",children:s("unverified")})]})]}),t(R,{"data-testid":"ud-close",onClick:i,size:"sm",type:"button",variant:"ghost",children:s("Close")})]}),l!==null&&t("p",{className:"text-sm text-destructive","data-testid":"ud-action-error",role:"alert",children:l}),m.admin&&h(le,{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")})}),h(ie,{className:"flex flex-col gap-3 p-3",children:[h("div",{className:"flex items-end gap-2",children:[h("div",{className:"flex flex-1 flex-col gap-1",children:[t(W,{htmlFor:"ud-role",children:s("Role")}),t(j,{"data-testid":"ud-role-input",id:"ud-role",onChange:o,value:F})]}),t(R,{"data-testid":"ud-set-role",disabled:d||F.trim()==="",onClick:_,size:"sm",type:"button",variant:"outline",children:s("Set role")})]}),c?t(R,{"data-testid":"ud-unban",disabled:d,onClick:q,size:"sm",type:"button",variant:"outline",children:s("Unban")}):t(Nt,{busy:d,onBan:z}),h("div",{className:"flex items-end gap-2",children:[h("div",{className:"flex flex-1 flex-col gap-1",children:[t(W,{htmlFor:"ud-password",children:s("New password")}),t(j,{"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")})]}),h("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:D,size:"sm",type:"button",variant:"outline",children:s("Revoke all sessions")}),y?h(tt,{children:[t(R,{"data-testid":"ud-delete-confirm",disabled:d,onClick:B,size:"sm",type:"button",variant:"destructive",children:s("Confirm delete")}),t(R,{"data-testid":"ud-delete-cancel",onClick:U,size:"sm",type:"button",variant:"ghost",children:s("Cancel")})]}):t(R,{"data-testid":"ud-delete",disabled:d,onClick:O,size:"sm",type:"button",variant:"destructive",children:s("Delete user")})]}),f!==null&&h("div",{className:"flex flex-col gap-1","data-testid":"ud-impersonation",children:[t(W,{htmlFor:"ud-token",children:s("Impersonation token")}),t(j,{"data-testid":"ud-token",id:"ud-token",readOnly:!0,value:f})]})]})]}),t(ht,{busy:d,runAction:g,userId:n.id,version:N}),m.accounts&&t(ft,{busy:d,runAction:g,userId:n.id,version:N}),(m.twoFactor||m.passkey||m.apiKey)&&t(pt,{busy:d,capabilities:m,runAction:g,userId:n.id,version:N}),h("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:K.map(([w,E])=>h("div",{className:"flex flex-col border-t border-border py-1.5",children:[t("dt",{className:"text-xs font-semibold text-muted-foreground",children:w}),t("dd",{className:"m-0 font-mono text-xs break-words",children:kt(w,E)})]},w))})]})]})},wt=50,Ht=({pageSize:m=wt}={})=>{const e=ae(),i=J(),[n,r]=I(""),[s,c]=I(""),[l,a]=I(0),d=Je(n),[p,N]=I(null),[b,F]=I(!1),{capabilities:C}=lt(),v=d.trim(),u=s.trim(),f=Ye(["lunora-auth-users",v,u,m,l],()=>e.listAuthUsers({filterField:u===""?void 0:"role",filterValue:u===""?void 0:u,limit:m,offset:l,search:v===""?void 0:v}).then(o=>({...o,offset:l})),{keepPreviousData:!0}),x=f.data?.rows??null,y=f.error,k=()=>{f.refetch()};Ge(()=>f.poll(),!0);const g=p===null?null:x?.find(o=>o.id===p)??null;return h("div",{className:"flex flex-col gap-4","data-testid":"lunora-users",children:[h("div",{className:"flex flex-wrap items-center gap-2",children:[t(j,{"aria-label":i("Search users"),className:"w-56","data-testid":"us-search",onChange:o=>{r(o.target.value),a(0)},placeholder:i("Search by email or name…"),value:n}),t(j,{"aria-label":i("Filter by role"),className:"w-40","data-testid":"us-role-filter",onChange:o=>{c(o.target.value),a(0)},placeholder:i("Filter by role"),value:s}),t(R,{"data-testid":"us-new",onClick:()=>{F(!0)},size:"sm",type:"button",children:i("New user")})]}),y!==null&&t("p",{className:"text-sm text-destructive","data-testid":"us-users-error",role:"alert",children:y}),x!==null&&x.length===0&&t(He,{description:i("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:i("No users.")}),x!==null&&x.length>0&&t(le,{className:"overflow-hidden py-0",children:t(ie,{className:"px-0",children:h(Te,{"data-testid":"us-table",children:[t($e,{children:h(Z,{children:[t(T,{children:i("id")}),t(T,{children:i("email")}),t(T,{children:i("name")}),t(T,{children:i("role")}),t(T,{children:i("status")}),t(T,{children:i("verified")}),t(T,{children:i("created")}),t(T,{"aria-label":i("Actions")})]})}),t(De,{children:x.map(o=>h(Z,{"data-testid":`us-row-${o.id}`,children:[t(P,{className:"font-mono text-xs",children:o.id}),t(P,{children:o.email??""}),t(P,{children:o.name??""}),t(P,{children:typeof o.role=="string"&&o.role!==""?t(G,{variant:"secondary",children:o.role}):""}),t(P,{children:o.banned===!0?t(G,{variant:"destructive",children:i("Banned")}):t(G,{variant:"success",children:i("Active")})}),t(P,{children:o.emailVerified===!0?t(G,{variant:"success",children:i("yes")}):t(G,{variant:"outline",children:i("no")})}),t(P,{className:"text-muted-foreground tabular-nums",children:te(o.createdAt)}),t(P,{children:t(R,{"data-testid":`us-manage-${o.id}`,onClick:()=>{N(o.id)},size:"xs",type:"button",variant:"ghost",children:i("Manage")})})]},o.id))})]})})}),x!==null&&t(et,{count:x.length,offset:f.data?.offset??0,onOffsetChange:a,pageSize:m,prefix:"us",total:f.data?.total}),g!==null&&t(Ct,{capabilities:C,onChanged:k,onClose:()=>{N(null)},user:g}),b&&t(mt,{onClose:()=>{F(!1)},onCreated:k}),C.inviteOnly&&t(ot,{})]})};export{Ht as UsersPanel};
@@ -1 +1 @@
1
- import{c as B}from"react/compiler-runtime";import{useState as k,useRef as z,useEffect as O}from"react";import{B as P}from"../packem_shared/button-q0UYSmrn.mjs";import{C as F,a as L}from"../packem_shared/card-By2O8ULa.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as W}from"../packem_shared/input-CXhxesPC.mjs";import{b as V,e as C,c as S,a as Q,d as A,T as D}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Z}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{f as $,b as j,l as G}from"../packem_shared/internal-hIuTpSbx.mjs";import{jsxs as N,jsx as t}from"react/jsx-runtime";const J=10,_=f=>{const e=B(7),{label:i,value:l}=f;let s;e[0]!==i?(s=t("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[0]=i,e[1]=s):s=e[1];const r=l??"—";let a;e[2]!==r?(a=t("span",{className:"font-mono text-sm",children:r}),e[2]=r,e[3]=a):a=e[3];let n;return e[4]!==s||e[5]!==a?(n=N("div",{className:"flex flex-col gap-0.5",children:[s,a]}),e[4]=s,e[5]=a,e[6]=n):n=e[6],n},X=f=>{const e=B(38),{indexes:i,onSelect:l,selected:s}=f,r=M();let a;e[0]!==r?(a=r("name"),e[0]=r,e[1]=a):a=e[1];let n;e[2]!==a?(n=t(S,{children:a}),e[2]=a,e[3]=n):n=e[3];let c;e[4]!==r?(c=r("table"),e[4]=r,e[5]=c):c=e[5];let d;e[6]!==c?(d=t(S,{children:c}),e[6]=c,e[7]=d):d=e[7];let o;e[8]!==r?(o=r("dimensions"),e[8]=r,e[9]=o):o=e[9];let h;e[10]!==o?(h=t(S,{children:o}),e[10]=o,e[11]=h):h=e[11];let m;e[12]!==r?(m=r("metric"),e[12]=r,e[13]=m):m=e[13];let p;e[14]!==m?(p=t(S,{children:m}),e[14]=m,e[15]=p):p=e[15];let u;e[16]!==r?(u=r("vectors"),e[16]=r,e[17]=u):u=e[17];let x;e[18]!==u?(x=t(S,{children:u}),e[18]=u,e[19]=x):x=e[19];let w;e[20]!==x||e[21]!==n||e[22]!==d||e[23]!==h||e[24]!==p?(w=t(Q,{children:N(V,{children:[n,d,h,p,x]})}),e[20]=x,e[21]=n,e[22]=d,e[23]=h,e[24]=p,e[25]=w):w=e[25];let T;if(e[26]!==i||e[27]!==l||e[28]!==s){let q;e[30]!==l||e[31]!==s?(q=y=>N(V,{className:y.name===s?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":y.name,"data-testid":`vector-row-${y.name}`,onClick:l,children:[t(C,{className:"font-mono text-xs",children:y.name}),t(C,{className:"font-mono text-xs",children:y.table}),t(C,{className:"tabular-nums",children:y.dimensions??"—"}),t(C,{children:y.metric??"—"}),t(C,{className:"tabular-nums",children:y.vectorsCount??"—"})]},y.name),e[30]=l,e[31]=s,e[32]=q):q=e[32],T=i.map(q),e[26]=i,e[27]=l,e[28]=s,e[29]=T}else T=e[29];let b;e[33]!==T?(b=t(A,{children:T}),e[33]=T,e[34]=b):b=e[34];let v;return e[35]!==w||e[36]!==b?(v=t(F,{className:"overflow-hidden py-0",children:t(L,{className:"px-0",children:N(D,{"data-testid":"vector-table",children:[w,b]})})}),e[35]=w,e[36]=b,e[37]=v):v=e[37],v},Y=f=>{const e=B(27),{matches:i}=f,l=M();if(i.length===0){let u;e[0]!==l?(u=l("No matches."),e[0]=l,e[1]=u):u=e[1];let x;return e[2]!==u?(x=t("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:u}),e[2]=u,e[3]=x):x=e[3],x}let s;e[4]!==l?(s=l("id"),e[4]=l,e[5]=s):s=e[5];let r;e[6]!==s?(r=t(S,{children:s}),e[6]=s,e[7]=r):r=e[7];let a;e[8]!==l?(a=l("score"),e[8]=l,e[9]=a):a=e[9];let n;e[10]!==a?(n=t(S,{children:a}),e[10]=a,e[11]=n):n=e[11];let c;e[12]!==l?(c=l("metadata"),e[12]=l,e[13]=c):c=e[13];let d;e[14]!==c?(d=t(S,{children:c}),e[14]=c,e[15]=d):d=e[15];let o;e[16]!==r||e[17]!==n||e[18]!==d?(o=t(Q,{children:N(V,{children:[r,n,d]})}),e[16]=r,e[17]=n,e[18]=d,e[19]=o):o=e[19];let h;e[20]!==i?(h=i.map(ee),e[20]=i,e[21]=h):h=e[21];let m;e[22]!==h?(m=t(A,{children:h}),e[22]=h,e[23]=m):m=e[23];let p;return e[24]!==o||e[25]!==m?(p=t(F,{className:"mt-3 overflow-hidden py-0",children:t(L,{className:"px-0",children:N(D,{"data-testid":"vector-matches",children:[o,m]})})}),e[24]=o,e[25]=m,e[26]=p):p=e[26],p},ue=({loadIndexes:f,runQuery:e}={})=>{const i=Z(),l=M(),[s,r]=k(null),[a,n]=k(null),[c,d]=k(null),[o,h]=k(""),[m,p]=k(null),[u,x]=k(null),[w,T]=k(!1),b=z(0);O(()=>{const g={cancelled:!1};return $((async()=>{try{const I=await(f??(()=>i.listVectorIndexes()))();g.cancelled||(r(I),n(null),d(E=>E??I[0]?.name??null))}catch(I){g.cancelled||(r(null),n(j(I)))}})()),()=>{g.cancelled=!0}},[i,f]);const v=s?.find(g=>g.name===c)??null,q=g=>{b.current+=1,d(g.currentTarget.dataset.index??null),p(null),x(null),T(!1)},y=g=>{h(g.target.value)},H=async()=>{const g=o.trim();if(c===null||g==="")return;b.current+=1;const I=b.current;T(!0),x(null);try{const E=await(e??(R=>i.queryVectorIndex(R)))({name:c,text:g,topK:J});if(I!==b.current)return;p(E)}catch(E){if(I!==b.current)return;p(null),x(j(E))}T(!1)},K=()=>{$(H())};return N("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:a}),s!==null&&s.length===0&&t(U,{description:l("Indexes declared with .vectorize() or defineVectorIndex() 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:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:l("No vector indexes.")}),s!==null&&s.length>0&&t(X,{indexes:s,onSelect:q,selected:c}),v!==null&&N("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[N("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[t(_,{label:l("field"),value:v.field}),t(_,{label:l("dimensions"),value:v.dimensions}),t(_,{label:l("metric"),value:v.metric}),t(_,{label:l("vectors"),value:v.vectorsCount})]}),v.metadata!==void 0&&v.metadata.length>0&&N("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[l("metadata"),": ",t("span",{className:"font-mono",children:v.metadata.join(", ")})]}),N("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t(W,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:y,placeholder:l("Search by similarity…"),value:o}),t(P,{"data-testid":"vector-search",disabled:w||o.trim()==="",onClick:K,children:l(w?"Searching…":"Search")})]}),u!==null&&t("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:u}),m!==null&&t(Y,{matches:m})]})]})};function ee(f){return N(V,{"data-testid":`vector-match-${f.id}`,children:[t(C,{className:"font-mono text-xs",children:f.id}),t(C,{className:"tabular-nums",children:f.score.toFixed(4)}),t(C,{className:"max-w-md truncate font-mono text-xs",children:f.metadata===void 0?"—":G(f.metadata)})]},f.id)}export{ue as VectorBrowser};
1
+ import{c as B}from"react/compiler-runtime";import{useState as I,useRef as z,useEffect as O}from"react";import{B as P}from"../packem_shared/button-q0UYSmrn.mjs";import{C as F,a as L}from"../packem_shared/card-By2O8ULa.mjs";import{E as U}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as W}from"../packem_shared/input-CXhxesPC.mjs";import{b as V,e as C,c as S,a as Q,d as A,T as D}from"../packem_shared/table-D0SBiDu-.mjs";import{u as Z}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as M}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{f as $,b as j,k as G}from"../packem_shared/internal-BT5tH08j.mjs";import{jsxs as N,jsx as t}from"react/jsx-runtime";const J=10,_=f=>{const e=B(7),{label:i,value:l}=f;let s;e[0]!==i?(s=t("span",{className:"font-mono text-[11px] uppercase tracking-wide text-muted-foreground",children:i}),e[0]=i,e[1]=s):s=e[1];const r=l??"—";let a;e[2]!==r?(a=t("span",{className:"font-mono text-sm",children:r}),e[2]=r,e[3]=a):a=e[3];let n;return e[4]!==s||e[5]!==a?(n=N("div",{className:"flex flex-col gap-0.5",children:[s,a]}),e[4]=s,e[5]=a,e[6]=n):n=e[6],n},X=f=>{const e=B(38),{indexes:i,onSelect:l,selected:s}=f,r=M();let a;e[0]!==r?(a=r("name"),e[0]=r,e[1]=a):a=e[1];let n;e[2]!==a?(n=t(S,{children:a}),e[2]=a,e[3]=n):n=e[3];let c;e[4]!==r?(c=r("table"),e[4]=r,e[5]=c):c=e[5];let d;e[6]!==c?(d=t(S,{children:c}),e[6]=c,e[7]=d):d=e[7];let o;e[8]!==r?(o=r("dimensions"),e[8]=r,e[9]=o):o=e[9];let h;e[10]!==o?(h=t(S,{children:o}),e[10]=o,e[11]=h):h=e[11];let m;e[12]!==r?(m=r("metric"),e[12]=r,e[13]=m):m=e[13];let p;e[14]!==m?(p=t(S,{children:m}),e[14]=m,e[15]=p):p=e[15];let u;e[16]!==r?(u=r("vectors"),e[16]=r,e[17]=u):u=e[17];let x;e[18]!==u?(x=t(S,{children:u}),e[18]=u,e[19]=x):x=e[19];let w;e[20]!==x||e[21]!==n||e[22]!==d||e[23]!==h||e[24]!==p?(w=t(Q,{children:N(V,{children:[n,d,h,p,x]})}),e[20]=x,e[21]=n,e[22]=d,e[23]=h,e[24]=p,e[25]=w):w=e[25];let T;if(e[26]!==i||e[27]!==l||e[28]!==s){let q;e[30]!==l||e[31]!==s?(q=y=>N(V,{className:y.name===s?"border-l-2 border-l-royal-amethyst bg-muted/50":"cursor-pointer","data-index":y.name,"data-testid":`vector-row-${y.name}`,onClick:l,children:[t(C,{className:"font-mono text-xs",children:y.name}),t(C,{className:"font-mono text-xs",children:y.table}),t(C,{className:"tabular-nums",children:y.dimensions??"—"}),t(C,{children:y.metric??"—"}),t(C,{className:"tabular-nums",children:y.vectorsCount??"—"})]},y.name),e[30]=l,e[31]=s,e[32]=q):q=e[32],T=i.map(q),e[26]=i,e[27]=l,e[28]=s,e[29]=T}else T=e[29];let b;e[33]!==T?(b=t(A,{children:T}),e[33]=T,e[34]=b):b=e[34];let v;return e[35]!==w||e[36]!==b?(v=t(F,{className:"overflow-hidden py-0",children:t(L,{className:"px-0",children:N(D,{"data-testid":"vector-table",children:[w,b]})})}),e[35]=w,e[36]=b,e[37]=v):v=e[37],v},Y=f=>{const e=B(27),{matches:i}=f,l=M();if(i.length===0){let u;e[0]!==l?(u=l("No matches."),e[0]=l,e[1]=u):u=e[1];let x;return e[2]!==u?(x=t("p",{className:"mt-2 text-sm text-muted-foreground","data-testid":"vector-no-matches",children:u}),e[2]=u,e[3]=x):x=e[3],x}let s;e[4]!==l?(s=l("id"),e[4]=l,e[5]=s):s=e[5];let r;e[6]!==s?(r=t(S,{children:s}),e[6]=s,e[7]=r):r=e[7];let a;e[8]!==l?(a=l("score"),e[8]=l,e[9]=a):a=e[9];let n;e[10]!==a?(n=t(S,{children:a}),e[10]=a,e[11]=n):n=e[11];let c;e[12]!==l?(c=l("metadata"),e[12]=l,e[13]=c):c=e[13];let d;e[14]!==c?(d=t(S,{children:c}),e[14]=c,e[15]=d):d=e[15];let o;e[16]!==r||e[17]!==n||e[18]!==d?(o=t(Q,{children:N(V,{children:[r,n,d]})}),e[16]=r,e[17]=n,e[18]=d,e[19]=o):o=e[19];let h;e[20]!==i?(h=i.map(ee),e[20]=i,e[21]=h):h=e[21];let m;e[22]!==h?(m=t(A,{children:h}),e[22]=h,e[23]=m):m=e[23];let p;return e[24]!==o||e[25]!==m?(p=t(F,{className:"mt-3 overflow-hidden py-0",children:t(L,{className:"px-0",children:N(D,{"data-testid":"vector-matches",children:[o,m]})})}),e[24]=o,e[25]=m,e[26]=p):p=e[26],p},ue=({loadIndexes:f,runQuery:e}={})=>{const i=Z(),l=M(),[s,r]=I(null),[a,n]=I(null),[c,d]=I(null),[o,h]=I(""),[m,p]=I(null),[u,x]=I(null),[w,T]=I(!1),b=z(0);O(()=>{const g={cancelled:!1};return $((async()=>{try{const k=await(f??(()=>i.listVectorIndexes()))();g.cancelled||(r(k),n(null),d(E=>E??k[0]?.name??null))}catch(k){g.cancelled||(r(null),n(j(k)))}})()),()=>{g.cancelled=!0}},[i,f]);const v=s?.find(g=>g.name===c)??null,q=g=>{b.current+=1,d(g.currentTarget.dataset.index??null),p(null),x(null),T(!1)},y=g=>{h(g.target.value)},H=async()=>{const g=o.trim();if(c===null||g==="")return;b.current+=1;const k=b.current;T(!0),x(null);try{const E=await(e??(R=>i.queryVectorIndex(R)))({name:c,text:g,topK:J});if(k!==b.current)return;p(E)}catch(E){if(k!==b.current)return;p(null),x(j(E))}T(!1)},K=()=>{$(H())};return N("div",{className:"flex flex-col gap-4","data-testid":"lunora-vector-browser",children:[a!==null&&t("p",{className:"text-sm text-destructive","data-testid":"vector-error",role:"alert",children:a}),s!==null&&s.length===0&&t(U,{description:l("Indexes declared with .vectorize() or defineVectorIndex() 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:"M4 7l8-4 8 4-8 4-8-4Zm0 5 8 4 8-4M4 17l8 4 8-4"})}),testId:"vector-empty",title:l("No vector indexes.")}),s!==null&&s.length>0&&t(X,{indexes:s,onSelect:q,selected:c}),v!==null&&N("section",{className:"border border-border bg-card p-3","data-testid":"vector-detail",children:[N("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[t(_,{label:l("field"),value:v.field}),t(_,{label:l("dimensions"),value:v.dimensions}),t(_,{label:l("metric"),value:v.metric}),t(_,{label:l("vectors"),value:v.vectorsCount})]}),v.metadata!==void 0&&v.metadata.length>0&&N("p",{className:"mt-3 text-xs text-muted-foreground","data-testid":"vector-metadata",children:[l("metadata"),": ",t("span",{className:"font-mono",children:v.metadata.join(", ")})]}),N("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[t(W,{className:"min-w-[18rem] flex-1","data-testid":"vector-query-input",onChange:y,placeholder:l("Search by similarity…"),value:o}),t(P,{"data-testid":"vector-search",disabled:w||o.trim()==="",onClick:K,children:l(w?"Searching…":"Search")})]}),u!==null&&t("p",{className:"mt-2 text-sm text-destructive","data-testid":"vector-query-error",role:"alert",children:u}),m!==null&&t(Y,{matches:m})]})]})};function ee(f){return N(V,{"data-testid":`vector-match-${f.id}`,children:[t(C,{className:"font-mono text-xs",children:f.id}),t(C,{className:"tabular-nums",children:f.score.toFixed(4)}),t(C,{className:"max-w-md truncate font-mono text-xs",children:f.metadata===void 0?"—":G(f.metadata)})]},f.id)}export{ue as VectorBrowser};
@@ -1 +1 @@
1
- import{c as xe}from"react/compiler-runtime";import{useState as f,useRef as ce,useEffect as ge}from"react";import{B as X}from"../packem_shared/button-q0UYSmrn.mjs";import{C as te,a as re}from"../packem_shared/card-By2O8ULa.mjs";import{E as de}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ue}from"../packem_shared/input-CXhxesPC.mjs";import{T as se,a as ne,b as q,c as u,d as ae,e as m}from"../packem_shared/table-D0SBiDu-.mjs";import{T as we}from"../packem_shared/textarea--40GKAyz.mjs";import{u as ye}from"../packem_shared/use-admin-query-CaOm4JS3.mjs";import{u as fe}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{f as V,b as U,k as Ne,d as me,c as pe}from"../packem_shared/internal-hIuTpSbx.mjs";import{ConfirmButton as be}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{jsxs as i,jsx as t,Fragment as ke}from"react/jsx-runtime";const Se=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],Ie=["pause","resume","restart","terminate"],Ce=l=>{const e=xe(7),{busy:p,id:h,onAct:x}=l,y=le();let s;e[0]!==p||e[1]!==h||e[2]!==x||e[3]!==y?(s=Ie.map(d=>d==="restart"?t(be,{confirmLabel:y("Restart?"),disabled:p,onConfirm:()=>{x(d)},testId:`workflow-instance-${d}-${h}`,children:y(d)},d):t(X,{"data-testid":`workflow-instance-${d}-${h}`,disabled:p,onClick:()=>{x(d)},size:"sm",type:"button",variant:"ghost",children:y(d)},d)),e[0]=p,e[1]=h,e[2]=x,e[3]=y,e[4]=s):s=e[4];let c;return e[5]!==s?(c=t(ke,{children:s}),e[5]=s,e[6]=c):c=e[6],c},Te="WORKFLOWS_NOT_CONFIGURED",Oe=l=>typeof l=="object"&&l!==null&&l.code===Te,Ee=l=>{const e=l.error??l.output;if(e===void 0)return"—";try{return JSON.stringify(e,Ne)}catch{return"(unserializable)"}},_e=({loadDetail:l,loadInstances:e,readOnly:p,runAction:h,workflowName:x})=>{const y=fe(),s=le(),[c,d]=f(null),[w,D]=f(null),[b,j]=f(""),[k,S]=f(null),[$,C]=f(!1),[_,J]=f(null),N=ce(0),v=ce(0),g=ce(0),T=l??(n=>y.getWorkflowInstance(n)),O=p?void 0:h??(e===void 0?n=>y.setWorkflowInstanceStatus(n):void 0),E=async()=>{v.current+=1;const n=v.current;S(null),C(!1);const r=b===""?void 0:b;try{if(e===void 0){const o=await y.listWorkflowInstances({name:x,status:r});if(n!==v.current)return;if(o.configured===!1){d(null),C(!0);return}d(o.instances);return}const a=await e({name:x,status:r});n===v.current&&d(a)}catch(a){if(n!==v.current)return;d(null),Oe(a)?C(!0):S(U(a))}};ge(()=>{N.current+=1,g.current+=1,D(null),V(E())},[x,b]);const W=async n=>{g.current+=1;const r=g.current;S(null);try{const a=await T({id:n,name:x});r===g.current&&D(a)}catch(a){r===g.current&&S(U(a))}},A=()=>{g.current+=1,D(null)},L=async(n,r)=>{if(O===void 0)return;const a=N.current;J(n),S(null);try{await O({action:r,id:n,name:x}),a===N.current&&await E()}catch(o){S(U(o))}J(null)};return i("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[i("div",{className:"flex items-center justify-between gap-2",children:[t("h3",{className:"text-sm font-medium",children:s("Instance history")}),i("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n=>{j(n.target.value)},value:b,children:[t("option",{value:"",children:s("All statuses")}),Se.map(n=>t("option",{value:n,children:n},n))]})]}),k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:k}),$&&t(de,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!$&&c!==null&&c.length===0&&t(de,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),c!==null&&c.length>0&&t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflow-instances-table",children:[t(ne,{children:i(q,{children:[t(u,{children:s("Instance id")}),t(u,{children:s("Status")}),t(u,{children:s("Created")}),t(u,{children:s("Ended")}),t(u,{"aria-label":s("Actions")})]})}),t(ae,{children:c.map(n=>i(q,{"data-testid":`workflow-instance-${n.id}`,children:[t(m,{className:"font-mono text-xs",children:n.id}),t(m,{className:"font-mono text-xs",children:n.status}),t(m,{className:"text-muted-foreground tabular-nums",children:n.createdOn??"—"}),t(m,{className:"text-muted-foreground tabular-nums",children:n.endedOn??"—"}),t(m,{className:"text-right",children:i("div",{className:"flex justify-end gap-1.5",children:[t(X,{"data-testid":`workflow-instance-steps-${n.id}`,onClick:()=>{V(W(n.id))},size:"sm",type:"button",variant:"outline",children:s("Steps")}),O!==void 0&&t(Ce,{busy:_===n.id,id:n.id,onAct:r=>{V(L(n.id,r))}},x)]})})]},n.id))})]})})}),w!==null&&t(te,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:i(re,{className:"flex flex-col gap-2 px-4 py-3",children:[i("div",{className:"flex items-center justify-between",children:[i("span",{className:"font-mono text-xs",children:[s("Steps")," · ",w.id]}),t(X,{"data-testid":"workflow-instance-detail-close",onClick:A,size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),w.steps.length===0?t("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):i(se,{"data-testid":"workflow-instance-steps",children:[t(ne,{children:i(q,{children:[t(u,{children:s("Step")}),t(u,{children:s("Type")}),t(u,{children:s("Attempts")}),t(u,{children:s("Started")}),t(u,{children:s("Output")})]})}),t(ae,{children:w.steps.map((n,r)=>i(q,{"data-testid":`workflow-step-${String(r)}`,children:[t(m,{className:"font-mono text-xs",children:n.name}),t(m,{className:"text-xs text-muted-foreground",children:n.type??"—"}),t(m,{className:"tabular-nums",children:n.attempts??"—"}),t(m,{className:"text-muted-foreground tabular-nums",children:n.start??"—"}),t(m,{className:"font-mono text-xs text-muted-foreground",children:Ee(n)})]},`${n.name}:${String(r)}`))})]})]})})]})},We=pe(oe.createWorkflowInstance),Ae=pe(oe.getWorkflowInstanceStatus),Re=pe(oe.sendWorkflowEvent),$e=l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"—";try{return JSON.stringify(l.output,Ne)}catch{return"(unserializable)"}},ve=l=>{const e=l.trim();if(e==="")return{value:void 0};try{return{value:JSON.parse(e)}}catch{return null}},Fe=(l,e)=>l.some(p=>p.exportName===e)?e:l[0]?.exportName??"",Pe=l=>{const e=xe(72),{eventTypes:p,exportName:h,onSent:x}=l,y=fe(),s=le(),[c,d]=f(""),[w,D]=f(""),[b,j]=f(""),[k,S]=f(!1),[$,C]=f(null);let _;e[0]!==y||e[1]!==h||e[2]!==x||e[3]!==s||e[4]!==w?(_=async(R,ee)=>{try{await y.query(Re,{exportName:h,id:R,payload:ee,type:w},me(""))}catch(ie){C(U(ie));return}try{await x(h,R)}catch(ie){const he=ie;C(`${s("Event sent, but refreshing the instance failed")}: ${U(he)}`)}},e[0]=y,e[1]=h,e[2]=x,e[3]=s,e[4]=w,e[5]=_):_=e[5];const J=_;let N;e[6]!==J||e[7]!==c||e[8]!==b||e[9]!==s?(N=async()=>{const R=c.trim(),ee=ve(b);if(ee===null){C(s("Payload must be valid JSON"));return}S(!0),C(null),await J(R,ee.value).finally(()=>{S(!1)})},e[6]=J,e[7]=c,e[8]=b,e[9]=s,e[10]=N):N=e[10];const v=N;let g;e[11]!==s?(g=s("Send event"),e[11]=s,e[12]=g):g=e[12];let T;e[13]!==g?(T=t("h3",{className:"text-sm font-medium",children:g}),e[13]=g,e[14]=T):T=e[14];let F;e[15]!==$?(F=$!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-event-error",role:"alert",children:$}),e[15]=$,e[16]=F):F=e[16];let P;e[17]!==s?(P=s("Instance id"),e[17]=s,e[18]=P):P=e[18];let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=R=>{d(R.target.value)},e[19]=O):O=e[19];let E;e[20]!==s?(E=s("Instance id"),e[20]=s,e[21]=E):E=e[21];let W;e[22]!==c||e[23]!==P||e[24]!==E?(W=t(ue,{"aria-label":P,className:"max-w-48","data-testid":"workflows-event-id",onChange:O,placeholder:E,value:c}),e[22]=c,e[23]=P,e[24]=E,e[25]=W):W=e[25];let A;e[26]!==s?(A=s("Event type"),e[26]=s,e[27]=A):A=e[27];let L;e[28]===Symbol.for("react.memo_cache_sentinel")?(L=R=>{D(R.target.value)},e[28]=L):L=e[28];let n;e[29]!==s?(n=s("Event type"),e[29]=s,e[30]=n):n=e[30];let r;e[31]!==A||e[32]!==n||e[33]!==w?(r=t(ue,{"aria-label":A,className:"max-w-48","data-testid":"workflows-event-type",list:"workflows-event-types",onChange:L,placeholder:n,value:w}),e[31]=A,e[32]=n,e[33]=w,e[34]=r):r=e[34];let a;e[35]!==p?(a=p.map(De),e[35]=p,e[36]=a):a=e[36];let o;e[37]!==a?(o=t("datalist",{"data-testid":"workflows-event-types",id:"workflows-event-types",children:a}),e[37]=a,e[38]=o):o=e[38];let I;e[39]!==h||e[40]!==c||e[41]!==k||e[42]!==w?(I=k||h===""||c.trim()===""||w.trim()==="",e[39]=h,e[40]=c,e[41]=k,e[42]=w,e[43]=I):I=e[43];let z;e[44]!==v?(z=()=>{V(v())},e[44]=v,e[45]=z):z=e[45];let B;e[46]!==k||e[47]!==s?(B=s(k?"Sending…":"Send event"),e[46]=k,e[47]=s,e[48]=B):B=e[48];let K;e[49]!==I||e[50]!==z||e[51]!==B?(K=t(X,{"data-testid":"workflows-event-button",disabled:I,onClick:z,children:B}),e[49]=I,e[50]=z,e[51]=B,e[52]=K):K=e[52];let G;e[53]!==r||e[54]!==o||e[55]!==K||e[56]!==W?(G=i("div",{className:"flex flex-wrap items-center gap-2",children:[W,r,o,K]}),e[53]=r,e[54]=o,e[55]=K,e[56]=W,e[57]=G):G=e[57];let H;e[58]!==s?(H=s("Payload (JSON)"),e[58]=s,e[59]=H):H=e[59];let Y;e[60]===Symbol.for("react.memo_cache_sentinel")?(Y=R=>{j(R.target.value)},e[60]=Y):Y=e[60];let M;e[61]!==s?(M=s("Payload (JSON, optional)"),e[61]=s,e[62]=M):M=e[62];let Q;e[63]!==b||e[64]!==H||e[65]!==M?(Q=t(we,{"aria-label":H,className:"font-mono","data-testid":"workflows-event-payload",onChange:Y,placeholder:M,value:b}),e[63]=b,e[64]=H,e[65]=M,e[66]=Q):Q=e[66];let Z;return e[67]!==G||e[68]!==Q||e[69]!==T||e[70]!==F?(Z=i("div",{className:"flex flex-col gap-3","data-testid":"workflows-event",children:[T,F,G,Q]}),e[67]=G,e[68]=Q,e[69]=T,e[70]=F,e[71]=Z):Z=e[71],Z},Ze=()=>{const l=fe(),e=le(),{data:p,error:h}=ye(oe.listWorkflows,{}),[x,y]=f(""),[s,c]=f(""),[d,w]=f(""),[D,b]=f(!1),[j,k]=f(null),[S,$]=f([]),[C,_]=f(null),J=p!==void 0,N=Array.isArray(p?.workflows)?[...p.workflows].toSorted((r,a)=>r.exportName.localeCompare(a.exportName)):[],v=Fe(N,x),g=N.find(r=>r.exportName===v),T=r=>{$(a=>{const o=a.filter(I=>!(I.exportName===r.exportName&&I.id===r.id));return[r,...o]})},F=async()=>{const r=v;if(r==="")return;const a=ve(d);if(a===null){k(e("Params must be valid JSON"));return}b(!0),k(null);try{const o=s.trim(),I=await l.query(We,{exportName:r,id:o===""?void 0:o,params:a.value},me(""));T({exportName:r,id:I.id,status:I.status}),c("")}catch(o){k(U(o))}b(!1)},P=()=>{V(F())},O=async(r,a)=>{_(a);try{const o=await l.query(Ae,{exportName:r,id:a},me(""));T({error:o.error,exportName:r,id:o.id,output:o.output,status:o.status})}catch(o){throw _(null),o}_(null)},E=async(r,a)=>{try{await O(r,a)}catch(o){k(U(o))}},W=r=>{y(r.target.value)},A=r=>{c(r.target.value)},L=r=>{w(r.target.value)},n=r=>{const{export:a,id:o}=r.currentTarget.dataset;a!==void 0&&o!==void 0&&V(E(a,o))};return i("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[h!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:h}),t("p",{className:"text-sm text-muted-foreground",children:e("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),J&&N.length===0?t(de,{description:e("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:e("No workflows defined")}):t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflows-table",children:[t(ne,{children:i(q,{children:[t(u,{children:e("Export")}),t(u,{children:e("Name")}),t(u,{children:e("Class")})]})}),t(ae,{children:N.map(r=>i(q,{"data-testid":`workflows-row-${r.exportName}`,children:[t(m,{className:"font-mono text-xs",children:r.exportName}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.name}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.className})]},r.exportName))})]})})}),N.length>0&&i("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[t("h3",{className:"text-sm font-medium",children:e("Start instance")}),j!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:j}),i("div",{className:"flex flex-wrap items-center gap-2",children:[t("select",{"aria-label":e("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:W,value:v,children:N.map(r=>t("option",{value:r.exportName,children:r.exportName},r.exportName))}),t(ue,{"aria-label":e("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:A,placeholder:e("Instance id (optional)"),value:s}),t(X,{"data-testid":"workflows-start-button",disabled:D||v==="",onClick:P,children:e(D?"Starting…":"Start instance")})]}),t(we,{"aria-label":e("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:L,placeholder:e("Params (JSON, optional)"),value:d})]}),N.length>0&&t(Pe,{eventTypes:p?.eventTypes??[],exportName:v,onSent:O},v),S.length>0&&i("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[t("h3",{className:"text-sm font-medium",children:e("Instances")}),t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflows-instances-table",children:[t(ne,{children:i(q,{children:[t(u,{children:e("Workflow")}),t(u,{children:e("Instance id")}),t(u,{children:e("Status")}),t(u,{children:e("Output")}),t(u,{})]})}),t(ae,{children:S.map(r=>i(q,{"data-testid":`workflows-instance-${r.id}`,children:[t(m,{className:"font-mono text-xs",children:r.exportName}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.id}),t(m,{className:"font-mono text-xs",children:r.status}),t(m,{className:"font-mono text-xs text-muted-foreground",children:$e(r)}),t(m,{children:t(X,{"data-export":r.exportName,"data-id":r.id,"data-testid":`workflows-instance-refresh-${r.id}`,disabled:C===r.id,onClick:n,size:"xs",variant:"outline",children:C===r.id?e("Refreshing…"):e("Refresh")})})]},`${r.exportName}:${r.id}`))})]})})})]}),g!==void 0&&t(_e,{workflowName:g.name})]})};function De(l){return t("option",{value:l,children:l},l)}export{Ze as default};
1
+ import{c as xe}from"react/compiler-runtime";import{useState as f,useRef as ce,useEffect as ge}from"react";import{B as X}from"../packem_shared/button-q0UYSmrn.mjs";import{C as te,a as re}from"../packem_shared/card-By2O8ULa.mjs";import{E as de}from"../packem_shared/empty-state-D7jEML_T.mjs";import{I as ue}from"../packem_shared/input-CXhxesPC.mjs";import{T as se,a as ne,b as q,c as u,d as ae,e as m}from"../packem_shared/table-D0SBiDu-.mjs";import{T as we}from"../packem_shared/textarea--40GKAyz.mjs";import{u as ye}from"../packem_shared/use-admin-query-DMnTt_hg.mjs";import{u as fe}from"../packem_shared/use-studio-client-DCA50tF2.mjs";import{useT as le}from"../packem_shared/DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as oe}from"../packem_shared/ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{f as V,b as j,j as Ne,g as me,d as pe}from"../packem_shared/internal-BT5tH08j.mjs";import{ConfirmButton as be}from"../packem_shared/ConfirmButton-CIXYF6Mg.mjs";import{jsxs as i,jsx as t,Fragment as ke}from"react/jsx-runtime";const Se=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],Ie=["pause","resume","restart","terminate"],Ce=l=>{const e=xe(7),{busy:p,id:h,onAct:x}=l,y=le();let s;e[0]!==p||e[1]!==h||e[2]!==x||e[3]!==y?(s=Ie.map(d=>d==="restart"?t(be,{confirmLabel:y("Restart?"),disabled:p,onConfirm:()=>{x(d)},testId:`workflow-instance-${d}-${h}`,children:y(d)},d):t(X,{"data-testid":`workflow-instance-${d}-${h}`,disabled:p,onClick:()=>{x(d)},size:"sm",type:"button",variant:"ghost",children:y(d)},d)),e[0]=p,e[1]=h,e[2]=x,e[3]=y,e[4]=s):s=e[4];let c;return e[5]!==s?(c=t(ke,{children:s}),e[5]=s,e[6]=c):c=e[6],c},Te="WORKFLOWS_NOT_CONFIGURED",Oe=l=>typeof l=="object"&&l!==null&&l.code===Te,Ee=l=>{const e=l.error??l.output;if(e===void 0)return"—";try{return JSON.stringify(e,Ne)}catch{return"(unserializable)"}},_e=({loadDetail:l,loadInstances:e,readOnly:p,runAction:h,workflowName:x})=>{const y=fe(),s=le(),[c,d]=f(null),[w,D]=f(null),[b,U]=f(""),[k,S]=f(null),[$,C]=f(!1),[_,J]=f(null),N=ce(0),v=ce(0),g=ce(0),T=l??(n=>y.getWorkflowInstance(n)),O=p?void 0:h??(e===void 0?n=>y.setWorkflowInstanceStatus(n):void 0),E=async()=>{v.current+=1;const n=v.current;S(null),C(!1);const r=b===""?void 0:b;try{if(e===void 0){const o=await y.listWorkflowInstances({name:x,status:r});if(n!==v.current)return;if(o.configured===!1){d(null),C(!0);return}d(o.instances);return}const a=await e({name:x,status:r});n===v.current&&d(a)}catch(a){if(n!==v.current)return;d(null),Oe(a)?C(!0):S(j(a))}};ge(()=>{N.current+=1,g.current+=1,D(null),V(E())},[x,b]);const W=async n=>{g.current+=1;const r=g.current;S(null);try{const a=await T({id:n,name:x});r===g.current&&D(a)}catch(a){r===g.current&&S(j(a))}},A=()=>{g.current+=1,D(null)},L=async(n,r)=>{if(O===void 0)return;const a=N.current;J(n),S(null);try{await O({action:r,id:n,name:x}),a===N.current&&await E()}catch(o){S(j(o))}J(null)};return i("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[i("div",{className:"flex items-center justify-between gap-2",children:[t("h3",{className:"text-sm font-medium",children:s("Instance history")}),i("select",{"aria-label":s("Filter by status"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflow-instances-filter",onChange:n=>{U(n.target.value)},value:b,children:[t("option",{value:"",children:s("All statuses")}),Se.map(n=>t("option",{value:n,children:n},n))]})]}),k!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:k}),$&&t(de,{description:s("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:s("Workflow inspection not configured")}),!$&&c!==null&&c.length===0&&t(de,{description:s("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:s("No instances")}),c!==null&&c.length>0&&t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflow-instances-table",children:[t(ne,{children:i(q,{children:[t(u,{children:s("Instance id")}),t(u,{children:s("Status")}),t(u,{children:s("Created")}),t(u,{children:s("Ended")}),t(u,{"aria-label":s("Actions")})]})}),t(ae,{children:c.map(n=>i(q,{"data-testid":`workflow-instance-${n.id}`,children:[t(m,{className:"font-mono text-xs",children:n.id}),t(m,{className:"font-mono text-xs",children:n.status}),t(m,{className:"text-muted-foreground tabular-nums",children:n.createdOn??"—"}),t(m,{className:"text-muted-foreground tabular-nums",children:n.endedOn??"—"}),t(m,{className:"text-right",children:i("div",{className:"flex justify-end gap-1.5",children:[t(X,{"data-testid":`workflow-instance-steps-${n.id}`,onClick:()=>{V(W(n.id))},size:"sm",type:"button",variant:"outline",children:s("Steps")}),O!==void 0&&t(Ce,{busy:_===n.id,id:n.id,onAct:r=>{V(L(n.id,r))}},x)]})})]},n.id))})]})})}),w!==null&&t(te,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:i(re,{className:"flex flex-col gap-2 px-4 py-3",children:[i("div",{className:"flex items-center justify-between",children:[i("span",{className:"font-mono text-xs",children:[s("Steps")," · ",w.id]}),t(X,{"data-testid":"workflow-instance-detail-close",onClick:A,size:"xs",type:"button",variant:"ghost",children:s("Close")})]}),w.steps.length===0?t("p",{className:"text-xs text-muted-foreground",children:s("This instance has no recorded steps yet.")}):i(se,{"data-testid":"workflow-instance-steps",children:[t(ne,{children:i(q,{children:[t(u,{children:s("Step")}),t(u,{children:s("Type")}),t(u,{children:s("Attempts")}),t(u,{children:s("Started")}),t(u,{children:s("Output")})]})}),t(ae,{children:w.steps.map((n,r)=>i(q,{"data-testid":`workflow-step-${String(r)}`,children:[t(m,{className:"font-mono text-xs",children:n.name}),t(m,{className:"text-xs text-muted-foreground",children:n.type??"—"}),t(m,{className:"tabular-nums",children:n.attempts??"—"}),t(m,{className:"text-muted-foreground tabular-nums",children:n.start??"—"}),t(m,{className:"font-mono text-xs text-muted-foreground",children:Ee(n)})]},`${n.name}:${String(r)}`))})]})]})})]})},We=pe(oe.createWorkflowInstance),Ae=pe(oe.getWorkflowInstanceStatus),Re=pe(oe.sendWorkflowEvent),$e=l=>{if(l.error)return`${l.error.name}: ${l.error.message}`;if(l.output===void 0)return"—";try{return JSON.stringify(l.output,Ne)}catch{return"(unserializable)"}},ve=l=>{const e=l.trim();if(e==="")return{value:void 0};try{return{value:JSON.parse(e)}}catch{return null}},Fe=(l,e)=>l.some(p=>p.exportName===e)?e:l[0]?.exportName??"",Pe=l=>{const e=xe(72),{eventTypes:p,exportName:h,onSent:x}=l,y=fe(),s=le(),[c,d]=f(""),[w,D]=f(""),[b,U]=f(""),[k,S]=f(!1),[$,C]=f(null);let _;e[0]!==y||e[1]!==h||e[2]!==x||e[3]!==s||e[4]!==w?(_=async(R,ee)=>{try{await y.query(Re,{exportName:h,id:R,payload:ee,type:w},me(""))}catch(ie){C(j(ie));return}try{await x(h,R)}catch(ie){const he=ie;C(`${s("Event sent, but refreshing the instance failed")}: ${j(he)}`)}},e[0]=y,e[1]=h,e[2]=x,e[3]=s,e[4]=w,e[5]=_):_=e[5];const J=_;let N;e[6]!==J||e[7]!==c||e[8]!==b||e[9]!==s?(N=async()=>{const R=c.trim(),ee=ve(b);if(ee===null){C(s("Payload must be valid JSON"));return}S(!0),C(null),await J(R,ee.value).finally(()=>{S(!1)})},e[6]=J,e[7]=c,e[8]=b,e[9]=s,e[10]=N):N=e[10];const v=N;let g;e[11]!==s?(g=s("Send event"),e[11]=s,e[12]=g):g=e[12];let T;e[13]!==g?(T=t("h3",{className:"text-sm font-medium",children:g}),e[13]=g,e[14]=T):T=e[14];let F;e[15]!==$?(F=$!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-event-error",role:"alert",children:$}),e[15]=$,e[16]=F):F=e[16];let P;e[17]!==s?(P=s("Instance id"),e[17]=s,e[18]=P):P=e[18];let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=R=>{d(R.target.value)},e[19]=O):O=e[19];let E;e[20]!==s?(E=s("Instance id"),e[20]=s,e[21]=E):E=e[21];let W;e[22]!==c||e[23]!==P||e[24]!==E?(W=t(ue,{"aria-label":P,className:"max-w-48","data-testid":"workflows-event-id",onChange:O,placeholder:E,value:c}),e[22]=c,e[23]=P,e[24]=E,e[25]=W):W=e[25];let A;e[26]!==s?(A=s("Event type"),e[26]=s,e[27]=A):A=e[27];let L;e[28]===Symbol.for("react.memo_cache_sentinel")?(L=R=>{D(R.target.value)},e[28]=L):L=e[28];let n;e[29]!==s?(n=s("Event type"),e[29]=s,e[30]=n):n=e[30];let r;e[31]!==A||e[32]!==n||e[33]!==w?(r=t(ue,{"aria-label":A,className:"max-w-48","data-testid":"workflows-event-type",list:"workflows-event-types",onChange:L,placeholder:n,value:w}),e[31]=A,e[32]=n,e[33]=w,e[34]=r):r=e[34];let a;e[35]!==p?(a=p.map(De),e[35]=p,e[36]=a):a=e[36];let o;e[37]!==a?(o=t("datalist",{"data-testid":"workflows-event-types",id:"workflows-event-types",children:a}),e[37]=a,e[38]=o):o=e[38];let I;e[39]!==h||e[40]!==c||e[41]!==k||e[42]!==w?(I=k||h===""||c.trim()===""||w.trim()==="",e[39]=h,e[40]=c,e[41]=k,e[42]=w,e[43]=I):I=e[43];let z;e[44]!==v?(z=()=>{V(v())},e[44]=v,e[45]=z):z=e[45];let B;e[46]!==k||e[47]!==s?(B=s(k?"Sending…":"Send event"),e[46]=k,e[47]=s,e[48]=B):B=e[48];let K;e[49]!==I||e[50]!==z||e[51]!==B?(K=t(X,{"data-testid":"workflows-event-button",disabled:I,onClick:z,children:B}),e[49]=I,e[50]=z,e[51]=B,e[52]=K):K=e[52];let G;e[53]!==r||e[54]!==o||e[55]!==K||e[56]!==W?(G=i("div",{className:"flex flex-wrap items-center gap-2",children:[W,r,o,K]}),e[53]=r,e[54]=o,e[55]=K,e[56]=W,e[57]=G):G=e[57];let H;e[58]!==s?(H=s("Payload (JSON)"),e[58]=s,e[59]=H):H=e[59];let Y;e[60]===Symbol.for("react.memo_cache_sentinel")?(Y=R=>{U(R.target.value)},e[60]=Y):Y=e[60];let M;e[61]!==s?(M=s("Payload (JSON, optional)"),e[61]=s,e[62]=M):M=e[62];let Q;e[63]!==b||e[64]!==H||e[65]!==M?(Q=t(we,{"aria-label":H,className:"font-mono","data-testid":"workflows-event-payload",onChange:Y,placeholder:M,value:b}),e[63]=b,e[64]=H,e[65]=M,e[66]=Q):Q=e[66];let Z;return e[67]!==G||e[68]!==Q||e[69]!==T||e[70]!==F?(Z=i("div",{className:"flex flex-col gap-3","data-testid":"workflows-event",children:[T,F,G,Q]}),e[67]=G,e[68]=Q,e[69]=T,e[70]=F,e[71]=Z):Z=e[71],Z},Ze=()=>{const l=fe(),e=le(),{data:p,error:h}=ye(oe.listWorkflows,{}),[x,y]=f(""),[s,c]=f(""),[d,w]=f(""),[D,b]=f(!1),[U,k]=f(null),[S,$]=f([]),[C,_]=f(null),J=p!==void 0,N=Array.isArray(p?.workflows)?[...p.workflows].toSorted((r,a)=>r.exportName.localeCompare(a.exportName)):[],v=Fe(N,x),g=N.find(r=>r.exportName===v),T=r=>{$(a=>{const o=a.filter(I=>!(I.exportName===r.exportName&&I.id===r.id));return[r,...o]})},F=async()=>{const r=v;if(r==="")return;const a=ve(d);if(a===null){k(e("Params must be valid JSON"));return}b(!0),k(null);try{const o=s.trim(),I=await l.query(We,{exportName:r,id:o===""?void 0:o,params:a.value},me(""));T({exportName:r,id:I.id,status:I.status}),c("")}catch(o){k(j(o))}b(!1)},P=()=>{V(F())},O=async(r,a)=>{_(a);try{const o=await l.query(Ae,{exportName:r,id:a},me(""));T({error:o.error,exportName:r,id:o.id,output:o.output,status:o.status})}catch(o){throw _(null),o}_(null)},E=async(r,a)=>{try{await O(r,a)}catch(o){k(j(o))}},W=r=>{y(r.target.value)},A=r=>{c(r.target.value)},L=r=>{w(r.target.value)},n=r=>{const{export:a,id:o}=r.currentTarget.dataset;a!==void 0&&o!==void 0&&V(E(a,o))};return i("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[h!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:h}),t("p",{className:"text-sm text-muted-foreground",children:e("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),J&&N.length===0?t(de,{description:e("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:e("No workflows defined")}):t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflows-table",children:[t(ne,{children:i(q,{children:[t(u,{children:e("Export")}),t(u,{children:e("Name")}),t(u,{children:e("Class")})]})}),t(ae,{children:N.map(r=>i(q,{"data-testid":`workflows-row-${r.exportName}`,children:[t(m,{className:"font-mono text-xs",children:r.exportName}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.name}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.className})]},r.exportName))})]})})}),N.length>0&&i("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[t("h3",{className:"text-sm font-medium",children:e("Start instance")}),U!==null&&t("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:U}),i("div",{className:"flex flex-wrap items-center gap-2",children:[t("select",{"aria-label":e("Workflow"),className:"h-8 rounded-md border border-input bg-transparent px-2.5 py-1 text-xs outline-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50","data-testid":"workflows-start-select",onChange:W,value:v,children:N.map(r=>t("option",{value:r.exportName,children:r.exportName},r.exportName))}),t(ue,{"aria-label":e("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:A,placeholder:e("Instance id (optional)"),value:s}),t(X,{"data-testid":"workflows-start-button",disabled:D||v==="",onClick:P,children:e(D?"Starting…":"Start instance")})]}),t(we,{"aria-label":e("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:L,placeholder:e("Params (JSON, optional)"),value:d})]}),N.length>0&&t(Pe,{eventTypes:p?.eventTypes??[],exportName:v,onSent:O},v),S.length>0&&i("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[t("h3",{className:"text-sm font-medium",children:e("Instances")}),t(te,{className:"overflow-hidden py-0",children:t(re,{className:"px-0",children:i(se,{"data-testid":"workflows-instances-table",children:[t(ne,{children:i(q,{children:[t(u,{children:e("Workflow")}),t(u,{children:e("Instance id")}),t(u,{children:e("Status")}),t(u,{children:e("Output")}),t(u,{})]})}),t(ae,{children:S.map(r=>i(q,{"data-testid":`workflows-instance-${r.id}`,children:[t(m,{className:"font-mono text-xs",children:r.exportName}),t(m,{className:"font-mono text-xs text-muted-foreground",children:r.id}),t(m,{className:"font-mono text-xs",children:r.status}),t(m,{className:"font-mono text-xs text-muted-foreground",children:$e(r)}),t(m,{children:t(X,{"data-export":r.exportName,"data-id":r.id,"data-testid":`workflows-instance-refresh-${r.id}`,disabled:C===r.id,onClick:n,size:"xs",variant:"outline",children:C===r.id?e("Refreshing…"):e("Refresh")})})]},`${r.exportName}:${r.id}`))})]})})})]}),g!==void 0&&t(_e,{workflowName:g.name})]})};function De(l){return t("option",{value:l,children:l},l)}export{Ze as default};
@@ -0,0 +1,2 @@
1
+ import{c as F}from"react/compiler-runtime";import{useState as z,useEffect as V}from"react";import{B as H}from"./button-q0UYSmrn.mjs";import{E as K}from"./empty-state-D7jEML_T.mjs";import{u as W}from"./use-studio-client-DCA50tF2.mjs";import{useT as M}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{ADMIN_FUNCTIONS as X}from"./ADMIN_FUNCTIONS-DAHZ35kM.mjs";import{d as Z,g as ee,l as te}from"./internal-BT5tH08j.mjs";import{jsxs as R,jsx as u}from"react/jsx-runtime";const le={action:"action",mutation:"mutation",query:"query"},Q=n=>{const e=n.indexOf(":");return e===-1?{file:"",fn:n}:{file:n.slice(0,e),fn:n.slice(e+1)}},ie=({file:n,fn:e,kind:a})=>`await client.${le[a]}(api.${n}.${e}, { /* args */ });`,ne=n=>{const e=`api.${n.file}.${n.fn}`;switch(n.kind){case"action":return`const { call: ${n.fn} } = useAction(${e});`;case"mutation":return`const ${n.fn} = useMutation(${e});`;default:return`const data = useQuery(${e}, { /* args */ });`}},ae=({file:n,fn:e})=>`lunora run ${n}:${e} --args '{ }'`,se=n=>["// Read rows",`const rows = await ctx.db.query("${n}").collect();`,"","// Insert a row",`const id = await ctx.db.insert("${n}", { /* fields */ });`,"","// Generated types",`type Row = Doc<"${n}">;`,`type RowId = Id<"${n}">;`].join(`
2
+ `),oe=Z(X.listTables),ce=["react","client","cli"],re=(n,e)=>{switch(n){case"cli":return ae(e);case"client":return ie(e);default:return ne(e)}},U=n=>{const e=F(19),{code:a,label:s,testId:l}=n,i=M();let c;e[0]!==a?(c=()=>{te(a)},e[0]=a,e[1]=c):c=e[1];const m=c;let t;e[2]!==s?(t=u("span",{className:"text-xs font-medium text-muted-foreground",children:s}),e[2]=s,e[3]=t):t=e[3];const d=`${l}-copy`;let o;e[4]!==i?(o=i("Copy"),e[4]=i,e[5]=o):o=e[5];let f;e[6]!==m||e[7]!==d||e[8]!==o?(f=u(H,{"data-testid":d,onClick:m,size:"xs",type:"button",variant:"ghost",children:o}),e[6]=m,e[7]=d,e[8]=o,e[9]=f):f=e[9];let p;e[10]!==t||e[11]!==f?(p=R("div",{className:"flex items-center justify-between gap-2",children:[t,f]}),e[10]=t,e[11]=f,e[12]=p):p=e[12];let r;e[13]!==a||e[14]!==l?(r=u("pre",{className:"overflow-auto rounded-md border border-border bg-muted/50 p-3 font-mono text-xs","data-testid":l,children:a}),e[13]=a,e[14]=l,e[15]=r):r=e[15];let b;return e[16]!==p||e[17]!==r?(b=R("div",{className:"flex flex-col gap-1.5",children:[p,r]}),e[16]=p,e[17]=r,e[18]=b):b=e[18],b},de=n=>{const e=F(46),{file:a,fn:s,kind:l}=n,i=M(),[c,m]=z("react");let t,d,o;if(e[0]!==a||e[1]!==s||e[2]!==l||e[3]!==i||e[4]!==c){const x={file:a,fn:s,kind:l};let k;e[8]!==i?(k=i("CLI"),e[8]=i,e[9]=k):k=e[9];let w;e[10]!==i?(w=i("Client"),e[10]=i,e[11]=w):w=e[11];let I;e[12]!==i?(I=i("React"),e[12]=i,e[13]=I):I=e[13];let C;e[14]!==k||e[15]!==w||e[16]!==I?(C={cli:k,client:w,react:I},e[14]=k,e[15]=w,e[16]=I,e[17]=C):C=e[17],o=C;let B;e[18]===Symbol.for("react.memo_cache_sentinel")?(B=D=>{m(D.currentTarget.dataset.tab)},e[18]=B):B=e[18],t=B,d=re(c,x),e[0]=a,e[1]=s,e[2]=l,e[3]=i,e[4]=c,e[5]=t,e[6]=d,e[7]=o}else t=e[5],d=e[6],o=e[7];const f=d,p=`api.${a}.${s}`;let r;e[19]!==p?(r=u("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-fn-title",children:p}),e[19]=p,e[20]=r):r=e[20];let b;e[21]!==l||e[22]!==i?(b=i("Call this {kind} from your app.",{kind:l}),e[21]=l,e[22]=i,e[23]=b):b=e[23];let h;e[24]!==b?(h=u("p",{className:"text-xs text-muted-foreground",children:b}),e[24]=b,e[25]=h):h=e[25];let v;e[26]!==r||e[27]!==h?(v=R("div",{children:[r,h]}),e[26]=r,e[27]=h,e[28]=v):v=e[28];let $;e[29]!==i?($=i("Snippet flavour"),e[29]=i,e[30]=$):$=e[30];let y;e[31]!==t||e[32]!==c||e[33]!==o?(y=ce.map(x=>u(H,{"aria-selected":c===x,"data-tab":x,"data-testid":`api-tab-${x}`,onClick:t,role:"tab",size:"xs",type:"button",variant:c===x?"default":"outline",children:o[x]},x)),e[31]=t,e[32]=c,e[33]=o,e[34]=y):y=e[34];let N;e[35]!==$||e[36]!==y?(N=u("div",{"aria-label":$,className:"flex gap-1.5","data-testid":"api-tabs",role:"tablist",children:y}),e[35]=$,e[36]=y,e[37]=N):N=e[37];const _=o[c],A=`api-snippet-${c}`;let S;e[38]!==f||e[39]!==_||e[40]!==A?(S=u(U,{code:f,label:_,testId:A}),e[38]=f,e[39]=_,e[40]=A,e[41]=S):S=e[41];let T;return e[42]!==S||e[43]!==v||e[44]!==N?(T=R("div",{className:"flex flex-col gap-3","data-testid":"api-fn-doc",children:[v,N,S]}),e[42]=S,e[43]=v,e[44]=N,e[45]=T):T=e[45],T},fe=n=>{const e=F(19),{name:a}=n,s=M();let l;e[0]!==a?(l=se(a),e[0]=a,e[1]=l):l=e[1];const i=l;let c;e[2]!==a?(c=u("h2",{className:"font-mono text-sm font-semibold text-foreground","data-testid":"api-table-title",children:a}),e[2]=a,e[3]=c):c=e[3];let m;e[4]!==s?(m=s("Read and write this table through the typed data model."),e[4]=s,e[5]=m):m=e[5];let t;e[6]!==m?(t=u("p",{className:"text-xs text-muted-foreground",children:m}),e[6]=m,e[7]=t):t=e[7];let d;e[8]!==c||e[9]!==t?(d=R("div",{children:[c,t]}),e[8]=c,e[9]=t,e[10]=d):d=e[10];let o;e[11]!==s?(o=s("Data model"),e[11]=s,e[12]=o):o=e[12];let f;e[13]!==i||e[14]!==o?(f=u(U,{code:i,label:o,testId:"api-snippet-table"}),e[13]=i,e[14]=o,e[15]=f):f=e[15];let p;return e[16]!==d||e[17]!==f?(p=R("div",{className:"flex flex-col gap-3","data-testid":"api-table-doc",children:[d,f]}),e[16]=d,e[17]=f,e[18]=p):p=e[18],p},G=n=>{const e=F(8),{active:a,label:s,onSelect:l,testId:i,value:c}=n;let m;e[0]!==l||e[1]!==c?(m=()=>{l(c)},e[0]=l,e[1]=c,e[2]=m):m=e[2];const t=m,d=a?"page":void 0;let o;return e[3]!==s||e[4]!==t||e[5]!==d||e[6]!==i?(o=u("button",{"aria-current":d,className:"w-full truncate rounded-md px-2 py-1 text-start font-mono text-xs text-muted-foreground outline-none transition-colors hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:bg-sidebar-accent aria-[current=page]:bg-sidebar-accent aria-[current=page]:font-medium aria-[current=page]:text-foreground","data-testid":i,onClick:t,type:"button",children:s}),e[3]=s,e[4]=t,e[5]=d,e[6]=i,e[7]=o):o=e[7],o},pe=n=>{const e=new Map;for(const a of n){const{file:s,fn:l}=Q(a.path),i=e.get(s)??[];i.push({fn:l,kind:a.kind,path:a.path}),e.set(s,i)}return[...e.entries()].map(([a,s])=>({file:a,items:s.toSorted((l,i)=>l.fn.localeCompare(i.fn))})).toSorted((a,s)=>a.file.localeCompare(s.file))},ke=n=>{const e=F(58),{functions:a,initialShardKey:s}=n,l=M(),i=W(),[c,m]=z(null),[t,d]=z(null);let o,f;e[0]!==i||e[1]!==s?(o=()=>{let D=!1;return i.query(oe,{},ee(s??"")).then(L=>(D||m(L),L)).catch(()=>{D||m([])}),()=>{D=!0}},f=[i,s],e[0]=i,e[1]=s,e[2]=o,e[3]=f):(o=e[2],f=e[3]),V(o,f);let p,r,b,h,v,$,y,N,_,A;if(e[4]!==a||e[5]!==t||e[6]!==l||e[7]!==c){const D=a??[],L=pe(D),O=(c??[]).map(ue).toSorted(me);let P;e[18]===Symbol.for("react.memo_cache_sentinel")?(P=g=>{d({kind:"fn",path:g})},e[18]=P):P=e[18];const Y=P;let j;e[19]===Symbol.for("react.memo_cache_sentinel")?(j=g=>{d({kind:"table",name:g})},e[19]=j):j=e[19];const J=j;r=t?.kind==="fn"?D.find(g=>g.path===t.path):void 0,p=D.length>0||O.length>0,b=r===void 0?void 0:Q(r.path),_="grid min-h-0 gap-6 md:grid-cols-[16rem_minmax(0,1fr)]",A="lunora-api-docs",e[20]!==l?(h=l("API resources"),e[20]=l,e[21]=h):h=e[21],v="flex flex-col gap-4 overflow-y-auto",$="api-rail";let q;e[22]!==t||e[23]!==l?(q=g=>R("div",{className:"flex flex-col gap-1",children:[u("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:g.file||l("(root)")}),g.items.map(E=>u(G,{active:t?.kind==="fn"&&t.path===E.path,label:E.fn,onSelect:Y,testId:`api-rail-fn-${E.path}`,value:E.path},E.path))]},g.file),e[22]=t,e[23]=l,e[24]=q):q=e[24],y=L.map(q),N=O.length>0&&R("div",{className:"flex flex-col gap-1",children:[u("span",{className:"px-2 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:l("Tables")}),O.map(g=>u(G,{active:t?.kind==="table"&&t.name===g,label:g,onSelect:J,testId:`api-rail-table-${g}`,value:g},g))]}),e[4]=a,e[5]=t,e[6]=l,e[7]=c,e[8]=p,e[9]=r,e[10]=b,e[11]=h,e[12]=v,e[13]=$,e[14]=y,e[15]=N,e[16]=_,e[17]=A}else p=e[8],r=e[9],b=e[10],h=e[11],v=e[12],$=e[13],y=e[14],N=e[15],_=e[16],A=e[17];let S;e[25]!==p||e[26]!==l?(S=!p&&u("p",{className:"px-2 text-xs text-muted-foreground","data-testid":"api-rail-empty",children:l("No functions or tables to document yet.")}),e[25]=p,e[26]=l,e[27]=S):S=e[27];let T;e[28]!==S||e[29]!==h||e[30]!==v||e[31]!==$||e[32]!==y||e[33]!==N?(T=R("nav",{"aria-label":h,className:v,"data-testid":$,children:[y,N,S]}),e[28]=S,e[29]=h,e[30]=v,e[31]=$,e[32]=y,e[33]=N,e[34]=T):T=e[34];let x;e[35]!==t||e[36]!==l?(x=t===null&&u(K,{description:l("Select a function or table to see how to call it from your app."),testId:"api-empty",title:l("API usage snippets")}),e[35]=t,e[36]=l,e[37]=x):x=e[37];let k;e[38]!==t?.kind||e[39]!==r||e[40]!==b?(k=t?.kind==="fn"&&r!==void 0&&b!==void 0&&u(de,{file:b.file,fn:b.fn,kind:r.kind},r.path),e[38]=t?.kind,e[39]=r,e[40]=b,e[41]=k):k=e[41];let w;e[42]!==t?.kind||e[43]!==r||e[44]!==l?(w=t?.kind==="fn"&&r===void 0&&u(K,{testId:"api-empty",title:l("API usage snippets")}),e[42]=t?.kind,e[43]=r,e[44]=l,e[45]=w):w=e[45];let I;e[46]!==t?(I=t?.kind==="table"&&u(fe,{name:t.name}),e[46]=t,e[47]=I):I=e[47];let C;e[48]!==x||e[49]!==k||e[50]!==w||e[51]!==I?(C=R("div",{className:"min-w-0",children:[x,k,w,I]}),e[48]=x,e[49]=k,e[50]=w,e[51]=I,e[52]=C):C=e[52];let B;return e[53]!==T||e[54]!==C||e[55]!==_||e[56]!==A?(B=R("div",{className:_,"data-testid":A,children:[T,C]}),e[53]=T,e[54]=C,e[55]=_,e[56]=A,e[57]=B):B=e[57],B};function ue(n){return n.name}function me(n,e){return n.localeCompare(e)}export{ke as default};
@@ -1 +1 @@
1
- import{c as k}from"react/compiler-runtime";import{E as h}from"./empty-state-D7jEML_T.mjs";import{S as g}from"./skeleton-DX1gfixl.mjs";import{u as v}from"./use-admin-spec-CK7mk3Ui.mjs";import{u as O}from"./use-studio-client-DCA50tF2.mjs";import{useT as S}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{R as A}from"./reference-view-DENugPcj.mjs";import{jsxs as I,jsx as m}from"react/jsx-runtime";const P=["get","post","put","patch","delete","head","options","trace"],y=r=>r?.content?.["application/json"]?.schema,j=(r,e)=>Object.entries(r.responses??{}).map(([i,s])=>{const c=s.$ref?.replace("#/components/responses/",""),n=c===void 0?s:e.components?.responses?.[c]??s;return{description:n.description,schema:y(n),status:i}}),b=(r,e,i,s,c)=>{const n=y(s.requestBody),l=n?.properties?.functionPath?.const,t=typeof l=="string"?l:void 0,f=t===void 0?n:n?.properties?.args,a=s.operationId??`${i} ${e}`;return{argsSchema:f,description:s.description,functionPath:t,httpPath:e,key:r,kind:s["x-lunora-function-kind"],method:i.toUpperCase(),operationId:a,requestSchema:n,responses:j(s,c),summary:s.summary??a,tags:s.tags??[],title:s.summary??a}},x=r=>{const e=[];for(const[i,s]of Object.entries(r.paths??{})){const c=i.includes("#")?i.slice(0,i.indexOf("#")):i;for(const n of P){const l=s[n];l!==void 0&&e.push(b(i,c,n,l,r))}}return e},w=r=>{const e=r??{},i=x(e),s=new Map((e.tags??[]).map(t=>[t.name,t.description])),c=new Set,n=[],l=t=>{if(c.has(t))return;c.add(t);const f=i.filter(a=>(a.tags[0]??"")===t);f.length>0&&n.push({description:s.get(t),name:t,operations:f})};for(const t of e.tags??[])l(t.name);for(const t of i)l(t.tags[0]??"");return{groups:n,operationByKey:new Map(i.map(t=>[t.key,t])),server:e.servers?.[0]?.url,title:e.info?.title??"API reference",version:e.info?.version}},R=r=>{const{paths:e}=r;return e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0},T=r=>{const e=r;return R(e)?{kind:"empty"}:{kind:"ready",spec:e}},H=r=>{const e=k(23),{spec:i}=r,s=S(),c=O();let n;e[0]!==c?(n=()=>c.fetchOpenApi(),e[0]=c,e[1]=n):n=e[1];const t=v(i,n,T);let f;e[2]!==t.kind||e[3]!==t.spec?(f=t.kind==="ready"?w(t.spec):void 0,e[2]=t.kind,e[3]=t.spec,e[4]=f):f=e[4];const a=f;if(t.kind==="loading"){let o;return e[5]===Symbol.for("react.memo_cache_sentinel")?(o=I("div",{className:"flex flex-col gap-4","data-testid":"api-reference-loading",children:[m(g,{className:"h-8 w-48"}),m(g,{className:"h-64 w-full"})]}),e[5]=o):o=e[5],o}if(t.kind==="error"){let o;e[6]!==t.message||e[7]!==s?(o=s("Couldn't load the OpenAPI spec: {message}",{message:t.message}),e[6]=t.message,e[7]=s,e[8]=o):o=e[8];let p;e[9]!==s?(p=s("API reference unavailable"),e[9]=s,e[10]=p):p=e[10];let d;return e[11]!==o||e[12]!==p?(d=m(h,{description:o,testId:"api-reference-error",title:p}),e[11]=o,e[12]=p,e[13]=d):d=e[13],d}if(t.kind==="empty"||a===void 0){let o;e[14]!==s?(o=s("Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here."),e[14]=s,e[15]=o):o=e[15];let p;e[16]!==s?(p=s("No OpenAPI spec configured"),e[16]=s,e[17]=p):p=e[17];let d;return e[18]!==o||e[19]!==p?(d=m(h,{description:o,testId:"api-reference-empty",title:p}),e[18]=o,e[19]=p,e[20]=d):d=e[20],d}let u;return e[21]!==a?(u=m(A,{model:a}),e[21]=a,e[22]=u):u=e[22],u};export{H as default};
1
+ import{c as k}from"react/compiler-runtime";import{E as h}from"./empty-state-D7jEML_T.mjs";import{S as g}from"./skeleton-DX1gfixl.mjs";import{u as v}from"./use-admin-spec-Cokw73Ks.mjs";import{u as O}from"./use-studio-client-DCA50tF2.mjs";import{useT as S}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{R as A}from"./reference-view-CRtrtDMy.mjs";import{jsxs as I,jsx as m}from"react/jsx-runtime";const P=["get","post","put","patch","delete","head","options","trace"],y=r=>r?.content?.["application/json"]?.schema,j=(r,e)=>Object.entries(r.responses??{}).map(([i,s])=>{const c=s.$ref?.replace("#/components/responses/",""),n=c===void 0?s:e.components?.responses?.[c]??s;return{description:n.description,schema:y(n),status:i}}),b=(r,e,i,s,c)=>{const n=y(s.requestBody),l=n?.properties?.functionPath?.const,t=typeof l=="string"?l:void 0,f=t===void 0?n:n?.properties?.args,a=s.operationId??`${i} ${e}`;return{argsSchema:f,description:s.description,functionPath:t,httpPath:e,key:r,kind:s["x-lunora-function-kind"],method:i.toUpperCase(),operationId:a,requestSchema:n,responses:j(s,c),summary:s.summary??a,tags:s.tags??[],title:s.summary??a}},x=r=>{const e=[];for(const[i,s]of Object.entries(r.paths??{})){const c=i.includes("#")?i.slice(0,i.indexOf("#")):i;for(const n of P){const l=s[n];l!==void 0&&e.push(b(i,c,n,l,r))}}return e},w=r=>{const e=r??{},i=x(e),s=new Map((e.tags??[]).map(t=>[t.name,t.description])),c=new Set,n=[],l=t=>{if(c.has(t))return;c.add(t);const f=i.filter(a=>(a.tags[0]??"")===t);f.length>0&&n.push({description:s.get(t),name:t,operations:f})};for(const t of e.tags??[])l(t.name);for(const t of i)l(t.tags[0]??"");return{groups:n,operationByKey:new Map(i.map(t=>[t.key,t])),server:e.servers?.[0]?.url,title:e.info?.title??"API reference",version:e.info?.version}},R=r=>{const{paths:e}=r;return e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0},T=r=>{const e=r;return R(e)?{kind:"empty"}:{kind:"ready",spec:e}},H=r=>{const e=k(23),{spec:i}=r,s=S(),c=O();let n;e[0]!==c?(n=()=>c.fetchOpenApi(),e[0]=c,e[1]=n):n=e[1];const t=v(i,n,T);let f;e[2]!==t.kind||e[3]!==t.spec?(f=t.kind==="ready"?w(t.spec):void 0,e[2]=t.kind,e[3]=t.spec,e[4]=f):f=e[4];const a=f;if(t.kind==="loading"){let o;return e[5]===Symbol.for("react.memo_cache_sentinel")?(o=I("div",{className:"flex flex-col gap-4","data-testid":"api-reference-loading",children:[m(g,{className:"h-8 w-48"}),m(g,{className:"h-64 w-full"})]}),e[5]=o):o=e[5],o}if(t.kind==="error"){let o;e[6]!==t.message||e[7]!==s?(o=s("Couldn't load the OpenAPI spec: {message}",{message:t.message}),e[6]=t.message,e[7]=s,e[8]=o):o=e[8];let p;e[9]!==s?(p=s("API reference unavailable"),e[9]=s,e[10]=p):p=e[10];let d;return e[11]!==o||e[12]!==p?(d=m(h,{description:o,testId:"api-reference-error",title:p}),e[11]=o,e[12]=p,e[13]=d):d=e[13],d}if(t.kind==="empty"||a===void 0){let o;e[14]!==s?(o=s("Run `lunora codegen` and wire `_generated/openapi.json` to the worker to render the API reference here."),e[14]=s,e[15]=o):o=e[15];let p;e[16]!==s?(p=s("No OpenAPI spec configured"),e[16]=s,e[17]=p):p=e[17];let d;return e[18]!==o||e[19]!==p?(d=m(h,{description:o,testId:"api-reference-empty",title:p}),e[18]=o,e[19]=p,e[20]=d):d=e[20],d}let u;return e[21]!==a?(u=m(A,{model:a}),e[21]=a,e[22]=u):u=e[22],u};export{H as default};
@@ -1 +1 @@
1
- import{c as U}from"react/compiler-runtime";import{Dialog as D}from"@base-ui/react/dialog";import{useNavigate as H}from"@tanstack/react-router";import{useState as B,useRef as Q,useEffect as V}from"react";import{useT as W}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{f as X}from"./internal-hIuTpSbx.mjs";import{u as G}from"./shortcuts-B9gDaXmw.mjs";import{c as J}from"./utils-bhneXptQ.mjs";import{jsx as r,jsxs as A}from"react/jsx-runtime";const F="lunora:command-palette",ce=()=>{"window"in globalThis&&globalThis.dispatchEvent(new Event(F))},Y=v=>{const e=U(18),{active:f,index:o,item:n,onActivate:h,onSelect:b}=v;let g;e[0]!==n||e[1]!==b?(g=()=>{b(n)},e[0]=n,e[1]=b,e[2]=g):g=e[2];const c=g;let x;e[3]!==o||e[4]!==h?(x=()=>{h(o)},e[3]=o,e[4]=h,e[5]=x):x=e[5];const d=x,m=f?"bg-accent text-accent-foreground":"text-foreground";let u;e[6]!==m?(u=J("flex w-full items-center justify-between gap-3 rounded-md px-3 py-2 text-start text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground",m),e[6]=m,e[7]=u):u=e[7];let s;e[8]!==n.label?(s=r("span",{children:n.label}),e[8]=n.label,e[9]=s):s=e[9];let i;e[10]!==n.group?(i=r("span",{className:"text-xs text-muted-foreground",children:n.group}),e[10]=n.group,e[11]=i):i=e[11];let p;return e[12]!==c||e[13]!==d||e[14]!==u||e[15]!==s||e[16]!==i?(p=r("li",{children:A("button",{className:u,onClick:c,onMouseEnter:d,type:"button",children:[s,i]})}),e[12]=c,e[13]=d,e[14]=u,e[15]=s,e[16]=i,e[17]=p):p=e[17],p},Z=(v,e)=>{const f=e.trim().toLowerCase();return f===""?v:v.filter(o=>o.label.toLowerCase().includes(f)||o.group.toLowerCase().includes(f))},de=v=>{const e=U(40),{items:f}=v,o=W(),n=H(),{palette:h}=G(),[b,g]=B(!1),[c,x]=B(""),[d,m]=B(0),u=Q(null);let s,i;e[0]!==h?(s=()=>{const t=S=>{if(!(S.metaKey||S.ctrlKey)||S.key.toLowerCase()!==h)return;const{target:_}=S;_ instanceof HTMLElement&&(_.isContentEditable||["INPUT","SELECT","TEXTAREA"].includes(_.tagName))||(S.preventDefault(),g(!0))},l=()=>{g(!0)};return globalThis.addEventListener("keydown",t),globalThis.addEventListener(F,l),()=>{globalThis.removeEventListener("keydown",t),globalThis.removeEventListener(F,l)}},i=[h],e[0]=h,e[1]=s,e[2]=i):(s=e[1],i=e[2]),V(s,i);let p;e[3]!==f||e[4]!==c?(p=Z(f,c),e[3]=f,e[4]=c,e[5]=p):p=e[5];const a=p;let I;e[6]===Symbol.for("react.memo_cache_sentinel")?(I=t=>{g(t),t||(x(""),m(0))},e[6]=I):I=e[6];const M=I;let K;e[7]!==n?(K=t=>{if(M(!1),t.run!==void 0){t.run();return}t.to!==void 0&&X(n({to:t.to}))},e[7]=n,e[8]=K):K=e[8];const w=K;let P;e[9]===Symbol.for("react.memo_cache_sentinel")?(P=t=>{x(t.target.value),m(0)},e[9]=P):P=e[9];const q=P;let z;e[10]!==d||e[11]!==a||e[12]!==w?(z=t=>{e:switch(t.key){case"ArrowDown":{t.preventDefault(),m(l=>a.length===0?0:(l+1)%a.length);break e}case"ArrowUp":{t.preventDefault(),m(l=>a.length===0?0:(l-1+a.length)%a.length);break e}case"Enter":{t.preventDefault();const l=a[d];l!==void 0&&w(l);break e}}},e[10]=d,e[11]=a,e[12]=w,e[13]=z):z=e[13];const j=z;let R;e[14]===Symbol.for("react.memo_cache_sentinel")?(R=r(D.Backdrop,{className:"fixed inset-0 z-50 bg-black/40 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0"}),e[14]=R):R=e[14];let y;e[15]!==o?(y=o("Command palette"),e[15]=o,e[16]=y):y=e[16];let E;e[17]!==y?(E=r(D.Title,{className:"sr-only",children:y}),e[17]=y,e[18]=E):E=e[18];let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=A("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.8,viewBox:"0 0 24 24",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3",strokeLinecap:"round"})]}),e[19]=O):O=e[19];let N;e[20]!==o?(N=o("Search…"),e[20]=o,e[21]=N):N=e[21];let C;e[22]!==j||e[23]!==c||e[24]!==N?(C=A("div",{className:"flex items-center gap-2 border-b border-border px-3",children:[O,r("input",{className:"h-11 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground","data-testid":"dash-command-input",onChange:q,onKeyDown:j,placeholder:N,ref:u,type:"text",value:c})]}),e[22]=j,e[23]=c,e[24]=N,e[25]=C):C=e[25];let T;e[26]!==d||e[27]!==a||e[28]!==w||e[29]!==o?(T=a.length===0?r("li",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:o("No results.")}):a.map((t,l)=>r(Y,{active:l===d,index:l,item:t,onActivate:m,onSelect:w},t.to??`${t.group}:${t.label}`)),e[26]=d,e[27]=a,e[28]=w,e[29]=o,e[30]=T):T=e[30];let k;e[31]!==T?(k=r("ul",{className:"max-h-80 overflow-y-auto p-1.5","data-testid":"dash-command-list",children:T}),e[31]=T,e[32]=k):k=e[32];let L;e[33]!==E||e[34]!==C||e[35]!==k?(L=A(D.Portal,{children:[R,A(D.Popup,{className:"fixed start-1/2 top-24 z-50 w-[36rem] max-w-[90vw] -translate-x-1/2 overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-lg outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95","data-testid":"dash-command-palette",initialFocus:u,children:[E,C,k]})]}),e[33]=E,e[34]=C,e[35]=k,e[36]=L):L=e[36];let $;return e[37]!==b||e[38]!==L?($=r(D.Root,{onOpenChange:M,open:b,children:L}),e[37]=b,e[38]=L,e[39]=$):$=e[39],$};export{de as CommandPalette,ce as openCommandPalette};
1
+ import{c as U}from"react/compiler-runtime";import{Dialog as D}from"@base-ui/react/dialog";import{useNavigate as H}from"@tanstack/react-router";import{useState as B,useRef as Q,useEffect as V}from"react";import{useT as W}from"./DEFAULT_LOCALE-BQ3jRT74.mjs";import{f as X}from"./internal-BT5tH08j.mjs";import{u as G}from"./shortcuts-B9gDaXmw.mjs";import{c as J}from"./utils-bhneXptQ.mjs";import{jsx as r,jsxs as A}from"react/jsx-runtime";const F="lunora:command-palette",ce=()=>{"window"in globalThis&&globalThis.dispatchEvent(new Event(F))},Y=v=>{const e=U(18),{active:f,index:o,item:n,onActivate:h,onSelect:b}=v;let g;e[0]!==n||e[1]!==b?(g=()=>{b(n)},e[0]=n,e[1]=b,e[2]=g):g=e[2];const c=g;let x;e[3]!==o||e[4]!==h?(x=()=>{h(o)},e[3]=o,e[4]=h,e[5]=x):x=e[5];const d=x,m=f?"bg-accent text-accent-foreground":"text-foreground";let u;e[6]!==m?(u=J("flex w-full items-center justify-between gap-3 rounded-md px-3 py-2 text-start text-sm outline-none transition-colors hover:bg-accent hover:text-accent-foreground",m),e[6]=m,e[7]=u):u=e[7];let s;e[8]!==n.label?(s=r("span",{children:n.label}),e[8]=n.label,e[9]=s):s=e[9];let i;e[10]!==n.group?(i=r("span",{className:"text-xs text-muted-foreground",children:n.group}),e[10]=n.group,e[11]=i):i=e[11];let p;return e[12]!==c||e[13]!==d||e[14]!==u||e[15]!==s||e[16]!==i?(p=r("li",{children:A("button",{className:u,onClick:c,onMouseEnter:d,type:"button",children:[s,i]})}),e[12]=c,e[13]=d,e[14]=u,e[15]=s,e[16]=i,e[17]=p):p=e[17],p},Z=(v,e)=>{const f=e.trim().toLowerCase();return f===""?v:v.filter(o=>o.label.toLowerCase().includes(f)||o.group.toLowerCase().includes(f))},de=v=>{const e=U(40),{items:f}=v,o=W(),n=H(),{palette:h}=G(),[b,g]=B(!1),[c,x]=B(""),[d,m]=B(0),u=Q(null);let s,i;e[0]!==h?(s=()=>{const t=S=>{if(!(S.metaKey||S.ctrlKey)||S.key.toLowerCase()!==h)return;const{target:_}=S;_ instanceof HTMLElement&&(_.isContentEditable||["INPUT","SELECT","TEXTAREA"].includes(_.tagName))||(S.preventDefault(),g(!0))},l=()=>{g(!0)};return globalThis.addEventListener("keydown",t),globalThis.addEventListener(F,l),()=>{globalThis.removeEventListener("keydown",t),globalThis.removeEventListener(F,l)}},i=[h],e[0]=h,e[1]=s,e[2]=i):(s=e[1],i=e[2]),V(s,i);let p;e[3]!==f||e[4]!==c?(p=Z(f,c),e[3]=f,e[4]=c,e[5]=p):p=e[5];const a=p;let I;e[6]===Symbol.for("react.memo_cache_sentinel")?(I=t=>{g(t),t||(x(""),m(0))},e[6]=I):I=e[6];const M=I;let K;e[7]!==n?(K=t=>{if(M(!1),t.run!==void 0){t.run();return}t.to!==void 0&&X(n({to:t.to}))},e[7]=n,e[8]=K):K=e[8];const w=K;let P;e[9]===Symbol.for("react.memo_cache_sentinel")?(P=t=>{x(t.target.value),m(0)},e[9]=P):P=e[9];const q=P;let z;e[10]!==d||e[11]!==a||e[12]!==w?(z=t=>{e:switch(t.key){case"ArrowDown":{t.preventDefault(),m(l=>a.length===0?0:(l+1)%a.length);break e}case"ArrowUp":{t.preventDefault(),m(l=>a.length===0?0:(l-1+a.length)%a.length);break e}case"Enter":{t.preventDefault();const l=a[d];l!==void 0&&w(l);break e}}},e[10]=d,e[11]=a,e[12]=w,e[13]=z):z=e[13];const j=z;let R;e[14]===Symbol.for("react.memo_cache_sentinel")?(R=r(D.Backdrop,{className:"fixed inset-0 z-50 bg-black/40 data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0"}),e[14]=R):R=e[14];let y;e[15]!==o?(y=o("Command palette"),e[15]=o,e[16]=y):y=e[16];let E;e[17]!==y?(E=r(D.Title,{className:"sr-only",children:y}),e[17]=y,e[18]=E):E=e[18];let O;e[19]===Symbol.for("react.memo_cache_sentinel")?(O=A("svg",{"aria-hidden":"true",className:"size-4 text-muted-foreground",fill:"none",stroke:"currentColor",strokeWidth:1.8,viewBox:"0 0 24 24",children:[r("circle",{cx:"11",cy:"11",r:"7"}),r("path",{d:"m21 21-4.3-4.3",strokeLinecap:"round"})]}),e[19]=O):O=e[19];let N;e[20]!==o?(N=o("Search…"),e[20]=o,e[21]=N):N=e[21];let C;e[22]!==j||e[23]!==c||e[24]!==N?(C=A("div",{className:"flex items-center gap-2 border-b border-border px-3",children:[O,r("input",{className:"h-11 w-full bg-transparent text-sm outline-none placeholder:text-muted-foreground","data-testid":"dash-command-input",onChange:q,onKeyDown:j,placeholder:N,ref:u,type:"text",value:c})]}),e[22]=j,e[23]=c,e[24]=N,e[25]=C):C=e[25];let T;e[26]!==d||e[27]!==a||e[28]!==w||e[29]!==o?(T=a.length===0?r("li",{className:"px-3 py-6 text-center text-sm text-muted-foreground",children:o("No results.")}):a.map((t,l)=>r(Y,{active:l===d,index:l,item:t,onActivate:m,onSelect:w},t.to??`${t.group}:${t.label}`)),e[26]=d,e[27]=a,e[28]=w,e[29]=o,e[30]=T):T=e[30];let k;e[31]!==T?(k=r("ul",{className:"max-h-80 overflow-y-auto p-1.5","data-testid":"dash-command-list",children:T}),e[31]=T,e[32]=k):k=e[32];let L;e[33]!==E||e[34]!==C||e[35]!==k?(L=A(D.Portal,{children:[R,A(D.Popup,{className:"fixed start-1/2 top-24 z-50 w-[36rem] max-w-[90vw] -translate-x-1/2 overflow-hidden rounded-lg border border-border bg-popover text-popover-foreground shadow-lg outline-none data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95","data-testid":"dash-command-palette",initialFocus:u,children:[E,C,k]})]}),e[33]=E,e[34]=C,e[35]=k,e[36]=L):L=e[36];let $;return e[37]!==b||e[38]!==L?($=r(D.Root,{onOpenChange:M,open:b,children:L}),e[37]=b,e[38]=L,e[39]=$):$=e[39],$};export{de as CommandPalette,ce as openCommandPalette};
@@ -1 +1 @@
1
- import{c as y}from"react/compiler-runtime";import{useRef as F,useEffect as E}from"react";import{i as P}from"./internal-hIuTpSbx.mjs";import{u as T}from"./use-studio-client-DCA50tF2.mjs";const g=6e4,D=e=>(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function",j=5e3,v=(e,s,r,c)=>{const t=y(10),o=r===void 0?j:r,m=T(),d=F(e);let i;t[0]!==e?(i=()=>{d.current=e},t[0]=e,t[1]=i):i=t[1],E(i);let n;t[2]!==s||t[3]!==o?(n=()=>{if(!s)return;let f=o,h=!1,p;const u=()=>{h||(p=setTimeout(R,f))},_=()=>{f=o,u()},M=A=>{P(A)||(f=Math.max(o,Math.min(f*2,g)),u())},R=()=>{if(globalThis.document?.hidden===!0){u();return}let a;try{a=d.current()}catch(S){M(S);return}D(a)?Promise.resolve(a).then(_).catch(M):_()};return u(),()=>{h=!0,clearTimeout(p)}},t[2]=s,t[3]=o,t[4]=n):n=t[4];let l;t[5]!==m||t[6]!==s||t[7]!==o||t[8]!==c?(l=[m,s,o,c],t[5]=m,t[6]=s,t[7]=o,t[8]=c,t[9]=l):l=t[9],E(n,l)},B=async e=>{const r=(await Promise.allSettled(e)).find(c=>c.status==="rejected");if(r!==void 0)throw r.reason};export{j as DEFAULT_AUTO_REFRESH_MS,B as settlePolls,v as useAutoRefresh};
1
+ import{c as y}from"react/compiler-runtime";import{useRef as F,useEffect as E}from"react";import{i as P}from"./internal-BT5tH08j.mjs";import{u as T}from"./use-studio-client-DCA50tF2.mjs";const g=6e4,D=e=>(typeof e=="object"||typeof e=="function")&&e!==null&&typeof e.then=="function",j=5e3,v=(e,s,r,c)=>{const t=y(10),o=r===void 0?j:r,m=T(),d=F(e);let i;t[0]!==e?(i=()=>{d.current=e},t[0]=e,t[1]=i):i=t[1],E(i);let n;t[2]!==s||t[3]!==o?(n=()=>{if(!s)return;let f=o,h=!1,p;const u=()=>{h||(p=setTimeout(R,f))},_=()=>{f=o,u()},M=A=>{P(A)||(f=Math.max(o,Math.min(f*2,g)),u())},R=()=>{if(globalThis.document?.hidden===!0){u();return}let a;try{a=d.current()}catch(S){M(S);return}D(a)?Promise.resolve(a).then(_).catch(M):_()};return u(),()=>{h=!0,clearTimeout(p)}},t[2]=s,t[3]=o,t[4]=n):n=t[4];let l;t[5]!==m||t[6]!==s||t[7]!==o||t[8]!==c?(l=[m,s,o,c],t[5]=m,t[6]=s,t[7]=o,t[8]=c,t[9]=l):l=t[9],E(n,l)},B=async e=>{const r=(await Promise.allSettled(e)).find(c=>c.status==="rejected");if(r!==void 0)throw r.reason};export{j as DEFAULT_AUTO_REFRESH_MS,B as settlePolls,v as useAutoRefresh};