@lunora/studio 1.0.0-alpha.324 → 1.0.0-alpha.326

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 (173) hide show
  1. package/dist/index.d.mts +3 -3
  2. package/dist/index.d.ts +3 -3
  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/auth-audit-panel.mjs +1 -1
  32. package/dist/packem_chunks/auth-config-panel.mjs +1 -1
  33. package/dist/packem_chunks/auth-sessions-panel.mjs +1 -1
  34. package/dist/packem_chunks/containers-panel.mjs +1 -1
  35. package/dist/packem_chunks/dashboards-panel.mjs +1 -1
  36. package/dist/packem_chunks/evals-panel.mjs +1 -1
  37. package/dist/packem_chunks/fanout-panel.mjs +1 -1
  38. package/dist/packem_chunks/flags-panel.mjs +1 -1
  39. package/dist/packem_chunks/issues-panel.mjs +1 -1
  40. package/dist/packem_chunks/kv-browser.mjs +1 -1
  41. package/dist/packem_chunks/log-drains-panel.mjs +1 -1
  42. package/dist/packem_chunks/migrations-route.mjs +1 -1
  43. package/dist/packem_chunks/organizations-panel.mjs +1 -1
  44. package/dist/packem_chunks/payments-panel.mjs +1 -1
  45. package/dist/packem_chunks/permissions-panel.mjs +1 -1
  46. package/dist/packem_chunks/privacy-requests-panel.mjs +1 -1
  47. package/dist/packem_chunks/queues-panel.mjs +1 -1
  48. package/dist/packem_chunks/reactors-panel.mjs +1 -1
  49. package/dist/packem_chunks/rls-panel.mjs +1 -1
  50. package/dist/packem_chunks/schedule-panel.mjs +1 -1
  51. package/dist/packem_chunks/storage-rules-panel.mjs +1 -1
  52. package/dist/packem_chunks/subscriptions-panel.mjs +1 -1
  53. package/dist/packem_chunks/sync-client-panel.mjs +1 -1
  54. package/dist/packem_chunks/traces-panel.mjs +1 -1
  55. package/dist/packem_chunks/users-panel.mjs +1 -1
  56. package/dist/packem_chunks/vector-browser.mjs +1 -1
  57. package/dist/packem_chunks/workflows-panel.mjs +1 -1
  58. package/dist/packem_shared/{ApiDocsPanel-fhDlZGE4.mjs → ApiDocsPanel-6yZaaxch.mjs} +1 -1
  59. package/dist/packem_shared/{ApiReferencePanel-nAf8tNRr.mjs → ApiReferencePanel-mwEK_vL7.mjs} +1 -1
  60. package/dist/packem_shared/{CommandPalette-D9ZY-qQd.mjs → CommandPalette-CcTVGQvw.mjs} +1 -1
  61. package/dist/packem_shared/{DataBrowser-E68QfaST.mjs → DataBrowser-B6xr6S3s.mjs} +1 -1
  62. package/dist/packem_shared/{GlobalDataBrowser-DhObcZDY.mjs → GlobalDataBrowser-DlBYI85g.mjs} +1 -1
  63. package/dist/packem_shared/{HomePanel-CUuYsApa.mjs → HomePanel-DBUgY2yE.mjs} +1 -1
  64. package/dist/packem_shared/{MigrationsPanel-C2kb3oL-.mjs → MigrationsPanel-_H327LDl.mjs} +1 -1
  65. package/dist/packem_shared/{OpenRpcReferencePanel-BxEr49D9.mjs → OpenRpcReferencePanel-DJg4AbuZ.mjs} +1 -1
  66. package/dist/packem_shared/{ScheduledJobs-BZNcYWBP.mjs → ScheduledJobs-CscRWLW-.mjs} +1 -1
  67. package/dist/packem_shared/{Studio-CZjQXFHC.mjs → Studio-s4EbmwaL.mjs} +1 -1
  68. package/dist/packem_shared/{StudioApp-C9ENwcOH.mjs → StudioApp-D1e2uc7_.mjs} +1 -1
  69. package/dist/packem_shared/{advisor-view-y4cW5JcX.mjs → advisor-view-kg9uZT7H.mjs} +1 -1
  70. package/dist/packem_shared/{app.d-D7vL0y8y.d.mts → app.d-D45VvUTx.d.mts} +2 -0
  71. package/dist/packem_shared/{app.d-D7vL0y8y.d.ts → app.d-D45VvUTx.d.ts} +2 -0
  72. package/dist/packem_shared/{data-grid-DIiNmDR9.mjs → data-grid-XIuWrWDy.mjs} +1 -1
  73. package/dist/packem_shared/{diagram-export-panel-D5CVNJkp.mjs → diagram-export-panel-DrYRni_b.mjs} +1 -1
  74. package/dist/packem_shared/{error-alert-DAsOWnCL.mjs → error-alert-Dr4RMEID.mjs} +1 -1
  75. package/dist/packem_shared/{grid-features-OVIMIQan.mjs → grid-features-6mTvrzgT.mjs} +1 -1
  76. package/dist/packem_shared/{home-panel-BcE8S2Nn.mjs → home-panel-CKbpgpz9.mjs} +1 -1
  77. package/dist/packem_shared/{internal-Df43vQI0.mjs → internal-S7SDbbPa.mjs} +2 -2
  78. package/dist/packem_shared/{log-line-CICyJ_kc.mjs → log-line-DP0b3YT5.mjs} +1 -1
  79. package/dist/packem_shared/{recording-client-CyFiAE2l.mjs → recording-client-BbX9ql7w.mjs} +1 -1
  80. package/dist/packem_shared/{reference-view-CIHyURU6.mjs → reference-view-DNdYDPow.mjs} +1 -1
  81. package/dist/packem_shared/{schema-diagram-C5oilX7l.mjs → schema-diagram-DKBYRWsL.mjs} +1 -1
  82. package/dist/packem_shared/{sql-result-table-DyK762_A.mjs → sql-result-table-B7g48CHO.mjs} +1 -1
  83. package/dist/packem_shared/{studio-fK2DTLde.mjs → studio-BTM7dITm.mjs} +1 -1
  84. package/dist/packem_shared/{table-list-sidebar-DkPO_Qtz.mjs → table-list-sidebar-DcvrtBkE.mjs} +1 -1
  85. package/dist/packem_shared/{use-admin-query-tlBof8Yg.mjs → use-admin-query-B2jU5P5u.mjs} +1 -1
  86. package/dist/packem_shared/{use-admin-spec-Bir7V68L.mjs → use-admin-spec-CISwmdXM.mjs} +1 -1
  87. package/dist/packem_shared/{use-async-submit-CZqCMTJ_.mjs → use-async-submit-CgvRHgaD.mjs} +1 -1
  88. package/dist/packem_shared/{use-auth-config-Z_n4ABCI.mjs → use-auth-config-B9w5-1-p.mjs} +1 -1
  89. package/dist/packem_shared/{use-open-trace-DMVhpnyG.mjs → use-open-trace-CUyoDXjN.mjs} +1 -1
  90. package/dist/packem_shared/{use-sql-assistant-CZydTzd5.mjs → use-sql-assistant-CK6G1ycr.mjs} +1 -1
  91. package/dist/standalone/{chunk-YVR4SEPU.js → chunk-2EYOYWS2.js} +1 -1
  92. package/dist/standalone/{chunk-OSGXNEFA.js → chunk-2G3B5PAO.js} +1 -1
  93. package/dist/standalone/{chunk-ZJQI4C3A.js → chunk-2PZ4MP3G.js} +1 -1
  94. package/dist/standalone/{chunk-2VA5S3IA.js → chunk-2QXJTBVX.js} +1 -1
  95. package/dist/standalone/{chunk-6HLARDYO.js → chunk-2W67FQCF.js} +1 -1
  96. package/dist/standalone/{chunk-4Y5AFETG.js → chunk-33YIKGW6.js} +1 -1
  97. package/dist/standalone/{chunk-WP2AS7SZ.js → chunk-3I6JC6NL.js} +1 -1
  98. package/dist/standalone/{chunk-WJHMDTV2.js → chunk-4LAD57XQ.js} +1 -1
  99. package/dist/standalone/{chunk-RBAD4SMG.js → chunk-52YTJ556.js} +1 -1
  100. package/dist/standalone/chunk-5CNRDILP.js +1 -0
  101. package/dist/standalone/{chunk-HJHSQPHW.js → chunk-5OMZCVRF.js} +1 -1
  102. package/dist/standalone/{chunk-MGEACGEE.js → chunk-6LU7UD32.js} +1 -1
  103. package/dist/standalone/{chunk-2QLSWJDL.js → chunk-6TILEHRA.js} +1 -1
  104. package/dist/standalone/{chunk-CUJGTNYR.js → chunk-6Z2A2P2U.js} +1 -1
  105. package/dist/standalone/{chunk-2H5IXFGR.js → chunk-7AEDQPBM.js} +1 -1
  106. package/dist/standalone/{chunk-SNJ5HRZO.js → chunk-7FY6RTSD.js} +1 -1
  107. package/dist/standalone/{chunk-POKVFO6Q.js → chunk-7JYYC4A5.js} +1 -1
  108. package/dist/standalone/{chunk-OX6JWCPF.js → chunk-7QP56XBQ.js} +1 -1
  109. package/dist/standalone/{chunk-NDGHCEE3.js → chunk-7TF3N4ZD.js} +1 -1
  110. package/dist/standalone/{chunk-4K6CXILB.js → chunk-AKHBJSQO.js} +1 -1
  111. package/dist/standalone/{chunk-MJ3SSK6L.js → chunk-AQFI2GWT.js} +1 -1
  112. package/dist/standalone/{chunk-QSUWAGXH.js → chunk-B74YABQU.js} +1 -1
  113. package/dist/standalone/chunk-BDYCZHD2.js +9 -0
  114. package/dist/standalone/{chunk-MRJB4FPI.js → chunk-CQ3UUCD2.js} +1 -1
  115. package/dist/standalone/{chunk-22TUDRBR.js → chunk-CUEZLEQO.js} +1 -1
  116. package/dist/standalone/{chunk-HOGQLP3J.js → chunk-D6ZXOSCM.js} +1 -1
  117. package/dist/standalone/{chunk-SV764LKQ.js → chunk-D746I7ZX.js} +1 -1
  118. package/dist/standalone/{chunk-KU3IXE36.js → chunk-DGHWBHUF.js} +1 -1
  119. package/dist/standalone/{chunk-Z6THFOLU.js → chunk-DSYUT6DA.js} +1 -1
  120. package/dist/standalone/{chunk-TIQ7OBZJ.js → chunk-DVX5J34S.js} +1 -1
  121. package/dist/standalone/{chunk-7AF3FZCB.js → chunk-E7Q7NE77.js} +1 -1
  122. package/dist/standalone/{chunk-MTGFTTXO.js → chunk-FBGCQYRO.js} +1 -1
  123. package/dist/standalone/{chunk-JZGTSH2C.js → chunk-FCVKROK5.js} +1 -1
  124. package/dist/standalone/{chunk-2JH7ZYVY.js → chunk-G26RQPDL.js} +1 -1
  125. package/dist/standalone/{chunk-F3UUFO2C.js → chunk-GH24P7D2.js} +1 -1
  126. package/dist/standalone/{chunk-MB5JGSN6.js → chunk-HC4J57UZ.js} +1 -1
  127. package/dist/standalone/{chunk-6YQ3RTCB.js → chunk-HTGHQYIG.js} +1 -1
  128. package/dist/standalone/{chunk-OM3B3V47.js → chunk-HXLPQMQY.js} +1 -1
  129. package/dist/standalone/{chunk-VFL7VJWF.js → chunk-HYKN42SO.js} +1 -1
  130. package/dist/standalone/{chunk-XHRKNCCI.js → chunk-I23ULEUU.js} +1 -1
  131. package/dist/standalone/{chunk-OH7DVC7S.js → chunk-IBXENKTW.js} +1 -1
  132. package/dist/standalone/{chunk-EXYBVVHU.js → chunk-JM4M6D6X.js} +1 -1
  133. package/dist/standalone/{chunk-W3LXMSGC.js → chunk-JOQMVPGT.js} +1 -1
  134. package/dist/standalone/{chunk-3OHVDOV5.js → chunk-K67NQCL7.js} +1 -1
  135. package/dist/standalone/{chunk-U4YBJ4OW.js → chunk-KC67FFZF.js} +1 -1
  136. package/dist/standalone/{chunk-SB4443ME.js → chunk-KGWOEE3Y.js} +1 -1
  137. package/dist/standalone/{chunk-7RAYXTNN.js → chunk-LCYDNUTU.js} +1 -1
  138. package/dist/standalone/{chunk-SQ2LCZBH.js → chunk-LWE4JQGT.js} +1 -1
  139. package/dist/standalone/{chunk-ESSG4L6C.js → chunk-MNXBTILQ.js} +1 -1
  140. package/dist/standalone/{chunk-R6PJYMJT.js → chunk-MRWBB3N3.js} +1 -1
  141. package/dist/standalone/{chunk-WFNUMMDF.js → chunk-MZB4M3O4.js} +2 -2
  142. package/dist/standalone/{chunk-R4ILI46D.js → chunk-N5VW6ADU.js} +1 -1
  143. package/dist/standalone/{chunk-HER5A45F.js → chunk-NFCRD6DB.js} +1 -1
  144. package/dist/standalone/{chunk-OK35SLOW.js → chunk-O3YOPOFI.js} +1 -1
  145. package/dist/standalone/{chunk-QZRKA2E4.js → chunk-O4AU6G7Z.js} +1 -1
  146. package/dist/standalone/{chunk-5WOMOENH.js → chunk-OGNEIWHN.js} +1 -1
  147. package/dist/standalone/{chunk-JNBWPXNV.js → chunk-OJVA6YJI.js} +1 -1
  148. package/dist/standalone/{chunk-XTQR2C6N.js → chunk-OKX7I64M.js} +1 -1
  149. package/dist/standalone/{chunk-4WD4XGC3.js → chunk-OMN44W6V.js} +1 -1
  150. package/dist/standalone/{chunk-6MFVEI7C.js → chunk-OTQSYE6X.js} +1 -1
  151. package/dist/standalone/{chunk-HM57YJY5.js → chunk-OVVRMPVR.js} +1 -1
  152. package/dist/standalone/{chunk-WAX5WY6F.js → chunk-P2NSASR2.js} +1 -1
  153. package/dist/standalone/{chunk-EEDIMNRC.js → chunk-PKHFMUAX.js} +1 -1
  154. package/dist/standalone/{chunk-RDJCY5PQ.js → chunk-PWH4FCFR.js} +1 -1
  155. package/dist/standalone/{chunk-DSIY2CMT.js → chunk-PYNRIX74.js} +1 -1
  156. package/dist/standalone/{chunk-JL6LEVHQ.js → chunk-RU4O6ZXP.js} +1 -1
  157. package/dist/standalone/{chunk-UDMY3BMT.js → chunk-SEODHPIF.js} +1 -1
  158. package/dist/standalone/{chunk-3YH5TM3G.js → chunk-UQAMQR4Q.js} +1 -1
  159. package/dist/standalone/{chunk-Z22BDS6N.js → chunk-VASJTDMU.js} +1 -1
  160. package/dist/standalone/{chunk-DL6TTBE6.js → chunk-VST2VNEU.js} +1 -1
  161. package/dist/standalone/{chunk-NW6FNJ4L.js → chunk-W3QVYZMI.js} +1 -1
  162. package/dist/standalone/{chunk-ICU56FBP.js → chunk-WGU2LV5D.js} +1 -1
  163. package/dist/standalone/chunk-WS7WNXF3.js +15 -0
  164. package/dist/standalone/{chunk-PIMTWCRD.js → chunk-X2YHVCMH.js} +1 -1
  165. package/dist/standalone/{chunk-NDTQTKDX.js → chunk-X472RKFD.js} +1 -1
  166. package/dist/standalone/{chunk-VKURTWDH.js → chunk-XBZGJ7I6.js} +1 -1
  167. package/dist/standalone/{chunk-NYHYH5Z5.js → chunk-XD6XP3QZ.js} +1 -1
  168. package/dist/standalone/{chunk-6QTAHSDD.js → chunk-ZQ4C2DMJ.js} +1 -1
  169. package/dist/standalone/studio.js +1 -1
  170. package/package.json +5 -5
  171. package/dist/standalone/chunk-BOYS4DOC.js +0 -9
  172. package/dist/standalone/chunk-KLTGKTSL.js +0 -1
  173. package/dist/standalone/chunk-N7LJO732.js +0 -15
@@ -1 +1 @@
1
- import{a as Ot,b as Qt,c as ot}from"./chunk-CVXNHIQW.js";import{a as me}from"./chunk-253UHWDX.js";import{a as Kt,b as At,c as Pt,d as $t}from"./chunk-2I4NHEKA.js";import{a as it}from"./chunk-HOGQLP3J.js";import{a as It,b as Rt,c as Tt,d as zt,e as Qe}from"./chunk-5QR2SQIS.js";import{a as Ft}from"./chunk-VCFEO3RI.js";import{a as Lt}from"./chunk-6QTAHSDD.js";import"./chunk-VESGIGMQ.js";import"./chunk-NRP22GKC.js";import{e as Ct}from"./chunk-UYEZR3BI.js";import"./chunk-OPM7ESDV.js";import{a as Dt}from"./chunk-SV764LKQ.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Ze,b as et,c as tt,d as Nt,e as yt,f as rt,g as at,h as wt,i as St}from"./chunk-TIQ7OBZJ.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import{a as Mt}from"./chunk-R6U22RSY.js";import{a as _t}from"./chunk-YVR4SEPU.js";import{a as qt,b as kt}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-OQ6I6OXT.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as Je}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Ge}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as Ke}from"./chunk-4ZEL6BYL.js";import{c as $e}from"./chunk-DSIY2CMT.js";import{a as ct,l as mt}from"./chunk-BOYS4DOC.js";import"./chunk-QAQDMS6R.js";import"./chunk-N7LJO732.js";import{a as gt}from"./chunk-RWVIV3U7.js";import{a as st,b as lt,c as nt,d as Oe,e as ce,f as V}from"./chunk-HCTJKP5J.js";import{a as fe,b as Ae,c as Pe,d as ht,e as pe}from"./chunk-2IKDEUCX.js";import{d as ge,f as ft,g as pt,h as xt,i as bt,l as Ve,p as vt}from"./chunk-HJHSQPHW.js";import{a as d,d as Ye,e as Et,f as Ht,g as Ut,i as ut}from"./chunk-I26MS5PJ.js";var B=Ye(Et(),1);var xe=Ye(Ht(),1);var t=Ye(Ut(),1);var jt=d((l,e,s)=>`${l}:${e}:${ct(s??{})}`,"ut"),Bt=d((l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,"ft"),Gt=d((l,e)=>Bt(l,e),"jt"),Vt=d(l=>Bt(l.kind,l),"Gt"),dt=d(l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),"We"),Wt=d(l=>Array.isArray(l?.series)?l.series:[],"Jt"),Xt="FUNCTION_NOT_FOUND",Yt=d(l=>{let e=new Map;if(!Array.isArray(l?.series))return e;for(let s of l.series)e.set(jt(s.kind,s.name,s.attributes),s.points);return e},"Xt"),Jt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=d(l=>{let e=(0,xe.c)(18),{name:s,onOpenTrace:a,traceId:r}=l,h=ge();if(r===void 0){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=c):c=e[0],c}let i;e[1]!==r?(i=r.slice(0,8),e[1]=r,e[2]=i):i=e[2];let n=i;if(a===void 0){let c=`mt-instrument-trace-${s}`,p;return e[3]!==n||e[4]!==c||e[5]!==r?(p=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":c,title:r,children:n}),e[3]=n,e[4]=c,e[5]=r,e[6]=p):p=e[6],p}let g=`mt-instrument-trace-${s}`,v;e[7]!==a||e[8]!==r?(v=d(()=>{a(r)},"v"),e[7]=a,e[8]=r,e[9]=v):v=e[9];let S;e[10]!==h||e[11]!==r?(S=h("Open the exemplar trace {trace}",{trace:r}),e[10]=h,e[11]=r,e[12]=S):S=e[12];let f;return e[13]!==n||e[14]!==g||e[15]!==v||e[16]!==S?(f=(0,t.jsx)("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":g,onClick:v,title:S,type:"button",children:n}),e[13]=n,e[14]=g,e[15]=v,e[16]=S,e[17]=f):f=e[17],f},"Zt"),er=d(l=>{let e=(0,xe.c)(105),{onOpenTrace:s,shardKey:a}=l,r=ge(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={},e[0]=h):h=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];let{data:n,error:g,errorSource:v}=$e(Ke.getMetricSeries,h,i),S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let f;e[4]!==a?(f={live:!0,shardKey:a},e[4]=a,e[5]=f):f=e[5];let{data:c}=$e(Ke.getMetricHistory,S,f),p,N,q,M,o,k,x,b,_,D,u,C,I;if(e[6]!==n||e[7]!==g||e[8]!==v||e[9]!==c||e[10]!==s||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{let A=Wt(n),P=bt(v)===Xt;if(g!==null&&!P){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let j;e[27]!==m?(j=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=j):j=e[28];let E;e[29]!==g||e[30]!==r?(E=r("Instruments unavailable: {error}",{error:g}),e[29]=g,e[30]=r,e[31]=E):E=e[31];let H;e[32]!==E?(H=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:E}),e[32]=E,e[33]=H):H=e[33];let de;e[34]!==j||e[35]!==H?(de=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[j,H]}),e[34]=j,e[35]=H,e[36]=de):de=e[36],b=de;break e}if(A.length===0){b=null;break e}let $=Yt(c),L;e[37]!==r?(L=d(m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),"L"),e[37]=r,e[38]=L):L=e[38];let U=L;o="flex flex-col gap-2",k="mt-instruments";let Q;e[39]!==r?(Q=r("Instruments"),e[39]=r,e[40]=Q):Q=e[40],e[41]!==Q?(x=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:Q}),e[41]=Q,e[42]=x):x=e[42],M=fe,I="overflow-hidden py-0",q=pe,C="px-0",N=st,D="mt-instruments-table";let K;e[43]!==r?(K=r("name"),e[43]=r,e[44]=K):K=e[44];let O;e[45]!==K?(O=(0,t.jsx)(ce,{children:K}),e[45]=K,e[46]=O):O=e[46];let W;e[47]!==r?(W=r("kind"),e[47]=r,e[48]=W):W=e[48];let X;e[49]!==W?(X=(0,t.jsx)(ce,{children:W}),e[49]=W,e[50]=X):X=e[50];let Y;e[51]!==r?(Y=r("value"),e[51]=r,e[52]=Y):Y=e[52];let J;e[53]!==Y?(J=(0,t.jsx)(ce,{className:"text-right",children:Y}),e[53]=Y,e[54]=J):J=e[54];let Z;e[55]!==r?(Z=r("count"),e[55]=r,e[56]=Z):Z=e[56];let ee;e[57]!==Z?(ee=(0,t.jsx)(ce,{className:"text-right",children:Z}),e[57]=Z,e[58]=ee):ee=e[58];let te;e[59]!==r?(te=r("range"),e[59]=r,e[60]=te):te=e[60];let re;e[61]!==te?(re=(0,t.jsx)(ce,{className:"text-right",children:te}),e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==r?(ae=r("trend"),e[63]=r,e[64]=ae):ae=e[64];let se;e[65]!==ae?(se=(0,t.jsx)(ce,{children:ae}),e[65]=ae,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ne;e[69]!==le?(ne=(0,t.jsx)(ce,{children:le}),e[69]=le,e[70]=ne):ne=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let oe;e[73]!==ie?(oe=(0,t.jsx)(ce,{children:ie}),e[73]=ie,e[74]=oe):oe=e[74],e[75]!==O||e[76]!==X||e[77]!==J||e[78]!==ee||e[79]!==re||e[80]!==se||e[81]!==ne||e[82]!==oe?(u=(0,t.jsx)(lt,{children:(0,t.jsxs)(Oe,{children:[O,X,J,ee,re,se,ne,oe]})}),e[75]=O,e[76]=X,e[77]=J,e[78]=ee,e[79]=re,e[80]=se,e[81]=ne,e[82]=oe,e[83]=u):u=e[83],p=nt,_=A.map(m=>{let j=Ft(m.attributes),E=jt(m.kind,m.name,m.attributes),H=($.get(E)??[]).map(de=>Gt(m.kind,de));return(0,t.jsxs)(Oe,{"data-testid":`mt-instrument-${m.name}`,children:[(0,t.jsx)(V,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),(0,t.jsx)(V,{children:(0,t.jsx)(Ge,{variant:Jt[m.kind],children:U(m.kind)})}),(0,t.jsx)(V,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:dt(Vt(m))}),(0,t.jsx)(V,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),(0,t.jsx)(V,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"\u2014":`${dt(m.min)}\u2013${dt(m.max)}`}),(0,t.jsx)(V,{children:H.length>=2?(0,t.jsx)(it,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:H,testId:`mt-instrument-trend-${m.name}`}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(V,{className:"font-mono text-xs",children:(0,t.jsx)(Zt,{name:m.name,onOpenTrace:s,traceId:m.exemplarTraceId})}),(0,t.jsx)(V,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:j,children:j===""?"\u2014":j})]},E)})}e[6]=n,e[7]=g,e[8]=v,e[9]=c,e[10]=s,e[11]=r,e[12]=p,e[13]=N,e[14]=q,e[15]=M,e[16]=o,e[17]=k,e[18]=x,e[19]=b,e[20]=_,e[21]=D,e[22]=u,e[23]=C,e[24]=I}else p=e[12],N=e[13],q=e[14],M=e[15],o=e[16],k=e[17],x=e[18],b=e[19],_=e[20],D=e[21],u=e[22],C=e[23],I=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let R;e[84]!==p||e[85]!==_?(R=(0,t.jsx)(p,{children:_}),e[84]=p,e[85]=_,e[86]=R):R=e[86];let T;e[87]!==N||e[88]!==R||e[89]!==D||e[90]!==u?(T=(0,t.jsxs)(N,{"data-testid":D,children:[u,R]}),e[87]=N,e[88]=R,e[89]=D,e[90]=u,e[91]=T):T=e[91];let w;e[92]!==q||e[93]!==T||e[94]!==C?(w=(0,t.jsx)(q,{className:C,children:T}),e[92]=q,e[93]=T,e[94]=C,e[95]=w):w=e[95];let y;e[96]!==M||e[97]!==w||e[98]!==I?(y=(0,t.jsx)(M,{className:I,children:w}),e[96]=M,e[97]=w,e[98]=I,e[99]=y):y=e[99];let F;return e[100]!==o||e[101]!==k||e[102]!==x||e[103]!==y?(F=(0,t.jsxs)("section",{className:o,"data-testid":k,children:[x,y]}),e[100]=o,e[101]=k,e[102]=x,e[103]=y,e[104]=F):F=e[104],F},"er"),tr=d(l=>{let e=(0,xe.c)(74),{aggregate:s,shardResults:a}=l,r=ge(),h;e[0]!==r?(h=r("Shards"),e[0]=r,e[1]=h):h=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==r?(i=s.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):r("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==h||e[7]!==i?(n=(0,t.jsx)(me,{label:h,testId:"mt-agg-shards",value:i}),e[6]=h,e[7]=i,e[8]=n):n=e[8];let g;e[9]!==r?(g=r("Total requests"),e[9]=r,e[10]=g):g=e[10];let v;e[11]!==s.totalRequests||e[12]!==g?(v=(0,t.jsx)(me,{label:g,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=g,e[13]=v):v=e[13];let S;e[14]!==r?(S=r("Total errors"),e[14]=r,e[15]=S):S=e[15];let f;e[16]!==s.totalErrors||e[17]!==S?(f=(0,t.jsx)(me,{label:S,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=S,e[18]=f):f=e[18];let c;e[19]!==r?(c=r("Total database size"),e[19]=r,e[20]=c):c=e[20];let p;e[21]!==s.totalDatabaseSize?(p=Ve(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=p):p=e[22];let N;e[23]!==c||e[24]!==p?(N=(0,t.jsx)(me,{label:c,testId:"mt-agg-db-size",value:p}),e[23]=c,e[24]=p,e[25]=N):N=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let M;e[28]!==s.hitRate||e[29]!==r?(M=s.hitRate===null?r("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=r,e[30]=M):M=e[30];let o;e[31]!==q||e[32]!==M?(o=(0,t.jsx)(me,{label:q,testId:"mt-agg-cache",value:M}),e[31]=q,e[32]=M,e[33]=o):o=e[33];let k;e[34]!==N||e[35]!==o||e[36]!==n||e[37]!==v||e[38]!==f?(k=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,v,f,N,o]}),e[34]=N,e[35]=o,e[36]=n,e[37]=v,e[38]=f,e[39]=k):k=e[39];let x;e[40]!==r?(x=r("shard"),e[40]=r,e[41]=x):x=e[41];let b;e[42]!==x?(b=(0,t.jsx)(ce,{children:x}),e[42]=x,e[43]=b):b=e[43];let _;e[44]!==r?(_=r("requests"),e[44]=r,e[45]=_):_=e[45];let D;e[46]!==_?(D=(0,t.jsx)(ce,{children:_}),e[46]=_,e[47]=D):D=e[47];let u;e[48]!==r?(u=r("errors"),e[48]=r,e[49]=u):u=e[49];let C;e[50]!==u?(C=(0,t.jsx)(ce,{children:u}),e[50]=u,e[51]=C):C=e[51];let I;e[52]!==r?(I=r("db size"),e[52]=r,e[53]=I):I=e[53];let R;e[54]!==I?(R=(0,t.jsx)(ce,{children:I}),e[54]=I,e[55]=R):R=e[55];let T;e[56]!==b||e[57]!==D||e[58]!==C||e[59]!==R?(T=(0,t.jsx)(lt,{children:(0,t.jsxs)(Oe,{children:[b,D,C,R]})}),e[56]=b,e[57]=D,e[58]=C,e[59]=R,e[60]=T):T=e[60];let w;if(e[61]!==a||e[62]!==r){let P;e[64]!==r?(P=d($=>(0,t.jsxs)(Oe,{"data-testid":`mt-agg-row-${$.shard}`,children:[(0,t.jsx)(V,{children:$.shard}),$.metrics===null?(0,t.jsx)(V,{className:"text-destructive",colSpan:3,children:$.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(V,{className:"tabular-nums",children:$.metrics.requests}),(0,t.jsx)(V,{className:"tabular-nums",children:$.metrics.errors}),(0,t.jsx)(V,{className:"tabular-nums",children:Ve($.metrics.databaseSize)})]})]},$.shard),"z"),e[64]=r,e[65]=P):P=e[65],w=a.map(P),e[61]=a,e[62]=r,e[63]=w}else w=e[63];let y;e[66]!==w?(y=(0,t.jsx)(nt,{children:w}),e[66]=w,e[67]=y):y=e[67];let F;e[68]!==T||e[69]!==y?(F=(0,t.jsx)(fe,{className:"overflow-hidden py-0",children:(0,t.jsx)(pe,{className:"px-0",children:(0,t.jsxs)(st,{"data-testid":"mt-agg-table",children:[T,y]})})}),e[68]=T,e[69]=y,e[70]=F):F=e[70];let A;return e[71]!==k||e[72]!==F?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[k,F]}),e[71]=k,e[72]=F,e[73]=A):A=e[73],A},"tr"),rr=d(l=>{let e=(0,xe.c)(75),{currentDelta:s,errorRate:a,history:r,latencyPercentiles:h,metrics:i}=l,n=ge(),{cache:g}=i,v;e[0]!==r||e[1]!==n?(v=r.length>=2?(0,t.jsx)(it,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=n,e[2]=v):v=e[2];let S;e[3]!==s||e[4]!==r.length||e[5]!==n?(S=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples\u2026")}),e[3]=s,e[4]=r.length,e[5]=n,e[6]=S):S=e[6];let f;e[7]!==n?(f=n("Requests"),e[7]=n,e[8]=f):f=e[8];let c;e[9]!==i.requests||e[10]!==v||e[11]!==S||e[12]!==f?(c=(0,t.jsx)(me,{chart:v,footer:S,label:f,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=v,e[11]=S,e[12]=f,e[13]=c):c=e[13];let p;e[14]!==a||e[15]!==n?(p=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=p):p=e[16];let N;e[17]!==n?(N=n("Errors"),e[17]=n,e[18]=N):N=e[18];let q;e[19]!==a||e[20]!==i.errors?(q=(0,t.jsxs)(t.Fragment,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=q):q=e[21];let M;e[22]!==p||e[23]!==N||e[24]!==q?(M=(0,t.jsx)(me,{footer:p,label:N,testId:"mt-errors",value:q}),e[22]=p,e[23]=N,e[24]=q,e[25]=M):M=e[25];let o;e[26]!==h.p90?(o=h.p90>0?`P90 ${ot(h.p90)}`:void 0,e[26]=h.p90,e[27]=o):o=e[27];let k;e[28]!==n?(k=n("P95 latency"),e[28]=n,e[29]=k):k=e[29];let x;e[30]!==h.p95?(x=h.p95>0?ot(h.p95):"\u2014",e[30]=h.p95,e[31]=x):x=e[31];let b;e[32]!==k||e[33]!==x||e[34]!==o?(b=(0,t.jsx)(me,{footer:o,label:k,testId:"mt-p95",value:x}),e[32]=k,e[33]=x,e[34]=o,e[35]=b):b=e[35];let _;e[36]!==g||e[37]!==n?(_=g?`${g.entries.toLocaleString()} ${n("cache entries")}`:void 0,e[36]=g,e[37]=n,e[38]=_):_=e[38];let D;e[39]!==n?(D=n("Database size"),e[39]=n,e[40]=D):D=e[40];let u;e[41]!==i.databaseSize?(u=Ve(i.databaseSize),e[41]=i.databaseSize,e[42]=u):u=e[42];let C;e[43]!==_||e[44]!==D||e[45]!==u?(C=(0,t.jsx)(me,{footer:_,label:D,testId:"mt-db-size",value:u}),e[43]=_,e[44]=D,e[45]=u,e[46]=C):C=e[46];let I;e[47]!==n?(I=n("Shard"),e[47]=n,e[48]=I):I=e[48];let R;e[49]!==i.shard||e[50]!==I?(R=(0,t.jsx)(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=R):R=e[51];let T;e[52]!==n?(T=n("Uptime"),e[52]=n,e[53]=T):T=e[53];let w;e[54]!==i.uptimeMs?(w=Ot(i.uptimeMs),e[54]=i.uptimeMs,e[55]=w):w=e[55];let y;e[56]!==T||e[57]!==w?(y=(0,t.jsx)(me,{label:T,testId:"mt-uptime",value:w}),e[56]=T,e[57]=w,e[58]=y):y=e[58];let F;e[59]!==n?(F=n("Cache hit rate"),e[59]=n,e[60]=F):F=e[60];let A;e[61]!==g||e[62]!==n?(A=g?n("{rate} ({count} entries)",{count:g.entries,rate:Qt(g.hits,g.misses)}):n("no cache configured"),e[61]=g,e[62]=n,e[63]=A):A=e[63];let P;e[64]!==F||e[65]!==A?(P=(0,t.jsx)(me,{label:F,testId:"mt-cache",value:A}),e[64]=F,e[65]=A,e[66]=P):P=e[66];let $;return e[67]!==b||e[68]!==C||e[69]!==R||e[70]!==y||e[71]!==P||e[72]!==c||e[73]!==M?($=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[c,M,b,C,R,y,P]}),e[67]=b,e[68]=C,e[69]=R,e[70]=y,e[71]=P,e[72]=c,e[73]=M,e[74]=$):$=e[74],$},"rr"),Xe=d(l=>l>=100?"critical":l>=50?"warning":"good","Ge"),je=d(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"Ee"),We=d(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"Ue"),ar=d(l=>{let e=(0,xe.c)(3),{level:s}=l;if(s==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Ge,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(s==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=a):a=e[2],a},"sr"),sr=d((l,e)=>{let s=[...l];return s.sort((a,r)=>{switch(e){case"avgTime":return r.avgDurationMs-a.avgDurationMs;case"execCount":return r.execCount-a.execCount;case"rowsRead":return r.rowsRead-a.rowsRead;default:return r.totalDurationMs-a.totalDurationMs}}),s},"lr"),lr=d(l=>{let e=(0,xe.c)(161),{queryStats:s}=l,a=ge(),[r,h]=(0,B.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[n,g]=(0,B.useState)(i),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=d(I=>{I!==null&&h(I)},"v"),e[1]=v):v=e[1];let S=v,f,c,p,N,q,M,o,k,x,b;if(e[2]!==n||e[3]!==s||e[4]!==r||e[5]!==a){p=Symbol.for("react.early_return_sentinel");e:{let I=sr(s,r),R;e[16]!==s?(R=s.filter(nr),e[16]=s,e[17]=R):R=e[17];let T=R.length,w;e[18]!==s?(w=s.filter(ir),e[18]=s,e[19]=w):w=e[19];let y=w.length,F;e[20]!==s?(F=s.filter(or),e[20]=s,e[21]=F):F=e[21];let A=F.length,P;e[22]===Symbol.for("react.memo_cache_sentinel")?(P=d(z=>{g(ue=>{let G=new Set(ue);return G.has(z)?G.delete(z):G.add(z),G})},"z"),e[22]=P):P=e[22];let $=P;if(s.length===0){let z;e[23]!==a?(z=a("No query insights yet"),e[23]=a,e[24]=z):z=e[24];let ue;e[25]!==z?(ue=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:z}),e[25]=z,e[26]=ue):ue=e[26];let G;e[27]!==a?(G=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=G):G=e[28];let he;e[29]!==G?(he=(0,t.jsx)("p",{className:"mt-1 text-sm",children:G}),e[29]=G,e[30]=he):he=e[30];let Ue;e[31]!==ue||e[32]!==he?(Ue=(0,t.jsx)(fe,{children:(0,t.jsx)(pe,{className:"py-12",children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground",children:[ue,he]})})}),e[31]=ue,e[32]=he,e[33]=Ue):Ue=e[33],p=Ue;break e}o="space-y-4",k="qi-root";let L;e[34]!==a?(L=a("Critical queries"),e[34]=a,e[35]=L):L=e[35];let U;e[36]!==L?(U=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=U):U=e[37];let Q;e[38]!==T?(Q=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:T}),e[38]=T,e[39]=Q):Q=e[39];let K;e[40]!==a?(K=a(">100ms avg execution"),e[40]=a,e[41]=K):K=e[41];let O;e[42]!==K?(O=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:K}),e[42]=K,e[43]=O):O=e[43];let W;e[44]!==Q||e[45]!==O?(W=(0,t.jsxs)(pe,{children:[Q,O]}),e[44]=Q,e[45]=O,e[46]=W):W=e[46];let X;e[47]!==U||e[48]!==W?(X=(0,t.jsxs)(fe,{children:[U,W]}),e[47]=U,e[48]=W,e[49]=X):X=e[49];let Y;e[50]!==a?(Y=a("Moderate queries"),e[50]=a,e[51]=Y):Y=e[51];let J;e[52]!==Y?(J=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:Y})}),e[52]=Y,e[53]=J):J=e[53];let Z;e[54]!==y?(Z=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:y}),e[54]=y,e[55]=Z):Z=e[55];let ee;e[56]!==a?(ee=a("50\u2013100ms avg execution"),e[56]=a,e[57]=ee):ee=e[57];let te;e[58]!==ee?(te=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ee}),e[58]=ee,e[59]=te):te=e[59];let re;e[60]!==Z||e[61]!==te?(re=(0,t.jsxs)(pe,{children:[Z,te]}),e[60]=Z,e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==J||e[64]!==re?(ae=(0,t.jsxs)(fe,{children:[J,re]}),e[63]=J,e[64]=re,e[65]=ae):ae=e[65];let se;e[66]!==a?(se=a("Fast queries"),e[66]=a,e[67]=se):se=e[67];let le;e[68]!==se?(le=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ne;e[70]!==A?(ne=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:A}),e[70]=A,e[71]=ne):ne=e[71];let ie;e[72]!==a?(ie=a("<50ms avg execution"),e[72]=a,e[73]=ie):ie=e[73];let oe;e[74]!==ie?(oe=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=oe):oe=e[75];let m;e[76]!==ne||e[77]!==oe?(m=(0,t.jsxs)(pe,{children:[ne,oe]}),e[76]=ne,e[77]=oe,e[78]=m):m=e[78];let j;e[79]!==le||e[80]!==m?(j=(0,t.jsxs)(fe,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=j):j=e[81],e[82]!==X||e[83]!==ae||e[84]!==j?(x=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[X,ae,j]}),e[82]=X,e[83]=ae,e[84]=j,e[85]=x):x=e[85];let E;e[86]!==a?(E=a("Query leaderboard"),e[86]=a,e[87]=E):E=e[87];let H;e[88]!==E?(H=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:E}),e[88]=E,e[89]=H):H=e[89];let de;e[90]!==r||e[91]!==a?(de=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=de):de=e[92];let be;e[93]!==de?(be=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:de}),e[93]=de,e[94]=be):be=e[94];let ve;e[95]!==H||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[H,be]}),e[95]=H,e[96]=be,e[97]=ve):ve=e[97];let Ne;e[98]!==a?(Ne=a("Sort by"),e[98]=a,e[99]=Ne):Ne=e[99];let ye;e[100]!==Ne?(ye=(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:Ne}),e[100]=Ne,e[101]=ye):ye=e[101];let we;e[102]!==a?(we=a("Sort queries by"),e[102]=a,e[103]=we):we=e[103];let Be;e[104]===Symbol.for("react.memo_cache_sentinel")?(Be=(0,t.jsx)(Rt,{}),e[104]=Be):Be=e[104];let Se;e[105]!==we?(Se=(0,t.jsx)(Tt,{"aria-label":we,className:"w-[140px]","data-testid":"qi-sort",children:Be}),e[105]=we,e[106]=Se):Se=e[106];let qe;e[107]!==a?(qe=a("Total time"),e[107]=a,e[108]=qe):qe=e[108];let ke;e[109]!==qe?(ke=(0,t.jsx)(Qe,{value:"totalTime",children:qe}),e[109]=qe,e[110]=ke):ke=e[110];let _e;e[111]!==a?(_e=a("Avg time"),e[111]=a,e[112]=_e):_e=e[112];let Me;e[113]!==_e?(Me=(0,t.jsx)(Qe,{value:"avgTime",children:_e}),e[113]=_e,e[114]=Me):Me=e[114];let De;e[115]!==a?(De=a("Execution count"),e[115]=a,e[116]=De):De=e[116];let Ce;e[117]!==De?(Ce=(0,t.jsx)(Qe,{value:"execCount",children:De}),e[117]=De,e[118]=Ce):Ce=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Re;e[121]!==Ie?(Re=(0,t.jsx)(Qe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Re):Re=e[122];let Te;e[123]!==ke||e[124]!==Me||e[125]!==Ce||e[126]!==Re?(Te=(0,t.jsxs)(zt,{children:[ke,Me,Ce,Re]}),e[123]=ke,e[124]=Me,e[125]=Ce,e[126]=Re,e[127]=Te):Te=e[127];let ze;e[128]!==r||e[129]!==Se||e[130]!==Te?(ze=(0,t.jsxs)(It,{onValueChange:S,value:r,children:[Se,Te]}),e[128]=r,e[129]=Se,e[130]=Te,e[131]=ze):ze=e[131];let Fe;e[132]!==ye||e[133]!==ze?(Fe=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[ye,ze]}),e[132]=ye,e[133]=ze,e[134]=Fe):Fe=e[134],e[135]!==ve||e[136]!==Fe?(b=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,Fe]}),e[135]=ve,e[136]=Fe,e[137]=b):b=e[137],c=fe;let Le;e[138]!==a?(Le=a("Statements"),e[138]=a,e[139]=Le):Le=e[139];let Ee;e[140]!==Le?(Ee=(0,t.jsx)(Pe,{children:Le}),e[140]=Le,e[141]=Ee):Ee=e[141],M=(0,t.jsxs)(Ae,{children:[Ee,(0,t.jsx)(ht,{children:a("{count} tracked statements",{count:I.length})})]}),f=pe,N="space-y-2";let He;e[142]!==n||e[143]!==a?(He=d(z=>{let ue=z.normalizedSql,G=n.has(ue),he=Xe(z.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":G,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:d(()=>{$(ue)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(ar,{level:he}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:z.normalizedSql})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.totalDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),z.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.p95DurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:We(z.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),G&&(0,t.jsxs)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),(0,t.jsx)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:z.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[z.p50DurationMs!==void 0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("p50")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:je(z.p50DurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Exec count")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.execCount)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Total time")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:je(z.totalDurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows read")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.rowsRead)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows written")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.rowsWritten)})]})]})]})]},ue)},"Ke"),e[142]=n,e[143]=a,e[144]=He):He=e[144],q=I.map(He)}e[2]=n,e[3]=s,e[4]=r,e[5]=a,e[6]=f,e[7]=c,e[8]=p,e[9]=N,e[10]=q,e[11]=M,e[12]=o,e[13]=k,e[14]=x,e[15]=b}else f=e[6],c=e[7],p=e[8],N=e[9],q=e[10],M=e[11],o=e[12],k=e[13],x=e[14],b=e[15];if(p!==Symbol.for("react.early_return_sentinel"))return p;let _;e[145]!==N||e[146]!==q?(_=(0,t.jsx)("div",{className:N,children:q}),e[145]=N,e[146]=q,e[147]=_):_=e[147];let D;e[148]!==f||e[149]!==_?(D=(0,t.jsx)(f,{children:_}),e[148]=f,e[149]=_,e[150]=D):D=e[150];let u;e[151]!==c||e[152]!==D||e[153]!==M?(u=(0,t.jsxs)(c,{children:[M,D]}),e[151]=c,e[152]=D,e[153]=M,e[154]=u):u=e[154];let C;return e[155]!==u||e[156]!==o||e[157]!==k||e[158]!==x||e[159]!==b?(C=(0,t.jsxs)("div",{className:o,"data-testid":k,children:[x,b,u]}),e[155]=u,e[156]=o,e[157]=k,e[158]=x,e[159]=b,e[160]=C):C=e[160],C},"ar");function nr(l){return Xe(l.avgDurationMs)==="critical"}d(nr,"ir");function ir(l){return Xe(l.avgDurationMs)==="warning"}d(ir,"nr");function or(l){return Xe(l.avgDurationMs)==="good"}d(or,"or");var dr=["1m","5m","15m","1h"],cr=d(l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"dr"),mr=d(l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:cr(e.bucketMs)})),"mr"),ur=d(({shardKey:l=""})=>{let e=ge(),[s,a]=(0,B.useState)("15m"),r=$e(Ke.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,h=mr(r?.buckets??[]);return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:dr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===s,className:ut("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:d(()=>{a(i)},"onClick"),type:"button",children:i},i))}),r?.capped===!0&&(0,t.jsx)(Ge,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),h.length===0?(0,t.jsx)(gt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):(0,t.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(St,{data:h,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(yt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(wt,{data:h,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(Nt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(lr,{queryStats:r?.entries??[]})]})},"ur"),hr=ft(Ke.getMetrics),gr=d((l,e)=>l?e:"overview","hr"),Or=d(({initialShardKey:l})=>{let e=mt(),s=ge(),{queryShardKey:a,setShardKey:r,shardKey:h}=Mt(l),[i,n]=(0,B.useState)("overview"),[g,v]=(0,B.useState)([]),S=(0,B.useRef)(null),f=(0,B.useRef)(null),c=(0,B.useRef)(!0);(0,B.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=Lt(a),{data:N,error:q,liveError:M}=$e(Ke.getMetrics,{},{live:!0,shardKey:a}),o=N??null;(0,B.useEffect)(()=>{if(N===void 0)return;kt(a);let L=N,U=S.current,Q=f.current!==null&&f.current!==L.shard;if(f.current=L.shard,S.current=L.requests,Q){v([]);return}U!==null&&L.requests>=U&&v(K=>[...K,L.requests-U].slice(-30))},[N,a]);let[k,x]=(0,B.useState)(null),[b,_]=(0,B.useState)(!1),D=d(async()=>{_(!0);let L=h,U=At(L,qt());try{let Q=await Promise.all(U.map(async K=>{try{let O=await e.query(hr,{},pt(K));return{error:null,metrics:O,shard:K===""?O.shard:K}}catch(O){return{error:xt(O),metrics:null,shard:K===""?"__root__":K}}}));c.current&&x({results:Q,shard:L})}finally{c.current&&_(!1)}},"R"),u=k?.shard===h?k.results:null,C=u===null?null:Kt(u),I=o===null||o.requests===0?"\u2014":`${(o.errors/o.requests*100).toFixed(1)}%`,R=g.length>0?g.at(-1):0,T=o?Pt(o):{p90:0,p95:0},w=(0,B.useMemo)(()=>{if(!o||!("queryStats"in o))return;let L=o.queryStats;if(!(!L||!Array.isArray(L)))return $t(L)},[o]),y=gr(w!==void 0,i),F=d(()=>{vt(D())},"A"),A=d(()=>{x(null)},"F"),P=d(()=>{n("overview")},"z"),$=d(()=>{n("query-insights")},"O");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(_t,{onChange:r,testId:"mt-shard-input",value:h}),(0,t.jsx)(Dt,{message:M,prefix:"mt"}),(0,t.jsx)(Je,{"data-testid":"mt-aggregate",disabled:b,onClick:F,size:"sm",type:"button",variant:"secondary",children:s(b?"Aggregating\u2026":"All shards")}),u!==null&&(0,t.jsx)(Je,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")}),(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:Ct,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")})]}),q!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),w!==void 0&&(0,t.jsxs)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsx)("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:P,type:"button",children:s("Overview")}),(0,t.jsxs)("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:$,type:"button",children:[s("Query insights"),w.length>0&&(0,t.jsx)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:w.length})]})]}),y==="query-insights"&&w!==void 0&&(0,t.jsx)(ur,{shardKey:a}),y==="overview"&&o!==null&&(0,t.jsx)(rr,{currentDelta:R,errorRate:I,history:g,latencyPercentiles:T,metrics:o}),y==="overview"&&o===null&&null,y==="overview"&&(0,t.jsx)(er,{onOpenTrace:p,shardKey:a}),y==="overview"&&C!==null&&u!==null&&(0,t.jsx)(tr,{aggregate:C,shardResults:u})]})},"Qr");export{Or as MetricsPanel};
1
+ import{a as Ot,b as Qt,c as ot}from"./chunk-CVXNHIQW.js";import{a as me}from"./chunk-253UHWDX.js";import{a as Kt,b as At,c as Pt,d as $t}from"./chunk-2I4NHEKA.js";import{a as it}from"./chunk-D6ZXOSCM.js";import{a as It,b as Rt,c as Tt,d as zt,e as Qe}from"./chunk-5QR2SQIS.js";import{a as Ft}from"./chunk-VCFEO3RI.js";import{a as Lt}from"./chunk-ZQ4C2DMJ.js";import"./chunk-VESGIGMQ.js";import"./chunk-NRP22GKC.js";import{e as Ct}from"./chunk-UYEZR3BI.js";import"./chunk-OPM7ESDV.js";import{a as Dt}from"./chunk-D746I7ZX.js";import"./chunk-NXQW5E6W.js";import"./chunk-UC7MNI2F.js";import"./chunk-NGVP66OH.js";import"./chunk-GHQ2VDI2.js";import{a as Ze,b as et,c as tt,d as Nt,e as yt,f as rt,g as at,h as wt,i as St}from"./chunk-DVX5J34S.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import{a as Mt}from"./chunk-R6U22RSY.js";import{a as _t}from"./chunk-2EYOYWS2.js";import{a as qt,b as kt}from"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-OQ6I6OXT.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{a as Je}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Ge}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as Ke}from"./chunk-4ZEL6BYL.js";import{c as $e}from"./chunk-PYNRIX74.js";import{a as ct,l as mt}from"./chunk-BDYCZHD2.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as gt}from"./chunk-RWVIV3U7.js";import{a as st,b as lt,c as nt,d as Oe,e as ce,f as V}from"./chunk-HCTJKP5J.js";import{a as fe,b as Ae,c as Pe,d as ht,e as pe}from"./chunk-2IKDEUCX.js";import{d as ge,f as ft,g as pt,h as xt,i as bt,l as Ve,p as vt}from"./chunk-5OMZCVRF.js";import{a as d,d as Ye,e as Et,f as Ht,g as Ut,i as ut}from"./chunk-I26MS5PJ.js";var B=Ye(Et(),1);var xe=Ye(Ht(),1);var t=Ye(Ut(),1);var jt=d((l,e,s)=>`${l}:${e}:${ct(s??{})}`,"ut"),Bt=d((l,e)=>l==="gauge"?e.last:l==="histogram"?e.sum/Math.max(1,e.count):e.sum,"ft"),Gt=d((l,e)=>Bt(l,e),"jt"),Vt=d(l=>Bt(l.kind,l),"Gt"),dt=d(l=>Number.isInteger(l)?l.toLocaleString():l.toLocaleString(void 0,{maximumFractionDigits:2}),"We"),Wt=d(l=>Array.isArray(l?.series)?l.series:[],"Jt"),Xt="FUNCTION_NOT_FOUND",Yt=d(l=>{let e=new Map;if(!Array.isArray(l?.series))return e;for(let s of l.series)e.set(jt(s.kind,s.name,s.attributes),s.points);return e},"Xt"),Jt={counter:"secondary",gauge:"default",histogram:"outline"},Zt=d(l=>{let e=(0,xe.c)(18),{name:s,onOpenTrace:a,traceId:r}=l,h=ge();if(r===void 0){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}),e[0]=c):c=e[0],c}let i;e[1]!==r?(i=r.slice(0,8),e[1]=r,e[2]=i):i=e[2];let n=i;if(a===void 0){let c=`mt-instrument-trace-${s}`,p;return e[3]!==n||e[4]!==c||e[5]!==r?(p=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":c,title:r,children:n}),e[3]=n,e[4]=c,e[5]=r,e[6]=p):p=e[6],p}let g=`mt-instrument-trace-${s}`,v;e[7]!==a||e[8]!==r?(v=d(()=>{a(r)},"v"),e[7]=a,e[8]=r,e[9]=v):v=e[9];let S;e[10]!==h||e[11]!==r?(S=h("Open the exemplar trace {trace}",{trace:r}),e[10]=h,e[11]=r,e[12]=S):S=e[12];let f;return e[13]!==n||e[14]!==g||e[15]!==v||e[16]!==S?(f=(0,t.jsx)("button",{className:"text-primary underline-offset-4 hover:underline","data-testid":g,onClick:v,title:S,type:"button",children:n}),e[13]=n,e[14]=g,e[15]=v,e[16]=S,e[17]=f):f=e[17],f},"Zt"),er=d(l=>{let e=(0,xe.c)(105),{onOpenTrace:s,shardKey:a}=l,r=ge(),h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={},e[0]=h):h=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];let{data:n,error:g,errorSource:v}=$e(Ke.getMetricSeries,h,i),S;e[3]===Symbol.for("react.memo_cache_sentinel")?(S={},e[3]=S):S=e[3];let f;e[4]!==a?(f={live:!0,shardKey:a},e[4]=a,e[5]=f):f=e[5];let{data:c}=$e(Ke.getMetricHistory,S,f),p,N,q,M,o,k,x,b,_,D,u,C,I;if(e[6]!==n||e[7]!==g||e[8]!==v||e[9]!==c||e[10]!==s||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{let A=Wt(n),P=bt(v)===Xt;if(g!==null&&!P){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let j;e[27]!==m?(j=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=j):j=e[28];let E;e[29]!==g||e[30]!==r?(E=r("Instruments unavailable: {error}",{error:g}),e[29]=g,e[30]=r,e[31]=E):E=e[31];let H;e[32]!==E?(H=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:E}),e[32]=E,e[33]=H):H=e[33];let de;e[34]!==j||e[35]!==H?(de=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[j,H]}),e[34]=j,e[35]=H,e[36]=de):de=e[36],b=de;break e}if(A.length===0){b=null;break e}let $=Yt(c),L;e[37]!==r?(L=d(m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),"L"),e[37]=r,e[38]=L):L=e[38];let U=L;o="flex flex-col gap-2",k="mt-instruments";let Q;e[39]!==r?(Q=r("Instruments"),e[39]=r,e[40]=Q):Q=e[40],e[41]!==Q?(x=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:Q}),e[41]=Q,e[42]=x):x=e[42],M=fe,I="overflow-hidden py-0",q=pe,C="px-0",N=st,D="mt-instruments-table";let K;e[43]!==r?(K=r("name"),e[43]=r,e[44]=K):K=e[44];let O;e[45]!==K?(O=(0,t.jsx)(ce,{children:K}),e[45]=K,e[46]=O):O=e[46];let W;e[47]!==r?(W=r("kind"),e[47]=r,e[48]=W):W=e[48];let X;e[49]!==W?(X=(0,t.jsx)(ce,{children:W}),e[49]=W,e[50]=X):X=e[50];let Y;e[51]!==r?(Y=r("value"),e[51]=r,e[52]=Y):Y=e[52];let J;e[53]!==Y?(J=(0,t.jsx)(ce,{className:"text-right",children:Y}),e[53]=Y,e[54]=J):J=e[54];let Z;e[55]!==r?(Z=r("count"),e[55]=r,e[56]=Z):Z=e[56];let ee;e[57]!==Z?(ee=(0,t.jsx)(ce,{className:"text-right",children:Z}),e[57]=Z,e[58]=ee):ee=e[58];let te;e[59]!==r?(te=r("range"),e[59]=r,e[60]=te):te=e[60];let re;e[61]!==te?(re=(0,t.jsx)(ce,{className:"text-right",children:te}),e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==r?(ae=r("trend"),e[63]=r,e[64]=ae):ae=e[64];let se;e[65]!==ae?(se=(0,t.jsx)(ce,{children:ae}),e[65]=ae,e[66]=se):se=e[66];let le;e[67]!==r?(le=r("trace"),e[67]=r,e[68]=le):le=e[68];let ne;e[69]!==le?(ne=(0,t.jsx)(ce,{children:le}),e[69]=le,e[70]=ne):ne=e[70];let ie;e[71]!==r?(ie=r("dimensions"),e[71]=r,e[72]=ie):ie=e[72];let oe;e[73]!==ie?(oe=(0,t.jsx)(ce,{children:ie}),e[73]=ie,e[74]=oe):oe=e[74],e[75]!==O||e[76]!==X||e[77]!==J||e[78]!==ee||e[79]!==re||e[80]!==se||e[81]!==ne||e[82]!==oe?(u=(0,t.jsx)(lt,{children:(0,t.jsxs)(Oe,{children:[O,X,J,ee,re,se,ne,oe]})}),e[75]=O,e[76]=X,e[77]=J,e[78]=ee,e[79]=re,e[80]=se,e[81]=ne,e[82]=oe,e[83]=u):u=e[83],p=nt,_=A.map(m=>{let j=Ft(m.attributes),E=jt(m.kind,m.name,m.attributes),H=($.get(E)??[]).map(de=>Gt(m.kind,de));return(0,t.jsxs)(Oe,{"data-testid":`mt-instrument-${m.name}`,children:[(0,t.jsx)(V,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),(0,t.jsx)(V,{children:(0,t.jsx)(Ge,{variant:Jt[m.kind],children:U(m.kind)})}),(0,t.jsx)(V,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:dt(Vt(m))}),(0,t.jsx)(V,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),(0,t.jsx)(V,{className:"text-right font-mono text-xs tabular-nums text-muted-foreground",children:m.min===m.max?"\u2014":`${dt(m.min)}\u2013${dt(m.max)}`}),(0,t.jsx)(V,{children:H.length>=2?(0,t.jsx)(it,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:H,testId:`mt-instrument-trend-${m.name}`}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(V,{className:"font-mono text-xs",children:(0,t.jsx)(Zt,{name:m.name,onOpenTrace:s,traceId:m.exemplarTraceId})}),(0,t.jsx)(V,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:j,children:j===""?"\u2014":j})]},E)})}e[6]=n,e[7]=g,e[8]=v,e[9]=c,e[10]=s,e[11]=r,e[12]=p,e[13]=N,e[14]=q,e[15]=M,e[16]=o,e[17]=k,e[18]=x,e[19]=b,e[20]=_,e[21]=D,e[22]=u,e[23]=C,e[24]=I}else p=e[12],N=e[13],q=e[14],M=e[15],o=e[16],k=e[17],x=e[18],b=e[19],_=e[20],D=e[21],u=e[22],C=e[23],I=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let R;e[84]!==p||e[85]!==_?(R=(0,t.jsx)(p,{children:_}),e[84]=p,e[85]=_,e[86]=R):R=e[86];let T;e[87]!==N||e[88]!==R||e[89]!==D||e[90]!==u?(T=(0,t.jsxs)(N,{"data-testid":D,children:[u,R]}),e[87]=N,e[88]=R,e[89]=D,e[90]=u,e[91]=T):T=e[91];let w;e[92]!==q||e[93]!==T||e[94]!==C?(w=(0,t.jsx)(q,{className:C,children:T}),e[92]=q,e[93]=T,e[94]=C,e[95]=w):w=e[95];let y;e[96]!==M||e[97]!==w||e[98]!==I?(y=(0,t.jsx)(M,{className:I,children:w}),e[96]=M,e[97]=w,e[98]=I,e[99]=y):y=e[99];let F;return e[100]!==o||e[101]!==k||e[102]!==x||e[103]!==y?(F=(0,t.jsxs)("section",{className:o,"data-testid":k,children:[x,y]}),e[100]=o,e[101]=k,e[102]=x,e[103]=y,e[104]=F):F=e[104],F},"er"),tr=d(l=>{let e=(0,xe.c)(74),{aggregate:s,shardResults:a}=l,r=ge(),h;e[0]!==r?(h=r("Shards"),e[0]=r,e[1]=h):h=e[1];let i;e[2]!==s.failed||e[3]!==s.reachable||e[4]!==r?(i=s.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:s.failed,reachable:s.reachable}):r("{reachable} reachable",{reachable:s.reachable}),e[2]=s.failed,e[3]=s.reachable,e[4]=r,e[5]=i):i=e[5];let n;e[6]!==h||e[7]!==i?(n=(0,t.jsx)(me,{label:h,testId:"mt-agg-shards",value:i}),e[6]=h,e[7]=i,e[8]=n):n=e[8];let g;e[9]!==r?(g=r("Total requests"),e[9]=r,e[10]=g):g=e[10];let v;e[11]!==s.totalRequests||e[12]!==g?(v=(0,t.jsx)(me,{label:g,testId:"mt-agg-requests",value:s.totalRequests}),e[11]=s.totalRequests,e[12]=g,e[13]=v):v=e[13];let S;e[14]!==r?(S=r("Total errors"),e[14]=r,e[15]=S):S=e[15];let f;e[16]!==s.totalErrors||e[17]!==S?(f=(0,t.jsx)(me,{label:S,testId:"mt-agg-errors",value:s.totalErrors}),e[16]=s.totalErrors,e[17]=S,e[18]=f):f=e[18];let c;e[19]!==r?(c=r("Total database size"),e[19]=r,e[20]=c):c=e[20];let p;e[21]!==s.totalDatabaseSize?(p=Ve(s.totalDatabaseSize),e[21]=s.totalDatabaseSize,e[22]=p):p=e[22];let N;e[23]!==c||e[24]!==p?(N=(0,t.jsx)(me,{label:c,testId:"mt-agg-db-size",value:p}),e[23]=c,e[24]=p,e[25]=N):N=e[25];let q;e[26]!==r?(q=r("Combined cache hit rate"),e[26]=r,e[27]=q):q=e[27];let M;e[28]!==s.hitRate||e[29]!==r?(M=s.hitRate===null?r("no cache configured"):`${(s.hitRate*100).toFixed(1)}%`,e[28]=s.hitRate,e[29]=r,e[30]=M):M=e[30];let o;e[31]!==q||e[32]!==M?(o=(0,t.jsx)(me,{label:q,testId:"mt-agg-cache",value:M}),e[31]=q,e[32]=M,e[33]=o):o=e[33];let k;e[34]!==N||e[35]!==o||e[36]!==n||e[37]!==v||e[38]!==f?(k=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3","data-testid":"mt-aggregate-stats",children:[n,v,f,N,o]}),e[34]=N,e[35]=o,e[36]=n,e[37]=v,e[38]=f,e[39]=k):k=e[39];let x;e[40]!==r?(x=r("shard"),e[40]=r,e[41]=x):x=e[41];let b;e[42]!==x?(b=(0,t.jsx)(ce,{children:x}),e[42]=x,e[43]=b):b=e[43];let _;e[44]!==r?(_=r("requests"),e[44]=r,e[45]=_):_=e[45];let D;e[46]!==_?(D=(0,t.jsx)(ce,{children:_}),e[46]=_,e[47]=D):D=e[47];let u;e[48]!==r?(u=r("errors"),e[48]=r,e[49]=u):u=e[49];let C;e[50]!==u?(C=(0,t.jsx)(ce,{children:u}),e[50]=u,e[51]=C):C=e[51];let I;e[52]!==r?(I=r("db size"),e[52]=r,e[53]=I):I=e[53];let R;e[54]!==I?(R=(0,t.jsx)(ce,{children:I}),e[54]=I,e[55]=R):R=e[55];let T;e[56]!==b||e[57]!==D||e[58]!==C||e[59]!==R?(T=(0,t.jsx)(lt,{children:(0,t.jsxs)(Oe,{children:[b,D,C,R]})}),e[56]=b,e[57]=D,e[58]=C,e[59]=R,e[60]=T):T=e[60];let w;if(e[61]!==a||e[62]!==r){let P;e[64]!==r?(P=d($=>(0,t.jsxs)(Oe,{"data-testid":`mt-agg-row-${$.shard}`,children:[(0,t.jsx)(V,{children:$.shard}),$.metrics===null?(0,t.jsx)(V,{className:"text-destructive",colSpan:3,children:$.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(V,{className:"tabular-nums",children:$.metrics.requests}),(0,t.jsx)(V,{className:"tabular-nums",children:$.metrics.errors}),(0,t.jsx)(V,{className:"tabular-nums",children:Ve($.metrics.databaseSize)})]})]},$.shard),"z"),e[64]=r,e[65]=P):P=e[65],w=a.map(P),e[61]=a,e[62]=r,e[63]=w}else w=e[63];let y;e[66]!==w?(y=(0,t.jsx)(nt,{children:w}),e[66]=w,e[67]=y):y=e[67];let F;e[68]!==T||e[69]!==y?(F=(0,t.jsx)(fe,{className:"overflow-hidden py-0",children:(0,t.jsx)(pe,{className:"px-0",children:(0,t.jsxs)(st,{"data-testid":"mt-agg-table",children:[T,y]})})}),e[68]=T,e[69]=y,e[70]=F):F=e[70];let A;return e[71]!==k||e[72]!==F?(A=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[k,F]}),e[71]=k,e[72]=F,e[73]=A):A=e[73],A},"tr"),rr=d(l=>{let e=(0,xe.c)(75),{currentDelta:s,errorRate:a,history:r,latencyPercentiles:h,metrics:i}=l,n=ge(),{cache:g}=i,v;e[0]!==r||e[1]!==n?(v=r.length>=2?(0,t.jsx)(it,{ariaLabel:n("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=n,e[2]=v):v=e[2];let S;e[3]!==s||e[4]!==r.length||e[5]!==n?(S=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${s.toLocaleString()}`})," ",n("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:n("collecting samples\u2026")}),e[3]=s,e[4]=r.length,e[5]=n,e[6]=S):S=e[6];let f;e[7]!==n?(f=n("Requests"),e[7]=n,e[8]=f):f=e[8];let c;e[9]!==i.requests||e[10]!==v||e[11]!==S||e[12]!==f?(c=(0,t.jsx)(me,{chart:v,footer:S,label:f,testId:"mt-requests",value:i.requests}),e[9]=i.requests,e[10]=v,e[11]=S,e[12]=f,e[13]=c):c=e[13];let p;e[14]!==a||e[15]!==n?(p=n("{rate} error rate",{rate:a}),e[14]=a,e[15]=n,e[16]=p):p=e[16];let N;e[17]!==n?(N=n("Errors"),e[17]=n,e[18]=N):N=e[18];let q;e[19]!==a||e[20]!==i.errors?(q=(0,t.jsxs)(t.Fragment,{children:[i.errors," (",a,")"]}),e[19]=a,e[20]=i.errors,e[21]=q):q=e[21];let M;e[22]!==p||e[23]!==N||e[24]!==q?(M=(0,t.jsx)(me,{footer:p,label:N,testId:"mt-errors",value:q}),e[22]=p,e[23]=N,e[24]=q,e[25]=M):M=e[25];let o;e[26]!==h.p90?(o=h.p90>0?`P90 ${ot(h.p90)}`:void 0,e[26]=h.p90,e[27]=o):o=e[27];let k;e[28]!==n?(k=n("P95 latency"),e[28]=n,e[29]=k):k=e[29];let x;e[30]!==h.p95?(x=h.p95>0?ot(h.p95):"\u2014",e[30]=h.p95,e[31]=x):x=e[31];let b;e[32]!==k||e[33]!==x||e[34]!==o?(b=(0,t.jsx)(me,{footer:o,label:k,testId:"mt-p95",value:x}),e[32]=k,e[33]=x,e[34]=o,e[35]=b):b=e[35];let _;e[36]!==g||e[37]!==n?(_=g?`${g.entries.toLocaleString()} ${n("cache entries")}`:void 0,e[36]=g,e[37]=n,e[38]=_):_=e[38];let D;e[39]!==n?(D=n("Database size"),e[39]=n,e[40]=D):D=e[40];let u;e[41]!==i.databaseSize?(u=Ve(i.databaseSize),e[41]=i.databaseSize,e[42]=u):u=e[42];let C;e[43]!==_||e[44]!==D||e[45]!==u?(C=(0,t.jsx)(me,{footer:_,label:D,testId:"mt-db-size",value:u}),e[43]=_,e[44]=D,e[45]=u,e[46]=C):C=e[46];let I;e[47]!==n?(I=n("Shard"),e[47]=n,e[48]=I):I=e[48];let R;e[49]!==i.shard||e[50]!==I?(R=(0,t.jsx)(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=R):R=e[51];let T;e[52]!==n?(T=n("Uptime"),e[52]=n,e[53]=T):T=e[53];let w;e[54]!==i.uptimeMs?(w=Ot(i.uptimeMs),e[54]=i.uptimeMs,e[55]=w):w=e[55];let y;e[56]!==T||e[57]!==w?(y=(0,t.jsx)(me,{label:T,testId:"mt-uptime",value:w}),e[56]=T,e[57]=w,e[58]=y):y=e[58];let F;e[59]!==n?(F=n("Cache hit rate"),e[59]=n,e[60]=F):F=e[60];let A;e[61]!==g||e[62]!==n?(A=g?n("{rate} ({count} entries)",{count:g.entries,rate:Qt(g.hits,g.misses)}):n("no cache configured"),e[61]=g,e[62]=n,e[63]=A):A=e[63];let P;e[64]!==F||e[65]!==A?(P=(0,t.jsx)(me,{label:F,testId:"mt-cache",value:A}),e[64]=F,e[65]=A,e[66]=P):P=e[66];let $;return e[67]!==b||e[68]!==C||e[69]!==R||e[70]!==y||e[71]!==P||e[72]!==c||e[73]!==M?($=(0,t.jsxs)("dl",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4","data-testid":"mt-stats",children:[c,M,b,C,R,y,P]}),e[67]=b,e[68]=C,e[69]=R,e[70]=y,e[71]=P,e[72]=c,e[73]=M,e[74]=$):$=e[74],$},"rr"),Xe=d(l=>l>=100?"critical":l>=50?"warning":"good","Ge"),je=d(l=>l<1?`${(l*1e3).toFixed(0)}\u03BCs`:l<1e3?`${l.toFixed(1)}ms`:`${(l/1e3).toFixed(2)}s`,"Ee"),We=d(l=>l>=1e9?`${(l/1e9).toFixed(1)}B`:l>=1e6?`${(l/1e6).toFixed(1)}M`:l>=1e3?`${(l/1e3).toFixed(1)}K`:l.toLocaleString(),"Ue"),ar=d(l=>{let e=(0,xe.c)(3),{level:s}=l;if(s==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(Ge,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(s==="warning"){let r;return e[1]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-warning/10 px-2 py-0.5 text-xs font-medium text-warning",children:"Moderate"}),e[1]=r):r=e[1],r}let a;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=(0,t.jsx)("span",{className:"inline-flex items-center gap-1 rounded-md border border-transparent bg-success/10 px-2 py-0.5 text-xs font-medium text-success",children:"Fast"}),e[2]=a):a=e[2],a},"sr"),sr=d((l,e)=>{let s=[...l];return s.sort((a,r)=>{switch(e){case"avgTime":return r.avgDurationMs-a.avgDurationMs;case"execCount":return r.execCount-a.execCount;case"rowsRead":return r.rowsRead-a.rowsRead;default:return r.totalDurationMs-a.totalDurationMs}}),s},"lr"),lr=d(l=>{let e=(0,xe.c)(161),{queryStats:s}=l,a=ge(),[r,h]=(0,B.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[n,g]=(0,B.useState)(i),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=d(I=>{I!==null&&h(I)},"v"),e[1]=v):v=e[1];let S=v,f,c,p,N,q,M,o,k,x,b;if(e[2]!==n||e[3]!==s||e[4]!==r||e[5]!==a){p=Symbol.for("react.early_return_sentinel");e:{let I=sr(s,r),R;e[16]!==s?(R=s.filter(nr),e[16]=s,e[17]=R):R=e[17];let T=R.length,w;e[18]!==s?(w=s.filter(ir),e[18]=s,e[19]=w):w=e[19];let y=w.length,F;e[20]!==s?(F=s.filter(or),e[20]=s,e[21]=F):F=e[21];let A=F.length,P;e[22]===Symbol.for("react.memo_cache_sentinel")?(P=d(z=>{g(ue=>{let G=new Set(ue);return G.has(z)?G.delete(z):G.add(z),G})},"z"),e[22]=P):P=e[22];let $=P;if(s.length===0){let z;e[23]!==a?(z=a("No query insights yet"),e[23]=a,e[24]=z):z=e[24];let ue;e[25]!==z?(ue=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:z}),e[25]=z,e[26]=ue):ue=e[26];let G;e[27]!==a?(G=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=G):G=e[28];let he;e[29]!==G?(he=(0,t.jsx)("p",{className:"mt-1 text-sm",children:G}),e[29]=G,e[30]=he):he=e[30];let Ue;e[31]!==ue||e[32]!==he?(Ue=(0,t.jsx)(fe,{children:(0,t.jsx)(pe,{className:"py-12",children:(0,t.jsxs)("div",{className:"text-center text-muted-foreground",children:[ue,he]})})}),e[31]=ue,e[32]=he,e[33]=Ue):Ue=e[33],p=Ue;break e}o="space-y-4",k="qi-root";let L;e[34]!==a?(L=a("Critical queries"),e[34]=a,e[35]=L):L=e[35];let U;e[36]!==L?(U=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=U):U=e[37];let Q;e[38]!==T?(Q=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:T}),e[38]=T,e[39]=Q):Q=e[39];let K;e[40]!==a?(K=a(">100ms avg execution"),e[40]=a,e[41]=K):K=e[41];let O;e[42]!==K?(O=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:K}),e[42]=K,e[43]=O):O=e[43];let W;e[44]!==Q||e[45]!==O?(W=(0,t.jsxs)(pe,{children:[Q,O]}),e[44]=Q,e[45]=O,e[46]=W):W=e[46];let X;e[47]!==U||e[48]!==W?(X=(0,t.jsxs)(fe,{children:[U,W]}),e[47]=U,e[48]=W,e[49]=X):X=e[49];let Y;e[50]!==a?(Y=a("Moderate queries"),e[50]=a,e[51]=Y):Y=e[51];let J;e[52]!==Y?(J=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:Y})}),e[52]=Y,e[53]=J):J=e[53];let Z;e[54]!==y?(Z=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:y}),e[54]=y,e[55]=Z):Z=e[55];let ee;e[56]!==a?(ee=a("50\u2013100ms avg execution"),e[56]=a,e[57]=ee):ee=e[57];let te;e[58]!==ee?(te=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ee}),e[58]=ee,e[59]=te):te=e[59];let re;e[60]!==Z||e[61]!==te?(re=(0,t.jsxs)(pe,{children:[Z,te]}),e[60]=Z,e[61]=te,e[62]=re):re=e[62];let ae;e[63]!==J||e[64]!==re?(ae=(0,t.jsxs)(fe,{children:[J,re]}),e[63]=J,e[64]=re,e[65]=ae):ae=e[65];let se;e[66]!==a?(se=a("Fast queries"),e[66]=a,e[67]=se):se=e[67];let le;e[68]!==se?(le=(0,t.jsx)(Ae,{className:"pb-2",children:(0,t.jsx)(Pe,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ne;e[70]!==A?(ne=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:A}),e[70]=A,e[71]=ne):ne=e[71];let ie;e[72]!==a?(ie=a("<50ms avg execution"),e[72]=a,e[73]=ie):ie=e[73];let oe;e[74]!==ie?(oe=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:ie}),e[74]=ie,e[75]=oe):oe=e[75];let m;e[76]!==ne||e[77]!==oe?(m=(0,t.jsxs)(pe,{children:[ne,oe]}),e[76]=ne,e[77]=oe,e[78]=m):m=e[78];let j;e[79]!==le||e[80]!==m?(j=(0,t.jsxs)(fe,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=j):j=e[81],e[82]!==X||e[83]!==ae||e[84]!==j?(x=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[X,ae,j]}),e[82]=X,e[83]=ae,e[84]=j,e[85]=x):x=e[85];let E;e[86]!==a?(E=a("Query leaderboard"),e[86]=a,e[87]=E):E=e[87];let H;e[88]!==E?(H=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:E}),e[88]=E,e[89]=H):H=e[89];let de;e[90]!==r||e[91]!==a?(de=a("Slow queries sorted by {sortField}",{sortField:a(r)}),e[90]=r,e[91]=a,e[92]=de):de=e[92];let be;e[93]!==de?(be=(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:de}),e[93]=de,e[94]=be):be=e[94];let ve;e[95]!==H||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[H,be]}),e[95]=H,e[96]=be,e[97]=ve):ve=e[97];let Ne;e[98]!==a?(Ne=a("Sort by"),e[98]=a,e[99]=Ne):Ne=e[99];let ye;e[100]!==Ne?(ye=(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:Ne}),e[100]=Ne,e[101]=ye):ye=e[101];let we;e[102]!==a?(we=a("Sort queries by"),e[102]=a,e[103]=we):we=e[103];let Be;e[104]===Symbol.for("react.memo_cache_sentinel")?(Be=(0,t.jsx)(Rt,{}),e[104]=Be):Be=e[104];let Se;e[105]!==we?(Se=(0,t.jsx)(Tt,{"aria-label":we,className:"w-[140px]","data-testid":"qi-sort",children:Be}),e[105]=we,e[106]=Se):Se=e[106];let qe;e[107]!==a?(qe=a("Total time"),e[107]=a,e[108]=qe):qe=e[108];let ke;e[109]!==qe?(ke=(0,t.jsx)(Qe,{value:"totalTime",children:qe}),e[109]=qe,e[110]=ke):ke=e[110];let _e;e[111]!==a?(_e=a("Avg time"),e[111]=a,e[112]=_e):_e=e[112];let Me;e[113]!==_e?(Me=(0,t.jsx)(Qe,{value:"avgTime",children:_e}),e[113]=_e,e[114]=Me):Me=e[114];let De;e[115]!==a?(De=a("Execution count"),e[115]=a,e[116]=De):De=e[116];let Ce;e[117]!==De?(Ce=(0,t.jsx)(Qe,{value:"execCount",children:De}),e[117]=De,e[118]=Ce):Ce=e[118];let Ie;e[119]!==a?(Ie=a("Rows read"),e[119]=a,e[120]=Ie):Ie=e[120];let Re;e[121]!==Ie?(Re=(0,t.jsx)(Qe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Re):Re=e[122];let Te;e[123]!==ke||e[124]!==Me||e[125]!==Ce||e[126]!==Re?(Te=(0,t.jsxs)(zt,{children:[ke,Me,Ce,Re]}),e[123]=ke,e[124]=Me,e[125]=Ce,e[126]=Re,e[127]=Te):Te=e[127];let ze;e[128]!==r||e[129]!==Se||e[130]!==Te?(ze=(0,t.jsxs)(It,{onValueChange:S,value:r,children:[Se,Te]}),e[128]=r,e[129]=Se,e[130]=Te,e[131]=ze):ze=e[131];let Fe;e[132]!==ye||e[133]!==ze?(Fe=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[ye,ze]}),e[132]=ye,e[133]=ze,e[134]=Fe):Fe=e[134],e[135]!==ve||e[136]!==Fe?(b=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,Fe]}),e[135]=ve,e[136]=Fe,e[137]=b):b=e[137],c=fe;let Le;e[138]!==a?(Le=a("Statements"),e[138]=a,e[139]=Le):Le=e[139];let Ee;e[140]!==Le?(Ee=(0,t.jsx)(Pe,{children:Le}),e[140]=Le,e[141]=Ee):Ee=e[141],M=(0,t.jsxs)(Ae,{children:[Ee,(0,t.jsx)(ht,{children:a("{count} tracked statements",{count:I.length})})]}),f=pe,N="space-y-2";let He;e[142]!==n||e[143]!==a?(He=d(z=>{let ue=z.normalizedSql,G=n.has(ue),he=Xe(z.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":G,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:d(()=>{$(ue)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(ar,{level:he}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:z.normalizedSql})]}),(0,t.jsxs)("div",{className:"flex shrink-0 items-center gap-4",children:[(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.totalDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("total")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),z.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:je(z.p95DurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("p95")})]}),(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:We(z.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),G&&(0,t.jsxs)("div",{className:"space-y-3 border-t bg-muted/30 p-4",children:[(0,t.jsxs)("div",{children:[(0,t.jsx)("p",{className:"mb-2 text-sm font-medium",children:a("Full statement")}),(0,t.jsx)("pre",{className:"overflow-x-auto rounded-md bg-muted p-3 font-mono text-sm whitespace-pre-wrap break-all",children:z.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[z.p50DurationMs!==void 0&&(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("p50")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:je(z.p50DurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Exec count")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.execCount)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Total time")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:je(z.totalDurationMs)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows read")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.rowsRead)})]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("span",{className:"text-muted-foreground",children:a("Rows written")}),(0,t.jsx)("span",{className:"block font-medium tabular-nums",children:We(z.rowsWritten)})]})]})]})]},ue)},"Ke"),e[142]=n,e[143]=a,e[144]=He):He=e[144],q=I.map(He)}e[2]=n,e[3]=s,e[4]=r,e[5]=a,e[6]=f,e[7]=c,e[8]=p,e[9]=N,e[10]=q,e[11]=M,e[12]=o,e[13]=k,e[14]=x,e[15]=b}else f=e[6],c=e[7],p=e[8],N=e[9],q=e[10],M=e[11],o=e[12],k=e[13],x=e[14],b=e[15];if(p!==Symbol.for("react.early_return_sentinel"))return p;let _;e[145]!==N||e[146]!==q?(_=(0,t.jsx)("div",{className:N,children:q}),e[145]=N,e[146]=q,e[147]=_):_=e[147];let D;e[148]!==f||e[149]!==_?(D=(0,t.jsx)(f,{children:_}),e[148]=f,e[149]=_,e[150]=D):D=e[150];let u;e[151]!==c||e[152]!==D||e[153]!==M?(u=(0,t.jsxs)(c,{children:[M,D]}),e[151]=c,e[152]=D,e[153]=M,e[154]=u):u=e[154];let C;return e[155]!==u||e[156]!==o||e[157]!==k||e[158]!==x||e[159]!==b?(C=(0,t.jsxs)("div",{className:o,"data-testid":k,children:[x,b,u]}),e[155]=u,e[156]=o,e[157]=k,e[158]=x,e[159]=b,e[160]=C):C=e[160],C},"ar");function nr(l){return Xe(l.avgDurationMs)==="critical"}d(nr,"ir");function ir(l){return Xe(l.avgDurationMs)==="warning"}d(ir,"nr");function or(l){return Xe(l.avgDurationMs)==="good"}d(or,"or");var dr=["1m","5m","15m","1h"],cr=d(l=>new Date(l).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"dr"),mr=d(l=>l.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:cr(e.bucketMs)})),"mr"),ur=d(({shardKey:l=""})=>{let e=ge(),[s,a]=(0,B.useState)("15m"),r=$e(Ke.getQueryInsights,{range:s},{live:!0,shardKey:l}).data,h=mr(r?.buckets??[]);return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"qi-range",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)("div",{className:"flex gap-1 rounded-lg border border-border p-0.5","data-testid":"qi-ranges",role:"group",children:dr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===s,className:ut("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===s&&"bg-accent font-medium text-foreground"),"data-testid":`qi-range-${i}`,onClick:d(()=>{a(i)},"onClick"),type:"button",children:i},i))}),r?.capped===!0&&(0,t.jsx)(Ge,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),h.length===0?(0,t.jsx)(gt,{description:e("Statements executed in the selected window appear here, with throughput and latency over time."),testId:"qi-empty",title:e("No queries in this window.")}):(0,t.jsxs)("div",{className:"grid gap-4 lg:grid-cols-2",children:[(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-throughput",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Throughput")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(St,{data:h,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{allowDecimals:!1,fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(yt,{dataKey:"execs",fill:"var(--color-primary)",fillOpacity:.15,stroke:"var(--color-primary)",type:"monotone"})]})})]}),(0,t.jsxs)("figure",{className:"rounded-xl border border-border p-3","data-testid":"qi-latency",children:[(0,t.jsx)("figcaption",{className:"mb-2 text-xs font-medium text-muted-foreground",children:e("Mean latency (ms)")}),(0,t.jsx)(Ze,{height:140,width:"100%",children:(0,t.jsxs)(wt,{data:h,children:[(0,t.jsx)(tt,{strokeDasharray:"3 3",vertical:!1}),(0,t.jsx)(rt,{dataKey:"label",fontSize:10,tickLine:!1}),(0,t.jsx)(at,{fontSize:10,tickLine:!1,width:32}),(0,t.jsx)(et,{}),(0,t.jsx)(Nt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(lr,{queryStats:r?.entries??[]})]})},"ur"),hr=ft(Ke.getMetrics),gr=d((l,e)=>l?e:"overview","hr"),Or=d(({initialShardKey:l})=>{let e=mt(),s=ge(),{queryShardKey:a,setShardKey:r,shardKey:h}=Mt(l),[i,n]=(0,B.useState)("overview"),[g,v]=(0,B.useState)([]),S=(0,B.useRef)(null),f=(0,B.useRef)(null),c=(0,B.useRef)(!0);(0,B.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=Lt(a),{data:N,error:q,liveError:M}=$e(Ke.getMetrics,{},{live:!0,shardKey:a}),o=N??null;(0,B.useEffect)(()=>{if(N===void 0)return;kt(a);let L=N,U=S.current,Q=f.current!==null&&f.current!==L.shard;if(f.current=L.shard,S.current=L.requests,Q){v([]);return}U!==null&&L.requests>=U&&v(K=>[...K,L.requests-U].slice(-30))},[N,a]);let[k,x]=(0,B.useState)(null),[b,_]=(0,B.useState)(!1),D=d(async()=>{_(!0);let L=h,U=At(L,qt());try{let Q=await Promise.all(U.map(async K=>{try{let O=await e.query(hr,{},pt(K));return{error:null,metrics:O,shard:K===""?O.shard:K}}catch(O){return{error:xt(O),metrics:null,shard:K===""?"__root__":K}}}));c.current&&x({results:Q,shard:L})}finally{c.current&&_(!1)}},"R"),u=k?.shard===h?k.results:null,C=u===null?null:Kt(u),I=o===null||o.requests===0?"\u2014":`${(o.errors/o.requests*100).toFixed(1)}%`,R=g.length>0?g.at(-1):0,T=o?Pt(o):{p90:0,p95:0},w=(0,B.useMemo)(()=>{if(!o||!("queryStats"in o))return;let L=o.queryStats;if(!(!L||!Array.isArray(L)))return $t(L)},[o]),y=gr(w!==void 0,i),F=d(()=>{vt(D())},"A"),A=d(()=>{x(null)},"F"),P=d(()=>{n("overview")},"z"),$=d(()=>{n("query-insights")},"O");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-metrics",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(_t,{onChange:r,testId:"mt-shard-input",value:h}),(0,t.jsx)(Dt,{message:M,prefix:"mt"}),(0,t.jsx)(Je,{"data-testid":"mt-aggregate",disabled:b,onClick:F,size:"sm",type:"button",variant:"secondary",children:s(b?"Aggregating\u2026":"All shards")}),u!==null&&(0,t.jsx)(Je,{"data-testid":"mt-aggregate-clear",onClick:A,size:"sm",type:"button",variant:"ghost",children:s("Hide")}),(0,t.jsx)("a",{className:"text-sm text-primary underline-offset-4 hover:underline","data-testid":"mt-cf-link",href:Ct,rel:"noreferrer",target:"_blank",children:s("Open in Cloudflare")})]}),q!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"mt-error",role:"alert",children:q}),w!==void 0&&(0,t.jsxs)("div",{className:"flex gap-2 border-b","data-testid":"mt-tabs",children:[(0,t.jsx)("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:P,type:"button",children:s("Overview")}),(0,t.jsxs)("button",{className:`pb-2 text-sm font-medium transition-colors ${y==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:$,type:"button",children:[s("Query insights"),w.length>0&&(0,t.jsx)("span",{className:"ml-1.5 rounded-full bg-primary/10 px-1.5 py-0.5 text-xs text-primary",children:w.length})]})]}),y==="query-insights"&&w!==void 0&&(0,t.jsx)(ur,{shardKey:a}),y==="overview"&&o!==null&&(0,t.jsx)(rr,{currentDelta:R,errorRate:I,history:g,latencyPercentiles:T,metrics:o}),y==="overview"&&o===null&&null,y==="overview"&&(0,t.jsx)(er,{onOpenTrace:p,shardKey:a}),y==="overview"&&C!==null&&u!==null&&(0,t.jsx)(tr,{aggregate:C,shardResults:u})]})},"Qr");export{Or as MetricsPanel};
@@ -1,2 +1,2 @@
1
- import{a as fe}from"./chunk-ECY2JC5F.js";import"./chunk-NRP22GKC.js";import{a as ie}from"./chunk-Y3AYVFTK.js";import{a as pe}from"./chunk-JQXA2OYK.js";import"./chunk-UC7MNI2F.js";import{i as de}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as b}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ne}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as he}from"./chunk-3YH5TM3G.js";import"./chunk-NCPW7WHO.js";import"./chunk-WP2AS7SZ.js";import"./chunk-55UGUCQ6.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as ue}from"./chunk-DSIY2CMT.js";import{l as le}from"./chunk-BOYS4DOC.js";import"./chunk-QAQDMS6R.js";import"./chunk-N7LJO732.js";import{a as ce}from"./chunk-RWVIV3U7.js";import{d as oe,f as Z,g as ee,h as te,p as ae,s as me,t as re}from"./chunk-HJHSQPHW.js";import{a as i,d as Y,e as ge,f as ve,g as Ne,i as se}from"./chunk-I26MS5PJ.js";var t=Y(Ne(),1);var be=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"ge");var we=/https?:\/\/[^\s"'<>)]+/i,xe=i(a=>a===void 0?void 0:we.exec(a)?.[0],"re"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=/<a\s(?:[^>]*?\s)?href\s*=\s*["'](https?:\/\/[^"'\s]+)["']/iu,ke=/&(?:amp|#0*38|#x0*26);/giu,Se=i(a=>a===void 0?void 0:((a.html===void 0?void 0:Ce.exec(a.html)?.[1])??xe(a.text)??xe(a.html))?.replaceAll(ke,"&"),"ye"),Te=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"Ce"),Le=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"Se"),je=Z(B.clearCapturedMail),Me=Z(B.sendTestMail),_e=i(a=>{let e=(0,be.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:q,error:w,errorSource:C,isLoading:g,refetch:n}=ue(B.getCapturedMail,p),[k,f]=(0,N.useState)(null),[P,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,D]=(0,N.useState)(""),x=q?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(je,{},ee("")),S(null),n()}catch(m){f(te(m))}},"T"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let Q=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Me,{},ee("")),n()}catch(m){f(te(m))}},"k"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let R=L,j;e[8]!==n?(j=i(()=>{n()},"A"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==Q?(M=i(()=>{ae(Q())},"E"),e[10]=Q,e[11]=M):M=e[11];let U=M,_;e[12]!==R?(_=i(()=>{ae(R())},"L"),e[12]=R,e[13]=_):_=e[13];let W=_,z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{D(m.currentTarget.value)},"_"),e[14]=z):z=e[14];let G=z,$;e[15]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"M"),e[15]=$):$=e[15];let J=$,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"I"),e[16]=A):A=e[16];let K=A,O=Te(x,c),F=Le(O,P),d=Se(F),E;e[17]!==d?(E=i(()=>{d!==void 0&&me(d)},"z"),e[17]=d,e[18]=E):E=e[18];let V=E,H;e[19]!==d?(H=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"F"),e[19]=d,e[20]=H):H=e[20];let X=H,I;return e[21]!==x||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==U||e[28]!==V||e[29]!==G||e[30]!==X||e[31]!==J||e[32]!==K||e[33]!==W||e[34]!==F||e[35]!==v||e[36]!==O?(I={entries:x,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:U,onCopyLink:V,onFilterChange:G,onOpenLink:X,onSelectMessage:J,onSelectTab:K,onSendTest:W,selected:F,tab:v,visible:O},e[21]=x,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=U,e[28]=V,e[29]=G,e[30]=X,e[31]=J,e[32]=K,e[33]=W,e[34]=F,e[35]=v,e[36]=O,e[37]=I):I=e[37],I},"Ae"),ze=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,$e=i(a=>`${ze}${a}`,"Le"),Ke=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:q,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:P,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:D}=_e({limit:a}),x=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"x");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(b,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(b,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:q}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:D.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:P,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(b,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(b,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(b,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:x(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:$e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
1
+ import{a as fe}from"./chunk-ECY2JC5F.js";import"./chunk-NRP22GKC.js";import{a as ie}from"./chunk-Y3AYVFTK.js";import{a as pe}from"./chunk-JQXA2OYK.js";import"./chunk-UC7MNI2F.js";import{i as de}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as b}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as ne}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as he}from"./chunk-UQAMQR4Q.js";import"./chunk-NCPW7WHO.js";import"./chunk-3I6JC6NL.js";import"./chunk-55UGUCQ6.js";import{a as B}from"./chunk-4ZEL6BYL.js";import{c as ue}from"./chunk-PYNRIX74.js";import{l as le}from"./chunk-BDYCZHD2.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as ce}from"./chunk-RWVIV3U7.js";import{d as oe,f as Z,g as ee,h as te,p as ae,s as me,t as re}from"./chunk-5OMZCVRF.js";import{a as i,d as Y,e as ge,f as ve,g as Ne,i as se}from"./chunk-I26MS5PJ.js";var t=Y(Ne(),1);var be=Y(ve(),1);var N=Y(ge(),1);function ye({className:a,orientation:e="horizontal",...s}){return(0,t.jsx)(ie,{"data-slot":"separator",orientation:e,className:se("shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",a),...s})}i(ye,"ge");var we=/https?:\/\/[^\s"'<>)]+/i,xe=i(a=>a===void 0?void 0:we.exec(a)?.[0],"re"),y=i(a=>a===void 0?"":Array.isArray(a)?a.join(", "):a,"N"),Ce=/<a\s(?:[^>]*?\s)?href\s*=\s*["'](https?:\/\/[^"'\s]+)["']/iu,ke=/&(?:amp|#0*38|#x0*26);/giu,Se=i(a=>a===void 0?void 0:((a.html===void 0?void 0:Ce.exec(a.html)?.[1])??xe(a.text)??xe(a.html))?.replaceAll(ke,"&"),"ye"),Te=i((a,e)=>{let s=e.trim().toLowerCase();return s===""?a:a.filter(o=>`${o.subject} ${y(o.to)} ${y(o.cc)}`.toLowerCase().includes(s))},"Ce"),Le=i((a,e)=>{if(a.length!==0)return a.find(s=>s.id===e)??a[0]},"Se"),je=Z(B.clearCapturedMail),Me=Z(B.sendTestMail),_e=i(a=>{let e=(0,be.c)(38),{limit:s}=a,o=le(),p;e[0]!==s?(p={limit:s},e[0]=s,e[1]=p):p=e[1];let{data:q,error:w,errorSource:C,isLoading:g,refetch:n}=ue(B.getCapturedMail,p),[k,f]=(0,N.useState)(null),[P,S]=(0,N.useState)(null),[v,l]=(0,N.useState)("html"),[c,D]=(0,N.useState)(""),x=q?.entries??[],r=w??k,u=w===null?k:C,T;e[2]!==o||e[3]!==n?(T=i(async()=>{f(null);try{await o.query(je,{},ee("")),S(null),n()}catch(m){f(te(m))}},"T"),e[2]=o,e[3]=n,e[4]=T):T=e[4];let Q=T,L;e[5]!==o||e[6]!==n?(L=i(async()=>{f(null);try{await o.query(Me,{},ee("")),n()}catch(m){f(te(m))}},"k"),e[5]=o,e[6]=n,e[7]=L):L=e[7];let R=L,j;e[8]!==n?(j=i(()=>{n()},"A"),e[8]=n,e[9]=j):j=e[9],pe(j,!0);let M;e[10]!==Q?(M=i(()=>{ae(Q())},"E"),e[10]=Q,e[11]=M):M=e[11];let U=M,_;e[12]!==R?(_=i(()=>{ae(R())},"L"),e[12]=R,e[13]=_):_=e[13];let W=_,z;e[14]===Symbol.for("react.memo_cache_sentinel")?(z=i(m=>{D(m.currentTarget.value)},"_"),e[14]=z):z=e[14];let G=z,$;e[15]===Symbol.for("react.memo_cache_sentinel")?($=i(m=>{let{id:h}=m.currentTarget.dataset;h!==void 0&&S(h)},"M"),e[15]=$):$=e[15];let J=$,A;e[16]===Symbol.for("react.memo_cache_sentinel")?(A=i(m=>{let h=m.currentTarget.dataset.tab;(h==="headers"||h==="html"||h==="text")&&l(h)},"I"),e[16]=A):A=e[16];let K=A,O=Te(x,c),F=Le(O,P),d=Se(F),E;e[17]!==d?(E=i(()=>{d!==void 0&&me(d)},"z"),e[17]=d,e[18]=E):E=e[18];let V=E,H;e[19]!==d?(H=i(()=>{d!==void 0&&"window"in globalThis&&globalThis.window.open(d,"_blank","noopener")},"F"),e[19]=d,e[20]=H):H=e[20];let X=H,I;return e[21]!==x||e[22]!==r||e[23]!==u||e[24]!==c||e[25]!==g||e[26]!==d||e[27]!==U||e[28]!==V||e[29]!==G||e[30]!==X||e[31]!==J||e[32]!==K||e[33]!==W||e[34]!==F||e[35]!==v||e[36]!==O?(I={entries:x,error:r,errorSource:u,filter:c,isLoading:g,link:d,onClear:U,onCopyLink:V,onFilterChange:G,onOpenLink:X,onSelectMessage:J,onSelectTab:K,onSendTest:W,selected:F,tab:v,visible:O},e[21]=x,e[22]=r,e[23]=u,e[24]=c,e[25]=g,e[26]=d,e[27]=U,e[28]=V,e[29]=G,e[30]=X,e[31]=J,e[32]=K,e[33]=W,e[34]=F,e[35]=v,e[36]=O,e[37]=I):I=e[37],I},"Ae"),ze=`<meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src data:; style-src 'unsafe-inline'; font-src data:">`,$e=i(a=>`${ze}${a}`,"Le"),Ke=i(({limit:a=100})=>{let e=oe(),{entries:s,error:o,errorSource:p,filter:q,isLoading:w,link:C,onClear:g,onCopyLink:n,onFilterChange:k,onOpenLink:f,onSelectMessage:P,onSelectTab:S,onSendTest:v,selected:l,tab:c,visible:D}=_e({limit:a}),x=i(r=>e(r==="html"?"HTML":r==="text"?"Plain text":"Headers"),"x");return(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mail-panel",children:[(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,t.jsx)(b,{"data-testid":"mail-send-test",onClick:v,size:"sm",type:"button",variant:"outline",children:e("Send test")}),(0,t.jsx)(b,{"data-testid":"mail-clear",disabled:s.length===0,onClick:g,size:"sm",type:"button",variant:"outline",children:e("Clear inbox")}),s.length>0&&(0,t.jsx)(ne,{className:"ml-auto","data-testid":"mail-count",variant:"secondary",children:e("{count} messages",{count:s.length})})]}),o!==null&&(0,t.jsx)(he,{error:p,testId:"mail-error"}),o===null&&!w&&s.length===0&&(0,t.jsx)(ce,{description:e("Email your app sends in dev is captured here \u2014 nothing is delivered."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("path",{d:"M4 5h16v14H4z"}),(0,t.jsx)("path",{d:"m4 6 8 6 8-6"})]}),testId:"mail-empty",title:e("No captured email.")}),s.length>0&&(0,t.jsxs)("div",{className:"grid grid-cols-1 gap-4 md:grid-cols-[minmax(0,22rem)_1fr]","data-testid":"mail-reader",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,t.jsx)(de,{"aria-label":e("Search messages"),"data-testid":"mail-search",onChange:k,placeholder:e("Filter messages"),type:"search",value:q}),(0,t.jsx)(fe,{className:"max-h-[32rem] rounded-xl border border-border bg-card shadow-xs","data-testid":"mail-list",children:(0,t.jsx)("ul",{className:"divide-y",children:D.map(r=>{let u=r.id===l?.id;return(0,t.jsx)("li",{children:(0,t.jsxs)("button",{className:`flex w-full flex-col items-start gap-0.5 px-3 py-2 text-left text-sm hover:bg-muted/60 ${u?"bg-muted":""}`,"data-active":u,"data-id":r.id,"data-testid":"mail-list-item",onClick:P,type:"button",children:[(0,t.jsx)("span",{className:"w-full truncate font-medium",children:r.subject||e("(no subject)")}),(0,t.jsx)("span",{className:"w-full truncate text-xs text-muted-foreground",children:y(r.to)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:re(r.capturedAt,"\u2014")})]})},r.id)})})})]}),l!==void 0&&(0,t.jsxs)("div",{className:"flex min-w-0 flex-col gap-3 rounded-xl border border-border bg-card p-4 shadow-xs","data-testid":"mail-detail",children:[(0,t.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,t.jsx)("h2",{className:"truncate text-base font-semibold","data-testid":"mail-subject",children:l.subject||e("(no subject)")}),(0,t.jsxs)("dl",{className:"grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5 text-xs text-muted-foreground",children:[(0,t.jsx)("dt",{children:e("From")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:l.from??"\u2014"}),(0,t.jsx)("dt",{children:e("To")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.to)}),l.cc!==void 0&&l.cc.length>0&&(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("dt",{children:e("Cc")}),(0,t.jsx)("dd",{className:"truncate font-mono",children:y(l.cc)})]}),(0,t.jsx)("dt",{children:e("Sent")}),(0,t.jsx)("dd",{className:"tabular-nums",children:re(l.capturedAt,"\u2014")})]})]}),(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2","data-testid":"mail-actions",children:[(0,t.jsx)(b,{"data-testid":"mail-copy-link",disabled:C===void 0,onClick:n,size:"sm",type:"button",variant:"outline",children:e("Copy link")}),(0,t.jsx)(b,{"data-testid":"mail-open-link",disabled:C===void 0,onClick:f,size:"sm",type:"button",variant:"outline",children:e("Open in new tab")})]}),(0,t.jsx)(ye,{}),(0,t.jsx)("div",{className:"flex items-center gap-1","data-testid":"mail-tabs",role:"tablist",children:["html","text","headers"].map(r=>(0,t.jsx)(b,{"aria-selected":c===r,"data-tab":r,"data-testid":`mail-tab-${r}`,onClick:S,role:"tab",size:"sm",type:"button",variant:c===r?"secondary":"ghost",children:x(r)},r))}),(0,t.jsxs)("div",{className:"min-h-[12rem]",children:[c==="html"&&(l.html===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No HTML body.")}):(0,t.jsx)("iframe",{className:"h-[24rem] w-full rounded-md border bg-white","data-testid":"mail-preview-html",sandbox:"",srcDoc:$e(l.html),title:e("Email preview")})),c==="text"&&(l.text===void 0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No text body.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-text",children:l.text})),c==="headers"&&(l.headers===void 0||Object.keys(l.headers).length===0?(0,t.jsx)("p",{className:"text-sm text-muted-foreground",children:e("No headers.")}):(0,t.jsx)("pre",{className:"overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs","data-testid":"mail-preview-headers",children:Object.entries(l.headers).map(([r,u])=>`${r}: ${u}`).join(`
2
2
  `)}))]})]})]})]})},"Qe");export{Ke as MailPanel};
@@ -1 +1 @@
1
- import{a as O}from"./chunk-JQXA2OYK.js";import{a as H}from"./chunk-XHRKNCCI.js";import{a as ee}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Z}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as E}from"./chunk-DSIY2CMT.js";import{l as R}from"./chunk-BOYS4DOC.js";import"./chunk-QAQDMS6R.js";import"./chunk-N7LJO732.js";import{a as _}from"./chunk-RWVIV3U7.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-HCTJKP5J.js";import{a as A,e as T}from"./chunk-2IKDEUCX.js";import{d as M,h as G,p as W,t as X}from"./chunk-HJHSQPHW.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-I26MS5PJ.js";var U=P(re(),1),Y=P(oe(),1);var t=P(ae(),1);var se=P(re(),1);var Q=P(oe(),1);var h=P(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","X"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"F"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"Y"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,f=R(),r=M(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let v=await(d??(()=>f.listScheduledJobs()))();return le(v)}),[x,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),y,k;e[1]!==f||e[2]!==l?(y=c(()=>{if(l)return f.subscribeScheduledJobs(v=>{m(void 0),n(le(v))})},"v"),k=[l,f],e[1]=f,e[2]=l,e[3]=y,e[4]=k):(y=e[3],k=e[4]),(0,Q.useEffect)(y,k);let g;e[5]!==N?(g=c(()=>{N.refetch()},"y"),e[5]=N,e[6]=g):g=e[6],O(g,!l);let J=ce(f,i,d),b=x??N.data,j=s??N.error,I=c(async v=>{if(J!==void 0){m(void 0);try{await J(v),l||N.refetch()}catch(D){m(G(D))}}},"A"),q="flex flex-col gap-3",B="lunora-scheduled-jobs",S;e[7]!==j?(S=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=S):S=e[8];let L;e[9]!==b?.length||e[10]!==r?(L=b?.length===0&&(0,h.jsx)(_,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=L):L=e[11];let $=b!==void 0&&b.length>0&&(0,h.jsx)(A,{className:"overflow-hidden py-0",children:(0,h.jsx)(T,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(F,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(v=>(0,h.jsxs)(F,{"data-testid":`sj-row-${v.id}`,children:[(0,h.jsx)(p,{className:"font-mono text-xs",children:v.workflow??v.functionPath}),(0,h.jsx)(p,{className:"text-muted-foreground tabular-nums",children:ie(v.scheduledFor)}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.pool??""}),(0,h.jsx)(p,{className:"tabular-nums",children:v.attempts??0}),(0,h.jsx)(p,{children:v.shardKey??""}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.id}),J!==void 0&&(0,h.jsx)(p,{className:"text-right",children:(0,h.jsx)(H,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{W(I(v.id))},"onConfirm"),testId:`sj-cancel-${v.id}`,children:r("Cancel")})})]},v.id))})]})})}),w;return e[12]!==$||e[13]!==S||e[14]!==L?(w=(0,h.jsxs)("div",{className:q,"data-testid":B,children:[S,L,$]}),e[12]=$,e[13]=S,e[14]=L,e[15]=w):w=e[15],w},"he");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"re"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=R(),d=M(),[f,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,x=me(i,a,e),n=c(async s=>{if(x!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await x(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(y=>({...y,[s]:{kind:"error",message:G(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(_,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),x!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=f[s.name]??he;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(p,{children:s.name}),(0,t.jsx)(p,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(p,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(p,{children:s.shardKey??""}),x!==void 0&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(H,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{W(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),pe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","se"),fe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:f,retryJob:r}=i,l=R(),o=M(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let x;e[3]!==l||e[4]!==d?(x=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=x):x=e[5];let n=E(N,x),s=n.data,[m,y]=(0,Y.useState)(void 0),k=n.error??m,g=d===void 0,J;e[6]!==l||e[7]!==g||e[8]!==r?(J=r??(g?C=>l.retryDeadJob(C):void 0),e[6]=l,e[7]=g,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==g||e[12]!==f?(j=f??(g?C=>l.removeDeadJob(C):void 0),e[10]=l,e[11]=g,e[12]=f,e[13]=j):j=e[13];let I=j,q;e[14]!==n?(q=c(()=>{n.refetch()},"$"),e[14]=n,e[15]=q):q=e[15],O(q,!0);let B;e[16]!==n?(B=c(async C=>{y(void 0);try{await C,n.refetch()}catch(ne){y(G(ne))}},"I"),e[16]=n,e[17]=B):B=e[17];let S=B,L=b!==void 0||I!==void 0,$;e[18]!==k?($=k!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:k}),e[18]=k,e[19]=$):$=e[19];let w;e[20]!==s?.length||e[21]!==o?(w=s?.length===0&&(0,t.jsx)(_,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=w):w=e[22];let v;e[23]!==S||e[24]!==L||e[25]!==s||e[26]!==I||e[27]!==b||e[28]!==o?(v=s!==void 0&&s.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),L&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(C=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${C.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:C.workflow??C.functionPath}),(0,t.jsx)(p,{className:"tabular-nums",children:C.attempts??0}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:pe(C.scheduledFor)}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.pool??""}),(0,t.jsx)(p,{children:C.shardKey??""}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.id}),L&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${C.id}`,onClick:c(()=>{W(S(b(C.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),I!==void 0&&(0,t.jsx)(H,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{W(S(I(C.id)))},"onConfirm"),testId:`dlq-remove-${C.id}`,children:o("Drop")})]})})]},C.id))})]})})}),e[23]=S,e[24]=L,e[25]=s,e[26]=I,e[27]=b,e[28]=o,e[29]=v):v=e[29];let D;return e[30]!==v||e[31]!==$||e[32]!==w?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,w,v]}),e[30]=v,e[31]=$,e[32]=w,e[33]=D):D=e[33],D},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"oe");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:f}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==f?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(A,{className:"flex-1 py-0",children:(0,t.jsxs)(T,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"E"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,f=R(),r=M(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==f||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>f.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"y"),e[4]=f,e[5]=d,e[6]=N):N=e[6];let x=E(o,N),{data:n,error:s}=x,m;e[7]!==x?(m=c(()=>{x.refetch()},"d"),e[7]=x,e[8]=m):m=e[8],O(m,!0);let y;e[9]!==s?(y=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=y):y=e[10];let k;e[11]!==n||e[12]!==r?(k=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=k):k=e[13];let g;e[14]!==n?.pools.length||e[15]!==r?(g=n?.pools.length===0&&(0,t.jsx)(_,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=g):g=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==y||e[21]!==k||e[22]!==g||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[y,k,g,J]}),e[20]=y,e[21]=k,e[22]=g,e[23]=J,e[24]=b):b=e[24],b},"ae");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(p,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(p,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(p,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"de");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:f,scheduledLoad:r}=i,l=M(),[o,N]=(0,Y.useState)("jobs"),x;e[2]!==l?(x=l("Cron triggers"),e[2]=l,e[3]=x):x=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let y;e[10]!==x||e[11]!==n||e[12]!==s||e[13]!==m?(y={cron:x,dead:n,jobs:s,pools:m},e[10]=x,e[11]=n,e[12]=s,e[13]=m,e[14]=y):y=e[14];let k=y,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c(w=>{N(w.currentTarget.dataset.view)},"f"),e[15]=g):g=e[15];let J=g,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==k?(j=Ne.map(w=>(0,t.jsx)(ee,{"aria-selected":o===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:J,role:"tab",size:"sm",type:"button",variant:o===w?"default":"outline",children:k[w]},w)),e[18]=o,e[19]=k,e[20]=j):j=e[20];let I;e[21]!==b||e[22]!==j?(I=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=I):I=e[23];let q;e[24]!==f||e[25]!==r||e[26]!==o?(q=o==="jobs"&&(0,t.jsx)(de,{cancelJob:f,loadJobs:r}),e[24]=f,e[25]=r,e[26]=o,e[27]=q):q=e[27];let B;e[28]!==o?(B=o==="dead"&&(0,t.jsx)(fe,{}),e[28]=o,e[29]=B):B=e[29];let S;e[30]!==o?(S=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=S):S=e[31];let L;e[32]!==d||e[33]!==o?(L=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=L):L=e[34];let $;return e[35]!==I||e[36]!==q||e[37]!==B||e[38]!==S||e[39]!==L?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[I,q,B,S,L]}),e[35]=I,e[36]=q,e[37]=B,e[38]=S,e[39]=L,e[40]=$):$=e[40],$},"Ie");export{Ve as SchedulePanel};
1
+ import{a as O}from"./chunk-JQXA2OYK.js";import{a as H}from"./chunk-I23ULEUU.js";import{a as ee}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as Z}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as E}from"./chunk-PYNRIX74.js";import{l as R}from"./chunk-BDYCZHD2.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as _}from"./chunk-RWVIV3U7.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-HCTJKP5J.js";import{a as A,e as T}from"./chunk-2IKDEUCX.js";import{d as M,h as G,p as W,t as X}from"./chunk-5OMZCVRF.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-I26MS5PJ.js";var U=P(re(),1),Y=P(oe(),1);var t=P(ae(),1);var se=P(re(),1);var Q=P(oe(),1);var h=P(ae(),1);var ie=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","X"),le=c(a=>a.toSorted((e,i)=>e.scheduledFor-i.scheduledFor),"F"),ce=c((a,e,i)=>e!==void 0?e:i===void 0?d=>a.cancelScheduledJob(d):void 0,"Y"),de=c(a=>{let e=(0,se.c)(16),{cancelJob:i,loadJobs:d}=a===void 0?{}:a,f=R(),r=M(),l=d===void 0,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=["lunora-scheduled-jobs"],e[0]=o):o=e[0];let N=E(o,async()=>{let v=await(d??(()=>f.listScheduledJobs()))();return le(v)}),[x,n]=(0,Q.useState)(void 0),[s,m]=(0,Q.useState)(void 0),y,k;e[1]!==f||e[2]!==l?(y=c(()=>{if(l)return f.subscribeScheduledJobs(v=>{m(void 0),n(le(v))})},"v"),k=[l,f],e[1]=f,e[2]=l,e[3]=y,e[4]=k):(y=e[3],k=e[4]),(0,Q.useEffect)(y,k);let g;e[5]!==N?(g=c(()=>{N.refetch()},"y"),e[5]=N,e[6]=g):g=e[6],O(g,!l);let J=ce(f,i,d),b=x??N.data,j=s??N.error,I=c(async v=>{if(J!==void 0){m(void 0);try{await J(v),l||N.refetch()}catch(D){m(G(D))}}},"A"),q="flex flex-col gap-3",B="lunora-scheduled-jobs",S;e[7]!==j?(S=j!==null&&(0,h.jsx)("p",{className:"text-sm text-destructive","data-testid":"sj-error",role:"alert",children:j}),e[7]=j,e[8]=S):S=e[8];let L;e[9]!==b?.length||e[10]!==r?(L=b?.length===0&&(0,h.jsx)(_,{description:r("Jobs queued with runAfter / runAt will appear here."),icon:(0,h.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,h.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,h.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"sj-empty",title:r("No scheduled jobs.")}),e[9]=b?.length,e[10]=r,e[11]=L):L=e[11];let $=b!==void 0&&b.length>0&&(0,h.jsx)(A,{className:"overflow-hidden py-0",children:(0,h.jsx)(T,{className:"px-0",children:(0,h.jsxs)(K,{"data-testid":"sj-table",children:[(0,h.jsx)(V,{children:(0,h.jsxs)(F,{children:[(0,h.jsx)(u,{children:r("function")}),(0,h.jsx)(u,{children:r("scheduled for")}),(0,h.jsx)(u,{children:r("pool")}),(0,h.jsx)(u,{children:r("attempts")}),(0,h.jsx)(u,{children:r("shard")}),(0,h.jsx)(u,{children:r("id")}),J!==void 0&&(0,h.jsx)(u,{"aria-label":r("Actions")})]})}),(0,h.jsx)(z,{children:b.map(v=>(0,h.jsxs)(F,{"data-testid":`sj-row-${v.id}`,children:[(0,h.jsx)(p,{className:"font-mono text-xs",children:v.workflow??v.functionPath}),(0,h.jsx)(p,{className:"text-muted-foreground tabular-nums",children:ie(v.scheduledFor)}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.pool??""}),(0,h.jsx)(p,{className:"tabular-nums",children:v.attempts??0}),(0,h.jsx)(p,{children:v.shardKey??""}),(0,h.jsx)(p,{className:"font-mono text-xs",children:v.id}),J!==void 0&&(0,h.jsx)(p,{className:"text-right",children:(0,h.jsx)(H,{confirmLabel:r("Cancel job?"),onConfirm:c(()=>{W(I(v.id))},"onConfirm"),testId:`sj-cancel-${v.id}`,children:r("Cancel")})})]},v.id))})]})})}),w;return e[12]!==$||e[13]!==S||e[14]!==L?(w=(0,h.jsxs)("div",{className:q,"data-testid":B,children:[S,L,$]}),e[12]=$,e[13]=S,e[14]=L,e[15]=w):w=e[15],w},"he");var he={kind:"idle"},me=c((a,e,i)=>i!==void 0?i:e===void 0?d=>a.runCronJob(d):void 0,"re"),ue=c(({loadCronJobs:a,runCronJob:e}={})=>{let i=R(),d=M(),[f,r]=(0,Y.useState)({}),l=E(["lunora-cron-jobs",a?"custom":"default"],()=>(a??(()=>i.getCronJobs()))()),{data:o,error:N}=l,x=me(i,a,e),n=c(async s=>{if(x!==void 0){r(m=>({...m,[s]:{kind:"running"}}));try{await x(s),r(m=>({...m,[s]:{kind:"ok"}})),l.refetch()}catch(m){r(y=>({...y,[s]:{kind:"error",message:G(m)}}))}}},"i");return(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-cron-triggers",children:[N!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"cron-error",role:"alert",children:N}),o?.length===0&&(0,t.jsx)(_,{description:d("Triggers declared with the cronJobs() builder appear here."),icon:(0,t.jsxs)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:[(0,t.jsx)("circle",{cx:"12",cy:"12",r:"9"}),(0,t.jsx)("path",{d:"M12 7.5V12l4 2"})]}),testId:"cron-empty",title:d("No cron triggers.")}),o!==void 0&&o.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"cron-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:d("name")}),(0,t.jsx)(u,{children:d("schedule")}),(0,t.jsx)(u,{children:d("target")}),(0,t.jsx)(u,{children:d("shard")}),x!==void 0&&(0,t.jsx)(u,{"aria-label":d("Actions")})]})}),(0,t.jsx)(z,{children:o.map(s=>{let m=f[s.name]??he;return(0,t.jsxs)(F,{"data-testid":`cron-row-${s.name}`,children:[(0,t.jsx)(p,{children:s.name}),(0,t.jsx)(p,{className:"font-mono text-xs tabular-nums",children:s.cron}),(0,t.jsx)(p,{children:(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[s.workflow===void 0?(0,t.jsx)(Z,{variant:"outline",children:d("function")}):(0,t.jsx)(Z,{variant:"secondary",children:d("workflow")}),(0,t.jsx)("span",{className:"font-mono text-xs",children:s.workflow??s.functionPath})]})}),(0,t.jsx)(p,{children:s.shardKey??""}),x!==void 0&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("span",{className:"flex items-center justify-end gap-2",children:[m.kind==="ok"&&(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`cron-ran-${s.name}`,children:d("ran")}),m.kind==="error"&&(0,t.jsx)("span",{className:"text-xs text-destructive","data-testid":`cron-run-error-${s.name}`,role:"alert",children:m.message}),(0,t.jsx)(H,{confirmLabel:d("Run now?"),disabled:m.kind==="running",onConfirm:c(()=>{W(n(s.name))},"onConfirm"),testId:`cron-run-${s.name}`,children:m.kind==="running"?d("Running\u2026"):d("Run now")})]})})]},`${s.cron}:${s.name}`)})})]})})})]})},"le"),pe=c(a=>Number.isFinite(a)?X(a,"\u2014"):"\u2014","se"),fe=c(a=>{let e=(0,U.c)(34),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadJobs:d,removeJob:f,retryJob:r}=i,l=R(),o=M(),N;e[2]===Symbol.for("react.memo_cache_sentinel")?(N=["lunora-dead-jobs"],e[2]=N):N=e[2];let x;e[3]!==l||e[4]!==d?(x=c(async()=>(await(d??(()=>l.listDeadJobs()))()).toSorted(be),"h"),e[3]=l,e[4]=d,e[5]=x):x=e[5];let n=E(N,x),s=n.data,[m,y]=(0,Y.useState)(void 0),k=n.error??m,g=d===void 0,J;e[6]!==l||e[7]!==g||e[8]!==r?(J=r??(g?C=>l.retryDeadJob(C):void 0),e[6]=l,e[7]=g,e[8]=r,e[9]=J):J=e[9];let b=J,j;e[10]!==l||e[11]!==g||e[12]!==f?(j=f??(g?C=>l.removeDeadJob(C):void 0),e[10]=l,e[11]=g,e[12]=f,e[13]=j):j=e[13];let I=j,q;e[14]!==n?(q=c(()=>{n.refetch()},"$"),e[14]=n,e[15]=q):q=e[15],O(q,!0);let B;e[16]!==n?(B=c(async C=>{y(void 0);try{await C,n.refetch()}catch(ne){y(G(ne))}},"I"),e[16]=n,e[17]=B):B=e[17];let S=B,L=b!==void 0||I!==void 0,$;e[18]!==k?($=k!==void 0&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"dlq-error",role:"alert",children:k}),e[18]=k,e[19]=$):$=e[19];let w;e[20]!==s?.length||e[21]!==o?(w=s?.length===0&&(0,t.jsx)(_,{description:o("Jobs that exhaust their retry budget are parked here instead of being dropped."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14"})}),testId:"dlq-empty",title:o("No dead-letter jobs.")}),e[20]=s?.length,e[21]=o,e[22]=w):w=e[22];let v;e[23]!==S||e[24]!==L||e[25]!==s||e[26]!==I||e[27]!==b||e[28]!==o?(v=s!==void 0&&s.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"dlq-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:o("function")}),(0,t.jsx)(u,{children:o("attempts")}),(0,t.jsx)(u,{children:o("last tried")}),(0,t.jsx)(u,{children:o("pool")}),(0,t.jsx)(u,{children:o("shard")}),(0,t.jsx)(u,{children:o("id")}),L&&(0,t.jsx)(u,{"aria-label":o("Actions")})]})}),(0,t.jsx)(z,{children:s.map(C=>(0,t.jsxs)(F,{"data-testid":`dlq-row-${C.id}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:C.workflow??C.functionPath}),(0,t.jsx)(p,{className:"tabular-nums",children:C.attempts??0}),(0,t.jsx)(p,{className:"text-muted-foreground tabular-nums",children:pe(C.scheduledFor)}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.pool??""}),(0,t.jsx)(p,{children:C.shardKey??""}),(0,t.jsx)(p,{className:"font-mono text-xs",children:C.id}),L&&(0,t.jsx)(p,{className:"text-right",children:(0,t.jsxs)("div",{className:"flex justify-end gap-1.5",children:[b!==void 0&&(0,t.jsx)(ee,{"data-testid":`dlq-retry-${C.id}`,onClick:c(()=>{W(S(b(C.id)))},"onClick"),size:"sm",type:"button",variant:"outline",children:o("Retry")}),I!==void 0&&(0,t.jsx)(H,{confirmLabel:o("Drop job?"),onConfirm:c(()=>{W(S(I(C.id)))},"onConfirm"),testId:`dlq-remove-${C.id}`,children:o("Drop")})]})})]},C.id))})]})})}),e[23]=S,e[24]=L,e[25]=s,e[26]=I,e[27]=b,e[28]=o,e[29]=v):v=e[29];let D;return e[30]!==v||e[31]!==$||e[32]!==w?(D=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-dead-letter",children:[$,w,v]}),e[30]=v,e[31]=$,e[32]=w,e[33]=D):D=e[33],D},"ne");function be(a,e){return(e.attempts??0)-(a.attempts??0)}c(be,"oe");var te=c(a=>{let e=(0,U.c)(8),{label:i,testId:d,value:f}=a,r;e[0]!==i?(r=(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:i}),e[0]=i,e[1]=r):r=e[1];let l;e[2]!==d||e[3]!==f?(l=(0,t.jsx)("span",{className:"text-2xl font-semibold tabular-nums","data-testid":d,children:f}),e[2]=d,e[3]=f,e[4]=l):l=e[4];let o;return e[5]!==r||e[6]!==l?(o=(0,t.jsx)(A,{className:"flex-1 py-0",children:(0,t.jsxs)(T,{className:"flex flex-col gap-1 p-4",children:[r,l]})}),e[5]=r,e[6]=l,e[7]=o):o=e[7],o},"E"),ve=c(a=>{let e=(0,U.c)(25),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadStatus:d}=i,f=R(),r=M(),l=d===void 0,o;e[2]!==l?(o=["lunora-scheduler-status",l],e[2]=l,e[3]=o):o=e[3];let N;e[4]!==f||e[5]!==d?(N=c(async()=>{let j=await(d??(()=>f.schedulerStatus()))();return{...j,pools:j.pools.toSorted(xe)}},"y"),e[4]=f,e[5]=d,e[6]=N):N=e[6];let x=E(o,N),{data:n,error:s}=x,m;e[7]!==x?(m=c(()=>{x.refetch()},"d"),e[7]=x,e[8]=m):m=e[8],O(m,!0);let y;e[9]!==s?(y=s!==null&&(0,t.jsx)("p",{className:"text-sm text-destructive","data-testid":"pools-error",role:"alert",children:s}),e[9]=s,e[10]=y):y=e[10];let k;e[11]!==n||e[12]!==r?(k=n!==void 0&&(0,t.jsxs)("div",{className:"flex gap-3","data-testid":"pools-totals",children:[(0,t.jsx)(te,{label:r("backlog"),testId:"pools-backlog",value:n.backlog}),(0,t.jsx)(te,{label:r("in flight"),testId:"pools-inflight",value:n.inFlight}),(0,t.jsx)(te,{label:r("pools"),testId:"pools-count",value:n.pools.length})]}),e[11]=n,e[12]=r,e[13]=k):k=e[13];let g;e[14]!==n?.pools.length||e[15]!==r?(g=n?.pools.length===0&&(0,t.jsx)(_,{description:r("Pools created with createWorkpool appear here once they have activity."),icon:(0,t.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,t.jsx)("path",{d:"M4 7h16M4 12h16M4 17h16"})}),testId:"pools-empty",title:r("No workpools.")}),e[14]=n?.pools.length,e[15]=r,e[16]=g):g=e[16];let J;e[17]!==n||e[18]!==r?(J=n!==void 0&&n.pools.length>0&&(0,t.jsx)(A,{className:"overflow-hidden py-0",children:(0,t.jsx)(T,{className:"px-0",children:(0,t.jsxs)(K,{"data-testid":"pools-table",children:[(0,t.jsx)(V,{children:(0,t.jsxs)(F,{children:[(0,t.jsx)(u,{children:r("pool")}),(0,t.jsx)(u,{children:r("queued")}),(0,t.jsx)(u,{children:r("in flight")}),(0,t.jsx)(u,{children:r("max concurrency")})]})}),(0,t.jsx)(z,{children:n.pools.map(ge)})]})})}),e[17]=n,e[18]=r,e[19]=J):J=e[19];let b;return e[20]!==y||e[21]!==k||e[22]!==g||e[23]!==J?(b=(0,t.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-scheduler-pools",children:[y,k,g,J]}),e[20]=y,e[21]=k,e[22]=g,e[23]=J,e[24]=b):b=e[24],b},"ae");function xe(a,e){return e.queued-a.queued}c(xe,"ie");function ge(a){return(0,t.jsxs)(F,{"data-testid":`pools-row-${a.name}`,children:[(0,t.jsx)(p,{className:"font-mono text-xs",children:a.name}),(0,t.jsx)(p,{className:"tabular-nums",children:a.queued}),(0,t.jsxs)(p,{className:"tabular-nums",children:[a.inFlight," / ",a.maxConcurrency]}),(0,t.jsx)(p,{className:"tabular-nums",children:a.maxConcurrency})]},a.name)}c(ge,"de");var Ne=["jobs","dead","pools","cron"],Ve=c(a=>{let e=(0,U.c)(41),i;e[0]!==a?(i=a===void 0?{}:a,e[0]=a,e[1]=i):i=e[1];let{loadCronJobs:d,scheduledCancel:f,scheduledLoad:r}=i,l=M(),[o,N]=(0,Y.useState)("jobs"),x;e[2]!==l?(x=l("Cron triggers"),e[2]=l,e[3]=x):x=e[3];let n;e[4]!==l?(n=l("Dead letter"),e[4]=l,e[5]=n):n=e[5];let s;e[6]!==l?(s=l("Scheduled jobs"),e[6]=l,e[7]=s):s=e[7];let m;e[8]!==l?(m=l("Pools"),e[8]=l,e[9]=m):m=e[9];let y;e[10]!==x||e[11]!==n||e[12]!==s||e[13]!==m?(y={cron:x,dead:n,jobs:s,pools:m},e[10]=x,e[11]=n,e[12]=s,e[13]=m,e[14]=y):y=e[14];let k=y,g;e[15]===Symbol.for("react.memo_cache_sentinel")?(g=c(w=>{N(w.currentTarget.dataset.view)},"f"),e[15]=g):g=e[15];let J=g,b;e[16]!==l?(b=l("Schedule view"),e[16]=l,e[17]=b):b=e[17];let j;e[18]!==o||e[19]!==k?(j=Ne.map(w=>(0,t.jsx)(ee,{"aria-selected":o===w,"data-testid":`schedule-view-${w}`,"data-view":w,onClick:J,role:"tab",size:"sm",type:"button",variant:o===w?"default":"outline",children:k[w]},w)),e[18]=o,e[19]=k,e[20]=j):j=e[20];let I;e[21]!==b||e[22]!==j?(I=(0,t.jsx)("div",{"aria-label":b,className:"flex gap-1.5","data-testid":"schedule-view-toggle",role:"tablist",children:j}),e[21]=b,e[22]=j,e[23]=I):I=e[23];let q;e[24]!==f||e[25]!==r||e[26]!==o?(q=o==="jobs"&&(0,t.jsx)(de,{cancelJob:f,loadJobs:r}),e[24]=f,e[25]=r,e[26]=o,e[27]=q):q=e[27];let B;e[28]!==o?(B=o==="dead"&&(0,t.jsx)(fe,{}),e[28]=o,e[29]=B):B=e[29];let S;e[30]!==o?(S=o==="pools"&&(0,t.jsx)(ve,{}),e[30]=o,e[31]=S):S=e[31];let L;e[32]!==d||e[33]!==o?(L=o==="cron"&&(0,t.jsx)(ue,{loadCronJobs:d}),e[32]=d,e[33]=o,e[34]=L):L=e[34];let $;return e[35]!==I||e[36]!==q||e[37]!==B||e[38]!==S||e[39]!==L?($=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-schedule",children:[I,q,B,S,L]}),e[35]=I,e[36]=q,e[37]=B,e[38]=S,e[39]=L,e[40]=$):$=e[40],$},"Ie");export{Ve as SchedulePanel};
@@ -1 +1 @@
1
- import{a as oe}from"./chunk-FPI7AMQJ.js";import{a as se}from"./chunk-XHRKNCCI.js";import{i as ae}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as A}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as M}from"./chunk-4ZEL6BYL.js";import{c as ne}from"./chunk-DSIY2CMT.js";import{l as Y}from"./chunk-BOYS4DOC.js";import"./chunk-QAQDMS6R.js";import"./chunk-N7LJO732.js";import{a as G}from"./chunk-RWVIV3U7.js";import{a as L,b as _,c as j,d as y,e as i,f as d}from"./chunk-HCTJKP5J.js";import{a as E,e as F}from"./chunk-2IKDEUCX.js";import{d as K,f as Z,g as ee,h as T,m as te,p as R}from"./chunk-HJHSQPHW.js";import{a as s,d as X,e as ie,f as de,g as ce}from"./chunk-I26MS5PJ.js";var l=X(ie(),1);var le=X(de(),1);var e=X(ce(),1);var me=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],ue=["pause","resume","restart","terminate"],fe=s(o=>{let r=(0,le.c)(7),{busy:w,id:k,onAct:h}=o,x=K(),n;r[0]!==w||r[1]!==k||r[2]!==h||r[3]!==x?(n=ue.map(c=>c==="restart"?(0,e.jsx)(se,{confirmLabel:x("Restart?"),disabled:w,onConfirm:s(()=>{h(c)},"onConfirm"),testId:`workflow-instance-${c}-${k}`,children:x(c)},c):(0,e.jsx)(A,{"data-testid":`workflow-instance-${c}-${k}`,disabled:w,onClick:s(()=>{h(c)},"onClick"),size:"sm",type:"button",variant:"ghost",children:x(c)},c)),r[0]=w,r[1]=k,r[2]=h,r[3]=x,r[4]=n):n=r[4];let p;return r[5]!==n?(p=(0,e.jsx)(e.Fragment,{children:n}),r[5]=n,r[6]=p):p=r[6],p},"me"),he="WORKFLOWS_NOT_CONFIGURED",pe=s(o=>typeof o=="object"&&o!==null&&o.code===he,"he"),we=s(o=>{let r=o.error??o.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r,te)}catch{return"(unserializable)"}},"pe"),xe=s(({loadDetail:o,loadInstances:r,readOnly:w,runAction:k,workflowName:h})=>{let x=Y(),n=K(),[p,c]=(0,l.useState)(null),[O,$]=(0,l.useState)(null),[S,J]=(0,l.useState)(""),[C,v]=(0,l.useState)(null),[z,W]=(0,l.useState)(!1),[U,B]=(0,l.useState)(null),N=(0,l.useRef)(0),g=(0,l.useRef)(0),b=(0,l.useRef)(0),P=o??(a=>x.getWorkflowInstance(a)),D=w?void 0:k??(r===void 0?a=>x.setWorkflowInstanceStatus(a):void 0),q=s(async()=>{g.current+=1;let a=g.current;v(null),W(!1);let u=S===""?void 0:S;try{if(r===void 0){let m=await x.listWorkflowInstances({name:h,status:u});if(a!==g.current)return;if(m.configured===!1){c(null),W(!0);return}c(m.instances);return}let t=await r({name:h,status:u});a===g.current&&c(t)}catch(t){if(a!==g.current)return;c(null),pe(t)?W(!0):v(T(t))}},"L");(0,l.useEffect)(()=>{N.current+=1,b.current+=1,$(null),R(q())},[h,S]);let H=s(async a=>{b.current+=1;let u=b.current;v(null);try{let t=await P({id:a,name:h});u===b.current&&$(t)}catch(t){u===b.current&&v(T(t))}},"B"),Q=s(()=>{b.current+=1,$(null)},"J"),V=s(async(a,u)=>{if(D===void 0)return;let t=N.current;B(a),v(null);try{await D({action:u,id:a,name:h}),t===N.current&&await q()}catch(m){v(T(m))}B(null)},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:n("Instance history")}),(0,e.jsxs)("select",{"aria-label":n("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:s(a=>{J(a.target.value)},"onChange"),value:S,children:[(0,e.jsx)("option",{value:"",children:n("All statuses")}),me.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),C!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:C}),z&&(0,e.jsx)(G,{description:n("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:n("Workflow inspection not configured")}),!z&&p!==null&&p.length===0&&(0,e.jsx)(G,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(F,{className:"px-0",children:(0,e.jsxs)(L,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(y,{children:[(0,e.jsx)(i,{children:n("Instance id")}),(0,e.jsx)(i,{children:n("Status")}),(0,e.jsx)(i,{children:n("Created")}),(0,e.jsx)(i,{children:n("Ended")}),(0,e.jsx)(i,{"aria-label":n("Actions")})]})}),(0,e.jsx)(j,{children:p.map(a=>(0,e.jsxs)(y,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(d,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(d,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(A,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:s(()=>{R(H(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:n("Steps")}),D!==void 0&&(0,e.jsx)(fe,{busy:U===a.id,id:a.id,onAct:s(u=>{R(V(a.id,u))},"onAct")},h)]})})]},a.id))})]})})}),O!==null&&(0,e.jsx)(E,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(F,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[n("Steps")," \xB7 ",O.id]}),(0,e.jsx)(A,{"data-testid":"workflow-instance-detail-close",onClick:Q,size:"xs",type:"button",variant:"ghost",children:n("Close")})]}),O.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:n("This instance has no recorded steps yet.")}):(0,e.jsxs)(L,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(y,{children:[(0,e.jsx)(i,{children:n("Step")}),(0,e.jsx)(i,{children:n("Type")}),(0,e.jsx)(i,{children:n("Attempts")}),(0,e.jsx)(i,{children:n("Started")}),(0,e.jsx)(i,{children:n("Output")})]})}),(0,e.jsx)(j,{children:O.steps.map((a,u)=>(0,e.jsxs)(y,{"data-testid":`workflow-step-${String(u)}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(d,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:we(a)})]},`${a.name}:${String(u)}`))})]})]})})]})},"xe"),Ne=Z(M.createWorkflowInstance),ge=Z(M.getWorkflowInstanceStatus),ke=s(o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"\u2014";try{return JSON.stringify(o.output,te)}catch{return"(unserializable)"}},"ge"),ve=s((o,r)=>o.some(w=>w.exportName===r)?r:o[0]?.exportName??"","be"),Ee=s(()=>{let o=Y(),r=K(),{data:w,error:k}=ne(M.listWorkflows,{}),[h,x]=(0,l.useState)(""),[n,p]=(0,l.useState)(""),[c,O]=(0,l.useState)(""),[$,S]=(0,l.useState)(!1),[J,C]=(0,l.useState)(null),[v,z]=(0,l.useState)([]),[W,U]=(0,l.useState)(null),B=w!==void 0,N=Array.isArray(w?.workflows)?[...w.workflows].toSorted((t,m)=>t.exportName.localeCompare(m.exportName)):[],g=ve(N,h),b=N.find(t=>t.exportName===g),P=s(t=>{z(m=>{let f=m.filter(I=>!(I.exportName===t.exportName&&I.id===t.id));return[t,...f]})},"D"),D=s(async()=>{let t=g;if(t==="")return;let m,f=c.trim();if(f!=="")try{m=JSON.parse(f)}catch{C(r("Params must be valid JSON"));return}S(!0),C(null);try{let I=n.trim(),re=await o.query(Ne,{exportName:t,id:I===""?void 0:I,params:m},ee(""));P({exportName:t,id:re.id,status:re.status}),p("")}catch(I){C(T(I))}S(!1)},"V"),q=s(()=>{R(D())},"X"),H=s(async(t,m)=>{U(m);try{let f=await o.query(ge,{exportName:t,id:m},ee(""));P({error:f.error,exportName:t,id:f.id,output:f.output,status:f.status})}catch(f){C(T(f))}U(null)},"T"),Q=s(t=>{x(t.target.value)},"L"),V=s(t=>{p(t.target.value)},"B"),a=s(t=>{O(t.target.value)},"J"),u=s(t=>{let{export:m,id:f}=t.currentTarget.dataset;m!==void 0&&f!==void 0&&R(H(m,f))},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:k}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),B&&N.length===0?(0,e.jsx)(G,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(F,{className:"px-0",children:(0,e.jsxs)(L,{"data-testid":"workflows-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(y,{children:[(0,e.jsx)(i,{children:r("Export")}),(0,e.jsx)(i,{children:r("Name")}),(0,e.jsx)(i,{children:r("Class")})]})}),(0,e.jsx)(j,{children:N.map(t=>(0,e.jsxs)(y,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:t.className})]},t.exportName))})]})})}),N.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),J!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:J}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("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:Q,value:g,children:N.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(ae,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:V,placeholder:r("Instance id (optional)"),value:n}),(0,e.jsx)(A,{"data-testid":"workflows-start-button",disabled:$||g==="",onClick:q,children:r($?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(oe,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:a,placeholder:r("Params (JSON, optional)"),value:c})]}),v.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(F,{className:"px-0",children:(0,e.jsxs)(L,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(y,{children:[(0,e.jsx)(i,{children:r("Workflow")}),(0,e.jsx)(i,{children:r("Instance id")}),(0,e.jsx)(i,{children:r("Status")}),(0,e.jsx)(i,{children:r("Output")}),(0,e.jsx)(i,{})]})}),(0,e.jsx)(j,{children:v.map(t=>(0,e.jsxs)(y,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:ke(t)}),(0,e.jsx)(d,{children:(0,e.jsx)(A,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:W===t.id,onClick:u,size:"xs",variant:"outline",children:W===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),b!==void 0&&(0,e.jsx)(xe,{workflowName:b.name})]})},"De");export{Ee as default};
1
+ import{a as oe}from"./chunk-FPI7AMQJ.js";import{a as se}from"./chunk-I23ULEUU.js";import{i as ae}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as A}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import{a as M}from"./chunk-4ZEL6BYL.js";import{c as ne}from"./chunk-PYNRIX74.js";import{l as Y}from"./chunk-BDYCZHD2.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as G}from"./chunk-RWVIV3U7.js";import{a as L,b as _,c as j,d as y,e as i,f as d}from"./chunk-HCTJKP5J.js";import{a as E,e as F}from"./chunk-2IKDEUCX.js";import{d as K,f as Z,g as ee,h as T,m as te,p as R}from"./chunk-5OMZCVRF.js";import{a as s,d as X,e as ie,f as de,g as ce}from"./chunk-I26MS5PJ.js";var l=X(ie(),1);var le=X(de(),1);var e=X(ce(),1);var me=["queued","running","rollingBack","paused","waiting","complete","errored","terminated"],ue=["pause","resume","restart","terminate"],fe=s(o=>{let r=(0,le.c)(7),{busy:w,id:k,onAct:h}=o,x=K(),n;r[0]!==w||r[1]!==k||r[2]!==h||r[3]!==x?(n=ue.map(c=>c==="restart"?(0,e.jsx)(se,{confirmLabel:x("Restart?"),disabled:w,onConfirm:s(()=>{h(c)},"onConfirm"),testId:`workflow-instance-${c}-${k}`,children:x(c)},c):(0,e.jsx)(A,{"data-testid":`workflow-instance-${c}-${k}`,disabled:w,onClick:s(()=>{h(c)},"onClick"),size:"sm",type:"button",variant:"ghost",children:x(c)},c)),r[0]=w,r[1]=k,r[2]=h,r[3]=x,r[4]=n):n=r[4];let p;return r[5]!==n?(p=(0,e.jsx)(e.Fragment,{children:n}),r[5]=n,r[6]=p):p=r[6],p},"me"),he="WORKFLOWS_NOT_CONFIGURED",pe=s(o=>typeof o=="object"&&o!==null&&o.code===he,"he"),we=s(o=>{let r=o.error??o.output;if(r===void 0)return"\u2014";try{return JSON.stringify(r,te)}catch{return"(unserializable)"}},"pe"),xe=s(({loadDetail:o,loadInstances:r,readOnly:w,runAction:k,workflowName:h})=>{let x=Y(),n=K(),[p,c]=(0,l.useState)(null),[O,$]=(0,l.useState)(null),[S,J]=(0,l.useState)(""),[C,v]=(0,l.useState)(null),[z,W]=(0,l.useState)(!1),[U,B]=(0,l.useState)(null),N=(0,l.useRef)(0),g=(0,l.useRef)(0),b=(0,l.useRef)(0),P=o??(a=>x.getWorkflowInstance(a)),D=w?void 0:k??(r===void 0?a=>x.setWorkflowInstanceStatus(a):void 0),q=s(async()=>{g.current+=1;let a=g.current;v(null),W(!1);let u=S===""?void 0:S;try{if(r===void 0){let m=await x.listWorkflowInstances({name:h,status:u});if(a!==g.current)return;if(m.configured===!1){c(null),W(!0);return}c(m.instances);return}let t=await r({name:h,status:u});a===g.current&&c(t)}catch(t){if(a!==g.current)return;c(null),pe(t)?W(!0):v(T(t))}},"L");(0,l.useEffect)(()=>{N.current+=1,b.current+=1,$(null),R(q())},[h,S]);let H=s(async a=>{b.current+=1;let u=b.current;v(null);try{let t=await P({id:a,name:h});u===b.current&&$(t)}catch(t){u===b.current&&v(T(t))}},"B"),Q=s(()=>{b.current+=1,$(null)},"J"),V=s(async(a,u)=>{if(D===void 0)return;let t=N.current;B(a),v(null);try{await D({action:u,id:a,name:h}),t===N.current&&await q()}catch(m){v(T(m))}B(null)},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"lunora-workflow-instances",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:n("Instance history")}),(0,e.jsxs)("select",{"aria-label":n("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:s(a=>{J(a.target.value)},"onChange"),value:S,children:[(0,e.jsx)("option",{value:"",children:n("All statuses")}),me.map(a=>(0,e.jsx)("option",{value:a,children:a},a))]})]}),C!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflow-instances-error",role:"alert",children:C}),z&&(0,e.jsx)(G,{description:n("Set CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN in your .dev.vars to enable workflow instance history."),testId:"workflow-instances-unconfigured",title:n("Workflow inspection not configured")}),!z&&p!==null&&p.length===0&&(0,e.jsx)(G,{description:n("No instances match this filter for the selected workflow."),testId:"workflow-instances-empty",title:n("No instances")}),p!==null&&p.length>0&&(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(F,{className:"px-0",children:(0,e.jsxs)(L,{"data-testid":"workflow-instances-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(y,{children:[(0,e.jsx)(i,{children:n("Instance id")}),(0,e.jsx)(i,{children:n("Status")}),(0,e.jsx)(i,{children:n("Created")}),(0,e.jsx)(i,{children:n("Ended")}),(0,e.jsx)(i,{"aria-label":n("Actions")})]})}),(0,e.jsx)(j,{children:p.map(a=>(0,e.jsxs)(y,{"data-testid":`workflow-instance-${a.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:a.id}),(0,e.jsx)(d,{className:"font-mono text-xs",children:a.status}),(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:a.createdOn??"\u2014"}),(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:a.endedOn??"\u2014"}),(0,e.jsx)(d,{className:"text-right",children:(0,e.jsxs)("div",{className:"flex justify-end gap-1.5",children:[(0,e.jsx)(A,{"data-testid":`workflow-instance-steps-${a.id}`,onClick:s(()=>{R(H(a.id))},"onClick"),size:"sm",type:"button",variant:"outline",children:n("Steps")}),D!==void 0&&(0,e.jsx)(fe,{busy:U===a.id,id:a.id,onAct:s(u=>{R(V(a.id,u))},"onAct")},h)]})})]},a.id))})]})})}),O!==null&&(0,e.jsx)(E,{className:"overflow-hidden py-0","data-testid":"workflow-instance-detail",children:(0,e.jsxs)(F,{className:"flex flex-col gap-2 px-4 py-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between",children:[(0,e.jsxs)("span",{className:"font-mono text-xs",children:[n("Steps")," \xB7 ",O.id]}),(0,e.jsx)(A,{"data-testid":"workflow-instance-detail-close",onClick:Q,size:"xs",type:"button",variant:"ghost",children:n("Close")})]}),O.steps.length===0?(0,e.jsx)("p",{className:"text-xs text-muted-foreground",children:n("This instance has no recorded steps yet.")}):(0,e.jsxs)(L,{"data-testid":"workflow-instance-steps",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(y,{children:[(0,e.jsx)(i,{children:n("Step")}),(0,e.jsx)(i,{children:n("Type")}),(0,e.jsx)(i,{children:n("Attempts")}),(0,e.jsx)(i,{children:n("Started")}),(0,e.jsx)(i,{children:n("Output")})]})}),(0,e.jsx)(j,{children:O.steps.map((a,u)=>(0,e.jsxs)(y,{"data-testid":`workflow-step-${String(u)}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:a.name}),(0,e.jsx)(d,{className:"text-xs text-muted-foreground",children:a.type??"\u2014"}),(0,e.jsx)(d,{className:"tabular-nums",children:a.attempts??"\u2014"}),(0,e.jsx)(d,{className:"text-muted-foreground tabular-nums",children:a.start??"\u2014"}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:we(a)})]},`${a.name}:${String(u)}`))})]})]})})]})},"xe"),Ne=Z(M.createWorkflowInstance),ge=Z(M.getWorkflowInstanceStatus),ke=s(o=>{if(o.error)return`${o.error.name}: ${o.error.message}`;if(o.output===void 0)return"\u2014";try{return JSON.stringify(o.output,te)}catch{return"(unserializable)"}},"ge"),ve=s((o,r)=>o.some(w=>w.exportName===r)?r:o[0]?.exportName??"","be"),Ee=s(()=>{let o=Y(),r=K(),{data:w,error:k}=ne(M.listWorkflows,{}),[h,x]=(0,l.useState)(""),[n,p]=(0,l.useState)(""),[c,O]=(0,l.useState)(""),[$,S]=(0,l.useState)(!1),[J,C]=(0,l.useState)(null),[v,z]=(0,l.useState)([]),[W,U]=(0,l.useState)(null),B=w!==void 0,N=Array.isArray(w?.workflows)?[...w.workflows].toSorted((t,m)=>t.exportName.localeCompare(m.exportName)):[],g=ve(N,h),b=N.find(t=>t.exportName===g),P=s(t=>{z(m=>{let f=m.filter(I=>!(I.exportName===t.exportName&&I.id===t.id));return[t,...f]})},"D"),D=s(async()=>{let t=g;if(t==="")return;let m,f=c.trim();if(f!=="")try{m=JSON.parse(f)}catch{C(r("Params must be valid JSON"));return}S(!0),C(null);try{let I=n.trim(),re=await o.query(Ne,{exportName:t,id:I===""?void 0:I,params:m},ee(""));P({exportName:t,id:re.id,status:re.status}),p("")}catch(I){C(T(I))}S(!1)},"V"),q=s(()=>{R(D())},"X"),H=s(async(t,m)=>{U(m);try{let f=await o.query(ge,{exportName:t,id:m},ee(""));P({error:f.error,exportName:t,id:f.id,output:f.output,status:f.status})}catch(f){C(T(f))}U(null)},"T"),Q=s(t=>{x(t.target.value)},"L"),V=s(t=>{p(t.target.value)},"B"),a=s(t=>{O(t.target.value)},"J"),u=s(t=>{let{export:m,id:f}=t.currentTarget.dataset;m!==void 0&&f!==void 0&&R(H(m,f))},"K");return(0,e.jsxs)("div",{className:"flex flex-col gap-6","data-testid":"lunora-workflows-panel",children:[k!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-error",role:"alert",children:k}),(0,e.jsx)("p",{className:"text-sm text-muted-foreground",children:r("Workflows are declared in code with defineWorkflow and run as durable Cloudflare Workflows. Start an instance and observe its status below.")}),B&&N.length===0?(0,e.jsx)(G,{description:r("No defineWorkflow is declared in lunora/workflows.ts in this deployment. Add one to run a durable, multi-step workflow."),testId:"workflows-empty",title:r("No workflows defined")}):(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(F,{className:"px-0",children:(0,e.jsxs)(L,{"data-testid":"workflows-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(y,{children:[(0,e.jsx)(i,{children:r("Export")}),(0,e.jsx)(i,{children:r("Name")}),(0,e.jsx)(i,{children:r("Class")})]})}),(0,e.jsx)(j,{children:N.map(t=>(0,e.jsxs)(y,{"data-testid":`workflows-row-${t.exportName}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:t.name}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:t.className})]},t.exportName))})]})})}),N.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-start",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Start instance")}),J!==null&&(0,e.jsx)("p",{className:"text-sm text-destructive","data-testid":"workflows-start-error",role:"alert",children:J}),(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)("select",{"aria-label":r("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:Q,value:g,children:N.map(t=>(0,e.jsx)("option",{value:t.exportName,children:t.exportName},t.exportName))}),(0,e.jsx)(ae,{"aria-label":r("Instance id (optional)"),className:"max-w-48","data-testid":"workflows-start-id",onChange:V,placeholder:r("Instance id (optional)"),value:n}),(0,e.jsx)(A,{"data-testid":"workflows-start-button",disabled:$||g==="",onClick:q,children:r($?"Starting\u2026":"Start instance")})]}),(0,e.jsx)(oe,{"aria-label":r("Params (JSON)"),className:"font-mono","data-testid":"workflows-start-params",onChange:a,placeholder:r("Params (JSON, optional)"),value:c})]}),v.length>0&&(0,e.jsxs)("div",{className:"flex flex-col gap-3","data-testid":"workflows-instances",children:[(0,e.jsx)("h3",{className:"text-sm font-medium",children:r("Instances")}),(0,e.jsx)(E,{className:"overflow-hidden py-0",children:(0,e.jsx)(F,{className:"px-0",children:(0,e.jsxs)(L,{"data-testid":"workflows-instances-table",children:[(0,e.jsx)(_,{children:(0,e.jsxs)(y,{children:[(0,e.jsx)(i,{children:r("Workflow")}),(0,e.jsx)(i,{children:r("Instance id")}),(0,e.jsx)(i,{children:r("Status")}),(0,e.jsx)(i,{children:r("Output")}),(0,e.jsx)(i,{})]})}),(0,e.jsx)(j,{children:v.map(t=>(0,e.jsxs)(y,{"data-testid":`workflows-instance-${t.id}`,children:[(0,e.jsx)(d,{className:"font-mono text-xs",children:t.exportName}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:t.id}),(0,e.jsx)(d,{className:"font-mono text-xs",children:t.status}),(0,e.jsx)(d,{className:"font-mono text-xs text-muted-foreground",children:ke(t)}),(0,e.jsx)(d,{children:(0,e.jsx)(A,{"data-export":t.exportName,"data-id":t.id,"data-testid":`workflows-instance-refresh-${t.id}`,disabled:W===t.id,onClick:u,size:"xs",variant:"outline",children:W===t.id?r("Refreshing\u2026"):r("Refresh")})})]},`${t.exportName}:${t.id}`))})]})})})]}),b!==void 0&&(0,e.jsx)(xe,{workflowName:b.name})]})},"De");export{Ee as default};
@@ -1 +1 @@
1
- import{a as H}from"./chunk-JQXA2OYK.js";import{b as x}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as z}from"./chunk-DSIY2CMT.js";import{l as O}from"./chunk-BOYS4DOC.js";import"./chunk-QAQDMS6R.js";import"./chunk-N7LJO732.js";import{a as _}from"./chunk-RWVIV3U7.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HCTJKP5J.js";import{a as A,e as L}from"./chunk-2IKDEUCX.js";import{d as W}from"./chunk-HJHSQPHW.js";import{a as R,d as M,f as $,g as D}from"./chunk-I26MS5PJ.js";var I=M($(),1);var n=M(D(),1);var F=2e3,G=new Set(["open"]),ie=R(Q=>{let e=(0,I.c)(41),{read:y}=Q,t=W(),j=O(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"T"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let V=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,refetch:Y}=z(b,V);if(H(Y,!0,F),!c){let r;e[5]!==t?(r=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=r):r=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==r||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:r,title:g})})}),e[9]=r,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let l;e[14]!==a?(l=(0,n.jsx)("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=l):l=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==l||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l,o,d]}),e[22]=l,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Shard")}),(0,n.jsx)(i,{children:t("Socket")}),(0,n.jsx)(i,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:r.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:G.has(r.wsState)?"default":"secondary",children:r.wsState})}),(0,n.jsx)(s,{children:r.confirmedMutationWatermark})]},r.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Subscription")}),(0,n.jsx)(i,{children:t("Kind")}),(0,n.jsx)(i,{children:t("Acked")}),(0,n.jsx)(i,{children:t("Cursor")}),(0,n.jsx)(i,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:r.functionPath}),(0,n.jsx)(s,{children:r.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:r.acked?"default":"secondary",children:r.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:r.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:r.pendingOptimisticLayers})]},r.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"ie");export{ie as default};
1
+ import{a as H}from"./chunk-JQXA2OYK.js";import{b as x}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{b as z}from"./chunk-PYNRIX74.js";import{l as O}from"./chunk-BDYCZHD2.js";import"./chunk-QAQDMS6R.js";import"./chunk-WS7WNXF3.js";import{a as _}from"./chunk-RWVIV3U7.js";import{a as q,b as B,c as E,d as S,e as i,f as s}from"./chunk-HCTJKP5J.js";import{a as A,e as L}from"./chunk-2IKDEUCX.js";import{d as W}from"./chunk-5OMZCVRF.js";import{a as R,d as M,f as $,g as D}from"./chunk-I26MS5PJ.js";var I=M($(),1);var n=M(D(),1);var F=2e3,G=new Set(["open"]),ie=R(Q=>{let e=(0,I.c)(41),{read:y}=Q,t=W(),j=O(),v;e[0]!==j||e[1]!==y?(v=R(()=>Promise.resolve(y?y():j.debug()),"T"),e[0]=j,e[1]=y,e[2]=v):v=e[2];let V=v,K=y?"injected":"live",b;e[3]!==K?(b=["lunora-studio","sync-client-debug",K],e[3]=K,e[4]=b):b=e[4];let{data:c,refetch:Y}=z(b,V);if(H(Y,!0,F),!c){let r;e[5]!==t?(r=t("Reading the sync client's state\u2026"),e[5]=t,e[6]=r):r=e[6];let g;e[7]!==t?(g=t("Sync client"),e[7]=t,e[8]=g):g=e[8];let T;return e[9]!==r||e[10]!==g?(T=(0,n.jsx)(A,{children:(0,n.jsx)(L,{children:(0,n.jsx)(_,{description:r,title:g})})}),e[9]=r,e[10]=g,e[11]=T):T=e[11],T}let{pendingWrites:k,shards:N,subscriptions:w}=c,a;e[12]!==t?(a=t("This Studio session's sync client"),e[12]=t,e[13]=a):a=e[13];let l;e[14]!==a?(l=(0,n.jsx)("span",{className:"text-sm font-medium",children:a}),e[14]=a,e[15]=l):l=e[15];let P=c.connectionStatus==="connected"?"default":"secondary",o;e[16]!==c.connectionStatus||e[17]!==P?(o=(0,n.jsx)(x,{variant:P,children:c.connectionStatus}),e[16]=c.connectionStatus,e[17]=P,e[18]=o):o=e[18];let d;e[19]!==k||e[20]!==t?(d=k>0?(0,n.jsx)(x,{variant:"secondary",children:t("{count} pending writes",{count:k})}):null,e[19]=k,e[20]=t,e[21]=d):d=e[21];let h;e[22]!==l||e[23]!==o||e[24]!==d?(h=(0,n.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[l,o,d]}),e[22]=l,e[23]=o,e[24]=d,e[25]=h):h=e[25];let u;e[26]!==t?(u=t("Reads client.debug() for the client running in this page \u2014 not your application's client. Call client.debug() in your app to diagnose a specific stuck overlay there."),e[26]=t,e[27]=u):u=e[27];let m;e[28]!==u?(m=(0,n.jsx)("p",{className:"text-muted-foreground text-xs",children:u}),e[28]=u,e[29]=m):m=e[29];let p;e[30]!==N||e[31]!==t?(p=N.length===0?(0,n.jsx)(_,{description:t("No shard connection has been opened yet."),title:t("No shards")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Shard")}),(0,n.jsx)(i,{children:t("Socket")}),(0,n.jsx)(i,{children:t("Confirmed watermark")})]})}),(0,n.jsx)(E,{children:N.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{children:r.shardKey??t("(default)")}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:G.has(r.wsState)?"default":"secondary",children:r.wsState})}),(0,n.jsx)(s,{children:r.confirmedMutationWatermark})]},r.shardKey??"__default__"))})]}),e[30]=N,e[31]=t,e[32]=p):p=e[32];let f;e[33]!==w||e[34]!==t?(f=w.length===0?(0,n.jsx)(_,{description:t("This client holds no live queries or shapes."),title:t("No subscriptions")}):(0,n.jsxs)(q,{children:[(0,n.jsx)(B,{children:(0,n.jsxs)(S,{children:[(0,n.jsx)(i,{children:t("Subscription")}),(0,n.jsx)(i,{children:t("Kind")}),(0,n.jsx)(i,{children:t("Acked")}),(0,n.jsx)(i,{children:t("Cursor")}),(0,n.jsx)(i,{children:t("Pending overlays")})]})}),(0,n.jsx)(E,{children:w.map(r=>(0,n.jsxs)(S,{children:[(0,n.jsx)(s,{className:"font-mono text-xs",children:r.functionPath}),(0,n.jsx)(s,{children:r.kind}),(0,n.jsx)(s,{children:(0,n.jsx)(x,{variant:r.acked?"default":"secondary",children:r.acked?t("yes"):t("no")})}),(0,n.jsx)(s,{children:r.serverCursor??"\u2014"}),(0,n.jsx)(s,{children:r.pendingOptimisticLayers})]},r.id))})]}),e[33]=w,e[34]=t,e[35]=f):f=e[35];let C;return e[36]!==m||e[37]!==p||e[38]!==f||e[39]!==h?(C=(0,n.jsx)(A,{children:(0,n.jsxs)(L,{className:"flex flex-col gap-4",children:[h,m,p,f]})}),e[36]=m,e[37]=p,e[38]=f,e[39]=h,e[40]=C):C=e[40],C},"ie");export{ie as default};
@@ -1 +1 @@
1
- import{m as u,n as d}from"./chunk-TIQ7OBZJ.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import"./chunk-N7LJO732.js";import{a as c,d as m,f as y,g as b}from"./chunk-I26MS5PJ.js";var h=m(y(),1);var n=m(b(),1);var p={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},_=c(o=>{let e=(0,h.c)(6),{data:i}=o,a,r;if(e[0]!==i){r=Symbol.for("react.early_return_sentinel");e:{let f=i.slice(-16);if(f.length<3){r=null;break e}a=f.map(g)}e[0]=i,e[1]=a,e[2]=r}else a=e[1],r=e[2];if(r!==Symbol.for("react.early_return_sentinel"))return r;let s=a,t;e[3]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)(d,{dataKey:"value"}),e[3]=t):t=e[3];let l;return e[4]!==s?(l=(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28",children:(0,n.jsx)(u,{animationType:"none",barCategoryGap:1,className:"h-8 w-full",config:p,data:s,children:t})}),e[4]=s,e[5]=l):l=e[5],l},"b");function g(o,e){return{index:e,value:o}}c(g,"h");export{_ as default};
1
+ import{m as u,n as d}from"./chunk-DVX5J34S.js";import"./chunk-AUGKHAMQ.js";import"./chunk-WJRYEML4.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import"./chunk-WS7WNXF3.js";import{a as c,d as m,f as y,g as b}from"./chunk-I26MS5PJ.js";var h=m(y(),1);var n=m(b(),1);var p={value:{colors:{dark:["var(--foreground)"],light:["var(--foreground)"]},label:""}},_=c(o=>{let e=(0,h.c)(6),{data:i}=o,a,r;if(e[0]!==i){r=Symbol.for("react.early_return_sentinel");e:{let f=i.slice(-16);if(f.length<3){r=null;break e}a=f.map(g)}e[0]=i,e[1]=a,e[2]=r}else a=e[1],r=e[2];if(r!==Symbol.for("react.early_return_sentinel"))return r;let s=a,t;e[3]===Symbol.for("react.memo_cache_sentinel")?(t=(0,n.jsx)(d,{dataKey:"value"}),e[3]=t):t=e[3];let l;return e[4]!==s?(l=(0,n.jsx)("div",{"aria-hidden":"true",className:"h-8 w-28",children:(0,n.jsx)(u,{animationType:"none",barCategoryGap:1,className:"h-8 w-full",config:p,data:s,children:t})}),e[4]=s,e[5]=l):l=e[5],l},"b");function g(o,e){return{index:e,value:o}}c(g,"h");export{_ as default};
@@ -1 +1 @@
1
- import{a as s}from"./chunk-7G4Z6Q7X.js";import{d}from"./chunk-HJHSQPHW.js";import{a as e,d as r,e as h,g as k}from"./chunk-I26MS5PJ.js";var l=r(h(),1);var t=r(k(),1);var g=e(({children:m,confirmLabel:c,disabled:a=!1,onConfirm:p,testId:i})=>{let o=d(),[f,n]=(0,l.useState)(!1),u=e(()=>{n(!0)},"f"),C=e(()=>{n(!1)},"l"),b=e(()=>{n(!1),p()},"p");return f?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1","data-testid":`${i}-prompt`,role:"group",children:[(0,t.jsx)(s,{"data-testid":`${i}-confirm`,disabled:a,onClick:b,size:"sm",type:"button",variant:"destructive",children:c??o("Confirm")}),(0,t.jsx)(s,{"data-testid":`${i}-cancel`,onClick:C,size:"sm",type:"button",variant:"ghost",children:o("Cancel")})]}):(0,t.jsx)(s,{"data-testid":i,disabled:a,onClick:u,size:"sm",type:"button",variant:"outline",children:m})},"k");export{g as a};
1
+ import{a as s}from"./chunk-7G4Z6Q7X.js";import{d}from"./chunk-5OMZCVRF.js";import{a as e,d as r,e as h,g as k}from"./chunk-I26MS5PJ.js";var l=r(h(),1);var t=r(k(),1);var g=e(({children:m,confirmLabel:c,disabled:a=!1,onConfirm:p,testId:i})=>{let o=d(),[f,n]=(0,l.useState)(!1),u=e(()=>{n(!0)},"f"),C=e(()=>{n(!1)},"l"),b=e(()=>{n(!1),p()},"p");return f?(0,t.jsxs)("span",{className:"inline-flex items-center gap-1","data-testid":`${i}-prompt`,role:"group",children:[(0,t.jsx)(s,{"data-testid":`${i}-confirm`,disabled:a,onClick:b,size:"sm",type:"button",variant:"destructive",children:c??o("Confirm")}),(0,t.jsx)(s,{"data-testid":`${i}-cancel`,onClick:C,size:"sm",type:"button",variant:"ghost",children:o("Cancel")})]}):(0,t.jsx)(s,{"data-testid":i,disabled:a,onClick:u,size:"sm",type:"button",variant:"outline",children:m})},"k");export{g as a};