/* global React, Icon, Reveal */
const { useState: useStateCalc, useMemo: useMemoCalc } = React;
/* ===========================================================
Calculadora interactiva de ahorro y dimensionamiento
Lógica simplificada con valores plausibles para Chile.
=========================================================== */
const REGIONS = [
{ v: 'arica', label: 'Arica y Parinacota', psh: 7.1 },
{ v: 'tarapaca', label: 'Tarapacá', psh: 7.4 },
{ v: 'antofagasta', label: 'Antofagasta', psh: 7.8 },
{ v: 'atacama', label: 'Atacama', psh: 7.5 },
{ v: 'coquimbo', label: 'Coquimbo', psh: 6.8 },
{ v: 'valparaiso', label: 'Valparaíso', psh: 5.6 },
{ v: 'metropolitana', label: 'Metropolitana', psh: 5.4 },
{ v: 'libertador', label: "O'Higgins", psh: 5.5 },
{ v: 'maule', label: 'Maule', psh: 5.2 },
{ v: 'nuble', label: 'Ñuble', psh: 5.0 },
{ v: 'biobio', label: 'Biobío', psh: 4.7 },
{ v: 'araucania', label: 'La Araucanía', psh: 4.3 },
{ v: 'rios', label: 'Los Ríos', psh: 4.0 },
{ v: 'lagos', label: 'Los Lagos', psh: 3.8 },
];
const SECTORS = [
{ v: 'mineria', label: 'Minería' },
{ v: 'retail', label: 'Retail / Multi-sucursal' },
{ v: 'manufactura', label: 'Manufactura' },
{ v: 'agro', label: 'Agroindustria' },
{ v: 'logistica', label: 'Logística' },
{ v: 'publico', label: 'Servicio público' },
{ v: 'otro', label: 'Otro' },
];
const PROJECT_TYPES = [
{ v: 'autoconsumo', label: 'Autoconsumo' },
{ v: 'inyeccion', label: 'Inyección a red' },
{ v: 'pmgd', label: 'PMGD' },
];
function fmtCLP(n) {
if (n >= 1e9) return `$${(n / 1e9).toLocaleString('es-CL', { maximumFractionDigits: 2 })} mM`;
if (n >= 1e6) return `$${(n / 1e6).toLocaleString('es-CL', { maximumFractionDigits: 1 })} M`;
if (n >= 1e3) return `$${(n / 1e3).toLocaleString('es-CL', { maximumFractionDigits: 0 })} K`;
return `$${n.toLocaleString('es-CL', { maximumFractionDigits: 0 })}`;
}
function fmtInt(n) { return n.toLocaleString('es-CL', { maximumFractionDigits: 0 }); }
function calc({ kwhMonth, region, projectType }) {
const psh = (REGIONS.find((r) => r.v === region) || REGIONS[5]).psh;
const yieldRatio = 0.78; // performance ratio
const dailyKwh = kwhMonth / 30;
// Size kWp to cover ~85% of daytime consumption baseline
const coverage = projectType === 'pmgd' ? 1.4 : projectType === 'inyeccion' ? 1.1 : 0.85;
const kWp = (dailyKwh * coverage) / (psh * yieldRatio);
const m2 = kWp * 6; // ~6 m² per kWp
const capexClpPerKwp = projectType === 'pmgd' ? 750_000 : 850_000;
const capexLow = Math.round(kWp * capexClpPerKwp * 0.92);
const capexHigh = Math.round(kWp * capexClpPerKwp * 1.08);
const annualKwh = kWp * psh * 365 * yieldRatio;
const tarifa = 130; // CLP/kWh promedio industrial
const annualSavings = annualKwh * tarifa;
const monthlySavings = annualSavings / 12;
const payback = ((capexLow + capexHigh) / 2) / annualSavings;
// TIR for ~25y project life — clamp to realistic range for Chile industrial PV (12–22%).
const tir = Math.max(12, Math.min(22, 100 / payback));
const co2 = annualKwh * 0.4 / 1000; // ton/year (0.4 kg/kWh factor for SEN-ish)
return {
kWp: Math.round(kWp * 10) / 10,
m2: Math.round(m2),
capexLow,
capexHigh,
monthlySavings: Math.round(monthlySavings),
payback: Math.round(payback * 10) / 10,
tir: Math.round(tir * 10) / 10,
co2: Math.round(co2 * 10) / 10,
annualKwh: Math.round(annualKwh),
};
}
function Calculator({ onRequestPreFactibility }) {
const [kwh, setKwh] = useStateCalc(50000);
const [region, setRegion] = useStateCalc('valparaiso');
const [sector, setSector] = useStateCalc('manufactura');
const [ptype, setPtype] = useStateCalc('autoconsumo');
const out = useMemoCalc(() => calc({ kwhMonth: kwh, region, projectType: ptype }), [kwh, region, ptype]);
return (
03 — Calculadora técnica
Estimación referencial usando radiación solar real por región (NASA POWER) y tarifas industriales chilenas promedio.
El estudio detallado requiere visita técnica.
INPUTS · Parámetros del proyecto
¿Quieres una pre-factibilidad detallada?
Memoria PVsyst, layout preliminar, TIR/VPN auditable y estructura financiera. Entrega en 5 días hábiles.
Disclaimer: cifras referenciales basadas en datos NASA POWER y tarifas industriales chilenas promedio (~130 CLP/kWh).
Estudio detallado requiere análisis de perfil horario, contrato eléctrico vigente y levantamiento técnico de sitio.
Dimensiona tu planta en 60 segundos.