Loading...
';
} else if (this.#children.length === 0 && this.#breadcrumb.length > 0) {
this.#contentEl.innerHTML = '
${sliders}
Total: ${Math.round(sum)}%
`;
// Wire node clicks
this.#contentEl!.querySelectorAll('.node').forEach((g) => {
g.addEventListener('click', (e) => {
e.stopPropagation();
const idx = parseInt((g as HTMLElement).dataset.idx!, 10);
if (idx >= 0 && idx < visible.length) this.#drillInto(visible[idx]);
});
});
// Wire sliders
this.#contentEl!.querySelectorAll('input[type=range]').forEach((el) => {
el.addEventListener('pointerdown', (e) => e.stopPropagation());
el.addEventListener('input', (e) => {
e.stopPropagation();
const idx = parseInt((el as HTMLElement).dataset.idx!, 10);
const val = parseFloat((el as HTMLInputElement).value);
const weights = this.#children.map((c) => c.weight);
weights[idx] = val;
const normalized = normalize(weights, idx);
for (let i = 0; i < this.#children.length; i++) this.#children[i].weight = normalized[i];
// Update slider UI without full re-render
this.#contentEl!.querySelectorAll('.slider-row').forEach((row, ri) => {
const inp = row.querySelector('input') as HTMLInputElement;
const span = row.querySelector('.val') as HTMLElement;
if (inp && span && ri < this.#children.length) {
inp.value = String(Math.round(this.#children[ri].weight));
span.textContent = String(Math.round(this.#children[ri].weight));
}
});
const sumEl = this.#contentEl!.querySelector('.sum-row');
if (sumEl) sumEl.textContent = `Total: ${Math.round(this.#children.reduce((s, c) => s + c.weight, 0))}%`;
this.#saveWeights();
this.#scheduleEndorse();
});
});
}
#buildHolonSvg(visible: ExplorerNode[], overflow: number, W: number, H: number): string {
const cx = W / 2, cy = H / 2;
let orbit = Math.min(W, H) * 0.35;
if (this.#children.length > 8) orbit *= 0.85;
const gridSvg = metatronGrid(Math.min(W, H));
const linesSvg: string[] = [];
const nodesSvg: string[] = [];
for (let i = 0; i < visible.length; i++) {
const child = visible[i];
const angle = -110 + (220 / (visible.length + 1)) * (i + 1);
const rad = (angle - 90) * Math.PI / 180;
const nx = cx + orbit * Math.cos(rad);
const ny = cy + orbit * Math.sin(rad);
const r = Math.min(36, Math.max(16, 16 + child.weight * 0.3));
linesSvg.push(
`