tokenrace 0.1.9 → 0.1.10
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-rCnJ9m1Y.js → index-DQk3XNu9.js} +2 -2
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/api-routes.js +30 -11
- package/src/otlp-parser.js +1 -0
- package/src/server.js +10 -2
- package/src/store.js +42 -41
|
@@ -116,7 +116,7 @@ export OTEL_METRICS_EXPORTER=otlp
|
|
|
116
116
|
export OTEL_LOGS_EXPORTER=otlp
|
|
117
117
|
export OTEL_EXPORTER_OTLP_PROTOCOL=http/json
|
|
118
118
|
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:1337
|
|
119
|
-
export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative`;function JR(){const[e,t]=W.useState(!1);function n(){navigator.clipboard.writeText(e_).then(()=>{t(!0),setTimeout(()=>t(!1),2e3)}).catch(()=>{})}return D.jsx("div",{className:"flex flex-col items-center justify-center min-h-[60vh] px-4",children:D.jsxs("div",{className:"max-w-xl w-full space-y-6",children:[D.jsxs("div",{className:"text-center space-y-2",children:[D.jsxs("div",{className:"text-4xl font-mono font-bold",children:[D.jsx("span",{className:"text-accent-green",children:"</>"}),D.jsx("span",{className:"text-text-primary",children:" tokenrace"})]}),D.jsxs("div",{className:"flex items-center justify-center gap-2 text-text-secondary",children:[D.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-accent-yellow animate-pulse"}),D.jsx("span",{children:"Esperando datos de Claude Code..."})]})]}),D.jsxs("div",{children:[D.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"Pega esto en tu terminal:"}),D.jsxs("div",{className:"relative bg-bg-subtle border border-bg-border rounded-lg p-4 font-mono text-sm",children:[D.jsx("pre",{className:"text-text-secondary whitespace-pre overflow-x-auto",children:e_}),D.jsx("button",{onClick:n,className:"absolute top-2 right-2 flex items-center gap-1 px-2 py-1 rounded text-xs bg-bg-card border border-bg-border text-text-secondary hover:text-text-primary transition-colors",children:e?D.jsxs(D.Fragment,{children:[D.jsx(zb,{size:12,className:"text-accent-green"}),D.jsx("span",{className:"text-accent-green",children:"Copiado"})]}):D.jsxs(D.Fragment,{children:[D.jsx(LR,{size:12}),D.jsx("span",{children:"Copiar"})]})})]})]}),D.jsxs("div",{children:[D.jsxs("p",{className:"text-text-secondary text-sm mb-2",children:["Etiqueta tu sesión ",D.jsx("span",{className:"text-text-muted",children:"(opcional — puedes hacerlo desde la web)"}),":"]}),D.jsx("div",{className:"bg-bg-subtle border border-bg-border rounded-lg p-4 font-mono text-sm text-text-secondary",children:'export OTEL_RESOURCE_ATTRIBUTES="project=mi-proyecto"'})]}),D.jsxs("div",{className:"text-center",children:[D.jsx("p",{className:"text-text-secondary text-sm",children:"Luego:"}),D.jsx("code",{className:"text-accent-green font-mono text-lg",children:"claude"})]})]})})}const e3="";async function Ln(e){const t=await fetch(`${e3}${e}`);if(!t.ok)throw new Error(`HTTP ${t.status}: ${e}`);return t.json()}const ht={status:()=>Ln("/api/status"),summary:e=>Ln(`/api/summary${e?`?from=${e}`:""}`),timeseries:(e,t,n)=>{const r=new URLSearchParams({metric:e});return t&&r.set("from",t),n&&r.set("bucket",n),Ln(`/api/timeseries?${r}`)},projects:e=>Ln(`/api/projects${e?`?from=${e}`:""}`),sessions:(e=50,t)=>{const n=new URLSearchParams({limit:String(e)});return t&&n.set("project",t),Ln(`/api/sessions?${n}`)},unlabeledSessions:()=>Ln("/api/sessions/unlabeled"),sessionEvents:e=>Ln(`/api/sessions/${e}/events`),events:(e=200,t,n)=>{const r=new URLSearchParams({limit:String(e)});return t&&r.set("type",t),n&&r.set("project",n),Ln(`/api/events?${r}`)},tools:e=>Ln(`/api/tools${e?`?from=${e}`:""}`),agents:()=>Ln("/api/agents"),models:e=>Ln(`/api/models${e?`?from=${e}`:""}`),labelSession:(e,t)=>fetch(`/api/sessions/${e}/label`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t})}).then(n=>n.json()),reset:()=>fetch("/api/reset",{method:"POST"}).then(e=>e.json())};function t3(e){const t=Date.now()-e;return t<6e4?`hace ${Math.floor(t/1e3)}s`:t<36e5?`hace ${Math.floor(t/6e4)}m`:`hace ${Math.floor(t/36e5)}h`}function n3({onLabeled:e}){const[t,n]=W.useState([]),[r,o]=W.useState([]),[l,c]=W.useState({}),[f,d]=W.useState({}),h=W.useCallback(async()=>{try{const[x,_]=await Promise.all([ht.unlabeledSessions(),ht.projects().catch(()=>[])]);n(S=>{const b=new Set(S.map(E=>E.session.sessionId)),w=x.filter(E=>!b.has(E.sessionId)).map(E=>({session:E,status:"pending"}));return[...S,...w]}),o(_.map(S=>S.project).sort((S,b)=>x.filter(w=>w.sessionId===b.toString()).length-x.filter(w=>w.sessionId===S.toString()).length))}catch{}},[]);W.useEffect(()=>{h();const x=setInterval(h,1e4);return()=>clearInterval(x)},[h]);async function v(x,_){await ht.labelSession(x,_).catch(()=>{}),n(S=>S.map(b=>b.session.sessionId===x?{...b,status:"resolved",resolvedProject:_}:b)),e(),setTimeout(()=>{n(S=>S.filter(b=>b.session.sessionId!==x))},3e3)}function y(x){n(_=>_.map(S=>S.session.sessionId===x?{...S,status:"ignored"}:S)),fetch(`/api/sessions/${x}/ignore`,{method:"POST"}).catch(()=>{}),setTimeout(()=>{n(_=>_.filter(S=>S.session.sessionId!==x))},500)}const g=t.filter(x=>x.status==="pending"||x.status==="resolved");return g.length===0?null:D.jsx("div",{className:"border-b border-bg-border bg-bg-subtle",children:g.map(({session:x,status:_,resolvedProject:S})=>D.jsxs("div",{className:`px-4 py-2 flex items-start gap-3 text-sm transition-all ${_==="resolved"?"opacity-60":""}`,children:[D.jsx("span",{className:`mt-0.5 inline-block w-2 h-2 rounded-full shrink-0 ${_==="resolved"?"bg-accent-green":"bg-accent-yellow animate-pulse"}`}),D.jsx("div",{className:"flex-1 min-w-0",children:_==="resolved"?D.jsxs("span",{className:"text-accent-green",children:["✓ Sesión etiquetada como ",D.jsx("strong",{children:S})]}):D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"text-text-secondary",children:[D.jsx("span",{className:"font-medium text-text-primary",children:"Nueva sesión sin proyecto"}),D.jsxs("span",{className:"text-text-muted ml-2",children:[x.sessionId.slice(0,8),"… · ",x.model??"modelo desconocido"," · ",t3(x.timestamp)]})]}),D.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[r.slice(0,5).map(b=>D.jsx("button",{onClick:()=>v(x.sessionId,b),className:"px-2 py-0.5 rounded text-xs bg-bg-card border border-bg-border text-text-secondary hover:border-accent-green hover:text-text-primary transition-colors",children:b},b)),f[x.sessionId]?D.jsxs("span",{className:"flex items-center gap-1",children:[D.jsx("input",{autoFocus:!0,value:l[x.sessionId]??"",onChange:b=>c(w=>({...w,[x.sessionId]:b.target.value})),onKeyDown:b=>{var w;b.key==="Enter"&&((w=l[x.sessionId])!=null&&w.trim())&&v(x.sessionId,l[x.sessionId].trim()),b.key==="Escape"&&d(E=>({...E,[x.sessionId]:!1}))},placeholder:"nombre del proyecto",className:"bg-bg-base border border-bg-border rounded px-2 py-0.5 text-xs text-text-primary outline-none focus:border-accent-green w-32"}),D.jsx("button",{onClick:()=>{var w;const b=(w=l[x.sessionId])==null?void 0:w.trim();b&&v(x.sessionId,b)},className:"text-accent-green",children:D.jsx(zb,{size:12})})]}):D.jsx("button",{onClick:()=>d(b=>({...b,[x.sessionId]:!0})),className:"px-2 py-0.5 rounded text-xs bg-bg-card border border-bg-border text-text-secondary hover:border-accent-green transition-colors",children:"+ Nuevo"}),D.jsxs("button",{onClick:()=>y(x.sessionId),className:"px-2 py-0.5 rounded text-xs text-text-muted hover:text-accent-orange transition-colors flex items-center gap-1",children:[D.jsx(k2,{size:10}),"Ignorar"]})]})]})})]},x.sessionId))})}function r3({label:e,value:t,accent:n,sublabel:r}){return D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 flex flex-col gap-1",children:[D.jsx("span",{className:"text-xs text-text-secondary uppercase tracking-wider",children:e}),D.jsx("span",{className:`text-2xl font-mono font-bold ${n}`,children:t}),r&&D.jsx("span",{className:"text-xs text-text-muted",children:r})]})}function er(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(0)}function ei(e){return`$${e.toFixed(2)}`}function Bb(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}h ${n%60}m`:n>0?`${n}m ${t%60}s`:`${t}s`}function a3(e){const t=Date.now()-e,n=Math.floor(t/6e4),r=Math.floor(t/36e5),o=Math.floor(t/864e5);return n<1?"hace <1 min":n<60?`hace ${n} min`:r<24?`hace ${r}h`:o===1?"ayer":`hace ${o}d`}function i3({summary:e}){const t=[{label:"Tokens Input",value:er(e.tokens.input),accent:"text-accent-blue",sublabel:`caché: ${er(e.tokens.cache)}`},{label:"Tokens Output",value:er(e.tokens.output),accent:"text-accent-green",sublabel:`eficiencia: ${(e.efficiency*100).toFixed(1)}%`},{label:"Coste Total",value:ei(e.cost),accent:"text-accent-purple"},{label:"Tiempo Activo",value:Bb(e.activeTimeMs),accent:"text-accent-teal"},{label:"Sesiones",value:String(e.sessions),accent:"text-text-primary"},{label:"Commits",value:String(e.commits),accent:"text-accent-yellow"}];return D.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:t.map(n=>D.jsx(r3,{...n},n.label))})}function U2(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=U2(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function $e(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=U2(e))&&(r&&(r+=" "),r+=t);return r}var gp,t_;function en(){if(t_)return gp;t_=1;var e=Array.isArray;return gp=e,gp}var bp,n_;function I2(){if(n_)return bp;n_=1;var e=typeof us=="object"&&us&&us.Object===Object&&us;return bp=e,bp}var xp,r_;function ir(){if(r_)return xp;r_=1;var e=I2(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return xp=n,xp}var Sp,a_;function Rl(){if(a_)return Sp;a_=1;var e=ir(),t=e.Symbol;return Sp=t,Sp}var Op,i_;function o3(){if(i_)return Op;i_=1;var e=Rl(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,o=e?e.toStringTag:void 0;function l(c){var f=n.call(c,o),d=c[o];try{c[o]=void 0;var h=!0}catch{}var v=r.call(c);return h&&(f?c[o]=d:delete c[o]),v}return Op=l,Op}var _p,o_;function u3(){if(o_)return _p;o_=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return _p=n,_p}var Ap,u_;function zr(){if(u_)return Ap;u_=1;var e=Rl(),t=o3(),n=u3(),r="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function c(f){return f==null?f===void 0?o:r:l&&l in Object(f)?t(f):n(f)}return Ap=c,Ap}var wp,l_;function Br(){if(l_)return wp;l_=1;function e(t){return t!=null&&typeof t=="object"}return wp=e,wp}var Tp,c_;function Do(){if(c_)return Tp;c_=1;var e=zr(),t=Br(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return Tp=r,Tp}var Ep,s_;function Lb(){if(s_)return Ep;s_=1;var e=en(),t=Do(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function o(l,c){if(e(l))return!1;var f=typeof l;return f=="number"||f=="symbol"||f=="boolean"||l==null||t(l)?!0:r.test(l)||!n.test(l)||c!=null&&l in Object(c)}return Ep=o,Ep}var jp,f_;function Sa(){if(f_)return jp;f_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return jp=e,jp}var Mp,d_;function kb(){if(d_)return Mp;d_=1;var e=zr(),t=Sa(),n="[object AsyncFunction]",r="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function c(f){if(!t(f))return!1;var d=e(f);return d==r||d==o||d==n||d==l}return Mp=c,Mp}var Cp,h_;function l3(){if(h_)return Cp;h_=1;var e=ir(),t=e["__core-js_shared__"];return Cp=t,Cp}var Np,p_;function c3(){if(p_)return Np;p_=1;var e=l3(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return Np=n,Np}var Dp,v_;function H2(){if(v_)return Dp;v_=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return Dp=n,Dp}var Pp,y_;function s3(){if(y_)return Pp;y_=1;var e=kb(),t=c3(),n=Sa(),r=H2(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,f=Object.prototype,d=c.toString,h=f.hasOwnProperty,v=RegExp("^"+d.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function y(g){if(!n(g)||t(g))return!1;var x=e(g)?v:l;return x.test(r(g))}return Pp=y,Pp}var Rp,m_;function f3(){if(m_)return Rp;m_=1;function e(t,n){return t==null?void 0:t[n]}return Rp=e,Rp}var $p,g_;function oi(){if(g_)return $p;g_=1;var e=s3(),t=f3();function n(r,o){var l=t(r,o);return e(l)?l:void 0}return $p=n,$p}var qp,b_;function Of(){if(b_)return qp;b_=1;var e=oi(),t=e(Object,"create");return qp=t,qp}var zp,x_;function d3(){if(x_)return zp;x_=1;var e=Of();function t(){this.__data__=e?e(null):{},this.size=0}return zp=t,zp}var Bp,S_;function h3(){if(S_)return Bp;S_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Bp=e,Bp}var Lp,O_;function p3(){if(O_)return Lp;O_=1;var e=Of(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function o(l){var c=this.__data__;if(e){var f=c[l];return f===t?void 0:f}return r.call(c,l)?c[l]:void 0}return Lp=o,Lp}var kp,__;function v3(){if(__)return kp;__=1;var e=Of(),t=Object.prototype,n=t.hasOwnProperty;function r(o){var l=this.__data__;return e?l[o]!==void 0:n.call(l,o)}return kp=r,kp}var Up,A_;function y3(){if(A_)return Up;A_=1;var e=Of(),t="__lodash_hash_undefined__";function n(r,o){var l=this.__data__;return this.size+=this.has(r)?0:1,l[r]=e&&o===void 0?t:o,this}return Up=n,Up}var Ip,w_;function m3(){if(w_)return Ip;w_=1;var e=d3(),t=h3(),n=p3(),r=v3(),o=y3();function l(c){var f=-1,d=c==null?0:c.length;for(this.clear();++f<d;){var h=c[f];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=o,Ip=l,Ip}var Hp,T_;function g3(){if(T_)return Hp;T_=1;function e(){this.__data__=[],this.size=0}return Hp=e,Hp}var Gp,E_;function Ub(){if(E_)return Gp;E_=1;function e(t,n){return t===n||t!==t&&n!==n}return Gp=e,Gp}var Yp,j_;function _f(){if(j_)return Yp;j_=1;var e=Ub();function t(n,r){for(var o=n.length;o--;)if(e(n[o][0],r))return o;return-1}return Yp=t,Yp}var Xp,M_;function b3(){if(M_)return Xp;M_=1;var e=_f(),t=Array.prototype,n=t.splice;function r(o){var l=this.__data__,c=e(l,o);if(c<0)return!1;var f=l.length-1;return c==f?l.pop():n.call(l,c,1),--this.size,!0}return Xp=r,Xp}var Kp,C_;function x3(){if(C_)return Kp;C_=1;var e=_f();function t(n){var r=this.__data__,o=e(r,n);return o<0?void 0:r[o][1]}return Kp=t,Kp}var Vp,N_;function S3(){if(N_)return Vp;N_=1;var e=_f();function t(n){return e(this.__data__,n)>-1}return Vp=t,Vp}var Zp,D_;function O3(){if(D_)return Zp;D_=1;var e=_f();function t(n,r){var o=this.__data__,l=e(o,n);return l<0?(++this.size,o.push([n,r])):o[l][1]=r,this}return Zp=t,Zp}var Fp,P_;function Af(){if(P_)return Fp;P_=1;var e=g3(),t=b3(),n=x3(),r=S3(),o=O3();function l(c){var f=-1,d=c==null?0:c.length;for(this.clear();++f<d;){var h=c[f];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=o,Fp=l,Fp}var Qp,R_;function Ib(){if(R_)return Qp;R_=1;var e=oi(),t=ir(),n=e(t,"Map");return Qp=n,Qp}var Wp,$_;function _3(){if($_)return Wp;$_=1;var e=m3(),t=Af(),n=Ib();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Wp=r,Wp}var Jp,q_;function A3(){if(q_)return Jp;q_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Jp=e,Jp}var ev,z_;function wf(){if(z_)return ev;z_=1;var e=A3();function t(n,r){var o=n.__data__;return e(r)?o[typeof r=="string"?"string":"hash"]:o.map}return ev=t,ev}var tv,B_;function w3(){if(B_)return tv;B_=1;var e=wf();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return tv=t,tv}var nv,L_;function T3(){if(L_)return nv;L_=1;var e=wf();function t(n){return e(this,n).get(n)}return nv=t,nv}var rv,k_;function E3(){if(k_)return rv;k_=1;var e=wf();function t(n){return e(this,n).has(n)}return rv=t,rv}var av,U_;function j3(){if(U_)return av;U_=1;var e=wf();function t(n,r){var o=e(this,n),l=o.size;return o.set(n,r),this.size+=o.size==l?0:1,this}return av=t,av}var iv,I_;function Hb(){if(I_)return iv;I_=1;var e=_3(),t=w3(),n=T3(),r=E3(),o=j3();function l(c){var f=-1,d=c==null?0:c.length;for(this.clear();++f<d;){var h=c[f];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=o,iv=l,iv}var ov,H_;function G2(){if(H_)return ov;H_=1;var e=Hb(),t="Expected a function";function n(r,o){if(typeof r!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var l=function(){var c=arguments,f=o?o.apply(this,c):c[0],d=l.cache;if(d.has(f))return d.get(f);var h=r.apply(this,c);return l.cache=d.set(f,h)||d,h};return l.cache=new(n.Cache||e),l}return n.Cache=e,ov=n,ov}var uv,G_;function M3(){if(G_)return uv;G_=1;var e=G2(),t=500;function n(r){var o=e(r,function(c){return l.size===t&&l.clear(),c}),l=o.cache;return o}return uv=n,uv}var lv,Y_;function C3(){if(Y_)return lv;Y_=1;var e=M3(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(t,function(c,f,d,h){l.push(d?h.replace(n,"$1"):f||c)}),l});return lv=r,lv}var cv,X_;function Gb(){if(X_)return cv;X_=1;function e(t,n){for(var r=-1,o=t==null?0:t.length,l=Array(o);++r<o;)l[r]=n(t[r],r,t);return l}return cv=e,cv}var sv,K_;function N3(){if(K_)return sv;K_=1;var e=Rl(),t=Gb(),n=en(),r=Do(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function c(f){if(typeof f=="string")return f;if(n(f))return t(f,c)+"";if(r(f))return l?l.call(f):"";var d=f+"";return d=="0"&&1/f==-1/0?"-0":d}return sv=c,sv}var fv,V_;function Y2(){if(V_)return fv;V_=1;var e=N3();function t(n){return n==null?"":e(n)}return fv=t,fv}var dv,Z_;function X2(){if(Z_)return dv;Z_=1;var e=en(),t=Lb(),n=C3(),r=Y2();function o(l,c){return e(l)?l:t(l,c)?[l]:n(r(l))}return dv=o,dv}var hv,F_;function Tf(){if(F_)return hv;F_=1;var e=Do();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return hv=t,hv}var pv,Q_;function Yb(){if(Q_)return pv;Q_=1;var e=X2(),t=Tf();function n(r,o){o=e(o,r);for(var l=0,c=o.length;r!=null&&l<c;)r=r[t(o[l++])];return l&&l==c?r:void 0}return pv=n,pv}var vv,W_;function K2(){if(W_)return vv;W_=1;var e=Yb();function t(n,r,o){var l=n==null?void 0:e(n,r);return l===void 0?o:l}return vv=t,vv}var D3=K2();const Cn=Qe(D3);var yv,J_;function P3(){if(J_)return yv;J_=1;function e(t){return t==null}return yv=e,yv}var R3=P3();const je=Qe(R3);var mv,eA;function $3(){if(eA)return mv;eA=1;var e=zr(),t=en(),n=Br(),r="[object String]";function o(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==r}return mv=o,mv}var q3=$3();const ti=Qe(q3);var z3=kb();const Ae=Qe(z3);var B3=Sa();const Po=Qe(B3);var gv={exports:{}},Ue={};/**
|
|
119
|
+
export OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE=cumulative`;function JR(){const[e,t]=W.useState(!1);function n(){navigator.clipboard.writeText(e_).then(()=>{t(!0),setTimeout(()=>t(!1),2e3)}).catch(()=>{})}return D.jsx("div",{className:"flex flex-col items-center justify-center min-h-[60vh] px-4",children:D.jsxs("div",{className:"max-w-xl w-full space-y-6",children:[D.jsxs("div",{className:"text-center space-y-2",children:[D.jsxs("div",{className:"text-4xl font-mono font-bold",children:[D.jsx("span",{className:"text-accent-green",children:"</>"}),D.jsx("span",{className:"text-text-primary",children:" tokenrace"})]}),D.jsxs("div",{className:"flex items-center justify-center gap-2 text-text-secondary",children:[D.jsx("span",{className:"inline-block w-2 h-2 rounded-full bg-accent-yellow animate-pulse"}),D.jsx("span",{children:"Esperando datos de Claude Code..."})]})]}),D.jsxs("div",{children:[D.jsx("p",{className:"text-text-secondary text-sm mb-2",children:"Pega esto en tu terminal:"}),D.jsxs("div",{className:"relative bg-bg-subtle border border-bg-border rounded-lg p-4 font-mono text-sm",children:[D.jsx("pre",{className:"text-text-secondary whitespace-pre overflow-x-auto",children:e_}),D.jsx("button",{onClick:n,className:"absolute top-2 right-2 flex items-center gap-1 px-2 py-1 rounded text-xs bg-bg-card border border-bg-border text-text-secondary hover:text-text-primary transition-colors",children:e?D.jsxs(D.Fragment,{children:[D.jsx(zb,{size:12,className:"text-accent-green"}),D.jsx("span",{className:"text-accent-green",children:"Copiado"})]}):D.jsxs(D.Fragment,{children:[D.jsx(LR,{size:12}),D.jsx("span",{children:"Copiar"})]})})]})]}),D.jsxs("div",{children:[D.jsxs("p",{className:"text-text-secondary text-sm mb-2",children:["Etiqueta tu sesión ",D.jsx("span",{className:"text-text-muted",children:"(opcional — puedes hacerlo desde la web)"}),":"]}),D.jsx("div",{className:"bg-bg-subtle border border-bg-border rounded-lg p-4 font-mono text-sm text-text-secondary",children:'export OTEL_RESOURCE_ATTRIBUTES="project=mi-proyecto"'})]}),D.jsxs("div",{className:"text-center",children:[D.jsx("p",{className:"text-text-secondary text-sm",children:"Luego:"}),D.jsx("code",{className:"text-accent-green font-mono text-lg",children:"claude"})]})]})})}const e3="";async function Ln(e){const t=await fetch(`${e3}${e}`);if(!t.ok)throw new Error(`HTTP ${t.status}: ${e}`);return t.json()}const ht={status:()=>Ln("/api/status"),summary:e=>Ln(`/api/summary${e?`?from=${e}`:""}`),timeseries:(e,t,n)=>{const r=new URLSearchParams({metric:e});return t&&r.set("from",t),n&&r.set("bucket",n),Ln(`/api/timeseries?${r}`)},projects:e=>Ln(`/api/projects${e?`?from=${e}`:""}`),sessions:(e=50,t)=>{const n=new URLSearchParams({limit:String(e)});return t&&n.set("project",t),Ln(`/api/sessions?${n}`)},unlabeledSessions:()=>Ln("/api/sessions/unlabeled"),sessionEvents:e=>Ln(`/api/sessions/${e}/events`),events:(e=200,t,n)=>{const r=new URLSearchParams({limit:String(e)});return t&&r.set("type",t),n&&r.set("project",n),Ln(`/api/events?${r}`)},tools:e=>Ln(`/api/tools${e?`?from=${e}`:""}`),agents:()=>Ln("/api/agents"),models:e=>Ln(`/api/models${e?`?from=${e}`:""}`),labelSession:(e,t)=>fetch(`/api/sessions/${e}/label`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({project:t})}).then(n=>n.json()),reset:()=>fetch("/api/reset",{method:"POST"}).then(e=>e.json())};function t3(e){const t=Date.now()-e;return t<6e4?`hace ${Math.floor(t/1e3)}s`:t<36e5?`hace ${Math.floor(t/6e4)}m`:`hace ${Math.floor(t/36e5)}h`}function n3({onLabeled:e}){const[t,n]=W.useState([]),[r,o]=W.useState([]),[l,c]=W.useState({}),[f,d]=W.useState({}),h=W.useCallback(async()=>{try{const[x,_]=await Promise.all([ht.unlabeledSessions(),ht.projects().catch(()=>[])]);n(S=>{const b=new Set(S.map(E=>E.session.sessionId)),w=x.filter(E=>!b.has(E.sessionId)).map(E=>({session:E,status:"pending"}));return[...S,...w]}),o([..._].sort((S,b)=>b.sessions-S.sessions).map(S=>S.project))}catch{}},[]);W.useEffect(()=>{h();const x=setInterval(h,1e4);return()=>clearInterval(x)},[h]);async function v(x,_){await ht.labelSession(x,_).catch(()=>{}),n(S=>S.map(b=>b.session.sessionId===x?{...b,status:"resolved",resolvedProject:_}:b)),e(),setTimeout(()=>{n(S=>S.filter(b=>b.session.sessionId!==x))},3e3)}function y(x){n(_=>_.map(S=>S.session.sessionId===x?{...S,status:"ignored"}:S)),fetch(`/api/sessions/${x}/ignore`,{method:"POST"}).catch(()=>{}),setTimeout(()=>{n(_=>_.filter(S=>S.session.sessionId!==x))},500)}const g=t.filter(x=>x.status==="pending"||x.status==="resolved");return g.length===0?null:D.jsx("div",{className:"border-b border-bg-border bg-bg-subtle",children:g.map(({session:x,status:_,resolvedProject:S})=>D.jsxs("div",{className:`px-4 py-2 flex items-start gap-3 text-sm transition-all ${_==="resolved"?"opacity-60":""}`,children:[D.jsx("span",{className:`mt-0.5 inline-block w-2 h-2 rounded-full shrink-0 ${_==="resolved"?"bg-accent-green":"bg-accent-yellow animate-pulse"}`}),D.jsx("div",{className:"flex-1 min-w-0",children:_==="resolved"?D.jsxs("span",{className:"text-accent-green",children:["✓ Sesión etiquetada como ",D.jsx("strong",{children:S})]}):D.jsxs(D.Fragment,{children:[D.jsxs("div",{className:"text-text-secondary",children:[D.jsx("span",{className:"font-medium text-text-primary",children:"Nueva sesión sin proyecto"}),D.jsxs("span",{className:"text-text-muted ml-2",children:[x.sessionId.slice(0,8),"… · ",x.model??"modelo desconocido"," · ",t3(x.timestamp)]})]}),D.jsxs("div",{className:"flex flex-wrap gap-1 mt-1",children:[r.slice(0,5).map(b=>D.jsx("button",{onClick:()=>v(x.sessionId,b),className:"px-2 py-0.5 rounded text-xs bg-bg-card border border-bg-border text-text-secondary hover:border-accent-green hover:text-text-primary transition-colors",children:b},b)),f[x.sessionId]?D.jsxs("span",{className:"flex items-center gap-1",children:[D.jsx("input",{autoFocus:!0,value:l[x.sessionId]??"",onChange:b=>c(w=>({...w,[x.sessionId]:b.target.value})),onKeyDown:b=>{var w;b.key==="Enter"&&((w=l[x.sessionId])!=null&&w.trim())&&v(x.sessionId,l[x.sessionId].trim()),b.key==="Escape"&&d(E=>({...E,[x.sessionId]:!1}))},placeholder:"nombre del proyecto",className:"bg-bg-base border border-bg-border rounded px-2 py-0.5 text-xs text-text-primary outline-none focus:border-accent-green w-32"}),D.jsx("button",{onClick:()=>{var w;const b=(w=l[x.sessionId])==null?void 0:w.trim();b&&v(x.sessionId,b)},className:"text-accent-green",children:D.jsx(zb,{size:12})})]}):D.jsx("button",{onClick:()=>d(b=>({...b,[x.sessionId]:!0})),className:"px-2 py-0.5 rounded text-xs bg-bg-card border border-bg-border text-text-secondary hover:border-accent-green transition-colors",children:"+ Nuevo"}),D.jsxs("button",{onClick:()=>y(x.sessionId),className:"px-2 py-0.5 rounded text-xs text-text-muted hover:text-accent-orange transition-colors flex items-center gap-1",children:[D.jsx(k2,{size:10}),"Ignorar"]})]})]})})]},x.sessionId))})}function r3({label:e,value:t,accent:n,sublabel:r}){return D.jsxs("div",{className:"bg-bg-card border border-bg-border rounded-lg p-4 flex flex-col gap-1",children:[D.jsx("span",{className:"text-xs text-text-secondary uppercase tracking-wider",children:e}),D.jsx("span",{className:`text-2xl font-mono font-bold ${n}`,children:t}),r&&D.jsx("span",{className:"text-xs text-text-muted",children:r})]})}function er(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toFixed(0)}function ei(e){return`$${e.toFixed(2)}`}function Bb(e){const t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return r>0?`${r}h ${n%60}m`:n>0?`${n}m ${t%60}s`:`${t}s`}function a3(e){const t=Date.now()-e,n=Math.floor(t/6e4),r=Math.floor(t/36e5),o=Math.floor(t/864e5);return n<1?"hace <1 min":n<60?`hace ${n} min`:r<24?`hace ${r}h`:o===1?"ayer":`hace ${o}d`}function i3({summary:e}){const t=[{label:"Tokens Input",value:er(e.tokens.input),accent:"text-accent-blue",sublabel:`caché: ${er(e.tokens.cache)}`},{label:"Tokens Output",value:er(e.tokens.output),accent:"text-accent-green",sublabel:`eficiencia: ${(e.efficiency*100).toFixed(1)}%`},{label:"Coste Total",value:ei(e.cost),accent:"text-accent-purple"},{label:"Tiempo Activo",value:Bb(e.activeTimeMs),accent:"text-accent-teal"},{label:"Sesiones",value:String(e.sessions),accent:"text-text-primary"},{label:"Commits",value:String(e.commits),accent:"text-accent-yellow"}];return D.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-3",children:t.map(n=>D.jsx(r3,{...n},n.label))})}function U2(e){var t,n,r="";if(typeof e=="string"||typeof e=="number")r+=e;else if(typeof e=="object")if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(n=U2(e[t]))&&(r&&(r+=" "),r+=n)}else for(n in e)e[n]&&(r&&(r+=" "),r+=n);return r}function $e(){for(var e,t,n=0,r="",o=arguments.length;n<o;n++)(e=arguments[n])&&(t=U2(e))&&(r&&(r+=" "),r+=t);return r}var gp,t_;function en(){if(t_)return gp;t_=1;var e=Array.isArray;return gp=e,gp}var bp,n_;function I2(){if(n_)return bp;n_=1;var e=typeof us=="object"&&us&&us.Object===Object&&us;return bp=e,bp}var xp,r_;function ir(){if(r_)return xp;r_=1;var e=I2(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return xp=n,xp}var Sp,a_;function Rl(){if(a_)return Sp;a_=1;var e=ir(),t=e.Symbol;return Sp=t,Sp}var Op,i_;function o3(){if(i_)return Op;i_=1;var e=Rl(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,o=e?e.toStringTag:void 0;function l(c){var f=n.call(c,o),d=c[o];try{c[o]=void 0;var h=!0}catch{}var v=r.call(c);return h&&(f?c[o]=d:delete c[o]),v}return Op=l,Op}var _p,o_;function u3(){if(o_)return _p;o_=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return _p=n,_p}var Ap,u_;function zr(){if(u_)return Ap;u_=1;var e=Rl(),t=o3(),n=u3(),r="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function c(f){return f==null?f===void 0?o:r:l&&l in Object(f)?t(f):n(f)}return Ap=c,Ap}var wp,l_;function Br(){if(l_)return wp;l_=1;function e(t){return t!=null&&typeof t=="object"}return wp=e,wp}var Tp,c_;function Do(){if(c_)return Tp;c_=1;var e=zr(),t=Br(),n="[object Symbol]";function r(o){return typeof o=="symbol"||t(o)&&e(o)==n}return Tp=r,Tp}var Ep,s_;function Lb(){if(s_)return Ep;s_=1;var e=en(),t=Do(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function o(l,c){if(e(l))return!1;var f=typeof l;return f=="number"||f=="symbol"||f=="boolean"||l==null||t(l)?!0:r.test(l)||!n.test(l)||c!=null&&l in Object(c)}return Ep=o,Ep}var jp,f_;function Sa(){if(f_)return jp;f_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return jp=e,jp}var Mp,d_;function kb(){if(d_)return Mp;d_=1;var e=zr(),t=Sa(),n="[object AsyncFunction]",r="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function c(f){if(!t(f))return!1;var d=e(f);return d==r||d==o||d==n||d==l}return Mp=c,Mp}var Cp,h_;function l3(){if(h_)return Cp;h_=1;var e=ir(),t=e["__core-js_shared__"];return Cp=t,Cp}var Np,p_;function c3(){if(p_)return Np;p_=1;var e=l3(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return Np=n,Np}var Dp,v_;function H2(){if(v_)return Dp;v_=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return Dp=n,Dp}var Pp,y_;function s3(){if(y_)return Pp;y_=1;var e=kb(),t=c3(),n=Sa(),r=H2(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,f=Object.prototype,d=c.toString,h=f.hasOwnProperty,v=RegExp("^"+d.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function y(g){if(!n(g)||t(g))return!1;var x=e(g)?v:l;return x.test(r(g))}return Pp=y,Pp}var Rp,m_;function f3(){if(m_)return Rp;m_=1;function e(t,n){return t==null?void 0:t[n]}return Rp=e,Rp}var $p,g_;function oi(){if(g_)return $p;g_=1;var e=s3(),t=f3();function n(r,o){var l=t(r,o);return e(l)?l:void 0}return $p=n,$p}var qp,b_;function Of(){if(b_)return qp;b_=1;var e=oi(),t=e(Object,"create");return qp=t,qp}var zp,x_;function d3(){if(x_)return zp;x_=1;var e=Of();function t(){this.__data__=e?e(null):{},this.size=0}return zp=t,zp}var Bp,S_;function h3(){if(S_)return Bp;S_=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Bp=e,Bp}var Lp,O_;function p3(){if(O_)return Lp;O_=1;var e=Of(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function o(l){var c=this.__data__;if(e){var f=c[l];return f===t?void 0:f}return r.call(c,l)?c[l]:void 0}return Lp=o,Lp}var kp,__;function v3(){if(__)return kp;__=1;var e=Of(),t=Object.prototype,n=t.hasOwnProperty;function r(o){var l=this.__data__;return e?l[o]!==void 0:n.call(l,o)}return kp=r,kp}var Up,A_;function y3(){if(A_)return Up;A_=1;var e=Of(),t="__lodash_hash_undefined__";function n(r,o){var l=this.__data__;return this.size+=this.has(r)?0:1,l[r]=e&&o===void 0?t:o,this}return Up=n,Up}var Ip,w_;function m3(){if(w_)return Ip;w_=1;var e=d3(),t=h3(),n=p3(),r=v3(),o=y3();function l(c){var f=-1,d=c==null?0:c.length;for(this.clear();++f<d;){var h=c[f];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=o,Ip=l,Ip}var Hp,T_;function g3(){if(T_)return Hp;T_=1;function e(){this.__data__=[],this.size=0}return Hp=e,Hp}var Gp,E_;function Ub(){if(E_)return Gp;E_=1;function e(t,n){return t===n||t!==t&&n!==n}return Gp=e,Gp}var Yp,j_;function _f(){if(j_)return Yp;j_=1;var e=Ub();function t(n,r){for(var o=n.length;o--;)if(e(n[o][0],r))return o;return-1}return Yp=t,Yp}var Xp,M_;function b3(){if(M_)return Xp;M_=1;var e=_f(),t=Array.prototype,n=t.splice;function r(o){var l=this.__data__,c=e(l,o);if(c<0)return!1;var f=l.length-1;return c==f?l.pop():n.call(l,c,1),--this.size,!0}return Xp=r,Xp}var Kp,C_;function x3(){if(C_)return Kp;C_=1;var e=_f();function t(n){var r=this.__data__,o=e(r,n);return o<0?void 0:r[o][1]}return Kp=t,Kp}var Vp,N_;function S3(){if(N_)return Vp;N_=1;var e=_f();function t(n){return e(this.__data__,n)>-1}return Vp=t,Vp}var Zp,D_;function O3(){if(D_)return Zp;D_=1;var e=_f();function t(n,r){var o=this.__data__,l=e(o,n);return l<0?(++this.size,o.push([n,r])):o[l][1]=r,this}return Zp=t,Zp}var Fp,P_;function Af(){if(P_)return Fp;P_=1;var e=g3(),t=b3(),n=x3(),r=S3(),o=O3();function l(c){var f=-1,d=c==null?0:c.length;for(this.clear();++f<d;){var h=c[f];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=o,Fp=l,Fp}var Qp,R_;function Ib(){if(R_)return Qp;R_=1;var e=oi(),t=ir(),n=e(t,"Map");return Qp=n,Qp}var Wp,$_;function _3(){if($_)return Wp;$_=1;var e=m3(),t=Af(),n=Ib();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Wp=r,Wp}var Jp,q_;function A3(){if(q_)return Jp;q_=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Jp=e,Jp}var ev,z_;function wf(){if(z_)return ev;z_=1;var e=A3();function t(n,r){var o=n.__data__;return e(r)?o[typeof r=="string"?"string":"hash"]:o.map}return ev=t,ev}var tv,B_;function w3(){if(B_)return tv;B_=1;var e=wf();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return tv=t,tv}var nv,L_;function T3(){if(L_)return nv;L_=1;var e=wf();function t(n){return e(this,n).get(n)}return nv=t,nv}var rv,k_;function E3(){if(k_)return rv;k_=1;var e=wf();function t(n){return e(this,n).has(n)}return rv=t,rv}var av,U_;function j3(){if(U_)return av;U_=1;var e=wf();function t(n,r){var o=e(this,n),l=o.size;return o.set(n,r),this.size+=o.size==l?0:1,this}return av=t,av}var iv,I_;function Hb(){if(I_)return iv;I_=1;var e=_3(),t=w3(),n=T3(),r=E3(),o=j3();function l(c){var f=-1,d=c==null?0:c.length;for(this.clear();++f<d;){var h=c[f];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=o,iv=l,iv}var ov,H_;function G2(){if(H_)return ov;H_=1;var e=Hb(),t="Expected a function";function n(r,o){if(typeof r!="function"||o!=null&&typeof o!="function")throw new TypeError(t);var l=function(){var c=arguments,f=o?o.apply(this,c):c[0],d=l.cache;if(d.has(f))return d.get(f);var h=r.apply(this,c);return l.cache=d.set(f,h)||d,h};return l.cache=new(n.Cache||e),l}return n.Cache=e,ov=n,ov}var uv,G_;function M3(){if(G_)return uv;G_=1;var e=G2(),t=500;function n(r){var o=e(r,function(c){return l.size===t&&l.clear(),c}),l=o.cache;return o}return uv=n,uv}var lv,Y_;function C3(){if(Y_)return lv;Y_=1;var e=M3(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(t,function(c,f,d,h){l.push(d?h.replace(n,"$1"):f||c)}),l});return lv=r,lv}var cv,X_;function Gb(){if(X_)return cv;X_=1;function e(t,n){for(var r=-1,o=t==null?0:t.length,l=Array(o);++r<o;)l[r]=n(t[r],r,t);return l}return cv=e,cv}var sv,K_;function N3(){if(K_)return sv;K_=1;var e=Rl(),t=Gb(),n=en(),r=Do(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function c(f){if(typeof f=="string")return f;if(n(f))return t(f,c)+"";if(r(f))return l?l.call(f):"";var d=f+"";return d=="0"&&1/f==-1/0?"-0":d}return sv=c,sv}var fv,V_;function Y2(){if(V_)return fv;V_=1;var e=N3();function t(n){return n==null?"":e(n)}return fv=t,fv}var dv,Z_;function X2(){if(Z_)return dv;Z_=1;var e=en(),t=Lb(),n=C3(),r=Y2();function o(l,c){return e(l)?l:t(l,c)?[l]:n(r(l))}return dv=o,dv}var hv,F_;function Tf(){if(F_)return hv;F_=1;var e=Do();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return hv=t,hv}var pv,Q_;function Yb(){if(Q_)return pv;Q_=1;var e=X2(),t=Tf();function n(r,o){o=e(o,r);for(var l=0,c=o.length;r!=null&&l<c;)r=r[t(o[l++])];return l&&l==c?r:void 0}return pv=n,pv}var vv,W_;function K2(){if(W_)return vv;W_=1;var e=Yb();function t(n,r,o){var l=n==null?void 0:e(n,r);return l===void 0?o:l}return vv=t,vv}var D3=K2();const Cn=Qe(D3);var yv,J_;function P3(){if(J_)return yv;J_=1;function e(t){return t==null}return yv=e,yv}var R3=P3();const je=Qe(R3);var mv,eA;function $3(){if(eA)return mv;eA=1;var e=zr(),t=en(),n=Br(),r="[object String]";function o(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==r}return mv=o,mv}var q3=$3();const ti=Qe(q3);var z3=kb();const Ae=Qe(z3);var B3=Sa();const Po=Qe(B3);var gv={exports:{}},Ue={};/**
|
|
120
120
|
* @license React
|
|
121
121
|
* react-is.production.min.js
|
|
122
122
|
*
|
|
@@ -184,4 +184,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
184
184
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function P7(e,t){if(e){if(typeof e=="string")return Ab(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 Ab(e,t)}}function R7(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function $7(e){if(Array.isArray(e))return Ab(e)}function Ab(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 q7(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function E2(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,RN(r.key),r)}}function z7(e,t,n){return t&&E2(e.prototype,t),n&&E2(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function B7(e,t,n){return t=mf(t),L7(e,PN()?Reflect.construct(t,n||[],mf(e).constructor):t.apply(e,n))}function L7(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 k7(e)}function k7(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function PN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(PN=function(){return!!e})()}function mf(e){return mf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},mf(e)}function U7(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&&wb(e,t)}function wb(e,t){return wb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},wb(e,t)}function In(e,t,n){return t=RN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function RN(e){var t=I7(e,"string");return To(t)=="symbol"?t:t+""}function I7(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;q7(this,t);for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];return n=B7(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 U7(t,e),z7(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=w2(f,M7),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 Q=Math.floor(V*T);if(E[Q]){var Z=E[Q],R=$t(Z.x,B.x),G=$t(Z.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),F;if(d){var U="".concat(d).split(/[,\s]+/gim).map(function(B){return parseFloat(B)});F=l.getStrokeDasharray(z,j,U)}else F=l.generateSimpleStrokeDasharray(j,z);return l.renderCurveStatically(f,r,o,{strokeDasharray:F})})}},{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,F=z===void 0?3:z,U=$.strokeWidth,B=U===void 0?2:U,V=Z2(c)?c:{},Q=V.clipDot,Z=Q===void 0?!0:Q,R=F*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})),!Z&&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,Z,C),(!S||w)&&Dr.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=w2(o,C7),d=$e("recharts-line-dot",typeof r!="boolean"?r.className:"");l=L.createElement(Gf,Wu({key:c},f,{className:d}))}return l}}])})(W.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 H7=["layout","type","stroke","connectNulls","isRange","ref"],G7=["key"],$N;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 qN(e,t){if(e==null)return{};var n=Y7(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 Y7(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 j2(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?j2(Object(n),!0).forEach(function(r){Jn(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function X7(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function M2(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,BN(r.key),r)}}function K7(e,t,n){return t&&M2(e.prototype,t),n&&M2(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function V7(e,t,n){return t=gf(t),Z7(e,zN()?Reflect.construct(t,n||[],gf(e).constructor):t.apply(e,n))}function Z7(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 F7(e)}function F7(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function zN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(zN=function(){return!!e})()}function gf(e){return gf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},gf(e)}function Q7(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 Jn(e,t,n){return t=BN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function BN(e){var t=W7(e,"string");return Eo(t)=="symbol"?t:t+""}function W7(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;X7(this,t);for(var r=arguments.length,o=new Array(r),l=0;l<r;l++)o[l]=arguments[l];return n=V7(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 Q7(t,e),K7(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=qN(f,H7);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 F=Math.floor(z*j);if(S[F]){var U=S[F],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 F=Math.floor(z*j);if(b[F]){var U=b[F],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,F=z===void 0?3:z,U=$.strokeWidth,B=U===void 0?2:U,V=Z2(c)?c:{},Q=V.clipDot,Z=Q===void 0?!0:Q,R=F*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})),!Z&&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,Z,C),(!S||w)&&Dr.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}}])})(W.PureComponent);$N=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=$N.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=qN(t,G7);n=L.createElement(Gf,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 J7(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function eG(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,UN(r.key),r)}}function tG(e,t,n){return t&&eG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function nG(e,t,n){return t=bf(t),rG(e,LN()?Reflect.construct(t,n||[],bf(e).constructor):t.apply(e,n))}function rG(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 aG(e)}function aG(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 iG(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 kN(e,t,n){return t=UN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function UN(e){var t=oG(e,"string");return jo(t)=="symbol"?t:t+""}function oG(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 jb(){return jb=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},jb.apply(this,arguments)}function uG(e){var t=e.xAxisId,n=z0(),r=B0(),o=SN(t);return o==null?null:W.createElement(ko,jb({},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 jr(c,!0)}}))}var kr=(function(e){function t(){return J7(this,t),nG(this,t,arguments)}return iG(t,e),tG(t,[{key:"render",value:function(){return W.createElement(uG,this.props)}}])})(W.Component);kN(kr,"displayName","XAxis");kN(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 lG(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,GN(r.key),r)}}function sG(e,t,n){return t&&cG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function fG(e,t,n){return t=xf(t),dG(e,IN()?Reflect.construct(t,n||[],xf(e).constructor):t.apply(e,n))}function dG(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 hG(e)}function hG(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function IN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(IN=function(){return!!e})()}function xf(e){return xf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},xf(e)}function pG(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&&Mb(e,t)}function Mb(e,t){return Mb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Mb(e,t)}function HN(e,t,n){return t=GN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function GN(e){var t=vG(e,"string");return Mo(t)=="symbol"?t:t+""}function vG(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 Cb(){return Cb=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},Cb.apply(this,arguments)}var yG=function(t){var n=t.yAxisId,r=z0(),o=B0(),l=ON(n);return l==null?null:W.createElement(ko,Cb({},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 jr(f,!0)}}))},Ur=(function(e){function t(){return lG(this,t),fG(this,t,arguments)}return pG(t,e),sG(t,[{key:"render",value:function(){return W.createElement(yG,this.props)}}])})(W.Component);HN(Ur,"displayName","YAxis");HN(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 C2(e){return xG(e)||bG(e)||gG(e)||mG()}function mG(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
185
185
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gG(e,t){if(e){if(typeof e=="string")return Nb(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 Nb(e,t)}}function bG(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function xG(e){if(Array.isArray(e))return Nb(e)}function Nb(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 Db=function(t,n,r,o,l){var c=Nn(t,Vf),f=Nn(t,Ff),d=[].concat(C2(c),C2(f)),h=Nn(t,Wf),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},pg={exports:{}},N2;function SG(){return N2||(N2=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})(pg)),pg.exports}var OG=SG();const _G=Qe(OG);var vg=new _G,yg="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 AG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function wG(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,YN(r.key),r)}}function TG(e,t,n){return t&&wG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function mg(e,t,n){return t=YN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function YN(e){var t=EG(e,"string");return Dl(t)=="symbol"?t:t+""}function EG(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 jG=(function(){function e(){AG(this,e),mg(this,"activeIndex",0),mg(this,"coordinateList",[]),mg(this,"layout","horizontal")}return TG(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 MG(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 CG(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 XN(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 NG(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 XN(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 D2(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?D2(Object(n),!0).forEach(function(r){DG(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):D2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function DG(e,t,n){return t=PG(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function PG(e){var t=RG(e,"string");return Pl(t)=="symbol"?t:t+""}function RG(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 $G(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=_I;else if(g==="BarChart")_=CG(y,c,d,v),S=D0;else if(y==="radial"){var b=XN(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=QC}else _={points:NG(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 W.isValidElement(x)?W.cloneElement(x,T):W.createElement(S,T)}var qG=["item"],zG=["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 P2(e,t){return kG(e)||LG(e,t)||VN(e,t)||BG()}function BG(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
186
186
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function LG(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 kG(e){if(Array.isArray(e))return e}function R2(e,t){if(e==null)return{};var n=UG(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 UG(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 IG(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function HG(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,ZN(r.key),r)}}function GG(e,t,n){return t&&HG(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function YG(e,t,n){return t=Sf(t),XG(e,KN()?Reflect.construct(t,n||[],Sf(e).constructor):t.apply(e,n))}function XG(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 KG(e)}function KG(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function KN(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(KN=function(){return!!e})()}function Sf(e){return Sf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Sf(e)}function VG(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&&Pb(e,t)}function Pb(e,t){return Pb=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,o){return r.__proto__=o,r},Pb(e,t)}function No(e){return QG(e)||FG(e)||VN(e)||ZG()}function ZG(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
|
187
|
-
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function VN(e,t){if(e){if(typeof e=="string")return Rb(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 Rb(e,t)}}function FG(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function QG(e){if(Array.isArray(e))return Rb(e)}function Rb(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 $2(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?$2(Object(n),!0).forEach(function(r){be(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function be(e,t,n){return t=ZN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ZN(e){var t=WG(e,"string");return Co(t)=="symbol"?t:t+""}function WG(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 JG={xAxis:["bottom","top"],yAxis:["left","right"]},eY={width:"100%",height:"100%"},FN={x:0,y:0};function xs(e){return e}var tY=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},nY=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 FN},Jf=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 QN(e){return e==="number"?[0,"auto"]:void 0}var $b=function(t,n,r,o){var l=t.graphicalItems,c=t.tooltipAxis,f=Jf(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=Ss(x,c.dataKey,o)}else g=y&&y[r]||f[r];return g?[].concat(No(d),[VC(h,g)]):d},[])},q2=function(t,n,r,o){var l=o||{x:t.chartX,y:t.chartY},c=tY(l,r),f=t.orderedTooltipTicks,d=t.tooltipAxis,h=t.tooltipTicks,v=n5(c,f,h,d);if(v>=0&&h){var y=h[v]&&h[v].value,g=$b(t,n,v,y),x=nY(r,f,v,l);return{activeTooltipIndex:v,activeLabel:y,activePayload:g,activeCoordinate:x}}return null},rY=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=YC(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 F=Jf(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=F.length,B,V,Q;MG(w.domain,N,E)&&(B=Wg(w.domain,null,N),x&&(E==="number"||T!=="auto")&&(Q=Fu(F,j,"category")));var Z=QN(E);if(!B||B.length===0){var R,G=(R=w.domain)!==null&&R!==void 0?R:Z;if(j){if(B=Fu(F,j,E),E==="category"&&x){var ee=V3(B);A&&ee?(V=B,B=uf(0,U)):A||(B=VE(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=VE(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=u5(F,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")&&(Q=Fu(F,j,"category"))}else x?B=uf(0,U):f&&f[z]&&f[z].hasStack&&E==="number"?B=g==="expand"?[0,1]:KC(f[z].stackGroups,d,h):B=GC(F,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=Db(y,B,z,l,C),G&&(B=Wg(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:Q,duplicateDomain:V,originalDomain:(b=w.domain)!==null&&b!==void 0?b:Z,isCategorical:x,layout:v})))},{})},aY=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=Jf(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:h}),x=g.length,_=YC(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=QN("number");if(!b[j]){S++;var A;return _?A=uf(0,x):f&&f[j]&&f[j].hasStack?(A=KC(f[j].stackGroups,d,h),A=Db(y,A,j,l)):(A=Wg(N,GC(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],F="hide"in T.props?T.props.hide:($=T.type.defaultProps)===null||$===void 0?void 0:$.hide;return z===j&&!F}),"number",v),o.defaultProps.allowDataOverflow),A=Db(y,A,j,l)),ne(ne({},b),{},be({},j,ne(ne({axisType:l},o.defaultProps),{},{hide:!0,orientation:Cn(JG,"".concat(l,".").concat(S%2),null),domain:A,originalDomain:N,isCategorical:_,layout:v})))}return b},{})},iY=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=rY(t,{axes:g,graphicalItems:c,axisType:o,axisIdKey:y,stackGroups:f,dataStartIndex:d,dataEndIndex:h}):c&&c.length&&(x=aY(t,{Axis:l,graphicalItems:c,axisType:o,axisIdKey:y,stackGroups:f,dataStartIndex:d,dataEndIndex:h})),x},oY=function(t){var n=ya(t),r=jr(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:i0(r,function(o){return o.coordinate}),tooltipAxis:n,tooltipAxisBandSize:Fs(n,r)}},z2=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}},uY=function(t){return!t||!t.length?!1:t.some(function(n){var r=Mr(n&&n.type);return r&&r.indexOf("Bar")>=0})},B2=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"}},lY=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=i5(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)})},cY=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},I0=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,F=w.layout,U=w.barGap,B=w.barCategoryGap,V=w.maxBarSize,Q=B2(F),Z=Q.numericAxisName,R=Q.cateAxisName,G=uY(j),ee=[];return j.forEach(function(oe,le){var P=Jf(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(Z,"Id")],me=I["".concat(R,"Id")],Me={},ke=d.reduce(function($n,or){var Uo=E["".concat(or.axisType,"Map")],Bt=I["".concat(or.axisType,"Id")];Uo&&Uo[Bt]||or.axisType==="zAxis"||ai();var Hl=Uo[Bt];return ne(ne({},$n),{},be(be({},or.axisType,Hl),"".concat(or.axisType,"Ticks"),jr(Hl)))},Me),ce=ke[R],xe=ke["".concat(R,"Ticks")],Se=N&&N[pe]&&N[pe].hasStack&&b5(oe,N[pe].stackGroups),ue=Mr(oe.type).indexOf("Bar")>=0,et=Fs(ce,xe),we=[],ot=G&&r5({barSize:z,stackGroups:N,totalSize:cY(ke,R)});if(ue){var ut,zt,Rn=je(se)?V:se,Kn=(ut=(zt=Fs(ce,xe,!0))!==null&&zt!==void 0?zt:Rn)!==null&&ut!==void 0?ut:0;we=a5({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:F,dataStartIndex:C,dataEndIndex:$}))),{},be(be(be({key:oe.key||"item-".concat(le)},Z,ke[Z]),R,ke[R]),"animationId",T)),childIndex:o$(oe,w.children),item:oe})}),ee},x=function(w,E){var j=w.props,N=w.dataStartIndex,A=w.dataEndIndex,T=w.updateId;if(!cA({props:j}))return null;var C=j.children,$=j.layout,z=j.stackOffset,F=j.data,U=j.reverseStackOrder,B=B2($),V=B.numericAxisName,Q=B.cateAxisName,Z=Nn(C,r),R=y5(F,Z,"".concat(V,"Id"),"".concat(Q,"Id"),z,U),G=d.reduce(function(I,re){var se="".concat(re.axisType,"Map");return ne(ne({},I),{},be({},se,iY(j,ne(ne({},re),{},{graphicalItems:Z,stackGroups:re.axisType===V&&R,dataStartIndex:N,dataEndIndex:A}))))},{}),ee=lY(ne(ne({},G),{},{props:j,graphicalItems:Z}),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(Q,"Map")],le=oY(oe),P=g(j,ne(ne({},G),{},{dataStartIndex:N,dataEndIndex:A,updateId:T,graphicalItems:Z,stackGroups:R,offset:ee}));return ne(ne({formattedGraphicalItems:P,graphicalItems:Z,offset:ee,stackGroups:R},le),G)},_=(function(b){function w(E){var j,N,A;return IG(this,w),A=YG(this,w,[E]),be(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),be(A,"accessibilityManager",new jG),be(A,"handleLegendBBoxUpdate",function(T){if(T){var C=A.state,$=C.dataStartIndex,z=C.dataEndIndex,F=C.updateId;A.setState(ne({legendBBox:T},x({props:A.props,dataStartIndex:$,dataEndIndex:z,updateId:F},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=i$(T),$=Cn(A.props,"".concat(C));if(C&&Ae($)){var z,F;/.*touch.*/i.test(C)?F=A.getMouseInfo(T.changedTouches[0]):F=A.getMouseInfo(T),$((z=F)!==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&&vg.emit(yg,A.props.syncId,T,A.eventEmitterSymbol)}),be(A,"applySyncEvent",function(T){var C=A.props,$=C.layout,z=C.syncMethod,F=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:F},A.state)));else if(T.activeTooltipIndex!==void 0){var V=T.chartX,Q=T.chartY,Z=T.activeTooltipIndex,R=A.state,G=R.offset,ee=R.tooltipTicks;if(!G)return;if(typeof z=="function")Z=z(ee,T);else if(z==="value"){Z=-1;for(var oe=0;oe<ee.length;oe++)if(ee[oe].value===T.activeLabel){Z=oe;break}}var le=ne(ne({},G),{},{x:G.left,y:G.top}),P=Math.min(V,le.x+le.width),I=Math.min(Q,le.y+le.height),re=ee[Z]&&ee[Z].value,se=$b(A.state,A.props.data,Z),pe=ee[Z]?{x:$==="horizontal"?ee[Z].coordinate:P,y:$==="horizontal"?I:ee[Z].coordinate}:FN;A.setState(ne(ne({},T),{},{activeLabel:re,activeCoordinate:pe,activePayload:se,activeTooltipIndex:Z}))}else A.setState(T)}),be(A,"renderCursor",function(T){var C,$=A.state,z=$.isTooltipActive,F=$.activeCoordinate,U=$.activePayload,B=$.offset,V=$.activeTooltipIndex,Q=$.tooltipAxisBandSize,Z=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($G,{key:ee,activeCoordinate:F,activePayload:U,activeTooltipIndex:V,chartName:n,element:T,isActive:R,layout:G,offset:B,tooltipAxisBandSize:Q,tooltipEventType:Z})}),be(A,"renderPolarAxis",function(T,C,$){var z=Cn(T,"type.axisType"),F=Cn(A.state,"".concat(z,"Map")),U=T.type.defaultProps,B=U!==void 0?ne(ne({},U),T.props):T.props,V=F&&F[B["".concat(z,"Id")]];return W.cloneElement(T,ne(ne({},V),{},{className:$e(z,V.className),key:T.key||"".concat(C,"-").concat($),ticks:jr(V,!0)}))}),be(A,"renderPolarGrid",function(T){var C=T.props,$=C.radialLines,z=C.polarAngles,F=C.polarRadius,U=A.state,B=U.radiusAxisMap,V=U.angleAxisMap,Q=ya(B),Z=ya(V),R=Z.cx,G=Z.cy,ee=Z.innerRadius,oe=Z.outerRadius;return W.cloneElement(T,{polarAngles:Array.isArray(z)?z:jr(Z,!0).map(function(le){return le.coordinate}),polarRadius:Array.isArray(F)?F:jr(Q,!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,F=C.height,U=A.props.margin||{},B=z-(U.left||0)-(U.right||0),V=IC({children:$,formattedGraphicalItems:T,legendWidth:B,legendContent:h});if(!V)return null;var Q=V.item,Z=R2(V,qG);return W.cloneElement(Q,ne(ne({},Z),{},{chartWidth:z,chartHeight:F,margin:U,onBBoxUpdate:A.handleLegendBBoxUpdate}))}),be(A,"renderTooltip",function(){var T,C=A.props,$=C.children,z=C.accessibilityLayer,F=hn($,pn);if(!F)return null;var U=A.state,B=U.isTooltipActive,V=U.activeCoordinate,Q=U.activePayload,Z=U.activeLabel,R=U.offset,G=(T=F.props.active)!==null&&T!==void 0?T:B;return W.cloneElement(F,{viewBox:ne(ne({},R),{},{x:R.left,y:R.top}),active:G,label:Z,payload:G?Q:[],coordinate:V,accessibilityLayer:z})}),be(A,"renderBrush",function(T){var C=A.props,$=C.margin,z=C.data,F=A.state,U=F.offset,B=F.dataStartIndex,V=F.dataEndIndex,Q=F.updateId;return W.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(Q)})}),be(A,"renderReferenceElement",function(T,C,$){if(!T)return null;var z=A,F=z.clipPathId,U=A.state,B=U.xAxisMap,V=U.yAxisMap,Q=U.offset,Z=T.type.defaultProps||{},R=T.props,G=R.xAxisId,ee=G===void 0?Z.xAxisId:G,oe=R.yAxisId,le=oe===void 0?Z.yAxisId:oe;return W.cloneElement(T,{key:T.key||"".concat(C,"-").concat($),xAxis:B[ee],yAxis:V[le],viewBox:{x:Q.left,y:Q.top,width:Q.width,height:Q.height},clipPathId:F})}),be(A,"renderActivePoints",function(T){var C=T.item,$=T.activePoint,z=T.basePoint,F=T.childIndex,U=T.isRange,B=[],V=C.props.key,Q=C.item.type.defaultProps!==void 0?ne(ne({},C.item.type.defaultProps),C.item.props):C.item.props,Z=Q.activeDot,R=Q.dataKey,G=ne(ne({index:F,dataKey:R,cx:$.x,cy:$.y,r:4,fill:N0(C.item),strokeWidth:2,stroke:"#fff",payload:$.payload,value:$.value},Ee(Z,!1)),Os(Z));return B.push(w.renderActiveDot(Z,G,"".concat(V,"-activePoint-").concat(F))),z?B.push(w.renderActiveDot(Z,ne(ne({},G),{},{cx:z.x,cy:z.y}),"".concat(V,"-basePoint-").concat(F))):U&&B.push(null),B}),be(A,"renderGraphicChild",function(T,C,$){var z=A.filterFormatItem(T,C,$);if(!z)return null;var F=A.getTooltipEventType(),U=A.state,B=U.isTooltipActive,V=U.tooltipAxis,Q=U.activeTooltipIndex,Z=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={};F!=="axis"&&G&&G.props.trigger==="click"?ke={onClick:vs(A.handleItemMouseEnter,T.props.onClick)}:F!=="axis"&&(ke={onMouseLeave:vs(A.handleItemMouseLeave,T.props.onMouseLeave),onMouseEnter:vs(A.handleItemMouseEnter,T.props.onMouseEnter)});var ce=W.cloneElement(T,ne(ne({},z.props),ke));function xe(or){return typeof V.dataKey=="function"?V.dataKey(or.payload):null}if(Me)if(Q>=0){var Se,ue;if(V.dataKey&&!V.allowDuplicatedCategory){var et=typeof V.dataKey=="function"?xe:"payload.".concat(V.dataKey.toString());Se=Ss(oe,et,Z),ue=le&&P&&Ss(P,et,Z)}else Se=oe==null?void 0:oe[Q],ue=le&&P&&P[Q];if(me||pe){var we=T.props.activeIndex!==void 0?T.props.activeIndex:Q;return[W.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:Q,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[W.cloneElement(Kn,$n),null,null]}return le?[ce,null,null]:[ce,null]}),be(A,"renderCustomized",function(T,C,$){return W.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=IM(A.triggeredAfterMouseMove,(N=E.throttleDelay)!==null&&N!==void 0?N:1e3/60),A.state={},A}return VG(w,b),GG(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 F=this.state.tooltipTicks[z]&&this.state.tooltipTicks[z].value,U=$b(this.state,A,z,F),B=this.state.tooltipTicks[z].coordinate,V=(this.state.offset.top+T)/2,Q=C==="horizontal",Z=Q?{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&&(Z=ne(ne({},Z),R.props.points[z].tooltipPosition),U=R.props.points[z].tooltipPayload);var G={activeTooltipIndex:z,isTooltipActive:!0,activeLabel:F,activePayload:U,activeCoordinate:Z};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){xg([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=X8(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 F=this.state,U=F.xAxisMap,B=F.yAxisMap,V=this.getTooltipEventType(),Q=q2(this.state,this.props.data,this.props.layout,z);if(V!=="axis"&&U&&B){var Z=ya(U).scale,R=ya(B).scale,G=Z&&Z.invert?Z.invert(C.chartX):null,ee=R&&R.invert?R.invert(C.chartY):null;return ne(ne({},C),{},{xValue:G,yValue:ee},Q)}return Q?ne(ne({},C),Q):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,F=C>=z.left&&C<=z.left+z.width&&$>=z.top&&$<=z.top+z.height;return F?{x:C,y:$}:null}var U=this.state,B=U.angleAxisMap,V=U.radiusAxisMap;if(B&&V){var Q=ya(B);return QE({x:C,y:$},Q)}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=Os(this.props,this.handleOuterEvent);return ne(ne({},C),T)}},{key:"addListener",value:function(){vg.on(yg,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){vg.removeListener(yg,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===Mr(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=P2(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=P2(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],F=z.props,U=z.item,B=U.type.defaultProps!==void 0?ne(ne({},U.type.defaultProps),U.props):U.props,V=Mr(U.type);if(V==="Bar"){var Q=(F.data||[]).find(function(ee){return hI(j,ee)});if(Q)return{graphicalItem:z,payload:Q}}else if(V==="RadialBar"){var Z=(F.data||[]).find(function(ee){return QE(j,ee)});if(Z)return{graphicalItem:z,payload:Z}}else if(Yf(z,T)||Xf(z,T)||El(z,T)){var R=r9({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(!cA(this))return null;var N=this.props,A=N.children,T=N.className,C=N.width,$=N.height,z=N.style,F=N.compact,U=N.title,B=N.desc,V=R2(N,zG),Q=Ee(V,!1);if(F)return L.createElement(d2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},L.createElement(Og,no({},Q,{width:C,height:$,title:U,desc:B}),this.renderClipPath(),fA(A,this.renderMap)));if(this.props.accessibilityLayer){var Z,R;Q.tabIndex=(Z=this.props.tabIndex)!==null&&Z!==void 0?Z:0,Q.role=(R=this.props.role)!==null&&R!==void 0?R:"application",Q.onKeyDown=function(ee){j.accessibilityManager.keyboardEvent(ee)},Q.onFocus=function(){j.accessibilityManager.focus()}}var G=this.parseEventsOfWrapper();return L.createElement(d2,{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(Og,no({},Q,{width:C,height:$,title:U,desc:B,style:eY}),this.renderClipPath(),fA(A,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(W.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,F=w.dataStartIndex,U=w.dataEndIndex;if(w.updateId===void 0){var B=z2(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=z2(b),Q={chartX:w.chartX,chartY:w.chartY,isTooltipActive:w.isTooltipActive},Z=ne(ne({},q2(w,j,C)),{},{updateId:w.updateId+1}),R=ne(ne(ne({},V),Q),Z);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(!xg(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:F,re=P&&(oe=(le=P.props)===null||le===void 0?void 0:le.endIndex)!==null&&oe!==void 0?oe:U,se=I!==F||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 W.isValidElement(b)?j=W.cloneElement(b,w):Ae(b)?j=b(w):j=L.createElement(Gf,w),L.createElement(Je,{className:"recharts-active-dot",key:E},j)});var S=W.forwardRef(function(w,E){return L.createElement(_,no({},w,{ref:E}))});return S.displayName=_.displayName,S},sY=I0({chartName:"LineChart",GraphicalChild:Il,axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:P0}),fY=I0({chartName:"BarChart",GraphicalChild:fi,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:P0}),WN=I0({chartName:"AreaChart",GraphicalChild:Yn,axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:P0});function dY(e){return new Date(e).toLocaleString("es",{hour:"2-digit",minute:"2-digit",day:"numeric",month:"short"})}function hY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState([]);W.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ht.timeseries("claude_code.tokens.input",e,v),ht.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:dY(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(Rf,{width:"100%",height:220,children:D.jsxs(WN,{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 pY(e){return new Date(e).toLocaleDateString("es",{day:"numeric",month:"short"})}function vY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]);W.useEffect(()=>{ht.timeseries("claude_code.cost",e,"1d").then(r).catch(()=>{})},[e,t]);const o=n.map(l=>({label:pY(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(Rf,{width:"100%",height:220,children:D.jsxs(fY,{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(3)}`}),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 yY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState([]);W.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ht.timeseries("claude_code.tokens.cache.read",e,v),ht.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(Rf,{width:"100%",height:220,children:D.jsxs(WN,{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 mY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState([]);W.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ht.timeseries("claude_code.tokens.input",e,v),ht.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(Rf,{width:"100%",height:220,children:D.jsxs(sY,{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(Vf,{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 gY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState(null),[c,f]=W.useState([]),[d,h]=W.useState(null),[v,y]=W.useState("");W.useEffect(()=>{ht.sessions(50).then(r).catch(()=>{})},[e,t]);function g(S){o===S?l(null):(l(S),ht.sessionEvents(S).then(f).catch(()=>{}))}function x(S,b,w){w.stopPropagation(),h(S),y(b??"")}async function _(S){v.trim()&&(await ht.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 overflow-hidden",children:D.jsxs("table",{className:"w-full text-sm",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(W.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($R,{size:14}):D.jsx(zR,{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(zb,{size:12})}),D.jsx("button",{onClick:()=>h(null),className:"text-accent-orange",children:D.jsx(k2,{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(HR,{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:a3(S.startTime)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-text-secondary",children:Bb(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})]},w))})})})]},S.sessionId))})]})})}function bY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]);if(W.useEffect(()=>{ht.projects(e).then(r).catch(()=>{})},[e,t]),n.length===0)return D.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin proyectos registrados"});const o=Math.max(...n.map(l=>l.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(l=>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:l.project}),D.jsx("span",{className:"text-accent-purple font-mono",children:ei(l.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:`${l.cost/o*100}%`}})})]},l.project))}),D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-hidden",children:D.jsxs("table",{className:"w-full text-sm",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("tbody",{children:n.map(l=>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:l.project}),D.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:l.sessions}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:er(l.tokensInput)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:er(l.tokensOutput)}),D.jsxs("td",{className:"px-3 py-2 text-right font-mono text-accent-teal",children:[(l.cacheHitRate*100).toFixed(1),"%"]}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:ei(l.cost)}),D.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:l.commits}),D.jsxs("td",{className:"px-3 py-2 text-right font-mono text-xs",children:[D.jsxs("span",{className:"text-accent-green",children:["+",l.linesAdded]}),D.jsx("span",{className:"text-text-muted",children:" / "}),D.jsxs("span",{className:"text-accent-orange",children:["-",l.linesRemoved]})]})]},l.project))})]})})]})}function xY({timeRange:e,sseVersion:t}){const[n,r]=W.useState(null);if(W.useEffect(()=>{ht.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 SY=[{id:"all",label:"Todos"},{id:"api",label:"API"},{id:"tools",label:"Tools"},{id:"prompts",label:"Prompts"},{id:"errors",label:"Errores"}];function OY(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 _Y(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 AY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState("all"),[c,f]=W.useState(!1);W.useEffect(()=>{ht.events(500).then(r).catch(()=>{})},[e,t]);const d=n.filter(h=>_Y(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:[SY.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(YR,{size:12}):D.jsx(UR,{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)=>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 ${OY(h.eventName)}`,children:h.eventName}),h.sessionId&&D.jsxs("span",{className:"text-text-muted",children:[h.sessionId.slice(0,6),"…"]})]},v))})]})}function wY({sseVersion:e}){const[t,n]=W.useState([]);if(W.useEffect(()=>{ht.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:Bb(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 TY(){const[e,t]=W.useState("now-7d");return{timeRange:e,setTimeRange:t}}function EY(e){W.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 jY(e){const[t,n]=W.useState({connected:!1,lastSeen:null,sessionCount:0,totalEvents:0,uptime:0}),[r,o]=W.useState(null),[l,c]=W.useState(0),f=W.useRef(0),d=W.useCallback(async()=>{f.current=Date.now();try{const[v,y]=await Promise.all([ht.status(),ht.summary(e)]);n(v),o(y)}catch{}},[e]);W.useEffect(()=>{d()},[d]);const h=W.useCallback((v,y)=>{c(g=>g+1),Date.now()-f.current>5e3?d():ht.status().then(n).catch(()=>{})},[d]);return EY(h),{status:t,summary:r,refetch:d,sseVersion:l}}function MY(){const[e,t]=W.useState("overview"),{timeRange:n,setTimeRange:r}=TY(),{status:o,summary:l,refetch:c,sseVersion:f}=jY(n),d=W.useCallback(async()=>{await ht.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(JO,{timeRange:n,onTimeRangeChange:r,connected:!1,lastSeen:null,onReset:d}),D.jsx(JR,{})]}):D.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex flex-col",children:[D.jsx(JO,{timeRange:n,onTimeRangeChange:r,connected:o.connected,lastSeen:o.lastSeen,onReset:d}),D.jsx(n3,{onLabeled:c}),D.jsx(WR,{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(i3,{summary:l}),D.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[D.jsx(hY,{timeRange:n,sseVersion:f}),D.jsx(vY,{timeRange:n,sseVersion:f})]})]}),e==="sessions"&&D.jsx(gY,{timeRange:n,sseVersion:f}),e==="projects"&&D.jsx(bY,{timeRange:n,sseVersion:f}),e==="tools"&&D.jsx(xY,{timeRange:n,sseVersion:f}),e==="agents"&&D.jsx(wY,{sseVersion:f}),e==="events"&&D.jsx(AY,{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(l.tokens.cache*3e-7)})]})]}),D.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[D.jsx(yY,{timeRange:n,sseVersion:f}),D.jsx(mY,{timeRange:n,sseVersion:f})]})]})]})]})}ER.createRoot(document.getElementById("root")).render(D.jsx(W.StrictMode,{children:D.jsx(MY,{})}));
|
|
187
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function VN(e,t){if(e){if(typeof e=="string")return Rb(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 Rb(e,t)}}function FG(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function QG(e){if(Array.isArray(e))return Rb(e)}function Rb(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 $2(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?$2(Object(n),!0).forEach(function(r){be(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):$2(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function be(e,t,n){return t=ZN(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ZN(e){var t=WG(e,"string");return Co(t)=="symbol"?t:t+""}function WG(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 JG={xAxis:["bottom","top"],yAxis:["left","right"]},eY={width:"100%",height:"100%"},FN={x:0,y:0};function xs(e){return e}var tY=function(t,n){return n==="horizontal"?t.x:n==="vertical"?t.y:n==="centric"?t.angle:t.radius},nY=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 FN},Jf=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 QN(e){return e==="number"?[0,"auto"]:void 0}var $b=function(t,n,r,o){var l=t.graphicalItems,c=t.tooltipAxis,f=Jf(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=Ss(x,c.dataKey,o)}else g=y&&y[r]||f[r];return g?[].concat(No(d),[VC(h,g)]):d},[])},q2=function(t,n,r,o){var l=o||{x:t.chartX,y:t.chartY},c=tY(l,r),f=t.orderedTooltipTicks,d=t.tooltipAxis,h=t.tooltipTicks,v=n5(c,f,h,d);if(v>=0&&h){var y=h[v]&&h[v].value,g=$b(t,n,v,y),x=nY(r,f,v,l);return{activeTooltipIndex:v,activeLabel:y,activePayload:g,activeCoordinate:x}}return null},rY=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=YC(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 F=Jf(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=F.length,B,V,Q;MG(w.domain,N,E)&&(B=Wg(w.domain,null,N),x&&(E==="number"||T!=="auto")&&(Q=Fu(F,j,"category")));var Z=QN(E);if(!B||B.length===0){var R,G=(R=w.domain)!==null&&R!==void 0?R:Z;if(j){if(B=Fu(F,j,E),E==="category"&&x){var ee=V3(B);A&&ee?(V=B,B=uf(0,U)):A||(B=VE(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=VE(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=u5(F,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")&&(Q=Fu(F,j,"category"))}else x?B=uf(0,U):f&&f[z]&&f[z].hasStack&&E==="number"?B=g==="expand"?[0,1]:KC(f[z].stackGroups,d,h):B=GC(F,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=Db(y,B,z,l,C),G&&(B=Wg(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:Q,duplicateDomain:V,originalDomain:(b=w.domain)!==null&&b!==void 0?b:Z,isCategorical:x,layout:v})))},{})},aY=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=Jf(t.data,{graphicalItems:r,dataStartIndex:d,dataEndIndex:h}),x=g.length,_=YC(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=QN("number");if(!b[j]){S++;var A;return _?A=uf(0,x):f&&f[j]&&f[j].hasStack?(A=KC(f[j].stackGroups,d,h),A=Db(y,A,j,l)):(A=Wg(N,GC(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],F="hide"in T.props?T.props.hide:($=T.type.defaultProps)===null||$===void 0?void 0:$.hide;return z===j&&!F}),"number",v),o.defaultProps.allowDataOverflow),A=Db(y,A,j,l)),ne(ne({},b),{},be({},j,ne(ne({axisType:l},o.defaultProps),{},{hide:!0,orientation:Cn(JG,"".concat(l,".").concat(S%2),null),domain:A,originalDomain:N,isCategorical:_,layout:v})))}return b},{})},iY=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=rY(t,{axes:g,graphicalItems:c,axisType:o,axisIdKey:y,stackGroups:f,dataStartIndex:d,dataEndIndex:h}):c&&c.length&&(x=aY(t,{Axis:l,graphicalItems:c,axisType:o,axisIdKey:y,stackGroups:f,dataStartIndex:d,dataEndIndex:h})),x},oY=function(t){var n=ya(t),r=jr(n,!1,!0);return{tooltipTicks:r,orderedTooltipTicks:i0(r,function(o){return o.coordinate}),tooltipAxis:n,tooltipAxisBandSize:Fs(n,r)}},z2=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}},uY=function(t){return!t||!t.length?!1:t.some(function(n){var r=Mr(n&&n.type);return r&&r.indexOf("Bar")>=0})},B2=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"}},lY=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=i5(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)})},cY=function(t,n){if(n==="xAxis")return t[n].width;if(n==="yAxis")return t[n].height},I0=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,F=w.layout,U=w.barGap,B=w.barCategoryGap,V=w.maxBarSize,Q=B2(F),Z=Q.numericAxisName,R=Q.cateAxisName,G=uY(j),ee=[];return j.forEach(function(oe,le){var P=Jf(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(Z,"Id")],me=I["".concat(R,"Id")],Me={},ke=d.reduce(function($n,or){var Uo=E["".concat(or.axisType,"Map")],Bt=I["".concat(or.axisType,"Id")];Uo&&Uo[Bt]||or.axisType==="zAxis"||ai();var Hl=Uo[Bt];return ne(ne({},$n),{},be(be({},or.axisType,Hl),"".concat(or.axisType,"Ticks"),jr(Hl)))},Me),ce=ke[R],xe=ke["".concat(R,"Ticks")],Se=N&&N[pe]&&N[pe].hasStack&&b5(oe,N[pe].stackGroups),ue=Mr(oe.type).indexOf("Bar")>=0,et=Fs(ce,xe),we=[],ot=G&&r5({barSize:z,stackGroups:N,totalSize:cY(ke,R)});if(ue){var ut,zt,Rn=je(se)?V:se,Kn=(ut=(zt=Fs(ce,xe,!0))!==null&&zt!==void 0?zt:Rn)!==null&&ut!==void 0?ut:0;we=a5({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:F,dataStartIndex:C,dataEndIndex:$}))),{},be(be(be({key:oe.key||"item-".concat(le)},Z,ke[Z]),R,ke[R]),"animationId",T)),childIndex:o$(oe,w.children),item:oe})}),ee},x=function(w,E){var j=w.props,N=w.dataStartIndex,A=w.dataEndIndex,T=w.updateId;if(!cA({props:j}))return null;var C=j.children,$=j.layout,z=j.stackOffset,F=j.data,U=j.reverseStackOrder,B=B2($),V=B.numericAxisName,Q=B.cateAxisName,Z=Nn(C,r),R=y5(F,Z,"".concat(V,"Id"),"".concat(Q,"Id"),z,U),G=d.reduce(function(I,re){var se="".concat(re.axisType,"Map");return ne(ne({},I),{},be({},se,iY(j,ne(ne({},re),{},{graphicalItems:Z,stackGroups:re.axisType===V&&R,dataStartIndex:N,dataEndIndex:A}))))},{}),ee=lY(ne(ne({},G),{},{props:j,graphicalItems:Z}),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(Q,"Map")],le=oY(oe),P=g(j,ne(ne({},G),{},{dataStartIndex:N,dataEndIndex:A,updateId:T,graphicalItems:Z,stackGroups:R,offset:ee}));return ne(ne({formattedGraphicalItems:P,graphicalItems:Z,offset:ee,stackGroups:R},le),G)},_=(function(b){function w(E){var j,N,A;return IG(this,w),A=YG(this,w,[E]),be(A,"eventEmitterSymbol",Symbol("rechartsEventEmitter")),be(A,"accessibilityManager",new jG),be(A,"handleLegendBBoxUpdate",function(T){if(T){var C=A.state,$=C.dataStartIndex,z=C.dataEndIndex,F=C.updateId;A.setState(ne({legendBBox:T},x({props:A.props,dataStartIndex:$,dataEndIndex:z,updateId:F},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=i$(T),$=Cn(A.props,"".concat(C));if(C&&Ae($)){var z,F;/.*touch.*/i.test(C)?F=A.getMouseInfo(T.changedTouches[0]):F=A.getMouseInfo(T),$((z=F)!==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&&vg.emit(yg,A.props.syncId,T,A.eventEmitterSymbol)}),be(A,"applySyncEvent",function(T){var C=A.props,$=C.layout,z=C.syncMethod,F=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:F},A.state)));else if(T.activeTooltipIndex!==void 0){var V=T.chartX,Q=T.chartY,Z=T.activeTooltipIndex,R=A.state,G=R.offset,ee=R.tooltipTicks;if(!G)return;if(typeof z=="function")Z=z(ee,T);else if(z==="value"){Z=-1;for(var oe=0;oe<ee.length;oe++)if(ee[oe].value===T.activeLabel){Z=oe;break}}var le=ne(ne({},G),{},{x:G.left,y:G.top}),P=Math.min(V,le.x+le.width),I=Math.min(Q,le.y+le.height),re=ee[Z]&&ee[Z].value,se=$b(A.state,A.props.data,Z),pe=ee[Z]?{x:$==="horizontal"?ee[Z].coordinate:P,y:$==="horizontal"?I:ee[Z].coordinate}:FN;A.setState(ne(ne({},T),{},{activeLabel:re,activeCoordinate:pe,activePayload:se,activeTooltipIndex:Z}))}else A.setState(T)}),be(A,"renderCursor",function(T){var C,$=A.state,z=$.isTooltipActive,F=$.activeCoordinate,U=$.activePayload,B=$.offset,V=$.activeTooltipIndex,Q=$.tooltipAxisBandSize,Z=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($G,{key:ee,activeCoordinate:F,activePayload:U,activeTooltipIndex:V,chartName:n,element:T,isActive:R,layout:G,offset:B,tooltipAxisBandSize:Q,tooltipEventType:Z})}),be(A,"renderPolarAxis",function(T,C,$){var z=Cn(T,"type.axisType"),F=Cn(A.state,"".concat(z,"Map")),U=T.type.defaultProps,B=U!==void 0?ne(ne({},U),T.props):T.props,V=F&&F[B["".concat(z,"Id")]];return W.cloneElement(T,ne(ne({},V),{},{className:$e(z,V.className),key:T.key||"".concat(C,"-").concat($),ticks:jr(V,!0)}))}),be(A,"renderPolarGrid",function(T){var C=T.props,$=C.radialLines,z=C.polarAngles,F=C.polarRadius,U=A.state,B=U.radiusAxisMap,V=U.angleAxisMap,Q=ya(B),Z=ya(V),R=Z.cx,G=Z.cy,ee=Z.innerRadius,oe=Z.outerRadius;return W.cloneElement(T,{polarAngles:Array.isArray(z)?z:jr(Z,!0).map(function(le){return le.coordinate}),polarRadius:Array.isArray(F)?F:jr(Q,!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,F=C.height,U=A.props.margin||{},B=z-(U.left||0)-(U.right||0),V=IC({children:$,formattedGraphicalItems:T,legendWidth:B,legendContent:h});if(!V)return null;var Q=V.item,Z=R2(V,qG);return W.cloneElement(Q,ne(ne({},Z),{},{chartWidth:z,chartHeight:F,margin:U,onBBoxUpdate:A.handleLegendBBoxUpdate}))}),be(A,"renderTooltip",function(){var T,C=A.props,$=C.children,z=C.accessibilityLayer,F=hn($,pn);if(!F)return null;var U=A.state,B=U.isTooltipActive,V=U.activeCoordinate,Q=U.activePayload,Z=U.activeLabel,R=U.offset,G=(T=F.props.active)!==null&&T!==void 0?T:B;return W.cloneElement(F,{viewBox:ne(ne({},R),{},{x:R.left,y:R.top}),active:G,label:Z,payload:G?Q:[],coordinate:V,accessibilityLayer:z})}),be(A,"renderBrush",function(T){var C=A.props,$=C.margin,z=C.data,F=A.state,U=F.offset,B=F.dataStartIndex,V=F.dataEndIndex,Q=F.updateId;return W.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(Q)})}),be(A,"renderReferenceElement",function(T,C,$){if(!T)return null;var z=A,F=z.clipPathId,U=A.state,B=U.xAxisMap,V=U.yAxisMap,Q=U.offset,Z=T.type.defaultProps||{},R=T.props,G=R.xAxisId,ee=G===void 0?Z.xAxisId:G,oe=R.yAxisId,le=oe===void 0?Z.yAxisId:oe;return W.cloneElement(T,{key:T.key||"".concat(C,"-").concat($),xAxis:B[ee],yAxis:V[le],viewBox:{x:Q.left,y:Q.top,width:Q.width,height:Q.height},clipPathId:F})}),be(A,"renderActivePoints",function(T){var C=T.item,$=T.activePoint,z=T.basePoint,F=T.childIndex,U=T.isRange,B=[],V=C.props.key,Q=C.item.type.defaultProps!==void 0?ne(ne({},C.item.type.defaultProps),C.item.props):C.item.props,Z=Q.activeDot,R=Q.dataKey,G=ne(ne({index:F,dataKey:R,cx:$.x,cy:$.y,r:4,fill:N0(C.item),strokeWidth:2,stroke:"#fff",payload:$.payload,value:$.value},Ee(Z,!1)),Os(Z));return B.push(w.renderActiveDot(Z,G,"".concat(V,"-activePoint-").concat(F))),z?B.push(w.renderActiveDot(Z,ne(ne({},G),{},{cx:z.x,cy:z.y}),"".concat(V,"-basePoint-").concat(F))):U&&B.push(null),B}),be(A,"renderGraphicChild",function(T,C,$){var z=A.filterFormatItem(T,C,$);if(!z)return null;var F=A.getTooltipEventType(),U=A.state,B=U.isTooltipActive,V=U.tooltipAxis,Q=U.activeTooltipIndex,Z=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={};F!=="axis"&&G&&G.props.trigger==="click"?ke={onClick:vs(A.handleItemMouseEnter,T.props.onClick)}:F!=="axis"&&(ke={onMouseLeave:vs(A.handleItemMouseLeave,T.props.onMouseLeave),onMouseEnter:vs(A.handleItemMouseEnter,T.props.onMouseEnter)});var ce=W.cloneElement(T,ne(ne({},z.props),ke));function xe(or){return typeof V.dataKey=="function"?V.dataKey(or.payload):null}if(Me)if(Q>=0){var Se,ue;if(V.dataKey&&!V.allowDuplicatedCategory){var et=typeof V.dataKey=="function"?xe:"payload.".concat(V.dataKey.toString());Se=Ss(oe,et,Z),ue=le&&P&&Ss(P,et,Z)}else Se=oe==null?void 0:oe[Q],ue=le&&P&&P[Q];if(me||pe){var we=T.props.activeIndex!==void 0?T.props.activeIndex:Q;return[W.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:Q,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[W.cloneElement(Kn,$n),null,null]}return le?[ce,null,null]:[ce,null]}),be(A,"renderCustomized",function(T,C,$){return W.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=IM(A.triggeredAfterMouseMove,(N=E.throttleDelay)!==null&&N!==void 0?N:1e3/60),A.state={},A}return VG(w,b),GG(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 F=this.state.tooltipTicks[z]&&this.state.tooltipTicks[z].value,U=$b(this.state,A,z,F),B=this.state.tooltipTicks[z].coordinate,V=(this.state.offset.top+T)/2,Q=C==="horizontal",Z=Q?{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&&(Z=ne(ne({},Z),R.props.points[z].tooltipPosition),U=R.props.points[z].tooltipPayload);var G={activeTooltipIndex:z,isTooltipActive:!0,activeLabel:F,activePayload:U,activeCoordinate:Z};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){xg([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=X8(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 F=this.state,U=F.xAxisMap,B=F.yAxisMap,V=this.getTooltipEventType(),Q=q2(this.state,this.props.data,this.props.layout,z);if(V!=="axis"&&U&&B){var Z=ya(U).scale,R=ya(B).scale,G=Z&&Z.invert?Z.invert(C.chartX):null,ee=R&&R.invert?R.invert(C.chartY):null;return ne(ne({},C),{},{xValue:G,yValue:ee},Q)}return Q?ne(ne({},C),Q):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,F=C>=z.left&&C<=z.left+z.width&&$>=z.top&&$<=z.top+z.height;return F?{x:C,y:$}:null}var U=this.state,B=U.angleAxisMap,V=U.radiusAxisMap;if(B&&V){var Q=ya(B);return QE({x:C,y:$},Q)}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=Os(this.props,this.handleOuterEvent);return ne(ne({},C),T)}},{key:"addListener",value:function(){vg.on(yg,this.handleReceiveSyncEvent)}},{key:"removeListener",value:function(){vg.removeListener(yg,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===Mr(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=P2(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=P2(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],F=z.props,U=z.item,B=U.type.defaultProps!==void 0?ne(ne({},U.type.defaultProps),U.props):U.props,V=Mr(U.type);if(V==="Bar"){var Q=(F.data||[]).find(function(ee){return hI(j,ee)});if(Q)return{graphicalItem:z,payload:Q}}else if(V==="RadialBar"){var Z=(F.data||[]).find(function(ee){return QE(j,ee)});if(Z)return{graphicalItem:z,payload:Z}}else if(Yf(z,T)||Xf(z,T)||El(z,T)){var R=r9({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(!cA(this))return null;var N=this.props,A=N.children,T=N.className,C=N.width,$=N.height,z=N.style,F=N.compact,U=N.title,B=N.desc,V=R2(N,zG),Q=Ee(V,!1);if(F)return L.createElement(d2,{state:this.state,width:this.props.width,height:this.props.height,clipPathId:this.clipPathId},L.createElement(Og,no({},Q,{width:C,height:$,title:U,desc:B}),this.renderClipPath(),fA(A,this.renderMap)));if(this.props.accessibilityLayer){var Z,R;Q.tabIndex=(Z=this.props.tabIndex)!==null&&Z!==void 0?Z:0,Q.role=(R=this.props.role)!==null&&R!==void 0?R:"application",Q.onKeyDown=function(ee){j.accessibilityManager.keyboardEvent(ee)},Q.onFocus=function(){j.accessibilityManager.focus()}}var G=this.parseEventsOfWrapper();return L.createElement(d2,{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(Og,no({},Q,{width:C,height:$,title:U,desc:B,style:eY}),this.renderClipPath(),fA(A,this.renderMap)),this.renderLegend(),this.renderTooltip()))}}])})(W.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,F=w.dataStartIndex,U=w.dataEndIndex;if(w.updateId===void 0){var B=z2(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=z2(b),Q={chartX:w.chartX,chartY:w.chartY,isTooltipActive:w.isTooltipActive},Z=ne(ne({},q2(w,j,C)),{},{updateId:w.updateId+1}),R=ne(ne(ne({},V),Q),Z);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(!xg(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:F,re=P&&(oe=(le=P.props)===null||le===void 0?void 0:le.endIndex)!==null&&oe!==void 0?oe:U,se=I!==F||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 W.isValidElement(b)?j=W.cloneElement(b,w):Ae(b)?j=b(w):j=L.createElement(Gf,w),L.createElement(Je,{className:"recharts-active-dot",key:E},j)});var S=W.forwardRef(function(w,E){return L.createElement(_,no({},w,{ref:E}))});return S.displayName=_.displayName,S},sY=I0({chartName:"LineChart",GraphicalChild:Il,axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:P0}),fY=I0({chartName:"BarChart",GraphicalChild:fi,defaultTooltipEventType:"axis",validateTooltipEventTypes:["axis","item"],axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:P0}),WN=I0({chartName:"AreaChart",GraphicalChild:Yn,axisComponents:[{axisType:"xAxis",AxisComp:kr},{axisType:"yAxis",AxisComp:Ur}],formatAxisMap:P0});function dY(e){return new Date(e).toLocaleString("es",{hour:"2-digit",minute:"2-digit",day:"numeric",month:"short"})}function hY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState([]);W.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ht.timeseries("claude_code.tokens.input",e,v),ht.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:dY(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(Rf,{width:"100%",height:220,children:D.jsxs(WN,{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 pY(e){return new Date(e).toLocaleDateString("es",{day:"numeric",month:"short"})}function vY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]);W.useEffect(()=>{ht.timeseries("claude_code.cost",e,"1d").then(r).catch(()=>{})},[e,t]);const o=n.map(l=>({label:pY(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(Rf,{width:"100%",height:220,children:D.jsxs(fY,{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(3)}`}),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 yY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState([]);W.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ht.timeseries("claude_code.tokens.cache.read",e,v),ht.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(Rf,{width:"100%",height:220,children:D.jsxs(WN,{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 mY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState([]);W.useEffect(()=>{const v=e==="now-24h"?"1h":"1d";Promise.all([ht.timeseries("claude_code.tokens.input",e,v),ht.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(Rf,{width:"100%",height:220,children:D.jsxs(sY,{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(Vf,{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 gY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState(null),[c,f]=W.useState([]),[d,h]=W.useState(null),[v,y]=W.useState("");W.useEffect(()=>{ht.sessions(50).then(r).catch(()=>{})},[e,t]);function g(S){o===S?(l(null),f([])):(f([]),l(S),ht.sessionEvents(S).then(f).catch(()=>{}))}function x(S,b,w){w.stopPropagation(),h(S),y(b??"")}async function _(S){v.trim()&&(await ht.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 overflow-hidden",children:D.jsxs("table",{className:"w-full text-sm",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(W.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($R,{size:14}):D.jsx(zR,{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(zb,{size:12})}),D.jsx("button",{onClick:()=>h(null),className:"text-accent-orange",children:D.jsx(k2,{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(HR,{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:a3(S.startTime)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-text-secondary",children:Bb(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 bY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]);if(W.useEffect(()=>{ht.projects(e).then(r).catch(()=>{})},[e,t]),n.length===0)return D.jsx("div",{className:"text-text-muted text-sm p-4",children:"Sin proyectos registrados"});const o=Math.max(...n.map(l=>l.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(l=>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:l.project}),D.jsx("span",{className:"text-accent-purple font-mono",children:ei(l.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:`${l.cost/o*100}%`}})})]},l.project))}),D.jsx("div",{className:"bg-bg-card border border-bg-border rounded-lg overflow-hidden",children:D.jsxs("table",{className:"w-full text-sm",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("tbody",{children:n.map(l=>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:l.project}),D.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:l.sessions}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-blue",children:er(l.tokensInput)}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-green",children:er(l.tokensOutput)}),D.jsxs("td",{className:"px-3 py-2 text-right font-mono text-accent-teal",children:[(l.cacheHitRate*100).toFixed(1),"%"]}),D.jsx("td",{className:"px-3 py-2 text-right font-mono text-accent-purple",children:ei(l.cost)}),D.jsx("td",{className:"px-3 py-2 text-right text-text-secondary",children:l.commits}),D.jsxs("td",{className:"px-3 py-2 text-right font-mono text-xs",children:[D.jsxs("span",{className:"text-accent-green",children:["+",l.linesAdded]}),D.jsx("span",{className:"text-text-muted",children:" / "}),D.jsxs("span",{className:"text-accent-orange",children:["-",l.linesRemoved]})]})]},l.project))})]})})]})}function xY({timeRange:e,sseVersion:t}){const[n,r]=W.useState(null);if(W.useEffect(()=>{ht.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 SY=[{id:"all",label:"Todos"},{id:"api",label:"API"},{id:"tools",label:"Tools"},{id:"prompts",label:"Prompts"},{id:"errors",label:"Errores"}];function OY(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 _Y(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 AY({timeRange:e,sseVersion:t}){const[n,r]=W.useState([]),[o,l]=W.useState("all"),[c,f]=W.useState(!1);W.useEffect(()=>{c||ht.events(500).then(r).catch(()=>{})},[e,t,c]);const d=n.filter(h=>_Y(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:[SY.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(YR,{size:12}):D.jsx(UR,{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)=>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 ${OY(h.eventName)}`,children:h.eventName}),h.sessionId&&D.jsxs("span",{className:"text-text-muted",children:[h.sessionId.slice(0,6),"…"]})]},`${h.sessionId??""}-${h.timestamp}-${h.eventName}-${v}`))})]})}function wY({sseVersion:e}){const[t,n]=W.useState([]);if(W.useEffect(()=>{ht.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:Bb(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 TY(){const[e,t]=W.useState("now-7d");return{timeRange:e,setTimeRange:t}}function EY(e){W.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 jY(e){const[t,n]=W.useState({connected:!1,lastSeen:null,sessionCount:0,totalEvents:0,uptime:0}),[r,o]=W.useState(null),[l,c]=W.useState(0),f=W.useRef(0),d=W.useRef(0),h=W.useCallback(async()=>{f.current=Date.now();try{const[y,g]=await Promise.all([ht.status(),ht.summary(e)]);n(y),o(g)}catch{}},[e]);W.useEffect(()=>{h()},[h]);const v=W.useCallback((y,g)=>{Date.now()-f.current>5e3?h():ht.status().then(n).catch(()=>{});const x=Date.now();x-d.current>5e3&&(d.current=x,c(_=>_+1))},[h]);return EY(v),{status:t,summary:r,refetch:h,sseVersion:l}}function MY(){const[e,t]=W.useState("overview"),{timeRange:n,setTimeRange:r}=TY(),{status:o,summary:l,refetch:c,sseVersion:f}=jY(n),d=W.useCallback(async()=>{await ht.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(JO,{timeRange:n,onTimeRangeChange:r,connected:!1,lastSeen:null,onReset:d}),D.jsx(JR,{})]}):D.jsxs("div",{className:"min-h-screen bg-bg-base text-text-primary flex flex-col",children:[D.jsx(JO,{timeRange:n,onTimeRangeChange:r,connected:o.connected,lastSeen:o.lastSeen,onReset:d}),D.jsx(n3,{onLabeled:c}),D.jsx(WR,{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(i3,{summary:l}),D.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[D.jsx(hY,{timeRange:n,sseVersion:f}),D.jsx(vY,{timeRange:n,sseVersion:f})]})]}),e==="sessions"&&D.jsx(gY,{timeRange:n,sseVersion:f}),e==="projects"&&D.jsx(bY,{timeRange:n,sseVersion:f}),e==="tools"&&D.jsx(xY,{timeRange:n,sseVersion:f}),e==="agents"&&D.jsx(wY,{sseVersion:f}),e==="events"&&D.jsx(AY,{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(l.tokens.cache*3e-7)})]})]}),D.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[D.jsx(yY,{timeRange:n,sseVersion:f}),D.jsx(mY,{timeRange:n,sseVersion:f})]})]})]})]})}ER.createRoot(document.getElementById("root")).render(D.jsx(W.StrictMode,{children:D.jsx(MY,{})}));
|
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-DQk3XNu9.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-B0dy8dWP.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
package/src/api-routes.js
CHANGED
|
@@ -40,17 +40,37 @@ export function broadcast(type, payload) {
|
|
|
40
40
|
|
|
41
41
|
/**
|
|
42
42
|
* Crea y devuelve el router Express con todas las rutas /api/*.
|
|
43
|
+
* @param {{ port?: number }} options
|
|
43
44
|
* @returns {Router}
|
|
44
45
|
*/
|
|
45
|
-
export function createRouter() {
|
|
46
|
+
export function createRouter({ port = 1337 } = {}) {
|
|
46
47
|
const router = Router()
|
|
47
48
|
|
|
48
|
-
//
|
|
49
|
+
// Solo se permiten solicitudes del propio dashboard (mismo origen)
|
|
50
|
+
const allowedOrigins = new Set([
|
|
51
|
+
`http://localhost:${port}`,
|
|
52
|
+
`http://127.0.0.1:${port}`,
|
|
53
|
+
])
|
|
54
|
+
|
|
55
|
+
// CORS: responder solo al origen del dashboard, nunca con wildcard
|
|
49
56
|
router.use((req, res, next) => {
|
|
50
|
-
|
|
57
|
+
const origin = req.headers.origin
|
|
58
|
+
if (origin && allowedOrigins.has(origin)) {
|
|
59
|
+
res.setHeader('Access-Control-Allow-Origin', origin)
|
|
60
|
+
}
|
|
51
61
|
next()
|
|
52
62
|
})
|
|
53
63
|
|
|
64
|
+
// Guard CSRF: bloquea POST con Origin presente pero no permitido.
|
|
65
|
+
// Requests sin Origin (CLI, tests, curl) pasan sin restricción.
|
|
66
|
+
function requireSafeOrigin(req, res, next) {
|
|
67
|
+
const origin = req.headers.origin
|
|
68
|
+
if (origin && !allowedOrigins.has(origin)) {
|
|
69
|
+
return res.status(403).json({ error: 'origen no permitido' })
|
|
70
|
+
}
|
|
71
|
+
return next()
|
|
72
|
+
}
|
|
73
|
+
|
|
54
74
|
// ── SSE ────────────────────────────────────────────────────────────────────
|
|
55
75
|
|
|
56
76
|
/**
|
|
@@ -61,7 +81,6 @@ export function createRouter() {
|
|
|
61
81
|
res.setHeader('Content-Type', 'text/event-stream')
|
|
62
82
|
res.setHeader('Cache-Control', 'no-cache')
|
|
63
83
|
res.setHeader('Connection', 'keep-alive')
|
|
64
|
-
res.setHeader('Access-Control-Allow-Origin', '*')
|
|
65
84
|
res.flushHeaders()
|
|
66
85
|
|
|
67
86
|
const clientId = ++_nextClientId
|
|
@@ -111,7 +130,7 @@ export function createRouter() {
|
|
|
111
130
|
/** GET /api/sessions — lista de sesiones, acepta ?limit, ?project */
|
|
112
131
|
router.get('/api/sessions', (req, res) => {
|
|
113
132
|
res.json(getSessions({
|
|
114
|
-
limit:
|
|
133
|
+
limit: Math.min(Number(req.query.limit) || 50, 500),
|
|
115
134
|
project: req.query.project || null
|
|
116
135
|
}))
|
|
117
136
|
})
|
|
@@ -124,7 +143,7 @@ export function createRouter() {
|
|
|
124
143
|
/** GET /api/events — eventos filtrados, acepta ?limit, ?type, ?project */
|
|
125
144
|
router.get('/api/events', (req, res) => {
|
|
126
145
|
res.json(getEvents({
|
|
127
|
-
limit:
|
|
146
|
+
limit: Math.min(Number(req.query.limit) || 200, 500),
|
|
128
147
|
type: req.query.type || null,
|
|
129
148
|
project: req.query.project || null
|
|
130
149
|
}))
|
|
@@ -150,10 +169,10 @@ export function createRouter() {
|
|
|
150
169
|
* Asigna un proyecto a una sesión.
|
|
151
170
|
* Body: { project: string }
|
|
152
171
|
*/
|
|
153
|
-
router.post('/api/sessions/:sessionId/label', (req, res) => {
|
|
172
|
+
router.post('/api/sessions/:sessionId/label', requireSafeOrigin, (req, res) => {
|
|
154
173
|
const { project } = req.body
|
|
155
|
-
if (!project || typeof project !== 'string') {
|
|
156
|
-
return res.status(400).json({ error: 'project
|
|
174
|
+
if (!project || typeof project !== 'string' || project.length > 200) {
|
|
175
|
+
return res.status(400).json({ error: 'project inválido' })
|
|
157
176
|
}
|
|
158
177
|
labelSession(req.params.sessionId, project)
|
|
159
178
|
broadcast('label_updated', { sessionId: req.params.sessionId, project })
|
|
@@ -164,13 +183,13 @@ export function createRouter() {
|
|
|
164
183
|
* POST /api/sessions/:sessionId/ignore
|
|
165
184
|
* Marca una sesión como ignorada (no aparecerá en notificaciones ni en métricas).
|
|
166
185
|
*/
|
|
167
|
-
router.post('/api/sessions/:sessionId/ignore', (req, res) => {
|
|
186
|
+
router.post('/api/sessions/:sessionId/ignore', requireSafeOrigin, (req, res) => {
|
|
168
187
|
ignoreSession(req.params.sessionId)
|
|
169
188
|
res.json({ ok: true })
|
|
170
189
|
})
|
|
171
190
|
|
|
172
191
|
/** POST /api/reset — resetea todo el estado en memoria */
|
|
173
|
-
router.post('/api/reset', (req, res) => {
|
|
192
|
+
router.post('/api/reset', requireSafeOrigin, (req, res) => {
|
|
174
193
|
reset()
|
|
175
194
|
res.json({ ok: true })
|
|
176
195
|
})
|
package/src/otlp-parser.js
CHANGED
|
@@ -21,6 +21,7 @@ export function extractAttributes(attrs) {
|
|
|
21
21
|
for (const attr of attrs) {
|
|
22
22
|
const { key, value } = attr
|
|
23
23
|
if (!key || !value) continue
|
|
24
|
+
if (key === '__proto__' || key === 'constructor' || key === 'prototype') continue
|
|
24
25
|
|
|
25
26
|
if ('stringValue' in value) {
|
|
26
27
|
result[key] = value.stringValue
|
package/src/server.js
CHANGED
|
@@ -31,6 +31,14 @@ export async function startServer({ port = 1337 } = {}) {
|
|
|
31
31
|
const app = express()
|
|
32
32
|
app.use(express.json({ limit: '10mb' }))
|
|
33
33
|
|
|
34
|
+
// Headers de seguridad HTTP mínimos
|
|
35
|
+
app.use((_req, res, next) => {
|
|
36
|
+
res.setHeader('X-Content-Type-Options', 'nosniff')
|
|
37
|
+
res.setHeader('X-Frame-Options', 'DENY')
|
|
38
|
+
res.setHeader('Referrer-Policy', 'no-referrer')
|
|
39
|
+
next()
|
|
40
|
+
})
|
|
41
|
+
|
|
34
42
|
// ── Endpoints OTLP ──────────────────────────────────────────────────────────
|
|
35
43
|
|
|
36
44
|
/**
|
|
@@ -83,7 +91,7 @@ export async function startServer({ port = 1337 } = {}) {
|
|
|
83
91
|
})
|
|
84
92
|
|
|
85
93
|
// ── API REST + SSE ──────────────────────────────────────────────────────────
|
|
86
|
-
app.use(createRouter())
|
|
94
|
+
app.use(createRouter({ port }))
|
|
87
95
|
|
|
88
96
|
// ── Archivos estáticos (web compilada) ──────────────────────────────────────
|
|
89
97
|
// dist/ está en la raíz del proyecto (un nivel arriba de src/)
|
|
@@ -111,7 +119,7 @@ export async function startServer({ port = 1337 } = {}) {
|
|
|
111
119
|
|
|
112
120
|
// ── Arrancar servidor ───────────────────────────────────────────────────────
|
|
113
121
|
return new Promise((resolve) => {
|
|
114
|
-
const server = app.listen(port, () => {
|
|
122
|
+
const server = app.listen(port, '127.0.0.1', () => {
|
|
115
123
|
resolve({ app, server, autoSaveInterval })
|
|
116
124
|
})
|
|
117
125
|
})
|
package/src/store.js
CHANGED
|
@@ -220,7 +220,10 @@ export function processMetric(raw) {
|
|
|
220
220
|
|
|
221
221
|
// ── Timeseries ──
|
|
222
222
|
if (!state.timeseries.has(name)) state.timeseries.set(name, [])
|
|
223
|
-
state.timeseries.get(name)
|
|
223
|
+
const tsPoints = state.timeseries.get(name)
|
|
224
|
+
tsPoints.push({ ts: timestamp, value, labels })
|
|
225
|
+
// Cap por métrica para prevenir DoS por agotamiento de memoria
|
|
226
|
+
if (tsPoints.length > 10_000) tsPoints.splice(0, tsPoints.length - 10_000)
|
|
224
227
|
|
|
225
228
|
// ── Sesiones ──
|
|
226
229
|
if (sessionId) {
|
|
@@ -436,15 +439,9 @@ export function labelSession(sessionId, project) {
|
|
|
436
439
|
state.sessions.get(sessionId).project = project
|
|
437
440
|
}
|
|
438
441
|
|
|
439
|
-
//
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
if (point.labels['session.id'] === sessionId) {
|
|
443
|
-
point.labels.project = project
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
|
|
442
|
+
// No es necesario propagar retroactivamente a los labels de timeseries:
|
|
443
|
+
// resolveProject() consulta sessionMappings primero, por lo que todos los
|
|
444
|
+
// lectores de labels.project ya obtendrán el valor correcto.
|
|
448
445
|
rebuildProjectAggregates()
|
|
449
446
|
scheduleSave()
|
|
450
447
|
}
|
|
@@ -486,13 +483,16 @@ export function reset() {
|
|
|
486
483
|
* Estado de conexión del servidor.
|
|
487
484
|
*/
|
|
488
485
|
export function getStatus() {
|
|
486
|
+
let sessionCount = 0
|
|
487
|
+
for (const id of state.sessions.keys()) {
|
|
488
|
+
if (!state.ignoredSessions.has(id)) sessionCount++
|
|
489
|
+
}
|
|
489
490
|
return {
|
|
490
|
-
connected:
|
|
491
|
-
lastSeen:
|
|
492
|
-
sessionCount
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
uptime: Date.now() - state.startTime
|
|
491
|
+
connected: state.lastSeen !== null,
|
|
492
|
+
lastSeen: state.lastSeen,
|
|
493
|
+
sessionCount,
|
|
494
|
+
totalEvents: state.totalEvents,
|
|
495
|
+
uptime: Date.now() - state.startTime
|
|
496
496
|
}
|
|
497
497
|
}
|
|
498
498
|
|
|
@@ -587,8 +587,24 @@ export function getProjects(from) {
|
|
|
587
587
|
const minTs = parseTimeRange(from)
|
|
588
588
|
const result = []
|
|
589
589
|
|
|
590
|
+
// Pre-agregar commits/líneas desde timeseries en un único recorrido O(puntos)
|
|
591
|
+
// en lugar de O(proyectos × puntos)
|
|
592
|
+
const tsAgg = new Map() // projectName → { commits, linesAdded, linesRemoved }
|
|
593
|
+
for (const [metric, field] of [
|
|
594
|
+
['claude_code.commits', 'commits'],
|
|
595
|
+
['claude_code.lines_added', 'linesAdded'],
|
|
596
|
+
['claude_code.lines_removed', 'linesRemoved'],
|
|
597
|
+
]) {
|
|
598
|
+
for (const point of state.timeseries.get(metric) ?? []) {
|
|
599
|
+
if (point.ts < minTs) continue
|
|
600
|
+
const proj = resolveProject(point.labels['session.id'], point.labels.project)
|
|
601
|
+
if (!proj) continue
|
|
602
|
+
if (!tsAgg.has(proj)) tsAgg.set(proj, { commits: 0, linesAdded: 0, linesRemoved: 0 })
|
|
603
|
+
tsAgg.get(proj)[field] += point.value
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
|
|
590
607
|
for (const [project, proj] of state.projects.entries()) {
|
|
591
|
-
// Filtrar sesiones activas en el rango
|
|
592
608
|
const activeSessions = new Set()
|
|
593
609
|
let cost = 0, tokensInput = 0, tokensOutput = 0, tokensCache = 0
|
|
594
610
|
|
|
@@ -604,20 +620,7 @@ export function getProjects(from) {
|
|
|
604
620
|
|
|
605
621
|
if (activeSessions.size === 0 && minTs > 0) continue
|
|
606
622
|
|
|
607
|
-
|
|
608
|
-
let commits = 0, linesAdded = 0, linesRemoved = 0
|
|
609
|
-
const tsMap = {
|
|
610
|
-
'claude_code.commits': (v) => { commits += v },
|
|
611
|
-
'claude_code.lines_added': (v) => { linesAdded += v },
|
|
612
|
-
'claude_code.lines_removed': (v) => { linesRemoved += v }
|
|
613
|
-
}
|
|
614
|
-
for (const [metric, accum] of Object.entries(tsMap)) {
|
|
615
|
-
for (const point of state.timeseries.get(metric) ?? []) {
|
|
616
|
-
const pointProject = resolveProject(point.labels['session.id'], point.labels.project)
|
|
617
|
-
if (pointProject === project && point.ts >= minTs) accum(point.value)
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
|
|
623
|
+
const { commits, linesAdded, linesRemoved } = tsAgg.get(project) ?? { commits: 0, linesAdded: 0, linesRemoved: 0 }
|
|
621
624
|
const cacheHitRate = tokensInput > 0 ? tokensCache / tokensInput : 0
|
|
622
625
|
|
|
623
626
|
result.push({
|
|
@@ -766,7 +769,7 @@ export function getModels(from) {
|
|
|
766
769
|
*/
|
|
767
770
|
export function saveSync() {
|
|
768
771
|
try {
|
|
769
|
-
fs.mkdirSync(dataDir, { recursive: true })
|
|
772
|
+
fs.mkdirSync(dataDir, { recursive: true, mode: 0o700 })
|
|
770
773
|
|
|
771
774
|
const data = {
|
|
772
775
|
timeseries: Array.from(state.timeseries.entries()),
|
|
@@ -779,7 +782,11 @@ export function saveSync() {
|
|
|
779
782
|
startTime: state.startTime
|
|
780
783
|
}
|
|
781
784
|
|
|
782
|
-
fs.writeFileSync(dataFile, JSON.stringify(data))
|
|
785
|
+
fs.writeFileSync(dataFile, JSON.stringify(data), { mode: 0o600 })
|
|
786
|
+
// Forzar permisos en archivos ya existentes (mode en writeFileSync
|
|
787
|
+
// solo aplica al crear el archivo, no al sobreescribirlo)
|
|
788
|
+
try { fs.chmodSync(dataDir, 0o700) } catch {}
|
|
789
|
+
try { fs.chmodSync(dataFile, 0o600) } catch {}
|
|
783
790
|
} catch (err) {
|
|
784
791
|
console.error('[store] Error guardando datos en disco:', err.message)
|
|
785
792
|
}
|
|
@@ -836,18 +843,12 @@ export function loadFromDisk() {
|
|
|
836
843
|
state.startTime = data.startTime
|
|
837
844
|
}
|
|
838
845
|
|
|
839
|
-
// Re-aplicar mappings a sesiones
|
|
846
|
+
// Re-aplicar mappings a sesiones (timeseries no necesitan propagación:
|
|
847
|
+
// resolveProject() consulta sessionMappings primero en todos los lectores)
|
|
840
848
|
for (const [sessionId, project] of state.sessionMappings.entries()) {
|
|
841
849
|
if (state.sessions.has(sessionId)) {
|
|
842
850
|
state.sessions.get(sessionId).project = project
|
|
843
851
|
}
|
|
844
|
-
for (const points of state.timeseries.values()) {
|
|
845
|
-
for (const point of points) {
|
|
846
|
-
if (point.labels['session.id'] === sessionId) {
|
|
847
|
-
point.labels.project = project
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
}
|
|
851
852
|
}
|
|
852
853
|
|
|
853
854
|
rebuildProjectAggregates()
|