{
const th = d3.range(0, 2 * Math.PI + 0.02, 0.02);
const esp = d3.range(0, Math.PI + 0.01, 0.01).map(t => [Math.exp(-z_lab / Math.sqrt(1 - z_lab ** 2) * t) * Math.cos(t), Math.exp(-z_lab / Math.sqrt(1 - z_lab ** 2) * t) * Math.sin(t)]);
const zr = polo.mod * Math.cos(polo.angPlegado), zi = polo.mod * Math.sin(polo.angPlegado);
const planoZ = Plot.plot({
width: 360, height: 360, aspectRatio: 1, grid: true, marginLeft: 40,
x: {domain: [-1.15, 1.15], label: "Re z"}, y: {domain: [-1.15, 1.15], label: "Im z"},
marks: [
Plot.line(th.map(t => [Math.cos(t), Math.sin(t)]), {stroke: "#6B7280"}),
Plot.line(esp, {stroke: "#D95F02", strokeDasharray: "4,3"}),
Plot.line(esp.map(([a, b]) => [a, -b]), {stroke: "#D95F02", strokeDasharray: "4,3"}),
Plot.line([[0, 0], [Math.cos(polo.angPlegado), Math.sin(polo.angPlegado)]], {stroke: "#1B6CA8", strokeDasharray: "4,3"}),
Plot.dot([[zr, zi], [zr, -zi]], {fill: "#1B6CA8", r: 6})
]
});
// señal continua y muestras
const T = 4 / Math.max(0.5, Math.min(f_lab, 3)) ;
const t = d3.range(0, T, T / 600);
const x = (tt) => Math.exp(-z_lab * polo.w * tt) * Math.cos(polo.w * Math.sqrt(1 - z_lab ** 2) * tt);
const ks = d3.range(0, Math.floor(T / polo.dt) + 1).map(k => ({t: k * polo.dt, x: x(k * polo.dt)}));
const serie = Plot.plot({
width: 520, height: 280, marginLeft: 45, x: {label: "t (s)"}, y: {label: "x(t)", domain: [-1.1, 1.1]},
marks: [Plot.ruleY([0]), Plot.line(t.map(tt => ({t: tt, x: x(tt)})), {x: "t", y: "x", stroke: "#9CA3AF"}),
Plot.ruleX(ks, {x: "t", y1: 0, y2: "x", stroke: "#D95F02"}), Plot.dot(ks, {x: "t", y: "x", fill: "#D95F02", r: 3})]
});
return html`<div style="display:flex; gap:16px; flex-wrap:wrap">${planoZ}${serie}</div>`;
}