tokenrace 0.1.15 → 0.1.17
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.
- package/dist/assets/{index-Cy4B5yrR.js → index-BeIgeSpB.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/git-detector.js +61 -0
- package/src/server.js +20 -1
- package/src/store.js +74 -2
|
@@ -189,4 +189,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
189
189
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function B7(e,t){if(e){if(typeof e=="string")return wb(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 wb(e,t)}}function L7(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function k7(e){if(Array.isArray(e))return wb(e)}function wb(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 U7(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function j2(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,qN(r.key),r)}}function I7(e,t,n){return t&&j2(e.prototype,t),n&&j2(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function H7(e,t,n){return t=gf(t),G7(e,$N()?Reflect.construct(t,n||[],gf(e).constructor):t.apply(e,n))}function G7(e,t){if(t&&(To(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Y7(e)}function Y7(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function $N(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return($N=function(){return!!e})()}function gf(e){return gf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},gf(e)}function X7(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&&Tb(e,t)}function Tb(e,t){return Tb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Tb(e,t)}function In(e,t,n){return t=qN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qN(e){var t=K7(e,"string");return To(t)=="symbol"?t:t+""}function K7(e,t){if(To(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(To(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Il=(function(e){function t(){var n;U7(this,t);for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];return n=H7(this,t,[].concat(o)),In(n,"state",{isAnimationFinished:!0,totalLength:0}),In(n,"generateSimpleStrokeDasharray",function(c,f){return"".concat(f,"px ").concat(c-f,"px")}),In(n,"getStrokeDasharray",function(c,f,d){var h=d.reduce(function(w,E){return w+E});if(!h)return n.generateSimpleStrokeDasharray(f,c);for(var v=Math.floor(c/h),y=c%h,g=f-c,x=[],_=0,S=0;_<d.length;S+=d[_],++_)if(S+d[_]>y){x=[].concat(Ji(d.slice(0,_)),[y-S]);break}var b=x.length%2===0?[0,g]:[g];return[].concat(Ji(t.repeat(d,v)),Ji(x),b).map(function(w){return"".concat(w,"px")}).join(", ")}),In(n,"id",$o("recharts-line-")),In(n,"pathRef",function(c){n.mainCurve=c}),In(n,"handleAnimationEnd",function(){n.setState({isAnimationFinished:!0}),n.props.onAnimationEnd&&n.props.onAnimationEnd()}),In(n,"handleAnimationStart",function(){n.setState({isAnimationFinished:!1}),n.props.onAnimationStart&&n.props.onAnimationStart()}),n}return X7(t,e),I7(t,[{key:"componentDidMount",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();this.setState({totalLength:r})}}},{key:"componentDidUpdate",value:function(){if(this.props.isAnimationActive){var r=this.getTotalLength();r!==this.state.totalLength&&this.setState({totalLength:r})}}},{key:"getTotalLength",value:function(){var r=this.mainCurve;try{return r&&r.getTotalLength&&r.getTotalLength()||0}catch{return 0}}},{key:"renderErrorBar",value:function(r,o){if(this.props.isAnimationActive&&!this.state.isAnimationFinished)return null;var l=this.props,c=l.points,f=l.xAxis,d=l.yAxis,h=l.layout,v=l.children,y=Nn(v,kl);if(!y)return null;var g=function(S,b){return{x:S.x,y:S.y,value:S.value,errorVal:Yt(S.payload,b)}},x={clipPath:r?"url(#clipPath-".concat(o,")"):null};return L.createElement(Je,x,y.map(function(_){return L.cloneElement(_,{key:"bar-".concat(_.props.dataKey),data:c,xAxis:f,yAxis:d,layout:h,dataPointFormatter:g})}))}},{key:"renderDots",value:function(r,o,l){var c=this.props.isAnimationActive;if(c&&!this.state.isAnimationFinished)return null;var f=this.props,d=f.dot,h=f.points,v=f.dataKey,y=Ee(this.props,!1),g=Ee(d,!0),x=h.map(function(S,b){var w=fn(fn(fn({key:"dot-".concat(b),r:3},y),g),{},{index:b,cx:S.x,cy:S.y,value:S.value,dataKey:v,payload:S.payload,points:h});return t.renderDotItem(d,w)}),_={clipPath:r?"url(#clipPath-".concat(o?"":"dots-").concat(l,")"):null};return L.createElement(Je,Wu({className:"recharts-line-dots",key:"dots"},_),x)}},{key:"renderCurveStatically",value:function(r,o,l,c){var f=this.props,d=f.type,h=f.layout,v=f.connectNulls;f.ref;var y=T2(f,R7),g=fn(fn(fn({},Ee(y,!0)),{},{fill:"none",className:"recharts-line-curve",clipPath:o?"url(#clipPath-".concat(l,")"):null,points:r},c),{},{type:d,layout:h,connectNulls:v});return L.createElement(oo,Wu({},g,{pathRef:this.pathRef}))}},{key:"renderCurveWithAnimation",value:function(r,o){var l=this,c=this.props,f=c.points,d=c.strokeDasharray,h=c.isAnimationActive,v=c.animationBegin,y=c.animationDuration,g=c.animationEasing,x=c.animationId,_=c.animateNewValues,S=c.width,b=c.height,w=this.state,E=w.prevPoints,j=w.totalLength;return L.createElement(ar,{begin:v,duration:y,isActive:h,easing:g,from:{t:0},to:{t:1},key:"line-".concat(x),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(N){var A=N.t;if(E){var T=E.length/f.length,C=f.map(function(B,V){var W=Math.floor(V*T);if(E[W]){var F=E[W],R=$t(F.x,B.x),G=$t(F.y,B.y);return fn(fn({},B),{},{x:R(A),y:G(A)})}if(_){var ee=$t(S*2,B.x),oe=$t(b/2,B.y);return fn(fn({},B),{},{x:ee(A),y:oe(A)})}return fn(fn({},B),{},{x:B.x,y:B.y})});return l.renderCurveStatically(C,r,o)}var $=$t(0,j),z=$(A),Z;if(d){var U="".concat(d).split(/[,\s]+/gim).map(function(B){return parseFloat(B)});Z=l.getStrokeDasharray(z,j,U)}else Z=l.generateSimpleStrokeDasharray(j,z);return l.renderCurveStatically(f,r,o,{strokeDasharray:Z})})}},{key:"renderCurve",value:function(r,o){var l=this.props,c=l.points,f=l.isAnimationActive,d=this.state,h=d.prevPoints,v=d.totalLength;return f&&c&&c.length&&(!h&&v>0||!yo(h,c))?this.renderCurveWithAnimation(r,o):this.renderCurveStatically(c,r,o)}},{key:"render",value:function(){var r,o=this.props,l=o.hide,c=o.dot,f=o.points,d=o.className,h=o.xAxis,v=o.yAxis,y=o.top,g=o.left,x=o.width,_=o.height,S=o.isAnimationActive,b=o.id;if(l||!f||!f.length)return null;var w=this.state.isAnimationFinished,E=f.length===1,j=$e("recharts-line",d),N=h&&h.allowDataOverflow,A=v&&v.allowDataOverflow,T=N||A,C=je(b)?this.id:b,$=(r=Ee(c,!1))!==null&&r!==void 0?r:{r:3,strokeWidth:2},z=$.r,Z=z===void 0?3:z,U=$.strokeWidth,B=U===void 0?2:U,V=Q2(c)?c:{},W=V.clipDot,F=W===void 0?!0:W,R=Z*2+B;return L.createElement(Je,{className:j},N||A?L.createElement("defs",null,L.createElement("clipPath",{id:"clipPath-".concat(C)},L.createElement("rect",{x:N?g:g-x/2,y:A?y:y-_/2,width:N?x:x*2,height:A?_:_*2})),!F&&L.createElement("clipPath",{id:"clipPath-dots-".concat(C)},L.createElement("rect",{x:g-R/2,y:y-R/2,width:x+R,height:_+R}))):null,!E&&this.renderCurve(T,C),this.renderErrorBar(T,C),(E||c)&&this.renderDots(T,F,C),(!S||w)&&Pr.renderCallByParent(this.props,f))}}],[{key:"getDerivedStateFromProps",value:function(r,o){return r.animationId!==o.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,prevPoints:o.curPoints}:r.points!==o.curPoints?{curPoints:r.points}:null}},{key:"repeat",value:function(r,o){for(var l=r.length%2!==0?[].concat(Ji(r),[0]):r,c=[],f=0;f<o;++f)c=[].concat(Ji(c),Ji(l));return c}},{key:"renderDotItem",value:function(r,o){var l;if(L.isValidElement(r))l=L.cloneElement(r,o);else if(Ae(r))l=r(o);else{var c=o.key,f=T2(o,$7),d=$e("recharts-line-dot",typeof r!="boolean"?r.className:"");l=L.createElement(Yf,Wu({key:c},f,{className:d}))}return l}}])})(Q.PureComponent);In(Il,"displayName","Line");In(Il,"defaultProps",{xAxisId:0,yAxisId:0,connectNulls:!1,activeDot:!0,dot:!0,legendType:"line",stroke:"#3182bd",strokeWidth:1,fill:"#fff",points:[],isAnimationActive:!ui.isSsr,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:"ease",hide:!1,label:!1});In(Il,"getComposedData",function(e){var t=e.props,n=e.xAxis,r=e.yAxis,o=e.xAxisTicks,l=e.yAxisTicks,c=e.dataKey,f=e.bandSize,d=e.displayedData,h=e.offset,v=t.layout,y=d.map(function(g,x){var _=Yt(g,c);return v==="horizontal"?{x:Zs({axis:n,ticks:o,bandSize:f,entry:g,index:x}),y:je(_)?null:r.scale(_),value:_,payload:g}:{x:je(_)?null:n.scale(_),y:Zs({axis:r,ticks:l,bandSize:f,entry:g,index:x}),value:_,payload:g}});return fn({points:y,layout:v},h)});var V7=["layout","type","stroke","connectNulls","isRange","ref"],F7=["key"],zN;function Eo(e){"@babel/helpers - typeof";return Eo=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},Eo(e)}function BN(e,t){if(e==null)return{};var n=Z7(e,t),r,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)r=l[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function Z7(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 Qa(){return Qa=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},Qa.apply(this,arguments)}function M2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function pa(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?M2(Object(n),!0).forEach(function(r){Jn(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):M2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Q7(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function C2(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,kN(r.key),r)}}function W7(e,t,n){return t&&C2(e.prototype,t),n&&C2(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function J7(e,t,n){return t=bf(t),eG(e,LN()?Reflect.construct(t,n||[],bf(e).constructor):t.apply(e,n))}function eG(e,t){if(t&&(Eo(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return tG(e)}function tG(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function LN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(LN=function(){return!!e})()}function bf(e){return bf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},bf(e)}function nG(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&&Eb(e,t)}function Eb(e,t){return Eb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Eb(e,t)}function Jn(e,t,n){return t=kN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function kN(e){var t=rG(e,"string");return Eo(t)=="symbol"?t:t+""}function rG(e,t){if(Eo(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Eo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var Yn=(function(e){function t(){var n;Q7(this,t);for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];return n=J7(this,t,[].concat(o)),Jn(n,"state",{isAnimationFinished:!0}),Jn(n,"id",$o("recharts-area-")),Jn(n,"handleAnimationEnd",function(){var c=n.props.onAnimationEnd;n.setState({isAnimationFinished:!0}),Ae(c)&&c()}),Jn(n,"handleAnimationStart",function(){var c=n.props.onAnimationStart;n.setState({isAnimationFinished:!1}),Ae(c)&&c()}),n}return nG(t,e),W7(t,[{key:"renderDots",value:function(r,o,l){var c=this.props.isAnimationActive,f=this.state.isAnimationFinished;if(c&&!f)return null;var d=this.props,h=d.dot,v=d.points,y=d.dataKey,g=Ee(this.props,!1),x=Ee(h,!0),_=v.map(function(b,w){var E=pa(pa(pa({key:"dot-".concat(w),r:3},g),x),{},{index:w,cx:b.x,cy:b.y,dataKey:y,value:b.value,payload:b.payload,points:v});return t.renderDotItem(h,E)}),S={clipPath:r?"url(#clipPath-".concat(o?"":"dots-").concat(l,")"):null};return L.createElement(Je,Qa({className:"recharts-area-dots"},S),_)}},{key:"renderHorizontalRect",value:function(r){var o=this.props,l=o.baseLine,c=o.points,f=o.strokeWidth,d=c[0].x,h=c[c.length-1].x,v=r*Math.abs(d-h),y=ma(c.map(function(g){return g.y||0}));return fe(l)&&typeof l=="number"?y=Math.max(l,y):l&&Array.isArray(l)&&l.length&&(y=Math.max(ma(l.map(function(g){return g.y||0})),y)),fe(y)?L.createElement("rect",{x:d<h?d:d-v,y:0,width:v,height:Math.floor(y+(f?parseInt("".concat(f),10):1))}):null}},{key:"renderVerticalRect",value:function(r){var o=this.props,l=o.baseLine,c=o.points,f=o.strokeWidth,d=c[0].y,h=c[c.length-1].y,v=r*Math.abs(d-h),y=ma(c.map(function(g){return g.x||0}));return fe(l)&&typeof l=="number"?y=Math.max(l,y):l&&Array.isArray(l)&&l.length&&(y=Math.max(ma(l.map(function(g){return g.x||0})),y)),fe(y)?L.createElement("rect",{x:0,y:d<h?d:d-v,width:y+(f?parseInt("".concat(f),10):1),height:Math.floor(v)}):null}},{key:"renderClipRect",value:function(r){var o=this.props.layout;return o==="vertical"?this.renderVerticalRect(r):this.renderHorizontalRect(r)}},{key:"renderAreaStatically",value:function(r,o,l,c){var f=this.props,d=f.layout,h=f.type,v=f.stroke,y=f.connectNulls,g=f.isRange;f.ref;var x=BN(f,V7);return L.createElement(Je,{clipPath:l?"url(#clipPath-".concat(c,")"):null},L.createElement(oo,Qa({},Ee(x,!0),{points:r,connectNulls:y,type:h,baseLine:o,layout:d,stroke:"none",className:"recharts-area-area"})),v!=="none"&&L.createElement(oo,Qa({},Ee(this.props,!1),{className:"recharts-area-curve",layout:d,type:h,connectNulls:y,fill:"none",points:r})),v!=="none"&&g&&L.createElement(oo,Qa({},Ee(this.props,!1),{className:"recharts-area-curve",layout:d,type:h,connectNulls:y,fill:"none",points:o})))}},{key:"renderAreaWithAnimation",value:function(r,o){var l=this,c=this.props,f=c.points,d=c.baseLine,h=c.isAnimationActive,v=c.animationBegin,y=c.animationDuration,g=c.animationEasing,x=c.animationId,_=this.state,S=_.prevPoints,b=_.prevBaseLine;return L.createElement(ar,{begin:v,duration:y,isActive:h,easing:g,from:{t:0},to:{t:1},key:"area-".concat(x),onAnimationEnd:this.handleAnimationEnd,onAnimationStart:this.handleAnimationStart},function(w){var E=w.t;if(S){var j=S.length/f.length,N=f.map(function($,z){var Z=Math.floor(z*j);if(S[Z]){var U=S[Z],B=$t(U.x,$.x),V=$t(U.y,$.y);return pa(pa({},$),{},{x:B(E),y:V(E)})}return $}),A;if(fe(d)&&typeof d=="number"){var T=$t(b,d);A=T(E)}else if(je(d)||Ro(d)){var C=$t(b,0);A=C(E)}else A=d.map(function($,z){var Z=Math.floor(z*j);if(b[Z]){var U=b[Z],B=$t(U.x,$.x),V=$t(U.y,$.y);return pa(pa({},$),{},{x:B(E),y:V(E)})}return $});return l.renderAreaStatically(N,A,r,o)}return L.createElement(Je,null,L.createElement("defs",null,L.createElement("clipPath",{id:"animationClipPath-".concat(o)},l.renderClipRect(E))),L.createElement(Je,{clipPath:"url(#animationClipPath-".concat(o,")")},l.renderAreaStatically(f,d,r,o)))})}},{key:"renderArea",value:function(r,o){var l=this.props,c=l.points,f=l.baseLine,d=l.isAnimationActive,h=this.state,v=h.prevPoints,y=h.prevBaseLine,g=h.totalLength;return d&&c&&c.length&&(!v&&g>0||!yo(v,c)||!yo(y,f))?this.renderAreaWithAnimation(r,o):this.renderAreaStatically(c,f,r,o)}},{key:"render",value:function(){var r,o=this.props,l=o.hide,c=o.dot,f=o.points,d=o.className,h=o.top,v=o.left,y=o.xAxis,g=o.yAxis,x=o.width,_=o.height,S=o.isAnimationActive,b=o.id;if(l||!f||!f.length)return null;var w=this.state.isAnimationFinished,E=f.length===1,j=$e("recharts-area",d),N=y&&y.allowDataOverflow,A=g&&g.allowDataOverflow,T=N||A,C=je(b)?this.id:b,$=(r=Ee(c,!1))!==null&&r!==void 0?r:{r:3,strokeWidth:2},z=$.r,Z=z===void 0?3:z,U=$.strokeWidth,B=U===void 0?2:U,V=Q2(c)?c:{},W=V.clipDot,F=W===void 0?!0:W,R=Z*2+B;return L.createElement(Je,{className:j},N||A?L.createElement("defs",null,L.createElement("clipPath",{id:"clipPath-".concat(C)},L.createElement("rect",{x:N?v:v-x/2,y:A?h:h-_/2,width:N?x:x*2,height:A?_:_*2})),!F&&L.createElement("clipPath",{id:"clipPath-dots-".concat(C)},L.createElement("rect",{x:v-R/2,y:h-R/2,width:x+R,height:_+R}))):null,E?null:this.renderArea(T,C),(c||E)&&this.renderDots(T,F,C),(!S||w)&&Pr.renderCallByParent(this.props,f))}}],[{key:"getDerivedStateFromProps",value:function(r,o){return r.animationId!==o.prevAnimationId?{prevAnimationId:r.animationId,curPoints:r.points,curBaseLine:r.baseLine,prevPoints:o.curPoints,prevBaseLine:o.curBaseLine}:r.points!==o.curPoints||r.baseLine!==o.curBaseLine?{curPoints:r.points,curBaseLine:r.baseLine}:null}}])})(Q.PureComponent);zN=Yn;Jn(Yn,"displayName","Area");Jn(Yn,"defaultProps",{stroke:"#3182bd",fill:"#3182bd",fillOpacity:.6,xAxisId:0,yAxisId:0,legendType:"line",connectNulls:!1,points:[],dot:!1,activeDot:!0,hide:!1,isAnimationActive:!ui.isSsr,animationBegin:0,animationDuration:1500,animationEasing:"ease"});Jn(Yn,"getBaseValue",function(e,t,n,r){var o=e.layout,l=e.baseValue,c=t.props.baseValue,f=c??l;if(fe(f)&&typeof f=="number")return f;var d=o==="horizontal"?r:n,h=d.scale.domain();if(d.type==="number"){var v=Math.max(h[0],h[1]),y=Math.min(h[0],h[1]);return f==="dataMin"?y:f==="dataMax"||v<0?v:Math.max(Math.min(h[0],h[1]),0)}return f==="dataMin"?h[0]:f==="dataMax"?h[1]:h[0]});Jn(Yn,"getComposedData",function(e){var t=e.props,n=e.item,r=e.xAxis,o=e.yAxis,l=e.xAxisTicks,c=e.yAxisTicks,f=e.bandSize,d=e.dataKey,h=e.stackedData,v=e.dataStartIndex,y=e.displayedData,g=e.offset,x=t.layout,_=h&&h.length,S=zN.getBaseValue(t,n,r,o),b=x==="horizontal",w=!1,E=y.map(function(N,A){var T;_?T=h[v+A]:(T=Yt(N,d),Array.isArray(T)?w=!0:T=[S,T]);var C=T[1]==null||_&&Yt(N,d)==null;return b?{x:Zs({axis:r,ticks:l,bandSize:f,entry:N,index:A}),y:C?null:o.scale(T[1]),value:T,payload:N}:{x:C?null:r.scale(T[1]),y:Zs({axis:o,ticks:c,bandSize:f,entry:N,index:A}),value:T,payload:N}}),j;return _||w?j=E.map(function(N){var A=Array.isArray(N.value)?N.value[0]:null;return b?{x:N.x,y:A!=null&&N.y!=null?o.scale(A):null}:{x:A!=null?r.scale(A):null,y:N.y}}):j=b?o.scale(S):r.scale(S),pa({points:E,baseLine:j,layout:x,isRange:w},g)});Jn(Yn,"renderDotItem",function(e,t){var n;if(L.isValidElement(e))n=L.cloneElement(e,t);else if(Ae(e))n=e(t);else{var r=$e("recharts-area-dot",typeof e!="boolean"?e.className:""),o=t.key,l=BN(t,F7);n=L.createElement(Yf,Qa({},l,{key:o,className:r}))}return n});function jo(e){"@babel/helpers - typeof";return jo=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},jo(e)}function aG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function iG(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,HN(r.key),r)}}function oG(e,t,n){return t&&iG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function uG(e,t,n){return t=xf(t),lG(e,UN()?Reflect.construct(t,n||[],xf(e).constructor):t.apply(e,n))}function lG(e,t){if(t&&(jo(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return cG(e)}function cG(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function UN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(UN=function(){return!!e})()}function xf(e){return xf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},xf(e)}function sG(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&&jb(e,t)}function jb(e,t){return jb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},jb(e,t)}function IN(e,t,n){return t=HN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function HN(e){var t=fG(e,"string");return jo(t)=="symbol"?t:t+""}function fG(e,t){if(jo(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(jo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function Mb(){return Mb=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},Mb.apply(this,arguments)}function dG(e){var t=e.xAxisId,n=B0(),r=L0(),o=_N(t);return o==null?null:Q.createElement(ko,Mb({},o,{className:$e("recharts-".concat(o.axisType," ").concat(o.axisType),o.className),viewBox:{x:0,y:0,width:n,height:r},ticksGenerator:function(c){return Mr(c,!0)}}))}var kr=(function(e){function t(){return aG(this,t),uG(this,t,arguments)}return sG(t,e),oG(t,[{key:"render",value:function(){return Q.createElement(dG,this.props)}}])})(Q.Component);IN(kr,"displayName","XAxis");IN(kr,"defaultProps",{allowDecimals:!0,hide:!1,orientation:"bottom",width:0,height:30,mirror:!1,xAxisId:0,tickCount:5,type:"category",padding:{left:0,right:0},allowDataOverflow:!1,scale:"auto",reversed:!1,allowDuplicatedCategory:!0});function Mo(e){"@babel/helpers - typeof";return Mo=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},Mo(e)}function hG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function pG(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,XN(r.key),r)}}function vG(e,t,n){return t&&pG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function yG(e,t,n){return t=Sf(t),mG(e,GN()?Reflect.construct(t,n||[],Sf(e).constructor):t.apply(e,n))}function mG(e,t){if(t&&(Mo(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return gG(e)}function gG(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function GN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(GN=function(){return!!e})()}function Sf(e){return Sf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Sf(e)}function bG(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&&Cb(e,t)}function Cb(e,t){return Cb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Cb(e,t)}function YN(e,t,n){return t=XN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function XN(e){var t=xG(e,"string");return Mo(t)=="symbol"?t:t+""}function xG(e,t){if(Mo(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Mo(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function Nb(){return Nb=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},Nb.apply(this,arguments)}var SG=function(t){var n=t.yAxisId,r=B0(),o=L0(),l=AN(n);return l==null?null:Q.createElement(ko,Nb({},l,{className:$e("recharts-".concat(l.axisType," ").concat(l.axisType),l.className),viewBox:{x:0,y:0,width:r,height:o},ticksGenerator:function(f){return Mr(f,!0)}}))},Ur=(function(e){function t(){return hG(this,t),yG(this,t,arguments)}return bG(t,e),vG(t,[{key:"render",value:function(){return Q.createElement(SG,this.props)}}])})(Q.Component);YN(Ur,"displayName","YAxis");YN(Ur,"defaultProps",{allowDuplicatedCategory:!0,allowDecimals:!0,hide:!1,orientation:"left",width:60,height:0,mirror:!1,yAxisId:0,tickCount:5,type:"number",padding:{top:0,bottom:0},allowDataOverflow:!1,scale:"auto",reversed:!1});function N2(e){return wG(e)||AG(e)||_G(e)||OG()}function OG(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
190
190
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _G(e,t){if(e){if(typeof e=="string")return Db(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 Db(e,t)}}function AG(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function wG(e){if(Array.isArray(e))return Db(e)}function Db(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 Pb=function(t,n,r,o,l){var c=Nn(t,Ff),f=Nn(t,Qf),d=[].concat(N2(c),N2(f)),h=Nn(t,Jf),v="".concat(o,"Id"),y=o[0],g=n;if(d.length&&(g=d.reduce(function(S,b){if(b.props[v]===r&&nr(b.props,"extendDomain")&&fe(b.props[y])){var w=b.props[y];return[Math.min(S[0],w),Math.max(S[1],w)]}return S},g)),h.length){var x="".concat(y,"1"),_="".concat(y,"2");g=h.reduce(function(S,b){if(b.props[v]===r&&nr(b.props,"extendDomain")&&fe(b.props[x])&&fe(b.props[_])){var w=b.props[x],E=b.props[_];return[Math.min(S[0],w,E),Math.max(S[1],w,E)]}return S},g)}return l&&l.length&&(g=l.reduce(function(S,b){return fe(b)?[Math.min(S[0],b),Math.max(S[1],b)]:S},g)),g},vg={exports:{}},D2;function TG(){return D2||(D2=1,(function(e){var t=Object.prototype.hasOwnProperty,n="~";function r(){}Object.create&&(r.prototype=Object.create(null),new r().__proto__||(n=!1));function o(d,h,v){this.fn=d,this.context=h,this.once=v||!1}function l(d,h,v,y,g){if(typeof v!="function")throw new TypeError("The listener must be a function");var x=new o(v,y||d,g),_=n?n+h:h;return d._events[_]?d._events[_].fn?d._events[_]=[d._events[_],x]:d._events[_].push(x):(d._events[_]=x,d._eventsCount++),d}function c(d,h){--d._eventsCount===0?d._events=new r:delete d._events[h]}function f(){this._events=new r,this._eventsCount=0}f.prototype.eventNames=function(){var h=[],v,y;if(this._eventsCount===0)return h;for(y in v=this._events)t.call(v,y)&&h.push(n?y.slice(1):y);return Object.getOwnPropertySymbols?h.concat(Object.getOwnPropertySymbols(v)):h},f.prototype.listeners=function(h){var v=n?n+h:h,y=this._events[v];if(!y)return[];if(y.fn)return[y.fn];for(var g=0,x=y.length,_=new Array(x);g<x;g++)_[g]=y[g].fn;return _},f.prototype.listenerCount=function(h){var v=n?n+h:h,y=this._events[v];return y?y.fn?1:y.length:0},f.prototype.emit=function(h,v,y,g,x,_){var S=n?n+h:h;if(!this._events[S])return!1;var b=this._events[S],w=arguments.length,E,j;if(b.fn){switch(b.once&&this.removeListener(h,b.fn,void 0,!0),w){case 1:return b.fn.call(b.context),!0;case 2:return b.fn.call(b.context,v),!0;case 3:return b.fn.call(b.context,v,y),!0;case 4:return b.fn.call(b.context,v,y,g),!0;case 5:return b.fn.call(b.context,v,y,g,x),!0;case 6:return b.fn.call(b.context,v,y,g,x,_),!0}for(j=1,E=new Array(w-1);j<w;j++)E[j-1]=arguments[j];b.fn.apply(b.context,E)}else{var N=b.length,A;for(j=0;j<N;j++)switch(b[j].once&&this.removeListener(h,b[j].fn,void 0,!0),w){case 1:b[j].fn.call(b[j].context);break;case 2:b[j].fn.call(b[j].context,v);break;case 3:b[j].fn.call(b[j].context,v,y);break;case 4:b[j].fn.call(b[j].context,v,y,g);break;default:if(!E)for(A=1,E=new Array(w-1);A<w;A++)E[A-1]=arguments[A];b[j].fn.apply(b[j].context,E)}}return!0},f.prototype.on=function(h,v,y){return l(this,h,v,y,!1)},f.prototype.once=function(h,v,y){return l(this,h,v,y,!0)},f.prototype.removeListener=function(h,v,y,g){var x=n?n+h:h;if(!this._events[x])return this;if(!v)return c(this,x),this;var _=this._events[x];if(_.fn)_.fn===v&&(!g||_.once)&&(!y||_.context===y)&&c(this,x);else{for(var S=0,b=[],w=_.length;S<w;S++)(_[S].fn!==v||g&&!_[S].once||y&&_[S].context!==y)&&b.push(_[S]);b.length?this._events[x]=b.length===1?b[0]:b:c(this,x)}return this},f.prototype.removeAllListeners=function(h){var v;return h?(v=n?n+h:h,this._events[v]&&c(this,v)):(this._events=new r,this._eventsCount=0),this},f.prototype.off=f.prototype.removeListener,f.prototype.addListener=f.prototype.on,f.prefixed=n,f.EventEmitter=f,e.exports=f})(vg)),vg.exports}var EG=TG();const jG=Qe(EG);var yg=new jG,mg="recharts.syncMouseEvents";function Dl(e){"@babel/helpers - typeof";return Dl=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},Dl(e)}function MG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function CG(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,KN(r.key),r)}}function NG(e,t,n){return t&&CG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function gg(e,t,n){return t=KN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function KN(e){var t=DG(e,"string");return Dl(t)=="symbol"?t:t+""}function DG(e,t){if(Dl(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Dl(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}var PG=(function(){function e(){MG(this,e),gg(this,"activeIndex",0),gg(this,"coordinateList",[]),gg(this,"layout","horizontal")}return NG(e,[{key:"setDetails",value:function(n){var r,o=n.coordinateList,l=o===void 0?null:o,c=n.container,f=c===void 0?null:c,d=n.layout,h=d===void 0?null:d,v=n.offset,y=v===void 0?null:v,g=n.mouseHandlerCallback,x=g===void 0?null:g;this.coordinateList=(r=l??this.coordinateList)!==null&&r!==void 0?r:[],this.container=f??this.container,this.layout=h??this.layout,this.offset=y??this.offset,this.mouseHandlerCallback=x??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 o=this.container.getBoundingClientRect(),l=o.x,c=o.y,f=o.height,d=this.coordinateList[this.activeIndex].coordinate,h=((n=window)===null||n===void 0?void 0:n.scrollX)||0,v=((r=window)===null||r===void 0?void 0:r.scrollY)||0,y=l+d+h,g=c+this.offset.top+f/2+v;this.mouseHandlerCallback({pageX:y,pageY:g})}}}])})();function RG(e,t,n){if(n==="number"&&t===!0&&Array.isArray(e)){var r=e==null?void 0:e[0],o=e==null?void 0:e[1];if(r&&o&&fe(r)&&fe(o))return!0}return!1}function $G(e,t,n,r){var o=r/2;return{stroke:"none",fill:"#ccc",x:e==="horizontal"?t.x-o:n.left+.5,y:e==="horizontal"?n.top+.5:t.y-o,width:e==="horizontal"?r:n.width-1,height:e==="horizontal"?n.height-1:r}}function VN(e){var t=e.cx,n=e.cy,r=e.radius,o=e.startAngle,l=e.endAngle,c=qt(t,n,r,o),f=qt(t,n,r,l);return{points:[c,f],cx:t,cy:n,radius:r,startAngle:o,endAngle:l}}function qG(e,t,n){var r,o,l,c;if(e==="horizontal")r=t.x,l=r,o=n.top,c=n.top+n.height;else if(e==="vertical")o=t.y,c=o,r=n.left,l=n.left+n.width;else if(t.cx!=null&&t.cy!=null)if(e==="centric"){var f=t.cx,d=t.cy,h=t.innerRadius,v=t.outerRadius,y=t.angle,g=qt(f,d,h,y),x=qt(f,d,v,y);r=g.x,o=g.y,l=x.x,c=x.y}else return VN(t);return[{x:r,y:o},{x:l,y:c}]}function Pl(e){"@babel/helpers - typeof";return Pl=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},Pl(e)}function P2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function bs(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?P2(Object(n),!0).forEach(function(r){zG(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function zG(e,t,n){return t=BG(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function BG(e){var t=LG(e,"string");return Pl(t)=="symbol"?t:t+""}function LG(e,t){if(Pl(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Pl(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function kG(e){var t,n,r=e.element,o=e.tooltipEventType,l=e.isActive,c=e.activeCoordinate,f=e.activePayload,d=e.offset,h=e.activeTooltipIndex,v=e.tooltipAxisBandSize,y=e.layout,g=e.chartName,x=(t=r.props.cursor)!==null&&t!==void 0?t:(n=r.type.defaultProps)===null||n===void 0?void 0:n.cursor;if(!r||!x||!l||!c||g!=="ScatterChart"&&o!=="axis")return null;var _,S=oo;if(g==="ScatterChart")_=c,S=jI;else if(g==="BarChart")_=$G(y,c,d,v),S=P0;else if(y==="radial"){var b=VN(c),w=b.cx,E=b.cy,j=b.radius,N=b.startAngle,A=b.endAngle;_={cx:w,cy:E,startAngle:N,endAngle:A,innerRadius:j,outerRadius:j},S=JC}else _={points:qG(y,c,d)},S=oo;var T=bs(bs(bs(bs({stroke:"#ccc",pointerEvents:"none"},d),_),Ee(x,!1)),{},{payload:f,payloadIndex:h,className:$e("recharts-tooltip-cursor",x.className)});return Q.isValidElement(x)?Q.cloneElement(x,T):Q.createElement(S,T)}var UG=["item"],IG=["children","className","width","height","style","compact","title","desc"];function Co(e){"@babel/helpers - typeof";return Co=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},Co(e)}function no(){return no=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},no.apply(this,arguments)}function R2(e,t){return YG(e)||GG(e,t)||ZN(e,t)||HG()}function HG(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
191
191
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function GG(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,o,l,c,f=[],d=!0,h=!1;try{if(l=(n=n.call(e)).next,t!==0)for(;!(d=(r=l.call(n)).done)&&(f.push(r.value),f.length!==t);d=!0);}catch(v){h=!0,o=v}finally{try{if(!d&&n.return!=null&&(c=n.return(),Object(c)!==c))return}finally{if(h)throw o}}return f}}function YG(e){if(Array.isArray(e))return e}function $2(e,t){if(e==null)return{};var n=XG(e,t),r,o;if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(o=0;o<l.length;o++)r=l[o],!(t.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(n[r]=e[r])}return n}function XG(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 KG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function VG(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,QN(r.key),r)}}function FG(e,t,n){return t&&VG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function ZG(e,t,n){return t=Of(t),QG(e,FN()?Reflect.construct(t,n||[],Of(e).constructor):t.apply(e,n))}function QG(e,t){if(t&&(Co(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return WG(e)}function WG(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function FN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(FN=function(){return!!e})()}function Of(e){return Of=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Of(e)}function JG(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&&Rb(e,t)}function Rb(e,t){return Rb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Rb(e,t)}function No(e){return nY(e)||tY(e)||ZN(e)||eY()}function eY(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
192
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ZN(e,t){if(e){if(typeof e=="string")return $b(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 $b(e,t)}}function tY(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function nY(e){if(Array.isArray(e))return $b(e)}function $b(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 q2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ne(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?q2(Object(n),!0).forEach(function(r){be(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function be(e,t,n){return t=QN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QN(e){var t=rY(e,"string");return Co(t)=="symbol"?t:t+""}function rY(e,t){if(Co(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Co(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var aY={xAxis:["bottom","top"],yAxis:["left","right"]},iY={width:"100%",height:"100%"},WN={x:0,y:0};function xs(e){return e}var oY=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},uY=function(t,n,r,o){var l=n.find(function(v){return v&&v.index===r});if(l){if(t==="horizontal")return{x:l.coordinate,y:o.y};if(t==="vertical")return{x:o.x,y:l.coordinate};if(t==="centric"){var c=l.coordinate,f=o.radius;return ne(ne(ne({},o),qt(o.cx,o.cy,f,c)),{},{angle:c,radius:f})}var d=l.coordinate,h=o.angle;return ne(ne(ne({},o),qt(o.cx,o.cy,d,h)),{},{angle:h,radius:d})}return WN},ed=function(t,n){var r=n.graphicalItems,o=n.dataStartIndex,l=n.dataEndIndex,c=(r??[]).reduce(function(f,d){var h=d.props.data;return h&&h.length?[].concat(No(f),No(h)):f},[]);return c.length>0?c:t&&t.length&&fe(o)&&fe(l)?t.slice(o,l+1):[]};function JN(e){return e==="number"?[0,"auto"]:void 0}var qb=function(t,n,r,o){var l=t.graphicalItems,c=t.tooltipAxis,f=ed(n,t);return r<0||!l||!l.length||r>=f.length?null:l.reduce(function(d,h){var v,y=(v=h.props.data)!==null&&v!==void 0?v:n;y&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(y=y.slice(t.dataStartIndex,t.dataEndIndex+1));var g;if(c.dataKey&&!c.allowDuplicatedCategory){var x=y===void 0?f:y;g=Os(x,c.dataKey,o)}else g=y&&y[r]||f[r];return g?[].concat(No(d),[ZC(h,g)]):d},[])},z2=function(t,n,r,o){var l=o||{x:t.chartX,y:t.chartY},c=oY(l,r),f=t.orderedTooltipTicks,d=t.tooltipAxis,h=t.tooltipTicks,v=u5(c,f,h,d);if(v>=0&&h){var y=h[v]&&h[v].value,g=qb(t,n,v,y),x=uY(r,f,v,l);return{activeTooltipIndex:v,activeLabel:y,activePayload:g,activeCoordinate:x}}return null},lY=function(t,n){var r=n.axes,o=n.graphicalItems,l=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,v=t.layout,y=t.children,g=t.stackOffset,x=KC(v,l);return r.reduce(function(_,S){var b,w=S.type.defaultProps!==void 0?ne(ne({},S.type.defaultProps),S.props):S.props,E=w.type,j=w.dataKey,N=w.allowDataOverflow,A=w.allowDuplicatedCategory,T=w.scale,C=w.ticks,$=w.includeHidden,z=w[c];if(_[z])return _;var Z=ed(t.data,{graphicalItems:o.filter(function(I){var re,se=c in I.props?I.props[c]:(re=I.type.defaultProps)===null||re===void 0?void 0:re[c];return se===z}),dataStartIndex:d,dataEndIndex:h}),U=Z.length,B,V,W;RG(w.domain,N,E)&&(B=Jg(w.domain,null,N),x&&(E==="number"||T!=="auto")&&(W=Zu(Z,j,"category")));var F=JN(E);if(!B||B.length===0){var R,G=(R=w.domain)!==null&&R!==void 0?R:F;if(j){if(B=Zu(Z,j,E),E==="category"&&x){var ee=J3(B);A&&ee?(V=B,B=lf(0,U)):A||(B=FE(G,B,S).reduce(function(I,re){return I.indexOf(re)>=0?I:[].concat(No(I),[re])},[]))}else if(E==="category")A?B=B.filter(function(I){return I!==""&&!je(I)}):B=FE(G,B,S).reduce(function(I,re){return I.indexOf(re)>=0||re===""||je(re)?I:[].concat(No(I),[re])},[]);else if(E==="number"){var oe=d5(Z,o.filter(function(I){var re,se,pe=c in I.props?I.props[c]:(re=I.type.defaultProps)===null||re===void 0?void 0:re[c],me="hide"in I.props?I.props.hide:(se=I.type.defaultProps)===null||se===void 0?void 0:se.hide;return pe===z&&($||!me)}),j,l,v);oe&&(B=oe)}x&&(E==="number"||T!=="auto")&&(W=Zu(Z,j,"category"))}else x?B=lf(0,U):f&&f[z]&&f[z].hasStack&&E==="number"?B=g==="expand"?[0,1]:FC(f[z].stackGroups,d,h):B=XC(Z,o.filter(function(I){var re=c in I.props?I.props[c]:I.type.defaultProps[c],se="hide"in I.props?I.props.hide:I.type.defaultProps.hide;return re===z&&($||!se)}),E,v,!0);if(E==="number")B=Pb(y,B,z,l,C),G&&(B=Jg(G,B,N));else if(E==="category"&&G){var le=G,P=B.every(function(I){return le.indexOf(I)>=0});P&&(B=le)}}return ne(ne({},_),{},be({},z,ne(ne({},w),{},{axisType:l,domain:B,categoricalDomain:W,duplicateDomain:V,originalDomain:(b=w.domain)!==null&&b!==void 0?b:F,isCategorical:x,layout:v})))},{})},cY=function(t,n){var r=n.graphicalItems,o=n.Axis,l=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,v=t.layout,y=t.children,g=ed(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:h}),x=g.length,_=KC(v,l),S=-1;return r.reduce(function(b,w){var E=w.type.defaultProps!==void 0?ne(ne({},w.type.defaultProps),w.props):w.props,j=E[c],N=JN("number");if(!b[j]){S++;var A;return _?A=lf(0,x):f&&f[j]&&f[j].hasStack?(A=FC(f[j].stackGroups,d,h),A=Pb(y,A,j,l)):(A=Jg(N,XC(g,r.filter(function(T){var C,$,z=c in T.props?T.props[c]:(C=T.type.defaultProps)===null||C===void 0?void 0:C[c],Z="hide"in T.props?T.props.hide:($=T.type.defaultProps)===null||$===void 0?void 0:$.hide;return z===j&&!Z}),"number",v),o.defaultProps.allowDataOverflow),A=Pb(y,A,j,l)),ne(ne({},b),{},be({},j,ne(ne({axisType:l},o.defaultProps),{},{hide:!0,orientation:Cn(aY,"".concat(l,".").concat(S%2),null),domain:A,originalDomain:N,isCategorical:_,layout:v})))}return b},{})},sY=function(t,n){var r=n.axisType,o=r===void 0?"xAxis":r,l=n.AxisComp,c=n.graphicalItems,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,v=t.children,y="".concat(o,"Id"),g=Nn(v,l),x={};return g&&g.length?x=lY(t,{axes:g,graphicalItems:c,axisType:o,axisIdKey:y,stackGroups:f,dataStartIndex:d,dataEndIndex:h}):c&&c.length&&(x=cY(t,{Axis:l,graphicalItems:c,axisType:o,axisIdKey:y,stackGroups:f,dataStartIndex:d,dataEndIndex:h})),x},fY=function(t){var n=ya(t),r=Mr(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:o0(r,function(o){return o.coordinate}),tooltipAxis:n,tooltipAxisBandSize:Qs(n,r)}},B2=function(t){var n=t.children,r=t.defaultShowTooltip,o=hn(n,xo),l=0,c=0;return t.data&&t.data.length!==0&&(c=t.data.length-1),o&&o.props&&(o.props.startIndex>=0&&(l=o.props.startIndex),o.props.endIndex>=0&&(c=o.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:l,dataEndIndex:c,activeTooltipIndex:-1,isTooltipActive:!!r}},dY=function(t){return!t||!t.length?!1:t.some(function(n){var r=Cr(n&&n.type);return r&&r.indexOf("Bar")>=0})},L2=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"}},hY=function(t,n){var r=t.props,o=t.graphicalItems,l=t.xAxisMap,c=l===void 0?{}:l,f=t.yAxisMap,d=f===void 0?{}:f,h=r.width,v=r.height,y=r.children,g=r.margin||{},x=hn(y,xo),_=hn(y,ba),S=Object.keys(d).reduce(function(A,T){var C=d[T],$=C.orientation;return!C.mirror&&!C.hide?ne(ne({},A),{},be({},$,A[$]+C.width)):A},{left:g.left||0,right:g.right||0}),b=Object.keys(c).reduce(function(A,T){var C=c[T],$=C.orientation;return!C.mirror&&!C.hide?ne(ne({},A),{},be({},$,Cn(A,"".concat($))+C.height)):A},{top:g.top||0,bottom:g.bottom||0}),w=ne(ne({},b),S),E=w.bottom;x&&(w.bottom+=x.props.height||xo.defaultProps.height),_&&n&&(w=s5(w,o,r,n));var j=h-w.left-w.right,N=v-w.top-w.bottom;return ne(ne({brushBottom:E},w),{},{width:Math.max(j,0),height:Math.max(N,0)})},pY=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},H0=function(t){var n=t.chartName,r=t.GraphicalChild,o=t.defaultTooltipEventType,l=o===void 0?"axis":o,c=t.validateTooltipEventTypes,f=c===void 0?["axis"]:c,d=t.axisComponents,h=t.legendContent,v=t.formatAxisMap,y=t.defaultProps,g=function(w,E){var j=E.graphicalItems,N=E.stackGroups,A=E.offset,T=E.updateId,C=E.dataStartIndex,$=E.dataEndIndex,z=w.barSize,Z=w.layout,U=w.barGap,B=w.barCategoryGap,V=w.maxBarSize,W=L2(Z),F=W.numericAxisName,R=W.cateAxisName,G=dY(j),ee=[];return j.forEach(function(oe,le){var P=ed(w.data,{graphicalItems:[oe],dataStartIndex:C,dataEndIndex:$}),I=oe.type.defaultProps!==void 0?ne(ne({},oe.type.defaultProps),oe.props):oe.props,re=I.dataKey,se=I.maxBarSize,pe=I["".concat(F,"Id")],me=I["".concat(R,"Id")],Me={},ke=d.reduce(function($n,ur){var Uo=E["".concat(ur.axisType,"Map")],Bt=I["".concat(ur.axisType,"Id")];Uo&&Uo[Bt]||ur.axisType==="zAxis"||ai();var Hl=Uo[Bt];return ne(ne({},$n),{},be(be({},ur.axisType,Hl),"".concat(ur.axisType,"Ticks"),Mr(Hl)))},Me),ce=ke[R],xe=ke["".concat(R,"Ticks")],Se=N&&N[pe]&&N[pe].hasStack&&A5(oe,N[pe].stackGroups),ue=Cr(oe.type).indexOf("Bar")>=0,et=Qs(ce,xe),we=[],ot=G&&l5({barSize:z,stackGroups:N,totalSize:pY(ke,R)});if(ue){var ut,zt,Rn=je(se)?V:se,Kn=(ut=(zt=Qs(ce,xe,!0))!==null&&zt!==void 0?zt:Rn)!==null&&ut!==void 0?ut:0;we=c5({barGap:U,barCategoryGap:B,bandSize:Kn!==et?Kn:et,sizeList:ot[me],maxBarSize:Rn}),Kn!==et&&(we=we.map(function($n){return ne(ne({},$n),{},{position:ne(ne({},$n.position),{},{offset:$n.position.offset-Kn/2})})}))}var Ir=oe&&oe.type&&oe.type.getComposedData;Ir&&ee.push({props:ne(ne({},Ir(ne(ne({},ke),{},{displayedData:P,props:w,dataKey:re,item:oe,bandSize:et,barPosition:we,offset:A,stackedData:Se,layout:Z,dataStartIndex:C,dataEndIndex:$}))),{},be(be(be({key:oe.key||"item-".concat(le)},F,ke[F]),R,ke[R]),"animationId",T)),childIndex:f$(oe,w.children),item:oe})}),ee},x=function(w,E){var j=w.props,N=w.dataStartIndex,A=w.dataEndIndex,T=w.updateId;if(!sA({props:j}))return null;var C=j.children,$=j.layout,z=j.stackOffset,Z=j.data,U=j.reverseStackOrder,B=L2($),V=B.numericAxisName,W=B.cateAxisName,F=Nn(C,r),R=S5(Z,F,"".concat(V,"Id"),"".concat(W,"Id"),z,U),G=d.reduce(function(I,re){var se="".concat(re.axisType,"Map");return ne(ne({},I),{},be({},se,sY(j,ne(ne({},re),{},{graphicalItems:F,stackGroups:re.axisType===V&&R,dataStartIndex:N,dataEndIndex:A}))))},{}),ee=hY(ne(ne({},G),{},{props:j,graphicalItems:F}),E==null?void 0:E.legendBBox);Object.keys(G).forEach(function(I){G[I]=v(j,G[I],ee,I.replace("Map",""),n)});var oe=G["".concat(W,"Map")],le=fY(oe),P=g(j,ne(ne({},G),{},{dataStartIndex:N,dataEndIndex:A,updateId:T,graphicalItems:F,stackGroups:R,offset:ee}));return ne(ne({formattedGraphicalItems:P,graphicalItems:F,offset:ee,stackGroups:R},le),G)},_=(function(b){function w(E){var j,N,A;return KG(this,w),A=ZG(this,w,[E]),be(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),be(A,"accessibilityManager",new PG),be(A,"handleLegendBBoxUpdate",function(T){if(T){var C=A.state,$=C.dataStartIndex,z=C.dataEndIndex,Z=C.updateId;A.setState(ne({legendBBox:T},x({props:A.props,dataStartIndex:$,dataEndIndex:z,updateId:Z},ne(ne({},A.state),{},{legendBBox:T}))))}}),be(A,"handleReceiveSyncEvent",function(T,C,$){if(A.props.syncId===T){if($===A.eventEmitterSymbol&&typeof A.props.syncMethod!="function")return;A.applySyncEvent(C)}}),be(A,"handleBrushChange",function(T){var C=T.startIndex,$=T.endIndex;if(C!==A.state.dataStartIndex||$!==A.state.dataEndIndex){var z=A.state.updateId;A.setState(function(){return ne({dataStartIndex:C,dataEndIndex:$},x({props:A.props,dataStartIndex:C,dataEndIndex:$,updateId:z},A.state))}),A.triggerSyncEvent({dataStartIndex:C,dataEndIndex:$})}}),be(A,"handleMouseEnter",function(T){var C=A.getMouseInfo(T);if(C){var $=ne(ne({},C),{},{isTooltipActive:!0});A.setState($),A.triggerSyncEvent($);var z=A.props.onMouseEnter;Ae(z)&&z($,T)}}),be(A,"triggeredAfterMouseMove",function(T){var C=A.getMouseInfo(T),$=C?ne(ne({},C),{},{isTooltipActive:!0}):{isTooltipActive:!1};A.setState($),A.triggerSyncEvent($);var z=A.props.onMouseMove;Ae(z)&&z($,T)}),be(A,"handleItemMouseEnter",function(T){A.setState(function(){return{isTooltipActive:!0,activeItem:T,activePayload:T.tooltipPayload,activeCoordinate:T.tooltipPosition||{x:T.cx,y:T.cy}}})}),be(A,"handleItemMouseLeave",function(){A.setState(function(){return{isTooltipActive:!1}})}),be(A,"handleMouseMove",function(T){T.persist(),A.throttleTriggeredAfterMouseMove(T)}),be(A,"handleMouseLeave",function(T){A.throttleTriggeredAfterMouseMove.cancel();var C={isTooltipActive:!1};A.setState(C),A.triggerSyncEvent(C);var $=A.props.onMouseLeave;Ae($)&&$(C,T)}),be(A,"handleOuterEvent",function(T){var C=s$(T),$=Cn(A.props,"".concat(C));if(C&&Ae($)){var z,Z;/.*touch.*/i.test(C)?Z=A.getMouseInfo(T.changedTouches[0]):Z=A.getMouseInfo(T),$((z=Z)!==null&&z!==void 0?z:{},T)}}),be(A,"handleClick",function(T){var C=A.getMouseInfo(T);if(C){var $=ne(ne({},C),{},{isTooltipActive:!0});A.setState($),A.triggerSyncEvent($);var z=A.props.onClick;Ae(z)&&z($,T)}}),be(A,"handleMouseDown",function(T){var C=A.props.onMouseDown;if(Ae(C)){var $=A.getMouseInfo(T);C($,T)}}),be(A,"handleMouseUp",function(T){var C=A.props.onMouseUp;if(Ae(C)){var $=A.getMouseInfo(T);C($,T)}}),be(A,"handleTouchMove",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.throttleTriggeredAfterMouseMove(T.changedTouches[0])}),be(A,"handleTouchStart",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.handleMouseDown(T.changedTouches[0])}),be(A,"handleTouchEnd",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.handleMouseUp(T.changedTouches[0])}),be(A,"handleDoubleClick",function(T){var C=A.props.onDoubleClick;if(Ae(C)){var $=A.getMouseInfo(T);C($,T)}}),be(A,"handleContextMenu",function(T){var C=A.props.onContextMenu;if(Ae(C)){var $=A.getMouseInfo(T);C($,T)}}),be(A,"triggerSyncEvent",function(T){A.props.syncId!==void 0&&yg.emit(mg,A.props.syncId,T,A.eventEmitterSymbol)}),be(A,"applySyncEvent",function(T){var C=A.props,$=C.layout,z=C.syncMethod,Z=A.state.updateId,U=T.dataStartIndex,B=T.dataEndIndex;if(T.dataStartIndex!==void 0||T.dataEndIndex!==void 0)A.setState(ne({dataStartIndex:U,dataEndIndex:B},x({props:A.props,dataStartIndex:U,dataEndIndex:B,updateId:Z},A.state)));else if(T.activeTooltipIndex!==void 0){var V=T.chartX,W=T.chartY,F=T.activeTooltipIndex,R=A.state,G=R.offset,ee=R.tooltipTicks;if(!G)return;if(typeof z=="function")F=z(ee,T);else if(z==="value"){F=-1;for(var oe=0;oe<ee.length;oe++)if(ee[oe].value===T.activeLabel){F=oe;break}}var le=ne(ne({},G),{},{x:G.left,y:G.top}),P=Math.min(V,le.x+le.width),I=Math.min(W,le.y+le.height),re=ee[F]&&ee[F].value,se=qb(A.state,A.props.data,F),pe=ee[F]?{x:$==="horizontal"?ee[F].coordinate:P,y:$==="horizontal"?I:ee[F].coordinate}:WN;A.setState(ne(ne({},T),{},{activeLabel:re,activeCoordinate:pe,activePayload:se,activeTooltipIndex:F}))}else A.setState(T)}),be(A,"renderCursor",function(T){var C,$=A.state,z=$.isTooltipActive,Z=$.activeCoordinate,U=$.activePayload,B=$.offset,V=$.activeTooltipIndex,W=$.tooltipAxisBandSize,F=A.getTooltipEventType(),R=(C=T.props.active)!==null&&C!==void 0?C:z,G=A.props.layout,ee=T.key||"_recharts-cursor";return L.createElement(kG,{key:ee,activeCoordinate:Z,activePayload:U,activeTooltipIndex:V,chartName:n,element:T,isActive:R,layout:G,offset:B,tooltipAxisBandSize:W,tooltipEventType:F})}),be(A,"renderPolarAxis",function(T,C,$){var z=Cn(T,"type.axisType"),Z=Cn(A.state,"".concat(z,"Map")),U=T.type.defaultProps,B=U!==void 0?ne(ne({},U),T.props):T.props,V=Z&&Z[B["".concat(z,"Id")]];return Q.cloneElement(T,ne(ne({},V),{},{className:$e(z,V.className),key:T.key||"".concat(C,"-").concat($),ticks:Mr(V,!0)}))}),be(A,"renderPolarGrid",function(T){var C=T.props,$=C.radialLines,z=C.polarAngles,Z=C.polarRadius,U=A.state,B=U.radiusAxisMap,V=U.angleAxisMap,W=ya(B),F=ya(V),R=F.cx,G=F.cy,ee=F.innerRadius,oe=F.outerRadius;return Q.cloneElement(T,{polarAngles:Array.isArray(z)?z:Mr(F,!0).map(function(le){return le.coordinate}),polarRadius:Array.isArray(Z)?Z:Mr(W,!0).map(function(le){return le.coordinate}),cx:R,cy:G,innerRadius:ee,outerRadius:oe,key:T.key||"polar-grid",radialLines:$})}),be(A,"renderLegend",function(){var T=A.state.formattedGraphicalItems,C=A.props,$=C.children,z=C.width,Z=C.height,U=A.props.margin||{},B=z-(U.left||0)-(U.right||0),V=GC({children:$,formattedGraphicalItems:T,legendWidth:B,legendContent:h});if(!V)return null;var W=V.item,F=$2(V,UG);return Q.cloneElement(W,ne(ne({},F),{},{chartWidth:z,chartHeight:Z,margin:U,onBBoxUpdate:A.handleLegendBBoxUpdate}))}),be(A,"renderTooltip",function(){var T,C=A.props,$=C.children,z=C.accessibilityLayer,Z=hn($,pn);if(!Z)return null;var U=A.state,B=U.isTooltipActive,V=U.activeCoordinate,W=U.activePayload,F=U.activeLabel,R=U.offset,G=(T=Z.props.active)!==null&&T!==void 0?T:B;return Q.cloneElement(Z,{viewBox:ne(ne({},R),{},{x:R.left,y:R.top}),active:G,label:F,payload:G?W:[],coordinate:V,accessibilityLayer:z})}),be(A,"renderBrush",function(T){var C=A.props,$=C.margin,z=C.data,Z=A.state,U=Z.offset,B=Z.dataStartIndex,V=Z.dataEndIndex,W=Z.updateId;return Q.cloneElement(T,{key:T.key||"_recharts-brush",onChange:vs(A.handleBrushChange,T.props.onChange),data:z,x:fe(T.props.x)?T.props.x:U.left,y:fe(T.props.y)?T.props.y:U.top+U.height+U.brushBottom-($.bottom||0),width:fe(T.props.width)?T.props.width:U.width,startIndex:B,endIndex:V,updateId:"brush-".concat(W)})}),be(A,"renderReferenceElement",function(T,C,$){if(!T)return null;var z=A,Z=z.clipPathId,U=A.state,B=U.xAxisMap,V=U.yAxisMap,W=U.offset,F=T.type.defaultProps||{},R=T.props,G=R.xAxisId,ee=G===void 0?F.xAxisId:G,oe=R.yAxisId,le=oe===void 0?F.yAxisId:oe;return Q.cloneElement(T,{key:T.key||"".concat(C,"-").concat($),xAxis:B[ee],yAxis:V[le],viewBox:{x:W.left,y:W.top,width:W.width,height:W.height},clipPathId:Z})}),be(A,"renderActivePoints",function(T){var C=T.item,$=T.activePoint,z=T.basePoint,Z=T.childIndex,U=T.isRange,B=[],V=C.props.key,W=C.item.type.defaultProps!==void 0?ne(ne({},C.item.type.defaultProps),C.item.props):C.item.props,F=W.activeDot,R=W.dataKey,G=ne(ne({index:Z,dataKey:R,cx:$.x,cy:$.y,r:4,fill:D0(C.item),strokeWidth:2,stroke:"#fff",payload:$.payload,value:$.value},Ee(F,!1)),_s(F));return B.push(w.renderActiveDot(F,G,"".concat(V,"-activePoint-").concat(Z))),z?B.push(w.renderActiveDot(F,ne(ne({},G),{},{cx:z.x,cy:z.y}),"".concat(V,"-basePoint-").concat(Z))):U&&B.push(null),B}),be(A,"renderGraphicChild",function(T,C,$){var z=A.filterFormatItem(T,C,$);if(!z)return null;var Z=A.getTooltipEventType(),U=A.state,B=U.isTooltipActive,V=U.tooltipAxis,W=U.activeTooltipIndex,F=U.activeLabel,R=A.props.children,G=hn(R,pn),ee=z.props,oe=ee.points,le=ee.isRange,P=ee.baseLine,I=z.item.type.defaultProps!==void 0?ne(ne({},z.item.type.defaultProps),z.item.props):z.item.props,re=I.activeDot,se=I.hide,pe=I.activeBar,me=I.activeShape,Me=!!(!se&&B&&G&&(re||pe||me)),ke={};Z!=="axis"&&G&&G.props.trigger==="click"?ke={onClick:vs(A.handleItemMouseEnter,T.props.onClick)}:Z!=="axis"&&(ke={onMouseLeave:vs(A.handleItemMouseLeave,T.props.onMouseLeave),onMouseEnter:vs(A.handleItemMouseEnter,T.props.onMouseEnter)});var ce=Q.cloneElement(T,ne(ne({},z.props),ke));function xe(ur){return typeof V.dataKey=="function"?V.dataKey(ur.payload):null}if(Me)if(W>=0){var Se,ue;if(V.dataKey&&!V.allowDuplicatedCategory){var et=typeof V.dataKey=="function"?xe:"payload.".concat(V.dataKey.toString());Se=Os(oe,et,F),ue=le&&P&&Os(P,et,F)}else Se=oe==null?void 0:oe[W],ue=le&&P&&P[W];if(me||pe){var we=T.props.activeIndex!==void 0?T.props.activeIndex:W;return[Q.cloneElement(T,ne(ne(ne({},z.props),ke),{},{activeIndex:we})),null,null]}if(!je(Se))return[ce].concat(No(A.renderActivePoints({item:z,activePoint:Se,basePoint:ue,childIndex:W,isRange:le})))}else{var ot,ut=(ot=A.getItemByXY(A.state.activeCoordinate))!==null&&ot!==void 0?ot:{graphicalItem:ce},zt=ut.graphicalItem,Rn=zt.item,Kn=Rn===void 0?T:Rn,Ir=zt.childIndex,$n=ne(ne(ne({},z.props),ke),{},{activeIndex:Ir});return[Q.cloneElement(Kn,$n),null,null]}return le?[ce,null,null]:[ce,null]}),be(A,"renderCustomized",function(T,C,$){return Q.cloneElement(T,ne(ne({key:"recharts-customized-".concat($)},A.props),A.state))}),be(A,"renderMap",{CartesianGrid:{handler:xs,once:!0},ReferenceArea:{handler:A.renderReferenceElement},ReferenceLine:{handler:xs},ReferenceDot:{handler:A.renderReferenceElement},XAxis:{handler:xs},YAxis:{handler:xs},Brush:{handler:A.renderBrush,once:!0},Bar:{handler:A.renderGraphicChild},Line:{handler:A.renderGraphicChild},Area:{handler:A.renderGraphicChild},Radar:{handler:A.renderGraphicChild},RadialBar:{handler:A.renderGraphicChild},Scatter:{handler:A.renderGraphicChild},Pie:{handler:A.renderGraphicChild},Funnel:{handler:A.renderGraphicChild},Tooltip:{handler:A.renderCursor,once:!0},PolarGrid:{handler:A.renderPolarGrid,once:!0},PolarAngleAxis:{handler:A.renderPolarAxis},PolarRadiusAxis:{handler:A.renderPolarAxis},Customized:{handler:A.renderCustomized}}),A.clipPathId="".concat((j=E.id)!==null&&j!==void 0?j:$o("recharts"),"-clip"),A.throttleTriggeredAfterMouseMove=GM(A.triggeredAfterMouseMove,(N=E.throttleDelay)!==null&&N!==void 0?N:1e3/60),A.state={},A}return JG(w,b),FG(w,[{key:"componentDidMount",value:function(){var j,N;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(j=this.props.margin.left)!==null&&j!==void 0?j:0,top:(N=this.props.margin.top)!==null&&N!==void 0?N:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var j=this.props,N=j.children,A=j.data,T=j.height,C=j.layout,$=hn(N,pn);if($){var z=$.props.defaultIndex;if(!(typeof z!="number"||z<0||z>this.state.tooltipTicks.length-1)){var Z=this.state.tooltipTicks[z]&&this.state.tooltipTicks[z].value,U=qb(this.state,A,z,Z),B=this.state.tooltipTicks[z].coordinate,V=(this.state.offset.top+T)/2,W=C==="horizontal",F=W?{x:B,y:V}:{y:B,x:V},R=this.state.formattedGraphicalItems.find(function(ee){var oe=ee.item;return oe.type.name==="Scatter"});R&&(F=ne(ne({},F),R.props.points[z].tooltipPosition),U=R.props.points[z].tooltipPayload);var G={activeTooltipIndex:z,isTooltipActive:!0,activeLabel:Z,activePayload:U,activeCoordinate:F};this.setState(G),this.renderCursor($),this.accessibilityManager.setIndex(z)}}}},{key:"getSnapshotBeforeUpdate",value:function(j,N){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==N.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==j.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==j.margin){var A,T;this.accessibilityManager.setDetails({offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(T=this.props.margin.top)!==null&&T!==void 0?T:0}})}return null}},{key:"componentDidUpdate",value:function(j){Sg([hn(j.children,pn)],[hn(this.props.children,pn)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var j=hn(this.props.children,pn);if(j&&typeof j.props.shared=="boolean"){var N=j.props.shared?"axis":"item";return f.indexOf(N)>=0?N:l}return l}},{key:"getMouseInfo",value:function(j){if(!this.container)return null;var N=this.container,A=N.getBoundingClientRect(),T=Q8(A),C={chartX:Math.round(j.pageX-T.left),chartY:Math.round(j.pageY-T.top)},$=A.width/N.offsetWidth||1,z=this.inRange(C.chartX,C.chartY,$);if(!z)return null;var Z=this.state,U=Z.xAxisMap,B=Z.yAxisMap,V=this.getTooltipEventType(),W=z2(this.state,this.props.data,this.props.layout,z);if(V!=="axis"&&U&&B){var F=ya(U).scale,R=ya(B).scale,G=F&&F.invert?F.invert(C.chartX):null,ee=R&&R.invert?R.invert(C.chartY):null;return ne(ne({},C),{},{xValue:G,yValue:ee},W)}return W?ne(ne({},C),W):null}},{key:"inRange",value:function(j,N){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,T=this.props.layout,C=j/A,$=N/A;if(T==="horizontal"||T==="vertical"){var z=this.state.offset,Z=C>=z.left&&C<=z.left+z.width&&$>=z.top&&$<=z.top+z.height;return Z?{x:C,y:$}:null}var U=this.state,B=U.angleAxisMap,V=U.radiusAxisMap;if(B&&V){var W=ya(B);return WE({x:C,y:$},W)}return null}},{key:"parseEventsOfWrapper",value:function(){var j=this.props.children,N=this.getTooltipEventType(),A=hn(j,pn),T={};A&&N==="axis"&&(A.props.trigger==="click"?T={onClick:this.handleClick}:T={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 C=_s(this.props,this.handleOuterEvent);return ne(ne({},C),T)}},{key:"addListener",value:function(){yg.on(mg,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){yg.removeListener(mg,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(j,N,A){for(var T=this.state.formattedGraphicalItems,C=0,$=T.length;C<$;C++){var z=T[C];if(z.item===j||z.props.key===j.key||N===Cr(z.item.type)&&A===z.childIndex)return z}return null}},{key:"renderClipPath",value:function(){var j=this.clipPathId,N=this.state.offset,A=N.left,T=N.top,C=N.height,$=N.width;return L.createElement("defs",null,L.createElement("clipPath",{id:j},L.createElement("rect",{x:A,y:T,height:C,width:$})))}},{key:"getXScales",value:function(){var j=this.state.xAxisMap;return j?Object.entries(j).reduce(function(N,A){var T=R2(A,2),C=T[0],$=T[1];return ne(ne({},N),{},be({},C,$.scale))},{}):null}},{key:"getYScales",value:function(){var j=this.state.yAxisMap;return j?Object.entries(j).reduce(function(N,A){var T=R2(A,2),C=T[0],$=T[1];return ne(ne({},N),{},be({},C,$.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(j){var N;return(N=this.state.xAxisMap)===null||N===void 0||(N=N[j])===null||N===void 0?void 0:N.scale}},{key:"getYScaleByAxisId",value:function(j){var N;return(N=this.state.yAxisMap)===null||N===void 0||(N=N[j])===null||N===void 0?void 0:N.scale}},{key:"getItemByXY",value:function(j){var N=this.state,A=N.formattedGraphicalItems,T=N.activeItem;if(A&&A.length)for(var C=0,$=A.length;C<$;C++){var z=A[C],Z=z.props,U=z.item,B=U.type.defaultProps!==void 0?ne(ne({},U.type.defaultProps),U.props):U.props,V=Cr(U.type);if(V==="Bar"){var W=(Z.data||[]).find(function(ee){return gI(j,ee)});if(W)return{graphicalItem:z,payload:W}}else if(V==="RadialBar"){var F=(Z.data||[]).find(function(ee){return WE(j,ee)});if(F)return{graphicalItem:z,payload:F}}else if(Xf(z,T)||Kf(z,T)||El(z,T)){var R=l9({graphicalItem:z,activeTooltipItem:T,itemData:B.data}),G=B.activeIndex===void 0?R:B.activeIndex;return{graphicalItem:ne(ne({},z),{},{childIndex:G}),payload:El(z,T)?B.data[R]:z.props.data[R]}}}return null}},{key:"render",value:function(){var j=this;if(!sA(this))return null;var N=this.props,A=N.children,T=N.className,C=N.width,$=N.height,z=N.style,Z=N.compact,U=N.title,B=N.desc,V=$2(N,IG),W=Ee(V,!1);if(Z)return L.createElement(h2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},L.createElement(_g,no({},W,{width:C,height:$,title:U,desc:B}),this.renderClipPath(),dA(A,this.renderMap)));if(this.props.accessibilityLayer){var F,R;W.tabIndex=(F=this.props.tabIndex)!==null&&F!==void 0?F:0,W.role=(R=this.props.role)!==null&&R!==void 0?R:"application",W.onKeyDown=function(ee){j.accessibilityManager.keyboardEvent(ee)},W.onFocus=function(){j.accessibilityManager.focus()}}var G=this.parseEventsOfWrapper();return L.createElement(h2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},L.createElement("div",no({className:$e("recharts-wrapper",T),style:ne({position:"relative",cursor:"default",width:C,height:$},z)},G,{ref:function(oe){j.container=oe}}),L.createElement(_g,no({},W,{width:C,height:$,title:U,desc:B,style:iY}),this.renderClipPath(),dA(A,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(Q.Component);be(_,"displayName",n),be(_,"defaultProps",ne({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},y)),be(_,"getDerivedStateFromProps",function(b,w){var E=b.dataKey,j=b.data,N=b.children,A=b.width,T=b.height,C=b.layout,$=b.stackOffset,z=b.margin,Z=w.dataStartIndex,U=w.dataEndIndex;if(w.updateId===void 0){var B=B2(b);return ne(ne(ne({},B),{},{updateId:0},x(ne(ne({props:b},B),{},{updateId:0}),w)),{},{prevDataKey:E,prevData:j,prevWidth:A,prevHeight:T,prevLayout:C,prevStackOffset:$,prevMargin:z,prevChildren:N})}if(E!==w.prevDataKey||j!==w.prevData||A!==w.prevWidth||T!==w.prevHeight||C!==w.prevLayout||$!==w.prevStackOffset||!ro(z,w.prevMargin)){var V=B2(b),W={chartX:w.chartX,chartY:w.chartY,isTooltipActive:w.isTooltipActive},F=ne(ne({},z2(w,j,C)),{},{updateId:w.updateId+1}),R=ne(ne(ne({},V),W),F);return ne(ne(ne({},R),x(ne({props:b},R),w)),{},{prevDataKey:E,prevData:j,prevWidth:A,prevHeight:T,prevLayout:C,prevStackOffset:$,prevMargin:z,prevChildren:N})}if(!Sg(N,w.prevChildren)){var G,ee,oe,le,P=hn(N,xo),I=P&&(G=(ee=P.props)===null||ee===void 0?void 0:ee.startIndex)!==null&&G!==void 0?G:Z,re=P&&(oe=(le=P.props)===null||le===void 0?void 0:le.endIndex)!==null&&oe!==void 0?oe:U,se=I!==Z||re!==U,pe=!je(j),me=pe&&!se?w.updateId:w.updateId+1;return ne(ne({updateId:me},x(ne(ne({props:b},w),{},{updateId:me,dataStartIndex:I,dataEndIndex:re}),w)),{},{prevChildren:N,dataStartIndex:I,dataEndIndex:re})}return null}),be(_,"renderActiveDot",function(b,w,E){var j;return Q.isValidElement(b)?j=Q.cloneElement(b,w):Ae(b)?j=b(w):j=L.createElement(Yf,w),L.createElement(Je,{className:"recharts-active-dot",key:E},j)});var S=Q.forwardRef(function(w,E){return L.createElement(_,no({},w,{ref:E}))});return S.displayName=_.displayName,S},vY=H0({chartName:"LineChart",GraphicalChild:Il,axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:R0}),yY=H0({chartName:"BarChart",GraphicalChild:fi,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:R0}),eD=H0({chartName:"AreaChart",GraphicalChild:Yn,axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:R0});function mY(e){return new Date(e).toLocaleString("es",{hour:"2-digit",minute:"2-digit",day:"numeric",month:"short"})}function gY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState([]);Q.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ft.timeseries("claude_code.tokens.input",e,v),ft.timeseries("claude_code.tokens.output",e,v)]).then(([y,g])=>{r(y),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(v=>v.timestamp),...o.map(v=>v.timestamp)]),f=new Map(n.map(v=>[v.timestamp,v.value])),d=new Map(o.map(v=>[v.timestamp,v.value])),h=Array.from(c).sort().map(v=>({ts:v,label:mY(v),input:f.get(v)??0,output:d.get(v)??0}));return h.length===0?D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de tokens"})}):D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Tokens por período"}),D.jsx($f,{width:"100%",height:220,children:D.jsxs(eD,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[D.jsxs("defs",{children:[D.jsxs("linearGradient",{id:"colorInput",x1:"0",y1:"0",x2:"0",y2:"1",children:[D.jsx("stop",{offset:"5%",stopColor:"#4da6ff",stopOpacity:.3}),D.jsx("stop",{offset:"95%",stopColor:"#4da6ff",stopOpacity:0})]}),D.jsxs("linearGradient",{id:"colorOutput",x1:"0",y1:"0",x2:"0",y2:"1",children:[D.jsx("stop",{offset:"5%",stopColor:"#00ff88",stopOpacity:.3}),D.jsx("stop",{offset:"95%",stopColor:"#00ff88",stopOpacity:0})]})]}),D.jsx(Ul,{strokeDasharray:"3 3",stroke:"#1a1a1a"}),D.jsx(kr,{dataKey:"label",tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:{stroke:"#1a1a1a"}}),D.jsx(Ur,{tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:v=>v>=1e3?`${(v/1e3).toFixed(0)}K`:String(v)}),D.jsx(pn,{contentStyle:{background:"#0d0d0d",border:"1px solid #1a1a1a",borderRadius:"6px"},labelStyle:{color:"#888888",fontSize:12},itemStyle:{fontSize:12}}),D.jsx(ba,{wrapperStyle:{fontSize:12,color:"#888888"}}),D.jsx(Yn,{type:"monotone",dataKey:"input",name:"Input",stroke:"#4da6ff",fill:"url(#colorInput)",strokeWidth:2}),D.jsx(Yn,{type:"monotone",dataKey:"output",name:"Output",stroke:"#00ff88",fill:"url(#colorOutput)",strokeWidth:2})]})})]})}function bY(e){return new Date(e).toLocaleDateString("es",{day:"numeric",month:"short"})}function xY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]);Q.useEffect(()=>{ft.timeseries("claude_code.cost",e,"1d").then(r).catch(()=>{})},[e,t]);const o=n.map(l=>({label:bY(l.timestamp),cost:Number(l.value.toFixed(2))}));return o.length===0?D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de coste"})}):D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Coste por día ($)"}),D.jsx($f,{width:"100%",height:220,children:D.jsxs(yY,{data:o,margin:{top:4,right:8,left:0,bottom:0},children:[D.jsx(Ul,{strokeDasharray:"3 3",stroke:"#1a1a1a",vertical:!1}),D.jsx(kr,{dataKey:"label",tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:{stroke:"#1a1a1a"}}),D.jsx(Ur,{tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:l=>`$${l.toFixed(2)}`}),D.jsx(pn,{contentStyle:{background:"#0d0d0d",border:"1px solid #1a1a1a",borderRadius:"6px"},labelStyle:{color:"#888888",fontSize:12},formatter:l=>[`$${l.toFixed(2)}`,"Coste"]}),D.jsx(fi,{dataKey:"cost",fill:"#a855f7",radius:[3,3,0,0]})]})})]})}function SY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState([]);Q.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ft.timeseries("claude_code.tokens.cache.read",e,v),ft.timeseries("claude_code.tokens.cache.creation",e,v)]).then(([y,g])=>{r(y),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(v=>v.timestamp),...o.map(v=>v.timestamp)]),f=new Map(n.map(v=>[v.timestamp,v.value])),d=new Map(o.map(v=>[v.timestamp,v.value])),h=Array.from(c).sort().map(v=>({label:new Date(v).toLocaleString("es",{hour:"2-digit",day:"numeric",month:"short"}),read:f.get(v)??0,create:d.get(v)??0}));return h.length===0?D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de caché"})}):D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Tokens de caché"}),D.jsx($f,{width:"100%",height:220,children:D.jsxs(eD,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[D.jsx(Ul,{strokeDasharray:"3 3",stroke:"#1a1a1a"}),D.jsx(kr,{dataKey:"label",tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:{stroke:"#1a1a1a"}}),D.jsx(Ur,{tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:v=>v>=1e3?`${(v/1e3).toFixed(0)}K`:String(v)}),D.jsx(pn,{contentStyle:{background:"#0d0d0d",border:"1px solid #1a1a1a",borderRadius:"6px"}}),D.jsx(ba,{wrapperStyle:{fontSize:12,color:"#888888"}}),D.jsx(Yn,{type:"monotone",dataKey:"read",name:"Leído",stroke:"#00d4aa",fill:"#00d4aa",fillOpacity:.2,strokeWidth:2}),D.jsx(Yn,{type:"monotone",dataKey:"create",name:"Creado",stroke:"#4da6ff",fill:"#4da6ff",fillOpacity:.2,strokeWidth:2})]})})]})}function OY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState([]);Q.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ft.timeseries("claude_code.tokens.input",e,v),ft.timeseries("claude_code.tokens.output",e,v)]).then(([y,g])=>{r(y),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(v=>v.timestamp),...o.map(v=>v.timestamp)]),f=new Map(n.map(v=>[v.timestamp,v.value])),d=new Map(o.map(v=>[v.timestamp,v.value])),h=Array.from(c).sort().map(v=>{const y=f.get(v)??0,g=d.get(v)??0;return{label:new Date(v).toLocaleString("es",{hour:"2-digit",day:"numeric",month:"short"}),efficiency:y>0?Number((g/y).toFixed(3)):0}});return h.length===0?D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de eficiencia"})}):D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Ratio output/input"}),D.jsx($f,{width:"100%",height:220,children:D.jsxs(vY,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[D.jsx(Ul,{strokeDasharray:"3 3",stroke:"#1a1a1a"}),D.jsx(kr,{dataKey:"label",tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:{stroke:"#1a1a1a"}}),D.jsx(Ur,{tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:!1,domain:[0,"auto"]}),D.jsx(pn,{contentStyle:{background:"#0d0d0d",border:"1px solid #1a1a1a",borderRadius:"6px"},formatter:v=>[v.toFixed(3),"Eficiencia"]}),D.jsx(Ff,{y:.5,stroke:"#444444",strokeDasharray:"4 4",label:{value:"0.5",fill:"#666",fontSize:10}}),D.jsx(Il,{type:"monotone",dataKey:"efficiency",stroke:"#a855f7",strokeWidth:2,dot:!1})]})})]})}function _Y({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState(null),[c,f]=Q.useState([]),[d,h]=Q.useState(null),[v,y]=Q.useState("");Q.useEffect(()=>{ft.sessions(50).then(r).catch(()=>{})},[e,t]);function g(S){o===S?(l(null),f([])):(f([]),l(S),ft.sessionEvents(S).then(f).catch(()=>{}))}function x(S,b,w){w.stopPropagation(),h(S),y(b??"")}async function _(S){v.trim()&&(await ft.labelSession(S,v.trim()).catch(()=>{}),r(b=>b.map(w=>w.sessionId===S?{...w,project:v.trim()}:w))),h(null)}return n.length===0?D.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin sesiones registradas"}):D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg",children:D.jsx("div",{className:"overflow-x-auto",children:D.jsxs("table",{className:"w-full text-sm min-w-[720px] whitespace-nowrap",children:[D.jsx("thead",{children:D.jsxs("tr",{className:"border-b border-bg-border",children:[D.jsx("th",{className:"w-6 px-3 py-2"}),D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"ID"}),D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"Proyecto"}),D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"Modelo"}),D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"Inicio"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Duración"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Input"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Output"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Coste"})]})}),D.jsx("tbody",{children:n.map(S=>D.jsxs(Q.Fragment,{children:[D.jsxs("tr",{className:"border-b border-bg-border hover:bg-bg-card-hover cursor-pointer",onClick:()=>g(S.sessionId),children:[D.jsx("td",{className:"px-3 py-2 text-text-muted",children:o===S.sessionId?D.jsx(BR,{size:14}):D.jsx(kR,{size:14})}),D.jsxs("td",{className:"px-3 py-2 font-mono text-text-secondary text-xs",children:[S.sessionId.slice(0,8),"…"]}),D.jsx("td",{className:"px-3 py-2",onClick:b=>b.stopPropagation(),children:d===S.sessionId?D.jsxs("span",{className:"flex items-center gap-1",children:[D.jsx("input",{autoFocus:!0,value:v,onChange:b=>y(b.target.value),onKeyDown:b=>{b.key==="Enter"&&_(S.sessionId),b.key==="Escape"&&h(null)},className:"bg-bg-base border border-bg-border rounded px-1 py-0.5 text-xs text-text-primary w-24 outline-none focus:border-accent-green"}),D.jsx("button",{onClick:()=>_(S.sessionId),className:"text-accent-green",children:D.jsx(Bb,{size:12})}),D.jsx("button",{onClick:()=>h(null),className:"text-accent-orange",children:D.jsx(I2,{size:12})})]}):D.jsxs("span",{onClick:b=>x(S.sessionId,S.project,b),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-bg-base border border-bg-border text-text-secondary hover:border-accent-green cursor-pointer transition-colors",children:[S.project??"—",D.jsx(XR,{size:10,className:"opacity-50"})]})}),D.jsx("td",{className:"px-3 py-2 text-text-secondary font-mono text-xs",children:S.model??"—"}),D.jsx("td",{className:"px-3 py-2 text-text-secondary",children:c3(S.startTime)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-text-secondary",children:Lb(S.durationActiveMs)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:er(S.tokensInput)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:er(S.tokensOutput)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:ei(S.cost)})]}),o===S.sessionId&&D.jsx("tr",{children:D.jsx("td",{colSpan:9,className:"bg-bg-subtle px-6 py-3",children:D.jsx("div",{className:"text-xs font-mono space-y-0.5 max-h-40 overflow-y-auto",children:c.length===0?D.jsx("span",{className:"text-text-muted",children:"Sin eventos"}):c.slice(-20).map((b,w)=>D.jsxs("div",{className:"flex gap-2 text-text-secondary",children:[D.jsx("span",{className:"text-text-muted shrink-0",children:new Date(b.timestamp).toLocaleTimeString()}),D.jsx("span",{className:"text-accent-teal",children:b.eventName})]},`${b.timestamp}-${b.eventName}-${w}`))})})})]},S.sessionId))})]})})})}function AY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState(null),c=Q.useCallback(()=>{ft.projects(e).then(r).catch(()=>{})},[e]);Q.useEffect(()=>{c()},[c,t]);const f=async h=>{if(confirm(`¿Resetear todos los datos del proyecto "${h}"?`)){l(h);try{await ft.resetProject(h),c()}finally{l(null)}}};if(n.length===0)return D.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin proyectos registrados"});const d=Math.max(...n.map(h=>h.cost),1e-4);return D.jsxs("div",{className:"flex flex-col gap-4",children:[D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 space-y-3",children:n.map(h=>D.jsxs("div",{children:[D.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[D.jsx("span",{className:"text-text-primary font-medium",children:h.project}),D.jsx("span",{className:"text-accent-purple font-mono",children:ei(h.cost)})]}),D.jsx("div",{className:"h-2 bg-bg-base rounded-full overflow-hidden",children:D.jsx("div",{className:"h-full bg-accent-purple rounded-full",style:{width:`${h.cost/d*100}%`}})})]},h.project))}),D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-x-auto",children:D.jsxs("table",{className:"w-full text-sm min-w-[640px]",children:[D.jsx("thead",{children:D.jsxs("tr",{className:"border-b border-bg-border",children:[D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"Proyecto"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Sesiones"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Input"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Output"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Caché %"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Coste"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Commits"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"LOC +/-"}),D.jsx("th",{className:"px-3 py-2"})]})}),D.jsx("tbody",{children:n.map(h=>D.jsxs("tr",{className:"border-b border-bg-border hover:bg-bg-card-hover",children:[D.jsx("td",{className:"px-3 py-2 text-text-primary font-medium",children:h.project}),D.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:h.sessions}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:er(h.tokensInput)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:er(h.tokensOutput)}),D.jsxs("td",{className:"px-3 py-2 text-right font-mono text-accent-teal",children:[(h.cacheHitRate*100).toFixed(1),"%"]}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:ei(h.cost)}),D.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:h.commits}),D.jsxs("td",{className:"px-3 py-2 text-right font-mono text-xs",children:[D.jsxs("span",{className:"text-accent-green",children:["+",h.linesAdded]}),D.jsx("span",{className:"text-text-muted",children:" / "}),D.jsxs("span",{className:"text-accent-orange",children:["-",h.linesRemoved]})]}),D.jsx("td",{className:"px-3 py-2 text-right",children:D.jsx("button",{onClick:()=>f(h.project),disabled:o===h.project,title:"Resetear proyecto",className:"p-1 rounded text-text-muted hover:text-accent-orange hover:bg-bg-base transition-colors disabled:opacity-40",children:D.jsx(WR,{size:13})})})]},h.project))})]})})]})}function wY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState(null);if(Q.useEffect(()=>{ft.tools(e).then(r).catch(()=>{})},[e,t]),!n||n.usage.length===0)return D.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin datos de herramientas"});const o=Math.max(...n.usage.map(f=>f.count),1),l=n.decisionRate.approved+n.decisionRate.rejected,c=l>0?(n.decisionRate.approved/l*100).toFixed(1):"—";return D.jsxs("div",{className:"flex flex-col gap-4",children:[D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("span",{className:"text-text-secondary text-sm",children:"Tasa de aprobación: "}),D.jsxs("span",{className:"text-accent-green font-mono font-bold",children:[c,"%"]}),D.jsxs("span",{className:"text-text-muted text-xs ml-2",children:["(",n.decisionRate.approved," aprobadas / ",n.decisionRate.rejected," rechazadas)"]})]}),D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 space-y-2",children:n.usage.map(f=>D.jsxs("div",{children:[D.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[D.jsx("span",{className:"font-mono text-text-primary",children:f.toolName}),D.jsxs("span",{className:"text-text-secondary",children:[f.count," usos · ",(f.successRate*100).toFixed(0),"% éxito"]})]}),D.jsx("div",{className:"h-1.5 bg-bg-base rounded-full overflow-hidden",children:D.jsx("div",{className:"h-full bg-accent-teal rounded-full",style:{width:`${f.count/o*100}%`}})})]},f.toolName))})]})}const Ss={"claude-opus-4-8":{input:15,output:75,cacheWrite:18.75,cacheRead:1.5},"claude-sonnet-4-6":{input:3,output:15,cacheWrite:3.75,cacheRead:.3},"claude-haiku-4-5":{input:.8,output:4,cacheWrite:1,cacheRead:.08}},k2=Ss["claude-sonnet-4-6"];function tD(e){if(!e)return k2;const t=e.toLowerCase();return t.includes("opus")?Ss["claude-opus-4-8"]:t.includes("haiku")?Ss["claude-haiku-4-5"]:t.includes("sonnet")?Ss["claude-sonnet-4-6"]:k2}function TY(e,t){const n=tD(t);return e*(n.input-n.cacheRead)/1e6}const EY=[{id:"all",label:"Todos"},{id:"api",label:"API"},{id:"tools",label:"Tools"},{id:"prompts",label:"Prompts"},{id:"errors",label:"Errores"}];function jY(e){return e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}function MY(e){const t=e.attributes;if(typeof t.cost=="number"&&t.cost>0)return t.cost;const n=Number(t.input_tokens??t["tokens.input"]??0),r=Number(t.output_tokens??t["tokens.output"]??0),o=Number(t.cache_read_input_tokens??t["tokens.cache_read"]??0),l=Number(t.cache_creation_input_tokens??t["tokens.cache_creation"]??0);if(n===0&&r===0)return null;const c=tD(e.model);return n*c.input/1e6+r*c.output/1e6+o*c.cacheRead/1e6+l*c.cacheWrite/1e6}function CY(e){return e.includes("error")?"text-accent-orange":e==="user_prompt"?"text-accent-blue":e==="api_request"?"text-accent-green":e==="tool_use"?"text-accent-teal":e.startsWith("hook_")?"text-accent-yellow":"text-text-secondary"}function NY(e,t){return t==="all"?!0:t==="api"?e.eventName.includes("api"):t==="tools"?e.eventName.includes("tool"):t==="prompts"?e.eventName.includes("prompt"):t==="errors"?e.eventName.includes("error"):!0}function DY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState("all"),[c,f]=Q.useState(!1);Q.useEffect(()=>{c||ft.events(500).then(r).catch(()=>{})},[e,t,c]);const d=n.filter(h=>NY(h,o));return D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg flex flex-col h-[600px]",children:[D.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-bg-border flex-wrap",children:[EY.map(({id:h,label:v})=>D.jsx("button",{onClick:()=>l(h),className:`px-2 py-1 rounded text-xs transition-colors ${o===h?"bg-accent-green text-black font-medium":"text-text-secondary hover:text-text-primary"}`,children:v},h)),D.jsx("div",{className:"flex-1"}),D.jsxs("button",{onClick:()=>f(h=>!h),className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-text-secondary hover:text-text-primary",children:[c?D.jsx(VR,{size:12}):D.jsx(GR,{size:12}),D.jsx("span",{children:c?"Reanudar":"Pausar"})]})]}),D.jsx("div",{className:"flex-1 overflow-y-auto p-3 font-mono text-xs space-y-0.5",children:d.length===0?D.jsx("span",{className:"text-text-muted",children:"Sin eventos"}):d.map((h,v)=>{const y=MY(h);return D.jsxs("div",{className:"flex gap-2 hover:bg-bg-base px-1 rounded",children:[D.jsx("span",{className:"text-text-muted shrink-0",children:new Date(h.timestamp).toLocaleTimeString()}),D.jsx("span",{className:`shrink-0 ${CY(h.eventName)}`,children:h.eventName}),h.sessionId&&D.jsxs("span",{className:"text-text-muted",children:[h.sessionId.slice(0,6),"…"]}),y!==null&&D.jsx("span",{className:"text-accent-purple ml-auto shrink-0",children:jY(y)})]},`${h.sessionId??""}-${h.timestamp}-${h.eventName}-${v}`)})})]})}function PY({sseVersion:e}){const[t,n]=Q.useState([]);if(Q.useEffect(()=>{ft.agents().then(n).catch(()=>{})},[e]),t.length===0)return D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-8 flex items-center justify-center",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de agentes. Aparece cuando hay múltiples agentes en trazas OTLP."})});const r=t.filter(c=>!c.parentAgentId),o=c=>t.filter(f=>f.parentAgentId===c);function l({agent:c,depth:f=0}){const d=o(c.agentId);return D.jsxs("div",{style:{paddingLeft:`${f*16}px`},children:[D.jsxs("div",{className:"flex items-center gap-4 py-2 border-b border-bg-border text-sm hover:bg-bg-card-hover px-2",children:[D.jsxs("span",{className:"font-mono text-text-muted text-xs w-20 shrink-0",children:[c.agentId.slice(0,8),"…"]}),D.jsx("span",{className:"font-mono text-accent-blue",children:er(c.tokensInput)}),D.jsx("span",{className:"font-mono text-accent-green",children:er(c.tokensOutput)}),D.jsx("span",{className:"font-mono text-accent-purple",children:ei(c.cost)}),D.jsx("span",{className:"text-text-secondary",children:Lb(c.durationMs)}),D.jsxs("span",{className:"text-text-muted text-xs",children:[c.toolCalls," tools"]})]}),d.map(h=>D.jsx(l,{agent:h,depth:f+1},h.agentId))]})}return D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-hidden",children:[D.jsxs("div",{className:"px-3 py-2 border-b border-bg-border grid grid-cols-6 text-xs text-text-muted",children:[D.jsx("span",{children:"Agent ID"}),D.jsx("span",{children:"Input"}),D.jsx("span",{children:"Output"}),D.jsx("span",{children:"Coste"}),D.jsx("span",{children:"Duración"}),D.jsx("span",{children:"Tools"})]}),r.map(c=>D.jsx(l,{agent:c},c.agentId))]})}function RY(){const[e,t]=Q.useState("now-24h");return{timeRange:e,setTimeRange:t}}function $Y(e){Q.useEffect(()=>{let t=null,n;function r(){t=new EventSource("/api/stream"),t.onmessage=o=>{try{const{type:l,payload:c}=JSON.parse(o.data);l!=="ping"&&e(l,c)}catch{}},t.onerror=()=>{t==null||t.close(),t=null,n=setTimeout(r,3e3)}}return r(),()=>{clearTimeout(n),t==null||t.close()}},[])}function qY(e){const[t,n]=Q.useState({connected:!1,lastSeen:null,sessionCount:0,totalEvents:0,uptime:0}),[r,o]=Q.useState(null),[l,c]=Q.useState(0),f=Q.useRef(0),d=Q.useRef(0),h=Q.useCallback(async()=>{f.current=Date.now();try{const[y,g]=await Promise.all([ft.status(),ft.summary(e)]);n(y),o(g)}catch{}},[e]);Q.useEffect(()=>{h()},[h]);const v=Q.useCallback((y,g)=>{Date.now()-f.current>5e3?h():ft.status().then(n).catch(()=>{});const x=Date.now();x-d.current>5e3&&(d.current=x,c(_=>_+1))},[h]);return $Y(v),{status:t,summary:r,refetch:h,sseVersion:l}}function zY(){const[e,t]=Q.useState("overview"),{timeRange:n,setTimeRange:r}=RY(),{status:o,summary:l,refetch:c,sseVersion:f}=qY(n),d=Q.useCallback(async()=>{await ft.reset(),c()},[c]);return!o.connected&&o.totalEvents===0?D.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex flex-col",children:[D.jsx(e_,{timeRange:n,onTimeRangeChange:r,connected:!1,lastSeen:null,onReset:d}),D.jsx(a3,{})]}):D.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex flex-col",children:[D.jsx(e_,{timeRange:n,onTimeRangeChange:r,connected:o.connected,lastSeen:o.lastSeen,onReset:d}),D.jsx(u3,{onLabeled:c}),D.jsx(r3,{activeTab:e,onTabChange:t}),D.jsxs("main",{className:"flex-1 p-4 max-w-screen-2xl mx-auto w-full",children:[e==="overview"&&D.jsxs("div",{className:"flex flex-col gap-4",children:[l&&D.jsx(s3,{summary:l}),D.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[D.jsx(gY,{timeRange:n,sseVersion:f}),D.jsx(xY,{timeRange:n,sseVersion:f})]})]}),e==="sessions"&&D.jsx(_Y,{timeRange:n,sseVersion:f}),e==="projects"&&D.jsx(AY,{timeRange:n,sseVersion:f}),e==="tools"&&D.jsx(wY,{timeRange:n,sseVersion:f}),e==="agents"&&D.jsx(PY,{sseVersion:f}),e==="events"&&D.jsx(DY,{timeRange:n,sseVersion:f}),e==="costs"&&D.jsxs("div",{className:"flex flex-col gap-4",children:[l&&D.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Coste período"}),D.jsx("div",{className:"text-2xl font-mono font-bold text-accent-purple",children:ei(l.cost)})]}),D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Eficiencia"}),D.jsxs("div",{className:"text-2xl font-mono font-bold text-accent-green",children:[(l.efficiency*100).toFixed(1),"%"]})]}),D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Tokens caché"}),D.jsx("div",{className:"text-2xl font-mono font-bold text-accent-teal",children:er(l.tokens.cache)})]}),D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Ahorro caché est."}),D.jsx("div",{className:"text-2xl font-mono font-bold text-accent-yellow",children:ei(TY(l.tokens.cache))})]})]}),D.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[D.jsx(SY,{timeRange:n,sseVersion:f}),D.jsx(OY,{timeRange:n,sseVersion:f})]})]})]})]})}CR.createRoot(document.getElementById("root")).render(D.jsx(Q.StrictMode,{children:D.jsx(zY,{})}));
|
|
192
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ZN(e,t){if(e){if(typeof e=="string")return $b(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 $b(e,t)}}function tY(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function nY(e){if(Array.isArray(e))return $b(e)}function $b(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 q2(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),n.push.apply(n,r)}return n}function ne(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?q2(Object(n),!0).forEach(function(r){be(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function be(e,t,n){return t=QN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function QN(e){var t=rY(e,"string");return Co(t)=="symbol"?t:t+""}function rY(e,t){if(Co(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Co(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var aY={xAxis:["bottom","top"],yAxis:["left","right"]},iY={width:"100%",height:"100%"},WN={x:0,y:0};function xs(e){return e}var oY=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},uY=function(t,n,r,o){var l=n.find(function(v){return v&&v.index===r});if(l){if(t==="horizontal")return{x:l.coordinate,y:o.y};if(t==="vertical")return{x:o.x,y:l.coordinate};if(t==="centric"){var c=l.coordinate,f=o.radius;return ne(ne(ne({},o),qt(o.cx,o.cy,f,c)),{},{angle:c,radius:f})}var d=l.coordinate,h=o.angle;return ne(ne(ne({},o),qt(o.cx,o.cy,d,h)),{},{angle:h,radius:d})}return WN},ed=function(t,n){var r=n.graphicalItems,o=n.dataStartIndex,l=n.dataEndIndex,c=(r??[]).reduce(function(f,d){var h=d.props.data;return h&&h.length?[].concat(No(f),No(h)):f},[]);return c.length>0?c:t&&t.length&&fe(o)&&fe(l)?t.slice(o,l+1):[]};function JN(e){return e==="number"?[0,"auto"]:void 0}var qb=function(t,n,r,o){var l=t.graphicalItems,c=t.tooltipAxis,f=ed(n,t);return r<0||!l||!l.length||r>=f.length?null:l.reduce(function(d,h){var v,y=(v=h.props.data)!==null&&v!==void 0?v:n;y&&t.dataStartIndex+t.dataEndIndex!==0&&t.dataEndIndex-t.dataStartIndex>=r&&(y=y.slice(t.dataStartIndex,t.dataEndIndex+1));var g;if(c.dataKey&&!c.allowDuplicatedCategory){var x=y===void 0?f:y;g=Os(x,c.dataKey,o)}else g=y&&y[r]||f[r];return g?[].concat(No(d),[ZC(h,g)]):d},[])},z2=function(t,n,r,o){var l=o||{x:t.chartX,y:t.chartY},c=oY(l,r),f=t.orderedTooltipTicks,d=t.tooltipAxis,h=t.tooltipTicks,v=u5(c,f,h,d);if(v>=0&&h){var y=h[v]&&h[v].value,g=qb(t,n,v,y),x=uY(r,f,v,l);return{activeTooltipIndex:v,activeLabel:y,activePayload:g,activeCoordinate:x}}return null},lY=function(t,n){var r=n.axes,o=n.graphicalItems,l=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,v=t.layout,y=t.children,g=t.stackOffset,x=KC(v,l);return r.reduce(function(_,S){var b,w=S.type.defaultProps!==void 0?ne(ne({},S.type.defaultProps),S.props):S.props,E=w.type,j=w.dataKey,N=w.allowDataOverflow,A=w.allowDuplicatedCategory,T=w.scale,C=w.ticks,$=w.includeHidden,z=w[c];if(_[z])return _;var Z=ed(t.data,{graphicalItems:o.filter(function(I){var re,se=c in I.props?I.props[c]:(re=I.type.defaultProps)===null||re===void 0?void 0:re[c];return se===z}),dataStartIndex:d,dataEndIndex:h}),U=Z.length,B,V,W;RG(w.domain,N,E)&&(B=Jg(w.domain,null,N),x&&(E==="number"||T!=="auto")&&(W=Zu(Z,j,"category")));var F=JN(E);if(!B||B.length===0){var R,G=(R=w.domain)!==null&&R!==void 0?R:F;if(j){if(B=Zu(Z,j,E),E==="category"&&x){var ee=J3(B);A&&ee?(V=B,B=lf(0,U)):A||(B=FE(G,B,S).reduce(function(I,re){return I.indexOf(re)>=0?I:[].concat(No(I),[re])},[]))}else if(E==="category")A?B=B.filter(function(I){return I!==""&&!je(I)}):B=FE(G,B,S).reduce(function(I,re){return I.indexOf(re)>=0||re===""||je(re)?I:[].concat(No(I),[re])},[]);else if(E==="number"){var oe=d5(Z,o.filter(function(I){var re,se,pe=c in I.props?I.props[c]:(re=I.type.defaultProps)===null||re===void 0?void 0:re[c],me="hide"in I.props?I.props.hide:(se=I.type.defaultProps)===null||se===void 0?void 0:se.hide;return pe===z&&($||!me)}),j,l,v);oe&&(B=oe)}x&&(E==="number"||T!=="auto")&&(W=Zu(Z,j,"category"))}else x?B=lf(0,U):f&&f[z]&&f[z].hasStack&&E==="number"?B=g==="expand"?[0,1]:FC(f[z].stackGroups,d,h):B=XC(Z,o.filter(function(I){var re=c in I.props?I.props[c]:I.type.defaultProps[c],se="hide"in I.props?I.props.hide:I.type.defaultProps.hide;return re===z&&($||!se)}),E,v,!0);if(E==="number")B=Pb(y,B,z,l,C),G&&(B=Jg(G,B,N));else if(E==="category"&&G){var le=G,P=B.every(function(I){return le.indexOf(I)>=0});P&&(B=le)}}return ne(ne({},_),{},be({},z,ne(ne({},w),{},{axisType:l,domain:B,categoricalDomain:W,duplicateDomain:V,originalDomain:(b=w.domain)!==null&&b!==void 0?b:F,isCategorical:x,layout:v})))},{})},cY=function(t,n){var r=n.graphicalItems,o=n.Axis,l=n.axisType,c=n.axisIdKey,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,v=t.layout,y=t.children,g=ed(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:h}),x=g.length,_=KC(v,l),S=-1;return r.reduce(function(b,w){var E=w.type.defaultProps!==void 0?ne(ne({},w.type.defaultProps),w.props):w.props,j=E[c],N=JN("number");if(!b[j]){S++;var A;return _?A=lf(0,x):f&&f[j]&&f[j].hasStack?(A=FC(f[j].stackGroups,d,h),A=Pb(y,A,j,l)):(A=Jg(N,XC(g,r.filter(function(T){var C,$,z=c in T.props?T.props[c]:(C=T.type.defaultProps)===null||C===void 0?void 0:C[c],Z="hide"in T.props?T.props.hide:($=T.type.defaultProps)===null||$===void 0?void 0:$.hide;return z===j&&!Z}),"number",v),o.defaultProps.allowDataOverflow),A=Pb(y,A,j,l)),ne(ne({},b),{},be({},j,ne(ne({axisType:l},o.defaultProps),{},{hide:!0,orientation:Cn(aY,"".concat(l,".").concat(S%2),null),domain:A,originalDomain:N,isCategorical:_,layout:v})))}return b},{})},sY=function(t,n){var r=n.axisType,o=r===void 0?"xAxis":r,l=n.AxisComp,c=n.graphicalItems,f=n.stackGroups,d=n.dataStartIndex,h=n.dataEndIndex,v=t.children,y="".concat(o,"Id"),g=Nn(v,l),x={};return g&&g.length?x=lY(t,{axes:g,graphicalItems:c,axisType:o,axisIdKey:y,stackGroups:f,dataStartIndex:d,dataEndIndex:h}):c&&c.length&&(x=cY(t,{Axis:l,graphicalItems:c,axisType:o,axisIdKey:y,stackGroups:f,dataStartIndex:d,dataEndIndex:h})),x},fY=function(t){var n=ya(t),r=Mr(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:o0(r,function(o){return o.coordinate}),tooltipAxis:n,tooltipAxisBandSize:Qs(n,r)}},B2=function(t){var n=t.children,r=t.defaultShowTooltip,o=hn(n,xo),l=0,c=0;return t.data&&t.data.length!==0&&(c=t.data.length-1),o&&o.props&&(o.props.startIndex>=0&&(l=o.props.startIndex),o.props.endIndex>=0&&(c=o.props.endIndex)),{chartX:0,chartY:0,dataStartIndex:l,dataEndIndex:c,activeTooltipIndex:-1,isTooltipActive:!!r}},dY=function(t){return!t||!t.length?!1:t.some(function(n){var r=Cr(n&&n.type);return r&&r.indexOf("Bar")>=0})},L2=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"}},hY=function(t,n){var r=t.props,o=t.graphicalItems,l=t.xAxisMap,c=l===void 0?{}:l,f=t.yAxisMap,d=f===void 0?{}:f,h=r.width,v=r.height,y=r.children,g=r.margin||{},x=hn(y,xo),_=hn(y,ba),S=Object.keys(d).reduce(function(A,T){var C=d[T],$=C.orientation;return!C.mirror&&!C.hide?ne(ne({},A),{},be({},$,A[$]+C.width)):A},{left:g.left||0,right:g.right||0}),b=Object.keys(c).reduce(function(A,T){var C=c[T],$=C.orientation;return!C.mirror&&!C.hide?ne(ne({},A),{},be({},$,Cn(A,"".concat($))+C.height)):A},{top:g.top||0,bottom:g.bottom||0}),w=ne(ne({},b),S),E=w.bottom;x&&(w.bottom+=x.props.height||xo.defaultProps.height),_&&n&&(w=s5(w,o,r,n));var j=h-w.left-w.right,N=v-w.top-w.bottom;return ne(ne({brushBottom:E},w),{},{width:Math.max(j,0),height:Math.max(N,0)})},pY=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},H0=function(t){var n=t.chartName,r=t.GraphicalChild,o=t.defaultTooltipEventType,l=o===void 0?"axis":o,c=t.validateTooltipEventTypes,f=c===void 0?["axis"]:c,d=t.axisComponents,h=t.legendContent,v=t.formatAxisMap,y=t.defaultProps,g=function(w,E){var j=E.graphicalItems,N=E.stackGroups,A=E.offset,T=E.updateId,C=E.dataStartIndex,$=E.dataEndIndex,z=w.barSize,Z=w.layout,U=w.barGap,B=w.barCategoryGap,V=w.maxBarSize,W=L2(Z),F=W.numericAxisName,R=W.cateAxisName,G=dY(j),ee=[];return j.forEach(function(oe,le){var P=ed(w.data,{graphicalItems:[oe],dataStartIndex:C,dataEndIndex:$}),I=oe.type.defaultProps!==void 0?ne(ne({},oe.type.defaultProps),oe.props):oe.props,re=I.dataKey,se=I.maxBarSize,pe=I["".concat(F,"Id")],me=I["".concat(R,"Id")],Me={},ke=d.reduce(function($n,ur){var Uo=E["".concat(ur.axisType,"Map")],Bt=I["".concat(ur.axisType,"Id")];Uo&&Uo[Bt]||ur.axisType==="zAxis"||ai();var Hl=Uo[Bt];return ne(ne({},$n),{},be(be({},ur.axisType,Hl),"".concat(ur.axisType,"Ticks"),Mr(Hl)))},Me),ce=ke[R],xe=ke["".concat(R,"Ticks")],Se=N&&N[pe]&&N[pe].hasStack&&A5(oe,N[pe].stackGroups),ue=Cr(oe.type).indexOf("Bar")>=0,et=Qs(ce,xe),we=[],ot=G&&l5({barSize:z,stackGroups:N,totalSize:pY(ke,R)});if(ue){var ut,zt,Rn=je(se)?V:se,Kn=(ut=(zt=Qs(ce,xe,!0))!==null&&zt!==void 0?zt:Rn)!==null&&ut!==void 0?ut:0;we=c5({barGap:U,barCategoryGap:B,bandSize:Kn!==et?Kn:et,sizeList:ot[me],maxBarSize:Rn}),Kn!==et&&(we=we.map(function($n){return ne(ne({},$n),{},{position:ne(ne({},$n.position),{},{offset:$n.position.offset-Kn/2})})}))}var Ir=oe&&oe.type&&oe.type.getComposedData;Ir&&ee.push({props:ne(ne({},Ir(ne(ne({},ke),{},{displayedData:P,props:w,dataKey:re,item:oe,bandSize:et,barPosition:we,offset:A,stackedData:Se,layout:Z,dataStartIndex:C,dataEndIndex:$}))),{},be(be(be({key:oe.key||"item-".concat(le)},F,ke[F]),R,ke[R]),"animationId",T)),childIndex:f$(oe,w.children),item:oe})}),ee},x=function(w,E){var j=w.props,N=w.dataStartIndex,A=w.dataEndIndex,T=w.updateId;if(!sA({props:j}))return null;var C=j.children,$=j.layout,z=j.stackOffset,Z=j.data,U=j.reverseStackOrder,B=L2($),V=B.numericAxisName,W=B.cateAxisName,F=Nn(C,r),R=S5(Z,F,"".concat(V,"Id"),"".concat(W,"Id"),z,U),G=d.reduce(function(I,re){var se="".concat(re.axisType,"Map");return ne(ne({},I),{},be({},se,sY(j,ne(ne({},re),{},{graphicalItems:F,stackGroups:re.axisType===V&&R,dataStartIndex:N,dataEndIndex:A}))))},{}),ee=hY(ne(ne({},G),{},{props:j,graphicalItems:F}),E==null?void 0:E.legendBBox);Object.keys(G).forEach(function(I){G[I]=v(j,G[I],ee,I.replace("Map",""),n)});var oe=G["".concat(W,"Map")],le=fY(oe),P=g(j,ne(ne({},G),{},{dataStartIndex:N,dataEndIndex:A,updateId:T,graphicalItems:F,stackGroups:R,offset:ee}));return ne(ne({formattedGraphicalItems:P,graphicalItems:F,offset:ee,stackGroups:R},le),G)},_=(function(b){function w(E){var j,N,A;return KG(this,w),A=ZG(this,w,[E]),be(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),be(A,"accessibilityManager",new PG),be(A,"handleLegendBBoxUpdate",function(T){if(T){var C=A.state,$=C.dataStartIndex,z=C.dataEndIndex,Z=C.updateId;A.setState(ne({legendBBox:T},x({props:A.props,dataStartIndex:$,dataEndIndex:z,updateId:Z},ne(ne({},A.state),{},{legendBBox:T}))))}}),be(A,"handleReceiveSyncEvent",function(T,C,$){if(A.props.syncId===T){if($===A.eventEmitterSymbol&&typeof A.props.syncMethod!="function")return;A.applySyncEvent(C)}}),be(A,"handleBrushChange",function(T){var C=T.startIndex,$=T.endIndex;if(C!==A.state.dataStartIndex||$!==A.state.dataEndIndex){var z=A.state.updateId;A.setState(function(){return ne({dataStartIndex:C,dataEndIndex:$},x({props:A.props,dataStartIndex:C,dataEndIndex:$,updateId:z},A.state))}),A.triggerSyncEvent({dataStartIndex:C,dataEndIndex:$})}}),be(A,"handleMouseEnter",function(T){var C=A.getMouseInfo(T);if(C){var $=ne(ne({},C),{},{isTooltipActive:!0});A.setState($),A.triggerSyncEvent($);var z=A.props.onMouseEnter;Ae(z)&&z($,T)}}),be(A,"triggeredAfterMouseMove",function(T){var C=A.getMouseInfo(T),$=C?ne(ne({},C),{},{isTooltipActive:!0}):{isTooltipActive:!1};A.setState($),A.triggerSyncEvent($);var z=A.props.onMouseMove;Ae(z)&&z($,T)}),be(A,"handleItemMouseEnter",function(T){A.setState(function(){return{isTooltipActive:!0,activeItem:T,activePayload:T.tooltipPayload,activeCoordinate:T.tooltipPosition||{x:T.cx,y:T.cy}}})}),be(A,"handleItemMouseLeave",function(){A.setState(function(){return{isTooltipActive:!1}})}),be(A,"handleMouseMove",function(T){T.persist(),A.throttleTriggeredAfterMouseMove(T)}),be(A,"handleMouseLeave",function(T){A.throttleTriggeredAfterMouseMove.cancel();var C={isTooltipActive:!1};A.setState(C),A.triggerSyncEvent(C);var $=A.props.onMouseLeave;Ae($)&&$(C,T)}),be(A,"handleOuterEvent",function(T){var C=s$(T),$=Cn(A.props,"".concat(C));if(C&&Ae($)){var z,Z;/.*touch.*/i.test(C)?Z=A.getMouseInfo(T.changedTouches[0]):Z=A.getMouseInfo(T),$((z=Z)!==null&&z!==void 0?z:{},T)}}),be(A,"handleClick",function(T){var C=A.getMouseInfo(T);if(C){var $=ne(ne({},C),{},{isTooltipActive:!0});A.setState($),A.triggerSyncEvent($);var z=A.props.onClick;Ae(z)&&z($,T)}}),be(A,"handleMouseDown",function(T){var C=A.props.onMouseDown;if(Ae(C)){var $=A.getMouseInfo(T);C($,T)}}),be(A,"handleMouseUp",function(T){var C=A.props.onMouseUp;if(Ae(C)){var $=A.getMouseInfo(T);C($,T)}}),be(A,"handleTouchMove",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.throttleTriggeredAfterMouseMove(T.changedTouches[0])}),be(A,"handleTouchStart",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.handleMouseDown(T.changedTouches[0])}),be(A,"handleTouchEnd",function(T){T.changedTouches!=null&&T.changedTouches.length>0&&A.handleMouseUp(T.changedTouches[0])}),be(A,"handleDoubleClick",function(T){var C=A.props.onDoubleClick;if(Ae(C)){var $=A.getMouseInfo(T);C($,T)}}),be(A,"handleContextMenu",function(T){var C=A.props.onContextMenu;if(Ae(C)){var $=A.getMouseInfo(T);C($,T)}}),be(A,"triggerSyncEvent",function(T){A.props.syncId!==void 0&&yg.emit(mg,A.props.syncId,T,A.eventEmitterSymbol)}),be(A,"applySyncEvent",function(T){var C=A.props,$=C.layout,z=C.syncMethod,Z=A.state.updateId,U=T.dataStartIndex,B=T.dataEndIndex;if(T.dataStartIndex!==void 0||T.dataEndIndex!==void 0)A.setState(ne({dataStartIndex:U,dataEndIndex:B},x({props:A.props,dataStartIndex:U,dataEndIndex:B,updateId:Z},A.state)));else if(T.activeTooltipIndex!==void 0){var V=T.chartX,W=T.chartY,F=T.activeTooltipIndex,R=A.state,G=R.offset,ee=R.tooltipTicks;if(!G)return;if(typeof z=="function")F=z(ee,T);else if(z==="value"){F=-1;for(var oe=0;oe<ee.length;oe++)if(ee[oe].value===T.activeLabel){F=oe;break}}var le=ne(ne({},G),{},{x:G.left,y:G.top}),P=Math.min(V,le.x+le.width),I=Math.min(W,le.y+le.height),re=ee[F]&&ee[F].value,se=qb(A.state,A.props.data,F),pe=ee[F]?{x:$==="horizontal"?ee[F].coordinate:P,y:$==="horizontal"?I:ee[F].coordinate}:WN;A.setState(ne(ne({},T),{},{activeLabel:re,activeCoordinate:pe,activePayload:se,activeTooltipIndex:F}))}else A.setState(T)}),be(A,"renderCursor",function(T){var C,$=A.state,z=$.isTooltipActive,Z=$.activeCoordinate,U=$.activePayload,B=$.offset,V=$.activeTooltipIndex,W=$.tooltipAxisBandSize,F=A.getTooltipEventType(),R=(C=T.props.active)!==null&&C!==void 0?C:z,G=A.props.layout,ee=T.key||"_recharts-cursor";return L.createElement(kG,{key:ee,activeCoordinate:Z,activePayload:U,activeTooltipIndex:V,chartName:n,element:T,isActive:R,layout:G,offset:B,tooltipAxisBandSize:W,tooltipEventType:F})}),be(A,"renderPolarAxis",function(T,C,$){var z=Cn(T,"type.axisType"),Z=Cn(A.state,"".concat(z,"Map")),U=T.type.defaultProps,B=U!==void 0?ne(ne({},U),T.props):T.props,V=Z&&Z[B["".concat(z,"Id")]];return Q.cloneElement(T,ne(ne({},V),{},{className:$e(z,V.className),key:T.key||"".concat(C,"-").concat($),ticks:Mr(V,!0)}))}),be(A,"renderPolarGrid",function(T){var C=T.props,$=C.radialLines,z=C.polarAngles,Z=C.polarRadius,U=A.state,B=U.radiusAxisMap,V=U.angleAxisMap,W=ya(B),F=ya(V),R=F.cx,G=F.cy,ee=F.innerRadius,oe=F.outerRadius;return Q.cloneElement(T,{polarAngles:Array.isArray(z)?z:Mr(F,!0).map(function(le){return le.coordinate}),polarRadius:Array.isArray(Z)?Z:Mr(W,!0).map(function(le){return le.coordinate}),cx:R,cy:G,innerRadius:ee,outerRadius:oe,key:T.key||"polar-grid",radialLines:$})}),be(A,"renderLegend",function(){var T=A.state.formattedGraphicalItems,C=A.props,$=C.children,z=C.width,Z=C.height,U=A.props.margin||{},B=z-(U.left||0)-(U.right||0),V=GC({children:$,formattedGraphicalItems:T,legendWidth:B,legendContent:h});if(!V)return null;var W=V.item,F=$2(V,UG);return Q.cloneElement(W,ne(ne({},F),{},{chartWidth:z,chartHeight:Z,margin:U,onBBoxUpdate:A.handleLegendBBoxUpdate}))}),be(A,"renderTooltip",function(){var T,C=A.props,$=C.children,z=C.accessibilityLayer,Z=hn($,pn);if(!Z)return null;var U=A.state,B=U.isTooltipActive,V=U.activeCoordinate,W=U.activePayload,F=U.activeLabel,R=U.offset,G=(T=Z.props.active)!==null&&T!==void 0?T:B;return Q.cloneElement(Z,{viewBox:ne(ne({},R),{},{x:R.left,y:R.top}),active:G,label:F,payload:G?W:[],coordinate:V,accessibilityLayer:z})}),be(A,"renderBrush",function(T){var C=A.props,$=C.margin,z=C.data,Z=A.state,U=Z.offset,B=Z.dataStartIndex,V=Z.dataEndIndex,W=Z.updateId;return Q.cloneElement(T,{key:T.key||"_recharts-brush",onChange:vs(A.handleBrushChange,T.props.onChange),data:z,x:fe(T.props.x)?T.props.x:U.left,y:fe(T.props.y)?T.props.y:U.top+U.height+U.brushBottom-($.bottom||0),width:fe(T.props.width)?T.props.width:U.width,startIndex:B,endIndex:V,updateId:"brush-".concat(W)})}),be(A,"renderReferenceElement",function(T,C,$){if(!T)return null;var z=A,Z=z.clipPathId,U=A.state,B=U.xAxisMap,V=U.yAxisMap,W=U.offset,F=T.type.defaultProps||{},R=T.props,G=R.xAxisId,ee=G===void 0?F.xAxisId:G,oe=R.yAxisId,le=oe===void 0?F.yAxisId:oe;return Q.cloneElement(T,{key:T.key||"".concat(C,"-").concat($),xAxis:B[ee],yAxis:V[le],viewBox:{x:W.left,y:W.top,width:W.width,height:W.height},clipPathId:Z})}),be(A,"renderActivePoints",function(T){var C=T.item,$=T.activePoint,z=T.basePoint,Z=T.childIndex,U=T.isRange,B=[],V=C.props.key,W=C.item.type.defaultProps!==void 0?ne(ne({},C.item.type.defaultProps),C.item.props):C.item.props,F=W.activeDot,R=W.dataKey,G=ne(ne({index:Z,dataKey:R,cx:$.x,cy:$.y,r:4,fill:D0(C.item),strokeWidth:2,stroke:"#fff",payload:$.payload,value:$.value},Ee(F,!1)),_s(F));return B.push(w.renderActiveDot(F,G,"".concat(V,"-activePoint-").concat(Z))),z?B.push(w.renderActiveDot(F,ne(ne({},G),{},{cx:z.x,cy:z.y}),"".concat(V,"-basePoint-").concat(Z))):U&&B.push(null),B}),be(A,"renderGraphicChild",function(T,C,$){var z=A.filterFormatItem(T,C,$);if(!z)return null;var Z=A.getTooltipEventType(),U=A.state,B=U.isTooltipActive,V=U.tooltipAxis,W=U.activeTooltipIndex,F=U.activeLabel,R=A.props.children,G=hn(R,pn),ee=z.props,oe=ee.points,le=ee.isRange,P=ee.baseLine,I=z.item.type.defaultProps!==void 0?ne(ne({},z.item.type.defaultProps),z.item.props):z.item.props,re=I.activeDot,se=I.hide,pe=I.activeBar,me=I.activeShape,Me=!!(!se&&B&&G&&(re||pe||me)),ke={};Z!=="axis"&&G&&G.props.trigger==="click"?ke={onClick:vs(A.handleItemMouseEnter,T.props.onClick)}:Z!=="axis"&&(ke={onMouseLeave:vs(A.handleItemMouseLeave,T.props.onMouseLeave),onMouseEnter:vs(A.handleItemMouseEnter,T.props.onMouseEnter)});var ce=Q.cloneElement(T,ne(ne({},z.props),ke));function xe(ur){return typeof V.dataKey=="function"?V.dataKey(ur.payload):null}if(Me)if(W>=0){var Se,ue;if(V.dataKey&&!V.allowDuplicatedCategory){var et=typeof V.dataKey=="function"?xe:"payload.".concat(V.dataKey.toString());Se=Os(oe,et,F),ue=le&&P&&Os(P,et,F)}else Se=oe==null?void 0:oe[W],ue=le&&P&&P[W];if(me||pe){var we=T.props.activeIndex!==void 0?T.props.activeIndex:W;return[Q.cloneElement(T,ne(ne(ne({},z.props),ke),{},{activeIndex:we})),null,null]}if(!je(Se))return[ce].concat(No(A.renderActivePoints({item:z,activePoint:Se,basePoint:ue,childIndex:W,isRange:le})))}else{var ot,ut=(ot=A.getItemByXY(A.state.activeCoordinate))!==null&&ot!==void 0?ot:{graphicalItem:ce},zt=ut.graphicalItem,Rn=zt.item,Kn=Rn===void 0?T:Rn,Ir=zt.childIndex,$n=ne(ne(ne({},z.props),ke),{},{activeIndex:Ir});return[Q.cloneElement(Kn,$n),null,null]}return le?[ce,null,null]:[ce,null]}),be(A,"renderCustomized",function(T,C,$){return Q.cloneElement(T,ne(ne({key:"recharts-customized-".concat($)},A.props),A.state))}),be(A,"renderMap",{CartesianGrid:{handler:xs,once:!0},ReferenceArea:{handler:A.renderReferenceElement},ReferenceLine:{handler:xs},ReferenceDot:{handler:A.renderReferenceElement},XAxis:{handler:xs},YAxis:{handler:xs},Brush:{handler:A.renderBrush,once:!0},Bar:{handler:A.renderGraphicChild},Line:{handler:A.renderGraphicChild},Area:{handler:A.renderGraphicChild},Radar:{handler:A.renderGraphicChild},RadialBar:{handler:A.renderGraphicChild},Scatter:{handler:A.renderGraphicChild},Pie:{handler:A.renderGraphicChild},Funnel:{handler:A.renderGraphicChild},Tooltip:{handler:A.renderCursor,once:!0},PolarGrid:{handler:A.renderPolarGrid,once:!0},PolarAngleAxis:{handler:A.renderPolarAxis},PolarRadiusAxis:{handler:A.renderPolarAxis},Customized:{handler:A.renderCustomized}}),A.clipPathId="".concat((j=E.id)!==null&&j!==void 0?j:$o("recharts"),"-clip"),A.throttleTriggeredAfterMouseMove=GM(A.triggeredAfterMouseMove,(N=E.throttleDelay)!==null&&N!==void 0?N:1e3/60),A.state={},A}return JG(w,b),FG(w,[{key:"componentDidMount",value:function(){var j,N;this.addListener(),this.accessibilityManager.setDetails({container:this.container,offset:{left:(j=this.props.margin.left)!==null&&j!==void 0?j:0,top:(N=this.props.margin.top)!==null&&N!==void 0?N:0},coordinateList:this.state.tooltipTicks,mouseHandlerCallback:this.triggeredAfterMouseMove,layout:this.props.layout}),this.displayDefaultTooltip()}},{key:"displayDefaultTooltip",value:function(){var j=this.props,N=j.children,A=j.data,T=j.height,C=j.layout,$=hn(N,pn);if($){var z=$.props.defaultIndex;if(!(typeof z!="number"||z<0||z>this.state.tooltipTicks.length-1)){var Z=this.state.tooltipTicks[z]&&this.state.tooltipTicks[z].value,U=qb(this.state,A,z,Z),B=this.state.tooltipTicks[z].coordinate,V=(this.state.offset.top+T)/2,W=C==="horizontal",F=W?{x:B,y:V}:{y:B,x:V},R=this.state.formattedGraphicalItems.find(function(ee){var oe=ee.item;return oe.type.name==="Scatter"});R&&(F=ne(ne({},F),R.props.points[z].tooltipPosition),U=R.props.points[z].tooltipPayload);var G={activeTooltipIndex:z,isTooltipActive:!0,activeLabel:Z,activePayload:U,activeCoordinate:F};this.setState(G),this.renderCursor($),this.accessibilityManager.setIndex(z)}}}},{key:"getSnapshotBeforeUpdate",value:function(j,N){if(!this.props.accessibilityLayer)return null;if(this.state.tooltipTicks!==N.tooltipTicks&&this.accessibilityManager.setDetails({coordinateList:this.state.tooltipTicks}),this.props.layout!==j.layout&&this.accessibilityManager.setDetails({layout:this.props.layout}),this.props.margin!==j.margin){var A,T;this.accessibilityManager.setDetails({offset:{left:(A=this.props.margin.left)!==null&&A!==void 0?A:0,top:(T=this.props.margin.top)!==null&&T!==void 0?T:0}})}return null}},{key:"componentDidUpdate",value:function(j){Sg([hn(j.children,pn)],[hn(this.props.children,pn)])||this.displayDefaultTooltip()}},{key:"componentWillUnmount",value:function(){this.removeListener(),this.throttleTriggeredAfterMouseMove.cancel()}},{key:"getTooltipEventType",value:function(){var j=hn(this.props.children,pn);if(j&&typeof j.props.shared=="boolean"){var N=j.props.shared?"axis":"item";return f.indexOf(N)>=0?N:l}return l}},{key:"getMouseInfo",value:function(j){if(!this.container)return null;var N=this.container,A=N.getBoundingClientRect(),T=Q8(A),C={chartX:Math.round(j.pageX-T.left),chartY:Math.round(j.pageY-T.top)},$=A.width/N.offsetWidth||1,z=this.inRange(C.chartX,C.chartY,$);if(!z)return null;var Z=this.state,U=Z.xAxisMap,B=Z.yAxisMap,V=this.getTooltipEventType(),W=z2(this.state,this.props.data,this.props.layout,z);if(V!=="axis"&&U&&B){var F=ya(U).scale,R=ya(B).scale,G=F&&F.invert?F.invert(C.chartX):null,ee=R&&R.invert?R.invert(C.chartY):null;return ne(ne({},C),{},{xValue:G,yValue:ee},W)}return W?ne(ne({},C),W):null}},{key:"inRange",value:function(j,N){var A=arguments.length>2&&arguments[2]!==void 0?arguments[2]:1,T=this.props.layout,C=j/A,$=N/A;if(T==="horizontal"||T==="vertical"){var z=this.state.offset,Z=C>=z.left&&C<=z.left+z.width&&$>=z.top&&$<=z.top+z.height;return Z?{x:C,y:$}:null}var U=this.state,B=U.angleAxisMap,V=U.radiusAxisMap;if(B&&V){var W=ya(B);return WE({x:C,y:$},W)}return null}},{key:"parseEventsOfWrapper",value:function(){var j=this.props.children,N=this.getTooltipEventType(),A=hn(j,pn),T={};A&&N==="axis"&&(A.props.trigger==="click"?T={onClick:this.handleClick}:T={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 C=_s(this.props,this.handleOuterEvent);return ne(ne({},C),T)}},{key:"addListener",value:function(){yg.on(mg,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){yg.removeListener(mg,this.handleReceiveSyncEvent)}},{key:"filterFormatItem",value:function(j,N,A){for(var T=this.state.formattedGraphicalItems,C=0,$=T.length;C<$;C++){var z=T[C];if(z.item===j||z.props.key===j.key||N===Cr(z.item.type)&&A===z.childIndex)return z}return null}},{key:"renderClipPath",value:function(){var j=this.clipPathId,N=this.state.offset,A=N.left,T=N.top,C=N.height,$=N.width;return L.createElement("defs",null,L.createElement("clipPath",{id:j},L.createElement("rect",{x:A,y:T,height:C,width:$})))}},{key:"getXScales",value:function(){var j=this.state.xAxisMap;return j?Object.entries(j).reduce(function(N,A){var T=R2(A,2),C=T[0],$=T[1];return ne(ne({},N),{},be({},C,$.scale))},{}):null}},{key:"getYScales",value:function(){var j=this.state.yAxisMap;return j?Object.entries(j).reduce(function(N,A){var T=R2(A,2),C=T[0],$=T[1];return ne(ne({},N),{},be({},C,$.scale))},{}):null}},{key:"getXScaleByAxisId",value:function(j){var N;return(N=this.state.xAxisMap)===null||N===void 0||(N=N[j])===null||N===void 0?void 0:N.scale}},{key:"getYScaleByAxisId",value:function(j){var N;return(N=this.state.yAxisMap)===null||N===void 0||(N=N[j])===null||N===void 0?void 0:N.scale}},{key:"getItemByXY",value:function(j){var N=this.state,A=N.formattedGraphicalItems,T=N.activeItem;if(A&&A.length)for(var C=0,$=A.length;C<$;C++){var z=A[C],Z=z.props,U=z.item,B=U.type.defaultProps!==void 0?ne(ne({},U.type.defaultProps),U.props):U.props,V=Cr(U.type);if(V==="Bar"){var W=(Z.data||[]).find(function(ee){return gI(j,ee)});if(W)return{graphicalItem:z,payload:W}}else if(V==="RadialBar"){var F=(Z.data||[]).find(function(ee){return WE(j,ee)});if(F)return{graphicalItem:z,payload:F}}else if(Xf(z,T)||Kf(z,T)||El(z,T)){var R=l9({graphicalItem:z,activeTooltipItem:T,itemData:B.data}),G=B.activeIndex===void 0?R:B.activeIndex;return{graphicalItem:ne(ne({},z),{},{childIndex:G}),payload:El(z,T)?B.data[R]:z.props.data[R]}}}return null}},{key:"render",value:function(){var j=this;if(!sA(this))return null;var N=this.props,A=N.children,T=N.className,C=N.width,$=N.height,z=N.style,Z=N.compact,U=N.title,B=N.desc,V=$2(N,IG),W=Ee(V,!1);if(Z)return L.createElement(h2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},L.createElement(_g,no({},W,{width:C,height:$,title:U,desc:B}),this.renderClipPath(),dA(A,this.renderMap)));if(this.props.accessibilityLayer){var F,R;W.tabIndex=(F=this.props.tabIndex)!==null&&F!==void 0?F:0,W.role=(R=this.props.role)!==null&&R!==void 0?R:"application",W.onKeyDown=function(ee){j.accessibilityManager.keyboardEvent(ee)},W.onFocus=function(){j.accessibilityManager.focus()}}var G=this.parseEventsOfWrapper();return L.createElement(h2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},L.createElement("div",no({className:$e("recharts-wrapper",T),style:ne({position:"relative",cursor:"default",width:C,height:$},z)},G,{ref:function(oe){j.container=oe}}),L.createElement(_g,no({},W,{width:C,height:$,title:U,desc:B,style:iY}),this.renderClipPath(),dA(A,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(Q.Component);be(_,"displayName",n),be(_,"defaultProps",ne({layout:"horizontal",stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:"index"},y)),be(_,"getDerivedStateFromProps",function(b,w){var E=b.dataKey,j=b.data,N=b.children,A=b.width,T=b.height,C=b.layout,$=b.stackOffset,z=b.margin,Z=w.dataStartIndex,U=w.dataEndIndex;if(w.updateId===void 0){var B=B2(b);return ne(ne(ne({},B),{},{updateId:0},x(ne(ne({props:b},B),{},{updateId:0}),w)),{},{prevDataKey:E,prevData:j,prevWidth:A,prevHeight:T,prevLayout:C,prevStackOffset:$,prevMargin:z,prevChildren:N})}if(E!==w.prevDataKey||j!==w.prevData||A!==w.prevWidth||T!==w.prevHeight||C!==w.prevLayout||$!==w.prevStackOffset||!ro(z,w.prevMargin)){var V=B2(b),W={chartX:w.chartX,chartY:w.chartY,isTooltipActive:w.isTooltipActive},F=ne(ne({},z2(w,j,C)),{},{updateId:w.updateId+1}),R=ne(ne(ne({},V),W),F);return ne(ne(ne({},R),x(ne({props:b},R),w)),{},{prevDataKey:E,prevData:j,prevWidth:A,prevHeight:T,prevLayout:C,prevStackOffset:$,prevMargin:z,prevChildren:N})}if(!Sg(N,w.prevChildren)){var G,ee,oe,le,P=hn(N,xo),I=P&&(G=(ee=P.props)===null||ee===void 0?void 0:ee.startIndex)!==null&&G!==void 0?G:Z,re=P&&(oe=(le=P.props)===null||le===void 0?void 0:le.endIndex)!==null&&oe!==void 0?oe:U,se=I!==Z||re!==U,pe=!je(j),me=pe&&!se?w.updateId:w.updateId+1;return ne(ne({updateId:me},x(ne(ne({props:b},w),{},{updateId:me,dataStartIndex:I,dataEndIndex:re}),w)),{},{prevChildren:N,dataStartIndex:I,dataEndIndex:re})}return null}),be(_,"renderActiveDot",function(b,w,E){var j;return Q.isValidElement(b)?j=Q.cloneElement(b,w):Ae(b)?j=b(w):j=L.createElement(Yf,w),L.createElement(Je,{className:"recharts-active-dot",key:E},j)});var S=Q.forwardRef(function(w,E){return L.createElement(_,no({},w,{ref:E}))});return S.displayName=_.displayName,S},vY=H0({chartName:"LineChart",GraphicalChild:Il,axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:R0}),yY=H0({chartName:"BarChart",GraphicalChild:fi,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:R0}),eD=H0({chartName:"AreaChart",GraphicalChild:Yn,axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:R0});function mY(e){return new Date(e).toLocaleString("es",{hour:"2-digit",minute:"2-digit",day:"numeric",month:"short"})}function gY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState([]);Q.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ft.timeseries("claude_code.tokens.input",e,v),ft.timeseries("claude_code.tokens.output",e,v)]).then(([y,g])=>{r(y),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(v=>v.timestamp),...o.map(v=>v.timestamp)]),f=new Map(n.map(v=>[v.timestamp,v.value])),d=new Map(o.map(v=>[v.timestamp,v.value])),h=Array.from(c).sort().map(v=>({ts:v,label:mY(v),input:f.get(v)??0,output:d.get(v)??0}));return h.length===0?D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de tokens"})}):D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Tokens por período"}),D.jsx($f,{width:"100%",height:220,children:D.jsxs(eD,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[D.jsxs("defs",{children:[D.jsxs("linearGradient",{id:"colorInput",x1:"0",y1:"0",x2:"0",y2:"1",children:[D.jsx("stop",{offset:"5%",stopColor:"#4da6ff",stopOpacity:.3}),D.jsx("stop",{offset:"95%",stopColor:"#4da6ff",stopOpacity:0})]}),D.jsxs("linearGradient",{id:"colorOutput",x1:"0",y1:"0",x2:"0",y2:"1",children:[D.jsx("stop",{offset:"5%",stopColor:"#00ff88",stopOpacity:.3}),D.jsx("stop",{offset:"95%",stopColor:"#00ff88",stopOpacity:0})]})]}),D.jsx(Ul,{strokeDasharray:"3 3",stroke:"#1a1a1a"}),D.jsx(kr,{dataKey:"label",tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:{stroke:"#1a1a1a"}}),D.jsx(Ur,{tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:v=>v>=1e3?`${(v/1e3).toFixed(0)}K`:String(v)}),D.jsx(pn,{contentStyle:{background:"#0d0d0d",border:"1px solid #1a1a1a",borderRadius:"6px"},labelStyle:{color:"#888888",fontSize:12},itemStyle:{fontSize:12}}),D.jsx(ba,{wrapperStyle:{fontSize:12,color:"#888888"}}),D.jsx(Yn,{type:"monotone",dataKey:"input",name:"Input",stroke:"#4da6ff",fill:"url(#colorInput)",strokeWidth:2}),D.jsx(Yn,{type:"monotone",dataKey:"output",name:"Output",stroke:"#00ff88",fill:"url(#colorOutput)",strokeWidth:2})]})})]})}function bY(e){return new Date(e).toLocaleDateString("es",{day:"numeric",month:"short"})}function xY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]);Q.useEffect(()=>{ft.timeseries("claude_code.cost",e,"1d").then(r).catch(()=>{})},[e,t]);const o=n.map(l=>({label:bY(l.timestamp),cost:Number(l.value.toFixed(2))}));return o.length===0?D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de coste"})}):D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Coste por día ($)"}),D.jsx($f,{width:"100%",height:220,children:D.jsxs(yY,{data:o,margin:{top:4,right:8,left:0,bottom:0},children:[D.jsx(Ul,{strokeDasharray:"3 3",stroke:"#1a1a1a",vertical:!1}),D.jsx(kr,{dataKey:"label",tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:{stroke:"#1a1a1a"}}),D.jsx(Ur,{tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:l=>`$${l.toFixed(2)}`}),D.jsx(pn,{contentStyle:{background:"#0d0d0d",border:"1px solid #1a1a1a",borderRadius:"6px"},labelStyle:{color:"#888888",fontSize:12},formatter:l=>[`$${l.toFixed(2)}`,"Coste"]}),D.jsx(fi,{dataKey:"cost",fill:"#a855f7",radius:[3,3,0,0]})]})})]})}function SY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState([]);Q.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ft.timeseries("claude_code.tokens.cache.read",e,v),ft.timeseries("claude_code.tokens.cache.creation",e,v)]).then(([y,g])=>{r(y),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(v=>v.timestamp),...o.map(v=>v.timestamp)]),f=new Map(n.map(v=>[v.timestamp,v.value])),d=new Map(o.map(v=>[v.timestamp,v.value])),h=Array.from(c).sort().map(v=>({label:new Date(v).toLocaleString("es",{hour:"2-digit",day:"numeric",month:"short"}),read:f.get(v)??0,create:d.get(v)??0}));return h.length===0?D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de caché"})}):D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Tokens de caché"}),D.jsx($f,{width:"100%",height:220,children:D.jsxs(eD,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[D.jsx(Ul,{strokeDasharray:"3 3",stroke:"#1a1a1a"}),D.jsx(kr,{dataKey:"label",tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:{stroke:"#1a1a1a"}}),D.jsx(Ur,{tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:!1,tickFormatter:v=>v>=1e3?`${(v/1e3).toFixed(0)}K`:String(v)}),D.jsx(pn,{contentStyle:{background:"#0d0d0d",border:"1px solid #1a1a1a",borderRadius:"6px"}}),D.jsx(ba,{wrapperStyle:{fontSize:12,color:"#888888"}}),D.jsx(Yn,{type:"monotone",dataKey:"read",name:"Leído",stroke:"#00d4aa",fill:"#00d4aa",fillOpacity:.2,strokeWidth:2}),D.jsx(Yn,{type:"monotone",dataKey:"create",name:"Creado",stroke:"#4da6ff",fill:"#4da6ff",fillOpacity:.2,strokeWidth:2})]})})]})}function OY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState([]);Q.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ft.timeseries("claude_code.tokens.input",e,v),ft.timeseries("claude_code.tokens.output",e,v)]).then(([y,g])=>{r(y),l(g)}).catch(()=>{})},[e,t]);const c=new Set([...n.map(v=>v.timestamp),...o.map(v=>v.timestamp)]),f=new Map(n.map(v=>[v.timestamp,v.value])),d=new Map(o.map(v=>[v.timestamp,v.value])),h=Array.from(c).sort().map(v=>{const y=f.get(v)??0,g=d.get(v)??0;return{label:new Date(v).toLocaleString("es",{hour:"2-digit",day:"numeric",month:"short"}),efficiency:y>0?Number((g/y).toFixed(3)):0}});return h.length===0?D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-6 flex items-center justify-center h-48",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de eficiencia"})}):D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("h3",{className:"text-sm font-medium text-text-secondary mb-4",children:"Ratio output/input"}),D.jsx($f,{width:"100%",height:220,children:D.jsxs(vY,{data:h,margin:{top:4,right:8,left:0,bottom:0},children:[D.jsx(Ul,{strokeDasharray:"3 3",stroke:"#1a1a1a"}),D.jsx(kr,{dataKey:"label",tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:{stroke:"#1a1a1a"}}),D.jsx(Ur,{tick:{fill:"#888888",fontSize:11},tickLine:!1,axisLine:!1,domain:[0,"auto"]}),D.jsx(pn,{contentStyle:{background:"#0d0d0d",border:"1px solid #1a1a1a",borderRadius:"6px"},formatter:v=>[v.toFixed(3),"Eficiencia"]}),D.jsx(Ff,{y:.5,stroke:"#444444",strokeDasharray:"4 4",label:{value:"0.5",fill:"#666",fontSize:10}}),D.jsx(Il,{type:"monotone",dataKey:"efficiency",stroke:"#a855f7",strokeWidth:2,dot:!1})]})})]})}function _Y({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState(null),[c,f]=Q.useState([]),[d,h]=Q.useState(null),[v,y]=Q.useState("");Q.useEffect(()=>{ft.sessions(50).then(r).catch(()=>{})},[e,t]);function g(S){o===S?(l(null),f([])):(f([]),l(S),ft.sessionEvents(S).then(f).catch(()=>{}))}function x(S,b,w){w.stopPropagation(),h(S),y(b??"")}async function _(S){v.trim()&&(await ft.labelSession(S,v.trim()).catch(()=>{}),r(b=>b.map(w=>w.sessionId===S?{...w,project:v.trim()}:w))),h(null)}return n.length===0?D.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin sesiones registradas"}):D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg",children:D.jsx("div",{className:"overflow-x-auto",children:D.jsxs("table",{className:"w-full text-sm min-w-[720px] whitespace-nowrap",children:[D.jsx("thead",{children:D.jsxs("tr",{className:"border-b border-bg-border",children:[D.jsx("th",{className:"w-6 px-3 py-2"}),D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"ID"}),D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"Proyecto"}),D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"Modelo"}),D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"Inicio"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Duración"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Input"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Output"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Coste"})]})}),D.jsx("tbody",{children:n.map(S=>D.jsxs(Q.Fragment,{children:[D.jsxs("tr",{className:"border-b border-bg-border hover:bg-bg-card-hover cursor-pointer",onClick:()=>g(S.sessionId),children:[D.jsx("td",{className:"px-3 py-2 text-text-muted",children:o===S.sessionId?D.jsx(BR,{size:14}):D.jsx(kR,{size:14})}),D.jsxs("td",{className:"px-3 py-2 font-mono text-text-secondary text-xs",children:[S.sessionId.slice(0,8),"…"]}),D.jsx("td",{className:"px-3 py-2",onClick:b=>b.stopPropagation(),children:d===S.sessionId?D.jsxs("span",{className:"flex items-center gap-1",children:[D.jsx("input",{autoFocus:!0,value:v,onChange:b=>y(b.target.value),onKeyDown:b=>{b.key==="Enter"&&_(S.sessionId),b.key==="Escape"&&h(null)},className:"bg-bg-base border border-bg-border rounded px-1 py-0.5 text-xs text-text-primary w-24 outline-none focus:border-accent-green"}),D.jsx("button",{onClick:()=>_(S.sessionId),className:"text-accent-green",children:D.jsx(Bb,{size:12})}),D.jsx("button",{onClick:()=>h(null),className:"text-accent-orange",children:D.jsx(I2,{size:12})})]}):D.jsxs("span",{onClick:b=>x(S.sessionId,S.project,b),className:"inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs bg-bg-base border border-bg-border text-text-secondary hover:border-accent-green cursor-pointer transition-colors",children:[S.project??"—",D.jsx(XR,{size:10,className:"opacity-50"})]})}),D.jsx("td",{className:"px-3 py-2 text-text-secondary font-mono text-xs",children:S.model??"—"}),D.jsx("td",{className:"px-3 py-2 text-text-secondary",children:c3(S.startTime)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-text-secondary",children:Lb(S.durationActiveMs)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:er(S.tokensInput)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:er(S.tokensOutput)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:ei(S.cost)})]}),o===S.sessionId&&D.jsx("tr",{children:D.jsx("td",{colSpan:9,className:"bg-bg-subtle px-6 py-3",children:D.jsx("div",{className:"text-xs font-mono space-y-0.5 max-h-40 overflow-y-auto",children:c.length===0?D.jsx("span",{className:"text-text-muted",children:"Sin eventos"}):c.slice(-20).map((b,w)=>D.jsxs("div",{className:"flex gap-2 text-text-secondary",children:[D.jsx("span",{className:"text-text-muted shrink-0",children:new Date(b.timestamp).toLocaleTimeString()}),D.jsx("span",{className:"text-accent-teal",children:b.eventName})]},`${b.timestamp}-${b.eventName}-${w}`))})})})]},S.sessionId))})]})})})}function AY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState(null),c=Q.useCallback(()=>{ft.projects(e).then(r).catch(()=>{})},[e]);Q.useEffect(()=>{c()},[c,t]);const f=async h=>{if(confirm(`¿Resetear todos los datos del proyecto "${h}"?`)){l(h);try{await ft.resetProject(h),c()}finally{l(null)}}};if(n.length===0)return D.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin proyectos registrados"});const d=Math.max(...n.map(h=>h.cost),1e-4);return D.jsxs("div",{className:"flex flex-col gap-4",children:[D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 space-y-3",children:n.map(h=>D.jsxs("div",{children:[D.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[D.jsx("span",{className:"text-text-primary font-medium",children:h.project}),D.jsx("span",{className:"text-accent-purple font-mono",children:ei(h.cost)})]}),D.jsx("div",{className:"h-2 bg-bg-base rounded-full overflow-hidden",children:D.jsx("div",{className:"h-full bg-accent-purple rounded-full",style:{width:`${h.cost/d*100}%`}})})]},h.project))}),D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-x-auto",children:D.jsxs("table",{className:"w-full text-sm min-w-[640px]",children:[D.jsx("thead",{children:D.jsxs("tr",{className:"border-b border-bg-border",children:[D.jsx("th",{className:"text-left px-3 py-2 text-text-muted font-medium",children:"Proyecto"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Sesiones"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Input"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Output"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Caché %"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Coste"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"Commits"}),D.jsx("th",{className:"text-right px-3 py-2 text-text-muted font-medium",children:"LOC +/-"}),D.jsx("th",{className:"px-3 py-2"})]})}),D.jsx("tbody",{children:n.map(h=>D.jsxs("tr",{className:"border-b border-bg-border hover:bg-bg-card-hover",children:[D.jsx("td",{className:"px-3 py-2 text-text-primary font-medium",children:h.project}),D.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:h.sessions}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:er(h.tokensInput)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:er(h.tokensOutput)}),D.jsxs("td",{className:"px-3 py-2 text-right font-mono text-accent-teal",children:[(h.cacheHitRate*100).toFixed(1),"%"]}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:ei(h.cost)}),D.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:h.commits}),D.jsxs("td",{className:"px-3 py-2 text-right font-mono text-xs",children:[D.jsxs("span",{className:"text-accent-green",children:["+",h.linesAdded]}),D.jsx("span",{className:"text-text-muted",children:" / "}),D.jsxs("span",{className:"text-accent-orange",children:["-",h.linesRemoved]})]}),D.jsx("td",{className:"px-3 py-2 text-right",children:D.jsx("button",{onClick:()=>f(h.project),disabled:o===h.project,title:"Resetear proyecto",className:"p-1 rounded text-text-muted hover:text-accent-orange hover:bg-bg-base transition-colors disabled:opacity-40",children:D.jsx(WR,{size:13})})})]},h.project))})]})})]})}function wY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState(null);if(Q.useEffect(()=>{ft.tools(e).then(r).catch(()=>{})},[e,t]),!n||n.usage.length===0)return D.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin datos de herramientas"});const o=Math.max(...n.usage.map(f=>f.count),1),l=n.decisionRate.approved+n.decisionRate.rejected,c=l>0?(n.decisionRate.approved/l*100).toFixed(1):"—";return D.jsxs("div",{className:"flex flex-col gap-4",children:[D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("span",{className:"text-text-secondary text-sm",children:"Tasa de aprobación: "}),D.jsxs("span",{className:"text-accent-green font-mono font-bold",children:[c,"%"]}),D.jsxs("span",{className:"text-text-muted text-xs ml-2",children:["(",n.decisionRate.approved," aprobadas / ",n.decisionRate.rejected," rechazadas)"]})]}),D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 space-y-2",children:n.usage.map(f=>D.jsxs("div",{children:[D.jsxs("div",{className:"flex justify-between text-xs mb-1",children:[D.jsx("span",{className:"font-mono text-text-primary",children:f.toolName}),D.jsxs("span",{className:"text-text-secondary",children:[f.count," usos · ",(f.successRate*100).toFixed(0),"% éxito"]})]}),D.jsx("div",{className:"h-1.5 bg-bg-base rounded-full overflow-hidden",children:D.jsx("div",{className:"h-full bg-accent-teal rounded-full",style:{width:`${f.count/o*100}%`}})})]},f.toolName))})]})}const Ss={"claude-opus-4-8":{input:15,output:75,cacheWrite:18.75,cacheRead:1.5},"claude-sonnet-4-6":{input:3,output:15,cacheWrite:3.75,cacheRead:.3},"claude-haiku-4-5":{input:.8,output:4,cacheWrite:1,cacheRead:.08}},k2=Ss["claude-sonnet-4-6"];function tD(e){if(!e)return k2;const t=e.toLowerCase();return t.includes("opus")?Ss["claude-opus-4-8"]:t.includes("haiku")?Ss["claude-haiku-4-5"]:t.includes("sonnet")?Ss["claude-sonnet-4-6"]:k2}function TY(e,t){const n=tD(t);return e*(n.input-n.cacheRead)/1e6}const EY=[{id:"all",label:"Todos"},{id:"api",label:"API"},{id:"tools",label:"Tools"},{id:"prompts",label:"Prompts"},{id:"errors",label:"Errores"}];function jY(e){return e>=1?`$${e.toFixed(2)}`:e>=.01?`$${e.toFixed(3)}`:`$${e.toFixed(4)}`}function MY(e){const t=e.attributes;if(typeof t.cost=="number"&&t.cost>0)return t.cost;const n=Number(t.input_tokens??t["tokens.input"]??0),r=Number(t.output_tokens??t["tokens.output"]??0),o=Number(t.cache_read_input_tokens??t["tokens.cache_read"]??0),l=Number(t.cache_creation_input_tokens??t["tokens.cache_creation"]??0);if(n===0&&r===0)return null;const c=tD(e.model);return n*c.input/1e6+r*c.output/1e6+o*c.cacheRead/1e6+l*c.cacheWrite/1e6}function CY(e){return e.includes("error")?"text-accent-orange":e==="user_prompt"?"text-accent-blue":e==="api_request"?"text-accent-green":e==="tool_use"?"text-accent-teal":e.startsWith("hook_")?"text-accent-yellow":"text-text-secondary"}function NY(e,t){return t==="all"?!0:t==="api"?e.eventName.includes("api"):t==="tools"?e.eventName.includes("tool"):t==="prompts"?e.eventName.includes("prompt"):t==="errors"?e.eventName.includes("error"):!0}function DY({timeRange:e,sseVersion:t}){const[n,r]=Q.useState([]),[o,l]=Q.useState("all"),[c,f]=Q.useState(!1);Q.useEffect(()=>{c||ft.events(500).then(r).catch(()=>{})},[e,t,c]);const d=n.filter(h=>NY(h,o));return D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg flex flex-col h-[600px]",children:[D.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 border-b border-bg-border flex-wrap",children:[EY.map(({id:h,label:v})=>D.jsx("button",{onClick:()=>l(h),className:`px-2 py-1 rounded text-xs transition-colors ${o===h?"bg-accent-green text-black font-medium":"text-text-secondary hover:text-text-primary"}`,children:v},h)),D.jsx("div",{className:"flex-1"}),D.jsxs("button",{onClick:()=>f(h=>!h),className:"flex items-center gap-1 px-2 py-1 rounded text-xs text-text-secondary hover:text-text-primary",children:[c?D.jsx(VR,{size:12}):D.jsx(GR,{size:12}),D.jsx("span",{children:c?"Reanudar":"Pausar"})]})]}),D.jsx("div",{className:"flex-1 overflow-y-auto p-3 font-mono text-xs space-y-0.5",children:d.length===0?D.jsx("span",{className:"text-text-muted",children:"Sin eventos"}):d.map((h,v)=>{const y=MY(h);return D.jsxs("div",{className:"flex gap-2 hover:bg-bg-base px-1 rounded",children:[D.jsx("span",{className:"text-text-muted shrink-0",children:new Date(h.timestamp).toLocaleTimeString()}),D.jsx("span",{className:`shrink-0 ${CY(h.eventName)}`,children:h.eventName}),h.sessionId&&D.jsxs("span",{className:"text-text-muted",children:[h.sessionId.slice(0,6),"…"]}),y!==null&&D.jsx("span",{className:"text-accent-purple ml-auto shrink-0",children:jY(y)})]},`${h.sessionId??""}-${h.timestamp}-${h.eventName}-${v}`)})})]})}function PY({sseVersion:e}){const[t,n]=Q.useState([]);if(Q.useEffect(()=>{ft.agents().then(n).catch(()=>{})},[e]),t.length===0)return D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg p-8 flex items-center justify-center",children:D.jsx("span",{className:"text-text-muted text-sm",children:"Sin datos de agentes. Aparece cuando hay múltiples agentes en trazas OTLP."})});const r=t.filter(c=>!c.parentAgentId),o=c=>t.filter(f=>f.parentAgentId===c);function l({agent:c,depth:f=0}){const d=o(c.agentId);return D.jsxs("div",{style:{paddingLeft:`${f*16}px`},children:[D.jsxs("div",{className:"flex items-center gap-4 py-2 border-b border-bg-border text-sm hover:bg-bg-card-hover px-2",children:[D.jsxs("span",{className:"font-mono text-text-muted text-xs w-20 shrink-0",children:[c.agentId.slice(0,8),"…"]}),D.jsx("span",{className:"font-mono text-accent-blue",children:er(c.tokensInput)}),D.jsx("span",{className:"font-mono text-accent-green",children:er(c.tokensOutput)}),D.jsx("span",{className:"font-mono text-accent-purple",children:ei(c.cost)}),D.jsx("span",{className:"text-text-secondary",children:Lb(c.durationMs)}),D.jsxs("span",{className:"text-text-muted text-xs",children:[c.toolCalls," tools"]})]}),d.map(h=>D.jsx(l,{agent:h,depth:f+1},h.agentId))]})}return D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-hidden",children:[D.jsxs("div",{className:"px-3 py-2 border-b border-bg-border grid grid-cols-6 text-xs text-text-muted",children:[D.jsx("span",{children:"Agent ID"}),D.jsx("span",{children:"Input"}),D.jsx("span",{children:"Output"}),D.jsx("span",{children:"Coste"}),D.jsx("span",{children:"Duración"}),D.jsx("span",{children:"Tools"})]}),r.map(c=>D.jsx(l,{agent:c},c.agentId))]})}function RY(){const[e,t]=Q.useState("now-24h");return{timeRange:e,setTimeRange:t}}function $Y(e){Q.useEffect(()=>{let t=null,n;function r(){t=new EventSource("/api/stream"),t.onmessage=o=>{try{const{type:l,payload:c}=JSON.parse(o.data);l!=="ping"&&e(l,c)}catch{}},t.onerror=()=>{t==null||t.close(),t=null,n=setTimeout(r,3e3)}}return r(),()=>{clearTimeout(n),t==null||t.close()}},[])}function qY(e){const[t,n]=Q.useState({connected:!1,lastSeen:null,sessionCount:0,totalEvents:0,uptime:0}),[r,o]=Q.useState(null),[l,c]=Q.useState(0),f=Q.useRef(0),d=Q.useRef(0),h=Q.useCallback(async()=>{f.current=Date.now();try{const[y,g]=await Promise.all([ft.status(),ft.summary(e)]);n(y),o(g)}catch{}},[e]);Q.useEffect(()=>{h()},[h]);const v=Q.useCallback((y,g)=>{Date.now()-f.current>5e3?h():ft.status().then(n).catch(()=>{});const x=Date.now();x-d.current>5e3&&(d.current=x,c(_=>_+1))},[h]);return $Y(v),{status:t,summary:r,refetch:h,sseVersion:l}}function zY(){const[e,t]=Q.useState("overview"),{timeRange:n,setTimeRange:r}=RY(),{status:o,summary:l,refetch:c,sseVersion:f}=qY(n),d=Q.useCallback(async()=>{await ft.reset(),c()},[c]);return!o.connected&&o.totalEvents===0?D.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex flex-col",children:[D.jsx(e_,{timeRange:n,onTimeRangeChange:r,connected:!1,lastSeen:null,onReset:d}),D.jsx(a3,{})]}):D.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex flex-col",children:[D.jsx(e_,{timeRange:n,onTimeRangeChange:r,connected:o.connected,lastSeen:o.lastSeen,onReset:d}),D.jsx(u3,{onLabeled:c}),D.jsx(r3,{activeTab:e,onTabChange:t}),D.jsxs("main",{className:"flex-1 p-4 max-w-screen-2xl mx-auto w-full",children:[e==="overview"&&D.jsxs("div",{className:"flex flex-col gap-4",children:[(l==null?void 0:l.currentProject)&&D.jsxs("div",{className:"flex items-center gap-2",children:[D.jsx("span",{className:"text-xs text-text-muted uppercase tracking-wider",children:"Proyecto"}),D.jsx("span",{className:"text-lg font-semibold text-text-primary",children:l.currentProject})]}),l&&D.jsx(s3,{summary:l}),D.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[D.jsx(gY,{timeRange:n,sseVersion:f}),D.jsx(xY,{timeRange:n,sseVersion:f})]})]}),e==="sessions"&&D.jsx(_Y,{timeRange:n,sseVersion:f}),e==="projects"&&D.jsx(AY,{timeRange:n,sseVersion:f}),e==="tools"&&D.jsx(wY,{timeRange:n,sseVersion:f}),e==="agents"&&D.jsx(PY,{sseVersion:f}),e==="events"&&D.jsx(DY,{timeRange:n,sseVersion:f}),e==="costs"&&D.jsxs("div",{className:"flex flex-col gap-4",children:[l&&D.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-3",children:[D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Coste período"}),D.jsx("div",{className:"text-2xl font-mono font-bold text-accent-purple",children:ei(l.cost)})]}),D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Eficiencia"}),D.jsxs("div",{className:"text-2xl font-mono font-bold text-accent-green",children:[(l.efficiency*100).toFixed(1),"%"]})]}),D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Tokens caché"}),D.jsx("div",{className:"text-2xl font-mono font-bold text-accent-teal",children:er(l.tokens.cache)})]}),D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4",children:[D.jsx("div",{className:"text-xs text-text-muted uppercase tracking-wider mb-1",children:"Ahorro caché est."}),D.jsx("div",{className:"text-2xl font-mono font-bold text-accent-yellow",children:ei(TY(l.tokens.cache))})]})]}),D.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[D.jsx(SY,{timeRange:n,sseVersion:f}),D.jsx(OY,{timeRange:n,sseVersion:f})]})]})]})]})}CR.createRoot(document.getElementById("root")).render(D.jsx(Q.StrictMode,{children:D.jsx(zY,{})}));
|
package/dist/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>tokenrace</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-BeIgeSpB.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-Bfrxw7xK.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* git-detector.js
|
|
3
|
+
*
|
|
4
|
+
* Detecta el proyecto git a partir de un path hint (directorio o fichero).
|
|
5
|
+
* Usa execFile (sin shell) para evitar inyección de comandos.
|
|
6
|
+
*
|
|
7
|
+
* Export:
|
|
8
|
+
* detectGitProject(pathHint) → Promise<{ name, remote }|null>
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { execFile } from 'node:child_process'
|
|
12
|
+
import path from 'node:path'
|
|
13
|
+
import fs from 'node:fs'
|
|
14
|
+
|
|
15
|
+
function git(args, cwd) {
|
|
16
|
+
return new Promise((resolve, reject) => {
|
|
17
|
+
execFile('git', args, { cwd, timeout: 5000 }, (err, stdout) => {
|
|
18
|
+
if (err) reject(err)
|
|
19
|
+
else resolve(stdout.trim())
|
|
20
|
+
})
|
|
21
|
+
})
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Detecta el nombre del proyecto git a partir de un path hint.
|
|
26
|
+
* @param {string} pathHint - Directorio de trabajo o ruta de fichero
|
|
27
|
+
* @returns {Promise<{ name: string, remote: string|null }|null>}
|
|
28
|
+
*/
|
|
29
|
+
export async function detectGitProject(pathHint) {
|
|
30
|
+
if (!pathHint) return null
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
// Si es un fichero, usar su directorio
|
|
34
|
+
let dir = pathHint
|
|
35
|
+
try {
|
|
36
|
+
if (!fs.statSync(pathHint).isDirectory()) dir = path.dirname(pathHint)
|
|
37
|
+
} catch {
|
|
38
|
+
dir = path.dirname(pathHint)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Obtener el root del repositorio git
|
|
42
|
+
const root = await git(['rev-parse', '--show-toplevel'], dir)
|
|
43
|
+
|
|
44
|
+
// Intentar obtener la URL del remote origin
|
|
45
|
+
let remote = null
|
|
46
|
+
try {
|
|
47
|
+
remote = await git(['remote', 'get-url', 'origin'], root)
|
|
48
|
+
} catch { /* sin remote — usaremos el nombre del directorio */ }
|
|
49
|
+
|
|
50
|
+
// Extraer nombre del proyecto
|
|
51
|
+
// https://github.com/user/repo.git → repo
|
|
52
|
+
// git@github.com:user/repo.git → repo
|
|
53
|
+
const name = remote
|
|
54
|
+
? remote.replace(/\.git$/, '').split(/[/:]/g).pop()
|
|
55
|
+
: path.basename(root)
|
|
56
|
+
|
|
57
|
+
return { name, remote: remote ?? null }
|
|
58
|
+
} catch {
|
|
59
|
+
return null
|
|
60
|
+
}
|
|
61
|
+
}
|
package/src/server.js
CHANGED
|
@@ -15,7 +15,8 @@ import express from 'express'
|
|
|
15
15
|
import path from 'node:path'
|
|
16
16
|
import { fileURLToPath } from 'node:url'
|
|
17
17
|
import { parseMetrics, parseEvents, parseTraces } from './otlp-parser.js'
|
|
18
|
-
import { processMetric, processEvent, processTrace, loadFromDisk, startAutoSave, saveSync } from './store.js'
|
|
18
|
+
import { processMetric, processEvent, processTrace, loadFromDisk, startAutoSave, saveSync, drainAutoDetectQueue, labelSession } from './store.js'
|
|
19
|
+
import { detectGitProject } from './git-detector.js'
|
|
19
20
|
import { createRouter, broadcast } from './api-routes.js'
|
|
20
21
|
|
|
21
22
|
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
|
@@ -39,6 +40,22 @@ export async function startServer({ port = 1337 } = {}) {
|
|
|
39
40
|
next()
|
|
40
41
|
})
|
|
41
42
|
|
|
43
|
+
// ── Auto-detección de proyecto vía git ─────────────────────────────────────
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Drena la cola de sesiones sin proyecto y lanza detección git de forma async.
|
|
47
|
+
* Cuando detecta un nombre, etiqueta la sesión y notifica a los clientes SSE.
|
|
48
|
+
*/
|
|
49
|
+
function runAutoDetect() {
|
|
50
|
+
for (const { sessionId, pathHint } of drainAutoDetectQueue()) {
|
|
51
|
+
detectGitProject(pathHint).then(result => {
|
|
52
|
+
if (!result) return
|
|
53
|
+
labelSession(sessionId, result.name)
|
|
54
|
+
broadcast('label_updated', { sessionId, project: result.name, auto: true })
|
|
55
|
+
}).catch(() => {})
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
// ── Endpoints OTLP ──────────────────────────────────────────────────────────
|
|
43
60
|
|
|
44
61
|
/**
|
|
@@ -51,6 +68,7 @@ export async function startServer({ port = 1337 } = {}) {
|
|
|
51
68
|
processMetric(point)
|
|
52
69
|
}
|
|
53
70
|
broadcast('metrics', { count: points.length })
|
|
71
|
+
runAutoDetect()
|
|
54
72
|
res.json({ partialSuccess: {} })
|
|
55
73
|
})
|
|
56
74
|
|
|
@@ -64,6 +82,7 @@ export async function startServer({ port = 1337 } = {}) {
|
|
|
64
82
|
const stored = processEvent(ev)
|
|
65
83
|
broadcast('event', stored)
|
|
66
84
|
}
|
|
85
|
+
runAutoDetect()
|
|
67
86
|
res.json({ partialSuccess: {} })
|
|
68
87
|
})
|
|
69
88
|
|
package/src/store.js
CHANGED
|
@@ -14,6 +14,34 @@ import os from 'node:os'
|
|
|
14
14
|
import path from 'node:path'
|
|
15
15
|
import { estimateCost } from './prices.js'
|
|
16
16
|
|
|
17
|
+
// ─── Cola de auto-detección de proyecto vía git ──────────────────────────────
|
|
18
|
+
|
|
19
|
+
const _pendingAutoDetect = [] // { sessionId, pathHint }[]
|
|
20
|
+
const _autoDetectQueued = new Set() // sessionIds con detección en cola ahora mismo
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Encola una sesión sin proyecto para auto-detección por git.
|
|
24
|
+
* No re-encola si ya está en cola o si la sesión ya tiene proyecto.
|
|
25
|
+
*/
|
|
26
|
+
function maybeQueueAutoDetect(sessionId, pathHint) {
|
|
27
|
+
if (!pathHint || _autoDetectQueued.has(sessionId)) return
|
|
28
|
+
const session = state.sessions.get(sessionId)
|
|
29
|
+
if (!session || resolveProject(sessionId, session.project) !== null) return
|
|
30
|
+
_autoDetectQueued.add(sessionId)
|
|
31
|
+
_pendingAutoDetect.push({ sessionId, pathHint })
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Devuelve y vacía la cola de sesiones pendientes de auto-detección.
|
|
36
|
+
* Al drenarla, las sessionIds vuelven a estar disponibles para future re-colas
|
|
37
|
+
* (permite reintentar si la primera detección falló).
|
|
38
|
+
*/
|
|
39
|
+
export function drainAutoDetectQueue() {
|
|
40
|
+
const items = _pendingAutoDetect.splice(0)
|
|
41
|
+
for (const { sessionId } of items) _autoDetectQueued.delete(sessionId)
|
|
42
|
+
return items
|
|
43
|
+
}
|
|
44
|
+
|
|
17
45
|
// ─── Ruta de persistencia ───────────────────────────────────────────────────
|
|
18
46
|
|
|
19
47
|
const HOME_DATA_DIR = path.join(os.homedir(), '.tokenrace')
|
|
@@ -242,7 +270,8 @@ export function processMetric(raw) {
|
|
|
242
270
|
tokensCache: 0,
|
|
243
271
|
cost: 0,
|
|
244
272
|
apiRequests: 0,
|
|
245
|
-
toolCalls: 0
|
|
273
|
+
toolCalls: 0,
|
|
274
|
+
cwd: null
|
|
246
275
|
})
|
|
247
276
|
}
|
|
248
277
|
|
|
@@ -250,6 +279,15 @@ export function processMetric(raw) {
|
|
|
250
279
|
session.lastSeen = Math.max(session.lastSeen, timestamp)
|
|
251
280
|
if (model && !session.model) session.model = model
|
|
252
281
|
|
|
282
|
+
// Capturar directorio de trabajo para auto-detección de proyecto
|
|
283
|
+
if (!session.cwd) {
|
|
284
|
+
const cwd = labels['process.cwd'] ?? labels['cwd'] ?? labels['working_directory'] ?? null
|
|
285
|
+
if (cwd) {
|
|
286
|
+
session.cwd = cwd
|
|
287
|
+
maybeQueueAutoDetect(sessionId, cwd)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
253
291
|
switch (name) {
|
|
254
292
|
case 'claude_code.tokens.input':
|
|
255
293
|
session.tokensInput += value; break
|
|
@@ -347,6 +385,7 @@ export function processEvent({ eventName, timestamp, severity, attributes }) {
|
|
|
347
385
|
feature: attributes.feature ?? null,
|
|
348
386
|
model,
|
|
349
387
|
startTime: timestamp,
|
|
388
|
+
cwd: attributes['process.cwd'] ?? attributes['cwd'] ?? attributes['working_directory'] ?? null,
|
|
350
389
|
lastSeen: timestamp,
|
|
351
390
|
durationActiveMs: 0,
|
|
352
391
|
tokensInput: 0,
|
|
@@ -363,6 +402,25 @@ export function processEvent({ eventName, timestamp, severity, attributes }) {
|
|
|
363
402
|
session.lastSeen = Math.max(session.lastSeen, timestamp)
|
|
364
403
|
if (model && !session.model) session.model = model
|
|
365
404
|
|
|
405
|
+
// Capturar directorio de trabajo para auto-detección de proyecto
|
|
406
|
+
if (!session.cwd) {
|
|
407
|
+
const cwd = attributes['process.cwd'] ?? attributes['cwd'] ?? attributes['working_directory'] ?? null
|
|
408
|
+
if (cwd) {
|
|
409
|
+
session.cwd = cwd
|
|
410
|
+
maybeQueueAutoDetect(sessionId, cwd)
|
|
411
|
+
} else if (eventName === 'tool_use') {
|
|
412
|
+
// Fallback: deducir cwd desde paths de ficheros usados por herramientas
|
|
413
|
+
const filePath = attributes['tool.input.file_path']
|
|
414
|
+
?? attributes['tool.input.path']
|
|
415
|
+
?? attributes['file_path']
|
|
416
|
+
?? null
|
|
417
|
+
if (filePath && filePath.startsWith('/')) {
|
|
418
|
+
session.cwd = path.dirname(filePath)
|
|
419
|
+
maybeQueueAutoDetect(sessionId, session.cwd)
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
|
|
366
424
|
// ── Tiempo activo desde eventos api_request (duration_ms) ──
|
|
367
425
|
if (eventName === 'api_request') {
|
|
368
426
|
const dur = Number(attributes['duration_ms'] ?? 0)
|
|
@@ -600,6 +658,19 @@ export function getSummary(from) {
|
|
|
600
658
|
|
|
601
659
|
const efficiency = tokensInput > 0 ? tokensOutput / tokensInput : 0
|
|
602
660
|
|
|
661
|
+
// Proyecto más reciente con nombre asignado dentro del rango
|
|
662
|
+
let currentProject = null
|
|
663
|
+
let latestProjectTs = -1
|
|
664
|
+
for (const session of state.sessions.values()) {
|
|
665
|
+
if (state.ignoredSessions.has(session.sessionId)) continue
|
|
666
|
+
if (session.lastSeen < minTs) continue
|
|
667
|
+
const proj = resolveProject(session.sessionId, session.project)
|
|
668
|
+
if (proj && session.lastSeen > latestProjectTs) {
|
|
669
|
+
latestProjectTs = session.lastSeen
|
|
670
|
+
currentProject = proj
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
|
|
603
674
|
return {
|
|
604
675
|
tokens: { input: tokensInput, output: tokensOutput, cache: tokensCache },
|
|
605
676
|
cost,
|
|
@@ -609,7 +680,8 @@ export function getSummary(from) {
|
|
|
609
680
|
pullRequests,
|
|
610
681
|
linesAdded,
|
|
611
682
|
linesRemoved,
|
|
612
|
-
efficiency
|
|
683
|
+
efficiency,
|
|
684
|
+
currentProject
|
|
613
685
|
}
|
|
614
686
|
}
|
|
615
687
|
|