import{S as g,G as m}from"./vendor.6ca40707.js";const S=function(){const n=document.createElement("link").relList;if(n&&n.supports&&n.supports("modulepreload"))return;for(const o of document.querySelectorAll('link[rel="modulepreload"]'))a(o);new MutationObserver(o=>{for(const l of o)if(l.type==="childList")for(const d of l.addedNodes)d.tagName==="LINK"&&d.rel==="modulepreload"&&a(d)}).observe(document,{childList:!0,subtree:!0});function h(o){const l={};return o.integrity&&(l.integrity=o.integrity),o.referrerpolicy&&(l.referrerPolicy=o.referrerpolicy),o.crossorigin==="use-credentials"?l.credentials="include":o.crossorigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(o){if(o.ep)return;o.ep=!0;const l=h(o);fetch(o.href,l)}};S();let i=[],f=[],t=null;const y=document.body.appendChild(document.createElement("span")),b=y.appendChild(document.createTextNode("")),u=y.appendChild(document.createElement("button"));u.textContent="Click Me!";let N=0,p=!1;u.onfocus=function(){p=!0};u.onblur=function(){p=!1};u.onclick=function(){N+=1,g.setComponentValue({numClicks:N,selectedNodes:i,selectedEdges:f})};function I(E){console.log("RENDER EVENT",Date.now());const n=E.detail;if(n.theme){const e=`1px solid var(${p?"--primary-color":"gray"})`;u.style.border=e,u.style.outline=e}u.disabled=n.disabled;let h=n.args.name;b.textContent=`Hello, ${h}! `+String.fromCharCode(160);const a=n.args.options||{selectNodes:3,selectEdges:3,clickClearAll:!1};let o=n.args.nodes,l=n.args.edges;const d={edges:[],nodes:[]};d.nodes=o,d.edges=l,d.edges.forEach(e=>{e.type==="loop"?e.style={endArrow:{path:m.Arrow.vee(10,15,0),d:0,stroke:"#0c0"}}:e.return?e.style={endArrow:{path:m.Arrow.triangle(10,15,20),d:20,fill:"#f00"}}:e.style={endArrow:{path:m.Arrow.triangle(10,15,20),d:20,fill:"#00f"}}}),m.Util.processParallelEdges(d.edges);let c=n.args.config;document.body.appendChild(document.createElement("div")).setAttribute("id","container"),t||(console.log("w h",c.width,c.height),c.width=c.width||document.getElementById("container").scrollWidth,c.height=c.height||document.getElementById("container").scrollHeight||500,console.log("w h",c.width,c.height),t=new m.Graph(c),t.on("edge:mouseenter",({item:e})=>t.setItemState(e,"active",!0)),t.on("edge:mouseleave",({item:e})=>t.setItemState(e,"active",!1)),t.on("edge:click",({item:e})=>{if(t.setItemState(e,"selected",!0),a.selectEdges){const s=e._cfg.states.includes("selected");a.selectEdges>1?(t.setItemState(e,"selected",!s),s?f=f.filter(r=>r.id!==e._cfg.model.id):f.push(e._cfg.model)):(t.getNodes().forEach(r=>t.clearItemStates(r)),f=[],s||(t.setItemState(e,"selected",!0),f=[e._cfg.model]))}}),t.on("node:click",({item:e})=>{if(a.selectNodes){const s=e._cfg.states.includes("selected");a.selectNodes>1?(t.setItemState(e,"selected",!s),s?i=i.filter(r=>r.id!==e._cfg.model.id):i.push(e._cfg.model)):(t.getNodes().forEach(r=>t.clearItemStates(r)),i=[],s||(t.setItemState(e,"selected",!0),i=[e._cfg.model]))}}),t.on("canvas:click",e=>{a.clickClearAll&&(i=[],f=[],t.getEdges().forEach(s=>t.clearItemStates(s)),t.getNodes().forEach(s=>t.clearItemStates(s)))})),t.data(d),t.render(),i.forEach(e=>{const s=t.getNodes().find(r=>r._cfg.model.label===e.label);s&&t.setItemState(s,"selected",!0)}),f.forEach(e=>{const s=t.getNodes().find(r=>r._cfg.model.label===e.label);s&&t.setItemState(s,"selected",!0)}),g.setFrameHeight()}g.events.addEventListener(g.RENDER_EVENT,I);g.setComponentReady();g.setFrameHeight();
