@codeplex-sac/graficos 0.0.22 → 0.0.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/index.cjs +1 -1
  2. package/index.js +1 -1
  3. package/package.json +1 -1
package/index.cjs CHANGED
@@ -45,4 +45,4 @@ To suppress this warning, you need to explicitly provide the \`palette.${r}Chann
45
45
  `;const ca=or.keyframes`
46
46
  0% { transform: scale(1); opacity: 0.55; }
47
47
  100% { transform: scale(2.6); opacity: 0; }
48
- `,Se={arriba:0,derecha:8,abajo:25,izquierda:28},la={lineal:ue.curveLinear,suave:ue.curveMonotoneX,escalon:ue.curveStep,natural:ue.curveNatural},da=e=>e instanceof Date,$t=e=>e instanceof Date?e.toLocaleDateString("es-ES",{day:"2-digit",month:"short"}):String(e),pa=({series:e,datos:r,titulo:t,subtitulo:o,alto:a=288,curva:i="suave",color:d,gradiente:f=!1,mostrarValores:y=!1,pulsante:h=!1,conCuadricula:v=!0,conTooltip:u=!0,conPapel:x=!0})=>{const m=pe(),p=ce(),s=ne.useId().replace(/:/g,""),$=ne.useMemo(()=>e&&e.length>0?e:r&&r.length>0?[{nombre:t??"Serie",datos:r,color:d}]:[],[e,r,t,d]),E=$.some(b=>b.datos.some(g=>g.icono)),w=ne.useMemo(()=>{const b=$.flatMap(N=>N.datos.map(I=>I.etiqueta)),g=$.flatMap(N=>N.datos.map(I=>I.valor)),S=le.max(g)??0,B=oe.scaleLinear().domain([0,S===0?1:S]).range([100,0]),_=b[0];let M;if(_ instanceof Date){const N=b.filter(da),I=le.extent(N),U=oe.scaleTime().domain(I).range([0,100]);M=C=>U(C)}else if(typeof _=="number"){const N=b,I=oe.scaleLinear().domain([le.min(N)??0,le.max(N)??0]).range([0,100]);M=U=>I(U)}else{const N=b.map(U=>String(U)),I=oe.scalePoint().domain(N).range([0,100]);M=U=>I(String(U))??0}const Y=ue.line().x(N=>M(N.etiqueta)).y(N=>B(N.valor)).curve(la[i]),P=B.ticks(6).map(N=>({posicion:B(N),texto:String(N)})),l=B.ticks(6).map(N=>B(N)),A=$[0]?.datos??[],k=A.reduce((N,I,U,C)=>I.valor>C[N].valor?U:N,0),z=Array.from(new Set([0,k,A.length-1].filter(N=>N>=0))).map(N=>({posicion:M(A[N].etiqueta),texto:$t(A[N].etiqueta),anclaje:N===0?"inicio":N===A.length-1?"fin":"centro"}));return{escalaY:B,posicionX:M,generarLinea:Y,marcasY:P,marcasX:z,posicionesCuadricula:l}},[$,i]),j=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:a},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Se.arriba}px - ${Se.abajo}px)`,width:`${Se.izquierda}px`,transform:`translateY(${Se.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:w.marcasY})}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Se.arriba}px - ${Se.abajo}px)`,width:`calc(100% - ${Se.izquierda}px - ${Se.derecha}px)`,transform:`translate(${Se.izquierda}px, ${Se.arriba}px)`,overflow:"visible"},children:[n.jsxs(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{width:"100%",height:"100%",overflow:"visible"},children:[f&&n.jsx("defs",{children:n.jsxs("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[n.jsx("stop",{offset:"0%",stopColor:p.color(d??"primario")}),n.jsx("stop",{offset:"100%",stopColor:p.color(d==="secundario"?"error":"secundario")})]})}),v&&n.jsx(Re,{posiciones:w.posicionesCuadricula}),$.map((b,g)=>{const S=w.generarLinea(b.datos),B=b.color?p.color(b.color):d?p.color(d):p.serie(g);return S?n.jsxs("g",{children:[n.jsx("path",{d:S,fill:"none",stroke:f?`url(#${s})`:B,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"}),u&&b.datos.map((_,M)=>{const Y=w.posicionX(_.etiqueta),P=w.escalaY(_.valor);return n.jsxs(ir,{children:[n.jsxs(Ke,{children:[n.jsx("path",{d:`M ${Y} ${P} l 0.0001 0`,stroke:B,strokeWidth:7,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),n.jsx("path",{d:`M ${Y} ${P} l 0.0001 0`,stroke:"transparent",strokeWidth:18,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"})]}),n.jsxs(sr,{children:[n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:b.nombre}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,color:"text.primary",children:[$t(_.etiqueta)," ·"," ",_.valor.toLocaleString("es-ES")]})]})]},`${b.nombre}-${M}`)})]},b.nombre):null})]}),(y||E||h)&&n.jsxs(c.Box,{sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:[$.flatMap((b,g)=>b.datos.map((S,B)=>{const _=w.posicionX(S.etiqueta),M=w.escalaY(S.valor),Y=b.color?p.color(b.color):d?p.color(d):p.serie(g),P=`${b.nombre}-${B}`;return S.icono?n.jsx(c.Box,{sx:{position:"absolute",left:`${_}%`,top:`${M}%`,transform:"translate(-50%, -50%)",width:24,height:24,borderRadius:"50%",overflow:"hidden","& img, & svg":{width:"100%",height:"100%"}},children:S.icono},P):y?n.jsx(c.Box,{sx:{position:"absolute",left:`${_}%`,top:`${M}%`,transform:"translate(-50%, -50%)",minWidth:20,height:20,px:.5,borderRadius:"999px",bgcolor:"background.paper",border:`1px solid ${Y}`,color:"text.primary",fontSize:11,fontVariantNumeric:"tabular-nums",display:"flex",alignItems:"center",justifyContent:"center"},children:S.valor},P):null})),h&&$[0]?.datos.length>0&&(()=>{const b=$[0],g=b.datos[b.datos.length-1],S=w.posicionX(g.etiqueta),B=w.escalaY(g.valor),_=b.color?p.color(b.color):d?p.color(d):p.serie(0);return n.jsxs(c.Box,{sx:{position:"absolute",left:`${S}%`,top:`${B}%`,transform:"translate(-50%, -50%)",width:10,height:10},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,borderRadius:"50%",bgcolor:_,animation:`${ca} 1.4s ease-out infinite`}}),n.jsx(c.Box,{sx:{position:"absolute",inset:"25%",borderRadius:"50%",bgcolor:_}})]})})()]}),n.jsx(c.Box,{sx:{position:"relative",mt:1},children:n.jsx(Ar,{marcas:w.marcasX})})]})]});return x?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${m.palette.divider}`,bgcolor:m.palette.background.paper,boxShadow:m.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),j]}):j},je={arriba:12,derecha:8,abajo:28},ua=({datos:e,titulo:r,subtitulo:t,alto:o=288,orientacion:a="horizontal",color:i,gradiente:d=!1,animado:f=!0,delgado:y=!1,mostrarValores:h=!1,conCuadricula:v=!0,conTooltip:u=!0,conPapel:x=!0})=>{const m=pe(),p=ce(),s=a==="horizontal",$=e.some(S=>S.icono),E=ne.useMemo(()=>{const S=e.map(A=>A.clave),B=le.max(e,A=>A.valor)??0,_=oe.scaleBand().domain(S).range([0,100]).padding(y?.6:.2),M=oe.scaleLinear().domain([0,B===0?1:B]).range(s?[0,100]:[100,0]),Y=M.ticks(5),P=Y.map(A=>M(A)),l=S.reduce((A,k)=>Math.max(A,k.length),1);return{claves:S,escalaCategoria:_,escalaValor:M,marcasValor:Y,posicionesCuadricula:P,margenCategoria:s?Math.min(l*7,120)+($?32:0):28}},[e,s,y,$]),w=(S,B)=>{const _=S.color?p.color(S.color):i?p.color(i):p.serie(B);return d?`linear-gradient(180deg, ${Ye.alpha(_,1)}, ${Ye.alpha(_,.55)})`:_},j=s?E.margenCategoria:je.derecha,b=e.map((S,B)=>{const _=E.escalaCategoria(S.clave)??0,M=E.escalaCategoria.bandwidth(),Y=s?E.escalaValor(S.valor):100-E.escalaValor(S.valor),P=n.jsx(c.Box,{sx:{position:"absolute",...s?{left:0,top:`${_}%`,width:`${Y}%`,height:`${M}%`,borderRadius:"0 6px 6px 0",transformOrigin:"left center",animation:f?`${Xt} 0.5s ease-out ${B*.06}s both`:"none"}:{left:`${_}%`,bottom:0,width:`${M}%`,height:`${Y}%`,borderRadius:"6px 6px 0 0",transformOrigin:"bottom center",animation:f?`${Ht} 0.5s ease-out ${B*.06}s both`:"none"},background:w(S,B)}});return u?n.jsx(c.Tooltip,{arrow:!0,placement:s?"right":"top",title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:S.clave}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:S.valor.toLocaleString("es-ES")})]}),children:P},S.clave):n.jsx(c.Box,{children:P},S.clave)}),g=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:o},children:[n.jsxs(c.Box,{sx:{position:"absolute",inset:0,zIndex:1,height:`calc(100% - ${je.arriba}px - ${je.abajo}px)`,width:`calc(100% - ${j}px - ${je.derecha}px)`,transform:`translate(${j}px, ${je.arriba}px)`,overflow:"visible"},children:[v&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:E.posicionesCuadricula,orientacion:s?"vertical":"horizontal"})}),b,h&&e.map(S=>{const _=(E.escalaCategoria(S.clave)??0)+E.escalaCategoria.bandwidth()/2,M=E.escalaValor(S.valor);return n.jsx(c.Box,{sx:{position:"absolute",color:p.ejeTexto,fontSize:12,fontWeight:500,fontVariantNumeric:"tabular-nums",pointerEvents:"none",whiteSpace:"nowrap",...s?{left:`calc(${M}% + 4px)`,top:`${_}%`,transform:"translateY(-50%)"}:{left:`${_}%`,top:`${M}%`,transform:"translate(-50%, -130%)"}},children:S.valor},`valor-${S.clave}`)}),E.marcasValor.map((S,B)=>n.jsx(c.Box,{sx:{position:"absolute",color:p.ejeTexto,fontSize:12,fontVariantNumeric:"tabular-nums",...s?{left:`${E.escalaValor(S)}%`,top:"100%",transform:"translateX(-50%)",pt:.5}:{top:`${E.escalaValor(S)}%`,right:"100%",transform:"translateY(-50%)",pr:1}},children:S},B))]}),n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${je.arriba}px - ${je.abajo}px)`,transform:`translateY(${je.arriba}px)`,overflow:"visible",...s?{width:`${j}px`}:{top:"auto",bottom:0,height:`${je.abajo}px`,transform:"none",left:`${j}px`,right:`${je.derecha}px`}},children:e.map(S=>{const B=(E.escalaCategoria(S.clave)??0)+E.escalaCategoria.bandwidth()/2;return n.jsxs(c.Box,{sx:{position:"absolute",display:"flex",alignItems:"center",gap:.75,color:p.ejeTexto,fontSize:12,whiteSpace:"nowrap",...s?{top:`${B}%`,left:S.icono?0:void 0,right:S.icono?void 0:m.spacing(1),transform:"translateY(-50%)"}:{left:`${B}%`,top:4,transform:"translateX(-50%)"}},children:[S.icono&&n.jsx(c.Box,{sx:{width:22,height:22,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",borderRadius:"50%","& img, & svg":{width:"100%",height:"100%"}},children:S.icono}),S.clave]},S.clave)})})]});return x?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${m.palette.divider}`,bgcolor:m.palette.background.paper,boxShadow:m.shadows[1]},children:[(r||t)&&n.jsxs(c.Box,{sx:{mb:2},children:[r&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:r}),t&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:t})]}),g]}):g},fa=({datos:e,variante:r="grueso",titulo:t,subtitulo:o,conPapel:a=!0})=>{const i=pe(),d=ce(),f=r==="grueso",y=n.jsx(c.Box,{sx:{display:"flex",gap:.4,width:"100%",alignItems:"stretch"},children:e.map((h,v)=>{const u=h.color?d.color(h.color):d.serie(v);return n.jsxs(c.Box,{sx:{flexGrow:Math.max(h.valor,.001),flexBasis:0,minWidth:0},children:[n.jsx(c.Box,{sx:{position:"relative",height:f?54:12,borderRadius:1,background:`linear-gradient(180deg, ${u}, ${u}cc)`,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:f&&n.jsxs(n.Fragment,{children:[n.jsx(c.Typography,{variant:"caption",sx:{color:i.palette.common.white,fontWeight:600,lineHeight:1.2,whiteSpace:"nowrap"},children:h.clave}),n.jsx(c.Typography,{sx:{color:i.palette.common.white,fontSize:12,fontWeight:700,fontFamily:"monospace"},children:h.valor})]})}),!f&&n.jsx(c.Typography,{sx:{mt:1,fontSize:12,color:d.ejeTexto,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:h.clave})]},h.clave)})});return a?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${i.palette.divider}`,bgcolor:i.palette.background.paper,boxShadow:i.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),y]}):y},_e={arriba:8,derecha:8,abajo:24},ha=({categorias:e,series:r,orientacion:t="vertical",titulo:o,subtitulo:a,alto:i=288,conCuadricula:d=!0,conLeyenda:f=!0,conPapel:y=!0})=>{const h=pe(),v=ce(),u=t==="horizontal",x=(w,j)=>w.color?v.color(w.color):v.serie(j),m=ne.useMemo(()=>{const w=e.map((A,k)=>r.reduce((W,z)=>W+(z.valores[k]??0),0)),j=le.max(w)??0,b=oe.scaleBand().domain(e).range([0,100]).padding(.3),g=oe.scaleLinear().domain([0,j===0?1:j]).range(u?[0,100]:[100,0]),S=e.map(()=>0),B=[];r.forEach((A,k)=>{e.forEach((W,z)=>{const N=A.valores[z]??0,I=S[z],U=I+N;S[z]=U,B.push({indiceSerie:k,indiceCategoria:z,clave:W,nombre:A.nombre,valor:N,relleno:x(A,k),inicio:g(I),fin:g(U),bandaInicio:b(W)??0,bandaGrosor:b.bandwidth()})})});const _=g.ticks(5),M=_.map(A=>g(A)),Y=_.map(A=>({posicion:g(A),texto:String(A)})),P=e.map(A=>({posicion:(b(A)??0)+b.bandwidth()/2,texto:A})),l=e.reduce((A,k)=>Math.max(A,k.length),1);return{segmentos:B,posicionesCuadricula:M,marcasValorEje:Y,marcasCategoria:P,margenCategoria:u?Math.min(l*7,110):28}},[e,r,u]),p=m.margenCategoria,s=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:i},children:[n.jsxs(c.Box,{sx:{position:"absolute",inset:0,zIndex:1,height:`calc(100% - ${_e.arriba}px - ${_e.abajo}px)`,width:`calc(100% - ${p}px - ${_e.derecha}px)`,transform:`translate(${p}px, ${_e.arriba}px)`,overflow:"visible"},children:[d&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:m.posicionesCuadricula,orientacion:u?"vertical":"horizontal"})}),m.segmentos.map(w=>{const j=Math.abs(w.fin-w.inicio);return n.jsx(c.Tooltip,{arrow:!0,placement:u?"top":"right",title:n.jsxs(c.Box,{children:[n.jsxs(c.Typography,{variant:"caption",sx:{opacity:.7},children:[w.nombre," · ",w.clave]}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:w.valor.toLocaleString("es-ES")})]}),children:n.jsx(c.Box,{sx:{position:"absolute",background:w.relleno,...u?{left:`${Math.min(w.inicio,w.fin)}%`,top:`${w.bandaInicio}%`,width:`${j}%`,height:`${w.bandaGrosor}%`}:{left:`${w.bandaInicio}%`,top:`${Math.min(w.inicio,w.fin)}%`,width:`${w.bandaGrosor}%`,height:`${j}%`}}})},`${w.indiceSerie}-${w.indiceCategoria}`)})]}),n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${_e.arriba}px - ${_e.abajo}px)`,width:`${p}px`,transform:`translateY(${_e.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:u?m.marcasCategoria:m.marcasValorEje})}),n.jsx(c.Box,{sx:{position:"absolute",bottom:0,left:`${p}px`,right:`${_e.derecha}px`,height:`${_e.abajo}px`,overflow:"visible"},children:n.jsx(Ar,{marcas:u?m.marcasValorEje:m.marcasCategoria})})]}),$=f&&n.jsx(c.Stack,{direction:"row",flexWrap:"wrap",gap:1.5,sx:{mb:1.5},children:r.map((w,j)=>n.jsxs(c.Stack,{direction:"row",spacing:.75,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"3px",bgcolor:x(w,j),flexShrink:0}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:w.nombre})]},w.nombre))}),E=n.jsxs(n.Fragment,{children:[$,s]});return y?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${h.palette.divider}`,bgcolor:h.palette.background.paper,boxShadow:h.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),E]}):E},ve={arriba:12,derecha:8,abajo:28,izquierda:28},wt=1.5,ma=({categorias:e,series:r,orientacion:t="vertical",titulo:o,subtitulo:a,alto:i=288,conCuadricula:d=!0,conLeyenda:f=!0,conPapel:y=!0})=>{const h=pe(),v=ce(),u=t==="horizontal",x=ne.useMemo(()=>{const w=r.length===0?1:r.length,j=oe.scaleBand().domain(e).range([0,100]).padding(.3),b=le.max(r.flatMap(P=>P.valores))??0,g=oe.scaleLinear().domain([0,b===0?1:b]).range(u?[0,100]:[100,0]),S=g.ticks(6),B=S.map(P=>g(P)),_=j.bandwidth(),M=(_-wt*(w-1))/w,Y=e.reduce((P,l)=>Math.max(P,l.length),1);return{escalaCategoria:j,escalaValor:g,marcasValor:S,posicionesCuadricula:B,grosorGrupo:_,grosorSubBarra:M,totalSeries:w,margenCategoria:u?Math.min(Y*7,120):ve.izquierda}},[e,r,u]),m=(w,j)=>w.color?v.color(w.color):v.serie(j),p=u?x.margenCategoria:ve.izquierda,s=e.flatMap((w,j)=>{const b=x.escalaCategoria(w)??0;return r.map((g,S)=>{const B=g.valores[j]??0,_=S*(x.grosorSubBarra+wt),M=u?x.escalaValor(B):100-x.escalaValor(B),Y=n.jsx(c.Box,{sx:{position:"absolute",background:m(g,S),...u?{left:0,top:`${b+_}%`,width:`${M}%`,height:`${x.grosorSubBarra}%`,borderRadius:"0 4px 4px 0"}:{bottom:0,left:`${b+_}%`,width:`${x.grosorSubBarra}%`,height:`${M}%`,borderRadius:"4px 4px 0 0"}}});return n.jsx(c.Tooltip,{arrow:!0,placement:u?"right":"top",title:n.jsxs(c.Box,{children:[n.jsxs(c.Typography,{variant:"caption",sx:{opacity:.7},children:[g.nombre," · ",w]}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:B.toLocaleString("es-ES")})]}),children:Y},`${w}-${g.nombre}`)})}),$=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:i},children:[n.jsxs(c.Box,{sx:{position:"absolute",inset:0,zIndex:1,height:`calc(100% - ${ve.arriba}px - ${ve.abajo}px)`,width:`calc(100% - ${p}px - ${ve.derecha}px)`,transform:`translate(${p}px, ${ve.arriba}px)`,overflow:"visible"},children:[d&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:x.posicionesCuadricula,orientacion:u?"vertical":"horizontal"})}),s,x.marcasValor.map((w,j)=>n.jsx(c.Box,{sx:{position:"absolute",color:v.ejeTexto,fontSize:12,fontVariantNumeric:"tabular-nums",...u?{left:`${x.escalaValor(w)}%`,top:"100%",transform:"translateX(-50%)",pt:.5}:{top:`${x.escalaValor(w)}%`,right:"100%",transform:"translateY(-50%)",pr:1}},children:w},j))]}),n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${ve.arriba}px - ${ve.abajo}px)`,transform:`translateY(${ve.arriba}px)`,overflow:"visible",...u?{width:`${p}px`}:{top:"auto",bottom:0,height:`${ve.abajo}px`,transform:"none",left:`${p}px`,right:`${ve.derecha}px`}},children:e.map(w=>{const j=(x.escalaCategoria(w)??0)+x.escalaCategoria.bandwidth()/2;return n.jsx(c.Box,{sx:{position:"absolute",color:v.ejeTexto,fontSize:12,whiteSpace:"nowrap",...u?{top:`${j}%`,right:h.spacing(1),transform:"translateY(-50%)"}:{left:`${j}%`,top:4,transform:"translateX(-50%)"}},children:w},w)})})]}),E=n.jsxs(c.Box,{children:[f&&n.jsx(c.Stack,{direction:"row",spacing:2,flexWrap:"wrap",sx:{mb:1.5},children:r.map((w,j)=>n.jsxs(c.Stack,{direction:"row",spacing:.75,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"3px",bgcolor:m(w,j)}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:w.nombre})]},w.nombre))}),$]});return y?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${h.palette.divider}`,bgcolor:h.palette.background.paper,boxShadow:h.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),E]}):E},xa=({datos:e,indiceDestacado:r=0,titulo:t,subtitulo:o,conPapel:a=!0})=>{const i=pe(),d=ce(),f=e.reduce((h,v)=>Math.max(h,v.valor),0),y=n.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",gap:2,width:"100%"},children:e.map((h,v)=>{const u=v===r,x=f===0?0:h.valor/f*100,m=u?`linear-gradient(90deg, ${d.color("exito")}, ${d.color("info")})`:`linear-gradient(90deg, ${d.ejeTexto}, ${d.cuadricula})`;return n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"body2",sx:{mb:.75,fontWeight:u?700:500,color:u?d.color("exito"):d.ejeTexto},children:h.clave}),n.jsxs(c.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[n.jsx(c.Box,{sx:{position:"relative",flexGrow:1,height:12,borderRadius:1,overflow:"hidden",bgcolor:i.palette.action.hover},children:n.jsx(c.Box,{sx:{position:"absolute",insetBlock:0,left:0,width:`${x}%`,borderRadius:1,background:m,transformOrigin:"left center",animation:`${Xt} 0.6s ease-out ${v*.08}s both`}})}),n.jsx(c.Typography,{variant:"body2",sx:{fontVariantNumeric:"tabular-nums",fontWeight:u?700:500,color:u?d.color("info"):d.ejeTexto,minWidth:40,textAlign:"right"},children:h.valor})]})]},h.clave)})});return a?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${i.palette.divider}`,bgcolor:i.palette.background.paper,boxShadow:i.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),y]}):y},Te={arriba:12,derecha:8,abajo:44,izquierda:28},ga=({datos:e,colorPositivo:r="exito",colorNegativo:t="error",titulo:o,subtitulo:a,alto:i=288,conCuadricula:d=!0,conTooltip:f=!0,conPapel:y=!0})=>{const h=pe(),v=ce(),u=ne.useMemo(()=>{const p=e.map(B=>B.clave),s=e.map(B=>B.valor),$=Math.min(0,le.min(s)??0),E=Math.max(0,le.max(s)??0),w=oe.scaleBand().domain(p).range([0,100]).padding(.3),j=oe.scaleLinear().domain([$,E===$?$+1:E]).range([100,0]),b=j(0),g=j.ticks(6),S=g.map(B=>j(B));return{claves:p,escalaCategoria:w,escalaValor:j,cero:b,marcasValor:g,posicionesCuadricula:S}},[e]),x=p=>{const s=v.color(p?r:t);return`linear-gradient(180deg, ${s}, ${s}bb)`},m=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:i},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Te.arriba}px - ${Te.abajo}px)`,width:`${Te.izquierda}px`,transform:`translateY(${Te.arriba}px)`,overflow:"visible"},children:u.marcasValor.map((p,s)=>n.jsx(c.Box,{sx:{position:"absolute",top:`${u.escalaValor(p)}%`,left:0,width:"100%",pr:1,textAlign:"right",transform:"translateY(-50%)",fontSize:12,fontVariantNumeric:"tabular-nums",color:v.ejeTexto},children:p},s))}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Te.arriba}px - ${Te.abajo}px)`,width:`calc(100% - ${Te.izquierda}px - ${Te.derecha}px)`,transform:`translate(${Te.izquierda}px, ${Te.arriba}px)`,overflow:"visible"},children:[d&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:u.posicionesCuadricula,orientacion:"horizontal"})}),e.map((p,s)=>{const $=p.valor>=0,E=u.escalaCategoria(p.clave)??0,w=u.escalaCategoria.bandwidth(),j=u.escalaValor(p.valor),b=$?j:u.cero,g=Math.abs(j-u.cero),S=n.jsx(c.Box,{sx:{position:"absolute",left:`${E}%`,top:`${b}%`,width:`${w}%`,height:`${g}%`,borderRadius:$?"4px 4px 0 0":"0 0 4px 4px",background:x($),transformOrigin:$?"bottom center":"top center",animation:`${Ht} 0.5s ease-out ${s*.05}s both`}});return f?n.jsx(c.Tooltip,{arrow:!0,placement:"top",title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:p.clave}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:p.valor.toLocaleString("es-ES")})]}),children:S},p.clave):n.jsx(c.Box,{children:S},p.clave)}),n.jsx(c.Box,{sx:{position:"absolute",left:0,right:0,top:`${u.cero}%`,borderTop:`1.5px solid ${v.ejeTexto}`,opacity:.6,pointerEvents:"none"}}),e.map(p=>{const s=(u.escalaCategoria(p.clave)??0)+u.escalaCategoria.bandwidth()/2;return n.jsx(c.Box,{sx:{position:"absolute",left:`${s}%`,top:"100%",transform:"rotate(45deg) translate(4px, 8px)",transformOrigin:"left top",fontSize:12,whiteSpace:"nowrap",color:v.ejeTexto},children:p.clave},`etq-${p.clave}`)})]})]});return y?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${h.palette.divider}`,bgcolor:h.palette.background.paper,boxShadow:h.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),m]}):m},he={arriba:8,derecha:30,abajo:28,izquierda:30},ya=({datos:e,colorBarra:r="secundario",colorLinea:t="error",titulo:o,subtitulo:a,alto:i=288,conPapel:d=!0})=>{const f=pe(),y=ce(),h=y.color(r),v=y.color(t),u=ne.useMemo(()=>{const m=e.map(g=>g.clave),p=oe.scaleBand().domain(m).range([0,100]).padding(.3),s=le.max(e,g=>g.barra)??0,$=oe.scaleLinear().domain([0,s===0?1:s]).range([100,0]),E=le.min(e,g=>g.linea)??0,w=le.max(e,g=>g.linea)??0,j=oe.scaleLinear().domain([E,w===E?E+1:w]).range([100,0]),b=ue.line().x(g=>(p(g.clave)??0)+p.bandwidth()/2).y(g=>j(g.linea)).curve(ue.curveMonotoneX);return{escalaX:p,escalaBarra:$,escalaLinea:j,trazo:b(e)??"",marcasBarra:$.ticks(6),marcasLinea:j.ticks(6)}},[e]),x=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:i},children:[n.jsx(c.Box,{sx:{position:"absolute",height:`calc(100% - ${he.arriba}px - ${he.abajo}px)`,width:`${he.izquierda}px`,left:0,transform:`translateY(${he.arriba}px)`,overflow:"visible"},children:u.marcasBarra.map((m,p)=>n.jsx(c.Box,{sx:{position:"absolute",top:`${u.escalaBarra(m)}%`,right:0,width:"100%",pr:.5,textAlign:"right",transform:"translateY(-50%)",fontSize:11,fontVariantNumeric:"tabular-nums",color:h},children:m},p))}),n.jsx(c.Box,{sx:{position:"absolute",height:`calc(100% - ${he.arriba}px - ${he.abajo}px)`,width:`${he.derecha}px`,right:0,transform:`translateY(${he.arriba}px)`,overflow:"visible"},children:u.marcasLinea.map((m,p)=>n.jsx(c.Box,{sx:{position:"absolute",top:`${u.escalaLinea(m)}%`,left:0,width:"100%",pl:.5,transform:"translateY(-50%)",fontSize:11,fontVariantNumeric:"tabular-nums",color:v},children:m},p))}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${he.arriba}px - ${he.abajo}px)`,width:`calc(100% - ${he.izquierda}px - ${he.derecha}px)`,transform:`translate(${he.izquierda}px, ${he.arriba}px)`,overflow:"visible"},children:[e.map(m=>{const p=u.escalaX(m.clave)??0,s=u.escalaX.bandwidth(),$=100-u.escalaBarra(m.barra);return n.jsx(c.Box,{sx:{position:"absolute",left:`${p}%`,bottom:0,width:`${s}%`,height:`${$}%`,borderRadius:"6px 6px 0 0",background:`linear-gradient(180deg, ${h}, ${h}99)`}},m.clave)}),n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},children:n.jsx("path",{d:u.trazo,fill:"none",stroke:v,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})}),n.jsx(c.Box,{sx:{position:"absolute",inset:0},children:e.map(m=>{const p=(u.escalaX(m.clave)??0)+u.escalaX.bandwidth()/2;return n.jsx(c.Box,{sx:{position:"absolute",left:`${p}%`,top:"100%",transform:"translateX(-50%)",pt:.5,fontSize:11,color:y.ejeTexto,whiteSpace:"nowrap"},children:m.clave},m.clave)})})]})]});return d?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${f.palette.divider}`,bgcolor:f.palette.background.paper,boxShadow:f.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),x]}):x},Ce={arriba:8,derecha:8,abajo:25,izquierda:32},ba=({datos:e,titulo:r,subtitulo:t,alto:o=288,conCuadricula:a=!0,conTooltip:i=!0,conPapel:d=!0})=>{const f=pe(),y=ce(),h=ne.useMemo(()=>{const u=e.map(j=>j.etiqueta),x=le.min(e,j=>j.minimo)??0,m=le.max(e,j=>j.maximo)??0,p=(m-x)*.05,s=oe.scaleBand().domain(u).range([0,100]).padding(.35),$=oe.scaleLinear().domain([x-p,m+p]).range([100,0]),E=$.ticks(6).map(j=>({posicion:$(j),texto:String(j)})),w=$.ticks(6).map(j=>$(j));return{escalaX:s,escalaY:$,marcasY:E,posicionesCuadricula:w}},[e]),v=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:o},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Ce.arriba}px - ${Ce.abajo}px)`,width:`${Ce.izquierda}px`,transform:`translateY(${Ce.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:h.marcasY})}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Ce.arriba}px - ${Ce.abajo}px)`,width:`calc(100% - ${Ce.izquierda}px - ${Ce.derecha}px)`,transform:`translate(${Ce.izquierda}px, ${Ce.arriba}px)`,overflow:"visible"},children:[a&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:h.posicionesCuadricula})}),e.map(u=>{const x=h.escalaX(u.etiqueta)??0,m=h.escalaX.bandwidth(),s=u.cierre>=u.apertura?y.color("exito"):y.color("error"),$=h.escalaY(u.maximo),E=h.escalaY(u.minimo)-$,w=h.escalaY(Math.max(u.apertura,u.cierre)),j=h.escalaY(Math.min(u.apertura,u.cierre))-w,b=n.jsxs(c.Box,{sx:{position:"absolute",left:`${x}%`,width:`${m}%`,top:0,height:"100%"},children:[n.jsx(c.Box,{sx:{position:"absolute",left:"50%",transform:"translateX(-50%)",width:"2px",top:`${$}%`,height:`${E}%`,backgroundColor:s}}),n.jsx(c.Box,{sx:{position:"absolute",left:0,width:"100%",top:`${w}%`,height:`${j}%`,minHeight:"1px",borderRadius:"2px",backgroundColor:s}})]});return i?n.jsx(c.Tooltip,{arrow:!0,placement:"top",title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:u.etiqueta}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,children:["A ",u.apertura," · M ",u.maximo," · m ",u.minimo," · C"," ",u.cierre]})]}),children:b},u.etiqueta):n.jsx(c.Box,{children:b},u.etiqueta)})]})]});return d?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${f.palette.divider}`,bgcolor:f.palette.background.paper,boxShadow:f.shadows[1]},children:[(r||t)&&n.jsxs(c.Box,{sx:{mb:2},children:[r&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:r}),t&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:t})]}),v]}):v},We={arriba:10,derecha:36,abajo:24},va=({datos:e,color:r="primario",titulo:t,subtitulo:o,alto:a=288,conCuadricula:i=!0,conTooltip:d=!0,conPapel:f=!0})=>{const y=pe(),h=ce(),v=ne.useMemo(()=>{const m=e.map(S=>S.clave),p=le.max(e,S=>S.valor)??0,s=oe.scaleBand().domain(m).range([0,100]).padding(.5),$=oe.scaleLinear().domain([0,p===0?1:p]).range([0,100]),E=e.map(S=>({dato:S,x:$(S.valor),y:(s(S.clave)??0)+s.bandwidth()/2})),w=E.map((S,B)=>`${B===0?"M":"L"} ${S.x} ${S.y}`).join(" "),j=$.ticks(5),b=j.map(S=>$(S)),g=m.reduce((S,B)=>Math.max(S,B.length),1);return{puntos:E,trazo:w,marcasValor:j,escalaValor:$,posicionesCuadricula:b,margenIzquierda:Math.min(g*7,120)}},[e]),u=h.color(r),x=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:a},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${We.arriba}px - ${We.abajo}px)`,width:`${v.margenIzquierda}px`,transform:`translateY(${We.arriba}px)`,overflow:"visible"},children:v.puntos.map(m=>n.jsx(c.Box,{sx:{position:"absolute",top:`${m.y}%`,right:y.spacing(1),transform:"translateY(-50%)",fontSize:12,whiteSpace:"nowrap",color:h.ejeTexto},children:m.dato.clave},m.dato.clave))}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${We.arriba}px - ${We.abajo}px)`,width:`calc(100% - ${v.margenIzquierda}px - ${We.derecha}px)`,transform:`translate(${v.margenIzquierda}px, ${We.arriba}px)`,overflow:"visible"},children:[n.jsxs(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{width:"100%",height:"100%",overflow:"visible"},children:[i&&n.jsx(Re,{posiciones:v.posicionesCuadricula,orientacion:"vertical"}),n.jsx("path",{d:v.trazo,fill:"none",stroke:u,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"}),v.puntos.map(m=>{const p=m.dato.color?h.color(m.dato.color):u,s=n.jsxs(n.Fragment,{children:[n.jsx("path",{d:`M ${m.x} ${m.y} l 0.0001 0`,stroke:p,strokeWidth:9,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),n.jsx("path",{d:`M ${m.x} ${m.y} l 0.0001 0`,stroke:"transparent",strokeWidth:18,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"})]});return d?n.jsxs(ir,{children:[n.jsx(Ke,{children:s}),n.jsxs(sr,{children:[n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:m.dato.clave}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,color:"text.primary",children:m.dato.valor.toLocaleString("es-ES")})]})]},m.dato.clave):n.jsx("g",{children:s},m.dato.clave)})]}),v.puntos.map(m=>n.jsx(c.Box,{sx:{position:"absolute",left:`${m.x}%`,top:`${m.y}%`,transform:"translate(8px, -50%)",fontSize:12,fontWeight:500,fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap",pointerEvents:"none",color:h.ejeTexto},children:m.dato.valor},`valor-${m.dato.clave}`)),v.marcasValor.map((m,p)=>n.jsx(c.Box,{sx:{position:"absolute",left:`${v.escalaValor(m)}%`,top:"100%",transform:"translateX(-50%)",pt:.5,fontSize:12,fontVariantNumeric:"tabular-nums",color:h.ejeTexto},children:m},p))]})]});return f?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${y.palette.divider}`,bgcolor:y.palette.background.paper,boxShadow:y.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),x]}):x},St=20,ge=100,$a=({datos:e,variante:r="dona",titulo:t,subtitulo:o,alto:a=288,valorCentral:i,etiquetaCentral:d,etiquetasEnPorciones:f=!1,gradiente:y=!1,conTooltip:h=!0,conLeyenda:v=!0,conPapel:u=!0})=>{const x=pe(),m=ce(),p=ne.useId().replace(/:/g,""),s=r==="media-dona",$=ne.useMemo(()=>{const b=ue.pie().value(P=>P.valor).sort(null).startAngle(s?-Math.PI/2:0).endAngle(s?Math.PI/2:2*Math.PI),g=r==="pastel"?0:ge*.6,S=ue.arc().innerRadius(g).outerRadius(ge).cornerRadius(r==="pastel"?0:3).padAngle(.012),B=r==="pastel"?ge*.62:(g+ge)/2,_=ue.arc().innerRadius(B).outerRadius(B),M=e.reduce((P,l)=>P+l.valor,0);return{segmentos:b(e).map(P=>({arco:P,ruta:S(P)??"",centroide:_.centroid(P),angulo:(P.endAngle-P.startAngle)*180/Math.PI,porcentaje:M===0?0:P.data.valor/M*100})),total:M}},[e,r,s]),E=(b,g)=>b.color?m.color(b.color):m.serie(g),w=s?`-${ge+16} -${ge+16} ${2*ge+32} ${ge+24}`:`-${ge+16} -${ge+16} ${2*ge+32} ${2*ge+32}`,j=n.jsxs(c.Stack,{direction:{xs:"column",sm:v?"row":"column"},spacing:2,alignItems:"center",justifyContent:"center",sx:{width:"100%",height:a},children:[n.jsxs(c.Box,{sx:{position:"relative",height:"100%",flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:[n.jsxs(c.Box,{component:"svg",viewBox:w,sx:{width:"100%",height:"100%",maxHeight:a,overflow:"visible"},children:[y&&n.jsx("defs",{children:$.segmentos.map((b,g)=>{const S=E(b.arco.data,g);return n.jsxs("linearGradient",{id:`${p}-${g}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[n.jsx("stop",{offset:"0%",stopColor:S,stopOpacity:1}),n.jsx("stop",{offset:"100%",stopColor:S,stopOpacity:.55})]},`grad-${b.arco.data.clave}`)})}),$.segmentos.map((b,g)=>{const S=y?`url(#${p}-${g})`:E(b.arco.data,g),B=n.jsx("path",{d:b.ruta,fill:S,stroke:m.superficie,strokeWidth:1.5});return h?n.jsxs(ir,{children:[n.jsx(Ke,{children:B}),n.jsxs(sr,{children:[n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:b.arco.data.clave}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,color:"text.primary",children:[b.arco.data.valor.toLocaleString("es-ES")," ·"," ",b.porcentaje.toFixed(1),"%"]})]})]},b.arco.data.clave):n.jsx("g",{children:B},b.arco.data.clave)}),f&&$.segmentos.map(b=>{if(b.angulo<=St)return null;const[g,S]=b.centroide;return n.jsxs("text",{transform:`translate(${g},${S})`,textAnchor:"middle",pointerEvents:"none",fill:x.palette.common.white,fontSize:8,fontWeight:600,children:[n.jsx("tspan",{x:0,y:"-0.3em",children:b.arco.data.clave}),n.jsx("tspan",{x:0,y:"1em",fontWeight:400,fillOpacity:.85,children:b.arco.data.valor.toLocaleString("es-ES")})]},`etq-${b.arco.data.clave}`)}),$.segmentos.map(b=>{const g=b.arco.data.icono;if(!g||b.angulo<=St)return null;const[S,B]=b.centroide,_=30;return n.jsx("foreignObject",{x:S-_/2,y:B-_/2,width:_,height:_,pointerEvents:"none",children:n.jsx(c.Box,{sx:{width:"100%",height:"100%",borderRadius:"50%",overflow:"hidden","& img, & svg":{width:"100%",height:"100%"}},children:g})},`ico-${b.arco.data.clave}`)})]}),(i!==void 0||d)&&r!=="pastel"&&n.jsxs(c.Box,{sx:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",pointerEvents:"none",pb:s?0:void 0},children:[i!==void 0&&n.jsx(c.Typography,{variant:"h5",fontWeight:800,color:"text.primary",children:i}),d&&n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:d})]})]}),v&&n.jsx(c.Stack,{spacing:1,sx:{minWidth:120},children:e.map((b,g)=>n.jsxs(c.Stack,{direction:"row",spacing:1,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"3px",bgcolor:E(b,g),flexShrink:0}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:b.clave})]},b.clave))})]});return u?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${x.palette.divider}`,bgcolor:x.palette.background.paper,boxShadow:x.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),j]}):j},Ee=100,wa=({valor:e,variante:r="completo",color:t="secundario",etiqueta:o,alto:a=240,conPapel:i=!0})=>{const d=pe(),f=ce(),y=r==="medio",h=Math.max(0,Math.min(100,e)),v=d.palette.mode==="dark"?d.palette.grey[800]:d.palette.grey[200],u=ne.useMemo(()=>{const p=ue.pie().value($=>$.valor).sort(null).padAngle(0).startAngle(y?-Math.PI/2:0).endAngle(y?Math.PI/2:2*Math.PI),s=ue.arc().innerRadius(Ee*.62).outerRadius(Ee).cornerRadius(4);return p([{valor:h},{valor:100-h}]).map($=>({arco:$,ruta:s($)??""}))},[h,y]),x=y?`-${Ee+12} -${Ee+12} ${2*Ee+24} ${Ee+24}`:`-${Ee+12} -${Ee+12} ${2*Ee+24} ${2*Ee+24}`,m=n.jsxs(c.Box,{sx:{position:"relative",height:a,display:"flex",alignItems:"center",justifyContent:"center"},children:[n.jsx(c.Box,{component:"svg",viewBox:x,sx:{width:"100%",height:"100%",maxHeight:a,overflow:"visible"},children:u.map((p,s)=>n.jsx("path",{d:p.ruta,fill:s===0?f.color(t):v},s))}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",pointerEvents:"none",transform:y?"translateY(28%)":"none"},children:[n.jsxs(c.Typography,{variant:"h4",fontWeight:800,color:"text.primary",lineHeight:1.1,children:[h,"%"]}),o&&n.jsx(c.Typography,{variant:"body2",color:"text.secondary",children:o})]})]});return i?n.jsx(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${d.palette.divider}`,bgcolor:d.palette.background.paper,boxShadow:d.shadows[1]},children:m}):m},ke={arriba:6,derecha:8,abajo:25,izquierda:28},jt={lineal:ue.curveLinear,suave:ue.curveMonotoneX,escalon:ue.curveStep},Sa=(e,r)=>e instanceof Date?e.toLocaleDateString("es-ES",r?{month:"short",year:"2-digit"}:{day:"2-digit",month:"short"}):String(e),ja=({series:e,datos:r,titulo:t,subtitulo:o,alto:a=288,curva:i="suave",color:d,colorLinea:f,gradiente:y=!0,contorno:h=!1,apilado:v=!1,conCuadricula:u=!0,conPapel:x=!0})=>{const m=pe(),p=ce(),s=ne.useMemo(()=>e&&e.length>0?e:r&&r.length>0?[{nombre:t??"Serie",datos:r,color:d}]:[],[e,r,t,d]),$=ne.useMemo(()=>{const w=s[0]?.datos.map(I=>I.etiqueta)??[],j=w.map(()=>0),b=v?Math.max(...w.map((I,U)=>s.reduce((C,O)=>C+(O.datos[U]?.valor??0),0)),1):le.max(s.flatMap(I=>I.datos.map(U=>U.valor)))??1,g=oe.scaleLinear().domain([0,b]).range([100,0]),S=w[0];let B;if(S instanceof Date){const I=w.filter(C=>C instanceof Date),U=oe.scaleTime().domain(le.extent(I)).range([0,100]);B=C=>U(C)}else if(typeof S=="number"){const I=w,U=oe.scaleLinear().domain([le.min(I)??0,le.max(I)??0]).range([0,100]);B=C=>U(C)}else{const I=w.map(C=>String(C)),U=oe.scalePoint().domain(I).range([0,100]);B=C=>U(String(C))??0}const _=s.map(I=>{const U=I.datos.map((D,V)=>{const L=v?j[V]:0,F=L+D.valor;return v&&(j[V]=F),{etiqueta:D.etiqueta,base:L,total:F}}),C=ue.area().x(D=>B(D.etiqueta)).y0(D=>g(D.base)).y1(D=>g(D.total)).curve(jt[i]),O=ue.line().x(D=>B(D.etiqueta)).y(D=>g(D.total)).curve(jt[i]);return{area:C(U)??"",linea:O(U)??""}}),M=g.ticks(5).map(I=>({posicion:g(I),texto:String(I)})),Y=g.ticks(5).map(I=>g(I)),P=w.length,l=Math.min(5,P),A=Array.from(new Set(l<=1?[0]:Array.from({length:l},(I,U)=>Math.round(U*(P-1)/(l-1))))).filter(I=>I>=0&&I<P),k=w[0],W=w[P-1],z=k instanceof Date&&W instanceof Date&&k.getFullYear()!==W.getFullYear(),N=A.map((I,U)=>({posicion:B(w[I]),texto:Sa(w[I],z),anclaje:U===0?"inicio":U===A.length-1?"fin":"centro"}));return{capas:_,marcasY:M,marcasX:N,posicionesCuadricula:Y}},[s,i,v]),E=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:a},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${ke.arriba}px - ${ke.abajo}px)`,width:`${ke.izquierda}px`,transform:`translateY(${ke.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:$.marcasY})}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${ke.arriba}px - ${ke.abajo}px)`,width:`calc(100% - ${ke.izquierda}px - ${ke.derecha}px)`,transform:`translate(${ke.izquierda}px, ${ke.arriba}px)`,overflow:"visible"},children:[n.jsxs(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{width:"100%",height:"100%",overflow:"visible"},children:[n.jsx("defs",{children:s.map((w,j)=>{const b=w.color?p.color(w.color):d?p.color(d):p.serie(j);return n.jsxs("linearGradient",{id:`codeplex-area-${j}`,x1:"0",x2:"0",y1:"0",y2:"1",children:[n.jsx("stop",{offset:"0%",stopColor:b,stopOpacity:.45}),n.jsx("stop",{offset:"100%",stopColor:b,stopOpacity:.02})]},w.nombre)})}),u&&n.jsx(Re,{posiciones:$.posicionesCuadricula}),$.capas.map((w,j)=>{const b=s[j],g=b.color?p.color(b.color):d?p.color(d):p.serie(j),S=f?p.color(f):g,B=h?g:y?`url(#codeplex-area-${j})`:g,_=h?.12:y?1:.35;return n.jsxs("g",{children:[n.jsx("path",{d:w.area,fill:B,fillOpacity:_}),n.jsx("path",{d:w.linea,fill:"none",stroke:S,strokeWidth:h?2.5:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},b.nombre)})]}),n.jsx(c.Box,{sx:{position:"relative",mt:1},children:n.jsx(Ar,{marcas:$.marcasX})})]})]});return x?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${m.palette.divider}`,bgcolor:m.palette.background.paper,boxShadow:m.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),E]}):E},Be={arriba:8,derecha:8,abajo:28,izquierda:32},Ta=({datos:e,series:r,titulo:t,subtitulo:o,alto:a=288,color:i,conCuadricula:d=!0,conTooltip:f=!0,conLeyenda:y=!0,conPapel:h=!0})=>{const v=pe(),u=ce(),x=ne.useMemo(()=>r&&r.length>0?r.map((w,j)=>({nombre:w.nombre,color:w.color,puntos:w.puntos,indice:j})):[{color:i,puntos:e??[],indice:0}],[r,e,i]),m=y&&!!(r&&r.length>0),p=(w,j)=>w.color?u.color(w.color):j.color?u.color(j.color):u.serie(j.indice),s=ne.useMemo(()=>{const w=x.flatMap(l=>l.puntos),j=le.extent(w,l=>l.x),b=le.extent(w,l=>l.y),g=oe.scaleLinear().domain([j[0]??0,j[1]??0]).nice().range([0,100]),S=oe.scaleLinear().domain([b[0]??0,b[1]??0]).nice().range([100,0]),B=S.ticks(5).map(l=>({posicion:S(l),texto:String(l)})),_=g.ticks(5).map(l=>({posicion:g(l),texto:String(l)})),M=S.ticks(5).map(l=>S(l)),Y=g.ticks(5).map(l=>g(l)),P=w.some(l=>l.icono);return{escalaX:g,escalaY:S,marcasY:B,marcasX:_,posicionesCuadriculaY:M,posicionesCuadriculaX:Y,tieneIconos:P}},[x]),$=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:a},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Be.arriba}px - ${Be.abajo}px)`,width:`${Be.izquierda}px`,transform:`translateY(${Be.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:s.marcasY})}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Be.arriba}px - ${Be.abajo}px)`,width:`calc(100% - ${Be.izquierda}px - ${Be.derecha}px)`,transform:`translate(${Be.izquierda}px, ${Be.arriba}px)`,overflow:"visible"},children:[n.jsxs(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{width:"100%",height:"100%",overflow:"visible"},children:[d&&n.jsxs(n.Fragment,{children:[n.jsx(Re,{posiciones:s.posicionesCuadriculaY}),n.jsx(Re,{posiciones:s.posicionesCuadriculaX,orientacion:"vertical"})]}),x.flatMap(w=>w.puntos.map((j,b)=>{const g=s.escalaX(j.x),S=s.escalaY(j.y),B=p(j,w),_=`${w.indice}-${b}`,M=n.jsxs(n.Fragment,{children:[!j.icono&&n.jsx("path",{d:`M ${g} ${S} l 0.0001 0`,stroke:B,strokeWidth:9,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke",opacity:.85}),n.jsx("path",{d:`M ${g} ${S} l 0.0001 0`,stroke:"transparent",strokeWidth:18,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"})]});return f?n.jsxs(ir,{children:[n.jsx(Ke,{children:M}),n.jsxs(sr,{children:[(j.etiqueta||w.nombre)&&n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:j.etiqueta??w.nombre}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,color:"text.primary",children:["x: ",j.x.toLocaleString("es-ES")," · y:"," ",j.y.toLocaleString("es-ES")]})]})]},_):n.jsx("g",{children:M},_)}))]}),s.tieneIconos&&n.jsx(c.Box,{sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:x.flatMap(w=>w.puntos.map((j,b)=>{if(!j.icono)return null;const g=s.escalaX(j.x),S=s.escalaY(j.y);return n.jsx(c.Box,{sx:{position:"absolute",left:`${g}%`,top:`${S}%`,transform:"translate(-50%, -50%)",width:28,height:28,borderRadius:"50%",overflow:"hidden","& img, & svg":{width:"100%",height:"100%"}},children:j.icono},`logo-${w.indice}-${b}`)}))}),n.jsx(c.Box,{sx:{position:"relative",mt:1},children:n.jsx(Ar,{marcas:s.marcasX})})]})]}),E=m?n.jsxs(c.Box,{children:[n.jsx(c.Stack,{direction:"row",spacing:2,flexWrap:"wrap",sx:{mb:1.5},children:x.map(w=>n.jsxs(c.Stack,{direction:"row",spacing:.75,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:w.color?u.color(w.color):u.serie(w.indice),flexShrink:0}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:w.nombre})]},w.indice))}),$]}):$;return h?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${v.palette.divider}`,bgcolor:v.palette.background.paper,boxShadow:v.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),E]}):E},Tt=15,Ca=({datos:e,variante:r="solido",alto:t=280,titulo:o,subtitulo:a,conPapel:i=!0})=>{const d=pe(),f=ce(),y=ne.useMemo(()=>{const u={name:"root",children:e.map((p,s)=>({name:p.grupo,indiceGrupo:s,children:p.items.map($=>({name:$.nombre,valor:$.valor,icono:$.icono}))}))},x=hr.hierarchy(u).sum(p=>p.valor??0).sort((p,s)=>(s.value??0)-(p.value??0));return hr.treemap().size([100,100]).paddingInner(.75).paddingOuter(1).round(!1)(x).leaves()},[e]),h=u=>{const x=u.parent?.data.indiceGrupo??0,m=e[x];return m?.color?f.color(m.color):f.serie(x)},v=n.jsx(c.Box,{sx:{position:"relative",width:"100%",height:t},children:y.map((u,x)=>{const m=u.x1-u.x0,p=u.y1-u.y0,s=h(u),$=m>Tt&&p>Tt,E=r==="gradiente"?`linear-gradient(180deg, ${s}, ${s}bb)`:s;return n.jsx(c.Tooltip,{arrow:!0,title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:u.data.name}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:(u.value??0).toLocaleString("es-ES")})]}),children:n.jsx(c.Box,{sx:{position:"absolute",left:`${u.x0}%`,top:`${u.y0}%`,width:`${m}%`,height:`${p}%`,borderRadius:"6px",border:"1px solid rgba(255, 255, 255, 0.25)",background:E,color:d.palette.common.white,p:.75,boxSizing:"border-box",overflow:"hidden",display:"flex",flexDirection:"column",alignItems:r==="logos"?"center":"flex-start",justifyContent:"center"},children:r==="logos"?u.data.icono&&n.jsx(c.Box,{sx:{width:36,height:36,"& img, & svg":{width:"100%",height:"100%"}},children:u.data.icono}):$&&n.jsxs(n.Fragment,{children:[n.jsx(c.Typography,{sx:{fontSize:13,fontWeight:600,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:u.data.name}),n.jsx(c.Typography,{sx:{fontSize:12,opacity:.85},children:(u.value??0).toLocaleString("es-ES")})]})})},x)})});return i?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${d.palette.divider}`,bgcolor:d.palette.background.paper,boxShadow:d.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),v]}):v},Ct=e=>"valor"in e,Ve=1e3,Ea=({datos:e,alto:r=300,titulo:t,subtitulo:o,conPapel:a=!0})=>{const i=pe(),d=ce(),f=ne.useMemo(()=>{const h=new Map;for(const m of e)h.has(m.grupo)||h.set(m.grupo,h.size);const v=hr.hierarchy({children:e}).sum(m=>Ct(m)?m.valor:0);return{nodos:hr.pack().size([Ve,Ve]).padding(12)(v).leaves().filter(m=>Ct(m.data)).map(m=>{const p=m.data,s=h.get(p.grupo)??0;return{nombre:p.nombre,grupo:p.grupo,valor:p.valor,x:m.x,y:m.y,r:m.r,relleno:p.color?d.color(p.color):d.serie(s)}})}},[e,d]),y=n.jsx(c.Box,{sx:{position:"relative",width:"100%",height:r,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(c.Box,{sx:{position:"relative",height:"100%",aspectRatio:"1 / 1",maxWidth:"100%"},children:f.nodos.map((h,v)=>{const u=h.r/Ve*100>7;return n.jsx(c.Tooltip,{arrow:!0,title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:h.grupo}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,children:[h.nombre," · ",h.valor.toLocaleString("es-ES")]})]}),children:n.jsx(c.Box,{sx:{position:"absolute",left:`${h.x/Ve*100}%`,top:`${h.y/Ve*100}%`,width:`${h.r*2/Ve*100}%`,height:`${h.r*2/Ve*100}%`,transform:"translate(-50%, -50%)",borderRadius:"50%",backgroundColor:h.relleno,border:`1px solid ${i.palette.common.white}33`,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",overflow:"hidden",cursor:"default",transition:"filter 0.2s","&:hover":{filter:"brightness(1.08)"}},children:u&&n.jsxs(n.Fragment,{children:[n.jsx(c.Typography,{sx:{color:i.palette.common.white,fontSize:11,fontWeight:600,lineHeight:1.1,textAlign:"center",whiteSpace:"nowrap"},children:h.nombre}),n.jsx(c.Typography,{sx:{color:i.palette.common.white,fontSize:10,opacity:.75,lineHeight:1.1},children:h.valor.toLocaleString("es-ES")})]})})},`${h.nombre}-${v}`)})})});return a?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${i.palette.divider}`,bgcolor:i.palette.background.paper,boxShadow:i.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),y]}):y},ka=48,Ba=8,Aa=({datos:e,gradiente:r=!0,alto:t=280,titulo:o,subtitulo:a,conPapel:i=!0})=>{const d=pe(),f=ce(),y=ne.useMemo(()=>[...e].sort((x,m)=>m.valor-x.valor),[e]),h=ne.useMemo(()=>y.reduce((x,m)=>Math.max(x,m.valor),0)||1,[y]),v=(x,m)=>{const p=x.color?f.color(x.color):f.serie(m);return r?`linear-gradient(180deg, ${p}, ${p}cc)`:p},u=n.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",gap:`${Ba}px`,width:"100%",height:t,justifyContent:"center"},children:y.map((x,m)=>{const p=x.valor/h*100;return n.jsxs(c.Box,{sx:{position:"relative",alignSelf:"center",width:`${p}%`,height:`${ka}px`,flexShrink:0,borderRadius:1.5,background:v(x,m),display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:[n.jsx(c.Typography,{variant:"caption",sx:{color:d.palette.common.white,fontWeight:600,lineHeight:1.2,whiteSpace:"nowrap"},children:x.clave}),n.jsx(c.Typography,{sx:{color:d.palette.common.white,fontSize:12,fontWeight:700,fontFamily:"monospace"},children:x.valor})]},`${x.clave}-${m}`)})});return i?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${d.palette.divider}`,bgcolor:d.palette.background.paper,boxShadow:d.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),u]}):u},Me=150,Et=5,Ra=({ejes:e,series:r,variante:t="lineal",conPuntos:o=!1,conLeyenda:a=!1,alto:i=300,titulo:d,subtitulo:f,conPapel:y=!0})=>{const h=pe(),v=ce(),u=ne.useMemo(()=>{const p=e.length,s=Math.PI*2/Math.max(p,1),$=Math.max(1,...r.flatMap(b=>b.valores)),E=oe.scaleLinear().range([0,Me]).domain([0,$]),w=ue.lineRadial().radius(b=>E(b)).angle((b,g)=>g*s).curve(t==="redondeado"?ue.curveCardinalClosed:ue.curveLinearClosed);return{anguloPorEje:s,rScale:E,generarTrazo:w,vertice:(b,g)=>{const S=s*b-Math.PI/2;return{x:g*Math.cos(S),y:g*Math.sin(S)}}}},[e,r,t]),x=(p,s)=>p.color?v.color(p.color):v.serie(s),m=n.jsxs(c.Stack,{spacing:2,alignItems:"center",sx:{width:"100%"},children:[n.jsx(c.Box,{sx:{width:"100%",height:i,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(c.Box,{component:"svg",viewBox:`0 0 ${Me*2} ${Me*2}`,sx:{height:"100%",maxHeight:i,overflow:"visible"},children:n.jsxs("g",{transform:`translate(${Me}, ${Me})`,children:[Array.from({length:Et}).map((p,s)=>n.jsx("circle",{cx:0,cy:0,r:Me/Et*(s+1),fill:"none",stroke:v.cuadricula,strokeWidth:.5},`anillo-${s}`)),e.map((p,s)=>{const $=u.vertice(s,Me);return n.jsx("line",{x1:0,y1:0,x2:$.x,y2:$.y,stroke:v.cuadricula,strokeWidth:.5},`eje-${s}`)}),r.map((p,s)=>{const $=u.generarTrazo(p.valores);if(!$)return null;const E=x(p,s);return n.jsx("path",{d:$,fill:E,fillOpacity:.25,stroke:E,strokeWidth:1.5},`serie-${p.nombre}`)}),o&&r[0]?.valores.map((p,s)=>{const $=u.vertice(s,u.rScale(p));return n.jsxs("g",{children:[n.jsx("circle",{cx:$.x,cy:$.y,r:11,fill:v.superficie,stroke:x(r[0],0),strokeWidth:1}),n.jsx("text",{x:$.x,y:$.y,dy:"0.35em",textAnchor:"middle",fontSize:10,fill:v.ejeTexto,children:p})]},`punto-${s}`)}),e.map((p,s)=>{const $=u.vertice(s,Me+16);return n.jsx("text",{x:$.x,y:$.y,dy:"0.35em",textAnchor:"middle",fontSize:13,fill:v.ejeTexto,children:p},`etq-${s}`)})]})})}),a&&n.jsx(c.Stack,{direction:"row",spacing:2,flexWrap:"wrap",justifyContent:"center",children:r.map((p,s)=>n.jsxs(c.Stack,{direction:"row",spacing:1,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"3px",bgcolor:x(p,s),flexShrink:0}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:p.nombre})]},p.nombre))})]});return y?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${h.palette.divider}`,bgcolor:h.palette.background.paper,boxShadow:h.shadows[1]},children:[(d||f)&&n.jsxs(c.Box,{sx:{mb:2},children:[d&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:d}),f&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:f})]}),m]}):m},kt=e=>{const r=new Set,t=[];for(const o of e)r.has(o)||(r.add(o),t.push(o));return t},Oa=({datos:e,color:r="exito",alto:t=280,conValores:o=!1,titulo:a,subtitulo:i,conPapel:d=!0})=>{const f=pe(),y=ce(),h=ne.useMemo(()=>{const x=kt(e.map(j=>j.fila)),m=kt(e.map(j=>j.columna)),p=e.map(j=>j.valor),s=p.length>0?Math.min(...p):0,$=p.length>0?Math.max(...p):0,E=oe.scaleLinear().domain([s,$===s?s+1:$]).range([.12,1]),w=new Map;for(const j of e)w.set(`${j.fila}__${j.columna}`,j);return{filas:x,columnas:m,escalaIntensidad:E,indice:w}},[e]),v=y.color(r),u=n.jsxs(c.Box,{sx:{display:"flex",flexDirection:"column",width:"100%",height:t},children:[n.jsxs(c.Box,{sx:{display:"flex",flex:1,minHeight:0},children:[n.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-around",pr:1,flexShrink:0},children:h.filas.map(x=>n.jsx(c.Typography,{variant:"caption",sx:{color:y.ejeTexto,whiteSpace:"nowrap",textAlign:"right"},children:x},x))}),n.jsx(c.Box,{sx:{flex:1,minWidth:0,display:"grid",gap:.5,gridTemplateColumns:`repeat(${h.columnas.length}, 1fr)`,gridTemplateRows:`repeat(${h.filas.length}, 1fr)`},children:h.filas.map(x=>h.columnas.map(m=>{const p=h.indice.get(`${x}__${m}`),s=p?h.escalaIntensidad(p.valor):0,$=p?Ye.alpha(v,s):Ye.alpha(y.cuadricula,.25),E=n.jsx(c.Box,{sx:{width:"100%",height:"100%",borderRadius:1,backgroundColor:$,display:"flex",alignItems:"center",justifyContent:"center",cursor:p?"default":"auto",transition:f.transitions.create("transform"),"&:hover":p?{transform:"scale(1.06)"}:void 0},children:o&&p&&n.jsx(c.Typography,{sx:{fontSize:11,fontVariantNumeric:"tabular-nums",color:s>.55?y.contraste(r):f.palette.text.primary},children:p.valor})});return p?n.jsx(c.Tooltip,{arrow:!0,placement:"top",title:n.jsxs(c.Box,{children:[n.jsxs(c.Typography,{variant:"caption",sx:{opacity:.7},children:[x," · ",m]}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:p.valor.toLocaleString("es-ES")})]}),children:E},`${x}__${m}`):n.jsx(c.Box,{children:E},`${x}__${m}`)}))})]}),n.jsxs(c.Box,{sx:{display:"flex",pt:.75},children:[n.jsx(c.Box,{sx:{flexShrink:0,pr:1,visibility:"hidden"},children:h.filas.length>0&&n.jsx(c.Typography,{variant:"caption",children:h.filas.reduce((x,m)=>x.length>=m.length?x:m,"")})}),n.jsx(c.Box,{sx:{flex:1,minWidth:0,display:"grid",gap:.5,gridTemplateColumns:`repeat(${h.columnas.length}, 1fr)`},children:h.columnas.map(x=>n.jsx(c.Typography,{variant:"caption",sx:{color:y.ejeTexto,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x},x))})]})]});return d?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${f.palette.divider}`,bgcolor:f.palette.background.paper,boxShadow:f.shadows[1]},children:[(a||i)&&n.jsxs(c.Box,{sx:{mb:2},children:[a&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:a}),i&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:i})]}),u]}):u};exports.CodeplexGraficoArea=ja;exports.CodeplexGraficoBarraLinea=ya;exports.CodeplexGraficoBarras=ua;exports.CodeplexGraficoBarrasApiladas=ha;exports.CodeplexGraficoBarrasDivergentes=ga;exports.CodeplexGraficoBarrasMultiples=ma;exports.CodeplexGraficoBurbujas=Ea;exports.CodeplexGraficoComparativa=xa;exports.CodeplexGraficoDesglose=fa;exports.CodeplexGraficoDispersion=Ta;exports.CodeplexGraficoEmbudo=Aa;exports.CodeplexGraficoLineas=pa;exports.CodeplexGraficoMapaCalor=Oa;exports.CodeplexGraficoMedidor=wa;exports.CodeplexGraficoPastel=$a;exports.CodeplexGraficoPuntosConectados=va;exports.CodeplexGraficoRadar=Ra;exports.CodeplexGraficoTooltip=ir;exports.CodeplexGraficoTreemap=Ca;exports.CodeplexGraficoVelas=ba;exports.GraficoTooltipContenido=sr;exports.GraficoTooltipDisparador=Ke;exports.agruparPorPeriodo=eo;exports.filtrarPorRango=Rt;exports.formatearFecha=Qt;exports.parsearFecha=Bt;
48
+ `,Se={arriba:0,derecha:8,abajo:25,izquierda:28},la={lineal:ue.curveLinear,suave:ue.curveMonotoneX,escalon:ue.curveStep,natural:ue.curveNatural},da=e=>e instanceof Date,$t=e=>e instanceof Date?e.toLocaleDateString("es-ES",{day:"2-digit",month:"short"}):String(e),pa=({series:e,datos:r,titulo:t,subtitulo:o,alto:a=288,curva:i="suave",color:d,gradiente:f=!1,mostrarValores:y=!1,pulsante:h=!1,conCuadricula:v=!0,conTooltip:u=!0,conPapel:x=!0})=>{const m=pe(),p=ce(),s=ne.useId().replace(/:/g,""),$=ne.useMemo(()=>e&&e.length>0?e:r&&r.length>0?[{nombre:t??"Serie",datos:r,color:d}]:[],[e,r,t,d]),E=$.some(b=>b.datos.some(g=>g.icono)),w=ne.useMemo(()=>{const b=$.flatMap(N=>N.datos.map(I=>I.etiqueta)),g=$.flatMap(N=>N.datos.map(I=>I.valor)),S=le.max(g)??0,B=oe.scaleLinear().domain([0,S===0?1:S]).range([100,0]),_=b[0];let M;if(_ instanceof Date){const N=b.filter(da),I=le.extent(N),U=oe.scaleTime().domain(I).range([0,100]);M=C=>U(C)}else if(typeof _=="number"){const N=b,I=oe.scaleLinear().domain([le.min(N)??0,le.max(N)??0]).range([0,100]);M=U=>I(U)}else{const N=b.map(U=>String(U)),I=oe.scalePoint().domain(N).range([0,100]);M=U=>I(String(U))??0}const Y=ue.line().x(N=>M(N.etiqueta)).y(N=>B(N.valor)).curve(la[i]),P=B.ticks(6).map(N=>({posicion:B(N),texto:String(N)})),l=B.ticks(6).map(N=>B(N)),A=$[0]?.datos??[],k=A.reduce((N,I,U,C)=>I.valor>C[N].valor?U:N,0),z=Array.from(new Set([0,k,A.length-1].filter(N=>N>=0))).map(N=>({posicion:M(A[N].etiqueta),texto:$t(A[N].etiqueta),anclaje:N===0?"inicio":N===A.length-1?"fin":"centro"}));return{escalaY:B,posicionX:M,generarLinea:Y,marcasY:P,marcasX:z,posicionesCuadricula:l}},[$,i]),j=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:a},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Se.arriba}px - ${Se.abajo}px)`,width:`${Se.izquierda}px`,transform:`translateY(${Se.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:w.marcasY})}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Se.arriba}px - ${Se.abajo}px)`,width:`calc(100% - ${Se.izquierda}px - ${Se.derecha}px)`,transform:`translate(${Se.izquierda}px, ${Se.arriba}px)`,overflow:"visible"},children:[n.jsxs(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{width:"100%",height:"100%",overflow:"visible"},children:[f&&n.jsx("defs",{children:n.jsxs("linearGradient",{id:s,x1:"0%",y1:"0%",x2:"100%",y2:"0%",children:[n.jsx("stop",{offset:"0%",stopColor:p.color(d??"primario")}),n.jsx("stop",{offset:"100%",stopColor:p.color(d==="secundario"?"error":"secundario")})]})}),v&&n.jsx(Re,{posiciones:w.posicionesCuadricula}),$.map((b,g)=>{const S=w.generarLinea(b.datos),B=b.color?p.color(b.color):d?p.color(d):p.serie(g);return S?n.jsxs("g",{children:[n.jsx("path",{d:S,fill:"none",stroke:f?`url(#${s})`:B,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"}),u&&b.datos.map((_,M)=>{const Y=w.posicionX(_.etiqueta),P=w.escalaY(_.valor);return n.jsxs(ir,{children:[n.jsxs(Ke,{children:[n.jsx("path",{d:`M ${Y} ${P} l 0.0001 0`,stroke:B,strokeWidth:7,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),n.jsx("path",{d:`M ${Y} ${P} l 0.0001 0`,stroke:"transparent",strokeWidth:18,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"})]}),n.jsxs(sr,{children:[n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:b.nombre}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,color:"text.primary",children:[$t(_.etiqueta)," ·"," ",_.valor.toLocaleString("es-ES")]})]})]},`${b.nombre}-${M}`)})]},b.nombre):null})]}),(y||E||h)&&n.jsxs(c.Box,{sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:[$.flatMap((b,g)=>b.datos.map((S,B)=>{const _=w.posicionX(S.etiqueta),M=w.escalaY(S.valor),Y=b.color?p.color(b.color):d?p.color(d):p.serie(g),P=`${b.nombre}-${B}`;return S.icono?n.jsx(c.Box,{sx:{position:"absolute",left:`${_}%`,top:`${M}%`,transform:"translate(-50%, -50%)",width:24,height:24,borderRadius:"50%",overflow:"hidden","& img, & svg":{width:"100%",height:"100%"}},children:S.icono},P):y?n.jsx(c.Box,{sx:{position:"absolute",left:`${_}%`,top:`${M}%`,transform:"translate(-50%, -50%)",minWidth:20,height:20,px:.5,borderRadius:"999px",bgcolor:"background.paper",border:`1px solid ${Y}`,color:"text.primary",fontSize:11,fontVariantNumeric:"tabular-nums",display:"flex",alignItems:"center",justifyContent:"center"},children:S.valor},P):null})),h&&$[0]?.datos.length>0&&(()=>{const b=$[0],g=b.datos[b.datos.length-1],S=w.posicionX(g.etiqueta),B=w.escalaY(g.valor),_=b.color?p.color(b.color):d?p.color(d):p.serie(0);return n.jsxs(c.Box,{sx:{position:"absolute",left:`${S}%`,top:`${B}%`,transform:"translate(-50%, -50%)",width:10,height:10},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,borderRadius:"50%",bgcolor:_,animation:`${ca} 1.4s ease-out infinite`}}),n.jsx(c.Box,{sx:{position:"absolute",inset:"25%",borderRadius:"50%",bgcolor:_}})]})})()]}),n.jsx(c.Box,{sx:{position:"relative",mt:1},children:n.jsx(Ar,{marcas:w.marcasX})})]})]});return x?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${m.palette.divider}`,bgcolor:m.palette.background.paper,boxShadow:m.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),j]}):j},je={arriba:12,derecha:8,abajo:28},ua=({datos:e,titulo:r,subtitulo:t,alto:o=288,orientacion:a="horizontal",color:i,gradiente:d=!1,animado:f=!0,delgado:y=!1,mostrarValores:h=!1,conCuadricula:v=!0,conTooltip:u=!0,conPapel:x=!0})=>{const m=pe(),p=ce(),s=a==="horizontal",$=e.some(S=>S.icono),E=ne.useMemo(()=>{const S=e.map(A=>A.clave),B=le.max(e,A=>A.valor)??0,_=oe.scaleBand().domain(S).range([0,100]).padding(y?.6:.2),M=oe.scaleLinear().domain([0,B===0?1:B]).range(s?[0,100]:[100,0]),Y=M.ticks(5),P=Y.map(A=>M(A)),l=S.reduce((A,k)=>Math.max(A,k.length),1);return{claves:S,escalaCategoria:_,escalaValor:M,marcasValor:Y,posicionesCuadricula:P,margenCategoria:s?Math.min(l*7,120)+($?32:0):28}},[e,s,y,$]),w=(S,B)=>{const _=S.color?p.color(S.color):i?p.color(i):p.serie(B);return d?`linear-gradient(180deg, ${Ye.alpha(_,1)}, ${Ye.alpha(_,.55)})`:_},j=s?E.margenCategoria:je.derecha,b=e.map((S,B)=>{const _=E.escalaCategoria(S.clave)??0,M=E.escalaCategoria.bandwidth(),Y=s?E.escalaValor(S.valor):100-E.escalaValor(S.valor),P=n.jsx(c.Box,{sx:{position:"absolute",...s?{left:0,top:`${_}%`,width:`${Y}%`,height:`${M}%`,borderRadius:"0 6px 6px 0",transformOrigin:"left center",animation:f?`${Xt} 0.5s ease-out ${B*.06}s both`:"none"}:{left:`${_}%`,bottom:0,width:`${M}%`,height:`${Y}%`,borderRadius:"6px 6px 0 0",transformOrigin:"bottom center",animation:f?`${Ht} 0.5s ease-out ${B*.06}s both`:"none"},background:w(S,B)}});return u?n.jsx(c.Tooltip,{arrow:!0,placement:s?"right":"top",title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:S.clave}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:S.valor.toLocaleString("es-ES")})]}),children:P},S.clave):n.jsx(c.Box,{children:P},S.clave)}),g=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:o},children:[n.jsxs(c.Box,{sx:{position:"absolute",inset:0,zIndex:1,height:`calc(100% - ${je.arriba}px - ${je.abajo}px)`,width:`calc(100% - ${j}px - ${je.derecha}px)`,transform:`translate(${j}px, ${je.arriba}px)`,overflow:"visible"},children:[v&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:E.posicionesCuadricula,orientacion:s?"vertical":"horizontal"})}),b,h&&e.map(S=>{const _=(E.escalaCategoria(S.clave)??0)+E.escalaCategoria.bandwidth()/2,M=E.escalaValor(S.valor);return n.jsx(c.Box,{sx:{position:"absolute",color:p.ejeTexto,fontSize:12,fontWeight:500,fontVariantNumeric:"tabular-nums",pointerEvents:"none",whiteSpace:"nowrap",...s?{left:`calc(${M}% + 4px)`,top:`${_}%`,transform:"translateY(-50%)"}:{left:`${_}%`,top:`${M}%`,transform:"translate(-50%, -130%)"}},children:S.valor},`valor-${S.clave}`)}),E.marcasValor.map((S,B)=>n.jsx(c.Box,{sx:{position:"absolute",color:p.ejeTexto,fontSize:12,fontVariantNumeric:"tabular-nums",...s?{left:`${E.escalaValor(S)}%`,top:"100%",transform:"translateX(-50%)",pt:.5}:{top:`${E.escalaValor(S)}%`,right:"100%",transform:"translateY(-50%)",pr:1}},children:S},B))]}),n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${je.arriba}px - ${je.abajo}px)`,transform:`translateY(${je.arriba}px)`,overflow:"visible",...s?{width:`${j}px`}:{top:"auto",bottom:0,height:`${je.abajo}px`,transform:"none",left:`${j}px`,right:`${je.derecha}px`}},children:e.map(S=>{const B=(E.escalaCategoria(S.clave)??0)+E.escalaCategoria.bandwidth()/2;return n.jsxs(c.Box,{sx:{position:"absolute",display:"flex",alignItems:"center",gap:.75,color:p.ejeTexto,fontSize:12,whiteSpace:"nowrap",...s?{top:`${B}%`,left:S.icono?0:void 0,right:S.icono?void 0:m.spacing(1),transform:"translateY(-50%)"}:{left:`${B}%`,top:4,transform:"translateX(-50%)"}},children:[S.icono&&n.jsx(c.Box,{sx:{width:22,height:22,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",borderRadius:"50%","& img, & svg":{width:"100%",height:"100%"}},children:S.icono}),S.clave]},S.clave)})})]});return x?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${m.palette.divider}`,bgcolor:m.palette.background.paper,boxShadow:m.shadows[1]},children:[(r||t)&&n.jsxs(c.Box,{sx:{mb:2},children:[r&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:r}),t&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:t})]}),g]}):g},fa=({datos:e,variante:r="grueso",titulo:t,subtitulo:o,conPapel:a=!0})=>{const i=pe(),d=ce(),f=r==="grueso",y=n.jsx(c.Box,{sx:{display:"flex",gap:.4,width:"100%",alignItems:"stretch"},children:e.map((h,v)=>{const u=h.color?d.color(h.color):d.serie(v);return n.jsxs(c.Box,{sx:{flexGrow:Math.max(h.valor,.001),flexBasis:0,minWidth:0},children:[n.jsx(c.Box,{sx:{position:"relative",height:f?54:12,borderRadius:1,background:`linear-gradient(180deg, ${u}, ${u}cc)`,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:f&&n.jsxs(n.Fragment,{children:[n.jsx(c.Typography,{variant:"caption",sx:{color:i.palette.common.white,fontWeight:600,lineHeight:1.2,whiteSpace:"nowrap"},children:h.clave}),n.jsx(c.Typography,{sx:{color:i.palette.common.white,fontSize:12,fontWeight:700,fontFamily:"monospace"},children:h.valor})]})}),!f&&n.jsx(c.Typography,{sx:{mt:1,fontSize:12,color:d.ejeTexto,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:h.clave})]},h.clave)})});return a?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${i.palette.divider}`,bgcolor:i.palette.background.paper,boxShadow:i.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),y]}):y},_e={arriba:8,derecha:8,abajo:24},ha=({categorias:e,series:r,orientacion:t="vertical",titulo:o,subtitulo:a,alto:i=288,conCuadricula:d=!0,conLeyenda:f=!0,conPapel:y=!0})=>{const h=pe(),v=ce(),u=t==="horizontal",x=(w,j)=>w.color?v.color(w.color):v.serie(j),m=ne.useMemo(()=>{const w=e.map((A,k)=>r.reduce((W,z)=>W+(z.valores[k]??0),0)),j=le.max(w)??0,b=oe.scaleBand().domain(e).range([0,100]).padding(.3),g=oe.scaleLinear().domain([0,j===0?1:j]).range(u?[0,100]:[100,0]),S=e.map(()=>0),B=[];r.forEach((A,k)=>{e.forEach((W,z)=>{const N=A.valores[z]??0,I=S[z],U=I+N;S[z]=U,B.push({indiceSerie:k,indiceCategoria:z,clave:W,nombre:A.nombre,valor:N,relleno:x(A,k),inicio:g(I),fin:g(U),bandaInicio:b(W)??0,bandaGrosor:b.bandwidth()})})});const _=g.ticks(5),M=_.map(A=>g(A)),Y=_.map(A=>({posicion:g(A),texto:String(A)})),P=e.map(A=>({posicion:(b(A)??0)+b.bandwidth()/2,texto:A})),l=e.reduce((A,k)=>Math.max(A,k.length),1);return{segmentos:B,posicionesCuadricula:M,marcasValorEje:Y,marcasCategoria:P,margenCategoria:u?Math.min(l*7,110):28}},[e,r,u]),p=m.margenCategoria,s=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:i},children:[n.jsxs(c.Box,{sx:{position:"absolute",inset:0,zIndex:1,height:`calc(100% - ${_e.arriba}px - ${_e.abajo}px)`,width:`calc(100% - ${p}px - ${_e.derecha}px)`,transform:`translate(${p}px, ${_e.arriba}px)`,overflow:"visible"},children:[d&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:m.posicionesCuadricula,orientacion:u?"vertical":"horizontal"})}),m.segmentos.map(w=>{const j=Math.abs(w.fin-w.inicio);return n.jsx(c.Tooltip,{arrow:!0,placement:u?"top":"right",title:n.jsxs(c.Box,{children:[n.jsxs(c.Typography,{variant:"caption",sx:{opacity:.7},children:[w.nombre," · ",w.clave]}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:w.valor.toLocaleString("es-ES")})]}),children:n.jsx(c.Box,{sx:{position:"absolute",background:w.relleno,...u?{left:`${Math.min(w.inicio,w.fin)}%`,top:`${w.bandaInicio}%`,width:`${j}%`,height:`${w.bandaGrosor}%`}:{left:`${w.bandaInicio}%`,top:`${Math.min(w.inicio,w.fin)}%`,width:`${w.bandaGrosor}%`,height:`${j}%`}}})},`${w.indiceSerie}-${w.indiceCategoria}`)})]}),n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${_e.arriba}px - ${_e.abajo}px)`,width:`${p}px`,transform:`translateY(${_e.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:u?m.marcasCategoria:m.marcasValorEje})}),n.jsx(c.Box,{sx:{position:"absolute",bottom:0,left:`${p}px`,right:`${_e.derecha}px`,height:`${_e.abajo}px`,overflow:"visible"},children:n.jsx(Ar,{marcas:u?m.marcasValorEje:m.marcasCategoria})})]}),$=f&&n.jsx(c.Stack,{direction:"row",flexWrap:"wrap",gap:1.5,sx:{mb:1.5},children:r.map((w,j)=>n.jsxs(c.Stack,{direction:"row",spacing:.75,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"3px",bgcolor:x(w,j),flexShrink:0}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:w.nombre})]},w.nombre))}),E=n.jsxs(n.Fragment,{children:[$,s]});return y?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${h.palette.divider}`,bgcolor:h.palette.background.paper,boxShadow:h.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),E]}):E},ve={arriba:12,derecha:8,abajo:28,izquierda:28},wt=1.5,ma=({categorias:e,series:r,orientacion:t="vertical",titulo:o,subtitulo:a,alto:i=288,conCuadricula:d=!0,conLeyenda:f=!0,conPapel:y=!0})=>{const h=pe(),v=ce(),u=t==="horizontal",x=ne.useMemo(()=>{const w=r.length===0?1:r.length,j=oe.scaleBand().domain(e).range([0,100]).padding(.3),b=le.max(r.flatMap(P=>P.valores))??0,g=oe.scaleLinear().domain([0,b===0?1:b]).range(u?[0,100]:[100,0]),S=g.ticks(6),B=S.map(P=>g(P)),_=j.bandwidth(),M=(_-wt*(w-1))/w,Y=e.reduce((P,l)=>Math.max(P,l.length),1);return{escalaCategoria:j,escalaValor:g,marcasValor:S,posicionesCuadricula:B,grosorGrupo:_,grosorSubBarra:M,totalSeries:w,margenCategoria:u?Math.min(Y*7,120):ve.izquierda}},[e,r,u]),m=(w,j)=>w.color?v.color(w.color):v.serie(j),p=u?x.margenCategoria:ve.izquierda,s=e.flatMap((w,j)=>{const b=x.escalaCategoria(w)??0;return r.map((g,S)=>{const B=g.valores[j]??0,_=S*(x.grosorSubBarra+wt),M=u?x.escalaValor(B):100-x.escalaValor(B),Y=n.jsx(c.Box,{sx:{position:"absolute",background:m(g,S),...u?{left:0,top:`${b+_}%`,width:`${M}%`,height:`${x.grosorSubBarra}%`,borderRadius:"0 4px 4px 0"}:{bottom:0,left:`${b+_}%`,width:`${x.grosorSubBarra}%`,height:`${M}%`,borderRadius:"4px 4px 0 0"}}});return n.jsx(c.Tooltip,{arrow:!0,placement:u?"right":"top",title:n.jsxs(c.Box,{children:[n.jsxs(c.Typography,{variant:"caption",sx:{opacity:.7},children:[g.nombre," · ",w]}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:B.toLocaleString("es-ES")})]}),children:Y},`${w}-${g.nombre}`)})}),$=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:i},children:[n.jsxs(c.Box,{sx:{position:"absolute",inset:0,zIndex:1,height:`calc(100% - ${ve.arriba}px - ${ve.abajo}px)`,width:`calc(100% - ${p}px - ${ve.derecha}px)`,transform:`translate(${p}px, ${ve.arriba}px)`,overflow:"visible"},children:[d&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:x.posicionesCuadricula,orientacion:u?"vertical":"horizontal"})}),s,x.marcasValor.map((w,j)=>n.jsx(c.Box,{sx:{position:"absolute",color:v.ejeTexto,fontSize:12,fontVariantNumeric:"tabular-nums",...u?{left:`${x.escalaValor(w)}%`,top:"100%",transform:"translateX(-50%)",pt:.5}:{top:`${x.escalaValor(w)}%`,right:"100%",transform:"translateY(-50%)",pr:1}},children:w},j))]}),n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${ve.arriba}px - ${ve.abajo}px)`,transform:`translateY(${ve.arriba}px)`,overflow:"visible",...u?{width:`${p}px`}:{top:"auto",bottom:0,height:`${ve.abajo}px`,transform:"none",left:`${p}px`,right:`${ve.derecha}px`}},children:e.map(w=>{const j=(x.escalaCategoria(w)??0)+x.escalaCategoria.bandwidth()/2;return n.jsx(c.Box,{sx:{position:"absolute",color:v.ejeTexto,fontSize:12,whiteSpace:"nowrap",...u?{top:`${j}%`,right:h.spacing(1),transform:"translateY(-50%)"}:{left:`${j}%`,top:4,transform:"translateX(-50%)"}},children:w},w)})})]}),E=n.jsxs(c.Box,{children:[f&&n.jsx(c.Stack,{direction:"row",spacing:2,flexWrap:"wrap",sx:{mb:1.5},children:r.map((w,j)=>n.jsxs(c.Stack,{direction:"row",spacing:.75,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"3px",bgcolor:m(w,j)}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:w.nombre})]},w.nombre))}),$]});return y?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${h.palette.divider}`,bgcolor:h.palette.background.paper,boxShadow:h.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),E]}):E},xa=({datos:e,indiceDestacado:r=0,titulo:t,subtitulo:o,conPapel:a=!0})=>{const i=pe(),d=ce(),f=e.reduce((h,v)=>Math.max(h,v.valor),0),y=n.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",gap:2,width:"100%"},children:e.map((h,v)=>{const u=v===r,x=f===0?0:h.valor/f*100,m=u?`linear-gradient(90deg, ${d.color("exito")}, ${d.color("info")})`:`linear-gradient(90deg, ${d.ejeTexto}, ${d.cuadricula})`;return n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"body2",sx:{mb:.75,fontWeight:u?700:500,color:u?d.color("exito"):d.ejeTexto},children:h.clave}),n.jsxs(c.Box,{sx:{display:"flex",alignItems:"center",gap:1.25},children:[n.jsx(c.Box,{sx:{position:"relative",flexGrow:1,height:12,borderRadius:1,overflow:"hidden",bgcolor:i.palette.action.hover},children:n.jsx(c.Box,{sx:{position:"absolute",insetBlock:0,left:0,width:`${x}%`,borderRadius:1,background:m,transformOrigin:"left center",animation:`${Xt} 0.6s ease-out ${v*.08}s both`}})}),n.jsx(c.Typography,{variant:"body2",sx:{fontVariantNumeric:"tabular-nums",fontWeight:u?700:500,color:u?d.color("info"):d.ejeTexto,minWidth:40,textAlign:"right"},children:h.valor})]})]},h.clave)})});return a?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${i.palette.divider}`,bgcolor:i.palette.background.paper,boxShadow:i.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),y]}):y},Te={arriba:12,derecha:8,abajo:44,izquierda:28},ga=({datos:e,colorPositivo:r="exito",colorNegativo:t="error",titulo:o,subtitulo:a,alto:i=288,conCuadricula:d=!0,conTooltip:f=!0,conPapel:y=!0})=>{const h=pe(),v=ce(),u=ne.useMemo(()=>{const p=e.map(B=>B.clave),s=e.map(B=>B.valor),$=Math.min(0,le.min(s)??0),E=Math.max(0,le.max(s)??0),w=oe.scaleBand().domain(p).range([0,100]).padding(.3),j=oe.scaleLinear().domain([$,E===$?$+1:E]).range([100,0]),b=j(0),g=j.ticks(6),S=g.map(B=>j(B));return{claves:p,escalaCategoria:w,escalaValor:j,cero:b,marcasValor:g,posicionesCuadricula:S}},[e]),x=p=>{const s=v.color(p?r:t);return`linear-gradient(180deg, ${s}, ${s}bb)`},m=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:i},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Te.arriba}px - ${Te.abajo}px)`,width:`${Te.izquierda}px`,transform:`translateY(${Te.arriba}px)`,overflow:"visible"},children:u.marcasValor.map((p,s)=>n.jsx(c.Box,{sx:{position:"absolute",top:`${u.escalaValor(p)}%`,left:0,width:"100%",pr:1,textAlign:"right",transform:"translateY(-50%)",fontSize:12,fontVariantNumeric:"tabular-nums",color:v.ejeTexto},children:p},s))}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Te.arriba}px - ${Te.abajo}px)`,width:`calc(100% - ${Te.izquierda}px - ${Te.derecha}px)`,transform:`translate(${Te.izquierda}px, ${Te.arriba}px)`,overflow:"visible"},children:[d&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:u.posicionesCuadricula,orientacion:"horizontal"})}),e.map((p,s)=>{const $=p.valor>=0,E=u.escalaCategoria(p.clave)??0,w=u.escalaCategoria.bandwidth(),j=u.escalaValor(p.valor),b=$?j:u.cero,g=Math.abs(j-u.cero),S=n.jsx(c.Box,{sx:{position:"absolute",left:`${E}%`,top:`${b}%`,width:`${w}%`,height:`${g}%`,borderRadius:$?"4px 4px 0 0":"0 0 4px 4px",background:x($),transformOrigin:$?"bottom center":"top center",animation:`${Ht} 0.5s ease-out ${s*.05}s both`}});return f?n.jsx(c.Tooltip,{arrow:!0,placement:"top",title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:p.clave}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:p.valor.toLocaleString("es-ES")})]}),children:S},p.clave):n.jsx(c.Box,{children:S},p.clave)}),n.jsx(c.Box,{sx:{position:"absolute",left:0,right:0,top:`${u.cero}%`,borderTop:`1.5px solid ${v.ejeTexto}`,opacity:.6,pointerEvents:"none"}}),e.map(p=>{const s=(u.escalaCategoria(p.clave)??0)+u.escalaCategoria.bandwidth()/2;return n.jsx(c.Box,{sx:{position:"absolute",left:`${s}%`,top:"100%",transform:"rotate(45deg) translate(4px, 8px)",transformOrigin:"left top",fontSize:12,whiteSpace:"nowrap",color:v.ejeTexto},children:p.clave},`etq-${p.clave}`)})]})]});return y?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${h.palette.divider}`,bgcolor:h.palette.background.paper,boxShadow:h.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),m]}):m},he={arriba:8,derecha:30,abajo:28,izquierda:30},ya=({datos:e,colorBarra:r="secundario",colorLinea:t="error",titulo:o,subtitulo:a,alto:i=288,conPapel:d=!0})=>{const f=pe(),y=ce(),h=y.color(r),v=y.color(t),u=ne.useMemo(()=>{const m=e.map(g=>g.clave),p=oe.scaleBand().domain(m).range([0,100]).padding(.3),s=le.max(e,g=>g.barra)??0,$=oe.scaleLinear().domain([0,s===0?1:s]).range([100,0]),E=le.min(e,g=>g.linea)??0,w=le.max(e,g=>g.linea)??0,j=oe.scaleLinear().domain([E,w===E?E+1:w]).range([100,0]),b=ue.line().x(g=>(p(g.clave)??0)+p.bandwidth()/2).y(g=>j(g.linea)).curve(ue.curveMonotoneX);return{escalaX:p,escalaBarra:$,escalaLinea:j,trazo:b(e)??"",marcasBarra:$.ticks(6),marcasLinea:j.ticks(6)}},[e]),x=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:i},children:[n.jsx(c.Box,{sx:{position:"absolute",height:`calc(100% - ${he.arriba}px - ${he.abajo}px)`,width:`${he.izquierda}px`,left:0,transform:`translateY(${he.arriba}px)`,overflow:"visible"},children:u.marcasBarra.map((m,p)=>n.jsx(c.Box,{sx:{position:"absolute",top:`${u.escalaBarra(m)}%`,right:0,width:"100%",pr:.5,textAlign:"right",transform:"translateY(-50%)",fontSize:11,fontVariantNumeric:"tabular-nums",color:h},children:m},p))}),n.jsx(c.Box,{sx:{position:"absolute",height:`calc(100% - ${he.arriba}px - ${he.abajo}px)`,width:`${he.derecha}px`,right:0,transform:`translateY(${he.arriba}px)`,overflow:"visible"},children:u.marcasLinea.map((m,p)=>n.jsx(c.Box,{sx:{position:"absolute",top:`${u.escalaLinea(m)}%`,left:0,width:"100%",pl:.5,transform:"translateY(-50%)",fontSize:11,fontVariantNumeric:"tabular-nums",color:v},children:m},p))}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${he.arriba}px - ${he.abajo}px)`,width:`calc(100% - ${he.izquierda}px - ${he.derecha}px)`,transform:`translate(${he.izquierda}px, ${he.arriba}px)`,overflow:"visible"},children:[e.map(m=>{const p=u.escalaX(m.clave)??0,s=u.escalaX.bandwidth(),$=100-u.escalaBarra(m.barra);return n.jsx(c.Box,{sx:{position:"absolute",left:`${p}%`,bottom:0,width:`${s}%`,height:`${$}%`,borderRadius:"6px 6px 0 0",background:`linear-gradient(180deg, ${h}, ${h}99)`}},m.clave)}),n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible",pointerEvents:"none"},children:n.jsx("path",{d:u.trazo,fill:"none",stroke:v,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})}),n.jsx(c.Box,{sx:{position:"absolute",inset:0},children:e.map(m=>{const p=(u.escalaX(m.clave)??0)+u.escalaX.bandwidth()/2;return n.jsx(c.Box,{sx:{position:"absolute",left:`${p}%`,top:"100%",transform:"translateX(-50%)",pt:.5,fontSize:11,color:y.ejeTexto,whiteSpace:"nowrap"},children:m.clave},m.clave)})})]})]});return d?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${f.palette.divider}`,bgcolor:f.palette.background.paper,boxShadow:f.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),x]}):x},Ce={arriba:8,derecha:8,abajo:25,izquierda:32},ba=({datos:e,titulo:r,subtitulo:t,alto:o=288,conCuadricula:a=!0,conTooltip:i=!0,conPapel:d=!0})=>{const f=pe(),y=ce(),h=ne.useMemo(()=>{const u=e.map(j=>j.etiqueta),x=le.min(e,j=>j.minimo)??0,m=le.max(e,j=>j.maximo)??0,p=(m-x)*.05,s=oe.scaleBand().domain(u).range([0,100]).padding(.35),$=oe.scaleLinear().domain([x-p,m+p]).range([100,0]),E=$.ticks(6).map(j=>({posicion:$(j),texto:String(j)})),w=$.ticks(6).map(j=>$(j));return{escalaX:s,escalaY:$,marcasY:E,posicionesCuadricula:w}},[e]),v=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:o},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Ce.arriba}px - ${Ce.abajo}px)`,width:`${Ce.izquierda}px`,transform:`translateY(${Ce.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:h.marcasY})}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Ce.arriba}px - ${Ce.abajo}px)`,width:`calc(100% - ${Ce.izquierda}px - ${Ce.derecha}px)`,transform:`translate(${Ce.izquierda}px, ${Ce.arriba}px)`,overflow:"visible"},children:[a&&n.jsx(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{position:"absolute",inset:0,width:"100%",height:"100%",overflow:"visible"},children:n.jsx(Re,{posiciones:h.posicionesCuadricula})}),e.map(u=>{const x=h.escalaX(u.etiqueta)??0,m=h.escalaX.bandwidth(),s=u.cierre>=u.apertura?y.color("exito"):y.color("error"),$=h.escalaY(u.maximo),E=h.escalaY(u.minimo)-$,w=h.escalaY(Math.max(u.apertura,u.cierre)),j=h.escalaY(Math.min(u.apertura,u.cierre))-w,b=n.jsxs(c.Box,{sx:{position:"absolute",left:`${x}%`,width:`${m}%`,top:0,height:"100%"},children:[n.jsx(c.Box,{sx:{position:"absolute",left:"50%",transform:"translateX(-50%)",width:"2px",top:`${$}%`,height:`${E}%`,backgroundColor:s}}),n.jsx(c.Box,{sx:{position:"absolute",left:0,width:"100%",top:`${w}%`,height:`${j}%`,minHeight:"1px",borderRadius:"2px",backgroundColor:s}})]});return i?n.jsx(c.Tooltip,{arrow:!0,placement:"top",title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:u.etiqueta}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,children:["A ",u.apertura," · M ",u.maximo," · m ",u.minimo," · C"," ",u.cierre]})]}),children:b},u.etiqueta):n.jsx(c.Box,{children:b},u.etiqueta)})]})]});return d?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${f.palette.divider}`,bgcolor:f.palette.background.paper,boxShadow:f.shadows[1]},children:[(r||t)&&n.jsxs(c.Box,{sx:{mb:2},children:[r&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:r}),t&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:t})]}),v]}):v},We={arriba:10,derecha:36,abajo:24},va=({datos:e,color:r="primario",titulo:t,subtitulo:o,alto:a=288,conCuadricula:i=!0,conTooltip:d=!0,conPapel:f=!0})=>{const y=pe(),h=ce(),v=ne.useMemo(()=>{const m=e.map(S=>S.clave),p=le.max(e,S=>S.valor)??0,s=oe.scaleBand().domain(m).range([0,100]).padding(.5),$=oe.scaleLinear().domain([0,p===0?1:p]).range([0,100]),E=e.map(S=>({dato:S,x:$(S.valor),y:(s(S.clave)??0)+s.bandwidth()/2})),w=E.map((S,B)=>`${B===0?"M":"L"} ${S.x} ${S.y}`).join(" "),j=$.ticks(5),b=j.map(S=>$(S)),g=m.reduce((S,B)=>Math.max(S,B.length),1);return{puntos:E,trazo:w,marcasValor:j,escalaValor:$,posicionesCuadricula:b,margenIzquierda:Math.min(g*7,120)}},[e]),u=h.color(r),x=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:a},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${We.arriba}px - ${We.abajo}px)`,width:`${v.margenIzquierda}px`,transform:`translateY(${We.arriba}px)`,overflow:"visible"},children:v.puntos.map(m=>n.jsx(c.Box,{sx:{position:"absolute",top:`${m.y}%`,right:y.spacing(1),transform:"translateY(-50%)",fontSize:12,whiteSpace:"nowrap",color:h.ejeTexto},children:m.dato.clave},m.dato.clave))}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${We.arriba}px - ${We.abajo}px)`,width:`calc(100% - ${v.margenIzquierda}px - ${We.derecha}px)`,transform:`translate(${v.margenIzquierda}px, ${We.arriba}px)`,overflow:"visible"},children:[n.jsxs(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{width:"100%",height:"100%",overflow:"visible"},children:[i&&n.jsx(Re,{posiciones:v.posicionesCuadricula,orientacion:"vertical"}),n.jsx("path",{d:v.trazo,fill:"none",stroke:u,strokeWidth:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"}),v.puntos.map(m=>{const p=m.dato.color?h.color(m.dato.color):u,s=n.jsxs(n.Fragment,{children:[n.jsx("path",{d:`M ${m.x} ${m.y} l 0.0001 0`,stroke:p,strokeWidth:9,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"}),n.jsx("path",{d:`M ${m.x} ${m.y} l 0.0001 0`,stroke:"transparent",strokeWidth:18,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"})]});return d?n.jsxs(ir,{children:[n.jsx(Ke,{children:s}),n.jsxs(sr,{children:[n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:m.dato.clave}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,color:"text.primary",children:m.dato.valor.toLocaleString("es-ES")})]})]},m.dato.clave):n.jsx("g",{children:s},m.dato.clave)})]}),v.puntos.map(m=>n.jsx(c.Box,{sx:{position:"absolute",left:`${m.x}%`,top:`${m.y}%`,transform:"translate(8px, -50%)",fontSize:12,fontWeight:500,fontVariantNumeric:"tabular-nums",whiteSpace:"nowrap",pointerEvents:"none",color:h.ejeTexto},children:m.dato.valor},`valor-${m.dato.clave}`)),v.marcasValor.map((m,p)=>n.jsx(c.Box,{sx:{position:"absolute",left:`${v.escalaValor(m)}%`,top:"100%",transform:"translateX(-50%)",pt:.5,fontSize:12,fontVariantNumeric:"tabular-nums",color:h.ejeTexto},children:m},p))]})]});return f?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${y.palette.divider}`,bgcolor:y.palette.background.paper,boxShadow:y.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),x]}):x},St=20,ge=100,$a=({datos:e,variante:r="dona",titulo:t,subtitulo:o,alto:a=288,valorCentral:i,etiquetaCentral:d,etiquetasEnPorciones:f=!1,gradiente:y=!1,conTooltip:h=!0,conLeyenda:v=!0,conPapel:u=!0})=>{const x=pe(),m=ce(),p=ne.useId().replace(/:/g,""),s=r==="media-dona",$=ne.useMemo(()=>{const b=ue.pie().value(P=>P.valor).sort(null).startAngle(s?-Math.PI/2:0).endAngle(s?Math.PI/2:2*Math.PI),g=r==="pastel"?0:ge*.6,S=ue.arc().innerRadius(g).outerRadius(ge).cornerRadius(r==="pastel"?0:3).padAngle(.012),B=r==="pastel"?ge*.62:(g+ge)/2,_=ue.arc().innerRadius(B).outerRadius(B),M=e.reduce((P,l)=>P+l.valor,0);return{segmentos:b(e).map(P=>({arco:P,ruta:S(P)??"",centroide:_.centroid(P),angulo:(P.endAngle-P.startAngle)*180/Math.PI,porcentaje:M===0?0:P.data.valor/M*100})),total:M}},[e,r,s]),E=(b,g)=>b.color?m.color(b.color):m.serie(g),w=s?`-${ge+16} -${ge+16} ${2*ge+32} ${ge+24}`:`-${ge+16} -${ge+16} ${2*ge+32} ${2*ge+32}`,j=n.jsxs(c.Stack,{direction:{xs:"column",sm:v?"row":"column"},spacing:2,alignItems:"center",justifyContent:"center",sx:{width:"100%",height:a},children:[n.jsxs(c.Box,{sx:{position:"relative",height:"100%",flex:1,display:"flex",alignItems:"center",justifyContent:"center"},children:[n.jsxs(c.Box,{component:"svg",viewBox:w,sx:{width:"100%",height:"100%",maxHeight:a,overflow:"visible"},children:[y&&n.jsx("defs",{children:$.segmentos.map((b,g)=>{const S=E(b.arco.data,g);return n.jsxs("linearGradient",{id:`${p}-${g}`,x1:"0",y1:"0",x2:"0",y2:"1",children:[n.jsx("stop",{offset:"0%",stopColor:S,stopOpacity:1}),n.jsx("stop",{offset:"100%",stopColor:S,stopOpacity:.55})]},`grad-${b.arco.data.clave}`)})}),$.segmentos.map((b,g)=>{const S=y?`url(#${p}-${g})`:E(b.arco.data,g),B=n.jsx("path",{d:b.ruta,fill:S,stroke:m.superficie,strokeWidth:1.5});return h?n.jsxs(ir,{children:[n.jsx(Ke,{children:B}),n.jsxs(sr,{children:[n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:b.arco.data.clave}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,color:"text.primary",children:[b.arco.data.valor.toLocaleString("es-ES")," ·"," ",b.porcentaje.toFixed(1),"%"]})]})]},b.arco.data.clave):n.jsx("g",{children:B},b.arco.data.clave)}),f&&$.segmentos.map(b=>{if(b.angulo<=St)return null;const[g,S]=b.centroide;return n.jsxs("text",{transform:`translate(${g},${S})`,textAnchor:"middle",pointerEvents:"none",fill:x.palette.common.white,fontSize:8,fontWeight:600,children:[n.jsx("tspan",{x:0,y:"-0.3em",children:b.arco.data.clave}),n.jsx("tspan",{x:0,y:"1em",fontWeight:400,fillOpacity:.85,children:b.arco.data.valor.toLocaleString("es-ES")})]},`etq-${b.arco.data.clave}`)}),$.segmentos.map(b=>{const g=b.arco.data.icono;if(!g||b.angulo<=St)return null;const[S,B]=b.centroide,_=30;return n.jsx("foreignObject",{x:S-_/2,y:B-_/2,width:_,height:_,pointerEvents:"none",children:n.jsx(c.Box,{sx:{width:"100%",height:"100%",borderRadius:"50%",overflow:"hidden","& img, & svg":{width:"100%",height:"100%"}},children:g})},`ico-${b.arco.data.clave}`)})]}),(i!==void 0||d)&&r!=="pastel"&&n.jsxs(c.Box,{sx:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",pointerEvents:"none",transform:s?"translateY(28%)":"none"},children:[i!==void 0&&n.jsx(c.Typography,{variant:"h5",fontWeight:800,color:"text.primary",children:i}),d&&n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:d})]})]}),v&&n.jsx(c.Stack,{spacing:1,sx:{minWidth:120},children:e.map((b,g)=>n.jsxs(c.Stack,{direction:"row",spacing:1,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"3px",bgcolor:E(b,g),flexShrink:0}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:b.clave})]},b.clave))})]});return u?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${x.palette.divider}`,bgcolor:x.palette.background.paper,boxShadow:x.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),j]}):j},Ee=100,wa=({valor:e,variante:r="completo",color:t="secundario",etiqueta:o,alto:a=240,conPapel:i=!0})=>{const d=pe(),f=ce(),y=r==="medio",h=Math.max(0,Math.min(100,e)),v=d.palette.mode==="dark"?d.palette.grey[800]:d.palette.grey[200],u=ne.useMemo(()=>{const p=ue.pie().value($=>$.valor).sort(null).padAngle(0).startAngle(y?-Math.PI/2:0).endAngle(y?Math.PI/2:2*Math.PI),s=ue.arc().innerRadius(Ee*.62).outerRadius(Ee).cornerRadius(4);return p([{valor:h},{valor:100-h}]).map($=>({arco:$,ruta:s($)??""}))},[h,y]),x=y?`-${Ee+12} -${Ee+12} ${2*Ee+24} ${Ee+24}`:`-${Ee+12} -${Ee+12} ${2*Ee+24} ${2*Ee+24}`,m=n.jsxs(c.Box,{sx:{position:"relative",height:a,display:"flex",alignItems:"center",justifyContent:"center"},children:[n.jsx(c.Box,{component:"svg",viewBox:x,sx:{width:"100%",height:"100%",maxHeight:a,overflow:"visible"},children:u.map((p,s)=>n.jsx("path",{d:p.ruta,fill:s===0?f.color(t):v},s))}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",pointerEvents:"none",transform:y?"translateY(28%)":"none"},children:[n.jsxs(c.Typography,{variant:"h4",fontWeight:800,color:"text.primary",lineHeight:1.1,children:[h,"%"]}),o&&n.jsx(c.Typography,{variant:"body2",color:"text.secondary",children:o})]})]});return i?n.jsx(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${d.palette.divider}`,bgcolor:d.palette.background.paper,boxShadow:d.shadows[1]},children:m}):m},ke={arriba:6,derecha:8,abajo:25,izquierda:28},jt={lineal:ue.curveLinear,suave:ue.curveMonotoneX,escalon:ue.curveStep},Sa=(e,r)=>e instanceof Date?e.toLocaleDateString("es-ES",r?{month:"short",year:"2-digit"}:{day:"2-digit",month:"short"}):String(e),ja=({series:e,datos:r,titulo:t,subtitulo:o,alto:a=288,curva:i="suave",color:d,colorLinea:f,gradiente:y=!0,contorno:h=!1,apilado:v=!1,conCuadricula:u=!0,conPapel:x=!0})=>{const m=pe(),p=ce(),s=ne.useMemo(()=>e&&e.length>0?e:r&&r.length>0?[{nombre:t??"Serie",datos:r,color:d}]:[],[e,r,t,d]),$=ne.useMemo(()=>{const w=s[0]?.datos.map(I=>I.etiqueta)??[],j=w.map(()=>0),b=v?Math.max(...w.map((I,U)=>s.reduce((C,O)=>C+(O.datos[U]?.valor??0),0)),1):le.max(s.flatMap(I=>I.datos.map(U=>U.valor)))??1,g=oe.scaleLinear().domain([0,b]).range([100,0]),S=w[0];let B;if(S instanceof Date){const I=w.filter(C=>C instanceof Date),U=oe.scaleTime().domain(le.extent(I)).range([0,100]);B=C=>U(C)}else if(typeof S=="number"){const I=w,U=oe.scaleLinear().domain([le.min(I)??0,le.max(I)??0]).range([0,100]);B=C=>U(C)}else{const I=w.map(C=>String(C)),U=oe.scalePoint().domain(I).range([0,100]);B=C=>U(String(C))??0}const _=s.map(I=>{const U=I.datos.map((D,V)=>{const L=v?j[V]:0,F=L+D.valor;return v&&(j[V]=F),{etiqueta:D.etiqueta,base:L,total:F}}),C=ue.area().x(D=>B(D.etiqueta)).y0(D=>g(D.base)).y1(D=>g(D.total)).curve(jt[i]),O=ue.line().x(D=>B(D.etiqueta)).y(D=>g(D.total)).curve(jt[i]);return{area:C(U)??"",linea:O(U)??""}}),M=g.ticks(5).map(I=>({posicion:g(I),texto:String(I)})),Y=g.ticks(5).map(I=>g(I)),P=w.length,l=Math.min(5,P),A=Array.from(new Set(l<=1?[0]:Array.from({length:l},(I,U)=>Math.round(U*(P-1)/(l-1))))).filter(I=>I>=0&&I<P),k=w[0],W=w[P-1],z=k instanceof Date&&W instanceof Date&&k.getFullYear()!==W.getFullYear(),N=A.map((I,U)=>({posicion:B(w[I]),texto:Sa(w[I],z),anclaje:U===0?"inicio":U===A.length-1?"fin":"centro"}));return{capas:_,marcasY:M,marcasX:N,posicionesCuadricula:Y}},[s,i,v]),E=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:a},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${ke.arriba}px - ${ke.abajo}px)`,width:`${ke.izquierda}px`,transform:`translateY(${ke.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:$.marcasY})}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${ke.arriba}px - ${ke.abajo}px)`,width:`calc(100% - ${ke.izquierda}px - ${ke.derecha}px)`,transform:`translate(${ke.izquierda}px, ${ke.arriba}px)`,overflow:"visible"},children:[n.jsxs(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{width:"100%",height:"100%",overflow:"visible"},children:[n.jsx("defs",{children:s.map((w,j)=>{const b=w.color?p.color(w.color):d?p.color(d):p.serie(j);return n.jsxs("linearGradient",{id:`codeplex-area-${j}`,x1:"0",x2:"0",y1:"0",y2:"1",children:[n.jsx("stop",{offset:"0%",stopColor:b,stopOpacity:.45}),n.jsx("stop",{offset:"100%",stopColor:b,stopOpacity:.02})]},w.nombre)})}),u&&n.jsx(Re,{posiciones:$.posicionesCuadricula}),$.capas.map((w,j)=>{const b=s[j],g=b.color?p.color(b.color):d?p.color(d):p.serie(j),S=f?p.color(f):g,B=h?g:y?`url(#codeplex-area-${j})`:g,_=h?.12:y?1:.35;return n.jsxs("g",{children:[n.jsx("path",{d:w.area,fill:B,fillOpacity:_}),n.jsx("path",{d:w.linea,fill:"none",stroke:S,strokeWidth:h?2.5:2,strokeLinejoin:"round",strokeLinecap:"round",vectorEffect:"non-scaling-stroke"})]},b.nombre)})]}),n.jsx(c.Box,{sx:{position:"relative",mt:1},children:n.jsx(Ar,{marcas:$.marcasX})})]})]});return x?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${m.palette.divider}`,bgcolor:m.palette.background.paper,boxShadow:m.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),E]}):E},Be={arriba:8,derecha:8,abajo:28,izquierda:32},Ta=({datos:e,series:r,titulo:t,subtitulo:o,alto:a=288,color:i,conCuadricula:d=!0,conTooltip:f=!0,conLeyenda:y=!0,conPapel:h=!0})=>{const v=pe(),u=ce(),x=ne.useMemo(()=>r&&r.length>0?r.map((w,j)=>({nombre:w.nombre,color:w.color,puntos:w.puntos,indice:j})):[{color:i,puntos:e??[],indice:0}],[r,e,i]),m=y&&!!(r&&r.length>0),p=(w,j)=>w.color?u.color(w.color):j.color?u.color(j.color):u.serie(j.indice),s=ne.useMemo(()=>{const w=x.flatMap(l=>l.puntos),j=le.extent(w,l=>l.x),b=le.extent(w,l=>l.y),g=oe.scaleLinear().domain([j[0]??0,j[1]??0]).nice().range([0,100]),S=oe.scaleLinear().domain([b[0]??0,b[1]??0]).nice().range([100,0]),B=S.ticks(5).map(l=>({posicion:S(l),texto:String(l)})),_=g.ticks(5).map(l=>({posicion:g(l),texto:String(l)})),M=S.ticks(5).map(l=>S(l)),Y=g.ticks(5).map(l=>g(l)),P=w.some(l=>l.icono);return{escalaX:g,escalaY:S,marcasY:B,marcasX:_,posicionesCuadriculaY:M,posicionesCuadriculaX:Y,tieneIconos:P}},[x]),$=n.jsxs(c.Box,{sx:{position:"relative",width:"100%",height:a},children:[n.jsx(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Be.arriba}px - ${Be.abajo}px)`,width:`${Be.izquierda}px`,transform:`translateY(${Be.arriba}px)`,overflow:"visible"},children:n.jsx(cr,{marcas:s.marcasY})}),n.jsxs(c.Box,{sx:{position:"absolute",inset:0,height:`calc(100% - ${Be.arriba}px - ${Be.abajo}px)`,width:`calc(100% - ${Be.izquierda}px - ${Be.derecha}px)`,transform:`translate(${Be.izquierda}px, ${Be.arriba}px)`,overflow:"visible"},children:[n.jsxs(c.Box,{component:"svg",viewBox:"0 0 100 100",preserveAspectRatio:"none",sx:{width:"100%",height:"100%",overflow:"visible"},children:[d&&n.jsxs(n.Fragment,{children:[n.jsx(Re,{posiciones:s.posicionesCuadriculaY}),n.jsx(Re,{posiciones:s.posicionesCuadriculaX,orientacion:"vertical"})]}),x.flatMap(w=>w.puntos.map((j,b)=>{const g=s.escalaX(j.x),S=s.escalaY(j.y),B=p(j,w),_=`${w.indice}-${b}`,M=n.jsxs(n.Fragment,{children:[!j.icono&&n.jsx("path",{d:`M ${g} ${S} l 0.0001 0`,stroke:B,strokeWidth:9,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke",opacity:.85}),n.jsx("path",{d:`M ${g} ${S} l 0.0001 0`,stroke:"transparent",strokeWidth:18,strokeLinecap:"round",fill:"none",vectorEffect:"non-scaling-stroke"})]});return f?n.jsxs(ir,{children:[n.jsx(Ke,{children:M}),n.jsxs(sr,{children:[(j.etiqueta||w.nombre)&&n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:j.etiqueta??w.nombre}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,color:"text.primary",children:["x: ",j.x.toLocaleString("es-ES")," · y:"," ",j.y.toLocaleString("es-ES")]})]})]},_):n.jsx("g",{children:M},_)}))]}),s.tieneIconos&&n.jsx(c.Box,{sx:{position:"absolute",top:0,left:0,width:"100%",height:"100%",pointerEvents:"none"},children:x.flatMap(w=>w.puntos.map((j,b)=>{if(!j.icono)return null;const g=s.escalaX(j.x),S=s.escalaY(j.y);return n.jsx(c.Box,{sx:{position:"absolute",left:`${g}%`,top:`${S}%`,transform:"translate(-50%, -50%)",width:28,height:28,borderRadius:"50%",overflow:"hidden","& img, & svg":{width:"100%",height:"100%"}},children:j.icono},`logo-${w.indice}-${b}`)}))}),n.jsx(c.Box,{sx:{position:"relative",mt:1},children:n.jsx(Ar,{marcas:s.marcasX})})]})]}),E=m?n.jsxs(c.Box,{children:[n.jsx(c.Stack,{direction:"row",spacing:2,flexWrap:"wrap",sx:{mb:1.5},children:x.map(w=>n.jsxs(c.Stack,{direction:"row",spacing:.75,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"50%",bgcolor:w.color?u.color(w.color):u.serie(w.indice),flexShrink:0}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:w.nombre})]},w.indice))}),$]}):$;return h?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${v.palette.divider}`,bgcolor:v.palette.background.paper,boxShadow:v.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),E]}):E},Tt=15,Ca=({datos:e,variante:r="solido",alto:t=280,titulo:o,subtitulo:a,conPapel:i=!0})=>{const d=pe(),f=ce(),y=ne.useMemo(()=>{const u={name:"root",children:e.map((p,s)=>({name:p.grupo,indiceGrupo:s,children:p.items.map($=>({name:$.nombre,valor:$.valor,icono:$.icono}))}))},x=hr.hierarchy(u).sum(p=>p.valor??0).sort((p,s)=>(s.value??0)-(p.value??0));return hr.treemap().size([100,100]).paddingInner(.75).paddingOuter(1).round(!1)(x).leaves()},[e]),h=u=>{const x=u.parent?.data.indiceGrupo??0,m=e[x];return m?.color?f.color(m.color):f.serie(x)},v=n.jsx(c.Box,{sx:{position:"relative",width:"100%",height:t},children:y.map((u,x)=>{const m=u.x1-u.x0,p=u.y1-u.y0,s=h(u),$=m>Tt&&p>Tt,E=r==="gradiente"?`linear-gradient(180deg, ${s}, ${s}bb)`:s;return n.jsx(c.Tooltip,{arrow:!0,title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:u.data.name}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:(u.value??0).toLocaleString("es-ES")})]}),children:n.jsx(c.Box,{sx:{position:"absolute",left:`${u.x0}%`,top:`${u.y0}%`,width:`${m}%`,height:`${p}%`,borderRadius:"6px",border:"1px solid rgba(255, 255, 255, 0.25)",background:E,color:d.palette.common.white,p:.75,boxSizing:"border-box",overflow:"hidden",display:"flex",flexDirection:"column",alignItems:r==="logos"?"center":"flex-start",justifyContent:"center"},children:r==="logos"?u.data.icono&&n.jsx(c.Box,{sx:{width:36,height:36,"& img, & svg":{width:"100%",height:"100%"}},children:u.data.icono}):$&&n.jsxs(n.Fragment,{children:[n.jsx(c.Typography,{sx:{fontSize:13,fontWeight:600,lineHeight:1.2,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%"},children:u.data.name}),n.jsx(c.Typography,{sx:{fontSize:12,opacity:.85},children:(u.value??0).toLocaleString("es-ES")})]})})},x)})});return i?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${d.palette.divider}`,bgcolor:d.palette.background.paper,boxShadow:d.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),v]}):v},Ct=e=>"valor"in e,Ve=1e3,Ea=({datos:e,alto:r=300,titulo:t,subtitulo:o,conPapel:a=!0})=>{const i=pe(),d=ce(),f=ne.useMemo(()=>{const h=new Map;for(const m of e)h.has(m.grupo)||h.set(m.grupo,h.size);const v=hr.hierarchy({children:e}).sum(m=>Ct(m)?m.valor:0);return{nodos:hr.pack().size([Ve,Ve]).padding(12)(v).leaves().filter(m=>Ct(m.data)).map(m=>{const p=m.data,s=h.get(p.grupo)??0;return{nombre:p.nombre,grupo:p.grupo,valor:p.valor,x:m.x,y:m.y,r:m.r,relleno:p.color?d.color(p.color):d.serie(s)}})}},[e,d]),y=n.jsx(c.Box,{sx:{position:"relative",width:"100%",height:r,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(c.Box,{sx:{position:"relative",height:"100%",aspectRatio:"1 / 1",maxWidth:"100%"},children:f.nodos.map((h,v)=>{const u=h.r/Ve*100>7;return n.jsx(c.Tooltip,{arrow:!0,title:n.jsxs(c.Box,{children:[n.jsx(c.Typography,{variant:"caption",sx:{opacity:.7},children:h.grupo}),n.jsxs(c.Typography,{variant:"body2",fontWeight:700,children:[h.nombre," · ",h.valor.toLocaleString("es-ES")]})]}),children:n.jsx(c.Box,{sx:{position:"absolute",left:`${h.x/Ve*100}%`,top:`${h.y/Ve*100}%`,width:`${h.r*2/Ve*100}%`,height:`${h.r*2/Ve*100}%`,transform:"translate(-50%, -50%)",borderRadius:"50%",backgroundColor:h.relleno,border:`1px solid ${i.palette.common.white}33`,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",overflow:"hidden",cursor:"default",transition:"filter 0.2s","&:hover":{filter:"brightness(1.08)"}},children:u&&n.jsxs(n.Fragment,{children:[n.jsx(c.Typography,{sx:{color:i.palette.common.white,fontSize:11,fontWeight:600,lineHeight:1.1,textAlign:"center",whiteSpace:"nowrap"},children:h.nombre}),n.jsx(c.Typography,{sx:{color:i.palette.common.white,fontSize:10,opacity:.75,lineHeight:1.1},children:h.valor.toLocaleString("es-ES")})]})})},`${h.nombre}-${v}`)})})});return a?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${i.palette.divider}`,bgcolor:i.palette.background.paper,boxShadow:i.shadows[1]},children:[(t||o)&&n.jsxs(c.Box,{sx:{mb:2},children:[t&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:t}),o&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:o})]}),y]}):y},ka=48,Ba=8,Aa=({datos:e,gradiente:r=!0,alto:t=280,titulo:o,subtitulo:a,conPapel:i=!0})=>{const d=pe(),f=ce(),y=ne.useMemo(()=>[...e].sort((x,m)=>m.valor-x.valor),[e]),h=ne.useMemo(()=>y.reduce((x,m)=>Math.max(x,m.valor),0)||1,[y]),v=(x,m)=>{const p=x.color?f.color(x.color):f.serie(m);return r?`linear-gradient(180deg, ${p}, ${p}cc)`:p},u=n.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",gap:`${Ba}px`,width:"100%",height:t,justifyContent:"center"},children:y.map((x,m)=>{const p=x.valor/h*100;return n.jsxs(c.Box,{sx:{position:"relative",alignSelf:"center",width:`${p}%`,height:`${ka}px`,flexShrink:0,borderRadius:1.5,background:v(x,m),display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",overflow:"hidden"},children:[n.jsx(c.Typography,{variant:"caption",sx:{color:d.palette.common.white,fontWeight:600,lineHeight:1.2,whiteSpace:"nowrap"},children:x.clave}),n.jsx(c.Typography,{sx:{color:d.palette.common.white,fontSize:12,fontWeight:700,fontFamily:"monospace"},children:x.valor})]},`${x.clave}-${m}`)})});return i?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${d.palette.divider}`,bgcolor:d.palette.background.paper,boxShadow:d.shadows[1]},children:[(o||a)&&n.jsxs(c.Box,{sx:{mb:2},children:[o&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:o}),a&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:a})]}),u]}):u},Me=150,Et=5,Ra=({ejes:e,series:r,variante:t="lineal",conPuntos:o=!1,conLeyenda:a=!1,alto:i=300,titulo:d,subtitulo:f,conPapel:y=!0})=>{const h=pe(),v=ce(),u=ne.useMemo(()=>{const p=e.length,s=Math.PI*2/Math.max(p,1),$=Math.max(1,...r.flatMap(b=>b.valores)),E=oe.scaleLinear().range([0,Me]).domain([0,$]),w=ue.lineRadial().radius(b=>E(b)).angle((b,g)=>g*s).curve(t==="redondeado"?ue.curveCardinalClosed:ue.curveLinearClosed);return{anguloPorEje:s,rScale:E,generarTrazo:w,vertice:(b,g)=>{const S=s*b-Math.PI/2;return{x:g*Math.cos(S),y:g*Math.sin(S)}}}},[e,r,t]),x=(p,s)=>p.color?v.color(p.color):v.serie(s),m=n.jsxs(c.Stack,{spacing:2,alignItems:"center",sx:{width:"100%"},children:[n.jsx(c.Box,{sx:{width:"100%",height:i,display:"flex",alignItems:"center",justifyContent:"center"},children:n.jsx(c.Box,{component:"svg",viewBox:`0 0 ${Me*2} ${Me*2}`,sx:{height:"100%",maxHeight:i,overflow:"visible"},children:n.jsxs("g",{transform:`translate(${Me}, ${Me})`,children:[Array.from({length:Et}).map((p,s)=>n.jsx("circle",{cx:0,cy:0,r:Me/Et*(s+1),fill:"none",stroke:v.cuadricula,strokeWidth:.5},`anillo-${s}`)),e.map((p,s)=>{const $=u.vertice(s,Me);return n.jsx("line",{x1:0,y1:0,x2:$.x,y2:$.y,stroke:v.cuadricula,strokeWidth:.5},`eje-${s}`)}),r.map((p,s)=>{const $=u.generarTrazo(p.valores);if(!$)return null;const E=x(p,s);return n.jsx("path",{d:$,fill:E,fillOpacity:.25,stroke:E,strokeWidth:1.5},`serie-${p.nombre}`)}),o&&r[0]?.valores.map((p,s)=>{const $=u.vertice(s,u.rScale(p));return n.jsxs("g",{children:[n.jsx("circle",{cx:$.x,cy:$.y,r:11,fill:v.superficie,stroke:x(r[0],0),strokeWidth:1}),n.jsx("text",{x:$.x,y:$.y,dy:"0.35em",textAnchor:"middle",fontSize:10,fill:v.ejeTexto,children:p})]},`punto-${s}`)}),e.map((p,s)=>{const $=u.vertice(s,Me+16);return n.jsx("text",{x:$.x,y:$.y,dy:"0.35em",textAnchor:"middle",fontSize:13,fill:v.ejeTexto,children:p},`etq-${s}`)})]})})}),a&&n.jsx(c.Stack,{direction:"row",spacing:2,flexWrap:"wrap",justifyContent:"center",children:r.map((p,s)=>n.jsxs(c.Stack,{direction:"row",spacing:1,alignItems:"center",children:[n.jsx(c.Box,{sx:{width:10,height:10,borderRadius:"3px",bgcolor:x(p,s),flexShrink:0}}),n.jsx(c.Typography,{variant:"caption",color:"text.secondary",children:p.nombre})]},p.nombre))})]});return y?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${h.palette.divider}`,bgcolor:h.palette.background.paper,boxShadow:h.shadows[1]},children:[(d||f)&&n.jsxs(c.Box,{sx:{mb:2},children:[d&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:d}),f&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:f})]}),m]}):m},kt=e=>{const r=new Set,t=[];for(const o of e)r.has(o)||(r.add(o),t.push(o));return t},Oa=({datos:e,color:r="exito",alto:t=280,conValores:o=!1,titulo:a,subtitulo:i,conPapel:d=!0})=>{const f=pe(),y=ce(),h=ne.useMemo(()=>{const x=kt(e.map(j=>j.fila)),m=kt(e.map(j=>j.columna)),p=e.map(j=>j.valor),s=p.length>0?Math.min(...p):0,$=p.length>0?Math.max(...p):0,E=oe.scaleLinear().domain([s,$===s?s+1:$]).range([.12,1]),w=new Map;for(const j of e)w.set(`${j.fila}__${j.columna}`,j);return{filas:x,columnas:m,escalaIntensidad:E,indice:w}},[e]),v=y.color(r),u=n.jsxs(c.Box,{sx:{display:"flex",flexDirection:"column",width:"100%",height:t},children:[n.jsxs(c.Box,{sx:{display:"flex",flex:1,minHeight:0},children:[n.jsx(c.Box,{sx:{display:"flex",flexDirection:"column",justifyContent:"space-around",pr:1,flexShrink:0},children:h.filas.map(x=>n.jsx(c.Typography,{variant:"caption",sx:{color:y.ejeTexto,whiteSpace:"nowrap",textAlign:"right"},children:x},x))}),n.jsx(c.Box,{sx:{flex:1,minWidth:0,display:"grid",gap:.5,gridTemplateColumns:`repeat(${h.columnas.length}, 1fr)`,gridTemplateRows:`repeat(${h.filas.length}, 1fr)`},children:h.filas.map(x=>h.columnas.map(m=>{const p=h.indice.get(`${x}__${m}`),s=p?h.escalaIntensidad(p.valor):0,$=p?Ye.alpha(v,s):Ye.alpha(y.cuadricula,.25),E=n.jsx(c.Box,{sx:{width:"100%",height:"100%",borderRadius:1,backgroundColor:$,display:"flex",alignItems:"center",justifyContent:"center",cursor:p?"default":"auto",transition:f.transitions.create("transform"),"&:hover":p?{transform:"scale(1.06)"}:void 0},children:o&&p&&n.jsx(c.Typography,{sx:{fontSize:11,fontVariantNumeric:"tabular-nums",color:s>.55?y.contraste(r):f.palette.text.primary},children:p.valor})});return p?n.jsx(c.Tooltip,{arrow:!0,placement:"top",title:n.jsxs(c.Box,{children:[n.jsxs(c.Typography,{variant:"caption",sx:{opacity:.7},children:[x," · ",m]}),n.jsx(c.Typography,{variant:"body2",fontWeight:700,children:p.valor.toLocaleString("es-ES")})]}),children:E},`${x}__${m}`):n.jsx(c.Box,{children:E},`${x}__${m}`)}))})]}),n.jsxs(c.Box,{sx:{display:"flex",pt:.75},children:[n.jsx(c.Box,{sx:{flexShrink:0,pr:1,visibility:"hidden"},children:h.filas.length>0&&n.jsx(c.Typography,{variant:"caption",children:h.filas.reduce((x,m)=>x.length>=m.length?x:m,"")})}),n.jsx(c.Box,{sx:{flex:1,minWidth:0,display:"grid",gap:.5,gridTemplateColumns:`repeat(${h.columnas.length}, 1fr)`},children:h.columnas.map(x=>n.jsx(c.Typography,{variant:"caption",sx:{color:y.ejeTexto,textAlign:"center",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x},x))})]})]});return d?n.jsxs(c.Paper,{elevation:0,sx:{p:3,borderRadius:4,border:`1px solid ${f.palette.divider}`,bgcolor:f.palette.background.paper,boxShadow:f.shadows[1]},children:[(a||i)&&n.jsxs(c.Box,{sx:{mb:2},children:[a&&n.jsx(c.Typography,{variant:"h6",fontWeight:700,color:"text.primary",children:a}),i&&n.jsx(c.Typography,{variant:"subtitle2",color:"text.secondary",children:i})]}),u]}):u};exports.CodeplexGraficoArea=ja;exports.CodeplexGraficoBarraLinea=ya;exports.CodeplexGraficoBarras=ua;exports.CodeplexGraficoBarrasApiladas=ha;exports.CodeplexGraficoBarrasDivergentes=ga;exports.CodeplexGraficoBarrasMultiples=ma;exports.CodeplexGraficoBurbujas=Ea;exports.CodeplexGraficoComparativa=xa;exports.CodeplexGraficoDesglose=fa;exports.CodeplexGraficoDispersion=Ta;exports.CodeplexGraficoEmbudo=Aa;exports.CodeplexGraficoLineas=pa;exports.CodeplexGraficoMapaCalor=Oa;exports.CodeplexGraficoMedidor=wa;exports.CodeplexGraficoPastel=$a;exports.CodeplexGraficoPuntosConectados=va;exports.CodeplexGraficoRadar=Ra;exports.CodeplexGraficoTooltip=ir;exports.CodeplexGraficoTreemap=Ca;exports.CodeplexGraficoVelas=ba;exports.GraficoTooltipContenido=sr;exports.GraficoTooltipDisparador=Ke;exports.agruparPorPeriodo=eo;exports.filtrarPorRango=Rt;exports.formatearFecha=Qt;exports.parsearFecha=Bt;
package/index.js CHANGED
@@ -5237,7 +5237,7 @@ const Ma = cr`
5237
5237
  alignItems: "center",
5238
5238
  justifyContent: "center",
5239
5239
  pointerEvents: "none",
5240
- pb: i ? 0 : void 0
5240
+ transform: i ? "translateY(28%)" : "none"
5241
5241
  },
5242
5242
  children: [
5243
5243
  a !== void 0 && /* @__PURE__ */ l(R, { variant: "h5", fontWeight: 800, color: "text.primary", children: a }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeplex-sac/graficos",
3
- "version": "0.0.22",
3
+ "version": "0.0.24",
4
4
  "type": "module",
5
5
  "main": "./index.js",
6
6
  "module": "./index.js",