import { BuilderCanvasData , BuilderRuntimeEdge } from "../interfaces" ; import { expandTemplateEdges } from "./expandTemplateEdges" ; export function reorderBuilderEdges ( { rootId , nodes , edges } , { parentUid , nodeUids , } ) { const edgesExcludeExpanded = edges . filter ( ( edge ) => ! edge . $$isTemplateExpanded ) ; return expandTemplateEdges ( { rootId , nodes , edges : edgesExcludeExpanded . map ( ( edge ) => { const index = edge . parent === parentUid ? nodeUids . indexOf ( edge . child ) : - 1 ; return index >= 0 ? { ... edge , sort : index , } : edge ; } ) , } ) ; }