// The Mellis HB-7 console, laid out at 1600 x 900 after the Cessna console and the reference app recordings: the
// orange HB-7 badge and title with the sim status cells, the wing beat with its live stroke chart, power, the six leg
// servos, flight telemetry with an attitude ball, the views, the display toggles, the subsystem registry, the flight
// log with the operator's actions on its timeline, the flight-mode word in the viewport, the labels with leaders into
// the bee and the operator's pointer. Panels are light paper over the near-white studio; the bee's orange is the one
// accent. update(s) redraws every live part from the frame's state; the film and a live page share it.
export const C = {ink: '#24211d', mute: '#9a8f82', faint: '#e0d7ca', line: '#ece5da', panel: 'rgba(253,251,247,.95)', or: '#ff5a1f', green: '#2fa36b', track: '#efe8de'};
export const VIEWS = ['hero', 'front', 'side', 'wing', 'legs'];
export const VIEW_LABEL = {hero: 'HERO', front: 'FRONT', side: 'SIDE', wing: 'WING', legs: 'LEGS'};
export const DISPLAY = ['labels', 'xray', 'exploded', 'blur', 'orbit'];
export const DISPLAY_LABEL = {labels: 'LABELS', xray: 'X-RAY', exploded: 'EXPLODED', blur: 'MOTION BLUR', orbit: 'ORBIT'};
// the viewport: the 3D shows between the side columns, above the flight log
export const VIEWPORT = {x0: 330, x1: 1270, y0: 108, y1: 744};
const CSS = `
#app{font-family:Inter,system-ui,sans-serif;color:${C.ink};-webkit-font-smoothing:antialiased;font-variant-numeric:tabular-nums}
.ui{position:absolute;inset:0;pointer-events:none}
.mo{font-family:'JetBrains Mono',ui-monospace,monospace}
.cp{position:absolute;background:${C.panel};border:1px solid ${C.line};border-radius:6px;box-shadow:0 2px 10px rgba(120,90,50,.07)}
.ph{position:absolute;display:flex;align-items:center;gap:9px;font:700 10.5px 'JetBrains Mono',monospace;letter-spacing:1.8px}
.ph i{display:block;width:3px;height:13px;background:${C.or}}
.pn{position:absolute;font:500 9.5px 'JetBrains Mono',monospace;color:${C.mute};letter-spacing:1px}
.sm{font:500 9px 'JetBrains Mono',monospace;letter-spacing:1.6px;color:${C.mute};text-transform:uppercase;white-space:nowrap}
.v{font:600 11px 'JetBrains Mono',monospace;color:${C.ink};white-space:nowrap}
.bt{position:absolute;height:23px;padding:0 10px;display:flex;align-items:center;justify-content:center;border:1px solid ${C.faint};border-radius:4px;background:#fffdf9;font:700 9.4px 'JetBrains Mono',monospace;letter-spacing:1.3px;color:${C.ink};white-space:nowrap;box-sizing:border-box}
.call{position:absolute;white-space:nowrap;padding:3px 6px 3px 5px;margin:-3px 0 0 -5px;background:rgba(253,251,247,.86);border-radius:3px}
.call b{display:flex;align-items:center;gap:6px;font:700 9.4px 'JetBrains Mono',monospace;letter-spacing:1.3px;color:${C.ink}}
.call b i{display:block;width:6px;height:6px;background:${C.or}}
.call span{display:block;font:500 7.8px 'JetBrains Mono',monospace;letter-spacing:1.2px;color:${C.mute};margin-top:2px}
.chip{position:absolute;height:15px;padding:0 6px;border-radius:3px;font:700 7.6px 'JetBrains Mono',monospace;letter-spacing:1.1px;display:flex;align-items:center;white-space:nowrap}
.cur{position:absolute;left:0;top:0;z-index:50;filter:drop-shadow(0 1px 2px rgba(0,0,0,.3))}
.ring{position:absolute;width:34px;height:34px;margin:-17px 0 0 -17px;border-radius:50%;border:1.5px solid ${C.or};opacity:0;z-index:49}
`;
const el = (h) => {
const d = document.createElement('div');
d.innerHTML = h.trim();
return d.firstElementChild;
};
const SUBS = [
['OPTIC HEAD', '2 × 18 MM LENS · AMBER IR'],
['NECK BEARING', '10-SEGMENT COLLAR'],
['THORAX DRIVE', '3 GEARS · 11 ACTUATORS'],
['WING ROOTS', '4 HINGES · 7.5 HZ CRANK'],
['LEG SERVOS', '6 LEGS × 3 JOINTS'],
['ABDOMEN BANDS', '5 SEGMENTS · GLASS STING'],
];
const LEGS = ['L1', 'L2', 'L3', 'R1', 'R2', 'R3'];
// opts (all optional, the first film's console when absent): views / viewLabel / viewsTitle / viewRows for the view
// panel (the second film puts its assemblies there, in two rows), display / displayLabel for the toggles; the panels
// below move down to make room and the subsystem rows close up.
export function createConsole(app, opts = {}) {
const views = opts.views ?? VIEWS;
const viewLabel = opts.viewLabel ?? VIEW_LABEL;
const display = opts.display ?? DISPLAY;
const displayLabel = opts.displayLabel ?? DISPLAY_LABEL;
const viewRows = opts.viewRows ?? 1;
const style = document.createElement('style');
style.textContent = CSS;
document.head.appendChild(style);
const ui = el(`