import{mastt,caset,iasnt,aasit,passt}from"./chunk-UGV5ZQQN-ClI3yjhf.js";import{casat,aasG,sasrt}from"./chunk-BAVOGKFW-DrwgV1hs.js";import{caslt,uasot,sasct,iasdt,pasM,aasF,basR}from"./chunk-YWFND7JV-Cx6rOFuu.js";import{_asg,lass,dasm,jasT,uasft,Oasut,Pas$,QasH,Rasz,tasht,easW,SasJ,TasB,Uasgt}from"./index-CQym0Fh-.js";import{Gasq}from"./graph-BSE5c6BB.js";import{laswt}from"./layout-DOTonGH5.js";import{wasS}from"./json-B9Vr1FDf.js";import"./_baseUniq-Dt3Sdbk-.js";import"./min-BWVHsSEv.js";varu={},x={},Q={},yt=g(()=>{x={},Q={},u={}},"clear"),L=g((e,t)=>(s.trace("In isDescendant",t," ",e," = ",x[t].includes(e)),!!x[t].includes(e)),"isDescendant"),bt=g((e,t)=>(s.info("Descendants of ",t," is ",x[t]),s.info("Edge is ",e),e.v===t||e.w===t?!1:x[t]?x[t].includes(e.v)||L(e.v,t)||L(e.w,t)||x[t].includes(e.w):(s.debug("Tilt, ",t,",not in descendants"),!1)),"edgeInCluster"),U=g((e,t,n,l)=>{s.warn("Copying children of ",e,"root",l,"data",t.node(e),l);consti=t.children(e)||[];e!==l&&i.push(e),s.warn("Copying (nodes) clusterId",e,"nodes",i),i.forEach(a=>{if(t.children(a).length>0)U(a,t,n,l);else{constr=t.node(a);s.info("cp ",a," to ",l," with parent ",e),n.setNode(a,r),l!==t.parent(a)&&(s.warn("Setting parent",a,t.parent(a)),n.setParent(a,t.parent(a))),e!==l&&a!==e?(s.debug("Setting parent",a,e),n.setParent(a,e)):(s.info("In copy ",e,"root",l,"data",t.node(e),l),s.debug("Not Setting parent for node=",a,"cluster!==rootId",e!==l,"node!==clusterId",a!==e));constf=t.edges(a);s.debug("Copying Edges",f),f.forEach(d=>{s.info("Edge",d);consth=t.edge(d.v,d.w,d.name);s.info("Edge data",h,l);try{bt(d,l)?(s.info("Copying as ",d.v,d.w,h,d.name),n.setEdge(d.v,d.w,h,d.name),s.info("newGraph edges ",n.edges(),n.edge(n.edges()[0]))):s.info("Skipping copy of edge ",d.v,"-->",d.w," rootId: ",l," clusterId:",e)}catch(b){s.error(b)}})}s.debug("Removing node",a),t.removeNode(a)})},"copy"),V=g((e,t)=>{constn=t.children(e);letl=[...n];for(constiofn)Q[i]=e,l=[...l,...V(i,t)];returnl},"extractDescendants"),k=g((e,t)=>{s.trace("Searching",e);constn=t.children(e);if(s.trace("Searching children of id ",e,n),n.length<1)returns.trace("This is a valid node",e),e;for(constlofn){consti=k(l,t);if(i)returns.trace("Found replacement for",e," => ",i),i}},"findNonClusterChild"),X=g(e=>!u[e]||!u[e].externalConnections?e:u[e]?u[e].id:e,"getAnchorId"),mt=g((e,t)=>{if(!e||t>10){s.debug("Opting out, no graph ");return}elses.debug("Opting in, graph ");e.nodes().forEach(function(n){e.children(n).length>0&&(s.warn("Cluster identified",n," Replacement id in edges: ",k(n,e)),x[n]=V(n,e),u[n]={id:k(n,e),clusterData:e.node(n)})}),e.nodes().forEach(function(n){constl=e.children(n),i=e.edges();l.length>0?(s.debug("Cluster identified",n,x),i.forEach(a=>{if(a.v!==n&&a.w!==n){constr=L(a.v,n),f=L(a.w,n);r^f&&(s.warn("Edge: ",a," leaves cluster ",n),s.warn("Descendants of XXX ",n,": ",x[n]),u[n].externalConnections=!0)}})):s.debug("Not a cluster ",n,x)});for(letnofObject.keys(u)){constl=u[n].id,i=e.parent(l);i!==n&&u[i]&&!u[i].externalConnections&&(u[n].id=i)}e.edges().forEach(function(n){constl=e.edge(n);s.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),s.warn("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(e.edge(n)));leti=n.v,a=n.w;if(s.warn("Fix XXX",u,"ids:",n.v,n.w,"Translating: ",u[n.v]," --- ",u[n.w]),u[n.v]&&u[n.w]&&u[n.v]===u[n.w]){s.warn("Fixing and trixing link to self - removing XXX",n.v,n.w,n.name),s.warn("Fixing and trixing - removing XXX",n.v,n.w,n.name),i=X(n.v),a=X(n.w),e.removeEdge(n.v,n.w,n.name);constr=n.w+"---"+n.v;e.setNode(r,{domId:r,id:r,labelStyle:"",labelText:l.label,padding:0,shape:"labelRect",style:""});constf=structuredClone(l),d=structuredClone(l);f.label="",f.arrowTypeEnd="none",d.label="",f.fromCluster=n.v,d.toCluster=n.v,e.setEdge(i,r,f,n.name+"-cyclic-special"),e.setEdge(r,a,d,n.name+"-cyclic-special")}elseif(u[n.v]||u[n.w]){if(s.warn("Fixing and trixing - removing XXX",n.v,n.w,n.name),i=X(n.v),a=X(n.w),e.removeEdge(n.v,n.w,n.name),i!==n.v){constr=e.parent(i);u[r].e