// Vector Arithmetic panel (extracted from Sidebar.js in H4 4.6). // A − B + C term inputs + Top-K, firing ctx.onCalculate; results land in #math-results. /** @typedef {import('../types.js').PanelContext} PanelContext */ /** * Build the Vector Arithmetic card and wire the CALCULATE button. * @param {PanelContext} ctx * @returns {HTMLElement} */ export function buildVectorMathPanel(ctx) { const arithmetic = document.createElement('div'); arithmetic.className = 'section-card'; arithmetic.innerHTML = `
🧮 Vector Arithmetic (A − B + C)
Results (Top K):
`; setTimeout(() => { const btnCalc = document.getElementById('btn-calc'); if (btnCalc) { btnCalc.onclick = () => { const a = document.getElementById('math-a').value.trim(); const b = document.getElementById('math-b').value.trim(); const c = document.getElementById('math-c').value.trim(); const topK = parseInt(document.getElementById('math-top-k').value) || 5; if (a && b && c) ctx.onCalculate(a, b, c, topK); }; } }, 0); return arithmetic; }