(function () {
const POS = {
front: {
tq_right_arm: [31.5, 60],  tq_left_arm: [68.5, 60],
tq_right_leg: [43.5, 124], tq_left_leg: [56.5, 124],
chest_seal_r: [42.5, 65],  chest_seal_l: [57.5, 65],
needle_decomp_r: [43.5, 56.5], needle_decomp_l: [56.5, 56.5]
},
back: {
tq_right_arm: [68.5, 60],  tq_left_arm: [31.5, 60],
tq_right_leg: [56.5, 124], tq_left_leg: [43.5, 124]
}
};
const ORANGE = "#ff9d4d", CYAN = "#5ecae0", GREEN = "#6fd99a",
WHITE = "#e8eef0", AMBER = "#f4b04a", TAN = "#d8c49a";
function TqBand({ x, y, k }) {
return (
<g className="treat-mark treat-tq" key={k}>
<rect x={x - 6} y={y - 1.7} width="12" height="3.4" rx="1.2" fill={ORANGE} opacity="0.9" />
<rect x={x - 6} y={y - 0.3} width="12" height="0.6" fill="#7a3c0e" opacity="0.8" />
<rect x={x - 1.6} y={y - 2.9} width="3.2" height="2" rx="0.5" fill={ORANGE} />
<line x1={x + 1.6} y1={y - 2.1} x2={x + 5} y2={y - 4.4} stroke={ORANGE} strokeWidth="0.9" strokeLinecap="round" />
<text x={x} y={y + 6} textAnchor="middle" fontSize="3.4" fill={ORANGE} fontWeight="700" letterSpacing="0.4">TQ</text>
</g>
);
}
function Seal({ x, y, k }) {
return (
<g className="treat-mark treat-seal" key={k}>
<rect x={x - 5} y={y - 5} width="10" height="10" rx="1.4"
fill={CYAN} opacity="0.18" stroke={CYAN} strokeWidth="0.8" />
<circle cx={x} cy={y} r="1.5" fill="none" stroke={CYAN} strokeWidth="0.7" />
<circle cx={x} cy={y} r="0.5" fill={CYAN} />
</g>
);
}
function Needle({ x, y, k }) {
return (
<g className="treat-mark treat-ncd" key={k}>
<line x1={x + 3.4} y1={y - 5.4} x2={x} y2={y} stroke={WHITE} strokeWidth="0.8" strokeLinecap="round" />
<circle cx={x + 3.4} cy={y - 5.4} r="1.3" fill="none" stroke={CYAN} strokeWidth="0.8" />
<circle cx={x} cy={y} r="0.8" fill={CYAN} />
<text x={x + 6} y={y - 6.5} textAnchor="middle" fontSize="3" fill={CYAN} fontWeight="600">NCD</text>
</g>
);
}
function Cric({ k }) {
const x = 50, y = 32.5;
return (
<g className="treat-mark treat-cric" key={k}>
<circle cx={x} cy={y} r="2" fill="none" stroke={GREEN} strokeWidth="0.8" />
<circle cx={x} cy={y} r="0.7" fill={GREEN} />
<line x1={x - 4} y1={y} x2={x - 2.2} y2={y} stroke={GREEN} strokeWidth="0.7" />
<line x1={x + 2.2} y1={y} x2={x + 4} y2={y} stroke={GREEN} strokeWidth="0.7" />
</g>
);
}
function Mask({ k }) {
const x = 50, y = 24.5;
return (
<g className="treat-mark treat-mask" key={k}>
<path d={`M ${x - 4.6} ${y - 2} Q ${x} ${y - 4.6} ${x + 4.6} ${y - 2} L ${x + 3.2} ${y + 3} Q ${x} ${y + 4.6} ${x - 3.2} ${y + 3} Z`}
fill={CYAN} opacity="0.20" stroke={CYAN} strokeWidth="0.7" />
<path d={`M ${x - 4.6} ${y - 2} Q ${x - 8} ${y - 1} ${x - 9} ${y + 1}`} fill="none" stroke={CYAN} strokeWidth="0.5" />
<path d={`M ${x + 4.6} ${y - 2} Q ${x + 8} ${y - 1} ${x + 9} ${y + 1}`} fill="none" stroke={CYAN} strokeWidth="0.5" />
</g>
);
}
function Tube({ k }) {
const x = 50, y = 23;
return (
<g className="treat-mark treat-tube" key={k}>
<path d={`M ${x} ${y} C ${x} ${y - 5} ${x + 4} ${y - 7} ${x + 7} ${y - 7}`}
fill="none" stroke={WHITE} strokeWidth="1.1" strokeLinecap="round" />
<rect x={x - 1.6} y={y - 1} width="3.2" height="2" rx="0.6" fill={WHITE} opacity="0.85" />
</g>
);
}
function Collar({ k }) {
const x = 50, y = 34.5;
return (
<g className="treat-mark treat-collar" key={k}>
<rect x={x - 7} y={y - 2.4} width="14" height="4.8" rx="2"
fill={WHITE} opacity="0.22" stroke={WHITE} strokeWidth="0.7" />
<line x1={x - 7} y1={y} x2={x + 7} y2={y} stroke={WHITE} strokeWidth="0.4" opacity="0.7" />
</g>
);
}
function Binder({ k }) {
const x = 50, y = 116;
return (
<g className="treat-mark treat-binder" key={k}>
<rect x={x - 17} y={y - 3} width="34" height="6" rx="2.4"
fill={ORANGE} opacity="0.22" stroke={ORANGE} strokeWidth="0.8" />
<rect x={x - 2.6} y={y - 2} width="5.2" height="4" rx="0.8" fill={ORANGE} opacity="0.85" />
</g>
);
}
function Electrodes({ k }) {
const pts = [[44, 58.5], [56, 58.5], [50, 73]];
return (
<g className="treat-mark treat-ekg" key={k}>
{pts.map((p, i) => (
<g key={i}>
<circle cx={p[0]} cy={p[1]} r="1.5" fill={GREEN} opacity="0.85" />
<circle cx={p[0]} cy={p[1]} r="2.3" fill="none" stroke={GREEN} strokeWidth="0.4" opacity="0.5" />
</g>
))}
<path d={`M 44 58.5 Q 47 64 50 73 Q 53 64 56 58.5`} fill="none" stroke={GREEN} strokeWidth="0.35" opacity="0.45" />
</g>
);
}
function IvSite({ k }) {
const x = 31, y = 80.5;
return (
<g className="treat-mark treat-iv" key={k}>
<line x1={x - 2.4} y1={y - 2.4} x2={x + 1.2} y2={y + 1.2} stroke={GREEN} strokeWidth="0.9" strokeLinecap="round" />
<rect x={x - 2.2} y={y - 0.8} width="4.4" height="1.6" rx="0.5" fill={WHITE} opacity="0.65" transform={`rotate(45 ${x} ${y})`} />
<text x={x} y={y + 5.4} textAnchor="middle" fontSize="3" fill={GREEN} fontWeight="600">IV</text>
</g>
);
}
function Wrap({ k }) {
return (
<g className="treat-mark treat-wrap" key={k}>
<rect x="13" y="8" width="74" height="202" rx="10"
fill="none" stroke={AMBER} strokeWidth="0.9" strokeDasharray="3.4 2.4" opacity="0.75" />
<text x="50" y="216.5" textAnchor="middle" fontSize="3.6" fill={AMBER} fontWeight="700" letterSpacing="0.8">HPMK</text>
</g>
);
}
function Gauze({ x, y, k, moist }) {
const c = moist ? CYAN : WHITE;
return (
<g className="treat-mark treat-gauze" key={k}>
<circle cx={x} cy={y} r="5.6" fill={c} opacity="0.16" />
<circle cx={x} cy={y} r="5.6" fill="none" stroke={GREEN} strokeWidth="0.7" strokeDasharray="2 1.4" />
{[-2.6, 0, 2.6].map((d, i) => (
<line key={i} x1={x - 4} y1={y + d} x2={x + 4} y2={y + d} stroke={c} strokeWidth="0.45" opacity="0.7" />
))}
{[-2.6, 0, 2.6].map((d, i) => (
<line key={"v" + i} x1={x + d} y1={y - 4} x2={x + d} y2={y + 4} stroke={c} strokeWidth="0.45" opacity="0.7" />
))}
</g>
);
}
function Splint({ x, y, k }) {
return (
<g className="treat-mark treat-splint" key={k}>
<line x1={x - 4.6} y1={y - 9} x2={x - 4.6} y2={y + 9} stroke={TAN} strokeWidth="1.3" strokeLinecap="round" />
<line x1={x + 4.6} y1={y - 9} x2={x + 4.6} y2={y + 9} stroke={TAN} strokeWidth="1.3" strokeLinecap="round" />
{[-6, 0, 6].map((d, i) => (
<line key={i} x1={x - 4.6} y1={y + d} x2={x + 4.6} y2={y + d} stroke={TAN} strokeWidth="0.6" opacity="0.85" />
))}
</g>
);
}
const PACK_IDS  = ["wound_packed", "combat_gauze", "pressure_dressing", "direct_pressure", "junctional_tq"];
const PACK_TYPES = ["entry", "exit", "frag", "lac", "gsw", "amputation"];
const BURN_TYPES = ["burn", "burn_partial", "burn_full"];
function AppliedTreatments({ side, taken, tqStates, injuries }) {
const has = (id) => !!(taken && taken.has && taken.has(id));
const tqOn = (k) => (tqStates && tqStates[k]) || has(k);
const marks = [];
const pos = POS[side] || {};
["tq_right_arm", "tq_left_arm", "tq_right_leg", "tq_left_leg"].forEach((k) => {
if (tqOn(k) && pos[k]) marks.push(<TqBand key={k} k={k} x={pos[k][0]} y={pos[k][1]} />);
});
if (side === "front") {
if (has("chest_seal_r")) marks.push(<Seal key="csr" k="csr" x={pos.chest_seal_r[0]} y={pos.chest_seal_r[1]} />);
if (has("chest_seal_l")) marks.push(<Seal key="csl" k="csl" x={pos.chest_seal_l[0]} y={pos.chest_seal_l[1]} />);
if (has("needle_decomp_r")) marks.push(<Needle key="ndr" k="ndr" x={pos.needle_decomp_r[0]} y={pos.needle_decomp_r[1]} />);
if (has("needle_decomp_l")) marks.push(<Needle key="ndl" k="ndl" x={pos.needle_decomp_l[0]} y={pos.needle_decomp_l[1]} />);
if (has("airway_cric") || has("cric")) marks.push(<Cric key="cric" k="cric" />);
if (has("intubation") || has("sga_igel")) marks.push(<Tube key="tube" k="tube" />);
else if (has("o2_administered") || has("bvm_ventilation")) marks.push(<Mask key="mask" k="mask" />);
if (has("c_spine") || has("mils_cspine")) marks.push(<Collar key="collar" k="collar" />);
if (has("pelvic_binder")) marks.push(<Binder key="binder" k="binder" />);
if (has("monitor_ekg")) marks.push(<Electrodes key="ekg" k="ekg" />);
if (has("iv_io")) marks.push(<IvSite key="iv" k="iv" />);
if (has("hypothermia_kit")) marks.push(<Wrap key="wrap" k="wrap" />);
} else {
if (has("c_spine") || has("mils_cspine")) marks.push(<Collar key="collar-b" k="collar-b" />);
if (has("pelvic_binder")) marks.push(<Binder key="binder-b" k="binder-b" />);
}
const sideInj = (injuries || []).filter((i) => i.view === side);
const packed = PACK_IDS.some(has);
const dryDress = has("dry_dressing");
const moistCover = has("moist_cover_evisc");
const headWrap = has("head_wrap");
const splint = has("splint_extremity");
sideInj.forEach((inj, i) => {
const x = inj.x * 100, y = inj.y * 220;
const isHead = inj.y < 0.12;
if (splint && inj.type === "frac") {
marks.push(<Splint key={"sp" + i} k={"sp" + i} x={x} y={y} />);
return;
}
if (moistCover && inj.type === "evisceration") {
marks.push(<Gauze key={"g" + i} k={"g" + i} x={x} y={y} moist />);
return;
}
if (dryDress && BURN_TYPES.includes(inj.type)) {
marks.push(<Gauze key={"g" + i} k={"g" + i} x={x} y={y} />);
return;
}
if (headWrap && isHead) {
marks.push(<Gauze key={"g" + i} k={"g" + i} x={x} y={y} />);
return;
}
if (packed && PACK_TYPES.includes(inj.type) && !isHead) {
marks.push(<Gauze key={"g" + i} k={"g" + i} x={x} y={y} />);
}
});
return <g className="treat-layer">{marks}</g>;
}
window.AppliedTreatments = AppliedTreatments;
})();