ima2-gen 3.21.0 → 3.22.0
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.
- package/bin/commands/grok.js +8 -1
- package/docs/API.md +4 -1
- package/docs/migration/runtime-test-inventory.md +164 -159
- package/lib/grokSizeMapper.js +2 -0
- package/lib/mcp/adapters/higgsfield.js +17 -10
- package/lib/mcp/adapters/higgsfieldUpload.js +77 -0
- package/lib/mcp/connectionManager.js +32 -0
- package/lib/mcp/modelsCatalog.js +12 -1
- package/lib/xaiAuth.js +35 -3
- package/lib/xaiDeviceLogin.js +30 -4
- package/package.json +2 -2
- package/routes/auth.js +13 -2
- package/routes/mcpMedia.js +21 -7
- package/routes/mcpMultishot.js +11 -7
- package/routes/mcpRecover.js +6 -2
- package/routes/quota.js +50 -14
- package/ui/dist/.vite/manifest.json +64 -64
- package/ui/dist/assets/{AgentWorkspace-CBOIYDSC.js → AgentWorkspace-CRJwrf5D.js} +1 -1
- package/ui/dist/assets/App-B7t5h5M_.js +9 -0
- package/ui/dist/assets/{AssetGenWorkspace-kjhZeUE8.js → AssetGenWorkspace-CR3k3lgk.js} +2 -2
- package/ui/dist/assets/{AssetMediaLightbox-B6YoVErG.js → AssetMediaLightbox-DOP-l7is.js} +1 -1
- package/ui/dist/assets/{AssetsWorkspace-D3yHm95L.js → AssetsWorkspace-i9IE-OMD.js} +1 -1
- package/ui/dist/assets/{CardNewsWorkspace-BVmfGpNh.js → CardNewsWorkspace-B238fPNf.js} +1 -1
- package/ui/dist/assets/{GenerationRequestLogPanel-lNQlY7ax.js → GenerationRequestLogPanel-Bznhoi1c.js} +1 -1
- package/ui/dist/assets/{HomeWorkspace-DoJRK1Oc.js → HomeWorkspace-DmQcpD4W.js} +1 -1
- package/ui/dist/assets/{KeyingPanel-CzXXD18n.js → KeyingPanel-C-9CZfhI.js} +1 -1
- package/ui/dist/assets/{NodeCanvas-Di9xPPrm.js → NodeCanvas-CtSwikbj.js} +1 -1
- package/ui/dist/assets/{PromptBuilderPanel-BRC8Or5u.js → PromptBuilderPanel-CWOtvCbq.js} +1 -1
- package/ui/dist/assets/{PromptImportDialog-DftvHziZ.js → PromptImportDialog-ski4y5rq.js} +2 -2
- package/ui/dist/assets/{PromptImportDiscoverySection-BRVea9Rt.js → PromptImportDiscoverySection-BxPnvWSF.js} +1 -1
- package/ui/dist/assets/{PromptImportFolderSection-y9o9rPoQ.js → PromptImportFolderSection-rt8TMgTU.js} +1 -1
- package/ui/dist/assets/{PromptLibraryPanel-CpseDORF.js → PromptLibraryPanel-evfChzKq.js} +2 -2
- package/ui/dist/assets/SettingsWorkspace-PzprnYiR.js +1 -0
- package/ui/dist/assets/{SpriteRecipeWorkspace-Bt9UmStQ.js → SpriteRecipeWorkspace-BidCI5hK.js} +1 -1
- package/ui/dist/assets/{index-DbV9f53B.js → index-CaFoTJlR.js} +8 -8
- package/ui/dist/assets/{index-C9gJqtx4.js → index-GbV8-z5Y.js} +4 -4
- package/ui/dist/assets/{pptxgen.es-CCODGbBd.js → pptxgen.es-BkpMsCHc.js} +1 -1
- package/ui/dist/assets/{promptBuilderStore-CF1EPSCL.js → promptBuilderStore-B7xCm5Ga.js} +1 -1
- package/ui/dist/assets/useAgentDialogFocus-C80ZVSWi.js +1 -0
- package/ui/dist/index.html +1 -1
- package/ui/dist/assets/App-BLBE-fTl.js +0 -9
- package/ui/dist/assets/SettingsWorkspace-BnvKUZsF.js +0 -1
- package/ui/dist/assets/useAgentDialogFocus-CNcAdwxO.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{m as Kr,n as Qa,R as Ja,f as N,j as h}from"./index-DbV9f53B.js";import{u as ae,a as K,r as ec,i as Vt,S as tc,f as nc,g as oc,b as rc,n as ic,c as sc,w as ac,d as cc,e as Qr,h as lc,l as uc,j as dc,k as fc,m as hc,o as Qe,p as pc,q as gc}from"./App-BLBE-fTl.js";import{c as mc}from"./clipboard-DirTPLEi.js";import{A as yc}from"./AssetMediaLightbox-B6YoVErG.js";import"./useAgentDialogFocus-CNcAdwxO.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var xc={value:()=>{}};function an(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Ft(n)}function Ft(e){this._=e}function wc(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Ft.prototype=an.prototype={constructor:Ft,on:function(e,t){var n=this._,o=wc(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=vc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=Po(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Po(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ft(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function vc(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Po(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=xc,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var On="http://www.w3.org/1999/xhtml";const Do={svg:"http://www.w3.org/2000/svg",xhtml:On,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Do.hasOwnProperty(t)?{space:Do[t],local:e}:e}function bc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===On&&t.documentElement.namespaceURI===On?t.createElement(e):t.createElementNS(n,e)}}function _c(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jr(e){var t=cn(e);return(t.local?_c:bc)(t)}function Sc(){}function oo(e){return e==null?Sc:function(){return this.querySelector(e)}}function Ec(e){typeof e!="function"&&(e=oo(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new de(o,this._parents)}function Nc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Cc(){return[]}function ei(e){return e==null?Cc:function(){return this.querySelectorAll(e)}}function Ic(e){return function(){return Nc(e.apply(this,arguments))}}function kc(e){typeof e=="function"?e=Ic(e):e=ei(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(o.push(e.call(c,c.__data__,l,s)),r.push(c));return new de(o,r)}function ti(e){return function(){return this.matches(e)}}function ni(e){return function(t){return t.matches(e)}}var Mc=Array.prototype.find;function Tc(e){return function(){return Mc.call(this.children,e)}}function Ac(){return this.firstElementChild}function Pc(e){return this.select(e==null?Ac:Tc(typeof e=="function"?e:ni(e)))}var Dc=Array.prototype.filter;function jc(){return Array.from(this.children)}function $c(e){return function(){return Dc.call(this.children,e)}}function Rc(e){return this.selectAll(e==null?jc:$c(typeof e=="function"?e:ni(e)))}function Hc(e){typeof e!="function"&&(e=ti(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new de(o,this._parents)}function oi(e){return new Array(e.length)}function Lc(){return new de(this._enter||this._groups.map(oi),this._parents)}function Ut(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ut.prototype={constructor:Ut,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Oc(e){return function(){return e}}function zc(e,t,n,o,r,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Ut(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function Bc(e,t,n,o,r,i,s){var a,c,l=new Map,u=t.length,f=i.length,d=new Array(u),p;for(a=0;a<u;++a)(c=t[a])&&(d[a]=p=s.call(c,c.__data__,a,t)+"",l.has(p)?r[a]=c:l.set(p,c));for(a=0;a<f;++a)p=s.call(e,i[a],a,i)+"",(c=l.get(p))?(o[a]=c,c.__data__=i[a],l.delete(p)):n[a]=new Ut(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(d[a])===c&&(r[a]=c)}function Vc(e){return e.__data__}function Fc(e,t){if(!arguments.length)return Array.from(this,Vc);var n=t?Bc:zc,o=this._parents,r=this._groups;typeof e!="function"&&(e=Oc(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=o[l],f=r[l],d=f.length,p=Yc(e.call(u,u&&u.__data__,l,o)),g=p.length,v=a[l]=new Array(g),w=s[l]=new Array(g),x=c[l]=new Array(d);n(u,f,v,w,x,p,t);for(var S=0,m=0,y,I;S<g;++S)if(y=v[S]){for(S>=m&&(m=S+1);!(I=w[m])&&++m<g;);y._next=I||null}}return s=new de(s,o),s._enter=a,s._exit=c,s}function Yc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Xc(){return new de(this._exit||this._groups.map(oi),this._parents)}function Wc(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function Zc(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),c=0;c<s;++c)for(var l=n[c],u=o[c],f=l.length,d=a[c]=new Array(f),p,g=0;g<f;++g)(p=l[g]||u[g])&&(d[g]=p);for(;c<r;++c)a[c]=n[c];return new de(a,this._parents)}function Gc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Uc(e){e||(e=qc);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,c=r[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new de(r,this._parents).order()}function qc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Kc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qc(){return Array.from(this)}function Jc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function el(){let e=0;for(const t of this)++e;return e}function tl(){return!this.node()}function nl(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function ol(e){return function(){this.removeAttribute(e)}}function rl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function il(e,t){return function(){this.setAttribute(e,t)}}function sl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function al(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function ll(e,t){var n=cn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?rl:ol:typeof t=="function"?n.local?cl:al:n.local?sl:il)(n,t))}function ri(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ul(e){return function(){this.style.removeProperty(e)}}function dl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function fl(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function hl(e,t,n){return arguments.length>1?this.each((t==null?ul:typeof t=="function"?fl:dl)(e,t,n??"")):it(this.node(),e)}function it(e,t){return e.style.getPropertyValue(t)||ri(e).getComputedStyle(e,null).getPropertyValue(t)}function pl(e){return function(){delete this[e]}}function gl(e,t){return function(){this[e]=t}}function ml(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yl(e,t){return arguments.length>1?this.each((t==null?pl:typeof t=="function"?ml:gl)(e,t)):this.node()[e]}function ii(e){return e.trim().split(/^|\s+/)}function ro(e){return e.classList||new si(e)}function si(e){this._node=e,this._names=ii(e.getAttribute("class")||"")}si.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ai(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function ci(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function xl(e){return function(){ai(this,e)}}function wl(e){return function(){ci(this,e)}}function vl(e,t){return function(){(t.apply(this,arguments)?ai:ci)(this,e)}}function bl(e,t){var n=ii(e+"");if(arguments.length<2){for(var o=ro(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?vl:t?xl:wl)(n,t))}function _l(){this.textContent=""}function Sl(e){return function(){this.textContent=e}}function El(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Nl(e){return arguments.length?this.each(e==null?_l:(typeof e=="function"?El:Sl)(e)):this.node().textContent}function Cl(){this.innerHTML=""}function Il(e){return function(){this.innerHTML=e}}function kl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Ml(e){return arguments.length?this.each(e==null?Cl:(typeof e=="function"?kl:Il)(e)):this.node().innerHTML}function Tl(){this.nextSibling&&this.parentNode.appendChild(this)}function Al(){return this.each(Tl)}function Pl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Dl(){return this.each(Pl)}function jl(e){var t=typeof e=="function"?e:Jr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function $l(){return null}function Rl(e,t){var n=typeof e=="function"?e:Jr(e),o=t==null?$l:typeof t=="function"?t:oo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Hl(){var e=this.parentNode;e&&e.removeChild(this)}function Ll(){return this.each(Hl)}function Ol(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bl(e){return this.select(e?zl:Ol)}function Vl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Fl(e){return function(t){e.call(this,t,this.__data__)}}function Yl(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Xl(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Wl(e,t,n){return function(){var o=this.__on,r,i=Fl(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function Zl(e,t,n){var o=Yl(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(r=0,u=a[c];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Wl:Xl,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function li(e,t,n){var o=ri(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Gl(e,t){return function(){return li(this,e,t)}}function Ul(e,t){return function(){return li(this,e,t.apply(this,arguments))}}function ql(e,t){return this.each((typeof t=="function"?Ul:Gl)(e,t))}function*Kl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var ui=[null];function de(e,t){this._groups=e,this._parents=t}function It(){return new de([[document.documentElement]],ui)}function Ql(){return this}de.prototype=It.prototype={constructor:de,select:Ec,selectAll:kc,selectChild:Pc,selectChildren:Rc,filter:Hc,data:Fc,enter:Lc,exit:Xc,join:Wc,merge:Zc,selection:Ql,order:Gc,sort:Uc,call:Kc,nodes:Qc,node:Jc,size:el,empty:tl,each:nl,attr:ll,style:hl,property:yl,classed:bl,text:Nl,html:Ml,raise:Al,lower:Dl,append:jl,insert:Rl,remove:Ll,clone:Bl,datum:Vl,on:Zl,dispatch:ql,[Symbol.iterator]:Kl};function ue(e){return typeof e=="string"?new de([[document.querySelector(e)]],[document.documentElement]):new de([[e]],ui)}function Jl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function he(e,t){if(e=Jl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const eu={passive:!1},xt={capture:!0,passive:!1};function Sn(e){e.stopImmediatePropagation()}function nt(e){e.preventDefault(),e.stopImmediatePropagation()}function di(e){var t=e.document.documentElement,n=ue(e).on("dragstart.drag",nt,xt);"onselectstart"in t?n.on("selectstart.drag",nt,xt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function fi(e,t){var n=e.document.documentElement,o=ue(e).on("dragstart.drag",null);t&&(o.on("click.drag",nt,xt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Dt=e=>()=>e;function zn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}zn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function tu(e){return!e.ctrlKey&&!e.button}function nu(){return this.parentNode}function ou(e,t){return t??{x:e.x,y:e.y}}function ru(){return navigator.maxTouchPoints||"ontouchstart"in this}function hi(){var e=tu,t=nu,n=ou,o=ru,r={},i=an("start","drag","end"),s=0,a,c,l,u,f=0;function d(y){y.on("mousedown.drag",p).filter(o).on("touchstart.drag",w).on("touchmove.drag",x,eu).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(y,I){if(!(u||!e.call(this,y,I))){var b=m(this,t.call(this,y,I),y,I,"mouse");b&&(ue(y.view).on("mousemove.drag",g,xt).on("mouseup.drag",v,xt),di(y.view),Sn(y),l=!1,a=y.clientX,c=y.clientY,b("start",y))}}function g(y){if(nt(y),!l){var I=y.clientX-a,b=y.clientY-c;l=I*I+b*b>f}r.mouse("drag",y)}function v(y){ue(y.view).on("mousemove.drag mouseup.drag",null),fi(y.view,l),nt(y),r.mouse("end",y)}function w(y,I){if(e.call(this,y,I)){var b=y.changedTouches,C=t.call(this,y,I),E=b.length,A,B;for(A=0;A<E;++A)(B=m(this,C,y,I,b[A].identifier,b[A]))&&(Sn(y),B("start",y,b[A]))}}function x(y){var I=y.changedTouches,b=I.length,C,E;for(C=0;C<b;++C)(E=r[I[C].identifier])&&(nt(y),E("drag",y,I[C]))}function S(y){var I=y.changedTouches,b=I.length,C,E;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),C=0;C<b;++C)(E=r[I[C].identifier])&&(Sn(y),E("end",y,I[C]))}function m(y,I,b,C,E,A){var B=i.copy(),T=he(A||b,I),L,H,_;if((_=n.call(y,new zn("beforestart",{sourceEvent:b,target:d,identifier:E,active:s,x:T[0],y:T[1],dx:0,dy:0,dispatch:B}),C))!=null)return L=_.x-T[0]||0,H=_.y-T[1]||0,function k(M,P,j){var $=T,O;switch(M){case"start":r[E]=k,O=s++;break;case"end":delete r[E],--s;case"drag":T=he(j||P,I),O=s;break}B.call(M,y,new zn(M,{sourceEvent:P,subject:_,target:d,identifier:E,active:O,x:T[0]+L,y:T[1]+H,dx:T[0]-$[0],dy:T[1]-$[1],dispatch:B}),C)}}return d.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Dt(!!y),d):e},d.container=function(y){return arguments.length?(t=typeof y=="function"?y:Dt(y),d):t},d.subject=function(y){return arguments.length?(n=typeof y=="function"?y:Dt(y),d):n},d.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:Dt(!!y),d):o},d.on=function(){var y=i.on.apply(i,arguments);return y===i?d:y},d.clickDistance=function(y){return arguments.length?(f=(y=+y)*y,d):Math.sqrt(f)},d}function io(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function pi(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function kt(){}var wt=.7,qt=1/wt,ot="\\s*([+-]?\\d+)\\s*",vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Se="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",iu=/^#([0-9a-f]{3,8})$/,su=new RegExp(`^rgb\\(${ot},${ot},${ot}\\)$`),au=new RegExp(`^rgb\\(${Se},${Se},${Se}\\)$`),cu=new RegExp(`^rgba\\(${ot},${ot},${ot},${vt}\\)$`),lu=new RegExp(`^rgba\\(${Se},${Se},${Se},${vt}\\)$`),uu=new RegExp(`^hsl\\(${vt},${Se},${Se}\\)$`),du=new RegExp(`^hsla\\(${vt},${Se},${Se},${vt}\\)$`),jo={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};io(kt,Xe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$o,formatHex:$o,formatHex8:fu,formatHsl:hu,formatRgb:Ro,toString:Ro});function $o(){return this.rgb().formatHex()}function fu(){return this.rgb().formatHex8()}function hu(){return gi(this).formatHsl()}function Ro(){return this.rgb().formatRgb()}function Xe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=iu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ho(t):n===3?new le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?jt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?jt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=su.exec(e))?new le(t[1],t[2],t[3],1):(t=au.exec(e))?new le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=cu.exec(e))?jt(t[1],t[2],t[3],t[4]):(t=lu.exec(e))?jt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uu.exec(e))?zo(t[1],t[2]/100,t[3]/100,1):(t=du.exec(e))?zo(t[1],t[2]/100,t[3]/100,t[4]):jo.hasOwnProperty(e)?Ho(jo[e]):e==="transparent"?new le(NaN,NaN,NaN,0):null}function Ho(e){return new le(e>>16&255,e>>8&255,e&255,1)}function jt(e,t,n,o){return o<=0&&(e=t=n=NaN),new le(e,t,n,o)}function pu(e){return e instanceof kt||(e=Xe(e)),e?(e=e.rgb(),new le(e.r,e.g,e.b,e.opacity)):new le}function Bn(e,t,n,o){return arguments.length===1?pu(e):new le(e,t,n,o??1)}function le(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}io(le,Bn,pi(kt,{brighter(e){return e=e==null?qt:Math.pow(qt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new le(Fe(this.r),Fe(this.g),Fe(this.b),Kt(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:Lo,formatHex:Lo,formatHex8:gu,formatRgb:Oo,toString:Oo}));function Lo(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function gu(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function Oo(){const e=Kt(this.opacity);return`${e===1?"rgb(":"rgba("}${Fe(this.r)}, ${Fe(this.g)}, ${Fe(this.b)}${e===1?")":`, ${e})`}`}function Kt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Fe(e),(e<16?"0":"")+e.toString(16)}function zo(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new pe(e,t,n,o)}function gi(e){if(e instanceof pe)return new pe(e.h,e.s,e.l,e.opacity);if(e instanceof kt||(e=Xe(e)),!e)return new pe;if(e instanceof pe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,c=(i+r)/2;return a?(t===i?s=(n-o)/a+(n<o)*6:n===i?s=(o-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+r:2-i-r,s*=60):a=c>0&&c<1?0:s,new pe(s,a,c,e.opacity)}function mu(e,t,n,o){return arguments.length===1?gi(e):new pe(e,t,n,o??1)}function pe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}io(pe,mu,pi(kt,{brighter(e){return e=e==null?qt:Math.pow(qt,e),new pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,e),new pe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new le(En(e>=240?e-240:e+120,r,o),En(e,r,o),En(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new pe(Bo(this.h),$t(this.s),$t(this.l),Kt(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=Kt(this.opacity);return`${e===1?"hsl(":"hsla("}${Bo(this.h)}, ${$t(this.s)*100}%, ${$t(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Bo(e){return e=(e||0)%360,e<0?e+360:e}function $t(e){return Math.max(0,Math.min(1,e||0))}function En(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const so=e=>()=>e;function yu(e,t){return function(n){return e+n*t}}function xu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function wu(e){return(e=+e)==1?mi:function(t,n){return n-t?xu(t,n,e):so(isNaN(t)?n:t)}}function mi(e,t){var n=t-e;return n?yu(e,n):so(isNaN(e)?t:e)}const Qt=(function e(t){var n=wu(t);function o(r,i){var s=n((r=Bn(r)).r,(i=Bn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),l=mi(r.opacity,i.opacity);return function(u){return r.r=s(u),r.g=a(u),r.b=c(u),r.opacity=l(u),r+""}}return o.gamma=e,o})(1);function vu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function bu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function _u(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=mt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<o;++s)i[s]=r[s](a);return i}}function Su(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function _e(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Eu(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=mt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var Vn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Nn=new RegExp(Vn.source,"g");function Nu(e){return function(){return e}}function Cu(e){return function(t){return e(t)+""}}function yi(e,t){var n=Vn.lastIndex=Nn.lastIndex=0,o,r,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(o=Vn.exec(e))&&(r=Nn.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:_e(o,r)})),n=Nn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?Cu(c[0].x):Nu(t):(t=c.length,function(l){for(var u=0,f;u<t;++u)a[(f=c[u]).i]=f.x(l);return a.join("")})}function mt(e,t){var n=typeof t,o;return t==null||n==="boolean"?so(t):(n==="number"?_e:n==="string"?(o=Xe(t))?(t=o,Qt):yi:t instanceof Xe?Qt:t instanceof Date?Su:bu(t)?vu:Array.isArray(t)?_u:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Eu:_e)(e,t)}var Vo=180/Math.PI,Fn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xi(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Vo,skewX:Math.atan(c)*Vo,scaleX:s,scaleY:a}}var Rt;function Iu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fn:xi(t.a,t.b,t.c,t.d,t.e,t.f)}function ku(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Fn:(e=e.matrix,xi(e.a,e.b,e.c,e.d,e.e,e.f))}function wi(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,u,f,d,p,g){if(l!==f||u!==d){var v=p.push("translate(",null,t,null,n);g.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f||d)&&p.push("translate("+f+t+d+n)}function s(l,u,f,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:_e(l,u)})):u&&f.push(r(f)+"rotate("+u+o)}function a(l,u,f,d){l!==u?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:_e(l,u)}):u&&f.push(r(f)+"skewX("+u+o)}function c(l,u,f,d,p,g){if(l!==f||u!==d){var v=p.push(r(p)+"scale(",null,",",null,")");g.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f!==1||d!==1)&&p.push(r(p)+"scale("+f+","+d+")")}return function(l,u){var f=[],d=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,f,d),s(l.rotate,u.rotate,f,d),a(l.skewX,u.skewX,f,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,d),l=u=null,function(p){for(var g=-1,v=d.length,w;++g<v;)f[(w=d[g]).i]=w.x(p);return f.join("")}}}var Mu=wi(Iu,"px, ","px)","deg)"),Tu=wi(ku,", ",")",")"),Au=1e-12;function Fo(e){return((e=Math.exp(e))+1/e)/2}function Pu(e){return((e=Math.exp(e))-1/e)/2}function Du(e){return((e=Math.exp(2*e))-1)/(e+1)}const Yt=(function e(t,n,o){function r(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],f=s[1],d=s[2],p=u-a,g=f-c,v=p*p+g*g,w,x;if(v<Au)x=Math.log(d/l)/t,w=function(C){return[a+C*p,c+C*g,l*Math.exp(t*C*x)]};else{var S=Math.sqrt(v),m=(d*d-l*l+o*v)/(2*l*n*S),y=(d*d-l*l-o*v)/(2*d*n*S),I=Math.log(Math.sqrt(m*m+1)-m),b=Math.log(Math.sqrt(y*y+1)-y);x=(b-I)/t,w=function(C){var E=C*x,A=Fo(I),B=l/(n*S)*(A*Du(t*E+I)-Pu(I));return[a+B*p,c+B*g,l*A/Fo(t*E+I)]}}return w.duration=x*1e3*t/Math.SQRT2,w}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r})(Math.SQRT2,2,4);var st=0,pt=0,dt=0,vi=1e3,Jt,gt,en=0,We=0,ln=0,bt=typeof performance=="object"&&performance.now?performance:Date,bi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ao(){return We||(bi(ju),We=bt.now()+ln)}function ju(){We=0}function tn(){this._call=this._time=this._next=null}tn.prototype=_i.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ao():+n)+(t==null?0:+t),!this._next&>!==this&&(gt?gt._next=this:Jt=this,gt=this),this._call=e,this._time=n,Yn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yn())}};function _i(e,t,n){var o=new tn;return o.restart(e,t,n),o}function $u(){ao(),++st;for(var e=Jt,t;e;)(t=We-e._time)>=0&&e._call.call(void 0,t),e=e._next;--st}function Yo(){We=(en=bt.now())+ln,st=pt=0;try{$u()}finally{st=0,Hu(),We=0}}function Ru(){var e=bt.now(),t=e-en;t>vi&&(ln-=t,en=e)}function Hu(){for(var e,t=Jt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);gt=e,Yn(o)}function Yn(e){if(!st){pt&&(pt=clearTimeout(pt));var t=e-We;t>24?(e<1/0&&(pt=setTimeout(Yo,e-bt.now()-ln)),dt&&(dt=clearInterval(dt))):(dt||(en=bt.now(),dt=setInterval(Ru,vi)),st=1,bi(Yo))}}function Xo(e,t,n){var o=new tn;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Lu=an("start","end","cancel","interrupt"),Ou=[],Si=0,Wo=1,Xn=2,Xt=3,Zo=4,Wn=5,Wt=6;function un(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;zu(e,n,{name:t,index:o,group:r,on:Lu,tween:Ou,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Si})}function co(e,t){var n=xe(e,t);if(n.state>Si)throw new Error("too late; already scheduled");return n}function Ee(e,t){var n=xe(e,t);if(n.state>Xt)throw new Error("too late; already running");return n}function xe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function zu(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=_i(i,0,n.time);function i(l){n.state=Wo,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,f,d,p;if(n.state!==Wo)return c();for(u in o)if(p=o[u],p.name===n.name){if(p.state===Xt)return Xo(s);p.state===Zo?(p.state=Wt,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete o[u]):+u<t&&(p.state=Wt,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete o[u])}if(Xo(function(){n.state===Xt&&(n.state=Zo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Xn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xn){for(n.state=Xt,r=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(p=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=p);r.length=f+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Wn,1),f=-1,d=r.length;++f<d;)r[f].call(e,u);n.state===Wn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Wt,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Zt(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>Xn&&o.state<Wn,o.state=Wt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Bu(e){return this.each(function(){Zt(this,e)})}function Vu(e,t){var n,o;return function(){var r=Ee(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function Fu(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Ee(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}i.tween=r}}function Yu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=xe(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?Vu:Fu)(n,e,t))}function lo(e,t,n){var o=e._id;return e.each(function(){var r=Ee(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return xe(r,o).value[t]}}function Ei(e,t){var n;return(typeof t=="number"?_e:t instanceof Xe?Qt:(n=Xe(t))?(t=n,Qt):yi)(e,t)}function Xu(e){return function(){this.removeAttribute(e)}}function Wu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Gu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function Uu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function qu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Ku(e,t){var n=cn(e),o=n==="transform"?Tu:Ei;return this.attrTween(e,typeof t=="function"?(n.local?qu:Uu)(n,o,lo(this,"attr."+e,t)):t==null?(n.local?Wu:Xu)(n):(n.local?Gu:Zu)(n,o,t))}function Qu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Ju(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ed(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Ju(e,i)),n}return r._value=t,r}function td(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Qu(e,i)),n}return r._value=t,r}function nd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=cn(e);return this.tween(n,(o.local?ed:td)(o,t))}function od(e,t){return function(){co(this,e).delay=+t.apply(this,arguments)}}function rd(e,t){return t=+t,function(){co(this,e).delay=t}}function id(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?od:rd)(t,e)):xe(this.node(),t).delay}function sd(e,t){return function(){Ee(this,e).duration=+t.apply(this,arguments)}}function ad(e,t){return t=+t,function(){Ee(this,e).duration=t}}function cd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?sd:ad)(t,e)):xe(this.node(),t).duration}function ld(e,t){if(typeof t!="function")throw new Error;return function(){Ee(this,e).ease=t}}function ud(e){var t=this._id;return arguments.length?this.each(ld(t,e)):xe(this.node(),t).ease}function dd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ee(this,e).ease=n}}function fd(e){if(typeof e!="function")throw new Error;return this.each(dd(this._id,e))}function hd(e){typeof e!="function"&&(e=ti(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Pe(o,this._parents,this._name,this._id)}function pd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,f=s[a]=new Array(u),d,p=0;p<u;++p)(d=c[p]||l[p])&&(f[p]=d);for(;a<o;++a)s[a]=t[a];return new Pe(s,this._parents,this._name,this._id)}function gd(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function md(e,t,n){var o,r,i=gd(t)?co:Ee;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function yd(e,t){var n=this._id;return arguments.length<2?xe(this.node(),n).on.on(e):this.each(md(n,e,t))}function xd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function wd(){return this.on("end.remove",xd(this._id))}function vd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oo(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,l=i[s]=new Array(c),u,f,d=0;d<c;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),l[d]=f,un(l[d],t,n,d,l,xe(u,n)));return new Pe(i,this._parents,t,n)}function bd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ei(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],l=c.length,u,f=0;f<l;++f)if(u=c[f]){for(var d=e.call(u,u.__data__,f,c),p,g=xe(u,n),v=0,w=d.length;v<w;++v)(p=d[v])&&un(p,t,n,v,d,g);i.push(d),s.push(u)}return new Pe(i,s,t,n)}var _d=It.prototype.constructor;function Sd(){return new _d(this._groups,this._parents)}function Ed(e,t){var n,o,r;return function(){var i=it(this,e),s=(this.style.removeProperty(e),it(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Ni(e){return function(){this.style.removeProperty(e)}}function Nd(e,t,n){var o,r=n+"",i;return function(){var s=it(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function Cd(e,t,n){var o,r,i;return function(){var s=it(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),it(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function Id(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=Ee(this,e),l=c.on,u=c.value[i]==null?a||(a=Ni(t)):void 0;(l!==n||r!==u)&&(o=(n=l).copy()).on(s,r=u),c.on=o}}function kd(e,t,n){var o=(e+="")=="transform"?Mu:Ei;return t==null?this.styleTween(e,Ed(e,o)).on("end.style."+e,Ni(e)):typeof t=="function"?this.styleTween(e,Cd(e,o,lo(this,"style."+e,t))).each(Id(this._id,e)):this.styleTween(e,Nd(e,o,t),n).on("end.style."+e,null)}function Md(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Td(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Md(e,s,n)),o}return i._value=t,i}function Ad(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,Td(e,t,n??""))}function Pd(e){return function(){this.textContent=e}}function Dd(e){return function(){var t=e(this);this.textContent=t??""}}function jd(e){return this.tween("text",typeof e=="function"?Dd(lo(this,"text",e)):Pd(e==null?"":e+""))}function $d(e){return function(t){this.textContent=e.call(this,t)}}function Rd(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&$d(r)),t}return o._value=e,o}function Hd(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Rd(e))}function Ld(){for(var e=this._name,t=this._id,n=Ci(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=xe(c,t);un(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Pe(o,this._parents,e,n)}function Od(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var l=Ee(this,o),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&i()})}var zd=0;function Pe(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Ci(){return++zd}var Me=It.prototype;Pe.prototype={constructor:Pe,select:vd,selectAll:bd,selectChild:Me.selectChild,selectChildren:Me.selectChildren,filter:hd,merge:pd,selection:Sd,transition:Ld,call:Me.call,nodes:Me.nodes,node:Me.node,size:Me.size,empty:Me.empty,each:Me.each,on:yd,attr:Ku,attrTween:nd,style:kd,styleTween:Ad,text:jd,textTween:Hd,remove:wd,tween:Yu,delay:id,duration:cd,ease:ud,easeVarying:fd,end:Od,[Symbol.iterator]:Me[Symbol.iterator]};function Bd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Vd={time:null,delay:0,duration:250,ease:Bd};function Fd(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Yd(e){var t,n;e instanceof Pe?(t=e._id,e=e._name):(t=Ci(),(n=Vd).time=ao(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&un(c,e,t,l,s,n||Fd(c,t));return new Pe(o,this._parents,e,t)}It.prototype.interrupt=Bu;It.prototype.transition=Yd;const Ht=e=>()=>e;function Xd(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Te(e,t,n){this.k=e,this.x=t,this.y=n}Te.prototype={constructor:Te,scale:function(e){return e===1?this:new Te(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Te(this.k,this.x+this.k*e,this.y+this.k*t)},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 dn=new Te(1,0,0);Ii.prototype=Te.prototype;function Ii(e){for(;!e.__zoom;)if(!(e=e.parentNode))return dn;return e.__zoom}function Cn(e){e.stopImmediatePropagation()}function ft(e){e.preventDefault(),e.stopImmediatePropagation()}function Wd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Zd(){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 Go(){return this.__zoom||dn}function Gd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ud(){return navigator.maxTouchPoints||"ontouchstart"in this}function qd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function ki(){var e=Wd,t=Zd,n=qd,o=Gd,r=Ud,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Yt,l=an("start","zoom","end"),u,f,d,p=500,g=150,v=0,w=10;function x(_){_.property("__zoom",Go).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",B).filter(r).on("touchstart.zoom",T).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(_,k,M,P){var j=_.selection?_.selection():_;j.property("__zoom",Go),_!==j?I(_,k,M,P):j.interrupt().each(function(){b(this,arguments).event(P).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},x.scaleBy=function(_,k,M,P){x.scaleTo(_,function(){var j=this.__zoom.k,$=typeof k=="function"?k.apply(this,arguments):k;return j*$},M,P)},x.scaleTo=function(_,k,M,P){x.transform(_,function(){var j=t.apply(this,arguments),$=this.__zoom,O=M==null?y(j):typeof M=="function"?M.apply(this,arguments):M,V=$.invert(O),z=typeof k=="function"?k.apply(this,arguments):k;return n(m(S($,z),O,V),j,s)},M,P)},x.translateBy=function(_,k,M,P){x.transform(_,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),s)},null,P)},x.translateTo=function(_,k,M,P,j){x.transform(_,function(){var $=t.apply(this,arguments),O=this.__zoom,V=P==null?y($):typeof P=="function"?P.apply(this,arguments):P;return n(dn.translate(V[0],V[1]).scale(O.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof M=="function"?-M.apply(this,arguments):-M),$,s)},P,j)};function S(_,k){return k=Math.max(i[0],Math.min(i[1],k)),k===_.k?_:new Te(k,_.x,_.y)}function m(_,k,M){var P=k[0]-M[0]*_.k,j=k[1]-M[1]*_.k;return P===_.x&&j===_.y?_:new Te(_.k,P,j)}function y(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function I(_,k,M,P){_.on("start.zoom",function(){b(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event(P).end()}).tween("zoom",function(){var j=this,$=arguments,O=b(j,$).event(P),V=t.apply(j,$),z=M==null?y(V):typeof M=="function"?M.apply(j,$):M,W=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),Y=j.__zoom,Z=typeof k=="function"?k.apply(j,$):k,J=c(Y.invert(z).concat(W/Y.k),Z.invert(z).concat(W/Z.k));return function(R){if(R===1)R=Z;else{var D=J(R),F=W/D[2];R=new Te(F,z[0]-D[0]*F,z[1]-D[1]*F)}O.zoom(null,R)}})}function b(_,k,M){return!M&&_.__zooming||new C(_,k)}function C(_,k){this.that=_,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,k),this.taps=0}C.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,k){return this.mouse&&_!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var k=ue(this.that).datum();l.call(_,this.that,new Xd(_,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:l}),k)}};function E(_,...k){if(!e.apply(this,arguments))return;var M=b(this,k).event(_),P=this.__zoom,j=Math.max(i[0],Math.min(i[1],P.k*Math.pow(2,o.apply(this,arguments)))),$=he(_);if(M.wheel)(M.mouse[0][0]!==$[0]||M.mouse[0][1]!==$[1])&&(M.mouse[1]=P.invert(M.mouse[0]=$)),clearTimeout(M.wheel);else{if(P.k===j)return;M.mouse=[$,P.invert($)],Zt(this),M.start()}ft(_),M.wheel=setTimeout(O,g),M.zoom("mouse",n(m(S(P,j),M.mouse[0],M.mouse[1]),M.extent,s));function O(){M.wheel=null,M.end()}}function A(_,...k){if(d||!e.apply(this,arguments))return;var M=_.currentTarget,P=b(this,k,!0).event(_),j=ue(_.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",W,!0),$=he(_,M),O=_.clientX,V=_.clientY;di(_.view),Cn(_),P.mouse=[$,this.__zoom.invert($)],Zt(this),P.start();function z(Y){if(ft(Y),!P.moved){var Z=Y.clientX-O,J=Y.clientY-V;P.moved=Z*Z+J*J>v}P.event(Y).zoom("mouse",n(m(P.that.__zoom,P.mouse[0]=he(Y,M),P.mouse[1]),P.extent,s))}function W(Y){j.on("mousemove.zoom mouseup.zoom",null),fi(Y.view,P.moved),ft(Y),P.event(Y).end()}}function B(_,...k){if(e.apply(this,arguments)){var M=this.__zoom,P=he(_.changedTouches?_.changedTouches[0]:_,this),j=M.invert(P),$=M.k*(_.shiftKey?.5:2),O=n(m(S(M,$),P,j),t.apply(this,k),s);ft(_),a>0?ue(this).transition().duration(a).call(I,O,P,_):ue(this).call(x.transform,O,P,_)}}function T(_,...k){if(e.apply(this,arguments)){var M=_.touches,P=M.length,j=b(this,k,_.changedTouches.length===P).event(_),$,O,V,z;for(Cn(_),O=0;O<P;++O)V=M[O],z=he(V,this),z=[z,this.__zoom.invert(z),V.identifier],j.touch0?!j.touch1&&j.touch0[2]!==z[2]&&(j.touch1=z,j.taps=0):(j.touch0=z,$=!0,j.taps=1+!!u);u&&(u=clearTimeout(u)),$&&(j.taps<2&&(f=z[0],u=setTimeout(function(){u=null},p)),Zt(this),j.start())}}function L(_,...k){if(this.__zooming){var M=b(this,k).event(_),P=_.changedTouches,j=P.length,$,O,V,z;for(ft(_),$=0;$<j;++$)O=P[$],V=he(O,this),M.touch0&&M.touch0[2]===O.identifier?M.touch0[0]=V:M.touch1&&M.touch1[2]===O.identifier&&(M.touch1[0]=V);if(O=M.that.__zoom,M.touch1){var W=M.touch0[0],Y=M.touch0[1],Z=M.touch1[0],J=M.touch1[1],R=(R=Z[0]-W[0])*R+(R=Z[1]-W[1])*R,D=(D=J[0]-Y[0])*D+(D=J[1]-Y[1])*D;O=S(O,Math.sqrt(R/D)),V=[(W[0]+Z[0])/2,(W[1]+Z[1])/2],z=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(M.touch0)V=M.touch0[0],z=M.touch0[1];else return;M.zoom("touch",n(m(O,V,z),M.extent,s))}}function H(_,...k){if(this.__zooming){var M=b(this,k).event(_),P=_.changedTouches,j=P.length,$,O;for(Cn(_),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),$=0;$<j;++$)O=P[$],M.touch0&&M.touch0[2]===O.identifier?delete M.touch0:M.touch1&&M.touch1[2]===O.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(O=he(O,this),Math.hypot(f[0]-O[0],f[1]-O[1])<w)){var V=ue(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return x.wheelDelta=function(_){return arguments.length?(o=typeof _=="function"?_:Ht(+_),x):o},x.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Ht(!!_),x):e},x.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Ht(!!_),x):r},x.extent=function(_){return arguments.length?(t=typeof _=="function"?_:Ht([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),x):t},x.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],x):[i[0],i[1]]},x.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],x):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},x.constrain=function(_){return arguments.length?(n=_,x):n},x.duration=function(_){return arguments.length?(a=+_,x):a},x.interpolate=function(_){return arguments.length?(c=_,x):c},x.on=function(){var _=l.on.apply(l,arguments);return _===l?x:_},x.clickDistance=function(_){return arguments.length?(v=(_=+_)*_,x):Math.sqrt(v)},x.tapDistance=function(_){return arguments.length?(w=+_,x):w},x}const ye={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 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:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},_t=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Mi=["Enter"," ","Escape"],Ti={"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:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"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 Ze;(function(e){e.Strict="strict",e.Loose="loose"})(Ze||(Ze={}));var Ye;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ye||(Ye={}));var St;(function(e){e.Partial="partial",e.Full="full"})(St||(St={}));const Ai={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Re;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Re||(Re={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Uo={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top},Pi=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Kd=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),uo=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mt=(e,t=[0,0])=>{const{width:n,height:o}=we(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Qd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const o=e.reduce((r,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):uo(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,fn(r,on(a,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?hn(o):{x:0,y:0,width:0,height:0}},Tt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=fn(n,on(r)),o=!0)}),o?hn(n):{x:0,y:0,width:0,height:0}},fo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/r,c=(t.y-o)/r,l=t.width/r,u=t.height/r,f=[];for(const d of e.values()){const{measured:p,selectable:g=!0,hidden:v=!1}=d;if(s&&!g||v)continue;const w=p.width??d.width??d.initialWidth??0,x=p.height??d.height??d.initialHeight??0,{x:S,y:m}=d.internals.positionAbsolute,y=Ri(a,c,l,u,S,m,w,x),I=w*x,b=i&&y>0;(!d.internals.handleBounds||b||y>=I||d.dragging)&&f.push(d)}return f},Jd=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function ef(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let i;if(t?.includeHiddenNodes){const{width:s,height:a}=we(r);i=s>0&&a>0}else i=!!(r.measured.width&&r.measured.height&&!r.hidden);i&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function tf({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return!0;const a=ef(e,s),c=Tt(a),l=po(c,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),!0}function Di({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",ye.error005());else{const{width:p,height:g}=we(a);p&&g&&(f=[[c,l],[c+p,l+g]])}else a&&Ue(s.extent)&&(f=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const d=Ue(f)?Ge(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",ye.error015()),{position:{x:d.x-c+(s.measured.width??0)*u[0],y:d.y-l+(s.measured.height??0)*u[1]},positionAbsolute:d}}async function nf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const p=i.has(d.id),g=!p&&d.parentId&&s.find(v=>v.id===d.parentId);(p||g)&&s.push(d)}const a=new Set(t.map(d=>d.id)),c=o.filter(d=>d.deletable!==!1),u=Jd(s,c);for(const d of c)a.has(d.id)&&!u.find(g=>g.id===d.id)&&u.push(d);if(!r)return{edges:u,nodes:s};const f=await r({nodes:s,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:s}:{edges:[],nodes:[]}:f}const at=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ge=(e={x:0,y:0},t,n)=>({x:at(e.x,t[0][0],t[1][0]-(n?.width??0)),y:at(e.y,t[0][1],t[1][1]-(n?.height??0))});function ji(e,t,n){const{width:o,height:r}=we(n),{x:i,y:s}=n.internals.positionAbsolute;return Ge(e,[[i,s],[i+o,s+r]],t)}const qo=(e,t,n)=>e<t?at(Math.abs(e-t),1,t)/t:e>n?-at(Math.abs(e-n),1,t)/t:0,ho=(e,t,n=15,o=40)=>{const r=qo(e.x,o,t.width-o)*n,i=qo(e.y,o,t.height-o)*n;return[r,i]},fn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),hn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Et=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},on=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},$i=(e,t)=>hn(fn(Zn(e),Zn(t))),Ri=(e,t,n,o,r,i,s,a)=>{const c=Math.max(0,Math.min(e+n,r+s)-Math.max(e,r)),l=Math.max(0,Math.min(t+o,i+a)-Math.max(t,i));return Math.ceil(c*l)},rn=(e,t)=>Ri(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ko=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),Hi=(e,t)=>(n,o)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?At(a,s):a},ct=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Je(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function of(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Je(e,n),r=Je(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Je(e.top??e.y??0,n),r=Je(e.bottom??e.y??0,n),i=Je(e.left??e.x??0,t),s=Je(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function rf(e,t,n,o,r,i){const{x:s,y:a}=ct(e,[t,n,o]),{x:c,y:l}=ct({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-c,f=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(f)}}const po=(e,t,n,o,r,i)=>{const s=of(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=at(l,o,r),f=e.x+e.width/2,d=e.y+e.height/2,p=t/2-f*u,g=n/2-d*u,v=rf(e,p,g,u,t,n),w={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:p-w.left+w.right,y:g-w.top+w.bottom,zoom:u}},Nt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ue(e){return e!=null&&e!=="parent"}function we(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Li(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Oi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Qo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function sf(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function af(e){return{...Ti,...e||{}}}function zi(e){return e===null?null:e?"valid":"invalid"}function yt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=me(e),a=Pt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const go=e=>({width:e.offsetWidth,height:e.offsetHeight}),Bi=e=>e?.getRootNode?.()||window?.document,cf=["INPUT","SELECT","TEXTAREA"];function Vi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:cf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Fi=e=>"clientX"in e,me=(e,t)=>{const n=Fi(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Jo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...go(s)}})};function Yi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+o*.125,u=Math.abs(c-e),f=Math.abs(l-t);return[c,l,u,f]}function Lt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function er({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Lt(t-o,i),n];case X.Right:return[t+Lt(o-t,i),n];case X.Top:return[t,n-Lt(n-r,i)];case X.Bottom:return[t,n+Lt(r-n,i)]}}function Xi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=er({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,u]=er({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,d,p,g]=Yi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${o},${r}`,f,d,p,g]}function Wi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function lf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function uf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=fn(on(e),on(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return rn(s,hn(i))>0}const df=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,ff=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),hf=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",ye.error006()),t;const o=n.getEdgeId||df;let r;return Pi(e)?r={...e}:r={...e,id:o(e)},ff(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Zi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Wi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const tr={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},pf=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},nr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function gf({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=tr[t],c=tr[o],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},f=pf({source:l,sourcePosition:t,target:u}),d=f.x!==0?"x":"y",p=f[d];let g=[],v,w;const x={x:0,y:0},S={x:0,y:0},[,,m,y]=Wi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*c[d]===-1){d==="x"?(v=r.x??l.x+(u.x-l.x)*s,w=r.y??(l.y+u.y)/2):(v=r.x??(l.x+u.x)/2,w=r.y??l.y+(u.y-l.y)*s);const E=[{x:v,y:l.y},{x:v,y:u.y}],A=[{x:l.x,y:w},{x:u.x,y:w}];a[d]===p?g=d==="x"?E:A:g=d==="x"?A:E}else{const E=[{x:l.x,y:u.y}],A=[{x:u.x,y:l.y}];if(d==="x"?g=a.x===p?A:E:g=a.y===p?E:A,t===o){const _=Math.abs(e[d]-n[d]);if(_<=i){const k=Math.min(i-1,i-_);a[d]===p?x[d]=(l[d]>e[d]?-1:1)*k:S[d]=(u[d]>n[d]?-1:1)*k}}if(t!==o){const _=d==="x"?"y":"x",k=a[d]===c[_],M=l[_]>u[_],P=l[_]<u[_];(a[d]===1&&(!k&&M||k&&P)||a[d]!==1&&(!k&&P||k&&M))&&(g=d==="x"?E:A)}const B={x:l.x+x.x,y:l.y+x.y},T={x:u.x+S.x,y:u.y+S.y},L=Math.max(Math.abs(B.x-g[0].x),Math.abs(T.x-g[0].x)),H=Math.max(Math.abs(B.y-g[0].y),Math.abs(T.y-g[0].y));L>=H?(v=(B.x+T.x)/2,w=g[0].y):(v=g[0].x,w=(B.y+T.y)/2)}const I={x:l.x+x.x,y:l.y+x.y},b={x:u.x+S.x,y:u.y+S.y};return[[e,...I.x!==g[0].x||I.y!==g[0].y?[I]:[],...g,...b.x!==g[g.length-1].x||b.y!==g[g.length-1].y?[b]:[],n],v,w,m,y]}function mf(e,t,n,o){const r=Math.min(nr(e,t)/2,nr(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}Q ${i},${s} ${i+r*a},${s}`}function Gn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[f,d,p,g,v]=gf({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let w=`M${f[0].x} ${f[0].y}`;for(let x=1;x<f.length-1;x++)w+=mf(f[x-1],f[x],f[x+1],s);return w+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[w,d,p,g,v]}function or(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function yf(e){const{sourceNode:t,targetNode:n}=e;if(!or(t)||!or(n))return null;const o=t.internals.handleBounds||rr(t.handles),r=n.internals.handleBounds||rr(n.handles),i=ir(o?.source??[],e.sourceHandle),s=ir(e.connectionMode===Ze.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",ye.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||X.Bottom,c=s?.position||X.Top,l=qe(t,i,a),u=qe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function rr(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function qe(e,t,n=X.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??we(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case X.Top:return{x:r+s/2,y:i};case X.Right:return{x:r+s,y:i+a/2};case X.Bottom:return{x:r+s/2,y:i+a};case X.Left:return{x:r,y:i+a/2}}}function ir(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Un(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function xf(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const l=Un(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Gi=1e3,wf=10,mo={nodeOrigin:[0,0],nodeExtent:_t,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},vf={...mo,checkEquality:!0};function yo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function bf(e,t,n){const o=yo(mo,n);for(const r of e.values())if(r.parentId)wo(r,e,t,o);else{const i=Mt(r,o.nodeOrigin),s=Ue(r.extent)?r.extent:o.nodeExtent,a=Ge(i,s,we(r));r.internals.positionAbsolute=a}}function _f(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function xo(e){return e==="manual"}function qn(e,t,n,o={}){const r=yo(vf,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!xo(r.zIndexMode)?Gi:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const u of e){let f=s.get(u.id);if(r.checkEquality&&u===f?.internals.userNode)t.set(u.id,f);else{const d=Mt(u,r.nodeOrigin),p=Ue(u.extent)?u.extent:r.nodeExtent,g=Ge(d,p,we(u));f={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:g,handleBounds:_f(u,f),z:Ui(u,a,r.zIndexMode),userNode:u}},t.set(u.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),u.parentId&&wo(f,t,n,o,i),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Sf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function wo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=yo(mo,o),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Sf(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*wf),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const f=i&&!xo(c)?Gi:0,{x:d,y:p,z:g}=Ef(e,u,s,a,f,c),{positionAbsolute:v}=e.internals,w=d!==v.x||p!==v.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:d,y:p}:v,z:g}})}function Ui(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return xo(n)?o:o+(e.selected?t:0)}function Ef(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=we(e),l=Mt(e,n),u=Ue(e.extent)?Ge(l,e.extent,c):l;let f=Ge({x:s+u.x,y:a+u.y},o,c);e.extent==="parent"&&(f=ji(f,c,t));const d=Ui(e,r,i),p=t.internals.z??0;return{x:f.x,y:f.y,z:p>=d?p+1:d}}function vo(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const c=i.get(s.parentId)?.expandedRect??Et(a),l=$i(c,s.rect);i.set(s.parentId,{expandedRect:l,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},c)=>{const l=a.internals.positionAbsolute,u=we(a),f=a.origin??o,d=s.x<l.x?Math.round(Math.abs(l.x-s.x)):0,p=s.y<l.y?Math.round(Math.abs(l.y-s.y)):0,g=Math.max(u.width,Math.round(s.width)),v=Math.max(u.height,Math.round(s.height)),w=(g-u.width)*f[0],x=(v-u.height)*f[1];(d>0||p>0||w||x)&&(r.push({id:c,type:"position",position:{x:a.position.x-d+w,y:a.position.y-p+x}}),n.get(c)?.forEach(S=>{e.some(m=>m.id===S.id)||r.push({id:S.id,type:"position",position:{x:S.position.x+d,y:S.position.y+p}})})),(u.width<s.width||u.height<s.height||d||p)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(d?f[0]*d-w:0),height:v+(p?f[1]*p-x:0)}})}),r}function Nf(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:f}=new window.DOMMatrixReadOnly(u.transform),d=[];for(const p of e.values()){const g=t.get(p.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const v=go(p.nodeElement),w=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(w||!g.internals.handleBounds||p.force))){const S=p.nodeElement.getBoundingClientRect(),m=Ue(g.extent)?g.extent:i;let{positionAbsolute:y}=g.internals;if(g.parentId&&g.extent==="parent"){const b=t.get(g.parentId);b&&(y=ji(y,v,b))}else m&&(y=Ge(y,m,v));const I={...g,measured:v,internals:{...g.internals,positionAbsolute:y,handleBounds:{source:Jo("source",p.nodeElement,S,f,g.id),target:Jo("target",p.nodeElement,S,f,g.id)}}};t.set(g.id,I),g.parentId&&wo(I,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,w&&(l.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&d.push({id:g.id,parentId:g.parentId,rect:Et(I,r)}))}}if(d.length>0){const p=vo(d,t,n,r);l.push(...p)}return{changes:l,updatedInternals:c}}async function Cf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function sr(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function qi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},l=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;sr("source",c,u,e,r,s),sr("target",c,l,e,i,a),t.set(o.id,o)}}function Ki(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ki(n,t):!1}function ar(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function If(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Ki(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function In({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const c=n.get(s)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function kf({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Mf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,f=!1,d=null,p=!1,g=!1,v=null;function w({noDragClassName:S,handleSelector:m,domNode:y,isSelectable:I,nodeId:b,nodeClickDistance:C=0}){d=ue(y);function E({x:L,y:H}){const{nodeLookup:_,nodeExtent:k,snapGrid:M,snapToGrid:P,nodeOrigin:j,onNodeDrag:$,onSelectionDrag:O,onError:V,updateNodePositions:z}=t();i={x:L,y:H};let W=!1;const Y=a.size>1,Z=Y&&k?Zn(Tt(a)):null,J=Y&&P?kf({dragItems:a,snapGrid:M,x:L,y:H}):null;for(const[R,D]of a){if(!_.has(R))continue;let F={x:L-D.distance.x,y:H-D.distance.y};P&&(F=J?{x:Math.round(F.x+J.x),y:Math.round(F.y+J.y)}:At(F,M));let U=null;if(Y&&k&&!D.extent&&Z){const{positionAbsolute:q}=D.internals,ee=q.x-Z.x+k[0][0],ne=q.x+D.measured.width-Z.x2+k[1][0],oe=q.y-Z.y+k[0][1],ce=q.y+D.measured.height-Z.y2+k[1][1];U=[[ee,oe],[ne,ce]]}const{position:Q,positionAbsolute:G}=Di({nodeId:R,nextPosition:F,nodeLookup:_,nodeExtent:U||k,nodeOrigin:j,onError:V});W=W||D.position.x!==Q.x||D.position.y!==Q.y,D.position=Q,D.internals.positionAbsolute=G}if(g=g||W,!!W&&(z(a,!0),v&&(o||$||!b&&O))){const[R,D]=In({nodeId:b,dragItems:a,nodeLookup:_});o?.(v,a,R,D),$?.(v,R,D),b||O?.(v,D)}}async function A(){if(!u)return;const{transform:L,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:k}=t();if(!k){c=!1,cancelAnimationFrame(s);return}const[M,P]=ho(l,u,_);(M!==0||P!==0)&&(i.x=(i.x??0)-M/L[2],i.y=(i.y??0)-P/L[2],await H({x:M,y:P})&&E(i)),s=requestAnimationFrame(A)}function B(L){const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:k,transform:M,snapGrid:P,snapToGrid:j,selectNodesOnDrag:$,onNodeDragStart:O,onSelectionDragStart:V,unselectNodesAndEdges:z}=t();f=!0,(!$||!I)&&!_&&b&&(H.get(b)?.selected||z()),I&&$&&b&&e?.(b);const W=yt(L.sourceEvent,{transform:M,snapGrid:P,snapToGrid:j,containerBounds:u});if(i=W,a=If(H,k,W,b),a.size>0&&(n||O||!b&&V)){const[Y,Z]=In({nodeId:b,dragItems:a,nodeLookup:H});n?.(L.sourceEvent,a,Y,Z),O?.(L.sourceEvent,Y,Z),b||V?.(L.sourceEvent,Z)}}const T=hi().clickDistance(C).on("start",L=>{const{domNode:H,nodeDragThreshold:_,transform:k,snapGrid:M,snapToGrid:P}=t();u=H?.getBoundingClientRect()||null,p=!1,g=!1,v=L.sourceEvent,_===0&&B(L),i=yt(L.sourceEvent,{transform:k,snapGrid:M,snapToGrid:P,containerBounds:u}),l=me(L.sourceEvent,u)}).on("drag",L=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:k,snapToGrid:M,nodeDragThreshold:P,nodeLookup:j}=t(),$=yt(L.sourceEvent,{transform:_,snapGrid:k,snapToGrid:M,containerBounds:u});if(v=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||b&&!j.has(b))&&(p=!0),!p){if(!c&&H&&f&&(c=!0,A()),!f){const O=me(L.sourceEvent,u),V=O.x-l.x,z=O.y-l.y;Math.sqrt(V*V+z*z)>P&&B(L)}(i.x!==$.xSnapped||i.y!==$.ySnapped)&&a&&f&&(l=me(L.sourceEvent,u),E($))}}).on("end",L=>{if(!f||p){p&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,f=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:k,onSelectionDragStop:M}=t();if(g&&(_(a,!1),g=!1),r||k||!b&&M){const[P,j]=In({nodeId:b,dragItems:a,nodeLookup:H,dragging:!1});r?.(L.sourceEvent,a,P,j),k?.(L.sourceEvent,P,j),b||M?.(L.sourceEvent,j)}}}).filter(L=>{const H=L.target;return!L.button&&(!S||!ar(H,`.${S}`,y))&&(!m||ar(H,m,y))});d.call(T)}function x(){d?.on(".drag",null)}return{update:w,destroy:x}}function Tf(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())rn(r,Et(i))>0&&o.push(i);return o}const Af=250;function Pf(e,t,n,o){let r=[],i=1/0;const s=Tf(e,n,t+Af);for(const a of s){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const l of c){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:u,y:f}=qe(a,l,l.position,!0),d=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));d>t||(d<i?(r=[{...l,x:u,y:f}],i=d):d===i&&r.push({...l,x:u,y:f}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function Qi(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?a?.find(l=>l.id===n):a?.[0])??null;return c&&i?{...c,...qe(s,c,c.position,!0)}:c}function Ji(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Df(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const es=()=>!0;function jf(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:f,panBy:d,cancelConnection:p,onConnectStart:g,onConnect:v,onConnectEnd:w,isValidConnection:x=es,onReconnectEnd:S,updateConnection:m,getTransform:y,getFromHandle:I,autoPanSpeed:b,dragThreshold:C=1,handleDomNode:E}){const A=Bi(e.target);let B=0,T;const{x:L,y:H}=me(e),_=Ji(i,E),k=a?.getBoundingClientRect();let M=!1;if(!k||!_)return;const P=Qi(r,_,o,c,t);if(!P)return;let j=me(e,k),$=!1,O=null,V=!1,z=null;function W(){if(!u||!k)return;const[Q,G]=ho(j,k,b);d({x:Q,y:G}),B=requestAnimationFrame(W)}const Y={...P,nodeId:r,type:_,position:P.position},Z=c.get(r);let R={inProgress:!0,isValid:null,from:qe(Z,Y,X.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:Z,to:j,toHandle:null,toPosition:Uo[Y.position],toNode:null,pointer:j};function D(){M=!0,m(R),g?.(e,{nodeId:r,handleId:o,handleType:_})}C===0&&D();function F(Q){if(!M){const{x:ce,y:Ne}=me(Q),ve=ce-L,be=Ne-H;if(!(ve*ve+be*be>C*C))return;D()}if(!I()||!Y){U(Q);return}const G=y();j=me(Q,k),T=Pf(Pt(j,G,!1,[1,1]),n,c,Y),$||(W(),$=!0);const q=ts(Q,{handle:T,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:x,doc:A,lib:l,flowId:f,nodeLookup:c});z=q.handleDomNode,O=q.connection,V=Df(!!T,q.isValid);const ee=c.get(r),ne=ee?qe(ee,Y,X.Left,!0):R.from,oe={...R,from:ne,isValid:V,to:q.toHandle&&V?ct({x:q.toHandle.x,y:q.toHandle.y},G):j,toHandle:q.toHandle,toPosition:V&&q.toHandle?q.toHandle.position:Uo[Y.position],toNode:q.toHandle?c.get(q.toHandle.nodeId):null,pointer:j};m(oe),R=oe}function U(Q){if(!("touches"in Q&&Q.touches.length>0)){if(M){(T||z)&&O&&V&&v?.(O);const{inProgress:G,...q}=R,ee={...q,toPosition:R.toHandle?R.toPosition:null};w?.(Q,ee),i&&S?.(Q,ee)}p(),cancelAnimationFrame(B),$=!1,V=!1,O=null,z=null,A.removeEventListener("mousemove",F),A.removeEventListener("mouseup",U),A.removeEventListener("touchmove",F),A.removeEventListener("touchend",U)}}A.addEventListener("mousemove",F),A.addEventListener("mouseup",U),A.addEventListener("touchmove",F),A.addEventListener("touchend",U)}function ts(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=es,nodeLookup:u}){const f=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:g}=me(e),v=s.elementFromPoint(p,g),w=v?.classList.contains(`${a}-flow__handle`)?v:d,x={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const S=Ji(void 0,w),m=w.getAttribute("data-nodeid"),y=w.getAttribute("data-handleid"),I=w.classList.contains("connectable"),b=w.classList.contains("connectableend");if(!m||!S)return x;const C={source:f?m:o,sourceHandle:f?y:r,target:f?o:m,targetHandle:f?r:y};x.connection=C;const A=I&&b&&(n===Ze.Strict?f&&S==="source"||!f&&S==="target":m!==o||y!==r);x.isValid=A&&l(C),x.toHandle=Qi(m,S,y,u,n,!0)}return x}const Kn={onPointerDown:jf,isValid:ts};function $f({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ue(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:f=!0,zoomable:d=!0,inversePan:p=!1}){const g=m=>{if(m.sourceEvent.type!=="wheel"||!t)return;const y=n(),I=m.sourceEvent.ctrlKey&&Nt()?10:1,b=-m.sourceEvent.deltaY*(m.sourceEvent.deltaMode===1?.05:m.sourceEvent.deltaMode?1:.002)*u,C=y[2]*Math.pow(2,b*I);t.scaleTo(C)};let v=[0,0];const w=m=>{(m.sourceEvent.type==="mousedown"||m.sourceEvent.type==="touchstart")&&(v=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY])},x=m=>{const y=n();if(m.sourceEvent.type!=="mousemove"&&m.sourceEvent.type!=="touchmove"||!t)return;const I=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY],b=[I[0]-v[0],I[1]-v[1]];v=I;const C=o()*Math.max(y[2],Math.log(y[2]))*(p?-1:1),E={x:y[0]-b[0]*C,y:y[1]-b[1]*C},A=[[0,0],[c,l]];t.setViewportConstrained({x:E.x,y:E.y,zoom:y[2]},A,a)},S=ki().on("start",w).on("zoom",f?x:null).on("zoom.wheel",d?g:null);r.call(S,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:he}}const pn=e=>({x:e.x,y:e.y,zoom:e.k}),kn=({x:e,y:t,zoom:n})=>dn.translate(e,t).scale(n),$e=(e,t)=>e.target.closest(`.${t}`),ns=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Rf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Mn=(e,t=0,n=Rf,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},os=e=>{const t=e.ctrlKey&&Nt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Hf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if($e(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&s){const w=he(u),x=os(u),S=f*Math.pow(2,x);o.scaleTo(n,S,w,u);return}const d=u.deltaMode===1?20:1;let p=r===Ye.Vertical?0:u.deltaX*d,g=r===Ye.Horizontal?0:u.deltaY*d;!Nt()&&u.shiftKey&&r!==Ye.Vertical&&(p=u.deltaY*d,g=0),o.translateBy(n,-(p/f)*i,-(g/f)*i,{internal:!0});const v=pn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,v):(e.isPanScrolling=!0,a?.(u,v)),e.panScrollTimeout=setTimeout(()=>{l?.(u,v),e.isPanScrolling=!1},150)}}function Lf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=$e(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Of({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=pn(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function zf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&ns(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,pn(i.transform))}}function Bf({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&ns(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=pn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function Vf({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:f}){return d=>{const p=t||n,g=o&&d.ctrlKey,v=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&($e(d,`${u}-flow__node`)||$e(d,`${u}-flow__edge`)||$e(d,`${u}-flow__selection`)||$e(d,`${u}-flow__nodesselection`)))return!0;if(!r&&!p&&!i&&!s&&!o||a||f&&!v||$e(d,c)&&v||$e(d,l)&&(!v||i&&v&&!t)||!o&&d.ctrlKey&&v)return!1;if(!o&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!p&&!i&&!g&&v||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const w=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||v||e)&&w}}function Ff({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let f=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(H=>{const _=H[0];_&&(f=[[0,0],[_.contentRect.width,_.contentRect.height]])}):null)?.observe(e);const p=ki().extent(()=>f).scaleExtent([t,n]).translateExtent(o),g=ue(e).call(p);y({x:r.x,y:r.y,zoom:at(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const v=g.on("wheel.zoom"),w=g.on("dblclick.zoom");p.wheelDelta(os);async function x(H,_){return g?new Promise(k=>{p?.interpolate(_?.interpolate==="linear"?mt:Yt).transform(Mn(g,_?.duration,_?.ease,()=>k(!0)),H)}):!1}function S({noWheelClassName:H,noPanClassName:_,onPaneContextMenu:k,userSelectionActive:M,panOnScroll:P,panOnDrag:j,panOnScrollMode:$,panOnScrollSpeed:O,preventScrolling:V,zoomOnPinch:z,zoomOnScroll:W,zoomOnDoubleClick:Y,panActivationKeyPressed:Z=!1,zoomActivationKeyPressed:J,lib:R,onTransformChange:D,connectionInProgress:F,paneClickDistance:U,selectionOnDrag:Q}){M&&!l.isZoomingOrPanning&&m();const G=P&&!J&&!M;p.clickDistance(Q?1/0:!ge(U)||U<0?0:U);const q=G?Hf({zoomPanValues:l,noWheelClassName:H,d3Selection:g,d3Zoom:p,panOnScrollMode:$,panOnScrollSpeed:O,zoomOnPinch:z,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Lf({noWheelClassName:H,preventScrolling:V,d3ZoomHandler:v});g.on("wheel.zoom",q,{passive:!1});const ee=Of({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});p.on("start",ee);const ne=zf({zoomPanValues:l,panOnDrag:j,onPaneContextMenu:!!k,onPanZoom:i,onTransformChange:D});p.on("zoom",ne);const oe=Bf({zoomPanValues:l,panOnDrag:j,panOnScroll:P,onPaneContextMenu:k,onPanZoomEnd:a,onDraggingChange:c});p.on("end",oe);const ce=Vf({panActivationKeyPressed:Z,zoomActivationKeyPressed:J,panOnDrag:j,zoomOnScroll:W,panOnScroll:P,zoomOnDoubleClick:Y,zoomOnPinch:z,userSelectionActive:M,noPanClassName:_,noWheelClassName:H,lib:R,connectionInProgress:F});p.filter(ce),Y?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function m(){p.on("zoom",null)}async function y(H,_,k){const M=kn(H),P=p?.constrain()(M,_,k);return P&&await x(P),P}async function I(H,_){const k=kn(H);return await x(k,_),k}function b(H){if(g){const _=kn(H),k=g.property("__zoom");(k.k!==H.zoom||k.x!==H.x||k.y!==H.y)&&p?.transform(g,_,null,{sync:!0})}}function C(){const H=g?Ii(g.node()):{x:0,y:0,k:1};return{x:H.x,y:H.y,zoom:H.k}}async function E(H,_){return g?new Promise(k=>{p?.interpolate(_?.interpolate==="linear"?mt:Yt).scaleTo(Mn(g,_?.duration,_?.ease,()=>k(!0)),H)}):!1}async function A(H,_){return g?new Promise(k=>{p?.interpolate(_?.interpolate==="linear"?mt:Yt).scaleBy(Mn(g,_?.duration,_?.ease,()=>k(!0)),H)}):!1}function B(H){p?.scaleExtent(H)}function T(H){p?.translateExtent(H)}function L(H){const _=!ge(H)||H<0?0:H;p?.clickDistance(_)}return{update:S,destroy:m,setViewport:I,setViewportConstrained:y,getViewport:C,scaleTo:E,scaleBy:A,setScaleExtent:B,setTranslateExtent:T,syncViewport:b,setClickDistance:L}}var lt;(function(e){e.Line="line",e.Handle="handle"})(lt||(lt={}));function Yf({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function cr(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function De(e,t){return Math.max(0,t-e)}function je(e,t){return Math.max(0,e-t)}function Ot(e,t,n){return Math.max(0,t-e,e-n)}function lr(e,t){return e?!t:t}function Xf(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:f}=t,d=u&&f,{xSnapped:p,ySnapped:g}=n,{minWidth:v,maxWidth:w,minHeight:x,maxHeight:S}=o,{x:m,y,width:I,height:b,aspectRatio:C}=e;let E=Math.floor(u?p-e.pointerX:0),A=Math.floor(f?g-e.pointerY:0);const B=I+(c?-E:E),T=b+(l?-A:A),L=-i[0]*I,H=-i[1]*b;let _=Ot(B,v,w),k=Ot(T,x,S);if(s){let j=0,$=0;c&&E<0?j=De(m+E+L,s[0][0]):!c&&E>0&&(j=je(m+B+L,s[1][0])),l&&A<0?$=De(y+A+H,s[0][1]):!l&&A>0&&($=je(y+T+H,s[1][1])),_=Math.max(_,j),k=Math.max(k,$)}if(a){let j=0,$=0;c&&E>0?j=je(m+E,a[0][0]):!c&&E<0&&(j=De(m+B,a[1][0])),l&&A>0?$=je(y+A,a[0][1]):!l&&A<0&&($=De(y+T,a[1][1])),_=Math.max(_,j),k=Math.max(k,$)}if(r){if(u){const j=Ot(B/C,x,S)*C;if(_=Math.max(_,j),s){let $=0;!c&&!l||c&&!l&&d?$=je(y+H+B/C,s[1][1])*C:$=De(y+H+(c?E:-E)/C,s[0][1])*C,_=Math.max(_,$)}if(a){let $=0;!c&&!l||c&&!l&&d?$=De(y+B/C,a[1][1])*C:$=je(y+(c?E:-E)/C,a[0][1])*C,_=Math.max(_,$)}}if(f){const j=Ot(T*C,v,w)/C;if(k=Math.max(k,j),s){let $=0;!c&&!l||l&&!c&&d?$=je(m+T*C+L,s[1][0])/C:$=De(m+(l?A:-A)*C+L,s[0][0])/C,k=Math.max(k,$)}if(a){let $=0;!c&&!l||l&&!c&&d?$=De(m+T*C,a[1][0])/C:$=je(m+(l?A:-A)*C,a[0][0])/C,k=Math.max(k,$)}}}A=A+(A<0?k:-k),E=E+(E<0?_:-_),r&&(d?B>T*C?A=(lr(c,l)?-E:E)/C:E=(lr(c,l)?-A:A)*C:u?(A=E/C,l=c):(E=A*C,c=l));const M=c?m+E:m,P=l?y+A:y;return{width:I+(c?-E:E),height:b+(l?-A:A),x:i[0]*E*(c?-1:1)+M,y:i[1]*A*(l?-1:1)+P}}const rs={width:0,height:0,x:0,y:0},Wf={...rs,pointerX:0,pointerY:0,aspectRatio:1};function Zf(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function Gf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ue(e);let s={controlDirection:cr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:f,resizeDirection:d,onResizeStart:p,onResize:g,onResizeEnd:v,shouldResize:w}){let x={...rs},S={...Wf};s={boundaries:u,resizeDirection:d,keepAspectRatio:f,controlDirection:cr(l)};let m,y=null,I=[],b,C,E,A=!1;const B=hi().on("start",T=>{const{nodeLookup:L,transform:H,snapGrid:_,snapToGrid:k,nodeOrigin:M,paneDomNode:P}=n();if(m=L.get(t),!m)return;y=P?.getBoundingClientRect()??null;const{xSnapped:j,ySnapped:$}=yt(T.sourceEvent,{transform:H,snapGrid:_,snapToGrid:k,containerBounds:y});x={width:m.measured.width??0,height:m.measured.height??0,x:m.position.x??0,y:m.position.y??0},S={...x,pointerX:j,pointerY:$,aspectRatio:x.width/x.height},b=void 0,C=Ue(m.extent)?m.extent:void 0,m.parentId&&(m.extent==="parent"||m.expandParent)&&(b=L.get(m.parentId)),b&&m.extent==="parent"&&(C=[[0,0],[b.measured.width,b.measured.height]]),I=[],E=void 0;for(const[O,V]of L)if(V.parentId===t&&(I.push({id:O,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const z=Zf(V,m,V.origin??M);E?E=[[Math.min(z[0][0],E[0][0]),Math.min(z[0][1],E[0][1])],[Math.max(z[1][0],E[1][0]),Math.max(z[1][1],E[1][1])]]:E=z}p?.(T,{...x})}).on("drag",T=>{const{transform:L,snapGrid:H,snapToGrid:_,nodeOrigin:k}=n(),M=yt(T.sourceEvent,{transform:L,snapGrid:H,snapToGrid:_,containerBounds:y}),P=[];if(!m)return;const{x:j,y:$,width:O,height:V}=x,z={},W=m.origin??k,{width:Y,height:Z,x:J,y:R}=Xf(S,s.controlDirection,M,s.boundaries,s.keepAspectRatio,W,C,E),D=Y!==O,F=Z!==V,U=J!==j&&D,Q=R!==$&&F;if(!U&&!Q&&!D&&!F)return;if((U||Q||W[0]===1||W[1]===1)&&(z.x=U?J:x.x,z.y=Q?R:x.y,x.x=z.x,x.y=z.y,I.length>0)){const ne=J-j,oe=R-$;for(const ce of I)ce.position={x:ce.position.x-ne+W[0]*(Y-O),y:ce.position.y-oe+W[1]*(Z-V)},P.push(ce)}if((D||F)&&(z.width=D&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:x.width,z.height=F&&(!s.resizeDirection||s.resizeDirection==="vertical")?Z:x.height,x.width=z.width,x.height=z.height),b&&m.expandParent){const ne=W[0]*(z.width??0);z.x&&z.x<ne&&(x.x=ne,S.x=S.x-(z.x-ne));const oe=W[1]*(z.height??0);z.y&&z.y<oe&&(x.y=oe,S.y=S.y-(z.y-oe))}const G=Yf({width:x.width,prevWidth:O,height:x.height,prevHeight:V,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),q={...x,direction:G};w?.(T,q)!==!1&&(A=!0,g?.(T,q),o(z,P))}).on("end",T=>{A&&(v?.(T,{...x}),r?.({...x}),A=!1)});i.call(B)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var Tn={exports:{}},An={},Pn={exports:{}},Dn={};var ur;function Uf(){if(ur)return Dn;ur=1;var e=Kr();function t(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(f,d){var p=d(),g=o({inst:{value:p,getSnapshot:d}}),v=g[0].inst,w=g[1];return i(function(){v.value=p,v.getSnapshot=d,c(v)&&w({inst:v})},[f,p,d]),r(function(){return c(v)&&w({inst:v}),f(function(){c(v)&&w({inst:v})})},[f]),s(p),p}function c(f){var d=f.getSnapshot;f=f.value;try{var p=d();return!n(f,p)}catch{return!0}}function l(f,d){return d()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Dn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Dn}var dr;function qf(){return dr||(dr=1,Pn.exports=Uf()),Pn.exports}var fr;function Kf(){if(fr)return An;fr=1;var e=Kr(),t=qf();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return An.useSyncExternalStoreWithSelector=function(l,u,f,d,p){var g=i(null);if(g.current===null){var v={hasValue:!1,value:null};g.current=v}else v=g.current;g=a(function(){function x(b){if(!S){if(S=!0,m=b,b=d(b),p!==void 0&&v.hasValue){var C=v.value;if(p(C,b))return y=C}return y=b}if(C=y,o(m,b))return C;var E=d(b);return p!==void 0&&p(C,E)?(m=b,C):(m=b,y=E)}var S=!1,m,y,I=f===void 0?null:f;return[function(){return x(u())},I===null?void 0:function(){return x(I())}]},[u,f,d,p]);var w=r(l,g[0],g[1]);return s(function(){v.hasValue=!0,v.value=w},[w]),c(w),w},An}var hr;function Qf(){return hr||(hr=1,Tn.exports=Kf()),Tn.exports}var Jf=Qf();const eh=Qa(Jf),th={},pr=e=>{let t;const n=new Set,o=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const p=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(g=>g(t,p))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(th?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,c);return c},nh=e=>e?pr(e):pr,{useDebugValue:oh}=Ja,{useSyncExternalStoreWithSelector:rh}=eh,ih=e=>e;function is(e,t=ih,n){const o=rh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return oh(o),o}const gr=(e,t)=>{const n=nh(e),o=(r,i=t)=>is(n,r,i);return Object.assign(o,n),o},sh=(e,t)=>e?gr(e,t):gr;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const gn=N.createContext(null),ah=gn.Provider,ss=ye.error001("react");function te(e,t){const n=N.useContext(gn);if(n===null)throw new Error(ss);return is(n,e,t)}function re(){const e=N.useContext(gn);if(e===null)throw new Error(ss);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const mr={display:"none"},ch={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},as="react-flow__node-desc",cs="react-flow__edge-desc",lh="react-flow__aria-live",uh=e=>e.ariaLiveMessage,dh=e=>e.ariaLabelConfig;function fh({rfId:e}){const t=te(uh);return h.jsx("div",{id:`${lh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ch,children:t})}function hh({rfId:e,disableKeyboardA11y:t}){const n=te(dh);return h.jsxs(h.Fragment,{children:[h.jsx("div",{id:`${as}-${e}`,style:mr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),h.jsx("div",{id:`${cs}-${e}`,style:mr,children:n["edge.a11yDescription.default"]}),!t&&h.jsx(fh,{rfId:e})]})}const Ke=N.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return h.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Ke.displayName="Panel";const yr="https://reactflow.dev?utm_source=attribution";function ph({proOptions:e,position:t="bottom-right"}){return N.useEffect(()=>{},[]),e?.hideAttribution?null:h.jsx(Ke,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${yr}`,children:h.jsx("a",{href:yr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const gh=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},zt=e=>e.id;function mh(e,t){return ie(e.selectedNodes.map(zt),t.selectedNodes.map(zt))&&ie(e.selectedEdges.map(zt),t.selectedEdges.map(zt))}function yh({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:o}=te(gh,mh);return N.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const xh=e=>!!e.onSelectionChangeHandlers;function wh({onSelectionChange:e}){const t=te(xh);return e||t?h.jsx(yh,{onSelectionChange:e}):null}const ls=[0,0],vh={x:0,y:0,zoom:1},bh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],xr=[...bh,"rfId"],_h=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),wr={translateExtent:_t,nodeOrigin:ls,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Sh(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(_h,ie),l=re();N.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=wr,a()}),[]);const u=N.useRef(wr);return N.useEffect(()=>{for(const f of xr){const d=e[f],p=u.current[f];d!==p&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?i(d):f==="nodeExtent"?s(d):f==="ariaLabelConfig"?l.setState({ariaLabelConfig:af(d)}):f==="fitView"?l.setState({fitViewQueued:d}):f==="fitViewOptions"?l.setState({fitViewOptions:d}):l.setState({[f]:d})))}u.current=e},xr.map(f=>e[f])),null}function vr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Eh(e){const[t,n]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){n(e);return}const o=vr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:vr()?.matches?"dark":"light"}const br=typeof document<"u"?document:null;function Ct(e=null,t={target:br,actInsideInputWithModifier:!0}){const[n,o]=N.useState(!1),r=N.useRef(!1),i=N.useRef(new Set([])),[s,a]=N.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace(/\+/g,`
|
|
1
|
+
import{m as Kr,n as Qa,R as Ja,f as N,j as h}from"./index-CaFoTJlR.js";import{u as ae,a as K,r as ec,i as Vt,S as tc,f as nc,g as oc,b as rc,n as ic,c as sc,w as ac,d as cc,e as Qr,h as lc,l as uc,j as dc,k as fc,m as hc,o as Qe,p as pc,q as gc}from"./App-B7t5h5M_.js";import{c as mc}from"./clipboard-DirTPLEi.js";import{A as yc}from"./AssetMediaLightbox-DOP-l7is.js";import"./useAgentDialogFocus-C80ZVSWi.js";function se(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=se(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var xc={value:()=>{}};function an(){for(var e=0,t=arguments.length,n={},o;e<t;++e){if(!(o=arguments[e]+"")||o in n||/[\s.]/.test(o))throw new Error("illegal type: "+o);n[o]=[]}return new Ft(n)}function Ft(e){this._=e}function wc(e,t){return e.trim().split(/^|\s+/).map(function(n){var o="",r=n.indexOf(".");if(r>=0&&(o=n.slice(r+1),n=n.slice(0,r)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:o}})}Ft.prototype=an.prototype={constructor:Ft,on:function(e,t){var n=this._,o=wc(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=vc(n[r],e.name)))return r;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<s;)if(r=(e=o[i]).type)n[r]=Po(n[r],e.name,t);else if(t==null)for(r in n)n[r]=Po(n[r],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ft(e)},call:function(e,t){if((r=arguments.length-2)>0)for(var n=new Array(r),o=0,r,i;o<r;++o)n[o]=arguments[o+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],o=0,r=i.length;o<r;++o)i[o].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)}};function vc(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function Po(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=xc,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var On="http://www.w3.org/1999/xhtml";const Do={svg:"http://www.w3.org/2000/svg",xhtml:On,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function cn(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Do.hasOwnProperty(t)?{space:Do[t],local:e}:e}function bc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===On&&t.documentElement.namespaceURI===On?t.createElement(e):t.createElementNS(n,e)}}function _c(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Jr(e){var t=cn(e);return(t.local?_c:bc)(t)}function Sc(){}function oo(e){return e==null?Sc:function(){return this.querySelector(e)}}function Ec(e){typeof e!="function"&&(e=oo(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=new Array(s),c,l,u=0;u<s;++u)(c=i[u])&&(l=e.call(c,c.__data__,u,i))&&("__data__"in c&&(l.__data__=c.__data__),a[u]=l);return new de(o,this._parents)}function Nc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Cc(){return[]}function ei(e){return e==null?Cc:function(){return this.querySelectorAll(e)}}function Ic(e){return function(){return Nc(e.apply(this,arguments))}}function kc(e){typeof e=="function"?e=Ic(e):e=ei(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&(o.push(e.call(c,c.__data__,l,s)),r.push(c));return new de(o,r)}function ti(e){return function(){return this.matches(e)}}function ni(e){return function(t){return t.matches(e)}}var Mc=Array.prototype.find;function Tc(e){return function(){return Mc.call(this.children,e)}}function Ac(){return this.firstElementChild}function Pc(e){return this.select(e==null?Ac:Tc(typeof e=="function"?e:ni(e)))}var Dc=Array.prototype.filter;function jc(){return Array.from(this.children)}function $c(e){return function(){return Dc.call(this.children,e)}}function Rc(e){return this.selectAll(e==null?jc:$c(typeof e=="function"?e:ni(e)))}function Hc(e){typeof e!="function"&&(e=ti(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new de(o,this._parents)}function oi(e){return new Array(e.length)}function Lc(){return new de(this._enter||this._groups.map(oi),this._parents)}function Ut(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ut.prototype={constructor:Ut,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Oc(e){return function(){return e}}function zc(e,t,n,o,r,i){for(var s=0,a,c=t.length,l=i.length;s<l;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Ut(e,i[s]);for(;s<c;++s)(a=t[s])&&(r[s]=a)}function Bc(e,t,n,o,r,i,s){var a,c,l=new Map,u=t.length,f=i.length,d=new Array(u),p;for(a=0;a<u;++a)(c=t[a])&&(d[a]=p=s.call(c,c.__data__,a,t)+"",l.has(p)?r[a]=c:l.set(p,c));for(a=0;a<f;++a)p=s.call(e,i[a],a,i)+"",(c=l.get(p))?(o[a]=c,c.__data__=i[a],l.delete(p)):n[a]=new Ut(e,i[a]);for(a=0;a<u;++a)(c=t[a])&&l.get(d[a])===c&&(r[a]=c)}function Vc(e){return e.__data__}function Fc(e,t){if(!arguments.length)return Array.from(this,Vc);var n=t?Bc:zc,o=this._parents,r=this._groups;typeof e!="function"&&(e=Oc(e));for(var i=r.length,s=new Array(i),a=new Array(i),c=new Array(i),l=0;l<i;++l){var u=o[l],f=r[l],d=f.length,p=Yc(e.call(u,u&&u.__data__,l,o)),g=p.length,v=a[l]=new Array(g),w=s[l]=new Array(g),x=c[l]=new Array(d);n(u,f,v,w,x,p,t);for(var S=0,m=0,y,I;S<g;++S)if(y=v[S]){for(S>=m&&(m=S+1);!(I=w[m])&&++m<g;);y._next=I||null}}return s=new de(s,o),s._enter=a,s._exit=c,s}function Yc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Xc(){return new de(this._exit||this._groups.map(oi),this._parents)}function Wc(e,t,n){var o=this.enter(),r=this,i=this.exit();return typeof e=="function"?(o=e(o),o&&(o=o.selection())):o=o.append(e+""),t!=null&&(r=t(r),r&&(r=r.selection())),n==null?i.remove():n(i),o&&r?o.merge(r).order():r}function Zc(e){for(var t=e.selection?e.selection():e,n=this._groups,o=t._groups,r=n.length,i=o.length,s=Math.min(r,i),a=new Array(r),c=0;c<s;++c)for(var l=n[c],u=o[c],f=l.length,d=a[c]=new Array(f),p,g=0;g<f;++g)(p=l[g]||u[g])&&(d[g]=p);for(;c<r;++c)a[c]=n[c];return new de(a,this._parents)}function Gc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var o=e[t],r=o.length-1,i=o[r],s;--r>=0;)(s=o[r])&&(i&&s.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(s,i),i=s);return this}function Uc(e){e||(e=qc);function t(f,d){return f&&d?e(f.__data__,d.__data__):!f-!d}for(var n=this._groups,o=n.length,r=new Array(o),i=0;i<o;++i){for(var s=n[i],a=s.length,c=r[i]=new Array(a),l,u=0;u<a;++u)(l=s[u])&&(c[u]=l);c.sort(t)}return new de(r,this._parents).order()}function qc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Kc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Qc(){return Array.from(this)}function Jc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length;r<i;++r){var s=o[r];if(s)return s}return null}function el(){let e=0;for(const t of this)++e;return e}function tl(){return!this.node()}function nl(e){for(var t=this._groups,n=0,o=t.length;n<o;++n)for(var r=t[n],i=0,s=r.length,a;i<s;++i)(a=r[i])&&e.call(a,a.__data__,i,r);return this}function ol(e){return function(){this.removeAttribute(e)}}function rl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function il(e,t){return function(){this.setAttribute(e,t)}}function sl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function al(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function cl(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function ll(e,t){var n=cn(e);if(arguments.length<2){var o=this.node();return n.local?o.getAttributeNS(n.space,n.local):o.getAttribute(n)}return this.each((t==null?n.local?rl:ol:typeof t=="function"?n.local?cl:al:n.local?sl:il)(n,t))}function ri(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ul(e){return function(){this.style.removeProperty(e)}}function dl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function fl(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function hl(e,t,n){return arguments.length>1?this.each((t==null?ul:typeof t=="function"?fl:dl)(e,t,n??"")):it(this.node(),e)}function it(e,t){return e.style.getPropertyValue(t)||ri(e).getComputedStyle(e,null).getPropertyValue(t)}function pl(e){return function(){delete this[e]}}function gl(e,t){return function(){this[e]=t}}function ml(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function yl(e,t){return arguments.length>1?this.each((t==null?pl:typeof t=="function"?ml:gl)(e,t)):this.node()[e]}function ii(e){return e.trim().split(/^|\s+/)}function ro(e){return e.classList||new si(e)}function si(e){this._node=e,this._names=ii(e.getAttribute("class")||"")}si.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function ai(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function ci(e,t){for(var n=ro(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function xl(e){return function(){ai(this,e)}}function wl(e){return function(){ci(this,e)}}function vl(e,t){return function(){(t.apply(this,arguments)?ai:ci)(this,e)}}function bl(e,t){var n=ii(e+"");if(arguments.length<2){for(var o=ro(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?vl:t?xl:wl)(n,t))}function _l(){this.textContent=""}function Sl(e){return function(){this.textContent=e}}function El(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Nl(e){return arguments.length?this.each(e==null?_l:(typeof e=="function"?El:Sl)(e)):this.node().textContent}function Cl(){this.innerHTML=""}function Il(e){return function(){this.innerHTML=e}}function kl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Ml(e){return arguments.length?this.each(e==null?Cl:(typeof e=="function"?kl:Il)(e)):this.node().innerHTML}function Tl(){this.nextSibling&&this.parentNode.appendChild(this)}function Al(){return this.each(Tl)}function Pl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Dl(){return this.each(Pl)}function jl(e){var t=typeof e=="function"?e:Jr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function $l(){return null}function Rl(e,t){var n=typeof e=="function"?e:Jr(e),o=t==null?$l:typeof t=="function"?t:oo(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Hl(){var e=this.parentNode;e&&e.removeChild(this)}function Ll(){return this.each(Hl)}function Ol(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Bl(e){return this.select(e?zl:Ol)}function Vl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Fl(e){return function(t){e.call(this,t,this.__data__)}}function Yl(e){return e.trim().split(/^|\s+/).map(function(t){var n="",o=t.indexOf(".");return o>=0&&(n=t.slice(o+1),t=t.slice(0,o)),{type:t,name:n}})}function Xl(e){return function(){var t=this.__on;if(t){for(var n=0,o=-1,r=t.length,i;n<r;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++o]=i;++o?t.length=o:delete this.__on}}}function Wl(e,t,n){return function(){var o=this.__on,r,i=Fl(t);if(o){for(var s=0,a=o.length;s<a;++s)if((r=o[s]).type===e.type&&r.name===e.name){this.removeEventListener(r.type,r.listener,r.options),this.addEventListener(r.type,r.listener=i,r.options=n),r.value=t;return}}this.addEventListener(e.type,i,n),r={type:e.type,name:e.name,value:t,listener:i,options:n},o?o.push(r):this.__on=[r]}}function Zl(e,t,n){var o=Yl(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,u;c<l;++c)for(r=0,u=a[c];r<i;++r)if((s=o[r]).type===u.type&&s.name===u.name)return u.value}return}for(a=t?Wl:Xl,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function li(e,t,n){var o=ri(e),r=o.CustomEvent;typeof r=="function"?r=new r(t,n):(r=o.document.createEvent("Event"),n?(r.initEvent(t,n.bubbles,n.cancelable),r.detail=n.detail):r.initEvent(t,!1,!1)),e.dispatchEvent(r)}function Gl(e,t){return function(){return li(this,e,t)}}function Ul(e,t){return function(){return li(this,e,t.apply(this,arguments))}}function ql(e,t){return this.each((typeof t=="function"?Ul:Gl)(e,t))}function*Kl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var o=e[t],r=0,i=o.length,s;r<i;++r)(s=o[r])&&(yield s)}var ui=[null];function de(e,t){this._groups=e,this._parents=t}function It(){return new de([[document.documentElement]],ui)}function Ql(){return this}de.prototype=It.prototype={constructor:de,select:Ec,selectAll:kc,selectChild:Pc,selectChildren:Rc,filter:Hc,data:Fc,enter:Lc,exit:Xc,join:Wc,merge:Zc,selection:Ql,order:Gc,sort:Uc,call:Kc,nodes:Qc,node:Jc,size:el,empty:tl,each:nl,attr:ll,style:hl,property:yl,classed:bl,text:Nl,html:Ml,raise:Al,lower:Dl,append:jl,insert:Rl,remove:Ll,clone:Bl,datum:Vl,on:Zl,dispatch:ql,[Symbol.iterator]:Kl};function ue(e){return typeof e=="string"?new de([[document.querySelector(e)]],[document.documentElement]):new de([[e]],ui)}function Jl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function he(e,t){if(e=Jl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const eu={passive:!1},xt={capture:!0,passive:!1};function Sn(e){e.stopImmediatePropagation()}function nt(e){e.preventDefault(),e.stopImmediatePropagation()}function di(e){var t=e.document.documentElement,n=ue(e).on("dragstart.drag",nt,xt);"onselectstart"in t?n.on("selectstart.drag",nt,xt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function fi(e,t){var n=e.document.documentElement,o=ue(e).on("dragstart.drag",null);t&&(o.on("click.drag",nt,xt),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Dt=e=>()=>e;function zn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:s,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}zn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function tu(e){return!e.ctrlKey&&!e.button}function nu(){return this.parentNode}function ou(e,t){return t??{x:e.x,y:e.y}}function ru(){return navigator.maxTouchPoints||"ontouchstart"in this}function hi(){var e=tu,t=nu,n=ou,o=ru,r={},i=an("start","drag","end"),s=0,a,c,l,u,f=0;function d(y){y.on("mousedown.drag",p).filter(o).on("touchstart.drag",w).on("touchmove.drag",x,eu).on("touchend.drag touchcancel.drag",S).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function p(y,I){if(!(u||!e.call(this,y,I))){var b=m(this,t.call(this,y,I),y,I,"mouse");b&&(ue(y.view).on("mousemove.drag",g,xt).on("mouseup.drag",v,xt),di(y.view),Sn(y),l=!1,a=y.clientX,c=y.clientY,b("start",y))}}function g(y){if(nt(y),!l){var I=y.clientX-a,b=y.clientY-c;l=I*I+b*b>f}r.mouse("drag",y)}function v(y){ue(y.view).on("mousemove.drag mouseup.drag",null),fi(y.view,l),nt(y),r.mouse("end",y)}function w(y,I){if(e.call(this,y,I)){var b=y.changedTouches,C=t.call(this,y,I),E=b.length,A,B;for(A=0;A<E;++A)(B=m(this,C,y,I,b[A].identifier,b[A]))&&(Sn(y),B("start",y,b[A]))}}function x(y){var I=y.changedTouches,b=I.length,C,E;for(C=0;C<b;++C)(E=r[I[C].identifier])&&(nt(y),E("drag",y,I[C]))}function S(y){var I=y.changedTouches,b=I.length,C,E;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),C=0;C<b;++C)(E=r[I[C].identifier])&&(Sn(y),E("end",y,I[C]))}function m(y,I,b,C,E,A){var B=i.copy(),T=he(A||b,I),L,H,_;if((_=n.call(y,new zn("beforestart",{sourceEvent:b,target:d,identifier:E,active:s,x:T[0],y:T[1],dx:0,dy:0,dispatch:B}),C))!=null)return L=_.x-T[0]||0,H=_.y-T[1]||0,function k(M,P,j){var $=T,O;switch(M){case"start":r[E]=k,O=s++;break;case"end":delete r[E],--s;case"drag":T=he(j||P,I),O=s;break}B.call(M,y,new zn(M,{sourceEvent:P,subject:_,target:d,identifier:E,active:O,x:T[0]+L,y:T[1]+H,dx:T[0]-$[0],dy:T[1]-$[1],dispatch:B}),C)}}return d.filter=function(y){return arguments.length?(e=typeof y=="function"?y:Dt(!!y),d):e},d.container=function(y){return arguments.length?(t=typeof y=="function"?y:Dt(y),d):t},d.subject=function(y){return arguments.length?(n=typeof y=="function"?y:Dt(y),d):n},d.touchable=function(y){return arguments.length?(o=typeof y=="function"?y:Dt(!!y),d):o},d.on=function(){var y=i.on.apply(i,arguments);return y===i?d:y},d.clickDistance=function(y){return arguments.length?(f=(y=+y)*y,d):Math.sqrt(f)},d}function io(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function pi(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function kt(){}var wt=.7,qt=1/wt,ot="\\s*([+-]?\\d+)\\s*",vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Se="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",iu=/^#([0-9a-f]{3,8})$/,su=new RegExp(`^rgb\\(${ot},${ot},${ot}\\)$`),au=new RegExp(`^rgb\\(${Se},${Se},${Se}\\)$`),cu=new RegExp(`^rgba\\(${ot},${ot},${ot},${vt}\\)$`),lu=new RegExp(`^rgba\\(${Se},${Se},${Se},${vt}\\)$`),uu=new RegExp(`^hsl\\(${vt},${Se},${Se}\\)$`),du=new RegExp(`^hsla\\(${vt},${Se},${Se},${vt}\\)$`),jo={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};io(kt,Xe,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:$o,formatHex:$o,formatHex8:fu,formatHsl:hu,formatRgb:Ro,toString:Ro});function $o(){return this.rgb().formatHex()}function fu(){return this.rgb().formatHex8()}function hu(){return gi(this).formatHsl()}function Ro(){return this.rgb().formatRgb()}function Xe(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=iu.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Ho(t):n===3?new le(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?jt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?jt(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=su.exec(e))?new le(t[1],t[2],t[3],1):(t=au.exec(e))?new le(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=cu.exec(e))?jt(t[1],t[2],t[3],t[4]):(t=lu.exec(e))?jt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=uu.exec(e))?zo(t[1],t[2]/100,t[3]/100,1):(t=du.exec(e))?zo(t[1],t[2]/100,t[3]/100,t[4]):jo.hasOwnProperty(e)?Ho(jo[e]):e==="transparent"?new le(NaN,NaN,NaN,0):null}function Ho(e){return new le(e>>16&255,e>>8&255,e&255,1)}function jt(e,t,n,o){return o<=0&&(e=t=n=NaN),new le(e,t,n,o)}function pu(e){return e instanceof kt||(e=Xe(e)),e?(e=e.rgb(),new le(e.r,e.g,e.b,e.opacity)):new le}function Bn(e,t,n,o){return arguments.length===1?pu(e):new le(e,t,n,o??1)}function le(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}io(le,Bn,pi(kt,{brighter(e){return e=e==null?qt:Math.pow(qt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,e),new le(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new le(Fe(this.r),Fe(this.g),Fe(this.b),Kt(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:Lo,formatHex:Lo,formatHex8:gu,formatRgb:Oo,toString:Oo}));function Lo(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}`}function gu(){return`#${Ve(this.r)}${Ve(this.g)}${Ve(this.b)}${Ve((isNaN(this.opacity)?1:this.opacity)*255)}`}function Oo(){const e=Kt(this.opacity);return`${e===1?"rgb(":"rgba("}${Fe(this.r)}, ${Fe(this.g)}, ${Fe(this.b)}${e===1?")":`, ${e})`}`}function Kt(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fe(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ve(e){return e=Fe(e),(e<16?"0":"")+e.toString(16)}function zo(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new pe(e,t,n,o)}function gi(e){if(e instanceof pe)return new pe(e.h,e.s,e.l,e.opacity);if(e instanceof kt||(e=Xe(e)),!e)return new pe;if(e instanceof pe)return e;e=e.rgb();var t=e.r/255,n=e.g/255,o=e.b/255,r=Math.min(t,n,o),i=Math.max(t,n,o),s=NaN,a=i-r,c=(i+r)/2;return a?(t===i?s=(n-o)/a+(n<o)*6:n===i?s=(o-t)/a+2:s=(t-n)/a+4,a/=c<.5?i+r:2-i-r,s*=60):a=c>0&&c<1?0:s,new pe(s,a,c,e.opacity)}function mu(e,t,n,o){return arguments.length===1?gi(e):new pe(e,t,n,o??1)}function pe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}io(pe,mu,pi(kt,{brighter(e){return e=e==null?qt:Math.pow(qt,e),new pe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?wt:Math.pow(wt,e),new pe(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,o=n+(n<.5?n:1-n)*t,r=2*n-o;return new le(En(e>=240?e-240:e+120,r,o),En(e,r,o),En(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new pe(Bo(this.h),$t(this.s),$t(this.l),Kt(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=Kt(this.opacity);return`${e===1?"hsl(":"hsla("}${Bo(this.h)}, ${$t(this.s)*100}%, ${$t(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Bo(e){return e=(e||0)%360,e<0?e+360:e}function $t(e){return Math.max(0,Math.min(1,e||0))}function En(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const so=e=>()=>e;function yu(e,t){return function(n){return e+n*t}}function xu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(o){return Math.pow(e+o*t,n)}}function wu(e){return(e=+e)==1?mi:function(t,n){return n-t?xu(t,n,e):so(isNaN(t)?n:t)}}function mi(e,t){var n=t-e;return n?yu(e,n):so(isNaN(e)?t:e)}const Qt=(function e(t){var n=wu(t);function o(r,i){var s=n((r=Bn(r)).r,(i=Bn(i)).r),a=n(r.g,i.g),c=n(r.b,i.b),l=mi(r.opacity,i.opacity);return function(u){return r.r=s(u),r.g=a(u),r.b=c(u),r.opacity=l(u),r+""}}return o.gamma=e,o})(1);function vu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,o=t.slice(),r;return function(i){for(r=0;r<n;++r)o[r]=e[r]*(1-i)+t[r]*i;return o}}function bu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function _u(e,t){var n=t?t.length:0,o=e?Math.min(n,e.length):0,r=new Array(o),i=new Array(n),s;for(s=0;s<o;++s)r[s]=mt(e[s],t[s]);for(;s<n;++s)i[s]=t[s];return function(a){for(s=0;s<o;++s)i[s]=r[s](a);return i}}function Su(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function _e(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Eu(e,t){var n={},o={},r;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(r in t)r in e?n[r]=mt(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var Vn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Nn=new RegExp(Vn.source,"g");function Nu(e){return function(){return e}}function Cu(e){return function(t){return e(t)+""}}function yi(e,t){var n=Vn.lastIndex=Nn.lastIndex=0,o,r,i,s=-1,a=[],c=[];for(e=e+"",t=t+"";(o=Vn.exec(e))&&(r=Nn.exec(t));)(i=r.index)>n&&(i=t.slice(n,i),a[s]?a[s]+=i:a[++s]=i),(o=o[0])===(r=r[0])?a[s]?a[s]+=r:a[++s]=r:(a[++s]=null,c.push({i:s,x:_e(o,r)})),n=Nn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?c[0]?Cu(c[0].x):Nu(t):(t=c.length,function(l){for(var u=0,f;u<t;++u)a[(f=c[u]).i]=f.x(l);return a.join("")})}function mt(e,t){var n=typeof t,o;return t==null||n==="boolean"?so(t):(n==="number"?_e:n==="string"?(o=Xe(t))?(t=o,Qt):yi:t instanceof Xe?Qt:t instanceof Date?Su:bu(t)?vu:Array.isArray(t)?_u:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Eu:_e)(e,t)}var Vo=180/Math.PI,Fn={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function xi(e,t,n,o,r,i){var s,a,c;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(c=e*n+t*o)&&(n-=e*c,o-=t*c),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,c/=a),e*o<t*n&&(e=-e,t=-t,c=-c,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Vo,skewX:Math.atan(c)*Vo,scaleX:s,scaleY:a}}var Rt;function Iu(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Fn:xi(t.a,t.b,t.c,t.d,t.e,t.f)}function ku(e){return e==null||(Rt||(Rt=document.createElementNS("http://www.w3.org/2000/svg","g")),Rt.setAttribute("transform",e),!(e=Rt.transform.baseVal.consolidate()))?Fn:(e=e.matrix,xi(e.a,e.b,e.c,e.d,e.e,e.f))}function wi(e,t,n,o){function r(l){return l.length?l.pop()+" ":""}function i(l,u,f,d,p,g){if(l!==f||u!==d){var v=p.push("translate(",null,t,null,n);g.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f||d)&&p.push("translate("+f+t+d+n)}function s(l,u,f,d){l!==u?(l-u>180?u+=360:u-l>180&&(l+=360),d.push({i:f.push(r(f)+"rotate(",null,o)-2,x:_e(l,u)})):u&&f.push(r(f)+"rotate("+u+o)}function a(l,u,f,d){l!==u?d.push({i:f.push(r(f)+"skewX(",null,o)-2,x:_e(l,u)}):u&&f.push(r(f)+"skewX("+u+o)}function c(l,u,f,d,p,g){if(l!==f||u!==d){var v=p.push(r(p)+"scale(",null,",",null,")");g.push({i:v-4,x:_e(l,f)},{i:v-2,x:_e(u,d)})}else(f!==1||d!==1)&&p.push(r(p)+"scale("+f+","+d+")")}return function(l,u){var f=[],d=[];return l=e(l),u=e(u),i(l.translateX,l.translateY,u.translateX,u.translateY,f,d),s(l.rotate,u.rotate,f,d),a(l.skewX,u.skewX,f,d),c(l.scaleX,l.scaleY,u.scaleX,u.scaleY,f,d),l=u=null,function(p){for(var g=-1,v=d.length,w;++g<v;)f[(w=d[g]).i]=w.x(p);return f.join("")}}}var Mu=wi(Iu,"px, ","px)","deg)"),Tu=wi(ku,", ",")",")"),Au=1e-12;function Fo(e){return((e=Math.exp(e))+1/e)/2}function Pu(e){return((e=Math.exp(e))-1/e)/2}function Du(e){return((e=Math.exp(2*e))-1)/(e+1)}const Yt=(function e(t,n,o){function r(i,s){var a=i[0],c=i[1],l=i[2],u=s[0],f=s[1],d=s[2],p=u-a,g=f-c,v=p*p+g*g,w,x;if(v<Au)x=Math.log(d/l)/t,w=function(C){return[a+C*p,c+C*g,l*Math.exp(t*C*x)]};else{var S=Math.sqrt(v),m=(d*d-l*l+o*v)/(2*l*n*S),y=(d*d-l*l-o*v)/(2*d*n*S),I=Math.log(Math.sqrt(m*m+1)-m),b=Math.log(Math.sqrt(y*y+1)-y);x=(b-I)/t,w=function(C){var E=C*x,A=Fo(I),B=l/(n*S)*(A*Du(t*E+I)-Pu(I));return[a+B*p,c+B*g,l*A/Fo(t*E+I)]}}return w.duration=x*1e3*t/Math.SQRT2,w}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,c=a*a;return e(s,a,c)},r})(Math.SQRT2,2,4);var st=0,pt=0,dt=0,vi=1e3,Jt,gt,en=0,We=0,ln=0,bt=typeof performance=="object"&&performance.now?performance:Date,bi=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ao(){return We||(bi(ju),We=bt.now()+ln)}function ju(){We=0}function tn(){this._call=this._time=this._next=null}tn.prototype=_i.prototype={constructor:tn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ao():+n)+(t==null?0:+t),!this._next&>!==this&&(gt?gt._next=this:Jt=this,gt=this),this._call=e,this._time=n,Yn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yn())}};function _i(e,t,n){var o=new tn;return o.restart(e,t,n),o}function $u(){ao(),++st;for(var e=Jt,t;e;)(t=We-e._time)>=0&&e._call.call(void 0,t),e=e._next;--st}function Yo(){We=(en=bt.now())+ln,st=pt=0;try{$u()}finally{st=0,Hu(),We=0}}function Ru(){var e=bt.now(),t=e-en;t>vi&&(ln-=t,en=e)}function Hu(){for(var e,t=Jt,n,o=1/0;t;)t._call?(o>t._time&&(o=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jt=n);gt=e,Yn(o)}function Yn(e){if(!st){pt&&(pt=clearTimeout(pt));var t=e-We;t>24?(e<1/0&&(pt=setTimeout(Yo,e-bt.now()-ln)),dt&&(dt=clearInterval(dt))):(dt||(en=bt.now(),dt=setInterval(Ru,vi)),st=1,bi(Yo))}}function Xo(e,t,n){var o=new tn;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var Lu=an("start","end","cancel","interrupt"),Ou=[],Si=0,Wo=1,Xn=2,Xt=3,Zo=4,Wn=5,Wt=6;function un(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;zu(e,n,{name:t,index:o,group:r,on:Lu,tween:Ou,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:Si})}function co(e,t){var n=xe(e,t);if(n.state>Si)throw new Error("too late; already scheduled");return n}function Ee(e,t){var n=xe(e,t);if(n.state>Xt)throw new Error("too late; already running");return n}function xe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function zu(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=_i(i,0,n.time);function i(l){n.state=Wo,n.timer.restart(s,n.delay,n.time),n.delay<=l&&s(l-n.delay)}function s(l){var u,f,d,p;if(n.state!==Wo)return c();for(u in o)if(p=o[u],p.name===n.name){if(p.state===Xt)return Xo(s);p.state===Zo?(p.state=Wt,p.timer.stop(),p.on.call("interrupt",e,e.__data__,p.index,p.group),delete o[u]):+u<t&&(p.state=Wt,p.timer.stop(),p.on.call("cancel",e,e.__data__,p.index,p.group),delete o[u])}if(Xo(function(){n.state===Xt&&(n.state=Zo,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=Xn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xn){for(n.state=Xt,r=new Array(d=n.tween.length),u=0,f=-1;u<d;++u)(p=n.tween[u].value.call(e,e.__data__,n.index,n.group))&&(r[++f]=p);r.length=f+1}}function a(l){for(var u=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=Wn,1),f=-1,d=r.length;++f<d;)r[f].call(e,u);n.state===Wn&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Wt,n.timer.stop(),delete o[t];for(var l in o)return;delete e.__transition}}function Zt(e,t){var n=e.__transition,o,r,i=!0,s;if(n){t=t==null?null:t+"";for(s in n){if((o=n[s]).name!==t){i=!1;continue}r=o.state>Xn&&o.state<Wn,o.state=Wt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Bu(e){return this.each(function(){Zt(this,e)})}function Vu(e,t){var n,o;return function(){var r=Ee(this,e),i=r.tween;if(i!==n){o=n=i;for(var s=0,a=o.length;s<a;++s)if(o[s].name===t){o=o.slice(),o.splice(s,1);break}}r.tween=o}}function Fu(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=Ee(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},c=0,l=r.length;c<l;++c)if(r[c].name===t){r[c]=a;break}c===l&&r.push(a)}i.tween=r}}function Yu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=xe(this.node(),n).tween,r=0,i=o.length,s;r<i;++r)if((s=o[r]).name===e)return s.value;return null}return this.each((t==null?Vu:Fu)(n,e,t))}function lo(e,t,n){var o=e._id;return e.each(function(){var r=Ee(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return xe(r,o).value[t]}}function Ei(e,t){var n;return(typeof t=="number"?_e:t instanceof Xe?Qt:(n=Xe(t))?(t=n,Qt):yi)(e,t)}function Xu(e){return function(){this.removeAttribute(e)}}function Wu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Zu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttribute(e);return s===r?null:s===o?i:i=t(o=s,n)}}function Gu(e,t,n){var o,r=n+"",i;return function(){var s=this.getAttributeNS(e.space,e.local);return s===r?null:s===o?i:i=t(o=s,n)}}function Uu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function qu(e,t,n){var o,r,i;return function(){var s,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),c=a+"",s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a)))}}function Ku(e,t){var n=cn(e),o=n==="transform"?Tu:Ei;return this.attrTween(e,typeof t=="function"?(n.local?qu:Uu)(n,o,lo(this,"attr."+e,t)):t==null?(n.local?Wu:Xu)(n):(n.local?Gu:Zu)(n,o,t))}function Qu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Ju(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ed(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Ju(e,i)),n}return r._value=t,r}function td(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&Qu(e,i)),n}return r._value=t,r}function nd(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var o=cn(e);return this.tween(n,(o.local?ed:td)(o,t))}function od(e,t){return function(){co(this,e).delay=+t.apply(this,arguments)}}function rd(e,t){return t=+t,function(){co(this,e).delay=t}}function id(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?od:rd)(t,e)):xe(this.node(),t).delay}function sd(e,t){return function(){Ee(this,e).duration=+t.apply(this,arguments)}}function ad(e,t){return t=+t,function(){Ee(this,e).duration=t}}function cd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?sd:ad)(t,e)):xe(this.node(),t).duration}function ld(e,t){if(typeof t!="function")throw new Error;return function(){Ee(this,e).ease=t}}function ud(e){var t=this._id;return arguments.length?this.each(ld(t,e)):xe(this.node(),t).ease}function dd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ee(this,e).ease=n}}function fd(e){if(typeof e!="function")throw new Error;return this.each(dd(this._id,e))}function hd(e){typeof e!="function"&&(e=ti(e));for(var t=this._groups,n=t.length,o=new Array(n),r=0;r<n;++r)for(var i=t[r],s=i.length,a=o[r]=[],c,l=0;l<s;++l)(c=i[l])&&e.call(c,c.__data__,l,i)&&a.push(c);return new Pe(o,this._parents,this._name,this._id)}function pd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,o=t.length,r=n.length,i=Math.min(o,r),s=new Array(o),a=0;a<i;++a)for(var c=t[a],l=n[a],u=c.length,f=s[a]=new Array(u),d,p=0;p<u;++p)(d=c[p]||l[p])&&(f[p]=d);for(;a<o;++a)s[a]=t[a];return new Pe(s,this._parents,this._name,this._id)}function gd(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function md(e,t,n){var o,r,i=gd(t)?co:Ee;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function yd(e,t){var n=this._id;return arguments.length<2?xe(this.node(),n).on.on(e):this.each(md(n,e,t))}function xd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function wd(){return this.on("end.remove",xd(this._id))}function vd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oo(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],c=a.length,l=i[s]=new Array(c),u,f,d=0;d<c;++d)(u=a[d])&&(f=e.call(u,u.__data__,d,a))&&("__data__"in u&&(f.__data__=u.__data__),l[d]=f,un(l[d],t,n,d,l,xe(u,n)));return new Pe(i,this._parents,t,n)}function bd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ei(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var c=o[a],l=c.length,u,f=0;f<l;++f)if(u=c[f]){for(var d=e.call(u,u.__data__,f,c),p,g=xe(u,n),v=0,w=d.length;v<w;++v)(p=d[v])&&un(p,t,n,v,d,g);i.push(d),s.push(u)}return new Pe(i,s,t,n)}var _d=It.prototype.constructor;function Sd(){return new _d(this._groups,this._parents)}function Ed(e,t){var n,o,r;return function(){var i=it(this,e),s=(this.style.removeProperty(e),it(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Ni(e){return function(){this.style.removeProperty(e)}}function Nd(e,t,n){var o,r=n+"",i;return function(){var s=it(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function Cd(e,t,n){var o,r,i;return function(){var s=it(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),it(this,e))),s===c?null:s===o&&c===r?i:(r=c,i=t(o=s,a))}}function Id(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var c=Ee(this,e),l=c.on,u=c.value[i]==null?a||(a=Ni(t)):void 0;(l!==n||r!==u)&&(o=(n=l).copy()).on(s,r=u),c.on=o}}function kd(e,t,n){var o=(e+="")=="transform"?Mu:Ei;return t==null?this.styleTween(e,Ed(e,o)).on("end.style."+e,Ni(e)):typeof t=="function"?this.styleTween(e,Cd(e,o,lo(this,"style."+e,t))).each(Id(this._id,e)):this.styleTween(e,Nd(e,o,t),n).on("end.style."+e,null)}function Md(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Td(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Md(e,s,n)),o}return i._value=t,i}function Ad(e,t,n){var o="style."+(e+="");if(arguments.length<2)return(o=this.tween(o))&&o._value;if(t==null)return this.tween(o,null);if(typeof t!="function")throw new Error;return this.tween(o,Td(e,t,n??""))}function Pd(e){return function(){this.textContent=e}}function Dd(e){return function(){var t=e(this);this.textContent=t??""}}function jd(e){return this.tween("text",typeof e=="function"?Dd(lo(this,"text",e)):Pd(e==null?"":e+""))}function $d(e){return function(t){this.textContent=e.call(this,t)}}function Rd(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&$d(r)),t}return o._value=e,o}function Hd(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Rd(e))}function Ld(){for(var e=this._name,t=this._id,n=Ci(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)if(c=s[l]){var u=xe(c,t);un(c,e,n,l,s,{time:u.time+u.delay+u.duration,delay:0,duration:u.duration,ease:u.ease})}return new Pe(o,this._parents,e,n)}function Od(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},c={value:function(){--r===0&&i()}};n.each(function(){var l=Ee(this,o),u=l.on;u!==e&&(t=(e=u).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),r===0&&i()})}var zd=0;function Pe(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Ci(){return++zd}var Me=It.prototype;Pe.prototype={constructor:Pe,select:vd,selectAll:bd,selectChild:Me.selectChild,selectChildren:Me.selectChildren,filter:hd,merge:pd,selection:Sd,transition:Ld,call:Me.call,nodes:Me.nodes,node:Me.node,size:Me.size,empty:Me.empty,each:Me.each,on:yd,attr:Ku,attrTween:nd,style:kd,styleTween:Ad,text:jd,textTween:Hd,remove:wd,tween:Yu,delay:id,duration:cd,ease:ud,easeVarying:fd,end:Od,[Symbol.iterator]:Me[Symbol.iterator]};function Bd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Vd={time:null,delay:0,duration:250,ease:Bd};function Fd(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Yd(e){var t,n;e instanceof Pe?(t=e._id,e=e._name):(t=Ci(),(n=Vd).time=ao(),e=e==null?null:e+"");for(var o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,c,l=0;l<a;++l)(c=s[l])&&un(c,e,t,l,s,n||Fd(c,t));return new Pe(o,this._parents,e,t)}It.prototype.interrupt=Bu;It.prototype.transition=Yd;const Ht=e=>()=>e;function Xd(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function Te(e,t,n){this.k=e,this.x=t,this.y=n}Te.prototype={constructor:Te,scale:function(e){return e===1?this:new Te(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Te(this.k,this.x+this.k*e,this.y+this.k*t)},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 dn=new Te(1,0,0);Ii.prototype=Te.prototype;function Ii(e){for(;!e.__zoom;)if(!(e=e.parentNode))return dn;return e.__zoom}function Cn(e){e.stopImmediatePropagation()}function ft(e){e.preventDefault(),e.stopImmediatePropagation()}function Wd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Zd(){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 Go(){return this.__zoom||dn}function Gd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ud(){return navigator.maxTouchPoints||"ontouchstart"in this}function qd(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],i=e.invertY(t[0][1])-n[0][1],s=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),s>i?(i+s)/2:Math.min(0,i)||Math.max(0,s))}function ki(){var e=Wd,t=Zd,n=qd,o=Gd,r=Ud,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,c=Yt,l=an("start","zoom","end"),u,f,d,p=500,g=150,v=0,w=10;function x(_){_.property("__zoom",Go).on("wheel.zoom",E,{passive:!1}).on("mousedown.zoom",A).on("dblclick.zoom",B).filter(r).on("touchstart.zoom",T).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",H).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}x.transform=function(_,k,M,P){var j=_.selection?_.selection():_;j.property("__zoom",Go),_!==j?I(_,k,M,P):j.interrupt().each(function(){b(this,arguments).event(P).start().zoom(null,typeof k=="function"?k.apply(this,arguments):k).end()})},x.scaleBy=function(_,k,M,P){x.scaleTo(_,function(){var j=this.__zoom.k,$=typeof k=="function"?k.apply(this,arguments):k;return j*$},M,P)},x.scaleTo=function(_,k,M,P){x.transform(_,function(){var j=t.apply(this,arguments),$=this.__zoom,O=M==null?y(j):typeof M=="function"?M.apply(this,arguments):M,V=$.invert(O),z=typeof k=="function"?k.apply(this,arguments):k;return n(m(S($,z),O,V),j,s)},M,P)},x.translateBy=function(_,k,M,P){x.transform(_,function(){return n(this.__zoom.translate(typeof k=="function"?k.apply(this,arguments):k,typeof M=="function"?M.apply(this,arguments):M),t.apply(this,arguments),s)},null,P)},x.translateTo=function(_,k,M,P,j){x.transform(_,function(){var $=t.apply(this,arguments),O=this.__zoom,V=P==null?y($):typeof P=="function"?P.apply(this,arguments):P;return n(dn.translate(V[0],V[1]).scale(O.k).translate(typeof k=="function"?-k.apply(this,arguments):-k,typeof M=="function"?-M.apply(this,arguments):-M),$,s)},P,j)};function S(_,k){return k=Math.max(i[0],Math.min(i[1],k)),k===_.k?_:new Te(k,_.x,_.y)}function m(_,k,M){var P=k[0]-M[0]*_.k,j=k[1]-M[1]*_.k;return P===_.x&&j===_.y?_:new Te(_.k,P,j)}function y(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function I(_,k,M,P){_.on("start.zoom",function(){b(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){b(this,arguments).event(P).end()}).tween("zoom",function(){var j=this,$=arguments,O=b(j,$).event(P),V=t.apply(j,$),z=M==null?y(V):typeof M=="function"?M.apply(j,$):M,W=Math.max(V[1][0]-V[0][0],V[1][1]-V[0][1]),Y=j.__zoom,Z=typeof k=="function"?k.apply(j,$):k,J=c(Y.invert(z).concat(W/Y.k),Z.invert(z).concat(W/Z.k));return function(R){if(R===1)R=Z;else{var D=J(R),F=W/D[2];R=new Te(F,z[0]-D[0]*F,z[1]-D[1]*F)}O.zoom(null,R)}})}function b(_,k,M){return!M&&_.__zooming||new C(_,k)}function C(_,k){this.that=_,this.args=k,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,k),this.taps=0}C.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,k){return this.mouse&&_!=="mouse"&&(this.mouse[1]=k.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=k.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=k.invert(this.touch1[0])),this.that.__zoom=k,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var k=ue(this.that).datum();l.call(_,this.that,new Xd(_,{sourceEvent:this.sourceEvent,target:x,transform:this.that.__zoom,dispatch:l}),k)}};function E(_,...k){if(!e.apply(this,arguments))return;var M=b(this,k).event(_),P=this.__zoom,j=Math.max(i[0],Math.min(i[1],P.k*Math.pow(2,o.apply(this,arguments)))),$=he(_);if(M.wheel)(M.mouse[0][0]!==$[0]||M.mouse[0][1]!==$[1])&&(M.mouse[1]=P.invert(M.mouse[0]=$)),clearTimeout(M.wheel);else{if(P.k===j)return;M.mouse=[$,P.invert($)],Zt(this),M.start()}ft(_),M.wheel=setTimeout(O,g),M.zoom("mouse",n(m(S(P,j),M.mouse[0],M.mouse[1]),M.extent,s));function O(){M.wheel=null,M.end()}}function A(_,...k){if(d||!e.apply(this,arguments))return;var M=_.currentTarget,P=b(this,k,!0).event(_),j=ue(_.view).on("mousemove.zoom",z,!0).on("mouseup.zoom",W,!0),$=he(_,M),O=_.clientX,V=_.clientY;di(_.view),Cn(_),P.mouse=[$,this.__zoom.invert($)],Zt(this),P.start();function z(Y){if(ft(Y),!P.moved){var Z=Y.clientX-O,J=Y.clientY-V;P.moved=Z*Z+J*J>v}P.event(Y).zoom("mouse",n(m(P.that.__zoom,P.mouse[0]=he(Y,M),P.mouse[1]),P.extent,s))}function W(Y){j.on("mousemove.zoom mouseup.zoom",null),fi(Y.view,P.moved),ft(Y),P.event(Y).end()}}function B(_,...k){if(e.apply(this,arguments)){var M=this.__zoom,P=he(_.changedTouches?_.changedTouches[0]:_,this),j=M.invert(P),$=M.k*(_.shiftKey?.5:2),O=n(m(S(M,$),P,j),t.apply(this,k),s);ft(_),a>0?ue(this).transition().duration(a).call(I,O,P,_):ue(this).call(x.transform,O,P,_)}}function T(_,...k){if(e.apply(this,arguments)){var M=_.touches,P=M.length,j=b(this,k,_.changedTouches.length===P).event(_),$,O,V,z;for(Cn(_),O=0;O<P;++O)V=M[O],z=he(V,this),z=[z,this.__zoom.invert(z),V.identifier],j.touch0?!j.touch1&&j.touch0[2]!==z[2]&&(j.touch1=z,j.taps=0):(j.touch0=z,$=!0,j.taps=1+!!u);u&&(u=clearTimeout(u)),$&&(j.taps<2&&(f=z[0],u=setTimeout(function(){u=null},p)),Zt(this),j.start())}}function L(_,...k){if(this.__zooming){var M=b(this,k).event(_),P=_.changedTouches,j=P.length,$,O,V,z;for(ft(_),$=0;$<j;++$)O=P[$],V=he(O,this),M.touch0&&M.touch0[2]===O.identifier?M.touch0[0]=V:M.touch1&&M.touch1[2]===O.identifier&&(M.touch1[0]=V);if(O=M.that.__zoom,M.touch1){var W=M.touch0[0],Y=M.touch0[1],Z=M.touch1[0],J=M.touch1[1],R=(R=Z[0]-W[0])*R+(R=Z[1]-W[1])*R,D=(D=J[0]-Y[0])*D+(D=J[1]-Y[1])*D;O=S(O,Math.sqrt(R/D)),V=[(W[0]+Z[0])/2,(W[1]+Z[1])/2],z=[(Y[0]+J[0])/2,(Y[1]+J[1])/2]}else if(M.touch0)V=M.touch0[0],z=M.touch0[1];else return;M.zoom("touch",n(m(O,V,z),M.extent,s))}}function H(_,...k){if(this.__zooming){var M=b(this,k).event(_),P=_.changedTouches,j=P.length,$,O;for(Cn(_),d&&clearTimeout(d),d=setTimeout(function(){d=null},p),$=0;$<j;++$)O=P[$],M.touch0&&M.touch0[2]===O.identifier?delete M.touch0:M.touch1&&M.touch1[2]===O.identifier&&delete M.touch1;if(M.touch1&&!M.touch0&&(M.touch0=M.touch1,delete M.touch1),M.touch0)M.touch0[1]=this.__zoom.invert(M.touch0[0]);else if(M.end(),M.taps===2&&(O=he(O,this),Math.hypot(f[0]-O[0],f[1]-O[1])<w)){var V=ue(this).on("dblclick.zoom");V&&V.apply(this,arguments)}}}return x.wheelDelta=function(_){return arguments.length?(o=typeof _=="function"?_:Ht(+_),x):o},x.filter=function(_){return arguments.length?(e=typeof _=="function"?_:Ht(!!_),x):e},x.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:Ht(!!_),x):r},x.extent=function(_){return arguments.length?(t=typeof _=="function"?_:Ht([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),x):t},x.scaleExtent=function(_){return arguments.length?(i[0]=+_[0],i[1]=+_[1],x):[i[0],i[1]]},x.translateExtent=function(_){return arguments.length?(s[0][0]=+_[0][0],s[1][0]=+_[1][0],s[0][1]=+_[0][1],s[1][1]=+_[1][1],x):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},x.constrain=function(_){return arguments.length?(n=_,x):n},x.duration=function(_){return arguments.length?(a=+_,x):a},x.interpolate=function(_){return arguments.length?(c=_,x):c},x.on=function(){var _=l.on.apply(l,arguments);return _===l?x:_},x.clickDistance=function(_){return arguments.length?(v=(_=+_)*_,x):Math.sqrt(v)},x.tapDistance=function(_){return arguments.length?(w=+_,x):w},x}const ye={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.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 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:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,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.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},_t=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Mi=["Enter"," ","Escape"],Ti={"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:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"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 Ze;(function(e){e.Strict="strict",e.Loose="loose"})(Ze||(Ze={}));var Ye;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ye||(Ye={}));var St;(function(e){e.Partial="partial",e.Full="full"})(St||(St={}));const Ai={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Re;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Re||(Re={}));var nn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nn||(nn={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const Uo={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top},Pi=e=>!!e&&typeof e=="object"&&"id"in e&&"source"in e&&"target"in e,Kd=e=>!!e&&typeof e=="object"&&"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),uo=e=>!!e&&typeof e=="object"&&"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Mt=(e,t=[0,0])=>{const{width:n,height:o}=we(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},Qd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1;const o=e.reduce((r,i)=>{const s=typeof i=="string";let a=!t.nodeLookup&&!s?i:void 0;return t.nodeLookup&&(a=s?t.nodeLookup.get(i):uo(i)?i:t.nodeLookup.get(i.id)),a?(n=!0,fn(r,on(a,t.nodeOrigin))):r},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?hn(o):{x:0,y:0,width:0,height:0}},Tt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(r=>{(t.filter===void 0||t.filter(r))&&(n=fn(n,on(r)),o=!0)}),o?hn(n):{x:0,y:0,width:0,height:0}},fo=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a=(t.x-n)/r,c=(t.y-o)/r,l=t.width/r,u=t.height/r,f=[];for(const d of e.values()){const{measured:p,selectable:g=!0,hidden:v=!1}=d;if(s&&!g||v)continue;const w=p.width??d.width??d.initialWidth??0,x=p.height??d.height??d.initialHeight??0,{x:S,y:m}=d.internals.positionAbsolute,y=Ri(a,c,l,u,S,m,w,x),I=w*x,b=i&&y>0;(!d.internals.handleBounds||b||y>=I||d.dragging)&&f.push(d)}return f},Jd=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function ef(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{let i;if(t?.includeHiddenNodes){const{width:s,height:a}=we(r);i=s>0&&a>0}else i=!!(r.measured.width&&r.measured.height&&!r.hidden);i&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function tf({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return!0;const a=ef(e,s),c=Tt(a),l=po(c,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(l,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),!0}function Di({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:r,onError:i}){const s=n.get(e),a=s.parentId?n.get(s.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},u=s.origin??o;let f=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",ye.error005());else{const{width:p,height:g}=we(a);p&&g&&(f=[[c,l],[c+p,l+g]])}else a&&Ue(s.extent)&&(f=[[s.extent[0][0]+c,s.extent[0][1]+l],[s.extent[1][0]+c,s.extent[1][1]+l]]);const d=Ue(f)?Ge(t,f,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",ye.error015()),{position:{x:d.x-c+(s.measured.width??0)*u[0],y:d.y-l+(s.measured.height??0)*u[1]},positionAbsolute:d}}async function nf({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(d=>d.id)),s=[];for(const d of n){if(d.deletable===!1)continue;const p=i.has(d.id),g=!p&&d.parentId&&s.find(v=>v.id===d.parentId);(p||g)&&s.push(d)}const a=new Set(t.map(d=>d.id)),c=o.filter(d=>d.deletable!==!1),u=Jd(s,c);for(const d of c)a.has(d.id)&&!u.find(g=>g.id===d.id)&&u.push(d);if(!r)return{edges:u,nodes:s};const f=await r({nodes:s,edges:u});return typeof f=="boolean"?f?{edges:u,nodes:s}:{edges:[],nodes:[]}:f}const at=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ge=(e={x:0,y:0},t,n)=>({x:at(e.x,t[0][0],t[1][0]-(n?.width??0)),y:at(e.y,t[0][1],t[1][1]-(n?.height??0))});function ji(e,t,n){const{width:o,height:r}=we(n),{x:i,y:s}=n.internals.positionAbsolute;return Ge(e,[[i,s],[i+o,s+r]],t)}const qo=(e,t,n)=>e<t?at(Math.abs(e-t),1,t)/t:e>n?-at(Math.abs(e-n),1,t)/t:0,ho=(e,t,n=15,o=40)=>{const r=qo(e.x,o,t.width-o)*n,i=qo(e.y,o,t.height-o)*n;return[r,i]},fn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Zn=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),hn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Et=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:o,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},on=(e,t=[0,0])=>{const{x:n,y:o}=uo(e)?e.internals.positionAbsolute:Mt(e,t);return{x:n,y:o,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:o+(e.measured?.height??e.height??e.initialHeight??0)}},$i=(e,t)=>hn(fn(Zn(e),Zn(t))),Ri=(e,t,n,o,r,i,s,a)=>{const c=Math.max(0,Math.min(e+n,r+s)-Math.max(e,r)),l=Math.max(0,Math.min(t+o,i+a)-Math.max(t,i));return Math.ceil(c*l)},rn=(e,t)=>Ri(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ko=e=>ge(e.width)&&ge(e.height)&&ge(e.x)&&ge(e.y),ge=e=>!isNaN(e)&&isFinite(e),Hi=(e,t)=>(n,o)=>{},At=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Pt=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?At(a,s):a},ct=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Je(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function of(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Je(e,n),r=Je(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Je(e.top??e.y??0,n),r=Je(e.bottom??e.y??0,n),i=Je(e.left??e.x??0,t),s=Je(e.right??e.x??0,t);return{top:o,right:s,bottom:r,left:i,x:i+s,y:o+r}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function rf(e,t,n,o,r,i){const{x:s,y:a}=ct(e,[t,n,o]),{x:c,y:l}=ct({x:e.x+e.width,y:e.y+e.height},[t,n,o]),u=r-c,f=i-l;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(u),bottom:Math.floor(f)}}const po=(e,t,n,o,r,i)=>{const s=of(i,t,n),a=(t-s.x)/e.width,c=(n-s.y)/e.height,l=Math.min(a,c),u=at(l,o,r),f=e.x+e.width/2,d=e.y+e.height/2,p=t/2-f*u,g=n/2-d*u,v=rf(e,p,g,u,t,n),w={left:Math.min(v.left-s.left,0),top:Math.min(v.top-s.top,0),right:Math.min(v.right-s.right,0),bottom:Math.min(v.bottom-s.bottom,0)};return{x:p-w.left+w.right,y:g-w.top+w.bottom,zoom:u}},Nt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ue(e){return e!=null&&e!=="parent"}function we(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Li(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function Oi(e,t={width:0,height:0},n,o,r){const i={...e},s=o.get(n);if(s){const a=s.origin||r;i.x+=s.internals.positionAbsolute.x-(t.width??0)*a[0],i.y+=s.internals.positionAbsolute.y-(t.height??0)*a[1]}return i}function Qo(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function sf(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function af(e){return{...Ti,...e||{}}}function zi(e){return e===null?null:e?"valid":"invalid"}function yt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=me(e),a=Pt({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:c,y:l}=n?At(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const go=e=>({width:e.offsetWidth,height:e.offsetHeight}),Bi=e=>e?.getRootNode?.()||window?.document,cf=["INPUT","SELECT","TEXTAREA"];function Vi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:cf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const Fi=e=>"clientX"in e,me=(e,t)=>{const n=Fi(e),o=n?e.clientX:e.touches?.[0].clientX,r=n?e.clientY:e.touches?.[0].clientY;return{x:o-(t?.left??0),y:r-(t?.top??0)}},Jo=(e,t,n,o,r)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).map(s=>{const a=s.getBoundingClientRect();return{id:s.getAttribute("data-handleid"),type:e,nodeId:r,position:s.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...go(s)}})};function Yi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const c=e*.125+r*.375+s*.375+n*.125,l=t*.125+i*.375+a*.375+o*.125,u=Math.abs(c-e),f=Math.abs(l-t);return[c,l,u,f]}function Lt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function er({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Lt(t-o,i),n];case X.Right:return[t+Lt(o-t,i),n];case X.Top:return[t,n-Lt(n-r,i)];case X.Bottom:return[t,n+Lt(r-n,i)]}}function Xi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,c]=er({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[l,u]=er({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[f,d,p,g]=Yi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${a},${c} ${l},${u} ${o},${r}`,f,d,p,g]}function Wi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,i=n<e?n+r:n-r,s=Math.abs(o-t)/2,a=o<t?o+s:o-s;return[i,a,r,s]}function lf({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:r=!1,zIndexMode:i="basic"}){if(i==="manual")return o;const s=r&&n?o+1e3:o,a=Math.max(e.parentId||r&&e.selected?e.internals.z:0,t.parentId||r&&t.selected?t.internals.z:0);return s+a}function uf({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=fn(on(e),on(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const s={x:-r[0]/r[2],y:-r[1]/r[2],width:n/r[2],height:o/r[2]};return rn(s,hn(i))>0}const df=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,ff=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),hf=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.("006",ye.error006()),t;const o=n.getEdgeId||df;let r;return Pi(e)?r={...e}:r={...e,id:o(e)},ff(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function Zi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=Wi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const tr={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},pf=({source:e,sourcePosition:t=X.Bottom,target:n})=>t===X.Left||t===X.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},nr=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function gf({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=tr[t],c=tr[o],l={x:e.x+a.x*i,y:e.y+a.y*i},u={x:n.x+c.x*i,y:n.y+c.y*i},f=pf({source:l,sourcePosition:t,target:u}),d=f.x!==0?"x":"y",p=f[d];let g=[],v,w;const x={x:0,y:0},S={x:0,y:0},[,,m,y]=Wi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*c[d]===-1){d==="x"?(v=r.x??l.x+(u.x-l.x)*s,w=r.y??(l.y+u.y)/2):(v=r.x??(l.x+u.x)/2,w=r.y??l.y+(u.y-l.y)*s);const E=[{x:v,y:l.y},{x:v,y:u.y}],A=[{x:l.x,y:w},{x:u.x,y:w}];a[d]===p?g=d==="x"?E:A:g=d==="x"?A:E}else{const E=[{x:l.x,y:u.y}],A=[{x:u.x,y:l.y}];if(d==="x"?g=a.x===p?A:E:g=a.y===p?E:A,t===o){const _=Math.abs(e[d]-n[d]);if(_<=i){const k=Math.min(i-1,i-_);a[d]===p?x[d]=(l[d]>e[d]?-1:1)*k:S[d]=(u[d]>n[d]?-1:1)*k}}if(t!==o){const _=d==="x"?"y":"x",k=a[d]===c[_],M=l[_]>u[_],P=l[_]<u[_];(a[d]===1&&(!k&&M||k&&P)||a[d]!==1&&(!k&&P||k&&M))&&(g=d==="x"?E:A)}const B={x:l.x+x.x,y:l.y+x.y},T={x:u.x+S.x,y:u.y+S.y},L=Math.max(Math.abs(B.x-g[0].x),Math.abs(T.x-g[0].x)),H=Math.max(Math.abs(B.y-g[0].y),Math.abs(T.y-g[0].y));L>=H?(v=(B.x+T.x)/2,w=g[0].y):(v=g[0].x,w=(B.y+T.y)/2)}const I={x:l.x+x.x,y:l.y+x.y},b={x:u.x+S.x,y:u.y+S.y};return[[e,...I.x!==g[0].x||I.y!==g[0].y?[I]:[],...g,...b.x!==g[g.length-1].x||b.y!==g[g.length-1].y?[b]:[],n],v,w,m,y]}function mf(e,t,n,o){const r=Math.min(nr(e,t)/2,nr(t,n)/2,o),{x:i,y:s}=t;if(e.x===i&&i===n.x||e.y===s&&s===n.y)return`L${i} ${s}`;if(e.y===s){const l=e.x<n.x?-1:1,u=e.y<n.y?1:-1;return`L ${i+r*l},${s}Q ${i},${s} ${i},${s+r*u}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${i},${s+r*c}Q ${i},${s} ${i+r*a},${s}`}function Gn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:c,offset:l=20,stepPosition:u=.5}){const[f,d,p,g,v]=gf({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:c},offset:l,stepPosition:u});let w=`M${f[0].x} ${f[0].y}`;for(let x=1;x<f.length-1;x++)w+=mf(f[x-1],f[x],f[x+1],s);return w+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[w,d,p,g,v]}function or(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function yf(e){const{sourceNode:t,targetNode:n}=e;if(!or(t)||!or(n))return null;const o=t.internals.handleBounds||rr(t.handles),r=n.internals.handleBounds||rr(n.handles),i=ir(o?.source??[],e.sourceHandle),s=ir(e.connectionMode===Ze.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",ye.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||X.Bottom,c=s?.position||X.Top,l=qe(t,i,a),u=qe(n,s,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:a,targetPosition:c}}function rr(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function qe(e,t,n=X.Left,o=!1){const r=(t?.x??0)+e.internals.positionAbsolute.x,i=(t?.y??0)+e.internals.positionAbsolute.y,{width:s,height:a}=t??we(e);if(o)return{x:r+s/2,y:i+a/2};switch(t?.position??n){case X.Top:return{x:r+s/2,y:i};case X.Right:return{x:r+s,y:i+a/2};case X.Bottom:return{x:r+s/2,y:i+a};case X.Left:return{x:r,y:i+a/2}}}function ir(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Un(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function xf(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:r}){const i=new Set;return e.reduce((s,a)=>([a.markerStart||o,a.markerEnd||r].forEach(c=>{if(c&&typeof c=="object"){const l=Un(c,t);i.has(l)||(s.push({id:l,color:c.color||n,...c}),i.add(l))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const Gi=1e3,wf=10,mo={nodeOrigin:[0,0],nodeExtent:_t,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},vf={...mo,checkEquality:!0};function yo(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function bf(e,t,n){const o=yo(mo,n);for(const r of e.values())if(r.parentId)wo(r,e,t,o);else{const i=Mt(r,o.nodeOrigin),s=Ue(r.extent)?r.extent:o.nodeExtent,a=Ge(i,s,we(r));r.internals.positionAbsolute=a}}function _f(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;const n=[],o=[];for(const r of e.handles){const i={id:r.id,width:r.width??1,height:r.height??1,nodeId:e.id,x:r.x,y:r.y,position:r.position,type:r.type};r.type==="source"?n.push(i):r.type==="target"&&o.push(i)}return{source:n,target:o}}function xo(e){return e==="manual"}function qn(e,t,n,o={}){const r=yo(vf,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!xo(r.zIndexMode)?Gi:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const u of e){let f=s.get(u.id);if(r.checkEquality&&u===f?.internals.userNode)t.set(u.id,f);else{const d=Mt(u,r.nodeOrigin),p=Ue(u.extent)?u.extent:r.nodeExtent,g=Ge(d,p,we(u));f={...r.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:g,handleBounds:_f(u,f),z:Ui(u,a,r.zIndexMode),userNode:u}},t.set(u.id,f)}(f.measured===void 0||f.measured.width===void 0||f.measured.height===void 0)&&!f.hidden&&(c=!1),u.parentId&&wo(f,t,n,o,i),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Sf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function wo(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:c}=yo(mo,o),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Sf(e,n),r&&!u.parentId&&u.internals.rootParentIndex===void 0&&c==="auto"&&(u.internals.rootParentIndex=++r.i,u.internals.z=u.internals.z+r.i*wf),r&&u.internals.rootParentIndex!==void 0&&(r.i=u.internals.rootParentIndex);const f=i&&!xo(c)?Gi:0,{x:d,y:p,z:g}=Ef(e,u,s,a,f,c),{positionAbsolute:v}=e.internals,w=d!==v.x||p!==v.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:d,y:p}:v,z:g}})}function Ui(e,t,n){const o=ge(e.zIndex)?e.zIndex:0;return xo(n)?o:o+(e.selected?t:0)}function Ef(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,c=we(e),l=Mt(e,n),u=Ue(e.extent)?Ge(l,e.extent,c):l;let f=Ge({x:s+u.x,y:a+u.y},o,c);e.extent==="parent"&&(f=ji(f,c,t));const d=Ui(e,r,i),p=t.internals.z??0;return{x:f.x,y:f.y,z:p>=d?p+1:d}}function vo(e,t,n,o=[0,0]){const r=[],i=new Map;for(const s of e){const a=t.get(s.parentId);if(!a)continue;const c=i.get(s.parentId)?.expandedRect??Et(a),l=$i(c,s.rect);i.set(s.parentId,{expandedRect:l,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},c)=>{const l=a.internals.positionAbsolute,u=we(a),f=a.origin??o,d=s.x<l.x?Math.round(Math.abs(l.x-s.x)):0,p=s.y<l.y?Math.round(Math.abs(l.y-s.y)):0,g=Math.max(u.width,Math.round(s.width)),v=Math.max(u.height,Math.round(s.height)),w=(g-u.width)*f[0],x=(v-u.height)*f[1];(d>0||p>0||w||x)&&(r.push({id:c,type:"position",position:{x:a.position.x-d+w,y:a.position.y-p+x}}),n.get(c)?.forEach(S=>{e.some(m=>m.id===S.id)||r.push({id:S.id,type:"position",position:{x:S.position.x+d,y:S.position.y+p}})})),(u.width<s.width||u.height<s.height||d||p)&&r.push({id:c,type:"dimensions",setAttributes:!0,dimensions:{width:g+(d?f[0]*d-w:0),height:v+(p?f[1]*p-x:0)}})}),r}function Nf(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],u=window.getComputedStyle(a),{m22:f}=new window.DOMMatrixReadOnly(u.transform),d=[];for(const p of e.values()){const g=t.get(p.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),c=!0;continue}const v=go(p.nodeElement),w=g.measured.width!==v.width||g.measured.height!==v.height;if(!!(v.width&&v.height&&(w||!g.internals.handleBounds||p.force))){const S=p.nodeElement.getBoundingClientRect(),m=Ue(g.extent)?g.extent:i;let{positionAbsolute:y}=g.internals;if(g.parentId&&g.extent==="parent"){const b=t.get(g.parentId);b&&(y=ji(y,v,b))}else m&&(y=Ge(y,m,v));const I={...g,measured:v,internals:{...g.internals,positionAbsolute:y,handleBounds:{source:Jo("source",p.nodeElement,S,f,g.id),target:Jo("target",p.nodeElement,S,f,g.id)}}};t.set(g.id,I),g.parentId&&wo(I,t,n,{nodeOrigin:r,zIndexMode:s}),c=!0,w&&(l.push({id:g.id,type:"dimensions",dimensions:v}),g.expandParent&&g.parentId&&d.push({id:g.id,parentId:g.parentId,rect:Et(I,r)}))}}if(d.length>0){const p=vo(d,t,n,r);l.push(...p)}return{changes:l,updatedInternals:c}}async function Cf({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return!1;const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o);return!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2])}function sr(e,t,n,o,r,i){let s=r;const a=o.get(s)||new Map;o.set(s,a.set(n,t)),s=`${r}-${e}`;const c=o.get(s)||new Map;if(o.set(s,c.set(n,t)),i){s=`${r}-${e}-${i}`;const l=o.get(s)||new Map;o.set(s,l.set(n,t))}}function qi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,c={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},l=`${r}-${s}--${i}-${a}`,u=`${i}-${a}--${r}-${s}`;sr("source",c,u,e,r,s),sr("target",c,l,e,i,a),t.set(o.id,o)}}function Ki(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:Ki(n,t):!1}function ar(e,t,n){let o=e;do{if(o?.matches?.(t))return!0;if(o===n)return!1;o=o?.parentElement}while(o);return!1}function If(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!Ki(s,e))&&(s.draggable||t&&typeof s.draggable>"u")){const a=e.get(i);a&&r.set(i,{id:i,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return r}function In({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const c=n.get(s)?.internals.userNode;c&&r.push({...c,position:a.position,dragging:o})}if(!e)return[r[0],r];const i=n.get(e)?.internals.userNode;return[i?{...i,position:t.get(e)?.position||i.position,dragging:o}:r[0],r]}function kf({dragItems:e,snapGrid:t,x:n,y:o}){const r=e.values().next().value;if(!r)return null;const i={x:n-r.distance.x,y:o-r.distance.y},s=At(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Mf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,c=!1,l={x:0,y:0},u=null,f=!1,d=null,p=!1,g=!1,v=null;function w({noDragClassName:S,handleSelector:m,domNode:y,isSelectable:I,nodeId:b,nodeClickDistance:C=0}){d=ue(y);function E({x:L,y:H}){const{nodeLookup:_,nodeExtent:k,snapGrid:M,snapToGrid:P,nodeOrigin:j,onNodeDrag:$,onSelectionDrag:O,onError:V,updateNodePositions:z}=t();i={x:L,y:H};let W=!1;const Y=a.size>1,Z=Y&&k?Zn(Tt(a)):null,J=Y&&P?kf({dragItems:a,snapGrid:M,x:L,y:H}):null;for(const[R,D]of a){if(!_.has(R))continue;let F={x:L-D.distance.x,y:H-D.distance.y};P&&(F=J?{x:Math.round(F.x+J.x),y:Math.round(F.y+J.y)}:At(F,M));let U=null;if(Y&&k&&!D.extent&&Z){const{positionAbsolute:q}=D.internals,ee=q.x-Z.x+k[0][0],ne=q.x+D.measured.width-Z.x2+k[1][0],oe=q.y-Z.y+k[0][1],ce=q.y+D.measured.height-Z.y2+k[1][1];U=[[ee,oe],[ne,ce]]}const{position:Q,positionAbsolute:G}=Di({nodeId:R,nextPosition:F,nodeLookup:_,nodeExtent:U||k,nodeOrigin:j,onError:V});W=W||D.position.x!==Q.x||D.position.y!==Q.y,D.position=Q,D.internals.positionAbsolute=G}if(g=g||W,!!W&&(z(a,!0),v&&(o||$||!b&&O))){const[R,D]=In({nodeId:b,dragItems:a,nodeLookup:_});o?.(v,a,R,D),$?.(v,R,D),b||O?.(v,D)}}async function A(){if(!u)return;const{transform:L,panBy:H,autoPanSpeed:_,autoPanOnNodeDrag:k}=t();if(!k){c=!1,cancelAnimationFrame(s);return}const[M,P]=ho(l,u,_);(M!==0||P!==0)&&(i.x=(i.x??0)-M/L[2],i.y=(i.y??0)-P/L[2],await H({x:M,y:P})&&E(i)),s=requestAnimationFrame(A)}function B(L){const{nodeLookup:H,multiSelectionActive:_,nodesDraggable:k,transform:M,snapGrid:P,snapToGrid:j,selectNodesOnDrag:$,onNodeDragStart:O,onSelectionDragStart:V,unselectNodesAndEdges:z}=t();f=!0,(!$||!I)&&!_&&b&&(H.get(b)?.selected||z()),I&&$&&b&&e?.(b);const W=yt(L.sourceEvent,{transform:M,snapGrid:P,snapToGrid:j,containerBounds:u});if(i=W,a=If(H,k,W,b),a.size>0&&(n||O||!b&&V)){const[Y,Z]=In({nodeId:b,dragItems:a,nodeLookup:H});n?.(L.sourceEvent,a,Y,Z),O?.(L.sourceEvent,Y,Z),b||V?.(L.sourceEvent,Z)}}const T=hi().clickDistance(C).on("start",L=>{const{domNode:H,nodeDragThreshold:_,transform:k,snapGrid:M,snapToGrid:P}=t();u=H?.getBoundingClientRect()||null,p=!1,g=!1,v=L.sourceEvent,_===0&&B(L),i=yt(L.sourceEvent,{transform:k,snapGrid:M,snapToGrid:P,containerBounds:u}),l=me(L.sourceEvent,u)}).on("drag",L=>{const{autoPanOnNodeDrag:H,transform:_,snapGrid:k,snapToGrid:M,nodeDragThreshold:P,nodeLookup:j}=t(),$=yt(L.sourceEvent,{transform:_,snapGrid:k,snapToGrid:M,containerBounds:u});if(v=L.sourceEvent,(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1||b&&!j.has(b))&&(p=!0),!p){if(!c&&H&&f&&(c=!0,A()),!f){const O=me(L.sourceEvent,u),V=O.x-l.x,z=O.y-l.y;Math.sqrt(V*V+z*z)>P&&B(L)}(i.x!==$.xSnapped||i.y!==$.ySnapped)&&a&&f&&(l=me(L.sourceEvent,u),E($))}}).on("end",L=>{if(!f||p){p&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,f=!1,cancelAnimationFrame(s),a.size>0){const{nodeLookup:H,updateNodePositions:_,onNodeDragStop:k,onSelectionDragStop:M}=t();if(g&&(_(a,!1),g=!1),r||k||!b&&M){const[P,j]=In({nodeId:b,dragItems:a,nodeLookup:H,dragging:!1});r?.(L.sourceEvent,a,P,j),k?.(L.sourceEvent,P,j),b||M?.(L.sourceEvent,j)}}}).filter(L=>{const H=L.target;return!L.button&&(!S||!ar(H,`.${S}`,y))&&(!m||ar(H,m,y))});d.call(T)}function x(){d?.on(".drag",null)}return{update:w,destroy:x}}function Tf(e,t,n){const o=[],r={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())rn(r,Et(i))>0&&o.push(i);return o}const Af=250;function Pf(e,t,n,o){let r=[],i=1/0;const s=Tf(e,n,t+Af);for(const a of s){const c=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const l of c){if(o.nodeId===l.nodeId&&o.type===l.type&&o.id===l.id)continue;const{x:u,y:f}=qe(a,l,l.position,!0),d=Math.sqrt(Math.pow(u-e.x,2)+Math.pow(f-e.y,2));d>t||(d<i?(r=[{...l,x:u,y:f}],i=d):d===i&&r.push({...l,x:u,y:f}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(c=>c.type===a)??r[0]}return r[0]}function Qi(e,t,n,o,r,i=!1){const s=o.get(e);if(!s)return null;const a=r==="strict"?s.internals.handleBounds?.[t]:[...s.internals.handleBounds?.source??[],...s.internals.handleBounds?.target??[]],c=(n?a?.find(l=>l.id===n):a?.[0])??null;return c&&i?{...c,...qe(s,c,c.position,!0)}:c}function Ji(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Df(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const es=()=>!0;function jf(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:f,panBy:d,cancelConnection:p,onConnectStart:g,onConnect:v,onConnectEnd:w,isValidConnection:x=es,onReconnectEnd:S,updateConnection:m,getTransform:y,getFromHandle:I,autoPanSpeed:b,dragThreshold:C=1,handleDomNode:E}){const A=Bi(e.target);let B=0,T;const{x:L,y:H}=me(e),_=Ji(i,E),k=a?.getBoundingClientRect();let M=!1;if(!k||!_)return;const P=Qi(r,_,o,c,t);if(!P)return;let j=me(e,k),$=!1,O=null,V=!1,z=null;function W(){if(!u||!k)return;const[Q,G]=ho(j,k,b);d({x:Q,y:G}),B=requestAnimationFrame(W)}const Y={...P,nodeId:r,type:_,position:P.position},Z=c.get(r);let R={inProgress:!0,isValid:null,from:qe(Z,Y,X.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:Z,to:j,toHandle:null,toPosition:Uo[Y.position],toNode:null,pointer:j};function D(){M=!0,m(R),g?.(e,{nodeId:r,handleId:o,handleType:_})}C===0&&D();function F(Q){if(!M){const{x:ce,y:Ne}=me(Q),ve=ce-L,be=Ne-H;if(!(ve*ve+be*be>C*C))return;D()}if(!I()||!Y){U(Q);return}const G=y();j=me(Q,k),T=Pf(Pt(j,G,!1,[1,1]),n,c,Y),$||(W(),$=!0);const q=ts(Q,{handle:T,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:x,doc:A,lib:l,flowId:f,nodeLookup:c});z=q.handleDomNode,O=q.connection,V=Df(!!T,q.isValid);const ee=c.get(r),ne=ee?qe(ee,Y,X.Left,!0):R.from,oe={...R,from:ne,isValid:V,to:q.toHandle&&V?ct({x:q.toHandle.x,y:q.toHandle.y},G):j,toHandle:q.toHandle,toPosition:V&&q.toHandle?q.toHandle.position:Uo[Y.position],toNode:q.toHandle?c.get(q.toHandle.nodeId):null,pointer:j};m(oe),R=oe}function U(Q){if(!("touches"in Q&&Q.touches.length>0)){if(M){(T||z)&&O&&V&&v?.(O);const{inProgress:G,...q}=R,ee={...q,toPosition:R.toHandle?R.toPosition:null};w?.(Q,ee),i&&S?.(Q,ee)}p(),cancelAnimationFrame(B),$=!1,V=!1,O=null,z=null,A.removeEventListener("mousemove",F),A.removeEventListener("mouseup",U),A.removeEventListener("touchmove",F),A.removeEventListener("touchend",U)}}A.addEventListener("mousemove",F),A.addEventListener("mouseup",U),A.addEventListener("touchmove",F),A.addEventListener("touchend",U)}function ts(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:c,isValidConnection:l=es,nodeLookup:u}){const f=i==="target",d=t?s.querySelector(`.${a}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:g}=me(e),v=s.elementFromPoint(p,g),w=v?.classList.contains(`${a}-flow__handle`)?v:d,x={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const S=Ji(void 0,w),m=w.getAttribute("data-nodeid"),y=w.getAttribute("data-handleid"),I=w.classList.contains("connectable"),b=w.classList.contains("connectableend");if(!m||!S)return x;const C={source:f?m:o,sourceHandle:f?y:r,target:f?o:m,targetHandle:f?r:y};x.connection=C;const A=I&&b&&(n===Ze.Strict?f&&S==="source"||!f&&S==="target":m!==o||y!==r);x.isValid=A&&l(C),x.toHandle=Qi(m,S,y,u,n,!0)}return x}const Kn={onPointerDown:jf,isValid:ts};function $f({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=ue(e);function i({translateExtent:a,width:c,height:l,zoomStep:u=1,pannable:f=!0,zoomable:d=!0,inversePan:p=!1}){const g=m=>{if(m.sourceEvent.type!=="wheel"||!t)return;const y=n(),I=m.sourceEvent.ctrlKey&&Nt()?10:1,b=-m.sourceEvent.deltaY*(m.sourceEvent.deltaMode===1?.05:m.sourceEvent.deltaMode?1:.002)*u,C=y[2]*Math.pow(2,b*I);t.scaleTo(C)};let v=[0,0];const w=m=>{(m.sourceEvent.type==="mousedown"||m.sourceEvent.type==="touchstart")&&(v=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY])},x=m=>{const y=n();if(m.sourceEvent.type!=="mousemove"&&m.sourceEvent.type!=="touchmove"||!t)return;const I=[m.sourceEvent.clientX??m.sourceEvent.touches[0].clientX,m.sourceEvent.clientY??m.sourceEvent.touches[0].clientY],b=[I[0]-v[0],I[1]-v[1]];v=I;const C=o()*Math.max(y[2],Math.log(y[2]))*(p?-1:1),E={x:y[0]-b[0]*C,y:y[1]-b[1]*C},A=[[0,0],[c,l]];t.setViewportConstrained({x:E.x,y:E.y,zoom:y[2]},A,a)},S=ki().on("start",w).on("zoom",f?x:null).on("zoom.wheel",d?g:null);r.call(S,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:he}}const pn=e=>({x:e.x,y:e.y,zoom:e.k}),kn=({x:e,y:t,zoom:n})=>dn.translate(e,t).scale(n),$e=(e,t)=>e.target.closest(`.${t}`),ns=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Rf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Mn=(e,t=0,n=Rf,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},os=e=>{const t=e.ctrlKey&&Nt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Hf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return u=>{if($e(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(u.ctrlKey&&s){const w=he(u),x=os(u),S=f*Math.pow(2,x);o.scaleTo(n,S,w,u);return}const d=u.deltaMode===1?20:1;let p=r===Ye.Vertical?0:u.deltaX*d,g=r===Ye.Horizontal?0:u.deltaY*d;!Nt()&&u.shiftKey&&r!==Ye.Vertical&&(p=u.deltaY*d,g=0),o.translateBy(n,-(p/f)*i,-(g/f)*i,{internal:!0});const v=pn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,v):(e.isPanScrolling=!0,a?.(u,v)),e.panScrollTimeout=setTimeout(()=>{l?.(u,v),e.isPanScrolling=!1},150)}}function Lf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=$e(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Of({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=pn(o.transform);e.mouseButton=o.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=r,o.sourceEvent?.type==="mousedown"&&t(!0),n&&n?.(o.sourceEvent,r)}}function zf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&ns(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,pn(i.transform))}}function Bf({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&ns(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=pn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function Vf({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:o,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:s,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:f}){return d=>{const p=t||n,g=o&&d.ctrlKey,v=d.type==="wheel";if(d.button===1&&d.type==="mousedown"&&($e(d,`${u}-flow__node`)||$e(d,`${u}-flow__edge`)||$e(d,`${u}-flow__selection`)||$e(d,`${u}-flow__nodesselection`)))return!0;if(!r&&!p&&!i&&!s&&!o||a||f&&!v||$e(d,c)&&v||$e(d,l)&&(!v||i&&v&&!t)||!o&&d.ctrlKey&&v)return!1;if(!o&&d.type==="touchstart"&&d.touches?.length>1)return d.preventDefault(),!1;if(!p&&!i&&!g&&v||!r&&(d.type==="mousedown"||d.type==="touchstart")||Array.isArray(r)&&!r.includes(d.button)&&d.type==="mousedown")return!1;const w=Array.isArray(r)&&r.includes(d.button)||!d.button||d.button<=1;return(!d.ctrlKey||v||e)&&w}}function Ff({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect();let f=[[0,0],[u.width,u.height]];(typeof ResizeObserver<"u"?new ResizeObserver(H=>{const _=H[0];_&&(f=[[0,0],[_.contentRect.width,_.contentRect.height]])}):null)?.observe(e);const p=ki().extent(()=>f).scaleExtent([t,n]).translateExtent(o),g=ue(e).call(p);y({x:r.x,y:r.y,zoom:at(r.zoom,t,n)},[[0,0],[u.width,u.height]],o);const v=g.on("wheel.zoom"),w=g.on("dblclick.zoom");p.wheelDelta(os);async function x(H,_){return g?new Promise(k=>{p?.interpolate(_?.interpolate==="linear"?mt:Yt).transform(Mn(g,_?.duration,_?.ease,()=>k(!0)),H)}):!1}function S({noWheelClassName:H,noPanClassName:_,onPaneContextMenu:k,userSelectionActive:M,panOnScroll:P,panOnDrag:j,panOnScrollMode:$,panOnScrollSpeed:O,preventScrolling:V,zoomOnPinch:z,zoomOnScroll:W,zoomOnDoubleClick:Y,panActivationKeyPressed:Z=!1,zoomActivationKeyPressed:J,lib:R,onTransformChange:D,connectionInProgress:F,paneClickDistance:U,selectionOnDrag:Q}){M&&!l.isZoomingOrPanning&&m();const G=P&&!J&&!M;p.clickDistance(Q?1/0:!ge(U)||U<0?0:U);const q=G?Hf({zoomPanValues:l,noWheelClassName:H,d3Selection:g,d3Zoom:p,panOnScrollMode:$,panOnScrollSpeed:O,zoomOnPinch:z,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):Lf({noWheelClassName:H,preventScrolling:V,d3ZoomHandler:v});g.on("wheel.zoom",q,{passive:!1});const ee=Of({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:s});p.on("start",ee);const ne=zf({zoomPanValues:l,panOnDrag:j,onPaneContextMenu:!!k,onPanZoom:i,onTransformChange:D});p.on("zoom",ne);const oe=Bf({zoomPanValues:l,panOnDrag:j,panOnScroll:P,onPaneContextMenu:k,onPanZoomEnd:a,onDraggingChange:c});p.on("end",oe);const ce=Vf({panActivationKeyPressed:Z,zoomActivationKeyPressed:J,panOnDrag:j,zoomOnScroll:W,panOnScroll:P,zoomOnDoubleClick:Y,zoomOnPinch:z,userSelectionActive:M,noPanClassName:_,noWheelClassName:H,lib:R,connectionInProgress:F});p.filter(ce),Y?g.on("dblclick.zoom",w):g.on("dblclick.zoom",null)}function m(){p.on("zoom",null)}async function y(H,_,k){const M=kn(H),P=p?.constrain()(M,_,k);return P&&await x(P),P}async function I(H,_){const k=kn(H);return await x(k,_),k}function b(H){if(g){const _=kn(H),k=g.property("__zoom");(k.k!==H.zoom||k.x!==H.x||k.y!==H.y)&&p?.transform(g,_,null,{sync:!0})}}function C(){const H=g?Ii(g.node()):{x:0,y:0,k:1};return{x:H.x,y:H.y,zoom:H.k}}async function E(H,_){return g?new Promise(k=>{p?.interpolate(_?.interpolate==="linear"?mt:Yt).scaleTo(Mn(g,_?.duration,_?.ease,()=>k(!0)),H)}):!1}async function A(H,_){return g?new Promise(k=>{p?.interpolate(_?.interpolate==="linear"?mt:Yt).scaleBy(Mn(g,_?.duration,_?.ease,()=>k(!0)),H)}):!1}function B(H){p?.scaleExtent(H)}function T(H){p?.translateExtent(H)}function L(H){const _=!ge(H)||H<0?0:H;p?.clickDistance(_)}return{update:S,destroy:m,setViewport:I,setViewportConstrained:y,getViewport:C,scaleTo:E,scaleBy:A,setScaleExtent:B,setTranslateExtent:T,syncViewport:b,setClickDistance:L}}var lt;(function(e){e.Line="line",e.Handle="handle"})(lt||(lt={}));function Yf({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,c=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(c[0]=c[0]*-1),a&&i&&(c[1]=c[1]*-1),c}function cr(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),r=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:r}}function De(e,t){return Math.max(0,t-e)}function je(e,t){return Math.max(0,e-t)}function Ot(e,t,n){return Math.max(0,t-e,e-n)}function lr(e,t){return e?!t:t}function Xf(e,t,n,o,r,i,s,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:u,isVertical:f}=t,d=u&&f,{xSnapped:p,ySnapped:g}=n,{minWidth:v,maxWidth:w,minHeight:x,maxHeight:S}=o,{x:m,y,width:I,height:b,aspectRatio:C}=e;let E=Math.floor(u?p-e.pointerX:0),A=Math.floor(f?g-e.pointerY:0);const B=I+(c?-E:E),T=b+(l?-A:A),L=-i[0]*I,H=-i[1]*b;let _=Ot(B,v,w),k=Ot(T,x,S);if(s){let j=0,$=0;c&&E<0?j=De(m+E+L,s[0][0]):!c&&E>0&&(j=je(m+B+L,s[1][0])),l&&A<0?$=De(y+A+H,s[0][1]):!l&&A>0&&($=je(y+T+H,s[1][1])),_=Math.max(_,j),k=Math.max(k,$)}if(a){let j=0,$=0;c&&E>0?j=je(m+E,a[0][0]):!c&&E<0&&(j=De(m+B,a[1][0])),l&&A>0?$=je(y+A,a[0][1]):!l&&A<0&&($=De(y+T,a[1][1])),_=Math.max(_,j),k=Math.max(k,$)}if(r){if(u){const j=Ot(B/C,x,S)*C;if(_=Math.max(_,j),s){let $=0;!c&&!l||c&&!l&&d?$=je(y+H+B/C,s[1][1])*C:$=De(y+H+(c?E:-E)/C,s[0][1])*C,_=Math.max(_,$)}if(a){let $=0;!c&&!l||c&&!l&&d?$=De(y+B/C,a[1][1])*C:$=je(y+(c?E:-E)/C,a[0][1])*C,_=Math.max(_,$)}}if(f){const j=Ot(T*C,v,w)/C;if(k=Math.max(k,j),s){let $=0;!c&&!l||l&&!c&&d?$=je(m+T*C+L,s[1][0])/C:$=De(m+(l?A:-A)*C+L,s[0][0])/C,k=Math.max(k,$)}if(a){let $=0;!c&&!l||l&&!c&&d?$=De(m+T*C,a[1][0])/C:$=je(m+(l?A:-A)*C,a[0][0])/C,k=Math.max(k,$)}}}A=A+(A<0?k:-k),E=E+(E<0?_:-_),r&&(d?B>T*C?A=(lr(c,l)?-E:E)/C:E=(lr(c,l)?-A:A)*C:u?(A=E/C,l=c):(E=A*C,c=l));const M=c?m+E:m,P=l?y+A:y;return{width:I+(c?-E:E),height:b+(l?-A:A),x:i[0]*E*(c?-1:1)+M,y:i[1]*A*(l?-1:1)+P}}const rs={width:0,height:0,x:0,y:0},Wf={...rs,pointerX:0,pointerY:0,aspectRatio:1};function Zf(e,t,n){const o=t.position.x+e.position.x,r=t.position.y+e.position.y,i=e.measured.width??0,s=e.measured.height??0,a=n[0]*i,c=n[1]*s;return[[o-a,r-c],[o+i-a,r+s-c]]}function Gf({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=ue(e);let s={controlDirection:cr("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:u,keepAspectRatio:f,resizeDirection:d,onResizeStart:p,onResize:g,onResizeEnd:v,shouldResize:w}){let x={...rs},S={...Wf};s={boundaries:u,resizeDirection:d,keepAspectRatio:f,controlDirection:cr(l)};let m,y=null,I=[],b,C,E,A=!1;const B=hi().on("start",T=>{const{nodeLookup:L,transform:H,snapGrid:_,snapToGrid:k,nodeOrigin:M,paneDomNode:P}=n();if(m=L.get(t),!m)return;y=P?.getBoundingClientRect()??null;const{xSnapped:j,ySnapped:$}=yt(T.sourceEvent,{transform:H,snapGrid:_,snapToGrid:k,containerBounds:y});x={width:m.measured.width??0,height:m.measured.height??0,x:m.position.x??0,y:m.position.y??0},S={...x,pointerX:j,pointerY:$,aspectRatio:x.width/x.height},b=void 0,C=Ue(m.extent)?m.extent:void 0,m.parentId&&(m.extent==="parent"||m.expandParent)&&(b=L.get(m.parentId)),b&&m.extent==="parent"&&(C=[[0,0],[b.measured.width,b.measured.height]]),I=[],E=void 0;for(const[O,V]of L)if(V.parentId===t&&(I.push({id:O,position:{...V.position},extent:V.extent}),V.extent==="parent"||V.expandParent)){const z=Zf(V,m,V.origin??M);E?E=[[Math.min(z[0][0],E[0][0]),Math.min(z[0][1],E[0][1])],[Math.max(z[1][0],E[1][0]),Math.max(z[1][1],E[1][1])]]:E=z}p?.(T,{...x})}).on("drag",T=>{const{transform:L,snapGrid:H,snapToGrid:_,nodeOrigin:k}=n(),M=yt(T.sourceEvent,{transform:L,snapGrid:H,snapToGrid:_,containerBounds:y}),P=[];if(!m)return;const{x:j,y:$,width:O,height:V}=x,z={},W=m.origin??k,{width:Y,height:Z,x:J,y:R}=Xf(S,s.controlDirection,M,s.boundaries,s.keepAspectRatio,W,C,E),D=Y!==O,F=Z!==V,U=J!==j&&D,Q=R!==$&&F;if(!U&&!Q&&!D&&!F)return;if((U||Q||W[0]===1||W[1]===1)&&(z.x=U?J:x.x,z.y=Q?R:x.y,x.x=z.x,x.y=z.y,I.length>0)){const ne=J-j,oe=R-$;for(const ce of I)ce.position={x:ce.position.x-ne+W[0]*(Y-O),y:ce.position.y-oe+W[1]*(Z-V)},P.push(ce)}if((D||F)&&(z.width=D&&(!s.resizeDirection||s.resizeDirection==="horizontal")?Y:x.width,z.height=F&&(!s.resizeDirection||s.resizeDirection==="vertical")?Z:x.height,x.width=z.width,x.height=z.height),b&&m.expandParent){const ne=W[0]*(z.width??0);z.x&&z.x<ne&&(x.x=ne,S.x=S.x-(z.x-ne));const oe=W[1]*(z.height??0);z.y&&z.y<oe&&(x.y=oe,S.y=S.y-(z.y-oe))}const G=Yf({width:x.width,prevWidth:O,height:x.height,prevHeight:V,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),q={...x,direction:G};w?.(T,q)!==!1&&(A=!0,g?.(T,q),o(z,P))}).on("end",T=>{A&&(v?.(T,{...x}),r?.({...x}),A=!1)});i.call(B)}function c(){i.on(".drag",null)}return{update:a,destroy:c}}var Tn={exports:{}},An={},Pn={exports:{}},Dn={};var ur;function Uf(){if(ur)return Dn;ur=1;var e=Kr();function t(f,d){return f===d&&(f!==0||1/f===1/d)||f!==f&&d!==d}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(f,d){var p=d(),g=o({inst:{value:p,getSnapshot:d}}),v=g[0].inst,w=g[1];return i(function(){v.value=p,v.getSnapshot=d,c(v)&&w({inst:v})},[f,p,d]),r(function(){return c(v)&&w({inst:v}),f(function(){c(v)&&w({inst:v})})},[f]),s(p),p}function c(f){var d=f.getSnapshot;f=f.value;try{var p=d();return!n(f,p)}catch{return!0}}function l(f,d){return d()}var u=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?l:a;return Dn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:u,Dn}var dr;function qf(){return dr||(dr=1,Pn.exports=Uf()),Pn.exports}var fr;function Kf(){if(fr)return An;fr=1;var e=Kr(),t=qf();function n(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,c=e.useDebugValue;return An.useSyncExternalStoreWithSelector=function(l,u,f,d,p){var g=i(null);if(g.current===null){var v={hasValue:!1,value:null};g.current=v}else v=g.current;g=a(function(){function x(b){if(!S){if(S=!0,m=b,b=d(b),p!==void 0&&v.hasValue){var C=v.value;if(p(C,b))return y=C}return y=b}if(C=y,o(m,b))return C;var E=d(b);return p!==void 0&&p(C,E)?(m=b,C):(m=b,y=E)}var S=!1,m,y,I=f===void 0?null:f;return[function(){return x(u())},I===null?void 0:function(){return x(I())}]},[u,f,d,p]);var w=r(l,g[0],g[1]);return s(function(){v.hasValue=!0,v.value=w},[w]),c(w),w},An}var hr;function Qf(){return hr||(hr=1,Tn.exports=Kf()),Tn.exports}var Jf=Qf();const eh=Qa(Jf),th={},pr=e=>{let t;const n=new Set,o=(u,f)=>{const d=typeof u=="function"?u(t):u;if(!Object.is(d,t)){const p=t;t=f??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(g=>g(t,p))}},r=()=>t,c={setState:o,getState:r,getInitialState:()=>l,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{(th?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(o,r,c);return c},nh=e=>e?pr(e):pr,{useDebugValue:oh}=Ja,{useSyncExternalStoreWithSelector:rh}=eh,ih=e=>e;function is(e,t=ih,n){const o=rh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return oh(o),o}const gr=(e,t)=>{const n=nh(e),o=(r,i=t)=>is(n,r,i);return Object.assign(o,n),o},sh=(e,t)=>e?gr(e,t):gr;function ie(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[o,r]of e)if(!Object.is(r,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const gn=N.createContext(null),ah=gn.Provider,ss=ye.error001("react");function te(e,t){const n=N.useContext(gn);if(n===null)throw new Error(ss);return is(n,e,t)}function re(){const e=N.useContext(gn);if(e===null)throw new Error(ss);return N.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const mr={display:"none"},ch={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},as="react-flow__node-desc",cs="react-flow__edge-desc",lh="react-flow__aria-live",uh=e=>e.ariaLiveMessage,dh=e=>e.ariaLabelConfig;function fh({rfId:e}){const t=te(uh);return h.jsx("div",{id:`${lh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ch,children:t})}function hh({rfId:e,disableKeyboardA11y:t}){const n=te(dh);return h.jsxs(h.Fragment,{children:[h.jsx("div",{id:`${as}-${e}`,style:mr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),h.jsx("div",{id:`${cs}-${e}`,style:mr,children:n["edge.a11yDescription.default"]}),!t&&h.jsx(fh,{rfId:e})]})}const Ke=N.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return h.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Ke.displayName="Panel";const yr="https://reactflow.dev?utm_source=attribution";function ph({proOptions:e,position:t="bottom-right"}){return N.useEffect(()=>{},[]),e?.hideAttribution?null:h.jsx(Ke,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${yr}`,children:h.jsx("a",{href:yr,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const gh=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},zt=e=>e.id;function mh(e,t){return ie(e.selectedNodes.map(zt),t.selectedNodes.map(zt))&&ie(e.selectedEdges.map(zt),t.selectedEdges.map(zt))}function yh({onSelectionChange:e}){const t=re(),{selectedNodes:n,selectedEdges:o}=te(gh,mh);return N.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const xh=e=>!!e.onSelectionChangeHandlers;function wh({onSelectionChange:e}){const t=te(xh);return e||t?h.jsx(yh,{onSelectionChange:e}):null}const ls=[0,0],vh={x:0,y:0,zoom:1},bh=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],xr=[...bh,"rfId"],_h=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),wr={translateExtent:_t,nodeOrigin:ls,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Sh(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:c}=te(_h,ie),l=re();N.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=wr,a()}),[]);const u=N.useRef(wr);return N.useEffect(()=>{for(const f of xr){const d=e[f],p=u.current[f];d!==p&&(typeof e[f]>"u"||(f==="nodes"?t(d):f==="edges"?n(d):f==="minZoom"?o(d):f==="maxZoom"?r(d):f==="translateExtent"?i(d):f==="nodeExtent"?s(d):f==="ariaLabelConfig"?l.setState({ariaLabelConfig:af(d)}):f==="fitView"?l.setState({fitViewQueued:d}):f==="fitViewOptions"?l.setState({fitViewOptions:d}):l.setState({[f]:d})))}u.current=e},xr.map(f=>e[f])),null}function vr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Eh(e){const[t,n]=N.useState(e==="system"?null:e);return N.useEffect(()=>{if(e!=="system"){n(e);return}const o=vr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:vr()?.matches?"dark":"light"}const br=typeof document<"u"?document:null;function Ct(e=null,t={target:br,actInsideInputWithModifier:!0}){const[n,o]=N.useState(!1),r=N.useRef(!1),i=N.useRef(new Set([])),[s,a]=N.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace(/\+/g,`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as e,f as x}from"./index-
|
|
1
|
+
import{j as e,f as x}from"./index-CaFoTJlR.js";import{a as d,u,t as I}from"./App-B7t5h5M_.js";import{u as a}from"./promptBuilderStore-B7xCm5Ga.js";function y(t){return t?.filename??t?.url??t?.image??null}function C(t){const s=t.split(/[\\/]/).pop()??t;return s.length<=32?s:`${s.slice(0,14)}...${s.slice(-12)}`}function S(){const t=a(c=>c.scope),s=a(c=>c.clearImageScope),o=d(c=>c.currentImage),n=d(c=>c.history),{t:i}=u();if(t.kind==="draft")return e.jsx("span",{className:"prompt-builder__scope",children:i("promptBuilder.scopeDraft")});const p=y(o)===t.imageKey?o:n.find(c=>y(c)===t.imageKey)??null;if(!p)return e.jsx("span",{className:"prompt-builder__scope",children:i("promptBuilder.scopeDraft")});const h=i("promptBuilder.scopeImage",{name:C(t.imageKey)||i("promptBuilder.scopeImageFallback")});return e.jsxs("div",{className:"prompt-builder__scope-card",children:[e.jsx("img",{className:"prompt-builder__scope-thumb",src:p.thumb||p.url||p.image,alt:""}),e.jsx("span",{className:"prompt-builder__scope-name",children:h}),e.jsx("button",{type:"button",className:"prompt-builder__scope-remove",onClick:s,"aria-label":i("promptBuilder.removeScopeImage"),title:i("promptBuilder.removeScopeImage"),children:"×"})]})}function A(){const t=a(l=>l.model),s=a(l=>l.modelOptions),o=a(l=>l.backend),n=a(l=>l.updateConfig),{t:i}=u();return e.jsx(I,{className:"prompt-builder__model-picker",items:s.map(l=>({value:l,label:l==="auto"?i("promptBuilder.modelAuto"):l})),value:t,onChange:l=>{n(o,l)},ariaLabel:i("promptBuilder.model"),portal:!0})}const E={"Brief Intent Summary":"summary","Final Prompt - Korean":"ko","Final Prompt - English":"en",Notes:"notes"},T=/^(Brief Intent Summary|Final Prompt - Korean|Final Prompt - English|Notes):\s*(.*)$/gim;function K(t){const s=t.trim();return(s.match(/^```(?:[a-zA-Z0-9_-]+)?\s*([\s\S]*?)\s*```$/)?.[1]??s).trim()}function M(t){const s={},o=Array.from(t.matchAll(T));for(let n=0;n<o.length;n+=1){const i=o[n],l=i[1]??"",p=E[l];if(!p||typeof i.index!="number")continue;const h=i[2]?.trim()??"",c=i.index+i[0].length,m=o[n+1]?.index??t.length,f=K([h,t.slice(c,m)].filter(Boolean).join(`
|
|
2
2
|
`));f&&(s[p]=f)}return s}function $(t){const s=M(t),o=[];return s.ko&&o.push({language:"ko",heading:"Final Prompt - Korean",text:s.ko}),s.en&&o.push({language:"en",heading:"Final Prompt - English",text:s.en}),o.length===0?null:{summary:s.summary,prompts:o,notes:s.notes}}function F({messageId:t,prompt:s}){const o=d(m=>m.setPrompt),n=d(m=>m.insertPromptToComposer),i=d(m=>m.showToast),{t:l}=u(),p=s.language==="ko"?l("promptBuilder.finalKoreanPrompt"):l("promptBuilder.finalEnglishPrompt"),h=()=>{o(s.text),i(l("promptBuilder.applied"))},c=()=>{n({id:`builder_${t}_${s.language}`,name:p,text:s.text,placement:"after"}),i(l("promptBuilder.inserted"))};return e.jsxs("section",{className:"prompt-builder__structured-card","aria-label":p,children:[e.jsxs("div",{className:"prompt-builder__structured-card-header",children:[e.jsx("strong",{children:p}),e.jsx("span",{children:s.language.toUpperCase()})]}),e.jsx("p",{children:s.text}),e.jsxs("div",{className:"prompt-builder__structured-actions",children:[e.jsx("button",{type:"button",onClick:h,children:l("promptBuilder.applyToPrompt")}),e.jsx("button",{type:"button",onClick:c,children:l("promptBuilder.insertAsBlock")})]})]})}function D(t){return t.kind==="image"?"IMG":t.kind==="text"?"TXT":"FILE"}function R({message:t}){const{t:s}=u(),o=t.role==="assistant"?$(t.content):null;return e.jsxs("article",{className:`prompt-builder__message prompt-builder__message--${t.role}`,children:[e.jsx("div",{className:"prompt-builder__message-role",children:t.role==="user"?s("promptBuilder.user"):s("promptBuilder.assistant")}),o?e.jsxs("div",{className:"prompt-builder__structured-prompts",children:[o.summary?e.jsx("p",{className:"prompt-builder__structured-summary",children:o.summary}):null,o.prompts.map(n=>e.jsx(F,{messageId:t.id,prompt:n},`${t.id}-${n.language}`)),o.notes?e.jsx("p",{className:"prompt-builder__structured-notes",children:o.notes}):null]}):e.jsx("p",{children:t.content}),t.attachments&&t.attachments.length>0?e.jsx("div",{className:"prompt-builder__message-attachments",children:t.attachments.map(n=>e.jsxs("span",{className:"prompt-builder__message-attachment",children:[n.kind==="image"&&n.dataUrl?e.jsx("img",{src:n.dataUrl,alt:""}):e.jsx("span",{children:D(n)}),e.jsx("em",{children:n.name})]},n.id))}):null]})}function L(){const t=a(l=>l.messages),s=a(l=>l.loading),o=a(l=>l.error),n=x.useRef(null),{t:i}=u();return x.useEffect(()=>{const l=n.current;l&&(l.scrollTop=l.scrollHeight)},[t.length,s]),e.jsxs("div",{ref:n,className:"prompt-builder__messages",children:[t.length===0&&e.jsx("div",{className:"prompt-builder__empty",children:i("promptBuilder.empty")}),t.map(l=>e.jsx(R,{message:l},l.id)),s&&e.jsxs("div",{className:"prompt-builder__thinking",role:"status","aria-live":"polite",children:[e.jsxs("span",{className:"prompt-builder__thinking-dots","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}),e.jsx("span",{children:i("promptBuilder.thinking")})]}),o?e.jsx("div",{className:"prompt-builder__empty prompt-builder__error",role:"alert",children:o}):null]})}function U(t){return t.kind==="image"?"IMG":t.kind==="text"?"TXT":"FILE"}function z(){const t=a(n=>n.attachments),s=a(n=>n.removeAttachment),{t:o}=u();return t.length===0?null:e.jsx("div",{className:"prompt-builder__attachments",children:t.map(n=>e.jsxs("span",{className:"prompt-builder__attachment",children:[n.kind==="image"&&n.dataUrl?e.jsx("img",{src:n.dataUrl,alt:""}):e.jsx("span",{children:U(n)}),e.jsx("em",{children:n.name}),e.jsx("button",{type:"button",onClick:()=>s(n.id),"aria-label":o("promptBuilder.removeAttachment",{name:n.name}),title:o("promptBuilder.removeAttachment",{name:n.name}),children:"×"})]},n.id))})}function O(){const t=a(r=>r.draft),s=a(r=>r.setDraft),o=a(r=>r.loading),n=a(r=>r.configLoaded),i=a(r=>r.addAttachments),l=a(r=>r.sendMessage),p=a(r=>r.messages),h=a(r=>r.clearMessages),c=a(r=>r.attachments),m=d(r=>r.prompt),f=d(r=>r.insertedPrompts),N=d(r=>r.quality),k=d(r=>r.getResolvedSize),v=d(r=>r.currentImage),b=x.useRef(null),{t:g}=u(),_=()=>{!t.trim()&&c.length===0||o||!n||l({currentPrompt:m,insertedPrompts:f.map(r=>({name:r.name,text:r.text})),settings:{quality:N,size:k()},currentResultPrompt:v?.prompt??null})},j=r=>{r.length!==0&&i(r)},P=r=>{const B=Array.from(r.clipboardData?.files??[]);B.length!==0&&(r.preventDefault(),j(B))};return e.jsxs("div",{className:"prompt-builder__composer",children:[e.jsx(z,{}),e.jsx("textarea",{value:t,placeholder:g("promptBuilder.placeholder"),onChange:r=>s(r.target.value),onPaste:P,onKeyDown:r=>{r.key==="Enter"&&(r.ctrlKey||r.metaKey)&&(r.preventDefault(),_())}}),e.jsx("input",{ref:b,type:"file",multiple:!0,hidden:!0,onChange:r=>{j(Array.from(r.target.files??[])),r.target.value=""}}),e.jsxs("div",{className:"prompt-builder__composer-actions",children:[e.jsx("button",{type:"button",className:"prompt-builder__attach",onClick:()=>b.current?.click(),disabled:o,"aria-label":g("promptBuilder.attach"),title:g("promptBuilder.attach"),children:"+"}),e.jsx("button",{type:"button",className:"prompt-builder__clear",onClick:h,disabled:p.length===0||o,children:g("promptBuilder.clear")}),e.jsx("button",{type:"button",className:"prompt-builder__send",onClick:_,disabled:!t.trim()&&c.length===0||o||!n,children:g(o?"promptBuilder.sending":"promptBuilder.send")})]})]})}function H({variant:t="panel"}){const{t:s}=u(),o=a(i=>i.lastBackend),n=a(i=>i.loadConfig);return x.useEffect(()=>{n()},[n]),e.jsxs("section",{className:`prompt-builder prompt-builder--${t}`,"aria-label":s("promptBuilder.title"),children:[e.jsxs("div",{className:"prompt-builder__header",children:[e.jsxs("div",{children:[e.jsx("span",{className:"section-title",children:s("promptBuilder.title")}),e.jsx(S,{}),o?e.jsx("span",{className:"prompt-builder__scope prompt-builder__backend-badge",children:s("promptBuilder.viaBackend",{backend:s(`promptBuilder.backends.${o==="grok-api"?"grokApi":o}`)})}):null]}),e.jsx("div",{className:"prompt-builder__header-actions",children:e.jsx(A,{})})]}),e.jsx(L,{}),e.jsx(O,{})]})}export{H as PromptBuilderPanel};
|