visual-graphql
Version:
A lightweight GraphQL schema visualization tool built with SolidJS
10 lines • 105 kB
JavaScript
(function(I,E){typeof exports=="object"&&typeof module<"u"?E(exports,require("solid-js/web"),require("solid-js"),require("solid-js/store"),require("graphql")):typeof define=="function"&&define.amd?define(["exports","solid-js/web","solid-js","solid-js/store","graphql"],E):(I=typeof globalThis<"u"?globalThis:I||self,E(I.GraphQLVoyagerLite={},I.solidWeb,I.solid,I.solidStore,I.graphql))})(this,function(I,E,N,Se,O){"use strict";var Yo=Object.defineProperty;var pn=I=>{throw TypeError(I)};var Ho=(I,E,N)=>E in I?Yo(I,E,{enumerable:!0,configurable:!0,writable:!0,value:N}):I[E]=N;var H=(I,E,N)=>Ho(I,typeof E!="symbol"?E+"":E,N),dn=(I,E,N)=>E.has(I)||pn("Cannot "+N);var k=(I,E,N)=>(dn(I,E,"read from private field"),N?N.call(I):E.get(I)),$e=(I,E,N)=>E.has(I)?pn("Cannot add the same private member more than once"):E instanceof WeakSet?E.add(I):E.set(I,N),hn=(I,E,N,Se)=>(dn(I,E,"write to private field"),Se?Se.call(I,N):E.set(I,N),N);var se,ae,K,Pe,Le;function gn(s,r){return s}async function mn(s,r){try{let n,u=s;if(typeof s=="string")return n=O.buildSchema(s),ht(n,r);if(s.data&&s.data.__schema?u=s.data:s.__schema&&(u=s),!u.__schema)throw new Error("Invalid introspection data: missing __schema property");if(!u.__schema.queryType)throw new Error("Invalid schema: missing queryType definition");if(!u.__schema.types||!Array.isArray(u.__schema.types))throw new Error("Invalid schema: missing or invalid types array");const a=["String","Int","Float","Boolean","ID"],f=u.__schema.types.filter(A=>A.kind==="SCALAR").map(A=>A.name),t=a.filter(A=>!f.includes(A));t.length>0&&console.warn(`Missing required scalar types: ${t.join(", ")}`);try{return n=O.buildClientSchema(u),ht(n,r)}catch(A){throw console.error("Error building client schema:",A),A}}catch(n){throw console.error("Error processing schema:",n),n}}function ht(s,r){let n=s;const u=[];return r.skipRelay!==!1&&u.push(vn),r.skipDeprecated!==!1&&u.push(An),r.sortByAlphabet===!0&&(n=O.lexicographicSortSchema(n)),u.length>0&&(n=gn(n)),n}function vn(s){return s&&s.name&&(/.Connection$/.test(s.name)||/.Edge$/.test(s.name)||s.name==="PageInfo"||s.name==="Node")?null:s}function An(s){if(s&&s.getFields)try{const r=s.getFields();if(Object.values(r).every(u=>u.deprecationReason!=null))return null}catch{}return s}class yn{constructor(r,n){H(this,"schema");H(this,"rootType");H(this,"nodes");H(this,"edges");H(this,"displayOptions");if(this.schema=r,this.displayOptions=n,this.nodes=new Map,this.edges=new Map,n.rootType?this.rootType=r.getType(n.rootType):this.rootType=r.getQueryType(),!this.rootType)throw new Error("Root type not found in schema");this.buildGraph()}buildGraph(){var n;const r=this.schema.getTypeMap();for(const u in r){const a=r[u];u.startsWith("__")||this.displayOptions.hideRoot&&u===this.rootType.name||this.displayOptions.skipRelay&&(u.endsWith("Connection")||u.endsWith("Edge")||u==="PageInfo")||this.nodes.set(u,a)}for(const[u,a]of this.nodes.entries())if(O.isObjectType(a)||O.isInterfaceType(a)){this.edges.set(u,[]);const f=a.getFields();for(const t in f){const A=f[t];this.displayOptions.skipDeprecated&&A.deprecationReason||(n=this.edges.get(u))==null||n.push({sourceType:a,targetType:A.type,fieldName:t})}}}getConnectedTypes(r){const n=[],u=this.edges.get(r)||[];for(const a of u){const f=this.getNamedType(a.targetType);n.includes(f)||n.push(f)}return n}getNamedType(r){return r.ofType?this.getNamedType(r.ofType):r}}function be(s){return`TYPE-${s.replace(/[^_a-zA-Z0-9]/g,"_")}`}var Cn=E.template("<div class=doc-explorer-back>← Back"),En=E.template("<div class=doc-category><div class=doc-category-title>Schema Types"),Fn=E.template("<div class=doc-explorer><div class=doc-explorer-title-bar><div class=doc-explorer-title></div></div><div class=doc-explorer-contents>"),Dn=E.template("<div class=doc-type-description>"),$n=E.template("<div class=doc-category><div class=doc-category-title>Fields"),bn=E.template("<div class=doc-category><div class=doc-category-title>Implements"),Bn=E.template("<div class=doc-category><div class=doc-category-title>Possible Types"),wn=E.template("<div class=doc-category><div class=doc-category-title>Enum Values"),Sn=E.template("<div class=doc-category-item><span class=field-name></span>: <span class=type-name>"),xn=E.template("<span class=arg-name>"),Tn=E.template("<span class=type-name>"),Ge=E.template("<div class=doc-category-item><span class=type-name>"),Nn=E.template("<div class=enum-value-description>"),Pn=E.template("<div class=doc-category-item><span class=field-name>");const Ln=s=>{const[r,n]=N.createSignal([]),u=()=>{if(!s.selectedTypeID||!s.typeGraph)return null;const A=s.selectedTypeID.replace(/^TYPE-/,"");return s.typeGraph.nodes.get(A)||null},a=()=>{const A=r();if(A.length>0){const v=[...A];v.pop(),n(v);const S=v.length>0?v[v.length-1]:null;s.onSelectNode(S)}},f=A=>{n([...r(),A]),s.onSelectNode(A)},t=u();return(()=>{var A=Fn(),v=A.firstChild,S=v.firstChild,l=v.nextSibling;return E.insert(v,E.createComponent(N.Show,{get when(){return r().length>0},get children(){var d=Cn();return d.$$click=a,d}}),S),E.insert(S,()=>t?t.name:"Documentation Explorer"),E.insert(l,E.createComponent(N.Show,{when:t,children:d=>[(()=>{var F=Dn();return E.insert(F,()=>d().description||`No description for ${d().name}`),F})(),E.createComponent(N.Show,{get when(){return E.memo(()=>!!d().getFields)()&&typeof d().getFields=="function"},get children(){var F=$n();return F.firstChild,E.insert(F,E.createComponent(N.For,{get each(){return Object.values(d().getFields())},children:y=>(()=>{var m=Sn(),C=m.firstChild,T=C.nextSibling,z=T.nextSibling;return E.insert(C,()=>y.name),E.insert(m,()=>y.args&&y.args.length>0?"(":"",T),E.insert(m,E.createComponent(N.For,{get each(){return y.args},children:(Z,q)=>[(()=>{var j=xn();return E.insert(j,()=>Z.name),j})(),": ",(()=>{var j=Tn();return j.$$click=()=>f(Z.type.name),E.insert(j,()=>Z.type.toString()),j})(),E.memo(()=>q()<y.args.length-1?", ":"")]}),T),E.insert(m,()=>y.args&&y.args.length>0?")":"",T),z.$$click=()=>{const Z=y.type.toString().replace(/[[\]!]/g,"");f(Z)},E.insert(z,()=>y.type.toString()),m})()}),null),F}}),E.createComponent(N.Show,{get when(){return E.memo(()=>!!(d().getInterfaces&&typeof d().getInterfaces=="function"))()&&d().getInterfaces().length>0},get children(){var F=bn();return F.firstChild,E.insert(F,E.createComponent(N.For,{get each(){return d().getInterfaces()},children:y=>(()=>{var m=Ge(),C=m.firstChild;return m.$$click=()=>f(y.name),E.insert(C,()=>y.name),m})()}),null),F}}),E.createComponent(N.Show,{get when(){return E.memo(()=>!!(d().getTypes&&typeof d().getTypes=="function"))()&&d().getTypes().length>0},get children(){var F=Bn();return F.firstChild,E.insert(F,E.createComponent(N.For,{get each(){return d().getTypes()},children:y=>(()=>{var m=Ge(),C=m.firstChild;return m.$$click=()=>f(y.name),E.insert(C,()=>y.name),m})()}),null),F}}),E.createComponent(N.Show,{get when(){return E.memo(()=>!!(d().getValues&&typeof d().getValues=="function"))()&&d().getValues().length>0},get children(){var F=wn();return F.firstChild,E.insert(F,E.createComponent(N.For,{get each(){return d().getValues()},children:y=>(()=>{var m=Pn(),C=m.firstChild;return E.insert(C,()=>y.name),E.insert(m,E.createComponent(N.Show,{get when(){return y.description},get children(){var T=Nn();return E.insert(T,()=>y.description),T}}),null),m})()}),null),F}})]}),null),E.insert(l,E.createComponent(N.Show,{when:!t,get children(){var d=En();return d.firstChild,E.insert(d,E.createComponent(N.For,{get each(){return Array.from(s.typeGraph.nodes.values())},children:F=>(()=>{var y=Ge(),m=y.firstChild;return y.$$click=()=>f(F.name),E.insert(m,()=>F.name),y})()}),null),d}}),null),A})()};E.delegateEvents(["click"]);function Mn(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}var Ve,gt;function In(){return gt||(gt=1,Ve=function(){var s="",r,n,u,a=[],f={passive:!0},t={passive:!1};window.addEventListener?(r="addEventListener",n="removeEventListener"):(r="attachEvent",n="detachEvent",s="on"),u="onwheel"in document.createElement("div")?"wheel":document.onmousewheel!==void 0?"mousewheel":"DOMMouseScroll";function A(m,C){var T=function(z){!z&&(z=window.event);var Z={originalEvent:z,target:z.target||z.srcElement,type:"wheel",deltaMode:z.type=="MozMousePixelScroll"?0:1,deltaX:0,delatZ:0,preventDefault:function(){z.preventDefault?z.preventDefault():z.returnValue=!1}};return u=="mousewheel"?(Z.deltaY=-.025*z.wheelDelta,z.wheelDeltaX&&(Z.deltaX=-.025*z.wheelDeltaX)):Z.deltaY=z.detail,C(Z)};return a.push({element:m,fn:T}),T}function v(m){for(var C=0;C<a.length;C++)if(a[C].element===m)return a[C].fn;return function(){}}function S(m){for(var C=0;C<a.length;C++)if(a[C].element===m)return a.splice(C,1)}function l(m,C,T,z){var Z;u==="wheel"?Z=T:Z=A(m,T),m[r](s+C,Z,z?f:t)}function d(m,C,T,z){var Z;u==="wheel"?Z=T:Z=v(m),m[n](s+C,Z,z?f:t),S(m)}function F(m,C,T){l(m,u,C,T),u=="DOMMouseScroll"&&l(m,"MozMousePixelScroll",C,T)}function y(m,C,T){d(m,u,C,T),u=="DOMMouseScroll"&&d(m,"MozMousePixelScroll",C,T)}return{on:F,off:y}}()),Ve}var je,mt;function qe(){if(mt)return je;mt=1,je={extend:function(r,n){r=r||{};for(var u in n)this.isObject(n[u])?r[u]=this.extend(r[u],n[u]):r[u]=n[u];return r},isElement:function(r){return r instanceof HTMLElement||r instanceof SVGElement||r instanceof SVGSVGElement||r&&typeof r=="object"&&r!==null&&r.nodeType===1&&typeof r.nodeName=="string"},isObject:function(r){return Object.prototype.toString.call(r)==="[object Object]"},isNumber:function(r){return!isNaN(parseFloat(r))&&isFinite(r)},getSvg:function(r){var n,u;if(this.isElement(r))n=r;else if(typeof r=="string"||r instanceof String){if(n=document.querySelector(r),!n)throw new Error("Provided selector did not find any elements. Selector: "+r)}else throw new Error("Provided selector is not an HTML object nor String");if(n.tagName.toLowerCase()==="svg")u=n;else if(n.tagName.toLowerCase()==="object")u=n.contentDocument.documentElement;else if(n.tagName.toLowerCase()==="embed")u=n.getSVGDocument().documentElement;else throw n.tagName.toLowerCase()==="img"?new Error('Cannot script an SVG in an "img" element. Please use an "object" element or an in-line SVG.'):new Error("Cannot get SVG.");return u},proxy:function(r,n){return function(){return r.apply(n,arguments)}},getType:function(r){return Object.prototype.toString.apply(r).replace(/^\[object\s/,"").replace(/\]$/,"")},mouseAndTouchNormalize:function(r,n){if(r.clientX===void 0||r.clientX===null)if(r.clientX=0,r.clientY=0,r.touches!==void 0&&r.touches.length){if(r.touches[0].clientX!==void 0)r.clientX=r.touches[0].clientX,r.clientY=r.touches[0].clientY;else if(r.touches[0].pageX!==void 0){var u=n.getBoundingClientRect();r.clientX=r.touches[0].pageX-u.left,r.clientY=r.touches[0].pageY-u.top}}else r.originalEvent!==void 0&&r.originalEvent.clientX!==void 0&&(r.clientX=r.originalEvent.clientX,r.clientY=r.originalEvent.clientY)},isDblClick:function(r,n){if(r.detail===2)return!0;if(n!=null){var u=r.timeStamp-n.timeStamp,a=Math.sqrt(Math.pow(r.clientX-n.clientX,2)+Math.pow(r.clientY-n.clientY,2));return u<250&&a<10}return!1},now:Date.now||function(){return new Date().getTime()},throttle:function(r,n,u){var a=this,f,t,A,v=null,S=0;u||(u={});var l=function(){S=u.leading===!1?0:a.now(),v=null,A=r.apply(f,t),v||(f=t=null)};return function(){var d=a.now();!S&&u.leading===!1&&(S=d);var F=n-(d-S);return f=this,t=arguments,F<=0||F>n?(clearTimeout(v),v=null,S=d,A=r.apply(f,t),v||(f=t=null)):!v&&u.trailing!==!1&&(v=setTimeout(l,F)),A}},createRequestAnimationFrame:function(r){var n=null;return r!=="auto"&&r<60&&r>1&&(n=Math.floor(1e3/r)),n===null?window.requestAnimationFrame||s(33):s(n)}};function s(r){return function(n){window.setTimeout(n,r)}}return je}var Be,vt;function Ue(){if(vt)return Be;vt=1;var s=qe(),r="unknown";return document.documentMode&&(r="ie"),Be={svgNS:"http://www.w3.org/2000/svg",xmlNS:"http://www.w3.org/XML/1998/namespace",xmlnsNS:"http://www.w3.org/2000/xmlns/",xlinkNS:"http://www.w3.org/1999/xlink",evNS:"http://www.w3.org/2001/xml-events",getBoundingClientRectNormalized:function(n){if(n.clientWidth&&n.clientHeight)return{width:n.clientWidth,height:n.clientHeight};if(n.getBoundingClientRect())return n.getBoundingClientRect();throw new Error("Cannot get BoundingClientRect for SVG.")},getOrCreateViewport:function(n,u){var a=null;if(s.isElement(u)?a=u:a=n.querySelector(u),!a){var f=Array.prototype.slice.call(n.childNodes||n.children).filter(function(l){return l.nodeName!=="defs"&&l.nodeName!=="#text"});f.length===1&&f[0].nodeName==="g"&&f[0].getAttribute("transform")===null&&(a=f[0])}if(!a){var t="viewport-"+new Date().toISOString().replace(/\D/g,"");a=document.createElementNS(this.svgNS,"g"),a.setAttribute("id",t);var A=n.childNodes||n.children;if(A&&A.length>0)for(var v=A.length;v>0;v--)A[A.length-v].nodeName!=="defs"&&a.appendChild(A[A.length-v]);n.appendChild(a)}var S=[];return a.getAttribute("class")&&(S=a.getAttribute("class").split(" ")),~S.indexOf("svg-pan-zoom_viewport")||(S.push("svg-pan-zoom_viewport"),a.setAttribute("class",S.join(" "))),a},setupSvgAttributes:function(n){if(n.setAttribute("xmlns",this.svgNS),n.setAttributeNS(this.xmlnsNS,"xmlns:xlink",this.xlinkNS),n.setAttributeNS(this.xmlnsNS,"xmlns:ev",this.evNS),n.parentNode!==null){var u=n.getAttribute("style")||"";u.toLowerCase().indexOf("overflow")===-1&&n.setAttribute("style","overflow: hidden; "+u)}},internetExplorerRedisplayInterval:300,refreshDefsGlobal:s.throttle(function(){for(var n=document.querySelectorAll("defs"),u=n.length,a=0;a<u;a++){var f=n[a];f.parentNode.insertBefore(f,f)}},Be?Be.internetExplorerRedisplayInterval:null),setCTM:function(n,u,a){var f=this,t="matrix("+u.a+","+u.b+","+u.c+","+u.d+","+u.e+","+u.f+")";n.setAttributeNS(null,"transform",t),"transform"in n.style?n.style.transform=t:"-ms-transform"in n.style?n.style["-ms-transform"]=t:"-webkit-transform"in n.style&&(n.style["-webkit-transform"]=t),r==="ie"&&a&&(a.parentNode.insertBefore(a,a),window.setTimeout(function(){f.refreshDefsGlobal()},f.internetExplorerRedisplayInterval))},getEventPoint:function(n,u){var a=u.createSVGPoint();return s.mouseAndTouchNormalize(n,u),a.x=n.clientX,a.y=n.clientY,a},getSvgCenterPoint:function(n,u,a){return this.createSVGPoint(n,u/2,a/2)},createSVGPoint:function(n,u,a){var f=n.createSVGPoint();return f.x=u,f.y=a,f}},Be}var We,At;function zn(){if(At)return We;At=1;var s=Ue();return We={enable:function(r){var n=r.svg.querySelector("defs");n||(n=document.createElementNS(s.svgNS,"defs"),r.svg.appendChild(n));var u=n.querySelector("style#svg-pan-zoom-controls-styles");if(!u){var a=document.createElementNS(s.svgNS,"style");a.setAttribute("id","svg-pan-zoom-controls-styles"),a.setAttribute("type","text/css"),a.textContent=".svg-pan-zoom-control { cursor: pointer; fill: black; fill-opacity: 0.333; } .svg-pan-zoom-control:hover { fill-opacity: 0.8; } .svg-pan-zoom-control-background { fill: white; fill-opacity: 0.5; } .svg-pan-zoom-control-background { fill-opacity: 0.8; }",n.appendChild(a)}var f=document.createElementNS(s.svgNS,"g");f.setAttribute("id","svg-pan-zoom-controls"),f.setAttribute("transform","translate("+(r.width-70)+" "+(r.height-76)+") scale(0.75)"),f.setAttribute("class","svg-pan-zoom-control"),f.appendChild(this._createZoomIn(r)),f.appendChild(this._createZoomReset(r)),f.appendChild(this._createZoomOut(r)),r.svg.appendChild(f),r.controlIcons=f},_createZoomIn:function(r){var n=document.createElementNS(s.svgNS,"g");n.setAttribute("id","svg-pan-zoom-zoom-in"),n.setAttribute("transform","translate(30.5 5) scale(0.015)"),n.setAttribute("class","svg-pan-zoom-control"),n.addEventListener("click",function(){r.getPublicInstance().zoomIn()},!1),n.addEventListener("touchstart",function(){r.getPublicInstance().zoomIn()},!1);var u=document.createElementNS(s.svgNS,"rect");u.setAttribute("x","0"),u.setAttribute("y","0"),u.setAttribute("width","1500"),u.setAttribute("height","1400"),u.setAttribute("class","svg-pan-zoom-control-background"),n.appendChild(u);var a=document.createElementNS(s.svgNS,"path");return a.setAttribute("d","M1280 576v128q0 26 -19 45t-45 19h-320v320q0 26 -19 45t-45 19h-128q-26 0 -45 -19t-19 -45v-320h-320q-26 0 -45 -19t-19 -45v-128q0 -26 19 -45t45 -19h320v-320q0 -26 19 -45t45 -19h128q26 0 45 19t19 45v320h320q26 0 45 19t19 45zM1536 1120v-960 q0 -119 -84.5 -203.5t-203.5 -84.5h-960q-119 0 -203.5 84.5t-84.5 203.5v960q0 119 84.5 203.5t203.5 84.5h960q119 0 203.5 -84.5t84.5 -203.5z"),a.setAttribute("class","svg-pan-zoom-control-element"),n.appendChild(a),n},_createZoomReset:function(r){var n=document.createElementNS(s.svgNS,"g");n.setAttribute("id","svg-pan-zoom-reset-pan-zoom"),n.setAttribute("transform","translate(5 35) scale(0.4)"),n.setAttribute("class","svg-pan-zoom-control"),n.addEventListener("click",function(){r.getPublicInstance().reset()},!1),n.addEventListener("touchstart",function(){r.getPublicInstance().reset()},!1);var u=document.createElementNS(s.svgNS,"rect");u.setAttribute("x","2"),u.setAttribute("y","2"),u.setAttribute("width","182"),u.setAttribute("height","58"),u.setAttribute("class","svg-pan-zoom-control-background"),n.appendChild(u);var a=document.createElementNS(s.svgNS,"path");a.setAttribute("d","M33.051,20.632c-0.742-0.406-1.854-0.609-3.338-0.609h-7.969v9.281h7.769c1.543,0,2.701-0.188,3.473-0.562c1.365-0.656,2.048-1.953,2.048-3.891C35.032,22.757,34.372,21.351,33.051,20.632z"),a.setAttribute("class","svg-pan-zoom-control-element"),n.appendChild(a);var f=document.createElementNS(s.svgNS,"path");return f.setAttribute("d","M170.231,0.5H15.847C7.102,0.5,0.5,5.708,0.5,11.84v38.861C0.5,56.833,7.102,61.5,15.847,61.5h154.384c8.745,0,15.269-4.667,15.269-10.798V11.84C185.5,5.708,178.976,0.5,170.231,0.5z M42.837,48.569h-7.969c-0.219-0.766-0.375-1.383-0.469-1.852c-0.188-0.969-0.289-1.961-0.305-2.977l-0.047-3.211c-0.03-2.203-0.41-3.672-1.142-4.406c-0.732-0.734-2.103-1.102-4.113-1.102h-7.05v13.547h-7.055V14.022h16.524c2.361,0.047,4.178,0.344,5.45,0.891c1.272,0.547,2.351,1.352,3.234,2.414c0.731,0.875,1.31,1.844,1.737,2.906s0.64,2.273,0.64,3.633c0,1.641-0.414,3.254-1.242,4.84s-2.195,2.707-4.102,3.363c1.594,0.641,2.723,1.551,3.387,2.73s0.996,2.98,0.996,5.402v2.32c0,1.578,0.063,2.648,0.19,3.211c0.19,0.891,0.635,1.547,1.333,1.969V48.569z M75.579,48.569h-26.18V14.022h25.336v6.117H56.454v7.336h16.781v6H56.454v8.883h19.125V48.569z M104.497,46.331c-2.44,2.086-5.887,3.129-10.34,3.129c-4.548,0-8.125-1.027-10.731-3.082s-3.909-4.879-3.909-8.473h6.891c0.224,1.578,0.662,2.758,1.316,3.539c1.196,1.422,3.246,2.133,6.15,2.133c1.739,0,3.151-0.188,4.236-0.562c2.058-0.719,3.087-2.055,3.087-4.008c0-1.141-0.504-2.023-1.512-2.648c-1.008-0.609-2.607-1.148-4.796-1.617l-3.74-0.82c-3.676-0.812-6.201-1.695-7.576-2.648c-2.328-1.594-3.492-4.086-3.492-7.477c0-3.094,1.139-5.664,3.417-7.711s5.623-3.07,10.036-3.07c3.685,0,6.829,0.965,9.431,2.895c2.602,1.93,3.966,4.73,4.093,8.402h-6.938c-0.128-2.078-1.057-3.555-2.787-4.43c-1.154-0.578-2.587-0.867-4.301-0.867c-1.907,0-3.428,0.375-4.565,1.125c-1.138,0.75-1.706,1.797-1.706,3.141c0,1.234,0.561,2.156,1.682,2.766c0.721,0.406,2.25,0.883,4.589,1.43l6.063,1.43c2.657,0.625,4.648,1.461,5.975,2.508c2.059,1.625,3.089,3.977,3.089,7.055C108.157,41.624,106.937,44.245,104.497,46.331z M139.61,48.569h-26.18V14.022h25.336v6.117h-18.281v7.336h16.781v6h-16.781v8.883h19.125V48.569z M170.337,20.14h-10.336v28.43h-7.266V20.14h-10.383v-6.117h27.984V20.14z"),f.setAttribute("class","svg-pan-zoom-control-element"),n.appendChild(f),n},_createZoomOut:function(r){var n=document.createElementNS(s.svgNS,"g");n.setAttribute("id","svg-pan-zoom-zoom-out"),n.setAttribute("transform","translate(30.5 70) scale(0.015)"),n.setAttribute("class","svg-pan-zoom-control"),n.addEventListener("click",function(){r.getPublicInstance().zoomOut()},!1),n.addEventListener("touchstart",function(){r.getPublicInstance().zoomOut()},!1);var u=document.createElementNS(s.svgNS,"rect");u.setAttribute("x","0"),u.setAttribute("y","0"),u.setAttribute("width","1500"),u.setAttribute("height","1400"),u.setAttribute("class","svg-pan-zoom-control-background"),n.appendChild(u);var a=document.createElementNS(s.svgNS,"path");return a.setAttribute("d","M1280 576v128q0 26 -19 45t-45 19h-896q-26 0 -45 -19t-19 -45v-128q0 -26 19 -45t45 -19h896q26 0 45 19t19 45zM1536 1120v-960q0 -119 -84.5 -203.5t-203.5 -84.5h-960q-119 0 -203.5 84.5t-84.5 203.5v960q0 119 84.5 203.5t203.5 84.5h960q119 0 203.5 -84.5 t84.5 -203.5z"),a.setAttribute("class","svg-pan-zoom-control-element"),n.appendChild(a),n},disable:function(r){r.controlIcons&&(r.controlIcons.parentNode.removeChild(r.controlIcons),r.controlIcons=null)}},We}var Xe,yt;function _n(){if(yt)return Xe;yt=1;var s=Ue(),r=qe(),n=function(u,a){this.init(u,a)};return n.prototype.init=function(u,a){this.viewport=u,this.options=a,this.originalState={zoom:1,x:0,y:0},this.activeState={zoom:1,x:0,y:0},this.updateCTMCached=r.proxy(this.updateCTM,this),this.requestAnimationFrame=r.createRequestAnimationFrame(this.options.refreshRate),this.viewBox={x:0,y:0,width:0,height:0},this.cacheViewBox();var f=this.processCTM();this.setCTM(f),this.updateCTM()},n.prototype.cacheViewBox=function(){var u=this.options.svg.getAttribute("viewBox");if(u){var a=u.split(/[\s\,]/).filter(function(t){return t}).map(parseFloat);this.viewBox.x=a[0],this.viewBox.y=a[1],this.viewBox.width=a[2],this.viewBox.height=a[3];var f=Math.min(this.options.width/this.viewBox.width,this.options.height/this.viewBox.height);this.activeState.zoom=f,this.activeState.x=(this.options.width-this.viewBox.width*f)/2,this.activeState.y=(this.options.height-this.viewBox.height*f)/2,this.updateCTMOnNextFrame(),this.options.svg.removeAttribute("viewBox")}else this.simpleViewBoxCache()},n.prototype.simpleViewBoxCache=function(){var u=this.viewport.getBBox();this.viewBox.x=u.x,this.viewBox.y=u.y,this.viewBox.width=u.width,this.viewBox.height=u.height},n.prototype.getViewBox=function(){return r.extend({},this.viewBox)},n.prototype.processCTM=function(){var u=this.getCTM();if(this.options.fit||this.options.contain){var a;this.options.fit?a=Math.min(this.options.width/this.viewBox.width,this.options.height/this.viewBox.height):a=Math.max(this.options.width/this.viewBox.width,this.options.height/this.viewBox.height),u.a=a,u.d=a,u.e=-this.viewBox.x*a,u.f=-this.viewBox.y*a}if(this.options.center){var f=(this.options.width-(this.viewBox.width+this.viewBox.x*2)*u.a)*.5,t=(this.options.height-(this.viewBox.height+this.viewBox.y*2)*u.a)*.5;u.e=f,u.f=t}return this.originalState.zoom=u.a,this.originalState.x=u.e,this.originalState.y=u.f,u},n.prototype.getOriginalState=function(){return r.extend({},this.originalState)},n.prototype.getState=function(){return r.extend({},this.activeState)},n.prototype.getZoom=function(){return this.activeState.zoom},n.prototype.getRelativeZoom=function(){return this.activeState.zoom/this.originalState.zoom},n.prototype.computeRelativeZoom=function(u){return u/this.originalState.zoom},n.prototype.getPan=function(){return{x:this.activeState.x,y:this.activeState.y}},n.prototype.getCTM=function(){var u=this.options.svg.createSVGMatrix();return u.a=this.activeState.zoom,u.b=0,u.c=0,u.d=this.activeState.zoom,u.e=this.activeState.x,u.f=this.activeState.y,u},n.prototype.setCTM=function(u){var a=this.isZoomDifferent(u),f=this.isPanDifferent(u);if(a||f){if(a&&(this.options.beforeZoom(this.getRelativeZoom(),this.computeRelativeZoom(u.a))===!1?(u.a=u.d=this.activeState.zoom,a=!1):(this.updateCache(u),this.options.onZoom(this.getRelativeZoom()))),f){var t=this.options.beforePan(this.getPan(),{x:u.e,y:u.f}),A=!1,v=!1;t===!1?(u.e=this.getPan().x,u.f=this.getPan().y,A=v=!0):r.isObject(t)&&(t.x===!1?(u.e=this.getPan().x,A=!0):r.isNumber(t.x)&&(u.e=t.x),t.y===!1?(u.f=this.getPan().y,v=!0):r.isNumber(t.y)&&(u.f=t.y)),A&&v||!this.isPanDifferent(u)?f=!1:(this.updateCache(u),this.options.onPan(this.getPan()))}(a||f)&&this.updateCTMOnNextFrame()}},n.prototype.isZoomDifferent=function(u){return this.activeState.zoom!==u.a},n.prototype.isPanDifferent=function(u){return this.activeState.x!==u.e||this.activeState.y!==u.f},n.prototype.updateCache=function(u){this.activeState.zoom=u.a,this.activeState.x=u.e,this.activeState.y=u.f},n.prototype.pendingUpdate=!1,n.prototype.updateCTMOnNextFrame=function(){this.pendingUpdate||(this.pendingUpdate=!0,this.requestAnimationFrame.call(window,this.updateCTMCached))},n.prototype.updateCTM=function(){var u=this.getCTM();s.setCTM(this.viewport,u,this.defs),this.pendingUpdate=!1,this.options.onUpdatedCTM&&this.options.onUpdatedCTM(u)},Xe=function(u,a){return new n(u,a)},Xe}var Ye,Ct;function Rn(){if(Ct)return Ye;Ct=1;var s=In(),r=zn(),n=qe(),u=Ue(),a=_n(),f=function(l,d){this.init(l,d)},t={viewportSelector:".svg-pan-zoom_viewport",panEnabled:!0,controlIconsEnabled:!1,zoomEnabled:!0,dblClickZoomEnabled:!0,mouseWheelZoomEnabled:!0,preventMouseEventsDefault:!0,zoomScaleSensitivity:.1,minZoom:.5,maxZoom:10,fit:!0,contain:!1,center:!0,refreshRate:"auto",beforeZoom:null,onZoom:null,beforePan:null,onPan:null,customEventsHandler:null,eventsListenerElement:null,onUpdatedCTM:null},A={passive:!0};f.prototype.init=function(l,d){var F=this;this.svg=l,this.defs=l.querySelector("defs"),u.setupSvgAttributes(this.svg),this.options=n.extend(n.extend({},t),d),this.state="none";var y=u.getBoundingClientRectNormalized(l);this.width=y.width,this.height=y.height,this.viewport=a(u.getOrCreateViewport(this.svg,this.options.viewportSelector),{svg:this.svg,width:this.width,height:this.height,fit:this.options.fit,contain:this.options.contain,center:this.options.center,refreshRate:this.options.refreshRate,beforeZoom:function(C,T){if(F.viewport&&F.options.beforeZoom)return F.options.beforeZoom(C,T)},onZoom:function(C){if(F.viewport&&F.options.onZoom)return F.options.onZoom(C)},beforePan:function(C,T){if(F.viewport&&F.options.beforePan)return F.options.beforePan(C,T)},onPan:function(C){if(F.viewport&&F.options.onPan)return F.options.onPan(C)},onUpdatedCTM:function(C){if(F.viewport&&F.options.onUpdatedCTM)return F.options.onUpdatedCTM(C)}});var m=this.getPublicInstance();m.setBeforeZoom(this.options.beforeZoom),m.setOnZoom(this.options.onZoom),m.setBeforePan(this.options.beforePan),m.setOnPan(this.options.onPan),m.setOnUpdatedCTM(this.options.onUpdatedCTM),this.options.controlIconsEnabled&&r.enable(this),this.lastMouseWheelEventTime=Date.now(),this.setupHandlers()},f.prototype.setupHandlers=function(){var l=this,d=null;if(this.eventListeners={mousedown:function(C){var T=l.handleMouseDown(C,d);return d=C,T},touchstart:function(C){var T=l.handleMouseDown(C,d);return d=C,T},mouseup:function(C){return l.handleMouseUp(C)},touchend:function(C){return l.handleMouseUp(C)},mousemove:function(C){return l.handleMouseMove(C)},touchmove:function(C){return l.handleMouseMove(C)},mouseleave:function(C){return l.handleMouseUp(C)},touchleave:function(C){return l.handleMouseUp(C)},touchcancel:function(C){return l.handleMouseUp(C)}},this.options.customEventsHandler!=null){this.options.customEventsHandler.init({svgElement:this.svg,eventsListenerElement:this.options.eventsListenerElement,instance:this.getPublicInstance()});var F=this.options.customEventsHandler.haltEventListeners;if(F&&F.length)for(var y=F.length-1;y>=0;y--)this.eventListeners.hasOwnProperty(F[y])&&delete this.eventListeners[F[y]]}for(var m in this.eventListeners)(this.options.eventsListenerElement||this.svg).addEventListener(m,this.eventListeners[m],this.options.preventMouseEventsDefault?!1:A);this.options.mouseWheelZoomEnabled&&(this.options.mouseWheelZoomEnabled=!1,this.enableMouseWheelZoom())},f.prototype.enableMouseWheelZoom=function(){if(!this.options.mouseWheelZoomEnabled){var l=this;this.wheelListener=function(F){return l.handleMouseWheel(F)};var d=!this.options.preventMouseEventsDefault;s.on(this.options.eventsListenerElement||this.svg,this.wheelListener,d),this.options.mouseWheelZoomEnabled=!0}},f.prototype.disableMouseWheelZoom=function(){if(this.options.mouseWheelZoomEnabled){var l=!this.options.preventMouseEventsDefault;s.off(this.options.eventsListenerElement||this.svg,this.wheelListener,l),this.options.mouseWheelZoomEnabled=!1}},f.prototype.handleMouseWheel=function(l){if(!(!this.options.zoomEnabled||this.state!=="none")){this.options.preventMouseEventsDefault&&(l.preventDefault?l.preventDefault():l.returnValue=!1);var d=l.deltaY||1,F=Date.now()-this.lastMouseWheelEventTime,y=3+Math.max(0,30-F);this.lastMouseWheelEventTime=Date.now(),"deltaMode"in l&&l.deltaMode===0&&l.wheelDelta&&(d=l.deltaY===0?0:Math.abs(l.wheelDelta)/l.deltaY),d=-.3<d&&d<.3?d:(d>0?1:-1)*Math.log(Math.abs(d)+10)/y;var m=this.svg.getScreenCTM().inverse(),C=u.getEventPoint(l,this.svg).matrixTransform(m),T=Math.pow(1+this.options.zoomScaleSensitivity,-1*d);this.zoomAtPoint(T,C)}},f.prototype.zoomAtPoint=function(l,d,F){var y=this.viewport.getOriginalState();F?(l=Math.max(this.options.minZoom*y.zoom,Math.min(this.options.maxZoom*y.zoom,l)),l=l/this.getZoom()):this.getZoom()*l<this.options.minZoom*y.zoom?l=this.options.minZoom*y.zoom/this.getZoom():this.getZoom()*l>this.options.maxZoom*y.zoom&&(l=this.options.maxZoom*y.zoom/this.getZoom());var m=this.viewport.getCTM(),C=d.matrixTransform(m.inverse()),T=this.svg.createSVGMatrix().translate(C.x,C.y).scale(l).translate(-C.x,-C.y),z=m.multiply(T);z.a!==m.a&&this.viewport.setCTM(z)},f.prototype.zoom=function(l,d){this.zoomAtPoint(l,u.getSvgCenterPoint(this.svg,this.width,this.height),d)},f.prototype.publicZoom=function(l,d){d&&(l=this.computeFromRelativeZoom(l)),this.zoom(l,d)},f.prototype.publicZoomAtPoint=function(l,d,F){if(F&&(l=this.computeFromRelativeZoom(l)),n.getType(d)!=="SVGPoint")if("x"in d&&"y"in d)d=u.createSVGPoint(this.svg,d.x,d.y);else throw new Error("Given point is invalid");this.zoomAtPoint(l,d,F)},f.prototype.getZoom=function(){return this.viewport.getZoom()},f.prototype.getRelativeZoom=function(){return this.viewport.getRelativeZoom()},f.prototype.computeFromRelativeZoom=function(l){return l*this.viewport.getOriginalState().zoom},f.prototype.resetZoom=function(){var l=this.viewport.getOriginalState();this.zoom(l.zoom,!0)},f.prototype.resetPan=function(){this.pan(this.viewport.getOriginalState())},f.prototype.reset=function(){this.resetZoom(),this.resetPan()},f.prototype.handleDblClick=function(l){if(this.options.preventMouseEventsDefault&&(l.preventDefault?l.preventDefault():l.returnValue=!1),this.options.controlIconsEnabled){var d=l.target.getAttribute("class")||"";if(d.indexOf("svg-pan-zoom-control")>-1)return!1}var F;l.shiftKey?F=1/((1+this.options.zoomScaleSensitivity)*2):F=(1+this.options.zoomScaleSensitivity)*2;var y=u.getEventPoint(l,this.svg).matrixTransform(this.svg.getScreenCTM().inverse());this.zoomAtPoint(F,y)},f.prototype.handleMouseDown=function(l,d){this.options.preventMouseEventsDefault&&(l.preventDefault?l.preventDefault():l.returnValue=!1),n.mouseAndTouchNormalize(l,this.svg),this.options.dblClickZoomEnabled&&n.isDblClick(l,d)?this.handleDblClick(l):(this.state="pan",this.firstEventCTM=this.viewport.getCTM(),this.stateOrigin=u.getEventPoint(l,this.svg).matrixTransform(this.firstEventCTM.inverse()))},f.prototype.handleMouseMove=function(l){if(this.options.preventMouseEventsDefault&&(l.preventDefault?l.preventDefault():l.returnValue=!1),this.state==="pan"&&this.options.panEnabled){var d=u.getEventPoint(l,this.svg).matrixTransform(this.firstEventCTM.inverse()),F=this.firstEventCTM.translate(d.x-this.stateOrigin.x,d.y-this.stateOrigin.y);this.viewport.setCTM(F)}},f.prototype.handleMouseUp=function(l){this.options.preventMouseEventsDefault&&(l.preventDefault?l.preventDefault():l.returnValue=!1),this.state==="pan"&&(this.state="none")},f.prototype.fit=function(){var l=this.viewport.getViewBox(),d=Math.min(this.width/l.width,this.height/l.height);this.zoom(d,!0)},f.prototype.contain=function(){var l=this.viewport.getViewBox(),d=Math.max(this.width/l.width,this.height/l.height);this.zoom(d,!0)},f.prototype.center=function(){var l=this.viewport.getViewBox(),d=(this.width-(l.width+l.x*2)*this.getZoom())*.5,F=(this.height-(l.height+l.y*2)*this.getZoom())*.5;this.getPublicInstance().pan({x:d,y:F})},f.prototype.updateBBox=function(){this.viewport.simpleViewBoxCache()},f.prototype.pan=function(l){var d=this.viewport.getCTM();d.e=l.x,d.f=l.y,this.viewport.setCTM(d)},f.prototype.panBy=function(l){var d=this.viewport.getCTM();d.e+=l.x,d.f+=l.y,this.viewport.setCTM(d)},f.prototype.getPan=function(){var l=this.viewport.getState();return{x:l.x,y:l.y}},f.prototype.resize=function(){var l=u.getBoundingClientRectNormalized(this.svg);this.width=l.width,this.height=l.height;var d=this.viewport;d.options.width=this.width,d.options.height=this.height,d.processCTM(),this.options.controlIconsEnabled&&(this.getPublicInstance().disableControlIcons(),this.getPublicInstance().enableControlIcons())},f.prototype.destroy=function(){var l=this;this.beforeZoom=null,this.onZoom=null,this.beforePan=null,this.onPan=null,this.onUpdatedCTM=null,this.options.customEventsHandler!=null&&this.options.customEventsHandler.destroy({svgElement:this.svg,eventsListenerElement:this.options.eventsListenerElement,instance:this.getPublicInstance()});for(var d in this.eventListeners)(this.options.eventsListenerElement||this.svg).removeEventListener(d,this.eventListeners[d],this.options.preventMouseEventsDefault?!1:A);this.disableMouseWheelZoom(),this.getPublicInstance().disableControlIcons(),this.reset(),v=v.filter(function(F){return F.svg!==l.svg}),delete this.options,delete this.viewport,delete this.publicInstance,delete this.pi,this.getPublicInstance=function(){return null}},f.prototype.getPublicInstance=function(){var l=this;return this.publicInstance||(this.publicInstance=this.pi={enablePan:function(){return l.options.panEnabled=!0,l.pi},disablePan:function(){return l.options.panEnabled=!1,l.pi},isPanEnabled:function(){return!!l.options.panEnabled},pan:function(d){return l.pan(d),l.pi},panBy:function(d){return l.panBy(d),l.pi},getPan:function(){return l.getPan()},setBeforePan:function(d){return l.options.beforePan=d===null?null:n.proxy(d,l.publicInstance),l.pi},setOnPan:function(d){return l.options.onPan=d===null?null:n.proxy(d,l.publicInstance),l.pi},enableZoom:function(){return l.options.zoomEnabled=!0,l.pi},disableZoom:function(){return l.options.zoomEnabled=!1,l.pi},isZoomEnabled:function(){return!!l.options.zoomEnabled},enableControlIcons:function(){return l.options.controlIconsEnabled||(l.options.controlIconsEnabled=!0,r.enable(l)),l.pi},disableControlIcons:function(){return l.options.controlIconsEnabled&&(l.options.controlIconsEnabled=!1,r.disable(l)),l.pi},isControlIconsEnabled:function(){return!!l.options.controlIconsEnabled},enableDblClickZoom:function(){return l.options.dblClickZoomEnabled=!0,l.pi},disableDblClickZoom:function(){return l.options.dblClickZoomEnabled=!1,l.pi},isDblClickZoomEnabled:function(){return!!l.options.dblClickZoomEnabled},enableMouseWheelZoom:function(){return l.enableMouseWheelZoom(),l.pi},disableMouseWheelZoom:function(){return l.disableMouseWheelZoom(),l.pi},isMouseWheelZoomEnabled:function(){return!!l.options.mouseWheelZoomEnabled},setZoomScaleSensitivity:function(d){return l.options.zoomScaleSensitivity=d,l.pi},setMinZoom:function(d){return l.options.minZoom=d,l.pi},setMaxZoom:function(d){return l.options.maxZoom=d,l.pi},setBeforeZoom:function(d){return l.options.beforeZoom=d===null?null:n.proxy(d,l.publicInstance),l.pi},setOnZoom:function(d){return l.options.onZoom=d===null?null:n.proxy(d,l.publicInstance),l.pi},zoom:function(d){return l.publicZoom(d,!0),l.pi},zoomBy:function(d){return l.publicZoom(d,!1),l.pi},zoomAtPoint:function(d,F){return l.publicZoomAtPoint(d,F,!0),l.pi},zoomAtPointBy:function(d,F){return l.publicZoomAtPoint(d,F,!1),l.pi},zoomIn:function(){return this.zoomBy(1+l.options.zoomScaleSensitivity),l.pi},zoomOut:function(){return this.zoomBy(1/(1+l.options.zoomScaleSensitivity)),l.pi},getZoom:function(){return l.getRelativeZoom()},setOnUpdatedCTM:function(d){return l.options.onUpdatedCTM=d===null?null:n.proxy(d,l.publicInstance),l.pi},resetZoom:function(){return l.resetZoom(),l.pi},resetPan:function(){return l.resetPan(),l.pi},reset:function(){return l.reset(),l.pi},fit:function(){return l.fit(),l.pi},contain:function(){return l.contain(),l.pi},center:function(){return l.center(),l.pi},updateBBox:function(){return l.updateBBox(),l.pi},resize:function(){return l.resize(),l.pi},getSizes:function(){return{width:l.width,height:l.height,realZoom:l.getZoom(),viewBox:l.viewport.getViewBox()}},destroy:function(){return l.destroy(),l.pi}}),this.publicInstance};var v=[],S=function(l,d){var F=n.getSvg(l);if(F===null)return null;for(var y=v.length-1;y>=0;y--)if(v[y].svg===F)return v[y].instance.getPublicInstance();return v.push({svg:F,instance:new f(F,d)}),v[v.length-1].instance.getPublicInstance()};return Ye=S,Ye}var Zn=Rn();const kn=Mn(Zn),xe=Object.seal({Graph:null,Digraph:null,Subgraph:null,Node:null,Edge:null});function On(s){return Object.assign(Object.seal(Object.assign({},xe)),s)}function Et(s){return typeof s=="object"&&s!==null&&typeof s.id=="string"}function He(s){return typeof s=="object"&&s!==null&&s.$$type==="Node"&&typeof s.id=="string"}function Ft(s){return He(s)||Et(s)}function Te(s){return typeof s=="string"||Ft(s)}function Gn(s){return Array.isArray(s)&&s.every(Te)}function Vn(s){return["n","ne","e","se","s","sw","w","nw","c"].includes(s)}function Dt(s){if(Ft(s))return s;const[r,n,u]=s.split(":");return Vn(u)?{id:r,port:n,compass:u}:{id:r,port:n}}function jn(s){if(s.length<1)throw Error("EdgeTargets must have at least 1 elements.");if(!s.every(r=>Te(r)))throw Error("The element of Edge target is missing or not satisfied as Edge target.");return s.map(r=>Dt(r))}class Ke{}class Qe extends Ke{constructor(n){super();$e(this,se,new Map);n!==void 0&&this.apply(n)}get values(){return Array.from(k(this,se).entries())}get size(){return k(this,se).size}get(n){return k(this,se).get(n)}set(n,u){u!=null&&k(this,se).set(n,u)}delete(n){k(this,se).delete(n)}apply(n){const u=Array.isArray(n)?n:Object.entries(n);for(const[a,f]of u)this.set(a,f)}clear(){k(this,se).clear()}}se=new WeakMap;class Je extends Qe{constructor(n,u){super(u);H(this,"comment");this.$$kind=n}get $$type(){return"AttributeList"}}class $t extends Qe{constructor(){super(...arguments);$e(this,ae,xe);H(this,"id");H(this,"comment");H(this,"attributes",Object.freeze({graph:new Je("Graph"),edge:new Je("Edge"),node:new Je("Node")}));$e(this,K,{nodes:new Map,edges:new Set,subgraphs:new Set})}get nodes(){return Array.from(k(this,K).nodes.values())}get edges(){return Array.from(k(this,K).edges.values())}get subgraphs(){return Array.from(k(this,K).subgraphs.values())}with(n){hn(this,ae,On(n))}addNode(n){k(this,K).nodes.set(n.id,n)}addEdge(n){k(this,K).edges.add(n)}addSubgraph(n){k(this,K).subgraphs.add(n)}existNode(n){return k(this,K).nodes.has(n)}existEdge(n){return k(this,K).edges.has(n)}existSubgraph(n){return k(this,K).subgraphs.has(n)}createSubgraph(...n){const u=new(k(this,ae)).Subgraph(...n);return u.with(k(this,ae)),this.addSubgraph(u),u}removeNode(n){k(this,K).nodes.delete(typeof n=="string"?n:n.id)}removeEdge(n){k(this,K).edges.delete(n)}removeSubgraph(n){k(this,K).subgraphs.delete(n)}createNode(n,u){const a=new(k(this,ae)).Node(n,u);return this.addNode(a),a}getSubgraph(n){return Array.from(k(this,K).subgraphs.values()).find(u=>u.id===n)}getNode(n){return k(this,K).nodes.get(n)}createEdge(n,u){const a=n.map(t=>Gn(t)?jn(t):Dt(t)),f=new(k(this,ae)).Edge(a,u);return this.addEdge(f),f}subgraph(...n){const u=n.find(A=>typeof A=="string"),a=n.find(A=>typeof A=="object"&&A!==null),f=n.find(A=>typeof A=="function"),t=u?this.getSubgraph(u)??this.createSubgraph(u):this.createSubgraph();return a!==void 0&&t.apply(a),f!==void 0&&f(t),t}node(n,...u){if(typeof n=="string"){const a=n,f=u.find(v=>typeof v=="object"&&v!==null),t=u.find(v=>typeof v=="function"),A=this.getNode(a)??this.createNode(a);return f!==void 0&&A.attributes.apply(f),t!==void 0&&t(A),A}typeof n=="object"&&n!==null&&this.attributes.node.apply(n)}edge(n,...u){if(Array.isArray(n)){const a=n,f=u.find(v=>typeof v=="object"),t=u.find(v=>typeof v=="function"),A=this.createEdge(a,f);return t!==void 0&&t(A),A}typeof n=="object"&&n!==null&&this.attributes.edge.apply(n)}graph(n){this.attributes.graph.apply(n)}}ae=new WeakMap,K=new WeakMap;class bt extends $t{constructor(...n){super();H(this,"id");H(this,"strict");this.id=n.find(a=>typeof a=="string"),this.strict=n.find(a=>typeof a=="boolean")??!1;const u=n.find(a=>typeof a=="object"&&a!==null);u!==void 0&&this.apply(u)}get $$type(){return"Graph"}}class qn extends bt{get directed(){return!0}}class Bt extends Qe{constructor(){super(...arguments);H(this,"comment")}}class Un extends Ke{constructor(n,u){super();H(this,"comment");H(this,"attributes");if(this.targets=n,n.length<2&&(Te(n[0])&&Te(n[1]))===!1)throw Error("The element of Edge target is missing or not satisfied as Edge target.");this.attributes=new Bt(u)}get $$type(){return"Edge"}}class Wn extends bt{get directed(){return!1}}class Xn extends Ke{constructor(n,u){super();H(this,"comment");H(this,"attributes");this.id=n,this.attributes=new Bt(u)}get $$type(){return"Node"}port(n){return typeof n=="string"?{id:this.id,port:n}:{id:this.id,...n}}}class Yn extends $t{constructor(...n){super();H(this,"id");this.id=n.find(a=>typeof a=="string");const u=n.find(a=>typeof a=="object"&&a!==null);u!==void 0&&this.apply(u)}get $$type(){return"Subgraph"}isSubgraphCluster(){return typeof this.id=="string"?this.id.startsWith("cluster"):!1}}function Hn(){Object.assign(xe,{Graph:Wn,Digraph:qn,Subgraph:Yn,Node:Xn,Edge:Un})}class et{constructor(r){this.options=r}getLocation(){var r,n;return((n=(r=this.options)==null?void 0:r.locationFunction)==null?void 0:n.call(r))??null}createElement(r,n,u=[]){return{location:this.getLocation(),...n,type:r,children:u}}}const _=et.prototype.createElement.bind(new et),Kn={match(s){return s.type==="AttributeList"},*print(s,r){r.children.length===0?yield`${r.kind.toLocaleLowerCase()} [];`:(yield`${r.kind.toLocaleLowerCase()} [`,yield*s.printChildren(r.children),yield"];")}},Qn={match(s){return s.type==="Attribute"},*print(s,r){yield*s.print(r.key),yield" = ",yield*s.print(r.value),yield";"}},Jn=/\r?\n/,er={Block:" * ",Macro:"# ",Slash:"// "},tr={match(s){return s.type==="Comment"},*print(s,r){const n=er[r.kind];r.kind==="Block"&&(yield*["/**",s.EOL]);const u=r.value.split(Jn),a=u.length;for(let f=0;f<a;f++)yield n,yield u[f],f<a-1&&(yield s.EOL);r.kind==="Block"&&(yield*[s.EOL," */"])}},nr={match(s){return s.type==="Dot"},*print(s,r){yield*s.join(r.children,s.EOL)}},rr={match(s){return s.type==="Edge"},*print(s,r){yield*s.join(r.targets,s.directed?" -> ":" -- "),r.children.length===0?yield";":(yield" [",yield*s.printChildren(r.children),yield"];")}},ir={match(s){return s.type==="Graph"},*print(s,r){s.directed=r.directed,r.strict&&(yield"strict "),yield r.directed?"digraph ":"graph ",r.id&&(yield*s.print(r.id),yield" "),yield"{",r.children.length>=1&&(yield*s.printChildren(r.children)),yield"}"}},or=s=>s.replace(new RegExp('(?<!\\\\)"|[\\r\\n]',"g"),sr),ur={"\r":String.raw`\r`,"\n":String.raw`\n`,'"':String.raw`\"`};function sr(s){return ur[s]}const ar=[Kn,Qn,tr,nr,rr,ir,{match(s){return s.type==="Literal"},*print(s,r){switch(r.quoted){case"html":yield"<",yield r.value,yield">";return;case!0:yield'"',yield or(r.value),yield'"';return;default:yield r.value;return}}},{match(s){return s.type==="Node"},*print(s,r){yield*s.print(r.id),r.children.length>=1&&(yield" [",yield*s.printChildren(r.children),yield"]"),yield";"}},{match(s){return s.type==="NodeRefGroup"},*print(s,r){yield"{",yield*s.join(r.children," "),yield"}"}},{match(s){return s.type==="NodeRef"},*print(s,r){yield*s.print(r.id),r.port&&(yield":",yield*s.print(r.port)),r.compass&&(yield":",yield*s.print(r.compass))}},{match(s){return s.type==="Subgraph"},*print(s,r){yield"subgraph",r.id&&(yield" ",yield*s.print(r.id)),yield" {",r.children.length>=1&&(yield*s.printChildren(r.children)),yield"}"}}];class lr{constructor(r={}){$e(this,Pe,[...ar]);this.options=r}print(r){return Array.from(this.toChunks(r)).join("")}toChunks(r){const n=[...k(this,Pe)],{indentSize:u=2,indentStyle:a="space",endOfLine:f="lf"}=this.options,t=f==="crlf"?`\r
`:`
`,A=a==="space"?" ".repeat(u):" ",v={directed:!0,EOL:t,*printChildren(l){yield*S(function*(){yield t,yield*v.join(l,t)}),yield t},*print(l){for(const d of n)if(d.match(l)){yield*d.print(this,l);return}throw new Error(`No matching plugin found for AST node: ${JSON.stringify(l)}`)},*join(l,d){const F=l.length;for(let y=0;y<F;y++)yield*v.print(l[y]),y<F-1&&(yield d)}};return{[Symbol.iterator]:function*(){yield*v.print(r)}};function*S(l){for(const d of l())yield d,d===t&&(yield A)}}}Pe=new WeakMap;function cr(s,r){const n=new lr(r).print(s);if(!n)throw new Error;return n}const fr=function(){function s(a,f){function t(){this.constructor=a}t.prototype=f.prototype,a.prototype=new t}function r(a,f,t,A){var v=Error.call(this,a);return Object.setPrototypeOf&&Object.setPrototypeOf(v,r.prototype),v.expected=f,v.found=t,v.location=A,v.name="SyntaxError",v}s(r,Error);function n(a,f,t){return t=t||" ",a.length>f?a:(f-=a.length,t+=t.repeat(f),a+t.slice(0,f))}r.prototype.format=function(a){var f="Error: "+this.message;if(this.location){var t=null,A;for(A=0;A<a.length;A++)if(a[A].source===this.location.source){t=a[A].text.split(/\r\n|\n|\r/g);break}var v=this.location.start,S=this.location.source&&typeof this.location.source.offset=="function"?this.location.source.offset(v):v,l=this.location.source+":"+S.line+":"+S.column;if(t){var d=this.location.end,F=n("",S.line.toString().length," "),y=t[v.line-1],m=v.line===d.line?d.column:y.length+1,C=m-v.column||1;f+=`
--> `+l+`
`+F+` |
`+S.line+" | "+y+`
`+F+" | "+n("",v.column-1," ")+n("",C,"^")}else f+=`
at `+l}return f},r.buildMessage=function(a,f){var t={literal:function(y){return'"'+v(y.text)+'"'},class:function(y){var m=y.parts.map(function(C){return Array.isArray(C)?S(C[0])+"-"+S(C[1]):S(C)});return"["+(y.inverted?"^":"")+m.join("")+"]"},any:function(){return"any character"},end:function(){return"end of input"},other:function(y){return y.description}};function A(y){return y.charCodeAt(0).toString(16).toUpperCase()}function v(y){return y.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(m){return"\\x0"+A(m)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(m){return"\\x"+A(m)})}function S(y){return y.replace(/\\/g,"\\\\").replace(/\]/g,"\\]").replace(/\^/g,"\\^").replace(/-/g,"\\-").replace(/\0/g,"\\0").replace(/\t/g,"\\t").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/[\x00-\x0F]/g,function(m){return"\\x0"+A(m)}).replace(/[\x10-\x1F\x7F-\x9F]/g,function(m){return"\\x"+A(m)})}function l(y){return t[y.type](y)}function d(y){var m=y.map(l),C,T;if(m.sort(),m.length>0){for(C=1,T=1;C<m.length;C++)m[C-1]!==m[C]&&(m[T]=m[C],T++);m.length=T}switch(m.length){case 1:return m[0];case 2:return m[0]+" or "+m[1];default:return m.slice(0,-1).join(", ")+", or "+m[m.length-1]}}function F(y){return y?'"'+v(y)+'"':"end of input"}return"Expected "+d(a)+" but "+F(f)+" found."};function u(a,f){f=f!==void 0?f:{};var t={},A=f.grammarSource,v={Dot:Yt,Graph:Ht,Subgraph:lt,Node:ot,Edge:at,AttributeList:ut,Attribute:st,ClusterStatements:ct},S=Yt,l="strict",d="graph",F="digraph",y="{",m="}",C="node",T="edge",z="=",Z="[",q="]",j="->",b="--",B=":",x="subgraph",P="n",R="ne",U="e",W="se",X="s",J="sw",ee="w",le="nw",te='"',re="/*",ie="*/",ve="//",ce="#",fe="-",pe=".",Me="<",Mr=">",Nt="\\",Ir=`
`,Pt=`\r
`,Ie=/^[,;]/,zr=/^[$A-Z_a-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0370-\u0374\u0376-\u0377\u037A-\u037D\u0386\u0388-\u038A\u038C\u038E-\u03A1\u03A3-\u03F5\u03F7-\u0481\u048A-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05D0-\u05EA\u05F0-\u05F2\u0620-\u064A\u066E-\u066F\u0671-\u06D3\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FC\u06FF\u0710\u0712-\u072F\u074D-\u07A5\u07B1\u07CA-\u07EA\u07F4-\u07F5\u07FA\u0800-\u0815\u081A\u0824\u0828\u0840-\u0858\u08A0\u08A2-\u08AC\u0904-\u0939\u093D\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097F\u0985-\u098C\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD\u09CE\u09DC-\u09DD\u09DF-\u09E1\u09F0-\u09F1\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33\u0A35-\u0A36\u0A38-\u0A39\u0A59-\u0A5C\u0A5E\u0A72-\u0A74\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0AD0\u0AE0-\u0AE1\u0B05-\u0B0C\u0B0F-\u0B10\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B5C-\u0B5D\u0B5F-\u0B61\u0B71\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9\u0BD0\u0C05-\u0C0C\u0C0E-\u0C10\u0C12-\u0C28\u0C2A-\u0C33\u0C35-\u0C39\u0C3D\u0C58-\u0C59\u0C60-\u0C61\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CDE\u0CE0-\u0CE1\u0CF1-\u0CF2\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D\u0D4E\u0D60-\u0D61\u0D7A-\u0D7F\u0D85-\u0D96\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E46\u0E81-\u0E82\u0E84\u0E87-\u0E88\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6\u0EDC-\u0EDF\u0F00\u0F40-\u0F47\u0F49-\u0F6C\u0F88-\u0F8C\u1000-\u102A\u103F\u1050-\u1055\u105A-\u105D\u1061\u1065-\u1066\u106E-\u1070\u1075-\u1081\u108E\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FC-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EE-\u16F0\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17D7\u17DC\u1820-\u1877\u1880-\u18A8\u18AA\u18B0-\u18F5\u1900-\u191C\u1950-\u196D\u1970-\u1974\u1980-\u19AB\u19C1-\u19C7\u1A00-\u1A16\u1A20