import { locateNode } from "./node_explorer.js"; export function buildImpactAnalysis( impactData ) { const wrapper = document.createElement( "div" ); wrapper.style.padding = "10px"; const safeRemovalCandidates = impactData?.safe_removal_candidates ?? 0; const lowRiskNodes = impactData?.low_risk_nodes ?? 0; const mediumRiskNodes = impactData?.medium_risk_nodes ?? 0; const highRiskNodes = impactData?.high_risk_nodes ?? 0; wrapper.innerHTML = `

Impact Analysis

Safe Removal

${safeRemovalCandidates}

Low Risk

${lowRiskNodes}

Medium Risk

${mediumRiskNodes}

High Risk

${highRiskNodes}

`; const nodeSection = document.createElement( "div" ); nodeSection.style.background = "#252526"; nodeSection.style.border = "1px solid #444"; nodeSection.style.borderRadius = "10px"; nodeSection.style.padding = "15px"; nodeSection.style.marginBottom = "20px"; nodeSection.innerHTML = `

Node Impact Report

`; const nodes = impactData?.nodes ?? []; if ( nodes.length === 0 ) { nodeSection.innerHTML += `

No impact data available.

`; } else { nodes.forEach( node => { let borderColor = "#00cc66"; if ( node.risk === "Medium" ) { borderColor = "#ffaa00"; } if ( node.risk === "High" ) { borderColor = "#ff4444"; } const card = document.createElement( "div" ); card.style.border = `1px solid ${borderColor}`; card.style.borderRadius = "8px"; card.style.padding = "12px"; card.style.marginBottom = "12px"; card.innerHTML = `

${node.node_type}

Node ID: ${node.node_id}

Dependencies: ${node.dependencies}

Dependents: ${node.dependents}

Affected Branches: ${node.affected_branches}

Risk: ${node.risk}

Safe To Remove: ${ node.safe_to_remove ? "Yes" : "No" }

`; const locateButton = document.createElement( "button" ); locateButton.innerText = "Locate Node"; locateButton.style.marginTop = "10px"; locateButton.onclick = () => { locateNode( node.node_id ); }; card.appendChild( locateButton ); nodeSection.appendChild( card ); } ); } wrapper.appendChild( nodeSection ); const insightSection = document.createElement( "div" ); insightSection.style.background = "#252526"; insightSection.style.border = "1px solid #444"; insightSection.style.borderRadius = "10px"; insightSection.style.padding = "15px"; insightSection.innerHTML = `

Impact Insights

`; const list = document.createElement( "ul" ); const insights = impactData?.insights ?? []; insights.forEach( insight => { const item = document.createElement( "li" ); item.innerText = insight; list.appendChild( item ); } ); insightSection.appendChild( list ); wrapper.appendChild( insightSection ); return wrapper; }