@dudousxd/nestjs-telescope-ui 1.16.1 → 1.18.0

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.
@@ -140,4 +140,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
140
140
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function sie(e,t){if(e){if(typeof e=="string")return Gy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Gy(e,t)}}function lie(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function uie(e){if(Array.isArray(e))return Gy(e)}function Gy(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var Qy=function(t,n,r,i,a){var o=sn(t,dx),s=sn(t,Gp),l=[].concat(eO(o),eO(s)),u=sn(t,Xp),d="".concat(i,"Id"),f=i[0],p=n;if(l.length&&(p=l.reduce(function(y,b){if(b.props[d]===r&&tr(b.props,"extendDomain")&&W(b.props[f])){var v=b.props[f];return[Math.min(y[0],v),Math.max(y[1],v)]}return y},p)),u.length){var h="".concat(f,"1"),g="".concat(f,"2");p=u.reduce(function(y,b){if(b.props[d]===r&&tr(b.props,"extendDomain")&&W(b.props[h])&&W(b.props[g])){var v=b.props[h],m=b.props[g];return[Math.min(y[0],v,m),Math.max(y[1],v,m)]}return y},p)}return a&&a.length&&(p=a.reduce(function(y,b){return W(b)?[Math.min(y[0],b),Math.max(y[1],b)]:y},p)),p},Ak={exports:{}};(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function i(l,u,d){this.fn=l,this.context=u,this.once=d||!1}function a(l,u,d,f,p){if(typeof d!="function")throw new TypeError("The listener must be a function");var h=new i(d,f||l,p),g=n?n+u:u;return l._events[g]?l._events[g].fn?l._events[g]=[l._events[g],h]:l._events[g].push(h):(l._events[g]=h,l._eventsCount++),l}function o(l,u){--l._eventsCount===0?l._events=new r:delete l._events[u]}function s(){this._events=new r,this._eventsCount=0}s.prototype.eventNames=function(){var u=[],d,f;if(this._eventsCount===0)return u;for(f in d=this._events)t.call(d,f)&&u.push(n?f.slice(1):f);return Object.getOwnPropertySymbols?u.concat(Object.getOwnPropertySymbols(d)):u},s.prototype.listeners=function(u){var d=n?n+u:u,f=this._events[d];if(!f)return[];if(f.fn)return[f.fn];for(var p=0,h=f.length,g=new Array(h);p<h;p++)g[p]=f[p].fn;return g},s.prototype.listenerCount=function(u){var d=n?n+u:u,f=this._events[d];return f?f.fn?1:f.length:0},s.prototype.emit=function(u,d,f,p,h,g){var y=n?n+u:u;if(!this._events[y])return!1;var b=this._events[y],v=arguments.length,m,x;if(b.fn){switch(b.once&&this.removeListener(u,b.fn,void 0,!0),v){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,d),!0;case 3:return b.fn.call(b.context,d,f),!0;case 4:return b.fn.call(b.context,d,f,p),!0;case 5:return b.fn.call(b.context,d,f,p,h),!0;case 6:return b.fn.call(b.context,d,f,p,h,g),!0}for(x=1,m=new Array(v-1);x<v;x++)m[x-1]=arguments[x];b.fn.apply(b.context,m)}else{var j=b.length,w;for(x=0;x<j;x++)switch(b[x].once&&this.removeListener(u,b[x].fn,void 0,!0),v){case 1:b[x].fn.call(b[x].context);break;case 2:b[x].fn.call(b[x].context,d);break;case 3:b[x].fn.call(b[x].context,d,f);break;case 4:b[x].fn.call(b[x].context,d,f,p);break;default:if(!m)for(w=1,m=new Array(v-1);w<v;w++)m[w-1]=arguments[w];b[x].fn.apply(b[x].context,m)}}return!0},s.prototype.on=function(u,d,f){return a(this,u,d,f,!1)},s.prototype.once=function(u,d,f){return a(this,u,d,f,!0)},s.prototype.removeListener=function(u,d,f,p){var h=n?n+u:u;if(!this._events[h])return this;if(!d)return o(this,h),this;var g=this._events[h];if(g.fn)g.fn===d&&(!p||g.once)&&(!f||g.context===f)&&o(this,h);else{for(var y=0,b=[],v=g.length;y<v;y++)(g[y].fn!==d||p&&!g[y].once||f&&g[y].context!==f)&&b.push(g[y]);b.length?this._events[h]=b.length===1?b[0]:b:o(this,h)}return this},s.prototype.removeAllListeners=function(u){var d;return u?(d=n?n+u:u,this._events[d]&&o(this,d)):(this._events=new r,this._eventsCount=0),this},s.prototype.off=s.prototype.removeListener,s.prototype.addListener=s.prototype.on,s.prefixed=n,s.EventEmitter=s,e.exports=s})(Ak);var cie=Ak.exports;const fie=ge(cie);var im=new fie,am="recharts.syncMouseEvents";function ku(e){"@babel/helpers - typeof";return ku=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ku(e)}function die(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pie(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,_k(r.key),r)}}function hie(e,t,n){return t&&pie(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function om(e,t,n){return t=_k(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _k(e){var t=mie(e,"string");return ku(t)=="symbol"?t:t+""}function mie(e,t){if(ku(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(ku(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var vie=function(){function e(){die(this,e),om(this,"activeIndex",0),om(this,"coordinateList",[]),om(this,"layout","horizontal")}return hie(e,[{key:"setDetails",value:function(n){var r,i=n.coordinateList,a=i===void 0?null:i,o=n.container,s=o===void 0?null:o,l=n.layout,u=l===void 0?null:l,d=n.offset,f=d===void 0?null:d,p=n.mouseHandlerCallback,h=p===void 0?null:p;this.coordinateList=(r=a??this.coordinateList)!==null&&r!==void 0?r:[],this.container=s??this.container,this.layout=u??this.layout,this.offset=f??this.offset,this.mouseHandlerCallback=h??this.mouseHandlerCallback,this.activeIndex=Math.min(Math.max(this.activeIndex,0),this.coordinateList.length-1)}},{key:"focus",value:function(){this.spoofMouse()}},{key:"keyboardEvent",value:function(n){if(this.coordinateList.length!==0)switch(n.key){case"ArrowRight":{if(this.layout!=="horizontal")return;this.activeIndex=Math.min(this.activeIndex+1,this.coordinateList.length-1),this.spoofMouse();break}case"ArrowLeft":{if(this.layout!=="horizontal")return;this.activeIndex=Math.max(this.activeIndex-1,0),this.spoofMouse();break}}}},{key:"setIndex",value:function(n){this.activeIndex=n}},{key:"spoofMouse",value:function(){var n,r;if(this.layout==="horizontal"&&this.coordinateList.length!==0){var i=this.container.getBoundingClientRect(),a=i.x,o=i.y,s=i.height,l=this.coordinateList[this.activeIndex].coordinate,u=((n=window)===null||n===void 0?void 0:n.scrollX)||0,d=((r=window)===null||r===void 0?void 0:r.scrollY)||0,f=a+l+u,p=o+this.offset.top+s/2+d;this.mouseHandlerCallback({pageX:f,pageY:p})}}}])}();function yie(e,t,n){if(n==="number"&&t===!0&&Array.isArray(e)){var r=e==null?void 0:e[0],i=e==null?void 0:e[1];if(r&&i&&W(r)&&W(i))return!0}return!1}function gie(e,t,n,r){var i=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-i:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-i,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}function Ek(e){var t=e.cx,n=e.cy,r=e.radius,i=e.startAngle,a=e.endAngle,o=je(t,n,r,i),s=je(t,n,r,a);return{points:[o,s],cx:t,cy:n,radius:r,startAngle:i,endAngle:a}}function xie(e,t,n){var r,i,a,o;if(e==="horizontal")r=t.x,a=r,i=n.top,o=n.top+n.height;else if(e==="vertical")i=t.y,o=i,r=n.left,a=n.left+n.width;else if(t.cx!=null&&t.cy!=null)if(e==="centric"){var s=t.cx,l=t.cy,u=t.innerRadius,d=t.outerRadius,f=t.angle,p=je(s,l,u,f),h=je(s,l,d,f);r=p.x,i=p.y,a=h.x,o=h.y}else return Ek(t);return[{x:r,y:i},{x:a,y:o}]}function Tu(e){"@babel/helpers - typeof";return Tu=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tu(e)}function tO(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Rc(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?tO(Object(n),!0).forEach(function(r){bie(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):tO(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function bie(e,t,n){return t=wie(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wie(e){var t=jie(e,"string");return Tu(t)=="symbol"?t:t+""}function jie(e,t){if(Tu(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Tu(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Sie(e){var t,n,r=e.element,i=e.tooltipEventType,a=e.isActive,o=e.activeCoordinate,s=e.activePayload,l=e.offset,u=e.activeTooltipIndex,d=e.tooltipAxisBandSize,f=e.layout,p=e.chartName,h=(t=r.props.cursor)!==null&&t!==void 0?t:(n=r.type.defaultProps)===null||n===void 0?void 0:n.cursor;if(!r||!h||!a||!o||p!=="ScatterChart"&&i!=="axis")return null;var g,y=Po;if(p==="ScatterChart")g=o,y=kJ;else if(p==="BarChart")g=gie(f,o,l,d),y=ix;else if(f==="radial"){var b=Ek(o),v=b.cx,m=b.cy,x=b.radius,j=b.startAngle,w=b.endAngle;g={cx:v,cy:m,startAngle:j,endAngle:w,innerRadius:x,outerRadius:x},y=wN}else g={points:xie(f,o,l)},y=Po;var S=Rc(Rc(Rc(Rc({stroke:"#ccc",pointerEvents:"none"},l),g),J(h,!1)),{},{payload:s,payloadIndex:u,className:ne("recharts-tooltip-cursor",h.className)});return A.isValidElement(h)?A.cloneElement(h,S):A.createElement(y,S)}var Oie=["item"],Pie=["children","className","width","height","style","compact","title","desc"];function xs(e){"@babel/helpers - typeof";return xs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},xs(e)}function mo(){return mo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},mo.apply(this,arguments)}function nO(e,t){return Eie(e)||_ie(e,t)||Nk(e,t)||Aie()}function Aie(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
141
141
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _ie(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,a,o,s=[],l=!0,u=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(l=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);l=!0);}catch(d){u=!0,i=d}finally{try{if(!l&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw i}}return s}}function Eie(e){if(Array.isArray(e))return e}function rO(e,t){if(e==null)return{};var n=$ie(e,t),r,i;if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(i=0;i<a.length;i++)r=a[i],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function $ie(e,t){if(e==null)return{};var n={};for(var r in e)if(Object.prototype.hasOwnProperty.call(e,r)){if(t.indexOf(r)>=0)continue;n[r]=e[r]}return n}function Nie(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function kie(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,kk(r.key),r)}}function Tie(e,t,n){return t&&kie(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function Cie(e,t,n){return t=Rd(t),Mie(e,$k()?Reflect.construct(t,n||[],Rd(e).constructor):t.apply(e,n))}function Mie(e,t){if(t&&(xs(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Iie(e)}function Iie(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $k(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return($k=function(){return!!e})()}function Rd(e){return Rd=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Rd(e)}function zie(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Xy(e,t)}function Xy(e,t){return Xy=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Xy(e,t)}function bs(e){return Lie(e)||Die(e)||Nk(e)||Rie()}function Rie(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
142
142
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Nk(e,t){if(e){if(typeof e=="string")return Yy(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Yy(e,t)}}function Die(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Lie(e){if(Array.isArray(e))return Yy(e)}function Yy(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function iO(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function R(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?iO(Object(n),!0).forEach(function(r){te(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):iO(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function te(e,t,n){return t=kk(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kk(e){var t=Bie(e,"string");return xs(t)=="symbol"?t:t+""}function Bie(e,t){if(xs(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(xs(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var Fie={xAxis:["bottom","top"],yAxis:["left","right"]},Uie={width:"100%",height:"100%"},Tk={x:0,y:0};function Dc(e){return e}var Wie=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},qie=function(t,n,r,i){var a=n.find(function(d){return d&&d.index===r});if(a){if(t==="horizontal")return{x:a.coordinate,y:i.y};if(t==="vertical")return{x:i.x,y:a.coordinate};if(t==="centric"){var o=a.coordinate,s=i.radius;return R(R(R({},i),je(i.cx,i.cy,s,o)),{},{angle:o,radius:s})}var l=a.coordinate,u=i.angle;return R(R(R({},i),je(i.cx,i.cy,l,u)),{},{angle:u,radius:l})}return Tk},Yp=function(t,n){var r=n.graphicalItems,i=n.dataStartIndex,a=n.dataEndIndex,o=(r??[]).reduce(function(s,l){var u=l.props.data;return u&&u.length?[].concat(bs(s),bs(u)):s},[]);return o.length>0?o:t&&t.length&&W(i)&&W(a)?t.slice(i,a+1):[]};function Ck(e){return e==="number"?[0,"auto"]:void 0}var Jy=function(t,n,r,i){var a=t.graphicalItems,o=t.tooltipAxis,s=Yp(n,t);return r<0||!a||!a.length||r>=s.length?null:a.reduce(function(l,u){var d,f=(d=u.props.data)!==null&&d!==void 0?d:n;f&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(f=f.slice(t.dataStartIndex,t.dataEndIndex+1));var p;if(o.dataKey&&!o.allowDuplicatedCategory){var h=f===void 0?s:f;p=Cf(h,o.dataKey,i)}else p=f&&f[r]||s[r];return p?[].concat(bs(l),[rx(u,p)]):l},[])},aO=function(t,n,r,i){var a=i||{x:t.chartX,y:t.chartY},o=Wie(a,r),s=t.orderedTooltipTicks,l=t.tooltipAxis,u=t.tooltipTicks,d=tQ(o,s,u,l);if(d>=0&&u){var f=u[d]&&u[d].value,p=Jy(t,n,d,f),h=qie(r,s,d,a);return{activeTooltipIndex:d,activeLabel:f,activePayload:p,activeCoordinate:h}}return null},Hie=function(t,n){var r=n.axes,i=n.graphicalItems,a=n.axisType,o=n.axisIdKey,s=n.stackGroups,l=n.dataStartIndex,u=n.dataEndIndex,d=t.layout,f=t.children,p=t.stackOffset,h=oN(d,a);return r.reduce(function(g,y){var b,v=y.type.defaultProps!==void 0?R(R({},y.type.defaultProps),y.props):y.props,m=v.type,x=v.dataKey,j=v.allowDataOverflow,w=v.allowDuplicatedCategory,S=v.scale,O=v.ticks,P=v.includeHidden,_=v[o];if(g[_])return g;var N=Yp(t.data,{graphicalItems:i.filter(function(H){var Z,fe=o in H.props?H.props[o]:(Z=H.type.defaultProps)===null||Z===void 0?void 0:Z[o];return fe===_}),dataStartIndex:l,dataEndIndex:u}),T=N.length,k,z,I;yie(v.domain,j,m)&&(k=fy(v.domain,null,j),h&&(m==="number"||S!=="auto")&&(I=Ol(N,x,"category")));var M=Ck(m);if(!k||k.length===0){var D,F=(D=v.domain)!==null&&D!==void 0?D:M;if(x){if(k=Ol(N,x,m),m==="category"&&h){var C=q3(k);w&&C?(z=k,k=Od(0,T)):w||(k=Pj(F,k,y).reduce(function(H,Z){return H.indexOf(Z)>=0?H:[].concat(bs(H),[Z])},[]))}else if(m==="category")w?k=k.filter(function(H){return H!==""&&!re(H)}):k=Pj(F,k,y).reduce(function(H,Z){return H.indexOf(Z)>=0||Z===""||re(Z)?H:[].concat(bs(H),[Z])},[]);else if(m==="number"){var L=oQ(N,i.filter(function(H){var Z,fe,Ne=o in H.props?H.props[o]:(Z=H.type.defaultProps)===null||Z===void 0?void 0:Z[o],qe="hide"in H.props?H.props.hide:(fe=H.type.defaultProps)===null||fe===void 0?void 0:fe.hide;return Ne===_&&(P||!qe)}),x,a,d);L&&(k=L)}h&&(m==="number"||S!=="auto")&&(I=Ol(N,x,"category"))}else h?k=Od(0,T):s&&s[_]&&s[_].hasStack&&m==="number"?k=p==="expand"?[0,1]:hN(s[_].stackGroups,l,u):k=aN(N,i.filter(function(H){var Z=o in H.props?H.props[o]:H.type.defaultProps[o],fe="hide"in H.props?H.props.hide:H.type.defaultProps.hide;return Z===_&&(P||!fe)}),m,d,!0);if(m==="number")k=Qy(f,k,_,a,O),F&&(k=fy(F,k,j));else if(m==="category"&&F){var B=F,V=k.every(function(H){return B.indexOf(H)>=0});V&&(k=B)}}return R(R({},g),{},te({},_,R(R({},v),{},{axisType:a,domain:k,categoricalDomain:I,duplicateDomain:z,originalDomain:(b=v.domain)!==null&&b!==void 0?b:M,isCategorical:h,layout:d})))},{})},Kie=function(t,n){var r=n.graphicalItems,i=n.Axis,a=n.axisType,o=n.axisIdKey,s=n.stackGroups,l=n.dataStartIndex,u=n.dataEndIndex,d=t.layout,f=t.children,p=Yp(t.data,{graphicalItems:r,dataStartIndex:l,dataEndIndex:u}),h=p.length,g=oN(d,a),y=-1;return r.reduce(function(b,v){var m=v.type.defaultProps!==void 0?R(R({},v.type.defaultProps),v.props):v.props,x=m[o],j=Ck("number");if(!b[x]){y++;var w;return g?w=Od(0,h):s&&s[x]&&s[x].hasStack?(w=hN(s[x].stackGroups,l,u),w=Qy(f,w,x,a)):(w=fy(j,aN(p,r.filter(function(S){var O,P,_=o in S.props?S.props[o]:(O=S.type.defaultProps)===null||O===void 0?void 0:O[o],N="hide"in S.props?S.props.hide:(P=S.type.defaultProps)===null||P===void 0?void 0:P.hide;return _===x&&!N}),"number",d),i.defaultProps.allowDataOverflow),w=Qy(f,w,x,a)),R(R({},b),{},te({},x,R(R({axisType:a},i.defaultProps),{},{hide:!0,orientation:on(Fie,"".concat(a,".").concat(y%2),null),domain:w,originalDomain:j,isCategorical:g,layout:d})))}return b},{})},Vie=function(t,n){var r=n.axisType,i=r===void 0?"xAxis":r,a=n.AxisComp,o=n.graphicalItems,s=n.stackGroups,l=n.dataStartIndex,u=n.dataEndIndex,d=t.children,f="".concat(i,"Id"),p=sn(d,a),h={};return p&&p.length?h=Hie(t,{axes:p,graphicalItems:o,axisType:i,axisIdKey:f,stackGroups:s,dataStartIndex:l,dataEndIndex:u}):o&&o.length&&(h=Kie(t,{Axis:a,graphicalItems:o,axisType:i,axisIdKey:f,stackGroups:s,dataStartIndex:l,dataEndIndex:u})),h},Gie=function(t){var n=Jr(t),r=br(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:N0(r,function(i){return i.coordinate}),tooltipAxis:n,tooltipAxisBandSize:ud(n,r)}},oO=function(t){var n=t.children,r=t.defaultShowTooltip,i=Zt(n,us),a=0,o=0;return t.data&&t.data.length!==0&&(o=t.data.length-1),i&&i.props&&(i.props.startIndex>=0&&(a=i.props.startIndex),i.props.endIndex>=0&&(o=i.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:a,dataEndIndex:o,activeTooltipIndex:-1,isTooltipActive:!!r}},Qie=function(t){return!t||!t.length?!1:t.some(function(n){var r=jr(n&&n.type);return r&&r.indexOf("Bar")>=0})},sO=function(t){return t==="horizontal"?{numericAxisName:"yAxis",cateAxisName:"xAxis"}:t==="vertical"?{numericAxisName:"xAxis",cateAxisName:"yAxis"}:t==="centric"?{numericAxisName:"radiusAxis",cateAxisName:"angleAxis"}:{numericAxisName:"angleAxis",cateAxisName:"radiusAxis"}},Xie=function(t,n){var r=t.props,i=t.graphicalItems,a=t.xAxisMap,o=a===void 0?{}:a,s=t.yAxisMap,l=s===void 0?{}:s,u=r.width,d=r.height,f=r.children,p=r.margin||{},h=Zt(f,us),g=Zt(f,da),y=Object.keys(l).reduce(function(w,S){var O=l[S],P=O.orientation;return!O.mirror&&!O.hide?R(R({},w),{},te({},P,w[P]+O.width)):w},{left:p.left||0,right:p.right||0}),b=Object.keys(o).reduce(function(w,S){var O=o[S],P=O.orientation;return!O.mirror&&!O.hide?R(R({},w),{},te({},P,on(w,"".concat(P))+O.height)):w},{top:p.top||0,bottom:p.bottom||0}),v=R(R({},b),y),m=v.bottom;h&&(v.bottom+=h.props.height||us.defaultProps.height),g&&n&&(v=iQ(v,i,r,n));var x=u-v.left-v.right,j=d-v.top-v.bottom;return R(R({brushBottom:m},v),{},{width:Math.max(x,0),height:Math.max(j,0)})},Yie=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},Jp=function(t){var n=t.chartName,r=t.GraphicalChild,i=t.defaultTooltipEventType,a=i===void 0?"axis":i,o=t.validateTooltipEventTypes,s=o===void 0?["axis"]:o,l=t.axisComponents,u=t.legendContent,d=t.formatAxisMap,f=t.defaultProps,p=function(v,m){var x=m.graphicalItems,j=m.stackGroups,w=m.offset,S=m.updateId,O=m.dataStartIndex,P=m.dataEndIndex,_=v.barSize,N=v.layout,T=v.barGap,k=v.barCategoryGap,z=v.maxBarSize,I=sO(N),M=I.numericAxisName,D=I.cateAxisName,F=Qie(x),C=[];return x.forEach(function(L,B){var V=Yp(v.data,{graphicalItems:[L],dataStartIndex:O,dataEndIndex:P}),H=L.type.defaultProps!==void 0?R(R({},L.type.defaultProps),L.props):L.props,Z=H.dataKey,fe=H.maxBarSize,Ne=H["".concat(M,"Id")],qe=H["".concat(D,"Id")],fn={},Lt=l.reduce(function(Ii,zi){var eh=m["".concat(zi.axisType,"Map")],wx=H["".concat(zi.axisType,"Id")];eh&&eh[wx]||zi.axisType==="zAxis"||Ca();var jx=eh[wx];return R(R({},Ii),{},te(te({},zi.axisType,jx),"".concat(zi.axisType,"Ticks"),br(jx)))},fn),G=Lt[D],ie=Lt["".concat(D,"Ticks")],oe=j&&j[Ne]&&j[Ne].hasStack&&dQ(L,j[Ne].stackGroups),U=jr(L.type).indexOf("Bar")>=0,Le=ud(G,ie),de=[],Xe=F&&nQ({barSize:_,stackGroups:j,totalSize:Yie(Lt,D)});if(U){var Ye,Bt,Wr=re(fe)?z:fe,Ka=(Ye=(Bt=ud(G,ie,!0))!==null&&Bt!==void 0?Bt:Wr)!==null&&Ye!==void 0?Ye:0;de=rQ({barGap:T,barCategoryGap:k,bandSize:Ka!==Le?Ka:Le,sizeList:Xe[qe],maxBarSize:Wr}),Ka!==Le&&(de=de.map(function(Ii){return R(R({},Ii),{},{position:R(R({},Ii.position),{},{offset:Ii.position.offset-Ka/2})})}))}var nc=L&&L.type&&L.type.getComposedData;nc&&C.push({props:R(R({},nc(R(R({},Lt),{},{displayedData:V,props:v,dataKey:Z,item:L,bandSize:Le,barPosition:de,offset:w,stackedData:oe,layout:N,dataStartIndex:O,dataEndIndex:P}))),{},te(te(te({key:L.key||"item-".concat(B)},M,Lt[M]),D,Lt[D]),"animationId",S)),childIndex:r4(L,v.children),item:L})}),C},h=function(v,m){var x=v.props,j=v.dataStartIndex,w=v.dataEndIndex,S=v.updateId;if(!xw({props:x}))return null;var O=x.children,P=x.layout,_=x.stackOffset,N=x.data,T=x.reverseStackOrder,k=sO(P),z=k.numericAxisName,I=k.cateAxisName,M=sn(O,r),D=fQ(N,M,"".concat(z,"Id"),"".concat(I,"Id"),_,T),F=l.reduce(function(H,Z){var fe="".concat(Z.axisType,"Map");return R(R({},H),{},te({},fe,Vie(x,R(R({},Z),{},{graphicalItems:M,stackGroups:Z.axisType===z&&D,dataStartIndex:j,dataEndIndex:w}))))},{}),C=Xie(R(R({},F),{},{props:x,graphicalItems:M}),m==null?void 0:m.legendBBox);Object.keys(F).forEach(function(H){F[H]=d(x,F[H],C,H.replace("Map",""),n)});var L=F["".concat(I,"Map")],B=Gie(L),V=p(x,R(R({},F),{},{dataStartIndex:j,dataEndIndex:w,updateId:S,graphicalItems:M,stackGroups:D,offset:C}));return R(R({formattedGraphicalItems:V,graphicalItems:M,offset:C,stackGroups:D},B),F)},g=function(b){function v(m){var x,j,w;return Nie(this,v),w=Cie(this,v,[m]),te(w,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),te(w,"accessibilityManager",new vie),te(w,"handleLegendBBoxUpdate",function(S){if(S){var O=w.state,P=O.dataStartIndex,_=O.dataEndIndex,N=O.updateId;w.setState(R({legendBBox:S},h({props:w.props,dataStartIndex:P,dataEndIndex:_,updateId:N},R(R({},w.state),{},{legendBBox:S}))))}}),te(w,"handleReceiveSyncEvent",function(S,O,P){if(w.props.syncId===S){if(P===w.eventEmitterSymbol&&typeof w.props.syncMethod!="function")return;w.applySyncEvent(O)}}),te(w,"handleBrushChange",function(S){var O=S.startIndex,P=S.endIndex;if(O!==w.state.dataStartIndex||P!==w.state.dataEndIndex){var _=w.state.updateId;w.setState(function(){return R({dataStartIndex:O,dataEndIndex:P},h({props:w.props,dataStartIndex:O,dataEndIndex:P,updateId:_},w.state))}),w.triggerSyncEvent({dataStartIndex:O,dataEndIndex:P})}}),te(w,"handleMouseEnter",function(S){var O=w.getMouseInfo(S);if(O){var P=R(R({},O),{},{isTooltipActive:!0});w.setState(P),w.triggerSyncEvent(P);var _=w.props.onMouseEnter;ee(_)&&_(P,S)}}),te(w,"triggeredAfterMouseMove",function(S){var O=w.getMouseInfo(S),P=O?R(R({},O),{},{isTooltipActive:!0}):{isTooltipActive:!1};w.setState(P),w.triggerSyncEvent(P);var _=w.props.onMouseMove;ee(_)&&_(P,S)}),te(w,"handleItemMouseEnter",function(S){w.setState(function(){return{isTooltipActive:!0,activeItem:S,activePayload:S.tooltipPayload,activeCoordinate:S.tooltipPosition||{x:S.cx,y:S.cy}}})}),te(w,"handleItemMouseLeave",function(){w.setState(function(){return{isTooltipActive:!1}})}),te(w,"handleMouseMove",function(S){S.persist(),w.throttleTriggeredAfterMouseMove(S)}),te(w,"handleMouseLeave",function(S){w.throttleTriggeredAfterMouseMove.cancel();var O={isTooltipActive:!1};w.setState(O),w.triggerSyncEvent(O);var P=w.props.onMouseLeave;ee(P)&&P(O,S)}),te(w,"handleOuterEvent",function(S){var O=n4(S),P=on(w.props,"".concat(O));if(O&&ee(P)){var _,N;/.*touch.*/i.test(O)?N=w.getMouseInfo(S.changedTouches[0]):N=w.getMouseInfo(S),P((_=N)!==null&&_!==void 0?_:{},S)}}),te(w,"handleClick",function(S){var O=w.getMouseInfo(S);if(O){var P=R(R({},O),{},{isTooltipActive:!0});w.setState(P),w.triggerSyncEvent(P);var _=w.props.onClick;ee(_)&&_(P,S)}}),te(w,"handleMouseDown",function(S){var O=w.props.onMouseDown;if(ee(O)){var P=w.getMouseInfo(S);O(P,S)}}),te(w,"handleMouseUp",function(S){var O=w.props.onMouseUp;if(ee(O)){var P=w.getMouseInfo(S);O(P,S)}}),te(w,"handleTouchMove",function(S){S.changedTouches!=null&&S.changedTouches.length>0&&w.throttleTriggeredAfterMouseMove(S.changedTouches[0])}),te(w,"handleTouchStart",function(S){S.changedTouches!=null&&S.changedTouches.length>0&&w.handleMouseDown(S.changedTouches[0])}),te(w,"handleTouchEnd",function(S){S.changedTouches!=null&&S.changedTouches.length>0&&w.handleMouseUp(S.changedTouches[0])}),te(w,"handleDoubleClick",function(S){var O=w.props.onDoubleClick;if(ee(O)){var P=w.getMouseInfo(S);O(P,S)}}),te(w,"handleContextMenu",function(S){var O=w.props.onContextMenu;if(ee(O)){var P=w.getMouseInfo(S);O(P,S)}}),te(w,"triggerSyncEvent",function(S){w.props.syncId!==void 0&&im.emit(am,w.props.syncId,S,w.eventEmitterSymbol)}),te(w,"applySyncEvent",function(S){var O=w.props,P=O.layout,_=O.syncMethod,N=w.state.updateId,T=S.dataStartIndex,k=S.dataEndIndex;if(S.dataStartIndex!==void 0||S.dataEndIndex!==void 0)w.setState(R({dataStartIndex:T,dataEndIndex:k},h({props:w.props,dataStartIndex:T,dataEndIndex:k,updateId:N},w.state)));else if(S.activeTooltipIndex!==void 0){var z=S.chartX,I=S.chartY,M=S.activeTooltipIndex,D=w.state,F=D.offset,C=D.tooltipTicks;if(!F)return;if(typeof _=="function")M=_(C,S);else if(_==="value"){M=-1;for(var L=0;L<C.length;L++)if(C[L].value===S.activeLabel){M=L;break}}var B=R(R({},F),{},{x:F.left,y:F.top}),V=Math.min(z,B.x+B.width),H=Math.min(I,B.y+B.height),Z=C[M]&&C[M].value,fe=Jy(w.state,w.props.data,M),Ne=C[M]?{x:P==="horizontal"?C[M].coordinate:V,y:P==="horizontal"?H:C[M].coordinate}:Tk;w.setState(R(R({},S),{},{activeLabel:Z,activeCoordinate:Ne,activePayload:fe,activeTooltipIndex:M}))}else w.setState(S)}),te(w,"renderCursor",function(S){var O,P=w.state,_=P.isTooltipActive,N=P.activeCoordinate,T=P.activePayload,k=P.offset,z=P.activeTooltipIndex,I=P.tooltipAxisBandSize,M=w.getTooltipEventType(),D=(O=S.props.active)!==null&&O!==void 0?O:_,F=w.props.layout,C=S.key||"_recharts-cursor";return E.createElement(Sie,{key:C,activeCoordinate:N,activePayload:T,activeTooltipIndex:z,chartName:n,element:S,isActive:D,layout:F,offset:k,tooltipAxisBandSize:I,tooltipEventType:M})}),te(w,"renderPolarAxis",function(S,O,P){var _=on(S,"type.axisType"),N=on(w.state,"".concat(_,"Map")),T=S.type.defaultProps,k=T!==void 0?R(R({},T),S.props):S.props,z=N&&N[k["".concat(_,"Id")]];return A.cloneElement(S,R(R({},z),{},{className:ne(_,z.className),key:S.key||"".concat(O,"-").concat(P),ticks:br(z,!0)}))}),te(w,"renderPolarGrid",function(S){var O=S.props,P=O.radialLines,_=O.polarAngles,N=O.polarRadius,T=w.state,k=T.radiusAxisMap,z=T.angleAxisMap,I=Jr(k),M=Jr(z),D=M.cx,F=M.cy,C=M.innerRadius,L=M.outerRadius;return A.cloneElement(S,{polarAngles:Array.isArray(_)?_:br(M,!0).map(function(B){return B.coordinate}),polarRadius:Array.isArray(N)?N:br(I,!0).map(function(B){return B.coordinate}),cx:D,cy:F,innerRadius:C,outerRadius:L,key:S.key||"polar-grid",radialLines:P})}),te(w,"renderLegend",function(){var S=w.state.formattedGraphicalItems,O=w.props,P=O.children,_=O.width,N=O.height,T=w.props.margin||{},k=_-(T.left||0)-(T.right||0),z=rN({children:P,formattedGraphicalItems:S,legendWidth:k,legendContent:u});if(!z)return null;var I=z.item,M=rO(z,Oie);return A.cloneElement(I,R(R({},M),{},{chartWidth:_,chartHeight:N,margin:T,onBBoxUpdate:w.handleLegendBBoxUpdate}))}),te(w,"renderTooltip",function(){var S,O=w.props,P=O.children,_=O.accessibilityLayer,N=Zt(P,Pt);if(!N)return null;var T=w.state,k=T.isTooltipActive,z=T.activeCoordinate,I=T.activePayload,M=T.activeLabel,D=T.offset,F=(S=N.props.active)!==null&&S!==void 0?S:k;return A.cloneElement(N,{viewBox:R(R({},D),{},{x:D.left,y:D.top}),active:F,label:M,payload:F?I:[],coordinate:z,accessibilityLayer:_})}),te(w,"renderBrush",function(S){var O=w.props,P=O.margin,_=O.data,N=w.state,T=N.offset,k=N.dataStartIndex,z=N.dataEndIndex,I=N.updateId;return A.cloneElement(S,{key:S.key||"_recharts-brush",onChange:Cc(w.handleBrushChange,S.props.onChange),data:_,x:W(S.props.x)?S.props.x:T.left,y:W(S.props.y)?S.props.y:T.top+T.height+T.brushBottom-(P.bottom||0),width:W(S.props.width)?S.props.width:T.width,startIndex:k,endIndex:z,updateId:"brush-".concat(I)})}),te(w,"renderReferenceElement",function(S,O,P){if(!S)return null;var _=w,N=_.clipPathId,T=w.state,k=T.xAxisMap,z=T.yAxisMap,I=T.offset,M=S.type.defaultProps||{},D=S.props,F=D.xAxisId,C=F===void 0?M.xAxisId:F,L=D.yAxisId,B=L===void 0?M.yAxisId:L;return A.cloneElement(S,{key:S.key||"".concat(O,"-").concat(P),xAxis:k[C],yAxis:z[B],viewBox:{x:I.left,y:I.top,width:I.width,height:I.height},clipPathId:N})}),te(w,"renderActivePoints",function(S){var O=S.item,P=S.activePoint,_=S.basePoint,N=S.childIndex,T=S.isRange,k=[],z=O.props.key,I=O.item.type.defaultProps!==void 0?R(R({},O.item.type.defaultProps),O.item.props):O.item.props,M=I.activeDot,D=I.dataKey,F=R(R({index:N,dataKey:D,cx:P.x,cy:P.y,r:4,fill:nx(O.item),strokeWidth:2,stroke:"#fff",payload:P.payload,value:P.value},J(M,!1)),Mf(M));return k.push(v.renderActiveDot(M,F,"".concat(z,"-activePoint-").concat(N))),_?k.push(v.renderActiveDot(M,R(R({},F),{},{cx:_.x,cy:_.y}),"".concat(z,"-basePoint-").concat(N))):T&&k.push(null),k}),te(w,"renderGraphicChild",function(S,O,P){var _=w.filterFormatItem(S,O,P);if(!_)return null;var N=w.getTooltipEventType(),T=w.state,k=T.isTooltipActive,z=T.tooltipAxis,I=T.activeTooltipIndex,M=T.activeLabel,D=w.props.children,F=Zt(D,Pt),C=_.props,L=C.points,B=C.isRange,V=C.baseLine,H=_.item.type.defaultProps!==void 0?R(R({},_.item.type.defaultProps),_.item.props):_.item.props,Z=H.activeDot,fe=H.hide,Ne=H.activeBar,qe=H.activeShape,fn=!!(!fe&&k&&F&&(Z||Ne||qe)),Lt={};N!=="axis"&&F&&F.props.trigger==="click"?Lt={onClick:Cc(w.handleItemMouseEnter,S.props.onClick)}:N!=="axis"&&(Lt={onMouseLeave:Cc(w.handleItemMouseLeave,S.props.onMouseLeave),onMouseEnter:Cc(w.handleItemMouseEnter,S.props.onMouseEnter)});var G=A.cloneElement(S,R(R({},_.props),Lt));function ie(zi){return typeof z.dataKey=="function"?z.dataKey(zi.payload):null}if(fn)if(I>=0){var oe,U;if(z.dataKey&&!z.allowDuplicatedCategory){var Le=typeof z.dataKey=="function"?ie:"payload.".concat(z.dataKey.toString());oe=Cf(L,Le,M),U=B&&V&&Cf(V,Le,M)}else oe=L==null?void 0:L[I],U=B&&V&&V[I];if(qe||Ne){var de=S.props.activeIndex!==void 0?S.props.activeIndex:I;return[A.cloneElement(S,R(R(R({},_.props),Lt),{},{activeIndex:de})),null,null]}if(!re(oe))return[G].concat(bs(w.renderActivePoints({item:_,activePoint:oe,basePoint:U,childIndex:I,isRange:B})))}else{var Xe,Ye=(Xe=w.getItemByXY(w.state.activeCoordinate))!==null&&Xe!==void 0?Xe:{graphicalItem:G},Bt=Ye.graphicalItem,Wr=Bt.item,Ka=Wr===void 0?S:Wr,nc=Bt.childIndex,Ii=R(R(R({},_.props),Lt),{},{activeIndex:nc});return[A.cloneElement(Ka,Ii),null,null]}return B?[G,null,null]:[G,null]}),te(w,"renderCustomized",function(S,O,P){return A.cloneElement(S,R(R({key:"recharts-customized-".concat(P)},w.props),w.state))}),te(w,"renderMap",{CartesianGrid:{handler:Dc,once:!0},ReferenceArea:{handler:w.renderReferenceElement},ReferenceLine:{handler:Dc},ReferenceDot:{handler:w.renderReferenceElement},XAxis:{handler:Dc},YAxis:{handler:Dc},Brush:{handler:w.renderBrush,once:!0},Bar:{handler:w.renderGraphicChild},Line:{handler:w.renderGraphicChild},Area:{handler:w.renderGraphicChild},Radar:{handler:w.renderGraphicChild},RadialBar:{handler:w.renderGraphicChild},Scatter:{handler:w.renderGraphicChild},Pie:{handler:w.renderGraphicChild},Funnel:{handler:w.renderGraphicChild},Tooltip:{handler:w.renderCursor,once:!0},PolarGrid:{handler:w.renderPolarGrid,once:!0},PolarAngleAxis:{handler:w.renderPolarAxis},PolarRadiusAxis:{handler:w.renderPolarAxis},Customized:{handler:w.renderCustomized}}),w.clipPathId="".concat((x=m.id)!==null&&x!==void 0?x:Ts("recharts"),"-clip"),w.throttleTriggeredAfterMouseMove=r$(w.triggeredAfterMouseMove,(j=m.throttleDelay)!==null&&j!==void 0?j:1e3/60),w.state={},w}return zie(v,b),Tie(v,[{key:"componentDidMount",value:function(){var x,j;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(x=this.props.margin.left)!==null&&x!==void 0?x:0,top:(j=this.props.margin.top)!==null&&j!==void 0?j:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var x=this.props,j=x.children,w=x.data,S=x.height,O=x.layout,P=Zt(j,Pt);if(P){var _=P.props.defaultIndex;if(!(typeof _!="number"||_<0||_>this.state.tooltipTicks.length-1)){var N=this.state.tooltipTicks[_]&&this.state.tooltipTicks[_].value,T=Jy(this.state,w,_,N),k=this.state.tooltipTicks[_].coordinate,z=(this.state.offset.top+S)/2,I=O==="horizontal",M=I?{x:k,y:z}:{y:k,x:z},D=this.state.formattedGraphicalItems.find(function(C){var L=C.item;return L.type.name==="Scatter"});D&&(M=R(R({},M),D.props.points[_].tooltipPosition),T=D.props.points[_].tooltipPayload);var F={activeTooltipIndex:_,isTooltipActive:!0,activeLabel:N,activePayload:T,activeCoordinate:M};this.setState(F),this.renderCursor(P),this.accessibilityManager.setIndex(_)}}}},{key:"getSnapshotBeforeUpdate",value:function(x,j){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==j.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==x.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==x.margin){var w,S;this.accessibilityManager.setDetails({offset:{left:(w=this.props.margin.left)!==null&&w!==void 0?w:0,top:(S=this.props.margin.top)!==null&&S!==void 0?S:0}})}return null}},{key:"componentDidUpdate",value:function(x){Av([Zt(x.children,Pt)],[Zt(this.props.children,Pt)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var x=Zt(this.props.children,Pt);if(x&&typeof x.props.shared=="boolean"){var j=x.props.shared?"axis":"item";return s.indexOf(j)>=0?j:a}return a}},{key:"getMouseInfo",value:function(x){if(!this.container)return null;var j=this.container,w=j.getBoundingClientRect(),S=$H(w),O={chartX:Math.round(x.pageX-S.left),chartY:Math.round(x.pageY-S.top)},P=w.width/j.offsetWidth||1,_=this.inRange(O.chartX,O.chartY,P);if(!_)return null;var N=this.state,T=N.xAxisMap,k=N.yAxisMap,z=this.getTooltipEventType(),I=aO(this.state,this.props.data,this.props.layout,_);if(z!=="axis"&&T&&k){var M=Jr(T).scale,D=Jr(k).scale,F=M&&M.invert?M.invert(O.chartX):null,C=D&&D.invert?D.invert(O.chartY):null;return R(R({},O),{},{xValue:F,yValue:C},I)}return I?R(R({},O),I):null}},{key:"inRange",value:function(x,j){var w=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,S=this.props.layout,O=x/w,P=j/w;if(S==="horizontal"||S==="vertical"){var _=this.state.offset,N=O>=_.left&&O<=_.left+_.width&&P>=_.top&&P<=_.top+_.height;return N?{x:O,y:P}:null}var T=this.state,k=T.angleAxisMap,z=T.radiusAxisMap;if(k&&z){var I=Jr(k);return Ej({x:O,y:P},I)}return null}},{key:"parseEventsOfWrapper",value:function(){var x=this.props.children,j=this.getTooltipEventType(),w=Zt(x,Pt),S={};w&&j==="axis"&&(w.props.trigger==="click"?S={onClick:this.handleClick}:S={onMouseEnter:this.handleMouseEnter,onDoubleClick:this.handleDoubleClick,onMouseMove:this.handleMouseMove,onMouseLeave:this.handleMouseLeave,onTouchMove:this.handleTouchMove,onTouchStart:this.handleTouchStart,onTouchEnd:this.handleTouchEnd,onContextMenu:this.handleContextMenu});var O=Mf(this.props,this.handleOuterEvent);return R(R({},O),S)}},{key:"addListener",value:function(){im.on(am,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){im.removeListener(am,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(x,j,w){for(var S=this.state.formattedGraphicalItems,O=0,P=S.length;O<P;O++){var _=S[O];if(_.item===x||_.props.key===x.key||j===jr(_.item.type)&&w===_.childIndex)return _}return null}},{key:"renderClipPath",value:function(){var x=this.clipPathId,j=this.state.offset,w=j.left,S=j.top,O=j.height,P=j.width;return E.createElement("defs",null,E.createElement("clipPath",{id:x},E.createElement("rect",{x:w,y:S,height:O,width:P})))}},{key:"getXScales",value:function(){var x=this.state.xAxisMap;return x?Object.entries(x).reduce(function(j,w){var S=nO(w,2),O=S[0],P=S[1];return R(R({},j),{},te({},O,P.scale))},{}):null}},{key:"getYScales",value:function(){var x=this.state.yAxisMap;return x?Object.entries(x).reduce(function(j,w){var S=nO(w,2),O=S[0],P=S[1];return R(R({},j),{},te({},O,P.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(x){var j;return(j=this.state.xAxisMap)===null||j===void 0||(j=j[x])===null||j===void 0?void 0:j.scale}},{key:"getYScaleByAxisId",value:function(x){var j;return(j=this.state.yAxisMap)===null||j===void 0||(j=j[x])===null||j===void 0?void 0:j.scale}},{key:"getItemByXY",value:function(x){var j=this.state,w=j.formattedGraphicalItems,S=j.activeItem;if(w&&w.length)for(var O=0,P=w.length;O<P;O++){var _=w[O],N=_.props,T=_.item,k=T.type.defaultProps!==void 0?R(R({},T.type.defaultProps),T.props):T.props,z=jr(T.type);if(z==="Bar"){var I=(N.data||[]).find(function(C){return fJ(x,C)});if(I)return{graphicalItem:_,payload:I}}else if(z==="RadialBar"){var M=(N.data||[]).find(function(C){return Ej(x,C)});if(M)return{graphicalItem:_,payload:M}}else if(qp(_,S)||Hp(_,S)||Pu(_,S)){var D=ZZ({graphicalItem:_,activeTooltipItem:S,itemData:k.data}),F=k.activeIndex===void 0?D:k.activeIndex;return{graphicalItem:R(R({},_),{},{childIndex:F}),payload:Pu(_,S)?k.data[D]:_.props.data[D]}}}return null}},{key:"render",value:function(){var x=this;if(!xw(this))return null;var j=this.props,w=j.children,S=j.className,O=j.width,P=j.height,_=j.style,N=j.compact,T=j.title,k=j.desc,z=rO(j,Pie),I=J(z,!1);if(N)return E.createElement(LS,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},E.createElement(Ev,mo({},I,{width:O,height:P,title:T,desc:k}),this.renderClipPath(),ww(w,this.renderMap)));if(this.props.accessibilityLayer){var M,D;I.tabIndex=(M=this.props.tabIndex)!==null&&M!==void 0?M:0,I.role=(D=this.props.role)!==null&&D!==void 0?D:"application",I.onKeyDown=function(C){x.accessibilityManager.keyboardEvent(C)},I.onFocus=function(){x.accessibilityManager.focus()}}var F=this.parseEventsOfWrapper();return E.createElement(LS,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},E.createElement("div",mo({className:ne("recharts-wrapper",S),style:R({position:"relative",cursor:"default",width:O,height:P},_)},F,{ref:function(L){x.container=L}}),E.createElement(Ev,mo({},I,{width:O,height:P,title:T,desc:k,style:Uie}),this.renderClipPath(),ww(w,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])}(A.Component);te(g,"displayName",n),te(g,"defaultProps",R({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},f)),te(g,"getDerivedStateFromProps",function(b,v){var m=b.dataKey,x=b.data,j=b.children,w=b.width,S=b.height,O=b.layout,P=b.stackOffset,_=b.margin,N=v.dataStartIndex,T=v.dataEndIndex;if(v.updateId===void 0){var k=oO(b);return R(R(R({},k),{},{updateId:0},h(R(R({props:b},k),{},{updateId:0}),v)),{},{prevDataKey:m,prevData:x,prevWidth:w,prevHeight:S,prevLayout:O,prevStackOffset:P,prevMargin:_,prevChildren:j})}if(m!==v.prevDataKey||x!==v.prevData||w!==v.prevWidth||S!==v.prevHeight||O!==v.prevLayout||P!==v.prevStackOffset||!jo(_,v.prevMargin)){var z=oO(b),I={chartX:v.chartX,chartY:v.chartY,isTooltipActive:v.isTooltipActive},M=R(R({},aO(v,x,O)),{},{updateId:v.updateId+1}),D=R(R(R({},z),I),M);return R(R(R({},D),h(R({props:b},D),v)),{},{prevDataKey:m,prevData:x,prevWidth:w,prevHeight:S,prevLayout:O,prevStackOffset:P,prevMargin:_,prevChildren:j})}if(!Av(j,v.prevChildren)){var F,C,L,B,V=Zt(j,us),H=V&&(F=(C=V.props)===null||C===void 0?void 0:C.startIndex)!==null&&F!==void 0?F:N,Z=V&&(L=(B=V.props)===null||B===void 0?void 0:B.endIndex)!==null&&L!==void 0?L:T,fe=H!==N||Z!==T,Ne=!re(x),qe=Ne&&!fe?v.updateId:v.updateId+1;return R(R({updateId:qe},h(R(R({props:b},v),{},{updateId:qe,dataStartIndex:H,dataEndIndex:Z}),v)),{},{prevChildren:j,dataStartIndex:H,dataEndIndex:Z})}return null}),te(g,"renderActiveDot",function(b,v,m){var x;return A.isValidElement(b)?x=A.cloneElement(b,v):ee(b)?x=b(v):x=E.createElement(Fp,v),E.createElement(se,{className:"recharts-active-dot",key:m},x)});var y=A.forwardRef(function(v,m){return E.createElement(g,mo({},v,{ref:m}))});return y.displayName=g.displayName,y},Dd=Jp({chartName:"BarChart",GraphicalChild:rr,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:Cr},{axisType:"yAxis",AxisComp:Mr}],formatAxisMap:XN}),Jie=Jp({chartName:"PieChart",GraphicalChild:Fr,validateTooltipEventTypes:["item"],defaultTooltipEventType:"item",legendContent:"children",axisComponents:[{axisType:"angleAxis",AxisComp:Yu},{axisType:"radiusAxis",AxisComp:Xu}],formatAxisMap:yN,defaultProps:{layout:"centric",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}}),Mk=Jp({chartName:"AreaChart",GraphicalChild:Ur,axisComponents:[{axisType:"xAxis",AxisComp:Cr},{axisType:"yAxis",AxisComp:Mr}],formatAxisMap:XN}),Zie=Jp({chartName:"RadialBarChart",GraphicalChild:Ju,legendContent:"children",defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"angleAxis",AxisComp:Yu},{axisType:"radiusAxis",AxisComp:Xu}],formatAxisMap:yN,defaultProps:{layout:"radial",startAngle:0,endAngle:360,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"}});function qa({title:e,data:t,right:n,color:r=F_,valueLabel:i="value",height:a=220}){const o=A.useId(),s=a-64;return c.jsx(Aa,{title:e,right:n,height:s,children:t.length===0?c.jsx(o0,{height:s}):c.jsx(Ea,{width:"100%",height:"100%",children:c.jsxs(Mk,{data:t,margin:{top:4,right:8,bottom:0,left:-16},children:[c.jsx("defs",{children:c.jsxs("linearGradient",{id:o,x1:"0",y1:"0",x2:"0",y2:"1",children:[c.jsx("stop",{offset:"0%",stopColor:r,stopOpacity:.35}),c.jsx("stop",{offset:"100%",stopColor:r,stopOpacity:0})]})}),c.jsx(ms,{stroke:Te.gridStroke,vertical:!1}),c.jsx(Cr,{dataKey:"label",tick:Gn,stroke:Te.axisStroke,tickLine:!1,minTickGap:24}),c.jsx(Mr,{tick:Gn,stroke:Te.axisStroke,tickLine:!1,width:40,allowDecimals:!1}),c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa,cursor:{stroke:Te.axisStroke}}),c.jsx(Ur,{type:"monotone",dataKey:"value",name:i,stroke:r,strokeWidth:2,fill:`url(#${o})`,isAnimationActive:!1,dot:!1,activeDot:{r:3}})]})})})}function mx({title:e,data:t,series:n,right:r,height:i=240}){const a=i-64;return c.jsx(Aa,{title:e,right:r,height:a,children:t.length===0||n.length===0?c.jsx(o0,{height:a}):c.jsx(Ea,{width:"100%",height:"100%",children:c.jsxs(Mk,{data:t,margin:{top:4,right:8,bottom:0,left:-16},children:[c.jsx(ms,{stroke:Te.gridStroke,vertical:!1}),c.jsx(Cr,{dataKey:"label",tick:Gn,stroke:Te.axisStroke,tickLine:!1,minTickGap:24}),c.jsx(Mr,{tick:Gn,stroke:Te.axisStroke,tickLine:!1,width:40,allowDecimals:!1}),c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa,cursor:{stroke:Te.axisStroke}}),c.jsx(da,{iconType:"circle",iconSize:8,wrapperStyle:{fontSize:10,color:Te.legendText}}),n.map((o,s)=>{const l=fR(o,s);return c.jsx(Ur,{type:"monotone",dataKey:o,name:o,stackId:"1",stroke:l,strokeWidth:1.5,fill:l,fillOpacity:.25,isAnimationActive:!1},o)})]})})})}function eae(e,t){return e.length<=t?e:`${e.slice(0,Math.max(0,t-1))}…`}function va({title:e,data:t,right:n,color:r=F_,valueLabel:i="value",height:a=220,horizontal:o=!1,truncateLabel:s,onBarClick:l}){const u=a-64;function d(h,g){const y=t[g];y&&l&&l(y)}const f=s!==void 0?{tickFormatter:h=>eae(h,s)}:{},p=l!==void 0?{onClick:d,cursor:"pointer"}:{};return c.jsx(Aa,{title:e,right:n,height:u,children:t.length===0?c.jsx(o0,{height:u}):c.jsx(Ea,{width:"100%",height:"100%",children:o?c.jsxs(Dd,{data:t,layout:"vertical",margin:{top:4,right:8,bottom:0,left:8},children:[c.jsx(ms,{stroke:Te.gridStroke,horizontal:!1}),c.jsx(Cr,{type:"number",tick:Gn,stroke:Te.axisStroke,tickLine:!1,allowDecimals:!1}),c.jsx(Mr,{type:"category",dataKey:"label",tick:Gn,...f,stroke:Te.axisStroke,tickLine:!1,width:160,interval:0}),c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa,cursor:{fill:"#ffffff08"}}),c.jsx(rr,{dataKey:"value",name:i,radius:[0,3,3,0],isAnimationActive:!1,...p,children:t.map(h=>c.jsx($a,{fill:h.color??r},h.id??h.label))})]}):c.jsxs(Dd,{data:t,margin:{top:4,right:8,bottom:0,left:-16},children:[c.jsx(ms,{stroke:Te.gridStroke,vertical:!1}),c.jsx(Cr,{dataKey:"label",tick:Gn,...f,stroke:Te.axisStroke,tickLine:!1,interval:0}),c.jsx(Mr,{tick:Gn,stroke:Te.axisStroke,tickLine:!1,width:40,allowDecimals:!1}),c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa,cursor:{fill:"#ffffff08"}}),c.jsx(rr,{dataKey:"value",name:i,radius:[3,3,0,0],isAnimationActive:!1,...p,children:t.map(h=>c.jsx($a,{fill:h.color??r},h.id??h.label))})]})})})}const Ik=["waiting","active","delayed","failed","completed","paused"],zk={waiting:"text-zinc-300",active:"text-sky-400",delayed:"text-amber-400",failed:"text-red-400",completed:"text-emerald-400",paused:"text-violet-400"};function Ha(e){if(e==null)return"—";const t=Date.now()-e;if(t<0)return"just now";const n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;const r=Math.floor(n/60);if(r<60)return`${r}m ago`;const i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}const tae="1h";function nae(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Zu(e){return((e==null?void 0:e.buckets)??[]).map(t=>({label:nae(t.t),value:t.total}))}function Et({label:e,value:t,accent:n="text-zinc-100"}){return c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 px-4 py-3",children:[c.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:e}),c.jsx("p",{className:`mt-1 text-2xl font-semibold tabular-nums ${n}`,children:t})]})}function ec({children:e}){return c.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:e})}function vx({children:e}){return c.jsx("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:e})}function rae(e){return e.map(t=>({label:t.label!==""?t.label:t.familyHash.slice(0,12),value:t.p99,id:t.familyHash}))}function iae(e){return[{label:"2xx",value:e["2xx"],color:"#34d399"},{label:"3xx",value:e["3xx"],color:"#38bdf8"},{label:"4xx",value:e["4xx"],color:"#fbbf24"},{label:"5xx",value:e["5xx"],color:"#f87171"},{label:"other",value:e.other,color:"#71717a"}]}function aae(e){return e.topKeys.map(t=>({label:t.key,value:t.count}))}function oae({stats:e}){const t=e.latency,n=ir();return c.jsxs(c.Fragment,{children:[c.jsxs(ec,{children:[c.jsx(Et,{label:"Total",value:e.total.toLocaleString()}),c.jsx(Et,{label:"p50 ms",value:t?t.p50.toLocaleString():"—"}),c.jsx(Et,{label:"p99 ms",value:t?t.p99.toLocaleString():"—",accent:"text-sky-400"}),c.jsx(Et,{label:"Slow",value:t?t.slow.toLocaleString():"—",accent:t&&t.slow>0?"text-amber-400":"text-zinc-100"})]}),c.jsxs(vx,{children:[e.families?c.jsx(va,{title:"Slowest query shapes (p99)",valueLabel:"p99 ms",data:rae(e.families),horizontal:!0,truncateLabel:40,onBarClick:r=>{r.id!==void 0&&n(`/entries/query?familyHash=${encodeURIComponent(r.id)}`)}}):null,c.jsx(qa,{title:"Queries over time",valueLabel:"queries",data:Zu(e.overTime)})]})]})}function sae(e){return Object.entries(e).map(([t,n])=>({label:t,value:n.hits})).sort((t,n)=>t.label.localeCompare(n.label))}function lae({stats:e}){const t=e.cache,n=(t==null?void 0:t.byTier)??{},r=Object.keys(n),i=(t==null?void 0:t.staleHits)??0,a=(t==null?void 0:t.deletes)??0;return c.jsxs(c.Fragment,{children:[c.jsxs(ec,{children:[c.jsx(Et,{label:"Hit ratio",value:t?`${Math.round(t.hitRatio*100)}%`:"—",accent:"text-emerald-400"}),c.jsx(Et,{label:"Hits",value:t?t.hits.toLocaleString():"—"}),c.jsx(Et,{label:"Misses",value:t?t.misses.toLocaleString():"—"}),c.jsx(Et,{label:"Sets",value:t?t.sets.toLocaleString():"—"}),a>0?c.jsx(Et,{label:"Deletes",value:a.toLocaleString()}):null,i>0?c.jsx(Et,{label:"Stale hits",value:i.toLocaleString(),accent:"text-amber-400"}):null]}),c.jsxs(vx,{children:[t?c.jsx(va,{title:"Hits vs misses",valueLabel:"count",data:[{label:"hits",value:t.hits,color:"#34d399"},{label:"misses",value:t.misses,color:"#f87171"}]}):null,r.length>0?c.jsx(va,{title:"Hits by tier",valueLabel:"hits",data:sae(n)}):null,c.jsx(qa,{title:"Cache over time",valueLabel:"ops",data:Zu(e.overTime)})]}),t?c.jsx(va,{title:"Top keys",valueLabel:"count",data:aae(t)}):null]})}function uae({stats:e}){const t=e.latency,n=e.status,r=n?n["4xx"]+n["5xx"]:0,i=e.total>0?Math.round(r/e.total*100):0;return c.jsxs(c.Fragment,{children:[c.jsxs(ec,{children:[c.jsx(Et,{label:"Total",value:e.total.toLocaleString()}),c.jsx(Et,{label:"p99 ms",value:t?t.p99.toLocaleString():"—",accent:"text-sky-400"}),c.jsx(Et,{label:"Error %",value:`${i}%`,accent:r>0?"text-red-400":"text-zinc-100"})]}),c.jsxs(vx,{children:[n?c.jsx(va,{title:"Status codes",valueLabel:"count",data:iae(n)}):null,c.jsx(qa,{title:"Throughput",valueLabel:"requests",data:Zu(e.overTime)})]})]})}function cae({values:e}){if(e.length===0)return null;const t=Math.max(1,...e);return c.jsx("div",{className:"flex h-6 items-end gap-px","aria-hidden":"true",children:e.map((n,r)=>c.jsx("div",{className:"w-1 rounded-sm bg-amber-500/60",style:{height:`${Math.max(2,Math.round(n/t*100))}%`}},r))})}function fae({group:e}){const t=new Date(e.lastAt).getTime();return c.jsxs(b_,{to:`/entries/exception?familyHash=${encodeURIComponent(e.key)}`,className:"flex items-center gap-3 rounded-lg border border-zinc-800 bg-zinc-900/40 px-4 py-3 transition hover:border-zinc-700 hover:bg-zinc-900/70",children:[c.jsxs("div",{className:"min-w-0 flex-1",children:[c.jsx("p",{className:"truncate font-mono text-sm font-semibold text-red-300",children:e.class}),c.jsx("p",{className:"truncate text-xs text-zinc-400",children:e.message})]}),c.jsx(cae,{values:e.overTime}),c.jsxs("div",{className:"shrink-0 text-right",children:[c.jsx("p",{className:"text-sm font-semibold tabular-nums text-zinc-100",children:e.count.toLocaleString()}),c.jsx("p",{className:"text-[10px] text-zinc-500",children:Ha(Number.isNaN(t)?null:t)})]})]})}function dae({stats:e}){const t=e.exceptions??[];return c.jsxs(c.Fragment,{children:[c.jsxs(ec,{children:[c.jsx(Et,{label:"Total",value:e.total.toLocaleString()}),c.jsx(Et,{label:"Groups",value:t.length.toLocaleString(),accent:t.length>0?"text-amber-400":"text-zinc-100"})]}),t.length>0?c.jsxs("div",{className:"space-y-2",children:[c.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Exception groups"}),t.map(n=>c.jsx(fae,{group:n},n.key))]}):null,c.jsx(qa,{title:"Exceptions over time",valueLabel:"exceptions",data:Zu(e.overTime)})]})}function pae({stats:e}){return c.jsxs(c.Fragment,{children:[c.jsx(ec,{children:c.jsx(Et,{label:"Total",value:e.total.toLocaleString()})}),c.jsx(qa,{title:"Over time",valueLabel:"entries",data:Zu(e.overTime)})]})}function hae({stats:e}){return e.type==="query"?c.jsx(oae,{stats:e}):e.type==="cache"?c.jsx(lae,{stats:e}):e.type==="request"?c.jsx(uae,{stats:e}):e.type==="exception"?c.jsx(dae,{stats:e}):c.jsx(pae,{stats:e})}function mae({type:e}){const{data:t}=YI(e,tae);return t?c.jsxs("div",{className:"mb-4 space-y-4",children:[c.jsx(hae,{stats:t}),t.truncated?c.jsx("p",{className:"text-[10px] text-zinc-600",children:"sampled (window capped)"}):null]}):c.jsx("div",{className:"mb-4 h-24 animate-pulse rounded-lg border border-zinc-800 bg-zinc-900/20"})}const vae=["15m","1h","6h","24h"];function tc({value:e,onChange:t}){return c.jsx("select",{value:e,onChange:n=>t(n.target.value),className:"rounded border border-zinc-800 bg-zinc-900 px-2 py-1 text-xs text-zinc-300",children:vae.map(n=>c.jsx("option",{value:n,children:n},n))})}const yae=10;function gae(e,t){const n=t.trim().toLowerCase();return e.filter(r=>n===""||r.tag.toLowerCase().includes(n)).sort((r,i)=>i.count-r.count).slice(0,yae)}function lO({onSelect:e,prefix:t="",placeholder:n="Filter by tag…",ariaLabel:r="Filter by tag"}){const[i,a]=A.useState(""),[o,s]=A.useState(!1),[l,u]=A.useState(0),d=A.useRef(null),f=A.useId(),p=i.trim(),h=`${t}${p}`,{data:g}=XI(h),y=p===""?[]:gae(g??[],h),b=o&&y.length>0;function v(w){return t!==""&&w.startsWith(t)?w.slice(t.length):w}A.useEffect(()=>{u(w=>w>=y.length?0:w)},[y.length]),A.useEffect(()=>{function w(S){var P;const O=S.target;O instanceof Node&&!((P=d.current)!=null&&P.contains(O))&&s(!1)}return document.addEventListener("mousedown",w),()=>document.removeEventListener("mousedown",w)},[]);function m(w){e(w),a(v(w)),s(!1)}function x(w){if(w.key==="Escape"){s(!1);return}if(!b){w.key==="Enter"&&p!==""&&m(h);return}if(w.key==="ArrowDown")w.preventDefault(),u(S=>(S+1)%y.length);else if(w.key==="ArrowUp")w.preventDefault(),u(S=>(S-1+y.length)%y.length);else if(w.key==="Enter"){w.preventDefault();const S=y[l];S?m(S.tag):p!==""&&m(h)}}const j=b?`${f}-option-${l}`:void 0;return c.jsxs("div",{ref:d,className:"relative",children:[c.jsx("input",{type:"text",value:i,onChange:w=>{a(w.target.value),s(!0)},onFocus:()=>s(!0),onKeyDown:x,placeholder:n,"aria-label":r,role:"combobox","aria-expanded":b,"aria-controls":f,"aria-autocomplete":"list",...j?{"aria-activedescendant":j}:{},className:"rounded border border-zinc-800 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 placeholder:text-zinc-600 focus:border-emerald-500 focus:outline-none"}),b?c.jsx("div",{id:f,role:"listbox","aria-label":"Tag suggestions",tabIndex:-1,className:"absolute left-0 top-full z-10 mt-1 max-h-64 w-48 overflow-auto rounded border border-zinc-800 bg-zinc-950 py-1 shadow-lg",children:y.map((w,S)=>c.jsxs("div",{id:`${f}-option-${S}`,role:"option",tabIndex:-1,"aria-selected":S===l,onMouseDown:O=>{O.preventDefault(),m(w.tag)},onMouseEnter:()=>u(S),className:`flex cursor-pointer items-center justify-between gap-3 px-2 py-1 text-xs ${S===l?"bg-zinc-800 text-zinc-100":"text-zinc-300"}`,children:[c.jsx("span",{className:"truncate",children:v(w.tag)}),c.jsx("span",{className:"shrink-0 text-zinc-500",children:w.count})]},w.tag))}):null]})}function Ya({title:e,children:t}){return c.jsxs("section",{className:"mb-6",children:[c.jsx("h3",{className:"mb-2 text-xs uppercase tracking-wide text-zinc-500",children:e}),t]})}function xae({report:e,onSelectEntry:t,onSelectFamily:n,onSelectRoute:r,onSelectOutgoing:i}){return c.jsxs("div",{className:"text-xs",children:[e.truncated&&c.jsxs("p",{className:"mb-4 text-amber-500",children:["Scan truncated at ",e.scanned," entries — widen the window with care."]}),c.jsx(Ya,{title:"Entries by type",children:c.jsxs("div",{className:"flex flex-wrap gap-3",children:[Object.entries(e.counts).map(([a,o])=>c.jsxs("span",{className:"rounded bg-zinc-900 px-2 py-1",children:[c.jsx("span",{className:"text-emerald-400",children:a})," ",c.jsx("span",{className:"text-zinc-300",children:o})]},a)),Object.keys(e.counts).length===0&&c.jsx("span",{className:"text-zinc-600",children:"No entries in window."})]})}),c.jsx(Ya,{title:"Slowest",children:c.jsx("table",{className:"w-full text-left",children:c.jsxs("tbody",{children:[e.slowest.map(a=>c.jsxs("tr",{tabIndex:0,onClick:()=>t==null?void 0:t(a.id),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(t==null||t(a.id))},className:"cursor-pointer border-t border-zinc-900 hover:bg-zinc-900",children:[c.jsx("td",{className:"py-1 text-emerald-400",children:a.type}),c.jsx("td",{className:"max-w-md truncate text-zinc-300",children:a.label}),c.jsxs("td",{className:"text-right text-zinc-400",children:[a.durationMs,"ms"]})]},a.id)),e.slowest.length===0&&c.jsx("tr",{children:c.jsx("td",{className:"py-1 text-zinc-600",children:"—"})})]})})}),c.jsx(Ya,{title:"Top exceptions",children:c.jsx("table",{className:"w-full text-left",children:c.jsxs("tbody",{children:[e.topExceptions.map(a=>c.jsxs("tr",{className:"border-t border-zinc-900",children:[c.jsx("td",{className:"py-1 text-red-400",children:a.class}),c.jsx("td",{className:"max-w-md truncate text-zinc-300",children:a.message}),c.jsxs("td",{className:"text-right text-zinc-400",children:["×",a.count]})]},a.familyHash)),e.topExceptions.length===0&&c.jsx("tr",{children:c.jsx("td",{className:"py-1 text-zinc-600",children:"No exceptions 🎉"})})]})})}),c.jsx(Ya,{title:"N+1 query hotspots",children:c.jsx("table",{className:"w-full text-left",children:c.jsxs("tbody",{children:[e.nPlusOne.map(a=>c.jsxs("tr",{tabIndex:0,onClick:()=>n==null?void 0:n(a.familyHash),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(n==null||n(a.familyHash))},className:"cursor-pointer border-t border-zinc-900 hover:bg-zinc-900",children:[c.jsxs("td",{className:"whitespace-nowrap py-1 text-amber-400",children:["×",a.perRequest,c.jsx("span",{className:"text-zinc-500",children:" per request"})]}),c.jsx("td",{className:"max-w-md truncate text-zinc-300",children:a.sql}),c.jsxs("td",{className:"whitespace-nowrap text-right text-zinc-500",children:[a.requests," requests · ",a.total," total"]})]},a.familyHash)),e.nPlusOne.length===0&&c.jsx("tr",{children:c.jsx("td",{className:"py-1 text-zinc-600",children:"None detected"})})]})})}),c.jsx(Ya,{title:"Slow request hotspots",children:c.jsx("table",{className:"w-full text-left",children:c.jsxs("tbody",{children:[e.slowRoutes.map(a=>c.jsxs("tr",{tabIndex:0,onClick:()=>r==null?void 0:r(a.route),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(r==null||r(a.route))},className:"cursor-pointer border-t border-zinc-900 hover:bg-zinc-900",children:[c.jsx("td",{className:"max-w-md truncate py-1 font-mono text-zinc-300",children:a.route}),c.jsxs("td",{className:"whitespace-nowrap text-right text-amber-400",children:[a.p99,"ms",c.jsx("span",{className:"text-zinc-500",children:" p99"})]}),c.jsxs("td",{className:"whitespace-nowrap text-right text-zinc-500",children:["×",a.count]})]},a.route)),e.slowRoutes.length===0&&c.jsx("tr",{children:c.jsx("td",{className:"py-1 text-zinc-600",children:"No routes over the slow threshold"})})]})})}),c.jsx(Ya,{title:"Slow outgoing HTTP",children:c.jsx("table",{className:"w-full text-left",children:c.jsxs("tbody",{children:[e.slowOutgoing.map(a=>c.jsxs("tr",{tabIndex:0,onClick:()=>i==null?void 0:i(a.route),onKeyDown:o=>{(o.key==="Enter"||o.key===" ")&&(i==null||i(a.route))},className:"cursor-pointer border-t border-zinc-900 hover:bg-zinc-900",children:[c.jsx("td",{className:"max-w-md truncate py-1 font-mono text-zinc-300",children:a.route}),c.jsxs("td",{className:"whitespace-nowrap text-right text-amber-400",children:[a.p99,"ms",c.jsx("span",{className:"text-zinc-500",children:" p99"})]}),c.jsxs("td",{className:"whitespace-nowrap text-right text-zinc-500",children:["×",a.count]})]},a.route)),e.slowOutgoing.length===0&&c.jsx("tr",{children:c.jsx("td",{className:"py-1 text-zinc-600",children:"No outgoing calls over the slow threshold"})})]})})})]})}function uO(e){return e?`${Math.round(e.p95)}ms`:"—"}function bae({report:e,sparkline:t}){return c.jsxs("table",{className:"w-full text-left text-xs",children:[c.jsx("thead",{className:"text-zinc-500",children:c.jsxs("tr",{children:[c.jsx("th",{className:"py-2 font-normal",children:"Queue"}),c.jsx("th",{className:"font-normal",children:"Total"}),c.jsx("th",{className:"font-normal",children:"Failed"}),c.jsx("th",{className:"font-normal",children:"Fail %"}),c.jsx("th",{className:"font-normal",children:"Per min"}),c.jsx("th",{className:"font-normal",children:"Runtime p95"}),c.jsx("th",{className:"font-normal",children:"Wait p95"}),t&&c.jsx("th",{className:"font-normal",children:"Trend"})]})}),c.jsxs("tbody",{children:[e.queues.map(n=>c.jsxs("tr",{className:"border-t border-zinc-900",children:[c.jsx("td",{className:"py-1.5 text-emerald-400",children:n.queue}),c.jsx("td",{className:"text-zinc-300",children:n.total}),c.jsx("td",{className:"text-zinc-300",children:n.failed}),c.jsxs("td",{className:n.failureRate>0?"text-red-400":"text-zinc-500",children:[(n.failureRate*100).toFixed(1),"%"]}),c.jsx("td",{className:"text-zinc-400",children:n.throughputPerMinute.toFixed(1)}),c.jsx("td",{className:"text-zinc-400",children:uO(n.runtimeMs)}),c.jsx("td",{className:"text-zinc-400",children:uO(n.waitMs)}),t&&c.jsx("td",{className:"text-zinc-400",children:t(n.queue)})]},n.queue)),e.queues.length===0&&c.jsx("tr",{children:c.jsx("td",{className:"py-2 text-zinc-600",colSpan:t?8:7,children:"No queue activity in window."})})]})]})}function wae(e,t,n){if(e.length===0)return"";const r=Math.max(...e,1),i=e.length>1?t/(e.length-1):0;return e.map((a,o)=>{const s=o*i,l=n-a/r*n;return`${s.toFixed(1)},${l.toFixed(1)}`}).join(" ")}function nf({values:e,width:t=160,height:n=36}){const r=wae(e,t,n),i=r?`0,${n} ${r} ${t},${n}`:"";return c.jsxs("svg",{width:t,height:n,viewBox:`0 0 ${t} ${n}`,preserveAspectRatio:"none",role:"img","aria-label":"throughput",children:[i&&c.jsx("polygon",{points:i,className:"fill-emerald-500/10"}),r&&c.jsx("polyline",{points:r,className:"fill-none stroke-emerald-400",strokeWidth:1.5})]})}const cO={request:"fill-emerald-400",query:"fill-sky-400",job:"fill-violet-400",exception:"fill-red-400",http_client:"fill-amber-400",mail:"fill-pink-400"};function yx(e){const t=new Set;for(const i of e)for(const a of Object.keys(i.byType))t.add(a);const n=Object.keys(cO).filter(i=>t.has(i)),r=[...t].filter(i=>!(i in cO)).sort();return[...n,...r]}function jae({queue:e,window:t}){const{data:n}=n0({window:t,tag:`queue:${e}`,buckets:24});return c.jsx(nf,{values:((n==null?void 0:n.buckets)??[]).map(r=>r.total),width:120,height:20})}function Sae({state:e,value:t}){const n=e==="failed"&&t>0;return c.jsxs("span",{className:`flex items-baseline gap-1 rounded px-1.5 py-0.5 ${n?"bg-red-500/10":"bg-zinc-800/60"}`,title:`${t} ${e}`,children:[c.jsx("span",{className:"text-[9px] uppercase tracking-wide text-zinc-500",children:e.slice(0,4)}),c.jsx("span",{className:`tabular-nums ${t>0?zk[e]:"text-zinc-600"}`,children:t})]})}function Oae({summary:e,active:t,onSelect:n}){return c.jsxs("button",{type:"button",onClick:()=>n(e.driver,e.queue),className:`w-full rounded-lg border px-3 py-2.5 text-left transition-colors ${t?"border-emerald-500/40 bg-emerald-500/5":"border-zinc-800 bg-zinc-900/40 hover:border-zinc-700 hover:bg-zinc-900"}`,children:[c.jsxs("div",{className:"flex items-center justify-between gap-2",children:[c.jsx("span",{className:"min-w-0 truncate font-medium text-zinc-100",children:e.queue}),e.isPaused&&c.jsx("span",{className:"shrink-0 rounded bg-violet-500/15 px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-violet-300",children:"paused"})]}),c.jsx("div",{className:"mt-0.5 text-[10px] uppercase tracking-wide text-zinc-600",children:e.driver}),c.jsx("div",{className:"mt-2 flex flex-wrap gap-1 text-[10px]",children:Ik.map(r=>c.jsx(Sae,{state:r,value:e.counts[r]},r))})]})}function Pae({selected:e,onSelect:t}){const{data:n,isLoading:r,isError:i}=A_();if(r)return c.jsx("p",{className:"px-1 py-2 text-xs text-zinc-600",children:"Loading queues…"});if(i)return c.jsx("p",{className:"px-1 py-2 text-xs text-red-400",children:"Failed to load queues."});const a=(n==null?void 0:n.queues)??[];return a.length===0?c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-3 py-6 text-center text-xs text-zinc-600",children:"No live queues detected."}):c.jsx("div",{className:"space-y-2",children:a.map(o=>c.jsx(Oae,{summary:o,active:(e==null?void 0:e.driver)===o.driver&&(e==null?void 0:e.queue)===o.queue,onSelect:t},`${o.driver}:${o.queue}`))})}function Aae({counts:e,state:t,onState:n}){return c.jsx("div",{className:"flex flex-wrap gap-1 border-b border-zinc-800 pb-2",children:Ik.map(r=>{const i=r===t,a=(e==null?void 0:e[r])??0;return c.jsxs("button",{type:"button",onClick:()=>n(r),className:`flex items-baseline gap-1.5 rounded-md px-2.5 py-1 text-xs transition-colors ${i?"bg-zinc-800 text-zinc-100":"text-zinc-500 hover:bg-zinc-900 hover:text-zinc-300"}`,children:[c.jsx("span",{className:"capitalize",children:r}),c.jsx("span",{className:`tabular-nums text-[11px] ${i?zk[r]:"text-zinc-600"}`,children:a})]},r)})})}const fO=25;function _ae(e){return e.maxAttempts!=null?`${e.attemptsMade}/${e.maxAttempts}`:`${e.attemptsMade}`}function Eae({job:e,onOpen:t}){return c.jsxs("tr",{onClick:()=>t(e.id),onKeyDown:n=>{(n.key==="Enter"||n.key===" ")&&t(e.id)},className:"cursor-pointer border-t border-zinc-900 align-top hover:bg-zinc-900",children:[c.jsx("td",{className:"py-1.5 pr-2 font-mono text-[11px] text-zinc-500",children:e.id}),c.jsx("td",{className:"pr-2 text-emerald-400",children:e.name||"—"}),c.jsx("td",{className:"pr-2 tabular-nums text-zinc-400",children:_ae(e)}),c.jsx("td",{className:"pr-2 whitespace-nowrap text-zinc-500",children:Ha(e.timestamp)}),c.jsx("td",{className:"max-w-xs truncate pr-2 text-zinc-400",children:e.failedReason?c.jsx("span",{className:"text-red-400",children:e.failedReason}):c.jsx("span",{className:"text-zinc-600",children:"open to inspect payload →"})})]})}function $ae(e,t){const n=new Map;for(const r of e)n.set(r.id,r);for(const r of t)n.set(r.id,r);return[...n.values()]}function Nae({driver:e,queue:t,state:n,onOpen:r}){const[i,a]=A.useState(void 0),[o,s]=A.useState([]),l=`${e}\0${t}\0${n}`,u=A.useRef(l);u.current!==l&&(u.current=l,i!==void 0&&a(void 0),o.length>0&&s([]));const{data:d,isLoading:f,isError:p}=II(e,t,n,i!==void 0?{cursor:i,limit:fO}:{limit:fO}),h=(d==null?void 0:d.nextCursor)??null,g=d==null?void 0:d.jobs;return A.useEffect(()=>{g&&s(i===void 0?y=>kae(y,g):y=>$ae(y,g))},[g,i]),f&&o.length===0?c.jsx("p",{className:"px-1 py-3 text-xs text-zinc-600",children:"Loading jobs…"}):p&&o.length===0?c.jsx("p",{className:"px-1 py-3 text-xs text-red-400",children:"Failed to load jobs."}):o.length===0?c.jsxs("div",{className:"rounded-lg border border-dashed border-zinc-800 px-3 py-8 text-center text-xs text-zinc-600",children:["No ",c.jsx("span",{className:"text-zinc-400",children:n})," jobs."]}):c.jsxs("div",{className:"space-y-3",children:[c.jsxs("table",{className:"w-full text-left text-xs",children:[c.jsx("thead",{className:"text-zinc-500",children:c.jsxs("tr",{children:[c.jsx("th",{className:"py-1.5 pr-2 font-normal",children:"ID"}),c.jsx("th",{className:"pr-2 font-normal",children:"Name"}),c.jsx("th",{className:"pr-2 font-normal",children:"Attempts"}),c.jsx("th",{className:"pr-2 font-normal",children:"Age"}),c.jsx("th",{className:"pr-2 font-normal",children:"Reason / Payload"})]})}),c.jsx("tbody",{children:o.map(y=>c.jsx(Eae,{job:y,onOpen:r},y.id))})]}),h!=null&&c.jsx("button",{type:"button",onClick:()=>a(h),className:"w-full rounded-md border border-zinc-800 py-1.5 text-[11px] text-zinc-400 transition-colors hover:border-zinc-700 hover:text-zinc-200",children:"Load more"})]})}function kae(e,t){const n=new Set(t.map(i=>i.id)),r=e.filter(i=>!n.has(i.id));return[...t,...r]}function Zp(e,t,n){return e!=null&&e.mutationsEnabled?(e.actionsByDriver[t]??[]).includes(n):!1}function Tae(e,t){switch(e){case"promote":return t==="delayed";case"retry":return t==="failed"||t==="completed";case"remove":return!0;default:return!1}}function gx(e){return e instanceof Error&&/\b403\b/.test(e.message)}const Cae={retry:"border-emerald-500/40 text-emerald-300 hover:bg-emerald-500/10",promote:"border-amber-500/40 text-amber-300 hover:bg-amber-500/10",remove:"border-red-500/40 text-red-300 hover:bg-red-500/10"};function Mae({driver:e,queue:t,id:n,action:r,onDone:i}){const a=RI(),[o,s]=A.useState(!1),l=a.isPending,u=gx(a.error);async function d(){s(!1);try{await a.mutateAsync({driver:e,queue:t,id:n,action:r}),i==null||i()}catch{}}return r==="remove"&&o?c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx("button",{type:"button",disabled:l,onClick:d,className:"rounded border border-red-500/50 bg-red-500/10 px-2 py-1 text-[11px] text-red-200 disabled:opacity-50",children:l?"Removing…":"Confirm remove"}),c.jsx("button",{type:"button",onClick:()=>s(!1),className:"rounded border border-zinc-700 px-2 py-1 text-[11px] text-zinc-400 hover:text-zinc-200",children:"Cancel"})]}):c.jsxs("span",{className:"inline-flex flex-col",children:[c.jsx("button",{type:"button",disabled:l,onClick:r==="remove"?()=>s(!0):d,className:`rounded border px-2 py-1 text-[11px] capitalize transition-colors disabled:opacity-50 ${Cae[r]}`,children:l?`${r}…`:r}),u&&c.jsx("span",{className:"mt-0.5 text-[10px] text-red-400",children:"Not authorized"})]})}function Iae({capabilities:e,driver:t,queue:n,id:r,state:i,onDone:a}){const o=["retry","promote","remove"].filter(s=>Zp(e,t,s)&&Tae(s,i));return o.length===0?null:c.jsx("div",{className:"flex flex-wrap items-start gap-1.5",children:o.map(s=>c.jsx(Mae,{driver:t,queue:n,id:r,action:s,onDone:a},s))})}function zae({capabilities:e,driver:t,queue:n}){const r=__();if(!Zp(e,t,"retry-all"))return null;const i=gx(r.error);async function a(){try{await r.mutateAsync({driver:t,queue:n,action:"retry-all",state:"failed"})}catch{}}return c.jsxs("span",{className:"inline-flex items-center gap-2",children:[c.jsx("button",{type:"button",disabled:r.isPending,onClick:a,className:"rounded border border-emerald-500/40 px-2.5 py-1 text-[11px] text-emerald-300 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",children:r.isPending?"Retrying all…":"Retry all failed"}),i&&c.jsx("span",{className:"text-[10px] text-red-400",children:"Not authorized"})]})}function Rae({capabilities:e,driver:t,queue:n}){const r=__(),[i,a]=A.useState(!1);if(!Zp(e,t,"redrive"))return null;const o=gx(r.error);async function s(){a(!1);try{await r.mutateAsync({driver:t,queue:n,action:"redrive"})}catch{}}return i?c.jsxs("span",{className:"inline-flex items-center gap-1",children:[c.jsx("button",{type:"button",disabled:r.isPending,onClick:s,className:"rounded border border-amber-500/50 bg-amber-500/10 px-2.5 py-1 text-[11px] text-amber-200 disabled:opacity-50",children:r.isPending?"Redriving…":"Confirm redrive"}),c.jsx("button",{type:"button",onClick:()=>a(!1),className:"rounded border border-zinc-700 px-2 py-1 text-[11px] text-zinc-400 hover:text-zinc-200",children:"Cancel"})]}):c.jsxs("span",{className:"inline-flex items-center gap-2",children:[c.jsx("button",{type:"button",disabled:r.isPending,onClick:()=>a(!0),className:"rounded border border-amber-500/40 px-2.5 py-1 text-[11px] text-amber-300 transition-colors hover:bg-amber-500/10 disabled:opacity-50",children:"Redrive DLQ"}),o&&c.jsx("span",{className:"text-[10px] text-red-400",children:"Not authorized"})]})}function Dae(e){if(e===void 0)return"—";try{return JSON.stringify(e,null,2)}catch{return String(e)}}function sm({label:e,value:t}){return c.jsxs("section",{children:[c.jsx("h4",{className:"mb-1 text-[10px] uppercase tracking-wide text-zinc-500",children:e}),c.jsx("pre",{className:"overflow-auto rounded bg-zinc-950 p-2.5 text-[11px] leading-relaxed text-zinc-300 ring-1 ring-zinc-800",children:Dae(t)})]})}function al({label:e,value:t}){return c.jsxs("div",{className:"flex items-baseline justify-between gap-3 border-t border-zinc-900 py-1 first:border-0",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:e}),c.jsx("span",{className:"tabular-nums text-zinc-300",children:t})]})}function lm(e){return e==null?"—":`${new Date(e).toLocaleString()} (${Ha(e)})`}function Lae({detail:e,capabilities:t,driver:n,queue:r,state:i,onClose:a}){return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("header",{className:"space-y-1",children:[c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("span",{className:"text-sm font-medium text-emerald-400",children:e.name||"job"}),c.jsx("span",{className:"rounded bg-zinc-800 px-1.5 py-0.5 text-[10px] capitalize text-zinc-300",children:e.state})]}),c.jsx("div",{className:"font-mono text-[11px] text-zinc-500",children:e.id})]}),c.jsx(Iae,{capabilities:t,driver:n,queue:r,id:e.id,state:i,onDone:a}),c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 px-3 py-2 text-xs",children:[c.jsx(al,{label:"Attempts",value:e.maxAttempts!=null?`${e.attemptsMade}/${e.maxAttempts}`:`${e.attemptsMade}`}),c.jsx(al,{label:"Progress",value:e.progress!=null?`${e.progress}`:"—"}),c.jsx(al,{label:"Created",value:lm(e.timestamp)}),c.jsx(al,{label:"Processed",value:lm(e.processedOn)}),c.jsx(al,{label:"Finished",value:lm(e.finishedOn)})]}),e.failedReason&&c.jsxs("section",{children:[c.jsx("h4",{className:"mb-1 text-[10px] uppercase tracking-wide text-red-400",children:"Failed reason"}),c.jsx("p",{className:"rounded bg-red-500/5 px-2.5 py-2 text-[11px] text-red-300 ring-1 ring-red-500/20",children:e.failedReason})]}),c.jsx(sm,{label:"Payload (data)",value:e.data}),c.jsx(sm,{label:"Options (opts)",value:e.opts}),e.returnValue!==void 0&&e.returnValue!==null&&c.jsx(sm,{label:"Return value",value:e.returnValue}),e.stacktrace&&e.stacktrace.length>0&&c.jsxs("section",{children:[c.jsx("h4",{className:"mb-1 text-[10px] uppercase tracking-wide text-zinc-500",children:"Stacktrace"}),c.jsx("pre",{className:"overflow-auto rounded bg-zinc-950 p-2.5 text-[11px] leading-relaxed text-red-300/80 ring-1 ring-zinc-800",children:e.stacktrace.join(`
143
- `)})]})]})}function Bae({driver:e,queue:t,jobId:n,state:r,capabilities:i,onClose:a}){const{data:o,isLoading:s,isError:l}=zI(e,t,n);return A.useEffect(()=>{function u(d){d.key==="Escape"&&a()}return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a]),c.jsxs("div",{className:"fixed inset-0 z-40 flex justify-end",children:[c.jsx("button",{type:"button","aria-label":"Close job detail",onClick:a,className:"absolute inset-0 bg-black/50"}),c.jsxs("aside",{className:"relative z-10 flex h-full w-full max-w-md flex-col border-l border-zinc-800 bg-zinc-950 shadow-2xl",children:[c.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-2.5",children:[c.jsx("span",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Job detail"}),c.jsx("button",{type:"button",onClick:a,className:"rounded px-2 py-0.5 text-zinc-500 hover:bg-zinc-900 hover:text-zinc-200",children:"✕"})]}),c.jsx("div",{className:"flex-1 overflow-auto p-4",children:s?c.jsx("p",{className:"text-xs text-zinc-600",children:"Loading job…"}):l?c.jsx("p",{className:"text-xs text-red-400",children:"Failed to load job."}):o?c.jsx(Lae,{detail:o,capabilities:i,driver:e,queue:t,state:r,onClose:a}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Job not found (it may have been removed)."})})]})]})}function Fae(e){return e instanceof Error&&/\b403\b/.test(e.message)}function Uae(e){const t=e.trim();if(t==="")return{ok:!1,message:"Payload is required."};try{return{ok:!0,value:JSON.parse(t)}}catch{return{ok:!1,message:"Payload must be valid JSON."}}}function Wae({capabilities:e,driver:t,queue:n}){const r=DI(),[i,a]=A.useState(""),[o,s]=A.useState(""),[l,u]=A.useState(null),[d,f]=A.useState(void 0);if(!Zp(e,t,"enqueue"))return null;const p=Fae(r.error);async function h(g){g.preventDefault(),f(void 0);const y=Uae(o);if(!y.ok){u(y.message);return}u(null);try{const b=await r.mutateAsync({driver:t,queue:n,...i.trim()!==""?{name:i.trim()}:{},payload:y.value});f(b.id),s("")}catch{}}return c.jsxs("form",{onSubmit:h,className:"space-y-2 rounded-lg border border-zinc-800 p-3",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Send message"}),c.jsx("input",{type:"text",value:i,onChange:g=>a(g.target.value),placeholder:"Job name (optional)","aria-label":"Job name",className:"w-full rounded border border-zinc-800 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 placeholder:text-zinc-600"}),c.jsx("textarea",{value:o,onChange:g=>s(g.target.value),placeholder:'{"to": "a@b.c"}',"aria-label":"Payload (JSON)",rows:4,className:"w-full rounded border border-zinc-800 bg-zinc-950 px-2 py-1 font-mono text-xs text-zinc-200 placeholder:text-zinc-600"}),l&&c.jsx("p",{className:"text-[10px] text-red-400",children:l}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"submit",disabled:r.isPending,className:"rounded border border-emerald-500/40 px-2.5 py-1 text-[11px] text-emerald-300 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",children:r.isPending?"Sending…":"Send message"}),p&&c.jsx("span",{className:"text-[10px] text-red-400",children:"Not authorized"}),d!==void 0&&!p&&c.jsx("span",{className:"text-[10px] text-emerald-400",children:d?`Enqueued job ${d}`:"Message enqueued"})]})]})}const xx=A.createContext(null);function qae(e){return e instanceof Error&&/ 401$/.test(e.message)}function Hae({children:e}){const t=ce(),n=zr(),[r,i]=A.useState("loading"),[a,o]=A.useState([]),s=A.useRef(!1),l=A.useMemo(()=>{async function u(){const f=await t.auth.me();if(f.status==="authenticated"){s.current=!0,i("app");return}if(f.status==="unauthenticated"){s.current=!0,o(f.modes),i("screen");return}s.current=!1,i("disabled")}async function d(){await t.auth.logout(),await u()}return{phase:r,modes:a,refresh:u,logout:d}},[t,r,a]);return A.useEffect(()=>{let u=!1;return t.auth.me().then(d=>{u||(d.status==="authenticated"?(s.current=!0,i("app")):d.status==="unauthenticated"?(s.current=!0,o(d.modes),i("screen")):(s.current=!1,i("disabled")))}),()=>{u=!0}},[t]),A.useEffect(()=>n.getQueryCache().subscribe(d=>{d.type==="updated"&&d.query.state.status==="error"&&s.current&&qae(d.query.state.error)&&l.refresh()}),[n,l]),c.jsx(xx.Provider,{value:l,children:e})}function bx(){const e=A.useContext(xx);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function Kae(){return A.useContext(xx)}function Vae({children:e}){return c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-zinc-950 px-4 font-mono text-sm text-zinc-200",children:c.jsxs("div",{className:"w-full max-w-sm rounded-lg border border-zinc-800 bg-zinc-900 p-8 shadow-2xl",children:[c.jsx("div",{className:"mb-6 text-center text-lg font-semibold text-emerald-400",children:"Telescope"}),e]})})}function Gae(){const e=ce(),{refresh:t}=bx(),[n,r]=A.useState(""),[i,a]=A.useState(""),[o,s]=A.useState(null),[l,u]=A.useState(!1);async function d(f){f.preventDefault(),u(!0),s(null);try{const p=await e.auth.login(n,i);if(p.ok){await t();return}s(p.message)}finally{u(!1)}}return c.jsxs("form",{onSubmit:d,className:"flex flex-col gap-4",children:[c.jsxs("label",{className:"flex flex-col gap-1.5",children:[c.jsx("span",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Username"}),c.jsx("input",{type:"text",name:"username",autoComplete:"username",value:n,onChange:f=>r(f.target.value),className:"rounded border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-emerald-500/60"})]}),c.jsxs("label",{className:"flex flex-col gap-1.5",children:[c.jsx("span",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Password"}),c.jsx("input",{type:"password",name:"password",autoComplete:"current-password",value:i,onChange:f=>a(f.target.value),className:"rounded border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-emerald-500/60"})]}),o!==null?c.jsx("p",{role:"alert",className:"text-xs text-rose-400",children:o}):null,c.jsx("button",{type:"submit",disabled:l,className:"mt-2 rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-xs font-medium uppercase tracking-wide text-emerald-300 transition-colors hover:bg-emerald-500/20 disabled:cursor-not-allowed disabled:opacity-50",children:l?"Signing in…":"Sign in"})]})}function Qae(){const{refresh:e}=bx(),[t,n]=A.useState(!1);async function r(){n(!0);try{await e()}finally{n(!1)}}return c.jsxs("div",{className:"flex flex-col gap-4 text-center",children:[c.jsx("p",{className:"text-sm font-medium text-zinc-200",children:"Open Telescope from your application"}),c.jsx("p",{className:"text-xs leading-relaxed text-zinc-500",children:"Your session is minted by the host app. Use its “Open Telescope” action to sign in, then come back here."}),c.jsx("button",{type:"button",onClick:r,disabled:t,className:"mt-2 rounded border border-zinc-700 px-3 py-2 text-xs font-medium uppercase tracking-wide text-zinc-300 transition-colors hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-50",children:t?"Checking…":"Retry"})]})}function Xae({modes:e}){const t=e.includes("login");return c.jsx(Vae,{children:t?c.jsx(Gae,{}):c.jsx(Qae,{})})}const Yae=[{id:"page-overview",label:"Overview",to:"/"},{id:"page-entries",label:"Entries",to:"/entries"},{id:"page-pulse",label:"Pulse",to:"/pulse"},{id:"page-queues",label:"Queues",to:"/queues"},{id:"page-metrics",label:"Queue Metrics",to:"/queues/metrics"},{id:"page-schedules",label:"Schedules",to:"/schedules"},{id:"page-traces",label:"Traces",to:"/traces"}],Jae=[...Yae,...Ql.map(e=>({id:`entry-${e.id}`,label:e.label,to:`/entries/${e.id}`}))];function Zae(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.label.toLowerCase().includes(n)):e}function eoe(){const[e,t]=A.useState(!1);return A.useEffect(()=>{function n(r){(r.metaKey||r.ctrlKey)&&r.key.toLowerCase()==="k"&&(r.preventDefault(),t(i=>!i))}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),{open:e,setOpen:t}}function toe({open:e,onClose:t}){const n=ir(),r=A.useRef(null),[i,a]=A.useState(""),[o,s]=A.useState(0),l=A.useId(),u=A.useMemo(()=>Zae(Jae,i),[i]);A.useEffect(()=>{var h;e&&(a(""),s(0),(h=r.current)==null||h.focus())},[e]),A.useEffect(()=>{s(h=>u.length===0?0:Math.min(h,u.length-1))},[u.length]);const d=A.useCallback(h=>{h&&(n(h.to),t())},[n,t]);if(!e)return null;function f(h){if(h.key==="Escape"){h.preventDefault(),t();return}u.length!==0&&(h.key==="ArrowDown"?(h.preventDefault(),s(g=>(g+1)%u.length)):h.key==="ArrowUp"?(h.preventDefault(),s(g=>(g-1+u.length)%u.length)):h.key==="Enter"&&(h.preventDefault(),d(u[o])))}const p=u[o]?`${l}-${u[o].id}`:void 0;return c.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/60 pt-[12vh]",onClick:t,children:c.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Command palette",className:"w-full max-w-lg overflow-hidden rounded-lg border border-zinc-700 bg-zinc-900 shadow-2xl",onClick:h=>h.stopPropagation(),onKeyDown:f,children:[c.jsx("input",{ref:r,type:"text",value:i,onChange:h=>a(h.target.value),placeholder:"Jump to…","aria-label":"Search actions","aria-controls":l,"aria-activedescendant":p,className:"w-full border-b border-zinc-800 bg-transparent px-4 py-3 text-sm text-zinc-100 outline-none placeholder:text-zinc-500"}),c.jsx("ul",{id:l,role:"listbox",className:"max-h-72 overflow-y-auto py-1",children:u.length===0?c.jsx("li",{className:"px-4 py-3 text-xs text-zinc-500",children:"No matching actions"}):u.map((h,g)=>c.jsx("li",{id:`${l}-${h.id}`,role:"option","aria-selected":g===o,onMouseEnter:()=>s(g),onMouseDown:y=>{y.preventDefault(),d(h)},className:`cursor-pointer px-4 py-2 text-sm ${g===o?"bg-zinc-800 text-emerald-300":"text-zinc-300"}`,children:h.label},h.id))})]})})}const Rk="telescope-theme",um="dark",Dk=A.createContext(null);function dO(){if(typeof window>"u"||!window.localStorage)return um;try{const e=window.localStorage.getItem(Rk);return e==="light"||e==="dark"?e:um}catch{return um}}function noe(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(Rk,e)}catch{}}function roe({children:e}){const[t,n]=A.useState(dO),r=A.useCallback(()=>{n(a=>{const o=a==="dark"?"light":"dark";return noe(o),o})},[]);A.useEffect(()=>{n(dO())},[]);const i=A.useMemo(()=>({theme:t,toggleTheme:r}),[t,r]);return c.jsx(Dk.Provider,{value:i,children:c.jsx("div",{className:t,"data-theme":t,"data-testid":"telescope-root",children:e})})}function ioe(){const e=A.useContext(Dk);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}const aoe=[{to:"/",label:"Overview",end:!0},{to:"/entries",label:"Entries",end:!0},{to:"/traces",label:"Traces",end:!0},{to:"/pulse",label:"Pulse",end:!1},{to:"/queues",label:"Queues",end:!1},{to:"/schedules",label:"Schedules",end:!1},{to:"/prunes",label:"Prunes",end:!1},{to:"/exports",label:"Exports",end:!1},{to:"/profiles",label:"Profiles",end:!1}];function ooe(e,t,n){return e.filter(r=>!(r.to==="/traces"&&t===!1||r.to==="/profiles"&&n!==!0))}function pO({isActive:e}){return`block rounded px-3 py-1.5 text-xs uppercase tracking-wide ${e?"bg-zinc-900 text-emerald-300":"text-zinc-500 hover:bg-zinc-900 hover:text-zinc-300"}`}function soe({isActive:e}){return`flex items-center gap-2 rounded px-3 py-1.5 text-xs ${e?"bg-zinc-900 text-zinc-100":"text-zinc-500 hover:bg-zinc-900 hover:text-zinc-300"}`}function loe(){const{paused:e,setPaused:t}=S_();return c.jsxs("button",{type:"button",onClick:()=>t(!e),"aria-pressed":e,title:e?"Resume live tail":"Pause live tail",className:`flex items-center gap-1.5 rounded border px-2.5 py-1 text-xs font-medium uppercase tracking-wide transition-colors ${e?"border-amber-500/40 bg-amber-500/10 text-amber-300 hover:bg-amber-500/20":"border-emerald-500/40 bg-emerald-500/10 text-emerald-300 hover:bg-emerald-500/20"}`,children:[c.jsx("span",{"aria-hidden":"true",children:e?"⏸":"●"}),e?"Paused":"Live"]})}function uoe(){const{theme:e,toggleTheme:t}=ioe(),n=e==="dark";return c.jsxs("button",{type:"button",onClick:t,"aria-pressed":!n,title:n?"Switch to light theme":"Switch to dark theme",className:"flex items-center gap-1.5 rounded border border-zinc-700 px-2.5 py-1 text-xs font-medium text-zinc-300 transition-colors hover:bg-zinc-800",children:[c.jsx("span",{"aria-hidden":"true",children:n?"☾":"☀"}),n?"Dark":"Light"]})}function coe({onClick:e}){return c.jsx("button",{type:"button",onClick:e,title:"Open command palette","aria-keyshortcuts":"Meta+K Control+K",className:"flex items-center gap-1.5 rounded border border-zinc-700 px-2.5 py-1 text-xs font-medium text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-zinc-200",children:c.jsx("span",{"aria-hidden":"true",children:"⌘K"})})}function foe(){const e=Kae(),[t,n]=A.useState(!1);if(e===null||e.phase!=="app")return null;async function r(){if(e!==null){n(!0);try{await e.logout()}finally{n(!1)}}}return c.jsxs("button",{type:"button",onClick:r,disabled:t,title:"Sign out",className:"flex items-center gap-1.5 rounded border border-zinc-700 px-2.5 py-1 text-xs font-medium text-zinc-300 transition-colors hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-50",children:[c.jsx("span",{"aria-hidden":"true",children:"⎋"}),"Sign out"]})}function doe({children:e}){var o,s,l,u,d,f;const{open:t,setOpen:n}=eoe(),r=La(),i=dz(fz((o=r.data)==null?void 0:o.entryTypes),(s=r.data)==null?void 0:s.watchers),a=ooe(aoe,(l=r.data)==null?void 0:l.tracesEnabled,(d=(u=r.data)==null?void 0:u.profiling)==null?void 0:d.enabled);return c.jsxs("div",{className:"flex min-h-screen bg-zinc-950 font-mono text-sm text-zinc-200",children:[c.jsx(toe,{open:t,onClose:()=>n(!1)}),c.jsxs("aside",{className:"flex w-56 shrink-0 flex-col gap-6 border-r border-zinc-800 px-3 py-4",children:[c.jsx("span",{className:"px-3 text-base font-semibold text-emerald-400",children:"Telescope"}),c.jsxs("nav",{className:"flex flex-col gap-1",children:[a.map(p=>c.jsx(Zc,{to:p.to,end:p.end,className:pO,children:p.label},p.to)),(((f=r.data)==null?void 0:f.dashboards)??[]).map(p=>c.jsx(Zc,{to:`/ext/${p.id}`,className:pO,children:p.label},p.id))]}),c.jsxs("nav",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:"px-3 pb-1 text-[10px] uppercase tracking-wider text-zinc-600",children:"Watchers"}),i.map(p=>c.jsxs(Zc,{to:`/entries/${p.id}`,className:soe,children:[c.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${p.dot}`,"aria-hidden":"true"}),p.label]},p.id))]})]}),c.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c.jsxs("header",{className:"flex items-center justify-end gap-4 border-b border-zinc-800 px-4 py-2",children:[c.jsx(uR,{}),c.jsx(coe,{onClick:()=>n(!0)}),c.jsx(uoe,{}),c.jsx(loe,{}),c.jsx(foe,{})]}),c.jsx("main",{className:"min-w-0 flex-1",children:e})]})]})}function poe(e,t){if(e===void 0||!t)return null;const n=t.direction==="up-bad";return(n?e>=t.bad:e<=t.bad)?"bad":(n?e>=t.warn:e<=t.warn)?"warn":"ok"}const hoe={ok:"#34d399",warn:"#fbbf24",bad:"#f87171"};function moe({points:e}){if(e.length<2)return null;const t=Math.max(...e),n=Math.min(...e),r=t-n||1,i=e.map((a,o)=>{const s=o/(e.length-1)*100,l=20-(a-n)/r*18-1;return`${o===0?"M":"L"}${s.toFixed(1)},${l.toFixed(1)}`}).join(" ");return c.jsxs("svg",{className:"mt-2",width:"100%",height:"22",viewBox:"0 0 100 22",preserveAspectRatio:"none",children:[c.jsx("title",{children:"Trend sparkline"}),c.jsx("path",{d:i,fill:"none",stroke:"#52525b",strokeWidth:"1.5"})]})}function ze({label:e,value:t,delta:n,deltaLabel:r,spark:i,thresholds:a,currentValue:o,accent:s="text-zinc-100",hint:l}){const u=poe(o,a),d=n===void 0||!a?null:a.direction==="up-bad"?n<0:n>0,f=d===null?"#a1a1aa":d?"#34d399":"#f87171",p=n===void 0?"":n>0?"▲":n<0?"▼":"◆";return c.jsxs("div",{"data-health":u??void 0,className:"rounded-lg border border-zinc-800 bg-zinc-900/40 px-4 py-3 overflow-hidden",children:[u&&c.jsx("div",{style:{height:3,background:hoe[u],margin:"-12px -16px 9px"}}),c.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:e}),c.jsxs("p",{className:`mt-1 text-2xl font-semibold tabular-nums ${s} flex items-baseline gap-2`,children:[t,n!==void 0&&c.jsxs("span",{className:"text-xs font-semibold",style:{color:f},children:[p," ",r??Math.abs(n)]})]}),i&&c.jsx(moe,{points:i}),l&&c.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:l})]})}function voe(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:`${i}m ${t%60}s`}function yoe({stats:e}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Server"}),e?c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5",children:[c.jsx(ze,{label:"Uptime",value:voe(e.uptimeSec),accent:"text-emerald-400"}),c.jsx(ze,{label:"RSS",value:`${e.memory.rssMb} MB`,hint:`heap ${e.memory.heapUsedMb}/${e.memory.heapTotalMb} MB`}),c.jsx(ze,{label:"Heap used",value:`${e.memory.heapUsedMb} MB`,accent:"text-sky-400"}),c.jsx(ze,{label:"CPU",value:`${Math.round(e.cpu.userMs)} ms`,accent:"text-violet-400",hint:`sys ${Math.round(e.cpu.systemMs)} ms`}),c.jsx(ze,{label:"Event loop",value:e.eventLoopDelayMs===null?"n/a":`${e.eventLoopDelayMs} ms`,accent:e.eventLoopDelayMs!==null&&e.eventLoopDelayMs>100?"text-red-400":"text-zinc-100",hint:`instance ${e.instanceId}`})]}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Loading…"})]})}function goe(e){return`${(Math.max(0,e)/1e3).toFixed(1)} µs`}function hO(e){return e===null?"n/a":`${e.toFixed(1)} ms`}function xoe({health:e}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3",children:[c.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Telescope health"}),c.jsx("span",{className:"text-[10px] text-zinc-600",children:"Captures run off the response path — your requests don't wait on Telescope."})]}),e?c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6",children:[c.jsx(ze,{label:"Capture cost",value:`${goe(e.captureCostNanos)}/capture`,accent:"text-emerald-400",hint:"micro-benchmark"}),c.jsx(ze,{label:"Buffer",value:`${e.bufferUsed} / ${e.bufferSize}`,accent:"text-sky-400",hint:`high-water ${e.bufferHighWater}`}),c.jsx(ze,{label:"Last flush",value:hO(e.lastFlushMs),hint:`max ${hO(e.maxFlushMs)}`}),c.jsx(ze,{label:"Flushes",value:e.flushes.toLocaleString(),accent:"text-violet-400",hint:`${e.flushedEntries.toLocaleString()} entries`}),c.jsx(ze,{label:"Dropped",value:e.droppedCount.toLocaleString(),accent:e.droppedCount>0?"text-red-400":"text-emerald-400",hint:e.droppedCount>0?`overflow ${e.overflowDropped} · store ${e.storeFailedDropped}`:"keeping up"}),c.jsx(ze,{label:"Truncated",value:e.truncatedCount.toLocaleString(),accent:e.truncatedCount>0?"text-amber-400":"text-emerald-400",hint:e.truncatedCount>0?"fat content — tune redact/sampling":"within bounds"})]}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Loading…"})]})}function boe({retention:e,pruneEnabled:t}){const n=E_(),r=e==null?void 0:e.retention;async function i(){if(globalThis.confirm("Prune now deletes entries older than the retention window. Continue?"))try{const a=await n.mutateAsync();globalThis.alert(`Pruned ${a.pruned} ${a.pruned===1?"entry":"entries"}.`)}catch{globalThis.alert("Prune failed.")}}return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3",children:[c.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Retention"}),t?c.jsx("button",{type:"button",onClick:i,disabled:n.isPending,className:"rounded border border-zinc-700 px-2 py-1 text-[11px] text-zinc-300 hover:border-emerald-500 hover:text-emerald-400 disabled:cursor-not-allowed disabled:opacity-50",children:n.isPending?"Pruning…":"Prune now"}):null]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[c.jsx(ze,{label:"Window",value:r?wl(r.afterMs):"none",accent:r?"text-emerald-400":"text-zinc-500",hint:(r==null?void 0:r.keepLast)!=null?`keep last ${r.keepLast}`:"unbounded"}),c.jsx(ze,{label:"Entries",value:(e==null?void 0:e.entryCount)!=null?e.entryCount.toLocaleString():"n/a"}),c.jsx(ze,{label:"Oldest",value:(e==null?void 0:e.oldestCreatedAt)!=null?"tracked":"n/a"})]})]})}function Lk(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function woe(e){return((e==null?void 0:e.buckets)??[]).map(t=>({label:Lk(t.t),value:t.total}))}function Bk(e){const t=yx((e==null?void 0:e.buckets)??[]);return((e==null?void 0:e.buckets)??[]).map(n=>{const r={label:Lk(n.t)};for(const i of t)r[i]=n.byType[i]??0;return r})}function joe(e){return Object.values(e).reduce((t,n)=>t+n,0)}function Soe(e){const t=e.request??0;return t===0?null:(e.exception??0)/t}const Ooe=.05;function Poe(e){return e===null?"n/a":`${(e*100).toFixed(1)}%`}function Aoe(e){return(e==null?void 0:e.slowRoutes.length)??0}const Zy=100;function _oe(e){return((e==null?void 0:e.queues)??[]).filter(t=>{const n=Math.max(0,t.total-t.completed-t.failed);return t.failed>0||n>=Zy})}function Eoe({pulse:e,queues:t}){const n=(e==null?void 0:e.counts)??{},r=joe(n),i=n.request??0,a=n.exception??0,o=Soe(n),s=((t==null?void 0:t.queues)??[]).reduce((u,d)=>u+d.failed,0),l=Aoe(e);return c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[c.jsx(ze,{label:"Requests",value:i.toLocaleString(),accent:"text-emerald-400",hint:`${r.toLocaleString()} entries total`}),c.jsx(ze,{label:"Error rate",value:Poe(o),accent:o!==null&&o>Ooe?"text-red-400":"text-zinc-100",hint:`${a.toLocaleString()} exceptions`}),c.jsx(ze,{label:"Failed jobs",value:s.toLocaleString(),accent:s>0?"text-red-400":"text-zinc-100",hint:"across queues"}),c.jsx(ze,{label:"Slow routes",value:l.toLocaleString(),accent:l>0?"text-amber-400":"text-zinc-100",hint:"routes over the slow p99 threshold"})]})}function mO({title:e,emptyLabel:t,children:n}){const r=Array.isArray(n)?n.length>0:!!n;return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:e}),r?c.jsx("ul",{className:"space-y-1 text-xs",children:n}):c.jsx("p",{className:"text-xs text-zinc-600",children:t})]})}function $oe({hotspots:e,onSelectFamily:t}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"N+1 query hotspots"}),e.length>0?c.jsx("ul",{className:"space-y-1 text-xs",children:e.map(n=>c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:()=>t(n.familyHash),className:"flex w-full items-center justify-between gap-3 border-t border-zinc-900 pt-1 text-left hover:text-zinc-100 first:border-0 first:pt-0",children:[c.jsxs("span",{className:"min-w-0 truncate",children:[c.jsxs("span",{className:"whitespace-nowrap text-amber-400",children:["×",n.perRequest]})," ",c.jsx("span",{className:"text-zinc-400",children:n.sql})]}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:[n.requests," req · ",n.total," total",n.totalDurationMs>0?` · ${Math.round(n.totalDurationMs)}ms`:""]})]})},n.familyHash))}):c.jsx("p",{className:"text-xs text-zinc-600",children:"None detected"})]})}function Noe({queues:e,onOpenQueues:t}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3",children:[c.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Queues needing attention"}),c.jsx("button",{type:"button",onClick:t,className:"text-[11px] text-zinc-500 hover:text-emerald-400",children:"All queues →"})]}),e.length>0?c.jsx("ul",{className:"space-y-1 text-xs",children:e.map(n=>{const r=Math.max(0,n.total-n.completed-n.failed);return c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:t,className:"flex w-full items-center justify-between gap-3 border-t border-zinc-900 pt-1 text-left hover:text-zinc-100 first:border-0 first:pt-0",children:[c.jsx("span",{className:"min-w-0 truncate text-zinc-300",children:n.queue}),c.jsxs("span",{className:"shrink-0 tabular-nums",children:[n.failed>0?c.jsxs("span",{className:"text-red-400",children:[n.failed," failed"]}):null,n.failed>0&&r>=Zy?c.jsx("span",{className:"text-zinc-600",children:" · "}):null,r>=Zy?c.jsxs("span",{className:"text-amber-400",children:[r.toLocaleString()," pending"]}):null]})]})},n.queue)})}):c.jsx("p",{className:"text-xs text-emerald-400/80",children:"All queues healthy"})]})}function koe({hotspots:e}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Slowest jobs"}),e.length>0?c.jsx("ul",{className:"space-y-1 text-xs",children:e.map(t=>c.jsxs("li",{className:"flex items-center justify-between gap-3 border-t border-zinc-900 pt-1 first:border-0 first:pt-0",children:[c.jsx("span",{className:"min-w-0 truncate text-zinc-300",children:t.route}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:[c.jsxs("span",{className:"text-amber-400",children:[Math.round(t.p99),"ms"]})," p99 ·"," ",t.count,"×"]})]},t.route))}):c.jsx("p",{className:"text-xs text-zinc-600",children:"No jobs in window."})]})}function Toe({users:e,onSelectUser:t}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Load by user"}),e.length>0?c.jsx("ul",{className:"space-y-1 text-xs",children:e.map(n=>c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:()=>t(n.user),className:"flex w-full items-center justify-between gap-3 border-t border-zinc-900 pt-1 text-left hover:text-zinc-100 first:border-0 first:pt-0",children:[c.jsx("span",{className:"min-w-0 truncate text-zinc-300",children:n.user}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:[n.count," req · ",Math.round(n.totalDurationMs),"ms"]})]})},n.user))}):c.jsx("p",{className:"text-xs text-zinc-600",children:"No identified users in window."})]})}function Coe({history:e}){const t=(e==null?void 0:e.samples)??[],n=t.map(o=>o.cpuPercent),r=t.map(o=>o.rssMb),i=t.map(o=>o.heapUsedMb),a=t[t.length-1];return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Resource history"}),t.length>1?c.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"mb-1 text-[11px] text-zinc-500",children:["CPU ",a?`${a.cpuPercent}%`:""]}),c.jsx(nf,{values:n})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"mb-1 text-[11px] text-zinc-500",children:["RSS ",a?`${a.rssMb}MB`:""]}),c.jsx(nf,{values:r})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"mb-1 text-[11px] text-zinc-500",children:["Heap ",a?`${a.heapUsedMb}MB`:""]}),c.jsx(nf,{values:i})]})]}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Collecting samples…"})]})}function Moe(){var y,b,v,m,x,j,w;const[e,t]=A.useState("1h"),n=ir(),r=N_(e),i=k_(e),a=n0({window:e,buckets:60}),o=KI(),s=VI(),l=QI(),u=LI(),d=La(),f=woe(a.data),p=Bk(a.data),h=yx(((y=a.data)==null?void 0:y.buckets)??[]),g=_oe(i.data);return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"Overview"}),c.jsx(tc,{value:e,onChange:t})]}),c.jsx(Eoe,{pulse:r.data,queues:i.data}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[c.jsx(mO,{title:"Recent failures",emptyLabel:"No exceptions 🎉",children:(((b=r.data)==null?void 0:b.topExceptions)??[]).map(S=>c.jsxs("li",{className:"flex items-center justify-between gap-3 border-t border-zinc-900 pt-1 first:border-0 first:pt-0",children:[c.jsxs("span",{className:"min-w-0",children:[c.jsx("span",{className:"text-red-400",children:S.class})," ",c.jsx("span",{className:"text-zinc-400",children:S.message})]}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:["×",S.count]})]},S.familyHash))}),c.jsx($oe,{hotspots:((v=r.data)==null?void 0:v.nPlusOne)??[],onSelectFamily:S=>n(`/entries/query?familyHash=${encodeURIComponent(S)}`)})]}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[c.jsx(mO,{title:"Slowest",emptyLabel:"Nothing slow in window.",children:(((m=r.data)==null?void 0:m.slowest)??[]).map(S=>c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:()=>n(`/entries/view/${S.id}`),className:"flex w-full items-center justify-between gap-3 border-t border-zinc-900 pt-1 text-left hover:text-zinc-100 first:border-0 first:pt-0",children:[c.jsxs("span",{className:"min-w-0 truncate",children:[c.jsx("span",{className:"text-emerald-400",children:S.type})," ",c.jsx("span",{className:"text-zinc-400",children:S.label})]}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:[S.durationMs,"ms"]})]})},S.id))}),c.jsx(Noe,{queues:g,onOpenQueues:()=>n("/queues")})]}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[c.jsx(koe,{hotspots:((x=r.data)==null?void 0:x.slowJobs)??[]}),c.jsx(Toe,{users:((j=r.data)==null?void 0:j.loadByUser)??[],onSelectUser:S=>n(`/entries?tag=${encodeURIComponent(`user:${S}`)}`)})]}),c.jsx(Coe,{history:s.data}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[c.jsx(qa,{title:"Throughput",valueLabel:"entries",data:f}),c.jsx(mx,{title:"By type",series:h,data:p})]}),c.jsx(yoe,{stats:o.data}),c.jsx(xoe,{health:l.data}),c.jsx(boe,{retention:u.data,pruneEnabled:((w=d.data)==null?void 0:w.pruneEnabled)??!1})]})}function Ioe(){const{data:e}=A_(),t=(e==null?void 0:e.queues)??[],n=e==null?void 0:e.capabilities,[r,i]=A.useState(void 0),[a,o]=A.useState("waiting"),[s,l]=A.useState(null);A.useEffect(()=>{if(r||t.length===0)return;const f=t[0];f&&i({driver:f.driver,queue:f.queue})},[t,r]);const u=t.find(f=>f.driver===(r==null?void 0:r.driver)&&f.queue===(r==null?void 0:r.queue));function d(f,p){i({driver:f,queue:p}),l(null)}return c.jsxs("div",{className:"grid grid-cols-1 gap-4 p-4 lg:grid-cols-[280px_minmax(0,1fr)]",children:[c.jsxs("aside",{className:"space-y-2",children:[c.jsx("h3",{className:"px-1 text-[10px] uppercase tracking-wide text-zinc-500",children:"Live queues"}),c.jsx(Pae,{selected:r,onSelect:d})]}),c.jsx("section",{className:"min-w-0 space-y-3",children:r?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsxs("h2",{className:"truncate text-sm text-emerald-400",children:[r.queue,c.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-zinc-600",children:r.driver})]}),a==="failed"&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(zae,{capabilities:n,driver:r.driver,queue:r.queue}),c.jsx(Rae,{capabilities:n,driver:r.driver,queue:r.queue})]})]}),c.jsx(Aae,{counts:u==null?void 0:u.counts,state:a,onState:o}),c.jsx(Nae,{driver:r.driver,queue:r.queue,state:a,onOpen:l}),c.jsx(Wae,{capabilities:n,driver:r.driver,queue:r.queue})]}):c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-12 text-center text-xs text-zinc-600",children:"Select a queue to inspect its jobs."})}),r&&s&&c.jsx(Bae,{driver:r.driver,queue:r.queue,jobId:s,state:a,capabilities:n,onClose:()=>l(null)})]})}function zoe(e,t){return t.trim()!==""?`No entries match tag '${t.trim()}'`:e?`No ${sp(e)} entries`:"No entries"}function vO(){const{type:e}=ip(),t=ir(),[n]=aI(),[r,i]=A.useState(()=>n.get("tag")??""),[a,o]=A.useState(""),[s,l]=A.useState(""),[u,d]=A.useState(0),[f,p]=A.useState(0);function h(M){i(M),p(D=>D+1)}function g(M){i(M),d(D=>D+1)}const y=e&&uz(e)?e:void 0,b=r.trim(),v=xz(b)?b:"",m=v===""?b:"",x=s.trim(),j=n.get("familyHash")??"",w=j!=="",S=x!=="",O=y!==void 0||b!==""||w||S,{data:P,isLoading:_}=$_({...y?T_(y):{},...b!==""?{tag:b}:{},...w?{familyHash:j}:{},...S?{search:x}:{}}),N=(P==null?void 0:P.data)??[];function T(){l(a)}function k(){o(""),l("")}function z(){i(""),k(),t("/entries")}function I(){t(y?`/entries/${y}`:"/entries")}return c.jsxs("div",{className:"p-4",children:[y?c.jsx(mae,{type:y}):null,c.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3 border-b border-zinc-800 pb-3",children:[y?c.jsxs("button",{type:"button",onClick:()=>t("/entries"),className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{className:`h-2 w-2 rounded-full ${r0(y)}`,"aria-hidden":"true"}),sp(y),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):c.jsx("span",{className:"rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-400",children:"All types"}),c.jsx(lO,{onSelect:h},`tag-${u}`),c.jsx(lO,{prefix:gz,placeholder:"Filter by user…",ariaLabel:"Filter by user",onSelect:g},`user-${f}`),m!==""?c.jsxs("button",{type:"button",onClick:()=>i(""),className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{children:`tag:${m}`}),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):null,v!==""?c.jsxs("button",{type:"button",onClick:()=>i(""),className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{children:`User: ${i0(v)}`}),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):null,c.jsx("input",{type:"text",value:a,onChange:M=>o(M.target.value),onKeyDown:M=>{M.key==="Enter"&&T()},onBlur:T,placeholder:"Search content…","aria-label":"Search content",className:"rounded border border-zinc-800 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 placeholder:text-zinc-600 focus:border-emerald-500 focus:outline-none"}),S?c.jsxs("button",{type:"button",onClick:k,className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{children:`search:"${x}"`}),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):null,w?c.jsxs("button",{type:"button",onClick:I,className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 font-mono text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"family:"}),j.slice(0,12),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):null,O?c.jsx("button",{type:"button",onClick:z,className:"text-xs text-zinc-500 hover:text-zinc-300",children:"Clear filters"}):null]}),_?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):N.length===0?c.jsx("p",{className:"text-zinc-600",children:zoe(y,r)}):c.jsx(D_,{entries:N,onSelect:M=>t(`/entries/view/${M}`)})]})}function Roe(){const{id:e=""}=ip(),t=ir(),{data:n,isLoading:r}=HI(e);return c.jsxs("div",{className:"p-4",children:[c.jsx("button",{type:"button",onClick:()=>t("/entries"),className:"mb-4 text-xs text-zinc-500 hover:text-zinc-300",children:"← entries"}),r||!n?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):c.jsx(Uz,{entry:n,onSelect:i=>t(`/entries/view/${i}`)})]})}const Doe=200,yO=1e3,gO=1e4,xO={"15m":15*6e4,"1h":60*6e4,"6h":6*60*6e4,"24h":24*60*6e4},Lc="rounded border border-zinc-800 bg-zinc-900 px-2 py-1 text-xs text-zinc-300";function Loe(e){return e==="all"?{}:T_(e)}async function Boe(e,t,n,r,i){const a=[];let o;for(;a.length<n;){const s=Math.min(Doe,n-a.length),l=await e.entries({...t,limit:s,...o!==void 0?{cursor:o}:{}});let u=!1;for(const d of l.data){if(new Date(d.createdAt).getTime()<r){u=!0;break}if(a.push(d),a.length>=n)break}if(i(a.length),u||l.nextCursor===null)break;o=l.nextCursor}return a}function Foe({records:e}){return e.length===0?null:c.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800",children:c.jsxs("table",{className:"w-full min-w-[640px] text-left text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:[c.jsx("th",{className:"px-3 py-2 font-normal",children:"Filename"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Type"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Rows"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Format"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Time"})]})}),c.jsx("tbody",{children:e.map(t=>c.jsxs("tr",{className:"border-t border-zinc-800/60 hover:bg-zinc-900/40",children:[c.jsx("td",{className:"px-3 py-2 font-mono text-xs text-zinc-300",children:t.filename}),c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:t.type}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-100",children:t.rows.toLocaleString()}),c.jsx("td",{className:"px-3 py-2 text-xs uppercase text-zinc-400",children:t.format}),c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:new Date(t.at).toLocaleTimeString()})]},`${t.filename}:${t.at}`))})]})})}function Uoe(){const e=ce(),[t,n]=A.useState("all"),[r,i]=A.useState("1h"),[a,o]=A.useState(""),[s,l]=A.useState(yO),[u,d]=A.useState("json"),[f,p]=A.useState(!1),[h,g]=A.useState(null),[y,b]=A.useState(null),[v,m]=A.useState([]);async function x(){p(!0),b(null),g(0);const j=Math.min(Math.max(1,s),gO),w=Date.now()-(xO[r]??xO["1h"]),S={...Loe(t),...a.trim()!==""?{search:a.trim()}:{}};try{const O=await Boe(e,S,j,w,g),P=new Date().toISOString().replace(/[:.]/g,"-"),_=`telescope-export-${t}-${P}.${u}`;u==="csv"?sR(_,oR(O)):a0(_,O),m(N=>[{filename:_,type:t,rows:O.length,format:u,at:Date.now()},...N])}catch{b("Export failed while gathering entries.")}finally{p(!1)}}return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"px-1",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Export workbench"}),c.jsx("p",{className:"mt-1 text-xs text-zinc-600",children:"Page captured entries into a downloadable JSON or CSV file. Gathering runs in your browser against the live store, newest-first within the selected window."})]}),c.jsxs("div",{className:"flex flex-wrap items-end gap-3 rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsxs("label",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Type",c.jsxs("select",{value:t,onChange:j=>n(j.target.value),className:Lc,children:[c.jsx("option",{value:"all",children:"all"}),Ql.map(j=>c.jsx("option",{value:j.id,children:j.label},j.id))]})]}),c.jsxs("div",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Window",c.jsx(tc,{value:r,onChange:i})]}),c.jsxs("label",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Search",c.jsx("input",{type:"text",value:a,onChange:j=>o(j.target.value),placeholder:"content filter",className:Lc})]}),c.jsxs("label",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Limit",c.jsx("input",{type:"number",min:1,max:gO,value:s,onChange:j=>l(Number(j.target.value)||yO),className:`${Lc} w-24 tabular-nums`})]}),c.jsxs("label",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Format",c.jsxs("select",{value:u,onChange:j=>d(j.target.value==="csv"?"csv":"json"),className:Lc,children:[c.jsx("option",{value:"json",children:"JSON"}),c.jsx("option",{value:"csv",children:"CSV"})]})]}),c.jsx("button",{type:"button",onClick:x,disabled:f,className:"rounded border border-zinc-700 px-3 py-1.5 text-[11px] text-zinc-300 hover:border-emerald-500 hover:text-emerald-400 disabled:cursor-not-allowed disabled:opacity-50",children:f?"Exporting…":"Export"}),f&&h!==null&&c.jsxs("span",{className:"text-xs tabular-nums text-zinc-500",children:["gathered ",h.toLocaleString(),"…"]})]}),y&&c.jsx("p",{className:"px-1 text-xs text-red-400",children:y}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("h4",{className:"px-1 text-[10px] uppercase tracking-wide text-zinc-500",children:"Recent exports (this session)"}),v.length===0?c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-10 text-center text-xs text-zinc-600",children:"No exports yet. Pick a type, window, and format, then export."}):c.jsx(Foe,{records:v})]})]})}const bO=["#34d399","#fbbf24","#f87171","#38bdf8","#a78bfa"];function wO(e,t){return t||(bO[e%bO.length]??"#71717a")}function Woe({title:e,segments:t,style:n="donut",height:r=220}){const i=r-64;if(n==="bar"){const o=[{name:"breakdown",...Object.fromEntries(t.map(s=>[s.label,s.value]))}];return c.jsx(Aa,{title:e,height:i,children:c.jsx(Ea,{width:"100%",height:"100%",children:c.jsxs(Dd,{data:o,layout:"vertical",children:[c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa}),t.map((s,l)=>c.jsx(rr,{dataKey:s.label,stackId:"a",fill:wO(l,s.color),isAnimationActive:!1},s.label))]})})})}const a=t.map((o,s)=>({name:o.label,value:o.value,fill:wO(s,o.color)}));return c.jsx(Aa,{title:e,height:i,children:c.jsx(Ea,{width:"100%",height:"100%",children:c.jsxs(Jie,{children:[c.jsx(Fr,{data:a,dataKey:"value",nameKey:"name",innerRadius:"55%",outerRadius:"80%",isAnimationActive:!1,children:a.map(o=>c.jsx($a,{fill:o.fill},o.name))}),c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa})]})})})}function qoe(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function Hoe({title:e,buckets:t,p50:n,p95:r,p99:i,height:a=220}){const o=[];n!==void 0&&o.push([n,"p50","#34d399"]),r!==void 0&&o.push([r,"p95","#fbbf24"]),i!==void 0&&o.push([i,"p99","#f87171"]);const s=a-64;return c.jsxs(Aa,{title:e,height:s,children:[o.length>0&&c.jsx("div",{style:{display:"flex",gap:8,marginBottom:6,flexWrap:"wrap"},children:o.map(([l,u,d])=>c.jsxs("span",{style:{fontSize:10,fontVariantNumeric:"tabular-nums",color:d,background:`${d}22`,border:`1px solid ${d}55`,borderRadius:4,padding:"1px 6px"},children:[u,": ",qoe(l)]},u))}),c.jsx(Ea,{width:"100%",height:"100%",children:c.jsxs(Dd,{data:t,margin:{top:4,right:8,bottom:0,left:-16},children:[c.jsx(ms,{stroke:Te.gridStroke,vertical:!1}),c.jsx(Cr,{dataKey:"label",tick:Gn,stroke:Te.axisStroke,tickLine:!1}),c.jsx(Mr,{tick:Gn,stroke:Te.axisStroke,tickLine:!1,allowDecimals:!1,width:40}),c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa}),c.jsx(rr,{dataKey:"count",fill:"#0ea5e9",radius:[3,3,0,0],isAnimationActive:!1})]})})]})}function Koe({title:e,value:t,min:n=0,max:r=1,label:i,color:a="#34d399",height:o=220}){const s=r-n,l=s===0?0:Math.max(0,Math.min(1,(t-n)/s)),u=i??`${Math.round(l*100)}%`,d=o-64,f=[{value:l*100,fill:a}];return c.jsx(Aa,{title:e,height:d,children:c.jsxs("div",{style:{position:"relative",height:d},children:[c.jsx(Ea,{width:"100%",height:"100%",children:c.jsx(Zie,{innerRadius:"60%",outerRadius:"100%",data:f,startAngle:180,endAngle:0,barSize:16,children:c.jsx(Ju,{dataKey:"value",cornerRadius:4,isAnimationActive:!1})})}),c.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"40%"},children:c.jsx("span",{style:{fontSize:20,fontWeight:600,color:"#e4e4e7"},children:u})})]})})}function Voe(e,t){return t==="percent"?`${Math.round(e*100)}%`:t==="duration"?e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`:t==="rate"?`${new Intl.NumberFormat().format(Math.round(e))}/hr`:new Intl.NumberFormat().format(e)}function Goe(e,t){const n=e.replace(/\{(\w+)\}/g,(r,i)=>String(t[i]??""));return/^\s*(javascript|data|vbscript):/i.test(n)?"#":n}function Qoe({title:e}){return c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40",children:[c.jsx("p",{className:"border-b border-zinc-800 px-4 py-2 text-xs font-medium text-zinc-300",children:e}),c.jsx("p",{className:"px-4 py-8 text-center text-xs text-zinc-600",children:"No data in this window."})]})}function jO({columns:e,rows:t}){return c.jsxs("tbody",{children:[t.length===0?c.jsx("tr",{className:"border-t border-zinc-800/60",children:c.jsx("td",{colSpan:e.length,className:"px-4 py-6 text-center text-xs text-zinc-600",children:"No data in this window."})}):null,t.map(n=>c.jsx("tr",{className:"border-t border-zinc-800/60",children:e.map(r=>{const i=String(n[r.key]??"");return c.jsx("td",{className:"px-4 py-2 text-zinc-200",children:r.link?c.jsx("a",{className:"text-sky-400 hover:underline",href:Goe(r.link.href,n),...r.link.external?{target:"_blank",rel:"noreferrer"}:{},children:i}):i},r.key)})},e.map(r=>String(n[r.key]??"")).join("|")))]})}function SO({columns:e}){return c.jsx("thead",{children:c.jsx("tr",{children:e.map(t=>c.jsx("th",{className:"px-4 py-2 text-left text-[10px] uppercase tracking-wide text-zinc-500",children:t.label},t.key))})})}function Xoe({page:e,totalPages:t,onPageChange:n}){return c.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-zinc-500",children:[c.jsx("button",{type:"button",disabled:e<=1,onClick:()=>n==null?void 0:n(e-1),className:"rounded border border-zinc-800 px-1.5 py-0.5 text-zinc-400 hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),c.jsxs("span",{children:["Page ",e," of ",t]}),c.jsx("button",{type:"button",disabled:e>=t,onClick:()=>n==null?void 0:n(e+1),className:"rounded border border-zinc-800 px-1.5 py-0.5 text-zinc-400 hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})}function Yoe({panel:e,data:t,onPageChange:n}){switch(e.kind){case"stat":{const r=t??{};return c.jsx(ze,{label:e.title,value:Voe(r.value??0,e.format),...r.value!==void 0?{currentValue:r.value}:{},...r.delta!==void 0?{delta:r.delta}:{},...r.deltaLabel?{deltaLabel:r.deltaLabel}:{},...e.spark&&r.spark?{spark:r.spark}:{},...e.thresholds?{thresholds:e.thresholds}:{},...e.accent?{accent:e.accent}:{}})}case"distribution":{const r=t??{};return c.jsx(Hoe,{title:e.title,buckets:r.buckets??[],...r.p50!==void 0?{p50:r.p50}:{},...r.p95!==void 0?{p95:r.p95}:{},...r.p99!==void 0?{p99:r.p99}:{}})}case"gauge":{const r=t??{};return c.jsx(Koe,{title:e.title,value:r.value??0,...e.min!==void 0?{min:e.min}:{},...e.max!==void 0?{max:e.max}:{}})}case"breakdown":{const r=t??{};return c.jsx(Woe,{title:e.title,segments:r.segments??[],...e.style?{style:e.style}:{}})}case"timeseries":{const r=(t==null?void 0:t.rows)??[],i=e.series[0];return e.style==="stacked"?c.jsx(mx,{title:e.title,data:r,series:e.series}):c.jsx(qa,{title:e.title,data:r.map(a=>({label:a.label,value:i?Number(a[i]??0):0}))})}case"topN":{const r=(t==null?void 0:t.items)??[],i=e.limit?r.slice(0,e.limit):r;return i.length===0?c.jsx(Qoe,{title:e.title}):c.jsx(va,{title:e.title,data:i,horizontal:!0,truncateLabel:32})}case"table":{if(e.paged){const i=t??{},a=i.rows??[],o=i.page??1,s=i.limit??(a.length||1),l=i.total??a.length,u=Math.max(1,Math.ceil(l/s));return c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40",children:[c.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-2",children:[c.jsx("p",{className:"text-xs font-medium text-zinc-300",children:e.title}),c.jsx(Xoe,{page:o,totalPages:u,...n?{onPageChange:n}:{}})]}),c.jsxs("table",{className:"w-full text-sm",children:[c.jsx(SO,{columns:e.columns}),c.jsx(jO,{columns:e.columns,rows:a})]})]})}const r=(t==null?void 0:t.rows)??[];return c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40",children:[c.jsx("p",{className:"border-b border-zinc-800 px-4 py-2 text-xs font-medium text-zinc-300",children:e.title}),c.jsxs("table",{className:"w-full text-sm",children:[c.jsx(SO,{columns:e.columns}),c.jsx(jO,{columns:e.columns,rows:r})]})]})}default:return null}}const Joe={2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-2 lg:grid-cols-4"},Zoe=50;function ese({status:e}){const t=e==="live";return c.jsxs("span",{"data-telescope-status":e,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide ${t?"bg-emerald-950/60 text-emerald-400":"bg-amber-950/60 text-amber-400"}`,children:[c.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${t?"animate-pulse bg-emerald-400":"bg-amber-400"}`}),t?"live":e]})}function tse({ext:e,panel:t}){const n=t.kind==="table"&&t.paged===!0,[r,i]=A.useState(1),a=n?{...t.data.query,page:r,limit:Zoe}:t.data.query,o=GI(e,t.data.provider,a);return o.isError?c.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/30 px-4 py-3 text-sm text-red-300",children:['Failed to load "',t.title,'".']}):c.jsx(Yoe,{panel:t,data:o.data,...n?{onPageChange:i}:{}})}function nse(){var o,s;const{dashboardId:e}=ip(),t=La(),{status:n}=sz(),r=(s=(o=t.data)==null?void 0:o.dashboards)==null?void 0:s.find(l=>l.id===e);if(!r)return c.jsx("div",{className:"p-6 text-sm text-zinc-400",children:"Dashboard not found."});const i=(e==null?void 0:e.split(".")[0])??"",a=r.sections??[{panels:r.panels,cols:2}];return c.jsxs("div",{className:"p-4",children:[c.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[c.jsx("h2",{className:"text-sm font-semibold text-zinc-200",children:r.label}),c.jsx(ese,{status:n})]}),a.map((l,u)=>c.jsxs("section",{className:"mb-6",children:[l.title&&c.jsx("p",{className:"mb-2 text-[10px] uppercase tracking-wide text-zinc-500",children:l.title}),c.jsx("div",{className:`grid grid-cols-1 gap-3 ${Joe[l.cols??2]}`,children:l.panels.map(d=>c.jsx(tse,{ext:i,panel:d},`${d.kind}-${d.title}`))})]},l.title??`s${u}`))]})}function rse({profile:e,selected:t,onSelect:n}){return c.jsxs("button",{type:"button",onClick:n,className:`flex w-full flex-col gap-0.5 border-b border-zinc-900 px-3 py-2 text-left hover:bg-zinc-900 ${t?"bg-zinc-900":""}`,children:[c.jsx("span",{className:"truncate font-mono text-xs text-zinc-200",title:e.familyHash??e.id,children:e.familyHash??"(unlabelled)"}),c.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-zinc-500",children:[c.jsx("span",{children:e.durationMs!==null?Xl(e.durationMs):"—"}),e.tags.includes("manual")&&c.jsx("span",{className:"text-amber-400",children:"manual"}),e.tags.includes("sampled")&&c.jsx("span",{className:"text-sky-400",children:"sampled"}),c.jsx("span",{className:"ml-auto",children:Ha(new Date(e.createdAt).getTime())})]})]})}function ise({hot:e}){return e.length===0?c.jsx("p",{className:"text-xs text-zinc-600",children:"No hot frames."}):c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40",children:[c.jsxs("div",{className:"flex items-center gap-2 border-b border-zinc-800 px-3 py-1.5 text-[10px] uppercase tracking-wide text-zinc-500",children:[c.jsx("span",{className:"flex-1",children:"Function"}),c.jsx("span",{className:"w-16 text-right",children:"Self"}),c.jsx("span",{className:"w-12 text-right",children:"%"})]}),e.map(t=>c.jsxs("div",{className:"flex items-center gap-2 border-b border-zinc-900 px-3 py-1 text-[11px] last:border-0",children:[c.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-zinc-200",title:`${t.name} ${t.file}`,children:[t.name,t.file&&c.jsx("span",{className:"ml-1 text-zinc-600",children:t.file})]}),c.jsx("span",{className:"w-16 text-right tabular-nums text-zinc-300",children:Xl(t.selfMs)}),c.jsx("span",{className:"w-12 text-right tabular-nums text-amber-400",children:t.selfPct.toFixed(1)})]},`${t.name}:${t.file}`))]})}function ase({id:e}){const{data:t,isLoading:n}=az(e);if(n)return c.jsx("p",{className:"text-zinc-600",children:"Loading profile…"});if(!t)return c.jsx("p",{className:"text-zinc-600",children:"Profile not found."});const r=t.content;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1",children:[c.jsx("h3",{className:"font-mono text-sm text-zinc-100",children:r.label??"(unlabelled)"}),c.jsxs("span",{className:"text-xs text-zinc-500",children:[Xl(r.durationMs)," · ",r.sampleCount," samples · ",r.reason]})]}),c.jsx(kz,{tree:r.tree}),c.jsx(ise,{hot:r.hot})]})}function ose({pendingManual:e}){const[t,n]=A.useState(1),[r,i]=A.useState(""),a=oz();return c.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-zinc-800 bg-zinc-900/40 px-3 py-2",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Capture next"}),c.jsx("input",{type:"number",min:1,value:t,onChange:o=>n(Math.max(1,Number(o.target.value))),className:"w-14 rounded border border-zinc-700 bg-zinc-950 px-1 py-0.5 text-xs text-zinc-200"}),c.jsx("span",{className:"text-[10px] text-zinc-500",children:"request(s) matching"}),c.jsx("input",{type:"text",placeholder:"any route (e.g. GET /users/:id)",value:r,onChange:o=>i(o.target.value),className:"w-56 rounded border border-zinc-700 bg-zinc-950 px-1 py-0.5 text-xs text-zinc-200"}),c.jsx("button",{type:"button",disabled:a.isPending,onClick:()=>a.mutate({count:t,...r?{label:r}:{}}),className:"rounded bg-emerald-600 px-2 py-0.5 text-xs font-medium text-white hover:bg-emerald-500 disabled:opacity-50",children:a.isPending?"Arming…":"Arm capture"}),e>0&&c.jsxs("span",{className:"text-[10px] text-amber-400",children:[e," pending"]}),a.isError&&c.jsx("span",{className:"text-[10px] text-rose-400",children:a.error instanceof Error?a.error.message:"Failed to arm (mutations disabled?)"})]})}function sse(){var u,d,f,p,h;const e=La(),t=rz(),{data:n,isLoading:r}=iz(100),i=(n==null?void 0:n.data)??[],[a,o]=A.useState(null),s=((d=(u=e.data)==null?void 0:u.profiling)==null?void 0:d.enabled)??((f=t.data)==null?void 0:f.enabled)??!1,l=a??((p=i[0])==null?void 0:p.id)??null;return s?c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"CPU Profiles"}),t.data&&c.jsxs("span",{className:"text-[10px] text-zinc-500",children:["sampling ",(t.data.sampleRate*100).toFixed(0),"% · ",t.data.active," active"]})]}),c.jsx(ose,{pendingManual:((h=t.data)==null?void 0:h.pendingManual)??0}),c.jsxs("div",{className:"flex gap-4",children:[c.jsx("div",{className:"w-64 shrink-0 rounded-lg border border-zinc-800",children:r?c.jsx("p",{className:"p-3 text-xs text-zinc-600",children:"Loading…"}):i.length===0?c.jsx("p",{className:"p-3 text-xs text-zinc-600",children:"No profiles captured yet."}):i.map(g=>c.jsx(rse,{profile:g,selected:g.id===l,onSelect:()=>o(g.id)},g.id))}),c.jsx("div",{className:"min-w-0 flex-1",children:l?c.jsx(ase,{id:l}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Select a profile to view its flamegraph."})})]})]}):c.jsxs("div",{className:"space-y-3 p-4",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"CPU Profiles"}),c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-6 text-xs text-zinc-400",children:[c.jsx("p",{className:"mb-2 text-zinc-300",children:"CPU profiling is disabled."}),c.jsxs("p",{children:["Enable it with"," ",c.jsxs("code",{className:"rounded bg-zinc-800 px-1 text-emerald-300",children:["profiling: ","{"," enabled: true ","}"]})," ","in ",c.jsx("code",{className:"rounded bg-zinc-800 px-1",children:"TelescopeModule.forRoot"}),". Profiling is opt-in because it carries real CPU overhead; when off there is zero cost on the request path."]})]})]})}const lse={scheduled:"text-sky-300 bg-sky-500/10",manual:"text-amber-300 bg-amber-500/10"};function use({trigger:e}){return c.jsx("span",{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wide ${lse[e]}`,children:e})}function cse({type:e,count:t}){return c.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-zinc-800/80 px-1.5 py-0.5 text-[10px] text-zinc-300",children:[c.jsx("span",{className:"text-zinc-500",children:sp(e)}),c.jsx("span",{className:"tabular-nums text-zinc-100",children:t})]})}function fse(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function dse(e,t){if(e===null)return"—";const n=new Date(e).getTime()-t;if(Number.isNaN(n))return"—";if(n<=0)return"now";const r=Math.round(n/1e3);return r<60?`~${r}s`:`~${Math.floor(r/60)}m ${r%60}s`}function pse(){const[e,t]=A.useState(()=>Date.now());return A.useEffect(()=>{const n=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(n)},[]),e}function hse({config:e,nextRunAt:t,nowMs:n}){const r=Object.entries(e.perType??{});return c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[c.jsx(ze,{label:"Window",value:wl(e.afterMs),accent:"text-emerald-400"}),c.jsx(ze,{label:"Interval",value:wl(e.intervalMs)}),c.jsx(ze,{label:"Keep last",value:e.keepLast!=null?e.keepLast.toLocaleString():"unbounded"}),c.jsx(ze,{label:"Next prune",value:dse(t,n),accent:"text-sky-300",hint:r.length>0?`${r.length} per-type override(s)`:void 0}),r.length>0&&c.jsxs("div",{className:"col-span-2 rounded-lg border border-zinc-800 bg-zinc-900/40 p-3 sm:col-span-4",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Per-type overrides"}),c.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:r.map(([i,a])=>c.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-zinc-800/80 px-1.5 py-0.5 text-[10px] text-zinc-300",children:[c.jsx("span",{className:"text-zinc-500",children:sp(i)}),c.jsx("span",{className:"tabular-nums text-zinc-100",children:wl(a)})]},i))})]})]})}function mse({run:e}){const t=Object.entries(e.deletedByType);return c.jsxs("tr",{className:"border-t border-zinc-800/60 align-top hover:bg-zinc-900/40",children:[c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:Ha(new Date(e.at).getTime())}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(use,{trigger:e.trigger})}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-400",children:fse(e.durationMs)}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-100",children:e.deletedTotal.toLocaleString()}),c.jsx("td",{className:"px-3 py-2",children:t.length>0?c.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(([n,r])=>c.jsx(cse,{type:n,count:r},n))}):c.jsx("span",{className:"text-zinc-600",children:"—"})}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-400",children:e.archivedTotal!=null?e.archivedTotal.toLocaleString():"—"}),c.jsx("td",{className:"px-3 py-2 text-xs text-red-400",children:e.error??""})]})}function vse(){var d;const{data:e,isLoading:t,isError:n}=BI(),r=La(),i=E_(),a=pse(),o=((d=r.data)==null?void 0:d.pruneEnabled)??!1,s=(e==null?void 0:e.runs)??[],l=(e==null?void 0:e.config)??null;async function u(){if(globalThis.confirm("Prune now deletes entries older than the retention window. Continue?"))try{const f=await i.mutateAsync();globalThis.alert(`Pruned ${f.pruned} ${f.pruned===1?"entry":"entries"}.`)}catch{globalThis.alert("Prune failed.")}}return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between px-1",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Prune activity"}),c.jsx("button",{type:"button",onClick:u,disabled:!o||i.isPending,title:o?"Run a prune cycle now":"Mutations are disabled (configure authorizeAction to enable on-demand pruning).",className:"rounded border border-zinc-700 px-2.5 py-1 text-[11px] text-zinc-300 hover:border-emerald-500 hover:text-emerald-400 disabled:cursor-not-allowed disabled:opacity-50",children:i.isPending?"Pruning…":"Prune now"})]}),l?c.jsx(hse,{config:l,nextRunAt:(e==null?void 0:e.nextRunAt)??null,nowMs:a}):c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-6 text-center text-xs text-zinc-600",children:"No retention window is configured. Set a `prune` option to enable automatic pruning."}),t&&c.jsx("p",{className:"px-1 py-2 text-xs text-zinc-600",children:"Loading prune runs…"}),n&&c.jsx("p",{className:"px-1 py-2 text-xs text-red-400",children:"Failed to load prune runs."}),!t&&!n&&s.length===0&&c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-12 text-center text-xs text-zinc-600",children:"No prune runs recorded yet on this pod."}),s.length>0&&c.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800",children:c.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:[c.jsx("th",{className:"px-3 py-2 font-normal",children:"Time"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Trigger"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Duration"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Deleted"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"By type"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Archived"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Error"})]})}),c.jsx("tbody",{children:s.map((f,p)=>c.jsx(mse,{run:f},`${f.at}:${p}`))})]})})]})}function yse(){var s;const[e,t]=A.useState("1h"),n=ir(),{data:r,isLoading:i}=N_(e),a=n0({window:e,buckets:60}),o=yx(((s=a.data)==null?void 0:s.buckets)??[]);return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"Pulse"}),c.jsx(tc,{value:e,onChange:t})]}),c.jsx(mx,{title:"Throughput by type",series:o,data:Bk(a.data)}),i||!r?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):c.jsx(xae,{report:r,onSelectEntry:l=>n(`/entries/view/${l}`),onSelectFamily:l=>n(`/entries/query?familyHash=${encodeURIComponent(l)}`),onSelectRoute:l=>n(`/entries/request?familyHash=${encodeURIComponent(l)}`),onSelectOutgoing:l=>n(`/entries/http_client?familyHash=${encodeURIComponent(l)}`)})]})}const gse="#f87171",xse="#34d399";function bse(e){return((e==null?void 0:e.queues)??[]).map(t=>({label:t.queue,value:Number((t.failureRate*100).toFixed(1)),color:t.failureRate>0?gse:xse}))}function wse(){const[e,t]=A.useState("1h"),{data:n,isLoading:r}=k_(e);return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"Queue metrics"}),c.jsx(tc,{value:e,onChange:t})]}),c.jsx(va,{title:"Failure rate by queue",valueLabel:"fail %",data:bse(n)}),r||!n?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):c.jsx(bae,{report:n,sparkline:i=>c.jsx(jae,{queue:i,window:e})})]})}const jse=[{to:"/queues",label:"Manage",end:!0},{to:"/queues/metrics",label:"Metrics",end:!1}];function Sse(){return c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"flex gap-1 border-b border-zinc-800 px-4 pt-3",children:jse.map(e=>c.jsx(Zc,{to:e.to,end:e.end,className:({isActive:t})=>`rounded-t-md px-3 py-1.5 text-xs transition-colors ${t?"bg-zinc-900 text-emerald-300":"text-zinc-500 hover:text-zinc-300"}`,children:e.label},e.to))}),c.jsx(WM,{})]})}const Ose={cron:"text-emerald-300 bg-emerald-500/10",interval:"text-sky-300 bg-sky-500/10",timeout:"text-amber-300 bg-amber-500/10"};function Pse({kind:e}){return c.jsx("span",{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wide ${Ose[e]}`,children:e})}function Ase({running:e}){return e==null?c.jsx("span",{className:"rounded bg-zinc-500/10 px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-zinc-500",children:"unknown"}):c.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wide ${e?"bg-emerald-500/10 text-emerald-300":"bg-red-500/10 text-red-300"}`,children:[c.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${e?"bg-emerald-400":"bg-red-400"}`}),e?"active":"stopped"]})}function _se({status:e}){if(e===null)return c.jsx("span",{className:"text-zinc-600",children:"—"});const t=e==="completed"?"text-emerald-300 bg-emerald-500/10":"text-red-300 bg-red-500/10";return c.jsx("span",{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wide ${t}`,children:e})}function Ese(e){return e===null?"—":e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function $se(e){if(e===null)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function Nse({task:e}){return c.jsxs("tr",{className:"border-t border-zinc-800/60 hover:bg-zinc-900/40",children:[c.jsx("td",{className:"px-3 py-2 font-medium text-zinc-100",children:e.name}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(Pse,{kind:e.kind})}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(Ase,{running:e.running})}),c.jsx("td",{className:"px-3 py-2 font-mono text-xs text-zinc-400",children:e.schedule}),c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:$se(e.nextRunAt)}),c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:Ha(kse(e.lastRunAt))}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-400",children:Ese(e.lastDurationMs)}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(_se,{status:e.lastStatus})})]})}function kse(e){if(e===null)return null;const t=new Date(e).getTime();return Number.isNaN(t)?null:t}function Tse(){const{data:e,isLoading:t,isError:n}=MI(),r=(e==null?void 0:e.tasks)??[],i=r.filter(o=>o.running===!0).length,a=r.filter(o=>o.running===!1).length;return c.jsxs("div",{className:"space-y-3 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between px-1",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Scheduled tasks"}),r.length>0&&c.jsxs("div",{className:"flex items-center gap-3 text-[10px] uppercase tracking-wide",children:[c.jsxs("span",{className:"text-emerald-400",children:[i," active"]}),a>0&&c.jsxs("span",{className:"text-red-400",children:[a," stopped"]}),c.jsxs("span",{className:"text-zinc-600",children:[r.length," total"]})]})]}),t&&c.jsx("p",{className:"px-1 py-2 text-xs text-zinc-600",children:"Loading schedules…"}),n&&c.jsx("p",{className:"px-1 py-2 text-xs text-red-400",children:"Failed to load schedules."}),!t&&!n&&r.length===0&&c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-12 text-center text-xs text-zinc-600",children:"No scheduled tasks detected. Register a ScheduleManager (the @nestjs/schedule watcher) to populate this console."}),r.length>0&&c.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800",children:c.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:[c.jsx("th",{className:"px-3 py-2 font-normal",children:"Name"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Kind"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Active"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Schedule"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Next run"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Last run"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Duration"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Status"})]})}),c.jsx("tbody",{children:r.map(o=>c.jsx(Nse,{task:o},`${o.kind}:${o.name}`))})]})})]})}function Cse(){const{traceId:e=""}=ip(),t=ir(),[n,r]=A.useState("waterfall"),{data:i,isLoading:a}=$_({traceId:e}),o=(i==null?void 0:i.data)??[],{data:s,isLoading:l}=ZI(e);return c.jsxs("div",{className:"p-4",children:[c.jsx("button",{type:"button",onClick:()=>t("/entries"),className:"mb-4 text-xs text-zinc-500 hover:text-zinc-300",children:"← entries"}),c.jsxs("div",{className:"mb-4 flex flex-wrap items-baseline gap-3 border-b border-zinc-800 pb-3",children:[c.jsx("h2",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Trace"}),c.jsx("span",{className:"max-w-md truncate font-mono text-xs text-zinc-300",title:e,children:e}),c.jsxs("span",{className:"text-xs text-zinc-500",children:[o.length," ",o.length===1?"entry":"entries"]}),c.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[c.jsxs("div",{className:"flex overflow-hidden rounded border border-zinc-700 text-[11px]",children:[c.jsx("button",{type:"button",onClick:()=>r("waterfall"),className:`px-2.5 py-1 transition-colors ${n==="waterfall"?"bg-zinc-800 text-zinc-100":"bg-zinc-900 text-zinc-400 hover:text-zinc-200"}`,children:"Waterfall"}),c.jsx("button",{type:"button",onClick:()=>r("entries"),className:`border-l border-zinc-700 px-2.5 py-1 transition-colors ${n==="entries"?"bg-zinc-800 text-zinc-100":"bg-zinc-900 text-zinc-400 hover:text-zinc-200"}`,children:"Entries"})]}),o.length>0?c.jsx("button",{type:"button",onClick:()=>a0(`telescope-trace-${e}.json`,o),className:"rounded border border-zinc-700 bg-zinc-900 px-2.5 py-1 text-[11px] text-zinc-300 transition-colors hover:border-zinc-600 hover:bg-zinc-800 hover:text-zinc-100",children:"Download JSON"}):null]})]}),n==="waterfall"?l?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):s===void 0||s.spans.length===0?c.jsx("p",{className:"text-zinc-600",children:"No spans in this trace"}):c.jsx(_z,{waterfall:s,onSelect:u=>t(`/entries/view/${u}`)}):a?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):o.length===0?c.jsx("p",{className:"text-zinc-600",children:"No entries in this trace"}):c.jsx(D_,{entries:o,onSelect:u=>t(`/entries/view/${u}`)})]})}function Mse(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function Ise({trace:e}){const t=ir(),n=e.rootLabel??e.traceId;return c.jsxs("button",{type:"button",onClick:()=>t(`/traces/${e.traceId}`),className:"flex w-full items-center gap-3 border-b border-zinc-900 px-3 py-2 text-left hover:bg-zinc-900",children:[c.jsx("span",{className:"flex shrink-0 items-center gap-1","aria-hidden":"true",children:e.types.map(r=>c.jsx("span",{className:`h-2 w-2 rounded-full ${r0(r)}`,title:r},r))}),c.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-zinc-200",title:n,children:n}),c.jsxs("span",{className:"shrink-0 text-xs text-zinc-500",children:[e.entryCount," ",e.entryCount===1?"entry":"entries"]}),c.jsx("span",{className:"w-16 shrink-0 text-right text-xs text-zinc-400",children:Mse(e.totalDurationMs)}),c.jsx("span",{className:"w-16 shrink-0 text-right text-xs text-zinc-600",children:Ha(new Date(e.lastAt).getTime())})]})}function zse(){const[e,t]=A.useState("1h"),{data:n,isLoading:r}=JI(e),i=(n==null?void 0:n.traces)??[];return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"Traces"}),c.jsx(tc,{value:e,onChange:t})]}),r?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):i.length===0?c.jsx("p",{className:"text-zinc-600",children:"No traces in this window"}):c.jsx("div",{className:"border border-zinc-800",children:i.map(a=>c.jsx(Ise,{trace:a},a.traceId))})]})}const Rse=new B2;function Dse(){return c.jsx(eI,{children:c.jsx(doe,{children:c.jsxs(HM,{children:[c.jsx(jt,{path:"/",element:c.jsx(Moe,{})}),c.jsx(jt,{path:"/entries",element:c.jsx(vO,{})}),c.jsx(jt,{path:"/entries/view/:id",element:c.jsx(Roe,{})}),c.jsx(jt,{path:"/entries/:type",element:c.jsx(vO,{})}),c.jsx(jt,{path:"/traces",element:c.jsx(zse,{})}),c.jsx(jt,{path:"/traces/:traceId",element:c.jsx(Cse,{})}),c.jsx(jt,{path:"/pulse",element:c.jsx(yse,{})}),c.jsxs(jt,{path:"/queues",element:c.jsx(Sse,{}),children:[c.jsx(jt,{index:!0,element:c.jsx(Ioe,{})}),c.jsx(jt,{path:"metrics",element:c.jsx(wse,{})})]}),c.jsx(jt,{path:"/schedules",element:c.jsx(Tse,{})}),c.jsx(jt,{path:"/prunes",element:c.jsx(vse,{})}),c.jsx(jt,{path:"/exports",element:c.jsx(Uoe,{})}),c.jsx(jt,{path:"/profiles",element:c.jsx(sse,{})}),c.jsx(jt,{path:"/ext/:dashboardId",element:c.jsx(nse,{})})]})})})}function Lse(){const{phase:e,modes:t}=bx();return e==="loading"?c.jsx("div",{className:"min-h-screen bg-zinc-950","data-testid":"auth-loading"}):e==="screen"?c.jsx(Xae,{modes:t}):c.jsx(Dse,{})}function Bse(){return c.jsx(roe,{children:c.jsx(cI,{children:c.jsx(F2,{client:Rse,children:c.jsx(Hae,{children:c.jsx(Lse,{})})})})})}const OO=document.getElementById("root");OO&&GA(OO).render(c.jsx(A.StrictMode,{children:c.jsx(Bse,{})}));
143
+ `)})]})]})}function Bae({driver:e,queue:t,jobId:n,state:r,capabilities:i,onClose:a}){const{data:o,isLoading:s,isError:l}=zI(e,t,n);return A.useEffect(()=>{function u(d){d.key==="Escape"&&a()}return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a]),c.jsxs("div",{className:"fixed inset-0 z-40 flex justify-end",children:[c.jsx("button",{type:"button","aria-label":"Close job detail",onClick:a,className:"absolute inset-0 bg-black/50"}),c.jsxs("aside",{className:"relative z-10 flex h-full w-full max-w-md flex-col border-l border-zinc-800 bg-zinc-950 shadow-2xl",children:[c.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-2.5",children:[c.jsx("span",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Job detail"}),c.jsx("button",{type:"button",onClick:a,className:"rounded px-2 py-0.5 text-zinc-500 hover:bg-zinc-900 hover:text-zinc-200",children:"✕"})]}),c.jsx("div",{className:"flex-1 overflow-auto p-4",children:s?c.jsx("p",{className:"text-xs text-zinc-600",children:"Loading job…"}):l?c.jsx("p",{className:"text-xs text-red-400",children:"Failed to load job."}):o?c.jsx(Lae,{detail:o,capabilities:i,driver:e,queue:t,state:r,onClose:a}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Job not found (it may have been removed)."})})]})]})}function Fae(e){return e instanceof Error&&/\b403\b/.test(e.message)}function Uae(e){const t=e.trim();if(t==="")return{ok:!1,message:"Payload is required."};try{return{ok:!0,value:JSON.parse(t)}}catch{return{ok:!1,message:"Payload must be valid JSON."}}}function Wae({capabilities:e,driver:t,queue:n}){const r=DI(),[i,a]=A.useState(""),[o,s]=A.useState(""),[l,u]=A.useState(null),[d,f]=A.useState(void 0);if(!Zp(e,t,"enqueue"))return null;const p=Fae(r.error);async function h(g){g.preventDefault(),f(void 0);const y=Uae(o);if(!y.ok){u(y.message);return}u(null);try{const b=await r.mutateAsync({driver:t,queue:n,...i.trim()!==""?{name:i.trim()}:{},payload:y.value});f(b.id),s("")}catch{}}return c.jsxs("form",{onSubmit:h,className:"space-y-2 rounded-lg border border-zinc-800 p-3",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Send message"}),c.jsx("input",{type:"text",value:i,onChange:g=>a(g.target.value),placeholder:"Job name (optional)","aria-label":"Job name",className:"w-full rounded border border-zinc-800 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 placeholder:text-zinc-600"}),c.jsx("textarea",{value:o,onChange:g=>s(g.target.value),placeholder:'{"to": "a@b.c"}',"aria-label":"Payload (JSON)",rows:4,className:"w-full rounded border border-zinc-800 bg-zinc-950 px-2 py-1 font-mono text-xs text-zinc-200 placeholder:text-zinc-600"}),l&&c.jsx("p",{className:"text-[10px] text-red-400",children:l}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("button",{type:"submit",disabled:r.isPending,className:"rounded border border-emerald-500/40 px-2.5 py-1 text-[11px] text-emerald-300 transition-colors hover:bg-emerald-500/10 disabled:opacity-50",children:r.isPending?"Sending…":"Send message"}),p&&c.jsx("span",{className:"text-[10px] text-red-400",children:"Not authorized"}),d!==void 0&&!p&&c.jsx("span",{className:"text-[10px] text-emerald-400",children:d?`Enqueued job ${d}`:"Message enqueued"})]})]})}const xx=A.createContext(null);function qae(e){return e instanceof Error&&/ 401$/.test(e.message)}function Hae({children:e}){const t=ce(),n=zr(),[r,i]=A.useState("loading"),[a,o]=A.useState([]),s=A.useRef(!1),l=A.useMemo(()=>{async function u(){const f=await t.auth.me();if(f.status==="authenticated"){s.current=!0,i("app");return}if(f.status==="unauthenticated"){s.current=!0,o(f.modes),i("screen");return}s.current=!1,i("disabled")}async function d(){await t.auth.logout(),await u()}return{phase:r,modes:a,refresh:u,logout:d}},[t,r,a]);return A.useEffect(()=>{let u=!1;return t.auth.me().then(d=>{u||(d.status==="authenticated"?(s.current=!0,i("app")):d.status==="unauthenticated"?(s.current=!0,o(d.modes),i("screen")):(s.current=!1,i("disabled")))}),()=>{u=!0}},[t]),A.useEffect(()=>n.getQueryCache().subscribe(d=>{d.type==="updated"&&d.query.state.status==="error"&&s.current&&qae(d.query.state.error)&&l.refresh()}),[n,l]),c.jsx(xx.Provider,{value:l,children:e})}function bx(){const e=A.useContext(xx);if(!e)throw new Error("useAuth must be used within an AuthProvider");return e}function Kae(){return A.useContext(xx)}function Vae({children:e}){return c.jsx("div",{className:"flex min-h-screen items-center justify-center bg-zinc-950 px-4 font-mono text-sm text-zinc-200",children:c.jsxs("div",{className:"w-full max-w-sm rounded-lg border border-zinc-800 bg-zinc-900 p-8 shadow-2xl",children:[c.jsx("div",{className:"mb-6 text-center text-lg font-semibold text-emerald-400",children:"Telescope"}),e]})})}function Gae(){const e=ce(),{refresh:t}=bx(),[n,r]=A.useState(""),[i,a]=A.useState(""),[o,s]=A.useState(null),[l,u]=A.useState(!1);async function d(f){f.preventDefault(),u(!0),s(null);try{const p=await e.auth.login(n,i);if(p.ok){await t();return}s(p.message)}finally{u(!1)}}return c.jsxs("form",{onSubmit:d,className:"flex flex-col gap-4",children:[c.jsxs("label",{className:"flex flex-col gap-1.5",children:[c.jsx("span",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Username"}),c.jsx("input",{type:"text",name:"username",autoComplete:"username",value:n,onChange:f=>r(f.target.value),className:"rounded border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-emerald-500/60"})]}),c.jsxs("label",{className:"flex flex-col gap-1.5",children:[c.jsx("span",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Password"}),c.jsx("input",{type:"password",name:"password",autoComplete:"current-password",value:i,onChange:f=>a(f.target.value),className:"rounded border border-zinc-700 bg-zinc-950 px-3 py-2 text-sm text-zinc-100 outline-none focus:border-emerald-500/60"})]}),o!==null?c.jsx("p",{role:"alert",className:"text-xs text-rose-400",children:o}):null,c.jsx("button",{type:"submit",disabled:l,className:"mt-2 rounded border border-emerald-500/40 bg-emerald-500/10 px-3 py-2 text-xs font-medium uppercase tracking-wide text-emerald-300 transition-colors hover:bg-emerald-500/20 disabled:cursor-not-allowed disabled:opacity-50",children:l?"Signing in…":"Sign in"})]})}function Qae(){const{refresh:e}=bx(),[t,n]=A.useState(!1);async function r(){n(!0);try{await e()}finally{n(!1)}}return c.jsxs("div",{className:"flex flex-col gap-4 text-center",children:[c.jsx("p",{className:"text-sm font-medium text-zinc-200",children:"Open Telescope from your application"}),c.jsx("p",{className:"text-xs leading-relaxed text-zinc-500",children:"Your session is minted by the host app. Use its “Open Telescope” action to sign in, then come back here."}),c.jsx("button",{type:"button",onClick:r,disabled:t,className:"mt-2 rounded border border-zinc-700 px-3 py-2 text-xs font-medium uppercase tracking-wide text-zinc-300 transition-colors hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-50",children:t?"Checking…":"Retry"})]})}function Xae({modes:e}){const t=e.includes("login");return c.jsx(Vae,{children:t?c.jsx(Gae,{}):c.jsx(Qae,{})})}const Yae=[{id:"page-overview",label:"Overview",to:"/"},{id:"page-entries",label:"Entries",to:"/entries"},{id:"page-pulse",label:"Pulse",to:"/pulse"},{id:"page-queues",label:"Queues",to:"/queues"},{id:"page-metrics",label:"Queue Metrics",to:"/queues/metrics"},{id:"page-schedules",label:"Schedules",to:"/schedules"},{id:"page-traces",label:"Traces",to:"/traces"}],Jae=[...Yae,...Ql.map(e=>({id:`entry-${e.id}`,label:e.label,to:`/entries/${e.id}`}))];function Zae(e,t){const n=t.trim().toLowerCase();return n?e.filter(r=>r.label.toLowerCase().includes(n)):e}function eoe(){const[e,t]=A.useState(!1);return A.useEffect(()=>{function n(r){(r.metaKey||r.ctrlKey)&&r.key.toLowerCase()==="k"&&(r.preventDefault(),t(i=>!i))}return window.addEventListener("keydown",n),()=>window.removeEventListener("keydown",n)},[]),{open:e,setOpen:t}}function toe({open:e,onClose:t}){const n=ir(),r=A.useRef(null),[i,a]=A.useState(""),[o,s]=A.useState(0),l=A.useId(),u=A.useMemo(()=>Zae(Jae,i),[i]);A.useEffect(()=>{var h;e&&(a(""),s(0),(h=r.current)==null||h.focus())},[e]),A.useEffect(()=>{s(h=>u.length===0?0:Math.min(h,u.length-1))},[u.length]);const d=A.useCallback(h=>{h&&(n(h.to),t())},[n,t]);if(!e)return null;function f(h){if(h.key==="Escape"){h.preventDefault(),t();return}u.length!==0&&(h.key==="ArrowDown"?(h.preventDefault(),s(g=>(g+1)%u.length)):h.key==="ArrowUp"?(h.preventDefault(),s(g=>(g-1+u.length)%u.length)):h.key==="Enter"&&(h.preventDefault(),d(u[o])))}const p=u[o]?`${l}-${u[o].id}`:void 0;return c.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center bg-black/60 pt-[12vh]",onClick:t,children:c.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"Command palette",className:"w-full max-w-lg overflow-hidden rounded-lg border border-zinc-700 bg-zinc-900 shadow-2xl",onClick:h=>h.stopPropagation(),onKeyDown:f,children:[c.jsx("input",{ref:r,type:"text",value:i,onChange:h=>a(h.target.value),placeholder:"Jump to…","aria-label":"Search actions","aria-controls":l,"aria-activedescendant":p,className:"w-full border-b border-zinc-800 bg-transparent px-4 py-3 text-sm text-zinc-100 outline-none placeholder:text-zinc-500"}),c.jsx("ul",{id:l,role:"listbox",className:"max-h-72 overflow-y-auto py-1",children:u.length===0?c.jsx("li",{className:"px-4 py-3 text-xs text-zinc-500",children:"No matching actions"}):u.map((h,g)=>c.jsx("li",{id:`${l}-${h.id}`,role:"option","aria-selected":g===o,onMouseEnter:()=>s(g),onMouseDown:y=>{y.preventDefault(),d(h)},className:`cursor-pointer px-4 py-2 text-sm ${g===o?"bg-zinc-800 text-emerald-300":"text-zinc-300"}`,children:h.label},h.id))})]})})}const Rk="telescope-theme",um="dark",Dk=A.createContext(null);function dO(){if(typeof window>"u"||!window.localStorage)return um;try{const e=window.localStorage.getItem(Rk);return e==="light"||e==="dark"?e:um}catch{return um}}function noe(e){if(!(typeof window>"u"||!window.localStorage))try{window.localStorage.setItem(Rk,e)}catch{}}function roe({children:e}){const[t,n]=A.useState(dO),r=A.useCallback(()=>{n(a=>{const o=a==="dark"?"light":"dark";return noe(o),o})},[]);A.useEffect(()=>{n(dO())},[]);const i=A.useMemo(()=>({theme:t,toggleTheme:r}),[t,r]);return c.jsx(Dk.Provider,{value:i,children:c.jsx("div",{className:t,"data-theme":t,"data-testid":"telescope-root",children:e})})}function ioe(){const e=A.useContext(Dk);if(!e)throw new Error("useTheme must be used within a ThemeProvider");return e}const aoe=[{to:"/",label:"Overview",end:!0},{to:"/entries",label:"Entries",end:!0},{to:"/traces",label:"Traces",end:!0},{to:"/pulse",label:"Pulse",end:!1},{to:"/queues",label:"Queues",end:!1},{to:"/schedules",label:"Schedules",end:!1},{to:"/prunes",label:"Prunes",end:!1},{to:"/exports",label:"Exports",end:!1},{to:"/profiles",label:"Profiles",end:!1}];function ooe(e,t,n){return e.filter(r=>!(r.to==="/traces"&&t===!1||r.to==="/profiles"&&n!==!0))}function pO({isActive:e}){return`block rounded px-3 py-1.5 text-xs uppercase tracking-wide ${e?"bg-zinc-900 text-emerald-300":"text-zinc-500 hover:bg-zinc-900 hover:text-zinc-300"}`}function soe({isActive:e}){return`flex items-center gap-2 rounded px-3 py-1.5 text-xs ${e?"bg-zinc-900 text-zinc-100":"text-zinc-500 hover:bg-zinc-900 hover:text-zinc-300"}`}function loe(){const{paused:e,setPaused:t}=S_();return c.jsxs("button",{type:"button",onClick:()=>t(!e),"aria-pressed":e,title:e?"Resume live tail":"Pause live tail",className:`flex items-center gap-1.5 rounded border px-2.5 py-1 text-xs font-medium uppercase tracking-wide transition-colors ${e?"border-amber-500/40 bg-amber-500/10 text-amber-300 hover:bg-amber-500/20":"border-emerald-500/40 bg-emerald-500/10 text-emerald-300 hover:bg-emerald-500/20"}`,children:[c.jsx("span",{"aria-hidden":"true",children:e?"⏸":"●"}),e?"Paused":"Live"]})}function uoe(){const{theme:e,toggleTheme:t}=ioe(),n=e==="dark";return c.jsxs("button",{type:"button",onClick:t,"aria-pressed":!n,title:n?"Switch to light theme":"Switch to dark theme",className:"flex items-center gap-1.5 rounded border border-zinc-700 px-2.5 py-1 text-xs font-medium text-zinc-300 transition-colors hover:bg-zinc-800",children:[c.jsx("span",{"aria-hidden":"true",children:n?"☾":"☀"}),n?"Dark":"Light"]})}function coe({onClick:e}){return c.jsx("button",{type:"button",onClick:e,title:"Open command palette","aria-keyshortcuts":"Meta+K Control+K",className:"flex items-center gap-1.5 rounded border border-zinc-700 px-2.5 py-1 text-xs font-medium text-zinc-400 transition-colors hover:bg-zinc-800 hover:text-zinc-200",children:c.jsx("span",{"aria-hidden":"true",children:"⌘K"})})}function foe(){const e=Kae(),[t,n]=A.useState(!1);if(e===null||e.phase!=="app")return null;async function r(){if(e!==null){n(!0);try{await e.logout()}finally{n(!1)}}}return c.jsxs("button",{type:"button",onClick:r,disabled:t,title:"Sign out",className:"flex items-center gap-1.5 rounded border border-zinc-700 px-2.5 py-1 text-xs font-medium text-zinc-300 transition-colors hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-50",children:[c.jsx("span",{"aria-hidden":"true",children:"⎋"}),"Sign out"]})}function doe({children:e}){var o,s,l,u,d,f;const{open:t,setOpen:n}=eoe(),r=La(),i=dz(fz((o=r.data)==null?void 0:o.entryTypes),(s=r.data)==null?void 0:s.watchers),a=ooe(aoe,(l=r.data)==null?void 0:l.tracesEnabled,(d=(u=r.data)==null?void 0:u.profiling)==null?void 0:d.enabled);return c.jsxs("div",{className:"flex min-h-screen bg-zinc-950 font-mono text-sm text-zinc-200",children:[c.jsx(toe,{open:t,onClose:()=>n(!1)}),c.jsxs("aside",{className:"flex w-56 shrink-0 flex-col gap-6 border-r border-zinc-800 px-3 py-4",children:[c.jsx("span",{className:"px-3 text-base font-semibold text-emerald-400",children:"Telescope"}),c.jsxs("nav",{className:"flex flex-col gap-1",children:[a.map(p=>c.jsx(Zc,{to:p.to,end:p.end,className:pO,children:p.label},p.to)),(((f=r.data)==null?void 0:f.dashboards)??[]).map(p=>c.jsx(Zc,{to:`/ext/${p.id}`,className:pO,children:p.label},p.id))]}),c.jsxs("nav",{className:"flex flex-col gap-1",children:[c.jsx("span",{className:"px-3 pb-1 text-[10px] uppercase tracking-wider text-zinc-600",children:"Watchers"}),i.map(p=>c.jsxs(Zc,{to:`/entries/${p.id}`,className:soe,children:[c.jsx("span",{className:`h-2 w-2 shrink-0 rounded-full ${p.dot}`,"aria-hidden":"true"}),p.label]},p.id))]})]}),c.jsxs("div",{className:"flex min-w-0 flex-1 flex-col",children:[c.jsxs("header",{className:"flex items-center justify-end gap-4 border-b border-zinc-800 px-4 py-2",children:[c.jsx(uR,{}),c.jsx(coe,{onClick:()=>n(!0)}),c.jsx(uoe,{}),c.jsx(loe,{}),c.jsx(foe,{})]}),c.jsx("main",{className:"min-w-0 flex-1",children:e})]})]})}function poe(e,t){if(e===void 0||!t)return null;const n=t.direction==="up-bad";return(n?e>=t.bad:e<=t.bad)?"bad":(n?e>=t.warn:e<=t.warn)?"warn":"ok"}const hoe={ok:"#34d399",warn:"#fbbf24",bad:"#f87171"};function moe({points:e}){if(e.length<2)return null;const t=Math.max(...e),n=Math.min(...e),r=t-n||1,i=e.map((a,o)=>{const s=o/(e.length-1)*100,l=20-(a-n)/r*18-1;return`${o===0?"M":"L"}${s.toFixed(1)},${l.toFixed(1)}`}).join(" ");return c.jsxs("svg",{className:"mt-2",width:"100%",height:"22",viewBox:"0 0 100 22",preserveAspectRatio:"none",children:[c.jsx("title",{children:"Trend sparkline"}),c.jsx("path",{d:i,fill:"none",stroke:"#52525b",strokeWidth:"1.5"})]})}function ze({label:e,value:t,delta:n,deltaLabel:r,spark:i,thresholds:a,currentValue:o,accent:s="text-zinc-100",hint:l}){const u=poe(o,a),d=n===void 0||!a?null:a.direction==="up-bad"?n<0:n>0,f=d===null?"#a1a1aa":d?"#34d399":"#f87171",p=n===void 0?"":n>0?"▲":n<0?"▼":"◆";return c.jsxs("div",{"data-health":u??void 0,className:"rounded-lg border border-zinc-800 bg-zinc-900/40 px-4 py-3 overflow-hidden",children:[u&&c.jsx("div",{style:{height:3,background:hoe[u],margin:"-12px -16px 9px"}}),c.jsx("p",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:e}),c.jsxs("p",{className:`mt-1 text-2xl font-semibold tabular-nums ${s} flex items-baseline gap-2`,children:[t,n!==void 0&&c.jsxs("span",{className:"text-xs font-semibold",style:{color:f},children:[p," ",r??Math.abs(n)]})]}),i&&c.jsx(moe,{points:i}),l&&c.jsx("p",{className:"mt-0.5 text-[10px] text-zinc-600",children:l})]})}function voe(e){const t=Math.max(0,Math.floor(e)),n=Math.floor(t/86400),r=Math.floor(t%86400/3600),i=Math.floor(t%3600/60);return n>0?`${n}d ${r}h`:r>0?`${r}h ${i}m`:`${i}m ${t%60}s`}function yoe({stats:e}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Server"}),e?c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-5",children:[c.jsx(ze,{label:"Uptime",value:voe(e.uptimeSec),accent:"text-emerald-400"}),c.jsx(ze,{label:"RSS",value:`${e.memory.rssMb} MB`,hint:`heap ${e.memory.heapUsedMb}/${e.memory.heapTotalMb} MB`}),c.jsx(ze,{label:"Heap used",value:`${e.memory.heapUsedMb} MB`,accent:"text-sky-400"}),c.jsx(ze,{label:"CPU",value:`${Math.round(e.cpu.userMs)} ms`,accent:"text-violet-400",hint:`sys ${Math.round(e.cpu.systemMs)} ms`}),c.jsx(ze,{label:"Event loop",value:e.eventLoopDelayMs===null?"n/a":`${e.eventLoopDelayMs} ms`,accent:e.eventLoopDelayMs!==null&&e.eventLoopDelayMs>100?"text-red-400":"text-zinc-100",hint:`instance ${e.instanceId}`})]}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Loading…"})]})}function goe(e){return`${(Math.max(0,e)/1e3).toFixed(1)} µs`}function hO(e){return e===null?"n/a":`${e.toFixed(1)} ms`}function xoe({health:e}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3",children:[c.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Telescope health"}),c.jsx("span",{className:"text-[10px] text-zinc-600",children:"Captures run off the response path — your requests don't wait on Telescope."})]}),e?c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6",children:[c.jsx(ze,{label:"Capture cost",value:`${goe(e.captureCostNanos)}/capture`,accent:"text-emerald-400",hint:"micro-benchmark"}),c.jsx(ze,{label:"Buffer",value:`${e.bufferUsed} / ${e.bufferSize}`,accent:"text-sky-400",hint:`high-water ${e.bufferHighWater}`}),c.jsx(ze,{label:"Last flush",value:hO(e.lastFlushMs),hint:`max ${hO(e.maxFlushMs)}`}),c.jsx(ze,{label:"Flushes",value:e.flushes.toLocaleString(),accent:"text-violet-400",hint:`${e.flushedEntries.toLocaleString()} entries`}),c.jsx(ze,{label:"Dropped",value:e.droppedCount.toLocaleString(),accent:e.droppedCount>0?"text-red-400":"text-emerald-400",hint:e.droppedCount>0?`overflow ${e.overflowDropped} · store ${e.storeFailedDropped}`:"keeping up"}),c.jsx(ze,{label:"Truncated",value:e.truncatedCount.toLocaleString(),accent:e.truncatedCount>0?"text-amber-400":"text-emerald-400",hint:e.truncatedCount>0?"fat content — tune redact/sampling":"within bounds"})]}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Loading…"})]})}function boe({retention:e,pruneEnabled:t}){const n=E_(),r=e==null?void 0:e.retention;async function i(){if(globalThis.confirm("Prune now deletes entries older than the retention window. Continue?"))try{const a=await n.mutateAsync();globalThis.alert(`Pruned ${a.pruned} ${a.pruned===1?"entry":"entries"}.`)}catch{globalThis.alert("Prune failed.")}}return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3",children:[c.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Retention"}),t?c.jsx("button",{type:"button",onClick:i,disabled:n.isPending,className:"rounded border border-zinc-700 px-2 py-1 text-[11px] text-zinc-300 hover:border-emerald-500 hover:text-emerald-400 disabled:cursor-not-allowed disabled:opacity-50",children:n.isPending?"Pruning…":"Prune now"}):null]}),c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3",children:[c.jsx(ze,{label:"Window",value:r?wl(r.afterMs):"none",accent:r?"text-emerald-400":"text-zinc-500",hint:(r==null?void 0:r.keepLast)!=null?`keep last ${r.keepLast}`:"unbounded"}),c.jsx(ze,{label:"Entries",value:(e==null?void 0:e.entryCount)!=null?e.entryCount.toLocaleString():"n/a"}),c.jsx(ze,{label:"Oldest",value:(e==null?void 0:e.oldestCreatedAt)!=null?"tracked":"n/a"})]})]})}function Lk(e){const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function woe(e){return((e==null?void 0:e.buckets)??[]).map(t=>({label:Lk(t.t),value:t.total}))}function Bk(e){const t=yx((e==null?void 0:e.buckets)??[]);return((e==null?void 0:e.buckets)??[]).map(n=>{const r={label:Lk(n.t)};for(const i of t)r[i]=n.byType[i]??0;return r})}function joe(e){return Object.values(e).reduce((t,n)=>t+n,0)}function Soe(e){const t=e.request??0;return t===0?null:(e.exception??0)/t}const Ooe=.05;function Poe(e){return e===null?"n/a":`${(e*100).toFixed(1)}%`}function Aoe(e){return(e==null?void 0:e.slowRoutes.length)??0}const Zy=100;function _oe(e){return((e==null?void 0:e.queues)??[]).filter(t=>{const n=Math.max(0,t.total-t.completed-t.failed);return t.failed>0||n>=Zy})}function Eoe({pulse:e,queues:t}){const n=(e==null?void 0:e.counts)??{},r=joe(n),i=n.request??0,a=n.exception??0,o=Soe(n),s=((t==null?void 0:t.queues)??[]).reduce((u,d)=>u+d.failed,0),l=Aoe(e);return c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[c.jsx(ze,{label:"Requests",value:i.toLocaleString(),accent:"text-emerald-400",hint:`${r.toLocaleString()} entries total`}),c.jsx(ze,{label:"Error rate",value:Poe(o),accent:o!==null&&o>Ooe?"text-red-400":"text-zinc-100",hint:`${a.toLocaleString()} exceptions`}),c.jsx(ze,{label:"Failed jobs",value:s.toLocaleString(),accent:s>0?"text-red-400":"text-zinc-100",hint:"across queues"}),c.jsx(ze,{label:"Slow routes",value:l.toLocaleString(),accent:l>0?"text-amber-400":"text-zinc-100",hint:"routes over the slow p99 threshold"})]})}function mO({title:e,emptyLabel:t,children:n}){const r=Array.isArray(n)?n.length>0:!!n;return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:e}),r?c.jsx("ul",{className:"space-y-1 text-xs",children:n}):c.jsx("p",{className:"text-xs text-zinc-600",children:t})]})}function $oe({hotspots:e,onSelectFamily:t}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"N+1 query hotspots"}),e.length>0?c.jsx("ul",{className:"space-y-1 text-xs",children:e.map(n=>c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:()=>t(n.familyHash),className:"flex w-full items-center justify-between gap-3 border-t border-zinc-900 pt-1 text-left hover:text-zinc-100 first:border-0 first:pt-0",children:[c.jsxs("span",{className:"min-w-0 truncate",children:[c.jsxs("span",{className:"whitespace-nowrap text-amber-400",children:["×",n.perRequest]})," ",c.jsx("span",{className:"text-zinc-400",children:n.sql})]}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:[n.requests," req · ",n.total," total",n.totalDurationMs>0?` · ${Math.round(n.totalDurationMs)}ms`:""]})]})},n.familyHash))}):c.jsx("p",{className:"text-xs text-zinc-600",children:"None detected"})]})}function Noe({queues:e,onOpenQueues:t}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsxs("div",{className:"mb-3 flex items-baseline justify-between gap-3",children:[c.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Queues needing attention"}),c.jsx("button",{type:"button",onClick:t,className:"text-[11px] text-zinc-500 hover:text-emerald-400",children:"All queues →"})]}),e.length>0?c.jsx("ul",{className:"space-y-1 text-xs",children:e.map(n=>{const r=Math.max(0,n.total-n.completed-n.failed);return c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:t,className:"flex w-full items-center justify-between gap-3 border-t border-zinc-900 pt-1 text-left hover:text-zinc-100 first:border-0 first:pt-0",children:[c.jsx("span",{className:"min-w-0 truncate text-zinc-300",children:n.queue}),c.jsxs("span",{className:"shrink-0 tabular-nums",children:[n.failed>0?c.jsxs("span",{className:"text-red-400",children:[n.failed," failed"]}):null,n.failed>0&&r>=Zy?c.jsx("span",{className:"text-zinc-600",children:" · "}):null,r>=Zy?c.jsxs("span",{className:"text-amber-400",children:[r.toLocaleString()," pending"]}):null]})]})},n.queue)})}):c.jsx("p",{className:"text-xs text-emerald-400/80",children:"All queues healthy"})]})}function koe({hotspots:e}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Slowest jobs"}),e.length>0?c.jsx("ul",{className:"space-y-1 text-xs",children:e.map(t=>c.jsxs("li",{className:"flex items-center justify-between gap-3 border-t border-zinc-900 pt-1 first:border-0 first:pt-0",children:[c.jsx("span",{className:"min-w-0 truncate text-zinc-300",children:t.route}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:[c.jsxs("span",{className:"text-amber-400",children:[Math.round(t.p99),"ms"]})," p99 ·"," ",t.count,"×"]})]},t.route))}):c.jsx("p",{className:"text-xs text-zinc-600",children:"No jobs in window."})]})}function Toe({users:e,onSelectUser:t}){return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Load by user"}),e.length>0?c.jsx("ul",{className:"space-y-1 text-xs",children:e.map(n=>c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:()=>t(n.user),className:"flex w-full items-center justify-between gap-3 border-t border-zinc-900 pt-1 text-left hover:text-zinc-100 first:border-0 first:pt-0",children:[c.jsx("span",{className:"min-w-0 truncate text-zinc-300",children:n.user}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:[n.count," req · ",Math.round(n.totalDurationMs),"ms"]})]})},n.user))}):c.jsx("p",{className:"text-xs text-zinc-600",children:"No identified users in window."})]})}function Coe({history:e}){const t=(e==null?void 0:e.samples)??[],n=t.map(o=>o.cpuPercent),r=t.map(o=>o.rssMb),i=t.map(o=>o.heapUsedMb),a=t[t.length-1];return c.jsxs("section",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsx("h3",{className:"mb-3 text-xs font-medium uppercase tracking-wide text-zinc-400",children:"Resource history"}),t.length>1?c.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-3",children:[c.jsxs("div",{children:[c.jsxs("div",{className:"mb-1 text-[11px] text-zinc-500",children:["CPU ",a?`${a.cpuPercent}%`:""]}),c.jsx(nf,{values:n})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"mb-1 text-[11px] text-zinc-500",children:["RSS ",a?`${a.rssMb}MB`:""]}),c.jsx(nf,{values:r})]}),c.jsxs("div",{children:[c.jsxs("div",{className:"mb-1 text-[11px] text-zinc-500",children:["Heap ",a?`${a.heapUsedMb}MB`:""]}),c.jsx(nf,{values:i})]})]}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Collecting samples…"})]})}function Moe(){var y,b,v,m,x,j,w;const[e,t]=A.useState("1h"),n=ir(),r=N_(e),i=k_(e),a=n0({window:e,buckets:60}),o=KI(),s=VI(),l=QI(),u=LI(),d=La(),f=woe(a.data),p=Bk(a.data),h=yx(((y=a.data)==null?void 0:y.buckets)??[]),g=_oe(i.data);return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"Overview"}),c.jsx(tc,{value:e,onChange:t})]}),c.jsx(Eoe,{pulse:r.data,queues:i.data}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[c.jsx(mO,{title:"Recent failures",emptyLabel:"No exceptions 🎉",children:(((b=r.data)==null?void 0:b.topExceptions)??[]).map(S=>c.jsxs("li",{className:"flex items-center justify-between gap-3 border-t border-zinc-900 pt-1 first:border-0 first:pt-0",children:[c.jsxs("span",{className:"min-w-0",children:[c.jsx("span",{className:"text-red-400",children:S.class})," ",c.jsx("span",{className:"text-zinc-400",children:S.message})]}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:["×",S.count]})]},S.familyHash))}),c.jsx($oe,{hotspots:((v=r.data)==null?void 0:v.nPlusOne)??[],onSelectFamily:S=>n(`/entries/query?familyHash=${encodeURIComponent(S)}`)})]}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[c.jsx(mO,{title:"Slowest",emptyLabel:"Nothing slow in window.",children:(((m=r.data)==null?void 0:m.slowest)??[]).map(S=>c.jsx("li",{children:c.jsxs("button",{type:"button",onClick:()=>n(`/entries/view/${S.id}`),className:"flex w-full items-center justify-between gap-3 border-t border-zinc-900 pt-1 text-left hover:text-zinc-100 first:border-0 first:pt-0",children:[c.jsxs("span",{className:"min-w-0 truncate",children:[c.jsx("span",{className:"text-emerald-400",children:S.type})," ",c.jsx("span",{className:"text-zinc-400",children:S.label})]}),c.jsxs("span",{className:"shrink-0 tabular-nums text-zinc-500",children:[S.durationMs,"ms"]})]})},S.id))}),c.jsx(Noe,{queues:g,onOpenQueues:()=>n("/queues")})]}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[c.jsx(koe,{hotspots:((x=r.data)==null?void 0:x.slowJobs)??[]}),c.jsx(Toe,{users:((j=r.data)==null?void 0:j.loadByUser)??[],onSelectUser:S=>n(`/entries?tag=${encodeURIComponent(`user:${S}`)}`)})]}),c.jsx(Coe,{history:s.data}),c.jsxs("div",{className:"grid grid-cols-1 gap-4 lg:grid-cols-2",children:[c.jsx(qa,{title:"Throughput",valueLabel:"entries",data:f}),c.jsx(mx,{title:"By type",series:h,data:p})]}),c.jsx(yoe,{stats:o.data}),c.jsx(xoe,{health:l.data}),c.jsx(boe,{retention:u.data,pruneEnabled:((w=d.data)==null?void 0:w.pruneEnabled)??!1})]})}function Ioe(){const{data:e}=A_(),t=(e==null?void 0:e.queues)??[],n=e==null?void 0:e.capabilities,[r,i]=A.useState(void 0),[a,o]=A.useState("waiting"),[s,l]=A.useState(null);A.useEffect(()=>{if(r||t.length===0)return;const f=t[0];f&&i({driver:f.driver,queue:f.queue})},[t,r]);const u=t.find(f=>f.driver===(r==null?void 0:r.driver)&&f.queue===(r==null?void 0:r.queue));function d(f,p){i({driver:f,queue:p}),l(null)}return c.jsxs("div",{className:"grid grid-cols-1 gap-4 p-4 lg:grid-cols-[280px_minmax(0,1fr)]",children:[c.jsxs("aside",{className:"space-y-2",children:[c.jsx("h3",{className:"px-1 text-[10px] uppercase tracking-wide text-zinc-500",children:"Live queues"}),c.jsx(Pae,{...r?{selected:r}:{},onSelect:d})]}),c.jsx("section",{className:"min-w-0 space-y-3",children:r?c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"flex items-center justify-between gap-3",children:[c.jsxs("h2",{className:"truncate text-sm text-emerald-400",children:[r.queue,c.jsx("span",{className:"ml-2 text-[10px] uppercase tracking-wide text-zinc-600",children:r.driver})]}),a==="failed"&&c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(zae,{capabilities:n,driver:r.driver,queue:r.queue}),c.jsx(Rae,{capabilities:n,driver:r.driver,queue:r.queue})]})]}),c.jsx(Aae,{counts:u==null?void 0:u.counts,state:a,onState:o}),c.jsx(Nae,{driver:r.driver,queue:r.queue,state:a,onOpen:l}),c.jsx(Wae,{capabilities:n,driver:r.driver,queue:r.queue})]}):c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-12 text-center text-xs text-zinc-600",children:"Select a queue to inspect its jobs."})}),r&&s&&c.jsx(Bae,{driver:r.driver,queue:r.queue,jobId:s,state:a,capabilities:n,onClose:()=>l(null)})]})}function zoe(e,t){return t.trim()!==""?`No entries match tag '${t.trim()}'`:e?`No ${sp(e)} entries`:"No entries"}function vO(){const{type:e}=ip(),t=ir(),[n]=aI(),[r,i]=A.useState(()=>n.get("tag")??""),[a,o]=A.useState(""),[s,l]=A.useState(""),[u,d]=A.useState(0),[f,p]=A.useState(0);function h(M){i(M),p(D=>D+1)}function g(M){i(M),d(D=>D+1)}const y=e&&uz(e)?e:void 0,b=r.trim(),v=xz(b)?b:"",m=v===""?b:"",x=s.trim(),j=n.get("familyHash")??"",w=j!=="",S=x!=="",O=y!==void 0||b!==""||w||S,{data:P,isLoading:_}=$_({...y?T_(y):{},...b!==""?{tag:b}:{},...w?{familyHash:j}:{},...S?{search:x}:{}}),N=(P==null?void 0:P.data)??[];function T(){l(a)}function k(){o(""),l("")}function z(){i(""),k(),t("/entries")}function I(){t(y?`/entries/${y}`:"/entries")}return c.jsxs("div",{className:"p-4",children:[y?c.jsx(mae,{type:y}):null,c.jsxs("div",{className:"mb-4 flex flex-wrap items-center gap-3 border-b border-zinc-800 pb-3",children:[y?c.jsxs("button",{type:"button",onClick:()=>t("/entries"),className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{className:`h-2 w-2 rounded-full ${r0(y)}`,"aria-hidden":"true"}),sp(y),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):c.jsx("span",{className:"rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-400",children:"All types"}),c.jsx(lO,{onSelect:h},`tag-${u}`),c.jsx(lO,{prefix:gz,placeholder:"Filter by user…",ariaLabel:"Filter by user",onSelect:g},`user-${f}`),m!==""?c.jsxs("button",{type:"button",onClick:()=>i(""),className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{children:`tag:${m}`}),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):null,v!==""?c.jsxs("button",{type:"button",onClick:()=>i(""),className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{children:`User: ${i0(v)}`}),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):null,c.jsx("input",{type:"text",value:a,onChange:M=>o(M.target.value),onKeyDown:M=>{M.key==="Enter"&&T()},onBlur:T,placeholder:"Search content…","aria-label":"Search content",className:"rounded border border-zinc-800 bg-zinc-950 px-2 py-1 text-xs text-zinc-200 placeholder:text-zinc-600 focus:border-emerald-500 focus:outline-none"}),S?c.jsxs("button",{type:"button",onClick:k,className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{children:`search:"${x}"`}),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):null,w?c.jsxs("button",{type:"button",onClick:I,className:"flex items-center gap-1.5 rounded bg-zinc-900 px-2 py-1 font-mono text-xs text-zinc-200 hover:bg-zinc-800",children:[c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"family:"}),j.slice(0,12),c.jsx("span",{className:"text-zinc-500","aria-hidden":"true",children:"×"})]}):null,O?c.jsx("button",{type:"button",onClick:z,className:"text-xs text-zinc-500 hover:text-zinc-300",children:"Clear filters"}):null]}),_?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):N.length===0?c.jsx("p",{className:"text-zinc-600",children:zoe(y,r)}):c.jsx(D_,{entries:N,onSelect:M=>t(`/entries/view/${M}`)})]})}function Roe(){const{id:e=""}=ip(),t=ir(),{data:n,isLoading:r}=HI(e);return c.jsxs("div",{className:"p-4",children:[c.jsx("button",{type:"button",onClick:()=>t("/entries"),className:"mb-4 text-xs text-zinc-500 hover:text-zinc-300",children:"← entries"}),r||!n?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):c.jsx(Uz,{entry:n,onSelect:i=>t(`/entries/view/${i}`)})]})}const Doe=200,yO=1e3,gO=1e4,xO={"15m":15*6e4,"1h":60*6e4,"6h":6*60*6e4,"24h":24*60*6e4},Lc="rounded border border-zinc-800 bg-zinc-900 px-2 py-1 text-xs text-zinc-300";function Loe(e){return e==="all"?{}:T_(e)}async function Boe(e,t,n,r,i){const a=[];let o;for(;a.length<n;){const s=Math.min(Doe,n-a.length),l=await e.entries({...t,limit:s,...o!==void 0?{cursor:o}:{}});let u=!1;for(const d of l.data){if(new Date(d.createdAt).getTime()<r){u=!0;break}if(a.push(d),a.length>=n)break}if(i(a.length),u||l.nextCursor===null)break;o=l.nextCursor}return a}function Foe({records:e}){return e.length===0?null:c.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800",children:c.jsxs("table",{className:"w-full min-w-[640px] text-left text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:[c.jsx("th",{className:"px-3 py-2 font-normal",children:"Filename"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Type"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Rows"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Format"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Time"})]})}),c.jsx("tbody",{children:e.map(t=>c.jsxs("tr",{className:"border-t border-zinc-800/60 hover:bg-zinc-900/40",children:[c.jsx("td",{className:"px-3 py-2 font-mono text-xs text-zinc-300",children:t.filename}),c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:t.type}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-100",children:t.rows.toLocaleString()}),c.jsx("td",{className:"px-3 py-2 text-xs uppercase text-zinc-400",children:t.format}),c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:new Date(t.at).toLocaleTimeString()})]},`${t.filename}:${t.at}`))})]})})}function Uoe(){const e=ce(),[t,n]=A.useState("all"),[r,i]=A.useState("1h"),[a,o]=A.useState(""),[s,l]=A.useState(yO),[u,d]=A.useState("json"),[f,p]=A.useState(!1),[h,g]=A.useState(null),[y,b]=A.useState(null),[v,m]=A.useState([]);async function x(){p(!0),b(null),g(0);const j=Math.min(Math.max(1,s),gO),w=Date.now()-(xO[r]??xO["1h"]),S={...Loe(t),...a.trim()!==""?{search:a.trim()}:{}};try{const O=await Boe(e,S,j,w,g),P=new Date().toISOString().replace(/[:.]/g,"-"),_=`telescope-export-${t}-${P}.${u}`;u==="csv"?sR(_,oR(O)):a0(_,O),m(N=>[{filename:_,type:t,rows:O.length,format:u,at:Date.now()},...N])}catch{b("Export failed while gathering entries.")}finally{p(!1)}}return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"px-1",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Export workbench"}),c.jsx("p",{className:"mt-1 text-xs text-zinc-600",children:"Page captured entries into a downloadable JSON or CSV file. Gathering runs in your browser against the live store, newest-first within the selected window."})]}),c.jsxs("div",{className:"flex flex-wrap items-end gap-3 rounded-lg border border-zinc-800 bg-zinc-900/40 p-4",children:[c.jsxs("label",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Type",c.jsxs("select",{value:t,onChange:j=>n(j.target.value),className:Lc,children:[c.jsx("option",{value:"all",children:"all"}),Ql.map(j=>c.jsx("option",{value:j.id,children:j.label},j.id))]})]}),c.jsxs("div",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Window",c.jsx(tc,{value:r,onChange:i})]}),c.jsxs("label",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Search",c.jsx("input",{type:"text",value:a,onChange:j=>o(j.target.value),placeholder:"content filter",className:Lc})]}),c.jsxs("label",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Limit",c.jsx("input",{type:"number",min:1,max:gO,value:s,onChange:j=>l(Number(j.target.value)||yO),className:`${Lc} w-24 tabular-nums`})]}),c.jsxs("label",{className:"flex flex-col gap-1 text-[10px] uppercase tracking-wide text-zinc-500",children:["Format",c.jsxs("select",{value:u,onChange:j=>d(j.target.value==="csv"?"csv":"json"),className:Lc,children:[c.jsx("option",{value:"json",children:"JSON"}),c.jsx("option",{value:"csv",children:"CSV"})]})]}),c.jsx("button",{type:"button",onClick:x,disabled:f,className:"rounded border border-zinc-700 px-3 py-1.5 text-[11px] text-zinc-300 hover:border-emerald-500 hover:text-emerald-400 disabled:cursor-not-allowed disabled:opacity-50",children:f?"Exporting…":"Export"}),f&&h!==null&&c.jsxs("span",{className:"text-xs tabular-nums text-zinc-500",children:["gathered ",h.toLocaleString(),"…"]})]}),y&&c.jsx("p",{className:"px-1 text-xs text-red-400",children:y}),c.jsxs("div",{className:"space-y-2",children:[c.jsx("h4",{className:"px-1 text-[10px] uppercase tracking-wide text-zinc-500",children:"Recent exports (this session)"}),v.length===0?c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-10 text-center text-xs text-zinc-600",children:"No exports yet. Pick a type, window, and format, then export."}):c.jsx(Foe,{records:v})]})]})}const bO=["#34d399","#fbbf24","#f87171","#38bdf8","#a78bfa"];function wO(e,t){return t||(bO[e%bO.length]??"#71717a")}function Woe({title:e,segments:t,style:n="donut",height:r=220}){const i=r-64;if(n==="bar"){const o=[{name:"breakdown",...Object.fromEntries(t.map(s=>[s.label,s.value]))}];return c.jsx(Aa,{title:e,height:i,children:c.jsx(Ea,{width:"100%",height:"100%",children:c.jsxs(Dd,{data:o,layout:"vertical",children:[c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa}),t.map((s,l)=>c.jsx(rr,{dataKey:s.label,stackId:"a",fill:wO(l,s.color),isAnimationActive:!1},s.label))]})})})}const a=t.map((o,s)=>({name:o.label,value:o.value,fill:wO(s,o.color)}));return c.jsx(Aa,{title:e,height:i,children:c.jsx(Ea,{width:"100%",height:"100%",children:c.jsxs(Jie,{children:[c.jsx(Fr,{data:a,dataKey:"value",nameKey:"name",innerRadius:"55%",outerRadius:"80%",isAnimationActive:!1,children:a.map(o=>c.jsx($a,{fill:o.fill},o.name))}),c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa})]})})})}function qoe(e){return e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`}function Hoe({title:e,buckets:t,p50:n,p95:r,p99:i,height:a=220}){const o=[];n!==void 0&&o.push([n,"p50","#34d399"]),r!==void 0&&o.push([r,"p95","#fbbf24"]),i!==void 0&&o.push([i,"p99","#f87171"]);const s=a-64;return c.jsxs(Aa,{title:e,height:s,children:[o.length>0&&c.jsx("div",{style:{display:"flex",gap:8,marginBottom:6,flexWrap:"wrap"},children:o.map(([l,u,d])=>c.jsxs("span",{style:{fontSize:10,fontVariantNumeric:"tabular-nums",color:d,background:`${d}22`,border:`1px solid ${d}55`,borderRadius:4,padding:"1px 6px"},children:[u,": ",qoe(l)]},u))}),c.jsx(Ea,{width:"100%",height:"100%",children:c.jsxs(Dd,{data:t,margin:{top:4,right:8,bottom:0,left:-16},children:[c.jsx(ms,{stroke:Te.gridStroke,vertical:!1}),c.jsx(Cr,{dataKey:"label",tick:Gn,stroke:Te.axisStroke,tickLine:!1}),c.jsx(Mr,{tick:Gn,stroke:Te.axisStroke,tickLine:!1,allowDecimals:!1,width:40}),c.jsx(Pt,{contentStyle:Sa,labelStyle:Oa,itemStyle:Pa}),c.jsx(rr,{dataKey:"count",fill:"#0ea5e9",radius:[3,3,0,0],isAnimationActive:!1})]})})]})}function Koe({title:e,value:t,min:n=0,max:r=1,label:i,color:a="#34d399",height:o=220}){const s=r-n,l=s===0?0:Math.max(0,Math.min(1,(t-n)/s)),u=i??`${Math.round(l*100)}%`,d=o-64,f=[{value:l*100,fill:a}];return c.jsx(Aa,{title:e,height:d,children:c.jsxs("div",{style:{position:"relative",height:d},children:[c.jsx(Ea,{width:"100%",height:"100%",children:c.jsx(Zie,{innerRadius:"60%",outerRadius:"100%",data:f,startAngle:180,endAngle:0,barSize:16,children:c.jsx(Ju,{dataKey:"value",cornerRadius:4,isAnimationActive:!1})})}),c.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",paddingTop:"40%"},children:c.jsx("span",{style:{fontSize:20,fontWeight:600,color:"#e4e4e7"},children:u})})]})})}function Voe(e,t){return t==="percent"?`${Math.round(e*100)}%`:t==="duration"?e>=1e3?`${(e/1e3).toFixed(1)}s`:`${Math.round(e)}ms`:t==="rate"?`${new Intl.NumberFormat().format(Math.round(e))}/hr`:new Intl.NumberFormat().format(e)}function Goe(e,t){const n=e.replace(/\{(\w+)\}/g,(r,i)=>String(t[i]??""));return/^\s*(javascript|data|vbscript):/i.test(n)?"#":n}function Qoe({title:e}){return c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40",children:[c.jsx("p",{className:"border-b border-zinc-800 px-4 py-2 text-xs font-medium text-zinc-300",children:e}),c.jsx("p",{className:"px-4 py-8 text-center text-xs text-zinc-600",children:"No data in this window."})]})}function jO({columns:e,rows:t}){return c.jsxs("tbody",{children:[t.length===0?c.jsx("tr",{className:"border-t border-zinc-800/60",children:c.jsx("td",{colSpan:e.length,className:"px-4 py-6 text-center text-xs text-zinc-600",children:"No data in this window."})}):null,t.map(n=>c.jsx("tr",{className:"border-t border-zinc-800/60",children:e.map(r=>{const i=String(n[r.key]??"");return c.jsx("td",{className:"px-4 py-2 text-zinc-200",children:r.link?c.jsx("a",{className:"text-sky-400 hover:underline",href:Goe(r.link.href,n),...r.link.external?{target:"_blank",rel:"noreferrer"}:{},children:i}):i},r.key)})},e.map(r=>String(n[r.key]??"")).join("|")))]})}function SO({columns:e}){return c.jsx("thead",{children:c.jsx("tr",{children:e.map(t=>c.jsx("th",{className:"px-4 py-2 text-left text-[10px] uppercase tracking-wide text-zinc-500",children:t.label},t.key))})})}function Xoe({page:e,totalPages:t,onPageChange:n}){return c.jsxs("div",{className:"flex items-center gap-2 text-[10px] text-zinc-500",children:[c.jsx("button",{type:"button",disabled:e<=1,onClick:()=>n==null?void 0:n(e-1),className:"rounded border border-zinc-800 px-1.5 py-0.5 text-zinc-400 hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-40",children:"Prev"}),c.jsxs("span",{children:["Page ",e," of ",t]}),c.jsx("button",{type:"button",disabled:e>=t,onClick:()=>n==null?void 0:n(e+1),className:"rounded border border-zinc-800 px-1.5 py-0.5 text-zinc-400 hover:bg-zinc-800 disabled:cursor-not-allowed disabled:opacity-40",children:"Next"})]})}function Yoe({panel:e,data:t,onPageChange:n}){switch(e.kind){case"stat":{const r=t??{};return c.jsx(ze,{label:e.title,value:Voe(r.value??0,e.format),...r.value!==void 0?{currentValue:r.value}:{},...r.delta!==void 0?{delta:r.delta}:{},...r.deltaLabel?{deltaLabel:r.deltaLabel}:{},...e.spark&&r.spark?{spark:r.spark}:{},...e.thresholds?{thresholds:e.thresholds}:{},...e.accent?{accent:e.accent}:{}})}case"distribution":{const r=t??{};return c.jsx(Hoe,{title:e.title,buckets:r.buckets??[],...r.p50!==void 0?{p50:r.p50}:{},...r.p95!==void 0?{p95:r.p95}:{},...r.p99!==void 0?{p99:r.p99}:{}})}case"gauge":{const r=t??{};return c.jsx(Koe,{title:e.title,value:r.value??0,...e.min!==void 0?{min:e.min}:{},...e.max!==void 0?{max:e.max}:{}})}case"breakdown":{const r=t??{};return c.jsx(Woe,{title:e.title,segments:r.segments??[],...e.style?{style:e.style}:{}})}case"timeseries":{const r=(t==null?void 0:t.rows)??[],i=e.series[0];return e.style==="stacked"?c.jsx(mx,{title:e.title,data:r,series:e.series}):c.jsx(qa,{title:e.title,data:r.map(a=>({label:a.label,value:i?Number(a[i]??0):0}))})}case"topN":{const r=(t==null?void 0:t.items)??[],i=e.limit?r.slice(0,e.limit):r;return i.length===0?c.jsx(Qoe,{title:e.title}):c.jsx(va,{title:e.title,data:i,horizontal:!0,truncateLabel:32})}case"table":{if(e.paged){const i=t??{},a=i.rows??[],o=i.page??1,s=i.limit??(a.length||1),l=i.total??a.length,u=Math.max(1,Math.ceil(l/s));return c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40",children:[c.jsxs("div",{className:"flex items-center justify-between border-b border-zinc-800 px-4 py-2",children:[c.jsx("p",{className:"text-xs font-medium text-zinc-300",children:e.title}),c.jsx(Xoe,{page:o,totalPages:u,...n?{onPageChange:n}:{}})]}),c.jsxs("table",{className:"w-full text-sm",children:[c.jsx(SO,{columns:e.columns}),c.jsx(jO,{columns:e.columns,rows:a})]})]})}const r=(t==null?void 0:t.rows)??[];return c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40",children:[c.jsx("p",{className:"border-b border-zinc-800 px-4 py-2 text-xs font-medium text-zinc-300",children:e.title}),c.jsxs("table",{className:"w-full text-sm",children:[c.jsx(SO,{columns:e.columns}),c.jsx(jO,{columns:e.columns,rows:r})]})]})}default:return null}}const Joe={2:"md:grid-cols-2",3:"md:grid-cols-3",4:"md:grid-cols-2 lg:grid-cols-4"},Zoe=50;function ese({status:e}){const t=e==="live";return c.jsxs("span",{"data-telescope-status":e,className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] font-medium uppercase tracking-wide ${t?"bg-emerald-950/60 text-emerald-400":"bg-amber-950/60 text-amber-400"}`,children:[c.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${t?"animate-pulse bg-emerald-400":"bg-amber-400"}`}),t?"live":e]})}function tse({ext:e,panel:t}){const n=t.kind==="table"&&t.paged===!0,[r,i]=A.useState(1),a=n?{...t.data.query,page:r,limit:Zoe}:t.data.query,o=GI(e,t.data.provider,a);return o.isError?c.jsxs("div",{className:"rounded-lg border border-red-900/50 bg-red-950/30 px-4 py-3 text-sm text-red-300",children:['Failed to load "',t.title,'".']}):c.jsx(Yoe,{panel:t,data:o.data,...n?{onPageChange:i}:{}})}function nse(){var o,s;const{dashboardId:e}=ip(),t=La(),{status:n}=sz(),r=(s=(o=t.data)==null?void 0:o.dashboards)==null?void 0:s.find(l=>l.id===e);if(!r)return c.jsx("div",{className:"p-6 text-sm text-zinc-400",children:"Dashboard not found."});const i=(e==null?void 0:e.split(".")[0])??"",a=r.sections??[{panels:r.panels,cols:2}];return c.jsxs("div",{className:"p-4",children:[c.jsxs("div",{className:"mb-4 flex items-center gap-3",children:[c.jsx("h2",{className:"text-sm font-semibold text-zinc-200",children:r.label}),c.jsx(ese,{status:n})]}),a.map((l,u)=>c.jsxs("section",{className:"mb-6",children:[l.title&&c.jsx("p",{className:"mb-2 text-[10px] uppercase tracking-wide text-zinc-500",children:l.title}),c.jsx("div",{className:`grid grid-cols-1 gap-3 ${Joe[l.cols??2]}`,children:l.panels.map(d=>c.jsx(tse,{ext:i,panel:d},`${d.kind}-${d.title}`))})]},l.title??`s${u}`))]})}function rse({profile:e,selected:t,onSelect:n}){return c.jsxs("button",{type:"button",onClick:n,className:`flex w-full flex-col gap-0.5 border-b border-zinc-900 px-3 py-2 text-left hover:bg-zinc-900 ${t?"bg-zinc-900":""}`,children:[c.jsx("span",{className:"truncate font-mono text-xs text-zinc-200",title:e.familyHash??e.id,children:e.familyHash??"(unlabelled)"}),c.jsxs("span",{className:"flex items-center gap-2 text-[10px] text-zinc-500",children:[c.jsx("span",{children:e.durationMs!==null?Xl(e.durationMs):"—"}),e.tags.includes("manual")&&c.jsx("span",{className:"text-amber-400",children:"manual"}),e.tags.includes("sampled")&&c.jsx("span",{className:"text-sky-400",children:"sampled"}),c.jsx("span",{className:"ml-auto",children:Ha(new Date(e.createdAt).getTime())})]})]})}function ise({hot:e}){return e.length===0?c.jsx("p",{className:"text-xs text-zinc-600",children:"No hot frames."}):c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40",children:[c.jsxs("div",{className:"flex items-center gap-2 border-b border-zinc-800 px-3 py-1.5 text-[10px] uppercase tracking-wide text-zinc-500",children:[c.jsx("span",{className:"flex-1",children:"Function"}),c.jsx("span",{className:"w-16 text-right",children:"Self"}),c.jsx("span",{className:"w-12 text-right",children:"%"})]}),e.map(t=>c.jsxs("div",{className:"flex items-center gap-2 border-b border-zinc-900 px-3 py-1 text-[11px] last:border-0",children:[c.jsxs("span",{className:"min-w-0 flex-1 truncate font-mono text-zinc-200",title:`${t.name} ${t.file}`,children:[t.name,t.file&&c.jsx("span",{className:"ml-1 text-zinc-600",children:t.file})]}),c.jsx("span",{className:"w-16 text-right tabular-nums text-zinc-300",children:Xl(t.selfMs)}),c.jsx("span",{className:"w-12 text-right tabular-nums text-amber-400",children:t.selfPct.toFixed(1)})]},`${t.name}:${t.file}`))]})}function ase({id:e}){const{data:t,isLoading:n}=az(e);if(n)return c.jsx("p",{className:"text-zinc-600",children:"Loading profile…"});if(!t)return c.jsx("p",{className:"text-zinc-600",children:"Profile not found."});const r=t.content;return c.jsxs("div",{className:"space-y-4",children:[c.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-4 gap-y-1",children:[c.jsx("h3",{className:"font-mono text-sm text-zinc-100",children:r.label??"(unlabelled)"}),c.jsxs("span",{className:"text-xs text-zinc-500",children:[Xl(r.durationMs)," · ",r.sampleCount," samples · ",r.reason]})]}),c.jsx(kz,{tree:r.tree}),c.jsx(ise,{hot:r.hot})]})}function ose({pendingManual:e}){const[t,n]=A.useState(1),[r,i]=A.useState(""),a=oz();return c.jsxs("div",{className:"flex flex-wrap items-center gap-2 rounded-lg border border-zinc-800 bg-zinc-900/40 px-3 py-2",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Capture next"}),c.jsx("input",{type:"number",min:1,value:t,onChange:o=>n(Math.max(1,Number(o.target.value))),className:"w-14 rounded border border-zinc-700 bg-zinc-950 px-1 py-0.5 text-xs text-zinc-200"}),c.jsx("span",{className:"text-[10px] text-zinc-500",children:"request(s) matching"}),c.jsx("input",{type:"text",placeholder:"any route (e.g. GET /users/:id)",value:r,onChange:o=>i(o.target.value),className:"w-56 rounded border border-zinc-700 bg-zinc-950 px-1 py-0.5 text-xs text-zinc-200"}),c.jsx("button",{type:"button",disabled:a.isPending,onClick:()=>a.mutate({count:t,...r?{label:r}:{}}),className:"rounded bg-emerald-600 px-2 py-0.5 text-xs font-medium text-white hover:bg-emerald-500 disabled:opacity-50",children:a.isPending?"Arming…":"Arm capture"}),e>0&&c.jsxs("span",{className:"text-[10px] text-amber-400",children:[e," pending"]}),a.isError&&c.jsx("span",{className:"text-[10px] text-rose-400",children:a.error instanceof Error?a.error.message:"Failed to arm (mutations disabled?)"})]})}function sse(){var u,d,f,p,h;const e=La(),t=rz(),{data:n,isLoading:r}=iz(100),i=(n==null?void 0:n.data)??[],[a,o]=A.useState(null),s=((d=(u=e.data)==null?void 0:u.profiling)==null?void 0:d.enabled)??((f=t.data)==null?void 0:f.enabled)??!1,l=a??((p=i[0])==null?void 0:p.id)??null;return s?c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"CPU Profiles"}),t.data&&c.jsxs("span",{className:"text-[10px] text-zinc-500",children:["sampling ",(t.data.sampleRate*100).toFixed(0),"% · ",t.data.active," active"]})]}),c.jsx(ose,{pendingManual:((h=t.data)==null?void 0:h.pendingManual)??0}),c.jsxs("div",{className:"flex gap-4",children:[c.jsx("div",{className:"w-64 shrink-0 rounded-lg border border-zinc-800",children:r?c.jsx("p",{className:"p-3 text-xs text-zinc-600",children:"Loading…"}):i.length===0?c.jsx("p",{className:"p-3 text-xs text-zinc-600",children:"No profiles captured yet."}):i.map(g=>c.jsx(rse,{profile:g,selected:g.id===l,onSelect:()=>o(g.id)},g.id))}),c.jsx("div",{className:"min-w-0 flex-1",children:l?c.jsx(ase,{id:l}):c.jsx("p",{className:"text-xs text-zinc-600",children:"Select a profile to view its flamegraph."})})]})]}):c.jsxs("div",{className:"space-y-3 p-4",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"CPU Profiles"}),c.jsxs("div",{className:"rounded-lg border border-zinc-800 bg-zinc-900/40 p-6 text-xs text-zinc-400",children:[c.jsx("p",{className:"mb-2 text-zinc-300",children:"CPU profiling is disabled."}),c.jsxs("p",{children:["Enable it with"," ",c.jsxs("code",{className:"rounded bg-zinc-800 px-1 text-emerald-300",children:["profiling: ","{"," enabled: true ","}"]})," ","in ",c.jsx("code",{className:"rounded bg-zinc-800 px-1",children:"TelescopeModule.forRoot"}),". Profiling is opt-in because it carries real CPU overhead; when off there is zero cost on the request path."]})]})]})}const lse={scheduled:"text-sky-300 bg-sky-500/10",manual:"text-amber-300 bg-amber-500/10"};function use({trigger:e}){return c.jsx("span",{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wide ${lse[e]}`,children:e})}function cse({type:e,count:t}){return c.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-zinc-800/80 px-1.5 py-0.5 text-[10px] text-zinc-300",children:[c.jsx("span",{className:"text-zinc-500",children:sp(e)}),c.jsx("span",{className:"tabular-nums text-zinc-100",children:t})]})}function fse(e){return e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function dse(e,t){if(e===null)return"—";const n=new Date(e).getTime()-t;if(Number.isNaN(n))return"—";if(n<=0)return"now";const r=Math.round(n/1e3);return r<60?`~${r}s`:`~${Math.floor(r/60)}m ${r%60}s`}function pse(){const[e,t]=A.useState(()=>Date.now());return A.useEffect(()=>{const n=setInterval(()=>t(Date.now()),1e3);return()=>clearInterval(n)},[]),e}function hse({config:e,nextRunAt:t,nowMs:n}){const r=Object.entries(e.perType??{});return c.jsxs("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-4",children:[c.jsx(ze,{label:"Window",value:wl(e.afterMs),accent:"text-emerald-400"}),c.jsx(ze,{label:"Interval",value:wl(e.intervalMs)}),c.jsx(ze,{label:"Keep last",value:e.keepLast!=null?e.keepLast.toLocaleString():"unbounded"}),c.jsx(ze,{label:"Next prune",value:dse(t,n),accent:"text-sky-300",...r.length>0?{hint:`${r.length} per-type override(s)`}:{}}),r.length>0&&c.jsxs("div",{className:"col-span-2 rounded-lg border border-zinc-800 bg-zinc-900/40 p-3 sm:col-span-4",children:[c.jsx("span",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Per-type overrides"}),c.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:r.map(([i,a])=>c.jsxs("span",{className:"inline-flex items-center gap-1 rounded bg-zinc-800/80 px-1.5 py-0.5 text-[10px] text-zinc-300",children:[c.jsx("span",{className:"text-zinc-500",children:sp(i)}),c.jsx("span",{className:"tabular-nums text-zinc-100",children:wl(a)})]},i))})]})]})}function mse({run:e}){const t=Object.entries(e.deletedByType);return c.jsxs("tr",{className:"border-t border-zinc-800/60 align-top hover:bg-zinc-900/40",children:[c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:Ha(new Date(e.at).getTime())}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(use,{trigger:e.trigger})}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-400",children:fse(e.durationMs)}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-100",children:e.deletedTotal.toLocaleString()}),c.jsx("td",{className:"px-3 py-2",children:t.length>0?c.jsx("div",{className:"flex flex-wrap gap-1",children:t.map(([n,r])=>c.jsx(cse,{type:n,count:r},n))}):c.jsx("span",{className:"text-zinc-600",children:"—"})}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-400",children:e.archivedTotal!=null?e.archivedTotal.toLocaleString():"—"}),c.jsx("td",{className:"px-3 py-2 text-xs text-red-400",children:e.error??""})]})}function vse(){var d;const{data:e,isLoading:t,isError:n}=BI(),r=La(),i=E_(),a=pse(),o=((d=r.data)==null?void 0:d.pruneEnabled)??!1,s=(e==null?void 0:e.runs)??[],l=(e==null?void 0:e.config)??null;async function u(){if(globalThis.confirm("Prune now deletes entries older than the retention window. Continue?"))try{const f=await i.mutateAsync();globalThis.alert(`Pruned ${f.pruned} ${f.pruned===1?"entry":"entries"}.`)}catch{globalThis.alert("Prune failed.")}}return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between px-1",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Prune activity"}),c.jsx("button",{type:"button",onClick:u,disabled:!o||i.isPending,title:o?"Run a prune cycle now":"Mutations are disabled (configure authorizeAction to enable on-demand pruning).",className:"rounded border border-zinc-700 px-2.5 py-1 text-[11px] text-zinc-300 hover:border-emerald-500 hover:text-emerald-400 disabled:cursor-not-allowed disabled:opacity-50",children:i.isPending?"Pruning…":"Prune now"})]}),l?c.jsx(hse,{config:l,nextRunAt:(e==null?void 0:e.nextRunAt)??null,nowMs:a}):c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-6 text-center text-xs text-zinc-600",children:"No retention window is configured. Set a `prune` option to enable automatic pruning."}),t&&c.jsx("p",{className:"px-1 py-2 text-xs text-zinc-600",children:"Loading prune runs…"}),n&&c.jsx("p",{className:"px-1 py-2 text-xs text-red-400",children:"Failed to load prune runs."}),!t&&!n&&s.length===0&&c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-12 text-center text-xs text-zinc-600",children:"No prune runs recorded yet on this pod."}),s.length>0&&c.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800",children:c.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:[c.jsx("th",{className:"px-3 py-2 font-normal",children:"Time"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Trigger"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Duration"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Deleted"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"By type"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Archived"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Error"})]})}),c.jsx("tbody",{children:s.map((f,p)=>c.jsx(mse,{run:f},`${f.at}:${p}`))})]})})]})}function yse(){var s;const[e,t]=A.useState("1h"),n=ir(),{data:r,isLoading:i}=N_(e),a=n0({window:e,buckets:60}),o=yx(((s=a.data)==null?void 0:s.buckets)??[]);return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"Pulse"}),c.jsx(tc,{value:e,onChange:t})]}),c.jsx(mx,{title:"Throughput by type",series:o,data:Bk(a.data)}),i||!r?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):c.jsx(xae,{report:r,onSelectEntry:l=>n(`/entries/view/${l}`),onSelectFamily:l=>n(`/entries/query?familyHash=${encodeURIComponent(l)}`),onSelectRoute:l=>n(`/entries/request?familyHash=${encodeURIComponent(l)}`),onSelectOutgoing:l=>n(`/entries/http_client?familyHash=${encodeURIComponent(l)}`)})]})}const gse="#f87171",xse="#34d399";function bse(e){return((e==null?void 0:e.queues)??[]).map(t=>({label:t.queue,value:Number((t.failureRate*100).toFixed(1)),color:t.failureRate>0?gse:xse}))}function wse(){const[e,t]=A.useState("1h"),{data:n,isLoading:r}=k_(e);return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"Queue metrics"}),c.jsx(tc,{value:e,onChange:t})]}),c.jsx(va,{title:"Failure rate by queue",valueLabel:"fail %",data:bse(n)}),r||!n?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):c.jsx(bae,{report:n,sparkline:i=>c.jsx(jae,{queue:i,window:e})})]})}const jse=[{to:"/queues",label:"Manage",end:!0},{to:"/queues/metrics",label:"Metrics",end:!1}];function Sse(){return c.jsxs("div",{className:"space-y-1",children:[c.jsx("div",{className:"flex gap-1 border-b border-zinc-800 px-4 pt-3",children:jse.map(e=>c.jsx(Zc,{to:e.to,end:e.end,className:({isActive:t})=>`rounded-t-md px-3 py-1.5 text-xs transition-colors ${t?"bg-zinc-900 text-emerald-300":"text-zinc-500 hover:text-zinc-300"}`,children:e.label},e.to))}),c.jsx(WM,{})]})}const Ose={cron:"text-emerald-300 bg-emerald-500/10",interval:"text-sky-300 bg-sky-500/10",timeout:"text-amber-300 bg-amber-500/10"};function Pse({kind:e}){return c.jsx("span",{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wide ${Ose[e]}`,children:e})}function Ase({running:e}){return e==null?c.jsx("span",{className:"rounded bg-zinc-500/10 px-1.5 py-0.5 text-[9px] uppercase tracking-wide text-zinc-500",children:"unknown"}):c.jsxs("span",{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wide ${e?"bg-emerald-500/10 text-emerald-300":"bg-red-500/10 text-red-300"}`,children:[c.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${e?"bg-emerald-400":"bg-red-400"}`}),e?"active":"stopped"]})}function _se({status:e}){if(e===null)return c.jsx("span",{className:"text-zinc-600",children:"—"});const t=e==="completed"?"text-emerald-300 bg-emerald-500/10":"text-red-300 bg-red-500/10";return c.jsx("span",{className:`rounded px-1.5 py-0.5 text-[9px] uppercase tracking-wide ${t}`,children:e})}function Ese(e){return e===null?"—":e<1e3?`${e}ms`:`${(e/1e3).toFixed(2)}s`}function $se(e){if(e===null)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function Nse({task:e}){return c.jsxs("tr",{className:"border-t border-zinc-800/60 hover:bg-zinc-900/40",children:[c.jsx("td",{className:"px-3 py-2 font-medium text-zinc-100",children:e.name}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(Pse,{kind:e.kind})}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(Ase,{running:e.running})}),c.jsx("td",{className:"px-3 py-2 font-mono text-xs text-zinc-400",children:e.schedule}),c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:$se(e.nextRunAt)}),c.jsx("td",{className:"px-3 py-2 text-xs text-zinc-400",children:Ha(kse(e.lastRunAt))}),c.jsx("td",{className:"px-3 py-2 text-xs tabular-nums text-zinc-400",children:Ese(e.lastDurationMs)}),c.jsx("td",{className:"px-3 py-2",children:c.jsx(_se,{status:e.lastStatus})})]})}function kse(e){if(e===null)return null;const t=new Date(e).getTime();return Number.isNaN(t)?null:t}function Tse(){const{data:e,isLoading:t,isError:n}=MI(),r=(e==null?void 0:e.tasks)??[],i=r.filter(o=>o.running===!0).length,a=r.filter(o=>o.running===!1).length;return c.jsxs("div",{className:"space-y-3 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between px-1",children:[c.jsx("h3",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:"Scheduled tasks"}),r.length>0&&c.jsxs("div",{className:"flex items-center gap-3 text-[10px] uppercase tracking-wide",children:[c.jsxs("span",{className:"text-emerald-400",children:[i," active"]}),a>0&&c.jsxs("span",{className:"text-red-400",children:[a," stopped"]}),c.jsxs("span",{className:"text-zinc-600",children:[r.length," total"]})]})]}),t&&c.jsx("p",{className:"px-1 py-2 text-xs text-zinc-600",children:"Loading schedules…"}),n&&c.jsx("p",{className:"px-1 py-2 text-xs text-red-400",children:"Failed to load schedules."}),!t&&!n&&r.length===0&&c.jsx("div",{className:"rounded-lg border border-dashed border-zinc-800 px-4 py-12 text-center text-xs text-zinc-600",children:"No scheduled tasks detected. Register a ScheduleManager (the @nestjs/schedule watcher) to populate this console."}),r.length>0&&c.jsx("div",{className:"overflow-x-auto rounded-lg border border-zinc-800",children:c.jsxs("table",{className:"w-full min-w-[760px] text-left text-sm",children:[c.jsx("thead",{children:c.jsxs("tr",{className:"text-[10px] uppercase tracking-wide text-zinc-500",children:[c.jsx("th",{className:"px-3 py-2 font-normal",children:"Name"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Kind"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Active"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Schedule"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Next run"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Last run"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Duration"}),c.jsx("th",{className:"px-3 py-2 font-normal",children:"Status"})]})}),c.jsx("tbody",{children:r.map(o=>c.jsx(Nse,{task:o},`${o.kind}:${o.name}`))})]})})]})}function Cse(){const{traceId:e=""}=ip(),t=ir(),[n,r]=A.useState("waterfall"),{data:i,isLoading:a}=$_({traceId:e}),o=(i==null?void 0:i.data)??[],{data:s,isLoading:l}=ZI(e);return c.jsxs("div",{className:"p-4",children:[c.jsx("button",{type:"button",onClick:()=>t("/entries"),className:"mb-4 text-xs text-zinc-500 hover:text-zinc-300",children:"← entries"}),c.jsxs("div",{className:"mb-4 flex flex-wrap items-baseline gap-3 border-b border-zinc-800 pb-3",children:[c.jsx("h2",{className:"text-xs uppercase tracking-wide text-zinc-500",children:"Trace"}),c.jsx("span",{className:"max-w-md truncate font-mono text-xs text-zinc-300",title:e,children:e}),c.jsxs("span",{className:"text-xs text-zinc-500",children:[o.length," ",o.length===1?"entry":"entries"]}),c.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[c.jsxs("div",{className:"flex overflow-hidden rounded border border-zinc-700 text-[11px]",children:[c.jsx("button",{type:"button",onClick:()=>r("waterfall"),className:`px-2.5 py-1 transition-colors ${n==="waterfall"?"bg-zinc-800 text-zinc-100":"bg-zinc-900 text-zinc-400 hover:text-zinc-200"}`,children:"Waterfall"}),c.jsx("button",{type:"button",onClick:()=>r("entries"),className:`border-l border-zinc-700 px-2.5 py-1 transition-colors ${n==="entries"?"bg-zinc-800 text-zinc-100":"bg-zinc-900 text-zinc-400 hover:text-zinc-200"}`,children:"Entries"})]}),o.length>0?c.jsx("button",{type:"button",onClick:()=>a0(`telescope-trace-${e}.json`,o),className:"rounded border border-zinc-700 bg-zinc-900 px-2.5 py-1 text-[11px] text-zinc-300 transition-colors hover:border-zinc-600 hover:bg-zinc-800 hover:text-zinc-100",children:"Download JSON"}):null]})]}),n==="waterfall"?l?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):s===void 0||s.spans.length===0?c.jsx("p",{className:"text-zinc-600",children:"No spans in this trace"}):c.jsx(_z,{waterfall:s,onSelect:u=>t(`/entries/view/${u}`)}):a?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):o.length===0?c.jsx("p",{className:"text-zinc-600",children:"No entries in this trace"}):c.jsx(D_,{entries:o,onSelect:u=>t(`/entries/view/${u}`)})]})}function Mse(e){return e<1e3?`${Math.round(e)}ms`:`${(e/1e3).toFixed(2)}s`}function Ise({trace:e}){const t=ir(),n=e.rootLabel??e.traceId;return c.jsxs("button",{type:"button",onClick:()=>t(`/traces/${e.traceId}`),className:"flex w-full items-center gap-3 border-b border-zinc-900 px-3 py-2 text-left hover:bg-zinc-900",children:[c.jsx("span",{className:"flex shrink-0 items-center gap-1","aria-hidden":"true",children:e.types.map(r=>c.jsx("span",{className:`h-2 w-2 rounded-full ${r0(r)}`,title:r},r))}),c.jsx("span",{className:"min-w-0 flex-1 truncate font-mono text-xs text-zinc-200",title:n,children:n}),c.jsxs("span",{className:"shrink-0 text-xs text-zinc-500",children:[e.entryCount," ",e.entryCount===1?"entry":"entries"]}),c.jsx("span",{className:"w-16 shrink-0 text-right text-xs text-zinc-400",children:Mse(e.totalDurationMs)}),c.jsx("span",{className:"w-16 shrink-0 text-right text-xs text-zinc-600",children:Ha(new Date(e.lastAt).getTime())})]})}function zse(){const[e,t]=A.useState("1h"),{data:n,isLoading:r}=JI(e),i=(n==null?void 0:n.traces)??[];return c.jsxs("div",{className:"space-y-4 p-4",children:[c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx("h2",{className:"text-sm text-emerald-400",children:"Traces"}),c.jsx(tc,{value:e,onChange:t})]}),r?c.jsx("p",{className:"text-zinc-600",children:"Loading…"}):i.length===0?c.jsx("p",{className:"text-zinc-600",children:"No traces in this window"}):c.jsx("div",{className:"border border-zinc-800",children:i.map(a=>c.jsx(Ise,{trace:a},a.traceId))})]})}const Rse=new B2;function Dse(){return c.jsx(eI,{children:c.jsx(doe,{children:c.jsxs(HM,{children:[c.jsx(jt,{path:"/",element:c.jsx(Moe,{})}),c.jsx(jt,{path:"/entries",element:c.jsx(vO,{})}),c.jsx(jt,{path:"/entries/view/:id",element:c.jsx(Roe,{})}),c.jsx(jt,{path:"/entries/:type",element:c.jsx(vO,{})}),c.jsx(jt,{path:"/traces",element:c.jsx(zse,{})}),c.jsx(jt,{path:"/traces/:traceId",element:c.jsx(Cse,{})}),c.jsx(jt,{path:"/pulse",element:c.jsx(yse,{})}),c.jsxs(jt,{path:"/queues",element:c.jsx(Sse,{}),children:[c.jsx(jt,{index:!0,element:c.jsx(Ioe,{})}),c.jsx(jt,{path:"metrics",element:c.jsx(wse,{})})]}),c.jsx(jt,{path:"/schedules",element:c.jsx(Tse,{})}),c.jsx(jt,{path:"/prunes",element:c.jsx(vse,{})}),c.jsx(jt,{path:"/exports",element:c.jsx(Uoe,{})}),c.jsx(jt,{path:"/profiles",element:c.jsx(sse,{})}),c.jsx(jt,{path:"/ext/:dashboardId",element:c.jsx(nse,{})})]})})})}function Lse(){const{phase:e,modes:t}=bx();return e==="loading"?c.jsx("div",{className:"min-h-screen bg-zinc-950","data-testid":"auth-loading"}):e==="screen"?c.jsx(Xae,{modes:t}):c.jsx(Dse,{})}function Bse(){return c.jsx(roe,{children:c.jsx(cI,{children:c.jsx(F2,{client:Rse,children:c.jsx(Hae,{children:c.jsx(Lse,{})})})})})}const OO=document.getElementById("root");OO&&GA(OO).render(c.jsx(A.StrictMode,{children:c.jsx(Bse,{})}));