morffy 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -176,7 +176,7 @@ ${i.comment}`:i.comment}this.doc.range[2]=i.offset;break}default:this.errors.pus
|
|
|
176
176
|
`)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
|
|
177
177
|
`,i)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(a){var c;const i=a.items[a.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,i.value){const o="end"in i.value?i.value.end:void 0,l=Array.isArray(o)?o[o.length-1]:void 0;(l==null?void 0:l.type)==="comment"?o==null||o.push(this.sourceToken):a.items.push({start:[this.sourceToken]})}else i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)a.items.push({start:[this.sourceToken]});else if(i.sep)i.sep.push(this.sourceToken);else{if(this.atIndentedComment(i.start,a.indent)){const o=a.items[a.items.length-2],l=(c=o==null?void 0:o.value)==null?void 0:c.end;if(Array.isArray(l)){BI(l,i.start),l.push(this.sourceToken),a.items.pop();return}}i.start.push(this.sourceToken)}return}if(this.indent>=a.indent){const o=!this.onKeyLine&&this.indent===a.indent,l=o&&(i.sep||i.explicitKey)&&this.type!=="seq-item-ind";let u=[];if(l&&i.sep&&!i.value){const h=[];for(let f=0;f<i.sep.length;++f){const p=i.sep[f];switch(p.type){case"newline":h.push(f);break;case"space":break;case"comment":p.indent>a.indent&&(h.length=0);break;default:h.length=0}}h.length>=2&&(u=i.sep.splice(h[1]))}switch(this.type){case"anchor":case"tag":l||i.value?(u.push(this.sourceToken),a.items.push({start:u}),this.onKeyLine=!0):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"explicit-key-ind":!i.sep&&!i.explicitKey?(i.start.push(this.sourceToken),i.explicitKey=!0):l||i.value?(u.push(this.sourceToken),a.items.push({start:u,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(i.explicitKey)if(i.sep)if(i.value)a.items.push({start:[],key:null,sep:[this.sourceToken]});else if(y1(i.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:u,key:null,sep:[this.sourceToken]}]});else if(vB(i.key)&&!y1(i.sep,"newline")){const h=wl(i.start),f=i.key,p=i.sep;p.push(this.sourceToken),delete i.key,delete i.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:h,key:f,sep:p}]})}else u.length>0?i.sep=i.sep.concat(u,this.sourceToken):i.sep.push(this.sourceToken);else if(y1(i.start,"newline"))Object.assign(i,{key:null,sep:[this.sourceToken]});else{const h=wl(i.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:h,key:null,sep:[this.sourceToken]}]})}else i.sep?i.value||l?a.items.push({start:u,key:null,sep:[this.sourceToken]}):y1(i.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const h=this.flowScalar(this.type);l||i.value?(a.items.push({start:u,key:h,sep:[]}),this.onKeyLine=!0):i.sep?this.stack.push(h):(Object.assign(i,{key:h,sep:[]}),this.onKeyLine=!0);return}default:{const h=this.startBlockValue(a);if(h){if(h.type==="block-seq"){if(!i.explicitKey&&i.sep&&!y1(i.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else o&&a.items.push({start:u});this.stack.push(h);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(a){var c;const i=a.items[a.items.length-1];switch(this.type){case"newline":if(i.value){const o="end"in i.value?i.value.end:void 0,l=Array.isArray(o)?o[o.length-1]:void 0;(l==null?void 0:l.type)==="comment"?o==null||o.push(this.sourceToken):a.items.push({start:[this.sourceToken]})}else i.start.push(this.sourceToken);return;case"space":case"comment":if(i.value)a.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(i.start,a.indent)){const o=a.items[a.items.length-2],l=(c=o==null?void 0:o.value)==null?void 0:c.end;if(Array.isArray(l)){BI(l,i.start),l.push(this.sourceToken),a.items.pop();return}}i.start.push(this.sourceToken)}return;case"anchor":case"tag":if(i.value||this.indent<=a.indent)break;i.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==a.indent)break;i.value||y1(i.start,"seq-item-ind")?a.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return}if(this.indent>a.indent){const o=this.startBlockValue(a);if(o){this.stack.push(o);return}}yield*this.pop(),yield*this.step()}*flowCollection(a){const i=a.items[a.items.length-1];if(this.type==="flow-error-end"){let c;do yield*this.pop(),c=this.peek(1);while((c==null?void 0:c.type)==="flow-collection")}else if(a.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!i||i.sep?a.items.push({start:[this.sourceToken]}):i.start.push(this.sourceToken);return;case"map-value-ind":!i||i.value?a.items.push({start:[],key:null,sep:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):Object.assign(i,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!i||i.value?a.items.push({start:[this.sourceToken]}):i.sep?i.sep.push(this.sourceToken):i.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const o=this.flowScalar(this.type);!i||i.value?a.items.push({start:[],key:o,sep:[]}):i.sep?this.stack.push(o):Object.assign(i,{key:o,sep:[]});return}case"flow-map-end":case"flow-seq-end":a.end.push(this.sourceToken);return}const c=this.startBlockValue(a);c?this.stack.push(c):(yield*this.pop(),yield*this.step())}else{const c=this.peek(2);if(c.type==="block-map"&&(this.type==="map-value-ind"&&c.indent===a.indent||this.type==="newline"&&!c.items[c.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&c.type!=="flow-collection"){const o=vd(c),l=wl(o);eO(a);const u=a.end.splice(1,a.end.length);u.push(this.sourceToken);const h={type:"block-map",offset:a.offset,indent:a.indent,items:[{start:l,key:a,sep:u}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=h}else yield*this.lineEnd(a)}}flowScalar(a){if(this.onNewLine){let i=this.source.indexOf(`
|
|
178
178
|
`)+1;for(;i!==0;)this.onNewLine(this.offset+i),i=this.source.indexOf(`
|
|
179
|
-
`,i)+1}return{type:a,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(a){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const i=vd(a),c=wl(i);return c.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:c,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const i=vd(a),c=wl(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:c,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(a,i){return this.type!=="comment"||this.indent<=i?!1:a.every(c=>c.type==="newline"||c.type==="space")}*documentEnd(a){this.type!=="doc-mode"&&(a.end?a.end.push(this.sourceToken):a.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(a){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:a.end?a.end.push(this.sourceToken):a.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function WG(e){const a=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||a&&new KG||null,prettyErrors:a}}function JG(e,a={}){const{lineCounter:i,prettyErrors:c}=WG(a),o=new QG(i==null?void 0:i.addNewLine),l=new ZG(a);let u=null;for(const h of l.compose(o.parse(e),!0,e.length))if(!u)u=h;else if(u.options.logLevel!=="silent"){u.errors.push(new l2(h.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return c&&i&&(u.errors.forEach(YD(e,i)),u.warnings.forEach(YD(e,i))),u}function tO(e,a,i){let c;const o=JG(e,i);if(!o)return null;if(o.warnings.forEach(l=>ZV(o.options.logLevel,l)),o.errors.length>0){if(o.options.logLevel!=="silent")throw o.errors[0];o.errors=[]}return o.toJS(Object.assign({reviver:c},i))}const e$={service:"server",database:"database",container:"box",frontend:"globe","third-party-gateway":"plug"};function t$(e){return"milestones"in e||"diagramName"in e}function a$(e){const i=[...e.milestones??[]].sort((p,g)=>p.id-g.id),c=p=>`m${p}`,o=i.map(p=>({id:c(p.id),label:p.name,description:p.description})),u=(e.elements??[]).map(p=>{const g=p.sms,m=p.ems,v=p.metadata??{},M={};Array.isArray(v.team)&&(M.team=v.team),Array.isArray(v.techStack)&&(M.techStack=v.techStack);const b=typeof p.icon=="string"?p.icon:e$[String(p.type)],w=typeof p.type=="string"?p.type:b;return{id:String(p.id),label:String(p.label),icon:b,kind:w,parentId:p.parentId==null?void 0:String(p.parentId),lifespan:{startMilestone:typeof g=="number"?c(g):void 0,endMilestone:typeof m=="number"?c(m):void 0},metadata:Object.keys(M).length?M:void 0}}),f=(e.connectors??[]).map(p=>({id:String(p.id),source:String(p.sourceId),target:String(p.targetId),label:p.label==null?void 0:String(p.label),directed:!0}));return{title:e.diagramName?String(e.diagramName):void 0,timeline:o,elements:u,connectors:f}}function n$(e,a){if(/\.ya?ml$/i.test(a??""))return tO(e);try{return JSON.parse(e)}catch{return tO(e)}}function zT(e,a){const i=n$(e,a);if(i&&typeof i=="object"&&!Array.isArray(i)){const c=i;if(t$(c))return a$(c)}return i}function Md(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var W_={exports:{}},aO;function i$(){return aO||(aO=1,(function(e,a){(function(i){e.exports=i()})(function(){return(function(){function i(c,o,l){function u(p,g){if(!o[p]){if(!c[p]){var m=typeof Md=="function"&&Md;if(!g&&m)return m(p,!0);if(h)return h(p,!0);var v=new Error("Cannot find module '"+p+"'");throw v.code="MODULE_NOT_FOUND",v}var M=o[p]={exports:{}};c[p][0].call(M.exports,function(b){var w=c[p][1][b];return u(w||b)},M,M.exports,i,c,o,l)}return o[p].exports}for(var h=typeof Md=="function"&&Md,f=0;f<l.length;f++)u(l[f]);return u}return i})()({1:[function(i,c,o){Object.defineProperty(o,"__esModule",{value:!0});var l=(function(){function p(g,m){for(var v=0;v<m.length;v++){var M=m[v];M.enumerable=M.enumerable||!1,M.configurable=!0,"value"in M&&(M.writable=!0),Object.defineProperty(g,M.key,M)}}return function(g,m,v){return m&&p(g.prototype,m),v&&p(g,v),g}})();function u(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")}var h=(function(){function p(){var g=this,m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v=m.defaultLayoutOptions,M=v===void 0?{}:v,b=m.algorithms,w=b===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:b,L=m.workerFactory,S=m.workerUrl;if(u(this,p),this.defaultLayoutOptions=M,this.initialized=!1,typeof S>"u"&&typeof L>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var q=L;typeof S<"u"&&typeof L>"u"&&(q=function(H){return new Worker(H)});var C=q(S);if(typeof C.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new f(C),this.worker.postMessage({cmd:"register",algorithms:w}).then(function(z){return g.initialized=!0}).catch(console.err)}return l(p,[{key:"layout",value:function(m){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},M=v.layoutOptions,b=M===void 0?this.defaultLayoutOptions:M,w=v.logging,L=w===void 0?!1:w,S=v.measureExecutionTime,q=S===void 0?!1:S;return m?this.worker.postMessage({cmd:"layout",graph:m,layoutOptions:b,options:{logging:L,measureExecutionTime:q}}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker&&this.worker.terminate()}}]),p})();o.default=h;var f=(function(){function p(g){var m=this;if(u(this,p),g===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=g,this.worker.onmessage=function(v){setTimeout(function(){m.receive(m,v)},0)}}return l(p,[{key:"postMessage",value:function(m){var v=this.id||0;this.id=v+1,m.id=v;var M=this;return new Promise(function(b,w){M.resolvers[v]=function(L,S){L?(M.convertGwtStyleError(L),w(L)):b(S)},M.worker.postMessage(m)})}},{key:"receive",value:function(m,v){var M=v.data,b=m.resolvers[M.id];b&&(delete m.resolvers[M.id],M.error?b(M.error):b(null,M.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(m){if(m){var v=m.__java$exception;v&&(v.cause&&v.cause.backingJsObject&&(m.cause=v.cause.backingJsObject,this.convertGwtStyleError(m.cause)),delete m.__java$exception)}}}]),p})()},{}],2:[function(i,c,o){var l=i("./elk-api.js").default;Object.defineProperty(c.exports,"__esModule",{value:!0}),c.exports=l,l.default=l},{"./elk-api.js":1}]},{},[2])(2)})})(W_)),W_.exports}var c$=i$();const r$=GT(c$),nO=""+new URL("elk-worker.min--dAJroGl.js",import.meta.url).href;let J_=null;function o$(){return J_||(J_=new r$({workerFactory:e=>new Worker(e??nO),workerUrl:nO})),J_}const l$={"elk.algorithm":"layered","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"60","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.edgeRouting":"ORTHOGONAL"},MB=30,s$=`[top=${MB+6},left=14,bottom=14,right=14]`;function d$(e){const a=new Map;for(const c of e)a.set(c.id,{id:c.id,width:c.width,height:c.height,children:[]});const i=[];for(const c of e){const o=a.get(c.id),l=c.parentId?a.get(c.parentId):void 0;l?l.children.push(o):i.push(o)}for(const c of a.values())c.children&&c.children.length>0&&(c.layoutOptions={"elk.padding":s$});return i}function u$(e,a,i){return{id:"root",layoutOptions:{...l$,"elk.direction":i},children:d$(e),edges:a.map(c=>({id:c.id,sources:[c.source],targets:[c.target]}))}}function xB(e,a=0,i=0,c=void 0,o=[]){for(const l of e){const u=l.x??0,h=l.y??0,f=u+a,p=h+i;o.push({id:l.id,x:f,y:p,relativeX:u,relativeY:h,width:l.width??0,height:l.height??0,parentId:c}),l.children&&l.children.length>0&&xB(l.children,f,p,l.id,o)}return o}const h$=170,y$=52;function f$(e){const a=e.elements.map(u=>({id:u.id,width:h$,height:y$,parentId:u.parentId})),i=new Map(e.elements.map(u=>[u.id,u.parentId])),c=new Set(e.elements.map(u=>u.id)),o=(u,h)=>{let f=h;for(;f;){if(f===u)return!0;f=i.get(f)}return!1},l=e.connectors.filter(u=>c.has(u.source)&&c.has(u.target)&&!o(u.source,u.target)&&!o(u.target,u.source)).map(u=>({id:u.id,source:u.source,target:u.target}));return{nodes:a,edges:l}}async function iO(e,a="DOWN"){const{nodes:i,edges:c}=f$(e);if(i.length===0)return{positions:new Map,bounds:{width:0,height:0}};const o=u$(i,c,a),l=await o$().layout(o),u=xB(l.children??[]),h=new Map(u.map(g=>[g.id,g])),f=Math.max(0,...u.map(g=>g.x+g.width)),p=Math.max(0,...u.map(g=>g.y+g.height));return{positions:h,bounds:{width:f,height:p}}}const Le=IF((e,a)=>({diagram:null,timeline:null,report:null,masterLayout:null,loadStatus:"empty",errors:[],active:0,view:"graph",selectedElementId:null,compare:{enabled:!1,from:0,to:0},filter:{},colorProperty:null,loadDiagram:async i=>{e({loadStatus:"loading",errors:[]});const{diagram:c,report:o}=RD(i);if(!c)return e({loadStatus:"error",report:o,errors:o.schemaErrors}),!1;const l=new MT(c.timeline),u=Math.max(0,l.length-1);e({diagram:c,timeline:l,report:o,masterLayout:null,errors:o.schemaErrors,active:0,selectedElementId:null,compare:{enabled:!1,from:0,to:u},filter:{},colorProperty:null});try{const h=await iO(c,"DOWN");return a().diagram!==c||e({masterLayout:h,loadStatus:"ready"}),!0}catch(h){return a().diagram!==c||e({loadStatus:"error",errors:[String(h)]}),!1}},reloadDiagram:async i=>{const c=a();e({loadStatus:"loading",errors:[]});const{diagram:o,report:l}=RD(i);if(!o)return e({loadStatus:"error",report:l,errors:l.schemaErrors}),!1;const u=new MT(o.timeline),h=Math.max(0,u.length-1),f=Math.max(0,Math.min(h,c.active)),p={enabled:c.compare.enabled,from:Math.max(0,Math.min(h,c.compare.from)),to:Math.max(0,Math.min(h,c.compare.to))},m=o.elements.some(v=>v.id===c.selectedElementId)?c.selectedElementId:null;e({diagram:o,timeline:u,report:l,masterLayout:null,errors:l.schemaErrors,active:f,selectedElementId:m,compare:p});try{const v=await iO(o,"DOWN");return a().diagram!==o||e({masterLayout:v,loadStatus:"ready"}),!0}catch(v){return a().diagram!==o||e({loadStatus:"error",errors:[String(v)]}),!1}},setActive:i=>{const{timeline:c}=a();e({active:c?c.clamp(i):0})},stepActive:i=>{const{active:c,timeline:o}=a();e({active:o?o.clamp(c+i):0})},setView:i=>e({view:i}),selectElement:i=>e({selectedElementId:i}),setCompare:i=>e(c=>{const o={...c.compare,...i},l=c.timeline?Math.max(0,c.timeline.length-1):0,u=h=>Math.max(0,Math.min(l,h));return i.enabled&&!c.compare.enabled&&o.from===0&&o.to===0&&(o.from=0,o.to=l),o.from=u(o.from),o.to=u(o.to),{compare:o}}),toggleFilterValue:(i,c)=>e(o=>{if(!o.diagram)return{};const l=Io(o.diagram).find(g=>g.name===i);if(!l)return{};const u=QI(l),h=o.filter[i]??u,f=h.includes(c)?h.filter(g=>g!==c):[...h,c],p={...o.filter};return f.length===u.length?delete p[i]:p[i]=f,{filter:p}}),resetFilterProperty:i=>e(c=>{const o={...c.filter};return delete o[i],{filter:o}}),clearFilterProperty:i=>e(c=>({filter:{...c.filter,[i]:[]}})),clearFilter:()=>e({filter:{}}),setColorProperty:i=>e({colorProperty:i})}));function wt(e){if(typeof e=="string"||typeof e=="number")return""+e;let a="";if(Array.isArray(e))for(let i=0,c;i<e.length;i++)(c=wt(e[i]))!==""&&(a+=(a&&" ")+c);else for(let i in e)e[i]&&(a+=(a&&" ")+i);return a}var p$={value:()=>{}};function lz(){for(var e=0,a=arguments.length,i={},c;e<a;++e){if(!(c=arguments[e]+"")||c in i||/[\s.]/.test(c))throw new Error("illegal type: "+c);i[c]=[]}return new jd(i)}function jd(e){this._=e}function k$(e,a){return e.trim().split(/^|\s+/).map(function(i){var c="",o=i.indexOf(".");if(o>=0&&(c=i.slice(o+1),i=i.slice(0,o)),i&&!a.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:c}})}jd.prototype=lz.prototype={constructor:jd,on:function(e,a){var i=this._,c=k$(e+"",i),o,l=-1,u=c.length;if(arguments.length<2){for(;++l<u;)if((o=(e=c[l]).type)&&(o=m$(i[o],e.name)))return o;return}if(a!=null&&typeof a!="function")throw new Error("invalid callback: "+a);for(;++l<u;)if(o=(e=c[l]).type)i[o]=cO(i[o],e.name,a);else if(a==null)for(o in i)i[o]=cO(i[o],e.name,null);return this},copy:function(){var e={},a=this._;for(var i in a)e[i]=a[i].slice();return new jd(e)},call:function(e,a){if((o=arguments.length-2)>0)for(var i=new Array(o),c=0,o,l;c<o;++c)i[c]=arguments[c+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],c=0,o=l.length;c<o;++c)l[c].value.apply(a,i)},apply:function(e,a,i){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var c=this._[e],o=0,l=c.length;o<l;++o)c[o].value.apply(a,i)}};function m$(e,a){for(var i=0,c=e.length,o;i<c;++i)if((o=e[i]).name===a)return o.value}function cO(e,a,i){for(var c=0,o=e.length;c<o;++c)if(e[c].name===a){e[c]=p$,e=e.slice(0,c).concat(e.slice(c+1));break}return i!=null&&e.push({name:a,value:i}),e}var qT="http://www.w3.org/1999/xhtml";const rO={svg:"http://www.w3.org/2000/svg",xhtml:qT,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function sz(e){var a=e+="",i=a.indexOf(":");return i>=0&&(a=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),rO.hasOwnProperty(a)?{space:rO[a],local:e}:e}function g$(e){return function(){var a=this.ownerDocument,i=this.namespaceURI;return i===qT&&a.documentElement.namespaceURI===qT?a.createElement(e):a.createElementNS(i,e)}}function v$(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function wB(e){var a=sz(e);return(a.local?v$:g$)(a)}function M$(){}function uH(e){return e==null?M$:function(){return this.querySelector(e)}}function x$(e){typeof e!="function"&&(e=uH(e));for(var a=this._groups,i=a.length,c=new Array(i),o=0;o<i;++o)for(var l=a[o],u=l.length,h=c[o]=new Array(u),f,p,g=0;g<u;++g)(f=l[g])&&(p=e.call(f,f.__data__,g,l))&&("__data__"in f&&(p.__data__=f.__data__),h[g]=p);return new oa(c,this._parents)}function w$(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function b$(){return[]}function bB(e){return e==null?b$:function(){return this.querySelectorAll(e)}}function L$(e){return function(){return w$(e.apply(this,arguments))}}function S$(e){typeof e=="function"?e=L$(e):e=bB(e);for(var a=this._groups,i=a.length,c=[],o=[],l=0;l<i;++l)for(var u=a[l],h=u.length,f,p=0;p<h;++p)(f=u[p])&&(c.push(e.call(f,f.__data__,p,u)),o.push(f));return new oa(c,o)}function LB(e){return function(){return this.matches(e)}}function SB(e){return function(a){return a.matches(e)}}var C$=Array.prototype.find;function A$(e){return function(){return C$.call(this.children,e)}}function I$(){return this.firstElementChild}function z$(e){return this.select(e==null?I$:A$(typeof e=="function"?e:SB(e)))}var q$=Array.prototype.filter;function _$(){return Array.from(this.children)}function T$(e){return function(){return q$.call(this.children,e)}}function H$(e){return this.selectAll(e==null?_$:T$(typeof e=="function"?e:SB(e)))}function j$(e){typeof e!="function"&&(e=LB(e));for(var a=this._groups,i=a.length,c=new Array(i),o=0;o<i;++o)for(var l=a[o],u=l.length,h=c[o]=[],f,p=0;p<u;++p)(f=l[p])&&e.call(f,f.__data__,p,l)&&h.push(f);return new oa(c,this._parents)}function CB(e){return new Array(e.length)}function E$(){return new oa(this._enter||this._groups.map(CB),this._parents)}function RI(e,a){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=a}RI.prototype={constructor:RI,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,a){return this._parent.insertBefore(e,a)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function N$(e){return function(){return e}}function D$(e,a,i,c,o,l){for(var u=0,h,f=a.length,p=l.length;u<p;++u)(h=a[u])?(h.__data__=l[u],c[u]=h):i[u]=new RI(e,l[u]);for(;u<f;++u)(h=a[u])&&(o[u]=h)}function O$(e,a,i,c,o,l,u){var h,f,p=new Map,g=a.length,m=l.length,v=new Array(g),M;for(h=0;h<g;++h)(f=a[h])&&(v[h]=M=u.call(f,f.__data__,h,a)+"",p.has(M)?o[h]=f:p.set(M,f));for(h=0;h<m;++h)M=u.call(e,l[h],h,l)+"",(f=p.get(M))?(c[h]=f,f.__data__=l[h],p.delete(M)):i[h]=new RI(e,l[h]);for(h=0;h<g;++h)(f=a[h])&&p.get(v[h])===f&&(o[h]=f)}function V$(e){return e.__data__}function B$(e,a){if(!arguments.length)return Array.from(this,V$);var i=a?O$:D$,c=this._parents,o=this._groups;typeof e!="function"&&(e=N$(e));for(var l=o.length,u=new Array(l),h=new Array(l),f=new Array(l),p=0;p<l;++p){var g=c[p],m=o[p],v=m.length,M=R$(e.call(g,g&&g.__data__,p,c)),b=M.length,w=h[p]=new Array(b),L=u[p]=new Array(b),S=f[p]=new Array(v);i(g,m,w,L,S,M,a);for(var q=0,C=0,z,H;q<b;++q)if(z=w[q]){for(q>=C&&(C=q+1);!(H=L[C])&&++C<b;);z._next=H||null}}return u=new oa(u,c),u._enter=h,u._exit=f,u}function R$(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function U$(){return new oa(this._exit||this._groups.map(CB),this._parents)}function P$(e,a,i){var c=this.enter(),o=this,l=this.exit();return typeof e=="function"?(c=e(c),c&&(c=c.selection())):c=c.append(e+""),a!=null&&(o=a(o),o&&(o=o.selection())),i==null?l.remove():i(l),c&&o?c.merge(o).order():o}function F$(e){for(var a=e.selection?e.selection():e,i=this._groups,c=a._groups,o=i.length,l=c.length,u=Math.min(o,l),h=new Array(o),f=0;f<u;++f)for(var p=i[f],g=c[f],m=p.length,v=h[f]=new Array(m),M,b=0;b<m;++b)(M=p[b]||g[b])&&(v[b]=M);for(;f<o;++f)h[f]=i[f];return new oa(h,this._parents)}function Z$(){for(var e=this._groups,a=-1,i=e.length;++a<i;)for(var c=e[a],o=c.length-1,l=c[o],u;--o>=0;)(u=c[o])&&(l&&u.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(u,l),l=u);return this}function G$(e){e||(e=$$);function a(m,v){return m&&v?e(m.__data__,v.__data__):!m-!v}for(var i=this._groups,c=i.length,o=new Array(c),l=0;l<c;++l){for(var u=i[l],h=u.length,f=o[l]=new Array(h),p,g=0;g<h;++g)(p=u[g])&&(f[g]=p);f.sort(a)}return new oa(o,this._parents).order()}function $$(e,a){return e<a?-1:e>a?1:e>=a?0:NaN}function X$(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Y$(){return Array.from(this)}function K$(){for(var e=this._groups,a=0,i=e.length;a<i;++a)for(var c=e[a],o=0,l=c.length;o<l;++o){var u=c[o];if(u)return u}return null}function Q$(){let e=0;for(const a of this)++e;return e}function W$(){return!this.node()}function J$(e){for(var a=this._groups,i=0,c=a.length;i<c;++i)for(var o=a[i],l=0,u=o.length,h;l<u;++l)(h=o[l])&&e.call(h,h.__data__,l,o);return this}function eX(e){return function(){this.removeAttribute(e)}}function tX(e){return function(){this.removeAttributeNS(e.space,e.local)}}function aX(e,a){return function(){this.setAttribute(e,a)}}function nX(e,a){return function(){this.setAttributeNS(e.space,e.local,a)}}function iX(e,a){return function(){var i=a.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function cX(e,a){return function(){var i=a.apply(this,arguments);i==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,i)}}function rX(e,a){var i=sz(e);if(arguments.length<2){var c=this.node();return i.local?c.getAttributeNS(i.space,i.local):c.getAttribute(i)}return this.each((a==null?i.local?tX:eX:typeof a=="function"?i.local?cX:iX:i.local?nX:aX)(i,a))}function AB(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function oX(e){return function(){this.style.removeProperty(e)}}function lX(e,a,i){return function(){this.style.setProperty(e,a,i)}}function sX(e,a,i){return function(){var c=a.apply(this,arguments);c==null?this.style.removeProperty(e):this.style.setProperty(e,c,i)}}function dX(e,a,i){return arguments.length>1?this.each((a==null?oX:typeof a=="function"?sX:lX)(e,a,i??"")):Gl(this.node(),e)}function Gl(e,a){return e.style.getPropertyValue(a)||AB(e).getComputedStyle(e,null).getPropertyValue(a)}function uX(e){return function(){delete this[e]}}function hX(e,a){return function(){this[e]=a}}function yX(e,a){return function(){var i=a.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function fX(e,a){return arguments.length>1?this.each((a==null?uX:typeof a=="function"?yX:hX)(e,a)):this.node()[e]}function IB(e){return e.trim().split(/^|\s+/)}function hH(e){return e.classList||new zB(e)}function zB(e){this._node=e,this._names=IB(e.getAttribute("class")||"")}zB.prototype={add:function(e){var a=this._names.indexOf(e);a<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var a=this._names.indexOf(e);a>=0&&(this._names.splice(a,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function qB(e,a){for(var i=hH(e),c=-1,o=a.length;++c<o;)i.add(a[c])}function _B(e,a){for(var i=hH(e),c=-1,o=a.length;++c<o;)i.remove(a[c])}function pX(e){return function(){qB(this,e)}}function kX(e){return function(){_B(this,e)}}function mX(e,a){return function(){(a.apply(this,arguments)?qB:_B)(this,e)}}function gX(e,a){var i=IB(e+"");if(arguments.length<2){for(var c=hH(this.node()),o=-1,l=i.length;++o<l;)if(!c.contains(i[o]))return!1;return!0}return this.each((typeof a=="function"?mX:a?pX:kX)(i,a))}function vX(){this.textContent=""}function MX(e){return function(){this.textContent=e}}function xX(e){return function(){var a=e.apply(this,arguments);this.textContent=a??""}}function wX(e){return arguments.length?this.each(e==null?vX:(typeof e=="function"?xX:MX)(e)):this.node().textContent}function bX(){this.innerHTML=""}function LX(e){return function(){this.innerHTML=e}}function SX(e){return function(){var a=e.apply(this,arguments);this.innerHTML=a??""}}function CX(e){return arguments.length?this.each(e==null?bX:(typeof e=="function"?SX:LX)(e)):this.node().innerHTML}function AX(){this.nextSibling&&this.parentNode.appendChild(this)}function IX(){return this.each(AX)}function zX(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qX(){return this.each(zX)}function _X(e){var a=typeof e=="function"?e:wB(e);return this.select(function(){return this.appendChild(a.apply(this,arguments))})}function TX(){return null}function HX(e,a){var i=typeof e=="function"?e:wB(e),c=a==null?TX:typeof a=="function"?a:uH(a);return this.select(function(){return this.insertBefore(i.apply(this,arguments),c.apply(this,arguments)||null)})}function jX(){var e=this.parentNode;e&&e.removeChild(this)}function EX(){return this.each(jX)}function NX(){var e=this.cloneNode(!1),a=this.parentNode;return a?a.insertBefore(e,this.nextSibling):e}function DX(){var e=this.cloneNode(!0),a=this.parentNode;return a?a.insertBefore(e,this.nextSibling):e}function OX(e){return this.select(e?DX:NX)}function VX(e){return arguments.length?this.property("__data__",e):this.node().__data__}function BX(e){return function(a){e.call(this,a,this.__data__)}}function RX(e){return e.trim().split(/^|\s+/).map(function(a){var i="",c=a.indexOf(".");return c>=0&&(i=a.slice(c+1),a=a.slice(0,c)),{type:a,name:i}})}function UX(e){return function(){var a=this.__on;if(a){for(var i=0,c=-1,o=a.length,l;i<o;++i)l=a[i],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):a[++c]=l;++c?a.length=c:delete this.__on}}}function PX(e,a,i){return function(){var c=this.__on,o,l=BX(a);if(c){for(var u=0,h=c.length;u<h;++u)if((o=c[u]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=l,o.options=i),o.value=a;return}}this.addEventListener(e.type,l,i),o={type:e.type,name:e.name,value:a,listener:l,options:i},c?c.push(o):this.__on=[o]}}function FX(e,a,i){var c=RX(e+""),o,l=c.length,u;if(arguments.length<2){var h=this.node().__on;if(h){for(var f=0,p=h.length,g;f<p;++f)for(o=0,g=h[f];o<l;++o)if((u=c[o]).type===g.type&&u.name===g.name)return g.value}return}for(h=a?PX:UX,o=0;o<l;++o)this.each(h(c[o],a,i));return this}function TB(e,a,i){var c=AB(e),o=c.CustomEvent;typeof o=="function"?o=new o(a,i):(o=c.document.createEvent("Event"),i?(o.initEvent(a,i.bubbles,i.cancelable),o.detail=i.detail):o.initEvent(a,!1,!1)),e.dispatchEvent(o)}function ZX(e,a){return function(){return TB(this,e,a)}}function GX(e,a){return function(){return TB(this,e,a.apply(this,arguments))}}function $X(e,a){return this.each((typeof a=="function"?GX:ZX)(e,a))}function*XX(){for(var e=this._groups,a=0,i=e.length;a<i;++a)for(var c=e[a],o=0,l=c.length,u;o<l;++o)(u=c[o])&&(yield u)}var HB=[null];function oa(e,a){this._groups=e,this._parents=a}function B2(){return new oa([[document.documentElement]],HB)}function YX(){return this}oa.prototype=B2.prototype={constructor:oa,select:x$,selectAll:S$,selectChild:z$,selectChildren:H$,filter:j$,data:B$,enter:E$,exit:U$,join:P$,merge:F$,selection:YX,order:Z$,sort:G$,call:X$,nodes:Y$,node:K$,size:Q$,empty:W$,each:J$,attr:rX,style:dX,property:fX,classed:gX,text:wX,html:CX,raise:IX,lower:qX,append:_X,insert:HX,remove:EX,clone:OX,datum:VX,on:FX,dispatch:$X,[Symbol.iterator]:XX};function ra(e){return typeof e=="string"?new oa([[document.querySelector(e)]],[document.documentElement]):new oa([[e]],HB)}function KX(e){let a;for(;a=e.sourceEvent;)e=a;return e}function Ia(e,a){if(e=KX(e),a===void 0&&(a=e.currentTarget),a){var i=a.ownerSVGElement||a;if(i.createSVGPoint){var c=i.createSVGPoint();return c.x=e.clientX,c.y=e.clientY,c=c.matrixTransform(a.getScreenCTM().inverse()),[c.x,c.y]}if(a.getBoundingClientRect){var o=a.getBoundingClientRect();return[e.clientX-o.left-a.clientLeft,e.clientY-o.top-a.clientTop]}}return[e.pageX,e.pageY]}const QX={passive:!1},b2={capture:!0,passive:!1};function eT(e){e.stopImmediatePropagation()}function jl(e){e.preventDefault(),e.stopImmediatePropagation()}function jB(e){var a=e.document.documentElement,i=ra(e).on("dragstart.drag",jl,b2);"onselectstart"in a?i.on("selectstart.drag",jl,b2):(a.__noselect=a.style.MozUserSelect,a.style.MozUserSelect="none")}function EB(e,a){var i=e.document.documentElement,c=ra(e).on("dragstart.drag",null);a&&(c.on("click.drag",jl,b2),setTimeout(function(){c.on("click.drag",null)},0)),"onselectstart"in i?c.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const xd=e=>()=>e;function _T(e,{sourceEvent:a,subject:i,target:c,identifier:o,active:l,x:u,y:h,dx:f,dy:p,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:a,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:c,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:g}})}_T.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function WX(e){return!e.ctrlKey&&!e.button}function JX(){return this.parentNode}function eY(e,a){return a??{x:e.x,y:e.y}}function tY(){return navigator.maxTouchPoints||"ontouchstart"in this}function NB(){var e=WX,a=JX,i=eY,c=tY,o={},l=lz("start","drag","end"),u=0,h,f,p,g,m=0;function v(z){z.on("mousedown.drag",M).filter(c).on("touchstart.drag",L).on("touchmove.drag",S,QX).on("touchend.drag touchcancel.drag",q).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function M(z,H){if(!(g||!e.call(this,z,H))){var N=C(this,a.call(this,z,H),z,H,"mouse");N&&(ra(z.view).on("mousemove.drag",b,b2).on("mouseup.drag",w,b2),jB(z.view),eT(z),p=!1,h=z.clientX,f=z.clientY,N("start",z))}}function b(z){if(jl(z),!p){var H=z.clientX-h,N=z.clientY-f;p=H*H+N*N>m}o.mouse("drag",z)}function w(z){ra(z.view).on("mousemove.drag mouseup.drag",null),EB(z.view,p),jl(z),o.mouse("end",z)}function L(z,H){if(e.call(this,z,H)){var N=z.changedTouches,E=a.call(this,z,H),R=N.length,O,ae;for(O=0;O<R;++O)(ae=C(this,E,z,H,N[O].identifier,N[O]))&&(eT(z),ae("start",z,N[O]))}}function S(z){var H=z.changedTouches,N=H.length,E,R;for(E=0;E<N;++E)(R=o[H[E].identifier])&&(jl(z),R("drag",z,H[E]))}function q(z){var H=z.changedTouches,N=H.length,E,R;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),E=0;E<N;++E)(R=o[H[E].identifier])&&(eT(z),R("end",z,H[E]))}function C(z,H,N,E,R,O){var ae=l.copy(),G=Ia(O||N,H),Z,ne,j;if((j=i.call(z,new _T("beforestart",{sourceEvent:N,target:v,identifier:R,active:u,x:G[0],y:G[1],dx:0,dy:0,dispatch:ae}),E))!=null)return Z=j.x-G[0]||0,ne=j.y-G[1]||0,function X(T,V,U){var F=G,J;switch(T){case"start":o[R]=X,J=u++;break;case"end":delete o[R],--u;case"drag":G=Ia(U||V,H),J=u;break}ae.call(T,z,new _T(T,{sourceEvent:V,subject:j,target:v,identifier:R,active:J,x:G[0]+Z,y:G[1]+ne,dx:G[0]-F[0],dy:G[1]-F[1],dispatch:ae}),E)}}return v.filter=function(z){return arguments.length?(e=typeof z=="function"?z:xd(!!z),v):e},v.container=function(z){return arguments.length?(a=typeof z=="function"?z:xd(z),v):a},v.subject=function(z){return arguments.length?(i=typeof z=="function"?z:xd(z),v):i},v.touchable=function(z){return arguments.length?(c=typeof z=="function"?z:xd(!!z),v):c},v.on=function(){var z=l.on.apply(l,arguments);return z===l?v:z},v.clickDistance=function(z){return arguments.length?(m=(z=+z)*z,v):Math.sqrt(m)},v}function yH(e,a,i){e.prototype=a.prototype=i,i.constructor=e}function DB(e,a){var i=Object.create(e.prototype);for(var c in a)i[c]=a[c];return i}function R2(){}var L2=.7,UI=1/L2,El="\\s*([+-]?\\d+)\\s*",S2="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Za="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",aY=/^#([0-9a-f]{3,8})$/,nY=new RegExp(`^rgb\\(${El},${El},${El}\\)$`),iY=new RegExp(`^rgb\\(${Za},${Za},${Za}\\)$`),cY=new RegExp(`^rgba\\(${El},${El},${El},${S2}\\)$`),rY=new RegExp(`^rgba\\(${Za},${Za},${Za},${S2}\\)$`),oY=new RegExp(`^hsl\\(${S2},${Za},${Za}\\)$`),lY=new RegExp(`^hsla\\(${S2},${Za},${Za},${S2}\\)$`),oO={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};yH(R2,qo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:lO,formatHex:lO,formatHex8:sY,formatHsl:dY,formatRgb:sO,toString:sO});function lO(){return this.rgb().formatHex()}function sY(){return this.rgb().formatHex8()}function dY(){return OB(this).formatHsl()}function sO(){return this.rgb().formatRgb()}function qo(e){var a,i;return e=(e+"").trim().toLowerCase(),(a=aY.exec(e))?(i=a[1].length,a=parseInt(a[1],16),i===6?dO(a):i===3?new Kt(a>>8&15|a>>4&240,a>>4&15|a&240,(a&15)<<4|a&15,1):i===8?wd(a>>24&255,a>>16&255,a>>8&255,(a&255)/255):i===4?wd(a>>12&15|a>>8&240,a>>8&15|a>>4&240,a>>4&15|a&240,((a&15)<<4|a&15)/255):null):(a=nY.exec(e))?new Kt(a[1],a[2],a[3],1):(a=iY.exec(e))?new Kt(a[1]*255/100,a[2]*255/100,a[3]*255/100,1):(a=cY.exec(e))?wd(a[1],a[2],a[3],a[4]):(a=rY.exec(e))?wd(a[1]*255/100,a[2]*255/100,a[3]*255/100,a[4]):(a=oY.exec(e))?yO(a[1],a[2]/100,a[3]/100,1):(a=lY.exec(e))?yO(a[1],a[2]/100,a[3]/100,a[4]):oO.hasOwnProperty(e)?dO(oO[e]):e==="transparent"?new Kt(NaN,NaN,NaN,0):null}function dO(e){return new Kt(e>>16&255,e>>8&255,e&255,1)}function wd(e,a,i,c){return c<=0&&(e=a=i=NaN),new Kt(e,a,i,c)}function uY(e){return e instanceof R2||(e=qo(e)),e?(e=e.rgb(),new Kt(e.r,e.g,e.b,e.opacity)):new Kt}function TT(e,a,i,c){return arguments.length===1?uY(e):new Kt(e,a,i,c??1)}function Kt(e,a,i,c){this.r=+e,this.g=+a,this.b=+i,this.opacity=+c}yH(Kt,TT,DB(R2,{brighter(e){return e=e==null?UI:Math.pow(UI,e),new Kt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?L2:Math.pow(L2,e),new Kt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Kt(Lo(this.r),Lo(this.g),Lo(this.b),PI(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:uO,formatHex:uO,formatHex8:hY,formatRgb:hO,toString:hO}));function uO(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}`}function hY(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}${bo((isNaN(this.opacity)?1:this.opacity)*255)}`}function hO(){const e=PI(this.opacity);return`${e===1?"rgb(":"rgba("}${Lo(this.r)}, ${Lo(this.g)}, ${Lo(this.b)}${e===1?")":`, ${e})`}`}function PI(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Lo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function bo(e){return e=Lo(e),(e<16?"0":"")+e.toString(16)}function yO(e,a,i,c){return c<=0?e=a=i=NaN:i<=0||i>=1?e=a=NaN:a<=0&&(e=NaN),new za(e,a,i,c)}function OB(e){if(e instanceof za)return new za(e.h,e.s,e.l,e.opacity);if(e instanceof R2||(e=qo(e)),!e)return new za;if(e instanceof za)return e;e=e.rgb();var a=e.r/255,i=e.g/255,c=e.b/255,o=Math.min(a,i,c),l=Math.max(a,i,c),u=NaN,h=l-o,f=(l+o)/2;return h?(a===l?u=(i-c)/h+(i<c)*6:i===l?u=(c-a)/h+2:u=(a-i)/h+4,h/=f<.5?l+o:2-l-o,u*=60):h=f>0&&f<1?0:u,new za(u,h,f,e.opacity)}function yY(e,a,i,c){return arguments.length===1?OB(e):new za(e,a,i,c??1)}function za(e,a,i,c){this.h=+e,this.s=+a,this.l=+i,this.opacity=+c}yH(za,yY,DB(R2,{brighter(e){return e=e==null?UI:Math.pow(UI,e),new za(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?L2:Math.pow(L2,e),new za(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,a=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,c=i+(i<.5?i:1-i)*a,o=2*i-c;return new Kt(tT(e>=240?e-240:e+120,o,c),tT(e,o,c),tT(e<120?e+240:e-120,o,c),this.opacity)},clamp(){return new za(fO(this.h),bd(this.s),bd(this.l),PI(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=PI(this.opacity);return`${e===1?"hsl(":"hsla("}${fO(this.h)}, ${bd(this.s)*100}%, ${bd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fO(e){return e=(e||0)%360,e<0?e+360:e}function bd(e){return Math.max(0,Math.min(1,e||0))}function tT(e,a,i){return(e<60?a+(i-a)*e/60:e<180?i:e<240?a+(i-a)*(240-e)/60:a)*255}const fH=e=>()=>e;function fY(e,a){return function(i){return e+i*a}}function pY(e,a,i){return e=Math.pow(e,i),a=Math.pow(a,i)-e,i=1/i,function(c){return Math.pow(e+c*a,i)}}function kY(e){return(e=+e)==1?VB:function(a,i){return i-a?pY(a,i,e):fH(isNaN(a)?i:a)}}function VB(e,a){var i=a-e;return i?fY(e,i):fH(isNaN(e)?a:e)}const FI=(function e(a){var i=kY(a);function c(o,l){var u=i((o=TT(o)).r,(l=TT(l)).r),h=i(o.g,l.g),f=i(o.b,l.b),p=VB(o.opacity,l.opacity);return function(g){return o.r=u(g),o.g=h(g),o.b=f(g),o.opacity=p(g),o+""}}return c.gamma=e,c})(1);function mY(e,a){a||(a=[]);var i=e?Math.min(a.length,e.length):0,c=a.slice(),o;return function(l){for(o=0;o<i;++o)c[o]=e[o]*(1-l)+a[o]*l;return c}}function gY(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vY(e,a){var i=a?a.length:0,c=e?Math.min(i,e.length):0,o=new Array(c),l=new Array(i),u;for(u=0;u<c;++u)o[u]=y2(e[u],a[u]);for(;u<i;++u)l[u]=a[u];return function(h){for(u=0;u<c;++u)l[u]=o[u](h);return l}}function MY(e,a){var i=new Date;return e=+e,a=+a,function(c){return i.setTime(e*(1-c)+a*c),i}}function Ua(e,a){return e=+e,a=+a,function(i){return e*(1-i)+a*i}}function xY(e,a){var i={},c={},o;(e===null||typeof e!="object")&&(e={}),(a===null||typeof a!="object")&&(a={});for(o in a)o in e?i[o]=y2(e[o],a[o]):c[o]=a[o];return function(l){for(o in i)c[o]=i[o](l);return c}}var HT=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,aT=new RegExp(HT.source,"g");function wY(e){return function(){return e}}function bY(e){return function(a){return e(a)+""}}function BB(e,a){var i=HT.lastIndex=aT.lastIndex=0,c,o,l,u=-1,h=[],f=[];for(e=e+"",a=a+"";(c=HT.exec(e))&&(o=aT.exec(a));)(l=o.index)>i&&(l=a.slice(i,l),h[u]?h[u]+=l:h[++u]=l),(c=c[0])===(o=o[0])?h[u]?h[u]+=o:h[++u]=o:(h[++u]=null,f.push({i:u,x:Ua(c,o)})),i=aT.lastIndex;return i<a.length&&(l=a.slice(i),h[u]?h[u]+=l:h[++u]=l),h.length<2?f[0]?bY(f[0].x):wY(a):(a=f.length,function(p){for(var g=0,m;g<a;++g)h[(m=f[g]).i]=m.x(p);return h.join("")})}function y2(e,a){var i=typeof a,c;return a==null||i==="boolean"?fH(a):(i==="number"?Ua:i==="string"?(c=qo(a))?(a=c,FI):BB:a instanceof qo?FI:a instanceof Date?MY:gY(a)?mY:Array.isArray(a)?vY:typeof a.valueOf!="function"&&typeof a.toString!="function"||isNaN(a)?xY:Ua)(e,a)}var pO=180/Math.PI,jT={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function RB(e,a,i,c,o,l){var u,h,f;return(u=Math.sqrt(e*e+a*a))&&(e/=u,a/=u),(f=e*i+a*c)&&(i-=e*f,c-=a*f),(h=Math.sqrt(i*i+c*c))&&(i/=h,c/=h,f/=h),e*c<a*i&&(e=-e,a=-a,f=-f,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(a,e)*pO,skewX:Math.atan(f)*pO,scaleX:u,scaleY:h}}var Ld;function LY(e){const a=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return a.isIdentity?jT:RB(a.a,a.b,a.c,a.d,a.e,a.f)}function SY(e){return e==null||(Ld||(Ld=document.createElementNS("http://www.w3.org/2000/svg","g")),Ld.setAttribute("transform",e),!(e=Ld.transform.baseVal.consolidate()))?jT:(e=e.matrix,RB(e.a,e.b,e.c,e.d,e.e,e.f))}function UB(e,a,i,c){function o(p){return p.length?p.pop()+" ":""}function l(p,g,m,v,M,b){if(p!==m||g!==v){var w=M.push("translate(",null,a,null,i);b.push({i:w-4,x:Ua(p,m)},{i:w-2,x:Ua(g,v)})}else(m||v)&&M.push("translate("+m+a+v+i)}function u(p,g,m,v){p!==g?(p-g>180?g+=360:g-p>180&&(p+=360),v.push({i:m.push(o(m)+"rotate(",null,c)-2,x:Ua(p,g)})):g&&m.push(o(m)+"rotate("+g+c)}function h(p,g,m,v){p!==g?v.push({i:m.push(o(m)+"skewX(",null,c)-2,x:Ua(p,g)}):g&&m.push(o(m)+"skewX("+g+c)}function f(p,g,m,v,M,b){if(p!==m||g!==v){var w=M.push(o(M)+"scale(",null,",",null,")");b.push({i:w-4,x:Ua(p,m)},{i:w-2,x:Ua(g,v)})}else(m!==1||v!==1)&&M.push(o(M)+"scale("+m+","+v+")")}return function(p,g){var m=[],v=[];return p=e(p),g=e(g),l(p.translateX,p.translateY,g.translateX,g.translateY,m,v),u(p.rotate,g.rotate,m,v),h(p.skewX,g.skewX,m,v),f(p.scaleX,p.scaleY,g.scaleX,g.scaleY,m,v),p=g=null,function(M){for(var b=-1,w=v.length,L;++b<w;)m[(L=v[b]).i]=L.x(M);return m.join("")}}}var CY=UB(LY,"px, ","px)","deg)"),AY=UB(SY,", ",")",")"),IY=1e-12;function kO(e){return((e=Math.exp(e))+1/e)/2}function zY(e){return((e=Math.exp(e))-1/e)/2}function qY(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ed=(function e(a,i,c){function o(l,u){var h=l[0],f=l[1],p=l[2],g=u[0],m=u[1],v=u[2],M=g-h,b=m-f,w=M*M+b*b,L,S;if(w<IY)S=Math.log(v/p)/a,L=function(E){return[h+E*M,f+E*b,p*Math.exp(a*E*S)]};else{var q=Math.sqrt(w),C=(v*v-p*p+c*w)/(2*p*i*q),z=(v*v-p*p-c*w)/(2*v*i*q),H=Math.log(Math.sqrt(C*C+1)-C),N=Math.log(Math.sqrt(z*z+1)-z);S=(N-H)/a,L=function(E){var R=E*S,O=kO(H),ae=p/(i*q)*(O*qY(a*R+H)-zY(H));return[h+ae*M,f+ae*b,p*O/kO(a*R+H)]}}return L.duration=S*1e3*a/Math.SQRT2,L}return o.rho=function(l){var u=Math.max(.001,+l),h=u*u,f=h*h;return e(u,h,f)},o})(Math.SQRT2,2,4);var $l=0,s2=0,n2=0,PB=1e3,ZI,d2,GI=0,_o=0,dz=0,C2=typeof performance=="object"&&performance.now?performance:Date,FB=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function pH(){return _o||(FB(_Y),_o=C2.now()+dz)}function _Y(){_o=0}function $I(){this._call=this._time=this._next=null}$I.prototype=ZB.prototype={constructor:$I,restart:function(e,a,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?pH():+i)+(a==null?0:+a),!this._next&&d2!==this&&(d2?d2._next=this:ZI=this,d2=this),this._call=e,this._time=i,ET()},stop:function(){this._call&&(this._call=null,this._time=1/0,ET())}};function ZB(e,a,i){var c=new $I;return c.restart(e,a,i),c}function TY(){pH(),++$l;for(var e=ZI,a;e;)(a=_o-e._time)>=0&&e._call.call(void 0,a),e=e._next;--$l}function mO(){_o=(GI=C2.now())+dz,$l=s2=0;try{TY()}finally{$l=0,jY(),_o=0}}function HY(){var e=C2.now(),a=e-GI;a>PB&&(dz-=a,GI=e)}function jY(){for(var e,a=ZI,i,c=1/0;a;)a._call?(c>a._time&&(c=a._time),e=a,a=a._next):(i=a._next,a._next=null,a=e?e._next=i:ZI=i);d2=e,ET(c)}function ET(e){if(!$l){s2&&(s2=clearTimeout(s2));var a=e-_o;a>24?(e<1/0&&(s2=setTimeout(mO,e-C2.now()-dz)),n2&&(n2=clearInterval(n2))):(n2||(GI=C2.now(),n2=setInterval(HY,PB)),$l=1,FB(mO))}}function gO(e,a,i){var c=new $I;return a=a==null?0:+a,c.restart(o=>{c.stop(),e(o+a)},a,i),c}var EY=lz("start","end","cancel","interrupt"),NY=[],GB=0,vO=1,NT=2,Nd=3,MO=4,DT=5,Dd=6;function uz(e,a,i,c,o,l){var u=e.__transition;if(!u)e.__transition={};else if(i in u)return;DY(e,i,{name:a,index:c,group:o,on:EY,tween:NY,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:GB})}function kH(e,a){var i=Ha(e,a);if(i.state>GB)throw new Error("too late; already scheduled");return i}function Ka(e,a){var i=Ha(e,a);if(i.state>Nd)throw new Error("too late; already running");return i}function Ha(e,a){var i=e.__transition;if(!i||!(i=i[a]))throw new Error("transition not found");return i}function DY(e,a,i){var c=e.__transition,o;c[a]=i,i.timer=ZB(l,0,i.time);function l(p){i.state=vO,i.timer.restart(u,i.delay,i.time),i.delay<=p&&u(p-i.delay)}function u(p){var g,m,v,M;if(i.state!==vO)return f();for(g in c)if(M=c[g],M.name===i.name){if(M.state===Nd)return gO(u);M.state===MO?(M.state=Dd,M.timer.stop(),M.on.call("interrupt",e,e.__data__,M.index,M.group),delete c[g]):+g<a&&(M.state=Dd,M.timer.stop(),M.on.call("cancel",e,e.__data__,M.index,M.group),delete c[g])}if(gO(function(){i.state===Nd&&(i.state=MO,i.timer.restart(h,i.delay,i.time),h(p))}),i.state=NT,i.on.call("start",e,e.__data__,i.index,i.group),i.state===NT){for(i.state=Nd,o=new Array(v=i.tween.length),g=0,m=-1;g<v;++g)(M=i.tween[g].value.call(e,e.__data__,i.index,i.group))&&(o[++m]=M);o.length=m+1}}function h(p){for(var g=p<i.duration?i.ease.call(null,p/i.duration):(i.timer.restart(f),i.state=DT,1),m=-1,v=o.length;++m<v;)o[m].call(e,g);i.state===DT&&(i.on.call("end",e,e.__data__,i.index,i.group),f())}function f(){i.state=Dd,i.timer.stop(),delete c[a];for(var p in c)return;delete e.__transition}}function Od(e,a){var i=e.__transition,c,o,l=!0,u;if(i){a=a==null?null:a+"";for(u in i){if((c=i[u]).name!==a){l=!1;continue}o=c.state>NT&&c.state<DT,c.state=Dd,c.timer.stop(),c.on.call(o?"interrupt":"cancel",e,e.__data__,c.index,c.group),delete i[u]}l&&delete e.__transition}}function OY(e){return this.each(function(){Od(this,e)})}function VY(e,a){var i,c;return function(){var o=Ka(this,e),l=o.tween;if(l!==i){c=i=l;for(var u=0,h=c.length;u<h;++u)if(c[u].name===a){c=c.slice(),c.splice(u,1);break}}o.tween=c}}function BY(e,a,i){var c,o;if(typeof i!="function")throw new Error;return function(){var l=Ka(this,e),u=l.tween;if(u!==c){o=(c=u).slice();for(var h={name:a,value:i},f=0,p=o.length;f<p;++f)if(o[f].name===a){o[f]=h;break}f===p&&o.push(h)}l.tween=o}}function RY(e,a){var i=this._id;if(e+="",arguments.length<2){for(var c=Ha(this.node(),i).tween,o=0,l=c.length,u;o<l;++o)if((u=c[o]).name===e)return u.value;return null}return this.each((a==null?VY:BY)(i,e,a))}function mH(e,a,i){var c=e._id;return e.each(function(){var o=Ka(this,c);(o.value||(o.value={}))[a]=i.apply(this,arguments)}),function(o){return Ha(o,c).value[a]}}function $B(e,a){var i;return(typeof a=="number"?Ua:a instanceof qo?FI:(i=qo(a))?(a=i,FI):BB)(e,a)}function UY(e){return function(){this.removeAttribute(e)}}function PY(e){return function(){this.removeAttributeNS(e.space,e.local)}}function FY(e,a,i){var c,o=i+"",l;return function(){var u=this.getAttribute(e);return u===o?null:u===c?l:l=a(c=u,i)}}function ZY(e,a,i){var c,o=i+"",l;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===c?l:l=a(c=u,i)}}function GY(e,a,i){var c,o,l;return function(){var u,h=i(this),f;return h==null?void this.removeAttribute(e):(u=this.getAttribute(e),f=h+"",u===f?null:u===c&&f===o?l:(o=f,l=a(c=u,h)))}}function $Y(e,a,i){var c,o,l;return function(){var u,h=i(this),f;return h==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),f=h+"",u===f?null:u===c&&f===o?l:(o=f,l=a(c=u,h)))}}function XY(e,a){var i=sz(e),c=i==="transform"?AY:$B;return this.attrTween(e,typeof a=="function"?(i.local?$Y:GY)(i,c,mH(this,"attr."+e,a)):a==null?(i.local?PY:UY)(i):(i.local?ZY:FY)(i,c,a))}function YY(e,a){return function(i){this.setAttribute(e,a.call(this,i))}}function KY(e,a){return function(i){this.setAttributeNS(e.space,e.local,a.call(this,i))}}function QY(e,a){var i,c;function o(){var l=a.apply(this,arguments);return l!==c&&(i=(c=l)&&KY(e,l)),i}return o._value=a,o}function WY(e,a){var i,c;function o(){var l=a.apply(this,arguments);return l!==c&&(i=(c=l)&&YY(e,l)),i}return o._value=a,o}function JY(e,a){var i="attr."+e;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(a==null)return this.tween(i,null);if(typeof a!="function")throw new Error;var c=sz(e);return this.tween(i,(c.local?QY:WY)(c,a))}function eK(e,a){return function(){kH(this,e).delay=+a.apply(this,arguments)}}function tK(e,a){return a=+a,function(){kH(this,e).delay=a}}function aK(e){var a=this._id;return arguments.length?this.each((typeof e=="function"?eK:tK)(a,e)):Ha(this.node(),a).delay}function nK(e,a){return function(){Ka(this,e).duration=+a.apply(this,arguments)}}function iK(e,a){return a=+a,function(){Ka(this,e).duration=a}}function cK(e){var a=this._id;return arguments.length?this.each((typeof e=="function"?nK:iK)(a,e)):Ha(this.node(),a).duration}function rK(e,a){if(typeof a!="function")throw new Error;return function(){Ka(this,e).ease=a}}function oK(e){var a=this._id;return arguments.length?this.each(rK(a,e)):Ha(this.node(),a).ease}function lK(e,a){return function(){var i=a.apply(this,arguments);if(typeof i!="function")throw new Error;Ka(this,e).ease=i}}function sK(e){if(typeof e!="function")throw new Error;return this.each(lK(this._id,e))}function dK(e){typeof e!="function"&&(e=LB(e));for(var a=this._groups,i=a.length,c=new Array(i),o=0;o<i;++o)for(var l=a[o],u=l.length,h=c[o]=[],f,p=0;p<u;++p)(f=l[p])&&e.call(f,f.__data__,p,l)&&h.push(f);return new qn(c,this._parents,this._name,this._id)}function uK(e){if(e._id!==this._id)throw new Error;for(var a=this._groups,i=e._groups,c=a.length,o=i.length,l=Math.min(c,o),u=new Array(c),h=0;h<l;++h)for(var f=a[h],p=i[h],g=f.length,m=u[h]=new Array(g),v,M=0;M<g;++M)(v=f[M]||p[M])&&(m[M]=v);for(;h<c;++h)u[h]=a[h];return new qn(u,this._parents,this._name,this._id)}function hK(e){return(e+"").trim().split(/^|\s+/).every(function(a){var i=a.indexOf(".");return i>=0&&(a=a.slice(0,i)),!a||a==="start"})}function yK(e,a,i){var c,o,l=hK(a)?kH:Ka;return function(){var u=l(this,e),h=u.on;h!==c&&(o=(c=h).copy()).on(a,i),u.on=o}}function fK(e,a){var i=this._id;return arguments.length<2?Ha(this.node(),i).on.on(e):this.each(yK(i,e,a))}function pK(e){return function(){var a=this.parentNode;for(var i in this.__transition)if(+i!==e)return;a&&a.removeChild(this)}}function kK(){return this.on("end.remove",pK(this._id))}function mK(e){var a=this._name,i=this._id;typeof e!="function"&&(e=uH(e));for(var c=this._groups,o=c.length,l=new Array(o),u=0;u<o;++u)for(var h=c[u],f=h.length,p=l[u]=new Array(f),g,m,v=0;v<f;++v)(g=h[v])&&(m=e.call(g,g.__data__,v,h))&&("__data__"in g&&(m.__data__=g.__data__),p[v]=m,uz(p[v],a,i,v,p,Ha(g,i)));return new qn(l,this._parents,a,i)}function gK(e){var a=this._name,i=this._id;typeof e!="function"&&(e=bB(e));for(var c=this._groups,o=c.length,l=[],u=[],h=0;h<o;++h)for(var f=c[h],p=f.length,g,m=0;m<p;++m)if(g=f[m]){for(var v=e.call(g,g.__data__,m,f),M,b=Ha(g,i),w=0,L=v.length;w<L;++w)(M=v[w])&&uz(M,a,i,w,v,b);l.push(v),u.push(g)}return new qn(l,u,a,i)}var vK=B2.prototype.constructor;function MK(){return new vK(this._groups,this._parents)}function xK(e,a){var i,c,o;return function(){var l=Gl(this,e),u=(this.style.removeProperty(e),Gl(this,e));return l===u?null:l===i&&u===c?o:o=a(i=l,c=u)}}function XB(e){return function(){this.style.removeProperty(e)}}function wK(e,a,i){var c,o=i+"",l;return function(){var u=Gl(this,e);return u===o?null:u===c?l:l=a(c=u,i)}}function bK(e,a,i){var c,o,l;return function(){var u=Gl(this,e),h=i(this),f=h+"";return h==null&&(f=h=(this.style.removeProperty(e),Gl(this,e))),u===f?null:u===c&&f===o?l:(o=f,l=a(c=u,h))}}function LK(e,a){var i,c,o,l="style."+a,u="end."+l,h;return function(){var f=Ka(this,e),p=f.on,g=f.value[l]==null?h||(h=XB(a)):void 0;(p!==i||o!==g)&&(c=(i=p).copy()).on(u,o=g),f.on=c}}function SK(e,a,i){var c=(e+="")=="transform"?CY:$B;return a==null?this.styleTween(e,xK(e,c)).on("end.style."+e,XB(e)):typeof a=="function"?this.styleTween(e,bK(e,c,mH(this,"style."+e,a))).each(LK(this._id,e)):this.styleTween(e,wK(e,c,a),i).on("end.style."+e,null)}function CK(e,a,i){return function(c){this.style.setProperty(e,a.call(this,c),i)}}function AK(e,a,i){var c,o;function l(){var u=a.apply(this,arguments);return u!==o&&(c=(o=u)&&CK(e,u,i)),c}return l._value=a,l}function IK(e,a,i){var c="style."+(e+="");if(arguments.length<2)return(c=this.tween(c))&&c._value;if(a==null)return this.tween(c,null);if(typeof a!="function")throw new Error;return this.tween(c,AK(e,a,i??""))}function zK(e){return function(){this.textContent=e}}function qK(e){return function(){var a=e(this);this.textContent=a??""}}function _K(e){return this.tween("text",typeof e=="function"?qK(mH(this,"text",e)):zK(e==null?"":e+""))}function TK(e){return function(a){this.textContent=e.call(this,a)}}function HK(e){var a,i;function c(){var o=e.apply(this,arguments);return o!==i&&(a=(i=o)&&TK(o)),a}return c._value=e,c}function jK(e){var a="text";if(arguments.length<1)return(a=this.tween(a))&&a._value;if(e==null)return this.tween(a,null);if(typeof e!="function")throw new Error;return this.tween(a,HK(e))}function EK(){for(var e=this._name,a=this._id,i=YB(),c=this._groups,o=c.length,l=0;l<o;++l)for(var u=c[l],h=u.length,f,p=0;p<h;++p)if(f=u[p]){var g=Ha(f,a);uz(f,e,i,p,u,{time:g.time+g.delay+g.duration,delay:0,duration:g.duration,ease:g.ease})}return new qn(c,this._parents,e,i)}function NK(){var e,a,i=this,c=i._id,o=i.size();return new Promise(function(l,u){var h={value:u},f={value:function(){--o===0&&l()}};i.each(function(){var p=Ka(this,c),g=p.on;g!==e&&(a=(e=g).copy(),a._.cancel.push(h),a._.interrupt.push(h),a._.end.push(f)),p.on=a}),o===0&&l()})}var DK=0;function qn(e,a,i,c){this._groups=e,this._parents=a,this._name=i,this._id=c}function YB(){return++DK}var wn=B2.prototype;qn.prototype={constructor:qn,select:mK,selectAll:gK,selectChild:wn.selectChild,selectChildren:wn.selectChildren,filter:dK,merge:uK,selection:MK,transition:EK,call:wn.call,nodes:wn.nodes,node:wn.node,size:wn.size,empty:wn.empty,each:wn.each,on:fK,attr:XY,attrTween:JY,style:SK,styleTween:IK,text:_K,textTween:jK,remove:kK,tween:RY,delay:aK,duration:cK,ease:oK,easeVarying:sK,end:NK,[Symbol.iterator]:wn[Symbol.iterator]};function OK(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var VK={time:null,delay:0,duration:250,ease:OK};function BK(e,a){for(var i;!(i=e.__transition)||!(i=i[a]);)if(!(e=e.parentNode))throw new Error(`transition ${a} not found`);return i}function RK(e){var a,i;e instanceof qn?(a=e._id,e=e._name):(a=YB(),(i=VK).time=pH(),e=e==null?null:e+"");for(var c=this._groups,o=c.length,l=0;l<o;++l)for(var u=c[l],h=u.length,f,p=0;p<h;++p)(f=u[p])&&uz(f,e,a,p,u,i||BK(f,a));return new qn(c,this._parents,e,a)}B2.prototype.interrupt=OY;B2.prototype.transition=RK;const Sd=e=>()=>e;function UK(e,{sourceEvent:a,target:i,transform:c,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:a,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:c,enumerable:!0,configurable:!0},_:{value:o}})}function Cn(e,a,i){this.k=e,this.x=a,this.y=i}Cn.prototype={constructor:Cn,scale:function(e){return e===1?this:new Cn(this.k*e,this.x,this.y)},translate:function(e,a){return e===0&a===0?this:new Cn(this.k,this.x+this.k*e,this.y+this.k*a)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var hz=new Cn(1,0,0);KB.prototype=Cn.prototype;function KB(e){for(;!e.__zoom;)if(!(e=e.parentNode))return hz;return e.__zoom}function nT(e){e.stopImmediatePropagation()}function i2(e){e.preventDefault(),e.stopImmediatePropagation()}function PK(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function FK(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function xO(){return this.__zoom||hz}function ZK(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function GK(){return navigator.maxTouchPoints||"ontouchstart"in this}function $K(e,a,i){var c=e.invertX(a[0][0])-i[0][0],o=e.invertX(a[1][0])-i[1][0],l=e.invertY(a[0][1])-i[0][1],u=e.invertY(a[1][1])-i[1][1];return e.translate(o>c?(c+o)/2:Math.min(0,c)||Math.max(0,o),u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u))}function QB(){var e=PK,a=FK,i=$K,c=ZK,o=GK,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],h=250,f=Ed,p=lz("start","zoom","end"),g,m,v,M=500,b=150,w=0,L=10;function S(j){j.property("__zoom",xO).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",ae).filter(o).on("touchstart.zoom",G).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",ne).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(j,X,T,V){var U=j.selection?j.selection():j;U.property("__zoom",xO),j!==U?H(j,X,T,V):U.interrupt().each(function(){N(this,arguments).event(V).start().zoom(null,typeof X=="function"?X.apply(this,arguments):X).end()})},S.scaleBy=function(j,X,T,V){S.scaleTo(j,function(){var U=this.__zoom.k,F=typeof X=="function"?X.apply(this,arguments):X;return U*F},T,V)},S.scaleTo=function(j,X,T,V){S.transform(j,function(){var U=a.apply(this,arguments),F=this.__zoom,J=T==null?z(U):typeof T=="function"?T.apply(this,arguments):T,_=F.invert(J),B=typeof X=="function"?X.apply(this,arguments):X;return i(C(q(F,B),J,_),U,u)},T,V)},S.translateBy=function(j,X,T,V){S.transform(j,function(){return i(this.__zoom.translate(typeof X=="function"?X.apply(this,arguments):X,typeof T=="function"?T.apply(this,arguments):T),a.apply(this,arguments),u)},null,V)},S.translateTo=function(j,X,T,V,U){S.transform(j,function(){var F=a.apply(this,arguments),J=this.__zoom,_=V==null?z(F):typeof V=="function"?V.apply(this,arguments):V;return i(hz.translate(_[0],_[1]).scale(J.k).translate(typeof X=="function"?-X.apply(this,arguments):-X,typeof T=="function"?-T.apply(this,arguments):-T),F,u)},V,U)};function q(j,X){return X=Math.max(l[0],Math.min(l[1],X)),X===j.k?j:new Cn(X,j.x,j.y)}function C(j,X,T){var V=X[0]-T[0]*j.k,U=X[1]-T[1]*j.k;return V===j.x&&U===j.y?j:new Cn(j.k,V,U)}function z(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function H(j,X,T,V){j.on("start.zoom",function(){N(this,arguments).event(V).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(V).end()}).tween("zoom",function(){var U=this,F=arguments,J=N(U,F).event(V),_=a.apply(U,F),B=T==null?z(_):typeof T=="function"?T.apply(U,F):T,te=Math.max(_[1][0]-_[0][0],_[1][1]-_[0][1]),ie=U.__zoom,le=typeof X=="function"?X.apply(U,F):X,ue=f(ie.invert(B).concat(te/ie.k),le.invert(B).concat(te/le.k));return function(he){if(he===1)he=le;else{var se=ue(he),ye=te/se[2];he=new Cn(ye,B[0]-se[0]*ye,B[1]-se[1]*ye)}J.zoom(null,he)}})}function N(j,X,T){return!T&&j.__zooming||new E(j,X)}function E(j,X){this.that=j,this.args=X,this.active=0,this.sourceEvent=null,this.extent=a.apply(j,X),this.taps=0}E.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,X){return this.mouse&&j!=="mouse"&&(this.mouse[1]=X.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=X.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=X.invert(this.touch1[0])),this.that.__zoom=X,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var X=ra(this.that).datum();p.call(j,this.that,new UK(j,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:p}),X)}};function R(j,...X){if(!e.apply(this,arguments))return;var T=N(this,X).event(j),V=this.__zoom,U=Math.max(l[0],Math.min(l[1],V.k*Math.pow(2,c.apply(this,arguments)))),F=Ia(j);if(T.wheel)(T.mouse[0][0]!==F[0]||T.mouse[0][1]!==F[1])&&(T.mouse[1]=V.invert(T.mouse[0]=F)),clearTimeout(T.wheel);else{if(V.k===U)return;T.mouse=[F,V.invert(F)],Od(this),T.start()}i2(j),T.wheel=setTimeout(J,b),T.zoom("mouse",i(C(q(V,U),T.mouse[0],T.mouse[1]),T.extent,u));function J(){T.wheel=null,T.end()}}function O(j,...X){if(v||!e.apply(this,arguments))return;var T=j.currentTarget,V=N(this,X,!0).event(j),U=ra(j.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",te,!0),F=Ia(j,T),J=j.clientX,_=j.clientY;jB(j.view),nT(j),V.mouse=[F,this.__zoom.invert(F)],Od(this),V.start();function B(ie){if(i2(ie),!V.moved){var le=ie.clientX-J,ue=ie.clientY-_;V.moved=le*le+ue*ue>w}V.event(ie).zoom("mouse",i(C(V.that.__zoom,V.mouse[0]=Ia(ie,T),V.mouse[1]),V.extent,u))}function te(ie){U.on("mousemove.zoom mouseup.zoom",null),EB(ie.view,V.moved),i2(ie),V.event(ie).end()}}function ae(j,...X){if(e.apply(this,arguments)){var T=this.__zoom,V=Ia(j.changedTouches?j.changedTouches[0]:j,this),U=T.invert(V),F=T.k*(j.shiftKey?.5:2),J=i(C(q(T,F),V,U),a.apply(this,X),u);i2(j),h>0?ra(this).transition().duration(h).call(H,J,V,j):ra(this).call(S.transform,J,V,j)}}function G(j,...X){if(e.apply(this,arguments)){var T=j.touches,V=T.length,U=N(this,X,j.changedTouches.length===V).event(j),F,J,_,B;for(nT(j),J=0;J<V;++J)_=T[J],B=Ia(_,this),B=[B,this.__zoom.invert(B),_.identifier],U.touch0?!U.touch1&&U.touch0[2]!==B[2]&&(U.touch1=B,U.taps=0):(U.touch0=B,F=!0,U.taps=1+!!g);g&&(g=clearTimeout(g)),F&&(U.taps<2&&(m=B[0],g=setTimeout(function(){g=null},M)),Od(this),U.start())}}function Z(j,...X){if(this.__zooming){var T=N(this,X).event(j),V=j.changedTouches,U=V.length,F,J,_,B;for(i2(j),F=0;F<U;++F)J=V[F],_=Ia(J,this),T.touch0&&T.touch0[2]===J.identifier?T.touch0[0]=_:T.touch1&&T.touch1[2]===J.identifier&&(T.touch1[0]=_);if(J=T.that.__zoom,T.touch1){var te=T.touch0[0],ie=T.touch0[1],le=T.touch1[0],ue=T.touch1[1],he=(he=le[0]-te[0])*he+(he=le[1]-te[1])*he,se=(se=ue[0]-ie[0])*se+(se=ue[1]-ie[1])*se;J=q(J,Math.sqrt(he/se)),_=[(te[0]+le[0])/2,(te[1]+le[1])/2],B=[(ie[0]+ue[0])/2,(ie[1]+ue[1])/2]}else if(T.touch0)_=T.touch0[0],B=T.touch0[1];else return;T.zoom("touch",i(C(J,_,B),T.extent,u))}}function ne(j,...X){if(this.__zooming){var T=N(this,X).event(j),V=j.changedTouches,U=V.length,F,J;for(nT(j),v&&clearTimeout(v),v=setTimeout(function(){v=null},M),F=0;F<U;++F)J=V[F],T.touch0&&T.touch0[2]===J.identifier?delete T.touch0:T.touch1&&T.touch1[2]===J.identifier&&delete T.touch1;if(T.touch1&&!T.touch0&&(T.touch0=T.touch1,delete T.touch1),T.touch0)T.touch0[1]=this.__zoom.invert(T.touch0[0]);else if(T.end(),T.taps===2&&(J=Ia(J,this),Math.hypot(m[0]-J[0],m[1]-J[1])<L)){var _=ra(this).on("dblclick.zoom");_&&_.apply(this,arguments)}}}return S.wheelDelta=function(j){return arguments.length?(c=typeof j=="function"?j:Sd(+j),S):c},S.filter=function(j){return arguments.length?(e=typeof j=="function"?j:Sd(!!j),S):e},S.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:Sd(!!j),S):o},S.extent=function(j){return arguments.length?(a=typeof j=="function"?j:Sd([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),S):a},S.scaleExtent=function(j){return arguments.length?(l[0]=+j[0],l[1]=+j[1],S):[l[0],l[1]]},S.translateExtent=function(j){return arguments.length?(u[0][0]=+j[0][0],u[1][0]=+j[1][0],u[0][1]=+j[0][1],u[1][1]=+j[1][1],S):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},S.constrain=function(j){return arguments.length?(i=j,S):i},S.duration=function(j){return arguments.length?(h=+j,S):h},S.interpolate=function(j){return arguments.length?(f=j,S):f},S.on=function(){var j=p.on.apply(p,arguments);return j===p?S:j},S.clickDistance=function(j){return arguments.length?(w=(j=+j)*j,S):Math.sqrt(w)},S.tapDistance=function(j){return arguments.length?(L=+j,S):L},S}const Ya={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:a,sourceHandle:i,targetHandle:c})=>`Couldn't create edge for ${e} handle id: "${e==="source"?i:c}", edge id: ${a}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},A2=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],WB=["Enter"," ","Escape"],JB={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:a,y:i})=>`Moved selected node ${e}. New position, x: ${a}, y: ${i}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Xl;(function(e){e.Strict="strict",e.Loose="loose"})(Xl||(Xl={}));var So;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(So||(So={}));var I2;(function(e){e.Partial="partial",e.Full="full"})(I2||(I2={}));const eR={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var k1;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(k1||(k1={}));var z2;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(z2||(z2={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const wO={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function tR(e){return e===null?null:e?"valid":"invalid"}const aR=e=>"id"in e&&"source"in e&&"target"in e,XK=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),gH=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),U2=(e,a=[0,0])=>{const{width:i,height:c}=_n(e),o=e.origin??a,l=i*o[0],u=c*o[1];return{x:e.position.x-l,y:e.position.y-u}},YK=(e,a={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const i=e.reduce((c,o)=>{const l=typeof o=="string";let u=!a.nodeLookup&&!l?o:void 0;a.nodeLookup&&(u=l?a.nodeLookup.get(o):gH(o)?o:a.nodeLookup.get(o.id));const h=u?XI(u,a.nodeOrigin):{x:0,y:0,x2:0,y2:0};return yz(c,h)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fz(i)},P2=(e,a={})=>{let i={x:1/0,y:1/0,x2:-1/0,y2:-1/0},c=!1;return e.forEach(o=>{(a.filter===void 0||a.filter(o))&&(i=yz(i,XI(o)),c=!0)}),c?fz(i):{x:0,y:0,width:0,height:0}},vH=(e,a,[i,c,o]=[0,0,1],l=!1,u=!1)=>{const h={...Z2(a,[i,c,o]),width:a.width/o,height:a.height/o},f=[];for(const p of e.values()){const{measured:g,selectable:m=!0,hidden:v=!1}=p;if(u&&!m||v)continue;const M=g.width??p.width??p.initialWidth??null,b=g.height??p.height??p.initialHeight??null,w=q2(h,Kl(p)),L=(M??0)*(b??0),S=l&&w>0;(!p.internals.handleBounds||S||w>=L||p.dragging)&&f.push(p)}return f},KK=(e,a)=>{const i=new Set;return e.forEach(c=>{i.add(c.id)}),a.filter(c=>i.has(c.source)||i.has(c.target))};function QK(e,a){const i=new Map,c=a!=null&&a.nodes?new Set(a.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((a==null?void 0:a.includeHiddenNodes)||!o.hidden)&&(!c||c.has(o.id))&&i.set(o.id,o)}),i}async function WK({nodes:e,width:a,height:i,panZoom:c,minZoom:o,maxZoom:l},u){if(e.size===0)return Promise.resolve(!0);const h=QK(e,u),f=P2(h),p=MH(f,a,i,(u==null?void 0:u.minZoom)??o,(u==null?void 0:u.maxZoom)??l,(u==null?void 0:u.padding)??.1);return await c.setViewport(p,{duration:u==null?void 0:u.duration,ease:u==null?void 0:u.ease,interpolate:u==null?void 0:u.interpolate}),Promise.resolve(!0)}function nR({nodeId:e,nextPosition:a,nodeLookup:i,nodeOrigin:c=[0,0],nodeExtent:o,onError:l}){const u=i.get(e),h=u.parentId?i.get(u.parentId):void 0,{x:f,y:p}=h?h.internals.positionAbsolute:{x:0,y:0},g=u.origin??c;let m=u.extent||o;if(u.extent==="parent"&&!u.expandParent)if(!h)l==null||l("005",Ya.error005());else{const M=h.measured.width,b=h.measured.height;M&&b&&(m=[[f,p],[f+M,p+b]])}else h&&Ql(u.extent)&&(m=[[u.extent[0][0]+f,u.extent[0][1]+p],[u.extent[1][0]+f,u.extent[1][1]+p]]);const v=Ql(m)?To(a,m,u.measured):a;return(u.measured.width===void 0||u.measured.height===void 0)&&(l==null||l("015",Ya.error015())),{position:{x:v.x-f+(u.measured.width??0)*g[0],y:v.y-p+(u.measured.height??0)*g[1]},positionAbsolute:v}}async function JK({nodesToRemove:e=[],edgesToRemove:a=[],nodes:i,edges:c,onBeforeDelete:o}){const l=new Set(e.map(v=>v.id)),u=[];for(const v of i){if(v.deletable===!1)continue;const M=l.has(v.id),b=!M&&v.parentId&&u.find(w=>w.id===v.parentId);(M||b)&&u.push(v)}const h=new Set(a.map(v=>v.id)),f=c.filter(v=>v.deletable!==!1),g=KK(u,f);for(const v of f)h.has(v.id)&&!g.find(b=>b.id===v.id)&&g.push(v);if(!o)return{edges:g,nodes:u};const m=await o({nodes:u,edges:g});return typeof m=="boolean"?m?{edges:g,nodes:u}:{edges:[],nodes:[]}:m}const Yl=(e,a=0,i=1)=>Math.min(Math.max(e,a),i),To=(e={x:0,y:0},a,i)=>({x:Yl(e.x,a[0][0],a[1][0]-((i==null?void 0:i.width)??0)),y:Yl(e.y,a[0][1],a[1][1]-((i==null?void 0:i.height)??0))});function iR(e,a,i){const{width:c,height:o}=_n(i),{x:l,y:u}=i.internals.positionAbsolute;return To(e,[[l,u],[l+c,u+o]],a)}const bO=(e,a,i)=>e<a?Yl(Math.abs(e-a),1,a)/a:e>i?-Yl(Math.abs(e-i),1,a)/a:0,cR=(e,a,i=15,c=40)=>{const o=bO(e.x,c,a.width-c)*i,l=bO(e.y,c,a.height-c)*i;return[o,l]},yz=(e,a)=>({x:Math.min(e.x,a.x),y:Math.min(e.y,a.y),x2:Math.max(e.x2,a.x2),y2:Math.max(e.y2,a.y2)}),OT=({x:e,y:a,width:i,height:c})=>({x:e,y:a,x2:e+i,y2:a+c}),fz=({x:e,y:a,x2:i,y2:c})=>({x:e,y:a,width:i-e,height:c-a}),Kl=(e,a=[0,0])=>{var o,l;const{x:i,y:c}=gH(e)?e.internals.positionAbsolute:U2(e,a);return{x:i,y:c,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((l=e.measured)==null?void 0:l.height)??e.height??e.initialHeight??0}},XI=(e,a=[0,0])=>{var o,l;const{x:i,y:c}=gH(e)?e.internals.positionAbsolute:U2(e,a);return{x:i,y:c,x2:i+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:c+(((l=e.measured)==null?void 0:l.height)??e.height??e.initialHeight??0)}},rR=(e,a)=>fz(yz(OT(e),OT(a))),q2=(e,a)=>{const i=Math.max(0,Math.min(e.x+e.width,a.x+a.width)-Math.max(e.x,a.x)),c=Math.max(0,Math.min(e.y+e.height,a.y+a.height)-Math.max(e.y,a.y));return Math.ceil(i*c)},LO=e=>qa(e.width)&&qa(e.height)&&qa(e.x)&&qa(e.y),qa=e=>!isNaN(e)&&isFinite(e),eQ=(e,a)=>{},F2=(e,a=[1,1])=>({x:a[0]*Math.round(e.x/a[0]),y:a[1]*Math.round(e.y/a[1])}),Z2=({x:e,y:a},[i,c,o],l=!1,u=[1,1])=>{const h={x:(e-i)/o,y:(a-c)/o};return l?F2(h,u):h},YI=({x:e,y:a},[i,c,o])=>({x:e*o+i,y:a*o+c});function bl(e,a){if(typeof e=="number")return Math.floor((a-a/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const i=parseFloat(e);if(!Number.isNaN(i))return Math.floor(i)}if(typeof e=="string"&&e.endsWith("%")){const i=parseFloat(e);if(!Number.isNaN(i))return Math.floor(a*i*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function tQ(e,a,i){if(typeof e=="string"||typeof e=="number"){const c=bl(e,i),o=bl(e,a);return{top:c,right:o,bottom:c,left:o,x:o*2,y:c*2}}if(typeof e=="object"){const c=bl(e.top??e.y??0,i),o=bl(e.bottom??e.y??0,i),l=bl(e.left??e.x??0,a),u=bl(e.right??e.x??0,a);return{top:c,right:u,bottom:o,left:l,x:l+u,y:c+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function aQ(e,a,i,c,o,l){const{x:u,y:h}=YI(e,[a,i,c]),{x:f,y:p}=YI({x:e.x+e.width,y:e.y+e.height},[a,i,c]),g=o-f,m=l-p;return{left:Math.floor(u),top:Math.floor(h),right:Math.floor(g),bottom:Math.floor(m)}}const MH=(e,a,i,c,o,l)=>{const u=tQ(l,a,i),h=(a-u.x)/e.width,f=(i-u.y)/e.height,p=Math.min(h,f),g=Yl(p,c,o),m=e.x+e.width/2,v=e.y+e.height/2,M=a/2-m*g,b=i/2-v*g,w=aQ(e,M,b,g,a,i),L={left:Math.min(w.left-u.left,0),top:Math.min(w.top-u.top,0),right:Math.min(w.right-u.right,0),bottom:Math.min(w.bottom-u.bottom,0)};return{x:M-L.left+L.right,y:b-L.top+L.bottom,zoom:g}},_2=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ql(e){return e!=null&&e!=="parent"}function _n(e){var a,i;return{width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}}function oR(e){var a,i;return(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth)!==void 0&&(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight)!==void 0}function lR(e,a={width:0,height:0},i,c,o){const l={...e},u=c.get(i);if(u){const h=u.origin||o;l.x+=u.internals.positionAbsolute.x-(a.width??0)*h[0],l.y+=u.internals.positionAbsolute.y-(a.height??0)*h[1]}return l}function SO(e,a){if(e.size!==a.size)return!1;for(const i of e)if(!a.has(i))return!1;return!0}function nQ(){let e,a;return{promise:new Promise((c,o)=>{e=c,a=o}),resolve:e,reject:a}}function iQ(e){return{...JB,...e||{}}}function f2(e,{snapGrid:a=[0,0],snapToGrid:i=!1,transform:c,containerBounds:o}){const{x:l,y:u}=_a(e),h=Z2({x:l-((o==null?void 0:o.left)??0),y:u-((o==null?void 0:o.top)??0)},c),{x:f,y:p}=i?F2(h,a):h;return{xSnapped:f,ySnapped:p,...h}}const xH=e=>({width:e.offsetWidth,height:e.offsetHeight}),sR=e=>{var a;return((a=e==null?void 0:e.getRootNode)==null?void 0:a.call(e))||(window==null?void 0:window.document)},cQ=["INPUT","SELECT","TEXTAREA"];function dR(e){var c,o;const a=((o=(c=e.composedPath)==null?void 0:c.call(e))==null?void 0:o[0])||e.target;return(a==null?void 0:a.nodeType)!==1?!1:cQ.includes(a.nodeName)||a.hasAttribute("contenteditable")||!!a.closest(".nokey")}const uR=e=>"clientX"in e,_a=(e,a)=>{var l,u;const i=uR(e),c=i?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,o=i?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:c-((a==null?void 0:a.left)??0),y:o-((a==null?void 0:a.top)??0)}},CO=(e,a,i,c,o)=>{const l=a.querySelectorAll(`.${e}`);return!l||!l.length?null:Array.from(l).map(u=>{const h=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),type:e,nodeId:o,position:u.getAttribute("data-handlepos"),x:(h.left-i.left)/c,y:(h.top-i.top)/c,...xH(u)}})};function hR({sourceX:e,sourceY:a,targetX:i,targetY:c,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:h}){const f=e*.125+o*.375+u*.375+i*.125,p=a*.125+l*.375+h*.375+c*.125,g=Math.abs(f-e),m=Math.abs(p-a);return[f,p,g,m]}function Cd(e,a){return e>=0?.5*e:a*25*Math.sqrt(-e)}function AO({pos:e,x1:a,y1:i,x2:c,y2:o,c:l}){switch(e){case ve.Left:return[a-Cd(a-c,l),i];case ve.Right:return[a+Cd(c-a,l),i];case ve.Top:return[a,i-Cd(i-o,l)];case ve.Bottom:return[a,i+Cd(o-i,l)]}}function yR({sourceX:e,sourceY:a,sourcePosition:i=ve.Bottom,targetX:c,targetY:o,targetPosition:l=ve.Top,curvature:u=.25}){const[h,f]=AO({pos:i,x1:e,y1:a,x2:c,y2:o,c:u}),[p,g]=AO({pos:l,x1:c,y1:o,x2:e,y2:a,c:u}),[m,v,M,b]=hR({sourceX:e,sourceY:a,targetX:c,targetY:o,sourceControlX:h,sourceControlY:f,targetControlX:p,targetControlY:g});return[`M${e},${a} C${h},${f} ${p},${g} ${c},${o}`,m,v,M,b]}function fR({sourceX:e,sourceY:a,targetX:i,targetY:c}){const o=Math.abs(i-e)/2,l=i<e?i+o:i-o,u=Math.abs(c-a)/2,h=c<a?c+u:c-u;return[l,h,o,u]}function rQ({sourceNode:e,targetNode:a,selected:i=!1,zIndex:c=0,elevateOnSelect:o=!1,zIndexMode:l="basic"}){if(l==="manual")return c;const u=o&&i?c+1e3:c,h=Math.max(e.parentId||o&&e.selected?e.internals.z:0,a.parentId||o&&a.selected?a.internals.z:0);return u+h}function oQ({sourceNode:e,targetNode:a,width:i,height:c,transform:o}){const l=yz(XI(e),XI(a));l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u={x:-o[0]/o[2],y:-o[1]/o[2],width:i/o[2],height:c/o[2]};return q2(u,fz(l))>0}const lQ=({source:e,sourceHandle:a,target:i,targetHandle:c})=>`xy-edge__${e}${a||""}-${i}${c||""}`,sQ=(e,a)=>a.some(i=>i.source===e.source&&i.target===e.target&&(i.sourceHandle===e.sourceHandle||!i.sourceHandle&&!e.sourceHandle)&&(i.targetHandle===e.targetHandle||!i.targetHandle&&!e.targetHandle)),dQ=(e,a,i={})=>{if(!e.source||!e.target)return a;const c=i.getEdgeId||lQ;let o;return aR(e)?o={...e}:o={...e,id:c(e)},sQ(o,a)?a:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,a.concat(o))};function pR({sourceX:e,sourceY:a,targetX:i,targetY:c}){const[o,l,u,h]=fR({sourceX:e,sourceY:a,targetX:i,targetY:c});return[`M ${e},${a}L ${i},${c}`,o,l,u,h]}const IO={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},uQ=({source:e,sourcePosition:a=ve.Bottom,target:i})=>a===ve.Left||a===ve.Right?e.x<i.x?{x:1,y:0}:{x:-1,y:0}:e.y<i.y?{x:0,y:1}:{x:0,y:-1},zO=(e,a)=>Math.sqrt(Math.pow(a.x-e.x,2)+Math.pow(a.y-e.y,2));function hQ({source:e,sourcePosition:a=ve.Bottom,target:i,targetPosition:c=ve.Top,center:o,offset:l,stepPosition:u}){const h=IO[a],f=IO[c],p={x:e.x+h.x*l,y:e.y+h.y*l},g={x:i.x+f.x*l,y:i.y+f.y*l},m=uQ({source:p,sourcePosition:a,target:g}),v=m.x!==0?"x":"y",M=m[v];let b=[],w,L;const S={x:0,y:0},q={x:0,y:0},[,,C,z]=fR({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(h[v]*f[v]===-1){v==="x"?(w=o.x??p.x+(g.x-p.x)*u,L=o.y??(p.y+g.y)/2):(w=o.x??(p.x+g.x)/2,L=o.y??p.y+(g.y-p.y)*u);const R=[{x:w,y:p.y},{x:w,y:g.y}],O=[{x:p.x,y:L},{x:g.x,y:L}];h[v]===M?b=v==="x"?R:O:b=v==="x"?O:R}else{const R=[{x:p.x,y:g.y}],O=[{x:g.x,y:p.y}];if(v==="x"?b=h.x===M?O:R:b=h.y===M?R:O,a===c){const j=Math.abs(e[v]-i[v]);if(j<=l){const X=Math.min(l-1,l-j);h[v]===M?S[v]=(p[v]>e[v]?-1:1)*X:q[v]=(g[v]>i[v]?-1:1)*X}}if(a!==c){const j=v==="x"?"y":"x",X=h[v]===f[j],T=p[j]>g[j],V=p[j]<g[j];(h[v]===1&&(!X&&T||X&&V)||h[v]!==1&&(!X&&V||X&&T))&&(b=v==="x"?R:O)}const ae={x:p.x+S.x,y:p.y+S.y},G={x:g.x+q.x,y:g.y+q.y},Z=Math.max(Math.abs(ae.x-b[0].x),Math.abs(G.x-b[0].x)),ne=Math.max(Math.abs(ae.y-b[0].y),Math.abs(G.y-b[0].y));Z>=ne?(w=(ae.x+G.x)/2,L=b[0].y):(w=b[0].x,L=(ae.y+G.y)/2)}const H={x:p.x+S.x,y:p.y+S.y},N={x:g.x+q.x,y:g.y+q.y};return[[e,...H.x!==b[0].x||H.y!==b[0].y?[H]:[],...b,...N.x!==b[b.length-1].x||N.y!==b[b.length-1].y?[N]:[],i],w,L,C,z]}function yQ(e,a,i,c){const o=Math.min(zO(e,a)/2,zO(a,i)/2,c),{x:l,y:u}=a;if(e.x===l&&l===i.x||e.y===u&&u===i.y)return`L${l} ${u}`;if(e.y===u){const p=e.x<i.x?-1:1,g=e.y<i.y?1:-1;return`L ${l+o*p},${u}Q ${l},${u} ${l},${u+o*g}`}const h=e.x<i.x?1:-1,f=e.y<i.y?-1:1;return`L ${l},${u+o*f}Q ${l},${u} ${l+o*h},${u}`}function VT({sourceX:e,sourceY:a,sourcePosition:i=ve.Bottom,targetX:c,targetY:o,targetPosition:l=ve.Top,borderRadius:u=5,centerX:h,centerY:f,offset:p=20,stepPosition:g=.5}){const[m,v,M,b,w]=hQ({source:{x:e,y:a},sourcePosition:i,target:{x:c,y:o},targetPosition:l,center:{x:h,y:f},offset:p,stepPosition:g});let L=`M${m[0].x} ${m[0].y}`;for(let S=1;S<m.length-1;S++)L+=yQ(m[S-1],m[S],m[S+1],u);return L+=`L${m[m.length-1].x} ${m[m.length-1].y}`,[L,v,M,b,w]}function qO(e){var a;return e&&!!(e.internals.handleBounds||(a=e.handles)!=null&&a.length)&&!!(e.measured.width||e.width||e.initialWidth)}function fQ(e){var m;const{sourceNode:a,targetNode:i}=e;if(!qO(a)||!qO(i))return null;const c=a.internals.handleBounds||_O(a.handles),o=i.internals.handleBounds||_O(i.handles),l=TO((c==null?void 0:c.source)??[],e.sourceHandle),u=TO(e.connectionMode===Xl.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!l||!u)return(m=e.onError)==null||m.call(e,"008",Ya.error008(l?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const h=(l==null?void 0:l.position)||ve.Bottom,f=(u==null?void 0:u.position)||ve.Top,p=Ho(a,l,h),g=Ho(i,u,f);return{sourceX:p.x,sourceY:p.y,targetX:g.x,targetY:g.y,sourcePosition:h,targetPosition:f}}function _O(e){if(!e)return null;const a=[],i=[];for(const c of e)c.width=c.width??1,c.height=c.height??1,c.type==="source"?a.push(c):c.type==="target"&&i.push(c);return{source:a,target:i}}function Ho(e,a,i=ve.Left,c=!1){const o=((a==null?void 0:a.x)??0)+e.internals.positionAbsolute.x,l=((a==null?void 0:a.y)??0)+e.internals.positionAbsolute.y,{width:u,height:h}=a??_n(e);if(c)return{x:o+u/2,y:l+h/2};switch((a==null?void 0:a.position)??i){case ve.Top:return{x:o+u/2,y:l};case ve.Right:return{x:o+u,y:l+h/2};case ve.Bottom:return{x:o+u/2,y:l+h};case ve.Left:return{x:o,y:l+h/2}}}function TO(e,a){return e&&(a?e.find(i=>i.id===a):e[0])||null}function BT(e,a){return e?typeof e=="string"?e:`${a?`${a}__`:""}${Object.keys(e).sort().map(c=>`${c}=${e[c]}`).join("&")}`:""}function pQ(e,{id:a,defaultColor:i,defaultMarkerStart:c,defaultMarkerEnd:o}){const l=new Set;return e.reduce((u,h)=>([h.markerStart||c,h.markerEnd||o].forEach(f=>{if(f&&typeof f=="object"){const p=BT(f,a);l.has(p)||(u.push({id:p,color:f.color||i,...f}),l.add(p))}}),u),[]).sort((u,h)=>u.id.localeCompare(h.id))}const kR=1e3,kQ=10,wH={nodeOrigin:[0,0],nodeExtent:A2,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},mQ={...wH,checkEquality:!0};function bH(e,a){const i={...e};for(const c in a)a[c]!==void 0&&(i[c]=a[c]);return i}function gQ(e,a,i){const c=bH(wH,i);for(const o of e.values())if(o.parentId)SH(o,e,a,c);else{const l=U2(o,c.nodeOrigin),u=Ql(o.extent)?o.extent:c.nodeExtent,h=To(l,u,_n(o));o.internals.positionAbsolute=h}}function vQ(e,a){if(!e.handles)return e.measured?a==null?void 0:a.internals.handleBounds:void 0;const i=[],c=[];for(const o of e.handles){const l={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?i.push(l):o.type==="target"&&c.push(l)}return{source:i,target:c}}function LH(e){return e==="manual"}function RT(e,a,i,c={}){var g,m;const o=bH(mQ,c),l={i:0},u=new Map(a),h=o!=null&&o.elevateNodesOnSelect&&!LH(o.zIndexMode)?kR:0;let f=e.length>0,p=!1;a.clear(),i.clear();for(const v of e){let M=u.get(v.id);if(o.checkEquality&&v===(M==null?void 0:M.internals.userNode))a.set(v.id,M);else{const b=U2(v,o.nodeOrigin),w=Ql(v.extent)?v.extent:o.nodeExtent,L=To(b,w,_n(v));M={...o.defaults,...v,measured:{width:(g=v.measured)==null?void 0:g.width,height:(m=v.measured)==null?void 0:m.height},internals:{positionAbsolute:L,handleBounds:vQ(v,M),z:mR(v,h,o.zIndexMode),userNode:v}},a.set(v.id,M)}(M.measured===void 0||M.measured.width===void 0||M.measured.height===void 0)&&!M.hidden&&(f=!1),v.parentId&&SH(M,a,i,c,l),p||(p=v.selected??!1)}return{nodesInitialized:f,hasSelectedNodes:p}}function MQ(e,a){if(!e.parentId)return;const i=a.get(e.parentId);i?i.set(e.id,e):a.set(e.parentId,new Map([[e.id,e]]))}function SH(e,a,i,c,o){const{elevateNodesOnSelect:l,nodeOrigin:u,nodeExtent:h,zIndexMode:f}=bH(wH,c),p=e.parentId,g=a.get(p);if(!g){console.warn(`Parent node ${p} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}MQ(e,i),o&&!g.parentId&&g.internals.rootParentIndex===void 0&&f==="auto"&&(g.internals.rootParentIndex=++o.i,g.internals.z=g.internals.z+o.i*kQ),o&&g.internals.rootParentIndex!==void 0&&(o.i=g.internals.rootParentIndex);const m=l&&!LH(f)?kR:0,{x:v,y:M,z:b}=xQ(e,g,u,h,m,f),{positionAbsolute:w}=e.internals,L=v!==w.x||M!==w.y;(L||b!==e.internals.z)&&a.set(e.id,{...e,internals:{...e.internals,positionAbsolute:L?{x:v,y:M}:w,z:b}})}function mR(e,a,i){const c=qa(e.zIndex)?e.zIndex:0;return LH(i)?c:c+(e.selected?a:0)}function xQ(e,a,i,c,o,l){const{x:u,y:h}=a.internals.positionAbsolute,f=_n(e),p=U2(e,i),g=Ql(e.extent)?To(p,e.extent,f):p;let m=To({x:u+g.x,y:h+g.y},c,f);e.extent==="parent"&&(m=iR(m,f,a));const v=mR(e,o,l),M=a.internals.z??0;return{x:m.x,y:m.y,z:M>=v?M+1:v}}function CH(e,a,i,c=[0,0]){var u;const o=[],l=new Map;for(const h of e){const f=a.get(h.parentId);if(!f)continue;const p=((u=l.get(h.parentId))==null?void 0:u.expandedRect)??Kl(f),g=rR(p,h.rect);l.set(h.parentId,{expandedRect:g,parent:f})}return l.size>0&&l.forEach(({expandedRect:h,parent:f},p)=>{var C;const g=f.internals.positionAbsolute,m=_n(f),v=f.origin??c,M=h.x<g.x?Math.round(Math.abs(g.x-h.x)):0,b=h.y<g.y?Math.round(Math.abs(g.y-h.y)):0,w=Math.max(m.width,Math.round(h.width)),L=Math.max(m.height,Math.round(h.height)),S=(w-m.width)*v[0],q=(L-m.height)*v[1];(M>0||b>0||S||q)&&(o.push({id:p,type:"position",position:{x:f.position.x-M+S,y:f.position.y-b+q}}),(C=i.get(p))==null||C.forEach(z=>{e.some(H=>H.id===z.id)||o.push({id:z.id,type:"position",position:{x:z.position.x+M,y:z.position.y+b}})})),(m.width<h.width||m.height<h.height||M||b)&&o.push({id:p,type:"dimensions",setAttributes:!0,dimensions:{width:w+(M?v[0]*M-S:0),height:L+(b?v[1]*b-q:0)}})}),o}function wQ(e,a,i,c,o,l,u){const h=c==null?void 0:c.querySelector(".xyflow__viewport");let f=!1;if(!h)return{changes:[],updatedInternals:f};const p=[],g=window.getComputedStyle(h),{m22:m}=new window.DOMMatrixReadOnly(g.transform),v=[];for(const M of e.values()){const b=a.get(M.id);if(!b)continue;if(b.hidden){a.set(b.id,{...b,internals:{...b.internals,handleBounds:void 0}}),f=!0;continue}const w=xH(M.nodeElement),L=b.measured.width!==w.width||b.measured.height!==w.height;if(!!(w.width&&w.height&&(L||!b.internals.handleBounds||M.force))){const q=M.nodeElement.getBoundingClientRect(),C=Ql(b.extent)?b.extent:l;let{positionAbsolute:z}=b.internals;b.parentId&&b.extent==="parent"?z=iR(z,w,a.get(b.parentId)):C&&(z=To(z,C,w));const H={...b,measured:w,internals:{...b.internals,positionAbsolute:z,handleBounds:{source:CO("source",M.nodeElement,q,m,b.id),target:CO("target",M.nodeElement,q,m,b.id)}}};a.set(b.id,H),b.parentId&&SH(H,a,i,{nodeOrigin:o,zIndexMode:u}),f=!0,L&&(p.push({id:b.id,type:"dimensions",dimensions:w}),b.expandParent&&b.parentId&&v.push({id:b.id,parentId:b.parentId,rect:Kl(H,o)}))}}if(v.length>0){const M=CH(v,a,i,o);p.push(...M)}return{changes:p,updatedInternals:f}}async function bQ({delta:e,panZoom:a,transform:i,translateExtent:c,width:o,height:l}){if(!a||!e.x&&!e.y)return Promise.resolve(!1);const u=await a.setViewportConstrained({x:i[0]+e.x,y:i[1]+e.y,zoom:i[2]},[[0,0],[o,l]],c),h=!!u&&(u.x!==i[0]||u.y!==i[1]||u.k!==i[2]);return Promise.resolve(h)}function HO(e,a,i,c,o,l){let u=o;const h=c.get(u)||new Map;c.set(u,h.set(i,a)),u=`${o}-${e}`;const f=c.get(u)||new Map;if(c.set(u,f.set(i,a)),l){u=`${o}-${e}-${l}`;const p=c.get(u)||new Map;c.set(u,p.set(i,a))}}function gR(e,a,i){e.clear(),a.clear();for(const c of i){const{source:o,target:l,sourceHandle:u=null,targetHandle:h=null}=c,f={edgeId:c.id,source:o,target:l,sourceHandle:u,targetHandle:h},p=`${o}-${u}--${l}-${h}`,g=`${l}-${h}--${o}-${u}`;HO("source",f,g,e,o,u),HO("target",f,p,e,l,h),a.set(c.id,c)}}function vR(e,a){if(!e.parentId)return!1;const i=a.get(e.parentId);return i?i.selected?!0:vR(i,a):!1}function jO(e,a,i){var o;let c=e;do{if((o=c==null?void 0:c.matches)!=null&&o.call(c,a))return!0;if(c===i)return!1;c=c==null?void 0:c.parentElement}while(c);return!1}function LQ(e,a,i,c){const o=new Map;for(const[l,u]of e)if((u.selected||u.id===c)&&(!u.parentId||!vR(u,e))&&(u.draggable||a&&typeof u.draggable>"u")){const h=e.get(l);h&&o.set(l,{id:l,position:h.position||{x:0,y:0},distance:{x:i.x-h.internals.positionAbsolute.x,y:i.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return o}function iT({nodeId:e,dragItems:a,nodeLookup:i,dragging:c=!0}){var u,h,f;const o=[];for(const[p,g]of a){const m=(u=i.get(p))==null?void 0:u.internals.userNode;m&&o.push({...m,position:g.position,dragging:c})}if(!e)return[o[0],o];const l=(h=i.get(e))==null?void 0:h.internals.userNode;return[l?{...l,position:((f=a.get(e))==null?void 0:f.position)||l.position,dragging:c}:o[0],o]}function SQ({dragItems:e,snapGrid:a,x:i,y:c}){const o=e.values().next().value;if(!o)return null;const l={x:i-o.distance.x,y:c-o.distance.y},u=F2(l,a);return{x:u.x-l.x,y:u.y-l.y}}function CQ({onNodeMouseDown:e,getStoreItems:a,onDragStart:i,onDrag:c,onDragStop:o}){let l={x:null,y:null},u=0,h=new Map,f=!1,p={x:0,y:0},g=null,m=!1,v=null,M=!1,b=!1,w=null;function L({noDragClassName:q,handleSelector:C,domNode:z,isSelectable:H,nodeId:N,nodeClickDistance:E=0}){v=ra(z);function R({x:Z,y:ne}){const{nodeLookup:j,nodeExtent:X,snapGrid:T,snapToGrid:V,nodeOrigin:U,onNodeDrag:F,onSelectionDrag:J,onError:_,updateNodePositions:B}=a();l={x:Z,y:ne};let te=!1;const ie=h.size>1,le=ie&&X?OT(P2(h)):null,ue=ie&&V?SQ({dragItems:h,snapGrid:T,x:Z,y:ne}):null;for(const[he,se]of h){if(!j.has(he))continue;let ye={x:Z-se.distance.x,y:ne-se.distance.y};V&&(ye=ue?{x:Math.round(ye.x+ue.x),y:Math.round(ye.y+ue.y)}:F2(ye,T));let ze=null;if(ie&&X&&!se.extent&&le){const{positionAbsolute:xe}=se.internals,Ee=xe.x-le.x+X[0][0],Xe=xe.x+se.measured.width-le.x2+X[1][0],Oe=xe.y-le.y+X[0][1],Ct=xe.y+se.measured.height-le.y2+X[1][1];ze=[[Ee,Oe],[Xe,Ct]]}const{position:Se,positionAbsolute:we}=nR({nodeId:he,nextPosition:ye,nodeLookup:j,nodeExtent:ze||X,nodeOrigin:U,onError:_});te=te||se.position.x!==Se.x||se.position.y!==Se.y,se.position=Se,se.internals.positionAbsolute=we}if(b=b||te,!!te&&(B(h,!0),w&&(c||F||!N&&J))){const[he,se]=iT({nodeId:N,dragItems:h,nodeLookup:j});c==null||c(w,h,he,se),F==null||F(w,he,se),N||J==null||J(w,se)}}async function O(){if(!g)return;const{transform:Z,panBy:ne,autoPanSpeed:j,autoPanOnNodeDrag:X}=a();if(!X){f=!1,cancelAnimationFrame(u);return}const[T,V]=cR(p,g,j);(T!==0||V!==0)&&(l.x=(l.x??0)-T/Z[2],l.y=(l.y??0)-V/Z[2],await ne({x:T,y:V})&&R(l)),u=requestAnimationFrame(O)}function ae(Z){var ie;const{nodeLookup:ne,multiSelectionActive:j,nodesDraggable:X,transform:T,snapGrid:V,snapToGrid:U,selectNodesOnDrag:F,onNodeDragStart:J,onSelectionDragStart:_,unselectNodesAndEdges:B}=a();m=!0,(!F||!H)&&!j&&N&&((ie=ne.get(N))!=null&&ie.selected||B()),H&&F&&N&&(e==null||e(N));const te=f2(Z.sourceEvent,{transform:T,snapGrid:V,snapToGrid:U,containerBounds:g});if(l=te,h=LQ(ne,X,te,N),h.size>0&&(i||J||!N&&_)){const[le,ue]=iT({nodeId:N,dragItems:h,nodeLookup:ne});i==null||i(Z.sourceEvent,h,le,ue),J==null||J(Z.sourceEvent,le,ue),N||_==null||_(Z.sourceEvent,ue)}}const G=NB().clickDistance(E).on("start",Z=>{const{domNode:ne,nodeDragThreshold:j,transform:X,snapGrid:T,snapToGrid:V}=a();g=(ne==null?void 0:ne.getBoundingClientRect())||null,M=!1,b=!1,w=Z.sourceEvent,j===0&&ae(Z),l=f2(Z.sourceEvent,{transform:X,snapGrid:T,snapToGrid:V,containerBounds:g}),p=_a(Z.sourceEvent,g)}).on("drag",Z=>{const{autoPanOnNodeDrag:ne,transform:j,snapGrid:X,snapToGrid:T,nodeDragThreshold:V,nodeLookup:U}=a(),F=f2(Z.sourceEvent,{transform:j,snapGrid:X,snapToGrid:T,containerBounds:g});if(w=Z.sourceEvent,(Z.sourceEvent.type==="touchmove"&&Z.sourceEvent.touches.length>1||N&&!U.has(N))&&(M=!0),!M){if(!f&&ne&&m&&(f=!0,O()),!m){const J=_a(Z.sourceEvent,g),_=J.x-p.x,B=J.y-p.y;Math.sqrt(_*_+B*B)>V&&ae(Z)}(l.x!==F.xSnapped||l.y!==F.ySnapped)&&h&&m&&(p=_a(Z.sourceEvent,g),R(F))}}).on("end",Z=>{if(!(!m||M)&&(f=!1,m=!1,cancelAnimationFrame(u),h.size>0)){const{nodeLookup:ne,updateNodePositions:j,onNodeDragStop:X,onSelectionDragStop:T}=a();if(b&&(j(h,!1),b=!1),o||X||!N&&T){const[V,U]=iT({nodeId:N,dragItems:h,nodeLookup:ne,dragging:!1});o==null||o(Z.sourceEvent,h,V,U),X==null||X(Z.sourceEvent,V,U),N||T==null||T(Z.sourceEvent,U)}}}).filter(Z=>{const ne=Z.target;return!Z.button&&(!q||!jO(ne,`.${q}`,z))&&(!C||jO(ne,C,z))});v.call(G)}function S(){v==null||v.on(".drag",null)}return{update:L,destroy:S}}function AQ(e,a,i){const c=[],o={x:e.x-i,y:e.y-i,width:i*2,height:i*2};for(const l of a.values())q2(o,Kl(l))>0&&c.push(l);return c}const IQ=250;function zQ(e,a,i,c){var h,f;let o=[],l=1/0;const u=AQ(e,i,a+IQ);for(const p of u){const g=[...((h=p.internals.handleBounds)==null?void 0:h.source)??[],...((f=p.internals.handleBounds)==null?void 0:f.target)??[]];for(const m of g){if(c.nodeId===m.nodeId&&c.type===m.type&&c.id===m.id)continue;const{x:v,y:M}=Ho(p,m,m.position,!0),b=Math.sqrt(Math.pow(v-e.x,2)+Math.pow(M-e.y,2));b>a||(b<l?(o=[{...m,x:v,y:M}],l=b):b===l&&o.push({...m,x:v,y:M}))}}if(!o.length)return null;if(o.length>1){const p=c.type==="source"?"target":"source";return o.find(g=>g.type===p)??o[0]}return o[0]}function MR(e,a,i,c,o,l=!1){var p,g,m;const u=c.get(e);if(!u)return null;const h=o==="strict"?(p=u.internals.handleBounds)==null?void 0:p[a]:[...((g=u.internals.handleBounds)==null?void 0:g.source)??[],...((m=u.internals.handleBounds)==null?void 0:m.target)??[]],f=(i?h==null?void 0:h.find(v=>v.id===i):h==null?void 0:h[0])??null;return f&&l?{...f,...Ho(u,f,f.position,!0)}:f}function xR(e,a){return e||(a!=null&&a.classList.contains("target")?"target":a!=null&&a.classList.contains("source")?"source":null)}function qQ(e,a){let i=null;return a?i=!0:e&&!a&&(i=!1),i}const wR=()=>!0;function _Q(e,{connectionMode:a,connectionRadius:i,handleId:c,nodeId:o,edgeUpdaterType:l,isTarget:u,domNode:h,nodeLookup:f,lib:p,autoPanOnConnect:g,flowId:m,panBy:v,cancelConnection:M,onConnectStart:b,onConnect:w,onConnectEnd:L,isValidConnection:S=wR,onReconnectEnd:q,updateConnection:C,getTransform:z,getFromHandle:H,autoPanSpeed:N,dragThreshold:E=1,handleDomNode:R}){const O=sR(e.target);let ae=0,G;const{x:Z,y:ne}=_a(e),j=xR(l,R),X=h==null?void 0:h.getBoundingClientRect();let T=!1;if(!X||!j)return;const V=MR(o,j,c,f,a);if(!V)return;let U=_a(e,X),F=!1,J=null,_=!1,B=null;function te(){if(!g||!X)return;const[Se,we]=cR(U,X,N);v({x:Se,y:we}),ae=requestAnimationFrame(te)}const ie={...V,nodeId:o,type:j,position:V.position},le=f.get(o);let he={inProgress:!0,isValid:null,from:Ho(le,ie,ve.Left,!0),fromHandle:ie,fromPosition:ie.position,fromNode:le,to:U,toHandle:null,toPosition:wO[ie.position],toNode:null,pointer:U};function se(){T=!0,C(he),b==null||b(e,{nodeId:o,handleId:c,handleType:j})}E===0&&se();function ye(Se){if(!T){const{x:Ct,y:xa}=_a(Se),Qt=Ct-Z,wa=xa-ne;if(!(Qt*Qt+wa*wa>E*E))return;se()}if(!H()||!ie){ze(Se);return}const we=z();U=_a(Se,X),G=zQ(Z2(U,we,!1,[1,1]),i,f,ie),F||(te(),F=!0);const xe=bR(Se,{handle:G,connectionMode:a,fromNodeId:o,fromHandleId:c,fromType:u?"target":"source",isValidConnection:S,doc:O,lib:p,flowId:m,nodeLookup:f});B=xe.handleDomNode,J=xe.connection,_=qQ(!!G,xe.isValid);const Ee=f.get(o),Xe=Ee?Ho(Ee,ie,ve.Left,!0):he.from,Oe={...he,from:Xe,isValid:_,to:xe.toHandle&&_?YI({x:xe.toHandle.x,y:xe.toHandle.y},we):U,toHandle:xe.toHandle,toPosition:_&&xe.toHandle?xe.toHandle.position:wO[ie.position],toNode:xe.toHandle?f.get(xe.toHandle.nodeId):null,pointer:U};C(Oe),he=Oe}function ze(Se){if(!("touches"in Se&&Se.touches.length>0)){if(T){(G||B)&&J&&_&&(w==null||w(J));const{inProgress:we,...xe}=he,Ee={...xe,toPosition:he.toHandle?he.toPosition:null};L==null||L(Se,Ee),l&&(q==null||q(Se,Ee))}M(),cancelAnimationFrame(ae),F=!1,_=!1,J=null,B=null,O.removeEventListener("mousemove",ye),O.removeEventListener("mouseup",ze),O.removeEventListener("touchmove",ye),O.removeEventListener("touchend",ze)}}O.addEventListener("mousemove",ye),O.addEventListener("mouseup",ze),O.addEventListener("touchmove",ye),O.addEventListener("touchend",ze)}function bR(e,{handle:a,connectionMode:i,fromNodeId:c,fromHandleId:o,fromType:l,doc:u,lib:h,flowId:f,isValidConnection:p=wR,nodeLookup:g}){const m=l==="target",v=a?u.querySelector(`.${h}-flow__handle[data-id="${f}-${a==null?void 0:a.nodeId}-${a==null?void 0:a.id}-${a==null?void 0:a.type}"]`):null,{x:M,y:b}=_a(e),w=u.elementFromPoint(M,b),L=w!=null&&w.classList.contains(`${h}-flow__handle`)?w:v,S={handleDomNode:L,isValid:!1,connection:null,toHandle:null};if(L){const q=xR(void 0,L),C=L.getAttribute("data-nodeid"),z=L.getAttribute("data-handleid"),H=L.classList.contains("connectable"),N=L.classList.contains("connectableend");if(!C||!q)return S;const E={source:m?C:c,sourceHandle:m?z:o,target:m?c:C,targetHandle:m?o:z};S.connection=E;const O=H&&N&&(i===Xl.Strict?m&&q==="source"||!m&&q==="target":C!==c||z!==o);S.isValid=O&&p(E),S.toHandle=MR(C,q,z,g,i,!0)}return S}const UT={onPointerDown:_Q,isValid:bR};function TQ({domNode:e,panZoom:a,getTransform:i,getViewScale:c}){const o=ra(e);function l({translateExtent:h,width:f,height:p,zoomStep:g=1,pannable:m=!0,zoomable:v=!0,inversePan:M=!1}){const b=C=>{if(C.sourceEvent.type!=="wheel"||!a)return;const z=i(),H=C.sourceEvent.ctrlKey&&_2()?10:1,N=-C.sourceEvent.deltaY*(C.sourceEvent.deltaMode===1?.05:C.sourceEvent.deltaMode?1:.002)*g,E=z[2]*Math.pow(2,N*H);a.scaleTo(E)};let w=[0,0];const L=C=>{(C.sourceEvent.type==="mousedown"||C.sourceEvent.type==="touchstart")&&(w=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY])},S=C=>{const z=i();if(C.sourceEvent.type!=="mousemove"&&C.sourceEvent.type!=="touchmove"||!a)return;const H=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY],N=[H[0]-w[0],H[1]-w[1]];w=H;const E=c()*Math.max(z[2],Math.log(z[2]))*(M?-1:1),R={x:z[0]-N[0]*E,y:z[1]-N[1]*E},O=[[0,0],[f,p]];a.setViewportConstrained({x:R.x,y:R.y,zoom:z[2]},O,h)},q=QB().on("start",L).on("zoom",m?S:null).on("zoom.wheel",v?b:null);o.call(q,{})}function u(){o.on("zoom",null)}return{update:l,destroy:u,pointer:Ia}}const pz=e=>({x:e.x,y:e.y,zoom:e.k}),cT=({x:e,y:a,zoom:i})=>hz.translate(e,a).scale(i),zl=(e,a)=>e.target.closest(`.${a}`),LR=(e,a)=>a===2&&Array.isArray(e)&&e.includes(2),HQ=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,rT=(e,a=0,i=HQ,c=()=>{})=>{const o=typeof a=="number"&&a>0;return o||c(),o?e.transition().duration(a).ease(i).on("end",c):e},SR=e=>{const a=e.ctrlKey&&_2()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*a};function jQ({zoomPanValues:e,noWheelClassName:a,d3Selection:i,d3Zoom:c,panOnScrollMode:o,panOnScrollSpeed:l,zoomOnPinch:u,onPanZoomStart:h,onPanZoom:f,onPanZoomEnd:p}){return g=>{if(zl(g,a))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const m=i.property("__zoom").k||1;if(g.ctrlKey&&u){const L=Ia(g),S=SR(g),q=m*Math.pow(2,S);c.scaleTo(i,q,L,g);return}const v=g.deltaMode===1?20:1;let M=o===So.Vertical?0:g.deltaX*v,b=o===So.Horizontal?0:g.deltaY*v;!_2()&&g.shiftKey&&o!==So.Vertical&&(M=g.deltaY*v,b=0),c.translateBy(i,-(M/m)*l,-(b/m)*l,{internal:!0});const w=pz(i.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(f==null||f(g,w),e.panScrollTimeout=setTimeout(()=>{p==null||p(g,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,h==null||h(g,w))}}function EQ({noWheelClassName:e,preventScrolling:a,d3ZoomHandler:i}){return function(c,o){const l=c.type==="wheel",u=!a&&l&&!c.ctrlKey,h=zl(c,e);if(c.ctrlKey&&l&&h&&c.preventDefault(),u||h)return null;c.preventDefault(),i.call(this,c,o)}}function NQ({zoomPanValues:e,onDraggingChange:a,onPanZoomStart:i}){return c=>{var l,u,h;if((l=c.sourceEvent)!=null&&l.internal)return;const o=pz(c.transform);e.mouseButton=((u=c.sourceEvent)==null?void 0:u.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((h=c.sourceEvent)==null?void 0:h.type)==="mousedown"&&a(!0),i&&(i==null||i(c.sourceEvent,o))}}function DQ({zoomPanValues:e,panOnDrag:a,onPaneContextMenu:i,onTransformChange:c,onPanZoom:o}){return l=>{var u,h;e.usedRightMouseButton=!!(i&&LR(a,e.mouseButton??0)),(u=l.sourceEvent)!=null&&u.sync||c([l.transform.x,l.transform.y,l.transform.k]),o&&!((h=l.sourceEvent)!=null&&h.internal)&&(o==null||o(l.sourceEvent,pz(l.transform)))}}function OQ({zoomPanValues:e,panOnDrag:a,panOnScroll:i,onDraggingChange:c,onPanZoomEnd:o,onPaneContextMenu:l}){return u=>{var h;if(!((h=u.sourceEvent)!=null&&h.internal)&&(e.isZoomingOrPanning=!1,l&&LR(a,e.mouseButton??0)&&!e.usedRightMouseButton&&u.sourceEvent&&l(u.sourceEvent),e.usedRightMouseButton=!1,c(!1),o)){const f=pz(u.transform);e.prevViewport=f,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(u.sourceEvent,f)},i?150:0)}}}function VQ({zoomActivationKeyPressed:e,zoomOnScroll:a,zoomOnPinch:i,panOnDrag:c,panOnScroll:o,zoomOnDoubleClick:l,userSelectionActive:u,noWheelClassName:h,noPanClassName:f,lib:p,connectionInProgress:g}){return m=>{var L;const v=e||a,M=i&&m.ctrlKey,b=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(zl(m,`${p}-flow__node`)||zl(m,`${p}-flow__edge`)))return!0;if(!c&&!v&&!o&&!l&&!i||u||g&&!b||zl(m,h)&&b||zl(m,f)&&(!b||o&&b&&!e)||!i&&m.ctrlKey&&b)return!1;if(!i&&m.type==="touchstart"&&((L=m.touches)==null?void 0:L.length)>1)return m.preventDefault(),!1;if(!v&&!o&&!M&&b||!c&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(c)&&!c.includes(m.button)&&m.type==="mousedown")return!1;const w=Array.isArray(c)&&c.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||b)&&w}}function BQ({domNode:e,minZoom:a,maxZoom:i,translateExtent:c,viewport:o,onPanZoom:l,onPanZoomStart:u,onPanZoomEnd:h,onDraggingChange:f}){const p={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=e.getBoundingClientRect(),m=QB().scaleExtent([a,i]).translateExtent(c),v=ra(e).call(m);q({x:o.x,y:o.y,zoom:Yl(o.zoom,a,i)},[[0,0],[g.width,g.height]],c);const M=v.on("wheel.zoom"),b=v.on("dblclick.zoom");m.wheelDelta(SR);function w(G,Z){return v?new Promise(ne=>{m==null||m.interpolate((Z==null?void 0:Z.interpolate)==="linear"?y2:Ed).transform(rT(v,Z==null?void 0:Z.duration,Z==null?void 0:Z.ease,()=>ne(!0)),G)}):Promise.resolve(!1)}function L({noWheelClassName:G,noPanClassName:Z,onPaneContextMenu:ne,userSelectionActive:j,panOnScroll:X,panOnDrag:T,panOnScrollMode:V,panOnScrollSpeed:U,preventScrolling:F,zoomOnPinch:J,zoomOnScroll:_,zoomOnDoubleClick:B,zoomActivationKeyPressed:te,lib:ie,onTransformChange:le,connectionInProgress:ue,paneClickDistance:he,selectionOnDrag:se}){j&&!p.isZoomingOrPanning&&S();const ye=X&&!te&&!j;m.clickDistance(se?1/0:!qa(he)||he<0?0:he);const ze=ye?jQ({zoomPanValues:p,noWheelClassName:G,d3Selection:v,d3Zoom:m,panOnScrollMode:V,panOnScrollSpeed:U,zoomOnPinch:J,onPanZoomStart:u,onPanZoom:l,onPanZoomEnd:h}):EQ({noWheelClassName:G,preventScrolling:F,d3ZoomHandler:M});if(v.on("wheel.zoom",ze,{passive:!1}),!j){const we=NQ({zoomPanValues:p,onDraggingChange:f,onPanZoomStart:u});m.on("start",we);const xe=DQ({zoomPanValues:p,panOnDrag:T,onPaneContextMenu:!!ne,onPanZoom:l,onTransformChange:le});m.on("zoom",xe);const Ee=OQ({zoomPanValues:p,panOnDrag:T,panOnScroll:X,onPaneContextMenu:ne,onPanZoomEnd:h,onDraggingChange:f});m.on("end",Ee)}const Se=VQ({zoomActivationKeyPressed:te,panOnDrag:T,zoomOnScroll:_,panOnScroll:X,zoomOnDoubleClick:B,zoomOnPinch:J,userSelectionActive:j,noPanClassName:Z,noWheelClassName:G,lib:ie,connectionInProgress:ue});m.filter(Se),B?v.on("dblclick.zoom",b):v.on("dblclick.zoom",null)}function S(){m.on("zoom",null)}async function q(G,Z,ne){const j=cT(G),X=m==null?void 0:m.constrain()(j,Z,ne);return X&&await w(X),new Promise(T=>T(X))}async function C(G,Z){const ne=cT(G);return await w(ne,Z),new Promise(j=>j(ne))}function z(G){if(v){const Z=cT(G),ne=v.property("__zoom");(ne.k!==G.zoom||ne.x!==G.x||ne.y!==G.y)&&(m==null||m.transform(v,Z,null,{sync:!0}))}}function H(){const G=v?KB(v.node()):{x:0,y:0,k:1};return{x:G.x,y:G.y,zoom:G.k}}function N(G,Z){return v?new Promise(ne=>{m==null||m.interpolate((Z==null?void 0:Z.interpolate)==="linear"?y2:Ed).scaleTo(rT(v,Z==null?void 0:Z.duration,Z==null?void 0:Z.ease,()=>ne(!0)),G)}):Promise.resolve(!1)}function E(G,Z){return v?new Promise(ne=>{m==null||m.interpolate((Z==null?void 0:Z.interpolate)==="linear"?y2:Ed).scaleBy(rT(v,Z==null?void 0:Z.duration,Z==null?void 0:Z.ease,()=>ne(!0)),G)}):Promise.resolve(!1)}function R(G){m==null||m.scaleExtent(G)}function O(G){m==null||m.translateExtent(G)}function ae(G){const Z=!qa(G)||G<0?0:G;m==null||m.clickDistance(Z)}return{update:L,destroy:S,setViewport:C,setViewportConstrained:q,getViewport:H,scaleTo:N,scaleBy:E,setScaleExtent:R,setTranslateExtent:O,syncViewport:z,setClickDistance:ae}}var Wl;(function(e){e.Line="line",e.Handle="handle"})(Wl||(Wl={}));function RQ({width:e,prevWidth:a,height:i,prevHeight:c,affectsX:o,affectsY:l}){const u=e-a,h=i-c,f=[u>0?1:u<0?-1:0,h>0?1:h<0?-1:0];return u&&o&&(f[0]=f[0]*-1),h&&l&&(f[1]=f[1]*-1),f}function EO(e){const a=e.includes("right")||e.includes("left"),i=e.includes("bottom")||e.includes("top"),c=e.includes("left"),o=e.includes("top");return{isHorizontal:a,isVertical:i,affectsX:c,affectsY:o}}function d1(e,a){return Math.max(0,a-e)}function u1(e,a){return Math.max(0,e-a)}function Ad(e,a,i){return Math.max(0,a-e,e-i)}function NO(e,a){return e?!a:a}function UQ(e,a,i,c,o,l,u,h){let{affectsX:f,affectsY:p}=a;const{isHorizontal:g,isVertical:m}=a,v=g&&m,{xSnapped:M,ySnapped:b}=i,{minWidth:w,maxWidth:L,minHeight:S,maxHeight:q}=c,{x:C,y:z,width:H,height:N,aspectRatio:E}=e;let R=Math.floor(g?M-e.pointerX:0),O=Math.floor(m?b-e.pointerY:0);const ae=H+(f?-R:R),G=N+(p?-O:O),Z=-l[0]*H,ne=-l[1]*N;let j=Ad(ae,w,L),X=Ad(G,S,q);if(u){let U=0,F=0;f&&R<0?U=d1(C+R+Z,u[0][0]):!f&&R>0&&(U=u1(C+ae+Z,u[1][0])),p&&O<0?F=d1(z+O+ne,u[0][1]):!p&&O>0&&(F=u1(z+G+ne,u[1][1])),j=Math.max(j,U),X=Math.max(X,F)}if(h){let U=0,F=0;f&&R>0?U=u1(C+R,h[0][0]):!f&&R<0&&(U=d1(C+ae,h[1][0])),p&&O>0?F=u1(z+O,h[0][1]):!p&&O<0&&(F=d1(z+G,h[1][1])),j=Math.max(j,U),X=Math.max(X,F)}if(o){if(g){const U=Ad(ae/E,S,q)*E;if(j=Math.max(j,U),u){let F=0;!f&&!p||f&&!p&&v?F=u1(z+ne+ae/E,u[1][1])*E:F=d1(z+ne+(f?R:-R)/E,u[0][1])*E,j=Math.max(j,F)}if(h){let F=0;!f&&!p||f&&!p&&v?F=d1(z+ae/E,h[1][1])*E:F=u1(z+(f?R:-R)/E,h[0][1])*E,j=Math.max(j,F)}}if(m){const U=Ad(G*E,w,L)/E;if(X=Math.max(X,U),u){let F=0;!f&&!p||p&&!f&&v?F=u1(C+G*E+Z,u[1][0])/E:F=d1(C+(p?O:-O)*E+Z,u[0][0])/E,X=Math.max(X,F)}if(h){let F=0;!f&&!p||p&&!f&&v?F=d1(C+G*E,h[1][0])/E:F=u1(C+(p?O:-O)*E,h[0][0])/E,X=Math.max(X,F)}}}O=O+(O<0?X:-X),R=R+(R<0?j:-j),o&&(v?ae>G*E?O=(NO(f,p)?-R:R)/E:R=(NO(f,p)?-O:O)*E:g?(O=R/E,p=f):(R=O*E,f=p));const T=f?C+R:C,V=p?z+O:z;return{width:H+(f?-R:R),height:N+(p?-O:O),x:l[0]*R*(f?-1:1)+T,y:l[1]*O*(p?-1:1)+V}}const CR={width:0,height:0,x:0,y:0},PQ={...CR,pointerX:0,pointerY:0,aspectRatio:1};function FQ(e){return[[0,0],[e.measured.width,e.measured.height]]}function ZQ(e,a,i){const c=a.position.x+e.position.x,o=a.position.y+e.position.y,l=e.measured.width??0,u=e.measured.height??0,h=i[0]*l,f=i[1]*u;return[[c-h,o-f],[c+l-h,o+u-f]]}function GQ({domNode:e,nodeId:a,getStoreItems:i,onChange:c,onEnd:o}){const l=ra(e);let u={controlDirection:EO("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:p,boundaries:g,keepAspectRatio:m,resizeDirection:v,onResizeStart:M,onResize:b,onResizeEnd:w,shouldResize:L}){let S={...CR},q={...PQ};u={boundaries:g,resizeDirection:v,keepAspectRatio:m,controlDirection:EO(p)};let C,z=null,H=[],N,E,R,O=!1;const ae=NB().on("start",G=>{const{nodeLookup:Z,transform:ne,snapGrid:j,snapToGrid:X,nodeOrigin:T,paneDomNode:V}=i();if(C=Z.get(a),!C)return;z=(V==null?void 0:V.getBoundingClientRect())??null;const{xSnapped:U,ySnapped:F}=f2(G.sourceEvent,{transform:ne,snapGrid:j,snapToGrid:X,containerBounds:z});S={width:C.measured.width??0,height:C.measured.height??0,x:C.position.x??0,y:C.position.y??0},q={...S,pointerX:U,pointerY:F,aspectRatio:S.width/S.height},N=void 0,C.parentId&&(C.extent==="parent"||C.expandParent)&&(N=Z.get(C.parentId),E=N&&C.extent==="parent"?FQ(N):void 0),H=[],R=void 0;for(const[J,_]of Z)if(_.parentId===a&&(H.push({id:J,position:{..._.position},extent:_.extent}),_.extent==="parent"||_.expandParent)){const B=ZQ(_,C,_.origin??T);R?R=[[Math.min(B[0][0],R[0][0]),Math.min(B[0][1],R[0][1])],[Math.max(B[1][0],R[1][0]),Math.max(B[1][1],R[1][1])]]:R=B}M==null||M(G,{...S})}).on("drag",G=>{const{transform:Z,snapGrid:ne,snapToGrid:j,nodeOrigin:X}=i(),T=f2(G.sourceEvent,{transform:Z,snapGrid:ne,snapToGrid:j,containerBounds:z}),V=[];if(!C)return;const{x:U,y:F,width:J,height:_}=S,B={},te=C.origin??X,{width:ie,height:le,x:ue,y:he}=UQ(q,u.controlDirection,T,u.boundaries,u.keepAspectRatio,te,E,R),se=ie!==J,ye=le!==_,ze=ue!==U&&se,Se=he!==F&&ye;if(!ze&&!Se&&!se&&!ye)return;if((ze||Se||te[0]===1||te[1]===1)&&(B.x=ze?ue:S.x,B.y=Se?he:S.y,S.x=B.x,S.y=B.y,H.length>0)){const Xe=ue-U,Oe=he-F;for(const Ct of H)Ct.position={x:Ct.position.x-Xe+te[0]*(ie-J),y:Ct.position.y-Oe+te[1]*(le-_)},V.push(Ct)}if((se||ye)&&(B.width=se&&(!u.resizeDirection||u.resizeDirection==="horizontal")?ie:S.width,B.height=ye&&(!u.resizeDirection||u.resizeDirection==="vertical")?le:S.height,S.width=B.width,S.height=B.height),N&&C.expandParent){const Xe=te[0]*(B.width??0);B.x&&B.x<Xe&&(S.x=Xe,q.x=q.x-(B.x-Xe));const Oe=te[1]*(B.height??0);B.y&&B.y<Oe&&(S.y=Oe,q.y=q.y-(B.y-Oe))}const we=RQ({width:S.width,prevWidth:J,height:S.height,prevHeight:_,affectsX:u.controlDirection.affectsX,affectsY:u.controlDirection.affectsY}),xe={...S,direction:we};(L==null?void 0:L(G,xe))!==!1&&(O=!0,b==null||b(G,xe),c(B,V))}).on("end",G=>{O&&(w==null||w(G,{...S}),o==null||o({...S}),O=!1)});l.call(ae)}function f(){l.on(".drag",null)}return{update:h,destroy:f}}var oT={exports:{}},lT={},sT={exports:{}},dT={};/**
|
|
179
|
+
`,i)+1}return{type:a,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(a){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const i=vd(a),c=wl(i);return c.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:c,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const i=vd(a),c=wl(i);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:c,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(a,i){return this.type!=="comment"||this.indent<=i?!1:a.every(c=>c.type==="newline"||c.type==="space")}*documentEnd(a){this.type!=="doc-mode"&&(a.end?a.end.push(this.sourceToken):a.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(a){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:a.end?a.end.push(this.sourceToken):a.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function WG(e){const a=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||a&&new KG||null,prettyErrors:a}}function JG(e,a={}){const{lineCounter:i,prettyErrors:c}=WG(a),o=new QG(i==null?void 0:i.addNewLine),l=new ZG(a);let u=null;for(const h of l.compose(o.parse(e),!0,e.length))if(!u)u=h;else if(u.options.logLevel!=="silent"){u.errors.push(new l2(h.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return c&&i&&(u.errors.forEach(YD(e,i)),u.warnings.forEach(YD(e,i))),u}function tO(e,a,i){let c;const o=JG(e,i);if(!o)return null;if(o.warnings.forEach(l=>ZV(o.options.logLevel,l)),o.errors.length>0){if(o.options.logLevel!=="silent")throw o.errors[0];o.errors=[]}return o.toJS(Object.assign({reviver:c},i))}const e$={service:"server",database:"database",container:"box",frontend:"globe","third-party-gateway":"plug"};function t$(e){return"milestones"in e||"diagramName"in e}function a$(e){const i=[...e.milestones??[]].sort((p,g)=>p.id-g.id),c=p=>`m${p}`,o=i.map(p=>({id:c(p.id),label:p.name,description:p.description})),u=(e.elements??[]).map(p=>{const g=p.sms,m=p.ems,v=p.metadata??{},M={};for(const[L,S]of Object.entries(v))Array.isArray(S)&&S.every(q=>typeof q=="string")&&(M[L]=S);const b=typeof p.icon=="string"?p.icon:e$[String(p.type)],w=typeof p.type=="string"?p.type:b;return{id:String(p.id),label:String(p.label),icon:b,kind:w,parentId:p.parentId==null?void 0:String(p.parentId),lifespan:{startMilestone:typeof g=="number"?c(g):void 0,endMilestone:typeof m=="number"?c(m):void 0},metadata:Object.keys(M).length?M:void 0}}),f=(e.connectors??[]).map(p=>({id:String(p.id),source:String(p.sourceId),target:String(p.targetId),label:p.label==null?void 0:String(p.label),directed:!0}));return{title:e.diagramName?String(e.diagramName):void 0,timeline:o,elements:u,connectors:f}}function n$(e,a){if(/\.ya?ml$/i.test(a??""))return tO(e);try{return JSON.parse(e)}catch{return tO(e)}}function zT(e,a){const i=n$(e,a);if(i&&typeof i=="object"&&!Array.isArray(i)){const c=i;if(t$(c))return a$(c)}return i}function Md(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var W_={exports:{}},aO;function i$(){return aO||(aO=1,(function(e,a){(function(i){e.exports=i()})(function(){return(function(){function i(c,o,l){function u(p,g){if(!o[p]){if(!c[p]){var m=typeof Md=="function"&&Md;if(!g&&m)return m(p,!0);if(h)return h(p,!0);var v=new Error("Cannot find module '"+p+"'");throw v.code="MODULE_NOT_FOUND",v}var M=o[p]={exports:{}};c[p][0].call(M.exports,function(b){var w=c[p][1][b];return u(w||b)},M,M.exports,i,c,o,l)}return o[p].exports}for(var h=typeof Md=="function"&&Md,f=0;f<l.length;f++)u(l[f]);return u}return i})()({1:[function(i,c,o){Object.defineProperty(o,"__esModule",{value:!0});var l=(function(){function p(g,m){for(var v=0;v<m.length;v++){var M=m[v];M.enumerable=M.enumerable||!1,M.configurable=!0,"value"in M&&(M.writable=!0),Object.defineProperty(g,M.key,M)}}return function(g,m,v){return m&&p(g.prototype,m),v&&p(g,v),g}})();function u(p,g){if(!(p instanceof g))throw new TypeError("Cannot call a class as a function")}var h=(function(){function p(){var g=this,m=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},v=m.defaultLayoutOptions,M=v===void 0?{}:v,b=m.algorithms,w=b===void 0?["layered","stress","mrtree","radial","force","disco","sporeOverlap","sporeCompaction","rectpacking"]:b,L=m.workerFactory,S=m.workerUrl;if(u(this,p),this.defaultLayoutOptions=M,this.initialized=!1,typeof S>"u"&&typeof L>"u")throw new Error("Cannot construct an ELK without both 'workerUrl' and 'workerFactory'.");var q=L;typeof S<"u"&&typeof L>"u"&&(q=function(H){return new Worker(H)});var C=q(S);if(typeof C.postMessage!="function")throw new TypeError("Created worker does not provide the required 'postMessage' function.");this.worker=new f(C),this.worker.postMessage({cmd:"register",algorithms:w}).then(function(z){return g.initialized=!0}).catch(console.err)}return l(p,[{key:"layout",value:function(m){var v=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},M=v.layoutOptions,b=M===void 0?this.defaultLayoutOptions:M,w=v.logging,L=w===void 0?!1:w,S=v.measureExecutionTime,q=S===void 0?!1:S;return m?this.worker.postMessage({cmd:"layout",graph:m,layoutOptions:b,options:{logging:L,measureExecutionTime:q}}):Promise.reject(new Error("Missing mandatory parameter 'graph'."))}},{key:"knownLayoutAlgorithms",value:function(){return this.worker.postMessage({cmd:"algorithms"})}},{key:"knownLayoutOptions",value:function(){return this.worker.postMessage({cmd:"options"})}},{key:"knownLayoutCategories",value:function(){return this.worker.postMessage({cmd:"categories"})}},{key:"terminateWorker",value:function(){this.worker&&this.worker.terminate()}}]),p})();o.default=h;var f=(function(){function p(g){var m=this;if(u(this,p),g===void 0)throw new Error("Missing mandatory parameter 'worker'.");this.resolvers={},this.worker=g,this.worker.onmessage=function(v){setTimeout(function(){m.receive(m,v)},0)}}return l(p,[{key:"postMessage",value:function(m){var v=this.id||0;this.id=v+1,m.id=v;var M=this;return new Promise(function(b,w){M.resolvers[v]=function(L,S){L?(M.convertGwtStyleError(L),w(L)):b(S)},M.worker.postMessage(m)})}},{key:"receive",value:function(m,v){var M=v.data,b=m.resolvers[M.id];b&&(delete m.resolvers[M.id],M.error?b(M.error):b(null,M.data))}},{key:"terminate",value:function(){this.worker&&this.worker.terminate()}},{key:"convertGwtStyleError",value:function(m){if(m){var v=m.__java$exception;v&&(v.cause&&v.cause.backingJsObject&&(m.cause=v.cause.backingJsObject,this.convertGwtStyleError(m.cause)),delete m.__java$exception)}}}]),p})()},{}],2:[function(i,c,o){var l=i("./elk-api.js").default;Object.defineProperty(c.exports,"__esModule",{value:!0}),c.exports=l,l.default=l},{"./elk-api.js":1}]},{},[2])(2)})})(W_)),W_.exports}var c$=i$();const r$=GT(c$),nO=""+new URL("elk-worker.min--dAJroGl.js",import.meta.url).href;let J_=null;function o$(){return J_||(J_=new r$({workerFactory:e=>new Worker(e??nO),workerUrl:nO})),J_}const l$={"elk.algorithm":"layered","elk.layered.spacing.nodeNodeBetweenLayers":"80","elk.spacing.nodeNode":"60","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.edgeRouting":"ORTHOGONAL"},MB=30,s$=`[top=${MB+6},left=14,bottom=14,right=14]`;function d$(e){const a=new Map;for(const c of e)a.set(c.id,{id:c.id,width:c.width,height:c.height,children:[]});const i=[];for(const c of e){const o=a.get(c.id),l=c.parentId?a.get(c.parentId):void 0;l?l.children.push(o):i.push(o)}for(const c of a.values())c.children&&c.children.length>0&&(c.layoutOptions={"elk.padding":s$});return i}function u$(e,a,i){return{id:"root",layoutOptions:{...l$,"elk.direction":i},children:d$(e),edges:a.map(c=>({id:c.id,sources:[c.source],targets:[c.target]}))}}function xB(e,a=0,i=0,c=void 0,o=[]){for(const l of e){const u=l.x??0,h=l.y??0,f=u+a,p=h+i;o.push({id:l.id,x:f,y:p,relativeX:u,relativeY:h,width:l.width??0,height:l.height??0,parentId:c}),l.children&&l.children.length>0&&xB(l.children,f,p,l.id,o)}return o}const h$=170,y$=52;function f$(e){const a=e.elements.map(u=>({id:u.id,width:h$,height:y$,parentId:u.parentId})),i=new Map(e.elements.map(u=>[u.id,u.parentId])),c=new Set(e.elements.map(u=>u.id)),o=(u,h)=>{let f=h;for(;f;){if(f===u)return!0;f=i.get(f)}return!1},l=e.connectors.filter(u=>c.has(u.source)&&c.has(u.target)&&!o(u.source,u.target)&&!o(u.target,u.source)).map(u=>({id:u.id,source:u.source,target:u.target}));return{nodes:a,edges:l}}async function iO(e,a="DOWN"){const{nodes:i,edges:c}=f$(e);if(i.length===0)return{positions:new Map,bounds:{width:0,height:0}};const o=u$(i,c,a),l=await o$().layout(o),u=xB(l.children??[]),h=new Map(u.map(g=>[g.id,g])),f=Math.max(0,...u.map(g=>g.x+g.width)),p=Math.max(0,...u.map(g=>g.y+g.height));return{positions:h,bounds:{width:f,height:p}}}const Le=IF((e,a)=>({diagram:null,timeline:null,report:null,masterLayout:null,loadStatus:"empty",errors:[],active:0,view:"graph",selectedElementId:null,compare:{enabled:!1,from:0,to:0},filter:{},colorProperty:null,loadDiagram:async i=>{e({loadStatus:"loading",errors:[]});const{diagram:c,report:o}=RD(i);if(!c)return e({loadStatus:"error",report:o,errors:o.schemaErrors}),!1;const l=new MT(c.timeline),u=Math.max(0,l.length-1);e({diagram:c,timeline:l,report:o,masterLayout:null,errors:o.schemaErrors,active:0,selectedElementId:null,compare:{enabled:!1,from:0,to:u},filter:{},colorProperty:null});try{const h=await iO(c,"DOWN");return a().diagram!==c||e({masterLayout:h,loadStatus:"ready"}),!0}catch(h){return a().diagram!==c||e({loadStatus:"error",errors:[String(h)]}),!1}},reloadDiagram:async i=>{const c=a();e({loadStatus:"loading",errors:[]});const{diagram:o,report:l}=RD(i);if(!o)return e({loadStatus:"error",report:l,errors:l.schemaErrors}),!1;const u=new MT(o.timeline),h=Math.max(0,u.length-1),f=Math.max(0,Math.min(h,c.active)),p={enabled:c.compare.enabled,from:Math.max(0,Math.min(h,c.compare.from)),to:Math.max(0,Math.min(h,c.compare.to))},m=o.elements.some(v=>v.id===c.selectedElementId)?c.selectedElementId:null;e({diagram:o,timeline:u,report:l,masterLayout:null,errors:l.schemaErrors,active:f,selectedElementId:m,compare:p});try{const v=await iO(o,"DOWN");return a().diagram!==o||e({masterLayout:v,loadStatus:"ready"}),!0}catch(v){return a().diagram!==o||e({loadStatus:"error",errors:[String(v)]}),!1}},setActive:i=>{const{timeline:c}=a();e({active:c?c.clamp(i):0})},stepActive:i=>{const{active:c,timeline:o}=a();e({active:o?o.clamp(c+i):0})},setView:i=>e({view:i}),selectElement:i=>e({selectedElementId:i}),setCompare:i=>e(c=>{const o={...c.compare,...i},l=c.timeline?Math.max(0,c.timeline.length-1):0,u=h=>Math.max(0,Math.min(l,h));return i.enabled&&!c.compare.enabled&&o.from===0&&o.to===0&&(o.from=0,o.to=l),o.from=u(o.from),o.to=u(o.to),{compare:o}}),toggleFilterValue:(i,c)=>e(o=>{if(!o.diagram)return{};const l=Io(o.diagram).find(g=>g.name===i);if(!l)return{};const u=QI(l),h=o.filter[i]??u,f=h.includes(c)?h.filter(g=>g!==c):[...h,c],p={...o.filter};return f.length===u.length?delete p[i]:p[i]=f,{filter:p}}),resetFilterProperty:i=>e(c=>{const o={...c.filter};return delete o[i],{filter:o}}),clearFilterProperty:i=>e(c=>({filter:{...c.filter,[i]:[]}})),clearFilter:()=>e({filter:{}}),setColorProperty:i=>e({colorProperty:i})}));function wt(e){if(typeof e=="string"||typeof e=="number")return""+e;let a="";if(Array.isArray(e))for(let i=0,c;i<e.length;i++)(c=wt(e[i]))!==""&&(a+=(a&&" ")+c);else for(let i in e)e[i]&&(a+=(a&&" ")+i);return a}var p$={value:()=>{}};function lz(){for(var e=0,a=arguments.length,i={},c;e<a;++e){if(!(c=arguments[e]+"")||c in i||/[\s.]/.test(c))throw new Error("illegal type: "+c);i[c]=[]}return new jd(i)}function jd(e){this._=e}function k$(e,a){return e.trim().split(/^|\s+/).map(function(i){var c="",o=i.indexOf(".");if(o>=0&&(c=i.slice(o+1),i=i.slice(0,o)),i&&!a.hasOwnProperty(i))throw new Error("unknown type: "+i);return{type:i,name:c}})}jd.prototype=lz.prototype={constructor:jd,on:function(e,a){var i=this._,c=k$(e+"",i),o,l=-1,u=c.length;if(arguments.length<2){for(;++l<u;)if((o=(e=c[l]).type)&&(o=m$(i[o],e.name)))return o;return}if(a!=null&&typeof a!="function")throw new Error("invalid callback: "+a);for(;++l<u;)if(o=(e=c[l]).type)i[o]=cO(i[o],e.name,a);else if(a==null)for(o in i)i[o]=cO(i[o],e.name,null);return this},copy:function(){var e={},a=this._;for(var i in a)e[i]=a[i].slice();return new jd(e)},call:function(e,a){if((o=arguments.length-2)>0)for(var i=new Array(o),c=0,o,l;c<o;++c)i[c]=arguments[c+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],c=0,o=l.length;c<o;++c)l[c].value.apply(a,i)},apply:function(e,a,i){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var c=this._[e],o=0,l=c.length;o<l;++o)c[o].value.apply(a,i)}};function m$(e,a){for(var i=0,c=e.length,o;i<c;++i)if((o=e[i]).name===a)return o.value}function cO(e,a,i){for(var c=0,o=e.length;c<o;++c)if(e[c].name===a){e[c]=p$,e=e.slice(0,c).concat(e.slice(c+1));break}return i!=null&&e.push({name:a,value:i}),e}var qT="http://www.w3.org/1999/xhtml";const rO={svg:"http://www.w3.org/2000/svg",xhtml:qT,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function sz(e){var a=e+="",i=a.indexOf(":");return i>=0&&(a=e.slice(0,i))!=="xmlns"&&(e=e.slice(i+1)),rO.hasOwnProperty(a)?{space:rO[a],local:e}:e}function g$(e){return function(){var a=this.ownerDocument,i=this.namespaceURI;return i===qT&&a.documentElement.namespaceURI===qT?a.createElement(e):a.createElementNS(i,e)}}function v$(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function wB(e){var a=sz(e);return(a.local?v$:g$)(a)}function M$(){}function uH(e){return e==null?M$:function(){return this.querySelector(e)}}function x$(e){typeof e!="function"&&(e=uH(e));for(var a=this._groups,i=a.length,c=new Array(i),o=0;o<i;++o)for(var l=a[o],u=l.length,h=c[o]=new Array(u),f,p,g=0;g<u;++g)(f=l[g])&&(p=e.call(f,f.__data__,g,l))&&("__data__"in f&&(p.__data__=f.__data__),h[g]=p);return new oa(c,this._parents)}function w$(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function b$(){return[]}function bB(e){return e==null?b$:function(){return this.querySelectorAll(e)}}function L$(e){return function(){return w$(e.apply(this,arguments))}}function S$(e){typeof e=="function"?e=L$(e):e=bB(e);for(var a=this._groups,i=a.length,c=[],o=[],l=0;l<i;++l)for(var u=a[l],h=u.length,f,p=0;p<h;++p)(f=u[p])&&(c.push(e.call(f,f.__data__,p,u)),o.push(f));return new oa(c,o)}function LB(e){return function(){return this.matches(e)}}function SB(e){return function(a){return a.matches(e)}}var C$=Array.prototype.find;function A$(e){return function(){return C$.call(this.children,e)}}function I$(){return this.firstElementChild}function z$(e){return this.select(e==null?I$:A$(typeof e=="function"?e:SB(e)))}var q$=Array.prototype.filter;function _$(){return Array.from(this.children)}function T$(e){return function(){return q$.call(this.children,e)}}function H$(e){return this.selectAll(e==null?_$:T$(typeof e=="function"?e:SB(e)))}function j$(e){typeof e!="function"&&(e=LB(e));for(var a=this._groups,i=a.length,c=new Array(i),o=0;o<i;++o)for(var l=a[o],u=l.length,h=c[o]=[],f,p=0;p<u;++p)(f=l[p])&&e.call(f,f.__data__,p,l)&&h.push(f);return new oa(c,this._parents)}function CB(e){return new Array(e.length)}function E$(){return new oa(this._enter||this._groups.map(CB),this._parents)}function RI(e,a){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=a}RI.prototype={constructor:RI,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,a){return this._parent.insertBefore(e,a)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function N$(e){return function(){return e}}function D$(e,a,i,c,o,l){for(var u=0,h,f=a.length,p=l.length;u<p;++u)(h=a[u])?(h.__data__=l[u],c[u]=h):i[u]=new RI(e,l[u]);for(;u<f;++u)(h=a[u])&&(o[u]=h)}function O$(e,a,i,c,o,l,u){var h,f,p=new Map,g=a.length,m=l.length,v=new Array(g),M;for(h=0;h<g;++h)(f=a[h])&&(v[h]=M=u.call(f,f.__data__,h,a)+"",p.has(M)?o[h]=f:p.set(M,f));for(h=0;h<m;++h)M=u.call(e,l[h],h,l)+"",(f=p.get(M))?(c[h]=f,f.__data__=l[h],p.delete(M)):i[h]=new RI(e,l[h]);for(h=0;h<g;++h)(f=a[h])&&p.get(v[h])===f&&(o[h]=f)}function V$(e){return e.__data__}function B$(e,a){if(!arguments.length)return Array.from(this,V$);var i=a?O$:D$,c=this._parents,o=this._groups;typeof e!="function"&&(e=N$(e));for(var l=o.length,u=new Array(l),h=new Array(l),f=new Array(l),p=0;p<l;++p){var g=c[p],m=o[p],v=m.length,M=R$(e.call(g,g&&g.__data__,p,c)),b=M.length,w=h[p]=new Array(b),L=u[p]=new Array(b),S=f[p]=new Array(v);i(g,m,w,L,S,M,a);for(var q=0,C=0,z,H;q<b;++q)if(z=w[q]){for(q>=C&&(C=q+1);!(H=L[C])&&++C<b;);z._next=H||null}}return u=new oa(u,c),u._enter=h,u._exit=f,u}function R$(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function U$(){return new oa(this._exit||this._groups.map(CB),this._parents)}function P$(e,a,i){var c=this.enter(),o=this,l=this.exit();return typeof e=="function"?(c=e(c),c&&(c=c.selection())):c=c.append(e+""),a!=null&&(o=a(o),o&&(o=o.selection())),i==null?l.remove():i(l),c&&o?c.merge(o).order():o}function F$(e){for(var a=e.selection?e.selection():e,i=this._groups,c=a._groups,o=i.length,l=c.length,u=Math.min(o,l),h=new Array(o),f=0;f<u;++f)for(var p=i[f],g=c[f],m=p.length,v=h[f]=new Array(m),M,b=0;b<m;++b)(M=p[b]||g[b])&&(v[b]=M);for(;f<o;++f)h[f]=i[f];return new oa(h,this._parents)}function Z$(){for(var e=this._groups,a=-1,i=e.length;++a<i;)for(var c=e[a],o=c.length-1,l=c[o],u;--o>=0;)(u=c[o])&&(l&&u.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(u,l),l=u);return this}function G$(e){e||(e=$$);function a(m,v){return m&&v?e(m.__data__,v.__data__):!m-!v}for(var i=this._groups,c=i.length,o=new Array(c),l=0;l<c;++l){for(var u=i[l],h=u.length,f=o[l]=new Array(h),p,g=0;g<h;++g)(p=u[g])&&(f[g]=p);f.sort(a)}return new oa(o,this._parents).order()}function $$(e,a){return e<a?-1:e>a?1:e>=a?0:NaN}function X$(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Y$(){return Array.from(this)}function K$(){for(var e=this._groups,a=0,i=e.length;a<i;++a)for(var c=e[a],o=0,l=c.length;o<l;++o){var u=c[o];if(u)return u}return null}function Q$(){let e=0;for(const a of this)++e;return e}function W$(){return!this.node()}function J$(e){for(var a=this._groups,i=0,c=a.length;i<c;++i)for(var o=a[i],l=0,u=o.length,h;l<u;++l)(h=o[l])&&e.call(h,h.__data__,l,o);return this}function eX(e){return function(){this.removeAttribute(e)}}function tX(e){return function(){this.removeAttributeNS(e.space,e.local)}}function aX(e,a){return function(){this.setAttribute(e,a)}}function nX(e,a){return function(){this.setAttributeNS(e.space,e.local,a)}}function iX(e,a){return function(){var i=a.apply(this,arguments);i==null?this.removeAttribute(e):this.setAttribute(e,i)}}function cX(e,a){return function(){var i=a.apply(this,arguments);i==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,i)}}function rX(e,a){var i=sz(e);if(arguments.length<2){var c=this.node();return i.local?c.getAttributeNS(i.space,i.local):c.getAttribute(i)}return this.each((a==null?i.local?tX:eX:typeof a=="function"?i.local?cX:iX:i.local?nX:aX)(i,a))}function AB(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function oX(e){return function(){this.style.removeProperty(e)}}function lX(e,a,i){return function(){this.style.setProperty(e,a,i)}}function sX(e,a,i){return function(){var c=a.apply(this,arguments);c==null?this.style.removeProperty(e):this.style.setProperty(e,c,i)}}function dX(e,a,i){return arguments.length>1?this.each((a==null?oX:typeof a=="function"?sX:lX)(e,a,i??"")):Gl(this.node(),e)}function Gl(e,a){return e.style.getPropertyValue(a)||AB(e).getComputedStyle(e,null).getPropertyValue(a)}function uX(e){return function(){delete this[e]}}function hX(e,a){return function(){this[e]=a}}function yX(e,a){return function(){var i=a.apply(this,arguments);i==null?delete this[e]:this[e]=i}}function fX(e,a){return arguments.length>1?this.each((a==null?uX:typeof a=="function"?yX:hX)(e,a)):this.node()[e]}function IB(e){return e.trim().split(/^|\s+/)}function hH(e){return e.classList||new zB(e)}function zB(e){this._node=e,this._names=IB(e.getAttribute("class")||"")}zB.prototype={add:function(e){var a=this._names.indexOf(e);a<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var a=this._names.indexOf(e);a>=0&&(this._names.splice(a,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function qB(e,a){for(var i=hH(e),c=-1,o=a.length;++c<o;)i.add(a[c])}function _B(e,a){for(var i=hH(e),c=-1,o=a.length;++c<o;)i.remove(a[c])}function pX(e){return function(){qB(this,e)}}function kX(e){return function(){_B(this,e)}}function mX(e,a){return function(){(a.apply(this,arguments)?qB:_B)(this,e)}}function gX(e,a){var i=IB(e+"");if(arguments.length<2){for(var c=hH(this.node()),o=-1,l=i.length;++o<l;)if(!c.contains(i[o]))return!1;return!0}return this.each((typeof a=="function"?mX:a?pX:kX)(i,a))}function vX(){this.textContent=""}function MX(e){return function(){this.textContent=e}}function xX(e){return function(){var a=e.apply(this,arguments);this.textContent=a??""}}function wX(e){return arguments.length?this.each(e==null?vX:(typeof e=="function"?xX:MX)(e)):this.node().textContent}function bX(){this.innerHTML=""}function LX(e){return function(){this.innerHTML=e}}function SX(e){return function(){var a=e.apply(this,arguments);this.innerHTML=a??""}}function CX(e){return arguments.length?this.each(e==null?bX:(typeof e=="function"?SX:LX)(e)):this.node().innerHTML}function AX(){this.nextSibling&&this.parentNode.appendChild(this)}function IX(){return this.each(AX)}function zX(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function qX(){return this.each(zX)}function _X(e){var a=typeof e=="function"?e:wB(e);return this.select(function(){return this.appendChild(a.apply(this,arguments))})}function TX(){return null}function HX(e,a){var i=typeof e=="function"?e:wB(e),c=a==null?TX:typeof a=="function"?a:uH(a);return this.select(function(){return this.insertBefore(i.apply(this,arguments),c.apply(this,arguments)||null)})}function jX(){var e=this.parentNode;e&&e.removeChild(this)}function EX(){return this.each(jX)}function NX(){var e=this.cloneNode(!1),a=this.parentNode;return a?a.insertBefore(e,this.nextSibling):e}function DX(){var e=this.cloneNode(!0),a=this.parentNode;return a?a.insertBefore(e,this.nextSibling):e}function OX(e){return this.select(e?DX:NX)}function VX(e){return arguments.length?this.property("__data__",e):this.node().__data__}function BX(e){return function(a){e.call(this,a,this.__data__)}}function RX(e){return e.trim().split(/^|\s+/).map(function(a){var i="",c=a.indexOf(".");return c>=0&&(i=a.slice(c+1),a=a.slice(0,c)),{type:a,name:i}})}function UX(e){return function(){var a=this.__on;if(a){for(var i=0,c=-1,o=a.length,l;i<o;++i)l=a[i],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):a[++c]=l;++c?a.length=c:delete this.__on}}}function PX(e,a,i){return function(){var c=this.__on,o,l=BX(a);if(c){for(var u=0,h=c.length;u<h;++u)if((o=c[u]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=l,o.options=i),o.value=a;return}}this.addEventListener(e.type,l,i),o={type:e.type,name:e.name,value:a,listener:l,options:i},c?c.push(o):this.__on=[o]}}function FX(e,a,i){var c=RX(e+""),o,l=c.length,u;if(arguments.length<2){var h=this.node().__on;if(h){for(var f=0,p=h.length,g;f<p;++f)for(o=0,g=h[f];o<l;++o)if((u=c[o]).type===g.type&&u.name===g.name)return g.value}return}for(h=a?PX:UX,o=0;o<l;++o)this.each(h(c[o],a,i));return this}function TB(e,a,i){var c=AB(e),o=c.CustomEvent;typeof o=="function"?o=new o(a,i):(o=c.document.createEvent("Event"),i?(o.initEvent(a,i.bubbles,i.cancelable),o.detail=i.detail):o.initEvent(a,!1,!1)),e.dispatchEvent(o)}function ZX(e,a){return function(){return TB(this,e,a)}}function GX(e,a){return function(){return TB(this,e,a.apply(this,arguments))}}function $X(e,a){return this.each((typeof a=="function"?GX:ZX)(e,a))}function*XX(){for(var e=this._groups,a=0,i=e.length;a<i;++a)for(var c=e[a],o=0,l=c.length,u;o<l;++o)(u=c[o])&&(yield u)}var HB=[null];function oa(e,a){this._groups=e,this._parents=a}function B2(){return new oa([[document.documentElement]],HB)}function YX(){return this}oa.prototype=B2.prototype={constructor:oa,select:x$,selectAll:S$,selectChild:z$,selectChildren:H$,filter:j$,data:B$,enter:E$,exit:U$,join:P$,merge:F$,selection:YX,order:Z$,sort:G$,call:X$,nodes:Y$,node:K$,size:Q$,empty:W$,each:J$,attr:rX,style:dX,property:fX,classed:gX,text:wX,html:CX,raise:IX,lower:qX,append:_X,insert:HX,remove:EX,clone:OX,datum:VX,on:FX,dispatch:$X,[Symbol.iterator]:XX};function ra(e){return typeof e=="string"?new oa([[document.querySelector(e)]],[document.documentElement]):new oa([[e]],HB)}function KX(e){let a;for(;a=e.sourceEvent;)e=a;return e}function Ia(e,a){if(e=KX(e),a===void 0&&(a=e.currentTarget),a){var i=a.ownerSVGElement||a;if(i.createSVGPoint){var c=i.createSVGPoint();return c.x=e.clientX,c.y=e.clientY,c=c.matrixTransform(a.getScreenCTM().inverse()),[c.x,c.y]}if(a.getBoundingClientRect){var o=a.getBoundingClientRect();return[e.clientX-o.left-a.clientLeft,e.clientY-o.top-a.clientTop]}}return[e.pageX,e.pageY]}const QX={passive:!1},b2={capture:!0,passive:!1};function eT(e){e.stopImmediatePropagation()}function jl(e){e.preventDefault(),e.stopImmediatePropagation()}function jB(e){var a=e.document.documentElement,i=ra(e).on("dragstart.drag",jl,b2);"onselectstart"in a?i.on("selectstart.drag",jl,b2):(a.__noselect=a.style.MozUserSelect,a.style.MozUserSelect="none")}function EB(e,a){var i=e.document.documentElement,c=ra(e).on("dragstart.drag",null);a&&(c.on("click.drag",jl,b2),setTimeout(function(){c.on("click.drag",null)},0)),"onselectstart"in i?c.on("selectstart.drag",null):(i.style.MozUserSelect=i.__noselect,delete i.__noselect)}const xd=e=>()=>e;function _T(e,{sourceEvent:a,subject:i,target:c,identifier:o,active:l,x:u,y:h,dx:f,dy:p,dispatch:g}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:a,enumerable:!0,configurable:!0},subject:{value:i,enumerable:!0,configurable:!0},target:{value:c,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:h,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:g}})}_T.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function WX(e){return!e.ctrlKey&&!e.button}function JX(){return this.parentNode}function eY(e,a){return a??{x:e.x,y:e.y}}function tY(){return navigator.maxTouchPoints||"ontouchstart"in this}function NB(){var e=WX,a=JX,i=eY,c=tY,o={},l=lz("start","drag","end"),u=0,h,f,p,g,m=0;function v(z){z.on("mousedown.drag",M).filter(c).on("touchstart.drag",L).on("touchmove.drag",S,QX).on("touchend.drag touchcancel.drag",q).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function M(z,H){if(!(g||!e.call(this,z,H))){var N=C(this,a.call(this,z,H),z,H,"mouse");N&&(ra(z.view).on("mousemove.drag",b,b2).on("mouseup.drag",w,b2),jB(z.view),eT(z),p=!1,h=z.clientX,f=z.clientY,N("start",z))}}function b(z){if(jl(z),!p){var H=z.clientX-h,N=z.clientY-f;p=H*H+N*N>m}o.mouse("drag",z)}function w(z){ra(z.view).on("mousemove.drag mouseup.drag",null),EB(z.view,p),jl(z),o.mouse("end",z)}function L(z,H){if(e.call(this,z,H)){var N=z.changedTouches,E=a.call(this,z,H),R=N.length,O,ae;for(O=0;O<R;++O)(ae=C(this,E,z,H,N[O].identifier,N[O]))&&(eT(z),ae("start",z,N[O]))}}function S(z){var H=z.changedTouches,N=H.length,E,R;for(E=0;E<N;++E)(R=o[H[E].identifier])&&(jl(z),R("drag",z,H[E]))}function q(z){var H=z.changedTouches,N=H.length,E,R;for(g&&clearTimeout(g),g=setTimeout(function(){g=null},500),E=0;E<N;++E)(R=o[H[E].identifier])&&(eT(z),R("end",z,H[E]))}function C(z,H,N,E,R,O){var ae=l.copy(),G=Ia(O||N,H),Z,ne,j;if((j=i.call(z,new _T("beforestart",{sourceEvent:N,target:v,identifier:R,active:u,x:G[0],y:G[1],dx:0,dy:0,dispatch:ae}),E))!=null)return Z=j.x-G[0]||0,ne=j.y-G[1]||0,function X(T,V,U){var F=G,J;switch(T){case"start":o[R]=X,J=u++;break;case"end":delete o[R],--u;case"drag":G=Ia(U||V,H),J=u;break}ae.call(T,z,new _T(T,{sourceEvent:V,subject:j,target:v,identifier:R,active:J,x:G[0]+Z,y:G[1]+ne,dx:G[0]-F[0],dy:G[1]-F[1],dispatch:ae}),E)}}return v.filter=function(z){return arguments.length?(e=typeof z=="function"?z:xd(!!z),v):e},v.container=function(z){return arguments.length?(a=typeof z=="function"?z:xd(z),v):a},v.subject=function(z){return arguments.length?(i=typeof z=="function"?z:xd(z),v):i},v.touchable=function(z){return arguments.length?(c=typeof z=="function"?z:xd(!!z),v):c},v.on=function(){var z=l.on.apply(l,arguments);return z===l?v:z},v.clickDistance=function(z){return arguments.length?(m=(z=+z)*z,v):Math.sqrt(m)},v}function yH(e,a,i){e.prototype=a.prototype=i,i.constructor=e}function DB(e,a){var i=Object.create(e.prototype);for(var c in a)i[c]=a[c];return i}function R2(){}var L2=.7,UI=1/L2,El="\\s*([+-]?\\d+)\\s*",S2="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Za="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",aY=/^#([0-9a-f]{3,8})$/,nY=new RegExp(`^rgb\\(${El},${El},${El}\\)$`),iY=new RegExp(`^rgb\\(${Za},${Za},${Za}\\)$`),cY=new RegExp(`^rgba\\(${El},${El},${El},${S2}\\)$`),rY=new RegExp(`^rgba\\(${Za},${Za},${Za},${S2}\\)$`),oY=new RegExp(`^hsl\\(${S2},${Za},${Za}\\)$`),lY=new RegExp(`^hsla\\(${S2},${Za},${Za},${S2}\\)$`),oO={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};yH(R2,qo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:lO,formatHex:lO,formatHex8:sY,formatHsl:dY,formatRgb:sO,toString:sO});function lO(){return this.rgb().formatHex()}function sY(){return this.rgb().formatHex8()}function dY(){return OB(this).formatHsl()}function sO(){return this.rgb().formatRgb()}function qo(e){var a,i;return e=(e+"").trim().toLowerCase(),(a=aY.exec(e))?(i=a[1].length,a=parseInt(a[1],16),i===6?dO(a):i===3?new Kt(a>>8&15|a>>4&240,a>>4&15|a&240,(a&15)<<4|a&15,1):i===8?wd(a>>24&255,a>>16&255,a>>8&255,(a&255)/255):i===4?wd(a>>12&15|a>>8&240,a>>8&15|a>>4&240,a>>4&15|a&240,((a&15)<<4|a&15)/255):null):(a=nY.exec(e))?new Kt(a[1],a[2],a[3],1):(a=iY.exec(e))?new Kt(a[1]*255/100,a[2]*255/100,a[3]*255/100,1):(a=cY.exec(e))?wd(a[1],a[2],a[3],a[4]):(a=rY.exec(e))?wd(a[1]*255/100,a[2]*255/100,a[3]*255/100,a[4]):(a=oY.exec(e))?yO(a[1],a[2]/100,a[3]/100,1):(a=lY.exec(e))?yO(a[1],a[2]/100,a[3]/100,a[4]):oO.hasOwnProperty(e)?dO(oO[e]):e==="transparent"?new Kt(NaN,NaN,NaN,0):null}function dO(e){return new Kt(e>>16&255,e>>8&255,e&255,1)}function wd(e,a,i,c){return c<=0&&(e=a=i=NaN),new Kt(e,a,i,c)}function uY(e){return e instanceof R2||(e=qo(e)),e?(e=e.rgb(),new Kt(e.r,e.g,e.b,e.opacity)):new Kt}function TT(e,a,i,c){return arguments.length===1?uY(e):new Kt(e,a,i,c??1)}function Kt(e,a,i,c){this.r=+e,this.g=+a,this.b=+i,this.opacity=+c}yH(Kt,TT,DB(R2,{brighter(e){return e=e==null?UI:Math.pow(UI,e),new Kt(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?L2:Math.pow(L2,e),new Kt(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Kt(Lo(this.r),Lo(this.g),Lo(this.b),PI(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:uO,formatHex:uO,formatHex8:hY,formatRgb:hO,toString:hO}));function uO(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}`}function hY(){return`#${bo(this.r)}${bo(this.g)}${bo(this.b)}${bo((isNaN(this.opacity)?1:this.opacity)*255)}`}function hO(){const e=PI(this.opacity);return`${e===1?"rgb(":"rgba("}${Lo(this.r)}, ${Lo(this.g)}, ${Lo(this.b)}${e===1?")":`, ${e})`}`}function PI(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Lo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function bo(e){return e=Lo(e),(e<16?"0":"")+e.toString(16)}function yO(e,a,i,c){return c<=0?e=a=i=NaN:i<=0||i>=1?e=a=NaN:a<=0&&(e=NaN),new za(e,a,i,c)}function OB(e){if(e instanceof za)return new za(e.h,e.s,e.l,e.opacity);if(e instanceof R2||(e=qo(e)),!e)return new za;if(e instanceof za)return e;e=e.rgb();var a=e.r/255,i=e.g/255,c=e.b/255,o=Math.min(a,i,c),l=Math.max(a,i,c),u=NaN,h=l-o,f=(l+o)/2;return h?(a===l?u=(i-c)/h+(i<c)*6:i===l?u=(c-a)/h+2:u=(a-i)/h+4,h/=f<.5?l+o:2-l-o,u*=60):h=f>0&&f<1?0:u,new za(u,h,f,e.opacity)}function yY(e,a,i,c){return arguments.length===1?OB(e):new za(e,a,i,c??1)}function za(e,a,i,c){this.h=+e,this.s=+a,this.l=+i,this.opacity=+c}yH(za,yY,DB(R2,{brighter(e){return e=e==null?UI:Math.pow(UI,e),new za(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?L2:Math.pow(L2,e),new za(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,a=isNaN(e)||isNaN(this.s)?0:this.s,i=this.l,c=i+(i<.5?i:1-i)*a,o=2*i-c;return new Kt(tT(e>=240?e-240:e+120,o,c),tT(e,o,c),tT(e<120?e+240:e-120,o,c),this.opacity)},clamp(){return new za(fO(this.h),bd(this.s),bd(this.l),PI(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=PI(this.opacity);return`${e===1?"hsl(":"hsla("}${fO(this.h)}, ${bd(this.s)*100}%, ${bd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fO(e){return e=(e||0)%360,e<0?e+360:e}function bd(e){return Math.max(0,Math.min(1,e||0))}function tT(e,a,i){return(e<60?a+(i-a)*e/60:e<180?i:e<240?a+(i-a)*(240-e)/60:a)*255}const fH=e=>()=>e;function fY(e,a){return function(i){return e+i*a}}function pY(e,a,i){return e=Math.pow(e,i),a=Math.pow(a,i)-e,i=1/i,function(c){return Math.pow(e+c*a,i)}}function kY(e){return(e=+e)==1?VB:function(a,i){return i-a?pY(a,i,e):fH(isNaN(a)?i:a)}}function VB(e,a){var i=a-e;return i?fY(e,i):fH(isNaN(e)?a:e)}const FI=(function e(a){var i=kY(a);function c(o,l){var u=i((o=TT(o)).r,(l=TT(l)).r),h=i(o.g,l.g),f=i(o.b,l.b),p=VB(o.opacity,l.opacity);return function(g){return o.r=u(g),o.g=h(g),o.b=f(g),o.opacity=p(g),o+""}}return c.gamma=e,c})(1);function mY(e,a){a||(a=[]);var i=e?Math.min(a.length,e.length):0,c=a.slice(),o;return function(l){for(o=0;o<i;++o)c[o]=e[o]*(1-l)+a[o]*l;return c}}function gY(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vY(e,a){var i=a?a.length:0,c=e?Math.min(i,e.length):0,o=new Array(c),l=new Array(i),u;for(u=0;u<c;++u)o[u]=y2(e[u],a[u]);for(;u<i;++u)l[u]=a[u];return function(h){for(u=0;u<c;++u)l[u]=o[u](h);return l}}function MY(e,a){var i=new Date;return e=+e,a=+a,function(c){return i.setTime(e*(1-c)+a*c),i}}function Ua(e,a){return e=+e,a=+a,function(i){return e*(1-i)+a*i}}function xY(e,a){var i={},c={},o;(e===null||typeof e!="object")&&(e={}),(a===null||typeof a!="object")&&(a={});for(o in a)o in e?i[o]=y2(e[o],a[o]):c[o]=a[o];return function(l){for(o in i)c[o]=i[o](l);return c}}var HT=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,aT=new RegExp(HT.source,"g");function wY(e){return function(){return e}}function bY(e){return function(a){return e(a)+""}}function BB(e,a){var i=HT.lastIndex=aT.lastIndex=0,c,o,l,u=-1,h=[],f=[];for(e=e+"",a=a+"";(c=HT.exec(e))&&(o=aT.exec(a));)(l=o.index)>i&&(l=a.slice(i,l),h[u]?h[u]+=l:h[++u]=l),(c=c[0])===(o=o[0])?h[u]?h[u]+=o:h[++u]=o:(h[++u]=null,f.push({i:u,x:Ua(c,o)})),i=aT.lastIndex;return i<a.length&&(l=a.slice(i),h[u]?h[u]+=l:h[++u]=l),h.length<2?f[0]?bY(f[0].x):wY(a):(a=f.length,function(p){for(var g=0,m;g<a;++g)h[(m=f[g]).i]=m.x(p);return h.join("")})}function y2(e,a){var i=typeof a,c;return a==null||i==="boolean"?fH(a):(i==="number"?Ua:i==="string"?(c=qo(a))?(a=c,FI):BB:a instanceof qo?FI:a instanceof Date?MY:gY(a)?mY:Array.isArray(a)?vY:typeof a.valueOf!="function"&&typeof a.toString!="function"||isNaN(a)?xY:Ua)(e,a)}var pO=180/Math.PI,jT={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function RB(e,a,i,c,o,l){var u,h,f;return(u=Math.sqrt(e*e+a*a))&&(e/=u,a/=u),(f=e*i+a*c)&&(i-=e*f,c-=a*f),(h=Math.sqrt(i*i+c*c))&&(i/=h,c/=h,f/=h),e*c<a*i&&(e=-e,a=-a,f=-f,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(a,e)*pO,skewX:Math.atan(f)*pO,scaleX:u,scaleY:h}}var Ld;function LY(e){const a=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return a.isIdentity?jT:RB(a.a,a.b,a.c,a.d,a.e,a.f)}function SY(e){return e==null||(Ld||(Ld=document.createElementNS("http://www.w3.org/2000/svg","g")),Ld.setAttribute("transform",e),!(e=Ld.transform.baseVal.consolidate()))?jT:(e=e.matrix,RB(e.a,e.b,e.c,e.d,e.e,e.f))}function UB(e,a,i,c){function o(p){return p.length?p.pop()+" ":""}function l(p,g,m,v,M,b){if(p!==m||g!==v){var w=M.push("translate(",null,a,null,i);b.push({i:w-4,x:Ua(p,m)},{i:w-2,x:Ua(g,v)})}else(m||v)&&M.push("translate("+m+a+v+i)}function u(p,g,m,v){p!==g?(p-g>180?g+=360:g-p>180&&(p+=360),v.push({i:m.push(o(m)+"rotate(",null,c)-2,x:Ua(p,g)})):g&&m.push(o(m)+"rotate("+g+c)}function h(p,g,m,v){p!==g?v.push({i:m.push(o(m)+"skewX(",null,c)-2,x:Ua(p,g)}):g&&m.push(o(m)+"skewX("+g+c)}function f(p,g,m,v,M,b){if(p!==m||g!==v){var w=M.push(o(M)+"scale(",null,",",null,")");b.push({i:w-4,x:Ua(p,m)},{i:w-2,x:Ua(g,v)})}else(m!==1||v!==1)&&M.push(o(M)+"scale("+m+","+v+")")}return function(p,g){var m=[],v=[];return p=e(p),g=e(g),l(p.translateX,p.translateY,g.translateX,g.translateY,m,v),u(p.rotate,g.rotate,m,v),h(p.skewX,g.skewX,m,v),f(p.scaleX,p.scaleY,g.scaleX,g.scaleY,m,v),p=g=null,function(M){for(var b=-1,w=v.length,L;++b<w;)m[(L=v[b]).i]=L.x(M);return m.join("")}}}var CY=UB(LY,"px, ","px)","deg)"),AY=UB(SY,", ",")",")"),IY=1e-12;function kO(e){return((e=Math.exp(e))+1/e)/2}function zY(e){return((e=Math.exp(e))-1/e)/2}function qY(e){return((e=Math.exp(2*e))-1)/(e+1)}const Ed=(function e(a,i,c){function o(l,u){var h=l[0],f=l[1],p=l[2],g=u[0],m=u[1],v=u[2],M=g-h,b=m-f,w=M*M+b*b,L,S;if(w<IY)S=Math.log(v/p)/a,L=function(E){return[h+E*M,f+E*b,p*Math.exp(a*E*S)]};else{var q=Math.sqrt(w),C=(v*v-p*p+c*w)/(2*p*i*q),z=(v*v-p*p-c*w)/(2*v*i*q),H=Math.log(Math.sqrt(C*C+1)-C),N=Math.log(Math.sqrt(z*z+1)-z);S=(N-H)/a,L=function(E){var R=E*S,O=kO(H),ae=p/(i*q)*(O*qY(a*R+H)-zY(H));return[h+ae*M,f+ae*b,p*O/kO(a*R+H)]}}return L.duration=S*1e3*a/Math.SQRT2,L}return o.rho=function(l){var u=Math.max(.001,+l),h=u*u,f=h*h;return e(u,h,f)},o})(Math.SQRT2,2,4);var $l=0,s2=0,n2=0,PB=1e3,ZI,d2,GI=0,_o=0,dz=0,C2=typeof performance=="object"&&performance.now?performance:Date,FB=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function pH(){return _o||(FB(_Y),_o=C2.now()+dz)}function _Y(){_o=0}function $I(){this._call=this._time=this._next=null}$I.prototype=ZB.prototype={constructor:$I,restart:function(e,a,i){if(typeof e!="function")throw new TypeError("callback is not a function");i=(i==null?pH():+i)+(a==null?0:+a),!this._next&&d2!==this&&(d2?d2._next=this:ZI=this,d2=this),this._call=e,this._time=i,ET()},stop:function(){this._call&&(this._call=null,this._time=1/0,ET())}};function ZB(e,a,i){var c=new $I;return c.restart(e,a,i),c}function TY(){pH(),++$l;for(var e=ZI,a;e;)(a=_o-e._time)>=0&&e._call.call(void 0,a),e=e._next;--$l}function mO(){_o=(GI=C2.now())+dz,$l=s2=0;try{TY()}finally{$l=0,jY(),_o=0}}function HY(){var e=C2.now(),a=e-GI;a>PB&&(dz-=a,GI=e)}function jY(){for(var e,a=ZI,i,c=1/0;a;)a._call?(c>a._time&&(c=a._time),e=a,a=a._next):(i=a._next,a._next=null,a=e?e._next=i:ZI=i);d2=e,ET(c)}function ET(e){if(!$l){s2&&(s2=clearTimeout(s2));var a=e-_o;a>24?(e<1/0&&(s2=setTimeout(mO,e-C2.now()-dz)),n2&&(n2=clearInterval(n2))):(n2||(GI=C2.now(),n2=setInterval(HY,PB)),$l=1,FB(mO))}}function gO(e,a,i){var c=new $I;return a=a==null?0:+a,c.restart(o=>{c.stop(),e(o+a)},a,i),c}var EY=lz("start","end","cancel","interrupt"),NY=[],GB=0,vO=1,NT=2,Nd=3,MO=4,DT=5,Dd=6;function uz(e,a,i,c,o,l){var u=e.__transition;if(!u)e.__transition={};else if(i in u)return;DY(e,i,{name:a,index:c,group:o,on:EY,tween:NY,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:GB})}function kH(e,a){var i=Ha(e,a);if(i.state>GB)throw new Error("too late; already scheduled");return i}function Ka(e,a){var i=Ha(e,a);if(i.state>Nd)throw new Error("too late; already running");return i}function Ha(e,a){var i=e.__transition;if(!i||!(i=i[a]))throw new Error("transition not found");return i}function DY(e,a,i){var c=e.__transition,o;c[a]=i,i.timer=ZB(l,0,i.time);function l(p){i.state=vO,i.timer.restart(u,i.delay,i.time),i.delay<=p&&u(p-i.delay)}function u(p){var g,m,v,M;if(i.state!==vO)return f();for(g in c)if(M=c[g],M.name===i.name){if(M.state===Nd)return gO(u);M.state===MO?(M.state=Dd,M.timer.stop(),M.on.call("interrupt",e,e.__data__,M.index,M.group),delete c[g]):+g<a&&(M.state=Dd,M.timer.stop(),M.on.call("cancel",e,e.__data__,M.index,M.group),delete c[g])}if(gO(function(){i.state===Nd&&(i.state=MO,i.timer.restart(h,i.delay,i.time),h(p))}),i.state=NT,i.on.call("start",e,e.__data__,i.index,i.group),i.state===NT){for(i.state=Nd,o=new Array(v=i.tween.length),g=0,m=-1;g<v;++g)(M=i.tween[g].value.call(e,e.__data__,i.index,i.group))&&(o[++m]=M);o.length=m+1}}function h(p){for(var g=p<i.duration?i.ease.call(null,p/i.duration):(i.timer.restart(f),i.state=DT,1),m=-1,v=o.length;++m<v;)o[m].call(e,g);i.state===DT&&(i.on.call("end",e,e.__data__,i.index,i.group),f())}function f(){i.state=Dd,i.timer.stop(),delete c[a];for(var p in c)return;delete e.__transition}}function Od(e,a){var i=e.__transition,c,o,l=!0,u;if(i){a=a==null?null:a+"";for(u in i){if((c=i[u]).name!==a){l=!1;continue}o=c.state>NT&&c.state<DT,c.state=Dd,c.timer.stop(),c.on.call(o?"interrupt":"cancel",e,e.__data__,c.index,c.group),delete i[u]}l&&delete e.__transition}}function OY(e){return this.each(function(){Od(this,e)})}function VY(e,a){var i,c;return function(){var o=Ka(this,e),l=o.tween;if(l!==i){c=i=l;for(var u=0,h=c.length;u<h;++u)if(c[u].name===a){c=c.slice(),c.splice(u,1);break}}o.tween=c}}function BY(e,a,i){var c,o;if(typeof i!="function")throw new Error;return function(){var l=Ka(this,e),u=l.tween;if(u!==c){o=(c=u).slice();for(var h={name:a,value:i},f=0,p=o.length;f<p;++f)if(o[f].name===a){o[f]=h;break}f===p&&o.push(h)}l.tween=o}}function RY(e,a){var i=this._id;if(e+="",arguments.length<2){for(var c=Ha(this.node(),i).tween,o=0,l=c.length,u;o<l;++o)if((u=c[o]).name===e)return u.value;return null}return this.each((a==null?VY:BY)(i,e,a))}function mH(e,a,i){var c=e._id;return e.each(function(){var o=Ka(this,c);(o.value||(o.value={}))[a]=i.apply(this,arguments)}),function(o){return Ha(o,c).value[a]}}function $B(e,a){var i;return(typeof a=="number"?Ua:a instanceof qo?FI:(i=qo(a))?(a=i,FI):BB)(e,a)}function UY(e){return function(){this.removeAttribute(e)}}function PY(e){return function(){this.removeAttributeNS(e.space,e.local)}}function FY(e,a,i){var c,o=i+"",l;return function(){var u=this.getAttribute(e);return u===o?null:u===c?l:l=a(c=u,i)}}function ZY(e,a,i){var c,o=i+"",l;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===c?l:l=a(c=u,i)}}function GY(e,a,i){var c,o,l;return function(){var u,h=i(this),f;return h==null?void this.removeAttribute(e):(u=this.getAttribute(e),f=h+"",u===f?null:u===c&&f===o?l:(o=f,l=a(c=u,h)))}}function $Y(e,a,i){var c,o,l;return function(){var u,h=i(this),f;return h==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),f=h+"",u===f?null:u===c&&f===o?l:(o=f,l=a(c=u,h)))}}function XY(e,a){var i=sz(e),c=i==="transform"?AY:$B;return this.attrTween(e,typeof a=="function"?(i.local?$Y:GY)(i,c,mH(this,"attr."+e,a)):a==null?(i.local?PY:UY)(i):(i.local?ZY:FY)(i,c,a))}function YY(e,a){return function(i){this.setAttribute(e,a.call(this,i))}}function KY(e,a){return function(i){this.setAttributeNS(e.space,e.local,a.call(this,i))}}function QY(e,a){var i,c;function o(){var l=a.apply(this,arguments);return l!==c&&(i=(c=l)&&KY(e,l)),i}return o._value=a,o}function WY(e,a){var i,c;function o(){var l=a.apply(this,arguments);return l!==c&&(i=(c=l)&&YY(e,l)),i}return o._value=a,o}function JY(e,a){var i="attr."+e;if(arguments.length<2)return(i=this.tween(i))&&i._value;if(a==null)return this.tween(i,null);if(typeof a!="function")throw new Error;var c=sz(e);return this.tween(i,(c.local?QY:WY)(c,a))}function eK(e,a){return function(){kH(this,e).delay=+a.apply(this,arguments)}}function tK(e,a){return a=+a,function(){kH(this,e).delay=a}}function aK(e){var a=this._id;return arguments.length?this.each((typeof e=="function"?eK:tK)(a,e)):Ha(this.node(),a).delay}function nK(e,a){return function(){Ka(this,e).duration=+a.apply(this,arguments)}}function iK(e,a){return a=+a,function(){Ka(this,e).duration=a}}function cK(e){var a=this._id;return arguments.length?this.each((typeof e=="function"?nK:iK)(a,e)):Ha(this.node(),a).duration}function rK(e,a){if(typeof a!="function")throw new Error;return function(){Ka(this,e).ease=a}}function oK(e){var a=this._id;return arguments.length?this.each(rK(a,e)):Ha(this.node(),a).ease}function lK(e,a){return function(){var i=a.apply(this,arguments);if(typeof i!="function")throw new Error;Ka(this,e).ease=i}}function sK(e){if(typeof e!="function")throw new Error;return this.each(lK(this._id,e))}function dK(e){typeof e!="function"&&(e=LB(e));for(var a=this._groups,i=a.length,c=new Array(i),o=0;o<i;++o)for(var l=a[o],u=l.length,h=c[o]=[],f,p=0;p<u;++p)(f=l[p])&&e.call(f,f.__data__,p,l)&&h.push(f);return new qn(c,this._parents,this._name,this._id)}function uK(e){if(e._id!==this._id)throw new Error;for(var a=this._groups,i=e._groups,c=a.length,o=i.length,l=Math.min(c,o),u=new Array(c),h=0;h<l;++h)for(var f=a[h],p=i[h],g=f.length,m=u[h]=new Array(g),v,M=0;M<g;++M)(v=f[M]||p[M])&&(m[M]=v);for(;h<c;++h)u[h]=a[h];return new qn(u,this._parents,this._name,this._id)}function hK(e){return(e+"").trim().split(/^|\s+/).every(function(a){var i=a.indexOf(".");return i>=0&&(a=a.slice(0,i)),!a||a==="start"})}function yK(e,a,i){var c,o,l=hK(a)?kH:Ka;return function(){var u=l(this,e),h=u.on;h!==c&&(o=(c=h).copy()).on(a,i),u.on=o}}function fK(e,a){var i=this._id;return arguments.length<2?Ha(this.node(),i).on.on(e):this.each(yK(i,e,a))}function pK(e){return function(){var a=this.parentNode;for(var i in this.__transition)if(+i!==e)return;a&&a.removeChild(this)}}function kK(){return this.on("end.remove",pK(this._id))}function mK(e){var a=this._name,i=this._id;typeof e!="function"&&(e=uH(e));for(var c=this._groups,o=c.length,l=new Array(o),u=0;u<o;++u)for(var h=c[u],f=h.length,p=l[u]=new Array(f),g,m,v=0;v<f;++v)(g=h[v])&&(m=e.call(g,g.__data__,v,h))&&("__data__"in g&&(m.__data__=g.__data__),p[v]=m,uz(p[v],a,i,v,p,Ha(g,i)));return new qn(l,this._parents,a,i)}function gK(e){var a=this._name,i=this._id;typeof e!="function"&&(e=bB(e));for(var c=this._groups,o=c.length,l=[],u=[],h=0;h<o;++h)for(var f=c[h],p=f.length,g,m=0;m<p;++m)if(g=f[m]){for(var v=e.call(g,g.__data__,m,f),M,b=Ha(g,i),w=0,L=v.length;w<L;++w)(M=v[w])&&uz(M,a,i,w,v,b);l.push(v),u.push(g)}return new qn(l,u,a,i)}var vK=B2.prototype.constructor;function MK(){return new vK(this._groups,this._parents)}function xK(e,a){var i,c,o;return function(){var l=Gl(this,e),u=(this.style.removeProperty(e),Gl(this,e));return l===u?null:l===i&&u===c?o:o=a(i=l,c=u)}}function XB(e){return function(){this.style.removeProperty(e)}}function wK(e,a,i){var c,o=i+"",l;return function(){var u=Gl(this,e);return u===o?null:u===c?l:l=a(c=u,i)}}function bK(e,a,i){var c,o,l;return function(){var u=Gl(this,e),h=i(this),f=h+"";return h==null&&(f=h=(this.style.removeProperty(e),Gl(this,e))),u===f?null:u===c&&f===o?l:(o=f,l=a(c=u,h))}}function LK(e,a){var i,c,o,l="style."+a,u="end."+l,h;return function(){var f=Ka(this,e),p=f.on,g=f.value[l]==null?h||(h=XB(a)):void 0;(p!==i||o!==g)&&(c=(i=p).copy()).on(u,o=g),f.on=c}}function SK(e,a,i){var c=(e+="")=="transform"?CY:$B;return a==null?this.styleTween(e,xK(e,c)).on("end.style."+e,XB(e)):typeof a=="function"?this.styleTween(e,bK(e,c,mH(this,"style."+e,a))).each(LK(this._id,e)):this.styleTween(e,wK(e,c,a),i).on("end.style."+e,null)}function CK(e,a,i){return function(c){this.style.setProperty(e,a.call(this,c),i)}}function AK(e,a,i){var c,o;function l(){var u=a.apply(this,arguments);return u!==o&&(c=(o=u)&&CK(e,u,i)),c}return l._value=a,l}function IK(e,a,i){var c="style."+(e+="");if(arguments.length<2)return(c=this.tween(c))&&c._value;if(a==null)return this.tween(c,null);if(typeof a!="function")throw new Error;return this.tween(c,AK(e,a,i??""))}function zK(e){return function(){this.textContent=e}}function qK(e){return function(){var a=e(this);this.textContent=a??""}}function _K(e){return this.tween("text",typeof e=="function"?qK(mH(this,"text",e)):zK(e==null?"":e+""))}function TK(e){return function(a){this.textContent=e.call(this,a)}}function HK(e){var a,i;function c(){var o=e.apply(this,arguments);return o!==i&&(a=(i=o)&&TK(o)),a}return c._value=e,c}function jK(e){var a="text";if(arguments.length<1)return(a=this.tween(a))&&a._value;if(e==null)return this.tween(a,null);if(typeof e!="function")throw new Error;return this.tween(a,HK(e))}function EK(){for(var e=this._name,a=this._id,i=YB(),c=this._groups,o=c.length,l=0;l<o;++l)for(var u=c[l],h=u.length,f,p=0;p<h;++p)if(f=u[p]){var g=Ha(f,a);uz(f,e,i,p,u,{time:g.time+g.delay+g.duration,delay:0,duration:g.duration,ease:g.ease})}return new qn(c,this._parents,e,i)}function NK(){var e,a,i=this,c=i._id,o=i.size();return new Promise(function(l,u){var h={value:u},f={value:function(){--o===0&&l()}};i.each(function(){var p=Ka(this,c),g=p.on;g!==e&&(a=(e=g).copy(),a._.cancel.push(h),a._.interrupt.push(h),a._.end.push(f)),p.on=a}),o===0&&l()})}var DK=0;function qn(e,a,i,c){this._groups=e,this._parents=a,this._name=i,this._id=c}function YB(){return++DK}var wn=B2.prototype;qn.prototype={constructor:qn,select:mK,selectAll:gK,selectChild:wn.selectChild,selectChildren:wn.selectChildren,filter:dK,merge:uK,selection:MK,transition:EK,call:wn.call,nodes:wn.nodes,node:wn.node,size:wn.size,empty:wn.empty,each:wn.each,on:fK,attr:XY,attrTween:JY,style:SK,styleTween:IK,text:_K,textTween:jK,remove:kK,tween:RY,delay:aK,duration:cK,ease:oK,easeVarying:sK,end:NK,[Symbol.iterator]:wn[Symbol.iterator]};function OK(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var VK={time:null,delay:0,duration:250,ease:OK};function BK(e,a){for(var i;!(i=e.__transition)||!(i=i[a]);)if(!(e=e.parentNode))throw new Error(`transition ${a} not found`);return i}function RK(e){var a,i;e instanceof qn?(a=e._id,e=e._name):(a=YB(),(i=VK).time=pH(),e=e==null?null:e+"");for(var c=this._groups,o=c.length,l=0;l<o;++l)for(var u=c[l],h=u.length,f,p=0;p<h;++p)(f=u[p])&&uz(f,e,a,p,u,i||BK(f,a));return new qn(c,this._parents,e,a)}B2.prototype.interrupt=OY;B2.prototype.transition=RK;const Sd=e=>()=>e;function UK(e,{sourceEvent:a,target:i,transform:c,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:a,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},transform:{value:c,enumerable:!0,configurable:!0},_:{value:o}})}function Cn(e,a,i){this.k=e,this.x=a,this.y=i}Cn.prototype={constructor:Cn,scale:function(e){return e===1?this:new Cn(this.k*e,this.x,this.y)},translate:function(e,a){return e===0&a===0?this:new Cn(this.k,this.x+this.k*e,this.y+this.k*a)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var hz=new Cn(1,0,0);KB.prototype=Cn.prototype;function KB(e){for(;!e.__zoom;)if(!(e=e.parentNode))return hz;return e.__zoom}function nT(e){e.stopImmediatePropagation()}function i2(e){e.preventDefault(),e.stopImmediatePropagation()}function PK(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function FK(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function xO(){return this.__zoom||hz}function ZK(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function GK(){return navigator.maxTouchPoints||"ontouchstart"in this}function $K(e,a,i){var c=e.invertX(a[0][0])-i[0][0],o=e.invertX(a[1][0])-i[1][0],l=e.invertY(a[0][1])-i[0][1],u=e.invertY(a[1][1])-i[1][1];return e.translate(o>c?(c+o)/2:Math.min(0,c)||Math.max(0,o),u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u))}function QB(){var e=PK,a=FK,i=$K,c=ZK,o=GK,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],h=250,f=Ed,p=lz("start","zoom","end"),g,m,v,M=500,b=150,w=0,L=10;function S(j){j.property("__zoom",xO).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",ae).filter(o).on("touchstart.zoom",G).on("touchmove.zoom",Z).on("touchend.zoom touchcancel.zoom",ne).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(j,X,T,V){var U=j.selection?j.selection():j;U.property("__zoom",xO),j!==U?H(j,X,T,V):U.interrupt().each(function(){N(this,arguments).event(V).start().zoom(null,typeof X=="function"?X.apply(this,arguments):X).end()})},S.scaleBy=function(j,X,T,V){S.scaleTo(j,function(){var U=this.__zoom.k,F=typeof X=="function"?X.apply(this,arguments):X;return U*F},T,V)},S.scaleTo=function(j,X,T,V){S.transform(j,function(){var U=a.apply(this,arguments),F=this.__zoom,J=T==null?z(U):typeof T=="function"?T.apply(this,arguments):T,_=F.invert(J),B=typeof X=="function"?X.apply(this,arguments):X;return i(C(q(F,B),J,_),U,u)},T,V)},S.translateBy=function(j,X,T,V){S.transform(j,function(){return i(this.__zoom.translate(typeof X=="function"?X.apply(this,arguments):X,typeof T=="function"?T.apply(this,arguments):T),a.apply(this,arguments),u)},null,V)},S.translateTo=function(j,X,T,V,U){S.transform(j,function(){var F=a.apply(this,arguments),J=this.__zoom,_=V==null?z(F):typeof V=="function"?V.apply(this,arguments):V;return i(hz.translate(_[0],_[1]).scale(J.k).translate(typeof X=="function"?-X.apply(this,arguments):-X,typeof T=="function"?-T.apply(this,arguments):-T),F,u)},V,U)};function q(j,X){return X=Math.max(l[0],Math.min(l[1],X)),X===j.k?j:new Cn(X,j.x,j.y)}function C(j,X,T){var V=X[0]-T[0]*j.k,U=X[1]-T[1]*j.k;return V===j.x&&U===j.y?j:new Cn(j.k,V,U)}function z(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function H(j,X,T,V){j.on("start.zoom",function(){N(this,arguments).event(V).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(V).end()}).tween("zoom",function(){var U=this,F=arguments,J=N(U,F).event(V),_=a.apply(U,F),B=T==null?z(_):typeof T=="function"?T.apply(U,F):T,te=Math.max(_[1][0]-_[0][0],_[1][1]-_[0][1]),ie=U.__zoom,le=typeof X=="function"?X.apply(U,F):X,ue=f(ie.invert(B).concat(te/ie.k),le.invert(B).concat(te/le.k));return function(he){if(he===1)he=le;else{var se=ue(he),ye=te/se[2];he=new Cn(ye,B[0]-se[0]*ye,B[1]-se[1]*ye)}J.zoom(null,he)}})}function N(j,X,T){return!T&&j.__zooming||new E(j,X)}function E(j,X){this.that=j,this.args=X,this.active=0,this.sourceEvent=null,this.extent=a.apply(j,X),this.taps=0}E.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,X){return this.mouse&&j!=="mouse"&&(this.mouse[1]=X.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=X.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=X.invert(this.touch1[0])),this.that.__zoom=X,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var X=ra(this.that).datum();p.call(j,this.that,new UK(j,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:p}),X)}};function R(j,...X){if(!e.apply(this,arguments))return;var T=N(this,X).event(j),V=this.__zoom,U=Math.max(l[0],Math.min(l[1],V.k*Math.pow(2,c.apply(this,arguments)))),F=Ia(j);if(T.wheel)(T.mouse[0][0]!==F[0]||T.mouse[0][1]!==F[1])&&(T.mouse[1]=V.invert(T.mouse[0]=F)),clearTimeout(T.wheel);else{if(V.k===U)return;T.mouse=[F,V.invert(F)],Od(this),T.start()}i2(j),T.wheel=setTimeout(J,b),T.zoom("mouse",i(C(q(V,U),T.mouse[0],T.mouse[1]),T.extent,u));function J(){T.wheel=null,T.end()}}function O(j,...X){if(v||!e.apply(this,arguments))return;var T=j.currentTarget,V=N(this,X,!0).event(j),U=ra(j.view).on("mousemove.zoom",B,!0).on("mouseup.zoom",te,!0),F=Ia(j,T),J=j.clientX,_=j.clientY;jB(j.view),nT(j),V.mouse=[F,this.__zoom.invert(F)],Od(this),V.start();function B(ie){if(i2(ie),!V.moved){var le=ie.clientX-J,ue=ie.clientY-_;V.moved=le*le+ue*ue>w}V.event(ie).zoom("mouse",i(C(V.that.__zoom,V.mouse[0]=Ia(ie,T),V.mouse[1]),V.extent,u))}function te(ie){U.on("mousemove.zoom mouseup.zoom",null),EB(ie.view,V.moved),i2(ie),V.event(ie).end()}}function ae(j,...X){if(e.apply(this,arguments)){var T=this.__zoom,V=Ia(j.changedTouches?j.changedTouches[0]:j,this),U=T.invert(V),F=T.k*(j.shiftKey?.5:2),J=i(C(q(T,F),V,U),a.apply(this,X),u);i2(j),h>0?ra(this).transition().duration(h).call(H,J,V,j):ra(this).call(S.transform,J,V,j)}}function G(j,...X){if(e.apply(this,arguments)){var T=j.touches,V=T.length,U=N(this,X,j.changedTouches.length===V).event(j),F,J,_,B;for(nT(j),J=0;J<V;++J)_=T[J],B=Ia(_,this),B=[B,this.__zoom.invert(B),_.identifier],U.touch0?!U.touch1&&U.touch0[2]!==B[2]&&(U.touch1=B,U.taps=0):(U.touch0=B,F=!0,U.taps=1+!!g);g&&(g=clearTimeout(g)),F&&(U.taps<2&&(m=B[0],g=setTimeout(function(){g=null},M)),Od(this),U.start())}}function Z(j,...X){if(this.__zooming){var T=N(this,X).event(j),V=j.changedTouches,U=V.length,F,J,_,B;for(i2(j),F=0;F<U;++F)J=V[F],_=Ia(J,this),T.touch0&&T.touch0[2]===J.identifier?T.touch0[0]=_:T.touch1&&T.touch1[2]===J.identifier&&(T.touch1[0]=_);if(J=T.that.__zoom,T.touch1){var te=T.touch0[0],ie=T.touch0[1],le=T.touch1[0],ue=T.touch1[1],he=(he=le[0]-te[0])*he+(he=le[1]-te[1])*he,se=(se=ue[0]-ie[0])*se+(se=ue[1]-ie[1])*se;J=q(J,Math.sqrt(he/se)),_=[(te[0]+le[0])/2,(te[1]+le[1])/2],B=[(ie[0]+ue[0])/2,(ie[1]+ue[1])/2]}else if(T.touch0)_=T.touch0[0],B=T.touch0[1];else return;T.zoom("touch",i(C(J,_,B),T.extent,u))}}function ne(j,...X){if(this.__zooming){var T=N(this,X).event(j),V=j.changedTouches,U=V.length,F,J;for(nT(j),v&&clearTimeout(v),v=setTimeout(function(){v=null},M),F=0;F<U;++F)J=V[F],T.touch0&&T.touch0[2]===J.identifier?delete T.touch0:T.touch1&&T.touch1[2]===J.identifier&&delete T.touch1;if(T.touch1&&!T.touch0&&(T.touch0=T.touch1,delete T.touch1),T.touch0)T.touch0[1]=this.__zoom.invert(T.touch0[0]);else if(T.end(),T.taps===2&&(J=Ia(J,this),Math.hypot(m[0]-J[0],m[1]-J[1])<L)){var _=ra(this).on("dblclick.zoom");_&&_.apply(this,arguments)}}}return S.wheelDelta=function(j){return arguments.length?(c=typeof j=="function"?j:Sd(+j),S):c},S.filter=function(j){return arguments.length?(e=typeof j=="function"?j:Sd(!!j),S):e},S.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:Sd(!!j),S):o},S.extent=function(j){return arguments.length?(a=typeof j=="function"?j:Sd([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),S):a},S.scaleExtent=function(j){return arguments.length?(l[0]=+j[0],l[1]=+j[1],S):[l[0],l[1]]},S.translateExtent=function(j){return arguments.length?(u[0][0]=+j[0][0],u[1][0]=+j[1][0],u[0][1]=+j[0][1],u[1][1]=+j[1][1],S):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},S.constrain=function(j){return arguments.length?(i=j,S):i},S.duration=function(j){return arguments.length?(h=+j,S):h},S.interpolate=function(j){return arguments.length?(f=j,S):f},S.on=function(){var j=p.on.apply(p,arguments);return j===p?S:j},S.clickDistance=function(j){return arguments.length?(w=(j=+j)*j,S):Math.sqrt(w)},S.tapDistance=function(j){return arguments.length?(L=+j,S):L},S}const Ya={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:a,sourceHandle:i,targetHandle:c})=>`Couldn't create edge for ${e} handle id: "${e==="source"?i:c}", edge id: ${a}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs."},A2=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],WB=["Enter"," ","Escape"],JB={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:a,y:i})=>`Moved selected node ${e}. New position, x: ${a}, y: ${i}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Xl;(function(e){e.Strict="strict",e.Loose="loose"})(Xl||(Xl={}));var So;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(So||(So={}));var I2;(function(e){e.Partial="partial",e.Full="full"})(I2||(I2={}));const eR={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var k1;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(k1||(k1={}));var z2;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(z2||(z2={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const wO={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function tR(e){return e===null?null:e?"valid":"invalid"}const aR=e=>"id"in e&&"source"in e&&"target"in e,XK=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),gH=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),U2=(e,a=[0,0])=>{const{width:i,height:c}=_n(e),o=e.origin??a,l=i*o[0],u=c*o[1];return{x:e.position.x-l,y:e.position.y-u}},YK=(e,a={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const i=e.reduce((c,o)=>{const l=typeof o=="string";let u=!a.nodeLookup&&!l?o:void 0;a.nodeLookup&&(u=l?a.nodeLookup.get(o):gH(o)?o:a.nodeLookup.get(o.id));const h=u?XI(u,a.nodeOrigin):{x:0,y:0,x2:0,y2:0};return yz(c,h)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return fz(i)},P2=(e,a={})=>{let i={x:1/0,y:1/0,x2:-1/0,y2:-1/0},c=!1;return e.forEach(o=>{(a.filter===void 0||a.filter(o))&&(i=yz(i,XI(o)),c=!0)}),c?fz(i):{x:0,y:0,width:0,height:0}},vH=(e,a,[i,c,o]=[0,0,1],l=!1,u=!1)=>{const h={...Z2(a,[i,c,o]),width:a.width/o,height:a.height/o},f=[];for(const p of e.values()){const{measured:g,selectable:m=!0,hidden:v=!1}=p;if(u&&!m||v)continue;const M=g.width??p.width??p.initialWidth??null,b=g.height??p.height??p.initialHeight??null,w=q2(h,Kl(p)),L=(M??0)*(b??0),S=l&&w>0;(!p.internals.handleBounds||S||w>=L||p.dragging)&&f.push(p)}return f},KK=(e,a)=>{const i=new Set;return e.forEach(c=>{i.add(c.id)}),a.filter(c=>i.has(c.source)||i.has(c.target))};function QK(e,a){const i=new Map,c=a!=null&&a.nodes?new Set(a.nodes.map(o=>o.id)):null;return e.forEach(o=>{o.measured.width&&o.measured.height&&((a==null?void 0:a.includeHiddenNodes)||!o.hidden)&&(!c||c.has(o.id))&&i.set(o.id,o)}),i}async function WK({nodes:e,width:a,height:i,panZoom:c,minZoom:o,maxZoom:l},u){if(e.size===0)return Promise.resolve(!0);const h=QK(e,u),f=P2(h),p=MH(f,a,i,(u==null?void 0:u.minZoom)??o,(u==null?void 0:u.maxZoom)??l,(u==null?void 0:u.padding)??.1);return await c.setViewport(p,{duration:u==null?void 0:u.duration,ease:u==null?void 0:u.ease,interpolate:u==null?void 0:u.interpolate}),Promise.resolve(!0)}function nR({nodeId:e,nextPosition:a,nodeLookup:i,nodeOrigin:c=[0,0],nodeExtent:o,onError:l}){const u=i.get(e),h=u.parentId?i.get(u.parentId):void 0,{x:f,y:p}=h?h.internals.positionAbsolute:{x:0,y:0},g=u.origin??c;let m=u.extent||o;if(u.extent==="parent"&&!u.expandParent)if(!h)l==null||l("005",Ya.error005());else{const M=h.measured.width,b=h.measured.height;M&&b&&(m=[[f,p],[f+M,p+b]])}else h&&Ql(u.extent)&&(m=[[u.extent[0][0]+f,u.extent[0][1]+p],[u.extent[1][0]+f,u.extent[1][1]+p]]);const v=Ql(m)?To(a,m,u.measured):a;return(u.measured.width===void 0||u.measured.height===void 0)&&(l==null||l("015",Ya.error015())),{position:{x:v.x-f+(u.measured.width??0)*g[0],y:v.y-p+(u.measured.height??0)*g[1]},positionAbsolute:v}}async function JK({nodesToRemove:e=[],edgesToRemove:a=[],nodes:i,edges:c,onBeforeDelete:o}){const l=new Set(e.map(v=>v.id)),u=[];for(const v of i){if(v.deletable===!1)continue;const M=l.has(v.id),b=!M&&v.parentId&&u.find(w=>w.id===v.parentId);(M||b)&&u.push(v)}const h=new Set(a.map(v=>v.id)),f=c.filter(v=>v.deletable!==!1),g=KK(u,f);for(const v of f)h.has(v.id)&&!g.find(b=>b.id===v.id)&&g.push(v);if(!o)return{edges:g,nodes:u};const m=await o({nodes:u,edges:g});return typeof m=="boolean"?m?{edges:g,nodes:u}:{edges:[],nodes:[]}:m}const Yl=(e,a=0,i=1)=>Math.min(Math.max(e,a),i),To=(e={x:0,y:0},a,i)=>({x:Yl(e.x,a[0][0],a[1][0]-((i==null?void 0:i.width)??0)),y:Yl(e.y,a[0][1],a[1][1]-((i==null?void 0:i.height)??0))});function iR(e,a,i){const{width:c,height:o}=_n(i),{x:l,y:u}=i.internals.positionAbsolute;return To(e,[[l,u],[l+c,u+o]],a)}const bO=(e,a,i)=>e<a?Yl(Math.abs(e-a),1,a)/a:e>i?-Yl(Math.abs(e-i),1,a)/a:0,cR=(e,a,i=15,c=40)=>{const o=bO(e.x,c,a.width-c)*i,l=bO(e.y,c,a.height-c)*i;return[o,l]},yz=(e,a)=>({x:Math.min(e.x,a.x),y:Math.min(e.y,a.y),x2:Math.max(e.x2,a.x2),y2:Math.max(e.y2,a.y2)}),OT=({x:e,y:a,width:i,height:c})=>({x:e,y:a,x2:e+i,y2:a+c}),fz=({x:e,y:a,x2:i,y2:c})=>({x:e,y:a,width:i-e,height:c-a}),Kl=(e,a=[0,0])=>{var o,l;const{x:i,y:c}=gH(e)?e.internals.positionAbsolute:U2(e,a);return{x:i,y:c,width:((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0,height:((l=e.measured)==null?void 0:l.height)??e.height??e.initialHeight??0}},XI=(e,a=[0,0])=>{var o,l;const{x:i,y:c}=gH(e)?e.internals.positionAbsolute:U2(e,a);return{x:i,y:c,x2:i+(((o=e.measured)==null?void 0:o.width)??e.width??e.initialWidth??0),y2:c+(((l=e.measured)==null?void 0:l.height)??e.height??e.initialHeight??0)}},rR=(e,a)=>fz(yz(OT(e),OT(a))),q2=(e,a)=>{const i=Math.max(0,Math.min(e.x+e.width,a.x+a.width)-Math.max(e.x,a.x)),c=Math.max(0,Math.min(e.y+e.height,a.y+a.height)-Math.max(e.y,a.y));return Math.ceil(i*c)},LO=e=>qa(e.width)&&qa(e.height)&&qa(e.x)&&qa(e.y),qa=e=>!isNaN(e)&&isFinite(e),eQ=(e,a)=>{},F2=(e,a=[1,1])=>({x:a[0]*Math.round(e.x/a[0]),y:a[1]*Math.round(e.y/a[1])}),Z2=({x:e,y:a},[i,c,o],l=!1,u=[1,1])=>{const h={x:(e-i)/o,y:(a-c)/o};return l?F2(h,u):h},YI=({x:e,y:a},[i,c,o])=>({x:e*o+i,y:a*o+c});function bl(e,a){if(typeof e=="number")return Math.floor((a-a/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const i=parseFloat(e);if(!Number.isNaN(i))return Math.floor(i)}if(typeof e=="string"&&e.endsWith("%")){const i=parseFloat(e);if(!Number.isNaN(i))return Math.floor(a*i*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function tQ(e,a,i){if(typeof e=="string"||typeof e=="number"){const c=bl(e,i),o=bl(e,a);return{top:c,right:o,bottom:c,left:o,x:o*2,y:c*2}}if(typeof e=="object"){const c=bl(e.top??e.y??0,i),o=bl(e.bottom??e.y??0,i),l=bl(e.left??e.x??0,a),u=bl(e.right??e.x??0,a);return{top:c,right:u,bottom:o,left:l,x:l+u,y:c+o}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function aQ(e,a,i,c,o,l){const{x:u,y:h}=YI(e,[a,i,c]),{x:f,y:p}=YI({x:e.x+e.width,y:e.y+e.height},[a,i,c]),g=o-f,m=l-p;return{left:Math.floor(u),top:Math.floor(h),right:Math.floor(g),bottom:Math.floor(m)}}const MH=(e,a,i,c,o,l)=>{const u=tQ(l,a,i),h=(a-u.x)/e.width,f=(i-u.y)/e.height,p=Math.min(h,f),g=Yl(p,c,o),m=e.x+e.width/2,v=e.y+e.height/2,M=a/2-m*g,b=i/2-v*g,w=aQ(e,M,b,g,a,i),L={left:Math.min(w.left-u.left,0),top:Math.min(w.top-u.top,0),right:Math.min(w.right-u.right,0),bottom:Math.min(w.bottom-u.bottom,0)};return{x:M-L.left+L.right,y:b-L.top+L.bottom,zoom:g}},_2=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ql(e){return e!=null&&e!=="parent"}function _n(e){var a,i;return{width:((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}}function oR(e){var a,i;return(((a=e.measured)==null?void 0:a.width)??e.width??e.initialWidth)!==void 0&&(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight)!==void 0}function lR(e,a={width:0,height:0},i,c,o){const l={...e},u=c.get(i);if(u){const h=u.origin||o;l.x+=u.internals.positionAbsolute.x-(a.width??0)*h[0],l.y+=u.internals.positionAbsolute.y-(a.height??0)*h[1]}return l}function SO(e,a){if(e.size!==a.size)return!1;for(const i of e)if(!a.has(i))return!1;return!0}function nQ(){let e,a;return{promise:new Promise((c,o)=>{e=c,a=o}),resolve:e,reject:a}}function iQ(e){return{...JB,...e||{}}}function f2(e,{snapGrid:a=[0,0],snapToGrid:i=!1,transform:c,containerBounds:o}){const{x:l,y:u}=_a(e),h=Z2({x:l-((o==null?void 0:o.left)??0),y:u-((o==null?void 0:o.top)??0)},c),{x:f,y:p}=i?F2(h,a):h;return{xSnapped:f,ySnapped:p,...h}}const xH=e=>({width:e.offsetWidth,height:e.offsetHeight}),sR=e=>{var a;return((a=e==null?void 0:e.getRootNode)==null?void 0:a.call(e))||(window==null?void 0:window.document)},cQ=["INPUT","SELECT","TEXTAREA"];function dR(e){var c,o;const a=((o=(c=e.composedPath)==null?void 0:c.call(e))==null?void 0:o[0])||e.target;return(a==null?void 0:a.nodeType)!==1?!1:cQ.includes(a.nodeName)||a.hasAttribute("contenteditable")||!!a.closest(".nokey")}const uR=e=>"clientX"in e,_a=(e,a)=>{var l,u;const i=uR(e),c=i?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,o=i?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:c-((a==null?void 0:a.left)??0),y:o-((a==null?void 0:a.top)??0)}},CO=(e,a,i,c,o)=>{const l=a.querySelectorAll(`.${e}`);return!l||!l.length?null:Array.from(l).map(u=>{const h=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),type:e,nodeId:o,position:u.getAttribute("data-handlepos"),x:(h.left-i.left)/c,y:(h.top-i.top)/c,...xH(u)}})};function hR({sourceX:e,sourceY:a,targetX:i,targetY:c,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:h}){const f=e*.125+o*.375+u*.375+i*.125,p=a*.125+l*.375+h*.375+c*.125,g=Math.abs(f-e),m=Math.abs(p-a);return[f,p,g,m]}function Cd(e,a){return e>=0?.5*e:a*25*Math.sqrt(-e)}function AO({pos:e,x1:a,y1:i,x2:c,y2:o,c:l}){switch(e){case ve.Left:return[a-Cd(a-c,l),i];case ve.Right:return[a+Cd(c-a,l),i];case ve.Top:return[a,i-Cd(i-o,l)];case ve.Bottom:return[a,i+Cd(o-i,l)]}}function yR({sourceX:e,sourceY:a,sourcePosition:i=ve.Bottom,targetX:c,targetY:o,targetPosition:l=ve.Top,curvature:u=.25}){const[h,f]=AO({pos:i,x1:e,y1:a,x2:c,y2:o,c:u}),[p,g]=AO({pos:l,x1:c,y1:o,x2:e,y2:a,c:u}),[m,v,M,b]=hR({sourceX:e,sourceY:a,targetX:c,targetY:o,sourceControlX:h,sourceControlY:f,targetControlX:p,targetControlY:g});return[`M${e},${a} C${h},${f} ${p},${g} ${c},${o}`,m,v,M,b]}function fR({sourceX:e,sourceY:a,targetX:i,targetY:c}){const o=Math.abs(i-e)/2,l=i<e?i+o:i-o,u=Math.abs(c-a)/2,h=c<a?c+u:c-u;return[l,h,o,u]}function rQ({sourceNode:e,targetNode:a,selected:i=!1,zIndex:c=0,elevateOnSelect:o=!1,zIndexMode:l="basic"}){if(l==="manual")return c;const u=o&&i?c+1e3:c,h=Math.max(e.parentId||o&&e.selected?e.internals.z:0,a.parentId||o&&a.selected?a.internals.z:0);return u+h}function oQ({sourceNode:e,targetNode:a,width:i,height:c,transform:o}){const l=yz(XI(e),XI(a));l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const u={x:-o[0]/o[2],y:-o[1]/o[2],width:i/o[2],height:c/o[2]};return q2(u,fz(l))>0}const lQ=({source:e,sourceHandle:a,target:i,targetHandle:c})=>`xy-edge__${e}${a||""}-${i}${c||""}`,sQ=(e,a)=>a.some(i=>i.source===e.source&&i.target===e.target&&(i.sourceHandle===e.sourceHandle||!i.sourceHandle&&!e.sourceHandle)&&(i.targetHandle===e.targetHandle||!i.targetHandle&&!e.targetHandle)),dQ=(e,a,i={})=>{if(!e.source||!e.target)return a;const c=i.getEdgeId||lQ;let o;return aR(e)?o={...e}:o={...e,id:c(e)},sQ(o,a)?a:(o.sourceHandle===null&&delete o.sourceHandle,o.targetHandle===null&&delete o.targetHandle,a.concat(o))};function pR({sourceX:e,sourceY:a,targetX:i,targetY:c}){const[o,l,u,h]=fR({sourceX:e,sourceY:a,targetX:i,targetY:c});return[`M ${e},${a}L ${i},${c}`,o,l,u,h]}const IO={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},uQ=({source:e,sourcePosition:a=ve.Bottom,target:i})=>a===ve.Left||a===ve.Right?e.x<i.x?{x:1,y:0}:{x:-1,y:0}:e.y<i.y?{x:0,y:1}:{x:0,y:-1},zO=(e,a)=>Math.sqrt(Math.pow(a.x-e.x,2)+Math.pow(a.y-e.y,2));function hQ({source:e,sourcePosition:a=ve.Bottom,target:i,targetPosition:c=ve.Top,center:o,offset:l,stepPosition:u}){const h=IO[a],f=IO[c],p={x:e.x+h.x*l,y:e.y+h.y*l},g={x:i.x+f.x*l,y:i.y+f.y*l},m=uQ({source:p,sourcePosition:a,target:g}),v=m.x!==0?"x":"y",M=m[v];let b=[],w,L;const S={x:0,y:0},q={x:0,y:0},[,,C,z]=fR({sourceX:e.x,sourceY:e.y,targetX:i.x,targetY:i.y});if(h[v]*f[v]===-1){v==="x"?(w=o.x??p.x+(g.x-p.x)*u,L=o.y??(p.y+g.y)/2):(w=o.x??(p.x+g.x)/2,L=o.y??p.y+(g.y-p.y)*u);const R=[{x:w,y:p.y},{x:w,y:g.y}],O=[{x:p.x,y:L},{x:g.x,y:L}];h[v]===M?b=v==="x"?R:O:b=v==="x"?O:R}else{const R=[{x:p.x,y:g.y}],O=[{x:g.x,y:p.y}];if(v==="x"?b=h.x===M?O:R:b=h.y===M?R:O,a===c){const j=Math.abs(e[v]-i[v]);if(j<=l){const X=Math.min(l-1,l-j);h[v]===M?S[v]=(p[v]>e[v]?-1:1)*X:q[v]=(g[v]>i[v]?-1:1)*X}}if(a!==c){const j=v==="x"?"y":"x",X=h[v]===f[j],T=p[j]>g[j],V=p[j]<g[j];(h[v]===1&&(!X&&T||X&&V)||h[v]!==1&&(!X&&V||X&&T))&&(b=v==="x"?R:O)}const ae={x:p.x+S.x,y:p.y+S.y},G={x:g.x+q.x,y:g.y+q.y},Z=Math.max(Math.abs(ae.x-b[0].x),Math.abs(G.x-b[0].x)),ne=Math.max(Math.abs(ae.y-b[0].y),Math.abs(G.y-b[0].y));Z>=ne?(w=(ae.x+G.x)/2,L=b[0].y):(w=b[0].x,L=(ae.y+G.y)/2)}const H={x:p.x+S.x,y:p.y+S.y},N={x:g.x+q.x,y:g.y+q.y};return[[e,...H.x!==b[0].x||H.y!==b[0].y?[H]:[],...b,...N.x!==b[b.length-1].x||N.y!==b[b.length-1].y?[N]:[],i],w,L,C,z]}function yQ(e,a,i,c){const o=Math.min(zO(e,a)/2,zO(a,i)/2,c),{x:l,y:u}=a;if(e.x===l&&l===i.x||e.y===u&&u===i.y)return`L${l} ${u}`;if(e.y===u){const p=e.x<i.x?-1:1,g=e.y<i.y?1:-1;return`L ${l+o*p},${u}Q ${l},${u} ${l},${u+o*g}`}const h=e.x<i.x?1:-1,f=e.y<i.y?-1:1;return`L ${l},${u+o*f}Q ${l},${u} ${l+o*h},${u}`}function VT({sourceX:e,sourceY:a,sourcePosition:i=ve.Bottom,targetX:c,targetY:o,targetPosition:l=ve.Top,borderRadius:u=5,centerX:h,centerY:f,offset:p=20,stepPosition:g=.5}){const[m,v,M,b,w]=hQ({source:{x:e,y:a},sourcePosition:i,target:{x:c,y:o},targetPosition:l,center:{x:h,y:f},offset:p,stepPosition:g});let L=`M${m[0].x} ${m[0].y}`;for(let S=1;S<m.length-1;S++)L+=yQ(m[S-1],m[S],m[S+1],u);return L+=`L${m[m.length-1].x} ${m[m.length-1].y}`,[L,v,M,b,w]}function qO(e){var a;return e&&!!(e.internals.handleBounds||(a=e.handles)!=null&&a.length)&&!!(e.measured.width||e.width||e.initialWidth)}function fQ(e){var m;const{sourceNode:a,targetNode:i}=e;if(!qO(a)||!qO(i))return null;const c=a.internals.handleBounds||_O(a.handles),o=i.internals.handleBounds||_O(i.handles),l=TO((c==null?void 0:c.source)??[],e.sourceHandle),u=TO(e.connectionMode===Xl.Strict?(o==null?void 0:o.target)??[]:((o==null?void 0:o.target)??[]).concat((o==null?void 0:o.source)??[]),e.targetHandle);if(!l||!u)return(m=e.onError)==null||m.call(e,"008",Ya.error008(l?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const h=(l==null?void 0:l.position)||ve.Bottom,f=(u==null?void 0:u.position)||ve.Top,p=Ho(a,l,h),g=Ho(i,u,f);return{sourceX:p.x,sourceY:p.y,targetX:g.x,targetY:g.y,sourcePosition:h,targetPosition:f}}function _O(e){if(!e)return null;const a=[],i=[];for(const c of e)c.width=c.width??1,c.height=c.height??1,c.type==="source"?a.push(c):c.type==="target"&&i.push(c);return{source:a,target:i}}function Ho(e,a,i=ve.Left,c=!1){const o=((a==null?void 0:a.x)??0)+e.internals.positionAbsolute.x,l=((a==null?void 0:a.y)??0)+e.internals.positionAbsolute.y,{width:u,height:h}=a??_n(e);if(c)return{x:o+u/2,y:l+h/2};switch((a==null?void 0:a.position)??i){case ve.Top:return{x:o+u/2,y:l};case ve.Right:return{x:o+u,y:l+h/2};case ve.Bottom:return{x:o+u/2,y:l+h};case ve.Left:return{x:o,y:l+h/2}}}function TO(e,a){return e&&(a?e.find(i=>i.id===a):e[0])||null}function BT(e,a){return e?typeof e=="string"?e:`${a?`${a}__`:""}${Object.keys(e).sort().map(c=>`${c}=${e[c]}`).join("&")}`:""}function pQ(e,{id:a,defaultColor:i,defaultMarkerStart:c,defaultMarkerEnd:o}){const l=new Set;return e.reduce((u,h)=>([h.markerStart||c,h.markerEnd||o].forEach(f=>{if(f&&typeof f=="object"){const p=BT(f,a);l.has(p)||(u.push({id:p,color:f.color||i,...f}),l.add(p))}}),u),[]).sort((u,h)=>u.id.localeCompare(h.id))}const kR=1e3,kQ=10,wH={nodeOrigin:[0,0],nodeExtent:A2,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},mQ={...wH,checkEquality:!0};function bH(e,a){const i={...e};for(const c in a)a[c]!==void 0&&(i[c]=a[c]);return i}function gQ(e,a,i){const c=bH(wH,i);for(const o of e.values())if(o.parentId)SH(o,e,a,c);else{const l=U2(o,c.nodeOrigin),u=Ql(o.extent)?o.extent:c.nodeExtent,h=To(l,u,_n(o));o.internals.positionAbsolute=h}}function vQ(e,a){if(!e.handles)return e.measured?a==null?void 0:a.internals.handleBounds:void 0;const i=[],c=[];for(const o of e.handles){const l={id:o.id,width:o.width??1,height:o.height??1,nodeId:e.id,x:o.x,y:o.y,position:o.position,type:o.type};o.type==="source"?i.push(l):o.type==="target"&&c.push(l)}return{source:i,target:c}}function LH(e){return e==="manual"}function RT(e,a,i,c={}){var g,m;const o=bH(mQ,c),l={i:0},u=new Map(a),h=o!=null&&o.elevateNodesOnSelect&&!LH(o.zIndexMode)?kR:0;let f=e.length>0,p=!1;a.clear(),i.clear();for(const v of e){let M=u.get(v.id);if(o.checkEquality&&v===(M==null?void 0:M.internals.userNode))a.set(v.id,M);else{const b=U2(v,o.nodeOrigin),w=Ql(v.extent)?v.extent:o.nodeExtent,L=To(b,w,_n(v));M={...o.defaults,...v,measured:{width:(g=v.measured)==null?void 0:g.width,height:(m=v.measured)==null?void 0:m.height},internals:{positionAbsolute:L,handleBounds:vQ(v,M),z:mR(v,h,o.zIndexMode),userNode:v}},a.set(v.id,M)}(M.measured===void 0||M.measured.width===void 0||M.measured.height===void 0)&&!M.hidden&&(f=!1),v.parentId&&SH(M,a,i,c,l),p||(p=v.selected??!1)}return{nodesInitialized:f,hasSelectedNodes:p}}function MQ(e,a){if(!e.parentId)return;const i=a.get(e.parentId);i?i.set(e.id,e):a.set(e.parentId,new Map([[e.id,e]]))}function SH(e,a,i,c,o){const{elevateNodesOnSelect:l,nodeOrigin:u,nodeExtent:h,zIndexMode:f}=bH(wH,c),p=e.parentId,g=a.get(p);if(!g){console.warn(`Parent node ${p} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}MQ(e,i),o&&!g.parentId&&g.internals.rootParentIndex===void 0&&f==="auto"&&(g.internals.rootParentIndex=++o.i,g.internals.z=g.internals.z+o.i*kQ),o&&g.internals.rootParentIndex!==void 0&&(o.i=g.internals.rootParentIndex);const m=l&&!LH(f)?kR:0,{x:v,y:M,z:b}=xQ(e,g,u,h,m,f),{positionAbsolute:w}=e.internals,L=v!==w.x||M!==w.y;(L||b!==e.internals.z)&&a.set(e.id,{...e,internals:{...e.internals,positionAbsolute:L?{x:v,y:M}:w,z:b}})}function mR(e,a,i){const c=qa(e.zIndex)?e.zIndex:0;return LH(i)?c:c+(e.selected?a:0)}function xQ(e,a,i,c,o,l){const{x:u,y:h}=a.internals.positionAbsolute,f=_n(e),p=U2(e,i),g=Ql(e.extent)?To(p,e.extent,f):p;let m=To({x:u+g.x,y:h+g.y},c,f);e.extent==="parent"&&(m=iR(m,f,a));const v=mR(e,o,l),M=a.internals.z??0;return{x:m.x,y:m.y,z:M>=v?M+1:v}}function CH(e,a,i,c=[0,0]){var u;const o=[],l=new Map;for(const h of e){const f=a.get(h.parentId);if(!f)continue;const p=((u=l.get(h.parentId))==null?void 0:u.expandedRect)??Kl(f),g=rR(p,h.rect);l.set(h.parentId,{expandedRect:g,parent:f})}return l.size>0&&l.forEach(({expandedRect:h,parent:f},p)=>{var C;const g=f.internals.positionAbsolute,m=_n(f),v=f.origin??c,M=h.x<g.x?Math.round(Math.abs(g.x-h.x)):0,b=h.y<g.y?Math.round(Math.abs(g.y-h.y)):0,w=Math.max(m.width,Math.round(h.width)),L=Math.max(m.height,Math.round(h.height)),S=(w-m.width)*v[0],q=(L-m.height)*v[1];(M>0||b>0||S||q)&&(o.push({id:p,type:"position",position:{x:f.position.x-M+S,y:f.position.y-b+q}}),(C=i.get(p))==null||C.forEach(z=>{e.some(H=>H.id===z.id)||o.push({id:z.id,type:"position",position:{x:z.position.x+M,y:z.position.y+b}})})),(m.width<h.width||m.height<h.height||M||b)&&o.push({id:p,type:"dimensions",setAttributes:!0,dimensions:{width:w+(M?v[0]*M-S:0),height:L+(b?v[1]*b-q:0)}})}),o}function wQ(e,a,i,c,o,l,u){const h=c==null?void 0:c.querySelector(".xyflow__viewport");let f=!1;if(!h)return{changes:[],updatedInternals:f};const p=[],g=window.getComputedStyle(h),{m22:m}=new window.DOMMatrixReadOnly(g.transform),v=[];for(const M of e.values()){const b=a.get(M.id);if(!b)continue;if(b.hidden){a.set(b.id,{...b,internals:{...b.internals,handleBounds:void 0}}),f=!0;continue}const w=xH(M.nodeElement),L=b.measured.width!==w.width||b.measured.height!==w.height;if(!!(w.width&&w.height&&(L||!b.internals.handleBounds||M.force))){const q=M.nodeElement.getBoundingClientRect(),C=Ql(b.extent)?b.extent:l;let{positionAbsolute:z}=b.internals;b.parentId&&b.extent==="parent"?z=iR(z,w,a.get(b.parentId)):C&&(z=To(z,C,w));const H={...b,measured:w,internals:{...b.internals,positionAbsolute:z,handleBounds:{source:CO("source",M.nodeElement,q,m,b.id),target:CO("target",M.nodeElement,q,m,b.id)}}};a.set(b.id,H),b.parentId&&SH(H,a,i,{nodeOrigin:o,zIndexMode:u}),f=!0,L&&(p.push({id:b.id,type:"dimensions",dimensions:w}),b.expandParent&&b.parentId&&v.push({id:b.id,parentId:b.parentId,rect:Kl(H,o)}))}}if(v.length>0){const M=CH(v,a,i,o);p.push(...M)}return{changes:p,updatedInternals:f}}async function bQ({delta:e,panZoom:a,transform:i,translateExtent:c,width:o,height:l}){if(!a||!e.x&&!e.y)return Promise.resolve(!1);const u=await a.setViewportConstrained({x:i[0]+e.x,y:i[1]+e.y,zoom:i[2]},[[0,0],[o,l]],c),h=!!u&&(u.x!==i[0]||u.y!==i[1]||u.k!==i[2]);return Promise.resolve(h)}function HO(e,a,i,c,o,l){let u=o;const h=c.get(u)||new Map;c.set(u,h.set(i,a)),u=`${o}-${e}`;const f=c.get(u)||new Map;if(c.set(u,f.set(i,a)),l){u=`${o}-${e}-${l}`;const p=c.get(u)||new Map;c.set(u,p.set(i,a))}}function gR(e,a,i){e.clear(),a.clear();for(const c of i){const{source:o,target:l,sourceHandle:u=null,targetHandle:h=null}=c,f={edgeId:c.id,source:o,target:l,sourceHandle:u,targetHandle:h},p=`${o}-${u}--${l}-${h}`,g=`${l}-${h}--${o}-${u}`;HO("source",f,g,e,o,u),HO("target",f,p,e,l,h),a.set(c.id,c)}}function vR(e,a){if(!e.parentId)return!1;const i=a.get(e.parentId);return i?i.selected?!0:vR(i,a):!1}function jO(e,a,i){var o;let c=e;do{if((o=c==null?void 0:c.matches)!=null&&o.call(c,a))return!0;if(c===i)return!1;c=c==null?void 0:c.parentElement}while(c);return!1}function LQ(e,a,i,c){const o=new Map;for(const[l,u]of e)if((u.selected||u.id===c)&&(!u.parentId||!vR(u,e))&&(u.draggable||a&&typeof u.draggable>"u")){const h=e.get(l);h&&o.set(l,{id:l,position:h.position||{x:0,y:0},distance:{x:i.x-h.internals.positionAbsolute.x,y:i.y-h.internals.positionAbsolute.y},extent:h.extent,parentId:h.parentId,origin:h.origin,expandParent:h.expandParent,internals:{positionAbsolute:h.internals.positionAbsolute||{x:0,y:0}},measured:{width:h.measured.width??0,height:h.measured.height??0}})}return o}function iT({nodeId:e,dragItems:a,nodeLookup:i,dragging:c=!0}){var u,h,f;const o=[];for(const[p,g]of a){const m=(u=i.get(p))==null?void 0:u.internals.userNode;m&&o.push({...m,position:g.position,dragging:c})}if(!e)return[o[0],o];const l=(h=i.get(e))==null?void 0:h.internals.userNode;return[l?{...l,position:((f=a.get(e))==null?void 0:f.position)||l.position,dragging:c}:o[0],o]}function SQ({dragItems:e,snapGrid:a,x:i,y:c}){const o=e.values().next().value;if(!o)return null;const l={x:i-o.distance.x,y:c-o.distance.y},u=F2(l,a);return{x:u.x-l.x,y:u.y-l.y}}function CQ({onNodeMouseDown:e,getStoreItems:a,onDragStart:i,onDrag:c,onDragStop:o}){let l={x:null,y:null},u=0,h=new Map,f=!1,p={x:0,y:0},g=null,m=!1,v=null,M=!1,b=!1,w=null;function L({noDragClassName:q,handleSelector:C,domNode:z,isSelectable:H,nodeId:N,nodeClickDistance:E=0}){v=ra(z);function R({x:Z,y:ne}){const{nodeLookup:j,nodeExtent:X,snapGrid:T,snapToGrid:V,nodeOrigin:U,onNodeDrag:F,onSelectionDrag:J,onError:_,updateNodePositions:B}=a();l={x:Z,y:ne};let te=!1;const ie=h.size>1,le=ie&&X?OT(P2(h)):null,ue=ie&&V?SQ({dragItems:h,snapGrid:T,x:Z,y:ne}):null;for(const[he,se]of h){if(!j.has(he))continue;let ye={x:Z-se.distance.x,y:ne-se.distance.y};V&&(ye=ue?{x:Math.round(ye.x+ue.x),y:Math.round(ye.y+ue.y)}:F2(ye,T));let ze=null;if(ie&&X&&!se.extent&&le){const{positionAbsolute:xe}=se.internals,Ee=xe.x-le.x+X[0][0],Xe=xe.x+se.measured.width-le.x2+X[1][0],Oe=xe.y-le.y+X[0][1],Ct=xe.y+se.measured.height-le.y2+X[1][1];ze=[[Ee,Oe],[Xe,Ct]]}const{position:Se,positionAbsolute:we}=nR({nodeId:he,nextPosition:ye,nodeLookup:j,nodeExtent:ze||X,nodeOrigin:U,onError:_});te=te||se.position.x!==Se.x||se.position.y!==Se.y,se.position=Se,se.internals.positionAbsolute=we}if(b=b||te,!!te&&(B(h,!0),w&&(c||F||!N&&J))){const[he,se]=iT({nodeId:N,dragItems:h,nodeLookup:j});c==null||c(w,h,he,se),F==null||F(w,he,se),N||J==null||J(w,se)}}async function O(){if(!g)return;const{transform:Z,panBy:ne,autoPanSpeed:j,autoPanOnNodeDrag:X}=a();if(!X){f=!1,cancelAnimationFrame(u);return}const[T,V]=cR(p,g,j);(T!==0||V!==0)&&(l.x=(l.x??0)-T/Z[2],l.y=(l.y??0)-V/Z[2],await ne({x:T,y:V})&&R(l)),u=requestAnimationFrame(O)}function ae(Z){var ie;const{nodeLookup:ne,multiSelectionActive:j,nodesDraggable:X,transform:T,snapGrid:V,snapToGrid:U,selectNodesOnDrag:F,onNodeDragStart:J,onSelectionDragStart:_,unselectNodesAndEdges:B}=a();m=!0,(!F||!H)&&!j&&N&&((ie=ne.get(N))!=null&&ie.selected||B()),H&&F&&N&&(e==null||e(N));const te=f2(Z.sourceEvent,{transform:T,snapGrid:V,snapToGrid:U,containerBounds:g});if(l=te,h=LQ(ne,X,te,N),h.size>0&&(i||J||!N&&_)){const[le,ue]=iT({nodeId:N,dragItems:h,nodeLookup:ne});i==null||i(Z.sourceEvent,h,le,ue),J==null||J(Z.sourceEvent,le,ue),N||_==null||_(Z.sourceEvent,ue)}}const G=NB().clickDistance(E).on("start",Z=>{const{domNode:ne,nodeDragThreshold:j,transform:X,snapGrid:T,snapToGrid:V}=a();g=(ne==null?void 0:ne.getBoundingClientRect())||null,M=!1,b=!1,w=Z.sourceEvent,j===0&&ae(Z),l=f2(Z.sourceEvent,{transform:X,snapGrid:T,snapToGrid:V,containerBounds:g}),p=_a(Z.sourceEvent,g)}).on("drag",Z=>{const{autoPanOnNodeDrag:ne,transform:j,snapGrid:X,snapToGrid:T,nodeDragThreshold:V,nodeLookup:U}=a(),F=f2(Z.sourceEvent,{transform:j,snapGrid:X,snapToGrid:T,containerBounds:g});if(w=Z.sourceEvent,(Z.sourceEvent.type==="touchmove"&&Z.sourceEvent.touches.length>1||N&&!U.has(N))&&(M=!0),!M){if(!f&&ne&&m&&(f=!0,O()),!m){const J=_a(Z.sourceEvent,g),_=J.x-p.x,B=J.y-p.y;Math.sqrt(_*_+B*B)>V&&ae(Z)}(l.x!==F.xSnapped||l.y!==F.ySnapped)&&h&&m&&(p=_a(Z.sourceEvent,g),R(F))}}).on("end",Z=>{if(!(!m||M)&&(f=!1,m=!1,cancelAnimationFrame(u),h.size>0)){const{nodeLookup:ne,updateNodePositions:j,onNodeDragStop:X,onSelectionDragStop:T}=a();if(b&&(j(h,!1),b=!1),o||X||!N&&T){const[V,U]=iT({nodeId:N,dragItems:h,nodeLookup:ne,dragging:!1});o==null||o(Z.sourceEvent,h,V,U),X==null||X(Z.sourceEvent,V,U),N||T==null||T(Z.sourceEvent,U)}}}).filter(Z=>{const ne=Z.target;return!Z.button&&(!q||!jO(ne,`.${q}`,z))&&(!C||jO(ne,C,z))});v.call(G)}function S(){v==null||v.on(".drag",null)}return{update:L,destroy:S}}function AQ(e,a,i){const c=[],o={x:e.x-i,y:e.y-i,width:i*2,height:i*2};for(const l of a.values())q2(o,Kl(l))>0&&c.push(l);return c}const IQ=250;function zQ(e,a,i,c){var h,f;let o=[],l=1/0;const u=AQ(e,i,a+IQ);for(const p of u){const g=[...((h=p.internals.handleBounds)==null?void 0:h.source)??[],...((f=p.internals.handleBounds)==null?void 0:f.target)??[]];for(const m of g){if(c.nodeId===m.nodeId&&c.type===m.type&&c.id===m.id)continue;const{x:v,y:M}=Ho(p,m,m.position,!0),b=Math.sqrt(Math.pow(v-e.x,2)+Math.pow(M-e.y,2));b>a||(b<l?(o=[{...m,x:v,y:M}],l=b):b===l&&o.push({...m,x:v,y:M}))}}if(!o.length)return null;if(o.length>1){const p=c.type==="source"?"target":"source";return o.find(g=>g.type===p)??o[0]}return o[0]}function MR(e,a,i,c,o,l=!1){var p,g,m;const u=c.get(e);if(!u)return null;const h=o==="strict"?(p=u.internals.handleBounds)==null?void 0:p[a]:[...((g=u.internals.handleBounds)==null?void 0:g.source)??[],...((m=u.internals.handleBounds)==null?void 0:m.target)??[]],f=(i?h==null?void 0:h.find(v=>v.id===i):h==null?void 0:h[0])??null;return f&&l?{...f,...Ho(u,f,f.position,!0)}:f}function xR(e,a){return e||(a!=null&&a.classList.contains("target")?"target":a!=null&&a.classList.contains("source")?"source":null)}function qQ(e,a){let i=null;return a?i=!0:e&&!a&&(i=!1),i}const wR=()=>!0;function _Q(e,{connectionMode:a,connectionRadius:i,handleId:c,nodeId:o,edgeUpdaterType:l,isTarget:u,domNode:h,nodeLookup:f,lib:p,autoPanOnConnect:g,flowId:m,panBy:v,cancelConnection:M,onConnectStart:b,onConnect:w,onConnectEnd:L,isValidConnection:S=wR,onReconnectEnd:q,updateConnection:C,getTransform:z,getFromHandle:H,autoPanSpeed:N,dragThreshold:E=1,handleDomNode:R}){const O=sR(e.target);let ae=0,G;const{x:Z,y:ne}=_a(e),j=xR(l,R),X=h==null?void 0:h.getBoundingClientRect();let T=!1;if(!X||!j)return;const V=MR(o,j,c,f,a);if(!V)return;let U=_a(e,X),F=!1,J=null,_=!1,B=null;function te(){if(!g||!X)return;const[Se,we]=cR(U,X,N);v({x:Se,y:we}),ae=requestAnimationFrame(te)}const ie={...V,nodeId:o,type:j,position:V.position},le=f.get(o);let he={inProgress:!0,isValid:null,from:Ho(le,ie,ve.Left,!0),fromHandle:ie,fromPosition:ie.position,fromNode:le,to:U,toHandle:null,toPosition:wO[ie.position],toNode:null,pointer:U};function se(){T=!0,C(he),b==null||b(e,{nodeId:o,handleId:c,handleType:j})}E===0&&se();function ye(Se){if(!T){const{x:Ct,y:xa}=_a(Se),Qt=Ct-Z,wa=xa-ne;if(!(Qt*Qt+wa*wa>E*E))return;se()}if(!H()||!ie){ze(Se);return}const we=z();U=_a(Se,X),G=zQ(Z2(U,we,!1,[1,1]),i,f,ie),F||(te(),F=!0);const xe=bR(Se,{handle:G,connectionMode:a,fromNodeId:o,fromHandleId:c,fromType:u?"target":"source",isValidConnection:S,doc:O,lib:p,flowId:m,nodeLookup:f});B=xe.handleDomNode,J=xe.connection,_=qQ(!!G,xe.isValid);const Ee=f.get(o),Xe=Ee?Ho(Ee,ie,ve.Left,!0):he.from,Oe={...he,from:Xe,isValid:_,to:xe.toHandle&&_?YI({x:xe.toHandle.x,y:xe.toHandle.y},we):U,toHandle:xe.toHandle,toPosition:_&&xe.toHandle?xe.toHandle.position:wO[ie.position],toNode:xe.toHandle?f.get(xe.toHandle.nodeId):null,pointer:U};C(Oe),he=Oe}function ze(Se){if(!("touches"in Se&&Se.touches.length>0)){if(T){(G||B)&&J&&_&&(w==null||w(J));const{inProgress:we,...xe}=he,Ee={...xe,toPosition:he.toHandle?he.toPosition:null};L==null||L(Se,Ee),l&&(q==null||q(Se,Ee))}M(),cancelAnimationFrame(ae),F=!1,_=!1,J=null,B=null,O.removeEventListener("mousemove",ye),O.removeEventListener("mouseup",ze),O.removeEventListener("touchmove",ye),O.removeEventListener("touchend",ze)}}O.addEventListener("mousemove",ye),O.addEventListener("mouseup",ze),O.addEventListener("touchmove",ye),O.addEventListener("touchend",ze)}function bR(e,{handle:a,connectionMode:i,fromNodeId:c,fromHandleId:o,fromType:l,doc:u,lib:h,flowId:f,isValidConnection:p=wR,nodeLookup:g}){const m=l==="target",v=a?u.querySelector(`.${h}-flow__handle[data-id="${f}-${a==null?void 0:a.nodeId}-${a==null?void 0:a.id}-${a==null?void 0:a.type}"]`):null,{x:M,y:b}=_a(e),w=u.elementFromPoint(M,b),L=w!=null&&w.classList.contains(`${h}-flow__handle`)?w:v,S={handleDomNode:L,isValid:!1,connection:null,toHandle:null};if(L){const q=xR(void 0,L),C=L.getAttribute("data-nodeid"),z=L.getAttribute("data-handleid"),H=L.classList.contains("connectable"),N=L.classList.contains("connectableend");if(!C||!q)return S;const E={source:m?C:c,sourceHandle:m?z:o,target:m?c:C,targetHandle:m?o:z};S.connection=E;const O=H&&N&&(i===Xl.Strict?m&&q==="source"||!m&&q==="target":C!==c||z!==o);S.isValid=O&&p(E),S.toHandle=MR(C,q,z,g,i,!0)}return S}const UT={onPointerDown:_Q,isValid:bR};function TQ({domNode:e,panZoom:a,getTransform:i,getViewScale:c}){const o=ra(e);function l({translateExtent:h,width:f,height:p,zoomStep:g=1,pannable:m=!0,zoomable:v=!0,inversePan:M=!1}){const b=C=>{if(C.sourceEvent.type!=="wheel"||!a)return;const z=i(),H=C.sourceEvent.ctrlKey&&_2()?10:1,N=-C.sourceEvent.deltaY*(C.sourceEvent.deltaMode===1?.05:C.sourceEvent.deltaMode?1:.002)*g,E=z[2]*Math.pow(2,N*H);a.scaleTo(E)};let w=[0,0];const L=C=>{(C.sourceEvent.type==="mousedown"||C.sourceEvent.type==="touchstart")&&(w=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY])},S=C=>{const z=i();if(C.sourceEvent.type!=="mousemove"&&C.sourceEvent.type!=="touchmove"||!a)return;const H=[C.sourceEvent.clientX??C.sourceEvent.touches[0].clientX,C.sourceEvent.clientY??C.sourceEvent.touches[0].clientY],N=[H[0]-w[0],H[1]-w[1]];w=H;const E=c()*Math.max(z[2],Math.log(z[2]))*(M?-1:1),R={x:z[0]-N[0]*E,y:z[1]-N[1]*E},O=[[0,0],[f,p]];a.setViewportConstrained({x:R.x,y:R.y,zoom:z[2]},O,h)},q=QB().on("start",L).on("zoom",m?S:null).on("zoom.wheel",v?b:null);o.call(q,{})}function u(){o.on("zoom",null)}return{update:l,destroy:u,pointer:Ia}}const pz=e=>({x:e.x,y:e.y,zoom:e.k}),cT=({x:e,y:a,zoom:i})=>hz.translate(e,a).scale(i),zl=(e,a)=>e.target.closest(`.${a}`),LR=(e,a)=>a===2&&Array.isArray(e)&&e.includes(2),HQ=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,rT=(e,a=0,i=HQ,c=()=>{})=>{const o=typeof a=="number"&&a>0;return o||c(),o?e.transition().duration(a).ease(i).on("end",c):e},SR=e=>{const a=e.ctrlKey&&_2()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*a};function jQ({zoomPanValues:e,noWheelClassName:a,d3Selection:i,d3Zoom:c,panOnScrollMode:o,panOnScrollSpeed:l,zoomOnPinch:u,onPanZoomStart:h,onPanZoom:f,onPanZoomEnd:p}){return g=>{if(zl(g,a))return g.ctrlKey&&g.preventDefault(),!1;g.preventDefault(),g.stopImmediatePropagation();const m=i.property("__zoom").k||1;if(g.ctrlKey&&u){const L=Ia(g),S=SR(g),q=m*Math.pow(2,S);c.scaleTo(i,q,L,g);return}const v=g.deltaMode===1?20:1;let M=o===So.Vertical?0:g.deltaX*v,b=o===So.Horizontal?0:g.deltaY*v;!_2()&&g.shiftKey&&o!==So.Vertical&&(M=g.deltaY*v,b=0),c.translateBy(i,-(M/m)*l,-(b/m)*l,{internal:!0});const w=pz(i.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(f==null||f(g,w),e.panScrollTimeout=setTimeout(()=>{p==null||p(g,w),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,h==null||h(g,w))}}function EQ({noWheelClassName:e,preventScrolling:a,d3ZoomHandler:i}){return function(c,o){const l=c.type==="wheel",u=!a&&l&&!c.ctrlKey,h=zl(c,e);if(c.ctrlKey&&l&&h&&c.preventDefault(),u||h)return null;c.preventDefault(),i.call(this,c,o)}}function NQ({zoomPanValues:e,onDraggingChange:a,onPanZoomStart:i}){return c=>{var l,u,h;if((l=c.sourceEvent)!=null&&l.internal)return;const o=pz(c.transform);e.mouseButton=((u=c.sourceEvent)==null?void 0:u.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=o,((h=c.sourceEvent)==null?void 0:h.type)==="mousedown"&&a(!0),i&&(i==null||i(c.sourceEvent,o))}}function DQ({zoomPanValues:e,panOnDrag:a,onPaneContextMenu:i,onTransformChange:c,onPanZoom:o}){return l=>{var u,h;e.usedRightMouseButton=!!(i&&LR(a,e.mouseButton??0)),(u=l.sourceEvent)!=null&&u.sync||c([l.transform.x,l.transform.y,l.transform.k]),o&&!((h=l.sourceEvent)!=null&&h.internal)&&(o==null||o(l.sourceEvent,pz(l.transform)))}}function OQ({zoomPanValues:e,panOnDrag:a,panOnScroll:i,onDraggingChange:c,onPanZoomEnd:o,onPaneContextMenu:l}){return u=>{var h;if(!((h=u.sourceEvent)!=null&&h.internal)&&(e.isZoomingOrPanning=!1,l&&LR(a,e.mouseButton??0)&&!e.usedRightMouseButton&&u.sourceEvent&&l(u.sourceEvent),e.usedRightMouseButton=!1,c(!1),o)){const f=pz(u.transform);e.prevViewport=f,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{o==null||o(u.sourceEvent,f)},i?150:0)}}}function VQ({zoomActivationKeyPressed:e,zoomOnScroll:a,zoomOnPinch:i,panOnDrag:c,panOnScroll:o,zoomOnDoubleClick:l,userSelectionActive:u,noWheelClassName:h,noPanClassName:f,lib:p,connectionInProgress:g}){return m=>{var L;const v=e||a,M=i&&m.ctrlKey,b=m.type==="wheel";if(m.button===1&&m.type==="mousedown"&&(zl(m,`${p}-flow__node`)||zl(m,`${p}-flow__edge`)))return!0;if(!c&&!v&&!o&&!l&&!i||u||g&&!b||zl(m,h)&&b||zl(m,f)&&(!b||o&&b&&!e)||!i&&m.ctrlKey&&b)return!1;if(!i&&m.type==="touchstart"&&((L=m.touches)==null?void 0:L.length)>1)return m.preventDefault(),!1;if(!v&&!o&&!M&&b||!c&&(m.type==="mousedown"||m.type==="touchstart")||Array.isArray(c)&&!c.includes(m.button)&&m.type==="mousedown")return!1;const w=Array.isArray(c)&&c.includes(m.button)||!m.button||m.button<=1;return(!m.ctrlKey||b)&&w}}function BQ({domNode:e,minZoom:a,maxZoom:i,translateExtent:c,viewport:o,onPanZoom:l,onPanZoomStart:u,onPanZoomEnd:h,onDraggingChange:f}){const p={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},g=e.getBoundingClientRect(),m=QB().scaleExtent([a,i]).translateExtent(c),v=ra(e).call(m);q({x:o.x,y:o.y,zoom:Yl(o.zoom,a,i)},[[0,0],[g.width,g.height]],c);const M=v.on("wheel.zoom"),b=v.on("dblclick.zoom");m.wheelDelta(SR);function w(G,Z){return v?new Promise(ne=>{m==null||m.interpolate((Z==null?void 0:Z.interpolate)==="linear"?y2:Ed).transform(rT(v,Z==null?void 0:Z.duration,Z==null?void 0:Z.ease,()=>ne(!0)),G)}):Promise.resolve(!1)}function L({noWheelClassName:G,noPanClassName:Z,onPaneContextMenu:ne,userSelectionActive:j,panOnScroll:X,panOnDrag:T,panOnScrollMode:V,panOnScrollSpeed:U,preventScrolling:F,zoomOnPinch:J,zoomOnScroll:_,zoomOnDoubleClick:B,zoomActivationKeyPressed:te,lib:ie,onTransformChange:le,connectionInProgress:ue,paneClickDistance:he,selectionOnDrag:se}){j&&!p.isZoomingOrPanning&&S();const ye=X&&!te&&!j;m.clickDistance(se?1/0:!qa(he)||he<0?0:he);const ze=ye?jQ({zoomPanValues:p,noWheelClassName:G,d3Selection:v,d3Zoom:m,panOnScrollMode:V,panOnScrollSpeed:U,zoomOnPinch:J,onPanZoomStart:u,onPanZoom:l,onPanZoomEnd:h}):EQ({noWheelClassName:G,preventScrolling:F,d3ZoomHandler:M});if(v.on("wheel.zoom",ze,{passive:!1}),!j){const we=NQ({zoomPanValues:p,onDraggingChange:f,onPanZoomStart:u});m.on("start",we);const xe=DQ({zoomPanValues:p,panOnDrag:T,onPaneContextMenu:!!ne,onPanZoom:l,onTransformChange:le});m.on("zoom",xe);const Ee=OQ({zoomPanValues:p,panOnDrag:T,panOnScroll:X,onPaneContextMenu:ne,onPanZoomEnd:h,onDraggingChange:f});m.on("end",Ee)}const Se=VQ({zoomActivationKeyPressed:te,panOnDrag:T,zoomOnScroll:_,panOnScroll:X,zoomOnDoubleClick:B,zoomOnPinch:J,userSelectionActive:j,noPanClassName:Z,noWheelClassName:G,lib:ie,connectionInProgress:ue});m.filter(Se),B?v.on("dblclick.zoom",b):v.on("dblclick.zoom",null)}function S(){m.on("zoom",null)}async function q(G,Z,ne){const j=cT(G),X=m==null?void 0:m.constrain()(j,Z,ne);return X&&await w(X),new Promise(T=>T(X))}async function C(G,Z){const ne=cT(G);return await w(ne,Z),new Promise(j=>j(ne))}function z(G){if(v){const Z=cT(G),ne=v.property("__zoom");(ne.k!==G.zoom||ne.x!==G.x||ne.y!==G.y)&&(m==null||m.transform(v,Z,null,{sync:!0}))}}function H(){const G=v?KB(v.node()):{x:0,y:0,k:1};return{x:G.x,y:G.y,zoom:G.k}}function N(G,Z){return v?new Promise(ne=>{m==null||m.interpolate((Z==null?void 0:Z.interpolate)==="linear"?y2:Ed).scaleTo(rT(v,Z==null?void 0:Z.duration,Z==null?void 0:Z.ease,()=>ne(!0)),G)}):Promise.resolve(!1)}function E(G,Z){return v?new Promise(ne=>{m==null||m.interpolate((Z==null?void 0:Z.interpolate)==="linear"?y2:Ed).scaleBy(rT(v,Z==null?void 0:Z.duration,Z==null?void 0:Z.ease,()=>ne(!0)),G)}):Promise.resolve(!1)}function R(G){m==null||m.scaleExtent(G)}function O(G){m==null||m.translateExtent(G)}function ae(G){const Z=!qa(G)||G<0?0:G;m==null||m.clickDistance(Z)}return{update:L,destroy:S,setViewport:C,setViewportConstrained:q,getViewport:H,scaleTo:N,scaleBy:E,setScaleExtent:R,setTranslateExtent:O,syncViewport:z,setClickDistance:ae}}var Wl;(function(e){e.Line="line",e.Handle="handle"})(Wl||(Wl={}));function RQ({width:e,prevWidth:a,height:i,prevHeight:c,affectsX:o,affectsY:l}){const u=e-a,h=i-c,f=[u>0?1:u<0?-1:0,h>0?1:h<0?-1:0];return u&&o&&(f[0]=f[0]*-1),h&&l&&(f[1]=f[1]*-1),f}function EO(e){const a=e.includes("right")||e.includes("left"),i=e.includes("bottom")||e.includes("top"),c=e.includes("left"),o=e.includes("top");return{isHorizontal:a,isVertical:i,affectsX:c,affectsY:o}}function d1(e,a){return Math.max(0,a-e)}function u1(e,a){return Math.max(0,e-a)}function Ad(e,a,i){return Math.max(0,a-e,e-i)}function NO(e,a){return e?!a:a}function UQ(e,a,i,c,o,l,u,h){let{affectsX:f,affectsY:p}=a;const{isHorizontal:g,isVertical:m}=a,v=g&&m,{xSnapped:M,ySnapped:b}=i,{minWidth:w,maxWidth:L,minHeight:S,maxHeight:q}=c,{x:C,y:z,width:H,height:N,aspectRatio:E}=e;let R=Math.floor(g?M-e.pointerX:0),O=Math.floor(m?b-e.pointerY:0);const ae=H+(f?-R:R),G=N+(p?-O:O),Z=-l[0]*H,ne=-l[1]*N;let j=Ad(ae,w,L),X=Ad(G,S,q);if(u){let U=0,F=0;f&&R<0?U=d1(C+R+Z,u[0][0]):!f&&R>0&&(U=u1(C+ae+Z,u[1][0])),p&&O<0?F=d1(z+O+ne,u[0][1]):!p&&O>0&&(F=u1(z+G+ne,u[1][1])),j=Math.max(j,U),X=Math.max(X,F)}if(h){let U=0,F=0;f&&R>0?U=u1(C+R,h[0][0]):!f&&R<0&&(U=d1(C+ae,h[1][0])),p&&O>0?F=u1(z+O,h[0][1]):!p&&O<0&&(F=d1(z+G,h[1][1])),j=Math.max(j,U),X=Math.max(X,F)}if(o){if(g){const U=Ad(ae/E,S,q)*E;if(j=Math.max(j,U),u){let F=0;!f&&!p||f&&!p&&v?F=u1(z+ne+ae/E,u[1][1])*E:F=d1(z+ne+(f?R:-R)/E,u[0][1])*E,j=Math.max(j,F)}if(h){let F=0;!f&&!p||f&&!p&&v?F=d1(z+ae/E,h[1][1])*E:F=u1(z+(f?R:-R)/E,h[0][1])*E,j=Math.max(j,F)}}if(m){const U=Ad(G*E,w,L)/E;if(X=Math.max(X,U),u){let F=0;!f&&!p||p&&!f&&v?F=u1(C+G*E+Z,u[1][0])/E:F=d1(C+(p?O:-O)*E+Z,u[0][0])/E,X=Math.max(X,F)}if(h){let F=0;!f&&!p||p&&!f&&v?F=d1(C+G*E,h[1][0])/E:F=u1(C+(p?O:-O)*E,h[0][0])/E,X=Math.max(X,F)}}}O=O+(O<0?X:-X),R=R+(R<0?j:-j),o&&(v?ae>G*E?O=(NO(f,p)?-R:R)/E:R=(NO(f,p)?-O:O)*E:g?(O=R/E,p=f):(R=O*E,f=p));const T=f?C+R:C,V=p?z+O:z;return{width:H+(f?-R:R),height:N+(p?-O:O),x:l[0]*R*(f?-1:1)+T,y:l[1]*O*(p?-1:1)+V}}const CR={width:0,height:0,x:0,y:0},PQ={...CR,pointerX:0,pointerY:0,aspectRatio:1};function FQ(e){return[[0,0],[e.measured.width,e.measured.height]]}function ZQ(e,a,i){const c=a.position.x+e.position.x,o=a.position.y+e.position.y,l=e.measured.width??0,u=e.measured.height??0,h=i[0]*l,f=i[1]*u;return[[c-h,o-f],[c+l-h,o+u-f]]}function GQ({domNode:e,nodeId:a,getStoreItems:i,onChange:c,onEnd:o}){const l=ra(e);let u={controlDirection:EO("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function h({controlPosition:p,boundaries:g,keepAspectRatio:m,resizeDirection:v,onResizeStart:M,onResize:b,onResizeEnd:w,shouldResize:L}){let S={...CR},q={...PQ};u={boundaries:g,resizeDirection:v,keepAspectRatio:m,controlDirection:EO(p)};let C,z=null,H=[],N,E,R,O=!1;const ae=NB().on("start",G=>{const{nodeLookup:Z,transform:ne,snapGrid:j,snapToGrid:X,nodeOrigin:T,paneDomNode:V}=i();if(C=Z.get(a),!C)return;z=(V==null?void 0:V.getBoundingClientRect())??null;const{xSnapped:U,ySnapped:F}=f2(G.sourceEvent,{transform:ne,snapGrid:j,snapToGrid:X,containerBounds:z});S={width:C.measured.width??0,height:C.measured.height??0,x:C.position.x??0,y:C.position.y??0},q={...S,pointerX:U,pointerY:F,aspectRatio:S.width/S.height},N=void 0,C.parentId&&(C.extent==="parent"||C.expandParent)&&(N=Z.get(C.parentId),E=N&&C.extent==="parent"?FQ(N):void 0),H=[],R=void 0;for(const[J,_]of Z)if(_.parentId===a&&(H.push({id:J,position:{..._.position},extent:_.extent}),_.extent==="parent"||_.expandParent)){const B=ZQ(_,C,_.origin??T);R?R=[[Math.min(B[0][0],R[0][0]),Math.min(B[0][1],R[0][1])],[Math.max(B[1][0],R[1][0]),Math.max(B[1][1],R[1][1])]]:R=B}M==null||M(G,{...S})}).on("drag",G=>{const{transform:Z,snapGrid:ne,snapToGrid:j,nodeOrigin:X}=i(),T=f2(G.sourceEvent,{transform:Z,snapGrid:ne,snapToGrid:j,containerBounds:z}),V=[];if(!C)return;const{x:U,y:F,width:J,height:_}=S,B={},te=C.origin??X,{width:ie,height:le,x:ue,y:he}=UQ(q,u.controlDirection,T,u.boundaries,u.keepAspectRatio,te,E,R),se=ie!==J,ye=le!==_,ze=ue!==U&&se,Se=he!==F&&ye;if(!ze&&!Se&&!se&&!ye)return;if((ze||Se||te[0]===1||te[1]===1)&&(B.x=ze?ue:S.x,B.y=Se?he:S.y,S.x=B.x,S.y=B.y,H.length>0)){const Xe=ue-U,Oe=he-F;for(const Ct of H)Ct.position={x:Ct.position.x-Xe+te[0]*(ie-J),y:Ct.position.y-Oe+te[1]*(le-_)},V.push(Ct)}if((se||ye)&&(B.width=se&&(!u.resizeDirection||u.resizeDirection==="horizontal")?ie:S.width,B.height=ye&&(!u.resizeDirection||u.resizeDirection==="vertical")?le:S.height,S.width=B.width,S.height=B.height),N&&C.expandParent){const Xe=te[0]*(B.width??0);B.x&&B.x<Xe&&(S.x=Xe,q.x=q.x-(B.x-Xe));const Oe=te[1]*(B.height??0);B.y&&B.y<Oe&&(S.y=Oe,q.y=q.y-(B.y-Oe))}const we=RQ({width:S.width,prevWidth:J,height:S.height,prevHeight:_,affectsX:u.controlDirection.affectsX,affectsY:u.controlDirection.affectsY}),xe={...S,direction:we};(L==null?void 0:L(G,xe))!==!1&&(O=!0,b==null||b(G,xe),c(B,V))}).on("end",G=>{O&&(w==null||w(G,{...S}),o==null||o({...S}),O=!1)});l.call(ae)}function f(){l.on(".drag",null)}return{update:h,destroy:f}}var oT={exports:{}},lT={},sT={exports:{}},dT={};/**
|
|
180
180
|
* @license React
|
|
181
181
|
* use-sync-external-store-shim.production.js
|
|
182
182
|
*
|
package/dist/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;500;600;700&display=swap"
|
|
12
12
|
rel="stylesheet"
|
|
13
13
|
/>
|
|
14
|
-
<script type="module" crossorigin src="./assets/index-
|
|
14
|
+
<script type="module" crossorigin src="./assets/index-CdBXJTT3.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="./assets/index-Bgyy7bzr.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "morffy",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "A read-only architecture diagram visualizer that shows how a system evolves across a timeline. Combines a Visio-style graph canvas with a Gantt-style timeline view.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|