import { useState, useEffect, useRef } from “react”;
const MATERIALS = [
“Орех Бруно D (дуб) Lamarty”,
“Графит К Lamarty”,
“Дуб Сонома R Lamarty”,
“Капучино светлый ЮГРА”,
“Белый гладкий Lamarty”,
“Венге Lamarty”,
];
const PRICES = {
“Орех Бруно D (дуб) Lamarty”: 549,
“Графит К Lamarty”: 549,
“Дуб Сонома R Lamarty”: 549,
“Капучино светлый ЮГРА”: 420,
“Белый гладкий Lamarty”: 490,
“Венге Lamarty”: 510,
};
const KIM = 0.88;
const EDGE_PRICE = 45;
const EDGE_KIM = 1.15;
const WORK = 0.4;
const MARGIN = 0.7;
const VAT = 0.0873;
function calcWardrobe(W, D, H, mat) {
const w = W / 1000, d = D / 1000, h = H / 1000;
const ppm = PRICES[mat] || 549;
const korpusArea = (2 * d * h) + (2 * d * w) + (d * w) + (3 * (d - 0.016) * (w - 0.032));
const fasadArea = 2 * ((w / 2) - 0.004) * (h - 0.032);
const dvpArea = (w - 0.032) * (h - 0.016);
const edgeLen = (2 * (2 * h + 2 * w)) + (2 * (2 * d + 2 * w)) + (3 * (w - 0.032)) + (2 * (2 * (w / 2 - 0.004) + 2 * (h - 0.032)));
const korpusCost = (korpusArea / KIM) * ppm;
const fasadCost = (fasadArea / KIM) * ppm;
const dvpCost = (dvpArea / KIM) * 99.6;
const edgeCost = (edgeLen * EDGE_KIM) * EDGE_PRICE;
const hw = 8 * 42 + 20 * 0.99 + 2 * 123.73 + 4 * 12 + 15 * 32 + 93;
const mat_total = korpusCost + fasadCost + dvpCost + edgeCost + hw;
const total = mat_total * (1 + WORK + MARGIN) * (1 + VAT);
return { korpusCost, fasadCost, dvpCost, edgeCost, hw, total, korpusArea, fasadArea };
}
function WardrobeIcon({ size = 40 }) {
return (
);
}
function WardrobePreview({ W, D, H }) {
const maxDim = Math.max(W, H, D);
const s = 180 / maxDim;
const pw = W * s, ph = H * s, pd = D * s * 0.4;
const ox = 20, oy = 20;
const doorGap = pw * 0.02;
const door1W = pw / 2 - doorGap;
return (