ima2-gen 1.1.13 → 1.1.14

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.
Files changed (53) hide show
  1. package/README.md +10 -1
  2. package/bin/commands/doctor.js +195 -0
  3. package/bin/commands/doctor.ts +202 -0
  4. package/bin/ima2.js +3 -105
  5. package/bin/ima2.ts +3 -109
  6. package/config.js +1 -0
  7. package/config.ts +5 -0
  8. package/docs/CLI.md +36 -0
  9. package/docs/FAQ.ko.md +82 -2
  10. package/docs/FAQ.md +85 -2
  11. package/docs/PROMPT_STUDIO.ko.md +111 -0
  12. package/docs/PROMPT_STUDIO.md +115 -0
  13. package/docs/README.ko.md +8 -1
  14. package/docs/migration/runtime-test-inventory.md +6 -1
  15. package/lib/agentRuntime.js +9 -2
  16. package/lib/agentRuntime.ts +8 -2
  17. package/lib/errorClassify.js +1 -1
  18. package/lib/errorClassify.ts +1 -1
  19. package/lib/generationErrors.js +121 -23
  20. package/lib/generationErrors.ts +100 -13
  21. package/lib/responsesDoctor.js +386 -0
  22. package/lib/responsesDoctor.ts +456 -0
  23. package/lib/responsesErrors.js +57 -0
  24. package/lib/responsesErrors.ts +83 -0
  25. package/lib/responsesFallback.js +72 -0
  26. package/lib/responsesFallback.ts +114 -0
  27. package/lib/responsesImageAdapter.js +121 -174
  28. package/lib/responsesImageAdapter.ts +136 -211
  29. package/lib/responsesParse.js +324 -0
  30. package/lib/responsesParse.ts +452 -0
  31. package/lib/responsesTools.js +15 -0
  32. package/lib/responsesTools.ts +28 -0
  33. package/package.json +1 -1
  34. package/routes/edit.js +26 -1
  35. package/routes/edit.ts +26 -1
  36. package/routes/generate.js +40 -0
  37. package/routes/generate.ts +47 -0
  38. package/ui/dist/.vite/manifest.json +12 -12
  39. package/ui/dist/assets/{AgentWorkspace-BJe9yxPA.js → AgentWorkspace-B6YNOZHi.js} +1 -1
  40. package/ui/dist/assets/{CardNewsWorkspace-BBLdwzYU.js → CardNewsWorkspace-EFVeg4l_.js} +1 -1
  41. package/ui/dist/assets/{NodeCanvas-BSZ527J4.js → NodeCanvas-iM6yjHvO.js} +1 -1
  42. package/ui/dist/assets/{PromptBuilderPanel-Y2VygFc0.js → PromptBuilderPanel-C3GdLDCl.js} +1 -1
  43. package/ui/dist/assets/{PromptImportDialog-C6lFV-LL.js → PromptImportDialog-DS9vrc_w.js} +2 -2
  44. package/ui/dist/assets/{PromptImportDiscoverySection-D8YJFhND.js → PromptImportDiscoverySection-DHFEt_FA.js} +1 -1
  45. package/ui/dist/assets/{PromptImportFolderSection-ywfcQolW.js → PromptImportFolderSection-BQxb1zs5.js} +1 -1
  46. package/ui/dist/assets/{PromptLibraryPanel-fk4KmrGy.js → PromptLibraryPanel-NhMKVGfU.js} +2 -2
  47. package/ui/dist/assets/{SettingsWorkspace-DL5vhAHQ.js → SettingsWorkspace-FjKjaDqj.js} +1 -1
  48. package/ui/dist/assets/index-BAN6lKgf.js +28 -0
  49. package/ui/dist/assets/{index-BLx55BOg.js → index-BbFZyM92.js} +1 -1
  50. package/ui/dist/assets/index-DK1faG9Z.css +1 -0
  51. package/ui/dist/index.html +2 -2
  52. package/ui/dist/assets/index-ByViUJfx.css +0 -1
  53. package/ui/dist/assets/index-Ci36vcFD.js +0 -28
@@ -1,4 +1,4 @@
1
- import{r as Nr,g as pa,R as ma,a as T,j as E,u as Fn,b as ee,S as ya,c as xa,n as wa,d as va,e as ba}from"./index-Ci36vcFD.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 _a={value:()=>{}};function Qt(){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 Rt(n)}function Rt(e){this._=e}function Ea(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}})}Rt.prototype=Qt.prototype={constructor:Rt,on:function(e,t){var n=this._,o=Ea(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=Na(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]=yo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=yo(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 Rt(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 Na(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function yo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=_a,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var In="http://www.w3.org/1999/xhtml";const xo={svg:"http://www.w3.org/2000/svg",xhtml:In,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),xo.hasOwnProperty(t)?{space:xo[t],local:e}:e}function Sa(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===In&&t.documentElement.namespaceURI===In?t.createElement(e):t.createElementNS(n,e)}}function Ca(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Sr(e){var t=Jt(e);return(t.local?Ca:Sa)(t)}function Ma(){}function Xn(e){return e==null?Ma:function(){return this.querySelector(e)}}function Ia(e){typeof e!="function"&&(e=Xn(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),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new ue(o,this._parents)}function ka(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Aa(){return[]}function Cr(e){return e==null?Aa:function(){return this.querySelectorAll(e)}}function Pa(e){return function(){return ka(e.apply(this,arguments))}}function $a(e){typeof e=="function"?e=Pa(e):e=Cr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(o.push(e.call(l,l.__data__,c,s)),r.push(l));return new ue(o,r)}function Mr(e){return function(){return this.matches(e)}}function Ir(e){return function(t){return t.matches(e)}}var Da=Array.prototype.find;function Ta(e){return function(){return Da.call(this.children,e)}}function Ra(){return this.firstElementChild}function za(e){return this.select(e==null?Ra:Ta(typeof e=="function"?e:Ir(e)))}var Ha=Array.prototype.filter;function La(){return Array.from(this.children)}function Ba(e){return function(){return Ha.call(this.children,e)}}function Va(e){return this.selectAll(e==null?La:Ba(typeof e=="function"?e:Ir(e)))}function Oa(e){typeof e!="function"&&(e=Mr(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]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new ue(o,this._parents)}function kr(e){return new Array(e.length)}function ja(){return new ue(this._enter||this._groups.map(kr),this._parents)}function Ot(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ot.prototype={constructor:Ot,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 Fa(e){return function(){return e}}function Xa(e,t,n,o,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Ot(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Ya(e,t,n,o,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,f=new Array(d),h;for(a=0;a<d;++a)(l=t[a])&&(f[a]=h=s.call(l,l.__data__,a,t)+"",c.has(h)?r[a]=l:c.set(h,l));for(a=0;a<u;++a)h=s.call(e,i[a],a,i)+"",(l=c.get(h))?(o[a]=l,l.__data__=i[a],c.delete(h)):n[a]=new Ot(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(f[a])===l&&(r[a]=l)}function Wa(e){return e.__data__}function Za(e,t){if(!arguments.length)return Array.from(this,Wa);var n=t?Ya:Xa,o=this._parents,r=this._groups;typeof e!="function"&&(e=Fa(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=o[c],u=r[c],f=u.length,h=Ga(e.call(d,d&&d.__data__,c,o)),g=h.length,y=a[c]=new Array(g),w=s[c]=new Array(g),m=l[c]=new Array(f);n(d,u,y,w,m,h,t);for(var b=0,p=0,x,S;b<g;++b)if(x=y[b]){for(b>=p&&(p=b+1);!(S=w[p])&&++p<g;);x._next=S||null}}return s=new ue(s,o),s._enter=a,s._exit=l,s}function Ga(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function qa(){return new ue(this._exit||this._groups.map(kr),this._parents)}function Ua(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 Ka(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),l=0;l<s;++l)for(var c=n[l],d=o[l],u=c.length,f=a[l]=new Array(u),h,g=0;g<u;++g)(h=c[g]||d[g])&&(f[g]=h);for(;l<r;++l)a[l]=n[l];return new ue(a,this._parents)}function Qa(){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 Ja(e){e||(e=ec);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}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,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new ue(r,this._parents).order()}function ec(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function tc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function nc(){return Array.from(this)}function oc(){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 rc(){let e=0;for(const t of this)++e;return e}function ic(){return!this.node()}function sc(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 ac(e){return function(){this.removeAttribute(e)}}function cc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lc(e,t){return function(){this.setAttribute(e,t)}}function uc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function dc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function fc(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 hc(e,t){var n=Jt(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?cc:ac:typeof t=="function"?n.local?fc:dc:n.local?uc:lc)(n,t))}function Ar(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function gc(e){return function(){this.style.removeProperty(e)}}function pc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function mc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function yc(e,t,n){return arguments.length>1?this.each((t==null?gc:typeof t=="function"?mc:pc)(e,t,n??"")):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||Ar(e).getComputedStyle(e,null).getPropertyValue(t)}function xc(e){return function(){delete this[e]}}function wc(e,t){return function(){this[e]=t}}function vc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function bc(e,t){return arguments.length>1?this.each((t==null?xc:typeof t=="function"?vc:wc)(e,t)):this.node()[e]}function Pr(e){return e.trim().split(/^|\s+/)}function Yn(e){return e.classList||new $r(e)}function $r(e){this._node=e,this._names=Pr(e.getAttribute("class")||"")}$r.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 Dr(e,t){for(var n=Yn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Tr(e,t){for(var n=Yn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function _c(e){return function(){Dr(this,e)}}function Ec(e){return function(){Tr(this,e)}}function Nc(e,t){return function(){(t.apply(this,arguments)?Dr:Tr)(this,e)}}function Sc(e,t){var n=Pr(e+"");if(arguments.length<2){for(var o=Yn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Nc:t?_c:Ec)(n,t))}function Cc(){this.textContent=""}function Mc(e){return function(){this.textContent=e}}function Ic(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function kc(e){return arguments.length?this.each(e==null?Cc:(typeof e=="function"?Ic:Mc)(e)):this.node().textContent}function Ac(){this.innerHTML=""}function Pc(e){return function(){this.innerHTML=e}}function $c(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Dc(e){return arguments.length?this.each(e==null?Ac:(typeof e=="function"?$c:Pc)(e)):this.node().innerHTML}function Tc(){this.nextSibling&&this.parentNode.appendChild(this)}function Rc(){return this.each(Tc)}function zc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Hc(){return this.each(zc)}function Lc(e){var t=typeof e=="function"?e:Sr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Bc(){return null}function Vc(e,t){var n=typeof e=="function"?e:Sr(e),o=t==null?Bc:typeof t=="function"?t:Xn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Oc(){var e=this.parentNode;e&&e.removeChild(this)}function jc(){return this.each(Oc)}function Fc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Yc(e){return this.select(e?Xc:Fc)}function Wc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Zc(e){return function(t){e.call(this,t,this.__data__)}}function Gc(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 qc(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 Uc(e,t,n){return function(){var o=this.__on,r,i=Zc(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 Kc(e,t,n){var o=Gc(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=o[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Uc:qc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function Rr(e,t,n){var o=Ar(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 Qc(e,t){return function(){return Rr(this,e,t)}}function Jc(e,t){return function(){return Rr(this,e,t.apply(this,arguments))}}function el(e,t){return this.each((typeof t=="function"?Jc:Qc)(e,t))}function*tl(){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 zr=[null];function ue(e,t){this._groups=e,this._parents=t}function xt(){return new ue([[document.documentElement]],zr)}function nl(){return this}ue.prototype=xt.prototype={constructor:ue,select:Ia,selectAll:$a,selectChild:za,selectChildren:Va,filter:Oa,data:Za,enter:ja,exit:qa,join:Ua,merge:Ka,selection:nl,order:Qa,sort:Ja,call:tc,nodes:nc,node:oc,size:rc,empty:ic,each:sc,attr:hc,style:yc,property:bc,classed:Sc,text:kc,html:Dc,raise:Rc,lower:Hc,append:Lc,insert:Vc,remove:jc,clone:Yc,datum:Wc,on:Kc,dispatch:el,[Symbol.iterator]:tl};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],zr)}function ol(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=ol(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 rl={passive:!1},lt={capture:!0,passive:!1};function gn(e){e.stopImmediatePropagation()}function Xe(e){e.preventDefault(),e.stopImmediatePropagation()}function Hr(e){var t=e.document.documentElement,n=le(e).on("dragstart.drag",Xe,lt);"onselectstart"in t?n.on("selectstart.drag",Xe,lt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Lr(e,t){var n=e.document.documentElement,o=le(e).on("dragstart.drag",null);t&&(o.on("click.drag",Xe,lt),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 Ct=e=>()=>e;function kn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:l,dy:c,dispatch:d}){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:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}kn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function il(e){return!e.ctrlKey&&!e.button}function sl(){return this.parentNode}function al(e,t){return t??{x:e.x,y:e.y}}function cl(){return navigator.maxTouchPoints||"ontouchstart"in this}function Br(){var e=il,t=sl,n=al,o=cl,r={},i=Qt("start","drag","end"),s=0,a,l,c,d,u=0;function f(x){x.on("mousedown.drag",h).filter(o).on("touchstart.drag",w).on("touchmove.drag",m,rl).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,S){if(!(d||!e.call(this,x,S))){var N=p(this,t.call(this,x,S),x,S,"mouse");N&&(le(x.view).on("mousemove.drag",g,lt).on("mouseup.drag",y,lt),Hr(x.view),gn(x),c=!1,a=x.clientX,l=x.clientY,N("start",x))}}function g(x){if(Xe(x),!c){var S=x.clientX-a,N=x.clientY-l;c=S*S+N*N>u}r.mouse("drag",x)}function y(x){le(x.view).on("mousemove.drag mouseup.drag",null),Lr(x.view,c),Xe(x),r.mouse("end",x)}function w(x,S){if(e.call(this,x,S)){var N=x.changedTouches,_=t.call(this,x,S),I=N.length,$,O;for($=0;$<I;++$)(O=p(this,_,x,S,N[$].identifier,N[$]))&&(gn(x),O("start",x,N[$]))}}function m(x){var S=x.changedTouches,N=S.length,_,I;for(_=0;_<N;++_)(I=r[S[_].identifier])&&(Xe(x),I("drag",x,S[_]))}function b(x){var S=x.changedTouches,N=S.length,_,I;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),_=0;_<N;++_)(I=r[S[_].identifier])&&(gn(x),I("end",x,S[_]))}function p(x,S,N,_,I,$){var O=i.copy(),A=de($||N,S),R,V,v;if((v=n.call(x,new kn("beforestart",{sourceEvent:N,target:f,identifier:I,active:s,x:A[0],y:A[1],dx:0,dy:0,dispatch:O}),_))!=null)return R=v.x-A[0]||0,V=v.y-A[1]||0,function M(C,P,k){var D=A,H;switch(C){case"start":r[I]=M,H=s++;break;case"end":delete r[I],--s;case"drag":A=de(k||P,S),H=s;break}O.call(C,x,new kn(C,{sourceEvent:P,subject:v,target:f,identifier:I,active:H,x:A[0]+R,y:A[1]+V,dx:A[0]-D[0],dy:A[1]-D[1],dispatch:O}),_)}}return f.filter=function(x){return arguments.length?(e=typeof x=="function"?x:Ct(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:Ct(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:Ct(x),f):n},f.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:Ct(!!x),f):o},f.on=function(){var x=i.on.apply(i,arguments);return x===i?f:x},f.clickDistance=function(x){return arguments.length?(u=(x=+x)*x,f):Math.sqrt(u)},f}function Wn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Vr(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function wt(){}var ut=.7,jt=1/ut,Ye="\\s*([+-]?\\d+)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ye="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ll=/^#([0-9a-f]{3,8})$/,ul=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),dl=new RegExp(`^rgb\\(${ye},${ye},${ye}\\)$`),fl=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${dt}\\)$`),hl=new RegExp(`^rgba\\(${ye},${ye},${ye},${dt}\\)$`),gl=new RegExp(`^hsl\\(${dt},${ye},${ye}\\)$`),pl=new RegExp(`^hsla\\(${dt},${ye},${ye},${dt}\\)$`),wo={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};Wn(wt,Re,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:vo,formatHex:vo,formatHex8:ml,formatHsl:yl,formatRgb:bo,toString:bo});function vo(){return this.rgb().formatHex()}function ml(){return this.rgb().formatHex8()}function yl(){return Or(this).formatHsl()}function bo(){return this.rgb().formatRgb()}function Re(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=ll.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?_o(t):n===3?new ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mt(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=ul.exec(e))?new ce(t[1],t[2],t[3],1):(t=dl.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=fl.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=hl.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=gl.exec(e))?So(t[1],t[2]/100,t[3]/100,1):(t=pl.exec(e))?So(t[1],t[2]/100,t[3]/100,t[4]):wo.hasOwnProperty(e)?_o(wo[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function _o(e){return new ce(e>>16&255,e>>8&255,e&255,1)}function Mt(e,t,n,o){return o<=0&&(e=t=n=NaN),new ce(e,t,n,o)}function xl(e){return e instanceof wt||(e=Re(e)),e?(e=e.rgb(),new ce(e.r,e.g,e.b,e.opacity)):new ce}function An(e,t,n,o){return arguments.length===1?xl(e):new ce(e,t,n,o??1)}function ce(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Wn(ce,An,Vr(wt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ce(De(this.r),De(this.g),De(this.b),Ft(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:Eo,formatHex:Eo,formatHex8:wl,formatRgb:No,toString:No}));function Eo(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}`}function wl(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}${$e((isNaN(this.opacity)?1:this.opacity)*255)}`}function No(){const e=Ft(this.opacity);return`${e===1?"rgb(":"rgba("}${De(this.r)}, ${De(this.g)}, ${De(this.b)}${e===1?")":`, ${e})`}`}function Ft(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function De(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $e(e){return e=De(e),(e<16?"0":"")+e.toString(16)}function So(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new fe(e,t,n,o)}function Or(e){if(e instanceof fe)return new fe(e.h,e.s,e.l,e.opacity);if(e instanceof wt||(e=Re(e)),!e)return new fe;if(e instanceof fe)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,l=(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/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new fe(s,a,l,e.opacity)}function vl(e,t,n,o){return arguments.length===1?Or(e):new fe(e,t,n,o??1)}function fe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Wn(fe,vl,Vr(wt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new fe(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 ce(pn(e>=240?e-240:e+120,r,o),pn(e,r,o),pn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new fe(Co(this.h),It(this.s),It(this.l),Ft(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=Ft(this.opacity);return`${e===1?"hsl(":"hsla("}${Co(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Co(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function pn(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 Zn=e=>()=>e;function bl(e,t){return function(n){return e+n*t}}function _l(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 El(e){return(e=+e)==1?jr:function(t,n){return n-t?_l(t,n,e):Zn(isNaN(t)?n:t)}}function jr(e,t){var n=t-e;return n?bl(e,n):Zn(isNaN(e)?t:e)}const Xt=(function e(t){var n=El(t);function o(r,i){var s=n((r=An(r)).r,(i=An(i)).r),a=n(r.g,i.g),l=n(r.b,i.b),c=jr(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return o.gamma=e,o})(1);function Nl(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 Sl(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Cl(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]=at(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 Ml(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function me(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Il(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]=at(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var Pn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mn=new RegExp(Pn.source,"g");function kl(e){return function(){return e}}function Al(e){return function(t){return e(t)+""}}function Fr(e,t){var n=Pn.lastIndex=mn.lastIndex=0,o,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(o=Pn.exec(e))&&(r=mn.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,l.push({i:s,x:me(o,r)})),n=mn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Al(l[0].x):kl(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}function at(e,t){var n=typeof t,o;return t==null||n==="boolean"?Zn(t):(n==="number"?me:n==="string"?(o=Re(t))?(t=o,Xt):Fr:t instanceof Re?Xt:t instanceof Date?Ml:Sl(t)?Nl:Array.isArray(t)?Cl:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Il:me)(e,t)}var Mo=180/Math.PI,$n={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Xr(e,t,n,o,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,l/=a),e*o<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Mo,skewX:Math.atan(l)*Mo,scaleX:s,scaleY:a}}var kt;function Pl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?$n:Xr(t.a,t.b,t.c,t.d,t.e,t.f)}function $l(e){return e==null||(kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","g")),kt.setAttribute("transform",e),!(e=kt.transform.baseVal.consolidate()))?$n:(e=e.matrix,Xr(e.a,e.b,e.c,e.d,e.e,e.f))}function Yr(e,t,n,o){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,h,g){if(c!==u||d!==f){var y=h.push("translate(",null,t,null,n);g.push({i:y-4,x:me(c,u)},{i:y-2,x:me(d,f)})}else(u||f)&&h.push("translate("+u+t+f+n)}function s(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,o)-2,x:me(c,d)})):d&&u.push(r(u)+"rotate("+d+o)}function a(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,o)-2,x:me(c,d)}):d&&u.push(r(u)+"skewX("+d+o)}function l(c,d,u,f,h,g){if(c!==u||d!==f){var y=h.push(r(h)+"scale(",null,",",null,")");g.push({i:y-4,x:me(c,u)},{i:y-2,x:me(d,f)})}else(u!==1||f!==1)&&h.push(r(h)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),s(c.rotate,d.rotate,u,f),a(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(h){for(var g=-1,y=f.length,w;++g<y;)u[(w=f[g]).i]=w.x(h);return u.join("")}}}var Dl=Yr(Pl,"px, ","px)","deg)"),Tl=Yr($l,", ",")",")"),Rl=1e-12;function Io(e){return((e=Math.exp(e))+1/e)/2}function zl(e){return((e=Math.exp(e))-1/e)/2}function Hl(e){return((e=Math.exp(2*e))-1)/(e+1)}const zt=(function e(t,n,o){function r(i,s){var a=i[0],l=i[1],c=i[2],d=s[0],u=s[1],f=s[2],h=d-a,g=u-l,y=h*h+g*g,w,m;if(y<Rl)m=Math.log(f/c)/t,w=function(_){return[a+_*h,l+_*g,c*Math.exp(t*_*m)]};else{var b=Math.sqrt(y),p=(f*f-c*c+o*y)/(2*c*n*b),x=(f*f-c*c-o*y)/(2*f*n*b),S=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(x*x+1)-x);m=(N-S)/t,w=function(_){var I=_*m,$=Io(S),O=c/(n*b)*($*Hl(t*I+S)-zl(S));return[a+O*h,l+O*g,c*$/Io(t*I+S)]}}return w.duration=m*1e3*t/Math.SQRT2,w}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,l=a*a;return e(s,a,l)},r})(Math.SQRT2,2,4);var Ze=0,it=0,ot=0,Wr=1e3,Yt,st,Wt=0,ze=0,en=0,ft=typeof performance=="object"&&performance.now?performance:Date,Zr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Gn(){return ze||(Zr(Ll),ze=ft.now()+en)}function Ll(){ze=0}function Zt(){this._call=this._time=this._next=null}Zt.prototype=Gr.prototype={constructor:Zt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Gn():+n)+(t==null?0:+t),!this._next&&st!==this&&(st?st._next=this:Yt=this,st=this),this._call=e,this._time=n,Dn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Dn())}};function Gr(e,t,n){var o=new Zt;return o.restart(e,t,n),o}function Bl(){Gn(),++Ze;for(var e=Yt,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ze}function ko(){ze=(Wt=ft.now())+en,Ze=it=0;try{Bl()}finally{Ze=0,Ol(),ze=0}}function Vl(){var e=ft.now(),t=e-Wt;t>Wr&&(en-=t,Wt=e)}function Ol(){for(var e,t=Yt,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:Yt=n);st=e,Dn(o)}function Dn(e){if(!Ze){it&&(it=clearTimeout(it));var t=e-ze;t>24?(e<1/0&&(it=setTimeout(ko,e-ft.now()-en)),ot&&(ot=clearInterval(ot))):(ot||(Wt=ft.now(),ot=setInterval(Vl,Wr)),Ze=1,Zr(ko))}}function Ao(e,t,n){var o=new Zt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var jl=Qt("start","end","cancel","interrupt"),Fl=[],qr=0,Po=1,Tn=2,Ht=3,$o=4,Rn=5,Lt=6;function tn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Xl(e,n,{name:t,index:o,group:r,on:jl,tween:Fl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:qr})}function qn(e,t){var n=pe(e,t);if(n.state>qr)throw new Error("too late; already scheduled");return n}function we(e,t){var n=pe(e,t);if(n.state>Ht)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Xl(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Gr(i,0,n.time);function i(c){n.state=Po,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var d,u,f,h;if(n.state!==Po)return l();for(d in o)if(h=o[d],h.name===n.name){if(h.state===Ht)return Ao(s);h.state===$o?(h.state=Lt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[d]):+d<t&&(h.state=Lt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[d])}if(Ao(function(){n.state===Ht&&(n.state=$o,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=Tn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Tn){for(n.state=Ht,r=new Array(f=n.tween.length),d=0,u=-1;d<f;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=h);r.length=u+1}}function a(c){for(var d=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Rn,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);n.state===Rn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Lt,n.timer.stop(),delete o[t];for(var c in o)return;delete e.__transition}}function Bt(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>Tn&&o.state<Rn,o.state=Lt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Yl(e){return this.each(function(){Bt(this,e)})}function Wl(e,t){var n,o;return function(){var r=we(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 Zl(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=we(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Gl(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=pe(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?Wl:Zl)(n,e,t))}function Un(e,t,n){var o=e._id;return e.each(function(){var r=we(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return pe(r,o).value[t]}}function Ur(e,t){var n;return(typeof t=="number"?me:t instanceof Re?Xt:(n=Re(t))?(t=n,Xt):Fr)(e,t)}function ql(e){return function(){this.removeAttribute(e)}}function Ul(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Kl(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 Ql(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 Jl(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function eu(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function tu(e,t){var n=Jt(e),o=n==="transform"?Tl:Ur;return this.attrTween(e,typeof t=="function"?(n.local?eu:Jl)(n,o,Un(this,"attr."+e,t)):t==null?(n.local?Ul:ql)(n):(n.local?Ql:Kl)(n,o,t))}function nu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ou(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ru(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&ou(e,i)),n}return r._value=t,r}function iu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&nu(e,i)),n}return r._value=t,r}function su(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=Jt(e);return this.tween(n,(o.local?ru:iu)(o,t))}function au(e,t){return function(){qn(this,e).delay=+t.apply(this,arguments)}}function cu(e,t){return t=+t,function(){qn(this,e).delay=t}}function lu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?au:cu)(t,e)):pe(this.node(),t).delay}function uu(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function du(e,t){return t=+t,function(){we(this,e).duration=t}}function fu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?uu:du)(t,e)):pe(this.node(),t).duration}function hu(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function gu(e){var t=this._id;return arguments.length?this.each(hu(t,e)):pe(this.node(),t).ease}function pu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;we(this,e).ease=n}}function mu(e){if(typeof e!="function")throw new Error;return this.each(pu(this._id,e))}function yu(e){typeof e!="function"&&(e=Mr(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]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ee(o,this._parents,this._name,this._id)}function xu(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 l=t[a],c=n[a],d=l.length,u=s[a]=new Array(d),f,h=0;h<d;++h)(f=l[h]||c[h])&&(u[h]=f);for(;a<o;++a)s[a]=t[a];return new Ee(s,this._parents,this._name,this._id)}function wu(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 vu(e,t,n){var o,r,i=wu(t)?qn:we;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function bu(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(vu(n,e,t))}function _u(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Eu(){return this.on("end.remove",_u(this._id))}function Nu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Xn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],l=a.length,c=i[s]=new Array(l),d,u,f=0;f<l;++f)(d=a[f])&&(u=e.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,tn(c[f],t,n,f,c,pe(d,n)));return new Ee(i,this._parents,t,n)}function Su(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Cr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var l=o[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=e.call(d,d.__data__,u,l),h,g=pe(d,n),y=0,w=f.length;y<w;++y)(h=f[y])&&tn(h,t,n,y,f,g);i.push(f),s.push(d)}return new Ee(i,s,t,n)}var Cu=xt.prototype.constructor;function Mu(){return new Cu(this._groups,this._parents)}function Iu(e,t){var n,o,r;return function(){var i=We(this,e),s=(this.style.removeProperty(e),We(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Kr(e){return function(){this.style.removeProperty(e)}}function ku(e,t,n){var o,r=n+"",i;return function(){var s=We(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function Au(e,t,n){var o,r,i;return function(){var s=We(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),We(this,e))),s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a))}}function Pu(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var l=we(this,e),c=l.on,d=l.value[i]==null?a||(a=Kr(t)):void 0;(c!==n||r!==d)&&(o=(n=c).copy()).on(s,r=d),l.on=o}}function $u(e,t,n){var o=(e+="")=="transform"?Dl:Ur;return t==null?this.styleTween(e,Iu(e,o)).on("end.style."+e,Kr(e)):typeof t=="function"?this.styleTween(e,Au(e,o,Un(this,"style."+e,t))).each(Pu(this._id,e)):this.styleTween(e,ku(e,o,t),n).on("end.style."+e,null)}function Du(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Tu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Du(e,s,n)),o}return i._value=t,i}function Ru(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,Tu(e,t,n??""))}function zu(e){return function(){this.textContent=e}}function Hu(e){return function(){var t=e(this);this.textContent=t??""}}function Lu(e){return this.tween("text",typeof e=="function"?Hu(Un(this,"text",e)):zu(e==null?"":e+""))}function Bu(e){return function(t){this.textContent=e.call(this,t)}}function Vu(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Bu(r)),t}return o._value=e,o}function Ou(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,Vu(e))}function ju(){for(var e=this._name,t=this._id,n=Qr(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=pe(l,t);tn(l,e,n,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ee(o,this._parents,e,n)}function Fu(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};n.each(function(){var c=we(this,o),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Xu=0;function Ee(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Qr(){return++Xu}var be=xt.prototype;Ee.prototype={constructor:Ee,select:Nu,selectAll:Su,selectChild:be.selectChild,selectChildren:be.selectChildren,filter:yu,merge:xu,selection:Mu,transition:ju,call:be.call,nodes:be.nodes,node:be.node,size:be.size,empty:be.empty,each:be.each,on:bu,attr:tu,attrTween:su,style:$u,styleTween:Ru,text:Lu,textTween:Ou,remove:Eu,tween:Gl,delay:lu,duration:fu,ease:gu,easeVarying:mu,end:Fu,[Symbol.iterator]:be[Symbol.iterator]};function Yu(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Wu={time:null,delay:0,duration:250,ease:Yu};function Zu(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 Gu(e){var t,n;e instanceof Ee?(t=e._id,e=e._name):(t=Qr(),(n=Wu).time=Gn(),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,l,c=0;c<a;++c)(l=s[c])&&tn(l,e,t,c,s,n||Zu(l,t));return new Ee(o,this._parents,e,t)}xt.prototype.interrupt=Yl;xt.prototype.transition=Gu;const At=e=>()=>e;function qu(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 _e(e,t,n){this.k=e,this.x=t,this.y=n}_e.prototype={constructor:_e,scale:function(e){return e===1?this:new _e(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _e(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 nn=new _e(1,0,0);Jr.prototype=_e.prototype;function Jr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function yn(e){e.stopImmediatePropagation()}function rt(e){e.preventDefault(),e.stopImmediatePropagation()}function Uu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ku(){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 Do(){return this.__zoom||nn}function Qu(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ju(){return navigator.maxTouchPoints||"ontouchstart"in this}function ed(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 ei(){var e=Uu,t=Ku,n=ed,o=Qu,r=Ju,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=zt,c=Qt("start","zoom","end"),d,u,f,h=500,g=150,y=0,w=10;function m(v){v.property("__zoom",Do).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",A).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(v,M,C,P){var k=v.selection?v.selection():v;k.property("__zoom",Do),v!==k?S(v,M,C,P):k.interrupt().each(function(){N(this,arguments).event(P).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},m.scaleBy=function(v,M,C,P){m.scaleTo(v,function(){var k=this.__zoom.k,D=typeof M=="function"?M.apply(this,arguments):M;return k*D},C,P)},m.scaleTo=function(v,M,C,P){m.transform(v,function(){var k=t.apply(this,arguments),D=this.__zoom,H=C==null?x(k):typeof C=="function"?C.apply(this,arguments):C,B=D.invert(H),L=typeof M=="function"?M.apply(this,arguments):M;return n(p(b(D,L),H,B),k,s)},C,P)},m.translateBy=function(v,M,C,P){m.transform(v,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,P)},m.translateTo=function(v,M,C,P,k){m.transform(v,function(){var D=t.apply(this,arguments),H=this.__zoom,B=P==null?x(D):typeof P=="function"?P.apply(this,arguments):P;return n(nn.translate(B[0],B[1]).scale(H.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof C=="function"?-C.apply(this,arguments):-C),D,s)},P,k)};function b(v,M){return M=Math.max(i[0],Math.min(i[1],M)),M===v.k?v:new _e(M,v.x,v.y)}function p(v,M,C){var P=M[0]-C[0]*v.k,k=M[1]-C[1]*v.k;return P===v.x&&k===v.y?v:new _e(v.k,P,k)}function x(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function S(v,M,C,P){v.on("start.zoom",function(){N(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(P).end()}).tween("zoom",function(){var k=this,D=arguments,H=N(k,D).event(P),B=t.apply(k,D),L=C==null?x(B):typeof C=="function"?C.apply(k,D):C,z=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),j=k.__zoom,Y=typeof M=="function"?M.apply(k,D):M,U=l(j.invert(L).concat(z/j.k),Y.invert(L).concat(z/Y.k));return function(Z){if(Z===1)Z=Y;else{var F=U(Z),W=z/F[2];Z=new _e(W,L[0]-F[0]*W,L[1]-F[1]*W)}H.zoom(null,Z)}})}function N(v,M,C){return!C&&v.__zooming||new _(v,M)}function _(v,M){this.that=v,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,M),this.taps=0}_.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,M){return this.mouse&&v!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var M=le(this.that).datum();c.call(v,this.that,new qu(v,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:c}),M)}};function I(v,...M){if(!e.apply(this,arguments))return;var C=N(this,M).event(v),P=this.__zoom,k=Math.max(i[0],Math.min(i[1],P.k*Math.pow(2,o.apply(this,arguments)))),D=de(v);if(C.wheel)(C.mouse[0][0]!==D[0]||C.mouse[0][1]!==D[1])&&(C.mouse[1]=P.invert(C.mouse[0]=D)),clearTimeout(C.wheel);else{if(P.k===k)return;C.mouse=[D,P.invert(D)],Bt(this),C.start()}rt(v),C.wheel=setTimeout(H,g),C.zoom("mouse",n(p(b(P,k),C.mouse[0],C.mouse[1]),C.extent,s));function H(){C.wheel=null,C.end()}}function $(v,...M){if(f||!e.apply(this,arguments))return;var C=v.currentTarget,P=N(this,M,!0).event(v),k=le(v.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",z,!0),D=de(v,C),H=v.clientX,B=v.clientY;Hr(v.view),yn(v),P.mouse=[D,this.__zoom.invert(D)],Bt(this),P.start();function L(j){if(rt(j),!P.moved){var Y=j.clientX-H,U=j.clientY-B;P.moved=Y*Y+U*U>y}P.event(j).zoom("mouse",n(p(P.that.__zoom,P.mouse[0]=de(j,C),P.mouse[1]),P.extent,s))}function z(j){k.on("mousemove.zoom mouseup.zoom",null),Lr(j.view,P.moved),rt(j),P.event(j).end()}}function O(v,...M){if(e.apply(this,arguments)){var C=this.__zoom,P=de(v.changedTouches?v.changedTouches[0]:v,this),k=C.invert(P),D=C.k*(v.shiftKey?.5:2),H=n(p(b(C,D),P,k),t.apply(this,M),s);rt(v),a>0?le(this).transition().duration(a).call(S,H,P,v):le(this).call(m.transform,H,P,v)}}function A(v,...M){if(e.apply(this,arguments)){var C=v.touches,P=C.length,k=N(this,M,v.changedTouches.length===P).event(v),D,H,B,L;for(yn(v),H=0;H<P;++H)B=C[H],L=de(B,this),L=[L,this.__zoom.invert(L),B.identifier],k.touch0?!k.touch1&&k.touch0[2]!==L[2]&&(k.touch1=L,k.taps=0):(k.touch0=L,D=!0,k.taps=1+!!d);d&&(d=clearTimeout(d)),D&&(k.taps<2&&(u=L[0],d=setTimeout(function(){d=null},h)),Bt(this),k.start())}}function R(v,...M){if(this.__zooming){var C=N(this,M).event(v),P=v.changedTouches,k=P.length,D,H,B,L;for(rt(v),D=0;D<k;++D)H=P[D],B=de(H,this),C.touch0&&C.touch0[2]===H.identifier?C.touch0[0]=B:C.touch1&&C.touch1[2]===H.identifier&&(C.touch1[0]=B);if(H=C.that.__zoom,C.touch1){var z=C.touch0[0],j=C.touch0[1],Y=C.touch1[0],U=C.touch1[1],Z=(Z=Y[0]-z[0])*Z+(Z=Y[1]-z[1])*Z,F=(F=U[0]-j[0])*F+(F=U[1]-j[1])*F;H=b(H,Math.sqrt(Z/F)),B=[(z[0]+Y[0])/2,(z[1]+Y[1])/2],L=[(j[0]+U[0])/2,(j[1]+U[1])/2]}else if(C.touch0)B=C.touch0[0],L=C.touch0[1];else return;C.zoom("touch",n(p(H,B,L),C.extent,s))}}function V(v,...M){if(this.__zooming){var C=N(this,M).event(v),P=v.changedTouches,k=P.length,D,H;for(yn(v),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),D=0;D<k;++D)H=P[D],C.touch0&&C.touch0[2]===H.identifier?delete C.touch0:C.touch1&&C.touch1[2]===H.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(H=de(H,this),Math.hypot(u[0]-H[0],u[1]-H[1])<w)){var B=le(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return m.wheelDelta=function(v){return arguments.length?(o=typeof v=="function"?v:At(+v),m):o},m.filter=function(v){return arguments.length?(e=typeof v=="function"?v:At(!!v),m):e},m.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:At(!!v),m):r},m.extent=function(v){return arguments.length?(t=typeof v=="function"?v:At([[+v[0][0],+v[0][1]],[+v[1][0],+v[1][1]]]),m):t},m.scaleExtent=function(v){return arguments.length?(i[0]=+v[0],i[1]=+v[1],m):[i[0],i[1]]},m.translateExtent=function(v){return arguments.length?(s[0][0]=+v[0][0],s[1][0]=+v[1][0],s[0][1]=+v[0][1],s[1][1]=+v[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(v){return arguments.length?(n=v,m):n},m.duration=function(v){return arguments.length?(a=+v,m):a},m.interpolate=function(v){return arguments.length?(l=v,m):l},m.on=function(){var v=c.on.apply(c,arguments);return v===c?m:v},m.clickDistance=function(v){return arguments.length?(y=(v=+v)*v,m):Math.sqrt(y)},m.tapDistance=function(v){return arguments.length?(w=+v,m):w},m}const xe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id: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."},ht=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ti=["Enter"," ","Escape"],ni={"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 He;(function(e){e.Strict="strict",e.Loose="loose"})(He||(He={}));var Te;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Te||(Te={}));var gt;(function(e){e.Partial="partial",e.Full="full"})(gt||(gt={}));const oi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var Gt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Gt||(Gt={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const To={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function ri(e){return e===null?null:e?"valid":"invalid"}const ii=e=>"id"in e&&"source"in e&&"target"in e,td=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Kn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vt=(e,t=[0,0])=>{const{width:n,height:o}=Ne(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},nd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):Kn(r)?r:t.nodeLookup.get(r.id));const a=s?qt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return on(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return rn(n)},bt=(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=on(n,qt(r)),o=!0)}),o?rn(n):{x:0,y:0,width:0,height:0}},Qn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...Et(t,[n,o,r]),width:t.width/r,height:t.height/r},l=[];for(const c of e.values()){const{measured:d,selectable:u=!0,hidden:f=!1}=c;if(s&&!u||f)continue;const h=d.width??c.width??c.initialWidth??null,g=d.height??c.height??c.initialHeight??null,y=pt(a,qe(c)),w=(h??0)*(g??0),m=i&&y>0;(!c.internals.handleBounds||m||y>=w||c.dragging)&&l.push(c)}return l},od=(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 rd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function id({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=rd(e,s),l=bt(a),c=Jn(l,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(c,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function si({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:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},d=s.origin??o;let u=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",xe.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[l,c],[l+h,c+g]])}else a&&Ue(s.extent)&&(u=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);const f=Ue(u)?Le(t,u,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",xe.error015()),{position:{x:f.x-l+(s.measured.width??0)*d[0],y:f.y-c+(s.measured.height??0)*d[1]},positionAbsolute:f}}async function sd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(y=>y.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),l=o.filter(f=>f.deletable!==!1),d=od(s,l);for(const f of l)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!r)return{edges:d,nodes:s};const u=await r({nodes:s,edges:d});return typeof u=="boolean"?u?{edges:d,nodes:s}:{edges:[],nodes:[]}:u}const Ge=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Le=(e={x:0,y:0},t,n)=>({x:Ge(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ge(e.y,t[0][1],t[1][1]-(n?.height??0))});function ai(e,t,n){const{width:o,height:r}=Ne(n),{x:i,y:s}=n.internals.positionAbsolute;return Le(e,[[i,s],[i+o,s+r]],t)}const Ro=(e,t,n)=>e<t?Ge(Math.abs(e-t),1,t)/t:e>n?-Ge(Math.abs(e-n),1,t)/t:0,ci=(e,t,n=15,o=40)=>{const r=Ro(e.x,o,t.width-o)*n,i=Ro(e.y,o,t.height-o)*n;return[r,i]},on=(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}),rn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),qe=(e,t=[0,0])=>{const{x:n,y:o}=Kn(e)?e.internals.positionAbsolute:vt(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}},qt=(e,t=[0,0])=>{const{x:n,y:o}=Kn(e)?e.internals.positionAbsolute:vt(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)}},li=(e,t)=>rn(on(zn(e),zn(t))),pt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},zo=e=>he(e.width)&&he(e.height)&&he(e.x)&&he(e.y),he=e=>!isNaN(e)&&isFinite(e),ad=(e,t)=>{},_t=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Et=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?_t(a,s):a},Ut=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Oe(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(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function cd(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Oe(e,n),r=Oe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Oe(e.top??e.y??0,n),r=Oe(e.bottom??e.y??0,n),i=Oe(e.left??e.x??0,t),s=Oe(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 ld(e,t,n,o,r,i){const{x:s,y:a}=Ut(e,[t,n,o]),{x:l,y:c}=Ut({x:e.x+e.width,y:e.y+e.height},[t,n,o]),d=r-l,u=i-c;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(u)}}const Jn=(e,t,n,o,r,i)=>{const s=cd(i,t,n),a=(t-s.x)/e.width,l=(n-s.y)/e.height,c=Math.min(a,l),d=Ge(c,o,r),u=e.x+e.width/2,f=e.y+e.height/2,h=t/2-u*d,g=n/2-f*d,y=ld(e,h,g,d,t,n),w={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:h-w.left+w.right,y:g-w.top+w.bottom,zoom:d}},mt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ue(e){return e!=null&&e!=="parent"}function Ne(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function ui(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function di(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 Ho(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function ud(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function dd(e){return{...ni,...e||{}}}function ct(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=ge(e),a=Et({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:l,y:c}=n?_t(a,t):a;return{xSnapped:l,ySnapped:c,...a}}const eo=e=>({width:e.offsetWidth,height:e.offsetHeight}),fi=e=>e?.getRootNode?.()||window?.document,fd=["INPUT","SELECT","TEXTAREA"];function hi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:fd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const gi=e=>"clientX"in e,ge=(e,t)=>{const n=gi(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)}},Lo=(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,...eo(s)}})};function pi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=e*.125+r*.375+s*.375+n*.125,c=t*.125+i*.375+a*.375+o*.125,d=Math.abs(l-e),u=Math.abs(c-t);return[l,c,d,u]}function Pt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Bo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Pt(t-o,i),n];case X.Right:return[t+Pt(o-t,i),n];case X.Top:return[t,n-Pt(n-r,i)];case X.Bottom:return[t,n+Pt(r-n,i)]}}function mi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,l]=Bo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,d]=Bo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[u,f,h,g]=pi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${o},${r}`,u,f,h,g]}function yi({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 hd({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 gd({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=on(qt(e),qt(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 pt(s,rn(i))>0}const pd=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,md=(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)),yd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||pd;let r;return ii(e)?r={...e}:r={...e,id:o(e)},md(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function xi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=yi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Vo={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},xd=({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},Oo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function wd({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=Vo[t],l=Vo[o],c={x:e.x+a.x*i,y:e.y+a.y*i},d={x:n.x+l.x*i,y:n.y+l.y*i},u=xd({source:c,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let g=[],y,w;const m={x:0,y:0},b={x:0,y:0},[,,p,x]=yi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*l[f]===-1){f==="x"?(y=r.x??c.x+(d.x-c.x)*s,w=r.y??(c.y+d.y)/2):(y=r.x??(c.x+d.x)/2,w=r.y??c.y+(d.y-c.y)*s);const I=[{x:y,y:c.y},{x:y,y:d.y}],$=[{x:c.x,y:w},{x:d.x,y:w}];a[f]===h?g=f==="x"?I:$:g=f==="x"?$:I}else{const I=[{x:c.x,y:d.y}],$=[{x:d.x,y:c.y}];if(f==="x"?g=a.x===h?$:I:g=a.y===h?I:$,t===o){const v=Math.abs(e[f]-n[f]);if(v<=i){const M=Math.min(i-1,i-v);a[f]===h?m[f]=(c[f]>e[f]?-1:1)*M:b[f]=(d[f]>n[f]?-1:1)*M}}if(t!==o){const v=f==="x"?"y":"x",M=a[f]===l[v],C=c[v]>d[v],P=c[v]<d[v];(a[f]===1&&(!M&&C||M&&P)||a[f]!==1&&(!M&&P||M&&C))&&(g=f==="x"?I:$)}const O={x:c.x+m.x,y:c.y+m.y},A={x:d.x+b.x,y:d.y+b.y},R=Math.max(Math.abs(O.x-g[0].x),Math.abs(A.x-g[0].x)),V=Math.max(Math.abs(O.y-g[0].y),Math.abs(A.y-g[0].y));R>=V?(y=(O.x+A.x)/2,w=g[0].y):(y=g[0].x,w=(O.y+A.y)/2)}const S={x:c.x+m.x,y:c.y+m.y},N={x:d.x+b.x,y:d.y+b.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],y,w,p,x]}function vd(e,t,n,o){const r=Math.min(Oo(e,t)/2,Oo(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 c=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+r*c},${s}Q ${i},${s} ${i},${s+r*d}`}const a=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${s+r*l}Q ${i},${s} ${i+r*a},${s}`}function Hn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:d=.5}){const[u,f,h,g,y]=wd({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:d});let w=`M${u[0].x} ${u[0].y}`;for(let m=1;m<u.length-1;m++)w+=vd(u[m-1],u[m],u[m+1],s);return w+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[w,f,h,g,y]}function jo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function bd(e){const{sourceNode:t,targetNode:n}=e;if(!jo(t)||!jo(n))return null;const o=t.internals.handleBounds||Fo(t.handles),r=n.internals.handleBounds||Fo(n.handles),i=Xo(o?.source??[],e.sourceHandle),s=Xo(e.connectionMode===He.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",xe.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||X.Bottom,l=s?.position||X.Top,c=Be(t,i,a),d=Be(n,s,l);return{sourceX:c.x,sourceY:c.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:l}}function Fo(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 Be(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??Ne(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 Xo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ln(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function _d(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(l=>{if(l&&typeof l=="object"){const c=Ln(l,t);i.has(c)||(s.push({id:c,color:l.color||n,...l}),i.add(c))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const wi=1e3,Ed=10,to={nodeOrigin:[0,0],nodeExtent:ht,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Nd={...to,checkEquality:!0};function no(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Sd(e,t,n){const o=no(to,n);for(const r of e.values())if(r.parentId)ro(r,e,t,o);else{const i=vt(r,o.nodeOrigin),s=Ue(r.extent)?r.extent:o.nodeExtent,a=Le(i,s,Ne(r));r.internals.positionAbsolute=a}}function Cd(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 oo(e){return e==="manual"}function Bn(e,t,n,o={}){const r=no(Nd,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!oo(r.zIndexMode)?wi:0;let l=e.length>0,c=!1;t.clear(),n.clear();for(const d of e){let u=s.get(d.id);if(r.checkEquality&&d===u?.internals.userNode)t.set(d.id,u);else{const f=vt(d,r.nodeOrigin),h=Ue(d.extent)?d.extent:r.nodeExtent,g=Le(f,h,Ne(d));u={...r.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:g,handleBounds:Cd(d,u),z:vi(d,a,r.zIndexMode),userNode:d}},t.set(d.id,u)}(u.measured===void 0||u.measured.width===void 0||u.measured.height===void 0)&&!u.hidden&&(l=!1),d.parentId&&ro(u,t,n,o,i),c||=d.selected??!1}return{nodesInitialized:l,hasSelectedNodes:c}}function Md(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 ro(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=no(to,o),c=e.parentId,d=t.get(c);if(!d){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Md(e,n),r&&!d.parentId&&d.internals.rootParentIndex===void 0&&l==="auto"&&(d.internals.rootParentIndex=++r.i,d.internals.z=d.internals.z+r.i*Ed),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const u=i&&!oo(l)?wi:0,{x:f,y:h,z:g}=Id(e,d,s,a,u,l),{positionAbsolute:y}=e.internals,w=f!==y.x||h!==y.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:h}:y,z:g}})}function vi(e,t,n){const o=he(e.zIndex)?e.zIndex:0;return oo(n)?o:o+(e.selected?t:0)}function Id(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,l=Ne(e),c=vt(e,n),d=Ue(e.extent)?Le(c,e.extent,l):c;let u=Le({x:s+d.x,y:a+d.y},o,l);e.extent==="parent"&&(u=ai(u,l,t));const f=vi(e,r,i),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function io(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 l=i.get(s.parentId)?.expandedRect??qe(a),c=li(l,s.rect);i.set(s.parentId,{expandedRect:c,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},l)=>{const c=a.internals.positionAbsolute,d=Ne(a),u=a.origin??o,f=s.x<c.x?Math.round(Math.abs(c.x-s.x)):0,h=s.y<c.y?Math.round(Math.abs(c.y-s.y)):0,g=Math.max(d.width,Math.round(s.width)),y=Math.max(d.height,Math.round(s.height)),w=(g-d.width)*u[0],m=(y-d.height)*u[1];(f>0||h>0||w||m)&&(r.push({id:l,type:"position",position:{x:a.position.x-f+w,y:a.position.y-h+m}}),n.get(l)?.forEach(b=>{e.some(p=>p.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+h}})})),(d.width<s.width||d.height<s.height||f||h)&&r.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:g+(f?u[0]*f-w:0),height:y+(h?u[1]*h-m:0)}})}),r}function kd(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let l=!1;if(!a)return{changes:[],updatedInternals:l};const c=[],d=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(d.transform),f=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),l=!0;continue}const y=eo(h.nodeElement),w=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(w||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ue(g.extent)?g.extent:i;let{positionAbsolute:x}=g.internals;g.parentId&&g.extent==="parent"?x=ai(x,y,t.get(g.parentId)):p&&(x=Le(x,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:Lo("source",h.nodeElement,b,u,g.id),target:Lo("target",h.nodeElement,b,u,g.id)}}};t.set(g.id,S),g.parentId&&ro(S,t,n,{nodeOrigin:r,zIndexMode:s}),l=!0,w&&(c.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:qe(S,r)}))}}if(f.length>0){const h=io(f,t,n,r);c.push(...h)}return{changes:c,updatedInternals:l}}async function Ad({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Yo(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 l=o.get(s)||new Map;if(o.set(s,l.set(n,t)),i){s=`${r}-${e}-${i}`;const c=o.get(s)||new Map;o.set(s,c.set(n,t))}}function bi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,l={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},c=`${r}-${s}--${i}-${a}`,d=`${i}-${a}--${r}-${s}`;Yo("source",l,d,e,r,s),Yo("target",l,c,e,i,a),t.set(o.id,o)}}function _i(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:_i(n,t):!1}function Wo(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 Pd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!_i(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 xn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const l=n.get(s)?.internals.userNode;l&&r.push({...l,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 $d({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=_t(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Dd({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},d=null,u=!1,f=null,h=!1,g=!1,y=null;function w({noDragClassName:b,handleSelector:p,domNode:x,isSelectable:S,nodeId:N,nodeClickDistance:_=0}){f=le(x);function I({x:R,y:V}){const{nodeLookup:v,nodeExtent:M,snapGrid:C,snapToGrid:P,nodeOrigin:k,onNodeDrag:D,onSelectionDrag:H,onError:B,updateNodePositions:L}=t();i={x:R,y:V};let z=!1;const j=a.size>1,Y=j&&M?zn(bt(a)):null,U=j&&P?$d({dragItems:a,snapGrid:C,x:R,y:V}):null;for(const[Z,F]of a){if(!v.has(Z))continue;let W={x:R-F.distance.x,y:V-F.distance.y};P&&(W=U?{x:Math.round(W.x+U.x),y:Math.round(W.y+U.y)}:_t(W,C));let Q=null;if(j&&M&&!F.extent&&Y){const{positionAbsolute:q}=F.internals,te=q.x-Y.x+M[0][0],oe=q.x+F.measured.width-Y.x2+M[1][0],ne=q.y-Y.y+M[0][1],ae=q.y+F.measured.height-Y.y2+M[1][1];Q=[[te,ne],[oe,ae]]}const{position:K,positionAbsolute:G}=si({nodeId:Z,nextPosition:W,nodeLookup:v,nodeExtent:Q||M,nodeOrigin:k,onError:B});z=z||F.position.x!==K.x||F.position.y!==K.y,F.position=K,F.internals.positionAbsolute=G}if(g=g||z,!!z&&(L(a,!0),y&&(o||D||!N&&H))){const[Z,F]=xn({nodeId:N,dragItems:a,nodeLookup:v});o?.(y,a,Z,F),D?.(y,Z,F),N||H?.(y,F)}}async function $(){if(!d)return;const{transform:R,panBy:V,autoPanSpeed:v,autoPanOnNodeDrag:M}=t();if(!M){l=!1,cancelAnimationFrame(s);return}const[C,P]=ci(c,d,v);(C!==0||P!==0)&&(i.x=(i.x??0)-C/R[2],i.y=(i.y??0)-P/R[2],await V({x:C,y:P})&&I(i)),s=requestAnimationFrame($)}function O(R){const{nodeLookup:V,multiSelectionActive:v,nodesDraggable:M,transform:C,snapGrid:P,snapToGrid:k,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:B,unselectNodesAndEdges:L}=t();u=!0,(!D||!S)&&!v&&N&&(V.get(N)?.selected||L()),S&&D&&N&&e?.(N);const z=ct(R.sourceEvent,{transform:C,snapGrid:P,snapToGrid:k,containerBounds:d});if(i=z,a=Pd(V,M,z,N),a.size>0&&(n||H||!N&&B)){const[j,Y]=xn({nodeId:N,dragItems:a,nodeLookup:V});n?.(R.sourceEvent,a,j,Y),H?.(R.sourceEvent,j,Y),N||B?.(R.sourceEvent,Y)}}const A=Br().clickDistance(_).on("start",R=>{const{domNode:V,nodeDragThreshold:v,transform:M,snapGrid:C,snapToGrid:P}=t();d=V?.getBoundingClientRect()||null,h=!1,g=!1,y=R.sourceEvent,v===0&&O(R),i=ct(R.sourceEvent,{transform:M,snapGrid:C,snapToGrid:P,containerBounds:d}),c=ge(R.sourceEvent,d)}).on("drag",R=>{const{autoPanOnNodeDrag:V,transform:v,snapGrid:M,snapToGrid:C,nodeDragThreshold:P,nodeLookup:k}=t(),D=ct(R.sourceEvent,{transform:v,snapGrid:M,snapToGrid:C,containerBounds:d});if(y=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||N&&!k.has(N))&&(h=!0),!h){if(!l&&V&&u&&(l=!0,$()),!u){const H=ge(R.sourceEvent,d),B=H.x-c.x,L=H.y-c.y;Math.sqrt(B*B+L*L)>P&&O(R)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&a&&u&&(c=ge(R.sourceEvent,d),I(D))}}).on("end",R=>{if(!(!u||h)&&(l=!1,u=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:V,updateNodePositions:v,onNodeDragStop:M,onSelectionDragStop:C}=t();if(g&&(v(a,!1),g=!1),r||M||!N&&C){const[P,k]=xn({nodeId:N,dragItems:a,nodeLookup:V,dragging:!1});r?.(R.sourceEvent,a,P,k),M?.(R.sourceEvent,P,k),N||C?.(R.sourceEvent,k)}}}).filter(R=>{const V=R.target;return!R.button&&(!b||!Wo(V,`.${b}`,x))&&(!p||Wo(V,p,x))});f.call(A)}function m(){f?.on(".drag",null)}return{update:w,destroy:m}}function Td(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())pt(r,qe(i))>0&&o.push(i);return o}const Rd=250;function zd(e,t,n,o){let r=[],i=1/0;const s=Td(e,n,t+Rd);for(const a of s){const l=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const c of l){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:d,y:u}=Be(a,c,c.position,!0),f=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(u-e.y,2));f>t||(f<i?(r=[{...c,x:d,y:u}],i=f):f===i&&r.push({...c,x:d,y:u}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(l=>l.type===a)??r[0]}return r[0]}function Ei(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??[]],l=(n?a?.find(c=>c.id===n):a?.[0])??null;return l&&i?{...l,...Be(s,l,l.position,!0)}:l}function Ni(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Hd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Si=()=>!0;function Ld(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:y,onConnectEnd:w,isValidConnection:m=Si,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:S,autoPanSpeed:N,dragThreshold:_=1,handleDomNode:I}){const $=fi(e.target);let O=0,A;const{x:R,y:V}=ge(e),v=Ni(i,I),M=a?.getBoundingClientRect();let C=!1;if(!M||!v)return;const P=Ei(r,v,o,l,t);if(!P)return;let k=ge(e,M),D=!1,H=null,B=!1,L=null;function z(){if(!d||!M)return;const[K,G]=ci(k,M,N);f({x:K,y:G}),O=requestAnimationFrame(z)}const j={...P,nodeId:r,type:v,position:P.position},Y=l.get(r);let Z={inProgress:!0,isValid:null,from:Be(Y,j,X.Left,!0),fromHandle:j,fromPosition:j.position,fromNode:Y,to:k,toHandle:null,toPosition:To[j.position],toNode:null,pointer:k};function F(){C=!0,p(Z),g?.(e,{nodeId:r,handleId:o,handleType:v})}_===0&&F();function W(K){if(!C){const{x:ae,y:Se}=ge(K),ve=ae-R,Ae=Se-V;if(!(ve*ve+Ae*Ae>_*_))return;F()}if(!S()||!j){Q(K);return}const G=x();k=ge(K,M),A=zd(Et(k,G,!1,[1,1]),n,l,j),D||(z(),D=!0);const q=Ci(K,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:$,lib:c,flowId:u,nodeLookup:l});L=q.handleDomNode,H=q.connection,B=Hd(!!A,q.isValid);const te=l.get(r),oe=te?Be(te,j,X.Left,!0):Z.from,ne={...Z,from:oe,isValid:B,to:q.toHandle&&B?Ut({x:q.toHandle.x,y:q.toHandle.y},G):k,toHandle:q.toHandle,toPosition:B&&q.toHandle?q.toHandle.position:To[j.position],toNode:q.toHandle?l.get(q.toHandle.nodeId):null,pointer:k};p(ne),Z=ne}function Q(K){if(!("touches"in K&&K.touches.length>0)){if(C){(A||L)&&H&&B&&y?.(H);const{inProgress:G,...q}=Z,te={...q,toPosition:Z.toHandle?Z.toPosition:null};w?.(K,te),i&&b?.(K,te)}h(),cancelAnimationFrame(O),D=!1,B=!1,H=null,L=null,$.removeEventListener("mousemove",W),$.removeEventListener("mouseup",Q),$.removeEventListener("touchmove",W),$.removeEventListener("touchend",Q)}}$.addEventListener("mousemove",W),$.addEventListener("mouseup",Q),$.addEventListener("touchmove",W),$.addEventListener("touchend",Q)}function Ci(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=Si,nodeLookup:d}){const u=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=ge(e),y=s.elementFromPoint(h,g),w=y?.classList.contains(`${a}-flow__handle`)?y:f,m={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const b=Ni(void 0,w),p=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),S=w.classList.contains("connectable"),N=w.classList.contains("connectableend");if(!p||!b)return m;const _={source:u?p:o,sourceHandle:u?x:r,target:u?o:p,targetHandle:u?r:x};m.connection=_;const $=S&&N&&(n===He.Strict?u&&b==="source"||!u&&b==="target":p!==o||x!==r);m.isValid=$&&c(_),m.toHandle=Ei(p,b,x,d,n,!0)}return m}const Vn={onPointerDown:Ld,isValid:Ci};function Bd({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=le(e);function i({translateExtent:a,width:l,height:c,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const x=n(),S=p.sourceEvent.ctrlKey&&mt()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,_=x[2]*Math.pow(2,N*S);t.scaleTo(_)};let y=[0,0];const w=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const x=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const S=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],N=[S[0]-y[0],S[1]-y[1]];y=S;const _=o()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),I={x:x[0]-N[0]*_,y:x[1]-N[1]*_},$=[[0,0],[l,c]];t.setViewportConstrained({x:I.x,y:I.y,zoom:x[2]},$,a)},b=ei().on("start",w).on("zoom",u?m:null).on("zoom.wheel",f?g:null);r.call(b,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:de}}const sn=e=>({x:e.x,y:e.y,zoom:e.k}),wn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),Mi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Vd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,vn=(e,t=0,n=Vd,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Ii=e=>{const t=e.ctrlKey&&mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Od({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return d=>{if(je(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(d.ctrlKey&&s){const w=de(d),m=Ii(d),b=u*Math.pow(2,m);o.scaleTo(n,b,w,d);return}const f=d.deltaMode===1?20:1;let h=r===Te.Vertical?0:d.deltaX*f,g=r===Te.Horizontal?0:d.deltaY*f;!mt()&&d.shiftKey&&r!==Te.Vertical&&(h=d.deltaY*f,g=0),o.translateBy(n,-(h/u)*i,-(g/u)*i,{internal:!0});const y=sn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(d,y),e.panScrollTimeout=setTimeout(()=>{c?.(d,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(d,y))}}function jd({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=je(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Fd({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=sn(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 Xd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Mi(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,sn(i.transform))}}function Yd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Mi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=sn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function Wd({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:d}){return u=>{const f=e||t,h=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(je(u,`${c}-flow__node`)||je(u,`${c}-flow__edge`)))return!0;if(!o&&!f&&!r&&!i&&!n||s||d&&!g||je(u,a)&&g||je(u,l)&&(!g||r&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&u.touches?.length>1)return u.preventDefault(),!1;if(!f&&!r&&!h&&g||!o&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(o)&&!o.includes(u.button)&&u.type==="mousedown")return!1;const y=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&y}}function Zd({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),u=ei().scaleExtent([t,n]).translateExtent(o),f=le(e).call(u);b({x:r.x,y:r.y,zoom:Ge(r.zoom,t,n)},[[0,0],[d.width,d.height]],o);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(Ii);function y(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).transform(vn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function w({noWheelClassName:A,noPanClassName:R,onPaneContextMenu:V,userSelectionActive:v,panOnScroll:M,panOnDrag:C,panOnScrollMode:P,panOnScrollSpeed:k,preventScrolling:D,zoomOnPinch:H,zoomOnScroll:B,zoomOnDoubleClick:L,zoomActivationKeyPressed:z,lib:j,onTransformChange:Y,connectionInProgress:U,paneClickDistance:Z,selectionOnDrag:F}){v&&!c.isZoomingOrPanning&&m();const W=M&&!z&&!v;u.clickDistance(F?1/0:!he(Z)||Z<0?0:Z);const Q=W?Od({zoomPanValues:c,noWheelClassName:A,d3Selection:f,d3Zoom:u,panOnScrollMode:P,panOnScrollSpeed:k,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):jd({noWheelClassName:A,preventScrolling:D,d3ZoomHandler:h});if(f.on("wheel.zoom",Q,{passive:!1}),!v){const G=Fd({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});u.on("start",G);const q=Xd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!V,onPanZoom:i,onTransformChange:Y});u.on("zoom",q);const te=Yd({zoomPanValues:c,panOnDrag:C,panOnScroll:M,onPaneContextMenu:V,onPanZoomEnd:a,onDraggingChange:l});u.on("end",te)}const K=Wd({zoomActivationKeyPressed:z,panOnDrag:C,zoomOnScroll:B,panOnScroll:M,zoomOnDoubleClick:L,zoomOnPinch:H,userSelectionActive:v,noPanClassName:R,noWheelClassName:A,lib:j,connectionInProgress:U});u.filter(K),L?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function b(A,R,V){const v=wn(A),M=u?.constrain()(v,R,V);return M&&await y(M),new Promise(C=>C(M))}async function p(A,R){const V=wn(A);return await y(V,R),new Promise(v=>v(V))}function x(A){if(f){const R=wn(A),V=f.property("__zoom");(V.k!==A.zoom||V.x!==A.x||V.y!==A.y)&&u?.transform(f,R,null,{sync:!0})}}function S(){const A=f?Jr(f.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function N(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).scaleTo(vn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function _(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).scaleBy(vn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function I(A){u?.scaleExtent(A)}function $(A){u?.translateExtent(A)}function O(A){const R=!he(A)||A<0?0:A;u?.clickDistance(R)}return{update:w,destroy:m,setViewport:p,setViewportConstrained:b,getViewport:S,scaleTo:N,scaleBy:_,setScaleExtent:I,setTranslateExtent:$,syncViewport:x,setClickDistance:O}}var Ke;(function(e){e.Line="line",e.Handle="handle"})(Ke||(Ke={}));function Gd({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(l[0]=l[0]*-1),a&&i&&(l[1]=l[1]*-1),l}function Zo(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 Ce(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function $t(e,t,n){return Math.max(0,t-e,e-n)}function Go(e,t){return e?!t:t}function qd(e,t,n,o,r,i,s,a){let{affectsX:l,affectsY:c}=t;const{isHorizontal:d,isVertical:u}=t,f=d&&u,{xSnapped:h,ySnapped:g}=n,{minWidth:y,maxWidth:w,minHeight:m,maxHeight:b}=o,{x:p,y:x,width:S,height:N,aspectRatio:_}=e;let I=Math.floor(d?h-e.pointerX:0),$=Math.floor(u?g-e.pointerY:0);const O=S+(l?-I:I),A=N+(c?-$:$),R=-i[0]*S,V=-i[1]*N;let v=$t(O,y,w),M=$t(A,m,b);if(s){let k=0,D=0;l&&I<0?k=Ce(p+I+R,s[0][0]):!l&&I>0&&(k=Me(p+O+R,s[1][0])),c&&$<0?D=Ce(x+$+V,s[0][1]):!c&&$>0&&(D=Me(x+A+V,s[1][1])),v=Math.max(v,k),M=Math.max(M,D)}if(a){let k=0,D=0;l&&I>0?k=Me(p+I,a[0][0]):!l&&I<0&&(k=Ce(p+O,a[1][0])),c&&$>0?D=Me(x+$,a[0][1]):!c&&$<0&&(D=Ce(x+A,a[1][1])),v=Math.max(v,k),M=Math.max(M,D)}if(r){if(d){const k=$t(O/_,m,b)*_;if(v=Math.max(v,k),s){let D=0;!l&&!c||l&&!c&&f?D=Me(x+V+O/_,s[1][1])*_:D=Ce(x+V+(l?I:-I)/_,s[0][1])*_,v=Math.max(v,D)}if(a){let D=0;!l&&!c||l&&!c&&f?D=Ce(x+O/_,a[1][1])*_:D=Me(x+(l?I:-I)/_,a[0][1])*_,v=Math.max(v,D)}}if(u){const k=$t(A*_,y,w)/_;if(M=Math.max(M,k),s){let D=0;!l&&!c||c&&!l&&f?D=Me(p+A*_+R,s[1][0])/_:D=Ce(p+(c?$:-$)*_+R,s[0][0])/_,M=Math.max(M,D)}if(a){let D=0;!l&&!c||c&&!l&&f?D=Ce(p+A*_,a[1][0])/_:D=Me(p+(c?$:-$)*_,a[0][0])/_,M=Math.max(M,D)}}}$=$+($<0?M:-M),I=I+(I<0?v:-v),r&&(f?O>A*_?$=(Go(l,c)?-I:I)/_:I=(Go(l,c)?-$:$)*_:d?($=I/_,c=l):(I=$*_,l=c));const C=l?p+I:p,P=c?x+$:x;return{width:S+(l?-I:I),height:N+(c?-$:$),x:i[0]*I*(l?-1:1)+C,y:i[1]*$*(c?-1:1)+P}}const ki={width:0,height:0,x:0,y:0},Ud={...ki,pointerX:0,pointerY:0,aspectRatio:1};function Kd(e){return[[0,0],[e.measured.width,e.measured.height]]}function Qd(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,l=n[1]*s;return[[o-a,r-l],[o+i-a,r+s-l]]}function Jd({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=le(e);let s={controlDirection:Zo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:d,keepAspectRatio:u,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:y,shouldResize:w}){let m={...ki},b={...Ud};s={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Zo(c)};let p,x=null,S=[],N,_,I,$=!1;const O=Br().on("start",A=>{const{nodeLookup:R,transform:V,snapGrid:v,snapToGrid:M,nodeOrigin:C,paneDomNode:P}=n();if(p=R.get(t),!p)return;x=P?.getBoundingClientRect()??null;const{xSnapped:k,ySnapped:D}=ct(A.sourceEvent,{transform:V,snapGrid:v,snapToGrid:M,containerBounds:x});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:k,pointerY:D,aspectRatio:m.width/m.height},N=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(N=R.get(p.parentId),_=N&&p.extent==="parent"?Kd(N):void 0),S=[],I=void 0;for(const[H,B]of R)if(B.parentId===t&&(S.push({id:H,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const L=Qd(B,p,B.origin??C);I?I=[[Math.min(L[0][0],I[0][0]),Math.min(L[0][1],I[0][1])],[Math.max(L[1][0],I[1][0]),Math.max(L[1][1],I[1][1])]]:I=L}h?.(A,{...m})}).on("drag",A=>{const{transform:R,snapGrid:V,snapToGrid:v,nodeOrigin:M}=n(),C=ct(A.sourceEvent,{transform:R,snapGrid:V,snapToGrid:v,containerBounds:x}),P=[];if(!p)return;const{x:k,y:D,width:H,height:B}=m,L={},z=p.origin??M,{width:j,height:Y,x:U,y:Z}=qd(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,z,_,I),F=j!==H,W=Y!==B,Q=U!==k&&F,K=Z!==D&&W;if(!Q&&!K&&!F&&!W)return;if((Q||K||z[0]===1||z[1]===1)&&(L.x=Q?U:m.x,L.y=K?Z:m.y,m.x=L.x,m.y=L.y,S.length>0)){const oe=U-k,ne=Z-D;for(const ae of S)ae.position={x:ae.position.x-oe+z[0]*(j-H),y:ae.position.y-ne+z[1]*(Y-B)},P.push(ae)}if((F||W)&&(L.width=F&&(!s.resizeDirection||s.resizeDirection==="horizontal")?j:m.width,L.height=W&&(!s.resizeDirection||s.resizeDirection==="vertical")?Y:m.height,m.width=L.width,m.height=L.height),N&&p.expandParent){const oe=z[0]*(L.width??0);L.x&&L.x<oe&&(m.x=oe,b.x=b.x-(L.x-oe));const ne=z[1]*(L.height??0);L.y&&L.y<ne&&(m.y=ne,b.y=b.y-(L.y-ne))}const G=Gd({width:m.width,prevWidth:H,height:m.height,prevHeight:B,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),q={...m,direction:G};w?.(A,q)!==!1&&($=!0,g?.(A,q),o(L,P))}).on("end",A=>{$&&(y?.(A,{...m}),r?.({...m}),$=!1)});i.call(O)}function l(){i.on(".drag",null)}return{update:a,destroy:l}}var bn={exports:{}},_n={},En={exports:{}},Nn={};var qo;function ef(){if(qo)return Nn;qo=1;var e=Nr();function t(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(u,f){var h=f(),g=o({inst:{value:h,getSnapshot:f}}),y=g[0].inst,w=g[1];return i(function(){y.value=h,y.getSnapshot=f,l(y)&&w({inst:y})},[u,h,f]),r(function(){return l(y)&&w({inst:y}),u(function(){l(y)&&w({inst:y})})},[u]),s(h),h}function l(u){var f=u.getSnapshot;u=u.value;try{var h=f();return!n(u,h)}catch{return!0}}function c(u,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Nn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Nn}var Uo;function tf(){return Uo||(Uo=1,En.exports=ef()),En.exports}var Ko;function nf(){if(Ko)return _n;Ko=1;var e=Nr(),t=tf();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return _n.useSyncExternalStoreWithSelector=function(c,d,u,f,h){var g=i(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=a(function(){function m(N){if(!b){if(b=!0,p=N,N=f(N),h!==void 0&&y.hasValue){var _=y.value;if(h(_,N))return x=_}return x=N}if(_=x,o(p,N))return _;var I=f(N);return h!==void 0&&h(_,I)?(p=N,_):(p=N,x=I)}var b=!1,p,x,S=u===void 0?null:u;return[function(){return m(d())},S===null?void 0:function(){return m(S())}]},[d,u,f,h]);var w=r(c,g[0],g[1]);return s(function(){y.hasValue=!0,y.value=w},[w]),l(w),w},_n}var Qo;function of(){return Qo||(Qo=1,bn.exports=nf()),bn.exports}var rf=of();const sf=pa(rf),af={},Jo=e=>{let t;const n=new Set,o=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},r=()=>t,l={setState:o,getState:r,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(af?"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()}},c=t=e(o,r,l);return l},cf=e=>e?Jo(e):Jo,{useDebugValue:lf}=ma,{useSyncExternalStoreWithSelector:uf}=sf,df=e=>e;function Ai(e,t=df,n){const o=uf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return lf(o),o}const er=(e,t)=>{const n=cf(e),o=(r,i=t)=>Ai(n,r,i);return Object.assign(o,n),o},ff=(e,t)=>e?er(e,t):er;function re(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 an=T.createContext(null),hf=an.Provider,Pi=xe.error001();function J(e,t){const n=T.useContext(an);if(n===null)throw new Error(Pi);return Ai(n,e,t)}function ie(){const e=T.useContext(an);if(e===null)throw new Error(Pi);return T.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const tr={display:"none"},gf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},$i="react-flow__node-desc",Di="react-flow__edge-desc",pf="react-flow__aria-live",mf=e=>e.ariaLiveMessage,yf=e=>e.ariaLabelConfig;function xf({rfId:e}){const t=J(mf);return E.jsx("div",{id:`${pf}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:gf,children:t})}function wf({rfId:e,disableKeyboardA11y:t}){const n=J(yf);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${$i}-${e}`,style:tr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${Di}-${e}`,style:tr,children:n["edge.a11yDescription.default"]}),!t&&E.jsx(xf,{rfId:e})]})}const Nt=T.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return E.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Nt.displayName="Panel";function vf({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:E.jsx(Nt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:E.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const bf=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}},Dt=e=>e.id;function _f(e,t){return re(e.selectedNodes.map(Dt),t.selectedNodes.map(Dt))&&re(e.selectedEdges.map(Dt),t.selectedEdges.map(Dt))}function Ef({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:o}=J(bf,_f);return T.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Nf=e=>!!e.onSelectionChangeHandlers;function Sf({onSelectionChange:e}){const t=J(Nf);return e||t?E.jsx(Ef,{onSelectionChange:e}):null}const On=typeof window<"u"?T.useLayoutEffect:T.useEffect,Ti=[0,0],Cf={x:0,y:0,zoom:1},Mf=["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"],nr=[...Mf,"rfId"],If=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}),or={translateExtent:ht,nodeOrigin:Ti,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function kf(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=J(If,re),c=ie();On(()=>(l(e.defaultNodes,e.defaultEdges),()=>{d.current=or,a()}),[]);const d=T.useRef(or);return On(()=>{for(const u of nr){const f=e[u],h=d.current[u];f!==h&&(typeof e[u]>"u"||(u==="nodes"?t(f):u==="edges"?n(f):u==="minZoom"?o(f):u==="maxZoom"?r(f):u==="translateExtent"?i(f):u==="nodeExtent"?s(f):u==="ariaLabelConfig"?c.setState({ariaLabelConfig:dd(f)}):u==="fitView"?c.setState({fitViewQueued:f}):u==="fitViewOptions"?c.setState({fitViewOptions:f}):c.setState({[u]:f})))}d.current=e},nr.map(u=>e[u])),null}function rr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Af(e){const[t,n]=T.useState(e==="system"?null:e);return T.useEffect(()=>{if(e!=="system"){n(e);return}const o=rr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:rr()?.matches?"dark":"light"}const ir=typeof document<"u"?document:null;function yt(e=null,t={target:ir,actInsideInputWithModifier:!0}){const[n,o]=T.useState(!1),r=T.useRef(!1),i=T.useRef(new Set([])),[s,a]=T.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
1
+ import{r as Nr,g as pa,R as ma,a as T,j as E,u as Fn,b as ee,S as ya,c as xa,n as wa,d as va,e as ba}from"./index-BAN6lKgf.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 _a={value:()=>{}};function Qt(){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 Rt(n)}function Rt(e){this._=e}function Ea(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}})}Rt.prototype=Qt.prototype={constructor:Rt,on:function(e,t){var n=this._,o=Ea(e+"",n),r,i=-1,s=o.length;if(arguments.length<2){for(;++i<s;)if((r=(e=o[i]).type)&&(r=Na(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]=yo(n[r],e.name,t);else if(t==null)for(r in n)n[r]=yo(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 Rt(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 Na(e,t){for(var n=0,o=e.length,r;n<o;++n)if((r=e[n]).name===t)return r.value}function yo(e,t,n){for(var o=0,r=e.length;o<r;++o)if(e[o].name===t){e[o]=_a,e=e.slice(0,o).concat(e.slice(o+1));break}return n!=null&&e.push({name:t,value:n}),e}var In="http://www.w3.org/1999/xhtml";const xo={svg:"http://www.w3.org/2000/svg",xhtml:In,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jt(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),xo.hasOwnProperty(t)?{space:xo[t],local:e}:e}function Sa(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===In&&t.documentElement.namespaceURI===In?t.createElement(e):t.createElementNS(n,e)}}function Ca(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Sr(e){var t=Jt(e);return(t.local?Ca:Sa)(t)}function Ma(){}function Xn(e){return e==null?Ma:function(){return this.querySelector(e)}}function Ia(e){typeof e!="function"&&(e=Xn(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),l,c,d=0;d<s;++d)(l=i[d])&&(c=e.call(l,l.__data__,d,i))&&("__data__"in l&&(c.__data__=l.__data__),a[d]=c);return new ue(o,this._parents)}function ka(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Aa(){return[]}function Cr(e){return e==null?Aa:function(){return this.querySelectorAll(e)}}function Pa(e){return function(){return ka(e.apply(this,arguments))}}function $a(e){typeof e=="function"?e=Pa(e):e=Cr(e);for(var t=this._groups,n=t.length,o=[],r=[],i=0;i<n;++i)for(var s=t[i],a=s.length,l,c=0;c<a;++c)(l=s[c])&&(o.push(e.call(l,l.__data__,c,s)),r.push(l));return new ue(o,r)}function Mr(e){return function(){return this.matches(e)}}function Ir(e){return function(t){return t.matches(e)}}var Da=Array.prototype.find;function Ta(e){return function(){return Da.call(this.children,e)}}function Ra(){return this.firstElementChild}function za(e){return this.select(e==null?Ra:Ta(typeof e=="function"?e:Ir(e)))}var Ha=Array.prototype.filter;function La(){return Array.from(this.children)}function Ba(e){return function(){return Ha.call(this.children,e)}}function Va(e){return this.selectAll(e==null?La:Ba(typeof e=="function"?e:Ir(e)))}function Oa(e){typeof e!="function"&&(e=Mr(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]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new ue(o,this._parents)}function kr(e){return new Array(e.length)}function ja(){return new ue(this._enter||this._groups.map(kr),this._parents)}function Ot(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Ot.prototype={constructor:Ot,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 Fa(e){return function(){return e}}function Xa(e,t,n,o,r,i){for(var s=0,a,l=t.length,c=i.length;s<c;++s)(a=t[s])?(a.__data__=i[s],o[s]=a):n[s]=new Ot(e,i[s]);for(;s<l;++s)(a=t[s])&&(r[s]=a)}function Ya(e,t,n,o,r,i,s){var a,l,c=new Map,d=t.length,u=i.length,f=new Array(d),h;for(a=0;a<d;++a)(l=t[a])&&(f[a]=h=s.call(l,l.__data__,a,t)+"",c.has(h)?r[a]=l:c.set(h,l));for(a=0;a<u;++a)h=s.call(e,i[a],a,i)+"",(l=c.get(h))?(o[a]=l,l.__data__=i[a],c.delete(h)):n[a]=new Ot(e,i[a]);for(a=0;a<d;++a)(l=t[a])&&c.get(f[a])===l&&(r[a]=l)}function Wa(e){return e.__data__}function Za(e,t){if(!arguments.length)return Array.from(this,Wa);var n=t?Ya:Xa,o=this._parents,r=this._groups;typeof e!="function"&&(e=Fa(e));for(var i=r.length,s=new Array(i),a=new Array(i),l=new Array(i),c=0;c<i;++c){var d=o[c],u=r[c],f=u.length,h=Ga(e.call(d,d&&d.__data__,c,o)),g=h.length,y=a[c]=new Array(g),w=s[c]=new Array(g),m=l[c]=new Array(f);n(d,u,y,w,m,h,t);for(var b=0,p=0,x,S;b<g;++b)if(x=y[b]){for(b>=p&&(p=b+1);!(S=w[p])&&++p<g;);x._next=S||null}}return s=new ue(s,o),s._enter=a,s._exit=l,s}function Ga(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function qa(){return new ue(this._exit||this._groups.map(kr),this._parents)}function Ua(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 Ka(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),l=0;l<s;++l)for(var c=n[l],d=o[l],u=c.length,f=a[l]=new Array(u),h,g=0;g<u;++g)(h=c[g]||d[g])&&(f[g]=h);for(;l<r;++l)a[l]=n[l];return new ue(a,this._parents)}function Qa(){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 Ja(e){e||(e=ec);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}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,l=r[i]=new Array(a),c,d=0;d<a;++d)(c=s[d])&&(l[d]=c);l.sort(t)}return new ue(r,this._parents).order()}function ec(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function tc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function nc(){return Array.from(this)}function oc(){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 rc(){let e=0;for(const t of this)++e;return e}function ic(){return!this.node()}function sc(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 ac(e){return function(){this.removeAttribute(e)}}function cc(e){return function(){this.removeAttributeNS(e.space,e.local)}}function lc(e,t){return function(){this.setAttribute(e,t)}}function uc(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function dc(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function fc(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 hc(e,t){var n=Jt(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?cc:ac:typeof t=="function"?n.local?fc:dc:n.local?uc:lc)(n,t))}function Ar(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function gc(e){return function(){this.style.removeProperty(e)}}function pc(e,t,n){return function(){this.style.setProperty(e,t,n)}}function mc(e,t,n){return function(){var o=t.apply(this,arguments);o==null?this.style.removeProperty(e):this.style.setProperty(e,o,n)}}function yc(e,t,n){return arguments.length>1?this.each((t==null?gc:typeof t=="function"?mc:pc)(e,t,n??"")):We(this.node(),e)}function We(e,t){return e.style.getPropertyValue(t)||Ar(e).getComputedStyle(e,null).getPropertyValue(t)}function xc(e){return function(){delete this[e]}}function wc(e,t){return function(){this[e]=t}}function vc(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function bc(e,t){return arguments.length>1?this.each((t==null?xc:typeof t=="function"?vc:wc)(e,t)):this.node()[e]}function Pr(e){return e.trim().split(/^|\s+/)}function Yn(e){return e.classList||new $r(e)}function $r(e){this._node=e,this._names=Pr(e.getAttribute("class")||"")}$r.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 Dr(e,t){for(var n=Yn(e),o=-1,r=t.length;++o<r;)n.add(t[o])}function Tr(e,t){for(var n=Yn(e),o=-1,r=t.length;++o<r;)n.remove(t[o])}function _c(e){return function(){Dr(this,e)}}function Ec(e){return function(){Tr(this,e)}}function Nc(e,t){return function(){(t.apply(this,arguments)?Dr:Tr)(this,e)}}function Sc(e,t){var n=Pr(e+"");if(arguments.length<2){for(var o=Yn(this.node()),r=-1,i=n.length;++r<i;)if(!o.contains(n[r]))return!1;return!0}return this.each((typeof t=="function"?Nc:t?_c:Ec)(n,t))}function Cc(){this.textContent=""}function Mc(e){return function(){this.textContent=e}}function Ic(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function kc(e){return arguments.length?this.each(e==null?Cc:(typeof e=="function"?Ic:Mc)(e)):this.node().textContent}function Ac(){this.innerHTML=""}function Pc(e){return function(){this.innerHTML=e}}function $c(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Dc(e){return arguments.length?this.each(e==null?Ac:(typeof e=="function"?$c:Pc)(e)):this.node().innerHTML}function Tc(){this.nextSibling&&this.parentNode.appendChild(this)}function Rc(){return this.each(Tc)}function zc(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Hc(){return this.each(zc)}function Lc(e){var t=typeof e=="function"?e:Sr(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Bc(){return null}function Vc(e,t){var n=typeof e=="function"?e:Sr(e),o=t==null?Bc:typeof t=="function"?t:Xn(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),o.apply(this,arguments)||null)})}function Oc(){var e=this.parentNode;e&&e.removeChild(this)}function jc(){return this.each(Oc)}function Fc(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Xc(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Yc(e){return this.select(e?Xc:Fc)}function Wc(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Zc(e){return function(t){e.call(this,t,this.__data__)}}function Gc(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 qc(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 Uc(e,t,n){return function(){var o=this.__on,r,i=Zc(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 Kc(e,t,n){var o=Gc(e+""),r,i=o.length,s;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,c=a.length,d;l<c;++l)for(r=0,d=a[l];r<i;++r)if((s=o[r]).type===d.type&&s.name===d.name)return d.value}return}for(a=t?Uc:qc,r=0;r<i;++r)this.each(a(o[r],t,n));return this}function Rr(e,t,n){var o=Ar(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 Qc(e,t){return function(){return Rr(this,e,t)}}function Jc(e,t){return function(){return Rr(this,e,t.apply(this,arguments))}}function el(e,t){return this.each((typeof t=="function"?Jc:Qc)(e,t))}function*tl(){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 zr=[null];function ue(e,t){this._groups=e,this._parents=t}function xt(){return new ue([[document.documentElement]],zr)}function nl(){return this}ue.prototype=xt.prototype={constructor:ue,select:Ia,selectAll:$a,selectChild:za,selectChildren:Va,filter:Oa,data:Za,enter:ja,exit:qa,join:Ua,merge:Ka,selection:nl,order:Qa,sort:Ja,call:tc,nodes:nc,node:oc,size:rc,empty:ic,each:sc,attr:hc,style:yc,property:bc,classed:Sc,text:kc,html:Dc,raise:Rc,lower:Hc,append:Lc,insert:Vc,remove:jc,clone:Yc,datum:Wc,on:Kc,dispatch:el,[Symbol.iterator]:tl};function le(e){return typeof e=="string"?new ue([[document.querySelector(e)]],[document.documentElement]):new ue([[e]],zr)}function ol(e){let t;for(;t=e.sourceEvent;)e=t;return e}function de(e,t){if(e=ol(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 rl={passive:!1},lt={capture:!0,passive:!1};function gn(e){e.stopImmediatePropagation()}function Xe(e){e.preventDefault(),e.stopImmediatePropagation()}function Hr(e){var t=e.document.documentElement,n=le(e).on("dragstart.drag",Xe,lt);"onselectstart"in t?n.on("selectstart.drag",Xe,lt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Lr(e,t){var n=e.document.documentElement,o=le(e).on("dragstart.drag",null);t&&(o.on("click.drag",Xe,lt),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 Ct=e=>()=>e;function kn(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:i,x:s,y:a,dx:l,dy:c,dispatch:d}){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:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}kn.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function il(e){return!e.ctrlKey&&!e.button}function sl(){return this.parentNode}function al(e,t){return t??{x:e.x,y:e.y}}function cl(){return navigator.maxTouchPoints||"ontouchstart"in this}function Br(){var e=il,t=sl,n=al,o=cl,r={},i=Qt("start","drag","end"),s=0,a,l,c,d,u=0;function f(x){x.on("mousedown.drag",h).filter(o).on("touchstart.drag",w).on("touchmove.drag",m,rl).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,S){if(!(d||!e.call(this,x,S))){var N=p(this,t.call(this,x,S),x,S,"mouse");N&&(le(x.view).on("mousemove.drag",g,lt).on("mouseup.drag",y,lt),Hr(x.view),gn(x),c=!1,a=x.clientX,l=x.clientY,N("start",x))}}function g(x){if(Xe(x),!c){var S=x.clientX-a,N=x.clientY-l;c=S*S+N*N>u}r.mouse("drag",x)}function y(x){le(x.view).on("mousemove.drag mouseup.drag",null),Lr(x.view,c),Xe(x),r.mouse("end",x)}function w(x,S){if(e.call(this,x,S)){var N=x.changedTouches,_=t.call(this,x,S),I=N.length,$,O;for($=0;$<I;++$)(O=p(this,_,x,S,N[$].identifier,N[$]))&&(gn(x),O("start",x,N[$]))}}function m(x){var S=x.changedTouches,N=S.length,_,I;for(_=0;_<N;++_)(I=r[S[_].identifier])&&(Xe(x),I("drag",x,S[_]))}function b(x){var S=x.changedTouches,N=S.length,_,I;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),_=0;_<N;++_)(I=r[S[_].identifier])&&(gn(x),I("end",x,S[_]))}function p(x,S,N,_,I,$){var O=i.copy(),A=de($||N,S),R,V,v;if((v=n.call(x,new kn("beforestart",{sourceEvent:N,target:f,identifier:I,active:s,x:A[0],y:A[1],dx:0,dy:0,dispatch:O}),_))!=null)return R=v.x-A[0]||0,V=v.y-A[1]||0,function M(C,P,k){var D=A,H;switch(C){case"start":r[I]=M,H=s++;break;case"end":delete r[I],--s;case"drag":A=de(k||P,S),H=s;break}O.call(C,x,new kn(C,{sourceEvent:P,subject:v,target:f,identifier:I,active:H,x:A[0]+R,y:A[1]+V,dx:A[0]-D[0],dy:A[1]-D[1],dispatch:O}),_)}}return f.filter=function(x){return arguments.length?(e=typeof x=="function"?x:Ct(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:Ct(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:Ct(x),f):n},f.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:Ct(!!x),f):o},f.on=function(){var x=i.on.apply(i,arguments);return x===i?f:x},f.clickDistance=function(x){return arguments.length?(u=(x=+x)*x,f):Math.sqrt(u)},f}function Wn(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Vr(e,t){var n=Object.create(e.prototype);for(var o in t)n[o]=t[o];return n}function wt(){}var ut=.7,jt=1/ut,Ye="\\s*([+-]?\\d+)\\s*",dt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ye="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ll=/^#([0-9a-f]{3,8})$/,ul=new RegExp(`^rgb\\(${Ye},${Ye},${Ye}\\)$`),dl=new RegExp(`^rgb\\(${ye},${ye},${ye}\\)$`),fl=new RegExp(`^rgba\\(${Ye},${Ye},${Ye},${dt}\\)$`),hl=new RegExp(`^rgba\\(${ye},${ye},${ye},${dt}\\)$`),gl=new RegExp(`^hsl\\(${dt},${ye},${ye}\\)$`),pl=new RegExp(`^hsla\\(${dt},${ye},${ye},${dt}\\)$`),wo={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};Wn(wt,Re,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:vo,formatHex:vo,formatHex8:ml,formatHsl:yl,formatRgb:bo,toString:bo});function vo(){return this.rgb().formatHex()}function ml(){return this.rgb().formatHex8()}function yl(){return Or(this).formatHsl()}function bo(){return this.rgb().formatRgb()}function Re(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=ll.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?_o(t):n===3?new ce(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Mt(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Mt(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=ul.exec(e))?new ce(t[1],t[2],t[3],1):(t=dl.exec(e))?new ce(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=fl.exec(e))?Mt(t[1],t[2],t[3],t[4]):(t=hl.exec(e))?Mt(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=gl.exec(e))?So(t[1],t[2]/100,t[3]/100,1):(t=pl.exec(e))?So(t[1],t[2]/100,t[3]/100,t[4]):wo.hasOwnProperty(e)?_o(wo[e]):e==="transparent"?new ce(NaN,NaN,NaN,0):null}function _o(e){return new ce(e>>16&255,e>>8&255,e&255,1)}function Mt(e,t,n,o){return o<=0&&(e=t=n=NaN),new ce(e,t,n,o)}function xl(e){return e instanceof wt||(e=Re(e)),e?(e=e.rgb(),new ce(e.r,e.g,e.b,e.opacity)):new ce}function An(e,t,n,o){return arguments.length===1?xl(e):new ce(e,t,n,o??1)}function ce(e,t,n,o){this.r=+e,this.g=+t,this.b=+n,this.opacity=+o}Wn(ce,An,Vr(wt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new ce(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ce(De(this.r),De(this.g),De(this.b),Ft(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:Eo,formatHex:Eo,formatHex8:wl,formatRgb:No,toString:No}));function Eo(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}`}function wl(){return`#${$e(this.r)}${$e(this.g)}${$e(this.b)}${$e((isNaN(this.opacity)?1:this.opacity)*255)}`}function No(){const e=Ft(this.opacity);return`${e===1?"rgb(":"rgba("}${De(this.r)}, ${De(this.g)}, ${De(this.b)}${e===1?")":`, ${e})`}`}function Ft(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function De(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function $e(e){return e=De(e),(e<16?"0":"")+e.toString(16)}function So(e,t,n,o){return o<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new fe(e,t,n,o)}function Or(e){if(e instanceof fe)return new fe(e.h,e.s,e.l,e.opacity);if(e instanceof wt||(e=Re(e)),!e)return new fe;if(e instanceof fe)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,l=(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/=l<.5?i+r:2-i-r,s*=60):a=l>0&&l<1?0:s,new fe(s,a,l,e.opacity)}function vl(e,t,n,o){return arguments.length===1?Or(e):new fe(e,t,n,o??1)}function fe(e,t,n,o){this.h=+e,this.s=+t,this.l=+n,this.opacity=+o}Wn(fe,vl,Vr(wt,{brighter(e){return e=e==null?jt:Math.pow(jt,e),new fe(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ut:Math.pow(ut,e),new fe(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 ce(pn(e>=240?e-240:e+120,r,o),pn(e,r,o),pn(e<120?e+240:e-120,r,o),this.opacity)},clamp(){return new fe(Co(this.h),It(this.s),It(this.l),Ft(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=Ft(this.opacity);return`${e===1?"hsl(":"hsla("}${Co(this.h)}, ${It(this.s)*100}%, ${It(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Co(e){return e=(e||0)%360,e<0?e+360:e}function It(e){return Math.max(0,Math.min(1,e||0))}function pn(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 Zn=e=>()=>e;function bl(e,t){return function(n){return e+n*t}}function _l(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 El(e){return(e=+e)==1?jr:function(t,n){return n-t?_l(t,n,e):Zn(isNaN(t)?n:t)}}function jr(e,t){var n=t-e;return n?bl(e,n):Zn(isNaN(e)?t:e)}const Xt=(function e(t){var n=El(t);function o(r,i){var s=n((r=An(r)).r,(i=An(i)).r),a=n(r.g,i.g),l=n(r.b,i.b),c=jr(r.opacity,i.opacity);return function(d){return r.r=s(d),r.g=a(d),r.b=l(d),r.opacity=c(d),r+""}}return o.gamma=e,o})(1);function Nl(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 Sl(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Cl(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]=at(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 Ml(e,t){var n=new Date;return e=+e,t=+t,function(o){return n.setTime(e*(1-o)+t*o),n}}function me(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function Il(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]=at(e[r],t[r]):o[r]=t[r];return function(i){for(r in n)o[r]=n[r](i);return o}}var Pn=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,mn=new RegExp(Pn.source,"g");function kl(e){return function(){return e}}function Al(e){return function(t){return e(t)+""}}function Fr(e,t){var n=Pn.lastIndex=mn.lastIndex=0,o,r,i,s=-1,a=[],l=[];for(e=e+"",t=t+"";(o=Pn.exec(e))&&(r=mn.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,l.push({i:s,x:me(o,r)})),n=mn.lastIndex;return n<t.length&&(i=t.slice(n),a[s]?a[s]+=i:a[++s]=i),a.length<2?l[0]?Al(l[0].x):kl(t):(t=l.length,function(c){for(var d=0,u;d<t;++d)a[(u=l[d]).i]=u.x(c);return a.join("")})}function at(e,t){var n=typeof t,o;return t==null||n==="boolean"?Zn(t):(n==="number"?me:n==="string"?(o=Re(t))?(t=o,Xt):Fr:t instanceof Re?Xt:t instanceof Date?Ml:Sl(t)?Nl:Array.isArray(t)?Cl:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?Il:me)(e,t)}var Mo=180/Math.PI,$n={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Xr(e,t,n,o,r,i){var s,a,l;return(s=Math.sqrt(e*e+t*t))&&(e/=s,t/=s),(l=e*n+t*o)&&(n-=e*l,o-=t*l),(a=Math.sqrt(n*n+o*o))&&(n/=a,o/=a,l/=a),e*o<t*n&&(e=-e,t=-t,l=-l,s=-s),{translateX:r,translateY:i,rotate:Math.atan2(t,e)*Mo,skewX:Math.atan(l)*Mo,scaleX:s,scaleY:a}}var kt;function Pl(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?$n:Xr(t.a,t.b,t.c,t.d,t.e,t.f)}function $l(e){return e==null||(kt||(kt=document.createElementNS("http://www.w3.org/2000/svg","g")),kt.setAttribute("transform",e),!(e=kt.transform.baseVal.consolidate()))?$n:(e=e.matrix,Xr(e.a,e.b,e.c,e.d,e.e,e.f))}function Yr(e,t,n,o){function r(c){return c.length?c.pop()+" ":""}function i(c,d,u,f,h,g){if(c!==u||d!==f){var y=h.push("translate(",null,t,null,n);g.push({i:y-4,x:me(c,u)},{i:y-2,x:me(d,f)})}else(u||f)&&h.push("translate("+u+t+f+n)}function s(c,d,u,f){c!==d?(c-d>180?d+=360:d-c>180&&(c+=360),f.push({i:u.push(r(u)+"rotate(",null,o)-2,x:me(c,d)})):d&&u.push(r(u)+"rotate("+d+o)}function a(c,d,u,f){c!==d?f.push({i:u.push(r(u)+"skewX(",null,o)-2,x:me(c,d)}):d&&u.push(r(u)+"skewX("+d+o)}function l(c,d,u,f,h,g){if(c!==u||d!==f){var y=h.push(r(h)+"scale(",null,",",null,")");g.push({i:y-4,x:me(c,u)},{i:y-2,x:me(d,f)})}else(u!==1||f!==1)&&h.push(r(h)+"scale("+u+","+f+")")}return function(c,d){var u=[],f=[];return c=e(c),d=e(d),i(c.translateX,c.translateY,d.translateX,d.translateY,u,f),s(c.rotate,d.rotate,u,f),a(c.skewX,d.skewX,u,f),l(c.scaleX,c.scaleY,d.scaleX,d.scaleY,u,f),c=d=null,function(h){for(var g=-1,y=f.length,w;++g<y;)u[(w=f[g]).i]=w.x(h);return u.join("")}}}var Dl=Yr(Pl,"px, ","px)","deg)"),Tl=Yr($l,", ",")",")"),Rl=1e-12;function Io(e){return((e=Math.exp(e))+1/e)/2}function zl(e){return((e=Math.exp(e))-1/e)/2}function Hl(e){return((e=Math.exp(2*e))-1)/(e+1)}const zt=(function e(t,n,o){function r(i,s){var a=i[0],l=i[1],c=i[2],d=s[0],u=s[1],f=s[2],h=d-a,g=u-l,y=h*h+g*g,w,m;if(y<Rl)m=Math.log(f/c)/t,w=function(_){return[a+_*h,l+_*g,c*Math.exp(t*_*m)]};else{var b=Math.sqrt(y),p=(f*f-c*c+o*y)/(2*c*n*b),x=(f*f-c*c-o*y)/(2*f*n*b),S=Math.log(Math.sqrt(p*p+1)-p),N=Math.log(Math.sqrt(x*x+1)-x);m=(N-S)/t,w=function(_){var I=_*m,$=Io(S),O=c/(n*b)*($*Hl(t*I+S)-zl(S));return[a+O*h,l+O*g,c*$/Io(t*I+S)]}}return w.duration=m*1e3*t/Math.SQRT2,w}return r.rho=function(i){var s=Math.max(.001,+i),a=s*s,l=a*a;return e(s,a,l)},r})(Math.SQRT2,2,4);var Ze=0,it=0,ot=0,Wr=1e3,Yt,st,Wt=0,ze=0,en=0,ft=typeof performance=="object"&&performance.now?performance:Date,Zr=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Gn(){return ze||(Zr(Ll),ze=ft.now()+en)}function Ll(){ze=0}function Zt(){this._call=this._time=this._next=null}Zt.prototype=Gr.prototype={constructor:Zt,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Gn():+n)+(t==null?0:+t),!this._next&&st!==this&&(st?st._next=this:Yt=this,st=this),this._call=e,this._time=n,Dn()},stop:function(){this._call&&(this._call=null,this._time=1/0,Dn())}};function Gr(e,t,n){var o=new Zt;return o.restart(e,t,n),o}function Bl(){Gn(),++Ze;for(var e=Yt,t;e;)(t=ze-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ze}function ko(){ze=(Wt=ft.now())+en,Ze=it=0;try{Bl()}finally{Ze=0,Ol(),ze=0}}function Vl(){var e=ft.now(),t=e-Wt;t>Wr&&(en-=t,Wt=e)}function Ol(){for(var e,t=Yt,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:Yt=n);st=e,Dn(o)}function Dn(e){if(!Ze){it&&(it=clearTimeout(it));var t=e-ze;t>24?(e<1/0&&(it=setTimeout(ko,e-ft.now()-en)),ot&&(ot=clearInterval(ot))):(ot||(Wt=ft.now(),ot=setInterval(Vl,Wr)),Ze=1,Zr(ko))}}function Ao(e,t,n){var o=new Zt;return t=t==null?0:+t,o.restart(r=>{o.stop(),e(r+t)},t,n),o}var jl=Qt("start","end","cancel","interrupt"),Fl=[],qr=0,Po=1,Tn=2,Ht=3,$o=4,Rn=5,Lt=6;function tn(e,t,n,o,r,i){var s=e.__transition;if(!s)e.__transition={};else if(n in s)return;Xl(e,n,{name:t,index:o,group:r,on:jl,tween:Fl,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:qr})}function qn(e,t){var n=pe(e,t);if(n.state>qr)throw new Error("too late; already scheduled");return n}function we(e,t){var n=pe(e,t);if(n.state>Ht)throw new Error("too late; already running");return n}function pe(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Xl(e,t,n){var o=e.__transition,r;o[t]=n,n.timer=Gr(i,0,n.time);function i(c){n.state=Po,n.timer.restart(s,n.delay,n.time),n.delay<=c&&s(c-n.delay)}function s(c){var d,u,f,h;if(n.state!==Po)return l();for(d in o)if(h=o[d],h.name===n.name){if(h.state===Ht)return Ao(s);h.state===$o?(h.state=Lt,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete o[d]):+d<t&&(h.state=Lt,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete o[d])}if(Ao(function(){n.state===Ht&&(n.state=$o,n.timer.restart(a,n.delay,n.time),a(c))}),n.state=Tn,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Tn){for(n.state=Ht,r=new Array(f=n.tween.length),d=0,u=-1;d<f;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(r[++u]=h);r.length=u+1}}function a(c){for(var d=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(l),n.state=Rn,1),u=-1,f=r.length;++u<f;)r[u].call(e,d);n.state===Rn&&(n.on.call("end",e,e.__data__,n.index,n.group),l())}function l(){n.state=Lt,n.timer.stop(),delete o[t];for(var c in o)return;delete e.__transition}}function Bt(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>Tn&&o.state<Rn,o.state=Lt,o.timer.stop(),o.on.call(r?"interrupt":"cancel",e,e.__data__,o.index,o.group),delete n[s]}i&&delete e.__transition}}function Yl(e){return this.each(function(){Bt(this,e)})}function Wl(e,t){var n,o;return function(){var r=we(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 Zl(e,t,n){var o,r;if(typeof n!="function")throw new Error;return function(){var i=we(this,e),s=i.tween;if(s!==o){r=(o=s).slice();for(var a={name:t,value:n},l=0,c=r.length;l<c;++l)if(r[l].name===t){r[l]=a;break}l===c&&r.push(a)}i.tween=r}}function Gl(e,t){var n=this._id;if(e+="",arguments.length<2){for(var o=pe(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?Wl:Zl)(n,e,t))}function Un(e,t,n){var o=e._id;return e.each(function(){var r=we(this,o);(r.value||(r.value={}))[t]=n.apply(this,arguments)}),function(r){return pe(r,o).value[t]}}function Ur(e,t){var n;return(typeof t=="number"?me:t instanceof Re?Xt:(n=Re(t))?(t=n,Xt):Fr)(e,t)}function ql(e){return function(){this.removeAttribute(e)}}function Ul(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Kl(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 Ql(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 Jl(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttribute(e):(s=this.getAttribute(e),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function eu(e,t,n){var o,r,i;return function(){var s,a=n(this),l;return a==null?void this.removeAttributeNS(e.space,e.local):(s=this.getAttributeNS(e.space,e.local),l=a+"",s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a)))}}function tu(e,t){var n=Jt(e),o=n==="transform"?Tl:Ur;return this.attrTween(e,typeof t=="function"?(n.local?eu:Jl)(n,o,Un(this,"attr."+e,t)):t==null?(n.local?Ul:ql)(n):(n.local?Ql:Kl)(n,o,t))}function nu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function ou(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function ru(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&ou(e,i)),n}return r._value=t,r}function iu(e,t){var n,o;function r(){var i=t.apply(this,arguments);return i!==o&&(n=(o=i)&&nu(e,i)),n}return r._value=t,r}function su(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=Jt(e);return this.tween(n,(o.local?ru:iu)(o,t))}function au(e,t){return function(){qn(this,e).delay=+t.apply(this,arguments)}}function cu(e,t){return t=+t,function(){qn(this,e).delay=t}}function lu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?au:cu)(t,e)):pe(this.node(),t).delay}function uu(e,t){return function(){we(this,e).duration=+t.apply(this,arguments)}}function du(e,t){return t=+t,function(){we(this,e).duration=t}}function fu(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?uu:du)(t,e)):pe(this.node(),t).duration}function hu(e,t){if(typeof t!="function")throw new Error;return function(){we(this,e).ease=t}}function gu(e){var t=this._id;return arguments.length?this.each(hu(t,e)):pe(this.node(),t).ease}function pu(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;we(this,e).ease=n}}function mu(e){if(typeof e!="function")throw new Error;return this.each(pu(this._id,e))}function yu(e){typeof e!="function"&&(e=Mr(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]=[],l,c=0;c<s;++c)(l=i[c])&&e.call(l,l.__data__,c,i)&&a.push(l);return new Ee(o,this._parents,this._name,this._id)}function xu(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 l=t[a],c=n[a],d=l.length,u=s[a]=new Array(d),f,h=0;h<d;++h)(f=l[h]||c[h])&&(u[h]=f);for(;a<o;++a)s[a]=t[a];return new Ee(s,this._parents,this._name,this._id)}function wu(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 vu(e,t,n){var o,r,i=wu(t)?qn:we;return function(){var s=i(this,e),a=s.on;a!==o&&(r=(o=a).copy()).on(t,n),s.on=r}}function bu(e,t){var n=this._id;return arguments.length<2?pe(this.node(),n).on.on(e):this.each(vu(n,e,t))}function _u(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Eu(){return this.on("end.remove",_u(this._id))}function Nu(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Xn(e));for(var o=this._groups,r=o.length,i=new Array(r),s=0;s<r;++s)for(var a=o[s],l=a.length,c=i[s]=new Array(l),d,u,f=0;f<l;++f)(d=a[f])&&(u=e.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),c[f]=u,tn(c[f],t,n,f,c,pe(d,n)));return new Ee(i,this._parents,t,n)}function Su(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Cr(e));for(var o=this._groups,r=o.length,i=[],s=[],a=0;a<r;++a)for(var l=o[a],c=l.length,d,u=0;u<c;++u)if(d=l[u]){for(var f=e.call(d,d.__data__,u,l),h,g=pe(d,n),y=0,w=f.length;y<w;++y)(h=f[y])&&tn(h,t,n,y,f,g);i.push(f),s.push(d)}return new Ee(i,s,t,n)}var Cu=xt.prototype.constructor;function Mu(){return new Cu(this._groups,this._parents)}function Iu(e,t){var n,o,r;return function(){var i=We(this,e),s=(this.style.removeProperty(e),We(this,e));return i===s?null:i===n&&s===o?r:r=t(n=i,o=s)}}function Kr(e){return function(){this.style.removeProperty(e)}}function ku(e,t,n){var o,r=n+"",i;return function(){var s=We(this,e);return s===r?null:s===o?i:i=t(o=s,n)}}function Au(e,t,n){var o,r,i;return function(){var s=We(this,e),a=n(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(e),We(this,e))),s===l?null:s===o&&l===r?i:(r=l,i=t(o=s,a))}}function Pu(e,t){var n,o,r,i="style."+t,s="end."+i,a;return function(){var l=we(this,e),c=l.on,d=l.value[i]==null?a||(a=Kr(t)):void 0;(c!==n||r!==d)&&(o=(n=c).copy()).on(s,r=d),l.on=o}}function $u(e,t,n){var o=(e+="")=="transform"?Dl:Ur;return t==null?this.styleTween(e,Iu(e,o)).on("end.style."+e,Kr(e)):typeof t=="function"?this.styleTween(e,Au(e,o,Un(this,"style."+e,t))).each(Pu(this._id,e)):this.styleTween(e,ku(e,o,t),n).on("end.style."+e,null)}function Du(e,t,n){return function(o){this.style.setProperty(e,t.call(this,o),n)}}function Tu(e,t,n){var o,r;function i(){var s=t.apply(this,arguments);return s!==r&&(o=(r=s)&&Du(e,s,n)),o}return i._value=t,i}function Ru(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,Tu(e,t,n??""))}function zu(e){return function(){this.textContent=e}}function Hu(e){return function(){var t=e(this);this.textContent=t??""}}function Lu(e){return this.tween("text",typeof e=="function"?Hu(Un(this,"text",e)):zu(e==null?"":e+""))}function Bu(e){return function(t){this.textContent=e.call(this,t)}}function Vu(e){var t,n;function o(){var r=e.apply(this,arguments);return r!==n&&(t=(n=r)&&Bu(r)),t}return o._value=e,o}function Ou(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,Vu(e))}function ju(){for(var e=this._name,t=this._id,n=Qr(),o=this._groups,r=o.length,i=0;i<r;++i)for(var s=o[i],a=s.length,l,c=0;c<a;++c)if(l=s[c]){var d=pe(l,t);tn(l,e,n,c,s,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ee(o,this._parents,e,n)}function Fu(){var e,t,n=this,o=n._id,r=n.size();return new Promise(function(i,s){var a={value:s},l={value:function(){--r===0&&i()}};n.each(function(){var c=we(this,o),d=c.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(l)),c.on=t}),r===0&&i()})}var Xu=0;function Ee(e,t,n,o){this._groups=e,this._parents=t,this._name=n,this._id=o}function Qr(){return++Xu}var be=xt.prototype;Ee.prototype={constructor:Ee,select:Nu,selectAll:Su,selectChild:be.selectChild,selectChildren:be.selectChildren,filter:yu,merge:xu,selection:Mu,transition:ju,call:be.call,nodes:be.nodes,node:be.node,size:be.size,empty:be.empty,each:be.each,on:bu,attr:tu,attrTween:su,style:$u,styleTween:Ru,text:Lu,textTween:Ou,remove:Eu,tween:Gl,delay:lu,duration:fu,ease:gu,easeVarying:mu,end:Fu,[Symbol.iterator]:be[Symbol.iterator]};function Yu(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Wu={time:null,delay:0,duration:250,ease:Yu};function Zu(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 Gu(e){var t,n;e instanceof Ee?(t=e._id,e=e._name):(t=Qr(),(n=Wu).time=Gn(),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,l,c=0;c<a;++c)(l=s[c])&&tn(l,e,t,c,s,n||Zu(l,t));return new Ee(o,this._parents,e,t)}xt.prototype.interrupt=Yl;xt.prototype.transition=Gu;const At=e=>()=>e;function qu(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 _e(e,t,n){this.k=e,this.x=t,this.y=n}_e.prototype={constructor:_e,scale:function(e){return e===1?this:new _e(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new _e(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 nn=new _e(1,0,0);Jr.prototype=_e.prototype;function Jr(e){for(;!e.__zoom;)if(!(e=e.parentNode))return nn;return e.__zoom}function yn(e){e.stopImmediatePropagation()}function rt(e){e.preventDefault(),e.stopImmediatePropagation()}function Uu(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Ku(){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 Do(){return this.__zoom||nn}function Qu(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ju(){return navigator.maxTouchPoints||"ontouchstart"in this}function ed(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 ei(){var e=Uu,t=Ku,n=ed,o=Qu,r=Ju,i=[0,1/0],s=[[-1/0,-1/0],[1/0,1/0]],a=250,l=zt,c=Qt("start","zoom","end"),d,u,f,h=500,g=150,y=0,w=10;function m(v){v.property("__zoom",Do).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",O).filter(r).on("touchstart.zoom",A).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(v,M,C,P){var k=v.selection?v.selection():v;k.property("__zoom",Do),v!==k?S(v,M,C,P):k.interrupt().each(function(){N(this,arguments).event(P).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},m.scaleBy=function(v,M,C,P){m.scaleTo(v,function(){var k=this.__zoom.k,D=typeof M=="function"?M.apply(this,arguments):M;return k*D},C,P)},m.scaleTo=function(v,M,C,P){m.transform(v,function(){var k=t.apply(this,arguments),D=this.__zoom,H=C==null?x(k):typeof C=="function"?C.apply(this,arguments):C,B=D.invert(H),L=typeof M=="function"?M.apply(this,arguments):M;return n(p(b(D,L),H,B),k,s)},C,P)},m.translateBy=function(v,M,C,P){m.transform(v,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof C=="function"?C.apply(this,arguments):C),t.apply(this,arguments),s)},null,P)},m.translateTo=function(v,M,C,P,k){m.transform(v,function(){var D=t.apply(this,arguments),H=this.__zoom,B=P==null?x(D):typeof P=="function"?P.apply(this,arguments):P;return n(nn.translate(B[0],B[1]).scale(H.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof C=="function"?-C.apply(this,arguments):-C),D,s)},P,k)};function b(v,M){return M=Math.max(i[0],Math.min(i[1],M)),M===v.k?v:new _e(M,v.x,v.y)}function p(v,M,C){var P=M[0]-C[0]*v.k,k=M[1]-C[1]*v.k;return P===v.x&&k===v.y?v:new _e(v.k,P,k)}function x(v){return[(+v[0][0]+ +v[1][0])/2,(+v[0][1]+ +v[1][1])/2]}function S(v,M,C,P){v.on("start.zoom",function(){N(this,arguments).event(P).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(P).end()}).tween("zoom",function(){var k=this,D=arguments,H=N(k,D).event(P),B=t.apply(k,D),L=C==null?x(B):typeof C=="function"?C.apply(k,D):C,z=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),j=k.__zoom,Y=typeof M=="function"?M.apply(k,D):M,U=l(j.invert(L).concat(z/j.k),Y.invert(L).concat(z/Y.k));return function(Z){if(Z===1)Z=Y;else{var F=U(Z),W=z/F[2];Z=new _e(W,L[0]-F[0]*W,L[1]-F[1]*W)}H.zoom(null,Z)}})}function N(v,M,C){return!C&&v.__zooming||new _(v,M)}function _(v,M){this.that=v,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(v,M),this.taps=0}_.prototype={event:function(v){return v&&(this.sourceEvent=v),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(v,M){return this.mouse&&v!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&v!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&v!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(v){var M=le(this.that).datum();c.call(v,this.that,new qu(v,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:c}),M)}};function I(v,...M){if(!e.apply(this,arguments))return;var C=N(this,M).event(v),P=this.__zoom,k=Math.max(i[0],Math.min(i[1],P.k*Math.pow(2,o.apply(this,arguments)))),D=de(v);if(C.wheel)(C.mouse[0][0]!==D[0]||C.mouse[0][1]!==D[1])&&(C.mouse[1]=P.invert(C.mouse[0]=D)),clearTimeout(C.wheel);else{if(P.k===k)return;C.mouse=[D,P.invert(D)],Bt(this),C.start()}rt(v),C.wheel=setTimeout(H,g),C.zoom("mouse",n(p(b(P,k),C.mouse[0],C.mouse[1]),C.extent,s));function H(){C.wheel=null,C.end()}}function $(v,...M){if(f||!e.apply(this,arguments))return;var C=v.currentTarget,P=N(this,M,!0).event(v),k=le(v.view).on("mousemove.zoom",L,!0).on("mouseup.zoom",z,!0),D=de(v,C),H=v.clientX,B=v.clientY;Hr(v.view),yn(v),P.mouse=[D,this.__zoom.invert(D)],Bt(this),P.start();function L(j){if(rt(j),!P.moved){var Y=j.clientX-H,U=j.clientY-B;P.moved=Y*Y+U*U>y}P.event(j).zoom("mouse",n(p(P.that.__zoom,P.mouse[0]=de(j,C),P.mouse[1]),P.extent,s))}function z(j){k.on("mousemove.zoom mouseup.zoom",null),Lr(j.view,P.moved),rt(j),P.event(j).end()}}function O(v,...M){if(e.apply(this,arguments)){var C=this.__zoom,P=de(v.changedTouches?v.changedTouches[0]:v,this),k=C.invert(P),D=C.k*(v.shiftKey?.5:2),H=n(p(b(C,D),P,k),t.apply(this,M),s);rt(v),a>0?le(this).transition().duration(a).call(S,H,P,v):le(this).call(m.transform,H,P,v)}}function A(v,...M){if(e.apply(this,arguments)){var C=v.touches,P=C.length,k=N(this,M,v.changedTouches.length===P).event(v),D,H,B,L;for(yn(v),H=0;H<P;++H)B=C[H],L=de(B,this),L=[L,this.__zoom.invert(L),B.identifier],k.touch0?!k.touch1&&k.touch0[2]!==L[2]&&(k.touch1=L,k.taps=0):(k.touch0=L,D=!0,k.taps=1+!!d);d&&(d=clearTimeout(d)),D&&(k.taps<2&&(u=L[0],d=setTimeout(function(){d=null},h)),Bt(this),k.start())}}function R(v,...M){if(this.__zooming){var C=N(this,M).event(v),P=v.changedTouches,k=P.length,D,H,B,L;for(rt(v),D=0;D<k;++D)H=P[D],B=de(H,this),C.touch0&&C.touch0[2]===H.identifier?C.touch0[0]=B:C.touch1&&C.touch1[2]===H.identifier&&(C.touch1[0]=B);if(H=C.that.__zoom,C.touch1){var z=C.touch0[0],j=C.touch0[1],Y=C.touch1[0],U=C.touch1[1],Z=(Z=Y[0]-z[0])*Z+(Z=Y[1]-z[1])*Z,F=(F=U[0]-j[0])*F+(F=U[1]-j[1])*F;H=b(H,Math.sqrt(Z/F)),B=[(z[0]+Y[0])/2,(z[1]+Y[1])/2],L=[(j[0]+U[0])/2,(j[1]+U[1])/2]}else if(C.touch0)B=C.touch0[0],L=C.touch0[1];else return;C.zoom("touch",n(p(H,B,L),C.extent,s))}}function V(v,...M){if(this.__zooming){var C=N(this,M).event(v),P=v.changedTouches,k=P.length,D,H;for(yn(v),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),D=0;D<k;++D)H=P[D],C.touch0&&C.touch0[2]===H.identifier?delete C.touch0:C.touch1&&C.touch1[2]===H.identifier&&delete C.touch1;if(C.touch1&&!C.touch0&&(C.touch0=C.touch1,delete C.touch1),C.touch0)C.touch0[1]=this.__zoom.invert(C.touch0[0]);else if(C.end(),C.taps===2&&(H=de(H,this),Math.hypot(u[0]-H[0],u[1]-H[1])<w)){var B=le(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return m.wheelDelta=function(v){return arguments.length?(o=typeof v=="function"?v:At(+v),m):o},m.filter=function(v){return arguments.length?(e=typeof v=="function"?v:At(!!v),m):e},m.touchable=function(v){return arguments.length?(r=typeof v=="function"?v:At(!!v),m):r},m.extent=function(v){return arguments.length?(t=typeof v=="function"?v:At([[+v[0][0],+v[0][1]],[+v[1][0],+v[1][1]]]),m):t},m.scaleExtent=function(v){return arguments.length?(i[0]=+v[0],i[1]=+v[1],m):[i[0],i[1]]},m.translateExtent=function(v){return arguments.length?(s[0][0]=+v[0][0],s[1][0]=+v[1][0],s[0][1]=+v[0][1],s[1][1]=+v[1][1],m):[[s[0][0],s[0][1]],[s[1][0],s[1][1]]]},m.constrain=function(v){return arguments.length?(n=v,m):n},m.duration=function(v){return arguments.length?(a=+v,m):a},m.interpolate=function(v){return arguments.length?(l=v,m):l},m.on=function(){var v=c.on.apply(c,arguments);return v===c?m:v},m.clickDistance=function(v){return arguments.length?(y=(v=+v)*v,m):Math.sqrt(y)},m.tapDistance=function(v){return arguments.length?(w=+v,m):w},m}const xe={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id: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."},ht=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ti=["Enter"," ","Escape"],ni={"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 He;(function(e){e.Strict="strict",e.Loose="loose"})(He||(He={}));var Te;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Te||(Te={}));var gt;(function(e){e.Partial="partial",e.Full="full"})(gt||(gt={}));const oi={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ie;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ie||(Ie={}));var Gt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Gt||(Gt={}));var X;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(X||(X={}));const To={[X.Left]:X.Right,[X.Right]:X.Left,[X.Top]:X.Bottom,[X.Bottom]:X.Top};function ri(e){return e===null?null:e?"valid":"invalid"}const ii=e=>"id"in e&&"source"in e&&"target"in e,td=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Kn=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vt=(e,t=[0,0])=>{const{width:n,height:o}=Ne(e),r=e.origin??t,i=n*r[0],s=o*r[1];return{x:e.position.x-i,y:e.position.y-s}},nd=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,r)=>{const i=typeof r=="string";let s=!t.nodeLookup&&!i?r:void 0;t.nodeLookup&&(s=i?t.nodeLookup.get(r):Kn(r)?r:t.nodeLookup.get(r.id));const a=s?qt(s,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return on(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return rn(n)},bt=(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=on(n,qt(r)),o=!0)}),o?rn(n):{x:0,y:0,width:0,height:0}},Qn=(e,t,[n,o,r]=[0,0,1],i=!1,s=!1)=>{const a={...Et(t,[n,o,r]),width:t.width/r,height:t.height/r},l=[];for(const c of e.values()){const{measured:d,selectable:u=!0,hidden:f=!1}=c;if(s&&!u||f)continue;const h=d.width??c.width??c.initialWidth??null,g=d.height??c.height??c.initialHeight??null,y=pt(a,qe(c)),w=(h??0)*(g??0),m=i&&y>0;(!c.internals.handleBounds||m||y>=w||c.dragging)&&l.push(c)}return l},od=(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 rd(e,t){const n=new Map,o=t?.nodes?new Set(t.nodes.map(r=>r.id)):null;return e.forEach(r=>{r.measured.width&&r.measured.height&&(t?.includeHiddenNodes||!r.hidden)&&(!o||o.has(r.id))&&n.set(r.id,r)}),n}async function id({nodes:e,width:t,height:n,panZoom:o,minZoom:r,maxZoom:i},s){if(e.size===0)return Promise.resolve(!0);const a=rd(e,s),l=bt(a),c=Jn(l,t,n,s?.minZoom??r,s?.maxZoom??i,s?.padding??.1);return await o.setViewport(c,{duration:s?.duration,ease:s?.ease,interpolate:s?.interpolate}),Promise.resolve(!0)}function si({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:l,y:c}=a?a.internals.positionAbsolute:{x:0,y:0},d=s.origin??o;let u=s.extent||r;if(s.extent==="parent"&&!s.expandParent)if(!a)i?.("005",xe.error005());else{const h=a.measured.width,g=a.measured.height;h&&g&&(u=[[l,c],[l+h,c+g]])}else a&&Ue(s.extent)&&(u=[[s.extent[0][0]+l,s.extent[0][1]+c],[s.extent[1][0]+l,s.extent[1][1]+c]]);const f=Ue(u)?Le(t,u,s.measured):t;return(s.measured.width===void 0||s.measured.height===void 0)&&i?.("015",xe.error015()),{position:{x:f.x-l+(s.measured.width??0)*d[0],y:f.y-c+(s.measured.height??0)*d[1]},positionAbsolute:f}}async function sd({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:r}){const i=new Set(e.map(f=>f.id)),s=[];for(const f of n){if(f.deletable===!1)continue;const h=i.has(f.id),g=!h&&f.parentId&&s.find(y=>y.id===f.parentId);(h||g)&&s.push(f)}const a=new Set(t.map(f=>f.id)),l=o.filter(f=>f.deletable!==!1),d=od(s,l);for(const f of l)a.has(f.id)&&!d.find(g=>g.id===f.id)&&d.push(f);if(!r)return{edges:d,nodes:s};const u=await r({nodes:s,edges:d});return typeof u=="boolean"?u?{edges:d,nodes:s}:{edges:[],nodes:[]}:u}const Ge=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Le=(e={x:0,y:0},t,n)=>({x:Ge(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Ge(e.y,t[0][1],t[1][1]-(n?.height??0))});function ai(e,t,n){const{width:o,height:r}=Ne(n),{x:i,y:s}=n.internals.positionAbsolute;return Le(e,[[i,s],[i+o,s+r]],t)}const Ro=(e,t,n)=>e<t?Ge(Math.abs(e-t),1,t)/t:e>n?-Ge(Math.abs(e-n),1,t)/t:0,ci=(e,t,n=15,o=40)=>{const r=Ro(e.x,o,t.width-o)*n,i=Ro(e.y,o,t.height-o)*n;return[r,i]},on=(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}),rn=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),qe=(e,t=[0,0])=>{const{x:n,y:o}=Kn(e)?e.internals.positionAbsolute:vt(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}},qt=(e,t=[0,0])=>{const{x:n,y:o}=Kn(e)?e.internals.positionAbsolute:vt(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)}},li=(e,t)=>rn(on(zn(e),zn(t))),pt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},zo=e=>he(e.width)&&he(e.height)&&he(e.x)&&he(e.y),he=e=>!isNaN(e)&&isFinite(e),ad=(e,t)=>{},_t=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Et=({x:e,y:t},[n,o,r],i=!1,s=[1,1])=>{const a={x:(e-n)/r,y:(t-o)/r};return i?_t(a,s):a},Ut=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o});function Oe(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(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function cd(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Oe(e,n),r=Oe(e,t);return{top:o,right:r,bottom:o,left:r,x:r*2,y:o*2}}if(typeof e=="object"){const o=Oe(e.top??e.y??0,n),r=Oe(e.bottom??e.y??0,n),i=Oe(e.left??e.x??0,t),s=Oe(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 ld(e,t,n,o,r,i){const{x:s,y:a}=Ut(e,[t,n,o]),{x:l,y:c}=Ut({x:e.x+e.width,y:e.y+e.height},[t,n,o]),d=r-l,u=i-c;return{left:Math.floor(s),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(u)}}const Jn=(e,t,n,o,r,i)=>{const s=cd(i,t,n),a=(t-s.x)/e.width,l=(n-s.y)/e.height,c=Math.min(a,l),d=Ge(c,o,r),u=e.x+e.width/2,f=e.y+e.height/2,h=t/2-u*d,g=n/2-f*d,y=ld(e,h,g,d,t,n),w={left:Math.min(y.left-s.left,0),top:Math.min(y.top-s.top,0),right:Math.min(y.right-s.right,0),bottom:Math.min(y.bottom-s.bottom,0)};return{x:h-w.left+w.right,y:g-w.top+w.bottom,zoom:d}},mt=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Ue(e){return e!=null&&e!=="parent"}function Ne(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function ui(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function di(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 Ho(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function ud(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}function dd(e){return{...ni,...e||{}}}function ct(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:r}){const{x:i,y:s}=ge(e),a=Et({x:i-(r?.left??0),y:s-(r?.top??0)},o),{x:l,y:c}=n?_t(a,t):a;return{xSnapped:l,ySnapped:c,...a}}const eo=e=>({width:e.offsetWidth,height:e.offsetHeight}),fi=e=>e?.getRootNode?.()||window?.document,fd=["INPUT","SELECT","TEXTAREA"];function hi(e){const t=e.composedPath?.()?.[0]||e.target;return t?.nodeType!==1?!1:fd.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const gi=e=>"clientX"in e,ge=(e,t)=>{const n=gi(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)}},Lo=(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,...eo(s)}})};function pi({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:i,targetControlX:s,targetControlY:a}){const l=e*.125+r*.375+s*.375+n*.125,c=t*.125+i*.375+a*.375+o*.125,d=Math.abs(l-e),u=Math.abs(c-t);return[l,c,d,u]}function Pt(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Bo({pos:e,x1:t,y1:n,x2:o,y2:r,c:i}){switch(e){case X.Left:return[t-Pt(t-o,i),n];case X.Right:return[t+Pt(o-t,i),n];case X.Top:return[t,n-Pt(n-r,i)];case X.Bottom:return[t,n+Pt(r-n,i)]}}function mi({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,curvature:s=.25}){const[a,l]=Bo({pos:n,x1:e,y1:t,x2:o,y2:r,c:s}),[c,d]=Bo({pos:i,x1:o,y1:r,x2:e,y2:t,c:s}),[u,f,h,g]=pi({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${o},${r}`,u,f,h,g]}function yi({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 hd({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 gd({sourceNode:e,targetNode:t,width:n,height:o,transform:r}){const i=on(qt(e),qt(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 pt(s,rn(i))>0}const pd=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,md=(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)),yd=(e,t,n={})=>{if(!e.source||!e.target)return t;const o=n.getEdgeId||pd;let r;return ii(e)?r={...e}:r={...e,id:o(e)},md(r,t)?t:(r.sourceHandle===null&&delete r.sourceHandle,r.targetHandle===null&&delete r.targetHandle,t.concat(r))};function xi({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,i,s,a]=yi({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,i,s,a]}const Vo={[X.Left]:{x:-1,y:0},[X.Right]:{x:1,y:0},[X.Top]:{x:0,y:-1},[X.Bottom]:{x:0,y:1}},xd=({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},Oo=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function wd({source:e,sourcePosition:t=X.Bottom,target:n,targetPosition:o=X.Top,center:r,offset:i,stepPosition:s}){const a=Vo[t],l=Vo[o],c={x:e.x+a.x*i,y:e.y+a.y*i},d={x:n.x+l.x*i,y:n.y+l.y*i},u=xd({source:c,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let g=[],y,w;const m={x:0,y:0},b={x:0,y:0},[,,p,x]=yi({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*l[f]===-1){f==="x"?(y=r.x??c.x+(d.x-c.x)*s,w=r.y??(c.y+d.y)/2):(y=r.x??(c.x+d.x)/2,w=r.y??c.y+(d.y-c.y)*s);const I=[{x:y,y:c.y},{x:y,y:d.y}],$=[{x:c.x,y:w},{x:d.x,y:w}];a[f]===h?g=f==="x"?I:$:g=f==="x"?$:I}else{const I=[{x:c.x,y:d.y}],$=[{x:d.x,y:c.y}];if(f==="x"?g=a.x===h?$:I:g=a.y===h?I:$,t===o){const v=Math.abs(e[f]-n[f]);if(v<=i){const M=Math.min(i-1,i-v);a[f]===h?m[f]=(c[f]>e[f]?-1:1)*M:b[f]=(d[f]>n[f]?-1:1)*M}}if(t!==o){const v=f==="x"?"y":"x",M=a[f]===l[v],C=c[v]>d[v],P=c[v]<d[v];(a[f]===1&&(!M&&C||M&&P)||a[f]!==1&&(!M&&P||M&&C))&&(g=f==="x"?I:$)}const O={x:c.x+m.x,y:c.y+m.y},A={x:d.x+b.x,y:d.y+b.y},R=Math.max(Math.abs(O.x-g[0].x),Math.abs(A.x-g[0].x)),V=Math.max(Math.abs(O.y-g[0].y),Math.abs(A.y-g[0].y));R>=V?(y=(O.x+A.x)/2,w=g[0].y):(y=g[0].x,w=(O.y+A.y)/2)}const S={x:c.x+m.x,y:c.y+m.y},N={x:d.x+b.x,y:d.y+b.y};return[[e,...S.x!==g[0].x||S.y!==g[0].y?[S]:[],...g,...N.x!==g[g.length-1].x||N.y!==g[g.length-1].y?[N]:[],n],y,w,p,x]}function vd(e,t,n,o){const r=Math.min(Oo(e,t)/2,Oo(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 c=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${i+r*c},${s}Q ${i},${s} ${i},${s+r*d}`}const a=e.x<n.x?1:-1,l=e.y<n.y?-1:1;return`L ${i},${s+r*l}Q ${i},${s} ${i+r*a},${s}`}function Hn({sourceX:e,sourceY:t,sourcePosition:n=X.Bottom,targetX:o,targetY:r,targetPosition:i=X.Top,borderRadius:s=5,centerX:a,centerY:l,offset:c=20,stepPosition:d=.5}){const[u,f,h,g,y]=wd({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:i,center:{x:a,y:l},offset:c,stepPosition:d});let w=`M${u[0].x} ${u[0].y}`;for(let m=1;m<u.length-1;m++)w+=vd(u[m-1],u[m],u[m+1],s);return w+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[w,f,h,g,y]}function jo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function bd(e){const{sourceNode:t,targetNode:n}=e;if(!jo(t)||!jo(n))return null;const o=t.internals.handleBounds||Fo(t.handles),r=n.internals.handleBounds||Fo(n.handles),i=Xo(o?.source??[],e.sourceHandle),s=Xo(e.connectionMode===He.Strict?r?.target??[]:(r?.target??[]).concat(r?.source??[]),e.targetHandle);if(!i||!s)return e.onError?.("008",xe.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=i?.position||X.Bottom,l=s?.position||X.Top,c=Be(t,i,a),d=Be(n,s,l);return{sourceX:c.x,sourceY:c.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:l}}function Fo(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 Be(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??Ne(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 Xo(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Ln(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function _d(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(l=>{if(l&&typeof l=="object"){const c=Ln(l,t);i.has(c)||(s.push({id:c,color:l.color||n,...l}),i.add(c))}}),s),[]).sort((s,a)=>s.id.localeCompare(a.id))}const wi=1e3,Ed=10,to={nodeOrigin:[0,0],nodeExtent:ht,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},Nd={...to,checkEquality:!0};function no(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function Sd(e,t,n){const o=no(to,n);for(const r of e.values())if(r.parentId)ro(r,e,t,o);else{const i=vt(r,o.nodeOrigin),s=Ue(r.extent)?r.extent:o.nodeExtent,a=Le(i,s,Ne(r));r.internals.positionAbsolute=a}}function Cd(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 oo(e){return e==="manual"}function Bn(e,t,n,o={}){const r=no(Nd,o),i={i:0},s=new Map(t),a=r?.elevateNodesOnSelect&&!oo(r.zIndexMode)?wi:0;let l=e.length>0,c=!1;t.clear(),n.clear();for(const d of e){let u=s.get(d.id);if(r.checkEquality&&d===u?.internals.userNode)t.set(d.id,u);else{const f=vt(d,r.nodeOrigin),h=Ue(d.extent)?d.extent:r.nodeExtent,g=Le(f,h,Ne(d));u={...r.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:g,handleBounds:Cd(d,u),z:vi(d,a,r.zIndexMode),userNode:d}},t.set(d.id,u)}(u.measured===void 0||u.measured.width===void 0||u.measured.height===void 0)&&!u.hidden&&(l=!1),d.parentId&&ro(u,t,n,o,i),c||=d.selected??!1}return{nodesInitialized:l,hasSelectedNodes:c}}function Md(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 ro(e,t,n,o,r){const{elevateNodesOnSelect:i,nodeOrigin:s,nodeExtent:a,zIndexMode:l}=no(to,o),c=e.parentId,d=t.get(c);if(!d){console.warn(`Parent node ${c} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Md(e,n),r&&!d.parentId&&d.internals.rootParentIndex===void 0&&l==="auto"&&(d.internals.rootParentIndex=++r.i,d.internals.z=d.internals.z+r.i*Ed),r&&d.internals.rootParentIndex!==void 0&&(r.i=d.internals.rootParentIndex);const u=i&&!oo(l)?wi:0,{x:f,y:h,z:g}=Id(e,d,s,a,u,l),{positionAbsolute:y}=e.internals,w=f!==y.x||h!==y.y;(w||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:h}:y,z:g}})}function vi(e,t,n){const o=he(e.zIndex)?e.zIndex:0;return oo(n)?o:o+(e.selected?t:0)}function Id(e,t,n,o,r,i){const{x:s,y:a}=t.internals.positionAbsolute,l=Ne(e),c=vt(e,n),d=Ue(e.extent)?Le(c,e.extent,l):c;let u=Le({x:s+d.x,y:a+d.y},o,l);e.extent==="parent"&&(u=ai(u,l,t));const f=vi(e,r,i),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function io(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 l=i.get(s.parentId)?.expandedRect??qe(a),c=li(l,s.rect);i.set(s.parentId,{expandedRect:c,parent:a})}return i.size>0&&i.forEach(({expandedRect:s,parent:a},l)=>{const c=a.internals.positionAbsolute,d=Ne(a),u=a.origin??o,f=s.x<c.x?Math.round(Math.abs(c.x-s.x)):0,h=s.y<c.y?Math.round(Math.abs(c.y-s.y)):0,g=Math.max(d.width,Math.round(s.width)),y=Math.max(d.height,Math.round(s.height)),w=(g-d.width)*u[0],m=(y-d.height)*u[1];(f>0||h>0||w||m)&&(r.push({id:l,type:"position",position:{x:a.position.x-f+w,y:a.position.y-h+m}}),n.get(l)?.forEach(b=>{e.some(p=>p.id===b.id)||r.push({id:b.id,type:"position",position:{x:b.position.x+f,y:b.position.y+h}})})),(d.width<s.width||d.height<s.height||f||h)&&r.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:g+(f?u[0]*f-w:0),height:y+(h?u[1]*h-m:0)}})}),r}function kd(e,t,n,o,r,i,s){const a=o?.querySelector(".xyflow__viewport");let l=!1;if(!a)return{changes:[],updatedInternals:l};const c=[],d=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(d.transform),f=[];for(const h of e.values()){const g=t.get(h.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),l=!0;continue}const y=eo(h.nodeElement),w=g.measured.width!==y.width||g.measured.height!==y.height;if(!!(y.width&&y.height&&(w||!g.internals.handleBounds||h.force))){const b=h.nodeElement.getBoundingClientRect(),p=Ue(g.extent)?g.extent:i;let{positionAbsolute:x}=g.internals;g.parentId&&g.extent==="parent"?x=ai(x,y,t.get(g.parentId)):p&&(x=Le(x,p,y));const S={...g,measured:y,internals:{...g.internals,positionAbsolute:x,handleBounds:{source:Lo("source",h.nodeElement,b,u,g.id),target:Lo("target",h.nodeElement,b,u,g.id)}}};t.set(g.id,S),g.parentId&&ro(S,t,n,{nodeOrigin:r,zIndexMode:s}),l=!0,w&&(c.push({id:g.id,type:"dimensions",dimensions:y}),g.expandParent&&g.parentId&&f.push({id:g.id,parentId:g.parentId,rect:qe(S,r)}))}}if(f.length>0){const h=io(f,t,n,r);c.push(...h)}return{changes:c,updatedInternals:l}}async function Ad({delta:e,panZoom:t,transform:n,translateExtent:o,width:r,height:i}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const s=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[r,i]],o),a=!!s&&(s.x!==n[0]||s.y!==n[1]||s.k!==n[2]);return Promise.resolve(a)}function Yo(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 l=o.get(s)||new Map;if(o.set(s,l.set(n,t)),i){s=`${r}-${e}-${i}`;const c=o.get(s)||new Map;o.set(s,c.set(n,t))}}function bi(e,t,n){e.clear(),t.clear();for(const o of n){const{source:r,target:i,sourceHandle:s=null,targetHandle:a=null}=o,l={edgeId:o.id,source:r,target:i,sourceHandle:s,targetHandle:a},c=`${r}-${s}--${i}-${a}`,d=`${i}-${a}--${r}-${s}`;Yo("source",l,d,e,r,s),Yo("target",l,c,e,i,a),t.set(o.id,o)}}function _i(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:_i(n,t):!1}function Wo(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 Pd(e,t,n,o){const r=new Map;for(const[i,s]of e)if((s.selected||s.id===o)&&(!s.parentId||!_i(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 xn({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){const r=[];for(const[s,a]of t){const l=n.get(s)?.internals.userNode;l&&r.push({...l,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 $d({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=_t(i,t);return{x:s.x-i.x,y:s.y-i.y}}function Dd({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:r}){let i={x:null,y:null},s=0,a=new Map,l=!1,c={x:0,y:0},d=null,u=!1,f=null,h=!1,g=!1,y=null;function w({noDragClassName:b,handleSelector:p,domNode:x,isSelectable:S,nodeId:N,nodeClickDistance:_=0}){f=le(x);function I({x:R,y:V}){const{nodeLookup:v,nodeExtent:M,snapGrid:C,snapToGrid:P,nodeOrigin:k,onNodeDrag:D,onSelectionDrag:H,onError:B,updateNodePositions:L}=t();i={x:R,y:V};let z=!1;const j=a.size>1,Y=j&&M?zn(bt(a)):null,U=j&&P?$d({dragItems:a,snapGrid:C,x:R,y:V}):null;for(const[Z,F]of a){if(!v.has(Z))continue;let W={x:R-F.distance.x,y:V-F.distance.y};P&&(W=U?{x:Math.round(W.x+U.x),y:Math.round(W.y+U.y)}:_t(W,C));let Q=null;if(j&&M&&!F.extent&&Y){const{positionAbsolute:q}=F.internals,te=q.x-Y.x+M[0][0],oe=q.x+F.measured.width-Y.x2+M[1][0],ne=q.y-Y.y+M[0][1],ae=q.y+F.measured.height-Y.y2+M[1][1];Q=[[te,ne],[oe,ae]]}const{position:K,positionAbsolute:G}=si({nodeId:Z,nextPosition:W,nodeLookup:v,nodeExtent:Q||M,nodeOrigin:k,onError:B});z=z||F.position.x!==K.x||F.position.y!==K.y,F.position=K,F.internals.positionAbsolute=G}if(g=g||z,!!z&&(L(a,!0),y&&(o||D||!N&&H))){const[Z,F]=xn({nodeId:N,dragItems:a,nodeLookup:v});o?.(y,a,Z,F),D?.(y,Z,F),N||H?.(y,F)}}async function $(){if(!d)return;const{transform:R,panBy:V,autoPanSpeed:v,autoPanOnNodeDrag:M}=t();if(!M){l=!1,cancelAnimationFrame(s);return}const[C,P]=ci(c,d,v);(C!==0||P!==0)&&(i.x=(i.x??0)-C/R[2],i.y=(i.y??0)-P/R[2],await V({x:C,y:P})&&I(i)),s=requestAnimationFrame($)}function O(R){const{nodeLookup:V,multiSelectionActive:v,nodesDraggable:M,transform:C,snapGrid:P,snapToGrid:k,selectNodesOnDrag:D,onNodeDragStart:H,onSelectionDragStart:B,unselectNodesAndEdges:L}=t();u=!0,(!D||!S)&&!v&&N&&(V.get(N)?.selected||L()),S&&D&&N&&e?.(N);const z=ct(R.sourceEvent,{transform:C,snapGrid:P,snapToGrid:k,containerBounds:d});if(i=z,a=Pd(V,M,z,N),a.size>0&&(n||H||!N&&B)){const[j,Y]=xn({nodeId:N,dragItems:a,nodeLookup:V});n?.(R.sourceEvent,a,j,Y),H?.(R.sourceEvent,j,Y),N||B?.(R.sourceEvent,Y)}}const A=Br().clickDistance(_).on("start",R=>{const{domNode:V,nodeDragThreshold:v,transform:M,snapGrid:C,snapToGrid:P}=t();d=V?.getBoundingClientRect()||null,h=!1,g=!1,y=R.sourceEvent,v===0&&O(R),i=ct(R.sourceEvent,{transform:M,snapGrid:C,snapToGrid:P,containerBounds:d}),c=ge(R.sourceEvent,d)}).on("drag",R=>{const{autoPanOnNodeDrag:V,transform:v,snapGrid:M,snapToGrid:C,nodeDragThreshold:P,nodeLookup:k}=t(),D=ct(R.sourceEvent,{transform:v,snapGrid:M,snapToGrid:C,containerBounds:d});if(y=R.sourceEvent,(R.sourceEvent.type==="touchmove"&&R.sourceEvent.touches.length>1||N&&!k.has(N))&&(h=!0),!h){if(!l&&V&&u&&(l=!0,$()),!u){const H=ge(R.sourceEvent,d),B=H.x-c.x,L=H.y-c.y;Math.sqrt(B*B+L*L)>P&&O(R)}(i.x!==D.xSnapped||i.y!==D.ySnapped)&&a&&u&&(c=ge(R.sourceEvent,d),I(D))}}).on("end",R=>{if(!(!u||h)&&(l=!1,u=!1,cancelAnimationFrame(s),a.size>0)){const{nodeLookup:V,updateNodePositions:v,onNodeDragStop:M,onSelectionDragStop:C}=t();if(g&&(v(a,!1),g=!1),r||M||!N&&C){const[P,k]=xn({nodeId:N,dragItems:a,nodeLookup:V,dragging:!1});r?.(R.sourceEvent,a,P,k),M?.(R.sourceEvent,P,k),N||C?.(R.sourceEvent,k)}}}).filter(R=>{const V=R.target;return!R.button&&(!b||!Wo(V,`.${b}`,x))&&(!p||Wo(V,p,x))});f.call(A)}function m(){f?.on(".drag",null)}return{update:w,destroy:m}}function Td(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())pt(r,qe(i))>0&&o.push(i);return o}const Rd=250;function zd(e,t,n,o){let r=[],i=1/0;const s=Td(e,n,t+Rd);for(const a of s){const l=[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]];for(const c of l){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:d,y:u}=Be(a,c,c.position,!0),f=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(u-e.y,2));f>t||(f<i?(r=[{...c,x:d,y:u}],i=f):f===i&&r.push({...c,x:d,y:u}))}}if(!r.length)return null;if(r.length>1){const a=o.type==="source"?"target":"source";return r.find(l=>l.type===a)??r[0]}return r[0]}function Ei(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??[]],l=(n?a?.find(c=>c.id===n):a?.[0])??null;return l&&i?{...l,...Be(s,l,l.position,!0)}:l}function Ni(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function Hd(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Si=()=>!0;function Ld(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:r,edgeUpdaterType:i,isTarget:s,domNode:a,nodeLookup:l,lib:c,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:h,onConnectStart:g,onConnect:y,onConnectEnd:w,isValidConnection:m=Si,onReconnectEnd:b,updateConnection:p,getTransform:x,getFromHandle:S,autoPanSpeed:N,dragThreshold:_=1,handleDomNode:I}){const $=fi(e.target);let O=0,A;const{x:R,y:V}=ge(e),v=Ni(i,I),M=a?.getBoundingClientRect();let C=!1;if(!M||!v)return;const P=Ei(r,v,o,l,t);if(!P)return;let k=ge(e,M),D=!1,H=null,B=!1,L=null;function z(){if(!d||!M)return;const[K,G]=ci(k,M,N);f({x:K,y:G}),O=requestAnimationFrame(z)}const j={...P,nodeId:r,type:v,position:P.position},Y=l.get(r);let Z={inProgress:!0,isValid:null,from:Be(Y,j,X.Left,!0),fromHandle:j,fromPosition:j.position,fromNode:Y,to:k,toHandle:null,toPosition:To[j.position],toNode:null,pointer:k};function F(){C=!0,p(Z),g?.(e,{nodeId:r,handleId:o,handleType:v})}_===0&&F();function W(K){if(!C){const{x:ae,y:Se}=ge(K),ve=ae-R,Ae=Se-V;if(!(ve*ve+Ae*Ae>_*_))return;F()}if(!S()||!j){Q(K);return}const G=x();k=ge(K,M),A=zd(Et(k,G,!1,[1,1]),n,l,j),D||(z(),D=!0);const q=Ci(K,{handle:A,connectionMode:t,fromNodeId:r,fromHandleId:o,fromType:s?"target":"source",isValidConnection:m,doc:$,lib:c,flowId:u,nodeLookup:l});L=q.handleDomNode,H=q.connection,B=Hd(!!A,q.isValid);const te=l.get(r),oe=te?Be(te,j,X.Left,!0):Z.from,ne={...Z,from:oe,isValid:B,to:q.toHandle&&B?Ut({x:q.toHandle.x,y:q.toHandle.y},G):k,toHandle:q.toHandle,toPosition:B&&q.toHandle?q.toHandle.position:To[j.position],toNode:q.toHandle?l.get(q.toHandle.nodeId):null,pointer:k};p(ne),Z=ne}function Q(K){if(!("touches"in K&&K.touches.length>0)){if(C){(A||L)&&H&&B&&y?.(H);const{inProgress:G,...q}=Z,te={...q,toPosition:Z.toHandle?Z.toPosition:null};w?.(K,te),i&&b?.(K,te)}h(),cancelAnimationFrame(O),D=!1,B=!1,H=null,L=null,$.removeEventListener("mousemove",W),$.removeEventListener("mouseup",Q),$.removeEventListener("touchmove",W),$.removeEventListener("touchend",Q)}}$.addEventListener("mousemove",W),$.addEventListener("mouseup",Q),$.addEventListener("touchmove",W),$.addEventListener("touchend",Q)}function Ci(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:r,fromType:i,doc:s,lib:a,flowId:l,isValidConnection:c=Si,nodeLookup:d}){const u=i==="target",f=t?s.querySelector(`.${a}-flow__handle[data-id="${l}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:h,y:g}=ge(e),y=s.elementFromPoint(h,g),w=y?.classList.contains(`${a}-flow__handle`)?y:f,m={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const b=Ni(void 0,w),p=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),S=w.classList.contains("connectable"),N=w.classList.contains("connectableend");if(!p||!b)return m;const _={source:u?p:o,sourceHandle:u?x:r,target:u?o:p,targetHandle:u?r:x};m.connection=_;const $=S&&N&&(n===He.Strict?u&&b==="source"||!u&&b==="target":p!==o||x!==r);m.isValid=$&&c(_),m.toHandle=Ei(p,b,x,d,n,!0)}return m}const Vn={onPointerDown:Ld,isValid:Ci};function Bd({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const r=le(e);function i({translateExtent:a,width:l,height:c,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const g=p=>{if(p.sourceEvent.type!=="wheel"||!t)return;const x=n(),S=p.sourceEvent.ctrlKey&&mt()?10:1,N=-p.sourceEvent.deltaY*(p.sourceEvent.deltaMode===1?.05:p.sourceEvent.deltaMode?1:.002)*d,_=x[2]*Math.pow(2,N*S);t.scaleTo(_)};let y=[0,0];const w=p=>{(p.sourceEvent.type==="mousedown"||p.sourceEvent.type==="touchstart")&&(y=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY])},m=p=>{const x=n();if(p.sourceEvent.type!=="mousemove"&&p.sourceEvent.type!=="touchmove"||!t)return;const S=[p.sourceEvent.clientX??p.sourceEvent.touches[0].clientX,p.sourceEvent.clientY??p.sourceEvent.touches[0].clientY],N=[S[0]-y[0],S[1]-y[1]];y=S;const _=o()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),I={x:x[0]-N[0]*_,y:x[1]-N[1]*_},$=[[0,0],[l,c]];t.setViewportConstrained({x:I.x,y:I.y,zoom:x[2]},$,a)},b=ei().on("start",w).on("zoom",u?m:null).on("zoom.wheel",f?g:null);r.call(b,{})}function s(){r.on("zoom",null)}return{update:i,destroy:s,pointer:de}}const sn=e=>({x:e.x,y:e.y,zoom:e.k}),wn=({x:e,y:t,zoom:n})=>nn.translate(e,t).scale(n),je=(e,t)=>e.target.closest(`.${t}`),Mi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Vd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,vn=(e,t=0,n=Vd,o=()=>{})=>{const r=typeof t=="number"&&t>0;return r||o(),r?e.transition().duration(t).ease(n).on("end",o):e},Ii=e=>{const t=e.ctrlKey&&mt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Od({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:r,panOnScrollSpeed:i,zoomOnPinch:s,onPanZoomStart:a,onPanZoom:l,onPanZoomEnd:c}){return d=>{if(je(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(d.ctrlKey&&s){const w=de(d),m=Ii(d),b=u*Math.pow(2,m);o.scaleTo(n,b,w,d);return}const f=d.deltaMode===1?20:1;let h=r===Te.Vertical?0:d.deltaX*f,g=r===Te.Horizontal?0:d.deltaY*f;!mt()&&d.shiftKey&&r!==Te.Vertical&&(h=d.deltaY*f,g=0),o.translateBy(n,-(h/u)*i,-(g/u)*i,{internal:!0});const y=sn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(d,y),e.panScrollTimeout=setTimeout(()=>{c?.(d,y),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a?.(d,y))}}function jd({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,r){const i=o.type==="wheel",s=!t&&i&&!o.ctrlKey,a=je(o,e);if(o.ctrlKey&&i&&a&&o.preventDefault(),s||a)return null;o.preventDefault(),n.call(this,o,r)}}function Fd({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{if(o.sourceEvent?.internal)return;const r=sn(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 Xd({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:r}){return i=>{e.usedRightMouseButton=!!(n&&Mi(t,e.mouseButton??0)),i.sourceEvent?.sync||o([i.transform.x,i.transform.y,i.transform.k]),r&&!i.sourceEvent?.internal&&r?.(i.sourceEvent,sn(i.transform))}}function Yd({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:r,onPaneContextMenu:i}){return s=>{if(!s.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,i&&Mi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&s.sourceEvent&&i(s.sourceEvent),e.usedRightMouseButton=!1,o(!1),r)){const a=sn(s.transform);e.prevViewport=a,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{r?.(s.sourceEvent,a)},n?150:0)}}}function Wd({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:r,zoomOnDoubleClick:i,userSelectionActive:s,noWheelClassName:a,noPanClassName:l,lib:c,connectionInProgress:d}){return u=>{const f=e||t,h=n&&u.ctrlKey,g=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(je(u,`${c}-flow__node`)||je(u,`${c}-flow__edge`)))return!0;if(!o&&!f&&!r&&!i&&!n||s||d&&!g||je(u,a)&&g||je(u,l)&&(!g||r&&g&&!e)||!n&&u.ctrlKey&&g)return!1;if(!n&&u.type==="touchstart"&&u.touches?.length>1)return u.preventDefault(),!1;if(!f&&!r&&!h&&g||!o&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(o)&&!o.includes(u.button)&&u.type==="mousedown")return!1;const y=Array.isArray(o)&&o.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||g)&&y}}function Zd({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:r,onPanZoom:i,onPanZoomStart:s,onPanZoomEnd:a,onDraggingChange:l}){const c={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),u=ei().scaleExtent([t,n]).translateExtent(o),f=le(e).call(u);b({x:r.x,y:r.y,zoom:Ge(r.zoom,t,n)},[[0,0],[d.width,d.height]],o);const h=f.on("wheel.zoom"),g=f.on("dblclick.zoom");u.wheelDelta(Ii);function y(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).transform(vn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function w({noWheelClassName:A,noPanClassName:R,onPaneContextMenu:V,userSelectionActive:v,panOnScroll:M,panOnDrag:C,panOnScrollMode:P,panOnScrollSpeed:k,preventScrolling:D,zoomOnPinch:H,zoomOnScroll:B,zoomOnDoubleClick:L,zoomActivationKeyPressed:z,lib:j,onTransformChange:Y,connectionInProgress:U,paneClickDistance:Z,selectionOnDrag:F}){v&&!c.isZoomingOrPanning&&m();const W=M&&!z&&!v;u.clickDistance(F?1/0:!he(Z)||Z<0?0:Z);const Q=W?Od({zoomPanValues:c,noWheelClassName:A,d3Selection:f,d3Zoom:u,panOnScrollMode:P,panOnScrollSpeed:k,zoomOnPinch:H,onPanZoomStart:s,onPanZoom:i,onPanZoomEnd:a}):jd({noWheelClassName:A,preventScrolling:D,d3ZoomHandler:h});if(f.on("wheel.zoom",Q,{passive:!1}),!v){const G=Fd({zoomPanValues:c,onDraggingChange:l,onPanZoomStart:s});u.on("start",G);const q=Xd({zoomPanValues:c,panOnDrag:C,onPaneContextMenu:!!V,onPanZoom:i,onTransformChange:Y});u.on("zoom",q);const te=Yd({zoomPanValues:c,panOnDrag:C,panOnScroll:M,onPaneContextMenu:V,onPanZoomEnd:a,onDraggingChange:l});u.on("end",te)}const K=Wd({zoomActivationKeyPressed:z,panOnDrag:C,zoomOnScroll:B,panOnScroll:M,zoomOnDoubleClick:L,zoomOnPinch:H,userSelectionActive:v,noPanClassName:R,noWheelClassName:A,lib:j,connectionInProgress:U});u.filter(K),L?f.on("dblclick.zoom",g):f.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function b(A,R,V){const v=wn(A),M=u?.constrain()(v,R,V);return M&&await y(M),new Promise(C=>C(M))}async function p(A,R){const V=wn(A);return await y(V,R),new Promise(v=>v(V))}function x(A){if(f){const R=wn(A),V=f.property("__zoom");(V.k!==A.zoom||V.x!==A.x||V.y!==A.y)&&u?.transform(f,R,null,{sync:!0})}}function S(){const A=f?Jr(f.node()):{x:0,y:0,k:1};return{x:A.x,y:A.y,zoom:A.k}}function N(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).scaleTo(vn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function _(A,R){return f?new Promise(V=>{u?.interpolate(R?.interpolate==="linear"?at:zt).scaleBy(vn(f,R?.duration,R?.ease,()=>V(!0)),A)}):Promise.resolve(!1)}function I(A){u?.scaleExtent(A)}function $(A){u?.translateExtent(A)}function O(A){const R=!he(A)||A<0?0:A;u?.clickDistance(R)}return{update:w,destroy:m,setViewport:p,setViewportConstrained:b,getViewport:S,scaleTo:N,scaleBy:_,setScaleExtent:I,setTranslateExtent:$,syncViewport:x,setClickDistance:O}}var Ke;(function(e){e.Line="line",e.Handle="handle"})(Ke||(Ke={}));function Gd({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:r,affectsY:i}){const s=e-t,a=n-o,l=[s>0?1:s<0?-1:0,a>0?1:a<0?-1:0];return s&&r&&(l[0]=l[0]*-1),a&&i&&(l[1]=l[1]*-1),l}function Zo(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 Ce(e,t){return Math.max(0,t-e)}function Me(e,t){return Math.max(0,e-t)}function $t(e,t,n){return Math.max(0,t-e,e-n)}function Go(e,t){return e?!t:t}function qd(e,t,n,o,r,i,s,a){let{affectsX:l,affectsY:c}=t;const{isHorizontal:d,isVertical:u}=t,f=d&&u,{xSnapped:h,ySnapped:g}=n,{minWidth:y,maxWidth:w,minHeight:m,maxHeight:b}=o,{x:p,y:x,width:S,height:N,aspectRatio:_}=e;let I=Math.floor(d?h-e.pointerX:0),$=Math.floor(u?g-e.pointerY:0);const O=S+(l?-I:I),A=N+(c?-$:$),R=-i[0]*S,V=-i[1]*N;let v=$t(O,y,w),M=$t(A,m,b);if(s){let k=0,D=0;l&&I<0?k=Ce(p+I+R,s[0][0]):!l&&I>0&&(k=Me(p+O+R,s[1][0])),c&&$<0?D=Ce(x+$+V,s[0][1]):!c&&$>0&&(D=Me(x+A+V,s[1][1])),v=Math.max(v,k),M=Math.max(M,D)}if(a){let k=0,D=0;l&&I>0?k=Me(p+I,a[0][0]):!l&&I<0&&(k=Ce(p+O,a[1][0])),c&&$>0?D=Me(x+$,a[0][1]):!c&&$<0&&(D=Ce(x+A,a[1][1])),v=Math.max(v,k),M=Math.max(M,D)}if(r){if(d){const k=$t(O/_,m,b)*_;if(v=Math.max(v,k),s){let D=0;!l&&!c||l&&!c&&f?D=Me(x+V+O/_,s[1][1])*_:D=Ce(x+V+(l?I:-I)/_,s[0][1])*_,v=Math.max(v,D)}if(a){let D=0;!l&&!c||l&&!c&&f?D=Ce(x+O/_,a[1][1])*_:D=Me(x+(l?I:-I)/_,a[0][1])*_,v=Math.max(v,D)}}if(u){const k=$t(A*_,y,w)/_;if(M=Math.max(M,k),s){let D=0;!l&&!c||c&&!l&&f?D=Me(p+A*_+R,s[1][0])/_:D=Ce(p+(c?$:-$)*_+R,s[0][0])/_,M=Math.max(M,D)}if(a){let D=0;!l&&!c||c&&!l&&f?D=Ce(p+A*_,a[1][0])/_:D=Me(p+(c?$:-$)*_,a[0][0])/_,M=Math.max(M,D)}}}$=$+($<0?M:-M),I=I+(I<0?v:-v),r&&(f?O>A*_?$=(Go(l,c)?-I:I)/_:I=(Go(l,c)?-$:$)*_:d?($=I/_,c=l):(I=$*_,l=c));const C=l?p+I:p,P=c?x+$:x;return{width:S+(l?-I:I),height:N+(c?-$:$),x:i[0]*I*(l?-1:1)+C,y:i[1]*$*(c?-1:1)+P}}const ki={width:0,height:0,x:0,y:0},Ud={...ki,pointerX:0,pointerY:0,aspectRatio:1};function Kd(e){return[[0,0],[e.measured.width,e.measured.height]]}function Qd(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,l=n[1]*s;return[[o-a,r-l],[o+i-a,r+s-l]]}function Jd({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:r}){const i=le(e);let s={controlDirection:Zo("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:c,boundaries:d,keepAspectRatio:u,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:y,shouldResize:w}){let m={...ki},b={...Ud};s={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Zo(c)};let p,x=null,S=[],N,_,I,$=!1;const O=Br().on("start",A=>{const{nodeLookup:R,transform:V,snapGrid:v,snapToGrid:M,nodeOrigin:C,paneDomNode:P}=n();if(p=R.get(t),!p)return;x=P?.getBoundingClientRect()??null;const{xSnapped:k,ySnapped:D}=ct(A.sourceEvent,{transform:V,snapGrid:v,snapToGrid:M,containerBounds:x});m={width:p.measured.width??0,height:p.measured.height??0,x:p.position.x??0,y:p.position.y??0},b={...m,pointerX:k,pointerY:D,aspectRatio:m.width/m.height},N=void 0,p.parentId&&(p.extent==="parent"||p.expandParent)&&(N=R.get(p.parentId),_=N&&p.extent==="parent"?Kd(N):void 0),S=[],I=void 0;for(const[H,B]of R)if(B.parentId===t&&(S.push({id:H,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const L=Qd(B,p,B.origin??C);I?I=[[Math.min(L[0][0],I[0][0]),Math.min(L[0][1],I[0][1])],[Math.max(L[1][0],I[1][0]),Math.max(L[1][1],I[1][1])]]:I=L}h?.(A,{...m})}).on("drag",A=>{const{transform:R,snapGrid:V,snapToGrid:v,nodeOrigin:M}=n(),C=ct(A.sourceEvent,{transform:R,snapGrid:V,snapToGrid:v,containerBounds:x}),P=[];if(!p)return;const{x:k,y:D,width:H,height:B}=m,L={},z=p.origin??M,{width:j,height:Y,x:U,y:Z}=qd(b,s.controlDirection,C,s.boundaries,s.keepAspectRatio,z,_,I),F=j!==H,W=Y!==B,Q=U!==k&&F,K=Z!==D&&W;if(!Q&&!K&&!F&&!W)return;if((Q||K||z[0]===1||z[1]===1)&&(L.x=Q?U:m.x,L.y=K?Z:m.y,m.x=L.x,m.y=L.y,S.length>0)){const oe=U-k,ne=Z-D;for(const ae of S)ae.position={x:ae.position.x-oe+z[0]*(j-H),y:ae.position.y-ne+z[1]*(Y-B)},P.push(ae)}if((F||W)&&(L.width=F&&(!s.resizeDirection||s.resizeDirection==="horizontal")?j:m.width,L.height=W&&(!s.resizeDirection||s.resizeDirection==="vertical")?Y:m.height,m.width=L.width,m.height=L.height),N&&p.expandParent){const oe=z[0]*(L.width??0);L.x&&L.x<oe&&(m.x=oe,b.x=b.x-(L.x-oe));const ne=z[1]*(L.height??0);L.y&&L.y<ne&&(m.y=ne,b.y=b.y-(L.y-ne))}const G=Gd({width:m.width,prevWidth:H,height:m.height,prevHeight:B,affectsX:s.controlDirection.affectsX,affectsY:s.controlDirection.affectsY}),q={...m,direction:G};w?.(A,q)!==!1&&($=!0,g?.(A,q),o(L,P))}).on("end",A=>{$&&(y?.(A,{...m}),r?.({...m}),$=!1)});i.call(O)}function l(){i.on(".drag",null)}return{update:a,destroy:l}}var bn={exports:{}},_n={},En={exports:{}},Nn={};var qo;function ef(){if(qo)return Nn;qo=1;var e=Nr();function t(u,f){return u===f&&(u!==0||1/u===1/f)||u!==u&&f!==f}var n=typeof Object.is=="function"?Object.is:t,o=e.useState,r=e.useEffect,i=e.useLayoutEffect,s=e.useDebugValue;function a(u,f){var h=f(),g=o({inst:{value:h,getSnapshot:f}}),y=g[0].inst,w=g[1];return i(function(){y.value=h,y.getSnapshot=f,l(y)&&w({inst:y})},[u,h,f]),r(function(){return l(y)&&w({inst:y}),u(function(){l(y)&&w({inst:y})})},[u]),s(h),h}function l(u){var f=u.getSnapshot;u=u.value;try{var h=f();return!n(u,h)}catch{return!0}}function c(u,f){return f()}var d=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?c:a;return Nn.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:d,Nn}var Uo;function tf(){return Uo||(Uo=1,En.exports=ef()),En.exports}var Ko;function nf(){if(Ko)return _n;Ko=1;var e=Nr(),t=tf();function n(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var o=typeof Object.is=="function"?Object.is:n,r=t.useSyncExternalStore,i=e.useRef,s=e.useEffect,a=e.useMemo,l=e.useDebugValue;return _n.useSyncExternalStoreWithSelector=function(c,d,u,f,h){var g=i(null);if(g.current===null){var y={hasValue:!1,value:null};g.current=y}else y=g.current;g=a(function(){function m(N){if(!b){if(b=!0,p=N,N=f(N),h!==void 0&&y.hasValue){var _=y.value;if(h(_,N))return x=_}return x=N}if(_=x,o(p,N))return _;var I=f(N);return h!==void 0&&h(_,I)?(p=N,_):(p=N,x=I)}var b=!1,p,x,S=u===void 0?null:u;return[function(){return m(d())},S===null?void 0:function(){return m(S())}]},[d,u,f,h]);var w=r(c,g[0],g[1]);return s(function(){y.hasValue=!0,y.value=w},[w]),l(w),w},_n}var Qo;function of(){return Qo||(Qo=1,bn.exports=nf()),bn.exports}var rf=of();const sf=pa(rf),af={},Jo=e=>{let t;const n=new Set,o=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(g=>g(t,h))}},r=()=>t,l={setState:o,getState:r,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(af?"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()}},c=t=e(o,r,l);return l},cf=e=>e?Jo(e):Jo,{useDebugValue:lf}=ma,{useSyncExternalStoreWithSelector:uf}=sf,df=e=>e;function Ai(e,t=df,n){const o=uf(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return lf(o),o}const er=(e,t)=>{const n=cf(e),o=(r,i=t)=>Ai(n,r,i);return Object.assign(o,n),o},ff=(e,t)=>e?er(e,t):er;function re(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 an=T.createContext(null),hf=an.Provider,Pi=xe.error001();function J(e,t){const n=T.useContext(an);if(n===null)throw new Error(Pi);return Ai(n,e,t)}function ie(){const e=T.useContext(an);if(e===null)throw new Error(Pi);return T.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const tr={display:"none"},gf={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},$i="react-flow__node-desc",Di="react-flow__edge-desc",pf="react-flow__aria-live",mf=e=>e.ariaLiveMessage,yf=e=>e.ariaLabelConfig;function xf({rfId:e}){const t=J(mf);return E.jsx("div",{id:`${pf}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:gf,children:t})}function wf({rfId:e,disableKeyboardA11y:t}){const n=J(yf);return E.jsxs(E.Fragment,{children:[E.jsx("div",{id:`${$i}-${e}`,style:tr,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),E.jsx("div",{id:`${Di}-${e}`,style:tr,children:n["edge.a11yDescription.default"]}),!t&&E.jsx(xf,{rfId:e})]})}const Nt=T.forwardRef(({position:e="top-left",children:t,className:n,style:o,...r},i)=>{const s=`${e}`.split("-");return E.jsx("div",{className:se(["react-flow__panel",n,...s]),style:o,ref:i,...r,children:t})});Nt.displayName="Panel";function vf({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:E.jsx(Nt,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:E.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const bf=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}},Dt=e=>e.id;function _f(e,t){return re(e.selectedNodes.map(Dt),t.selectedNodes.map(Dt))&&re(e.selectedEdges.map(Dt),t.selectedEdges.map(Dt))}function Ef({onSelectionChange:e}){const t=ie(),{selectedNodes:n,selectedEdges:o}=J(bf,_f);return T.useEffect(()=>{const r={nodes:n,edges:o};e?.(r),t.getState().onSelectionChangeHandlers.forEach(i=>i(r))},[n,o,e]),null}const Nf=e=>!!e.onSelectionChangeHandlers;function Sf({onSelectionChange:e}){const t=J(Nf);return e||t?E.jsx(Ef,{onSelectionChange:e}):null}const On=typeof window<"u"?T.useLayoutEffect:T.useEffect,Ti=[0,0],Cf={x:0,y:0,zoom:1},Mf=["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"],nr=[...Mf,"rfId"],If=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}),or={translateExtent:ht,nodeOrigin:Ti,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function kf(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:r,setTranslateExtent:i,setNodeExtent:s,reset:a,setDefaultNodesAndEdges:l}=J(If,re),c=ie();On(()=>(l(e.defaultNodes,e.defaultEdges),()=>{d.current=or,a()}),[]);const d=T.useRef(or);return On(()=>{for(const u of nr){const f=e[u],h=d.current[u];f!==h&&(typeof e[u]>"u"||(u==="nodes"?t(f):u==="edges"?n(f):u==="minZoom"?o(f):u==="maxZoom"?r(f):u==="translateExtent"?i(f):u==="nodeExtent"?s(f):u==="ariaLabelConfig"?c.setState({ariaLabelConfig:dd(f)}):u==="fitView"?c.setState({fitViewQueued:f}):u==="fitViewOptions"?c.setState({fitViewOptions:f}):c.setState({[u]:f})))}d.current=e},nr.map(u=>e[u])),null}function rr(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Af(e){const[t,n]=T.useState(e==="system"?null:e);return T.useEffect(()=>{if(e!=="system"){n(e);return}const o=rr(),r=()=>n(o?.matches?"dark":"light");return r(),o?.addEventListener("change",r),()=>{o?.removeEventListener("change",r)}},[e]),t!==null?t:rr()?.matches?"dark":"light"}const ir=typeof document<"u"?document:null;function yt(e=null,t={target:ir,actInsideInputWithModifier:!0}){const[n,o]=T.useState(!1),r=T.useRef(!1),i=T.useRef(new Set([])),[s,a]=T.useMemo(()=>{if(e!==null){const c=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
2
2
  `).replace(`
3
3
 
4
4
  `,`
@@ -1,2 +1,2 @@
1
- import{B as I,C as S,b as u,u as f,j as t,a as _}from"./index-Ci36vcFD.js";function T(e){return e.filename??e.url??e.image}let M=0;function y(){return`pb_${Date.now()}_${++M}`}async function A(e){const n=y(),s=e.type.startsWith("image/")?"image":"file";if(s==="image"){const r=await new Promise(o=>{const l=new FileReader;l.onload=()=>o(l.result),l.readAsDataURL(e)});return{id:n,kind:s,name:e.name,mimeType:e.type,size:e.size,dataUrl:r}}return{id:n,kind:s,name:e.name,mimeType:e.type,size:e.size}}const p=I()((e,n)=>({messages:[],scope:{kind:"draft"},draft:"",model:"gpt-5.5",loading:!1,attachments:[],error:null,setDraft:s=>e({draft:s}),setModel:s=>e({model:s}),clearMessages:()=>e({messages:[],error:null}),clearImageScope:()=>e({scope:{kind:"draft"}}),setScopeFromImage:s=>{const r=T(s);e({scope:{kind:"image",imageKey:r}})},addAttachments:async s=>{const r=await Promise.all(s.map(A));e(o=>({attachments:[...o.attachments,...r]}))},removeAttachment:s=>{e(r=>({attachments:r.attachments.filter(o=>o.id!==s)}))},sendMessage:async s=>{const{draft:r,attachments:o,model:l,messages:i}=n(),d=r.trim()||(o.length>0?"Use the attached file as context and help with the prompt":"");if(!d&&o.length===0)return;const c={id:y(),role:"user",content:d,attachments:o.length>0?[...o]:void 0};e(m=>({messages:[...m.messages,c],draft:"",attachments:[],loading:!0,error:null}));try{const m=[...i,c].map(x=>({role:x.role,content:x.content,attachments:x.attachments?.map(h=>({kind:h.kind,name:h.name,mimeType:h.mimeType,size:h.size,dataUrl:h.dataUrl,text:h.text}))})),g=await S({model:l,messages:m,context:s}),j={id:y(),role:"assistant",content:g.message.content};e(x=>({messages:[...x.messages,j],loading:!1}))}catch(m){const g=m instanceof Error?m.message:"Prompt builder request failed";e({loading:!1,error:g})}}}));function P(e){return e?.filename??e?.url??e?.image??null}function C(e){const n=e.split(/[\\/]/).pop()??e;return n.length<=32?n:`${n.slice(0,14)}...${n.slice(-12)}`}function E(){const e=p(c=>c.scope),n=p(c=>c.clearImageScope),s=u(c=>c.currentImage),r=u(c=>c.history),{t:o}=f();if(e.kind==="draft")return t.jsx("span",{className:"prompt-builder__scope",children:o("promptBuilder.scopeDraft")});const i=P(s)===e.imageKey?s:r.find(c=>P(c)===e.imageKey)??null;if(!i)return t.jsx("span",{className:"prompt-builder__scope",children:o("promptBuilder.scopeDraft")});const d=o("promptBuilder.scopeImage",{name:C(e.imageKey)||o("promptBuilder.scopeImageFallback")});return t.jsxs("div",{className:"prompt-builder__scope-card",children:[t.jsx("img",{className:"prompt-builder__scope-thumb",src:i.thumb||i.url||i.image,alt:""}),t.jsx("span",{className:"prompt-builder__scope-name",children:d}),t.jsx("button",{type:"button",className:"prompt-builder__scope-remove",onClick:n,"aria-label":o("promptBuilder.removeScopeImage"),title:o("promptBuilder.removeScopeImage"),children:"×"})]})}const K=["gpt-5.5","gpt-5.4","gpt-5.4-mini"];function $(){const e=p(l=>l.model),n=p(l=>l.setModel),[s,r]=_.useState(!1),{t:o}=f();return t.jsxs("div",{className:"prompt-builder__model-picker",onBlur:l=>{const i=l.relatedTarget;i instanceof Node&&l.currentTarget.contains(i)||r(!1)},children:[t.jsx("button",{type:"button",className:"prompt-builder__model-trigger","aria-label":o("promptBuilder.model"),"aria-haspopup":"listbox","aria-expanded":s,onClick:()=>r(l=>!l),onKeyDown:l=>{l.key==="Escape"&&r(!1)},children:t.jsx("span",{children:e})}),s&&t.jsx("div",{className:"prompt-builder__model-menu",role:"listbox","aria-label":o("promptBuilder.model"),children:K.map(l=>t.jsx("button",{type:"button",role:"option","aria-selected":l===e,className:`prompt-builder__model-option${l===e?" active":""}`,onClick:()=>{n(l),r(!1)},children:l},l))})]})}const D={"Brief Intent Summary":"summary","Final Prompt - Korean":"ko","Final Prompt - English":"en",Notes:"notes"},F=/^(Brief Intent Summary|Final Prompt - Korean|Final Prompt - English|Notes):\s*(.*)$/gim;function w(e){const n=e.trim();return(n.match(/^```(?:[a-zA-Z0-9_-]+)?\s*([\s\S]*?)\s*```$/)?.[1]??n).trim()}function R(e){const n={},s=Array.from(e.matchAll(F));for(let r=0;r<s.length;r+=1){const o=s[r],l=o[1]??"",i=D[l];if(!i||typeof o.index!="number")continue;const d=o[2]?.trim()??"",c=o.index+o[0].length,m=s[r+1]?.index??e.length,g=w([d,e.slice(c,m)].filter(Boolean).join(`
1
+ import{B as I,C as S,b as u,u as f,j as t,a as _}from"./index-BAN6lKgf.js";function T(e){return e.filename??e.url??e.image}let M=0;function y(){return`pb_${Date.now()}_${++M}`}async function A(e){const n=y(),s=e.type.startsWith("image/")?"image":"file";if(s==="image"){const r=await new Promise(o=>{const l=new FileReader;l.onload=()=>o(l.result),l.readAsDataURL(e)});return{id:n,kind:s,name:e.name,mimeType:e.type,size:e.size,dataUrl:r}}return{id:n,kind:s,name:e.name,mimeType:e.type,size:e.size}}const p=I()((e,n)=>({messages:[],scope:{kind:"draft"},draft:"",model:"gpt-5.5",loading:!1,attachments:[],error:null,setDraft:s=>e({draft:s}),setModel:s=>e({model:s}),clearMessages:()=>e({messages:[],error:null}),clearImageScope:()=>e({scope:{kind:"draft"}}),setScopeFromImage:s=>{const r=T(s);e({scope:{kind:"image",imageKey:r}})},addAttachments:async s=>{const r=await Promise.all(s.map(A));e(o=>({attachments:[...o.attachments,...r]}))},removeAttachment:s=>{e(r=>({attachments:r.attachments.filter(o=>o.id!==s)}))},sendMessage:async s=>{const{draft:r,attachments:o,model:l,messages:i}=n(),d=r.trim()||(o.length>0?"Use the attached file as context and help with the prompt":"");if(!d&&o.length===0)return;const c={id:y(),role:"user",content:d,attachments:o.length>0?[...o]:void 0};e(m=>({messages:[...m.messages,c],draft:"",attachments:[],loading:!0,error:null}));try{const m=[...i,c].map(x=>({role:x.role,content:x.content,attachments:x.attachments?.map(h=>({kind:h.kind,name:h.name,mimeType:h.mimeType,size:h.size,dataUrl:h.dataUrl,text:h.text}))})),g=await S({model:l,messages:m,context:s}),j={id:y(),role:"assistant",content:g.message.content};e(x=>({messages:[...x.messages,j],loading:!1}))}catch(m){const g=m instanceof Error?m.message:"Prompt builder request failed";e({loading:!1,error:g})}}}));function P(e){return e?.filename??e?.url??e?.image??null}function C(e){const n=e.split(/[\\/]/).pop()??e;return n.length<=32?n:`${n.slice(0,14)}...${n.slice(-12)}`}function E(){const e=p(c=>c.scope),n=p(c=>c.clearImageScope),s=u(c=>c.currentImage),r=u(c=>c.history),{t:o}=f();if(e.kind==="draft")return t.jsx("span",{className:"prompt-builder__scope",children:o("promptBuilder.scopeDraft")});const i=P(s)===e.imageKey?s:r.find(c=>P(c)===e.imageKey)??null;if(!i)return t.jsx("span",{className:"prompt-builder__scope",children:o("promptBuilder.scopeDraft")});const d=o("promptBuilder.scopeImage",{name:C(e.imageKey)||o("promptBuilder.scopeImageFallback")});return t.jsxs("div",{className:"prompt-builder__scope-card",children:[t.jsx("img",{className:"prompt-builder__scope-thumb",src:i.thumb||i.url||i.image,alt:""}),t.jsx("span",{className:"prompt-builder__scope-name",children:d}),t.jsx("button",{type:"button",className:"prompt-builder__scope-remove",onClick:n,"aria-label":o("promptBuilder.removeScopeImage"),title:o("promptBuilder.removeScopeImage"),children:"×"})]})}const K=["gpt-5.5","gpt-5.4","gpt-5.4-mini"];function $(){const e=p(l=>l.model),n=p(l=>l.setModel),[s,r]=_.useState(!1),{t:o}=f();return t.jsxs("div",{className:"prompt-builder__model-picker",onBlur:l=>{const i=l.relatedTarget;i instanceof Node&&l.currentTarget.contains(i)||r(!1)},children:[t.jsx("button",{type:"button",className:"prompt-builder__model-trigger","aria-label":o("promptBuilder.model"),"aria-haspopup":"listbox","aria-expanded":s,onClick:()=>r(l=>!l),onKeyDown:l=>{l.key==="Escape"&&r(!1)},children:t.jsx("span",{children:e})}),s&&t.jsx("div",{className:"prompt-builder__model-menu",role:"listbox","aria-label":o("promptBuilder.model"),children:K.map(l=>t.jsx("button",{type:"button",role:"option","aria-selected":l===e,className:`prompt-builder__model-option${l===e?" active":""}`,onClick:()=>{n(l),r(!1)},children:l},l))})]})}const D={"Brief Intent Summary":"summary","Final Prompt - Korean":"ko","Final Prompt - English":"en",Notes:"notes"},F=/^(Brief Intent Summary|Final Prompt - Korean|Final Prompt - English|Notes):\s*(.*)$/gim;function w(e){const n=e.trim();return(n.match(/^```(?:[a-zA-Z0-9_-]+)?\s*([\s\S]*?)\s*```$/)?.[1]??n).trim()}function R(e){const n={},s=Array.from(e.matchAll(F));for(let r=0;r<s.length;r+=1){const o=s[r],l=o[1]??"",i=D[l];if(!i||typeof o.index!="number")continue;const d=o[2]?.trim()??"",c=o.index+o[0].length,m=s[r+1]?.index??e.length,g=w([d,e.slice(c,m)].filter(Boolean).join(`
2
2
  `));g&&(n[i]=g)}return n}function z(e){const n=R(e),s=[];return n.ko&&s.push({language:"ko",heading:"Final Prompt - Korean",text:n.ko}),n.en&&s.push({language:"en",heading:"Final Prompt - English",text:n.en}),s.length===0?null:{summary:n.summary,prompts:s,notes:n.notes}}function U({messageId:e,prompt:n}){const s=u(m=>m.setPrompt),r=u(m=>m.insertPromptToComposer),o=u(m=>m.showToast),{t:l}=f(),i=n.language==="ko"?l("promptBuilder.finalKoreanPrompt"):l("promptBuilder.finalEnglishPrompt"),d=()=>{s(n.text),o(l("promptBuilder.applied"))},c=()=>{r({id:`builder_${e}_${n.language}`,name:i,text:n.text,placement:"after"}),o(l("promptBuilder.inserted"))};return t.jsxs("section",{className:"prompt-builder__structured-card","aria-label":i,children:[t.jsxs("div",{className:"prompt-builder__structured-card-header",children:[t.jsx("strong",{children:i}),t.jsx("span",{children:n.language.toUpperCase()})]}),t.jsx("p",{children:n.text}),t.jsxs("div",{className:"prompt-builder__structured-actions",children:[t.jsx("button",{type:"button",onClick:d,children:l("promptBuilder.applyToPrompt")}),t.jsx("button",{type:"button",onClick:c,children:l("promptBuilder.insertAsBlock")})]})]})}function L(e){return e.kind==="image"?"IMG":e.kind==="text"?"TXT":"FILE"}function O({message:e}){const{t:n}=f(),s=e.role==="assistant"?z(e.content):null;return t.jsxs("article",{className:`prompt-builder__message prompt-builder__message--${e.role}`,children:[t.jsx("div",{className:"prompt-builder__message-role",children:e.role==="user"?n("promptBuilder.user"):n("promptBuilder.assistant")}),s?t.jsxs("div",{className:"prompt-builder__structured-prompts",children:[s.summary?t.jsx("p",{className:"prompt-builder__structured-summary",children:s.summary}):null,s.prompts.map(r=>t.jsx(U,{messageId:e.id,prompt:r},`${e.id}-${r.language}`)),s.notes?t.jsx("p",{className:"prompt-builder__structured-notes",children:s.notes}):null]}):t.jsx("p",{children:e.content}),e.attachments&&e.attachments.length>0?t.jsx("div",{className:"prompt-builder__message-attachments",children:e.attachments.map(r=>t.jsxs("span",{className:"prompt-builder__message-attachment",children:[r.kind==="image"&&r.dataUrl?t.jsx("img",{src:r.dataUrl,alt:""}):t.jsx("span",{children:L(r)}),t.jsx("em",{children:r.name})]},r.id))}):null]})}function q(){const e=p(o=>o.messages),n=p(o=>o.loading),s=_.useRef(null),{t:r}=f();return _.useEffect(()=>{const o=s.current;o&&(o.scrollTop=o.scrollHeight)},[e.length,n]),t.jsxs("div",{ref:s,className:"prompt-builder__messages",children:[e.length===0&&t.jsx("div",{className:"prompt-builder__empty",children:r("promptBuilder.empty")}),e.map(o=>t.jsx(O,{message:o},o.id)),n&&t.jsxs("div",{className:"prompt-builder__thinking",role:"status","aria-live":"polite",children:[t.jsxs("span",{className:"prompt-builder__thinking-dots","aria-hidden":"true",children:[t.jsx("span",{}),t.jsx("span",{}),t.jsx("span",{})]}),t.jsx("span",{children:r("promptBuilder.thinking")})]})]})}function G(e){return e.kind==="image"?"IMG":e.kind==="text"?"TXT":"FILE"}function H(){const e=p(r=>r.attachments),n=p(r=>r.removeAttachment),{t:s}=f();return e.length===0?null:t.jsx("div",{className:"prompt-builder__attachments",children:e.map(r=>t.jsxs("span",{className:"prompt-builder__attachment",children:[r.kind==="image"&&r.dataUrl?t.jsx("img",{src:r.dataUrl,alt:""}):t.jsx("span",{children:G(r)}),t.jsx("em",{children:r.name}),t.jsx("button",{type:"button",onClick:()=>n(r.id),"aria-label":s("promptBuilder.removeAttachment",{name:r.name}),title:s("promptBuilder.removeAttachment",{name:r.name}),children:"×"})]},r.id))})}function X(){const e=p(a=>a.draft),n=p(a=>a.setDraft),s=p(a=>a.loading),r=p(a=>a.addAttachments),o=p(a=>a.sendMessage),l=p(a=>a.messages),i=p(a=>a.clearMessages),d=p(a=>a.attachments),c=u(a=>a.prompt),m=u(a=>a.insertedPrompts),g=u(a=>a.quality),j=u(a=>a.getResolvedSize),x=u(a=>a.currentImage),h=_.useRef(null),{t:b}=f(),B=()=>{!e.trim()&&d.length===0||s||o({currentPrompt:c,insertedPrompts:m.map(a=>({name:a.name,text:a.text})),settings:{quality:g,size:j()},currentResultPrompt:x?.prompt??null})},N=a=>{a.length!==0&&r(a)},v=a=>{const k=Array.from(a.clipboardData?.files??[]);k.length!==0&&(a.preventDefault(),N(k))};return t.jsxs("div",{className:"prompt-builder__composer",children:[t.jsx(H,{}),t.jsx("textarea",{value:e,placeholder:b("promptBuilder.placeholder"),onChange:a=>n(a.target.value),onPaste:v,onKeyDown:a=>{a.key==="Enter"&&(a.ctrlKey||a.metaKey)&&(a.preventDefault(),B())}}),t.jsx("input",{ref:h,type:"file",multiple:!0,hidden:!0,onChange:a=>{N(Array.from(a.target.files??[])),a.target.value=""}}),t.jsxs("div",{className:"prompt-builder__composer-actions",children:[t.jsx("button",{type:"button",className:"prompt-builder__attach",onClick:()=>h.current?.click(),disabled:s,"aria-label":b("promptBuilder.attach"),title:b("promptBuilder.attach"),children:"+"}),t.jsx("button",{type:"button",className:"prompt-builder__clear",onClick:i,disabled:l.length===0||s,children:b("promptBuilder.clear")}),t.jsx("button",{type:"button",className:"prompt-builder__send",onClick:B,disabled:!e.trim()&&d.length===0||s,children:b(s?"promptBuilder.sending":"promptBuilder.send")})]})]})}function Y({variant:e="panel"}){const{t:n}=f();return t.jsxs("section",{className:`prompt-builder prompt-builder--${e}`,"aria-label":n("promptBuilder.title"),children:[t.jsxs("div",{className:"prompt-builder__header",children:[t.jsxs("div",{children:[t.jsx("span",{className:"section-title",children:n("promptBuilder.title")}),t.jsx(E,{})]}),t.jsx("div",{className:"prompt-builder__header-actions",children:t.jsx($,{})})]}),t.jsx(q,{}),t.jsx(X,{})]})}export{Y as PromptBuilderPanel};