@lunora/studio 1.0.0-alpha.264 → 1.0.0-alpha.266

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 (142) hide show
  1. package/dist/standalone/{chunk-NYKWTNZX.js → chunk-253UHWDX.js} +1 -1
  2. package/dist/standalone/{chunk-72GVG7ZA.js → chunk-2I4NHEKA.js} +1 -1
  3. package/dist/standalone/{chunk-N6NMLJ6R.js → chunk-2IKDEUCX.js} +1 -1
  4. package/dist/standalone/{chunk-4ALGJHGT.js → chunk-2LDBVPWQ.js} +1 -1
  5. package/dist/standalone/{chunk-GFQSMB25.js → chunk-2WSX2ZR2.js} +1 -1
  6. package/dist/standalone/{chunk-YY67675G.js → chunk-2ZIRRUR5.js} +1 -1
  7. package/dist/standalone/{chunk-OTH4FYM7.js → chunk-36BHFCJZ.js} +1 -1
  8. package/dist/standalone/{chunk-C6P2S732.js → chunk-36OOBZSU.js} +1 -1
  9. package/dist/standalone/{chunk-IMOHEGMV.js → chunk-37WYCOQ2.js} +1 -1
  10. package/dist/standalone/{chunk-FK4GW22X.js → chunk-3HP2TTN5.js} +1 -1
  11. package/dist/standalone/{chunk-VVQ64OES.js → chunk-3K3K3PW3.js} +1 -1
  12. package/dist/standalone/{chunk-IS6LVJ6L.js → chunk-3YXASVTP.js} +1 -1
  13. package/dist/standalone/{chunk-JOGSIIY2.js → chunk-46NRRTO2.js} +1 -1
  14. package/dist/standalone/{chunk-LCRAEP3B.js → chunk-4WD4XGC3.js} +1 -1
  15. package/dist/standalone/{chunk-XC734N2Q.js → chunk-4ZDBUYGM.js} +1 -1
  16. package/dist/standalone/{chunk-35DM4JJG.js → chunk-55UGUCQ6.js} +1 -1
  17. package/dist/standalone/chunk-5B2RTXBS.js +1 -0
  18. package/dist/standalone/{chunk-G3CZ2FAC.js → chunk-5EALT2C5.js} +1 -1
  19. package/dist/standalone/{chunk-PFIUSVS6.js → chunk-5NOZE2BB.js} +1 -1
  20. package/dist/standalone/{chunk-H6LZ3QM4.js → chunk-5QR2SQIS.js} +1 -1
  21. package/dist/standalone/{chunk-236GHAHX.js → chunk-65BYZFEA.js} +1 -1
  22. package/dist/standalone/{chunk-H44HW3WV.js → chunk-6HLARDYO.js} +1 -1
  23. package/dist/standalone/chunk-6QTAHSDD.js +1 -0
  24. package/dist/standalone/{chunk-OJE7SI3H.js → chunk-7CX2KBPN.js} +1 -1
  25. package/dist/standalone/{chunk-55754F6H.js → chunk-7G4Z6Q7X.js} +1 -1
  26. package/dist/standalone/{chunk-HVAGAMHZ.js → chunk-7IF35UKO.js} +1 -1
  27. package/dist/standalone/{chunk-BRIYEPXI.js → chunk-7RKB5KS7.js} +1 -1
  28. package/dist/standalone/{chunk-V34AI5VV.js → chunk-7TOFQCI2.js} +1 -1
  29. package/dist/standalone/chunk-7Y3SY37W.js +1 -0
  30. package/dist/standalone/{chunk-QSIQCK3O.js → chunk-A4BIP777.js} +1 -1
  31. package/dist/standalone/{chunk-VNGJA3DB.js → chunk-AG4AQVJT.js} +1 -1
  32. package/dist/standalone/{chunk-AAVLPU5Q.js → chunk-AUAECCXB.js} +1 -1
  33. package/dist/standalone/{chunk-5JDWLCSH.js → chunk-AUGKHAMQ.js} +1 -1
  34. package/dist/standalone/{chunk-RKOBPURU.js → chunk-B6THVJOE.js} +3 -3
  35. package/dist/standalone/{chunk-225VJ77I.js → chunk-BOMPSVRC.js} +1 -1
  36. package/dist/standalone/{chunk-M23RGNY6.js → chunk-C4CN3KU7.js} +1 -1
  37. package/dist/standalone/{chunk-ILVYBIS4.js → chunk-C55EORND.js} +1 -1
  38. package/dist/standalone/{chunk-4S4HJOW4.js → chunk-CASWKFSS.js} +1 -1
  39. package/dist/standalone/{chunk-6DAD3RFX.js → chunk-CCDX5RYT.js} +1 -1
  40. package/dist/standalone/{chunk-NCFRIHLB.js → chunk-CGQMJYCW.js} +1 -1
  41. package/dist/standalone/{chunk-3M5DIK2H.js → chunk-CHFWRN5A.js} +1 -1
  42. package/dist/standalone/{chunk-TIYUHTB3.js → chunk-CIO364ZD.js} +1 -1
  43. package/dist/standalone/{chunk-O3EVDJD5.js → chunk-CVXNHIQW.js} +1 -1
  44. package/dist/standalone/{chunk-ZOBBA5XA.js → chunk-CZLVSMOP.js} +1 -1
  45. package/dist/standalone/{chunk-HEDS6FOP.js → chunk-E2BLE4AI.js} +1 -1
  46. package/dist/standalone/{chunk-6QA34EWC.js → chunk-E4PXACVL.js} +1 -1
  47. package/dist/standalone/{chunk-HPFN7S7N.js → chunk-ECY2JC5F.js} +1 -1
  48. package/dist/standalone/{chunk-LPT6MHEY.js → chunk-EQ642P2K.js} +1 -1
  49. package/dist/standalone/{chunk-36SHCQOV.js → chunk-EWCDT3C4.js} +1 -1
  50. package/dist/standalone/chunk-FCPQOUUQ.js +5 -0
  51. package/dist/standalone/{chunk-5WHNC53N.js → chunk-FE2NK2KO.js} +1 -1
  52. package/dist/standalone/{chunk-FZ7UOWAB.js → chunk-FFVKIOKZ.js} +1 -1
  53. package/dist/standalone/{chunk-EA2JKR5D.js → chunk-FPI7AMQJ.js} +1 -1
  54. package/dist/standalone/{chunk-K7AJEMKE.js → chunk-FUYEZFBP.js} +1 -1
  55. package/dist/standalone/{chunk-SRCY6GJN.js → chunk-GBS7KH2J.js} +1 -1
  56. package/dist/standalone/chunk-GHQ2VDI2.js +1 -0
  57. package/dist/standalone/{chunk-DTOAMMQF.js → chunk-GZI4QESE.js} +1 -1
  58. package/dist/standalone/{chunk-NKZCEQJ7.js → chunk-H2QIHAXY.js} +1 -1
  59. package/dist/standalone/{chunk-HEAQVSNS.js → chunk-HCTJKP5J.js} +1 -1
  60. package/dist/standalone/{chunk-ZD2UXTLR.js → chunk-HECPC2VY.js} +1 -1
  61. package/dist/standalone/{chunk-PTZD7RUZ.js → chunk-HJHSQPHW.js} +11 -11
  62. package/dist/standalone/chunk-I26MS5PJ.js +1 -0
  63. package/dist/standalone/{chunk-KGF3ZXRT.js → chunk-IE4X3UYS.js} +1 -1
  64. package/dist/standalone/{chunk-QKEJLVC5.js → chunk-IWZ7GVQO.js} +1 -1
  65. package/dist/standalone/{chunk-NSWDULEE.js → chunk-JI22NSXG.js} +1 -1
  66. package/dist/standalone/{chunk-H6WXBORU.js → chunk-JNRKX2W3.js} +1 -1
  67. package/dist/standalone/{chunk-66UGPQVC.js → chunk-JQXA2OYK.js} +1 -1
  68. package/dist/standalone/{chunk-OCUJO2PM.js → chunk-JZGTSH2C.js} +1 -1
  69. package/dist/standalone/{chunk-YOB2X3FZ.js → chunk-K2MZTOIJ.js} +1 -1
  70. package/dist/standalone/{chunk-IAL3CXYI.js → chunk-KKPGRVBG.js} +1 -1
  71. package/dist/standalone/{chunk-3HLT7EQR.js → chunk-KZHKRFFX.js} +1 -1
  72. package/dist/standalone/{chunk-HCGXKDHF.js → chunk-LLNH4AP2.js} +1 -1
  73. package/dist/standalone/{chunk-ZFXRRVWV.js → chunk-LWM7Y3CL.js} +1 -1
  74. package/dist/standalone/{chunk-7IV6BZTQ.js → chunk-MFF6SM5S.js} +2 -2
  75. package/dist/standalone/{chunk-N2U3OE4N.js → chunk-MQ5RY4I7.js} +1 -1
  76. package/dist/standalone/{chunk-TDXV3OT5.js → chunk-MVWZMWPD.js} +1 -1
  77. package/dist/standalone/{chunk-WOY4G5ON.js → chunk-NAN5F2XU.js} +1 -1
  78. package/dist/standalone/{chunk-ULIQFBZU.js → chunk-NCPW7WHO.js} +1 -1
  79. package/dist/standalone/{chunk-T6JDEFHN.js → chunk-NDTQTKDX.js} +1 -1
  80. package/dist/standalone/{chunk-NESDGS7F.js → chunk-NQZALRU3.js} +1 -1
  81. package/dist/standalone/{chunk-4JLGLPWV.js → chunk-NRP22GKC.js} +1 -1
  82. package/dist/standalone/{chunk-IFJOYAEZ.js → chunk-NXQW5E6W.js} +1 -1
  83. package/dist/standalone/{chunk-IGNYTJPT.js → chunk-NZT7EQC7.js} +1 -1
  84. package/dist/standalone/{chunk-XXVOKVXV.js → chunk-OPM7ESDV.js} +1 -1
  85. package/dist/standalone/chunk-OQ6I6OXT.js +2 -0
  86. package/dist/standalone/{chunk-MRAMNVDG.js → chunk-OSGXNEFA.js} +1 -1
  87. package/dist/standalone/{chunk-GX2YM7MB.js → chunk-OYCUPD3Q.js} +1 -1
  88. package/dist/standalone/{chunk-Z3S3I4CF.js → chunk-P6VUSJG2.js} +1 -1
  89. package/dist/standalone/{chunk-RDL5WK55.js → chunk-PCBRDDD7.js} +1 -1
  90. package/dist/standalone/{chunk-44NITJRA.js → chunk-PH33W25H.js} +1 -1
  91. package/dist/standalone/{chunk-U7E33WOM.js → chunk-PIMTWCRD.js} +1 -1
  92. package/dist/standalone/{chunk-FEWMAPNI.js → chunk-Q6ED4KUL.js} +1 -1
  93. package/dist/standalone/{chunk-CSUROWL2.js → chunk-Q6IT6ZD7.js} +1 -1
  94. package/dist/standalone/{chunk-FSRSK4LY.js → chunk-QAQDMS6R.js} +1 -1
  95. package/dist/standalone/{chunk-XZMOZFE6.js → chunk-QJLHH3ET.js} +1 -1
  96. package/dist/standalone/{chunk-IRQNBAYI.js → chunk-QNG76J7U.js} +1 -1
  97. package/dist/standalone/{chunk-S3CRZLGS.js → chunk-R6U22RSY.js} +1 -1
  98. package/dist/standalone/{chunk-OKG3HWSJ.js → chunk-RGMVGZV4.js} +1 -1
  99. package/dist/standalone/{chunk-FKVZRPV5.js → chunk-RWVIV3U7.js} +1 -1
  100. package/dist/standalone/{chunk-STF7K7PL.js → chunk-RZF2RURD.js} +1 -1
  101. package/dist/standalone/chunk-S4Z7K55A.js +1 -0
  102. package/dist/standalone/{chunk-5WJXVZMZ.js → chunk-SA2OGF3F.js} +1 -1
  103. package/dist/standalone/{chunk-Y6CXU7T4.js → chunk-SJQERRSZ.js} +1 -1
  104. package/dist/standalone/{chunk-DMNR5ITO.js → chunk-SS4FGGY5.js} +1 -1
  105. package/dist/standalone/{chunk-Z5O2NQAV.js → chunk-SV764LKQ.js} +1 -1
  106. package/dist/standalone/{chunk-I7H22G4D.js → chunk-TDQLMXKM.js} +1 -1
  107. package/dist/standalone/{chunk-3Q2P62UR.js → chunk-UC7MNI2F.js} +1 -1
  108. package/dist/standalone/{chunk-5KQPYU7I.js → chunk-URMNAUYR.js} +1 -1
  109. package/dist/standalone/{chunk-EIISOYGA.js → chunk-UUMEGH4P.js} +1 -1
  110. package/dist/standalone/{chunk-EXOWNDCL.js → chunk-UYLU2CFX.js} +1 -1
  111. package/dist/standalone/{chunk-4GTO7FL5.js → chunk-VESGIGMQ.js} +1 -1
  112. package/dist/standalone/chunk-WJRYEML4.js +1 -0
  113. package/dist/standalone/{chunk-VUPEFCIO.js → chunk-WLCZLWDF.js} +1 -1
  114. package/dist/standalone/{chunk-RPQL45FL.js → chunk-WMN5PZZX.js} +1 -1
  115. package/dist/standalone/{chunk-EGVOSH7K.js → chunk-WNZLTRKF.js} +1 -1
  116. package/dist/standalone/{chunk-22BBGCHO.js → chunk-X2N24K56.js} +1 -1
  117. package/dist/standalone/{chunk-RJQMO2EF.js → chunk-XE7KY2IJ.js} +1 -1
  118. package/dist/standalone/{chunk-Q4CAKBWN.js → chunk-XGCIDUJF.js} +1 -1
  119. package/dist/standalone/{chunk-NFS7FTAR.js → chunk-XHRKNCCI.js} +1 -1
  120. package/dist/standalone/{chunk-NT2ZOFRF.js → chunk-XMUOATX2.js} +1 -1
  121. package/dist/standalone/{chunk-YDLEJGBK.js → chunk-XTQQIXJ4.js} +1 -1
  122. package/dist/standalone/{chunk-NZSVJLGE.js → chunk-XWLNR5FB.js} +1 -1
  123. package/dist/standalone/{chunk-MU3P2FI7.js → chunk-Y3AYVFTK.js} +1 -1
  124. package/dist/standalone/{chunk-NYFJOVIA.js → chunk-Y5NTSEWR.js} +1 -1
  125. package/dist/standalone/{chunk-LIOUCOP2.js → chunk-YVR4SEPU.js} +1 -1
  126. package/dist/standalone/{chunk-UXXDN6Z3.js → chunk-Z22BDS6N.js} +1 -1
  127. package/dist/standalone/{chunk-FUHBEF6J.js → chunk-ZHAVJQY7.js} +1 -1
  128. package/dist/standalone/{chunk-HZQ627G2.js → chunk-ZKIWGBN4.js} +1 -1
  129. package/dist/standalone/{chunk-OGUKYRFM.js → chunk-ZKJS6EBE.js} +1 -1
  130. package/dist/standalone/{chunk-YLPFIPVU.js → chunk-ZWXQKMYE.js} +1 -1
  131. package/dist/standalone/studio.js +9 -9
  132. package/package.json +13 -13
  133. package/dist/standalone/chunk-4L4WTGN5.js +0 -1
  134. package/dist/standalone/chunk-6D6Z2KXU.js +0 -1
  135. package/dist/standalone/chunk-B2HYHTIX.js +0 -1
  136. package/dist/standalone/chunk-CMA4PTV7.js +0 -1
  137. package/dist/standalone/chunk-EVTM6Q43.js +0 -1
  138. package/dist/standalone/chunk-IPBXA3JQ.js +0 -5
  139. package/dist/standalone/chunk-MXLAOCAN.js +0 -1
  140. package/dist/standalone/chunk-V3VJAA4D.js +0 -1
  141. package/dist/standalone/chunk-YKXDMIHQ.js +0 -1
  142. /package/dist/standalone/{chunk-AWHXPIXU.js → chunk-NGVP66OH.js} +0 -0
@@ -1 +1 @@
1
- import{a as r,d as p,e as m}from"./chunk-YKXDMIHQ.js";function d(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}r(d,"mergeObjects");var y={};function h(e,t,n,o,i){if(!n&&!o&&!i&&!e)return R(t);let c=R(e);return t&&(c=E(c,t)),n&&(c=E(c,n)),o&&(c=E(c,o)),i&&(c=E(c,i)),c}r(h,"mergeProps");function x(e){if(e.length===0)return y;if(e.length===1)return R(e[0]);let t=R(e[0]);for(let n=1;n<e.length;n+=1)t=E(t,e[n]);return t}r(x,"mergePropsN");function R(e){return b(e)?{...T(e,y)}:J(e)}r(R,"createInitialMergedProps");function E(e,t){return b(t)?T(t,e):q(e,t)}r(E,"mergeInto");function J(e){let t={...e};for(let n in t){let o=t[n];O(n,o)&&(t[n]=k(o))}return t}r(J,"copyInitialProps");function q(e,t){if(!t)return e;for(let n in t){let o=t[n];switch(n){case"style":{e[n]=d(e.style,o);break}case"className":{e[n]=g(e.className,o);break}default:O(n,o)?e[n]=K(e[n],o):e[n]=o}}return e}r(q,"mutablyMergeInto");function O(e,t){let n=e.charCodeAt(0),o=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&o===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}r(O,"isEventHandler");function b(e){return typeof e=="function"}r(b,"isPropsGetter");function T(e,t){return b(e)?e(t):e??y}r(T,"resolvePropsGetter");function K(e,t){return t?e?(...n)=>{let o=n[0];if(_(o)){let c=o;M(c);let s=t(...n);return c.baseUIHandlerPrevented||e?.(...n),s}let i=t(...n);return e?.(...n),i}:k(t):e}r(K,"mergeEventHandlers");function k(e){return e&&((...t)=>{let n=t[0];return _(n)&&M(n),e(...t)})}r(k,"wrapEventHandler");function M(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}r(M,"makeEventPreventable");function g(e,t){return t?e?t+" "+e:t:e}r(g,"mergeClassNames");function _(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}r(_,"isSyntheticEvent");function Q(e,t){return r(function(o,...i){let c=new URL(e);return c.searchParams.set("code",o.toString()),i.forEach(s=>c.searchParams.append("args[]",s)),`${t} error #${o}; visit ${c} for the full message.`},"formatErrorMessage")}r(Q,"createFormatErrorMessage");var X=Q("https://base-ui.com/production-error","Base UI"),L=X;var a=p(m(),1);var j=p(m(),1);var V={};function v(e,t){let n=j.useRef(V);return n.current===V&&(n.current=e(t)),n}r(v,"useRefWithInit");function A(e,t,n,o){let i=v(S).current;return ee(i,e,t,n,o)&&$(i,[e,t,n,o]),i.callback}r(A,"useMergedRefs");function U(e){let t=v(S).current;return te(t,e)&&$(t,e),t.callback}r(U,"useMergedRefsN");function S(){return{callback:null,cleanup:null,refs:[]}}r(S,"createForkRef");function ee(e,t,n,o,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==o||e.refs[3]!==i}r(ee,"didChange");function te(e,t){return e.refs.length!==t.length||e.refs.some((n,o)=>n!==t[o])}r(te,"didChangeN");function $(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){let o=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){let c=t[i];if(c!=null)switch(typeof c){case"function":{let s=c(n);typeof s=="function"&&(o[i]=s);break}case"object":{c.current=n;break}default:}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){let c=t[i];if(c!=null)switch(typeof c){case"function":{let s=o[i];typeof s=="function"?s():c(null);break}case"object":{c.current=null;break}default:}}}}}}r($,"update");var z=p(m(),1);var B=p(m(),1);var ne=parseInt(B.version,10);function Y(e){return ne>=e}r(Y,"isReactVersionAtLeast");function N(e){if(!z.isValidElement(e))return null;let t=e,n=t.props;return(Y(19)?n?.ref:t.ref)??null}r(N,"getReactElementRef");function we(){}r(we,"NOOP");var Ce=Object.freeze([]),l=Object.freeze({});function D(e,t){let n={};for(let o in e){let i=e[o];if(t?.hasOwnProperty(o)){let c=t[o](i);c!=null&&Object.assign(n,c);continue}i===!0?n[`data-${o.toLowerCase()}`]="":i&&(n[`data-${o.toLowerCase()}`]=i.toString())}return n}r(D,"getStateAttributesProps");function F(e,t){return typeof e=="function"?e(t):e}r(F,"resolveClassName");function W(e,t){return typeof e=="function"?e(t):e}r(W,"resolveStyle");var P=p(m(),1);function We(e,t,n={}){let o=t.render;n.enabled!==!1&&(o=ce(o));let i=re(t,n,o);if(n.enabled===!1)return null;let c=n.state??l;return se(e,o,i,c)}r(We,"useRenderElement");function re(e,t,n){let{className:o,style:i}=e,{state:c=l,ref:s,props:I,stateAttributesMapping:Z,enabled:f=!0}=t,w=f?F(o,c):void 0,C=f?W(i,c):void 0,G=f?D(c,Z):l,H=f&&I?oe(I):void 0,u=f?d(G,H)??{}:l;return typeof document<"u"&&(f?Array.isArray(s)?u.ref=U([u.ref,N(n),...s]):u.ref=A(u.ref,N(n),s):A(null,null)),f?(w!==void 0&&(u.className=g(u.className,w)),C!==void 0&&(u.style=d(u.style,C)),u):l}r(re,"useRenderElementProps");function oe(e){return Array.isArray(e)?x(e):h(void 0,e)}r(oe,"resolveRenderFunctionProps");var ie=Symbol.for("react.lazy");function ce(e){if(e?.$$typeof!==ie)return e;let t=a.Children.toArray(e)[0];return a.isValidElement(t)?t:e}r(ce,"unwrapLazyRenderProp");function se(e,t,n,o){if(t){if(typeof t=="function")return t(n,o);let i=h(n,t.props);return i.ref=n.ref,a.cloneElement(t,i)}if(e&&typeof e=="string")return ue(e,n);throw new Error(L(8))}r(se,"evaluateRenderProp");function ue(e,t){return e==="button"?(0,P.createElement)("button",{type:"button",...t,key:t.key}):e==="img"?(0,P.createElement)("img",{alt:"",...t,key:t.key}):a.createElement(e,t)}r(ue,"renderTag");export{h as a,M as b,L as c,v as d,A as e,Y as f,we as g,Ce as h,l as i,We as j};
1
+ import{a as r,d as p,e as m}from"./chunk-I26MS5PJ.js";function d(e,t){if(e&&!t)return e;if(!e&&t)return t;if(e||t)return{...e,...t}}r(d,"mergeObjects");var y={};function h(e,t,n,o,i){if(!n&&!o&&!i&&!e)return R(t);let c=R(e);return t&&(c=E(c,t)),n&&(c=E(c,n)),o&&(c=E(c,o)),i&&(c=E(c,i)),c}r(h,"mergeProps");function x(e){if(e.length===0)return y;if(e.length===1)return R(e[0]);let t=R(e[0]);for(let n=1;n<e.length;n+=1)t=E(t,e[n]);return t}r(x,"mergePropsN");function R(e){return b(e)?{...T(e,y)}:J(e)}r(R,"createInitialMergedProps");function E(e,t){return b(t)?T(t,e):q(e,t)}r(E,"mergeInto");function J(e){let t={...e};for(let n in t){let o=t[n];O(n,o)&&(t[n]=k(o))}return t}r(J,"copyInitialProps");function q(e,t){if(!t)return e;for(let n in t){let o=t[n];switch(n){case"style":{e[n]=d(e.style,o);break}case"className":{e[n]=g(e.className,o);break}default:O(n,o)?e[n]=K(e[n],o):e[n]=o}}return e}r(q,"mutablyMergeInto");function O(e,t){let n=e.charCodeAt(0),o=e.charCodeAt(1),i=e.charCodeAt(2);return n===111&&o===110&&i>=65&&i<=90&&(typeof t=="function"||typeof t>"u")}r(O,"isEventHandler");function b(e){return typeof e=="function"}r(b,"isPropsGetter");function T(e,t){return b(e)?e(t):e??y}r(T,"resolvePropsGetter");function K(e,t){return t?e?(...n)=>{let o=n[0];if(_(o)){let c=o;M(c);let s=t(...n);return c.baseUIHandlerPrevented||e?.(...n),s}let i=t(...n);return e?.(...n),i}:k(t):e}r(K,"mergeEventHandlers");function k(e){return e&&((...t)=>{let n=t[0];return _(n)&&M(n),e(...t)})}r(k,"wrapEventHandler");function M(e){return e.preventBaseUIHandler=()=>{e.baseUIHandlerPrevented=!0},e}r(M,"makeEventPreventable");function g(e,t){return t?e?t+" "+e:t:e}r(g,"mergeClassNames");function _(e){return e!=null&&typeof e=="object"&&"nativeEvent"in e}r(_,"isSyntheticEvent");function Q(e,t){return r(function(o,...i){let c=new URL(e);return c.searchParams.set("code",o.toString()),i.forEach(s=>c.searchParams.append("args[]",s)),`${t} error #${o}; visit ${c} for the full message.`},"formatErrorMessage")}r(Q,"createFormatErrorMessage");var X=Q("https://base-ui.com/production-error","Base UI"),L=X;var a=p(m(),1);var j=p(m(),1);var V={};function v(e,t){let n=j.useRef(V);return n.current===V&&(n.current=e(t)),n}r(v,"useRefWithInit");function A(e,t,n,o){let i=v(S).current;return ee(i,e,t,n,o)&&$(i,[e,t,n,o]),i.callback}r(A,"useMergedRefs");function U(e){let t=v(S).current;return te(t,e)&&$(t,e),t.callback}r(U,"useMergedRefsN");function S(){return{callback:null,cleanup:null,refs:[]}}r(S,"createForkRef");function ee(e,t,n,o,i){return e.refs[0]!==t||e.refs[1]!==n||e.refs[2]!==o||e.refs[3]!==i}r(ee,"didChange");function te(e,t){return e.refs.length!==t.length||e.refs.some((n,o)=>n!==t[o])}r(te,"didChangeN");function $(e,t){if(e.refs=t,t.every(n=>n==null)){e.callback=null;return}e.callback=n=>{if(e.cleanup&&(e.cleanup(),e.cleanup=null),n!=null){let o=Array(t.length).fill(null);for(let i=0;i<t.length;i+=1){let c=t[i];if(c!=null)switch(typeof c){case"function":{let s=c(n);typeof s=="function"&&(o[i]=s);break}case"object":{c.current=n;break}default:}}e.cleanup=()=>{for(let i=0;i<t.length;i+=1){let c=t[i];if(c!=null)switch(typeof c){case"function":{let s=o[i];typeof s=="function"?s():c(null);break}case"object":{c.current=null;break}default:}}}}}}r($,"update");var z=p(m(),1);var B=p(m(),1);var ne=parseInt(B.version,10);function Y(e){return ne>=e}r(Y,"isReactVersionAtLeast");function N(e){if(!z.isValidElement(e))return null;let t=e,n=t.props;return(Y(19)?n?.ref:t.ref)??null}r(N,"getReactElementRef");function we(){}r(we,"NOOP");var Ce=Object.freeze([]),l=Object.freeze({});function D(e,t){let n={};for(let o in e){let i=e[o];if(t?.hasOwnProperty(o)){let c=t[o](i);c!=null&&Object.assign(n,c);continue}i===!0?n[`data-${o.toLowerCase()}`]="":i&&(n[`data-${o.toLowerCase()}`]=i.toString())}return n}r(D,"getStateAttributesProps");function F(e,t){return typeof e=="function"?e(t):e}r(F,"resolveClassName");function W(e,t){return typeof e=="function"?e(t):e}r(W,"resolveStyle");var P=p(m(),1);function We(e,t,n={}){let o=t.render;n.enabled!==!1&&(o=ce(o));let i=re(t,n,o);if(n.enabled===!1)return null;let c=n.state??l;return se(e,o,i,c)}r(We,"useRenderElement");function re(e,t,n){let{className:o,style:i}=e,{state:c=l,ref:s,props:I,stateAttributesMapping:Z,enabled:f=!0}=t,w=f?F(o,c):void 0,C=f?W(i,c):void 0,G=f?D(c,Z):l,H=f&&I?oe(I):void 0,u=f?d(G,H)??{}:l;return typeof document<"u"&&(f?Array.isArray(s)?u.ref=U([u.ref,N(n),...s]):u.ref=A(u.ref,N(n),s):A(null,null)),f?(w!==void 0&&(u.className=g(u.className,w)),C!==void 0&&(u.style=d(u.style,C)),u):l}r(re,"useRenderElementProps");function oe(e){return Array.isArray(e)?x(e):h(void 0,e)}r(oe,"resolveRenderFunctionProps");var ie=Symbol.for("react.lazy");function ce(e){if(e?.$$typeof!==ie)return e;let t=a.Children.toArray(e)[0];return a.isValidElement(t)?t:e}r(ce,"unwrapLazyRenderProp");function se(e,t,n,o){if(t){if(typeof t=="function")return t(n,o);let i=h(n,t.props);return i.ref=n.ref,a.cloneElement(t,i)}if(e&&typeof e=="string")return ue(e,n);throw new Error(L(8))}r(se,"evaluateRenderProp");function ue(e,t){return e==="button"?(0,P.createElement)("button",{type:"button",...t,key:t.key}):e==="img"?(0,P.createElement)("img",{alt:"",...t,key:t.key}):a.createElement(e,t)}r(ue,"renderTag");export{h as a,M as b,L as c,v as d,A as e,Y as f,we as g,Ce as h,l as i,We as j};
@@ -1 +1 @@
1
- import{a as ee}from"./chunk-5WJXVZMZ.js";import{b as Z}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{d as se,f as X}from"./chunk-EGVOSH7K.js";import"./chunk-FSRSK4LY.js";import"./chunk-RDL5WK55.js";import{a as re}from"./chunk-FKVZRPV5.js";import{a as O}from"./chunk-N6NMLJ6R.js";import{d as le,t as ne}from"./chunk-PTZD7RUZ.js";import{a as k,d as ae,f as ce,g as me,i as Y}from"./chunk-YKXDMIHQ.js";var te=ae(ce(),1);var a=ae(me(),1);var pe="/_lunora/health",he="/_lunora/health/ready",ue=k((r,e)=>(r.endsWith("/")?r.slice(0,-1):r)+e,"me"),fe=k(()=>{let r=X();return async e=>{let w=e==="ready"?he:pe,t=r.getAuthToken(),y=ue(r.url,w);try{let i=await fetch(y,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),p=null;try{p=await i.json()}catch{p=null}return{body:p,ok:i.ok,status:i.status}}catch(i){return{body:null,error:i instanceof Error?i.message:String(i),ok:!1,status:0}}}},"pe"),ge={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ye=k(r=>r==="unhealthy"?"crit":r==="degraded"?"warn":"ok","fe"),ie=k(r=>{let e=(0,te.c)(13),{label:w,level:t,testId:y,value:i}=r,p=ge[t],d;e[0]!==p?(d=Y("size-1.5 shrink-0 rounded-full",p),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==d?(o=(0,a.jsx)("span",{"aria-hidden":"true",className:d}),e[2]=d,e[3]=o):o=e[3];let c;e[4]!==w||e[5]!==o?(c=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[o,w]}),e[4]=w,e[5]=o,e[6]=c):c=e[6];let h;e[7]!==y||e[8]!==i?(h=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":y,children:i}),e[7]=y,e[8]=i,e[9]=h):h=e[9];let C;return e[10]!==c||e[11]!==h?(C=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[c,h]})}),e[10]=c,e[11]=h,e[12]=C):C=e[12],C},"Z"),Pe=k(r=>{let e=(0,te.c)(107),{probe:w}=r,t=le(),y=X(),i=fe(),p=w??i,d;e[0]!==p?(d=k(async()=>{let[s,n]=await Promise.all([p("live"),p("ready")]);return{live:s,ready:n}},"o"),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==y?(o=y.clientIdentifier(),e[2]=y,e[3]=o):o=e[3];let c;e[4]!==o?(c=["deployment-health",o],e[4]=o,e[5]=c):c=e[5];let h;e[6]!==d||e[7]!==c?(h={queryFn:d,queryKey:c},e[6]=d,e[7]=c,e[8]=h):h=e[8];let{data:C,isPending:de}=se(h),Q=C?.live??null,oe=C?.ready??null;if(de){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(ee,{className:"h-16 w-full"}),(0,a.jsx)(ee,{className:"h-40 w-full"})]}),e[9]=s):s=e[9],s}let l=Q?.body??null;if(l===null){let s=Q?.status===403,n;e[10]!==s||e[11]!==Q?.error||e[12]!==t?(n=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:Q?.error??t("no response")}),e[10]=s,e[11]=Q?.error,e[12]=t,e[13]=n):n=e[13];let m;e[14]!==t?(m=t("Health endpoint unavailable"),e[14]=t,e[15]=m):m=e[15];let f;return e[16]!==n||e[17]!==m?(f=(0,a.jsx)(re,{description:n,testId:"deployment-health-error",title:m}),e[16]=n,e[17]=m,e[18]=f):f=e[18],f}let J;e[19]!==l.status?(J=ye(l.status),e[19]=l.status,e[20]=J):J=e[20];let W=J,u;if(l.status==="unhealthy"){let s;e[21]!==t?(s=t("Unhealthy"),e[21]=t,e[22]=s):s=e[22],u=s}else if(l.status==="degraded"){let s;e[23]!==t?(s=t("Degraded"),e[23]=t,e[24]=s):s=e[24],u=s}else{let s;e[25]!==t?(s=t("Healthy"),e[25]=t,e[26]=s):s=e[26],u=s}let j=oe?.ok??!1,G=j?"ok":"crit",H,I,P,x,N,v,S,V,b,_;if(e[27]!==l.appName||e[28]!==l.appVersion||e[29]!==l.checks||e[30]!==l.timestamp||e[31]!==W||e[32]!==G||e[33]!==j||e[34]!==u||e[35]!==t){let s=[...l.checks].toSorted(xe);I="flex flex-col gap-6",P="deployment-health";let n;e[46]!==t?(n=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[46]=t,e[47]=n):n=e[47],e[48]!==n?(x=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:n}),e[48]=n,e[49]=x):x=e[49];let m;e[50]!==u?(m=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:u}),e[50]=u,e[51]=m):m=e[51];let f;e[52]!==l.appName||e[53]!==l.appVersion?(f=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[l.appName," \xB7 ",l.appVersion]}),e[52]=l.appName,e[53]=l.appVersion,e[54]=f):f=e[54];let D;e[55]!==m||e[56]!==f?(D=(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"grid leading-tight",children:[m,f]})}),e[55]=m,e[56]=f,e[57]=D):D=e[57];let L;e[58]!==t?(L=t("Checked"),e[58]=t,e[59]=L):L=e[59];let T;e[60]!==L?(T=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:L}),e[60]=L,e[61]=T):T=e[61];let $;e[62]!==l.timestamp?($=ne(l.timestamp),e[62]=l.timestamp,e[63]=$):$=e[63];let q;e[64]!==$?(q=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:$}),e[64]=$,e[65]=q):q=e[65];let B;e[66]!==T||e[67]!==q?(B=(0,a.jsxs)("div",{className:"text-end",children:[T,q]}),e[66]=T,e[67]=q,e[68]=B):B=e[68],e[69]!==D||e[70]!==B?(N=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[D,B]})}),e[69]=D,e[70]=B,e[71]=N):N=e[71];let E;e[72]!==t?(E=t("Liveness"),e[72]=t,e[73]=E):E=e[73];let R;e[74]!==W||e[75]!==u||e[76]!==E?(R=(0,a.jsx)(ie,{label:E,level:W,testId:"dh-liveness",value:u}),e[74]=W,e[75]=u,e[76]=E,e[77]=R):R=e[77];let U;e[78]!==t?(U=t("Readiness"),e[78]=t,e[79]=U):U=e[79];let A;e[80]!==j||e[81]!==t?(A=t(j?"Ready":"Not ready"),e[80]=j,e[81]=t,e[82]=A):A=e[82];let F;e[83]!==G||e[84]!==U||e[85]!==A?(F=(0,a.jsx)(ie,{label:U,level:G,testId:"dh-readiness",value:A}),e[83]=G,e[84]=U,e[85]=A,e[86]=F):F=e[86],e[87]!==R||e[88]!==F?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[R,F]}),e[87]=R,e[88]=F,e[89]=v):v=e[89],H=O,S="gap-0 py-0",V="dh-checks";let K;e[90]!==t?(K=t("Subsystem checks"),e[90]=t,e[91]=K):K=e[91],e[92]!==K?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K})}),e[92]=K,e[93]=b):b=e[93],_=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(g=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${g.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Y("size-1.5 shrink-0 rounded-full",g.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:g.name}),g.critical&&(0,a.jsx)(Z,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[g.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:g.message}),(0,a.jsx)(Z,{"data-testid":`dh-check-status-${g.name}`,variant:g.status==="up"?"secondary":"destructive",children:g.status==="up"?t("Up"):t("Down")})]})]},g.name))}),e[27]=l.appName,e[28]=l.appVersion,e[29]=l.checks,e[30]=l.timestamp,e[31]=W,e[32]=G,e[33]=j,e[34]=u,e[35]=t,e[36]=H,e[37]=I,e[38]=P,e[39]=x,e[40]=N,e[41]=v,e[42]=S,e[43]=V,e[44]=b,e[45]=_}else H=e[36],I=e[37],P=e[38],x=e[39],N=e[40],v=e[41],S=e[42],V=e[43],b=e[44],_=e[45];let z;e[94]!==H||e[95]!==S||e[96]!==V||e[97]!==b||e[98]!==_?(z=(0,a.jsxs)(H,{className:S,"data-testid":V,children:[b,_]}),e[94]=H,e[95]=S,e[96]=V,e[97]=b,e[98]=_,e[99]=z):z=e[99];let M;return e[100]!==I||e[101]!==P||e[102]!==x||e[103]!==N||e[104]!==v||e[105]!==z?(M=(0,a.jsxs)("div",{className:I,"data-testid":P,children:[x,N,v,z]}),e[100]=I,e[101]=P,e[102]=x,e[103]=N,e[104]=v,e[105]=z,e[106]=M):M=e[106],M},"Pe");function xe(r,e){return r.name.localeCompare(e.name)}k(xe,"he");export{Pe as DeploymentHealthPanel};
1
+ import{a as ee}from"./chunk-SA2OGF3F.js";import{b as Z}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{d as se,f as X}from"./chunk-WNZLTRKF.js";import"./chunk-QAQDMS6R.js";import"./chunk-PCBRDDD7.js";import{a as re}from"./chunk-RWVIV3U7.js";import{a as O}from"./chunk-2IKDEUCX.js";import{d as le,t as ne}from"./chunk-HJHSQPHW.js";import{a as k,d as ae,f as ce,g as me,i as Y}from"./chunk-I26MS5PJ.js";var te=ae(ce(),1);var a=ae(me(),1);var pe="/_lunora/health",he="/_lunora/health/ready",ue=k((r,e)=>(r.endsWith("/")?r.slice(0,-1):r)+e,"me"),fe=k(()=>{let r=X();return async e=>{let w=e==="ready"?he:pe,t=r.getAuthToken(),y=ue(r.url,w);try{let i=await fetch(y,{headers:t===null?{}:{authorization:`Bearer ${t}`}}),p=null;try{p=await i.json()}catch{p=null}return{body:p,ok:i.ok,status:i.status}}catch(i){return{body:null,error:i instanceof Error?i.message:String(i),ok:!1,status:0}}}},"pe"),ge={crit:"bg-destructive",ok:"bg-success",warn:"bg-warning"},ye=k(r=>r==="unhealthy"?"crit":r==="degraded"?"warn":"ok","fe"),ie=k(r=>{let e=(0,te.c)(13),{label:w,level:t,testId:y,value:i}=r,p=ge[t],d;e[0]!==p?(d=Y("size-1.5 shrink-0 rounded-full",p),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==d?(o=(0,a.jsx)("span",{"aria-hidden":"true",className:d}),e[2]=d,e[3]=o):o=e[3];let c;e[4]!==w||e[5]!==o?(c=(0,a.jsxs)("span",{className:"flex items-center gap-1.5 font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:[o,w]}),e[4]=w,e[5]=o,e[6]=c):c=e[6];let h;e[7]!==y||e[8]!==i?(h=(0,a.jsx)("span",{className:"text-lg font-semibold text-foreground","data-testid":y,children:i}),e[7]=y,e[8]=i,e[9]=h):h=e[9];let C;return e[10]!==c||e[11]!==h?(C=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-col gap-2.5 p-4",children:[c,h]})}),e[10]=c,e[11]=h,e[12]=C):C=e[12],C},"Z"),Pe=k(r=>{let e=(0,te.c)(107),{probe:w}=r,t=le(),y=X(),i=fe(),p=w??i,d;e[0]!==p?(d=k(async()=>{let[s,n]=await Promise.all([p("live"),p("ready")]);return{live:s,ready:n}},"o"),e[0]=p,e[1]=d):d=e[1];let o;e[2]!==y?(o=y.clientIdentifier(),e[2]=y,e[3]=o):o=e[3];let c;e[4]!==o?(c=["deployment-health",o],e[4]=o,e[5]=c):c=e[5];let h;e[6]!==d||e[7]!==c?(h={queryFn:d,queryKey:c},e[6]=d,e[7]=c,e[8]=h):h=e[8];let{data:C,isPending:de}=se(h),Q=C?.live??null,oe=C?.ready??null;if(de){let s;return e[9]===Symbol.for("react.memo_cache_sentinel")?(s=(0,a.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"deployment-health-loading",children:[(0,a.jsx)(ee,{className:"h-16 w-full"}),(0,a.jsx)(ee,{className:"h-40 w-full"})]}),e[9]=s):s=e[9],s}let l=Q?.body??null;if(l===null){let s=Q?.status===403,n;e[10]!==s||e[11]!==Q?.error||e[12]!==t?(n=s?t("The health endpoint is in the admin posture. Paste a valid admin token in the connect popover, or set its auth to public."):t("Couldn't reach the health endpoint: {message}",{message:Q?.error??t("no response")}),e[10]=s,e[11]=Q?.error,e[12]=t,e[13]=n):n=e[13];let m;e[14]!==t?(m=t("Health endpoint unavailable"),e[14]=t,e[15]=m):m=e[15];let f;return e[16]!==n||e[17]!==m?(f=(0,a.jsx)(re,{description:n,testId:"deployment-health-error",title:m}),e[16]=n,e[17]=m,e[18]=f):f=e[18],f}let J;e[19]!==l.status?(J=ye(l.status),e[19]=l.status,e[20]=J):J=e[20];let W=J,u;if(l.status==="unhealthy"){let s;e[21]!==t?(s=t("Unhealthy"),e[21]=t,e[22]=s):s=e[22],u=s}else if(l.status==="degraded"){let s;e[23]!==t?(s=t("Degraded"),e[23]=t,e[24]=s):s=e[24],u=s}else{let s;e[25]!==t?(s=t("Healthy"),e[25]=t,e[26]=s):s=e[26],u=s}let j=oe?.ok??!1,G=j?"ok":"crit",H,I,P,x,N,v,S,V,b,_;if(e[27]!==l.appName||e[28]!==l.appVersion||e[29]!==l.checks||e[30]!==l.timestamp||e[31]!==W||e[32]!==G||e[33]!==j||e[34]!==u||e[35]!==t){let s=[...l.checks].toSorted(xe);I="flex flex-col gap-6",P="deployment-health";let n;e[46]!==t?(n=t("Live liveness, readiness, and per-binding health from the deployment's /_lunora/health endpoint \u2014 wire an uptime monitor or a Cloudflare Health Check at it."),e[46]=t,e[47]=n):n=e[47],e[48]!==n?(x=(0,a.jsx)("p",{className:"text-sm text-muted-foreground",children:n}),e[48]=n,e[49]=x):x=e[49];let m;e[50]!==u?(m=(0,a.jsx)("span",{className:"text-sm font-semibold text-foreground","data-testid":"dh-status",children:u}),e[50]=u,e[51]=m):m=e[51];let f;e[52]!==l.appName||e[53]!==l.appVersion?(f=(0,a.jsxs)("span",{className:"font-mono text-[13px] text-muted-foreground","data-testid":"dh-app",children:[l.appName," \xB7 ",l.appVersion]}),e[52]=l.appName,e[53]=l.appVersion,e[54]=f):f=e[54];let D;e[55]!==m||e[56]!==f?(D=(0,a.jsx)("div",{className:"flex items-center gap-3",children:(0,a.jsxs)("div",{className:"grid leading-tight",children:[m,f]})}),e[55]=m,e[56]=f,e[57]=D):D=e[57];let L;e[58]!==t?(L=t("Checked"),e[58]=t,e[59]=L):L=e[59];let T;e[60]!==L?(T=(0,a.jsx)("div",{className:"font-mono text-[10px] tracking-wide text-muted-foreground uppercase",children:L}),e[60]=L,e[61]=T):T=e[61];let $;e[62]!==l.timestamp?($=ne(l.timestamp),e[62]=l.timestamp,e[63]=$):$=e[63];let q;e[64]!==$?(q=(0,a.jsx)("time",{className:"text-[13px] text-muted-foreground","data-testid":"dh-timestamp",children:$}),e[64]=$,e[65]=q):q=e[65];let B;e[66]!==T||e[67]!==q?(B=(0,a.jsxs)("div",{className:"text-end",children:[T,q]}),e[66]=T,e[67]=q,e[68]=B):B=e[68],e[69]!==D||e[70]!==B?(N=(0,a.jsx)(O,{className:"gap-0 py-0",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[D,B]})}),e[69]=D,e[70]=B,e[71]=N):N=e[71];let E;e[72]!==t?(E=t("Liveness"),e[72]=t,e[73]=E):E=e[73];let R;e[74]!==W||e[75]!==u||e[76]!==E?(R=(0,a.jsx)(ie,{label:E,level:W,testId:"dh-liveness",value:u}),e[74]=W,e[75]=u,e[76]=E,e[77]=R):R=e[77];let U;e[78]!==t?(U=t("Readiness"),e[78]=t,e[79]=U):U=e[79];let A;e[80]!==j||e[81]!==t?(A=t(j?"Ready":"Not ready"),e[80]=j,e[81]=t,e[82]=A):A=e[82];let F;e[83]!==G||e[84]!==U||e[85]!==A?(F=(0,a.jsx)(ie,{label:U,level:G,testId:"dh-readiness",value:A}),e[83]=G,e[84]=U,e[85]=A,e[86]=F):F=e[86],e[87]!==R||e[88]!==F?(v=(0,a.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2","data-testid":"dh-probes",children:[R,F]}),e[87]=R,e[88]=F,e[89]=v):v=e[89],H=O,S="gap-0 py-0",V="dh-checks";let K;e[90]!==t?(K=t("Subsystem checks"),e[90]=t,e[91]=K):K=e[91],e[92]!==K?(b=(0,a.jsx)("header",{className:"border-b border-border px-4 py-3",children:(0,a.jsx)("span",{className:"font-mono text-[11px] tracking-wide text-muted-foreground uppercase",children:K})}),e[92]=K,e[93]=b):b=e[93],_=s.length===0?(0,a.jsx)("p",{className:"px-4 py-8 text-center text-sm text-muted-foreground","data-testid":"dh-checks-empty",children:t("No checks reported.")}):(0,a.jsx)("ul",{className:"divide-y divide-border",children:s.map(g=>(0,a.jsxs)("li",{className:"flex flex-wrap items-center justify-between gap-2 px-4 py-2.5 text-xs","data-testid":`dh-check-${g.name}`,children:[(0,a.jsxs)("span",{className:"flex items-center gap-2",children:[(0,a.jsx)("span",{"aria-hidden":"true",className:Y("size-1.5 shrink-0 rounded-full",g.status==="up"?"bg-success":"bg-destructive")}),(0,a.jsx)("span",{className:"font-mono text-foreground",children:g.name}),g.critical&&(0,a.jsx)(Z,{variant:"outline",children:t("Critical")})]}),(0,a.jsxs)("span",{className:"flex shrink-0 items-center gap-2",children:[g.message!==void 0&&(0,a.jsx)("span",{className:"text-muted-foreground",children:g.message}),(0,a.jsx)(Z,{"data-testid":`dh-check-status-${g.name}`,variant:g.status==="up"?"secondary":"destructive",children:g.status==="up"?t("Up"):t("Down")})]})]},g.name))}),e[27]=l.appName,e[28]=l.appVersion,e[29]=l.checks,e[30]=l.timestamp,e[31]=W,e[32]=G,e[33]=j,e[34]=u,e[35]=t,e[36]=H,e[37]=I,e[38]=P,e[39]=x,e[40]=N,e[41]=v,e[42]=S,e[43]=V,e[44]=b,e[45]=_}else H=e[36],I=e[37],P=e[38],x=e[39],N=e[40],v=e[41],S=e[42],V=e[43],b=e[44],_=e[45];let z;e[94]!==H||e[95]!==S||e[96]!==V||e[97]!==b||e[98]!==_?(z=(0,a.jsxs)(H,{className:S,"data-testid":V,children:[b,_]}),e[94]=H,e[95]=S,e[96]=V,e[97]=b,e[98]=_,e[99]=z):z=e[99];let M;return e[100]!==I||e[101]!==P||e[102]!==x||e[103]!==N||e[104]!==v||e[105]!==z?(M=(0,a.jsxs)("div",{className:I,"data-testid":P,children:[x,N,v,z]}),e[100]=I,e[101]=P,e[102]=x,e[103]=N,e[104]=v,e[105]=z,e[106]=M):M=e[106],M},"Pe");function xe(r,e){return r.name.localeCompare(e.name)}k(xe,"he");export{Pe as DeploymentHealthPanel};
@@ -1 +1 @@
1
- import{a as g}from"./chunk-4ZEL6BYL.js";import{c as k}from"./chunk-ZD2UXTLR.js";import{f as S}from"./chunk-EGVOSH7K.js";import{d as _,f as y,g as v,o as C}from"./chunk-PTZD7RUZ.js";import{a as i,d as N,e as L,f as T,g as F}from"./chunk-YKXDMIHQ.js";var w=N(L(),1);var j={},A=y(g.aiGenerateSql),I=y(g.aiTableFilter),O=y(g.aiChartConfig),Q=i(s=>{let e=S(),[l,d]=(0,w.useState)({}),[n,t]=(0,w.useState)({}),a=k(g.aiAvailable,j,{shardKey:s}),[u,c]=(0,w.useState)(!1),x=u||a.data?.available===!1,p=i(o=>{d(r=>({...r,[o]:!0})),t(r=>({...r,[o]:void 0}))},"i"),h=i((o,r)=>{d(b=>({...b,[o]:!1})),r!==void 0&&t(b=>({...b,[o]:r})),r==="no-ai-binding"&&c(!0)},"a"),f=i(async o=>{p("sql");try{let{result:r}=await e.query(A,o,v(s));return h("sql",r.degraded?r.reason:void 0),r.degraded?void 0:r.sql}catch{h("sql","ai-error");return}},"f");return{generate:i(async(o,r)=>f({failedError:r?.error,failedSql:r?.sql,prompt:o}),"generate"),inferChart:i(async o=>{p("chart");try{let{result:r}=await e.query(O,o,v(s));return h("chart",r.degraded?r.reason:void 0),r.degraded?void 0:r.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:i(o=>l[o]===!0,"pending"),reason:i(o=>n[o],"reason"),rewrite:i(async(o,r)=>f({editSql:r,prompt:o}),"rewrite"),suggestFilter:i(async(o,r)=>{p("filter");try{let{result:b}=await e.query(I,{prompt:o,table:r},v(s));return h("filter",b.degraded?b.reason:void 0),b.degraded?void 0:b.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:x}},"Q");var q=N(T(),1);var m=N(F(),1);var G=i((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let l=[],d=s.toLowerCase(),n=e.toLowerCase(),t=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,t))a>t&&l.push({match:!1,offset:t,text:s.slice(t,a)}),l.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),t=a+e.length;return t<s.length&&l.push({match:!1,offset:t,text:s.slice(t)}),l},"N"),U=i(s=>{let e=(0,q.c)(9),{highlight:l,value:d}=s;if(d==null){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=c):c=e[0],c}let n,t,a;if(e[1]!==l||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let c=C(d);if(l===void 0||l===""){a=(0,m.jsx)("span",{title:c,children:c});break e}n=c,t=G(c,l).map(z)}e[1]=l,e[2]=d,e[3]=n,e[4]=t,e[5]=a}else n=e[3],t=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let u;return e[6]!==n||e[7]!==t?(u=(0,m.jsx)("span",{title:n,children:t}),e[6]=n,e[7]=t,e[8]=u):u=e[8],u},"v"),P=i(s=>{let e=(0,q.c)(22),{columns:l,rows:d}=s,n=_(),t;e[0]!==n?(t=n("Field"),e[0]=n,e[1]=t):t=e[1];let a;e[2]!==t?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:t}),e[2]=t,e[3]=a):a=e[3];let u;if(e[4]!==d||e[5]!==n){let f;e[7]!==n?(f=i((o,r)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:r+1})},r),"c"),e[7]=n,e[8]=f):f=e[8],u=d.map(f),e[4]=d,e[5]=n,e[6]=u}else u=e[6];let c;e[9]!==a||e[10]!==u?(c=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,u]})}),e[9]=a,e[10]=u,e[11]=c):c=e[11];let x;if(e[12]!==l||e[13]!==d){let f;e[15]!==d?(f=i(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((r,b)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(U,{value:r[o]})},b))]},o),"c"),e[15]=d,e[16]=f):f=e[16],x=l.map(f),e[12]=l,e[13]=d,e[14]=x}else x=e[14];let p;e[17]!==x?(p=(0,m.jsx)("tbody",{children:x}),e[17]=x,e[18]=p):p=e[18];let h;return e[19]!==c||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[c,p]})}),e[19]=c,e[20]=p,e[21]=h):h=e[21],h},"T"),V=i(({children:s,layout:e="card",testId:l})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":l,children:s}),"j");function z(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}i(z,"_");export{Q as a,U as b,P as c,V as d};
1
+ import{a as g}from"./chunk-4ZEL6BYL.js";import{c as k}from"./chunk-HECPC2VY.js";import{f as S}from"./chunk-WNZLTRKF.js";import{d as _,f as y,g as v,o as C}from"./chunk-HJHSQPHW.js";import{a as i,d as N,e as L,f as T,g as F}from"./chunk-I26MS5PJ.js";var w=N(L(),1);var j={},A=y(g.aiGenerateSql),I=y(g.aiTableFilter),O=y(g.aiChartConfig),Q=i(s=>{let e=S(),[l,d]=(0,w.useState)({}),[n,t]=(0,w.useState)({}),a=k(g.aiAvailable,j,{shardKey:s}),[u,c]=(0,w.useState)(!1),x=u||a.data?.available===!1,p=i(o=>{d(r=>({...r,[o]:!0})),t(r=>({...r,[o]:void 0}))},"i"),h=i((o,r)=>{d(b=>({...b,[o]:!1})),r!==void 0&&t(b=>({...b,[o]:r})),r==="no-ai-binding"&&c(!0)},"a"),f=i(async o=>{p("sql");try{let{result:r}=await e.query(A,o,v(s));return h("sql",r.degraded?r.reason:void 0),r.degraded?void 0:r.sql}catch{h("sql","ai-error");return}},"f");return{generate:i(async(o,r)=>f({failedError:r?.error,failedSql:r?.sql,prompt:o}),"generate"),inferChart:i(async o=>{p("chart");try{let{result:r}=await e.query(O,o,v(s));return h("chart",r.degraded?r.reason:void 0),r.degraded?void 0:r.chart}catch{h("chart","ai-error");return}},"inferChart"),pending:i(o=>l[o]===!0,"pending"),reason:i(o=>n[o],"reason"),rewrite:i(async(o,r)=>f({editSql:r,prompt:o}),"rewrite"),suggestFilter:i(async(o,r)=>{p("filter");try{let{result:b}=await e.query(I,{prompt:o,table:r},v(s));return h("filter",b.degraded?b.reason:void 0),b.degraded?void 0:b.clauses}catch{h("filter","ai-error");return}},"suggestFilter"),unavailable:x}},"Q");var q=N(T(),1);var m=N(F(),1);var G=i((s,e)=>{if(e==="")return[{match:!1,offset:0,text:s}];let l=[],d=s.toLowerCase(),n=e.toLowerCase(),t=0;for(let a=d.indexOf(n);a!==-1;a=d.indexOf(n,t))a>t&&l.push({match:!1,offset:t,text:s.slice(t,a)}),l.push({match:!0,offset:a,text:s.slice(a,a+e.length)}),t=a+e.length;return t<s.length&&l.push({match:!1,offset:t,text:s.slice(t)}),l},"N"),U=i(s=>{let e=(0,q.c)(9),{highlight:l,value:d}=s;if(d==null){let c;return e[0]===Symbol.for("react.memo_cache_sentinel")?(c=(0,m.jsx)("span",{className:"text-muted-foreground/50 italic",children:"NULL"}),e[0]=c):c=e[0],c}let n,t,a;if(e[1]!==l||e[2]!==d){a=Symbol.for("react.early_return_sentinel");e:{let c=C(d);if(l===void 0||l===""){a=(0,m.jsx)("span",{title:c,children:c});break e}n=c,t=G(c,l).map(z)}e[1]=l,e[2]=d,e[3]=n,e[4]=t,e[5]=a}else n=e[3],t=e[4],a=e[5];if(a!==Symbol.for("react.early_return_sentinel"))return a;let u;return e[6]!==n||e[7]!==t?(u=(0,m.jsx)("span",{title:n,children:t}),e[6]=n,e[7]=t,e[8]=u):u=e[8],u},"v"),P=i(s=>{let e=(0,q.c)(22),{columns:l,rows:d}=s,n=_(),t;e[0]!==n?(t=n("Field"),e[0]=n,e[1]=t):t=e[1];let a;e[2]!==t?(a=(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase text-muted-foreground",children:t}),e[2]=t,e[3]=a):a=e[3];let u;if(e[4]!==d||e[5]!==n){let f;e[7]!==n?(f=i((o,r)=>(0,m.jsx)("th",{className:"border-b border-border px-3 py-1.5 text-start font-mono text-[11px] tracking-wide uppercase tabular-nums text-muted-foreground",children:n("Row {n}",{n:r+1})},r),"c"),e[7]=n,e[8]=f):f=e[8],u=d.map(f),e[4]=d,e[5]=n,e[6]=u}else u=e[6];let c;e[9]!==a||e[10]!==u?(c=(0,m.jsx)("thead",{className:"sticky top-0 z-10 bg-muted",children:(0,m.jsxs)("tr",{children:[a,u]})}),e[9]=a,e[10]=u,e[11]=c):c=e[11];let x;if(e[12]!==l||e[13]!==d){let f;e[15]!==d?(f=i(o=>(0,m.jsxs)("tr",{className:"hover:bg-muted/40",children:[(0,m.jsx)("th",{className:"border-b border-e border-border px-3 py-1.5 text-start font-mono font-medium whitespace-nowrap",scope:"row",children:o}),d.map((r,b)=>(0,m.jsx)("td",{className:"max-w-md truncate border-b border-border px-3 py-1.5 font-mono",children:(0,m.jsx)(U,{value:r[o]})},b))]},o),"c"),e[15]=d,e[16]=f):f=e[16],x=l.map(f),e[12]=l,e[13]=d,e[14]=x}else x=e[14];let p;e[17]!==x?(p=(0,m.jsx)("tbody",{children:x}),e[17]=x,e[18]=p):p=e[18];let h;return e[19]!==c||e[20]!==p?(h=(0,m.jsx)("div",{className:"min-h-0 flex-1 overflow-auto","data-testid":"db-transposed",children:(0,m.jsxs)("table",{className:"border-collapse text-xs",children:[c,p]})}),e[19]=c,e[20]=p,e[21]=h):h=e[21],h},"T"),V=i(({children:s,layout:e="card",testId:l})=>(0,m.jsx)("div",{className:e==="fill"?"flex min-h-0 flex-1 flex-col overflow-hidden border-t border-border":"overflow-x-auto border border-border bg-card","data-testid":l,children:s}),"j");function z(s){return(0,m.jsx)("mark",{className:s.match?"rounded-sm bg-warning/40 text-foreground":"bg-transparent text-inherit",children:s.text},s.offset)}i(z,"_");export{Q as a,U as b,P as c,V as d};
@@ -1 +1 @@
1
- import{a as O}from"./chunk-66UGPQVC.js";import{a as H}from"./chunk-NFS7FTAR.js";import{a as ee}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as Z}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{b as E}from"./chunk-ZD2UXTLR.js";import{f as R}from"./chunk-EGVOSH7K.js";import"./chunk-FSRSK4LY.js";import"./chunk-RDL5WK55.js";import{a as _}from"./chunk-FKVZRPV5.js";import{a as K,b as V,c as z,d as F,e as u,f as p}from"./chunk-HEAQVSNS.js";import{a as A,e as T}from"./chunk-N6NMLJ6R.js";import{d as M,h as G,p as W,t as X}from"./chunk-PTZD7RUZ.js";import{a as c,d as P,e as oe,f as re,g as ae}from"./chunk-YKXDMIHQ.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-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-HECPC2VY.js";import{f as R}from"./chunk-WNZLTRKF.js";import"./chunk-QAQDMS6R.js";import"./chunk-PCBRDDD7.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 +1 @@
1
- import{a as s}from"./chunk-YKXDMIHQ.js";var u=new Set(["contains","eq","gt","gte","lt","lte","ne"]),a=s(r=>typeof r=="number"&&Number.isSafeInteger(r)?String(r):r,"i"),o=s(r=>{if(typeof r!="string")return;let e=r.trim();return e===""?void 0:e},"e"),v=s(r=>{if(r===null||typeof r!="object")return!1;let e=r;return typeof e.column=="string"&&typeof e.operator=="string"&&u.has(e.operator)},"p"),h=s(r=>{if(typeof r!="string"||r==="")return[];try{let e=JSON.parse(r);return Array.isArray(e)?e.filter(v):[]}catch{return[]}},"f"),g=s(r=>{if(typeof r!="string"||r==="")return;let e=r.lastIndexOf(":");if(e<=0)return;let i=r.slice(0,e),n=r.slice(e+1);if(!(n!=="asc"&&n!=="desc"))return{column:i,direction:n}},"u"),p=/^[\da-f]{16}$/u,b=s(r=>{let e={};if(typeof r.pins=="string"&&r.pins!==""){let c=r.pins.split(",").filter(f=>f!==""&&f.length<=64).slice(0,12);c.length>0&&(e.pins=c.join(","))}r.schema==="global"&&(e.schema="global");let i=o(r.table);i!==void 0&&(e.table=i);let n=o(a(r.shard));n!==void 0&&(e.shard=n);let d=o(a(r.search));d!==void 0&&(e.search=d);let t=o(r.order);t!==void 0&&g(t)!==void 0&&(e.order=t);let l=o(r.filters);return l!==void 0&&h(l).length>0&&(e.filters=l),e},"b"),y=s(r=>{let e=h(r.filters),i=g(r.order);return{filters:e.length>0?e:void 0,orderBy:i,search:o(a(r.search)),shard:o(a(r.shard)),table:o(r.table),tier:r.schema==="global"?"global":"shard"}},"v"),m=s(r=>{let e=r.filters??[];return{filters:e.length>0?JSON.stringify(e):void 0,order:r.orderBy===void 0?void 0:`${r.orderBy.column}:${r.orderBy.direction}`,schema:r.tier==="global"?"global":void 0,search:r.search!==void 0&&r.search!==""?r.search:void 0,shard:r.shard!==void 0&&r.shard!==""?r.shard:void 0,table:r.table!==void 0&&r.table!==""?r.table:void 0}},"y"),S=s(r=>{let{version:e}=r;return typeof e=="string"&&p.test(e)?{version:e}:{}},"S");export{b as a,y as b,m as c,S as d};
1
+ import{a as s}from"./chunk-I26MS5PJ.js";var u=new Set(["contains","eq","gt","gte","lt","lte","ne"]),a=s(r=>typeof r=="number"&&Number.isSafeInteger(r)?String(r):r,"i"),o=s(r=>{if(typeof r!="string")return;let e=r.trim();return e===""?void 0:e},"e"),v=s(r=>{if(r===null||typeof r!="object")return!1;let e=r;return typeof e.column=="string"&&typeof e.operator=="string"&&u.has(e.operator)},"p"),h=s(r=>{if(typeof r!="string"||r==="")return[];try{let e=JSON.parse(r);return Array.isArray(e)?e.filter(v):[]}catch{return[]}},"f"),g=s(r=>{if(typeof r!="string"||r==="")return;let e=r.lastIndexOf(":");if(e<=0)return;let i=r.slice(0,e),n=r.slice(e+1);if(!(n!=="asc"&&n!=="desc"))return{column:i,direction:n}},"u"),p=/^[\da-f]{16}$/u,b=s(r=>{let e={};if(typeof r.pins=="string"&&r.pins!==""){let c=r.pins.split(",").filter(f=>f!==""&&f.length<=64).slice(0,12);c.length>0&&(e.pins=c.join(","))}r.schema==="global"&&(e.schema="global");let i=o(r.table);i!==void 0&&(e.table=i);let n=o(a(r.shard));n!==void 0&&(e.shard=n);let d=o(a(r.search));d!==void 0&&(e.search=d);let t=o(r.order);t!==void 0&&g(t)!==void 0&&(e.order=t);let l=o(r.filters);return l!==void 0&&h(l).length>0&&(e.filters=l),e},"b"),y=s(r=>{let e=h(r.filters),i=g(r.order);return{filters:e.length>0?e:void 0,orderBy:i,search:o(a(r.search)),shard:o(a(r.shard)),table:o(r.table),tier:r.schema==="global"?"global":"shard"}},"v"),m=s(r=>{let e=r.filters??[];return{filters:e.length>0?JSON.stringify(e):void 0,order:r.orderBy===void 0?void 0:`${r.orderBy.column}:${r.orderBy.direction}`,schema:r.tier==="global"?"global":void 0,search:r.search!==void 0&&r.search!==""?r.search:void 0,shard:r.shard!==void 0&&r.shard!==""?r.shard:void 0,table:r.table!==void 0&&r.table!==""?r.table:void 0}},"y"),S=s(r=>{let{version:e}=r;return typeof e=="string"&&p.test(e)?{version:e}:{}},"S");export{b as a,y as b,m as c,S as d};
@@ -1 +1 @@
1
- import{a as f,d as r,e as m,f as n}from"./chunk-YKXDMIHQ.js";var u=r(n(),1),s=r(m(),1);function a(t){let e=(0,u.c)(2),c=(0,s.useRef)(t),o;return e[0]!==t?(o=f(()=>{c.current=t},"t"),e[0]=t,e[1]=o):o=e[1],(0,s.useEffect)(o),c}f(a,"m");export{a};
1
+ import{a as f,d as r,e as m,f as n}from"./chunk-I26MS5PJ.js";var u=r(n(),1),s=r(m(),1);function a(t){let e=(0,u.c)(2),c=(0,s.useRef)(t),o;return e[0]!==t?(o=f(()=>{c.current=t},"t"),e[0]=t,e[1]=o):o=e[1],(0,s.useEffect)(o),c}f(a,"m");export{a};
@@ -1 +1 @@
1
- import{a as re}from"./chunk-Z5O2NQAV.js";import{a as X}from"./chunk-S3CRZLGS.js";import{a as V}from"./chunk-LIOUCOP2.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-6QA34EWC.js";import"./chunk-TDXV3OT5.js";import"./chunk-4L4WTGN5.js";import{a as R}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as O}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as Y}from"./chunk-YLPFIPVU.js";import"./chunk-ULIQFBZU.js";import"./chunk-XC734N2Q.js";import"./chunk-35DM4JJG.js";import{a as Q}from"./chunk-4ZEL6BYL.js";import{c as J}from"./chunk-ZD2UXTLR.js";import"./chunk-EGVOSH7K.js";import"./chunk-FSRSK4LY.js";import"./chunk-RDL5WK55.js";import{a as G}from"./chunk-FKVZRPV5.js";import{a as Z,b as ee,c as te,d as P,e as n,f as o}from"./chunk-HEAQVSNS.js";import{a as U,e as W}from"./chunk-N6NMLJ6R.js";import{d as z,t as H}from"./chunk-PTZD7RUZ.js";import{a as l,d as B,e as de,f as me,g as he,i as L}from"./chunk-YKXDMIHQ.js";var se=B(me(),1),le=B(de(),1);var t=B(he(),1);var ue={action:"outline",mutation:"default",query:"secondary"},ae=l(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"q"),fe=l(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"de"),pe=l(r=>{let e=r.conflicts??0;return r.calls===0?"\u2014":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},"me"),xe={calls:l((r,e)=>e.calls-r.calls,"calls"),recent:l((r,e)=>e.lastCalledAt-r.lastCalledAt,"recent"),slowest:l((r,e)=>e.maxDurationMs-r.maxDurationMs,"slowest")},Ee=l(r=>{let e=(0,se.c)(47),{functions:K,initialShardKey:ne}=r,s=z(),{queryShardKey:_,setShardKey:N,shardKey:v}=X(ne),[i,oe]=(0,le.useState)("recent"),w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];let C;e[1]!==_?(C={live:!0,shardKey:_},e[1]=_,e[2]=C):C=e[2];let{data:ie,error:c,errorSource:S,liveError:b}=J(Q.getFunctionStats,w,C),k=ie?.functions??null,$;e[3]!==K?($=new Map((K??[]).map(ge)),e[3]=K,e[4]=$):$=e[4];let T=$,F;e[5]===Symbol.for("react.memo_cache_sentinel")?(F=l(M=>{oe(M.currentTarget.dataset.sort)},"E"),e[5]=F):F=e[5];let ce=F,I;if(e[6]!==c||e[7]!==S||e[8]!==T||e[9]!==b||e[10]!==N||e[11]!==v||e[12]!==i||e[13]!==k||e[14]!==s){let M=k===null?[]:k.toSorted(xe[i]),d;e[16]!==s?(d=s("Recent"),e[16]=s,e[17]=d):d=e[17];let m;e[18]!==d?(m={key:"recent",label:d},e[18]=d,e[19]=m):m=e[19];let h;e[20]!==s?(h=s("Most called"),e[20]=s,e[21]=h):h=e[21];let u;e[22]!==h?(u={key:"calls",label:h},e[22]=h,e[23]=u):u=e[23];let f;e[24]!==s?(f=s("Slowest"),e[24]=s,e[25]=f):f=e[25];let p;e[26]!==f?(p={key:"slowest",label:f},e[26]=f,e[27]=p):p=e[27];let A;e[28]!==p||e[29]!==m||e[30]!==u?(A=[m,u,p],e[28]=p,e[29]=m,e[30]=u,e[31]=A):A=e[31];let j=A,x;e[32]!==N||e[33]!==v?(x=(0,t.jsx)(V,{onChange:N,testId:"fs-shard-input",value:v}),e[32]=N,e[33]=v,e[34]=x):x=e[34];let g;e[35]!==b?(g=(0,t.jsx)(re,{message:b,prefix:"fs"}),e[35]=b,e[36]=g):g=e[36];let y;e[37]!==j||e[38]!==i?(y=(0,t.jsx)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:j.map(a=>(0,t.jsx)(R,{"data-sort":a.key,"data-testid":`fs-sort-${a.key}`,onClick:ce,size:"sm",type:"button",variant:i===a.key?"secondary":"ghost",children:a.label},a.key))}),e[37]=j,e[38]=i,e[39]=y):y=e[39];let D;e[40]!==x||e[41]!==g||e[42]!==y?(D=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,g,y]}),e[40]=x,e[41]=g,e[42]=y,e[43]=D):D=e[43];let E;e[44]!==c||e[45]!==S?(E=c!==null&&(0,t.jsx)(Y,{error:S,testId:"fs-error"}),e[44]=c,e[45]=S,e[46]=E):E=e[46],I=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[D,E,k!==null&&M.length===0&&c===null&&(0,t.jsx)(G,{description:s("Per-function call counts, error rates, and latency land here after your first request."),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:"M3 3v18h18"}),(0,t.jsx)("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:s("No functions have run on this shard yet.")}),M.length>0&&(0,t.jsx)(U,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Z,{"data-testid":"fs-table",children:[(0,t.jsx)(ee,{children:(0,t.jsxs)(P,{children:[(0,t.jsx)(n,{children:s("function")}),(0,t.jsx)(n,{children:s("kind")}),(0,t.jsx)(n,{className:"text-right",children:s("calls")}),(0,t.jsx)(n,{className:"text-right",children:s("errors")}),(0,t.jsx)(n,{className:"text-right",children:s("conflicts")}),(0,t.jsx)(n,{className:"text-right",children:s("avg")}),(0,t.jsx)(n,{className:"text-right",children:s("max")}),(0,t.jsx)(n,{children:s("last run")}),(0,t.jsx)(n,{children:s("last error")})]})}),(0,t.jsx)(te,{children:M.map(a=>{let q=T.get(a.path);return(0,t.jsxs)(P,{"data-testid":`fs-row-${a.path}`,children:[(0,t.jsx)(o,{className:"font-medium",children:a.path}),(0,t.jsx)(o,{children:q===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)(O,{variant:ue[q],children:q})}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls}),(0,t.jsx)(o,{className:L("text-right tabular-nums",a.errors>0&&"text-destructive"),children:fe(a)}),(0,t.jsx)(o,{className:L("text-right tabular-nums",(a.conflicts??0)>0&&"text-warning"),children:pe(a)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.totalDurationMs/a.calls)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.maxDurationMs)}),(0,t.jsx)(o,{className:"text-muted-foreground",children:H(a.lastCalledAt,"\u2014")}),(0,t.jsx)(o,{className:"max-w-[24ch] truncate text-destructive",title:a.lastErrorMessage??void 0,children:a.lastErrorMessage??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.path)})})]})})})]}),e[6]=c,e[7]=S,e[8]=T,e[9]=b,e[10]=N,e[11]=v,e[12]=i,e[13]=k,e[14]=s,e[15]=I}else I=e[15];return I},"Ae");function ge(r){return[r.path,r.kind]}l(ge,"fe");export{Ee as FunctionStatsPanel};
1
+ import{a as re}from"./chunk-SV764LKQ.js";import{a as X}from"./chunk-R6U22RSY.js";import{a as V}from"./chunk-YVR4SEPU.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import{a as R}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as O}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as Y}from"./chunk-ZWXQKMYE.js";import"./chunk-NCPW7WHO.js";import"./chunk-4ZDBUYGM.js";import"./chunk-55UGUCQ6.js";import{a as Q}from"./chunk-4ZEL6BYL.js";import{c as J}from"./chunk-HECPC2VY.js";import"./chunk-WNZLTRKF.js";import"./chunk-QAQDMS6R.js";import"./chunk-PCBRDDD7.js";import{a as G}from"./chunk-RWVIV3U7.js";import{a as Z,b as ee,c as te,d as P,e as n,f as o}from"./chunk-HCTJKP5J.js";import{a as U,e as W}from"./chunk-2IKDEUCX.js";import{d as z,t as H}from"./chunk-HJHSQPHW.js";import{a as l,d as B,e as de,f as me,g as he,i as L}from"./chunk-I26MS5PJ.js";var se=B(me(),1),le=B(de(),1);var t=B(he(),1);var ue={action:"outline",mutation:"default",query:"secondary"},ae=l(r=>r<1e3?`${r<10?r.toFixed(1):Math.round(r).toString()}ms`:`${(r/1e3).toFixed(2)}s`,"q"),fe=l(r=>r.calls===0?"\u2014":r.errors===0?"0":`${r.errors.toString()} (${(r.errors/r.calls*100).toFixed(1)}%)`,"de"),pe=l(r=>{let e=r.conflicts??0;return r.calls===0?"\u2014":e===0?"0":`${e.toString()} (${(e/r.calls*100).toFixed(1)}%)`},"me"),xe={calls:l((r,e)=>e.calls-r.calls,"calls"),recent:l((r,e)=>e.lastCalledAt-r.lastCalledAt,"recent"),slowest:l((r,e)=>e.maxDurationMs-r.maxDurationMs,"slowest")},Ee=l(r=>{let e=(0,se.c)(47),{functions:K,initialShardKey:ne}=r,s=z(),{queryShardKey:_,setShardKey:N,shardKey:v}=X(ne),[i,oe]=(0,le.useState)("recent"),w;e[0]===Symbol.for("react.memo_cache_sentinel")?(w={},e[0]=w):w=e[0];let C;e[1]!==_?(C={live:!0,shardKey:_},e[1]=_,e[2]=C):C=e[2];let{data:ie,error:c,errorSource:S,liveError:b}=J(Q.getFunctionStats,w,C),k=ie?.functions??null,$;e[3]!==K?($=new Map((K??[]).map(ge)),e[3]=K,e[4]=$):$=e[4];let T=$,F;e[5]===Symbol.for("react.memo_cache_sentinel")?(F=l(M=>{oe(M.currentTarget.dataset.sort)},"E"),e[5]=F):F=e[5];let ce=F,I;if(e[6]!==c||e[7]!==S||e[8]!==T||e[9]!==b||e[10]!==N||e[11]!==v||e[12]!==i||e[13]!==k||e[14]!==s){let M=k===null?[]:k.toSorted(xe[i]),d;e[16]!==s?(d=s("Recent"),e[16]=s,e[17]=d):d=e[17];let m;e[18]!==d?(m={key:"recent",label:d},e[18]=d,e[19]=m):m=e[19];let h;e[20]!==s?(h=s("Most called"),e[20]=s,e[21]=h):h=e[21];let u;e[22]!==h?(u={key:"calls",label:h},e[22]=h,e[23]=u):u=e[23];let f;e[24]!==s?(f=s("Slowest"),e[24]=s,e[25]=f):f=e[25];let p;e[26]!==f?(p={key:"slowest",label:f},e[26]=f,e[27]=p):p=e[27];let A;e[28]!==p||e[29]!==m||e[30]!==u?(A=[m,u,p],e[28]=p,e[29]=m,e[30]=u,e[31]=A):A=e[31];let j=A,x;e[32]!==N||e[33]!==v?(x=(0,t.jsx)(V,{onChange:N,testId:"fs-shard-input",value:v}),e[32]=N,e[33]=v,e[34]=x):x=e[34];let g;e[35]!==b?(g=(0,t.jsx)(re,{message:b,prefix:"fs"}),e[35]=b,e[36]=g):g=e[36];let y;e[37]!==j||e[38]!==i?(y=(0,t.jsx)("div",{className:"ml-auto flex items-center gap-1",role:"group",children:j.map(a=>(0,t.jsx)(R,{"data-sort":a.key,"data-testid":`fs-sort-${a.key}`,onClick:ce,size:"sm",type:"button",variant:i===a.key?"secondary":"ghost",children:a.label},a.key))}),e[37]=j,e[38]=i,e[39]=y):y=e[39];let D;e[40]!==x||e[41]!==g||e[42]!==y?(D=(0,t.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[x,g,y]}),e[40]=x,e[41]=g,e[42]=y,e[43]=D):D=e[43];let E;e[44]!==c||e[45]!==S?(E=c!==null&&(0,t.jsx)(Y,{error:S,testId:"fs-error"}),e[44]=c,e[45]=S,e[46]=E):E=e[46],I=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-function-stats",children:[D,E,k!==null&&M.length===0&&c===null&&(0,t.jsx)(G,{description:s("Per-function call counts, error rates, and latency land here after your first request."),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:"M3 3v18h18"}),(0,t.jsx)("path",{d:"M7 14l4-4 3 3 5-6"})]}),testId:"fs-empty",title:s("No functions have run on this shard yet.")}),M.length>0&&(0,t.jsx)(U,{className:"overflow-hidden py-0",children:(0,t.jsx)(W,{className:"px-0",children:(0,t.jsxs)(Z,{"data-testid":"fs-table",children:[(0,t.jsx)(ee,{children:(0,t.jsxs)(P,{children:[(0,t.jsx)(n,{children:s("function")}),(0,t.jsx)(n,{children:s("kind")}),(0,t.jsx)(n,{className:"text-right",children:s("calls")}),(0,t.jsx)(n,{className:"text-right",children:s("errors")}),(0,t.jsx)(n,{className:"text-right",children:s("conflicts")}),(0,t.jsx)(n,{className:"text-right",children:s("avg")}),(0,t.jsx)(n,{className:"text-right",children:s("max")}),(0,t.jsx)(n,{children:s("last run")}),(0,t.jsx)(n,{children:s("last error")})]})}),(0,t.jsx)(te,{children:M.map(a=>{let q=T.get(a.path);return(0,t.jsxs)(P,{"data-testid":`fs-row-${a.path}`,children:[(0,t.jsx)(o,{className:"font-medium",children:a.path}),(0,t.jsx)(o,{children:q===void 0?(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"}):(0,t.jsx)(O,{variant:ue[q],children:q})}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls}),(0,t.jsx)(o,{className:L("text-right tabular-nums",a.errors>0&&"text-destructive"),children:fe(a)}),(0,t.jsx)(o,{className:L("text-right tabular-nums",(a.conflicts??0)>0&&"text-warning"),children:pe(a)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.totalDurationMs/a.calls)}),(0,t.jsx)(o,{className:"text-right tabular-nums",children:a.calls===0?"\u2014":ae(a.maxDurationMs)}),(0,t.jsx)(o,{className:"text-muted-foreground",children:H(a.lastCalledAt,"\u2014")}),(0,t.jsx)(o,{className:"max-w-[24ch] truncate text-destructive",title:a.lastErrorMessage??void 0,children:a.lastErrorMessage??(0,t.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},a.path)})})]})})})]}),e[6]=c,e[7]=S,e[8]=T,e[9]=b,e[10]=N,e[11]=v,e[12]=i,e[13]=k,e[14]=s,e[15]=I}else I=e[15];return I},"Ae");function ge(r){return[r.path,r.kind]}l(ge,"fe");export{Ee as FunctionStatsPanel};
@@ -1 +1 @@
1
- import{a as O,b as D}from"./chunk-CMA4PTV7.js";import{a as F}from"./chunk-Z5O2NQAV.js";import{a as V}from"./chunk-S3CRZLGS.js";import{a as T}from"./chunk-LIOUCOP2.js";import"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import{i as L}from"./chunk-6QA34EWC.js";import"./chunk-TDXV3OT5.js";import"./chunk-4L4WTGN5.js";import"./chunk-AAVLPU5Q.js";import{b as C}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import{a as z}from"./chunk-YLPFIPVU.js";import"./chunk-ULIQFBZU.js";import"./chunk-XC734N2Q.js";import"./chunk-35DM4JJG.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as M}from"./chunk-ZD2UXTLR.js";import"./chunk-EGVOSH7K.js";import"./chunk-FSRSK4LY.js";import"./chunk-RDL5WK55.js";import{a as K}from"./chunk-FKVZRPV5.js";import{a as A,b as q,c as B,d as p,e as d,f as n}from"./chunk-HEAQVSNS.js";import{a as I,e as E}from"./chunk-N6NMLJ6R.js";import{d as b,m as j,t as k}from"./chunk-PTZD7RUZ.js";import{a as i,d as y,e as ee,g as te}from"./chunk-YKXDMIHQ.js";var s=y(ee(),1);var e=y(te(),1);var re=i(o=>o===void 0?"":JSON.stringify(o,j),"te"),ae=41,J=480,H=5,ie=i((o,t)=>O(o,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:o})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=V(o),[h,W]=(0,s.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:G}=M(R.getAuditLog,{},{live:!0,shardKey:l}),c=(0,s.useMemo)(()=>f?.entries??[],[f]),m=(0,s.useMemo)(()=>{let a=h.trim().toLowerCase();return a===""?c:c.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[c,h]),x=(0,s.useRef)(null),v=D({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),Q=v.getTotalSize(),N=u[0]?.start??0,w=Q-(u.at(-1)?.end??0),X={height:N},Y={height:w},$=i(a=>{W(a.target.value)},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(T,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{message:G,prefix:"au"}),(0,e.jsx)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:$,placeholder:t("filter op, table, id"),value:h})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(K,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(q,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(d,{children:t("time")}),(0,e.jsx)(d,{children:t("op")}),(0,e.jsx)(d,{children:t("table")}),(0,e.jsx)(d,{children:t("id")}),(0,e.jsx)(d,{children:t("detail")})]})}),(0,e.jsxs)(B,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(n,{className:"text-muted-foreground tabular-nums",children:k(r.ts,"\u2014")}),(0,e.jsx)(n,{children:(0,e.jsx)(C,{variant:"secondary",children:r.op})}),(0,e.jsx)(n,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Y})})]})]})})})]})},"we");export{Ne as AuditPanel};
1
+ import{a as O,b as D}from"./chunk-5B2RTXBS.js";import{a as F}from"./chunk-SV764LKQ.js";import{a as V}from"./chunk-R6U22RSY.js";import{a as T}from"./chunk-YVR4SEPU.js";import"./chunk-ZKJS6EBE.js";import"./chunk-RGMVGZV4.js";import{i as L}from"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-7Y3SY37W.js";import"./chunk-AUAECCXB.js";import{b as C}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import{a as z}from"./chunk-ZWXQKMYE.js";import"./chunk-NCPW7WHO.js";import"./chunk-4ZDBUYGM.js";import"./chunk-55UGUCQ6.js";import{a as R}from"./chunk-4ZEL6BYL.js";import{c as M}from"./chunk-HECPC2VY.js";import"./chunk-WNZLTRKF.js";import"./chunk-QAQDMS6R.js";import"./chunk-PCBRDDD7.js";import{a as K}from"./chunk-RWVIV3U7.js";import{a as A,b as q,c as B,d as p,e as d,f as n}from"./chunk-HCTJKP5J.js";import{a as I,e as E}from"./chunk-2IKDEUCX.js";import{d as b,m as j,t as k}from"./chunk-HJHSQPHW.js";import{a as i,d as y,e as ee,g as te}from"./chunk-I26MS5PJ.js";var s=y(ee(),1);var e=y(te(),1);var re=i(o=>o===void 0?"":JSON.stringify(o,j),"te"),ae=41,J=480,H=5,ie=i((o,t)=>O(o,l=>{t(l.height>0?l:{height:J,width:l.width})}),"ae"),Ne=i(({initialShardKey:o})=>{let t=b(),{queryShardKey:l,setShardKey:P,shardKey:U}=V(o),[h,W]=(0,s.useState)(""),{data:f,error:g,errorSource:Z,isLoading:_,liveError:G}=M(R.getAuditLog,{},{live:!0,shardKey:l}),c=(0,s.useMemo)(()=>f?.entries??[],[f]),m=(0,s.useMemo)(()=>{let a=h.trim().toLowerCase();return a===""?c:c.filter(r=>r.op.toLowerCase().includes(a)||(r.table??"").toLowerCase().includes(a)||(r.id??"").toLowerCase().includes(a))},[c,h]),x=(0,s.useRef)(null),v=D({count:m.length,estimateSize:i(()=>ae,"estimateSize"),getScrollElement:i(()=>x.current,"getScrollElement"),initialRect:{height:J,width:800},observeElementRect:ie,overscan:8}),u=v.getVirtualItems(),Q=v.getTotalSize(),N=u[0]?.start??0,w=Q-(u.at(-1)?.end??0),X={height:N},Y={height:w},$=i(a=>{W(a.target.value)},"z");return(0,e.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"lunora-audit",children:[(0,e.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,e.jsx)(T,{onChange:P,testId:"au-shard-input",value:U}),(0,e.jsx)(F,{message:G,prefix:"au"}),(0,e.jsx)(L,{"aria-label":t("Filter audit log"),className:"h-8 w-48","data-testid":"au-search",onChange:$,placeholder:t("filter op, table, id"),value:h})]}),g!==null&&(0,e.jsx)(z,{error:Z,testId:"au-error"}),g===null&&!_&&m.length===0&&(0,e.jsx)(K,{description:t("State-changing admin operations are recorded here."),icon:(0,e.jsx)("svg",{"aria-hidden":"true",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.6,viewBox:"0 0 24 24",children:(0,e.jsx)("path",{d:"M8 3H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2h-2M9 3a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v1a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V3Zm-1 9h8m-8 4h5"})}),testId:"au-empty",title:t("No audit entries.")}),m.length>0&&(0,e.jsx)(I,{className:"overflow-hidden py-0",children:(0,e.jsx)(E,{className:"max-h-[30rem] overflow-auto px-0",ref:x,children:(0,e.jsxs)(A,{"data-testid":"au-table",children:[(0,e.jsx)(q,{children:(0,e.jsxs)(p,{children:[(0,e.jsx)(d,{children:t("time")}),(0,e.jsx)(d,{children:t("op")}),(0,e.jsx)(d,{children:t("table")}),(0,e.jsx)(d,{children:t("id")}),(0,e.jsx)(d,{children:t("detail")})]})}),(0,e.jsxs)(B,{children:[N>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:X})}),u.map(a=>{let r=m[a.index],S=re(r.detail);return(0,e.jsxs)(p,{"data-testid":"au-row",children:[(0,e.jsx)(n,{className:"text-muted-foreground tabular-nums",children:k(r.ts,"\u2014")}),(0,e.jsx)(n,{children:(0,e.jsx)(C,{variant:"secondary",children:r.op})}),(0,e.jsx)(n,{className:"font-medium",children:r.table??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[20ch] truncate font-mono text-xs",children:r.id??(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})}),(0,e.jsx)(n,{className:"max-w-[32ch] truncate font-mono text-xs text-muted-foreground",title:S||void 0,children:S||(0,e.jsx)("span",{className:"text-muted-foreground",children:"\u2014"})})]},r.seq)}),w>0&&(0,e.jsx)("tr",{"aria-hidden":"true",children:(0,e.jsx)("td",{colSpan:H,style:Y})})]})]})})})]})},"we");export{Ne as AuditPanel};
@@ -1 +1 @@
1
- import{a as i}from"./chunk-YKXDMIHQ.js";var e=i(t=>{let r=Math.floor(t/1e3),o=Math.floor(r/3600),n=Math.floor(r%3600/60),a=r%60;return o>0?`${o.toString()}h ${n.toString()}m`:n>0?`${n.toString()}m ${a.toString()}s`:`${a.toString()}s`},"e"),m=i((t,r)=>{let o=t+r;return o===0?"\u2014":`${(t/o*100).toFixed(1)}%`},"a"),s=i(t=>t<=0?"\u2014":t<1?`${(t*1e3).toFixed(0)}\u03BCs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(2)}s`,"s"),c=i((t,r)=>new Intl.NumberFormat(r,t===0||Math.abs(t)>=1?{currency:"USD",maximumFractionDigits:2,minimumFractionDigits:2,style:"currency"}:{currency:"USD",maximumSignificantDigits:3,style:"currency"}).format(t),"c"),u=i((t,r)=>new Intl.NumberFormat(r,{maximumFractionDigits:0}).format(t),"m");export{e as a,m as b,s as c,c as d,u as e};
1
+ import{a as i}from"./chunk-I26MS5PJ.js";var e=i(t=>{let r=Math.floor(t/1e3),o=Math.floor(r/3600),n=Math.floor(r%3600/60),a=r%60;return o>0?`${o.toString()}h ${n.toString()}m`:n>0?`${n.toString()}m ${a.toString()}s`:`${a.toString()}s`},"e"),m=i((t,r)=>{let o=t+r;return o===0?"\u2014":`${(t/o*100).toFixed(1)}%`},"a"),s=i(t=>t<=0?"\u2014":t<1?`${(t*1e3).toFixed(0)}\u03BCs`:t<1e3?`${t.toFixed(1)}ms`:`${(t/1e3).toFixed(2)}s`,"s"),c=i((t,r)=>new Intl.NumberFormat(r,t===0||Math.abs(t)>=1?{currency:"USD",maximumFractionDigits:2,minimumFractionDigits:2,style:"currency"}:{currency:"USD",maximumSignificantDigits:3,style:"currency"}).format(t),"c"),u=i((t,r)=>new Intl.NumberFormat(r,{maximumFractionDigits:0}).format(t),"m");export{e as a,m as b,s as c,c as d,u as e};
@@ -1 +1 @@
1
- import{a as jt,b as Pt,c as ot}from"./chunk-O3EVDJD5.js";import{a as At,b as Ft,c as zt,d as Et}from"./chunk-72GVG7ZA.js";import{a as it}from"./chunk-PFIUSVS6.js";import{a as me}from"./chunk-NYKWTNZX.js";import{a as It,b as Tt,c as Rt,d as Ot,e as Pe}from"./chunk-H6LZ3QM4.js";import{a as Lt}from"./chunk-B2HYHTIX.js";import{a as Kt}from"./chunk-RPQL45FL.js";import"./chunk-4GTO7FL5.js";import"./chunk-4JLGLPWV.js";import{e as Ct}from"./chunk-UYEZR3BI.js";import"./chunk-XXVOKVXV.js";import{a as Dt}from"./chunk-Z5O2NQAV.js";import"./chunk-IFJOYAEZ.js";import"./chunk-3Q2P62UR.js";import"./chunk-AWHXPIXU.js";import"./chunk-V3VJAA4D.js";import{a as Ze,b as et,c as tt,d as yt,e as Nt,f as rt,g as at,h as wt,i as St}from"./chunk-NKZCEQJ7.js";import"./chunk-5JDWLCSH.js";import"./chunk-EVTM6Q43.js";import{a as Mt}from"./chunk-S3CRZLGS.js";import{a as _t}from"./chunk-LIOUCOP2.js";import{a as qt,b as kt}from"./chunk-OGUKYRFM.js";import"./chunk-OKG3HWSJ.js";import"./chunk-6D6Z2KXU.js";import"./chunk-6QA34EWC.js";import"./chunk-TDXV3OT5.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{a as Ye}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import{b as He}from"./chunk-FEWMAPNI.js";import"./chunk-225VJ77I.js";import"./chunk-35DM4JJG.js";import{a as Ae}from"./chunk-4ZEL6BYL.js";import{c as Ee}from"./chunk-ZD2UXTLR.js";import{f as mt}from"./chunk-EGVOSH7K.js";import"./chunk-FSRSK4LY.js";import"./chunk-RDL5WK55.js";import{a as gt}from"./chunk-FKVZRPV5.js";import{a as st,b as lt,c as nt,d as je,e as ce,f as W}from"./chunk-HEAQVSNS.js";import{a as fe,b as Fe,c as ze,d as ht,e as pe}from"./chunk-N6NMLJ6R.js";import{d as ge,f as ft,g as pt,h as xt,i as bt,l as We,p as vt}from"./chunk-PTZD7RUZ.js";import{a as d,d as Xe,e as Ut,f as Bt,g as Ht,i as ut}from"./chunk-YKXDMIHQ.js";var Q=Xe(Ut(),1);var xe=Xe(Bt(),1);var t=Xe(Ht(),1);var Wt=/["\\\u0000-\u001F\uD800-\uDFFF]/,$t=d(s=>Wt.test(s)?JSON.stringify(s):`"${s}"`,"ct"),ct=d(s=>{if(s===void 0)return"null";if(typeof s=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key \u2014 pass it as a string, or use stableWireKey");if(typeof s=="number"){if(Number.isNaN(s))return"nan";if(s===1/0)return"inf";if(s===-1/0)return"-inf";if(Object.is(s,-0))return"-0"}if(typeof s=="string")return $t(s);if(s===null||typeof s!="object")return JSON.stringify(s);if(Array.isArray(s)){let i="[";for(let l=0;l<s.length;l++)l>0&&(i+=","),i+=ct(s[l]);return i+"]"}let e=Object.getPrototypeOf(s);if(e!==null&&e!==Object.prototype){let i=s.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${i} in a stable JSON cache key \u2014 only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}let n=s,a=Object.keys(n).sort(),r="{",u=!0;for(let i of a){let l=n[i];l!==void 0&&(u?u=!1:r+=",",r+=$t(i),r+=":",r+=ct(l))}return r+"}"},"Ze"),Qt=d((s,e,n)=>`${s}:${e}:${ct(n??{})}`,"ht"),Jt=d((s,e)=>s==="gauge"?e.last:s==="histogram"?e.sum/Math.max(1,e.count):e.sum,"gt"),Gt=d((s,e)=>Jt(s,e),"Gt"),Vt=d(s=>Jt(s.kind,s),"Wt"),dt=d(s=>Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}),"We"),Xt=d(s=>Array.isArray(s?.series)?s.series:[],"Xt"),Yt="FUNCTION_NOT_FOUND",Zt=d(s=>{let e=new Map;if(!Array.isArray(s?.series))return e;for(let n of s.series)e.set(Qt(n.kind,n.name,n.attributes),n.points);return e},"Zt"),er={counter:"secondary",gauge:"default",histogram:"outline"},tr=d(s=>{let e=(0,xe.c)(18),{name:n,onOpenTrace:a,traceId:r}=s,u=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 l=i;if(a===void 0){let c=`mt-instrument-trace-${n}`,p;return e[3]!==l||e[4]!==c||e[5]!==r?(p=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":c,title:r,children:l}),e[3]=l,e[4]=c,e[5]=r,e[6]=p):p=e[6],p}let g=`mt-instrument-trace-${n}`,v;e[7]!==a||e[8]!==r?(v=d(()=>{a(r)},"y"),e[7]=a,e[8]=r,e[9]=v):v=e[9];let S;e[10]!==u||e[11]!==r?(S=u("Open the exemplar trace {trace}",{trace:r}),e[10]=u,e[11]=r,e[12]=S):S=e[12];let f;return e[13]!==l||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:l}),e[13]=l,e[14]=g,e[15]=v,e[16]=S,e[17]=f):f=e[17],f},"tr"),rr=d(s=>{let e=(0,xe.c)(105),{onOpenTrace:n,shardKey:a}=s,r=ge(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={},e[0]=u):u=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];let{data:l,error:g,errorSource:v}=Ee(Ae.getMetricSeries,u,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}=Ee(Ae.getMetricHistory,S,f),p,y,q,M,o,k,x,b,_,D,h,C,I;if(e[6]!==l||e[7]!==g||e[8]!==v||e[9]!==c||e[10]!==n||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{let F=Xt(l),z=bt(v)===Yt;if(g!==null&&!z){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let $;e[27]!==m?($=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=$):$=e[28];let J;e[29]!==g||e[30]!==r?(J=r("Instruments unavailable: {error}",{error:g}),e[29]=g,e[30]=r,e[31]=J):J=e[31];let U;e[32]!==J?(U=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:J}),e[32]=J,e[33]=U):U=e[33];let de;e[34]!==$||e[35]!==U?(de=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[$,U]}),e[34]=$,e[35]=U,e[36]=de):de=e[36],b=de;break e}if(F.length===0){b=null;break e}let E=Zt(c),L;e[37]!==r?(L=d(m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),"E"),e[37]=r,e[38]=L):L=e[38];let B=L;o="flex flex-col gap-2",k="mt-instruments";let P;e[39]!==r?(P=r("Instruments"),e[39]=r,e[40]=P):P=e[40],e[41]!==P?(x=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:P}),e[41]=P,e[42]=x):x=e[42],M=fe,I="overflow-hidden py-0",q=pe,C="px-0",y=st,D="mt-instruments-table";let A;e[43]!==r?(A=r("name"),e[43]=r,e[44]=A):A=e[44];let j;e[45]!==A?(j=(0,t.jsx)(ce,{children:A}),e[45]=A,e[46]=j):j=e[46];let G;e[47]!==r?(G=r("kind"),e[47]=r,e[48]=G):G=e[48];let V;e[49]!==G?(V=(0,t.jsx)(ce,{children:G}),e[49]=G,e[50]=V):V=e[50];let X;e[51]!==r?(X=r("value"),e[51]=r,e[52]=X):X=e[52];let Y;e[53]!==X?(Y=(0,t.jsx)(ce,{className:"text-right",children:X}),e[53]=X,e[54]=Y):Y=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]!==j||e[76]!==V||e[77]!==Y||e[78]!==ee||e[79]!==re||e[80]!==se||e[81]!==ne||e[82]!==oe?(h=(0,t.jsx)(lt,{children:(0,t.jsxs)(je,{children:[j,V,Y,ee,re,se,ne,oe]})}),e[75]=j,e[76]=V,e[77]=Y,e[78]=ee,e[79]=re,e[80]=se,e[81]=ne,e[82]=oe,e[83]=h):h=e[83],p=nt,_=F.map(m=>{let $=Kt(m.attributes),J=Qt(m.kind,m.name,m.attributes),U=(E.get(J)??[]).map(de=>Gt(m.kind,de));return(0,t.jsxs)(je,{"data-testid":`mt-instrument-${m.name}`,children:[(0,t.jsx)(W,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),(0,t.jsx)(W,{children:(0,t.jsx)(He,{variant:er[m.kind],children:B(m.kind)})}),(0,t.jsx)(W,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:dt(Vt(m))}),(0,t.jsx)(W,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),(0,t.jsx)(W,{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)(W,{children:U.length>=2?(0,t.jsx)(it,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:U,testId:`mt-instrument-trend-${m.name}`}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(W,{className:"font-mono text-xs",children:(0,t.jsx)(tr,{name:m.name,onOpenTrace:n,traceId:m.exemplarTraceId})}),(0,t.jsx)(W,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:$,children:$===""?"\u2014":$})]},J)})}e[6]=l,e[7]=g,e[8]=v,e[9]=c,e[10]=n,e[11]=r,e[12]=p,e[13]=y,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]=h,e[23]=C,e[24]=I}else p=e[12],y=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],h=e[22],C=e[23],I=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let T;e[84]!==p||e[85]!==_?(T=(0,t.jsx)(p,{children:_}),e[84]=p,e[85]=_,e[86]=T):T=e[86];let R;e[87]!==y||e[88]!==T||e[89]!==D||e[90]!==h?(R=(0,t.jsxs)(y,{"data-testid":D,children:[h,T]}),e[87]=y,e[88]=T,e[89]=D,e[90]=h,e[91]=R):R=e[91];let w;e[92]!==q||e[93]!==R||e[94]!==C?(w=(0,t.jsx)(q,{className:C,children:R}),e[92]=q,e[93]=R,e[94]=C,e[95]=w):w=e[95];let N;e[96]!==M||e[97]!==w||e[98]!==I?(N=(0,t.jsx)(M,{className:I,children:w}),e[96]=M,e[97]=w,e[98]=I,e[99]=N):N=e[99];let K;return e[100]!==o||e[101]!==k||e[102]!==x||e[103]!==N?(K=(0,t.jsxs)("section",{className:o,"data-testid":k,children:[x,N]}),e[100]=o,e[101]=k,e[102]=x,e[103]=N,e[104]=K):K=e[104],K},"rr"),ar=d(s=>{let e=(0,xe.c)(74),{aggregate:n,shardResults:a}=s,r=ge(),u;e[0]!==r?(u=r("Shards"),e[0]=r,e[1]=u):u=e[1];let i;e[2]!==n.failed||e[3]!==n.reachable||e[4]!==r?(i=n.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:n.failed,reachable:n.reachable}):r("{reachable} reachable",{reachable:n.reachable}),e[2]=n.failed,e[3]=n.reachable,e[4]=r,e[5]=i):i=e[5];let l;e[6]!==u||e[7]!==i?(l=(0,t.jsx)(me,{label:u,testId:"mt-agg-shards",value:i}),e[6]=u,e[7]=i,e[8]=l):l=e[8];let g;e[9]!==r?(g=r("Total requests"),e[9]=r,e[10]=g):g=e[10];let v;e[11]!==n.totalRequests||e[12]!==g?(v=(0,t.jsx)(me,{label:g,testId:"mt-agg-requests",value:n.totalRequests}),e[11]=n.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]!==n.totalErrors||e[17]!==S?(f=(0,t.jsx)(me,{label:S,testId:"mt-agg-errors",value:n.totalErrors}),e[16]=n.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]!==n.totalDatabaseSize?(p=We(n.totalDatabaseSize),e[21]=n.totalDatabaseSize,e[22]=p):p=e[22];let y;e[23]!==c||e[24]!==p?(y=(0,t.jsx)(me,{label:c,testId:"mt-agg-db-size",value:p}),e[23]=c,e[24]=p,e[25]=y):y=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]!==n.hitRate||e[29]!==r?(M=n.hitRate===null?r("no cache configured"):`${(n.hitRate*100).toFixed(1)}%`,e[28]=n.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]!==y||e[35]!==o||e[36]!==l||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:[l,v,f,y,o]}),e[34]=y,e[35]=o,e[36]=l,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 h;e[48]!==r?(h=r("errors"),e[48]=r,e[49]=h):h=e[49];let C;e[50]!==h?(C=(0,t.jsx)(ce,{children:h}),e[50]=h,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 T;e[54]!==I?(T=(0,t.jsx)(ce,{children:I}),e[54]=I,e[55]=T):T=e[55];let R;e[56]!==b||e[57]!==D||e[58]!==C||e[59]!==T?(R=(0,t.jsx)(lt,{children:(0,t.jsxs)(je,{children:[b,D,C,T]})}),e[56]=b,e[57]=D,e[58]=C,e[59]=T,e[60]=R):R=e[60];let w;if(e[61]!==a||e[62]!==r){let z;e[64]!==r?(z=d(E=>(0,t.jsxs)(je,{"data-testid":`mt-agg-row-${E.shard}`,children:[(0,t.jsx)(W,{children:E.shard}),E.metrics===null?(0,t.jsx)(W,{className:"text-destructive",colSpan:3,children:E.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(W,{className:"tabular-nums",children:E.metrics.requests}),(0,t.jsx)(W,{className:"tabular-nums",children:E.metrics.errors}),(0,t.jsx)(W,{className:"tabular-nums",children:We(E.metrics.databaseSize)})]})]},E.shard),"L"),e[64]=r,e[65]=z):z=e[65],w=a.map(z),e[61]=a,e[62]=r,e[63]=w}else w=e[63];let N;e[66]!==w?(N=(0,t.jsx)(nt,{children:w}),e[66]=w,e[67]=N):N=e[67];let K;e[68]!==R||e[69]!==N?(K=(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:[R,N]})})}),e[68]=R,e[69]=N,e[70]=K):K=e[70];let F;return e[71]!==k||e[72]!==K?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[k,K]}),e[71]=k,e[72]=K,e[73]=F):F=e[73],F},"sr"),sr=d(s=>{let e=(0,xe.c)(75),{currentDelta:n,errorRate:a,history:r,latencyPercentiles:u,metrics:i}=s,l=ge(),{cache:g}=i,v;e[0]!==r||e[1]!==l?(v=r.length>=2?(0,t.jsx)(it,{ariaLabel:l("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=l,e[2]=v):v=e[2];let S;e[3]!==n||e[4]!==r.length||e[5]!==l?(S=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${n.toLocaleString()}`})," ",l("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:l("collecting samples\u2026")}),e[3]=n,e[4]=r.length,e[5]=l,e[6]=S):S=e[6];let f;e[7]!==l?(f=l("Requests"),e[7]=l,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]!==l?(p=l("{rate} error rate",{rate:a}),e[14]=a,e[15]=l,e[16]=p):p=e[16];let y;e[17]!==l?(y=l("Errors"),e[17]=l,e[18]=y):y=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]!==y||e[24]!==q?(M=(0,t.jsx)(me,{footer:p,label:y,testId:"mt-errors",value:q}),e[22]=p,e[23]=y,e[24]=q,e[25]=M):M=e[25];let o;e[26]!==u.p90?(o=u.p90>0?`P90 ${ot(u.p90)}`:void 0,e[26]=u.p90,e[27]=o):o=e[27];let k;e[28]!==l?(k=l("P95 latency"),e[28]=l,e[29]=k):k=e[29];let x;e[30]!==u.p95?(x=u.p95>0?ot(u.p95):"\u2014",e[30]=u.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]!==l?(_=g?`${g.entries.toLocaleString()} ${l("cache entries")}`:void 0,e[36]=g,e[37]=l,e[38]=_):_=e[38];let D;e[39]!==l?(D=l("Database size"),e[39]=l,e[40]=D):D=e[40];let h;e[41]!==i.databaseSize?(h=We(i.databaseSize),e[41]=i.databaseSize,e[42]=h):h=e[42];let C;e[43]!==_||e[44]!==D||e[45]!==h?(C=(0,t.jsx)(me,{footer:_,label:D,testId:"mt-db-size",value:h}),e[43]=_,e[44]=D,e[45]=h,e[46]=C):C=e[46];let I;e[47]!==l?(I=l("Shard"),e[47]=l,e[48]=I):I=e[48];let T;e[49]!==i.shard||e[50]!==I?(T=(0,t.jsx)(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=T):T=e[51];let R;e[52]!==l?(R=l("Uptime"),e[52]=l,e[53]=R):R=e[53];let w;e[54]!==i.uptimeMs?(w=jt(i.uptimeMs),e[54]=i.uptimeMs,e[55]=w):w=e[55];let N;e[56]!==R||e[57]!==w?(N=(0,t.jsx)(me,{label:R,testId:"mt-uptime",value:w}),e[56]=R,e[57]=w,e[58]=N):N=e[58];let K;e[59]!==l?(K=l("Cache hit rate"),e[59]=l,e[60]=K):K=e[60];let F;e[61]!==g||e[62]!==l?(F=g?l("{rate} ({count} entries)",{count:g.entries,rate:Pt(g.hits,g.misses)}):l("no cache configured"),e[61]=g,e[62]=l,e[63]=F):F=e[63];let z;e[64]!==K||e[65]!==F?(z=(0,t.jsx)(me,{label:K,testId:"mt-cache",value:F}),e[64]=K,e[65]=F,e[66]=z):z=e[66];let E;return e[67]!==b||e[68]!==C||e[69]!==T||e[70]!==N||e[71]!==z||e[72]!==c||e[73]!==M?(E=(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,T,N,z]}),e[67]=b,e[68]=C,e[69]=T,e[70]=N,e[71]=z,e[72]=c,e[73]=M,e[74]=E):E=e[74],E},"lr"),Ve=d(s=>s>=100?"critical":s>=50?"warning":"good","Ve"),$e=d(s=>s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"Fe"),Ge=d(s=>s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString(),"He"),lr=d(s=>{let e=(0,xe.c)(3),{level:n}=s;if(n==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(He,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(n==="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},"ar"),nr=d((s,e)=>{let n=[...s];return n.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}}),n},"ir"),ir=d(s=>{let e=(0,xe.c)(161),{queryStats:n}=s,a=ge(),[r,u]=(0,Q.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[l,g]=(0,Q.useState)(i),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=d(I=>{I!==null&&u(I)},"y"),e[1]=v):v=e[1];let S=v,f,c,p,y,q,M,o,k,x,b;if(e[2]!==l||e[3]!==n||e[4]!==r||e[5]!==a){p=Symbol.for("react.early_return_sentinel");e:{let I=nr(n,r),T;e[16]!==n?(T=n.filter(or),e[16]=n,e[17]=T):T=e[17];let R=T.length,w;e[18]!==n?(w=n.filter(dr),e[18]=n,e[19]=w):w=e[19];let N=w.length,K;e[20]!==n?(K=n.filter(cr),e[20]=n,e[21]=K):K=e[21];let F=K.length,z;e[22]===Symbol.for("react.memo_cache_sentinel")?(z=d(O=>{g(ue=>{let H=new Set(ue);return H.has(O)?H.delete(O):H.add(O),H})},"L"),e[22]=z):z=e[22];let E=z;if(n.length===0){let O;e[23]!==a?(O=a("No query insights yet"),e[23]=a,e[24]=O):O=e[24];let ue;e[25]!==O?(ue=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:O}),e[25]=O,e[26]=ue):ue=e[26];let H;e[27]!==a?(H=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=H):H=e[28];let he;e[29]!==H?(he=(0,t.jsx)("p",{className:"mt-1 text-sm",children:H}),e[29]=H,e[30]=he):he=e[30];let Be;e[31]!==ue||e[32]!==he?(Be=(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]=Be):Be=e[33],p=Be;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 B;e[36]!==L?(B=(0,t.jsx)(Fe,{className:"pb-2",children:(0,t.jsx)(ze,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=B):B=e[37];let P;e[38]!==R?(P=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:R}),e[38]=R,e[39]=P):P=e[39];let A;e[40]!==a?(A=a(">100ms avg execution"),e[40]=a,e[41]=A):A=e[41];let j;e[42]!==A?(j=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:A}),e[42]=A,e[43]=j):j=e[43];let G;e[44]!==P||e[45]!==j?(G=(0,t.jsxs)(pe,{children:[P,j]}),e[44]=P,e[45]=j,e[46]=G):G=e[46];let V;e[47]!==B||e[48]!==G?(V=(0,t.jsxs)(fe,{children:[B,G]}),e[47]=B,e[48]=G,e[49]=V):V=e[49];let X;e[50]!==a?(X=a("Moderate queries"),e[50]=a,e[51]=X):X=e[51];let Y;e[52]!==X?(Y=(0,t.jsx)(Fe,{className:"pb-2",children:(0,t.jsx)(ze,{className:"text-sm font-medium",children:X})}),e[52]=X,e[53]=Y):Y=e[53];let Z;e[54]!==N?(Z=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:N}),e[54]=N,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]!==Y||e[64]!==re?(ae=(0,t.jsxs)(fe,{children:[Y,re]}),e[63]=Y,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)(Fe,{className:"pb-2",children:(0,t.jsx)(ze,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ne;e[70]!==F?(ne=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:F}),e[70]=F,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 $;e[79]!==le||e[80]!==m?($=(0,t.jsxs)(fe,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=$):$=e[81],e[82]!==V||e[83]!==ae||e[84]!==$?(x=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[V,ae,$]}),e[82]=V,e[83]=ae,e[84]=$,e[85]=x):x=e[85];let J;e[86]!==a?(J=a("Query leaderboard"),e[86]=a,e[87]=J):J=e[87];let U;e[88]!==J?(U=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:J}),e[88]=J,e[89]=U):U=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]!==U||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[U,be]}),e[95]=U,e[96]=be,e[97]=ve):ve=e[97];let ye;e[98]!==a?(ye=a("Sort by"),e[98]=a,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let we;e[102]!==a?(we=a("Sort queries by"),e[102]=a,e[103]=we):we=e[103];let Qe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Qe=(0,t.jsx)(Tt,{}),e[104]=Qe):Qe=e[104];let Se;e[105]!==we?(Se=(0,t.jsx)(Rt,{"aria-label":we,className:"w-[140px]","data-testid":"qi-sort",children:Qe}),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)(Pe,{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)(Pe,{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)(Pe,{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 Te;e[121]!==Ie?(Te=(0,t.jsx)(Pe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Te):Te=e[122];let Re;e[123]!==ke||e[124]!==Me||e[125]!==Ce||e[126]!==Te?(Re=(0,t.jsxs)(Ot,{children:[ke,Me,Ce,Te]}),e[123]=ke,e[124]=Me,e[125]=Ce,e[126]=Te,e[127]=Re):Re=e[127];let Oe;e[128]!==r||e[129]!==Se||e[130]!==Re?(Oe=(0,t.jsxs)(It,{onValueChange:S,value:r,children:[Se,Re]}),e[128]=r,e[129]=Se,e[130]=Re,e[131]=Oe):Oe=e[131];let Ke;e[132]!==Ne||e[133]!==Oe?(Ke=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[Ne,Oe]}),e[132]=Ne,e[133]=Oe,e[134]=Ke):Ke=e[134],e[135]!==ve||e[136]!==Ke?(b=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,Ke]}),e[135]=ve,e[136]=Ke,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 Je;e[140]!==Le?(Je=(0,t.jsx)(ze,{children:Le}),e[140]=Le,e[141]=Je):Je=e[141],M=(0,t.jsxs)(Fe,{children:[Je,(0,t.jsx)(ht,{children:a("{count} tracked statements",{count:I.length})})]}),f=pe,y="space-y-2";let Ue;e[142]!==l||e[143]!==a?(Ue=d(O=>{let ue=O.normalizedSql,H=l.has(ue),he=Ve(O.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":H,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:d(()=>{E(ue)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(lr,{level:he}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:O.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:$e(O.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:$e(O.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),O.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:$e(O.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:Ge(O.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),H&&(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:O.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[O.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:$e(O.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:Ge(O.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:$e(O.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:Ge(O.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:Ge(O.rowsWritten)})]})]})]})]},ue)},"Ke"),e[142]=l,e[143]=a,e[144]=Ue):Ue=e[144],q=I.map(Ue)}e[2]=l,e[3]=n,e[4]=r,e[5]=a,e[6]=f,e[7]=c,e[8]=p,e[9]=y,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],y=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]!==y||e[146]!==q?(_=(0,t.jsx)("div",{className:y,children:q}),e[145]=y,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 h;e[151]!==c||e[152]!==D||e[153]!==M?(h=(0,t.jsxs)(c,{children:[M,D]}),e[151]=c,e[152]=D,e[153]=M,e[154]=h):h=e[154];let C;return e[155]!==h||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,h]}),e[155]=h,e[156]=o,e[157]=k,e[158]=x,e[159]=b,e[160]=C):C=e[160],C},"nr");function or(s){return Ve(s.avgDurationMs)==="critical"}d(or,"or");function dr(s){return Ve(s.avgDurationMs)==="warning"}d(dr,"cr");function cr(s){return Ve(s.avgDurationMs)==="good"}d(cr,"dr");var mr=["1m","5m","15m","1h"],ur=d(s=>new Date(s).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"fr"),hr=d(s=>s.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),"ur"),gr=d(({shardKey:s=""})=>{let e=ge(),[n,a]=(0,Q.useState)("15m"),r=Ee(Ae.getQueryInsights,{range:n},{live:!0,shardKey:s}).data,u=hr(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:mr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===n,className:ut("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===n&&"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)(He,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),u.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:u,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)(Nt,{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:u,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)(yt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(ir,{queryStats:r?.entries??[]})]})},"hr"),fr=ft(Ae.getMetrics),pr=d((s,e)=>s?e:"overview","pr"),Pr=d(({initialShardKey:s})=>{let e=mt(),n=ge(),{queryShardKey:a,setShardKey:r,shardKey:u}=Mt(s),[i,l]=(0,Q.useState)("overview"),[g,v]=(0,Q.useState)([]),S=(0,Q.useRef)(null),f=(0,Q.useRef)(null),c=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=Lt(a),{data:y,error:q,liveError:M}=Ee(Ae.getMetrics,{},{live:!0,shardKey:a}),o=y??null;(0,Q.useEffect)(()=>{if(y===void 0)return;kt(a);let L=y,B=S.current,P=f.current!==null&&f.current!==L.shard;if(f.current=L.shard,S.current=L.requests,P){v([]);return}B!==null&&L.requests>=B&&v(A=>[...A,L.requests-B].slice(-30))},[y,a]);let[k,x]=(0,Q.useState)(null),[b,_]=(0,Q.useState)(!1),D=d(async()=>{_(!0);let L=u,B=Ft(L,qt());try{let P=await Promise.all(B.map(async A=>{try{let j=await e.query(fr,{},pt(A));return{error:null,metrics:j,shard:A===""?j.shard:A}}catch(j){return{error:xt(j),metrics:null,shard:A===""?"__root__":A}}}));c.current&&x({results:P,shard:L})}finally{c.current&&_(!1)}},"k"),h=k?.shard===u?k.results:null,C=h===null?null:At(h),I=o===null||o.requests===0?"\u2014":`${(o.errors/o.requests*100).toFixed(1)}%`,T=g.length>0?g.at(-1):0,R=o?zt(o):{p90:0,p95:0},w=(0,Q.useMemo)(()=>{if(!o||!("queryStats"in o))return;let L=o.queryStats;if(!(!L||!Array.isArray(L)))return Et(L)},[o]),N=pr(w!==void 0,i),K=d(()=>{vt(D())},"A"),F=d(()=>{x(null)},"O"),z=d(()=>{l("overview")},"L"),E=d(()=>{l("query-insights")},"z");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:u}),(0,t.jsx)(Dt,{message:M,prefix:"mt"}),(0,t.jsx)(Ye,{"data-testid":"mt-aggregate",disabled:b,onClick:K,size:"sm",type:"button",variant:"secondary",children:n(b?"Aggregating\u2026":"All shards")}),h!==null&&(0,t.jsx)(Ye,{"data-testid":"mt-aggregate-clear",onClick:F,size:"sm",type:"button",variant:"ghost",children:n("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:n("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 ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:z,type:"button",children:n("Overview")}),(0,t.jsxs)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:E,type:"button",children:[n("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})]})]}),N==="query-insights"&&w!==void 0&&(0,t.jsx)(gr,{shardKey:a}),N==="overview"&&o!==null&&(0,t.jsx)(sr,{currentDelta:T,errorRate:I,history:g,latencyPercentiles:R,metrics:o}),N==="overview"&&o===null&&null,N==="overview"&&(0,t.jsx)(rr,{onOpenTrace:p,shardKey:a}),N==="overview"&&C!==null&&h!==null&&(0,t.jsx)(ar,{aggregate:C,shardResults:h})]})},"Qr");export{Pr as MetricsPanel};
1
+ import{a as jt,b as Pt,c as ot}from"./chunk-CVXNHIQW.js";import{a as At,b as Ft,c as zt,d as Et}from"./chunk-2I4NHEKA.js";import{a as it}from"./chunk-5NOZE2BB.js";import{a as me}from"./chunk-253UHWDX.js";import{a as It,b as Tt,c as Rt,d as Ot,e as Pe}from"./chunk-5QR2SQIS.js";import{a as Lt}from"./chunk-6QTAHSDD.js";import{a as Kt}from"./chunk-WMN5PZZX.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 yt,e as Nt,f as rt,g as at,h as wt,i as St}from"./chunk-H2QIHAXY.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 Ye}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import{b as He}from"./chunk-Q6ED4KUL.js";import"./chunk-BOMPSVRC.js";import"./chunk-55UGUCQ6.js";import{a as Ae}from"./chunk-4ZEL6BYL.js";import{c as Ee}from"./chunk-HECPC2VY.js";import{f as mt}from"./chunk-WNZLTRKF.js";import"./chunk-QAQDMS6R.js";import"./chunk-PCBRDDD7.js";import{a as gt}from"./chunk-RWVIV3U7.js";import{a as st,b as lt,c as nt,d as je,e as ce,f as W}from"./chunk-HCTJKP5J.js";import{a as fe,b as Fe,c as ze,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 We,p as vt}from"./chunk-HJHSQPHW.js";import{a as d,d as Xe,e as Ut,f as Bt,g as Ht,i as ut}from"./chunk-I26MS5PJ.js";var Q=Xe(Ut(),1);var xe=Xe(Bt(),1);var t=Xe(Ht(),1);var Wt=/["\\\u0000-\u001F\uD800-\uDFFF]/,$t=d(s=>Wt.test(s)?JSON.stringify(s):`"${s}"`,"ct"),ct=d(s=>{if(s===void 0)return"null";if(typeof s=="bigint")throw new TypeError("stableStringify: cannot use a bigint in a stable JSON cache key \u2014 pass it as a string, or use stableWireKey");if(typeof s=="number"){if(Number.isNaN(s))return"nan";if(s===1/0)return"inf";if(s===-1/0)return"-inf";if(Object.is(s,-0))return"-0"}if(typeof s=="string")return $t(s);if(s===null||typeof s!="object")return JSON.stringify(s);if(Array.isArray(s)){let i="[";for(let l=0;l<s.length;l++)l>0&&(i+=","),i+=ct(s[l]);return i+"]"}let e=Object.getPrototypeOf(s);if(e!==null&&e!==Object.prototype){let i=s.constructor?.name??"value";throw new TypeError(`stableStringify: cannot use a ${i} in a stable JSON cache key \u2014 only plain objects, arrays, and JSON primitives are supported (wire-typed values key via stableWireKey)`)}let n=s,a=Object.keys(n).sort(),r="{",u=!0;for(let i of a){let l=n[i];l!==void 0&&(u?u=!1:r+=",",r+=$t(i),r+=":",r+=ct(l))}return r+"}"},"Ze"),Qt=d((s,e,n)=>`${s}:${e}:${ct(n??{})}`,"ht"),Jt=d((s,e)=>s==="gauge"?e.last:s==="histogram"?e.sum/Math.max(1,e.count):e.sum,"gt"),Gt=d((s,e)=>Jt(s,e),"Gt"),Vt=d(s=>Jt(s.kind,s),"Wt"),dt=d(s=>Number.isInteger(s)?s.toLocaleString():s.toLocaleString(void 0,{maximumFractionDigits:2}),"We"),Xt=d(s=>Array.isArray(s?.series)?s.series:[],"Xt"),Yt="FUNCTION_NOT_FOUND",Zt=d(s=>{let e=new Map;if(!Array.isArray(s?.series))return e;for(let n of s.series)e.set(Qt(n.kind,n.name,n.attributes),n.points);return e},"Zt"),er={counter:"secondary",gauge:"default",histogram:"outline"},tr=d(s=>{let e=(0,xe.c)(18),{name:n,onOpenTrace:a,traceId:r}=s,u=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 l=i;if(a===void 0){let c=`mt-instrument-trace-${n}`,p;return e[3]!==l||e[4]!==c||e[5]!==r?(p=(0,t.jsx)("span",{className:"text-muted-foreground","data-testid":c,title:r,children:l}),e[3]=l,e[4]=c,e[5]=r,e[6]=p):p=e[6],p}let g=`mt-instrument-trace-${n}`,v;e[7]!==a||e[8]!==r?(v=d(()=>{a(r)},"y"),e[7]=a,e[8]=r,e[9]=v):v=e[9];let S;e[10]!==u||e[11]!==r?(S=u("Open the exemplar trace {trace}",{trace:r}),e[10]=u,e[11]=r,e[12]=S):S=e[12];let f;return e[13]!==l||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:l}),e[13]=l,e[14]=g,e[15]=v,e[16]=S,e[17]=f):f=e[17],f},"tr"),rr=d(s=>{let e=(0,xe.c)(105),{onOpenTrace:n,shardKey:a}=s,r=ge(),u;e[0]===Symbol.for("react.memo_cache_sentinel")?(u={},e[0]=u):u=e[0];let i;e[1]!==a?(i={live:!0,shardKey:a},e[1]=a,e[2]=i):i=e[2];let{data:l,error:g,errorSource:v}=Ee(Ae.getMetricSeries,u,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}=Ee(Ae.getMetricHistory,S,f),p,y,q,M,o,k,x,b,_,D,h,C,I;if(e[6]!==l||e[7]!==g||e[8]!==v||e[9]!==c||e[10]!==n||e[11]!==r){b=Symbol.for("react.early_return_sentinel");e:{let F=Xt(l),z=bt(v)===Yt;if(g!==null&&!z){let m;e[25]!==r?(m=r("Instruments"),e[25]=r,e[26]=m):m=e[26];let $;e[27]!==m?($=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:m}),e[27]=m,e[28]=$):$=e[28];let J;e[29]!==g||e[30]!==r?(J=r("Instruments unavailable: {error}",{error:g}),e[29]=g,e[30]=r,e[31]=J):J=e[31];let U;e[32]!==J?(U=(0,t.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":"mt-instruments-error",role:"status",children:J}),e[32]=J,e[33]=U):U=e[33];let de;e[34]!==$||e[35]!==U?(de=(0,t.jsxs)("section",{className:"flex flex-col gap-2","data-testid":"mt-instruments",children:[$,U]}),e[34]=$,e[35]=U,e[36]=de):de=e[36],b=de;break e}if(F.length===0){b=null;break e}let E=Zt(c),L;e[37]!==r?(L=d(m=>r(m==="counter"?"Counter":m==="gauge"?"Gauge":"Histogram"),"E"),e[37]=r,e[38]=L):L=e[38];let B=L;o="flex flex-col gap-2",k="mt-instruments";let P;e[39]!==r?(P=r("Instruments"),e[39]=r,e[40]=P):P=e[40],e[41]!==P?(x=(0,t.jsx)("h3",{className:"text-sm font-semibold text-foreground",children:P}),e[41]=P,e[42]=x):x=e[42],M=fe,I="overflow-hidden py-0",q=pe,C="px-0",y=st,D="mt-instruments-table";let A;e[43]!==r?(A=r("name"),e[43]=r,e[44]=A):A=e[44];let j;e[45]!==A?(j=(0,t.jsx)(ce,{children:A}),e[45]=A,e[46]=j):j=e[46];let G;e[47]!==r?(G=r("kind"),e[47]=r,e[48]=G):G=e[48];let V;e[49]!==G?(V=(0,t.jsx)(ce,{children:G}),e[49]=G,e[50]=V):V=e[50];let X;e[51]!==r?(X=r("value"),e[51]=r,e[52]=X):X=e[52];let Y;e[53]!==X?(Y=(0,t.jsx)(ce,{className:"text-right",children:X}),e[53]=X,e[54]=Y):Y=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]!==j||e[76]!==V||e[77]!==Y||e[78]!==ee||e[79]!==re||e[80]!==se||e[81]!==ne||e[82]!==oe?(h=(0,t.jsx)(lt,{children:(0,t.jsxs)(je,{children:[j,V,Y,ee,re,se,ne,oe]})}),e[75]=j,e[76]=V,e[77]=Y,e[78]=ee,e[79]=re,e[80]=se,e[81]=ne,e[82]=oe,e[83]=h):h=e[83],p=nt,_=F.map(m=>{let $=Kt(m.attributes),J=Qt(m.kind,m.name,m.attributes),U=(E.get(J)??[]).map(de=>Gt(m.kind,de));return(0,t.jsxs)(je,{"data-testid":`mt-instrument-${m.name}`,children:[(0,t.jsx)(W,{className:"font-mono text-xs",title:m.functionPath,children:m.name}),(0,t.jsx)(W,{children:(0,t.jsx)(He,{variant:er[m.kind],children:B(m.kind)})}),(0,t.jsx)(W,{className:"text-right font-mono tabular-nums","data-testid":`mt-instrument-value-${m.name}`,children:dt(Vt(m))}),(0,t.jsx)(W,{className:"text-right tabular-nums text-muted-foreground",children:m.count.toLocaleString()}),(0,t.jsx)(W,{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)(W,{children:U.length>=2?(0,t.jsx)(it,{ariaLabel:r("{name} trend",{name:m.name}),className:"h-6 w-24 text-foreground",series:U,testId:`mt-instrument-trend-${m.name}`}):(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:"\u2014"})}),(0,t.jsx)(W,{className:"font-mono text-xs",children:(0,t.jsx)(tr,{name:m.name,onOpenTrace:n,traceId:m.exemplarTraceId})}),(0,t.jsx)(W,{className:"max-w-64 truncate font-mono text-xs text-muted-foreground",title:$,children:$===""?"\u2014":$})]},J)})}e[6]=l,e[7]=g,e[8]=v,e[9]=c,e[10]=n,e[11]=r,e[12]=p,e[13]=y,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]=h,e[23]=C,e[24]=I}else p=e[12],y=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],h=e[22],C=e[23],I=e[24];if(b!==Symbol.for("react.early_return_sentinel"))return b;let T;e[84]!==p||e[85]!==_?(T=(0,t.jsx)(p,{children:_}),e[84]=p,e[85]=_,e[86]=T):T=e[86];let R;e[87]!==y||e[88]!==T||e[89]!==D||e[90]!==h?(R=(0,t.jsxs)(y,{"data-testid":D,children:[h,T]}),e[87]=y,e[88]=T,e[89]=D,e[90]=h,e[91]=R):R=e[91];let w;e[92]!==q||e[93]!==R||e[94]!==C?(w=(0,t.jsx)(q,{className:C,children:R}),e[92]=q,e[93]=R,e[94]=C,e[95]=w):w=e[95];let N;e[96]!==M||e[97]!==w||e[98]!==I?(N=(0,t.jsx)(M,{className:I,children:w}),e[96]=M,e[97]=w,e[98]=I,e[99]=N):N=e[99];let K;return e[100]!==o||e[101]!==k||e[102]!==x||e[103]!==N?(K=(0,t.jsxs)("section",{className:o,"data-testid":k,children:[x,N]}),e[100]=o,e[101]=k,e[102]=x,e[103]=N,e[104]=K):K=e[104],K},"rr"),ar=d(s=>{let e=(0,xe.c)(74),{aggregate:n,shardResults:a}=s,r=ge(),u;e[0]!==r?(u=r("Shards"),e[0]=r,e[1]=u):u=e[1];let i;e[2]!==n.failed||e[3]!==n.reachable||e[4]!==r?(i=n.failed>0?r("{reachable} reachable, {failed} unreachable",{failed:n.failed,reachable:n.reachable}):r("{reachable} reachable",{reachable:n.reachable}),e[2]=n.failed,e[3]=n.reachable,e[4]=r,e[5]=i):i=e[5];let l;e[6]!==u||e[7]!==i?(l=(0,t.jsx)(me,{label:u,testId:"mt-agg-shards",value:i}),e[6]=u,e[7]=i,e[8]=l):l=e[8];let g;e[9]!==r?(g=r("Total requests"),e[9]=r,e[10]=g):g=e[10];let v;e[11]!==n.totalRequests||e[12]!==g?(v=(0,t.jsx)(me,{label:g,testId:"mt-agg-requests",value:n.totalRequests}),e[11]=n.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]!==n.totalErrors||e[17]!==S?(f=(0,t.jsx)(me,{label:S,testId:"mt-agg-errors",value:n.totalErrors}),e[16]=n.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]!==n.totalDatabaseSize?(p=We(n.totalDatabaseSize),e[21]=n.totalDatabaseSize,e[22]=p):p=e[22];let y;e[23]!==c||e[24]!==p?(y=(0,t.jsx)(me,{label:c,testId:"mt-agg-db-size",value:p}),e[23]=c,e[24]=p,e[25]=y):y=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]!==n.hitRate||e[29]!==r?(M=n.hitRate===null?r("no cache configured"):`${(n.hitRate*100).toFixed(1)}%`,e[28]=n.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]!==y||e[35]!==o||e[36]!==l||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:[l,v,f,y,o]}),e[34]=y,e[35]=o,e[36]=l,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 h;e[48]!==r?(h=r("errors"),e[48]=r,e[49]=h):h=e[49];let C;e[50]!==h?(C=(0,t.jsx)(ce,{children:h}),e[50]=h,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 T;e[54]!==I?(T=(0,t.jsx)(ce,{children:I}),e[54]=I,e[55]=T):T=e[55];let R;e[56]!==b||e[57]!==D||e[58]!==C||e[59]!==T?(R=(0,t.jsx)(lt,{children:(0,t.jsxs)(je,{children:[b,D,C,T]})}),e[56]=b,e[57]=D,e[58]=C,e[59]=T,e[60]=R):R=e[60];let w;if(e[61]!==a||e[62]!==r){let z;e[64]!==r?(z=d(E=>(0,t.jsxs)(je,{"data-testid":`mt-agg-row-${E.shard}`,children:[(0,t.jsx)(W,{children:E.shard}),E.metrics===null?(0,t.jsx)(W,{className:"text-destructive",colSpan:3,children:E.error??r("unreachable")}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(W,{className:"tabular-nums",children:E.metrics.requests}),(0,t.jsx)(W,{className:"tabular-nums",children:E.metrics.errors}),(0,t.jsx)(W,{className:"tabular-nums",children:We(E.metrics.databaseSize)})]})]},E.shard),"L"),e[64]=r,e[65]=z):z=e[65],w=a.map(z),e[61]=a,e[62]=r,e[63]=w}else w=e[63];let N;e[66]!==w?(N=(0,t.jsx)(nt,{children:w}),e[66]=w,e[67]=N):N=e[67];let K;e[68]!==R||e[69]!==N?(K=(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:[R,N]})})}),e[68]=R,e[69]=N,e[70]=K):K=e[70];let F;return e[71]!==k||e[72]!==K?(F=(0,t.jsxs)("div",{className:"flex flex-col gap-4","data-testid":"mt-aggregate-view",children:[k,K]}),e[71]=k,e[72]=K,e[73]=F):F=e[73],F},"sr"),sr=d(s=>{let e=(0,xe.c)(75),{currentDelta:n,errorRate:a,history:r,latencyPercentiles:u,metrics:i}=s,l=ge(),{cache:g}=i,v;e[0]!==r||e[1]!==l?(v=r.length>=2?(0,t.jsx)(it,{ariaLabel:l("Requests per interval over time"),className:"h-7 w-24 text-foreground",series:r,testId:"mt-sparkline"}):void 0,e[0]=r,e[1]=l,e[2]=v):v=e[2];let S;e[3]!==n||e[4]!==r.length||e[5]!==l?(S=r.length>=2?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("span",{className:"font-semibold text-foreground",children:`+${n.toLocaleString()}`})," ",l("last interval")]}):(0,t.jsx)("span",{"data-testid":"mt-sparkline-empty",children:l("collecting samples\u2026")}),e[3]=n,e[4]=r.length,e[5]=l,e[6]=S):S=e[6];let f;e[7]!==l?(f=l("Requests"),e[7]=l,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]!==l?(p=l("{rate} error rate",{rate:a}),e[14]=a,e[15]=l,e[16]=p):p=e[16];let y;e[17]!==l?(y=l("Errors"),e[17]=l,e[18]=y):y=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]!==y||e[24]!==q?(M=(0,t.jsx)(me,{footer:p,label:y,testId:"mt-errors",value:q}),e[22]=p,e[23]=y,e[24]=q,e[25]=M):M=e[25];let o;e[26]!==u.p90?(o=u.p90>0?`P90 ${ot(u.p90)}`:void 0,e[26]=u.p90,e[27]=o):o=e[27];let k;e[28]!==l?(k=l("P95 latency"),e[28]=l,e[29]=k):k=e[29];let x;e[30]!==u.p95?(x=u.p95>0?ot(u.p95):"\u2014",e[30]=u.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]!==l?(_=g?`${g.entries.toLocaleString()} ${l("cache entries")}`:void 0,e[36]=g,e[37]=l,e[38]=_):_=e[38];let D;e[39]!==l?(D=l("Database size"),e[39]=l,e[40]=D):D=e[40];let h;e[41]!==i.databaseSize?(h=We(i.databaseSize),e[41]=i.databaseSize,e[42]=h):h=e[42];let C;e[43]!==_||e[44]!==D||e[45]!==h?(C=(0,t.jsx)(me,{footer:_,label:D,testId:"mt-db-size",value:h}),e[43]=_,e[44]=D,e[45]=h,e[46]=C):C=e[46];let I;e[47]!==l?(I=l("Shard"),e[47]=l,e[48]=I):I=e[48];let T;e[49]!==i.shard||e[50]!==I?(T=(0,t.jsx)(me,{label:I,testId:"mt-shard",value:i.shard}),e[49]=i.shard,e[50]=I,e[51]=T):T=e[51];let R;e[52]!==l?(R=l("Uptime"),e[52]=l,e[53]=R):R=e[53];let w;e[54]!==i.uptimeMs?(w=jt(i.uptimeMs),e[54]=i.uptimeMs,e[55]=w):w=e[55];let N;e[56]!==R||e[57]!==w?(N=(0,t.jsx)(me,{label:R,testId:"mt-uptime",value:w}),e[56]=R,e[57]=w,e[58]=N):N=e[58];let K;e[59]!==l?(K=l("Cache hit rate"),e[59]=l,e[60]=K):K=e[60];let F;e[61]!==g||e[62]!==l?(F=g?l("{rate} ({count} entries)",{count:g.entries,rate:Pt(g.hits,g.misses)}):l("no cache configured"),e[61]=g,e[62]=l,e[63]=F):F=e[63];let z;e[64]!==K||e[65]!==F?(z=(0,t.jsx)(me,{label:K,testId:"mt-cache",value:F}),e[64]=K,e[65]=F,e[66]=z):z=e[66];let E;return e[67]!==b||e[68]!==C||e[69]!==T||e[70]!==N||e[71]!==z||e[72]!==c||e[73]!==M?(E=(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,T,N,z]}),e[67]=b,e[68]=C,e[69]=T,e[70]=N,e[71]=z,e[72]=c,e[73]=M,e[74]=E):E=e[74],E},"lr"),Ve=d(s=>s>=100?"critical":s>=50?"warning":"good","Ve"),$e=d(s=>s<1?`${(s*1e3).toFixed(0)}\u03BCs`:s<1e3?`${s.toFixed(1)}ms`:`${(s/1e3).toFixed(2)}s`,"Fe"),Ge=d(s=>s>=1e9?`${(s/1e9).toFixed(1)}B`:s>=1e6?`${(s/1e6).toFixed(1)}M`:s>=1e3?`${(s/1e3).toFixed(1)}K`:s.toLocaleString(),"He"),lr=d(s=>{let e=(0,xe.c)(3),{level:n}=s;if(n==="critical"){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=(0,t.jsx)(He,{variant:"destructive",children:"Slow"}),e[0]=r):r=e[0],r}if(n==="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},"ar"),nr=d((s,e)=>{let n=[...s];return n.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}}),n},"ir"),ir=d(s=>{let e=(0,xe.c)(161),{queryStats:n}=s,a=ge(),[r,u]=(0,Q.useState)("totalTime"),i;e[0]===Symbol.for("react.memo_cache_sentinel")?(i=new Set,e[0]=i):i=e[0];let[l,g]=(0,Q.useState)(i),v;e[1]===Symbol.for("react.memo_cache_sentinel")?(v=d(I=>{I!==null&&u(I)},"y"),e[1]=v):v=e[1];let S=v,f,c,p,y,q,M,o,k,x,b;if(e[2]!==l||e[3]!==n||e[4]!==r||e[5]!==a){p=Symbol.for("react.early_return_sentinel");e:{let I=nr(n,r),T;e[16]!==n?(T=n.filter(or),e[16]=n,e[17]=T):T=e[17];let R=T.length,w;e[18]!==n?(w=n.filter(dr),e[18]=n,e[19]=w):w=e[19];let N=w.length,K;e[20]!==n?(K=n.filter(cr),e[20]=n,e[21]=K):K=e[21];let F=K.length,z;e[22]===Symbol.for("react.memo_cache_sentinel")?(z=d(O=>{g(ue=>{let H=new Set(ue);return H.has(O)?H.delete(O):H.add(O),H})},"L"),e[22]=z):z=e[22];let E=z;if(n.length===0){let O;e[23]!==a?(O=a("No query insights yet"),e[23]=a,e[24]=O):O=e[24];let ue;e[25]!==O?(ue=(0,t.jsx)("p",{className:"text-lg font-medium","data-testid":"qi-empty",children:O}),e[25]=O,e[26]=ue):ue=e[26];let H;e[27]!==a?(H=a("Query insights appear once statements are executed against this shard."),e[27]=a,e[28]=H):H=e[28];let he;e[29]!==H?(he=(0,t.jsx)("p",{className:"mt-1 text-sm",children:H}),e[29]=H,e[30]=he):he=e[30];let Be;e[31]!==ue||e[32]!==he?(Be=(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]=Be):Be=e[33],p=Be;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 B;e[36]!==L?(B=(0,t.jsx)(Fe,{className:"pb-2",children:(0,t.jsx)(ze,{className:"text-sm font-medium",children:L})}),e[36]=L,e[37]=B):B=e[37];let P;e[38]!==R?(P=(0,t.jsx)("div",{className:"text-2xl font-bold text-destructive","data-testid":"qi-critical",children:R}),e[38]=R,e[39]=P):P=e[39];let A;e[40]!==a?(A=a(">100ms avg execution"),e[40]=a,e[41]=A):A=e[41];let j;e[42]!==A?(j=(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:A}),e[42]=A,e[43]=j):j=e[43];let G;e[44]!==P||e[45]!==j?(G=(0,t.jsxs)(pe,{children:[P,j]}),e[44]=P,e[45]=j,e[46]=G):G=e[46];let V;e[47]!==B||e[48]!==G?(V=(0,t.jsxs)(fe,{children:[B,G]}),e[47]=B,e[48]=G,e[49]=V):V=e[49];let X;e[50]!==a?(X=a("Moderate queries"),e[50]=a,e[51]=X):X=e[51];let Y;e[52]!==X?(Y=(0,t.jsx)(Fe,{className:"pb-2",children:(0,t.jsx)(ze,{className:"text-sm font-medium",children:X})}),e[52]=X,e[53]=Y):Y=e[53];let Z;e[54]!==N?(Z=(0,t.jsx)("div",{className:"text-2xl font-bold text-warning","data-testid":"qi-moderate",children:N}),e[54]=N,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]!==Y||e[64]!==re?(ae=(0,t.jsxs)(fe,{children:[Y,re]}),e[63]=Y,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)(Fe,{className:"pb-2",children:(0,t.jsx)(ze,{className:"text-sm font-medium",children:se})}),e[68]=se,e[69]=le):le=e[69];let ne;e[70]!==F?(ne=(0,t.jsx)("div",{className:"text-2xl font-bold text-success","data-testid":"qi-fast",children:F}),e[70]=F,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 $;e[79]!==le||e[80]!==m?($=(0,t.jsxs)(fe,{children:[le,m]}),e[79]=le,e[80]=m,e[81]=$):$=e[81],e[82]!==V||e[83]!==ae||e[84]!==$?(x=(0,t.jsxs)("div",{className:"grid gap-4 md:grid-cols-3",children:[V,ae,$]}),e[82]=V,e[83]=ae,e[84]=$,e[85]=x):x=e[85];let J;e[86]!==a?(J=a("Query leaderboard"),e[86]=a,e[87]=J):J=e[87];let U;e[88]!==J?(U=(0,t.jsx)("h3",{className:"text-lg font-semibold",children:J}),e[88]=J,e[89]=U):U=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]!==U||e[96]!==be?(ve=(0,t.jsxs)("div",{children:[U,be]}),e[95]=U,e[96]=be,e[97]=ve):ve=e[97];let ye;e[98]!==a?(ye=a("Sort by"),e[98]=a,e[99]=ye):ye=e[99];let Ne;e[100]!==ye?(Ne=(0,t.jsx)("span",{className:"text-sm text-muted-foreground",children:ye}),e[100]=ye,e[101]=Ne):Ne=e[101];let we;e[102]!==a?(we=a("Sort queries by"),e[102]=a,e[103]=we):we=e[103];let Qe;e[104]===Symbol.for("react.memo_cache_sentinel")?(Qe=(0,t.jsx)(Tt,{}),e[104]=Qe):Qe=e[104];let Se;e[105]!==we?(Se=(0,t.jsx)(Rt,{"aria-label":we,className:"w-[140px]","data-testid":"qi-sort",children:Qe}),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)(Pe,{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)(Pe,{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)(Pe,{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 Te;e[121]!==Ie?(Te=(0,t.jsx)(Pe,{value:"rowsRead",children:Ie}),e[121]=Ie,e[122]=Te):Te=e[122];let Re;e[123]!==ke||e[124]!==Me||e[125]!==Ce||e[126]!==Te?(Re=(0,t.jsxs)(Ot,{children:[ke,Me,Ce,Te]}),e[123]=ke,e[124]=Me,e[125]=Ce,e[126]=Te,e[127]=Re):Re=e[127];let Oe;e[128]!==r||e[129]!==Se||e[130]!==Re?(Oe=(0,t.jsxs)(It,{onValueChange:S,value:r,children:[Se,Re]}),e[128]=r,e[129]=Se,e[130]=Re,e[131]=Oe):Oe=e[131];let Ke;e[132]!==Ne||e[133]!==Oe?(Ke=(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[Ne,Oe]}),e[132]=Ne,e[133]=Oe,e[134]=Ke):Ke=e[134],e[135]!==ve||e[136]!==Ke?(b=(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[ve,Ke]}),e[135]=ve,e[136]=Ke,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 Je;e[140]!==Le?(Je=(0,t.jsx)(ze,{children:Le}),e[140]=Le,e[141]=Je):Je=e[141],M=(0,t.jsxs)(Fe,{children:[Je,(0,t.jsx)(ht,{children:a("{count} tracked statements",{count:I.length})})]}),f=pe,y="space-y-2";let Ue;e[142]!==l||e[143]!==a?(Ue=d(O=>{let ue=O.normalizedSql,H=l.has(ue),he=Ve(O.avgDurationMs);return(0,t.jsxs)("div",{className:"overflow-hidden rounded-lg border","data-testid":"qi-row",children:[(0,t.jsxs)("button",{"aria-expanded":H,className:"flex w-full items-center justify-between p-3 text-left transition-colors hover:bg-muted/50",onClick:d(()=>{E(ue)},"onClick"),type:"button",children:[(0,t.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-3",children:[(0,t.jsx)(lr,{level:he}),(0,t.jsx)("span",{className:"max-w-[300px] truncate font-mono text-sm lg:max-w-[500px]",children:O.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:$e(O.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:$e(O.avgDurationMs)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("avg")})]}),O.p95DurationMs!==void 0&&(0,t.jsxs)("div",{className:"text-right",children:[(0,t.jsx)("div",{className:"text-sm font-medium",children:$e(O.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:Ge(O.execCount)}),(0,t.jsx)("div",{className:"text-xs text-muted-foreground",children:a("calls")})]})]})]}),H&&(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:O.normalizedSql})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-4 text-sm md:grid-cols-4",children:[O.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:$e(O.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:Ge(O.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:$e(O.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:Ge(O.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:Ge(O.rowsWritten)})]})]})]})]},ue)},"Ke"),e[142]=l,e[143]=a,e[144]=Ue):Ue=e[144],q=I.map(Ue)}e[2]=l,e[3]=n,e[4]=r,e[5]=a,e[6]=f,e[7]=c,e[8]=p,e[9]=y,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],y=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]!==y||e[146]!==q?(_=(0,t.jsx)("div",{className:y,children:q}),e[145]=y,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 h;e[151]!==c||e[152]!==D||e[153]!==M?(h=(0,t.jsxs)(c,{children:[M,D]}),e[151]=c,e[152]=D,e[153]=M,e[154]=h):h=e[154];let C;return e[155]!==h||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,h]}),e[155]=h,e[156]=o,e[157]=k,e[158]=x,e[159]=b,e[160]=C):C=e[160],C},"nr");function or(s){return Ve(s.avgDurationMs)==="critical"}d(or,"or");function dr(s){return Ve(s.avgDurationMs)==="warning"}d(dr,"cr");function cr(s){return Ve(s.avgDurationMs)==="good"}d(cr,"dr");var mr=["1m","5m","15m","1h"],ur=d(s=>new Date(s).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}),"fr"),hr=d(s=>s.map(e=>({avg:Math.round(e.avgDurationMs*100)/100,execs:e.execCount,label:ur(e.bucketMs)})),"ur"),gr=d(({shardKey:s=""})=>{let e=ge(),[n,a]=(0,Q.useState)("15m"),r=Ee(Ae.getQueryInsights,{range:n},{live:!0,shardKey:s}).data,u=hr(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:mr.map(i=>(0,t.jsx)("button",{"aria-pressed":i===n,className:ut("rounded px-2 py-1 text-xs outline-none transition-colors hover:bg-accent focus-visible:bg-accent",i===n&&"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)(He,{"data-testid":"qi-capped",variant:"secondary",children:e("showing a capped set")})]}),u.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:u,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)(Nt,{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:u,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)(yt,{dataKey:"avg",dot:!1,stroke:"var(--color-destructive)",type:"monotone"})]})})]})]}),(0,t.jsx)(ir,{queryStats:r?.entries??[]})]})},"hr"),fr=ft(Ae.getMetrics),pr=d((s,e)=>s?e:"overview","pr"),Pr=d(({initialShardKey:s})=>{let e=mt(),n=ge(),{queryShardKey:a,setShardKey:r,shardKey:u}=Mt(s),[i,l]=(0,Q.useState)("overview"),[g,v]=(0,Q.useState)([]),S=(0,Q.useRef)(null),f=(0,Q.useRef)(null),c=(0,Q.useRef)(!0);(0,Q.useEffect)(()=>(c.current=!0,()=>{c.current=!1}),[]);let p=Lt(a),{data:y,error:q,liveError:M}=Ee(Ae.getMetrics,{},{live:!0,shardKey:a}),o=y??null;(0,Q.useEffect)(()=>{if(y===void 0)return;kt(a);let L=y,B=S.current,P=f.current!==null&&f.current!==L.shard;if(f.current=L.shard,S.current=L.requests,P){v([]);return}B!==null&&L.requests>=B&&v(A=>[...A,L.requests-B].slice(-30))},[y,a]);let[k,x]=(0,Q.useState)(null),[b,_]=(0,Q.useState)(!1),D=d(async()=>{_(!0);let L=u,B=Ft(L,qt());try{let P=await Promise.all(B.map(async A=>{try{let j=await e.query(fr,{},pt(A));return{error:null,metrics:j,shard:A===""?j.shard:A}}catch(j){return{error:xt(j),metrics:null,shard:A===""?"__root__":A}}}));c.current&&x({results:P,shard:L})}finally{c.current&&_(!1)}},"k"),h=k?.shard===u?k.results:null,C=h===null?null:At(h),I=o===null||o.requests===0?"\u2014":`${(o.errors/o.requests*100).toFixed(1)}%`,T=g.length>0?g.at(-1):0,R=o?zt(o):{p90:0,p95:0},w=(0,Q.useMemo)(()=>{if(!o||!("queryStats"in o))return;let L=o.queryStats;if(!(!L||!Array.isArray(L)))return Et(L)},[o]),N=pr(w!==void 0,i),K=d(()=>{vt(D())},"A"),F=d(()=>{x(null)},"O"),z=d(()=>{l("overview")},"L"),E=d(()=>{l("query-insights")},"z");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:u}),(0,t.jsx)(Dt,{message:M,prefix:"mt"}),(0,t.jsx)(Ye,{"data-testid":"mt-aggregate",disabled:b,onClick:K,size:"sm",type:"button",variant:"secondary",children:n(b?"Aggregating\u2026":"All shards")}),h!==null&&(0,t.jsx)(Ye,{"data-testid":"mt-aggregate-clear",onClick:F,size:"sm",type:"button",variant:"ghost",children:n("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:n("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 ${N==="overview"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-overview",onClick:z,type:"button",children:n("Overview")}),(0,t.jsxs)("button",{className:`pb-2 text-sm font-medium transition-colors ${N==="query-insights"?"border-b-2 border-primary text-foreground":"text-muted-foreground hover:text-foreground"}`,"data-testid":"mt-tab-query-insights",onClick:E,type:"button",children:[n("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})]})]}),N==="query-insights"&&w!==void 0&&(0,t.jsx)(gr,{shardKey:a}),N==="overview"&&o!==null&&(0,t.jsx)(sr,{currentDelta:T,errorRate:I,history:g,latencyPercentiles:R,metrics:o}),N==="overview"&&o===null&&null,N==="overview"&&(0,t.jsx)(rr,{onOpenTrace:p,shardKey:a}),N==="overview"&&C!==null&&h!==null&&(0,t.jsx)(ar,{aggregate:C,shardResults:h})]})},"Qr");export{Pr as MetricsPanel};
@@ -1 +1 @@
1
- import{a as Z}from"./chunk-S3CRZLGS.js";import{a as te}from"./chunk-NFS7FTAR.js";import{a as Y}from"./chunk-LIOUCOP2.js";import{b as X}from"./chunk-OGUKYRFM.js";import{a as W}from"./chunk-K7AJEMKE.js";import"./chunk-OKG3HWSJ.js";import{e as G}from"./chunk-6D6Z2KXU.js";import"./chunk-6QA34EWC.js";import"./chunk-TDXV3OT5.js";import"./chunk-Y6CXU7T4.js";import"./chunk-4L4WTGN5.js";import{b as ae,c as ne}from"./chunk-FZ7UOWAB.js";import{a as q,b as ee}from"./chunk-VUPEFCIO.js";import{a as Q}from"./chunk-55754F6H.js";import"./chunk-IS6LVJ6L.js";import"./chunk-AAVLPU5Q.js";import"./chunk-225VJ77I.js";import"./chunk-YLPFIPVU.js";import"./chunk-ULIQFBZU.js";import"./chunk-XC734N2Q.js";import"./chunk-35DM4JJG.js";import{a as I}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-ZD2UXTLR.js";import{f as D}from"./chunk-EGVOSH7K.js";import"./chunk-FSRSK4LY.js";import"./chunk-RDL5WK55.js";import"./chunk-HEAQVSNS.js";import"./chunk-N6NMLJ6R.js";import{d as M,f as C,g as A,l as V,p as N}from"./chunk-PTZD7RUZ.js";import{a as l,d as j,e as he,f as me,g as pe}from"./chunk-YKXDMIHQ.js";var E=j(me(),1);var c=j(he(),1);var S=j(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:i}=t;if(typeof i!="string"||i.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:n}=e;return!Array.isArray(a)||a.length===0||a.some(s=>typeof s!="string"||s.length===0)?!1:typeof n=="string"&&n.length>0},"ye"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(i=>JSON.stringify(i)).join(", ")}])`,"ge"),ye=l(t=>{let e=(0,E.c)(19),{fields:i,indexName:a,table:n,testId:s}=t,u=M(),[h,f]=(0,c.useState)(null),m;e[0]!==i||e[1]!==a?(m=l(()=>{let b=be(a,i),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=i,e[1]=a,e[2]=m):m=e[2];let x=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==n||e[7]!==s?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${s}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:n})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${s}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:n}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=n,e[7]=s,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==n?(p=u("Copy index declaration for {table}",{table:n}),e[11]=u,e[12]=n,e[13]=p):p=e[13];let w;return e[14]!==x||e[15]!==T||e[16]!==p||e[17]!==s?(w=(0,S.jsx)(te,{confirmLabel:T,onConfirm:x,testId:s,children:p}),e[14]=x,e[15]=T,e[16]=p,e[17]=s,e[18]=w):w=e[18],w},"ve"),xe=l((t,e)=>{let i=new Map;for(let a of e){let n=`${a.table} ${a.index}`;i.set(n,(i.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:i.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let i of t)for(let a of i.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([i,a])=>({scans:a,table:i}))},"Te"),ie=l((t,e)=>e.map(i=>({index:i.name,table:t})),"P"),we=l(t=>{let e=xe(t.declaredIndexes??[],t.indexHits??[]),i=ve(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,s=n&&n.indexHits.length>0?n.indexHits:e,u=n&&n.tableScans.length>0?n.tableScans:i,h=n&&n.shardTraffic.length>0?n.shardTraffic:a,f=ne({indexHits:s,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(x=>!(x.metadata.kind==="hot_scan"&&typeof x.metadata.table=="string"&&m.has(x.metadata.table)))).map(x=>q(x))},"we"),Se=C(I.listTables),Te=C(I.listTableIndexes),Ie=C(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"L"),re=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),se=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:re(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:re(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:V(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:i,table:a}=t,n=M(),s;e[0]!==i||e[1]!==a?(s=l(()=>{i(a)},"i"),e[0]=i,e[1]=a,e[2]=s):s=e[2];let u=s,h=`in-add-index-${a}`,f;e[3]!==n||e[4]!==a?(f=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(Q,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let i=D(),a=G(),n=M(),{queryShardKey:s,setShardKey:u,shardKey:h}=Z(t),[f,m]=(0,c.useState)(null),[x,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=_(I.getMetrics,{},{live:!0,shardKey:s}),b=_(I.getFunctionStats,{},{live:!0,shardKey:s}),$=_(I.getAdvisories,{},{live:!0,shardKey:s}),L=w.data??null,H=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(r=>i.shardTraffic(r)),le=l(async(r,y)=>{let o=r[0];if(o===void 0||o===""){p.current===y&&T(null);return}try{let g=await oe(o);if(p.current!==y)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===y&&T(null)}},"Y"),de=l(async(r,y)=>{let o=await Promise.allSettled(r.map(async d=>[d,await i.query(Te,{table:d},A(y))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...ie(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async r=>{p.current=r;let y=[];try{let o=await i.query(Se,{},A(r));if(p.current!==r)return;X(r),y=o.map(d=>d.name);let g=[];if(y.length>0)try{let d=await i.query(Ie,{tables:y},A(r));if(p.current!==r)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...ie(v,k))}catch{if(g=await de(y,r),p.current!==r)return}m(g)}catch{p.current===r&&m(null)}await le(y,r)});(0,c.useEffect)(()=>{N(z(s))},[s]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(s))});(0,c.useEffect)(()=>{let r=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]);let U=(0,c.useCallback)(r=>{N(a({search:{table:r},to:"/schema"}))},[a]),K=(0,c.useMemo)(()=>W(L,H),[H,L]),P=(0,c.useMemo)(()=>new Set(K.filter(r=>r.kind==="missing-index").flatMap(r=>r.tables??[])),[K]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:H,indexHits:J,shardTraffic:x,suppressHotScanTables:P}),[f,H,J,P,x]),ue=(0,c.useMemo)(()=>{let r=K.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?se(n,o):`${se(n,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(n,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),y=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=q(o);if(y.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(ye,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...r]},[F,K,U,R,n]),fe=(0,S.jsx)(Y,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(ee,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};
1
+ import{a as Z}from"./chunk-R6U22RSY.js";import{a as te}from"./chunk-XHRKNCCI.js";import{a as Y}from"./chunk-YVR4SEPU.js";import{b as X}from"./chunk-ZKJS6EBE.js";import{a as W}from"./chunk-FUYEZFBP.js";import"./chunk-RGMVGZV4.js";import{i as G}from"./chunk-OQ6I6OXT.js";import"./chunk-E4PXACVL.js";import"./chunk-MVWZMWPD.js";import"./chunk-SJQERRSZ.js";import"./chunk-7Y3SY37W.js";import{b as ae,c as ne}from"./chunk-FFVKIOKZ.js";import{a as q,b as ee}from"./chunk-WLCZLWDF.js";import{a as Q}from"./chunk-7G4Z6Q7X.js";import"./chunk-3YXASVTP.js";import"./chunk-AUAECCXB.js";import"./chunk-BOMPSVRC.js";import"./chunk-ZWXQKMYE.js";import"./chunk-NCPW7WHO.js";import"./chunk-4ZDBUYGM.js";import"./chunk-55UGUCQ6.js";import{a as I}from"./chunk-4ZEL6BYL.js";import{c as _}from"./chunk-HECPC2VY.js";import{f as D}from"./chunk-WNZLTRKF.js";import"./chunk-QAQDMS6R.js";import"./chunk-PCBRDDD7.js";import"./chunk-HCTJKP5J.js";import"./chunk-2IKDEUCX.js";import{d as M,f as C,g as A,l as V,p as N}from"./chunk-HJHSQPHW.js";import{a as l,d as j,e as he,f as me,g as pe}from"./chunk-I26MS5PJ.js";var E=j(me(),1);var c=j(he(),1);var S=j(pe(),1);var ge=l(t=>{let{suggestedIndex:e,table:i}=t;if(typeof i!="string"||i.length===0||typeof e!="object"||e===null)return!1;let{fields:a,name:n}=e;return!Array.isArray(a)||a.length===0||a.some(s=>typeof s!="string"||s.length===0)?!1:typeof n=="string"&&n.length>0},"ye"),be=l((t,e)=>`.index(${JSON.stringify(t)}, [${e.map(i=>JSON.stringify(i)).join(", ")}])`,"ge"),ye=l(t=>{let e=(0,E.c)(19),{fields:i,indexName:a,table:n,testId:s}=t,u=M(),[h,f]=(0,c.useState)(null),m;e[0]!==i||e[1]!==a?(m=l(()=>{let b=be(a,i),$="navigator"in globalThis?globalThis.navigator.clipboard:void 0;if($===void 0){f({copied:!1,declaration:b});return}N($.writeText(b).then(()=>(f({copied:!0,declaration:b}),!0)),()=>{f({copied:!1,declaration:b})})},"m"),e[0]=i,e[1]=a,e[2]=m):m=e[2];let x=m;if(h!==null){let b;return e[3]!==h.copied||e[4]!==h.declaration||e[5]!==u||e[6]!==n||e[7]!==s?(b=h.copied?(0,S.jsx)("span",{className:"text-xs text-muted-foreground","data-testid":`${s}-applied`,children:u("Index declaration copied \u2014 add it to {table} in lunora/schema.ts.",{table:n})}):(0,S.jsxs)("span",{className:"flex flex-col gap-1 text-xs text-muted-foreground","data-testid":`${s}-manual`,children:[u("Could not reach the clipboard \u2014 add this to {table} in lunora/schema.ts:",{table:n}),(0,S.jsx)("code",{className:"font-mono break-all select-all",children:h.declaration})]}),e[3]=h.copied,e[4]=h.declaration,e[5]=u,e[6]=n,e[7]=s,e[8]=b):b=e[8],b}let T;e[9]!==u?(T=u("Copy?"),e[9]=u,e[10]=T):T=e[10];let p;e[11]!==u||e[12]!==n?(p=u("Copy index declaration for {table}",{table:n}),e[11]=u,e[12]=n,e[13]=p):p=e[13];let w;return e[14]!==x||e[15]!==T||e[16]!==p||e[17]!==s?(w=(0,S.jsx)(te,{confirmLabel:T,onConfirm:x,testId:s,children:p}),e[14]=x,e[15]=T,e[16]=p,e[17]=s,e[18]=w):w=e[18],w},"ve"),xe=l((t,e)=>{let i=new Map;for(let a of e){let n=`${a.table} ${a.index}`;i.set(n,(i.get(n)??0)+a.reads)}return t.map(a=>({index:a.index,reads:i.get(`${a.table} ${a.index}`)??0,table:a.table}))},"Se"),ve=l(t=>{let e=new Map;for(let i of t)for(let a of i.scannedTables??[])e.set(a.table,(e.get(a.table)??0)+a.scans);return[...e].map(([i,a])=>({scans:a,table:i}))},"Te"),ie=l((t,e)=>e.map(i=>({index:i.name,table:t})),"P"),we=l(t=>{let e=xe(t.declaredIndexes??[],t.indexHits??[]),i=ve(t.functions??[]),a=t.shardTraffic??[],n=t.analyticsMetrics,s=n&&n.indexHits.length>0?n.indexHits:e,u=n&&n.tableScans.length>0?n.tableScans:i,h=n&&n.shardTraffic.length>0?n.shardTraffic:a,f=ne({indexHits:s,schema:{tables:[]},shardTraffic:h,tableScans:u},{lints:ae,source:"runtime"}),m=t.suppressHotScanTables;return(m===void 0?f:f.filter(x=>!(x.metadata.kind==="hot_scan"&&typeof x.metadata.table=="string"&&m.has(x.metadata.table)))).map(x=>q(x))},"we"),Se=C(I.listTables),Te=C(I.listTableIndexes),Ie=C(I.listTablesIndexes),B=l(t=>`${(t*100).toFixed(1)}%`,"L"),re=l(t=>`${(t/1e3).toFixed(2)}s`,"V"),$e=l(t=>{if(t.length<=1)return t[0]??"";let e=t[t.length-1]??"";return`${t.slice(0,-1).join(", ")} and ${e}`},"Ne"),ke=l((t,e)=>({"high-error-rate":t("High error rate"),"high-evictions":t("High cache eviction rate"),"high-write-contention":t("High write contention"),"low-cache-hit-rate":t("Low cache hit rate"),"missing-index":t("Missing index"),"slow-function":t("Slow function"),"storage-headroom":t("Storage headroom")})[e.kind],"ke"),se=l((t,e)=>({"high-error-rate":t("{rate} of calls failed.",{rate:B(e.value)}),"high-evictions":t("{count} entries evicted recently.",{count:e.value}),"high-write-contention":t("{rate} of calls hit a write conflict \u2014 consider sharding to cut contention.",{rate:B(e.value)}),"low-cache-hit-rate":t("{rate} hit rate over recent traffic.",{rate:B(e.value)}),"missing-index":t("Slowest call took {duration} \u2014 it full-scanned {tables} with no index.",{duration:re(e.value),tables:$e(e.tables??[])}),"slow-function":t("Slowest call took {duration}.",{duration:re(e.value)}),"storage-headroom":t("{size} of the 10 GiB per-shard ceiling \u2014 plan a .shardBy() migration while it still has runway.",{size:V(e.value)})})[e.kind],"U"),Ne=l(t=>{let e=(0,E.c)(10),{onJump:i,table:a}=t,n=M(),s;e[0]!==i||e[1]!==a?(s=l(()=>{i(a)},"i"),e[0]=i,e[1]=a,e[2]=s):s=e[2];let u=s,h=`in-add-index-${a}`,f;e[3]!==n||e[4]!==a?(f=n("Add index on {table}",{table:a}),e[3]=n,e[4]=a,e[5]=f):f=e[5];let m;return e[6]!==u||e[7]!==h||e[8]!==f?(m=(0,S.jsx)(Q,{"data-testid":h,onClick:u,size:"sm",type:"button",variant:"outline",children:f}),e[6]=u,e[7]=h,e[8]=f,e[9]=m):m=e[9],m},"Be"),ze=l(({initialShardKey:t,loadShardTraffic:e})=>{let i=D(),a=G(),n=M(),{queryShardKey:s,setShardKey:u,shardKey:h}=Z(t),[f,m]=(0,c.useState)(null),[x,T]=(0,c.useState)(null),p=(0,c.useRef)(""),w=_(I.getMetrics,{},{live:!0,shardKey:s}),b=_(I.getFunctionStats,{},{live:!0,shardKey:s}),$=_(I.getAdvisories,{},{live:!0,shardKey:s}),L=w.data??null,H=b.data?.functions??null,F=$.data?.advisories??null,J=w.data?.indexHits??null,O=w.error!==null&&b.error!==null?w.error:null,oe=e??(r=>i.shardTraffic(r)),le=l(async(r,y)=>{let o=r[0];if(o===void 0||o===""){p.current===y&&T(null);return}try{let g=await oe(o);if(p.current!==y)return;let d=new Map;for(let v of g.shards)d.has(v.shardKey)||d.set(v.shardKey,{requests:v.requests,shardKey:v.shardKey});T([...d.values()])}catch{p.current===y&&T(null)}},"Y"),de=l(async(r,y)=>{let o=await Promise.allSettled(r.map(async d=>[d,await i.query(Te,{table:d},A(y))])),g=[];for(let d of o)if(d.status==="fulfilled"){let[v,k]=d.value;g.push(...ie(v,k.indexes))}return g},"Z"),z=(0,c.useEffectEvent)(async r=>{p.current=r;let y=[];try{let o=await i.query(Se,{},A(r));if(p.current!==r)return;X(r),y=o.map(d=>d.name);let g=[];if(y.length>0)try{let d=await i.query(Ie,{tables:y},A(r));if(p.current!==r)return;for(let[v,k]of Object.entries(d.indexesByTable))g.push(...ie(v,k))}catch{if(g=await de(y,r),p.current!==r)return}m(g)}catch{p.current===r&&m(null)}await le(y,r)});(0,c.useEffect)(()=>{N(z(s))},[s]);let ce=(0,c.useEffectEvent)(()=>{w.refetch(),b.refetch(),$.refetch(),N(z(s))});(0,c.useEffect)(()=>{let r=l(()=>{document.visibilityState==="visible"&&ce()},"r");return document.addEventListener("visibilitychange",r),()=>{document.removeEventListener("visibilitychange",r)}},[]);let U=(0,c.useCallback)(r=>{N(a({search:{table:r},to:"/schema"}))},[a]),K=(0,c.useMemo)(()=>W(L,H),[H,L]),P=(0,c.useMemo)(()=>new Set(K.filter(r=>r.kind==="missing-index").flatMap(r=>r.tables??[])),[K]),R=(0,c.useMemo)(()=>we({declaredIndexes:f??[],functions:H,indexHits:J,shardTraffic:x,suppressHotScanTables:P}),[f,H,J,P,x]),ue=(0,c.useMemo)(()=>{let r=K.map(o=>{let g=o.kind==="missing-index"?o.tables??[]:[];return{action:g.length>0?g.map(d=>(0,S.jsx)(Ne,{onJump:U,table:d},d)):void 0,description:o.message===void 0?se(n,o):`${se(n,o)} \u2014 ${o.message}`,entity:o.fn,issueType:ke(n,o),key:`${o.kind}:${o.fn??""}`,level:o.severity}}),y=new Set(["unindexed_foreign_key","unindexed_relation_target"]);return[...(F??[]).map(o=>{let g=q(o);if(y.has(o.name)&&ge(o.metadata)){let{table:d,suggestedIndex:v}=o.metadata,k=`in-apply-index-${d}-${v.name}`;return{...g,action:(0,S.jsx)(ye,{fields:v.fields,indexName:v.name,table:d,testId:k})}}return g}),...R,...r]},[F,K,U,R,n]),fe=(0,S.jsx)(Y,{onChange:u,testId:"in-shard-input",value:h});return(0,S.jsx)(ee,{error:O,errorSource:O===null?void 0:w.errorSource,rows:ue,testId:"lunora-insights",toolbar:fe})},"Ue");export{ze as InsightsPanel};