1import{r as o,j as e,I as O,f as J,a4 as Q,X as w,s as Y,R as re,a5 as K,a6 as ee,a7 as ne,a8 as ie}from"./index-I66EXJkq.js";import{R as ae,T as se}from"./_baseAssignValue-B6WzCh_V.js";import{L as oe}from"./LineChart-BtJasHGs.js";import{C as de,X as te,Y as le}from"./YAxis-Cx06t1qz.js";import{L as ce}from"./Line-BintXaB1.js";import{f as me}from"./MainContent-BcjOMdE7.js";import{B as ue}from"./BarChart-DTlfKPQk.js";import{B as xe,C as be}from"./generateCategoricalChart-D-Gav4Xi.js";const he=({onClose:r})=>e.jsxs("div",{role:"dialog","aria-modal":"true",className:"fixed inset-0 z-50 flex items-center justify-center p-4",children:[e.jsx("div",{className:"absolute inset-0 bg-black/60 backdrop-blur-sm animate-[fade-in_0.3s_ease-out]",onClick:r}),e.jsxs("div",{className:"relative bg-white dark:bg-zinc-900 rounded-2xl shadow-2xl w-full max-w-lg p-6 md:p-8 animate-[scale-in_0.3s_ease-out]",children:[e.jsx("button",{onClick:r,className:"absolute top-3 right-3 p-2 rounded-full text-slate-500 dark:text-zinc-400 hover:bg-slate-100 dark:hover:bg-zinc-800","aria-label":"Cerrar",children:e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",className:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),e.jsxs("h3",{className:"text-xl font-bold text-slate-800 dark:text-zinc-200 mb-6 flex items-center gap-3",children:[e.jsx(O,{className:"w-6 h-6 text-sky-500"}),"Acerca del Predictor Sociométrico"]}),e.jsxs("div",{className:"space-y-4 text-sm text-slate-600 dark:text-zinc-300",children:[e.jsxs("p",{children:["Este predictor utiliza un ",e.jsx("strong",{children:"modelo de regresión lineal"})," para estimar una tendencia social (variable dependiente) basándose en los valores de una o más variables predictoras (independientes)."]}),e.jsxs("p",{children:["La funcionalidad de ",e.jsx("strong",{children:"proyección"})," permite simular cómo cambiará el resultado a lo largo del tiempo si una de las variables independientes sigue una tendencia lineal (aumenta o disminuye a un ritmo constante)."]}),e.jsxs("p",{className:"text-xs italic text-slate-500 dark:text-zinc-400 mt-6",children:[e.jsx("strong",{children:"Nota:"})," Este es un modelo simplificado con fines demostrativos. Las predicciones se basan en coeficientes predefinidos y no en un análisis de regresión en tiempo real sobre tus datos."]})]})]})]}),H=({title:r,value:x,change:t,icon:d,colorClass:c})=>e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 p-4 rounded-xl flex items-start gap-4",children:[e.jsx("div",{className:`flex-shrink-0 p-3 rounded-full ${c.replace("text-","bg-").replace("600","100").replace("400","900/40")}`,children:re.cloneElement(d,{className:`w-6 h-6 ${c}`})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:r}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("p",{className:"text-2xl font-bold text-slate-800 dark:text-slate-200",children:x}),t&&e.jsx("p",{className:`text-sm font-semibold ${t.startsWith("+")?"text-green-500":"text-red-500"}`,children:t})]})]})]}),W={"Confianza Institucional":{intercept:50,rSquared:.82,coefficients:{"Exposición a Medios CrÃticos":-1.5,"Percepción de Corrupción (0-10)":-2.5,"Crecimiento PIB %":3,"Tasa de Paro %":-1.2}},"Polarización Social":{intercept:40,rSquared:.75,coefficients:{"Exposición a Medios CrÃticos":.8,"Desigualdad Gini":1.5,"Frecuencia Elecciones":2,"Crisis Económica (dummy 0/1)":10}}},pe=Object.values(W).flatMap(r=>Object.keys(r.coefficients)),Z=[...new Set(pe)],ge=()=>{var $;const[r,x]=o.useState("Confianza Institucional"),[t,d]=o.useState([{id:1,name:"Percepción de Corrupción (0-10)",value:"6.5"},{id:2,name:"Crecimiento PIB %",value:"1.2"}]),[c,y]=o.useState(12),[p,k]=o.useState((($=t[0])==null?void 0:$.id)||null),[M,C]=o.useState("-0.1"),[m,A]=o.useState(null),[v,P]=o.useState(!1),[g,S]=o.useState(null),[L,E]=o.useState(!1);o.useEffect(()=>{t.length>0&&!t.some(s=>s.id===p)&&k(t[0].id)},[t,p]);const B=()=>{P(!0),S(null),A(null),setTimeout(()=>{try{const s=W[r];if(!s)throw new Error("Modelo no encontrado.");if(p===null)throw new Error("Selecciona una variable para la proyección de tendencia.");const a=h=>{let u=s.intercept;return h.forEach(N=>{const f=s.coefficients[N.name];f!==void 0&&(u+=f*parseFloat(N.value))}),u}
1,l=a(t),b=parseFloat(M);if(isNaN(b))throw new Error("El valor del cambio mensual debe ser un número.");const i=t.map(h=>{if(h.id===p){const u=parseFloat(h.value);return{...h,value:(u+b*c).toString()}}return h}),T=a(i),G=Array.from({length:c+1},(h,u)=>{const N=t.map(f=>{if(f.id===p){const n=parseFloat(f.value);return{...f,value:(n+b*u).toString()}}return f});return{month:`Mes ${u}`,value:a(N)}}),q=Object.entries(s.coefficients).map(([h,u])=>({name:h,impact:Math.abs(u)}));q.sort((h,u)=>u.impact-h.impact);const V=q[0],U=`El modelo es más sensible a cambios en **'${V.name}'**. Un cambio de 1 punto en esta variable altera la predicción en **${V.impact.toFixed(2)}** puntos.`;A({currentValue:l,futureValue:T,equation:`${r} = ${s.intercept} + ...`,rSquared:s.rSquared,sensitivityAnalysis:U,chartData:G})}catch(s){S(s instanceof Error?s.message:"Ocurrió un error desconocido.")}finally{P(!1)}},1500)},I=()=>{const s=Z.find(a=>!t.some(l=>l.name===a))||"NuevaVariable";d(a=>[...a,{id:Date.now(),name:s,value:"0"}])},F=(s,a,l)=>{d(b=>b.map(i=>i.id===s?{...i,[a]:l}:i))},D=s=>{d(a=>a.filter(l=>l.id!==s))};return e.jsxs("div",{className:"animate-[fade-in_0.5s_ease-out]",children:[L&&e.jsx(he,{onClose:()=>E(!1)}),e.jsxs("div",{className:"grid grid-cols-1 xl:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6 relative",children:[e.jsx("button",{onClick:()=>E(!0),className:"absolute top-4 right-4 p-2 text-slate-400 hover:text-slate-600 dark:text-slate-500 dark:hover:text-slate-300",children:e.jsx(O,{className:"w-6 h-6"})}),e.jsx("h3",{className:"text-lg font-semibold text-slate-800 dark:text-slate-200 mb-4",children:"1. Configuración del Modelo"}),e.jsx("label",{className:"block text-sm font-medium text-slate-500 dark:text-slate-400 mb-1",children:"Variable a Predecir (Dependiente)"}),e.jsx("select",{value:r,onChange:s=>x(s.target.value),className:"w-full appearance-none bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm",children:Object.keys(W).map(s=>e.jsx("option",{value:s,children:s},s))})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-800 dark:text-slate-200",children:"2. Variables Predictoras (Independientes)"}),t.map(s=>e.jsxs("div",{className:"grid grid-cols-12 gap-2 items-center",children:[e.jsx("select",{value:s.name,onChange:a=>F(s.id,"name",a.target.value),className:"col-span-6 w-full appearance-none bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm",children:Z.map(a=>e.jsx("option",{value:a,children:a},a))}),e.jsx("input",{type:"number",step:"0.1",value:s.value,onChange:a=>F(s.id,"value",a.target.value),placeholder:"Valor",className:"col-span-4 w-full bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm"}),e.jsx("button",{type:"button",onClick:()=>D(s.id),disabled:t.length<=1,className:"col-span-2 text-red-500 hover:text-red-600 disabled:opacity-30",children:e.jsx(J,{className:"w-5 h-5 mx-auto"})})]},s.id)),e.jsxs("button",{type:"button",onClick:I,className:"text-sm font-semibold text-sky-600 hover:underline flex items-center gap-1",children:[e.jsx(Q,{className:"w-4 h-4"}),"Añadir Variable"]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6 space-y-4",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-800 dark:text-slate-200",children:"3. Proyección de Tendencia"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-500 dark:text-slate-400 mb-1",children:"Horizonte (meses)"}),e.jsx("input",{type:"number",min:"1",max:"60",value:c,onChange:s=>y(parseInt(s.target.value)),className:"w-full bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-500 dark:text-slate-400 mb-1",children:"Variable con tendencia"}),e.jsx("select",{value:p||"",onChange:s=>k(Number(s.target.value)),className:"w-full appearance-none bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm",children:t.map(s=>e.jsx("option",{value:s.id,children:s.name},s.id))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-slate-500 dark:text-slate-400 mb-1",children:"Cambio Mensual de la Variable"}),e.jsx("input",{type:"number",step:"0.1",value:M,onChange:s=>C(s.target.value),placeholder:"Ej: +0.1 o -0.5",className:"w-full bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm"})]})]}),e.jsx("button",{onClick:B,disabled:v,className:"w-full bg-sky-600 text-white font-bold py-3 px-6 rounded-lg shadow-lg hover:bg-sky-500",children:v?"Calculando...":"Calcular Predicción y Tendencia"})]}),e.jsxs("div",{className:"space-y-6",children:[!m&&!v&&!g&&e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6 h-full flex flex-col justify-center items-center text-center",children:[e.jsx(w,{className:"w-16 h-16 text-slate-300 dark:text-slate-600 mb-4"}),e.jsx("h4",{className:"font-bold text-slate-700 dark:text-slate-300",children:"Resultados de la Predicción"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mt-2",children:"Configura y ejecuta el modelo para ver los resultados aquÃ."})]}),v&&e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6 h-full flex flex-col justify-center items-center text-center",children:[e.jsx(w,{className:"w-8 h-8 text-sky-500 animate-pulse mb-4"}),e.jsx("p",{children:"Ejecutando modelo predictivo..."})]}),g&&e.jsx("div",{className:"bg-red-100 border border-red-400 text-red-700 p-4 rounded-lg",children:g}),m&&e.jsxs("div",{className:"space-y-6 animate-[fade-in-up_0.5s_ease-out]",children:[e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-slate-800 dark:text-slate-200 mb-4",children:"Resultados de la Predicción"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:[e.jsx(H,{title:"Valor Actual",value:m.currentValue.toFixed(2),icon:e.jsx(Y,{}),colorClass:"text-sky-600 dark:text-sky-400"}),e.jsx(H,{title:"Valor Proyectado",value:m.futureValue.toFixed(2),change:`${m.futureValue-m.currentValue>=0?"+":""}${(m.futureValue-m.currentValue).toFixed(2)}`,icon:e.jsx(Y,{}
1),colorClass:"text-purple-600 dark:text-purple-400"}),e.jsx(H,{title:"R-Cuadrado",value:m.rSquared.toFixed(2),icon:e.jsx(w,{}),colorClass:"text-amber-600 dark:text-amber-400"})]})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6",children:[e.jsxs("h4",{className:"font-semibold text-slate-700 dark:text-slate-300 mb-4",children:["Gráfico de Proyección a ",c," Meses"]}),e.jsx("div",{className:"w-full h-64",children:e.jsx(ae,{children:e.jsxs(oe,{data:m.chartData,margin:{top:5,right:20,bottom:5,left:-10},children:[e.jsx(de,{strokeDasharray:"3 3",stroke:"rgba(128,128,128,0.1)"}),e.jsx(te,{dataKey:"month",fontSize:10,tick:{fill:"#64748b"}}),e.jsx(le,{fontSize:10,tick:{fill:"#64748b"},domain:["dataMin - 2","dataMax + 2"]}),e.jsx(se,{contentStyle:{backgroundColor:"rgba(255, 255, 255, 0.9)",backdropFilter:"blur(4px)",borderRadius:"0.5rem"}}),e.jsx(ce,{type:"monotone",dataKey:"value",name:r,stroke:"#3b82f6",strokeWidth:2,dot:{r:2},activeDot:{r:5}})]})})})]}),e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6",children:[e.jsxs("h4",{className:"font-semibold text-slate-700 dark:text-slate-300 mb-2 flex items-center gap-2",children:[e.jsx(w,{className:"w-5 h-5 text-sky-500"}),"Análisis de Sensibilidad (IA Simulado)"]}),e.jsx("p",{className:"text-sm text-slate-600 dark:text-slate-400",dangerouslySetInnerHTML:{__html:m.sensitivityAnalysis.replace(/\*\*(.*?)\*\*/g,'<strong class="text-slate-800 dark:text-slate-200">$1</strong>')}})]})]})]})]})]})},fe=()=>{const[r,x]=o.useState("El resultado de (variable_A * 30) - (variable_B * 10) será mayor que 2000."),[t,d]=o.useState([{id:1,name:"variable_A",mean:"100",stdDev:"10"},{id:2,name:"variable_B",mean:"50",stdDev:"5"}]),[c,y]=o.useState("(variable_A * 30) - (variable_B * 10)"),[p,k]=o.useState(">"),[M,C]=o.useState("2000"),[m,A]=o.useState(1e4),[v,P]=o.useState(!1),[g,S]=o.useState(null),[L,E]=o.useState(null),B=()=>{const a=Date.now(),l=`variable_${String.fromCharCode(65+t.length)}`;d([...t,{id:a,name:l,mean:"0",stdDev:"0"}])},I=(a,l,b)=>{d(t.map(i=>i.id===a?{...i,[l]:b}:i))},F=a=>{d(t.filter(l=>l.id!==a))},D=a=>{a==="electoral"?(x("La suma de escaños de PSOE y Sumar superará los 150 escaños."),d([{id:1,name:"esc_PSOE",mean:"121",stdDev:"5"},{id:2,name:"esc_Sumar",mean:"31",stdDev:"4"}]),y("esc_PSOE + esc_Sumar"),k(">"),C("150")):a==="referendum"?(x("La aprobación del referéndum (voto SÃ) superará el 50% del voto emitido."),d([{id:1,name:"voto_Si",mean:"48",stdDev:"3"},{id:2,name:"voto_No",mean:"45",stdDev:"3"}]),y("(voto_Si / (voto_Si + voto_No)) * 100"),k(">"),C("50")):(x("La participación total será superior al 65%."),d([{id:1,name:"participacion_urbana",mean:"68",stdDev:"4"},{id:2,name:"participacion_rural",mean:"60",stdDev:"5"},{id:3,name:"peso_urbano",mean:"70",stdDev:"2"}]),y("(participacion_urbana * (peso_urbano / 100)) + (participacion_rural * (1 - (peso_urbano / 100)))"),k(">"),C("65")),S(null),E(null)},$=(a,l)=>{let b=0,i=0;for(;b===0;)b=Math.random();for(;i===0;)i=Math.random();return Math.sqrt(-2*Math.log(b))*Math.cos(2*Math.PI*i)*l+a},s=()=>{P(!0),E(null),S(null),setTimeout(()=>{try{if(!c.trim())throw new Error("La fórmula no puede estar vacÃa.");if(t.some(n=>!n.name.trim()||!/^[a-zA-Z_]\w*$/.test(n.name)))throw new Error("Los nombres de las variables deben ser válidos (empezar con letra o _, sin espacios ni sÃmbolos).");const a=parseFloat(M);if(isNaN(a))throw new Error("El valor de la condición debe ser un número.");const l=t.map(n=>n.name),b=new Function(...l,`return ${c};`),i=[];for(let n=0;n<m;n++){const j=t.map(R=>{const z=parseFloat(R.mean),X=parseFloat(R.stdDev);if(isNaN(z)||isNaN(X))throw new Error(`Variable '${R.name}' tiene valores no numéricos.`);return $(z,X)}),_=b(...j);if(typeof _!="number"||isNaN(_))throw new Error(`La fórmula produjo un resultado no numérico en la simulación #${n+1}. Revisa la expresión.`);i.push(_)}const G=i.filter(n=>{switch(p){case">":return n>a;case"<":return n<a;case"=":return Math.abs(n-a)<1e-9;default:return!1}}).length/m*100,q=i.reduce((n,j)=>n+j,0)/m,V=Math.min(...i),u=(Math.max(...i)-V)/30,N={};
1i.forEach(n=>{const j=Math.floor((n-V)/u),_=V+j*u,R=_+u,z=`${Math.round(_)}-${Math.round(R)}`;N[z]=(N[z]||0)+1});const f=Object.entries(N).map(([n,j])=>({range:n,count:j})).sort((n,j)=>parseFloat(n.range)-parseFloat(j.range));S({successRate:G,averageResult:q,chartData:f})}catch(a){E(a instanceof Error?a.message:"Ocurrió un error desconocido durante la simulación.")}finally{P(!1)}},100)};return e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6 lg:p-8 grid grid-cols-1 lg:grid-cols-2 gap-8",children:[e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-slate-800 dark:text-slate-200 mb-2",children:"¿No sabe por dónde empezar? Pruebe un ejemplo:"}),e.jsxs("div",{className:"grid grid-cols-3 gap-3 text-sm",children:[e.jsxs("button",{onClick:()=>D("electoral"),className:"flex flex-col items-center justify-center gap-2 p-3 bg-slate-50 dark:bg-slate-800/50 rounded-lg hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[e.jsx(K,{className:"w-6 h-6 text-sky-500"})," ",e.jsx("span",{className:"font-semibold",children:"Predicción Electoral"})]}),e.jsxs("button",{onClick:()=>D("referendum"),className:"flex flex-col items-center justify-center gap-2 p-3 bg-slate-50 dark:bg-slate-800/50 rounded-lg hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[e.jsx(ne,{className:"w-6 h-6 text-sky-500"})," ",e.jsx("span",{className:"font-semibold",children:"Aprobación de Referéndum"})]}),e.jsxs("button",{onClick:()=>D("participation"),className:"flex flex-col items-center justify-center gap-2 p-3 bg-slate-50 dark:bg-slate-800/50 rounded-lg hover:bg-slate-100 dark:hover:bg-slate-800 transition-colors",children:[e.jsx(ie,{className:"w-6 h-6 text-sky-500"})," ",e.jsx("span",{className:"font-semibold",children:"Estimación de Participación"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-slate-800 dark:text-slate-200",children:[e.jsx("span",{className:"flex items-center justify-center w-6 h-6 bg-sky-500 text-white rounded-full text-xs font-bold",children:"1"}),"Defina su Hipótesis"]}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:"Describa en una frase el escenario que quiere analizar. Esto ayudará a contextualizar los resultados."}),e.jsx("textarea",{value:r,onChange:a=>x(a.target.value),rows:2,className:"w-full bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-slate-800 dark:text-slate-200",children:[e.jsx("span",{className:"flex items-center justify-center w-6 h-6 bg-sky-500 text-white rounded-full text-xs font-bold",children:"2"}),"Ingrese Variables de Entrada ",e.jsx(O,{className:"w-4 h-4 text-slate-400"})]}),e.jsxs("div",{className:"p-4 bg-slate-50 dark:bg-slate-800/50 rounded-lg space-y-3",children:[t.map(a=>e.jsxs("div",{className:"grid grid-cols-12 gap-2 items-center",children:[e.jsx("input",{type:"text",value:a.name,onChange:l=>I(a.id,"name",l.target.value),placeholder:"Nombre",className:"col-span-5 w-full bg-white dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm"}),e.jsx("input",{type:"number",value:a.mean,onChange:l=>I(a.id,"mean",l.target.value),placeholder:"Media",className:"col-span-3 w-full bg-white dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm"}),e.jsx("input",{type:"number",value:a.stdDev,onChange:l=>I(a.id,"stdDev",l.target.value),placeholder:"Desv. Est.",className:"col-span-3 w-full bg-white dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm"}),e.jsx("button",{onClick:()=>F(a.id),className:"col-span-1 text-slate-400 hover:text-red-500",children:e.jsx(J,{className:"w-5 h-5"})})]},a.id)),e.jsxs("button",{onClick:B,className:"text-sm font-semibold text-sky-600 hover:underline flex items-center gap-1",children:[e.jsx(Q,{className:"w-4 h-4"}),"Añadir Variable"]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-slate-800 dark:text-slate-200",children:[e.jsx("span",{className:"flex items-center justify-center w-6 h-6 bg-sky-500 text-white rounded-full text-xs font-bold",children:"3"}),"Defina la Fórmula de Resultado ",e.jsx(O,{className:"w-4 h-4 text-slate-400"})]}),e.jsx("input",{type:"text",value:c,onChange:a=>y(a.target.value),className:"w-full bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm font-mono"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("h4",{className:"flex items-center gap-2 font-semibold text-slate-800 dark:text-slate-200",children:[e.jsx("span",{className:"flex items-center justify-center w-6 h-6 bg-sky-500 text-white rounded-full text-xs font-bold",children:"4"}),"Defina la Condición y Nº de Simulaciones"]}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400",children:'Establezca el objetivo numérico que define el "éxito". A más simulaciones, más preciso será el resultado (Ley de los Grandes Números).'}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("select",{value:p,onChange:a=>k(a.target.value),className:"col-span-1 w-full bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm",children:[e.jsx("option",{value:">",children:"> (mayor que)"}),e.jsx("option",{value:"<",children:"< (menor que)"}),e.jsx("option",{value:"=",children:"= (igual que)"})]}),e.jsx("input",{type:"number",value:M,onChange:a=>C(a.target.value),className:"col-span-1 w-full bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm"}),e.jsxs("select",{value:m,onChange:a=>A(Number(a.target.value)),className:"col-span-1 w-full bg-slate-50 dark:bg-slate-800 border border-slate-300 dark:border-slate-700 rounded-md p-2 text-sm",children:[e.jsx("option",{value:1e3,children:"1,000 Simulaciones"}),e.jsx("option",{value:5e3,children:"5,000 Simulaciones"}),e.jsx("option",{value:1e4,children:"10,000 (Recomendado)"}),e.jsx("option",{value:5e4,children:"50,000 Simulaciones"})]})]})]}),e.jsx("button",{onClick:s,disabled:v,className:"w-full bg-sky-600 text-white font-bold py-3 px-6 rounded-lg shadow-lg hover:bg-sky-500 disabled:bg-slate-400 disabled:cursor-not-allowed",children:v?"Simulando...":"Ejecutar Simulación"})]}),e.jsxs("div",{className:"bg-slate-800 dark:bg-black p-6 rounded-2xl flex flex-col",children:[e.jsx("h3",{className:"text-xl font-bold text-white mb-6 text-center",children:"Resultados de la Simulación"}),v&&e.jsxs("div",{className:"flex flex-col items-center justify-center h-full min-h-[300px]",children:[e.jsx(w,{className:"w-12 h-12 text-sky-400 animate-pulse mb-4"}),e.jsx("p",{className:"text-lg font-semibold text-sky-300",children:"Calculando probabilidades..."})]}),L&&e.jsx("div",{className:"bg-red-900/50 border border-red-500 text-red-300 p-4 rounded-lg",children:L}),g&&e.jsxs("div",{className:"animate-[fade-in_0.5s_ease-out] flex flex-col flex-grow",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-slate-700/50 dark:bg-black/50 p-4 rounded-lg text-center",children:[e.jsx("p",{className:"text-sm text-slate-300",children:"Probabilidad de Ãxito"}),e.jsxs("p",{className:"text-4xl font-black text-green-400",children:[g.successRate.toFixed(2),"%"]})]}),e.jsxs("div",{className:"bg-slate-700/50 dark:bg-black/50 p-4 rounded-lg text-center",children:[e.jsx("p",{className:"text-sm text-slate-300",children:"Resultado Promedio"}),e.jsx("p",{className:"text-4xl font-black text-sky-400",children:me(g.averageResult,2)})]})]}),e.jsx("div",{className:"flex-grow w-full h-80",children:e.jsx(ae,{children:e.jsxs(ue,{data:g.chartData,margin:{top:5,right:5,bottom:5,left:-25}
1,children:[e.jsx(te,{dataKey:"range",fontSize:10,tick:{fill:"#94a3b8"},interval:"preserveStartEnd"}),e.jsx(le,{fontSize:10,tick:{fill:"#94a3b8"}}),e.jsx(se,{cursor:{fill:"rgba(128,128,128,0.1)"},contentStyle:{backgroundColor:"rgba(30, 41, 59, 0.9)",border:"1px solid #334155",borderRadius:"0.5rem"},labelStyle:{color:"#cbd5e1"},itemStyle:{color:"#0ea5e9",fontWeight:"bold"},formatter:a=>[`${a} veces`,"Frecuencia"]}),e.jsx(xe,{dataKey:"count",name:"Frecuencia",children:g.chartData.map((a,l)=>e.jsx(be,{fill:"#0ea5e9"},`cell-${l}`))})]})})}),e.jsxs("button",{className:"mt-6 w-full bg-slate-700 hover:bg-slate-600 text-white font-semibold py-2 px-4 rounded-lg flex items-center justify-center gap-2",children:[e.jsx(w,{className:"w-5 h-5"})," Interpretar Resultados con IA"]})]})]})]})},je=()=>{const r=({icon:x,title:t,children:d})=>e.jsxs("div",{className:"bg-slate-50 dark:bg-slate-800/50 p-6 rounded-xl ring-1 ring-slate-200/50 dark:ring-slate-800",children:[e.jsxs("div",{className:"flex items-center gap-4 mb-4",children:[e.jsx("div",{className:"flex-shrink-0 text-sky-600 dark:text-sky-400",children:x}),e.jsx("h3",{className:"text-lg font-bold text-slate-800 dark:text-slate-200",children:t})]}),e.jsx("div",{className:"space-y-3 text-sm text-slate-600 dark:text-slate-400 leading-relaxed",children:d})]});return e.jsxs("div",{className:"bg-white dark:bg-slate-900 rounded-xl shadow-lg p-6 lg:p-8",children:[e.jsx("h3",{className:"text-xl font-bold text-slate-800 dark:text-slate-200 mb-2",children:"GuÃa de Uso del Simulador"}),e.jsx("p",{className:"text-sm text-slate-500 dark:text-slate-400 mb-8",children:"Aprende a utilizar las herramientas de simulación para validar tus hipótesis y explorar escenarios."}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-8",children:[e.jsxs(r,{icon:e.jsx(K,{className:"w-8 h-8"}),title:"Simulador Monte Carlo",children:[e.jsx("p",{children:"Esta herramienta ejecuta miles de simulaciones de resultados para medir la probabilidad de cada escenario, considerando la incertidumbre inherente a las variables de entrada."}),e.jsx("h4",{className:"font-semibold text-slate-700 dark:text-slate-300 pt-3 border-t border-slate-200 dark:border-slate-700/50 mt-4",children:"Cómo usarlo:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[e.jsx("li",{children:"Define tu hipótesis en lenguaje natural."}),e.jsx("li",{children:"Identifica las variables inciertas, asÃgnales un nombre, un valor medio esperado (media) y un rango de incertidumbre (desviación estándar)."}),e.jsx("li",{children:"Escribe una fórmula matemática que conecte tus variables para calcular el resultado."}),e.jsx("li",{children:'Establece la condición de "éxito" y el número de simulaciones.'}),e.jsxs("li",{children:["Pulsa ",e.jsx("strong",{children:"'Ejecutar'"})," y analiza la probabilidad de que tu hipótesis se cumpla y la distribución de posibles resultados."]})]})]}),e.jsxs(r,{icon:e.jsx(ee,{className:"w-8 h-8"}),title:"Predictor Sociométrico",children:[e.jsx("p",{children:"Este modelo de regresión lineal te permite predecir cómo el cambio en ciertas variables sociales o económicas puede afectar a una tendencia general a lo largo del tiempo."}),e.jsx("h4",{className:"font-semibold text-slate-700 dark:text-slate-300 pt-3 border-t border-slate-200 dark:border-slate-700/50 mt-4",children:"Cómo usarlo:"}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1",children:[e.jsxs("li",{children:["Elige la ",e.jsx("strong",{children:"tendencia a predecir"})," (variable dependiente)."]}),e.jsxs("li",{children:["Añade una o más ",e.jsx("strong",{children:"variables predictoras"})," y sus valores actuales."]}),e.jsxs("li",{children:["Configura la ",e.jsx("strong",{children:"proyección"}),": selecciona qué variable cambiará, su ritmo de cambio mensual y durante cuántos meses."]}),e.jsxs("li",{children:["Pulsa ",e.jsx("strong",{children:"'Calcular'"})," para ver la tendencia futura y la fiabilidad del modelo."]})]})]})]})]})},ve=({id:r,label:x,activeTab:t,onClick:d,icon:c})=>e.jsxs("button",{onClick:()=>d(r),className:`flex items-center gap-2 px-4 py-3 text-sm font-semibold rounded-t-md transition-colors whitespace-nowrap border-b-2 -mb-px ${t===r?"border-sky-500 text-sky-600 dark:text-sky-400":"border-transparent text-slate-500 dark:text-slate-400 hover:text-slate-900 dark:hover:text-slate-100"}`,"aria-pressed":t===r,children:[c,x]},r),_e=()=>
1{const[r,x]=o.useState("monte-carlo"),t=[{id:"monte-carlo",label:"Simulador Monte Carlo",icon:e.jsx(K,{className:"w-5 h-5"})},{id:"predictor",label:"Predictor Sociométrico",icon:e.jsx(ee,{className:"w-5 h-5"})},{id:"instructions",label:"Instrucciones",icon:e.jsx(w,{className:"w-5 h-5"})}],d=()=>{switch(r){case"monte-carlo":return e.jsx(fe,{});case"predictor":return e.jsx(ge,{});case"instructions":return e.jsx(je,{});default:return null}};return e.jsxs("div",{className:"max-w-7xl mx-auto p-4 md:p-8",children:[e.jsxs("header",{className:"text-center mb-10",children:[e.jsx("h2",{className:"text-3xl md:text-4xl font-bold text-slate-800 dark:text-slate-200 mb-2",children:"Simulador Predictivo de Hipótesis"}),e.jsx("p",{className:"text-slate-500 dark:text-slate-400 max-w-3xl mx-auto",children:"Modela la incertidumbre, cuantifica probabilidades y obtén análisis para validar tus escenarios."})]}),e.jsx("div",{className:"mb-8 border-b border-slate-200 dark:border-slate-800",children:e.jsx("div",{className:"flex items-center space-x-1 overflow-x-auto [&::-webkit-scrollbar]:hidden [-ms-overflow-style:none] [scrollbar-width:none]",children:t.map(c=>e.jsx(ve,{id:c.id,label:c.label,activeTab:r,onClick:x,icon:c.icon},c.id))})}),e.jsx("div",{className:"animate-[fade-in_0.5s_ease-out]",children:d()})]})};export{_e as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.