const D = window.BRIDGE_DATA;
const $ = (id) => document.getElementById(id);
$('trk').textContent = D.receipt.trace_resonance_key;
function shortHash(h){ return h ? h.slice(0,12).toUpperCase() : 'MISSING'; }
$('sources').innerHTML = D.manifest.sources.map(s => `
${s.source_id} — ${s.title || ''}
${s.source_class}
Use: ${s.use_in_layer}
SHA-256: ${shortHash(s.sha256)}…
`).join('');
const sourceFilters = ['ALL', ...new Set(D.atoms.map(a => a.source_id))];
let current = 'ALL';
function renderTabs(){
$('tabs').innerHTML = sourceFilters.map(f => ``).join('');
document.querySelectorAll('.tab').forEach(b => b.onclick = () => { current = b.dataset.filter; renderTabs(); renderAtoms(); });
}
function renderAtoms(){
const list = current==='ALL' ? D.atoms : D.atoms.filter(a => a.source_id===current);
$('atoms').innerHTML = list.map(a => `
${a.atom_id}${a.gate_status}
${a.atom_type.replaceAll('_',' ')}
${a.derived_summary}
Source: ${a.source_id} · ${a.source_location}
Coupling relevance: ${a.coupling_relevance}
${a.export_variable ? `
export: ${a.export_variable}
` : ''}
`).join('');
}
function renderGates(){
const sum = D.receipt.gate_summary;
const total = Object.values(sum).reduce((a,b)=>a+b,0) || 1;
$('gates').innerHTML = Object.entries(sum).map(([k,v]) => `
${k} ${v} atoms
`).join('');
}
$('blocked').innerHTML = D.simulatorExport.blocked_exports.map(x => `${x.replaceAll('_',' ')}`).join('');
$('edges').innerHTML = D.edgeRules.edge_types.map(e => `${e.edge_type}
${e.description}`).join('');
$('exports').innerHTML = D.simulatorExport.allowed_exports.map(x => `${x}`).join('');
renderTabs(); renderAtoms(); renderGates();